X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=vrfileman;a=blobdiff_plain;f=src%2Fopt.cc;h=6698f8c30f5a7a6396bd57d2ae334d4c490acdb6;hp=de3f5a378464bb6c8b44b02d9a4acb706d5f47dc;hb=f737a4688a44fa05c9a5ea7919819437fae85ae1;hpb=eca943b2fb891a01cb4e883c07aad2167a8ac94b diff --git a/src/opt.cc b/src/opt.cc index de3f5a3..6698f8c 100644 --- a/src/opt.cc +++ b/src/opt.cc @@ -27,6 +27,7 @@ static optcfg_option options[] = { }; 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) { @@ -38,6 +39,7 @@ 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); @@ -94,5 +96,15 @@ static int opt_handler(optcfg *oc, int optid, void *cls) 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; }