mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 13:38:26 +00:00
use dns_rbt_findname instead of dns_rbt_findnode, and adjust tests for
possible return values.
This commit is contained in:
parent
587fc7b519
commit
ec40d2ec68
@ -108,11 +108,11 @@ print_data(void *data) {
|
|||||||
void
|
void
|
||||||
main (int argc, char **argv) {
|
main (int argc, char **argv) {
|
||||||
char *command, *arg, *whitespace, buffer[1024];
|
char *command, *arg, *whitespace, buffer[1024];
|
||||||
int length;
|
|
||||||
dns_name_t *name;
|
dns_name_t *name;
|
||||||
dns_rbt_t *rbt;
|
dns_rbt_t *rbt;
|
||||||
dns_rbtnode_t *node;
|
int length;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
void *data;
|
||||||
|
|
||||||
progname = strrchr(*argv, '/');
|
progname = strrchr(*argv, '/');
|
||||||
if (progname != NULL)
|
if (progname != NULL)
|
||||||
@ -197,15 +197,30 @@ main (int argc, char **argv) {
|
|||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
printf("searching for name %s ... ",
|
printf("searching for name %s ... ",
|
||||||
arg);
|
arg);
|
||||||
node = dns_rbt_findnode(rbt, name,
|
data = NULL;
|
||||||
NULL);
|
result = dns_rbt_findname(rbt, name,
|
||||||
if (node != NULL) {
|
&data);
|
||||||
printf("found it: ");
|
switch (result) {
|
||||||
print_data(node->data);
|
case DNS_R_SUCCESS:
|
||||||
|
printf("found exact: ");
|
||||||
|
print_data(data);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
|
break;
|
||||||
} else
|
case DNS_R_PARTIALMATCH:
|
||||||
|
printf("found parent: ");
|
||||||
|
print_data(data);
|
||||||
|
putchar('\n');
|
||||||
|
break;
|
||||||
|
case DNS_R_NOTFOUND:
|
||||||
printf("NOT FOUND!\n");
|
printf("NOT FOUND!\n");
|
||||||
|
break;
|
||||||
|
case DNS_R_NOMEMORY:
|
||||||
|
printf("OUT OF MEMORY!\n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf("UNEXPECTED RESULT\n");
|
||||||
|
}
|
||||||
|
|
||||||
delete_name(name, NULL);
|
delete_name(name, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +238,7 @@ main (int argc, char **argv) {
|
|||||||
printf("usage: quit\n");
|
printf("usage: quit\n");
|
||||||
} else {
|
} else {
|
||||||
printf("a(dd) NAME, d(elete) NAME, "
|
printf("a(dd) NAME, d(elete) NAME, "
|
||||||
"s(earch) NAME, print, or quit\n");
|
"s(earch) NAME, p(rint), or q(uit)\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user