summaryrefslogtreecommitdiff
path: root/ext/dba
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2003-02-01 18:59:59 +0000
committerMarcus Boerger <helly@php.net>2003-02-01 18:59:59 +0000
commit0319e6377588c9bd8d182589c3d8bec4bec8fdef (patch)
tree981edce762f2aff5768503c4c68c317c3fe4bd21 /ext/dba
parentc4eecf91993dcd431eee5e93e409ce3b1e179192 (diff)
downloadphp-git-0319e6377588c9bd8d182589c3d8bec4bec8fdef.tar.gz
- unify configure mechanisms (include file handling)
- fix dbm - allow dbm to be based on gdbm
Diffstat (limited to 'ext/dba')
-rw-r--r--ext/dba/config.m428
-rw-r--r--ext/dba/dba_cdb.c11
-rw-r--r--ext/dba/dba_dbm.c23
-rw-r--r--ext/dba/dba_gdbm.c4
4 files changed, 48 insertions, 18 deletions
diff --git a/ext/dba/config.m4 b/ext/dba/config.m4
index bbbc34952a..30d75a08b4 100644
--- a/ext/dba/config.m4
+++ b/ext/dba/config.m4
@@ -5,7 +5,7 @@ dnl
dnl Suppose we need FlatFile if no support or only CDB is used.
AC_DEFUN(PHP_DBA_STD_BEGIN,[
- unset THIS_INCLUDE THIS_INC_DIR THIS_LIBS THIS_LFLAGS THIS_PREFIX THIS_RESULT
+ unset THIS_INCLUDE THIS_LIBS THIS_LFLAGS THIS_PREFIX THIS_RESULT
])
AC_DEFUN(PHP_TEMP_LDFLAGS,[
@@ -35,11 +35,8 @@ AC_DEFUN(PHP_DBA_STD_CHECK,[
dnl Attach THIS_x to DBA_x
AC_DEFUN(PHP_DBA_STD_ATTACH,[
- if test -n "$THIS_INC_DIR" -a "$THIS_PREFIX" != "/usr"; then
- PHP_ADD_INCLUDE($THIS_INC_DIR)
- fi
PHP_ADD_LIBRARY_WITH_PATH($THIS_LIBS, $THIS_LFLAGS, DBA_SHARED_LIBADD)
- unset THIS_INCLUDE THIS_INC_DIR THIS_LIBS THIS_LFLAGS THIS_PREFIX
+ unset THIS_INCLUDE THIS_LIBS THIS_LFLAGS THIS_PREFIX
])
dnl Print the result message
@@ -76,7 +73,6 @@ AC_ARG_WITH(gdbm,
if test -f "$i/include/gdbm.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/gdbm.h
- THIS_INC_DIR=$i/include
break
fi
done
@@ -85,6 +81,7 @@ AC_ARG_WITH(gdbm,
unset ac_cv_lib_gdbm_gdbm_open
PHP_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[
AC_CHECK_LIB(gdbm, gdbm_open, [
+ AC_DEFINE_UNQUOTED(GDBM_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
AC_DEFINE(DBA_GDBM, 1, [ ])
THIS_LIBS=gdbm
break
@@ -116,10 +113,10 @@ AC_ARG_WITH(ndbm,
done
if test -n "$THIS_INCLUDE"; then
- AC_DEFINE_UNQUOTED(NDBM_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
for LIB in ndbm db1 c; do
PHP_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[
AC_CHECK_LIB($LIB, dbm_open, [
+ AC_DEFINE_UNQUOTED(NDBM_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
AC_DEFINE(DBA_NDBM,1, [ ])
THIS_LIBS=$LIB
break
@@ -301,15 +298,26 @@ AC_ARG_WITH(dbm,
if test -f "$i/include/dbm.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/dbm.h
- THIS_INC_DIR=$i/include
break
+ elif test -f "$i/include/gdbm/dbm.h"; then
+ THIS_PREFIX=$i
+ THIS_INCLUDE=$i/include/gdbm/dbm.h
fi
done
if test -n "$THIS_INCLUDE"; then
- for LIB in db1 dbm c; do
+ for LIB in gdbm dbm c; do
PHP_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[
AC_CHECK_LIB($LIB, dbminit, [
+ AC_MSG_CHECKING(for DBM using GDBM)
+ AC_DEFINE_UNQUOTED(DBM_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
+ if test "$LIB" = "gdbm"; then
+ AC_DEFINE_UNQUOTED(DBM_VERSION, "GDBM", [ ])
+ AC_MSG_RESULT(yes)
+ else
+ AC_DEFINE_UNQUOTED(DBM_VERSION, "DBM", [ ])
+ AC_MSG_RESULT(no)
+ fi
AC_DEFINE(DBA_DBM,1,[ ])
THIS_LIBS=$LIB
break
@@ -344,7 +352,6 @@ AC_ARG_WITH(cdb,
if test -f "$i/include/cdb.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/cdb.h
- THIS_INC_DIR=$i/include
break
fi
done
@@ -353,6 +360,7 @@ AC_ARG_WITH(cdb,
for LIB in cdb c; do
PHP_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[
AC_CHECK_LIB($LIB, cdb_read, [
+ AC_DEFINE_UNQUOTED(CDB_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
AC_DEFINE(DBA_CDB,1,[ ])
THIS_LIBS=$LIB
break
diff --git a/ext/dba/dba_cdb.c b/ext/dba/dba_cdb.c
index fb1a3f3ba2..ee9d53a74d 100644
--- a/ext/dba/dba_cdb.c
+++ b/ext/dba/dba_cdb.c
@@ -35,12 +35,13 @@
#include <fcntl.h>
#if DBA_CDB_BUILTIN
-#include "libcdb/cdb.h"
-#include "libcdb/cdb_make.h"
-#include "libcdb/uint32.h"
+# include "libcdb/cdb.h"
+# include "libcdb/cdb_make.h"
+# include "libcdb/uint32.h"
#else
-#include <cdb.h>
-#include <uint32.h>
+# ifdef CDB_INCLUDE_FILE
+# include CDB_INCLUDE_FILE
+# endif
#endif
#define CDB_INFO \
diff --git a/ext/dba/dba_dbm.c b/ext/dba/dba_dbm.c
index f50d58a03f..06010af589 100644
--- a/ext/dba/dba_dbm.c
+++ b/ext/dba/dba_dbm.c
@@ -27,7 +27,12 @@
#if DBA_DBM
#include "php_dbm.h"
-#include <dbm.h>
+#ifdef DBM_INCLUDE_FILE
+#include DBM_INCLUDE_FILE
+#endif
+#if DBA_GDBM
+#include "php_gdbm.h"
+#endif
#include <unistd.h>
#include <sys/types.h>
@@ -108,6 +113,14 @@ DBA_UPDATE_FUNC(dbm)
datum gval;
DBM_GKEY;
+
+ if (mode == 1) { /* insert */
+ gval = fetch(gkey);
+ if(gval.dptr) {
+ return FAILURE;
+ }
+ }
+
gval.dptr = (char *) val;
gval.dsize = vallen;
@@ -179,7 +192,13 @@ DBA_SYNC_FUNC(dbm)
DBA_INFO_FUNC(dbm)
{
- return estrdup("DBM");
+#if DBA_GDBM
+ if (!strcmp(DBM_VERSION, "GDBM"))
+ {
+ return dba_info_gdbm(hnd, info TSRMLS_CC);
+ }
+#endif
+ return estrdup(DBM_VERSION);
}
#endif
diff --git a/ext/dba/dba_gdbm.c b/ext/dba/dba_gdbm.c
index 40332ad44e..b3b8abdc73 100644
--- a/ext/dba/dba_gdbm.c
+++ b/ext/dba/dba_gdbm.c
@@ -27,7 +27,9 @@
#if DBA_GDBM
#include "php_gdbm.h"
-#include <gdbm.h>
+#ifdef GDBM_INCLUDE_FILE
+#include GDBM_INCLUDE_FILE
+#endif
#define GDBM_DATA dba_gdbm_data *dba = info->dbf
#define GDBM_GKEY datum gkey; gkey.dptr = (char *) key; gkey.dsize = keylen