1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* getopt_long and getopt_long_only entry points for GNU getopt.
4 Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2011 Free Software
6 This file is part of the GNU C Library.
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
27 #include "getopt_int.h"
31 /* This needs to come after some library #include
32 to get __GNU_LIBRARY__ defined. */
33 #ifdef __GNU_LIBRARY__
42 getopt_long (int argc
, char *__getopt_argv_const
*argv
, const char *options
,
43 const struct option
*long_options
, int *opt_index
)
45 return _getopt_internal (argc
, (char **) argv
, options
, long_options
,
50 _getopt_long_r (int argc
, char **argv
, const char *options
,
51 const struct option
*long_options
, int *opt_index
,
52 struct _getopt_data
*d
)
54 return _getopt_internal_r (argc
, argv
, options
, long_options
, opt_index
,
58 /* Like getopt_long, but '-' as well as '--' can indicate a long option.
59 If an option that starts with '-' (not '--') doesn't match a long option,
60 but does match a short option, it is parsed as a short option
64 getopt_long_only (int argc
, char *__getopt_argv_const
*argv
,
66 const struct option
*long_options
, int *opt_index
)
68 return _getopt_internal (argc
, (char **) argv
, options
, long_options
,
73 _getopt_long_only_r (int argc
, char **argv
, const char *options
,
74 const struct option
*long_options
, int *opt_index
,
75 struct _getopt_data
*d
)
77 return _getopt_internal_r (argc
, argv
, options
, long_options
, opt_index
,
87 main (int argc
, char **argv
)
94 int this_option_optind
= optind
? optind
: 1;
96 static const struct option long_options
[] =
101 {"verbose", 0, 0, 0},
107 c
= getopt_long (argc
, argv
, "abc:d:0123456789",
108 long_options
, &option_index
);
115 printf ("option %s", long_options
[option_index
].name
);
117 printf (" with arg %s", optarg
);
131 if (digit_optind
!= 0 && digit_optind
!= this_option_optind
)
132 printf ("digits occur in two different argv-elements.\n");
133 digit_optind
= this_option_optind
;
134 printf ("option %c\n", c
);
138 printf ("option a\n");
142 printf ("option b\n");
146 printf ("option c with value `%s'\n", optarg
);
150 printf ("option d with value `%s'\n", optarg
);
157 printf ("?? getopt returned character code 0%o ??\n", c
);
163 printf ("non-option ARGV-elements: ");
164 while (optind
< argc
)
165 printf ("%s ", argv
[optind
++]);