Commit ca03bd79 authored by Libor Peltan's avatar Libor Peltan

Merge branch 'kdig_nocomments' into 'master'

kdig: add +[no]comments option

See merge request !964
parents a10d5a5c 9c9d28ba
......@@ -197,6 +197,9 @@ Show the query packet.
\fB+\fP[\fBno\fP]\fBheader\fP
Show the packet header.
.TP
\fB+\fP[\fBno\fP]\fBcomments\fP
Show commented section names.
.TP
\fB+\fP[\fBno\fP]\fBopt\fP
Show the EDNS pseudosection.
.TP
......
......@@ -176,6 +176,9 @@ Options
**+**\ [\ **no**\ ]\ **header**
Show the packet header.
**+**\ [\ **no**\ ]\ **comments**
Show commented section names.
**+**\ [\ **no**\ ]\ **opt**
Show the EDNS pseudosection.
......
......@@ -608,7 +608,7 @@ void print_packet(const knot_pkt_t *packet,
// Print EDNS section.
if (style->show_edns && knot_pkt_has_edns(packet)) {
printf("\n;; EDNS PSEUDOSECTION:\n;; ");
printf("%s", style->show_section ? "\n;; EDNS PSEUDOSECTION:\n;; " : ";;");
print_section_opt(packet);
}
......@@ -628,7 +628,7 @@ void print_packet(const knot_pkt_t *packet,
break;
case FORMAT_NSUPDATE:
if (style->show_question && qdcount > 0) {
printf("\n;; ZONE SECTION:\n;; ");
printf("%s", style->show_section ? "\n;; ZONE SECTION:\n;; " : ";;");
print_section_question(knot_pkt_qname(packet),
knot_pkt_qclass(packet),
knot_pkt_qtype(packet),
......@@ -636,23 +636,23 @@ void print_packet(const knot_pkt_t *packet,
}
if (style->show_answer && ancount > 0) {
printf("\n;; PREREQUISITE SECTION:\n");
printf("%s", style->show_section ? "\n;; PREREQUISITE SECTION:\n" : "");
print_section_full(knot_pkt_rr(answers, 0), ancount, style, true);
}
if (style->show_authority && nscount > 0) {
printf("\n;; UPDATE SECTION:\n");
printf("%s", style->show_section ? "\n;; UPDATE SECTION:\n" : "");
print_section_full(knot_pkt_rr(authority, 0), nscount, style, true);
}
if (style->show_additional && arcount > 0) {
printf("\n;; ADDITIONAL DATA:\n");
printf("%s", style->show_section ? "\n;; ADDITIONAL DATA:\n" : "");
print_section_full(knot_pkt_rr(additional, 0), arcount, style, true);
}
break;
case FORMAT_FULL:
if (style->show_question && qdcount > 0) {
printf("\n;; QUESTION SECTION:\n;; ");
printf("%s", style->show_section ? "\n;; QUESTION SECTION:\n;; " : ";;");
print_section_question(knot_pkt_qname(packet),
knot_pkt_qclass(packet),
knot_pkt_qtype(packet),
......@@ -660,17 +660,17 @@ void print_packet(const knot_pkt_t *packet,
}
if (style->show_answer && ancount > 0) {
printf("\n;; ANSWER SECTION:\n");
printf("%s", style->show_section ? "\n;; ANSWER SECTION:\n" : "");
print_section_full(knot_pkt_rr(answers, 0), ancount, style, true);
}
if (style->show_authority && nscount > 0) {
printf("\n;; AUTHORITY SECTION:\n");
printf("%s", style->show_section ? "\n;; AUTHORITY SECTION:\n" : "");
print_section_full(knot_pkt_rr(authority, 0), nscount, style, true);
}
if (style->show_additional && arcount > 0) {
printf("\n;; ADDITIONAL SECTION:\n");
printf("%s", style->show_section ? "\n;; ADDITIONAL SECTION:\n" : "");
print_section_full(knot_pkt_rr(additional, 0), arcount, style, true);
}
break;
......@@ -680,7 +680,7 @@ void print_packet(const knot_pkt_t *packet,
// Print TSIG section.
if (style->show_tsig && knot_pkt_has_tsig(packet)) {
printf("\n;; TSIG PSEUDOSECTION:\n");
printf("%s", style->show_section ? "\n;; TSIG PSEUDOSECTION:\n" : "");
print_section_full(packet->tsig_rr, 1, style, false);
}
......
......@@ -72,6 +72,8 @@ typedef struct {
bool show_query;
/*!< Show header info. */
bool show_header;
/*!< Show section name. */
bool show_section;
/*!< Show EDNS pseudosection. */
bool show_edns;
/*!< Show QUERY/ZONE section. */
......
......@@ -69,6 +69,7 @@ static const style_t DEFAULT_STYLE_DIG = {
},
.show_query = false,
.show_header = true,
.show_section = true,
.show_edns = true,
.show_question = true,
.show_answer = true,
......@@ -353,6 +354,24 @@ static int opt_noheader(const char *arg, void *query)
return KNOT_EOK;
}
static int opt_comments(const char *arg, void *query)
{
query_t *q = query;
q->style.show_section = true;
return KNOT_EOK;
}
static int opt_nocomments(const char *arg, void *query)
{
query_t *q = query;
q->style.show_section = false;
return KNOT_EOK;
}
static int opt_opt(const char *arg, void *query)
{
query_t *q = query;
......@@ -1152,6 +1171,10 @@ static const param_t kdig_opts2[] = {
{ "header", ARG_NONE, opt_header },
{ "noheader", ARG_NONE, opt_noheader },
{ "comments", ARG_NONE, opt_comments },
{ "nocomments", ARG_NONE, opt_nocomments },
{ "opt", ARG_NONE, opt_opt },
{ "opt", ARG_NONE, opt_opt },
{ "noopt", ARG_NONE, opt_noopt },
......@@ -1889,6 +1912,7 @@ static void print_help(void)
" +[no]all Show all packet sections.\n"
" +[no]qr Show query packet.\n"
" +[no]header Show packet header.\n"
" +[no]comments Show commented section names.\n"
" +[no]opt Show EDNS pseudosection.\n"
" +[no]question Show question section.\n"
" +[no]answer Show answer section.\n"
......
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