1 /* $NetBSD: getopt.h,v 1.1.1.1 2021/04/07 02:43:15 christos Exp $ */ 2 #ifndef __GETOPT_H__ 3 #define __GETOPT_H__ 4 5 #ifdef __cplusplus 6 extern "C" { 7 #endif 8 9 extern int opterr; /* if error message should be printed */ 10 extern int optind; /* index into parent argv vector */ 11 extern int optopt; /* character checked for validity */ 12 extern int optreset; /* reset getopt */ 13 extern char *optarg; /* argument associated with option */ 14 15 struct option 16 { 17 const char *name; 18 int has_arg; 19 int *flag; 20 int val; 21 }; 22 23 #define no_argument 0 24 #define required_argument 1 25 #define optional_argument 2 26 27 int getopt(int, char**, const char*); 28 int getopt_long(int, char**, const char*, const struct option*, int*); 29 30 #ifdef __cplusplus 31 } 32 #endif 33 34 #endif /* __GETOPT_H__ */ 35