diff options
Diffstat (limited to 'ext')
53 files changed, 1231 insertions, 3589 deletions
diff --git a/ext/Makefile.am b/ext/Makefile.am index 12f02bafc4..0903c2c82b 100644 --- a/ext/Makefile.am +++ b/ext/Makefile.am @@ -1,10 +1,9 @@ ## Process this file with automake to produce Makefile.in SUBDIRS = @EXT_SUBDIRS@ -EXT_STATIC = @EXT_STATIC@ noinst_LIBRARIES=libphpext.a libphpext.a: @EXT_LIBS@ - top_srcdir=$(top_srcdir) $(top_builddir)/scripts/mkextlib $@ $(EXT_STATIC) + top_srcdir=$(top_srcdir) $(top_builddir)/scripts/mkextlib $@ $(SUBDIRS) -@test "`uname -s`" = "Rhapsody" && $(RANLIB) $@ diff --git a/ext/dba/Makefile.am b/ext/dba/Makefile.am deleted file mode 100644 index b609be3bf3..0000000000 --- a/ext/dba/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -# $Id$ - -INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend -noinst_LIBRARIES=libphpext_dba.a -libphpext_dba_a_SOURCES=dba.c dba_cdb.c dba_db2.c dba_dbm.c dba_gdbm.c \ - dba_ndbm.c - diff --git a/ext/dba/config.h.stub b/ext/dba/config.h.stub deleted file mode 100644 index f65ae9b7fa..0000000000 --- a/ext/dba/config.h.stub +++ /dev/null @@ -1,17 +0,0 @@ -/* define if you want to use the dba extension */ - -#define NDBM_DB1_NDBM_H 0 -#define NDBM_NDBM_H 0 -#define DB2_DB2_DB_H 0 -#define DB2_DB_DB2_H 0 -#define DB2_DB_H 0 -#define DB2_DB2_H 0 -#define HAVE_DBA 0 -#define DBA_GDBM 0 -#define DBA_NDBM 0 -#define DBA_DBOPEN 0 -#define DBA_DB2 0 -#define DBA_DBM 0 -#define DBA_CDB 0 - - diff --git a/ext/dba/config.m4 b/ext/dba/config.m4 deleted file mode 100644 index c3e9b60aa0..0000000000 --- a/ext/dba/config.m4 +++ /dev/null @@ -1,210 +0,0 @@ -dnl $Id$ -dnl config.m4 for extension dba -dnl don't forget to call PHP_EXTENSION(dba) - -AC_DEFUN(AC_TEMP_LDFLAGS,[ - old_LDFLAGS="$LDFLAGS" - LDFLAGS="$1 $LDFLAGS" - $2 - LDFLAGS="$old_LDFLAGS" -]) - - -dnl Assign INCLUDE/LFLAGS from PREFIX -AC_DEFUN(AC_DBA_STD_ASSIGN,[ - if test "$THIS_PREFIX" != "" -a "$THIS_PREFIX" != "/usr"; then - THIS_INCLUDE="$THIS_PREFIX/include" - THIS_LFLAGS="$THIS_PREFIX/lib" - fi -]) - -dnl Standard check -AC_DEFUN(AC_DBA_STD_CHECK,[ - THIS_RESULT="yes" - if test "$THIS_PREFIX" != "/usr"; then - if test "$THIS_INCLUDE" = "" ; then - AC_MSG_ERROR(cannot find necessary header file(s)) - elif test "$THIS_LIBS" = "" ; then - AC_MSG_ERROR(cannot find necessary library) - fi - fi -]) - -dnl Attach THIS_x to DBA_x -AC_DEFUN(AC_DBA_STD_ATTACH,[ - AC_ADD_INCLUDE($THIS_INCLUDE) - AC_ADD_LIBRARY_WITH_PATH($THIS_LIBS, $THIS_LFLAGS) - - THIS_INCLUDE="" - THIS_LIBS="" - THIS_LFLAGS="" - THIS_PREFIX="" -]) - -dnl Print the result message -AC_DEFUN(AC_DBA_STD_RESULT,[ - if test "$THIS_RESULT" = "yes"; then - HAVE_DBA=1 - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - fi - THIS_RESULT="" -]) - - - -AC_ARG_WITH(gdbm, -[ --with-gdbm[=DIR] Include GDBM support],[ - if test "$withval" != "no"; then - for i in /usr/local /usr $withval; do - if test -f "$i/include/gdbm.h"; then - THIS_PREFIX="$i" - fi - done - - unset ac_cv_lib_gdbm_gdbm_open - AC_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[ - AC_CHECK_LIB(gdbm, gdbm_open, [AC_DEFINE(DBA_GDBM, 1) THIS_LIBS="gdbm"]) - ]) - - AC_DBA_STD_ASSIGN - AC_DBA_STD_CHECK - AC_DBA_STD_ATTACH - fi -]) -AC_MSG_CHECKING(for GDBM support) -AC_DBA_STD_RESULT - -AC_ARG_WITH(ndbm, -[ --with-ndbm[=DIR] Include NDBM support],[ - if test "$withval" != "no"; then - for i in /usr/local /usr $withval; do - if test -f "$i/include/db1/ndbm.h" ; then - THIS_PREFIX="$i" - NDBM_EXTRA="NDBM_DB1_NDBM_H" - elif test -f "$i/include/ndbm.h" ; then - THIS_PREFIX="$i" - NDBM_EXTRA="NDBM_NDBM_H" - fi - done - - if test "$NDBM_EXTRA" != ""; then - eval "AC_DEFINE($NDBM_EXTRA, 1)" - fi - - for LIB in db1 ndbm c; do - AC_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[ - AC_CHECK_LIB($LIB, dbm_open, [AC_DEFINE(DBA_NDBM,1) THIS_LIBS="$LIB"]) - ]) - done - - AC_DBA_STD_ASSIGN - AC_DBA_STD_CHECK - AC_DBA_STD_ATTACH - fi -]) -AC_MSG_CHECKING(for NDBM support) -AC_DBA_STD_RESULT - -AC_ARG_WITH(db2, -[ --with-db2[=DIR] Include DB2 support],[ - if test "$withval" != "no"; then - for i in /usr/local /usr /usr/BerkeleyDB $withval; do - if test -f "$i/db2/db.h"; then - THIS_PREFIX="$i" - DB2_EXTRA="db2" - elif test -f "$i/include/db2/db.h"; then - THIS_PREFIX="$i" - DB2_EXTRA="DB2_DB2_DB_H" - elif test -f "$i/include/db/db2.h"; then - THIS_PREFIX="$i" - DB2_EXTRA="DB2_DB_DB2_H" - elif test -f "$i/include/db2.h"; then - THIS_PREFIX="$i" - DB2_EXTRA="DB2_DB2_H" - elif test -f "$i/include/db.h" ; then - THIS_PREFIX="$i" - DB2_EXTRA="DB2_DB_H" - fi - done - - if test "$DB2_EXTRA" = "db2" ; then - DBA_INCLUDE="$DBA_INCLUDE -I$THIS_PREFIX/db2" - DB2_EXTRA="DB2_DB_H" - fi - - if test "$DB2_EXTRA" != ""; then - eval "AC_DEFINE($DB2_EXTRA, 1)" - fi - - for LIB in db db2 c; do - AC_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[ - AC_CHECK_LIB($LIB, db_appinit, [AC_DEFINE(DBA_DB2,1) THIS_LIBS="$LIB"]) - ]) - done - - AC_DBA_STD_ASSIGN - AC_DBA_STD_CHECK - AC_DBA_STD_ATTACH - fi -]) -AC_MSG_CHECKING(for DB2 support) -AC_DBA_STD_RESULT - -AC_ARG_WITH(dbm, -[ --with-dbm[=DIR] Include DBM support],[ - if test "$withval" != "no"; then - for i in /usr/local /usr $withval; do - if test -f "$i/include/dbm.h" ; then - THIS_PREFIX="$i" - fi - done - - for LIB in db1 dbm c; do - AC_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[ - AC_CHECK_LIB($LIB, dbminit, [AC_DEFINE(DBA_DBM,1) THIS_LIBS="$LIB"]) - ]) - done - - AC_DBA_STD_ASSIGN - AC_DBA_STD_CHECK - AC_DBA_STD_ATTACH - fi -]) -AC_MSG_CHECKING(for DBM support) -AC_DBA_STD_RESULT - -AC_ARG_WITH(cdb, -[ --with-cdb[=DIR] Include CDB support],[ - if test "$withval" != "no"; then - for i in /usr/local /usr $withval; do - if test -f "$i/include/cdb.h" ; then - THIS_PREFIX="$i" - fi - done - - for LIB in cdb c; do - AC_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[ - AC_CHECK_LIB($LIB, cdb_bread, [AC_DEFINE(DBA_CDB,1) THIS_LIBS="$LIB"]) - ]) - done - - AC_DBA_STD_ASSIGN - AC_DBA_STD_CHECK - AC_DBA_STD_ATTACH - fi -]) -AC_MSG_CHECKING(for CDB support) -AC_DBA_STD_RESULT - -AC_MSG_CHECKING(whether to enable DBA interface) -if test "$HAVE_DBA" = "1"; then - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_DBA, 1) - PHP_EXTENSION(dba) -else - AC_MSG_RESULT(no) - AC_DEFINE(HAVE_DBA, 0) -fi - diff --git a/ext/dba/dba.c b/ext/dba/dba.c deleted file mode 100644 index 7024673d21..0000000000 --- a/ext/dba/dba.c +++ /dev/null @@ -1,476 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP HTML Embedded Scripting Language Version 3.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1999 PHP Development Team (See Credits file) | - +----------------------------------------------------------------------+ - | This program is free software; you can redistribute it and/or modify | - | it under the terms of one of the following licenses: | - | | - | A) the GNU General Public License as published by the Free Software | - | Foundation; either version 2 of the License, or (at your option) | - | any later version. | - | | - | B) the PHP License as published by the PHP Development Team and | - | included in the distribution in the file: LICENSE | - | | - | This program is distributed in the hope that it will be useful, | - | but WITHOUT ANY WARRANTY; without even the implied warranty of | - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | - | GNU General Public License for more details. | - | | - | You should have received a copy of both licenses referred to here. | - | If you did not, or have any questions about PHP licensing, please | - | contact core@php.net. | - +----------------------------------------------------------------------+ - | Authors: Sascha Schumann <sas@schell.de> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#include "php.h" - -#if HAVE_DBA - -#include "php3_dba.h" - -#include "php3_gdbm.h" -#include "php3_ndbm.h" -#include "php3_dbm.h" -#include "php3_cdb.h" -#include "php3_db2.h" - -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) - {NULL,NULL,NULL} -}; - -static int php3_minit_dba(INIT_FUNC_ARGS); -static int php3_mshutdown_dba(SHUTDOWN_FUNC_ARGS); -static void php3_info_dba(ZEND_MODULES_INFO_FUNC_ARGS); - -php3_module_entry dba_module_entry = { - "DataBase API", dba_functions, - php3_minit_dba, - php3_mshutdown_dba, - NULL, NULL, - php3_info_dba, - STANDARD_MODULE_PROPERTIES -}; - -typedef struct dba_handler { - char *name; - int (*open)(dba_info *); - void (*close)(dba_info *); - char* (*fetch)(dba_info *, char *, int, int *); - int (*update)(dba_info *, char *, int, char *, int, int); - int (*exists)(dba_info *, char *, int); - int (*delete)(dba_info *, char *, int); - char* (*firstkey)(dba_info *, int *); - char* (*nextkey)(dba_info *, int *); - int (*optimize)(dba_info *); - int (*sync)(dba_info *); -} dba_handler; - -/* {{{ macromania */ - -#define DBA_ID_PARS pval *id; dba_info *info = NULL; int type, ac = ARG_COUNT(ht) - -/* these are used to get the standard arguments */ - -#define DBA_GET1 \ - if(ac != 1 || getParameters(ht, ac, &id) != SUCCESS) { \ - WRONG_PARAM_COUNT; \ - } - -#define DBA_GET2 \ - pval *key; \ - if(ac != 2 || getParameters(ht, ac, &key, &id) != SUCCESS) { \ - WRONG_PARAM_COUNT; \ - } \ - convert_to_string(key) - -#define DBA_IF_NOT_CORRECT_TYPE(link_id) \ - info = php3_list_find(link_id, &type); \ - if(!info || (type != GLOBAL(le_db) && type != GLOBAL(le_pdb))) - -#define DBA_ID_GET \ - convert_to_long(id); \ - DBA_IF_NOT_CORRECT_TYPE(id->value.lval) { \ - php3_error(E_WARNING, "Unable to find DBA identifier %d", id->value.lval); \ - RETURN_FALSE; \ - } - -#define DBA_ID_GET1 DBA_ID_PARS; DBA_GET1; DBA_ID_GET -#define DBA_ID_GET2 DBA_ID_PARS; DBA_GET2; DBA_ID_GET - -/* a DBA handler must have specific routines */ - -#define DBA_HND(x) \ -{\ - #x, 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 \ -}, - -/* check whether the user has write access */ -#define DBA_WRITE_CHECK \ - if(info->mode != DBA_WRITER && info->mode != DBA_TRUNC && info->mode != DBA_CREAT) { \ - php3_error(E_WARNING, "you cannot perform a modification to a database without proper access"); \ - RETURN_FALSE; \ - } - -#define GLOBAL(a) a - -/* }}} */ - -/* {{{ globals */ - -static dba_handler handler[] = { -#if DBA_GDBM - DBA_HND(gdbm) -#endif -#if DBA_DBM - DBA_HND(dbm) -#endif -#if DBA_NDBM - DBA_HND(ndbm) -#endif -#if DBA_CDB - DBA_HND(cdb) -#endif -#if DBA_DB2 - DBA_HND(db2) -#endif - { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } -}; - -static int le_db; -static int le_pdb; -static HashTable ht_keys; -/* }}} */ - -/* {{{ helper routines */ - /* {{{ dba_close */ - -static void dba_close(dba_info *info) -{ - if(info->hnd) info->hnd->close(info); - if(info->path) free(info->path); - free(info); -} -/* }}} */ - /* {{{ php3_minit_dba */ - -static int php3_minit_dba(INIT_FUNC_ARGS) -{ - _php3_hash_init(&ht_keys, 0, NULL, NULL, 1); - GLOBAL(le_db) = register_list_destructors(dba_close, NULL); - GLOBAL(le_pdb) = register_list_destructors(NULL, dba_close); - return SUCCESS; -} -/* }}} */ - /* {{{ php3_mshutdown_dba */ - -static int php3_mshutdown_dba(SHUTDOWN_FUNC_ARGS) -{ - _php3_hash_destroy(&ht_keys); - return SUCCESS; -} -/* }}} */ - /* {{{ php3_info_dba */ - -static void php3_info_dba(ZEND_MODULE_INFO_FUNC_ARGS) -{ - dba_handler *hptr; - - PUTS("V1 ($Id$)"); - for(hptr = handler; hptr->name; hptr++) { - PUTS(" "); - PUTS(hptr->name); - } -} -/* }}} */ - /* {{{ _php3_dba_update */ - -static void _php3_dba_update(INTERNAL_FUNCTION_PARAMETERS, int mode) -{ - DBA_ID_PARS; - pval *val, *key; - - if(ac != 3 || getParameters(ht, ac, &key, &val, &id) != SUCCESS) { - WRONG_PARAM_COUNT; - } - convert_to_string(key); - convert_to_string(val); - DBA_ID_GET; - - DBA_WRITE_CHECK; - - if(info->hnd->update(info, VALLEN(key), VALLEN(val), mode) == SUCCESS) - RETURN_TRUE; - RETURN_FALSE; -} -/* }}} */ - /* {{{ _php3_dba_open */ - -#define FREENOW if(args) efree(args); if(key) efree(key) - -static void _php3_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent) -{ - pval **args = (pval **) NULL; - int ac = ARG_COUNT(ht); - dba_mode_t modenr; - dba_info *info; - dba_handler *hptr; - char *key = NULL; - int keylen = 0; - int listid; - int i; - - if(ac < 3) { - WRONG_PARAM_COUNT; - } - - /* we pass additional args to the respective handler */ - args = emalloc(ac * sizeof(pval *)); - if(getParametersArray(ht, ac, args) != SUCCESS) { - FREENOW; - WRONG_PARAM_COUNT; - } - - /* we only take string arguments */ - for(i = 0; i < ac; i++) { - convert_to_string(args[i]); - keylen += args[i]->value.str.len; - } - - if(persistent) { - /* calculate hash */ - key = emalloc(keylen); - keylen = 0; - - for(i = 0; i < ac; i++) { - memcpy(key+keylen,args[i]->value.str.val,args[i]->value.str.len); - keylen += args[i]->value.str.len; - } - - if(_php3_hash_find(&ht_keys, key, keylen, (void **) &info) == SUCCESS) { - FREENOW; - RETURN_LONG(php3_list_insert(info, GLOBAL(le_pdb))); - } - } - - /* this is O(n) and could be improved */ - for(hptr = handler; hptr->name && - strcasecmp(hptr->name, args[2]->value.str.val); hptr++); - - if(!hptr->name) { - php3_error(E_WARNING, "no such handler: %s", args[2]->value.str.val); - FREENOW; - RETURN_FALSE; - } - - switch(args[1]->value.str.val[0]) { - case 'c': - modenr = DBA_CREAT; - break; - case 'w': - modenr = DBA_WRITER; - break; - case 'r': - modenr = DBA_READER; - break; - case 'n': - modenr = DBA_TRUNC; - break; - default: - php3_error(E_WARNING,"illegal DBA mode: %s",args[1]->value.str.val); - FREENOW; - RETURN_FALSE; - } - - info = malloc(sizeof(*info)); - memset(info, 0, sizeof(info)); - info->path = strdup(args[0]->value.str.val); - info->mode = modenr; - info->argc = ac - 3; - info->argv = args + 3; - info->hnd = NULL; - - if(hptr->open(info) != SUCCESS) { - dba_close(info); - php3_error(E_WARNING, "driver initialization failed"); - FREENOW; - RETURN_FALSE; - } - info->hnd = hptr; - info->argc = 0; - info->argv = NULL; - - listid = php3_list_insert(info, persistent?GLOBAL(le_pdb):GLOBAL(le_db)); - if(persistent) { - _php3_hash_update(&ht_keys, key, keylen, info, sizeof(*info), NULL); - } - - FREENOW; - RETURN_LONG(listid); -} -#undef FREENOW -/* }}} */ -/* }}} */ - -/* {{{ proto int dba_popen(string path, string mode, string handlername[, ...]) - opens path using the specified handler in mode persistently */ -PHP_FUNCTION(dba_popen) -{ - _php3_dba_open(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); -} -/* }}} */ - -/* {{{ proto int dba_open(string path, string mode, string handlername[, ...]) - opens path using the specified handler in mode*/ -PHP_FUNCTION(dba_open) -{ - _php3_dba_open(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); -} -/* }}} */ - -/* {{{ proto void dba_close(int handle) - closes database */ -PHP_FUNCTION(dba_close) -{ - DBA_ID_GET1; - - php3_list_delete(id->value.lval); -} -/* }}} */ - -/* {{{ 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)) == SUCCESS) { - RETURN_TRUE; - } - RETURN_FALSE; -} -/* }}} */ - -/* {{{ proto string dba_fetch(string key, int handle) - fetches the data associated with key */ -PHP_FUNCTION(dba_fetch) -{ - char *val; - int len = 0; - DBA_ID_GET2; - - if((val = info->hnd->fetch(info, VALLEN(key), &len)) != NULL) { - 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); - 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); - 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)) == 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) -{ - _php3_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) -{ - _php3_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) == 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) == SUCCESS) { - RETURN_TRUE; - } - RETURN_FALSE; -} -/* }}} */ - -#endif diff --git a/ext/dba/dba_cdb.c b/ext/dba/dba_cdb.c deleted file mode 100644 index 55683590c5..0000000000 --- a/ext/dba/dba_cdb.c +++ /dev/null @@ -1,220 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP HTML Embedded Scripting Language Version 3.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1999 PHP Development Team (See Credits file) | - +----------------------------------------------------------------------+ - | This program is free software; you can redistribute it and/or modify | - | it under the terms of one of the following licenses: | - | | - | A) the GNU General Public License as published by the Free Software | - | Foundation; either version 2 of the License, or (at your option) | - | any later version. | - | | - | B) the PHP License as published by the PHP Development Team and | - | included in the distribution in the file: LICENSE | - | | - | This program is distributed in the hope that it will be useful, | - | but WITHOUT ANY WARRANTY; without even the implied warranty of | - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | - | GNU General Public License for more details. | - | | - | You should have received a copy of both licenses referred to here. | - | If you did not, or have any questions about PHP licensing, please | - | contact core@php.net. | - +----------------------------------------------------------------------+ - | Authors: Sascha Schumann <sas@schell.de> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#include "php.h" - -#if DBA_CDB -#include "php3_cdb.h" - -#include <sys/types.h> -#include <unistd.h> -#include <fcntl.h> - -#include <cdb.h> -#include <cdbmake.h> - -#define CDB_INFO \ - dba_cdb *cdb = (dba_cdb *) info->dbf - -typedef struct { - int fd; - uint32 eod; /* size of constant database */ - uint32 pos; /* current position for traversing */ -} dba_cdb; - -DBA_OPEN_FUNC(cdb) -{ - int gmode = 0; - dba_cdb *cdb; - dba_info *pinfo = (dba_info *) info; - - switch(info->mode) { - case DBA_READER: - gmode = O_RDONLY; break; - /* currently not supported: */ -#if 0 - case DBA_WRITER: - gmode = O_RDWR; break; -#endif - default: - return FAILURE; - } - - cdb = malloc(sizeof *cdb); - memset(cdb, 0, sizeof *cdb); - - cdb->fd = open(info->path, gmode); - if(cdb->fd < 0) { - free(cdb); - return FAILURE; - } - - pinfo->dbf = cdb; - return SUCCESS; -} - -DBA_CLOSE_FUNC(cdb) -{ - CDB_INFO; - - close(cdb->fd); - free(cdb); -} - -DBA_FETCH_FUNC(cdb) -{ - CDB_INFO; - int len; - char *new = NULL; - - if(cdb_seek(cdb->fd, key, keylen, &len) == 1) { - new = emalloc(len); - read(cdb->fd, new, len); - if(newlen) *newlen = len; - } - - return new; -} - -DBA_UPDATE_FUNC(cdb) -{ - /* if anyone figures out cdbmake.c, let me know */ - return FAILURE; -} - -DBA_EXISTS_FUNC(cdb) -{ - CDB_INFO; - int len; - - if(cdb_seek(cdb->fd, key, keylen, &len) == 1) - return SUCCESS; - return FAILURE; -} - -DBA_DELETE_FUNC(cdb) -{ - return FAILURE; -} - - -#define CREAD(n) if(read(cdb->fd, buf, n) < n) return NULL -#define CSEEK(n) \ - if(n >= cdb->eod) return NULL; \ - if(lseek(cdb->fd, (off_t)n, SEEK_SET) != (off_t) n) return NULL - -DBA_FIRSTKEY_FUNC(cdb) -{ - CDB_INFO; - uint32 len; - char buf[8]; - char *key; - - cdb->eod = -1; - CSEEK(0); - CREAD(4); - cdb->eod = cdb_unpack(buf); - - CSEEK(2048); - CREAD(8); - len = cdb_unpack(buf); - - key = emalloc(len + 1); - if(read(cdb->fd, key, len) < len) { - efree(key); - key = NULL; - } else - key[len] = '\0'; - /* header + klenlen + dlenlen + klen + dlen */ - cdb->pos = 2048 + 4 + 4 + len + cdb_unpack(buf + 4); - - return key; -} - -DBA_NEXTKEY_FUNC(cdb) -{ - CDB_INFO; - uint32 len; - char buf[8]; - char *nkey; - - CSEEK(cdb->pos); - CREAD(8); - len = cdb_unpack(buf); - - nkey = emalloc(len + 1); - if(read(cdb->fd, nkey, len) < len) { - efree(nkey); - return NULL; - } - nkey[len] = '\0'; - if(newlen) *newlen = len; - - cdb->pos += 8 + len + cdb_unpack(buf + 4); - - return nkey; -#if 0 - /* this code cdb_seeks and is thus slower than directly seeking - in the file */ - CDB_INFO; - char *nkey = NULL; - uint32 len; - char buf[8]; - - if(cdb_seek(cdb->fd, key, keylen, &len) == 1) { - if(lseek(cdb->fd, (off_t) len, SEEK_CUR) >= (off_t) cdb->eod) - return NULL; - CREAD(8); - len = cdb_unpack(buf); - - nkey = emalloc(len + 1); - if(read(cdb->fd, nkey, len) < len) { - efree(nkey); - nkey = NULL; - } else - nkey[len] = '\0'; - } - return nkey; -#endif -} - -DBA_OPTIMIZE_FUNC(cdb) -{ - return SUCCESS; -} - -DBA_SYNC_FUNC(cdb) -{ - /* this is read-only */ - return SUCCESS; -} - -#endif diff --git a/ext/dba/dba_db2.c b/ext/dba/dba_db2.c deleted file mode 100644 index c522ef7c2d..0000000000 --- a/ext/dba/dba_db2.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP HTML Embedded Scripting Language Version 3.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1999 PHP Development Team (See Credits file) | - +----------------------------------------------------------------------+ - | This program is free software; you can redistribute it and/or modify | - | it under the terms of one of the following licenses: | - | | - | A) the GNU General Public License as published by the Free Software | - | Foundation; either version 2 of the License, or (at your option) | - | any later version. | - | | - | B) the PHP License as published by the PHP Development Team and | - | included in the distribution in the file: LICENSE | - | | - | This program is distributed in the hope that it will be useful, | - | but WITHOUT ANY WARRANTY; without even the implied warranty of | - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | - | GNU General Public License for more details. | - | | - | You should have received a copy of both licenses referred to here. | - | If you did not, or have any questions about PHP licensing, please | - | contact core@php.net. | - +----------------------------------------------------------------------+ - | Authors: Sascha Schumann <sas@schell.de> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#include "php.h" - -#if DBA_DB2 -#include "php3_db2.h" -#include <sys/stat.h> - -#include <string.h> -#if DB2_DB2_DB_H -#include <db2/db.h> -#elif DB2_DB_DB2_H -#include <db/db2.h> -#elif DB2_DB2_H -#include <db2.h> -#elif DB2_DB_H -#include <db.h> -#endif - -#define DB2_DATA dba_db2_data *dba = info->dbf -#define DB2_GKEY \ - DBT gkey; \ - memset(&gkey, 0, sizeof(gkey)); \ - 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; - - type = info->mode == DBA_READER ? DB_UNKNOWN : - info->mode == DBA_TRUNC ? DB_BTREE : - stat(info->path, &check_stat) ? DB_BTREE : DB_UNKNOWN; - - gmode = info->mode == DBA_READER ? DB_RDONLY : - info->mode == DBA_CREAT ? DB_CREATE : - info->mode == DBA_WRITER ? 0 : - info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1; - - if(gmode == -1) - return FAILURE; - - if(info->argc > 0) { - convert_to_long(info->argv[0]); - filemode = info->argv[0]->value.lval; - } - - if(!db_open(info->path, type, gmode, filemode, NULL, NULL, &dbp)) { - info->dbf = malloc(sizeof(dba_db2_data)); - memset(info->dbf, 0, sizeof(dba_db2_data)); - ((dba_db2_data *) info->dbf)->dbp = dbp; - return SUCCESS; - } - return FAILURE; -} - -DBA_CLOSE_FUNC(db2) -{ - DB2_DATA; - - if(dba->cursor) dba->cursor->c_close(dba->cursor); - dba->dbp->close(dba->dbp, DB_NOSYNC); - free(dba); -} - -DBA_FETCH_FUNC(db2) -{ - DBT gval; - char *new = NULL; - DB2_DATA; - DB2_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(db2) -{ - DBT gval; - DB2_DATA; - DB2_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(db2) -{ - DBT gval; - DB2_DATA; - DB2_GKEY; - - memset(&gval, 0, sizeof(gval)); - if(!dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) { - return SUCCESS; - } - return FAILURE; -} - -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); -} - -DBA_NEXTKEY_FUNC(db2) -{ - DB2_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)) { - if(gkey.data) { - nkey = estrndup(gkey.data, gkey.size); - if(newlen) *newlen = gkey.size; - } - } - return nkey; -} - -DBA_OPTIMIZE_FUNC(db2) -{ - return SUCCESS; -} - -DBA_SYNC_FUNC(db2) -{ - DB2_DATA; - - return dba->dbp->sync(dba->dbp, 0) ? FAILURE : SUCCESS; -} - -#endif diff --git a/ext/dba/dba_dbm.c b/ext/dba/dba_dbm.c deleted file mode 100644 index 5858e8e610..0000000000 --- a/ext/dba/dba_dbm.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP HTML Embedded Scripting Language Version 3.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1999 PHP Development Team (See Credits file) | - +----------------------------------------------------------------------+ - | This program is free software; you can redistribute it and/or modify | - | it under the terms of one of the following licenses: | - | | - | A) the GNU General Public License as published by the Free Software | - | Foundation; either version 2 of the License, or (at your option) | - | any later version. | - | | - | B) the PHP License as published by the PHP Development Team and | - | included in the distribution in the file: LICENSE | - | | - | This program is distributed in the hope that it will be useful, | - | but WITHOUT ANY WARRANTY; without even the implied warranty of | - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | - | GNU General Public License for more details. | - | | - | You should have received a copy of both licenses referred to here. | - | If you did not, or have any questions about PHP licensing, please | - | contact core@php.net. | - +----------------------------------------------------------------------+ - | Authors: Sascha Schumann <sas@schell.de> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#include "php.h" - -#if DBA_DBM -#include "php3_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 - -#ifndef PATH_MAX -#define PATH_MAX 255 -#endif - -#define TRUNC_IT(extension, mode) \ - snprintf(buf, PATH_MAX, "%s" extension, info->path); \ - buf[PATH_MAX] = '\0'; \ - if((fd = open(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(info->argv[0]); - filemode = info->argv[0]->value.lval; - } - - if(info->mode == DBA_TRUNC) { - char buf[PATH_MAX + 1]; - - /* dbm/ndbm original */ - TRUNC_IT(".pag", O_TRUNC); - TRUNC_IT(".dir", O_TRUNC); - } - - if(info->mode == DBA_CREAT) { - char buf[PATH_MAX + 1]; - - TRUNC_IT(".pag", 0); - TRUNC_IT(".dir", 0); - } - - if(dbminit((char *) info->path) == -1) { - return FAILURE; - } - - info->dbf = calloc(sizeof(dba_dbm_data), 1); - return SUCCESS; -} - -DBA_CLOSE_FUNC(dbm) -{ - free(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 diff --git a/ext/dba/dba_gdbm.c b/ext/dba/dba_gdbm.c deleted file mode 100644 index 0e5f1450f2..0000000000 --- a/ext/dba/dba_gdbm.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP HTML Embedded Scripting Language Version 3.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1999 PHP Development Team (See Credits file) | - +----------------------------------------------------------------------+ - | This program is free software; you can redistribute it and/or modify | - | it under the terms of one of the following licenses: | - | | - | A) the GNU General Public License as published by the Free Software | - | Foundation; either version 2 of the License, or (at your option) | - | any later version. | - | | - | B) the PHP License as published by the PHP Development Team and | - | included in the distribution in the file: LICENSE | - | | - | This program is distributed in the hope that it will be useful, | - | but WITHOUT ANY WARRANTY; without even the implied warranty of | - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | - | GNU General Public License for more details. | - | | - | You should have received a copy of both licenses referred to here. | - | If you did not, or have any questions about PHP licensing, please | - | contact core@php.net. | - +----------------------------------------------------------------------+ - | Authors: Sascha Schumann <sas@schell.de> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#include "php.h" - -#if DBA_GDBM -#include "php3_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; - - if(info->argc > 0) { - convert_to_long(info->argv[0]); - filemode = info->argv[0]->value.lval; - } - - dbf = gdbm_open(info->path, 0, gmode, filemode, NULL); - - if(dbf) { - info->dbf = malloc(sizeof(dba_gdbm_data)); - memset(info->dbf, 0, sizeof(dba_gdbm_data)); - ((dba_gdbm_data *) info->dbf)->dbf = dbf; - return SUCCESS; - } - return FAILURE; -} - -DBA_CLOSE_FUNC(gdbm) -{ - GDBM_DATA; - - if(dba->nextkey.dptr) free(dba->nextkey.dptr); - gdbm_close(dba->dbf); - free(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; - printf("XXX %s\n", 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 diff --git a/ext/dba/dba_ndbm.c b/ext/dba/dba_ndbm.c deleted file mode 100644 index 0c6e2cd077..0000000000 --- a/ext/dba/dba_ndbm.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP HTML Embedded Scripting Language Version 3.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1999 PHP Development Team (See Credits file) | - +----------------------------------------------------------------------+ - | This program is free software; you can redistribute it and/or modify | - | it under the terms of one of the following licenses: | - | | - | A) the GNU General Public License as published by the Free Software | - | Foundation; either version 2 of the License, or (at your option) | - | any later version. | - | | - | B) the PHP License as published by the PHP Development Team and | - | included in the distribution in the file: LICENSE | - | | - | This program is distributed in the hope that it will be useful, | - | but WITHOUT ANY WARRANTY; without even the implied warranty of | - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | - | GNU General Public License for more details. | - | | - | You should have received a copy of both licenses referred to here. | - | If you did not, or have any questions about PHP licensing, please | - | contact core@php.net. | - +----------------------------------------------------------------------+ - | Authors: Sascha Schumann <sas@schell.de> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#include "php.h" - -#if DBA_NDBM -#include "php3_ndbm.h" - -#include <fcntl.h> - -#if NDBM_DB1_NDBM_H -#include <db1/ndbm.h> -#elif NDBM_NDBM_H -#include <ndbm.h> -#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; - } - - if(info->argc > 0) { - convert_to_long(info->argv[0]); - filemode = info->argv[0]->value.lval; - } - - dbf = dbm_open(info->path, gmode, filemode); - - if(dbf) { - pinfo->dbf = dbf; - return SUCCESS; - } - return FAILURE; -} - -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 diff --git a/ext/dba/php3_cdb.h b/ext/dba/php3_cdb.h deleted file mode 100644 index 162fa8bdb2..0000000000 --- a/ext/dba/php3_cdb.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _PHP3_CDB_H -#define _PHP3_CDB_H - -#if DBA_CDB - -#include "php3_dba.h" - -DBA_FUNCS(cdb); - -#endif - -#endif diff --git a/ext/dba/php3_db2.h b/ext/dba/php3_db2.h deleted file mode 100644 index 0f8c458db9..0000000000 --- a/ext/dba/php3_db2.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _PHP3_DB2_H -#define _PHP3_DB2_H - -#if DBA_DB2 - -#include "php3_dba.h" - -DBA_FUNCS(db2); - -#endif - -#endif diff --git a/ext/dba/php3_dba.h b/ext/dba/php3_dba.h deleted file mode 100644 index caa7bfed05..0000000000 --- a/ext/dba/php3_dba.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP HTML Embedded Scripting Language Version 3.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-1999 PHP Development Team (See Credits file) | - +----------------------------------------------------------------------+ - | This program is free software; you can redistribute it and/or modify | - | it under the terms of one of the following licenses: | - | | - | A) the GNU General Public License as published by the Free Software | - | Foundation; either version 2 of the License, or (at your option) | - | any later version. | - | | - | B) the PHP License as published by the PHP Development Team and | - | included in the distribution in the file: LICENSE | - | | - | This program is distributed in the hope that it will be useful, | - | but WITHOUT ANY WARRANTY; without even the implied warranty of | - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | - | GNU General Public License for more details. | - | | - | You should have received a copy of both licenses referred to here. | - | If you did not, or have any questions about PHP licensing, please | - | contact core@php.net. | - +----------------------------------------------------------------------+ - | Authors: Sascha Schumann <sas@schell.de> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifndef _DBA_H -#define _DBA_H - -#if HAVE_DBA - -typedef enum { - DBA_READER = 1, - DBA_WRITER, - DBA_TRUNC, - DBA_CREAT -} dba_mode_t; - -typedef struct dba_info { - /* public */ - void *dbf; /* ptr to private data or whatever */ - char *path; - dba_mode_t mode; - /* arg[cv] are only available when the dba_open handler is called! */ - int argc; - pval **argv; - /* private */ - struct dba_handler *hnd; -} dba_info; - -extern php3_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) -#define DBA_CLOSE_FUNC(x) \ - void dba_close_##x(dba_info *info) -#define DBA_FETCH_FUNC(x) \ - char *dba_fetch_##x(dba_info *info, char *key, int keylen, int *newlen) -#define DBA_UPDATE_FUNC(x) \ - int dba_update_##x(dba_info *info, char *key, int keylen, char *val, int vallen, int mode) -#define DBA_EXISTS_FUNC(x) \ - int dba_exists_##x(dba_info *info, char *key, int keylen) -#define DBA_DELETE_FUNC(x) \ - int dba_delete_##x(dba_info *info, char *key, int keylen) -#define DBA_FIRSTKEY_FUNC(x) \ - char *dba_firstkey_##x(dba_info *info, int *newlen) -#define DBA_NEXTKEY_FUNC(x) \ - char *dba_nextkey_##x(dba_info *info, int *newlen) -#define DBA_OPTIMIZE_FUNC(x) \ - int dba_optimize_##x(dba_info *info) -#define DBA_SYNC_FUNC(x) \ - int dba_sync_##x(dba_info *info) - -#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) (p)->value.str.val, (p)->value.str.len - -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); - -#else -#define dba_module_ptr NULL -#endif - -#define phpext_dba_ptr dba_module_ptr - -#endif diff --git a/ext/dba/php3_dbm.h b/ext/dba/php3_dbm.h deleted file mode 100644 index 5007c84b3e..0000000000 --- a/ext/dba/php3_dbm.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _PHP3_DBM_H -#define _PHP3_DBM_H - -#if DBA_DBM - -#include "php3_dba.h" - -DBA_FUNCS(dbm); - -#endif - -#endif diff --git a/ext/dba/php3_gdbm.h b/ext/dba/php3_gdbm.h deleted file mode 100644 index 9a18b531d4..0000000000 --- a/ext/dba/php3_gdbm.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _PHP3_GDBM_H -#define _PHP3_GDBM_H - -#if DBA_GDBM - -#include "php3_dba.h" - -DBA_FUNCS(gdbm); - -#endif - -#endif diff --git a/ext/dba/php3_ndbm.h b/ext/dba/php3_ndbm.h deleted file mode 100644 index 398b8e39a1..0000000000 --- a/ext/dba/php3_ndbm.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _PHP3_NDBM_H -#define _PHP3_NDBM_H - -#if DBA_NDBM - -#include "php3_dba.h" - -DBA_FUNCS(ndbm); - -#endif - -#endif diff --git a/ext/dba/setup.stub b/ext/dba/setup.stub deleted file mode 100644 index 0df17de7d1..0000000000 --- a/ext/dba/setup.stub +++ /dev/null @@ -1,6 +0,0 @@ -# $Source$ -# $Id$ - -define_option with-dba 'dba support?' yesnodir no \ -' Whether to build the dba extension.' - diff --git a/ext/fdf/fdf.c b/ext/fdf/fdf.c index bc7568ebb9..eac48ba413 100644 --- a/ext/fdf/fdf.c +++ b/ext/fdf/fdf.c @@ -28,7 +28,7 @@ #endif #include "php.h" -#include "ext/standard/head.h" +#include "head.h" #include <math.h> #include "php3_fdf.h" diff --git a/ext/hyperwave/DList.h b/ext/hyperwave/DList.h new file mode 100644 index 0000000000..e574638e18 --- /dev/null +++ b/ext/hyperwave/DList.h @@ -0,0 +1,128 @@ +/**************************************************************************** +* +* Copyright (C) 1991 Kendall Bennett. +* All rights reserved. +* +* Filename: $RCSfile$ +* Version: $Revision$ +* +* Language: ANSI C +* Environment: any +* +* Description: Header file for doubly linked list routines. +* +* $Id$ +* +* Revision History: +* ----------------- +* +* $Log$ +* Revision 1.1.1.1 1999/04/07 21:03:20 zeev +* PHP 4.0 +* +* Revision 1.1.1.1 1999/03/17 04:29:11 andi +* PHP4 +* +* Revision 1.1.1.1 1998/12/21 07:56:22 andi +* Trying to start the zend CVS tree +* +* Revision 1.2 1998/08/14 15:51:12 shane +* Some work on getting hyperwave to work on windows. hg_comm needs a lot of work. +* +* Mainly, signals, fnctl, bzero, bcopy, etc are not portable functions. Most of this +* will have to be rewriten for windows. +* +* Revision 1.1 1998/08/12 09:29:16 steinm +* First version of Hyperwave module. +* +* Revision 1.5 91/12/31 19:40:54 kjb +* +* Modified include files directories. +* +* Revision 1.4 91/09/27 03:10:41 kjb +* Added compatibility with C++. +* +* Revision 1.3 91/09/26 10:07:16 kjb +* Took out extern references +* +* Revision 1.2 91/09/01 19:37:20 ROOT_DOS +* Changed DLST_TAIL macro so that it returns a pointer to the REAL last +* node of the list, not the dummy last node (l->z). +* +* Revision 1.1 91/09/01 18:38:23 ROOT_DOS +* Initial revision +* +****************************************************************************/ + +#ifndef __DLIST_H +#define __DLIST_H + +#ifndef __DEBUG_H +/*#include "debug.h"*/ +#endif + +/*---------------------- Macros and type definitions ----------------------*/ + +typedef struct DLST_BUCKET { + struct DLST_BUCKET *next; + struct DLST_BUCKET *prev; + } DLST_BUCKET; + +typedef struct { + int count; /* Number of elements currently in list */ + DLST_BUCKET *head; /* Pointer to head element of list */ + DLST_BUCKET *z; /* Pointer to last node of list */ + DLST_BUCKET hz[2]; /* Space for head and z nodes */ + } DLIST; + +/* Return a pointer to the user space given the address of the header of + * a node. + */ + +#define DLST_USERSPACE(h) ((void*)((DLST_BUCKET*)(h) + 1)) + +/* Return a pointer to the header of a node, given the address of the + * user space. + */ + +#define DLST_HEADER(n) ((DLST_BUCKET*)(n) - 1) + +/* Return a pointer to the user space of the list's head node. This user + * space does not actually exist, but it is useful to be able to address + * it to enable insertion at the start of the list. + */ + +#define DLST_HEAD(l) DLST_USERSPACE((l)->head) + +/* Return a pointer to the user space of the last node in list. */ + +#define DLST_TAIL(l) DLST_USERSPACE((l)->z->prev) + +/* Determine if a list is empty + */ + +#define DLST_EMPTY(l) ((l)->count == 0) + +/*-------------------------- Function Prototypes --------------------------*/ + +#ifdef __cplusplus +extern "C" { +#endif + +void *dlst_newnode(int size); +void dlst_freenode(void *node); +DLIST *dlst_init(void); +void dlst_kill(DLIST *l,void (*freeNode)(void *node)); +void dlst_insertafter(DLIST *l,void *node,void *after); +void *dlst_deletenext(DLIST *l,void *node); +void *dlst_first(DLIST *l); +void *dlst_last(DLIST *l); +void *dlst_next(void *prev); +void *dlst_prev(void *next); +void dlst_mergesort(DLIST *l,int (*cmp_func)(void*,void*)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ext/hyperwave/dlist.c b/ext/hyperwave/dlist.c new file mode 100644 index 0000000000..94dd6edf7b --- /dev/null +++ b/ext/hyperwave/dlist.c @@ -0,0 +1,413 @@ +/**************************************************************************** +* +* Copyright (C) 1991 Kendall Bennett. +* All rights reserved. +* +* Filename: $RCSfile$ +* Version: $Revision$ +* +* Language: ANSI C +* Environment: any +* +* Description: Module to implement doubly linked lists. Includes a routine +* to peform a mergesort on the doubly linked list. +* +* $Id$ +* +* Revision History: +* ----------------- +* +* $Log$ +* Revision 1.1 1999/04/21 23:11:20 ssb +* moved apache, com and hyperwave into ext/ +* +* Revision 1.1.1.1 1999/04/07 21:03:31 zeev +* PHP 4.0 +* +* Revision 1.1.1.1 1999/03/17 04:29:11 andi +* PHP4 +* +* Revision 1.1.1.1 1998/12/21 07:56:22 andi +* Trying to start the zend CVS tree +* +* Revision 1.1 1998/08/12 09:29:16 steinm +* First version of Hyperwave module. +* +* Revision 1.5 91/12/31 19:39:49 kjb +* Modified include file directories. +* +* Revision 1.4 91/10/28 03:16:39 kjb +* Ported to the Iris. +* +* Revision 1.3 91/09/27 03:09:18 kjb +* Cosmetic change. +* +* Revision 1.2 91/09/03 18:27:42 ROOT_DOS +* Ported to UNIX. +* +* Revision 1.1 91/09/01 18:35:23 ROOT_DOS +* Initial revision +* +****************************************************************************/ + +#ifndef MSVC5 +#include "php_config.h" +#endif + +#if HYPERWAVE + +#include <stdio.h> +#include <malloc.h> +#include <signal.h> +#include "debug.h" +#include "DList.h" + +PUBLIC void *dlst_newnode(int size) +/**************************************************************************** +* +* Function: dlst_newnode +* Parameters: size - Amount of memory to allocate for node +* Returns: Pointer to the allocated node's user space. +* +* Description: Allocates the memory required for a node, adding a small +* header at the start of the node. We return a reference to +* the user space of the node, as if it had been allocated via +* malloc(). +* +****************************************************************************/ +{ + DLST_BUCKET *node; + + if ( !(node = (DLST_BUCKET*)malloc(size + sizeof(DLST_BUCKET))) ) { + fprintf(stderr,"Not enough memory to allocate list node.\n"); +/* raise(SIGABRT);*/ + return NULL; + } + + return DLST_USERSPACE(node); /* Return pointer to user space */ +} + +PUBLIC void dlst_freenode(void *node) +/**************************************************************************** +* +* Function: dlst_freenode +* Parameters: node - Node to free. +* +* Description: Frees a node previously allocated with lst_newnode(). +* +****************************************************************************/ +{ + free(DLST_HEADER(node)); +} + +PUBLIC DLIST *dlst_init(void) +/**************************************************************************** +* +* Function: dlst_init +* Returns: Pointer to a newly created list. +* +* Description: Initialises a list and returns a pointer to it. +* +****************************************************************************/ +{ + DLIST *l; + + if ((l = (DLIST*)malloc(sizeof(DLIST))) != NULL) { + l->count = 0; + l->head = &(l->hz[0]); + l->z = &(l->hz[1]); + l->head->next = l->z->next = l->z; + l->z->prev = l->head->prev = l->head; + } + else { + fprintf(stderr,"Insufficient memory to allocate list\n"); + /*raise(SIGABRT);*/ + return NULL; + } + + return l; +} + +PUBLIC void dlst_kill(DLIST *l,void (*freeNode)(void *node)) +/**************************************************************************** +* +* Function: dlst_kill +* Parameters: l - List to kill +* freeNode - Pointer to user routine to free a node +* +* Description: Kills the list l, by deleting all of the elements contained +* within the list one by one and then deleting the list +* itself. Note that we call the user supplied routine +* (*freeNode)() to free each list node. This allows the user +* program to perform any extra processing needed to kill each +* node (if each node contains pointers to other items on the +* heap for example). If no extra processing is required, just +* pass the address of dlst_freenode(), ie: +* +* dlst_kill(myList,dlst_freenode); +* +****************************************************************************/ +{ + DLST_BUCKET *n,*p; + + n = l->head->next; + while (n != l->z) { /* Free all nodes in list */ + p = n; + n = n->next; + (*freeNode)(DLST_USERSPACE(p)); + } + free(l); /* Free the list itself */ +} + +PUBLIC void dlst_insertafter(DLIST *l,void *node,void *after) +/**************************************************************************** +* +* Function: lst_insertafter +* Parameters: l - List to insert node into +* node - Pointer to user space of node to insert +* after - Pointer to user space of node to insert node after +* +* Description: Inserts a new node into the list after the node 'after'. To +* insert a new node at the beginning of the list, user the +* macro DLST_HEAD in place of 'after'. ie: +* +* dlst_insertafter(mylist,node,DLST_HEAD(mylist)); +* +****************************************************************************/ +{ + DLST_BUCKET *n = DLST_HEADER(node),*a = DLST_HEADER(after); + + n->next = a->next; + a->next = n; + n->prev = a; + n->next->prev = n; + l->count++; +} + +PUBLIC void *dlst_deletenext(DLIST *l,void *node) +/**************************************************************************** +* +* Function: lst_deletenext +* Parameters: l - List to delete node from. +* node - Node to delete the next node from +* Returns: Pointer to the deleted node's userspace. +* +* Description: Removes the node AFTER 'node' from the list l. +* +****************************************************************************/ +{ + DLST_BUCKET *n = DLST_HEADER(node); + + node = DLST_USERSPACE(n->next); + n->next->next->prev = n; + n->next = n->next->next; + l->count--; + return node; +} + +PUBLIC void *dlst_first(DLIST *l) +/**************************************************************************** +* +* Function: dlst_first +* Parameters: l - List to obtain first node from +* Returns: Pointer to first node in list, NULL if list is empty. +* +* Description: Returns a pointer to the user space of the first node in +* the list. If the list is empty, we return NULL. +* +****************************************************************************/ +{ + DLST_BUCKET *n; + + n = l->head->next; + return (n == l->z ? NULL : DLST_USERSPACE(n)); +} + +PUBLIC void *dlst_last(DLIST *l) +/**************************************************************************** +* +* Function: dlst_last +* Parameters: l - List to obtain last node from +* Returns: Pointer to last node in list, NULL if list is empty. +* +* Description: Returns a pointer to the user space of the last node in +* the list. If the list is empty, we return NULL. +* +****************************************************************************/ +{ + DLST_BUCKET *n; + + n = l->z->prev; + return (n == l->head ? NULL : DLST_USERSPACE(n)); +} + +PUBLIC void *dlst_next(void *prev) +/**************************************************************************** +* +* Function: dlst_next +* Parameters: prev - Previous node in list to obtain next node from +* Returns: Pointer to the next node in the list, NULL at end of list. +* +* Description: Returns a pointer to the user space of the next node in the +* list given a pointer to the user space of the previous node. +* If we have reached the end of the list, we return NULL. The +* end of the list is detected when the next pointer of a node +* points back to itself, as does the dummy last node's next +* pointer. This enables us to detect the end of the list +* without needed access to the list data structure itself. +* +* NOTE: We do no checking to ensure that 'prev' is NOT a +* NULL pointer. +* +****************************************************************************/ +{ + DLST_BUCKET *n = DLST_HEADER(prev); + + n = n->next; + return (n == n->next ? NULL : DLST_USERSPACE(n)); +} + +PUBLIC void *dlst_prev(void *next) +/**************************************************************************** +* +* Function: dlst_prev +* Parameters: next - Next node in list to obtain previous node from +* Returns: Pointer to the previous node in the list, NULL at start list. +* +* Description: Returns a pointer to the user space of the prev node in the +* list given a pointer to the user space of the next node. +* If we have reached the start of the list, we return NULL. The +* start of the list is detected when the prev pointer of a node +* points back to itself, as does the dummy head node's prev +* pointer. This enables us to detect the start of the list +* without needed access to the list data structure itself. +* +* NOTE: We do no checking to ensure that 'next' is NOT a +* NULL pointer. +* +****************************************************************************/ +{ + DLST_BUCKET *n = DLST_HEADER(next); + + n = n->prev; + return (n == n->prev ? NULL : DLST_USERSPACE(n)); +} + +/* Static globals required by merge() */ + +static DLST_BUCKET *z; +static int (*cmp)(void*,void*); + +PRIVATE DLST_BUCKET *merge(DLST_BUCKET *a,DLST_BUCKET *b,DLST_BUCKET **end) +/**************************************************************************** +* +* Function: merge +* Parameters: a,b - Sublist's to merge +* Returns: Pointer to the merged sublists. +* +* Description: Merges two sorted lists of nodes together into a single +* sorted list. +* +****************************************************************************/ +{ + DLST_BUCKET *c; + + /* Go through the lists, merging them together in sorted order */ + + c = z; + while (a != z && b != z) { + if ((*cmp)(DLST_USERSPACE(a),DLST_USERSPACE(b)) <= 0) { + c->next = a; c = a; a = a->next; + } + else { + c->next = b; c = b; b = b->next; + } + }; + + /* If one of the lists is not exhausted, then re-attach it to the end + * of the newly merged list + */ + + if (a != z) c->next = a; + if (b != z) c->next = b; + + /* Set *end to point to the end of the newly merged list */ + + while (c->next != z) c = c->next; + *end = c; + + /* Determine the start of the merged lists, and reset z to point to + * itself + */ + + c = z->next; z->next = z; + return c; +} + +PUBLIC void dlst_mergesort(DLIST *l,int (*cmp_func)(void*,void*)) +/**************************************************************************** +* +* Function: dlst_mergesort +* Parameters: l - List to merge sort +* cmp_func - Function to compare two user spaces +* +* Description: Mergesort's all the nodes in the list. 'cmp' must point to +* a comparison function that can compare the user spaces of +* two different nodes. 'cmp' should work the same as +* strcmp(), in terms of the values it returns. Rather than +* waste processing time keeping the previous pointers up to +* date while performing the mergesort, we simply run through +* the list at the end of the sort to fix the previous pointers. +* +****************************************************************************/ +{ + int i,N; + DLST_BUCKET *a,*b; /* Pointers to sublists to merge */ + DLST_BUCKET *c; /* Pointer to end of sorted sublists */ + DLST_BUCKET *head; /* Pointer to dummy head node for list */ + DLST_BUCKET *todo; /* Pointer to sublists yet to be sorted */ + DLST_BUCKET *t; /* Temporary */ + + /* Set up globals required by merge() and pointer to head */ + + z = l->z; cmp = cmp_func; head = l->head; + + for (N = 1,a = z; a != head->next; N = N + N) { + todo = head->next; c = head; + while (todo != z) { + + /* Build first sublist to be merged, and splice from main list + */ + + a = t = todo; + for (i = 1; i < N; i++) t = t->next; + b = t->next; t->next = z; t = b; + + /* Build second sublist to be merged and splice from main list + */ + + for (i = 1; i < N; i++) t = t->next; + todo = t->next; t->next = z; + + /* Merge the two sublists created, and set 'c' to point to the + * end of the newly merged sublists. + */ + + c->next = merge(a,b,&t); c = t; + } + } + + /* Fix the previous pointers for the list */ + + a = b = l->head; + b = b->next; + while (1) { + b->prev = a; + if (b == z) + break; + a = a->next; + b = b->next; + } +} + +#endif diff --git a/ext/imap/config.m4 b/ext/imap/config.m4 index 36697bfc18..06ceb6ce9b 100644 --- a/ext/imap/config.m4 +++ b/ext/imap/config.m4 @@ -11,16 +11,12 @@ AC_ARG_WITH(imap, withval=/usr elif test -f /usr/include/imap/mail.h; then withval=/usr - elif test -f /usr/include/c-client/mail.h; then - withval=/usr fi fi if test "$withval" != "no" && test "$withval" != "yes"; then IMAP_DIR=$withval if test -f $IMAP_DIR/include/imap/mail.h; then IMAP_INC_DIR=$IMAP_DIR/include/imap - elif test -f $IMAP_DIR/include/c-client/mail.h; then - IMAP_INC_DIR=$IMAP_DIR/include/c-client else IMAP_INC_DIR=$withval/include fi diff --git a/ext/informix/ifx.ec b/ext/informix/ifx.ec index df60a38921..c0586d37a3 100644 --- a/ext/informix/ifx.ec +++ b/ext/informix/ifx.ec @@ -13,7 +13,6 @@ | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Danny Heijl <Danny.Heijl@cevi.be> : initial cut (ODS 7.2x) | - | PHP4 port | | Christian Cartus <chc@idgruppe.de> : blobs, and IUS 9 | | Jouni Ahto <jah@mork.net> : configuration stuff | | Based on the MySQL code by: Zeev Suraski <zeev@php.net> | @@ -26,28 +25,109 @@ * you a very short one * ------------------------------------------------------------------- */ +/* + * I started with the mysql-driver, removed all stuff I did not need, + * and changed all mysql-specific stuff to Informix-ESQL/C. + * I used the X-open way of using ESQL/C (using an SQL descriptor and + * not the Informix-specific way). It is perhaps a little bit slower, + * but more verbose and less prone to coding errors. + * This is the first time in my life I coded ESQL/C, so do not look too + * closely and do not hesitate to point out errors/omissions etc... + * Aug. 8, 1998 + * Danny Heijl, Danny.Heijl@cevi.be + */ /* TODO: * * ? Safe mode implementation + * + * Jouni Ahto promised help and already did the configuration stuff + * (Jouni Ahto <jah@mork.net>). + * */ +/* +Changes: 23.8.1998 (chc@idgruppe.de) +- full blobsupport (TEXT and BYTE) +- new functions: ifx_create_blob, ifx_copy_blob, ifx_free_blob, + ifx_update_blob, ifx_get_blob, ifx_blobinfile_mode +- file and memory-support of blobs +- load TEXT and BYTE in memory by default + (controllable by "ifx.blobinfile" in php3.ini-file) +- update all functions to support blobs (ifx_query, ifx_prepare, + ifx_do, ifx_htmltbl_result, ifx_fetch_row) +- minor bug-fixes +- Test-Page (informix_blob.php3) which tests the blob-support + + +Changes: 11.9.1998 (chc@idgruppe.de) +- ifx_query and ifx_prepare: blob-paramters now as array +- new funtions: ifx_textasvarchar, ifx_byteasvarchar, ifx_nullformat +- new php.ini-variables: ifx.textasvarchar, ifx.byteasvarchar, ifx.nullformat +- update all functions to support blobarray and new functions + (ifx_query, ifx_prepare, ifx_do, ifx_htmltbl_result, ifx_fetch_row) +- minor bug-fixes +- Test-Page (informix_blob.php3) updated +- begin with coding of slob-support + (still deactivated, not yet complete: #undef HAVE_IFX_IUS in php3_ifx.h) +- ifx_fetch_row returns always a blob-id (contains "NULL"-flag or content from db) + (except ifx_textasvarchar, ifx_byteasvarchar set to 1) + +Changes 14.9.1998 (chc@idgruppe.de) +- supports now IUS- serial8,int8,boolean, nchar, nvchar, lvarchar +- still incomplete slob-support + +Changes 25.9.1998 (danny.heijl@cevi.be) +- cursory and non-cursory stored procedures + +Changes 24.10.1998 (chc@idgruppe.de) +- changes the internal structure of IFX_BLOB and IFX_SLOB into one structure. + it is now prepared for general-id-usage. +- fixed a lvarchar-bug (i hate esql/c) + +Changes 12.11.1998 (danny.heijl@cevi.be) +- added proto comments + +Changes 04/03/1999 (danny.heijl@cevi.be) +- added "SET CONNECTION" statement to ifx_fetch_row() so that you can now + fetch rows from different databases simultaneously + (ifx_query() & ifx_prepare() were already OK). + +Changes 05/03/1999 (danny.heijl@cevi.be) +- made all sqlerrd[] fields of sqlca structure available + with ifx_getsqlca($query_id) in a pseudo-row after a + prepare (select statements) or insert/update (non-select statements). + gives access to affected rows and serial insert values +- made all internal functions static + + +Changes 09/03/1999 (danny.heijl@cevi.be) +- suppressed ESQL/C BLOB memory leak fix for ESQL/C 7.24 and higher + this is the same fix as in Perl DBD::Informix +- really free an Ifx_Result now, do not wait for script termination +- code cleanup + +*/ + + #if defined(COMPILE_DL) #include "dl/phpdl.h" #endif - -#include "php.h" -#include "php_globals.h" -#include "ext/standard/php3_standard.h" -#include "php_informix.h" -#include "php_globals.h" - +// +// php 3.0 +//#if defined(THREAD_SAFE) +//#include "tls.h" +//DWORD InformixTls; +//static int numthreads=0; +//void *ifx_mutex; +//#endif #if WIN32|WINNT #include <winsock.h> #else +#include "config.h" #include "build-defs.h" #if HAVE_SYS_TYPES_H @@ -57,7 +137,10 @@ #include <netinet/in.h> #endif -#include "php_ini.h" +#include "php.h" +#include "php3_string.h" +#include "build-defs.h" +#include "php_informix.h" #if HAVE_IFX @@ -111,6 +194,8 @@ EXEC SQL include sqlstype; typedef char IFX[128]; +#include "php3_list.h" + #define SAFE_STRING(s) ((s)?(s):"") function_entry ifx_functions[] = { @@ -172,7 +257,7 @@ php3_module_entry ifx_module_entry = { STANDARD_MODULE_PROPERTIES }; -#ifdef COMPILE_DL +#if COMPILE_DL DLEXPORT php3_module_entry *get_module(void) { return &ifx_module_entry; } #if 0 BOOL WINAPI DllMain(HANDLE hModule, @@ -184,13 +269,24 @@ BOOL WINAPI DllMain(HANDLE hModule, #endif #endif -#ifdef ZTS -int ifx_globals_id; + +#if defined(THREAD_SAFE) +typedef struct ifx_global_struct{ + ifx_module php3_ifx_module; +}ifx_global_struct; + +#define Informix_GLOBAL(a) ifx_globals->a + +#define Informix_TLS_VARS \ + ifx_global_struct *ifx_globals; \ + ifx_globals=TlsGetValue(InformixTls); + #else -PHP_IFX_API php_ifx_globals ifx_globals; +#define Informix_GLOBAL(a) a +#define Informix_TLS_VARS +ifx_module php3_ifx_module; #endif - #define CHECK_LINK(link) { \ if (link==0) { \ php3_error(E_WARNING, \ @@ -241,12 +337,10 @@ static char *ifx_error(ifx) char c; int errorcode; - IFXLS_FETCH(); - - if (IFXG(sv_sqlcode) == 0) + if (Informix_GLOBAL(php3_ifx_module).sv_sqlcode == 0) errorcode = SQLCODE; else - errorcode = IFXG(sv_sqlcode); + errorcode = Informix_GLOBAL(php3_ifx_module).sv_sqlcode; switch (ifx_check()) { case IFX_SUCCESS: @@ -285,12 +379,12 @@ static void _close_ifx_link(link) EXEC SQL END DECLARE SECTION; { - IFXLS_FETCH(); + Informix_TLS_VARS; EXEC SQL SET CONNECTION :link; EXEC SQL DISCONNECT CURRENT; efree(link); - IFXG(num_links)--; + Informix_GLOBAL(php3_ifx_module).num_links--; } static void _close_ifx_plink(link) @@ -299,14 +393,14 @@ EXEC SQL BEGIN DECLARE SECTION; EXEC SQL END DECLARE SECTION; { - IFXLS_FETCH(); + Informix_TLS_VARS; EXEC SQL SET CONNECTION :link; EXEC SQL DISCONNECT CURRENT; free(link); - IFXG(num_persistent)--; - IFXG(num_links)--; + Informix_GLOBAL(php3_ifx_module).num_persistent--; + Informix_GLOBAL(php3_ifx_module).num_links--; } static void ifx_free_result(a_result_id) @@ -315,62 +409,100 @@ char *a_result_id; return; } - -PHP_INI_BEGIN() - STD_PHP_INI_ENTRY("ifx.allow_persistent", "1", PHP_INI_SYSTEM, - OnUpdateInt, allow_persistent, php_ifx_globals, ifx_globals) - STD_PHP_INI_ENTRY("ifx.max_persistent", "0", PHP_INI_SYSTEM, - OnUpdateInt, max_persistent, php_ifx_globals, ifx_globals) - STD_PHP_INI_ENTRY("ifx.max_links", "0", PHP_INI_SYSTEM, - OnUpdateInt, max_links, php_ifx_globals, ifx_globals) - STD_PHP_INI_ENTRY("ifx.default_host", NULL, PHP_INI_SYSTEM, - OnUpdateString, default_host, php_ifx_globals, ifx_globals) - STD_PHP_INI_ENTRY("ifx.default_user", NULL, PHP_INI_SYSTEM, - OnUpdateString, default_user, php_ifx_globals, ifx_globals) - STD_PHP_INI_ENTRY("ifx.default_password", NULL, PHP_INI_SYSTEM, - OnUpdateString, default_password, php_ifx_globals, ifx_globals) - STD_PHP_INI_ENTRY("ifx.blobinfile", "1", PHP_INI_ALL, - OnUpdateInt, blobinfile, php_ifx_globals, ifx_globals) - STD_PHP_INI_ENTRY("ifx.textasvarchar", "0", PHP_INI_ALL, - OnUpdateInt, textasvarchar, php_ifx_globals, ifx_globals) - STD_PHP_INI_ENTRY("ifx.byteasvarchar", "0", PHP_INI_ALL, - OnUpdateInt, byteasvarchar, php_ifx_globals, ifx_globals) - STD_PHP_INI_ENTRY("ifx.charasvarchar", "0", PHP_INI_ALL, - OnUpdateInt, charasvarchar, php_ifx_globals, ifx_globals) - STD_PHP_INI_ENTRY("ifx.nullformat", "0", PHP_INI_ALL, - OnUpdateInt, nullformat, php_ifx_globals, ifx_globals) -PHP_INI_END() - int php3_minit_ifx(INIT_FUNC_ARGS) { -#ifdef ZTS - ifx_globals_id = ts_allocate_id(sizeof(php_ifx_globals), php_ifx_init_globals, NULL); -#else - IFXG(num_persistent)=0; +#if defined(THREAD_SAFE) + ifx_global_struct *ifx_globals; + CREATE_MUTEX(ifx_mutex,"Informix_TLS"); + SET_MUTEX(ifx_mutex); + numthreads++; + if (numthreads==1){ + if ((InformixTls=TlsAlloc())==0xFFFFFFFF){ + FREE_MUTEX(ifx_mutex); + return 0; + } + } + FREE_MUTEX(ifx_mutex); + ifx_globals = (ifx_global_struct *) + LocalAlloc(LPTR, sizeof(ifx_global_struct)); + TlsSetValue(InformixTls, (void *) ifx_globals); #endif - REGISTER_INI_ENTRIES(); - - IFXG(nullvalue) = malloc(1); - IFXG(nullvalue)[0] = 0; - IFXG(nullstring) = malloc(5); - strcpy(IFXG(nullstring), "NULL"); + if (cfg_get_long("ifx.blobinfile", + &Informix_GLOBAL(php3_ifx_module).blobinfile)==FAILURE) { + Informix_GLOBAL(php3_ifx_module).blobinfile=BLOBINFILE; + } - IFXG(num_persistent)=0; - IFXG(sv_sqlcode)=0; + if (cfg_get_long("ifx.textasvarchar", + &Informix_GLOBAL(php3_ifx_module).textasvarchar)==FAILURE) { + Informix_GLOBAL(php3_ifx_module).textasvarchar=0; + } - IFXG(le_result) = register_list_destructors(ifx_free_result,NULL); - IFXG(le_idresult) = register_list_destructors(ifx_free_result,NULL); - IFXG(le_link) = register_list_destructors(_close_ifx_link,NULL); - IFXG(le_plink) = register_list_destructors(NULL,_close_ifx_plink); + + if (cfg_get_long("ifx.byteasvarchar", + &Informix_GLOBAL(php3_ifx_module).byteasvarchar)==FAILURE) { + Informix_GLOBAL(php3_ifx_module).byteasvarchar=0; + } + + if (cfg_get_long("ifx.charasvarchar", + &Informix_GLOBAL(php3_ifx_module).charasvarchar)==FAILURE) { + Informix_GLOBAL(php3_ifx_module).charasvarchar=0; + } + + if (cfg_get_long("ifx.nullformat", + &Informix_GLOBAL(php3_ifx_module).nullformat)==FAILURE) { + Informix_GLOBAL(php3_ifx_module).nullformat=0; + } + + Informix_GLOBAL(php3_ifx_module).nullvalue = malloc(1); + Informix_GLOBAL(php3_ifx_module).nullvalue[0] = 0; + Informix_GLOBAL(php3_ifx_module).nullstring = malloc(5); + strcpy(Informix_GLOBAL(php3_ifx_module).nullstring, "NULL"); + + if (cfg_get_long("ifx.allow_persistent", + &Informix_GLOBAL(php3_ifx_module).allow_persistent)==FAILURE) { + Informix_GLOBAL(php3_ifx_module).allow_persistent=1; + } + if (cfg_get_long("ifx.max_persistent", + &Informix_GLOBAL(php3_ifx_module).max_persistent)==FAILURE) { + Informix_GLOBAL(php3_ifx_module).max_persistent=-1; + } + if (cfg_get_long("ifx.max_links", + &Informix_GLOBAL(php3_ifx_module).max_links)==FAILURE) { + Informix_GLOBAL(php3_ifx_module).max_links=-1; + } + if (cfg_get_string("ifx.default_host", + &Informix_GLOBAL(php3_ifx_module).default_host)==FAILURE + || Informix_GLOBAL(php3_ifx_module).default_host[0]==0) { + Informix_GLOBAL(php3_ifx_module).default_host=NULL; + } + if (cfg_get_string("ifx.default_user", + &Informix_GLOBAL(php3_ifx_module).default_user)==FAILURE + || Informix_GLOBAL(php3_ifx_module).default_user[0]==0) { + Informix_GLOBAL(php3_ifx_module).default_user=NULL; + } + if (cfg_get_string("ifx.default_password", + &Informix_GLOBAL(php3_ifx_module).default_password)==FAILURE + || Informix_GLOBAL(php3_ifx_module).default_password[0]==0) { + Informix_GLOBAL(php3_ifx_module).default_password=NULL; + } + Informix_GLOBAL(php3_ifx_module).num_persistent=0; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode=0; + Informix_GLOBAL(php3_ifx_module).le_result = + register_list_destructors(ifx_free_result,NULL); + Informix_GLOBAL(php3_ifx_module).le_idresult = + register_list_destructors(ifx_free_result,NULL); + Informix_GLOBAL(php3_ifx_module).le_link = + register_list_destructors(_close_ifx_link,NULL); + Informix_GLOBAL(php3_ifx_module).le_plink = + register_list_destructors(NULL,_close_ifx_plink); #if 0 printf("Registered: %d,%d,%d\n", - IFXG(le_result), - IFXG(le_link), - IFXG(le_plink)); + Informix_GLOBAL(php3_ifx_module).le_result, + Informix_GLOBAL(php3_ifx_module).le_link, + Informix_GLOBAL(php3_ifx_module).le_plink); #endif - ifx_module_entry.type = type; REGISTER_LONG_CONSTANT("IFX_SCROLL", IFX_SCROLL, CONST_CS | CONST_PERSISTENT); @@ -388,39 +520,50 @@ $endif; } -int php3_mshutdown_ifx(SHUTDOWN_FUNC_ARGS){ - - UNREGISTER_INI_ENTRIES(); +int php3_mshutdown_ifx(void){ +#if defined(THREAD_SAFE) + Informix_TLS_VARS; + if (ifx_globals != 0) + LocalFree((HLOCAL) ifx_globals); + SET_MUTEX(ifx_mutex); + numthreads--; + if (!numthreads){ + if (!TlsFree(InformixTls)){ + FREE_MUTEX(ifx_mutex); + return 0; + } + } + FREE_MUTEX(ifx_mutex); +#endif return SUCCESS; - } int php3_rinit_ifx(INIT_FUNC_ARGS) { - IFXLS_FETCH(); + Informix_TLS_VARS; - IFXG(default_link)=-1; - IFXG(num_links) = - IFXG(num_persistent); + Informix_GLOBAL(php3_ifx_module).default_link=-1; + Informix_GLOBAL(php3_ifx_module).num_links = + Informix_GLOBAL(php3_ifx_module).num_persistent; return SUCCESS; } -void php3_info_ifx(ZEND_MODULE_INFO_FUNC_ARGS) +void php3_info_ifx(void) { char maxp[16],maxl[16]; - IFXLS_FETCH(); + Informix_TLS_VARS; - if (IFXG(max_persistent)==-1) { + if (Informix_GLOBAL(php3_ifx_module).max_persistent==-1) { strcpy(maxp,"Unlimited"); } else { - snprintf(maxp,15,"%ld",IFXG(max_persistent)); + snprintf(maxp,15,"%ld",Informix_GLOBAL(php3_ifx_module).max_persistent); maxp[15]=0; } - if (IFXG(max_links)==-1) { + if (Informix_GLOBAL(php3_ifx_module).max_links==-1) { strcpy(maxl,"Unlimited"); } else { - snprintf(maxl,15,"%ld",IFXG(max_links)); + snprintf(maxl,15,"%ld",Informix_GLOBAL(php3_ifx_module).max_links); maxl[15]=0; } php3_printf("<table cellpadding=5>" @@ -428,11 +571,22 @@ void php3_info_ifx(ZEND_MODULE_INFO_FUNC_ARGS) "<tr><td>Persistent links:</td><td>%d/%s</td></tr>\n" "<tr><td>Total links:</td><td>%d/%s</td></tr>\n" "<tr><td>Client API version:</td><td>%02.2f</td></tr>\n" +#if !(WIN32|WINNT) + "<tr><td valign=\"top\">Compilation definitions:</td><td>" + "<tt>IFX_INCLUDE=%s<br>\n" + "IFX_LFLAGS=%s<br>\n" + "IFX_LIBS=%s<br></tt></td></tr>" +#endif "</table>\n", - (IFXG(allow_persistent)?"Yes":"No"), - IFXG(num_persistent),maxp, - IFXG(num_links),maxl, + (Informix_GLOBAL(php3_ifx_module).allow_persistent?"Yes":"No"), + Informix_GLOBAL(php3_ifx_module).num_persistent,maxp, + Informix_GLOBAL(php3_ifx_module).num_links,maxl, (double)(CLIENT_SQLI_VER/100.0) +#if !(WIN32|WINNT) + ,PHP_IFX_INCLUDE, + PHP_IFX_LFLAGS, + PHP_IFX_LIBS +#endif ); } @@ -455,11 +609,9 @@ static void php3_ifx_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) char *hashed_details; int hashed_details_length; - IFXLS_FETCH(); + Informix_TLS_VARS; - PLS_FETCH(); - - if (PG(sql_safe_mode)) { + if (php3_ini.sql_safe_mode) { if (ARG_COUNT(ht)>0) { php3_error(E_NOTICE, "SQL safe mode in effect - ignoring host/user/password information"); @@ -470,9 +622,9 @@ static void php3_ifx_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) hashed_details = (char *) emalloc(hashed_details_length+1); sprintf(hashed_details,"ifx__%s_",user); } else { - host = IFXG(default_host); - user = IFXG(default_user); - passwd = IFXG(default_password); + host = Informix_GLOBAL(php3_ifx_module).default_host; + user = Informix_GLOBAL(php3_ifx_module).default_user; + passwd = Informix_GLOBAL(php3_ifx_module).default_password; switch(ARG_COUNT(ht)) { case 0: /* defaults */ @@ -529,9 +681,9 @@ static void php3_ifx_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) } - IFXG(sv_sqlcode) = 0; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = 0; - if (!IFXG(allow_persistent)) { + if (!Informix_GLOBAL(php3_ifx_module).allow_persistent) { persistent=0; } if (persistent) { @@ -542,37 +694,37 @@ static void php3_ifx_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) (void **) &le)==FAILURE) { /* we don't */ list_entry new_le; - if (IFXG(max_links)!=-1 && - IFXG(num_links) >= - IFXG(max_links)) { + if (Informix_GLOBAL(php3_ifx_module).max_links!=-1 && + Informix_GLOBAL(php3_ifx_module).num_links >= + Informix_GLOBAL(php3_ifx_module).max_links) { php3_error(E_WARNING, "Informix: Too many open links (%d)", - IFXG(num_links)); + Informix_GLOBAL(php3_ifx_module).num_links); efree(hashed_details); RETURN_FALSE; } - if (IFXG(max_persistent)!=-1 && - IFXG(num_persistent) >= - IFXG(max_persistent)) { + if (Informix_GLOBAL(php3_ifx_module).max_persistent!=-1 && + Informix_GLOBAL(php3_ifx_module).num_persistent >= + Informix_GLOBAL(php3_ifx_module).max_persistent) { php3_error(E_WARNING, "Informix: Too many open persistent links (%d)", - IFXG(num_persistent)); + Informix_GLOBAL(php3_ifx_module).num_persistent); efree(hashed_details); RETURN_FALSE; } /* create the link */ ifx = (char *)malloc(sizeof(IFX)); - IFXG(connectionid)++; + Informix_GLOBAL(php3_ifx_module).connectionid++; sprintf(ifx,"%s%x", user, - IFXG(connectionid)); + Informix_GLOBAL(php3_ifx_module).connectionid); EXEC SQL CONNECT TO :host AS :ifx USER :user USING :passwd WITH CONCURRENT TRANSACTION; if (ifx_check() == IFX_ERROR) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,ifx_error(ifx)); free(ifx); efree(hashed_details); @@ -580,7 +732,7 @@ static void php3_ifx_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) } /* hash it up */ - new_le.type = IFXG(le_plink); + new_le.type = Informix_GLOBAL(php3_ifx_module).le_plink; new_le.ptr = ifx; if (_php3_hash_update(plist, hashed_details, hashed_details_length+1, @@ -589,10 +741,10 @@ static void php3_ifx_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) efree(hashed_details); RETURN_FALSE; } - IFXG(num_persistent)++; - IFXG(num_links)++; + Informix_GLOBAL(php3_ifx_module).num_persistent++; + Informix_GLOBAL(php3_ifx_module).num_links++; } else { /* we do */ - if (le->type != IFXG(le_plink)) { + if (le->type != Informix_GLOBAL(php3_ifx_module).le_plink) { RETURN_FALSE; } /* ensure that the link did not die */ @@ -606,7 +758,7 @@ static void php3_ifx_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) WITH CONCURRENT TRANSACTION; if (ifx_check() == IFX_ERROR) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING, "Informix: Link to server lost, unable to reconnect (%s)", ifx_error(ifx)); @@ -618,7 +770,8 @@ static void php3_ifx_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) } ifx = le->ptr; } - return_value->value.lval = php3_list_insert(ifx, IFXG(le_plink)); + return_value->value.lval = php3_list_insert(ifx, + Informix_GLOBAL(php3_ifx_module).le_plink); return_value->type = IS_LONG; } else { /* non persistent */ list_entry *index_ptr,new_index_ptr; @@ -632,44 +785,43 @@ static void php3_ifx_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) (void **) &index_ptr) == SUCCESS) { int type,link; void *ptr; -#ifdef THREAD_SAFE - if (index_ptr->type != _php3_le_index_ptr()) { -#else + if (index_ptr->type != le_index_ptr) { -#endif RETURN_FALSE; } link = (int) index_ptr->ptr; ptr = php3_list_find(link,&type); /* check if the link is still there */ - if (ptr && (type==IFXG(le_link) || type==IFXG(le_plink))) { - zend_list_addref(link); - return_value->value.lval = IFXG(default_link) = link; - return_value->type = IS_RESOURCE; + if (ptr && (type==Informix_GLOBAL(php3_ifx_module).le_link || + type==Informix_GLOBAL(php3_ifx_module).le_plink)) { + return_value->value.lval = + Informix_GLOBAL(php3_ifx_module).default_link = + link; + return_value->type = IS_LONG; efree(hashed_details); return; } else { _php3_hash_del(list,hashed_details,hashed_details_length+1); } } - if (IFXG(max_links) != -1 && - IFXG(num_links) >= - IFXG(max_links)) { + if (Informix_GLOBAL(php3_ifx_module).max_links != -1 && + Informix_GLOBAL(php3_ifx_module).num_links >= + Informix_GLOBAL(php3_ifx_module).max_links) { php3_error(E_WARNING, "Informix: Too many open links (%d)", - IFXG(num_links)); + Informix_GLOBAL(php3_ifx_module).num_links); efree(hashed_details); RETURN_FALSE; } ifx = (char *) emalloc(sizeof(IFX)); - IFXG(connectionid)++; + Informix_GLOBAL(php3_ifx_module).connectionid++; sprintf(ifx,"connec%x", - IFXG(connectionid)); + Informix_GLOBAL(php3_ifx_module).connectionid); EXEC SQL CONNECT TO :host AS :ifx USER :user USING :passwd WITH CONCURRENT TRANSACTION; if (ifx_check() == IFX_ERROR) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"ifx_pconnect : %s", ifx_error(ifx)); efree(hashed_details); efree(ifx); @@ -677,16 +829,13 @@ static void php3_ifx_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) } /* add it to the list */ - return_value->value.lval = php3_list_insert(ifx,IFXG(le_link)); - return_value->type = IS_RESOURCE; + return_value->value.lval = + php3_list_insert(ifx,Informix_GLOBAL(php3_ifx_module).le_link); + return_value->type = IS_LONG; /* add it to the hash */ new_index_ptr.ptr = (void *) return_value->value.lval; -#ifdef THREAD_SAFE - new_index_ptr.type = _php3_le_index_ptr(); -#else new_index_ptr.type = le_index_ptr; -#endif if (_php3_hash_update(list, hashed_details, hashed_details_length+1, @@ -695,10 +844,10 @@ static void php3_ifx_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) efree(hashed_details); RETURN_FALSE; } - IFXG(num_links)++; + Informix_GLOBAL(php3_ifx_module).num_links++; } efree(hashed_details); - IFXG(default_link)=return_value->value.lval; + Informix_GLOBAL(php3_ifx_module).default_link=return_value->value.lval; } @@ -720,16 +869,16 @@ PHP_FUNCTION(ifx_pconnect) static int php3_ifx_get_default_link(INTERNAL_FUNCTION_PARAMETERS) { - IFXLS_FETCH(); + Informix_TLS_VARS; - if (IFXG(default_link)==-1) { /* no link opened yet, implicitly open one */ + if (Informix_GLOBAL(php3_ifx_module).default_link==-1) { /* no link opened yet, implicitly open one */ HashTable tmp; _php3_hash_init(&tmp,0,NULL,NULL,0); - php3_ifx_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0); + php3_ifx_do_connect(&tmp,return_value,list,plist,0); _php3_hash_destroy(&tmp); } - return IFXG(default_link); + return Informix_GLOBAL(php3_ifx_module).default_link; } /* ---------------------------------------------------------------------- @@ -751,13 +900,13 @@ EXEC SQL BEGIN DECLARE SECTION; char *ifx; EXEC SQL END DECLARE SECTION; - IFXLS_FETCH(); + Informix_TLS_VARS; switch (ARG_COUNT(ht)) { case 0: - id = IFXG(default_link); + id = Informix_GLOBAL(php3_ifx_module).default_link; break; case 1: if (getParameters(ht, 1, &ifx_link)==FAILURE) { @@ -771,11 +920,11 @@ EXEC SQL END DECLARE SECTION; break; } - IFXG(sv_sqlcode) = 0; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = 0; ifx = (char *) php3_list_find(id,&type); - if (type!=IFXG(le_link) && - type!=IFXG(le_plink)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_link && + type!=Informix_GLOBAL(php3_ifx_module).le_plink) { php3_error(E_WARNING, "ifx_close : %d (type %d) is not an Informix link index", id, @@ -853,37 +1002,24 @@ EXEC SQL END DECLARE SECTION; int query_type; int cursoryproc; - IFXLS_FETCH(); + Informix_TLS_VARS; if(ARG_COUNT(ht)<2) { WRONG_PARAM_COUNT; } - IFXG(sv_sqlcode) = 0; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = 0; - /* get the first 2 parameters, - php4 insists on the correct number of arguments */ - switch(ARG_COUNT(ht)) { - case 2: - if (getParameters(ht, 2, &query, &ifx_link)==FAILURE) - RETURN_FALSE; - break; - case 3: - if (getParameters(ht, 3, &query, &ifx_link, &dummy)==FAILURE) - RETURN_FALSE; - break; - case 4: - if (getParameters(ht, 4, &query, &ifx_link, &dummy, &dummy)==FAILURE) - RETURN_FALSE; - break; + /* get the first 2 parameters */ + if (getParameters(ht, 2, &query, &ifx_link)==FAILURE) { + RETURN_FALSE; } - convert_to_long(ifx_link); id = ifx_link->value.lval; ifx = (char *) php3_list_find(id,&type); - if (type != IFXG(le_link) && - type!=IFXG(le_plink)) { + if (type != Informix_GLOBAL(php3_ifx_module).le_link && + type!=Informix_GLOBAL(php3_ifx_module).le_plink) { php3_error(E_WARNING, "ifx_query : %d (type %d) is not a Informix link index", id, @@ -896,14 +1032,14 @@ EXEC SQL END DECLARE SECTION; convert_to_string(query); statement = query->value.str.val; - IFXG(cursorid)++; - sprintf(statemid, "statem%x", IFXG(cursorid)); - sprintf(cursorid, "cursor%x", IFXG(cursorid)); - sprintf(descrpid, "descrp%x", IFXG(cursorid)); + Informix_GLOBAL(php3_ifx_module).cursorid++; + sprintf(statemid, "statem%x", Informix_GLOBAL(php3_ifx_module).cursorid); + sprintf(cursorid, "cursor%x", Informix_GLOBAL(php3_ifx_module).cursorid); + sprintf(descrpid, "descrp%x", Informix_GLOBAL(php3_ifx_module).cursorid); EXEC SQL set connection :ifx; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Set connection %s fails (%s)", ifx, ifx_error(ifx)); @@ -911,7 +1047,7 @@ EXEC SQL END DECLARE SECTION; } EXEC SQL PREPARE :statemid FROM :statement; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Prepare fails (%s)", ifx_error(ifx)); RETURN_FALSE; @@ -922,7 +1058,7 @@ EXEC SQL END DECLARE SECTION; EXEC SQL ALLOCATE DESCRIPTOR :descrpid WITH MAX 256; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Allocate desciptor <%s> fails (%s)", descrpid, ifx_error(ifx)); @@ -931,7 +1067,7 @@ EXEC SQL END DECLARE SECTION; } EXEC SQL DESCRIBE :statemid USING SQL DESCRIPTOR :descrpid; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Describe fails (%s)", ifx_error(ifx)); EXEC SQL DEALLOCATE DESCRIPTOR :descrpid; @@ -973,7 +1109,7 @@ EXEC SQL END DECLARE SECTION; ## NONSELECT-STATEMENT ## */ - pval *pblobidarr, **tmp; + pval *pblobidarr, *tmp; Ifx_Result->iscursory = 0; @@ -986,13 +1122,7 @@ EXEC SQL END DECLARE SECTION; } if(ARG_COUNT(ht)==3) { - if (getParameters(ht, 3, &dummy, &dummy, &pblobidarr) == FAILURE) { - php3_error(E_WARNING,"Can't get blob array param"); - EXEC SQL DEALLOCATE DESCRIPTOR :descrpid; - EXEC SQL free :statemid; - efree(Ifx_Result); - RETURN_FALSE; - } + getParameters(ht, ARG_COUNT(ht), &dummy,&dummy,&pblobidarr); if (pblobidarr->type != IS_ARRAY) { php3_error(E_WARNING,"blob-parameter not an array"); EXEC SQL DEALLOCATE DESCRIPTOR :descrpid; @@ -1005,16 +1135,16 @@ EXEC SQL END DECLARE SECTION; i=1; while (_php3_hash_get_current_data(pblobidarr->value.ht, (void **) &tmp) == SUCCESS) { - convert_to_long(*tmp); + convert_to_long(tmp); if ((query_type == SQ_UPDATE) || (query_type == SQ_UPDALL)) { EXEC SQL SET DESCRIPTOR :descrpid COUNT = :i; } /* TEXT/BYTE */ - if(php3_intifx_getType((int)(*tmp)->value.lval,list)==TYPE_BLTEXT || php3_intifx_getType((int)(*tmp)->value.lval,list)==TYPE_BLBYTE) { - locator=php3_intifx_get_blobloc((int)((*tmp)->value.lval),list); + if(php3_intifx_getType((int)tmp->value.lval,list)==TYPE_BLTEXT || php3_intifx_getType((int)tmp->value.lval,list)==TYPE_BLBYTE) { + locator=php3_intifx_get_blobloc((int)tmp->value.lval,list); if(locator==NULL) { php3_error(E_WARNING,"%d is not a Informix blob-result index", - (int)((*tmp)->value.lval)); + (int)tmp->value.lval); EXEC SQL DEALLOCATE DESCRIPTOR :descrpid; EXEC SQL free :statemid; efree(Ifx_Result); @@ -1029,8 +1159,8 @@ EXEC SQL END DECLARE SECTION; } /* CHAR */ - if(php3_intifx_getType((int)(*tmp)->value.lval,list)==TYPE_CHAR) { - len=php3_intifx_get_char((int)((*tmp)->value.lval),list,&char_tmp); + if(php3_intifx_getType((int)tmp->value.lval,list)==TYPE_CHAR) { + len=php3_intifx_get_char((int)tmp->value.lval,list,&char_tmp); indicator=0; if(char_tmp==NULL || len<0) indicator=-1; @@ -1052,7 +1182,7 @@ EXEC SQL END DECLARE SECTION; EXEC SQL EXECUTE :statemid; } if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Execute immediate fails : %s (%s)", statement, ifx_error(ifx)); @@ -1096,7 +1226,7 @@ EXEC SQL END DECLARE SECTION; EXEC SQL GET DESCRIPTOR :descrpid :fieldcount = COUNT; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Can not get descriptor %s (%s)", descrpid, ifx_error(ifx)); @@ -1125,7 +1255,7 @@ EXEC SQL END DECLARE SECTION; EXEC SQL DECLARE :cursorid CURSOR FOR :statemid; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Declare cursor fails (%s)", ifx_error(ifx)); efree(Ifx_Result); EXEC SQL DEALLOCATE DESCRIPTOR :descrpid; @@ -1134,7 +1264,7 @@ EXEC SQL END DECLARE SECTION; } EXEC SQL OPEN :cursorid; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Open cursor fails (%s)", ifx_error(ifx)); efree(Ifx_Result); EXEC SQL DEALLOCATE DESCRIPTOR :descrpid; @@ -1166,7 +1296,7 @@ $endif; EXEC SQL SET DESCRIPTOR :descrpid VALUE :i DATA = :*locator; } if(fieldtype==SQLBYTES) { - if(IFXG(blobinfile)==0) { + if(Informix_GLOBAL(php3_ifx_module).blobinfile==0) { bid=php3_intifx_create_blob(TYPE_BLBYTE,BLMODE_INMEM,"",-1,list); locator=php3_intifx_get_blobloc(bid,list); } else { @@ -1194,7 +1324,7 @@ $endif; } - RETURN_LONG(php3_list_insert(Ifx_Result,IFXG(le_result))); + RETURN_LONG(php3_list_insert(Ifx_Result,Informix_GLOBAL(php3_ifx_module).le_result)); } /* }}} */ @@ -1254,37 +1384,24 @@ EXEC SQL END DECLARE SECTION; int query_type; int cursoryproc; - IFXLS_FETCH(); + Informix_TLS_VARS; if(ARG_COUNT(ht)<2) { WRONG_PARAM_COUNT; } - IFXG(sv_sqlcode) = 0; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = 0; - /* get the first 2 parameters, - php4 insists on the correct number of arguments */ - switch(ARG_COUNT(ht)) { - case 2: - if (getParameters(ht, 2, &query, &ifx_link)==FAILURE) - RETURN_FALSE; - break; - case 3: - if (getParameters(ht, 3, &query, &ifx_link, &dummy)==FAILURE) - RETURN_FALSE; - break; - case 4: - if (getParameters(ht, 4, &query, &ifx_link, &dummy, &dummy)==FAILURE) - RETURN_FALSE; - break; + /* get the first 2 parameters */ + if (getParameters(ht, 2, &query, &ifx_link)==FAILURE) { + RETURN_FALSE; } - convert_to_long(ifx_link); id = ifx_link->value.lval; ifx = (char *) php3_list_find(id,&type); - if (type != IFXG(le_link) && - type!=IFXG(le_plink)) { + if (type != Informix_GLOBAL(php3_ifx_module).le_link && + type!=Informix_GLOBAL(php3_ifx_module).le_plink) { php3_error(E_WARNING, "ifx_query : %d (type %d) is not a Informix link index", id, @@ -1298,14 +1415,14 @@ EXEC SQL END DECLARE SECTION; convert_to_string(query); statement = query->value.str.val; - IFXG(cursorid)++; - sprintf(statemid, "statem%x", IFXG(cursorid)); - sprintf(cursorid, "cursor%x", IFXG(cursorid)); - sprintf(descrpid, "descrp%x", IFXG(cursorid)); + Informix_GLOBAL(php3_ifx_module).cursorid++; + sprintf(statemid, "statem%x", Informix_GLOBAL(php3_ifx_module).cursorid); + sprintf(cursorid, "cursor%x", Informix_GLOBAL(php3_ifx_module).cursorid); + sprintf(descrpid, "descrp%x", Informix_GLOBAL(php3_ifx_module).cursorid); EXEC SQL set connection :ifx; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Set connection %s fails (%s)", ifx, ifx_error(ifx)); @@ -1313,7 +1430,7 @@ EXEC SQL END DECLARE SECTION; } EXEC SQL PREPARE :statemid FROM :statement; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Prepare fails (%s)", ifx_error(ifx)); RETURN_FALSE; @@ -1322,7 +1439,7 @@ EXEC SQL END DECLARE SECTION; for (e = 0; e < 6; e++) sqlerrd[e] = sqlca.sqlerrd[e]; EXEC SQL ALLOCATE DESCRIPTOR :descrpid WITH MAX 256; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Allocate desciptor <%s> fails (%s)", descrpid, ifx_error(ifx)); @@ -1331,7 +1448,7 @@ EXEC SQL END DECLARE SECTION; } EXEC SQL DESCRIBE :statemid USING SQL DESCRIPTOR :descrpid; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Describe fails (%s)", ifx_error(ifx)); EXEC SQL DEALLOCATE DESCRIPTOR :descrpid; @@ -1343,7 +1460,7 @@ EXEC SQL END DECLARE SECTION; Ifx_Result = (IFX_RES *)emalloc(sizeof(IFX_RES)); if (Ifx_Result == NULL) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Out of memory allocating IFX_RES"); EXEC SQL DEALLOCATE DESCRIPTOR :descrpid; EXEC SQL free :statemid; @@ -1375,7 +1492,7 @@ EXEC SQL END DECLARE SECTION; ## NONSELECT-STATEMENT ## */ - pval *pblobidarr, **tmp; + pval *pblobidarr, *tmp; Ifx_Result->iscursory = 0; @@ -1389,13 +1506,7 @@ EXEC SQL END DECLARE SECTION; } if(ARG_COUNT(ht)==3) { Ifx_Result->paramquery=1; - if (getParameters(ht, 3, &dummy, &dummy,&pblobidarr) == FAILURE) { - php3_error(E_WARNING,"Can't get blob array param"); - EXEC SQL DEALLOCATE DESCRIPTOR :descrpid; - EXEC SQL free :statemid; - efree(Ifx_Result); - RETURN_FALSE; - } + getParameters(ht, ARG_COUNT(ht), &dummy,&dummy,&pblobidarr); if(pblobidarr->type != IS_ARRAY) { php3_error(E_WARNING,"blob-parameter not an array"); EXEC SQL DEALLOCATE DESCRIPTOR :descrpid; @@ -1407,16 +1518,16 @@ EXEC SQL END DECLARE SECTION; i=1; while (_php3_hash_get_current_data(pblobidarr->value.ht, (void **) &tmp) == SUCCESS) { - convert_to_long(*tmp); + convert_to_long(tmp); if ((query_type == SQ_UPDATE) || (query_type == SQ_UPDALL)) { EXEC SQL SET DESCRIPTOR :descrpid COUNT = :i; } /* TEXT/BYTE */ - if(php3_intifx_getType((int)((*tmp)->value.lval),list)==TYPE_BLTEXT || php3_intifx_getType((int)((*tmp)->value.lval),list)==TYPE_BLBYTE) { - locator=php3_intifx_get_blobloc((int)((*tmp)->value.lval),list); + if(php3_intifx_getType((int)tmp->value.lval,list)==TYPE_BLTEXT || php3_intifx_getType((int)tmp->value.lval,list)==TYPE_BLBYTE) { + locator=php3_intifx_get_blobloc((int)tmp->value.lval,list); if(locator==NULL) { php3_error(E_WARNING,"%d is not a Informix blob-result index", - (int)((*tmp)->value.lval)); + (int)tmp->value.lval); EXEC SQL DEALLOCATE DESCRIPTOR :descrpid; EXEC SQL free :statemid; efree(Ifx_Result); @@ -1430,8 +1541,8 @@ EXEC SQL END DECLARE SECTION; TYPE=:loc_t_type; } /* CHAR */ - if(php3_intifx_getType((int)((*tmp)->value.lval),list)==TYPE_CHAR) { - len=php3_intifx_get_char((int)((*tmp)->value.lval),list,&char_tmp); + if(php3_intifx_getType((int)tmp->value.lval,list)==TYPE_CHAR) { + len=php3_intifx_get_char((int)tmp->value.lval,list,&char_tmp); indicator=0; if(char_tmp==NULL || len<0) indicator=-1; @@ -1481,7 +1592,7 @@ EXEC SQL END DECLARE SECTION; for (e = 0; e < 6; e++) Ifx_Result->sqlerrd[e] = sqlerrd[e]; EXEC SQL GET DESCRIPTOR :descrpid :fieldcount = COUNT; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Can not get descriptor %s (%s)", descrpid, ifx_error(ifx)); @@ -1500,7 +1611,7 @@ EXEC SQL END DECLARE SECTION; } /* if select */ - RETURN_LONG(php3_list_insert(Ifx_Result,IFXG(le_result))); + RETURN_LONG(php3_list_insert(Ifx_Result,Informix_GLOBAL(php3_ifx_module).le_result)); } /* }}} */ @@ -1546,7 +1657,7 @@ EXEC SQL END DECLARE SECTION; int locind; char *blobfilename; - IFXLS_FETCH(); + Informix_TLS_VARS; switch(ARG_COUNT(ht)) { case 0: @@ -1564,9 +1675,9 @@ EXEC SQL END DECLARE SECTION; break; } - IFXG(sv_sqlcode) = 0; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = 0; - if (type!=IFXG(le_result)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_result) { php3_error(E_WARNING,"%d is not an Informix result index", result->value.lval); RETURN_FALSE; @@ -1580,7 +1691,7 @@ EXEC SQL END DECLARE SECTION; EXEC SQL set connection :ifx; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Set connection %s fails (%s)", ifx, ifx_error(ifx)); @@ -1599,7 +1710,7 @@ EXEC SQL END DECLARE SECTION; EXEC SQL EXECUTE :statemid; } if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Execute immediate fails : %s ", ifx_error(ifx)); RETURN_FALSE; @@ -1619,13 +1730,13 @@ EXEC SQL END DECLARE SECTION; EXEC SQL DECLARE :cursorid CURSOR FOR :statemid; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Declare cursor fails (%s)", ifx_error(ifx)); RETURN_FALSE; } EXEC SQL OPEN :cursorid; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Open cursor fails (%s)", ifx_error(ifx)); RETURN_FALSE; } @@ -1650,7 +1761,7 @@ $endif; EXEC SQL SET DESCRIPTOR :descrpid VALUE :i DATA = :*locator; } if(fieldtype==SQLBYTES) { - if(IFXG(blobinfile)==0) { + if(Informix_GLOBAL(php3_ifx_module).blobinfile==0) { bid=php3_intifx_create_blob(TYPE_BLBYTE,BLMODE_INMEM,"",-1,list); locator=php3_intifx_get_blobloc(bid,list); } else { @@ -1700,12 +1811,12 @@ PHP_FUNCTION(ifx_error) { pval *ifx_link; int id; - IFXLS_FETCH(); + Informix_TLS_VARS; switch(ARG_COUNT(ht)) { case 0: - id = IFXG(default_link); + id = Informix_GLOBAL(php3_ifx_module).default_link; break; case 1: if (getParameters(ht, 1, &ifx_link)==FAILURE) { @@ -1744,14 +1855,14 @@ PHP_FUNCTION(ifx_errormsg) char *ifx_errmsg; char * returnmsg; - IFXLS_FETCH(); + Informix_TLS_VARS; switch(ARG_COUNT(ht)) { case 0: - if (IFXG(sv_sqlcode) == 0) + if (Informix_GLOBAL(php3_ifx_module).sv_sqlcode == 0) ifx_errorcode = SQLCODE; else - ifx_errorcode = IFXG(sv_sqlcode); + ifx_errorcode = Informix_GLOBAL(php3_ifx_module).sv_sqlcode; break; case 1: if (getParameters(ht, 1, &errcode)==FAILURE) { @@ -1805,7 +1916,7 @@ PHP_FUNCTION(ifx_affected_rows) int type; IFX_RES *Ifx_Result; - IFXLS_FETCH(); + Informix_TLS_VARS; switch(ARG_COUNT(ht)) { case 0: @@ -1823,9 +1934,9 @@ PHP_FUNCTION(ifx_affected_rows) break; } - IFXG(sv_sqlcode )= 0; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = 0; - if (type!=IFXG(le_result)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_result) { php3_error(E_WARNING,"%d is not an Informix result index", result->value.lval); RETURN_FALSE; @@ -1905,7 +2016,7 @@ EXEC SQL END DECLARE SECTION; char *nullstr; - IFXLS_FETCH(); + Informix_TLS_VARS; switch(ARG_COUNT(ht)) { case 0: @@ -1941,9 +2052,9 @@ EXEC SQL END DECLARE SECTION; nullstr=php3_intifx_null(); - IFXG(sv_sqlcode) = 0; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = 0; - if (type!=IFXG(le_result)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_result) { php3_error(E_WARNING,"%d is not an Informix result index", result->value.lval); RETURN_FALSE; @@ -1961,7 +2072,7 @@ EXEC SQL END DECLARE SECTION; EXEC SQL set connection :ifx; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Set connection %s fails (%s)", ifx, ifx_error(ifx)); @@ -2002,7 +2113,7 @@ EXEC SQL END DECLARE SECTION; if(SQLCODE!=-451) { switch (ifx_check()) { case IFX_ERROR: - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING, "Can not fetch row on cursor %s (%s)", ifx_error(ifx), @@ -2030,7 +2141,7 @@ EXEC SQL END DECLARE SECTION; :fieldleng = LENGTH, :indicator = INDICATOR; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Get descriptor (field # %d) fails (%s)", i, ifx_error(ifx)); @@ -2045,9 +2156,9 @@ EXEC SQL END DECLARE SECTION; sprintf(fieldname, "[Expr_%d]", i); if (indicator == -1) { /* NULL */ - if((IFXG(textasvarchar)==0 + if((Informix_GLOBAL(php3_ifx_module).textasvarchar==0 && fieldtype==SQLTEXT) - || (IFXG(byteasvarchar)==0 + || (Informix_GLOBAL(php3_ifx_module).byteasvarchar==0 && fieldtype==SQLBYTES)) { bid_b=Ifx_Result->res_id[locind]; @@ -2149,7 +2260,7 @@ $endif; RETURN_FALSE; } EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :char_data = DATA; - if (IFXG(charasvarchar) != 0 + if (Informix_GLOBAL(php3_ifx_module).charasvarchar != 0 && (fieldtype == SQLCHAR || fieldtype == SQLNCHAR)) { ldchar(char_data, fieldleng, char_data); } @@ -2198,9 +2309,9 @@ $endif; /* note that in case of "blobinfile" */ /* you get the file name */ /* a new one for every row ! */ - if((IFXG(textasvarchar)!=0 + if((Informix_GLOBAL(php3_ifx_module).textasvarchar!=0 && fieldtype==SQLTEXT) - || (IFXG(byteasvarchar)!=0 + || (Informix_GLOBAL(php3_ifx_module).byteasvarchar!=0 && fieldtype==SQLBYTES)) { char *content; long lg; @@ -2295,7 +2406,7 @@ EXEC SQL END DECLARE SECTION; char *table_options; int moredata; - IFXLS_FETCH(); + Informix_TLS_VARS; switch (ARG_COUNT(ht)) { case 1: @@ -2315,12 +2426,12 @@ EXEC SQL END DECLARE SECTION; break; } - IFXG(sv_sqlcode) = 0; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = 0; convert_to_long(result); Ifx_Result = (IFX_RES *) php3_list_find(result->value.lval,&type); - if (type!=IFXG(le_result)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_result) { php3_error(E_WARNING, "%d is not a Informix result index",result->value.lval); RETURN_FALSE; @@ -2339,7 +2450,7 @@ EXEC SQL END DECLARE SECTION; EXEC SQL set connection :ifx; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Set connection %s fails (%s)", ifx, ifx_error(ifx)); @@ -2351,7 +2462,7 @@ EXEC SQL END DECLARE SECTION; EXEC SQL FETCH :cursorid USING SQL DESCRIPTOR :descrpid; switch (ifx_check()) { case IFX_ERROR: - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING, "Can not fetch next row on cursor %s (%s)", ifx_error(ifx), @@ -2383,7 +2494,7 @@ EXEC SQL END DECLARE SECTION; for (i = 1; i <= num_fields; i++) { EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :fieldname = NAME; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Get descriptor (field # %d) fails (%s)", i, ifx_error(ifx)); @@ -2410,7 +2521,7 @@ EXEC SQL END DECLARE SECTION; :fieldleng = LENGTH, :indicator = INDICATOR; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Get descriptor (field # %d) fails (%s)", i, ifx_error(ifx)); @@ -2505,7 +2616,7 @@ $endif; RETURN_FALSE; } EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :char_data = DATA; - if (IFXG(charasvarchar) != 0 + if (Informix_GLOBAL(php3_ifx_module).charasvarchar != 0 && (fieldtype == SQLCHAR || fieldtype == SQLNCHAR)) { ldchar(char_data, fieldleng, char_data); } @@ -2569,7 +2680,7 @@ $endif; EXEC SQL FETCH :cursorid USING SQL DESCRIPTOR :descrpid; switch (ifx_check()) { case IFX_ERROR: - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING, "Can not fetch next row on cursor %s (%s)", ifx_error(ifx), @@ -2629,7 +2740,7 @@ EXEC SQL END DECLARE SECTION; char *p; char *table_options; - IFXLS_FETCH(); + Informix_TLS_VARS; switch (ARG_COUNT(ht)) { case 1: @@ -2649,12 +2760,12 @@ EXEC SQL END DECLARE SECTION; break; } - IFXG(sv_sqlcode) = 0; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = 0; convert_to_long(result); Ifx_Result = (IFX_RES *) php3_list_find(result->value.lval,&type); - if (type!=IFXG(le_result)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_result) { php3_error(E_WARNING, "%d is not a Informix result index",result->value.lval); RETURN_FALSE; @@ -2673,7 +2784,7 @@ EXEC SQL END DECLARE SECTION; EXEC SQL set connection :ifx; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Set connection %s fails (%s)", ifx, ifx_error(ifx)); @@ -2688,7 +2799,7 @@ EXEC SQL END DECLARE SECTION; EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :fieldname = NAME, :fieldtype = TYPE; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Get descriptor (field # %d) fails (%s)", i, ifx_error(ifx)); @@ -2824,7 +2935,7 @@ EXEC SQL END DECLARE SECTION; char *p; char *table_options; - IFXLS_FETCH(); + Informix_TLS_VARS; switch (ARG_COUNT(ht)) { case 1: @@ -2844,12 +2955,12 @@ EXEC SQL END DECLARE SECTION; break; } - IFXG(sv_sqlcode) = 0; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = 0; convert_to_long(result); Ifx_Result = (IFX_RES *) php3_list_find(result->value.lval,&type); - if (type!=IFXG(le_result)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_result) { php3_error(E_WARNING, "%d is not a Informix result index",result->value.lval); RETURN_FALSE; @@ -2868,7 +2979,7 @@ EXEC SQL END DECLARE SECTION; EXEC SQL set connection :ifx; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Set connection %s fails (%s)", ifx, ifx_error(ifx)); @@ -2888,7 +2999,7 @@ EXEC SQL END DECLARE SECTION; :scale = SCALE, :isnullable = NULLABLE; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Get descriptor (field # %d) fails (%s)", i, ifx_error(ifx)); @@ -3002,18 +3113,18 @@ PHP_FUNCTION(ifx_num_rows) pval *result; IFX_RES *Ifx_Result; int type; - IFXLS_FETCH(); + Informix_TLS_VARS; if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) { WRONG_PARAM_COUNT; } - IFXG(sv_sqlcode) = 0; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = 0; convert_to_long(result); Ifx_Result = (IFX_RES *) php3_list_find(result->value.lval,&type); - if (type!=IFXG(le_result)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_result) { php3_error(E_WARNING,"%d is not a Informix result index", result->value.lval); RETURN_FALSE; @@ -3045,18 +3156,18 @@ PHP_FUNCTION(ifx_getsqlca) char fieldname[16]; int e; - IFXLS_FETCH(); + Informix_TLS_VARS; if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) { WRONG_PARAM_COUNT; } - IFXG(sv_sqlcode) = 0; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = 0; convert_to_long(result); Ifx_Result = (IFX_RES *) php3_list_find(result->value.lval,&type); - if (type!=IFXG(le_result)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_result) { php3_error(E_WARNING,"%d is not a Informix result index", result->value.lval); RETURN_FALSE; @@ -3093,18 +3204,18 @@ PHP_FUNCTION(ifx_num_fields) pval *result; IFX_RES *Ifx_Result; int type; - IFXLS_FETCH(); + Informix_TLS_VARS; if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) { WRONG_PARAM_COUNT; } - IFXG(sv_sqlcode) = 0; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = 0; convert_to_long(result); Ifx_Result = (IFX_RES *) php3_list_find(result->value.lval,&type); - if (type!=IFXG(le_result)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_result) { php3_error(E_WARNING,"%d is not a Informix result index", result->value.lval); RETURN_FALSE; @@ -3145,7 +3256,7 @@ EXEC SQL END DECLARE SECTION; int i, locind; - IFXLS_FETCH(); + Informix_TLS_VARS; if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) { @@ -3159,13 +3270,13 @@ EXEC SQL END DECLARE SECTION; Ifx_Result = (IFX_RES *) php3_list_find(result->value.lval,&type); - if (type!=IFXG(le_result)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_result) { php3_error(E_WARNING,"%d is not a Informix result index", result->value.lval); RETURN_FALSE; } - IFXG(sv_sqlcode = 0); + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = 0; for (i = 0; i < MAX_RESID; ++i) { @@ -3182,7 +3293,7 @@ EXEC SQL END DECLARE SECTION; EXEC SQL set connection :ifx; if (ifx_check() < 0) { - IFXG(sv_sqlcode) = SQLCODE; + Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE; php3_error(E_WARNING,"Set connection %s fails (%s)", ifx, ifx_error(ifx)); @@ -3226,7 +3337,7 @@ static long php3_intifx_getType(long id, HashTable *list) { int type; Ifx_res = (IFX_IDRES *) php3_list_find(id,&type); - if (type!=IFXG(le_idresult)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult) { php3_error(E_WARNING,"%d is not a Informix id-result index", id); return -1; @@ -3346,7 +3457,7 @@ static long php3_intifx_create_blob(long type, long mode, char* param, long len, Ifx_blob->BLOB.blob_data.loc_oflags=LOC_WONLY; Ifx_blob->BLOB.blob_data.loc_size=-1; } - return php3_list_insert(Ifx_blob,IFXG(le_idresult)); + return php3_list_insert(Ifx_blob,Informix_GLOBAL(php3_ifx_module).le_idresult); } @@ -3401,7 +3512,7 @@ static long php3_intifx_copy_blob(long bid, HashTable *list) { int type; Ifx_blob_orig = (IFX_IDRES *) php3_list_find(bid,&type); - if (type!=IFXG(le_idresult) || !(Ifx_blob_orig->type==TYPE_BLBYTE || Ifx_blob_orig->type==TYPE_BLTEXT)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult || !(Ifx_blob_orig->type==TYPE_BLBYTE || Ifx_blob_orig->type==TYPE_BLTEXT)) { php3_error(E_WARNING,"%d is not a Informix blob-result index", bid); return -1; @@ -3453,7 +3564,7 @@ static long php3_intifx_copy_blob(long bid, HashTable *list) { locator->loc_oflags=locator_orig->loc_oflags; } - return php3_list_insert(Ifx_blob,IFXG(le_idresult)); + return php3_list_insert(Ifx_blob,Informix_GLOBAL(php3_ifx_module).le_idresult); } @@ -3503,7 +3614,7 @@ static long php3_intifx_free_blob(long bid, HashTable *list) { int type; Ifx_blob = (IFX_IDRES *) php3_list_find(bid,&type); - if (type!=IFXG(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) { php3_error(E_WARNING,"%d is not a Informix blob-result index", bid); return -1; @@ -3545,7 +3656,7 @@ static long php3_intifx2_free_blob(long bid, HashTable *list) { int type; Ifx_blob = (IFX_IDRES *) php3_list_find(bid,&type); - if (type!=IFXG(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) { php3_error(E_WARNING,"%d is not a Informix blob-result index", bid); return -1; @@ -3620,7 +3731,7 @@ static long php3_intifx_get_blob(long bid, HashTable *list, char** content) { int type; Ifx_blob = (IFX_IDRES *) php3_list_find(bid,&type); - if (type!=IFXG(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) { php3_error(E_WARNING,"%d is not a Informix blob-result index", bid); return -1; @@ -3650,7 +3761,7 @@ static loc_t *php3_intifx_get_blobloc(long bid, HashTable *list) { int type; Ifx_blob = (IFX_IDRES *) php3_list_find(bid,&type); - if (type!=IFXG(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) { php3_error(E_WARNING,"%d is not a Informix blob-result index", bid); return NULL; @@ -3713,7 +3824,7 @@ static long php3_intifx_update_blob(long bid, char* param, long len, HashTable * int type; Ifx_blob = (IFX_IDRES *) php3_list_find(bid,&type); - if (type!=IFXG(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) { php3_error(E_WARNING,"%d is not a Informix blob-result index", bid); return -1; @@ -3812,7 +3923,7 @@ PHP_FUNCTION(ifx_blobinfile_mode) { } convert_to_long(pmode); - IFXG(blobinfile)=pmode->value.lval; + Informix_GLOBAL(php3_ifx_module).blobinfile=pmode->value.lval; RETURN_TRUE; } /* }}} */ @@ -3840,7 +3951,7 @@ PHP_FUNCTION(ifx_textasvarchar) { } convert_to_long(pmode); - IFXG(textasvarchar)=pmode->value.lval; + Informix_GLOBAL(php3_ifx_module).textasvarchar=pmode->value.lval; RETURN_TRUE; } /* }}} */ @@ -3867,7 +3978,7 @@ PHP_FUNCTION(ifx_byteasvarchar) { } convert_to_long(pmode); - IFXG(byteasvarchar)=pmode->value.lval; + Informix_GLOBAL(php3_ifx_module).byteasvarchar=pmode->value.lval; RETURN_TRUE; } @@ -3894,7 +4005,7 @@ PHP_FUNCTION(ifx_nullformat) { } convert_to_long(pmode); - IFXG(nullformat)=pmode->value.lval; + Informix_GLOBAL(php3_ifx_module).nullformat=pmode->value.lval; RETURN_TRUE; } /* }}} */ @@ -3910,10 +4021,10 @@ PHP_FUNCTION(ifx_nullformat) { static char* php3_intifx_null() { char* tmp; - if(IFXG(nullformat)==0) { - tmp=IFXG(nullvalue); + if(Informix_GLOBAL(php3_ifx_module).nullformat==0) { + tmp=Informix_GLOBAL(php3_ifx_module).nullvalue; } else { - tmp=IFXG(nullstring); + tmp=Informix_GLOBAL(php3_ifx_module).nullstring; } return tmp; } @@ -3996,7 +4107,7 @@ static long php3_intifx_create_char(char* param, long len, HashTable *list) { Ifx_char->CHAR.char_data[len]=0; Ifx_char->CHAR.len=len; } - return php3_list_insert(Ifx_char,IFXG(le_idresult)); + return php3_list_insert(Ifx_char,Informix_GLOBAL(php3_ifx_module).le_idresult); } /* ---------------------------------------------------------------------- @@ -4047,7 +4158,7 @@ static long php3_intifx_get_char(long bid, HashTable *list, char** content) { int type; Ifx_char = (IFX_IDRES *) php3_list_find(bid,&type); - if (type!=IFXG(le_idresult) && !(Ifx_char->type==TYPE_CHAR)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult && !(Ifx_char->type==TYPE_CHAR)) { php3_error(E_WARNING,"%d is not a Informix char-result index", bid); return -1; @@ -4101,7 +4212,7 @@ static long php3_intifx_free_char(long bid, HashTable *list) { int type; Ifx_char = (IFX_IDRES *) php3_list_find(bid,&type); - if (type!=IFXG(le_idresult) && !(Ifx_char->type==TYPE_CHAR)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult && !(Ifx_char->type==TYPE_CHAR)) { php3_error(E_WARNING,"%d is not a Informix char-result index", bid); return -1; @@ -4168,7 +4279,7 @@ static long php3_intifx_update_char(long bid, char* param, long len, HashTable * int type; Ifx_char = (IFX_IDRES *) php3_list_find(bid,&type); - if (type!=IFXG(le_idresult) && !(Ifx_char->type==TYPE_CHAR)) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult && !(Ifx_char->type==TYPE_CHAR)) { php3_error(E_WARNING,"%d is not a Informix char-result index", bid); return -1; @@ -4313,7 +4424,7 @@ static long php3_intifxus_create_slob(long create_mode, HashTable *list) { return -1; } - return php3_list_insert(Ifx_slob,IFXG(le_idresult)); + return php3_list_insert(Ifx_slob,Informix_GLOBAL(php3_ifx_module).le_idresult); } @@ -4362,7 +4473,7 @@ static long php3_intifxus_free_slob(long bid, HashTable *list) { int type; Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type); - if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult || Ifx_slob->type!=TYPE_SLOB) { php3_error(E_WARNING,"%d is not a Informix slob-result index", bid); return -1; @@ -4428,7 +4539,7 @@ static long php3_intifxus_close_slob(long bid, HashTable *list) { int type; Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type); - if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult || Ifx_slob->type!=TYPE_SLOB) { php3_error(E_WARNING,"%d is not a Informix slob-result index", bid); return -1; @@ -4513,7 +4624,7 @@ static long php3_intifxus_open_slob(long bid, long create_mode, HashTable *list) Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type); - if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult || Ifx_slob->type!=TYPE_SLOB) { php3_error(E_WARNING,"%d is not a Informix slob-result index", bid); return -1; @@ -4562,7 +4673,7 @@ static long php3_intifxus_new_slob(HashTable *list) { Ifx_slob->type=TYPE_SLOB; Ifx_slob->SLOB.lofd=-1; Ifx_slob->SLOB.createspec=NULL; - return php3_list_insert(Ifx_slob,IFXG(le_idresult)); + return php3_list_insert(Ifx_slob,Informix_GLOBAL(php3_ifx_module).le_idresult); } @@ -4581,7 +4692,7 @@ static ifx_lo_t *php3_intifxus_get_slobloc(long bid, HashTable *list) { int errcode, type; Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type); - if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult || Ifx_slob->type!=TYPE_SLOB) { php3_error(E_WARNING,"%d is not a Informix slob-result index", bid); return NULL; @@ -4621,7 +4732,7 @@ PHP_FUNCTION(ifxus_tell_slob) { convert_to_long(pbid); bid=pbid->value.lval; Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type); - if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult || Ifx_slob->type!=TYPE_SLOB) { php3_error(E_WARNING,"%d is not a Informix slob-result index", bid); RETURN_FALSE; @@ -4671,7 +4782,7 @@ PHP_FUNCTION(ifxus_seek_slob) { bid=pbid->value.lval; Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type); - if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult || Ifx_slob->type!=TYPE_SLOB) { php3_error(E_WARNING,"%d is not a Informix slob-result index", bid); RETURN_FALSE; @@ -4730,7 +4841,7 @@ PHP_FUNCTION(ifxus_read_slob) { bid=pbid->value.lval; Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type); - if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult || Ifx_slob->type!=TYPE_SLOB) { php3_error(E_WARNING,"%d is not a Informix slob-result index", bid); RETURN_FALSE; @@ -4781,7 +4892,7 @@ PHP_FUNCTION(ifxus_write_slob) { bid=pbid->value.lval; Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type); - if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) { + if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult || Ifx_slob->type!=TYPE_SLOB) { php3_error(E_WARNING,"%d is not a Informix slob-result index", bid); RETURN_FALSE; diff --git a/ext/informix/php_informix.h b/ext/informix/php_informix.h index 264e362623..ae409bb4f9 100644 --- a/ext/informix/php_informix.h +++ b/ext/informix/php_informix.h @@ -40,36 +40,22 @@ #define HAVE_IFX 1 #endif -#if WIN32||WINNT -#define PHP_IFX_API __declspec(dllexport) -#else -#define PHP_IFX_API -#endif - - -#if HAVE_IFX /* with Informix */ - +#if HAVE_IFX #ifndef DLEXPORT #define DLEXPORT #endif -#ifdef ZTS -#include "TSRM.h" -#endif +#include "locator.h" +#include "sqltypes.h" + extern php3_module_entry ifx_module_entry; #define ifx_module_ptr &ifx_module_entry - -#include "locator.h" -#include "sqltypes.h" - -/* user functions */ extern int php3_minit_ifx(INIT_FUNC_ARGS); extern int php3_rinit_ifx(INIT_FUNC_ARGS); extern int php3_mshutdown_ifx(SHUTDOWN_FUNC_ARGS); void php3_info_ifx(ZEND_MODULE_INFO_FUNC_ARGS); -/* functions common to all Informix versions */ PHP_FUNCTION(ifx_connect); PHP_FUNCTION(ifx_pconnect); PHP_FUNCTION(ifx_close); @@ -87,7 +73,7 @@ PHP_FUNCTION(ifx_htmltbl_result); PHP_FUNCTION(ifx_fieldtypes); PHP_FUNCTION(ifx_fieldproperties); PHP_FUNCTION(ifx_getsqlca); -/* BLOB related stuff, IDS & IUS only */ + PHP_FUNCTION(ifx_create_blob); PHP_FUNCTION(ifx_free_blob) ; PHP_FUNCTION(ifx_get_blob); @@ -97,12 +83,13 @@ PHP_FUNCTION(ifx_copy_blob); PHP_FUNCTION(ifx_textasvarchar); PHP_FUNCTION(ifx_byteasvarchar); PHP_FUNCTION(ifx_nullformat); + PHP_FUNCTION(ifx_create_char); PHP_FUNCTION(ifx_free_char) ; PHP_FUNCTION(ifx_update_char); PHP_FUNCTION(ifx_get_char); -/* SLOB, CLOB : IUS only functions */ + #if HAVE_IFX_IUS PHP_FUNCTION(ifxus_create_slob); PHP_FUNCTION(ifxus_free_slob) ; @@ -131,36 +118,11 @@ typedef struct { long nullformat; /* 0=NULL as "", 1= NULL as "NULL" */ char *nullvalue; /* "" */ char *nullstring; /* "NULL" */ -} php_ifx_globals; /* formerly "ifx_module" in the php3 version */ - -#ifndef ZTS -extern php_ifx_globals ifx_globals; -#endif - -#ifdef ZTS -# define IFXLS_D php_ifx_globals *ifx_globals -# define IFXLS_DC , IFXLS_D -# define IFXLS_C ifx_globals -# define IFXLS_CC , IFXLS_C -# define IFXG(v) (ifx_globals->v) -# define IFXLS_FETCH() php_ifx_globals *ifx_globals = ts_resource(ifx_globals_id) -# define IFX_TLS_VARS char *globals; IFXLS_FETCH(); globals = (char *)ifx_globals; -#else -# define IFXLS_D -# define IFXLS_DC -# define IFXLS_C -# define IFXLS_CC -# define IFXG(v) (ifx_globals.v) -# define IFXLS_FETCH() -# define IFX_TLS_VARS char *globals = (char *)&ifx_globals -extern ZEND_API php_ifx_globals ifx_globals; -#endif - +} ifx_module; #define MAX_RESID 64 #define BLOBINFILE 0 /* 0=in memory, 1=in file */ -/* query result set data */ typedef struct ifx_res { char connecid[16]; char cursorid[16]; @@ -212,12 +174,18 @@ typedef struct _IFX_IDRES { #endif -#else /* not HAVE_IFX */ -#define ifx_module_ptr NULL + + +#ifndef THREAD_SAFE +extern ifx_module php3_ifx_module; #endif -#define phpext_informix_ptr ifx_module_ptr +#else + +#define ifx_module_ptr NULL + +#endif #endif /* _PHP3_IFX_H */ diff --git a/ext/msql/config.m4 b/ext/msql/config.m4 index 3ed38f3e46..25694d1b09 100644 --- a/ext/msql/config.m4 +++ b/ext/msql/config.m4 @@ -6,7 +6,7 @@ dnl AC_DEFUN(AC_MSQL_VERSION,[ AC_MSG_CHECKING([mSQL version]) ac_php_oldcflags=$CFLAGS - CFLAGS="$INCLUDES $CFLAGS" + CFLAGS="$INCLUDES $CFLAGS"; AC_TRY_COMPILE([#include <sys/types.h> #include "msql.h"],[int i = IDX_TYPE],[ AC_DEFINE(MSQL1,0) diff --git a/ext/msql/msql.c b/ext/msql/msql.c index 466df9ee15..aab491ef36 100644 --- a/ext/msql/msql.c +++ b/ext/msql/msql.c @@ -450,8 +450,7 @@ static int php3_msql_get_default_link(INTERNAL_FUNCTION_PARAMETERS) { MSQL_TLS_VARS; if (MSQL_GLOBAL(php3_msql_module).default_link==-1) { /* no link opened yet, implicitly open one */ - ht = 0; - php3_msql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); + php3_msql_do_connect(0, return_value, list, plist, this_ptr,0); } return MSQL_GLOBAL(php3_msql_module).default_link; } diff --git a/ext/mysql/mysql.c b/ext/mysql/mysql.c index 319addc54e..6f0f1fec27 100644 --- a/ext/mysql/mysql.c +++ b/ext/mysql/mysql.c @@ -587,7 +587,6 @@ static void php3_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) static int php3_mysql_get_default_link(INTERNAL_FUNCTION_PARAMETERS MySLS_DC) { if (MySG(default_link)==-1) { /* no link opened yet, implicitly open one */ - ht = 0; php3_mysql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); } return MySG(default_link); @@ -1473,7 +1472,7 @@ PHP_FUNCTION(mysql_fetch_row) /* }}} */ -/* {{{ proto object mysql_fetch_object(int result [, int result_type]) +/* {{{ proto object mysql_fetch_object(int result) Fetch a result row as an object */ PHP_FUNCTION(mysql_fetch_object) { @@ -1487,7 +1486,7 @@ PHP_FUNCTION(mysql_fetch_object) /* }}} */ -/* {{{ proto array mysql_fetch_array(int result [, int result_type]) +/* {{{ proto array mysql_fetch_array(int result) Fetch a result row as an associative array */ PHP_FUNCTION(mysql_fetch_array) { diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 6ca165694c..0e4c0e8f61 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -77,9 +77,6 @@ static int _php_free_pcre_cache(void *data) { pcre_cache_entry *pce = (pcre_cache_entry *) data; pefree(pce->re, 1); -#if HAVE_SETLOCALE - pefree((void*)pce->tables, 1); -#endif return 1; } @@ -166,10 +163,6 @@ static pcre* _pcre_get_compiled_regex(char *regex, pcre_extra *extra, int *preg_ int regex_len; int do_study = 0; int poptions = 0; - unsigned const char *tables = NULL; -#if HAVE_SETLOCALE - char *locale = setlocale(LC_CTYPE, NULL); -#endif pcre_cache_entry *pce; pcre_cache_entry new_entry; PCRE_LS_FETCH(); @@ -178,15 +171,9 @@ static pcre* _pcre_get_compiled_regex(char *regex, pcre_extra *extra, int *preg_ back the compiled pattern, otherwise go on and compile it. */ regex_len = strlen(regex); if (zend_hash_find(&PCRE_G(pcre_cache), regex, regex_len+1, (void **)&pce) == SUCCESS) { -#if HAVE_SETLOCALE - if (!strcmp(pce->locale, locale)) { -#endif - extra = pce->extra; - *preg_options = pce->preg_options; - return pce->re; -#if HAVE_SETLOCALE - } -#endif + extra = pce->extra; + *preg_options = pce->preg_options; + return pce->re; } p = regex; @@ -231,7 +218,7 @@ static pcre* _pcre_get_compiled_regex(char *regex, pcre_extra *extra, int *preg_ *preg_options = 0; /* Parse through the options, setting appropriate flags. Display - a warning if we encounter an unknown modifier. */ + a warning if we encounter an unknown option. */ while (*pp != 0) { switch (*pp++) { /* Perl compatible options */ @@ -255,23 +242,18 @@ static pcre* _pcre_get_compiled_regex(char *regex, pcre_extra *extra, int *preg_ break; default: - zend_error(E_WARNING, "Unknown modifier '%c'", pp[-1]); + zend_error(E_WARNING, "Unknown option '%c'", pp[-1]); efree(pattern); return NULL; } } - -#if HAVE_SETLOCALE - if (strcmp(locale, "C")) - tables = pcre_maketables(); -#endif /* Compile pattern and display a warning if compilation failed. */ re = pcre_compile(pattern, coptions, &error, &erroffset, - tables); + NULL); if (re == NULL) { zend_error(E_WARNING, "Compilation failed: %s at offset %d\n", error, erroffset); @@ -296,10 +278,6 @@ static pcre* _pcre_get_compiled_regex(char *regex, pcre_extra *extra, int *preg_ new_entry.re = re; new_entry.extra = extra; new_entry.preg_options = poptions; -#if HAVE_SETLOCALE - new_entry.locale = locale; - new_entry.tables = tables; -#endif zend_hash_update(&PCRE_G(pcre_cache), regex, regex_len+1, (void *)&new_entry, sizeof(pcre_cache_entry), NULL); diff --git a/ext/pcre/php_pcre.h b/ext/pcre/php_pcre.h index c7f9043b05..a367da3bd4 100644 --- a/ext/pcre/php_pcre.h +++ b/ext/pcre/php_pcre.h @@ -35,9 +35,6 @@ #if HAVE_PCRE #include "pcrelib/pcre.h" -#if HAVE_LOCALE_H -#include <locale.h> -#endif extern void php_info_pcre(ZEND_MODULE_INFO_FUNC_ARGS); extern int php_minit_pcre(INIT_FUNC_ARGS); @@ -58,10 +55,6 @@ typedef struct { pcre *re; pcre_extra *extra; int preg_options; -#if HAVE_SETLOCALE - char *locale; - unsigned const char *tables; -#endif } pcre_cache_entry; typedef struct { diff --git a/ext/pgsql/config.m4 b/ext/pgsql/config.m4 index c40840cc3c..bd83c2794e 100644 --- a/ext/pgsql/config.m4 +++ b/ext/pgsql/config.m4 @@ -12,7 +12,6 @@ AC_ARG_WITH(pgsql, else PGSQL_INCDIR=$withval/include test -d $withval/include/pgsql && PGSQL_INCDIR=$withval/include/pgsql - test -d $withval/include/postgresql && PGSQL_INCDIR=$withval/include/postgresql PGSQL_LIBDIR=$withval/lib test -d $withval/lib/pgsql && PGSQL_LIBDIR=$withval/lib/pgsql fi diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 4738a21a93..2e4412c3fd 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -351,13 +351,15 @@ void php3_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) int php3_pgsql_get_default_link(INTERNAL_FUNCTION_PARAMETERS) { if (php3_pgsql_module.default_link==-1) { /* no link opened yet, implicitly open one */ - ht = 0; + HashTable tmp; + + _php3_hash_init(&tmp,0,NULL,NULL,0); php3_pgsql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0); + _php3_hash_destroy(&tmp); } return php3_pgsql_module.default_link; } - /* {{{ proto int pg_connect([string connection_string] | [string host, string port, [string options, [string tty,]] string database) Open a PostgreSQL connection */ PHP_FUNCTION(pgsql_connect) @@ -953,7 +955,7 @@ PHP_FUNCTION(pgsql_fetch_row) /* }}} */ /* ?? This is a rather odd function - why not just point pg_fetcharray() directly at fetch_hash ? -RL */ -/* {{{ proto array pg_fetch_array(int result, int row [, int result_type]) +/* {{{ proto array pg_fetch_array(int result, int row) Fetch a row as an array */ PHP_FUNCTION(pgsql_fetch_array) { @@ -961,7 +963,7 @@ PHP_FUNCTION(pgsql_fetch_array) } /* }}} */ -/* {{{ proto object pg_fetch_object(int result, int row [, int result_type]) +/* {{{ proto object pg_fetch_object(int result, int row) Fetch a row as an object */ PHP_FUNCTION(pgsql_fetch_object) { diff --git a/ext/session/session.c b/ext/session/session.c index f6614da409..eb5fd00023 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -13,7 +13,6 @@ | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Sascha Schumann <ss@2ns.de> | - | Andrey Zmievski <andrey@ispi.net> | +----------------------------------------------------------------------+ */ @@ -327,21 +326,17 @@ static void _php_session_start(PSLS_D) { pval **ppid; pval **data; - char *p; int send_cookie = 1; int define_sid = 1; int module_number = PS(module_number); int nrand; - int lensess; ELS_FETCH(); if (PS(nr_open_sessions) > 0) return; - lensess = strlen(PS(session_name)); - if(!PS(id) && zend_hash_find(&EG(symbol_table), PS(session_name), - lensess + 1, (void **) &ppid) == SUCCESS) { + strlen(PS(session_name)) + 1, (void **) &ppid) == SUCCESS) { convert_to_string((*ppid)); PS(id) = estrndup((*ppid)->value.str.val, (*ppid)->value.str.len); send_cookie = 0; @@ -352,22 +347,9 @@ static void _php_session_start(PSLS_D) sizeof("HTTP_COOKIE_VARS"), (void **) &data) == SUCCESS && (*data)->type == IS_ARRAY && zend_hash_find((*data)->value.ht, PS(session_name), - lensess + 1, (void **) &ppid) == SUCCESS) { + strlen(PS(session_name)) + 1, (void **) &ppid) == SUCCESS) { define_sid = 0; } - - if(!PS(id) && - zend_hash_find(&EG(symbol_table), "REQUEST_URI", - sizeof("REQUEST_URI"), (void **) &data) == SUCCESS && - (*data)->type == IS_STRING && - (p = strstr((*data)->value.str.val, PS(session_name))) && - p[lensess] == '=') { - char *q; - - p += lensess + 1; - if((q = strpbrk(p, "/?\\"))) - PS(id) = estrndup(p, q - p); - } if(!PS(id)) { PS(id) = _php_create_id(NULL); diff --git a/ext/snmp/config.m4 b/ext/snmp/config.m4 index 1608331b56..c39d77908e 100644 --- a/ext/snmp/config.m4 +++ b/ext/snmp/config.m4 @@ -12,7 +12,6 @@ AC_ARG_WITH(snmp, SNMP_LIBDIR=/usr/local/lib test -d /usr/local/include/ucd-snmp && SNMP_INCDIR=/usr/local/include/ucd-snmp test -d /usr/include/ucd-snmp && SNMP_INCDIR=/usr/include/ucd-snmp - test -d /usr/include/snmp && SNMP_INCDIR=/usr/include/snmp test -f /usr/lib/libsnmp.a && SNMP_LIBDIR=/usr/lib else SNMP_INCDIR=$withval/include diff --git a/ext/standard/base64.c b/ext/standard/base64.c index d0a565fde4..70675d14e3 100644 --- a/ext/standard/base64.c +++ b/ext/standard/base64.c @@ -71,24 +71,8 @@ unsigned char *_php3_base64_encode(const unsigned char *string, int length, int unsigned char *_php3_base64_decode(const unsigned char *string, int length, int *ret_length) { const unsigned char *current = string; int ch, i = 0, j = 0, k; - /* this sucks for threaded environments */ - static short reverse_table[256]; - static int table_built; - unsigned char *result; - - if (++table_built == 1) { - char *chp; - for(ch = 0; ch < 256; ch++) { - chp = strchr(base64_table, ch); - if(chp) { - reverse_table[ch] = chp - base64_table; - } else { - reverse_table[ch] = -1; - } - } - } - result = (unsigned char *)emalloc((length / 4 * 3 + 1) * sizeof(char)); + unsigned char *result = (unsigned char *)emalloc((length / 4 * 3 + 1) * sizeof(char)); if (result == NULL) { return NULL; } @@ -96,8 +80,9 @@ unsigned char *_php3_base64_decode(const unsigned char *string, int length, int /* run through the whole string, converting as we go */ while ((ch = *current++) != '\0') { if (ch == base64_pad) break; - ch = reverse_table[ch]; - if (ch < 0) continue; + ch = (int)strchr(base64_table, ch); + if (ch == 0) continue; + ch -= (int)base64_table; switch(i % 4) { case 0: diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 3f445804a0..4ff386f0cd 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -284,7 +284,6 @@ function_entry basic_functions[] = { PHP_FE(print_r, NULL) {"setcookie", php3_SetCookie, NULL}, {"header", php3_Header, NULL}, - PHP_FE(headers_sent, NULL) PHP_FE(function_exists, NULL) PHP_FE(in_array, NULL) PHP_FE(extract, NULL) @@ -1414,7 +1413,7 @@ static int _php3_array_walk(const void *a) pval retval; CLS_FETCH(); - args[0] = *((pval **)a); + args[0] = (pval *)a; call_user_function(CG(function_table), NULL, php3_array_walk_func_name, &retval, 1, args); return 0; diff --git a/ext/standard/datetime.c b/ext/standard/datetime.c index 99038e0bd5..9be3bc80ae 100644 --- a/ext/standard/datetime.c +++ b/ext/standard/datetime.c @@ -60,8 +60,6 @@ static int phpday_tab[2][12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} }; -#define isleap(year) (((year%4) == 0 && (year%100)!=0) || (year%400)==0) - PHP_FUNCTION(time) { return_value->value.lval = (long) time(NULL); @@ -144,7 +142,7 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm) pval *format, *timestamp; time_t the_time; struct tm *ta; - int i, size = 0, length, h, beat; + int i, size = 0, length, h; char tmp_buff[16]; switch(ARG_COUNT(ht)) { @@ -183,45 +181,33 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm) break; case 'F': /* month, textual, full */ case 'l': /* day (of the week), textual */ - case 'T': /* timezone name */ size += 9; break; - case 'Z': /* timezone offset in seconds */ - size += 6; - break; case 'Y': /* year, numeric, 4 digits */ size += 4; break; case 'M': /* month, textual, 3 letters */ case 'D': /* day, textual, 3 letters */ - case 'z': /* day of the year, 1 to 366 */ + case 'z': /* day of the year */ size += 3; break; case 'y': /* year, numeric, 2 digits */ case 'm': /* month, numeric */ - case 'n': /* month, numeric, no leading zeroes */ case 'd': /* day of the month, numeric */ case 'j': /* day of the month, numeric, no leading zeros */ case 'H': /* hour, numeric, 24 hour format */ case 'h': /* hour, numeric, 12 hour format */ - case 'G': /* hour, numeric, 24 hour format, no leading zeroes */ - case 'g': /* hour, numeric, 12 hour format, no leading zeroes */ case 'i': /* minutes, numeric */ case 's': /* seconds, numeric */ case 'A': /* AM/PM */ case 'a': /* am/pm */ case 'S': /* standard english suffix for the day of the month (e.g. 3rd, 2nd, etc) */ - case 't': /* days in current month */ size += 2; break; case '\\': if(i < format->value.str.len-1) { i++; } - case 'L': /* boolean for leap year */ - case 'B': /* Swatch Beat, 3 digits */ - size += 3; - break; case 'w': /* day of the week, numeric */ default: size++; @@ -275,10 +261,6 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm) sprintf(tmp_buff, "%02d", ta->tm_mon + 1); /* SAFE */ strcat(return_value->value.str.val, tmp_buff); break; - case 'n': /* month, numeric, no leading zeros */ - sprintf(tmp_buff, "%d", ta->tm_mon + 1); /* SAFE */ - strcat(return_value->value.str.val, tmp_buff); - break; case 'd': /* day of the month, numeric */ sprintf(tmp_buff, "%02d", ta->tm_mday); /* SAFE */ strcat(return_value->value.str.val, tmp_buff); @@ -296,15 +278,6 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm) sprintf(tmp_buff, "%02d", h); /* SAFE */ strcat(return_value->value.str.val, tmp_buff); break; - case 'G': /* hour, numeric, 24 hour format, no leading zeros */ - sprintf(tmp_buff, "%d", ta->tm_hour); /* SAFE */ - strcat(return_value->value.str.val, tmp_buff); - break; - case 'g': /* hour, numeric, 12 hour format, no leading zeros */ - h = ta->tm_hour % 12; if (h==0) h = 12; - sprintf(tmp_buff, "%d", h); /* SAFE */ - strcat(return_value->value.str.val, tmp_buff); - break; case 'i': /* minutes, numeric */ sprintf(tmp_buff, "%02d", ta->tm_min); /* SAFE */ strcat(return_value->value.str.val, tmp_buff); @@ -339,40 +312,10 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm) } } break; - case 't': /* days in current month */ - sprintf(tmp_buff, "%2d", phpday_tab[isleap((ta->tm_year+1900))][ta->tm_mon] ); - strcat(return_value->value.str.val, tmp_buff); - break; case 'w': /* day of the week, numeric EXTENSION */ sprintf(tmp_buff, "%01d", ta->tm_wday); /* SAFE */ strcat(return_value->value.str.val, tmp_buff); break; - case 'Z': /* timezone offset in seconds */ -#if HAVE_TM_GMTOFF - sprintf(tmp_buff, "%ld", ta->tm_gmtoff ); -#else - sprintf(tmp_buff, "%ld", timezone); -#endif - strcat(return_value->value.str.val, tmp_buff); - break; - case 'L': /* boolean for leapyear */ - sprintf(tmp_buff, "%d", (isleap((ta->tm_year+1900)) ? 1 : 0 ) ); - strcat(return_value->value.str.val, tmp_buff); - break; - case 'T': /* timezone name */ -#if HAVE_TM_ZONE - strcat(return_value->value.str.val, ta->tm_zone); -#else - strcat(return_value->value.str.val, tzname[0]); -#endif - break; - case 'B': /* Swatch Beat a.k.a. Internet Time */ - beat = (((((long)the_time)-(((long)the_time) - - ((((long)the_time) % 86400) + 3600))) * 10) / 864); - if (beat > 999) beat = 0; - sprintf(tmp_buff, "%03d", beat); /* SAFE */ - strcat(return_value->value.str.val, tmp_buff); - break; default: length = strlen(return_value->value.str.val); return_value->value.str.val[length] = format->value.str.val[i]; diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 87eaddadbf..c1bcb609ed 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -41,20 +41,12 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value) { FILE *fp; - char *buf, *tmp=NULL; - int buflen = 0; + char buf[EXEC_INPUT_BUF], *tmp=NULL; int t, l, ret, output=1; int overflow_limit, lcmd, ldir; char *b, *c, *d=NULL; PLS_FETCH(); - buf = (char*) emalloc(EXEC_INPUT_BUF); - if (!buf) { - php3_error(E_WARNING, "Unable to emalloc %d bytes for exec buffer", EXEC_INPUT_BUF); - return -1; - } - buflen = EXEC_INPUT_BUF; - if (PG(safe_mode)) { lcmd = strlen(cmd); ldir = strlen(PG(safe_mode_exec_dir)); @@ -64,7 +56,6 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value) if (c) *c = '\0'; if (strstr(cmd, "..")) { php3_error(E_WARNING, "No '..' components allowed in path"); - efree(buf); return -1; } d = emalloc(l); @@ -94,7 +85,6 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value) if (!fp) { php3_error(E_WARNING, "Unable to fork [%s]", d); efree(d); - efree(buf); return -1; } } else { /* not safe_mode */ @@ -105,7 +95,6 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value) #endif if (!fp) { php3_error(E_WARNING, "Unable to fork [%s]", cmd); - efree(buf); return -1; } } @@ -117,33 +106,7 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value) } } if (type != 3) { - l=0; - while ( !feof(fp) || l != 0 ) { - l = 0; - /* Read a line or fill the buffer, whichever comes first */ - do { - if ( buflen <= (l+1) ) { - buf = erealloc(buf, buflen + EXEC_INPUT_BUF); - if ( buf == NULL ) { - php3_error(E_WARNING, "Unable to erealloc %d bytes for exec buffer", - buflen + EXEC_INPUT_BUF); - return -1; - } - buflen += EXEC_INPUT_BUF; - } - - if ( fgets(&(buf[l]), buflen - l, fp) == NULL ) { - /* eof */ - break; - } - l += strlen(&(buf[l])); - } while ( (l > 0) && (buf[l-1] != '\n') ); - - if ( feof(fp) && (l == 0) ) { - break; - } - - + while (fgets(buf, EXEC_INPUT_BUF - 1, fp)) { if (type == 1) { SLS_FETCH(); @@ -169,7 +132,7 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value) /* strip trailing whitespaces */ l = strlen(buf); t = l; - while (l-- && isspace((int)buf[l])); + while (l && isspace((int)buf[--l])); if (l < t) { buf[l + 1] = '\0'; } @@ -210,7 +173,6 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value) #endif if (d) efree(d); - efree(buf); return ret; } diff --git a/ext/standard/fsock.c b/ext/standard/fsock.c index cc000f42b4..ab19214dec 100644 --- a/ext/standard/fsock.c +++ b/ext/standard/fsock.c @@ -20,7 +20,6 @@ /* $Id$ */ /* Synced with php3 revision 1.121 1999-06-18 [ssb] */ -/* Synced with php3 revision 1.133 1999-07-21 [sas] */ #include "php.h" #include "php_globals.h" @@ -71,9 +70,6 @@ extern int le_fp; #define FREE_SOCK if(socketd >= 0) close(socketd); efree(sock); if (key) efree(key) -#define SEARCHCR \ - p = memchr(READPTR(sock), '\n', MIN(TOREAD(sock), maxlen - 1)); - #if WIN32|WINNT #define EWOULDBLOCK WSAEWOULDBLOCK #else @@ -237,7 +233,6 @@ static void _php3_fsockopen(INTERNAL_FUNCTION_PARAMETERS, int persistent) { int socketd = -1; struct timeval timeout = { 60, 0 }; unsigned short portno; - unsigned long conv; char *key = NULL; PLS_FETCH(); @@ -247,10 +242,8 @@ static void _php3_fsockopen(INTERNAL_FUNCTION_PARAMETERS, int persistent) { } switch(arg_count) { case 5: - convert_to_double(args[4]); - conv = args[4]->value.dval * 1000000.0; - timeout.tv_sec = conv / 1000000; - timeout.tv_usec = conv % 1000000; + convert_to_long(args[4]); + timeout.tv_sec = args[4]->value.lval; /* fall-through */ case 4: if(!ParameterPassedByReference(ht,4)) { @@ -278,7 +271,7 @@ static void _php3_fsockopen(INTERNAL_FUNCTION_PARAMETERS, int persistent) { if (persistent && _php3_hash_find(&PG(ht_fsock_keys), key, strlen(key) + 1, (void *) &sockp) == SUCCESS) { - FREE_SOCK; + efree(key); *sock = *sockp; RETURN_LONG(php3_list_insert(sock, wsa_fp)); } @@ -362,14 +355,14 @@ static void _php3_fsockopen(INTERNAL_FUNCTION_PARAMETERS, int persistent) { } /* }}} */ -/* {{{ proto int fsockopen(string hostname, int port [, int errno [, string errstr [, double timeout]]]) +/* {{{ proto int fsockopen(string hostname, int port [, int errno [, string errstr]]) Open Internet or Unix domain socket connection */ PHP_FUNCTION(fsockopen) { _php3_fsockopen(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); } /* }}} */ -/* {{{ proto int pfsockopen(string hostname, int port [, int errno [, string errstr [, double timeout]]]) +/* {{{ proto int pfsockopen(string hostname, int port [, int errno [, string errstr]]) Open persistent Internet or Unix domain socket connection */ PHP_FUNCTION(pfsockopen) { @@ -377,7 +370,40 @@ PHP_FUNCTION(pfsockopen) } /* }}} */ -#define CHUNK_SIZE 8192 +/* Known issues with the socket buffering code: + * - does not work reliably with persistent sockets yet + * (buffered data is not persistent) + * - php3_fopen_url_wrapper() is still doing single-byte lookahead/read + */ + +static php3i_sockbuf *_php3_sock_findsock(int socket) +{ + /* FIXME: O(n) could be improved */ + + php3i_sockbuf *buf = NULL, *tmp; + + for(tmp = phpsockbuf; tmp; tmp = tmp->next) + if(tmp->socket == socket) { + buf = tmp; + break; + } + + return buf; +} + +int _php3_sock_eof(int socket) +{ + php3i_sockbuf *sockbuf; + int ret = 0; + + sockbuf = _php3_sock_findsock(socket); + if(sockbuf) { + ret = (sockbuf->writepos - sockbuf->readpos) == 0 ? 1 : 0; + } + return ret; +} + +#define CHUNK_SIZE 2048 #define SOCK_DESTROY(sock) \ if(sock->readbuf) pefree(sock->readbuf, sock->persistent); \ if(sock->prev) sock->prev->next = sock->next; \ @@ -412,12 +438,12 @@ static php3i_sockbuf *_php3_sock_find(int socket) { php3i_sockbuf *buf = NULL, *tmp; - for(tmp = phpsockbuf; tmp; tmp = tmp->next) - if(tmp->socket == socket) { + for (tmp = phpsockbuf; tmp; tmp = tmp->next) { + if (tmp->socket == socket) { buf = tmp; break; } - + } return buf; } @@ -428,8 +454,9 @@ static php3i_sockbuf *_php3_sock_create(int socket) sock = pecalloc(sizeof(*sock), 1, persistent); sock->socket = socket; - if((sock->next = phpsockbuf)) + if ((sock->next = phpsockbuf)) { phpsockbuf->prev = sock; + } sock->persistent = persistent; sock->is_blocked = 1; sock->chunk_size = def_chunk_size; @@ -444,8 +471,9 @@ size_t _php3_sock_set_def_chunk_size(size_t size) old = def_chunk_size; - if(size <= CHUNK_SIZE || size > 0) + if (size <= CHUNK_SIZE || size > 0) { def_chunk_size = size; + } return old; } @@ -456,7 +484,7 @@ int _php3_sock_destroy(int socket) php3i_sockbuf *sock; sock = _php3_sock_find(socket); - if(sock) { + if (sock) { ret = 1; SOCK_DESTROY(sock); } @@ -464,31 +492,24 @@ int _php3_sock_destroy(int socket) return ret; } -#if !defined(WIN32) && !defined(WINNT) -#undef closesocket -#define closesocket close -#endif - -#ifndef HAVE_SHUTDOWN -#undef shutdown -#define shutdown -#endif - -#define SOCK_CLOSE(s) shutdown(s, 0); closesocket(s) - int _php3_sock_close(int socket) { int ret = 0; php3i_sockbuf *sock; sock = _php3_sock_find(socket); - if(sock) { - if(!sock->persistent) { - SOCK_CLOSE(sock->socket); + if (sock) { + if (!sock->persistent) { +#if HAVE_SHUTDOWN + shutdown(sock->socket, 0); +#endif +#if WIN32||WINNT + closesocket(sock->socket); +#else + close(sock->socket); +#endif SOCK_DESTROY(sock); } - } else { - SOCK_CLOSE(socket); } return ret; @@ -503,64 +524,52 @@ static void _php3_sock_wait_for_data(php3i_sockbuf *sock) FD_ZERO(&fdr); FD_SET(sock->socket, &fdr); - while(1) { + while (1) { tfdr = fdr; - if(select(sock->socket + 1, &tfdr, NULL, NULL, NULL) == 1) + if(select(sock->socket + 1, &tfdr, NULL, NULL, NULL) == 1) { break; + } } } -static size_t _php3_sock_read_internal(php3i_sockbuf *sock) +static size_t _php3_sock_read_limited(php3i_sockbuf *sock, int maxread) { char buf[CHUNK_SIZE]; int nr_bytes; size_t nr_read = 0; - - /* For blocking sockets, we wait until there is some - data to read (real data or EOF) - - Otherwise, recv() may time out and return 0 and - therefore sock->eof would be set errornously. - */ - - if(sock->is_blocked) { + if (sock->eof || TOREAD(sock) >= maxread) { + return 0; + } + if (sock->is_blocked) { _php3_sock_wait_for_data(sock); } - /* read at a maximum sock->chunk_size */ nr_bytes = recv(sock->socket, buf, sock->chunk_size, 0); - if(nr_bytes > 0) { - if(sock->writepos + nr_bytes > sock->readbuflen) { + if (nr_bytes > 0) { + if (sock->writepos + nr_bytes > sock->readbuflen) { sock->readbuflen += sock->chunk_size; sock->readbuf = perealloc(sock->readbuf, sock->readbuflen, - sock->persistent); + sock->persistent); } memcpy(WRITEPTR(sock), buf, nr_bytes); sock->writepos += nr_bytes; nr_read = nr_bytes; - } else if(nr_bytes == 0 || (nr_bytes < 0 && errno != EWOULDBLOCK)) { + } else if (nr_bytes == 0 || (nr_bytes < 0 && errno != EWOULDBLOCK)) { sock->eof = 1; } return nr_read; } -static void _php3_sock_read_total(php3i_sockbuf *sock, size_t maxread) -{ - while(!sock->eof && TOREAD(sock) < maxread) { - _php3_sock_read_internal(sock); - } -} - static size_t _php3_sock_read(php3i_sockbuf *sock) { size_t nr_bytes; size_t nr_read = 0; int i; - - for(i = 0; !sock->eof && i < MAX_CHUNKS_PER_READ; i++) { - nr_bytes = _php3_sock_read_internal(sock); + + for (i = 0; !sock->eof && i < MAX_CHUNKS_PER_READ; i++) { + nr_bytes = _php3_sock_read_limited(sock, CHUNK_SIZE); if(nr_bytes == 0) break; nr_read += nr_bytes; } @@ -574,60 +583,64 @@ int _php3_sock_set_blocking(int socket, int mode) SOCK_FIND(sock, socket); old = sock->is_blocked; - + sock->is_blocked = mode; - + return old; } #define SOCK_FIND_AND_READ_MAX(max) \ - SOCK_FIND(sock, socket); \ - if(sock->is_blocked) _php3_sock_read_total(sock, max); else _php3_sock_read(sock) + SOCK_FIND(sock, socket); \ + if(sock->is_blocked) _php3_sock_read_limited(sock, max); else _php3_sock_read(sock) /* {{{ _php3_sock_fgets() */ /* - * FIXME: fgets depends on '\n' as line delimiter + * FIXME: fgets depends on '\n' as line delimiters */ char *_php3_sock_fgets(char *buf, size_t maxlen, int socket) { char *p = NULL; char *ret = NULL; size_t amount = 0; + size_t nr_read; + size_t nr_toread; SOCK_FIND(sock, socket); - SEARCHCR; + if (maxlen < 0) { + return ret; + } - if(!p) { - if(sock->is_blocked) { - while(!p && !sock->eof && TOREAD(sock) < maxlen - 1) { - _php3_sock_read_internal(sock); - SEARCHCR; + if (sock->is_blocked) { + nr_toread = 0; + for (nr_read = 1; !sock->eof && nr_read < maxlen; ) { + nr_read += _php3_sock_read_limited(sock, nr_toread); + if ((p = memchr(READPTR(sock), '\n', TOREAD(sock))) != NULL) { + break; } - } else { - _php3_sock_read(sock); - SEARCHCR; + nr_toread = 512; } + } else { + _php3_sock_read(sock); + p = memchr(READPTR(sock), '\n', MIN(TOREAD(sock), maxlen - 1)); } - - if(p) { + if (p) { amount = (ptrdiff_t) p - (ptrdiff_t) READPTR(sock) + 1; } else { - amount = TOREAD(sock); + amount = MIN(TOREAD(sock), maxlen - 1); } - - amount = MIN(amount, maxlen - 1); - if(amount > 0) { + if (amount > 0) { memcpy(buf, READPTR(sock), amount); sock->readpos += amount; } buf[amount] = '\0'; - - /* signal error only, if we don't return data from this call and + + /* signal error only, if we don't return data from this call and if there is no data to read and if the eof flag is set */ - if(amount || TOREAD(sock) || !sock->eof) + if (amount || TOREAD(sock) || !sock->eof) { ret = buf; + } return ret; } @@ -646,7 +659,7 @@ int _php3_sock_fgetc(int socket) int ret = EOF; SOCK_FIND_AND_READ_MAX(1); - if(TOREAD(sock) > 0) { + if (TOREAD(sock) > 0) { ret = *READPTR(sock); sock->readpos++; } @@ -659,11 +672,9 @@ int _php3_sock_feof(int socket) int ret = 0; SOCK_FIND(sock, socket); - if(!sock->is_blocked) - _php3_sock_read(sock); - - if(!TOREAD(sock) && sock->eof) + if (!TOREAD(sock) && sock->eof) { ret = 1; + } return ret; } @@ -675,11 +686,12 @@ size_t _php3_sock_fread(char *ptr, size_t size, int socket) size_t ret = 0; SOCK_FIND_AND_READ_MAX(size); - if(size < 0) + if (size < 0) { return ret; + } ret = MIN(TOREAD(sock), size); - if(ret) { + if (ret) { memcpy(ptr, READPTR(sock), ret); sock->readpos += ret; } diff --git a/ext/standard/head.c b/ext/standard/head.c index cfc6930f7d..f1bd0dcdc8 100644 --- a/ext/standard/head.c +++ b/ext/standard/head.c @@ -24,7 +24,6 @@ #include "main.h" #include "head.h" #include "post.h" -#include "SAPI.h" #ifdef TM_IN_SYS_TIME #include <sys/time.h> #else @@ -557,16 +556,6 @@ int php3_headers_unsent(void) } } -PHP_FUNCTION(headers_sent) -{ - SLS_FETCH(); - - if (SG(headers_sent)) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} function_entry php3_header_functions[] = { {NULL, NULL, NULL} diff --git a/ext/standard/head.h b/ext/standard/head.h index a8096ecaca..977fc83345 100644 --- a/ext/standard/head.h +++ b/ext/standard/head.h @@ -55,7 +55,6 @@ extern php3_module_entry php3_header_module_entry; extern int php3_init_head(INIT_FUNC_ARGS); PHP_FUNCTION(Header); PHP_FUNCTION(SetCookie); -PHP_FUNCTION(headers_sent); void php4i_add_header_information(char *header_information, uint header_length); diff --git a/ext/standard/info.c b/ext/standard/info.c index eb87281301..fe4e55120e 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -310,7 +310,6 @@ void php_print_credits(int flag) CREDIT_LINE("Sybase", "Zeev Suraski"); CREDIT_LINE("System V Shared Memory", "Christian Cartus"); CREDIT_LINE("System V Semaphores", "Tom May"); - CREDIT_LINE("WDDX", "Andrey Zmievski"); CREDIT_LINE("XML", "Stig Bakken"); CREDIT_LINE("Yellow Pages", "Stephanie Wehner"); CREDIT_LINE("Zlib", "Rasmus Lerdorf, Stefan Ruhrich"); diff --git a/ext/standard/string.c b/ext/standard/string.c index 1836e2a4d6..e645cda6f6 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1344,6 +1344,11 @@ PHPAPI void _php3_char_to_str(char *str,uint len,char from,char *to,int to_len,p *target = 0; } +#if 0 +/* + * this is a binary safe equivalent to strnstr + * note that we don't check for the end in str_to_str but here + */ static inline char * _php3_memnstr(char *haystack, char *needle, int needle_len, char *end) @@ -1409,6 +1414,55 @@ finish: return new; } +#else + +static char *_php3_memstr(char *s, char *c, size_t n, size_t m) +{ + char *p; + + for(p = s; (p - s) < n; p++) + if(memcmp(p, c, m) == 0) + return p; + return NULL; +} + +#define ATTCHSTR(st, sz) \ + nl += sz; \ + n = erealloc(n, nl + 1); \ + memcpy(n + no, st, sz); \ + no += sz + + +PHPAPI char *_php3_str_to_str(char *a, int al, char *b, int bl, char *c, int cl, + int *newlen) +{ + char *n = NULL, *p, *q; + int nl = 0; + int no = 0; + + /* run through all occurences of b in a */ + for(p = q = a; (p = _php3_memstr(p, b, al - (p - a), bl)); q = p) { + /* attach everything between the previous occ. and this one */ + ATTCHSTR(q, p - q); + /* attach the replacement string c */ + ATTCHSTR(c, cl); + /* jump over string b in a */ + p += bl; + } + + /* anything left over ? */ + if((al - (q - a)) > 0) { + ATTCHSTR(q, al - (q - a)); + } + + if(newlen) *newlen = nl; + n[nl] = '\0'; + + return n; +} + +#undef ATTCHSTR +#endif /* {{{ proto string str_replace(string needle, string str, string haystack) Replace all occurrences of needle in haystack with str */ diff --git a/ext/sybase/sybase-ct.c b/ext/sybase/sybase-ct.c index aa1d992dae..cf50de9f29 100644 --- a/ext/sybase/sybase-ct.c +++ b/ext/sybase/sybase-ct.c @@ -20,6 +20,9 @@ /* $Id$ */ +#ifndef MSVC5 +#include "php_config.h" +#endif #include "php.h" #include "php3_sybase-ct.h" #include "ext/standard/php3_standard.h" @@ -602,8 +605,11 @@ static void php3_sybct_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) static int php3_sybct_get_default_link(INTERNAL_FUNCTION_PARAMETERS) { if (php3_sybct_module.default_link==-1) { /* no link opened yet, implicitly open one */ - ht = 0; - php3_sybct_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); + HashTable dummy; + + _php3_hash_init(&dummy,0,NULL,NULL,0); + php3_sybct_do_connect(&dummy,return_value,list,plist,0); + _php3_hash_destroy(&dummy); } return php3_sybct_module.default_link; } @@ -1309,7 +1315,7 @@ static PHP_FUNCTION(sybct_fetch_hash) tmp->value.str.val = _php3_addslashes(tmp->value.str.val,tmp->value.str.len,&tmp->value.str.len,1); } _php3_hash_index_update(return_value->value.ht, i, (void *) &tmp, sizeof(pval *), NULL); - _php3_hash_update(return_value->value.ht, result->fields[i].name, strlen(result->fields[i].name)+1, (void *) &tmp, sizeof(pval *), NULL); + _php3_hash_update(return_value->value.ht, result->fields[i].name, strlen(result->fields[i].name)+1, (void *) &tmp, sizeof(pval *) NULL); } result->cur_row++; } diff --git a/ext/sybase/sybase.c b/ext/sybase/sybase.c index 0b50958ee8..760335d21e 100644 --- a/ext/sybase/sybase.c +++ b/ext/sybase/sybase.c @@ -473,7 +473,8 @@ static void php3_sybase_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) static int php3_sybase_get_default_link(INTERNAL_FUNCTION_PARAMETERS) { if (php3_sybase_module.default_link==-1) { /* no link opened yet, implicitly open one */ - ht = 0; + int ht; + php3_sybase_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0); } return php3_sybase_module.default_link; diff --git a/ext/wddx/Makefile.am b/ext/wddx/Makefile.am deleted file mode 100644 index 435d1604b1..0000000000 --- a/ext/wddx/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -# $Id$ - -INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend -noinst_LIBRARIES=libphpext_wddx.a -libphpext_wddx_a_SOURCES=wddx.c - diff --git a/ext/wddx/config.h.stub b/ext/wddx/config.h.stub deleted file mode 100644 index 9dedf15dff..0000000000 --- a/ext/wddx/config.h.stub +++ /dev/null @@ -1,2 +0,0 @@ -/* define if you want to use the wddx extension */ -#define HAVE_WDDX 0 diff --git a/ext/wddx/config.m4 b/ext/wddx/config.m4 deleted file mode 100644 index 2b8078f596..0000000000 --- a/ext/wddx/config.m4 +++ /dev/null @@ -1,20 +0,0 @@ -dnl $Id$ -dnl config.m4 for extension wddx - -AC_MSG_CHECKING(whether to include WDDX support) -AC_ARG_WITH(wddx, -[ --with-wddx Include WDDX support],[ - if test "$withval" = "yes"; then - if test "${with_xml+set}" != "set" -o "$with_xml" = "no"; then - AC_MSG_ERROR(WDDX requires --with-xml) - else - AC_DEFINE(HAVE_WDDX, 1) - AC_MSG_RESULT(yes) - PHP_EXTENSION(wddx) - fi - else - AC_MSG_RESULT(no) - fi -],[ - AC_MSG_RESULT(no) -]) diff --git a/ext/wddx/php_wddx.h b/ext/wddx/php_wddx.h deleted file mode 100644 index efc19ef349..0000000000 --- a/ext/wddx/php_wddx.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP HTML Embedded Scripting Language Version 3.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-1999 PHP Development Team (See Credits file) | - +----------------------------------------------------------------------+ - | This program is free software; you can redistribute it and/or modify | - | it under the terms of one of the following licenses: | - | | - | A) the GNU General Public License as published by the Free Software | - | Foundation; either version 2 of the License, or (at your option) | - | any later version. | - | | - | B) the PHP License as published by the PHP Development Team and | - | included in the distribution in the file: LICENSE | - | | - | This program is distributed in the hope that it will be useful, | - | but WITHOUT ANY WARRANTY; without even the implied warranty of | - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | - | GNU General Public License for more details. | - | | - | You should have received a copy of both licenses referred to here. | - | If you did not, or have any questions about PHP licensing, please | - | contact core@php.net. | - +----------------------------------------------------------------------+ - | Authors: Andrey Zmievski <andrey@ispi.net> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifndef _WDDX_H -#define _WDDX_H - -#if HAVE_WDDX - -#include "xml/xmlparse.h" - -extern int php_minit_wddx(INIT_FUNC_ARGS); - -extern zend_module_entry wddx_module_entry; -#define wddx_module_ptr &wddx_module_entry - -PHP_FUNCTION(wddx_serialize_value); -PHP_FUNCTION(wddx_serialize_vars); -PHP_FUNCTION(wddx_packet_start); -PHP_FUNCTION(wddx_packet_end); -PHP_FUNCTION(wddx_add_vars); -PHP_FUNCTION(wddx_deserialize); - -#else - -#define wddx_module_ptr NULL - -#endif /* HAVE_WDDX */ - -#define phpext_wddx_ptr wddx_module_ptr - -#endif /* !_WDDX_H */ diff --git a/ext/wddx/setup.stub b/ext/wddx/setup.stub deleted file mode 100644 index 30500bf406..0000000000 --- a/ext/wddx/setup.stub +++ /dev/null @@ -1,6 +0,0 @@ -# $Source$ -# $Id$ - -define_option with-wddx 'wddx support?' yesnodir no \ -' Whether to build the wddx extension.' - diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c deleted file mode 100644 index 3fbc211bbb..0000000000 --- a/ext/wddx/wddx.c +++ /dev/null @@ -1,842 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP HTML Embedded Scripting Language Version 3.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-1999 PHP Development Team (See Credits file) | - +----------------------------------------------------------------------+ - | This program is free software; you can redistribute it and/or modify | - | it under the terms of one of the following licenses: | - | | - | A) the GNU General Public License as published by the Free Software | - | Foundation; either version 2 of the License, or (at your option) | - | any later version. | - | | - | B) the PHP License as published by the PHP Development Team and | - | included in the distribution in the file: LICENSE | - | | - | This program is distributed in the hope that it will be useful, | - | but WITHOUT ANY WARRANTY; without even the implied warranty of | - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | - | GNU General Public License for more details. | - | | - | You should have received a copy of both licenses referred to here. | - | If you did not, or have any questions about PHP licensing, please | - | contact core@php.net. | - +----------------------------------------------------------------------+ - | Authors: Andrey Zmievski <andrey@ispi.net> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#include "php.h" -#include "php_wddx.h" - -#if HAVE_WDDX -#include "dlist.h" - -#define WDDX_PACKET_S "<wddxPacket version='0.9'>" -#define WDDX_PACKET_E "</wddxPacket>" -#define WDDX_HEADER "<header/>" -#define WDDX_HEADER_COMMENT "<header comment='%s'/>" -#define WDDX_DATA_S "<data>" -#define WDDX_DATA_E "</data>" -#define WDDX_STRING_S "<string>" -#define WDDX_STRING_E "</string>" -#define WDDX_CHAR "<char code='%02X'/>" -#define WDDX_NUMBER "<number>%s</number>" -#define WDDX_ARRAY_S "<array length='%d'>" -#define WDDX_ARRAY_E "</array>" -#define WDDX_VAR_S "<var name='%s'>" -#define WDDX_VAR_E "</var>" -#define WDDX_STRUCT_S "<struct>" -#define WDDX_STRUCT_E "</struct>" - -#define WDDX_BUF_LEN 256 - -#define EL_STRING "string" -#define EL_CHAR "char" -#define EL_CHAR_CODE "code" -#define EL_NUMBER "number" -#define EL_ARRAY "array" -#define EL_STRUCT "struct" -#define EL_VAR "var" -#define EL_VAR_NAME "name" -#define EL_PACKET "wddxPacket" -#define EL_VERSION "version" - - -static int le_wddx; - -typedef struct { - DLIST *packet_head; - int packet_length; -} wddx_packet; - -typedef struct { - zval *data; - enum { - ST_STRING, - ST_NUMBER, - ST_ARRAY, - ST_STRUCT - } type; - char *varname; -} st_entry; - -typedef struct { - int top, max; - char *varname; - void **elements; -} wddx_stack; - - -/* {{{ function prototypes */ -static void _php_wddx_serialize_var(wddx_packet *packet, zval *var, char *name); -static void _php_wddx_process_data(void *user_data, const char *s, int len); -/* }}} */ - - -/* {{{ module definition structures */ - -function_entry wddx_functions[] = { - PHP_FE(wddx_serialize_value, NULL) - PHP_FE(wddx_serialize_vars, NULL) - PHP_FE(wddx_packet_start, NULL) - PHP_FE(wddx_packet_end, NULL) - PHP_FE(wddx_add_vars, NULL) - PHP_FE(wddx_deserialize, NULL) - {NULL, NULL, NULL} -}; - -zend_module_entry wddx_module_entry = { - "WDDX_A", wddx_functions, php_minit_wddx, NULL, NULL, NULL, NULL, STANDARD_MODULE_PROPERTIES -}; - -/* }}} */ - - -/* {{{ int wddx_stack_init(wddx_stack *stack) */ -static int wddx_stack_init(wddx_stack *stack) -{ - stack->top = 0; - stack->elements = (void **) emalloc(sizeof(void **) * STACK_BLOCK_SIZE); - if (!stack->elements) { - return FAILURE; - } else { - stack->max = STACK_BLOCK_SIZE; - stack->varname = NULL; - return SUCCESS; - } -} -/* }}} */ - - -/* {{{ int wddx_stack_push(wddx_stack *stack, void *element, int size) */ -static int wddx_stack_push(wddx_stack *stack, void *element, int size) -{ - if (stack->top >= stack->max) { /* we need to allocate more memory */ - stack->elements = (void **) erealloc(stack->elements, - (sizeof(void **) * (stack->max += STACK_BLOCK_SIZE))); - if (!stack->elements) { - return FAILURE; - } - } - stack->elements[stack->top] = (void *) emalloc(size); - memcpy(stack->elements[stack->top], element, size); - return stack->top++; -} -/* }}} */ - - -/* {{{ int wddx_stack_top(wddx_stack *stack, void **element) */ -static int wddx_stack_top(wddx_stack *stack, void **element) -{ - if (stack->top > 0) { - *element = stack->elements[stack->top - 1]; - return SUCCESS; - } else { - *element = NULL; - return FAILURE; - } -} -/* }}} */ - - -/* {{{ int wddx_stack_is_empty(wddx_stack *stack) */ -static int wddx_stack_is_empty(wddx_stack *stack) -{ - if (stack->top == 0) { - return 1; - } else { - return 0; - } -} -/* }}} */ - - -/* {{{ int wddx_stack_destroy(wddx_stack *stack) */ -static int wddx_stack_destroy(wddx_stack *stack) -{ - register int i; - - if (stack->elements) { - for (i = 0; i < stack->top; i++) { - if (((st_entry *)stack->elements[i])->data) - { - zval_dtor(((st_entry *)stack->elements[i])->data); - efree(((st_entry *)stack->elements[i])->data); - } - efree(stack->elements[i]); - } - efree(stack->elements); - } - return SUCCESS; -} -/* }}} */ - - -/* {{{ _php_free_packet_chunk */ -static void _php_free_packet_chunk(char **chunk_ptr) -{ - if ((*chunk_ptr)) - efree((*chunk_ptr)); -} -/* }}} */ - - -/* {{{ _php_wddx_destructor */ -static void _php_wddx_destructor(wddx_packet *packet) -{ - dlst_kill(packet->packet_head, (void (*)(void *))_php_free_packet_chunk); - efree(packet); -} -/* }}} */ - - -/* {{{ php_minit_wddx */ -int php_minit_wddx(INIT_FUNC_ARGS) -{ - le_wddx = register_list_destructors(_php_wddx_destructor, NULL); - - return SUCCESS; -} -/* }}} */ - - -/* {{{ _php_wddx_add_chunk */ -static void _php_wddx_add_chunk(wddx_packet *packet, char *str) -{ - char **chunk_ptr; - - chunk_ptr = (char**)dlst_newnode(sizeof(char *)); - (*chunk_ptr) = estrdup(str); - dlst_insertafter(packet->packet_head, chunk_ptr, PHP_DLST_TAIL(packet->packet_head)); - packet->packet_length += strlen(str); -} -/* }}} */ - - -/* {{{ _php_wddx_gather */ -static char* _php_wddx_gather(wddx_packet *packet) -{ - char **chunk; - char *buf; - - buf = (char *)emalloc(packet->packet_length+1); - buf[0] = '\0'; - for(chunk=dlst_first(packet->packet_head); - chunk!=NULL; - chunk = dlst_next(chunk)) { - strcat(buf, *chunk); - } - - return buf; -} -/* }}} */ - - -/* {{{ void _php_wddx_packet_start */ -static void _php_wddx_packet_start(wddx_packet *packet, char *comment) -{ - char tmp_buf[WDDX_BUF_LEN]; - - _php_wddx_add_chunk(packet, WDDX_PACKET_S); - if (comment) - { - sprintf(tmp_buf, WDDX_HEADER_COMMENT, comment); - _php_wddx_add_chunk(packet, tmp_buf); - } - else - _php_wddx_add_chunk(packet, WDDX_HEADER); - _php_wddx_add_chunk(packet, WDDX_DATA_S); -} -/* }}} */ - - -/* {{{ int _php_wddx_packet_end */ -static void _php_wddx_packet_end(wddx_packet *packet) -{ - _php_wddx_add_chunk(packet, WDDX_DATA_E); - _php_wddx_add_chunk(packet, WDDX_PACKET_E); -} -/* }}} */ - - -/* {{{ void _php_wddx_serialize_var(wddx_packet *packet, zval *var) */ -static void _php_wddx_serialize_string(wddx_packet *packet, zval *var) -{ - char *buf, - *c, - control_buf[WDDX_BUF_LEN]; - int i; - - _php_wddx_add_chunk(packet, WDDX_STRING_S); - - i = 0; - buf = (char *)emalloc(var->value.str.len); - for(c=var->value.str.val; *c!='\0'; c++) - { - if (iscntrl((int)*c)) - { - if (*buf) - { - buf[i] = '\0'; - _php_wddx_add_chunk(packet, buf); - i = 0; - buf[i] = '\0'; - } - sprintf(control_buf, WDDX_CHAR, *c); - _php_wddx_add_chunk(packet, control_buf); - } - else - buf[i++] = *c; - } - buf[i] = '\0'; - if (*buf) - _php_wddx_add_chunk(packet, buf); - efree(buf); - - _php_wddx_add_chunk(packet, WDDX_STRING_E); -} -/* }}} */ - - -/* {{{ void _php_wddx_serialize_number(wddx_packet *packet, zval *var) */ -static void _php_wddx_serialize_number(wddx_packet *packet, zval *var) -{ - char tmp_buf[WDDX_BUF_LEN]; - - convert_to_string(var); - sprintf(tmp_buf, WDDX_NUMBER, var->value.str.val); - _php_wddx_add_chunk(packet, tmp_buf); -} -/* }}} */ - - -/* {{{ void _php_wddx_serialize_hash(wddx_packet *packet, zval *var) */ -static void _php_wddx_serialize_hash(wddx_packet *packet, zval *var) -{ - zval **ent; - char *key; - int hash_type, ent_type; - ulong idx; - char tmp_buf[WDDX_BUF_LEN]; - - zend_hash_internal_pointer_reset(var->value.ht); - - hash_type = zend_hash_get_current_key(var->value.ht, &key, &idx); - - if (hash_type == HASH_KEY_IS_STRING) { - _php_wddx_add_chunk(packet, WDDX_STRUCT_S); - efree(key); - } else { - sprintf(tmp_buf, WDDX_ARRAY_S, zend_hash_num_elements(var->value.ht)); - _php_wddx_add_chunk(packet, tmp_buf); - } - - while(zend_hash_get_current_data(var->value.ht, (void**)&ent) == SUCCESS) { - if (hash_type == HASH_KEY_IS_STRING) { - ent_type = zend_hash_get_current_key(var->value.ht, &key, &idx); - - if (ent_type == HASH_KEY_IS_STRING) { - _php_wddx_serialize_var(packet, *ent, key); - efree(key); - } else { - sprintf(tmp_buf, "%ld", idx); - _php_wddx_serialize_var(packet, *ent, tmp_buf); - } - } else - _php_wddx_serialize_var(packet, *ent, NULL); - - zend_hash_move_forward(var->value.ht); - } - - if (hash_type == HASH_KEY_IS_STRING) - _php_wddx_add_chunk(packet, WDDX_STRUCT_E); - else - _php_wddx_add_chunk(packet, WDDX_ARRAY_E); -} -/* }}} */ - - -/* {{{ void _php_wddx_serialize_var(wddx_packet *packet, zval *var, char *name) */ -static void _php_wddx_serialize_var(wddx_packet *packet, zval *var, char *name) -{ - char tmp_buf[WDDX_BUF_LEN]; - - if (name) { - sprintf(tmp_buf, WDDX_VAR_S, name); - _php_wddx_add_chunk(packet, tmp_buf); - } - - switch(var->type) { - case IS_STRING: - _php_wddx_serialize_string(packet, var); - break; - - case IS_LONG: - case IS_DOUBLE: - _php_wddx_serialize_number(packet, var); - break; - - case IS_ARRAY: - case IS_OBJECT: - _php_wddx_serialize_hash(packet, var); - break; - } - - if (name) { - _php_wddx_add_chunk(packet, WDDX_VAR_E); - } -} -/* }}} */ - - -/* {{{ void _php_wddx_add_var(wddx_packet *packet, zval *name_var) */ -static void _php_wddx_add_var(wddx_packet *packet, zval *name_var) -{ - zval **val; - ELS_FETCH(); - - if (name_var->type & IS_STRING) - { - if (zend_hash_find(EG(active_symbol_table), name_var->value.str.val, - name_var->value.str.len+1, (void**)&val) != FAILURE) { - _php_wddx_serialize_var(packet, *val, name_var->value.str.val); - } - } - else if (name_var->type & IS_ARRAY) - { - zend_hash_internal_pointer_reset(name_var->value.ht); - - while(zend_hash_get_current_data(name_var->value.ht, (void**)&val) == SUCCESS) { - _php_wddx_add_var(packet, *val); - - zend_hash_move_forward(name_var->value.ht); - } - } -} -/* }}} */ - - -/* {{{ void _php_wddx_push_element(void *user_data, const char *name, const char **atts) */ -static void _php_wddx_push_element(void *user_data, const char *name, const char **atts) -{ - st_entry ent; - wddx_stack *stack = (wddx_stack *)user_data; - - if (!strcmp(name, EL_PACKET)) { - int i; - - for (i=0; atts[i]; i++) { - if (!strcmp(atts[i], EL_VERSION)) { - } - } - } else if (!strcmp(name, EL_STRING)) { - ent.type = ST_STRING; - if (stack->varname) { - ent.varname = estrdup(stack->varname); - efree(stack->varname); - stack->varname = NULL; - } else - ent.varname = NULL; - - ent.data = (zval *)emalloc(sizeof(zval)); - ent.data->value.str.len = 0; - INIT_PZVAL(ent.data); - wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry)); - } else if (!strcmp(name, EL_CHAR)) { - int i; - char tmp_buf[2]; - - for (i=0; atts[i]; i++) { - if (!strcmp(atts[i], EL_CHAR_CODE) && atts[i+1]) { - sprintf(tmp_buf, "%c", (char)strtol(atts[i+1], NULL, 16)); - _php_wddx_process_data(user_data, tmp_buf, strlen(tmp_buf)); - } - } - } else if (!strcmp(name, EL_NUMBER)) { - ent.type = ST_NUMBER; - if (stack->varname) { - ent.varname = estrdup(stack->varname); - efree(stack->varname); - stack->varname = NULL; - } else - ent.varname = NULL; - - ent.data = (zval *)emalloc(sizeof(zval)); - INIT_PZVAL(ent.data); - wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry)); - } else if (!strcmp(name, EL_ARRAY)) { - ent.type = ST_ARRAY; - if (stack->varname) { - ent.varname = estrdup(stack->varname); - efree(stack->varname); - stack->varname = NULL; - } else - ent.varname = NULL; - - ent.data = (zval *)emalloc(sizeof(zval)); - array_init(ent.data); - INIT_PZVAL(ent.data); - wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry)); - } else if (!strcmp(name, EL_STRUCT)) { - ent.type = ST_STRUCT; - if (stack->varname) { - ent.varname = estrdup(stack->varname); - efree(stack->varname); - stack->varname = NULL; - } else - ent.varname = NULL; - - ent.data = (zval *)emalloc(sizeof(zval)); - array_init(ent.data); - INIT_PZVAL(ent.data); - wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry)); - } else if (!strcmp(name, EL_VAR)) { - int i; - - for (i=0; atts[i]; i++) { - if (!strcmp(atts[i], EL_VAR_NAME) && atts[i+1]) { - stack->varname = estrdup(atts[i+1]); - } - } - } - -} -/* }}} */ - - -/* {{{ void _php_wddx_pop_element(void *user_data, const char *name) */ -static void _php_wddx_pop_element(void *user_data, const char *name) -{ - st_entry *ent1, *ent2; - wddx_stack *stack = (wddx_stack *)user_data; - - if (!strcmp(name, EL_STRING) || !strcmp(name, EL_NUMBER) || - !strcmp(name, EL_ARRAY) || !strcmp(name, EL_STRUCT)) { - if (stack->top > 1) { - wddx_stack_top(stack, (void**)&ent1); - stack->top--; - wddx_stack_top(stack, (void**)&ent2); - if (ent2->data->type == IS_ARRAY) { - if (ent1->varname) { - zend_hash_update(ent2->data->value.ht, - ent1->varname, strlen(ent1->varname)+1, - &ent1->data, sizeof(zval *), NULL); - efree(ent1->varname); - } else { - zend_hash_next_index_insert(ent2->data->value.ht, - &ent1->data, - sizeof(zval *), NULL); - } - } - efree(ent1); - } - } -} -/* }}} */ - - -/* {{{ void _php_wddx_process_data(void *user_data, const char *s, int len) */ -static void _php_wddx_process_data(void *user_data, const char *s, int len) -{ - st_entry *ent; - wddx_stack *stack = (wddx_stack *)user_data; - - if (!wddx_stack_is_empty(stack)) { - wddx_stack_top(stack, (void**)&ent); - switch (ent->type) { - case ST_STRING: - ent->data->type = IS_STRING; - if (ent->data->value.str.len == 0) { - ent->data->value.str.val = estrndup(s, len); - ent->data->value.str.len = len; - } else { - ent->data->value.str.val = erealloc(ent->data->value.str.val, - ent->data->value.str.len + len + 1); - strncpy(ent->data->value.str.val+ent->data->value.str.len, s, len); - ent->data->value.str.len += len; - ent->data->value.str.val[ent->data->value.str.len] = '\0'; - } - break; - - case ST_NUMBER: - ent->data->type = IS_STRING; - ent->data->value.str.len = len; - ent->data->value.str.val = estrndup(s, len); - convert_scalar_to_number(ent->data); - break; - - default: - break; - } - } -} -/* }}} */ - - -/* {{{ void _php_wddx_deserialize(zval *packet, zval *return_value) */ -static void _php_wddx_deserialize(zval *packet, zval *return_value) -{ - wddx_stack stack; - XML_Parser parser; - st_entry *ent; - - wddx_stack_init(&stack); - parser = XML_ParserCreate(NULL); - - XML_SetUserData(parser, &stack); - XML_SetElementHandler(parser, _php_wddx_push_element, _php_wddx_pop_element); - XML_SetCharacterDataHandler(parser, _php_wddx_process_data); - - XML_Parse(parser, packet->value.str.val, packet->value.str.len, 1); - - XML_ParserFree(parser); - - wddx_stack_top(&stack, (void**)&ent); - *return_value = *(ent->data); - zval_copy_ctor(return_value); - - wddx_stack_destroy(&stack); -} -/* }}} */ - - -/* {{{ proto string wddx_serialize_value(mixed var [, string comment ]) - Creates a new packet and serializes the given value */ -PHP_FUNCTION(wddx_serialize_value) -{ - int argc; - zval *var, - *comment; - wddx_packet *packet; - char *buf; - - argc = ARG_COUNT(ht); - if(argc < 1 || argc > 2 || getParameters(ht, argc, &var, &comment) == FAILURE) { - WRONG_PARAM_COUNT; - } - - packet = emalloc(sizeof(wddx_packet)); - if (!packet) { - zend_error(E_WARNING, "Unable to allocate memory in php_wddx_packet_start"); - RETURN_FALSE; - } - - packet->packet_head = dlst_init(); - packet->packet_length = 0; - - if (argc == 2) - { - convert_to_string(comment); - _php_wddx_packet_start(packet, comment->value.str.val); - } - else - _php_wddx_packet_start(packet, NULL); - - _php_wddx_serialize_var(packet, var, NULL); - _php_wddx_packet_end(packet); - buf = _php_wddx_gather(packet); - _php_wddx_destructor(packet); - - RETURN_STRING(buf, 0); -} -/* }}} */ - - -/* {{{ proto string wddx_serialize_vars(. . .) - Creates a new packet and serializes given variables into a struct */ -PHP_FUNCTION(wddx_serialize_vars) -{ - int argc, i; - wddx_packet *packet; - zval **args; - char *buf; - - argc = ARG_COUNT(ht); - /* Allocate arguments array and get the arguments, checking for errors. */ - args = (zval **)emalloc(argc * sizeof(zval *)); - if (getParametersArray(ht, argc, args) == FAILURE) { - efree(args); - WRONG_PARAM_COUNT; - } - - packet = emalloc(sizeof(wddx_packet)); - if (!packet) { - zend_error(E_WARNING, "Unable to allocate memory in php_wddx_packet_start"); - RETURN_FALSE; - } - - packet->packet_head = dlst_init(); - packet->packet_length = 0; - - _php_wddx_packet_start(packet, NULL); - _php_wddx_add_chunk(packet, WDDX_STRUCT_S); - - for (i=0; i<argc; i++) { - _php_wddx_add_var(packet, args[i]); - } - - _php_wddx_add_chunk(packet, WDDX_STRUCT_E); - _php_wddx_packet_end(packet); - buf = _php_wddx_gather(packet); - _php_wddx_destructor(packet); - - efree(args); - - RETURN_STRING(buf, 0); -} -/* }}} */ - - -/* {{{ proto int wddx_packet_start([ string comment ]) - Starts a WDDX packet with optional comment and returns the packet id */ -PHP_FUNCTION(wddx_packet_start) -{ - int argc; - zval *comment; - wddx_packet *packet; - - comment = NULL; - argc = ARG_COUNT(ht); - - if (argc>1 || (argc==1 && getParameters(ht, 1, &comment)==FAILURE)) { - WRONG_PARAM_COUNT; - } - - packet = emalloc(sizeof(wddx_packet)); - if (!packet) { - zend_error(E_WARNING, "Unable to allocate memory in php_wddx_packet_start"); - RETURN_FALSE; - } - - packet->packet_head = dlst_init(); - packet->packet_length = 0; - - if (argc == 1) { - convert_to_string(comment); - _php_wddx_packet_start(packet, comment->value.str.val); - } - else - _php_wddx_packet_start(packet, NULL); - - _php_wddx_add_chunk(packet, WDDX_STRUCT_S); - - RETURN_LONG(zend_list_insert(packet, le_wddx)); -} -/* }}} */ - - -/* {{{ proto string wddx_packet_end(int packet_id) - Ends specified WDDX packet and returns the string containing the packet */ -PHP_FUNCTION(wddx_packet_end) -{ - zval *packet_id; - char *buf; - wddx_packet *packet; - int type, id; - - if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &packet_id)==FAILURE) { - WRONG_PARAM_COUNT; - } - - convert_to_long(packet_id); - id = packet_id->value.lval; - packet = zend_list_find(id, &type); - if (type!=le_wddx) { - zend_error(E_WARNING, "%d is not a valid WDDX packet id", id); - RETURN_FALSE; - } - - _php_wddx_add_chunk(packet, WDDX_STRUCT_E); - - _php_wddx_packet_end(packet); - - buf = _php_wddx_gather(packet); - - zend_list_delete(id); - - RETURN_STRING(buf, 0); -} -/* }}} */ - - -/* {{{ proto int wddx_add_vars(int packet_id, . . .) - Serializes given variables and adds them to packet given by packet_id */ -PHP_FUNCTION(wddx_add_vars) -{ - int argc, type, id, i; - zval **args; - zval *packet_id; - wddx_packet *packet; - - argc = ARG_COUNT(ht); - if (argc < 2) { - WRONG_PARAM_COUNT; - } - - /* Allocate arguments array and get the arguments, checking for errors. */ - args = (zval **)emalloc(argc * sizeof(zval *)); - if (getParametersArray(ht, argc, args) == FAILURE) { - efree(args); - WRONG_PARAM_COUNT; - } - - packet_id = args[0]; - - convert_to_long(packet_id); - id = packet_id->value.lval; - packet = zend_list_find(id, &type); - if (type!=le_wddx) { - zend_error(E_WARNING, "%d is not a valid WDDX packet id", id); - RETURN_FALSE; - } - - for (i=1; i<argc; i++) { - _php_wddx_add_var(packet, args[i]); - } - - efree(args); - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto mixed wddx_deserialized(string packet) - Deserializes given packet and returns a PHP value */ -PHP_FUNCTION(wddx_deserialize) -{ - zval *packet; - - if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &packet) == FAILURE) { - WRONG_PARAM_COUNT; - } - - _php_wddx_deserialize(packet, return_value); -} -/* }}} */ - - -#endif /* HAVE_LIBEXPAT */ diff --git a/ext/xml/Makefile.am b/ext/xml/Makefile.am index 9b6e9cdec4..c4f9f526f3 100644 --- a/ext/xml/Makefile.am +++ b/ext/xml/Makefile.am @@ -1,12 +1,6 @@ # $Id$ -phplibdir=$(libdir)/php - -SRC=xml.c -INCLUDES=@INCLUDES@ @XML_INCLUDE@ -I@top_srcdir@ -I@top_srcdir@/libzend +INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend noinst_LIBRARIES=libphpext_xml.a -phplib_LTLIBRARIES=libphpext_xml.la -libphpext_xml_a_SOURCES=$(SRC) -libphpext_xml_la_SOURCES=$(SRC) -libphpext_xml_la_LIBADD=@XML_LIBS@ -EXTRA_LIBS= +libphpext_xml_a_SOURCES=xml.c + diff --git a/ext/xml/config.m4 b/ext/xml/config.m4 index 787ee3465d..c4b871107d 100644 --- a/ext/xml/config.m4 +++ b/ext/xml/config.m4 @@ -1,51 +1,24 @@ -# $Source$ -# $Id$ +dnl $Id$ AC_MSG_CHECKING(for XML support) AC_ARG_WITH(xml, [ --with-xml Include XML support],[ - case $withval in - shared) - shared=yes - withval=yes - ;; - shared,*) - shared=yes - withval=`echo $withval | sed -e 's/^shared,//'` - ;; - *) - shared=no - ;; - esac if test "$withval" != "no"; then - if test "$shared" = "yes"; then - AC_MSG_RESULT([yes (shared)]) - else - AC_MSG_RESULT([yes (static)]) - fi if test "$withval" = "yes"; then - test -d /usr/include/xmltok && XML_INCLUDE="-I/usr/include/xmltok" - test -d /usr/include/xml && XML_INCLUDE="-I/usr/include/xml" - test -d /usr/local/include/xml && XML_INCLUDE="-I/usr/local/include/xml" - AC_CHECK_LIB(expat, main, XML_LIBS="-lexpat", XML_LIBS="-lxmlparse -lxmltok") + XML_LIBS="-lexpat" + XML_INCLUDE="" else XML_LIBS="-L$withval/lib -lexpat" - if test -d $withval/include/xml; then - XML_INCLUDE="-I$withval/include/xml" - else - XML_INCLUDE="-I$withval/include" - fi + XML_INCLUDE="-I$withval/include" fi AC_DEFINE(HAVE_LIBEXPAT, 1) - PHP_EXTENSION(xml, $shared) - if test "$shared" != "yes"; then - EXTRA_LIBS="$EXTRA_LIBS $XML_LIBS" - fi + AC_MSG_RESULT(yes) + PHP_EXTENSION(xml) + EXTRA_LIBS="$EXTRA_LIBS $XML_LIBS" + INCLUDES="$INCLUDES $XML_INCLUDE" else AC_MSG_RESULT(no) fi ],[ AC_MSG_RESULT(no) ]) -AC_SUBST(XML_LIBS) -AC_SUBST(XML_INCLUDE) diff --git a/ext/xml/php3_xml.h b/ext/xml/php3_xml.h index 5016848c8e..0c4c706d9d 100644 --- a/ext/xml/php3_xml.h +++ b/ext/xml/php3_xml.h @@ -29,13 +29,13 @@ /* $Id$ */ -#ifndef _PHP_XML_H -# define _PHP_XML_H +#if HAVE_LIBEXPAT +# ifndef _PHP_XML_H +# define _PHP_XML_H +# endif -# if HAVE_LIBEXPAT - -#include <xmltok.h> -#include <xmlparse.h> +#include <xml/xmltok.h> +#include <xml/xmlparse.h> #ifdef XML_UNICODE # error "UTF-16 Unicode support not implemented!" @@ -129,8 +129,6 @@ PHP_FUNCTION(xml_parse_into_struct); #define phpext_xml_ptr xml_module_ptr -# endif /* _PHP_XML_H */ - /* * Local variables: * tab-width: 4 diff --git a/ext/xml/xml.c b/ext/xml/xml.c index b270adc1ea..acfe5ccb05 100644 --- a/ext/xml/xml.c +++ b/ext/xml/xml.c @@ -18,12 +18,6 @@ /* $Id$ */ #define IS_EXT_MODULE - -/* boldly assume that if PIC is defined, we are being compiled dynamically */ -#ifdef PIC -# define COMPILE_DL 1 -#endif - #if COMPILE_DL # if PHP_31 # include "../phpdl.h" @@ -98,44 +92,27 @@ DLEXPORT php3_module_entry *get_module() { return &xml_module_entry; }; #if PHP_API_VERSION >= 19990421 #define php3tls_pval_destructor(a) zval_dtor(a) #endif - /* {{{ php3i_long_pval() */ - -PHPAPI pval *php3i_long_pval(long value) +static pval *php3i_long_pval(long value) { - pval *ret = emalloc(sizeof(pval)); - - ret->type = IS_LONG; - ret->value.lval = value; - return ret; + pval *ret = emalloc(sizeof(pval)); + + ret->type = IS_LONG; + ret->value.lval = value; + INIT_PZVAL(ret); + return ret; } -/* }}} */ - /* {{{ php3i_double_pval() */ - -PHPAPI pval *php3i_double_pval(double value) +static pval *php3i_string_pval(const char *str) { - pval *ret = emalloc(sizeof(pval)); - - ret->type = IS_DOUBLE; - ret->value.dval = value; - return ret; -} - -/* }}} */ - /* {{{ php3i_string_pval() */ - -PHPAPI pval *php3i_string_pval(const char *str) -{ - pval *ret = emalloc(sizeof(pval)); - int len = strlen(str); - - ret->type = IS_STRING; - ret->value.str.len = len; - ret->value.str.val = estrndup(str, len); - return ret; -} - -/* }}} */ + pval *ret = emalloc(sizeof(pval)); + int len = strlen(str); + + ret->type = IS_STRING; + ret->value.str.len = len; + INIT_PZVAL(ret); + ret->value.str.val = estrndup(str, len); + return ret; +} /* end of UGLY HACK!!! */ @@ -641,21 +618,7 @@ static int php3i_xmlcharlen(const XML_Char *s) } /* }}} */ - /* {{{ php3i_pval_strdup() */ - -PHPAPI char *php3i_pval_strdup(pval *val) -{ - if (val->type == IS_STRING) { - char *buf = emalloc(val->value.str.len + 1); - memcpy(buf, val->value.str.val, val->value.str.len); - buf[val->value.str.len] = '\0'; - return buf; - } - return NULL; -} - -/* }}} */ - /* {{{ php3i_add_to_info */ +/* {{{ php3i_add_to_info */ static void php3i_add_to_info(xml_parser *parser,char *name) { pval **element, *values; @@ -682,7 +645,7 @@ static void php3i_add_to_info(xml_parser *parser,char *name) } /* }}} */ - /* {{{ php3i_xml_startElementHandler() */ +/* {{{ php3i_xml_startElementHandler() */ void php3i_xml_startElementHandler(void *userData, const char *name, const char **attributes) |