db_test.c revision 732e537cdc91e757165da1088ac812cc7b80ef34
/*
* 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.
*/
/*
* Principal Author: Bob Halley
*/
#include <config.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h> /* XXX Naughty. */
#include <isc/assertions.h>
#include <dns/fixedname.h>
#include <dns/rdataclass.h>
#include <dns/rdatatype.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdatasetiter.h>
#include <dns/compress.h>
#include <dns/dbiterator.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;
&text);
isc_buffer_used(&text, &r);
if (result == DNS_R_SUCCESS)
else
}
static void
while (result == DNS_R_SUCCESS) {
}
if (result != DNS_R_NOMORE)
}
static dbinfo *
select_db(char *origintext) {
printf("the cache does not exist\n");
return (cache_dbi);
}
NULL);
if (result != DNS_R_SUCCESS) {
return (NULL);
}
break;
}
return (dbi);
}
static void
int i;
else
}
&dbi->dbiterator);
if (result == DNS_R_SUCCESS)
} else
i = 0;
while (result == DNS_R_SUCCESS) {
break;
&rdsiter);
if (result != DNS_R_SUCCESS) {
break;
}
i++;
printf("[more...]\n");
if (result == DNS_R_SUCCESS)
return;
}
}
if (result != DNS_R_NOMORE)
}
static isc_result_t
unsigned int i;
return (DNS_R_NOMEMORY);
for (i = 0; i < MAXVERSIONS; i++)
dbi->hold_count = 0;
for (i = 0; i < MAXHOLD; i++)
NULL);
if (result != DNS_R_SUCCESS)
return (result);
if (result != DNS_R_SUCCESS) {
return (result);
}
if (result != DNS_R_SUCCESS) {
return (result);
}
printf("loaded\n");
if (cache) {
} else {
return (result);
}
}
return (DNS_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];
unsigned int options = 0;
char *origintext;
size_t memory_quota = 0;
dns_trust_t trust = 0;
switch (ch) {
case 'c':
if (result != DNS_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)
origintext = optarg;
else
origintext++; /* Skip '/'. */
if (result != DNS_R_SUCCESS)
printf("zone load(%s) %08x: %s\n",
break;
}
}
if (argc != 0)
printf("ignoring trailing arguments\n");
/*
* Some final initialization...
*/
if (time_lookups) {
/* Naughty */
}
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 != DNS_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 (strcmp(s, "!LS") == 0) {
continue;
} else if (strstr(s, "!DU ") == s) {
if (result != DNS_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, "!DB") == 0) {
printf("now searching all databases\n");
continue;
} else {
printf("database not found; "
"now searching all databases\n");
}
continue;
}
if (result != DNS_R_SUCCESS) {
continue;
}
if (result != DNS_R_SUCCESS &&
result != DNS_R_PARTIALMATCH) {
if (!quiet) {
printf("\n");
}
continue;
}
&tb1);
if (result != DNS_R_SUCCESS) {
printf("\n");
dns_db_detach(&db);
continue;
}
printf("\ndatabase = %.*s (%s)\n",
}
if (!quiet) {
printf("\n");
}
switch (result) {
case DNS_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_NXRDATASET:
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 != DNS_R_SUCCESS) {
dns_db_detach(&db);
continue;
}
if (result != DNS_R_SUCCESS) {
dns_db_detach(&db);
continue;
}
printf("found %.*s as %.*s\n",
}
if (printnode)
&rdsiter);
if (result == DNS_R_SUCCESS) {
if (!quiet)
} else
} else {
if (!quiet)
0, &rdataset,
NULL);
if (result != DNS_R_SUCCESS)
if (printnode)
if (result != DNS_R_SUCCESS)
if (printnode)
}
}
if (holdmode) {
} else
} else {
dns_db_detach(&db);
}
}
if (time_lookups) {
/* Naughty */
} else
printf("elapsed time: %lu.%06lu seconds\n",
}
unload_all();
if (!quiet)
return (0);
}