-static char *make_optstring(void)
-{
- char *str = malloc(1 + opt_num_short + opt_num_short_arg + 1);
- const char *p;
- unsigned int i, num = 0;
-
- /* This tells getopt_long we want a ':' returned for missing arg. */
- str[num++] = ':';
- for (p = first_sopt(&i); p; p = next_sopt(p, &i)) {
- str[num++] = *p;
- if (opt_table[i].type == OPT_HASARG)
- str[num++] = ':';
- }
- str[num++] = '\0';
- assert(num == 1 + opt_num_short + opt_num_short_arg + 1);
- return str;
-}
-
-static struct option *make_options(void)
-{
- struct option *options = malloc(sizeof(*options) * (opt_num_long + 1));
- unsigned int i, num = 0, len = 0 /* GCC bogus warning */;
- const char *p;
-
- for (p = first_lopt(&i, &len); p; p = next_lopt(p, &i, &len)) {
- char *buf = malloc(len + 1);
- memcpy(buf, p, len);
- buf[len] = 0;
- options[num].name = buf;
- options[num].has_arg = (opt_table[i].type == OPT_HASARG);
- options[num].flag = NULL;
- options[num].val = 0;
- num++;
- }
- memset(&options[num], 0, sizeof(options[num]));
- assert(num == opt_num_long);
- return options;
-}
-
-static struct opt_table *find_short(char shortopt)
+/* Parse your arguments. */
+bool opt_parse(int *argc, char *argv[], void (*errlog)(const char *fmt, ...))