rbt_test.c revision 4997d113e1b0362e25f0a682bb7c7c7ef03b9440
be755f4725e6579ffe725b3ead9ccfbd108f55ddTinderbox User * Copyright (C) 1999 Internet Software Consortium.
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt * Permission to use, copy, modify, and distribute this software for any
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt * purpose with or without fee is hereby granted, provided that the above
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt * copyright notice and this permission notice appear in all copies.
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt isc_buffer_init(&source, s, length, ISC_BUFFERTYPE_TEXT);
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt * It isn't really necessary in this program to create individual
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt * memory spaces for each name structure and its associate character
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt * string. It is done here to provide a relatively easy way to test
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt * the callback from dns_rbt_deletename that is supposed to free the
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt * data associated with a node.
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt * The buffer for the actual name will immediately follow the
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt * name structure.
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt name = isc_mem_get(mctx, sizeof(*name) + DNSNAMELEN);
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt isc_buffer_init(&target, name + 1, DNSNAMELEN, ISC_BUFFERTYPE_BINARY);
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt result = dns_name_fromtext(name, &source, dns_rootname,
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt isc_mem_put(mctx, data, sizeof(dns_name_t) + DNSNAMELEN);
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt isc_buffer_init(&target, buffer, sizeof(buffer), ISC_BUFFERTYPE_TEXT);
d2a50c9ba87a6c57cb310308dfe95fff2f2836e2Mark Andrews * ISC_FALSE means absolute names have the final dot added.
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt printf("%.*s", (int)target.used, (char *)target.base);
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt dns_fixedname_t fixedfoundname, fixedorigin, fixedfullname;
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt result = dns_rbt_findnode(rbt, name, foundname, &node1, &chain,
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt printf(" unexpected result: %s\n", dns_result_totext(result));
84ee90b52d4fb443c796f4e1481f98d5a95b5614Evan Hunt if (result == DNS_R_SUCCESS || result == DNS_R_PARTIALMATCH) {
if (forward) {
origin);
origin);
void *data;
progname++;
switch (ch) {
ISC_TRUE);
arg);
&data);
switch (result) {
case DNS_R_SUCCESS:
case DNS_R_PARTIALMATCH:
case DNS_R_NOTFOUND:
case DNS_R_NOMEMORY:
if (show_final_mem)
exit(0);