26#if !LELY_HAVE_UNISTD_H
46getopt(
int argc,
char *
const argv[],
const char *optstring)
61 if (*cp++ !=
'-' || !*cp)
64 if (*cp ==
'-' && !cp[1]) {
80 const char *op = optstring;
81 while (*op && (*op ==
':' || *op ==
'?' || *op != c))
86 if (
opterr && *optstring !=
':')
87 fprintf(stderr,
"%s: illegal option -- %c\n", argv[0],
108 if (
opterr && *optstring !=
':')
110 "%s: option requires an "
114 return *optstring ==
':' ?
':' :
'?';
int getopt(int argc, char *const argv[], const char *optstring)
Parses options passed as arguments to main().
static int optoff
The offset (in characters) of the next option with respect to the beginning of the current option arg...
This is the internal header file of the C11 and POSIX compatibility library.
This header file is part of the C11 and POSIX compatibility library; it includes <stddef....
This header file is part of the C11 and POSIX compatibility library; it includes <stdio....
This header file is part of the C11 and POSIX compatibility library; it includes <unistd....
int optopt
The last option character to cause an error.
int optind
The index of the next argument to be parsed by getopt().
char * optarg
A pointer to the argument of the current option.
int opterr
A flag indicating whether a diagnostic message should be printed if an unknown option character or mi...