/* -*- buffer-read-only: t -*- vi: set ro:
   THIS FILE IS GENERATED AUTOMATICALLY.  PLEASE DO NOT EDIT.
*/

#line 1 "rwopt.opt"
/* This file is part of GNU Rush.                  
   Copyright (C) 2008-2010, 2014 Sergey Poznyakoff

   GNU Rush 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 Rush 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 Rush.  If not, see <http://www.gnu.org/licenses/>. */

#line 17 "rwopt.opt"

#line 17
void print_help(void);
#line 17
void print_usage(void);
#line 38 "rwopt.opt"

#line 38
/* Option codes */
#line 38
enum {
#line 38
	_OPTION_INIT=255,
#line 38
	#line 38 "rwopt.opt"

#line 38
	OPTION_USAGE,
#line 38 "rwopt.opt"

#line 38
	OPTION_VERSION,

#line 38 "rwopt.opt"
	MAX_OPTION
#line 38
};
#line 38
static struct option long_options[] = {
#line 38
	#line 20 "rwopt.opt"

#line 20
	{ "format", required_argument, 0, 'F' },
#line 26 "rwopt.opt"

#line 26
	{ "file", required_argument, 0, 'f' },
#line 32 "rwopt.opt"

#line 32
	{ "no-header", no_argument, 0, 'H' },
#line 38 "rwopt.opt"

#line 38
	{ "help", no_argument, 0, 'h' },
#line 38 "rwopt.opt"

#line 38
	{ "usage", no_argument, 0, OPTION_USAGE },
#line 38 "rwopt.opt"

#line 38
	{ "version", no_argument, 0, OPTION_VERSION },

#line 38 "rwopt.opt"
	{0, 0, 0, 0}
#line 38
};
#line 38
static struct opthelp {
#line 38
        const char *opt;
#line 38
        const char *arg;
#line 38
        int is_optional;
#line 38
        const char *descr;
#line 38
} opthelp[] = {
#line 38
	#line 22 "rwopt.opt"

#line 22
	{ "-F, --format", N_("STRING"), 0, N_("Use STRING instead of the default format.") },
#line 28 "rwopt.opt"

#line 28
	{ "-f, --file", N_("DIR"), 0, N_("Look for database files in DIR.") },
#line 34 "rwopt.opt"

#line 34
	{ "-H, --no-header", NULL, 0, N_("Do not display header line.") },
#line 38 "rwopt.opt"

#line 38
	{ NULL, NULL, 0, N_("Other options") },
#line 38 "rwopt.opt"

#line 38
	{ "-h, --help", NULL, 0, N_("Give this help list") },
#line 38 "rwopt.opt"

#line 38
	{ "--usage", NULL, 0, N_("Give a short usage message") },
#line 38 "rwopt.opt"

#line 38
	{ "--version", NULL, 0, N_("Print program version") },

#line 38 "rwopt.opt"
};
#line 17 "rwopt.opt"

#line 17
const char *program_version = "rushwho" " (" PACKAGE_STRING ")";
#line 17
static char doc[] = N_("rushwho - show listing of online Rush users.");
#line 17
static char args_doc[] = N_("");
#line 17
const char *program_bug_address = "<" PACKAGE_BUGREPORT ">";
#line 17
		    
#line 17
#define DESCRCOLUMN 30
#line 17
#define RMARGIN 79
#line 17
#define GROUPCOLUMN 2
#line 17
#define USAGECOLUMN 13
#line 17
		    
#line 17
static void
#line 17
indent (size_t start, size_t col)
#line 17
{
#line 17
  for (; start < col; start++)
#line 17
    putchar (' ');
#line 17
}
#line 17
		    
#line 17
static void
#line 17
print_option_descr (const char *descr, size_t lmargin, size_t rmargin)
#line 17
{
#line 17
  while (*descr)
#line 17
    {
#line 17
      size_t s = 0;
#line 17
      size_t i;
#line 17
      size_t width = rmargin - lmargin;
#line 17

#line 17
      for (i = 0; ; i++)
#line 17
	{
#line 17
	  if (descr[i] == 0 || isspace (descr[i]))
#line 17
	    {
#line 17
	      if (i > width)
#line 17
		break;
#line 17
	      s = i;
#line 17
	      if (descr[i] == 0)
#line 17
		break;
#line 17
	    }
#line 17
	}
#line 17
      printf ("%*.*s\n", s, s, descr);
#line 17
      descr += s;
#line 17
      if (*descr)
#line 17
	{
#line 17
	  indent (0, lmargin);
#line 17
	  descr++;
#line 17
	}
#line 17
    }
#line 17
}
#line 17

