version 1.35, 2020/06/12 07:10:43 |
version 1.36, 2021/08/20 17:53:54 |
|
|
return (RB_FIND(args_tree, &args->tree, &entry)); |
return (RB_FIND(args_tree, &args->tree, &entry)); |
} |
} |
|
|
|
/* Create an empty arguments set. */ |
|
struct args * |
|
args_create(void) |
|
{ |
|
struct args *args; |
|
|
|
args = xcalloc(1, sizeof *args); |
|
RB_INIT(&args->tree); |
|
return (args); |
|
} |
|
|
/* Parse an argv and argc into a new argument set. */ |
/* Parse an argv and argc into a new argument set. */ |
struct args * |
struct args * |
args_parse(const char *template, int argc, char **argv) |
args_parse(const char *template, int argc, char **argv) |
|
|
struct args *args; |
struct args *args; |
int opt; |
int opt; |
|
|
args = xcalloc(1, sizeof *args); |
|
|
|
optreset = 1; |
optreset = 1; |
optind = 1; |
optind = 1; |
optarg = NULL; |
optarg = NULL; |
|
|
|
args = args_create(); |
while ((opt = getopt(argc, argv, template)) != -1) { |
while ((opt = getopt(argc, argv, template)) != -1) { |
if (opt < 0) |
if (opt < 0) |
continue; |
continue; |