};
static int opt_handler(optcfg *oc, int opt, void *cls);
+static int arg_handler(optcfg *oc, const char *arg, void *cls);
bool init_options(int argc, char **argv, const char *cfgfile)
{
optcfg *oc = optcfg_init(options);
optcfg_set_opt_callback(oc, opt_handler, 0);
+ optcfg_set_arg_callback(oc, arg_handler, 0);
if(cfgfile) {
optcfg_parse_config_file(oc, cfgfile);
optcfg_print_options(oc);
exit(0);
}
- return true;
+ return 0;
+}
+
+static int arg_handler(optcfg *oc, const char *arg, void *cls)
+{
+ if(opt.path) {
+ fprintf(stderr, "unexpected argument: %s\n", arg);
+ return -1;
+ }
+ opt.path = arg;
+ return 0;
}