1 |
/* getopt_long and getopt_long_only entry points for GNU getopt. |
/* getopt_long and getopt_long_only entry points for GNU getopt. |
2 |
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98 |
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004 |
3 |
Free Software Foundation, Inc. |
Free Software Foundation, Inc. |
4 |
This file is part of the GNU C Library. |
This file is part of the GNU C Library. |
5 |
|
|
26 |
#else |
#else |
27 |
# include "getopt.h" |
# include "getopt.h" |
28 |
#endif |
#endif |
29 |
|
#include "getopt_int.h" |
|
#if !defined __STDC__ || !__STDC__ |
|
|
/* This is a separate conditional since some stdc systems |
|
|
reject `defined (const)'. */ |
|
|
#ifndef const |
|
|
#define const |
|
|
#endif |
|
|
#endif |
|
30 |
|
|
31 |
#include <stdio.h> |
#include <stdio.h> |
32 |
|
|
|
/* Comment out all this code if we are using the GNU C Library, and are not |
|
|
actually compiling the library itself. This code is part of the GNU C |
|
|
Library, but also included in many other GNU distributions. Compiling |
|
|
and linking in this code is a waste when using the GNU C library |
|
|
(especially if it is a shared library). Rather than having every GNU |
|
|
program understand `configure --with-gnu-libc' and omit the object files, |
|
|
it is simpler to just do this in the source for each such file. */ |
|
|
|
|
|
#define GETOPT_INTERFACE_VERSION 2 |
|
|
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 |
|
|
#include <gnu-versions.h> |
|
|
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION |
|
|
#define ELIDE_CODE |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
#ifndef ELIDE_CODE |
|
|
|
|
|
|
|
33 |
/* This needs to come after some library #include |
/* This needs to come after some library #include |
34 |
to get __GNU_LIBRARY__ defined. */ |
to get __GNU_LIBRARY__ defined. */ |
35 |
#ifdef __GNU_LIBRARY__ |
#ifdef __GNU_LIBRARY__ |
41 |
#endif |
#endif |
42 |
|
|
43 |
int |
int |
44 |
getopt_long (argc, argv, options, long_options, opt_index) |
getopt_long (int argc, char *__getopt_argv_const *argv, const char *options, |
45 |
int argc; |
const struct option *long_options, int *opt_index) |
|
char *const *argv; |
|
|
const char *options; |
|
|
const struct option *long_options; |
|
|
int *opt_index; |
|
46 |
{ |
{ |
47 |
return _getopt_internal (argc, argv, options, long_options, opt_index, 0); |
return _getopt_internal (argc, (char **) argv, options, long_options, |
48 |
|
opt_index, 0, 0); |
49 |
|
} |
50 |
|
|
51 |
|
int |
52 |
|
_getopt_long_r (int argc, char **argv, const char *options, |
53 |
|
const struct option *long_options, int *opt_index, |
54 |
|
struct _getopt_data *d) |
55 |
|
{ |
56 |
|
return _getopt_internal_r (argc, argv, options, long_options, opt_index, |
57 |
|
0, 0, d); |
58 |
} |
} |
59 |
|
|
60 |
/* Like getopt_long, but '-' as well as '--' can indicate a long option. |
/* Like getopt_long, but '-' as well as '--' can indicate a long option. |
63 |
instead. */ |
instead. */ |
64 |
|
|
65 |
int |
int |
66 |
getopt_long_only (argc, argv, options, long_options, opt_index) |
getopt_long_only (int argc, char *__getopt_argv_const *argv, |
67 |
int argc; |
const char *options, |
68 |
char *const *argv; |
const struct option *long_options, int *opt_index) |
|
const char *options; |
|
|
const struct option *long_options; |
|
|
int *opt_index; |
|
69 |
{ |
{ |
70 |
return _getopt_internal (argc, argv, options, long_options, opt_index, 1); |
return _getopt_internal (argc, (char **) argv, options, long_options, |
71 |
|
opt_index, 1, 0); |
72 |
} |
} |
73 |
|
|
74 |
# ifdef _LIBC |
int |
75 |
libc_hidden_def (getopt_long) |
_getopt_long_only_r (int argc, char **argv, const char *options, |
76 |
libc_hidden_def (getopt_long_only) |
const struct option *long_options, int *opt_index, |
77 |
# endif |
struct _getopt_data *d) |
78 |
|
{ |
79 |
|
return _getopt_internal_r (argc, argv, options, long_options, opt_index, |
80 |
|
1, 0, d); |
81 |
|
} |
82 |
|
|
|
#endif /* Not ELIDE_CODE. */ |
|
83 |
|
|
84 |
#ifdef TEST |
#ifdef TEST |
85 |
|
|
86 |
#include <stdio.h> |
#include <stdio.h> |
87 |
|
|
88 |
int |
int |
89 |
main (argc, argv) |
main (int argc, char **argv) |
|
int argc; |
|
|
char **argv; |
|
90 |
{ |
{ |
91 |
int c; |
int c; |
92 |
int digit_optind = 0; |
int digit_optind = 0; |
172 |
} |
} |
173 |
|
|
174 |
#endif /* TEST */ |
#endif /* TEST */ |
|
|
|
|
/* arch-tag: 28a5c558-b0c0-4bff-b5bc-e2e20291d4b6 |
|
|
(do not change this comment) */ |
|