68 #define STDERR_FILENO 2
76 static void ERR (
char *
const argv[],
const char * s,
char c)
81 printf(
"DF_TRACE_DEBUG: static void ERR () in getopt.c\n");
87 (void) write(STDERR_FILENO,argv[0],strlen(argv[0]));
88 (void) write(STDERR_FILENO,s,strlen(s));
89 (void) write(STDERR_FILENO,errbuf,
sizeof errbuf);
93 int getopt (
int argc,
char *
const argv [],
const char * opts)
95 static int sp = 1,
error = (
int)
'?';
96 static char sw =
'-', eos =
'\0', arg =
':';
97 register char c, * cp;
100 printf(
"DF_TRACE_DEBUG: int getopt () in getopt.c\n");
104 if (optind >= argc || argv[optind][0] != sw
105 || argv[optind][1] == eos)
107 else if (strcmp(argv[optind],
"--") == 0)
115 if (c == arg || (cp = strchr(opts,c)) == NULL)
117 ERR(argv,
": illegal option--",c);
118 if (argv[optind][++sp] == eos)
125 else if (*++cp == arg)
127 if (argv[optind][sp + 1] != eos)
128 optarg = &argv[optind++][sp + 1];
129 else if (++optind >= argc)
131 ERR(argv,
": option requires an argument--",c);
141 if (argv[optind][++sp] == eos)
int error(const char *test, int value)
static void ERR(char *const argv[], const char *s, char c)
static std::stack< cleanup * > c
int getopt(int argc, char *const argv[], const char *opts)