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