#line 416 "../grecs/build-aux/getopt.m4"
/* -*- buffer-read-only: t -*- vi: set ro:
   THIS FILE IS GENERATED AUTOMATICALLY.  PLEASE DO NOT EDIT.
*/
#line 1 "piesctl-cl.opt"
/* This file is part of GNU Pies. -*- c -*-
   Copyright (C) 2008-2016 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 92 "piesctl-cl.opt"

#line 92

#line 92
#ifdef HAVE_CONFIG_H
#line 92
# include <config.h>
#line 92
#endif
#line 92
#ifdef HAVE_GETOPT_H
#line 92
# include <getopt.h>
#line 92
#endif
#line 92
#include <unistd.h>
#line 92

#line 92
#include <grecs.h>
#line 92
#include <grecs/opt.h>
#line 92
/* Option codes */
#line 92
enum {
#line 92
	_OPTION_INIT=255,
#line 92
	#line 36 "piesctl-cl.opt"

#line 36
	OPTION_CONFIG_HELP,
#line 92 "piesctl-cl.opt"

#line 92
	OPTION_USAGE,

#line 92 "piesctl-cl.opt"
	MAX_OPTION
#line 92
};
#line 92
#ifdef HAVE_GETOPT_LONG
#line 92
static struct option long_options[] = {
#line 92
	#line 24 "piesctl-cl.opt"

#line 24
	{ "instance", required_argument, 0, 'i' },
#line 30 "piesctl-cl.opt"

#line 30
	{ "config-file", required_argument, 0, 'c' },
#line 36 "piesctl-cl.opt"

#line 36
	{ "config-help", no_argument, 0, OPTION_CONFIG_HELP },
#line 49 "piesctl-cl.opt"

#line 49
	{ "verbose", no_argument, 0, 'v' },
#line 55 "piesctl-cl.opt"

#line 55
	{ "dump", no_argument, 0, 'd' },
#line 61 "piesctl-cl.opt"

#line 61
	{ "url", required_argument, 0, 'u' },
#line 74 "piesctl-cl.opt"

#line 74
	{ "include-directory", required_argument, 0, 'I' },
#line 80 "piesctl-cl.opt"

#line 80
	{ "define", required_argument, 0, 'D' },
#line 86 "piesctl-cl.opt"

#line 86
	{ "undefine", required_argument, 0, 'U' },
#line 92 "piesctl-cl.opt"

#line 92
	{ "help", no_argument, 0, 'h' },
#line 92 "piesctl-cl.opt"

#line 92
	{ "usage", no_argument, 0, OPTION_USAGE },
#line 92 "piesctl-cl.opt"

#line 92
	{ "version", no_argument, 0, 'V' },

#line 92 "piesctl-cl.opt"
	{0, 0, 0, 0}
#line 92
};
#line 92
#endif
#line 92
static struct grecs_opthelp opthelp[] = {
#line 92
	#line 26 "piesctl-cl.opt"

#line 26
	{
#line 26
#ifdef HAVE_GETOPT_LONG
#line 26
	  "-i, --instance",
#line 26
#else
#line 26
	  "-i",
#line 26
#endif
#line 26
				   N_("NAME"), 0, N_("connect to instance NAME") },
#line 32 "piesctl-cl.opt"

#line 32
	{
#line 32
#ifdef HAVE_GETOPT_LONG
#line 32
	  "-c, --config-file",
#line 32
#else
#line 32
	  "-c",
#line 32
#endif
#line 32
				   N_("FILE"), 0, N_("use FILE instead of the default configuration") },
#line 38 "piesctl-cl.opt"

#line 38
	{
#line 38
#ifdef HAVE_GETOPT_LONG
#line 38
	  "--config-help",
#line 38
#else
#line 38
	  "",
#line 38
#endif
#line 38
				   NULL, 0, N_("show configuration file summary") },
#line 45 "piesctl-cl.opt"

#line 45
	{
#line 45
#ifdef HAVE_GETOPT_LONG
#line 45
	  "-E",
#line 45
#else
#line 45
	  "-E",
#line 45
#endif
#line 45
				   NULL, 0, N_("preprocess configuration files and exit") },
#line 51 "piesctl-cl.opt"

#line 51
	{
#line 51
#ifdef HAVE_GETOPT_LONG
#line 51
	  "-v, --verbose",
#line 51
#else
#line 51
	  "-v",
#line 51
#endif
#line 51
				   NULL, 0, N_("verbose diagnostics") },
#line 57 "piesctl-cl.opt"

#line 57
	{
#line 57
#ifdef HAVE_GETOPT_LONG
#line 57
	  "-d, --dump",
#line 57
#else
#line 57
	  "-d",
#line 57
#endif
#line 57
				   NULL, 0, N_("dump obtained responses verbatim") },
#line 63 "piesctl-cl.opt"

#line 63
	{
#line 63
#ifdef HAVE_GETOPT_LONG
#line 63
	  "-u, --url",
#line 63
#else
#line 63
	  "-u",
#line 63
#endif
#line 63
				   N_("URL"), 0, N_("connect to this socket") },
#line 72 "piesctl-cl.opt"

#line 72
	{ NULL, NULL, 0, N_("Preprocessor") },
#line 76 "piesctl-cl.opt"

#line 76
	{
#line 76
#ifdef HAVE_GETOPT_LONG
#line 76
	  "-I, --include-directory",
#line 76
#else
#line 76
	  "-I",
#line 76
#endif
#line 76
				   N_("DIR"), 0, N_("add include directory") },
#line 82 "piesctl-cl.opt"

#line 82
	{
#line 82
#ifdef HAVE_GETOPT_LONG
#line 82
	  "-D, --define",
#line 82
#else
#line 82
	  "-D",
#line 82
#endif
#line 82
				   N_("NAME[=VALUE]"), 0, N_("define a preprocessor symbol NAME as having VALUE or empty") },
#line 88 "piesctl-cl.opt"

#line 88
	{
#line 88
#ifdef HAVE_GETOPT_LONG
#line 88
	  "-U, --undefine",
#line 88
#else
#line 88
	  "-U",
#line 88
#endif
#line 88
				   N_("NAME"), 0, N_("undefine a preprocessor symbol NAME") },
#line 92 "piesctl-cl.opt"

#line 92
	{ NULL, NULL, 0, N_("Other options") },
#line 92 "piesctl-cl.opt"

#line 92
	{
#line 92
#ifdef HAVE_GETOPT_LONG
#line 92
	  "-h, --help",
#line 92
#else
#line 92
	  "-h",
#line 92
#endif
#line 92
				   NULL, 0, N_("Give this help list") },
#line 92 "piesctl-cl.opt"

#line 92
	{
#line 92
#ifdef HAVE_GETOPT_LONG
#line 92
	  "--usage",
#line 92
#else
#line 92
	  "",
#line 92
#endif
#line 92
				   NULL, 0, N_("Give a short usage message") },
#line 92 "piesctl-cl.opt"

#line 92
	{
#line 92
#ifdef HAVE_GETOPT_LONG
#line 92
	  "-V, --version",
#line 92
#else
#line 92
	  "-V",
#line 92
#endif
#line 92
				   NULL, 0, N_("Print program version") },

#line 92 "piesctl-cl.opt"
};
#line 17 "piesctl-cl.opt"

