#line 539 "../grecs/build-aux/getopt.m4"
/* -*- buffer-read-only: t -*- vi: set ro:
   THIS FILE IS GENERATED AUTOMATICALLY.  PLEASE DO NOT EDIT.
*/
#line 1 "cmdline.opt"
/* This file is part of GNU Pies. -*- c -*-
   Copyright (C) 2008-2019 Sergey Poznyakoff

   GNU Pies is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   GNU Pies is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with GNU Pies.  If not, see <http://www.gnu.org/licenses/>. */

#line 214 "cmdline.opt"
#ifdef HAVE_CONFIG_H
#line 214
# include <config.h>
#line 214
#endif
#line 214
#ifdef HAVE_GETOPT_H
#line 214
# include <getopt.h>
#line 214
#endif
#line 214
#include <unistd.h>
#line 214
#include <stdlib.h>
#line 214
#include <grecs.h>
#line 214
#include <grecs/opt.h>
#line 214
#ifndef EX_USAGE
#line 214
# define EX_USAGE 64
#line 214
#endif
#line 214
/* Option codes */
#line 214
enum {
#line 214
	_OPTION_INIT=255,
#line 32 "cmdline.opt"
	OPTION_CONFIG_HELP,
#line 45 "cmdline.opt"
	OPTION_FORCE,
#line 51 "cmdline.opt"
	OPTION_FOREGROUND,
#line 58 "cmdline.opt"
	OPTION_NO_INIT,
#line 73 "cmdline.opt"
	OPTION_INSTANCE,
#line 79 "cmdline.opt"
	OPTION_RATE,
#line 91 "cmdline.opt"
	OPTION_STDERR,
#line 97 "cmdline.opt"
	OPTION_SYNTAX,
#line 108 "cmdline.opt"
	OPTION_SYSLOG,
#line 181 "cmdline.opt"
	OPTION_DUMP_DEPMAP,
#line 188 "cmdline.opt"
	OPTION_TRACE_DEPEND,
#line 195 "cmdline.opt"
	OPTION_TRACE_PREREQ,
#line 202 "cmdline.opt"
	OPTION_SOURCE_INFO,
#line 214 "cmdline.opt"
	OPTION_USAGE,
#line 214 "cmdline.opt"
	MAX_OPTION
#line 214
};
#line 214
#ifdef HAVE_GETOPT_LONG
#line 214
static struct option long_options[] = {
#line 26 "cmdline.opt"
	{ "config-file", required_argument, 0, 'c' },
#line 32 "cmdline.opt"
	{ "config-help", no_argument, 0, OPTION_CONFIG_HELP },
#line 45 "cmdline.opt"
	{ "force", no_argument, 0, OPTION_FORCE },
#line 51 "cmdline.opt"
	{ "foreground", no_argument, 0, OPTION_FOREGROUND },
#line 58 "cmdline.opt"
	{ "no-init", no_argument, 0, OPTION_NO_INIT },
#line 64 "cmdline.opt"
	{ "inetd", no_argument, 0, 'i' },
#line 73 "cmdline.opt"
	{ "instance", required_argument, 0, OPTION_INSTANCE },
#line 79 "cmdline.opt"
	{ "rate", required_argument, 0, OPTION_RATE },
#line 91 "cmdline.opt"
	{ "stderr", no_argument, 0, OPTION_STDERR },
#line 97 "cmdline.opt"
	{ "syntax", required_argument, 0, OPTION_SYNTAX },
#line 108 "cmdline.opt"
	{ "syslog", no_argument, 0, OPTION_SYSLOG },
#line 114 "cmdline.opt"
	{ "lint", no_argument, 0, 't' },
#line 121 "cmdline.opt"
	{ "telinit", no_argument, 0, 'T' },
#line 130 "cmdline.opt"
	{ "include-directory", required_argument, 0, 'I' },
#line 136 "cmdline.opt"
	{ "define", required_argument, 0, 'D' },
#line 142 "cmdline.opt"
	{ "undefine", required_argument, 0, 'U' },
#line 150 "cmdline.opt"
	{ "reload", no_argument, 0, 'r' },
#line 158 "cmdline.opt"
	{ "restart-component", no_argument, 0, 'R' },
#line 165 "cmdline.opt"
	{ "status", no_argument, 0, 's' },
#line 172 "cmdline.opt"
	{ "stop", no_argument, 0, 'S' },
#line 181 "cmdline.opt"
	{ "dump-depmap", no_argument, 0, OPTION_DUMP_DEPMAP },
#line 188 "cmdline.opt"
	{ "trace-depend", no_argument, 0, OPTION_TRACE_DEPEND },
#line 195 "cmdline.opt"
	{ "trace-prereq", no_argument, 0, OPTION_TRACE_PREREQ },
#line 202 "cmdline.opt"
	{ "source-info", no_argument, 0, OPTION_SOURCE_INFO },
#line 208 "cmdline.opt"
	{ "debug", required_argument, 0, 'x' },
#line 214 "cmdline.opt"
	{ "help", no_argument, 0, 'h' },
#line 214 "cmdline.opt"
	{ "usage", no_argument, 0, OPTION_USAGE },
#line 214 "cmdline.opt"
	{ "version", no_argument, 0, 'V' },
#line 214 "cmdline.opt"
	{0, 0, 0, 0}
#line 214
};
#line 214
#endif
#line 214

