From 5ba2dd5bf105d0a6e70c5b0a54c36ce8fce7e0af Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 22 Apr 2007 13:30:36 +0200 Subject: [PATCH] support DB >= 4.1 --- common/db.h | 8 ++++++++ common/exf.c | 4 ++-- common/log.c | 2 +- common/msg.c | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/common/db.h b/common/db.h index e9142320..2d3fd044 100644 --- a/common/db.h +++ b/common/db.h @@ -1,5 +1,13 @@ #include +#if DB_VERSION_MAJOR >= 4 && DB_VERSION_MINOR >= 1 +#define db_open(db,file,type,flags,mode) \ + (db)->open(db, NULL, file, NULL, type, flags, mode) +#else +#define db_open(db,file,type,flags,mode) \ + (db)->open(db, file, NULL, type, flags, mode) +#endif + #ifdef USE_DYNAMIC_LOADING #define db_create nvi_db_create #define db_env_create nvi_db_env_create diff --git a/common/exf.c b/common/exf.c index 195d2c06..3d1a30eb 100644 --- a/common/exf.c +++ b/common/exf.c @@ -287,7 +287,7 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags) #define _DB_OPEN_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH - if ((sp->db_error = ep->db->open(ep->db, ep->rcv_path, NULL, DB_RECNO, + if ((sp->db_error = db_open(ep->db, ep->rcv_path, DB_RECNO, ((rcv_name == 0) ? DB_TRUNCATE : 0) | VI_DB_THREAD | NOMMAPIFFCNTL, _DB_OPEN_MODE)) != 0) { msgq_str(sp, @@ -319,7 +319,7 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags) msgq(sp, M_DBERR, "db_create 2"); goto err; } - if ((sp->db_error = ep->db->open(ep->db, ep->rcv_path, NULL, DB_RECNO, + if ((sp->db_error = db_open(ep->db, ep->rcv_path, DB_RECNO, VI_DB_THREAD | NOMMAPIFFCNTL, _DB_OPEN_MODE)) != 0) { msgq_str(sp, M_DBERR, ep->rcv_path, "%s"); diff --git a/common/log.c b/common/log.c index f9033ce0..642304bc 100644 --- a/common/log.c +++ b/common/log.c @@ -109,7 +109,7 @@ log_init(SCR *sp, EXF *ep) ep->l_high = ep->l_cur = 1; if (db_create(&ep->log, 0, 0) != 0 || - ep->log->open(ep->log, NULL, NULL, DB_RECNO, + db_open(ep->log, NULL, DB_RECNO, DB_CREATE | VI_DB_THREAD, S_IRUSR | S_IWUSR) != 0) { msgq(sp, M_SYSERR, "009|Log file"); F_SET(ep, F_NOLOG); diff --git a/common/msg.c b/common/msg.c index 62cf512b..1386dc95 100644 --- a/common/msg.c +++ b/common/msg.c @@ -726,7 +726,7 @@ msg_open(SCR *sp, char *file) p = file; if ((sp->db_error = db_create(&db, 0, 0)) != 0 || (sp->db_error = db->set_re_source(db, p)) != 0 || - (sp->db_error = db->open(db, NULL, NULL, DB_RECNO, 0, 0)) != 0) { + (sp->db_error = db_open(db, NULL, DB_RECNO, 0, 0)) != 0) { if (first) { first = 0; return (1); -- 2.11.4.GIT