mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-21 07:56:37 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc963b2f91 |
No files matched your search
+3
-3
@@ -40,8 +40,8 @@ AC_CONFIG_HEADER(main/php_config.h)
|
||||
|
||||
MAJOR_VERSION=4
|
||||
MINOR_VERSION=3
|
||||
RELEASE_VERSION=3
|
||||
EXTRA_VERSION="-dev"
|
||||
RELEASE_VERSION=2
|
||||
EXTRA_VERSION="RC4"
|
||||
VERSION="$MAJOR_VERSION.$MINOR_VERSION.$RELEASE_VERSION$EXTRA_VERSION"
|
||||
|
||||
dnl Define where extension directories are located in the configure context
|
||||
@@ -1275,7 +1275,7 @@ cat <<X
|
||||
| *** WARNING *** |
|
||||
| |
|
||||
| You chose to compile PHP with DB extension. This extension is |
|
||||
| deprecated and does not support database locking correctly. Please |
|
||||
| deprecated and does not support databse locking correctly. Please |
|
||||
| use DBA extension which is a fully operational superset. |
|
||||
X
|
||||
fi
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
Bzip2
|
||||
Sterling Hughes
|
||||
-529
@@ -1,529 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP version 4.0 |
|
||||
+----------------------------------------------------------------------+
|
||||
| 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: Sterling Hughes <sterling@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "php.h"
|
||||
#include "php_bz2.h"
|
||||
|
||||
#if HAVE_BZ2
|
||||
|
||||
/* PHP Includes */
|
||||
#include "ext/standard/file.h"
|
||||
#include "ext/standard/info.h"
|
||||
#include "ext/standard/php_string.h"
|
||||
|
||||
/* for fileno() */
|
||||
#include <stdio.h>
|
||||
|
||||
/* Internal error constants */
|
||||
#define PHP_BZ_ERRNO 0
|
||||
#define PHP_BZ_ERRSTR 1
|
||||
#define PHP_BZ_ERRBOTH 2
|
||||
|
||||
/* Blocksize of the decompression buffer */
|
||||
#define PHP_BZ_DECOMPRESS_SIZE 4096
|
||||
|
||||
function_entry bz2_functions[] = {
|
||||
PHP_FE(bzopen, NULL)
|
||||
PHP_FE(bzread, NULL)
|
||||
PHP_FALIAS(bzwrite, fwrite, NULL)
|
||||
PHP_FALIAS(bzflush, fflush, NULL)
|
||||
PHP_FALIAS(bzclose, fclose, NULL)
|
||||
PHP_FE(bzerrno, NULL)
|
||||
PHP_FE(bzerrstr, NULL)
|
||||
PHP_FE(bzerror, NULL)
|
||||
PHP_FE(bzcompress, NULL)
|
||||
PHP_FE(bzdecompress, NULL)
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
zend_module_entry bz2_module_entry = {
|
||||
STANDARD_MODULE_HEADER,
|
||||
"bz2",
|
||||
bz2_functions,
|
||||
PHP_MINIT(bz2),
|
||||
PHP_MSHUTDOWN(bz2),
|
||||
NULL,
|
||||
NULL,
|
||||
PHP_MINFO(bz2),
|
||||
NO_VERSION_YET,
|
||||
STANDARD_MODULE_PROPERTIES
|
||||
};
|
||||
|
||||
#ifdef COMPILE_DL_BZ2
|
||||
ZEND_GET_MODULE(bz2)
|
||||
#endif
|
||||
|
||||
struct php_bz2_stream_data_t {
|
||||
BZFILE *bz_file;
|
||||
php_stream *stream;
|
||||
};
|
||||
|
||||
/* {{{ BZip2 stream implementation */
|
||||
|
||||
static size_t php_bz2iop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
|
||||
{
|
||||
struct php_bz2_stream_data_t *self = (struct php_bz2_stream_data_t *) stream->abstract;
|
||||
size_t ret;
|
||||
|
||||
ret = BZ2_bzread(self->bz_file, buf, count);
|
||||
|
||||
if (ret == 0) {
|
||||
stream->eof = 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static size_t php_bz2iop_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
|
||||
{
|
||||
struct php_bz2_stream_data_t *self = (struct php_bz2_stream_data_t *) stream->abstract;
|
||||
|
||||
return BZ2_bzwrite(self->bz_file, (char*)buf, count);
|
||||
}
|
||||
|
||||
static int php_bz2iop_close(php_stream *stream, int close_handle TSRMLS_DC)
|
||||
{
|
||||
struct php_bz2_stream_data_t *self = (struct php_bz2_stream_data_t *)stream->abstract;
|
||||
int ret = EOF;
|
||||
|
||||
if (close_handle) {
|
||||
BZ2_bzclose(self->bz_file);
|
||||
}
|
||||
|
||||
if (self->stream) {
|
||||
php_stream_free(self->stream, PHP_STREAM_FREE_CLOSE | (close_handle == 0 ? PHP_STREAM_FREE_PRESERVE_HANDLE : 0));
|
||||
}
|
||||
|
||||
efree(self);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int php_bz2iop_flush(php_stream *stream TSRMLS_DC)
|
||||
{
|
||||
struct php_bz2_stream_data_t *self = (struct php_bz2_stream_data_t *)stream->abstract;
|
||||
return BZ2_bzflush(self->bz_file);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
php_stream_ops php_stream_bz2io_ops = {
|
||||
php_bz2iop_write, php_bz2iop_read,
|
||||
php_bz2iop_close, php_bz2iop_flush,
|
||||
"BZip2",
|
||||
NULL, /* seek */
|
||||
NULL, /* cast */
|
||||
NULL, /* stat */
|
||||
NULL /* set_option */
|
||||
};
|
||||
|
||||
/* {{{ Bzip2 stream openers */
|
||||
PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz,
|
||||
char *mode, php_stream *innerstream STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
struct php_bz2_stream_data_t *self;
|
||||
|
||||
self = emalloc(sizeof(*self));
|
||||
|
||||
self->stream = innerstream;
|
||||
self->bz_file = bz;
|
||||
|
||||
return php_stream_alloc_rel(&php_stream_bz2io_ops, self, 0, mode);
|
||||
}
|
||||
|
||||
PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper,
|
||||
char *path,
|
||||
char *mode,
|
||||
int options,
|
||||
char **opened_path,
|
||||
php_stream_context *context STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
php_stream *retstream = NULL, *stream = NULL;
|
||||
char *path_copy = NULL;
|
||||
BZFILE *bz_file = NULL;
|
||||
|
||||
if (strncasecmp("compress.bzip2://", path, 17) == 0) {
|
||||
path += 17;
|
||||
}
|
||||
|
||||
#ifdef VIRTUAL_DIR
|
||||
virtual_filepath(path, &path_copy TSRMLS_CC);
|
||||
#else
|
||||
path_copy = path;
|
||||
#endif
|
||||
|
||||
/* try and open it directly first */
|
||||
bz_file = BZ2_bzopen(path_copy, mode);
|
||||
|
||||
if (opened_path && bz_file) {
|
||||
*opened_path = estrdup(path_copy);
|
||||
}
|
||||
path_copy = NULL;
|
||||
|
||||
if (bz_file == NULL) {
|
||||
/* that didn't work, so try and get something from the network/wrapper */
|
||||
stream = php_stream_open_wrapper(path, mode, options, opened_path);
|
||||
|
||||
if (stream) {
|
||||
int fd;
|
||||
if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD, (void **) &fd, REPORT_ERRORS)) {
|
||||
bz_file = BZ2_bzdopen(fd, mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bz_file) {
|
||||
retstream = _php_stream_bz2open_from_BZFILE(bz_file, mode, stream STREAMS_REL_CC TSRMLS_CC);
|
||||
if (retstream) {
|
||||
return retstream;
|
||||
}
|
||||
|
||||
BZ2_bzclose(bz_file);
|
||||
}
|
||||
|
||||
if (stream) {
|
||||
php_stream_close(stream);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
static php_stream_wrapper_ops bzip2_stream_wops = {
|
||||
_php_stream_bz2open,
|
||||
NULL, /* close */
|
||||
NULL, /* fstat */
|
||||
NULL, /* stat */
|
||||
NULL, /* opendir */
|
||||
"BZip2",
|
||||
NULL /* unlink */
|
||||
};
|
||||
|
||||
php_stream_wrapper php_stream_bzip2_wrapper = {
|
||||
&bzip2_stream_wops,
|
||||
NULL,
|
||||
0 /* is_url */
|
||||
};
|
||||
|
||||
static void php_bz2_error(INTERNAL_FUNCTION_PARAMETERS, int);
|
||||
|
||||
PHP_MINIT_FUNCTION(bz2)
|
||||
{
|
||||
php_register_url_stream_wrapper("compress.bzip2", &php_stream_bzip2_wrapper TSRMLS_CC);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
PHP_MSHUTDOWN_FUNCTION(bz2)
|
||||
{
|
||||
php_unregister_url_stream_wrapper("compress.bzip2" TSRMLS_CC);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
PHP_MINFO_FUNCTION(bz2)
|
||||
{
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_row(2, "BZip2 Support", "Enabled");
|
||||
php_info_print_table_row(2, "BZip2 Version", (char *) BZ2_bzlibVersion());
|
||||
php_info_print_table_end();
|
||||
}
|
||||
|
||||
/* {{{ proto string bzread(int bz[, int length])
|
||||
Reads up to length bytes from a BZip2 stream, or 1024 bytes if length is not specified */
|
||||
PHP_FUNCTION(bzread)
|
||||
{
|
||||
zval *bz;
|
||||
long len = 1024;
|
||||
php_stream *stream;
|
||||
|
||||
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &bz, &len)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
php_stream_from_zval(stream, &bz);
|
||||
|
||||
if (len < 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "length may not be negative");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
Z_STRVAL_P(return_value) = emalloc(len + 1);
|
||||
Z_STRLEN_P(return_value) = php_stream_read(stream, Z_STRVAL_P(return_value), len);
|
||||
|
||||
if (Z_STRLEN_P(return_value) < 0) {
|
||||
efree(Z_STRVAL_P(return_value));
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "could not read valid bz2 data from stream");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
Z_STRVAL_P(return_value)[Z_STRLEN_P(return_value)] = 0;
|
||||
|
||||
if (PG(magic_quotes_runtime)) {
|
||||
Z_STRVAL_P(return_value) = php_addslashes( Z_STRVAL_P(return_value),
|
||||
Z_STRLEN_P(return_value),
|
||||
&Z_STRLEN_P(return_value), 1 TSRMLS_CC);
|
||||
}
|
||||
|
||||
Z_TYPE_P(return_value) = IS_STRING;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto resource bzopen(string|int file|fp, string mode)
|
||||
Opens a new BZip2 stream */
|
||||
PHP_FUNCTION(bzopen)
|
||||
{
|
||||
zval **file, /* The file to open */
|
||||
**mode; /* The mode to open the stream with */
|
||||
BZFILE *bz; /* The compressed file stream */
|
||||
php_stream *stream = NULL;
|
||||
|
||||
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &file, &mode) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_string_ex(mode);
|
||||
|
||||
/* If it's not a resource its a string containing the filename to open */
|
||||
if (Z_TYPE_PP(file) != IS_RESOURCE) {
|
||||
convert_to_string_ex(file);
|
||||
stream = php_stream_bz2open(NULL,
|
||||
Z_STRVAL_PP(file),
|
||||
Z_STRVAL_PP(mode),
|
||||
ENFORCE_SAFE_MODE | REPORT_ERRORS,
|
||||
NULL);
|
||||
} else {
|
||||
/* If it is a resource, than its a stream resource */
|
||||
int fd;
|
||||
|
||||
php_stream_from_zval(stream, file);
|
||||
|
||||
if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_FD, (void *) &fd, REPORT_ERRORS)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
bz = BZ2_bzdopen(fd, Z_STRVAL_PP(mode));
|
||||
|
||||
stream = php_stream_bz2open_from_BZFILE(bz, Z_STRVAL_PP(mode), stream);
|
||||
}
|
||||
|
||||
if (stream) {
|
||||
php_stream_to_zval(stream, return_value);
|
||||
} else {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int bzerrno(resource bz)
|
||||
Returns the error number */
|
||||
PHP_FUNCTION(bzerrno)
|
||||
{
|
||||
php_bz2_error(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_BZ_ERRNO);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string bzerrstr(resource bz)
|
||||
Returns the error string */
|
||||
PHP_FUNCTION(bzerrstr)
|
||||
{
|
||||
php_bz2_error(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_BZ_ERRSTR);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto array bzerror(resource bz)
|
||||
Returns the error number and error string in an associative array */
|
||||
PHP_FUNCTION(bzerror)
|
||||
{
|
||||
php_bz2_error(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_BZ_ERRBOTH);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string bzcompress(string source [, int blocksize100k [, int workfactor]])
|
||||
Compresses a string into BZip2 encoded data */
|
||||
PHP_FUNCTION(bzcompress)
|
||||
{
|
||||
zval **source, /* Source data to compress */
|
||||
**zblock_size, /* Optional block size to use */
|
||||
**zwork_factor; /* Optional work factor to use */
|
||||
char *dest = NULL; /* Destination to place the compressed data into */
|
||||
int error, /* Error Container */
|
||||
block_size = 4, /* Block size for compression algorithm */
|
||||
work_factor = 0, /* Work factor for compression algorithm */
|
||||
argc; /* Argument count */
|
||||
unsigned int source_len, /* Length of the source data */
|
||||
dest_len; /* Length of the destination buffer */
|
||||
|
||||
argc = ZEND_NUM_ARGS();
|
||||
|
||||
if (argc < 1 || argc > 3 || zend_get_parameters_ex(argc, &source, &zblock_size, &zwork_factor) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(source);
|
||||
|
||||
/* Assign them to easy to use variables, dest_len is initially the length of the data
|
||||
+ .01 x length of data + 600 which is the largest size the results of the compression
|
||||
could possibly be, at least that's what the libbz2 docs say (thanks to jeremy@nirvani.net
|
||||
for pointing this out). */
|
||||
source_len = Z_STRLEN_PP(source);
|
||||
dest_len = Z_STRLEN_PP(source) + (0.01 * Z_STRLEN_PP(source)) + 600;
|
||||
|
||||
/* Allocate the destination buffer */
|
||||
dest = emalloc(dest_len + 1);
|
||||
|
||||
/* Handle the optional arguments */
|
||||
if (argc > 1) {
|
||||
convert_to_long_ex(zblock_size);
|
||||
block_size = Z_LVAL_PP(zblock_size);
|
||||
}
|
||||
|
||||
if (argc > 2) {
|
||||
convert_to_long_ex(zwork_factor);
|
||||
work_factor = Z_LVAL_PP(zwork_factor);
|
||||
}
|
||||
|
||||
error = BZ2_bzBuffToBuffCompress(dest, &dest_len, Z_STRVAL_PP(source), source_len, block_size, 0, work_factor);
|
||||
if (error != BZ_OK) {
|
||||
efree(dest);
|
||||
RETURN_LONG(error);
|
||||
} else {
|
||||
/* Copy the buffer, we have perhaps allocate alot more than we need,
|
||||
so we erealloc() the buffer to the proper size */
|
||||
dest = erealloc(dest, dest_len + 1);
|
||||
dest[dest_len] = 0;
|
||||
RETURN_STRINGL(dest, dest_len, 0);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string bzdecompress(string source [, int small])
|
||||
Decompresses BZip2 compressed data */
|
||||
PHP_FUNCTION(bzdecompress)
|
||||
{
|
||||
zval **source, /* Source data to decompress */
|
||||
**zsmall; /* (Optional) user specified small */
|
||||
char *dest; /* Destination buffer, initially allocated */
|
||||
int error, /* Error container */
|
||||
iter = 1, /* Iteration count for the compression loop */
|
||||
size, /* Current size to realloc the dest buffer to */
|
||||
dest_len = PHP_BZ_DECOMPRESS_SIZE, /* Size of the destination length */
|
||||
small = 0, /* The actual small */
|
||||
argc = ZEND_NUM_ARGS(); /* Argument count */
|
||||
|
||||
if (argc < 1 || argc > 2 || zend_get_parameters_ex(argc, &source, &zsmall) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(source);
|
||||
|
||||
/* optional small argument handling */
|
||||
if (argc > 1) {
|
||||
convert_to_long_ex(zsmall);
|
||||
small = Z_LVAL_PP(zsmall);
|
||||
}
|
||||
|
||||
/* Depending on the size of the source buffer, either allocate
|
||||
the length of the source buffer or the a default decompression
|
||||
size */
|
||||
dest = emalloc(PHP_BZ_DECOMPRESS_SIZE > Z_STRLEN_PP(source) ? PHP_BZ_DECOMPRESS_SIZE : Z_STRLEN_PP(source));
|
||||
|
||||
/* (de)Compression Loop */
|
||||
do {
|
||||
/* Handle the (re)allocation of the buffer */
|
||||
size = dest_len * iter;
|
||||
if (iter > 1) {
|
||||
dest = erealloc(dest, size);
|
||||
}
|
||||
++iter;
|
||||
|
||||
/* Perform the decompression */
|
||||
error = BZ2_bzBuffToBuffDecompress(dest, &size, Z_STRVAL_PP(source), Z_STRLEN_PP(source), small, 0);
|
||||
} while (error == BZ_OUTBUFF_FULL);
|
||||
|
||||
if (error != BZ_OK) {
|
||||
efree(dest);
|
||||
RETURN_LONG(error);
|
||||
} else {
|
||||
/* we might have allocated a little to much, so erealloc the buffer
|
||||
down to size, before returning it */
|
||||
dest = erealloc(dest, size + 1);
|
||||
dest[size] = 0;
|
||||
RETURN_STRINGL(dest, size, 0);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_bz2_error()
|
||||
The central error handling interface, does the work for bzerrno, bzerrstr and bzerror */
|
||||
static void php_bz2_error(INTERNAL_FUNCTION_PARAMETERS, int opt)
|
||||
{
|
||||
zval **bzp; /* BZip2 Resource Pointer */
|
||||
php_stream *stream;
|
||||
const char *errstr; /* Error string */
|
||||
int errnum; /* Error number */
|
||||
struct php_bz2_stream_data_t *self;
|
||||
|
||||
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &bzp) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
php_stream_from_zval(stream, bzp);
|
||||
|
||||
if (!php_stream_is(stream, PHP_STREAM_IS_BZIP2)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
self = (struct php_bz2_stream_data_t *) stream->abstract;
|
||||
|
||||
/* Fetch the error information */
|
||||
errstr = BZ2_bzerror(self->bz_file, &errnum);
|
||||
|
||||
/* Determine what to return */
|
||||
switch (opt) {
|
||||
case PHP_BZ_ERRNO:
|
||||
RETURN_LONG(errnum);
|
||||
break;
|
||||
case PHP_BZ_ERRSTR:
|
||||
RETURN_STRING((char*)errstr, 1);
|
||||
break;
|
||||
case PHP_BZ_ERRBOTH:
|
||||
array_init(return_value);
|
||||
|
||||
add_assoc_long (return_value, "errno", errnum);
|
||||
add_assoc_string(return_value, "errstr", (char*)errstr, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: fdm=marker
|
||||
* vim: noet sw=4 ts=4
|
||||
*/
|
||||
-108
@@ -1,108 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="bz2" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=bz2 - Win32 Debug_TS
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "bz2.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "bz2.mak" CFG="bz2 - Win32 Debug_TS"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "bz2 - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "bz2 - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "bz2 - Win32 Release_TS"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release_TS"
|
||||
# PROP BASE Intermediate_Dir "Release_TS"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release_TS"
|
||||
# PROP Intermediate_Dir "Release_TS"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZ2_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\..\php_build\includes" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_BZ2" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_BZ2=1 /D "PHP_BZ2_EXPORTS" /FR /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x407 /d "NDEBUG"
|
||||
# ADD RSC /l 0x407 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 libbz2.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_bz2.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"..\..\..\php_build\release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "bz2 - Win32 Debug_TS"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug_TS"
|
||||
# PROP BASE Intermediate_Dir "Debug_TS"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug_TS"
|
||||
# PROP Intermediate_Dir "Debug_TS"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZ2_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\..\php_build\includes" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_BZ2" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_BZ2=1 /D "PHP_BZ2_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x407 /d "_DEBUG"
|
||||
# ADD RSC /l 0x407 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 php4ts_debug.lib libbz2.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS/php_bz2.dll" /pdbtype:sept /libpath:"..\..\Debug_TS" /libpath:"..\..\..\php_build\release"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "bz2 - Win32 Release_TS"
|
||||
# Name "bz2 - Win32 Debug_TS"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\bz2.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\php_bz2.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -1,33 +0,0 @@
|
||||
dnl
|
||||
dnl $Id$
|
||||
dnl
|
||||
|
||||
PHP_ARG_WITH(bz2, for BZip2 support,
|
||||
[ --with-bz2[=DIR] Include BZip2 support])
|
||||
|
||||
if test "$PHP_BZ2" != "no"; then
|
||||
if test -r $PHP_BZ2/include/bzlib.h; then
|
||||
BZIP_DIR=$PHP_BZ2
|
||||
else
|
||||
AC_MSG_CHECKING(for BZip2 in default path)
|
||||
for i in /usr/local /usr; do
|
||||
if test -r $i/include/bzlib.h; then
|
||||
BZIP_DIR=$i
|
||||
AC_MSG_RESULT(found in $i)
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if test -z "$BZIP_DIR"; then
|
||||
AC_MSG_RESULT(not found)
|
||||
AC_MSG_ERROR(Please reinstall the BZip2 distribution)
|
||||
fi
|
||||
|
||||
PHP_ADD_INCLUDE($BZIP_DIR/include)
|
||||
|
||||
PHP_SUBST(BZ2_SHARED_LIBADD)
|
||||
PHP_ADD_LIBRARY_WITH_PATH(bz2, $BZIP_DIR/lib, BZ2_SHARED_LIBADD)
|
||||
AC_CHECK_LIB(bz2, BZ2_bzerror, [AC_DEFINE(HAVE_BZ2,1,[ ])], [AC_MSG_ERROR(bz2 module requires libbz2 >= 1.0.0)],)
|
||||
|
||||
PHP_NEW_EXTENSION(bz2, bz2.c, $ext_shared)
|
||||
fi
|
||||
@@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<!-- do not use the "Type" attribute here, that one is only for
|
||||
generated package.xml files -->
|
||||
<package>
|
||||
<name>bz2</name>
|
||||
<summary>A Bzip2 management extension</summary>
|
||||
<description>
|
||||
Bz2 is an extension to create and parse bzip2 compressed data.
|
||||
</description>
|
||||
<license>PHP License</license>
|
||||
<maintainers>
|
||||
<maintainer>
|
||||
<user>sterling</user>
|
||||
<name>Sterling Hughes</name>
|
||||
<email>sterling@php.net</email>
|
||||
</maintainer>
|
||||
</maintainers>
|
||||
<release>
|
||||
<version>1.0</version>
|
||||
<date>2003-05-17</date>
|
||||
<state>stable</state>
|
||||
<notes>
|
||||
Initial Release in PECL
|
||||
</notes>
|
||||
</release>
|
||||
<filelist>
|
||||
<dir role="src" name="/">
|
||||
<file role="doc">CREDITS</file>
|
||||
<file role="src">config.m4</file>
|
||||
<file role="doc">php_bz2.h</file>
|
||||
<file role="src">bz2.c</file>
|
||||
<file role="src">bz2.dsp</file>
|
||||
</dir>
|
||||
</filelist>
|
||||
</package>
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| 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: Sterling Hughes <sterling@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef PHP_BZ2_H
|
||||
#define PHP_BZ2_H
|
||||
|
||||
#if HAVE_BZ2
|
||||
|
||||
extern zend_module_entry bz2_module_entry;
|
||||
#define phpext_bz2_ptr &bz2_module_entry
|
||||
|
||||
/* Bzip2 includes */
|
||||
#include <bzlib.h>
|
||||
|
||||
PHP_MINIT_FUNCTION(bz2);
|
||||
PHP_MSHUTDOWN_FUNCTION(bz2);
|
||||
PHP_MINFO_FUNCTION(bz2);
|
||||
PHP_FUNCTION(bzopen);
|
||||
PHP_FUNCTION(bzread);
|
||||
PHP_FUNCTION(bzerrno);
|
||||
PHP_FUNCTION(bzerrstr);
|
||||
PHP_FUNCTION(bzerror);
|
||||
PHP_FUNCTION(bzcompress);
|
||||
PHP_FUNCTION(bzdecompress);
|
||||
|
||||
#else
|
||||
#define phpext_bz2_ptr NULL
|
||||
#endif
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
# ifdef PHP_BZ2_EXPORTS
|
||||
# define PHP_BZ2_API __declspec(dllexport)
|
||||
# else
|
||||
# define PHP_BZ2_API __declspec(dllimport)
|
||||
# endif
|
||||
#else
|
||||
# define PHP_BZ2_API
|
||||
#endif
|
||||
|
||||
PHP_BZ2_API PHPAPI php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
|
||||
PHP_BZ2_API PHPAPI php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz, char *mode, php_stream *innerstream STREAMS_DC TSRMLS_DC);
|
||||
|
||||
#define php_stream_bz2open_from_BZFILE(bz, mode, innerstream) _php_stream_bz2open_from_BZFILE((bz), (mode), (innerstream) STREAMS_CC TSRMLS_CC)
|
||||
#define php_stream_bz2open(wrapper, path, mode, options, opened_path) _php_stream_bz2open((wrapper), (path), (mode), (options), (opened_path), NULL STREAMS_CC TSRMLS_CC)
|
||||
|
||||
php_stream_ops php_stream_bz2io_ops;
|
||||
#define PHP_STREAM_IS_BZIP2 &php_stream_bz2io_ops
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
@@ -1,25 +0,0 @@
|
||||
--TEST--
|
||||
BZ2 with files
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("bz2")) print "skip"; ?>
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php // $Id$
|
||||
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$filename = "testfile.bz2";
|
||||
$str = "This is a test string.\n";
|
||||
$bz = bzopen($filename, "w");
|
||||
bzwrite($bz, $str);
|
||||
bzclose($bz);
|
||||
|
||||
$bz = bzopen($filename, "r");
|
||||
print bzread($bz, 10);
|
||||
print bzread($bz);
|
||||
bzclose($bz);
|
||||
unlink($filename);
|
||||
|
||||
--EXPECT--
|
||||
This is a test string.
|
||||
@@ -1,29 +0,0 @@
|
||||
--TEST--
|
||||
BZ2 with strings
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("bz2")) print "skip"; ?>
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php // $Id$
|
||||
|
||||
error_reporting(E_ALL);
|
||||
|
||||
# This FAILS
|
||||
$blaat = <<<HEREDOC
|
||||
This is some random data
|
||||
HEREDOC;
|
||||
|
||||
# This Works: (so, is heredoc related)
|
||||
#$blaat= 'This is some random data';
|
||||
|
||||
$blaat2 = bzdecompress(bzcompress($blaat));
|
||||
|
||||
$tests = <<<TESTS
|
||||
\$blaat === \$blaat2
|
||||
TESTS;
|
||||
|
||||
include('tests/quicktester.inc');
|
||||
|
||||
--EXPECT--
|
||||
OK
|
||||
@@ -1,186 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| 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 <helly@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $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 <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#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
|
||||
*/
|
||||
@@ -1,598 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| 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 <helly@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "php.h"
|
||||
#include "php_globals.h"
|
||||
#include "safe_mode.h"
|
||||
#include "php_network.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "inifile.h"
|
||||
|
||||
/* ret = -1 means that database was opened for read-only
|
||||
* ret = 0 success
|
||||
* ret = 1 key already exists - nothing done
|
||||
*/
|
||||
|
||||
/* {{{ inifile_version */
|
||||
char *inifile_version()
|
||||
{
|
||||
return "1.0, $Revision$";
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_free_key */
|
||||
void inifile_key_free(key_type *key)
|
||||
{
|
||||
if (key->group) {
|
||||
efree(key->group);
|
||||
}
|
||||
if (key->name) {
|
||||
efree(key->name);
|
||||
}
|
||||
memset(key, 0, sizeof(key_type));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_free_val */
|
||||
void inifile_val_free(val_type *val)
|
||||
{
|
||||
if (val->value) {
|
||||
efree(val->value);
|
||||
}
|
||||
memset(val, 0, sizeof(val_type));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_free_val */
|
||||
void inifile_line_free(line_type *ln)
|
||||
{
|
||||
inifile_key_free(&ln->key);
|
||||
inifile_val_free(&ln->val);
|
||||
ln->pos = 0;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_alloc */
|
||||
inifile * inifile_alloc(php_stream *fp, int readonly, int persistent TSRMLS_DC)
|
||||
{
|
||||
inifile *dba;
|
||||
int fd = 0;
|
||||
|
||||
if (!readonly) {
|
||||
if (!php_stream_truncate_supported(fp)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't truncate this stream");
|
||||
return NULL;
|
||||
}
|
||||
if (SUCCESS != php_stream_cast(fp, PHP_STREAM_AS_FD, (void*)&fd, 1)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not cast stream");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
dba = pemalloc(sizeof(inifile), persistent);
|
||||
memset(dba, 0, sizeof(inifile));
|
||||
dba->fp = fp;
|
||||
dba->fd = fd;
|
||||
dba->readonly = readonly;
|
||||
return dba;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_free */
|
||||
void inifile_free(inifile *dba, int persistent)
|
||||
{
|
||||
if (dba) {
|
||||
inifile_line_free(&dba->curr);
|
||||
inifile_line_free(&dba->next);
|
||||
pefree(dba, persistent);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_key_split */
|
||||
key_type inifile_key_split(const char *group_name)
|
||||
{
|
||||
key_type key;
|
||||
char *name;
|
||||
|
||||
if (group_name[0] == '[' && (name = strchr(group_name, ']')) != NULL) {
|
||||
key.group = estrndup(group_name+1, name - (group_name + 1));
|
||||
key.name = estrdup(name+1);
|
||||
} else {
|
||||
key.group = estrdup("");
|
||||
key.name = estrdup(group_name);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_key_string */
|
||||
char * inifile_key_string(const key_type *key)
|
||||
{
|
||||
if (key->group && *key->group) {
|
||||
char *result;
|
||||
spprintf(&result, 0, "[%s]%s", key->group, key->name ? key->name : "");
|
||||
return result;
|
||||
} else if (key->name) {
|
||||
return estrdup(key->name);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ etrim */
|
||||
static char *etrim(const char *str)
|
||||
{
|
||||
char *val;
|
||||
size_t l;
|
||||
|
||||
if (!str) {
|
||||
return NULL;
|
||||
}
|
||||
val = (char*)str;
|
||||
while (strchr(" \t\r\n", *val)) {
|
||||
val++;
|
||||
}
|
||||
l = strlen(val);
|
||||
while (l && (strchr(" \t\r\n", val[l-1]))) {
|
||||
l--;
|
||||
}
|
||||
return estrndup(val, l);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_findkey
|
||||
*/
|
||||
static int inifile_read(inifile *dba, line_type *ln TSRMLS_DC) {
|
||||
char *fline;
|
||||
char *pos;
|
||||
|
||||
inifile_val_free(&ln->val);
|
||||
while ((fline = php_stream_gets(dba->fp, NULL, 0)) != NULL) {
|
||||
if (fline) {
|
||||
if (fline[0] == '[') {
|
||||
/* A value name cannot start with '['
|
||||
* So either we find a ']' or we found an error
|
||||
*/
|
||||
pos = strchr(fline+1, ']');
|
||||
if (pos) {
|
||||
*pos = '\0';
|
||||
inifile_key_free(&ln->key);
|
||||
ln->key.group = etrim(fline+1);
|
||||
ln->key.name = estrdup("");
|
||||
ln->pos = php_stream_tell(dba->fp);
|
||||
efree(fline);
|
||||
return 1;
|
||||
} else {
|
||||
efree(fline);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
pos = strchr(fline, '=');
|
||||
if (pos) {
|
||||
*pos = '\0';
|
||||
/* keep group or make empty if not existent */
|
||||
if (!ln->key.group) {
|
||||
ln->key.group = estrdup("");
|
||||
}
|
||||
if (ln->key.name) {
|
||||
efree(ln->key.name);
|
||||
}
|
||||
ln->key.name = etrim(fline);
|
||||
ln->val.value = etrim(pos+1);
|
||||
ln->pos = php_stream_tell(dba->fp);
|
||||
efree(fline);
|
||||
return 1;
|
||||
} else {
|
||||
/* simply ignore lines without '='
|
||||
* those should be comments
|
||||
*/
|
||||
efree(fline);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
inifile_line_free(ln);
|
||||
return 0;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_key_cmp */
|
||||
/* 0 = EQUAL
|
||||
* 1 = GROUP-EQUAL,NAME-DIFFERENT
|
||||
* 2 = DIFFERENT
|
||||
*/
|
||||
static int inifile_key_cmp(const key_type *k1, const key_type *k2 TSRMLS_DC)
|
||||
{
|
||||
assert(k1->group && k1->name && k2->group && k2->name);
|
||||
|
||||
if (!strcasecmp(k1->group, k2->group)) {
|
||||
if (!strcasecmp(k1->name, k2->name)) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_fetch
|
||||
*/
|
||||
val_type inifile_fetch(inifile *dba, const key_type *key, int skip TSRMLS_DC) {
|
||||
line_type ln = {{NULL,NULL},{NULL}};
|
||||
val_type val;
|
||||
int res, grp_eq = 0;
|
||||
|
||||
if (skip == -1 && dba->next.key.group && dba->next.key.name && !inifile_key_cmp(&dba->next.key, key TSRMLS_CC)) {
|
||||
/* we got position already from last fetch */
|
||||
php_stream_seek(dba->fp, dba->next.pos, SEEK_SET);
|
||||
} else {
|
||||
/* specific instance or not same key -> restart search */
|
||||
/* the slow way: restart and seacrch */
|
||||
php_stream_rewind(dba->fp);
|
||||
inifile_line_free(&dba->next);
|
||||
}
|
||||
if (skip == -1) {
|
||||
skip = 0;
|
||||
}
|
||||
while(inifile_read(dba, &ln TSRMLS_CC)) {
|
||||
if (!(res=inifile_key_cmp(&ln.key, key TSRMLS_CC))) {
|
||||
if (!skip) {
|
||||
val.value = estrdup(ln.val.value ? ln.val.value : "");
|
||||
/* allow faster access by updating key read into next */
|
||||
inifile_line_free(&dba->next);
|
||||
dba->next = ln;
|
||||
dba->next.pos = php_stream_tell(dba->fp);
|
||||
return val;
|
||||
}
|
||||
skip--;
|
||||
} else if (res == 1) {
|
||||
grp_eq = 1;
|
||||
} else if (grp_eq) {
|
||||
/* we are leaving group now: that means we cannot find the key */
|
||||
break;
|
||||
}
|
||||
}
|
||||
inifile_line_free(&ln);
|
||||
dba->next.pos = php_stream_tell(dba->fp);
|
||||
return ln.val;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_firstkey
|
||||
*/
|
||||
int inifile_firstkey(inifile *dba TSRMLS_DC) {
|
||||
inifile_line_free(&dba->curr);
|
||||
dba->curr.pos = 0;
|
||||
return inifile_nextkey(dba TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_nextkey
|
||||
*/
|
||||
int inifile_nextkey(inifile *dba TSRMLS_DC) {
|
||||
line_type ln = {{NULL,NULL},{NULL}};
|
||||
|
||||
/*inifile_line_free(&dba->next); ??? */
|
||||
php_stream_seek(dba->fp, dba->curr.pos, SEEK_SET);
|
||||
ln.key.group = estrdup(dba->curr.key.group ? dba->curr.key.group : "");
|
||||
inifile_read(dba, &ln TSRMLS_CC);
|
||||
inifile_line_free(&dba->curr);
|
||||
dba->curr = ln;
|
||||
return ln.key.group || ln.key.name;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_truncate
|
||||
*/
|
||||
static int inifile_truncate(inifile *dba, size_t size TSRMLS_DC)
|
||||
{
|
||||
int res;
|
||||
|
||||
if ((res=php_stream_truncate_set_size(dba->fp, size)) != 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error in ftruncate: %d", res);
|
||||
return FAILURE;
|
||||
}
|
||||
php_stream_seek(dba->fp, size, SEEK_SET);
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_find_group
|
||||
* if found pos_grp_start points to "[group_name]"
|
||||
*/
|
||||
static int inifile_find_group(inifile *dba, const key_type *key, size_t *pos_grp_start TSRMLS_DC)
|
||||
{
|
||||
int ret = FAILURE;
|
||||
|
||||
php_stream_flush(dba->fp);
|
||||
php_stream_seek(dba->fp, 0, SEEK_SET);
|
||||
inifile_line_free(&dba->curr);
|
||||
inifile_line_free(&dba->next);
|
||||
|
||||
if (key->group && strlen(key->group)) {
|
||||
int res;
|
||||
line_type ln = {{NULL,NULL},{NULL}};
|
||||
|
||||
res = 1;
|
||||
while(inifile_read(dba, &ln TSRMLS_CC)) {
|
||||
if ((res=inifile_key_cmp(&ln.key, key TSRMLS_CC)) < 2) {
|
||||
ret = SUCCESS;
|
||||
break;
|
||||
}
|
||||
*pos_grp_start = php_stream_tell(dba->fp);
|
||||
}
|
||||
inifile_line_free(&ln);
|
||||
} else {
|
||||
*pos_grp_start = 0;
|
||||
ret = SUCCESS;
|
||||
}
|
||||
if (ret == FAILURE) {
|
||||
*pos_grp_start = php_stream_tell(dba->fp);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_next_group
|
||||
* only valid after a call to inifile_find_group
|
||||
* if any next group is found pos_grp_start points to "[group_name]" or whitespace before that
|
||||
*/
|
||||
static int inifile_next_group(inifile *dba, const key_type *key, size_t *pos_grp_start TSRMLS_DC)
|
||||
{
|
||||
int ret = FAILURE;
|
||||
line_type ln = {{NULL,NULL},{NULL}};
|
||||
|
||||
*pos_grp_start = php_stream_tell(dba->fp);
|
||||
ln.key.group = estrdup(key->group);
|
||||
while(inifile_read(dba, &ln TSRMLS_CC)) {
|
||||
if (inifile_key_cmp(&ln.key, key TSRMLS_CC) == 2) {
|
||||
ret = SUCCESS;
|
||||
break;
|
||||
}
|
||||
*pos_grp_start = php_stream_tell(dba->fp);
|
||||
}
|
||||
inifile_line_free(&ln);
|
||||
return ret;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_copy_to
|
||||
*/
|
||||
static int inifile_copy_to(inifile *dba, size_t pos_start, size_t pos_end, inifile **ini_copy TSRMLS_DC)
|
||||
{
|
||||
php_stream *fp;
|
||||
|
||||
if (pos_start == pos_end) {
|
||||
*ini_copy = NULL;
|
||||
return SUCCESS;
|
||||
}
|
||||
if ((fp = php_stream_temp_create(0, 64 * 1024)) == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not create temporary stream");
|
||||
*ini_copy = NULL;
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if ((*ini_copy = inifile_alloc(fp, 1, 0 TSRMLS_CC)) == NULL) {
|
||||
/* writes error */
|
||||
return FAILURE;
|
||||
}
|
||||
php_stream_seek(dba->fp, pos_start, SEEK_SET);
|
||||
if (!php_stream_copy_to_stream(dba->fp, fp, pos_end - pos_start)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy group [%d - %d] to temporary stream", pos_start, pos_end);
|
||||
return FAILURE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_filter
|
||||
* copy from to dba while ignoring key name (group must equal)
|
||||
*/
|
||||
static int inifile_filter(inifile *dba, inifile *from, const key_type *key TSRMLS_DC)
|
||||
{
|
||||
size_t pos_start = 0, pos_next = 0, pos_curr;
|
||||
int ret = SUCCESS;
|
||||
line_type ln = {{NULL,NULL},{NULL}};
|
||||
|
||||
php_stream_seek(from->fp, 0, SEEK_SET);
|
||||
php_stream_seek(dba->fp, 0, SEEK_END);
|
||||
while(inifile_read(from, &ln TSRMLS_CC)) {
|
||||
switch(inifile_key_cmp(&ln.key, key TSRMLS_CC)) {
|
||||
case 0:
|
||||
pos_curr = php_stream_tell(from->fp);
|
||||
if (pos_start != pos_next) {
|
||||
php_stream_seek(from->fp, pos_start, SEEK_SET);
|
||||
if (!php_stream_copy_to_stream(from->fp, dba->fp, pos_next - pos_start)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy [%d - %d] from temporary stream", pos_next, pos_start);
|
||||
ret = FAILURE;
|
||||
}
|
||||
php_stream_seek(from->fp, pos_curr, SEEK_SET);
|
||||
}
|
||||
pos_next = pos_start = pos_curr;
|
||||
break;
|
||||
case 1:
|
||||
pos_next = php_stream_tell(from->fp);
|
||||
break;
|
||||
case 2:
|
||||
/* the function is meant to process only entries from same group */
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pos_start != pos_next) {
|
||||
php_stream_seek(from->fp, pos_start, SEEK_SET);
|
||||
if (!php_stream_copy_to_stream(from->fp, dba->fp, pos_next - pos_start)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy [%d - %d] from temporary stream", pos_next, pos_start);
|
||||
ret = FAILURE;
|
||||
}
|
||||
}
|
||||
inifile_line_free(&ln);
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_delete_replace_append
|
||||
*/
|
||||
static int inifile_delete_replace_append(inifile *dba, const key_type *key, const val_type *value, int append TSRMLS_DC)
|
||||
{
|
||||
size_t pos_grp_start, pos_grp_next;
|
||||
inifile *ini_tmp = NULL;
|
||||
php_stream *fp_tmp = NULL;
|
||||
int ret;
|
||||
|
||||
/* 1) Search group start
|
||||
* 2) Search next group
|
||||
* 3) If not append: Copy group to ini_tmp
|
||||
* 4) Open temp_stream and copy remainder
|
||||
* 5) Truncate stream
|
||||
* 6) If not append AND key.name given: Filtered copy back from ini_tmp
|
||||
* to stream. Otherwise the user wanted to delete the group.
|
||||
* 7) Append value if given
|
||||
* 8) Append temporary stream
|
||||
*/
|
||||
|
||||
assert(!append || (key->name && value)); /* missuse */
|
||||
|
||||
/* 1 - 3 */
|
||||
inifile_find_group(dba, key, &pos_grp_start TSRMLS_CC);
|
||||
inifile_next_group(dba, key, &pos_grp_next TSRMLS_CC);
|
||||
if (append) {
|
||||
ret = SUCCESS;
|
||||
} else {
|
||||
ret = inifile_copy_to(dba, pos_grp_start, pos_grp_next, &ini_tmp TSRMLS_CC);
|
||||
}
|
||||
|
||||
/* 4 */
|
||||
if (ret == SUCCESS) {
|
||||
fp_tmp = php_stream_temp_create(0, 64 * 1024);
|
||||
if (!fp_tmp) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not create temporary stream");
|
||||
ret = FAILURE;
|
||||
} else {
|
||||
php_stream_seek(dba->fp, 0, SEEK_END);
|
||||
if (pos_grp_next != php_stream_tell(dba->fp)) {
|
||||
php_stream_seek(dba->fp, pos_grp_next, SEEK_SET);
|
||||
if (!php_stream_copy_to_stream(dba->fp, fp_tmp, PHP_STREAM_COPY_ALL)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy remainder to temporary stream");
|
||||
ret = FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 5 */
|
||||
if (ret == SUCCESS) {
|
||||
ret = inifile_truncate(dba, append ? pos_grp_next : pos_grp_start TSRMLS_CC); /* writes error on fail */
|
||||
}
|
||||
|
||||
if (ret == SUCCESS) {
|
||||
if (key->name && strlen(key->name)) {
|
||||
/* 6 */
|
||||
if (!append && ini_tmp) {
|
||||
ret = inifile_filter(dba, ini_tmp, key TSRMLS_CC);
|
||||
}
|
||||
|
||||
/* 7 */
|
||||
/* important: do not query ret==SUCCESS again: inifile_filter might fail but
|
||||
* however next operation must be done.
|
||||
*/
|
||||
if (value) {
|
||||
if (pos_grp_start == pos_grp_next && key->group && strlen(key->group)) {
|
||||
php_stream_printf(dba->fp TSRMLS_CC, "[%s]\n", key->group);
|
||||
}
|
||||
php_stream_printf(dba->fp TSRMLS_CC, "%s=%s\n", key->name, value->value ? value->value : "");
|
||||
}
|
||||
}
|
||||
|
||||
/* 8 */
|
||||
/* important: do not query ret==SUCCESS again: inifile_filter might fail but
|
||||
* however next operation must be done.
|
||||
*/
|
||||
if (fp_tmp && php_stream_tell(fp_tmp)) {
|
||||
php_stream_seek(fp_tmp, 0, SEEK_SET);
|
||||
php_stream_seek(dba->fp, 0, SEEK_END);
|
||||
if (!php_stream_copy_to_stream(fp_tmp, dba->fp, PHP_STREAM_COPY_ALL)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not copy from temporary stream - ini file truncated");
|
||||
ret = FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ini_tmp) {
|
||||
php_stream_close(ini_tmp->fp);
|
||||
inifile_free(ini_tmp, 0);
|
||||
}
|
||||
if (fp_tmp) {
|
||||
php_stream_close(fp_tmp);
|
||||
}
|
||||
php_stream_flush(dba->fp);
|
||||
php_stream_seek(dba->fp, 0, SEEK_SET);
|
||||
|
||||
return ret;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_delete
|
||||
*/
|
||||
int inifile_delete(inifile *dba, const key_type *key TSRMLS_DC)
|
||||
{
|
||||
return inifile_delete_replace_append(dba, key, NULL, 0 TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_relace
|
||||
*/
|
||||
int inifile_replace(inifile *dba, const key_type *key, const val_type *value TSRMLS_DC)
|
||||
{
|
||||
return inifile_delete_replace_append(dba, key, value, 0 TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_append
|
||||
*/
|
||||
int inifile_append(inifile *dba, const key_type *key, const val_type *value TSRMLS_DC)
|
||||
{
|
||||
return inifile_delete_replace_append(dba, key, value, 1 TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| 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 <helly@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $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
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef PHP_INIFILE_H
|
||||
#define PHP_INIFILE_H
|
||||
|
||||
#if DBA_INIFILE
|
||||
|
||||
#include "php_dba.h"
|
||||
|
||||
DBA_FUNCS(inifile);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,29 +0,0 @@
|
||||
--TEST--
|
||||
DBA INIFILE handler test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = 'inifile';
|
||||
require_once('skipif.inc');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$handler = 'inifile';
|
||||
require_once('test.inc');
|
||||
require_once('dba_handler.inc');
|
||||
?>
|
||||
--EXPECT--
|
||||
database handler: inifile
|
||||
3NYNYY
|
||||
Content String 2
|
||||
Content 2 replaced
|
||||
Read during write: not allowed
|
||||
Content 2 replaced 2nd time
|
||||
The 6th value
|
||||
array(3) {
|
||||
["key number 6"]=>
|
||||
string(13) "The 6th value"
|
||||
["key2"]=>
|
||||
string(27) "Content 2 replaced 2nd time"
|
||||
["key5"]=>
|
||||
string(23) "The last content string"
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
sqlite
|
||||
Wez Furlong, Tal Peer, Marcus Börger
|
||||
@@ -1,14 +0,0 @@
|
||||
This is an extension for the SQLite Embeddable SQL Database Engine.
|
||||
http://www.sqlite.org/
|
||||
|
||||
SQLite is a C library that implements an embeddable SQL database engine.
|
||||
Programs that link with the SQLite library can have SQL database access
|
||||
without running a separate RDBMS process.
|
||||
|
||||
SQLite is not a client library used to connect to a big database server.
|
||||
SQLite is the server. The SQLite library reads and writes directly to and from
|
||||
the database files on disk
|
||||
|
||||
|
||||
|
||||
vim:tw=78:et
|
||||
@@ -1,22 +0,0 @@
|
||||
- Transparent binary encoding of return values from PHP callback functions.
|
||||
|
||||
- Add user-space callback for the authorizer function (this is potentially
|
||||
very slow, so it needs to be implemented carefully).
|
||||
|
||||
- Add user-space callback to handle busy databases.
|
||||
|
||||
- Test-suite
|
||||
|
||||
o Test how robust we are when a user-space function is registered as
|
||||
a callback for a persistent connection in script A, then script B is
|
||||
called that doesn't register the callback but does make use of the
|
||||
function in an SQL query.
|
||||
--> Our test suite doesn't allow us to test persistent connections
|
||||
at this time :/
|
||||
|
||||
- If building a ZTS build, -DTHREADSAFE while compiling libsqlite
|
||||
|
||||
- If building a non-debug build, -DNDEBUG will disable the expensive
|
||||
asserts in the inner loop. (and double performance)
|
||||
|
||||
vim:tw=78
|
||||
@@ -1,37 +0,0 @@
|
||||
This directory contains source code to
|
||||
|
||||
SQLite: An Embeddable SQL Database Engine
|
||||
|
||||
To compile the project, first create a directory in which to place
|
||||
the build products. It is recommended, but not required, that the
|
||||
build directory be separate from the source directory. Cd into the
|
||||
build directory and then from the build directory run the configure
|
||||
script found at the root of the source tree. Then run "make".
|
||||
|
||||
For example:
|
||||
|
||||
tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite"
|
||||
mkdir bld ;# Build will occur in a sibling directory
|
||||
cd bld ;# Change to the build directory
|
||||
../sqlite/configure ;# Run the configure script
|
||||
make ;# Run the makefile.
|
||||
|
||||
The configure script uses autoconf 2.50 and libtool. If the configure
|
||||
script does not work out for you, there is a generic makefile named
|
||||
"Makefile.linux-gcc" in the top directory of the source tree that you
|
||||
can copy and edit to suite your needs. Comments on the generic makefile
|
||||
show what changes are needed.
|
||||
|
||||
The linux binaries on the website are created using the generic makefile,
|
||||
not the configure script. The configure script is unmaintained. (You
|
||||
can volunteer to take over maintenance of the configure script, if you want!)
|
||||
The windows binaries on the website are created using MinGW32 configured
|
||||
as a cross-compiler running under Linux. For details, see the ./publish.sh
|
||||
script at the top-level of the source tree.
|
||||
|
||||
Contacts:
|
||||
|
||||
http://www.sqlite.org/
|
||||
http://www.hwaci.com/sw/sqlite/
|
||||
http://groups.yahoo.com/group/sqlite/
|
||||
drh@hwaci.com
|
||||
@@ -1,8 +0,0 @@
|
||||
#include "config.w32.h"
|
||||
#if ZTS
|
||||
# define THREADSAFE 1
|
||||
#endif
|
||||
#if !ZEND_DEBUG && !defined(NDEBUG)
|
||||
# define NDEBUG
|
||||
#endif
|
||||
#define SQLITE_PTR_SZ 4
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
if (!extension_loaded("sqlite")) {
|
||||
dl("sqlite.so");
|
||||
}
|
||||
|
||||
debug_zval_dump(sqlite_libversion());
|
||||
debug_zval_dump(sqlite_libencoding());
|
||||
|
||||
$s = sqlite_open("weztest.sqlite", 0666, $err);
|
||||
|
||||
debug_zval_dump($err);
|
||||
debug_zval_dump($s);
|
||||
|
||||
$r = sqlite_query("create table foo (a INTEGER PRIMARY KEY, b INTEGER )", $s);
|
||||
debug_zval_dump(sqlite_last_error($s));
|
||||
debug_zval_dump(sqlite_error_string(sqlite_last_error($s)));
|
||||
|
||||
$r = sqlite_query("select *, php('md5', sql) as o from sqlite_master", $s);
|
||||
debug_zval_dump($r);
|
||||
debug_zval_dump(sqlite_num_rows($r));
|
||||
debug_zval_dump(sqlite_num_fields($r));
|
||||
|
||||
for ($j = 0; $j < sqlite_num_fields($r); $j++) {
|
||||
echo "Field $j is " . sqlite_field_name($r, $j) . "\n";
|
||||
}
|
||||
|
||||
while ($row = sqlite_fetch_array($r, SQLITE_ASSOC)) {
|
||||
print_r($row);
|
||||
}
|
||||
|
||||
sqlite_close($s);
|
||||
|
||||
?>
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php #vim:ft=php
|
||||
$dbname = tempnam(dirname(__FILE__), "phpsql");
|
||||
function cleanup() {
|
||||
if ($GLOBALS['db']) {
|
||||
sqlite_close($GLOBALS['db']);
|
||||
}
|
||||
unlink($GLOBALS['dbname']);
|
||||
}
|
||||
register_shutdown_function("cleanup");
|
||||
$db = sqlite_open($dbname);
|
||||
?>
|
||||
@@ -1,17 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: sqlite_open/close
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once('blankdb.inc');
|
||||
echo "$db\n";
|
||||
sqlite_close($db);
|
||||
$db = NULL;
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Resource id #%d
|
||||
Done
|
||||
@@ -1,31 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: Simple insert/select
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
sqlite_query("CREATE TABLE foo(c1 date, c2 time, c3 varchar(64))", $db);
|
||||
sqlite_query("INSERT INTO foo VALUES ('2002-01-02', '12:49:00', NULL)", $db);
|
||||
$r = sqlite_query("SELECT * from foo", $db);
|
||||
var_dump(sqlite_fetch_array($r));
|
||||
?>
|
||||
--EXPECT--
|
||||
array(6) {
|
||||
[0]=>
|
||||
string(10) "2002-01-02"
|
||||
["c1"]=>
|
||||
string(10) "2002-01-02"
|
||||
[1]=>
|
||||
string(8) "12:49:00"
|
||||
["c2"]=>
|
||||
string(8) "12:49:00"
|
||||
[2]=>
|
||||
NULL
|
||||
["c3"]=>
|
||||
NULL
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: Simple insert/select, different result represenatation
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
sqlite_query("CREATE TABLE foo(c1 date, c2 time, c3 varchar(64))", $db);
|
||||
sqlite_query("INSERT INTO foo VALUES ('2002-01-02', '12:49:00', NULL)", $db);
|
||||
$r = sqlite_query("SELECT * from foo", $db);
|
||||
var_dump(sqlite_fetch_array($r, SQLITE_BOTH));
|
||||
$r = sqlite_query("SELECT * from foo", $db);
|
||||
var_dump(sqlite_fetch_array($r, SQLITE_NUM));
|
||||
$r = sqlite_query("SELECT * from foo", $db);
|
||||
var_dump(sqlite_fetch_array($r, SQLITE_ASSOC));
|
||||
?>
|
||||
--EXPECT--
|
||||
array(6) {
|
||||
[0]=>
|
||||
string(10) "2002-01-02"
|
||||
["c1"]=>
|
||||
string(10) "2002-01-02"
|
||||
[1]=>
|
||||
string(8) "12:49:00"
|
||||
["c2"]=>
|
||||
string(8) "12:49:00"
|
||||
[2]=>
|
||||
NULL
|
||||
["c3"]=>
|
||||
NULL
|
||||
}
|
||||
array(3) {
|
||||
[0]=>
|
||||
string(10) "2002-01-02"
|
||||
[1]=>
|
||||
string(8) "12:49:00"
|
||||
[2]=>
|
||||
NULL
|
||||
}
|
||||
array(3) {
|
||||
["c1"]=>
|
||||
string(10) "2002-01-02"
|
||||
["c2"]=>
|
||||
string(8) "12:49:00"
|
||||
["c3"]=>
|
||||
NULL
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: binary encoding
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
$strings = array(
|
||||
"hello",
|
||||
"hello\x01o",
|
||||
"\x01hello there",
|
||||
"hello\x00there",
|
||||
""
|
||||
);
|
||||
|
||||
sqlite_query("CREATE TABLE strings(a)", $db);
|
||||
|
||||
foreach ($strings as $str) {
|
||||
sqlite_query("INSERT INTO strings VALUES('" . sqlite_escape_string($str) . "')", $db);
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$r = sqlite_query("SELECT * from strings", $db);
|
||||
while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
|
||||
if ($row[0] !== $strings[$i]) {
|
||||
echo "FAIL!\n";
|
||||
var_dump($row[0]);
|
||||
var_dump($strings[$i]);
|
||||
} else {
|
||||
echo "OK!\n";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
echo "DONE!\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
OK!
|
||||
OK!
|
||||
OK!
|
||||
OK!
|
||||
OK!
|
||||
DONE!
|
||||
@@ -1,47 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: aggregate functions
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
$data = array(
|
||||
"one",
|
||||
"two",
|
||||
"three"
|
||||
);
|
||||
|
||||
sqlite_query("CREATE TABLE strings(a)", $db);
|
||||
|
||||
foreach ($data as $str) {
|
||||
sqlite_query("INSERT INTO strings VALUES('" . sqlite_escape_string($str) . "')", $db);
|
||||
}
|
||||
|
||||
function cat_step(&$context, $string)
|
||||
{
|
||||
$context .= $string;
|
||||
}
|
||||
|
||||
function cat_fin(&$context)
|
||||
{
|
||||
return $context;
|
||||
}
|
||||
|
||||
sqlite_create_aggregate($db, "cat", "cat_step", "cat_fin");
|
||||
|
||||
$r = sqlite_query("SELECT cat(a) from strings", $db);
|
||||
while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
|
||||
var_dump($row);
|
||||
}
|
||||
echo "DONE!\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(11) "onetwothree"
|
||||
}
|
||||
DONE!
|
||||
@@ -1,52 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: regular functions
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
$data = array(
|
||||
array("one", "uno"),
|
||||
array("two", "dos"),
|
||||
array("three", "tres"),
|
||||
);
|
||||
|
||||
sqlite_query("CREATE TABLE strings(a,b)", $db);
|
||||
|
||||
function implode_args()
|
||||
{
|
||||
$args = func_get_args();
|
||||
$sep = array_shift($args);
|
||||
return implode($sep, $args);
|
||||
}
|
||||
|
||||
foreach ($data as $row) {
|
||||
sqlite_query("INSERT INTO strings VALUES('" . sqlite_escape_string($row[0]) . "','" . sqlite_escape_string($row[1]) . "')", $db);
|
||||
}
|
||||
|
||||
sqlite_create_function($db, "implode", "implode_args");
|
||||
|
||||
$r = sqlite_query("SELECT implode('-', a, b) from strings", $db);
|
||||
while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
|
||||
var_dump($row);
|
||||
}
|
||||
echo "DONE!\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(7) "one-uno"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(7) "two-dos"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(10) "three-tres"
|
||||
}
|
||||
DONE!
|
||||
@@ -1,51 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: Simple insert/select (unbuffered)
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
sqlite_query("CREATE TABLE foo(c1 date, c2 time, c3 varchar(64))", $db);
|
||||
sqlite_query("INSERT INTO foo VALUES ('2002-01-02', '12:49:00', NULL)", $db);
|
||||
$r = sqlite_unbuffered_query("SELECT * from foo", $db);
|
||||
var_dump(sqlite_fetch_array($r, SQLITE_BOTH));
|
||||
$r = sqlite_unbuffered_query("SELECT * from foo", $db);
|
||||
var_dump(sqlite_fetch_array($r, SQLITE_NUM));
|
||||
$r = sqlite_unbuffered_query("SELECT * from foo", $db);
|
||||
var_dump(sqlite_fetch_array($r, SQLITE_ASSOC));
|
||||
?>
|
||||
--EXPECT--
|
||||
array(6) {
|
||||
[0]=>
|
||||
string(10) "2002-01-02"
|
||||
["c1"]=>
|
||||
string(10) "2002-01-02"
|
||||
[1]=>
|
||||
string(8) "12:49:00"
|
||||
["c2"]=>
|
||||
string(8) "12:49:00"
|
||||
[2]=>
|
||||
NULL
|
||||
["c3"]=>
|
||||
NULL
|
||||
}
|
||||
array(3) {
|
||||
[0]=>
|
||||
string(10) "2002-01-02"
|
||||
[1]=>
|
||||
string(8) "12:49:00"
|
||||
[2]=>
|
||||
NULL
|
||||
}
|
||||
array(3) {
|
||||
["c1"]=>
|
||||
string(10) "2002-01-02"
|
||||
["c2"]=>
|
||||
string(8) "12:49:00"
|
||||
["c3"]=>
|
||||
NULL
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: fetch all (buffered)
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
$data = array(
|
||||
"one",
|
||||
"two",
|
||||
"three"
|
||||
);
|
||||
|
||||
sqlite_query("CREATE TABLE strings(a VARCHAR)", $db);
|
||||
|
||||
foreach ($data as $str) {
|
||||
sqlite_query("INSERT INTO strings VALUES('$str')", $db);
|
||||
}
|
||||
|
||||
$r = sqlite_query("SELECT a from strings", $db);
|
||||
while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
|
||||
var_dump($row);
|
||||
}
|
||||
echo "DONE!\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "one"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "two"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(5) "three"
|
||||
}
|
||||
DONE!
|
||||
@@ -1,43 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: fetch all (unbuffered)
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
$data = array(
|
||||
"one",
|
||||
"two",
|
||||
"three"
|
||||
);
|
||||
|
||||
sqlite_query("CREATE TABLE strings(a VARCHAR)", $db);
|
||||
|
||||
foreach ($data as $str) {
|
||||
sqlite_query("INSERT INTO strings VALUES('$str')", $db);
|
||||
}
|
||||
|
||||
$r = sqlite_unbuffered_query("SELECT a from strings", $db);
|
||||
while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
|
||||
var_dump($row);
|
||||
}
|
||||
echo "DONE!\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "one"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "two"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(5) "three"
|
||||
}
|
||||
DONE!
|
||||
@@ -1,78 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: fetch all (iterator)
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
$data = array(
|
||||
"one",
|
||||
"two",
|
||||
"three"
|
||||
);
|
||||
|
||||
sqlite_query("CREATE TABLE strings(a VARCHAR)", $db);
|
||||
|
||||
foreach ($data as $str) {
|
||||
sqlite_query("INSERT INTO strings VALUES('$str')", $db);
|
||||
}
|
||||
|
||||
$r = sqlite_unbuffered_query("SELECT a from strings", $db);
|
||||
while (sqlite_has_more($r)) {
|
||||
var_dump(sqlite_current($r, SQLITE_NUM));
|
||||
sqlite_next($r);
|
||||
}
|
||||
$r = sqlite_query("SELECT a from strings", $db);
|
||||
while (sqlite_has_more($r)) {
|
||||
var_dump(sqlite_current($r, SQLITE_NUM));
|
||||
sqlite_next($r);
|
||||
}
|
||||
sqlite_rewind($r);
|
||||
while (sqlite_has_more($r)) {
|
||||
var_dump(sqlite_current($r, SQLITE_NUM));
|
||||
sqlite_next($r);
|
||||
}
|
||||
echo "DONE!\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "one"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "two"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(5) "three"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "one"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "two"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(5) "three"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "one"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "two"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(5) "three"
|
||||
}
|
||||
DONE!
|
||||
@@ -1,27 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: returned associative column names
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
sqlite_query("CREATE TABLE foo (c1 char, c2 char, c3 char)", $db);
|
||||
sqlite_query("CREATE TABLE bar (c1 char, c2 char, c3 char)", $db);
|
||||
sqlite_query("INSERT INTO foo VALUES ('1', '2', '3')", $db);
|
||||
sqlite_query("INSERT INTO bar VALUES ('4', '5', '6')", $db);
|
||||
$r = sqlite_query("SELECT * from foo, bar", $db, SQLITE_ASSOC);
|
||||
var_dump(sqlite_fetch_array($r));
|
||||
?>
|
||||
--EXPECT--
|
||||
array(3) {
|
||||
["c1"]=>
|
||||
string(1) "4"
|
||||
["c2"]=>
|
||||
string(1) "5"
|
||||
["c3"]=>
|
||||
string(1) "6"
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: read field names
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
sqlite_query("CREATE TABLE strings(foo VARCHAR, bar VARCHAR, baz VARCHAR)", $db);
|
||||
|
||||
echo "Buffered\n";
|
||||
$r = sqlite_query("SELECT * from strings", $db);
|
||||
for($i=0; $i<sqlite_num_fields($r); $i++) {
|
||||
var_dump(sqlite_field_name($r, $i));
|
||||
}
|
||||
echo "Unbuffered\n";
|
||||
$r = sqlite_unbuffered_query("SELECT * from strings", $db);
|
||||
for($i=0; $i<sqlite_num_fields($r); $i++) {
|
||||
var_dump(sqlite_field_name($r, $i));
|
||||
}
|
||||
echo "DONE!\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
Buffered
|
||||
string(3) "foo"
|
||||
string(3) "bar"
|
||||
string(3) "baz"
|
||||
Unbuffered
|
||||
string(3) "foo"
|
||||
string(3) "bar"
|
||||
string(3) "baz"
|
||||
DONE!
|
||||
+3
-3
@@ -2,6 +2,6 @@
|
||||
/* edit configure.in to change version number */
|
||||
#define PHP_MAJOR_VERSION 4
|
||||
#define PHP_MINOR_VERSION 3
|
||||
#define PHP_RELEASE_VERSION 3
|
||||
#define PHP_EXTRA_VERSION "-dev"
|
||||
#define PHP_VERSION "4.3.3-dev"
|
||||
#define PHP_RELEASE_VERSION 2
|
||||
#define PHP_EXTRA_VERSION "RC4"
|
||||
#define PHP_VERSION "4.3.2RC4"
|
||||
@@ -1,16 +0,0 @@
|
||||
--TEST--
|
||||
Bug #17115 (lambda functions produce segfault with static vars)
|
||||
--FILE--
|
||||
<?php
|
||||
$func = create_function('','
|
||||
static $foo = 0;
|
||||
return $foo++;
|
||||
');
|
||||
var_dump($func());
|
||||
var_dump($func());
|
||||
var_dump($func());
|
||||
?>
|
||||
--EXPECT--
|
||||
int(0)
|
||||
int(1)
|
||||
int(2)
|
||||
Reference in new issue
Block a user