replace fputs() with fprintf()

This commit is contained in:
Evan Hunt 2020-04-02 18:51:06 -07:00 committed by Michał Kępień
parent a6e6d0c1d5
commit b89decfcc9
13 changed files with 526 additions and 515 deletions

View file

@ -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");
}
}

View file

@ -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);
}

View file

@ -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';
}

View file

@ -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");
}

View file

@ -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);
}

View file

@ -859,7 +859,7 @@ get_next_command(void) {
add_history(ptr);
}
#else /* ifdef HAVE_READLINE */
fputs("> ", stderr);
fprintf(stderr, "> ");
fflush(stderr);
ptr = fgets(buf, COMMSIZE, stdin);
#endif /* ifdef HAVE_READLINE */

View file

@ -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");
}
}

View file

@ -53,7 +53,7 @@ main(int argc, char **argv) {
length = 0;
if (argc != 2) {
fputs(USAGE, stderr);
fprintf(stderr, USAGE);
goto out;
}

View file

@ -140,18 +140,18 @@ main(int argc, char **argv) {
case 'w':
seconds = strtod(optarg, &p);
if (seconds <= 0 || *p != '\0') {
fputs(USAGE, stderr);
fprintf(stderr, USAGE);
return (1);
}
usleep((int)(seconds * 1000.0 * 1000.0));
return (0);
default:
fputs(USAGE, stderr);
fprintf(stderr, USAGE);
return (1);
}
}
fputs(USAGE, stderr);
fprintf(stderr, USAGE);
return (1);
}

View file

