Commit b89decfc authored by Evan Hunt's avatar Evan Hunt Committed by Michał Kępień

replace fputs() with fprintf()

parent a6e6d0c1
Pipeline #40852 passed with stages
in 24 minutes and 47 seconds
......@@ -30,7 +30,7 @@ notify(const char *fmt, ...) {
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
fputs("\n", stderr);
fprintf(stderr, "\n");
}
}
......
......@@ -135,73 +135,83 @@ parse_uint(uint32_t *uip, const char *value, uint32_t max, const char *desc);
static void
usage(void) {
fputs("Usage: delv [@server] {q-opt} {d-opt} [domain] [q-type] "
"[q-class]\n"
"Where: domain is in the Domain Name System\n"
" q-class is one of (in,hs,ch,...) [default: in]\n"
" q-type is one of (a,any,mx,ns,soa,hinfo,axfr,txt,...) "
"[default:a]\n"
" q-opt is one of:\n"
" -4 (use IPv4 query transport "
"only)\n"
" -6 (use IPv6 query transport "
"only)\n"
" -a anchor-file (specify root trust "
"anchor)\n"
" -b address[#port] (bind to source "
"address/port)\n"
" -c class (option included for "
"compatibility;\n"
" -d level (set debugging level)\n"
" -h (print help and exit)\n"
" -i (disable DNSSEC "
"validation)\n"
" -m (enable memory usage "
"debugging)\n"
" -p port (specify port number)\n"
" -q name (specify query name)\n"
" -t type (specify query type)\n"
" only IN is supported)\n"
" -v (print version and exit)\n"
" -x dot-notation (shortcut for reverse "
"lookups)\n"
" d-opt is of the form +keyword[=value], where keyword "
"is:\n"
" +[no]all (Set or clear all display "
"flags)\n"
" +[no]class (Control display of "
"class)\n"
" +[no]comments (Control display of "
"comment lines)\n"
" +[no]crypto (Control display of "
"cryptographic\n"
" fields in records)\n"
" +[no]dlv (Obsolete)\n"
" +[no]dnssec (Display DNSSEC records)\n"
" +[no]mtrace (Trace messages received)\n"
" +[no]multiline (Print records in an "
"expanded format)\n"
" +[no]root (DNSSEC validation trust "
"anchor)\n"
" +[no]rrcomments (Control display of "
"per-record "
"comments)\n"
" +[no]rtrace (Trace resolver fetches)\n"
" +[no]short (Short form answer)\n"
" +[no]split=## (Split hex/base64 fields "
"into chunks)\n"
" +[no]tcp (TCP mode)\n"
" +[no]ttl (Control display of ttls "
"in records)\n"
" +[no]trust (Control display of trust "
"level)\n"
" +[no]unknownformat (Print RDATA in RFC 3597 "
"\"unknown\" format)\n"
" +[no]vtrace (Trace validation "
"process)\n"
" +[no]yaml (Present the results as "
"YAML)\n",
stderr);
fprintf(stderr,
"Usage: delv [@server] {q-opt} {d-opt} [domain] [q-type] "
"[q-class]\n"
"Where: domain is in the Domain Name System\n"
" q-class is one of (in,hs,ch,...) [default: in]\n"
" q-type is one of "
"(a,any,mx,ns,soa,hinfo,axfr,txt,...) "
"[default:a]\n"
" q-opt is one of:\n"
" -4 (use IPv4 query "
"transport "
"only)\n"
" -6 (use IPv6 query "
"transport "
"only)\n"
" -a anchor-file (specify root trust "
"anchor)\n"
" -b address[#port] (bind to source "
"address/port)\n"
" -c class (option included for "
"compatibility;\n"
" -d level (set debugging level)\n"
" -h (print help and exit)\n"
" -i (disable DNSSEC "
"validation)\n"
" -m (enable memory usage "
"debugging)\n"
" -p port (specify port number)\n"
" -q name (specify query name)\n"
" -t type (specify query type)\n"
" only IN is supported)\n"
" -v (print version and "
"exit)\n"
" -x dot-notation (shortcut for reverse "
"lookups)\n"
" d-opt is of the form +keyword[=value], where "
"keyword "
"is:\n"
" +[no]all (Set or clear all "
"display "
"flags)\n"
" +[no]class (Control display of "
"class)\n"
" +[no]comments (Control display of "
"comment lines)\n"
" +[no]crypto (Control display of "
"cryptographic\n"
" fields in records)\n"
" +[no]dlv (Obsolete)\n"
" +[no]dnssec (Display DNSSEC "
"records)\n"
" +[no]mtrace (Trace messages "
"received)\n"
" +[no]multiline (Print records in an "
"expanded format)\n"
" +[no]root (DNSSEC validation trust "
"anchor)\n"
" +[no]rrcomments (Control display of "
"per-record "
"comments)\n"
" +[no]rtrace (Trace resolver "
"fetches)\n"
" +[no]short (Short form answer)\n"
" +[no]split=## (Split hex/base64 fields "
"into chunks)\n"
" +[no]tcp (TCP mode)\n"
" +[no]ttl (Control display of ttls "
"in records)\n"
" +[no]trust (Control display of "
"trust "
"level)\n"
" +[no]unknownformat (Print RDATA in RFC 3597 "
"\"unknown\" format)\n"
" +[no]vtrace (Trace validation "
"process)\n"
" +[no]yaml (Present the results as "
"YAML)\n");
exit(1);
}
......
......@@ -97,11 +97,12 @@ rcode_totext(dns_rcode_t rcode) {
/*% print usage */
static void
print_usage(FILE *fp) {
fputs("Usage: dig [@global-server] [domain] [q-type] [q-class] "
"{q-opt}\n"
" {global-d-opt} host [@local-server] {local-d-opt}\n"
" [ host [@local-server] {local-d-opt} [...]]\n",
fp);
fprintf(fp,
"Usage: dig [@global-server] [domain] [q-type] [q-class] "
"{q-opt}\n"
" {global-d-opt} host [@local-server] "
"{local-d-opt}\n"
" [ host [@local-server] {local-d-opt} [...]]\n");
}
#if TARGET_OS_IPHONE
......@@ -116,9 +117,8 @@ usage(void);
static void
usage(void) {
print_usage(stderr);
fputs("\nUse \"dig -h\" (or \"dig -h | more\") "
"for complete list of options\n",
stderr);
fprintf(stderr, "\nUse \"dig -h\" (or \"dig -h | more\") "
"for complete list of options\n");
exit(1);
}
#endif /* if TARGET_OS_IPHONE */
......@@ -133,179 +133,187 @@ version(void) {
static void
help(void) {
print_usage(stdout);
fputs("Where: domain is in the Domain Name System\n"
" q-class is one of (in,hs,ch,...) [default: in]\n"
" q-type is one of (a,any,mx,ns,soa,hinfo,axfr,txt,...) "
"[default:a]\n"
" (Use ixfr=version for type ixfr)\n"
" q-opt is one of:\n"
" -4 (use IPv4 query transport "
"only)\n"
" -6 (use IPv6 query transport "
"only)\n"
" -b address[#port] (bind to source "
"address/port)\n"
" -c class (specify query class)\n"
" -f filename (batch mode)\n"
" -k keyfile (specify tsig key file)\n"
" -m (enable memory usage "
"debugging)\n"
" -p port (specify port number)\n"
" -q name (specify query name)\n"
" -r (do not read ~/.digrc)\n"
" -t type (specify query type)\n"
" -u (display times in usec "
"instead of msec)\n"
" -x dot-notation (shortcut for reverse "
"lookups)\n"
" -y [hmac:]name:key (specify named base64 tsig "
"key)\n"
" d-opt is of the form +keyword[=value], where keyword "
"is:\n"
" +[no]aaflag (Set AA flag in query "
"(+[no]aaflag))\n"
" +[no]aaonly (Set AA flag in query "
"(+[no]aaflag))\n"
" +[no]additional (Control display of "
"additional section)\n"
" +[no]adflag (Set AD flag in query "
"(default on))\n"
" +[no]all (Set or clear all display "
"flags)\n"
" +[no]answer (Control display of answer "
"section)\n"
" +[no]authority (Control display of "
"authority section)\n"
" +[no]badcookie (Retry BADCOOKIE "
"responses)\n"
" +[no]besteffort (Try to parse even illegal "
"messages)\n"
" +bufsize=### (Set EDNS0 Max UDP packet "
"size)\n"
" +[no]cdflag (Set checking disabled "
"flag in query)\n"
" +[no]class (Control display of class "
"in records)\n"
" +[no]cmd (Control display of "
"command line -\n"
" global option)\n"
" +[no]comments (Control display of packet "
"header\n"
" and section name "
"comments)\n"
" +[no]cookie (Add a COOKIE option to "
"the request)\n"
" +[no]crypto (Control display of "
"cryptographic\n"
" fields in records)\n"
" +[no]defname (Use search list "
"(+[no]search))\n"
" +[no]dnssec (Request DNSSEC records)\n"
" +domain=### (Set default domainname)\n"
" +[no]dscp[=###] (Set the DSCP value to ### "
"[0..63])\n"
" +[no]edns[=###] (Set EDNS version) [0]\n"
" +ednsflags=### (Set EDNS flag bits)\n"
" +[no]ednsnegotiation (Set EDNS version "
"negotiation)\n"
" +ednsopt=###[:value] (Send specified EDNS "
"option)\n"
" +noednsopt (Clear list of +ednsopt "
"options)\n"
" +[no]expandaaaa (Expand AAAA records)\n"
" +[no]expire (Request time to expire)\n"
" +[no]fail (Don't try next server on "
"SERVFAIL)\n"
" +[no]header-only (Send query without a "
"question section)\n"
" +[no]identify (ID responders in short "
"answers)\n"
printf("Where: domain is in the Domain Name System\n"
" q-class is one of (in,hs,ch,...) [default: in]\n"
" q-type is one of "
"(a,any,mx,ns,soa,hinfo,axfr,txt,...) "
"[default:a]\n"
" (Use ixfr=version for type ixfr)\n"
" q-opt is one of:\n"
" -4 (use IPv4 query transport "
"only)\n"
" -6 (use IPv6 query transport "
"only)\n"
" -b address[#port] (bind to source "
"address/port)\n"
" -c class (specify query class)\n"
" -f filename (batch mode)\n"
" -k keyfile (specify tsig key file)\n"
" -m (enable memory usage "
"debugging)\n"
" -p port (specify port number)\n"
" -q name (specify query name)\n"
" -r (do not read ~/.digrc)\n"
" -t type (specify query type)\n"
" -u (display times in usec "
"instead of msec)\n"
" -x dot-notation (shortcut for reverse "
"lookups)\n"
" -y [hmac:]name:key (specify named base64 "
"tsig "
"key)\n"
" d-opt is of the form +keyword[=value], where "
"keyword "
"is:\n"
" +[no]aaflag (Set AA flag in query "
"(+[no]aaflag))\n"
" +[no]aaonly (Set AA flag in query "
"(+[no]aaflag))\n"
" +[no]additional (Control display of "
"additional section)\n"
" +[no]adflag (Set AD flag in query "
"(default on))\n"
" +[no]all (Set or clear all display "
"flags)\n"
" +[no]answer (Control display of "
"answer "
"section)\n"
" +[no]authority (Control display of "
"authority section)\n"
" +[no]badcookie (Retry BADCOOKIE "
"responses)\n"
" +[no]besteffort (Try to parse even "
"illegal "
"messages)\n"
" +bufsize=### (Set EDNS0 Max UDP packet "
"size)\n"
" +[no]cdflag (Set checking disabled "
"flag in query)\n"
" +[no]class (Control display of class "
"in records)\n"
" +[no]cmd (Control display of "
"command line -\n"
" global option)\n"
" +[no]comments (Control display of "
"packet "
"header\n"
" and section name "
"comments)\n"
" +[no]cookie (Add a COOKIE option to "
"the request)\n"
" +[no]crypto (Control display of "
"cryptographic\n"
" fields in records)\n"
" +[no]defname (Use search list "
"(+[no]search))\n"
" +[no]dnssec (Request DNSSEC records)\n"
" +domain=### (Set default domainname)\n"
" +[no]dscp[=###] (Set the DSCP value to "
"### "
"[0..63])\n"
" +[no]edns[=###] (Set EDNS version) [0]\n"
" +ednsflags=### (Set EDNS flag bits)\n"
" +[no]ednsnegotiation (Set EDNS version "
"negotiation)\n"
" +ednsopt=###[:value] (Send specified EDNS "
"option)\n"
" +noednsopt (Clear list of +ednsopt "
"options)\n"
" +[no]expandaaaa (Expand AAAA records)\n"
" +[no]expire (Request time to expire)\n"
" +[no]fail (Don't try next server on "
"SERVFAIL)\n"
" +[no]header-only (Send query without a "
"question section)\n"
" +[no]identify (ID responders in short "
"answers)\n"
#ifdef HAVE_LIBIDN2
" +[no]idnin (Parse IDN names "
"[default=on on tty])\n"
" +[no]idnout (Convert IDN response "
"[default=on on tty])\n"
" +[no]idnin (Parse IDN names "
"[default=on on tty])\n"
" +[no]idnout (Convert IDN response "
"[default=on on tty])\n"
#endif /* ifdef HAVE_LIBIDN2 */
" +[no]ignore (Don't revert to TCP for "
"TC responses.)\n"
" +[no]keepalive (Request EDNS TCP "
"keepalive)\n"
" +[no]keepopen (Keep the TCP socket open "
"between "
"queries)\n"
" +[no]mapped (Allow mapped IPv4 over "
"IPv6)\n"
" +[no]multiline (Print records in an "
"expanded format)\n"
" +ndots=### (Set search NDOTS value)\n"
" +[no]nsid (Request Name Server ID)\n"
" +[no]nssearch (Search all authoritative "
"nameservers)\n"
" +[no]onesoa (AXFR prints only one soa "
"record)\n"
" +[no]opcode=### (Set the opcode of the "
"request)\n"
" +padding=### (Set padding block size "
"[0])\n"
" +[no]qr (Print question before "
"sending)\n"
" +[no]question (Control display of "
"question section)\n"
" +[no]raflag (Set RA flag in query "
"(+[no]raflag))\n"
" +[no]rdflag (Recursive mode "
"(+[no]recurse))\n"
" +[no]recurse (Recursive mode "
"(+[no]rdflag))\n"
" +retry=### (Set number of UDP "
"retries) [2]\n"
" +[no]rrcomments (Control display of "
"per-record "
"comments)\n"
" +[no]search (Set whether to use "
"searchlist)\n"
" +[no]short (Display nothing except "
"short\n"
" form of answers - global "
"option)\n"
" +[no]showsearch (Search with intermediate "
"results)\n"
" +[no]split=## (Split hex/base64 fields "
"into chunks)\n"
" +[no]stats (Control display of "
"statistics)\n"
" +subnet=addr (Set edns-client-subnet "
"option)\n"
" +[no]tcflag (Set TC flag in query "
"(+[no]tcflag))\n"
" +[no]tcp (TCP mode (+[no]vc))\n"
" +timeout=### (Set query timeout) [5]\n"
" +[no]trace (Trace delegation down "
"from root "
"[+dnssec])\n"
" +tries=### (Set number of UDP "
"attempts) [3]\n"
" +[no]ttlid (Control display of ttls "
"in records)\n"
" +[no]ttlunits (Display TTLs in "
"human-readable units)\n"
" +[no]unexpected (Print replies from "
"unexpected sources\n"
" default=off)\n"
" +[no]unknownformat (Print RDATA in RFC 3597 "
"\"unknown\" "
"format)\n"
" +[no]vc (TCP mode (+[no]tcp))\n"
" +[no]yaml (Present the results as "
"YAML)\n"
" +[no]zflag (Set Z flag in query)\n"
" global d-opts and servers (before host name) affect all "
"queries.\n"
" local d-opts and servers (after host name) affect only "
"that lookup.\n"
" -h (print help and exit)\n"
" -v (print version and exit)\n",
stdout);
" +[no]ignore (Don't revert to TCP for "
"TC responses.)\n"
" +[no]keepalive (Request EDNS TCP "
"keepalive)\n"
" +[no]keepopen (Keep the TCP socket open "
"between "
"queries)\n"
" +[no]mapped (Allow mapped IPv4 over "
"IPv6)\n"
" +[no]multiline (Print records in an "
"expanded format)\n"
" +ndots=### (Set search NDOTS value)\n"
" +[no]nsid (Request Name Server ID)\n"
" +[no]nssearch (Search all authoritative "
"nameservers)\n"
" +[no]onesoa (AXFR prints only one soa "
"record)\n"
" +[no]opcode=### (Set the opcode of the "
"request)\n"
" +padding=### (Set padding block size "
"[0])\n"
" +[no]qr (Print question before "
"sending)\n"
" +[no]question (Control display of "
"question section)\n"
" +[no]raflag (Set RA flag in query "
"(+[no]raflag))\n"
" +[no]rdflag (Recursive mode "
"(+[no]recurse))\n"
" +[no]recurse (Recursive mode "
"(+[no]rdflag))\n"
" +retry=### (Set number of UDP "
"retries) [2]\n"
" +[no]rrcomments (Control display of "
"per-record "
"comments)\n"
" +[no]search (Set whether to use "
"searchlist)\n"
" +[no]short (Display nothing except "
"short\n"
" form of answers - global "
"option)\n"
" +[no]showsearch (Search with intermediate "
"results)\n"
" +[no]split=## (Split hex/base64 fields "
"into chunks)\n"
" +[no]stats (Control display of "
"statistics)\n"
" +subnet=addr (Set edns-client-subnet "
"option)\n"
" +[no]tcflag (Set TC flag in query "
"(+[no]tcflag))\n"
" +[no]tcp (TCP mode (+[no]vc))\n"
" +timeout=### (Set query timeout) [5]\n"
" +[no]trace (Trace delegation down "
"from root "
"[+dnssec])\n"
" +tries=### (Set number of UDP "
"attempts) [3]\n"
" +[no]ttlid (Control display of ttls "
"in records)\n"
" +[no]ttlunits (Display TTLs in "
"human-readable units)\n"
" +[no]unexpected (Print replies from "
"unexpected sources\n"
" default=off)\n"
" +[no]unknownformat (Print RDATA in RFC 3597 "
"\"unknown\" "
"format)\n"
" +[no]vc (TCP mode (+[no]tcp))\n"
" +[no]yaml (Present the results as "
"YAML)\n"
" +[no]zflag (Set Z flag in query)\n"
" global d-opts and servers (before host name) affect "
"all "
"queries.\n"
" local d-opts and servers (after host name) affect only "
"that lookup.\n"
" -h (print help and exit)\n"
" -v (print version "
"and exit)\n");
}
/*%
......@@ -607,7 +615,7 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf, dns_message_t *msg,
if (query->lookup->cmdline[0] != 0) {
if (!short_form && printcmd) {
fputs(query->lookup->cmdline, stdout);
printf("%s", query->lookup->cmdline);
}
query->lookup->cmdline[0] = '\0';
}
......
......@@ -281,7 +281,7 @@ hex_dump(isc_buffer_t *b) {
for (len = 0; len < r.length; len++) {
printf("%02x ", r.base[len]);
if (len % 16 == 15) {
fputs(" ", stdout);
printf(" ");
for (i = len - 15; i <= len; i++) {
if (r.base[i] >= '!' && r.base[i] <= '}') {
putchar(r.base[i]);
......@@ -294,9 +294,9 @@ hex_dump(isc_buffer_t *b) {
}
if (len % 16 != 0) {
for (i = len; (i % 16) != 0; i++) {
fputs(" ", stdout);
printf(" ");
}
fputs(" ", stdout);
printf(" ");
for (i = ((len >> 4) << 4); i < len; i++) {
if (r.base[i] >= '!' && r.base[i] <= '}') {
putchar(r.base[i]);
......@@ -3058,7 +3058,7 @@ connect_timeout(isc_task_t *task, isc_event_t *event) {
dighost_error("no response from %s\n", buf);
} else {
fputs(l->cmdline, stdout);
printf("%s", l->cmdline);
dighost_error("connection timed out; "
"no servers could be reached\n");
}
......
......@@ -107,32 +107,34 @@ show_usage(void);
static void
show_usage(void) {
fputs("Usage: host [-aCdilrTvVw] [-c class] [-N ndots] [-t type] [-W "
"time]\n"
" [-R number] [-m flag] [-p port] hostname [server]\n"
" -a is equivalent to -v -t ANY\n"
" -A is like -a but omits RRSIG, NSEC, NSEC3\n"
" -c specifies query class for non-IN data\n"
" -C compares SOA records on authoritative nameservers\n"
" -d is equivalent to -v\n"
" -l lists all hosts in a domain, using AXFR\n"
" -m set memory debugging flag (trace|record|usage)\n"
" -N changes the number of dots allowed before root lookup "
"is done\n"
" -p specifies the port on the server to query\n"
" -r disables recursive processing\n"
" -R specifies number of retries for UDP packets\n"
" -s a SERVFAIL response should stop query\n"
" -t specifies the query type\n"
" -T enables TCP/IP mode\n"
" -U enables UDP mode\n"
" -v enables verbose output\n"
" -V print version number and exit\n"
" -w specifies to wait forever for a reply\n"
" -W specifies how long to wait for a reply\n"
" -4 use IPv4 query transport only\n"
" -6 use IPv6 query transport only\n",
stderr);
fprintf(stderr,
"Usage: host [-aCdilrTvVw] [-c class] [-N ndots] [-t type] [-W "
"time]\n"
" [-R number] [-m flag] [-p port] hostname "
"[server]\n"
" -a is equivalent to -v -t ANY\n"
" -A is like -a but omits RRSIG, NSEC, NSEC3\n"
" -c specifies query class for non-IN data\n"
" -C compares SOA records on authoritative nameservers\n"
" -d is equivalent to -v\n"
" -l lists all hosts in a domain, using AXFR\n"
" -m set memory debugging flag (trace|record|usage)\n"
" -N changes the number of dots allowed before root "
"lookup "
"is done\n"
" -p specifies the port on the server to query\n"
" -r disables recursive processing\n"
" -R specifies number of retries for UDP packets\n"
" -s a SERVFAIL response should stop query\n"
" -t specifies the query type\n"
" -T enables TCP/IP mode\n"
" -U enables UDP mode\n"
" -v enables verbose output\n"
" -V print version number and exit\n"
" -w specifies to wait forever for a reply\n"
" -W specifies how long to wait for a reply\n"
" -4 use IPv4 query transport only\n"
" -6 use IPv6 query transport only\n");
exit(1);
}
......