#line 17

#line 17
static struct grecs_proginfo proginfo = {
#line 17
	"piesctl", /* progname */
#line 17
	NULL, /* subcommands */
#line 17
	N_("GNU pies control program"), /* docstring */
#line 17
	N_("COMMAND [ARG...]"), /* 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-2016",/* 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
static struct grecs_node *cmdline_tree;
#line 17

#line 17

#line 92 "piesctl-cl.opt"

#line 92


void
parse_options(int argc, char *argv[], int *index)
{
  
#line 97
 {
#line 97
  int c;
#line 97

#line 97
  optind = 0;
#line 97
#ifdef HAVE_GETOPT_LONG
#line 97
  while ((c = getopt_long(argc, argv, "i:c:Evdu:I:D:U:hV",
#line 97
			  long_options, NULL)) != EOF)
#line 97
#else
#line 97
  while ((c = getopt(argc, argv, "i:c:Evdu:I:D:U:hV")) != EOF)
#line 97
#endif
#line 97
    {
#line 97
      switch (c)
#line 97
	{
#line 97
	default:
#line 97
	   	   exit(EX_USAGE);
#line 97
	#line 26 "piesctl-cl.opt"
	 case 'i':
#line 26
	  {
#line 26

  instance = optarg;

#line 28
	     break;
#line 28
	  }
#line 32 "piesctl-cl.opt"
	 case 'c':
#line 32
	  {
#line 32

  config_file = optarg;

#line 34
	     break;
#line 34
	  }
#line 38 "piesctl-cl.opt"
	 case OPTION_CONFIG_HELP:
#line 38
	  {
#line 38

  config_help ();
  exit (0);

#line 41
	     break;
#line 41
	  }
#line 45 "piesctl-cl.opt"
	 case 'E':
#line 45
	  {
#line 45

  preprocess_only = 1;

#line 47
	     break;
#line 47
	  }
#line 51 "piesctl-cl.opt"
	 case 'v':
#line 51
	  {
#line 51

  ++verbose;

#line 53
	     break;
#line 53
	  }
#line 57 "piesctl-cl.opt"
	 case 'd':
#line 57
	  {
#line 57

  ++dump;

#line 59
	     break;
#line 59
	  }
#line 63 "piesctl-cl.opt"
	 case 'u':
#line 63
	  {
#line 63

  if (pies_url_create (&client.url, optarg))
    {
      grecs_error (NULL, 0, _("%s: cannot create URL: %s"),
		   optarg, strerror (errno));
      exit (EX_USAGE);
    }

#line 70
	     break;
#line 70
	  }
#line 76 "piesctl-cl.opt"
	 case 'I':
#line 76
	  {
#line 76

  grecs_preproc_add_include_dir (optarg);

#line 78
	     break;
#line 78
	  }
#line 82 "piesctl-cl.opt"
	 case 'D':
#line 82
	  {
#line 82

  pp_add_option ("-D", optarg);

#line 84
	     break;
#line 84
	  }
#line 88 "piesctl-cl.opt"
	 case 'U':
#line 88
	  {
#line 88

  pp_add_option ("-U", optarg);

#line 90
	     break;
#line 90
	  }
#line 92 "piesctl-cl.opt"
	 case 'h':
#line 92
	  {
#line 92

#line 92
		grecs_print_help(&proginfo);
#line 92
		exit(0);
#line 92
	 
#line 92
	     break;
#line 92
	  }
#line 92 "piesctl-cl.opt"
	 case OPTION_USAGE:
#line 92
	  {
#line 92

#line 92
		grecs_print_usage(&proginfo);
#line 92
		exit(0);
#line 92
	 
#line 92
	     break;
#line 92
	  }
#line 92 "piesctl-cl.opt"
	 case 'V':
#line 92
	  {
#line 92

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

#line 97 "piesctl-cl.opt"
	}
#line 97
    }
#line 97
  *index = optind;
#line 97
  if (cmdline_tree)
#line 97
    {
#line 97
      struct grecs_node *rn = grecs_node_create(grecs_node_root, NULL);
#line 97
      rn->down = cmdline_tree;
#line 97
      cmdline_tree = rn;
#line 97
    }
#line 97
 }
#line 97

  setenv ("PIES_INSTANCE", instance, 1);
}


	      