@ -788,110 +788,110 @@ usage(void);
static void
usage(void) {
fputs("Usage: mdig @server {global-opt} host\n"
" {local-opt} [ host {local-opt} [...]]\n",
stderr);
fputs("\nUse \"mdig -h\" (or \"mdig -h | more\") "
"for complete list of options\n",
stderr);
fprintf(stderr, "Usage: mdig @server {global-opt} host\n"
" {local-opt} [ host {local-opt} [...]]\n"
"\nUse \"mdig -h\" (or \"mdig -h | more\") "
"for complete list of options\n");
exit(1);
}
/*% help */
static void
help(void) {
fputs("Usage: mdig @server {global-opt} host\n"
" {local-opt} [ host {local-opt} [...]]\n",
stdout);
fputs("Where:\n"
" anywhere opt is one of:\n"
" -f filename (batch mode)\n"
" -h (print help and exit)\n"
" -v (print version and exit)\n"
" global 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"
" -p port (specify port number)\n"
" -m (enable memory usage "
"debugging)\n"
" +[no]dscp[=###] (Set the DSCP value to ### "
"[0..63])\n"
" +[no]vc (TCP mode)\n"
" +[no]tcp (TCP mode, alternate "
"syntax)\n"
" +[no]besteffort (Try to parse even illegal "
"messages)\n"
" +[no]cl (Control display of class "
"in records)\n"
" +[no]comments (Control display of "
"comment lines)\n"
" +[no]rrcomments (Control display of "
"per-record "
"comments)\n"
" +[no]crypto (Control display of "
"cryptographic "
"fields in records)\n"
" +[no]question (Control display of "
"question)\n"
" +[no]answer (Control display of "
"answer)\n"
" +[no]authority (Control display of "
"authority)\n"
" +[no]additional (Control display of "
"additional)\n"
" +[no]short (Disable everything except "
"short\n"
" form of answer)\n"
" +[no]ttlid (Control display of ttls "
"in records)\n"
" +[no]ttlunits (Display TTLs in "
"human-readable units)\n"
" +[no]unknownformat (Print RDATA in RFC 3597 "
"\"unknown\" format)\n"
" +[no]all (Set or clear all display "
"flags)\n"
" +[no]multiline (Print records in an "
"expanded format)\n"
" +[no]split=## (Split hex/base64 fields "
"into chunks)\n"
" local opt is one of:\n"
" -c class (specify query class)\n"
" -t type (specify query type)\n"
" -x dot-notation (shortcut for reverse "
"lookups)\n"
" +timeout=### (Set query timeout) "
"[UDP=5,TCP=10]\n"
" +udptimeout=### (Set timeout before UDP "
"retry)\n"
" +tries=### (Set number of UDP "
"attempts) [3]\n"
" +retry=### (Set number of UDP "
"retries) [2]\n"
" +bufsize=### (Set EDNS0 Max UDP packet "
"size)\n"
" +subnet=addr (Set edns-client-subnet "
"option)\n"
" +[no]edns[=###] (Set EDNS version) [0]\n"
" +ednsflags=### (Set EDNS flag bits)\n"
" +ednsopt=###[:value] (Send specified EDNS "
"option)\n"
" +noednsopt (Clear list of +ednsopt "
"options)\n"
" +[no]recurse (Recursive mode)\n"
" +[no]aaonly (Set AA flag in query "
"(+[no]aaflag))\n"
" +[no]adflag (Set AD flag in query)\n"
" +[no]cdflag (Set CD flag in query)\n"
" +[no]zflag (Set Z flag in query)\n"
" +[no]dnssec (Request DNSSEC records)\n"
" +[no]expire (Request time to expire)\n"
" +[no]cookie[=###] (Send a COOKIE option)\n"
" +[no]nsid (Request Name Server ID)\n",
stdout);
printf("Usage: mdig @server {global-opt} host\n"
" {local-opt} [ host {local-opt} [...]]\n"
"Where:\n"
" anywhere opt is one of:\n"
" -f filename (batch mode)\n"
" -h (print help and exit)\n"
" -v (print version and exit)\n"
" global 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"
" -p port (specify port number)\n"
" -m (enable memory usage "
"debugging)\n"
" +[no]dscp[=###] (Set the DSCP value to "
"### "
"[0..63])\n"
" +[no]vc (TCP mode)\n"
" +[no]tcp (TCP mode, alternate "
"syntax)\n"
" +[no]besteffort (Try to parse even "
"illegal "
"messages)\n"
" +[no]cl (Control display of class "
"in records)\n"
" +[no]comments (Control display of "
"comment lines)\n"
" +[no]rrcomments (Control display of "
"per-record "
"comments)\n"
" +[no]crypto (Control display of "
"cryptographic "
"fields in records)\n"
" +[no]question (Control display of "
"question)\n"
" +[no]answer (Control display of "
"answer)\n"
" +[no]authority (Control display of "
"authority)\n"
" +[no]additional (Control display of "
"additional)\n"
" +[no]short (Disable everything "
"except "
"short\n"
" form of answer)\n"
" +[no]ttlid (Control display of ttls "
"in records)\n"
" +[no]ttlunits (Display TTLs in "
"human-readable units)\n"
" +[no]unknownformat (Print RDATA in RFC 3597 "
"\"unknown\" format)\n"
" +[no]all (Set or clear all display "
"flags)\n"
" +[no]multiline (Print records in an "
"expanded format)\n"
" +[no]split=## (Split hex/base64 fields "
"into chunks)\n"
" local opt is one of:\n"
" -c class (specify query class)\n"
" -t type (specify query type)\n"
" -x dot-notation (shortcut for reverse "
"lookups)\n"
" +timeout=### (Set query timeout) "
"[UDP=5,TCP=10]\n"
" +udptimeout=### (Set timeout before UDP "
"retry)\n"
" +tries=### (Set number of UDP "
"attempts) [3]\n"
" +retry=### (Set number of UDP "
"retries) [2]\n"
" +bufsize=### (Set EDNS0 Max UDP packet "
"size)\n"
" +subnet=addr (Set edns-client-subnet "
"option)\n"
" +[no]edns[=###] (Set EDNS version) [0]\n"
" +ednsflags=### (Set EDNS flag bits)\n"
" +ednsopt=###[:value] (Send specified EDNS "
"option)\n"
" +noednsopt (Clear list of +ednsopt "
"options)\n"
" +[no]recurse (Recursive mode)\n"
" +[no]aaonly (Set AA flag in query "
"(+[no]aaflag))\n"
" +[no]adflag (Set AD flag in query)\n"
" +[no]cdflag (Set CD flag in query)\n"
" +[no]zflag (Set Z flag in query)\n"
" +[no]dnssec (Request DNSSEC records)\n"
" +[no]expire (Request time to expire)\n"
" +[no]cookie[=###] (Send a COOKIE option)\n"
" +[no]nsid (Request Name "
"Server ID)\n");
}
ISC_NORETURN static void