#line 17
void
#line 17
print_help(void)
#line 17
{
#line 17
  unsigned i;
#line 17
  
#line 17
  printf ("%s %s [%s]... %s\n", _("Usage:"), "rushwho", _("OPTION"),
#line 17
	  gettext (args_doc)); 
#line 17
  if (doc[0])
#line 17
    print_option_descr(gettext (doc), 0, RMARGIN);
#line 17
  putchar ('\n');
#line 17

#line 17
  for (i = 0; i < sizeof (opthelp) / sizeof (opthelp[0]); i++)
#line 17
    {
#line 17
      unsigned n;
#line 17
      if (opthelp[i].opt)
#line 17
	{
#line 17
	  n = printf ("  %s", opthelp[i].opt);
#line 17
	  if (opthelp[i].arg)
#line 17
	    {
#line 17
	      char *cb, *ce;
#line 17
	      if (strlen (opthelp[i].opt) == 2)
#line 17
		{
#line 17
		  if (!opthelp[i].is_optional)
#line 17
		    {
#line 17
		      putchar (' ');
#line 17
		      n++;
#line 17
		    }
#line 17
		}
#line 17
	      else
#line 17
		{
#line 17
		  putchar ('=');
#line 17
		  n++;
#line 17
		}
#line 17
	      if (opthelp[i].is_optional)
#line 17
		{
#line 17
		  cb = "[";
#line 17
		  ce = "]";
#line 17
		}
#line 17
	      else
#line 17
		cb = ce = "";
#line 17
	      n += printf ("%s%s%s", cb, gettext (opthelp[i].arg), ce);
#line 17
	    }
#line 17
	  if (n >= DESCRCOLUMN)
#line 17
	    {
#line 17
	      putchar ('\n');
#line 17
	      n = 0;
#line 17
	    }
#line 17
	  indent (n, DESCRCOLUMN);
#line 17
	  print_option_descr (gettext (opthelp[i].descr), DESCRCOLUMN, RMARGIN);
#line 17
	}
#line 17
      else
#line 17
	{
#line 17
	  if (i)
#line 17
	    putchar ('\n');
#line 17
	  indent (0, GROUPCOLUMN);
#line 17
	  print_option_descr (gettext (opthelp[i].descr),
#line 17
			      GROUPCOLUMN, RMARGIN);
#line 17
	  putchar ('\n');
#line 17
	}
#line 17
    }
#line 17
  
#line 17
  putchar ('\n');
#line 17
  print_option_descr (_("Mandatory or optional arguments to long options are also mandatory or optional for any corresponding short options."), 0, RMARGIN);
#line 17
  putchar ('\n');
#line 17
  printf (_("Report bugs to %s.\n"), program_bug_address);
#line 17
}
#line 17

#line 17
void
#line 17
print_usage(void)
#line 17
{
#line 17
  unsigned i;
#line 17
  int f = 0;
#line 17
  unsigned n;
#line 17
  char buf[RMARGIN+1];
#line 17

#line 17
#define FLUSH                        do                                   {                              	  buf[n] = 0;              	  printf ("%s\n", buf);    	  n = USAGECOLUMN;         	  memset (buf, ' ', n);        }                                while (0)
#line 17
#define ADDC(c)   do { if (n == RMARGIN) FLUSH; buf[n++] = c; } while (0)
#line 17

#line 17
  n = snprintf (buf, sizeof buf, "%s %s ", _("Usage:"), "rushwho");
#line 17

#line 17
  /* Print a list of short options without arguments. */
#line 17
  for (i = 0; i < sizeof (opthelp) / sizeof (opthelp[0]); i++)
#line 17
    {
#line 17
      if (opthelp[i].opt && opthelp[i].descr && opthelp[i].opt[1] != '-'
#line 17
	  && opthelp[i].arg == NULL)
#line 17
	{
#line 17
	  if (f == 0)
#line 17
	    {
#line 17
	      ADDC('[');
#line 17
	      ADDC('-');
#line 17
	      f = 1;
#line 17
	    }
#line 17
	  ADDC(opthelp[i].opt[1]);
#line 17
	}
#line 17
    }
#line 17
  if (f)
#line 17
    ADDC(']');
#line 17

#line 17
  /* Print a list of short options with arguments. */
#line 17
  for (i = 0; i < sizeof (opthelp) / sizeof (opthelp[0]); i++)
#line 17
    {
#line 17
      if (opthelp[i].opt && opthelp[i].descr && opthelp[i].opt[1] != '-'
#line 17
	  && opthelp[i].arg)
#line 17
	{
#line 17
	  size_t len = 5 
#line 17
	                + strlen (opthelp[i].arg)
#line 17
			   + (opthelp[i].is_optional ? 2 : 1);
#line 17
	  if (n + len > RMARGIN) FLUSH;
#line 17
	  buf[n++] = ' '; 
#line 17
	  buf[n++] = '['; 
#line 17
	  buf[n++] = '-';
#line 17
	  buf[n++] = opthelp[i].opt[1];
#line 17
	  if (opthelp[i].is_optional)
#line 17
	    {
#line 17
	      buf[n++] = '[';
#line 17
	      strcpy (&buf[n], opthelp[i].arg);
#line 17
	      n += strlen (opthelp[i].arg);
#line 17
	      buf[n++] = ']';
#line 17
	    }
#line 17
	  else
#line 17
	    {
#line 17
	      buf[n++] = ' ';
#line 17
	      strcpy (&buf[n], opthelp[i].arg);
#line 17
	      n += strlen (opthelp[i].arg);
#line 17
	    }
#line 17
	  buf[n++] = ']';
#line 17
	}
#line 17
    }
#line 17

#line 17
  /* Print a list of long options */
#line 17
  for (i = 0; i < sizeof (opthelp) / sizeof (opthelp[0]); i++)
#line 17
    {
#line 17
      if (opthelp[i].opt && opthelp[i].descr)
#line 17
	{
#line 17
	  size_t len;
#line 17
	  const char *longopt;
#line 17

#line 17
	  if (opthelp[i].opt[1] == '-')
#line 17
	    longopt = opthelp[i].opt;
#line 17
	  else if (opthelp[i].opt[2] == ',')
#line 17
	    longopt = opthelp[i].opt + 4;
#line 17
	  else
#line 17
	    continue;
#line 17

#line 17
	  len = 3 + strlen (longopt)
#line 17
	          + (opthelp[i].arg ? 1 + strlen (opthelp[i].arg)
#line 17
		      + (opthelp[i].is_optional ? 2 : 0) : 0);
#line 17
	  if (n + len > RMARGIN) FLUSH;
#line 17
	  buf[n++] = ' '; 
#line 17
	  buf[n++] = '['; 
#line 17
	  strcpy (&buf[n], longopt);
#line 17
	  n += strlen (longopt);
#line 17
	  if (opthelp[i].arg)
#line 17
	    {
#line 17
	      buf[n++] = '=';
#line 17
	      if (opthelp[i].is_optional)
#line 17
		{
#line 17
		  buf[n++] = '[';
#line 17
		  strcpy (&buf[n], opthelp[i].arg);
#line 17
		  n += strlen (opthelp[i].arg);
#line 17
		  buf[n++] = ']';
#line 17
		}
#line 17
	      else
#line 17
		{
#line 17
		  strcpy (&buf[n], opthelp[i].arg);
#line 17
		  n += strlen (opthelp[i].arg);
#line 17
		}
#line 17
	    }
#line 17
	  buf[n++] = ']';
#line 17
	}
#line 17
    }
#line 17
  FLUSH;
#line 17
  
#line 17
}
#line 17

