* Wraps def_getopt into a convenient loop+switch to process all
* arguments. This macro is intended to be called from main_XXX().
*
- * SWITCH_FOREACH_OPT(int *opt, const char *opts,
+ * SWITCH_FOREACH_OPT(int *opt, "OPTS",
* const struct option *longopts,
* const char *commandname,
* int num_opts_req) { ...
*
* opt: pointer to an int variable, holds the current option
* during processing.
- * opts: short options, as per getopt_long(3)'s optstring argument.
+ * OPTS: short options, as per getopt_long(3)'s optstring argument.
+ * do not include "h"; will be provided automatically
* longopts: long options, as per getopt_long(3)'s longopts argument.
* May be null.
* commandname: name of this command, for usage string.
*/
#define SWITCH_FOREACH_OPT(opt, opts, longopts, \
commandname, num_required_opts) \
- while (((opt) = def_getopt(argc, argv, (opts), (longopts), \
+ while (((opt) = def_getopt(argc, argv, "h" opts, (longopts), \
(commandname), (num_required_opts))) != -1) \
switch (opt)
uint32_t domid;
int opt, autopass = 0;
- SWITCH_FOREACH_OPT(opt, "ah", opts, "vncviewer", 1) {
+ SWITCH_FOREACH_OPT(opt, "a", opts, "vncviewer", 1) {
case 'a':
autopass = 1;
break;
{0, 0, 0, 0}
};
- SWITCH_FOREACH_OPT(opt, "FhcpdeVA", opts, "restore", 1) {
+ SWITCH_FOREACH_OPT(opt, "FcpdeVA", opts, "restore", 1) {
case 'c':
console_autoconnect = 1;
break;
argc--; argv++;
}
- SWITCH_FOREACH_OPT(opt, "Fhnqf:pcdeVA", opts, "create", 0) {
+ SWITCH_FOREACH_OPT(opt, "Fnqf:pcdeVA", opts, "create", 0) {
case 'f':
filename = optarg;
break;
argc--; argv++;
}
- SWITCH_FOREACH_OPT(opt, "dhqf:", opts, "config_update", 0) {
+ SWITCH_FOREACH_OPT(opt, "dqf:", opts, "config_update", 0) {
case 'd':
debug = 1;
break;
};
int numa = 0;
- SWITCH_FOREACH_OPT(opt, "hn", opts, "info", 0) {
+ SWITCH_FOREACH_OPT(opt, "n", opts, "info", 0) {
case 'n':
numa = 1;
break;
{0, 0, 0, 0}
};
- SWITCH_FOREACH_OPT(opt, "d:w:c:p:t:r:hs", opts, "sched-credit", 0) {
+ SWITCH_FOREACH_OPT(opt, "d:w:c:p:t:r:s", opts, "sched-credit", 0) {
case 'd':
dom = optarg;
break;
{0, 0, 0, 0}
};
- SWITCH_FOREACH_OPT(opt, "d:w:p:h", opts, "sched-credit2", 0) {
+ SWITCH_FOREACH_OPT(opt, "d:w:p:", opts, "sched-credit2", 0) {
case 'd':
dom = optarg;
break;
{0, 0, 0, 0}
};
- SWITCH_FOREACH_OPT(opt, "d:p:b:c:h", opts, "sched-rtds", 0) {
+ SWITCH_FOREACH_OPT(opt, "d:p:b:c:", opts, "sched-rtds", 0) {
case 'd':
dom = optarg;
break;
libxl_cputopology *topology;
int rc = 1;
- SWITCH_FOREACH_OPT(opt, "hnf:", opts, "cpupool-create", 0) {
+ SWITCH_FOREACH_OPT(opt, "nf:", opts, "cpupool-create", 0) {
case 'f':
filename = optarg;
break;
uint32_t poolid;
char *name;
- SWITCH_FOREACH_OPT(opt, "hc", opts, "cpupool-list", 0) {
+ SWITCH_FOREACH_OPT(opt, "c", opts, "cpupool-list", 0) {
case 'c':
opt_cpus = 1;
break;