Add ability to switch between Berkeley and DBM for both aname and KDC database
authorPaul Park <pjpark@mit.edu>
Fri, 30 Jun 1995 20:11:46 +0000 (20:11 +0000)
committerPaul Park <pjpark@mit.edu>
Fri, 30 Jun 1995 20:11:46 +0000 (20:11 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6204 dc483132-0cff-0310-8789-dd5450dbe970

src/admin/aname/ChangeLog
src/admin/aname/Makefile.in
src/admin/aname/configure.in
src/admin/aname/kdb5_anadd.c

index fdfbfc1a3ccb5eb9b14101bcbe0b65f7f3bd4926..a8239d450daeec3b4e4903c5d7f7ca2fa13f0626 100644 (file)
@@ -1,4 +1,12 @@
 
+Fri Jun 30 14:28:20 EDT 1995   Paul Park       (pjpark@mit.edu)
+       * kdb5_anadd.c - Add ability to select between Berkeley and DBM format
+               at compile time.
+       * configure.in - Add --with-dbm and --with-aname-dbm and check/set
+               appropriate definitions and libraries.
+       * Makefile.in - Use DBFLAGS set by configure.in.
+
+
 Thu Jun 15 15:22:33 EDT 1995   Paul Park       (pjpark@mit.edu)
        * Makefile.in - Change explicit library names to -l<lib> form, and
                change target link line to use $(LD) and associated flags.
index cb607a9276f296ccfb00f38ef8218c31f272fd84..7e25cbf78b4be6244c9ff0883107c137e8aee9ec 100644 (file)
@@ -1,4 +1,5 @@
-CFLAGS = $(CCOPTS) $(DEFS) $(LOCALINCLUDE)
+DBFLAGS=@DBFLAGS@
+CFLAGS = $(CCOPTS) $(DEFS) $(LOCALINCLUDE) $(DBFLAGS)
 LDFLAGS = -g
 
 COMERRLIB=$(BUILDTOP)/util/et/libcom_err.a
index 630bb2361eefcf898e3cbd3dc9c2d88acda48959..6164b57842797ad00f6fe0d7b389610b72e0aecd 100644 (file)
@@ -1,7 +1,39 @@
 AC_INIT(kdb5_anadd.c)
 CONFIG_RULES
 AC_PROG_INSTALL
-AC_CHECK_LIB(ndbm,main)
-AC_CHECK_LIB(dbm,main)
+AC_ARG_WITH([aname-dbm],
+[  --with-aname-dbm            use native dbm for aname_to_lname database
+  --without-aname-dbm          use included version of Berkeley db (default)],
+,
+withval=no)dnl
+did_dbm_lib=no
+if test "$withval" = yes; then
+       AC_MSG_RESULT(Using native dbm for aname_to_lname database)
+       DBFLAGS=
+       AC_CHECK_LIB(ndbm,main)
+       AC_CHECK_LIB(dbm,main)
+       did_dbm_lib=yes
+else
+       AC_MSG_RESULT(Using Berkeley db for aname_to_lname database)
+       DBFLAGS=-DBERK_DB_DBM
+fi
+AC_SUBST(DBFLAGS)dnl
+dnl
+AC_ARG_WITH([dbm],
+[  --with-dbm          use native dbm for kdc database
+  --without-dbm                use included version of Berkeley db (default)],
+,
+withval=no)dnl
+if test "$withval" = yes; then
+       AC_MSG_RESULT(Using native dbm)
+       if test "$did_dbm_lib" = no; then
+               AC_CHECK_LIB(ndbm,main)
+               AC_CHECK_LIB(dbm,main)
+       fi
+else
+       AC_MSG_RESULT(Using Berkeley db)
+fi
+AC_SUBST(DBFLAGS)dnl
+dnl
 V5_USE_SHARED_LIB
 V5_AC_OUTPUT_MAKEFILE
index 2849abc979150208e9119086d60fc6a9df698074..4a841ecf96cd92d7cd3972027bb811435e03d8c6 100644 (file)
 #include <stdio.h>
 #include <errno.h>
 
+#ifdef BERK_DB_DBM
+/*
+ * Use Berkeley database code.
+ */
+extern DBM     *db_dbm_open PROTOTYPE((char *, int, int));
+extern void     db_dbm_close PROTOTYPE((DBM *));
+extern int      db_dbm_delete PROTOTYPE((DBM *, datum));
+extern int      db_dbm_store PROTOTYPE((DBM *, datum, datum, int));
+
+#define        KDBM_OPEN(db, fl, mo)   db_dbm_open(db, fl, mo)
+#define        KDBM_CLOSE(db)          db_dbm_close(db)
+#define        KDBM_DELETE(db, key)    db_dbm_delete(db, key)
+#define        KDBM_STORE(db,key,c,f)  db_dbm_store(db, key, c, f)
+#else  /* BERK_DB_DBM */
+/*
+ * Use stock DBM code.
+ */
+#define        KDBM_OPEN(db, fl, mo)   dbm_open(db, fl, mo)
+#define        KDBM_CLOSE(db)          dbm_close(db)
+#define        KDBM_DELETE(db, key)    dbm_delete(db, key)
+#define        KDBM_STORE(db,key,c,f)  dbm_store(db, key, c, f)
+#endif /* BERK_DB_DBM */
+
 extern int errno;
 
 void
@@ -97,7 +120,7 @@ char *argv[];
     pname = argv[optind];
     lname = argv[optind+1];
 
-    if (!(db = dbm_open(andbname, O_RDWR|O_CREAT, 0644))) {
+    if (!(db = KDBM_OPEN(andbname, O_RDWR|O_CREAT, 0644))) {
        com_err(argv[0], errno, "while opening/creating %s",
                andbname);
        exit(1);
@@ -106,22 +129,22 @@ char *argv[];
     key.dsize = strlen(pname)+1;       /* include the null */
 
     if (del) {
-       if (dbm_delete(db, key)) {
+       if (KDBM_DELETE(db, key)) {
            com_err(argv[0], 0, "No such entry while deleting %s from %s",
                    pname, andbname);
-           dbm_close(db);
+           KDBM_CLOSE(db);
            exit(1);
        }
     } else if (add) {
        contents.dptr = lname;
        contents.dsize = strlen(lname)+1;
-       if (dbm_store(db, key, contents, DBM_REPLACE)) {
+       if (KDBM_STORE(db, key, contents, DBM_REPLACE)) {
            com_err(argv[0], errno, "while inserting/replacing %s in %s",
                    pname, andbname);
-           dbm_close(db);
+           KDBM_CLOSE(db);
            exit(1);
        }
     }
-    dbm_close(db);
+    KDBM_CLOSE(db);
     exit(0);
 }