mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-11 01:10:00 -04:00
Style fixes per Andreas, functionality fixes per Michael Sawyer.
The printgreeting() stuff is fixed once and for all by the change to clone_lookup... I think this is the "right" way of doing it.
This commit is contained in:
parent
7aff04f5d0
commit
d8dde7c9fb
4 changed files with 64 additions and 86 deletions
106
bin/dig/dig.c
106
bin/dig/dig.c
|
|
@ -15,7 +15,7 @@
|
|||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: dig.c,v 1.137 2001/02/14 01:46:03 tamino Exp $ */
|
||||
/* $Id: dig.c,v 1.138 2001/02/15 23:44:03 tamino Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -414,7 +414,7 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
|
|||
}
|
||||
}
|
||||
|
||||
buftoosmall:
|
||||
repopulate_buffer:
|
||||
|
||||
if (query->lookup->comments && headers && !short_form)
|
||||
{
|
||||
|
|
@ -422,11 +422,14 @@ buftoosmall:
|
|||
DNS_PSEUDOSECTION_OPT,
|
||||
flags, buf);
|
||||
if (result == ISC_R_NOSPACE) {
|
||||
buftoosmall:
|
||||
len += OUTPUTBUF;
|
||||
isc_buffer_free(&buf);
|
||||
result = isc_buffer_allocate(mctx, &buf, len);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
goto buftoosmall;
|
||||
goto repopulate_buffer;
|
||||
else
|
||||
return (result);
|
||||
}
|
||||
check_result(result,
|
||||
"dns_message_pseudosectiontotext");
|
||||
|
|
@ -438,11 +441,7 @@ buftoosmall:
|
|||
DNS_SECTION_QUESTION,
|
||||
flags, buf);
|
||||
if (result == ISC_R_NOSPACE) {
|
||||
len += OUTPUTBUF;
|
||||
isc_buffer_free(&buf);
|
||||
result = isc_buffer_allocate(mctx, &buf, len);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
goto buftoosmall;
|
||||
goto buftoosmall;
|
||||
}
|
||||
check_result(result, "dns_message_sectiontotext");
|
||||
}
|
||||
|
|
@ -453,15 +452,14 @@ buftoosmall:
|
|||
DNS_SECTION_ANSWER,
|
||||
flags, buf);
|
||||
if (result == ISC_R_NOSPACE) {
|
||||
len += OUTPUTBUF;
|
||||
isc_buffer_free(&buf);
|
||||
result = isc_buffer_allocate(mctx, &buf, len);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
goto buftoosmall;
|
||||
goto buftoosmall;
|
||||
}
|
||||
check_result(result, "dns_message_sectiontotext");
|
||||
} else {
|
||||
result = short_answer(msg, flags, buf, query);
|
||||
if (result == ISC_R_NOSPACE) {
|
||||
goto buftoosmall;
|
||||
}
|
||||
check_result(result, "short_answer");
|
||||
}
|
||||
}
|
||||
|
|
@ -471,11 +469,7 @@ buftoosmall:
|
|||
DNS_SECTION_AUTHORITY,
|
||||
flags, buf);
|
||||
if (result == ISC_R_NOSPACE) {
|
||||
len += OUTPUTBUF;
|
||||
isc_buffer_free(&buf);
|
||||
result = isc_buffer_allocate(mctx, &buf, len);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
goto buftoosmall;
|
||||
goto buftoosmall;
|
||||
}
|
||||
check_result(result, "dns_message_sectiontotext");
|
||||
}
|
||||
|
|
@ -486,11 +480,7 @@ buftoosmall:
|
|||
DNS_SECTION_ADDITIONAL,
|
||||
flags, buf);
|
||||
if (result == ISC_R_NOSPACE) {
|
||||
len += OUTPUTBUF;
|
||||
isc_buffer_free(&buf);
|
||||
result = isc_buffer_allocate(mctx, &buf, len);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
goto buftoosmall;
|
||||
goto buftoosmall;
|
||||
}
|
||||
check_result(result, "dns_message_sectiontotext");
|
||||
/*
|
||||
|
|
@ -501,12 +491,18 @@ buftoosmall:
|
|||
msg,
|
||||
DNS_PSEUDOSECTION_TSIG,
|
||||
flags, buf);
|
||||
if (result == ISC_R_NOSPACE) {
|
||||
goto buftoosmall;
|
||||
}
|
||||
check_result(result,
|
||||
"dns_message_pseudosectiontotext");
|
||||
result = dns_message_pseudosectiontotext(
|
||||
msg,
|
||||
DNS_PSEUDOSECTION_SIG0,
|
||||
flags, buf);
|
||||
if (result == ISC_R_NOSPACE) {
|
||||
goto buftoosmall;
|
||||
}
|
||||
|
||||
check_result(result,
|
||||
"dns_message_pseudosectiontotext");
|
||||
|
|
@ -912,7 +908,9 @@ plus_option(char *option, isc_boolean_t is_batchfile,
|
|||
*/
|
||||
static isc_boolean_t
|
||||
dash_option(char *option, char *next, dig_lookup_t **lookup,
|
||||
isc_boolean_t *open_type_class)
|
||||
isc_boolean_t *open_type_class,
|
||||
isc_boolean_t *firstarg,
|
||||
int argc, char **argv)
|
||||
{
|
||||
char cmd, *value, *ptr;
|
||||
isc_result_t result;
|
||||
|
|
@ -921,13 +919,6 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
|
|||
dns_rdatatype_t rdtype;
|
||||
dns_rdataclass_t rdclass;
|
||||
char textname[MXNAME];
|
||||
isc_boolean_t orig_rdtypeset;
|
||||
dns_rdatatype_t orig_rdtype;
|
||||
isc_uint32_t orig_ixfr_serial;
|
||||
isc_boolean_t orig_section_question;
|
||||
isc_boolean_t orig_comments;
|
||||
dns_rdataclass_t orig_rdclass;
|
||||
isc_boolean_t orig_rdclassset;
|
||||
|
||||
cmd = option[0];
|
||||
if (strlen(option) > 1) {
|
||||
|
|
@ -1047,13 +1038,6 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
|
|||
keysecret[sizeof(keysecret)-1]=0;
|
||||
return (value_from_next);
|
||||
case 'x':
|
||||
orig_rdtypeset = (*lookup)->rdtypeset;
|
||||
orig_rdtype = (*lookup)->rdtype;
|
||||
orig_ixfr_serial = (*lookup)->ixfr_serial;
|
||||
orig_section_question = (*lookup)->section_question;
|
||||
orig_comments = (*lookup)->comments;
|
||||
orig_rdclassset = (*lookup)->rdclassset;
|
||||
orig_rdclass = (*lookup)->rdclass;
|
||||
*lookup = clone_lookup(default_lookup, ISC_TRUE);
|
||||
if (get_reverse(textname, value, nibble) == ISC_R_SUCCESS) {
|
||||
strncpy((*lookup)->textname, textname,
|
||||
|
|
@ -1062,24 +1046,16 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
|
|||
(*lookup)->trace_root = ISC_TF((*lookup)->trace ||
|
||||
(*lookup)->ns_search_only);
|
||||
(*lookup)->nibble = nibble;
|
||||
if (!orig_rdtypeset)
|
||||
if (!(*lookup)->rdtypeset)
|
||||
(*lookup)->rdtype = dns_rdatatype_ptr;
|
||||
else
|
||||
{
|
||||
(*lookup)->rdtypeset = orig_rdtypeset;
|
||||
(*lookup)->rdtype = orig_rdtype;
|
||||
(*lookup)->ixfr_serial = orig_ixfr_serial;
|
||||
(*lookup)->section_question = orig_section_question;
|
||||
(*lookup)->comments = orig_comments;
|
||||
}
|
||||
if (!orig_rdclassset)
|
||||
if (!(*lookup)->rdclassset)
|
||||
(*lookup)->rdclass = dns_rdataclass_in;
|
||||
else
|
||||
{
|
||||
(*lookup)->rdclassset = orig_rdclassset;
|
||||
(*lookup)->rdclass = orig_rdclass;
|
||||
}
|
||||
(*lookup)->new_search = ISC_TRUE;
|
||||
if (*lookup && *firstarg)
|
||||
{
|
||||
printgreeting(argc, argv, *lookup);
|
||||
*firstarg = ISC_FALSE;
|
||||
}
|
||||
ISC_LIST_APPEND(lookup_list, *lookup, link);
|
||||
} else {
|
||||
fprintf(stderr, "Invalid IP address %s\n", value);
|
||||
|
|
@ -1212,13 +1188,15 @@ parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only,
|
|||
} else if (rv[0][0] == '-') {
|
||||
if (rc <= 1) {
|
||||
if (dash_option(&rv[0][1], NULL,
|
||||
&lookup, &open_type_class)) {
|
||||
&lookup, &open_type_class,
|
||||
&firstarg, argc, argv)) {
|
||||
rc--;
|
||||
rv++;
|
||||
}
|
||||
} else {
|
||||
if (dash_option(&rv[0][1], rv[1],
|
||||
&lookup, &open_type_class)) {
|
||||
&lookup, &open_type_class,
|
||||
&firstarg, argc, argv)) {
|
||||
rc--;
|
||||
rv++;
|
||||
}
|
||||
|
|
@ -1348,22 +1326,12 @@ parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only,
|
|||
strcpy(lookup->textname, ".");
|
||||
lookup->rdtype = dns_rdatatype_ns;
|
||||
lookup->rdtypeset = ISC_TRUE;
|
||||
printgreeting(argc, argv, lookup);
|
||||
firstarg = ISC_FALSE;
|
||||
if (firstarg) {
|
||||
printgreeting(argc, argv, lookup);
|
||||
firstarg = ISC_FALSE;
|
||||
}
|
||||
ISC_LIST_APPEND(lookup_list, lookup, link);
|
||||
}
|
||||
|
||||
/*
|
||||
* If we haven't already printed a greeting, and we have a lookup
|
||||
* with which to print one, do it now. The reason that we sometimes
|
||||
* call it earlier than this is that we munge some of the things
|
||||
* printgreeting() needs under certain circumstances.
|
||||
*/
|
||||
if (lookup && firstarg)
|
||||
{
|
||||
printgreeting(argc, argv, lookup);
|
||||
firstarg = ISC_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: dighost.c,v 1.189 2001/02/13 23:12:14 tamino Exp $ */
|
||||
/* $Id: dighost.c,v 1.190 2001/02/15 23:44:05 tamino Exp $ */
|
||||
|
||||
/*
|
||||
* Notice to programmers: Do not use this code as an example of how to
|
||||
|
|
@ -347,7 +347,7 @@ make_empty_lookup(void) {
|
|||
__FILE__, __LINE__);
|
||||
looknew->pending = ISC_TRUE;
|
||||
looknew->textname[0] = 0;
|
||||
looknew->cmdline[0] = 0; /* Not copied in clone_lookup! */
|
||||
looknew->cmdline[0] = 0;
|
||||
looknew->rdtype = dns_rdatatype_a;
|
||||
looknew->rdclass = dns_rdataclass_in;
|
||||
looknew->rdtypeset = ISC_FALSE;
|
||||
|
|
@ -417,6 +417,7 @@ clone_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
|
|||
looknew = make_empty_lookup();
|
||||
INSIST(looknew != NULL);
|
||||
strncpy(looknew->textname, lookold-> textname, MXNAME);
|
||||
strncpy(looknew->cmdline, lookold->cmdline, MXNAME);
|
||||
looknew->textname[MXNAME-1] = 0;
|
||||
looknew->rdtype = lookold->rdtype;
|
||||
looknew->rdclass = lookold->rdclass;
|
||||
|
|
@ -2470,7 +2471,8 @@ recv_done(isc_task_t *task, isc_event_t *event) {
|
|||
{
|
||||
if ((result != ISC_R_SUCCESS) || l->trace_root)
|
||||
{
|
||||
/* We didn't get an
|
||||
/*
|
||||
* We didn't get an
|
||||
* answer section,
|
||||
* or else this is
|
||||
* the first initial
|
||||
|
|
@ -2481,12 +2483,14 @@ recv_done(isc_task_t *task, isc_event_t *event) {
|
|||
* be the right one).
|
||||
* In either case,
|
||||
* our next query
|
||||
* should be an NS. */
|
||||
* should be an NS.
|
||||
*/
|
||||
l->rdtype = dns_rdatatype_ns;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We got an answer
|
||||
/*
|
||||
* We got an answer
|
||||
* section for our
|
||||
* NS query! Yay!
|
||||
* Now we shift gears,
|
||||
|
|
@ -2494,7 +2498,8 @@ recv_done(isc_task_t *task, isc_event_t *event) {
|
|||
* and look for SOAs
|
||||
* in all the servers
|
||||
* we got back in our
|
||||
* answer section. */
|
||||
* answer section.
|
||||
*/
|
||||
l->rdtype = dns_rdatatype_soa;
|
||||
l->ns_search_only_leafnode = ISC_TRUE;
|
||||
if (followup_lookup(msg, query,
|
||||
|
|
@ -2507,8 +2512,10 @@ recv_done(isc_task_t *task, isc_event_t *event) {
|
|||
if ((result != ISC_R_SUCCESS) ||
|
||||
l->trace_root)
|
||||
{
|
||||
/* This is executed regardless
|
||||
* of whether we're doing * ns_search_only, but because
|
||||
/*
|
||||
* This is executed regardless
|
||||
* of whether we're doing
|
||||
* ns_search_only, but because
|
||||
* of the way the logic works,
|
||||
* it's mutually exclusive
|
||||
* with the other call to
|
||||
|
|
@ -2523,7 +2530,8 @@ recv_done(isc_task_t *task, isc_event_t *event) {
|
|||
* initial root query) then
|
||||
* we want to take whatever is
|
||||
* in the authority section and
|
||||
* follow up with them. */
|
||||
* follow up with them.
|
||||
*/
|
||||
if (followup_lookup(msg, query,
|
||||
DNS_SECTION_AUTHORITY)
|
||||
== 0)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: host.c,v 1.64 2001/02/13 23:12:16 tamino Exp $ */
|
||||
/* $Id: host.c,v 1.65 2001/02/15 23:44:06 tamino Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -273,10 +273,10 @@ say_message(dns_name_t *name, const char *msg, dns_rdata_t *rdata,
|
|||
check_result(result, "dns_rdata_totext");
|
||||
isc_buffer_usedregion(b2, &r2);
|
||||
if (query->lookup->identify_previous_line) {
|
||||
printf("Nameserver %s:\n",
|
||||
printf("Nameserver %s:\n\t",
|
||||
query->servname);
|
||||
}
|
||||
printf("\t%.*s %s %.*s", (int)r.length, (char *)r.base,
|
||||
printf("%.*s %s %.*s", (int)r.length, (char *)r.base,
|
||||
msg, (int)r2.length, (char *)r2.base);
|
||||
if (query->lookup->identify) {
|
||||
printf(" on server %s", query->servname);
|
||||
|
|
@ -422,9 +422,11 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
|
|||
|
||||
UNUSED(headers);
|
||||
|
||||
/* Special case. If we're doing an ns_search_only query, but we're
|
||||
/*
|
||||
* Special case. If we're doing an ns_search_only query, but we're
|
||||
* still following pointers, haven't gotten to the real NS records
|
||||
* yet, don't print anything. */
|
||||
* yet, don't print anything.
|
||||
*/
|
||||
if (query->lookup->ns_search_only && !query->lookup->ns_search_only_leafnode)
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: dig.h,v 1.65 2001/02/14 01:34:26 gson Exp $ */
|
||||
/* $Id: dig.h,v 1.66 2001/02/15 23:44:08 tamino Exp $ */
|
||||
|
||||
#ifndef DIG_H
|
||||
#define DIG_H
|
||||
|
|
@ -84,8 +84,8 @@ struct dig_lookup {
|
|||
doing_xfr,
|
||||
ns_search_only,
|
||||
ns_search_only_leafnode,
|
||||
identify, /* Append "on <server>" */
|
||||
identify_previous_line, /* Prepend "Nameserver <server>" */
|
||||
identify, /* Append an "on server <foo>" message */
|
||||
identify_previous_line, /* Prepend a "Nameserver <foo>:" message, with newline and tab */
|
||||
ignore,
|
||||
recurse,
|
||||
aaonly,
|
||||
|
|
|
|||
Loading…
Reference in a new issue