1 __BEGIN_DECLS 2 3 // <getopt.h> 4 extern int optind; /* index of first non-option in argv */ 5 extern int optopt; /* single option character, as parsed */ 6 extern int opterr; /* flag to enable built-in diagnostics... */ 7 /* (user may set to zero, to suppress) */ 8 extern char* optarg; /* pointer to argument of current option */ 9 10 extern int getopt(int nargc, char* const* nargv, const char* options); 11 12 struct option /* specification for a long form option... */ 13 { 14 const char* name; /* option name, without leading hyphens */ 15 int has_arg; /* does it take an argument? */ 16 int* flag; /* where to save its status, or NULL */ 17 int val; /* its associated status value */ 18 }; 19 20 enum /* permitted values for its `has_arg' field... */ 21 { no_argument = 0, /* option never takes an argument */ 22 required_argument, /* option always requires an argument */ 23 optional_argument /* option may take an argument */ 24 }; 25 26 extern int getopt_long(int nargc, 27 char* const* nargv, 28 const char* options, 29 const struct option* long_options, 30 int* idx); 31 extern int getopt_long_only(int nargc, 32 char* const* nargv, 33 const char* options, 34 const struct option* long_options, 35 int* idx); 36 __END_DECLS 37