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 |
|
|
22 |
#include <config.h> |
#include <config.h> |
23 |
#endif |
#endif |
24 |
|
|
25 |
#include "getopt.h" |
#ifdef _LIBC |
26 |
|
# include <getopt.h> |
27 |
#if !defined __STDC__ || !__STDC__ |
#else |
28 |
/* This is a separate conditional since some stdc systems |
# include "getopt.h" |
|
reject `defined (const)'. */ |
|
|
#ifndef const |
|
|
#define const |
|
|
#endif |
|
29 |
#endif |
#endif |
30 |
|
#include "getopt_int.h" |
31 |
|
|
32 |
#include <stdio.h> |
#include <stdio.h> |
33 |
|
|
61 |
#endif |
#endif |
62 |
|
|
63 |
int |
int |
64 |
getopt_long (argc, argv, options, long_options, opt_index) |
getopt_long (int argc, char *const *argv, const char *options, |
65 |
int argc; |
const struct option *long_options, int *opt_index) |
|
char *const *argv; |
|
|
const char *options; |
|
|
const struct option *long_options; |
|
|
int *opt_index; |
|
66 |
{ |
{ |
67 |
return _getopt_internal (argc, argv, options, long_options, opt_index, 0); |
return _getopt_internal (argc, argv, options, long_options, opt_index, 0); |
68 |
} |
} |
69 |
|
|
70 |
|
int |
71 |
|
_getopt_long_r (int argc, char *const *argv, const char *options, |
72 |
|
const struct option *long_options, int *opt_index, |
73 |
|
struct _getopt_data *d) |
74 |
|
{ |
75 |
|
return _getopt_internal_r (argc, argv, options, long_options, opt_index, |
76 |
|
0, d); |
77 |
|
} |
78 |
|
|
79 |
/* Like getopt_long, but '-' as well as '--' can indicate a long option. |
/* Like getopt_long, but '-' as well as '--' can indicate a long option. |
80 |
If an option that starts with '-' (not '--') doesn't match a long option, |
If an option that starts with '-' (not '--') doesn't match a long option, |
81 |
but does match a short option, it is parsed as a short option |
but does match a short option, it is parsed as a short option |
82 |
instead. */ |
instead. */ |
83 |
|
|
84 |
int |
int |
85 |
getopt_long_only (argc, argv, options, long_options, opt_index) |
getopt_long_only (int argc, char *const *argv, const char *options, |
86 |
int argc; |
const struct option *long_options, int *opt_index) |
|
char *const *argv; |
|
|
const char *options; |
|
|
const struct option *long_options; |
|
|
int *opt_index; |
|
87 |
{ |
{ |
88 |
return _getopt_internal (argc, argv, options, long_options, opt_index, 1); |
return _getopt_internal (argc, argv, options, long_options, opt_index, 1); |
89 |
} |
} |
90 |
|
|
91 |
|
int |
92 |
|
_getopt_long_only_r (int argc, char *const *argv, const char *options, |
93 |
|
const struct option *long_options, int *opt_index, |
94 |
|
struct _getopt_data *d) |
95 |
|
{ |
96 |
|
return _getopt_internal_r (argc, argv, options, long_options, opt_index, |
97 |
|
1, d); |
98 |
|
} |
99 |
|
|
100 |
#endif /* Not ELIDE_CODE. */ |
#endif /* Not ELIDE_CODE. */ |
101 |
|
|
104 |
#include <stdio.h> |
#include <stdio.h> |
105 |
|
|
106 |
int |
int |
107 |
main (argc, argv) |
main (int argc, char **argv) |
|
int argc; |
|
|
char **argv; |
|
108 |
{ |
{ |
109 |
int c; |
int c; |
110 |
int digit_optind = 0; |
int digit_optind = 0; |