1 /* __BEGIN_DECLS should be used at the beginning of your declarations, 2 so that C++ compilers don't mangle their names. Use __END_DECLS at 3 the end of C declarations. */ 4 #ifndef __BEGIN_DECLS 5 #ifdef __cplusplus 6 # define __BEGIN_DECLS extern "C" { 7 # define __END_DECLS } 8 #else 9 # define __BEGIN_DECLS /* empty */ 10 # define __END_DECLS /* empty */ 11 #endif 12 #endif 13 14 __BEGIN_DECLS 15 16 // <getopt.h> 17 extern int optind; /* index of first non-option in argv */ 18 extern int optopt; /* single option character, as parsed */ 19 extern int opterr; /* flag to enable built-in diagnostics... */ 20 /* (user may set to zero, to suppress) */ 21 extern char* optarg; /* pointer to argument of current option */ 22 23 extern int getopt(int nargc, char* const* nargv, const char* options); 24 25 struct option /* specification for a long form option... */ 26 { 27 const char* name; /* option name, without leading hyphens */ 28 int has_arg; /* does it take an argument? */ 29 int* flag; /* where to save its status, or NULL */ 30 int val; /* its associated status value */ 31 }; 32 33 enum /* permitted values for its `has_arg' field... */ 34 { no_argument = 0, /* option never takes an argument */ 35 required_argument, /* option always requires an argument */ 36 optional_argument /* option may take an argument */ 37 }; 38 39 extern int getopt_long(int nargc, 40 char* const* nargv, 41 const char* options, 42 const struct option* long_options, 43 int* idx); 44 extern int getopt_long_only(int nargc, 45 char* const* nargv, 46 const char* options, 47 const struct option* long_options, 48 int* idx); 49 __END_DECLS 50