From 08fc57d1f007c47ff7faf45d3581825892d6a834 Mon Sep 17 00:00:00 2001 From: jmarcus Date: Fri, 8 Feb 2002 16:26:31 +0000 Subject: [PATCH 1/1] Remove cnid_didname_verify.c. It is not needed since didname.db has been changed to a hash. This file may make a reappearance when the analysis of the BTree problems is complete. --- bin/cnid/Makefile.am | 7 -- bin/cnid/cnid_didname_verify.c | 220 --------------------------------- 2 files changed, 227 deletions(-) delete mode 100644 bin/cnid/cnid_didname_verify.c diff --git a/bin/cnid/Makefile.am b/bin/cnid/Makefile.am index 4be6dd12..c318a3b1 100644 --- a/bin/cnid/Makefile.am +++ b/bin/cnid/Makefile.am @@ -2,15 +2,8 @@ EXTRA_DIST = cnid_maint.in -CFLAGS = @CFLAGS@ @DB3_CFLAGS@ -LIBS = @LIBS@ @DB3_LIBS@ - if COMPILE_CNID -bin_PROGRAMS = cnid_didname_verify bin_SCRIPTS = cnid_maint else -bin_PROGRAMS = bin_SCRIPTS = endif - -cnid_didname_verify_SOURCES = cnid_didname_verify.c diff --git a/bin/cnid/cnid_didname_verify.c b/bin/cnid/cnid_didname_verify.c deleted file mode 100644 index 84b8036b..00000000 --- a/bin/cnid/cnid_didname_verify.c +++ /dev/null @@ -1,220 +0,0 @@ -/*- - * See the file LICENSE for redistribution information. - * - * Copyright (c) 1996, 1997, 1998, 1999, 2000 - * Sleepycat Software. All rights reserved. - * - * Modified to check the consistency of didname.db by - * Joe Clarke - * - * $Id: cnid_didname_verify.c,v 1.7 2001-12-16 18:39:34 srittau Exp $ - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif /* HAVE_UNISTD_H */ -#include - -#include - -#include -#include - -#ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif /* ! MIN */ - -#define DBDIDNAME "didname.db" - -int main __P((int, char *[])); -void usage __P((void)); -void version_check __P((void)); - -const char -*progname = "cnid_didname_verify"; /* Program name. */ - -static __inline__ int compare_did(const DBT *a, const DBT *b) { - u_int32_t dida, didb; - - memcpy(&dida, a->data, sizeof(dida)); - memcpy(&didb, b->data, sizeof(didb)); - return dida - didb; -} - -#if DB_VERSION_MINOR > 1 -static int compare_unix(DB *db, const DBT *a, const DBT *b) -#else /* DB_VERSION_MINOR < 1 */ -static int compare_unix(const DBT *a, const DBT *b) -#endif /* DB_VERSION_MINOR */ -{ - u_int8_t *sa, *sb; - int len, ret; - - if ((ret = compare_did(a, b))) - return ret; - - sa = (u_int8_t *) a->data + 4; - sb = (u_int8_t *) b->data + 4; - for (len = MIN(a->size, b->size); len-- > 4; sa++, sb++) - if ((ret = (*sa - *sb))) - return ret; - return a->size - b->size; -} - -int -main(argc, argv) -int argc; -char *argv[]; -{ - extern char *optarg; - extern int optind; - DB *dbp; - DB_ENV *dbenv; - int ch, e_close, exitval, nflag, quiet, ret, t_ret; - char *home; - - version_check(); - - dbenv = NULL; - e_close = exitval = nflag = quiet = 0; - home = NULL; - while ((ch = getopt(argc, argv, "h:NqV")) != EOF) - switch (ch) { - case 'h': - home = optarg; - break; - case 'N': - nflag = 1; - if ((ret = db_env_set_panicstate(0)) != 0) { - fprintf(stderr, - "%s: db_env_set_panicstate: %s\n", - progname, db_strerror(ret)); - exit (1); - } - break; - break; - case 'q': - quiet = 1; - break; - case 'V': - printf("%s\n", db_version(NULL, NULL, NULL)); - exit(0); - case '?': - default: - usage(); - } - argc -= optind; - argv += optind; - - /* - * Create an environment object and initialize it for error - * reporting. - */ - if ((ret = db_env_create(&dbenv, 0)) != 0) { - fprintf(stderr, "%s: db_env_create: %s\n", - progname, db_strerror(ret)); - goto shutdown; - } - e_close = 1; - - /* - * XXX - * We'd prefer to have error output configured while calling - * db_env_create, but there's no way to turn it off once it's - * turned on. - */ - if (!quiet) { - dbenv->set_errfile(dbenv, stderr); - dbenv->set_errpfx(dbenv, progname); - } - -#if DB_VERSION_MINOR > 1 - if (nflag && (ret = dbenv->set_mutexlocks(dbenv, 0)) != 0) { - dbenv->err(dbenv, ret, "set_mutexlocks"); - goto shutdown; - } -#else /* DB_VERSION_MINOR < 1 */ - if (nflag && (ret = db_env_set_mutexlocks(0)) != 0) { - dbenv->err(dbenv, ret, "db_env_set_mutexlocks"); - goto shutdown; - } -#endif /* DB_VERSION_MINOR */ - - /* - * Attach to an mpool if it exists, but if that fails, attach - * to a private region. - */ - if ((ret = dbenv->open(dbenv, - home, DB_INIT_MPOOL | DB_USE_ENVIRON, 0)) != 0 && - (ret = dbenv->open(dbenv, home, - DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE | DB_USE_ENVIRON, 0)) != 0) { - dbenv->err(dbenv, ret, "open"); - goto shutdown; - } - - if ((ret = db_create(&dbp, dbenv, 0)) != 0) { - fprintf(stderr, - "%s: db_create: %s\n", progname, db_strerror(ret)); - goto shutdown; - } - - /* This is the crux of the program. We need to make sure we verify - * using the correct sort routine. Else, the database will report - * corruption. */ - dbp->set_bt_compare(dbp, &compare_unix); - - if (!quiet) { - dbp->set_errfile(dbp, stderr); - dbp->set_errpfx(dbp, progname); - } - if ((ret = dbp->verify(dbp, DBDIDNAME, NULL, NULL, 0)) != 0) - dbp->err(dbp, ret, "DB->verify: %s", DBDIDNAME); - if ((t_ret = dbp->close(dbp, 0)) != 0 && ret == 0) { - dbp->err(dbp, ret, "DB->close: %s", DBDIDNAME); - ret = t_ret; - } - if (ret != 0) - goto shutdown; - - if (0) { -shutdown: exitval = 1; - } - if (e_close && (ret = dbenv->close(dbenv, 0)) != 0) { - exitval = 1; - fprintf(stderr, - "%s: dbenv->close: %s\n", progname, db_strerror(ret)); - } - - return (exitval); -} - -void -usage() -{ - fprintf(stderr, "usage: db_verify [-NqV] [-h home] ...\n"); - exit (1); -} - -void -version_check() -{ - int v_major, v_minor, v_patch; - - /* Make sure we're loaded with the right version of the DB library. */ - (void)db_version(&v_major, &v_minor, &v_patch); - if (v_major != DB_VERSION_MAJOR || - v_minor != DB_VERSION_MINOR || v_patch != DB_VERSION_PATCH) { - fprintf(stderr, - "%s: version %d.%d.%d doesn't match library version %d.%d.%d\n", - progname, DB_VERSION_MAJOR, DB_VERSION_MINOR, - DB_VERSION_PATCH, v_major, v_minor, v_patch); - exit (1); - } -} -- 2.39.2