X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/adns/blobdiff_plain/4ae90a83213075b16de83520a2c07402491bb33f..0b6f56ccd83f0715e55855b4ddbdc7db897c4a7a:/client/adh-opts.c diff --git a/client/adh-opts.c b/client/adh-opts.c index 6af9e02..e7704a1 100644 --- a/client/adh-opts.c +++ b/client/adh-opts.c @@ -297,14 +297,28 @@ static const struct optioninfo *find(const char **optp, const struct optioninfo *opt_findl(const char *opt) { return find(&opt,"--",oc_long); } const struct optioninfo *opt_finds(const char **optp) { return find(optp,"-",oc_short); } -void opt_do(const struct optioninfo *oip, const char *arg) { +static void noninvert(const struct optioninfo *oip) NONRETURNING; +static void noninvert(const struct optioninfo *oip) { + usageerr("option %s%s%s%s%s may not be inverted", + oip->sopt ? "-" : "", oip->sopt ? oip->sopt : "", + oip->lopt && oip->sopt ? " / " : "", + oip->lopt ? "--" : "", oip->lopt ? oip->lopt : ""); +} + +void opt_do(const struct optioninfo *oip, const char *arg, int invert) { switch (oip->type) { - case ot_flag: case ot_value: + case ot_flag: + assert(!arg); + *oip->storep= invert ? !oip->value : oip->value; + return; + case ot_value: assert(!arg); + if (invert) noninvert(oip); *oip->storep= oip->value; return; case ot_func: case ot_funcarg: - oip->func(oip,0); + if (invert) noninvert(oip); + oip->func(oip,arg); return; default: abort();