+struct optinfo;
+typedef void optfunc(const struct optinfo *oi, const char *arg);
+
+struct optinfo {
+ enum oi_type {
+ ot_end, ot_desconly,
+ ot_flag, ot_value, ot_func, ot_funcarg
+ } type;
+ const char *desc;
+ const char *sopt, *lopt;
+ int *storep, value;
+ optfunc *func;
+ const char *argdesc;
+};
+
+static int ov_env=1, ov_pipe=0, ov_asynch=0;
+static int ov_verbose= 0;
+static int ov_search=0, ov_qc_query=0, ov_qc_anshost=0, ov_qc_cname=1;
+static int ov_tcp=0, ov_show_owner=1, ov_show_type=1, ov_show_cname=1;
+static int ov_cname=0;
+enum ttlmode { tm_none, tm_rel, tm_abs };
+static int ov_ttl= tm_none;
+
+static optfunc of_help, of_type, of_asynch_id, of_cancel_id;
+
+static const struct optinfo global_options[]= {
+ { ot_desconly, "global binary options:" },
+ { ot_flag, "Do not look at environment variables at all",
+ "e", "env", &ov_env, 0 },
+ { ot_flag, "Read queries on stdin instead of using args",
+ "f", "pipe", &ov_pipe, 1 },
+ { ot_flag, "Allow answers to be reordered",
+ "a", "asynch", &ov_asynch, 1 },
+
+ { ot_desconly, "global verbosity level:" },
+ { ot_value, "Do not print anything to stderr",
+ "Vq", "quiet", &ov_verbose, adns_if_noerrprint },
+ { ot_value, "Report unexpected kinds of problem only (default)",
+ "Vn", "no-quiet", &ov_verbose, 0 },
+ { ot_value, "Debugging mode",
+ "Vd", "debug", &ov_verbose, adns_if_debug },
+
+ { ot_desconly, "other global options:" },
+ { ot_func, "Print usage information",
+ 0, "help", 0,0, of_help },
+
+ { ot_end }
+};
+
+static const struct optinfo perquery_options[]= {
+ { ot_desconly, "per-query options:" },
+ { ot_funcarg, "Query type (see below)",
+ "t", "type", 0,0, &of_type, "type" },
+
+ { ot_desconly, "per-query binary options:" },
+ { ot_flag, "Use the search list",
+ "s", "search", &ov_search, 1 },
+ { ot_flag, "Let query domains contain quote-requiring chars",
+ "Qq", "qc-query", &ov_qc_query, 1 },
+ { ot_flag, "Let hostnames in answers contain ...",
+ "Qa", "qc-anshost", &ov_qc_anshost, 1 },
+ { ot_flag, "Prevent CNAME target domains from containing ...",
+ "Qc", "qc-cname", &ov_qc_cname, 0 },
+ { ot_flag, "Force use of a virtual circuit",
+ "u", "tcp", &ov_tcp, 1 },
+ { ot_flag, "Do not display owner name in output",
+ "Do", "show-owner", &ov_show_owner, 0 },
+ { ot_flag, "Do not display RR type in output",
+ "Dt", "show-type", &ov_show_type, 0 },
+ { ot_flag, "Do not display CNAME target in output",
+ "Dc", "show-cname", &ov_show_cname, 0 },
+
+ { ot_desconly, "per-query TTL mode (NB TTL is minimum across all info in reply):" },
+ { ot_value, "Show the TTL as a TTL",
+ "Tt", "ttl-ttl", &ov_ttl, tm_rel },
+ { ot_value, "Show the TTL as a time_t when the data might expire",
+ "Ta", "ttl-abs", &ov_ttl, tm_abs },
+ { ot_value, "Do not show the TTL (default)",
+ "Tn", "no-ttl", &ov_ttl, tm_none },
+
+ { ot_desconly, "per-query CNAME handling mode:" },
+ { ot_value, "Call it an error if a CNAME is found",
+ "Cf", "cname-reject", &ov_cname, adns_qf_cname_forbid },
+ { ot_value, "Allow references to CNAMEs in other RRs",
+ "Cl", "cname-loose", &ov_cname, adns_qf_cname_loose },
+ { ot_value, "CNAME ok for query domain, but not in RRs (default)",
+ "Cs", "cname-ok", &ov_cname, 0 },
+
+ { ot_end }
+};
+
+static const struct optinfo asynch_options[]= {
+ { ot_desconly, "asynchronous mode `options':" },
+ { ot_funcarg, "Set <id>, default is decimal sequence starting 0",
+ "i", "asynch-id", 0,0, &of_asynch_id, "id" },
+ { ot_funcarg, "Cancel the query with id <id>",
+ 0, "cancel-id", 0,0, &of_cancel_id, "id" },
+
+ { ot_end }
+};