#line 559 "../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-2020 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 216 "cmdline.opt"
#ifdef HAVE_CONFIG_H
#line 216
# include <config.h>
#line 216
#endif
#line 216
#ifdef HAVE_GETOPT_H
#line 216
# include <getopt.h>
#line 216
#endif
#line 216
#include <unistd.h>
#line 216
#include <stdlib.h>
#line 216
#include <grecs.h>
#line 216
#include <grecs/opt.h>
#line 216
#ifndef EX_USAGE
#line 216
# define EX_USAGE 64
#line 216
#endif
#line 216
/* Option codes */
#line 216
enum {
#line 216
	_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 121 "cmdline.opt"
#if PIES_SYSVINIT_ENABLED
#line 128 "cmdline.opt"
#endif
#line 183 "cmdline.opt"
	OPTION_DUMP_DEPMAP,
#line 190 "cmdline.opt"
	OPTION_TRACE_DEPEND,
#line 197 "cmdline.opt"
	OPTION_TRACE_PREREQ,
#line 204 "cmdline.opt"
	OPTION_SOURCE_INFO,
#line 216 "cmdline.opt"
	OPTION_USAGE,
#line 216 "cmdline.opt"
	MAX_OPTION
#line 216
};
#line 216
#ifdef HAVE_GETOPT_LONG
#line 216
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"
#if PIES_SYSVINIT_ENABLED
#line 122 "cmdline.opt"
	{ "telinit", no_argument, 0, 'T' },
#line 128 "cmdline.opt"
#endif
#line 132 "cmdline.opt"
	{ "include-directory", required_argument, 0, 'I' },
#line 138 "cmdline.opt"
	{ "define", required_argument, 0, 'D' },
#line 144 "cmdline.opt"
	{ "undefine", required_argument, 0, 'U' },
#line 152 "cmdline.opt"
	{ "reload", no_argument, 0, 'r' },
#line 160 "cmdline.opt"
	{ "restart-component", no_argument, 0, 'R' },
#line 167 "cmdline.opt"
	{ "status", no_argument, 0, 's' },
#line 174 "cmdline.opt"
	{ "stop", no_argument, 0, 'S' },
#line 183 "cmdline.opt"
	{ "dump-depmap", no_argument, 0, OPTION_DUMP_DEPMAP },
#line 190 "cmdline.opt"
	{ "trace-depend", no_argument, 0, OPTION_TRACE_DEPEND },
#line 197 "cmdline.opt"
	{ "trace-prereq", no_argument, 0, OPTION_TRACE_PREREQ },
#line 204 "cmdline.opt"
	{ "source-info", no_argument, 0, OPTION_SOURCE_INFO },
#line 210 "cmdline.opt"
	{ "debug", required_argument, 0, 'x' },
#line 216 "cmdline.opt"
	{ "help", no_argument, 0, 'h' },
#line 216 "cmdline.opt"
	{ "usage", no_argument, 0, OPTION_USAGE },
#line 216 "cmdline.opt"
	{ "version", no_argument, 0, 'V' },
#line 216 "cmdline.opt"
	{0, 0, 0, 0}
#line 216
};
#line 216
#endif
#line 216

#line 216
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 configuration file 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 121 "cmdline.opt"
#if PIES_SYSVINIT_ENABLED
#line 124 "cmdline.opt"
	{
#line 124
#ifdef HAVE_GETOPT_LONG
#line 124
	  "-T, --telinit",
#line 124
#else
#line 124
	  "-T",
#line 124
#endif
#line 124
				   NULL, 0, N_("telinit command: run \"pies -T --help\" for help") },
#line 128 "cmdline.opt"
#endif
#line 130 "cmdline.opt"
	{ NULL, NULL, 0, N_("Preprocessor") },
#line 134 "cmdline.opt"
	{
#line 134
#ifdef HAVE_GETOPT_LONG
#line 134
	  "-I, --include-directory",
#line 134
#else
#line 134
	  "-I",
#line 134
#endif
#line 134
				   N_("DIR"), 0, N_("add include directory") },
