From 32276ee7b76a64e01a474f9d79d633d690a13e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Fri, 29 Aug 2003 16:37:25 +0000 Subject: [PATCH] patch for working with DB4 on heimdal-discuss From: Luke Howard git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12697 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/hdb/db3.c | 9 ++++++++- lib/roken/ndbm_wrap.c | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/hdb/db3.c b/lib/hdb/db3.c index 7d62181c6..db2c4157a 100644 --- a/lib/hdb/db3.c +++ b/lib/hdb/db3.c @@ -87,7 +87,6 @@ static krb5_error_code DB_seq(krb5_context context, HDB *db, unsigned flags, hdb_entry *entry, int flag) { - DB *d = (DB*)db->db; DBT key, value; DBC *dbcp = db->dbc; krb5_data key_data, data; @@ -262,10 +261,18 @@ DB_open(krb5_context context, HDB *db, int flags, mode_t mode) } db_create(&d, NULL, 0); db->db = d; +#if (DB_VERSION_MAJOR > 3) && (DB_VERSION_MINOR > 0) + if ((ret = d->open(db->db, NULL, fn, NULL, DB_BTREE, myflags, mode))) { +#else if ((ret = d->open(db->db, fn, NULL, DB_BTREE, myflags, mode))) { +#endif if(ret == ENOENT) /* try to open without .db extension */ +#if (DB_VERSION_MAJOR > 3) && (DB_VERSION_MINOR > 0) + if (d->open(db->db, NULL, db->name, NULL, DB_BTREE, myflags, mode)) { +#else if (d->open(db->db, db->name, NULL, DB_BTREE, myflags, mode)) { +#endif free(fn); krb5_set_error_string(context, "opening %s: %s", db->name, strerror(ret)); diff --git a/lib/roken/ndbm_wrap.c b/lib/roken/ndbm_wrap.c index 4fec089e4..7c7d6c37a 100644 --- a/lib/roken/ndbm_wrap.c +++ b/lib/roken/ndbm_wrap.c @@ -165,7 +165,12 @@ dbm_open (const char *file, int flags, mode_t mode) free(fn); return NULL; } + +#if (DB_VERSION_MAJOR > 3) && (DB_VERSION_MINOR > 0) + if(db->open(db, NULL, fn, NULL, DB_BTREE, myflags, mode) != 0) { +#else if(db->open(db, fn, NULL, DB_BTREE, myflags, mode) != 0) { +#endif free(fn); db->close(db, 0); return NULL;