version 1.7, 2014/01/09 13:51:57 |
version 1.8, 2014/01/15 11:44:18 |
|
|
args_parse(const char *template, int argc, char **argv) |
args_parse(const char *template, int argc, char **argv) |
{ |
{ |
struct args *args; |
struct args *args; |
char *ptr; |
|
int opt; |
int opt; |
|
|
args = xcalloc(1, sizeof *args); |
args = xcalloc(1, sizeof *args); |
|
|
while ((opt = getopt(argc, argv, template)) != -1) { |
while ((opt = getopt(argc, argv, template)) != -1) { |
if (opt < 0) |
if (opt < 0) |
continue; |
continue; |
if (opt == '?' || (ptr = strchr(template, opt)) == NULL) { |
if (opt == '?' || strchr(template, opt) == NULL) { |
args_free(args); |
args_free(args); |
return (NULL); |
return (NULL); |
} |
} |