#line 17
const char version_etc_copyright[] =
#line 17
  /* Do *not* mark this string for translation.  %s is a copyright
     symbol suitable for this locale, and %d is the copyright
     year.  */
#line 17
  "Copyright %s 2008-2013 Sergey Poznyakoff";
#line 17

#line 17
void
#line 17
print_version_only(const char *program_version, FILE *stream)
#line 17
{
#line 17
	fprintf (stream, "%s\n", program_version);
#line 17
	/* TRANSLATORS: Translate "(C)" to the copyright symbol
	   (C-in-a-circle), if this symbol is available in the user's
	   locale.  Otherwise, do not translate "(C)"; leave it as-is.  */
#line 17
	fprintf (stream, version_etc_copyright, _("(C)"));
#line 17
	fputc ('\n', stream);
#line 17
}
#line 17

#line 17
void
#line 17
print_version(const char *program_version, FILE *stream)
#line 17
{
#line 17
	print_version_only(program_version, stream);
#line 17
	
#line 17
	fputs (_("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n\n"),
#line 17
	       stream);
#line 17
	
#line 17
}
#line 17

#line 38 "rwopt.opt"

#line 38


void
get_options(int argc, char *argv[])
{
	
#line 43
 {
#line 43
  int optchar;
#line 43

#line 43

#line 43
  while ((optchar = getopt_long(argc, argv, "F:f:Hh",
#line 43
                                long_options, NULL)) != EOF)
#line 43
    {
#line 43
      switch (optchar)
#line 43
        {
#line 43
        default:
#line 43
	exit(1);
#line 43
       
#line 43
	#line 22 "rwopt.opt"
	 case 'F':
#line 22
          {
#line 22

	format = optarg;

#line 24
             break;
#line 24
          }
#line 28 "rwopt.opt"
	 case 'f':
#line 28
          {
#line 28

	base_name = optarg;

#line 30
             break;
#line 30
          }
#line 34 "rwopt.opt"
	 case 'H':
#line 34
          {
#line 34

	display_header = 0;

#line 36
             break;
#line 36
          }
#line 38 "rwopt.opt"
	 case 'h':
#line 38
          {
#line 38

#line 38
		print_help ();
#line 38
                exit (0);
#line 38
	 
#line 38
             break;
#line 38
          }
#line 38 "rwopt.opt"
	 case OPTION_USAGE:
#line 38
          {
#line 38

#line 38
		print_usage ();
#line 38
		exit (0);
#line 38
	 
#line 38
             break;
#line 38
          }
#line 38 "rwopt.opt"
	 case OPTION_VERSION:
#line 38
          {
#line 38

#line 38
		/* Give version */
#line 38
		print_version(program_version, stdout);
#line 38
		exit (0);
#line 38
         
#line 38
             break;
#line 38
          }

#line 43 "rwopt.opt"
        }
#line 43
    }
#line 43
 }   
#line 43
;
}

