+bool opt_early_parse(int argc, char *argv[],
+ void (*errlog)(const char *fmt, ...))
+{
+ int ret;
+ unsigned off = 0;
+ char **tmpargv = malloc(sizeof(argv[0]) * (argc + 1));
+
+ /* We could avoid a copy and skip instead, but this is simple. */
+ memcpy(tmpargv, argv, sizeof(argv[0]) * (argc + 1));
+
+ /* This helps opt_usage. */
+ opt_argv0 = argv[0];
+
+ while ((ret = parse_one(&argc, tmpargv, OPT_EARLY, &off, errlog)) == 1);
+
+ free(tmpargv);
+
+ /* parse_one returns 0 on finish, -1 on error */
+ return (ret == 0);
+}
+
+void opt_free_table(void)
+{
+ free(opt_table);
+ opt_table = NULL;
+ opt_count = opt_num_short = opt_num_short_arg = opt_num_long = 0;
+}
+