X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=adns.git;a=blobdiff_plain;f=client%2Fadh-opts.c;h=7670ba5a115b9a24662c40f8a18bc9d40a394ea3;hp=5b38dea77cef737480f6633e173752077baf9533;hb=cdf51ff0be2d71b61dec430d08c985f20cc5dffd;hpb=d7449548b74b994a0d7390c5f153f40f02b46105 diff --git a/client/adh-opts.c b/client/adh-opts.c index 5b38dea..7670ba5 100644 --- a/client/adh-opts.c +++ b/client/adh-opts.c @@ -4,12 +4,11 @@ * option handling tables etc. */ /* - * This file is - * Copyright (C) 1997-1999 Ian Jackson - * - * It is part of adns, which is - * Copyright (C) 1997-1999 Ian Jackson - * Copyright (C) 1999 Tony Finch + * This file is part of adns, which is + * Copyright (C) 1997-2000,2003,2006 Ian Jackson + * Copyright (C) 1999-2000,2003,2006 Tony Finch + * Copyright (C) 1991 Massachusetts Institute of Technology + * (See the file INSTALL for full details.) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,7 +31,7 @@ int ov_env=1, ov_pipe=0, ov_asynch=0; int ov_verbose= 0; adns_rrtype ov_type= adns_r_none; int ov_search=0, ov_qc_query=0, ov_qc_anshost=0, ov_qc_cname=1; -int ov_tcp=0, ov_cname=0; +int ov_tcp=0, ov_cname=0, ov_v6map=0, ov_format=fmt_default; char *ov_id= 0; struct perqueryflags_remember ov_pqfr = { 1,1,1, tm_none }; @@ -44,6 +43,14 @@ static const struct optioninfo global_options[]= { "f", "pipe", &ov_pipe, 1 }, { ot_flag, "Allow answers to be reordered", "a", "asynch", &ov_asynch, 1 }, + + { ot_desconly, "answer/error output format and destination (see below):" }, + { ot_value, "Answers to stdout, errors as messages to stderr (default)", + "Fs", "fmt-simple", &ov_format, fmt_simple }, + { ot_value, "Answers and errors both to stdout in parseable format", + "Fi", "fmt-inline", &ov_format, fmt_inline }, + { ot_value, "Fully-parseable output format (default for --asynch)", + "Fa", "fmt-asynch", &ov_format, fmt_asynch }, { ot_desconly, "global verbosity level:" }, { ot_value, "Do not print anything to stderr", @@ -54,6 +61,10 @@ static const struct optioninfo global_options[]= { "Vd", "debug", &ov_verbose, adns_if_debug }, { ot_desconly, "other global options:" }, + { ot_funcarg, "Configuration to use instead of /etc/resolv.conf", + 0, "config", 0,0, of_config, "" }, + { ot_func, "Print version number", + 0, "version", 0,0, of_version }, { ot_func, "Print usage information", 0, "help", 0,0, of_help }, @@ -66,6 +77,8 @@ static const struct optioninfo perquery_options[]= { "t", "type", 0,0, &of_type, "type" }, { ot_funcarg, "Do reverse query (address -> name lookup)", "i", "ptr", 0,0, &of_ptr, "addr" }, + { ot_funcarg2, "Lookup in in-addr-like `zone' (eg MAPS RBL)", + 0, "reverse", 0,0, &of_reverse, "addr","zone" }, { ot_desconly, "per-query binary options:" }, { ot_flag, "Use the search list", @@ -92,6 +105,9 @@ static const struct optioninfo perquery_options[]= { "Ta", "ttl-abs", &ov_pqfr.ttl, tm_abs }, { ot_value, "Do not show the TTL (default)", "Tn", "no-ttl", &ov_pqfr.ttl, tm_none }, + + { ot_flag, "Return IPv4 addresses as IPv6-mapped", + "Am", "--addr-ipv6-mapped", &ov_v6map, 1 }, { ot_desconly, "per-query CNAME handling mode:" }, { ot_value, "Call it an error if a CNAME is found", @@ -184,6 +200,15 @@ static void printusage(void) { oip->desc); } break; + case ot_funcarg2: + assert(!oip->sopt); + l= (maxlopt + maxsopt - 2 - + (strlen(oip->lopt) + strlen(oip->argdesc) + strlen(oip->argdesc2))); + printf(" --%s <%s> <%s>%*s%s\n", + oip->lopt, oip->argdesc, oip->argdesc2, + l>2 ? l : 2, "", + oip->desc); + break; case ot_desconly: printf("%s\n", oip->desc); break; @@ -216,11 +241,12 @@ 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 this (broken here for readability):\n" + "When a query fails you get an error message to stderr (with --fmt-simple).\n" + "Specify --fmt-inline for lines 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" + "If you use --fmt-asynch, which is the default for --asynch,\n" + "each answer (success or failure) is preceded by a line\n" " \\\n" " [] [] [] \"\"\n" "where is the number of RRs that follow and will be `$' or\n" @@ -239,18 +265,23 @@ static void printusage(void) { " 11 usage problems\n" "\n" "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" + " ns soa ptr mx rp srv addr - enhanced versions\n" + " cname hinfo txt - types with only one version\n" + " a aaaa ns- soa- ptr- mx- rp- srv- - _raw versions\n" + " type - `unknown' type, RFC3597\n" "Default is addr, or ptr for -i/--ptr queries\n", stdout); if (ferror(stdout)) sysfail("write usage message",errno); } -void of_help(const struct optioninfo *oi, const char *arg) { +void of_version(const struct optioninfo *oi, const char *arg, const char *arg2) { + VERSION_PRINT_QUIT("adnshost"); +} + +void of_help(const struct optioninfo *oi, const char *arg, const char *arg2) { printusage(); if (fclose(stdout)) sysfail("finish writing output",errno); - exit(0); + quitnow(0); } typedef int comparer_type(const char **optp, const struct optioninfo *entry); @@ -285,12 +316,14 @@ static const struct optioninfo *find(const char **optp, const char *prefix, comparer_type *comparer) { const struct optioninfo *oip; + const char *opt; + opt= *optp; oip= find1(optp,perquery_options,comparer); if (oip) return oip; oip= find1(optp,global_options,comparer); - if (!oip) usageerr("unknown option %s%s",prefix,*optp); - if (ads) usageerr("global option %s%s specified after query domain(s)",prefix,*optp); + if (!oip) usageerr("unknown option %s%s",prefix,opt); + if (ads) usageerr("global option %s%s specified after query domain(s)",prefix,opt); return oip; } @@ -305,7 +338,8 @@ static void noninvert(const struct optioninfo *oip) { oip->lopt ? "--" : "", oip->lopt ? oip->lopt : ""); } -void opt_do(const struct optioninfo *oip, const char *arg, int invert) { +void opt_do(const struct optioninfo *oip, int invert, + const char *arg, const char *arg2) { switch (oip->type) { case ot_flag: assert(!arg); @@ -316,9 +350,9 @@ void opt_do(const struct optioninfo *oip, const char *arg, int invert) { if (invert) noninvert(oip); *oip->storep= oip->value; return; - case ot_func: case ot_funcarg: + case ot_func: case ot_funcarg: case ot_funcarg2: if (invert) noninvert(oip); - oip->func(oip,arg); + oip->func(oip,arg,arg2); return; default: abort();