1999-01-26 03:30:25 +00:00
|
|
|
/*
|
2000-02-03 23:08:31 +00:00
|
|
|
* Copyright (C) 1999, 2000 Internet Software Consortium.
|
1999-01-26 03:30:25 +00:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
|
|
|
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
|
|
|
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
|
|
|
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
|
|
|
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
1999-10-06 20:07:25 +00:00
|
|
|
#include <isc/commandline.h>
|
1999-01-31 00:54:14 +00:00
|
|
|
#include <isc/boolean.h>
|
1999-01-26 03:30:25 +00:00
|
|
|
|
|
|
|
#include <dns/rbt.h>
|
1999-03-16 16:27:41 +00:00
|
|
|
#include <dns/fixedname.h>
|
1999-01-26 03:30:25 +00:00
|
|
|
|
|
|
|
char *progname;
|
1999-01-31 16:45:48 +00:00
|
|
|
isc_mem_t *mctx;
|
|
|
|
|
|
|
|
#define DNSNAMELEN 255
|
1999-01-26 03:30:25 +00:00
|
|
|
|
|
|
|
static dns_name_t *
|
|
|
|
create_name(char *s) {
|
|
|
|
int length;
|
|
|
|
isc_result_t result;
|
|
|
|
isc_buffer_t source, target;
|
1999-01-31 16:45:48 +00:00
|
|
|
static dns_name_t *name;
|
1999-01-26 03:30:25 +00:00
|
|
|
|
1999-01-31 16:45:48 +00:00
|
|
|
if (s == NULL || *s == '\0') {
|
|
|
|
printf("missing name argument\n");
|
|
|
|
return (NULL);
|
|
|
|
}
|
1999-01-26 03:30:25 +00:00
|
|
|
|
|
|
|
length = strlen(s);
|
1999-01-31 16:45:48 +00:00
|
|
|
|
1999-01-26 03:30:25 +00:00
|
|
|
isc_buffer_init(&source, s, length, ISC_BUFFERTYPE_TEXT);
|
|
|
|
isc_buffer_add(&source, length);
|
|
|
|
|
1999-01-31 16:45:48 +00:00
|
|
|
/*
|
|
|
|
* It isn't really necessary in this program to create individual
|
2000-04-12 21:33:01 +00:00
|
|
|
* memory spaces for each name structure and its associated character
|
1999-04-16 16:18:01 +00:00
|
|
|
* string. It is done here to provide a relatively easy way to test
|
|
|
|
* the callback from dns_rbt_deletename that is supposed to free the
|
|
|
|
* data associated with a node.
|
1999-01-31 16:45:48 +00:00
|
|
|
*
|
|
|
|
* The buffer for the actual name will immediately follow the
|
|
|
|
* name structure.
|
|
|
|
*/
|
|
|
|
name = isc_mem_get(mctx, sizeof(*name) + DNSNAMELEN);
|
|
|
|
if (name == NULL) {
|
|
|
|
printf("out of memory!\n");
|
|
|
|
return (NULL);
|
|
|
|
}
|
1999-01-26 03:30:25 +00:00
|
|
|
|
1999-01-31 16:45:48 +00:00
|
|
|
dns_name_init(name, NULL);
|
|
|
|
isc_buffer_init(&target, name + 1, DNSNAMELEN, ISC_BUFFERTYPE_BINARY);
|
1999-01-26 03:30:25 +00:00
|
|
|
|
1999-02-11 06:38:12 +00:00
|
|
|
result = dns_name_fromtext(name, &source, dns_rootname,
|
|
|
|
ISC_FALSE, &target);
|
1999-01-26 03:30:25 +00:00
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
1999-01-26 03:30:25 +00:00
|
|
|
printf("dns_name_fromtext(%s) failed: %s\n",
|
|
|
|
s, dns_result_totext(result));
|
1999-01-31 16:45:48 +00:00
|
|
|
return (NULL);
|
1999-01-26 03:30:25 +00:00
|
|
|
}
|
|
|
|
|
1999-01-31 16:45:48 +00:00
|
|
|
return (name);
|
1999-01-26 03:30:25 +00:00
|
|
|
}
|
|
|
|
|
1999-01-31 00:54:14 +00:00
|
|
|
static void
|
1999-02-06 01:28:15 +00:00
|
|
|
delete_name(void *data, void *arg) {
|
1999-01-31 00:54:14 +00:00
|
|
|
dns_name_t *name;
|
|
|
|
|
1999-02-06 01:28:15 +00:00
|
|
|
(void)arg;
|
1999-01-31 00:54:14 +00:00
|
|
|
name = data;
|
1999-01-31 16:45:48 +00:00
|
|
|
isc_mem_put(mctx, data, sizeof(dns_name_t) + DNSNAMELEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-04-09 15:17:57 +00:00
|
|
|
print_name(dns_name_t *name) {
|
1999-01-31 16:45:48 +00:00
|
|
|
isc_buffer_t target;
|
|
|
|
char *buffer[256];
|
|
|
|
|
|
|
|
isc_buffer_init(&target, buffer, sizeof(buffer), ISC_BUFFERTYPE_TEXT);
|
|
|
|
|
1999-03-03 19:55:03 +00:00
|
|
|
/*
|
|
|
|
* ISC_FALSE means absolute names have the final dot added.
|
|
|
|
*/
|
1999-04-09 15:17:57 +00:00
|
|
|
dns_name_totext(name, ISC_FALSE, &target);
|
1999-01-31 16:45:48 +00:00
|
|
|
|
|
|
|
printf("%.*s", (int)target.used, (char *)target.base);
|
1999-01-31 00:54:14 +00:00
|
|
|
}
|
|
|
|
|
1999-04-16 16:18:01 +00:00
|
|
|
static void
|
|
|
|
detail(dns_rbt_t *rbt, dns_name_t *name) {
|
|
|
|
dns_name_t *foundname, *origin, *fullname;
|
|
|
|
dns_fixedname_t fixedfoundname, fixedorigin, fixedfullname;
|
|
|
|
dns_rbtnode_t *node1, *node2;
|
|
|
|
dns_rbtnodechain_t chain;
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t result;
|
1999-04-16 16:18:01 +00:00
|
|
|
isc_boolean_t nodes_should_match = ISC_FALSE;
|
|
|
|
|
|
|
|
dns_rbtnodechain_init(&chain, mctx);
|
|
|
|
|
|
|
|
dns_fixedname_init(&fixedorigin);
|
|
|
|
dns_fixedname_init(&fixedfullname);
|
|
|
|
dns_fixedname_init(&fixedfoundname);
|
|
|
|
|
|
|
|
origin = dns_fixedname_name(&fixedorigin);
|
|
|
|
fullname = dns_fixedname_name(&fixedfullname);
|
|
|
|
foundname = dns_fixedname_name(&fixedfoundname);
|
|
|
|
|
|
|
|
node1 = node2 = NULL;
|
|
|
|
|
|
|
|
printf("checking chain information for ");
|
|
|
|
print_name(name);
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
result = dns_rbt_findnode(rbt, name, foundname, &node1, &chain,
|
|
|
|
ISC_TRUE, NULL, NULL);
|
|
|
|
|
|
|
|
switch (result) {
|
2000-04-06 22:03:35 +00:00
|
|
|
case ISC_R_SUCCESS:
|
1999-04-16 16:18:01 +00:00
|
|
|
printf(" found exact.");
|
|
|
|
nodes_should_match = ISC_TRUE;
|
|
|
|
break;
|
|
|
|
case DNS_R_PARTIALMATCH:
|
|
|
|
printf(" found parent.");
|
|
|
|
break;
|
2000-04-06 22:03:35 +00:00
|
|
|
case ISC_R_NOTFOUND:
|
1999-04-16 16:18:01 +00:00
|
|
|
printf(" name not found.");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf(" unexpected result: %s\n", dns_result_totext(result));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node1 != NULL && node1->data != NULL) {
|
|
|
|
printf(" data at node: ");
|
|
|
|
print_name(node1->data);
|
|
|
|
} else
|
|
|
|
printf(" no data at node.");
|
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) {
|
1999-04-16 16:18:01 +00:00
|
|
|
printf("\n name from dns_rbt_findnode: ");
|
|
|
|
print_name(foundname);
|
|
|
|
}
|
|
|
|
|
|
|
|
result = dns_rbtnodechain_current(&chain, foundname, origin, &node2);
|
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
1999-04-16 16:18:01 +00:00
|
|
|
printf("\n name from dns_rbtnodechain_current: ");
|
1999-04-23 05:00:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If foundname is absolute, it includes the origin (which
|
|
|
|
* is intrinsically known here to be just ".").
|
|
|
|
*/
|
|
|
|
|
|
|
|
result = dns_name_concatenate(foundname,
|
|
|
|
dns_name_isabsolute(foundname) ?
|
|
|
|
NULL : origin,
|
1999-04-16 16:18:01 +00:00
|
|
|
fullname, NULL);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result == ISC_R_SUCCESS)
|
1999-04-16 16:18:01 +00:00
|
|
|
print_name(fullname);
|
|
|
|
else
|
|
|
|
printf("%s\n", dns_result_totext(result));
|
|
|
|
printf("\n (foundname = ");
|
|
|
|
print_name(foundname);
|
|
|
|
printf(", origin = ");
|
|
|
|
print_name(origin);
|
|
|
|
printf(")\n");
|
|
|
|
if (nodes_should_match && node1 != node2)
|
|
|
|
printf(" nodes returned from each function "
|
|
|
|
"DO NOT match!\n");
|
|
|
|
|
|
|
|
} else
|
|
|
|
printf("\n result from dns_rbtnodechain_current: %s\n",
|
|
|
|
dns_result_totext(result));
|
|
|
|
|
1999-10-12 14:22:31 +00:00
|
|
|
printf(" level_matches = %d, level_count = %d\n",
|
|
|
|
chain.level_matches, chain.level_count);
|
1999-04-16 16:18:01 +00:00
|
|
|
}
|
|
|
|
|
1999-04-09 15:17:57 +00:00
|
|
|
static void
|
1999-04-14 12:03:18 +00:00
|
|
|
iterate(dns_rbt_t *rbt, isc_boolean_t forward) {
|
1999-04-14 14:24:51 +00:00
|
|
|
dns_name_t foundname, *origin;
|
1999-04-09 15:17:57 +00:00
|
|
|
dns_rbtnodechain_t chain;
|
1999-04-14 14:24:51 +00:00
|
|
|
dns_fixedname_t fixedorigin;
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t result;
|
|
|
|
isc_result_t (*move)(dns_rbtnodechain_t *chain, dns_name_t *name,
|
1999-04-09 15:17:57 +00:00
|
|
|
dns_name_t *origin);
|
|
|
|
|
1999-04-14 12:03:18 +00:00
|
|
|
dns_rbtnodechain_init(&chain, mctx);
|
|
|
|
|
1999-04-14 14:24:51 +00:00
|
|
|
dns_name_init(&foundname, NULL);
|
1999-04-14 12:03:18 +00:00
|
|
|
dns_fixedname_init(&fixedorigin);
|
1999-04-14 14:24:51 +00:00
|
|
|
origin = dns_fixedname_name(&fixedorigin);
|
1999-04-14 12:03:18 +00:00
|
|
|
|
1999-04-09 15:17:57 +00:00
|
|
|
if (forward) {
|
|
|
|
printf("iterating forward\n" );
|
|
|
|
move = dns_rbtnodechain_next;
|
|
|
|
|
1999-04-16 16:18:01 +00:00
|
|
|
result = dns_rbtnodechain_first(&chain, rbt, &foundname,
|
|
|
|
origin);
|
1999-04-14 12:03:18 +00:00
|
|
|
|
1999-04-09 15:17:57 +00:00
|
|
|
} else {
|
|
|
|
printf("iterating backward\n" );
|
|
|
|
move = dns_rbtnodechain_prev;
|
|
|
|
|
1999-04-16 16:18:01 +00:00
|
|
|
result = dns_rbtnodechain_last(&chain, rbt, &foundname,
|
|
|
|
origin);
|
1999-04-14 12:03:18 +00:00
|
|
|
}
|
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN)
|
1999-04-09 15:17:57 +00:00
|
|
|
printf("start not found!\n");
|
|
|
|
|
|
|
|
else {
|
|
|
|
while (1) {
|
|
|
|
if (result == DNS_R_NEWORIGIN) {
|
|
|
|
printf(" new origin: ");
|
|
|
|
print_name(origin);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result == ISC_R_SUCCESS ||
|
1999-04-09 15:17:57 +00:00
|
|
|
result == DNS_R_NEWORIGIN) {
|
1999-04-14 14:24:51 +00:00
|
|
|
print_name(&foundname);
|
1999-04-09 15:17:57 +00:00
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
} else {
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_NOMORE)
|
1999-04-09 15:17:57 +00:00
|
|
|
printf("UNEXEPCTED ITERATION ERROR: %s",
|
|
|
|
dns_result_totext(result));
|
|
|
|
break;
|
|
|
|
}
|
1999-04-14 12:03:18 +00:00
|
|
|
|
1999-04-14 14:24:51 +00:00
|
|
|
result = move(&chain, &foundname, origin);
|
1999-04-09 15:17:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-01-26 03:30:25 +00:00
|
|
|
#define CMDCHECK(s) (strncasecmp(command, (s), length) == 0)
|
2000-04-06 22:03:35 +00:00
|
|
|
#define PRINTERR(r) if (r != ISC_R_SUCCESS) \
|
1999-01-31 16:45:48 +00:00
|
|
|
printf("... %s\n", dns_result_totext(r));
|
1999-01-26 03:30:25 +00:00
|
|
|
|
1999-07-03 21:15:06 +00:00
|
|
|
int
|
1999-01-26 03:30:25 +00:00
|
|
|
main (int argc, char **argv) {
|
|
|
|
char *command, *arg, *whitespace, buffer[1024];
|
1999-03-16 16:27:41 +00:00
|
|
|
dns_name_t *name, *foundname;
|
|
|
|
dns_fixedname_t fixedname;
|
1999-01-26 03:30:25 +00:00
|
|
|
dns_rbt_t *rbt;
|
1999-03-11 19:20:34 +00:00
|
|
|
int length, ch;
|
|
|
|
isc_boolean_t show_final_mem = ISC_FALSE;
|
1999-01-26 03:30:25 +00:00
|
|
|
isc_result_t result;
|
1999-03-04 21:04:33 +00:00
|
|
|
void *data;
|
1999-01-26 03:30:25 +00:00
|
|
|
|
|
|
|
progname = strrchr(*argv, '/');
|
|
|
|
if (progname != NULL)
|
|
|
|
progname++;
|
|
|
|
else
|
|
|
|
progname = *argv;
|
|
|
|
|
1999-10-06 20:07:25 +00:00
|
|
|
while ((ch = isc_commandline_parse(argc, argv, "m")) != -1) {
|
1999-03-11 19:20:34 +00:00
|
|
|
switch (ch) {
|
|
|
|
case 'm':
|
|
|
|
show_final_mem = ISC_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-06 20:07:25 +00:00
|
|
|
argc -= isc_commandline_index;
|
|
|
|
argv += isc_commandline_index;
|
1999-03-11 19:20:34 +00:00
|
|
|
|
1999-01-26 03:30:25 +00:00
|
|
|
if (argc > 1) {
|
1999-03-11 19:20:34 +00:00
|
|
|
printf("Usage: %s [-m]\n", progname);
|
1999-01-26 03:30:25 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
setbuf(stdout, NULL);
|
|
|
|
|
1999-01-31 16:45:48 +00:00
|
|
|
result = isc_mem_create(0, 0, &mctx);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
printf("isc_mem_create: %s: exiting\n",
|
|
|
|
dns_result_totext(result));
|
|
|
|
exit(1);
|
|
|
|
}
|
1999-01-26 03:30:25 +00:00
|
|
|
|
1999-02-06 01:28:15 +00:00
|
|
|
result = dns_rbt_create(mctx, delete_name, NULL, &rbt);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
1999-01-26 03:30:25 +00:00
|
|
|
printf("dns_rbt_create: %s: exiting\n",
|
|
|
|
dns_result_totext(result));
|
1999-01-31 16:45:48 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
1999-01-26 03:30:25 +00:00
|
|
|
|
|
|
|
whitespace = " \t";
|
|
|
|
|
|
|
|
while (fgets(buffer, sizeof(buffer), stdin) != NULL) {
|
|
|
|
length = strlen(buffer);
|
|
|
|
|
|
|
|
if (buffer[length - 1] != '\n') {
|
|
|
|
printf("line to long (%d max), ignored\n",
|
|
|
|
sizeof(buffer) - 2);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer[length - 1] = '\0';
|
|
|
|
|
|
|
|
command = buffer + strspn(buffer, whitespace);
|
1999-04-16 16:18:01 +00:00
|
|
|
|
|
|
|
if (*command == '#')
|
|
|
|
continue;
|
|
|
|
|
1999-01-26 03:30:25 +00:00
|
|
|
arg = strpbrk(command, whitespace);
|
|
|
|
if (arg != NULL) {
|
|
|
|
*arg++ = '\0';
|
|
|
|
arg += strspn(arg, whitespace);
|
|
|
|
}
|
|
|
|
|
|
|
|
length = strlen(command);
|
|
|
|
if (*command != '\0') {
|
|
|
|
if (CMDCHECK("add")) {
|
1999-01-31 16:45:48 +00:00
|
|
|
name = create_name(arg);
|
|
|
|
if (name != NULL) {
|
|
|
|
printf("adding name %s\n", arg);
|
|
|
|
result = dns_rbt_addname(rbt,
|
1999-01-26 03:30:25 +00:00
|
|
|
name, name);
|
1999-01-31 16:45:48 +00:00
|
|
|
PRINTERR(result);
|
|
|
|
}
|
1999-01-26 03:30:25 +00:00
|
|
|
|
|
|
|
} else if (CMDCHECK("delete")) {
|
1999-01-31 16:45:48 +00:00
|
|
|
name = create_name(arg);
|
|
|
|
if (name != NULL) {
|
|
|
|
printf("deleting name %s\n", arg);
|
|
|
|
result = dns_rbt_deletename(rbt, name,
|
|
|
|
ISC_FALSE);
|
|
|
|
PRINTERR(result);
|
1999-02-06 01:28:15 +00:00
|
|
|
delete_name(name, NULL);
|
1999-01-31 16:45:48 +00:00
|
|
|
}
|
1999-01-31 00:54:14 +00:00
|
|
|
|
|
|
|
} else if (CMDCHECK("nuke")) {
|
1999-01-31 16:45:48 +00:00
|
|
|
name = create_name(arg);
|
|
|
|
if (name != NULL) {
|
1999-10-16 20:35:19 +00:00
|
|
|
printf("nuking name %s "
|
|
|
|
"and its descendants\n", arg);
|
1999-01-31 16:45:48 +00:00
|
|
|
result = dns_rbt_deletename(rbt, name,
|
|
|
|
ISC_TRUE);
|
|
|
|
PRINTERR(result);
|
1999-02-06 01:28:15 +00:00
|
|
|
delete_name(name, NULL);
|
1999-01-31 16:45:48 +00:00
|
|
|
}
|
1999-01-26 03:30:25 +00:00
|
|
|
|
|
|
|
} else if (CMDCHECK("search")) {
|
1999-01-31 16:45:48 +00:00
|
|
|
name = create_name(arg);
|
|
|
|
if (name != NULL) {
|
|
|
|
printf("searching for name %s ... ",
|
|
|
|
arg);
|
1999-03-16 16:27:41 +00:00
|
|
|
|
|
|
|
dns_fixedname_init(&fixedname);
|
|
|
|
foundname =
|
|
|
|
dns_fixedname_name(&fixedname);
|
1999-03-04 21:04:33 +00:00
|
|
|
data = NULL;
|
1999-03-16 16:27:41 +00:00
|
|
|
|
1999-03-04 21:04:33 +00:00
|
|
|
result = dns_rbt_findname(rbt, name,
|
1999-03-16 16:27:41 +00:00
|
|
|
foundname,
|
1999-03-04 21:04:33 +00:00
|
|
|
&data);
|
|
|
|
switch (result) {
|
2000-04-06 22:03:35 +00:00
|
|
|
case ISC_R_SUCCESS:
|
1999-03-04 21:04:33 +00:00
|
|
|
printf("found exact: ");
|
1999-04-09 15:17:57 +00:00
|
|
|
print_name(data);
|
1999-01-31 16:45:48 +00:00
|
|
|
putchar('\n');
|
1999-03-04 21:04:33 +00:00
|
|
|
break;
|
|
|
|
case DNS_R_PARTIALMATCH:
|
|
|
|
printf("found parent: ");
|
1999-04-09 15:17:57 +00:00
|
|
|
print_name(data);
|
|
|
|
printf("\n\t(foundname: ");
|
|
|
|
print_name(foundname);
|
|
|
|
printf(")\n");
|
1999-03-04 21:04:33 +00:00
|
|
|
break;
|
2000-04-06 22:03:35 +00:00
|
|
|
case ISC_R_NOTFOUND:
|
1999-01-31 16:45:48 +00:00
|
|
|
printf("NOT FOUND!\n");
|
1999-03-04 21:04:33 +00:00
|
|
|
break;
|
2000-04-06 22:03:35 +00:00
|
|
|
case ISC_R_NOMEMORY:
|
1999-03-04 21:04:33 +00:00
|
|
|
printf("OUT OF MEMORY!\n");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("UNEXPECTED RESULT\n");
|
|
|
|
}
|
|
|
|
|
1999-02-06 01:28:15 +00:00
|
|
|
delete_name(name, NULL);
|
1999-01-31 16:45:48 +00:00
|
|
|
}
|
1999-01-26 03:30:25 +00:00
|
|
|
|
1999-04-16 16:18:01 +00:00
|
|
|
} else if (CMDCHECK("check")) {
|
|
|
|
/*
|
|
|
|
* Or "chain". I know, I know. Lame name.
|
|
|
|
* I was having a hard time thinking of a
|
|
|
|
* name (especially one that did not have
|
|
|
|
* a conflicting first letter with another
|
|
|
|
* command) that would differentiate this
|
|
|
|
* from the search command.
|
|
|
|
*
|
|
|
|
* But it is just a test program, eh?
|
|
|
|
*/
|
|
|
|
name = create_name(arg);
|
|
|
|
if (name != NULL) {
|
|
|
|
detail(rbt, name);
|
|
|
|
|
|
|
|
delete_name(name, NULL);
|
|
|
|
}
|
|
|
|
|
1999-04-09 15:17:57 +00:00
|
|
|
} else if (CMDCHECK("forward")) {
|
1999-04-14 12:03:18 +00:00
|
|
|
iterate(rbt, ISC_TRUE);
|
1999-04-09 15:17:57 +00:00
|
|
|
|
|
|
|
} else if (CMDCHECK("backward")) {
|
1999-04-14 12:03:18 +00:00
|
|
|
iterate(rbt, ISC_FALSE);
|
1999-01-26 03:30:25 +00:00
|
|
|
|
|
|
|
} else if (CMDCHECK("print")) {
|
|
|
|
if (arg == NULL || *arg == '\0')
|
|
|
|
dns_rbt_printall(rbt);
|
|
|
|
else
|
|
|
|
printf("usage: print\n");
|
|
|
|
|
|
|
|
} else if (CMDCHECK("quit")) {
|
|
|
|
if (arg == NULL || *arg == '\0')
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
printf("usage: quit\n");
|
|
|
|
} else {
|
|
|
|
printf("a(dd) NAME, d(elete) NAME, "
|
1999-03-04 21:04:33 +00:00
|
|
|
"s(earch) NAME, p(rint), or q(uit)\n");
|
1999-01-26 03:30:25 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
dns_rbt_destroy(&rbt);
|
1999-03-11 19:20:34 +00:00
|
|
|
|
|
|
|
if (show_final_mem)
|
|
|
|
isc_mem_stats(mctx, stderr);
|
|
|
|
|
1999-07-03 21:15:06 +00:00
|
|
|
return (0);
|
1999-01-26 03:30:25 +00:00
|
|
|
}
|