#line 140 "cmdline.opt"
	{
#line 140
#ifdef HAVE_GETOPT_LONG
#line 140
	  "-D, --define",
#line 140
#else
#line 140
	  "-D",
#line 140
#endif
#line 140
				   N_("NAME[=VALUE]"), 0, N_("define a preprocessor symbol NAME as having VALUE or empty") },
#line 146 "cmdline.opt"
	{
#line 146
#ifdef HAVE_GETOPT_LONG
#line 146
	  "-U, --undefine",
#line 146
#else
#line 146
	  "-U",
#line 146
#endif
#line 146
				   N_("NAME"), 0, N_("undefine a preprocessor symbol NAME") },
#line 150 "cmdline.opt"
	{ NULL, NULL, 0, N_("Component Management") },
#line 155 "cmdline.opt"
	{
#line 155
#ifdef HAVE_GETOPT_LONG
#line 155
	  "-r, --reload",
#line 155
#else
#line 155
	  "-r",
#line 155
#endif
#line 155
				   NULL, 0, N_("reload the running instance of pies") },
#line 162 "cmdline.opt"
	{
#line 162
#ifdef HAVE_GETOPT_LONG
#line 162
	  "-R, --restart-component",
#line 162
#else
#line 162
	  "-R",
#line 162
#endif
#line 162
				   NULL, 0, N_("restart components named in the command line") },
#line 169 "cmdline.opt"
	{
#line 169
#ifdef HAVE_GETOPT_LONG
#line 169
	  "-s, --status",
#line 169
#else
#line 169
	  "-s",
#line 169
#endif
#line 169
				   NULL, 0, N_("display info about the running instance") },
#line 176 "cmdline.opt"
	{
#line 176
#ifdef HAVE_GETOPT_LONG
#line 176
	  "-S, --stop",
#line 176
#else
#line 176
	  "-S",
#line 176
#endif
#line 176
				   NULL, 0, N_("stop the running instance") },
#line 181 "cmdline.opt"
	{ NULL, NULL, 0, N_("Debugging and Additional Diagnostics") },
#line 185 "cmdline.opt"
	{
#line 185
#ifdef HAVE_GETOPT_LONG
#line 185
	  "--dump-depmap",
#line 185
#else
#line 185
	  "",
#line 185
#endif
#line 185
				   NULL, 0, N_("dump dependency map") },
#line 192 "cmdline.opt"
	{
#line 192
#ifdef HAVE_GETOPT_LONG
#line 192
	  "--trace-depend",
#line 192
#else
#line 192
	  "",
#line 192
#endif
#line 192
				   NULL, 0, N_("trace dependencies") },
#line 199 "cmdline.opt"
	{
#line 199
#ifdef HAVE_GETOPT_LONG
#line 199
	  "--trace-prereq",
#line 199
#else
#line 199
	  "",
#line 199
#endif
#line 199
				   NULL, 0, N_("trace prerequisites") },
#line 206 "cmdline.opt"
	{
#line 206
#ifdef HAVE_GETOPT_LONG
#line 206
	  "--source-info",
#line 206
#else
#line 206
	  "",
#line 206
#endif
#line 206
				   NULL, 0, N_("show source info with debugging messages") },
#line 212 "cmdline.opt"
	{
#line 212
#ifdef HAVE_GETOPT_LONG
#line 212
	  "-x, --debug",
#line 212
#else
#line 212
	  "-x",
#line 212
#endif
#line 212
				   N_("LEVEL"), 0, N_("set debug verbosity level") },
#line 216 "cmdline.opt"
	{ NULL, NULL, 0, N_("Other options") },
#line 216 "cmdline.opt"
	{
#line 216
#ifdef HAVE_GETOPT_LONG
#line 216
	  "-h, --help",
#line 216
#else
#line 216
	  "-h",
#line 216
#endif
#line 216
				   NULL, 0, N_("Give this help list") },
#line 216 "cmdline.opt"
	{
#line 216
#ifdef HAVE_GETOPT_LONG
#line 216
	  "--usage",
#line 216
#else
#line 216
	  "",
#line 216
#endif
#line 216
				   NULL, 0, N_("Give a short usage message") },
