diff options
Diffstat (limited to 'ext/dba')
51 files changed, 0 insertions, 5012 deletions
diff --git a/ext/dba/CREDITS b/ext/dba/CREDITS deleted file mode 100644 index 370b3ea271..0000000000 --- a/ext/dba/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -DBA -Sascha Schumann, Marcus Boerger
\ No newline at end of file diff --git a/ext/dba/config.m4 b/ext/dba/config.m4 deleted file mode 100644 index b70a3752c3..0000000000 --- a/ext/dba/config.m4 +++ /dev/null @@ -1,381 +0,0 @@ -dnl -dnl $Id$ -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 -]) - -AC_DEFUN(PHP_TEMP_LDFLAGS,[ - old_LDFLAGS=$LDFLAGS - LDFLAGS="$1 $LDFLAGS" - $2 - LDFLAGS=$old_LDFLAGS -]) - -dnl Assign INCLUDE/LFLAGS from PREFIX -AC_DEFUN(PHP_DBA_STD_ASSIGN,[ - if test -n "$THIS_PREFIX" && test "$THIS_PREFIX" != "/usr"; then - THIS_LFLAGS=$THIS_PREFIX/lib - fi -]) - -dnl Standard check -AC_DEFUN(PHP_DBA_STD_CHECK,[ - THIS_RESULT="yes" - if test -z "$THIS_INCLUDE"; then - AC_MSG_ERROR(cannot find necessary header file(s)) - fi - if test -z "$THIS_LIBS"; then - AC_MSG_ERROR(cannot find necessary library) - fi -]) - -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 -]) - -dnl Print the result message -dnl parameters(name [, full name [, empty or error message]]) -AC_DEFUN(AC_DBA_STD_RESULT,[ - THIS_NAME=[]translit($1,a-z0-9-,A-Z0-9_) - if test -n "$2"; then - THIS_FULL_NAME="$2" - else - THIS_FULL_NAME="$THIS_NAME" - fi - AC_MSG_CHECKING(for $THIS_FULL_NAME support) - if test -n "$3"; then - AC_MSG_ERROR($3) - fi - if test "$THIS_RESULT" = "yes" -o "$THIS_RESULT" = "builtin"; then - HAVE_DBA=1 - eval HAVE_$THIS_NAME=1 - AC_MSG_RESULT($THIS_RESULT) - else - AC_MSG_RESULT(no) - fi - unset THIS_RESULT THIS_NAME THIS_FULL_NAME -]) - -PHP_ARG_ENABLE(dba,whether to enable DBA, -[ --enable-dba Build DBA with builtin modules]) - -AC_ARG_WITH(gdbm, -[ --with-gdbm[=DIR] Include GDBM support],[ - if test "$withval" != "no"; then - PHP_DBA_STD_BEGIN - for i in $withval /usr/local /usr; do - 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 - - if test -n "$THIS_INCLUDE"; then - unset ac_cv_lib_gdbm_gdbm_open - PHP_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[ - AC_CHECK_LIB(gdbm, gdbm_open, [ - AC_DEFINE(DBA_GDBM, 1, [ ]) - THIS_LIBS=gdbm - break - ]) - ]) - fi - - PHP_DBA_STD_ASSIGN - PHP_DBA_STD_CHECK - PHP_DBA_STD_ATTACH - fi -]) -AC_DBA_STD_RESULT(gdbm) - -AC_ARG_WITH(ndbm, -[ --with-ndbm[=DIR] Include NDBM support],[ - if test "$withval" != "no"; then - PHP_DBA_STD_BEGIN - for i in $withval /usr/local /usr; do - if test -f "$i/include/ndbm.h"; then - THIS_PREFIX=$i - THIS_INCLUDE=$i/include/ndbm.h - break - elif test -f "$i/include/db1/ndbm.h"; then - THIS_PREFIX=$i - THIS_INCLUDE=$i/include/db1/ndbm.h - break - fi - 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(DBA_NDBM,1, [ ]) - THIS_LIBS=$LIB - break - ]) - ]) - done - fi - - PHP_DBA_STD_ASSIGN - PHP_DBA_STD_CHECK - PHP_DBA_STD_ATTACH - fi -]) -AC_DBA_STD_RESULT(ndbm) - -dnl Berkeley specific (library and version test) -dnl parameters(version, library list, function) -AC_DEFUN(PHP_DBA_DB_CHECK,[ - for LIB in $2; do - PHP_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[ - AC_CHECK_LIB($LIB, $3, [ - AC_TRY_RUN([ -#include "$THIS_INCLUDE" -int main() { - return DB_VERSION_MAJOR >= $1 ? 0 : 1; -} - ],[ - THIS_LIBS=$LIB - break - ],[ ],[ - THIS_LIBS=$LIB - break - ]) - ]) - ]) - done - if test -n "$THIS_LIBS"; then - AC_DEFINE(DBA_DB$1, 1, [ ]) - if test -n "$THIS_INCLUDE"; then - AC_DEFINE_UNQUOTED(DB$1_INCLUDE_FILE, "$THIS_INCLUDE", [ ]) - fi - fi - PHP_DBA_STD_ASSIGN - PHP_DBA_STD_CHECK - PHP_DBA_STD_ATTACH -]) - -AC_ARG_WITH(db4, -[ --with-db4[=DIR] Include Berkeley DB4 support],[ - if test "$withval" != "no"; then - PHP_DBA_STD_BEGIN - for i in $withval /usr/local/BerkeleyDB.4.1 /usr/local/BerkeleyDB.4.0 /usr/local /usr; do - if test -f "$i/db4/db.h"; then - THIS_PREFIX=$i - THIS_INCLUDE=$i/db4/db.h - break - elif test -f "$i/include/db4/db.h"; then - THIS_PREFIX=$i - THIS_INCLUDE=$i/include/db4/db.h - break - elif test -f "$i/include/db/db4.h"; then - THIS_PREFIX=$i - THIS_INCLUDE=$i/include/db/db4.h - break - elif test -f "$i/include/db4.h"; then - THIS_PREFIX=$i - THIS_INCLUDE=$i/include/db4.h - break - elif test -f "$i/include/db.h"; then - THIS_PREFIX=$i - THIS_INCLUDE=$i/include/db.h - break - fi - done - PHP_DBA_DB_CHECK(4, db-4.1 db-4 db4 db, db_create) - fi -]) -AC_DBA_STD_RESULT(db4,Berkeley DB4) - -AC_ARG_WITH(db3, -[ --with-db3[=DIR] Include Berkeley DB3 support],[ - if test "$withval" != "no"; then - PHP_DBA_STD_BEGIN - if test "$HAVE_DB4" = "1"; then - AC_DBA_STD_RESULT(db3,Berkeley DB3,You cannot combine --with-db3 with --with-db4) - fi - for i in $withval /usr/local/BerkeleyDB.3.3 /usr/local/BerkeleyDB.3.2 /usr/local/BerkeleyDB.3.1 /usr/local/BerkeleyDB.3.0 /usr/local /usr; do - if test -f "$i/db3/db.h"; then - THIS_PREFIX=$i - THIS_INCLUDE=$i/include/db3/db.h - break - elif test -f "$i/include/db3/db.h"; then - THIS_PREFIX=$i - THIS_INCLUDE=$i/include/db3/db.h - break - elif test -f "$i/include/db/db3.h"; then - THIS_PREFIX=$i - THIS_INCLUDE=$i/include/db/db3.h - break - elif test -f "$i/include/db3.h"; then - THIS_PREFIX=$i - THIS_INCLUDE=$i/include/db3.h - break - elif test -f "$i/include/db.h"; then - THIS_PREFIX=$i - THIS_INCLUDE=$i/include/db.h - break - fi - done - PHP_DBA_DB_CHECK(3, db-3.3 db-3.2 db-3.1 db-3 db3 db, db_create) - fi - ]) -AC_DBA_STD_RESULT(db3,Berkeley DB3) - -AC_ARG_WITH(db2, -[ --with-db2[=DIR] Include Berkeley DB2 support],[ - if test "$withval" != "no"; then - PHP_DBA_STD_BEGIN - if test "$HAVE_DB3" = "1" -o "$HAVE_DB4" = "1"; then - AC_DBA_STD_RESULT(db2,Berkeley DB2,You cannot combine --with-db2 with --with-db3 or --with-db4) - fi - for i in $withval $withval/BerkeleyDB /usr/BerkeleyDB /usr/local /usr; do - if test -f "$i/db2/db.h"; then - THIS_PREFIX=$i - THIS_INCLUDE=$i/db2/db.h - break - elif test -f "$i/include/db2/db.h"; then - THIS_PREFIX=$i - THIS_INCLUDE=$i/include/db2/db.h - break - elif test -f "$i/include/db/db2.h"; then - THIS_PREFIX=$i - THIS_INCLUDE=$i/include/db/db2.h - break - elif test -f "$i/include/db2.h"; then - THIS_PREFIX=$i - THIS_INCLUDE=$i/include/db2.h - break - elif test -f "$i/include/db.h"; then - THIS_PREFIX=$i - THIS_INCLUDE=$i/include/db.h - break - fi - done - PHP_DBA_DB_CHECK(2, db-2 db2 db, db_appinit) - fi -]) -AC_DBA_STD_RESULT(db2,Berkeley DB2) - -AC_ARG_WITH(dbm, -[ --with-dbm[=DIR] Include DBM support],[ - if test "$withval" != "no"; then - PHP_DBA_STD_BEGIN - for i in $withval /usr/local /usr; do - if test -f "$i/include/dbm.h"; then - THIS_PREFIX=$i - THIS_INCLUDE=$i/include/dbm.h - THIS_INC_DIR=$i/include - break - fi - done - - if test -n "$THIS_INCLUDE"; then - for LIB in db1 dbm c; do - PHP_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[ - AC_CHECK_LIB($LIB, dbminit, [ - AC_DEFINE(DBA_DBM,1,[ ]) - THIS_LIBS=$LIB - break - ]) - ]) - done - fi - - PHP_DBA_STD_ASSIGN - PHP_DBA_STD_CHECK - PHP_DBA_STD_ATTACH - fi -]) -AC_DBA_STD_RESULT(dbm) - -AC_DEFUN(PHP_DBA_BUILTIN_CDB,[ - PHP_ADD_BUILD_DIR($ext_builddir/libcdb) - AC_DEFINE(DBA_CDB_BUILTIN, 1, [ ]) - AC_DEFINE(DBA_CDB_MAKE, 1, [ ]) - AC_DEFINE(DBA_CDB, 1, [ ]) - cdb_sources="libcdb/cdb.c libcdb/cdb_make.c libcdb/uint32.c" - THIS_RESULT="builtin" -]) - -AC_ARG_WITH(cdb, -[ --with-cdb[=DIR] Include CDB support],[ - if test "$withval" != "no"; then - PHP_DBA_BUILTIN_CDB - elif test "$withval" != "no"; then - PHP_DBA_STD_BEGIN - for i in $withval /usr/local /usr; do - 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 - - if test -n "$THIS_INCLUDE"; then - for LIB in cdb c; do - PHP_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[ - AC_CHECK_LIB($LIB, cdb_read, [ - AC_DEFINE(DBA_CDB,1,[ ]) - THIS_LIBS=$LIB - break - ]) - ]) - done - fi - - PHP_DBA_STD_ASSIGN - PHP_DBA_STD_CHECK - PHP_DBA_STD_ATTACH - fi -],[ - if test "$PHP_DBA" != "no"; then - PHP_DBA_BUILTIN_CDB - fi -]) -AC_DBA_STD_RESULT(cdb) - -AC_DEFUN(PHP_DBA_BUILTIN_FLATFILE,[ - PHP_ADD_BUILD_DIR($ext_builddir/libflatfile) - AC_DEFINE(DBA_FLATFILE, 1, [ ]) - flat_sources="dba_flatfile.c libflatfile/flatfile.c" - THIS_RESULT="builtin" -]) - -dnl -dnl FlatFile check must be the last one. -dnl -AC_ARG_WITH(flatfile, -[ --with-flatfile Include FlatFile support],[ - if test "$withval" != "no"; then - PHP_DBA_BUILTIN_FLATFILE - fi -],[ - if test "$PHP_DBA" != "no"; then - PHP_DBA_BUILTIN_FLATFILE - fi -]) -AC_DBA_STD_RESULT(FlatFile,FlatFile) - -AC_MSG_CHECKING(whether to enable DBA interface) -if test "$HAVE_DBA" = "1"; then - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_DBA, 1, [ ]) - PHP_NEW_EXTENSION(dba, dba.c dba_cdb.c dba_db2.c dba_dbm.c dba_gdbm.c dba_ndbm.c dba_db3.c dba_db4.c $cdb_sources $flat_sources, $ext_shared) - PHP_SUBST(DBA_SHARED_LIBADD) -else - AC_MSG_RESULT(no) -fi diff --git a/ext/dba/dba.c b/ext/dba/dba.c deleted file mode 100644 index c110d73229..0000000000 --- a/ext/dba/dba.c +++ /dev/null @@ -1,821 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Sascha Schumann <sascha@schumann.cx> | - | Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" - -#if HAVE_DBA - -#include "ext/standard/flock_compat.h" -#include <stdio.h> -#include <fcntl.h> -#ifdef HAVE_SYS_FILE_H -#include <sys/file.h> -#endif - -#include "php_dba.h" -#include "ext/standard/info.h" -#include "ext/standard/php_string.h" - -#include "php_gdbm.h" -#include "php_ndbm.h" -#include "php_dbm.h" -#include "php_cdb.h" -#include "php_db2.h" -#include "php_db3.h" -#include "php_db4.h" -#include "php_flatfile.h" - -/* {{{ dba_functions[] - */ -function_entry dba_functions[] = { - PHP_FE(dba_open, NULL) - PHP_FE(dba_popen, NULL) - PHP_FE(dba_close, NULL) - PHP_FE(dba_delete, NULL) - PHP_FE(dba_exists, NULL) - PHP_FE(dba_fetch, NULL) - PHP_FE(dba_insert, NULL) - PHP_FE(dba_replace, NULL) - PHP_FE(dba_firstkey, NULL) - PHP_FE(dba_nextkey, NULL) - PHP_FE(dba_optimize, NULL) - PHP_FE(dba_sync, NULL) - PHP_FE(dba_handlers, NULL) - PHP_FE(dba_list, NULL) - {NULL, NULL, NULL} -}; -/* }}} */ - -PHP_MINIT_FUNCTION(dba); -PHP_MINFO_FUNCTION(dba); - -zend_module_entry dba_module_entry = { - STANDARD_MODULE_HEADER, - "dba", - dba_functions, - PHP_MINIT(dba), - NULL, - NULL, - NULL, - PHP_MINFO(dba), - NO_VERSION_YET, - STANDARD_MODULE_PROPERTIES -}; - -#ifdef COMPILE_DL_DBA -ZEND_GET_MODULE(dba) -#endif - -typedef struct dba_handler { - char *name; /* handler name */ - int flags; /* whether and how dba does locking and other flags*/ - int (*open)(dba_info *, char **error TSRMLS_DC); - void (*close)(dba_info * TSRMLS_DC); - char* (*fetch)(dba_info *, char *, int, int, int * TSRMLS_DC); - int (*update)(dba_info *, char *, int, char *, int, int TSRMLS_DC); - int (*exists)(dba_info *, char *, int TSRMLS_DC); - int (*delete)(dba_info *, char *, int TSRMLS_DC); - char* (*firstkey)(dba_info *, int * TSRMLS_DC); - char* (*nextkey)(dba_info *, int * TSRMLS_DC); - int (*optimize)(dba_info * TSRMLS_DC); - int (*sync)(dba_info * TSRMLS_DC); -} dba_handler; - -/* {{{ macromania */ - -#define DBA_ID_PARS \ - zval **id; \ - dba_info *info = NULL; \ - int ac = ZEND_NUM_ARGS() - -/* these are used to get the standard arguments */ - -#define DBA_GET1 \ - if(ac != 1 || zend_get_parameters_ex(ac, &id) != SUCCESS) { \ - WRONG_PARAM_COUNT; \ - } - -#define DBA_GET2 \ - zval **key; \ - if(ac != 2 || zend_get_parameters_ex(ac, &key, &id) != SUCCESS) { \ - WRONG_PARAM_COUNT; \ - } \ - convert_to_string_ex(key) - -#define DBA_GET2_3 \ - zval **key; \ - zval **tmp; \ - int skip = 0; \ - switch(ac) { \ - case 2: \ - if (zend_get_parameters_ex(ac, &key, &id) != SUCCESS) { \ - WRONG_PARAM_COUNT; \ - } \ - break; \ - case 3: \ - if (zend_get_parameters_ex(ac, &key, &tmp, &id) != SUCCESS) { \ - WRONG_PARAM_COUNT; \ - } \ - convert_to_long_ex(tmp); \ - skip = Z_LVAL_PP(tmp); \ - break; \ - default: \ - WRONG_PARAM_COUNT; \ - } \ - convert_to_string_ex(key) - -#define DBA_ID_GET \ - ZEND_FETCH_RESOURCE2(info, dba_info *, id, -1, "DBA identifier", le_db, le_pdb); - -#define DBA_ID_GET1 DBA_ID_PARS; DBA_GET1; DBA_ID_GET -#define DBA_ID_GET2 DBA_ID_PARS; DBA_GET2; DBA_ID_GET -#define DBA_ID_GET2_3 DBA_ID_PARS; DBA_GET2_3; DBA_ID_GET - -/* a DBA handler must have specific routines */ - -#define DBA_NAMED_HND(name, x, flags) \ -{\ - #name, flags, dba_open_##x, dba_close_##x, dba_fetch_##x, dba_update_##x, \ - dba_exists_##x, dba_delete_##x, dba_firstkey_##x, dba_nextkey_##x, \ - dba_optimize_##x, dba_sync_##x \ -}, - -#define DBA_HND(x, flags) DBA_NAMED_HND(x, x, flags) - -/* check whether the user has write access */ -#define DBA_WRITE_CHECK \ - if(info->mode != DBA_WRITER && info->mode != DBA_TRUNC && info->mode != DBA_CREAT) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "You cannot perform a modification to a database without proper access"); \ - RETURN_FALSE; \ - } - -/* }}} */ - -/* {{{ globals */ - -static dba_handler handler[] = { -#if DBA_GDBM - DBA_HND(gdbm, DBA_LOCK_EXT) /* Locking done in library if set */ -#endif -#if DBA_DBM - DBA_HND(dbm, DBA_LOCK_ALL) /* No lock in lib */ -#endif -#if DBA_NDBM - DBA_HND(ndbm, DBA_LOCK_ALL) /* Could be done in library: filemode = 0644 + S_ENFMT */ -#endif -#if DBA_CDB - DBA_HND(cdb, DBA_STREAM_OPEN|DBA_LOCK_ALL) /* No lock in lib */ -#endif -#if DBA_CDB_BUILTIN - DBA_NAMED_HND(cdb_make, cdb, DBA_STREAM_OPEN|DBA_LOCK_ALL) /* No lock in lib */ -#endif -#if DBA_DB2 - DBA_HND(db2, DBA_LOCK_ALL) /* No lock in lib */ -#endif -#if DBA_DB3 - DBA_HND(db3, DBA_LOCK_ALL) /* No lock in lib */ -#endif -#if DBA_DB4 - DBA_HND(db4, DBA_LOCK_ALL) /* No lock in lib */ -#endif -#if DBA_FLATFILE - DBA_HND(flatfile, DBA_STREAM_OPEN|DBA_LOCK_ALL) /* No lock in lib */ -#endif - { NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } -}; - -static int le_db; -static int le_pdb; -/* }}} */ - -/* {{{ dba_close - */ -static void dba_close(dba_info *info TSRMLS_DC) -{ - if (info->hnd) info->hnd->close(info TSRMLS_CC); - if (info->path) efree(info->path); - if (info->fp && info->fp!=info->lock.fp) php_stream_close(info->fp); - if (info->lock.fd) { - php_flock(info->lock.fd, LOCK_UN); - /*close(info->lock.fd);*/ - info->lock.fd = 0; - } - if (info->lock.fp) php_stream_close(info->lock.fp); - if (info->lock.name) efree(info->lock.name); - efree(info); -} -/* }}} */ - -/* {{{ dba_close_rsrc - */ -static void dba_close_rsrc(zend_rsrc_list_entry *rsrc TSRMLS_DC) -{ - dba_info *info = (dba_info *)rsrc->ptr; - - dba_close(info TSRMLS_CC); -} -/* }}} */ - -/* {{{ PHP_MINIT_FUNCTION - */ -PHP_MINIT_FUNCTION(dba) -{ - le_db = zend_register_list_destructors_ex(dba_close_rsrc, NULL, "dba", module_number); - le_pdb = zend_register_list_destructors_ex(NULL, dba_close_rsrc, "dba persistent", module_number); - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_MSHUTDOWN_FUNCTION - */ -PHP_MSHUTDOWN_FUNCTION(dba) -{ - return SUCCESS; -} -/* }}} */ - -#include "ext/standard/php_smart_str.h" - -/* {{{ PHP_MINFO_FUNCTION - */ -PHP_MINFO_FUNCTION(dba) -{ - dba_handler *hptr; - smart_str handlers = {0}; - - for(hptr = handler; hptr->name; hptr++) { - smart_str_appends(&handlers, hptr->name); - smart_str_appendc(&handlers, ' '); - } - - php_info_print_table_start(); - php_info_print_table_row(2, "DBA support", "enabled"); - if (handlers.c) { - smart_str_0(&handlers); - php_info_print_table_row(2, "Supported handlers", handlers.c); - smart_str_free(&handlers); - } else { - php_info_print_table_row(2, "Supported handlers", "none"); - } - php_info_print_table_end(); -} -/* }}} */ - -/* {{{ php_dba_update - */ -static void php_dba_update(INTERNAL_FUNCTION_PARAMETERS, int mode) -{ - DBA_ID_PARS; - zval **val, **key; - char *v; - int len; - - if(ac != 3 || zend_get_parameters_ex(ac, &key, &val, &id) != SUCCESS) { - WRONG_PARAM_COUNT; - } - convert_to_string_ex(key); - convert_to_string_ex(val); - DBA_ID_GET; - - DBA_WRITE_CHECK; - - if (PG(magic_quotes_runtime)) { - len = Z_STRLEN_PP(val); - v = estrndup(Z_STRVAL_PP(val), len); - php_stripslashes(v, &len TSRMLS_CC); - if(info->hnd->update(info, VALLEN(key), v, len, mode TSRMLS_CC) == SUCCESS) { - efree(v); - RETURN_TRUE; - } - efree(v); - } else { - if(info->hnd->update(info, VALLEN(key), VALLEN(val), mode TSRMLS_CC) == SUCCESS) - RETURN_TRUE; - } - RETURN_FALSE; -} -/* }}} */ - -#define FREENOW if(args) efree(args); if(key) efree(key) - -/* {{{ php_find_dbm - */ -dba_info *php_dba_find(const char* path TSRMLS_DC) -{ - list_entry *le; - dba_info *info; - int numitems, i; - - numitems = zend_hash_next_free_element(&EG(regular_list)); - for (i=1; i<numitems; i++) { - if (zend_hash_index_find(&EG(regular_list), i, (void **) &le)==FAILURE) { - continue; - } - if (Z_TYPE_P(le) == le_db || Z_TYPE_P(le) == le_pdb) { - info = (dba_info *)(le->ptr); - if (!strcmp(info->path, path)) { - return (dba_info *)(le->ptr); - } - } - } - - return NULL; -} -/* }}} */ - -/* {{{ php_dba_open - */ -static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent) -{ - zval ***args = (zval ***) NULL; - int ac = ZEND_NUM_ARGS(); - dba_mode_t modenr; - dba_info *info, *other; - dba_handler *hptr; - char *key = NULL, *error = NULL; - int keylen = 0; - int i; - int lock_mode, lock_flag, lock_dbf = 0; - char *file_mode; - char mode[4], *pmode, *lock_file_mode; - - if(ac < 3) { - WRONG_PARAM_COUNT; - } - - /* we pass additional args to the respective handler */ - args = emalloc(ac * sizeof(zval *)); - if (zend_get_parameters_array_ex(ac, args) != SUCCESS) { - FREENOW; - WRONG_PARAM_COUNT; - } - - /* we only take string arguments */ - for (i = 0; i < ac; i++) { - convert_to_string_ex(args[i]); - keylen += Z_STRLEN_PP(args[i]); - } - - if (persistent) { - list_entry *le; - - /* calculate hash */ - key = emalloc(keylen); - keylen = 0; - - for(i = 0; i < ac; i++) { - memcpy(key+keylen, Z_STRVAL_PP(args[i]), Z_STRLEN_PP(args[i])); - keylen += Z_STRLEN_PP(args[i]); - } - - /* try to find if we already have this link in our persistent list */ - if (zend_hash_find(&EG(persistent_list), key, keylen+1, (void **) &le) == SUCCESS) { - FREENOW; - - if (Z_TYPE_P(le) != le_pdb) { - RETURN_FALSE; - } - - info = (dba_info *)le->ptr; - - ZEND_REGISTER_RESOURCE(return_value, info, le_pdb); - return; - } - } - - for (hptr = handler; hptr->name && strcasecmp(hptr->name, Z_STRVAL_PP(args[2])); hptr++); - - if (!hptr->name) { - php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "No such handler: %s", Z_STRVAL_PP(args[2])); - FREENOW; - RETURN_FALSE; - } - - /* Check mode: [rwnc][fl]?t? - * r: Read - * w: Write - * n: Create/Truncate - * c: Create - * - * d: force lock on database file - * l: force lock on lck file - * -: ignore locking - * - * t: test open database, warning if locked - */ - strlcpy(mode, Z_STRVAL_PP(args[1]), sizeof(mode)); - pmode = &mode[0]; - if (pmode[0] && (pmode[1]=='d' || pmode[1]=='l' || pmode[1]=='-')) { /* force lock on db file or lck file or disable locking */ - switch (pmode[1]) { - case 'd': - lock_dbf = 1; - /* no break */ - case 'l': - lock_flag = DBA_LOCK_ALL; - if ((hptr->flags & DBA_LOCK_ALL) == 0) { - php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_NOTICE, "Handler %s does locking internally", hptr->name); - } - break; - default: - case '-': - if ((hptr->flags & DBA_LOCK_ALL) == 0) { - php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "Locking cannot be disabled for handler %s", hptr->name); - FREENOW; - RETURN_FALSE; - } - lock_flag = 0; - break; - } - } else { - lock_flag = (hptr->flags&DBA_LOCK_ALL); - lock_dbf = 1; - } - switch (*pmode++) { - case 'r': - modenr = DBA_READER; - lock_mode = (lock_flag & DBA_LOCK_READER) ? LOCK_SH : 0; - file_mode = "r"; - break; - case 'w': - modenr = DBA_WRITER; - lock_mode = (lock_flag & DBA_LOCK_WRITER) ? LOCK_EX : 0; - file_mode = "r+b"; - break; - case 'n': - modenr = DBA_TRUNC; - lock_mode = (lock_flag & DBA_LOCK_TRUNC) ? LOCK_EX : 0; - file_mode = "w+b"; - break; - case 'c': - modenr = DBA_CREAT; - lock_mode = (lock_flag & DBA_LOCK_CREAT) ? LOCK_EX : 0; - file_mode = "a+b"; - break; - default: - modenr = 0; - lock_mode = 0; - file_mode = ""; - } - if (*pmode=='d' || *pmode=='l' || *pmode=='-') { - pmode++; /* done already - skip here */ - } - if (*pmode=='t') { - pmode++; - if (!lock_flag) { - php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "You cannot combine modifiers - (no lock) and t (test lock)", hptr->name); - FREENOW; - RETURN_FALSE; - } - if (!lock_mode) { - if ((hptr->flags & DBA_LOCK_ALL) == 0) { - php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "Handler %s uses its own locking which doesn't support mode modifier t (test lock)", hptr->name); - FREENOW; - RETURN_FALSE; - } else { - php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "Handler %s doesn't uses locking for this mode which makes modifier t (test lock) obsolete", hptr->name); - FREENOW; - RETURN_FALSE; - } - } else { - lock_mode |= LOCK_NB; /* test =: non blocking */ - } - } - if (*pmode || !modenr) { - php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "Illegal DBA mode"); - FREENOW; - RETURN_FALSE; - } - - info = emalloc(sizeof(dba_info)); - memset(info, 0, sizeof(dba_info)); - info->path = estrdup(Z_STRVAL_PP(args[0])); - info->mode = modenr; - info->argc = ac - 3; - info->argv = args + 3; - info->flags = (hptr->flags & ~DBA_LOCK_ALL) | (lock_flag & DBA_LOCK_ALL); - info->lock.mode = lock_mode; - - /* if any open call is a locking call: - * check if we already habe a locking call open that should block this call - * the problem is some systems would allow read during write - */ - if (hptr->flags & DBA_LOCK_ALL) { - if ((other = php_dba_find(info->path TSRMLS_CC)) != NULL) { - if ( ( (lock_mode&LOCK_EX) && (other->lock.mode&(LOCK_EX|LOCK_SH)) ) - || ( (other->lock.mode&LOCK_EX) && (lock_mode&(LOCK_EX|LOCK_SH)) ) - ) { - error = "Unable to establish lock (database file already open)"; /* force failure exit */ - } - } - } - - if (!error && lock_mode) { - if (lock_dbf) { - info->lock.name = estrdup(info->path); - lock_file_mode = file_mode; - } else { - spprintf(&info->lock.name, 0, "%s.lck", info->path); - if (!strcmp(file_mode, "r")) { - /* when in read only mode try to use existing .lck file first */ - /* do not log errors for .lck file while in read ony mode on .lck file */ - lock_file_mode = "rb"; - info->lock.fp = php_stream_open_wrapper(info->lock.name, lock_file_mode, STREAM_MUST_SEEK|IGNORE_PATH|ENFORCE_SAFE_MODE, NULL); - } - if (!info->lock.fp) { - /* when not in read mode or failed to open .lck file read only. now try again in create(write) mode and log errors */ - lock_file_mode = "a+b"; - } - } - if (!info->lock.fp) { - info->lock.fp = php_stream_open_wrapper(info->lock.name, lock_file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE, NULL); - } - if (!info->lock.fp) { - dba_close(info TSRMLS_CC); - /* stream operation already wrote an error message */ - FREENOW; - RETURN_FALSE; - } - if (php_stream_cast(info->lock.fp, PHP_STREAM_AS_FD, (void*)&info->lock.fd, 1) == FAILURE) { - dba_close(info TSRMLS_CC); - /* stream operation already wrote an error message */ - FREENOW; - RETURN_FALSE; - } - if (php_flock(info->lock.fd, lock_mode)) { - error = "Unable to establish lock"; /* force failure exit */ - } - } - - /* centralised open stream for builtin */ - if (!error && (hptr->flags&DBA_STREAM_OPEN)==DBA_STREAM_OPEN) { - if (info->lock.fp && lock_dbf) { - info->fp = info->lock.fp; /* use the same stream for locking and database access */ - } else { - info->fp = php_stream_open_wrapper(info->path, file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE, NULL); - } - if (!info->fp) { - dba_close(info TSRMLS_CC); - /* stream operation already wrote an error message */ - FREENOW; - RETURN_FALSE; - } - } - - if (error || hptr->open(info, &error TSRMLS_CC) != SUCCESS) { - dba_close(info TSRMLS_CC); - php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "Driver initialization failed for handler: %s%s%s", Z_STRVAL_PP(args[2]), error?": ":"", error?error:""); - FREENOW; - RETURN_FALSE; - } - - info->hnd = hptr; - info->argc = 0; - info->argv = NULL; - - if (persistent) { - list_entry new_le; - - Z_TYPE(new_le) = le_pdb; - new_le.ptr = info; - if (zend_hash_update(&EG(persistent_list), key, keylen+1, &new_le, sizeof(list_entry), NULL) == FAILURE) { - FREENOW; - RETURN_FALSE; - } - } - - ZEND_REGISTER_RESOURCE(return_value, info, (persistent ? le_pdb : le_db)); - FREENOW; -} -/* }}} */ -#undef FREENOW - -/* {{{ proto int dba_popen(string path, string mode, string handlername [, string ...]) - Opens path using the specified handler in mode persistently */ -PHP_FUNCTION(dba_popen) -{ - php_dba_open(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); -} -/* }}} */ - -/* {{{ proto int dba_open(string path, string mode, string handlername [, string ...]) - Opens path using the specified handler in mode*/ -PHP_FUNCTION(dba_open) -{ - php_dba_open(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); -} -/* }}} */ - -/* {{{ proto void dba_close(resource handle) - Closes database */ -PHP_FUNCTION(dba_close) -{ - DBA_ID_GET1; - - zend_list_delete(Z_RESVAL_PP(id)); -} -/* }}} */ - -/* {{{ proto bool dba_exists(string key, int handle) - Checks, if the specified key exists */ -PHP_FUNCTION(dba_exists) -{ - DBA_ID_GET2; - - if(info->hnd->exists(info, VALLEN(key) TSRMLS_CC) == SUCCESS) { - RETURN_TRUE; - } - RETURN_FALSE; -} -/* }}} */ - -/* {{{ proto string dba_fetch(string key, [int skip ,] int handle) - Fetches the data associated with key */ -PHP_FUNCTION(dba_fetch) -{ - char *val; - int len = 0; - DBA_ID_GET2_3; - - if (ac==3 && strcmp(info->hnd->name, "cdb")) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Handler %s does not support optional skip parameter", info->hnd->name); - } - if((val = info->hnd->fetch(info, VALLEN(key), skip, &len TSRMLS_CC)) != NULL) { - if (val && PG(magic_quotes_runtime)) { - val = php_addslashes(val, len, &len, 1 TSRMLS_CC); - } - RETURN_STRINGL(val, len, 0); - } - RETURN_FALSE; -} -/* }}} */ - -/* {{{ proto string dba_firstkey(int handle) - Resets the internal key pointer and returns the first key */ -PHP_FUNCTION(dba_firstkey) -{ - char *fkey; - int len; - DBA_ID_GET1; - - fkey = info->hnd->firstkey(info, &len TSRMLS_CC); - if(fkey) - RETURN_STRINGL(fkey, len, 0); - RETURN_FALSE; -} -/* }}} */ - -/* {{{ proto string dba_nextkey(int handle) - Returns the next key */ -PHP_FUNCTION(dba_nextkey) -{ - char *nkey; - int len; - DBA_ID_GET1; - - nkey = info->hnd->nextkey(info, &len TSRMLS_CC); - if(nkey) - RETURN_STRINGL(nkey, len, 0); - RETURN_FALSE; -} -/* }}} */ - -/* {{{ proto bool dba_delete(string key, int handle) - Deletes the entry associated with key */ -PHP_FUNCTION(dba_delete) -{ - DBA_ID_GET2; - - DBA_WRITE_CHECK; - - if(info->hnd->delete(info, VALLEN(key) TSRMLS_CC) == SUCCESS) - RETURN_TRUE; - RETURN_FALSE; -} -/* }}} */ - -/* {{{ proto bool dba_insert(string key, string value, int handle) - Inserts value as key, returns false, if key exists already */ -PHP_FUNCTION(dba_insert) -{ - php_dba_update(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); -} -/* }}} */ - -/* {{{ proto bool dba_replace(string key, string value, int handle) - Inserts value as key, replaces key, if key exists already */ -PHP_FUNCTION(dba_replace) -{ - php_dba_update(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); -} -/* }}} */ - -/* {{{ proto bool dba_optimize(int handle) - Optimizes (e.g. clean up, vacuum) database */ -PHP_FUNCTION(dba_optimize) -{ - DBA_ID_GET1; - - DBA_WRITE_CHECK; - if(info->hnd->optimize(info TSRMLS_CC) == SUCCESS) { - RETURN_TRUE; - } - RETURN_FALSE; -} -/* }}} */ - -/* {{{ proto bool dba_sync(int handle) - Synchronizes database */ -PHP_FUNCTION(dba_sync) -{ - DBA_ID_GET1; - - if(info->hnd->sync(info TSRMLS_CC) == SUCCESS) { - RETURN_TRUE; - } - RETURN_FALSE; -} -/* }}} */ - -/* {{{ proto array dba_handlers() - List configured databases */ -PHP_FUNCTION(dba_handlers) -{ - dba_handler *hptr; - - if (ZEND_NUM_ARGS()!=0) { - ZEND_WRONG_PARAM_COUNT(); - RETURN_FALSE; - } - - if (array_init(return_value) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to initialize array"); - RETURN_FALSE; - } - for(hptr = handler; hptr->name; hptr++) { - add_next_index_string(return_value, hptr->name, 1); - } -} -/* }}} */ - -/* {{{ proto array dba_list() - List configured databases */ -PHP_FUNCTION(dba_list) -{ - ulong numitems, i; - zend_rsrc_list_entry *le; - dba_info *info; - - if (ZEND_NUM_ARGS()!=0) { - ZEND_WRONG_PARAM_COUNT(); - RETURN_FALSE; - } - - if (array_init(return_value) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to initialize array"); - RETURN_FALSE; - } - numitems = zend_hash_next_free_element(&EG(regular_list)); - for (i=1; i<numitems; i++) { - if (zend_hash_index_find(&EG(regular_list), i, (void **) &le)==FAILURE) { - continue; - } - if (Z_TYPE_P(le) == le_db || Z_TYPE_P(le) == le_pdb) { - info = (dba_info *)(le->ptr); - add_index_string(return_value, i, info->path, 1); - } - } -} -/* }}} */ - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/ext/dba/dba.dsp b/ext/dba/dba.dsp deleted file mode 100644 index 063d4e3ba2..0000000000 --- a/ext/dba/dba.dsp +++ /dev/null @@ -1,197 +0,0 @@ -# Microsoft Developer Studio Project File - Name="dba" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=dba - Win32 Debug_TS Berkeley DB3
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "dba.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "dba.mak" CFG="dba - Win32 Debug_TS Berkeley DB3"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "dba - Win32 Release_TS Berkeley DB3" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "dba - Win32 Debug_TS Berkeley DB3" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "dba - Win32 Release_TS Berkeley DB3"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_DBA" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DBA=1 /D DBA_DB3=1 /D DB3_INCLUDE_FILE="db.h" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=0 /D DBA_DB3=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_DBA" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DBA=1 /D DBA_FLATFILE=1 /D DBA_CDB=1 /D DBA_CDB_MAKE=1 /D DBA_CDB_BUILTIN=1 /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x407 /d "NDEBUG"
-# ADD RSC /l 0x407 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 php4ts.lib libdb31s.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_dba.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline"
-# ADD LINK32 php4ts.lib libdb31s.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_dba.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline"
-
-!ELSEIF "$(CFG)" == "dba - Win32 Debug_TS Berkeley DB3"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_DBA" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DBA=1 /D "DBA_DB3" /D DB3_INCLUDE_FILE="db.h" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=1 /D "DBA_DB3" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_DBA" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DBA=1 /D DBA_FLATFILE=1 /D DBA_CDB=1 /D DBA_CDB_MAKE=1 /D DBA_CDB_BUILTIN=1 /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x407 /d "_DEBUG"
-# ADD RSC /l 0x407 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 php4ts_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS/php_dba.dll" /pdbtype:sept /libpath:"..\..\Debug_TS"
-# ADD LINK32 php4ts_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS/php_dba.dll" /pdbtype:sept /libpath:"..\..\Debug_TS"
-
-!ENDIF
-
-# Begin Target
-
-# Name "dba - Win32 Release_TS Berkeley DB3"
-# Name "dba - Win32 Debug_TS Berkeley DB3"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\libcdb\cdb.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libcdb\cdb_make.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\dba.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\dba_cdb.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\dba_db2.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\dba_db3.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\dba_dbm.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\dba_flatfile.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\dba_gdbm.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\dba_ndbm.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libflatfile\flatfile.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libcdb\uint32.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\libcdb\cdb.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libcdb\cdb_make.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libflatfile\flatfile.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_cdb.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_db2.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_db3.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_dba.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_dbm.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_flatfile.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_gdbm.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_ndbm.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libcdb\uint32.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/ext/dba/dba_cdb.c b/ext/dba/dba_cdb.c deleted file mode 100644 index e04545e65f..0000000000 --- a/ext/dba/dba_cdb.c +++ /dev/null @@ -1,336 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Sascha Schumann <sascha@schumann.cx> | - | Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" - -#if DBA_CDB -#include "php_cdb.h" - -#include <sys/types.h> -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#include <fcntl.h> - -#if DBA_CDB_BUILTIN -#include "libcdb/cdb.h" -#include "libcdb/cdb_make.h" -#include "libcdb/uint32.h" -#else -#include <cdb.h> -#include <uint32.h> -#endif - -#define CDB_INFO \ - dba_cdb *cdb = (dba_cdb *) info->dbf - -typedef struct { - struct cdb c; -#if DBA_CDB_BUILTIN - struct cdb_make m; - php_stream *file; - int make; -#else - int file; -#endif - uint32 eod; /* size of constant database */ - uint32 pos; /* current position for traversing */ -} dba_cdb; - -DBA_OPEN_FUNC(cdb) -{ -#if DBA_CDB_BUILTIN - php_stream* file = 0; - int make; -#else - int file = 0; -#endif - dba_cdb *cdb; - dba_info *pinfo = (dba_info *) info; - - switch (info->mode) { - case DBA_READER: -#if DBA_CDB_BUILTIN - make = 0; - file = info->fp; -#else - file = VCWD_OPEN(info->path, O_RDONLY); - if (file < 0) { - *error = "Unable to open file"; - return FAILURE; - } -#endif - break; -#if DBA_CDB_BUILTIN - case DBA_TRUNC: - case DBA_CREAT: - make = 1; - file = info->fp; - break; - case DBA_WRITER: - *error = "Update operations are not supported"; - return FAILURE; /* not supported */ -#endif - default: - *error = "Currently not supported"; - return FAILURE; - } - - cdb = emalloc(sizeof(dba_cdb)); - memset(cdb, 0, sizeof(dba_cdb)); - -#if DBA_CDB_BUILTIN - if (make) { - cdb_make_start(&cdb->m, file TSRMLS_CC); - } else { - cdb_init(&cdb->c, file TSRMLS_CC); - } - cdb->make = make; -#else - cdb_init(&cdb->c, file); -#endif - cdb->file = file; - - pinfo->dbf = cdb; - return SUCCESS; -} - -DBA_CLOSE_FUNC(cdb) -{ - CDB_INFO; - - /* cdb_free does not close associated file */ -#if DBA_CDB_BUILTIN - if (cdb->make) { - cdb_make_finish(&cdb->m TSRMLS_CC); - } else { - cdb_free(&cdb->c TSRMLS_CC); - } -#else - cdb_free(&cdb->c); - close(cdb->file); -#endif - efree(cdb); -} - -#if DBA_CDB_BUILTIN -# define php_cdb_read(cdb, buf, len, pos) cdb_read(cdb, buf, len, pos TSRMLS_CC) -# define php_cdb_findnext(cdb, key, len) cdb_findnext(cdb, key, len TSRMLS_CC) -# define php_cdb_find(cdb, key, len) cdb_find(cdb, key, len TSRMLS_CC) -#else -# define php_cdb_read(cdb, buf, len, pos) cdb_read(cdb, buf, len, pos) -# define php_cdb_findnext(cdb, key, len) cdb_findnext(cdb, key, len) -# define php_cdb_find(cdb, key, len) cdb_find(cdb, key, len) -#endif - -DBA_FETCH_FUNC(cdb) -{ - CDB_INFO; - unsigned int len; - char *new_entry = NULL; - -#if DBA_CDB_BUILTIN - if (cdb->make) - return NULL; /* database was opened writeonly */ -#endif - if (php_cdb_find(&cdb->c, key, keylen) == 1) { - while(skip--) { - if (php_cdb_findnext(&cdb->c, key, keylen) != 1) { - return NULL; - } - } - len = cdb_datalen(&cdb->c); - new_entry = emalloc(len+1); - - if (php_cdb_read(&cdb->c, new_entry, len, cdb_datapos(&cdb->c)) == -1) { - efree(new_entry); - return NULL; - } - new_entry[len] = 0; - if (newlen) - *newlen = len; - } - - return new_entry; -} - -DBA_UPDATE_FUNC(cdb) -{ -#if DBA_CDB_BUILTIN - CDB_INFO; - - if (!cdb->make) - return FAILURE; /* database was opened readonly */ - if (!mode) - return FAILURE; /* cdb_make dosn't know replace */ - if (cdb_make_add(&cdb->m, key, keylen, val, vallen TSRMLS_CC) != -1) - return SUCCESS; -#endif - return FAILURE; -} - -DBA_EXISTS_FUNC(cdb) -{ - CDB_INFO; - -#if DBA_CDB_BUILTIN - if (cdb->make) - return FAILURE; /* database was opened writeonly */ -#endif - if (php_cdb_find(&cdb->c, key, keylen) == 1) - return SUCCESS; - return FAILURE; -} - -DBA_DELETE_FUNC(cdb) -{ - return FAILURE; /* cdb doesn't support delete */ -} - -/* {{{ cdb_file_read */ -#if DBA_CDB_BUILTIN -# define cdb_file_read(fildes, buf, size) php_stream_read(fildes, buf, size) -#else -# define cdb_file_read(fildes, buf, size) read(fildes, buf, size) -#endif -/* }}} */ - -#define CREAD(n) do { \ - if (cdb_file_read(cdb->file, buf, n) < n) return NULL; \ -} while (0) - -/* {{{ cdb_file_lseek - php_stream_seek does not return actual position */ -#if DBA_CDB_BUILTIN -int cdb_file_lseek(php_stream *fp, off_t offset, int whence TSRMLS_DC) { - php_stream_seek(fp, offset, whence); - return php_stream_tell(fp); -} -#else -int cdb_file_lseek(int fd, off_t offset, int whence TSRMLS_DC) { - return lseek(fd, offset, whence); -} -#endif -/* }}} */ - -#define CSEEK(n) do { \ - if (n >= cdb->eod) return NULL; \ - if (cdb_file_lseek(cdb->file, (off_t)n, SEEK_SET TSRMLS_CC) != (off_t) n) return NULL; \ -} while (0) - - -DBA_FIRSTKEY_FUNC(cdb) -{ - CDB_INFO; - uint32 klen, dlen; - char buf[8]; - char *key; - -#if DBA_CDB_BUILTIN - if (cdb->make) - return NULL; /* database was opened writeonly */ -#endif - - cdb->eod = -1; - CSEEK(0); - CREAD(4); - - /* Total length of file in bytes */ - uint32_unpack(buf, &cdb->eod); - - CSEEK(2048); - CREAD(8); - - /* The first four bytes contain the length of the key */ - uint32_unpack(buf, &klen); - uint32_unpack(buf + 4, &dlen); - - key = emalloc(klen + 1); - if (cdb_file_read(cdb->file, key, klen) < klen) { - efree(key); - key = NULL; - } else { - key[klen] = '\0'; - if (newlen) *newlen = klen; - } - - /* header + klenlen + dlenlen + klen + dlen */ - cdb->pos = 2048 + 4 + 4 + klen + dlen; - - return key; -} - -DBA_NEXTKEY_FUNC(cdb) -{ - CDB_INFO; - uint32 klen, dlen; - char buf[8]; - char *key; - -#if DBA_CDB_BUILTIN - if (cdb->make) - return NULL; /* database was opened writeonly */ -#endif - - CSEEK(cdb->pos); - CREAD(8); - uint32_unpack(buf, &klen); - uint32_unpack(buf + 4, &dlen); - - key = emalloc(klen + 1); - if (cdb_file_read(cdb->file, key, klen) < klen) { - efree(key); - key = NULL; - } else { - key[klen] = '\0'; - if (newlen) *newlen = klen; - } - - cdb->pos += 8 + klen + dlen; - - return key; -} - -DBA_OPTIMIZE_FUNC(cdb) -{ - return SUCCESS; -} - -DBA_SYNC_FUNC(cdb) -{ - /* this is read-only */ - return SUCCESS; -} - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/ext/dba/dba_db2.c b/ext/dba/dba_db2.c deleted file mode 100644 index 580e6f62e2..0000000000 --- a/ext/dba/dba_db2.c +++ /dev/null @@ -1,200 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" - -#if DBA_DB2 -#include "php_db2.h" -#include <sys/stat.h> - -#include <string.h> -#ifdef DB2_INCLUDE_FILE -#include DB2_INCLUDE_FILE -#endif - -#define DB2_DATA dba_db2_data *dba = info->dbf -#define DB2_GKEY \ - DBT gkey = {0}; \ - gkey.data = (char *) key; \ - gkey.size = keylen - -typedef struct { - DB *dbp; - DBC *cursor; -} dba_db2_data; - -DBA_OPEN_FUNC(db2) -{ - DB *dbp; - DBTYPE type; - int gmode = 0; - int filemode = 0644; - struct stat check_stat; - int s = VCWD_STAT(info->path, &check_stat); - - type = info->mode == DBA_READER ? DB_UNKNOWN : - info->mode == DBA_TRUNC ? DB_BTREE : - s ? DB_BTREE : DB_UNKNOWN; - - gmode = info->mode == DBA_READER ? DB_RDONLY : - (info->mode == DBA_CREAT && s) ? DB_CREATE : - (info->mode == DBA_CREAT && !s) ? 0 : - info->mode == DBA_WRITER ? 0 : - info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1; - - if (gmode == -1) { - return FAILURE;/* not possible */ - } - - if (info->argc > 0) { - convert_to_long_ex(info->argv[0]); - filemode = Z_LVAL_PP(info->argv[0]); - } - - if (db_open(info->path, type, gmode, filemode, NULL, NULL, &dbp)) { - return FAILURE; - } - - info->dbf = emalloc(sizeof(dba_db2_data)); - memset(info->dbf, 0, sizeof(dba_db2_data)); - ((dba_db2_data *) info->dbf)->dbp = dbp; - return SUCCESS; -} - -DBA_CLOSE_FUNC(db2) -{ - DB2_DATA; - - if (dba->cursor) - dba->cursor->c_close(dba->cursor); - dba->dbp->close(dba->dbp, 0); - efree(dba); -} - -DBA_FETCH_FUNC(db2) -{ - DBT gval = {0}; - DB2_DATA; - DB2_GKEY; - - if (dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) { - return NULL; - } - - if (newlen) *newlen = gval.size; - return estrndup(gval.data, gval.size); -} - -DBA_UPDATE_FUNC(db2) -{ - DBT gval = {0}; - DB2_DATA; - DB2_GKEY; - - gval.data = (char *) val; - gval.size = vallen; - - if (dba->dbp->put(dba->dbp, NULL, &gkey, &gval, - mode == 1 ? DB_NOOVERWRITE : 0)) { - return FAILURE; - } - return SUCCESS; -} - -DBA_EXISTS_FUNC(db2) -{ - DBT gval = {0}; - DB2_DATA; - DB2_GKEY; - - if (dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) { - return FAILURE; - } - return SUCCESS; -} - -DBA_DELETE_FUNC(db2) -{ - DB2_DATA; - DB2_GKEY; - - return dba->dbp->del(dba->dbp, NULL, &gkey, 0) ? FAILURE : SUCCESS; -} - -DBA_FIRSTKEY_FUNC(db2) -{ - DB2_DATA; - - if (dba->cursor) { - dba->cursor->c_close(dba->cursor); - dba->cursor = NULL; - } - -#if (DB_VERSION_MAJOR > 2) || (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR > 6) || (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 6 && DB_VERSION_PATCH >= 4) - if (dba->dbp->cursor(dba->dbp, NULL, &dba->cursor, 0)) { -#else - if (dba->dbp->cursor(dba->dbp, NULL, &dba->cursor)) { -#endif - return NULL; - } - - /* we should introduce something like PARAM_PASSTHRU... */ - return dba_nextkey_db2(info, newlen TSRMLS_CC); -} - -DBA_NEXTKEY_FUNC(db2) -{ - DB2_DATA; - DBT gkey = {0}, gval = {0}; - - if (dba->cursor->c_get(dba->cursor, &gkey, &gval, DB_NEXT) - || !gkey.data) - return NULL; - - if (newlen) *newlen = gkey.size; - return estrndup(gkey.data, gkey.size); -} - -DBA_OPTIMIZE_FUNC(db2) -{ - return SUCCESS; -} - -DBA_SYNC_FUNC(db2) -{ - DB2_DATA; - - return dba->dbp->sync(dba->dbp, 0) ? FAILURE : SUCCESS; -} - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/ext/dba/dba_db3.c b/ext/dba/dba_db3.c deleted file mode 100644 index dd93693d0a..0000000000 --- a/ext/dba/dba_db3.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" - -#if DBA_DB3 -#include "php_db3.h" -#include <sys/stat.h> - -#include <string.h> -#ifdef DB3_INCLUDE_FILE -#include DB3_INCLUDE_FILE -#else -#include <db.h> -#endif - -#define DB3_DATA dba_db3_data *dba = info->dbf -#define DB3_GKEY \ - DBT gkey; \ - memset(&gkey, 0, sizeof(gkey)); \ - gkey.data = (char *) key; gkey.size = keylen - -typedef struct { - DB *dbp; - DBC *cursor; -} dba_db3_data; - -DBA_OPEN_FUNC(db3) -{ - DB *dbp = NULL; - DBTYPE type; - int gmode = 0; - int filemode = 0644; - struct stat check_stat; - int s = VCWD_STAT(info->path, &check_stat); - - type = info->mode == DBA_READER ? DB_UNKNOWN : - info->mode == DBA_TRUNC ? DB_BTREE : - s? DB_BTREE : DB_UNKNOWN; - - gmode = info->mode == DBA_READER ? DB_RDONLY : - (info->mode == DBA_CREAT && s) ? DB_CREATE : - (info->mode == DBA_CREAT && !s) ? 0 : - info->mode == DBA_WRITER ? 0 : - info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1; - - if (gmode == -1) - return FAILURE; /* not possible */ - - if (info->argc > 0) { - convert_to_long_ex(info->argv[0]); - filemode = Z_LVAL_PP(info->argv[0]); - } - - if (db_create(&dbp, NULL, 0) == 0 && -#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1) - dbp->open(dbp, 0, info->path, NULL, type, gmode, filemode) == 0) { -#else - dbp->open(dbp, info->path, NULL, type, gmode, filemode) == 0) { -#endif - dba_db3_data *data; - - data = emalloc(sizeof(*data)); - data->dbp = dbp; - data->cursor = NULL; - info->dbf = data; - - return SUCCESS; - } else if (dbp != NULL) { - dbp->close(dbp, 0); - } - - return FAILURE; -} - -DBA_CLOSE_FUNC(db3) -{ - DB3_DATA; - - if (dba->cursor) dba->cursor->c_close(dba->cursor); - dba->dbp->close(dba->dbp, 0); - efree(dba); -} - -DBA_FETCH_FUNC(db3) -{ - DBT gval; - char *new = NULL; - DB3_DATA; - DB3_GKEY; - - memset(&gval, 0, sizeof(gval)); - if (!dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) { - if (newlen) *newlen = gval.size; - new = estrndup(gval.data, gval.size); - } - return new; -} - -DBA_UPDATE_FUNC(db3) -{ - DBT gval; - DB3_DATA; - DB3_GKEY; - - memset(&gval, 0, sizeof(gval)); - gval.data = (char *) val; - gval.size = vallen; - - if (!dba->dbp->put(dba->dbp, NULL, &gkey, &gval, - mode == 1 ? DB_NOOVERWRITE : 0)) { - return SUCCESS; - } - return FAILURE; -} - -DBA_EXISTS_FUNC(db3) -{ - DBT gval; - DB3_DATA; - DB3_GKEY; - - memset(&gval, 0, sizeof(gval)); - if (!dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) { - return SUCCESS; - } - return FAILURE; -} - -DBA_DELETE_FUNC(db3) -{ - DB3_DATA; - DB3_GKEY; - - return dba->dbp->del(dba->dbp, NULL, &gkey, 0) ? FAILURE : SUCCESS; -} - -DBA_FIRSTKEY_FUNC(db3) -{ - DB3_DATA; - - if (dba->cursor) { - dba->cursor->c_close(dba->cursor); - } - - dba->cursor = NULL; - if (dba->dbp->cursor(dba->dbp, NULL, &dba->cursor, 0) != 0) { - return NULL; - } - - /* we should introduce something like PARAM_PASSTHRU... */ - return dba_nextkey_db3(info, newlen TSRMLS_CC); -} - -DBA_NEXTKEY_FUNC(db3) -{ - DB3_DATA; - DBT gkey, gval; - char *nkey = NULL; - - memset(&gkey, 0, sizeof(gkey)); - memset(&gval, 0, sizeof(gval)); - - if (dba->cursor->c_get(dba->cursor, &gkey, &gval, DB_NEXT) == 0) { - if (gkey.data) { - nkey = estrndup(gkey.data, gkey.size); - if (newlen) *newlen = gkey.size; - } - } - - return nkey; -} - -DBA_OPTIMIZE_FUNC(db3) -{ - return SUCCESS; -} - -DBA_SYNC_FUNC(db3) -{ - DB3_DATA; - - return dba->dbp->sync(dba->dbp, 0) ? FAILURE : SUCCESS; -} - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/ext/dba/dba_db4.c b/ext/dba/dba_db4.c deleted file mode 100644 index 06c6cdbd32..0000000000 --- a/ext/dba/dba_db4.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" - -#if DBA_DB4 -#include "php_db4.h" -#include <sys/stat.h> - -#include <string.h> -#ifdef DB4_INCLUDE_FILE -#include DB4_INCLUDE_FILE -#else -#include <db.h> -#endif - -#define DB4_DATA dba_db4_data *dba = info->dbf -#define DB4_GKEY \ - DBT gkey; \ - memset(&gkey, 0, sizeof(gkey)); \ - gkey.data = (char *) key; gkey.size = keylen - -typedef struct { - DB *dbp; - DBC *cursor; -} dba_db4_data; - -DBA_OPEN_FUNC(db4) -{ - DB *dbp = NULL; - DBTYPE type; - int gmode = 0; - int filemode = 0644; - struct stat check_stat; - int s = VCWD_STAT(info->path, &check_stat); - - type = info->mode == DBA_READER ? DB_UNKNOWN : - info->mode == DBA_TRUNC ? DB_BTREE : - s? DB_BTREE : DB_UNKNOWN; - - gmode = info->mode == DBA_READER ? DB_RDONLY : - (info->mode == DBA_CREAT && s) ? DB_CREATE : - (info->mode == DBA_CREAT && !s) ? 0 : - info->mode == DBA_WRITER ? 0 : - info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1; - - if (gmode == -1) - return FAILURE; /* not possible */ - - if (info->argc > 0) { - convert_to_long_ex(info->argv[0]); - filemode = Z_LVAL_PP(info->argv[0]); - } - - if (db_create(&dbp, NULL, 0) == 0 && -#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1) - dbp->open(dbp, 0, info->path, NULL, type, gmode, filemode) == 0) { -#else - dbp->open(dbp, info->path, NULL, type, gmode, filemode) == 0) { -#endif - dba_db4_data *data; - - data = emalloc(sizeof(*data)); - data->dbp = dbp; - data->cursor = NULL; - info->dbf = data; - - return SUCCESS; - } else if (dbp != NULL) { - dbp->close(dbp, 0); - } - - return FAILURE; -} - -DBA_CLOSE_FUNC(db4) -{ - DB4_DATA; - - if (dba->cursor) dba->cursor->c_close(dba->cursor); - dba->dbp->close(dba->dbp, 0); - efree(dba); -} - -DBA_FETCH_FUNC(db4) -{ - DBT gval; - char *new = NULL; - DB4_DATA; - DB4_GKEY; - - memset(&gval, 0, sizeof(gval)); - if (!dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) { - if (newlen) *newlen = gval.size; - new = estrndup(gval.data, gval.size); - } - return new; -} - -DBA_UPDATE_FUNC(db4) -{ - DBT gval; - DB4_DATA; - DB4_GKEY; - - memset(&gval, 0, sizeof(gval)); - gval.data = (char *) val; - gval.size = vallen; - - if (!dba->dbp->put(dba->dbp, NULL, &gkey, &gval, - mode == 1 ? DB_NOOVERWRITE : 0)) { - return SUCCESS; - } - return FAILURE; -} - -DBA_EXISTS_FUNC(db4) -{ - DBT gval; - DB4_DATA; - DB4_GKEY; - - memset(&gval, 0, sizeof(gval)); - if (!dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) { - return SUCCESS; - } - return FAILURE; -} - -DBA_DELETE_FUNC(db4) -{ - DB4_DATA; - DB4_GKEY; - - return dba->dbp->del(dba->dbp, NULL, &gkey, 0) ? FAILURE : SUCCESS; -} - -DBA_FIRSTKEY_FUNC(db4) -{ - DB4_DATA; - - if (dba->cursor) { - dba->cursor->c_close(dba->cursor); - } - - dba->cursor = NULL; - if (dba->dbp->cursor(dba->dbp, NULL, &dba->cursor, 0) != 0) { - return NULL; - } - - /* we should introduce something like PARAM_PASSTHRU... */ - return dba_nextkey_db4(info, newlen TSRMLS_CC); -} - -DBA_NEXTKEY_FUNC(db4) -{ - DB4_DATA; - DBT gkey, gval; - char *nkey = NULL; - - memset(&gkey, 0, sizeof(gkey)); - memset(&gval, 0, sizeof(gval)); - - if (dba->cursor->c_get(dba->cursor, &gkey, &gval, DB_NEXT) == 0) { - if (gkey.data) { - nkey = estrndup(gkey.data, gkey.size); - if (newlen) *newlen = gkey.size; - } - } - - return nkey; -} - -DBA_OPTIMIZE_FUNC(db4) -{ - return SUCCESS; -} - -DBA_SYNC_FUNC(db4) -{ - DB4_DATA; - - return dba->dbp->sync(dba->dbp, 0) ? FAILURE : SUCCESS; -} - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/ext/dba/dba_dbm.c b/ext/dba/dba_dbm.c deleted file mode 100644 index 4eca420786..0000000000 --- a/ext/dba/dba_dbm.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" - -#if DBA_DBM -#include "php_dbm.h" - -#include <dbm.h> - -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -#define DBM_DATA dba_dbm_data *dba = info->dbf -#define DBM_GKEY datum gkey; gkey.dptr = (char *) key; gkey.dsize = keylen - -#define TRUNC_IT(extension, mode) \ - snprintf(buf, MAXPATHLEN, "%s" extension, info->path); \ - buf[MAXPATHLEN-1] = '\0'; \ - if((fd = VCWD_OPEN_MODE(buf, O_CREAT | mode | O_WRONLY, filemode)) == -1) \ - return FAILURE; \ - close(fd); - - -typedef struct { - datum nextkey; -} dba_dbm_data; - -DBA_OPEN_FUNC(dbm) -{ - int fd; - int filemode = 0644; - - if(info->argc > 0) { - convert_to_long_ex(info->argv[0]); - filemode = Z_LVAL_PP(info->argv[0]); - } - - if(info->mode == DBA_TRUNC) { - char buf[MAXPATHLEN]; - - /* dbm/ndbm original */ - TRUNC_IT(".pag", O_TRUNC); - TRUNC_IT(".dir", O_TRUNC); - } - - if(info->mode == DBA_CREAT) { - char buf[MAXPATHLEN]; - - TRUNC_IT(".pag", 0); - TRUNC_IT(".dir", 0); - } - - if(dbminit((char *) info->path) == -1) { - return FAILURE; - } - - info->dbf = emalloc(sizeof(dba_dbm_data)); - memset(info->dbf, 0, sizeof(dba_dbm_data)); - return SUCCESS; -} - -DBA_CLOSE_FUNC(dbm) -{ - efree(info->dbf); - dbmclose(); -} - -DBA_FETCH_FUNC(dbm) -{ - datum gval; - char *new = NULL; - - DBM_GKEY; - gval = fetch(gkey); - if(gval.dptr) { - if(newlen) *newlen = gval.dsize; - new = estrndup(gval.dptr, gval.dsize); - } - return new; -} - -DBA_UPDATE_FUNC(dbm) -{ - datum gval; - - DBM_GKEY; - gval.dptr = (char *) val; - gval.dsize = vallen; - - return (store(gkey, gval) == -1 ? FAILURE : SUCCESS); -} - -DBA_EXISTS_FUNC(dbm) -{ - datum gval; - DBM_GKEY; - - gval = fetch(gkey); - if(gval.dptr) { - return SUCCESS; - } - return FAILURE; -} - -DBA_DELETE_FUNC(dbm) -{ - DBM_GKEY; - return(delete(gkey) == -1 ? FAILURE : SUCCESS); -} - -DBA_FIRSTKEY_FUNC(dbm) -{ - DBM_DATA; - datum gkey; - char *key = NULL; - - gkey = firstkey(); - if(gkey.dptr) { - if(newlen) *newlen = gkey.dsize; - key = estrndup(gkey.dptr, gkey.dsize); - dba->nextkey = gkey; - } else - dba->nextkey.dptr = NULL; - return key; -} - -DBA_NEXTKEY_FUNC(dbm) -{ - DBM_DATA; - datum gkey; - char *nkey = NULL; - - if(!dba->nextkey.dptr) return NULL; - - gkey = nextkey(dba->nextkey); - if(gkey.dptr) { - if(newlen) *newlen = gkey.dsize; - nkey = estrndup(gkey.dptr, gkey.dsize); - dba->nextkey = gkey; - } else - dba->nextkey.dptr = NULL; - return nkey; -} - -DBA_OPTIMIZE_FUNC(dbm) -{ - /* dummy */ - return SUCCESS; -} - -DBA_SYNC_FUNC(dbm) -{ - return SUCCESS; -} - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/ext/dba/dba_flatfile.c b/ext/dba/dba_flatfile.c deleted file mode 100644 index a22866c456..0000000000 --- a/ext/dba/dba_flatfile.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" - -#if DBA_FLATFILE -#include "php_flatfile.h" - -#include "libflatfile/flatfile.h" - -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -#define FLATFILE_DATA flatfile *dba = info->dbf -#define FLATFILE_GKEY datum gkey; gkey.dptr = (char *) key; gkey.dsize = keylen - -DBA_OPEN_FUNC(flatfile) -{ - info->dbf = emalloc(sizeof(flatfile)); - memset(info->dbf, 0, sizeof(flatfile)); - - ((flatfile*)info->dbf)->fp = info->fp; - - return SUCCESS; -} - -DBA_CLOSE_FUNC(flatfile) -{ - FLATFILE_DATA; - - if (dba->nextkey.dptr) - efree(dba->nextkey.dptr); - efree(dba); -} - -DBA_FETCH_FUNC(flatfile) -{ - datum gval; - char *new = NULL; - - FLATFILE_DATA; - FLATFILE_GKEY; - - gval = flatfile_fetch(dba, gkey TSRMLS_CC); - if(gval.dptr) { - if(newlen) *newlen = gval.dsize; - new = estrndup(gval.dptr, gval.dsize); - efree(gval.dptr); - } - return new; -} - -DBA_UPDATE_FUNC(flatfile) -{ - datum gval; - - FLATFILE_DATA; - FLATFILE_GKEY; - gval.dptr = (char *) val; - gval.dsize = vallen; - - switch(flatfile_store(dba, gkey, gval, mode==1 ? FLATFILE_INSERT : FLATFILE_REPLACE TSRMLS_CC)) { - case -1: - php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Operation not possible"); - return FAILURE; - default: - case 0: - return SUCCESS; - case 1: - php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Key already exists"); - return SUCCESS; - } -} - -DBA_EXISTS_FUNC(flatfile) -{ - datum gval; - FLATFILE_DATA; - FLATFILE_GKEY; - - gval = flatfile_fetch(dba, gkey TSRMLS_CC); - if(gval.dptr) { - efree(gval.dptr); - return SUCCESS; - } - return FAILURE; -} - -DBA_DELETE_FUNC(flatfile) -{ - FLATFILE_DATA; - FLATFILE_GKEY; - return(flatfile_delete(dba, gkey TSRMLS_CC) == -1 ? FAILURE : SUCCESS); -} - -DBA_FIRSTKEY_FUNC(flatfile) -{ - FLATFILE_DATA; - - if (dba->nextkey.dptr) - efree(dba->nextkey.dptr); - dba->nextkey = flatfile_firstkey(dba TSRMLS_CC); - if(dba->nextkey.dptr) { - if(newlen) - *newlen = dba->nextkey.dsize; - return estrndup(dba->nextkey.dptr, dba->nextkey.dsize); - } - return NULL; -} - -DBA_NEXTKEY_FUNC(flatfile) -{ - FLATFILE_DATA; - - if(!dba->nextkey.dptr) - return NULL; - - if (dba->nextkey.dptr) - efree(dba->nextkey.dptr); - dba->nextkey = flatfile_nextkey(dba TSRMLS_CC); - if(dba->nextkey.dptr) { - if(newlen) - *newlen = dba->nextkey.dsize; - return estrndup(dba->nextkey.dptr, dba->nextkey.dsize); - } - return NULL; -} - -DBA_OPTIMIZE_FUNC(flatfile) -{ - /* dummy */ - return SUCCESS; -} - -DBA_SYNC_FUNC(flatfile) -{ - /* dummy */ - return SUCCESS; -} - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/ext/dba/dba_gdbm.c b/ext/dba/dba_gdbm.c deleted file mode 100644 index 18288ace27..0000000000 --- a/ext/dba/dba_gdbm.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" - -#if DBA_GDBM -#include "php_gdbm.h" - -#include <gdbm.h> - -#define GDBM_DATA dba_gdbm_data *dba = info->dbf -#define GDBM_GKEY datum gkey; gkey.dptr = (char *) key; gkey.dsize = keylen - -typedef struct { - GDBM_FILE dbf; - datum nextkey; -} dba_gdbm_data; - -DBA_OPEN_FUNC(gdbm) -{ - GDBM_FILE dbf; - int gmode = 0; - int filemode = 0644; - - gmode = info->mode == DBA_READER ? GDBM_READER : - info->mode == DBA_WRITER ? GDBM_WRITER : - info->mode == DBA_CREAT ? GDBM_WRCREAT : - info->mode == DBA_TRUNC ? GDBM_NEWDB : -1; - - if(gmode == -1) - return FAILURE; /* not possible */ - - if(info->argc > 0) { - convert_to_long_ex(info->argv[0]); - filemode = Z_LVAL_PP(info->argv[0]); - } - - dbf = gdbm_open(info->path, 0, gmode, filemode, NULL); - - if(dbf) { - info->dbf = emalloc(sizeof(dba_gdbm_data)); - memset(info->dbf, 0, sizeof(dba_gdbm_data)); - ((dba_gdbm_data *) info->dbf)->dbf = dbf; - return SUCCESS; - } - *error = gdbm_strerror(gdbm_errno); - return FAILURE; -} - -DBA_CLOSE_FUNC(gdbm) -{ - GDBM_DATA; - - if(dba->nextkey.dptr) free(dba->nextkey.dptr); - gdbm_close(dba->dbf); - efree(dba); -} - -DBA_FETCH_FUNC(gdbm) -{ - GDBM_DATA; - datum gval; - char *new = NULL; - - GDBM_GKEY; - gval = gdbm_fetch(dba->dbf, gkey); - if(gval.dptr) { - if(newlen) *newlen = gval.dsize; - new = estrndup(gval.dptr, gval.dsize); - free(gval.dptr); - } - return new; -} - -DBA_UPDATE_FUNC(gdbm) -{ - datum gval; - GDBM_DATA; - - GDBM_GKEY; - gval.dptr = (char *) val; - gval.dsize = vallen; - - if(gdbm_store(dba->dbf, gkey, gval, - mode == 1 ? GDBM_INSERT : GDBM_REPLACE) == 0) - return SUCCESS; - php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "%s", gdbm_strerror(gdbm_errno)); - return FAILURE; -} - -DBA_EXISTS_FUNC(gdbm) -{ - GDBM_DATA; - GDBM_GKEY; - - return gdbm_exists(dba->dbf, gkey) ? SUCCESS : FAILURE; -} - -DBA_DELETE_FUNC(gdbm) -{ - GDBM_DATA; - GDBM_GKEY; - - return gdbm_delete(dba->dbf, gkey) == -1 ? FAILURE : SUCCESS; -} - -DBA_FIRSTKEY_FUNC(gdbm) -{ - GDBM_DATA; - datum gkey; - char *key = NULL; - - if(dba->nextkey.dptr) { - free(dba->nextkey.dptr); - } - - gkey = gdbm_firstkey(dba->dbf); - if(gkey.dptr) { - key = estrndup(gkey.dptr, gkey.dsize); - if(newlen) *newlen = gkey.dsize; - dba->nextkey = gkey; - } else { - dba->nextkey.dptr = NULL; - } - return key; -} - -DBA_NEXTKEY_FUNC(gdbm) -{ - GDBM_DATA; - char *nkey = NULL; - datum gkey; - - if(!dba->nextkey.dptr) return NULL; - - gkey = gdbm_nextkey(dba->dbf, dba->nextkey); - free(dba->nextkey.dptr); - if(gkey.dptr) { - nkey = estrndup(gkey.dptr, gkey.dsize); - if(newlen) *newlen = gkey.dsize; - dba->nextkey = gkey; - } else { - dba->nextkey.dptr = NULL; - } - return nkey; -} - -DBA_OPTIMIZE_FUNC(gdbm) -{ - GDBM_DATA; - gdbm_reorganize(dba->dbf); - return SUCCESS; -} - -DBA_SYNC_FUNC(gdbm) -{ - GDBM_DATA; - - gdbm_sync(dba->dbf); - return SUCCESS; -} -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/ext/dba/dba_ndbm.c b/ext/dba/dba_ndbm.c deleted file mode 100644 index 06583c780b..0000000000 --- a/ext/dba/dba_ndbm.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" - -#if DBA_NDBM -#include "php_ndbm.h" - -#include <fcntl.h> -#ifdef NDBM_INCLUDE_FILE -#include NDBM_INCLUDE_FILE -#endif - -#define NDBM_GKEY datum gkey; gkey.dptr = (char *) key; gkey.dsize = keylen - -DBA_OPEN_FUNC(ndbm) -{ - DBM *dbf; - int gmode = 0; - int filemode = 0644; - dba_info *pinfo = (dba_info *) info; - - switch(info->mode) { - case DBA_READER: - gmode = O_RDONLY; - break; - case DBA_WRITER: - gmode = O_RDWR; - break; - case DBA_CREAT: - gmode = O_RDWR | O_CREAT; - break; - case DBA_TRUNC: - gmode = O_RDWR | O_CREAT | O_TRUNC; - break; - default: - return FAILURE; /* not possible */ - } - - if(info->argc > 0) { - convert_to_long_ex(info->argv[0]); - filemode = Z_LVAL_PP(info->argv[0]); - } - - dbf = dbm_open(info->path, gmode, filemode); - - pinfo->dbf = dbf; - return SUCCESS; -} - -DBA_CLOSE_FUNC(ndbm) -{ - dbm_close(info->dbf); -} - -DBA_FETCH_FUNC(ndbm) -{ - datum gval; - char *new = NULL; - - NDBM_GKEY; - gval = dbm_fetch(info->dbf, gkey); - if(gval.dptr) { - if(newlen) *newlen = gval.dsize; - new = estrndup(gval.dptr, gval.dsize); - } - return new; -} - -DBA_UPDATE_FUNC(ndbm) -{ - datum gval; - - NDBM_GKEY; - gval.dptr = (char *) val; - gval.dsize = vallen; - - if(!dbm_store(info->dbf, gkey, gval, mode == 1 ? DBM_INSERT : DBM_REPLACE)) - return SUCCESS; - return FAILURE; -} - -DBA_EXISTS_FUNC(ndbm) -{ - datum gval; - NDBM_GKEY; - gval = dbm_fetch(info->dbf, gkey); - if(gval.dptr) { - return SUCCESS; - } - return FAILURE; -} - -DBA_DELETE_FUNC(ndbm) -{ - NDBM_GKEY; - return(dbm_delete(info->dbf, gkey) == -1 ? FAILURE : SUCCESS); -} - -DBA_FIRSTKEY_FUNC(ndbm) -{ - datum gkey; - char *key = NULL; - - gkey = dbm_firstkey(info->dbf); - if(gkey.dptr) { - if(newlen) *newlen = gkey.dsize; - key = estrndup(gkey.dptr, gkey.dsize); - } - return key; -} - -DBA_NEXTKEY_FUNC(ndbm) -{ - datum gkey; - char *nkey = NULL; - - gkey = dbm_nextkey(info->dbf); - if(gkey.dptr) { - if(newlen) *newlen = gkey.dsize; - nkey = estrndup(gkey.dptr, gkey.dsize); - } - return nkey; -} - -DBA_OPTIMIZE_FUNC(ndbm) -{ - return SUCCESS; -} - -DBA_SYNC_FUNC(ndbm) -{ - return SUCCESS; -} -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/ext/dba/install_cdb.sh b/ext/dba/install_cdb.sh deleted file mode 100755 index ce5f3cc856..0000000000 --- a/ext/dba/install_cdb.sh +++ /dev/null @@ -1,53 +0,0 @@ -#! /bin/sh - -# You can use this script if you want to use an external cdb lib. If you -# compile php using --with-cdb the internal functions will be used and no -# external library is used so that this script is not necessary. -# -# cdb-0.75 lacks support for installing header files and creating a -# library which programs can link against. This shell script fills -# the gap. -# -# $Id: install_cdb.sh,v 1.2 2002-11-04 17:53:04 helly Exp $ - -if test -r "cdb.a" && test -r "auto-str.c" && test -r "byte.a"; then - : -else - echo "Please execute this script in the cdb-0.75 source directory after 'make'" - exit 1 -fi - -prefix=$1 - -if test -z "$prefix"; then - prefix=/usr/local -fi - -echo "Using prefix $prefix" - -if mkdir -p "$prefix/include" "$prefix/lib"; then - : -else - echo "Creating directories failed. Please become superuser." - exit 1 -fi - -mkdir -p tmp || exit 1 -cd tmp -ar x ../cdb.a -ar x ../byte.a -ar x ../unix.a -ar x ../byte.a -ar x ../buffer.a -cp ../error.o . - -# not really portable -ar r "$prefix/lib/libcdb.a" * -ranlib "$prefix/lib/libcdb.a" -cd .. - -rm -rf tmp - -cp cdb.h uint32.h "$prefix/include" - -echo "done" diff --git a/ext/dba/libcdb/cdb.c b/ext/dba/libcdb/cdb.c deleted file mode 100644 index fbc27eaceb..0000000000 --- a/ext/dba/libcdb/cdb.c +++ /dev/null @@ -1,195 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -/* incorporated from D.J.Bernstein's cdb-0.75 (http://cr.yp.to/cdb.html)*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" - -#include <sys/types.h> -#include <sys/stat.h> -#ifndef PHP_WIN32 -#include <sys/mman.h> -#endif -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#include <string.h> -#include <errno.h> -#include "cdb.h" - -#ifndef EPROTO -# define EPROTO -15 /* cdb 0.75's default for PROTOless systems */ -#endif - -/* {{{ cdb_match */ -static int cdb_match(struct cdb *c, char *key, unsigned int len, uint32 pos TSRMLS_DC) -{ - char buf[32]; - unsigned int n; - - while (len > 0) { - n = sizeof(buf); - if (n > len) - n = len; - if (cdb_read(c, buf, n, pos TSRMLS_CC) == -1) - return -1; - if (memcmp(buf, key, n)) - return 0; - pos += n; - key += n; - len -= n; - } - return 1; -} -/* }}} */ - -/* {{{ cdb_hashadd */ -static uint32 cdb_hashadd(uint32 h, unsigned char c) -{ - h += (h << 5); - return h ^ c; -} -/* }}} */ - -/* {{{ cdb_hash */ -uint32 cdb_hash(char *buf, unsigned int len) -{ - uint32 h; - - h = CDB_HASHSTART; - while (len) { - h = cdb_hashadd(h, *buf++); - --len; - } - return h; -} -/* }}} */ - -/* {{{ cdb_free */ -void cdb_free(struct cdb *c TSRMLS_DC) -{ -} -/* }}} */ - -/* {{{ cdb_findstart */ -void cdb_findstart(struct cdb *c TSRMLS_DC) -{ - c->loop = 0; -} -/* }}} */ - -/* {{{ cdb_init */ -void cdb_init(struct cdb *c, php_stream *fp TSRMLS_DC) -{ - cdb_free(c TSRMLS_CC); - cdb_findstart(c TSRMLS_CC); - c->fp = fp; -} -/* }}} */ - -/* {{{ cdb_read */ -int cdb_read(struct cdb *c, char *buf, unsigned int len, uint32 pos TSRMLS_DC) -{ - if (php_stream_seek(c->fp, pos, SEEK_SET) == -1) { - errno = EPROTO; - return -1; - } - while (len > 0) { - int r; - do { - r = php_stream_read(c->fp, buf, len); - } while ((r == -1) && (errno == EINTR)); - if (r == -1) - return -1; - if (r == 0) { - errno = EPROTO; - return -1; - } - buf += r; - len -= r; - } - return 0; -} -/* }}} */ - -/* {{{ cdb_findnext */ -int cdb_findnext(struct cdb *c, char *key, unsigned int len TSRMLS_DC) -{ - char buf[8]; - uint32 pos; - uint32 u; - - if (!c->loop) { - u = cdb_hash(key, len); - if (cdb_read(c, buf, 8, (u << 3) & 2047 TSRMLS_CC) == -1) - return -1; - uint32_unpack(buf + 4,&c->hslots); - if (!c->hslots) - return 0; - uint32_unpack(buf, &c->hpos); - c->khash = u; - u >>= 8; - u %= c->hslots; - u <<= 3; - c->kpos = c->hpos + u; - } - - while (c->loop < c->hslots) { - if (cdb_read(c, buf, 8, c->kpos TSRMLS_CC) == -1) - return -1; - uint32_unpack(buf + 4, &pos); - if (!pos) - return 0; - c->loop += 1; - c->kpos += 8; - if (c->kpos == c->hpos + (c->hslots << 3)) - c->kpos = c->hpos; - uint32_unpack(buf, &u); - if (u == c->khash) { - if (cdb_read(c, buf, 8, pos TSRMLS_CC) == -1) - return -1; - uint32_unpack(buf, &u); - if (u == len) - switch(cdb_match(c, key, len, pos + 8 TSRMLS_CC)) { - case -1: - return -1; - case 1: - uint32_unpack(buf + 4, &c->dlen); - c->dpos = pos + 8 + len; - return 1; - } - } - } - - return 0; -} -/* }}} */ - -/* {{{ cdb_find */ -int cdb_find(struct cdb *c, char *key, unsigned int len TSRMLS_DC) -{ - cdb_findstart(c TSRMLS_CC); - return cdb_findnext(c, key, len TSRMLS_CC); -} -/* }}} */ diff --git a/ext/dba/libcdb/cdb.h b/ext/dba/libcdb/cdb.h deleted file mode 100644 index a74ef2325b..0000000000 --- a/ext/dba/libcdb/cdb.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -/* incorporated from D.J.Bernstein's cdb-0.75 (http://cr.yp.to/cdb.html)*/ - -#ifndef CDB_H -#define CDB_H - -#include "uint32.h" - -#define CDB_HASHSTART 5381 - -struct cdb { - php_stream *fp; - uint32 loop; /* number of hash slots searched under this key */ - uint32 khash; /* initialized if loop is nonzero */ - uint32 kpos; /* initialized if loop is nonzero */ - uint32 hpos; /* initialized if loop is nonzero */ - uint32 hslots; /* initialized if loop is nonzero */ - uint32 dpos; /* initialized if cdb_findnext() returns 1 */ - uint32 dlen; /* initialized if cdb_findnext() returns 1 */ -}; - -uint32 cdb_hash(char *, unsigned int); - -void cdb_free(struct cdb * TSRMLS_DC); -void cdb_init(struct cdb *, php_stream *fp TSRMLS_DC); - -int cdb_read(struct cdb *, char *, unsigned int, uint32 TSRMLS_DC); - -void cdb_findstart(struct cdb * TSRMLS_DC); -int cdb_findnext(struct cdb *, char *, unsigned int TSRMLS_DC); -int cdb_find(struct cdb *, char *, unsigned int TSRMLS_DC); - -#define cdb_datapos(c) ((c)->dpos) -#define cdb_datalen(c) ((c)->dlen) - -#endif diff --git a/ext/dba/libcdb/cdb_make.c b/ext/dba/libcdb/cdb_make.c deleted file mode 100644 index 4023a154a6..0000000000 --- a/ext/dba/libcdb/cdb_make.c +++ /dev/null @@ -1,240 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -/* incorporated from D.J.Bernstein's cdb-0.75 (http://cr.yp.to/cdb.html)*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" - -#include <sys/types.h> -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include "cdb.h" -#include "cdb_make.h" -#include "uint32.h" - -/* {{{ cdb_make_write */ -static int cdb_make_write(struct cdb_make *c, char *buf, uint32 sz TSRMLS_DC) { - return php_stream_write(c->fp, buf, sz) == sz ? 0 : -1; -} - -/* {{{ cdb_posplus */ -static int cdb_posplus(struct cdb_make *c, uint32 len) -{ - uint32 newpos = c->pos + len; - if (newpos < len) { - errno = ENOMEM; - return -1; - } - c->pos = newpos; - return 0; -} -/* }}} */ - -/* {{{ cdb_make_start */ -int cdb_make_start(struct cdb_make *c, php_stream * f TSRMLS_DC) -{ - c->head = 0; - c->split = 0; - c->hash = 0; - c->numentries = 0; - c->fp = f; - c->pos = sizeof(c->final); - if (php_stream_seek(f, c->pos, SEEK_SET) == -1) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Fseek failed"); - return -1; - } - return php_stream_tell(c->fp); -} -/* }}} */ - -/* {{{ cdb_make_addend */ -int cdb_make_addend(struct cdb_make *c, unsigned int keylen, unsigned int datalen, uint32 h TSRMLS_DC) -{ - struct cdb_hplist *head; - - head = c->head; - if (!head || (head->num >= CDB_HPLIST)) { - head = (struct cdb_hplist *) - emalloc(sizeof(struct cdb_hplist)); - if (!head) - return -1; - head->num = 0; - head->next = c->head; - c->head = head; - } - head->hp[head->num].h = h; - head->hp[head->num].p = c->pos; - ++head->num; - ++c->numentries; - if (cdb_posplus(c,8) == -1) - return -1; - if (cdb_posplus(c, keylen) == -1) - return -1; - if (cdb_posplus(c, datalen) == -1) - return -1; - return 0; -} -/* }}} */ - -/* {{{ cdb_make_addbegin */ -int cdb_make_addbegin(struct cdb_make *c, unsigned int keylen, unsigned int datalen TSRMLS_DC) -{ - char buf[8]; - - if (keylen > 0xffffffff) { - errno = ENOMEM; - return -1; - } - if (datalen > 0xffffffff) { - errno = ENOMEM; - return -1; - } - - uint32_pack(buf, keylen); - uint32_pack(buf + 4, datalen); - if (cdb_make_write(c, buf, 8 TSRMLS_CC) != 0) - return -1; - return 0; -} - -/* {{{ cdb_make_add */ -int cdb_make_add(struct cdb_make *c,char *key,unsigned int keylen,char *data,unsigned int datalen TSRMLS_DC) -{ - if (cdb_make_addbegin(c, keylen, datalen TSRMLS_CC) == -1) - return -1; - if (cdb_make_write(c, key, keylen TSRMLS_CC) != 0) - return -1; - if (cdb_make_write(c, data, datalen TSRMLS_CC) != 0) - return -1; - return cdb_make_addend(c, keylen, datalen, cdb_hash(key, keylen) TSRMLS_CC); -} -/* }}} */ - -/* {{{ cdb_make_finish */ -int cdb_make_finish(struct cdb_make *c TSRMLS_DC) -{ - char buf[8]; - int i; - uint32 len; - uint32 u; - uint32 memsize; - uint32 count; - uint32 where; - struct cdb_hplist *x; - struct cdb_hp *hp; - - for (i = 0;i < 256;++i) - c->count[i] = 0; - - for (x = c->head; x; x = x->next) { - i = x->num; - while (i--) - ++c->count[255 & x->hp[i].h]; - } - - memsize = 1; - for (i = 0;i < 256;++i) { - u = c->count[i] * 2; - if (u > memsize) - memsize = u; - } - - memsize += c->numentries; /* no overflow possible up to now */ - u = (uint32) 0 - (uint32) 1; - u /= sizeof(struct cdb_hp); - if (memsize > u) { - errno = ENOMEM; - return -1; - } - - c->split = (struct cdb_hp *) - emalloc(memsize * sizeof(struct cdb_hp)); - if (!c->split) - return -1; - - c->hash = c->split + c->numentries; - - u = 0; - for (i = 0;i < 256;++i) { - u += c->count[i]; /* bounded by numentries, so no overflow */ - c->start[i] = u; - } - - for (x = c->head; x; x = x->next) { - i = x->num; - while (i--) - c->split[--c->start[255 & x->hp[i].h]] = x->hp[i]; - } - - for (i = 0;i < 256;++i) { - count = c->count[i]; - - len = count + count; /* no overflow possible */ - uint32_pack(c->final + 8 * i,c->pos); - uint32_pack(c->final + 8 * i + 4,len); - - for (u = 0;u < len;++u) - c->hash[u].h = c->hash[u].p = 0; - - hp = c->split + c->start[i]; - for (u = 0;u < count;++u) { - where = (hp->h >> 8) % len; - while (c->hash[where].p) - if (++where == len) - where = 0; - c->hash[where] = *hp++; - } - - for (u = 0;u < len;++u) { - uint32_pack(buf, c->hash[u].h); - uint32_pack(buf + 4, c->hash[u].p); - if (cdb_make_write(c, buf, 8 TSRMLS_CC) != 0) - return -1; - if (cdb_posplus(c, 8) == -1) - return -1; - } - } - - if (c->split) - efree(c->split); - - for (x = c->head; x; c->head = x) { - x = x->next; - efree(c->head); - } - - if (php_stream_flush(c->fp) != 0) - return -1; - php_stream_rewind(c->fp); - if (php_stream_tell(c->fp) != 0) - return -1; - if (cdb_make_write(c, c->final, sizeof(c->final) TSRMLS_CC) != 0) - return -1; - return php_stream_flush(c->fp); -} -/* }}} */ diff --git a/ext/dba/libcdb/cdb_make.h b/ext/dba/libcdb/cdb_make.h deleted file mode 100644 index e5fb65fe49..0000000000 --- a/ext/dba/libcdb/cdb_make.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -/* incorporated from D.J.Bernstein's cdb-0.75 (http://cr.yp.to/cdb.html)*/ - -#ifndef CDB_MAKE_H -#define CDB_MAKE_H - -#include <stdio.h> -#include "uint32.h" - -#define CDB_HPLIST 1000 - -struct cdb_hp { - uint32 h; - uint32 p; -}; - -struct cdb_hplist { - struct cdb_hp hp[CDB_HPLIST]; - struct cdb_hplist *next; - int num; -} ; - -struct cdb_make { - /* char bspace[8192]; */ - char final[2048]; - uint32 count[256]; - uint32 start[256]; - struct cdb_hplist *head; - struct cdb_hp *split; /* includes space for hash */ - struct cdb_hp *hash; - uint32 numentries; - /* buffer b; */ - uint32 pos; - /* int fd; */ - php_stream * fp; -}; - -int cdb_make_start(struct cdb_make *, php_stream * TSRMLS_DC); -int cdb_make_addbegin(struct cdb_make *, unsigned int, unsigned int TSRMLS_DC); -int cdb_make_addend(struct cdb_make *, unsigned int, unsigned int, uint32 TSRMLS_DC); -int cdb_make_add(struct cdb_make *, char *, unsigned int, char *, unsigned int TSRMLS_DC); -int cdb_make_finish(struct cdb_make * TSRMLS_DC); - -#endif diff --git a/ext/dba/libcdb/uint32.c b/ext/dba/libcdb/uint32.c deleted file mode 100644 index 223ad170ac..0000000000 --- a/ext/dba/libcdb/uint32.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -/* incorporated from D.J.Bernstein's cdb-0.75 (http://cr.yp.to/cdb.html)*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" - -#include "uint32.h" - -/* {{{ uint32_pack */ -void uint32_pack(char *out, uint32 in) -{ - out[0] = in&0xff; in>>=8; - out[1] = in&0xff; in>>=8; - out[2] = in&0xff; in>>=8; - out[3] = in&0xff; -} -/* }}} */ - -/* {{{ uint32_unpack */ -void uint32_unpack(const char *in, uint32 *out) -{ - *out = (((uint32)(unsigned char)in[3])<<24) | - (((uint32)(unsigned char)in[2])<<16) | - (((uint32)(unsigned char)in[1])<<8) | - (((uint32)(unsigned char)in[0])); -} -/* }}} */ diff --git a/ext/dba/libcdb/uint32.h b/ext/dba/libcdb/uint32.h deleted file mode 100644 index 8eeaf8db48..0000000000 --- a/ext/dba/libcdb/uint32.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -/* incorporated from D.J.Bernstein's cdb-0.75 (http://cr.yp.to/cdb.html)*/ - -#ifndef UINT32_H -#define UINT32_H - -#if SIZEOF_INT == 4 -/* Most 32-bit and 64-bit systems have 32-bit ints */ -typedef unsigned int uint32; -#elif SIZEOF_LONG == 4 -/* 16-bit systems? */ -typedef unsigned long uint32; -#else -#error Need type which holds 32 bits -#endif - -void uint32_pack(char *out, uint32 in); -void uint32_unpack(const char *in, uint32 *out); - -#endif diff --git a/ext/dba/libflatfile/flatfile.c b/ext/dba/libflatfile/flatfile.c deleted file mode 100644 index 4cb820875e..0000000000 --- a/ext/dba/libflatfile/flatfile.c +++ /dev/null @@ -1,305 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Marcus Boerger <helly@php.net> | - | based on ext/db/db.c by: | - | Rasmus Lerdorf <rasmus@php.net> | - | Jim Winstead <jimw@php.net> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_globals.h" -#include "safe_mode.h" - -#include <stdlib.h> -#include <string.h> -#include <errno.h> -#if HAVE_UNISTD_H -#include <unistd.h> -#endif - -#include "flatfile.h" - -/* - * ret = -1 means that database was opened for read-only - * ret = 0 success - * ret = 1 key already exists - nothing done - */ - -/* {{{ flatfile_store - */ -int flatfile_store(flatfile *dba, datum key_datum, datum value_datum, int mode TSRMLS_DC) { - if (mode == FLATFILE_INSERT) { - if (flatfile_findkey(dba, key_datum TSRMLS_CC)) { - return 1; - } - php_stream_seek(dba->fp, 0L, SEEK_END); - php_stream_printf(dba->fp TSRMLS_CC, "%d\n", key_datum.dsize); - php_stream_flush(dba->fp); - if (php_stream_write(dba->fp, key_datum.dptr, key_datum.dsize) < key_datum.dsize) - return -1; - php_stream_printf(dba->fp TSRMLS_CC, "%d\n", value_datum.dsize); - php_stream_flush(dba->fp); - if (php_stream_write(dba->fp, value_datum.dptr, value_datum.dsize) < value_datum.dsize) - return -1; - } else { /* DBM_REPLACE */ - flatfile_delete(dba, key_datum TSRMLS_CC); - php_stream_printf(dba->fp TSRMLS_CC, "%d\n", key_datum.dsize); - php_stream_flush(dba->fp); - if (php_stream_write(dba->fp, key_datum.dptr, key_datum.dsize) < key_datum.dsize) - return -1; - php_stream_printf(dba->fp TSRMLS_CC, "%d\n", value_datum.dsize); - if (php_stream_write(dba->fp, value_datum.dptr, value_datum.dsize) < value_datum.dsize) - return -1; - } - - php_stream_flush(dba->fp); - return 0; -} -/* }}} */ - -/* {{{ flatfile_fetch - */ -datum flatfile_fetch(flatfile *dba, datum key_datum TSRMLS_DC) { - datum value_datum = {NULL, 0}; - size_t num=0; - size_t buf_size = 1024; - char *buf; - - if (flatfile_findkey(dba, key_datum TSRMLS_CC)) { - buf = emalloc((buf_size+1) * sizeof(char)); - if (php_stream_gets(dba->fp, buf, 15)) { - num = atoi(buf); - if (num > buf_size) { - buf_size+=num; - buf = erealloc(buf, (buf_size+1)*sizeof(char)); - } - php_stream_read(dba->fp, buf, num); - value_datum.dptr = buf; - value_datum.dsize = num; - } else { - value_datum.dptr = NULL; - value_datum.dsize = 0; - efree(buf); - } - } - return value_datum; -} -/* }}} */ - -/* {{{ flatfile_delete - */ -int flatfile_delete(flatfile *dba, datum key_datum TSRMLS_DC) { - char *key = key_datum.dptr; - size_t size = key_datum.dsize; - - char *buf; - size_t num; - size_t buf_size = 1024; - size_t pos; - - php_stream_rewind(dba->fp); - - buf = emalloc((buf_size + 1)*sizeof(char)); - while(!php_stream_eof(dba->fp)) { - /* read in the length of the key name */ - if (!php_stream_gets(dba->fp, buf, 15)) - break; - num = atoi(buf); - if (num > buf_size) { - buf_size += num; - buf = erealloc(buf, (buf_size+1)*sizeof(char)); - } - pos = php_stream_tell(dba->fp); - - /* read in the key name */ - num = php_stream_read(dba->fp, buf, sizeof(char)*num); - if (num<0) - break; - *(buf+num) = '\0'; - - if (size == num && !memcmp(buf, key, size)) { - php_stream_seek(dba->fp, pos, SEEK_SET); - php_stream_putc(dba->fp, 0); - php_stream_flush(dba->fp); - php_stream_seek(dba->fp, 0L, SEEK_END); - if (buf) - efree(buf); - return SUCCESS; - } - - /* read in the length of the value */ - if (!php_stream_gets(dba->fp, buf, 15)) - break; - num = atoi(buf); - if (num > buf_size) { - buf_size+=num; - buf = erealloc(buf, (buf_size+1)*sizeof(char)); - } - /* read in the value */ - num = php_stream_read(dba->fp, buf, sizeof(char)*num); - if (num<0) - break; - } - if (buf) - efree(buf); - return FAILURE; -} -/* }}} */ - -/* {{{ flatfile_findkey - */ -int flatfile_findkey(flatfile *dba, datum key_datum TSRMLS_DC) { - char *buf = NULL; - size_t num; - size_t buf_size = 1024; - int ret=0; - void *key = key_datum.dptr; - size_t size = key_datum.dsize; - - php_stream_rewind(dba->fp); - buf = emalloc((buf_size+1)*sizeof(char)); - while (!php_stream_eof(dba->fp)) { - if (!php_stream_gets(dba->fp, buf, 15)) - break; - num = atoi(buf); - if (num > buf_size) { - buf_size+=num; - buf = erealloc(buf, (buf_size+1)*sizeof(char)); - } - num = php_stream_read(dba->fp, buf, sizeof(char)*num); - if (num<0) break; - *(buf+num) = '\0'; - if (size == num) { - if (!memcmp(buf, key, size)) { - ret = 1; - break; - } - } - if (!php_stream_gets(dba->fp, buf, 15)) - break; - num = atoi(buf); - if (num > buf_size) { - buf_size+=num; - buf = erealloc(buf, (buf_size+1)*sizeof(char)); - } - num = php_stream_read(dba->fp, buf, sizeof(char)*num); - if (num<0) - break; - *(buf+num) = '\0'; - } - if (buf) - efree(buf); - return(ret); -} -/* }}} */ - -/* {{{ flatfile_firstkey - */ -datum flatfile_firstkey(flatfile *dba TSRMLS_DC) { - datum buf; - size_t num; - size_t buf_size = 1024; - - php_stream_rewind(dba->fp); - buf.dptr = emalloc((buf_size+1)*sizeof(char)); - while(!php_stream_eof(dba->fp)) { - if (!php_stream_gets(dba->fp, buf.dptr, 15)) break; - num = atoi(buf.dptr); - if (num > buf_size) { - buf_size+=num; - buf.dptr = erealloc(buf.dptr, (buf_size+1)*sizeof(char)); - } - num = php_stream_read(dba->fp, buf.dptr, num); - if (num<0) - break; - buf.dsize = num; - if (*(buf.dptr)!=0) { - dba->CurrentFlatFilePos = php_stream_tell(dba->fp); - return(buf); - } - if (!php_stream_gets(dba->fp, buf.dptr, 15)) break; - num = atoi(buf.dptr); - if (num > buf_size) { - buf_size+=num; - buf.dptr = erealloc(buf.dptr, (buf_size+1)*sizeof(char)); - } - num = php_stream_read(dba->fp, buf.dptr, num); - if (num<0) - break; - } - if (buf.dptr) - efree(buf.dptr); - buf.dptr = NULL; - return(buf); -} -/* }}} */ - -/* {{{ flatfile_nextkey - */ -datum flatfile_nextkey(flatfile *dba TSRMLS_DC) { - datum buf; - size_t num; - size_t buf_size = 1024; - - php_stream_seek(dba->fp, dba->CurrentFlatFilePos, SEEK_SET); - buf.dptr = emalloc((buf_size+1)*sizeof(char)); - while(!php_stream_eof(dba->fp)) { - if (!php_stream_gets(dba->fp, buf.dptr, 15)) break; - num = atoi(buf.dptr); - if (num > buf_size) { - buf_size+=num; - buf.dptr = erealloc(buf.dptr, (buf_size+1)*sizeof(char)); - } - num = php_stream_read(dba->fp, buf.dptr, num); - if (num<0) - break; - if (!php_stream_gets(dba->fp, buf.dptr, 15)) - break; - num = atoi(buf.dptr); - if (num > buf_size) { - buf_size+=num; - buf.dptr = erealloc(buf.dptr, (buf_size+1)*sizeof(char)); - } - num = php_stream_read(dba->fp, buf.dptr, num); - if (num<0) - break; - buf.dsize = num; - if (*(buf.dptr)!=0) { - dba->CurrentFlatFilePos = php_stream_tell(dba->fp); - return(buf); - } - } - if (buf.dptr) - efree(buf.dptr); - buf.dptr = NULL; - return(buf); -} -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/ext/dba/libflatfile/flatfile.h b/ext/dba/libflatfile/flatfile.h deleted file mode 100644 index 9c910ae157..0000000000 --- a/ext/dba/libflatfile/flatfile.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifndef PHP_LIBDBM_H -#define PHP_LIBDBM_H - -typedef struct { - char *dptr; - size_t dsize; -} datum; - -typedef struct { - char *lockfn; - int lockfd; - php_stream *fp; - size_t CurrentFlatFilePos; - datum nextkey; -} flatfile; - -#define FLATFILE_INSERT 1 -#define FLATFILE_REPLACE 0 - -int flatfile_store(flatfile *dba, datum key_datum, datum value_datum, int mode TSRMLS_DC); -datum flatfile_fetch(flatfile *dba, datum key_datum TSRMLS_DC); -int flatfile_delete(flatfile *dba, datum key_datum TSRMLS_DC); -int flatfile_findkey(flatfile *dba, datum key_datum TSRMLS_DC); -datum flatfile_firstkey(flatfile *dba TSRMLS_DC); -datum flatfile_nextkey(flatfile *dba TSRMLS_DC); - -#endif diff --git a/ext/dba/php_cdb.h b/ext/dba/php_cdb.h deleted file mode 100644 index a046f0796b..0000000000 --- a/ext/dba/php_cdb.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef PHP_CDB_H -#define PHP_CDB_H - -#if DBA_CDB - -#include "php_dba.h" - -DBA_FUNCS(cdb); - -#endif - -#endif diff --git a/ext/dba/php_db2.h b/ext/dba/php_db2.h deleted file mode 100644 index 2a95223a85..0000000000 --- a/ext/dba/php_db2.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef PHP_DB2_H -#define PHP_DB2_H - -#if DBA_DB2 - -#include "php_dba.h" - -DBA_FUNCS(db2); - -#endif - -#endif diff --git a/ext/dba/php_db3.h b/ext/dba/php_db3.h deleted file mode 100644 index 58bb0b62a0..0000000000 --- a/ext/dba/php_db3.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef PHP_DB3_H -#define PHP_DB3_H - -#if DBA_DB3 - -#include "php_dba.h" - -DBA_FUNCS(db3); - -#endif - -#endif diff --git a/ext/dba/php_db4.h b/ext/dba/php_db4.h deleted file mode 100644 index fa814c3f5e..0000000000 --- a/ext/dba/php_db4.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef PHP_DB4_H -#define PHP_DB4_H - -#if DBA_DB4 - -#include "php_dba.h" - -DBA_FUNCS(db4); - -#endif - -#endif diff --git a/ext/dba/php_dba.h b/ext/dba/php_dba.h deleted file mode 100644 index 2290c638e8..0000000000 --- a/ext/dba/php_dba.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifndef PHP_DBA_H -#define PHP_DBA_H - -#if HAVE_DBA - -typedef enum { - /* do not allow 0 here */ - DBA_READER = 1, - DBA_WRITER, - DBA_TRUNC, - DBA_CREAT -} dba_mode_t; - -typedef struct dba_lock { - php_stream *fp; - int fd; - char *name; - int mode; /* LOCK_EX,LOCK_SH */ -} dba_lock; - -typedef struct dba_info { - /* public */ - void *dbf; /* ptr to private data or whatever */ - char *path; - dba_mode_t mode; - php_stream *fp; /* this is the database stream for builtin handlers */ - /* arg[cv] are only available when the dba_open handler is called! */ - int argc; - zval ***argv; - /* private */ - int flags; /* whether and how dba did locking and other flags*/ - struct dba_handler *hnd; - dba_lock lock; -} dba_info; - -#define DBA_LOCK_READER (0x0001) -#define DBA_LOCK_WRITER (0x0002) -#define DBA_LOCK_CREAT (0x0004) -#define DBA_LOCK_TRUNC (0x0008) - -#define DBA_LOCK_EXT (0) -#define DBA_LOCK_ALL (DBA_LOCK_READER|DBA_LOCK_WRITER|DBA_LOCK_CREAT|DBA_LOCK_TRUNC) -#define DBA_LOCK_WCT (DBA_LOCK_WRITER|DBA_LOCK_CREAT|DBA_LOCK_TRUNC) - -#define DBA_STREAM_OPEN (0x0010) - -extern zend_module_entry dba_module_entry; -#define dba_module_ptr &dba_module_entry - -/* common prototypes which must be supplied by modules */ - -#define DBA_OPEN_FUNC(x) \ - int dba_open_##x(dba_info *info, char **error TSRMLS_DC) -#define DBA_CLOSE_FUNC(x) \ - void dba_close_##x(dba_info *info TSRMLS_DC) -#define DBA_FETCH_FUNC(x) \ - char *dba_fetch_##x(dba_info *info, char *key, int keylen, int skip, int *newlen TSRMLS_DC) -#define DBA_UPDATE_FUNC(x) \ - int dba_update_##x(dba_info *info, char *key, int keylen, char *val, int vallen, int mode TSRMLS_DC) -#define DBA_EXISTS_FUNC(x) \ - int dba_exists_##x(dba_info *info, char *key, int keylen TSRMLS_DC) -#define DBA_DELETE_FUNC(x) \ - int dba_delete_##x(dba_info *info, char *key, int keylen TSRMLS_DC) -#define DBA_FIRSTKEY_FUNC(x) \ - char *dba_firstkey_##x(dba_info *info, int *newlen TSRMLS_DC) -#define DBA_NEXTKEY_FUNC(x) \ - char *dba_nextkey_##x(dba_info *info, int *newlen TSRMLS_DC) -#define DBA_OPTIMIZE_FUNC(x) \ - int dba_optimize_##x(dba_info *info TSRMLS_DC) -#define DBA_SYNC_FUNC(x) \ - int dba_sync_##x(dba_info *info TSRMLS_DC) - -#define DBA_FUNCS(x) \ - DBA_OPEN_FUNC(x); \ - DBA_CLOSE_FUNC(x); \ - DBA_FETCH_FUNC(x); \ - DBA_UPDATE_FUNC(x); \ - DBA_DELETE_FUNC(x); \ - DBA_EXISTS_FUNC(x); \ - DBA_FIRSTKEY_FUNC(x); \ - DBA_NEXTKEY_FUNC(x); \ - DBA_OPTIMIZE_FUNC(x); \ - DBA_SYNC_FUNC(x) - -#define VALLEN(p) Z_STRVAL_PP(p), Z_STRLEN_PP(p) - -PHP_FUNCTION(dba_open); -PHP_FUNCTION(dba_popen); -PHP_FUNCTION(dba_close); -PHP_FUNCTION(dba_firstkey); -PHP_FUNCTION(dba_nextkey); -PHP_FUNCTION(dba_replace); -PHP_FUNCTION(dba_insert); -PHP_FUNCTION(dba_delete); -PHP_FUNCTION(dba_exists); -PHP_FUNCTION(dba_fetch); -PHP_FUNCTION(dba_optimize); -PHP_FUNCTION(dba_sync); -PHP_FUNCTION(dba_handlers); -PHP_FUNCTION(dba_list); - -#else -#define dba_module_ptr NULL -#endif - -#define phpext_dba_ptr dba_module_ptr - -#endif diff --git a/ext/dba/php_dbm.h b/ext/dba/php_dbm.h deleted file mode 100644 index 4c963d18ed..0000000000 --- a/ext/dba/php_dbm.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef PHP_DBM_H -#define PHP_DBM_H - -#if DBA_DBM - -#include "php_dba.h" - -DBA_FUNCS(dbm); - -#endif - -#endif diff --git a/ext/dba/php_flatfile.h b/ext/dba/php_flatfile.h deleted file mode 100644 index afa9f6d5d3..0000000000 --- a/ext/dba/php_flatfile.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef PHP_FLATFILE_H -#define PHP_FLATFILE_H - -#if DBA_FLATFILE - -#include "php_dba.h" - -DBA_FUNCS(flatfile); - -#endif - -#endif diff --git a/ext/dba/php_gdbm.h b/ext/dba/php_gdbm.h deleted file mode 100644 index 3068404cfe..0000000000 --- a/ext/dba/php_gdbm.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef PHP_GDBM_H -#define PHP_GDBM_H - -#if DBA_GDBM - -#include "php_dba.h" - -DBA_FUNCS(gdbm); - -#endif - -#endif diff --git a/ext/dba/php_ndbm.h b/ext/dba/php_ndbm.h deleted file mode 100644 index b1ebf15af3..0000000000 --- a/ext/dba/php_ndbm.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef PHP_NDBM_H -#define PHP_NDBM_H - -#if DBA_NDBM - -#include "php_dba.h" - -DBA_FUNCS(ndbm); - -#endif - -#endif diff --git a/ext/dba/tests/dba001.phpt b/ext/dba/tests/dba001.phpt deleted file mode 100644 index 3d617fb2c2..0000000000 --- a/ext/dba/tests/dba001.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -DBA File Creation Test ---SKIPIF-- -<?php - require_once('skipif.inc'); - die("info $HND handler used"); -?> ---FILE-- -<?php - require_once('test.inc'); - echo "database handler: $handler\n"; - if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { - echo "database file created\n"; - dba_close($db_file); - } else { - echo "$db_file does not exist\n"; - } -?> ---EXPECTF-- -database handler: %s -database file created
\ No newline at end of file diff --git a/ext/dba/tests/dba002.phpt b/ext/dba/tests/dba002.phpt deleted file mode 100644 index 3f862e38c5..0000000000 --- a/ext/dba/tests/dba002.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -DBA Insert/Fetch Test ---SKIPIF-- -<?php - require_once('skipif.inc'); - die("info $HND handler used"); -?> ---FILE-- -<?php - require_once('test.inc'); - echo "database handler: $handler\n"; - if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { - dba_insert("key1", "This is a test insert", $db_file); - echo dba_fetch("key1", $db_file); - dba_close($db_file); - } else { - echo "Error creating database\n"; - } -?> ---EXPECTF-- -database handler: %s -This is a test insert diff --git a/ext/dba/tests/dba003.phpt b/ext/dba/tests/dba003.phpt deleted file mode 100644 index 617ae91891..0000000000 --- a/ext/dba/tests/dba003.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -DBA Insert/Replace/Fetch Test ---SKIPIF-- -<?php - require_once('skipif.inc'); - die("info $HND handler used"); -?> ---FILE-- -<?php - require_once('test.inc'); - echo "database handler: $handler\n"; - if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { - dba_insert("key1", "This is a test insert", $db_file); - dba_replace("key1", "This is the replacement text", $db_file); - $a = dba_fetch("key1", $db_file); - dba_close($db_file); - echo $a; - } else { - echo "Error creating database\n"; - } -?> ---EXPECTF-- -database handler: %s -This is the replacement text diff --git a/ext/dba/tests/dba004.phpt b/ext/dba/tests/dba004.phpt deleted file mode 100644 index 3b1f29c7dd..0000000000 --- a/ext/dba/tests/dba004.phpt +++ /dev/null @@ -1,28 +0,0 @@ ---TEST-- -DBA Multiple Insert/Fetch Test ---SKIPIF-- -<?php - require_once('skipif.inc'); - die("info $HND handler used"); -?> ---FILE-- -<?php - require_once('test.inc'); - echo "database handler: $handler\n"; - if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { - dba_insert("key1", "Content String 1", $db_file); - dba_insert("key2", "Content String 2", $db_file); - dba_insert("key3", "Third Content String", $db_file); - dba_insert("key4", "Another Content String", $db_file); - dba_insert("key5", "The last content string", $db_file); - $a = dba_fetch("key4", $db_file); - $b = dba_fetch("key2", $db_file); - dba_close($db_file); - echo "$a $b"; - } else { - echo "Error creating database\n"; - } -?> ---EXPECTF-- -database handler: %s -Another Content String Content String 2 diff --git a/ext/dba/tests/dba005.phpt b/ext/dba/tests/dba005.phpt deleted file mode 100644 index 5a933c48f9..0000000000 --- a/ext/dba/tests/dba005.phpt +++ /dev/null @@ -1,35 +0,0 @@ ---TEST-- -DBA FirstKey/NextKey Loop Test With 5 Items ---SKIPIF-- -<?php - require_once('skipif.inc'); - die("info $HND handler used"); -?> ---FILE-- -<?php - require_once('test.inc'); - echo "database handler: $handler\n"; - if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { - dba_insert("key1", "Content String 1", $db_file); - dba_insert("key2", "Content String 2", $db_file); - dba_insert("key3", "Third Content String", $db_file); - dba_insert("key4", "Another Content String", $db_file); - dba_insert("key5", "The last content string", $db_file); - $a = dba_firstkey($db_file); - $i=0; - while($a) { - $a = dba_nextkey($db_file); - $i++; - } - echo $i; - for ($i=1; $i<6; $i++) { - echo dba_exists("key$i", $db_file) ? "Y" : "N"; - } - dba_close($db_file); - } else { - echo "Error creating database\n"; - } -?> ---EXPECTF-- -database handler: %s -5YYYYY diff --git a/ext/dba/tests/dba006.phpt b/ext/dba/tests/dba006.phpt deleted file mode 100644 index efa36a5d07..0000000000 --- a/ext/dba/tests/dba006.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -DBA FirstKey/NextKey with 2 deletes ---SKIPIF-- -<?php - require_once('skipif.inc'); - die("info $HND handler used"); -?> ---FILE-- -<?php - require_once('test.inc'); - echo "database handler: $handler\n"; - if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { - dba_insert("key1", "Content String 1", $db_file); - dba_insert("key2", "Content String 2", $db_file); - dba_insert("key3", "Third Content String", $db_file); - dba_insert("key4", "Another Content String", $db_file); - dba_insert("key5", "The last content string", $db_file); - dba_delete("key3", $db_file); - dba_delete("key1", $db_file); - $a = dba_firstkey($db_file); - $i=0; - while($a) { - $a = dba_nextkey($db_file); - $i++; - } - echo $i; - for ($i=1; $i<6; $i++) { - echo dba_exists("key$i", $db_file) ? "Y" : "N"; - } - dba_close($db_file); - } else { - echo "Error creating database\n"; - } -?> ---EXPECTF-- -database handler: %s -3NYNYY
\ No newline at end of file diff --git a/ext/dba/tests/dba007.phpt b/ext/dba/tests/dba007.phpt deleted file mode 100644 index 0add3809aa..0000000000 --- a/ext/dba/tests/dba007.phpt +++ /dev/null @@ -1,45 +0,0 @@ ---TEST-- -DBA Multiple File Creation Test ---SKIPIF-- -<?php - require_once('skipif.inc'); - if (!function_exists('dba_list')) die('skip dba_list() not available'); - die("info $HND handler used"); -?> ---FILE-- -<?php - require_once('test.inc'); - echo "database handler: $handler\n"; - $db_file1 = dirname(__FILE__).'/test1.dbm'; - $db_file2 = dirname(__FILE__).'/test2.dbm'; - if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { - echo "database file created\n"; - } else { - echo "$db_file does not exist\n"; - } - if (($db_file1=dba_open($db_file1, "n", $handler))!==FALSE) { - echo "database file created\n"; - } else { - echo "$db_file does not exist\n"; - } - if (($db_file2=dba_open($db_file2, "n", $handler))!==FALSE) { - echo "database file created\n"; - } else { - echo "$db_file does not exist\n"; - } - var_dump(dba_list()); - dba_close($db_file); -?> ---EXPECTF-- -database handler: %s -database file created -database file created -database file created -array(3) { - [%d]=> - string(%d) "%sext/dba/tests/test0.dbm" - [%d]=> - string(%d) "%sext/dba/tests/test1.dbm" - [%d]=> - string(%d) "%sext/dba/tests/test2.dbm" -}
\ No newline at end of file diff --git a/ext/dba/tests/dba008.phpt b/ext/dba/tests/dba008.phpt deleted file mode 100644 index 84a47ba083..0000000000 --- a/ext/dba/tests/dba008.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -DBA magic_quotes_runtime Test ---SKIPIF-- -<?php - require_once('skipif.inc'); - die("info $HND handler used"); -?> ---FILE-- -<?php - require_once('test.inc'); - echo "database handler: $handler\n"; - if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { - ini_set('magic_quotes_runtime', 0); - dba_insert("key1", '"', $db_file); - var_dump(dba_fetch("key1", $db_file)); - ini_set('magic_quotes_runtime', 1); - var_dump(dba_fetch("key1", $db_file)); - dba_replace("key1", '\"', $db_file); - var_dump(dba_fetch("key1", $db_file)); - ini_set('magic_quotes_runtime', 0); - var_dump(dba_fetch("key1", $db_file)); - dba_close($db_file); - } else { - echo "Error creating database\n"; - } -?> ---EXPECTF-- -database handler: %s -string(1) """ -string(2) "\"" -string(2) "\"" -string(1) """ diff --git a/ext/dba/tests/dba_cdb.phpt b/ext/dba/tests/dba_cdb.phpt deleted file mode 100644 index 2390acbce5..0000000000 --- a/ext/dba/tests/dba_cdb.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -DBA CDB handler test ---SKIPIF-- -<?php - require_once('skipif.inc'); - if (!in_array('cdb', dba_handlers())) die('skip CDB handler not available'); - die('skip CDB does not support replace or delete'); -?> ---FILE-- -<?php - require_once('test.inc'); - $handler = 'cdb'; - require_once('dba_handler.inc'); -?> ---EXPECT-- -database handler: cdb -3NYNYY -Content String 2 -Content 2 replaced -Read during write: not allowed -Content 2 replaced 2nd time -The 6th value -array(3) { - ["key number 6"]=> - string(13) "The 6th value" - ["key2"]=> - string(27) "Content 2 replaced 2nd time" - ["key5"]=> - string(23) "The last content string" -}
\ No newline at end of file diff --git a/ext/dba/tests/dba_cdb_make.phpt b/ext/dba/tests/dba_cdb_make.phpt deleted file mode 100644 index 40a417860c..0000000000 --- a/ext/dba/tests/dba_cdb_make.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -DBA CDB_MAKE handler test ---INI-- -magic_quotes_runtime=1 ---SKIPIF-- -<?php - require_once('skipif.inc'); - if (!in_array('cdb_make', dba_handlers())) die('skip CDB_MAKE handler not available'); -?> ---FILE-- -<?php - require_once('test.inc'); - $handler = 'cdb_make'; - echo "database handler: $handler\n"; - // print md5 checksum of test.cdb which is generated by cdb_make program - var_dump(md5(implode('',file(dirname(__FILE__).'/test.cdb')))); - if (($db_make=dba_open($db_file, "n", $handler))!==FALSE) { - dba_insert("1", "1", $db_make); - dba_insert("2", "2", $db_make); - dba_insert("1", "3", $db_make); - dba_insert("2", "1", $db_make); - dba_insert("3", "3", $db_make); - dba_insert("1", "2", $db_make); - dba_insert("4", "4", $db_make); -// dba_replace cdb_make doesn't know replace - dba_close($db_make); - // write md5 checksum of generated database file - var_dump(md5(implode('',file($db_file)))); - // no need to test created database: this is done by dba_cdb_read.phpt - } else { - echo "Error creating database\n"; - } -?> ---EXPECT-- -database handler: cdb_make -string(32) "723d19f39c1b15b3b455dd64323148d1" -string(32) "723d19f39c1b15b3b455dd64323148d1"
\ No newline at end of file diff --git a/ext/dba/tests/dba_cdb_read.phpt b/ext/dba/tests/dba_cdb_read.phpt deleted file mode 100644 index 573a58cee3..0000000000 --- a/ext/dba/tests/dba_cdb_read.phpt +++ /dev/null @@ -1,65 +0,0 @@ ---TEST-- -DBA CDB handler test (read only) ---SKIPIF-- -<?php - if (!extension_loaded('dba')) die('skip dba extension not available'); - if (!in_array('cdb', dba_handlers())) die('skip CDB handler not available'); -?> ---FILE-- -<?php - echo "database handler: cdb\n"; - $handler = 'cdb'; - $db_file = dirname(__FILE__).'/test.cdb'; - if (($db_file=dba_open($db_file, "r", $handler))!==FALSE) { - // read key sequence - $a = dba_firstkey($db_file); - $count= 0; - $keys = $a; - while($a) { - $a = dba_nextkey($db_file); - $keys .= $a; - $count++; - } - // display number of entries and key existance - echo $count; - for ($i=1; $i<8; $i++) { - echo dba_exists($i, $db_file) ? "Y" : "N"; - } - echo "\n="; - echo dba_fetch(1, $db_file); - echo dba_fetch(2, $db_file); - echo dba_fetch(3, $db_file); - echo dba_fetch(4, $db_file); - echo "\n#"; - echo dba_fetch(1, $db_file); - echo dba_fetch(1, $db_file); - echo dba_fetch(2, $db_file); - echo dba_fetch(2, $db_file); - echo "\n?".$keys; - // with skip = 0 dba_fetch must fetch the first result - echo "\n#"; - $skip = array(); - for ($i=0; $i < strlen($keys); $i++) { - $key = substr($keys, $i, 1); - $skip[$key] = 0; - echo dba_fetch($key, $db_file); - } - echo "\n="; - for ($i=0; $i < strlen($keys); $i++) { - $key = substr($keys, $i, 1); - echo dba_fetch($key, $skip[$key], $db_file); - $skip[$key]++; - } - dba_close($db_file); - } else { - echo "Error creating database\n"; - } -?> ---EXPECT-- -database handler: cdb -7YYYYNNN -=1234 -#1122 -?1212314 -#1212314 -=1231324
\ No newline at end of file diff --git a/ext/dba/tests/dba_db2.phpt b/ext/dba/tests/dba_db2.phpt deleted file mode 100644 index 154ea32111..0000000000 --- a/ext/dba/tests/dba_db2.phpt +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -DBA DB2 handler test ---SKIPIF-- -<?php - require_once('skipif.inc'); - if (!in_array('db2', dba_handlers())) die('skip DB2 handler not available'); -?> ---FILE-- -<?php - require_once('test.inc'); - $handler = 'db2'; - require_once('dba_handler.inc'); -?> ---EXPECT-- -database handler: db2 -3NYNYY -Content String 2 -Content 2 replaced -Read during write: not allowed -Content 2 replaced 2nd time -The 6th value -array(3) { - ["key number 6"]=> - string(13) "The 6th value" - ["key2"]=> - string(27) "Content 2 replaced 2nd time" - ["key5"]=> - string(23) "The last content string" -}
\ No newline at end of file diff --git a/ext/dba/tests/dba_db3.phpt b/ext/dba/tests/dba_db3.phpt deleted file mode 100644 index e63b2da3e1..0000000000 --- a/ext/dba/tests/dba_db3.phpt +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -DBA DB3 handler test ---SKIPIF-- -<?php - require_once('skipif.inc'); - if (!in_array('db3', dba_handlers())) die('skip DB3 handler not available'); -?> ---FILE-- -<?php - require_once('test.inc'); - $handler = 'db3'; - require_once('dba_handler.inc'); -?> ---EXPECT-- -database handler: db3 -3NYNYY -Content String 2 -Content 2 replaced -Read during write: not allowed -Content 2 replaced 2nd time -The 6th value -array(3) { - ["key number 6"]=> - string(13) "The 6th value" - ["key2"]=> - string(27) "Content 2 replaced 2nd time" - ["key5"]=> - string(23) "The last content string" -}
\ No newline at end of file diff --git a/ext/dba/tests/dba_dbm.phpt b/ext/dba/tests/dba_dbm.phpt deleted file mode 100644 index 937d31d0d8..0000000000 --- a/ext/dba/tests/dba_dbm.phpt +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -DBA DBM handler test ---SKIPIF-- -<?php - require_once('skipif.inc'); - if (!in_array('dbm', dba_handlers())) die('skip DBM handler not available'); -?> ---FILE-- -<?php - require_once('test.inc'); - $handler = 'dbm'; - require_once('dba_handler.inc'); -?> ---EXPECT-- -database handler: dbm -3NYNYY -Content String 2 -Content 2 replaced -Read during write: not allowed -Content 2 replaced 2nd time -The 6th value -array(3) { - ["key number 6"]=> - string(13) "The 6th value" - ["key2"]=> - string(27) "Content 2 replaced 2nd time" - ["key5"]=> - string(23) "The last content string" -} diff --git a/ext/dba/tests/dba_flatfile.phpt b/ext/dba/tests/dba_flatfile.phpt deleted file mode 100644 index 42477dfd3c..0000000000 --- a/ext/dba/tests/dba_flatfile.phpt +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -DBA FlatFile handler test ---SKIPIF-- -<?php - require_once('skipif.inc'); - if (!in_array('flatfile', dba_handlers())) die('skip FlatFile handler not available'); -?> ---FILE-- -<?php - require_once('test.inc'); - $handler = 'flatfile'; - require_once('dba_handler.inc'); -?> ---EXPECT-- -database handler: flatfile -3NYNYY -Content String 2 -Content 2 replaced -Read during write: not allowed -Content 2 replaced 2nd time -The 6th value -array(3) { - ["key number 6"]=> - string(13) "The 6th value" - ["key2"]=> - string(27) "Content 2 replaced 2nd time" - ["key5"]=> - string(23) "The last content string" -}
\ No newline at end of file diff --git a/ext/dba/tests/dba_gdbm.phpt b/ext/dba/tests/dba_gdbm.phpt deleted file mode 100644 index c7eb5f9978..0000000000 --- a/ext/dba/tests/dba_gdbm.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -DBA GDBM handler test ---SKIPIF-- -<?php - require_once('skipif.inc'); - if (!in_array('gdbm', dba_handlers())) die('skip GDBM handler not available'); -?> ---FILE-- -<?php - require_once('test.inc'); - $handler = 'gdbm'; - $lock_flag = ''; // lock in library - require_once('dba_handler.inc'); - - // Read during write is system dependant. Important is that there is no deadlock -?> ---EXPECTF-- -database handler: gdbm -3NYNYY -Content String 2 -Content 2 replaced -Read during write:%sallowed -Content 2 replaced 2nd time -The 6th value -array(3) { - ["key number 6"]=> - string(13) "The 6th value" - ["key2"]=> - string(27) "Content 2 replaced 2nd time" - ["key5"]=> - string(23) "The last content string" -}
\ No newline at end of file diff --git a/ext/dba/tests/dba_handler.inc b/ext/dba/tests/dba_handler.inc deleted file mode 100644 index dafc991025..0000000000 --- a/ext/dba/tests/dba_handler.inc +++ /dev/null @@ -1,62 +0,0 @@ -<?php - echo "database handler: $handler\n"; - if (($db_file = dba_open($db_filename, 'n'.$lock_flag, $handler))!==FALSE) { - dba_insert("key1", "Content String 1", $db_file); - dba_insert("key2", "Content String 2", $db_file); - dba_insert("key3", "Third Content String", $db_file); - dba_insert("key4", "Another Content String", $db_file); - dba_insert("key5", "The last content string", $db_file); - dba_delete("key3", $db_file); - dba_delete("key1", $db_file); - $a = dba_firstkey($db_file); - $i=0; - while($a) { - $a = dba_nextkey($db_file); - $i++; - } - echo $i; - for ($i=1; $i<6; $i++) { - echo dba_exists("key$i", $db_file) ? "Y" : "N"; - } - echo "\n"; - echo dba_fetch("key2", $db_file)."\n"; - dba_replace("key2", "Content 2 replaced", $db_file); - echo dba_fetch("key2", $db_file)."\n"; - dba_close($db_file); - } else { - echo "Error creating database\n"; - } - $db_writer = dba_open($db_filename, 'w'.$lock_flag, $handler); - if (($dba_reader = @dba_open($db_filename, 'r'.$lock_flag.($lock_flag ? 't' : ''), $handler))===false) { - echo "Read during write: not allowed\n"; - } else { - echo "Read during write: allowed\n"; - } - if ($db_writer!==FALSE) { - dba_insert("key number 6", "The 6th value", $db_writer); - @dba_insert("key number 6", "The 6th value inserted again would be an error", $db_writer); - dba_replace("key2", "Content 2 replaced 2nd time", $db_writer); - dba_delete("key4", $db_writer); - echo dba_fetch("key2", $db_writer)."\n"; - echo dba_fetch("key number 6", $db_writer)."\n"; - dba_close($db_writer); // when the writer is open at least db3 would fail because of buffered io. - } else { - die("Error reopening database\n"); - } - if (($db_file = dba_open($db_filename, 'r'.$lock_flag, $handler))!==FALSE) { - $key = dba_firstkey($db_file); - $res = array(); - while($key) { - $res[$key] = dba_fetch($key, $db_file); - $key = dba_nextkey($db_file); - } - ksort($res); - var_dump($res); - dba_close($db_file); - } else { - echo "Error reading database\n"; - } - if ($dba_reader) { - dba_close($dba_reader); - } -?>
\ No newline at end of file diff --git a/ext/dba/tests/dba_ndbm.phpt b/ext/dba/tests/dba_ndbm.phpt deleted file mode 100644 index fd37b7bad2..0000000000 --- a/ext/dba/tests/dba_ndbm.phpt +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -DBA NDBM handler test ---SKIPIF-- -<?php - require_once('skipif.inc'); - if (!in_array('ndbm', dba_handlers())) die('skip NDBM handler not available'); -?> ---FILE-- -<?php - require_once('test.inc'); - $handler = 'ndbm'; - require_once('dba_handler.inc'); -?> ---EXPECT-- -database handler: ndbm -3NYNYY -Content String 2 -Content 2 replaced -Read during write: not allowed -Content 2 replaced 2nd time -The 6th value -array(3) { - ["key number 6"]=> - string(13) "The 6th value" - ["key2"]=> - string(27) "Content 2 replaced 2nd time" - ["key5"]=> - string(23) "The last content string" -}
\ No newline at end of file diff --git a/ext/dba/tests/skipif.inc b/ext/dba/tests/skipif.inc deleted file mode 100644 index 141c907111..0000000000 --- a/ext/dba/tests/skipif.inc +++ /dev/null @@ -1,20 +0,0 @@ -<?php - if (!extension_loaded('dba')) die('skip dba extension not available'); - if (!function_exists('dba_handlers')) die ('skip dba_handlers() not available'); - if (!sizeof(dba_handlers())) die('skip no handlers installed'); - $handler = dba_handlers(); - if (in_array('flatfile', $handler)) { - $handler = 'flatfile'; - } elseif ($handler[0]=='cdb') { // CDB currently supports only reading - if (count($handler)==1) { - die('skip CDB currently supports only reading'); - } - if ($handler[1]=='cdb_make' && count($handler)==2) { - die('skip CDB currently supports only reading and creating'); - } - $handler = $handler[1]; - } else { - $handler = $handler[0]; - } - $HND = strtoupper($handler); -?> diff --git a/ext/dba/tests/test.cdb b/ext/dba/tests/test.cdb Binary files differdeleted file mode 100644 index 21529c6280..0000000000 --- a/ext/dba/tests/test.cdb +++ /dev/null diff --git a/ext/dba/tests/test.inc b/ext/dba/tests/test.inc deleted file mode 100644 index 402096dbe9..0000000000 --- a/ext/dba/tests/test.inc +++ /dev/null @@ -1,17 +0,0 @@ -<?php - $db_filename = $db_file = dirname(__FILE__).'/test0.dbm'; - $handler = dba_handlers(); - if (in_array('flatfile', $handler)) { - $handler = 'flatfile'; - } elseif ($handler[0]=='cdb') { // CDB currently supports only reading - if (count($handler)==1) { - die('CDB currently supports only reading '); - } - $handler = $handler[1]; - } else { - $handler = $handler[0]; - } - $lock_flag = 'l'; - @unlink($db_filename); - @unlink($db_filename.'.lck'); -?> |