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
38("usage: adnshost [global-opts] [query-opts] query-type query-domain\n"
39 " [[query-opts] [query-type] query-domain ...]\n"
40 " adnshost [global-opts] [query-opts] -f|--pipe\n"
41 "\n"
42 "global binary options:\n"
43 " +e --no-env No not look at environment variables at all.\n"
44 " -f --pipe Read queries on stdin instead of using args.\n"
45 " -A --asynch Allow answers to be reordered.\n"
46 " -0 --null stdin items are delimited by nulls.\n"
47 "global verbosity level:\n"
48 " -vq --quiet Do not print anything to stderr.\n"
49 " -vn --no-quiet Report unexpected kinds of problem only.\n"
50 " -vd --debug Debugging mode.\n"
51 "other global options:\n"
52 " --help, --version Print usage or version information.\n"
53 "\n"
54 "per-query binary options:\n"
55 " -R --search Use the search list.\n"
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"
60 " +fo --no-owner Do not display owner name in output.\n"
61 " +ft --no-type Do not display RR type in output.\n"
62 " +fc --no-show-cname Do not display CNAME target in output.\n"
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"
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 "other per-query options:\n"
72 " -I<id> ) Set the <id> to print in the output with --async.\n"
73 " --asynch-id <id> ) Default is a sequence number in decimal starting at 0.\n"
74 "\n"
75 "For binary options, --FOO and --no-FOO are opposites,\n"
76 "as are -X and +X; in each case the default is the one not listed.\n"
77 "Per query options stay set a particular way until they are reset,\n"
78 "whether they appear on the command line or on stdin.\n"
79 "\n"
80 "Output format is master file format without class or TTL by default:\n"
81 " [<owner>] [<ttl>] [<type>] <data>\n"
82 "or if the <owner> domain refers to a CNAME and --show-cname is on\n"
83 " [<owner>] [<ttl>] CNAME <cname>\n"
84 " [<cname>] [<ttl>] <type> <data>\n"
85 "When a query fails you get a line like:\n"
86 " ; failed <statustype> [<owner>] [<ttl>] [<type>] <status> \"<status string>\"\n"
87 "If you use --asynch, you don't get that. Instead, each answer (success or\n"
88 "failure) is preceded by a line:\n"
89 " <id> <statustype> <status> <nrrs> [<cname>] \"<status string>\"\n"
90 "where <nrrs> is the number of RRs that follow and <cname> will be `$' or\n"
91 "the canonical name.\n"
92 "\n"
93 "With -f, the input should be a list of arguments one per line (ie separated\n"
94 "by newlines), or separated by null characters if -0 or --null was used\n"
95 "\n"
96 "Exit status:\n"
97 " 0 all went well\n"
98 " 1-6 at least one query failed with statustype:\n"
99 " 1 localfail )\n"
100 " 2 remotefail ) temporary errors\n"
101 " 3 tempfail __)_________________\n"
102 " 4 misconfig )\n"
103 " 5 misquery ) permanent errors\n"
104 " 6 permfail )\n"
105 " 10 system trouble\n"
106 " 11 usage problems\n"
107 "\n"
108 "Query types (see adns.h):\n"
109 " NS SOA PTR MX RP A - enhanced versions\n"
110 " CNAME HINFO TXT - types with only one version\n"
111 " A- NS- SOA- PTR- MX- RP- - _raw versions\n",
112 stdout) == EOF) sysfail("write usage message",errno);
113}
114
115int main(int argc, const char *const *argv) {
116 printusage();
117 if (fclose(stdout)) sysfail("finish writing output",errno);
118 exit(0);
119}