#line 216 "cmdline.opt"
	{
#line 216
#ifdef HAVE_GETOPT_LONG
#line 216
	  "-V, --version",
#line 216
#else
#line 216
	  "-V",
#line 216
#endif
#line 216
				   NULL, 0, N_("Print program version") },
#line 216 "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-2020",/* 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 121 "cmdline.opt"
#if PIES_SYSVINIT_ENABLED
#line 128 "cmdline.opt"
#endif
#line 216 "cmdline.opt"

#line 216


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

#line 232
  optind = 0;
#line 232
#ifdef HAVE_GETOPT_LONG
#line 232
  while ((c = getopt_long(argc, argv, "c:EitTI:D:U:rRsSx:hV",
#line 232
			  long_options, NULL)) != EOF)
#line 232
#else
#line 232
  while ((c = getopt(argc, argv, "c:EitTI:D:U:rRsSx:hV")) != EOF)
#line 232
#endif
#line 232
    {
#line 232
      switch (c)
#line 232
	{
#line 232
	default:
#line 232
	   	   exit(EX_USAGE);
#line 232
	#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 121 "cmdline.opt"
#if PIES_SYSVINIT_ENABLED
#line 124 "cmdline.opt"
	 case 'T':
#line 124
	  {
#line 124

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

#line 127
	     break;
#line 127
	  }
#line 128 "cmdline.opt"
#endif
#line 134 "cmdline.opt"
	 case 'I':
#line 134
	  {
#line 134

  grecs_preproc_add_include_dir(optarg);

#line 136
	     break;
#line 136
	  }
#line 140 "cmdline.opt"
	 case 'D':
#line 140
	  {
#line 140

  pp_add_option ("-D", optarg);

#line 142
	     break;
#line 142
	  }
#line 146 "cmdline.opt"
	 case 'U':
#line 146
	  {
#line 146

  pp_add_option ("-U", optarg);

#line 148
	     break;
#line 148
	  }
#line 155 "cmdline.opt"
	 case 'r':
#line 155
	  {
#line 155

  log_to_stderr_only = 1;
  command = COM_RELOAD;

#line 158
	     break;
#line 158
	  }
#line 162 "cmdline.opt"
	 case 'R':
#line 162
	  {
#line 162

  log_to_stderr_only = 1;
  command = COM_RESTART_COMPONENT;

#line 165
	     break;
#line 165
	  }
#line 169 "cmdline.opt"
	 case 's':
#line 169
	  {
#line 169

  log_to_stderr_only = 1;
  command = COM_STATUS;

#line 172
	     break;
#line 172
	  }
#line 176 "cmdline.opt"
	 case 'S':
#line 176
	  {
#line 176

  log_to_stderr_only = 1;
  command = COM_STOP;

#line 179
	     break;
#line 179
	  }
#line 185 "cmdline.opt"
	 case OPTION_DUMP_DEPMAP:
#line 185
	  {
#line 185

  log_to_stderr_only = 1;
  command = COM_DUMP_DEPMAP;

#line 188
	     break;
#line 188
	  }
#line 192 "cmdline.opt"
	 case OPTION_TRACE_DEPEND:
#line 192
	  {
#line 192

  log_to_stderr_only = 1;
  command = COM_TRACE_DEPEND;  

#line 195
	     break;
#line 195
	  }
#line 199 "cmdline.opt"
	 case OPTION_TRACE_PREREQ:
#line 199
	  {
#line 199

  log_to_stderr_only = 1;
  command = COM_TRACE_PREREQ;  

#line 202
	     break;
#line 202
	  }
#line 206 "cmdline.opt"
	 case OPTION_SOURCE_INFO:
#line 206
	  {
#line 206

  source_info_option = 1;

#line 208
	     break;
#line 208
	  }
#line 212 "cmdline.opt"
	 case 'x':
#line 212
	  {
#line 212

  debug_level = strtoul (optarg, NULL, 0);

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

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

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

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

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