db_test.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 1999-2001, 2004, 2005, 2007-2009, 2011-2013, 2015, 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id: db_test.c,v 1.70 2011/08/29 23:46:44 tbox Exp $ */
/*! \file
* \author
* Principal Author: Bob Halley
*/
#include <config.h>
#include <stdlib.h>
#include <isc/commandline.h>
#include <dns/dbiterator.h>
#include <dns/fixedname.h>
#include <dns/rdataset.h>
#include <dns/rdatasetiter.h>
#define MAXHOLD 100
#define MAXVERSIONS 100
typedef struct dbinfo {
int rcount;
int hold_count;
int pause_every;
} dbinfo;
static char dbtype[128];
static dns_dbtable_t * dbtable;
static int pause_every = 0;
static void
message = "";
}
static void
char t[1000];
isc_region_t r;
isc_buffer_init(&text, t, sizeof(t));
&text);
isc_buffer_usedregion(&text, &r);
if (result == ISC_R_SUCCESS)
else
}
static void
while (result == ISC_R_SUCCESS) {
}
if (result != ISC_R_NOMORE)
}
static dbinfo *
select_db(char *origintext) {
printf("the cache does not exist\n");
return (cache_dbi);
}
if (result != ISC_R_SUCCESS) {
return (NULL);
}
break;
}
return (dbi);
}
static void
int i;
else
}
if (result == ISC_R_SUCCESS) {
0, NULL);
if (result == ISC_R_SUCCESS)
seekname);
else
}
} else
i = 0;
while (result == ISC_R_SUCCESS) {
break;
&rdsiter);
if (result != ISC_R_SUCCESS) {
break;
}
else
i++;
printf("[more...]\n");
if (result == ISC_R_SUCCESS)
return;
}
}
if (result != ISC_R_NOMORE)
}
static isc_result_t
unsigned int i;
return (ISC_R_NOMEMORY);
for (i = 0; i < MAXVERSIONS; i++)
dbi->hold_count = 0;
for (i = 0; i < MAXHOLD; i++)
if (result != ISC_R_SUCCESS) {
return (result);
}
if (result != ISC_R_SUCCESS) {
return (result);
}
return (result);
}
printf("loaded\n");
if (cache) {
} else {
if (result != ISC_R_SUCCESS) {
return (result);
}
}
return (ISC_R_SUCCESS);
}
static void
unload_all(void) {
else {
}
}
}
printf("You must first select a database with !DB\n"); \
continue; \
}
int
char s[1000];
char b[255];
int ch;
int i, v;
char t1[256];
char t2[256];
const char *origintext;
size_t memory_quota = 0;
dns_trust_t trust = 0;
unsigned int addopts;
size_t n;
!= -1) {
switch (ch) {
case 'c':
if (result != ISC_R_SUCCESS)
printf("cache load(%s) %08x: %s\n",
break;
case 'd':
sizeof(dbtype));
if (n >= sizeof(dbtype)) {
exit(1);
}
break;
case 'g':
break;
case 'l':
NULL) == ISC_R_SUCCESS);
break;
case 'q':
break;
case 'p':
break;
case 'P':
break;
case 'Q':
break;
case 't':
break;
case 'T':
break;
case 'v':
break;
case 'z':
if (origintext == NULL)
else
origintext++; /* Skip '/'. */
if (result != ISC_R_SUCCESS)
printf("zone load(%s) %08x: %s\n",
break;
}
}
if (argc != 0)
printf("ignoring trailing arguments\n");
/*
* Some final initialization...
*/
if (time_lookups) {
}
while (!done) {
if (!quiet)
printf("\n");
continue;
}
len--;
}
printf("open version %d (%p)\n", i,
}
if (strcmp(s, "!R") == 0) {
printf("too many open versions\n");
continue;
}
continue;
} else if (strcmp(s, "!W") == 0) {
printf("using existing future version\n");
continue;
}
if (result != ISC_R_SUCCESS)
else
printf("newversion\n");
continue;
} else if (strcmp(s, "!C") == 0) {
continue;
printf("closing future version\n");
} else {
printf("closing open version %d\n",
i);
break;
}
}
}
continue;
} else if (strcmp(s, "!X") == 0) {
continue;
printf("aborting future version\n");
} else {
printf("closing open version %d\n",
i);
break;
}
}
}
continue;
} else if (strcmp(s, "!A") == 0) {
if (addmode)
else
continue;
} else if (strcmp(s, "!D") == 0) {
if (delmode)
else
continue;
} else if (strcmp(s, "!H") == 0) {
if (holdmode)
else
continue;
} else if (strcmp(s, "!HR") == 0) {
for (i = 0; i < dbi->hold_count; i++)
&dbi->hold_nodes[i]);
dbi->hold_count = 0;
printf("held nodes have been detached\n");
continue;
} else if (strcmp(s, "!VC") == 0) {
printf("switching to current version\n");
continue;
} else if (strstr(s, "!V") == s) {
v = atoi(&s[2]);
printf("unknown open version %d\n", v);
continue;
}
printf("version %d is not open\n", v);
continue;
}
printf("switching to open version %d\n", v);
continue;
} else if (strstr(s, "!TR") == s) {
continue;
} else if (strstr(s, "!T") == s) {
continue;
} else if (strcmp(s, "!G") == 0) {
if ((options & DNS_DBFIND_GLUEOK) != 0)
options &= ~DNS_DBFIND_GLUEOK;
else
printf("glue ok = %s\n",
((options & DNS_DBFIND_GLUEOK) != 0) ?
"TRUE" : "FALSE");
continue;
} else if (strcmp(s, "!GV") == 0) {
if ((options & DNS_DBFIND_VALIDATEGLUE) != 0)
else
printf("validate glue = %s\n",
((options & DNS_DBFIND_VALIDATEGLUE) != 0) ?
"TRUE" : "FALSE");
continue;
} else if (strcmp(s, "!WC") == 0) {
if ((options & DNS_DBFIND_NOWILD) != 0)
options &= ~DNS_DBFIND_NOWILD;
else
printf("wildcard matching = %s\n",
((options & DNS_DBFIND_NOWILD) == 0) ?
"TRUE" : "FALSE");
continue;
} else if (strstr(s, "!LS ") == s) {
continue;
} else if (strcmp(s, "!LS") == 0) {
continue;
} else if (strstr(s, "!DU ") == s) {
if (result != ISC_R_SUCCESS) {
printf("\n");
}
continue;
} else if (strcmp(s, "!PN") == 0) {
if (printnode)
else
printf("printnode = %s\n",
continue;
} else if (strstr(s, "!P") == s) {
v = atoi(&s[2]);
dbi->pause_every = v;
continue;
} else if (strcmp(s, "!+") == 0) {
continue;
} else if (strcmp(s, "!-") == 0) {
continue;
} else if (strcmp(s, "!DB") == 0) {
printf("now searching all databases\n");
continue;
} else {
printf("database not found; "
"now searching all databases\n");
}
continue;
} else if (strcmp(s, "!ZC") == 0) {
if (find_zonecut)
else
printf("find_zonecut = %s\n",
continue;
} else if (strcmp(s, "!NZ") == 0) {
if (noexact_zonecut)
else
printf("noexact_zonecut = %s\n",
continue;
}
isc_buffer_init(&target, b, sizeof(b));
if (result != ISC_R_SUCCESS) {
continue;
}
zcoptions = 0;
if (noexact_zonecut)
&db);
if (result != ISC_R_SUCCESS &&
result != DNS_R_PARTIALMATCH) {
if (!quiet) {
printf("\n");
}
continue;
}
&tb1);
if (result != ISC_R_SUCCESS) {
printf("\n");
dns_db_detach(&db);
continue;
}
printf("\ndatabase = %.*s (%s)\n",
}
if (noexact_zonecut)
&rdataset, &sigrdataset);
} else {
&rdataset, &sigrdataset);
}
if (!quiet) {
printf("\n");
}
switch (result) {
case ISC_R_SUCCESS:
case DNS_R_GLUE:
case DNS_R_CNAME:
case DNS_R_ZONECUT:
break;
case DNS_R_DNAME:
case DNS_R_DELEGATION:
break;
case DNS_R_NXRRSET:
break;
if (holdmode) {
MAXHOLD);
node;
} else
} else {
dns_db_detach(&db);
}
continue;
case DNS_R_NXDOMAIN:
break;
/* FALLTHROUGH */
default:
dns_db_detach(&db);
if (quiet)
continue;
}
if (result != ISC_R_SUCCESS) {
dns_db_detach(&db);
continue;
}
if (result != ISC_R_SUCCESS) {
dns_db_detach(&db);
continue;
}
printf("found %.*s as %.*s\n",
}
if (printnode)
&rdsiter);
if (result == ISC_R_SUCCESS) {
if (!quiet)
} else
} else {
if (!quiet)
if (dns_rdataset_isassociated(&sigrdataset)) {
if (!quiet)
}
if (dns_db_iszone(db))
else
addopts = 0;
0, &rdataset,
if (result != ISC_R_SUCCESS)
if (printnode)
0);
if (result != ISC_R_SUCCESS)
if (printnode)
}
}
if (holdmode) {
} else
} else {
dns_db_detach(&db);
}
}
if (time_lookups) {
printf("elapsed time: %lu.%06lu seconds\n",
(unsigned long)(usec / 1000000),
(unsigned long)(usec % 1000000));
}
unload_all();
if (!quiet)
return (0);
}