From a9b5596a026ff2475aceb6da11c3f9fd8b24a73b Mon Sep 17 00:00:00 2001 From: SVN Migration Date: Sun, 23 Feb 2003 02:39:52 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create branch 'PHP_4_3'. --- ext/dba/dba_inifile.c | 186 +++++++++++++++++++++++++++++++ ext/dba/libinifile/inifile.h | 67 +++++++++++ ext/dba/php_inifile.h | 12 ++ ext/mysqli/tests/014.phpt | 66 +++++++++++ ext/mysqli/tests/015.phpt | 68 +++++++++++ ext/mysqli/tests/046.phpt | 31 ++++++ ext/mysqli/tests/050.phpt | 19 ++++ ext/mysqli/tests/053.phpt | 18 +++ ext/mysqli/tests/054.phpt | 18 +++ ext/mysqli/tests/055.phpt | 17 +++ ext/mysqli/tests/057.phpt | 52 +++++++++ sapi/apache2filter/EXPERIMENTAL | 5 + sapi/apache2handler/EXPERIMENTAL | 5 + 13 files changed, 564 insertions(+) create mode 100644 ext/dba/dba_inifile.c create mode 100644 ext/dba/libinifile/inifile.h create mode 100644 ext/dba/php_inifile.h create mode 100644 ext/mysqli/tests/014.phpt create mode 100644 ext/mysqli/tests/015.phpt create mode 100644 ext/mysqli/tests/046.phpt create mode 100644 ext/mysqli/tests/050.phpt create mode 100644 ext/mysqli/tests/053.phpt create mode 100644 ext/mysqli/tests/054.phpt create mode 100644 ext/mysqli/tests/055.phpt create mode 100644 ext/mysqli/tests/057.phpt create mode 100644 sapi/apache2filter/EXPERIMENTAL create mode 100644 sapi/apache2handler/EXPERIMENTAL diff --git a/ext/dba/dba_inifile.c b/ext/dba/dba_inifile.c new file mode 100644 index 0000000000..2a12179e78 --- /dev/null +++ b/ext/dba/dba_inifile.c @@ -0,0 +1,186 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 4 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2003 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Marcus Boerger | + +----------------------------------------------------------------------+ + */ + +/* $Id$ */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" + +#if DBA_INIFILE +#include "php_inifile.h" + +#include "libinifile/inifile.h" + +#ifdef HAVE_UNISTD_H +#include +#endif +#include +#include +#include + +#define INIFILE_DATA \ + inifile *dba = info->dbf + +#define INIFILE_GKEY \ + key_type ini_key = inifile_key_split((char*)key) /* keylen not needed here */ + +#define INIFILE_DONE \ + inifile_key_free(&ini_key) + +DBA_OPEN_FUNC(inifile) +{ + info->dbf = inifile_alloc(info->fp, info->mode == DBA_READER, info->flags&DBA_PERSISTENT TSRMLS_CC); + + return info->dbf ? SUCCESS : FAILURE; +} + +DBA_CLOSE_FUNC(inifile) +{ + INIFILE_DATA; + + inifile_free(dba, info->flags&DBA_PERSISTENT); +} + +DBA_FETCH_FUNC(inifile) +{ + val_type ini_val; + + INIFILE_DATA; + INIFILE_GKEY; + + ini_val = inifile_fetch(dba, &ini_key, skip TSRMLS_CC); + *newlen = ini_val.value ? strlen(ini_val.value) : 0; + INIFILE_DONE; + return ini_val.value; +} + +DBA_UPDATE_FUNC(inifile) +{ + val_type ini_val; + int res; + + INIFILE_DATA; + INIFILE_GKEY; + + ini_val.value = val; + + if (mode == 1) { + res = inifile_append(dba, &ini_key, &ini_val TSRMLS_CC); + } else { + res = inifile_replace(dba, &ini_key, &ini_val TSRMLS_CC); + } + INIFILE_DONE; + switch(res) { + case -1: + php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Operation not possible"); + return FAILURE; + default: + case 0: + return SUCCESS; + case 1: + php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Key already exists"); + return SUCCESS; + } +} + +DBA_EXISTS_FUNC(inifile) +{ + val_type ini_val; + + INIFILE_DATA; + INIFILE_GKEY; + + ini_val = inifile_fetch(dba, &ini_key, 0 TSRMLS_CC); + INIFILE_DONE; + if (ini_val.value) { + inifile_val_free(&ini_val); + return SUCCESS; + } + return FAILURE; +} + +DBA_DELETE_FUNC(inifile) +{ + INIFILE_DATA; + INIFILE_GKEY; + int res = inifile_delete(dba, &ini_key TSRMLS_CC); + + INIFILE_DONE; + return (res == -1 ? FAILURE : SUCCESS); +} + +DBA_FIRSTKEY_FUNC(inifile) +{ + INIFILE_DATA; + + if (inifile_firstkey(dba TSRMLS_CC)) { + char *result = inifile_key_string(&dba->curr.key); + *newlen = strlen(result); + return result; + } else { + return NULL; + } +} + +DBA_NEXTKEY_FUNC(inifile) +{ + INIFILE_DATA; + + if (!dba->curr.key.group && !dba->curr.key.name) { + return NULL; + } + + if (inifile_nextkey(dba TSRMLS_CC)) { + char *result = inifile_key_string(&dba->curr.key); + *newlen = strlen(result); + return result; + } else { + return NULL; + } +} + +DBA_OPTIMIZE_FUNC(inifile) +{ + /* dummy */ + return SUCCESS; +} + +DBA_SYNC_FUNC(inifile) +{ + /* dummy */ + return SUCCESS; +} + +DBA_INFO_FUNC(inifile) +{ + return estrdup(inifile_version()); +} + +#endif + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: sw=4 ts=4 fdm=marker + * vim<600: sw=4 ts=4 + */ diff --git a/ext/dba/libinifile/inifile.h b/ext/dba/libinifile/inifile.h new file mode 100644 index 0000000000..f0c17c369c --- /dev/null +++ b/ext/dba/libinifile/inifile.h @@ -0,0 +1,67 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 4 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2003 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Marcus Boerger | + +----------------------------------------------------------------------+ + */ + +/* $Id$ */ + +#ifndef PHP_LIB_INIFILE_H +#define PHP_LIB_INIFILE_H + +typedef struct { + char *group; + char *name; +} key_type; + +typedef struct { + char *value; +} val_type; + +typedef struct { + key_type key; + val_type val; + size_t pos; +} line_type; + +typedef struct { + char *lockfn; + int lockfd; + php_stream *fp; + int fd; + int readonly; + line_type curr; + line_type next; +} inifile; + +val_type inifile_fetch(inifile *dba, const key_type *key, int skip TSRMLS_DC); +int inifile_firstkey(inifile *dba TSRMLS_DC); +int inifile_nextkey(inifile *dba TSRMLS_DC); +int inifile_delete(inifile *dba, const key_type *key TSRMLS_DC); +int inifile_replace(inifile *dba, const key_type *key, const val_type *val TSRMLS_DC); +int inifile_append(inifile *dba, const key_type *key, const val_type *val TSRMLS_DC); +char *inifile_version(); + +key_type inifile_key_split(const char *group_name); +char * inifile_key_string(const key_type *key); + +void inifile_key_free(key_type *key); +void inifile_val_free(val_type *val); +void inifile_line_free(line_type *ln); + +inifile * inifile_alloc(php_stream *fp, int readonly, int persistent TSRMLS_DC); +void inifile_free(inifile *dba, int persistent); + +#endif diff --git a/ext/dba/php_inifile.h b/ext/dba/php_inifile.h new file mode 100644 index 0000000000..69444df3c6 --- /dev/null +++ b/ext/dba/php_inifile.h @@ -0,0 +1,12 @@ +#ifndef PHP_INIFILE_H +#define PHP_INIFILE_H + +#if DBA_INIFILE + +#include "php_dba.h" + +DBA_FUNCS(inifile); + +#endif + +#endif diff --git a/ext/mysqli/tests/014.phpt b/ext/mysqli/tests/014.phpt new file mode 100644 index 0000000000..8a72c42c7f --- /dev/null +++ b/ext/mysqli/tests/014.phpt @@ -0,0 +1,66 @@ +--TEST-- +mysqli autocommit/commit/rollback +--SKIPIF-- + +--FILE-- + +--EXPECT-- +array(2) { + [0]=> + string(1) "1" + [1]=> + string(6) "foobar" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(4) "egon" +} diff --git a/ext/mysqli/tests/015.phpt b/ext/mysqli/tests/015.phpt new file mode 100644 index 0000000000..96864e8854 --- /dev/null +++ b/ext/mysqli/tests/015.phpt @@ -0,0 +1,68 @@ +--TEST-- +mysqli autocommit/commit/rollback with myisam +--SKIPIF-- + +--FILE-- + +--EXPECT-- +array(2) { + [0]=> + string(1) "2" + [1]=> + string(4) "egon" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(4) "egon" +} diff --git a/ext/mysqli/tests/046.phpt b/ext/mysqli/tests/046.phpt new file mode 100644 index 0000000000..d4a93ca277 --- /dev/null +++ b/ext/mysqli/tests/046.phpt @@ -0,0 +1,31 @@ +--TEST-- +mysqli_stmt_affected_rows (delete) +--FILE-- + +--EXPECT-- +bool(true) diff --git a/ext/mysqli/tests/050.phpt b/ext/mysqli/tests/050.phpt new file mode 100644 index 0000000000..9ab5d346f8 --- /dev/null +++ b/ext/mysqli/tests/050.phpt @@ -0,0 +1,19 @@ +--TEST-- +non freed statement test +--FILE-- + +--EXPECT-- +Ok diff --git a/ext/mysqli/tests/053.phpt b/ext/mysqli/tests/053.phpt new file mode 100644 index 0000000000..f542d0f099 --- /dev/null +++ b/ext/mysqli/tests/053.phpt @@ -0,0 +1,18 @@ +--TEST-- +not freed resultset +--FILE-- + +--EXPECT-- +Ok diff --git a/ext/mysqli/tests/054.phpt b/ext/mysqli/tests/054.phpt new file mode 100644 index 0000000000..eab207db4d --- /dev/null +++ b/ext/mysqli/tests/054.phpt @@ -0,0 +1,18 @@ +--TEST-- +free resultset after close +--FILE-- + +--EXPECT-- +Ok diff --git a/ext/mysqli/tests/055.phpt b/ext/mysqli/tests/055.phpt new file mode 100644 index 0000000000..e777bcfc99 --- /dev/null +++ b/ext/mysqli/tests/055.phpt @@ -0,0 +1,17 @@ +--TEST-- +free nothing +--FILE-- + +--EXPECT-- +Ok diff --git a/ext/mysqli/tests/057.phpt b/ext/mysqli/tests/057.phpt new file mode 100644 index 0000000000..a7333a0d93 --- /dev/null +++ b/ext/mysqli/tests/057.phpt @@ -0,0 +1,52 @@ +--TEST-- +mysqli_prepare_result +--FILE-- + +--EXPECT-- +Rows: 3 +array(1) { + [0]=> + string(1) "1" +} diff --git a/sapi/apache2filter/EXPERIMENTAL b/sapi/apache2filter/EXPERIMENTAL new file mode 100644 index 0000000000..293159a693 --- /dev/null +++ b/sapi/apache2filter/EXPERIMENTAL @@ -0,0 +1,5 @@ +this module is experimental, +its functions may change their names +or move to extension all together +so do not rely to much on them +you have been warned! diff --git a/sapi/apache2handler/EXPERIMENTAL b/sapi/apache2handler/EXPERIMENTAL new file mode 100644 index 0000000000..293159a693 --- /dev/null +++ b/sapi/apache2handler/EXPERIMENTAL @@ -0,0 +1,5 @@ +this module is experimental, +its functions may change their names +or move to extension all together +so do not rely to much on them +you have been warned! -- 2.50.1