View file

@ -240,61 +240,60 @@ doswitch(const char *name, const char *function, const char *args,
for (tt = types; tt != NULL; tt = tt->next) {
if (first) {
fprintf(stdout, "\n#define %s \\\n", name);
fprintf(stdout, "\tswitch (%s) { \\\n" /*}*/, tsw);
printf("\n#define %s \\\n", name);
printf("\tswitch (%s) { \\\n" /*}*/, tsw);
first = 0;
}
if (tt->type != lasttype && subswitch) {
if (res == NULL) {
fprintf(stdout, "\t\tdefault: break; \\\n");
printf("\t\tdefault: break; \\\n");
} else {
fprintf(stdout, "\t\tdefault: %s; break; \\\n",
res);
printf("\t\tdefault: %s; break; \\\n", res);
}
fputs(/*{*/ "\t\t} \\\n", stdout);
fputs("\t\tbreak; \\\n", stdout);
printf("\t\t} \\\n");
printf("\t\tbreak; \\\n");
subswitch = 0;
}
if (tt->rdclass && tt->type != lasttype) {
fprintf(stdout, "\tcase %d: switch (%s) { \\\n" /*}*/,
tt->type, csw);
printf("\tcase %d: switch (%s) { \\\n" /*}*/, tt->type,
csw);
subswitch = 1;
}
if (tt->rdclass == 0) {
fprintf(stdout, "\tcase %d:%s %s_%s(%s); break;",
tt->type, result, function,
funname(tt->typebuf, buf1), args);
printf("\tcase %d:%s %s_%s(%s); break;", tt->type,
result, function, funname(tt->typebuf, buf1),
args);
} else {
fprintf(stdout, "\t\tcase %d:%s %s_%s_%s(%s); break;",
tt->rdclass, result, function,
funname(tt->classbuf, buf1),
funname(tt->typebuf, buf2), args);
printf("\t\tcase %d:%s %s_%s_%s(%s); break;",
tt->rdclass, result, function,
funname(tt->classbuf, buf1),
funname(tt->typebuf, buf2), args);
}
fputs(" \\\n", stdout);
printf(" \\\n");
lasttype = tt->type;
}
if (subswitch) {
if (res == NULL) {
fprintf(stdout, "\t\tdefault: break; \\\n");
printf("\t\tdefault: break; \\\n");
} else {
fprintf(stdout, "\t\tdefault: %s; break; \\\n", res);
printf("\t\tdefault: %s; break; \\\n", res);
}
fputs(/*{*/ "\t\t} \\\n", stdout);
fputs("\t\tbreak; \\\n", stdout);
printf("\t\t} \\\n");
printf("\t\tbreak; \\\n");
}
if (first) {
if (res == NULL) {
fprintf(stdout, "\n#define %s\n", name);
printf("\n#define %s\n", name);
} else {
fprintf(stdout, "\n#define %s %s;\n", name, res);
printf("\n#define %s %s;\n", name, res);
}
} else {
if (res == NULL) {
fprintf(stdout, "\tdefault: break; \\\n");
printf("\tdefault: break; \\\n");
} else {
fprintf(stdout, "\tdefault: %s; break; \\\n", res);
printf("\tdefault: %s; break; \\\n", res);
}
fputs(/*{*/ "\t}\n", stdout);
printf("\t}\n");
}
}
@ -714,23 +713,23 @@ main(int argc, char **argv) {
}
if (!depend) {
fprintf(stdout, copyright, year);
printf(copyright, year);
}
if (code) {
fputs("#ifndef DNS_CODE_H\n", stdout);
fputs("#define DNS_CODE_H 1\n\n", stdout);
printf("#ifndef DNS_CODE_H\n");
printf("#define DNS_CODE_H 1\n\n");
fputs("#include <stdbool.h>\n", stdout);
fputs("#include <isc/result.h>\n\n", stdout);
fputs("#include <dns/name.h>\n\n", stdout);
printf("#include <stdbool.h>\n");
printf("#include <isc/result.h>\n\n");
printf("#include <dns/name.h>\n\n");
for (tt = types; tt != NULL; tt = tt->next) {
fprintf(stdout, "#include \"%s/%s_%d.c\"\n", tt->dirbuf,
tt->typebuf, tt->type);
printf("#include \"%s/%s_%d.c\"\n", tt->dirbuf,
tt->typebuf, tt->type);
}
fputs("\n\n", stdout);
printf("\n\n");
doswitch("FROMTEXTSWITCH", "fromtext", FROMTEXTARGS,
FROMTEXTTYPE, FROMTEXTCLASS, FROMTEXTDEF);
@ -801,23 +800,22 @@ main(int argc, char **argv) {
* Here, walk the list from top to bottom, calculating
* the hash (mod 256) for each name.
*/
fprintf(stdout, "#define RDATATYPE_COMPARE(_s, _d, _tn, _n, "
"_tp) \\\n");
fprintf(stdout, "\tdo { \\\n");
fprintf(stdout, "\t\tif (sizeof(_s) - 1 == _n && \\\n"
"\t\t strncasecmp(_s,(_tn),"
"(sizeof(_s) - 1)) == 0) { \\\n");
fprintf(stdout, "\t\t\tif ((dns_rdatatype_attributes(_d) & "
"DNS_RDATATYPEATTR_RESERVED) != 0) \\\n");
fprintf(stdout, "\t\t\t\treturn (ISC_R_NOTIMPLEMENTED); \\\n");
fprintf(stdout, "\t\t\t*(_tp) = _d; \\\n");
fprintf(stdout, "\t\t\treturn (ISC_R_SUCCESS); \\\n");
fprintf(stdout, "\t\t} \\\n");
fprintf(stdout, "\t} while (0)\n\n");
printf("#define RDATATYPE_COMPARE(_s, _d, _tn, _n, _tp) \\\n");
printf("\tdo { \\\n");
printf("\t\tif (sizeof(_s) - 1 == _n && \\\n"
"\t\t strncasecmp(_s,(_tn),"
"(sizeof(_s) - 1)) == 0) { \\\n");
printf("\t\t\tif ((dns_rdatatype_attributes(_d) & "
"DNS_RDATATYPEATTR_RESERVED) != 0) \\\n");
printf("\t\t\t\treturn (ISC_R_NOTIMPLEMENTED); \\\n");
printf("\t\t\t*(_tp) = _d; \\\n");
printf("\t\t\treturn (ISC_R_SUCCESS); \\\n");
printf("\t\t} \\\n");
printf("\t} while (0)\n\n");
fprintf(stdout, "#define RDATATYPE_FROMTEXT_SW(_hash,"
"_typename,_length,_typep) \\\n");
fprintf(stdout, "\tswitch (_hash) { \\\n");
printf("#define RDATATYPE_FROMTEXT_SW(_hash,"
"_typename,_length,_typep) \\\n");
printf("\tswitch (_hash) { \\\n");
for (i = 0; i <= maxtype; i++) {
ttn = find_typename(i);
if (ttn == NULL) {
@ -832,7 +830,7 @@ main(int argc, char **argv) {
}
hash = HASH(ttn->typebuf);
fprintf(stdout, "\t\tcase %u: \\\n", hash);
printf("\t\tcase %u: \\\n", hash);
/*
* Find all other entries that happen to match
@ -844,33 +842,31 @@ main(int argc, char **argv) {
continue;
}
if (hash == HASH(ttn2->typebuf)) {
fprintf(stdout,
"\t\t\t"
"RDATATYPE_COMPARE"
"(\"%s\", %d, _typename, "
" _length, _typep); \\\n",
ttn2->typebuf, ttn2->type);
printf("\t\t\tRDATATYPE_COMPARE"
"(\"%s\", %d, _typename, "
" _length, _typep); \\\n",
ttn2->typebuf, ttn2->type);
ttn2->sorted = 1;
}
}
fprintf(stdout, "\t\t\tbreak; \\\n");
printf("\t\t\tbreak; \\\n");
}
fprintf(stdout, "\t}\n");
printf("\t}\n");
fprintf(stdout, "#define RDATATYPE_ATTRIBUTE_SW \\\n");
fprintf(stdout, "\tswitch (type) { \\\n");
printf("#define RDATATYPE_ATTRIBUTE_SW \\\n");
printf("\tswitch (type) { \\\n");
for (i = 0; i <= maxtype; i++) {
ttn = find_typename(i);
if (ttn == NULL) {
continue;
}
fprintf(stdout, "\tcase %d: return (%s); \\\n", i,
upper(ttn->attr));
printf("\tcase %d: return (%s); \\\n", i,
upper(ttn->attr));
}
fprintf(stdout, "\t}\n");
printf("\t}\n");
fprintf(stdout, "#define RDATATYPE_TOTEXT_SW \\\n");
fprintf(stdout, "\tswitch (type) { \\\n");
printf("#define RDATATYPE_TOTEXT_SW \\\n");
printf("\tswitch (type) { \\\n");
for (i = 0; i <= maxtype; i++) {
ttn = find_typename(i);
if (ttn == NULL) {
@ -885,91 +881,86 @@ main(int argc, char **argv) {
if (i == 65533U) {
continue;
}
fprintf(stdout,
"\tcase %d: return "
"(str_totext(\"%s\", target)); \\\n",
i, upper(ttn->typebuf));
printf("\tcase %d: return "
"(str_totext(\"%s\", target)); \\\n",
i, upper(ttn->typebuf));
}
fprintf(stdout, "\t}\n");
printf("\t}\n");
fputs("#endif /* DNS_CODE_H */\n", stdout);
printf("#endif /* DNS_CODE_H */\n");
} else if (type_enum) {
char *s;
fprintf(stdout, "#ifndef DNS_ENUMTYPE_H\n");
fprintf(stdout, "#define DNS_ENUMTYPE_H 1\n\n");
printf("#ifndef DNS_ENUMTYPE_H\n");
printf("#define DNS_ENUMTYPE_H 1\n\n");
fprintf(stdout, "enum {\n");
fprintf(stdout, "\tdns_rdatatype_none = 0,\n");
printf("enum {\n");
printf("\tdns_rdatatype_none = 0,\n");
lasttype = 0;
for (tt = types; tt != NULL; tt = tt->next) {
if (tt->type != lasttype) {
fprintf(stdout, "\tdns_rdatatype_%s = %d,\n",
funname(tt->typebuf, buf1),
lasttype = tt->type);
printf("\tdns_rdatatype_%s = %d,\n",
funname(tt->typebuf, buf1),
lasttype = tt->type);
}
}
fprintf(stdout, "\tdns_rdatatype_ixfr = 251,\n");
fprintf(stdout, "\tdns_rdatatype_axfr = 252,\n");
fprintf(stdout, "\tdns_rdatatype_mailb = 253,\n");
fprintf(stdout, "\tdns_rdatatype_maila = 254,\n");
fprintf(stdout, "\tdns_rdatatype_any = 255\n");
printf("\tdns_rdatatype_ixfr = 251,\n");
printf("\tdns_rdatatype_axfr = 252,\n");
printf("\tdns_rdatatype_mailb = 253,\n");
printf("\tdns_rdatatype_maila = 254,\n");
printf("\tdns_rdatatype_any = 255\n");
fprintf(stdout, "};\n\n");
printf("};\n\n");
fprintf(stdout, "#define dns_rdatatype_none\t"
"((dns_rdatatype_t)dns_rdatatype_none)\n");
printf("#define dns_rdatatype_none\t"
"((dns_rdatatype_t)dns_rdatatype_none)\n");
for (tt = types; tt != NULL; tt = tt->next) {
if (tt->type != lasttype) {
s = funname(tt->typebuf, buf1);
fprintf(stdout,
"#define dns_rdatatype_%s\t%s"
"((dns_rdatatype_t)dns_rdatatype_%s)"
"\n",
s, strlen(s) < 2U ? "\t" : "", s);
printf("#define dns_rdatatype_%s\t%s"
"((dns_rdatatype_t)dns_rdatatype_%s)\n",
s, strlen(s) < 2U ? "\t" : "", s);
lasttype = tt->type;
}
}
fprintf(stdout, "#define dns_rdatatype_ixfr\t"
"((dns_rdatatype_t)dns_rdatatype_ixfr)\n");
fprintf(stdout, "#define dns_rdatatype_axfr\t"
"((dns_rdatatype_t)dns_rdatatype_axfr)\n");
fprintf(stdout, "#define dns_rdatatype_mailb\t"
"((dns_rdatatype_t)dns_rdatatype_mailb)\n");
fprintf(stdout, "#define dns_rdatatype_maila\t"
"((dns_rdatatype_t)dns_rdatatype_maila)\n");
fprintf(stdout, "#define dns_rdatatype_any\t"
"((dns_rdatatype_t)dns_rdatatype_any)\n");
printf("#define dns_rdatatype_ixfr\t"
"((dns_rdatatype_t)dns_rdatatype_ixfr)\n");
printf("#define dns_rdatatype_axfr\t"
"((dns_rdatatype_t)dns_rdatatype_axfr)\n");
printf("#define dns_rdatatype_mailb\t"
"((dns_rdatatype_t)dns_rdatatype_mailb)\n");
printf("#define dns_rdatatype_maila\t"
"((dns_rdatatype_t)dns_rdatatype_maila)\n");
printf("#define dns_rdatatype_any\t"
"((dns_rdatatype_t)dns_rdatatype_any)\n");
fprintf(stdout, "\n#endif /* DNS_ENUMTYPE_H */\n");
printf("\n#endif /* DNS_ENUMTYPE_H */\n");
} else if (class_enum) {
char *s;
int classnum;
fprintf(stdout, "#ifndef DNS_ENUMCLASS_H\n");
fprintf(stdout, "#define DNS_ENUMCLASS_H 1\n\n");
printf("#ifndef DNS_ENUMCLASS_H\n");
printf("#define DNS_ENUMCLASS_H 1\n\n");
fprintf(stdout, "enum {\n");
printf("enum {\n");
fprintf(stdout, "\tdns_rdataclass_reserved0 = 0,\n");
fprintf(stdout, "#define dns_rdataclass_reserved0 \\\n\t\t\t\t"
"((dns_rdataclass_t)dns_rdataclass_reserved0)"
"\n");
printf("\tdns_rdataclass_reserved0 = 0,\n");
printf("#define dns_rdataclass_reserved0 \\\n\t\t\t\t"
"((dns_rdataclass_t)dns_rdataclass_reserved0)\n");
#define PRINTCLASS(name, num) \
do { \
s = funname(name, buf1); \
classnum = num; \
fprintf(stdout, "\tdns_rdataclass_%s = %d%s\n", s, classnum, \
classnum != 255 ? "," : ""); \
fprintf(stdout, \
"#define dns_rdataclass_%s\t" \
"((dns_rdataclass_t)dns_rdataclass_%s)\n", \
s, s); \
#define PRINTCLASS(name, num) \
do { \
s = funname(name, buf1); \
classnum = num; \
printf("\tdns_rdataclass_%s = %d%s\n", s, classnum, \
classnum != 255 ? "," : ""); \
printf("#define dns_rdataclass_%s\t" \
"((dns_rdataclass_t)dns_rdataclass_%s)\n", \
s, s); \
} while (0)
for (cc = classes; cc != NULL; cc = cc->next) {
@ -983,13 +974,13 @@ main(int argc, char **argv) {
#undef PRINTCLASS
fprintf(stdout, "};\n\n");
fprintf(stdout, "#endif /* DNS_ENUMCLASS_H */\n");
printf("};\n\n");
printf("#endif /* DNS_ENUMCLASS_H */\n");
} else if (structs) {
if (prefix != NULL) {
if ((fd = fopen(prefix, "r")) != NULL) {
while (fgets(buf, sizeof(buf), fd) != NULL) {
fputs(buf, stdout);
printf("%s", buf);
}
fclose(fd);
}
@ -999,7 +990,7 @@ main(int argc, char **argv) {
tt->typebuf, tt->type);
if ((fd = fopen(buf, "r")) != NULL) {
while (fgets(buf, sizeof(buf), fd) != NULL) {
fputs(buf, stdout);
printf("%s", buf);
}
fclose(fd);
}
@ -1007,15 +998,15 @@ main(int argc, char **argv) {
if (suffix != NULL) {
if ((fd = fopen(suffix, "r")) != NULL) {
while (fgets(buf, sizeof(buf), fd) != NULL) {
fputs(buf, stdout);
printf("%s", buf);
}
fclose(fd);
}
}
} else if (depend) {
for (tt = types; tt != NULL; tt = tt->next) {
fprintf(stdout, "%s:\t%s/%s_%d.h\n", file, tt->dirbuf,
tt->typebuf, tt->type);
printf("%s:\t%s/%s_%d.h\n", file, tt->dirbuf,
tt->typebuf, tt->type);
}
}

View file

@ -1150,7 +1150,7 @@ print_active(isc__mem_t *mctx, FILE *out) {
unsigned int i;
bool found;
fputs("Dump of all outstanding memory allocations:\n", out);
fprintf(out, "Dump of all outstanding memory allocations:\n");
found = false;
for (i = 0; i < DEBUG_TABLE_COUNT; i++) {
dl = ISC_LIST_HEAD(mctx->debuglist[i]);
@ -1172,7 +1172,7 @@ print_active(isc__mem_t *mctx, FILE *out) {
}
if (!found) {
fputs("\tNone.\n", out);
fprintf(out, "\tNone.\n");
}
}
}
@ -1219,7 +1219,7 @@ isc_mem_stats(isc_mem_t *ctx0, FILE *out) {
*/
pool = ISC_LIST_HEAD(ctx->pools);
if (pool != NULL) {
fputs("[Pool statistics]\n", out);
fprintf(out, "[Pool statistics]\n");
fprintf(out, "%15s %10s %10s %10s %10s %10s %10s %10s %1s\n",
"name", "size", "maxalloc", "allocated", "freecount",
"freemax", "fillcount", "gets", "L");

View file

@ -35,7 +35,7 @@ getpass(const char *prompt) {
int cnt;
h = GetStdHandle(STD_INPUT_HANDLE);
fputs(prompt, stderr);
fprintf(stderr, "%s", prompt);
fflush(stderr);
fflush(stdout);
FlushConsoleInputBuffer(h);
@ -54,7 +54,7 @@ getpass(const char *prompt) {
SetConsoleMode(h, mode);
buf[cnt] = '\0';
fputs("\n", stderr);
fprintf(stderr, "\n");
return (buf);
}