Commit e535faec authored by Bob Halley's avatar Bob Halley
Browse files

add db_test

parent 1ccbfca6
......@@ -11,3 +11,4 @@ wire_test
rdata_test
master_test
rbt_test
db_test
......@@ -24,7 +24,8 @@ TARGETS = lex_test \
rdata_test \
rwlock_test \
wire_test \
master_test
master_test \
db_test
@BIND9_MAKE_RULES@
......@@ -61,5 +62,8 @@ wire_test: wire_test.o ../../lib/isc/libisc.a ../../lib/dns/libdns.a
master_test: master_test.o ../../lib/isc/libisc.a ../../lib/dns/libdns.a
${CC} -o $@ master_test.o ${LIBS}
db_test: db_test.o ../../lib/isc/libisc.a ../../lib/dns/libdns.a
${CC} -o $@ db_test.o ${LIBS}
clean distclean::
rm -f ${TARGETS}
/*
* 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 <stddef.h>
#include <isc/assertions.h>
#include <isc/error.h>
#include <isc/boolean.h>
#include <isc/region.h>
#include <dns/types.h>
#include <dns/result.h>
#include <dns/name.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
#include <dns/rdatatype.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/compress.h>
#include <dns/db.h>
int
main(int argc, char *argv[]) {
isc_mem_t *mctx = NULL;
dns_db_t *db;
dns_dbnode_t *node;
dns_result_t result;
dns_name_t name, *origin;
dns_offsets_t offsets;
isc_buffer_t source, target;
size_t len;
char s[1000];
char b[256];
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
db = NULL;
result = dns_db_create(mctx, "rbt", ISC_FALSE, 1, 0, NULL,
&db);
RUNTIME_CHECK(result == DNS_R_SUCCESS);
origin = dns_rootname;
dns_name_init(&name, offsets);
while (gets(s) != NULL) {
len = strlen(s);
isc_buffer_init(&source, s, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_add(&source, len);
isc_buffer_init(&target, b, 255, ISC_BUFFERTYPE_BINARY);
result = dns_name_fromtext(&name, &source, origin, ISC_FALSE,
&target);
RUNTIME_CHECK(result == DNS_R_SUCCESS);
node = NULL;
result = dns_db_findnode(db, &name, ISC_TRUE, &node);
RUNTIME_CHECK(result == DNS_R_SUCCESS);
/* dns_db_detachnode(db, &node); */
}
dns_db_detach(&db);
isc_mem_stats(mctx, stdout);
return (0);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment