chiark / gitweb /
Remove spurious semicolon.
[adns.git] / client / adh-opts.c
index 03ba5bbfc28eecfa189f1f5ea20193cb01eb8e97..5b38dea77cef737480f6633e173752077baf9533 100644 (file)
@@ -65,7 +65,7 @@ static const struct optioninfo perquery_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_type, "addr" },
+    "i", "ptr",            0,0, &of_ptr, "addr" },
 
   { ot_desconly, "per-query binary options:" },
   { ot_flag,             "Use the search list",
@@ -104,7 +104,7 @@ static const struct optioninfo perquery_options[]= {
   { ot_desconly, "asynchronous/pipe mode options:" },
   { ot_funcarg,          "Set <id>, default is decimal sequence starting 0",
     0, "asynch-id",        0,0, &of_asynch_id, "id" },
-  { ot_funcarg,          "Cancel the query with id <id>",
+  { ot_funcarg,          "Cancel the query with id <id> (no error if not found)",
     0, "cancel-id",        0,0, &of_cancel_id, "id" },
 
   { ot_end }
@@ -216,11 +216,13 @@ static void printusage(void) {
        "or if the <owner> domain refers to a CNAME and --show-cname is on\n"
        "   [<owner>] [<ttl>] CNAME <cname>\n"
        "   [<cname>] [<ttl>] <type> <data>\n"
-       "When a query fails you get a line like:\n"
- "   ; failed <statustype> [<owner>] [<ttl>] [<type>] <status> \"<status string>\"\n"
+       "When a query fails you get a line like this (broken here for readability):\n"
+       "   ; failed <statustype> <statusnum> <statusabbrev> \\\n"
+       "       [<owner>] [<ttl>] [<cname>] \"<status string>\"\n"
        "\n"
        "If you use --asynch each answer (success or failure) is preceded by a line\n"
-       "   <id> <statustype> <status> <nrrs> [<cname>] \"<status string>\"\n"
+       "   <id> <nrrs> <statustype> <statusnum> <statusabbrev> \\\n"
+       "       [<owner>] [<ttl>] [<cname>] \"<status string>\"\n"
        "where <nrrs> is the number of RRs that follow and <cname> will be `$' or\n"
        "the CNAME target; the CNAME indirection and error formats above are not used.\n"
        "\n"
@@ -295,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();