mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-08 09:47:30 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ccef75a19 |
No files matched your search
@@ -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
|
||||
|
||||
+17
-78
@@ -13,8 +13,6 @@ these rules.
|
||||
Code Implementation
|
||||
-------------------
|
||||
|
||||
[0] Document your code in source files and the manual. [tm]
|
||||
|
||||
[1] Functions that are given pointers to resources should not free them
|
||||
|
||||
For instance, function int mail(char *to, char *from) should NOT free
|
||||
@@ -48,58 +46,23 @@ Exceptions:
|
||||
doing so, should return that new length, so it doesn't have to be
|
||||
recalculated with strlen() (e.g. php_addslashes())
|
||||
|
||||
[5] Use php_error_docref() group of functions to report any errors/warnings
|
||||
during code execution. Use descriptive error messages, and try to avoid
|
||||
using identical error strings for different stages of an error. For
|
||||
example, if in order to obtain a URL you have to parse the URL, connect,
|
||||
and retreive the text, assuming something can go wrong at each of these
|
||||
stages, don't report an error "Unable to get URL" on all of them, but
|
||||
instead, write something like "Unable to parse URL", "Unable to connect
|
||||
to URL server" and "Unable to fetch URL text", respectively.
|
||||
|
||||
It has been silently agreed to prefix every php_error() message with the
|
||||
name of the current function if applicable:
|
||||
|
||||
php_error(E_WHATEVER, "%s(): Desc.", get_active_function_name(TSRMLS_C));
|
||||
|
||||
This can be done automatically using php_error_docref(). The first
|
||||
parameter, docref, is either NULL or the URL of a page describing the
|
||||
error in detail. In most cases you will pass NULL, to generate the URL
|
||||
from the name of the function being executed:
|
||||
|
||||
php_error_docref(NULL TSRMLS_CC, E_WHATEVER, "Desc.");
|
||||
|
||||
If you pass a URL, it can either be a full URL beginning with "http://":
|
||||
|
||||
php_error_docref("http://externalsite.tld/page.ext#error"
|
||||
TSRMLS_CC, E_WHATEVER, "Desc.");
|
||||
|
||||
Or the name of a manual page without file extension, but with an optional
|
||||
target anchor. Or simply the anchor within the manual page of the current
|
||||
function. When using function names you must replace '_' by '-':
|
||||
|
||||
php_error_docref("function.ext-func#error" TSRMLS_CC, E_WHATEVER, "Desc.");
|
||||
|
||||
To display one or two important parameters after the function name, use
|
||||
php_error_docref1() or php_error_docref2(). For example, file functions
|
||||
should display the name of the file opened:
|
||||
|
||||
php_error_docref1("function.fopen" TSRMLS_CC, filename,
|
||||
E_WHATEVER, "Desc.");
|
||||
|
||||
php_error_docref2("function.fopen" TSRMLS_CC, filename, openmode,
|
||||
E_WHATEVER, "Desc.");
|
||||
|
||||
Fixing ("unifying") existing php_error() message is a good thing [tm].
|
||||
[5] Use php_error() to report any errors/warnings during code execution.
|
||||
Use descriptive error messages, and try to avoid using identical
|
||||
error strings for different stages of an error. For example,
|
||||
if in order to obtain a URL you have to parse the URL, connect,
|
||||
and retreive the text, assuming something can go wrong at each
|
||||
of these stages, don't report an error "Unable to get URL"
|
||||
on all of them, but instead, write something like "Unable
|
||||
to parse URL", "Unable to connect to URL server" and "Unable
|
||||
to fetch URL text", respectively.
|
||||
|
||||
[6] NEVER USE strncat(). If you're absolutely sure you know what you're doing,
|
||||
check its man page again, and only then, consider using it, and even then,
|
||||
try avoiding it.
|
||||
|
||||
[7] Use PHP_* macros in the PHP source, and ZEND_* macros in the Zend
|
||||
part of the source. Although the PHP_* macro's are mostly aliased to the
|
||||
ZEND_* macros it gives a better understanding on what kind of macro you're
|
||||
calling.
|
||||
[7] Use ZEND_* macros instead of PHP_* macros. Use of PHP_* macros is not
|
||||
recommended. Since most of the PHP_* macros are ZEND_* macro aliases, using
|
||||
the PHP_* macros makes browsing the source code with a tag search harder.
|
||||
|
||||
[8] Use assert(). assert.h is included in php.h if it is available. Not only
|
||||
does good assertion catch bugs, but it also helps with code readability.
|
||||
@@ -111,30 +74,6 @@ Exceptions:
|
||||
Function calls in assert conditions may also cause this problem, if
|
||||
they modify one of their arguments or global variables.
|
||||
|
||||
[9] When commenting out code using a #if statement, do NOT use 0 only. Instead
|
||||
use "<cvs username here>_0". For example, #if FOO_0, where FOO is your
|
||||
cvs user foo. This allows easier tracking of why code was commented out,
|
||||
especially in bundled libraries.
|
||||
|
||||
[10] Do not define functions that are not available. For instance, if a
|
||||
library is missing a function, do not define the PHP version of the
|
||||
function, and do not raise a run-time error about the function not
|
||||
existing. End users should use function_exists() to test for the
|
||||
existence of a function
|
||||
|
||||
[11] Prefer emalloc(), efree(), estrdup(), etc. to their standard C library
|
||||
counterparts. These functions implement an internal "safety-net"
|
||||
mechanism that ensures the deallocation of any unfreed memory at the
|
||||
end of a request. They also provide useful allocation and overflow
|
||||
information while running in debug mode.
|
||||
|
||||
In almost all cases, memory returned to the engine must be allocated
|
||||
using emalloc().
|
||||
|
||||
The use of malloc() should be limited to cases where a third-party
|
||||
library may need to control or free the memory, or when the memory in
|
||||
question needs to survive between multiple requests.
|
||||
|
||||
Naming Conventions
|
||||
------------------
|
||||
|
||||
@@ -213,13 +152,13 @@ Syntax and indentation
|
||||
|
||||
[3] Be generous with whitespace and braces. Always prefer:
|
||||
|
||||
if (foo) {
|
||||
bar;
|
||||
}
|
||||
if (foo) {
|
||||
bar;
|
||||
}
|
||||
|
||||
to:
|
||||
to:
|
||||
|
||||
if(foo)bar;
|
||||
if(foo)bar;
|
||||
|
||||
Keep one empty line between the variable declaration section and
|
||||
the statements in a block, as well as between logical statement
|
||||
|
||||
+15
-39
@@ -89,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
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -147,8 +147,7 @@ STATUS: Working
|
||||
COMMENT: Tested on phpts and isapi versions
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: mysql
|
||||
PRIMARY MAINTAINER: Zak Greant <zak@mysql.com>, Georg Richter <georg@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
MAINTENANCE: Unknown
|
||||
STATUS: Working
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: pgsql
|
||||
@@ -174,7 +173,7 @@ EXTENSION: odbc
|
||||
PRIMARY MAINTAINER: Daniel R. Kalowsky <kalowsky@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
COMMENT: Working
|
||||
COMMENT: Working except for persistent connections
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: oracle
|
||||
PRIMARY MAINTAINER: Thies C. Arntzen <thies@thieso.net>
|
||||
@@ -197,23 +196,11 @@ MAINTENANCE: Unknown
|
||||
STATUS: Unknown
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: bz2
|
||||
PRIMARY MAINTAINER: Hartmut Holzgraefe <hartmut@six.de>
|
||||
MAINTENANCE: Odd Fixes
|
||||
PRIMARY MAINTAINER: Sterling Hughes <sterling@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
SINCE: 4.0.3
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: dio
|
||||
PRIMARY MAINTAINER: Sterling Hughes <sterling@php.net>
|
||||
MAINTENANCE: Orphaned
|
||||
STATUS: Working
|
||||
SINCE: 4.0.6
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: cyrus
|
||||
PRIMARY MAINTAINER: Sterling Hughes <sterling@php.net>
|
||||
MAINTENANCE: Orphaned
|
||||
STATUS: Working
|
||||
SINCE: 4.0.6
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: calendar
|
||||
PRIMARY MAINTAINER: Hartmut Holzgraefe <hartmut@six.de>
|
||||
MAINTENANCE: Odd Fixes
|
||||
@@ -271,15 +258,9 @@ PRIMARY MAINTAINER: Uwe Steinmann <steinm@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Unknown
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: fribidi
|
||||
PRIMARY MAINTAINER: Tal Peer <tal@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: ftp
|
||||
PRIMARY MAINTAINER: Stefan Esser (sesser@php.net)
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
MAINTENANCE: Unknown
|
||||
STATUS: Unknown
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: gd
|
||||
PRIMARY MAINTAINER: Rasmus Lerdorf <rasmus@php.net>
|
||||
@@ -299,11 +280,6 @@ EXTENSION: icap
|
||||
MAINTENANCE: Unknown
|
||||
STATUS: Obsolete
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: iconv
|
||||
PRIMARY MAINTAINER: Moriyoshi Koizumi <moriyoshi@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: imap
|
||||
PRIMARY MAINTAINER: Chuck Hagenbuch <chuck@horde.org>
|
||||
MAINTENANCE: Odd Fixes
|
||||
@@ -441,8 +417,8 @@ SINCE: 4.0.2
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: swf
|
||||
PRIMARY MAINTAINER: Sterling Hughes <sterling@php.net>
|
||||
MAINTENANCE: Orphaned
|
||||
STATUS: Deprecated (Use the ming swf extension instead)
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Depreciated (Use the ming swf extension instead)
|
||||
COMMENT: Only for Unix (won't change)
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: sysvsem
|
||||
@@ -469,9 +445,9 @@ MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: xslt
|
||||
PRIMARY MAINTAINER: Hartmut Holzgraefe <hartmut@six.de>
|
||||
MAINTENANCE: Odd Fixes
|
||||
STATUS: Working (mostly)
|
||||
PRIMARY MAINTAINER: Sterling Hughes <sterling@php.net>
|
||||
MAINTENANC: Maintained
|
||||
STATUS: Working
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: yaz
|
||||
PRIMARY MAINTAINER: Adam Dickmeiss <adam@indexdata.dk>
|
||||
@@ -489,9 +465,9 @@ MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: zziplib
|
||||
PRIMARY MAINTAINER: Hartmut Holzgraefe <hartmut@six.de>
|
||||
MAINTENANCE: Odd Fixes
|
||||
STATUS: Working
|
||||
PRIMARY MAINTAINER: Sterling Hughes <sterling@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Experimental
|
||||
SINCE: 4.0.5
|
||||
-------------------------------------------------------------------------------
|
||||
# iptc?
|
||||
@@ -8,11 +8,6 @@ up to date instructions in the online manual, located here:
|
||||
|
||||
http://www.php.net/manual/en/install.apache.php
|
||||
|
||||
For Apache 2, instructions and up-to-date information regarding it's
|
||||
support status, is available here:
|
||||
|
||||
http://www.php.net/manual/en/install.apache2.php
|
||||
|
||||
It is strongly recommended that you read the manual page before going
|
||||
further. However, for the impatient, here is a quick set of steps that
|
||||
will build PHP as (first) a dynamic Apache module (DSO) for Apache 1.3.x
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
+22
-22
@@ -3,24 +3,31 @@ INSTALL = $(top_srcdir)/build/shtool install -c
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
|
||||
DEFS = -DPHP_ATOM_INC -I$(top_builddir)/include -I$(top_builddir)/main -I$(top_srcdir)
|
||||
COMMON_FLAGS = $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(PHP_FRAMEWORKPATH)
|
||||
COMMON_FLAGS = $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS)
|
||||
|
||||
|
||||
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) --mode=link $(CC) $(COMMON_FLAGS) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@
|
||||
|
||||
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: $(install_targets)
|
||||
php: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
|
||||
$(BUILD_CGI)
|
||||
|
||||
sapi/cli/php: $(PHP_GLOBAL_OBJS) $(PHP_CLI_OBJS)
|
||||
$(BUILD_CLI)
|
||||
|
||||
install: $(install_targets)
|
||||
|
||||
|
||||
install-cli: sapi/cli/php
|
||||
@echo "Installing PHP CLI binary: $(INSTALL_ROOT)$(bindir)/"
|
||||
@$(INSTALL_CLI)
|
||||
|
||||
install-sapi: libphp4.la
|
||||
@echo "Installing PHP SAPI module"
|
||||
@@ -41,33 +48,26 @@ install-modules: build-modules
|
||||
$(mkinstalldirs) $(INSTALL_ROOT)$(EXTENSION_DIR) && \
|
||||
echo "Installing shared extensions: $(INSTALL_ROOT)$(EXTENSION_DIR)/" && \
|
||||
rm -f modules/*.la && \
|
||||
$(INSTALL) modules/* $(INSTALL_ROOT)$(EXTENSION_DIR) >/dev/null 2>&1 || true
|
||||
cp modules/* $(INSTALL_ROOT)$(EXTENSION_DIR) >/dev/null 2>&1 || true
|
||||
|
||||
install-tester:
|
||||
@echo "Installing regression tester: $(INSTALL_ROOT)$(PEAR_INSTALLDIR)/"
|
||||
@$(mkinstalldirs) $(INSTALL_ROOT)$(PEAR_INSTALLDIR)
|
||||
@$(mkinstalldirs) $(PEAR_INSTALLDIR)
|
||||
@$(INSTALL) -m 755 $(top_srcdir)/run-tests.php $(INSTALL_ROOT)$(PEAR_INSTALLDIR)
|
||||
|
||||
install-su: install-pear install-tester
|
||||
|
||||
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' -d 'output_buffering=0' $(top_srcdir)/run-tests.php $(TESTS)
|
||||
test: sapi/cli/php
|
||||
@TEST_PHP_EXECUTABLE=$(top_builddir)/sapi/cli/php \
|
||||
$(top_builddir)/sapi/cli/php -c php.ini-dist $(top_srcdir)/run-tests.php
|
||||
|
||||
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 \*.so | xargs rm -f
|
||||
find . -name \*.lo -o -name \*.o -o -name \*.la -o -name \*.a| xargs rm -f
|
||||
find . -name .libs -a -type d|xargs rm -rf
|
||||
rm -f libphp4.la $(SAPI_CLI_PATH) $(OVERALL_TARGET) modules/* libs/*
|
||||
rm -f libphp4.la php sapi/cli/php modules/* libs/*
|
||||
|
||||
distclean: clean
|
||||
rm -f config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h stamp-h php4.spec sapi/apache/libphp4.module buildmk.stamp
|
||||
egrep define'.*include/php' configure|sed 's/.*>//'|xargs rm -f
|
||||
find . -name Makefile | xargs rm -f
|
||||
|
||||
.PHONY: all clean install distclean test
|
||||
|
||||
@@ -1,568 +1,8 @@
|
||||
PHP 4 NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
29 May 2003, Version 4.3.2
|
||||
- Syncronized bundled GD library with GD 2.0.12. (Ilia)
|
||||
- Removed support for GDLIB version 1.x.x (php_gd.dll) on Windows. (Edin)
|
||||
- Enabled read-only GIF support in the bundled GDLIB (php_gd2.dll) on Windows.
|
||||
(Sebastian, Edin)
|
||||
- Improved dba extension (Marcus)
|
||||
. Added support for internal error handling of Berkeley db libraries.
|
||||
. Disallowed Berkeley db versions 4.1.0 to 4.1.24 due to locking problems.
|
||||
. Disallowed linkage of Berkeley db submodules against libraries with
|
||||
different major versions.
|
||||
. Disallowed configuring of more than one Berkeley db handler.
|
||||
. Reenabled dba_popen() with new persistent STDIO streams.
|
||||
- Added a new Apache 2.0 SAPI module (sapi/apache2handler) based on the old
|
||||
version (sapi/apache2filter). (Ian Holsman, Justin Erenkrantz)
|
||||
- Added "disable_classes" php.ini option to allow administrators to disable
|
||||
certain classes for security reasons. (Harald)
|
||||
- Added man page for CLI version of PHP. (Marcus)
|
||||
- Added --clean option into phpize. (Jani)
|
||||
- Added --ldflags option into php-config. (Jani)
|
||||
- Added imagesavealpha() and imageistruecolor() functions. (Pierre)
|
||||
- Added XBM support for bundled GD library. (Marcus)
|
||||
- Added session_regenerate_id() function. (Sascha)
|
||||
- Added zlib_get_coding_type() function which returns the coding type used for
|
||||
output compression. (Moriyoshi)
|
||||
- Added OCIPasswordChange() which allows renewing expired Oracle users. (Maxim)
|
||||
- Added memory_get_usage(). Only available when PHP is configured with
|
||||
--enable-memory-limit. (Andrey)
|
||||
- Added improved JPEG 2000 support for getimagesize(). (Marcus, Adam Wright)
|
||||
- Added XBM and WBMP support for getimagesize(). (Marcus)
|
||||
- Added KOI8-R, CP866, and CP1251 support for htmlentities().
|
||||
(Antony Dovgal, Moriyoshi)
|
||||
- Added domdocument->free() to free XML-documents from memory. (Rob Richards)
|
||||
- Fixed a bug in error reporting with the CLI for start-up errors. (Derick)
|
||||
- Fixed spurious fsync calls during socket communication. (Sascha)
|
||||
- Fixed a possible vhost issue in thttpd. (Sascha, dgl@dgl.cx)
|
||||
- Fixed including from HTTP URLs. (Sascha)
|
||||
- Fixed a lot of memory leaks in domxml. (Rob Richards, Chregu)
|
||||
- Fixed a bug in GD's truecolor TTF handling. (Derick)
|
||||
- Fixed several 64-bit problems. (Dave)
|
||||
- Fixed several errors in hwapi extension. Objects weren't handled properly.
|
||||
(Uwe)
|
||||
- Fixed bug #23788 (str|preg_replace() clobber the array elements). (Ilia)
|
||||
- Fixed bug #23765 (file uploads ignored due to case sensitivity). (Sara)
|
||||
- Fixed bug #23738 (ifx_copy_blob() crash). (Jani)
|
||||
- Fixed bug #23661 (mysql_fetch_array() gives no warning when an invalid
|
||||
argument was passed as result_type). (Derick)
|
||||
- Fixed bug #23619 (set_error_handler() registered handler not called for
|
||||
object instances). (Jani, waboring@qualys.com)
|
||||
- Fixed bug #23606 (Unable to build --with-db4 (db4.1.25)). (Marcus)
|
||||
- Fixed bug #23567 (pfsockopen() returns dead connections). (Wez)
|
||||
- Fixed bug #23539 (curl_exec() produces strange results). (daniel@haxx.se)
|
||||
- Fixed bug #23527 (PostScript Type 1 fonts do not render properly).
|
||||
(nid@home.se, Ilia)
|
||||
- Fixed bug #23402 (crash with improper use of mssql_bind()). (Frank)
|
||||
- Fixed bug #23371 (configure falsely detects c-client using SSL). (Jani)
|
||||
- Fixed bug #23340 (fopen on multiple URLs causes memory corruption). (Wez)
|
||||
- Fixed bug #23298 (serialize cuts off floats & doubles). (Ilia, Marcus)
|
||||
- Fixed bug #23232 (safe_mode does not honor PHP_AUTH_* in apache2). (Ilia)
|
||||
- Fixed bug #23225 (money_format() didn't handle erroneous return of strfmon).
|
||||
(Ilia, marcot@tabini.ca)
|
||||
- Fixed bug #23201 (set_file_buffer() crashes with stdio streams). (Ilia)
|
||||
- Fixed Bug #23188 (CDB databases created with 'c' mode do not work). (Marcus)
|
||||
- Fixed bug #23187 (memory leaks in sybase_connect/sybase_pconnect). (Ilia)
|
||||
- Fixed bug #23162 (user_error() crashs if error message > 1024 bytes).
|
||||
(Jay, Marcus, Moriyoshi)
|
||||
- Fixed bug #23152 ($http_response_header empty on invalid URLs). (Ilia)
|
||||
- Fixed bug #23102 (integer overflow in exif_iif_add_value()). (Ilia)
|
||||
- Fixed bug #23099 (ext/interbase: libgds.so: undefined reference to 'crypt').
|
||||
(Jani)
|
||||
- Fixed bug #23093 (highlight_string() crashed with __FUNCTION__). (Jani)
|
||||
- Fixed bug #23080 (socket_strerror() crashes on win32). (Moriyoshi)
|
||||
- Fixed bug #23071 (when DST in effect, date("T") crashed PHP).
|
||||
(Scott MacVicar, Jani)
|
||||
- Fixed bug #23069 (tempnam creates readonly file [win32]). (Wez)
|
||||
- Fixed bug #23009 (pg_select with timestamp). (Marcus, Jay)
|
||||
- Fixed bug #23008 (ldap_start_tls() not available on Windows). (Edin)
|
||||
- Fixed bug #23004 (When ftp_close() is called, send QUIT to the ftp server).
|
||||
(Ilia)
|
||||
- Fixed bug #22989 (sendmail not found by configure). (igyu@ionsphere.org)
|
||||
- Fixed bug #22987 (missing perror() check in configure). (Jani)
|
||||
- Fixed bug #22965 (Crash in gd lib's ImageFillToBorder()). (Ilia)
|
||||
- Fixed bug #22939 (crash in imap_header_info()). (Ilia)
|
||||
- Fixed bug #22844 (Changing bool value via -d or ini_set(), On would be Off).
|
||||
(Ilia)
|
||||
- Fixed bug #22786 (Crash when trying to call DomAttribute's
|
||||
set_namespace method). (Chregu)
|
||||
- Fixed bug #22775 (Fatal errors exit with status 0 with CGI/CLI). (Jani)
|
||||
- Fixed bug #22774 (PHP crashes when exiting (long XML doc)). (Rob Richards)
|
||||
- Fixed bug #22751 (Compile error in gdcache.c when external libgd is used).
|
||||
(Jani)
|
||||
- Fixed bug #22721 (Poor file() performance on systems without mmap). (Wez)
|
||||
- Fixed bug #22709 (Crash in interbase when database unavailable).
|
||||
(Vladimir Michl)
|
||||
- Fixed bug #22681 (Crash when reading from invalid file pointer). (Ilia)
|
||||
- Fixed bug #22672 (User not logged under Apache2). (Ian)
|
||||
- Fixed bug #22616 (Wrong order of -lssl and -lcrypto with IMAP). (Jani)
|
||||
- Fixed bug #22613 (imagettfbox() does not add the kerning distance to the
|
||||
running position). (Ilia)
|
||||
- Fixed bug #22585 (Do not terminate the script on minor errors). (Ilia)
|
||||
- Fixed bug #22550 (overflow protection for upload_max_filesize ini option).
|
||||
(Ilia)
|
||||
- Fixed bug #22544 (writing transparency to truecolor png images). (Ilia)
|
||||
- Fixed bug #22538 (failed stat on stdio/stdin/stderr streams). (Wez, Ilia)
|
||||
- Fixed bug #22530 (append_child does not unlink node). (Chregu)
|
||||
- Fixed bug #22520 (mcrypt_generic_deinit() was not available on Windows).
|
||||
(Edin)
|
||||
- Fixed bug #22508 (Added protection against circular HTML redirects). (Ilia)
|
||||
- Fixed bug #22473 (ISAPI Secure Server variables not available).
|
||||
(Christian Swoboda)
|
||||
- Fixed bug #22402 (opening of ftp for read/write could fail due to invalid
|
||||
return code handling). (Ilia)
|
||||
- Fixed bug #22384 (FNM_CASEFOLD is not available). (Hartmut)
|
||||
- Fixed bug #22382 (fgetcsv() did not handle \" correctly). (Ilia)
|
||||
- Fixed bug #22376 (wrong httpd.conf modified when using INSTALL_ROOT). (Jani)
|
||||
- Fixed bug #22363 (combinations of fwrite(), fread() and fseek() produce
|
||||
unexpected results). (Wez)
|
||||
- Fixed bug #22355 (PHP would remove folding from Subject & To fields). (Ilia)
|
||||
- Fixed bug #22330 (overloaded strrpos() gives wrong results).
|
||||
(david@santinoli.com, Moriyoshi)
|
||||
- Fixed bug #22312 (crash on failed connection when curl_getinfo() was called).
|
||||
(Phil Oleson <poleson@verio.net>)
|
||||
- Fixed bug #22308 (optimized passthru, code is now ~40 times faster). (Ilia)
|
||||
- Fixed bug #22306 (pg_lo_seek($h, 0, PGSQL_SEEK_SET) succeeds but
|
||||
returns false). (Jani)
|
||||
- Fixed bug #22301 (htmlspecialchars() crashes Apache on Tru64). (Ilia)
|
||||
- Fixed bug #22299 (gethostbyname() with non-existing domain crashed on MacOSX).
|
||||
(Jani)
|
||||
- Fixed bug #22283 (possible crash when opening relative URLs). (Ilia)
|
||||
- Fixed bug #22238 (stream_select() clobbers fifos under win9x). (Wez)
|
||||
- Fixed bug #22234 (copy() fails if source file has 0 length). (Moriyoshi)
|
||||
- Fixed bug #22227 (printf() field limiters broke between 4.2.3 and 4.3.0).
|
||||
(Moriyoshi)
|
||||
- Fixed bug #22224 (implode() changes object references in array). (Moriyoshi)
|
||||
- Fixed bug #22221 (bad rows count in the result object for postgresql). (Marc)
|
||||
- Fixed bug #22207 (e notation in *printf would be missing a 0 when there is
|
||||
no exponent). (Ilia)
|
||||
- Fixed bug #22220 ("php_admin_value open_basedir none" does not work). (Jani)
|
||||
- Fixed bug #22191 (frontbase build broken with old version of frontbase).
|
||||
(Ilia)
|
||||
- Fixed bug #22187 (spprintf function did not handle floats correctly). (Ilia)
|
||||
- Fixed bug #22149 (incorrect insertion of session id when tabs are used to
|
||||
separate tag elements). (Ilia)
|
||||
- Fixed bug #22141 (removed undocumented Boyer str_replace() method). (Sara)
|
||||
- Fixed bug #22103 (Added gdImageEllipse and replaced old gdImageFilledEllipse
|
||||
with a better implementation). (Pierre)
|
||||
- Fixed bug #22088 (array_shift() left next index to be +1 too much). (Jani)
|
||||
- Fixed bug #22083 (MySQL charset directory problem on Windows). (Edin)
|
||||
- Fixed bug #22059 (ftp_chdir() causes segfault). (Sara)
|
||||
- Fixed bug #22048 (crash in imap_header() when the e-mail contains an
|
||||
abnormally large number of special characters). (Ilia)
|
||||
- Fixed bug #22042 (pg_result_seek() would never seek to the 1st row in the
|
||||
result due to always seeking to row next to the one requested). (Ilia)
|
||||
- Fixed bug #22031 (Made curl_write() & curl_write_header() binary safe).
|
||||
(Ilia)
|
||||
- Fixed bug #22022 (Crash in imap_mail_compose() if the body is an empty array).
|
||||
(Ilia)
|
||||
- Fixed bug #22017 (date() does not support negative timestamps on win32).
|
||||
(Ilia)
|
||||
- Fixed bug #22008 (strip_tags() eliminates too much). (Moriyoshi)
|
||||
- Fixed bug #22004 (Overload extension and _call() breaks classes). (Shane)
|
||||
- Fixed bug #21998 (array_pop() did not reset the current array position).
|
||||
(Jani)
|
||||
- Fixed bug #21978, #21036 (win32 mail(), bcc: gets interpreted as cc:). (Sara)
|
||||
- Fixed bug #21885 (move_uploaded_file() does not ignore open_basedir). (Wez)
|
||||
- Fixed bug #21820 ("$arr['foo']" generates bogus E_NOTICE, should be E_PARSE).
|
||||
(Jani)
|
||||
- Fixed bug #21815 (fpassthru() ignored buffered data but complained anyway).
|
||||
(Wez)
|
||||
- Fixed bug #21809 (select would not always timeout during socket shutdown).
|
||||
(Wez)
|
||||
- Fixed bug #21751 (default output buffer could not be deleted). (Marcus)
|
||||
- Fixed bug #21725 (return behaviour differs between include and require).
|
||||
(Zeev)
|
||||
- Fixed bug #21713 (include remote files leaks descriptors on Solaris). (Wez)
|
||||
- Fixed bug #21708 (ucwords() trouble again). (Moriyoshi)
|
||||
- Fixed bug #21689 (fgetcsv() suppresses some characters before a separator).
|
||||
(Masahiro, Moriyoshi)
|
||||
- Fixed bug #21912, #21676 (getimagesize() failed for remote files). (Wez)
|
||||
- Fixed bug #21597 (made glob() understand Windows paths). (Edin)
|
||||
- Fixed bug #21549 (problem with Ingres II persistent connections). (Jani)
|
||||
- Fixed bug #21544 (Extended checks for where FreeTDS is installed). (Frank)
|
||||
- Fixed bug #21534 (typo in gmp_gcdext() causes incorrect results). (Sara)
|
||||
- Fixed bug #21531 (file_exists() and other filestat functions report errors
|
||||
when the requested file/directory does not exists). (Sara)
|
||||
- Fixed bug #21529 (memory corruption by fsockopen()). (Ilia)
|
||||
- Fixed bug #21525 (bind_textdomain_codeset() now available on Windows). (Edin)
|
||||
- Fixed bug #21523 (number_format() could cause a memory allocation for a
|
||||
negative memory size in situations where the sprintf implementation of the
|
||||
host system generated less decimal places than were requested). (Wez)
|
||||
- Fixed bug #21518 (imagecreatefromstring() crashed with invalid image files).
|
||||
(Ilia)
|
||||
- Fixed bug #21511 (config.status warning). (Jani)
|
||||
- Fixed bug #21498 (mysql_pconnect connection problems). (Georg)
|
||||
- Fixed bug #21453 (improper handling of non-terminated < by strip_tags()).
|
||||
(Ilia)
|
||||
- Fixed bug #21445 (gd unable to open fonts). (Ilia)
|
||||
- Fixed bug #21443 (improper handling of ? surrounded by spaces
|
||||
in get_browser()). (Ilia)
|
||||
- Fixed bug #21442 (crash in mail() on Windows when 1st parameter is empty).
|
||||
(Edin)
|
||||
- Fixed bug #21410 (fixed handling of NULL or "" files on Win32). (Ilia)
|
||||
- Fixed bug #21378 (COM code crashes after update 4.2.1 to 4.3.0). (Harald)
|
||||
- Fixed bug #21338 (html_entity_decode() crashed when "" is passed). (Ilia)
|
||||
- Fixed bug #21310 (Solaris has issues with getcwd() needing read permissions
|
||||
on directories instead of just execute). (Wez, jflemer)
|
||||
- Fixed bug #21297 (in CLI/CGI on the #! it would leave a \n when the code
|
||||
encounters \r\n). (Ilia)
|
||||
- Fixed bug #21268 (session_decode() returned FALSE on success). (Ilia)
|
||||
- Fixed bug #21267 (opening URLs that result in redirection to a relative
|
||||
path was failing). (Ilia)
|
||||
- Fixed bug #21229 (missing 3rd argument to php_module_startup). (Ilia)
|
||||
- Fixed bug #21228 (broken check for ob_gzhandler and made ob_start() return
|
||||
the correct value). (Ilia)
|
||||
- Fixed bug #21226 (parse_url handling of urls without a path). (Ilia)
|
||||
- Fixed bug #21224 (apache configure fails when using --enable-versioning).
|
||||
(Jani)
|
||||
- Fixed bug #21169 (Compile Failure and lots of warnings on UnixWare). (Derick)
|
||||
- Fixed bug #21131 (fopen() with mode 'a+' and rewind() doesn't work). (Wez)
|
||||
- Fixed bug #20857 (snmpset() failed always, patch by: rs@epost.de). (Jani)
|
||||
- Fixed bug #20802 (PHP would die silently when memory limit reached). (Ilia)
|
||||
- Fixed bug #20715 (odbc could not be compiled as shared extension). (Jani)
|
||||
- Fixed bug #20641 (Numeric/decimal datatype overflow in ext/interbase
|
||||
on Win32). (Daniela)
|
||||
- Fixed bug #20503 (imagesetbrush() not available on Windows). (Edin)
|
||||
- Fixed bug #20282 (COM memory leak). (Harald)
|
||||
- Fixed bug #20256 (snprintf() not defined on some systems). (Jani)
|
||||
- Fixed bug #19919 (crash in sapi_apache_header_handler under heavy load).
|
||||
(George)
|
||||
- Fixed bug #19795 (Problems with strnatcmp() / strnatcasecmp()). (Moriyoshi)
|
||||
- Fixed bug #17868 (multiple <!--include--> used to include PHP files crashes).
|
||||
(Ilia)
|
||||
- Fixed bug #17448 (Print the message when OCI_SUCCESS_WITH_INFO is returned).
|
||||
(Maxim)
|
||||
- Fixed bug #17098 (make Apache2 aware that PHP scripts should not be cached).
|
||||
(Ilia)
|
||||
- Fixed bug #16798 (Compile failure with LOB support for Oracle version < 8.1).
|
||||
(Maxim)
|
||||
- Fixed bug #14532 (fixed connection_status() to return 2 for timeouts). (Jani)
|
||||
- Fixed bug #14245 ('make install' fails on AIX when using --with-apxs). (Jani)
|
||||
- Fixed bug #13757 (CGI: passing query string on command line broken). (Shane)
|
||||
- Fixed bug #13561 (--without-pear disabled phpize/php-config install). (Jani)
|
||||
- Fixed bug #13551 (bcmath functions applying scale incorrectly). (Sara)
|
||||
|
||||
17 Feb 2003, Version 4.3.1
|
||||
- Fixed serious security vulnerability in CGI SAPI. (Shane)
|
||||
|
||||
27 Dec 2002, Version 4.3.0
|
||||
- If you don't specify building any other SAPI "make install" will install the
|
||||
CGI SAPI binary in {PREFIX}/bin/php. If you want to install CLI SAPI in that
|
||||
location use "make install-cli" after "make install" or add --disable-cgi
|
||||
to your configure options. In the Windows distribution CLI SAPI is included
|
||||
in the "cli" folder. (Edin)
|
||||
- Removed extensions: (Jan, Jani, Sebastian)
|
||||
. ext/aspell
|
||||
. ext/ccvs
|
||||
. ext/icap
|
||||
. sapi/fastcgi
|
||||
. sapi/fhttpd
|
||||
- Moved extensions to PECL (http://pear.php.net/): (James, Derick, George)
|
||||
. ext/vpopmail
|
||||
. ext/cybermut
|
||||
. ext/cybercash
|
||||
- Make PHP_AUTH_* variables not available in safe mode under Apache when an
|
||||
external basic auth mechanism is used. (Philip)
|
||||
- Aliased dba_popen() to dba_open() until 4.3.2 when persistent STDIO streams
|
||||
are introduced. (Andrei)
|
||||
- Fixed a security bug in the bundled MySQL library. (Georg, Stefan)
|
||||
- ZLIB extension is now built-in in the Windows distribution.
|
||||
External extension (php_zlib.dll) has been removed. (Edin)
|
||||
- Fixed a bug in ISO-8601 week calculation
|
||||
- Fixed a crash when using invalid color index with imagecolortransparent().
|
||||
(Pierre-Alain Joye)
|
||||
- Fixed bug #20987 (no handling for client certificates). (Ilia)
|
||||
- Fixed bug #21039 (crash when not supplying an IV to mcrypt_generic_init).
|
||||
(Derick)
|
||||
- Fixed bug #20936 (openssl_pkey_get was broken). (jeroen@derks.it, Wez)
|
||||
- Fixed bug #20927 (wordwrap crash). (Ilia)
|
||||
- Fixed bug #20796 (when register_globals is on & arrays with same names are
|
||||
passed via get/post/cookie the data inside $_GET/$_POST/$_COOKIE can would be
|
||||
corrupted). (Ilia)
|
||||
- Fixed bug #20725 (if the upload directory cannot be written to, the POST data
|
||||
after the uploaded file is lost). (Ilia)
|
||||
- Fixed bug #20865 (array_key_exists() fails to find NULL key). (Ilia)
|
||||
- Fixed bug #20812 (ftp_get returned NULL on success, instead of TRUE). (Ilia)
|
||||
- Fixed bug #20785 (crash when using pdf_open_memory_image() to load a
|
||||
true-color image). (Ilia)
|
||||
- Fixed a crash when converting between true-color images (png/jpeg) and
|
||||
gd1/gd2 image formats, png/jpeg -> gd1/gd2 -> png/jpeg conversion now
|
||||
works correctly. (Ilia, Pierre-Alain Joye)
|
||||
- Fixed a memory leak in the bundled GD library inside
|
||||
gdImageTrueColorToPalette(). (Ilia)
|
||||
- Fixed bug #12776 (array_walk crash). (Moriyoshi)
|
||||
- Fixed bug #20934 (htmlspecialchars returns latin1 from UTF-8). (Moriyoshi)
|
||||
- Fixed bugs #20270, #15702, #18600 (segfaults in ext/java). (Tony J. White)
|
||||
- Made bcmath extension thread safe. (Sander)
|
||||
- Fixed bug #19566 (get_declared_classes() segfaults). (Moriyoshi, Marcus, Andi)
|
||||
- Fixed bug #20381 (array_merge_recursive mangles input arrays). (Moriyoshi)
|
||||
- Added -n command switch to cli and cgi version which allows to skip php.ini
|
||||
parsing at startup. (Marcus, Wez)
|
||||
- Fixed bug #19689 (absolute paths like /test/dir/ not working correctly).
|
||||
(Ilia)
|
||||
- Added "neutral" language entry to mbstring spec. (Moriyoshi)
|
||||
- Changed bundled gd library to consider php.ini option memory_limit. (Marcus)
|
||||
- Modified log() to accept multiple bases. (Jason)
|
||||
- Fixed bugs #16190/18746 (ext/db: flatfile support with windows). (Marcus)
|
||||
- Added gd_info() which returns an array of gd support information. (Marcus)
|
||||
- Implemented features/changes requested in Bug #16960 (Timm):
|
||||
. Added a new function sybase_unbuffered_query()
|
||||
. Added a new function sybase_fetch_assoc()
|
||||
. Added sybase_set_message_handler() which enables users to handle
|
||||
server messages in a callback function
|
||||
. Added an ini entry for deadlock retries - retrying deadlocks can cause
|
||||
transaction state to break (sybct.deadlock_retry_count,
|
||||
defaults to -1 "forever").
|
||||
. Fixed sybase_fetch_object() not to return objects with numeric members
|
||||
. Fixed issues with identical fieldnames
|
||||
. Made sybase_fetch_*() functions return correct datatypes
|
||||
. Made phpinfo() section more verbose
|
||||
. Made sybase_query() error messages more verbose
|
||||
- Fixed bug #19935 (made OpenSSL file system operations abide by safe_mode
|
||||
& open_basedir restrictions). (Ilia)
|
||||
- Fixed bug #18868 (improved the check for availability of realpath()). (Ilia)
|
||||
- Fixed width/height detection of bmp images using getimagesize() function on
|
||||
big endian systems and added code to retrieve bmp bit depth. (Ilia)
|
||||
- Fixed bug #20035 (line counting error when script starts with #! in
|
||||
cgi/cli/fastcgi sapis). (Ilia)
|
||||
- Fixed bug #20235 (incorrect handling of symlinks on ZTS build). (Ilia)
|
||||
- Added sanity checks to headers_sent() & image_type_to_mime_type(). (Ilia)
|
||||
- Added an aditional parameter to the jdtojewish() function which makes
|
||||
the function return the symbolic hebrew name. (Moshe Doron, Derick)
|
||||
- Fixed bug #20169 (implode() clobbers first argument). (Moriyoshi)
|
||||
- Improved dba extension (Marcus)
|
||||
. Added dba_handlers() that returns an array of installed handlers and
|
||||
dba_list() that returns an associative array of open database files.
|
||||
. Added bundled cdb support wich can be activated by --with-cdb without a
|
||||
path. The bundled version supports cdb_make that allows writing cdb files.
|
||||
. Added optional skip parameter to dba_fetch() to support multiple key-value
|
||||
pairs with the same key for cdb handler.
|
||||
. Added locking for those handlers that do not have their own locking.
|
||||
. Added support for magic_quotes_runtime php.ini option.
|
||||
. Added flatfile support what finally makes ext/db deprecated.
|
||||
- Added imagerotate() which is available only when bundled libgd is used.
|
||||
(Pierre-Alain Joye, Ilia)
|
||||
- Fixed bug #17497 (mssql extension crashes if magic_quotes_runtime is on).
|
||||
(Sterling)
|
||||
- Remove $_FILES from $_REQUEST (import_request_variables is not modified),
|
||||
this didn't work properly in the first place, and added confusion. (Sterling)
|
||||
- Fixed the socket_read() function on win32 to work in normal mode (reading to
|
||||
the end of a line), as well as binary mode. (Sterling)
|
||||
- Fixed bug #20110 (added sanity check to prevent include/require functions
|
||||
from trying to include directories). (Ilia)
|
||||
- Fixed bug #20108 (segmentation fault on printf("%1.1s", "string")). (Ilia)
|
||||
- Added dbx_escape_string() function to dbx module. (Marc)
|
||||
- Added Oracle (oci8) support to dbx module. (Marc)
|
||||
- Updated FDF extension to work with Adode fdftk 5.0. (Hartmut)
|
||||
- Added mb_strtolower() and mb_strtoupper(). (Moriyoshi)
|
||||
- Fixed an infinite loop in setlocale() when only invalid locale names
|
||||
were passed in the array. (patch by Pal Loberg, pallo@initio.no)
|
||||
- Fixed bugs #19156 and #19544 (COM extension leaks memory and keeps
|
||||
components referenced). (Harald)
|
||||
- Added fribidi_get_charsets() and fribidi_charset_info() functions. (Tal)
|
||||
- Added Oracle TIMESTAMP type to oci8 extension. (Thies)
|
||||
- Fixed fgets($fp) to read until EOL when length parameter is not set. (Wez)
|
||||
- Changed registry entries under "HKLM\SOFTWARE\PHP\Per Directory Values" to
|
||||
work also with administrative directives such as safe_mode, open_basedir,
|
||||
etc. (Claudio Felber)
|
||||
- Added str_word_count() function which counts words inside a string. (Ilia)
|
||||
- Added PGSQL_CONNECT_FORCE_NEW option to pg_connect() (Yasuo)
|
||||
- Added ICONV_IMPL and ICONV_VERSION constants to iconv extension to
|
||||
indicate which iconv implementation is used. (Moriyoshi)
|
||||
- Fixed bug #4232 (Added %e & %E support to printf/sprintf). (Ilia)
|
||||
- Fixed bug #17580 (Allow ini parser to parse files >16K). (Ilia)
|
||||
- Fixed bug #19649 (Sanity checks for browscap.ini parser). (Ilia)
|
||||
- Added experimental patch to address problem with floats on various locales.
|
||||
(Bug #17079). (Ilia)
|
||||
- Fixed bug #19280 (imap_header fails with many To: addresses). (Ilia)
|
||||
- Added mb_regex_set_options(). The Options parameters of various mbregex
|
||||
functions are now deprecated. (Moriyoshi)
|
||||
- Fixed bug #19482 (Segfault with PCRE and locale). (Andrei)
|
||||
- Made ImageTruecolorToPalette() in bundled GD2 library actually work. (Rasmus)
|
||||
- Fixed ImageCopy() in bundled GD2 library to handle copying from truecolor to
|
||||
palette-based. (Wez, Rasmus)
|
||||
- Added read-only GIF support for bundled GD2 library. (Rasmus)
|
||||
- Made several adjustments to xslt extension (David Viner, Lehnar, Melvyn)
|
||||
. Added xslt_set_object and xslt_setopt function
|
||||
. Changed backend interaction with Sablotron library
|
||||
. Fixed leak with error_print
|
||||
. Made xslt_make_array() always set NULL on last index to signal array end.
|
||||
- Changed the glue argument in implode() to be optional. If not specified,
|
||||
defaults to "". (Sterling)
|
||||
- Fixed fields argument to contain correct info for xslt_set_error_handler().
|
||||
(Patch by Lenar Lohmus)
|
||||
- Added --with-config-file-scan-dir compile-time switch which specifies a
|
||||
directory which will be scanned for *.ini files. (Rasmus)
|
||||
- Added ob_get_clean() and ob_get_flush(). (Yasuo)
|
||||
- Added ftp_ssl_connect() to ext/ftp for FTP over SSL support. (Stefan Esser)
|
||||
- Made a few additions and changes to Apache 2 sapi. (Ilia)
|
||||
. Added apache_response_headers(), apache_note(), apache_getenv() and
|
||||
apache_setenv() functions.
|
||||
. Added more detailed error reporting to apache_lookup_uri() and virtual().
|
||||
. Renamed getallheaders() to apache_request_headers() and made an alias for BC.
|
||||
. Added php_apache_sapi_getenv() and php_apache_sapi_get_stat().
|
||||
. Added syntax-highlighting handling (.phps)
|
||||
- Fixed strstr(), strchr() and strrchr() to be binary safe. (Andrey)
|
||||
- Added array_diff_assoc() and array_intersect_assoc(). (Andrey)
|
||||
- Fixed bug #17825 (ob_start() chunk size option didn't work well). (Yasuo)
|
||||
- Fixed output buffer infinite loop when buffer_size became 0. (Marcus, Wez)
|
||||
- Added getopt() for parsing command line options and arguments. (Jon)
|
||||
- Added pg_fetch_assoc(), pg_fetch_all(), pg_ping(), pg_meta_data(), pg_convert(),
|
||||
pg_insert(), pg_select(), pg_update(), pg_delete(), pg_result_seek(),
|
||||
pg_unescape_bytea(), pg_get_notify() and pg_get_pid(). (Yasuo)
|
||||
- Fixed bug #17281 (Sanity checks for encoding sessions). (Ilia)
|
||||
- Fixed bug #16995 and #19392 (Prevent crash if $HTTP_SESSION_VARS != ARRAY).
|
||||
(Ilia)
|
||||
- Fixed bug #19292 (open_basedir restriction problem). (Rasmus)
|
||||
- Fixed bug #19366 (gdImageFill crashes when x & y are outside of
|
||||
the image's boundries). (Ilia)
|
||||
- Fixed bug #13936 (__FILE__ constant didn't contain full path). (Ilia)
|
||||
- PHP now has a new stream system that allows it to do some clever stuff with
|
||||
fopen() and fsockopen(). As a result:
|
||||
. URL wrappers natively supports https:// URLs if you have compiled
|
||||
OpenSSL support into PHP (shared extension does not support this).
|
||||
. Added support for fopen("ftps://...", ...) which allows to connect to FTP
|
||||
servers via SSL. (Stefan Esser)
|
||||
. fsockopen() adds support for ssl:// and tls:// connections via TCP/IP
|
||||
. copy($srcfilename, $destfilename) can now be used with URL wrappers
|
||||
. zlib wrappers/streams can be used even on systems without fopencookie()
|
||||
. Changed 'zlib:' fopen wrapper to 'compress.zlib://' and deprecate
|
||||
'zlib:' to avoid ambiguities when filenames have ':' characters. (Wez)
|
||||
. Added 'compress.bzip2://' stream and wrapper support.
|
||||
. Added user-space streams - it is now possible to define a class in PHP
|
||||
code and register it as a URL wrapper. (stream_register_wrapper)
|
||||
. Most extensions now support streams when passing files, which means
|
||||
that those extensions will now also support URL wrappers. (Wez)
|
||||
. Added URL-wrapper support to exif. (Marcus)
|
||||
. Added memory stream support. (Marcus)
|
||||
. Renamed:
|
||||
socket_set_timeout() -> stream_set_timeout()
|
||||
socket_set_blocking() -> stream_set_blocking()
|
||||
set_file_buffer() -> stream_set_write_buffer()
|
||||
socket_get_status() -> stream_get_meta_data()
|
||||
As these functions can (in theory) work on any type of stream. (Wez)
|
||||
. Raw POST data is now available as "php://input" stream. (Hartmut)
|
||||
. fopen("php://output", "wb") returns a stream that writes to the output
|
||||
buffer (like echo and print). (Wez)
|
||||
. Added stream_context_create(), stream_context_set_params() and
|
||||
stream_context_set_option and added an optional fourth parameter to
|
||||
fopen() which accepts a stream context. Contexts allow sharing of
|
||||
information between streams (a kind of "session") and setting
|
||||
notification callbacks. (Wez)
|
||||
. Made the "User-Agent" header sent by http:// and https:// wrappers
|
||||
configurable in php.ini or via a stream context. (Sterling)
|
||||
. Added stream_filter_prepend() and stream_filter_append() which apply
|
||||
a filter to either the top or the bottom of a stream filter stack.
|
||||
Implemented "string.rot13" filter as an example; more filters are
|
||||
expected to follow in later releases and other extensions. (Wez)
|
||||
. Added stream_select() which works like socket_select but works on
|
||||
streams returned by fopen(), fsockopen() and pfsockopen() instead. (Wez)
|
||||
. Added STDIN, STDOUT and STDERR constants for CLI sapi reflecting opened
|
||||
streams to their respective standard I/O counterparts. (Edin)
|
||||
. Added php.ini option "auto_detect_line_endings" which enables PHP to
|
||||
detect Macintosh, Unix and Dos end-of-line characters in fgets() and
|
||||
file(). Fixes bugs #16521 and #16708. (Wez)
|
||||
. Fixed include(), require() and GD functions to work with remote files
|
||||
under win32.
|
||||
Fixed bug #18609 (ImageCreateFromJPEG can't fetch from a URL). (Wez)
|
||||
- Fixed bug #18022 (fopen does not work with php://stdin anymore on Solaris).
|
||||
(Wez)
|
||||
- Added php.ini option "default_socket_timeout" to set the timeout limit for
|
||||
PHP network streams. (kalowsky, ilia@prohost.org, Wez)
|
||||
- Added file_get_contents() which returns the contents of a file as a string.
|
||||
This function also supports the URL wrappers. (Wez)
|
||||
- Fixed bug #19595 (Missing functions for GD2 format handling). (Edin)
|
||||
- Fixed bug #19633 (Wrong directories in ext/ldap/config.m4). (Derick)
|
||||
- Fixed bugs #17274 and #19627 (segfault in sem_remove). (Wez)
|
||||
- Added mb_convert_case() function to the mbstring extension which can convert
|
||||
strings between upper, lower and title case using Unicode mappings.
|
||||
Fixed bug #19257 (strtolower & strtoupper does not work for UTF-8 strings).
|
||||
(Wez)
|
||||
- Fixed bug #18521 (htmlentities didn't warn about unsupported charsets). (Wez)
|
||||
- Fixed bug #11643 (Session related, fix SID redefinition). (Ilia)
|
||||
- Fixed bug #18556 (Scripting Engine, problem with locales like tr_TR). (Ilia)
|
||||
- Changed y2k_compliance to default to 1 now. (Sascha)
|
||||
- Added platform independent socket error constants for better error handling. (Jason)
|
||||
- Update output of phpinfo() to use more CSS to reduce the file size, do
|
||||
proper HTML escaping, and make it XHTML compliant. (Colin)
|
||||
- Fixed compile errors in the FriBidi extension (Bug #16414). (Tal)
|
||||
- Fixed bugs #7472, #12120 and #12989 as well as other potential problems
|
||||
with strip_tags() function. (Ilia)
|
||||
- Fixed bugs #17570 and #17957 (Regexps related). (Andrei, Ilia)
|
||||
- Fixed bugs #18167 and #16859 (SEGV with session_decode). (Ilia)
|
||||
- Fixed bugs #19573 and #13472 (Session, XHTML compliance and trans_sid).
|
||||
(Sascha)
|
||||
- Fixed bug #19570 (last character was missing in get_html_translation_table).
|
||||
(Wez)
|
||||
- Upgraded PCRE to version 3.9. (Wez)
|
||||
- Fixed bug in OCIResult() which returned garbage when called on
|
||||
empty result-sets. (Thies)
|
||||
- Added ability to use Perl-style ${n} subpattern references in the
|
||||
replacement string for preg_replace() (bug #18442). (Andrei)
|
||||
- Fixed array_merge_recursive() to avoid problems with merging cyclical
|
||||
arrays (bug #16064). (Andrei)
|
||||
- Made function_exists() work properly with disabled functions. (Andrei)
|
||||
- Added ability to extract() variables as references via OR'able EXTR_REFS
|
||||
flag. (Andrei)
|
||||
- Fixed a build failure with the OCI8 extension on Tru64.
|
||||
(Patch by Michael Mauch, micahel.mauch@gmx.de)
|
||||
- Added --disable-all configure option. (Jani)
|
||||
- Backported debug_backtrace() from ZendEngine2. (Thies)
|
||||
- Added html-free phpinfo() output for CLI. (Jan)
|
||||
- Fixed socket_recvfrom() to be binary safe. (Jason)
|
||||
- Changed mail() to use escape_shell_cmd() to allow multiple extra parameters
|
||||
to the invocation of the mailer as used in the fifth parameter. (Derick)
|
||||
- Changed cURL extension to require cURL version 7.9.8 (Derick)
|
||||
- Added zend_execute_internal which is called like zend_execute but for
|
||||
internal functions. (Thies)
|
||||
- Changed pg_connection_status(), pg_connection_reset(), pg_connection_busy(),
|
||||
pg_result_status() and pg_result_error() to silently return FALSE when
|
||||
resource is not passed to them. (Yasuo)
|
||||
- Fixed some mysql compile failures on 64 bit-OS. (Georg)
|
||||
- Added warnings for deprecated mysql functions:
|
||||
. mysql_create_db()
|
||||
. mysql_drop_db()
|
||||
. mysql_escape_string()
|
||||
- Added XsltObject->result_dump_mem($result) for returning xslt-result directly
|
||||
into a string and XsltObject->result_dump_file($result,$file[,$compression])
|
||||
for dumping into a file. (morus.walter@web.de, chregu)
|
||||
- Made mime_magic and ZIP extensions available on Windows. (Edin)
|
||||
- Added xslt_backend_version() and xslt_backend_name() for getting
|
||||
information about the processor backend. (chregu)
|
||||
- Added ImageColorMatch() and ImageLayerEffect() functions which are only
|
||||
available when using the bundled GD library. (ttoohey)
|
||||
- Made major improvents to the pcntl extension. (Jason)
|
||||
. Greatly improved performance (signal callback mechanism uses ticks)
|
||||
. Implemented object signal callback ability by using array($obj, $method)
|
||||
. Added a restart parameter to pcntl_signal, which allows you to disable
|
||||
the default of system call restarting
|
||||
- Changed DomNode->next_sibling() and DomNode->previous_sibling() to return
|
||||
NULL instead of false (W3C specs). (chregu)
|
||||
- Changed DomNode->insert_before() and DomNode->append_child() to conform to
|
||||
W3C specs (moving not copying nodes, accepting NULL as 2nd param). (chregu)
|
||||
- Added DomNode->set_namespace(uri[,prefix]) (chregu)
|
||||
- Fixed shuffle() to properly generate all possibilities. (Patch provided by
|
||||
Adam <adam@trachtenberg.com>)
|
||||
- Fixed DomNode->insert_before() to behave according to W3C spec
|
||||
ie. new_child is moved, not copied. (chregu)
|
||||
- Added some namespace support with DomNode->add_namespace(uri, prefix)
|
||||
and DomDocument->create_element_ns(uri, nodename) (chregu)
|
||||
- Added optional parameter to DomElement->node_name() for retrieving fully
|
||||
qualified name (ie. namespace prefix). (chregu)
|
||||
- Changed DomNode->child_nodes() to return empty array instead of false if no
|
||||
child nodes are found. (chregu)
|
||||
- Fixed a bug with handling the Expect header. (Patch by ilia@prohost.org)
|
||||
- Fixed a bug in ODBC where closing the module caused a crash in the Windows
|
||||
executable. (kalowsky)
|
||||
- Fixed memory leaks in pack() and unpack(). (Patch by ilia@prohost.org)
|
||||
- Added URLs to error messages which direct to a page describing the error or
|
||||
function in question. (Derick, Wez, Marcus)
|
||||
- Added odbc_data_source() functionality to identify DB ServerName, and a
|
||||
description of it gathered from the DSN. (kalowsky)
|
||||
- Fixed copy() to return TRUE with 0 byte files. (Patch by ilia@prohost.org)
|
||||
? ? ??? 2002, Version 4.3.0
|
||||
- Added ob_list_handlers() which returns an array of all active output
|
||||
handlers. (Marcus)
|
||||
handlers. (marcus)
|
||||
- Added mbstring encoding/decoding "HTML-ENTITIES". (Marcus)
|
||||
- Added parameter 'L' for mb_http_input() to retrieve input encoding as a
|
||||
comma separated string. (Marcus)
|
||||
@@ -577,8 +17,8 @@ PHP 4 NEWS
|
||||
declare (ticks=1) {
|
||||
statement;
|
||||
}
|
||||
- Brought strtotime() "next" keyword handling in line with documentation and
|
||||
its glibc cousin. (Rasmus)
|
||||
- Bring strtotime() "next" keyword handling in line with documentation and
|
||||
its glibc cousin. (Rasmus)
|
||||
- Fixed str_rot13() to not mangle source string. (Rasmus)
|
||||
- Fixed imap_get_quota() to work with multiple returned resources as per
|
||||
the RFC 2087 and bug #14673. (kalowsky, Sander Steffann)
|
||||
@@ -591,6 +31,8 @@ PHP 4 NEWS
|
||||
representation instead of echoing it. (Derick)
|
||||
- Added mysql_ping(), mysql_real_escape_string(), mysql_character_set_name(),
|
||||
mysql_thread_id(), mysql_stat() and mysql_list_processes(). (Zak, Georg)
|
||||
- Added pg_fetch_all() which fetches all rows in a result. (Yasuo)
|
||||
- Changed "session.use_trans_sid" to be disabled by default in php.ini. (Yasuo)
|
||||
- Added safe_mode & open_basedir checks for pg_lo_export(). (Yasuo)
|
||||
- Added open_basedir check for pg_lo_import(). (Yasuo)
|
||||
- Fixed infinite recursion crash bug in ticks. (Jason)
|
||||
@@ -613,8 +55,9 @@ PHP 4 NEWS
|
||||
condition. Also fixed host resolution error messages on win32. (Jason)
|
||||
- Added optional 3rd parameter 'recursive' to ftp_rawlist() which will
|
||||
do 'LIST -R' instead of 'LIST'. (Jani)
|
||||
- Disabled the fifth parameter in mail() when safe-mode is turned on. (Derick)
|
||||
- Changed getimagesize() to always set unknown fields to 0 and added support
|
||||
for iff imagetype. (Marcus)
|
||||
iff imagetype. (Marcus)
|
||||
- Added runtime Apache2 thread check to ensure we don't run a non-threaded
|
||||
PHP inside a threaded Apache2 MPM. (Rasmus)
|
||||
- Made getimagesize() and exif_read_data() to return also the mime-type and
|
||||
@@ -627,9 +70,13 @@ PHP 4 NEWS
|
||||
response code. (Derick)
|
||||
- Changed the order of which modules are unloaded to the reverse order of
|
||||
which they were loaded. (Derick, Zend Engine)
|
||||
- Fixed a crash in ereg_replace() when backreference number was greater
|
||||
than the number of subpatterns. (oliver@billix.franken.de)
|
||||
- Added preliminary SAX-Input support. It's now possible to build a DomDocument
|
||||
with SAX-Events. (chregu)
|
||||
- Bundled GD library 2.0.1 with php (ext/gd/libgd) (Rasmus, Jani, Markus, Edin)
|
||||
- Fixed bug with Apache which let PHP_AUTH_* variables to be set when
|
||||
external basic auth mechanism was used. (Jani)
|
||||
- Fixed bzopen() crash in thread-safe mode. (Andrei)
|
||||
- Added better error-messages (3rd parameter) and validating of DTDs (2nd
|
||||
parameter) to domxml_open_mem() and domxml_open_file(). (Christian)
|
||||
@@ -647,7 +94,10 @@ PHP 4 NEWS
|
||||
the unix socket location. (e.g. NFS compiles, etc.) (James Cox)
|
||||
- Fixed is_a() to properly work on extension registered classes. (Andrei)
|
||||
- Added new constants: PHP_PREFIX and PHP_SHLIB_SUFFIX. (Stig)
|
||||
- Added STDIN, STDOUT and STDERR constants for CLI sapi reflecting opened
|
||||
streams to their respective I/O counterparts. (Edin)
|
||||
- Added pctnl_alarm() function. (Edin)
|
||||
- Fixed array_rand() on thread-safe platforms such as Windows. (Edin)
|
||||
- If zlib.output_compression is enabled and a page is compressed
|
||||
a "Vary: Accept-Encoding" header is now added. (Stefan)
|
||||
- Renamed getallheaders() to apache_request_headers() and kept getallheaders()
|
||||
@@ -683,6 +133,7 @@ PHP 4 NEWS
|
||||
when dealing with built-in extensions. (Sebastian)
|
||||
- Added large OID value (2^31 to 2^32) support for pg_lo_import(),
|
||||
pg_lo_unlink(), pg_lo_open() and pg_lo_export(). (Yasuo)
|
||||
- Changed the mbstring extension to be enabled by default. (Yasuo)
|
||||
- Fixed mixing OCIPlogon() and OCINLogon() to not leak Oracle-Sessions. (Thies)
|
||||
- Added php.ini options for EXIF extension to encode and decode Unicode/JIS
|
||||
user comments. (Marcus)
|
||||
@@ -691,6 +142,8 @@ PHP 4 NEWS
|
||||
- Added version information to the .dll and .exe files created under Windows.
|
||||
(jtate)
|
||||
- Added __FUNCTION__ and __CLASS__ constants. (Jani, Zend Engine)
|
||||
- Added pg_metadate(), pg_convert(), pg_insert(), pg_select(), pg_update()
|
||||
and pg_delete(). (Yasuo)
|
||||
- Added optional 2nd parameter for pg_result_status() to specify return type.
|
||||
(Yasuo)
|
||||
- Added "log_errors_max_len" php.ini option which controls maximum length for
|
||||
@@ -708,6 +161,23 @@ PHP 4 NEWS
|
||||
available at http://www.jtatesoftware.com/cracklib/. (jtate)
|
||||
- Added mysql_info() function. (Jan)
|
||||
- Added mysql_list_processes() and mysql_stat() functions. (Georg)
|
||||
- Added file_get_contents() which returns the contents of a file as a string.
|
||||
This function also supports the URL wrappers. (Wez)
|
||||
- Changed 'zlib:' fopen wrapper to 'compress.zlib://' to avoid ambiguities
|
||||
when filenames have ':' characters. (Wez)
|
||||
- Added URL-wrapper support to exif. (Marcus)
|
||||
- PHP now has a new stream system that allows it to do some clever stuff with
|
||||
fopen() and fsockopen(). As a result:
|
||||
. URL wrappers natively supports https:// URLs
|
||||
. fsockopen() adds support for ssl:// and tls:// connections via TCP/IP
|
||||
. copy($srcfilename, $destfilename) can now be used with URL wrappers
|
||||
. zlib wrappers/streams can be used even on systems without fopencookie()
|
||||
. Added 'compress.bzip2://' stream and wrapper support.
|
||||
. Added user-space streams - it is now possible to define a class in PHP
|
||||
code and register it as a URL wrapper.
|
||||
. Most extensions now support streams when passing files, which means
|
||||
that those extensions will support URL wrappers. (Wez)
|
||||
. Added memory stream support. (Marcus)
|
||||
- Fixed memory allocation problem on systems that have iconv() support in libc.
|
||||
(Yasuo)
|
||||
- Made var_dump() handle recursive structures better. (Yasuo, Derick)
|
||||
@@ -717,46 +187,6 @@ PHP 4 NEWS
|
||||
dependencies. Automake is only needed for its aclocal tool. The build
|
||||
process is now more portable and less resource-consuming. (Sascha)
|
||||
|
||||
06 Sep 2002, Version 4.2.3
|
||||
- Disabled the fifth parameter in mail() when safe-mode is turned on. (Derick)
|
||||
- Enable UTF8 modifier support for PCRE on win32. (Wez, Edin)
|
||||
- Enabled strcoll() on win32. (Markus)
|
||||
- Fixed possible ASCII control char injection in mail(). (Stefan Esser)
|
||||
- Fixed a potential crash bug in import_request_variables() (Zeev)
|
||||
- Fixed several problems with directory functions on Windows. (Steph)
|
||||
- Fixed xbithack bug in Apache module. (Rasmus)
|
||||
- Fixed a bug that prevented touch() from working on various platforms. (Steph)
|
||||
- Fixed ob_gzhandler()'s handling of requests that do have the Accept-Encoding
|
||||
header, but do not allow compression. (Zeev)
|
||||
- Fixed several bugs in the multithreaded version that could cause random parse
|
||||
errors, especially on machines with multiple CPUs. (Zeev, Zend Engine)
|
||||
- Fixed a build problem in bcmath. (Alan)
|
||||
- Fixed several bzip2 issues. (Andrei, kalowsky)
|
||||
- Fixed several COM issues. (Harald)
|
||||
- Various exif fixes. (Marcus)
|
||||
- Fixed domxml_xslt_process() and domxml_get_element_by_id() and several
|
||||
other issues in DOMXML. (Christian)
|
||||
- Fixed DOMXML crash on removing previously created attributes. (Christian)
|
||||
- Fixed crash when converting $GLOBALS to an object. (Zeev, Zend Engine)
|
||||
- Fixed ImageCreateFromGD2Part() (Jani)
|
||||
- Fixed a build issue in the IMAP extension under IRIX. (kalowsky)
|
||||
- Fixed a bug in imap_last_error() (Jani)
|
||||
- Various mbstring fixes. (Yasuo, Rui)
|
||||
- Fixed a build problem in the mcal extension. (Jani)
|
||||
- Made MySQL rollback open transactions when the request ends. (Georg)
|
||||
- Fixed a crash in the shutdown order of the ODBC module. (kalowsky)
|
||||
- Fixed PCRE build problems. (troels@arvin.dk)
|
||||
- Fixed a crash in pg_lo_write() (Yasuo)
|
||||
- Fixed posix_isatty() and posix_ttyname(). (Markus)
|
||||
- Fixed accidental pg_lo_import() API change. (Yasuo)
|
||||
- Fixed ereg_replace() crash when the backreference number was greater than the
|
||||
number of captured subpatterns. (oliver@billix.franken.de)
|
||||
- Fixed array_rand() on thread-safe platforms such as Windows. (Edin)
|
||||
- Report the right exit code after a call to exit(). (Edin)
|
||||
|
||||
22 Jul 2002, Version 4.2.2
|
||||
- Fixed serious security vulnerability. (Stefan Esser)
|
||||
|
||||
13 May 2002, Version 4.2.1
|
||||
- Added safe-mode checks to show_source(), parse_ini_file() and rmdir(). Also
|
||||
fixed security problems with safe_mode_include_dir directive. (Rasmus)
|
||||
@@ -810,7 +240,8 @@ PHP 4 NEWS
|
||||
shell scripts. Some of the differences to CGI sapi are: no HTTP headers,
|
||||
plain text error messages, does not change working directory, have a new -r
|
||||
option which executes a piece of PHP code directly from the commmand line, etc.
|
||||
(Edin)
|
||||
"make install" will install CLI SAPI version of php in {PREFIX}/bin/php while
|
||||
CGI is renamed and installed as {PREFIX}/bin/php-cgi. (Edin)
|
||||
- Fixed HTTP file upload support to handle big files better. (Jani)
|
||||
- Major modifications to the Sockets Extension and its API (Jason):
|
||||
. Fixed numerous bugs.
|
||||
|
||||
+5
-5
@@ -7,9 +7,9 @@ WHAT IT IS
|
||||
|
||||
HOW TO USE IT
|
||||
|
||||
Very simple. First, change to the ext/ directory of the PHP 4 sources. If
|
||||
you just need the basic framework and will be writing all the code in your
|
||||
functions yourself, you can now do
|
||||
Very simple. First, cd do directory ext/ in PHP 4 sources. If you just need
|
||||
the basic framework and will be writing all the code in your functions
|
||||
yourself, you can now do
|
||||
|
||||
./ext_skel --extname=module_name
|
||||
|
||||
@@ -22,7 +22,7 @@ HOW TO USE IT
|
||||
If you don't need to test the existence of any external header files,
|
||||
libraries or functions in them, the module is already almost ready to be
|
||||
compiled in PHP. Just remove 3 comments in your_module_name/config.m4,
|
||||
change back up to PHP sources top directory, and do
|
||||
cd back up to PHP sources top directory, and do
|
||||
|
||||
./buildconf; ./configure --enable-module_name; make
|
||||
|
||||
@@ -38,7 +38,7 @@ HOW TO USE IT
|
||||
FORMAT OF FUNCTION DEFINITIONS FILE
|
||||
|
||||
All the definitions must be on one line. In it's simplest form, it's just
|
||||
the function name, e.g.
|
||||
the function name, ie.
|
||||
|
||||
my_function
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ and not output any error messages.
|
||||
Both functions return SUCCESS or FAILURE depending on the result.
|
||||
|
||||
The auto-conversions are performed as necessary. Arrays, objects, and
|
||||
resources cannot be auto-converted.
|
||||
resources cannot be autoconverted.
|
||||
|
||||
|
||||
Type specifiers
|
||||
|
||||
@@ -4,7 +4,7 @@ $Id$
|
||||
HOW TO CREATE A SELF-CONTAINED PHP EXTENSION
|
||||
|
||||
A self-contained extension can be distributed independently of
|
||||
the PHP source. To create such an extension, two things are
|
||||
the PHP source. To create such an extension, three things are
|
||||
required:
|
||||
|
||||
- Configuration file (config.m4)
|
||||
@@ -115,9 +115,8 @@ CREATING SOURCE FILES
|
||||
|
||||
CREATING THE SELF-CONTAINED EXTENSION
|
||||
|
||||
Put config.m4 and the source files into one directory. Then, run phpize
|
||||
(this is installed during make install by PHP 4.0).
|
||||
|
||||
Put config.m4 and the source files into one directory. Afterwards,
|
||||
run phpize (this is installed during make install by PHP 4.0).
|
||||
For example, if you configured PHP with --prefix=/php, you would run
|
||||
|
||||
$ /php/bin/phpize
|
||||
|
||||
+8
-14
@@ -2,17 +2,13 @@ An Overview of the PHP Streams abstraction
|
||||
==========================================
|
||||
$Id$
|
||||
|
||||
WARNING: some prototypes in this file are out of date.
|
||||
The information contained here is being integrated into
|
||||
the PHP manual - stay tuned...
|
||||
|
||||
Please send comments to: Wez Furlong <wez@thebrainroom.com>
|
||||
|
||||
Why Streams?
|
||||
============
|
||||
You may have noticed a shed-load of issock parameters flying around the PHP
|
||||
code; we don't want them - they are ugly and cumbersome and force you to
|
||||
special case sockets and files every time you need to work with a "user-level"
|
||||
special case sockets and files everytime you need to work with a "user-level"
|
||||
PHP file pointer.
|
||||
Streams take care of that and present the PHP extension coder with an ANSI
|
||||
stdio-alike API that looks much nicer and can be extended to support non file
|
||||
@@ -28,8 +24,6 @@ The main functions are:
|
||||
PHPAPI size_t php_stream_read(php_stream * stream, char * buf, size_t count);
|
||||
PHPAPI size_t php_stream_write(php_stream * stream, const char * buf, size_t
|
||||
count);
|
||||
PHPAPI size_t php_stream_printf(php_stream * stream TSRMLS_DC,
|
||||
const char * fmt, ...);
|
||||
PHPAPI int php_stream_eof(php_stream * stream);
|
||||
PHPAPI int php_stream_getc(php_stream * stream);
|
||||
PHPAPI char *php_stream_gets(php_stream * stream, char *buf, size_t maxlen);
|
||||
@@ -39,7 +33,7 @@ PHPAPI int php_stream_seek(php_stream * stream, off_t offset, int whence);
|
||||
PHPAPI off_t php_stream_tell(php_stream * stream);
|
||||
|
||||
These (should) behave in the same way as the ANSI stdio functions with similar
|
||||
names: fread, fwrite, fprintf, feof, fgetc, fgets, fclose, fflush, fseek, ftell.
|
||||
names: fread, fwrite, feof, fgetc, fgets, fclose, fflush, fseek, ftell.
|
||||
|
||||
Opening Streams
|
||||
===============
|
||||
@@ -140,7 +134,7 @@ make_seekable will always set newstream to be the stream that is valid
|
||||
if the function succeeds.
|
||||
When you have finished, remember to close the stream.
|
||||
|
||||
NOTE: If you only need to seek forward, there is no need to call this
|
||||
NOTE: If you only need to seek forwards, there is no need to call this
|
||||
function, as the php_stream_seek can emulate forward seeking when the
|
||||
whence parameter is SEEK_CUR.
|
||||
|
||||
@@ -190,7 +184,7 @@ If your system has the fopencookie function, php streams can synthesize a
|
||||
FILE* on top of any stream, which is useful for SSL sockets, memory based
|
||||
streams, data base streams etc. etc.
|
||||
|
||||
In situations where this is not desirable, you should query the stream
|
||||
In situations where this is not desireable, you should query the stream
|
||||
to see if it naturally supports FILE *. You can use this code snippet
|
||||
for this purpose:
|
||||
|
||||
@@ -284,7 +278,7 @@ Writing your own stream implementation
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
RULE #1: when writing your own streams: make sure you have configured PHP with
|
||||
--enable-debug.
|
||||
I've taken some great pains to hook into the Zend memory manager to help track
|
||||
I've taken some great pains to hook into the zend memory manager to help track
|
||||
down allocation problems. It will also help you spot incorrect use of the
|
||||
STREAMS_DC, STREAMS_CC and the semi-private STREAMS_REL_CC macros for function
|
||||
definitions.
|
||||
@@ -297,7 +291,7 @@ be more up to date than these docs :-)
|
||||
First, you need to figure out what data you need to associate with the
|
||||
php_stream. For example, you might need a pointer to some memory for memory
|
||||
based streams, or if you were making a stream to read data from an RDBMS like
|
||||
MySQL, you might want to store the connection and rowset handles.
|
||||
mysql, you might want to store the connection and rowset handles.
|
||||
|
||||
The stream has a field called abstract that you can use to hold this data.
|
||||
If you need to store more than a single field of data, define a structure to
|
||||
@@ -327,7 +321,7 @@ Once you have that part figured out, you can write your implementation and
|
||||
define the your own php_stream_ops struct (we called it my_ops in the above
|
||||
example).
|
||||
|
||||
For example, for reading from this weird MySQL stream:
|
||||
For example, for reading from this wierd mysql stream:
|
||||
|
||||
static size_t php_mysqlop_read(php_stream * stream, char * buf, size_t count)
|
||||
{
|
||||
@@ -356,7 +350,7 @@ are all mandatory. The rest are optional. Declare your stream ops struct:
|
||||
php_stream_ops my_ops = {
|
||||
php_mysqlop_write, php_mysqlop_read, php_mysqlop_close,
|
||||
php_mysqlop_flush, NULL, NULL, NULL,
|
||||
"Strange MySQL example"
|
||||
"Strange mySQL example"
|
||||
}
|
||||
|
||||
Thats it!
|
||||
|
||||
@@ -66,8 +66,8 @@ Check list for submitting patch
|
||||
-------------------------------
|
||||
- Did you run "make test" to check if your patch didn't break
|
||||
other features?
|
||||
- Did you compile PHP with --enable-debug and check the PHP and
|
||||
web server error logs when you test your patch?
|
||||
- Did you compile PHP with --enable-debug and check php/webserver
|
||||
error logs when you test your patch?
|
||||
- Did you build PHP for multi-threaded web servers. (Optional)
|
||||
- Did you create test script for "make test"? (Recommended)
|
||||
- Did you check your patch is unified format and it does not
|
||||
@@ -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.
|
||||
|
||||
|
||||
+89
-221
@@ -14,23 +14,22 @@ Usage:
|
||||
make test
|
||||
|
||||
"make test" basically executes "run-tests.php" script
|
||||
under the source root (parallel builds will not work). Therefore you
|
||||
can execute the script as follows:
|
||||
under source root. Therefore you can execute the script
|
||||
as follows
|
||||
|
||||
./sapi/cli/php -c /path/to/php.ini/ run-tests.php [ext/some_extension_name]
|
||||
|
||||
TEST_PHP_EXECUTABLE=sapi/cli/php \
|
||||
sapi/cli/php [-c /path/to/php.ini] run-tests.php [ext/foo/tests/GLOB]
|
||||
|
||||
|
||||
[Which "php" executable "make test" look for]
|
||||
---------------------------------------------
|
||||
You must use TEST_PHP_EXECUTABLE environment variable to explicitly
|
||||
select the php executable to be used to run the tests. That can either
|
||||
be the CLI or CGI executable.
|
||||
|
||||
"make test" executes "run-tests.php" script with "php" binary. Some
|
||||
test scripts such as session must be executed by CGI SAPI. Therefore,
|
||||
you must build PHP with CGI SAPI to perform all tests.
|
||||
|
||||
If PHP is not build with CGI SAPI, "run-tests.php" script uses CLI
|
||||
SAPI. Tests that may not executed by CLI SAPI will be skipped.
|
||||
|
||||
NOTE: PHP binary executing "run-tests.php" and php binary used for
|
||||
executing test scripts may differ. If you use different PHP binary for
|
||||
executing "run-tests.php" script, you may get errors.
|
||||
@@ -38,248 +37,117 @@ executing "run-tests.php" script, you may get errors.
|
||||
|
||||
[Which php.ini is used]
|
||||
-----------------------
|
||||
"make test" uses the same php.ini file as it would once installed.
|
||||
The tests have been written to be independent of that php.ini file,
|
||||
so if you find a test that is affected by a setting, please report
|
||||
this, so we can address the issue.
|
||||
"make test" force to use php.ini-dist as default config file. If
|
||||
you would like to test with other configuration file, user
|
||||
"run-tests.php" script.
|
||||
|
||||
Example:
|
||||
./sapi/cli/php -c /path/to/php.ini/ ext/standard
|
||||
|
||||
If you use php.ini other than php.ini-dist, you may see more failed
|
||||
tests.
|
||||
|
||||
|
||||
[Which test scripts are executed]
|
||||
---------------------------------
|
||||
"run-tests.php" ("make test"), without any arguments executes all
|
||||
test scripts by extracting all directories named "tests"
|
||||
from the source root and any subdirectories below. If there are files,
|
||||
which have a "phpt" extension, "run-tests.php" looks at the sections
|
||||
in these files, determines whether it should run it, by evaluating
|
||||
the 'SKIP' section. If the test is eligible for execution, the 'FILE'
|
||||
section is extracted into a ".php" file (with the same name besides
|
||||
the extension) and gets executed.
|
||||
When an argument is given or TESTS environment variable is set, the
|
||||
GLOB is expanded by the shell and any file with extension "*.phpt" is
|
||||
regarded as a test file.
|
||||
"run-tests.php" ("make test") executes all test scripts by default
|
||||
by looking all directory named "tests". If there are files have "phpt"
|
||||
extension, "run-tests.php" takes test php code from the file and
|
||||
executes it.
|
||||
|
||||
Tester can easily execute tests selectively with as follows.
|
||||
Tester can easily executes tests selectively with as follows.
|
||||
|
||||
Examples:
|
||||
./sapi/cli/php run-tests.php ext/mbstring/*
|
||||
./sapi/cli/php run-tests.php ext/mbstring/020.phpt
|
||||
Example:
|
||||
./sapi/cli/php -c /path/to/php.ini/ run-tests.php ext/mbstring
|
||||
|
||||
|
||||
[Test results]
|
||||
--------------
|
||||
Test results are printed to standard output. If there is a failed test,
|
||||
the "run-tests.php" script saves the result, the expected result and the
|
||||
code executed to the test script directory. For example, if
|
||||
ext/myext/tests/myext.phpt fails to pass, the following files are created:
|
||||
"run-tests.php" script saves the result, expected result and code
|
||||
executed to the test script directory. For example, if
|
||||
ext/myext/tests/myext.phpt is failed to pass, following files are
|
||||
created:
|
||||
|
||||
ext/myext/tests/myext.php - actual test file executed
|
||||
ext/myext/tests/myext.log - log of test execution (L)
|
||||
ext/myext/tests/myext.exp - expected output (E)
|
||||
ext/myext/tests/myext.out - output from test script (O)
|
||||
ext/myext/tests/myext.diff - diff of .out and .exp (D)
|
||||
ext/myext/tests/myext.out - output from test script
|
||||
ext/myext/tests/myext.exp - expected output
|
||||
ext/myext/tests/myext.php - test script executed
|
||||
|
||||
Failed tests are always bugs. Either the test is bugged or not considering
|
||||
factors applying to the tester's environment, or there is a bug in PHP.
|
||||
If this is a known bug, we strive to provide bug numbers, in either the
|
||||
test name or the file name. You can check the status of such a bug, by
|
||||
going to: http://bugs.php.net/12345 where 12345 is the bug number.
|
||||
For clarity and automated processing, bug numbers are prefixed by a hash
|
||||
sign '#' in test names and/or test cases are named bug12345.phpt.
|
||||
|
||||
NOTE: The files generated by tests can be selected by setting the
|
||||
environment variable TEST_PHP_LOG_FORMAT. For each file you want to be
|
||||
generated use the character in brackets as shown above (default is LEOD).
|
||||
The php file will be generated always.
|
||||
|
||||
NOTE: You can set environment variable TEST_PHP_DETAILED to enable
|
||||
detailed test information.
|
||||
|
||||
[Automated testing]
|
||||
If you like to keep up to speed, with latest developments and quality
|
||||
assurance, setting the environment variable NO_INTERACTION to 1, will not
|
||||
prompt the tester for any user input.
|
||||
|
||||
Normally, the exit status of "make test" is zero, regardless of the results
|
||||
of independent tests. Set the environment variable REPORT_EXIT_STATUS to 1,
|
||||
and "make test" will set the exit status ("$?") to non-zero, when an
|
||||
individual test has failed.
|
||||
|
||||
Example script to be run by cron(1):
|
||||
========== qa-test.sh =============
|
||||
#!/bin/sh
|
||||
|
||||
CO_DIR=$HOME/cvs/php4
|
||||
MYMAIL=qa-test@domain.com
|
||||
TMPDIR=/var/tmp
|
||||
TODAY=`date +"%Y%m%d"`
|
||||
|
||||
# Make sure compilation enviroment is correct
|
||||
CONFIGURE_OPTS='--disable-all --enable-cli --with-pcre'
|
||||
export MAKE=gmake
|
||||
export CC=gcc
|
||||
|
||||
# Set test environment
|
||||
export NO_INTERACTIVITY=1
|
||||
export REPORT_EXIT_STATUS=1
|
||||
|
||||
cd $CO_DIR
|
||||
cvs update . >>$TMPDIR/phpqatest.$TODAY
|
||||
./cvsclean ; ./buildconf ; ./configure $CONFIGURE_OPTS ; $MAKE
|
||||
$MAKE test >>$TMPDIR/phpqatest.$TODAY 2>&1
|
||||
if test $? -gt 0
|
||||
then
|
||||
cat $TMPDIR/phpqatest.$TODAY | mail -s"PHP-QA Test Failed for $TODAY" $MYMAIL
|
||||
fi
|
||||
========== end of qa-test.sh =============
|
||||
|
||||
NOTE: the exit status of run-tests.php will be 1 when
|
||||
REPORT_EXIT_STATUS is set. The result of "make test" may be higher
|
||||
than that. At present, gmake 3.79.1 returns 2, so it is
|
||||
advised to test for non-zero, rather then a specific value.
|
||||
Tester can verify these files, if failed test is actually a bug
|
||||
or not.
|
||||
|
||||
|
||||
[Creating new test files]
|
||||
-------------------------
|
||||
Writing test file is very easy if you are used to PHP.
|
||||
Writing test file is very easy if you are used to PHP. Test file
|
||||
has following format. Here is a actual test file from iconv module.
|
||||
|
||||
Here is an actual test file from standard module.
|
||||
|
||||
===== ext/standard/tests/strings/strtr.phpt =======
|
||||
===== ext/iconv/002.phpt =======
|
||||
--TEST--
|
||||
strtr() function
|
||||
--FILE--
|
||||
<?php
|
||||
/* Do not change this test it is a REATME.TESTING example. */
|
||||
$trans = array("hello"=>"hi", "hi"=>"hello", "a"=>"A", "world"=>"planet");
|
||||
var_dump(strtr("# hi all, I said hello world! #", $trans));
|
||||
?>
|
||||
--EXPECT--
|
||||
string(32) "# hello All, I sAid hi planet! #"
|
||||
===== ext/standard/tests/strings/strtr.phpt =======
|
||||
|
||||
As you can see the file is devided into several sections. Below is a
|
||||
list of all possible sections:
|
||||
|
||||
"--TEST--" is title of the test (required).
|
||||
"--SKIPIF--" is condition when to skip this test (optional).
|
||||
"--POST--" is POST variable passed to test script (optional).
|
||||
"--GET--" is GET variable passed to test script (optional).
|
||||
"--INI--" each line contains an ini setting e.g. foo=bar (optional).
|
||||
"--FILE--" is the test script (required).
|
||||
"--EXPECT--" is the expected output from the test script (required).
|
||||
"--EXPECTF--" is an alternative of --EXPECT--. The difference is that
|
||||
this form uses sscanf for output validation (alternative).
|
||||
"--EXPECTREGEX--" is an alternative of --EXPECT--. This form allows the tester
|
||||
to specify the result in a regular expression (alternative).
|
||||
|
||||
A test must at least contain the sections TEST, FILE and either EXPECT
|
||||
or EXPECTF. When a test is called run-test.php takes the name from the
|
||||
TEST section and writes the FILE section into a ".php" file with the
|
||||
same name as the ".phpt" file. This ".php" file will then be executed
|
||||
and its output compared to the contents of the EXPECT section. It is a
|
||||
good idea to generate output with var_dump() calls.
|
||||
|
||||
/ext/standard/tests/strings/str_shuffle.phpt is a good example for using
|
||||
EXPECTF instead of EXPECT. From time to time the algorithm used for shuffle
|
||||
changed and sometimes the machine used to execute the code has influence
|
||||
on the result of shuffle. But it always returns a three character string
|
||||
detectable by %s. Other scan-able forms are %i for integers, %d for numbers
|
||||
only, %f for floating point values, %c for single characters and %x for
|
||||
hexadecimal values.
|
||||
|
||||
==== /ext/standard/tests/strings/str_shuffle.phpt ===
|
||||
--TEST--
|
||||
Testing str_shuffle.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Do not change this test it is a REATME.TESTING example. */
|
||||
$s = '123';
|
||||
var_dump(str_shuffle($s));
|
||||
var_dump($s);
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(3) %s
|
||||
string(3) "123"
|
||||
==== end of /ext/standard/tests/strings/str_shuffle.phpt ===
|
||||
|
||||
/ext/standard/tests/strings/strings001.phpt is a good example for using
|
||||
EXPECTREGEX instead of EXPECT. This test also shows that in EXPECTREGEX
|
||||
some characters need to be escaped since otherwise they would be
|
||||
interpreted as a regular expression.
|
||||
|
||||
==== /ext/standard/tests/strings/strings001.phpt ===
|
||||
--TEST--
|
||||
Test whether strstr() and strrchr() are binary safe.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Do not change this test it is a REATME.TESTING example. */
|
||||
$s = "alabala nica".chr(0)."turska panica";
|
||||
var_dump(strstr($s, "nic"));
|
||||
var_dump(strrchr($s," nic"));
|
||||
?>
|
||||
--EXPECTREGEX--
|
||||
string\(18\) \"nica\x00turska panica\"
|
||||
string\(19\) \" nica\x00turska panica\"
|
||||
==== end of /ext/standard/tests/strings/strings001.phpt ===
|
||||
|
||||
Some tests depend on modules or functions available only in certain versions
|
||||
or they even require minimum version of php or zend. These tests should be
|
||||
skipped when the requirement cannot be fullfilled. To achieve this you can
|
||||
use the SKIPIF section. To tell run-test.php that your test should be skipped
|
||||
the SKIPIF section must print out the word "skip" followed by a reason why
|
||||
the test should skip.
|
||||
|
||||
==== /ext/exif/tests/exif005.phpt ===
|
||||
--TEST--
|
||||
Check for exif_read_data, unusual IFD start
|
||||
UCS4BE to ASCII
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('exif')) print 'skip exif extension not available';
|
||||
?>
|
||||
<?php include('skipif.inc'); ?>
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php
|
||||
/* Do not change this test it is a REATME.TESTING example.
|
||||
* test5.jpg is a 1*1 image that contains an Exif section with ifd = 00000009h
|
||||
*/
|
||||
$image = exif_read_data('./ext/exif/tests/test5.jpg','',true,false);
|
||||
var_dump($image['IFD0']);
|
||||
?>
|
||||
<?php include('002.inc'); ?>
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
["ImageDescription"]=>
|
||||
string(11) "Ifd00000009"
|
||||
["DateTime"]=>
|
||||
string(19) "2002:10:18 20:06:00"
|
||||
abcd
|
||||
abcd
|
||||
===== end of ext/iconv/002.phpt =======
|
||||
|
||||
"--TEST--" is title of the test.
|
||||
"--SKIPIF--" is condition when to skip this test.
|
||||
"--POST--" is POST variable passed to test script.
|
||||
"--GET--" is GET variable passed to test script.
|
||||
"--FILE--" is the test script.
|
||||
"--EXPECT--" is the expected output from the test script.
|
||||
|
||||
ext/iconv/002.phpt uses 2 files. "skipif.inc" is used to skip
|
||||
test when test cannot be performed such as iconv module is not
|
||||
compiled or loaded.
|
||||
|
||||
==== ext/iconv/skipif.inc ====
|
||||
<?php
|
||||
// This script prints "skip" if condition does not meet.
|
||||
|
||||
if (!extension_loaded("iconv") && ini_get("enable_dl")) {
|
||||
$dlext = (substr(PHP_OS, 0, 3) == "WIN") ? ".dll" : ".so";
|
||||
@dl("iconv$dlext");
|
||||
}
|
||||
==== end of /ext/exif/tests/exif005.phpt ===
|
||||
if (!extension_loaded("iconv")) {
|
||||
die("skip\n");
|
||||
}
|
||||
?>
|
||||
==== end of ext/iconv/skipif.inc ====
|
||||
|
||||
Test script and SKIPIF code should be directly written into *.phpt. However,
|
||||
it is recommended to use include files when more test scripts depend on the
|
||||
same SKIPIF code or when certain test files need the same values for some
|
||||
input. But no file used by any test should have one of the following
|
||||
extensions: ".php", ".log", ".exp", ".out" or ".diff".
|
||||
ext/inconv/002.inc is the test script. "run-tests.php" script
|
||||
executes test script with CGI executable.
|
||||
|
||||
Tests should be named according to the following list:
|
||||
==== ext/iconv/002.inc ===
|
||||
<?php
|
||||
/*
|
||||
Expected output:
|
||||
abcd
|
||||
abcd
|
||||
*/
|
||||
|
||||
Class: Name: Example:
|
||||
Tests for bugs bug<bugid>.phpt bug17123.phpt
|
||||
Tests for functions <functionname>.phpt dba_open.phpt
|
||||
General tests for extensions <extname><no>.phpt dba3.phpt
|
||||
$s = unpack("V*", iconv("ascii","UCS-4LE", "abcd"));
|
||||
foreach($s as $c) { print "&#$c;"; } print "\n";
|
||||
|
||||
When you use an include file for the SKIPIF section it should be named
|
||||
"skipif.inc" and an include file used in the FILE section of many tests
|
||||
should be named "test.inc".
|
||||
$s = pack("NNNN", 97, 98, 99, 100);
|
||||
$q = iconv("UCS-4BE", "ascii", $s);
|
||||
print $q; print "\n";
|
||||
?>
|
||||
=== end of ext/iconv/002.inc ===
|
||||
|
||||
NOTE: All tests should run correctly with error_reporting(E_ALL) and
|
||||
display_errors=1. This is the default when called from run-test.php.
|
||||
If you have a good reason for lowering the error reporting, use --INI--
|
||||
section and comment this in your testcode.
|
||||
Test script and skipif code may be directly write into *.phpt.
|
||||
However, it is recommended to use other files for ease of writing
|
||||
test script. For instance, you can execute test script under
|
||||
ext/iconv as follows:
|
||||
|
||||
./sapi/cli/php -c /path/to/php.ini/ ext/iconv
|
||||
|
||||
NOTE: If your test intentionally generates a PHP warning message use
|
||||
$php_errormsg variable, which you can then output. This will result
|
||||
in a consistent error message output across all platforms and PHP
|
||||
configurations, preventing your test from failing due inconsistencies
|
||||
in the error message content.
|
||||
|
||||
[How to help us]
|
||||
----------------
|
||||
|
||||
@@ -2,7 +2,7 @@ PHP Build System V5 Overview
|
||||
|
||||
- supports Makefile.ins during transition phase
|
||||
- not-really-portable Makefile includes have been eliminated
|
||||
- supports separate build directories without VPATH by using
|
||||
- supports seperate build directories without VPATH by using
|
||||
explicit rules only
|
||||
- does not waste disk-space/CPU-time for building temporary libraries
|
||||
=> especially noticeable on slower systems
|
||||
@@ -50,8 +50,8 @@ are specified in the config.m4 now using the following macro:
|
||||
PHP_NEW_EXTENSION(foo, foo.c bar.c baz.cpp, $ext_shared)
|
||||
|
||||
E.g. this enables the extension foo which consists of three source-code
|
||||
modules, two in C and one in C++. And, depending on the user's wishes,
|
||||
the extension will even be built as a dynamic module.
|
||||
modules, two in C and one in C++. And dependending on the user's
|
||||
wishes, the extension will even be built as a dynamic module.
|
||||
|
||||
The full syntax:
|
||||
|
||||
|
||||
@@ -43,6 +43,10 @@ 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?)
|
||||
* Change the odbc_fetch_into() function to require ALWAYS the first two
|
||||
parameters ($conn_id and $array), and make the third (row) be optional.
|
||||
* Remove --with-openlink configure option (--with-iodbc replaces it).
|
||||
* Implement flush feature suitable for nested output buffers.
|
||||
|
||||
For PHP 5.0.0
|
||||
* bundle and use curl lib for fopen wrapper.
|
||||
@@ -66,7 +70,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
|
||||
@@ -98,16 +101,6 @@ ext/oci8
|
||||
* Make allow_call_time_pass_reference=Off working.
|
||||
* For additional todo information, see oci8.c, in ext/oci8
|
||||
|
||||
ext/odbc
|
||||
--------
|
||||
For PHP 4.3.0:
|
||||
* update all php_error calls to php_error_docref where valid
|
||||
* integrate EXPERIMENTAL ODBC update for use in PHP 5.0, use for
|
||||
testing purposes only.
|
||||
|
||||
For PHP 5.0.0
|
||||
* Activate EXPERIMENTAL ODBC codebase update
|
||||
|
||||
ext/pcre
|
||||
--------
|
||||
* Allow user to set PCRE_NOTEMPTY, PCRE_ANCHORED at execution time, maybe
|
||||
@@ -158,6 +151,8 @@ ext/standard
|
||||
basename()
|
||||
dirname()
|
||||
strrpos()
|
||||
strrchr()
|
||||
strip_tags()
|
||||
|
||||
ext/wddx
|
||||
--------
|
||||
|
||||
-146
@@ -1,146 +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)
|
||||
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 (7) (Marcus)
|
||||
|
||||
Open:
|
||||
|
||||
the dbase extension (1)
|
||||
chunk_split (2)
|
||||
socket_select (3)
|
||||
php_imagepolygon (4)
|
||||
imagesetstyle (5)
|
||||
bundled gd (6)
|
||||
php_base64_encode (8)
|
||||
pack (9)
|
||||
|
||||
(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) integer overflow in php_chunk_split
|
||||
|
||||
(3) 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
|
||||
|
||||
(4) integer overflow inside php_imagepolygon and possible subsequent
|
||||
integer overflows inside gdlib's gdImageFilledPolygon().
|
||||
|
||||
(5) integer overflow if the number of elements in the array passed as
|
||||
second argument * sizeof(int) result in an overflow.
|
||||
gdImageSetStyle function called by this php wrapper can die for the
|
||||
same reason.
|
||||
|
||||
(6) multiple integer overflows that can occur when trying to allocate a buffer
|
||||
for a new image. Affected functions:
|
||||
gdImageCreateFromJpegCtx
|
||||
readwbmp
|
||||
gdImageCreateFromXpm
|
||||
gdImageCreateFromPngCtx
|
||||
gdImagePngCtx
|
||||
gdImageCreateFromJpegCtx
|
||||
gdImageJpegCtx
|
||||
gdImageCreateFromGd2Ctx
|
||||
gdImageCreateFromGd2PartCtx
|
||||
_gdImageGd2
|
||||
GetDataBlock (gd_gif_in.c)
|
||||
|
||||
(7) few possible integer overflows, once safe_emalloc() or something similar
|
||||
is implemented they can all be addressed.
|
||||
|
||||
(8) integer overflow if the specified string is longer then ~1.1 billion bytes.
|
||||
|
||||
(9) multiple integer overflows, ex. pack("d4294967297", 2);
|
||||
|
||||
Ammendment 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' \
|
||||
"$@"
|
||||
|
||||
+15
-38
@@ -15,6 +15,7 @@
|
||||
#ifdef ZTS
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
@@ -79,7 +80,7 @@ static FILE *tsrm_error_file;
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define TSRM_ERROR(args)
|
||||
#define TSRM_ERROR
|
||||
#define TSRM_SAFE_RETURN_RSRC(array, offset, range) \
|
||||
if (offset==0) { \
|
||||
return &array; \
|
||||
@@ -95,10 +96,9 @@ static pthread_key_t tls_key;
|
||||
static int tls_key;
|
||||
#elif defined(TSRM_WIN32)
|
||||
static DWORD tls_key;
|
||||
#elif defined(BETHREADS)
|
||||
static int32 tls_key;
|
||||
#endif
|
||||
|
||||
|
||||
/* Startup TSRM (call once for the entire process) */
|
||||
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, char *debug_filename)
|
||||
{
|
||||
@@ -111,8 +111,6 @@ TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debu
|
||||
st_key_create(&tls_key, 0);
|
||||
#elif defined(TSRM_WIN32)
|
||||
tls_key = TlsAlloc();
|
||||
#elif defined(BETHREADS)
|
||||
tls_key = tls_allocate();
|
||||
#endif
|
||||
|
||||
tsrm_error_file = stderr;
|
||||
@@ -261,8 +259,6 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_
|
||||
st_thread_setspecific(tls_key, (void *) *thread_resources_ptr);
|
||||
#elif defined(TSRM_WIN32)
|
||||
TlsSetValue(tls_key, (void *) *thread_resources_ptr);
|
||||
#elif defined(BETHREADS)
|
||||
tls_set(tls_key, (void*) *thread_resources_ptr);
|
||||
#endif
|
||||
|
||||
if (tsrm_new_thread_begin_handler) {
|
||||
@@ -302,8 +298,6 @@ TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id)
|
||||
thread_resources = st_thread_getspecific(tls_key);
|
||||
#elif defined(TSRM_WIN32)
|
||||
thread_resources = TlsGetValue(tls_key);
|
||||
#elif defined(BETHREADS)
|
||||
thread_resources = (tsrm_tls_entry*)tls_get(tls_key);
|
||||
#else
|
||||
thread_resources = NULL;
|
||||
#endif
|
||||
@@ -430,8 +424,6 @@ TSRM_API THREAD_T tsrm_thread_id(void)
|
||||
return PIThread_getCurrent();
|
||||
#elif defined(TSRM_ST)
|
||||
return st_thread_self();
|
||||
#elif defined(BETHREADS)
|
||||
return find_thread(NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -439,18 +431,18 @@ TSRM_API THREAD_T tsrm_thread_id(void)
|
||||
/* Allocate a mutex */
|
||||
TSRM_API MUTEX_T tsrm_mutex_alloc(void)
|
||||
{
|
||||
MUTEX_T mutexp;
|
||||
MUTEX_T mutexp;
|
||||
#ifdef NETWARE
|
||||
long flags = 0; /* Don't require NX_MUTEX_RECURSIVE, I guess */
|
||||
NXHierarchy_t order = 0;
|
||||
NX_LOCK_INFO_ALLOC (lockInfo, "PHP-TSRM", 0);
|
||||
long flags = 0; /* Don't require NX_MUTEX_RECURSIVE, I guess */
|
||||
NXHierarchy_t order = 0;
|
||||
NX_LOCK_INFO_ALLOC (lockInfo, "PHP-TSRM", 0);
|
||||
#endif
|
||||
|
||||
#ifdef TSRM_WIN32
|
||||
mutexp = malloc(sizeof(CRITICAL_SECTION));
|
||||
mutexp = malloc(sizeof(CRITICAL_SECTION));
|
||||
InitializeCriticalSection(mutexp);
|
||||
#elif defined(NETWARE)
|
||||
mutexp = NXMutexAlloc(flags, order, &lockInfo); /* return value ignored for now */
|
||||
mutexp = NXMutexAlloc(flags, order, &lockInfo); /* return value ignored for now */
|
||||
#elif defined(GNUPTH)
|
||||
mutexp = (MUTEX_T) malloc(sizeof(*mutexp));
|
||||
pth_mutex_init(mutexp);
|
||||
@@ -463,22 +455,18 @@ TSRM_API MUTEX_T tsrm_mutex_alloc(void)
|
||||
mutexp = PIPlatform_allocLocalMutex();
|
||||
#elif defined(TSRM_ST)
|
||||
mutexp = st_mutex_new();
|
||||
#elif defined(BETHREADS)
|
||||
mutexp = (beos_ben*)malloc(sizeof(beos_ben));
|
||||
mutexp->ben = 0;
|
||||
mutexp->sem = create_sem(1, "PHP sempahore");
|
||||
#endif
|
||||
#ifdef THR_DEBUG
|
||||
printf("Mutex created thread: %d\n",mythreadid());
|
||||
printf("Mutex created thread: %d\n",mythreadid());
|
||||
#endif
|
||||
return( mutexp );
|
||||
return( mutexp );
|
||||
}
|
||||
|
||||
|
||||
/* Free a mutex */
|
||||
TSRM_API void tsrm_mutex_free(MUTEX_T mutexp)
|
||||
{
|
||||
if (mutexp) {
|
||||
if (mutexp) {
|
||||
#ifdef TSRM_WIN32
|
||||
DeleteCriticalSection(mutexp);
|
||||
#elif defined(NETWARE)
|
||||
@@ -494,13 +482,10 @@ TSRM_API void tsrm_mutex_free(MUTEX_T mutexp)
|
||||
PISync_delete(mutexp);
|
||||
#elif defined(TSRM_ST)
|
||||
st_mutex_destroy(mutexp);
|
||||
#elif defined(BETHREADS)
|
||||
delete_sem(mutexp->sem);
|
||||
free(mutexp);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef THR_DEBUG
|
||||
printf("Mutex freed thread: %d\n",mythreadid());
|
||||
printf("Mutex freed thread: %d\n",mythreadid());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -513,7 +498,7 @@ TSRM_API int tsrm_mutex_lock(MUTEX_T mutexp)
|
||||
EnterCriticalSection(mutexp);
|
||||
return 1;
|
||||
#elif defined(NETWARE)
|
||||
return NXLock(mutexp);
|
||||
return NXLock(mutexp);
|
||||
#elif defined(GNUPTH)
|
||||
return pth_mutex_acquire(mutexp, 0, NULL);
|
||||
#elif defined(PTHREADS)
|
||||
@@ -524,10 +509,6 @@ TSRM_API int tsrm_mutex_lock(MUTEX_T mutexp)
|
||||
return PISync_lock(mutexp);
|
||||
#elif defined(TSRM_ST)
|
||||
return st_mutex_lock(mutexp);
|
||||
#elif defined(BETHREADS)
|
||||
if (atomic_add(&mutexp->ben, 1) != 0)
|
||||
return acquire_sem(mutexp->sem);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -551,10 +532,6 @@ TSRM_API int tsrm_mutex_unlock(MUTEX_T mutexp)
|
||||
return PISync_unlock(mutexp);
|
||||
#elif defined(TSRM_ST)
|
||||
return st_mutex_unlock(mutexp);
|
||||
#elif defined(BETHREADS)
|
||||
if (atomic_add(&mutexp->ben, -1) != 1)
|
||||
return release_sem(mutexp->sem);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
-11
@@ -20,7 +20,6 @@
|
||||
|
||||
#ifdef WIN32
|
||||
# define TSRM_WIN32
|
||||
# include "tsrm_config.w32.h"
|
||||
#endif
|
||||
|
||||
#ifdef TSRM_WIN32
|
||||
@@ -47,9 +46,6 @@
|
||||
# include <pthread.h>
|
||||
#elif defined(TSRM_ST)
|
||||
# include <st.h>
|
||||
#elif defined(BETHREADS)
|
||||
#include <kernel/OS.h>
|
||||
#include <TLS.h>
|
||||
#endif
|
||||
|
||||
typedef int ts_rsrc_id;
|
||||
@@ -76,13 +72,6 @@ typedef int ts_rsrc_id;
|
||||
#elif defined(TSRM_ST)
|
||||
# define THREAD_T st_thread_t
|
||||
# define MUTEX_T st_mutex_t
|
||||
#elif defined(BETHREADS)
|
||||
# define THREAD_T thread_id
|
||||
typedef struct {
|
||||
sem_id sem;
|
||||
int32 ben;
|
||||
} beos_ben;
|
||||
# define MUTEX_T beos_ben *
|
||||
#endif
|
||||
|
||||
typedef void (*ts_allocate_ctor)(void *, void ***);
|
||||
|
||||
+19
-24
@@ -102,31 +102,26 @@ dnl -threads gcc (HP-UX)
|
||||
dnl
|
||||
AC_DEFUN(PTHREADS_CHECK,[
|
||||
|
||||
if test "$beos_threads" = "1"; then
|
||||
pthreads_working="yes"
|
||||
ac_cv_pthreads_cflags=""
|
||||
else
|
||||
save_CFLAGS=$CFLAGS
|
||||
save_LIBS=$LIBS
|
||||
PTHREADS_ASSIGN_VARS
|
||||
PTHREADS_CHECK_COMPILE
|
||||
LIBS=$save_LIBS
|
||||
CFLAGS=$save_CFLAGS
|
||||
save_CFLAGS=$CFLAGS
|
||||
save_LIBS=$LIBS
|
||||
PTHREADS_ASSIGN_VARS
|
||||
PTHREADS_CHECK_COMPILE
|
||||
LIBS=$save_LIBS
|
||||
CFLAGS=$save_CFLAGS
|
||||
|
||||
AC_CACHE_CHECK(for pthreads_cflags,ac_cv_pthreads_cflags,[
|
||||
ac_cv_pthreads_cflags=
|
||||
if test "$pthreads_working" != "yes"; then
|
||||
for flag in -kthread -pthread -pthreads -mthreads -Kthread -threads -mt -qthreaded; do
|
||||
ac_save=$CFLAGS
|
||||
CFLAGS="$CFLAGS $flag"
|
||||
PTHREADS_CHECK_COMPILE
|
||||
CFLAGS=$ac_save
|
||||
if test "$pthreads_working" = "yes"; then
|
||||
ac_cv_pthreads_cflags=$flag
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
AC_CACHE_CHECK(for pthreads_cflags,ac_cv_pthreads_cflags,[
|
||||
ac_cv_pthreads_cflags=
|
||||
if test "$pthreads_working" != "yes"; then
|
||||
for flag in -kthread -pthread -pthreads -mthreads -Kthread -threads -mt -qthreaded; do
|
||||
ac_save=$CFLAGS
|
||||
CFLAGS="$CFLAGS $flag"
|
||||
PTHREADS_CHECK_COMPILE
|
||||
CFLAGS=$ac_save
|
||||
if test "$pthreads_working" = "yes"; then
|
||||
ac_cv_pthreads_cflags=$flag
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
+8
-12
@@ -73,19 +73,15 @@ sinclude(TSRM/threads.m4)
|
||||
AC_DEFUN(TSRM_CHECK_PTHREADS,[
|
||||
|
||||
PTHREADS_CHECK
|
||||
|
||||
if test "$beos_threads" = "1"; then
|
||||
AC_DEFINE(BETHREADS, 1, Whether to use native BeOS threads)
|
||||
else
|
||||
if test "$pthreads_working" != "yes"; then
|
||||
AC_MSG_ERROR(Your system seems to lack POSIX threads.)
|
||||
fi
|
||||
|
||||
AC_DEFINE(PTHREADS, 1, Whether to use Pthreads)
|
||||
|
||||
AC_MSG_CHECKING(for POSIX threads)
|
||||
AC_MSG_RESULT(yes)
|
||||
|
||||
if test "$pthreads_working" != "yes"; then
|
||||
AC_MSG_ERROR(Your system seems to lack POSIX threads.)
|
||||
fi
|
||||
|
||||
AC_DEFINE(PTHREADS, 1, Whether to use Pthreads)
|
||||
|
||||
AC_MSG_CHECKING(for POSIX threads)
|
||||
AC_MSG_RESULT(yes)
|
||||
])
|
||||
|
||||
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
#define HAVE_UTIME 1
|
||||
#define HAVE_ALLOCA 1
|
||||
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
|
||||
#undef inline
|
||||
#ifdef ZEND_WIN32_FORCE_INLINE
|
||||
# define inline __forceinline
|
||||
|
||||
@@ -14,13 +14,15 @@
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_ALLOCA_H && !defined(_ALLOCA_H)
|
||||
# include <alloca.h>
|
||||
#ifdef TSRM_WIN32
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
/* AIX requires this to be the first thing in the file. */
|
||||
#ifndef __GNUC__
|
||||
# ifndef HAVE_ALLOCA_H
|
||||
# if HAVE_ALLOCA_H
|
||||
# include <alloca.h>
|
||||
# else
|
||||
# ifdef _AIX
|
||||
#pragma alloca
|
||||
# else
|
||||
|
||||
+1
-1
@@ -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
@@ -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 |
|
||||
|
||||
+108
-100
@@ -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 "tsrm_nw.h"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_REALPATH
|
||||
#define realpath(x,y) strcpy(y,x)
|
||||
#endif
|
||||
|
||||
#define VIRTUAL_CWD_DEBUG 0
|
||||
|
||||
#include "TSRM.h"
|
||||
@@ -284,7 +280,7 @@ CWD_API char *virtual_getcwd(char *buf, size_t size TSRMLS_DC)
|
||||
|
||||
/* Resolve path relatively to state and put the real path into state */
|
||||
/* returns 0 for ok, 1 for error */
|
||||
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath)
|
||||
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path)
|
||||
{
|
||||
int path_length = strlen(path);
|
||||
char *ptr, *path_copy;
|
||||
@@ -302,12 +298,9 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
|
||||
if (path_length == 0)
|
||||
return (0);
|
||||
|
||||
#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 && realpath(path, resolved_path)) {
|
||||
#if !defined(TSRM_WIN32) && !defined(__BEOS__) && !defined(NETWARE)
|
||||
if (IS_ABSOLUTE_PATH(path, path_length)) {
|
||||
if (realpath(path, resolved_path)) {
|
||||
path = resolved_path;
|
||||
path_length = strlen(path);
|
||||
}
|
||||
@@ -325,7 +318,7 @@ 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 (use_realpath && realpath(tmp, resolved_path)) {
|
||||
if (realpath(tmp, resolved_path)) {
|
||||
path = resolved_path;
|
||||
path_length = strlen(path);
|
||||
}
|
||||
@@ -340,7 +333,12 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
|
||||
fprintf(stderr,"cwd = %s path = %s\n", state->cwd, path);
|
||||
#endif
|
||||
if (IS_ABSOLUTE_PATH(path_copy, path_length)) {
|
||||
/* COPY_WHEN_ABSOLUTE needs to account for volume name that is unique to NetWare absolute paths */
|
||||
#ifndef NETWARE
|
||||
copy_amount = COPY_WHEN_ABSOLUTE;
|
||||
#else
|
||||
copy_amount = COPY_WHEN_ABSOLUTE(path_copy);
|
||||
#endif
|
||||
is_absolute = 1;
|
||||
#ifdef TSRM_WIN32
|
||||
} else if (IS_UNC_PATH(path_copy, path_length)) {
|
||||
@@ -366,64 +364,63 @@ 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);
|
||||
}
|
||||
|
||||
/* COPY_WHEN_ABSOLUTE needs to account for volume name that is unique to NetWare absolute paths */
|
||||
#ifndef NETWARE
|
||||
if (state->cwd_length == COPY_WHEN_ABSOLUTE) {
|
||||
#else
|
||||
if (state->cwd_length == COPY_WHEN_ABSOLUTE(state->cwd)) {
|
||||
#endif
|
||||
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)) {
|
||||
@@ -448,7 +445,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
|
||||
|
||||
CWD_API int virtual_chdir(const char *path TSRMLS_DC)
|
||||
{
|
||||
return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok, 1)?-1:0;
|
||||
return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok)?-1:0;
|
||||
}
|
||||
|
||||
CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path TSRMLS_DC) TSRMLS_DC)
|
||||
@@ -469,7 +466,12 @@ CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* COPY_WHEN_ABSOLUTE needs to account for volume name that is unique to NetWare absolute paths */
|
||||
#ifndef NETWARE
|
||||
if (length == COPY_WHEN_ABSOLUTE && IS_ABSOLUTE_PATH(path, length+1)) { /* Also use trailing slash if this is absolute */
|
||||
#else
|
||||
if (length == COPY_WHEN_ABSOLUTE(path) && IS_ABSOLUTE_PATH(path, length+1)) { /* Also use trailing slash if this is absolute */
|
||||
#endif
|
||||
length++;
|
||||
}
|
||||
temp = (char *) tsrm_do_alloca(length+1);
|
||||
@@ -489,7 +491,7 @@ CWD_API char *virtual_realpath(const char *path, char *real_path TSRMLS_DC)
|
||||
int retval;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
retval = virtual_file_ex(&new_state, path, NULL, 1);
|
||||
retval = virtual_file_ex(&new_state, path, NULL);
|
||||
|
||||
if (!retval) {
|
||||
int len = new_state.cwd_length>MAXPATHLEN-1?MAXPATHLEN-1:new_state.cwd_length;
|
||||
@@ -507,7 +509,7 @@ CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_f
|
||||
int retval;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
retval = virtual_file_ex(&new_state, path, verify_path, 1);
|
||||
retval = virtual_file_ex(&new_state, path, verify_path);
|
||||
|
||||
*filepath = new_state.cwd;
|
||||
|
||||
@@ -530,7 +532,7 @@ CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC)
|
||||
}
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, path, NULL, 1);
|
||||
virtual_file_ex(&new_state, path, NULL);
|
||||
|
||||
f = fopen(new_state.cwd, mode);
|
||||
|
||||
@@ -538,24 +540,6 @@ CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC)
|
||||
return f;
|
||||
}
|
||||
|
||||
#if !defined(TSRM_WIN32)
|
||||
CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC)
|
||||
{
|
||||
cwd_state new_state;
|
||||
int ret;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, pathname, NULL, 1);
|
||||
|
||||
ret = access(new_state.cwd, mode);
|
||||
|
||||
CWD_STATE_FREE(&new_state);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if HAVE_UTIME
|
||||
CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC)
|
||||
{
|
||||
@@ -563,7 +547,7 @@ CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC)
|
||||
int ret;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, filename, NULL, 0);
|
||||
virtual_file_ex(&new_state, filename, NULL);
|
||||
|
||||
ret = utime(new_state.cwd, buf);
|
||||
|
||||
@@ -578,7 +562,7 @@ CWD_API int virtual_chmod(const char *filename, mode_t mode TSRMLS_DC)
|
||||
int ret;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, filename, NULL, 1);
|
||||
virtual_file_ex(&new_state, filename, NULL);
|
||||
|
||||
ret = chmod(new_state.cwd, mode);
|
||||
|
||||
@@ -593,7 +577,7 @@ CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group TSRMLS_
|
||||
int ret;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, filename, NULL, 0);
|
||||
virtual_file_ex(&new_state, filename, NULL);
|
||||
|
||||
ret = chown(new_state.cwd, owner, group);
|
||||
|
||||
@@ -608,7 +592,7 @@ CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...)
|
||||
int f;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, path, NULL, 1);
|
||||
virtual_file_ex(&new_state, path, NULL);
|
||||
|
||||
if (flags & O_CREAT) {
|
||||
mode_t mode;
|
||||
@@ -632,7 +616,7 @@ CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC)
|
||||
int f;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, path, NULL, 1);
|
||||
virtual_file_ex(&new_state, path, NULL);
|
||||
|
||||
f = creat(new_state.cwd, mode);
|
||||
|
||||
@@ -647,11 +631,11 @@ CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC)
|
||||
int retval;
|
||||
|
||||
CWD_STATE_COPY(&old_state, &CWDG(cwd));
|
||||
virtual_file_ex(&old_state, oldname, NULL, 0);
|
||||
virtual_file_ex(&old_state, oldname, NULL);
|
||||
oldname = old_state.cwd;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, newname, NULL, 0);
|
||||
virtual_file_ex(&new_state, newname, NULL);
|
||||
newname = new_state.cwd;
|
||||
|
||||
retval = rename(oldname, newname);
|
||||
@@ -669,7 +653,7 @@ CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC)
|
||||
int retval;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, path, NULL, 1);
|
||||
virtual_file_ex(&new_state, path, NULL);
|
||||
|
||||
retval = stat(new_state.cwd, buf);
|
||||
|
||||
@@ -683,7 +667,7 @@ CWD_API int virtual_stat(const char *path, struct stat_libc *buf TSRMLS_DC)
|
||||
int retval;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, path, NULL, 1);
|
||||
virtual_file_ex(&new_state, path, NULL);
|
||||
|
||||
retval = stat(new_state.cwd, (struct stat*)buf);
|
||||
|
||||
@@ -699,7 +683,7 @@ CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC)
|
||||
int retval;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, path, NULL, 0);
|
||||
virtual_file_ex(&new_state, path, NULL);
|
||||
|
||||
retval = lstat(new_state.cwd, buf);
|
||||
|
||||
@@ -714,7 +698,7 @@ CWD_API int virtual_unlink(const char *path TSRMLS_DC)
|
||||
int retval;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, path, NULL, 0);
|
||||
virtual_file_ex(&new_state, path, NULL);
|
||||
|
||||
retval = unlink(new_state.cwd);
|
||||
|
||||
@@ -728,7 +712,7 @@ CWD_API int virtual_mkdir(const char *pathname, mode_t mode TSRMLS_DC)
|
||||
int retval;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, pathname, NULL, 1);
|
||||
virtual_file_ex(&new_state, pathname, NULL);
|
||||
|
||||
#ifdef TSRM_WIN32
|
||||
retval = mkdir(new_state.cwd);
|
||||
@@ -745,7 +729,7 @@ CWD_API int virtual_rmdir(const char *pathname TSRMLS_DC)
|
||||
int retval;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, pathname, NULL, 0);
|
||||
virtual_file_ex(&new_state, pathname, NULL);
|
||||
|
||||
retval = rmdir(new_state.cwd);
|
||||
|
||||
@@ -763,7 +747,7 @@ CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC)
|
||||
DIR *retval;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, pathname, NULL, 1);
|
||||
virtual_file_ex(&new_state, pathname, NULL);
|
||||
|
||||
retval = opendir(new_state.cwd);
|
||||
|
||||
@@ -773,9 +757,33 @@ CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC)
|
||||
|
||||
#ifdef TSRM_WIN32
|
||||
|
||||
/* On Windows the trick of prepending "cd cwd; " doesn't work so we need to perform
|
||||
a real chdir() and mutex it
|
||||
*/
|
||||
CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
|
||||
{
|
||||
return popen_ex(command, type, CWDG(cwd).cwd, NULL);
|
||||
char prev_cwd[MAXPATHLEN];
|
||||
char *getcwd_result;
|
||||
FILE *retval;
|
||||
|
||||
getcwd_result = getcwd(prev_cwd, MAXPATHLEN);
|
||||
if (!getcwd_result) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef ZTS
|
||||
tsrm_mutex_lock(cwd_mutex);
|
||||
#endif
|
||||
|
||||
chdir(CWDG(cwd).cwd);
|
||||
retval = popen(command, type);
|
||||
chdir(prev_cwd);
|
||||
|
||||
#ifdef ZTS
|
||||
tsrm_mutex_unlock(cwd_mutex);
|
||||
#endif
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
#elif defined(NETWARE)
|
||||
|
||||
+8
-17
@@ -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 |
|
||||
@@ -52,13 +52,9 @@ typedef unsigned short mode_t;
|
||||
#define IS_SLASH(c) ((c) == '/' || (c) == '\\')
|
||||
#define IS_SLASH_P(c) (*(c) == '/' || \
|
||||
(*(c) == '\\' && !IsDBCSLeadByte(*(c-1))))
|
||||
|
||||
/* COPY_WHEN_ABSOLUTE also takes path as argument because netware needs it
|
||||
* to account for volume name that is unique to NetWare absolute paths
|
||||
*/
|
||||
#define COPY_WHEN_ABSOLUTE(path) 2
|
||||
#define COPY_WHEN_ABSOLUTE 2
|
||||
#define IS_ABSOLUTE_PATH(path, len) \
|
||||
(len >= 2 && ((isalpha(path[0]) && path[1] == ':') || (IS_SLASH(path[0]) && IS_SLASH(path[1]))))
|
||||
(len >= 2 && isalpha(path[0]) && path[1] == ':')
|
||||
#define IS_UNC_PATH(path, len) \
|
||||
(len >= 2 && IS_SLASH(path[0]) && IS_SLASH(path[1]))
|
||||
|
||||
@@ -95,7 +91,7 @@ typedef unsigned short mode_t;
|
||||
|
||||
|
||||
#ifndef COPY_WHEN_ABSOLUTE
|
||||
#define COPY_WHEN_ABSOLUTE(path) 0
|
||||
#define COPY_WHEN_ABSOLUTE 0
|
||||
#endif
|
||||
|
||||
#ifndef IS_ABSOLUTE_PATH
|
||||
@@ -150,11 +146,6 @@ CWD_API int virtual_mkdir(const char *pathname, mode_t mode TSRMLS_DC);
|
||||
CWD_API int virtual_rmdir(const char *pathname TSRMLS_DC);
|
||||
CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC);
|
||||
CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC);
|
||||
|
||||
#if !defined(TSRM_WIN32)
|
||||
CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC);
|
||||
#endif
|
||||
|
||||
#if HAVE_UTIME
|
||||
CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC);
|
||||
#endif
|
||||
@@ -163,7 +154,7 @@ CWD_API int virtual_chmod(const char *filename, mode_t mode TSRMLS_DC);
|
||||
CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group TSRMLS_DC);
|
||||
#endif
|
||||
|
||||
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath);
|
||||
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path);
|
||||
|
||||
typedef struct _virtual_cwd_globals {
|
||||
cwd_state cwd;
|
||||
@@ -195,6 +186,8 @@ typedef struct _virtual_cwd_globals {
|
||||
#define VCWD_RENAME(oldname, newname) virtual_rename(oldname, newname TSRMLS_CC)
|
||||
#define VCWD_STAT(path, buff) virtual_stat(path, buff TSRMLS_CC)
|
||||
#if !defined(TSRM_WIN32) && !defined(NETWARE)
|
||||
#define VCWD_LSTAT(path, buff) virtual_stat(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)
|
||||
@@ -202,7 +195,6 @@ typedef struct _virtual_cwd_globals {
|
||||
#define VCWD_RMDIR(pathname) virtual_rmdir(pathname TSRMLS_CC)
|
||||
#define VCWD_OPENDIR(pathname) virtual_opendir(pathname TSRMLS_CC)
|
||||
#define VCWD_POPEN(command, type) virtual_popen(command, type TSRMLS_CC)
|
||||
#define VCWD_ACCESS(pathname, mode) virtual_access(pathname, mode TSRMLS_CC)
|
||||
#if HAVE_UTIME
|
||||
#define VCWD_UTIME(path, time) virtual_utime(path, time TSRMLS_CC)
|
||||
#endif
|
||||
@@ -229,9 +221,8 @@ typedef struct _virtual_cwd_globals {
|
||||
#define VCWD_RMDIR(pathname) rmdir(pathname)
|
||||
#define VCWD_OPENDIR(pathname) opendir(pathname)
|
||||
#define VCWD_POPEN(command, type) popen(command, type)
|
||||
#define VCWD_ACCESS(pathname, mode) access(pathname, mode)
|
||||
|
||||
#ifdef HAVE_REALPATH
|
||||
#if !defined(TSRM_WIN32) && !defined(NETWARE)
|
||||
#define VCWD_REALPATH(path, real_path) realpath(path, real_path)
|
||||
#else
|
||||
#define VCWD_REALPATH(path, real_path) strcpy(real_path, path)
|
||||
|
||||
+4
-7
@@ -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,6 +18,7 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
@@ -27,6 +28,7 @@
|
||||
#include "TSRM.h"
|
||||
|
||||
#ifdef TSRM_WIN32
|
||||
#include <windows.h>
|
||||
#include "tsrm_win32.h"
|
||||
|
||||
#ifdef ZTS
|
||||
@@ -148,11 +150,6 @@ static HANDLE dupHandle(HANDLE fh, BOOL inherit) {
|
||||
}
|
||||
|
||||
TSRM_API FILE *popen(const char *command, const char *type)
|
||||
{
|
||||
return popen_ex(command, type, NULL, NULL);
|
||||
}
|
||||
|
||||
TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char *env)
|
||||
{
|
||||
FILE *stream = NULL;
|
||||
int fno, str_len = strlen(type), read, mode;
|
||||
@@ -195,7 +192,7 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
|
||||
|
||||
cmd = (char*)malloc(strlen(command)+strlen(TWG(comspec))+sizeof(" /c "));
|
||||
sprintf(cmd, "%s /c %s", TWG(comspec), command);
|
||||
if (!CreateProcess(NULL, cmd, &security, &security, security.bInheritHandle, NORMAL_PRIORITY_CLASS, env, cwd, &startup, &process)) {
|
||||
if (!CreateProcess(NULL, cmd, &security, &security, security.bInheritHandle, NORMAL_PRIORITY_CLASS, NULL, NULL, &startup, &process)) {
|
||||
return NULL;
|
||||
}
|
||||
free(cmd);
|
||||
|
||||
+5
-2
@@ -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,6 +22,8 @@
|
||||
#define TSRM_WIN32_H
|
||||
|
||||
#include "TSRM.h"
|
||||
|
||||
#ifdef TSRM_WIN32
|
||||
#include <windows.h>
|
||||
|
||||
struct ipc_perm {
|
||||
@@ -71,6 +73,8 @@ typedef struct {
|
||||
# define TWG(v) (win32_globals.v)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define IPC_PRIVATE 0
|
||||
#define IPC_CREAT 00001000
|
||||
#define IPC_EXCL 00002000
|
||||
@@ -92,7 +96,6 @@ typedef struct {
|
||||
TSRM_API void tsrm_win32_startup(void);
|
||||
TSRM_API void tsrm_win32_shutdown(void);
|
||||
|
||||
TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char *env);
|
||||
TSRM_API FILE *popen(const char *command, const char *type);
|
||||
TSRM_API int pclose(FILE *stream);
|
||||
|
||||
|
||||
+220
-387
File diff suppressed because it is too large.
Load diff
+280
@@ -0,0 +1,280 @@
|
||||
Following is a merge of two letters I sent to php4beta@lists.php.net,
|
||||
describing the changes in API between PHP 3.0 and PHP 4.0 (Zend).
|
||||
This file is by no means thorough documentation of the PHP API,
|
||||
and is intended for developers who are familiar with the PHP 3.0 API,
|
||||
and want to port their code to PHP 4.0, or take advantage of its new
|
||||
features. For highlights about the PHP 3.0 API, consult apidoc.txt.
|
||||
|
||||
Zeev
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
|
||||
I'm going to try to list the important changes in API and programming
|
||||
techniques that are involved in developing modules for PHP4/Zend, as
|
||||
opposed to PHP3. Listing the whole PHP4 API is way beyond my scope here,
|
||||
it's mostly a 'diff' from the apidoc.txt, which you're all pretty familiar
|
||||
with.
|
||||
An important note that I neglected to mention yesterday - the php4 tree is
|
||||
based on the php 3.0.5 tree, plus all 3.0.6 patches hand-patched into it.
|
||||
Notably, it does NOT include any 3.0.7 patches. All of those have to be
|
||||
reapplied, with extreme care - modules should be safe to patch (mostly),
|
||||
but anything that touches the core or main.c will almost definitely require
|
||||
changes in order to work properly.
|
||||
|
||||
[1] Symbol Tables
|
||||
|
||||
One of the major changes in Zend involves changing the way symbols tables
|
||||
work. Zend enforces reference counting on all values and resources. This
|
||||
required changes in the semantics of the hash tables that implement symbol
|
||||
tables. Instead of storing pval in the hashes, we now store pval *. All
|
||||
of the API functions in Zend were changed in a way that this change is
|
||||
completely transparent. However, if you've used 'low level' hash functions
|
||||
to access or update elements in symbol tables, your code will require
|
||||
changes. Following are two simple examples, one demonstrates the
|
||||
difference between PHP3 and Zend when reading a symbol's value, and the
|
||||
other demonstrates the difference when writing a value.
|
||||
|
||||
php3_read()
|
||||
{
|
||||
pval *foo;
|
||||
|
||||
_php3_hash_find(ht, "foo", sizeof("foo"), &foo);
|
||||
/* foo->type is the type and foo->value is the value */
|
||||
}
|
||||
|
||||
|
||||
php4_read()
|
||||
{
|
||||
pval **foo;
|
||||
|
||||
_php3_hash_find(ht, "foo", sizeof("foo"), &foo);
|
||||
/* (*foo)->type is the type and (*foo)->value is the value */
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
php3_write()
|
||||
{
|
||||
pval newval;
|
||||
|
||||
newval.type = ...;
|
||||
newval.value = ...;
|
||||
_php3_hash_update(ht, "bar", sizeof("bar"), &newval, sizeof(pval), NULL);
|
||||
}
|
||||
|
||||
php4_write()
|
||||
{
|
||||
pval *newval = ALLOC_ZVAL();
|
||||
|
||||
newval->refcount=1;
|
||||
newval->is_ref=0;
|
||||
newval->type = ...;
|
||||
newval->value = ...;
|
||||
_php3_hash_update(ht, "bar", sizeof("bar"), &newval, sizeof(pval *), NULL);
|
||||
}
|
||||
|
||||
|
||||
[2] Resources
|
||||
|
||||
One of the 'cute' things about the reference counting support is that it
|
||||
completely eliminates the problem of resource leaking. A simple loop that
|
||||
included '$result = mysql_query(...)' in PHP leaked unless the user
|
||||
remembered to run mysql_free($result) at the end of the loop body, and
|
||||
nobody really did. In order to take advantage of the automatic resource
|
||||
deallocation upon destruction, there's virtually one small change you need
|
||||
to conduct. Change the result type of a resource that you want to destroy
|
||||
itself as soon as its no longer referenced (just about any resource I can
|
||||
think of) as IS_RESOURCE, instead of as IS_LONG. The rest is magic.
|
||||
|
||||
A special treatment is required for SQL modules that follow MySQL's
|
||||
approach for having the link handle as an optional argument. Modules that
|
||||
follow the MySQL module model, store the last opened link in a global
|
||||
variable, that they use in case the user neglects to explicitly specify a
|
||||
link handle. Due to the way referenec counting works, this global
|
||||
reference is just like any other reference, and must increase that SQL link
|
||||
resource's reference count (otherwise, it will be closed prematurely).
|
||||
Simply, when you set the default link to a certain link, increase that
|
||||
link's reference count by calling zend_list_addref().
|
||||
As always, the MySQL module is the one used to demonstrate 'new
|
||||
technology'. You can look around it and look for IS_RESOURCE, as well as
|
||||
zend_list_addref(), to see a clear example of how the new API should be used.
|
||||
|
||||
|
||||
[3] Thread safety issues
|
||||
|
||||
I'm not going to say that Zend was designed with thread safety in mind, but
|
||||
from some point, we've decided upon several guidelines that would make the
|
||||
move to thread safety much, much easier. Generally, we've followed the PHP
|
||||
3.1 approach of moving global variables to a structure, and encapsulating
|
||||
all global variable references within macros. There are three main
|
||||
differences:
|
||||
1. We grouped related globals in a single structure, instead of grouping
|
||||
all globals in one structure.
|
||||
2. We've used much, much shorter macro names to increase the readability
|
||||
of the source code.
|
||||
3. Regardless of whether we're compiling in thread safe mode or not, all
|
||||
global variables are *always* stored in a structure. For example, you
|
||||
would never have a global variable 'foo', instead, it'll be a property of a
|
||||
global structure, for example, compiler_globals.foo. That makes
|
||||
development much, much easier, since your code will simply not compile
|
||||
unless you remember to put the necessary macro around foo.
|
||||
|
||||
To write code that'll be thread safe in the future (when we release our
|
||||
thread safe memory manager and work on integrating it), you can take a look
|
||||
at zend_globals.h. Essentially, two sets of macros are defined, one for
|
||||
thread safe mode, and one for thread unsafe mode. All global references
|
||||
are encapsulated within ???G(varname), where ??? is the appropriate prefix
|
||||
for your structure (for example, so far we have CG(), EG() and AG(), which
|
||||
stand for the compiler, executor and memory allocator, respectively).
|
||||
When compiling with thread safety enabled, each function that makes use of
|
||||
a ???G() macro, must obtain the pointer to its copy of the structure. It
|
||||
can do so in one of two forms:
|
||||
1. It can receive it as an argument.
|
||||
2. It can fetch it.
|
||||
|
||||
Obviously, the first method is preferable since it's much quicker.
|
||||
However, it's not always possible to send the structure all the way to a
|
||||
particular function, or it may simply bloat the code too much in some
|
||||
cases. Functions that receive the globals as an argument, should look like
|
||||
this:
|
||||
|
||||
rettype functioname(???LS_D) <-- a function with no arguments
|
||||
rettype functioname(type arg1, ..., type argn ???LS_DC) <-- a funciton with
|
||||
arguments
|
||||
|
||||
Calls to such functions should look like this:
|
||||
functionname(???LS_C) <-- a function with no arguments
|
||||
functionname(arg1, ..., argn ???LS_CC) <-- a function with arguments
|
||||
|
||||
LS stands for 'Local Storage', _C stands for Call and _CC stands for Call
|
||||
Comma, _D stands for Declaration and _DC stands for Declaration Comma.
|
||||
Note that there's NO comma between the last argument and ???LS_DC or ???LS_CC.
|
||||
|
||||
If you do not pass the structure as an argument you can always fetch it by
|
||||
using the appropriate ???LS_FETCH() macros within a functions variable
|
||||
declarations.
|
||||
|
||||
In general, every module that makes use of globals should use this approach
|
||||
if it plans to be thread safe.
|
||||
|
||||
|
||||
[4] Generalized INI support
|
||||
|
||||
The code comes to solve several issues:
|
||||
|
||||
a. The ugly long block of code in main.c that reads values from the
|
||||
cfg_hash into php3_ini.
|
||||
b. Get rid of php3_ini. The performance penalty of copying it around all
|
||||
the time in the Apache module probably wasn't too high, but
|
||||
psychologically, it annoyed me :)
|
||||
c. Get rid of the ugly code in mod_php4.c, that also reads values from
|
||||
Apache directives and puts them into the php3_ini structure.
|
||||
d. Generalize all the code so that you only have to add an entry in one
|
||||
single place and get it automatically supported in php3.ini, Apache, Win32
|
||||
registry, runtime function ini_get() and ini_alter() and any future method
|
||||
we might have.
|
||||
e. Allow users to easily override *ANY* php3.ini value, except for ones
|
||||
they're not supposed to, of course.
|
||||
|
||||
I'm happy to say that I think I pretty much reached all goals. php_ini.c
|
||||
implements a mechanism that lets you add your INI entry in a single place,
|
||||
with a default value in case there's no php3.ini value. What you get by
|
||||
using this mechanism:
|
||||
|
||||
1. Automatic initialization from php3.ini if available, or from the
|
||||
default value if not.
|
||||
2. Automatic support in ini_alter(). That means a user can change the
|
||||
value for this INI entry at runtime, without you having to add in a single
|
||||
line of code, and definitely no additional function (for example, in PHP3,
|
||||
we had to add in special dedicated functions, like
|
||||
set_magic_quotes_runtime() or the likes - no need for that anymore).
|
||||
3. Automatic support in Apache .conf files.
|
||||
4. No need for a global php3_ini-like variable that'll store all that
|
||||
info. You can directly access each INI entry by name, in runtime. 'Sure,
|
||||
that's not revolutionary, it's just slow' is probably what some of you
|
||||
think - which is true, but, you can also register a callback function that
|
||||
is called each time your INI entry is changed, if you wish to store it in a
|
||||
cached location for intensive use.
|
||||
5. Ability to access the current active value for a given INI entry, and
|
||||
the 'master' value.
|
||||
|
||||
Of course, (2) and (3) are only applicable in some cases. Some entries
|
||||
shouldn't be overriden by users in runtime or through Apache .conf files -
|
||||
you can, of course, mark them as such.
|
||||
|
||||
|
||||
So, enough hype, how does it work.
|
||||
|
||||
Essentially:
|
||||
|
||||
static PHP_INI_MH(OnChangeBar); /* declare a message handler for a change
|
||||
in "bar" */
|
||||
|
||||
PHP_INI_BEGIN()
|
||||
PHP_INI_ENTRY("foo", "1", PHP_INI_ALL, NULL, NULL)
|
||||
PHP_INI_ENTRY("bar", "bah", PHP_INI_SYSTEM, OnChangeBar, NULL)
|
||||
PHP_INI_END()
|
||||
|
||||
static PHP_INI_MH(OnChangeBar)
|
||||
{
|
||||
a_global_var_for_bar = new_value;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int whatever_minit(INIT_FUNC_ARGS)
|
||||
{
|
||||
...
|
||||
REGISTER_INI_ENTRIES();
|
||||
...
|
||||
}
|
||||
|
||||
|
||||
int whatever_mshutdown(SHUTDOWN_FUNC_ARGS)
|
||||
{
|
||||
...
|
||||
UNREGISTER_INI_ENTRIES();
|
||||
...
|
||||
}
|
||||
|
||||
|
||||
and that's it. Here's what it does. As you can probably guess, this code
|
||||
registers two INI entries - "foo" and "bar". They're given defaults "1"
|
||||
and "bah" respectively - note that all defaults are always given as
|
||||
strings. That doesn't reduce your ability to use integer values, simply
|
||||
specify them as strings. "foo" is marked so that it can be changed by
|
||||
anyone at any time (PHP_INI_ALL), whereas "bar" is marked so it can be
|
||||
changed only at startup in the php3.ini only, presumably, by the system
|
||||
administrator (PHP_INI_SYSTEM).
|
||||
When "foo" changes, no function is called. Access to it is done using the
|
||||
macros INI_INT("foo"), INI_FLT("foo") or INI_STR("foo"), which return a
|
||||
long, double or char * respectively (strings that are returned aren't
|
||||
duplicated - if they're manipulated, you must duplicate them first). You
|
||||
can also access the original value (the 'master' value, in case one of them
|
||||
was overriden by a user) using another pair of macros:
|
||||
INI_ORIG_INT("foo"), INI_ORIG_FLT("foo") and INI_ORIG_STR("foo").
|
||||
|
||||
When "bar" changes, a special message handler is called, OnBarChange().
|
||||
Always declare those message handlers using PHP_INI_MH(), as they might
|
||||
change in the future. Message handlers are called as soon as an ini entry
|
||||
initializes or changes, and allow you to cache a certain INI value in a
|
||||
quick C structure. In this example, whenever "bar" changes, the new value
|
||||
is stored in a_global_var_for_bar, which is a global char * pointer,
|
||||
quickly accessible from other functions. Things get a bit more complicated
|
||||
when you want to implement a thread-safe module, but it's doable as well.
|
||||
Message handlers may return SUCCESS to acknowledge the new value, or
|
||||
FAILURE to reject it. That enables you to reject invalid values for some
|
||||
INI entries if you want. Finally, you can have a pointer passed to your
|
||||
message handler - that's the fifth argument to PHP_INI_ENTRY(). It is
|
||||
passed as mh_arg to the message handler.
|
||||
|
||||
Remember that for certain values, there's really no reason to mess with a
|
||||
callback function. A perfect example for this are the syntax highlight
|
||||
colors, which no longer have a dedicated global C slot that stores them,
|
||||
but instead, are fetched from the php_ini hash on demand.
|
||||
|
||||
"As always", for a perfect working example of this mechanism, consult
|
||||
functions/mysql.c. This module uses the new INI entry mechanism, and was
|
||||
also converted to be thread safe in general, and in its php_ini support in
|
||||
particular. Converting your modules to look like this for thread safety
|
||||
isn't a bad idea (not necessarily now, but in the long run).
|
||||
|
||||
+492
@@ -0,0 +1,492 @@
|
||||
PHP Version 3.0 API Documentation
|
||||
|
||||
Table of Contents
|
||||
-----------------
|
||||
1. Function Prototype
|
||||
2. Function Arguments
|
||||
3. Variable number of function arguments
|
||||
4. Using the function arguments
|
||||
5. Memory management in functions
|
||||
6. Setting variables in the symbol table
|
||||
7. Returning values from functions
|
||||
8. Returning 'complex' values from functions (arrays or objects)
|
||||
9. Using the resource list
|
||||
10. Using the persistent resource table
|
||||
11. Adding runtime configuration directives
|
||||
-----------------
|
||||
|
||||
1. Function Prototype
|
||||
|
||||
All functions look like this:
|
||||
|
||||
PHP_FUNCTION(foo) {
|
||||
|
||||
}
|
||||
|
||||
Even if your function doesn't take any arguments, this is how it is
|
||||
called.
|
||||
|
||||
-----------------
|
||||
|
||||
2. Function Arguments
|
||||
|
||||
Arguments are always of type pval. This type contains a union which
|
||||
has the actual type of the argument. So, if your function takes two
|
||||
arguments, you would do something like the following at the top of your
|
||||
function:
|
||||
|
||||
pval *arg1, *arg2;
|
||||
if (ARG_COUNT(ht) != 2 || getParameters(ht,2,&arg1,&arg2)==FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
NOTE: Arguments can be passed either by value or by reference. In both
|
||||
cases you will need to pass &(pval *) to getParameters. If you want to
|
||||
check if the n'th parameter was sent to you by reference or not, you can
|
||||
use the function, ParameterPassedByReference(ht,n). It will return either
|
||||
1 or 0.
|
||||
|
||||
When you change any of the passed parameters, whether they are sent by
|
||||
reference or by value, you can either start over with the parameter by
|
||||
calling pval_destructor on it, or if it's an ARRAY you want to add to,
|
||||
you can use functions similar to the ones in internal_functions.h which
|
||||
manipulate return_value as an ARRAY.
|
||||
|
||||
Also if you change a parameter to IS_STRING make sure you first assign
|
||||
the new estrdup'ed string and the string length, and only later change the
|
||||
type to IS_STRING. If you change the string of a parameter which already
|
||||
IS_STRING or IS_ARRAY you should run pval_destructor on it first.
|
||||
|
||||
-----------------
|
||||
|
||||
3. Variable number of function arguments
|
||||
|
||||
A function can take a variable number of arguments. If your function can
|
||||
take either 2 or 3 arguments, use the following:
|
||||
|
||||
pval *arg1, *arg2, *arg3;
|
||||
int arg_count = ARG_COUNT(ht);
|
||||
|
||||
if (arg_count<2 || arg_count>3 ||
|
||||
getParameters(ht,arg_count,&arg1,&arg2,&arg3)==FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
------------------
|
||||
|
||||
4. Using the function arguments
|
||||
|
||||
The type of each argument is stored in the pval type field:
|
||||
|
||||
|
||||
This type can be any of the following:
|
||||
|
||||
IS_STRING String
|
||||
IS_DOUBLE Double-precision floating point
|
||||
IS_LONG Long
|
||||
IS_ARRAY Array
|
||||
|
||||
IS_EMPTY ??
|
||||
IS_USER_FUNCTION ??
|
||||
IS_INTERNAL_FUNCTION ?? (if some of these cannot be passed to a
|
||||
function - delete)
|
||||
IS_CLASS ??
|
||||
IS_OBJECT ??
|
||||
|
||||
If you get an argument of one type and would like to use it as another,
|
||||
or if you just want to force the argument to be of a certain type, you
|
||||
can use one of the following conversion functions:
|
||||
|
||||
convert_to_long(arg1);
|
||||
convert_to_double(arg1);
|
||||
convert_to_string(arg1);
|
||||
convert_to_boolean_long(arg1); If the string is "" or "0" it
|
||||
becomes 0, 1 otherwise
|
||||
convert_string_to_number(arg1); Converts string to either LONG or
|
||||
DOUBLE depending on string
|
||||
|
||||
These function all do in-place conversion. They do not return anything.
|
||||
|
||||
The actual argument is stored in a union.
|
||||
|
||||
For type IS_STRING, use arg1->value.str.val
|
||||
IS_LONG arg1->value.lval
|
||||
IS_DOUBLE arg1->value.dval
|
||||
|
||||
-------------------
|
||||
|
||||
5. Memory management in functions
|
||||
|
||||
Any memory needed by a function should be allocated with either emalloc()
|
||||
or estrdup(). These are memory handling abstraction functions that look
|
||||
and smell like the normal malloc() and strdup() functions. Memory should
|
||||
be freed with efree().
|
||||
|
||||
There are two kinds of memory in this program. Memory which is returned
|
||||
to the parser in a variable and memory which you need for temporary
|
||||
storage in your internal function. When you assign a string to a
|
||||
variable which is returned to the parser you need to make sure you first
|
||||
allocate the memory with either emalloc or estrdup. This memory
|
||||
should NEVER be freed by you, unless you later, in the same function
|
||||
overwrite your original assignment (this kind of programming practice is
|
||||
not good though).
|
||||
|
||||
For any temporary/permanent memory you need in your functions/library you
|
||||
should use the three emalloc(), estrdup(), and efree() functions. They
|
||||
behave EXACTLY like their counterpart functions. Anything you emalloc()
|
||||
or estrdup() you have to efree() at some point or another, unless it's
|
||||
supposed to stick around until the end of the program, otherwise there
|
||||
will be a memory leak. The meaning of "the functions behave exactly like
|
||||
their counterparts" is if you efree() something which was not
|
||||
emalloc()'ed nor estrdup()'ed you might get a segmentation fault. So
|
||||
please take care and free all of your wasted memory. One of the biggest
|
||||
improvements in PHP 3.0 will hopefully be the memory management.
|
||||
|
||||
If you compile with "-DDEBUG", PHP3 will print out a list of all
|
||||
memory that was allocated using emalloc() and estrdup() but never
|
||||
freed with efree() when it is done running the specified script.
|
||||
|
||||
-------------------
|
||||
|
||||
6. Setting variables in the symbol table
|
||||
|
||||
A number of macros are available which make it easier to set a variable
|
||||
in the symbol table:
|
||||
|
||||
SET_VAR_STRING(name,value) **
|
||||
SET_VAR_DOUBLE(name,value)
|
||||
SET_VAR_LONG(name,value)
|
||||
|
||||
** Be careful here. The value part must be malloc'ed manually because
|
||||
the memory management code will try to free this pointer later. Do
|
||||
not pass statically allocated memory into a SET_VAR_STRING
|
||||
|
||||
Symbol tables in PHP 3.0 are implemented as hash tables. At any given time,
|
||||
&symbol_table is a pointer to the 'main' symbol table, and active_symbol_table
|
||||
points to the currently active symbol table (these may be identical like in
|
||||
startup, or different, if you're inside a function).
|
||||
|
||||
The following examples use 'active_symbol_table'. You should replace it with
|
||||
&symbol_table if you specifically want to work with the 'main' symbol table.
|
||||
Also, the same funcions may be applied to arrays, as explained below.
|
||||
|
||||
* To check whether a variable named $foo already exists in a symbol table:
|
||||
if (hash_exists(active_symbol_table,"foo",sizeof("foo"))) { exists... }
|
||||
else { doesn't exist }
|
||||
|
||||
* If you also need to get the type of the variable, you can use:
|
||||
hash_find(active_symbol_table,"foo",sizeof("foo"),&pvalue);
|
||||
check(pvalue.type);
|
||||
|
||||
Arrays in PHP 3.0 are implemented using the same hashtables as symbol tables.
|
||||
This means the two above functions can also be used to check variables
|
||||
inside arrays.
|
||||
|
||||
If you want to define a new array in a symbol table, you should do this:
|
||||
|
||||
1. Possibly check it exists and abort, using hash_exists()
|
||||
or hash_find().
|
||||
2. Code:
|
||||
|
||||
pval arr;
|
||||
|
||||
if (array_init(&arr) == FAILURE) { failed... };
|
||||
hash_update(active_symbol_table,"foo",sizeof("foo"),&arr,sizeof(pval),NULL);
|
||||
|
||||
This code declares a new array, named $foo, in the active symbol table.
|
||||
This array is empty.
|
||||
|
||||
Here's how to add new entries to it:
|
||||
|
||||
pval entry;
|
||||
|
||||
entry.type = IS_LONG;
|
||||
entry.value.lval = 5;
|
||||
|
||||
hash_update(arr.value.ht,"bar",sizeof("bar"),&entry,sizeof(pval),NULL); /* defines $foo["bar"] = 5 */
|
||||
hash_index_update(arr.value.ht,7,&entry,sizeof(pval),NULL); /* defines $foo[7] = 5 */
|
||||
hash_next_index_insert(arr.value.ht,&entry,sizeof(pval),NULL); /* defines the next free place in $foo[],
|
||||
* $foo[8], to be 5 (works like php2)
|
||||
*/
|
||||
|
||||
If you'd like to modify a value that you inserted to a hash, you must first retreive it from the hash. To
|
||||
prevent that overhead, you can supply a pval ** to the hash add function, and it'll be updated with the
|
||||
pval * address of the inserted element inside the hash. If that value is NULL (like in all of the
|
||||
above examples) - that parameter is ignored.
|
||||
|
||||
hash_next_index_insert() works more or less using the same logic
|
||||
"$foo[] = bar;" works in PHP 2.0.
|
||||
|
||||
If you are building an array to return from a function, you can initialize
|
||||
the array just like above by doing:
|
||||
|
||||
if (array_init(return_value) == FAILURE) { failed...; }
|
||||
|
||||
and then adding values with the helper functions:
|
||||
|
||||
add_next_index_long(return_value,long_value);
|
||||
add_next_index_double(return_value,double_value);
|
||||
add_next_index_string(return_value,estrdup(string_value));
|
||||
|
||||
Of course, if the adding isn't done right after the array
|
||||
initialization, you'd probably have to look for the array first:
|
||||
|
||||
pval *arr;
|
||||
|
||||
if (hash_find(active_symbol_table,"foo",sizeof("foo"),(void **)&arr)==FAILURE) { can't find... }
|
||||
else { use arr->value.ht... }
|
||||
|
||||
Note that hash_find receives a pointer to a pval pointer, and
|
||||
not a pval pointer.
|
||||
|
||||
Just about any hash function returns SUCCESS or FAILURE (except for
|
||||
hash_exists() that returns a boolean truth value).
|
||||
|
||||
-------------------
|
||||
|
||||
7. Returning 'simple' values from functions (integers, floats or strings)
|
||||
|
||||
A number of macros are available to make it easier to return things from
|
||||
functions:
|
||||
|
||||
These set the return value and return from the function:
|
||||
|
||||
RETURN_FALSE
|
||||
RETURN_TRUE
|
||||
RETURN_LONG(l)
|
||||
RETURN_STRING(s,dup) If dup is true, duplicates the string
|
||||
RETURN_STRINGL(s,l,dup) Return string (s) specifying length (l).
|
||||
RETURN_DOUBLE(d)
|
||||
|
||||
These only set the return value:
|
||||
|
||||
RETVAL_FALSE
|
||||
RETVAL_TRUE
|
||||
RETVAL_LONG(l)
|
||||
RETVAL_STRING(s,dup) If dup is true, duplicates the string
|
||||
RETVAL_STRINGL(s,l,dup) Return string (s) specifying length (l).
|
||||
RETVAL_DOUBLE(d)
|
||||
|
||||
The string macros above will all estrdup() the passed 's' argument,
|
||||
so you can safely free the argument after calling the macro, or
|
||||
alternatively use statically allocated memory.
|
||||
|
||||
If your function returns boolean success/error responses, always use
|
||||
RETURN_TRUE and RETURN_FALSE respectively.
|
||||
|
||||
-------------------
|
||||
|
||||
8. Returning 'complex' values from functions (arrays or objects)
|
||||
|
||||
Your function can also return a complex data type such as an object
|
||||
or an array.
|
||||
|
||||
Returning an object:
|
||||
|
||||
1. Call object_init(return_value).
|
||||
2. Fill it up with values:
|
||||
|
||||
add_property_long(return_value,property_name,l) Add a property named 'property_name', of type long, equals to 'l'
|
||||
add_property_double(return_value,property_name,d) Same, only a double
|
||||
add_property_string(return_value,property_name,str) Same, only a string
|
||||
add_property_stringl(return_value,property_name,str,l) Add a property named 'property_name', of type string, string is 'str' with length 'l'
|
||||
|
||||
3. Possibly, register functions for this object. In order to
|
||||
obtain values from the object, the function would have to fetch
|
||||
"this" from the active_symbol_table. Its type should be IS_OBJECT,
|
||||
and it's basically a regular hash table (i.e., you can use regular
|
||||
hash functions on .value.ht). The actual registration of the
|
||||
function can be done using:
|
||||
|
||||
add_method(return_value,function_name,function_ptr)
|
||||
|
||||
|
||||
Returning an array:
|
||||
|
||||
1. Call array_init(return_value).
|
||||
2. Fill it up with values:
|
||||
|
||||
add_assoc_long(return_value,key,l) add associative entry with key 'key' and long value 'l'
|
||||
add_assoc_double(return_value,key,d)
|
||||
add_assoc_string(return_value,key,str)
|
||||
add_assoc_stringl(return_value,key,str,length) specify the string length
|
||||
|
||||
add_index_long(return_value,index,l) add entry in index 'index' with long value 'l'
|
||||
add_index_double(return_value,index,d)
|
||||
add_index_string(return_value,index,str)
|
||||
add_index_stringl(return_value,index,str,length) specify the string length
|
||||
|
||||
add_next_index_long(return_value,l) add an array entry in the next free offset with long value 'l'
|
||||
add_next_index_double(return_value,d)
|
||||
add_next_index_string(return_value,str)
|
||||
add_next_index_stringl(return_value,str,length) specify the string length
|
||||
|
||||
-------------------
|
||||
|
||||
9. Using the resource list
|
||||
|
||||
PHP 3.0 has a standard way of dealing with various types of resources,
|
||||
that replaces all of the local linked lists in PHP 2.0.
|
||||
|
||||
Available functions:
|
||||
|
||||
php3_list_insert(ptr, type) returns the 'id' of the newly inserted resource
|
||||
php3_list_delete(id) delete the resource with the specified id
|
||||
php3_list_find(id,*type) returns the pointer of the resource with the specified id, updates 'type' to the resource's type
|
||||
|
||||
Typically, these functions are used for SQL drivers but they can be
|
||||
used for anything else, and are used, for instance, for maintaining
|
||||
file descriptors.
|
||||
|
||||
Typical list code would look like this:
|
||||
|
||||
Adding a new resource:
|
||||
|
||||
RESOURCE *resource;
|
||||
|
||||
...allocate memory for resource and acquire resource...
|
||||
/* add a new resource to the list */
|
||||
return_value->value.lval = php3_list_insert((void *) resource, LE_RESOURCE_TYPE);
|
||||
return_value->type = IS_LONG;
|
||||
|
||||
Using an existing resource:
|
||||
|
||||
pval *resource_id;
|
||||
RESOURCE *resource;
|
||||
int type;
|
||||
|
||||
convert_to_long(resource_id);
|
||||
resource = php3_list_find(resource_id->value.lval, &type);
|
||||
if (type != LE_RESOURCE_TYPE) {
|
||||
php3_error(E_WARNING,"resource index %d has the wrong type",resource_id->value.lval);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
...use resource...
|
||||
|
||||
Deleting an existing resource:
|
||||
|
||||
pval *resource_id;
|
||||
RESOURCE *resource;
|
||||
int type;
|
||||
|
||||
convert_to_long(resource_id);
|
||||
php3_list_delete(resource_id->value.lval);
|
||||
|
||||
|
||||
The resource types should be registered in php3_list.h, in enum
|
||||
list_entry_type. In addition, one should add shutdown code for any
|
||||
new resource type defined, in list.c's list_entry_destructor() (even if
|
||||
you don't have anything to do on shutdown, you must add an empty case).
|
||||
|
||||
-------------------
|
||||
|
||||
10. Using the persistent resource table
|
||||
|
||||
PHP 3.0 has a standard way of storing persistent resources (i.e.,
|
||||
resources that are kept in between hits). The first module to use
|
||||
this feature was the MySQL module, and mSQL followed it, so one can
|
||||
get the general impression of how a persistent resource should be
|
||||
used by reading mysql.c. The functions you should look at are:
|
||||
php3_mysql_do_connect()
|
||||
php3_mysql_connect()
|
||||
php3_mysql_pconnect()
|
||||
|
||||
The general idea of persistence modules is this:
|
||||
1. Code all of your module to work with the regular resource list
|
||||
mentioned in section (9).
|
||||
2. Code extra connect functions that check if the resource already
|
||||
exists in the persistent resource list. If it does, register it
|
||||
as in the regular resource list as a pointer to the persistent
|
||||
resource list (because of 1., the rest of the code
|
||||
should work immediately). If it doesn't, then create it, add it
|
||||
to the persistent resource list AND add a pointer to it from the
|
||||
regular resource list, so all of the code would work since it's
|
||||
in the regular resource list, but on the next connect, the
|
||||
resource would be found in the persistent resource list and be
|
||||
used without having to recreate it.
|
||||
You should register these resources with a different type (e.g.
|
||||
LE_MYSQL_LINK for non-persistent link and LE_MYSQL_PLINK for
|
||||
a persistent link).
|
||||
|
||||
If you read mysql.c, you'll notice that except for the more complex
|
||||
connect function, nothing in the rest of the module has to be changed.
|
||||
|
||||
The very same interface exists for the regular resource list and the
|
||||
persistent resource list, only 'list' is replaced with 'plist':
|
||||
|
||||
php3_plist_insert(ptr, type) returns the 'id' of the newly inserted resource
|
||||
php3_plist_delete(id) delete the resource with the specified id
|
||||
php3_plist_find(id,*type) returns the pointer of the resource with the specified id, updates 'type' to the resource's type
|
||||
|
||||
However, it's more than likely that these functions would prove
|
||||
to be useless for you when trying to implement a persistent module.
|
||||
Typically, one would want to use the fact that the persistent resource
|
||||
list is really a hash table. For instance, in the MySQL/mSQL modules,
|
||||
when there's a pconnect() call (persistent connect), the function
|
||||
builds a string out of the host/user/passwd that were passed to the
|
||||
function, and hashes the SQL link with this string as a key. The next
|
||||
time someone calls a pconnect() with the same host/user/passwd, the
|
||||
same key would be generated, and the function would find the SQL link
|
||||
in the persistent list.
|
||||
|
||||
Until further documented, you should look at mysql.c or msql.c to
|
||||
see how one should use the plist's hash table abilities.
|
||||
|
||||
One important thing to note: resources going into the persistent
|
||||
resource list must *NOT* be allocated with PHP's memory manager, i.e.,
|
||||
they should NOT be created with emalloc(), estrdup(), etc. Rather,
|
||||
one should use the regular malloc(), strdup(), etc. The reason for
|
||||
this is simple - at the end of the request (end of the hit), every
|
||||
memory chunk that was allocated using PHP's memory manager is deleted.
|
||||
Since the persistent list isn't supposed to be erased at the end
|
||||
of a request, one mustn't use PHP's memory manager for allocating
|
||||
resources that go to it.
|
||||
|
||||
Shutting down persistent resources:
|
||||
|
||||
When you register resource that's going to be in the persistent list,
|
||||
you should add destructors to it both in the non-persistent list
|
||||
and in the persistent list.
|
||||
The destructor in the non-persistent list destructor shouldn't do anything.
|
||||
The one in the persistent list destructor should properly free any
|
||||
resources obtained by that type (e.g. memory, SQL links, etc). Just like
|
||||
with the non-persistent resources, you *MUST* add destructors for every
|
||||
resource, even it requires no destructotion and the destructor would
|
||||
be empty.
|
||||
Remember, since emalloc() and friends aren't to be used in conjunction
|
||||
with the persistent list, you mustn't use efree() here either.
|
||||
|
||||
-------------------
|
||||
|
||||
11. Adding runtime configuration directives
|
||||
|
||||
Many of the features of PHP3 can be configured at runtime. These
|
||||
configuration directives can appear in either the designated php3.ini
|
||||
file, or in the case of the Apache module version in the Apache .conf
|
||||
files. The advantage of having them in the Apache .conf files is that
|
||||
they can be configured on a per-directory basis. This means that one
|
||||
directory may have a certain safemodeexecdir for example, while another
|
||||
directory may have another. This configuration granularity is especially
|
||||
handy when a server supports multiple virtual hosts.
|
||||
|
||||
The steps required to add a new directive:
|
||||
|
||||
1. Add directive to php3_ini_structure struct in mod_php4.h.
|
||||
|
||||
2. In main.c, edit the php3_module_startup function and add the
|
||||
appropriate cfg_get_string() or cfg_get_long() call.
|
||||
|
||||
3. Add the directive, restrictions and a comment to the php3_commands
|
||||
structure in mod_php4.c. Note the restrictions part. RSRC_CONF are
|
||||
directives that can only be present in the actual Apache .conf files.
|
||||
Any OR_OPTIONS directives can be present anywhere, include normal
|
||||
.htaccess files.
|
||||
|
||||
4. In either php3take1handler() or php3flaghandler() add the appropriate
|
||||
entry for your directive.
|
||||
|
||||
5. In the configuration section of the _php3_info() function in
|
||||
functions/info.c you need to add your new directive.
|
||||
|
||||
6. And last, you of course have to use your new directive somewhere.
|
||||
It will be addressable as php3_ini.directive
|
||||
+1
-1
@@ -67,7 +67,7 @@ snapshot:
|
||||
|
||||
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); \
|
||||
(cd `dirname $$i` 2>/dev/null && rm -rf `cat .cvsignore` *.o *.a .libs || true); \
|
||||
done
|
||||
|
||||
.PHONY: $(ALWAYS) snapshot cvsclean
|
||||
+9
-15
@@ -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.3 2003-05-19 13:14:06 sniper Exp $
|
||||
# $Id: buildcheck.sh,v 1.19 2002-07-21 13:09:07 sas Exp $
|
||||
#
|
||||
|
||||
echo "buildconf: checking installation..."
|
||||
@@ -70,37 +70,31 @@ else
|
||||
echo "buildconf: automake version $am_version (ok)"
|
||||
fi
|
||||
|
||||
# libtool 1.4.3 or newer
|
||||
# libtool 1.4 or newer
|
||||
# Prefer glibtool over libtool for Mac OS X compatibility
|
||||
libtool=`./build/shtool path glibtool 2> /dev/null`
|
||||
if test ! -r "$libtool"; then libtool=`./build/shtool path libtool`; fi
|
||||
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.3 or newer installed"
|
||||
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 "$3" = ""; then
|
||||
third=0
|
||||
else
|
||||
third=$3
|
||||
fi
|
||||
|
||||
if test "$1" -gt "1" || test "$2" -ge "5" || (test "$2" -ge "4" && test "$third" -ge "3")
|
||||
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
|
||||
|
||||
am_prefix=`./build/shtool path automake | sed -e 's#/[^/]*/[^/]*$##'`
|
||||
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"
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $Id$
|
||||
|
||||
dir=$1; shift
|
||||
for stubfile in $dir/*/config0.m4 $dir/*/config.m4 $dir/*/config9.m4; do
|
||||
echo "sinclude($stubfile)"
|
||||
done
|
||||
+46
-305
@@ -1,13 +1,13 @@
|
||||
#!/bin/sh
|
||||
##
|
||||
## GNU shtool -- The GNU Portable Shell Tool
|
||||
## Copyright (c) 1994-2002 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## Copyright (c) 1994-2001 Ralf S. Engelschall <rse@engelschall.com>
|
||||
##
|
||||
## See http://www.gnu.org/software/shtool/ for more information.
|
||||
## See ftp://ftp.gnu.org/gnu/shtool/ for latest version.
|
||||
##
|
||||
## Version: 1.6.2 (02-Nov-2002)
|
||||
## Contents: 4/19 available modules
|
||||
## Version: 1.5.4 (14-Jun-2001)
|
||||
## Contents: 3/17 available modules
|
||||
##
|
||||
|
||||
##
|
||||
@@ -41,7 +41,6 @@
|
||||
## echo Print string with optional construct expansion
|
||||
## install Install a program, script or datafile
|
||||
## mkdir Make one or more directories
|
||||
## path Deal with program paths
|
||||
##
|
||||
## Not available commands (because module was not built-in):
|
||||
## mdate Pretty-print modification time of a file or dir
|
||||
@@ -51,14 +50,13 @@
|
||||
## mkln Make link with calculation of relative paths
|
||||
## mkshadow Make a shadow tree through symbolic links
|
||||
## fixperm Fix file permissions inside a source tree
|
||||
## rotate Logfile rotation
|
||||
## tarball Roll distribution tarballs
|
||||
## subst Apply sed(1) substitution operations
|
||||
## guessos Simple operating system guesser
|
||||
## arx Extended archive command
|
||||
## slo Separate linker options by library class
|
||||
## scpp Sharing C Pre-Processor
|
||||
## version Maintain a version information file
|
||||
## path Deal with program paths
|
||||
##
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
@@ -67,8 +65,8 @@ if [ $# -eq 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
if [ ".$1" = ".-h" -o ".$1" = ".--help" ]; then
|
||||
echo "This is GNU shtool, version 1.6.2 (02-Nov-2002)"
|
||||
echo "Copyright (c) 1994-2002 Ralf S. Engelschall <rse@engelschall.com>"
|
||||
echo "This is GNU shtool, version 1.5.4 (14-Jun-2001)"
|
||||
echo "Copyright (c) 1994-2001 Ralf S. Engelschall <rse@engelschall.com>"
|
||||
echo "Report bugs to <bug-shtool@gnu.org>"
|
||||
echo ''
|
||||
echo "Usage: shtool [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]"
|
||||
@@ -80,63 +78,38 @@ if [ ".$1" = ".-h" -o ".$1" = ".--help" ]; then
|
||||
echo ' -r, --recreate recreate this shtool script via shtoolize'
|
||||
echo ''
|
||||
echo 'Available <cmd-name> [<cmd-options>] [<cmd-args>]:'
|
||||
echo ' echo [-n|--newline] [-e|--expand] [<str> ...]'
|
||||
echo ' install [-v|--verbose] [-t|--trace] [-d|--mkdir] [-c|--copy]'
|
||||
echo ' [-C|--compare-copy] [-s|--strip] [-m|--mode <mode>]'
|
||||
echo ' [-o|--owner <owner>] [-g|--group <group>] [-e|--exec'
|
||||
echo ' <sed-cmd>] <file> [<file> ...] <path>'
|
||||
echo ' mkdir [-t|--trace] [-f|--force] [-p|--parents] [-m|--mode'
|
||||
echo ' <mode>] [-o|--owner <owner>] [-g|--group <group>] <dir>'
|
||||
echo ' [<dir> ...]'
|
||||
echo ' path [-s|--suppress] [-r|--reverse] [-d|--dirname] [-b|--basename]'
|
||||
echo ' [-m|--magic] [-p|--path <path>] <str> [<str> ...]'
|
||||
echo ' echo [-n] [-e] [<str> ...]'
|
||||
echo ' install [-v] [-t] [-c] [-C] [-s] [-m<mode>] [-o<owner>] [-g<group>]'
|
||||
echo ' [-e<sed-cmd>] <file> [<file> ...] <path>'
|
||||
echo ' mkdir [-t] [-f] [-p] [-m<mode>] <dir> [<dir> ...]'
|
||||
echo ''
|
||||
echo 'Not available <cmd-name> (because module was not built-in):'
|
||||
echo ' mdate [-n|--newline] [-z|--zero] [-s|--shorten] [-d|--digits]'
|
||||
echo ' [-f|--field-sep <str>] [-o|--order <spec>] <path>'
|
||||
echo ' table [-F|--field-sep <sep>] [-w|--width <width>] [-c|--columns'
|
||||
echo ' <cols>] [-s|--strip <strip>] <str><sep><str>...'
|
||||
echo ' prop [-p|--prefix <str>]'
|
||||
echo ' move [-v|--verbose] [-t|--trace] [-e|--expand] [-p|--preserve]'
|
||||
echo ' <src-file> <dst-file>'
|
||||
echo ' mkln [-t|--trace] [-f|--force] [-s|--symbolic] <src-path>'
|
||||
echo ' [<src-path> ...] <dst-path>'
|
||||
echo ' mkshadow [-v|--verbose] [-t|--trace] [-a|--all] <src-dir> <dst-dir>'
|
||||
echo ' fixperm [-v|--verbose] [-t|--trace] <path> [<path> ...]'
|
||||
echo ' rotate [-v|--verbose] [-t|--trace] [-f|--force] [-n|--num-files'
|
||||
echo ' <count>] [-s|--size <size>] [-c|--copy] [-r|--remove]'
|
||||
echo ' [-a|--archive-dir <dir>] [-z|--compress [<tool>:]<level>]'
|
||||
echo ' [-b|--background] [-d|--delay] [-p|--pad <len>] [-o|--owner'
|
||||
echo ' <owner>] [-g|--group <group>] [-m|--mode <mode>] [-M|--migrate'
|
||||
echo ' <cmd>] [-P|--prolog <cmd>] [-E|--epilog <cmd>] <file> [...]'
|
||||
echo ' tarball [-t|--trace] [-v|--verbose] [-o|--output <tarball>]'
|
||||
echo ' [-c|--compress <prog>] [-d|--directory <dir>] [-u|--user'
|
||||
echo ' <user>] [-g|--group <group>] [-e|--exclude <pattern>]'
|
||||
echo ' <path> [<path> ...]'
|
||||
echo ' subst [-v|--verbose] [-t|--trace] [-n|--nop] [-s|--stealth]'
|
||||
echo ' [-i|--interactive] [-b|--backup <ext>] [-e|--exec <cmd>]'
|
||||
echo ' [-f|--file <cmd-file>] [<file>] [...]'
|
||||
echo ' mdate [-n] [-z] [-s] [-d] [-f<str>] [-o<spec>] <path>'
|
||||
echo ' table [-F<sep>] [-w<width>] [-c<cols>] [-s<strip>] <str><sep><str>...'
|
||||
echo ' prop [-p<str>]'
|
||||
echo ' move [-v] [-t] [-e] [-p] <src-file> <dst-file>'
|
||||
echo ' mkln [-t] [-f] [-s] <src-path> [<src-path> ...] <dst-path>'
|
||||
echo ' mkshadow [-v] [-t] [-a] <src-dir> <dst-dir>'
|
||||
echo ' fixperm [-v] [-t] <path> [<path> ...]'
|
||||
echo ' tarball [-t] [-v] [-o<tarball>] [-c<prog>] [-d<dir>] [-u<user>]'
|
||||
echo ' [-g<group>] [-e<pattern>] <path> [<path> ...]'
|
||||
echo ' guessos '
|
||||
echo ' arx [-t|--trace] [-C|--command <cmd>] <op> <archive> [<file>'
|
||||
echo ' ...]'
|
||||
echo ' slo [-p|--prefix <str>] -- -L<dir> -l<lib> [-L<dir> -l<lib>'
|
||||
echo ' ...]'
|
||||
echo ' scpp [-v|--verbose] [-p|--preserve] [-f|--filter <filter>]'
|
||||
echo ' [-o|--output <ofile>] [-t|--template <tfile>] [-M|--mark'
|
||||
echo ' <mark>] [-D|--define <dname>] [-C|--class <cname>]'
|
||||
echo ' <file> [<file> ...]'
|
||||
echo ' version [-l|--language <lang>] [-n|--name <name>] [-p|--prefix'
|
||||
echo ' <prefix>] [-s|--set <version>] [-e|--edit] [-i|--increase'
|
||||
echo ' <knob>] [-d|--display <type>] <file>'
|
||||
echo ' arx [-t] [-C<cmd>] <op> <archive> [<file> ...]'
|
||||
echo ' slo [-p<str>] -- -L<dir> -l<lib> [-L<dir> -l<lib> ...]'
|
||||
echo ' scpp [-v] [-p] [-f<filter>] [-o<ofile>] [-t<tfile>] [-M<mark>]'
|
||||
echo ' [-D<dname>] [-C<cname>] <file> [<file> ...]'
|
||||
echo ' version [-l<lang>] [-n<name>] [-p<prefix>] [-s<version>] [-e]'
|
||||
echo ' [-i<knob>] [-d<type>] <file>'
|
||||
echo ' path [-s] [-r] [-d] [-b] [-m] [-p<path>] <str> [<str> ...]'
|
||||
echo ''
|
||||
exit 0
|
||||
fi
|
||||
if [ ".$1" = ".-v" -o ".$1" = ."--version" ]; then
|
||||
echo "GNU shtool 1.6.2 (02-Nov-2002)"
|
||||
echo "GNU shtool 1.5.4 (14-Jun-2001)"
|
||||
exit 0
|
||||
fi
|
||||
if [ ".$1" = ".-r" -o ".$1" = ."--recreate" ]; then
|
||||
shtoolize -oshtool echo install mkdir path
|
||||
shtoolize -ofoo echo install mkdir
|
||||
exit 0
|
||||
fi
|
||||
if [ ".$1" = ".-d" -o ".$1" = ."--debug" ]; then
|
||||
@@ -145,7 +118,7 @@ if [ ".$1" = ".-d" -o ".$1" = ."--debug" ]; then
|
||||
fi
|
||||
name=`echo "$0" | sed -e 's;.*/\([^/]*\)$;\1;' -e 's;-sh$;;' -e 's;\.sh$;;'`
|
||||
case "$name" in
|
||||
echo|install|mkdir|path )
|
||||
echo|install|mkdir )
|
||||
# implicit tool command selection
|
||||
tool="$name"
|
||||
;;
|
||||
@@ -166,22 +139,19 @@ gen_tmpfile=no
|
||||
case $tool in
|
||||
echo )
|
||||
str_tool="echo"
|
||||
str_usage="[-n|--newline] [-e|--expand] [<str> ...]"
|
||||
str_usage="[-n] [-e] [<str> ...]"
|
||||
arg_spec="0+"
|
||||
opt_spec="n.e."
|
||||
opt_alias="n:newline,e:expand"
|
||||
opt_n=no
|
||||
opt_e=no
|
||||
;;
|
||||
install )
|
||||
str_tool="install"
|
||||
str_usage="[-v|--verbose] [-t|--trace] [-d|--mkdir] [-c|--copy] [-C|--compare-copy] [-s|--strip] [-m|--mode <mode>] [-o|--owner <owner>] [-g|--group <group>] [-e|--exec <sed-cmd>] <file> [<file> ...] <path>"
|
||||
arg_spec="1+"
|
||||
opt_spec="v.t.d.c.C.s.m:o:g:e+"
|
||||
opt_alias="v:verbose,t:trace,d:mkdir,c:copy,C:compare-copy,s:strip,m:mode,o:owner,g:group,e:exec"
|
||||
str_usage="[-v] [-t] [-c] [-C] [-s] [-m<mode>] [-o<owner>] [-g<group>] [-e<sed-cmd>] <file> [<file> ...] <path>"
|
||||
arg_spec="2+"
|
||||
opt_spec="v.t.c.C.s.m:o:g:e+"
|
||||
opt_v=no
|
||||
opt_t=no
|
||||
opt_d=no
|
||||
opt_c=no
|
||||
opt_C=no
|
||||
opt_s=no
|
||||
@@ -192,30 +162,13 @@ case $tool in
|
||||
;;
|
||||
mkdir )
|
||||
str_tool="mkdir"
|
||||
str_usage="[-t|--trace] [-f|--force] [-p|--parents] [-m|--mode <mode>] [-o|--owner <owner>] [-g|--group <group>] <dir> [<dir> ...]"
|
||||
str_usage="[-t] [-f] [-p] [-m<mode>] <dir> [<dir> ...]"
|
||||
arg_spec="1+"
|
||||
opt_spec="t.f.p.m:o:g:"
|
||||
opt_alias="t:trace,f:force,p:parents,m:mode,o:owner,g:group"
|
||||
opt_spec="t.f.p.m:"
|
||||
opt_t=no
|
||||
opt_f=no
|
||||
opt_p=no
|
||||
opt_m=""
|
||||
opt_o=""
|
||||
opt_g=""
|
||||
;;
|
||||
path )
|
||||
str_tool="path"
|
||||
str_usage="[-s|--suppress] [-r|--reverse] [-d|--dirname] [-b|--basename] [-m|--magic] [-p|--path <path>] <str> [<str> ...]"
|
||||
gen_tmpfile=yes
|
||||
arg_spec="1+"
|
||||
opt_spec="s.r.d.b.m.p:"
|
||||
opt_alias="s:suppress,r:reverse,d:dirname,b:basename,m:magic,p:path"
|
||||
opt_s=no
|
||||
opt_r=no
|
||||
opt_d=no
|
||||
opt_b=no
|
||||
opt_m=no
|
||||
opt_p="$PATH"
|
||||
;;
|
||||
-* )
|
||||
echo "$0:Error: unknown option \`$tool'" 2>&1
|
||||
@@ -233,11 +186,6 @@ esac
|
||||
## COMMON UTILITY CODE
|
||||
##
|
||||
|
||||
# commonly used ASCII values
|
||||
ASC_TAB=" "
|
||||
ASC_NL="
|
||||
"
|
||||
|
||||
# determine name of tool
|
||||
if [ ".$tool" != . ]; then
|
||||
# used inside shtool script
|
||||
@@ -259,10 +207,6 @@ eval `echo $arg_spec |\
|
||||
eval `echo h.$opt_spec |\
|
||||
sed -e 's/\([a-zA-Z0-9]\)\([.:+]\)/opt_MODE_\1=\2;/g'`
|
||||
|
||||
# parse option alias string
|
||||
eval `echo h:help,$opt_alias |\
|
||||
tr 'x-' 'x_' | sed -e 's/\([a-zA-Z0-9]\):\([^,]*\),*/opt_ALIAS_\2=\1;/g'`
|
||||
|
||||
# interate over argument line
|
||||
opt_PREV=''
|
||||
while [ $# -gt 0 ]; do
|
||||
@@ -283,18 +227,6 @@ while [ $# -gt 0 ]; do
|
||||
else
|
||||
# split argument into option and argument
|
||||
case "$1" in
|
||||
--[a-zA-Z0-9]*=*)
|
||||
eval `echo "x$1" |\
|
||||
sed -e 's/^x--\([a-zA-Z0-9-]*\)=\(.*\)$/opt_OPT="\1";opt_ARG="\2"/'`
|
||||
opt_STR=`echo $opt_OPT | tr 'x-' 'x_'`
|
||||
eval "opt_OPT=\${opt_ALIAS_${opt_STR}-${opt_OPT}}"
|
||||
;;
|
||||
--[a-zA-Z0-9]*)
|
||||
opt_OPT=`echo "x$1" | cut -c4-`
|
||||
opt_STR=`echo $opt_OPT | tr 'x-' 'x_'`
|
||||
eval "opt_OPT=\${opt_ALIAS_${opt_STR}-${opt_OPT}}"
|
||||
opt_ARG=''
|
||||
;;
|
||||
-[a-zA-Z0-9]*)
|
||||
eval `echo "x$1" |\
|
||||
sed -e 's/^x-\([a-zA-Z0-9]\)/opt_OPT="\1";/' \
|
||||
@@ -334,17 +266,17 @@ while [ $# -gt 0 ]; do
|
||||
;;
|
||||
'+' )
|
||||
# option with argument (multiple occurances append)
|
||||
eval "opt_${opt_OPT}=\"\$opt_${opt_OPT}\${ASC_NL}\$opt_ARG\""
|
||||
eval "opt_${opt_OPT}=\"\$opt_${opt_OPT} \$opt_ARG\""
|
||||
;;
|
||||
* )
|
||||
echo "$msgprefix:Error: unknown option: \`$opt_OPT'" 1>&2
|
||||
echo "$msgprefix:Error: unknown option: \`-$opt_OPT'" 1>&2
|
||||
echo "$msgprefix:Hint: run \`$toolcmdhelp -h' or \`man shtool' for details" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [ ".$opt_PREV" != . ]; then
|
||||
echo "$msgprefix:Error: missing argument to option \`$opt_PREV'" 1>&2
|
||||
echo "$msgprefix:Error: missing argument to option \`-$opt_PREV'" 1>&2
|
||||
echo "$msgprefix:Hint: run \`$toolcmdhelp -h' or \`man shtool' for details" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
@@ -397,7 +329,7 @@ case $tool in
|
||||
echo )
|
||||
##
|
||||
## echo -- Print string with optional construct expansion
|
||||
## Copyright (c) 1998-2002 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## Copyright (c) 1998-2001 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## Originally written for WML as buildinfo
|
||||
##
|
||||
|
||||
@@ -430,7 +362,7 @@ echo )
|
||||
term_bold=`awk 'BEGIN { printf("%c%c%c%c", 27, 91, 49, 109); }' </dev/null 2>/dev/null`
|
||||
term_norm=`awk 'BEGIN { printf("%c%c%c", 27, 91, 109); }' </dev/null 2>/dev/null`
|
||||
;;
|
||||
vt100|vt100*|cygwin)
|
||||
vt100|vt100*)
|
||||
term_bold=`awk 'BEGIN { printf("%c%c%c%c%c%c", 27, 91, 49, 109, 0, 0); }' </dev/null 2>/dev/null`
|
||||
term_norm=`awk 'BEGIN { printf("%c%c%c%c%c", 27, 91, 109, 0, 0); }' </dev/null 2>/dev/null`
|
||||
;;
|
||||
@@ -448,7 +380,7 @@ echo )
|
||||
fi
|
||||
done
|
||||
if [ ".$term_bold" != . ]; then
|
||||
for seq in sgr0 me rmso init reset; do # 'reset' is last
|
||||
for seq in sgr0 me rmso reset; do # 'reset' is last
|
||||
norm="`$dir/$tool $seq 2>/dev/null`"
|
||||
if [ ".$norm" != . ]; then
|
||||
term_norm="$norm"
|
||||
@@ -467,8 +399,6 @@ echo )
|
||||
esac
|
||||
if [ ".$term_bold" = . -o ".$term_norm" = . ]; then
|
||||
echo "$msgprefix:Warning: unable to determine terminal sequence for bold mode" 1>&2
|
||||
term_bold=''
|
||||
term_norm=''
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -568,13 +498,13 @@ echo )
|
||||
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%d'`" != . ]; then
|
||||
if [ ".$domainname" = . ]; then
|
||||
if [ -f /etc/resolv.conf ]; then
|
||||
domainname="`egrep '^[ ]*domain' /etc/resolv.conf | sed -e 'q' |\
|
||||
domainname="`egrep '^[ ]*domain' /etc/resolv.conf | head -1 |\
|
||||
sed -e 's/.*domain//' \
|
||||
-e 's/^[ ]*//' -e 's/^ *//' -e 's/^ *//' \
|
||||
-e 's/^\.//' -e 's/^/./' |\
|
||||
awk '{ printf("%s", $1); }'`"
|
||||
if [ ".$domainname" = . ]; then
|
||||
domainname="`egrep '^[ ]*search' /etc/resolv.conf | sed -e 'q' |\
|
||||
domainname="`egrep '^[ ]*search' /etc/resolv.conf | head -1 |\
|
||||
sed -e 's/.*search//' \
|
||||
-e 's/^[ ]*//' -e 's/^ *//' -e 's/^ *//' \
|
||||
-e 's/ .*//' -e 's/ .*//' \
|
||||
@@ -651,32 +581,10 @@ echo )
|
||||
install )
|
||||
##
|
||||
## install -- Install a program, script or datafile
|
||||
## Copyright (c) 1997-2002 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## Copyright (c) 1997-2001 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## Originally written for shtool
|
||||
##
|
||||
|
||||
# special case: "shtool install -d <dir> [...]" internally
|
||||
# maps to "shtool mkdir -f -p -m 755 <dir> [...]"
|
||||
if [ "$opt_d" = yes ]; then
|
||||
cmd="$0 mkdir -f -p -m 755"
|
||||
if [ ".$opt_o" != . ]; then
|
||||
cmd="$cmd -o '$opt_o'"
|
||||
fi
|
||||
if [ ".$opt_g" != . ]; then
|
||||
cmd="$cmd -g '$opt_g'"
|
||||
fi
|
||||
if [ ".$opt_v" = .yes ]; then
|
||||
cmd="$cmd -v"
|
||||
fi
|
||||
if [ ".$opt_t" = .yes ]; then
|
||||
cmd="$cmd -t"
|
||||
fi
|
||||
for dir in "$@"; do
|
||||
eval "$cmd $dir" || exit $?
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# determine source(s) and destination
|
||||
argc=$#
|
||||
srcs=""
|
||||
@@ -749,9 +657,7 @@ install )
|
||||
# adjust the target file
|
||||
if [ ".$opt_e" != . ]; then
|
||||
sed='sed'
|
||||
OIFS="$IFS"; IFS="$ASC_NL"; set -- $opt_e; IFS="$OIFS"
|
||||
for e
|
||||
do
|
||||
for e in $opt_e; do
|
||||
sed="$sed -e '$e'"
|
||||
done
|
||||
cp $dsttmp $dsttmp.old
|
||||
@@ -812,7 +718,7 @@ install )
|
||||
mkdir )
|
||||
##
|
||||
## mkdir -- Make one or more directories
|
||||
## Copyright (c) 1996-2002 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## Copyright (c) 1996-2001 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## Originally written for public domain by Noah Friedman <friedman@prep.ai.mit.edu>
|
||||
## Cleaned up and enhanced for shtool
|
||||
##
|
||||
@@ -835,18 +741,6 @@ mkdir )
|
||||
echo "mkdir $p" 1>&2
|
||||
fi
|
||||
mkdir $p || errstatus=$?
|
||||
if [ ".$opt_o" != . ]; then
|
||||
if [ ".$opt_t" = .yes ]; then
|
||||
echo "chown $opt_o $p" 1>&2
|
||||
fi
|
||||
chown $opt_o $p || errstatus=$?
|
||||
fi
|
||||
if [ ".$opt_g" != . ]; then
|
||||
if [ ".$opt_t" = .yes ]; then
|
||||
echo "chgrp $opt_g $p" 1>&2
|
||||
fi
|
||||
chgrp $opt_g $p || errstatus=$?
|
||||
fi
|
||||
if [ ".$opt_m" != . ]; then
|
||||
if [ ".$opt_t" = .yes ]; then
|
||||
echo "chmod $opt_m $p" 1>&2
|
||||
@@ -872,18 +766,6 @@ mkdir )
|
||||
echo "mkdir $pathcomp" 1>&2
|
||||
fi
|
||||
mkdir $pathcomp || errstatus=$?
|
||||
if [ ".$opt_o" != . ]; then
|
||||
if [ ".$opt_t" = .yes ]; then
|
||||
echo "chown $opt_o $pathcomp" 1>&2
|
||||
fi
|
||||
chown $opt_o $pathcomp || errstatus=$?
|
||||
fi
|
||||
if [ ".$opt_g" != . ]; then
|
||||
if [ ".$opt_t" = .yes ]; then
|
||||
echo "chgrp $opt_g $pathcomp" 1>&2
|
||||
fi
|
||||
chgrp $opt_g $pathcomp || errstatus=$?
|
||||
fi
|
||||
if [ ".$opt_m" != . ]; then
|
||||
if [ ".$opt_t" = .yes ]; then
|
||||
echo "chmod $opt_m $pathcomp" 1>&2
|
||||
@@ -898,147 +780,6 @@ mkdir )
|
||||
exit $errstatus
|
||||
;;
|
||||
|
||||
path )
|
||||
##
|
||||
## path -- Deal with program paths
|
||||
## Copyright (c) 1998-2002 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## Originally written for Apache
|
||||
##
|
||||
|
||||
namelist="$*"
|
||||
|
||||
# check whether the test command supports the -x option
|
||||
if [ -x /bin/sh ] 2>/dev/null; then
|
||||
minusx="-x"
|
||||
else
|
||||
minusx="-r"
|
||||
fi
|
||||
|
||||
# split path string
|
||||
paths="`echo $opt_p |\
|
||||
sed -e 's/^:/.:/' \
|
||||
-e 's/::/:.:/g' \
|
||||
-e 's/:$/:./' \
|
||||
-e 's/:/ /g'`"
|
||||
|
||||
# SPECIAL REQUEST
|
||||
# translate forward to reverse path
|
||||
if [ ".$opt_r" = .yes ]; then
|
||||
if [ "x$namelist" = "x." ]; then
|
||||
rp='.'
|
||||
else
|
||||
rp=''
|
||||
for pe in `IFS="$IFS/"; echo $namelist`; do
|
||||
rp="../$rp"
|
||||
done
|
||||
fi
|
||||
echo $rp | sed -e 's:/$::'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# SPECIAL REQUEST
|
||||
# strip out directory or base name
|
||||
if [ ".$opt_d" = .yes ]; then
|
||||
echo "$namelist" |\
|
||||
sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'
|
||||
exit 0
|
||||
fi
|
||||
if [ ".$opt_b" = .yes ]; then
|
||||
echo "$namelist" |\
|
||||
sed -e 's;.*/\([^/]*\)$;\1;'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# MAGIC SITUATION
|
||||
# Perl Interpreter (perl)
|
||||
if [ ".$opt_m" = .yes -a ".$namelist" = .perl ]; then
|
||||
rm -f $tmpfile >/dev/null 2>&1
|
||||
touch $tmpfile
|
||||
found=0
|
||||
pc=99
|
||||
for dir in $paths; do
|
||||
dir=`echo $dir | sed -e 's;/*$;;'`
|
||||
nc=99
|
||||
for name in perl perl5 miniperl; do
|
||||
if [ $minusx "$dir/$name" -a ! -d "$dir/$name" ]; then
|
||||
perl="$dir/$name"
|
||||
pv=`$perl -e 'printf("%.3f", $]);'`
|
||||
echo "$pv:$pc:$nc:$perl" >>$tmpfile
|
||||
found=1
|
||||
fi
|
||||
nc=`expr $nc - 1`
|
||||
done
|
||||
pc=`expr $pc - 1`
|
||||
done
|
||||
if [ $found = 1 ]; then
|
||||
perl="`cat $tmpfile | sort -r -u | sed -e 'q' | cut -d: -f4`"
|
||||
rm -f $tmpfile >/dev/null 2>&1
|
||||
echo "$perl"
|
||||
exit 0
|
||||
fi
|
||||
rm -f $tmpfile >/dev/null 2>&1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# MAGIC SITUATION
|
||||
# C pre-processor (cpp)
|
||||
if [ ".$opt_m" = .yes -a ".$namelist" = .cpp ]; then
|
||||
echo >$tmpfile.c "#include <assert.h>"
|
||||
echo >>$tmpfile.c "Syntax Error"
|
||||
# 1. try the standard cc -E approach
|
||||
cpp="${CC-cc} -E"
|
||||
(eval "$cpp $tmpfile.c >/dev/null") 2>$tmpfile.out
|
||||
my_error=`grep -v '^ *+' $tmpfile.out`
|
||||
if [ ".$my_error" != . ]; then
|
||||
# 2. try the cc -E approach and GCC's -traditional-ccp option
|
||||
cpp="${CC-cc} -E -traditional-cpp"
|
||||
(eval "$cpp $tmpfile.c >/dev/null") 2>$tmpfile.out
|
||||
my_error=`grep -v '^ *+' $tmpfile.out`
|
||||
if [ ".$my_error" != . ]; then
|
||||
# 3. try a standalone cpp command in path and lib dirs
|
||||
for path in $paths /lib /usr/lib /usr/local/lib; do
|
||||
path=`echo $path | sed -e 's;/*$;;'`
|
||||
if [ $minusx "$path/cpp" -a ! -d "$path/cpp" ]; then
|
||||
cpp="$path/cpp"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ ".$cpp" != . ]; then
|
||||
(eval "$cpp $tmpfile.c >/dev/null") 2>$tmpfile.out
|
||||
my_error=`grep -v '^ *+' $tmpfile.out`
|
||||
if [ ".$my_error" != . ]; then
|
||||
# ok, we gave up...
|
||||
cpp=''
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
rm -f $tmpfile >/dev/null 2>&1
|
||||
rm -f $tmpfile.c $tmpfile.out >/dev/null 2>&1
|
||||
if [ ".$cpp" != . ]; then
|
||||
echo "$cpp"
|
||||
exit 0
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# STANDARD SITUATION
|
||||
# iterate over names
|
||||
for name in $namelist; do
|
||||
# iterate over paths
|
||||
for path in $paths; do
|
||||
path=`echo $path | sed -e 's;/*$;;'`
|
||||
if [ $minusx "$path/$name" -a ! -d "$path/$name" ]; then
|
||||
if [ ".$opt_s" != .yes ]; then
|
||||
echo "$path/$name"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
done
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -1,18 +1,6 @@
|
||||
#!/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
|
||||
@@ -23,20 +11,9 @@ while test $# -gt 0; do
|
||||
echo "Using Zend Engine 2 code"
|
||||
fi
|
||||
|
||||
if test "$1" = "--force"; then
|
||||
devok=1
|
||||
echo "Forcing buildconf"
|
||||
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
|
||||
ZENDDIR=Zend
|
||||
echo "using default Zend directory"
|
||||
|
||||
Vendored
+31
-69
@@ -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
@@ -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)
|
||||
|
||||
+69
-170
@@ -27,7 +27,6 @@ dnl ## Diversion 5 is the last one. Here we generate files and clean up.
|
||||
dnl Basic autoconf + automake initialization, generation of config.nice.
|
||||
dnl -------------------------------------------------------------------------
|
||||
|
||||
AC_PREREQ(2.13)
|
||||
AC_INIT(README.CVS-RULES)
|
||||
|
||||
PHP_CONFIG_NICE(config.nice)
|
||||
@@ -40,8 +39,8 @@ AC_CONFIG_HEADER(main/php_config.h)
|
||||
|
||||
MAJOR_VERSION=4
|
||||
MINOR_VERSION=3
|
||||
RELEASE_VERSION=2
|
||||
EXTRA_VERSION=
|
||||
RELEASE_VERSION=0
|
||||
EXTRA_VERSION="-dev"
|
||||
VERSION="$MAJOR_VERSION.$MINOR_VERSION.$RELEASE_VERSION$EXTRA_VERSION"
|
||||
|
||||
dnl Define where extension directories are located in the configure context
|
||||
@@ -61,15 +60,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 +87,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
|
||||
|
||||
@@ -135,9 +135,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}" = "1" -a "(" "${2}" -lt "75" -a "${2}" -ne "28" -a "${2}" -ne "35" -o "${2}" -ge "875" ")"; then
|
||||
AC_MSG_WARN(You will need bison 1.28, 1.35 or 1.75 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
|
||||
@@ -154,20 +154,6 @@ if test "$ac_cv_c_const" = "yes" ; then
|
||||
LEX_CFLAGS="-DYY_USE_CONST"
|
||||
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.)
|
||||
fi
|
||||
|
||||
dnl Platform-specific compile settings.
|
||||
dnl -------------------------------------------------------------------------
|
||||
@@ -229,15 +215,19 @@ dnl SAPI configuration.
|
||||
dnl -------------------------------------------------------------------------
|
||||
|
||||
dnl paths to the targets are relative to the build directory
|
||||
SAPI_PROGRAM=php
|
||||
SAPI_SHARED=libs/libphp4.$SHLIB_SUFFIX_NAME
|
||||
SAPI_STATIC=libs/libphp4.a
|
||||
SAPI_LIBTOOL=libphp4.la
|
||||
|
||||
PHP_CONFIGURE_PART(Configuring SAPI modules)
|
||||
|
||||
esyscmd(./build/config-stubs sapi)
|
||||
esyscmd(./scripts/config-stubs sapi)
|
||||
|
||||
if test "$PHP_SAPI" = "default"; then
|
||||
PHP_SELECT_SAPI(cgi, program, cgi_main.c getopt.c)
|
||||
fi
|
||||
|
||||
dnl Show which main SAPI was selected
|
||||
AC_MSG_CHECKING([for chosen SAPI module])
|
||||
AC_MSG_RESULT([$PHP_SAPI])
|
||||
|
||||
@@ -246,11 +236,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)
|
||||
|
||||
@@ -294,10 +279,7 @@ PHP_CHECK_FUNC(gethostname, nsl)
|
||||
PHP_CHECK_FUNC(gethostbyaddr, nsl)
|
||||
PHP_CHECK_FUNC(yp_get_default_domain, nsl)
|
||||
|
||||
PHP_CHECK_FUNC(dlopen, dl)
|
||||
if test "$ac_cv_func_dlopen" = "yes"; then
|
||||
AC_DEFINE(HAVE_LIBDL, 1, [ ])
|
||||
fi
|
||||
AC_CHECK_LIB(dl, dlopen, [PHP_ADD_LIBRARY(dl)])
|
||||
AC_CHECK_LIB(m, sin)
|
||||
|
||||
dnl Check for resolver routines.
|
||||
@@ -341,9 +323,7 @@ ieeefp.h \
|
||||
langinfo.h \
|
||||
limits.h \
|
||||
locale.h \
|
||||
monetary.h \
|
||||
mach-o/dyld.h \
|
||||
netdb.h \
|
||||
pwd.h \
|
||||
resolv.h \
|
||||
signal.h \
|
||||
@@ -369,7 +349,6 @@ unistd.h \
|
||||
unix.h \
|
||||
utime.h \
|
||||
sys/utsname.h \
|
||||
sys/ipc.h \
|
||||
],[],[],[
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
@@ -385,9 +364,7 @@ sys/ipc.h \
|
||||
#endif
|
||||
])
|
||||
|
||||
PHP_FOPENCOOKIE
|
||||
PHP_BROKEN_GETCWD
|
||||
PHP_BROKEN_GLIBC_FOPEN_APPEND
|
||||
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
dnl -------------------------------------------------------------------------
|
||||
@@ -427,21 +404,15 @@ if test "$ac_cv_sockaddr_storage" = yes; then
|
||||
AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[Whether you have struct sockaddr_storage])
|
||||
fi
|
||||
|
||||
dnl Check if sockaddr data structure includes an "sa_len" member
|
||||
|
||||
AC_TRY_COMPILE([
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
], [static struct sockaddr sa; int n = (int) sa.sa_len; return n],
|
||||
[AC_DEFINE(HAVE_SOCKADDR_LEN,1,[Whether sockaddr struct has sa_len])],
|
||||
[])
|
||||
|
||||
dnl Check for IPv6 support
|
||||
AC_CACHE_CHECK([for IPv6 support], ac_cv_ipv6_support,
|
||||
[AC_TRY_LINK([ #include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>], [struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0;],
|
||||
[ac_cv_ipv6_support=yes], [ac_cv_ipv6_support=no])])
|
||||
if test "$ac_cv_ipv6_support" = yes; then
|
||||
AC_DEFINE(HAVE_IPV6,1,[Whether you have IPv6 support])
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -450,15 +421,12 @@ dnl -------------------------------------------------------------------------
|
||||
|
||||
AC_FUNC_VPRINTF
|
||||
AC_CHECK_FUNCS(
|
||||
alphasort \
|
||||
asctime_r \
|
||||
chroot \
|
||||
ctime_r \
|
||||
cuserid \
|
||||
crypt \
|
||||
flock \
|
||||
ftok \
|
||||
funopen \
|
||||
gai_strerror \
|
||||
gcvt \
|
||||
getlogin \
|
||||
@@ -479,15 +447,12 @@ memmove \
|
||||
mkstemp \
|
||||
mmap \
|
||||
nl_langinfo \
|
||||
perror \
|
||||
poll \
|
||||
putenv \
|
||||
realpath \
|
||||
random \
|
||||
rand_r \
|
||||
regcomp \
|
||||
res_search \
|
||||
scandir \
|
||||
setitimer \
|
||||
setlocale \
|
||||
localeconv \
|
||||
@@ -530,7 +495,6 @@ AC_REPLACE_FUNCS(strlcat strlcpy getopt)
|
||||
AC_FUNC_UTIME_NULL
|
||||
AC_FUNC_ALLOCA
|
||||
PHP_AC_BROKEN_SPRINTF
|
||||
PHP_AC_BROKEN_SNPRINTF
|
||||
PHP_DECLARED_TIMEZONE
|
||||
PHP_TIME_R_TYPE
|
||||
PHP_READDIR_R_TYPE
|
||||
@@ -563,12 +527,12 @@ dnl ## In diversion 4 we check user-configurable general settings.
|
||||
|
||||
dnl General settings.
|
||||
dnl -------------------------------------------------------------------------
|
||||
PHP_CONFIGURE_PART(General settings)
|
||||
|
||||
|
||||
PHP_HELP_SEPARATOR([General settings:])
|
||||
|
||||
PHP_ARG_ENABLE(debug, whether to include debugging symbols,
|
||||
[ --enable-debug Compile with debugging symbols.], no, no)
|
||||
[ --enable-debug Compile with debugging symbols.], no)
|
||||
|
||||
if test "$PHP_DEBUG" = "yes"; then
|
||||
PHP_DEBUG=1
|
||||
@@ -580,7 +544,7 @@ fi
|
||||
|
||||
PHP_ARG_WITH(layout,[layout of installed files],
|
||||
[ --with-layout=TYPE Sets how installed files will be laid out. Type is
|
||||
one of "PHP" (default) or "GNU"], PHP, no)
|
||||
one of "PHP" (default) or "GNU"], PHP)
|
||||
|
||||
case $PHP_LAYOUT in
|
||||
GNU)
|
||||
@@ -594,7 +558,7 @@ esac
|
||||
PHP_ARG_WITH(config-file-path,[path to configuration file],
|
||||
[ --with-config-file-path=PATH
|
||||
Sets the path in which to look for php.ini,
|
||||
defaults to PREFIX/lib], DEFAULT, no)
|
||||
defaults to PREFIX/lib], DEFAULT)
|
||||
|
||||
if test "$PHP_CONFIG_FILE_PATH" = "DEFAULT"; then
|
||||
case $PHP_LAYOUT in
|
||||
@@ -607,12 +571,6 @@ if test "$PHP_CONFIG_FILE_PATH" = "DEFAULT"; then
|
||||
esac
|
||||
fi
|
||||
|
||||
PHP_ARG_WITH(config-file-scan-dir,[directory to be scanned for configuration files],
|
||||
[ --with-config-file-scan-dir=PATH ], DEFAULT, no)
|
||||
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
|
||||
@@ -620,10 +578,10 @@ 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, yes)
|
||||
--without-pear Do not install PEAR], DEFAULT)
|
||||
|
||||
if test "$PHP_PEAR" != "no" && test "$disable_cli" != "1"; then
|
||||
install_pear="install-pear"
|
||||
install_pear="install-pear install-build install-headers install-programs"
|
||||
PEAR_INSTALLDIR=$PHP_PEAR
|
||||
fi
|
||||
|
||||
@@ -637,7 +595,7 @@ fi
|
||||
test -n "$DEBUG_CFLAGS" && CFLAGS="$CFLAGS $DEBUG_CFLAGS"
|
||||
|
||||
PHP_ARG_ENABLE(safe-mode, whether to enable safe mode by default,
|
||||
[ --enable-safe-mode Enable safe mode by default.], no, no)
|
||||
[ --enable-safe-mode Enable safe mode by default.])
|
||||
|
||||
if test "$PHP_SAFE_MODE" = "yes"; then
|
||||
AC_DEFINE(PHP_SAFE_MODE,1,[ ])
|
||||
@@ -667,8 +625,16 @@ AC_ARG_WITH(exec-dir,
|
||||
AC_MSG_RESULT([/usr/local/php/bin])
|
||||
])
|
||||
|
||||
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
|
||||
|
||||
PHP_ARG_ENABLE(sigchild,whether to enable PHP's own SIGCHLD handler,
|
||||
[ --enable-sigchild Enable PHP's own SIGCHLD handler.], no, no)
|
||||
[ --enable-sigchild Enable PHP's own SIGCHLD handler.],no)
|
||||
|
||||
if test "$PHP_SIGCHILD" = "yes"; then
|
||||
AC_DEFINE(PHP_SIGCHILD, 1, [ ])
|
||||
@@ -677,7 +643,7 @@ else
|
||||
fi
|
||||
|
||||
PHP_ARG_ENABLE(magic-quotes,whether to enable magic quotes by default,
|
||||
[ --enable-magic-quotes Enable magic quotes by default.], no, no)
|
||||
[ --enable-magic-quotes Enable magic quotes by default.])
|
||||
|
||||
if test "$PHP_MAGIC_QUOTES" = "yes"; then
|
||||
AC_DEFINE(MAGIC_QUOTES, 1, [ ])
|
||||
@@ -687,10 +653,10 @@ fi
|
||||
|
||||
PHP_ARG_ENABLE(rpath, whether to enable runpaths,
|
||||
[ --disable-rpath Disable passing additional runtime library
|
||||
search paths], yes, no)
|
||||
search paths], yes)
|
||||
|
||||
PHP_ARG_ENABLE(libgcc, whether to explicitly link against libgcc,
|
||||
[ --enable-libgcc Enable explicitly linking against libgcc], no, no)
|
||||
[ --enable-libgcc Enable explicitly linking against libgcc])
|
||||
|
||||
if test "$PHP_LIBGCC" = "yes"; then
|
||||
PHP_LIBGCC_LIBPATH(gcc)
|
||||
@@ -702,7 +668,7 @@ if test "$PHP_LIBGCC" = "yes"; then
|
||||
fi
|
||||
|
||||
PHP_ARG_ENABLE(short-tags,whether to enable short tags by default,
|
||||
[ --disable-short-tags Disable the short-form <? start tag by default.],yes, no)
|
||||
[ --disable-short-tags Disable the short-form <? start tag by default.],yes)
|
||||
|
||||
if test "$PHP_SHORT_TAGS" = "yes"; then
|
||||
AC_DEFINE(DEFAULT_SHORT_OPEN_TAG,"1",[ ])
|
||||
@@ -710,8 +676,9 @@ else
|
||||
AC_DEFINE(DEFAULT_SHORT_OPEN_TAG,"0",[ ])
|
||||
fi
|
||||
|
||||
|
||||
PHP_ARG_ENABLE(dmalloc,whether to enable dmalloc,
|
||||
[ --enable-dmalloc Enable dmalloc], no, no)
|
||||
[ --enable-dmalloc Enable dmalloc])
|
||||
|
||||
if test "$PHP_DMALLOC" = "yes"; then
|
||||
|
||||
@@ -724,30 +691,21 @@ if test "$PHP_DMALLOC" = "yes"; then
|
||||
])
|
||||
fi
|
||||
|
||||
PHP_ARG_ENABLE(ipv6,whether to enable IPv6 support,
|
||||
[ --disable-ipv6 Disable IPv6 support], yes, no)
|
||||
|
||||
if test "$PHP_IPV6" != "no" && test "$ac_cv_ipv6_support" = yes; then
|
||||
AC_DEFINE(HAVE_IPV6,1,[Whether to enable IPv6 support])
|
||||
fi
|
||||
AC_CHECK_LIB(crypt, crypt, [
|
||||
PHP_ADD_LIBRARY(crypt)
|
||||
PHP_ADD_LIBRARY(crypt, 1)
|
||||
AC_DEFINE(HAVE_CRYPT,1,[ ])
|
||||
])
|
||||
|
||||
|
||||
dnl
|
||||
dnl OpenSSL configure
|
||||
dnl
|
||||
PHP_ARG_WITH(openssl,for OpenSSL support,
|
||||
[ --with-openssl[=DIR] Include OpenSSL support (requires OpenSSL >= 0.9.6) ])
|
||||
|
||||
if test "$PHP_OPENSSL" != "no"; then
|
||||
ext_openssl_shared=$ext_shared
|
||||
PHP_SETUP_OPENSSL
|
||||
fi
|
||||
|
||||
divert(5)
|
||||
|
||||
dnl ## In diversion 5 we check which extensions should be compiled.
|
||||
dnl ## All of these are normally in the extension directories.
|
||||
|
||||
|
||||
|
||||
dnl Extension configuration.
|
||||
dnl -------------------------------------------------------------------------
|
||||
|
||||
@@ -765,18 +723,8 @@ PHP_HELP_SEPARATOR([Extensions:
|
||||
|
||||
PHP_CONFIGURE_PART(Configuring extensions)
|
||||
|
||||
dnl
|
||||
dnl Check if all enabled by default extensions should be disabled
|
||||
dnl
|
||||
|
||||
AC_ARG_ENABLE(all,
|
||||
[ --disable-all Disable all extensions enabled by default.
|
||||
], [
|
||||
PHP_ENABLE_ALL=$enableval
|
||||
])
|
||||
|
||||
# reading config stubs
|
||||
esyscmd(./build/config-stubs ext)
|
||||
esyscmd(./scripts/config-stubs ext)
|
||||
|
||||
|
||||
dnl Other settings.
|
||||
@@ -787,12 +735,8 @@ 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], [
|
||||
if test "x$APXS" != "x"; then
|
||||
PHP_VERSIONING=$enableval
|
||||
else
|
||||
PHP_VERSIONING=no
|
||||
fi
|
||||
See INSTALL for more information],[
|
||||
PHP_VERSIONING=$enableval
|
||||
],[
|
||||
PHP_VERSIONING=no
|
||||
])
|
||||
@@ -801,7 +745,7 @@ 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
|
||||
|
||||
@@ -826,13 +770,6 @@ 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 Configuring Zend and TSRM.
|
||||
@@ -840,7 +777,6 @@ dnl -------------------------------------------------------------------------
|
||||
|
||||
PHP_CONFIGURE_PART(Configuring Zend)
|
||||
LIBZEND_BASIC_CHECKS
|
||||
LIBZEND_DLSYM_CHECK
|
||||
LIBZEND_OTHER_CHECKS
|
||||
|
||||
TSRM_LIB='TSRM/libtsrm.la'
|
||||
@@ -937,7 +873,6 @@ EXPANDED_LIBDIR=$libdir
|
||||
EXPANDED_SYSCONFDIR=`eval echo $sysconfdir`
|
||||
EXPANDED_DATADIR=$datadir
|
||||
EXPANDED_PHP_CONFIG_FILE_PATH=`eval echo "$PHP_CONFIG_FILE_PATH"`
|
||||
EXPANDED_PHP_CONFIG_FILE_SCAN_DIR=`eval echo "$PHP_CONFIG_FILE_SCAN_DIR"`
|
||||
INCLUDE_PATH=.:$EXPANDED_PEAR_INSTALLDIR
|
||||
|
||||
exec_prefix=$old_exec_prefix
|
||||
@@ -953,18 +888,11 @@ AC_SUBST(EXPANDED_DATADIR)
|
||||
AC_SUBST(EXPANDED_SYSCONFDIR)
|
||||
AC_SUBST(EXPANDED_LOCALSTATEDIR)
|
||||
AC_SUBST(EXPANDED_PHP_CONFIG_FILE_PATH)
|
||||
AC_SUBST(EXPANDED_PHP_CONFIG_FILE_SCAN_DIR)
|
||||
|
||||
if test -n "$php_ldflags_add_usr_lib"; then
|
||||
PHP_RPATHS="$PHP_RPATHS /usr/lib"
|
||||
fi
|
||||
|
||||
PHP_UTILIZE_RPATHS
|
||||
|
||||
if test -z "$php_ldflags_add_usr_lib"; then
|
||||
PHP_REMOVE_USR_LIB(PHP_LDFLAGS)
|
||||
PHP_REMOVE_USR_LIB(LDFLAGS)
|
||||
fi
|
||||
PHP_REMOVE_USR_LIB(PHP_LDFLAGS)
|
||||
PHP_REMOVE_USR_LIB(LDFLAGS)
|
||||
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $PHP_LDFLAGS"
|
||||
|
||||
@@ -976,7 +904,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
|
||||
@@ -999,7 +927,6 @@ PHP_SUBST(bindir)
|
||||
PHP_SUBST(exec_prefix)
|
||||
PHP_SUBST(includedir)
|
||||
PHP_SUBST(libdir)
|
||||
PHP_SUBST(mandir)
|
||||
PHP_SUBST(phplibdir)
|
||||
PHP_SUBST(phptempdir)
|
||||
PHP_SUBST(prefix)
|
||||
@@ -1021,7 +948,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(EXTRA_LDFLAGS)
|
||||
PHP_SUBST_OLD(EXTRA_LIBS)
|
||||
PHP_SUBST_OLD(ZEND_EXTRA_LIBS)
|
||||
PHP_SUBST_OLD(INCLUDES)
|
||||
@@ -1050,7 +977,6 @@ PHP_SUBST(TSRM_DIR)
|
||||
PHP_SUBST(TSRM_LIB)
|
||||
PHP_SUBST(WARNING_LEVEL)
|
||||
PHP_SUBST(PHP_FRAMEWORKS)
|
||||
PHP_SUBST(PHP_FRAMEWORKPATH)
|
||||
PHP_SUBST_OLD(YACC)
|
||||
PHP_SUBST_OLD(SHLIB_SUFFIX_NAME)
|
||||
|
||||
@@ -1073,20 +999,11 @@ if test "$PHP_THREAD_SAFETY" = "yes" && test "$PHP_MYSQL" = "yes"; then
|
||||
CPPFLAGS="$CPPFLAGS -DTHREAD=1"
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl Libtool creation
|
||||
dnl
|
||||
|
||||
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 $<'
|
||||
@@ -1103,18 +1020,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-sapi install-modules $install_pear install-build install-headers install-programs"
|
||||
if test "$PHP_SAPI" != "cgi"; then
|
||||
install_targets="$PHP_INSTALL_CLI_TARGET $install_targets"
|
||||
fi
|
||||
|
||||
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 \
|
||||
@@ -1122,7 +1035,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, \
|
||||
@@ -1153,20 +1066,16 @@ 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)
|
||||
|
||||
PHP_GEN_BUILD_DIRS
|
||||
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, [], [
|
||||
@@ -1186,10 +1095,10 @@ 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"
|
||||
@@ -1218,7 +1127,7 @@ dnl else
|
||||
dnl rm -f main/internal_functions.c.old
|
||||
dnl fi
|
||||
|
||||
if test "$UNAME" = "FreeBSD" && test "$PHP_SAPI" = "apache2filter" && test "$TSRM_PTH" != "pth-config" ; then
|
||||
if test $UNAME = "FreeBSD" && test $PHP_SAPI = "apache2filter" && test $TSRM_PTH != "pth-config" ; then
|
||||
echo "+--------------------------------------------------------------------+"
|
||||
echo "| *** WARNING *** |"
|
||||
echo "| |"
|
||||
@@ -1269,17 +1178,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
|
||||
+--------------------------------------------------------------------+
|
||||
@@ -1320,7 +1218,7 @@ X
|
||||
fi
|
||||
fi
|
||||
|
||||
cat <<X
|
||||
cat<<X
|
||||
+--------------------------------------------------------------------+
|
||||
| License: |
|
||||
| This software is subject to the PHP License, available in this |
|
||||
@@ -1340,6 +1238,7 @@ cat <<X
|
||||
| avoid using it if possible. |
|
||||
+--------------------------------------------------------------------+
|
||||
|
||||
|
||||
Thank you for using PHP.
|
||||
|
||||
X
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
aspell
|
||||
Rasmus Lerdorf
|
||||
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2002 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Rasmus Lerdorf <rasmus@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "php.h"
|
||||
|
||||
#ifdef COMPILE_DL_ASPELL
|
||||
#include "phpdl.h"
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if HAVE_ASPELL
|
||||
|
||||
#include "php_aspell.h"
|
||||
#include <aspell-c.h>
|
||||
#include "ext/standard/info.h"
|
||||
|
||||
/* {{{ aspell_functions[]
|
||||
*/
|
||||
function_entry aspell_functions[] = {
|
||||
PHP_FE(aspell_new, NULL)
|
||||
PHP_FE(aspell_check, NULL)
|
||||
PHP_FE(aspell_check_raw, NULL)
|
||||
PHP_FE(aspell_suggest, NULL)
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
static int le_aspell;
|
||||
|
||||
zend_module_entry aspell_module_entry = {
|
||||
STANDARD_MODULE_HEADER,
|
||||
"aspell", aspell_functions, PHP_MINIT(aspell), NULL, NULL, NULL, PHP_MINFO(aspell), NO_VERSION_YET, STANDARD_MODULE_PROPERTIES
|
||||
};
|
||||
|
||||
#ifdef COMPILE_DL_ASPELL
|
||||
ZEND_GET_MODULE(aspell)
|
||||
#endif
|
||||
|
||||
/* {{{ php_aspell_close
|
||||
*/
|
||||
static void php_aspell_close(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||
{
|
||||
aspell *sc = (aspell *)rsrc->ptr;
|
||||
|
||||
aspell_free(sc);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_MINIT_FUNCTION
|
||||
*/
|
||||
PHP_MINIT_FUNCTION(aspell)
|
||||
{
|
||||
le_aspell = zend_register_list_destructors_ex(php_aspell_close, NULL, "aspell", module_number);
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int aspell_new(string master [, string personal])
|
||||
Load a dictionary */
|
||||
PHP_FUNCTION(aspell_new)
|
||||
{
|
||||
pval **master, **personal;
|
||||
int argc;
|
||||
aspell *sc;
|
||||
int ind;
|
||||
|
||||
argc = ZEND_NUM_ARGS();
|
||||
if (argc < 1 || argc > 2 || zend_get_parameters_ex(argc, &master, &personal) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_string_ex(master);
|
||||
if(argc==2)
|
||||
{
|
||||
convert_to_string_ex(personal) ;
|
||||
sc=aspell_new(Z_STRVAL_PP(master), Z_STRVAL_PP(personal));
|
||||
}
|
||||
else
|
||||
sc=aspell_new(Z_STRVAL_PP(master), "");
|
||||
|
||||
ind = zend_list_insert(sc, le_aspell);
|
||||
RETURN_LONG(ind);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto array aspell_suggest(aspell int, string word)
|
||||
Return array of Suggestions */
|
||||
PHP_FUNCTION(aspell_suggest)
|
||||
{
|
||||
pval **scin, **word;
|
||||
int argc;
|
||||
aspell *sc;
|
||||
int ind, type;
|
||||
aspellSuggestions *sug;
|
||||
size_t i;
|
||||
|
||||
|
||||
argc = ZEND_NUM_ARGS();
|
||||
if (argc != 2 || zend_get_parameters_ex(argc, &scin, &word) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_long_ex(scin);
|
||||
convert_to_string_ex(word);
|
||||
sc = (aspell *)zend_list_find(Z_LVAL_PP(scin), &type);
|
||||
if(!sc)
|
||||
{
|
||||
php_error(E_WARNING, "%s(): %d is not an ASPELL result index", get_active_function_name(TSRMLS_C), Z_LVAL_PP(scin));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (array_init(return_value) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
sug = aspell_suggest(sc, Z_STRVAL_PP(word));
|
||||
for (i = 0; i != sug->size; ++i) {
|
||||
add_next_index_string(return_value, (char *)sug->data[i], 1);
|
||||
}
|
||||
aspell_free_suggestions(sug);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int aspell_check(aspell int, string word)
|
||||
Return if word is valid */
|
||||
PHP_FUNCTION(aspell_check)
|
||||
{
|
||||
int type;
|
||||
pval **scin, **word;
|
||||
aspell *sc;
|
||||
|
||||
int argc;
|
||||
argc = ZEND_NUM_ARGS();
|
||||
if (argc != 2 || zend_get_parameters_ex(argc, &scin, &word) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_long_ex(scin);
|
||||
convert_to_string_ex(word);
|
||||
sc= (aspell *) zend_list_find(Z_LVAL_PP(scin), &type);
|
||||
if(!sc)
|
||||
{
|
||||
php_error(E_WARNING, "%s(): %d is not an ASPELL result index", get_active_function_name(TSRMLS_C), Z_LVAL_PP(scin));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (aspell_check(sc, Z_STRVAL_PP(word)))
|
||||
{
|
||||
RETURN_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int aspell_check_raw(aspell int, string word)
|
||||
Return if word is valid, ignoring case or trying to trim it in any way */
|
||||
PHP_FUNCTION(aspell_check_raw)
|
||||
{
|
||||
pval **scin, **word;
|
||||
int type;
|
||||
int argc;
|
||||
aspell *sc;
|
||||
|
||||
argc = ZEND_NUM_ARGS();
|
||||
if (argc != 2 || zend_get_parameters_ex(argc, &scin, &word) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_long_ex(scin);
|
||||
convert_to_string_ex(word);
|
||||
sc = (aspell *)zend_list_find(Z_LVAL_PP(scin), &type);
|
||||
if(!sc)
|
||||
{
|
||||
php_error(E_WARNING, "%s(): %d is not an ASPELL result index", get_active_function_name(TSRMLS_C), Z_LVAL_PP(scin));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (aspell_check_raw(sc, Z_STRVAL_PP(word)))
|
||||
{
|
||||
RETURN_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_MINFO_FUNCTION
|
||||
*/
|
||||
PHP_MINFO_FUNCTION(aspell)
|
||||
{
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_row(2, "ASpell Support", "enabled");
|
||||
php_info_print_table_end();
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -0,0 +1,30 @@
|
||||
dnl
|
||||
dnl $Id$
|
||||
dnl
|
||||
|
||||
AC_MSG_CHECKING(for ASPELL support)
|
||||
AC_ARG_WITH(aspell,
|
||||
[ --with-aspell[=DIR] Include ASPELL support.],
|
||||
[
|
||||
if test "$withval" != "no"; then
|
||||
if test "$withval" = "yes"; then
|
||||
ASPELL_DIR=/usr/local
|
||||
else
|
||||
ASPELL_DIR=$withval
|
||||
fi
|
||||
|
||||
PHP_ADD_INCLUDE($ASPELL_DIR/include)
|
||||
PHP_ADD_LIBRARY_WITH_PATH(aspell, $ASPELL_DIR/lib)
|
||||
|
||||
if test ! -f "$ASPELL_DIR/include/aspell-c.h"; then
|
||||
AC_MSG_ERROR(Could not find aspell-c.h in $ASPELL_DIR/include - please copy it manually from the aspell sources to $ASPELL_DIR/include)
|
||||
fi
|
||||
AC_DEFINE(HAVE_ASPELL,1,[Whether you have aspell])
|
||||
AC_MSG_RESULT(yes)
|
||||
PHP_NEW_EXTENSION(aspell, aspell.c)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
],[
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| 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 |
|
||||
@@ -12,38 +12,30 @@
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Marcus Boerger <helly@php.net> |
|
||||
| Author: Rasmus Lerdorf <rasmus@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* incorporated from D.J.Bernstein's cdb-0.75 (http://cr.yp.to/cdb.html)*/
|
||||
#ifndef PHP_ASPELL_H
|
||||
#define PHP_ASPELL_H
|
||||
#if HAVE_ASPELL
|
||||
extern zend_module_entry aspell_module_entry;
|
||||
#define aspell_module_ptr &aspell_module_entry
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
PHP_MINIT_FUNCTION(aspell);
|
||||
PHP_MINFO_FUNCTION(aspell);
|
||||
|
||||
PHP_FUNCTION(aspell_new);
|
||||
PHP_FUNCTION(aspell_check);
|
||||
PHP_FUNCTION(aspell_check_raw);
|
||||
PHP_FUNCTION(aspell_suggest);
|
||||
|
||||
#else
|
||||
#define aspell_module_ptr NULL
|
||||
#endif
|
||||
|
||||
#include "php.h"
|
||||
#define phpext_aspell_ptr aspell_module_ptr
|
||||
|
||||
#include "uint32.h"
|
||||
|
||||
/* {{{ uint32_pack */
|
||||
void uint32_pack(char *out, uint32 in)
|
||||
{
|
||||
out[0] = in&0xff; in>>=8;
|
||||
out[1] = in&0xff; in>>=8;
|
||||
out[2] = in&0xff; in>>=8;
|
||||
out[3] = in&0xff;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ uint32_unpack */
|
||||
void uint32_unpack(const char *in, uint32 *out)
|
||||
{
|
||||
*out = (((uint32)(unsigned char)in[3])<<24) |
|
||||
(((uint32)(unsigned char)in[2])<<16) |
|
||||
(((uint32)(unsigned char)in[1])<<8) |
|
||||
(((uint32)(unsigned char)in[0]));
|
||||
}
|
||||
/* }}} */
|
||||
#endif /* PHP_ASPELL_H */
|
||||
+77
-101
@@ -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 |
|
||||
@@ -28,9 +28,7 @@
|
||||
|
||||
#include "ext/standard/info.h"
|
||||
#include "php_bcmath.h"
|
||||
#include "libbcmath/src/bcmath.h"
|
||||
|
||||
ZEND_DECLARE_MODULE_GLOBALS(bcmath);
|
||||
#include "ext/bcmath/libbcmath/src/bcmath.h"
|
||||
|
||||
function_entry bcmath_functions[] = {
|
||||
PHP_FE(bcadd, 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,23 +395,21 @@ 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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -52,9 +52,6 @@ typedef struct bc_struct
|
||||
in the case of leading zeros generated. */
|
||||
} bc_struct;
|
||||
|
||||
#include <php.h>
|
||||
#include <ext/bcmath/php_bcmath.h>
|
||||
|
||||
|
||||
/* The base used in storing the numbers in n_value above.
|
||||
Currently this MUST be 10. */
|
||||
@@ -84,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. */
|
||||
@@ -96,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));
|
||||
|
||||
@@ -104,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));
|
||||
|
||||
@@ -116,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));
|
||||
|
||||
@@ -126,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. */
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#if PHP_WIN32
|
||||
#include "../../../../main/config.w32.h"
|
||||
#elif defined(NETWARE)
|
||||
#include "config.nw.h"
|
||||
#else
|
||||
#include "php_config.h"
|
||||
#endif
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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_);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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);
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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,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 |
|
||||
@@ -13,7 +13,7 @@
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Shane Caraveo <shane@caraveo.com> |
|
||||
| Colin Viebrock <colin@easydns.com> |
|
||||
| Colin Viebrock <cmv@easydns.com> |
|
||||
| Hartmut Holzgraefe <hartmut@six.de> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
+41
-143
@@ -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 |
|
||||
@@ -13,7 +13,7 @@
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Shane Caraveo <shane@caraveo.com> |
|
||||
| Colin Viebrock <colin@easydns.com> |
|
||||
| Colin Viebrock <cmv@easydns.com> |
|
||||
| Hartmut Holzgraefe <hartmut@six.de> |
|
||||
| Wez Furlong <wez@thebrainroom.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
@@ -33,8 +33,6 @@
|
||||
#include "php_calendar.h"
|
||||
#include "sdncal.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
function_entry calendar_functions[] = {
|
||||
PHP_FE(jdtogregorian, NULL)
|
||||
PHP_FE(gregoriantojd, NULL)
|
||||
@@ -87,15 +85,15 @@ typedef long int (*cal_to_jd_func_t)(int month, int day, int year);
|
||||
typedef void (*cal_from_jd_func_t)(long int jd, int* year, int* month, int* day);
|
||||
typedef char* (*cal_as_string_func_t)(int year, int month, int day);
|
||||
|
||||
struct cal_entry_t {
|
||||
char *name;
|
||||
char *symbol;
|
||||
cal_to_jd_func_t to_jd;
|
||||
cal_from_jd_func_t from_jd;
|
||||
int num_months;
|
||||
int max_days_in_month;
|
||||
char **month_name_short;
|
||||
char **month_name_long;
|
||||
struct cal_entry_t {
|
||||
char * name;
|
||||
char * symbol;
|
||||
cal_to_jd_func_t to_jd;
|
||||
cal_from_jd_func_t from_jd;
|
||||
int num_months;
|
||||
int max_days_in_month;
|
||||
char ** month_name_short;
|
||||
char ** month_name_long;
|
||||
};
|
||||
static struct cal_entry_t cal_conversion_table[CAL_NUM_CALS] = {
|
||||
{ "Gregorian", "CAL_GREGORIAN", GregorianToSdn, SdnToGregorian, 12, 31, MonthNameShort, MonthNameLong },
|
||||
@@ -110,9 +108,6 @@ enum { CAL_DOW_DAYNO, CAL_DOW_SHORT, CAL_DOW_LONG };
|
||||
enum { CAL_MONTH_GREGORIAN_SHORT, CAL_MONTH_GREGORIAN_LONG,
|
||||
CAL_MONTH_JULIAN_SHORT, CAL_MONTH_JULIAN_LONG, CAL_MONTH_JEWISH,
|
||||
CAL_MONTH_FRENCH };
|
||||
|
||||
/* for heb_number_to_chars */
|
||||
static char alef_bet[25] = "0àáâãäåæçèéëìîðñòôö÷øùú";
|
||||
|
||||
PHP_MINIT_FUNCTION(calendar)
|
||||
{
|
||||
@@ -142,9 +137,9 @@ PHP_MINIT_FUNCTION(calendar)
|
||||
|
||||
PHP_MINFO_FUNCTION(calendar)
|
||||
{
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_row(2, "Calendar support", "enabled");
|
||||
php_info_print_table_end();
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_row(2, "Calendar support", "enabled");
|
||||
php_info_print_table_end();
|
||||
}
|
||||
|
||||
/* {{{ proto array cal_info(int calendar)
|
||||
@@ -156,11 +151,11 @@ PHP_FUNCTION(cal_info)
|
||||
int i;
|
||||
struct cal_entry_t * calendar;
|
||||
|
||||
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &cal) != SUCCESS) {
|
||||
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &cal) != SUCCESS) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_long_ex(cal);
|
||||
if (Z_LVAL_PP(cal) < 0 || Z_LVAL_PP(cal) >= CAL_NUM_CALS) {
|
||||
if (Z_LVAL_PP(cal) < 0 || Z_LVAL_PP(cal) >= CAL_NUM_CALS) {
|
||||
zend_error(E_WARNING, "%s(): invalid calendar ID %d", get_active_function_name(TSRMLS_C), Z_LVAL_PP(cal));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@@ -173,7 +168,7 @@ PHP_FUNCTION(cal_info)
|
||||
array_init(months);
|
||||
array_init(smonths);
|
||||
|
||||
for (i=1; i<= calendar->num_months; i++) {
|
||||
for (i=1; i<= calendar->num_months; i++) {
|
||||
add_index_string(months, i, calendar->month_name_long[i], 1);
|
||||
add_index_string(smonths, i, calendar->month_name_short[i], 1);
|
||||
}
|
||||
@@ -194,7 +189,7 @@ PHP_FUNCTION(cal_days_in_month)
|
||||
struct cal_entry_t * calendar;
|
||||
long sdn_start, sdn_next;
|
||||
|
||||
if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &cal, &month, &year) != SUCCESS) {
|
||||
if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &cal, &month, &year) != SUCCESS) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
@@ -202,7 +197,7 @@ PHP_FUNCTION(cal_days_in_month)
|
||||
convert_to_long_ex(month);
|
||||
convert_to_long_ex(year);
|
||||
|
||||
if (Z_LVAL_PP(cal) < 0 || Z_LVAL_PP(cal) >= CAL_NUM_CALS) {
|
||||
if (Z_LVAL_PP(cal) < 0 || Z_LVAL_PP(cal) >= CAL_NUM_CALS) {
|
||||
zend_error(E_WARNING, "%s(): invalid calendar ID %d", get_active_function_name(TSRMLS_C), Z_LVAL_PP(cal));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@@ -229,7 +224,7 @@ PHP_FUNCTION(cal_to_jd)
|
||||
zval ** cal, **month, **day, **year;
|
||||
long jdate;
|
||||
|
||||
if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &cal, &month, &day, &year) != SUCCESS) {
|
||||
if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &cal, &month, &day, &year) != SUCCESS) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
@@ -238,7 +233,7 @@ PHP_FUNCTION(cal_to_jd)
|
||||
convert_to_long_ex(day);
|
||||
convert_to_long_ex(year);
|
||||
|
||||
if (Z_LVAL_PP(cal) < 0 || Z_LVAL_PP(cal) >= CAL_NUM_CALS) {
|
||||
if (Z_LVAL_PP(cal) < 0 || Z_LVAL_PP(cal) >= CAL_NUM_CALS) {
|
||||
zend_error(E_WARNING, "%s(): invalid calendar ID %d", get_active_function_name(TSRMLS_C), Z_LVAL_PP(cal));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@@ -258,13 +253,13 @@ PHP_FUNCTION(cal_from_jd)
|
||||
char date[16];
|
||||
struct cal_entry_t * calendar;
|
||||
|
||||
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &jd, &cal) != SUCCESS) {
|
||||
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &jd, &cal) != SUCCESS) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_long_ex(jd);
|
||||
convert_to_long_ex(cal);
|
||||
|
||||
if (Z_LVAL_PP(cal) < 0 || Z_LVAL_PP(cal) >= CAL_NUM_CALS) {
|
||||
if (Z_LVAL_PP(cal) < 0 || Z_LVAL_PP(cal) >= CAL_NUM_CALS) {
|
||||
zend_error(E_WARNING, "%s(): invalid calendar ID %d", get_active_function_name(TSRMLS_C), Z_LVAL_PP(cal));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@@ -316,7 +311,7 @@ PHP_FUNCTION(jdtogregorian)
|
||||
|
||||
/* {{{ proto int gregoriantojd(int month, int day, int year)
|
||||
Converts a gregorian calendar date to julian day count */
|
||||
PHP_FUNCTION(gregoriantojd)
|
||||
PHP_FUNCTION(gregoriantojd)
|
||||
{
|
||||
pval **year, **month, **day;
|
||||
int jdate;
|
||||
@@ -337,7 +332,7 @@ PHP_FUNCTION(gregoriantojd)
|
||||
|
||||
/* {{{ proto string jdtojulian(int juliandaycount)
|
||||
Convert a julian day count to a julian calendar date */
|
||||
PHP_FUNCTION(jdtojulian)
|
||||
PHP_FUNCTION(jdtojulian)
|
||||
{
|
||||
pval **julday;
|
||||
int year, month, day;
|
||||
@@ -357,7 +352,7 @@ PHP_FUNCTION(jdtojulian)
|
||||
|
||||
/* {{{ proto int juliantojd(int month, int day, int year)
|
||||
Converts a julian calendar date to julian day count */
|
||||
PHP_FUNCTION(juliantojd)
|
||||
PHP_FUNCTION(juliantojd)
|
||||
{
|
||||
pval **year, **month, **day;
|
||||
int jdate;
|
||||
@@ -376,127 +371,30 @@ PHP_FUNCTION(juliantojd)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
caution: the hebrew format product non unique result.
|
||||
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)
|
||||
{
|
||||
char *p, *old;
|
||||
|
||||
p = emalloc(10);
|
||||
old = p;
|
||||
|
||||
/*
|
||||
prevents the option breaking the jewish beliefs, and some other
|
||||
critical resources ;)
|
||||
*/
|
||||
if (n > 9999 || n < 1) {
|
||||
efree(old);
|
||||
*ret = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* alafim case */
|
||||
if (n / 1000) {
|
||||
*p = alef_bet[n / 1000];
|
||||
p++;
|
||||
n = n % 1000;
|
||||
}
|
||||
|
||||
/* taf-taf case */
|
||||
while (n >= 400) {
|
||||
*p = alef_bet[22];
|
||||
p++;
|
||||
n-=400;
|
||||
}
|
||||
|
||||
/* meot case */
|
||||
if (n >= 100) {
|
||||
*p = alef_bet[18+n/100];
|
||||
p++;
|
||||
n = n % 100;
|
||||
}
|
||||
|
||||
/* tet-vav tet-zain case */
|
||||
if (n == 15 || n == 16) {
|
||||
*p = alef_bet[9];
|
||||
p++;
|
||||
*p = alef_bet[n-9];
|
||||
p++;
|
||||
} else {
|
||||
/* asarot case */
|
||||
if (n >= 10) {
|
||||
*p = alef_bet[9+n/10];
|
||||
p++;
|
||||
n = n % 10;
|
||||
}
|
||||
|
||||
/* yeihot case */
|
||||
if (n > 0) {
|
||||
*p = alef_bet[n];
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
*p = '\0';
|
||||
*ret = estrndup(old, (p - old) + 1);
|
||||
p = *ret;
|
||||
efree(old);
|
||||
return p;
|
||||
}
|
||||
|
||||
/* {{{ proto string jdtojewish(int juliandaycount)
|
||||
Converts a julian day count to a jewish calendar date */
|
||||
PHP_FUNCTION(jdtojewish)
|
||||
PHP_FUNCTION(jdtojewish)
|
||||
{
|
||||
long julday, fl;
|
||||
pval **julday;
|
||||
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) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
fl=0;
|
||||
} else if (ZEND_NUM_ARGS() == 2) {
|
||||
if (zend_parse_parameters(2 TSRMLS_CC,"ll", &julday, &fl) != SUCCESS) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
} else {
|
||||
char date[10];
|
||||
|
||||
if (zend_get_parameters_ex(1, &julday) != SUCCESS) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_long_ex(julday);
|
||||
|
||||
SdnToJewish(julday, &year, &month, &day);
|
||||
if(!fl) {
|
||||
sprintf(date, "%i/%i/%i", month, day, year);
|
||||
RETURN_STRING(date, 1);
|
||||
} else {
|
||||
if (year <= 0 || year > 9999) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Out of range year.");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
sprintf(hebdate, "%s %s %s", heb_number_to_chars(day, &dayp), JewishMonthHebName[month], heb_number_to_chars(year, &yearp));
|
||||
|
||||
if (dayp) {
|
||||
efree(dayp);
|
||||
}
|
||||
if (yearp) {
|
||||
efree(yearp);
|
||||
}
|
||||
RETURN_STRING(hebdate, 1);
|
||||
|
||||
}
|
||||
SdnToJewish(Z_LVAL_PP(julday), &year, &month, &day);
|
||||
sprintf(date, "%i/%i/%i", month, day, year);
|
||||
|
||||
RETURN_STRING(date, 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int jewishtojd(int month, int day, int year)
|
||||
Converts a jewish calendar date to a julian day count */
|
||||
PHP_FUNCTION(jewishtojd)
|
||||
PHP_FUNCTION(jewishtojd)
|
||||
{
|
||||
pval **year, **month, **day;
|
||||
int jdate;
|
||||
@@ -517,7 +415,7 @@ PHP_FUNCTION(jewishtojd)
|
||||
|
||||
/* {{{ proto string jdtofrench(int juliandaycount)
|
||||
Converts a julian day count to a french republic calendar date */
|
||||
PHP_FUNCTION(jdtofrench)
|
||||
PHP_FUNCTION(jdtofrench)
|
||||
{
|
||||
pval **julday;
|
||||
int year, month, day;
|
||||
@@ -538,7 +436,7 @@ PHP_FUNCTION(jdtofrench)
|
||||
|
||||
/* {{{ proto int frenchtojd(int month, int day, int year)
|
||||
Converts a french republic calendar date to julian day count */
|
||||
PHP_FUNCTION(frenchtojd)
|
||||
PHP_FUNCTION(frenchtojd)
|
||||
{
|
||||
pval **year, **month, **day;
|
||||
int jdate;
|
||||
@@ -559,7 +457,7 @@ PHP_FUNCTION(frenchtojd)
|
||||
|
||||
/* {{{ proto mixed jddayofweek(int juliandaycount [, int mode])
|
||||
Returns name or number of day of week from julian day count */
|
||||
PHP_FUNCTION(jddayofweek)
|
||||
PHP_FUNCTION(jddayofweek)
|
||||
{
|
||||
pval *julday, *mode;
|
||||
int day;
|
||||
@@ -597,7 +495,7 @@ PHP_FUNCTION(jddayofweek)
|
||||
|
||||
/* {{{ proto string jdmonthname(int juliandaycount, int mode)
|
||||
Returns name of month for julian day count */
|
||||
PHP_FUNCTION(jdmonthname)
|
||||
PHP_FUNCTION(jdmonthname)
|
||||
{
|
||||
pval **julday, **mode;
|
||||
char *monthname = NULL;
|
||||
|
||||
@@ -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 |
|
||||
@@ -13,8 +13,8 @@
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Shane Caraveo <shane@caraveo.com> |
|
||||
| Colin Viebrock <colin@easydns.com> |
|
||||
| Hartmut Holzgraefe <hholzgra@php.net> |
|
||||
| Colin Viebrock <cmv@easydns.com> |
|
||||
| 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -260,10 +260,6 @@
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#if defined(PHP_WIN32) && _MSC_VER >= 1200
|
||||
#pragma setlocale("english")
|
||||
#endif
|
||||
|
||||
#include "sdncal.h"
|
||||
|
||||
#define HALAKIM_PER_HOUR 1080
|
||||
@@ -315,24 +311,6 @@ char *JewishMonthName[14] =
|
||||
"Elul"
|
||||
};
|
||||
|
||||
char *JewishMonthHebName[14] =
|
||||
{
|
||||
"",
|
||||
"úùøé",
|
||||
"çùåï",
|
||||
"ëñìå",
|
||||
"èáú",
|
||||
"ùáè",
|
||||
"àãø",
|
||||
"'àãø á",
|
||||
"ðéñï",
|
||||
"àééø",
|
||||
"ñéåï",
|
||||
"úîåæ",
|
||||
"àá",
|
||||
"àìåì"
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* Given the year within the 19 year metonic cycle and the time of a molad
|
||||
* (new moon) which starts that year, this routine will calculate what day
|
||||
|
||||
@@ -79,7 +79,6 @@ long int JulianToSdn(int year, int month, int day);
|
||||
void SdnToJewish(long int sdn, int *pYear, int *pMonth, int *pDay);
|
||||
long int JewishToSdn(int year, int month, int day);
|
||||
extern char *JewishMonthName[14];
|
||||
extern char *JewishMonthHebName[14];
|
||||
|
||||
/* French republic calendar conversions. */
|
||||
void SdnToFrench(long int sdn, int *pYear, int *pMonth, int *pDay);
|
||||
@@ -94,4 +93,4 @@ int DayOfWeek(long int sdn);
|
||||
extern char *DayNameShort[7];
|
||||
extern char *DayNameLong[7];
|
||||
|
||||
#endif /* SDNCAL_H */
|
||||
#endif /* SDNCAL_H */
|
||||
@@ -0,0 +1,2 @@
|
||||
ccvs
|
||||
Brendan W. McAdams, Doug DeJulio
|
||||
@@ -0,0 +1,7 @@
|
||||
CCVS Module ToDo List
|
||||
08/14/2000
|
||||
Brendan W. McAdams <bmcadams@php.net>
|
||||
-------------------------------------
|
||||
- Return value of the final stats of an authorization should already be split out into a php aware associative
|
||||
array, instead of having to do this at the PHP level. Right now we are splitting stuff out using text_value;
|
||||
I'm evaluating the merits of having a seperate function for the 'finishing' of a sale....
|
||||
+607
@@ -0,0 +1,607 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2002 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Brendan W. McAdams <bmcadams@php.net> |
|
||||
| Doug DeJulio <ddj@redhat.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
/*
|
||||
* cvvs.c $Revision$ - PHP4 Interface to the RedHat CCVS API
|
||||
* -------
|
||||
* Interfaces RedHat's CCVS [Credit Card Verification System] <http://www.redhat.com/products/ccvs/>
|
||||
* This code is ported from an original php3 interface written by RedHat's Doug DeJulio <ddj@redhat.com>
|
||||
* The code was subsequently ported to the Zend API by Brendan W. McAdams <bmcadams@php.net>
|
||||
* -------
|
||||
*/
|
||||
|
||||
/*
|
||||
* Code started on 2000.07.24@09.04.EST by Brendan W. McAdams <bmcadams@php.net>
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
static char const cvsid[] = "$Id$";
|
||||
|
||||
#include <php.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ccvs.h>
|
||||
|
||||
|
||||
/*
|
||||
* Create the Zend Internal hash construct to track this modules functions
|
||||
*
|
||||
* In case anyone is wondering why we use ccvs_<action> instead of cv_<action>,
|
||||
* it's because we are directly importing functions of the actual CCVS, which uses functions that are
|
||||
* cv_<action>, and we had problems implementing ZEND_NAMED_FE calls (bug in NAMED_FE? investigate
|
||||
* later). We don't want our PHP calls to conflict with the C calls in the CCVS API.
|
||||
*
|
||||
* BWM - 2000.07.27@16.41.EST - Added FALIAS Calls. While I'm of the opinion that naming the
|
||||
* functions in PHP ccvs_<action> is much more readable and clear to anyone reading the code than
|
||||
* cv_<action>, It strikes me that many people coming from php3 -> php4 will need backwards
|
||||
* compatibility. It was kind of careless to simply change the function calls (There were reasons other
|
||||
* than readability behind this; the ZEND_NAMED_FE macro was misbehaving) and not provide for
|
||||
* backwards compatibility - this *IS* an API and should scale with compatibility.
|
||||
*
|
||||
*/
|
||||
|
||||
function_entry ccvs_functions[] = {
|
||||
PHP_FE(ccvs_init, NULL)
|
||||
PHP_FALIAS(cv_init, ccvs_init, NULL)
|
||||
PHP_FE(ccvs_done, NULL)
|
||||
PHP_FALIAS(cv_done, ccvs_done, NULL)
|
||||
PHP_FE(ccvs_new, NULL)
|
||||
PHP_FALIAS(cv_new, ccvs_new, NULL)
|
||||
PHP_FE(ccvs_add, NULL)
|
||||
PHP_FALIAS(cv_add, ccvs_add, NULL)
|
||||
PHP_FE(ccvs_delete, NULL)
|
||||
PHP_FALIAS(cv_delete, ccvs_delete, NULL)
|
||||
PHP_FE(ccvs_auth, NULL)
|
||||
PHP_FALIAS(cv_auth, ccvs_auth, NULL)
|
||||
PHP_FE(ccvs_return, NULL)
|
||||
PHP_FALIAS(cv_return, ccvs_return, NULL)
|
||||
PHP_FE(ccvs_reverse, NULL)
|
||||
PHP_FALIAS(cv_reverse, ccvs_reverse, NULL)
|
||||
PHP_FE(ccvs_sale, NULL)
|
||||
PHP_FALIAS(cv_sale, ccvs_sale, NULL)
|
||||
PHP_FE(ccvs_void, NULL)
|
||||
PHP_FALIAS(cv_void, ccvs_void, NULL)
|
||||
PHP_FE(ccvs_status, NULL)
|
||||
PHP_FALIAS(cv_status, ccvs_status, NULL)
|
||||
PHP_FE(ccvs_count, NULL)
|
||||
PHP_FALIAS(cv_count, ccvs_count, NULL)
|
||||
PHP_FE(ccvs_lookup, NULL)
|
||||
PHP_FALIAS(cv_lookup, ccvs_lookup, NULL)
|
||||
PHP_FE(ccvs_report, NULL)
|
||||
PHP_FALIAS(cv_report, ccvs_report, NULL)
|
||||
PHP_FE(ccvs_command, NULL)
|
||||
PHP_FALIAS(cv_command, ccvs_command, NULL)
|
||||
PHP_FE(ccvs_textvalue, NULL)
|
||||
PHP_FALIAS(cv_textvalue, ccvs_textvalue, NULL)
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
/* End function declarations */
|
||||
|
||||
/* Zend Engine Exports - module information */
|
||||
|
||||
/* Declare our module to the Zend engine */
|
||||
zend_module_entry ccvs_module_entry = {
|
||||
STANDARD_MODULE_HEADER,
|
||||
"CCVS",
|
||||
ccvs_functions,
|
||||
NULL, NULL, NULL, NULL,
|
||||
PHP_MINFO(ccvs),
|
||||
NO_VERSION_YET,
|
||||
STANDARD_MODULE_PROPERTIES
|
||||
};
|
||||
|
||||
#ifdef COMPILE_DL_CCVS
|
||||
ZEND_GET_MODULE(ccvs)
|
||||
#endif
|
||||
|
||||
/* Full Functions (The actual CCVS functions and any internal php hooked functions such as MINFO) */
|
||||
|
||||
/* {{{ proto string ccvs_init(string name)
|
||||
Initialize CCVS for use */
|
||||
PHP_FUNCTION(ccvs_init) /* cv_init() */
|
||||
{
|
||||
zval **name;
|
||||
void *vsess;
|
||||
char *p;
|
||||
|
||||
if ((ZEND_NUM_ARGS() != 1) || (zend_get_parameters_ex(1, &name) != SUCCESS))
|
||||
/* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
|
||||
{
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(name);
|
||||
|
||||
vsess = cv_init(Z_STRVAL_PP(name));
|
||||
|
||||
/*
|
||||
* -- In the case that we don't run error checking on the return value... --
|
||||
* On 32 bit systems a failure of the cv_init call returns 0,0,0,0 ; on 64 bit systems its 0,0,0,0,0,0,0,0
|
||||
* This unconsistent error (not to mention a string of comma seperated zeros in and of itself) is hard to
|
||||
* Trap for in PHP (or any language). However, we can also grab cv_init to return CV_SESS_BAD on
|
||||
* failure at the C API level, and return a set, fixed error code to the user which the user then knows to
|
||||
* trap for... e.g. a NULL Value which PHP can then trap by:
|
||||
* if (!($string = cv_init($config)) { or some such...
|
||||
*/
|
||||
|
||||
if (vsess == CV_SESS_BAD) /* if the cv_init() call failed... */
|
||||
{
|
||||
|
||||
p = ""; /* set p, the value we will return, to NULL */
|
||||
|
||||
}
|
||||
else /* we got a valid session returned, which means it worked */
|
||||
{
|
||||
|
||||
p = hks_ptr_ptrtostring(vsess); /* Convert the (void*) into a string representation. */
|
||||
|
||||
}
|
||||
|
||||
RETVAL_STRING(p, 1);
|
||||
|
||||
free(p);
|
||||
return;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string ccvs_done(string sess)
|
||||
Terminate CCVS engine and do cleanup work */
|
||||
PHP_FUNCTION(ccvs_done) /* cv_done() */
|
||||
{
|
||||
zval **sess;
|
||||
void *vsess;
|
||||
|
||||
if ((ZEND_NUM_ARGS() != 1) || (zend_get_parameters_ex(1, &sess) != SUCCESS)) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
|
||||
{
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(sess);
|
||||
|
||||
/* Convert from the string representation back to a (void*) */
|
||||
vsess = hks_ptr_stringtoptr(Z_STRVAL_PP(sess));
|
||||
cv_done(vsess);
|
||||
|
||||
RETURN_STRING("OK", 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string ccvs_new(string session, string invoice)
|
||||
Create a new, blank transaction */
|
||||
PHP_FUNCTION(ccvs_new) /* cv_new() */
|
||||
{
|
||||
zval **psess;
|
||||
zval **pinvoice;
|
||||
void *sess;
|
||||
char *invoice;
|
||||
int r;
|
||||
|
||||
if ((ZEND_NUM_ARGS() != 2) || (zend_get_parameters_ex(2, &psess, &pinvoice) != SUCCESS)) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
|
||||
{
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(psess);
|
||||
if (!Z_STRVAL_PP(psess)) {
|
||||
php_error(E_WARNING, "%s(): Invalid session", get_active_function_name(TSRMLS_C));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
sess = hks_ptr_stringtoptr(Z_STRVAL_PP(psess));
|
||||
|
||||
convert_to_string_ex(pinvoice);
|
||||
invoice = Z_STRVAL_PP(pinvoice);
|
||||
|
||||
r = cv_new(sess, invoice);
|
||||
|
||||
RETURN_STRING(cv_ret2str(r), 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string ccvs_add(string session, string invoice, string argtype, string argval)
|
||||
Add data to a transaction */
|
||||
PHP_FUNCTION(ccvs_add) /* cv_add() */
|
||||
{
|
||||
zval **psess;
|
||||
zval **pinvoice;
|
||||
zval **pargtype;
|
||||
zval **pargval;
|
||||
void *sess;
|
||||
char *invoice;
|
||||
int argtype;
|
||||
char *argval;
|
||||
register int r;
|
||||
|
||||
if ((ZEND_NUM_ARGS() != 4) || (zend_get_parameters_ex(4, &psess, &pinvoice, &pargtype, &pargval) != SUCCESS)) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
|
||||
{
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
/* Get meaningful arguments. */
|
||||
convert_to_string_ex(psess);
|
||||
convert_to_string_ex(pinvoice);
|
||||
convert_to_string_ex(pargtype);
|
||||
convert_to_string_ex(pargval);
|
||||
sess = hks_ptr_stringtoptr(Z_STRVAL_PP(psess));
|
||||
invoice = Z_STRVAL_PP(pinvoice);
|
||||
argtype = cv_str2arg(Z_STRVAL_PP(pargtype));
|
||||
argval = Z_STRVAL_PP(pargval);
|
||||
|
||||
r = cv_add(sess, invoice, argtype, argval);
|
||||
|
||||
RETURN_STRING(cv_ret2str(r), 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* cv_create can't be implemented because of vararg limits in PHP3's C API.
|
||||
* (COMMENT BY DDJ [from original code])
|
||||
*
|
||||
* BWM: I looked into this, checking in on what cv_create was; it is a deprecated function left in for
|
||||
* backwards compatibility according
|
||||
* to the CCVS C API ref. I didn't try to implement it for that reason. If anyone needs it, they can add it in
|
||||
* themselves I'm sure.
|
||||
*/
|
||||
|
||||
/* {{{ proto string ccvs_delete(string session, string invoice)
|
||||
Delete a transaction */
|
||||
PHP_FUNCTION(ccvs_delete) /* cv_delete() */
|
||||
{
|
||||
zval **psess;
|
||||
zval **pinvoice;
|
||||
void *sess;
|
||||
char *invoice;
|
||||
register int r;
|
||||
|
||||
if ((ZEND_NUM_ARGS() != 2) || (zend_get_parameters_ex(2, &psess, &pinvoice) != SUCCESS)) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
|
||||
{
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(psess);
|
||||
convert_to_string_ex(pinvoice);
|
||||
invoice = Z_STRVAL_PP(pinvoice);
|
||||
sess = hks_ptr_stringtoptr(Z_STRVAL_PP(psess));
|
||||
|
||||
r = cv_delete(sess, invoice);
|
||||
|
||||
RETURN_STRING(cv_ret2str(r), 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string ccvs_auth(string session, string invoice)
|
||||
Perform credit authorization test on a transaction */
|
||||
PHP_FUNCTION(ccvs_auth) /* cv_auth() */
|
||||
{
|
||||
zval **psess;
|
||||
zval **pinvoice;
|
||||
void *sess;
|
||||
char *invoice;
|
||||
register int r;
|
||||
|
||||
if ((ZEND_NUM_ARGS() != 2) || (zend_get_parameters_ex(2, &psess, &pinvoice) != SUCCESS)) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
|
||||
{
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(psess);
|
||||
convert_to_string_ex(pinvoice);
|
||||
invoice = Z_STRVAL_PP(pinvoice);
|
||||
sess = hks_ptr_stringtoptr(Z_STRVAL_PP(psess));
|
||||
|
||||
r = cv_auth(sess, invoice);
|
||||
|
||||
RETURN_STRING(cv_ret2str(r), 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string ccvs_return(string session, string invoice)
|
||||
Transfer funds from the merchant to the credit card holder */
|
||||
PHP_FUNCTION(ccvs_return) /* cv_return() */
|
||||
{
|
||||
zval **psess;
|
||||
zval **pinvoice;
|
||||
void *sess;
|
||||
char *invoice;
|
||||
register int r;
|
||||
|
||||
if ((ZEND_NUM_ARGS() != 2) || (zend_get_parameters_ex(2, &psess, &pinvoice) != SUCCESS)) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
|
||||
{
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(psess);
|
||||
convert_to_string_ex(pinvoice);
|
||||
invoice = Z_STRVAL_PP(pinvoice);
|
||||
sess = hks_ptr_stringtoptr(Z_STRVAL_PP(psess));
|
||||
|
||||
r = cv_return(sess, invoice);
|
||||
|
||||
RETURN_STRING(cv_ret2str(r), 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string ccvs_reverse(string session, string invoice)
|
||||
Perform a full reversal on an already-processed authorization */
|
||||
PHP_FUNCTION(ccvs_reverse) /* cv_reverse() */
|
||||
{
|
||||
zval **psess;
|
||||
zval **pinvoice;
|
||||
void *sess;
|
||||
char *invoice;
|
||||
register int r;
|
||||
|
||||
if ((ZEND_NUM_ARGS() != 2) || (zend_get_parameters_ex(2, &psess, &pinvoice) != SUCCESS)) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
|
||||
{
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(psess);
|
||||
convert_to_string_ex(pinvoice);
|
||||
invoice = Z_STRVAL_PP(pinvoice);
|
||||
sess = hks_ptr_stringtoptr(Z_STRVAL_PP(psess));
|
||||
|
||||
r = cv_reverse(sess, invoice);
|
||||
|
||||
RETURN_STRING(cv_ret2str(r), 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string ccvs_sale(string session, string invoice)
|
||||
Transfer funds from the credit card holder to the merchant */
|
||||
PHP_FUNCTION(ccvs_sale) /* cv_sale() */
|
||||
{
|
||||
zval **psess;
|
||||
zval **pinvoice;
|
||||
void *sess;
|
||||
char *invoice;
|
||||
register int r;
|
||||
|
||||
if ((ZEND_NUM_ARGS() != 2) || (zend_get_parameters_ex(2, &psess, &pinvoice) != SUCCESS)) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
|
||||
{
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(psess);
|
||||
convert_to_string_ex(pinvoice);
|
||||
invoice = Z_STRVAL_PP(pinvoice);
|
||||
sess = hks_ptr_stringtoptr(Z_STRVAL_PP(psess));
|
||||
|
||||
r = cv_sale(sess, invoice);
|
||||
|
||||
RETURN_STRING(cv_ret2str(r), 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string ccvs_void(string session, string invoice)
|
||||
Perform a full reversal on a completed transaction */
|
||||
PHP_FUNCTION(ccvs_void) /* cv_void() */
|
||||
{
|
||||
zval **psess;
|
||||
zval **pinvoice;
|
||||
void *sess;
|
||||
char *invoice;
|
||||
register int r;
|
||||
|
||||
if ((ZEND_NUM_ARGS() != 2) || (zend_get_parameters_ex(2, &psess, &pinvoice) != SUCCESS)) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
|
||||
{
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(psess);
|
||||
convert_to_string_ex(pinvoice);
|
||||
invoice = Z_STRVAL_PP(pinvoice);
|
||||
sess = hks_ptr_stringtoptr(Z_STRVAL_PP(psess));
|
||||
|
||||
r = cv_void(sess, invoice);
|
||||
|
||||
RETURN_STRING(cv_ret2str(r), 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string ccvs_status(string session, string invoice)
|
||||
Check the status of an invoice */
|
||||
PHP_FUNCTION(ccvs_status) /* cv_status() */
|
||||
{
|
||||
zval **psess;
|
||||
zval **pinvoice;
|
||||
void *sess;
|
||||
char *invoice;
|
||||
register int r;
|
||||
|
||||
if ((ZEND_NUM_ARGS() != 2) || (zend_get_parameters_ex(2, &psess, &pinvoice) != SUCCESS)) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
|
||||
{
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(psess);
|
||||
convert_to_string_ex(pinvoice);
|
||||
invoice = Z_STRVAL_PP(pinvoice);
|
||||
sess = hks_ptr_stringtoptr(Z_STRVAL_PP(psess));
|
||||
|
||||
r = cv_status(sess, invoice);
|
||||
|
||||
RETURN_STRING(cv_stat2str(r), 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int ccvs_count(string session, string type)
|
||||
Find out how many transactions of a given type are stored in the system */
|
||||
PHP_FUNCTION(ccvs_count) /* cv_count() */
|
||||
{
|
||||
zval **psess;
|
||||
zval **ptype;
|
||||
void *sess;
|
||||
int type;
|
||||
register int r;
|
||||
|
||||
if ((ZEND_NUM_ARGS() != 2) || (zend_get_parameters_ex(2, &psess, &ptype) != SUCCESS)) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
|
||||
{
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(psess);
|
||||
convert_to_string_ex(ptype);
|
||||
type = cv_str2stat(Z_STRVAL_PP(ptype));
|
||||
sess = hks_ptr_stringtoptr(Z_STRVAL_PP(psess));
|
||||
|
||||
r = cv_count(sess, type);
|
||||
|
||||
RETURN_LONG(r);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string ccvs_lookup(string session, string invoice, int inum)
|
||||
Look up an item of a particular type in the database */
|
||||
PHP_FUNCTION(ccvs_lookup) /* cv_lookup() */
|
||||
{
|
||||
zval **psess;
|
||||
zval **ptype;
|
||||
zval **pinum;
|
||||
void *sess;
|
||||
int type;
|
||||
long inum;
|
||||
register int r;
|
||||
|
||||
if ((ZEND_NUM_ARGS() != 3) || (zend_get_parameters_ex(3, &psess, &ptype, &pinum) != SUCCESS)) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
|
||||
{
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(psess);
|
||||
sess = hks_ptr_stringtoptr(Z_STRVAL_PP(psess));
|
||||
convert_to_string_ex(ptype);
|
||||
type = cv_str2stat(Z_STRVAL_PP(ptype));
|
||||
convert_to_long_ex(pinum);
|
||||
inum = Z_LVAL_PP(pinum);
|
||||
|
||||
r = cv_lookup(sess, type, inum);
|
||||
|
||||
RETURN_STRING(cv_textvalue(sess), 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string ccvs_report(string session, string type)
|
||||
Return the status of the background communication process */
|
||||
PHP_FUNCTION(ccvs_report) /* cv_report() */
|
||||
{
|
||||
zval **psess;
|
||||
zval **ptype;
|
||||
void *sess;
|
||||
int type;
|
||||
long inum;
|
||||
register int r;
|
||||
|
||||
if ((ZEND_NUM_ARGS() != 2) || (zend_get_parameters_ex(2, &psess, &ptype) != SUCCESS)) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
|
||||
{
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(psess);
|
||||
sess = hks_ptr_stringtoptr(Z_STRVAL_PP(psess));
|
||||
convert_to_string_ex(ptype);
|
||||
type = cv_str2rep(Z_STRVAL_PP(ptype));
|
||||
|
||||
r = cv_report(sess, type);
|
||||
|
||||
RETURN_STRING(cv_stat2str(r), 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string ccvs_command(string session, string type, string argval)
|
||||
Performs a command which is peculiar to a single protocol, and thus is not available in the general CCVS API */
|
||||
PHP_FUNCTION(ccvs_command) /* cv_command() */
|
||||
{
|
||||
zval **psess;
|
||||
zval **ptype;
|
||||
zval **pargval;
|
||||
void *sess;
|
||||
int type;
|
||||
register int r;
|
||||
char *argval;
|
||||
|
||||
if ((ZEND_NUM_ARGS() != 3) || (zend_get_parameters_ex(3, &psess, &ptype, &pargval) != SUCCESS)) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
|
||||
{
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(psess);
|
||||
sess = hks_ptr_stringtoptr(Z_STRVAL_PP(psess));
|
||||
convert_to_string_ex(ptype);
|
||||
type = cv_str2cmd(Z_STRVAL_PP(ptype));
|
||||
convert_to_string_ex(pargval);
|
||||
argval = Z_STRVAL_PP(pargval);
|
||||
|
||||
r = cv_command(sess, type, argval);
|
||||
|
||||
RETURN_STRING(cv_stat2str(r), 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string ccvs_textvalue(string session)
|
||||
Get text return value for previous function call */
|
||||
PHP_FUNCTION(ccvs_textvalue) /* cv_textvalue() */
|
||||
{
|
||||
zval **psess;
|
||||
void *sess;
|
||||
|
||||
if ((ZEND_NUM_ARGS() != 1) || (zend_get_parameters_ex(1, &psess) != SUCCESS)) /* accept only SUCCESS in case something weird gets returned instead of 'FAILURE' on fail */
|
||||
{
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(psess);
|
||||
sess = hks_ptr_stringtoptr(Z_STRVAL_PP(psess));
|
||||
|
||||
RETURN_STRING(cv_textvalue(sess), 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* Our Info Function which reports info on this module out to PHP's phpinfo() function
|
||||
* Brendan W. McAdams <bmcadams@php.net> on 2000.07.26@16:22.EST
|
||||
*/
|
||||
|
||||
PHP_MINFO_FUNCTION(ccvs)
|
||||
{
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_header(2, "RedHat CCVS support", "enabled");
|
||||
php_info_print_table_row(2, "CCVS Support by", "Brendan W. McAdams <bmcadams@php.net><br />& Doug DeJulio <ddj@redhat.com>");
|
||||
php_info_print_table_row(2, "Release ID", cvsid);
|
||||
php_info_print_table_row(2, "This Release Certified For CCVS Versions", "3.0 and greater");
|
||||
php_info_print_table_end();
|
||||
|
||||
/* DISPLAY_INI_ENTRIES(); */
|
||||
|
||||
/*
|
||||
* In the future, we will probably have entries in php.ini for runtime config, in which case we will
|
||||
* Uncomment the DISPLAY_INI_ENTRIES call...
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2002 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Brendan W. McAdams <bmcadams@php.net> |
|
||||
| Doug DeJulio <ddj@redhat.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#include <cv_api.h>
|
||||
|
||||
extern zend_module_entry ccvs_module_entry;
|
||||
|
||||
#define ccvs_module_ptr &ccvs_module_entry
|
||||
#define phpext_ccvs_ptr ccvs_module_ptr
|
||||
|
||||
/* Declare functions not in cv_api.h but in libccvs.a. */
|
||||
char *hks_ptr_ptrtostring(void *vptr);
|
||||
void *hks_ptr_stringtoptr(char *str);
|
||||
|
||||
/* Declare the Functions this Module Makes Available to Zend */
|
||||
|
||||
|
||||
/* Pre-declarations of functions */
|
||||
PHP_FUNCTION(ccvs_init);
|
||||
PHP_FUNCTION(ccvs_done);
|
||||
PHP_FUNCTION(ccvs_new);
|
||||
PHP_FUNCTION(ccvs_add);
|
||||
PHP_FUNCTION(ccvs_delete);
|
||||
PHP_FUNCTION(ccvs_auth);
|
||||
PHP_FUNCTION(ccvs_return);
|
||||
PHP_FUNCTION(ccvs_reverse);
|
||||
PHP_FUNCTION(ccvs_sale);
|
||||
PHP_FUNCTION(ccvs_void);
|
||||
PHP_FUNCTION(ccvs_status);
|
||||
PHP_FUNCTION(ccvs_count);
|
||||
PHP_FUNCTION(ccvs_lookup);
|
||||
PHP_FUNCTION(ccvs_report);
|
||||
PHP_FUNCTION(ccvs_command);
|
||||
PHP_FUNCTION(ccvs_textvalue);
|
||||
PHP_MINFO_FUNCTION(ccvs);
|
||||
|
||||
/* Declare the information we need to dynamically link this module later */
|
||||
#if COMPILE_DL
|
||||
DLEXPORT zend_module_entry *get_module(void) { return &ccvs_module_entry; }
|
||||
#endif
|
||||
|
||||
/* End exports */
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
dnl
|
||||
dnl $Id$
|
||||
dnl
|
||||
|
||||
PHP_ARG_WITH(ccvs, for CCVS support,
|
||||
[ --with-ccvs[=DIR] Include CCVS support])
|
||||
|
||||
if test "$PHP_CCVS" != "no"; then
|
||||
if test -r $PHP_CCVS/include/cv_api.h; then
|
||||
CCVS_DIR=$PHP_CCVS
|
||||
else
|
||||
for i in /usr /usr/local /usr/local/ccvs ; do
|
||||
if test -r $i/include/cv_api.h; then
|
||||
CCVS_DIR=$i
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if test -z "$CCVS_DIR"; then
|
||||
AC_MSG_ERROR(not found. Please check your CCVS installation; cv_api.h should be in <ccvs_dir>/include/)
|
||||
fi
|
||||
|
||||
PHP_ADD_INCLUDE($CCVS_DIR/include)
|
||||
PHP_ADD_LIBRARY_WITH_PATH(ccvs, $CCVS_DIR/lib, CCVS_SHARED_LIBADD)
|
||||
PHP_NEW_EXTENSION(ccvs, ccvs.c, $ext_shared)
|
||||
PHP_SUBST(CCVS_SHARED_LIBADD)
|
||||
fi
|
||||
+153
-205
@@ -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$ */
|
||||
@@ -87,7 +87,6 @@ static unsigned char arg1and2_force_ref[] =
|
||||
function_entry COM_functions[] = {
|
||||
PHP_FE(com_load, NULL)
|
||||
PHP_FE(com_invoke, NULL)
|
||||
PHP_FE(com_invoke_ex, NULL)
|
||||
PHP_FE(com_addref, NULL)
|
||||
PHP_FE(com_release, NULL)
|
||||
PHP_FE(com_propget, NULL)
|
||||
@@ -124,7 +123,7 @@ PHPAPI HRESULT php_COM_invoke(comval *obj, DISPID dispIdMember, WORD wFlags, DIS
|
||||
if (C_ISREFD(obj)) {
|
||||
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 != DISP_E_EXCEPTION)) {
|
||||
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)) {
|
||||
/*
|
||||
@@ -134,7 +133,6 @@ PHPAPI HRESULT php_COM_invoke(comval *obj, DISPID dispIdMember, WORD wFlags, DIS
|
||||
|
||||
C_TYPEINFO_VT(obj)->Release(C_TYPEINFO(obj));
|
||||
C_HASTLIB(obj) = FALSE;
|
||||
C_TYPEINFO(obj) = NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -145,25 +143,22 @@ PHPAPI HRESULT php_COM_invoke(comval *obj, DISPID dispIdMember, WORD wFlags, DIS
|
||||
switch (hr) {
|
||||
case DISP_E_EXCEPTION: {
|
||||
|
||||
char *src = NULL;
|
||||
int srclen = 0;
|
||||
char *desc = NULL;
|
||||
int desclen = 0;
|
||||
char *src=estrdup("Unavailable");
|
||||
int srclen=strlen(src);
|
||||
char *desc=estrdup("Unavailable");
|
||||
int desclen=strlen(desc);
|
||||
|
||||
if (ExceptInfo.bstrSource) {
|
||||
if (ExceptInfo.bstrSource)
|
||||
{
|
||||
efree(src);
|
||||
src = php_OLECHAR_to_char(ExceptInfo.bstrSource, &srclen, codepage TSRMLS_CC);
|
||||
SysFreeString(ExceptInfo.bstrSource);
|
||||
} else {
|
||||
src = estrdup("Unavailable");
|
||||
srclen = strlen(src);
|
||||
}
|
||||
|
||||
if (ExceptInfo.bstrDescription) {
|
||||
if (ExceptInfo.bstrDescription)
|
||||
{
|
||||
efree(desc);
|
||||
desc = php_OLECHAR_to_char(ExceptInfo.bstrDescription, &desclen, codepage TSRMLS_CC);
|
||||
SysFreeString(ExceptInfo.bstrDescription);
|
||||
} else {
|
||||
desc = estrdup("Unavailable");
|
||||
desclen = strlen(desc);
|
||||
}
|
||||
|
||||
*ErrString = pemalloc(srclen+desclen+50, 1);
|
||||
@@ -216,7 +211,6 @@ PHPAPI HRESULT php_COM_get_ids_of_names(comval *obj, OLECHAR FAR* FAR* rgszNames
|
||||
|
||||
C_TYPEINFO_VT(obj)->Release(C_TYPEINFO(obj));
|
||||
C_HASTLIB(obj) = FALSE;
|
||||
C_TYPEINFO(obj) = NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -239,17 +233,12 @@ PHPAPI HRESULT php_COM_release(comval *obj TSRMLS_DC)
|
||||
} else if (obj->refcount == 1) {
|
||||
if (C_HASTLIB(obj)) {
|
||||
C_TYPEINFO_VT(obj)->Release(C_TYPEINFO(obj));
|
||||
C_TYPEINFO(obj) = NULL;
|
||||
C_HASTLIB(obj) = FALSE;
|
||||
}
|
||||
if (C_HASENUM(obj)) {
|
||||
hr = C_ENUMVARIANT_VT(obj)->Release(C_ENUMVARIANT(obj));
|
||||
C_ENUMVARIANT(obj) = NULL;
|
||||
C_HASENUM(obj) = FALSE;
|
||||
}
|
||||
hr = C_DISPATCH_VT(obj)->Release(C_DISPATCH(obj));
|
||||
C_RELEASE(obj);
|
||||
C_DISPATCH(obj) = NULL;
|
||||
}
|
||||
|
||||
return obj->refcount;
|
||||
@@ -261,6 +250,7 @@ PHPAPI HRESULT php_COM_addref(comval *obj TSRMLS_DC)
|
||||
if (C_ISREFD(obj)) {
|
||||
C_ADDREF(obj);
|
||||
}
|
||||
|
||||
return obj->refcount;
|
||||
}
|
||||
|
||||
@@ -291,9 +281,11 @@ PHPAPI HRESULT php_COM_set(comval *obj, IDispatch FAR* FAR* ppDisp, int cleanup
|
||||
if (C_HASENUM(obj) = SUCCEEDED(C_DISPATCH_VT(obj)->Invoke(C_DISPATCH(obj), DISPID_NEWENUM, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
|
||||
DISPATCH_METHOD|DISPATCH_PROPERTYGET, &dispparams, var_result, NULL, NULL))) {
|
||||
if (V_VT(var_result) == VT_UNKNOWN) {
|
||||
V_UNKNOWN(var_result)->lpVtbl->AddRef(V_UNKNOWN(var_result));
|
||||
C_HASENUM(obj) = SUCCEEDED(V_UNKNOWN(var_result)->lpVtbl->QueryInterface(V_UNKNOWN(var_result), &IID_IEnumVARIANT,
|
||||
(void**)&C_ENUMVARIANT(obj)));
|
||||
} else if (V_VT(var_result) == VT_DISPATCH) {
|
||||
V_DISPATCH(var_result)->lpVtbl->AddRef(V_DISPATCH(var_result));
|
||||
C_HASENUM(obj) = SUCCEEDED(V_DISPATCH(var_result)->lpVtbl->QueryInterface(V_DISPATCH(var_result), &IID_IEnumVARIANT,
|
||||
(void**)&C_ENUMVARIANT(obj)));
|
||||
}
|
||||
@@ -726,14 +718,14 @@ PHP_FUNCTION(com_load)
|
||||
}
|
||||
}
|
||||
|
||||
RETVAL_COM(obj);
|
||||
RETURN_RESOURCE(zend_list_insert(obj, IS_COM));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
static int do_COM_invoke(comval *obj, WORD dispflags, pval *function_name, VARIANT *var_result, pval **arguments, int arg_count TSRMLS_DC)
|
||||
int do_COM_invoke(comval *obj, pval *function_name, VARIANT *var_result, pval **arguments, int arg_count TSRMLS_DC)
|
||||
{
|
||||
DISPID dispid, altdispid;
|
||||
DISPID dispid;
|
||||
DISPPARAMS dispparams;
|
||||
HRESULT hr;
|
||||
OLECHAR *funcname;
|
||||
@@ -744,7 +736,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();
|
||||
@@ -884,19 +876,12 @@ static int do_COM_invoke(comval *obj, WORD dispflags, pval *function_name, VARIA
|
||||
dispparams.cArgs = arg_count;
|
||||
dispparams.cNamedArgs = 0;
|
||||
|
||||
if (dispflags & DISPATCH_PROPERTYPUT) {
|
||||
/* Make this work for property set-ing */
|
||||
altdispid = DISPID_PROPERTYPUT;
|
||||
dispparams.rgdispidNamedArgs = &altdispid;
|
||||
dispparams.cNamedArgs = 1;
|
||||
}
|
||||
|
||||
hr = php_COM_invoke(obj, dispid, dispflags, &dispparams, var_result, &ErrString TSRMLS_CC);
|
||||
hr = php_COM_invoke(obj, dispid, DISPATCH_METHOD|DISPATCH_PROPERTYGET, &dispparams, var_result, &ErrString TSRMLS_CC);
|
||||
|
||||
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]);
|
||||
}
|
||||
@@ -919,53 +904,6 @@ static int do_COM_invoke(comval *obj, WORD dispflags, pval *function_name, VARIA
|
||||
}
|
||||
|
||||
|
||||
/* {{{ proto mixed com_invoke_ex(int module, int invokeflags, string handler_name [, mixed arg [, mixed ...]])
|
||||
Invokes a COM module */
|
||||
PHP_FUNCTION(com_invoke_ex)
|
||||
{
|
||||
pval **arguments;
|
||||
pval *object, *function_name, *invokeflags;
|
||||
comval *obj = NULL;
|
||||
WORD dispflags = 0;
|
||||
int arg_count = ZEND_NUM_ARGS();
|
||||
VARIANT *var_result;
|
||||
|
||||
if (arg_count<3) {
|
||||
ZEND_WRONG_PARAM_COUNT();
|
||||
}
|
||||
arguments = (pval **) emalloc(sizeof(pval *)*arg_count);
|
||||
if (zend_get_parameters_array(ht, arg_count, arguments) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
object = arguments[0];
|
||||
function_name = arguments[2];
|
||||
invokeflags = arguments[1];
|
||||
|
||||
/* obtain property/method handler */
|
||||
convert_to_string_ex(&function_name);
|
||||
convert_to_long(invokeflags);
|
||||
dispflags = (WORD)Z_LVAL_P(invokeflags);
|
||||
|
||||
/* obtain IDispatch interface */
|
||||
FETCH_COM_SAFE(object, obj);
|
||||
|
||||
ALLOC_VARIANT(var_result);
|
||||
|
||||
if (do_COM_invoke(obj, dispflags, function_name, var_result, arguments+3, arg_count-3 TSRMLS_CC)==FAILURE) {
|
||||
FREE_VARIANT(var_result);
|
||||
efree(arguments);
|
||||
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
RETVAL_VARIANT(var_result);
|
||||
|
||||
efree(arguments);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ proto mixed com_invoke(int module, string handler_name [, mixed arg [, mixed ...]])
|
||||
Invokes a COM module */
|
||||
PHP_FUNCTION(com_invoke)
|
||||
@@ -973,6 +911,7 @@ PHP_FUNCTION(com_invoke)
|
||||
pval **arguments;
|
||||
pval *object, *function_name;
|
||||
comval *obj;
|
||||
int type;
|
||||
int arg_count = ZEND_NUM_ARGS();
|
||||
VARIANT *var_result;
|
||||
|
||||
@@ -988,14 +927,19 @@ 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(E_WARNING,"%s(): %d is not a COM object handler", get_active_function_name(TSRMLS_C), Z_STRVAL_P(function_name));
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
/* obtain property/method handler */
|
||||
convert_to_string_ex(&function_name);
|
||||
|
||||
ALLOC_VARIANT(var_result);
|
||||
|
||||
if (do_COM_invoke(obj, DISPATCH_METHOD|DISPATCH_PROPERTYGET, function_name, var_result, arguments+2, arg_count-2 TSRMLS_CC)==FAILURE) {
|
||||
if (do_COM_invoke(obj, function_name, var_result, arguments+2, arg_count-2 TSRMLS_CC)==FAILURE) {
|
||||
FREE_VARIANT(var_result);
|
||||
efree(arguments);
|
||||
|
||||
@@ -1015,6 +959,7 @@ PHP_FUNCTION(com_release)
|
||||
{
|
||||
pval *object;
|
||||
comval *obj;
|
||||
int type;
|
||||
int arg_count = ZEND_NUM_ARGS();
|
||||
|
||||
if (arg_count != 1) {
|
||||
@@ -1026,7 +971,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))
|
||||
}
|
||||
@@ -1039,6 +989,7 @@ PHP_FUNCTION(com_addref)
|
||||
{
|
||||
pval *object;
|
||||
comval *obj;
|
||||
int type;
|
||||
int arg_count = ZEND_NUM_ARGS();
|
||||
|
||||
if (arg_count != 1) {
|
||||
@@ -1050,7 +1001,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));
|
||||
}
|
||||
@@ -1311,7 +1268,7 @@ static int process_typeinfo(ITypeInfo *typeinfo, HashTable *id_to_name, int prin
|
||||
|
||||
ret = 1;
|
||||
} else {
|
||||
zend_error(E_WARNING, "Thats not a dispatchable interface!! type kind = %08x", attr->typekind);
|
||||
zend_error(E_WARNING, "Thats not a dispatchable interface!! type kind = %08x\n", attr->typekind);
|
||||
}
|
||||
|
||||
typeinfo->lpVtbl->ReleaseTypeAttr(typeinfo, attr);
|
||||
@@ -1425,8 +1382,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);
|
||||
@@ -1460,8 +1421,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;
|
||||
@@ -1508,7 +1475,7 @@ static int do_COM_offget(VARIANT *result, comval *array, pval *property, int cle
|
||||
int retval;
|
||||
|
||||
ZVAL_STRINGL(&function_name, "Item", 4, 0);
|
||||
retval = do_COM_invoke(array, DISPATCH_METHOD|DISPATCH_PROPERTYGET, &function_name, result, &property, 1 TSRMLS_CC);
|
||||
retval = do_COM_invoke(array, &function_name, result, &property, 1 TSRMLS_CC);
|
||||
if (cleanup) {
|
||||
php_COM_destruct(array TSRMLS_CC);
|
||||
}
|
||||
@@ -1627,11 +1594,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);
|
||||
|
||||
@@ -1649,10 +1611,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);
|
||||
}
|
||||
@@ -1660,98 +1620,72 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
/* {{{ proto mixed com_propget(int module, string property_name [, mixed arg ... ])
|
||||
/* {{{ proto mixed com_propget(int module, string property_name)
|
||||
Gets properties from a COM module */
|
||||
PHP_FUNCTION(com_propget)
|
||||
{
|
||||
zval **arguments;
|
||||
zval *object, *function_name;
|
||||
comval *obj = NULL;
|
||||
int arg_count = ZEND_NUM_ARGS();
|
||||
pval *arg_comval, *arg_property;
|
||||
int type;
|
||||
comval *obj;
|
||||
VARIANT *var_result;
|
||||
|
||||
if (arg_count < 2) {
|
||||
if ((ZEND_NUM_ARGS() != 2) || (zend_get_parameters(ht, 2, &arg_comval, &arg_property) == FAILURE)) {
|
||||
ZEND_WRONG_PARAM_COUNT();
|
||||
}
|
||||
arguments = (zval **) emalloc(sizeof(pval *)*arg_count);
|
||||
if (zend_get_parameters_array(ht, arg_count, arguments) == FAILURE) {
|
||||
|
||||
/* obtain IDispatch interface */
|
||||
convert_to_long(arg_comval);
|
||||
obj = (comval *)zend_list_find(Z_LVAL_P(arg_comval), &type);
|
||||
if (!obj || (type != IS_COM)) {
|
||||
php_error(E_WARNING, "%s(): %d is not a COM object handler", get_active_function_name(TSRMLS_C), Z_LVAL_P(arg_comval));
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
object = arguments[0];
|
||||
function_name = arguments[1];
|
||||
|
||||
FETCH_COM_SAFE(object, obj);
|
||||
|
||||
/* obtain property/method handler */
|
||||
convert_to_string_ex(&function_name);
|
||||
convert_to_string_ex(&arg_property);
|
||||
|
||||
ALLOC_VARIANT(var_result);
|
||||
|
||||
if (do_COM_invoke(obj, DISPATCH_PROPERTYGET, function_name, var_result, arguments+2, arg_count-2 TSRMLS_CC)==FAILURE) {
|
||||
if (do_COM_propget(var_result, obj, arg_property, FALSE TSRMLS_CC) == FAILURE) {
|
||||
FREE_VARIANT(var_result);
|
||||
efree(arguments);
|
||||
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
RETVAL_VARIANT(var_result);
|
||||
|
||||
efree(arguments);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ proto bool com_propput(int module, string property_name, mixed value, ...)
|
||||
/* {{{ proto bool com_propput(int module, string property_name, mixed value)
|
||||
Puts the properties for a module */
|
||||
PHP_FUNCTION(com_propput)
|
||||
{
|
||||
zval **arguments;
|
||||
zval *object, *function_name;
|
||||
pval *arg_comval, *arg_property, *arg_value;
|
||||
int type;
|
||||
comval *obj;
|
||||
int arg_count = ZEND_NUM_ARGS();
|
||||
VARIANT *var_result;
|
||||
|
||||
if (arg_count<3) {
|
||||
if (ZEND_NUM_ARGS()!=3 || zend_get_parameters(ht, 3, &arg_comval, &arg_property, &arg_value)==FAILURE) {
|
||||
ZEND_WRONG_PARAM_COUNT();
|
||||
}
|
||||
arguments = (zval **) emalloc(sizeof(pval *)*arg_count);
|
||||
if (zend_get_parameters_array(ht, arg_count, arguments) == FAILURE) {
|
||||
|
||||
/* obtain comval interface */
|
||||
convert_to_long(arg_comval);
|
||||
/* obtain comval interface */
|
||||
obj = (comval *)zend_list_find(Z_LVAL_P(arg_comval), &type);
|
||||
if (!obj || (type != IS_COM)) {
|
||||
php_error(E_WARNING, "%s(): %d is not a COM object handler", get_active_function_name(TSRMLS_C), Z_LVAL_P(arg_comval));
|
||||
RETURN_NULL();
|
||||
}
|
||||
convert_to_string_ex(&arg_property);
|
||||
|
||||
object = arguments[0];
|
||||
function_name = arguments[1];
|
||||
|
||||
FETCH_COM_SAFE(object, obj);
|
||||
|
||||
/* obtain property/method handler */
|
||||
convert_to_string_ex(&function_name);
|
||||
|
||||
ALLOC_VARIANT(var_result);
|
||||
|
||||
if (do_COM_invoke(obj, DISPATCH_PROPERTYPUT, function_name, var_result, arguments+2, arg_count-2 TSRMLS_CC)==FAILURE) {
|
||||
FREE_VARIANT(var_result);
|
||||
efree(arguments);
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
RETVAL_VARIANT(var_result);
|
||||
|
||||
efree(arguments);
|
||||
do_COM_propput(return_value, obj, arg_property, arg_value TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -1797,7 +1731,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;
|
||||
@@ -1805,14 +1739,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);
|
||||
@@ -1826,7 +1760,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;
|
||||
|
||||
@@ -1835,54 +1769,54 @@ 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;
|
||||
|
||||
case OE_IS_METHOD:
|
||||
FREE_VARIANT(var_result);
|
||||
case OE_IS_METHOD: {
|
||||
FREE_VARIANT(var_result);
|
||||
if (obj != obj_prop) {
|
||||
FREE_COM(obj_prop);
|
||||
|
||||
if (obj != obj_prop) {
|
||||
efree(obj_prop);
|
||||
|
||||
retval = *object;
|
||||
zval_copy_ctor(&retval);
|
||||
} else {
|
||||
ZVAL_COM(&retval, obj);
|
||||
return_value = *object;
|
||||
ZVAL_ADDREF(&return_value);
|
||||
} else {
|
||||
RETVAL_COM(obj);
|
||||
}
|
||||
return return_value;
|
||||
}
|
||||
|
||||
return retval;
|
||||
break;
|
||||
}
|
||||
|
||||
zval_dtor(&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
|
||||
} 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;
|
||||
}
|
||||
|
||||
pval_destructor(&overloaded_property->element);
|
||||
}
|
||||
|
||||
if (obj_prop != NULL) {
|
||||
ZVAL_COM(&retval, obj);
|
||||
RETVAL_COM(obj);
|
||||
}
|
||||
|
||||
|
||||
FREE_VARIANT(var_result);
|
||||
|
||||
return retval;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
@@ -1952,7 +1886,7 @@ PHPAPI int php_COM_set_property_handler(zend_property_reference *property_refere
|
||||
}
|
||||
|
||||
VariantInit(var_result); // to protect C_DISPATCH(obj) from being freed when var_result is destructed
|
||||
zval_dtor(&overloaded_property->element);
|
||||
pval_destructor(&overloaded_property->element);
|
||||
}
|
||||
FREE_VARIANT(var_result);
|
||||
|
||||
@@ -1960,7 +1894,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;
|
||||
}
|
||||
@@ -1991,15 +1925,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;
|
||||
}
|
||||
|
||||
@@ -2007,8 +1946,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;
|
||||
@@ -2018,8 +1957,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;
|
||||
}
|
||||
@@ -2037,20 +1976,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);
|
||||
if (do_COM_invoke(obj , &function_name->element, var_result, arguments, arg_count TSRMLS_CC) == SUCCESS) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -2311,7 +2254,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();
|
||||
@@ -2320,7 +2265,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));
|
||||
}
|
||||
@@ -2363,9 +2313,7 @@ PHP_MINIT_FUNCTION(COM)
|
||||
REGISTER_LONG_CONSTANT("CLSCTX_REMOTE_SERVER", CLSCTX_REMOTE_SERVER, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("CLSCTX_SERVER", CLSCTX_SERVER, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("CLSCTX_ALL", CLSCTX_ALL, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DISPATCH_METHOD", DISPATCH_METHOD, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DISPATCH_PROPERTYGET", DISPATCH_PROPERTYGET, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DISPATCH_PROPERTYPUT", DISPATCH_PROPERTYPUT, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
REGISTER_INI_ENTRIES();
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
+2
-2
@@ -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 |
|
||||
@@ -230,7 +230,7 @@ static int php_VARIANT_set_property_handler(zend_property_reference *property_re
|
||||
|
||||
static int do_VARIANT_propset(VARIANT *var_arg, pval *arg_property, pval *value TSRMLS_DC)
|
||||
{
|
||||
VARTYPE type;
|
||||
int type;
|
||||
|
||||
if (!strcmp(Z_STRVAL_P(arg_property), "value")) {
|
||||
php_pval_to_variant(value, var_arg, codepage TSRMLS_CC);
|
||||
|
||||
+4
-17
@@ -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)
|
||||
|
||||
+12
-17
@@ -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 |
|
||||
@@ -42,7 +42,7 @@ static void comval_to_variant(pval *pval_arg, VARIANT *var_arg TSRMLS_DC);
|
||||
/* implementations */
|
||||
PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage TSRMLS_DC)
|
||||
{
|
||||
VARTYPE type = VT_EMPTY; /* default variant type */
|
||||
int type = VT_EMPTY; /* default variant type */
|
||||
|
||||
switch (Z_TYPE_P(pval_arg)) {
|
||||
case IS_NULL:
|
||||
@@ -90,11 +90,11 @@ PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage T
|
||||
|
||||
PHPAPI void php_pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, pval *pval_type, int codepage TSRMLS_DC)
|
||||
{
|
||||
php_pval_to_variant_ex2(pval_arg, var_arg, (unsigned short) Z_LVAL_P(pval_type), codepage TSRMLS_CC);
|
||||
php_pval_to_variant_ex2(pval_arg, var_arg, Z_LVAL_P(pval_type), codepage TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, VARTYPE type, int codepage TSRMLS_DC)
|
||||
PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, int type, int codepage TSRMLS_DC)
|
||||
{
|
||||
OLECHAR *unicode_str;
|
||||
|
||||
@@ -108,7 +108,7 @@ PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, VARTYPE ty
|
||||
int numberOfElements = zend_hash_num_elements(ht);
|
||||
SAFEARRAY *safeArray;
|
||||
SAFEARRAYBOUND bounds[1];
|
||||
VARIANT *v, var;
|
||||
VARIANT *v;
|
||||
zval **entry; /* An entry in the input array */
|
||||
|
||||
type &= ~VT_ARRAY;
|
||||
@@ -118,35 +118,29 @@ PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, VARTYPE ty
|
||||
ALLOC_VARIANT(V_VARIANTREF(var_arg));
|
||||
var_arg = V_VARIANTREF(var_arg); /* put the array in that VARIANT */
|
||||
}
|
||||
if (!type) {
|
||||
// if no type is given we take the variant type
|
||||
type = VT_VARIANT;
|
||||
}
|
||||
|
||||
bounds[0].lLbound = 0;
|
||||
bounds[0].cElements = numberOfElements;
|
||||
safeArray = SafeArrayCreate(type, 1, bounds);
|
||||
safeArray = SafeArrayCreate(VT_VARIANT, 1, bounds);
|
||||
|
||||
if (NULL == safeArray) {
|
||||
php_error( E_WARNING,"Unable to convert php array to VARIANT array - %s", numberOfElements ? "" : "(Empty input array)");
|
||||
ZVAL_FALSE(pval_arg);
|
||||
} else {
|
||||
V_ARRAY(var_arg) = safeArray;
|
||||
V_VT(var_arg) = VT_ARRAY|type; /* Now have a valid safe array allocated */
|
||||
V_VT(var_arg) = VT_ARRAY|VT_VARIANT; /* Now have a valid safe array allocated */
|
||||
if (SUCCEEDED(SafeArrayLock(safeArray))) {
|
||||
ulong i;
|
||||
UINT size = SafeArrayGetElemsize(safeArray);
|
||||
|
||||
zend_hash_internal_pointer_reset(ht);
|
||||
for (i = 0; i < (ulong)numberOfElements; ++i) {
|
||||
if ((zend_hash_get_current_data(ht, (void **)&entry) == SUCCESS) && (entry != NULL)) { /* Get a pointer to the php array element */
|
||||
/* Add another value to the safe array */
|
||||
if (SUCCEEDED(SafeArrayPtrOfIndex(safeArray, &i, &v))) { /* Pointer to output element entry retrieved successfully */
|
||||
if (type == VT_VARIANT) {
|
||||
php_pval_to_variant(*entry, v, codepage TSRMLS_CC); /* Do the required conversion */
|
||||
if (SUCCEEDED(SafeArrayPtrOfIndex( safeArray, &i, &v))) { /* Pointer to output element entry retrieved successfully */
|
||||
if (type) { /* explicit type */
|
||||
php_pval_to_variant_ex2(*entry, v, type, codepage TSRMLS_CC); /* Do the required conversion */
|
||||
} else {
|
||||
php_pval_to_variant_ex2(*entry, &var, type, codepage TSRMLS_CC); /* Do the required conversion */
|
||||
memcpy(v, &(var.byref), size);
|
||||
php_pval_to_variant(*entry, v, codepage TSRMLS_CC); /* Do the required conversion */
|
||||
}
|
||||
} else {
|
||||
php_error( E_WARNING,"phpArrayToSafeArray() - Unable to retrieve pointer to output element number (%d)", i);
|
||||
@@ -729,6 +723,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;
|
||||
|
||||
@@ -13,7 +13,7 @@ BEGIN_EXTERN_C()
|
||||
|
||||
PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage TSRMLS_DC);
|
||||
PHPAPI void php_pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, pval *pval_type, int codepage TSRMLS_DC);
|
||||
PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, VARTYPE type, int codepage TSRMLS_DC);
|
||||
PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, int type, int codepage TSRMLS_DC);
|
||||
PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int codepage TSRMLS_DC);
|
||||
PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage TSRMLS_DC);
|
||||
PHPAPI char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int codepage TSRMLS_DC);
|
||||
|
||||
+1
-1
@@ -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
-2
@@ -12,7 +12,6 @@ PHP_MSHUTDOWN_FUNCTION(COM);
|
||||
|
||||
PHP_FUNCTION(com_load);
|
||||
PHP_FUNCTION(com_invoke);
|
||||
PHP_FUNCTION(com_invoke_ex);
|
||||
PHP_FUNCTION(com_addref);
|
||||
PHP_FUNCTION(com_release);
|
||||
PHP_FUNCTION(com_propget);
|
||||
@@ -58,7 +57,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
@@ -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));
|
||||
|
||||
+61
-87
@@ -1,96 +1,70 @@
|
||||
dnl $Id$
|
||||
|
||||
AC_DEFUN(CPDF_TEMP_SUBST,[
|
||||
old_LIBS=$LIBS
|
||||
$1
|
||||
LIBS=$old_LIBS
|
||||
])
|
||||
|
||||
AC_DEFUN(CPDF_JPEG_TEST,[
|
||||
CPDF_TEMP_SUBST([
|
||||
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
|
||||
LIBS="$LIBS -L$CPDF_JPEG_DIR/lib"
|
||||
],)
|
||||
AC_CHECK_LIB(jpeg,jpeg_read_header, ,[AC_MSG_ERROR(Problem with libjpeg.(a|so). Please check config.log for more information.)],)
|
||||
if test -z "$CPDF_JPEG_DIR"; then
|
||||
PHP_ADD_LIBRARY(jpeg)
|
||||
else
|
||||
PHP_ADD_LIBRARY_WITH_PATH(jpeg, $CPDF_JPEG_DIR/lib)
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
AC_DEFUN(CPDF_TIFF_TEST,[
|
||||
CPDF_TEMP_SUBST([
|
||||
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
|
||||
LIBS="$LIBS -L$CPDF_TIFF_DIR/lib"
|
||||
],)
|
||||
AC_CHECK_LIB(tiff,TIFFOpen, ,[AC_MSG_ERROR(Problem with libtiff.(a|so). Please check config.log for more information.)],)
|
||||
if test -z "$CPDF_TIFF_DIR"; then
|
||||
PHP_ADD_LIBRARY(tiff)
|
||||
else
|
||||
PHP_ADD_LIBRARY_WITH_PATH(tiff, $CPDF_TIFF_DIR/lib)
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING(for cpdflib support)
|
||||
AC_ARG_WITH(cpdflib,
|
||||
[ --with-cpdflib[=DIR] Include cpdflib support (requires cpdflib >= 2).],
|
||||
[
|
||||
if test "$withval" = "no"; then
|
||||
AC_MSG_RESULT(no)
|
||||
else
|
||||
AC_MSG_RESULT(yes)
|
||||
PHP_NEW_EXTENSION(cpdf, cpdf.c)
|
||||
CPDF_JPEG_TEST
|
||||
CPDF_TIFF_TEST
|
||||
for i in $withval /usr /usr/local; 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])
|
||||
CPDF_TEMP_SUBST([
|
||||
LIBS="$LIBS -L$i/lib"
|
||||
AC_CHECK_LIB(cpdf, cpdf_open, [AC_DEFINE(HAVE_CPDFLIB,1,[Whether you have cpdflib])],
|
||||
[AC_MSG_ERROR([Cpdflib module requires cpdflib >= 2.])])
|
||||
])
|
||||
if test "$i" != "/usr" -a "$i" != "/usr/local"; then
|
||||
PHP_ADD_LIBRARY_WITH_PATH(cpdf, $i/lib)
|
||||
PHP_ADD_INCLUDE($CPDFLIB_INCLUDE)
|
||||
else
|
||||
PHP_ADD_LIBRARY(cpdf)
|
||||
fi
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -z "$CPDFLIB_INCLUDE"; then
|
||||
AC_MSG_CHECKING(for cpdflib.h)
|
||||
AC_MSG_ERROR([not found])
|
||||
fi
|
||||
fi
|
||||
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
|
||||
|
||||
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>)
|
||||
])
|
||||
|
||||
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
|
||||
|
||||
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)
|
||||
])
|
||||
+2
-21
@@ -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,7 +23,7 @@
|
||||
|
||||
/* Note that there is no code from the cpdflib package in this file */
|
||||
|
||||
#if defined(THREAD_SAFE)
|
||||
#if !PHP_31 && defined(THREAD_SAFE)
|
||||
#undef THREAD_SAFE
|
||||
#endif
|
||||
|
||||
@@ -41,8 +41,6 @@
|
||||
#include <gd.h>
|
||||
#endif
|
||||
|
||||
#include <cpdflib.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
@@ -475,10 +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))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
cpdf_setOutputFilename(cpdf, Z_STRVAL_P(arg2));
|
||||
}
|
||||
cpdf_init(cpdf);
|
||||
@@ -932,10 +926,6 @@ 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;
|
||||
@@ -2386,10 +2376,6 @@ 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;
|
||||
@@ -2413,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]);
|
||||
|
||||
+3
-1
@@ -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
|
||||
|
||||
|
||||
+1
-1
@@ -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
@@ -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 |
|
||||
|
||||
@@ -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,8 +35,8 @@ ctype_test_002("ctype_space");
|
||||
ctype_test_002("ctype_xdigit");
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
LOCALE is '%s'
|
||||
--EXPECT--
|
||||
LOCALE is 'C'
|
||||
ctype_lower 26 26 0
|
||||
ctype_upper 26 26 0
|
||||
ctype_alpha 52 52 0
|
||||
|
||||
+4
-20
@@ -5,10 +5,6 @@ dnl
|
||||
PHP_ARG_WITH(curl, for CURL support,
|
||||
[ --with-curl[=DIR] Include CURL support])
|
||||
|
||||
dnl Temporary option while we develop this aspect of the extension
|
||||
dnl PHP_ARG_WITH(curlwrappers, if we should use CURL for url streams,
|
||||
dnl [ --with-curlwrappers Use CURL for url streams], no, no)
|
||||
|
||||
if test "$PHP_CURL" != "no"; then
|
||||
if test -r $PHP_CURL/include/curl/easy.h; then
|
||||
CURL_DIR=$PHP_CURL
|
||||
@@ -18,7 +14,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
|
||||
@@ -30,7 +25,7 @@ if test "$PHP_CURL" != "no"; then
|
||||
fi
|
||||
|
||||
CURL_CONFIG="curl-config"
|
||||
AC_MSG_CHECKING(for cURL 7.9.8 or greater)
|
||||
AC_MSG_CHECKING(for cURL 7.9 or greater)
|
||||
|
||||
if ${CURL_DIR}/bin/curl-config --libs print > /dev/null 2>&1; then
|
||||
CURL_CONFIG=${CURL_DIR}/bin/curl-config
|
||||
@@ -42,11 +37,11 @@ if test "$PHP_CURL" != "no"; then
|
||||
|
||||
curl_version_full=`$CURL_CONFIG --version`
|
||||
curl_version=`echo ${curl_version_full} | sed -e 's/libcurl //' | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
|
||||
if test "$curl_version" -ge 7009008; then
|
||||
if test "$curl_version" -ge 7009000; then
|
||||
AC_MSG_RESULT($curl_version_full)
|
||||
CURL_LIBS=`$CURL_CONFIG --libs`
|
||||
else
|
||||
AC_MSG_ERROR(cURL version 7.9.8 or later is required to compile php with cURL support)
|
||||
AC_MSG_ERROR(cURL version 7.9 or later is required to compile php with cURL support)
|
||||
fi
|
||||
|
||||
PHP_ADD_INCLUDE($CURL_DIR/include)
|
||||
@@ -62,17 +57,6 @@ if test "$PHP_CURL" != "no"; then
|
||||
$CURL_LIBS -L$CURL_DIR/lib
|
||||
])
|
||||
|
||||
PHP_CHECK_LIBRARY(curl,curl_version_info,
|
||||
[
|
||||
AC_DEFINE(HAVE_CURL_VERSION_INFO,1,[ ])
|
||||
],[],[
|
||||
$CURL_LIBS -L$CURL_DIR/lib
|
||||
])
|
||||
|
||||
dnl if test "$PHP_CURLWRAPPERS" != "no" ; then
|
||||
dnl AC_DEFINE(PHP_CURL_URL_WRAPPERS,1,[ ])
|
||||
dnl fi
|
||||
|
||||
PHP_NEW_EXTENSION(curl, curl.c curlstreams.c, $ext_shared)
|
||||
PHP_NEW_EXTENSION(curl, curl.c, $ext_shared)
|
||||
PHP_SUBST(CURL_SHARED_LIBADD)
|
||||
fi
|
||||
+63
-197
@@ -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 |
|
||||
@@ -51,11 +51,6 @@ static void _php_curl_close(zend_rsrc_list_entry *rsrc TSRMLS_DC);
|
||||
|
||||
#define SAVE_CURL_ERROR(__handle, __err) (__handle)->err.no = (int) __err;
|
||||
|
||||
#define CAAL(s, v) add_assoc_long_ex(return_value, s, sizeof(s), (long) v);
|
||||
#define CAAD(s, v) add_assoc_double_ex(return_value, s, sizeof(s), (double) v);
|
||||
#define CAAS(s, v) add_assoc_string_ex(return_value, s, sizeof(s), (char *) v, 1);
|
||||
#define CAAZ(s, v) add_assoc_zval_ex(return_value, s, sizeof(s), (zval *) v);
|
||||
|
||||
/* {{{ curl_functions[]
|
||||
*/
|
||||
function_entry curl_functions[] = {
|
||||
@@ -142,7 +137,6 @@ PHP_MINIT_FUNCTION(curl)
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_REFERER);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_USERAGENT);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_FTPPORT);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_EPSV);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_LOW_SPEED_LIMIT);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_LOW_SPEED_TIME);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_RESUME_FROM);
|
||||
@@ -179,22 +173,10 @@ PHP_MINIT_FUNCTION(curl)
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_CONNECTTIMEOUT);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_SSL_VERIFYPEER);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_CAINFO);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_CAPATH);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_COOKIEJAR);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_SSL_CIPHER_LIST);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_BINARYTRANSFER);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_HTTPGET);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_HTTP_VERSION);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_SSLKEY);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_SSLKEYTYPE);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_SSLKEYPASSWD);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_SSLENGINE);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_SSLENGINE_DEFAULT);
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_CRLF);
|
||||
#ifdef CURLOPT_ENCODING
|
||||
REGISTER_CURL_CONSTANT(CURLOPT_ENCODING);
|
||||
#endif
|
||||
|
||||
|
||||
/* Constants effecting the way CURLOPT_CLOSEPOLICY works */
|
||||
REGISTER_CURL_CONSTANT(CURLCLOSEPOLICY_LEAST_RECENTLY_USED);
|
||||
REGISTER_CURL_CONSTANT(CURLCLOSEPOLICY_LEAST_TRAFFIC);
|
||||
@@ -219,10 +201,6 @@ PHP_MINIT_FUNCTION(curl)
|
||||
REGISTER_CURL_CONSTANT(CURLINFO_SSL_VERIFYRESULT);
|
||||
REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_LENGTH_DOWNLOAD);
|
||||
REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_LENGTH_UPLOAD);
|
||||
REGISTER_CURL_CONSTANT(CURLINFO_STARTTRANSFER_TIME);
|
||||
REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_TYPE);
|
||||
REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_TIME);
|
||||
REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_COUNT);
|
||||
|
||||
/* Error Constants */
|
||||
REGISTER_CURL_CONSTANT(CURLE_OK);
|
||||
@@ -278,26 +256,10 @@ PHP_MINIT_FUNCTION(curl)
|
||||
REGISTER_CURL_CONSTANT(CURLE_OBSOLETE);
|
||||
REGISTER_CURL_CONSTANT(CURLE_SSL_PEER_CERTIFICATE);
|
||||
|
||||
REGISTER_CURL_CONSTANT(CURL_NETRC_OPTIONAL);
|
||||
REGISTER_CURL_CONSTANT(CURL_NETRC_IGNORED);
|
||||
REGISTER_CURL_CONSTANT(CURL_NETRC_REQUIRED);
|
||||
|
||||
REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_NONE);
|
||||
REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_1_0);
|
||||
REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_1_1);
|
||||
|
||||
|
||||
if (curl_global_init(CURL_GLOBAL_SSL) != CURLE_OK) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
#ifdef PHP_CURL_URL_WRAPPERS
|
||||
php_register_url_stream_wrapper("http", &php_curl_wrapper TSRMLS_CC);
|
||||
php_register_url_stream_wrapper("https", &php_curl_wrapper TSRMLS_CC);
|
||||
php_register_url_stream_wrapper("ftp", &php_curl_wrapper TSRMLS_CC);
|
||||
php_register_url_stream_wrapper("ldap", &php_curl_wrapper TSRMLS_CC);
|
||||
#endif
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
@@ -306,12 +268,6 @@ PHP_MINIT_FUNCTION(curl)
|
||||
*/
|
||||
PHP_MSHUTDOWN_FUNCTION(curl)
|
||||
{
|
||||
#ifdef PHP_CURL_URL_WRAPPERS
|
||||
php_unregister_url_stream_wrapper("http" TSRMLS_CC);
|
||||
php_unregister_url_stream_wrapper("https" TSRMLS_CC);
|
||||
php_unregister_url_stream_wrapper("ftp" TSRMLS_CC);
|
||||
php_unregister_url_stream_wrapper("ldap" TSRMLS_CC);
|
||||
#endif
|
||||
curl_global_cleanup();
|
||||
|
||||
return SUCCESS;
|
||||
@@ -338,7 +294,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);
|
||||
@@ -394,9 +350,7 @@ 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];
|
||||
@@ -458,7 +412,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);
|
||||
@@ -573,9 +527,8 @@ static void curl_free_slist(void **slist)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ proto array curl_version(void)
|
||||
Return cURL version information. */
|
||||
/* {{{ proto string curl_version(void)
|
||||
Return the CURL version string. */
|
||||
PHP_FUNCTION(curl_version)
|
||||
{
|
||||
if (ZEND_NUM_ARGS() != 0) {
|
||||
@@ -632,8 +585,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);
|
||||
@@ -695,7 +646,6 @@ PHP_FUNCTION(curl_setopt)
|
||||
case CURLOPT_PUT:
|
||||
case CURLOPT_MUTE:
|
||||
case CURLOPT_TIMEOUT:
|
||||
case CURLOPT_FTP_USE_EPSV:
|
||||
case CURLOPT_LOW_SPEED_LIMIT:
|
||||
case CURLOPT_SSLVERSION:
|
||||
case CURLOPT_LOW_SPEED_TIME:
|
||||
@@ -714,9 +664,6 @@ PHP_FUNCTION(curl_setopt)
|
||||
case CURLOPT_SSL_VERIFYHOST:
|
||||
case CURLOPT_SSL_VERIFYPEER:
|
||||
case CURLOPT_DNS_USE_GLOBAL_CACHE:
|
||||
case CURLOPT_HTTPGET:
|
||||
case CURLOPT_HTTP_VERSION:
|
||||
case CURLOPT_CRLF:
|
||||
convert_to_long_ex(zvalue);
|
||||
error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue));
|
||||
break;
|
||||
@@ -729,6 +676,8 @@ PHP_FUNCTION(curl_setopt)
|
||||
case CURLOPT_USERAGENT:
|
||||
case CURLOPT_FTPPORT:
|
||||
case CURLOPT_COOKIE:
|
||||
case CURLOPT_SSLCERT:
|
||||
case CURLOPT_SSLCERTPASSWD:
|
||||
case CURLOPT_COOKIEFILE:
|
||||
case CURLOPT_REFERER:
|
||||
case CURLOPT_INTERFACE:
|
||||
@@ -736,18 +685,8 @@ PHP_FUNCTION(curl_setopt)
|
||||
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_SSLCERT:
|
||||
case CURLOPT_SSLKEYTYPE:
|
||||
case CURLOPT_SSLKEYPASSWD:
|
||||
case CURLOPT_SSLENGINE:
|
||||
#ifdef CURLOPT_ENCODING
|
||||
case CURLOPT_ENCODING:
|
||||
#endif
|
||||
case CURLOPT_SSLENGINE_DEFAULT: {
|
||||
case CURLOPT_SSL_CIPHER_LIST: {
|
||||
char *copystr = NULL;
|
||||
|
||||
convert_to_string_ex(zvalue);
|
||||
@@ -817,33 +756,21 @@ PHP_FUNCTION(curl_setopt)
|
||||
}
|
||||
break;
|
||||
case CURLOPT_WRITEFUNCTION:
|
||||
if (ch->handlers->write->func) {
|
||||
zval_ptr_dtor(&ch->handlers->write->func);
|
||||
}
|
||||
zval_add_ref(zvalue);
|
||||
ch->handlers->write->func = *zvalue;
|
||||
ch->handlers->write->method = PHP_CURL_USER;
|
||||
break;
|
||||
case CURLOPT_READFUNCTION:
|
||||
if (ch->handlers->read->func) {
|
||||
zval_ptr_dtor(&ch->handlers->read->func);
|
||||
}
|
||||
zval_add_ref(zvalue);
|
||||
ch->handlers->read->func = *zvalue;
|
||||
ch->handlers->read->method = PHP_CURL_USER;
|
||||
break;
|
||||
case CURLOPT_HEADERFUNCTION:
|
||||
if (ch->handlers->write_header->func) {
|
||||
zval_ptr_dtor(&ch->handlers->write_header->func);
|
||||
}
|
||||
zval_add_ref(zvalue);
|
||||
ch->handlers->write_header->func = *zvalue;
|
||||
ch->handlers->write_header->method = PHP_CURL_USER;
|
||||
break;
|
||||
case CURLOPT_PASSWDFUNCTION:
|
||||
if (ch->handlers->passwd) {
|
||||
zval_ptr_dtor(&ch->handlers->passwd);
|
||||
}
|
||||
zval_add_ref(zvalue);
|
||||
ch->handlers->passwd = *zvalue;
|
||||
error = curl_easy_setopt(ch->cp, CURLOPT_PASSWDFUNCTION, curl_passwd);
|
||||
@@ -869,15 +796,13 @@ PHP_FUNCTION(curl_setopt)
|
||||
}
|
||||
|
||||
for (zend_hash_internal_pointer_reset(postfields);
|
||||
zend_hash_get_current_data(postfields,
|
||||
(void **) ¤t) == SUCCESS;
|
||||
zend_hash_get_current_data(postfields, (void **) ¤t) == SUCCESS;
|
||||
zend_hash_move_forward(postfields)) {
|
||||
|
||||
SEPARATE_ZVAL(current);
|
||||
convert_to_string_ex(current);
|
||||
|
||||
zend_hash_get_current_key_ex(postfields,
|
||||
&string_key, &string_key_len, &num_key, 0, NULL);
|
||||
zend_hash_get_current_key_ex(postfields, &string_key, &string_key_len, &num_key, 0, NULL);
|
||||
|
||||
postval = Z_STRVAL_PP(current);
|
||||
if (*postval == '@') {
|
||||
@@ -944,8 +869,7 @@ PHP_FUNCTION(curl_setopt)
|
||||
slist = curl_slist_append(slist, indiv);
|
||||
if (! slist) {
|
||||
efree(indiv);
|
||||
php_error(E_WARNING, "%s(): Couldn't build curl_slist",
|
||||
get_active_function_name(TSRMLS_C));
|
||||
php_error(E_WARNING, "%s(): Couldn't build curl_slist", get_active_function_name(TSRMLS_C));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
zend_llist_add_element(&ch->to_free.str, &indiv);
|
||||
@@ -967,24 +891,6 @@ PHP_FUNCTION(curl_setopt)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ cleanup_handle(ch)
|
||||
Cleanup an execution phase */
|
||||
static void
|
||||
cleanup_handle(php_curl *ch)
|
||||
{
|
||||
if (ch->uses < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ch->handlers->write->buf.len) {
|
||||
memset(&ch->handlers->write->buf, 0, sizeof(smart_str));
|
||||
}
|
||||
|
||||
memset(ch->err.str, 0, CURL_ERROR_SIZE + 1);
|
||||
ch->err.no = 0;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto bool curl_exec(resource ch)
|
||||
Perform a CURL session */
|
||||
PHP_FUNCTION(curl_exec)
|
||||
@@ -999,20 +905,14 @@ PHP_FUNCTION(curl_exec)
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
|
||||
|
||||
cleanup_handle(ch);
|
||||
|
||||
error = curl_easy_perform(ch->cp);
|
||||
SAVE_CURL_ERROR(ch, error);
|
||||
if (error != CURLE_OK) {
|
||||
if (ch->handlers->write->buf.len > 0) {
|
||||
if (ch->handlers->write->buf.len > 0)
|
||||
smart_str_free(&ch->handlers->write->buf);
|
||||
}
|
||||
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ch->uses++;
|
||||
|
||||
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);
|
||||
@@ -1023,6 +923,10 @@ PHP_FUNCTION(curl_exec)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
#define CAAL(s, v) add_assoc_long_ex(return_value, s, sizeof(s), v);
|
||||
#define CAAD(s, v) add_assoc_double_ex(return_value, s, sizeof(s), v);
|
||||
#define CAAS(s, v) add_assoc_string_ex(return_value, s, sizeof(s), v, 1);
|
||||
|
||||
/* {{{ proto string curl_getinfo(resource ch, int opt)
|
||||
Get information regarding a specific transfer */
|
||||
PHP_FUNCTION(curl_getinfo)
|
||||
@@ -1040,83 +944,52 @@ PHP_FUNCTION(curl_getinfo)
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
|
||||
|
||||
if (argc < 2) {
|
||||
char *s_code;
|
||||
char *url;
|
||||
long l_code;
|
||||
double d_code;
|
||||
|
||||
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, &url);
|
||||
CAAS("url", url);
|
||||
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_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);
|
||||
} else {
|
||||
option = Z_LVAL_PP(zoption);
|
||||
switch (option) {
|
||||
case CURLINFO_EFFECTIVE_URL:
|
||||
case CURLINFO_CONTENT_TYPE: {
|
||||
char *s_code;
|
||||
case CURLINFO_EFFECTIVE_URL: {
|
||||
char *url;
|
||||
|
||||
curl_easy_getinfo(ch->cp, option, &s_code);
|
||||
RETURN_STRING(s_code, 1);
|
||||
curl_easy_getinfo(ch->cp, option, &url);
|
||||
RETURN_STRING(url, 1);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -1124,8 +997,7 @@ PHP_FUNCTION(curl_getinfo)
|
||||
case CURLINFO_HEADER_SIZE:
|
||||
case CURLINFO_REQUEST_SIZE:
|
||||
case CURLINFO_FILETIME:
|
||||
case CURLINFO_SSL_VERIFYRESULT:
|
||||
case CURLINFO_REDIRECT_COUNT: {
|
||||
case CURLINFO_SSL_VERIFYRESULT: {
|
||||
long code;
|
||||
|
||||
curl_easy_getinfo(ch->cp, option, &code);
|
||||
@@ -1142,9 +1014,7 @@ PHP_FUNCTION(curl_getinfo)
|
||||
case CURLINFO_SPEED_DOWNLOAD:
|
||||
case CURLINFO_SPEED_UPLOAD:
|
||||
case CURLINFO_CONTENT_LENGTH_DOWNLOAD:
|
||||
case CURLINFO_CONTENT_LENGTH_UPLOAD:
|
||||
case CURLINFO_STARTTRANSFER_TIME:
|
||||
case CURLINFO_REDIRECT_TIME: {
|
||||
case CURLINFO_CONTENT_LENGTH_UPLOAD: {
|
||||
double code;
|
||||
|
||||
curl_easy_getinfo(ch->cp, option, &code);
|
||||
@@ -1220,14 +1090,10 @@ static void _php_curl_close(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||
zend_llist_clean(&ch->to_free.slist);
|
||||
zend_llist_clean(&ch->to_free.post);
|
||||
|
||||
if (ch->handlers->write->func)
|
||||
zval_ptr_dtor(&ch->handlers->write->func);
|
||||
if (ch->handlers->read->func)
|
||||
zval_ptr_dtor(&ch->handlers->read->func);
|
||||
if (ch->handlers->write_header->func)
|
||||
zval_ptr_dtor(&ch->handlers->write_header->func);
|
||||
if (ch->handlers->passwd)
|
||||
zval_ptr_dtor(&ch->handlers->passwd);
|
||||
if (ch->handlers->write->func) zval_ptr_dtor(&ch->handlers->write->func);
|
||||
if (ch->handlers->read->func) zval_ptr_dtor(&ch->handlers->read->func);
|
||||
if (ch->handlers->write_header->func) zval_ptr_dtor(&ch->handlers->write_header->func);
|
||||
if (ch->handlers->passwd) zval_ptr_dtor(&ch->handlers->passwd);
|
||||
|
||||
efree(ch->handlers->write);
|
||||
efree(ch->handlers->write_header);
|
||||
@@ -1244,6 +1110,6 @@ static void _php_curl_close(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: fdm=marker
|
||||
* vim: noet sw=4 ts=4
|
||||
* vim600: noet sw=4 ts=4 fdm=marker
|
||||
* vim<600: noet sw=4 ts=4
|
||||
*/
|
||||
@@ -1,392 +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: Wez Furlong <wez@thebrainroom.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* This file implements cURL based wrappers.
|
||||
* NOTE: If you are implementing your own streams that are intended to
|
||||
* work independently of wrappers, this is not a good example to follow!
|
||||
**/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "php.h"
|
||||
#include "php_memory_streams.h"
|
||||
|
||||
#if HAVE_CURL && defined(PHP_CURL_URL_WRAPPERS)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
#include <winsock.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/easy.h>
|
||||
|
||||
#define SMART_STR_PREALLOC 4096
|
||||
|
||||
#include "ext/standard/php_smart_str.h"
|
||||
#include "ext/standard/info.h"
|
||||
#include "ext/standard/file.h"
|
||||
#include "php_curl.h"
|
||||
|
||||
static size_t on_data_available(char *data, size_t size, size_t nmemb, void *ctx)
|
||||
{
|
||||
php_stream *stream = (php_stream*)ctx;
|
||||
php_curl_stream *curlstream = (php_curl_stream*)stream->abstract;
|
||||
size_t wrote;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
/* TODO: I'd like to deprecate this.
|
||||
* This code is here because until we start getting real data, we don't know
|
||||
* if we have had all of the headers
|
||||
* */
|
||||
if (curlstream->readbuffer.writepos == 0) {
|
||||
zval *sym;
|
||||
|
||||
MAKE_STD_ZVAL(sym);
|
||||
*sym = *curlstream->headers;
|
||||
zval_copy_ctor(sym);
|
||||
ZEND_SET_SYMBOL(EG(active_symbol_table), "http_response_header", sym);
|
||||
}
|
||||
|
||||
php_stream_seek(curlstream->readbuffer.buf, curlstream->readbuffer.writepos, SEEK_SET);
|
||||
wrote = php_stream_write(curlstream->readbuffer.buf, data, size * nmemb);
|
||||
curlstream->readbuffer.writepos = php_stream_tell(curlstream->readbuffer.buf);
|
||||
|
||||
return wrote;
|
||||
}
|
||||
|
||||
/* cURL guarantees that headers are written as complete lines, with this function
|
||||
* called once for each header */
|
||||
static size_t on_header_available(char *data, size_t size, size_t nmemb, void *ctx)
|
||||
{
|
||||
size_t length = size * nmemb;
|
||||
zval *header;
|
||||
php_stream *stream = (php_stream*)ctx;
|
||||
php_curl_stream *curlstream = (php_curl_stream*)stream->abstract;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
MAKE_STD_ZVAL(header);
|
||||
Z_STRLEN_P(header) = length;
|
||||
Z_STRVAL_P(header) = estrndup(data, length);
|
||||
if (Z_STRVAL_P(header)[length-1] == '\n') {
|
||||
Z_STRVAL_P(header)[length-1] = '\0';
|
||||
Z_STRLEN_P(header)--;
|
||||
|
||||
if (Z_STRVAL_P(header)[length-2] == '\r') {
|
||||
Z_STRVAL_P(header)[length-2] = '\0';
|
||||
Z_STRLEN_P(header)--;
|
||||
}
|
||||
}
|
||||
Z_TYPE_P(header) = IS_STRING;
|
||||
zend_hash_next_index_insert(Z_ARRVAL_P(curlstream->headers), &header, sizeof(zval *), NULL);
|
||||
|
||||
/* based on the header, we might need to trigger a notification */
|
||||
if (!strncasecmp(data, "Location: ", 10)) {
|
||||
php_stream_notify_info(stream->context, PHP_STREAM_NOTIFY_REDIRECTED, data + 10, 0);
|
||||
} else if (!strncasecmp(data, "Content-Type: ", 14)) {
|
||||
php_stream_notify_info(stream->context, PHP_STREAM_NOTIFY_MIME_TYPE_IS, data + 14, 0);
|
||||
} else if (!strncasecmp(data, "Context-Length: ", 16)) {
|
||||
php_stream_notify_file_size(stream->context, atoi(data + 16), data, 0);
|
||||
php_stream_notify_progress_init(stream->context, 0, 0);
|
||||
}
|
||||
|
||||
return length;
|
||||
|
||||
}
|
||||
|
||||
static int on_progress_avail(php_stream *stream, double dltotal, double dlnow, double ultotal, double ulnow)
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
/* our notification system only works in a single direction; we should detect which
|
||||
* direction is important and use the correct values in this call */
|
||||
php_stream_notify_progress(stream->context, dlnow, dltotal);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t php_curl_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
|
||||
{
|
||||
php_curl_stream *curlstream = (php_curl_stream*)stream->abstract;
|
||||
|
||||
if (curlstream->writebuffer.buf) {
|
||||
return php_stream_write(curlstream->writebuffer.buf, buf, count);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t php_curl_stream_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
|
||||
{
|
||||
php_curl_stream *curlstream = (php_curl_stream*)stream->abstract;
|
||||
size_t didread = 0;
|
||||
|
||||
if (buf == NULL && count == 0) {
|
||||
/* check for EOF */
|
||||
|
||||
/* if we have buffered data, then we are not at EOF */
|
||||
if (curlstream->readbuffer.writepos > 0
|
||||
&& curlstream->readbuffer.readpos < curlstream->readbuffer.writepos)
|
||||
return 0;
|
||||
|
||||
|
||||
return curlstream->pending ? 0 : EOF;
|
||||
}
|
||||
|
||||
if (curlstream->readbuffer.readpos >= curlstream->readbuffer.writepos && curlstream->pending) {
|
||||
/* we need to read some more data */
|
||||
struct timeval tv;
|
||||
|
||||
/* fire up the connection */
|
||||
if (curlstream->readbuffer.writepos == 0) {
|
||||
while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(curlstream->multi, &curlstream->pending))
|
||||
;
|
||||
}
|
||||
|
||||
do {
|
||||
/* get the descriptors from curl */
|
||||
curl_multi_fdset(curlstream->multi, &curlstream->readfds,
|
||||
&curlstream->writefds, &curlstream->excfds, &curlstream->maxfd);
|
||||
|
||||
/* if we are in blocking mode, set a timeout */
|
||||
tv.tv_usec = 0;
|
||||
tv.tv_sec = 15; /* TODO: allow this to be configured from the script */
|
||||
|
||||
/* wait for data */
|
||||
switch (select(curlstream->maxfd+1, &curlstream->readfds,
|
||||
&curlstream->writefds, &curlstream->excfds, &tv)) {
|
||||
case -1:
|
||||
/* error */
|
||||
return 0;
|
||||
case 0:
|
||||
/* no data yet: timed-out */
|
||||
return 0;
|
||||
default:
|
||||
/* fetch the data */
|
||||
do {
|
||||
curlstream->mcode = curl_multi_perform(curlstream->multi, &curlstream->pending);
|
||||
} while (curlstream->mcode == CURLM_CALL_MULTI_PERFORM);
|
||||
}
|
||||
} while(curlstream->readbuffer.readpos >= curlstream->readbuffer.writepos && curlstream->pending > 0);
|
||||
|
||||
}
|
||||
|
||||
/* if there is data in the buffer, try and read it */
|
||||
if (curlstream->readbuffer.writepos > 0 && curlstream->readbuffer.readpos < curlstream->readbuffer.writepos) {
|
||||
php_stream_seek(curlstream->readbuffer.buf, curlstream->readbuffer.readpos, SEEK_SET);
|
||||
didread = php_stream_read(curlstream->readbuffer.buf, buf, count);
|
||||
curlstream->readbuffer.readpos = php_stream_tell(curlstream->readbuffer.buf);
|
||||
|
||||
}
|
||||
return didread;
|
||||
}
|
||||
|
||||
static int php_curl_stream_close(php_stream *stream, int close_handle TSRMLS_DC)
|
||||
{
|
||||
php_curl_stream *curlstream = (php_curl_stream*)stream->abstract;
|
||||
|
||||
/* TODO: respect the close_handle flag here, so that casting to a FILE* on
|
||||
* systems without fopencookie will work properly */
|
||||
|
||||
curl_multi_remove_handle(curlstream->multi, curlstream->curl);
|
||||
curl_easy_cleanup(curlstream->curl);
|
||||
curl_multi_cleanup(curlstream->multi);
|
||||
|
||||
/* we are not closing curlstream->readbuf here, because we export
|
||||
* it as a zval with the wrapperdata - the engine will garbage collect it */
|
||||
|
||||
efree(curlstream->url);
|
||||
efree(curlstream);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int php_curl_stream_flush(php_stream *stream TSRMLS_DC)
|
||||
{
|
||||
php_curl_stream *curlstream = (php_curl_stream*)stream->abstract;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int php_curl_stream_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC)
|
||||
{
|
||||
/* TODO: fill in details based on Data: and Content-Length: headers, and/or data
|
||||
* from curl_easy_getinfo().
|
||||
* For now, return -1 to indicate that it doesn't make sense to stat this stream */
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int php_curl_stream_cast(php_stream *stream, int castas, void **ret TSRMLS_DC)
|
||||
{
|
||||
php_curl_stream *curlstream = (php_curl_stream*)stream->abstract;
|
||||
/* delegate to the readbuffer stream */
|
||||
return php_stream_cast(curlstream->readbuffer.buf, castas, ret, 0);
|
||||
}
|
||||
|
||||
PHPAPI php_stream_ops php_curl_stream_ops = {
|
||||
php_curl_stream_write,
|
||||
php_curl_stream_read,
|
||||
php_curl_stream_close,
|
||||
php_curl_stream_flush,
|
||||
"cURL",
|
||||
NULL, /* seek */
|
||||
php_curl_stream_cast, /* cast */
|
||||
php_curl_stream_stat /* stat */
|
||||
};
|
||||
|
||||
|
||||
PHPAPI php_stream *php_curl_stream_opener(php_stream_wrapper *wrapper, char *filename, char *mode,
|
||||
int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
php_stream *stream;
|
||||
php_curl_stream *curlstream;
|
||||
zval *tmp;
|
||||
|
||||
curlstream = emalloc(sizeof(php_curl_stream));
|
||||
memset(curlstream, 0, sizeof(php_curl_stream));
|
||||
|
||||
stream = php_stream_alloc(&php_curl_stream_ops, curlstream, 0, mode);
|
||||
php_stream_context_set(stream, context);
|
||||
|
||||
curlstream->curl = curl_easy_init();
|
||||
curlstream->multi = curl_multi_init();
|
||||
curlstream->pending = 1;
|
||||
|
||||
/* if opening for an include statement, ensure that the local storage will
|
||||
* have a FILE* associated with it.
|
||||
* Otherwise, use the "smart" memory stream that will turn itself into a file
|
||||
* when it gets large */
|
||||
#if !HAVE_FOPENCOOKIE
|
||||
if (options & STREAM_WILL_CAST) {
|
||||
curlstream->readbuffer.buf = php_stream_fopen_tmpfile();
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
curlstream->readbuffer.buf = php_stream_temp_new();
|
||||
}
|
||||
|
||||
/* curl requires the URL to be valid throughout it's operation, so dup it */
|
||||
curlstream->url = estrdup(filename);
|
||||
curl_easy_setopt(curlstream->curl, CURLOPT_URL, curlstream->url);
|
||||
|
||||
/* feed curl data into our read buffer */
|
||||
curl_easy_setopt(curlstream->curl, CURLOPT_WRITEFUNCTION, on_data_available);
|
||||
curl_easy_setopt(curlstream->curl, CURLOPT_FILE, stream);
|
||||
|
||||
/* feed headers */
|
||||
curl_easy_setopt(curlstream->curl, CURLOPT_HEADERFUNCTION, on_header_available);
|
||||
curl_easy_setopt(curlstream->curl, CURLOPT_WRITEHEADER, stream);
|
||||
|
||||
/* currently buggy (bug is in curl) */
|
||||
curl_easy_setopt(curlstream->curl, CURLOPT_FOLLOWLOCATION, 1);
|
||||
|
||||
curl_easy_setopt(curlstream->curl, CURLOPT_ERRORBUFFER, curlstream->errstr);
|
||||
curl_easy_setopt(curlstream->curl, CURLOPT_VERBOSE, 0);
|
||||
|
||||
/* enable progress notification */
|
||||
curl_easy_setopt(curlstream->curl, CURLOPT_PROGRESSFUNCTION, on_progress_avail);
|
||||
curl_easy_setopt(curlstream->curl, CURLOPT_PROGRESSDATA, stream);
|
||||
curl_easy_setopt(curlstream->curl, CURLOPT_NOPROGRESS, 0);
|
||||
|
||||
curl_easy_setopt(curlstream->curl, CURLOPT_USERAGENT, "PHP/" PHP_VERSION);
|
||||
|
||||
/* TODO: read cookies and options from context */
|
||||
|
||||
/* prepare for "pull" mode */
|
||||
curl_multi_add_handle(curlstream->multi, curlstream->curl);
|
||||
|
||||
/* Prepare stuff for file_get_wrapper_data: the data is an array:
|
||||
*
|
||||
* data = array(
|
||||
* "headers" => array("Content-Type: text/html", "Xxx: Yyy"),
|
||||
* "readbuf" => resource (equivalent to curlstream->readbuffer)
|
||||
* );
|
||||
* */
|
||||
MAKE_STD_ZVAL(stream->wrapperdata);
|
||||
array_init(stream->wrapperdata);
|
||||
|
||||
MAKE_STD_ZVAL(curlstream->headers);
|
||||
array_init(curlstream->headers);
|
||||
|
||||
add_assoc_zval(stream->wrapperdata, "headers", curlstream->headers);
|
||||
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
php_stream_to_zval(curlstream->readbuffer.buf, tmp);
|
||||
add_assoc_zval(stream->wrapperdata, "readbuf", tmp);
|
||||
|
||||
#if !HAVE_FOPENCOOKIE
|
||||
if (options & STREAM_WILL_CAST) {
|
||||
/* we will need to download the whole resource now,
|
||||
* since we cannot get the actual FD for the download,
|
||||
* so we won't be able to drive curl via stdio. */
|
||||
|
||||
/* TODO: this needs finishing */
|
||||
|
||||
curl_easy_perform(curlstream->curl);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* fire up the connection; we need to detect a connection error here,
|
||||
* otherwise the curlstream we return ends up doing nothing useful. */
|
||||
CURLMcode m;
|
||||
|
||||
while (CURLM_CALL_MULTI_PERFORM ==
|
||||
(m = curl_multi_perform(curlstream->multi, &curlstream->pending))
|
||||
) {
|
||||
; /* spin */
|
||||
}
|
||||
|
||||
if (m != CURLM_OK) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "There was an error mcode=%d", m);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
static php_stream_wrapper_ops php_curl_wrapper_ops = {
|
||||
php_curl_stream_opener,
|
||||
NULL, /* stream_close: curl streams know how to clean themselves up */
|
||||
NULL, /* stream_stat: curl streams know how to stat themselves */
|
||||
NULL, /* stat url */
|
||||
NULL /* opendir */
|
||||
};
|
||||
|
||||
php_stream_wrapper php_curl_wrapper = {
|
||||
&php_curl_wrapper_ops,
|
||||
NULL,
|
||||
1 /* is_url */
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: noet sw=4 ts=4 fdm=marker
|
||||
* vim<600: noet sw=4 ts=4
|
||||
*/
|
||||
+1
-34
@@ -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 |
|
||||
@@ -13,7 +13,6 @@
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Sterling Hughes <sterling@php.net> |
|
||||
| Wez Furlong <wez@thebrainroom.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
@@ -92,40 +91,8 @@ typedef struct {
|
||||
struct _php_curl_error err;
|
||||
struct _php_curl_free to_free;
|
||||
long id;
|
||||
unsigned int uses;
|
||||
} php_curl;
|
||||
|
||||
/* streams support */
|
||||
|
||||
PHPAPI extern php_stream_ops php_curl_stream_ops;
|
||||
#define PHP_STREAM_IS_CURL &php_curl_stream_ops
|
||||
|
||||
PHPAPI php_stream *php_curl_stream_opener(php_stream_wrapper *wrapper, char *filename, char *mode,
|
||||
int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
|
||||
|
||||
extern php_stream_wrapper php_curl_wrapper;
|
||||
|
||||
struct php_curl_buffer {
|
||||
off_t readpos, writepos;
|
||||
php_stream *buf;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
CURL *curl;
|
||||
CURLM *multi;
|
||||
char *url;
|
||||
struct php_curl_buffer readbuffer; /* holds downloaded data */
|
||||
struct php_curl_buffer writebuffer; /* holds data to upload */
|
||||
|
||||
fd_set readfds, writefds, excfds;
|
||||
int maxfd;
|
||||
|
||||
char errstr[CURL_ERROR_SIZE + 1];
|
||||
CURLMcode mcode;
|
||||
int pending;
|
||||
zval *headers;
|
||||
} php_curl_stream;
|
||||
|
||||
|
||||
#else
|
||||
#define curl_module_ptr NULL
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
CyberCash
|
||||
Evan Klinger
|
||||
@@ -0,0 +1,29 @@
|
||||
dnl
|
||||
dnl $Id$
|
||||
dnl
|
||||
|
||||
AC_MSG_CHECKING(for CyberCash support)
|
||||
AC_ARG_WITH(cybercash,
|
||||
[ --with-cybercash[=DIR] Include CyberCash support. DIR is the CyberCash MCK
|
||||
install directory.],
|
||||
[
|
||||
if test "$withval" != "no"; then
|
||||
test -f $withval/mckcrypt.h && MCK_DIR=$withval
|
||||
test -f $withval/c-api/mckcrypt.h && MCK_DIR=$withval/c-api
|
||||
if test -n "$MCK_DIR"; then
|
||||
AC_MSG_RESULT(yes)
|
||||
PHP_NEW_EXTENSION(cybercash, cybercash.c)
|
||||
old_LIBS=$LIBS
|
||||
LIBS="$LIBS -L$MCK_DIR/lib"
|
||||
AC_CHECK_LIB(mckcrypto,base64_encode,[AC_DEFINE(HAVE_MCK,1,[ ])],
|
||||
[AC_MSG_ERROR(Please reinstall the CyberCash MCK - cannot find mckcrypto lib)])
|
||||
LIBS=$old_LIBS
|
||||
PHP_ADD_LIBRARY_WITH_PATH(mckcrypto, $MCK_DIR/lib)
|
||||
PHP_ADD_INCLUDE($MCK_DIR)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
fi
|
||||
],[
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
Loaded 100 of 1438 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user