#line 214
static struct grecs_opthelp opthelp[] = {
#line 24 "cmdline.opt"
	{ NULL, NULL, 0, N_("Operation Mode") },
#line 28 "cmdline.opt"
	{
#line 28
#ifdef HAVE_GETOPT_LONG
#line 28
	  "-c, --config-file",
#line 28
#else
#line 28
	  "-c",
#line 28
#endif
#line 28
				   N_("FILE"), 0, N_("use FILE instead of the default configuration") },
#line 34 "cmdline.opt"
	{
#line 34
#ifdef HAVE_GETOPT_LONG
#line 34
	  "--config-help",
#line 34
#else
#line 34
	  "",
#line 34
#endif
#line 34
				   NULL, 0, N_("show configuration file summary") },
#line 41 "cmdline.opt"
	{
#line 41
#ifdef HAVE_GETOPT_LONG
#line 41
	  "-E",
#line 41
#else
#line 41
	  "-E",
#line 41
#endif
#line 41
				   NULL, 0, N_("preprocess config and exit") },
#line 47 "cmdline.opt"
	{
#line 47
#ifdef HAVE_GETOPT_LONG
#line 47
	  "--force",
#line 47
#else
#line 47
	  "",
#line 47
#endif
#line 47
				   NULL, 0, N_("force startup even if another instance may be running") },
#line 53 "cmdline.opt"
	{
#line 53
#ifdef HAVE_GETOPT_LONG
#line 53
	  "--foreground",
#line 53
#else
#line 53
	  "",
#line 53
#endif
#line 53
				   NULL, 0, N_("remain in foreground") },
#line 60 "cmdline.opt"
	{
#line 60
#ifdef HAVE_GETOPT_LONG
#line 60
	  "--no-init",
#line 60
#else
#line 60
	  "",
#line 60
#endif
#line 60
				   NULL, 0, N_("don't suppose SysV init mode if PID is 1") },
#line 66 "cmdline.opt"
	{
#line 66
#ifdef HAVE_GETOPT_LONG
#line 66
	  "-i, --inetd",
#line 66
#else
#line 66
	  "-i",
#line 66
#endif
#line 66
				   NULL, 0, N_("run in inetd mode") },
#line 75 "cmdline.opt"
	{
#line 75
#ifdef HAVE_GETOPT_LONG
#line 75
	  "--instance",
#line 75
#else
#line 75
	  "",
#line 75
#endif
#line 75
				   N_("NAME"), 0, N_("set instance name") },
#line 81 "cmdline.opt"
	{
#line 81
#ifdef HAVE_GETOPT_LONG
#line 81
	  "--rate",
#line 81
#else
#line 81
	  "",
#line 81
#endif
#line 81
				   N_("NUMBER"), 0, N_("set default maximum rate for inetd-style components") },
#line 93 "cmdline.opt"
	{
#line 93
#ifdef HAVE_GETOPT_LONG
#line 93
	  "--stderr",
#line 93
#else
#line 93
	  "",
#line 93
#endif
#line 93
				   NULL, 0, N_("log to stderr") },
#line 99 "cmdline.opt"
	{
#line 99
#ifdef HAVE_GETOPT_LONG
#line 99
	  "--syntax",
#line 99
#else
#line 99
	  "",
#line 99
#endif
#line 99
				   N_("{pies|meta1|inetd|inittab}"), 0, N_("expect configuration files in the given syntax") },
#line 110 "cmdline.opt"
	{
#line 110
#ifdef HAVE_GETOPT_LONG
#line 110
	  "--syslog",
#line 110
#else
#line 110
	  "",
#line 110
#endif
#line 110
				   NULL, 0, N_("log to syslog") },
#line 116 "cmdline.opt"
	{
#line 116
#ifdef HAVE_GETOPT_LONG
#line 116
	  "-t, --lint",
#line 116
#else
#line 116
	  "-t",
#line 116
#endif
#line 116
				   NULL, 0, N_("parse configuration file and exit") },
#line 123 "cmdline.opt"
	{
#line 123
#ifdef HAVE_GETOPT_LONG
#line 123
	  "-T, --telinit",
#line 123
#else
#line 123
	  "-T",
#line 123
#endif
#line 123
				   NULL, 0, N_("telinit command: run \"pies -T --help\" for help") },
#line 128 "cmdline.opt"
	{ NULL, NULL, 0, N_("Preprocessor") },
#line 132 "cmdline.opt"
	{
#line 132
#ifdef HAVE_GETOPT_LONG
#line 132
	  "-I, --include-directory",
#line 132
#else
#line 132
	  "-I",
#line 132
#endif
#line 132
				   N_("DIR"), 0, N_("add include directory") },
#line 138 "cmdline.opt"
	{
#line 138
#ifdef HAVE_GETOPT_LONG
#line 138
	  "-D, --define",
#line 138
#else
#line 138
	  "-D",
#line 138
#endif
#line 138
				   N_("NAME[=VALUE]"), 0, N_("define a preprocessor symbol NAME as having VALUE or empty") },
#line 144 "cmdline.opt"
	{
#line 144
#ifdef HAVE_GETOPT_LONG
#line 144
	  "-U, --undefine",
#line 144
#else
#line 144
	  "-U",
#line 144
#endif
#line 144
				   N_("NAME"), 0, N_("undefine a preprocessor symbol NAME") },
#line 148 "cmdline.opt"
	{ NULL, NULL, 0, N_("Component Management") },
#line 153 "cmdline.opt"
	{
#line 153
#ifdef HAVE_GETOPT_LONG
#line 153
	  "-r, --reload",
#line 153
#else
#line 153
	  "-r",
#line 153
#endif
#line 153
				   NULL, 0, N_("reload the running instance of pies") },
#line 160 "cmdline.opt"
	{
#line 160
#ifdef HAVE_GETOPT_LONG
#line 160
	  "-R, --restart-component",
#line 160
#else
#line 160
	  "-R",
#line 160
#endif
#line 160
				   NULL, 0, N_("restart components named in the command line") },
#line 167 "cmdline.opt"
	{
#line 167
#ifdef HAVE_GETOPT_LONG
#line 167
	  "-s, --status",
#line 167
#else
#line 167
	  "-s",
#line 167
#endif
#line 167
				   NULL, 0, N_("display info about the running instance") },
#line 174 "cmdline.opt"
	{
#line 174
#ifdef HAVE_GETOPT_LONG
#line 174
	  "-S, --stop",
#line 174
#else
#line 174
	  "-S",
#line 174
#endif
#line 174
				   NULL, 0, N_("stop the running instance") },
#line 179 "cmdline.opt"
	{ NULL, NULL, 0, N_("Debugging and Additional Diagnostics") },
#line 183 "cmdline.opt"
	{
#line 183
#ifdef HAVE_GETOPT_LONG
#line 183
	  "--dump-depmap",
#line 183
#else
#line 183
	  "",
#line 183
#endif
#line 183
				   NULL, 0, N_("dump dependency map") },
#line 190 "cmdline.opt"
	{
#line 190
#ifdef HAVE_GETOPT_LONG
#line 190
	  "--trace-depend",
#line 190
#else
#line 190
	  "",
#line 190
#endif
#line 190
				   NULL, 0, N_("trace dependencies") },
#line 197 "cmdline.opt"
	{
#line 197
#ifdef HAVE_GETOPT_LONG
#line 197
	  "--trace-prereq",
#line 197
#else
#line 197
	  "",
#line 197
#endif
#line 197
				   NULL, 0, N_("trace prerequisites") },
#line 204 "cmdline.opt"
	{
#line 204
#ifdef HAVE_GETOPT_LONG
#line 204
	  "--source-info",
#line 204
#else
#line 204
	  "",
#line 204
#endif
#line 204
				   NULL, 0, N_("show source info with debugging messages") },
#line 210 "cmdline.opt"
	{
#line 210
#ifdef HAVE_GETOPT_LONG
#line 210
	  "-x, --debug",
#line 210
#else
#line 210
	  "-x",
#line 210
#endif
#line 210
				   N_("LEVEL"), 0, N_("set debug verbosity level") },
#line 214 "cmdline.opt"
	{ NULL, NULL, 0, N_("Other options") },
#line 214 "cmdline.opt"
	{
#line 214
#ifdef HAVE_GETOPT_LONG
#line 214
	  "-h, --help",
#line 214
#else
#line 214
	  "-h",
#line 214
#endif
#line 214
				   NULL, 0, N_("Give this help list") },
#line 214 "cmdline.opt"
	{
#line 214
#ifdef HAVE_GETOPT_LONG
#line 214
	  "--usage",
#line 214
#else
#line 214
	  "",
#line 214
#endif
#line 214
				   NULL, 0, N_("Give a short usage message") },
#line 214 "cmdline.opt"
	{
#line 214
#ifdef HAVE_GETOPT_LONG
#line 214
	  "-V, --version",
#line 214
#else
#line 214
	  "-V",
#line 214
#endif
#line 214
				   NULL, 0, N_("Print program version") },
#line 214 "cmdline.opt"
};
#line 17 "cmdline.opt"

