2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-03 08:05:21 +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.
*/
/* $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 <stdlib.h>
extern int h_errno;
#include <isc/app.h>
#include <isc/string.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_searchlist_t) search_list;
#define ADD_STRING(b, s) {if (strlen(s) >= \
isc_buffer_availablelength(b)) \
return(ISC_R_NOSPACE); else \
isc_buffer_putstr(b, s);}
#define ADD_STRING(b, s) { \
if (strlen(s) >= isc_buffer_availablelength(b)) \
return (ISC_R_NOSPACE); \
else \
isc_buffer_putstr(b, s); \
}
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_uint16_t bufsize = 0;
isc_boolean_t identify = ISC_FALSE,
trace = ISC_FALSE, ns_search_only = ISC_FALSE,
forcecomment = ISC_FALSE, stats = ISC_TRUE,
comments = ISC_TRUE, 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;
isc_boolean_t
identify = ISC_FALSE,
trace = ISC_FALSE,
ns_search_only = ISC_FALSE,
forcecomment = ISC_FALSE,
stats = ISC_TRUE,
comments = ISC_TRUE,
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[] = {
"QUERY",
@@ -213,7 +221,6 @@ trying(int frmsize, char *frm, dig_lookup_t *lookup) {
UNUSED(frmsize);
UNUSED(frm);
UNUSED(lookup);
}
static isc_result_t
@@ -281,10 +288,8 @@ short_answer(dns_message_t *msg, dns_messagetextflag_t flags,
result = say_message(&rdata, query,
buf);
check_result(result, "say_message");
loopresult = dns_rdataset_next(
rdataset);
loopresult = dns_rdataset_next(rdataset);
}
}
result = dns_message_nextname(msg, DNS_SECTION_ANSWER);
if (result == ISC_R_NOMORE)
@@ -417,8 +422,7 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
goto answer_again;
}
check_result(result, "dns_message_sectiontotext");
}
else {
} else {
result = short_answer(msg, flags, buf, query);
check_result(result, "short_answer");
}
@@ -453,7 +457,9 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
goto additional_again;
}
check_result(result, "dns_message_sectiontotext");
/* Only print the signature on the first record */
/*
* Only print the signature on the first record.
*/
if (headers) {
result = dns_message_pseudosectiontotext(
msg,
@@ -1139,7 +1145,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
exitcode = 10;
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);
bargc = 1;
bargv[bargc] = strtok(batchline, " \t\r\n");

View File

@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: dighost.c,v 1.67 2000/07/03 21:52:13 bwelling Exp $ */
/* $Id: dighost.c,v 1.68 2000/07/05 19:31:24 gson Exp $ */
/*
* Notice to programmers: Do not use this code as an example of how to
@@ -47,6 +47,7 @@ extern int h_errno;
#include <dns/result.h>
#include <dns/tsig.h>
#include <dst/dst.h>
#include <isc/app.h>
#include <isc/base64.h>
#include <isc/entropy.h>
@@ -66,9 +67,15 @@ ISC_LIST(dig_lookup_t) lookup_list;
ISC_LIST(dig_server_t) server_list;
ISC_LIST(dig_searchlist_t) search_list;
isc_boolean_t have_ipv6 = ISC_FALSE, specified_source = ISC_FALSE,
free_now = ISC_FALSE, show_details = ISC_FALSE, usesearch=ISC_FALSE,
qr = ISC_FALSE, is_dst_up = ISC_FALSE;
isc_boolean_t
have_ipv6 = ISC_FALSE,
specified_source = ISC_FALSE,
free_now = ISC_FALSE,
show_details = ISC_FALSE,
usesearch = ISC_FALSE,
qr = ISC_FALSE,
is_dst_up = ISC_FALSE;
in_port_t port = 53;
unsigned int timeout = 5;
isc_mem_t *mctx = NULL;
@@ -108,7 +115,7 @@ count_dots(char *string) {
int i = 0;
s = string;
while (*s != 0) {
while (*s != '\0') {
if (*s == '.')
i++;
s++;
@@ -178,7 +185,8 @@ check_result(isc_result_t result, const char *msg) {
isc_boolean_t
isclass(char *text) {
/* Tests if a field is a class, without needing isc libs
/*
* Tests if a field is a class, without needing isc libs
* initialized. This list will have to be manually kept in
* sync with what the libs support.
*/
@@ -188,14 +196,15 @@ isclass(char *text) {
for (i = 0; i < numclasses; i++)
if (strcasecmp(text, classlist[i]) == 0)
return ISC_TRUE;
return (ISC_TRUE);
return ISC_FALSE;
return (ISC_FALSE);
}
isc_boolean_t
istype(char *text) {
/* Tests if a field is a type, without needing isc libs
/*
* Tests if a field is a type, without needing isc libs
* initialized. This list will have to be manually kept in
* sync with what the libs support.
*/
@@ -214,13 +223,13 @@ istype(char *text) {
for (i = 0; i < numtypes; i++) {
if (strcasecmp(text, typelist[i]) == 0)
return ISC_TRUE;
return (ISC_TRUE);
}
return ISC_FALSE;
return (ISC_FALSE);
}
dig_lookup_t
*requeue_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
dig_lookup_t *
requeue_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
dig_lookup_t *looknew;
dig_server_t *s, *srv;
@@ -232,8 +241,7 @@ dig_lookup_t
lookup_counter++;
if (lookup_counter > LOOKUP_LIMIT)
fatal("Too many lookups.");
looknew = isc_mem_allocate
(mctx, sizeof(struct dig_lookup));
looknew = isc_mem_allocate(mctx, sizeof(struct dig_lookup));
if (looknew == NULL)
fatal("Memory allocation failure in %s:%d",
__FILE__, __LINE__);
@@ -281,8 +289,8 @@ dig_lookup_t
if (looknew->use_my_server_list) {
s = ISC_LIST_HEAD(lookold->my_server_list);
while (s != NULL) {
srv = isc_mem_allocate (mctx, sizeof(struct
dig_server));
srv = isc_mem_allocate(mctx,
sizeof(struct dig_server));
if (srv == NULL)
fatal("Memory allocation failure "
"in %s:%d", __FILE__, __LINE__);
@@ -295,17 +303,12 @@ dig_lookup_t
}
}
debug("Before insertion, init@%p "
"-> %p, new@%p "
"-> %p", lookold,
lookold->link.next,
looknew, looknew->
link.next);
"-> %p, new@%p -> %p",
lookold, lookold->link.next, looknew, looknew->link.next);
ISC_LIST_INSERTAFTER(lookup_list, lookold, looknew, link);
debug("After insertion, init -> "
"%p, new = %p, "
"new -> %p", lookold,
looknew, looknew->
link.next);
"%p, new = %p, new -> %p",
lookold, looknew, looknew->link.next);
return (looknew);
}
@@ -425,7 +428,6 @@ setup_system(void) {
link);
}
}
}
}
fclose(fp);
@@ -462,7 +464,9 @@ setup_system(void) {
secretsize = strlen(keysecret) * 3 / 4;
debug("secretstore");
secretstore = isc_mem_get(mctx, secretsize);
ENSURE (secretstore != NULL);
if (secretstore == NULL)
fatal("Memory allocation failure in %s:%d",
__FILE__, __LINE__);
isc_buffer_init(&secretsrc, keysecret, strlen(keysecret));
isc_buffer_add(&secretsrc, strlen(keysecret));
isc_buffer_init(&secretbuf, secretstore, secretsize);
@@ -766,9 +770,7 @@ followup_lookup(dns_message_t *msg, dig_query_t *query,
my_server_list);
}
srv = isc_mem_allocate(mctx,
sizeof(
struct
dig_server));
sizeof(struct dig_server));
if (srv == NULL)
fatal("Memory allocation "
"failure in %s:%d",
@@ -806,8 +808,10 @@ next_origin(dns_message_t *msg, dig_query_t *query) {
return;
debug("Following up %s", query->lookup->textname);
if (query->lookup->origin == NULL) { /*Then we just did rootorg;
there's nothing left. */
if (query->lookup->origin == NULL) {
/*
* Then we just did rootorg; there's nothing left.
*/
debug("Made it to the root whith nowhere to go.");
return;
}
@@ -915,8 +919,10 @@ setup_lookup(dig_lookup_t *lookup) {
check_result(result, "dns_message_gettempname");
dns_name_init(lookup->name, NULL);
isc_buffer_init(&lookup->namebuf, lookup->namespace, BUFSIZE);
isc_buffer_init(&lookup->onamebuf, lookup->onamespace, BUFSIZE);
isc_buffer_init(&lookup->namebuf, lookup->namespace,
sizeof(lookup->namespace));
isc_buffer_init(&lookup->onamebuf, lookup->onamespace,
sizeof(lookup->onamespace));
if ((count_dots(lookup->textname) >= ndots) || lookup->defname)
lookup->origin = NULL; /* Force root lookup */
@@ -1213,7 +1219,9 @@ send_udp(dig_lookup_t *lookup) {
}
}
/* connect_timeout is used for both UDP recieves and TCP connects. */
/*
* connect_timeout is used for both UDP recieves and TCP connects.
*/
static void
connect_timeout(isc_task_t *task, isc_event_t *event) {
dig_lookup_t *lookup=NULL;
@@ -1532,7 +1540,7 @@ check_for_more_data(dig_query_t *query, dns_message_t *msg,
* now, just continue on...
*/
if (rdata.type != dns_rdatatype_soa)
goto NEXT_RDATA;
goto next_rdata;
/* Now we have an SOA. Work with it. */
debug("Got an SOA");
result = dns_rdata_tostruct(&rdata,
@@ -1550,10 +1558,10 @@ check_for_more_data(dig_query_t *query, dns_message_t *msg,
if (query->lookup->ixfr_serial >=
soa.serial) {
dns_rdata_freestruct(&soa);
goto XFR_DONE;
goto xfr_done;
}
dns_rdata_freestruct(&soa);
goto NEXT_RDATA;
goto next_rdata;
}
if (!query->second_rr_rcvd) {
debug("This is the second. %d",
@@ -1562,7 +1570,7 @@ check_for_more_data(dig_query_t *query, dns_message_t *msg,
query->second_rr_serial =
soa.serial;
dns_rdata_freestruct(&soa);
goto NEXT_RDATA;
goto next_rdata;
}
if (query->second_rr_serial == 0) {
/*
@@ -1572,7 +1580,7 @@ check_for_more_data(dig_query_t *query, dns_message_t *msg,
* AXFR, and we're done.
*/
debug("Done, since axfr.");
XFR_DONE:
xfr_done:
isc_buffer_init(&b, abspace, MXNAME);
result = isc_sockaddr_totext(&sevent->
address,
@@ -1597,16 +1605,16 @@ check_for_more_data(dig_query_t *query, dns_message_t *msg,
query->first_repeat_rcvd =
ISC_TRUE;
dns_rdata_freestruct(&soa);
goto NEXT_RDATA;
goto next_rdata;
}
debug("Done with ixfr");
dns_rdata_freestruct(&soa);
goto XFR_DONE;
goto xfr_done;
}
debug("Meaningless soa, %d",
soa.serial);
dns_rdata_freestruct(&soa);
NEXT_RDATA:
next_rdata:
result = dns_rdataset_next(rdataset);
} while (result == ISC_R_SUCCESS);
}
@@ -1639,8 +1647,7 @@ recv_done(isc_task_t *task, isc_event_t *event) {
}
query = event->ev_arg;
debug("(lookup=%p, query=%p)",
query->lookup, query);
debug("(lookup=%p, query=%p)", query->lookup, query);
if (free_now) {
debug("Bailing out, since freeing now.");
@@ -1826,8 +1833,10 @@ recv_done(isc_task_t *task, isc_event_t *event) {
isc_event_free(&event);
return;
}
/* In truth, we should never get into the CANCELED routine, since
the cancel_lookup() routine clears the pending flag. */
/*
* In truth, we should never get into the CANCELED routine, since
* the cancel_lookup() routine clears the pending flag.
*/
if (sevent->result == ISC_R_CANCELED) {
debug("In cancel handler");
query->working = ISC_FALSE;
@@ -1861,7 +1870,7 @@ get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr) {
#if defined(HAVE_ADDRINFO) && defined(HAVE_GETADDRINFO)
result = getaddrinfo(host, NULL, NULL, &res);
if (result != 0) {
fatal ("Couldn't find server %s. %s",
fatal("Couldn't find server '%s': %s",
host, gai_strerror(result));
}
memcpy(&sockaddr->type.sa,res->ai_addr, res->ai_addrlen);
@@ -1871,7 +1880,7 @@ get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr) {
#else
he = gethostbyname(host);
if (he == NULL)
fatal("Couldn't find server %s. errno=%d",
fatal("Couldn't find server '%s' (h_errno=%d)",
host, h_errno);
INSIST(he->h_addrtype == AF_INET);
isc_sockaddr_fromin(sockaddr,
@@ -2115,6 +2124,7 @@ free_lists(int _exitcode) {
}
debug("Getting ready to exit, code=%d", _exitcode);
if (_exitcode != 0)
exit(_exitcode);
}

View File

@@ -15,23 +15,24 @@
* 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 <stdlib.h>
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/commandline.h>
#include <isc/string.h>
#include <isc/util.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>
extern ISC_LIST(dig_lookup_t) lookup_list;
@@ -53,7 +54,8 @@ extern int lookup_counter;
extern int exitcode;
extern isc_taskmgr_t *taskmgr;
isc_boolean_t short_form = ISC_TRUE,
isc_boolean_t
short_form = ISC_TRUE,
filter = ISC_FALSE,
showallsoa = ISC_FALSE,
tcpmode = ISC_FALSE;
@@ -588,7 +590,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
tcpmode = ISC_TRUE;
break;
case 'C':
debug ("Showing all SOA's");
debug("Showing all SOAs");
if (querytype[0] == 0)
strcpy(querytype, "soa");
if (queryclass[0] == 0)
@@ -611,8 +613,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
}
strncpy(hostname, argv[isc_commandline_index], MXNAME);
if (argc > isc_commandline_index + 1) {
srv = isc_mem_allocate(mctx,
sizeof(struct dig_server));
srv = isc_mem_allocate(mctx, sizeof(struct dig_server));
if (srv == NULL)
fatal("Memory allocation failure.");
strncpy(srv->servername,
@@ -621,8 +622,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
ISC_LIST_APPEND(server_list, srv, link);
}
lookup = isc_mem_allocate (mctx,
sizeof(struct dig_lookup));
lookup = isc_mem_allocate(mctx, sizeof(struct dig_lookup));
if (lookup == NULL)
fatal("Memory allocation failure.");
lookup->pending = ISC_FALSE;
@@ -646,8 +646,9 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
strncat(lookup->textname, "in-addr.arpa.", MXNAME);
if (querytype[0] == 0)
strcpy(querytype, "ptr");
} else
} else {
strncpy(lookup->textname, hostname, MXNAME);
}
if (querytype[0] == 0)
strcpy(querytype, "a");
if (queryclass[0] == 0)

View File

@@ -15,7 +15,7 @@
* 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
#define DIG_H
@@ -39,13 +39,17 @@
#define COMMSIZE 0xffff
#define RESOLVCONF "/etc/resolv.conf"
#define OUTPUTBUF 32767
#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
* in a tight loop of constant lookups. It's value is arbitrary.
*/
#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.
* XXXMWS -- trace mode is currently semi-broken, and this number *MUST*
* be 1.
@@ -153,32 +157,46 @@ struct dig_searchlist {
*/
void
get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr);
void
fatal(const char *format, ...);
void
debug(const char *format, ...);
void
check_result(isc_result_t result, const char *msg);
isc_boolean_t
isclass(char *text);
isc_boolean_t
istype(char *text);
void
setup_lookup(dig_lookup_t *lookup);
void
do_lookup(dig_lookup_t *lookup);
void
start_lookup(void);
void
send_udp(dig_lookup_t *lookup);
int
dhmain(int argc, char **argv);
void
setup_libs(void);
void
setup_system(void);
void
free_lists(int exitcode);
dig_lookup_t *
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
printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers);
void
received(int bytes, int frmsize, char *frm, dig_query_t *query);
void
trying(int frmsize, char *frm, dig_lookup_t *lookup);
void
dighost_shutdown(void);