db_test.c revision 40f53fa8d9c6a4fc38c0014495e7a42b08f52481
/*
* Copyright (C) 1999, 2000 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.
*/
/* $Id: db_test.c,v 1.53 2000/08/01 01:12:40 tale Exp $ */
/*
* 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
len = 0;
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);
}
NULL);
if (result != ISC_R_SUCCESS) {
return (NULL);
}
break;
}
return (dbi);
}
static void
int i;
else
}
&dbi->dbiterator);
if (result == ISC_R_SUCCESS) {
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++)
NULL);
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS) {
return (result);
}
if (result != ISC_R_SUCCESS) {
return (result);
}
printf("loaded\n");
if (cache) {
} else {
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];
char *origintext;
size_t memory_quota = 0;
dns_trust_t trust = 0;
unsigned int addopts;
!= -1) {
switch (ch) {
case 'c':
if (result != ISC_R_SUCCESS)
printf("cache load(%s) %08x: %s\n",
break;
case 'd':
break;
case 'g':
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) {
(void)isc_time_now(&start);
}
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) {
(void)isc_time_now(&finish);
printf("elapsed time: %lu.%06lu seconds\n",
(unsigned long)(usec / 1000000),
(unsigned long)(usec % 1000000));
}
unload_all();
if (!quiet)
return (0);
}