* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: dig.c,v 1.51.2.9 2000/10/06 19:08:01 mws Exp $ */
+/* $Id: dig.c,v 1.51.2.10 2000/10/20 21:54:08 gson Exp $ */
#include <config.h>
#include <stdlib.h>
extern isc_uint32_t name_limit;
extern isc_uint32_t rr_limit;
-extern isc_boolean_t debugging, show_packets;
+extern isc_boolean_t debugging, memdebugging;
char *batchname = NULL;
FILE *batchfp = NULL;
char *argv0;
isc_boolean_t short_form = ISC_FALSE, printcmd = ISC_TRUE,
- nibble = ISC_FALSE;
+ nibble = ISC_FALSE, plusquest = ISC_FALSE, pluscomm = ISC_FALSE;
isc_uint16_t bufsize = 0;
isc_boolean_t forcecomment = ISC_FALSE;
check_result(result, "isc_buffer_allocate");
if (query->lookup->comments && !short_form) {
- if (!query->lookup->doing_xfr) {
- if (query->lookup->cmdline[0] != 0)
- printf ("; %s\n",query->lookup->cmdline);
- if (msg == query->lookup->sendmsg)
- printf(";; Sending:\n");
- else
- printf(";; Got answer:\n");
- }
+ if (query->lookup->cmdline[0] != 0)
+ printf("; %s\n", query->lookup->cmdline);
+ if (msg == query->lookup->sendmsg)
+ printf(";; Sending:\n");
+ else
+ printf(";; Got answer:\n");
if (headers) {
printf(";; ->>HEADER<<- opcode: %s, status: %s, "
cmd += 2;
state = ISC_FALSE;
}
- switch (tolower(cmd[0])) {
+ switch (cmd[0]) {
case 'a':
- switch (tolower(cmd[1])) {
+ switch (cmd[1]) {
case 'a': /* aaflag */
lookup->aaonly = state;
break;
case 'd':
- switch (tolower(cmd[2])) {
+ switch (cmd[2]) {
case 'd': /* additional */
lookup->section_additional = state;
break;
lookup->udpsize = COMMSIZE;
break;
case 'c':
- switch (tolower(cmd[1])) {
+ switch (cmd[1]) {
case 'd':/* cdflag */
lookup->cdflag = state;
break;
break;
case 'o': /* comments */
lookup->comments = state;
+ if (lookup == default_lookup)
+ pluscomm = state;
break;
default:
goto invalid_option;
}
break;
case 'd':
- switch (tolower(cmd[1])) {
+ switch (cmd[1]) {
case 'e':
lookup->defname = state;
break;
lookup->servfail_stops = state;
break;
case 'i':
- switch (tolower(cmd[1])) {
+ switch (cmd[1]) {
case 'd': /* identify */
lookup->identify = state;
break;
}
break;
case 'n':
- switch (tolower(cmd[1])) {
+ switch (cmd[1]) {
case 'a': /* namelimit */
if (value == NULL)
goto need_value;
}
break;
case 'q':
- switch (tolower(cmd[1])) {
+ switch (cmd[1]) {
case 'r': /* qr */
qr = state;
break;
case 'u': /* question */
lookup->section_question = state;
+ if (lookup == default_lookup)
+ plusquest = state;
break;
default:
goto invalid_option;
}
break;
case 'r':
- switch (tolower(cmd[1])) {
+ switch (cmd[1]) {
case 'e': /* recurse */
lookup->recurse = state;
break;
}
break;
case 's':
- switch (tolower(cmd[1])) {
+ switch (cmd[1]) {
case 'e': /* search */
usesearch = state;
break;
}
break;
case 't':
- switch (tolower(cmd[1])) {
+ switch (cmd[1]) {
case 'c': /* tcp */
if (!is_batchfile)
lookup->tcp_mode = state;
timeout = 1;
break;
case 'r':
- switch (tolower(cmd[2])) {
+ switch (cmd[2]) {
case 'a': /* trace */
lookup->trace = state;
lookup->trace_root = state;
value_from_next = ISC_TRUE;
value = next;
}
- switch (tolower(cmd)) {
+ switch (cmd) {
case 'd':
debugging = ISC_TRUE;
return (ISC_FALSE);
show_usage();
exit(0);
break;
- case 'm':
- isc_mem_debugging = ISC_TRUE;
+ case 'm': /* memdebug */
+ /* memdebug is handled in preparse_args() */
return (ISC_FALSE);
case 'n':
nibble = ISC_TRUE;
return (ISC_FALSE);
- case 'w':
- show_packets = ISC_TRUE;
- return (ISC_FALSE);
-
}
if (value == NULL)
goto invalid_option;
- switch (tolower(cmd)) {
+ switch (cmd) {
case 'b':
get_address(value, 0, &bind_address);
specified_source = ISC_TRUE;
(*lookup)->rdtype = dns_rdatatype_ixfr;
(*lookup)->ixfr_serial =
atoi(&value[5]);
+ (*lookup)->section_question = plusquest;
+ (*lookup)->comments = pluscomm;
return (value_from_next);
}
tr.base = value;
tr.length = strlen(value);
result = dns_rdatatype_fromtext(&rdtype,
(isc_textregion_t *)&tr);
- if (result == ISC_R_SUCCESS)
+ if (result == ISC_R_SUCCESS) {
(*lookup)->rdtype = rdtype;
- else
+ if (rdtype == dns_rdatatype_axfr) {
+ (*lookup)->section_question = plusquest;
+ (*lookup)->comments = pluscomm;
+ }
+ } else
fprintf(stderr, ";; Warning, ignoring "
"invalid type %s\n",
value);
return (ISC_FALSE);
}
+/*
+ * Because we may be trying to do memory allocation recording, we're going
+ * to need to parse the arguments for the -m *before* we start the main
+ * argument parsing routine.
+ * I'd prefer not to have to do this, but I am not quite sure how else to
+ * fix the problem. Argument parsing in dig involves memory allocation
+ * by its nature, so it can't be done in the main argument parser.
+ */
+static void
+preparse_args(int argc, char **argv) {
+ int rc;
+ char **rv;
+
+ rc = argc;
+ rv = argv;
+ for (rc--, rv++; rc > 0; rc--, rv++) {
+ if (strcmp(rv[0], "-m") == 0) {
+ memdebugging = ISC_TRUE;
+ isc_mem_debugging = ISC_TRUE;
+ return;
+ }
+ }
+}
+
static void
parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only,
int argc, char **argv) {
isc_boolean_t open_type_class = ISC_TRUE;
char batchline[MXNAME];
int bargc;
- char *bargv[16];
+ char *bargv[64];
int rc;
char **rv;
#ifndef NOPOSIX
char *homedir;
- char rcfile[132];
+ char rcfile[256];
#endif
char *input;
*/
homedir = getenv("HOME");
if (homedir != NULL)
- snprintf(rcfile, 132, "%s/.digrc", homedir);
+ snprintf(rcfile, sizeof(rcfile), "%s/.digrc", homedir);
else
strcpy(rcfile, ".digrc");
batchfp = fopen(rcfile, "r");
input = batchline;
bargv[bargc] = next_token(&input, " \t\r\n");
while ((bargv[bargc] != NULL) &&
- (bargc < 14)) {
+ (bargc < 62)) {
bargc++;
bargv[bargc] = next_token(&input, " \t\r\n");
}
lookup->rdtype = dns_rdatatype_ixfr;
lookup->ixfr_serial =
atoi(&rv[0][5]);
+ lookup->section_question = plusquest;
+ lookup->comments = pluscomm;
continue;
}
result = dns_rdatatype_fromtext(&rdtype,
(isc_textregion_t *)&tr);
if ((result == ISC_R_SUCCESS) &&
(rdtype != dns_rdatatype_ixfr)) {
+ if (rdtype == dns_rdatatype_axfr) {
+ lookup->section_question =
+ plusquest;
+ lookup->comments = pluscomm;
+ }
lookup->rdtype = rdtype;
continue;
}
ISC_LIST_INIT(search_list);
debug("main()");
+ preparse_args(argc, argv);
progname = argv[0];
result = isc_app_start();
check_result(result, "isc_app_start");
(dig_server_t *)s2, link);
isc_mem_free(mctx, s2);
}
- if (isc_mem_debugging != 0)
- isc_mem_stats(mctx, stderr);
isc_mem_free(mctx, default_lookup);
if (batchname != NULL) {
if (batchfp != stdin)
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: dighost.c,v 1.58.2.12 2000/10/06 19:08:03 mws Exp $ */
+/* $Id: dighost.c,v 1.58.2.13 2000/10/20 21:54:09 gson Exp $ */
/*
* Notice to programmers: Do not use this code as an example of how to
extern int h_errno;
#endif
+#include <dns/fixedname.h>
#include <dns/message.h>
#include <dns/name.h>
#include <dns/rdata.h>
#include <dns/rdatatype.h>
#include <dns/result.h>
#include <dns/tsig.h>
+
#include <dst/dst.h>
#include <isc/app.h>
qr = ISC_FALSE,
is_dst_up = ISC_FALSE,
have_domain = ISC_FALSE,
- is_blocking =ISC_FALSE,
- show_packets = ISC_FALSE;
+ is_blocking =ISC_FALSE;
in_port_t port = 53;
unsigned int timeout = 0;
isc_entropy_t *entp = NULL;
isc_mempool_t *commctx = NULL;
isc_boolean_t debugging = ISC_FALSE;
+isc_boolean_t memdebugging = ISC_FALSE;
char *progname = NULL;
isc_mutex_t lookup_lock;
dig_lookup_t *current_lookup = NULL;
printf("%d bytes\n", r.length);
for (len = 0; len < r.length; len++) {
printf("%02x ", r.base[len]);
- if (len != 0 && len % 16 == 0)
+ if (len % 16 == 15)
printf("\n");
}
if (len % 16 != 0)
UNUSED(task);
INSIST(!free_now);
- if (show_packets)
- puts(";; begin of DNS packet");
debug("recv_done()");
LOCK_LOOKUP;
query);
}
} else {
- if (query->first_soa_rcvd &&
- l->doing_xfr)
- printmessage(query, msg, ISC_FALSE);
- else
- printmessage(query, msg, ISC_TRUE);
+ printmessage(query, msg, ISC_TRUE);
}
} else if ((dns_message_firstname(msg, DNS_SECTION_ANSWER)
== ISC_R_SUCCESS) &&
UNLOCK_LOOKUP;
DESTROYLOCK(&lookup_lock);
- if (isc_mem_debugging != 0)
+ if (memdebugging != 0)
isc_mem_stats(mctx, stderr);
if (mctx != NULL)
isc_mem_destroy(&mctx);