mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 13:38:26 +00:00
allow type and zone to be specified
This commit is contained in:
parent
22c4f0162f
commit
a2f5b51dff
@ -20,6 +20,7 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h> /* XXX Naughty. */
|
||||||
|
|
||||||
#include <isc/assertions.h>
|
#include <isc/assertions.h>
|
||||||
#include <isc/error.h>
|
#include <isc/error.h>
|
||||||
@ -86,23 +87,44 @@ main(int argc, char *argv[]) {
|
|||||||
char b[255];
|
char b[255];
|
||||||
dns_rdataset_t rdataset;
|
dns_rdataset_t rdataset;
|
||||||
isc_region_t r;
|
isc_region_t r;
|
||||||
|
char basetext[1000];
|
||||||
|
int ch;
|
||||||
|
dns_rdatatype_t type = 2;
|
||||||
|
|
||||||
if (argc < 2) {
|
strcpy(basetext, "");
|
||||||
|
while ((ch = getopt(argc, argv, "z:t:")) != -1) {
|
||||||
|
switch (ch) {
|
||||||
|
case 'z':
|
||||||
|
strcpy(basetext, optarg);
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
type = atoi(optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
argc -= optind;
|
||||||
|
argv += optind;
|
||||||
|
|
||||||
|
if (argc < 1) {
|
||||||
fprintf(stderr, "usage: db_test filename\n");
|
fprintf(stderr, "usage: db_test filename\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||||
|
|
||||||
makename(mctx, "vix.com.", &base, NULL);
|
if (strcmp(basetext, "") == 0)
|
||||||
|
strcpy(basetext, "vix.com.");
|
||||||
|
makename(mctx, basetext, &base, NULL);
|
||||||
|
|
||||||
db = NULL;
|
db = NULL;
|
||||||
result = dns_db_create(mctx, "rbt", &base, ISC_FALSE, 1, 0, NULL,
|
result = dns_db_create(mctx, "rbt", &base, ISC_FALSE, 1, 0, NULL,
|
||||||
&db);
|
&db);
|
||||||
RUNTIME_CHECK(result == DNS_R_SUCCESS);
|
RUNTIME_CHECK(result == DNS_R_SUCCESS);
|
||||||
|
|
||||||
origin = dns_rootname;
|
origin = &base;
|
||||||
result = dns_db_load(db, argv[1]);
|
printf("loading %s\n", argv[0]);
|
||||||
|
result = dns_db_load(db, argv[0]);
|
||||||
if (result != DNS_R_SUCCESS) {
|
if (result != DNS_R_SUCCESS) {
|
||||||
printf("couldn't load master file: %s\n",
|
printf("couldn't load master file: %s\n",
|
||||||
dns_result_totext(result));
|
dns_result_totext(result));
|
||||||
@ -130,10 +152,10 @@ main(int argc, char *argv[]) {
|
|||||||
else {
|
else {
|
||||||
printf("success\n");
|
printf("success\n");
|
||||||
dns_rdataset_init(&rdataset);
|
dns_rdataset_init(&rdataset);
|
||||||
result = dns_db_findrdataset(db, node, NULL, 2,
|
result = dns_db_findrdataset(db, node, NULL, type,
|
||||||
&rdataset);
|
&rdataset);
|
||||||
if (result == DNS_R_NOTFOUND)
|
if (result == DNS_R_NOTFOUND)
|
||||||
printf("type 2 rdataset not found\n");
|
printf("type %d rdataset not found\n", type);
|
||||||
else if (result != DNS_R_SUCCESS)
|
else if (result != DNS_R_SUCCESS)
|
||||||
printf("%s\n", dns_result_totext(result));
|
printf("%s\n", dns_result_totext(result));
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user