+ * New adnshost utility - currently only a usage message :-).
[adns] / client / adnshost.c
CommitLineData
b0f83da6 1/*
2 * adnshost.c
3 * - useful general-purpose resolver client program
4 */
5/*
6 * This file is part of adns, which is Copyright (C) 1997-1999 Ian Jackson
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 */
22
23#include <stdio.h>
24#include <string.h>
25#include <errno.h>
26
27#include "config.h"
28
29static void sysfail(const char *what, int errnoval) NONRETURNING;
30static void sysfail(const char *what, int errnoval) {
31 fprintf(stderr,"adnshost failed: %s: %s\n",what,strerror(errnoval));
32 exit(10);
33}
34
35
36static void printusage(void) {
37 if (fputs
96fa2e75 38("usage: adnshost [global-opts] [query-opts] query-domain\n"
39 " [[query-opts] query-domain ...]\n"
b0f83da6 40 " adnshost [global-opts] [query-opts] -f|--pipe\n"
41 "\n"
42 "global binary options:\n"
96fa2e75 43 " +e --no-env Do not look at environment variables at all.\n"
b0f83da6 44 " -f --pipe Read queries on stdin instead of using args.\n"
96fa2e75 45 " -a --asynch Allow answers to be reordered.\n"
b0f83da6 46 " -0 --null stdin items are delimited by nulls.\n"
47 "global verbosity level:\n"
96fa2e75 48 " -Vq --quiet Do not print anything to stderr.\n"
49 " -Vn --no-quiet Report unexpected kinds of problem only. (default)\n"
50 " -Vd --debug Debugging mode.\n"
b0f83da6 51 "other global options:\n"
52 " --help, --version Print usage or version information.\n"
53 "\n"
54 "per-query binary options:\n"
96fa2e75 55 " -s --search Use the search list.\n"
b0f83da6 56 " -Qq --qc-query Let query domains contain quote-requiring chars.\n"
57 " -Qa --qc-anshost Let hostnames in answers contain ...\n"
58 " +Qc --no-qc-cname Prevent CNAME target domains from containing ...\n"
59 " -u --tcp Force use of a virtual circuit.\n"
96fa2e75 60 " +Do --no-owner Do not display owner name in output.\n"
61 " +Dt --no-type Do not display RR type in output.\n"
62 " +Dc --no-show-cname Do not display CNAME target in output.\n"
b0f83da6 63 "per-query TTL mode (NB TTL is minimum across whole query reply):\n"
64 " -Tt --ttl-ttl Show the TTL as a TTL.\n"
65 " -Ta --ttl-abs Show the TTL as a time_t when the data might expire.\n"
66 " -Tn --no-ttl Do not show the TTL (default).\n"
67 "per-query cname handling mode:\n"
96fa2e75 68 " -Cf --cname-reject Call it an error if a CNAME is found.\n"
69 " -Cl --cname-loose Allow references to CNAMEs in other RRs.\n"
70 " -Cs --cname-ok CNAME ok for query domain, but not in RRs (default).\n"
71 "query type:\n"
72 " -t<type> } Set the query type (see below).\n"
73 " --type <type> } Default is addr. Not case-sensitive.\n"
b0f83da6 74 "other per-query options:\n"
96fa2e75 75 " -i<id> } Set the <id> to print in the output with --async;\n"
76 " --asynch-id <id> } default is a sequence number in decimal starting at 0.\n"
77 " --cancel-id <id> Cancel the query with id <id>.\n"
78 " - <domain> Next argument is a domain, but more options may follow.\n"
b0f83da6 79 "\n"
96fa2e75 80 "For binary options, --FOO and --no-FOO are opposites, as are\n"
81 "-X and +X. In each case the default is the one not listed.\n"
b0f83da6 82 "Per query options stay set a particular way until they are reset,\n"
83 "whether they appear on the command line or on stdin.\n"
96fa2e75 84 "All global options must preceed the first query domain.\n"
b0f83da6 85 "\n"
86 "Output format is master file format without class or TTL by default:\n"
87 " [<owner>] [<ttl>] [<type>] <data>\n"
88 "or if the <owner> domain refers to a CNAME and --show-cname is on\n"
89 " [<owner>] [<ttl>] CNAME <cname>\n"
90 " [<cname>] [<ttl>] <type> <data>\n"
91 "When a query fails you get a line like:\n"
92 " ; failed <statustype> [<owner>] [<ttl>] [<type>] <status> \"<status string>\"\n"
93 "If you use --asynch, you don't get that. Instead, each answer (success or\n"
94 "failure) is preceded by a line:\n"
95 " <id> <statustype> <status> <nrrs> [<cname>] \"<status string>\"\n"
96 "where <nrrs> is the number of RRs that follow and <cname> will be `$' or\n"
97 "the canonical name.\n"
98 "\n"
99 "With -f, the input should be a list of arguments one per line (ie separated\n"
100 "by newlines), or separated by null characters if -0 or --null was used\n"
101 "\n"
102 "Exit status:\n"
103 " 0 all went well\n"
104 " 1-6 at least one query failed with statustype:\n"
105 " 1 localfail )\n"
106 " 2 remotefail ) temporary errors\n"
107 " 3 tempfail __)_________________\n"
108 " 4 misconfig )\n"
109 " 5 misquery ) permanent errors\n"
110 " 6 permfail )\n"
111 " 10 system trouble\n"
112 " 11 usage problems\n"
113 "\n"
114 "Query types (see adns.h):\n"
96fa2e75 115 " ns soa ptr mx rp addr - enhanced versions\n"
116 " cname hinfo txt - types with only one version\n"
117 " a ns- soa- ptr- mx- rp- - _raw versions\n",
b0f83da6 118 stdout) == EOF) sysfail("write usage message",errno);
119}
120
121int main(int argc, const char *const *argv) {
122 printusage();
123 if (fclose(stdout)) sysfail("finish writing output",errno);
124 exit(0);
125}