summaryrefslogtreecommitdiff
path: root/bin/dig/dig.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/dig/dig.c')
-rw-r--r--bin/dig/dig.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/bin/dig/dig.c b/bin/dig/dig.c
index 145e6107ad33c..d5f872dd38647 100644
--- a/bin/dig/dig.c
+++ b/bin/dig/dig.c
@@ -67,9 +67,12 @@ static char domainopt[DNS_NAME_MAXTEXT];
static isc_boolean_t short_form = ISC_FALSE, printcmd = ISC_TRUE,
ip6_int = ISC_FALSE, plusquest = ISC_FALSE, pluscomm = ISC_FALSE,
multiline = ISC_FALSE, nottl = ISC_FALSE, noclass = ISC_FALSE,
- onesoa = ISC_FALSE, rrcomments = ISC_FALSE;
+ onesoa = ISC_FALSE;
static isc_uint32_t splitwidth = 0xffffffff;
+/*% rrcomments are neither explicitly enabled nor disabled by default */
+static int rrcomments = 0;
+
/*% opcode text */
static const char * const opcodetext[] = {
"QUERY",
@@ -319,7 +322,8 @@ say_message(dns_rdata_t *rdata, dig_query_t *query, isc_buffer_t *buf) {
ADD_STRING(buf, " ");
}
- if (rrcomments)
+ /* Turn on rrcomments if explicitly enabled */
+ if (rrcomments > 0)
styleflags |= DNS_STYLEFLAG_RRCOMMENT;
result = dns_rdata_tofmttext(rdata, NULL, styleflags, 0,
splitwidth, " ", buf);
@@ -404,7 +408,8 @@ printrdataset(dns_name_t *owner_name, dns_rdataset_t *rdataset,
styleflags |= DNS_STYLEFLAG_NO_TTL;
if (noclass)
styleflags |= DNS_STYLEFLAG_NO_CLASS;
- if (rrcomments)
+ /* Turn on rrcomments if explicitly enabled */
+ if (rrcomments > 0)
styleflags |= DNS_STYLEFLAG_RRCOMMENT;
if (multiline) {
styleflags |= DNS_STYLEFLAG_OMIT_OWNER;
@@ -414,7 +419,9 @@ printrdataset(dns_name_t *owner_name, dns_rdataset_t *rdataset,
styleflags |= DNS_STYLEFLAG_TTL;
styleflags |= DNS_STYLEFLAG_MULTILINE;
styleflags |= DNS_STYLEFLAG_COMMENT;
- styleflags |= DNS_STYLEFLAG_RRCOMMENT;
+ /* Turn on rrcomments if not explicitly disabled */
+ if (rrcomments >= 0)
+ styleflags |= DNS_STYLEFLAG_RRCOMMENT;
}
if (multiline || (nottl && noclass))
@@ -455,7 +462,8 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
styleflags |= DNS_STYLEFLAG_REL_OWNER;
if (query->lookup->comments)
styleflags |= DNS_STYLEFLAG_COMMENT;
- if (rrcomments)
+ /* Turn on rrcomments if explicitly enabled */
+ if (rrcomments > 0)
styleflags |= DNS_STYLEFLAG_RRCOMMENT;
if (nottl)
styleflags |= DNS_STYLEFLAG_NO_TTL;
@@ -468,7 +476,9 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
styleflags |= DNS_STYLEFLAG_OMIT_TTL;
styleflags |= DNS_STYLEFLAG_TTL;
styleflags |= DNS_STYLEFLAG_MULTILINE;
- styleflags |= DNS_STYLEFLAG_RRCOMMENT;
+ /* Turn on rrcomments unless explicitly disabled */
+ if (rrcomments >= 0)
+ styleflags |= DNS_STYLEFLAG_RRCOMMENT;
}
if (multiline || (nottl && noclass))
result = dns_master_stylecreate2(&style, styleflags,
@@ -720,7 +730,7 @@ printgreeting(int argc, char **argv, dig_lookup_t *lookup) {
*/
static void
-plus_option(char *option, isc_boolean_t is_batchfile,
+plus_option(const char *option, isc_boolean_t is_batchfile,
dig_lookup_t *lookup)
{
isc_result_t result;
@@ -735,7 +745,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
strncpy(option_store, option, sizeof(option_store));
option_store[sizeof(option_store)-1]=0;
ptr = option_store;
- cmd = next_token(&ptr,"=");
+ cmd = next_token(&ptr, "=");
if (cmd == NULL) {
printf(";; Invalid option %s\n", option_store);
return;
@@ -789,7 +799,6 @@ plus_option(char *option, isc_boolean_t is_batchfile,
lookup->section_answer = state;
lookup->section_additional = state;
lookup->comments = state;
- rrcomments = state;
lookup->stats = state;
printcmd = state;
break;
@@ -955,13 +964,13 @@ plus_option(char *option, isc_boolean_t is_batchfile,
lookup->identify = ISC_TRUE;
lookup->stats = ISC_FALSE;
lookup->comments = ISC_FALSE;
- rrcomments = ISC_FALSE;
lookup->section_additional = ISC_FALSE;
lookup->section_authority = ISC_FALSE;
lookup->section_question = ISC_FALSE;
lookup->rdtype = dns_rdatatype_ns;
lookup->rdtypeset = ISC_TRUE;
short_form = ISC_TRUE;
+ rrcomments = 0;
}
break;
default:
@@ -1022,7 +1031,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
break;
case 'r': /* rrcomments */
FULLCHECK("rrcomments");
- rrcomments = state;
+ rrcomments = state ? 1 : -1;
break;
default:
goto invalid_option;
@@ -1050,8 +1059,8 @@ plus_option(char *option, isc_boolean_t is_batchfile,
lookup->section_authority = ISC_FALSE;
lookup->section_question = ISC_FALSE;
lookup->comments = ISC_FALSE;
- rrcomments = ISC_FALSE;
lookup->stats = ISC_FALSE;
+ rrcomments = -1;
}
break;
case 'w': /* showsearch */
@@ -1149,7 +1158,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
lookup->recurse = ISC_FALSE;
lookup->identify = ISC_TRUE;
lookup->comments = ISC_FALSE;
- rrcomments = ISC_FALSE;
+ rrcomments = 0;
lookup->stats = ISC_FALSE;
lookup->section_additional = ISC_FALSE;
lookup->section_authority = ISC_TRUE;
@@ -1207,7 +1216,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
invalid_option:
need_value:
fprintf(stderr, "Invalid option: +%s\n",
- option);
+ option);
usage();
}
return;
@@ -1434,14 +1443,14 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
value);
return (value_from_next);
case 'y':
- ptr = next_token(&value,":"); /* hmac type or name */
+ ptr = next_token(&value, ":"); /* hmac type or name */
if (ptr == NULL) {
usage();
}
ptr2 = next_token(&value, ":"); /* name or secret */
if (ptr2 == NULL)
usage();
- ptr3 = next_token(&value,":"); /* secret or NULL */
+ ptr3 = next_token(&value, ":"); /* secret or NULL */
if (ptr3 != NULL) {
parse_hmac(ptr);
ptr = ptr2;