X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;ds=sidebyside;f=client%2Fadh-opts.c;h=7dbedcd04e16bc403d8ae694b009b99b499ff167;hb=fc440c64836370db9d8cb1a25f09c9df0786f865;hp=af8afbdec13b3f94b1bb466d44ed1a1018d9261a;hpb=2b1c6979bb36a0e3a5aaa7f18b0c72b528f886b9;p=adns.git diff --git a/client/adh-opts.c b/client/adh-opts.c index af8afbd..7dbedcd 100644 --- a/client/adh-opts.c +++ b/client/adh-opts.c @@ -4,16 +4,16 @@ * 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,2014-2016,2020 Ian Jackson + * Copyright (C) 2014 Mark Wooding + * 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 - * the Free Software Foundation; either version 2, or (at your option) + * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, @@ -22,8 +22,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * along with this program; if not, write to the Free Software Foundation. */ #include "adnshost.h" @@ -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, ov_format=fmt_default; +int ov_tcp=0, ov_cname=0, ov_afflags=0, ov_v6map=0, ov_format=fmt_default; char *ov_id= 0; struct perqueryflags_remember ov_pqfr = { 1,1,1, tm_none }; @@ -46,11 +45,11 @@ static const struct optioninfo global_options[]= { "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)", + { 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", + { 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)", + { ot_value, "Fully-parseable output format (default for --asynch)", "Fa", "fmt-asynch", &ov_format, fmt_asynch }, { ot_desconly, "global verbosity level:" }, @@ -62,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 }, @@ -102,6 +105,16 @@ 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_desconly, "per-query address family options (for `addr' etc.):" }, + { ot_value, "Only return IPv4 addresses", + "A4", "--addr-ipv4-only", &ov_afflags, adns_qf_want_ipv4 }, + { ot_value, "Only return IPv6 addresses", + "A6", "--addr-ipv6-only", &ov_afflags, adns_qf_want_ipv6 }, + { ot_value, "Return all available addresses (default)", + "Aa", "--addr-all", &ov_afflags, 0 }, + { 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", @@ -114,7 +127,7 @@ static const struct optioninfo perquery_options[]= { { ot_desconly, "asynchronous/pipe mode options:" }, { ot_funcarg, "Set , default is decimal sequence starting 0", 0, "asynch-id", 0,0, &of_asynch_id, "id" }, - { ot_funcarg, "Cancel the query with id (no error if not found)", + { ot_funcarg, "Cancel the query with id (no error if not found)", 0, "cancel-id", 0,0, &of_cancel_id, "id" }, { ot_end } @@ -259,18 +272,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_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);