{
op = getopt_long(argc, argv, command_optstring, command_opts, NULL);
switch (op)
+ {
+ case '+':
+ case 'v':
+ continue;
+ default:
+ *arg = optarg;
+ return op;
+ }
+ }
+}
+
+/**
+ * Process options common for all commands
+ */
+static bool process_common_opts()
+{
+ while (TRUE)
+ {
+ switch (getopt_long(argc, argv, command_optstring, command_opts, NULL))
{
case '+':
if (!options->from(options, optarg, &argc, &argv, optind))
{
- /* a error value */
- return 255;
+ return FALSE;
}
continue;
case 'v':
dbg_default_set_level(atoi(optarg));
continue;
default:
- *arg = optarg;
- return op;
+ continue;
+ case '?':
+ return FALSE;
+ case EOF:
+ return TRUE;
}
}
}
{
active = i;
build_opts();
+ if (!process_common_opts())
+ {
+ return command_usage("invalid options");
+ }
+ optind = 2;
return cmds[i].call();
}
}