]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
1298. [func] dig: now supports +[no]cl +[no]ttlid.
authorMark Andrews <marka@isc.org>
Wed, 22 May 2002 04:58:30 +0000 (04:58 +0000)
committerMark Andrews <marka@isc.org>
Wed, 22 May 2002 04:58:30 +0000 (04:58 +0000)
CHANGES
bin/dig/dig.c
bin/dig/dig.docbook

diff --git a/CHANGES b/CHANGES
index 1c13fafce43f7b9f600a9937894d9caa3a4a2349..f7fc6b6019ee999a6e0bc15b932ff0ca95ceacff 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+1298.  [func]          dig: now supports +[no]cl +[no]ttlid.
+
 1297.  [func]          You can now create your own customised printing
                        styles: dns_master_stylecreate() and
                        dns_master_styledestroy().
index 231fd694ceb26ea9b2a4dda3bbc0019658e668bf..2f30ad821eed9ab6ad558ed7d5363ab115edea25 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: dig.c,v 1.176 2001/12/19 12:16:38 marka Exp $ */
+/* $Id: dig.c,v 1.177 2002/05/22 04:58:29 marka Exp $ */
 
 #include <config.h>
 #include <stdlib.h>
@@ -85,7 +85,7 @@ static char domainopt[DNS_NAME_MAXTEXT];
 
 static isc_boolean_t short_form = ISC_FALSE, printcmd = ISC_TRUE,
        nibble = ISC_FALSE, plusquest = ISC_FALSE, pluscomm = ISC_FALSE,
-       multiline = ISC_FALSE;
+       multiline = ISC_FALSE, nottl = ISC_FALSE, noclass = ISC_FALSE;
 
 static const char *opcodetext[] = {
        "QUERY",
@@ -186,6 +186,7 @@ help(void) {
 "                 +[no]aaonly         (Set AA flag in query)\n"
 "                 +[no]adflag         (Set AD flag in query)\n"
 "                 +[no]cdflag         (Set CD flag in query)\n"
+"                 +[no]cl             (Control display of class in records)\n"
 "                 +[no]cmd            (Control display of command line)\n"
 "                 +[no]comments       (Control display of comment lines)\n"
 "                 +[no]question       (Control display of question)\n"
@@ -195,6 +196,7 @@ help(void) {
 "                 +[no]stats          (Control display of statistics)\n"
 "                 +[no]short          (Disable everything except short\n"
 "                                      form of answer)\n"
+"                 +[no]ttlid          (Control display of ttls in records)\n"
 "                 +[no]all            (Set or clear all display flags)\n"
 "                 +[no]qr             (Print question before sending)\n"
 "                 +[no]nssearch       (Search all authoritative nameservers)\n"
@@ -356,12 +358,33 @@ 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;
+       dns_master_style_t *style = NULL;
+       unsigned int styleflags = 0;
+
+       styleflags |= DNS_STYLEFLAG_REL_OWNER;
+       if (nottl)
+               styleflags |= DNS_STYLEFLAG_NO_TTL;
+       if (noclass)
+               styleflags |= DNS_STYLEFLAG_NO_CLASS;
+       if (multiline) {
+               styleflags |= DNS_STYLEFLAG_OMIT_OWNER;
+               styleflags |= DNS_STYLEFLAG_OMIT_CLASS;
+               styleflags |= DNS_STYLEFLAG_REL_DATA;
+               styleflags |= DNS_STYLEFLAG_OMIT_TTL;
+               styleflags |= DNS_STYLEFLAG_TTL;
+               styleflags |= DNS_STYLEFLAG_MULTILINE;
+               styleflags |= DNS_STYLEFLAG_COMMENT;
+       }
+       if (multiline || (nottl && noclass))
+               result = dns_master_stylecreate(&style, styleflags,
+                                               24, 24, 24, 32, 80, 8, mctx);
+       else if (nottl || noclass)
+               result = dns_master_stylecreate(&style, styleflags,
+                                               24, 24, 32, 40, 80, 8, mctx);
+       else 
+               result = dns_master_stylecreate(&style, styleflags,
+                                               24, 32, 40, 48, 80, 8, mctx);
+       check_result(result, "dns_master_stylecreate");
 
        if (query->lookup->cmdline[0] != 0) {
                if (!short_form)
@@ -438,7 +461,7 @@ buftoosmall:
                        if (result == ISC_R_SUCCESS)
                                goto repopulate_buffer;
                        else
-                               return (result);
+                               goto cleanup;
                }
                check_result(result,
                     "dns_message_pseudosectiontotext");
@@ -516,6 +539,10 @@ buftoosmall:
        printf("%.*s", (int)isc_buffer_usedlength(buf),
               (char *)isc_buffer_base(buf));
        isc_buffer_free(&buf);
+
+cleanup:
+       if (style != NULL)
+               dns_master_styledestroy(&style, mctx);
        return (result);
 }
 
@@ -719,6 +746,10 @@ plus_option(char *option, isc_boolean_t is_batchfile,
                        FULLCHECK("cdflag");
                        lookup->cdflag = state;
                        break;
+               case 'l': /* cl */
+                       FULLCHECK("cl");
+                       noclass = !state;
+                       break;
                case 'm': /* cmd */
                        FULLCHECK("cmd");
                        printcmd = state;
@@ -924,6 +955,10 @@ plus_option(char *option, isc_boolean_t is_batchfile,
                                goto invalid_option;
                        }
                        break;
+               case 't': /* ttlid */
+                       FULLCHECK("ttlid");
+                       nottl = !state;
+                       break;
                default:
                        goto invalid_option;
                }
index 311a7602197b220bc9cce9ed4bfd0ec42cfb6bc5..087b41aa42a9a683e423a82e3acbe50dd5a902fc 100644 (file)
@@ -16,7 +16,7 @@
  - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 -->
 
-<!-- $Id: dig.docbook,v 1.10 2001/11/14 06:34:24 marka Exp $ -->
+<!-- $Id: dig.docbook,v 1.11 2002/05/22 04:58:30 marka Exp $ -->
 
 <refentry>
 
@@ -315,6 +315,16 @@ Set [do not set] the CD (checking disabled) bit in the query.  This
 requests the server to not perform DNSSEC validation of responses.
 </para></listitem></varlistentry>
 
+<varlistentry><term><option>+[no]cl</option></term>
+<listitem><para>
+Display [do not display] the CLASS when printing the record.
+</para></listitem></varlistentry>
+
+<varlistentry><term><option>+[no]ttlid</option></term>
+<listitem><para>
+Display [do not display] the TTL when printing the record.
+</para></listitem></varlistentry>
+
 <varlistentry><term><option>+[no]recursive</option></term>
 <listitem><para>
 Toggle the setting of the RD (recursion desired) bit in the query.