X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=client%2Fadh-opts.c;h=5b38dea77cef737480f6633e173752077baf9533;hb=3d1ae6ea11f3fa0f7eda890c7c81dc6a1ba76a95;hp=bc32ba9bb527c1c3ead985d9e3d30b72b2ae5f0f;hpb=e3f575ffc7bcb15d23f6844c7cf5562d2b93ac40;p=adns.git diff --git a/client/adh-opts.c b/client/adh-opts.c index bc32ba9..5b38dea 100644 --- a/client/adh-opts.c +++ b/client/adh-opts.c @@ -64,6 +64,8 @@ static const struct optioninfo perquery_options[]= { { ot_desconly, "per-query options:" }, { ot_funcarg, "Query type (see below)", "t", "type", 0,0, &of_type, "type" }, + { ot_funcarg, "Do reverse query (address -> name lookup)", + "i", "ptr", 0,0, &of_ptr, "addr" }, { ot_desconly, "per-query binary options:" }, { ot_flag, "Use the search list", @@ -101,8 +103,8 @@ static const struct optioninfo perquery_options[]= { { ot_desconly, "asynchronous/pipe mode options:" }, { ot_funcarg, "Set , default is decimal sequence starting 0", - "i", "asynch-id", 0,0, &of_asynch_id, "id" }, - { ot_funcarg, "Cancel the query with id ", + 0, "asynch-id", 0,0, &of_asynch_id, "id" }, + { ot_funcarg, "Cancel the query with id (no error if not found)", 0, "cancel-id", 0,0, &of_cancel_id, "id" }, { ot_end } @@ -214,11 +216,13 @@ static void printusage(void) { "or if the domain refers to a CNAME and --show-cname is on\n" " [] [] CNAME \n" " [] [] \n" - "When a query fails you get a line like:\n" - " ; failed [] [] [] \"\"\n" + "When a query fails you get a line like this (broken here for readability):\n" + " ; failed \\\n" + " [] [] [] \"\"\n" "\n" "If you use --asynch each answer (success or failure) is preceded by a line\n" - " [] \"\"\n" + " \\\n" + " [] [] [] \"\"\n" "where is the number of RRs that follow and will be `$' or\n" "the CNAME target; the CNAME indirection and error formats above are not used.\n" "\n" @@ -237,7 +241,8 @@ static void printusage(void) { "Query types (see adns.h; default is addr):\n" " ns soa ptr mx rp addr - enhanced versions\n" " cname hinfo txt - types with only one version\n" - " a ns- soa- ptr- mx- rp- - _raw versions\n", + " a ns- soa- ptr- mx- rp- - _raw versions\n" + "Default is addr, or ptr for -i/--ptr queries\n", stdout); if (ferror(stdout)) sysfail("write usage message",errno); } @@ -292,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; + 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();