+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.
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
#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
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);
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);
}