2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

Make option processing case sensitive.

Remove -w option; default xfr's to +nocomments, +noquestion.  Remove wiring
around repeated comment printing, so xfr's with +comments will cause
comment headers to be printed per packet, producing same result as -w
gave.
This commit is contained in:
Michael Sawyer 2000-10-17 00:35:18 +00:00
parent 7897195eed
commit 88aa63f566
2 changed files with 53 additions and 42 deletions

View File

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: dig.c,v 1.114 2000/10/16 19:00:01 mws Exp $ */ /* $Id: dig.c,v 1.115 2000/10/17 00:35:17 mws Exp $ */
#include <config.h> #include <config.h>
#include <stdlib.h> #include <stdlib.h>
@ -78,13 +78,13 @@ dig_lookup_t *default_lookup = NULL;
extern isc_uint32_t name_limit; extern isc_uint32_t name_limit;
extern isc_uint32_t rr_limit; extern isc_uint32_t rr_limit;
extern isc_boolean_t debugging, memdebugging, show_packets; extern isc_boolean_t debugging, memdebugging;
char *batchname = NULL; char *batchname = NULL;
FILE *batchfp = NULL; FILE *batchfp = NULL;
char *argv0; char *argv0;
isc_boolean_t short_form = ISC_FALSE, printcmd = ISC_TRUE, isc_boolean_t short_form = ISC_FALSE, printcmd = ISC_TRUE,
nibble = ISC_FALSE; nibble = ISC_FALSE, plusquest = ISC_FALSE, pluscomm = ISC_FALSE;
isc_uint16_t bufsize = 0; isc_uint16_t bufsize = 0;
isc_boolean_t forcecomment = ISC_FALSE; isc_boolean_t forcecomment = ISC_FALSE;
@ -341,7 +341,9 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
fputs(query->lookup->cmdline, stdout); fputs(query->lookup->cmdline, stdout);
query->lookup->cmdline[0]=0; query->lookup->cmdline[0]=0;
} }
debug("printmessage(%s)", headers ? "headers" : "noheaders"); debug("printmessage(%s %s %s)", headers ? "headers" : "noheaders",
query->lookup->comments ? "comments" : "nocomments",
short_form ? "short_form" : "long_form");
flags = 0; flags = 0;
if (!headers) { if (!headers) {
@ -357,14 +359,12 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
check_result(result, "isc_buffer_allocate"); check_result(result, "isc_buffer_allocate");
if (query->lookup->comments && !short_form) { if (query->lookup->comments && !short_form) {
if (!query->lookup->doing_xfr) { if (query->lookup->cmdline[0] != 0)
if (query->lookup->cmdline[0] != 0) printf ("; %s\n",query->lookup->cmdline);
printf ("; %s\n",query->lookup->cmdline); if (msg == query->lookup->sendmsg)
if (msg == query->lookup->sendmsg) printf(";; Sending:\n");
printf(";; Sending:\n"); else
else printf(";; Got answer:\n");
printf(";; Got answer:\n");
}
if (headers) { if (headers) {
printf(";; ->>HEADER<<- opcode: %s, status: %s, " printf(";; ->>HEADER<<- opcode: %s, status: %s, "
@ -604,14 +604,14 @@ plus_option(char *option, isc_boolean_t is_batchfile,
cmd += 2; cmd += 2;
state = ISC_FALSE; state = ISC_FALSE;
} }
switch (tolower(cmd[0])) { switch (cmd[0]) {
case 'a': case 'a':
switch (tolower(cmd[1])) { switch (cmd[1]) {
case 'a': /* aaflag */ case 'a': /* aaflag */
lookup->aaonly = state; lookup->aaonly = state;
break; break;
case 'd': case 'd':
switch (tolower(cmd[2])) { switch (cmd[2]) {
case 'd': /* additional */ case 'd': /* additional */
lookup->section_additional = state; lookup->section_additional = state;
break; break;
@ -640,7 +640,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
} }
break; break;
case 'b': case 'b':
switch (tolower(cmd[1])) { switch (cmd[1]) {
case 'e':/* besteffort */ case 'e':/* besteffort */
lookup->besteffort = state; lookup->besteffort = state;
break; break;
@ -660,7 +660,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
} }
break; break;
case 'c': case 'c':
switch (tolower(cmd[1])) { switch (cmd[1]) {
case 'd':/* cdflag */ case 'd':/* cdflag */
lookup->cdflag = state; lookup->cdflag = state;
break; break;
@ -669,13 +669,15 @@ plus_option(char *option, isc_boolean_t is_batchfile,
break; break;
case 'o': /* comments */ case 'o': /* comments */
lookup->comments = state; lookup->comments = state;
if (lookup == default_lookup)
pluscomm = state;
break; break;
default: default:
goto invalid_option; goto invalid_option;
} }
break; break;
case 'd': case 'd':
switch (tolower(cmd[1])) { switch (cmd[1]) {
case 'e': case 'e':
lookup->defname = state; lookup->defname = state;
break; break;
@ -694,7 +696,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
lookup->servfail_stops = state; lookup->servfail_stops = state;
break; break;
case 'i': case 'i':
switch (tolower(cmd[1])) { switch (cmd[1]) {
case 'd': /* identify */ case 'd': /* identify */
lookup->identify = state; lookup->identify = state;
break; break;
@ -704,7 +706,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
} }
break; break;
case 'n': case 'n':
switch (tolower(cmd[1])) { switch (cmd[1]) {
case 'a': /* namelimit */ case 'a': /* namelimit */
if (value == NULL) if (value == NULL)
goto need_value; goto need_value;
@ -741,19 +743,21 @@ plus_option(char *option, isc_boolean_t is_batchfile,
} }
break; break;
case 'q': case 'q':
switch (tolower(cmd[1])) { switch (cmd[1]) {
case 'r': /* qr */ case 'r': /* qr */
qr = state; qr = state;
break; break;
case 'u': /* question */ case 'u': /* question */
lookup->section_question = state; lookup->section_question = state;
if (lookup == default_lookup)
plusquest = state;
break; break;
default: default:
goto invalid_option; goto invalid_option;
} }
break; break;
case 'r': case 'r':
switch (tolower(cmd[1])) { switch (cmd[1]) {
case 'e': /* recurse */ case 'e': /* recurse */
lookup->recurse = state; lookup->recurse = state;
break; break;
@ -769,7 +773,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
} }
break; break;
case 's': case 's':
switch (tolower(cmd[1])) { switch (cmd[1]) {
case 'e': /* search */ case 'e': /* search */
usesearch = state; usesearch = state;
break; break;
@ -792,7 +796,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
} }
break; break;
case 't': case 't':
switch (tolower(cmd[1])) { switch (cmd[1]) {
case 'c': /* tcp */ case 'c': /* tcp */
if (!is_batchfile) if (!is_batchfile)
lookup->tcp_mode = state; lookup->tcp_mode = state;
@ -807,7 +811,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
timeout = 1; timeout = 1;
break; break;
case 'r': case 'r':
switch (tolower(cmd[2])) { switch (cmd[2]) {
case 'a': /* trace */ case 'a': /* trace */
lookup->trace = state; lookup->trace = state;
lookup->trace_root = state; lookup->trace_root = state;
@ -840,7 +844,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
break; break;
case 'v': case 'v':
#ifdef DNS_OPT_NEWCODES #ifdef DNS_OPT_NEWCODES
switch (tolower(cmd[1])) { switch (cmd[1]) {
default: default:
case 'c': /* vc, and default */ case 'c': /* vc, and default */
#endif /* DNS_OPT_NEWCODES */ #endif /* DNS_OPT_NEWCODES */
@ -902,7 +906,7 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
value_from_next = ISC_TRUE; value_from_next = ISC_TRUE;
value = next; value = next;
} }
switch (tolower(cmd)) { switch (cmd) {
case 'd': case 'd':
debugging = ISC_TRUE; debugging = ISC_TRUE;
return (ISC_FALSE); return (ISC_FALSE);
@ -916,14 +920,10 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
case 'n': case 'n':
nibble = ISC_TRUE; nibble = ISC_TRUE;
return (ISC_FALSE); return (ISC_FALSE);
case 'w':
show_packets = ISC_TRUE;
return (ISC_FALSE);
} }
if (value == NULL) if (value == NULL)
goto invalid_option; goto invalid_option;
switch (tolower(cmd)) { switch (cmd) {
case 'b': case 'b':
get_address(value, 0, &bind_address); get_address(value, 0, &bind_address);
specified_source = ISC_TRUE; specified_source = ISC_TRUE;
@ -956,15 +956,21 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
(*lookup)->rdtype = dns_rdatatype_ixfr; (*lookup)->rdtype = dns_rdatatype_ixfr;
(*lookup)->ixfr_serial = (*lookup)->ixfr_serial =
atoi(&value[5]); atoi(&value[5]);
(*lookup)->section_question = plusquest;
(*lookup)->comments = pluscomm;
return (value_from_next); return (value_from_next);
} }
tr.base = value; tr.base = value;
tr.length = strlen(value); tr.length = strlen(value);
result = dns_rdatatype_fromtext(&rdtype, result = dns_rdatatype_fromtext(&rdtype,
(isc_textregion_t *)&tr); (isc_textregion_t *)&tr);
if (result == ISC_R_SUCCESS) if (result == ISC_R_SUCCESS) {
(*lookup)->rdtype = rdtype; (*lookup)->rdtype = rdtype;
else if (rdtype == dns_rdatatype_axfr) {
(*lookup)->section_question = plusquest;
(*lookup)->comments = pluscomm;
}
} else
fprintf(stderr, ";; Warning, ignoring " fprintf(stderr, ";; Warning, ignoring "
"invalid type %s\n", "invalid type %s\n",
value); value);
@ -1059,7 +1065,7 @@ preparse_args(int argc, char **argv) {
rc = argc; rc = argc;
rv = argv; rv = argv;
for (rc--, rv++; rc > 0; rc--, rv++) { for (rc--, rv++; rc > 0; rc--, rv++) {
if (strcasecmp(rv[0], "-m") == 0) { if (strcmp(rv[0], "-m") == 0) {
memdebugging = ISC_TRUE; memdebugging = ISC_TRUE;
isc_mem_debugging = ISC_MEM_DEBUGTRACE | isc_mem_debugging = ISC_MEM_DEBUGTRACE |
ISC_MEM_DEBUGRECORD; ISC_MEM_DEBUGRECORD;
@ -1182,12 +1188,19 @@ parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only,
lookup->rdtype = dns_rdatatype_ixfr; lookup->rdtype = dns_rdatatype_ixfr;
lookup->ixfr_serial = lookup->ixfr_serial =
atoi(&rv[0][5]); atoi(&rv[0][5]);
lookup->section_question = plusquest;
lookup->comments = pluscomm;
continue; continue;
} }
result = dns_rdatatype_fromtext(&rdtype, result = dns_rdatatype_fromtext(&rdtype,
(isc_textregion_t *)&tr); (isc_textregion_t *)&tr);
if ((result == ISC_R_SUCCESS) && if ((result == ISC_R_SUCCESS) &&
(rdtype != dns_rdatatype_ixfr)) { (rdtype != dns_rdatatype_ixfr)) {
if (rdtype == dns_rdatatype_axfr) {
lookup->section_question =
plusquest;
lookup->comments = pluscomm;
}
lookup->rdtype = rdtype; lookup->rdtype = rdtype;
continue; continue;
} }

View File

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: dighost.c,v 1.147 2000/10/17 00:31:17 gson Exp $ */ /* $Id: dighost.c,v 1.148 2000/10/17 00:35:18 mws Exp $ */
/* /*
* Notice to programmers: Do not use this code as an example of how to * Notice to programmers: Do not use this code as an example of how to
@ -79,7 +79,6 @@ isc_boolean_t
is_dst_up = ISC_FALSE, is_dst_up = ISC_FALSE,
have_domain = ISC_FALSE, have_domain = ISC_FALSE,
is_blocking = ISC_FALSE, is_blocking = ISC_FALSE,
show_packets = ISC_FALSE;
in_port_t port = 53; in_port_t port = 53;
unsigned int timeout = 0; unsigned int timeout = 0;
@ -2182,8 +2181,11 @@ recv_done(isc_task_t *task, isc_event_t *event) {
UNUSED(task); UNUSED(task);
INSIST(!free_now); INSIST(!free_now);
<<<<<<< dighost.c
=======
if (show_packets) if (show_packets)
puts(";; beginning of DNS packet"); puts(";; beginning of DNS packet");
>>>>>>> 1.147
debug("recv_done()"); debug("recv_done()");
LOCK_LOOKUP; LOCK_LOOKUP;
@ -2409,10 +2411,6 @@ recv_done(isc_task_t *task, isc_event_t *event) {
query); query);
} }
} else { } else {
if (query->first_soa_rcvd &&
l->doing_xfr)
printmessage(query, msg, ISC_FALSE);
else
printmessage(query, msg, ISC_TRUE); printmessage(query, msg, ISC_TRUE);
} }
} else if ((dns_message_firstname(msg, DNS_SECTION_ANSWER) } else if ((dns_message_firstname(msg, DNS_SECTION_ANSWER)