#line 17

#line 17
#ifndef PACKAGE_URL
#line 17
# define PACKAGE_URL NULL
#line 17
#endif
#line 17
static struct grecs_proginfo proginfo = {
#line 17
	"pies", /* progname */
#line 17
	NULL, /* subcommands */
#line 17
	N_("process invocation and execution supervisor"), /* docstring */
#line 17
	"", /* args_doc */
#line 17
	opthelp, /* opthelp */
#line 17
	sizeof(opthelp)/sizeof(opthelp[0]), /* optcount */
#line 17
	NULL, /* print_help_hook */
#line 17
	NULL, /* print_version_hook */
#line 17
	PACKAGE_NAME,    /* package */
#line 17
	PACKAGE_VERSION, /* version */
#line 17
	NULL, /* license */
#line 17
	"2008-2017",/* copyright_year */
#line 17
	"Sergey Poznyakoff", /* copyright_holder */
#line 17
	NULL, /* *authors */
#line 17
	"<" PACKAGE_BUGREPORT ">", /* bug_address */
#line 17
	PACKAGE_URL, /* url */
#line 17
	NULL  /* epilogue */
#line 17
};
#line 17

#line 214 "cmdline.opt"

#line 214


void
parse_options (int *pargc, char ***pargv)
{
  int argc = *pargc;
  char **argv = *pargv;
  int index;
  
  if (init_process)
    {
      sysvinit_parse_argv (argc, argv);
      index = argc;
    }
  else
    {
      
#line 230
 {
#line 230
  int c;
#line 230

#line 230
  optind = 0;
#line 230
#ifdef HAVE_GETOPT_LONG
#line 230
  while ((c = getopt_long(argc, argv, "c:EitTI:D:U:rRsSx:hV",
#line 230
			  long_options, NULL)) != EOF)
#line 230
#else
#line 230
  while ((c = getopt(argc, argv, "c:EitTI:D:U:rRsSx:hV")) != EOF)
#line 230
#endif
#line 230
    {
#line 230
      switch (c)
#line 230
	{
#line 230
	default:
#line 230
	   	   exit(EX_USAGE);
#line 230
	#line 28 "cmdline.opt"
	 case 'c':
#line 28
	  {
#line 28

  config_file_add (current_syntax, optarg);

#line 30
	     break;
#line 30
	  }
#line 34 "cmdline.opt"
	 case OPTION_CONFIG_HELP:
#line 34
	  {
#line 34

  config_help ();
  exit (0);

#line 37
	     break;
#line 37
	  }
#line 41 "cmdline.opt"
	 case 'E':
#line 41
	  {
#line 41

  preprocess_only = 1;

#line 43
	     break;
#line 43
	  }
#line 47 "cmdline.opt"
	 case OPTION_FORCE:
#line 47
	  {
#line 47

  force_option = 1;

#line 49
	     break;
#line 49
	  }
#line 53 "cmdline.opt"
	 case OPTION_FOREGROUND:
#line 53
	  {
#line 53

  log_to_stderr_only = 1;
  foreground = 1;

#line 56
	     break;
#line 56
	  }
#line 60 "cmdline.opt"
	 case OPTION_NO_INIT:
#line 60
	  {
#line 60

  /* handled separately */

#line 62
	     break;
#line 62
	  }
#line 66 "cmdline.opt"
	 case 'i':
#line 66
	  {
#line 66

  if (!instance)
    instance = "inetd";
  current_syntax = &config_syntax_tab[CONF_INETD];
  inetd_mode = 1;

#line 71
	     break;
#line 71
	  }
#line 75 "cmdline.opt"
	 case OPTION_INSTANCE:
#line 75
	  {
#line 75

  instance = optarg;

#line 77
	     break;
#line 77
	  }
#line 81 "cmdline.opt"
	 case OPTION_RATE:
#line 81
	  {
#line 81

  char *p;
  default_max_rate = strtoul (optarg, &p, 10);
  if (*p)
    {
      logmsg (LOG_ERR, _("not a number: %s"), optarg);
      exit (EX_USAGE);
    }

#line 89
	     break;
#line 89
	  }
#line 93 "cmdline.opt"
	 case OPTION_STDERR:
#line 93
	  {
#line 93

  log_to_stderr_only = 1;

#line 95
	     break;
#line 95
	  }
#line 99 "cmdline.opt"
	 case OPTION_SYNTAX:
#line 99
	  {
#line 99

  current_syntax = str_to_config_syntax (optarg);
  if (!current_syntax)
    {
      logmsg (LOG_ERR, _("unknown syntax type: %s"), optarg);
      exit (EX_USAGE);
    }

#line 106
	     break;
#line 106
	  }
#line 110 "cmdline.opt"
	 case OPTION_SYSLOG:
#line 110
	  {
#line 110

  log_to_stderr_only = 0;

#line 112
	     break;
#line 112
	  }
#line 116 "cmdline.opt"
	 case 't':
#line 116
	  {
#line 116

  log_to_stderr_only = 1;
  lint_mode = 1;

#line 119
	     break;
#line 119
	  }
#line 123 "cmdline.opt"
	 case 'T':
#line 123
	  {
#line 123

  log_to_stderr_only = 1;
  exit (telinit (argc - (optind - 1), argv + (optind - 1)));

#line 126
	     break;
#line 126
	  }
#line 132 "cmdline.opt"
	 case 'I':
#line 132
	  {
#line 132

  grecs_preproc_add_include_dir(optarg);

#line 134
	     break;
#line 134
	  }
#line 138 "cmdline.opt"
	 case 'D':
#line 138
	  {
#line 138

  pp_add_option ("-D", optarg);

#line 140
	     break;
#line 140
	  }
#line 144 "cmdline.opt"
	 case 'U':
#line 144
	  {
#line 144

  pp_add_option ("-U", optarg);

#line 146
	     break;
#line 146
	  }
#line 153 "cmdline.opt"
	 case 'r':
#line 153
	  {
#line 153

  log_to_stderr_only = 1;
  command = COM_RELOAD;

#line 156
	     break;
#line 156
	  }
#line 160 "cmdline.opt"
	 case 'R':
#line 160
	  {
#line 160

  log_to_stderr_only = 1;
  command = COM_RESTART_COMPONENT;

#line 163
	     break;
#line 163
	  }
#line 167 "cmdline.opt"
	 case 's':
#line 167
	  {
#line 167

  log_to_stderr_only = 1;
  command = COM_STATUS;

#line 170
	     break;
#line 170
	  }
#line 174 "cmdline.opt"
	 case 'S':
#line 174
	  {
#line 174

  log_to_stderr_only = 1;
  command = COM_STOP;

#line 177
	     break;
#line 177
	  }
#line 183 "cmdline.opt"
	 case OPTION_DUMP_DEPMAP:
#line 183
	  {
#line 183

  log_to_stderr_only = 1;
  command = COM_DUMP_DEPMAP;

#line 186
	     break;
#line 186
	  }
#line 190 "cmdline.opt"
	 case OPTION_TRACE_DEPEND:
#line 190
	  {
#line 190

  log_to_stderr_only = 1;
  command = COM_TRACE_DEPEND;  

#line 193
	     break;
#line 193
	  }
#line 197 "cmdline.opt"
	 case OPTION_TRACE_PREREQ:
#line 197
	  {
#line 197

  log_to_stderr_only = 1;
  command = COM_TRACE_PREREQ;  

#line 200
	     break;
#line 200
	  }
#line 204 "cmdline.opt"
	 case OPTION_SOURCE_INFO:
#line 204
	  {
#line 204

  source_info_option = 1;

#line 206
	     break;
#line 206
	  }
#line 210 "cmdline.opt"
	 case 'x':
#line 210
	  {
#line 210

  debug_level = strtoul (optarg, NULL, 0);

#line 212
	     break;
#line 212
	  }
#line 214 "cmdline.opt"
	 case 'h':
#line 214
	  {
#line 214

#line 214
		grecs_print_help(&proginfo);
#line 214
		exit(0);
#line 214
	 
#line 214
	     break;
#line 214
	  }
#line 214 "cmdline.opt"
	 case OPTION_USAGE:
#line 214
	  {
#line 214

#line 214
		grecs_print_usage(&proginfo);
#line 214
		exit(0);
#line 214
	 
#line 214
	     break;
#line 214
	  }
#line 214 "cmdline.opt"
	 case 'V':
#line 214
	  {
#line 214

#line 214
	        /* Give version */
#line 214
		grecs_print_version(&proginfo, stdout);
#line 214
		exit(0);
#line 214
	 
#line 214
	     break;
#line 214
	  }

#line 230 "cmdline.opt"
	}
#line 230
    }
#line 230
  index = optind;
#line 230
 }
#line 230
;
    }
  *pargc -= index;
  *pargv += index;
}
