Commit 668f8d91 authored by Brian Wellington's avatar Brian Wellington

795. [func] Add the +multiline option to dig.

(which requires dns_message_totext(), etc. to take a style parameter)
parent 94bd918b
795. [func] Add the +multiline option to dig. [RT #1095]
794. [func] Implement the "port" and "default-port" statements
in rndc.conf.
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dig.c,v 1.142 2001/03/14 18:08:16 bwelling Exp $ */
/* $Id: dig.c,v 1.143 2001/03/28 02:42:49 bwelling Exp $ */
#include <config.h>
#include <stdlib.h>
......@@ -31,6 +31,7 @@
#include <dns/byaddr.h>
#include <dns/fixedname.h>
#include <dns/masterdump.h>
#include <dns/message.h>
#include <dns/name.h>
#include <dns/rdata.h>
......@@ -85,7 +86,8 @@ char *argv0;
char domainopt[DNS_NAME_MAXTEXT];
isc_boolean_t short_form = ISC_FALSE, printcmd = ISC_TRUE,
nibble = ISC_FALSE, plusquest = ISC_FALSE, pluscomm = ISC_FALSE;
nibble = ISC_FALSE, plusquest = ISC_FALSE, pluscomm = ISC_FALSE,
multiline = ISC_FALSE;
isc_uint16_t bufsize = 0;
isc_boolean_t forcecomment = ISC_FALSE;
......@@ -183,6 +185,7 @@ show_usage(void) {
" +rrlimit=### (Limit number of rr's in xfr)\n"
" +namelimit=### (Limit number of names in xfr)\n"
" +[no]dnssec (Request DNSSEC records)\n"
" +[no]multiline (Print records in an expanded format)\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"
, stderr);
......@@ -341,6 +344,12 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
dns_messagetextflag_t flags;
isc_buffer_t *buf = NULL;
unsigned int len = OUTPUTBUF;
const dns_master_style_t *style;
if (multiline)
style = &dns_master_style_default;
else
style = &dns_master_style_debug;
if (query->lookup->cmdline[0] != 0) {
fputs(query->lookup->cmdline, stdout);
......@@ -420,7 +429,7 @@ repopulate_buffer:
{
result = dns_message_pseudosectiontotext(msg,
DNS_PSEUDOSECTION_OPT,
flags, buf);
style, flags, buf);
if (result == ISC_R_NOSPACE) {
buftoosmall:
len += OUTPUTBUF;
......@@ -439,7 +448,7 @@ buftoosmall:
if (!short_form) {
result = dns_message_sectiontotext(msg,
DNS_SECTION_QUESTION,
flags, buf);
style, flags, buf);
if (result == ISC_R_NOSPACE)
goto buftoosmall;
check_result(result, "dns_message_sectiontotext");
......@@ -449,7 +458,7 @@ buftoosmall:
if (!short_form) {
result = dns_message_sectiontotext(msg,
DNS_SECTION_ANSWER,
flags, buf);
style, flags, buf);
if (result == ISC_R_NOSPACE)
goto buftoosmall;
check_result(result, "dns_message_sectiontotext");
......@@ -464,7 +473,7 @@ buftoosmall:
if (!short_form) {
result = dns_message_sectiontotext(msg,
DNS_SECTION_AUTHORITY,
flags, buf);
style, flags, buf);
if (result == ISC_R_NOSPACE)
goto buftoosmall;
check_result(result, "dns_message_sectiontotext");
......@@ -474,7 +483,7 @@ buftoosmall:
if (!short_form) {
result = dns_message_sectiontotext(msg,
DNS_SECTION_ADDITIONAL,
flags, buf);
style, flags, buf);
if (result == ISC_R_NOSPACE)
goto buftoosmall;
check_result(result, "dns_message_sectiontotext");
......@@ -485,7 +494,7 @@ buftoosmall:
result = dns_message_pseudosectiontotext(
msg,
DNS_PSEUDOSECTION_TSIG,
flags, buf);
style, flags, buf);
if (result == ISC_R_NOSPACE)
goto buftoosmall;
check_result(result,
......@@ -493,7 +502,7 @@ buftoosmall:
result = dns_message_pseudosectiontotext(
msg,
DNS_PSEUDOSECTION_SIG0,
flags, buf);
style, flags, buf);
if (result == ISC_R_NOSPACE)
goto buftoosmall;
check_result(result,
......@@ -731,6 +740,9 @@ plus_option(char *option, isc_boolean_t is_batchfile,
lookup->ignore = ISC_TRUE;
}
break;
case 'm': /* multiline */
multiline = state;
break;
case 'n':
switch (cmd[1]) {
case 'd': /* ndots */
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: nsupdate.c,v 1.84 2001/03/22 00:06:59 bwelling Exp $ */
/* $Id: nsupdate.c,v 1.85 2001/03/28 02:42:51 bwelling Exp $ */
#include <config.h>
......@@ -48,6 +48,7 @@
#include <dns/dispatch.h>
#include <dns/events.h>
#include <dns/fixedname.h>
#include <dns/masterdump.h>
#include <dns/message.h>
#include <dns/name.h>
#include <dns/rdata.h>
......@@ -127,6 +128,7 @@ static isc_boolean_t shuttingdown = ISC_FALSE;
static FILE *input;
static isc_boolean_t interactive = ISC_TRUE;
static isc_boolean_t seenerror = ISC_FALSE;
static const dns_master_style_t *style = &dns_master_style_debug;
typedef struct nsu_requestinfo {
dns_message_t *msg;
......@@ -1209,7 +1211,7 @@ show_message(dns_message_t *msg) {
isc_buffer_free(&buf);
result = isc_buffer_allocate(mctx, &buf, bufsz);
check_result(result, "isc_buffer_allocate");
result = dns_message_totext(msg, 0, buf);
result = dns_message_totext(msg, style, 0, buf);
bufsz *= 2;
} while (result == ISC_R_NOSPACE);
if (result != ISC_R_SUCCESS) {
......@@ -1336,7 +1338,7 @@ update_completed(isc_task_t *task, isc_event_t *event) {
isc_buffer_free(&buf);
result = isc_buffer_allocate(mctx, &buf, bufsz);
check_result(result, "isc_buffer_allocate");
result = dns_message_totext(rcvmsg, 0, buf);
result = dns_message_totext(rcvmsg, style, 0, buf);
bufsz *= 2;
} while (result == ISC_R_NOSPACE);
check_result(result, "dns_message_totext");
......@@ -1468,7 +1470,7 @@ recvsoa(isc_task_t *task, isc_event_t *event) {
}
result = isc_buffer_allocate(mctx, &buf, bufsz);
check_result(result, "isc_buffer_allocate");
result = dns_message_totext(rcvmsg, 0, buf);
result = dns_message_totext(rcvmsg, style, 0, buf);
} while (result == ISC_R_NOSPACE);
check_result(result, "dns_message_totext");
fprintf(stderr, "Reply from SOA query:\n%.*s\n",
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: sig0_test.c,v 1.7 2001/03/13 02:48:53 bwelling Exp $ */
/* $Id: sig0_test.c,v 1.8 2001/03/28 02:42:53 bwelling Exp $ */
#include <config.h>
......@@ -42,6 +42,7 @@
#include <dns/events.h>
#include <dns/fixedname.h>
#include <dns/keyvalues.h>
#include <dns/masterdump.h>
#include <dns/message.h>
#include <dns/name.h>
#include <dns/rdataset.h>
......@@ -73,6 +74,7 @@ isc_socket_t *s;
isc_sockaddr_t address;
char output[10 * 1024];
isc_buffer_t outbuf;
static const dns_master_style_t *style = &dns_master_style_debug;
static void
senddone(isc_task_t *task, isc_event_t *event) {
......@@ -114,7 +116,7 @@ recvdone(isc_task_t *task, isc_event_t *event) {
CHECK("dns_message_parse", result);
isc_buffer_init(&outbuf, output, sizeof(output));
result = dns_message_totext(response, 0, &outbuf);
result = dns_message_totext(response, style, 0, &outbuf);
CHECK("dns_message_totext", result);
printf("%.*s\n", (int)isc_buffer_usedlength(&outbuf),
(char *)isc_buffer_base(&outbuf));
......@@ -180,7 +182,7 @@ buildquery(void) {
dns_compress_invalidate(&cctx);
isc_buffer_init(&outbuf, output, sizeof(output));
result = dns_message_totext(query, 0, &outbuf);
result = dns_message_totext(query, style, 0, &outbuf);
CHECK("dns_message_totext", result);
printf("%.*s\n", (int)isc_buffer_usedlength(&outbuf),
(char *)isc_buffer_base(&outbuf));
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: message.h,v 1.96 2001/03/28 00:50:00 gson Exp $ */
/* $Id: message.h,v 1.97 2001/03/28 02:42:56 bwelling Exp $ */
#ifndef DNS_MESSAGE_H
#define DNS_MESSAGE_H 1
......@@ -28,6 +28,7 @@
#include <isc/magic.h>
#include <dns/compress.h>
#include <dns/masterdump.h>
#include <dns/types.h>
#include <dst/dst.h>
......@@ -296,12 +297,14 @@ dns_message_destroy(dns_message_t **msgp);
isc_result_t
dns_message_sectiontotext(dns_message_t *msg, dns_section_t section,
const dns_master_style_t *style,
dns_messagetextflag_t flags,
isc_buffer_t *target);
isc_result_t
dns_message_pseudosectiontotext(dns_message_t *msg,
dns_pseudosection_t section,
const dns_master_style_t *style,
dns_messagetextflag_t flags,
isc_buffer_t *target);
/*
......@@ -315,6 +318,8 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
*
* 'msg' is a valid message.
*
* 'style' is a valid master dump style.
*
* 'target' is a valid buffer.
*
* 'section' is a valid section label.
......@@ -335,8 +340,8 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
*/
isc_result_t
dns_message_totext(dns_message_t *msg, dns_messagetextflag_t flags,
isc_buffer_t *target);
dns_message_totext(dns_message_t *msg, const dns_master_style_t *style,
dns_messagetextflag_t flags, isc_buffer_t *target);
/*
* Convert all sections of message 'msg' to a cleartext representation
*
......@@ -352,6 +357,8 @@ dns_message_totext(dns_message_t *msg, dns_messagetextflag_t flags,
*
* 'msg' is a valid message.
*
* 'style' is a valid master dump style.
*
* 'target' is a valid buffer.
*
* Ensures:
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: message.c,v 1.188 2001/03/28 00:58:13 gson Exp $ */
/* $Id: message.c,v 1.189 2001/03/28 02:42:54 bwelling Exp $ */
/***
*** Imports
......@@ -2803,6 +2803,7 @@ dns_message_checksig(dns_message_t *msg, dns_view_t *view) {
isc_result_t
dns_message_sectiontotext(dns_message_t *msg, dns_section_t section,
const dns_master_style_t *style,
dns_messagetextflag_t flags,
isc_buffer_t *target) {
dns_name_t *name, empty_name;
......@@ -2842,12 +2843,12 @@ dns_message_sectiontotext(dns_message_t *msg, dns_section_t section,
ADD_STRING(target, ";");
result = dns_master_questiontotext(name,
rdataset,
&dns_master_style_debug,
style,
target);
} else {
result = dns_master_rdatasettotext(name,
rdataset,
&dns_master_style_debug,
style,
target);
}
if (result != ISC_R_SUCCESS)
......@@ -2866,6 +2867,7 @@ dns_message_sectiontotext(dns_message_t *msg, dns_section_t section,
isc_result_t
dns_message_pseudosectiontotext(dns_message_t *msg,
dns_pseudosection_t section,
const dns_master_style_t *style,
dns_messagetextflag_t flags,
isc_buffer_t *target) {
dns_rdataset_t *ps = NULL;
......@@ -2907,9 +2909,7 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
return (ISC_R_SUCCESS);
if ((flags & DNS_MESSAGETEXTFLAG_NOCOMMENTS) == 0)
ADD_STRING(target, ";; TSIG PSEUDOSECTION:\n");
result = dns_master_rdatasettotext(name, ps,
&dns_master_style_debug,
target);
result = dns_master_rdatasettotext(name, ps, style, target);
if ((flags & DNS_MESSAGETEXTFLAG_NOHEADERS) == 0 &&
(flags & DNS_MESSAGETEXTFLAG_NOCOMMENTS) == 0)
ADD_STRING(target, "\n");
......@@ -2920,9 +2920,7 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
return (ISC_R_SUCCESS);
if ((flags & DNS_MESSAGETEXTFLAG_NOCOMMENTS) == 0)
ADD_STRING(target, ";; SIG0 PSEUDOSECTION:\n");
result = dns_master_rdatasettotext(name, ps,
&dns_master_style_debug,
target);
result = dns_master_rdatasettotext(name, ps, style, target);
if ((flags & DNS_MESSAGETEXTFLAG_NOHEADERS) == 0 &&
(flags & DNS_MESSAGETEXTFLAG_NOCOMMENTS) == 0)
ADD_STRING(target, "\n");
......@@ -2932,8 +2930,8 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
}
isc_result_t
dns_message_totext(dns_message_t *msg, dns_messagetextflag_t flags,
isc_buffer_t *target) {
dns_message_totext(dns_message_t *msg, const dns_master_style_t *style,
dns_messagetextflag_t flags, isc_buffer_t *target) {
char buf[sizeof "1234567890"];
isc_result_t result;
......@@ -2991,36 +2989,36 @@ dns_message_totext(dns_message_t *msg, dns_messagetextflag_t flags,
}
result = dns_message_pseudosectiontotext(msg,
DNS_PSEUDOSECTION_OPT,
flags, target);
style, flags, target);
if (result != ISC_R_SUCCESS)
return (result);
result = dns_message_sectiontotext(msg, DNS_SECTION_QUESTION,
flags, target);
style, flags, target);
if (result != ISC_R_SUCCESS)
return (result);
result = dns_message_sectiontotext(msg, DNS_SECTION_ANSWER,
flags, target);
style, flags, target);
if (result != ISC_R_SUCCESS)
return (result);
result = dns_message_sectiontotext(msg, DNS_SECTION_AUTHORITY,
flags, target);
style, flags, target);
if (result != ISC_R_SUCCESS)
return (result);
result = dns_message_sectiontotext(msg, DNS_SECTION_ADDITIONAL,
flags, target);
style, flags, target);
if (result != ISC_R_SUCCESS)
return (result);
result = dns_message_pseudosectiontotext(msg,
DNS_PSEUDOSECTION_TSIG,
flags, target);
style, flags, target);
if (result != ISC_R_SUCCESS)
return (result);
result = dns_message_pseudosectiontotext(msg,
DNS_PSEUDOSECTION_SIG0,
flags, target);
style, flags, target);
if (result != ISC_R_SUCCESS)
return (result);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment