1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| static int arg_handle(const struct cmdopt *opt, const char **argv, void *data);
const struct cmdopt options[] = { { "h", 1, arg_handle }, { "p", 1, arg_handle } };
static int arg_handle(const struct cmdopt *opt, const char **argv, void *data) { printf("%s %s %p\n", opt->name, argv[0], data); return opt->argnums; }
int main(int argc, const char **argv) { cmdarg_parse(argc - 1, &argv[1], options, 2, NULL); return 0; }
|