rbt_test.c revision 1adfd0a9119434de35e1a6b6ddc65b28dd608308
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* 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>
#include <unistd.h>
#include <dns/fixedname.h>
char *progname;
#define DNSNAMELEN 255
static dns_name_t *
create_name(char *s) {
int length;
static dns_name_t *name;
if (s == NULL || *s == '\0') {
printf("missing name argument\n");
return (NULL);
}
/*
* It isn't really necessary in this program to create individual
* memory spaces for each name structure and its associate character
* string. It is done in this program 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.
*
* The buffer for the actual name will immediately follow the
* name structure.
*/
printf("out of memory!\n");
return (NULL);
}
if (result != DNS_R_SUCCESS) {
printf("dns_name_fromtext(%s) failed: %s\n",
s, dns_result_totext(result));
return (NULL);
}
return (name);
}
static void
(void)arg;
}
static void
char *buffer[256];
/*
* ISC_FALSE means absolute names have the final dot added.
*/
}
static void
dns_name_t *origin);
if (forward) {
printf("iterating forward\n" );
} else {
printf("iterating backward\n" );
}
printf("start not found!\n");
else {
while (1) {
if (result == DNS_R_NEWORIGIN) {
printf(" new origin: ");
printf("\n");
}
if (result == DNS_R_SUCCESS ||
result == DNS_R_NEWORIGIN) {
printf("\n");
} else {
if (result != DNS_R_NOMORE)
printf("UNEXEPCTED ITERATION ERROR: %s",
break;
}
}
}
}
#define PRINTERR(r) if (r != DNS_R_SUCCESS) \
void
void *data;
progname++;
else
switch (ch) {
case 'm':
break;
}
}
if (argc > 1) {
exit(1);
}
if (result != ISC_R_SUCCESS) {
printf("isc_mem_create: %s: exiting\n",
exit(1);
}
if (result != DNS_R_SUCCESS) {
printf("dns_rbt_create: %s: exiting\n",
exit(1);
}
whitespace = " \t";
printf("line to long (%d max), ignored\n",
sizeof(buffer) - 2);
continue;
}
*arg++ = '\0';
}
if (*command != '\0') {
if (CMDCHECK("add")) {
}
} else if (CMDCHECK("delete")) {
}
} else if (CMDCHECK("nuke")) {
ISC_TRUE);
}
} else if (CMDCHECK("search")) {
printf("searching for name %s ... ",
arg);
&data);
switch (result) {
case DNS_R_SUCCESS:
printf("found exact: ");
putchar('\n');
break;
case DNS_R_PARTIALMATCH:
printf("found parent: ");
printf("\n\t(foundname: ");
printf(")\n");
break;
case DNS_R_NOTFOUND:
printf("NOT FOUND!\n");
break;
case DNS_R_NOMEMORY:
printf("OUT OF MEMORY!\n");
break;
default:
printf("UNEXPECTED RESULT\n");
}
}
} else if (CMDCHECK("forward")) {
} else if (CMDCHECK("backward")) {
} else if (CMDCHECK("print")) {
else
printf("usage: print\n");
} else if (CMDCHECK("quit")) {
break;
else
printf("usage: quit\n");
} else {
printf("a(dd) NAME, d(elete) NAME, "
"s(earch) NAME, p(rint), or q(uit)\n");
}
}
}
if (show_final_mem)
exit(0);
}