2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-04 08:35:31 +00:00

lots of style changes; no functional change

This commit is contained in:
Andreas Gustafsson
2000-07-05 19:31:26 +00:00
parent 5618f70327
commit 24139527f3
4 changed files with 414 additions and 376 deletions

View File

@@ -15,13 +15,11 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: dig.c,v 1.54 2000/06/30 14:11:45 mws Exp $ */ /* $Id: dig.c,v 1.55 2000/07/05 19:31:22 gson Exp $ */
#include <config.h> #include <config.h>
#include <stdlib.h> #include <stdlib.h>
extern int h_errno;
#include <isc/app.h> #include <isc/app.h>
#include <isc/string.h> #include <isc/string.h>
#include <isc/util.h> #include <isc/util.h>
@@ -39,10 +37,12 @@ extern ISC_LIST(dig_lookup_t) lookup_list;
extern ISC_LIST(dig_server_t) server_list; extern ISC_LIST(dig_server_t) server_list;
extern ISC_LIST(dig_searchlist_t) search_list; extern ISC_LIST(dig_searchlist_t) search_list;
#define ADD_STRING(b, s) {if (strlen(s) >= \ #define ADD_STRING(b, s) { \
isc_buffer_availablelength(b)) \ if (strlen(s) >= isc_buffer_availablelength(b)) \
return(ISC_R_NOSPACE); else \ return (ISC_R_NOSPACE); \
isc_buffer_putstr(b, s);} else \
isc_buffer_putstr(b, s); \
}
extern isc_boolean_t have_ipv6, show_details, specified_source, extern isc_boolean_t have_ipv6, show_details, specified_source,
@@ -72,15 +72,23 @@ extern isc_boolean_t isc_mem_debugging;
isc_boolean_t short_form = ISC_FALSE, printcmd = ISC_TRUE; isc_boolean_t short_form = ISC_FALSE, printcmd = ISC_TRUE;
isc_uint16_t bufsize = 0; isc_uint16_t bufsize = 0;
isc_boolean_t identify = ISC_FALSE, isc_boolean_t
trace = ISC_FALSE, ns_search_only = ISC_FALSE, identify = ISC_FALSE,
forcecomment = ISC_FALSE, stats = ISC_TRUE, trace = ISC_FALSE,
comments = ISC_TRUE, section_question = ISC_TRUE, ns_search_only = ISC_FALSE,
section_answer = ISC_TRUE, section_authority = ISC_TRUE, forcecomment = ISC_FALSE,
section_additional = ISC_TRUE, recurse = ISC_TRUE, stats = ISC_TRUE,
defname = ISC_TRUE, aaonly = ISC_FALSE, tcpmode = ISC_FALSE, comments = ISC_TRUE,
adflag = ISC_FALSE, cdflag = ISC_FALSE; section_question = ISC_TRUE,
section_answer = ISC_TRUE,
section_authority = ISC_TRUE,
section_additional = ISC_TRUE,
recurse = ISC_TRUE,
defname = ISC_TRUE,
aaonly = ISC_FALSE,
tcpmode = ISC_FALSE,
adflag = ISC_FALSE,
cdflag = ISC_FALSE;
static const char *opcodetext[] = { static const char *opcodetext[] = {
"QUERY", "QUERY",
@@ -123,7 +131,7 @@ static const char *rcodetext[] = {
static void static void
show_usage(void) { show_usage(void) {
fputs ( fputs(
"Usage: dig [@global-server] [domain] [q-type] [q-class] {q-opt}\n" "Usage: dig [@global-server] [domain] [q-type] [q-class] {q-opt}\n"
" {global-d-opt} host [@local-server] {local-d-opt}\n" " {global-d-opt} host [@local-server] {local-d-opt}\n"
" [ host [@local-server] {local-d-opt} [...]]\n" " [ host [@local-server] {local-d-opt} [...]]\n"
@@ -183,24 +191,24 @@ received(int bytes, int frmsize, char *frm, dig_query_t *query) {
time_t tnow; time_t tnow;
result = isc_time_now(&now); result = isc_time_now(&now);
check_result (result, "isc_time_now"); check_result(result, "isc_time_now");
if (query->lookup->stats) { if (query->lookup->stats) {
diff = isc_time_microdiff(&now, &query->time_sent); diff = isc_time_microdiff(&now, &query->time_sent);
printf(";; Query time: %ld msec\n", (long int)diff/1000); printf(";; Query time: %ld msec\n", (long int)diff/1000);
printf(";; SERVER: %.*s\n", frmsize, frm); printf(";; SERVER: %.*s\n", frmsize, frm);
time (&tnow); time(&tnow);
printf(";; WHEN: %s", ctime(&tnow)); printf(";; WHEN: %s", ctime(&tnow));
printf (";; MSG SIZE rcvd: %d\n", bytes); printf(";; MSG SIZE rcvd: %d\n", bytes);
if (key != NULL) { if (key != NULL) {
if (!validated) if (!validated)
puts (";; WARNING -- Some TSIG could not " puts(";; WARNING -- Some TSIG could not "
"be validated"); "be validated");
} }
if ((key == NULL) && (keysecret[0] != 0)) { if ((key == NULL) && (keysecret[0] != 0)) {
puts (";; WARNING -- TSIG key was not used."); puts(";; WARNING -- TSIG key was not used.");
} }
puts (""); puts("");
} else if (query->lookup->identify && !short_form) { } else if (query->lookup->identify && !short_form) {
diff = isc_time_microdiff(&now, &query->time_sent); diff = isc_time_microdiff(&now, &query->time_sent);
printf(";; Received %u bytes from %.*s in %d ms\n", printf(";; Received %u bytes from %.*s in %d ms\n",
@@ -210,10 +218,9 @@ received(int bytes, int frmsize, char *frm, dig_query_t *query) {
void void
trying(int frmsize, char *frm, dig_lookup_t *lookup) { trying(int frmsize, char *frm, dig_lookup_t *lookup) {
UNUSED (frmsize); UNUSED(frmsize);
UNUSED (frm); UNUSED(frm);
UNUSED (lookup); UNUSED(lookup);
} }
static isc_result_t static isc_result_t
@@ -238,10 +245,10 @@ say_message(dns_rdata_t *rdata, dig_query_t *query, isc_buffer_t *buf) {
diff = isc_time_microdiff(&now, &query->time_sent); diff = isc_time_microdiff(&now, &query->time_sent);
ADD_STRING(buf, " from server "); ADD_STRING(buf, " from server ");
ADD_STRING(buf, query->servname); ADD_STRING(buf, query->servname);
snprintf (store, 19, " in %d ms.", (int)diff/1000); snprintf(store, 19, " in %d ms.", (int)diff/1000);
ADD_STRING(buf, store); ADD_STRING(buf, store);
} }
ADD_STRING(buf,"\n"); ADD_STRING(buf, "\n");
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} }
@@ -257,7 +264,7 @@ short_answer(dns_message_t *msg, dns_messagetextflag_t flags,
char t[4096]; char t[4096];
dns_rdata_t rdata; dns_rdata_t rdata;
UNUSED (flags); UNUSED(flags);
dns_name_init(&empty_name, NULL); dns_name_init(&empty_name, NULL);
result = dns_message_firstname(msg, DNS_SECTION_ANSWER); result = dns_message_firstname(msg, DNS_SECTION_ANSWER);
@@ -280,11 +287,9 @@ short_answer(dns_message_t *msg, dns_messagetextflag_t flags,
dns_rdataset_current(rdataset, &rdata); dns_rdataset_current(rdataset, &rdata);
result = say_message(&rdata, query, result = say_message(&rdata, query,
buf); buf);
check_result (result, "say_message"); check_result(result, "say_message");
loopresult = dns_rdataset_next( loopresult = dns_rdataset_next(rdataset);
rdataset);
} }
} }
result = dns_message_nextname(msg, DNS_SECTION_ANSWER); result = dns_message_nextname(msg, DNS_SECTION_ANSWER);
if (result == ISC_R_NOMORE) if (result == ISC_R_NOMORE)
@@ -305,9 +310,9 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
isc_buffer_t *buf = NULL; isc_buffer_t *buf = NULL;
unsigned int len = OUTPUTBUF; unsigned int len = OUTPUTBUF;
UNUSED (query); UNUSED(query);
debug ("printmessage(%s)",headers?"headers":"noheaders"); debug("printmessage(%s)", headers ? "headers" : "noheaders");
/* /*
* Exitcode 9 means we timed out, but if we're printing a message, * Exitcode 9 means we timed out, but if we're printing a message,
@@ -328,14 +333,14 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
result = ISC_R_SUCCESS; result = ISC_R_SUCCESS;
result = isc_buffer_allocate(mctx, &buf, len); result = isc_buffer_allocate(mctx, &buf, len);
check_result (result, "isc_buffer_allocate"); check_result(result, "isc_buffer_allocate");
if (query->lookup->comments && !short_form) { if (query->lookup->comments && !short_form) {
if (!query->lookup->doing_xfr) { if (!query->lookup->doing_xfr) {
if (msg == query->lookup->sendmsg) if (msg == query->lookup->sendmsg)
printf (";; Sending:\n"); printf(";; Sending:\n");
else else
printf (";; Got answer:\n"); printf(";; Got answer:\n");
} }
if (headers) { if (headers) {
@@ -389,7 +394,7 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
if (query->lookup->section_question && headers) { if (query->lookup->section_question && headers) {
if (!short_form) { if (!short_form) {
question_again: question_again:
result = dns_message_sectiontotext(msg, result = dns_message_sectiontotext(msg,
DNS_SECTION_QUESTION, DNS_SECTION_QUESTION,
flags, buf); flags, buf);
@@ -405,7 +410,7 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
} }
if (query->lookup->section_answer) { if (query->lookup->section_answer) {
if (!short_form) { if (!short_form) {
answer_again: answer_again:
result = dns_message_sectiontotext(msg, result = dns_message_sectiontotext(msg,
DNS_SECTION_ANSWER, DNS_SECTION_ANSWER,
flags, buf); flags, buf);
@@ -417,15 +422,14 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
goto answer_again; goto answer_again;
} }
check_result(result, "dns_message_sectiontotext"); check_result(result, "dns_message_sectiontotext");
} } else {
else {
result = short_answer(msg, flags, buf, query); result = short_answer(msg, flags, buf, query);
check_result (result, "short_answer"); check_result(result, "short_answer");
} }
} }
if (query->lookup->section_authority) { if (query->lookup->section_authority) {
if (!short_form) { if (!short_form) {
authority_again: authority_again:
result = dns_message_sectiontotext(msg, result = dns_message_sectiontotext(msg,
DNS_SECTION_AUTHORITY, DNS_SECTION_AUTHORITY,
flags, buf); flags, buf);
@@ -441,7 +445,7 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
} }
if (query->lookup->section_additional) { if (query->lookup->section_additional) {
if (!short_form) { if (!short_form) {
additional_again: additional_again:
result = dns_message_sectiontotext(msg, result = dns_message_sectiontotext(msg,
DNS_SECTION_ADDITIONAL, DNS_SECTION_ADDITIONAL,
flags, buf); flags, buf);
@@ -453,7 +457,9 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
goto additional_again; goto additional_again;
} }
check_result(result, "dns_message_sectiontotext"); check_result(result, "dns_message_sectiontotext");
/* Only print the signature on the first record */ /*
* Only print the signature on the first record.
*/
if (headers) { if (headers) {
result = dns_message_pseudosectiontotext( result = dns_message_pseudosectiontotext(
msg, msg,
@@ -474,8 +480,8 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
if (headers && query->lookup->comments && !short_form) if (headers && query->lookup->comments && !short_form)
printf("\n"); printf("\n");
printf ("%.*s",(int)isc_buffer_usedlength(buf), printf("%.*s", (int)isc_buffer_usedlength(buf),
(char *)isc_buffer_base(buf)); (char *)isc_buffer_base(buf));
isc_buffer_free(&buf); isc_buffer_free(&buf);
return (result); return (result);
} }
@@ -485,15 +491,15 @@ printgreeting(int argc, char **argv) {
int i = 1; int i = 1;
if (printcmd) { if (printcmd) {
puts (""); puts("");
printf ("; <<>> DiG 9.0 <<>>"); printf("; <<>> DiG 9.0 <<>>");
while (i < argc) { while (i < argc) {
printf (" %s", argv[i++]); printf(" %s", argv[i++]);
} }
puts (""); puts("");
printf (";; global options: %s %s\n", printf(";; global options: %s %s\n",
short_form?"short_form":"", short_form ? "short_form" : "",
printcmd?"printcmd":""); printcmd ? "printcmd" : "");
} }
} }
@@ -508,24 +514,24 @@ reorder_args(int argc, char *argv[]) {
char *ptr; char *ptr;
int end; int end;
debug ("reorder_args()"); debug("reorder_args()");
end = argc-1; end = argc - 1;
while (argv[end][0] == '@') { while (argv[end][0] == '@') {
end--; end--;
if (end == 0) if (end == 0)
return; return;
} }
debug ("arg[end]=%s",argv[end]); debug("arg[end]=%s", argv[end]);
for (i = 1; i<end-1; i++) { for (i = 1; i < end - 1; i++) {
if (argv[i][0] == '@') { if (argv[i][0] == '@') {
debug ("Arg[%d]=%s", i, argv[i]); debug("Arg[%d]=%s", i, argv[i]);
ptr = argv[i]; ptr = argv[i];
for (j = i+1; j<end; j++) { for (j = i + 1; j < end; j++) {
debug ("Moving %s to %d", argv[j], j-1); debug("Moving %s to %d", argv[j], j - 1);
argv[j-1] = argv[j]; argv[j - 1] = argv[j];
} }
debug ("Moving %s to end, %d", ptr, end-1); debug("Moving %s to end, %d", ptr, end - 1);
argv[end-1] = ptr; argv[end - 1] = ptr;
end--; end--;
if (end < 1) if (end < 1)
return; return;
@@ -567,7 +573,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
rc = argc; rc = argc;
rv = argv; rv = argv;
for (rc--, rv++; rc > 0; rc--, rv++) { for (rc--, rv++; rc > 0; rc--, rv++) {
debug ("Main parsing %s", rv[0]); debug("Main parsing %s", rv[0]);
if (strncmp(rv[0], "%", 1) == 0) if (strncmp(rv[0], "%", 1) == 0)
break; break;
if (strncmp(rv[0], "@", 1) == 0) { if (strncmp(rv[0], "@", 1) == 0) {
@@ -578,8 +584,8 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
strncpy(srv->servername, &rv[0][1], MXNAME-1); strncpy(srv->servername, &rv[0][1], MXNAME-1);
if (is_batchfile && have_host) { if (is_batchfile && have_host) {
if (!lookup->use_my_server_list) { if (!lookup->use_my_server_list) {
ISC_LIST_INIT (lookup-> ISC_LIST_INIT(lookup->
my_server_list); my_server_list);
lookup->use_my_server_list = lookup->use_my_server_list =
ISC_TRUE; ISC_TRUE;
} }
@@ -614,7 +620,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
tcpmode = ISC_FALSE; tcpmode = ISC_FALSE;
} else if (strncmp(rv[0], "+domain=", 8) == 0) { } else if (strncmp(rv[0], "+domain=", 8) == 0) {
/* Global option always */ /* Global option always */
strncpy (fixeddomain, &rv[0][8], MXNAME); strncpy(fixeddomain, &rv[0][8], MXNAME);
} else if (strncmp(rv[0], "+sea", 4) == 0) { } else if (strncmp(rv[0], "+sea", 4) == 0) {
/* Global option always */ /* Global option always */
usesearch = ISC_TRUE; usesearch = ISC_TRUE;
@@ -961,13 +967,13 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
ptr = strtok(ptr,":"); ptr = strtok(ptr,":");
if (ptr == NULL) { if (ptr == NULL) {
show_usage(); show_usage();
exit (exitcode); exit(exitcode);
} }
strncpy(keynametext, ptr, MXNAME); strncpy(keynametext, ptr, MXNAME);
ptr = strtok(NULL, ""); ptr = strtok(NULL, "");
if (ptr == NULL) { if (ptr == NULL) {
show_usage(); show_usage();
exit (exitcode); exit(exitcode);
} }
strncpy(keysecret, ptr, MXNAME); strncpy(keysecret, ptr, MXNAME);
} else if (strncmp(rv[0], "-p", 2) == 0) { } else if (strncmp(rv[0], "-p", 2) == 0) {
@@ -992,20 +998,20 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
specified_source = ISC_TRUE; specified_source = ISC_TRUE;
} else if (strncmp(rv[0], "-h", 2) == 0) { } else if (strncmp(rv[0], "-h", 2) == 0) {
show_usage(); show_usage();
exit (exitcode); exit(exitcode);
} else if (strcmp(rv[0], "-memdebug") == 0) { } else if (strcmp(rv[0], "-memdebug") == 0) {
isc_mem_debugging = 1; isc_mem_debugging = 1;
} else if (strcmp(rv[0], "-debug") == 0) { } else if (strcmp(rv[0], "-debug") == 0) {
debugging = ISC_TRUE; debugging = ISC_TRUE;
} else if (strncmp(rv[0], "-x", 2) == 0) { } else if (strncmp(rv[0], "-x", 2) == 0) {
/* /*
*XXXMWS Only works for ipv4 now. * XXXMWS Only works for ipv4 now.
* Can't use inet_pton here, since we allow * Can't use inet_pton here, since we allow
* partial addresses. * partial addresses.
*/ */
if (rc == 1) { if (rc == 1) {
show_usage(); show_usage();
exit (exitcode); exit(exitcode);
} }
n = sscanf(rv[1], "%d.%d.%d.%d", &adrs[0], &adrs[1], n = sscanf(rv[1], "%d.%d.%d.%d", &adrs[0], &adrs[1],
&adrs[2], &adrs[3]); &adrs[2], &adrs[3]);
@@ -1068,7 +1074,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
} else { } else {
if (have_host) { if (have_host) {
ENSURE(lookup != NULL); ENSURE(lookup != NULL);
if (strncmp(rv[0],"ixfr=",5) == 0) { if (strncmp(rv[0], "ixfr=", 5) == 0) {
strcpy(lookup->rttext, "ixfr"); strcpy(lookup->rttext, "ixfr");
lookup->ixfr_serial = lookup->ixfr_serial =
atoi(&rv[0][5]); atoi(&rv[0][5]);
@@ -1139,8 +1145,8 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
exitcode = 10; exitcode = 10;
fatal("Couldn't open specified batch file."); fatal("Couldn't open specified batch file.");
} }
while (fgets(batchline, MXNAME, fp) != 0) { while (fgets(batchline, sizeof(batchline), fp) != 0) {
debug ("Batch line %s", batchline); debug("Batch line %s", batchline);
bargc = 1; bargc = 1;
bargv[bargc] = strtok(batchline, " \t\r\n"); bargv[bargc] = strtok(batchline, " \t\r\n");
while ((bargv[bargc] != NULL) && (bargc < 14 )) { while ((bargv[bargc] != NULL) && (bargc < 14 )) {
@@ -1208,7 +1214,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
ISC_LIST_APPEND(lookup_list, lookup, link); ISC_LIST_APPEND(lookup_list, lookup, link);
} }
if (!is_batchfile) if (!is_batchfile)
printgreeting (argc, argv); printgreeting(argc, argv);
} }
int int
@@ -1217,7 +1223,7 @@ main(int argc, char **argv) {
ISC_LIST_INIT(server_list); ISC_LIST_INIT(server_list);
ISC_LIST_INIT(search_list); ISC_LIST_INIT(search_list);
debug ("dhmain()"); debug("dhmain()");
setup_libs(); setup_libs();
parse_args(ISC_FALSE, argc, argv); parse_args(ISC_FALSE, argc, argv);
setup_system(); setup_system();

File diff suppressed because it is too large Load Diff

View File

@@ -15,23 +15,24 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: host.c,v 1.33 2000/07/03 05:10:14 marka Exp $ */ /* $Id: host.c,v 1.34 2000/07/05 19:31:25 gson Exp $ */
#include <config.h> #include <config.h>
#include <stdlib.h> #include <stdlib.h>
extern int h_errno; extern int h_errno;
#include <dns/message.h>
#include <dns/name.h>
#include <dns/rdata.h>
#include <dns/rdataset.h>
#include <isc/app.h> #include <isc/app.h>
#include <isc/commandline.h> #include <isc/commandline.h>
#include <isc/string.h> #include <isc/string.h>
#include <isc/util.h> #include <isc/util.h>
#include <isc/task.h> #include <isc/task.h>
#include <dns/message.h>
#include <dns/name.h>
#include <dns/rdata.h>
#include <dns/rdataset.h>
#include <dig/dig.h> #include <dig/dig.h>
extern ISC_LIST(dig_lookup_t) lookup_list; extern ISC_LIST(dig_lookup_t) lookup_list;
@@ -53,7 +54,8 @@ extern int lookup_counter;
extern int exitcode; extern int exitcode;
extern isc_taskmgr_t *taskmgr; extern isc_taskmgr_t *taskmgr;
isc_boolean_t short_form = ISC_TRUE, isc_boolean_t
short_form = ISC_TRUE,
filter = ISC_FALSE, filter = ISC_FALSE,
showallsoa = ISC_FALSE, showallsoa = ISC_FALSE,
tcpmode = ISC_FALSE; tcpmode = ISC_FALSE;
@@ -205,7 +207,7 @@ static const char *rtypetext[] = {
static void static void
show_usage(void) { show_usage(void) {
fputs ( fputs(
"Usage: host [-aCdlrTwv] [-c class] [-N ndots] [-t type] [-W time]\n" "Usage: host [-aCdlrTwv] [-c class] [-N ndots] [-t type] [-W time]\n"
" [-R number] hostname [server]\n" " [-R number] hostname [server]\n"
" -a is equivalent to -v -t *\n" " -a is equivalent to -v -t *\n"
@@ -221,7 +223,7 @@ show_usage(void) {
" -v enables verbose output\n" " -v enables verbose output\n"
" -w specifies to wait forever for a reply\n" " -w specifies to wait forever for a reply\n"
" -W specifies how long to wait for a reply\n", stderr); " -W specifies how long to wait for a reply\n", stderr);
exit (exitcode); exit(exitcode);
} }
void void
@@ -238,7 +240,7 @@ received(int bytes, int frmsize, char *frm, dig_query_t *query) {
if ((!short_form) || (show_details)) { if ((!short_form) || (show_details)) {
result = isc_time_now(&now); result = isc_time_now(&now);
check_result (result, "isc_time_now"); check_result(result, "isc_time_now");
diff = isc_time_microdiff(&now, &query->time_sent); diff = isc_time_microdiff(&now, &query->time_sent);
printf("Received %u bytes from %.*s in %d ms\n", printf("Received %u bytes from %.*s in %d ms\n",
bytes, frmsize, frm, diff/1000); bytes, frmsize, frm, diff/1000);
@@ -247,7 +249,7 @@ received(int bytes, int frmsize, char *frm, dig_query_t *query) {
void void
trying(int frmsize, char *frm, dig_lookup_t *lookup) { trying(int frmsize, char *frm, dig_lookup_t *lookup) {
UNUSED (lookup); UNUSED(lookup);
if (!short_form) if (!short_form)
printf ("Trying \"%.*s\"\n", frmsize, frm); printf ("Trying \"%.*s\"\n", frmsize, frm);
@@ -262,9 +264,9 @@ say_message(dns_name_t *name, const char *msg, dns_rdata_t *rdata,
isc_result_t result; isc_result_t result;
result = isc_buffer_allocate(mctx, &b, BUFSIZE); result = isc_buffer_allocate(mctx, &b, BUFSIZE);
check_result (result, "isc_buffer_allocate"); check_result(result, "isc_buffer_allocate");
result = isc_buffer_allocate(mctx, &b2, BUFSIZE); result = isc_buffer_allocate(mctx, &b2, BUFSIZE);
check_result (result, "isc_buffer_allocate"); check_result(result, "isc_buffer_allocate");
result = dns_name_totext(name, ISC_FALSE, b); result = dns_name_totext(name, ISC_FALSE, b);
check_result(result, "dns_name_totext"); check_result(result, "dns_name_totext");
isc_buffer_usedregion(b, &r); isc_buffer_usedregion(b, &r);
@@ -414,7 +416,7 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
isc_buffer_t *b = NULL; isc_buffer_t *b = NULL;
isc_region_t r; isc_region_t r;
UNUSED (headers); UNUSED(headers);
/* /*
* Exitcode 9 means we timed out, but if we're printing a message, * Exitcode 9 means we timed out, but if we're printing a message,
@@ -426,15 +428,15 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
if (msg->rcode != 0) { if (msg->rcode != 0) {
result = isc_buffer_allocate(mctx, &b, MXNAME); result = isc_buffer_allocate(mctx, &b, MXNAME);
check_result (result, "isc_buffer_allocate"); check_result(result, "isc_buffer_allocate");
result = dns_name_totext(query->lookup->name, ISC_FALSE, result = dns_name_totext(query->lookup->name, ISC_FALSE,
b); b);
check_result (result, "dns_name_totext"); check_result(result, "dns_name_totext");
isc_buffer_usedregion (b, &r); isc_buffer_usedregion(b, &r);
printf ("Host %.*s not found: %d(%s)\n", printf("Host %.*s not found: %d(%s)\n",
(int)r.length, (char *)r.base, (int)r.length, (char *)r.base,
msg->rcode, rcodetext[msg->rcode]); msg->rcode, rcodetext[msg->rcode]);
isc_buffer_free (&b); isc_buffer_free(&b);
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} }
if (!short_form) { if (!short_form) {
@@ -487,7 +489,7 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
printf(";; PSEUDOSECTIONS: TSIG\n"); printf(";; PSEUDOSECTIONS: TSIG\n");
} }
if (! ISC_LIST_EMPTY(msg->sections[DNS_SECTION_QUESTION]) && if (! ISC_LIST_EMPTY(msg->sections[DNS_SECTION_QUESTION]) &&
!short_form ) { !short_form) {
printf("\n"); printf("\n");
result = printsection(msg, DNS_SECTION_QUESTION, "QUESTION", result = printsection(msg, DNS_SECTION_QUESTION, "QUESTION",
ISC_TRUE, query); ISC_TRUE, query);
@@ -503,7 +505,7 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
return (result); return (result);
} }
if (! ISC_LIST_EMPTY(msg->sections[DNS_SECTION_AUTHORITY]) && if (! ISC_LIST_EMPTY(msg->sections[DNS_SECTION_AUTHORITY]) &&
!short_form ) { !short_form) {
printf("\n"); printf("\n");
result = printsection(msg, DNS_SECTION_AUTHORITY, "AUTHORITY", result = printsection(msg, DNS_SECTION_AUTHORITY, "AUTHORITY",
ISC_TRUE, query); ISC_TRUE, query);
@@ -511,7 +513,7 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
return (result); return (result);
} }
if (! ISC_LIST_EMPTY(msg->sections[DNS_SECTION_ADDITIONAL]) && if (! ISC_LIST_EMPTY(msg->sections[DNS_SECTION_ADDITIONAL]) &&
!short_form ) { !short_form) {
printf("\n"); printf("\n");
result = printsection(msg, DNS_SECTION_ADDITIONAL, result = printsection(msg, DNS_SECTION_ADDITIONAL,
"ADDITIONAL", ISC_TRUE, query); "ADDITIONAL", ISC_TRUE, query);
@@ -588,17 +590,17 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
tcpmode = ISC_TRUE; tcpmode = ISC_TRUE;
break; break;
case 'C': case 'C':
debug ("Showing all SOA's"); debug("Showing all SOAs");
if (querytype[0] == 0) if (querytype[0] == 0)
strcpy (querytype, "soa"); strcpy(querytype, "soa");
if (queryclass[0] == 0) if (queryclass[0] == 0)
strcpy (queryclass, "in"); strcpy(queryclass, "in");
showallsoa = ISC_TRUE; showallsoa = ISC_TRUE;
show_details = ISC_TRUE; show_details = ISC_TRUE;
break; break;
case 'N': case 'N':
debug ("Setting NDOTS to %s", debug("Setting NDOTS to %s",
isc_commandline_argument); isc_commandline_argument);
ndots = atoi(isc_commandline_argument); ndots = atoi(isc_commandline_argument);
break; break;
case 'D': case 'D':
@@ -609,22 +611,20 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
if (isc_commandline_index >= argc) { if (isc_commandline_index >= argc) {
show_usage(); show_usage();
} }
strncpy (hostname, argv[isc_commandline_index], MXNAME); strncpy(hostname, argv[isc_commandline_index], MXNAME);
if (argc > isc_commandline_index+1) { if (argc > isc_commandline_index + 1) {
srv = isc_mem_allocate(mctx, srv = isc_mem_allocate(mctx, sizeof(struct dig_server));
sizeof(struct dig_server)); if (srv == NULL)
if (srv == NULL) fatal("Memory allocation failure.");
fatal ("Memory allocation failure."); strncpy(srv->servername,
strncpy(srv->servername, argv[isc_commandline_index+1], MXNAME-1);
argv[isc_commandline_index+1], MXNAME-1); debug("Server is %s", srv->servername);
debug("Server is %s", srv->servername); ISC_LIST_APPEND(server_list, srv, link);
ISC_LIST_APPEND(server_list, srv, link);
} }
lookup = isc_mem_allocate (mctx, lookup = isc_mem_allocate(mctx, sizeof(struct dig_lookup));
sizeof(struct dig_lookup));
if (lookup == NULL) if (lookup == NULL)
fatal ("Memory allocation failure."); fatal("Memory allocation failure.");
lookup->pending = ISC_FALSE; lookup->pending = ISC_FALSE;
/* /*
* XXXMWS Add IPv6 translation here, probably using inet_pton * XXXMWS Add IPv6 translation here, probably using inet_pton
@@ -636,7 +636,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
&adrs[2], &adrs[3]); &adrs[2], &adrs[3]);
if (n == 0) { if (n == 0) {
show_usage(); show_usage();
exit (exitcode); exit(exitcode);
} }
for (i = n - 1; i >= 0; i--) { for (i = n - 1; i >= 0; i--) {
snprintf(store, MXNAME/8, "%d.", snprintf(store, MXNAME/8, "%d.",
@@ -645,15 +645,16 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
} }
strncat(lookup->textname, "in-addr.arpa.", MXNAME); strncat(lookup->textname, "in-addr.arpa.", MXNAME);
if (querytype[0] == 0) if (querytype[0] == 0)
strcpy (querytype, "ptr"); strcpy(querytype, "ptr");
} else } else {
strncpy (lookup->textname, hostname, MXNAME); strncpy(lookup->textname, hostname, MXNAME);
}
if (querytype[0] == 0) if (querytype[0] == 0)
strcpy (querytype, "a"); strcpy(querytype, "a");
if (queryclass[0] == 0) if (queryclass[0] == 0)
strcpy (queryclass, "in"); strcpy(queryclass, "in");
strncpy (lookup->rttext, querytype, 32); strncpy(lookup->rttext, querytype, 32);
strncpy (lookup->rctext, queryclass, 32); strncpy(lookup->rctext, queryclass, 32);
lookup->namespace[0] = 0; lookup->namespace[0] = 0;
lookup->sendspace[0] = 0; lookup->sendspace[0] = 0;
lookup->sendmsg = NULL; lookup->sendmsg = NULL;
@@ -692,14 +693,14 @@ main(int argc, char **argv) {
ISC_LIST_INIT(server_list); ISC_LIST_INIT(server_list);
ISC_LIST_INIT(search_list); ISC_LIST_INIT(search_list);
debug ("dhmain()"); debug("dhmain()");
setup_libs(); setup_libs();
parse_args(ISC_FALSE, argc, argv); parse_args(ISC_FALSE, argc, argv);
setup_system(); setup_system();
start_lookup(); start_lookup();
isc_app_run(); isc_app_run();
if (taskmgr != NULL) { if (taskmgr != NULL) {
debug ("Freeing taskmgr"); debug("Freeing taskmgr");
isc_taskmgr_destroy(&taskmgr); isc_taskmgr_destroy(&taskmgr);
} }
if (isc_mem_debugging) if (isc_mem_debugging)

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: dig.h,v 1.26 2000/07/03 05:26:50 marka Exp $ */ /* $Id: dig.h,v 1.27 2000/07/05 19:31:26 gson Exp $ */
#ifndef DIG_H #ifndef DIG_H
#define DIG_H #define DIG_H
@@ -39,13 +39,17 @@
#define COMMSIZE 0xffff #define COMMSIZE 0xffff
#define RESOLVCONF "/etc/resolv.conf" #define RESOLVCONF "/etc/resolv.conf"
#define OUTPUTBUF 32767 #define OUTPUTBUF 32767
#define LOOKUP_LIMIT 64 #define LOOKUP_LIMIT 64
/* Lookup_limit is just a limiter, keeping too many lookups from being /*
* Lookup_limit is just a limiter, keeping too many lookups from being
* created. It's job is mainly to prevent the program from running away * created. It's job is mainly to prevent the program from running away
* in a tight loop of constant lookups. It's value is arbitrary. * in a tight loop of constant lookups. It's value is arbitrary.
*/ */
#define ROOTNS 1 #define ROOTNS 1
/* Set the number of root servers to ask for information when running in /*
* Set the number of root servers to ask for information when running in
* trace mode. * trace mode.
* XXXMWS -- trace mode is currently semi-broken, and this number *MUST* * XXXMWS -- trace mode is currently semi-broken, and this number *MUST*
* be 1. * be 1.
@@ -153,32 +157,46 @@ struct dig_searchlist {
*/ */
void void
get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr); get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr);
void void
fatal(const char *format, ...); fatal(const char *format, ...);
void void
debug(const char *format, ...); debug(const char *format, ...);
void void
check_result(isc_result_t result, const char *msg); check_result(isc_result_t result, const char *msg);
isc_boolean_t isc_boolean_t
isclass(char *text); isclass(char *text);
isc_boolean_t isc_boolean_t
istype(char *text); istype(char *text);
void void
setup_lookup(dig_lookup_t *lookup); setup_lookup(dig_lookup_t *lookup);
void void
do_lookup(dig_lookup_t *lookup); do_lookup(dig_lookup_t *lookup);
void void
start_lookup (void); start_lookup(void);
void void
send_udp(dig_lookup_t *lookup); send_udp(dig_lookup_t *lookup);
int int
dhmain(int argc, char **argv); dhmain(int argc, char **argv);
void void
setup_libs(void); setup_libs(void);
void void
setup_system(void); setup_system(void);
void void
free_lists(int exitcode); free_lists(int exitcode);
dig_lookup_t * dig_lookup_t *
requeue_lookup(dig_lookup_t *lookold, isc_boolean_t servers); requeue_lookup(dig_lookup_t *lookold, isc_boolean_t servers);
@@ -188,10 +206,13 @@ requeue_lookup(dig_lookup_t *lookold, isc_boolean_t servers);
*/ */
isc_result_t isc_result_t
printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers); printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers);
void void
received(int bytes, int frmsize, char *frm, dig_query_t *query); received(int bytes, int frmsize, char *frm, dig_query_t *query);
void void
trying(int frmsize, char *frm, dig_lookup_t *lookup); trying(int frmsize, char *frm, dig_lookup_t *lookup);
void void
dighost_shutdown(void); dighost_shutdown(void);