Compare commits

..
1659 changed files with 84507 additions and 123120 deletions

No files matched your search

-285
View File
@@ -1,285 +0,0 @@
define dump_bt
set $t = $arg0
while $t
printf "[0x%08x] ", $t
if $t->function_state.function->common.function_name
printf "%s() ", $t->function_state.function->common.function_name
else
printf "??? "
end
if $t->op_array != 0
printf "%s:%d ", $t->op_array->filename, $t->opline->lineno
end
set $t = $t->prev_execute_data
printf "\n"
end
end
document dump_bt
dumps the current execution stack. usage: dump_bt executor_globals.current_execute_data
end
define printzv
set $ind = 0
____printzv $arg0 0
end
document printzv
prints content of zval
end
define ____printzv
set $zvalue = $arg0
if $zvalue->type == 0
set $typename = "NULL"
end
if $zvalue->type == 1
set $typename = "long"
end
if $zvalue->type == 2
set $typename = "double"
end
if $zvalue->type == 3
set $typename = "string"
end
if $zvalue->type == 4
set $typename = "array"
end
if $zvalue->type == 5
set $typename = "object"
end
if $zvalue->type == 6
set $typename = "bool"
end
if $zvalue->type == 7
set $typename = "resource"
end
if $zvalue->type == 8
set $typename = "constant"
end
if $zvalue->type == 9
set $typename = "const_array"
end
printf "[0x%08x] ", $zvalue
if $zvalue == executor_globals.uninitialized_zval_ptr
printf "*uninitialized* "
end
printf "(refcount=%d) %s: ", $zvalue->refcount, $typename
if $zvalue->type == 1
printf "%ld", $zvalue->value.lval
end
if $zvalue->type == 2
printf "%lf", $zvalue->value.dval
end
if $zvalue->type == 3
printf "\"%s\"(%d)", $zvalue->value.str.val, $zvalue->value.str.len
end
if $zvalue->type == 4
if ! $arg1
printf "{\n"
set $ind = $ind + 1
____print_ht $zvalue->value.ht
set $ind = $ind - 1
set $i = $ind
while $i > 0
printf " "
set $i = $i - 1
end
printf "}"
end
end
if $zvalue->type == 5
if ! $arg1
printf "(prop examination disabled due to a gdb bug)"
# set $ht = $zvalue->value.obj.handlers->get_properties($zvalue)
# printf "{\n"
# set $ind = $ind + 1
# ____print_ht $ht
# set $ind = $ind - 1
# set $i = $ind
# while $i > 0
# printf " "
# set $i = $i - 1
# end
# printf "}"
end
end
if $zvalue->type == 6
if $zvalue->lval
printf "true"
else
printf "false"
end
end
if $zvalue->type == 7
printf "#%d", $zvalue->value.lval
end
printf "\n"
end
define ____print_ht
set $ht = $arg0
set $p = $ht->pListHead
while $p != 0
set $zval = *(struct _zval_struct **)$p->pData
set $i = $ind
while $i > 0
printf " "
set $i = $i - 1
end
if $p->nKeyLength > 0
printf "\"%s\" => ", $p->arKey
else
printf "%d => ", $p->h
end
____printzv $zval 1
set $p = $p->pListNext
end
end
define print_ht
set $ind = 1
printf "[0x%08x] {\n", $arg0
____print_ht $arg0
printf "}\n"
end
document print_ht
dumps elements of HashTable made of zval
end
define printzn
set $ind = 0
set $znode = $arg0
if $znode->op_type == 1
set $optype = "IS_CONST"
end
if $znode->op_type == 2
set $optype = "IS_TMP_VAR"
end
if $znode->op_type == 4
set $optype = "IS_VAR"
end
if $znode->op_type == 8
set $optype = "IS_UNUSED"
end
printf "[0x%08x] %s", $znode, $optype
if $znode->op_type == 1
printf ": "
____printzv &$znode->u.constant
end
if $znode->op_type == 2
printf ": "
set $tvar = (union _temp_variable *)((char *)executor_globals.current_execute_data->Ts + $znode->u.var)
____printzv ((union _temp_variable *)$tvar)->tmp_var
end
if $znode->op_type == 4
printf ": "
set $tvar = (union _temp_variable *)((char *)executor_globals.current_execute_data->Ts + $znode->u.var)
____printzv *$tvar->var.ptr_ptr
end
if $znode->op_type == 8
printf "\n"
end
end
document printzn
print type and content of znode.
usage: printzn &opline->op1
end
define printzops
printf "op1 => "
printzn &execute_data->opline.op1
printf "op2 => "
printzn &execute_data->opline.op2
printf "result => "
printzn &execute_data->opline.result
end
document printzops
dump operands of the current opline
end
define zmemcheck
set $p = alloc_globals.head
set $stat = "?"
set $total_size = 0
if $arg0 != 0
set $not_found = 1
else
set $not_found = 0
end
printf " block size status file:line\n"
printf "-------------------------------------------------------------------------------\n"
while $p
set $aptr = $p + sizeof(struct _zend_mem_header) + sizeof(align_test)
if $arg0 == 0 || (void *)$aptr == (void *)$arg0
if $p->magic == 0x7312f8dc
set $stat = "OK"
end
if $p->magic == 0x99954317
set $stat = "FREED"
end
if $p->magic == 0xfb8277dc
set $stat = "CACHED"
end
set $filename = strrchr($p->filename, '/')
if !$filename
set $filename = $p->filename
else
set $filename = $filename + 1
end
printf " 0x%08x ", $aptr
if $p->size == sizeof(struct _zval_struct) && ((struct _zval_struct *)$aptr)->type >= 0 && ((struct _zval_struct *)$aptr)->type < 10
printf "ZVAL?(%-2d) ", $p->size
else
printf "%-9d ", $p->size
end
set $total_size = $total_size + $p->size
printf "%-06s %s:%d", $stat, $filename, $p->lineno
if $p->orig_filename
set $orig_filename = strrchr($p->orig_filename, '/')
if !$orig_filename
set $orig_filename = $p->orig_filename
else
set $orig_filename = $orig_filename + 1
end
printf " <= %s:%d\n", $orig_filename, $p->orig_lineno
else
printf "\n"
end
if $arg0 != 0
set $p = 0
set $not_found = 0
else
set $p = $p->pNext
end
else
set $p = $p->pNext
end
end
if $not_found
printf "no such block that begins at 0x%08x.\n", $aptr
end
if $arg0 == 0
printf "-------------------------------------------------------------------------------\n"
printf " total: %d bytes\n", $total_size
end
end
document zmemcheck
show status of a memory block.
usage: zmemcheck [ptr].
if ptr is 0, all blocks will be listed.
end
-7316
View File
File diff suppressed because it is too large. Load diff
+9 -18
View File
@@ -31,11 +31,6 @@ EXTENSION: aolserver
MAINTENANCE: Unknown
STATUS: Unknown
-------------------------------------------------------------------------------
EXTENSION: activescript
PRIMARY MAINTAINER: Wez Furlong <wez@php.net>
MAINTENANCE: Odd Fixes
STATUS: Experimental
-------------------------------------------------------------------------------
EXTENSION: apache
PRIMARY MAINTAINER: Rasmus Lerdorf <rasmus@php.net>
MAINTENANCE: Maintained
@@ -50,10 +45,6 @@ EXTENSION: cgi
MAINTENANCE: Unknown
STATUS: Working
-------------------------------------------------------------------------------
EXTENSION: cli
MAINTENANCE: Unknown
STATUS: Working
-------------------------------------------------------------------------------
EXTENSION: fhttpd
MAINTENANCE: Unknown
STATUS: Unknown
@@ -63,9 +54,8 @@ MAINTENANCE: Unknown
STATUS: Working
-------------------------------------------------------------------------------
EXTENSION: nsapi
PRIMARY MAINTAINER: Uwe Schindler <thetaphi@php.net>
MAINTENANCE: Maintained
STATUS: Working
MAINTENANCE: Unknown
STATUS: Unknown
-------------------------------------------------------------------------------
EXTENSION: phttpd
MAINTENANCE: Unknown
@@ -99,7 +89,7 @@ STATUS: Experimental
-------------------------------------------------------------------------------
EXTENSION: dba
PRIMARY MAINTAINER: Marcus Börger <helly@php.net>
PRIMARY MAINTAINER: Sascha Schumann <sascha@schumann.cx>
MAINTENANCE: Maintained
STATUS: Working
-------------------------------------------------------------------------------
@@ -136,7 +126,7 @@ STATUS: Experimental
SINCE: 4.0.2
-------------------------------------------------------------------------------
EXTENSION: interbase
PRIMARY MAINTAINER: Jouni Ahto <jouni.ahto@exdec.fi>, Ard Biesheuvel <ard@ard.nu>
PRIMARY MAINTAINER: Jouni Ahto <jouni.ahto@exdec.fi>
MAINTENANCE: Odd Fixes
STATUS: Working
-------------------------------------------------------------------------------
@@ -176,7 +166,7 @@ MAINTENANCE: Unknown
STATUS: Working
-------------------------------------------------------------------------------
EXTENSION: oci8
PRIMARY MAINTAINER: Antony Dovgal <tony2001@php.net>
PRIMARY MAINTAINER: Thies C. Arntzen <thies@thieso.net>
MAINTENANCE: Maintained
STATUS: Working
-------------------------------------------------------------------------------
@@ -187,7 +177,8 @@ STATUS: Working
COMMENT: Working
-------------------------------------------------------------------------------
EXTENSION: oracle
MAINTENANCE: Orphaned
PRIMARY MAINTAINER: Thies C. Arntzen <thies@thieso.net>
MAINTENANCE: Maintained
STATUS: Working
COMMENT: Using the new OCI8 driver is encouraged where possible.
-------------------------------------------------------------------------------
@@ -262,7 +253,7 @@ STATUS: Unknown
EXTENSION: domxml
PRIMARY MAINTAINER: Uwe Steinmann <steinm@php.net>
MAINTENANCE: Maintained
STATUS: Working
STATUS: Experimental
-------------------------------------------------------------------------------
EXTENSION: dotnet
PRIMARY MAINTAINER: Sam Ruby <rubys@us.ibm.com>
@@ -339,7 +330,7 @@ MAINTENANCE: Odd Fixes
STATUS: Working
-------------------------------------------------------------------------------
EXTENSION: mcrypt
PRIMARY MAINTAINER: Derick Rethans <derick@derickrethans.nl>
PRIMARY MAINTAINER: Derick Rethans <d.rethans@jdimedia.nl>
MAINTENANCE: Maintained
STATUS: Working
-------------------------------------------------------------------------------
+354 -1462
View File
File diff suppressed because it is too large. Load diff
-5
View File
@@ -1,8 +1,3 @@
#
# Zend
#
$(builddir)/zend_language_scanner.lo: $(builddir)/zend_language_parser.h
$(builddir)/zend_ini_scanner.lo: $(builddir)/zend_ini_parser.h
+16 -26
View File
@@ -7,24 +7,20 @@ COMMON_FLAGS = $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(PHP_FRAMEWORK
all: $(all_targets)
@echo
@echo "Build complete."
@echo "(It is safe to ignore warnings about tempnam and tmpnam)."
@echo
build-modules: $(PHP_MODULES)
libphp4.la: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@
-@$(LIBTOOL) --silent --mode=install cp libphp4.la $(phptempdir)/libphp4.la >/dev/null 2>&1
libs/libphp4.bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
$(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ && cp $@ libs/libphp4.so
install: $(all_targets) $(install_targets)
install: $(install_targets)
install-sapi: $(OVERALL_TARGET)
@echo "Installing PHP SAPI module: $(PHP_SAPI)"
install-sapi: libphp4.la
@echo "Installing PHP SAPI module"
-@$(LIBTOOL) --silent --mode=install cp libphp4.la $(phptempdir)/libphp4.la >/dev/null 2>&1
-@$(mkinstalldirs) $(INSTALL_ROOT)$(bindir)
-@if test ! -r $(phptempdir)/libphp4.$(SHLIB_SUFFIX_NAME); then \
for i in 0.0.0 0.0 0; do \
@@ -38,10 +34,10 @@ install-sapi: $(OVERALL_TARGET)
install-modules: build-modules
@test -d modules && \
$(mkinstalldirs) $(INSTALL_ROOT)$(EXTENSION_DIR)
@echo "Installing shared extensions: $(INSTALL_ROOT)$(EXTENSION_DIR)/"
@rm -f modules/*.la >/dev/null 2>&1
@$(INSTALL) modules/* $(INSTALL_ROOT)$(EXTENSION_DIR)
$(mkinstalldirs) $(INSTALL_ROOT)$(EXTENSION_DIR) && \
echo "Installing shared extensions: $(INSTALL_ROOT)$(EXTENSION_DIR)/" && \
rm -f modules/*.la && \
cp modules/* $(INSTALL_ROOT)$(EXTENSION_DIR) >/dev/null 2>&1 || true
install-tester:
@echo "Installing regression tester: $(INSTALL_ROOT)$(PEAR_INSTALLDIR)/"
@@ -50,21 +46,15 @@ install-tester:
install-su: install-pear install-tester
test:
-@if test -x $(SAPI_CLI_PATH) && test ! -z $(SAPI_CLI_PATH); then \
TEST_PHP_EXECUTABLE=$(top_builddir)/$(SAPI_CLI_PATH) \
TEST_PHP_SRCDIR=$(top_srcdir) \
CC="$(CC)" \
$(top_builddir)/$(SAPI_CLI_PATH) -d 'open_basedir=' -d 'safe_mode=0' -d 'output_buffering=0' $(top_srcdir)/run-tests.php $(TESTS); \
else \
echo "ERROR: Cannot run tests without CLI sapi."; \
fi
test: $(SAPI_CLI_PATH)
@TEST_PHP_EXECUTABLE=$(top_builddir)/$(SAPI_CLI_PATH) \
TEST_PHP_SRCDIR=$(top_srcdir) \
CC=$(CC) \
$(top_builddir)/$(SAPI_CLI_PATH) -d 'open_basedir=' -d 'safe_mode=0' $(top_srcdir)/run-tests.php $(TESTS)
clean:
find . -name \*.lo | xargs rm -f
find . -name \*.o | xargs rm -f
find . -name \*.la | xargs rm -f
find . -name \*.a | xargs rm -f
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp4.la $(SAPI_CLI_PATH) $(OVERALL_TARGET) modules/* libs/*
+69 -1106
View File
File diff suppressed because it is too large. Load diff
+18 -10
View File
@@ -37,11 +37,8 @@ The next few rules are more of a technical nature.
messages every day. Woe be to those who attempt to mess with it.
2. All news updates intended for public viewing, such as new features,
bug fixes, improvements, etc., should go into the NEWS file.
NB! Lines, starting with @ will go automagically into NEWS file, but
this is NOT recommended, though. Please, add news entries directly to
NEWS file and don't forget to keep them adjusted and sorted.
bug fixes, improvements, etc., should go into the NEWS file. Also see
the note below about automatically updating NEWS in your commit message.
3. Do not commit multiple file and dump all messages in one commit. If you
modified several unrelated files, commit each group separately and
@@ -62,10 +59,14 @@ The next few rules are more of a technical nature.
The format of the commit messages is pretty simple.
If a line begins with #, it is taken to be a comment and will not appear
in the ChangeLog. Everything else goes into the ChangeLog.
in the ChangeLog. If the line begins with @, it will be redirected to the
NEWS file. Everything else goes into the ChangeLog.
It is important to note that if your comment or news logline spans multiple
lines, you have to put # at the beginning of _every_ such line.
lines, you have to put # or @ at the beginning of _every_ such line. Every
entry in NEWS has to have a name after it, so if you did it with someone's
help, put both your names there. Your name WILL NOT be automatically put
at the end of the NEWS entry - so, please provide it yourself.
Example. Say you modified two files, datetime.c and string.c. In datetime.c
you added a new format option for date() function, and in string.c you fixed
@@ -77,12 +78,17 @@ For datetime.c:
(PHP date) Added new 'K' format modifier for printing out number of
days until New Year's Eve.
@- Added new 'K' format modifier that will output the number of days
@ until New Year's Eve. (Bob)
For string.c:
(php_trim) Fixed a memory leak resulting from improper use of zval_dtor().
# Man, that thing was leaking all over the place!
@- Fixed memory leak in trim(). (Bob)
The # lines will be omitted from the ChangeLog automagically.
The lines above marked with @ will go into NEWS file automagically, and the
# lines will be omitted from the ChangeLog. Alternatively, you might want
to modify NEWS file directly and not use the @ lines.
If you fix some bugs, you should note the bug ID numbers in your
commit message. Bug ID should be prefixed by "#" for easier access to
@@ -91,10 +97,12 @@ bug report when developers are browsing CVS via. LXR or Bonsai.
Example:
Fixed pgsql notice handler double free crash bug. Bug #14016
@ Fixed pgsql notice handler double free crash bug. Bug #14016
If you don't see your messages in ChangeLog right away, don't worry!
If you don't see your messages in ChangeLog and NEWS right away, don't worry!
These files are updated once a day, so your stuff will not show up until
somewhat later.
somewhat later. Don't go adding stuff to NEWS by hand if you already put @
lines in the commit message.
You can use LXR (http://lxr.php.net/) and Bonsai (http://bonsai.php.net/)
to look at PHP CVS repository in various ways.
+2 -8
View File
@@ -37,7 +37,7 @@ Note though that you might get little response, if your patch is
too hard to review.
If you would like change/add many lines, it is better to ask module
maintainer and/or internals@lists.php.net, or pear-dev@lists.php.net if
maintainer and/or php-dev@lists.php.net, or pear-dev@lists.php.net if
you are patching PEAR. Official module maintainers can be found in
EXTENSIONS file in PHP source.
@@ -79,7 +79,7 @@ Check list for submitting patch
Where to send your patch?
-------------------------
If you are patching C source, send the patch to internals@lists.php.net.
If you are patching C source, send the patch to php-dev@lists.php.net.
If you are patching a module, you should also send the patch to the
maintainer. Official module maintainers are listed in EXTENSION file
in source.
@@ -88,11 +88,6 @@ If you are patching PEAR, send the patch to pear-dev@lists.php.net.
Please add the prefix "[PATCH]" to your email subject and make sure
to include the patch as a MIME attachment even if it is short.
NOTE: only MIME attachments of type 'text/*' are accepted. The
easiest way to acclomplish this, is to make the extension
'.txt'.
Test scripts should be included in the same email.
Explain what has been fixed/added/changed by your patch.
@@ -123,5 +118,4 @@ commit log. If your patch affects end-users, a brief description
and your name might be added to the NEWS file.
Thank you for submitting patch for PHP!
+7 -6
View File
@@ -43,6 +43,7 @@ global
(DONE ?)
* Use arg_separator.input to implode args in the CGI sapi extension
and arg_separator.input to explode in php_build_argv(). (DONE?)
* Implement flush feature suitable for nested output buffers.
For PHP 5.0.0
* bundle and use curl lib for fopen wrapper.
@@ -66,7 +67,6 @@ global
* find a better way to implement script timeouts. SIGVTALRM is used
by some POSIX threads implementations (i.e. OpenBSD) and is not
available in ZTS mode.
* Implement flush feature suitable for nested output buffers.
documentation
@@ -80,11 +80,11 @@ documentation
ext/bz2
-------
* Add an ini directive to specify the size of decompression buffer.
The default 4k is too small for large files and also requires much time
for decompression. 40k is suitable for such files, however it may be too
much under certain environments. There should be appropriate default
settings for the various SAPI modules (e.g. apache and cli).
* Add ini setting for decompression buffer size. The default 4k is to small
for big files and takes ages to decompress. However, 40k which perform
quite good with big files may be to much under certain environments as
default setting. There should be consideren different default sizes for
different SAPIS (e.g. apache and cli).
ext/curl
--------
@@ -158,6 +158,7 @@ ext/standard
basename()
dirname()
strrpos()
strip_tags()
ext/wddx
--------
+3
View File
@@ -0,0 +1,3 @@
- clean up .cvsignores
- purge Makefile.ins and replace PHP_EXTENSION in config.m4s
with appropiate calls to PHP_NEW_EXTENSION
-114
View File
@@ -1,114 +0,0 @@
This is an overview over existing segfaults in the current PHP source
tree.
Fixed:
mb_convert_encoding (Moriyoshi)
socket_iovec_alloc (Rasmus)
exif_imagetype,exif_thumbnail (Rasmus)
dbase_open (Rasmus)
array_pad (Rasmus)
setlocale (Rasmus)
unregister_tick_function (Rasmus)
bcsub (Rasmus)
str_repeat (Ilia)
imagecopyresized (Ilia)
mhash_keygen_s2k (Ilia)
bundled gd (Ilia)
mb_ereg, mb_ereg_match, mb_eregi, mb_split (Moriyoshi)
xml_parser_create (Moriyoshi)
ob_start (Sascha)
imagecreate/-truecolor (Sascha)
flock (Sascha)
register_shutdown_function (Sascha)
mb_strcut('', [number greater than the length of first arg]) (Moriyoshi)
ext/exif, ext/dba (Marcus)
php_base64_encode (Moriyoshi)
Open:
the dbase extension (1)
socket_select (2)
pack (3)
(1) heap corruption, mostly visible in malloc-related calls. Whether you see
this or not might depend on your libc/compiler. Hard to track down,
because the result of the corruption might be quite delayed.
Reproducable with glibc-2.3/gcc 3.2.2 by:
cat <<X | php do_crash
dbase_add_record
dbase_close
dbase_create
dbase_delete_record
dbase_get_record
dbase_get_record_with_names
dbase_numfields
dbase_numrecords
dbase_open
X
(2) heap corruption, dies in efree()/execute()
Methodology
1. Use a plain PHP_4_3 tree
2. Use the config.nice from ammendment 1.
3. Download the test script from:
<URL:http://schumann.cx/do_crash.txt>
4a. Use the scripts funcparse.awk/genfunclist.sh from phpdoc/scripts
for creating a plain text function list. Feed that list to
the script. Avoid calls like pcntl_fork. Manually remove functions
which take too long to finish/eat up all memory.
4b. For testing a single function, echo the name of the function to
the script like this:
echo dbase_open | php do_crash.txt
(3) multiple integer overflows, ex. pack("d4294967297", 2);
Amendment 1.
CFLAGS='-O0 -g' \
'../src/php4/configure' \
'--enable-pcntl' \
'--enable-shmop' \
'--enable-sysvsem' \
'--enable-sysvshm' \
'--enable-wddx' \
'--enable-yp' \
'--enable-filepro' \
'--enable-ftp' \
'--enable-dba' \
'--enable-dbase' \
'--enable-dio' \
'--enable-exif' \
'--enable-mbstring' \
'--enable-mbregex' \
'--enable-sockets' \
'--enable-bcmath' \
'--enable-calendar' \
'--enable-pcntl' \
'--enable-shmop' \
'--enable-sysvsem' \
'--enable-sysvshm' \
'--enable-wddx' \
'--enable-yp' \
'--enable-filepro' \
'--enable-ftp' \
'--enable-dba' \
'--enable-dbase' \
'--enable-dio' \
'--enable-exif' \
'--enable-mbstring' \
'--enable-mbregex' \
'--enable-sockets' \
'--enable-bcmath' \
'--enable-calendar' \
"$@"
+1 -12
View File
@@ -157,16 +157,7 @@ TSRM_API void tsrm_shutdown(void)
int j;
next_p = p->next;
for (j=0; j<p->count; j++) {
/* Disabled - calling dtors in tsrm_shutdown makes
modules registering TSRM ids to crash, if they have
dtors, since the module is unloaded before tsrm_shutdown
is called. Can be re-enabled after tsrm_free_id is
implemented.
if (resource_types_table && resource_types_table[j].dtor) {
resource_types_table[j].dtor(p->storage[j], &p->storage);
}
*/
for (j=0; j<id_count; j++) {
free(p->storage[j]);
}
free(p->storage);
@@ -190,7 +181,6 @@ TSRM_API void tsrm_shutdown(void)
#if defined(GNUPTH)
pth_kill();
#elif defined(PTHREADS)
pthread_setspecific(tls_key, 0);
pthread_key_delete(tls_key);
#elif defined(TSRM_WIN32)
TlsFree(tls_key);
@@ -491,7 +481,6 @@ TSRM_API void tsrm_mutex_free(MUTEX_T mutexp)
if (mutexp) {
#ifdef TSRM_WIN32
DeleteCriticalSection(mutexp);
free(mutexp);
#elif defined(NETWARE)
NXMutexFree(mutexp);
#elif defined(GNUPTH)
+2 -3
View File
@@ -95,15 +95,14 @@ dnl For the thread implementations, we always use --with-*
dnl to maintain consistency
AC_ARG_WITH(tsrm-pth,
[ --with-tsrm-pth[=pth-config]
Use GNU Pth.],[
[ --with-tsrm-pth[=pth-config] Use GNU Pth.],[
TSRM_PTH=$withval
],[
TSRM_PTH=no
])
AC_ARG_WITH(tsrm-st,
[ --with-tsrm-st Use SGI's State Threads],[
[ --with-tsrm-st],[
TSRM_ST=$withval
],[
TSRM_ST=no
-1
View File
@@ -3,7 +3,6 @@
#define HAVE_UTIME 1
#define HAVE_ALLOCA 1
#define HAVE_REALPATH 1
#include <malloc.h>
#include <stdlib.h>
+1 -1
View File
@@ -22,7 +22,7 @@
#ifndef __GNUC__
# ifndef HAVE_ALLOCA_H
# ifdef _AIX
#pragma alloca
#pragma alloca
# else
# ifndef alloca /* predefined by HP cc +Olibcalls */
char *alloca ();
+1 -1
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
+1 -1
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
+64 -118
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -92,7 +92,7 @@ static int php_check_dots(const char *element, int n)
(len >= 2 && !php_check_dots(element, len))
#define IS_DIRECTORY_CURRENT(element, len) \
(len == 1 && element[0] == '.')
(len == 1 && ptr[0] == '.')
#elif defined(NETWARE)
/* NetWare has strtok() (in LibC) and allows both slashes in paths, like Windows --
@@ -111,12 +111,12 @@ static int php_check_dots(const char *element, int n)
#ifndef IS_DIRECTORY_UP
#define IS_DIRECTORY_UP(element, len) \
(len == 2 && element[0] == '.' && element[1] == '.')
(len == 2 && memcmp(element, "..", 2) == 0)
#endif
#ifndef IS_DIRECTORY_CURRENT
#define IS_DIRECTORY_CURRENT(element, len) \
(len == 1 && element[0] == '.')
(len == 1 && ptr[0] == '.')
#endif
/* define this to check semantics */
@@ -301,22 +301,12 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
if (path_length == 0)
return (0);
if (path_length >= MAXPATHLEN)
return (1);
#if !defined(TSRM_WIN32) && !defined(NETWARE)
/* cwd_length can be 0 when getcwd() fails.
* This can happen under solaris when a dir does not have read permissions
* but *does* have execute permissions */
if (IS_ABSOLUTE_PATH(path, path_length) || (state->cwd_length < 1)) {
if (use_realpath) {
if (realpath(path, resolved_path)) {
path = resolved_path;
path_length = strlen(path);
} else {
/* disable for now
return 1; */
}
if (IS_ABSOLUTE_PATH(path, path_length)) {
if (use_realpath && realpath(path, resolved_path)) {
path = resolved_path;
path_length = strlen(path);
}
} else { /* Concat current directory with relative path and then run realpath() on it */
char *tmp;
@@ -332,19 +322,9 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
memcpy(ptr, path, path_length);
ptr += path_length;
*ptr = '\0';
if (strlen(tmp) >= MAXPATHLEN) {
free(tmp);
return 1;
}
if (use_realpath) {
if (realpath(tmp, resolved_path)) {
path = resolved_path;
path_length = strlen(path);
} else {
/* disable for now
free(tmp);
return 1; */
}
if (use_realpath && realpath(tmp, resolved_path)) {
path = resolved_path;
path_length = strlen(path);
}
free(tmp);
}
@@ -383,64 +363,58 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
}
if (state->cwd_length > 0 || IS_ABSOLUTE_PATH(path, path_length)) {
ptr = tsrm_strtok_r(path_copy, TOKENIZER_STRING, &tok);
while (ptr) {
ptr_length = strlen(ptr);
ptr = tsrm_strtok_r(path_copy, TOKENIZER_STRING, &tok);
while (ptr) {
ptr_length = strlen(ptr);
if (IS_DIRECTORY_UP(ptr, ptr_length)) {
char save;
if (IS_DIRECTORY_UP(ptr, ptr_length)) {
char save;
save = DEFAULT_SLASH;
save = DEFAULT_SLASH;
#define PREVIOUS state->cwd[state->cwd_length - 1]
while (IS_ABSOLUTE_PATH(state->cwd, state->cwd_length) &&
!IS_SLASH(PREVIOUS)) {
save = PREVIOUS;
PREVIOUS = '\0';
state->cwd_length--;
}
if (!IS_ABSOLUTE_PATH(state->cwd, state->cwd_length)) {
state->cwd[state->cwd_length++] = save;
state->cwd[state->cwd_length] = '\0';
} else {
PREVIOUS = '\0';
state->cwd_length--;
}
} else if (!IS_DIRECTORY_CURRENT(ptr, ptr_length)) {
state->cwd = (char *) realloc(state->cwd, state->cwd_length+ptr_length+1+1);
#ifdef TSRM_WIN32
/* Windows 9x will consider C:\\Foo as a network path. Avoid it. */
if ((state->cwd[state->cwd_length-1]!='\\' && state->cwd[state->cwd_length-1]!='/') ||
IsDBCSLeadByte(state->cwd[state->cwd_length-2])) {
state->cwd[state->cwd_length++] = DEFAULT_SLASH;
}
#elif defined(NETWARE)
/* If the token is a volume name, it will have colon at the end -- so, no slash before it */
if (ptr[ptr_length-1] != ':') {
state->cwd[state->cwd_length++] = DEFAULT_SLASH;
}
#else
state->cwd[state->cwd_length++] = DEFAULT_SLASH;
#endif
memcpy(&state->cwd[state->cwd_length], ptr, ptr_length+1);
state->cwd_length += ptr_length;
while (IS_ABSOLUTE_PATH(state->cwd, state->cwd_length) &&
!IS_SLASH(PREVIOUS)) {
save = PREVIOUS;
PREVIOUS = '\0';
state->cwd_length--;
}
ptr = tsrm_strtok_r(NULL, TOKENIZER_STRING, &tok);
}
if (state->cwd_length == COPY_WHEN_ABSOLUTE(state->cwd)) {
state->cwd = (char *) realloc(state->cwd, state->cwd_length+1+1);
state->cwd[state->cwd_length] = DEFAULT_SLASH;
state->cwd[state->cwd_length+1] = '\0';
state->cwd_length++;
if (!IS_ABSOLUTE_PATH(state->cwd, state->cwd_length)) {
state->cwd[state->cwd_length++] = save;
state->cwd[state->cwd_length] = '\0';
} else {
PREVIOUS = '\0';
state->cwd_length--;
}
} else if (!IS_DIRECTORY_CURRENT(ptr, ptr_length)) {
state->cwd = (char *) realloc(state->cwd, state->cwd_length+ptr_length+1+1);
#ifdef TSRM_WIN32
/* Windows 9x will consider C:\\Foo as a network path. Avoid it. */
if ((state->cwd[state->cwd_length-1]!='\\' && state->cwd[state->cwd_length-1]!='/') ||
IsDBCSLeadByte(state->cwd[state->cwd_length-2])) {
state->cwd[state->cwd_length++] = DEFAULT_SLASH;
}
#elif defined(NETWARE)
/* If the token is a volume name, it will have colon at the end -- so, no slash before it */
if (ptr[ptr_length-1] != ':') {
state->cwd[state->cwd_length++] = DEFAULT_SLASH;
}
#else
state->cwd[state->cwd_length++] = DEFAULT_SLASH;
#endif
memcpy(&state->cwd[state->cwd_length], ptr, ptr_length+1);
state->cwd_length += ptr_length;
}
} else {
state->cwd = (char *) realloc(state->cwd, path_length+1);
memcpy(state->cwd, path, path_length+1);
state->cwd_length = path_length;
ptr = tsrm_strtok_r(NULL, TOKENIZER_STRING, &tok);
}
if (state->cwd_length == COPY_WHEN_ABSOLUTE(state->cwd)) {
state->cwd = (char *) realloc(state->cwd, state->cwd_length+1+1);
state->cwd[state->cwd_length] = DEFAULT_SLASH;
state->cwd[state->cwd_length+1] = '\0';
state->cwd_length++;
}
if (verify_path && verify_path(state)) {
@@ -503,23 +477,19 @@ CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path
CWD_API char *virtual_realpath(const char *path, char *real_path TSRMLS_DC)
{
cwd_state new_state;
char *retval;
int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
retval = virtual_file_ex(&new_state, path, NULL, 1);
if (virtual_file_ex(&new_state, path, NULL, 1)==0) {
if (!retval) {
int len = new_state.cwd_length>MAXPATHLEN-1?MAXPATHLEN-1:new_state.cwd_length;
memcpy(real_path, new_state.cwd, len);
real_path[len] = '\0';
retval = real_path;
} else {
retval = NULL;
return real_path;
}
CWD_STATE_FREE(&new_state);
return retval;
return NULL;
}
CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path TSRMLS_DC)
@@ -835,24 +805,13 @@ CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
{
int command_length;
int dir_length, extra = 0;
char *command_line;
char *ptr, *dir;
char *ptr;
FILE *retval;
command_length = strlen(command);
dir_length = CWDG(cwd).cwd_length;
dir = CWDG(cwd).cwd;
while (dir_length > 0) {
if (*dir == '\'') extra+=3;
dir++;
dir_length--;
}
dir_length = CWDG(cwd).cwd_length;
dir = CWDG(cwd).cwd;
ptr = command_line = (char *) malloc(command_length + sizeof("cd '' ; ") + dir_length +1+1);
ptr = command_line = (char *) malloc(command_length + sizeof("cd ; ") + CWDG(cwd).cwd_length+1);
if (!command_line) {
return NULL;
}
@@ -862,21 +821,8 @@ CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
if (CWDG(cwd).cwd_length == 0) {
*ptr++ = DEFAULT_SLASH;
} else {
*ptr++ = '\'';
while (dir_length > 0) {
switch (*dir) {
case '\'':
*ptr++ = '\'';
*ptr++ = '\\';
*ptr++ = '\'';
/* fall-through */
default:
*ptr++ = *dir;
}
dir++;
dir_length--;
}
*ptr++ = '\'';
memcpy(ptr, CWDG(cwd).cwd, CWDG(cwd).cwd_length);
ptr += CWDG(cwd).cwd_length;
}
*ptr++ = ' ';
+5 -30
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -41,10 +41,6 @@
#include <unistd.h>
#endif
#if defined(__osf__) || defined(_AIX)
#include <errno.h>
#endif
#ifdef TSRM_WIN32
#include "readdir.h"
#include <sys/utime.h>
@@ -61,10 +57,10 @@ typedef unsigned short mode_t;
* to account for volume name that is unique to NetWare absolute paths
*/
#define COPY_WHEN_ABSOLUTE(path) 2
#define IS_ABSOLUTE_PATH(path, len) \
((len >= 2 && isalpha(path[0]) && path[1] == ':') || (len >= 1 && IS_SLASH(path[0])))
#define IS_UNC_PATH(path, len) \
(len >= 2 && IS_SLASH(path[0]) && IS_SLASH(path[1]))
#define IS_ABSOLUTE_PATH(path, len) \
(len >= 2 && ((isalpha(path[0]) && path[1] == ':') || IS_UNC_PATH(path, len)))
#elif defined(NETWARE)
#ifdef HAVE_DIRENT_H
@@ -159,25 +155,6 @@ CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC);
CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC);
#endif
/* On AIX & Tru64 when a file does not exist realpath() returns
* NULL, and sets errno to ENOENT. Unlike in other libc implementations
* the destination is not filled and remains undefined. Therefor, we
* must populate it manually using strcpy as done on systems with no
* realpath() function.
*/
#if defined(__osf__) || defined(_AIX)
static char *php_realpath_hack(char *src, char *dest)
{
char *ret;
if ((ret = realpath(src, dest)) == NULL && errno == ENOENT) {
return strcpy(dest, src);
} else {
return ret;
}
}
#endif
#if HAVE_UTIME
CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC);
#endif
@@ -219,6 +196,8 @@ typedef struct _virtual_cwd_globals {
#define VCWD_STAT(path, buff) virtual_stat(path, buff TSRMLS_CC)
#if !defined(TSRM_WIN32) && !defined(NETWARE)
#define VCWD_LSTAT(path, buff) virtual_lstat(path, buff TSRMLS_CC)
#else
#define VCWD_LSTAT(path, buff) virtual_lstat(path, buff TSRMLS_CC)
#endif
#define VCWD_UNLINK(path) virtual_unlink(path TSRMLS_CC)
#define VCWD_MKDIR(pathname, mode) virtual_mkdir(pathname, mode TSRMLS_CC)
@@ -255,11 +234,7 @@ typedef struct _virtual_cwd_globals {
#define VCWD_ACCESS(pathname, mode) access(pathname, mode)
#ifdef HAVE_REALPATH
#if defined(__osf__) || defined(_AIX)
#define VCWD_REALPATH(path, real_path) php_realpath_hack(path, real_path)
#else
#define VCWD_REALPATH(path, real_path) realpath(path, real_path)
#endif
#else
#define VCWD_REALPATH(path, real_path) strcpy(real_path, path)
#endif
+1 -10
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -359,13 +359,4 @@ TSRM_API int shmctl(int key, int cmd, struct shmid_ds *buf) {
return -1;
}
}
TSRM_API char *realpath(char *orig_path, char *buffer)
{
int ret = GetFullPathName(orig_path, _MAX_PATH, buffer, NULL);
if(!ret || ret > _MAX_PATH) {
return NULL;
}
return buffer;
}
#endif
+1 -2
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -101,5 +101,4 @@ TSRM_API void *shmat(int key, const void *shmaddr, int flags);
TSRM_API int shmdt(const void *shmaddr);
TSRM_API int shmctl(int key, int cmd, struct shmid_ds *buf);
TSRM_API char *realpath(char *orig_path, char *buffer);
#endif
+205 -248
View File
@@ -16,22 +16,19 @@ AC_DEFUN([PHP_ADD_MAKEFILE_FRAGMENT],[
sed -e "s#\$(srcdir)#$ac_srcdir#g" -e "s#\$(builddir)#$ac_builddir#g" $src >> Makefile.fragments
])
AC_DEFUN(PHP_PROG_RE2C,[
AC_CHECK_PROG(RE2C, re2c, re2c, [exit 0;])
])
dnl PHP_DEFINE(WHAT[, value[, directory]])
dnl PHP_DEFINE(WHAT[, value])
dnl
dnl Creates builddir/include/what.h and in there #define WHAT value
dnl
AC_DEFUN([PHP_DEFINE],[
[echo "#define ]$1[]ifelse([$2],,[ 1],[ $2])[" > ]ifelse([$3],,[include],[$3])[/php_]translit($1,A-Z,a-z)[.h]
[echo "#define ]$1[]ifelse([$2],,[ 1],[ $2])[" > include/php_]translit($1,A-Z,a-z)[.h]
])
dnl PHP_INIT_BUILD_SYSTEM
dnl
AC_DEFUN([PHP_INIT_BUILD_SYSTEM],[
test -d include || mkdir include
mkdir include >/dev/null 2>&1
> Makefile.objects
> Makefile.fragments
dnl We need to play tricks here to avoid matching the egrep line itself
@@ -180,13 +177,73 @@ AC_DEFUN([PHP_REMOVE_USR_LIB],[
unset ac_new_flags
for i in [$]$1; do
case [$]i in
-L/usr/lib|-L/usr/lib/[)] ;;
*[)] ac_new_flags="[$]ac_new_flags [$]i" ;;
-L/usr/lib|-L/usr/lib/) ;;
*) ac_new_flags="[$]ac_new_flags [$]i" ;;
esac
done
$1=[$]ac_new_flags
])
AC_DEFUN([PHP_SETUP_OPENSSL],[
if test "$PHP_OPENSSL" = "yes"; then
PHP_OPENSSL="/usr/local/ssl /usr/local /usr /usr/local/openssl"
fi
for i in $PHP_OPENSSL; do
if test -r $i/include/openssl/evp.h; then
OPENSSL_INCDIR=$i/include
fi
if test -r $i/lib/libssl.a -o -r $i/lib/libssl.$SHLIB_SUFFIX_NAME; then
OPENSSL_LIBDIR=$i/lib
fi
done
if test -z "$OPENSSL_INCDIR"; then
AC_MSG_ERROR([Cannot find OpenSSL's <evp.h>])
fi
if test -z "$OPENSSL_LIBDIR"; then
AC_MSG_ERROR([Cannot find OpenSSL's libraries])
fi
old_CPPFLAGS=$CPPFLAGS
CPPFLAGS=-I$OPENSSL_INCDIR
AC_MSG_CHECKING([for OpenSSL version])
AC_EGREP_CPP(yes,[
#include <openssl/opensslv.h>
#if OPENSSL_VERSION_NUMBER >= 0x0090500fL
yes
#endif
],[
AC_MSG_RESULT([>= 0.9.5])
],[
AC_MSG_ERROR([OpenSSL version 0.9.5 or greater required.])
])
CPPFLAGS=$old_CPPFLAGS
PHP_ADD_INCLUDE($OPENSSL_INCDIR)
PHP_ADD_LIBPATH($OPENSSL_LIBDIR)
PHP_CHECK_LIBRARY(crypto, CRYPTO_free, [
PHP_ADD_LIBRARY(crypto)
],[
AC_MSG_ERROR([libcrypto not found!])
],[
-L$OPENSSL_LIBDIR
])
PHP_CHECK_LIBRARY(ssl, SSL_CTX_set_ssl_version, [
PHP_ADD_LIBRARY(ssl)
],[
AC_MSG_ERROR([libssl not found!])
],[
-L$OPENSSL_LIBDIR
])
OPENSSL_INCDIR_OPT=-I$OPENSSL_INCDIR
AC_SUBST(OPENSSL_INCDIR_OPT)
])
dnl PHP_EVAL_LIBLINE(LINE, SHARED-LIBADD)
dnl
dnl Use this macro, if you need to add libraries and or library search
@@ -196,11 +253,11 @@ dnl
AC_DEFUN([PHP_EVAL_LIBLINE],[
for ac_i in $1; do
case $ac_i in
-l*[)]
-l*)
ac_ii=`echo $ac_i|cut -c 3-`
PHP_ADD_LIBRARY($ac_ii,1,$2)
;;
-L*[)]
-L*)
ac_ii=`echo $ac_i|cut -c 3-`
PHP_ADD_LIBPATH($ac_ii,$2)
;;
@@ -216,7 +273,7 @@ dnl
AC_DEFUN([PHP_EVAL_INCLINE],[
for ac_i in $1; do
case $ac_i in
-I*[)]
-I*)
ac_ii=`echo $ac_i|cut -c 3-`
PHP_ADD_INCLUDE($ac_ii)
;;
@@ -280,10 +337,10 @@ AC_DEFUN([PHP_SHLIB_SUFFIX_NAME],[
PHP_SUBST(SHLIB_SUFFIX_NAME)
SHLIB_SUFFIX_NAME=so
case $host_alias in
*hpux*[)]
*hpux*)
SHLIB_SUFFIX_NAME=sl
;;
*darwin*[)]
*darwin*)
SHLIB_SUFFIX_NAME=dylib
;;
esac
@@ -454,17 +511,17 @@ AC_DEFUN([PHP_ARG_ANALYZE_EX],[
ext_output="yes, shared"
ext_shared=yes
case [$]$1 in
shared,*[)]
shared,*)
$1=`echo "[$]$1"|sed 's/^shared,//'`
;;
shared[)]
shared)
$1=yes
;;
no[)]
no)
ext_output=no
ext_shared=no
;;
*[)]
*)
ext_output=yes
ext_shared=no
;;
@@ -474,7 +531,7 @@ PHP_ALWAYS_SHARED([$1])
])
AC_DEFUN([PHP_ARG_ANALYZE],[
ifelse([$3],yes,[PHP_ARG_ANALYZE_EX([$1])],[ext_output=ifelse([$]$1,,no,[$]$1)])
ifelse([$3],yes,[PHP_ARG_ANALYZE_EX([$1])])
ifelse([$2],,,[AC_MSG_RESULT([$ext_output])])
])
@@ -533,8 +590,7 @@ AC_DEFUN([PHP_MODULE_PTR],[
])
AC_DEFUN([PHP_CONFIG_NICE],[
test -f $1 && mv $1 $1.old
rm -f $1.old
rm -f $1
cat >$1<<EOF
#! /bin/sh
#
@@ -597,8 +653,8 @@ main() {
])
])
case $ac_cv_time_r_type in
hpux[)] AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) ;;
irix[)] AC_DEFINE(PHP_IRIX_TIME_R,1,[Whether you have IRIX-style functions]) ;;
hpux) AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) ;;
irix) AC_DEFINE(PHP_IRIX_TIME_R,1,[Whether you have IRIX-style functions]) ;;
esac
])
@@ -611,6 +667,21 @@ AC_DEFUN([PHP_SUBST_OLD],[
AC_SUBST($1)
])
AC_DEFUN([PHP_MKDIR_P_CHECK],[
AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[
test -d conftestdir && rm -rf conftestdir
mkdir -p conftestdir/somedir >/dev/null 2>&1
dnl `mkdir -p' must be quiet about creating existing directories
mkdir -p conftestdir/somedir >/dev/null 2>&1
if test "$?" = "0" && test -d conftestdir/somedir; then
ac_cv_mkdir_p=yes
else
ac_cv_mkdir_p=no
fi
rm -rf conftestdir
])
])
AC_DEFUN([PHP_TM_GMTOFF],[
AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
[AC_TRY_COMPILE([#include <sys/types.h>
@@ -630,8 +701,7 @@ AC_DEFUN([PHP_CONFIGURE_PART],[
])
AC_DEFUN([PHP_PROG_SENDMAIL],[
PHP_ALT_PATH=/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib
AC_PATH_PROG(PROG_SENDMAIL, sendmail,[], $PATH:$PHP_ALT_PATH)
AC_PATH_PROG(PROG_SENDMAIL, sendmail,[], $PATH:/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib)
if test -n "$PROG_SENDMAIL"; then
AC_DEFINE(HAVE_SENDMAIL,1,[whether you have sendmail])
fi
@@ -1037,11 +1107,7 @@ dnl
dnl Set libtool variable
dnl
AC_DEFUN([PHP_SET_LIBTOOL_VARIABLE],[
if test -z "$LIBTOOL"; then
LIBTOOL='$(SHELL) $(top_builddir)/libtool $1'
else
LIBTOOL="$LIBTOOL $1"
fi
LIBTOOL='$(SHELL) libtool $1'
])
dnl
@@ -1067,7 +1133,6 @@ AC_DEFUN([PHP_CHECK_CC_OPTION],[
AC_MSG_RESULT([no])
fi
fi
rm -rf conftest*
])
AC_DEFUN([PHP_REGEX],[
@@ -1130,9 +1195,7 @@ main() {
int res = 0;
res = res || (snprintf(buf, 2, "marcus") != 6);
res = res || (buf[1] != '\0');
/* Implementations may consider this as an encoding error */
snprintf(buf, 0, "boerger");
/* However, they MUST ignore the pointer */
res = res || (snprintf(buf, 0, "boerger") != 7);
res = res || (buf[0] != 'm');
res = res || (snprintf(NULL, 0, "boerger") != 7);
res = res || (snprintf(buf, sizeof(buf), "%f", 0.12345678) != 8);
@@ -1153,21 +1216,20 @@ main() {
fi
])
dnl PHP_SHARED_MODULE(module-name, object-var, build-dir, cxx)
dnl PHP_SHARED_MODULE(module-name, object-var, build-dir)
dnl
dnl Basically sets up the link-stage for building module-name
dnl from object_var in build-dir.
dnl
AC_DEFUN([PHP_SHARED_MODULE],[
install_modules="install-modules"
PHP_MODULES="$PHP_MODULES \$(phplibdir)/$1.la"
PHP_SUBST($2)
cat >>Makefile.objects<<EOF
\$(phplibdir)/$1.la: $3/$1.la
\$(LIBTOOL) --mode=install cp $3/$1.la \$(phplibdir)
$3/$1.la: \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_DEPENDENCIES)
\$(LIBTOOL) --mode=link ifelse($4,,[\$(CC)],[\$(CXX)]) \$(COMMON_FLAGS) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(LDFLAGS) -o \[$]@ -export-dynamic -avoid-version -prefer-pic -module -rpath \$(phplibdir) \$(EXTRA_LDFLAGS) \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_LIBADD)
$3/$1.la: \$($2) \$(translit($1,a-z-,A-Z_)_SHARED_DEPENDENCIES)
\$(LIBTOOL) --mode=link \$(CC) \$(COMMON_FLAGS) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(LDFLAGS) -o \[$]@ -export-dynamic -avoid-version -prefer-pic -module -rpath \$(phplibdir) \$(EXTRA_LDFLAGS) \$($2) \$(translit($1,a-z-,A-Z_)_SHARED_LIBADD)
EOF
])
@@ -1183,10 +1245,10 @@ AC_DEFUN([PHP_SELECT_SAPI],[
PHP_SAPI=$1
case "$2" in
static[)] PHP_BUILD_STATIC;;
shared[)] PHP_BUILD_SHARED;;
bundle[)] PHP_BUILD_BUNDLE;;
program[)] PHP_BUILD_PROGRAM($5);;
static) PHP_BUILD_STATIC;;
shared) PHP_BUILD_SHARED;;
bundle) PHP_BUILD_BUNDLE;;
program) PHP_BUILD_PROGRAM($5);;
esac
ifelse($3,,,[PHP_ADD_SOURCES([sapi/$1],[$3],[$4],[sapi])])
@@ -1194,7 +1256,7 @@ AC_DEFUN([PHP_SELECT_SAPI],[
dnl deprecated
AC_DEFUN([PHP_EXTENSION],[
sources=`$AWK -f $abs_srcdir/build/scan_makefile_in.awk < []PHP_EXT_SRCDIR($1)[]/Makefile.in`
sources=`awk -f $abs_srcdir/scan_makefile_in.awk < []PHP_EXT_SRCDIR($1)[]/Makefile.in`
PHP_NEW_EXTENSION($1, $sources, $2, $3)
@@ -1208,11 +1270,14 @@ AC_DEFUN([PHP_ADD_BUILD_DIR],[
])
AC_DEFUN([PHP_GEN_BUILD_DIRS],[
$php_shtool mkdir -p $BUILD_DIR
PHP_MKDIR_P_CHECK
if test "$ac_cv_mkdir_p" = "yes"; then
mkdir -p $BUILD_DIR
fi
])
dnl
dnl PHP_NEW_EXTENSION(extname, sources [, shared [,sapi_class[, extra-cflags[, cxx]]]])
dnl PHP_NEW_EXTENSION(extname, sources [, shared [,sapi_class[, extra-cflags]]])
dnl
dnl Includes an extension in the build.
dnl
@@ -1242,7 +1307,7 @@ dnl ---------------------------------------------- Static module
if test "$3" = "shared" || test "$3" = "yes"; then
dnl ---------------------------------------------- Shared module
PHP_ADD_SOURCES_X(PHP_EXT_DIR($1),$2,$ac_extra,shared_objects_$1,yes)
PHP_SHARED_MODULE($1,shared_objects_$1, $ext_builddir, $6)
PHP_SHARED_MODULE($1,shared_objects_$1, $ext_builddir)
AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z_-,A-Z__), 1, Whether to build $1 as dynamic module)
fi
fi
@@ -1272,13 +1337,13 @@ AC_DEFUN([PHP_SOLARIS_PIC_WEIRDNESS],[
if test -n "$EXT_SHARED"; then
os=`uname -sr 2>/dev/null`
case $os in
"SunOS 5.6"|"SunOS 5.7"[)]
"SunOS 5.6"|"SunOS 5.7")
case $CC in
gcc*|egcs*) CFLAGS="$CFLAGS -fPIC";;
*[)] CFLAGS="$CFLAGS -fpic";;
*) CFLAGS="$CFLAGS -fpic";;
esac
AC_MSG_RESULT([yes]);;
*[)]
*)
AC_MSG_RESULT([no]);;
esac
else
@@ -1316,8 +1381,8 @@ AC_DEFUN([PHP_SYS_LFS],
ac_shellvars='CPPFLAGS LDFLAGS LIBS'
for ac_shellvar in $ac_shellvars; do
case $ac_shellvar in
CPPFLAGS[)] ac_lfsvar=LFS_CFLAGS ;;
*[)] ac_lfsvar=LFS_$ac_shellvar ;;
CPPFLAGS) ac_lfsvar=LFS_CFLAGS ;;
*) ac_lfsvar=LFS_$ac_shellvar ;;
esac
eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
(getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
@@ -1326,14 +1391,14 @@ AC_DEFUN([PHP_SYS_LFS],
eval ac_test_$ac_shellvar=\$ac_getconf
done
case "$ac_result$ac_getconfs" in
yes[)] ac_result=no ;;
yes) ac_result=no ;;
esac
case "$ac_result$ac_set" in
yes?*[)] ac_result="yes, but $ac_set is already set, so use its settings"
yes?*) ac_result="yes, but $ac_set is already set, so use its settings"
esac
AC_MSG_RESULT([$ac_result])
case $ac_result in
yes[)]
yes)
for ac_shellvar in $ac_shellvars; do
eval $ac_shellvar=\$ac_test_$ac_shellvar
done ;;
@@ -1397,70 +1462,6 @@ int main(void) {
fi
])
dnl Some systems, notably Solaris, cause getcwd() or realpath to fail if a
dnl component of the path has execute but not read permissions
AC_DEFUN([PHP_BROKEN_GETCWD],[
AC_MSG_CHECKING([for broken getcwd])
os=`uname -sr 2>/dev/null`
case $os in
SunOS*[)]
AC_DEFINE(HAVE_BROKEN_GETCWD,1, [Define if system has broken getcwd])
AC_MSG_RESULT([yes]);;
*[)]
AC_MSG_RESULT([no]);;
esac
])
AC_DEFUN([PHP_BROKEN_GLIBC_FOPEN_APPEND],[
AC_MSG_CHECKING([for broken libc stdio])
AC_CACHE_VAL(have_broken_glibc_fopen_append,[
AC_TRY_RUN([
#include <stdio.h>
int main(int argc, char *argv[])
{
FILE *fp;
long position;
char *filename = "/tmp/phpglibccheck";
fp = fopen(filename, "w");
if (fp == NULL) {
perror("fopen");
exit(2);
}
fputs("foobar", fp);
fclose(fp);
fp = fopen(filename, "a+");
position = ftell(fp);
fclose(fp);
unlink(filename);
if (position == 0)
return 1;
return 0;
}
],
[have_broken_glibc_fopen_append=no],
[have_broken_glibc_fopen_append=yes ],
AC_TRY_COMPILE([
#include <features.h>
],[
#if !__GLIBC_PREREQ(2,2)
choke me
#endif
],
[have_broken_glibc_fopen_append=yes],
[have_broken_glibc_fopen_append=no ])
)])
if test "$have_broken_glibc_fopen_append" = "yes"; then
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_BROKEN_GLIBC_FOPEN_APPEND,1, [Define if your glibc borks on fopen with mode a+])
else
AC_MSG_RESULT(no)
fi
])
AC_DEFUN([PHP_FOPENCOOKIE],[
AC_CHECK_FUNC(fopencookie, [ have_glibc_fopencookie=yes ])
@@ -1486,16 +1487,16 @@ AC_DEFUN([PHP_FOPENCOOKIE],[
#include <stdio.h>
struct cookiedata {
__off64_t pos;
fpos_t pos;
};
__ssize_t reader(void *cookie, char *buffer, size_t size)
size_t reader(void *cookie, char *buffer, size_t size)
{ return size; }
__ssize_t writer(void *cookie, const char *buffer, size_t size)
size_t writer(void *cookie, const char *buffer, size_t size)
{ return size; }
int closer(void *cookie)
{ return 0; }
int seeker(void *cookie, __off64_t *position, int whence)
int seeker(void *cookie, fpos_t *position, int whence)
{ ((struct cookiedata*)cookie)->pos = *position; return 0; }
cookie_io_functions_t funcs = {reader, writer, seeker, closer};
@@ -1504,13 +1505,13 @@ main() {
struct cookiedata g = { 0 };
FILE *fp = fopencookie(&g, "r", funcs);
if (fp && fseek(fp, 8192, SEEK_SET) == 0 && g.pos == 8192)
if (fp && fseek(fp, 69, SEEK_SET) == 0 && g.pos == 69)
exit(0);
exit(1);
}
],
[ cookie_io_functions_use_off64_t=yes ],
[ cookie_io_functions_use_fpos_t=yes ],
[ ] )
else
@@ -1531,8 +1532,8 @@ main() {
if test "$have_fopen_cookie" = "yes" ; then
AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ])
AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ])
if test "$cookie_io_functions_use_off64_t" = "yes" ; then
AC_DEFINE(COOKIE_SEEKER_USES_OFF64_T, 1, [ ])
if test "$cookie_io_functions_use_fpos_t" = "yes" ; then
AC_DEFINE(COOKIE_SEEKER_USES_FPOS_T, 1, [ ])
fi
fi
@@ -1547,19 +1548,12 @@ dnl Wrapper for AC_CHECK_LIB
dnl
AC_DEFUN([PHP_CHECK_LIBRARY], [
save_old_LDFLAGS=$LDFLAGS
ac_stuff="$5"
save_ext_shared=$ext_shared
ext_shared=yes
PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS)
LDFLAGS="$5 $LDFLAGS"
AC_CHECK_LIB([$1],[$2],[
LDFLAGS=$save_old_LDFLAGS
ext_shared=$save_ext_shared
$3
],[
LDFLAGS=$save_old_LDFLAGS
ext_shared=$save_ext_shared
unset ac_cv_func_$1
$4
])dnl
])
@@ -1584,112 +1578,6 @@ AC_DEFUN([PHP_CHECK_FRAMEWORK], [
])
])
dnl
dnl PHP_SETUP_OPENSSL(shared-add [, action-found [, action-not-found]])
dnl
dnl Common setup macro for openssl
dnl
AC_DEFUN([PHP_SETUP_OPENSSL],[
found_openssl=no
unset OPENSSL_INCDIR
unset OPENSSL_LIBDIR
dnl First try to find pkg-config
if test -z "$PKG_CONFIG"; then
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
fi
dnl If pkg-config is found try using it
if test "$PHP_OPENSSL" = "yes" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists openssl; then
if $PKG_CONFIG --atleast-version=0.9.6 openssl; then
found_openssl=yes
OPENSSL_LIBS=`$PKG_CONFIG --libs openssl`
OPENSSL_INCS=`$PKG_CONFIG --cflags-only-I openssl`
OPENSSL_INCDIR=`$PKG_CONFIG --variable=includedir openssl`
else
AC_MSG_ERROR([OpenSSL version 0.9.6 or greater required.])
fi
if test -n "$OPENSSL_LIBS" && test -n "$OPENSSL_INCS"; then
PHP_EVAL_LIBLINE($OPENSSL_LIBS, $1)
PHP_EVAL_INCLINE($OPENSSL_INCS)
fi
else
dnl If pkg-config fails for some reason, revert to the old method
if test "$PHP_OPENSSL" = "yes"; then
PHP_OPENSSL="/usr/local/ssl /usr/local /usr /usr/local/openssl"
fi
for i in $PHP_OPENSSL; do
if test -r $i/include/openssl/evp.h; then
OPENSSL_INCDIR=$i/include
fi
if test -r $i/lib/libssl.a -o -r $i/lib/libssl.$SHLIB_SUFFIX_NAME; then
OPENSSL_LIBDIR=$i/lib
fi
test -n "$OPENSSL_INCDIR" && test -n "$OPENSSL_LIBDIR" && break
done
if test -z "$OPENSSL_INCDIR"; then
AC_MSG_ERROR([Cannot find OpenSSL's <evp.h>])
fi
if test -z "$OPENSSL_LIBDIR"; then
AC_MSG_ERROR([Cannot find OpenSSL's libraries])
fi
old_CPPFLAGS=$CPPFLAGS
CPPFLAGS=-I$OPENSSL_INCDIR
AC_MSG_CHECKING([for OpenSSL version])
AC_EGREP_CPP(yes,[
#include <openssl/opensslv.h>
#if OPENSSL_VERSION_NUMBER >= 0x0090600fL
yes
#endif
],[
AC_MSG_RESULT([>= 0.9.6])
],[
AC_MSG_ERROR([OpenSSL version 0.9.6 or greater required.])
])
CPPFLAGS=$old_CPPFLAGS
PHP_ADD_INCLUDE($OPENSSL_INCDIR)
PHP_CHECK_LIBRARY(crypto, CRYPTO_free, [
PHP_ADD_LIBRARY(crypto,,$1)
],[
AC_MSG_ERROR([libcrypto not found!])
],[
-L$OPENSSL_LIBDIR
])
old_LIBS=$LIBS
LIBS="$LIBS -lcrypto"
PHP_CHECK_LIBRARY(ssl, SSL_CTX_set_ssl_version, [
found_openssl=yes
],[
AC_MSG_ERROR([libssl not found!])
],[
-L$OPENSSL_LIBDIR
])
LIBS=$old_LIBS
PHP_ADD_LIBRARY(ssl,,$1)
PHP_ADD_LIBPATH($OPENSSL_LIBDIR, $1)
fi
dnl For apache 1.3.x static build
OPENSSL_INCDIR_OPT=-I$OPENSSL_INCDIR
AC_SUBST(OPENSSL_INCDIR_OPT)
if test "$found_openssl" = "yes"; then
ifelse([$2],[],:,[$2])
ifelse([$3],[],,[else $3])
fi
])
dnl
dnl PHP_SETUP_ICONV(shared-add [, action-found [, action-not-found]])
dnl
@@ -1699,19 +1587,16 @@ AC_DEFUN([PHP_SETUP_ICONV], [
found_iconv=no
unset ICONV_DIR
echo > ext/iconv/php_have_libiconv.h
echo > ext/iconv/php_have_iconv.h
dnl
dnl Check libc first if no path is provided in --with-iconv
dnl
if test "$PHP_ICONV" = "yes"; then
AC_CHECK_FUNC(iconv, [
PHP_DEFINE(HAVE_ICONV,1,[ext/iconv])
PHP_DEFINE(HAVE_ICONV)
found_iconv=yes
],[
AC_CHECK_FUNC(libiconv,[
PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv])
PHP_DEFINE(HAVE_LIBICONV)
found_iconv=yes
])
])
@@ -1744,11 +1629,11 @@ AC_DEFUN([PHP_SETUP_ICONV], [
then
PHP_CHECK_LIBRARY($iconv_lib_name, libiconv, [
found_iconv=yes
PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv])
PHP_DEFINE(HAVE_LIBICONV)
], [
PHP_CHECK_LIBRARY($iconv_lib_name, iconv, [
found_iconv=yes
PHP_DEFINE(HAVE_ICONV,1,[ext/iconv])
PHP_DEFINE(HAVE_ICONV)
], [], [
-L$ICONV_DIR/lib
])
@@ -1827,12 +1712,12 @@ AC_DEFUN([PHP_CHECK_FUNC],[
AC_CHECK_FUNC($1, [found=yes],[ AC_CHECK_FUNC(__$1,[found=yes],[found=no]) ])
case $found in
yes[)]
yes)
PHP_DEF_HAVE($1)
ac_cv_func_$1=yes
;;
ifelse($#,1,,[
*[)] PHP_CHECK_FUNC_LIB($@) ;;
*) PHP_CHECK_FUNC_LIB($@) ;;
])
esac
])
@@ -1853,3 +1738,75 @@ IFS="- /.
APACHE_VERSION=`expr [$]4 \* 1000000 + [$]5 \* 1000 + [$]6`
])
dnl PHP_PROG_SED
dnl ------------
dnl Check for a fully-functional sed program, that truncates
dnl as few characters as possible. Prefer GNU sed if found.
dnl
dnl Based on LT_AC_PROG_SED (libtool CVS)
dnl
AC_DEFUN([PHP_PROG_SED],
[AC_MSG_CHECKING([for working sed])
AC_CACHE_VAL(ac_cv_path_sed,
[
# Create a temporary directory, and hook for its removal unless debugging.
$debug ||
{
trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
trap '{ (exit 1); exit 1; }' 1 2 13 15
}
# Create a (secure) tmp directory for tmp files.
: ${TMPDIR=/tmp}
{
tmp=`(umask 077 && mktemp -d -q "$TMPDIR/sedXXXXXX") 2>/dev/null` &&
test -n "$tmp" && test -d "$tmp"
} ||
{
tmp=$TMPDIR/sed$$-$RANDOM
(umask 077 && mkdir $tmp)
} ||
{
echo "$me: cannot create a temporary directory in $TMPDIR" >&2
{ (exit 1); exit 1; }
}
_max=0
_count=0
# Use the sed found in PATH, skip the rest
_sed=sed
# Check for GNU sed and select it if it is found.
if "${_sed}" --version 2>&1 < /dev/null | egrep '(GNU)' > /dev/null; then
ac_cv_path_sed=${_sed}
else
cat /dev/null > "$tmp/sed.in"
_count=0
echo -n "0123456789" >"$tmp/sed.in"
while true; do
cat "$tmp/sed.in" "$tmp/sed.in" >"$tmp/sed.tmp"
mv "$tmp/sed.tmp" "$tmp/sed.in"
cp "$tmp/sed.in" "$tmp/sed.nl"
echo >>"$tmp/sed.nl"
${_sed} -e 's/a$//' < "$tmp/sed.nl" >"$tmp/sed.out" || break
cmp -s "$tmp/sed.out" "$tmp/sed.nl" || break
# 10000 chars as input seems more than enough
test $_count -gt 10 && break
_count=`expr $_count + 1`
if test $_count -gt $_max; then
_max=$_count
ac_cv_path_sed=${_sed}
fi
done
fi
rm -rf "$tmp"
])
if test -z "$ac_cv_path_sed"; then
AC_MSG_ERROR([Could not find working sed on this system. Please install GNU sed.])
else
SED=$ac_cv_path_sed
PHP_SUBST(SED)
AC_MSG_RESULT([$SED])
fi
])
+1 -1
View File
@@ -65,7 +65,7 @@ snapshot:
md5sum $$distname.tar.bz2; \
bzip2 -t $$distname.tar.bz2
cvsclean-work:
cvsclean:
@for i in `find . -name .cvsignore`; do \
(cd `dirname $$i` 2>/dev/null && rm -rf `cat .cvsignore | grep -v config.nice` *.o *.a .libs || true); \
done
+2 -7
View File
@@ -52,13 +52,8 @@ $(TOUCH_FILES):
touch $(TOUCH_FILES)
aclocal.m4: configure.in acinclude.m4
@echo rebuilding $@
@libtoolize=`./build/shtool path glibtoolize libtoolize`; \
$$libtoolize --copy --automake; \
ltpath=`dirname $$libtoolize`; \
ltfile=`cd $$ltpath/../share/aclocal; pwd`/libtool.m4; \
cat acinclude.m4 $$ltfile > $@
aclocal 2>&1 | $(SUPPRESS_WARNINGS)
configure: aclocal.m4 configure.in $(config_m4_files)
@echo rebuilding $@
@autoconf 2>&1 | $(SUPPRESS_WARNINGS)
+39 -25
View File
@@ -12,11 +12,11 @@
# | obtain it through the world-wide-web, please send a note to |
# | license@php.net so we can mail you a copy immediately. |
# +----------------------------------------------------------------------+
# | Authors: Stig Bakken <ssb@php.net> |
# | Authors: Stig Bakken <ssb@fast.no> |
# | Sascha Schumann <sascha@schumann.cx> |
# +----------------------------------------------------------------------+
#
# $Id: buildcheck.sh,v 1.21.2.6 2003-09-28 13:37:59 tal Exp $
# $Id: buildcheck.sh,v 1.21 2002-10-30 11:42:22 sas Exp $
#
echo "buildconf: checking installation..."
@@ -24,7 +24,7 @@ echo "buildconf: checking installation..."
stamp=$1
# autoconf 2.13 or newer
ac_version=`autoconf --version 2>/dev/null|head -n 1|sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
ac_version=`autoconf --version 2>/dev/null|head -1|sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
if test -z "$ac_version"; then
echo "buildconf: autoconf not found."
echo " You need autoconf version 2.13 or newer installed"
@@ -50,42 +50,56 @@ if test "$1" = "2" && test "$2" -ge "50"; then
stamp=
fi
# libtoolize 1.4.3 or newer
# Prefer glibtoolize over libtoolize for Mac OS X compatibility
libtoolize=`./build/shtool path glibtoolize libtoolize 2> /dev/null`
lt_pversion=`$libtoolize --version 2>/dev/null|head -n 1|sed -e 's/^[^0-9]*//'`
if test "$lt_pversion" = ""; then
echo "buildconf: libtool not found."
echo " You need libtool version 1.4.3 or newer installed"
# automake 1.4 or newer
am_version=`automake --version 2>/dev/null|head -1|sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
am_version_clean=`echo $am_version|sed -e 's/-p[0-9]*$//'`
if test "$am_version" = ""; then
echo "buildconf: automake not found."
echo " You need automake version 1.4 or newer installed"
echo " to build PHP from CVS."
exit 1
fi
IFS=.; set $lt_pversion; IFS=' '
if test "$3" = ""; then
third=0
IFS=.; set $am_version_clean; IFS=' '
if test "$1" = "1" -a "$2" -lt "4" || test "$1" -lt "1"; then
echo "buildconf: automake version $am_version found."
echo " You need automake version 1.4 or newer installed"
echo " to build PHP from CVS."
exit 1
else
third=$3
echo "buildconf: automake version $am_version (ok)"
fi
if test "$1" -gt "1" || test "$2" -ge "5" || (test "$2" -ge "4" && test "$third" -ge "3")
# libtool 1.4 or newer
# Prefer glibtool over libtool for Mac OS X compatibility
libtool=`which glibtool 2> /dev/null`
if test ! -f "$libtool"; then libtool=`which libtool`; fi
lt_pversion=`$libtool --version 2>/dev/null|sed -n -e 's/^[^0-9]*//' -e 1's/[- ].*//p'`
if test "$lt_pversion" = ""; then
echo "buildconf: libtool not found."
echo " You need libtool version 1.4 or newer installed"
echo " to build PHP from CVS."
exit 1
fi
lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$/.\1/'`
IFS=.; set $lt_version; IFS=' '
if test "$1" -gt "1" || test "$2" -ge "4";
then
echo "buildconf: libtool version $lt_pversion (ok)"
else
echo "buildconf: libtool version $lt_pversion found."
echo " You need libtool version 1.4.3 or newer installed"
echo " You need libtool version 1.4 or newer installed"
echo " to build PHP from CVS."
exit 1
fi
ltpath=`echo $libtoolize | sed -e 's#/[^/]*/[^/]*$##'`
ltfile="$ltpath/share/aclocal/libtool.m4"
if test -r "$ltfile"; then
:
else
echo "buildconf: $ltfile does not exist."
echo " Please reinstall libtool."
exit 1
am_prefix=`which automake | sed -e 's#/[^/]*/[^/]*$##'`
lt_prefix=`echo $libtool | sed -e 's#/[^/]*/[^/]*$##'`
if test "$am_prefix" != "$lt_prefix"; then
echo "WARNING: automake and libtool are installed in different"
echo " directories. This may cause aclocal to fail."
echo " continuing anyway"
fi
test -n "$stamp" && touch $stamp
+4 -44
View File
@@ -1,60 +1,20 @@
#!/bin/sh
# $Id$
eval `grep '^EXTRA_VERSION=' configure.in`
case "$EXTRA_VERSION" in
*-dev)
dev=1
;;
*)
dev=0
;;
esac
devok=0
while test $# -gt 0; do
if test "$1" = "--copy"; then
automake_flags=--copy
fi
if test "$1" = "--force"; then
devok=1
echo "Forcing buildconf"
fi
if test "$1" = "--ZendEngine2"; then
ZENDDIR=ZendEngine2
echo "Using Zend Engine 2 code"
fi
shift
done
if test "$dev" = "0" -a "$devok" = "0"; then
echo "You should not run buildconf in a release package."
echo "use buildconf --force to override this check."
exit 1
fi
if test -z "$ZENDDIR"; then
if grep "PHP_MAJOR_VERSION 5" main/php_version.h >/dev/null; then
v=5
else
v=4
fi
if test "$v" = "5"; then
if test -r "Zend/OBJECTS2_HOWTO"; then
:
else
mv Zend ZendEngine1 2>/dev/null
mv ZendEngine2 Zend
fi
else
if test -r "Zend/zend_execute_globals.h"; then
:
else
mv Zend ZendEngine2 2>/dev/null
mv ZendEngine1 Zend
fi
fi
ZENDDIR=Zend
echo "using default Zend directory"
fi
+31 -69
View File
@@ -3,7 +3,7 @@
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002 Free Software Foundation, Inc.
timestamp='2002-10-21'
timestamp='2002-05-29'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -88,40 +88,30 @@ if test $# != 0; then
exit 1
fi
trap 'exit 1' 1 2 15
# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
# compiler to aid in system detection is discouraged as it requires
# temporary files to be created and, as you can see below, it is a
# headache to deal with in a portable fashion.
dummy=dummy-$$
trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15
# CC_FOR_BUILD -- compiler used by this script.
# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
# use `HOST_CC' if defined, but it is deprecated.
# This shell variable is my proudest work .. or something. --bje
set_cc_for_build='tmpdir=${TMPDIR-/tmp}/config-guess-$$ ;
(old=`umask` && umask 077 && mkdir $tmpdir && umask $old && unset old)
|| (echo "$me: cannot create $tmpdir" >&2 && exit 1) ;
dummy=$tmpdir/dummy ;
files="$dummy.c $dummy.o $dummy.rel $dummy" ;
trap '"'"'rm -f $files; rmdir $tmpdir; exit 1'"'"' 1 2 15 ;
case $CC_FOR_BUILD,$HOST_CC,$CC in
,,) echo "int x;" > $dummy.c ;
set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in
,,) echo "int dummy(){}" > $dummy.c ;
for c in cc gcc c89 c99 ; do
if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ;
if test $? = 0 ; then
CC_FOR_BUILD="$c"; break ;
fi ;
done ;
rm -f $files ;
rm -f $dummy.c $dummy.o $dummy.rel ;
if test x"$CC_FOR_BUILD" = x ; then
CC_FOR_BUILD=no_compiler_found ;
fi
;;
,,*) CC_FOR_BUILD=$CC ;;
,*,*) CC_FOR_BUILD=$HOST_CC ;;
esac ;
unset files'
esac'
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 1994-08-24)
@@ -231,7 +221,6 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
eval $set_cc_for_build
cat <<EOF >$dummy.s
.data
\$Lformat:
@@ -257,9 +246,10 @@ main:
jsr \$26,exit
.end main
EOF
$CC_FOR_BUILD -o $dummy $dummy.s 2>/dev/null
eval $set_cc_for_build
$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
if test "$?" = 0 ; then
case `$dummy` in
case `./$dummy` in
0-0)
UNAME_MACHINE="alpha"
;;
@@ -281,12 +271,9 @@ EOF
2-1307)
UNAME_MACHINE="alphaev68"
;;
3-1307)
UNAME_MACHINE="alphaev7"
;;
esac
fi
rm -f $dummy.s $dummy && rmdir $tmpdir
rm -f $dummy.s $dummy
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
exit 0 ;;
Alpha\ *:Windows_NT*:*)
@@ -327,10 +314,6 @@ EOF
NILE*:*:*:dcosx)
echo pyramid-pyramid-svr4
exit 0 ;;
DRS?6000:UNIX_SV:4.2*:7*)
case `/usr/bin/uname -p` in
sparc) echo sparc-icl-nx7 && exit 0 ;;
esac ;;
sun4H:SunOS:5.*:*)
echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
@@ -437,18 +420,15 @@ EOF
exit (-1);
}
EOF
$CC_FOR_BUILD -o $dummy $dummy.c \
&& $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
&& rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
rm -f $dummy.c $dummy && rmdir $tmpdir
$CC_FOR_BUILD $dummy.c -o $dummy \
&& ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
&& rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
echo mips-mips-riscos${UNAME_RELEASE}
exit 0 ;;
Motorola:PowerMAX_OS:*:*)
echo powerpc-motorola-powermax
exit 0 ;;
Motorola:*:4.3:PL8-*)
echo powerpc-harris-powermax
exit 0 ;;
Night_Hawk:*:*:PowerMAX_OS)
echo powerpc-harris-powermax
exit 0 ;;
@@ -524,8 +504,8 @@ EOF
exit(0);
}
EOF
$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
rm -f $dummy.c $dummy && rmdir $tmpdir
$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
echo rs6000-ibm-aix3.2.5
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
echo rs6000-ibm-aix3.2.4
@@ -623,9 +603,9 @@ EOF
exit (0);
}
EOF
(CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
(CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null) && HP_ARCH=`./$dummy`
if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
rm -f $dummy.c $dummy && rmdir $tmpdir
rm -f $dummy.c $dummy
fi ;;
esac
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
@@ -661,8 +641,8 @@ EOF
exit (0);
}
EOF
$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
rm -f $dummy.c $dummy && rmdir $tmpdir
$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
echo unknown-hitachi-hiuxwe2
exit 0 ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
@@ -745,19 +725,7 @@ EOF
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit 0 ;;
*:FreeBSD:*:*)
# Determine whether the default compiler uses glibc.
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include <features.h>
#if __GLIBC__ >= 2
LIBC=gnu
#else
LIBC=
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
rm -f $dummy.c && rmdir $tmpdir
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit 0 ;;
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
@@ -818,7 +786,7 @@ EOF
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
rm -f $dummy.c && rmdir $tmpdir
rm -f $dummy.c
test x"${CPU}" != x && echo "${CPU}-pc-linux-gnu" && exit 0
;;
ppc:Linux:*:*)
@@ -881,7 +849,7 @@ EOF
;;
a.out-i386-linux)
echo "${UNAME_MACHINE}-pc-linux-gnuaout"
exit 0 ;;
exit 0 ;;
coff-i386)
echo "${UNAME_MACHINE}-pc-linux-gnucoff"
exit 0 ;;
@@ -914,7 +882,7 @@ EOF
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
rm -f $dummy.c && rmdir $tmpdir
rm -f $dummy.c
test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0
test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
;;
@@ -992,9 +960,6 @@ EOF
# "miniframe"
echo m68010-convergent-sysv
exit 0 ;;
mc68k:UNIX:SYSTEM5:3.51m)
echo m68k-convergent-sysv
exit 0 ;;
M68*:*:R3V[567]*:*)
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0)
@@ -1088,9 +1053,6 @@ EOF
SX-5:SUPER-UX:*:*)
echo sx5-nec-superux${UNAME_RELEASE}
exit 0 ;;
SX-6:SUPER-UX:*:*)
echo sx6-nec-superux${UNAME_RELEASE}
exit 0 ;;
Power*:Rhapsody:*:*)
echo powerpc-apple-rhapsody${UNAME_RELEASE}
exit 0 ;;
@@ -1111,7 +1073,7 @@ EOF
*:QNX:*:4*)
echo i386-pc-qnx
exit 0 ;;
NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*)
NSR-[GKLNPTVW]:NONSTOP_KERNEL:*:*)
echo nsr-tandem-nsk${UNAME_RELEASE}
exit 0 ;;
*:NonStop-UX:*:*)
@@ -1283,8 +1245,8 @@ main ()
}
EOF
$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
rm -f $dummy.c $dummy && rmdir $tmpdir
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
# Apollos put the system type in the environment.
Vendored
+42 -69
View File
@@ -3,7 +3,7 @@
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002 Free Software Foundation, Inc.
timestamp='2002-09-05'
timestamp='2002-05-28'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@@ -118,7 +118,7 @@ esac
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | freebsd*-gnu* | storm-chaos* | os2-emx* | windows32-* | rtmk-nova*)
nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
@@ -229,34 +229,24 @@ case $basic_machine in
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
| clipper \
| c4x | clipper \
| d10v | d30v | dlx | dsp16xx \
| fr30 | frv \
| fr30 \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \
| ip2k \
| m32r | m68000 | m68k | m88k | mcore \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
| mips64vr | mips64vrel \
| mips64orion | mips64orionel \
| mips64vr4100 | mips64vr4100el \
| mips64vr4300 | mips64vr4300el \
| mips64vr5000 | mips64vr5000el \
| mipsisa32 | mipsisa32el \
| mipsisa64 | mipsisa64el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
| mipstx39 | mipstx39el \
| mips | mips16 | mips64 | mips64el | mips64orion | mips64orionel \
| mips64vr4100 | mips64vr4100el | mips64vr4300 \
| mips64vr4300el | mips64vr5000 | mips64vr5000el \
| mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \
| mipsisa32 | mipsisa64 \
| mn10200 | mn10300 \
| ns16k | ns32k \
| openrisc | or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \
| sh | sh[1234] | sh3e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
| sh | sh[34] | sh[34]eb | shbe | shle | sh64 \
| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
| strongarm \
| tahoe | thumb | tic80 | tron \
@@ -294,42 +284,31 @@ case $basic_machine in
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* \
| bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* \
| c[123]* | c30-* | [cjt]90-* | c54x-* \
| clipper-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
| f30[01]-* | f700-* | fr30-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* \
| m32r-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | mcore-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
| mips64vr-* | mips64vrel-* \
| mips64orion-* | mips64orionel-* \
| mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* \
| mips64vr5000-* | mips64vr5000el-* \
| mipsisa32-* | mipsisa32el-* \
| mipsisa64-* | mipsisa64el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipstx39 | mipstx39el \
| mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \
| mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \
| mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \
| romp-* | rs6000-* \
| sh-* | sh[1234]-* | sh3e-* | sh[34]eb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* | sh64-* \
| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
| sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* | tic30-* | tic4x-* | tic54x-* | tic80-* | tron-* \
| tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \
| v850-* | v850e-* | vax-* \
| we32k-* \
| x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
@@ -749,13 +728,13 @@ case $basic_machine in
pbb)
basic_machine=m68k-tti
;;
pc532 | pc532-*)
pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
pentium | p5 | k5 | k6 | nexgen | viac3)
basic_machine=i586-pc
;;
pentiumpro | p6 | 6x86 | athlon | athlon_*)
pentiumpro | p6 | 6x86 | athlon)
basic_machine=i686-pc
;;
pentiumii | pentium2)
@@ -776,22 +755,22 @@ case $basic_machine in
power) basic_machine=power-ibm
;;
ppc) basic_machine=powerpc-unknown
;;
;;
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppcle | powerpclittle | ppc-le | powerpc-little)
basic_machine=powerpcle-unknown
;;
;;
ppcle-* | powerpclittle-*)
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64) basic_machine=powerpc64-unknown
;;
;;
ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64le | powerpc64little | ppc64-le | powerpc64-little)
basic_machine=powerpc64le-unknown
;;
;;
ppc64le-* | powerpc64little-*)
basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
@@ -822,12 +801,6 @@ case $basic_machine in
basic_machine=a29k-amd
os=-udi
;;
sb1)
basic_machine=mipsisa64sb1-unknown
;;
sb1el)
basic_machine=mipsisa64sb1el-unknown
;;
sequent)
basic_machine=i386-sequent
;;
@@ -893,7 +866,7 @@ case $basic_machine in
sun386 | sun386i | roadrunner)
basic_machine=i386-sun
;;
sv1)
sv1)
basic_machine=sv1-cray
os=-unicos
;;
@@ -913,10 +886,6 @@ case $basic_machine in
basic_machine=t90-cray
os=-unicos
;;
tic4x | c4x*)
basic_machine=tic4x-unknown
os=-coff
;;
tic54x | c54x*)
basic_machine=tic54x-unknown
os=-coff
@@ -955,8 +924,8 @@ case $basic_machine in
os=-vms
;;
vpp*|vx|vx-*)
basic_machine=f301-fujitsu
;;
basic_machine=f301-fujitsu
;;
vxworks960)
basic_machine=i960-wrs
os=-vxworks
@@ -981,7 +950,7 @@ case $basic_machine in
basic_machine=i386-pc
os=-windows32-msvcrt
;;
xps | xps100)
xps | xps100)
basic_machine=xps100-honeywell
;;
ymp)
@@ -1027,7 +996,7 @@ case $basic_machine in
we32k)
basic_machine=we32k-att
;;
sh3 | sh4 | sh3eb | sh4eb | sh[1234]le | sh3ele)
sh3 | sh4 | sh3eb | sh4eb)
basic_machine=sh-unknown
;;
sh64)
@@ -1036,7 +1005,7 @@ case $basic_machine in
sparc | sparcv9 | sparcv9b)
basic_machine=sparc-sun
;;
cydra)
cydra)
basic_machine=cydra-cydrome
;;
orion)
@@ -1051,6 +1020,10 @@ case $basic_machine in
pmac | pmac-mpw)
basic_machine=powerpc-apple
;;
c4x*)
basic_machine=c4x-none
os=-coff
;;
*-unknown)
# Make sure to match an already-canonicalized machine name.
;;
@@ -1182,7 +1155,7 @@ case $os in
os=-rtmk-nova
;;
-ns2 )
os=-nextstep2
os=-nextstep2
;;
-nsk*)
os=-nsk
@@ -1221,8 +1194,8 @@ case $os in
-xenix)
os=-xenix
;;
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
os=-mint
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
os=-mint
;;
-none)
;;
@@ -1259,7 +1232,7 @@ case $basic_machine in
pdp10-*)
os=-tops20
;;
pdp11-*)
pdp11-*)
os=-none
;;
*-dec | vax-*)
@@ -1352,19 +1325,19 @@ case $basic_machine in
*-next)
os=-nextstep3
;;
*-gould)
*-gould)
os=-sysv
;;
*-highlevel)
*-highlevel)
os=-bsd
;;
*-encore)
os=-bsd
;;
*-sgi)
*-sgi)
os=-irix
;;
*-siemens)
*-siemens)
os=-sysv4
;;
*-masscomp)
+110 -229
View File
@@ -30,6 +30,9 @@ dnl -------------------------------------------------------------------------
AC_PREREQ(2.13)
AC_INIT(README.CVS-RULES)
dnl check for working sed
PHP_PROG_SED
PHP_CONFIG_NICE(config.nice)
for arg in $0 "$@"; do
CONFIGURE_COMMAND="$CONFIGURE_COMMAND '$arg'"
@@ -40,8 +43,8 @@ AC_CONFIG_HEADER(main/php_config.h)
MAJOR_VERSION=4
MINOR_VERSION=3
RELEASE_VERSION=10
EXTRA_VERSION="RC2"
RELEASE_VERSION=0
EXTRA_VERSION="RC1"
VERSION="$MAJOR_VERSION.$MINOR_VERSION.$RELEASE_VERSION$EXTRA_VERSION"
dnl Define where extension directories are located in the configure context
@@ -61,15 +64,16 @@ echo "#define PHP_MINOR_VERSION $MINOR_VERSION" >> php_version.h.new
echo "#define PHP_RELEASE_VERSION $RELEASE_VERSION" >> php_version.h.new
echo "#define PHP_EXTRA_VERSION \"$EXTRA_VERSION\"" >> php_version.h.new
echo "#define PHP_VERSION \"$PHP_VERSION\"" >> php_version.h.new
cmp php_version.h.new $srcdir/main/php_version.h >/dev/null 2>&1
cmp php_version.h.new php_version.h >/dev/null 2>&1
if test $? -ne 0 ; then
rm -f $srcdir/main/php_version.h && mv php_version.h.new $srcdir/main/php_version.h && \
echo 'Updated main/php_version.h'
rm -f php_version.h && mv php_version.h.new php_version.h && \
echo 'Updated php_version.h'
else
rm -f php_version.h.new
fi
dnl Catch common errors here to save a few seconds of our users' time
dnl -------------------------------------------------------------------------
@@ -87,12 +91,12 @@ dnl -------------------------------------------------------------------------
cwd=`pwd`
PHP_INIT_BUILD_SYSTEM
php_shtool=$srcdir/build/shtool
T_MD=`$php_shtool echo -n -e %B`
T_ME=`$php_shtool echo -n -e %b`
PHP_INIT_BUILD_SYSTEM
dnl We want this one before the checks, so the checks can modify CFLAGS.
test -z "$CFLAGS" && auto_cflags=1
@@ -127,7 +131,6 @@ dnl AC_PROG_CXXCPP
dnl check for -R, etc. switch
PHP_RUNPATH_SWITCH
PHP_PROG_RE2C
AC_PROG_RANLIB
AC_PROG_LN_S
AC_PROG_AWK
@@ -136,9 +139,9 @@ if test "$YACC" != "bison -y"; then
AC_MSG_WARN([You will need bison if you want to regenerate the PHP parsers.])
else
AC_MSG_CHECKING([bison version])
set `bison --version| grep 'GNU Bison' | cut -d ' ' -f 4 | sed -e 's/\./ /'|tr -d a-z`
if test "${1}" -ne "1" -o "(" "${2}" != "28" -a "${2}" != "35" -a "${2}" != "75" -a "${2}" != "875" ")"; then
AC_MSG_WARN(You will need bison 1.28, 1.35, 1.75 or 1.875 if you want to regenerate the Zend parser (found ${1}.${2}).)
set `bison --version| grep 'GNU Bison' | cut -d ' ' -f 4 | sed -e 's/\./ /'`
if test "${1}" = "1" -a "${2}" -lt "28"; then
AC_MSG_WARN(You will need bison 1.28 if you want to regenerate the Zend parser (found ${1}.${2}).)
fi
AC_MSG_RESULT(${1}.${2} (ok))
fi
@@ -156,19 +159,11 @@ if test "$ac_cv_c_const" = "yes" ; then
fi
AC_MSG_CHECKING([flex version])
if test "$LEX" ;then
flexvers=`echo "" | $LEX -V -v --version 2>/dev/null |
sed -e 's/^.* //' -e 's/\./ /g'`
if test ! -z "$flexvers"; then
set $flexvers
if test "${1}" != "2" -o "${2}" != "5" -o "${3}" -lt "4"; then
AC_MSG_WARN(You will need flex 2.5.4 or later if you want to regenerate Zend/PHP lexical parsers.)
fi
fi
AC_MSG_RESULT(${1}.${2}.${3} (ok))
else
AC_MSG_WARN(You will need flex 2.5.4 or later if you want to regenerate Zend/PHP lexical parsers.)
set `$LEX -V | grep 'version' | cut -d ' ' -f 3 | sed -e 's/\./ /g' | sed -e 's/[^0-9 ]//g'`
if test "${1}" != "2" -o "${2}" != "5" -o "${3}" -lt "4"; then
AC_MSG_WARN(You will need flex 2.5.4 or later if you want to regenerate Zend/PHP lexical parsers.)
fi
AC_MSG_RESULT(${1}.${2}.${3} (ok))
dnl Platform-specific compile settings.
dnl -------------------------------------------------------------------------
@@ -189,7 +184,6 @@ case $host_alias in
CPPFLAGS="$CPPFLAGS -D_BSD_TIMEOFDAY_FLAVOR";;
*darwin*|*rhapsody*)
CPPFLAGS="$CPPFLAGS -no-cpp-precomp"
AC_DEFINE(BIND_8_COMPAT, 1, [Enabling BIND8 compatibility for Panther])
php_multiple_shlib_versions_ok=yes;;
*beos*)
beos_threads=1
@@ -237,7 +231,7 @@ SAPI_LIBTOOL=libphp4.la
PHP_CONFIGURE_PART(Configuring SAPI modules)
esyscmd(./build/config-stubs sapi)
esyscmd(./scripts/config-stubs sapi)
dnl Show which main SAPI was selected
AC_MSG_CHECKING([for chosen SAPI module])
@@ -248,11 +242,6 @@ if test "$enable_experimental_zts" = "yes"; then
PTHREADS_FLAGS
fi
if test "$PHP_ENABLE_FASTCGI" = "yes"; then
PHP_CONFIGURE_PART(Running FastCGI checks)
sinclude(sapi/cgi/libfcgi/acinclude.m4)
sinclude(sapi/cgi/libfcgi/libfcgi.m4)
fi
divert(3)
@@ -318,14 +307,17 @@ dnl -------------------------------------------------------------------------
dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_DIRENT
dnl In QNX opendir resides in libc but dirent.h is still required
if test "`uname -s 2>/dev/null`" != "QNX"; then
AC_HEADER_DIRENT
else
AC_CHECK_HEADERS(dirent.h)
fi
PHP_MISSING_FCLOSE_DECL
dnl QNX requires unix.h to allow functions in libunix to work properly
AC_CHECK_HEADERS([ \
dirent.h \
ApplicationServices/ApplicationServices.h \
sys/param.h \
sys/types.h \
sys/time.h \
netinet/in.h \
@@ -369,11 +361,7 @@ unix.h \
utime.h \
sys/utsname.h \
sys/ipc.h \
dlfcn.h
],[],[],[
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@@ -388,9 +376,7 @@ dlfcn.h
#endif
])
PHP_FOPENCOOKIE
PHP_BROKEN_GETCWD
PHP_BROKEN_GLIBC_FOPEN_APPEND
dnl Checks for typedefs, structures, and compiler characteristics.
dnl -------------------------------------------------------------------------
@@ -453,7 +439,6 @@ dnl -------------------------------------------------------------------------
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(
alphasort \
asctime_r \
chroot \
ctime_r \
@@ -461,7 +446,6 @@ cuserid \
crypt \
flock \
ftok \
funopen \
gai_strerror \
gcvt \
getlogin \
@@ -482,7 +466,6 @@ memmove \
mkstemp \
mmap \
nl_langinfo \
perror \
poll \
putenv \
realpath \
@@ -490,7 +473,6 @@ random \
rand_r \
regcomp \
res_search \
scandir \
setitimer \
setlocale \
localeconv \
@@ -521,48 +503,10 @@ vsnprintf \
)
dnl Check for getaddrinfo, should be a better way, but...
dnl Also check for working getaddrinfo
AC_CACHE_CHECK([for getaddrinfo], ac_cv_func_getaddrinfo,
[AC_TRY_LINK([#include <netdb.h>],
[struct addrinfo *g,h;g=&h;getaddrinfo("","",g,&g);],
AC_TRY_RUN([
#include <netdb.h>
#include <sys/types.h>
#ifndef AF_INET
# include <sys/socket.h>
#endif
int main(void) {
struct addrinfo *ai, *pai, hints;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_NUMERICHOST;
if (getaddrinfo("127.0.0.1", 0, &hints, &ai) < 0) {
exit(1);
}
if (ai == 0) {
exit(1);
}
pai = ai;
while (pai) {
if (pai->ai_family != AF_INET) {
/* 127.0.0.1/NUMERICHOST should only resolve ONE way */
exit(1);
}
if (pai->ai_addr->sa_family != AF_INET) {
/* 127.0.0.1/NUMERICHOST should only resolve ONE way */
exit(1);
}
pai = pai->ai_next;
}
freeaddrinfo(ai);
exit(0);
}
],ac_cv_func_getaddrinfo=yes, ac_cv_func_getaddrinfo=no),
ac_cv_func_getaddrinfo=no)])
[AC_TRY_COMPILE([#include <netdb.h>],
[struct addrinfo *g,h;g=&h;getaddrinfo("","",g,&g);],
ac_cv_func_getaddrinfo=yes, ac_cv_func_getaddrinfo=no)])
if test "$ac_cv_func_getaddrinfo" = yes; then
AC_DEFINE(HAVE_GETADDRINFO,1,[Define if you have the getaddrinfo function])
fi
@@ -570,8 +514,8 @@ fi
AC_REPLACE_FUNCS(strlcat strlcpy getopt)
AC_FUNC_UTIME_NULL
AC_FUNC_ALLOCA
dnl PHP_AC_BROKEN_SPRINTF
dnl PHP_AC_BROKEN_SNPRINTF
PHP_AC_BROKEN_SPRINTF
PHP_AC_BROKEN_SNPRINTF
PHP_DECLARED_TIMEZONE
PHP_TIME_R_TYPE
PHP_READDIR_R_TYPE
@@ -604,7 +548,7 @@ dnl ## In diversion 4 we check user-configurable general settings.
dnl General settings.
dnl -------------------------------------------------------------------------
PHP_CONFIGURE_PART(General settings)
PHP_HELP_SEPARATOR([General settings:])
@@ -654,6 +598,27 @@ if test "$PHP_CONFIG_FILE_SCAN_DIR" = "DEFAULT"; then
PHP_CONFIG_FILE_SCAN_DIR=""
fi
# compatibility
if test -z "$with_pear" && test "$enable_pear" = "no"; then
with_pear=no
fi
PHP_ARG_WITH(pear, [whether to install PEAR, and where],
[ --with-pear=DIR Install PEAR in DIR (default PREFIX/lib/php)
--without-pear Do not install PEAR], DEFAULT, no)
if test "$PHP_PEAR" != "no" && test "$disable_cli" != "1"; then
install_pear="install-pear install-build install-headers install-programs"
PEAR_INSTALLDIR=$PHP_PEAR
fi
if test "$PHP_PEAR" = "DEFAULT" || test "$PHP_PEAR" = "yes"; then
case $PHP_LAYOUT in
GNU) PEAR_INSTALLDIR=$datadir/pear;;
*) PEAR_INSTALLDIR=$libdir/php;;
esac
fi
test -n "$DEBUG_CFLAGS" && CFLAGS="$CFLAGS $DEBUG_CFLAGS"
PHP_ARG_ENABLE(safe-mode, whether to enable safe mode by default,
@@ -751,19 +716,24 @@ if test "$PHP_IPV6" != "no" && test "$ac_cv_ipv6_support" = yes; then
AC_DEFINE(HAVE_IPV6,1,[Whether to enable IPv6 support])
fi
AC_MSG_CHECKING([whether to enable versioning])
AC_ARG_ENABLE(versioning,
[ --enable-versioning Export only required symbols.
See INSTALL for more information], [
if test "x$APXS" != "x"; then
PHP_VERSIONING=$enableval
else
PHP_VERSIONING=no
fi
],[
PHP_VERSIONING=no
dnl
dnl OpenSSL configure
dnl
PHP_ARG_WITH(openssl,for OpenSSL support,
[ --with-openssl[=DIR] Include OpenSSL support (requires OpenSSL >= 0.9.5) ])
if test "$PHP_OPENSSL" != "no"; then
ext_openssl_shared=$ext_shared
PHP_SETUP_OPENSSL
fi
AC_CHECK_LIB(crypt, crypt, [
PHP_ADD_LIBRARY(crypt)
PHP_ADD_LIBRARY(crypt, 1)
AC_DEFINE(HAVE_CRYPT,1,[ ])
])
AC_MSG_RESULT([$PHP_VERSIONING])
divert(5)
@@ -793,20 +763,34 @@ dnl
AC_ARG_ENABLE(all,
[ --disable-all Disable all extensions enabled by default.
--enable-all Enable all extensions.
], [
PHP_ENABLE_ALL=$enableval
])
# reading config stubs
esyscmd(./build/config-stubs ext)
esyscmd(./scripts/config-stubs ext)
dnl Extensions post-config
dnl Other settings.
dnl -------------------------------------------------------------------------
PHP_HELP_SEPARATOR([Other settings:])
AC_MSG_CHECKING([whether to enable versioning])
AC_ARG_ENABLE(versioning,
[ --enable-versioning Export only required symbols.
See INSTALL for more information],[
PHP_VERSIONING=$enableval
],[
PHP_VERSIONING=no
])
AC_MSG_RESULT([$PHP_VERSIONING])
if test "$PHP_VERSIONING" = "yes"; then
test -z "$PHP_SYM_FILE" && PHP_SYM_FILE="$abs_srcdir/sapi/$PHP_SAPI/php.sym"
if test -f "$PHP_SYM_FILE"; then
EXTRA_LDFLAGS="-export-symbols $PHP_SYM_FILE $EXTRA_LDFLAGS"
EXTRA_LDFLAGS="-export-symbols $PHP_SYM_FILE"
fi
fi
@@ -828,80 +812,15 @@ shared)
;;
esac
PHP_REGEX
EXTRA_LIBS="$EXTRA_LIBS $DLIBS $LIBS"
dnl this has to be here to prevent the openssl crypt() from
dnl overriding the system provided crypt().
if test "$ac_cv_lib_crypt_crypt" = "yes"; then
EXTRA_LIBS="-lcrypt $EXTRA_LIBS -lcrypt"
fi
unset LIBS LDFLAGS
dnl PEAR
dnl -------------------------------------------------------------------------
PHP_HELP_SEPARATOR([PEAR:])
PHP_CONFIGURE_PART(Configuring PEAR)
# compatibility
if test -z "$with_pear" && test "$enable_pear" = "no"; then
with_pear=no
fi
PHP_ARG_WITH(pear, [whether to install PEAR],
[ --with-pear=DIR Install PEAR in DIR (default PREFIX/lib/php)
--without-pear Do not install PEAR], DEFAULT, yes)
if test "$PHP_PEAR" != "no"; then
dnl
dnl PEAR dependancies
dnl
if test "$PHP_SAPI_CLI" = "no"; then
pear_error_msg="$pear_error_msg
PEAR requires CLI to be enabled. Add --enable-cli to the configure line. (or --disable-pear)"
fi
if test "$PHP_PCRE_REGEX" = "no"; then
pear_error_msg="$pear_error_msg
PEAR requires PCRE to be enabled. Add --with-pcre-regex to the configure line. (or --disable-pear)"
fi
if test "$PHP_XML" = "no"; then
pear_error_msg="$pear_error_msg
PEAR requires XML to be enabled. Add --enable-xml to the configure line. (or --disable-pear)"
fi
dnl
dnl ext/xmlrpc is not really there yet to be a requirement..
dnl
dnl if test "$PHP_XMLRPC" = "no"; then
dnl pear_error_msg="$pear_error_msg
dnl PEAR requires XML-RPC to be enabled. Add --with-xmlrpc to the configure line. (or --disable-pear)"
dnl fi
dnl
if test "$pear_error_msg"; then
AC_MSG_ERROR([$pear_error_msg])
fi
install_pear="install-pear"
PEAR_INSTALLDIR=$PHP_PEAR
if test "$PHP_PEAR" = "DEFAULT" || test "$PHP_PEAR" = "yes"; then
case $PHP_LAYOUT in
GNU) PEAR_INSTALLDIR=$datadir/pear;;
*) PEAR_INSTALLDIR=$libdir/php;;
esac
fi
fi
dnl Configuring Zend and TSRM.
dnl -------------------------------------------------------------------------
PHP_HELP_SEPARATOR([Zend:])
PHP_CONFIGURE_PART(Configuring Zend)
LIBZEND_BASIC_CHECKS
LIBZEND_DLSYM_CHECK
LIBZEND_OTHER_CHECKS
@@ -919,27 +838,23 @@ fi
if test "$abs_srcdir" != "$abs_builddir"; then
INCLUDES="$INCLUDES -I\$(top_srcdir)/main -I\$(top_srcdir)/Zend"
INCLUDES="$INCLUDES -I\$(top_srcdir)/TSRM -I\$(top_builddir)/"
INCLUDES="$INCLUDES -I\$(top_srcdir)/TSRM"
fi
ZEND_EXTRA_LIBS="$LIBS"
unset LIBS LDFLAGS
PHP_HELP_SEPARATOR([TSRM:])
PHP_CONFIGURE_PART(Configuring TSRM)
TSRM_BASIC_CHECKS
if test "$PHP_THREAD_SAFETY" = "yes"; then
TSRM_THREADS_CHECKS
fi
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LDFLAGS"
EXTRA_LDFLAGS_PROGRAM="$EXTRA_LDFLAGS_PROGRAM $LDFLAGS"
EXTRA_LIBS="$EXTRA_LIBS $LIBS"
unset LIBS LDFLAGS
test "$prefix" = "NONE" && prefix=/usr/local
test "$exec_prefix" = "NONE" && exec_prefix='${prefix}'
test "$program_prefix" = "NONE" && program_prefix=
test "$program_suffix" = "NONE" && program_suffix=
case $libdir in
'${exec_prefix}/lib')
@@ -1034,7 +949,6 @@ if test -z "$php_ldflags_add_usr_lib"; then
fi
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $PHP_LDFLAGS"
EXTRA_LDFLAGS_PROGRAM="$EXTRA_LDFLAGS_PROGRAM $PHP_LDFLAGS"
PHP_BUILD_DATE=`date '+%Y-%m-%d'`
AC_DEFINE_UNQUOTED(PHP_BUILD_DATE,"$PHP_BUILD_DATE",[PHP build date])
@@ -1044,7 +958,7 @@ PHP_OS=`uname | xargs`
AC_DEFINE_UNQUOTED(PHP_OS,"$PHP_OS",[uname output])
if test "$disable_cli" != "1"; then
PHP_CLI_TARGET="\$(SAPI_CLI_PATH)"
PHP_CLI_TARGET=sapi/cli/php
PHP_INSTALL_CLI_TARGET="install-cli"
PHP_ADD_SOURCES(sapi/cli, php_cli.c getopt.c,, cli)
fi
@@ -1065,11 +979,8 @@ PHP_SUBST_OLD(php_abs_top_srcdir)
PHP_SUBST(bindir)
PHP_SUBST(exec_prefix)
PHP_SUBST(program_prefix)
PHP_SUBST(program_suffix)
PHP_SUBST(includedir)
PHP_SUBST(libdir)
PHP_SUBST(mandir)
PHP_SUBST(phplibdir)
PHP_SUBST(phptempdir)
PHP_SUBST(prefix)
@@ -1091,8 +1002,7 @@ PHP_SUBST(CXX_PHP_COMPILE)
PHP_SUBST_OLD(DEBUG_CFLAGS)
PHP_SUBST(DEFS)
PHP_SUBST_OLD(EXTENSION_DIR)
PHP_SUBST_OLD(EXTRA_LDFLAGS)
PHP_SUBST_OLD(EXTRA_LDFLAGS_PROGRAM)
PHP_SUBST(EXTRA_LDFLAGS)
PHP_SUBST_OLD(EXTRA_LIBS)
PHP_SUBST_OLD(ZEND_EXTRA_LIBS)
PHP_SUBST_OLD(INCLUDES)
@@ -1115,7 +1025,6 @@ PHP_SUBST(PHP_RPATHS)
PHP_SUBST(PHP_SAPI)
PHP_SUBST_OLD(PHP_VERSION)
PHP_SUBST(PROG_SENDMAIL)
PHP_SUBST(RE2C)
PHP_SUBST(SHELL)
PHP_SUBST(SHARED_LIBTOOL)
PHP_SUBST(TSRM_DIR)
@@ -1145,21 +1054,11 @@ if test "$PHP_THREAD_SAFETY" = "yes" && test "$PHP_MYSQL" = "yes"; then
CPPFLAGS="$CPPFLAGS -DTHREAD=1"
fi
dnl
dnl Libtool creation
dnl
PHP_HELP_SEPARATOR([Libtool:])
PHP_CONFIGURE_PART(Configuring libtool)
LDFLAGS="$LDFLAGS $PHP_AIX_LDFLAGS"
AC_PROG_LIBTOOL
if test "$enable_debug" != "yes"; then
PHP_SET_LIBTOOL_VARIABLE([--silent])
fi
dnl libtool 1.4.3 needs this.
PHP_SET_LIBTOOL_VARIABLE([--preserve-dup-deps])
test -z "$PHP_COMPILE" && PHP_COMPILE='$(LIBTOOL) --mode=compile $(COMPILE) -c $<'
test -z "$CXX_PHP_COMPILE" && CXX_PHP_COMPILE='$(LIBTOOL) --mode=compile $(CXX_COMPILE) -c $<'
@@ -1176,27 +1075,14 @@ INLINE_CFLAGS="$INLINE_CFLAGS $standard_libtool_flag"
CXXFLAGS="$CXXFLAGS $standard_libtool_flag"
all_targets='$(OVERALL_TARGET) $(PHP_MODULES) $(PHP_CLI_TARGET)'
install_targets="$install_modules $install_pear install-build install-headers install-programs"
case $PHP_SAPI in
cgi)
install_targets="install-sapi $install_targets"
;;
cli)
install_targets="$PHP_INSTALL_CLI_TARGET $install_targets"
;;
*)
install_targets="install-sapi $PHP_INSTALL_CLI_TARGET $install_targets"
;;
esac
install_targets="install-sapi install-modules $PHP_INSTALL_CLI_TARGET $install_pear"
PHP_SUBST(all_targets)
PHP_SUBST(install_targets)
PHP_ADD_SOURCES(TSRM, TSRM.c tsrm_strtok_r.c tsrm_virtual_cwd.c)
PHP_ADD_SOURCES(main, main.c snprintf.c spprintf.c php_sprintf.c \
safe_mode.c fopen_wrappers.c alloca.c php_scandir.c \
safe_mode.c fopen_wrappers.c alloca.c \
php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c \
streams.c network.c php_open_temporary_file.c php_logos.c \
@@ -1204,7 +1090,7 @@ PHP_ADD_SOURCES(main, main.c snprintf.c spprintf.c php_sprintf.c \
PHP_ADD_SOURCES(/main, internal_functions.c,, sapi)
PHP_ADD_SOURCES(/main, internal_functions_cli.c,, cli)
PHP_ADD_SOURCES(/Zend, zend_language_parser.c zend_language_scanner.c \
PHP_ADD_SOURCES(/Zend, zend_language_parser.c zend_language_scanner.c \
zend_ini_parser.c zend_ini_scanner.c)
PHP_ADD_SOURCES(Zend, \
@@ -1213,7 +1099,7 @@ PHP_ADD_SOURCES(Zend, \
zend_opcode.c zend_operators.c zend_ptr_stack.c zend_stack.c \
zend_variables.c zend.c zend_API.c zend_extensions.c zend_hash.c \
zend_list.c zend_indent.c zend_builtin_functions.c zend_sprintf.c \
zend_ini.c zend_qsort.c zend_multibyte.c zend_strtod.c)
zend_ini.c zend_qsort.c zend_multibyte.c)
if test -r "$abs_srcdir/Zend/zend_objects.c"; then
PHP_ADD_SOURCES(Zend, zend_objects.c zend_object_handlers.c zend_objects_API.c zend_mm.c)
@@ -1235,7 +1121,7 @@ PHP_ADD_BUILD_DIR(sapi/$PHP_SAPI sapi/cli)
PHP_ADD_BUILD_DIR(TSRM)
PHP_ADD_BUILD_DIR(Zend)
PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/scripts/Makefile.frag,$abs_srcdir/scripts,scripts)
PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/pear/Makefile.frag,$abs_srcdir/pear,pear)
PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/Makefile.frag,$abs_srcdir/Zend,Zend)
@@ -1245,10 +1131,8 @@ PHP_GEN_GLOBAL_MAKEFILE
AC_DEFINE([HAVE_BUILD_DEFS_H], 1, [ ])
$php_shtool mkdir -p pear/scripts
$php_shtool mkdir -p scripts
ALL_OUTPUT_FILES="php4.spec main/build-defs.h \
scripts/phpize scripts/php-config \
pear/scripts/phpize pear/scripts/php-config \
$PHP_OUTPUT_FILES"
AC_OUTPUT($ALL_OUTPUT_FILES, [], [
@@ -1257,14 +1141,21 @@ if test "\$CONFIG_FILES" = "$ALL_OUTPUT_FILES" || test "\$CONFIG_FILES" = " $ALL
REDO_ALL=yes
fi
if test ! -f $srcdir/ext/bcmath/number.c; then
echo "creating number.c"
echo "/* Dummy File */" > $srcdir/ext/bcmath/number.c
echo "creating number.h"
echo "/* Dummy File */" > $srcdir/ext/bcmath/number.h
fi
################################################################
# Create configuration headers
#
test -d TSRM || $php_shtool mkdir TSRM
test -d TSRM || mkdir TSRM
echo '#include "../main/php_config.h"' > TSRM/tsrm_config.h
test -d Zend || $php_shtool mkdir Zend
test -d Zend || mkdir Zend
cat >Zend/zend_config.h <<FEO
#include "../main/php_config.h"
@@ -1344,17 +1235,6 @@ cat <<X
X
fi
if test "$PHP_DB" != "no"; then
cat <<X
+--------------------------------------------------------------------+
| *** WARNING *** |
| |
| You chose to compile PHP with DB extension. This extension is |
| deprecated and does not support database locking correctly. Please |
| use DBA extension which is a fully operational superset. |
X
fi
if test "$MYSQL_MODULE_TYPE" = "builtin" && test "$PHP_SAPI" != "cgi" && test "$PHP_SAPI" != "cli" && test "$php_multiple_shlib_versions_ok" != "yes"; then
cat <<X
+--------------------------------------------------------------------+
@@ -1395,7 +1275,7 @@ X
fi
fi
cat <<X
cat<<X
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
@@ -1410,11 +1290,12 @@ cat <<X
| If your application relies on register_globals being ON, you |
| should explicitly set it to on in your php.ini file. |
| Note that you are strongly encouraged to read |
| http://www.php.net/manual/en/security.globals.php |
| http://www.php.net/manual/en/security.registerglobals.php |
| about the implications of having register_globals set to on, and |
| avoid using it if possible. |
+--------------------------------------------------------------------+
Thank you for using PHP.
X
+1 -1
View File
@@ -1,3 +1,3 @@
#! /bin/sh
${MAKE:-make} -f build/build.mk cvsclean-work
${MAKE:-make} -f build/build.mk cvsclean
+78 -102
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -30,8 +30,6 @@
#include "php_bcmath.h"
#include "libbcmath/src/bcmath.h"
ZEND_DECLARE_MODULE_GLOBALS(bcmath);
function_entry bcmath_functions[] = {
PHP_FE(bcadd, NULL)
PHP_FE(bcsub, NULL)
@@ -49,11 +47,7 @@ zend_module_entry bcmath_module_entry = {
STANDARD_MODULE_HEADER,
"bcmath",
bcmath_functions,
#if ZTS
PHP_MODULE_STARTUP_N(bcmath),
#else
NULL,
#endif
NULL,
PHP_RINIT(bcmath),
PHP_RSHUTDOWN(bcmath),
@@ -70,22 +64,32 @@ ZEND_GET_MODULE(bcmath)
static long bc_precision;
#endif
#if ZTS
PHP_MODULE_STARTUP_D(bcmath)
{
zend_bcmath_globals *bcmath_globals;
/* Storage used for special numbers. */
extern bc_num _zero_;
extern bc_num _one_;
extern bc_num _two_;
ts_allocate_id(&bcmath_globals_id, sizeof(zend_bcmath_globals), NULL, NULL);
bcmath_globals = ts_resource(bcmath_globals_id);
return SUCCESS;
/* Make a copy of a number! Just increments the reference count! */
bc_num copy_num (bc_num num)
{
num->n_refs++;
return num;
}
#endif
/* Initialize a number NUM by making it a copy of zero. */
void init_num (bc_num *num)
{
*num = copy_num (_zero_);
}
PHP_RSHUTDOWN_FUNCTION(bcmath)
{
bc_free_num(&BCG(_zero_));
bc_free_num(&BCG(_one_));
bc_free_num(&BCG(_two_));
bc_free_num(&_zero_);
bc_free_num(&_one_);
bc_free_num(&_two_);
return SUCCESS;
}
@@ -96,8 +100,8 @@ PHP_RINIT_FUNCTION(bcmath)
if (cfg_get_long("bcmath.scale", &bc_precision)==FAILURE) {
bc_precision=0;
}
if(bc_precision<0) bc_precision=0;
bc_init_numbers(TSRMLS_C);
bc_init_numbers();
return SUCCESS;
}
@@ -110,21 +114,6 @@ PHP_MINFO_FUNCTION(bcmath)
php_info_print_table_end();
}
/* {{{ php_str2num
Convert to bc_num detecting scale */
static void php_str2num(bc_num *num, char *str TSRMLS_DC)
{
char *p;
if (!(p = strchr(str, '.'))) {
bc_str2num(num, str, 0 TSRMLS_CC);
return;
}
bc_str2num(num, str, strlen(p+1) TSRMLS_CC);
}
/* }}} */
/* {{{ proto string bcadd(string left_operand, string right_operand [, int scale])
Returns the sum of two arbitrary precision numbers */
PHP_FUNCTION(bcadd)
@@ -144,7 +133,7 @@ PHP_FUNCTION(bcadd)
WRONG_PARAM_COUNT;
}
convert_to_long_ex(scale_param);
scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param);
scale = (int) Z_LVAL_PP(scale_param);
break;
default:
WRONG_PARAM_COUNT;
@@ -152,14 +141,12 @@ PHP_FUNCTION(bcadd)
}
convert_to_string_ex(left);
convert_to_string_ex(right);
bc_init_num(&first TSRMLS_CC);
bc_init_num(&second TSRMLS_CC);
bc_init_num(&result TSRMLS_CC);
php_str2num(&first, Z_STRVAL_PP(left) TSRMLS_CC);
php_str2num(&second, Z_STRVAL_PP(right) TSRMLS_CC);
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
bc_str2num(&first, Z_STRVAL_PP(left), scale);
bc_str2num(&second, Z_STRVAL_PP(right), scale);
bc_add (first, second, &result, scale);
if (result->n_scale > scale)
result->n_scale = scale;
Z_STRVAL_P(return_value) = bc_num2str(result);
Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
Z_TYPE_P(return_value) = IS_STRING;
@@ -189,7 +176,7 @@ PHP_FUNCTION(bcsub)
WRONG_PARAM_COUNT;
}
convert_to_long_ex(scale_param);
scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param);
scale = (int) Z_LVAL_PP(scale_param);
break;
default:
WRONG_PARAM_COUNT;
@@ -197,14 +184,12 @@ PHP_FUNCTION(bcsub)
}
convert_to_string_ex(left);
convert_to_string_ex(right);
bc_init_num(&first TSRMLS_CC);
bc_init_num(&second TSRMLS_CC);
bc_init_num(&result TSRMLS_CC);
php_str2num(&first, Z_STRVAL_PP(left) TSRMLS_CC);
php_str2num(&second, Z_STRVAL_PP(right) TSRMLS_CC);
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
bc_str2num(&first, Z_STRVAL_PP(left), scale);
bc_str2num(&second, Z_STRVAL_PP(right), scale);
bc_sub (first, second, &result, scale);
if (result->n_scale > scale)
result->n_scale = scale;
Z_STRVAL_P(return_value) = bc_num2str(result);
Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
Z_TYPE_P(return_value) = IS_STRING;
@@ -234,7 +219,7 @@ PHP_FUNCTION(bcmul)
WRONG_PARAM_COUNT;
}
convert_to_long_ex(scale_param);
scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param);
scale = (int) Z_LVAL_PP(scale_param);
break;
default:
WRONG_PARAM_COUNT;
@@ -242,14 +227,12 @@ PHP_FUNCTION(bcmul)
}
convert_to_string_ex(left);
convert_to_string_ex(right);
bc_init_num(&first TSRMLS_CC);
bc_init_num(&second TSRMLS_CC);
bc_init_num(&result TSRMLS_CC);
php_str2num(&first, Z_STRVAL_PP(left) TSRMLS_CC);
php_str2num(&second, Z_STRVAL_PP(right) TSRMLS_CC);
bc_multiply (first, second, &result, scale TSRMLS_CC);
if (result->n_scale > scale)
result->n_scale = scale;
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
bc_str2num(&first, Z_STRVAL_PP(left), scale);
bc_str2num(&second, Z_STRVAL_PP(right), scale);
bc_multiply (first, second, &result, scale);
Z_STRVAL_P(return_value) = bc_num2str(result);
Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
Z_TYPE_P(return_value) = IS_STRING;
@@ -279,7 +262,7 @@ PHP_FUNCTION(bcdiv)
WRONG_PARAM_COUNT;
}
convert_to_long_ex(scale_param);
scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param);
scale = (int) Z_LVAL_PP(scale_param);
break;
default:
WRONG_PARAM_COUNT;
@@ -287,21 +270,19 @@ PHP_FUNCTION(bcdiv)
}
convert_to_string_ex(left);
convert_to_string_ex(right);
bc_init_num(&first TSRMLS_CC);
bc_init_num(&second TSRMLS_CC);
bc_init_num(&result TSRMLS_CC);
php_str2num(&first, Z_STRVAL_PP(left) TSRMLS_CC);
php_str2num(&second, Z_STRVAL_PP(right) TSRMLS_CC);
switch (bc_divide (first, second, &result, scale TSRMLS_CC)) {
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
bc_str2num(&first, Z_STRVAL_PP(left), scale);
bc_str2num(&second, Z_STRVAL_PP(right), scale);
switch (bc_divide (first, second, &result, scale)) {
case 0: /* OK */
if (result->n_scale > scale)
result->n_scale = scale;
Z_STRVAL_P(return_value) = bc_num2str(result);
Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
Z_TYPE_P(return_value) = IS_STRING;
break;
case -1: /* division by zero */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Division by zero");
php_error(E_WARNING, "%s(): Division by zero", get_active_function_name(TSRMLS_C));
break;
}
bc_free_num(&first);
@@ -330,19 +311,19 @@ PHP_FUNCTION(bcmod)
}
convert_to_string_ex(left);
convert_to_string_ex(right);
bc_init_num(&first TSRMLS_CC);
bc_init_num(&second TSRMLS_CC);
bc_init_num(&result TSRMLS_CC);
bc_str2num(&first, Z_STRVAL_PP(left), 0 TSRMLS_CC);
bc_str2num(&second, Z_STRVAL_PP(right), 0 TSRMLS_CC);
switch (bc_modulo(first, second, &result, 0 TSRMLS_CC)) {
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
bc_str2num(&first, Z_STRVAL_PP(left), 0);
bc_str2num(&second, Z_STRVAL_PP(right), 0);
switch (bc_modulo(first, second, &result, 0)) {
case 0:
Z_STRVAL_P(return_value) = bc_num2str(result);
Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
Z_TYPE_P(return_value) = IS_STRING;
break;
case -1:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Division by zero");
php_error(E_WARNING, "%s(): Division by zero", get_active_function_name(TSRMLS_C));
break;
}
bc_free_num(&first);
@@ -371,7 +352,7 @@ PHP_FUNCTION(bcpow)
WRONG_PARAM_COUNT;
}
convert_to_long_ex(scale_param);
scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param);
scale = (int) Z_LVAL_PP(scale_param);
break;
default:
WRONG_PARAM_COUNT;
@@ -379,14 +360,12 @@ PHP_FUNCTION(bcpow)
}
convert_to_string_ex(left);
convert_to_string_ex(right);
bc_init_num(&first TSRMLS_CC);
bc_init_num(&second TSRMLS_CC);
bc_init_num(&result TSRMLS_CC);
php_str2num(&first, Z_STRVAL_PP(left) TSRMLS_CC);
php_str2num(&second, Z_STRVAL_PP(right) TSRMLS_CC);
bc_raise (first, second, &result, scale TSRMLS_CC);
if (result->n_scale > scale)
result->n_scale = scale;
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
bc_str2num(&first, Z_STRVAL_PP(left), scale);
bc_str2num(&second, Z_STRVAL_PP(right), scale);
bc_raise (first, second, &result, scale);
Z_STRVAL_P(return_value) = bc_num2str(result);
Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
Z_TYPE_P(return_value) = IS_STRING;
@@ -416,30 +395,28 @@ PHP_FUNCTION(bcsqrt)
WRONG_PARAM_COUNT;
}
convert_to_long_ex(scale_param);
scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param);
scale = (int) Z_LVAL_PP(scale_param);
break;
default:
WRONG_PARAM_COUNT;
break;
}
convert_to_string_ex(left);
bc_init_num(&result TSRMLS_CC);
php_str2num(&result, Z_STRVAL_PP(left) TSRMLS_CC);
if (bc_sqrt (&result, scale TSRMLS_CC) != 0) {
if (result->n_scale > scale)
result->n_scale = scale;
bc_init_num(&result);
bc_str2num(&result, Z_STRVAL_PP(left), scale);
if (bc_sqrt (&result, scale) != 0) {
Z_STRVAL_P(return_value) = bc_num2str(result);
Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
Z_TYPE_P(return_value) = IS_STRING;
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Square root of negative number");
php_error(E_WARNING, "%s(): Square root of negative number", get_active_function_name(TSRMLS_C));
}
bc_free_num(&result);
return;
}
/* }}} */
/* {{{ proto int bccomp(string left_operand, string right_operand [, int scale])
/* {{{ proto string bccomp(string left_operand, string right_operand [, int scale])
Compares two arbitrary precision numbers */
PHP_FUNCTION(bccomp)
{
@@ -458,7 +435,7 @@ PHP_FUNCTION(bccomp)
WRONG_PARAM_COUNT;
}
convert_to_long_ex(scale_param);
scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param);
scale = (int) Z_LVAL_PP(scale_param);
break;
default:
WRONG_PARAM_COUNT;
@@ -467,11 +444,11 @@ PHP_FUNCTION(bccomp)
convert_to_string_ex(left);
convert_to_string_ex(right);
bc_init_num(&first TSRMLS_CC);
bc_init_num(&second TSRMLS_CC);
bc_init_num(&first);
bc_init_num(&second);
bc_str2num(&first, Z_STRVAL_PP(left), scale TSRMLS_CC);
bc_str2num(&second, Z_STRVAL_PP(right), scale TSRMLS_CC);
bc_str2num(&first, Z_STRVAL_PP(left), scale);
bc_str2num(&second, Z_STRVAL_PP(right), scale);
Z_LVAL_P(return_value) = bc_compare(first, second);
Z_TYPE_P(return_value) = IS_LONG;
@@ -481,7 +458,7 @@ PHP_FUNCTION(bccomp)
}
/* }}} */
/* {{{ proto bool bcscale(int scale)
/* {{{ proto string bcscale(int scale)
Sets default scale parameter for all bc math functions */
PHP_FUNCTION(bcscale)
{
@@ -492,8 +469,7 @@ PHP_FUNCTION(bcscale)
}
convert_to_long_ex(new_scale);
bc_precision = (Z_LVAL_PP(new_scale)<0) ? 0 : Z_LVAL_PP(new_scale);
bc_precision = Z_LVAL_PP(new_scale);
RETURN_TRUE;
}
/* }}} */
+1 -1
View File
@@ -7,7 +7,7 @@ PHP_ARG_ENABLE(bcmath, whether to enable bc style precision math functions,
if test "$PHP_BCMATH" != "no"; then
AC_DEFINE(WITH_BCMATH, 1, [Whether you have bcmath])
PHP_NEW_EXTENSION(bcmath, bcmath.c \
PHP_NEW_EXTENSION(bcmath, bcmath.c number.c \
libbcmath/src/add.c libbcmath/src/div.c libbcmath/src/init.c libbcmath/src/neg.c libbcmath/src/outofmem.c libbcmath/src/raisemod.c libbcmath/src/rt.c libbcmath/src/sub.c \
libbcmath/src/compare.c libbcmath/src/divmod.c libbcmath/src/int2num.c libbcmath/src/num2long.c libbcmath/src/output.c libbcmath/src/recmul.c \
libbcmath/src/sqrt.c libbcmath/src/zero.c libbcmath/src/debug.c libbcmath/src/doaddsub.c libbcmath/src/nearzero.c libbcmath/src/num2str.c libbcmath/src/raise.c \
+18 -18
View File
@@ -52,12 +52,6 @@ typedef struct bc_struct
in the case of leading zeros generated. */
} bc_struct;
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
#include "php.h"
#include "../../php_bcmath.h"
/* The base used in storing the numbers in n_value above.
Currently this MUST be 10. */
@@ -87,6 +81,12 @@ typedef struct bc_struct
#endif
/* Global numbers. */
extern bc_num _zero_;
extern bc_num _one_;
extern bc_num _two_;
/* Function Prototypes */
/* Define the _PROTOTYPE macro if it is needed. */
@@ -99,7 +99,7 @@ typedef struct bc_struct
#endif
#endif
_PROTOTYPE(void bc_init_numbers, (TSRMLS_D));
_PROTOTYPE(void bc_init_numbers, (void));
_PROTOTYPE(bc_num bc_new_num, (int length, int scale));
@@ -107,9 +107,9 @@ _PROTOTYPE(void bc_free_num, (bc_num *num));
_PROTOTYPE(bc_num bc_copy_num, (bc_num num));
_PROTOTYPE(void bc_init_num, (bc_num *num TSRMLS_DC));
_PROTOTYPE(void bc_init_num, (bc_num *num));
_PROTOTYPE(void bc_str2num, (bc_num *num, char *str, int scale TSRMLS_DC));
_PROTOTYPE(void bc_str2num, (bc_num *num, char *str, int scale));
_PROTOTYPE(char *bc_num2str, (bc_num num));
@@ -119,7 +119,7 @@ _PROTOTYPE(long bc_num2long, (bc_num num));
_PROTOTYPE(int bc_compare, (bc_num n1, bc_num n2));
_PROTOTYPE(char bc_is_zero, (bc_num num TSRMLS_DC));
_PROTOTYPE(char bc_is_zero, (bc_num num));
_PROTOTYPE(char bc_is_near_zero, (bc_num num, int scale));
@@ -129,26 +129,26 @@ _PROTOTYPE(void bc_add, (bc_num n1, bc_num n2, bc_num *result, int scale_min));
_PROTOTYPE(void bc_sub, (bc_num n1, bc_num n2, bc_num *result, int scale_min));
_PROTOTYPE(void bc_multiply, (bc_num n1, bc_num n2, bc_num *prod, int scale TSRMLS_DC));
_PROTOTYPE(void bc_multiply, (bc_num n1, bc_num n2, bc_num *prod, int scale));
_PROTOTYPE(int bc_divide, (bc_num n1, bc_num n2, bc_num *quot, int scale TSRMLS_DC));
_PROTOTYPE(int bc_divide, (bc_num n1, bc_num n2, bc_num *quot, int scale));
_PROTOTYPE(int bc_modulo, (bc_num num1, bc_num num2, bc_num *result,
int scale TSRMLS_DC));
int scale));
_PROTOTYPE(int bc_divmod, (bc_num num1, bc_num num2, bc_num *quot,
bc_num *rem, int scale TSRMLS_DC));
bc_num *rem, int scale));
_PROTOTYPE(int bc_raisemod, (bc_num base, bc_num expo, bc_num mod,
bc_num *result, int scale TSRMLS_DC));
bc_num *result, int scale));
_PROTOTYPE(void bc_raise, (bc_num num1, bc_num num2, bc_num *result,
int scale TSRMLS_DC));
int scale));
_PROTOTYPE(int bc_sqrt, (bc_num *num, int scale TSRMLS_DC));
_PROTOTYPE(int bc_sqrt, (bc_num *num, int scale));
_PROTOTYPE(void bc_out_num, (bc_num num, int o_base, void (* out_char)(int),
int leading_zero TSRMLS_DC));
int leading_zero));
/* Prototypes needed for external utility routines. */
+3 -2
View File
@@ -48,9 +48,10 @@ out_char (int c)
void
pn (bc_num num TSRMLS_DC)
pn (num)
bc_num num;
{
bc_out_num (num, 10, out_char, 0 TSRMLS_CC);
bc_out_num (num, 10, out_char, 0);
out_char ('\n');
}
+5 -3
View File
@@ -85,7 +85,9 @@ _one_mult (num, size, digit, result)
by zero is tried. The algorithm is found in Knuth Vol 2. p237. */
int
bc_divide (bc_num n1, bc_num n2, bc_num *quot, int scale TSRMLS_DC)
bc_divide (n1, n2, quot, scale)
bc_num n1, n2, *quot;
int scale;
{
bc_num qval;
unsigned char *num1, *num2;
@@ -98,7 +100,7 @@ bc_divide (bc_num n1, bc_num n2, bc_num *quot, int scale TSRMLS_DC)
unsigned int norm;
/* Test for divide by zero. */
if (bc_is_zero (n2 TSRMLS_CC)) return -1;
if (bc_is_zero (n2)) return -1;
/* Test for divide by 1. If it is we must truncate. */
if (n2->n_scale == 0)
@@ -259,7 +261,7 @@ bc_divide (bc_num n1, bc_num n2, bc_num *quot, int scale TSRMLS_DC)
/* Clean up and return the number. */
qval->n_sign = ( n1->n_sign == n2->n_sign ? PLUS : MINUS );
if (bc_is_zero (qval TSRMLS_CC)) qval->n_sign = PLUS;
if (bc_is_zero (qval)) qval->n_sign = PLUS;
_bc_rm_leading_zeros (qval);
bc_free_num (quot);
*quot = qval;
+11 -7
View File
@@ -45,24 +45,26 @@
*/
int
bc_divmod (bc_num num1, bc_num num2, bc_num *quot, bc_num *rem, int scale TSRMLS_DC)
bc_divmod (num1, num2, quot, rem, scale)
bc_num num1, num2, *quot, *rem;
int scale;
{
bc_num quotient = NULL;
bc_num temp;
int rscale;
/* Check for correct numbers. */
if (bc_is_zero (num2 TSRMLS_CC)) return -1;
if (bc_is_zero (num2)) return -1;
/* Calculate final scale. */
rscale = MAX (num1->n_scale, num2->n_scale+scale);
bc_init_num(&temp TSRMLS_CC);
bc_init_num(&temp);
/* Calculate it. */
bc_divide (num1, num2, &temp, scale TSRMLS_CC);
bc_divide (num1, num2, &temp, scale);
if (quot)
quotient = bc_copy_num (temp);
bc_multiply (temp, num2, &temp, rscale TSRMLS_CC);
bc_multiply (temp, num2, &temp, rscale);
bc_sub (num1, temp, rem, rscale);
bc_free_num (&temp);
@@ -80,8 +82,10 @@ bc_divmod (bc_num num1, bc_num num2, bc_num *quot, bc_num *rem, int scale TSRMLS
result in RESULT. */
int
bc_modulo (bc_num num1, bc_num num2, bc_num *result, int scale TSRMLS_DC)
bc_modulo (num1, num2, result, scale)
bc_num num1, num2, *result;
int scale;
{
return bc_divmod (num1, num2, NULL, result, scale TSRMLS_CC);
return bc_divmod (num1, num2, NULL, result, scale);
}
+16 -11
View File
@@ -38,9 +38,12 @@
#include "bcmath.h"
#include "private.h"
#ifdef SANDER_0
/* Storage used for special numbers. */
bc_num _zero_;
bc_num _one_;
bc_num _two_;
bc_num _bc_Free_list = NULL;
#endif
/* new_num allocates a number and sets fields to known values. */
@@ -100,20 +103,21 @@ bc_free_num (num)
/* Intitialize the number package! */
void
bc_init_numbers (TSRMLS_D)
bc_init_numbers ()
{
BCG(_zero_) = bc_new_num (1,0);
BCG(_one_) = bc_new_num (1,0);
BCG(_one_)->n_value[0] = 1;
BCG(_two_) = bc_new_num (1,0);
BCG(_two_)->n_value[0] = 2;
_zero_ = bc_new_num (1,0);
_one_ = bc_new_num (1,0);
_one_->n_value[0] = 1;
_two_ = bc_new_num (1,0);
_two_->n_value[0] = 2;
}
/* Make a copy of a number! Just increments the reference count! */
bc_num
bc_copy_num (bc_num num)
bc_copy_num (num)
bc_num num;
{
num->n_refs++;
return num;
@@ -123,8 +127,9 @@ bc_copy_num (bc_num num)
/* Initialize a number NUM by making it a copy of zero. */
void
bc_init_num (bc_num *num TSRMLS_DC)
bc_init_num (num)
bc_num *num;
{
*num = bc_copy_num (BCG(_zero_));
*num = bc_copy_num (_zero_);
}
+21 -17
View File
@@ -86,11 +86,15 @@ bc_out_long (val, size, space, out_char)
as the routine to do the actual output of the characters. */
void
bc_out_num (num, o_base, out_char, leading_zero)
bc_num num;
int o_base;
#ifdef __STDC__
bc_out_num (bc_num num, int o_base, void (*out_char)(int), int leading_zero TSRMLS_DC)
void (*out_char)(int);
#else
bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero TSRMLS_DC)
void (*out_char)();
#endif
int leading_zero;
{
char *nptr;
int index, fdigit, pre_space;
@@ -101,7 +105,7 @@ bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero TSRMLS_
if (num->n_sign == MINUS) (*out_char) ('-');
/* Output the number. */
if (bc_is_zero (num TSRMLS_CC))
if (bc_is_zero (num))
(*out_char) ('0');
else
if (o_base == 10)
@@ -114,7 +118,7 @@ bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero TSRMLS_
else
nptr++;
if (leading_zero && bc_is_zero (num TSRMLS_CC))
if (leading_zero && bc_is_zero (num))
(*out_char) ('0');
/* Now the fraction. */
@@ -128,36 +132,36 @@ bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero TSRMLS_
else
{
/* special case ... */
if (leading_zero && bc_is_zero (num TSRMLS_CC))
if (leading_zero && bc_is_zero (num))
(*out_char) ('0');
/* The number is some other base. */
digits = NULL;
bc_init_num (&int_part TSRMLS_CC);
bc_divide (num, BCG(_one_), &int_part, 0 TSRMLS_CC);
bc_init_num (&frac_part TSRMLS_CC);
bc_init_num (&cur_dig TSRMLS_CC);
bc_init_num (&base TSRMLS_CC);
bc_init_num (&int_part);
bc_divide (num, _one_, &int_part, 0);
bc_init_num (&frac_part);
bc_init_num (&cur_dig);
bc_init_num (&base);
bc_sub (num, int_part, &frac_part, 0);
/* Make the INT_PART and FRAC_PART positive. */
int_part->n_sign = PLUS;
frac_part->n_sign = PLUS;
bc_int2num (&base, o_base);
bc_init_num (&max_o_digit TSRMLS_CC);
bc_init_num (&max_o_digit);
bc_int2num (&max_o_digit, o_base-1);
/* Get the digits of the integer part and push them on a stack. */
while (!bc_is_zero (int_part TSRMLS_CC))
while (!bc_is_zero (int_part))
{
bc_modulo (int_part, base, &cur_dig, 0 TSRMLS_CC);
bc_modulo (int_part, base, &cur_dig, 0);
/* PHP Change: malloc() -> emalloc() */
temp = (stk_rec *) emalloc (sizeof(stk_rec));
if (temp == NULL) bc_out_of_memory();
temp->digit = bc_num2long (cur_dig);
temp->next = digits;
digits = temp;
bc_divide (int_part, base, &int_part, 0 TSRMLS_CC);
bc_divide (int_part, base, &int_part, 0);
}
/* Print the digits on the stack. */
@@ -181,9 +185,9 @@ bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero TSRMLS_
{
(*out_char) ('.');
pre_space = 0;
t_num = bc_copy_num (BCG(_one_));
t_num = bc_copy_num (_one_);
while (t_num->n_len <= num->n_scale) {
bc_multiply (frac_part, base, &frac_part, num->n_scale TSRMLS_CC);
bc_multiply (frac_part, base, &frac_part, num->n_scale);
fdigit = bc_num2long (frac_part);
bc_int2num (&int_part, fdigit);
bc_sub (frac_part, int_part, &frac_part, 0);
@@ -193,7 +197,7 @@ bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero TSRMLS_
bc_out_long (fdigit, max_o_digit->n_len, pre_space, out_char);
pre_space = 1;
}
bc_multiply (t_num, base, &t_num, 0 TSRMLS_CC);
bc_multiply (t_num, base, &t_num, 0);
}
bc_free_num (&t_num);
}
+1 -3
View File
@@ -32,9 +32,7 @@
/* "Private" routines to bcmath. */
/* variables */
#ifdef SANDER_0
extern bc_num _bc_Free_list;
#endif
bc_num _bc_Free_list;
/* routines */
int _bc_do_compare (bc_num n1, bc_num n2, int use_sign, int ignore_last);
+8 -6
View File
@@ -44,7 +44,9 @@
only the integer part is used. */
void
bc_raise (bc_num num1, bc_num num2, bc_num *result, int scale TSRMLS_DC)
bc_raise (num1, num2, result, scale)
bc_num num1, num2, *result;
int scale;
{
bc_num temp, power;
long exponent;
@@ -64,7 +66,7 @@ bc_raise (bc_num num1, bc_num num2, bc_num *result, int scale TSRMLS_DC)
if (exponent == 0)
{
bc_free_num (result);
*result = bc_copy_num (BCG(_one_));
*result = bc_copy_num (_one_);
return;
}
@@ -87,7 +89,7 @@ bc_raise (bc_num num1, bc_num num2, bc_num *result, int scale TSRMLS_DC)
while ((exponent & 1) == 0)
{
pwrscale = 2*pwrscale;
bc_multiply (power, power, &power, pwrscale TSRMLS_CC);
bc_multiply (power, power, &power, pwrscale);
exponent = exponent >> 1;
}
temp = bc_copy_num (power);
@@ -98,10 +100,10 @@ bc_raise (bc_num num1, bc_num num2, bc_num *result, int scale TSRMLS_DC)
while (exponent > 0)
{
pwrscale = 2*pwrscale;
bc_multiply (power, power, &power, pwrscale TSRMLS_CC);
bc_multiply (power, power, &power, pwrscale);
if ((exponent & 1) == 1) {
calcscale = pwrscale + calcscale;
bc_multiply (temp, power, &temp, calcscale TSRMLS_CC);
bc_multiply (temp, power, &temp, calcscale);
}
exponent = exponent >> 1;
}
@@ -109,7 +111,7 @@ bc_raise (bc_num num1, bc_num num2, bc_num *result, int scale TSRMLS_DC)
/* Assign the value. */
if (neg)
{
bc_divide (BCG(_one_), temp, result, rscale TSRMLS_CC);
bc_divide (_one_, temp, result, rscale);
bc_free_num (&temp);
}
else
+14 -12
View File
@@ -43,20 +43,22 @@
only the integer part is used. */
int
bc_raisemod (bc_num base, bc_num expo, bc_num mod, bc_num *result, int scale TSRMLS_DC)
bc_raisemod (base, expo, mod, result, scale)
bc_num base, expo, mod, *result;
int scale;
{
bc_num power, exponent, parity, temp;
int rscale;
/* Check for correct numbers. */
if (bc_is_zero(mod TSRMLS_CC)) return -1;
if (bc_is_zero(mod)) return -1;
if (bc_is_neg(expo)) return -1;
/* Set initial values. */
power = bc_copy_num (base);
exponent = bc_copy_num (expo);
temp = bc_copy_num (BCG(_one_));
bc_init_num(&parity TSRMLS_CC);
temp = bc_copy_num (_one_);
bc_init_num(&parity);
/* Check the base for scale digits. */
if (base->n_scale != 0)
@@ -66,7 +68,7 @@ bc_raisemod (bc_num base, bc_num expo, bc_num mod, bc_num *result, int scale TSR
if (exponent->n_scale != 0)
{
bc_rt_warn ("non-zero scale in exponent");
bc_divide (exponent, BCG(_one_), &exponent, 0 TSRMLS_CC); /*truncate */
bc_divide (exponent, _one_, &exponent, 0); /*truncate */
}
/* Check the modulus for scale digits. */
@@ -75,17 +77,17 @@ bc_raisemod (bc_num base, bc_num expo, bc_num mod, bc_num *result, int scale TSR
/* Do the calculation. */
rscale = MAX(scale, base->n_scale);
while ( !bc_is_zero(exponent TSRMLS_CC) )
while ( !bc_is_zero(exponent) )
{
(void) bc_divmod (exponent, BCG(_two_), &exponent, &parity, 0 TSRMLS_CC);
if ( !bc_is_zero(parity TSRMLS_CC) )
(void) bc_divmod (exponent, _two_, &exponent, &parity, 0);
if ( !bc_is_zero(parity) )
{
bc_multiply (temp, power, &temp, rscale TSRMLS_CC);
(void) bc_modulo (temp, mod, &temp, scale TSRMLS_CC);
bc_multiply (temp, power, &temp, rscale);
(void) bc_modulo (temp, mod, &temp, scale);
}
bc_multiply (power, power, &power, rscale TSRMLS_CC);
(void) bc_modulo (power, mod, &power, scale TSRMLS_CC);
bc_multiply (power, power, &power, rscale);
(void) bc_modulo (power, mod, &power, scale);
}
/* Assign the value. */
+19 -21
View File
@@ -57,17 +57,13 @@ new_sub_num (length, scale, value)
{
bc_num temp;
#ifdef SANDER_0
if (_bc_Free_list != NULL) {
temp = _bc_Free_list;
_bc_Free_list = temp->n_next;
} else {
#endif
temp = (bc_num) emalloc (sizeof(bc_struct));
#ifdef SANDER_0
if (temp == NULL) bc_out_of_memory ();
}
#endif
temp->n_sign = PLUS;
temp->n_len = length;
temp->n_scale = scale;
@@ -180,7 +176,7 @@ _bc_shift_addsub (bc_num accum, bc_num val, int shift, int sub)
*/
static void
_bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
int full_scale TSRMLS_DC)
int full_scale)
{
bc_num u0, u1, v0, v1;
int u0len, v0len;
@@ -201,14 +197,14 @@ _bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
/* Split u and v. */
if (ulen < n) {
u1 = bc_copy_num (BCG(_zero_));
u1 = bc_copy_num (_zero_);
u0 = new_sub_num (ulen,0, u->n_value);
} else {
u1 = new_sub_num (ulen-n, 0, u->n_value);
u0 = new_sub_num (n, 0, u->n_value+ulen-n);
}
if (vlen < n) {
v1 = bc_copy_num (BCG(_zero_));
v1 = bc_copy_num (_zero_);
v0 = new_sub_num (vlen,0, v->n_value);
} else {
v1 = new_sub_num (vlen-n, 0, v->n_value);
@@ -221,12 +217,12 @@ _bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
_bc_rm_leading_zeros (v0);
v0len = v0->n_len;
m1zero = bc_is_zero(u1 TSRMLS_CC) || bc_is_zero(v1 TSRMLS_CC);
m1zero = bc_is_zero(u1) || bc_is_zero(v1);
/* Calculate sub results ... */
bc_init_num(&d1 TSRMLS_CC);
bc_init_num(&d2 TSRMLS_CC);
bc_init_num(&d1);
bc_init_num(&d2);
bc_sub (u1, u0, &d1, 0);
d1len = d1->n_len;
bc_sub (v0, v1, &d2, 0);
@@ -235,19 +231,19 @@ _bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
/* Do recursive multiplies and shifted adds. */
if (m1zero)
m1 = bc_copy_num (BCG(_zero_));
m1 = bc_copy_num (_zero_);
else
_bc_rec_mul (u1, u1->n_len, v1, v1->n_len, &m1, 0 TSRMLS_CC);
_bc_rec_mul (u1, u1->n_len, v1, v1->n_len, &m1, 0);
if (bc_is_zero(d1 TSRMLS_CC) || bc_is_zero(d2 TSRMLS_CC))
m2 = bc_copy_num (BCG(_zero_));
if (bc_is_zero(d1) || bc_is_zero(d2))
m2 = bc_copy_num (_zero_);
else
_bc_rec_mul (d1, d1len, d2, d2len, &m2, 0 TSRMLS_CC);
_bc_rec_mul (d1, d1len, d2, d2len, &m2, 0);
if (bc_is_zero(u0 TSRMLS_CC) || bc_is_zero(v0 TSRMLS_CC))
m3 = bc_copy_num (BCG(_zero_));
if (bc_is_zero(u0) || bc_is_zero(v0))
m3 = bc_copy_num (_zero_);
else
_bc_rec_mul (u0, u0->n_len, v0, v0->n_len, &m3, 0 TSRMLS_CC);
_bc_rec_mul (u0, u0->n_len, v0, v0->n_len, &m3, 0);
/* Initialize product */
prodlen = ulen+vlen+1;
@@ -278,7 +274,9 @@ _bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
*/
void
bc_multiply (bc_num n1, bc_num n2, bc_num *prod, int scale TSRMLS_DC)
bc_multiply (n1, n2, prod, scale)
bc_num n1, n2, *prod;
int scale;
{
bc_num pval;
int len1, len2;
@@ -291,7 +289,7 @@ bc_multiply (bc_num n1, bc_num n2, bc_num *prod, int scale TSRMLS_DC)
prod_scale = MIN(full_scale,MAX(scale,MAX(n1->n_scale,n2->n_scale)));
/* Do the multiply */
_bc_rec_mul (n1, len1, n2, len2, &pval, full_scale TSRMLS_CC);
_bc_rec_mul (n1, len1, n2, len2, &pval, full_scale);
/* Assign to prod and clean up the number. */
pval->n_sign = ( n1->n_sign == n2->n_sign ? PLUS : MINUS );
@@ -299,7 +297,7 @@ bc_multiply (bc_num n1, bc_num n2, bc_num *prod, int scale TSRMLS_DC)
pval->n_len = len2 + len1 + 1 - full_scale;
pval->n_scale = prod_scale;
_bc_rm_leading_zeros (pval);
if (bc_is_zero (pval TSRMLS_CC))
if (bc_is_zero (pval))
pval->n_sign = PLUS;
bc_free_num (prod);
*prod = pval;
+16 -14
View File
@@ -42,14 +42,16 @@
after the decimal place. */
int
bc_sqrt (bc_num *num, int scale TSRMLS_DC)
bc_sqrt (num, scale)
bc_num *num;
int scale;
{
int rscale, cmp_res, done;
int cscale;
bc_num guess, guess1, point5, diff;
/* Initial checks. */
cmp_res = bc_compare (*num, BCG(_zero_));
cmp_res = bc_compare (*num, _zero_);
if (cmp_res < 0)
return 0; /* error */
else
@@ -57,23 +59,23 @@ bc_sqrt (bc_num *num, int scale TSRMLS_DC)
if (cmp_res == 0)
{
bc_free_num (num);
*num = bc_copy_num (BCG(_zero_));
*num = bc_copy_num (_zero_);
return 1;
}
}
cmp_res = bc_compare (*num, BCG(_one_));
cmp_res = bc_compare (*num, _one_);
if (cmp_res == 0)
{
bc_free_num (num);
*num = bc_copy_num (BCG(_one_));
*num = bc_copy_num (_one_);
return 1;
}
/* Initialize the variables. */
rscale = MAX (scale, (*num)->n_scale);
bc_init_num(&guess TSRMLS_CC);
bc_init_num(&guess1 TSRMLS_CC);
bc_init_num(&diff TSRMLS_CC);
bc_init_num(&guess);
bc_init_num(&guess1);
bc_init_num(&diff);
point5 = bc_new_num (1,1);
point5->n_value[1] = 5;
@@ -82,7 +84,7 @@ bc_sqrt (bc_num *num, int scale TSRMLS_DC)
if (cmp_res < 0)
{
/* The number is between 0 and 1. Guess should start at 1. */
guess = bc_copy_num (BCG(_one_));
guess = bc_copy_num (_one_);
cscale = (*num)->n_scale;
}
else
@@ -91,9 +93,9 @@ bc_sqrt (bc_num *num, int scale TSRMLS_DC)
bc_int2num (&guess,10);
bc_int2num (&guess1,(*num)->n_len);
bc_multiply (guess1, point5, &guess1, 0 TSRMLS_CC);
bc_multiply (guess1, point5, &guess1, 0);
guess1->n_scale = 0;
bc_raise (guess, guess1, &guess, 0 TSRMLS_CC);
bc_raise (guess, guess1, &guess, 0);
bc_free_num (&guess1);
cscale = 3;
}
@@ -104,9 +106,9 @@ bc_sqrt (bc_num *num, int scale TSRMLS_DC)
{
bc_free_num (&guess1);
guess1 = bc_copy_num (guess);
bc_divide (*num, guess, &guess, cscale TSRMLS_CC);
bc_divide (*num, guess, &guess, cscale);
bc_add (guess, guess1, &guess, 0);
bc_multiply (guess, point5, &guess, cscale TSRMLS_CC);
bc_multiply (guess, point5, &guess, cscale);
bc_sub (guess, guess1, &diff, cscale+1);
if (bc_is_near_zero (diff, cscale))
{
@@ -119,7 +121,7 @@ bc_sqrt (bc_num *num, int scale TSRMLS_DC)
/* Assign the number and clean up. */
bc_free_num (num);
bc_divide (guess,BCG(_one_),num,rscale TSRMLS_CC);
bc_divide (guess,_one_,num,rscale);
bc_free_num (&guess);
bc_free_num (&guess1);
bc_free_num (&point5);
+5 -2
View File
@@ -41,7 +41,10 @@
/* Convert strings to bc numbers. Base 10 only.*/
void
bc_str2num (bc_num *num, char *str, int scale TSRMLS_DC)
bc_str2num (num, str, scale)
bc_num *num;
char *str;
int scale;
{
int digits, strscale;
char *ptr, *nptr;
@@ -62,7 +65,7 @@ bc_str2num (bc_num *num, char *str, int scale TSRMLS_DC)
while (isdigit((int)*ptr)) ptr++, strscale++; /* digits */
if ((*ptr != '\0') || (digits+strscale == 0))
{
*num = bc_copy_num (BCG(_zero_));
*num = bc_copy_num (_zero_);
return;
}
+3 -2
View File
@@ -41,13 +41,14 @@
/* In some places we need to check if the number NUM is zero. */
char
bc_is_zero (bc_num num TSRMLS_DC)
bc_is_zero (num)
bc_num num;
{
int count;
char *nptr;
/* Quick check. */
if (num == BCG(_zero_)) return TRUE;
if (num == _zero_) return TRUE;
/* Initialize */
count = num->n_len + num->n_scale;
+1 -22
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -23,30 +23,9 @@
#if WITH_BCMATH
#include "libbcmath/src/bcmath.h"
ZEND_BEGIN_MODULE_GLOBALS(bcmath)
bc_num _zero_;
bc_num _one_;
bc_num _two_;
ZEND_END_MODULE_GLOBALS(bcmath)
#if ZTS
# define BCG(v) TSRMG(bcmath_globals_id, zend_bcmath_globals *, v)
extern int bcmath_globals_id;
#else
# define BCG(v) (bcmath_globals.v)
extern zend_bcmath_globals bcmath_globals;
#endif
#define BC
extern zend_module_entry bcmath_module_entry;
#define phpext_bcmath_ptr &bcmath_module_entry
#if ZTS
PHP_MINIT_FUNCTION(bcmath);
#endif
PHP_RINIT_FUNCTION(bcmath);
PHP_RSHUTDOWN_FUNCTION(bcmath);
PHP_MINFO_FUNCTION(bcmath);
-16
View File
@@ -1,16 +0,0 @@
--TEST--
bcadd() function
--SKIPIF--
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
--INI--
bcmath.scale=0
--FILE--
<?php
echo bcadd("1", "2"),"\n";
echo bcadd("-1", "5", 4),"\n";
echo bcadd("1928372132132819737213", "8728932001983192837219398127471", 2),"\n";
?>
--EXPECT--
3
4.0000
8728932003911564969352217864684.00
-18
View File
@@ -1,18 +0,0 @@
--TEST--
bccomp() function
--SKIPIF--
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
--INI--
bcmath.scale=0
--FILE--
<?php
echo bccomp("-1", "5", 4),"\n";
echo bccomp("1928372132132819737213", "8728932001983192837219398127471"),"\n";
echo bccomp("1.00000000000000000001", "1", 2),"\n";
echo bccomp("97321", "2321"),"\n";
?>
--EXPECT--
-1
-1
0
1
-18
View File
@@ -1,18 +0,0 @@
--TEST--
bcdiv() function
--SKIPIF--
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
--INI--
bcmath.scale=0
--FILE--
<?php
echo bcdiv("1", "2"),"\n";
echo bcdiv("1", "2", 2),"\n";
echo bcdiv("-1", "5", 4),"\n";
echo bcdiv("8728932001983192837219398127471", "1928372132132819737213", 2),"\n";
?>
--EXPECT--
0
0.50
-0.2000
4526580661.75
-16
View File
@@ -1,16 +0,0 @@
--TEST--
bcmod() function
--SKIPIF--
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
--INI--
bcmath.scale=0
--FILE--
<?php
echo bcmod("11", "2"),"\n";
echo bcmod("-1", "5"),"\n";
echo bcmod("8728932001983192837219398127471", "1928372132132819737213"),"\n";
?>
--EXPECT--
1
-1
1459434331351930289678
-18
View File
@@ -1,18 +0,0 @@
--TEST--
bcmul() function
--SKIPIF--
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
--INI--
bcmath.scale=0
--FILE--
<?php
echo bcmul("1", "2"),"\n";
echo bcmul("-3", "5"),"\n";
echo bcmul("1234567890", "9876543210"),"\n";
echo bcmul("2.5", "1.5", 2),"\n";
?>
--EXPECT--
2
-15
12193263111263526900
3.75
-16
View File
@@ -1,16 +0,0 @@
--TEST--
bcpow() function
--SKIPIF--
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
--INI--
bcmath.scale=0
--FILE--
<?php
echo bcpow("1", "2"),"\n";
echo bcpow("-2", "5", 4),"\n";
echo bcpow("2", "64"),"\n";
?>
--EXPECT--
1
-32
18446744073709551616
-21
View File
@@ -1,21 +0,0 @@
--TEST--
bcscale() function
--SKIPIF--
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
--INI--
bcmath.scale=0
--FILE--
<?php
echo bcadd("1", "2"),"\n";
bcscale(2);
echo bcadd("1", "2"),"\n";
bcscale(10);
echo bcadd("1", "2"),"\n";
bcscale(0);
echo bcadd("1", "2"),"\n";
?>
--EXPECT--
3
3.00
3.0000000000
3
-14
View File
@@ -1,14 +0,0 @@
--TEST--
bcsqrt() function
--SKIPIF--
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
--INI--
bcmath.scale=0
--FILE--
<?php
echo bcsqrt("9"),"\n";
echo bcsqrt("1928372132132819737213", 5),"\n";
?>
--EXPECT--
3
43913234134.28826
-16
View File
@@ -1,16 +0,0 @@
--TEST--
bcsub() function
--SKIPIF--
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
--INI--
bcmath.scale=0
--FILE--
<?php
echo bcsub("1", "2"),"\n";
echo bcsub("-1", "5", 4),"\n";
echo bcsub("8728932001983192837219398127471", "1928372132132819737213", 2),"\n";
?>
--EXPECT--
-1
-6.0000
8728932000054820705086578390258.00
-2
View File
@@ -1,2 +0,0 @@
Bzip2
Sterling Hughes
-542
View File
@@ -1,542 +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;
}
if (mode[0] != 'w' && mode[0] != 'r' && mode[1] != '\0') {
return NULL;
}
#ifdef VIRTUAL_DIR
virtual_filepath_ex(path, &path_copy, NULL 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 | STREAM_WILL_CAST, 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);
}
}
/* remove the file created by php_stream_open_wrapper(), it is not needed since BZ2 functions
* failed.
*/
if (!bz_file && mode[0] == 'w') {
VCWD_UNLINK(*opened_path);
}
}
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"
};
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 (Z_STRVAL_PP(mode)[0] != 'r' && Z_STRVAL_PP(mode)[0] != 'w' && Z_STRVAL_PP(mode)[1] != '\0') {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "'%s' is not a valid mode for bzopen(). Only 'w' and 'r' are supported.", Z_STRVAL_PP(mode));
RETURN_FALSE;
}
/* 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
View File
@@ -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
-40
View File
@@ -1,40 +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)
break
fi
done
fi
if test -z "$BZIP_DIR"; then
AC_MSG_RESULT(not found)
AC_MSG_ERROR(Please reinstall the BZip2 distribution)
fi
PHP_CHECK_LIBRARY(bz2, BZ2_bzerror,
[
PHP_ADD_INCLUDE($BZIP_DIR/include)
PHP_ADD_LIBRARY_WITH_PATH(bz2, $BZIP_DIR/lib, BZ2_SHARED_LIBADD)
AC_DEFINE(HAVE_BZ2,1,[ ])
], [
AC_MSG_ERROR(bz2 module requires libbz2 >= 1.0.0)
], [
-L$BZIP_DIR/lib
])
PHP_NEW_EXTENSION(bz2, bz2.c, $ext_shared)
PHP_SUBST(BZ2_SHARED_LIBADD)
fi
-35
View File
@@ -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>
-72
View File
@@ -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:
*/
-25
View File
@@ -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.
-28
View File
@@ -1,28 +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(dirname(__FILE__) . '/../../../tests/quicktester.inc');
--EXPECT--
OK
+1 -1
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
+15 -23
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -161,7 +161,7 @@ PHP_FUNCTION(cal_info)
}
convert_to_long_ex(cal);
if (Z_LVAL_PP(cal) < 0 || Z_LVAL_PP(cal) >= CAL_NUM_CALS) {
zend_error(E_WARNING, "%s(): invalid calendar ID %ld", get_active_function_name(TSRMLS_C), Z_LVAL_PP(cal));
zend_error(E_WARNING, "%s(): invalid calendar ID %d", get_active_function_name(TSRMLS_C), Z_LVAL_PP(cal));
RETURN_FALSE;
}
@@ -203,7 +203,7 @@ PHP_FUNCTION(cal_days_in_month)
convert_to_long_ex(year);
if (Z_LVAL_PP(cal) < 0 || Z_LVAL_PP(cal) >= CAL_NUM_CALS) {
zend_error(E_WARNING, "%s(): invalid calendar ID %ld", get_active_function_name(TSRMLS_C), Z_LVAL_PP(cal));
zend_error(E_WARNING, "%s(): invalid calendar ID %d", get_active_function_name(TSRMLS_C), Z_LVAL_PP(cal));
RETURN_FALSE;
}
@@ -239,7 +239,7 @@ PHP_FUNCTION(cal_to_jd)
convert_to_long_ex(year);
if (Z_LVAL_PP(cal) < 0 || Z_LVAL_PP(cal) >= CAL_NUM_CALS) {
zend_error(E_WARNING, "%s(): invalid calendar ID %ld", get_active_function_name(TSRMLS_C), Z_LVAL_PP(cal));
zend_error(E_WARNING, "%s(): invalid calendar ID %d", get_active_function_name(TSRMLS_C), Z_LVAL_PP(cal));
RETURN_FALSE;
}
@@ -265,7 +265,7 @@ PHP_FUNCTION(cal_from_jd)
convert_to_long_ex(cal);
if (Z_LVAL_PP(cal) < 0 || Z_LVAL_PP(cal) >= CAL_NUM_CALS) {
zend_error(E_WARNING, "%s(): invalid calendar ID %ld", get_active_function_name(TSRMLS_C), Z_LVAL_PP(cal));
zend_error(E_WARNING, "%s(): invalid calendar ID %d", get_active_function_name(TSRMLS_C), Z_LVAL_PP(cal));
RETURN_FALSE;
}
calendar = &cal_conversion_table[Z_LVAL_PP(cal)];
@@ -381,9 +381,9 @@ PHP_FUNCTION(juliantojd)
for example both: year '5' and year '5000' product 'ä'.
use the numeric one for calculations.
*/
static char* heb_number_to_chars(int n, char **ret)
static char* heb_number_to_chars(int n)
{
char *p, *old;
char *p, *old, *ret;
p = emalloc(10);
old = p;
@@ -392,11 +392,8 @@ static char* heb_number_to_chars(int n, char **ret)
prevents the option breaking the jewish beliefs, and some other
critical resources ;)
*/
if (n > 9999 || n < 1) {
efree(old);
*ret = NULL;
if (n > 9999 || n < 1)
return NULL;
}
/* alafim case */
if (n / 1000) {
@@ -441,10 +438,9 @@ static char* heb_number_to_chars(int n, char **ret)
}
*p = '\0';
*ret = estrndup(old, (p - old) + 1);
p = *ret;
efree(old);
return p;
ret = emalloc((int) (p - old) + 1);
strncpy(ret, old, (int) (p - old) + 1);
return ret;
}
/* {{{ proto string jdtojewish(int juliandaycount)
@@ -454,7 +450,6 @@ PHP_FUNCTION(jdtojewish)
long julday, fl;
int year, month, day;
char date[10], hebdate[25];
char *dayp, *yearp;
if (ZEND_NUM_ARGS() == 1) {
if (zend_parse_parameters(1 TSRMLS_CC,"l", &julday) != SUCCESS) {
@@ -480,14 +475,11 @@ PHP_FUNCTION(jdtojewish)
RETURN_FALSE;
}
sprintf(hebdate, "%s %s %s", heb_number_to_chars(day, &dayp), JewishMonthHebName[month], heb_number_to_chars(year, &yearp));
sprintf(hebdate, "%s %s %s", \
heb_number_to_chars(day), \
JewishMonthHebName[month], \
heb_number_to_chars(year));
if (dayp) {
efree(dayp);
}
if (yearp) {
efree(yearp);
}
RETURN_STRING(hebdate, 1);
}
+3 -3
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
| Authors: Shane Caraveo <shane@caraveo.com> |
| Colin Viebrock <colin@easydns.com> |
| Hartmut Holzgraefe <hholzgra@php.net> |
| Hartmut Holzgraefe <hartmut@six.de> |
+----------------------------------------------------------------------+
*/
/* $Id: */
@@ -48,7 +48,7 @@ static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, int gm)
}
if (gm && (year<1970 || year>2037)) { /* out of range for timestamps */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "This function is only valid for years between 1970 and 2037 inclusive");
php_error(E_WARNING, "%s(): This function is only valid for years between 1970 and 2037 inclusive", get_active_function_name(TSRMLS_C));
RETURN_FALSE;
}
-4
View File
@@ -260,10 +260,6 @@
*
**************************************************************************/
#if defined(PHP_WIN32) && _MSC_VER >= 1200
#pragma setlocale("english")
#endif
#include "sdncal.h"
#define HALAKIM_PER_HOUR 1080
+181 -89
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -15,7 +15,7 @@
| Author: Zeev Suraski <zeev@zend.com> |
| Harald Radi <h.radi@nme.at> |
| Alan Brown <abrown@pobox.com> |
| Wez Furlong <wez@thebrainroom.com> |
| Wez Furlong <wez@thebrainroom.com> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
@@ -55,7 +55,7 @@
#ifdef PHP_WIN32
#define _WIN32_DCOM
#define COBJMACROS
#include <iostream.h>
#include <math.h>
#include <ocidl.h>
@@ -122,7 +122,24 @@ PHPAPI HRESULT php_COM_invoke(comval *obj, DISPID dispIdMember, WORD wFlags, DIS
*ErrString = NULL;
/* @todo use DispInvoke here ? */
if (C_ISREFD(obj)) {
hr = C_DISPATCH_VT(obj)->Invoke(C_DISPATCH(obj), dispIdMember, &IID_NULL, LOCALE_SYSTEM_DEFAULT, wFlags, pDispParams, pVarResult, &ExceptInfo, &ArgErr);
if (C_HASTLIB(obj)) {
hr = C_TYPEINFO_VT(obj)->Invoke(C_TYPEINFO(obj), C_DISPATCH(obj), dispIdMember, wFlags, pDispParams, pVarResult, &ExceptInfo, &ArgErr);
if (FAILED(hr)) {
hr = C_DISPATCH_VT(obj)->Invoke(C_DISPATCH(obj), dispIdMember, &IID_NULL, LOCALE_SYSTEM_DEFAULT, wFlags, pDispParams, pVarResult, &ExceptInfo, &ArgErr);
if (SUCCEEDED(hr)) {
/*
* ITypLib doesn't work
* Release ITypeLib and fall back to IDispatch
*/
C_TYPEINFO_VT(obj)->Release(C_TYPEINFO(obj));
C_HASTLIB(obj) = FALSE;
C_TYPEINFO(obj) = NULL;
}
}
} else {
hr = C_DISPATCH_VT(obj)->Invoke(C_DISPATCH(obj), dispIdMember, &IID_NULL, LOCALE_SYSTEM_DEFAULT, wFlags, pDispParams, pVarResult, &ExceptInfo, &ArgErr);
}
if (FAILED(hr)) {
switch (hr) {
@@ -709,7 +726,7 @@ PHP_FUNCTION(com_load)
}
}
RETVAL_COM(obj);
RETURN_RESOURCE(zend_list_insert(obj, IS_COM));
}
/* }}} */
@@ -727,7 +744,7 @@ static int do_COM_invoke(comval *obj, WORD dispflags, pval *function_name, VARIA
int current_arg, current_variant;
unsigned long count;
if (C_HASENUM(obj) && strstr(Z_STRVAL_P(function_name), "next")) {
if (C_HASENUM(obj) && strstr(Z_STRVAL_P(function_name), "next")) {
/* Grab one argument off the stack, allocate enough
* VARIANTs
* Get the IEnumVariant interface and call ->Next();
@@ -879,7 +896,7 @@ static int do_COM_invoke(comval *obj, WORD dispflags, pval *function_name, VARIA
efree(funcname);
for (current_arg=0;current_arg<arg_count;current_arg++) {
/* don't release IDispatch pointers as they are used afterwards */
if (V_VT(&(variant_args[current_arg])) != VT_DISPATCH) {
if (V_VT(&variant_args[current_arg]) != VT_DISPATCH) {
/* @todo review this: what happens to an array of IDispatchs or a VARIANT->IDispatch */
VariantClear(&variant_args[current_arg]);
}
@@ -901,7 +918,6 @@ static int do_COM_invoke(comval *obj, WORD dispflags, pval *function_name, VARIA
return SUCCESS;
}
/* {{{ proto mixed com_invoke_ex(int module, int invokeflags, string handler_name [, mixed arg [, mixed ...]])
Invokes a COM module */
PHP_FUNCTION(com_invoke_ex)
@@ -931,7 +947,17 @@ PHP_FUNCTION(com_invoke_ex)
dispflags = (WORD)Z_LVAL_P(invokeflags);
/* obtain IDispatch interface */
FETCH_COM_SAFE(object, obj);
if (Z_TYPE_P(object) == IS_OBJECT && (Z_OBJCE_P(object) == &COM_class_entry || !strcmp(Z_OBJCE_P(object)->name, "COM"))) {
zval **tmp;
zend_hash_index_find(Z_OBJPROP_P(object), 0, (void**)&tmp);
ZEND_FETCH_RESOURCE(obj, comval*, tmp, -1, "comval", IS_COM);
} else if (Z_TYPE_P(object) == IS_RESOURCE) {
ZEND_FETCH_RESOURCE(obj, comval*, &object, -1, "comval", IS_COM);
}
if (obj == NULL) {
php_error(E_WARNING, "%d is not a COM object handler", Z_LVAL_P(object));
RETURN_NULL();
}
ALLOC_VARIANT(var_result);
@@ -956,6 +982,7 @@ PHP_FUNCTION(com_invoke)
pval **arguments;
pval *object, *function_name;
comval *obj;
int type;
int arg_count = ZEND_NUM_ARGS();
VARIANT *var_result;
@@ -971,7 +998,12 @@ PHP_FUNCTION(com_invoke)
function_name = arguments[1];
/* obtain IDispatch interface */
FETCH_COM_SAFE(object, obj);
convert_to_long(object);
obj = (comval *)zend_list_find(Z_LVAL_P(object), &type);
if (!obj || (type != IS_COM)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s is not a COM object handler", Z_STRVAL_P(function_name));
RETURN_NULL();
}
/* obtain property/method handler */
convert_to_string_ex(&function_name);
@@ -998,6 +1030,7 @@ PHP_FUNCTION(com_release)
{
pval *object;
comval *obj;
int type;
int arg_count = ZEND_NUM_ARGS();
if (arg_count != 1) {
@@ -1009,7 +1042,12 @@ PHP_FUNCTION(com_release)
}
/* obtain IDispatch interface */
FETCH_COM_SAFE(object, obj);
convert_to_long_ex(&object);
obj = (comval *)zend_list_find(Z_LVAL_P(object), &type);
if (!obj || (type != IS_COM)) {
php_error(E_WARNING, "%s(): %d is not a COM object handler", get_active_function_name(TSRMLS_C));
RETURN_FALSE;
}
RETURN_LONG(php_COM_release(obj TSRMLS_CC))
}
@@ -1022,6 +1060,7 @@ PHP_FUNCTION(com_addref)
{
pval *object;
comval *obj;
int type;
int arg_count = ZEND_NUM_ARGS();
if (arg_count != 1) {
@@ -1033,7 +1072,13 @@ PHP_FUNCTION(com_addref)
}
/* obtain IDispatch interface */
FETCH_COM_SAFE(object, obj);
convert_to_long_ex(&object);
obj = (comval *)zend_list_find(Z_LVAL_P(object), &type);
if (!obj || (type != IS_COM))
{
php_error(E_WARNING, "%s(): %d is not a COM object handler", get_active_function_name(TSRMLS_C));
RETURN_FALSE;
}
RETURN_LONG(php_COM_addref(obj TSRMLS_CC));
}
@@ -1408,8 +1453,12 @@ PHP_FUNCTION(com_print_typeinfo)
RETURN_FALSE;
}
if (Z_TYPE_P(arg1) == IS_OBJECT) {
FETCH_COM_SAFE(arg1, obj);
if (Z_TYPE_P(arg1) == IS_OBJECT && (Z_OBJCE_P(arg1) == &COM_class_entry || !strcmp(Z_OBJCE_P(arg1)->name, "COM"))) {
zval **tmp;
zend_hash_index_find(Z_OBJPROP_P(arg1), 0, (void**)&tmp);
ZEND_FETCH_RESOURCE(obj, comval*, tmp, -1, "comval", IS_COM);
} else if (Z_TYPE_P(arg1) == IS_RESOURCE) {
ZEND_FETCH_RESOURCE(obj, comval*, &arg1, -1, "comval", IS_COM);
} else {
convert_to_string(arg1);
typelibname = Z_STRVAL_P(arg1);
@@ -1443,8 +1492,14 @@ PHP_FUNCTION(com_event_sink)
RETURN_FALSE;
}
FETCH_COM_SAFE(object, obj);
if (Z_TYPE_P(object) == IS_OBJECT && (Z_OBJCE_P(object) == &COM_class_entry || !strcmp(Z_OBJCE_P(object)->name, "COM"))) {
zval **tmp;
zend_hash_index_find(Z_OBJPROP_P(object), 0, (void**)&tmp);
ZEND_FETCH_RESOURCE(obj, comval*, tmp, -1, "comval", IS_COM);
} else {
ZEND_FETCH_RESOURCE(obj, comval*, &object, -1, "comval", IS_COM);
}
if (sink && Z_TYPE_P(sink) == IS_ARRAY) {
/* 0 => typelibname, 1 => dispname */
zval **tmp;
@@ -1610,11 +1665,6 @@ static void do_COM_propput(pval *return_value, comval *obj, pval *arg_property,
FREE_VARIANT(var_result);
/* free the string we allocated; invoked object made its own copy */
if (V_VT(new_value) == VT_BSTR) {
VariantClear(new_value);
}
efree(new_value);
efree(propname);
@@ -1632,10 +1682,8 @@ static void do_COM_propput(pval *return_value, comval *obj, pval *arg_property,
hr = php_COM_invoke(obj, dispid, DISPATCH_PROPERTYGET, &dispparams, var_result, &ErrString TSRMLS_CC);
if (SUCCEEDED(hr)) {
RETVAL_VARIANT(var_result);
php_variant_to_pval(var_result, return_value, codepage TSRMLS_CC);
} else {
FREE_VARIANT(var_result);
*return_value = *value;
zval_copy_ctor(return_value);
}
@@ -1643,15 +1691,11 @@ static void do_COM_propput(pval *return_value, comval *obj, pval *arg_property,
if (ErrString) {
pefree(ErrString, 1);
}
} else {
FREE_VARIANT(var_result);
}
/* free the string we allocated; invoked object made its own copy */
if (V_VT(new_value) == VT_BSTR) {
VariantClear(new_value);
}
efree(new_value);
FREE_VARIANT(var_result);
efree(new_value); // FREE_VARIANT does a VariantClear() which is not desired here !
efree(propname);
}
@@ -1677,8 +1721,18 @@ PHP_FUNCTION(com_propget)
object = arguments[0];
function_name = arguments[1];
FETCH_COM_SAFE(object, obj);
if (Z_TYPE_P(object) == IS_OBJECT && (Z_OBJCE_P(object) == &COM_class_entry || !strcmp(Z_OBJCE_P(object)->name, "COM"))) {
zval **tmp;
zend_hash_index_find(Z_OBJPROP_P(object), 0, (void**)&tmp);
ZEND_FETCH_RESOURCE(obj, comval*, tmp, -1, "comval", IS_COM);
} else if (Z_TYPE_P(object) == IS_RESOURCE) {
ZEND_FETCH_RESOURCE(obj, comval*, &object, -1, "comval", IS_COM);
}
if (obj == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "parameter 1 is not a COM object handler");
RETURN_NULL();
}
/* obtain property/method handler */
convert_to_string_ex(&function_name);
@@ -1719,8 +1773,18 @@ PHP_FUNCTION(com_propput)
object = arguments[0];
function_name = arguments[1];
FETCH_COM_SAFE(object, obj);
if (Z_TYPE_P(object) == IS_OBJECT && (Z_OBJCE_P(object) == &COM_class_entry || !strcmp(Z_OBJCE_P(object)->name, "COM"))) {
zval **tmp;
zend_hash_index_find(Z_OBJPROP_P(object), 0, (void**)&tmp);
ZEND_FETCH_RESOURCE(obj, comval*, tmp, -1, "comval", IS_COM);
} else if (Z_TYPE_P(object) == IS_RESOURCE) {
ZEND_FETCH_RESOURCE(obj, comval*, &object, -1, "comval", IS_COM);
}
if (obj == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "parameter 1 is not a COM object handler");
RETURN_NULL();
}
/* obtain property/method handler */
convert_to_string_ex(&function_name);
@@ -1780,7 +1844,7 @@ PHPAPI pval php_COM_get_property_handler(zend_property_reference *property_refer
{
zend_overloaded_element *overloaded_property;
zend_llist_element *element;
pval retval;
pval return_value;
pval **comval_handle;
pval *object = property_reference->object;
int type;
@@ -1788,14 +1852,14 @@ PHPAPI pval php_COM_get_property_handler(zend_property_reference *property_refer
VARIANT *var_result;
TSRMLS_FETCH();
INIT_ZVAL(retval);
ZVAL_NULL(&retval);
INIT_ZVAL(return_value);
ZVAL_NULL(&return_value);
/* fetch the IDispatch interface */
zend_hash_index_find(Z_OBJPROP_P(object), 0, (void **) &comval_handle);
obj = (comval *) zend_list_find(Z_LVAL_P(*comval_handle), &type);
if (!obj || (type != IS_COM)) {
return retval;
return return_value;
}
ALLOC_COM(obj_prop);
@@ -1809,7 +1873,7 @@ PHPAPI pval php_COM_get_property_handler(zend_property_reference *property_refer
FREE_VARIANT(var_result);
FREE_COM(obj_prop);
return retval;
return return_value;
}
break;
@@ -1818,7 +1882,7 @@ PHPAPI pval php_COM_get_property_handler(zend_property_reference *property_refer
FREE_VARIANT(var_result);
FREE_COM(obj_prop);
return retval;
return return_value;
}
break;
@@ -1826,32 +1890,35 @@ PHPAPI pval php_COM_get_property_handler(zend_property_reference *property_refer
FREE_VARIANT(var_result);
if (obj != obj_prop) {
efree(obj_prop);
FREE_COM(obj_prop);
retval = *object;
zval_copy_ctor(&retval);
return_value = *object;
ZVAL_ADDREF(&return_value);
} else {
ZVAL_COM(&retval, obj);
RETVAL_COM(obj);
}
return retval;
return return_value;
}
zval_dtor(&overloaded_property->element);
if (obj == obj_prop) {
// not head
pval_destructor(&overloaded_property->element);
}
if (V_VT(var_result) == VT_DISPATCH) {
if (V_DISPATCH(var_result) == NULL) {
FREE_VARIANT(var_result);
FREE_COM(obj_prop);
return retval;
return return_value;
}
obj = obj_prop;
php_COM_set(obj, &V_DISPATCH(var_result), TRUE TSRMLS_CC);
VariantInit(var_result); /* to protect C_DISPATCH(obj) from being freed when var_result is destructed */
VariantInit(var_result); // to protect C_DISPATCH(obj) from being freed when var_result is destructed
} else {
php_variant_to_pval(var_result, &retval, codepage TSRMLS_CC);
php_variant_to_pval(var_result, &return_value, codepage TSRMLS_CC);
FREE_COM(obj_prop);
obj_prop = NULL;
@@ -1859,13 +1926,13 @@ PHPAPI pval php_COM_get_property_handler(zend_property_reference *property_refer
}
if (obj_prop != NULL) {
ZVAL_COM(&retval, obj);
RETVAL_COM(obj);
}
FREE_VARIANT(var_result);
return retval;
return return_value;
}
@@ -1934,8 +2001,8 @@ PHPAPI int php_COM_set_property_handler(zend_property_reference *property_refere
return FAILURE;
}
VariantInit(var_result); /* to protect C_DISPATCH(obj) from being freed when var_result is destructed */
zval_dtor(&overloaded_property->element);
VariantInit(var_result); // to protect C_DISPATCH(obj) from being freed when var_result is destructed
pval_destructor(&overloaded_property->element);
}
FREE_VARIANT(var_result);
@@ -1943,7 +2010,7 @@ PHPAPI int php_COM_set_property_handler(zend_property_reference *property_refere
do_COM_propput(NULL, obj, &overloaded_property->element, value TSRMLS_CC);
FREE_COM(obj_prop);
zval_dtor(&overloaded_property->element);
pval_destructor(&overloaded_property->element);
return SUCCESS;
}
@@ -1974,15 +2041,20 @@ PHPAPI void php_COM_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_pro
if (zend_llist_count(property_reference->elements_list)==1
&& !strcmp(Z_STRVAL(function_name->element), "com")) {
/* constructor */
pval *object_handle;
PHP_FN(com_load)(INTERNAL_FUNCTION_PARAM_PASSTHRU);
/* free instance created by 'new' */
zval_dtor(object);
if (zend_is_true(return_value)) {
ALLOC_ZVAL(object_handle);
*object_handle = *return_value;
pval_copy_constructor(object_handle);
INIT_PZVAL(object_handle);
zend_hash_index_update(Z_OBJPROP_P(object), 0, &object_handle, sizeof(pval *), NULL);
pval_destructor(&function_name->element);
} else {
ZVAL_NULL(object);
}
/* and override it with the instance created by 'com_load()' */
*object = *return_value;
INIT_ZVAL(*return_value);
zval_dtor(&function_name->element);
return;
}
@@ -1990,8 +2062,8 @@ PHPAPI void php_COM_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_pro
property = php_COM_get_property_handler(property_reference);
if (Z_TYPE(property) != IS_OBJECT) {
zval_dtor(&property);
zval_dtor(&function_name->element);
pval_destructor(&property);
pval_destructor(&function_name->element);
/* error message - function call on a non-object */
return;
@@ -2001,8 +2073,8 @@ PHPAPI void php_COM_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_pro
obj = (comval *)zend_list_find(Z_LVAL_PP(handle), &type);
if (!obj || (type != IS_COM)) {
zval_dtor(&property);
zval_dtor(&function_name->element);
pval_destructor(&property);
pval_destructor(&function_name->element);
return;
}
@@ -2020,20 +2092,24 @@ PHPAPI void php_COM_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_pro
ALLOC_VARIANT(var_result);
arguments = (zval **) emalloc(sizeof(zval *)*arg_count);
arguments = (pval **) emalloc(sizeof(pval *)*arg_count);
zend_get_parameters_array(ht, arg_count, arguments);
if (do_COM_invoke(obj , DISPATCH_METHOD|DISPATCH_PROPERTYGET, &function_name->element, var_result, arguments, arg_count TSRMLS_CC) == SUCCESS) {
RETVAL_VARIANT(var_result);
} else {
FREE_VARIANT(var_result);
php_variant_to_pval(var_result, return_value, codepage TSRMLS_CC);
}
FREE_VARIANT(var_result);
efree(arguments);
}
zval_dtor(&property);
zval_dtor(&function_name->element);
if (zend_llist_count(property_reference->elements_list) > 1) {
/* destruct temporary object */
zend_list_delete(Z_LVAL_PP(handle));
pval_destructor(&property);
}
pval_destructor(&function_name->element);
}
@@ -2207,6 +2283,7 @@ static ITypeLib *php_COM_find_typelib(char *search_string, int mode TSRMLS_DC)
PHPAPI int php_COM_load_typelib(ITypeLib *TypeLib, int mode TSRMLS_DC)
{
ITypeComp *TypeComp;
int i;
int interfaces;
@@ -2214,33 +2291,40 @@ PHPAPI int php_COM_load_typelib(ITypeLib *TypeLib, int mode TSRMLS_DC)
return FAILURE;
}
interfaces = ITypeLib_GetTypeInfoCount(TypeLib);
interfaces = TypeLib->lpVtbl->GetTypeInfoCount(TypeLib);
TypeLib->lpVtbl->GetTypeComp(TypeLib, &TypeComp);
for (i=0; i<interfaces; i++) {
TYPEKIND pTKind;
ITypeLib_GetTypeInfoType(TypeLib, i, &pTKind);
if (pTKind == TKIND_ENUM) {
TypeLib->lpVtbl->GetTypeInfoType(TypeLib, i, &pTKind);
if (pTKind==TKIND_ENUM) {
ITypeInfo *TypeInfo;
VARDESC *pVarDesc;
UINT NameCount;
int j;
#if 0
BSTR bstr_EnumId;
char *EnumId;
ITypeLib_GetTypeInfo(TypeLib, i, &TypeInfo);
TypeLib->lpVtbl->GetDocumentation(TypeLib, i, &bstr_EnumId, NULL, NULL, NULL);
EnumId = php_OLECHAR_to_char(bstr_EnumId, NULL, codepage);
printf("Enumeration %d - %s:\n", i, EnumId);
efree(EnumId);
#endif
for (j = 0; ; j++) {
TypeLib->lpVtbl->GetTypeInfo(TypeLib, i, &TypeInfo);
j=0;
while (SUCCEEDED(TypeInfo->lpVtbl->GetVarDesc(TypeInfo, j, &pVarDesc))) {
BSTR bstr_ids;
zend_constant c;
zval exists, results, value;
char *const_name;
if (FAILED(ITypeInfo_GetVarDesc(TypeInfo, j, &pVarDesc))) {
break;
}
ITypeInfo_GetNames(TypeInfo, pVarDesc->memid, &bstr_ids, 1, &NameCount);
if (NameCount != 1) {
ITypeInfo_ReleaseVarDesc(TypeInfo, pVarDesc);
TypeInfo->lpVtbl->GetNames(TypeInfo, pVarDesc->memid, &bstr_ids, 1, &NameCount);
if (NameCount!=1) {
j++;
continue;
}
const_name = php_OLECHAR_to_char(bstr_ids, &c.name_len, codepage TSRMLS_CC);
@@ -2257,7 +2341,7 @@ PHPAPI int php_COM_load_typelib(ITypeLib *TypeLib, int mode TSRMLS_DC)
php_error(E_WARNING, "%s(): Type library value %s is already defined and has a different value", get_active_function_name(TSRMLS_C), c.name);
}
free(c.name);
ITypeInfo_ReleaseVarDesc(TypeInfo, pVarDesc);
j++;
continue;
}
@@ -2271,9 +2355,10 @@ PHPAPI int php_COM_load_typelib(ITypeLib *TypeLib, int mode TSRMLS_DC)
zend_register_constant(&c TSRMLS_CC);
}
ITypeInfo_ReleaseVarDesc(TypeInfo, pVarDesc);
j++;
}
ITypeInfo_Release(TypeInfo);
TypeInfo->lpVtbl->Release(TypeInfo);
}
}
@@ -2285,7 +2370,9 @@ PHPAPI int php_COM_load_typelib(ITypeLib *TypeLib, int mode TSRMLS_DC)
PHP_FUNCTION(com_isenum)
{
pval *object;
pval **comval_handle;
comval *obj;
int type;
if (ZEND_NUM_ARGS() != 1) {
ZEND_WRONG_PARAM_COUNT();
@@ -2294,7 +2381,12 @@ PHP_FUNCTION(com_isenum)
zend_get_parameters(ht, 1, &object);
/* obtain IDispatch interface */
FETCH_COM_SAFE(object, obj);
zend_hash_index_find(Z_OBJPROP_P(object), 0, (void **) &comval_handle);
obj = (comval *) zend_list_find(Z_LVAL_PP(comval_handle), &type);
if (!obj || (type != IS_COM)) {
php_error(E_WARNING,"%s(): %s is not a COM object handler", get_active_function_name(TSRMLS_C), "");
RETURN_FALSE;
}
RETURN_BOOL(C_HASENUM(obj));
}
+2 -2
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -181,7 +181,7 @@ static pval php_VARIANT_get_property_handler(zend_property_reference *property_r
case OE_IS_OBJECT:
if (!strcmp(Z_STRVAL(overloaded_property->element), "value")) {
/* var_arg can't be an idispatch, so we don't care for the implicit AddRef() call here */
// var_arg can't be an idispatch, so we don't care for the implicit AddRef() call here
php_variant_to_pval(var_arg, &result, codepage TSRMLS_CC);
} else if (!strcmp(Z_STRVAL(overloaded_property->element), "type")) {
ZVAL_LONG(&result, V_VT(var_arg))
+4 -17
View File
@@ -42,33 +42,20 @@ END_EXTERN_C()
} \
ZVAL_RESOURCE(handle, zend_list_insert((o), IS_COM)); \
\
zval_copy_ctor(handle); \
zend_hash_index_update(properties, 0, &handle, sizeof(zval *), NULL); \
object_and_properties_init(z, &COM_class_entry, properties); \
(z)->is_ref=1; \
}
#define RETVAL_COM(o) ZVAL_COM(return_value, o);
#define RETVAL_COM(o) ZVAL_COM(&return_value, o);
#define RETURN_COM(o) RETVAL_COM(o) \
return;
#define ALLOC_COM(z) (z) = (comval *) ecalloc(1, sizeof(comval));
#define ALLOC_COM(z) (z) = (comval *) ecalloc(1, sizeof(comval)); \
C_REFCOUNT(z) = 0;
#define FREE_COM(z) php_COM_destruct(z TSRMLS_CC);
#define FETCH_COM(z, obj) { \
zval **tmp; \
zend_hash_index_find(Z_OBJPROP_P(z), 0, (void**)&tmp); \
ZEND_FETCH_RESOURCE(obj, comval*, tmp, -1, "comval", IS_COM); \
} \
if (obj == NULL) { \
php_error(E_WARNING, "%d is not a COM object handler", Z_LVAL_P(z)); \
RETURN_NULL(); \
}
#define FETCH_COM_SAFE(z, obj) \
if ((Z_TYPE_P(z) == IS_OBJECT) && (Z_OBJCE_P(z) == &COM_class_entry)) \
FETCH_COM(z, obj)
#define IS_COM php_COM_get_le_comval()
#define C_HASTLIB(x) ((x)->typelib)
+3 -2
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -119,7 +119,7 @@ PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, VARTYPE ty
var_arg = V_VARIANTREF(var_arg); /* put the array in that VARIANT */
}
if (!type) {
/* if no type is given we take the variant type */
// if no type is given we take the variant type
type = VT_VARIANT;
}
@@ -729,6 +729,7 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int codepage TS
php_COM_set(obj, &V_DISPATCH(var_arg), FALSE TSRMLS_CC);
ZVAL_COM(pval_arg, obj);
VariantInit(var_arg); // to protect C_DISPATCH(obj) from being freed when var_result is destructed
}
}
break;
+2 -2
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -280,7 +280,7 @@ static HRESULT STDMETHODCALLTYPE disp_invokeex(
ZVAL_NULL(zarg);
}
} else {
/* arg can't be an idispatch, so we don't care for the implicit AddRef() call here */
// arg can't be an idispatch, so we don't care for the implicit AddRef() call here
if (FAILURE == php_variant_to_pval(arg, zarg, codepage TSRMLS_CC)) {
trace("failed to convert arg %d to zval\n", i);
ZVAL_NULL(zarg);
+1 -1
View File
@@ -58,7 +58,7 @@ ZEND_BEGIN_MODULE_GLOBALS(com)
int nothing;
ZEND_END_MODULE_GLOBALS(com)
PHPAPI ZEND_EXTERN_MODULE_GLOBALS(com)
PHPAPI ZEND_EXTERN_MODULE_GLOBALS(com);
#ifdef ZTS
#define COMG(v) TSRMG(com_globals_id, zend_com_globals *, v)
+8 -13
View File
@@ -12,19 +12,14 @@
#define IS_VARIANT php_VARIANT_get_le_variant()
#define ZVAL_VARIANT(z, v) if (V_VT(v) == VT_DISPATCH) { \
if (V_DISPATCH(v)) { \
comval *obj; \
ALLOC_COM(obj); \
php_COM_set(obj, &V_DISPATCH(v), TRUE TSRMLS_CC); \
ZVAL_COM((z), obj); \
efree(v); \
} else { \
ZVAL_NULL(z); \
} \
} else { \
php_variant_to_pval((v), (z), codepage TSRMLS_CC); \
FREE_VARIANT(v); \
#define ZVAL_VARIANT(z, v) if (V_VT(v) == VT_DISPATCH) { \
comval *obj; \
ALLOC_COM(obj); \
php_COM_set(obj, &V_DISPATCH(v), TRUE TSRMLS_CC); \
ZVAL_RESOURCE((z), zend_list_insert(obj, IS_COM)); \
} else { \
php_variant_to_pval((v), (z), codepage TSRMLS_CC); \
FREE_VARIANT(v); \
}
#define RETVAL_VARIANT(v) ZVAL_VARIANT(return_value, (v));
+58 -75
View File
@@ -1,87 +1,70 @@
dnl $Id$
AC_DEFUN(CPDF_JPEG_TEST,[
AC_ARG_WITH(jpeg-dir,
[ --with-jpeg-dir[=DIR] CPDF: Set the path to libjpeg install prefix.],[
for i in $withval /usr/local /usr; do
if test -f "$i/lib/libjpeg.$SHLIB_SUFFIX_NAME" -o -f "$i/lib/libjpeg.a"; then
CPDF_JPEG_DIR=$i
break;
fi
done
if test -z "$CPDF_JPEG_DIR"; then
AC_MSG_CHECKING([for libjpeg (needed by cpdflib 2.x)])
AC_MSG_ERROR([libjpeg.(a|so) not found.])
fi
PHP_CHECK_LIBRARY(jpeg, jpeg_read_header, [
PHP_ADD_LIBRARY_WITH_PATH(jpeg, $CPDF_JPEG_DIR/lib, CPDF_SHARED_LIBADD)
] ,[
AC_MSG_ERROR([CPDF: Problem with libjpeg.(a|so). Please check config.log for more information.])
], [
-L$CPDF_JPEG_DIR/lib
])
],)
])
AC_DEFUN(CPDF_TIFF_TEST,[
AC_ARG_WITH(tiff-dir,
[ --with-tiff-dir[=DIR] CPDF: Set the path to libtiff install prefix.],[
for i in $withval /usr/local /usr; do
if test -f "$i/lib/libtiff.$SHLIB_SUFFIX_NAME" -o -f "$i/lib/libtiff.a"; then
CPDF_TIFF_DIR=$i
break;
fi
done
if test -z "$CPDF_TIFF_DIR"; then
AC_MSG_CHECKING([for libtiff (needed by cpdflib 2.x)])
AC_MSG_ERROR([libtiff.(a|so) not found.])
fi
PHP_CHECK_LIBRARY(tiff, TIFFOpen, [
PHP_ADD_LIBRARY_WITH_PATH(tiff, $CPDF_TIFF_DIR/lib, CPDF_SHARED_LIBADD)
] ,[
AC_MSG_ERROR([CPDF: Problem with libtiff.(a|so). Please check config.log for more information.])
], [
-L$CPDF_TIFF_DIR/lib
])
],)
])
AC_MSG_CHECKING(for cpdflib support)
AC_ARG_WITH(cpdflib,
[ --with-cpdflib[=DIR] Include cpdflib support (requires cpdflib >= 2).],
[
PHP_WITH_SHARED
if test "$withval" != "no"; then
cpdf_withval=$withval
PHP_NEW_EXTENSION(cpdf, cpdf.c, $ext_shared,, \\$(GDLIB_CFLAGS))
PHP_SUBST(CPDF_SHARED_LIBADD)
CPDF_JPEG_TEST
CPDF_TIFF_TEST
case $withval in
no)
AC_MSG_RESULT(no) ;;
yes)
AC_MSG_RESULT(yes)
PHP_NEW_EXTENSION(cpdf, cpdf.c)
AC_CHECK_LIB(cpdf, cpdf_open, [AC_DEFINE(HAVE_CPDFLIB,1,[Whether you have cpdflib])],
[AC_MSG_ERROR([Cpdf module requires cpdflib >= 2.])])
PHP_ADD_LIBRARY(cpdf)
PHP_ADD_LIBRARY(tiff)
PHP_ADD_LIBRARY(jpeg)
;;
*)
test -f $withval/include/cpdflib.h && CPDFLIB_INCLUDE=$withval/include
if test -n "$CPDFLIB_INCLUDE" ; then
AC_MSG_RESULT(yes)
PHP_NEW_EXTENSION(cpdf, cpdf.c)
old_LIBS=$LIBS
old_withval=$withval
for i in $cpdf_withval /usr/local /usr; do
if test -f "$i/include/cpdflib.h"; then
CPDFLIB_INCLUDE=$i/include
AC_MSG_CHECKING(for cpdflib.h)
AC_MSG_RESULT([in $i/include])
AC_MSG_CHECKING([for libjpeg (needed by cpdflib 2.x)])
AC_ARG_WITH(jpeg-dir,
[ --with-jpeg-dir[=DIR] jpeg dir for cpdflib 2.x],[
AC_MSG_RESULT(yes)
if test -z $withval; then
withval=/usr/local
fi
LIBS="$LIBS -L$withval/lib"
AC_CHECK_LIB(jpeg,jpeg_read_header, ,[AC_MSG_RESULT(no)],)
PHP_ADD_LIBRARY_WITH_PATH(jpeg, $withval/lib)
],[
AC_MSG_RESULT(no)
AC_MSG_WARN(If configure fails try --with-jpeg-dir=<DIR>)
])
PHP_CHECK_LIBRARY(cpdf, cpdf_open, [
PHP_ADD_INCLUDE($CPDFLIB_INCLUDE)
PHP_ADD_LIBRARY_WITH_PATH(cpdf, $i/lib, CPDF_SHARED_LIBADD)
AC_DEFINE(HAVE_CPDFLIB,1,[Whether you have cpdflib])
], [
AC_MSG_ERROR([Cpdflib module requires cpdflib >= 2.])
], [
-L$i/lib $CPDF_SHARED_LIBADD
])
break
fi
done
AC_MSG_CHECKING([for libtiff (needed by cpdflib 2.x)])
AC_ARG_WITH(tiff-dir,
[ --with-tiff-dir[=DIR] tiff dir for cpdflib 2.x],[
AC_MSG_RESULT(yes)
if test -z $withval; then
withval=/usr/local
fi
LIBS="$LIBS -L$withval/lib"
AC_CHECK_LIB(tiff,TIFFOpen, ,[AC_MSG_RESULT(no)],)
PHP_ADD_LIBRARY_WITH_PATH(tiff, $withval/lib)
],[
AC_MSG_RESULT(no)
AC_MSG_WARN(If configure fails try --with-tiff-dir=<DIR>)
])
withval=$old_withval
if test -z "$CPDFLIB_INCLUDE"; then
AC_MSG_CHECKING(for cpdflib.h)
AC_MSG_ERROR([not found])
fi
fi
LIBS="$LIBS -L$withval/lib"
AC_CHECK_LIB(cpdf, cpdf_open, [AC_DEFINE(HAVE_CPDFLIB,1,[Whether you have cpdflib])],
[AC_MSG_ERROR([Cpdflib module requires cpdflib >= 2.])])
LIBS=$old_LIBS
PHP_ADD_LIBRARY_WITH_PATH(cpdf, $withval/lib)
PHP_ADD_INCLUDE($CPDFLIB_INCLUDE)
else
AC_MSG_RESULT(no)
fi ;;
esac
],[
AC_MSG_RESULT(no)
])
+71 -107
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -41,8 +41,6 @@
#include <gd.h>
#endif
#include <cpdflib.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
@@ -222,7 +220,7 @@ PHP_MSHUTDOWN_FUNCTION(cpdf)
return SUCCESS;
}
/* {{{ proto bool cpdf_global_set_document_limits(int maxPages, int maxFonts, int maxImages, int maxAnnots, int maxObjects)
/* {{{ proto void cpdf_global_set_document_limits(int maxPages, int maxFonts, int maxImages, int maxAnnots, int maxObjects)
Sets document settings for all documents */
PHP_FUNCTION(cpdf_global_set_document_limits)
{
@@ -356,7 +354,7 @@ PHP_FUNCTION(cpdf_set_keywords)
}
/* }}} */
/* {{{ proto bool cpdf_set_viewer_preferences(int pdfdoc, array preferences)
/* {{{ proto void cpdf_set_viewer_preferences(int pdfdoc, array preferences)
How to show the document in the viewer */
PHP_FUNCTION(cpdf_set_viewer_preferences)
{
@@ -475,11 +473,6 @@ PHP_FUNCTION(cpdf_open)
if(strcmp(Z_STRVAL_P(arg2), "-") == 0)
php_error(E_WARNING, "%s(): Writing to stdout as described in the ClibPDF manual is not possible if php is used as an Apache module. Write to a memory stream and use cpdf_output_buffer() instead.", get_active_function_name(TSRMLS_C));
#endif
if (php_check_open_basedir(Z_STRVAL_P(arg2) TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(Z_STRVAL_P(arg2), "rb+", CHECKUID_CHECK_MODE_PARAM))) {
cpdf_close(cpdf);
RETURN_FALSE;
}
cpdf_setOutputFilename(cpdf, Z_STRVAL_P(arg2));
}
cpdf_init(cpdf);
@@ -515,7 +508,7 @@ PHP_FUNCTION(cpdf_close)
/* }}} */
#define BUFFERLEN 40
/* {{{ proto bool cpdf_page_init(int pdfdoc, int pagenr, int orientation, int height, int width [, float unit])
/* {{{ proto void cpdf_page_init(int pdfdoc, int pagenr, int orientation, int height, int width [, float unit])
Starts page */
PHP_FUNCTION(cpdf_page_init)
{
@@ -560,7 +553,7 @@ PHP_FUNCTION(cpdf_page_init)
/* }}} */
#undef BUFFERLEN
/* {{{ proto bool cpdf_finalize_page(int pdfdoc, int pagenr)
/* {{{ proto void cpdf_finalize_page(int pdfdoc, int pagenr)
Ends the page to save memory */
PHP_FUNCTION(cpdf_finalize_page)
{
@@ -588,7 +581,7 @@ PHP_FUNCTION(cpdf_finalize_page)
}
/* }}} */
/* {{{ proto bool cpdf_set_current_page(int pdfdoc, int pagenr)
/* {{{ proto void cpdf_set_current_page(int pdfdoc, int pagenr)
Sets page for output */
PHP_FUNCTION(cpdf_set_current_page)
{
@@ -616,7 +609,7 @@ PHP_FUNCTION(cpdf_set_current_page)
}
/* }}} */
/* {{{ proto bool cpdf_begin_text(int pdfdoc)
/* {{{ proto void cpdf_begin_text(int pdfdoc)
Starts text section */
PHP_FUNCTION(cpdf_begin_text)
{
@@ -642,7 +635,7 @@ PHP_FUNCTION(cpdf_begin_text)
}
/* }}} */
/* {{{ proto bool cpdf_end_text(int pdfdoc)
/* {{{ proto void cpdf_end_text(int pdfdoc)
Ends text section */
PHP_FUNCTION(cpdf_end_text)
{
@@ -668,7 +661,7 @@ PHP_FUNCTION(cpdf_end_text)
}
/* }}} */
/* {{{ proto bool cpdf_show(int pdfdoc, string text)
/* {{{ proto void cpdf_show(int pdfdoc, string text)
Output text at current position */
PHP_FUNCTION(cpdf_show)
{
@@ -695,7 +688,7 @@ PHP_FUNCTION(cpdf_show)
}
/* }}} */
/* {{{ proto bool cpdf_show_xy(int pdfdoc, string text, float x-koor, float y-koor [, int mode])
/* {{{ proto void cpdf_show_xy(int pdfdoc, string text, float x-koor, float y-koor [, int mode])
Output text at position */
PHP_FUNCTION(cpdf_show_xy)
{
@@ -733,7 +726,7 @@ PHP_FUNCTION(cpdf_show_xy)
}
/* }}} */
/* {{{ proto bool cpdf_continue_text(int pdfdoc, string text)
/* {{{ proto void cpdf_continue_text(int pdfdoc, string text)
Outputs text in next line */
PHP_FUNCTION(cpdf_continue_text)
{
@@ -760,7 +753,7 @@ PHP_FUNCTION(cpdf_continue_text)
}
/* }}} */
/* {{{ proto bool cpdf_text(int pdfdoc, string text [, float x-koor, float y-koor [, int mode [, float orientation [, int alignmode]]]])
/* {{{ proto void cpdf_text(int pdfdoc, string text [, float x-koor, float y-koor [, int mode [, float orientation [, int alignmode]]]])
Outputs text */
PHP_FUNCTION(cpdf_text)
{
@@ -850,7 +843,7 @@ PHP_FUNCTION(cpdf_text)
}
/* }}} */
/* {{{ proto bool cpdf_set_font(int pdfdoc, string font, float size, string encoding)
/* {{{ proto void cpdf_set_font(int pdfdoc, string font, float size, string encoding)
Selects the current font face, size and encoding */
PHP_FUNCTION(cpdf_set_font)
{
@@ -884,7 +877,7 @@ PHP_FUNCTION(cpdf_set_font)
}
/* }}} */
/* {{{ proto bool cpdf_set_font_directories(int pdfdoc, string pfmdir, string pfbdir)
/* {{{ proto void cpdf_set_font_directories(int pdfdoc, string pfmdir, string pfbdir)
Sets directories to search when using external fonts */
PHP_FUNCTION(cpdf_set_font_directories)
{
@@ -912,7 +905,7 @@ PHP_FUNCTION(cpdf_set_font_directories)
}
/* }}} */
/* {{{ proto bool cpdf_set_font_map_file(int pdfdoc, string filename)
/* {{{ proto void cpdf_set_font_map_file(int pdfdoc, string filename)
Sets fontname to filename translation map when using external fonts */
PHP_FUNCTION(cpdf_set_font_map_file)
{
@@ -933,17 +926,13 @@ PHP_FUNCTION(cpdf_set_font_map_file)
RETURN_FALSE;
}
if (php_check_open_basedir(Z_STRVAL_P(arg2) TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(Z_STRVAL_P(arg2), "rb+", CHECKUID_CHECK_MODE_PARAM))) {
RETURN_FALSE;
}
cpdf_setFontMapFile(pdf, Z_STRVAL_P(arg2));
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool cpdf_set_leading(int pdfdoc, float distance)
/* {{{ proto void cpdf_set_leading(int pdfdoc, float distance)
Sets distance between text lines */
PHP_FUNCTION(cpdf_set_leading)
{
@@ -970,7 +959,7 @@ PHP_FUNCTION(cpdf_set_leading)
}
/* }}} */
/* {{{ proto bool cpdf_set_text_rendering(int pdfdoc, int rendermode)
/* {{{ proto void cpdf_set_text_rendering(int pdfdoc, int rendermode)
Determines how text is rendered */
PHP_FUNCTION(cpdf_set_text_rendering)
{
@@ -997,7 +986,7 @@ PHP_FUNCTION(cpdf_set_text_rendering)
}
/* }}} */
/* {{{ proto bool cpdf_set_horiz_scaling(int pdfdoc, float scale)
/* {{{ proto void cpdf_set_horiz_scaling(int pdfdoc, float scale)
Sets horizontal scaling of text */
PHP_FUNCTION(cpdf_set_horiz_scaling)
{
@@ -1024,7 +1013,7 @@ PHP_FUNCTION(cpdf_set_horiz_scaling)
}
/* }}} */
/* {{{ proto bool cpdf_set_text_rise(int pdfdoc, float value)
/* {{{ proto void cpdf_set_text_rise(int pdfdoc, float value)
Sets the text rise */
PHP_FUNCTION(cpdf_set_text_rise)
{
@@ -1051,7 +1040,7 @@ PHP_FUNCTION(cpdf_set_text_rise)
}
/* }}} */
/* {{{ proto bool cpdf_set_text_matrix(int pdfdoc, arry matrix)
/* {{{ proto void cpdf_set_text_matrix(int pdfdoc, arry matrix)
Sets the text matrix */
PHP_FUNCTION(cpdf_set_text_matrix)
{
@@ -1104,7 +1093,7 @@ PHP_FUNCTION(cpdf_set_text_matrix)
}
/* }}} */
/* {{{ proto bool cpdf_set_text_pos(int pdfdoc, float x, float y [, int mode])
/* {{{ proto void cpdf_set_text_pos(int pdfdoc, float x, float y [, int mode])
Sets the position of text for the next cpdf_show call */
PHP_FUNCTION(cpdf_set_text_pos)
{
@@ -1141,7 +1130,7 @@ PHP_FUNCTION(cpdf_set_text_pos)
}
/* }}} */
/* {{{ proto bool cpdf_rotate_text(int pdfdoc, float angle)
/* {{{ proto void cpdf_rotate_text(int pdfdoc, float angle)
Sets text rotation angle */
PHP_FUNCTION(cpdf_rotate_text)
{
@@ -1168,7 +1157,7 @@ PHP_FUNCTION(cpdf_rotate_text)
}
/* }}} */
/* {{{ proto bool cpdf_set_char_spacing(int pdfdoc, float space)
/* {{{ proto void cpdf_set_char_spacing(int pdfdoc, float space)
Sets character spacing */
PHP_FUNCTION(cpdf_set_char_spacing)
{
@@ -1195,7 +1184,7 @@ PHP_FUNCTION(cpdf_set_char_spacing)
}
/* }}} */
/* {{{ proto bool cpdf_set_word_spacing(int pdfdoc, float space)
/* {{{ proto void cpdf_set_word_spacing(int pdfdoc, float space)
Sets spacing between words */
PHP_FUNCTION(cpdf_set_word_spacing)
{
@@ -1250,7 +1239,7 @@ PHP_FUNCTION(cpdf_stringwidth)
}
/* }}} */
/* {{{ proto bool cpdf_save(int pdfdoc)
/* {{{ proto void cpdf_save(int pdfdoc)
Saves current enviroment */
PHP_FUNCTION(cpdf_save)
{
@@ -1276,7 +1265,7 @@ PHP_FUNCTION(cpdf_save)
}
/* }}} */
/* {{{ proto bool cpdf_restore(int pdfdoc)
/* {{{ proto void cpdf_restore(int pdfdoc)
Restores formerly saved enviroment */
PHP_FUNCTION(cpdf_restore)
{
@@ -1302,7 +1291,7 @@ PHP_FUNCTION(cpdf_restore)
}
/* }}} */
/* {{{ proto bool cpdf_translate(int pdfdoc, float x, float y)
/* {{{ proto void cpdf_translate(int pdfdoc, float x, float y)
Sets origin of coordinate system */
PHP_FUNCTION(cpdf_translate)
{
@@ -1330,7 +1319,7 @@ PHP_FUNCTION(cpdf_translate)
}
/* }}} */
/* {{{ proto bool cpdf_scale(int pdfdoc, float x_scale, float y_scale)
/* {{{ proto void cpdf_scale(int pdfdoc, float x_scale, float y_scale)
Sets scaling */
PHP_FUNCTION(cpdf_scale)
{
@@ -1358,7 +1347,7 @@ PHP_FUNCTION(cpdf_scale)
}
/* }}} */
/* {{{ proto bool cpdf_rotate(int pdfdoc, float angle)
/* {{{ proto void cpdf_rotate(int pdfdoc, float angle)
Sets rotation */
PHP_FUNCTION(cpdf_rotate)
{
@@ -1385,7 +1374,7 @@ PHP_FUNCTION(cpdf_rotate)
}
/* }}} */
/* {{{ proto bool cpdf_setflat(int pdfdoc, float value)
/* {{{ proto void cpdf_setflat(int pdfdoc, float value)
Sets flatness */
PHP_FUNCTION(cpdf_setflat)
{
@@ -1417,7 +1406,7 @@ PHP_FUNCTION(cpdf_setflat)
}
/* }}} */
/* {{{ proto bool cpdf_setlinejoin(int pdfdoc, int value)
/* {{{ proto void cpdf_setlinejoin(int pdfdoc, int value)
Sets linejoin parameter */
PHP_FUNCTION(cpdf_setlinejoin)
{
@@ -1449,7 +1438,7 @@ PHP_FUNCTION(cpdf_setlinejoin)
}
/* }}} */
/* {{{ proto bool cpdf_setlinecap(int pdfdoc, int value)
/* {{{ proto void cpdf_setlinecap(int pdfdoc, int value)
Sets linecap parameter */
PHP_FUNCTION(cpdf_setlinecap)
{
@@ -1481,7 +1470,7 @@ PHP_FUNCTION(cpdf_setlinecap)
}
/* }}} */
/* {{{ proto bool cpdf_setmiterlimit(int pdfdoc, float value)
/* {{{ proto void cpdf_setmiterlimit(int pdfdoc, float value)
Sets miter limit */
PHP_FUNCTION(cpdf_setmiterlimit)
{
@@ -1513,7 +1502,7 @@ PHP_FUNCTION(cpdf_setmiterlimit)
}
/* }}} */
/* {{{ proto bool cpdf_setlinewidth(int pdfdoc, float width)
/* {{{ proto void cpdf_setlinewidth(int pdfdoc, float width)
Sets line width */
PHP_FUNCTION(cpdf_setlinewidth)
{
@@ -1541,7 +1530,7 @@ PHP_FUNCTION(cpdf_setlinewidth)
/* }}} */
#define BUFFERLEN 20
/* {{{ proto bool cpdf_setdash(int pdfdoc, long white, long black)
/* {{{ proto void cpdf_setdash(int pdfdoc, long white, long black)
Sets dash pattern */
PHP_FUNCTION(cpdf_setdash)
{
@@ -1563,9 +1552,7 @@ PHP_FUNCTION(cpdf_setdash)
php_error(E_WARNING, "%s(): Unable to find identifier %d", get_active_function_name(TSRMLS_C), id);
RETURN_FALSE;
}
if (!pdf->currentMemStream) {
RETURN_FALSE;
}
snprintf(buffer, BUFFERLEN, "[%d %d] 0", (int) Z_LVAL_P(arg2), (int) Z_LVAL_P(arg3));
cpdf_setdash(pdf, buffer);
@@ -1574,7 +1561,7 @@ PHP_FUNCTION(cpdf_setdash)
/* }}} */
#undef BUFFERLEN
/* {{{ proto bool cpdf_moveto(int pdfdoc, float x, float y [, int mode])
/* {{{ proto void cpdf_moveto(int pdfdoc, float x, float y [, int mode])
Sets current point */
PHP_FUNCTION(cpdf_moveto)
{
@@ -1611,7 +1598,7 @@ PHP_FUNCTION(cpdf_moveto)
}
/* }}} */
/* {{{ proto bool cpdf_rmoveto(int pdfdoc, float x, float y [, int mode])
/* {{{ proto void cpdf_rmoveto(int pdfdoc, float x, float y [, int mode])
Sets current point */
PHP_FUNCTION(cpdf_rmoveto)
{
@@ -1648,7 +1635,7 @@ PHP_FUNCTION(cpdf_rmoveto)
}
/* }}} */
/* {{{ proto bool cpdf_curveto(int pdfdoc, float x1, float y1, float x2, float y2, float x3, float y3 [, int mode])
/* {{{ proto void cpdf_curveto(int pdfdoc, float x1, float y1, float x2, float y2, float x3, float y3 [, int mode])
Draws a curve */
PHP_FUNCTION(cpdf_curveto)
{
@@ -1699,7 +1686,7 @@ PHP_FUNCTION(cpdf_curveto)
}
/* }}} */
/* {{{ proto bool cpdf_lineto(int pdfdoc, float x, float y [, int mode])
/* {{{ proto void cpdf_lineto(int pdfdoc, float x, float y [, int mode])
Draws a line */
PHP_FUNCTION(cpdf_lineto)
{
@@ -1736,7 +1723,7 @@ PHP_FUNCTION(cpdf_lineto)
}
/* }}} */
/* {{{ proto bool cpdf_rlineto(int pdfdoc, float x, float y [, int mode])
/* {{{ proto void cpdf_rlineto(int pdfdoc, float x, float y [, int mode])
Draws a line relative to current point */
PHP_FUNCTION(cpdf_rlineto)
{
@@ -1773,7 +1760,7 @@ PHP_FUNCTION(cpdf_rlineto)
}
/* }}} */
/* {{{ proto bool cpdf_circle(int pdfdoc, float x, float y, float radius [, int mode])
/* {{{ proto void cpdf_circle(int pdfdoc, float x, float y, float radius [, int mode])
Draws a circle */
PHP_FUNCTION(cpdf_circle)
{
@@ -1811,7 +1798,7 @@ PHP_FUNCTION(cpdf_circle)
}
/* }}} */
/* {{{ proto bool cpdf_arc(int pdfdoc, float x, float y, float radius, float start, float end [, int mode])
/* {{{ proto void cpdf_arc(int pdfdoc, float x, float y, float radius, float start, float end [, int mode])
Draws an arc */
PHP_FUNCTION(cpdf_arc)
{
@@ -1851,7 +1838,7 @@ PHP_FUNCTION(cpdf_arc)
}
/* }}} */
/* {{{ proto bool cpdf_rect(int pdfdoc, float x, float y, float width, float height [, int mode])
/* {{{ proto void cpdf_rect(int pdfdoc, float x, float y, float width, float height [, int mode])
Draws a rectangle */
PHP_FUNCTION(cpdf_rect)
{
@@ -1896,7 +1883,7 @@ PHP_FUNCTION(cpdf_rect)
}
/* }}} */
/* {{{ proto bool cpdf_newpath(int pdfdoc)
/* {{{ proto void cpdf_newpath(int pdfdoc)
Starts new path */
PHP_FUNCTION(cpdf_newpath)
{
@@ -1922,7 +1909,7 @@ PHP_FUNCTION(cpdf_newpath)
}
/* }}} */
/* {{{ proto bool cpdf_closepath(int pdfdoc)
/* {{{ proto void cpdf_closepath(int pdfdoc)
Close path */
PHP_FUNCTION(cpdf_closepath)
{
@@ -1948,7 +1935,7 @@ PHP_FUNCTION(cpdf_closepath)
}
/* }}} */
/* {{{ proto bool cpdf_closepath_stroke(int pdfdoc)
/* {{{ proto void cpdf_closepath_stroke(int pdfdoc)
Close path and draw line along path */
PHP_FUNCTION(cpdf_closepath_stroke)
{
@@ -1975,7 +1962,7 @@ PHP_FUNCTION(cpdf_closepath_stroke)
}
/* }}} */
/* {{{ proto bool cpdf_stroke(int pdfdoc)
/* {{{ proto void cpdf_stroke(int pdfdoc)
Draws line along path path */
PHP_FUNCTION(cpdf_stroke)
{
@@ -2001,7 +1988,7 @@ PHP_FUNCTION(cpdf_stroke)
}
/* }}} */
/* {{{ proto bool cpdf_fill(int pdfdoc)
/* {{{ proto void cpdf_fill(int pdfdoc)
Fills current path */
PHP_FUNCTION(cpdf_fill)
{
@@ -2027,7 +2014,7 @@ PHP_FUNCTION(cpdf_fill)
}
/* }}} */
/* {{{ proto bool cpdf_fill_stroke(int pdfdoc)
/* {{{ proto void cpdf_fill_stroke(int pdfdoc)
Fills and stroke current path */
PHP_FUNCTION(cpdf_fill_stroke)
{
@@ -2054,7 +2041,7 @@ PHP_FUNCTION(cpdf_fill_stroke)
}
/* }}} */
/* {{{ proto bool cpdf_closepath_fill_stroke(int pdfdoc)
/* {{{ proto void cpdf_closepath_fill_stroke(int pdfdoc)
Close, fill and stroke current path */
PHP_FUNCTION(cpdf_closepath_fill_stroke)
{
@@ -2082,7 +2069,7 @@ PHP_FUNCTION(cpdf_closepath_fill_stroke)
}
/* }}} */
/* {{{ proto bool cpdf_clip(int pdfdoc)
/* {{{ proto void cpdf_clip(int pdfdoc)
Clips to current path */
PHP_FUNCTION(cpdf_clip)
{
@@ -2108,7 +2095,7 @@ PHP_FUNCTION(cpdf_clip)
}
/* }}} */
/* {{{ proto bool cpdf_setgray_fill(int pdfdoc, float value)
/* {{{ proto void cpdf_setgray_fill(int pdfdoc, float value)
Sets filling color to gray value */
PHP_FUNCTION(cpdf_setgray_fill)
{
@@ -2135,7 +2122,7 @@ PHP_FUNCTION(cpdf_setgray_fill)
}
/* }}} */
/* {{{ proto bool cpdf_setgray_stroke(int pdfdoc, float value)
/* {{{ proto void cpdf_setgray_stroke(int pdfdoc, float value)
Sets drawing color to gray value */
PHP_FUNCTION(cpdf_setgray_stroke)
{
@@ -2162,7 +2149,7 @@ PHP_FUNCTION(cpdf_setgray_stroke)
}
/* }}} */
/* {{{ proto bool cpdf_setgray(int pdfdoc, float value)
/* {{{ proto void cpdf_setgray(int pdfdoc, float value)
Sets drawing and filling color to gray value */
PHP_FUNCTION(cpdf_setgray)
{
@@ -2189,7 +2176,7 @@ PHP_FUNCTION(cpdf_setgray)
}
/* }}} */
/* {{{ proto bool cpdf_setrgbcolor_fill(int pdfdoc, float red, float green, float blue)
/* {{{ proto void cpdf_setrgbcolor_fill(int pdfdoc, float red, float green, float blue)
Sets filling color to rgb color value */
PHP_FUNCTION(cpdf_setrgbcolor_fill)
{
@@ -2218,7 +2205,7 @@ PHP_FUNCTION(cpdf_setrgbcolor_fill)
}
/* }}} */
/* {{{ proto bool cpdf_setrgbcolor_stroke(int pdfdoc, float red, float green, float blue)
/* {{{ proto void cpdf_setrgbcolor_stroke(int pdfdoc, float red, float green, float blue)
Sets drawing color to RGB color value */
PHP_FUNCTION(cpdf_setrgbcolor_stroke)
{
@@ -2247,7 +2234,7 @@ PHP_FUNCTION(cpdf_setrgbcolor_stroke)
}
/* }}} */
/* {{{ proto bool cpdf_setrgbcolor(int pdfdoc, float red, float green, float blue)
/* {{{ proto void cpdf_setrgbcolor(int pdfdoc, float red, float green, float blue)
Sets drawing and filling color to RGB color value */
PHP_FUNCTION(cpdf_setrgbcolor)
{
@@ -2276,7 +2263,7 @@ PHP_FUNCTION(cpdf_setrgbcolor)
}
/* }}} */
/* {{{ proto bool cpdf_set_page_animation(int pdfdoc, int transition, float duration, float direction, int orientation, int inout)
/* {{{ proto void cpdf_set_page_animation(int pdfdoc, int transition, float duration, float direction, int orientation, int inout)
Sets transition between pages */
PHP_FUNCTION(cpdf_set_page_animation)
{
@@ -2308,7 +2295,7 @@ PHP_FUNCTION(cpdf_set_page_animation)
}
/* }}} */
/* {{{ proto bool cpdf_finalize(int pdfdoc)
/* {{{ proto array cpdf_finalize(int pdfdoc)
Creates PDF doc in memory */
PHP_FUNCTION(cpdf_finalize)
{
@@ -2334,7 +2321,7 @@ PHP_FUNCTION(cpdf_finalize)
}
/* }}} */
/* {{{ proto bool cpdf_output_buffer(int pdfdoc)
/* {{{ proto array cpdf_output_buffer(int pdfdoc)
Returns the internal memory stream as string */
PHP_FUNCTION(cpdf_output_buffer)
{
@@ -2363,7 +2350,7 @@ PHP_FUNCTION(cpdf_output_buffer)
}
/* }}} */
/* {{{ proto bool cpdf_save_to_file(int pdfdoc, string filename)
/* {{{ proto array cpdf_save_to_file(int pdfdoc, string filename)
Saves the internal memory stream to a file */
PHP_FUNCTION(cpdf_save_to_file)
{
@@ -2389,17 +2376,13 @@ PHP_FUNCTION(cpdf_save_to_file)
php_error(E_WARNING, "%s(): Writing to stdout as described in the ClibPDF manual is not possible if php is used as an Apache module. Use cpdf_output_buffer() instead.", get_active_function_name(TSRMLS_C));
#endif
if (php_check_open_basedir(Z_STRVAL_P(arg2) TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(Z_STRVAL_P(arg2), "wb+", CHECKUID_CHECK_MODE_PARAM))) {
RETURN_FALSE;
}
cpdf_savePDFmemoryStreamToFile(pdf, Z_STRVAL_P(arg2));
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool cpdf_import_jpeg(int pdfdoc, string filename, float x, float y, float angle, float width, float height, float x_scale, float y_scale, int gsave [, int mode])
/* {{{ proto void cpdf_import_jpeg(int pdfdoc, string filename, float x, float y, float angle, float width, float height, float x_scale, float y_scale, int gsave [, int mode])
Includes JPEG image */
PHP_FUNCTION(cpdf_import_jpeg)
{
@@ -2416,11 +2399,6 @@ PHP_FUNCTION(cpdf_import_jpeg)
convert_to_long(argv[0]);
convert_to_string(argv[1]);
if (php_check_open_basedir(Z_STRVAL_P(argv[1]) TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(Z_STRVAL_P(argv[1]), "rb+", CHECKUID_CHECK_MODE_PARAM))) {
RETURN_FALSE;
}
convert_to_double(argv[2]);
convert_to_double(argv[3]);
convert_to_double(argv[4]);
@@ -2472,7 +2450,7 @@ PHP_FUNCTION(cpdf_import_jpeg)
/* }}} */
#if HAVE_LIBGD13
/* {{{ proto bool cpdf_place_inline_image(int pdfdoc, int gdimage, float x, float y, float angle, fload width, float height, int gsave [, int mode])
/* {{{ proto void cpdf_place_inline_image(int pdfdoc, int gdimage, float x, float y, float angle, fload width, float height, int gsave [, int mode])
Includes image */
PHP_FUNCTION(cpdf_place_inline_image)
{
@@ -2524,30 +2502,16 @@ PHP_FUNCTION(cpdf_place_inline_image)
}
count = 3 * im->sx * im->sy;
buffer = (unsigned char *) safe_emalloc(3 * im->sx, im->sy, 0);
if(NULL == (buffer = (unsigned char *) emalloc(count)))
RETURN_FALSE;
ptr = buffer;
for(i=0; i<im->sy; i++) {
for(j=0; j<im->sx; j++) {
#if HAVE_LIBGD20
if(gdImageTrueColor(im)) {
if (im->tpixels && gdImageBoundsSafe(im, j, i)) {
color = gdImageTrueColorPixel(im, j, i);
*ptr++ = (color >> 16) & 0xFF;
*ptr++ = (color >> 8) & 0xFF;
*ptr++ = color & 0xFF;
}
} else {
#endif
if (im->pixels && gdImageBoundsSafe(im, j, i)) {
color = im->pixels[i][j];
*ptr++ = im->red[color];
*ptr++ = im->green[color];
*ptr++ = im->blue[color];
}
#if HAVE_LIBGD20
}
#endif
color = im->pixels[i][j];
*ptr++ = im->red[color];
*ptr++ = im->green[color];
*ptr++ = im->blue[color];
}
}
@@ -2578,7 +2542,7 @@ PHP_FUNCTION(cpdf_place_inline_image)
/* }}} */
#endif
/* {{{ proto bool cpdf_add_annotation(int pdfdoc, float xll, float yll, float xur, float xur, string title, string text [, int mode])
/* {{{ proto void cpdf_add_annotation(int pdfdoc, float xll, float yll, float xur, float xur, string title, string text [, int mode])
Sets annotation */
PHP_FUNCTION(cpdf_add_annotation)
{
+3 -1
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -29,6 +29,8 @@
#undef T
#endif
#include <cpdflib.h>
extern zend_module_entry cpdf_module_entry;
#define cpdf_module_ptr &cpdf_module_entry
+19 -18
View File
@@ -7,26 +7,27 @@ PHP_ARG_WITH(crack, for CRACKlib support,
if test "$PHP_CRACK" != "no"; then
for i in $PHP_CRACK/lib $PHP_CRACK/cracklib /usr/local/lib /usr/lib; do
test -f $i/libcrack.$SHLIB_SUFFIX_NAME -o -f $i/libcrack.a && CRACK_LIBDIR=$i && break
done
for i in /usr/local/lib /usr/lib $PHP_CRACK/lib $PHP_CRACK/cracklib; do
test -f $i/libcrack.$SHLIB_SUFFIX_NAME -o -f $i/libcrack.a && CRACK_LIBDIR=$i
done
if test -z "$CRACK_LIBDIR"; then
AC_MSG_ERROR(Cannot find the cracklib library file)
fi
for i in $PHP_CRACK/include $PHP_CRACK/cracklib /usr/local/include /usr/include; do
test -f $i/packer.h && CRACK_INCLUDEDIR=$i && break
done
for i in /usr/local/include /usr/include $PHP_CRACK/include $PHP_CRACK/cracklib; do
test -f $i/packer.h && CRACK_INCLUDEDIR=$i
done
if test -z "$CRACK_INCLUDEDIR"; then
AC_MSG_ERROR(Cannot find a cracklib header file)
fi
if test -z "$CRACK_LIBDIR"; then
AC_MSG_ERROR(Cannot find the cracklib library file)
fi
PHP_ADD_INCLUDE($CRACK_INCLUDEDIR)
PHP_ADD_LIBRARY_WITH_PATH(crack, $CRACK_LIBDIR, CRACK_SHARED_LIBADD)
if test -z "$CRACK_INCLUDEDIR"; then
AC_MSG_ERROR(Cannot find a cracklib header file)
fi
PHP_NEW_EXTENSION(crack, crack.c, $ext_shared)
PHP_SUBST(CRACK_SHARED_LIBADD)
AC_DEFINE(HAVE_CRACK, 1, [ ])
PHP_ADD_INCLUDE($CRACK_INCLUDEDIR)
PHP_ADD_LIBRARY_WITH_PATH(crack, $CRACK_LIBDIR, CRACK_SHARED_LIBADD)
PHP_NEW_EXTENSION(crack, crack.c, $ext_shared)
PHP_SUBST(CRACK_SHARED_LIBADD)
AC_DEFINE(HAVE_CRACK, 1, [ ])
fi
+9 -20
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -29,9 +29,6 @@
#include <packer.h>
extern char * FascistLook(PWDICT *pwp, char *instring);
extern int PWClose(PWDICT *pwp);
ZEND_DECLARE_MODULE_GLOBALS(crack)
/* True global resources - no need for thread safety here */
@@ -72,16 +69,11 @@ long _crack_open_dict(char *dictpath TSRMLS_DC)
long resource;
if (CRACKG(current_id) != -1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can not use more than one open dictionary with this implementation of libcrack");
zend_error(E_WARNING, "Can not use more than one open dictionary with this implementation of libcrack");
return -1;
}
if ((PG(safe_mode) && (!php_checkuid(dictpath, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(dictpath TSRMLS_CC)) {
return -1;
}
if (NULL == (pwdict = PWOpen(dictpath, "r"))) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open a crack dictionary");
zend_error(E_WARNING, "Unable to open a crack dictionary");
return -1;
}
@@ -148,7 +140,7 @@ ZEND_MODULE_INFO_D(crack)
DISPLAY_INI_ENTRIES();
}
/* {{{ proto resource crack_opendict(string dictionary)
/* {{{ proto string crack_opendict(string dictionary)
Opens a new cracklib dictionary */
ZEND_FUNCTION(crack_opendict)
{
@@ -164,12 +156,12 @@ ZEND_FUNCTION(crack_opendict)
if (-1 == (resource = _crack_open_dict(Z_STRVAL_PP(dictpath) TSRMLS_CC))) {
RETURN_FALSE;
}
RETURN_RESOURCE(resource);
}
/* }}} */
/* {{{ proto bool crack_closedict([resource dictionary])
/* {{{ proto string crack_closedict([int link_identifier])
Closes an open cracklib dictionary */
ZEND_FUNCTION(crack_closedict)
{
@@ -192,10 +184,6 @@ ZEND_FUNCTION(crack_closedict)
break;
}
if (id < 1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE(pwdict, PWDICT *, dictionary, id, "cracklib dictionary", le_crack);
if (CRACKG(current_id) == id) {
CRACKG(current_id) = -1;
@@ -206,7 +194,7 @@ ZEND_FUNCTION(crack_closedict)
}
/* }}} */
/* {{{ proto bool crack_check([resource dictionary,] string password)
/* {{{ proto string crack_check([int dictionary,] string password)
Performs an obscure check with the given password */
ZEND_FUNCTION(crack_check)
{
@@ -230,6 +218,7 @@ ZEND_FUNCTION(crack_check)
if (zend_get_parameters_ex(2, &dictionary, &password) == FAILURE) {
RETURN_FALSE;
}
id = -1;
break;
default:
WRONG_PARAM_COUNT;
@@ -267,7 +256,7 @@ ZEND_FUNCTION(crack_getlastmessage)
}
if (NULL == CRACKG(last_message)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No obscure checks in this session");
zend_error(E_WARNING, "No obscure checks in this session");
RETURN_FALSE;
}
+3 -9
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -97,13 +97,7 @@ PHP_MINFO_FUNCTION(ctype)
return; \
switch (Z_TYPE_P(c)) { \
case IS_LONG: \
if (Z_LVAL_P(c) <= 255 && Z_LVAL_P(c) >= 0) { \
RETURN_BOOL(iswhat(Z_LVAL_P(c))); \
} else if (Z_LVAL_P(c) >= -128 && Z_LVAL_P(c) < 0) { \
RETURN_BOOL(iswhat(Z_LVAL_P(c) + 256)); \
} \
SEPARATE_ZVAL(&c); \
convert_to_string(c); \
RETURN_BOOL(iswhat(Z_LVAL_P(c))); \
case IS_STRING: \
{ \
char *p; \
@@ -111,7 +105,7 @@ PHP_MINFO_FUNCTION(ctype)
p=Z_STRVAL_P(c); \
len = Z_STRLEN_P(c); \
for(n=0;n<len;n++) { \
if(!iswhat((int)*(unsigned char *)(p++))) RETURN_FALSE; \
if(!iswhat(*p++)) RETURN_FALSE; \
} \
RETURN_TRUE; \
} \
+1 -1
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
-24
View File
@@ -1,24 +0,0 @@
--TEST--
Bug #25745 (ctype functions fail with non-ascii characters)
--FILE--
<?php
$funcs = array(
"ctype_alnum", "ctype_alpha", "ctype_cntrl", "ctype_digit",
"ctype_graph", "ctype_lower", "ctype_print", "ctype_punct",
"ctype_space", "ctype_upper", "ctype_xdigit"
);
foreach ($funcs as $ctype_func) {
for ($i = 0; $i < 256; $i++) {
$a = $ctype_func($i);
$b = $ctype_func(chr($i));
if ($a != $b) {
echo "broken... $ctype_func($i) = $a, $ctype_func(chr($i)) = $b\n";
exit;
}
}
}
echo "ok\n";
?>
--EXPECT--
ok
-1
View File
@@ -18,7 +18,6 @@ if test "$PHP_CURL" != "no"; then
if test -r $i/include/curl/easy.h; then
CURL_DIR=$i
AC_MSG_RESULT(found in $i)
break
fi
done
fi
+81 -218
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -22,10 +22,6 @@
#include "config.h"
#endif
#ifdef PHP_WIN32
#include <winsock2.h>
#endif
#include "php.h"
#if HAVE_CURL
@@ -34,17 +30,13 @@
#include <string.h>
#ifdef PHP_WIN32
#include <winsock.h>
#include <sys/types.h>
#endif
#include <curl/curl.h>
#include <curl/easy.h>
/* As of curl 7.11.1 this is no longer defined inside curl.h */
#ifndef HttpPost
#define HttpPost curl_httppost
#endif
#define SMART_STR_PREALLOC 4096
#include "ext/standard/php_smart_str.h"
@@ -141,9 +133,7 @@ PHP_MINIT_FUNCTION(curl)
REGISTER_CURL_CONSTANT(CURLOPT_FOLLOWLOCATION);
REGISTER_CURL_CONSTANT(CURLOPT_FTPASCII);
REGISTER_CURL_CONSTANT(CURLOPT_PUT);
#if CURLOPT_MUTE != 0
REGISTER_CURL_CONSTANT(CURLOPT_MUTE);
#endif
REGISTER_CURL_CONSTANT(CURLOPT_USERPWD);
REGISTER_CURL_CONSTANT(CURLOPT_PROXYUSERPWD);
REGISTER_CURL_CONSTANT(CURLOPT_RANGE);
@@ -201,28 +191,7 @@ PHP_MINIT_FUNCTION(curl)
REGISTER_CURL_CONSTANT(CURLOPT_SSLENGINE);
REGISTER_CURL_CONSTANT(CURLOPT_SSLENGINE_DEFAULT);
REGISTER_CURL_CONSTANT(CURLOPT_CRLF);
REGISTER_CURL_CONSTANT(CURL_TIMECOND_IFMODSINCE);
REGISTER_CURL_CONSTANT(CURL_TIMECOND_IFUNMODSINCE);
REGISTER_CURL_CONSTANT(CURL_TIMECOND_LASTMOD);
#if LIBCURL_VERSION_NUM >= 0x070a00
REGISTER_CURL_CONSTANT(CURLOPT_ENCODING);
#endif
#if LIBCURL_VERSION_NUM > 0x070a05 /* CURLOPT_HTTPAUTH is available since curl 7.10.6 */
REGISTER_CURL_CONSTANT(CURLOPT_HTTPAUTH);
/* http authentication options */
REGISTER_CURL_CONSTANT(CURLAUTH_BASIC);
REGISTER_CURL_CONSTANT(CURLAUTH_DIGEST);
REGISTER_CURL_CONSTANT(CURLAUTH_GSSNEGOTIATE);
REGISTER_CURL_CONSTANT(CURLAUTH_NTLM);
REGISTER_CURL_CONSTANT(CURLAUTH_ANY);
REGISTER_CURL_CONSTANT(CURLAUTH_ANYSAFE);
#endif
#if LIBCURL_VERSION_NUM > 0x070a06 /* CURLOPT_PROXYAUTH is available since curl 7.10.7 */
REGISTER_CURL_CONSTANT(CURLOPT_PROXYAUTH);
#endif
/* Constants effecting the way CURLOPT_CLOSEPOLICY works */
REGISTER_CURL_CONSTANT(CURLCLOSEPOLICY_LEAST_RECENTLY_USED);
REGISTER_CURL_CONSTANT(CURLCLOSEPOLICY_LEAST_TRAFFIC);
@@ -305,35 +274,6 @@ PHP_MINIT_FUNCTION(curl)
REGISTER_CURL_CONSTANT(CURLE_TELNET_OPTION_SYNTAX);
REGISTER_CURL_CONSTANT(CURLE_OBSOLETE);
REGISTER_CURL_CONSTANT(CURLE_SSL_PEER_CERTIFICATE);
REGISTER_CURL_CONSTANT(CURLE_GOT_NOTHING);
REGISTER_CURL_CONSTANT(CURLE_SSL_ENGINE_NOTFOUND);
REGISTER_CURL_CONSTANT(CURLE_SSL_ENGINE_SETFAILED);
REGISTER_CURL_CONSTANT(CURLE_SEND_ERROR);
REGISTER_CURL_CONSTANT(CURLE_RECV_ERROR);
#ifdef CURLE_SHARE_IN_USE
REGISTER_CURL_CONSTANT(CURLE_SHARE_IN_USE);
#endif
#ifdef CURLE_SSL_CERTPROBLEM
REGISTER_CURL_CONSTANT(CURLE_SSL_CERTPROBLEM);
#endif
#ifdef CURLE_SSL_CIPHER
REGISTER_CURL_CONSTANT(CURLE_SSL_CIPHER);
#endif
#ifdef CURLE_SSL_CACERT
REGISTER_CURL_CONSTANT(CURLE_SSL_CACERT);
#endif
#ifdef CURLE_BAD_CONTENT_ENCODING
REGISTER_CURL_CONSTANT(CURLE_BAD_CONTENT_ENCODING);
#endif
#ifdef CURLE_LDAP_INVALID_URL
REGISTER_CURL_CONSTANT(CURLE_LDAP_INVALID_URL);
#endif
#ifdef CURLE_FILESIZE_EXCEEDED
REGISTER_CURL_CONSTANT(CURLE_FILESIZE_EXCEEDED);
#endif
#ifdef CURLE_FTP_SSL_FAILED
REGISTER_CURL_CONSTANT(CURLE_FTP_SSL_FAILED);
#endif
REGISTER_CURL_CONSTANT(CURL_NETRC_OPTIONAL);
REGISTER_CURL_CONSTANT(CURL_NETRC_IGNORED);
@@ -395,7 +335,7 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
switch (t->method) {
case PHP_CURL_STDOUT:
PHPWRITE(data, length);
PUTS(data);
break;
case PHP_CURL_FILE:
return fwrite(data, size, nmemb, t->fp);
@@ -406,6 +346,7 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
zval *argv[2];
zval *retval;
int error;
TSRMLS_FETCH();
MAKE_STD_ZVAL(argv[0]);
MAKE_STD_ZVAL(argv[1]);
@@ -425,9 +366,6 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
length = -1;
}
else {
if (Z_TYPE_P(retval) != IS_LONG) {
convert_to_long_ex(&retval);
}
length = Z_LVAL_P(retval);
}
@@ -453,13 +391,12 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
switch (t->method) {
case PHP_CURL_DIRECT:
if (t->fp) {
length = fread(data, size, nmemb, t->fp);
}
length = fread(data, size, nmemb, t->fp);
break;
case PHP_CURL_USER: {
zval *argv[3];
zval *retval;
int length;
int error;
TSRMLS_FETCH();
@@ -481,9 +418,11 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
if (error == FAILURE) {
php_error(E_WARNING, "%s(): Cannot call the CURLOPT_READFUNCTION",
get_active_function_name(TSRMLS_C));
} else if (Z_TYPE_P(retval) == IS_STRING) {
length = MIN(size * nmemb, Z_STRLEN_P(retval));
memcpy(data, Z_STRVAL_P(retval), length);
length = -1;
}
else {
memcpy(data, Z_STRVAL_P(retval), size * nmemb);
length = Z_STRLEN_P(retval);
}
zval_ptr_dtor(&argv[0]);
@@ -514,7 +453,7 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
if (ch->handlers->write->method == PHP_CURL_RETURN)
smart_str_appendl(&ch->handlers->write->buf, data, (int) length);
else
PHPWRITE(data, length);
PUTS(data);
break;
case PHP_CURL_FILE:
return fwrite(data, size, nmemb, t->fp);
@@ -542,9 +481,6 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
length = -1;
}
else {
if (Z_TYPE_P(retval) != IS_LONG) {
convert_to_long_ex(&retval);
}
length = Z_LVAL_P(retval);
}
zval_ptr_dtor(&argv[0]);
@@ -552,18 +488,13 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
zval_ptr_dtor(&retval);
break;
}
case PHP_CURL_IGNORE:
return length;
default:
return -1;
}
return length;
}
/* }}} */
#if CURLOPT_PASSWDFUNCTION != 0
/* {{{ curl_passwd
*/
static size_t curl_passwd(void *ctx, char *prompt, char *buf, int buflen)
@@ -573,7 +504,7 @@ static size_t curl_passwd(void *ctx, char *prompt, char *buf, int buflen)
zval *argv[3];
zval *retval = NULL;
int error;
int ret = -1;
int ret = 0;
TSRMLS_FETCH();
MAKE_STD_ZVAL(argv[0]);
@@ -591,15 +522,17 @@ static size_t curl_passwd(void *ctx, char *prompt, char *buf, int buflen)
retval, 2, argv TSRMLS_CC);
if (error == FAILURE) {
php_error(E_WARNING, "%s(): Couldn't call the CURLOPT_PASSWDFUNCTION", get_active_function_name(TSRMLS_C));
} else if (Z_TYPE_P(retval) == IS_STRING) {
ret = -1;
}
else {
if (Z_STRLEN_P(retval) > buflen) {
php_error(E_WARNING, "%s(): Returned password is too long for libcurl to handle",
get_active_function_name(TSRMLS_C));
} else {
strlcpy(buf, Z_STRVAL_P(retval), Z_STRLEN_P(retval));
ret = -1;
}
else {
strlcpy(buf, Z_STRVAL_P(retval), buflen);
}
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "User handler '%s' did not return a string.", Z_STRVAL_P(func));
}
zval_ptr_dtor(&argv[0]);
@@ -610,7 +543,6 @@ static size_t curl_passwd(void *ctx, char *prompt, char *buf, int buflen)
return ret;
}
/* }}} */
#endif
/* {{{ curl_free_string
*/
@@ -637,7 +569,7 @@ static void curl_free_slist(void **slist)
/* }}} */
/* {{{ proto string curl_version(void)
/* {{{ proto array curl_version(void)
Return cURL version information. */
PHP_FUNCTION(curl_version)
{
@@ -695,8 +627,6 @@ PHP_FUNCTION(curl_init)
ch->handlers->read->method = PHP_CURL_DIRECT;
ch->handlers->write_header->method = PHP_CURL_IGNORE;
ch->uses = 0;
curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS, 1);
curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0);
curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str);
@@ -708,7 +638,6 @@ PHP_FUNCTION(curl_init)
curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch);
curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1);
curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120);
curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */
if (argc > 0) {
char *urlcopy;
@@ -757,9 +686,7 @@ PHP_FUNCTION(curl_setopt)
case CURLOPT_NETRC:
case CURLOPT_FOLLOWLOCATION:
case CURLOPT_PUT:
#if CURLOPT_MUTE != 0
case CURLOPT_MUTE:
#endif
case CURLOPT_MUTE:
case CURLOPT_TIMEOUT:
case CURLOPT_FTP_USE_EPSV:
case CURLOPT_LOW_SPEED_LIMIT:
@@ -783,12 +710,6 @@ PHP_FUNCTION(curl_setopt)
case CURLOPT_HTTPGET:
case CURLOPT_HTTP_VERSION:
case CURLOPT_CRLF:
#if LIBCURL_VERSION_NUM > 0x070a05 /* CURLOPT_HTTPAUTH is available since curl 7.10.6 */
case CURLOPT_HTTPAUTH:
#endif
#if LIBCURL_VERSION_NUM > 0x070a06 /* CURLOPT_PROXYAUTH is available since curl 7.10.7 */
case CURLOPT_PROXYAUTH:
#endif
convert_to_long_ex(zvalue);
error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue));
break;
@@ -801,20 +722,20 @@ PHP_FUNCTION(curl_setopt)
case CURLOPT_USERAGENT:
case CURLOPT_FTPPORT:
case CURLOPT_COOKIE:
case CURLOPT_COOKIEFILE:
case CURLOPT_REFERER:
case CURLOPT_INTERFACE:
case CURLOPT_KRB4LEVEL:
case CURLOPT_RANDOM_FILE:
case CURLOPT_EGDSOCKET:
case CURLOPT_CAINFO:
case CURLOPT_CAPATH:
case CURLOPT_COOKIEJAR:
case CURLOPT_SSL_CIPHER_LIST:
case CURLOPT_SSLKEY:
case CURLOPT_SSLKEYTYPE:
case CURLOPT_SSLKEYPASSWD:
case CURLOPT_SSLKEYPASSWD:
case CURLOPT_SSLENGINE:
#if LIBCURL_VERSION_NUM >= 0x070a00
case CURLOPT_ENCODING:
#endif
case CURLOPT_SSLENGINE_DEFAULT: {
char *copystr = NULL;
@@ -875,9 +796,7 @@ PHP_FUNCTION(curl_setopt)
if (Z_LVAL_PP(zvalue)) {
ch->handlers->write->method = PHP_CURL_RETURN;
} else {
ch->handlers->write->method = PHP_CURL_STDOUT;
}
}
break;
case CURLOPT_BINARYTRANSFER:
convert_to_long_ex(zvalue);
@@ -910,7 +829,6 @@ PHP_FUNCTION(curl_setopt)
ch->handlers->write_header->func = *zvalue;
ch->handlers->write_header->method = PHP_CURL_USER;
break;
#if CURLOPT_PASSWDFUNCTION != 0
case CURLOPT_PASSWDFUNCTION:
if (ch->handlers->passwd) {
zval_ptr_dtor(&ch->handlers->passwd);
@@ -920,7 +838,6 @@ PHP_FUNCTION(curl_setopt)
error = curl_easy_setopt(ch->cp, CURLOPT_PASSWDFUNCTION, curl_passwd);
error = curl_easy_setopt(ch->cp, CURLOPT_PASSWDDATA, (void *) ch);
break;
#endif
case CURLOPT_POSTFIELDS:
if (Z_TYPE_PP(zvalue) == IS_ARRAY || Z_TYPE_PP(zvalue) == IS_OBJECT) {
zval **current;
@@ -963,7 +880,7 @@ PHP_FUNCTION(curl_setopt)
error = curl_formadd(&first, &last,
CURLFORM_COPYNAME, string_key,
CURLFORM_NAMELENGTH, string_key_len - 1,
CURLFORM_COPYCONTENTS, postval,
CURLFORM_PTRCONTENTS, postval,
CURLFORM_CONTENTSLENGTH, Z_STRLEN_PP(current),
CURLFORM_END);
}
@@ -1026,28 +943,6 @@ PHP_FUNCTION(curl_setopt)
error = curl_easy_setopt(ch->cp, option, slist);
break;
}
/* the following options deal with files, therefor safe_mode & open_basedir checks
* are required.
*/
case CURLOPT_COOKIEJAR:
case CURLOPT_SSLCERT:
case CURLOPT_RANDOM_FILE:
case CURLOPT_COOKIEFILE: {
char *copystr = NULL;
convert_to_string_ex(zvalue);
if (php_check_open_basedir(Z_STRVAL_PP(zvalue) TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(Z_STRVAL_PP(zvalue), "rb+", CHECKUID_CHECK_MODE_PARAM))) {
RETURN_FALSE;
}
copystr = estrndup(Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue));
error = curl_easy_setopt(ch->cp, option, copystr);
zend_llist_add_element(&ch->to_free.str, &copystr);
break;
}
}
@@ -1097,8 +992,7 @@ PHP_FUNCTION(curl_exec)
error = curl_easy_perform(ch->cp);
SAVE_CURL_ERROR(ch, error);
/* CURLE_PARTIAL_FILE is returned by HEAD requests */
if (error != CURLE_OK && error != CURLE_PARTIAL_FILE) {
if (error != CURLE_OK) {
if (ch->handlers->write->buf.len > 0) {
smart_str_free(&ch->handlers->write->buf);
}
@@ -1111,14 +1005,14 @@ PHP_FUNCTION(curl_exec)
if (ch->handlers->write->method == PHP_CURL_RETURN && ch->handlers->write->buf.len > 0) {
if (ch->handlers->write->type != PHP_CURL_BINARY)
smart_str_0(&ch->handlers->write->buf);
RETURN_STRINGL(ch->handlers->write->buf.c, ch->handlers->write->buf.len, 0);
RETURN_STRINGL(ch->handlers->write->buf.c, ch->handlers->write->buf.len, 1);
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto mixed curl_getinfo(resource ch, int opt)
/* {{{ proto string curl_getinfo(resource ch, int opt)
Get information regarding a specific transfer */
PHP_FUNCTION(curl_getinfo)
{
@@ -1141,80 +1035,55 @@ PHP_FUNCTION(curl_getinfo)
array_init(return_value);
if (curl_easy_getinfo(ch->cp, CURLINFO_EFFECTIVE_URL, &s_code) == CURLE_OK) {
CAAS("url", s_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_TYPE, &s_code) == CURLE_OK) {
if (s_code != NULL) {
CAAS("content_type", s_code);
}
}
if (curl_easy_getinfo(ch->cp, CURLINFO_HTTP_CODE, &l_code) == CURLE_OK) {
CAAL("http_code", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_HEADER_SIZE, &l_code) == CURLE_OK) {
CAAL("header_size", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_REQUEST_SIZE, &l_code) == CURLE_OK) {
CAAL("request_size", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_FILETIME, &l_code) == CURLE_OK) {
CAAL("filetime", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SSL_VERIFYRESULT, &l_code) == CURLE_OK) {
CAAL("ssl_verify_result", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_COUNT, &l_code) == CURLE_OK) {
CAAL("redirect_count", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_TOTAL_TIME, &d_code) == CURLE_OK) {
CAAD("total_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_NAMELOOKUP_TIME, &d_code) == CURLE_OK) {
CAAD("namelookup_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_CONNECT_TIME, &d_code) == CURLE_OK) {
CAAD("connect_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_PRETRANSFER_TIME, &d_code) == CURLE_OK) {
CAAD("pretransfer_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SIZE_UPLOAD, &d_code) == CURLE_OK) {
CAAD("size_upload", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SIZE_DOWNLOAD, &d_code) == CURLE_OK) {
CAAD("size_download", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SPEED_DOWNLOAD, &d_code) == CURLE_OK) {
CAAD("speed_download", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SPEED_UPLOAD, &d_code) == CURLE_OK) {
CAAD("speed_upload", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d_code) == CURLE_OK) {
CAAD("download_content_length", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_LENGTH_UPLOAD, &d_code) == CURLE_OK) {
CAAD("upload_content_length", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_STARTTRANSFER_TIME, &d_code) == CURLE_OK) {
CAAD("starttransfer_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_TIME, &d_code) == CURLE_OK) {
CAAD("redirect_time", d_code);
}
curl_easy_getinfo(ch->cp, CURLINFO_EFFECTIVE_URL, &s_code);
CAAS("url", s_code);
curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_TYPE, &s_code);
CAAS("content_type", s_code);
curl_easy_getinfo(ch->cp, CURLINFO_HTTP_CODE, &l_code);
CAAL("http_code", l_code);
curl_easy_getinfo(ch->cp, CURLINFO_HEADER_SIZE, &l_code);
CAAL("header_size", l_code);
curl_easy_getinfo(ch->cp, CURLINFO_REQUEST_SIZE, &l_code);
CAAL("request_size", l_code);
curl_easy_getinfo(ch->cp, CURLINFO_FILETIME, &l_code);
CAAL("filetime", l_code);
curl_easy_getinfo(ch->cp, CURLINFO_SSL_VERIFYRESULT, &l_code);
CAAL("ssl_verify_result", l_code);
curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_COUNT, &l_code);
CAAL("redirect_count", l_code);
curl_easy_getinfo(ch->cp, CURLINFO_TOTAL_TIME, &d_code);
CAAD("total_time", d_code);
curl_easy_getinfo(ch->cp, CURLINFO_NAMELOOKUP_TIME, &d_code);
CAAD("namelookup_time", d_code);
curl_easy_getinfo(ch->cp, CURLINFO_CONNECT_TIME, &d_code);
CAAD("connect_time", d_code);
curl_easy_getinfo(ch->cp, CURLINFO_PRETRANSFER_TIME, &d_code);
CAAD("pretransfer_time", d_code);
curl_easy_getinfo(ch->cp, CURLINFO_SIZE_UPLOAD, &d_code);
CAAD("size_upload", d_code);
curl_easy_getinfo(ch->cp, CURLINFO_SIZE_DOWNLOAD, &d_code);
CAAD("size_download", d_code);
curl_easy_getinfo(ch->cp, CURLINFO_SPEED_DOWNLOAD, &d_code);
CAAD("speed_download", d_code);
curl_easy_getinfo(ch->cp, CURLINFO_SPEED_UPLOAD, &d_code);
CAAD("speed_upload", d_code);
curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d_code);
CAAD("download_content_length", d_code);
curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_LENGTH_UPLOAD, &d_code);
CAAD("upload_content_length", d_code);
curl_easy_getinfo(ch->cp, CURLINFO_STARTTRANSFER_TIME, &d_code);
CAAD("starttransfer_time", d_code);
curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_TIME, &d_code);
CAAD("redirect_time", d_code);
} else {
option = Z_LVAL_PP(zoption);
switch (option) {
case CURLINFO_EFFECTIVE_URL:
case CURLINFO_CONTENT_TYPE: {
char *s_code = NULL;
char *s_code;
if (curl_easy_getinfo(ch->cp, option, &s_code) == CURLE_OK && s_code) {
RETURN_STRING(s_code, 1);
} else {
RETURN_FALSE;
}
curl_easy_getinfo(ch->cp, option, &s_code);
RETURN_STRING(s_code, 1);
break;
}
@@ -1224,13 +1093,10 @@ PHP_FUNCTION(curl_getinfo)
case CURLINFO_FILETIME:
case CURLINFO_SSL_VERIFYRESULT:
case CURLINFO_REDIRECT_COUNT: {
long code = 0;
long code;
if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) {
RETURN_LONG(code);
} else {
RETURN_FALSE;
}
curl_easy_getinfo(ch->cp, option, &code);
RETURN_LONG(code);
break;
}
@@ -1246,13 +1112,10 @@ PHP_FUNCTION(curl_getinfo)
case CURLINFO_CONTENT_LENGTH_UPLOAD:
case CURLINFO_STARTTRANSFER_TIME:
case CURLINFO_REDIRECT_TIME: {
double code = 0.0;
double code;
if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) {
RETURN_DOUBLE(code);
} else {
RETURN_FALSE;
}
curl_easy_getinfo(ch->cp, option, &code);
RETURN_DOUBLE(code);
break;
}
+2 -2
View File
@@ -113,7 +113,7 @@ BSC32=bscmake.exe
LINK32=link.exe
# ADD BASE LINK32 php4ts_debug.lib libcurl.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 /incremental:yes /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /out:"..\..\Debug_TS/php_curl.dll" /libpath:"..\..\Debug_TS"
# SUBTRACT BASE LINK32 /pdb:none
# ADD LINK32 php4ts_debug.lib libcurl.lib ssleay32.lib libeay32.lib msvcrt.lib ws2_32.lib winmm.lib zlib.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 wsock32.lib /nologo /dll /incremental:yes /debug /machine:I386 /nodefaultlib:"MSVCRTD" /out:"..\..\Debug_TS/php_curl.dll" /libpath:"..\..\Debug_TS" /libpath:"..\..\..\php_build\curl\lib"
# ADD LINK32 php4ts_debug.lib libcurl.lib ssleay32.lib libeay32.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 wsock32.lib /nologo /dll /incremental:yes /debug /machine:I386 /nodefaultlib:"MSVCRTD" /out:"..\..\Debug_TS/php_curl.dll" /libpath:"..\..\Debug_TS" /libpath:"..\..\..\php_build\curl\lib"
# SUBTRACT LINK32 /pdb:none /nodefaultlib
!ELSEIF "$(CFG)" == "curl - Win32 Release_TS_SSL"
@@ -142,7 +142,7 @@ BSC32=bscmake.exe
LINK32=link.exe
# ADD BASE LINK32 php4ts.lib libcurl.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /nodefaultlib:"msvcrt.lib" /out:"..\..\Release_TS/php_curl.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline"
# SUBTRACT BASE LINK32 /pdb:none
# ADD LINK32 php4ts.lib libcurl.lib ssleay32.lib libeay32.lib msvcrt.lib ws2_32.lib winmm.lib zlib.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 wsock32.lib /nologo /dll /machine:I386 /nodefaultlib:"MSVCRT" /out:"..\..\Release_TS/php_curl.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"..\..\..\php_build\curl\lib"
# ADD LINK32 php4ts.lib libcurl.lib ssleay32.lib libeay32.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 wsock32.lib /nologo /dll /machine:I386 /nodefaultlib:"MSVCRT" /out:"..\..\Release_TS/php_curl.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"..\..\..\php_build\curl\lib"
# SUBTRACT LINK32 /pdb:none
!ENDIF
+3 -3
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -30,7 +30,7 @@
#include "php.h"
#include "php_memory_streams.h"
#if HAVE_CURL && defined(PHP_CURL_URL_WRAPPERS)
#if HAVE_CURL
#include <stdio.h>
#include <string.h>
@@ -307,7 +307,7 @@ PHPAPI php_stream *php_curl_stream_opener(php_stream_wrapper *wrapper, char *fil
curl_easy_setopt(curlstream->curl, CURLOPT_PROGRESSDATA, stream);
curl_easy_setopt(curlstream->curl, CURLOPT_NOPROGRESS, 0);
curl_easy_setopt(curlstream->curl, CURLOPT_USERAGENT, FG(user_agent) ? FG(user_agent) : "PHP/" PHP_VERSION);
curl_easy_setopt(curlstream->curl, CURLOPT_USERAGENT, "PHP/" PHP_VERSION);
/* TODO: read cookies and options from context */
+1 -1
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
+18 -51
View File
@@ -3,80 +3,47 @@ dnl $Id$
dnl
PHP_ARG_WITH(cyrus, for cyrus imap support,
[ --with-cyrus[=DIR] Include Cyrus IMAP support])
[ --with-cyrus Include Cyrus IMAP support])
if test "$PHP_CYRUS" != "no"; then
found_cyrus=no
found_sasl=no
found_openssl=no
dnl
dnl Cyrus
dnl
for i in $PHP_CYRUS /usr/local /usr; do
for i in /usr /usr/local $PHP_CYRUS; do
if test -r $i/include/cyrus/imclient.h && test "$found_cyrus" = "no"; then
PHP_ADD_INCLUDE($i/include)
PHP_ADD_LIBRARY_WITH_PATH(cyrus, $i/lib, CYRUS_SHARED_LIBADD)
found_cyrus=yes
CYRUS_INCPATH=$i/include
break 2
fi
if test -r $i/include/sasl.h && test "$found_sasl" = "no"; then
PHP_ADD_INCLUDE($i/include)
PHP_ADD_LIBRARY_WITH_PATH(sasl, $i/lib, CYRUS_SHARED_LIBADD)
found_sasl=yes
elif test -r $i/include/sasl/sasl.h && test "$found_sasl" = "no"; then
PHP_ADD_INCLUDE($i/include/sasl)
PHP_ADD_LIBRARY_WITH_PATH(sasl, $i/lib, CYRUS_SHARED_LIBADD)
found_sasl=yes
fi
if test -r $i/include/openssl/ssl.h && test "$found_openssl" = "no" && test "$PHP_OPENSSL" = "no"; then
PHP_ADD_LIBRARY_WITH_PATH(ssl, $i/lib, CYRUS_SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH(crypto, $i/lib, CYRUS_SHARED_LIBADD)
found_openssl=yes
fi
done
dnl Check that imclient_connect() accepts 4 args
old_CPPFLAGS=$CPPFLAGS
CPPFLAGS=-I$CYRUS_INCPATH
AC_TRY_COMPILE([#include <stdio.h>
#include <cyrus/imclient.h>], [imclient_connect(0,0,0,0)], [], [
AC_MSG_ERROR(cyrus-imap version 2.0.8 or greater required)
])
CPPFLAGS=$old_CPPFLAGS
if test "$found_cyrus" = "no"; then
AC_MSG_RESULT(not found)
AC_MSG_ERROR(Please Re-install the cyrus distribution)
fi
dnl
dnl sasl/sasl2
dnl
for i in $PHP_CYRUS /usr/local /usr; do
if test -r $i/include/sasl.h && test "$found_sasl" = "no"; then
PHP_ADD_INCLUDE($i/include)
found_sasl=yes
elif test -r $i/include/sasl/sasl.h && test "$found_sasl" = "no"; then
PHP_ADD_INCLUDE($i/include/sasl)
found_sasl=yes
fi
if test "$found_sasl" = "yes"; then
if test -f $i/lib/libsasl2.a || test -f $i/lib/libsasl2.$SHLIB_SUFFIX_NAME; then
PHP_ADD_LIBRARY_WITH_PATH(sasl2, $i/lib, CYRUS_SHARED_LIBADD)
else
PHP_ADD_LIBRARY_WITH_PATH(sasl, $i/lib, CYRUS_SHARED_LIBADD)
fi
break 2
fi
done
if test "$found_sasl" = "no"; then
AC_MSG_RESULT(sasl not found)
AC_MSG_ERROR(Please Re-install the cyrus distribution)
fi
dnl
dnl OpenSSL
dnl
if test "$PHP_OPENSSL" = "no"; then
for i in $PHP_CYRUS /usr/local /usr; do
if test -r $i/include/openssl/ssl.h; then
PHP_ADD_LIBRARY_WITH_PATH(ssl, $i/lib, CYRUS_SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH(crypto, $i/lib, CYRUS_SHARED_LIBADD)
break 2
fi
done
fi
PHP_NEW_EXTENSION(cyrus, cyrus.c, $ext_shared)
PHP_SUBST(CYRUS_SHARED_LIBADD)
AC_DEFINE(HAVE_CYRUS,1,[ ])
+44 -44
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -53,7 +53,7 @@ zend_module_entry cyrus_module_entry = {
cyrus_functions,
PHP_MINIT(cyrus),
NULL,
NULL,
NULL,
NULL,
PHP_MINFO(cyrus),
NO_VERSION_YET,
@@ -71,7 +71,7 @@ static void cyrus_free(zend_rsrc_list_entry *rsrc)
if (conn->client)
imclient_close(conn->client);
if (conn->host)
if (conn->host)
efree(conn->host);
if (conn->port)
@@ -79,16 +79,16 @@ static void cyrus_free(zend_rsrc_list_entry *rsrc)
efree(conn);
}
PHP_MINIT_FUNCTION(cyrus)
{
le_cyrus = zend_register_list_destructors_ex(cyrus_free, NULL,
le_cyrus = zend_register_list_destructors_ex(cyrus_free, NULL,
le_cyrus_name, module_number);
REGISTER_LONG_CONSTANT("CYRUS_CONN_NONSYNCLITERAL",
REGISTER_LONG_CONSTANT("CYRUS_CONN_NONSYNCLITERAL",
IMCLIENT_CONN_NONSYNCLITERAL,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CYRUS_CONN_INITIALRESPONSE",
REGISTER_LONG_CONSTANT("CYRUS_CONN_INITIALRESPONSE",
IMCLIENT_CONN_INITIALRESPONSE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CYRUS_CALLBACK_NUMBERED", CALLBACK_NUMBERED,
@@ -108,7 +108,7 @@ PHP_MINFO_FUNCTION(cyrus)
extern void fatal(char *s, int exit)
{
php_error(E_ERROR, "%s", s);
php_error(E_ERROR, s);
}
/* {{{ proto resource cyrus_connect([ string host [, string port [, int flags]]])
@@ -125,7 +125,7 @@ PHP_FUNCTION(cyrus_connect)
int flags = 0;
int error;
int argc = ZEND_NUM_ARGS();
if (argc < 0 || argc > 3 ||
zend_get_parameters_ex(argc, &z_host, &z_port, &z_flags) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -169,7 +169,7 @@ PHP_FUNCTION(cyrus_connect)
case -1:
php_error(E_WARNING, "%s(): Invalid hostname: %s", get_active_function_name(TSRMLS_C), host);
RETURN_FALSE;
case -2:
php_error(E_WARNING, "%s(): Invalid port: %d", get_active_function_name(TSRMLS_C), port);
RETURN_FALSE;
@@ -181,14 +181,14 @@ PHP_FUNCTION(cyrus_connect)
/* }}} */
static void cyrus_capable_callback(struct imclient *client, void *rock,
static void cyrus_capable_callback(struct imclient *client, void *rock,
struct imclient_reply *reply)
{
char *token = NULL;
char *token_buf;
char *mechanism = rock;
/* We need to split the reply up by the whitespace */
token = php_strtok_r(reply->text, " ", &token_buf);
while (token != NULL) {
@@ -202,7 +202,7 @@ static void cyrus_capable_callback(struct imclient *client, void *rock,
}
/* {{{ proto void cyrus_authenticate( resource connection [, string mechlist [, string service [, string user [, int minssf [, int maxssf]]]]])
/* {{{ proto bool cyrus_authenticate( resource connection [, string mechlist [, string service [, string user [, int minssf [, int maxssf]]]]])
Authenticate agaings a Cyrus IMAP server */
PHP_FUNCTION(cyrus_authenticate)
{
@@ -235,26 +235,26 @@ PHP_FUNCTION(cyrus_authenticate)
else {
char tmp_mechlist[100];
int pos = 0;
/* NULL out the buffer, ensures it has a safe ending and allows us to
* test properly for the end of the buffer
*/
memset(tmp_mechlist, 0, sizeof tmp_mechlist);
/* We'll be calling the "CAPABILITY" command, which will give us a list
* of the types of authorization the server is capable of
* of the types of authorization the server is capable of
*/
imclient_addcallback(conn->client, "CAPABILITY", 0,
imclient_addcallback(conn->client, "CAPABILITY", 0,
cyrus_capable_callback, (void *) tmp_mechlist, 0);
imclient_send(conn->client, NULL, NULL, "CAPABILITY");
/* Grab the end of string position into pos */
while (tmp_mechlist[pos++] != 0)
while (tmp_mechlist[pos++] != 0)
;
/* Tack on PLAIN to whatever the auth string is */
memcpy(tmp_mechlist + pos, " PLAIN", 6);
/* Copy it onto the main buffer */
mechlist = estrndup(tmp_mechlist, pos + 6);
}
@@ -277,22 +277,22 @@ PHP_FUNCTION(cyrus_authenticate)
/* XXX: UGLY, but works, determines the username to use */
user = (char *) sapi_getenv("USER", 4);
if (! user) {
user = (char *) getenv("USER");
user = (char *) getenv("USER");
if (! user) {
user = (char *) sapi_getenv("LOGNAME", 7);
if (! user) {
user = (char *) sapi_getenv("LOGNAME", 7);
if (! user) {
user = (char *) getenv("LOGNAME");
if (! user) {
struct passwd *pwd = getpwuid(getuid());
if (! pwd) {
php_error(E_WARNING, "%s(): Couldn't determine user id", get_active_function_name(TSRMLS_C));
RETURN_FALSE;
}
user = estrdup(pwd->pw_name);
}
user = (char *) getenv("LOGNAME");
if (! user) {
struct passwd *pwd = getpwuid(getuid());
if (! pwd) {
php_error(E_WARNING, "%s(): Couldn't determine user id", get_active_function_name(TSRMLS_C));
RETURN_FALSE;
}
user = estrdup(pwd->pw_name);
}
}
}
}
}
@@ -314,7 +314,7 @@ PHP_FUNCTION(cyrus_authenticate)
maxssf = 1000;
}
imclient_authenticate(conn->client, mechlist, service,
imclient_authenticate(conn->client, mechlist, service,
user, minssf, maxssf);
efree(mechlist);
@@ -324,8 +324,8 @@ PHP_FUNCTION(cyrus_authenticate)
/* }}} */
static void cyrus_generic_callback(struct imclient *client,
void *rock,
static void cyrus_generic_callback(struct imclient *client,
void *rock,
struct imclient_reply *reply)
{
php_cyrus_callback *callback = rock;
@@ -356,7 +356,7 @@ static void cyrus_generic_callback(struct imclient *client,
argv[2] = &text;
argv[3] = &msgno;
if (call_user_function_ex(EG(function_table), NULL, callback->function,
if (call_user_function_ex(EG(function_table), NULL, callback->function,
&retval, 4, argv, 0, NULL TSRMLS_CC) == FAILURE) {
php_error(E_WARNING, "%s(): Couldn't call the %s handler",
get_active_function_name(TSRMLS_C), callback->trigger);
@@ -374,8 +374,8 @@ static void cyrus_generic_callback(struct imclient *client,
}
}
/* {{{ proto bool cyrus_bind( resource connection, array callbacks)
/* {{{ proto bool cyrus_bind( resource connection, array callbacks)
Bind callbacks to a Cyrus IMAP connection */
PHP_FUNCTION(cyrus_bind)
{
@@ -397,7 +397,7 @@ PHP_FUNCTION(cyrus_bind)
hash = HASH_OF(*z_callback);
if (! hash) {
php_error(E_WARNING,
php_error(E_WARNING,
"%s(): Second argument must be an array or object", get_active_function_name(TSRMLS_C));
RETURN_FALSE;
}
@@ -407,9 +407,9 @@ PHP_FUNCTION(cyrus_bind)
zend_hash_move_forward(hash)) {
SEPARATE_ZVAL(tmp);
zend_hash_get_current_key(hash, &string_key, &num_key, 0);
if (! string_key)
if (! string_key)
continue;
if (! strcasecmp(string_key, "trigger")) {
convert_to_string_ex(tmp);
callback.trigger = estrndup(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
@@ -436,7 +436,7 @@ PHP_FUNCTION(cyrus_bind)
callback.le = conn->id;
imclient_addcallback(conn->client, callback.trigger, callback.flags,
imclient_addcallback(conn->client, callback.trigger, callback.flags,
cyrus_generic_callback, (void **) &callback, 0);
RETURN_TRUE;
@@ -458,14 +458,14 @@ PHP_FUNCTION(cyrus_unbind)
ZEND_FETCH_RESOURCE(conn, php_cyrus *, z_conn, -1, le_cyrus_name, le_cyrus);
convert_to_string_ex(trigger_name);
imclient_addcallback(conn->client, Z_STRVAL_PP(trigger_name), 0,
imclient_addcallback(conn->client, Z_STRVAL_PP(trigger_name), 0,
NULL, NULL, 0);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool cyrus_query( resource connection, string query)
/* {{{ proto bool cyrus_query( resource connection, string query)
Send a query to a Cyrus IMAP server */
PHP_FUNCTION(cyrus_query)
{
@@ -480,7 +480,7 @@ PHP_FUNCTION(cyrus_query)
ZEND_FETCH_RESOURCE(conn, php_cyrus *, z_conn, -1, le_cyrus_name, le_cyrus);
convert_to_string_ex(query);
imclient_send(conn->client, NULL, NULL, Z_STRVAL_PP(query));
imclient_send(conn->client, NULL, NULL, Z_STRVAL_PP(query));
RETURN_TRUE;
}
+1 -1
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
+1 -1
View File
@@ -26,7 +26,7 @@ AC_DEFUN(AC_PREFERRED_DB_LIB,[
PHP_ARG_WITH(db, for xDBM support,
[ --with-db Include old xDBM support (deprecated, use --enable-dba instead)])
[ --with-db Include old xDBM support (deprecated)])
if test "$PHP_DB" != "no"; then
+10 -10
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -260,7 +260,7 @@ PHP_MINFO_FUNCTION(db)
{
/* this isn't pretty ... should break out the info a bit more (cmv) */
php_info_print_box_start(0);
php_printf("%s", php_get_info_db());
php_printf(php_get_info_db());
php_info_print_box_end();
}
/* }}} */
@@ -424,7 +424,7 @@ dbm_info *php_dbm_open(char *filename, char *mode TSRMLS_DC)
else ret = -1;
#else
#if PHP_DEBUG
php_error_docref1(NULL TSRMLS_CC, filename, E_WARNING, "errno = %d [%s]\n", errno, strerror(errno));
php_error1(NULL TSRMLS_CC, filename, E_WARNING, "errno = %d [%s]\n", errno, strerror(errno));
#endif
if (errno) ret=errno;
else ret = -1;
@@ -513,7 +513,7 @@ PHP_FUNCTION(dbminsert)
info = php_find_dbm(id TSRMLS_CC);
if (!info) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %ld", Z_LVAL_P(id));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %d", Z_LVAL_P(id));
RETURN_FALSE;
}
@@ -539,7 +539,7 @@ PHP_FUNCTION(dbmreplace)
info = php_find_dbm(id TSRMLS_CC);
if (!info) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %ld", Z_LVAL_P(id));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %d", Z_LVAL_P(id));
RETURN_FALSE;
}
@@ -607,7 +607,7 @@ PHP_FUNCTION(dbmfetch)
info = php_find_dbm(id TSRMLS_CC);
if (!info) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %ld", Z_LVAL_P(id));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %d", Z_LVAL_P(id));
RETURN_FALSE;
}
@@ -683,7 +683,7 @@ PHP_FUNCTION(dbmexists)
info = php_find_dbm(id TSRMLS_CC);
if (!info) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %ld", Z_LVAL_P(id));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %d", Z_LVAL_P(id));
RETURN_FALSE;
}
@@ -732,7 +732,7 @@ PHP_FUNCTION(dbmdelete)
info = php_find_dbm(id TSRMLS_CC);
if (!info) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %ld", Z_LVAL_P(id));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %d", Z_LVAL_P(id));
RETURN_FALSE;
}
@@ -779,7 +779,7 @@ PHP_FUNCTION(dbmfirstkey)
info = php_find_dbm(id TSRMLS_CC);
if (!info) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %ld", Z_LVAL_P(id));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %d", Z_LVAL_P(id));
RETURN_FALSE;
}
@@ -841,7 +841,7 @@ PHP_FUNCTION(dbmnextkey)
info = php_find_dbm(id TSRMLS_CC);
if (!info) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %ld", Z_LVAL_P(id));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %d", Z_LVAL_P(id));
RETURN_FALSE;
}
+1 -1
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
-48
View File
@@ -1,48 +0,0 @@
These functions build the foundation for accessing Berkeley DB style
databases.
This is a general abstraction layer for several file-based databases. As
such, functionality is limited to a common subset of features supported
by modern databases such as Sleepycat Software's DB2. (This is not to be
confused with IBM's DB2 software, which is supported through the ODBC
functions.)
This extensions allows to work with the following databases:
dbm DBM is the oldest (original) type of Berkeley DB style databases.
You should avoid it, if possible. We do not support the
compatibility functions built into DB2 and gdbm, because they are
only compatible on the source code level, but cannot handle the
original dbm format.
ndbm NDBM is a newer type and more flexible than dbm. It still has
most of the arbitrary limits of dbm (therefore it is deprecated).
gdbm GDBM is the GNU database manager.
db2 DB2 is Sleepycat Software's DB2. It's described as "a programmatic
toolkit that provides high-performance built-in database support
for both standalone and client/server applications.
db3 DB3 is Sleepycat Software's DB3.
db4 DB4 is Sleepycat Software's DB4. This is available since PHP 5.0.
cdb CDB is "a fast, reliable, lightweight package for creating and
reading constant databases." It is from the author of qmail and
can be found at http://cr.yp.to/cdb.html. Since it is constant,
we support only reading operations. And since PHP 4.3.0 we support
writing (not updating) through the internal cdb library.
cdb_make Since PHP 4.3.0 we support creation (not updating) of cdb files
when the bundled cdb library is used.
flatfile This is available since PHP 4.3.0 for compatibility with the
deprecated dbm extension only and should be avoided. However you
may use this where files were created in this format. That happens
when configure could not find any external library.
inifile This is available since PHP 4.3.3 to be able to modify php.ini
files from within PHP scripts. When working with ini files you
can pass arrays of the form array(0=>group,1=>value_name) or
strings of the form "[group]value_name" where group is optional.
After configuring and compiling PHP you must execute the following test
from commandline:
php run-tests.php ext/dba.
This shows whether your combination of handlers works. Most problematic
are dbm and ndbm which conflict with many installations. The reason for
this is that on several systems these libraries are part of more than one
other library. The configuration test only prevents you from configuring
malfaunctioning single handlers but not combinations.
+140 -318
View File
@@ -2,25 +2,18 @@ dnl
dnl $Id$
dnl
dnl Suppose we need FlatFile if no support or only CDB is used.
AC_DEFUN(PHP_DBA_STD_BEGIN,[
unset THIS_INCLUDE THIS_LIBS THIS_LFLAGS THIS_PREFIX THIS_RESULT
])
AC_DEFUN(PHP_TEMP_LDFLAGS,[
old_LDFLAGS=$LDFLAGS
LDFLAGS="$1 $LDFLAGS"
old_LIBS=$LIBS
LIBS="$2 $LIBS"
$3
$2
LDFLAGS=$old_LDFLAGS
LIBS=$old_LIBS
])
dnl Assign INCLUDE/LFLAGS from PREFIX
AC_DEFUN(PHP_DBA_STD_ASSIGN,[
if test -n "$THIS_PREFIX" && test "$THIS_PREFIX" != "/usr"; then
THIS_INCLUDE=$THIS_PREFIX/include
THIS_LFLAGS=$THIS_PREFIX/lib
fi
])
@@ -28,414 +21,243 @@ AC_DEFUN(PHP_DBA_STD_ASSIGN,[
dnl Standard check
AC_DEFUN(PHP_DBA_STD_CHECK,[
THIS_RESULT="yes"
if test -z "$THIS_INCLUDE"; then
AC_MSG_ERROR([DBA: Could not find necessary header file(s).])
if test "$THIS_PREFIX" != "/usr" -a "$THIS_INCLUDE" = ""; then
AC_MSG_ERROR(cannot find necessary header file(s))
fi
if test -z "$THIS_LIBS"; then
AC_MSG_ERROR([DBA: Could not find necessary library.])
if test "$THIS_LIBS" = "" ; then
AC_MSG_ERROR(cannot find necessary library)
fi
])
dnl Attach THIS_x to DBA_x
AC_DEFUN(PHP_DBA_STD_ATTACH,[
PHP_ADD_INCLUDE($THIS_INCLUDE)
PHP_ADD_LIBRARY_WITH_PATH($THIS_LIBS, $THIS_LFLAGS, DBA_SHARED_LIBADD)
unset THIS_INCLUDE THIS_LIBS THIS_LFLAGS THIS_PREFIX
])
dnl Print the result message
dnl parameters(name [, full name [, empty or error message]])
AC_DEFUN(AC_DBA_STD_RESULT,[
THIS_NAME=[]translit($1,a-z0-9-,A-Z0-9_)
if test -n "$2"; then
THIS_FULL_NAME="$2"
else
THIS_FULL_NAME="$THIS_NAME"
fi
AC_MSG_CHECKING(for $THIS_FULL_NAME support)
if test -n "$3"; then
AC_MSG_ERROR($3)
fi
if test "$THIS_RESULT" = "yes" -o "$THIS_RESULT" = "builtin"; then
HAVE_DBA=1
eval HAVE_$THIS_NAME=1
AC_MSG_RESULT($THIS_RESULT)
else
AC_MSG_RESULT(no)
fi
unset THIS_RESULT THIS_NAME THIS_FULL_NAME
unset THIS_RESULT
])
PHP_ARG_ENABLE(dba,whether to enable DBA,
[ --enable-dba Build DBA with builtin modules])
[ --enable-dba=shared Build DBA as a shared module])
AC_ARG_WITH(gdbm,
[ --with-gdbm[=DIR] DBA: Include GDBM support],[
[ --with-gdbm[=DIR] Include GDBM support],[
if test "$withval" != "no"; then
PHP_DBA_STD_BEGIN
for i in $withval /usr/local /usr; do
for i in /usr/local /usr $withval; do
if test -f "$i/include/gdbm.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/gdbm.h
break
THIS_PREFIX="$i"
fi
done
if test -n "$THIS_INCLUDE"; then
unset ac_cv_lib_gdbm_gdbm_open
PHP_CHECK_LIBRARY(gdbm, gdbm_open, [
AC_DEFINE_UNQUOTED(GDBM_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
AC_DEFINE(DBA_GDBM, 1, [ ])
THIS_LIBS=gdbm
], [], [-L$THIS_PREFIX/lib])
fi
unset ac_cv_lib_gdbm_gdbm_open
PHP_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[
AC_CHECK_LIB(gdbm, gdbm_open, [AC_DEFINE(DBA_GDBM, 1, [ ]) THIS_LIBS=gdbm])
])
PHP_DBA_STD_ASSIGN
PHP_DBA_STD_CHECK
PHP_DBA_STD_ATTACH
fi
])
AC_DBA_STD_RESULT(gdbm)
AC_MSG_CHECKING(for GDBM support)
AC_DBA_STD_RESULT
AC_ARG_WITH(ndbm,
[ --with-ndbm[=DIR] DBA: Include NDBM support],[
[ --with-ndbm[=DIR] Include NDBM support],[
if test "$withval" != "no"; then
PHP_DBA_STD_BEGIN
for i in $withval /usr/local /usr; do
if test -f "$i/include/ndbm.h"; then
for i in /usr/local /usr $withval; do
if test -f "$i/include/db1/ndbm.h" ; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/ndbm.h
break
elif test -f "$i/include/db1/ndbm.h"; then
NDBM_EXTRA=db1/ndbm.h
elif test -f "$i/include/ndbm.h" ; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/db1/ndbm.h
break
NDBM_EXTRA=ndbm.h
fi
done
done
if test -n "$THIS_INCLUDE"; then
for LIB in ndbm db1 c; do
PHP_CHECK_LIBRARY($LIB, dbm_open, [
AC_DEFINE_UNQUOTED(NDBM_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
AC_DEFINE(DBA_NDBM, 1, [ ])
THIS_LIBS=$LIB
], [], [-L$THIS_PREFIX/lib])
if test -n "$THIS_LIBS"; then
break
fi
done
if test "$NDBM_EXTRA" != ""; then
AC_DEFINE_UNQUOTED(NDBM_INCLUDE_FILE, "$NDBM_EXTRA", [ ])
fi
for LIB in db1 ndbm c; do
PHP_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[
AC_CHECK_LIB($LIB, dbm_open, [AC_DEFINE(DBA_NDBM,1, [ ]) THIS_LIBS=$LIB])
])
done
PHP_DBA_STD_ASSIGN
PHP_DBA_STD_CHECK
PHP_DBA_STD_ATTACH
fi
])
AC_DBA_STD_RESULT(ndbm)
dnl Berkeley specific (library and version test)
dnl parameters(version, library list, function)
AC_DEFUN(PHP_DBA_DB_CHECK,[
for LIB in $2; do
if test -f $THIS_PREFIX/lib/lib$LIB.a -o -f $THIS_PREFIX/lib/lib$LIB.$SHLIB_SUFFIX_NAME; then
PHP_TEMP_LDFLAGS(-L$THIS_PREFIX/lib, -l$LIB,[
AC_TRY_LINK([
#include "$THIS_INCLUDE"
],[
$3;
],[
AC_EGREP_CPP(yes,[
#include "$THIS_INCLUDE"
#if DB_VERSION_MAJOR == $1
yes
#endif
],[
THIS_LIBS=$LIB
break
])
])
])
fi
done
if test -z "$THIS_LIBS"; then
AC_MSG_CHECKING(for db$1 major version)
AC_MSG_ERROR(Header contains different version)
fi
if test "$1" = "4"; then
AC_MSG_CHECKING(for db4 minor version and patch level)
AC_EGREP_CPP(yes,[
#include "$THIS_INCLUDE"
#if DB_VERSION_MINOR != 1 || DB_VERSION_PATCH >= 25
yes
#endif
],[
AC_MSG_RESULT(ok)
],[
AC_MSG_ERROR(Version 4.1 requires patch level 25)
])
fi
if test "$ext_shared" = "yes"; then
AC_MSG_CHECKING(if dba can be used as shared extension)
AC_EGREP_CPP(yes,[
#include "$THIS_INCLUDE"
#if DB_VERSION_MAJOR > 3 || (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR > 2)
yes
#endif
],[
AC_MSG_RESULT(yes)
],[
AC_MSG_ERROR(At least version 3.3 is required)
])
fi
if test -n "$THIS_LIBS"; then
AC_DEFINE(DBA_DB$1, 1, [ ])
if test -n "$THIS_INCLUDE"; then
AC_DEFINE_UNQUOTED(DB$1_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
fi
fi
PHP_DBA_STD_ASSIGN
PHP_DBA_STD_CHECK
PHP_DBA_STD_ATTACH
])
AC_ARG_WITH(db4,
[ --with-db4[=DIR] DBA: Include Berkeley DB4 support],[
if test "$withval" != "no"; then
PHP_DBA_STD_BEGIN
for i in $withval /usr/local/BerkeleyDB.4.2 /usr/local/BerkeleyDB.4.1 /usr/local/BerkeleyDB.4.0 /usr/local /usr; do
if test -f "$i/db4/db.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/db4/db.h
break
elif test -f "$i/include/db4/db.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/db4/db.h
break
elif test -f "$i/include/db/db4.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/db/db4.h
break
elif test -f "$i/include/db4.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/db4.h
break
elif test -f "$i/include/db.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/db.h
break
fi
done
PHP_DBA_DB_CHECK(4, db-4.2 db-4.1 db-4.0 db-4 db4 db, [(void)db_create((DB**)0, (DB_ENV*)0, 0)])
fi
])
AC_DBA_STD_RESULT(db4,Berkeley DB4)
AC_ARG_WITH(db3,
[ --with-db3[=DIR] DBA: Include Berkeley DB3 support],[
if test "$withval" != "no"; then
PHP_DBA_STD_BEGIN
if test "$HAVE_DB4" = "1"; then
AC_DBA_STD_RESULT(db3,Berkeley DB3,You cannot combine --with-db3 with --with-db4)
fi
for i in $withval /usr/local/BerkeleyDB.3.3 /usr/local/BerkeleyDB.3.2 /usr/local/BerkeleyDB.3.1 /usr/local/BerkeleyDB.3.0 /usr/local /usr; do
if test -f "$i/db3/db.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/db3/db.h
break
elif test -f "$i/include/db3/db.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/db3/db.h
break
elif test -f "$i/include/db/db3.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/db/db3.h
break
elif test -f "$i/include/db3.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/db3.h
break
elif test -f "$i/include/db.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/db.h
break
fi
done
PHP_DBA_DB_CHECK(3, db-3.3 db-3.2 db-3.1 db-3.0 db-3 db3 db, [(void)db_create((DB**)0, (DB_ENV*)0, 0)])
fi
])
AC_DBA_STD_RESULT(db3,Berkeley DB3)
AC_MSG_CHECKING(for NDBM support)
AC_DBA_STD_RESULT
AC_ARG_WITH(db2,
[ --with-db2[=DIR] DBA: Include Berkeley DB2 support],[
[ --with-db2[=DIR] Include Berkeley DB2 support],[
if test "$withval" != "no"; then
PHP_DBA_STD_BEGIN
if test "$HAVE_DB3" = "1" -o "$HAVE_DB4" = "1"; then
AC_DBA_STD_RESULT(db2,Berkeley DB2,You cannot combine --with-db2 with --with-db3 or --with-db4)
fi
for i in $withval $withval/BerkeleyDB /usr/BerkeleyDB /usr/local /usr; do
for i in /usr/local /usr /usr/BerkeleyDB $withval/BerkeleyDB $withval; do
if test -f "$i/db2/db.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/db2/db.h
break
DB2_EXTRA=db2
elif test -f "$i/include/db2/db.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/db2/db.h
break
DB2_EXTRA=db2/db.h
elif test -f "$i/include/db/db2.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/db/db2.h
break
DB2_EXTRA=db/db2.h
elif test -f "$i/include/db2.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/db2.h
break
DB2_EXTRA=db2.h
elif test -f "$i/include/db.h" ; then
THIS_PREFIX=$i
DB2_EXTRA=db.h
fi
done
if test "$DB2_EXTRA" = "db2" ; then
DBA_INCLUDE="$DBA_INCLUDE -I$THIS_PREFIX/db2"
DB2_EXTRA=db.h
fi
if test -n "$DB2_EXTRA"; then
AC_DEFINE_UNQUOTED(DB2_INCLUDE_FILE, "$DB2_EXTRA", [ ])
fi
for LIB in db db2 c; do
PHP_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[
AC_CHECK_LIB($LIB, db_appinit, [AC_DEFINE(DBA_DB2,1,[ ]) THIS_LIBS=$LIB])
])
done
PHP_DBA_STD_ASSIGN
PHP_DBA_STD_CHECK
PHP_DBA_STD_ATTACH
fi
])
AC_MSG_CHECKING(for Berkeley DB2 support)
AC_DBA_STD_RESULT
AC_ARG_WITH(db3,
[ --with-db3[=DIR] Include Berkeley DB3 support],[
if test "$withval" != "no"; then
for i in /usr/local /usr /usr/local/BerkeleyDB.3.0 $withval; do
if test -f "$i/db3/db.h"; then
THIS_PREFIX=$i
DB3_EXTRA=db3
elif test -f "$i/include/db3/db.h"; then
THIS_PREFIX=$i
DB3_EXTRA=db3/db.h
elif test -f "$i/include/db/db3.h"; then
THIS_PREFIX=$i
DB3_EXTRA=db/db3.h
elif test -f "$i/include/db3.h"; then
THIS_PREFIX=$i
DB3_EXTRA=db3.h
elif test -f "$i/include/db.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/db.h
break
DB3_EXTRA=db.h
fi
done
PHP_DBA_DB_CHECK(2, db-2 db2 db, [(void)db_appinit("", NULL, (DB_ENV*)0, 0)])
if test -n "$DB3_EXTRA"; then
AC_DEFINE_UNQUOTED(DB3_INCLUDE_FILE, "$DB3_EXTRA", [ ])
fi
for LIB in db-3.1 db-3 db3 db; do
PHP_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[
AC_CHECK_LIB($LIB, db_create, [AC_DEFINE(DBA_DB3,1,[ ]) THIS_LIBS=$LIB])
])
done
PHP_DBA_STD_ASSIGN
PHP_DBA_STD_CHECK
PHP_DBA_STD_ATTACH
fi
])
AC_DBA_STD_RESULT(db2,Berkeley DB2)
AC_MSG_CHECKING(for Berkeley DB3 support)
AC_DBA_STD_RESULT
AC_ARG_WITH(dbm,
[ --with-dbm[=DIR] DBA: Include DBM support],[
[ --with-dbm[=DIR] Include DBM support],[
if test "$withval" != "no"; then
PHP_DBA_STD_BEGIN
for i in $withval /usr/local /usr; do
if test -f "$i/include/dbm.h"; then
for i in /usr/local /usr $withval; do
if test -f "$i/include/dbm.h" ; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/dbm.h
break
elif test -f "$i/include/gdbm/dbm.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/gdbm/dbm.h
break
fi
done
done
if test -n "$THIS_INCLUDE"; then
for LIB in dbm c gdbm; do
PHP_CHECK_LIBRARY($LIB, dbminit, [
AC_MSG_CHECKING(for DBM using GDBM)
AC_DEFINE_UNQUOTED(DBM_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
if test "$LIB" = "gdbm"; then
AC_DEFINE_UNQUOTED(DBM_VERSION, "GDBM", [ ])
AC_MSG_RESULT(yes)
else
AC_DEFINE_UNQUOTED(DBM_VERSION, "DBM", [ ])
AC_MSG_RESULT(no)
fi
AC_DEFINE(DBA_DBM, 1, [ ])
THIS_LIBS=$LIB
], [], [-L$THIS_PREFIX/lib])
if test -n "$THIS_LIBS"; then
break
fi
done
fi
for LIB in db1 dbm c; do
PHP_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[
AC_CHECK_LIB($LIB, dbminit, [AC_DEFINE(DBA_DBM,1,[ ]) THIS_LIBS=$LIB])
])
done
PHP_DBA_STD_ASSIGN
PHP_DBA_STD_CHECK
PHP_DBA_STD_ATTACH
fi
])
AC_DBA_STD_RESULT(dbm)
AC_DEFUN(PHP_DBA_BUILTIN_CDB,[
AC_DEFINE(DBA_CDB_BUILTIN, 1, [ ])
AC_DEFINE(DBA_CDB_MAKE, 1, [ ])
AC_DEFINE(DBA_CDB, 1, [ ])
cdb_sources="libcdb/cdb.c libcdb/cdb_make.c libcdb/uint32.c"
THIS_RESULT="builtin"
])
AC_MSG_CHECKING(for DBM support)
AC_DBA_STD_RESULT
AC_ARG_WITH(cdb,
[ --with-cdb[=DIR] DBA: Include CDB support],[
if test "$withval" = "yes" -o "$HAVE_DBA" = "1"; then
PHP_DBA_BUILTIN_CDB
[ --with-cdb[=DIR] Include CDB support],[
if test "$withval" = "yes"; then
PHP_ADD_BUILD_DIR($ext_builddir/libcdb)
AC_DEFINE(DBA_CDB_BUILTIN, 1, [ ])
AC_DEFINE(DBA_CDB_MAKE, 1, [ ])
AC_DEFINE(DBA_CDB, 1, [ ])
cdb_sources="libcdb/cdb.c libcdb/cdb_make.c libcdb/uint32.c"
THIS_RESULT="builtin"
elif test "$withval" != "no"; then
PHP_DBA_STD_BEGIN
for i in $withval /usr/local /usr; do
if test -f "$i/include/cdb.h"; then
for i in /usr/local /usr $withval; do
if test -f "$i/include/cdb.h" ; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/include/cdb.h
break
fi
done
if test -n "$THIS_INCLUDE"; then
for LIB in cdb c; do
PHP_CHECK_LIBRARY($LIB, cdb_read, [
AC_DEFINE_UNQUOTED(CDB_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
AC_DEFINE(DBA_CDB, 1, [ ])
THIS_LIBS=$LIB
], [], [-L$THIS_PREFIX/lib])
if test -n "$THIS_LIBS"; then
break
fi
done
fi
for LIB in cdb c; do
PHP_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[
AC_CHECK_LIB($LIB, cdb_read, [AC_DEFINE(DBA_CDB,1,[ ]) THIS_LIBS=$LIB])
])
done
PHP_DBA_STD_ASSIGN
PHP_DBA_STD_CHECK
PHP_DBA_STD_ATTACH
fi
],[
if test "$PHP_DBA" != "no" -o "$HAVE_DBA" = "1"; then
PHP_DBA_BUILTIN_CDB
fi
])
AC_DBA_STD_RESULT(cdb)
AC_MSG_CHECKING(for CDB support)
AC_DBA_STD_RESULT
AC_DEFUN(PHP_DBA_BUILTIN_INI,[
AC_DEFINE(DBA_INIFILE, 1, [ ])
ini_sources="libinifile/inifile.c"
THIS_RESULT="builtin"
])
AC_ARG_WITH(inifile,
[ --with-inifile DBA: Include INI support],[
if test "$withval" != "no"; then
PHP_DBA_BUILTIN_INI
fi
],[
if test "$PHP_DBA" != "no" -o "$HAVE_DBA" = "1"; then
PHP_DBA_BUILTIN_INI
fi
])
AC_DBA_STD_RESULT(inifile,INI File)
AC_DEFUN(PHP_DBA_BUILTIN_FLATFILE,[
AC_DEFINE(DBA_FLATFILE, 1, [ ])
flat_sources="libflatfile/flatfile.c"
THIS_RESULT="builtin"
])
dnl
dnl FlatFile check must be the last one.
dnl
AC_ARG_WITH(flatfile,
[ --with-flatfile DBA: Include FlatFile support],[
[ --with-flatfile Include FlatFile support],[
if test "$withval" != "no"; then
PHP_DBA_BUILTIN_FLATFILE
fi
],[
if test "$PHP_DBA" != "no" -o "$HAVE_DBA" = "1"; then
PHP_DBA_BUILTIN_FLATFILE
PHP_ADD_BUILD_DIR($ext_builddir/libflatfile)
AC_DEFINE(DBA_FLATFILE, 1, [ ])
flat_sources="dba_flatfile.c libflatfile/flatfile.c"
THIS_RESULT="builtin"
fi
])
AC_DBA_STD_RESULT(FlatFile,FlatFile)
AC_MSG_CHECKING(for FlatFile 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_NEW_EXTENSION(dba, dba.c dba_cdb.c dba_db2.c dba_dbm.c dba_gdbm.c dba_ndbm.c dba_db3.c dba_db4.c dba_flatfile.c dba_inifile.c $cdb_sources $flat_sources $ini_sources, $ext_shared)
PHP_ADD_BUILD_DIR($ext_builddir/libinifile)
PHP_ADD_BUILD_DIR($ext_builddir/libcdb)
PHP_ADD_BUILD_DIR($ext_builddir/libflatfile)
PHP_NEW_EXTENSION(dba, dba.c dba_cdb.c dba_db2.c dba_dbm.c dba_gdbm.c dba_ndbm.c dba_db3.c $cdb_sources $flat_sources, $ext_shared)
PHP_SUBST(DBA_SHARED_LIBADD)
else
AC_MSG_RESULT(no)
+111 -401
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -27,7 +27,7 @@
#if HAVE_DBA
#include "php_ini.h"
#include "ext/standard/flock_compat.h"
#include <stdio.h>
#include <fcntl.h>
#ifdef HAVE_SYS_FILE_H
@@ -36,8 +36,6 @@
#include "php_dba.h"
#include "ext/standard/info.h"
#include "ext/standard/php_string.h"
#include "ext/standard/flock_compat.h"
#include "php_gdbm.h"
#include "php_ndbm.h"
@@ -45,9 +43,7 @@
#include "php_cdb.h"
#include "php_db2.h"
#include "php_db3.h"
#include "php_db4.h"
#include "php_flatfile.h"
#include "php_inifile.h"
/* {{{ dba_functions[]
*/
@@ -71,7 +67,6 @@ function_entry dba_functions[] = {
/* }}} */
PHP_MINIT_FUNCTION(dba);
PHP_MSHUTDOWN_FUNCTION(dba);
PHP_MINFO_FUNCTION(dba);
zend_module_entry dba_module_entry = {
@@ -79,7 +74,7 @@ zend_module_entry dba_module_entry = {
"dba",
dba_functions,
PHP_MINIT(dba),
PHP_MSHUTDOWN(dba),
NULL,
NULL,
NULL,
PHP_MINFO(dba),
@@ -91,6 +86,21 @@ zend_module_entry dba_module_entry = {
ZEND_GET_MODULE(dba)
#endif
typedef struct dba_handler {
char *name; /* handler name */
int flags; /* whether and how dba does locking and other flags*/
int (*open)(dba_info *, char **error TSRMLS_DC);
void (*close)(dba_info * TSRMLS_DC);
char* (*fetch)(dba_info *, char *, int, int, int * TSRMLS_DC);
int (*update)(dba_info *, char *, int, char *, int, int TSRMLS_DC);
int (*exists)(dba_info *, char *, int TSRMLS_DC);
int (*delete)(dba_info *, char *, int TSRMLS_DC);
char* (*firstkey)(dba_info *, int * TSRMLS_DC);
char* (*nextkey)(dba_info *, int * TSRMLS_DC);
int (*optimize)(dba_info * TSRMLS_DC);
int (*sync)(dba_info * TSRMLS_DC);
} dba_handler;
/* {{{ macromania */
#define DBA_ID_PARS \
@@ -105,56 +115,15 @@ ZEND_GET_MODULE(dba)
WRONG_PARAM_COUNT; \
}
/* {{{ php_dba_myke_key */
static size_t php_dba_make_key(zval **key, char **key_str, char **key_free TSRMLS_DC)
{
if (Z_TYPE_PP(key) == IS_ARRAY) {
zval **group, **name;
HashPosition pos;
size_t len;
if (zend_hash_num_elements(Z_ARRVAL_PP(key)) != 2) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Key does not have exactly two elements: (key, name)");
return -1;
}
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(key), &pos);
zend_hash_get_current_data_ex(Z_ARRVAL_PP(key), (void **) &group, &pos);
zend_hash_move_forward_ex(Z_ARRVAL_PP(key), &pos);
zend_hash_get_current_data_ex(Z_ARRVAL_PP(key), (void **) &name, &pos);
convert_to_string_ex(group);
convert_to_string_ex(name);
if (Z_STRLEN_PP(group) == 0) {
*key_str = Z_STRVAL_PP(name);
*key_free = NULL;
return Z_STRLEN_PP(name);
}
len = spprintf(key_str, 0, "[%s]%s", Z_STRVAL_PP(group), Z_STRVAL_PP(name));
*key_free = *key_str;
return len;
} else {
convert_to_string_ex(key);
*key_str = Z_STRVAL_PP(key);
*key_free = NULL;
return Z_STRLEN_PP(key);
}
}
/* }}} */
#define DBA_GET2 \
zval **key; \
char *key_str, *key_free; \
size_t key_len; \
if(ac != 2 || zend_get_parameters_ex(ac, &key, &id) != SUCCESS) { \
WRONG_PARAM_COUNT; \
} \
if ((key_len = php_dba_make_key(key, &key_str, &key_free TSRMLS_CC)) == 0) {\
RETURN_FALSE; \
}
convert_to_string_ex(key)
#define DBA_GET2_3 \
zval **key; \
char *key_str, *key_free; \
size_t key_len; \
zval **tmp; \
int skip = 0; \
switch(ac) { \
@@ -173,21 +142,7 @@ static size_t php_dba_make_key(zval **key, char **key_str, char **key_free TSRML
default: \
WRONG_PARAM_COUNT; \
} \
if ((key_len = php_dba_make_key(key, &key_str, &key_free TSRMLS_CC)) == 0) {\
RETURN_FALSE; \
}
#define DBA_GET3 \
zval **key, **val; \
char *key_str, *key_free; \
size_t key_len; \
if(ac != 3 || zend_get_parameters_ex(ac, &key, &val, &id) != SUCCESS) { \
WRONG_PARAM_COUNT; \
} \
convert_to_string_ex(val); \
if ((key_len = php_dba_make_key(key, &key_str, &key_free TSRMLS_CC)) == 0) {\
RETURN_FALSE; \
}
convert_to_string_ex(key)
#define DBA_ID_GET \
ZEND_FETCH_RESOURCE2(info, dba_info *, id, -1, "DBA identifier", le_db, le_pdb);
@@ -195,20 +150,17 @@ static size_t php_dba_make_key(zval **key, char **key_str, char **key_free TSRML
#define DBA_ID_GET1 DBA_ID_PARS; DBA_GET1; DBA_ID_GET
#define DBA_ID_GET2 DBA_ID_PARS; DBA_GET2; DBA_ID_GET
#define DBA_ID_GET2_3 DBA_ID_PARS; DBA_GET2_3; DBA_ID_GET
#define DBA_ID_GET3 DBA_ID_PARS; DBA_GET3; DBA_ID_GET
#define DBA_ID_DONE \
if (key_free) efree(key_free)
/* a DBA handler must have specific routines */
#define DBA_NAMED_HND(alias, name, flags) \
#define DBA_NAMED_HND(name, x, flags) \
{\
#alias, flags, dba_open_##name, dba_close_##name, dba_fetch_##name, dba_update_##name, \
dba_exists_##name, dba_delete_##name, dba_firstkey_##name, dba_nextkey_##name, \
dba_optimize_##name, dba_sync_##name, dba_info_##name \
#name, flags, dba_open_##x, dba_close_##x, dba_fetch_##x, dba_update_##x, \
dba_exists_##x, dba_delete_##x, dba_firstkey_##x, dba_nextkey_##x, \
dba_optimize_##x, dba_sync_##x \
},
#define DBA_HND(name, flags) DBA_NAMED_HND(name, name, flags)
#define DBA_HND(x, flags) DBA_NAMED_HND(x, x, flags)
/* check whether the user has write access */
#define DBA_WRITE_CHECK \
@@ -243,106 +195,31 @@ static dba_handler handler[] = {
#if DBA_DB3
DBA_HND(db3, DBA_LOCK_ALL) /* No lock in lib */
#endif
#if DBA_DB4
DBA_HND(db4, DBA_LOCK_ALL) /* No lock in lib */
#endif
#if DBA_INIFILE
DBA_HND(inifile, DBA_STREAM_OPEN|DBA_LOCK_ALL) /* No lock in lib */
#endif
#if DBA_FLATFILE
DBA_HND(flatfile, DBA_STREAM_OPEN|DBA_LOCK_ALL) /* No lock in lib */
#endif
{ NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
{ NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};
#if DBA_FLATFILE
#define DBA_DEFAULT "flatfile"
#elif DBA_DB4
#define DBA_DEFAULT "db4"
#elif DBA_DB3
#define DBA_DEFAULT "db3"
#elif DBA_DB2
#define DBA_DEFAULT "db2"
#elif DBA_GDBM
#define DBA_DEFAULT "gdbm"
#elif DBA_NBBM
#define DBA_DEFAULT "ndbm"
#elif DBA_DBM
#define DBA_DEFAULT "dbm"
#else
#define DBA_DEFAULT ""
#endif
/* cdb/cdb_make and ini are no option here */
ZEND_BEGIN_MODULE_GLOBALS(dba)
char *default_handler;
dba_handler *default_hptr;
ZEND_END_MODULE_GLOBALS(dba)
ZEND_DECLARE_MODULE_GLOBALS(dba)
#ifdef ZTS
#define DBA_G(v) TSRMG(dba_globals_id, zend_dba_globals *, v)
#else
#define DBA_G(v) (dba_globals.v)
#endif
static int le_db;
static int le_pdb;
/* {{{ dba_fetch_resource
PHPAPI void dba_fetch_resource(dba_info **pinfo, zval **id TSRMLS_DC)
{
dba_info *info;
DBA_ID_FETCH
*pinfo = info;
}
*/
/* }}} */
/* {{{ dba_get_handler
PHPAPI dba_handler *dba_get_handler(const char* handler_name)
{
dba_handler *hptr;
for (hptr = handler; hptr->name && strcasecmp(hptr->name, handler_name); hptr++);
return hptr;
}
*/
/* }}} */
/* {{{ dba_close
*/
static void dba_close(dba_info *info TSRMLS_DC)
{
if (info->hnd) {
info->hnd->close(info TSRMLS_CC);
}
if (info->path) {
pefree(info->path, info->flags&DBA_PERSISTENT);
}
if (info->fp && info->fp!=info->lock.fp) {
if(info->flags&DBA_PERSISTENT) {
php_stream_pclose(info->fp);
} else {
php_stream_close(info->fp);
}
}
if (info->hnd) info->hnd->close(info TSRMLS_CC);
if (info->path) efree(info->path);
if (info->fp && info->fp!=info->lock.fp) php_stream_close(info->fp);
if (info->lock.fd) {
php_flock(info->lock.fd, LOCK_UN);
/*close(info->lock.fd);*/
close(info->lock.fd);
info->lock.fd = 0;
}
if (info->lock.fp) {
if(info->flags&DBA_PERSISTENT) {
php_stream_pclose(info->lock.fp);
} else {
php_stream_close(info->lock.fp);
}
}
if (info->lock.name) {
pefree(info->lock.name, info->flags&DBA_PERSISTENT);
}
pefree(info, info->flags&DBA_PERSISTENT);
if (info->lock.fp) php_stream_close(info->lock.fp);
if (info->lock.name) efree(info->lock.name);
efree(info);
}
/* }}} */
@@ -350,72 +227,18 @@ static void dba_close(dba_info *info TSRMLS_DC)
*/
static void dba_close_rsrc(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
dba_info *info = (dba_info *)rsrc->ptr;
dba_info *info = (dba_info *)rsrc->ptr;
dba_close(info TSRMLS_CC);
}
/* }}} */
/* {{{ dba_close_pe_rsrc_deleter */
int dba_close_pe_rsrc_deleter(list_entry *le, void *pDba TSRMLS_DC)
{
return le->ptr == pDba;
}
/* }}} */
/* {{{ dba_close_pe_rsrc */
static void dba_close_pe_rsrc(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
dba_info *info = (dba_info *)rsrc->ptr;
/* closes the resource by calling dba_close_rsrc() */
zend_hash_apply_with_argument(&EG(persistent_list), (apply_func_arg_t) dba_close_pe_rsrc_deleter, info TSRMLS_CC);
}
/* }}} */
/* {{{ PHP_INI
*/
ZEND_INI_MH(OnUpdateDefaultHandler)
{
dba_handler *hptr;
if (!strlen(new_value)) {
DBA_G(default_hptr) = NULL;
return OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
}
for (hptr = handler; hptr->name && strcasecmp(hptr->name, new_value); hptr++);
if (!hptr->name) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such handler: %s", new_value);
return FAILURE;
}
DBA_G(default_hptr) = hptr;
return OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
}
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("dba.default_handler", DBA_DEFAULT, PHP_INI_ALL, OnUpdateDefaultHandler, default_handler, zend_dba_globals, dba_globals)
PHP_INI_END()
/* }}} */
/* {{{ php_dba_init_globals
*/
static void php_dba_init_globals(zend_dba_globals *dba_globals)
{
dba_globals->default_handler = "";
dba_globals->default_hptr = NULL;
}
/* }}} */
/* {{{ PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(dba)
{
ZEND_INIT_MODULE_GLOBALS(dba, php_dba_init_globals, NULL);
REGISTER_INI_ENTRIES();
le_db = zend_register_list_destructors_ex(dba_close_rsrc, NULL, "dba", module_number);
le_pdb = zend_register_list_destructors_ex(dba_close_pe_rsrc, dba_close_rsrc, "dba persistent", module_number);
le_pdb = zend_register_list_destructors_ex(NULL, dba_close_rsrc, "dba persistent", module_number);
return SUCCESS;
}
/* }}} */
@@ -424,7 +247,6 @@ PHP_MINIT_FUNCTION(dba)
*/
PHP_MSHUTDOWN_FUNCTION(dba)
{
UNREGISTER_INI_ENTRIES();
return SUCCESS;
}
/* }}} */
@@ -460,30 +282,20 @@ PHP_MINFO_FUNCTION(dba)
*/
static void php_dba_update(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
char *v;
int len;
DBA_ID_GET3;
DBA_ID_PARS;
zval **val, **key;
if(ac != 3 || zend_get_parameters_ex(ac, &key, &val, &id) != SUCCESS) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(key);
convert_to_string_ex(val);
DBA_ID_GET;
DBA_WRITE_CHECK;
if (PG(magic_quotes_runtime)) {
len = Z_STRLEN_PP(val);
v = estrndup(Z_STRVAL_PP(val), len);
php_stripslashes(v, &len TSRMLS_CC);
if(info->hnd->update(info, key_str, key_len, v, len, mode TSRMLS_CC) == SUCCESS) {
efree(v);
DBA_ID_DONE;
RETURN_TRUE;
}
efree(v);
} else {
if(info->hnd->update(info, key_str, key_len, VALLEN(val), mode TSRMLS_CC) == SUCCESS)
{
DBA_ID_DONE;
RETURN_TRUE;
}
}
DBA_ID_DONE;
if(info->hnd->update(info, VALLEN(key), VALLEN(val), mode TSRMLS_CC) == SUCCESS)
RETURN_TRUE;
RETURN_FALSE;
}
/* }}} */
@@ -529,15 +341,14 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
int i;
int lock_mode, lock_flag, lock_dbf = 0;
char *file_mode;
char mode[4], *pmode, *lock_file_mode = NULL;
int persistent_flag = persistent ? STREAM_OPEN_PERSISTENT : 0;
char mode[4], *pmode, *lock_file_mode;
if(ac < 2) {
if(ac < 3) {
WRONG_PARAM_COUNT;
}
/* we pass additional args to the respective handler */
args = safe_emalloc(ac, sizeof(zval *), 0);
args = emalloc(ac * sizeof(zval *));
if (zend_get_parameters_array_ex(ac, args) != SUCCESS) {
FREENOW;
WRONG_PARAM_COUNT;
@@ -553,8 +364,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
list_entry *le;
/* calculate hash */
key = safe_emalloc(keylen, 1, 1);
key[keylen] = '\0';
key = emalloc(keylen);
keylen = 0;
for(i = 0; i < ac; i++) {
@@ -577,16 +387,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
}
}
if (ac==2) {
hptr = DBA_G(default_hptr);
if (!hptr) {
php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "No default handler selected");
FREENOW;
RETURN_FALSE;
}
} else {
for (hptr = handler; hptr->name && strcasecmp(hptr->name, Z_STRVAL_PP(args[2])); hptr++);
}
for (hptr = handler; hptr->name && strcasecmp(hptr->name, Z_STRVAL_PP(args[2])); hptr++);
if (!hptr->name) {
php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "No such handler: %s", Z_STRVAL_PP(args[2]));
@@ -602,40 +403,21 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
*
* d: force lock on database file
* l: force lock on lck file
* -: ignore locking
*
* t: test open database, warning if locked
*/
strlcpy(mode, Z_STRVAL_PP(args[1]), sizeof(mode));
pmode = &mode[0];
if (pmode[0] && (pmode[1]=='d' || pmode[1]=='l' || pmode[1]=='-')) { /* force lock on db file or lck file or disable locking */
switch (pmode[1]) {
case 'd':
lock_dbf = 1;
if ((hptr->flags & DBA_LOCK_ALL) == 0) {
lock_flag = (hptr->flags & DBA_LOCK_ALL);
break;
}
/* no break */
case 'l':
lock_flag = DBA_LOCK_ALL;
if (pmode[0] && (pmode[1]=='d' || pmode[1]=='l')) { /* force lock on db file or lck file */
if (pmode[1]=='d') {
if ((hptr->flags & DBA_LOCK_ALL) == 0) {
php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_NOTICE, "Handler %s does locking internally", hptr->name);
}
break;
default:
case '-':
if ((hptr->flags & DBA_LOCK_ALL) == 0) {
php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "Locking cannot be disabled for handler %s", hptr->name);
FREENOW;
RETURN_FALSE;
}
lock_flag = 0;
break;
lock_dbf = 1;
}
lock_flag = DBA_LOCK_ALL;
} else {
lock_flag = (hptr->flags&DBA_LOCK_ALL);
lock_dbf = 1;
}
switch (*pmode++) {
case 'r':
@@ -648,57 +430,33 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
lock_mode = (lock_flag & DBA_LOCK_WRITER) ? LOCK_EX : 0;
file_mode = "r+b";
break;
case 'c':
modenr = DBA_CREAT;
lock_mode = (lock_flag & DBA_LOCK_CREAT) ? LOCK_EX : 0;
if (lock_mode) {
if (lock_dbf) {
/* the create/append check will be done on the lock
* when the lib opens the file it is already created
*/
file_mode = "r+b"; /* read & write, seek 0 */
lock_file_mode = "a+b"; /* append */
} else {
file_mode = "a+b"; /* append */
lock_file_mode = "w+b"; /* create/truncate */
}
} else {
file_mode = "a+b";
}
/* In case of the 'a+b' append mode, the handler is responsible
* to handle any rewind problems (see flatfile handler).
*/
break;
case 'n':
modenr = DBA_TRUNC;
lock_mode = (lock_flag & DBA_LOCK_TRUNC) ? LOCK_EX : 0;
file_mode = "w+b";
break;
case 'c':
modenr = DBA_CREAT;
lock_mode = (lock_flag & DBA_LOCK_CREAT) ? LOCK_EX : 0;
file_mode = "a+b";
break;
default:
php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "Illegal DBA mode");
FREENOW;
RETURN_FALSE;
modenr = 0;
lock_mode = 0;
file_mode = "";
}
if (!lock_file_mode) {
lock_file_mode = file_mode;
}
if (*pmode=='d' || *pmode=='l' || *pmode=='-') {
if (*pmode=='d' || *pmode=='l') {
pmode++; /* done already - skip here */
}
if (*pmode=='t') {
pmode++;
if (!lock_flag) {
php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "You cannot combine modifiers - (no lock) and t (test lock)");
FREENOW;
RETURN_FALSE;
}
if (!lock_mode) {
if ((hptr->flags & DBA_LOCK_ALL) == 0) {
php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "Handler %s uses its own locking which doesn't support mode modifier t (test lock)", hptr->name);
php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "Handler %s uses its own locking which doesn't support mode modifier t (testing)", hptr->name);
FREENOW;
RETURN_FALSE;
} else {
php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "Handler %s doesn't uses locking for this mode which makes modifier t (test lock) obsolete", hptr->name);
php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "Handler %s doesn't uses locking for this mode which makes modifier t (testing) obsolete", hptr->name);
FREENOW;
RETURN_FALSE;
}
@@ -706,19 +464,19 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
lock_mode |= LOCK_NB; /* test =: non blocking */
}
}
if (*pmode) {
if (*pmode || !modenr) {
php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "Illegal DBA mode");
FREENOW;
RETURN_FALSE;
}
info = pemalloc(sizeof(dba_info), persistent);
info = emalloc(sizeof(dba_info));
memset(info, 0, sizeof(dba_info));
info->path = pestrdup(Z_STRVAL_PP(args[0]), persistent);
info->path = estrdup(Z_STRVAL_PP(args[0]));
info->mode = modenr;
info->argc = ac - 3;
info->argv = args + 3;
info->flags = (hptr->flags & ~DBA_LOCK_ALL) | (lock_flag & DBA_LOCK_ALL) | (persistent ? DBA_PERSISTENT : 0);
info->flags = (hptr->flags & ~DBA_LOCK_ALL) | (lock_flag & DBA_LOCK_ALL);
info->lock.mode = lock_mode;
/* if any open call is a locking call:
@@ -737,36 +495,26 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
if (!error && lock_mode) {
if (lock_dbf) {
info->lock.name = pestrdup(info->path, persistent);
info->lock.name = estrdup(info->path);
lock_file_mode = file_mode;
} else {
spprintf(&info->lock.name, 0, "%s.lck", info->path);
if (!strcmp(file_mode, "r")) {
/* when in read only mode try to use existing .lck file first */
/* do not log errors for .lck file while in read ony mode on .lck file */
lock_file_mode = "rb";
info->lock.fp = php_stream_open_wrapper(info->lock.name, lock_file_mode, STREAM_MUST_SEEK|IGNORE_PATH|ENFORCE_SAFE_MODE|persistent_flag, NULL);
}
if (!info->lock.fp) {
/* when not in read mode or failed to open .lck file read only. now try again in create(write) mode and log errors */
lock_file_mode = "a+b";
}
}
if (!info->lock.fp) {
info->lock.fp = php_stream_open_wrapper(info->lock.name, lock_file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE|persistent_flag, NULL);
lock_file_mode = "a+b";
}
info->lock.fp = php_stream_open_wrapper(info->lock.name, lock_file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE, NULL);
if (!info->lock.fp) {
dba_close(info TSRMLS_CC);
/* stream operation already wrote an error message */
FREENOW;
RETURN_FALSE;
}
if (php_stream_cast(info->lock.fp, PHP_STREAM_AS_FD, (void*)&info->lock.fd, 1) == FAILURE) {
if (php_stream_cast(info->lock.fp, PHP_STREAM_AS_FD, (void*)&info->lock.fd, 1) == FAILURE) {
dba_close(info TSRMLS_CC);
/* stream operation already wrote an error message */
FREENOW;
RETURN_FALSE;
}
if (php_flock(info->lock.fd, lock_mode)) {
if (php_flock(info->lock.fd, lock_mode)) {
error = "Unable to establish lock"; /* force failure exit */
}
}
@@ -776,7 +524,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
if (info->lock.fp && lock_dbf) {
info->fp = info->lock.fp; /* use the same stream for locking and database access */
} else {
info->fp = php_stream_open_wrapper(info->path, file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE|persistent_flag, NULL);
info->fp = php_stream_open_wrapper(info->path, file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE, NULL);
}
if (!info->fp) {
dba_close(info TSRMLS_CC);
@@ -788,7 +536,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
if (error || hptr->open(info, &error TSRMLS_CC) != SUCCESS) {
dba_close(info TSRMLS_CC);
php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "Driver initialization failed for handler: %s%s%s", hptr->name, error?": ":"", error?error:"");
php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "Driver initialization failed for handler: %s%s%s", Z_STRVAL_PP(args[2]), error?": ":"", error?error:"");
FREENOW;
RETURN_FALSE;
}
@@ -803,8 +551,6 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
Z_TYPE(new_le) = le_pdb;
new_le.ptr = info;
if (zend_hash_update(&EG(persistent_list), key, keylen+1, &new_le, sizeof(list_entry), NULL) == FAILURE) {
dba_close(info TSRMLS_CC);
php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "Could not register persistent resource");
FREENOW;
RETURN_FALSE;
}
@@ -816,7 +562,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
/* }}} */
#undef FREENOW
/* {{{ proto resource dba_popen(string path, string mode [, string handlername, string ...])
/* {{{ proto int dba_popen(string path, string mode, string handlername [, string ...])
Opens path using the specified handler in mode persistently */
PHP_FUNCTION(dba_popen)
{
@@ -824,7 +570,7 @@ PHP_FUNCTION(dba_popen)
}
/* }}} */
/* {{{ proto resource dba_open(string path, string mode [, string handlername, string ...])
/* {{{ proto int dba_open(string path, string mode, string handlername [, string ...])
Opens path using the specified handler in mode*/
PHP_FUNCTION(dba_open)
{
@@ -842,22 +588,20 @@ PHP_FUNCTION(dba_close)
}
/* }}} */
/* {{{ proto bool dba_exists(string key, resource handle)
/* {{{ 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, key_str, key_len TSRMLS_CC) == SUCCESS) {
DBA_ID_DONE;
if(info->hnd->exists(info, VALLEN(key) TSRMLS_CC) == SUCCESS) {
RETURN_TRUE;
}
DBA_ID_DONE;
RETURN_FALSE;
}
/* }}} */
/* {{{ proto string dba_fetch(string key, [int skip ,] resource handle)
/* {{{ proto string dba_fetch(string key, [int skip ,] int handle)
Fetches the data associated with key */
PHP_FUNCTION(dba_fetch)
{
@@ -865,43 +609,17 @@ PHP_FUNCTION(dba_fetch)
int len = 0;
DBA_ID_GET2_3;
if (ac==3) {
if (!strcmp(info->hnd->name, "cdb")) {
if (skip < 0) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Handler %s accepts only skip values greater than or equal to zero, using skip=0", info->hnd->name);
skip = 0;
}
} else if (!strcmp(info->hnd->name, "inifile")) {
/* "-1" is compareable to 0 but allows a non restrictive
* access which is fater. For example 'inifile' uses this
* to allow faster access when the key was already found
* using firstkey/nextkey. However explicitly setting the
* value to 0 ensures the first value.
*/
if (skip < -1) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Handler %s accepts only skip value -1 and greater, using skip=0", info->hnd->name);
skip = 0;
}
} else {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Handler %s does not support optional skip parameter, the value will be ignored", info->hnd->name);
skip = 0;
}
} else {
skip = 0;
if (ac==3 && strcmp(info->hnd->name, "cdb")) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Handler %s does not support optional skip parameter", info->hnd->name);
}
if((val = info->hnd->fetch(info, key_str, key_len, skip, &len TSRMLS_CC)) != NULL) {
if (val && PG(magic_quotes_runtime)) {
val = php_addslashes(val, len, &len, 1 TSRMLS_CC);
}
DBA_ID_DONE;
if((val = info->hnd->fetch(info, VALLEN(key), skip, &len TSRMLS_CC)) != NULL) {
RETURN_STRINGL(val, len, 0);
}
DBA_ID_DONE;
RETURN_FALSE;
}
/* }}} */
/* {{{ proto string dba_firstkey(resource handle)
/* {{{ proto string dba_firstkey(int handle)
Resets the internal key pointer and returns the first key */
PHP_FUNCTION(dba_firstkey)
{
@@ -916,7 +634,7 @@ PHP_FUNCTION(dba_firstkey)
}
/* }}} */
/* {{{ proto string dba_nextkey(resource handle)
/* {{{ proto string dba_nextkey(int handle)
Returns the next key */
PHP_FUNCTION(dba_nextkey)
{
@@ -931,44 +649,37 @@ PHP_FUNCTION(dba_nextkey)
}
/* }}} */
/* {{{ proto bool dba_delete(string key, resource handle)
Deletes the entry associated with key
If inifile: remove all other key lines */
/* {{{ 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, key_str, key_len TSRMLS_CC) == SUCCESS)
{
DBA_ID_DONE;
if(info->hnd->delete(info, VALLEN(key) TSRMLS_CC) == SUCCESS)
RETURN_TRUE;
}
DBA_ID_DONE;
RETURN_FALSE;
}
/* }}} */
/* {{{ proto bool dba_insert(string key, string value, resource handle)
If not inifile: Insert value as key, return false, if key exists already
If inifile: Add vakue as key (next instance of key) */
/* {{{ proto bool dba_insert(string key, string value, int handle)
Inserts value as key, returns false, if key exists already */
PHP_FUNCTION(dba_insert)
{
php_dba_update(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
}
/* }}} */
/* {{{ proto bool dba_replace(string key, string value, resource handle)
Inserts value as key, replaces key, if key exists already
If inifile: remove all other key lines */
/* {{{ proto bool dba_replace(string key, string value, int handle)
Inserts value as key, replaces key, if key exists already */
PHP_FUNCTION(dba_replace)
{
php_dba_update(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
}
/* }}} */
/* {{{ proto bool dba_optimize(resource handle)
/* {{{ proto bool dba_optimize(int handle)
Optimizes (e.g. clean up, vacuum) database */
PHP_FUNCTION(dba_optimize)
{
@@ -982,7 +693,7 @@ PHP_FUNCTION(dba_optimize)
}
/* }}} */
/* {{{ proto bool dba_sync(resource handle)
/* {{{ proto bool dba_sync(int handle)
Synchronizes database */
PHP_FUNCTION(dba_sync)
{
@@ -995,32 +706,29 @@ PHP_FUNCTION(dba_sync)
}
/* }}} */
/* {{{ proto array dba_handlers([bool full_info])
List configured database handlers */
/* {{{ proto array dba_handlers()
List configured databases */
PHP_FUNCTION(dba_handlers)
{
dba_handler *hptr;
zend_bool full_info = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &full_info) == FAILURE) {
if (ZEND_NUM_ARGS()!=0) {
ZEND_WRONG_PARAM_COUNT();
RETURN_FALSE;
}
array_init(return_value);
if (array_init(return_value) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to initialize array");
RETURN_FALSE;
}
for(hptr = handler; hptr->name; hptr++) {
if (full_info) {
add_assoc_string(return_value, hptr->name, hptr->info(hptr, NULL TSRMLS_CC), 0);
} else {
add_next_index_string(return_value, hptr->name, 1);
}
add_next_index_string(return_value, hptr->name, 1);
}
}
/* }}} */
/* {{{ proto array dba_list()
List opened databases */
List configured databases */
PHP_FUNCTION(dba_list)
{
ulong numitems, i;
@@ -1032,8 +740,10 @@ PHP_FUNCTION(dba_list)
RETURN_FALSE;
}
array_init(return_value);
if (array_init(return_value) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to initialize array");
RETURN_FALSE;
}
numitems = zend_hash_next_free_element(&EG(regular_list));
for (i=1; i<numitems; i++) {
if (zend_hash_index_find(&EG(regular_list), i, (void **) &le)==FAILURE) {
@@ -1047,7 +757,7 @@ PHP_FUNCTION(dba_list)
}
/* }}} */
#endif /* HAVE_DBA */
#endif
/*
* Local variables:
+4 -20
View File
@@ -43,8 +43,8 @@ RSC=rc.exe
# PROP Intermediate_Dir "Release_TS"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_DBA" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DBA=1 /D DBA_DB3=1 /D DB3_INCLUDE_FILE="db.h" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=0 /D DBA_DB3=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_DBA" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DBA=1 /D DBA_FLATFILE=1 /D DBA_CDB=1 /D DBA_CDB_MAKE=1 /D DBA_CDB_BUILTIN=1 /D DBA_INIFILE=1 /YX /FD /c
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "PHP_EXPORTS" /D "COMPILE_DL_DBA" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DBA=1 /D DBA_DB3=1 /D DB3_INCLUDE_FILE="db.h" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=0 /D DBA_DB3=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "PHP_EXPORTS" /D "COMPILE_DL_DBA" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DBA=1 /D DBA_FLATFILE=1 /D DBA_CDB=1 /D DBA_CDB_MAKE=1 /D DBA_CDB_BUILTIN=1 /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x407 /d "NDEBUG"
@@ -70,8 +70,8 @@ LINK32=link.exe
# PROP Intermediate_Dir "Debug_TS"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_DBA" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DBA=1 /D "DBA_DB3" /D DB3_INCLUDE_FILE="db.h" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=1 /D "DBA_DB3" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_DBA" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DBA=1 /D DBA_FLATFILE=1 /D DBA_CDB=1 /D DBA_CDB_MAKE=1 /D DBA_CDB_BUILTIN=1 /D DBA_INIFILE=1 /YX /FD /GZ /c
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "PHP_EXPORTS" /D "COMPILE_DL_DBA" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DBA=1 /D "DBA_DB3" /D DB3_INCLUDE_FILE="db.h" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=1 /D "DBA_DB3" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "PHP_EXPORTS" /D "COMPILE_DL_DBA" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DBA=1 /D DBA_FLATFILE=1 /D DBA_CDB=1 /D DBA_CDB_MAKE=1 /D DBA_CDB_BUILTIN=1 /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x407 /d "_DEBUG"
@@ -130,10 +130,6 @@ SOURCE=.\dba_gdbm.c
# End Source File
# Begin Source File
SOURCE=.\dba_inifile.c
# End Source File
# Begin Source File
SOURCE=.\dba_ndbm.c
# End Source File
# Begin Source File
@@ -142,10 +138,6 @@ SOURCE=.\libflatfile\flatfile.c
# End Source File
# Begin Source File
SOURCE=.\libinifile\inifile.c
# End Source File
# Begin Source File
SOURCE=.\libcdb\uint32.c
# End Source File
# End Group
@@ -194,20 +186,12 @@ SOURCE=.\php_gdbm.h
# End Source File
# Begin Source File
SOURCE=.\php_inifile.h
# End Source File
# Begin Source File
SOURCE=.\php_ndbm.h
# End Source File
# Begin Source File
SOURCE=.\libcdb\uint32.h
# End Source File
# Begin Source File
SOURCE=.\libinifile\inifile.h
# End Source File
# End Group
# End Target
# End Project
+12 -26
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -35,13 +35,12 @@
#include <fcntl.h>
#if DBA_CDB_BUILTIN
# include "libcdb/cdb.h"
# include "libcdb/cdb_make.h"
# include "libcdb/uint32.h"
#include "libcdb/cdb.h"
#include "libcdb/cdb_make.h"
#include "libcdb/uint32.h"
#else
# ifdef CDB_INCLUDE_FILE
# include CDB_INCLUDE_FILE
# endif
#include <cdb.h>
#include <uint32.h>
#endif
#define CDB_INFO \
@@ -86,10 +85,10 @@ DBA_OPEN_FUNC(cdb)
break;
#if DBA_CDB_BUILTIN
case DBA_TRUNC:
case DBA_CREAT:
make = 1;
file = info->fp;
break;
case DBA_CREAT:
case DBA_WRITER:
*error = "Update operations are not supported";
return FAILURE; /* not supported */
@@ -99,7 +98,7 @@ DBA_OPEN_FUNC(cdb)
return FAILURE;
}
cdb = pemalloc(sizeof(dba_cdb), info->flags&DBA_PERSISTENT);
cdb = emalloc(sizeof(dba_cdb));
memset(cdb, 0, sizeof(dba_cdb));
#if DBA_CDB_BUILTIN
@@ -133,7 +132,7 @@ DBA_CLOSE_FUNC(cdb)
cdb_free(&cdb->c);
close(cdb->file);
#endif
pefree(cdb, info->flags&DBA_PERSISTENT);
efree(cdb);
}
#if DBA_CDB_BUILTIN
@@ -163,7 +162,7 @@ DBA_FETCH_FUNC(cdb)
}
}
len = cdb_datalen(&cdb->c);
new_entry = safe_emalloc(len, 1, 1);
new_entry = emalloc(len+1);
if (php_cdb_read(&cdb->c, new_entry, len, cdb_datapos(&cdb->c)) == -1) {
efree(new_entry);
@@ -268,7 +267,7 @@ DBA_FIRSTKEY_FUNC(cdb)
uint32_unpack(buf, &klen);
uint32_unpack(buf + 4, &dlen);
key = safe_emalloc(klen, 1, 1);
key = emalloc(klen + 1);
if (cdb_file_read(cdb->file, key, klen) < klen) {
efree(key);
key = NULL;
@@ -300,7 +299,7 @@ DBA_NEXTKEY_FUNC(cdb)
uint32_unpack(buf, &klen);
uint32_unpack(buf + 4, &dlen);
key = safe_emalloc(klen, 1, 1);
key = emalloc(klen + 1);
if (cdb_file_read(cdb->file, key, klen) < klen) {
efree(key);
key = NULL;
@@ -325,19 +324,6 @@ DBA_SYNC_FUNC(cdb)
return SUCCESS;
}
DBA_INFO_FUNC(cdb)
{
#if DBA_CDB_BUILTIN
if (!strcmp(hnd->name, "cdb")) {
return estrdup(cdb_version());
} else {
return estrdup(cdb_make_version());
}
#else
return estrdup("External");
#endif
}
#endif
/*
+3 -12
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -53,10 +53,6 @@ DBA_OPEN_FUNC(db2)
struct stat check_stat;
int s = VCWD_STAT(info->path, &check_stat);
if (!s && !check_stat.st_size) {
info->mode = DBA_TRUNC; /* force truncate */
}
type = info->mode == DBA_READER ? DB_UNKNOWN :
info->mode == DBA_TRUNC ? DB_BTREE :
s ? DB_BTREE : DB_UNKNOWN;
@@ -80,7 +76,7 @@ DBA_OPEN_FUNC(db2)
return FAILURE;
}
info->dbf = pemalloc(sizeof(dba_db2_data), info->flags&DBA_PERSISTENT);
info->dbf = emalloc(sizeof(dba_db2_data));
memset(info->dbf, 0, sizeof(dba_db2_data));
((dba_db2_data *) info->dbf)->dbp = dbp;
return SUCCESS;
@@ -93,7 +89,7 @@ DBA_CLOSE_FUNC(db2)
if (dba->cursor)
dba->cursor->c_close(dba->cursor);
dba->dbp->close(dba->dbp, 0);
pefree(dba, info->flags&DBA_PERSISTENT);
efree(dba);
}
DBA_FETCH_FUNC(db2)
@@ -192,11 +188,6 @@ DBA_SYNC_FUNC(db2)
return dba->dbp->sync(dba->dbp, 0) ? FAILURE : SUCCESS;
}
DBA_INFO_FUNC(db2)
{
return estrdup(DB_VERSION_STRING);
}
#endif
/*
Loaded 100 of 1659 files, more files were not shown because too many files have changed in this diff. Show more