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
+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
|
||||
|
||||
+14
-38
@@ -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?
|
||||
+20
-14
@@ -3,7 +3,7 @@ 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)
|
||||
@@ -11,12 +11,23 @@ all: $(all_targets)
|
||||
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,27 +52,22 @@ install-modules: build-modules
|
||||
|
||||
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' $(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 -o -name \*.o | xargs rm -f
|
||||
find . -name \*.la -o -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,327 +1,8 @@
|
||||
PHP 4 NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
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/cybercash
|
||||
. ext/icap
|
||||
. sapi/fastcgi
|
||||
. sapi/fhttpd
|
||||
- Moved extensions to PECL (http://pear.php.net/): (James, Derick)
|
||||
. ext/vpopmail
|
||||
. ext/cybermut
|
||||
- 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.1 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)
|
||||
- Fix 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 php.ini option "allow_webdav_methods" to allow handling of
|
||||
WebDAV http requests within PHP scripts. (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)
|
||||
@@ -336,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)
|
||||
@@ -350,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)
|
||||
@@ -372,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
|
||||
@@ -386,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)
|
||||
@@ -406,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()
|
||||
@@ -442,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)
|
||||
@@ -450,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
|
||||
@@ -467,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)
|
||||
@@ -476,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)
|
||||
@@ -569,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,9 @@ 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
|
||||
@@ -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,7 @@ ext/standard
|
||||
basename()
|
||||
dirname()
|
||||
strrpos()
|
||||
strrchr()
|
||||
strip_tags()
|
||||
|
||||
ext/wddx
|
||||
|
||||
+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
|
||||
|
||||
+62
-45
@@ -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,9 +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)
|
||||
#if !defined(TSRM_WIN32) && !defined(__BEOS__) && !defined(NETWARE)
|
||||
if (IS_ABSOLUTE_PATH(path, path_length)) {
|
||||
if (use_realpath && realpath(path, resolved_path)) {
|
||||
if (realpath(path, resolved_path)) {
|
||||
path = resolved_path;
|
||||
path_length = strlen(path);
|
||||
}
|
||||
@@ -322,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);
|
||||
}
|
||||
@@ -337,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)) {
|
||||
@@ -410,7 +411,12 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
|
||||
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';
|
||||
@@ -439,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)
|
||||
@@ -460,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);
|
||||
@@ -480,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;
|
||||
@@ -498,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;
|
||||
|
||||
@@ -521,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);
|
||||
|
||||
@@ -529,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)
|
||||
{
|
||||
@@ -554,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);
|
||||
|
||||
@@ -569,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);
|
||||
|
||||
@@ -584,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);
|
||||
|
||||
@@ -599,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;
|
||||
@@ -623,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);
|
||||
|
||||
@@ -638,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);
|
||||
@@ -660,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);
|
||||
|
||||
@@ -674,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);
|
||||
|
||||
@@ -690,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);
|
||||
|
||||
@@ -705,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);
|
||||
|
||||
@@ -719,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);
|
||||
@@ -736,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);
|
||||
|
||||
@@ -754,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);
|
||||
|
||||
@@ -764,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)
|
||||
|
||||
+6
-17
@@ -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,7 +186,7 @@ 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_lstat(path, buff TSRMLS_CC)
|
||||
#define VCWD_LSTAT(path, buff) virtual_stat(path, buff TSRMLS_CC)
|
||||
#else
|
||||
#define VCWD_LSTAT(path, buff) virtual_lstat(path, buff TSRMLS_CC)
|
||||
#endif
|
||||
@@ -204,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
|
||||
@@ -231,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)
|
||||
|
||||
+3
-6
@@ -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);
|
||||
|
||||
+4
-1
@@ -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);
|
||||
|
||||
|
||||
+194
-380
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
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
# | Sascha Schumann <sascha@schumann.cx> |
|
||||
# +----------------------------------------------------------------------+
|
||||
#
|
||||
# $Id: buildcheck.sh,v 1.21 2002-10-30 11:42:22 sas Exp $
|
||||
# $Id: buildcheck.sh,v 1.19 2002-07-21 13:09:07 sas Exp $
|
||||
#
|
||||
|
||||
echo "buildconf: checking installation..."
|
||||
|
||||
+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
|
||||
|
||||
+43
-123
@@ -27,12 +27,8 @@ 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)
|
||||
|
||||
dnl check for working sed
|
||||
PHP_PROG_SED
|
||||
|
||||
PHP_CONFIG_NICE(config.nice)
|
||||
for arg in $0 "$@"; do
|
||||
CONFIGURE_COMMAND="$CONFIGURE_COMMAND '$arg'"
|
||||
@@ -43,8 +39,8 @@ AC_CONFIG_HEADER(main/php_config.h)
|
||||
|
||||
MAJOR_VERSION=4
|
||||
MINOR_VERSION=3
|
||||
RELEASE_VERSION=1
|
||||
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
|
||||
@@ -158,12 +154,6 @@ if test "$ac_cv_c_const" = "yes" ; then
|
||||
LEX_CFLAGS="-DYY_USE_CONST"
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([flex version])
|
||||
set `echo "" | $LEX -V -v --version 2>/dev/null | grep 'version' | cut -d ' ' -f 3 | sed -e 's/\./ /g' | sed -e 's/[^0-9 ]//g'`
|
||||
if test "${1}" != "2" -o "${2}" != "5" -o "${3}" -lt "4"; then
|
||||
AC_MSG_WARN(You will need flex 2.5.4 or later if you want to regenerate Zend/PHP lexical parsers.)
|
||||
fi
|
||||
AC_MSG_RESULT(${1}.${2}.${3} (ok))
|
||||
|
||||
dnl Platform-specific compile settings.
|
||||
dnl -------------------------------------------------------------------------
|
||||
@@ -225,6 +215,7 @@ 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
|
||||
@@ -233,7 +224,10 @@ PHP_CONFIGURE_PART(Configuring SAPI modules)
|
||||
|
||||
esyscmd(./scripts/config-stubs sapi)
|
||||
|
||||
dnl Show which main SAPI was selected
|
||||
if test "$PHP_SAPI" = "default"; then
|
||||
PHP_SELECT_SAPI(cgi, program, cgi_main.c getopt.c)
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for chosen SAPI module])
|
||||
AC_MSG_RESULT([$PHP_SAPI])
|
||||
|
||||
@@ -242,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)
|
||||
|
||||
@@ -290,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.
|
||||
@@ -337,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 \
|
||||
@@ -365,7 +349,6 @@ unistd.h \
|
||||
unix.h \
|
||||
utime.h \
|
||||
sys/utsname.h \
|
||||
sys/ipc.h \
|
||||
],[],[],[
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
@@ -381,7 +364,7 @@ sys/ipc.h \
|
||||
#endif
|
||||
])
|
||||
|
||||
PHP_FOPENCOOKIE
|
||||
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
dnl -------------------------------------------------------------------------
|
||||
@@ -421,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,8 +427,6 @@ ctime_r \
|
||||
cuserid \
|
||||
crypt \
|
||||
flock \
|
||||
ftok \
|
||||
funopen \
|
||||
gai_strerror \
|
||||
gcvt \
|
||||
getlogin \
|
||||
@@ -472,7 +447,6 @@ memmove \
|
||||
mkstemp \
|
||||
mmap \
|
||||
nl_langinfo \
|
||||
poll \
|
||||
putenv \
|
||||
realpath \
|
||||
random \
|
||||
@@ -521,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
|
||||
@@ -559,7 +532,7 @@ dnl -------------------------------------------------------------------------
|
||||
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
|
||||
@@ -571,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)
|
||||
@@ -585,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
|
||||
@@ -598,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
|
||||
@@ -611,7 +578,7 @@ fi
|
||||
|
||||
PHP_ARG_WITH(pear, [whether to install PEAR, and where],
|
||||
[ --with-pear=DIR Install PEAR in DIR (default PREFIX/lib/php)
|
||||
--without-pear Do not install PEAR], DEFAULT, no)
|
||||
--without-pear Do not install PEAR], DEFAULT)
|
||||
|
||||
if test "$PHP_PEAR" != "no" && test "$disable_cli" != "1"; then
|
||||
install_pear="install-pear install-build install-headers install-programs"
|
||||
@@ -628,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,[ ])
|
||||
@@ -658,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, [ ])
|
||||
@@ -668,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, [ ])
|
||||
@@ -678,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)
|
||||
@@ -693,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",[ ])
|
||||
@@ -701,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
|
||||
|
||||
@@ -715,37 +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
|
||||
|
||||
|
||||
dnl
|
||||
dnl OpenSSL configure
|
||||
dnl
|
||||
PHP_ARG_WITH(openssl,for OpenSSL support,
|
||||
[ --with-openssl[=DIR] Include OpenSSL support (requires OpenSSL >= 0.9.5) ])
|
||||
|
||||
if test "$PHP_OPENSSL" != "no"; then
|
||||
ext_openssl_shared=$ext_shared
|
||||
PHP_SETUP_OPENSSL
|
||||
fi
|
||||
|
||||
|
||||
AC_CHECK_LIB(crypt, crypt, [
|
||||
PHP_ADD_LIBRARY(crypt)
|
||||
PHP_ADD_LIBRARY(crypt, 1)
|
||||
AC_DEFINE(HAVE_CRYPT,1,[ ])
|
||||
])
|
||||
|
||||
|
||||
|
||||
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 -------------------------------------------------------------------------
|
||||
|
||||
@@ -763,17 +723,6 @@ 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.
|
||||
--enable-all Enable all extensions.
|
||||
], [
|
||||
PHP_ENABLE_ALL=$enableval
|
||||
])
|
||||
|
||||
# reading config stubs
|
||||
esyscmd(./scripts/config-stubs ext)
|
||||
|
||||
@@ -828,7 +777,6 @@ dnl -------------------------------------------------------------------------
|
||||
|
||||
PHP_CONFIGURE_PART(Configuring Zend)
|
||||
LIBZEND_BASIC_CHECKS
|
||||
LIBZEND_DLSYM_CHECK
|
||||
LIBZEND_OTHER_CHECKS
|
||||
|
||||
TSRM_LIB='TSRM/libtsrm.la'
|
||||
@@ -925,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
|
||||
@@ -941,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"
|
||||
|
||||
@@ -964,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
|
||||
@@ -1008,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)
|
||||
@@ -1037,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)
|
||||
|
||||
@@ -1081,11 +1020,7 @@ 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"
|
||||
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)
|
||||
|
||||
@@ -1138,8 +1073,6 @@ 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
|
||||
ALL_OUTPUT_FILES="php4.spec main/build-defs.h \
|
||||
pear/scripts/phpize pear/scripts/php-config \
|
||||
@@ -1194,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 "| |"
|
||||
@@ -1245,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 databse 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
|
||||
+--------------------------------------------------------------------+
|
||||
@@ -1316,10 +1238,8 @@ cat<<X
|
||||
| avoid using it if possible. |
|
||||
+--------------------------------------------------------------------+
|
||||
|
||||
X
|
||||
PHP_CONFIGURE_PART(Thank you for using PHP.)
|
||||
cat<<X
|
||||
|
||||
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,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
@@ -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 */
|
||||
+67
-63
@@ -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;
|
||||
}
|
||||
@@ -97,7 +101,7 @@ PHP_RINIT_FUNCTION(bcmath)
|
||||
bc_precision=0;
|
||||
}
|
||||
|
||||
bc_init_numbers(TSRMLS_C);
|
||||
bc_init_numbers();
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -137,11 +141,11 @@ 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);
|
||||
bc_str2num(&first, Z_STRVAL_PP(left), scale TSRMLS_CC);
|
||||
bc_str2num(&second, Z_STRVAL_PP(right), 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);
|
||||
bc_add (first, second, &result, scale);
|
||||
Z_STRVAL_P(return_value) = bc_num2str(result);
|
||||
Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
|
||||
@@ -180,11 +184,11 @@ 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);
|
||||
bc_str2num(&first, Z_STRVAL_PP(left), scale TSRMLS_CC);
|
||||
bc_str2num(&second, Z_STRVAL_PP(right), 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);
|
||||
bc_sub (first, second, &result, scale);
|
||||
Z_STRVAL_P(return_value) = bc_num2str(result);
|
||||
Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
|
||||
@@ -223,12 +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);
|
||||
bc_str2num(&first, Z_STRVAL_PP(left), scale TSRMLS_CC);
|
||||
bc_str2num(&second, Z_STRVAL_PP(right), scale TSRMLS_CC);
|
||||
bc_multiply (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);
|
||||
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;
|
||||
@@ -266,19 +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);
|
||||
bc_str2num(&first, Z_STRVAL_PP(left), scale TSRMLS_CC);
|
||||
bc_str2num(&second, Z_STRVAL_PP(right), scale 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 */
|
||||
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);
|
||||
@@ -307,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);
|
||||
@@ -356,12 +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);
|
||||
bc_str2num(&first, Z_STRVAL_PP(left), scale TSRMLS_CC);
|
||||
bc_str2num(&second, Z_STRVAL_PP(right), scale TSRMLS_CC);
|
||||
bc_raise (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);
|
||||
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;
|
||||
@@ -398,14 +402,14 @@ PHP_FUNCTION(bcsqrt)
|
||||
break;
|
||||
}
|
||||
convert_to_string_ex(left);
|
||||
bc_init_num(&result TSRMLS_CC);
|
||||
bc_str2num(&result, Z_STRVAL_PP(left), scale TSRMLS_CC);
|
||||
if (bc_sqrt (&result, scale TSRMLS_CC) != 0) {
|
||||
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;
|
||||
@@ -440,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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
--SKIP--
|
||||
<?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
|
||||
--SKIP--
|
||||
<?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
|
||||
--SKIP--
|
||||
<?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
|
||||
--SKIP--
|
||||
<?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
|
||||
--SKIP--
|
||||
<?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
|
||||
--SKIP--
|
||||
<?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
|
||||
--SKIP--
|
||||
<?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
|
||||
--SKIP--
|
||||
<?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
|
||||
--SKIP--
|
||||
<?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
|
||||
@@ -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> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
+40
-142
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -311,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
|
||||
+61
-179
@@ -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)
|
||||
@@ -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)));
|
||||
}
|
||||
@@ -731,9 +723,9 @@ PHP_FUNCTION(com_load)
|
||||
/* }}} */
|
||||
|
||||
|
||||
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;
|
||||
@@ -884,14 +876,7 @@ 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++) {
|
||||
@@ -918,62 +903,6 @@ static int do_COM_invoke(comval *obj, WORD dispflags, pval *function_name, VARIA
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/* {{{ proto mixed com_invoke_ex(int module, int invokeflags, string handler_name [, mixed arg [, mixed ...]])
|
||||
Invokes a COM module */
|
||||
PHP_FUNCTION(com_invoke_ex)
|
||||
{
|
||||
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 */
|
||||
if (Z_TYPE_P(object) == IS_OBJECT && (Z_OBJCE_P(object) == &COM_class_entry || !strcmp(Z_OBJCE_P(object)->name, "COM"))) {
|
||||
zval **tmp;
|
||||
zend_hash_index_find(Z_OBJPROP_P(object), 0, (void**)&tmp);
|
||||
ZEND_FETCH_RESOURCE(obj, comval*, tmp, -1, "comval", IS_COM);
|
||||
} else if (Z_TYPE_P(object) == IS_RESOURCE) {
|
||||
ZEND_FETCH_RESOURCE(obj, comval*, &object, -1, "comval", IS_COM);
|
||||
}
|
||||
if (obj == NULL) {
|
||||
php_error(E_WARNING, "%d is not a COM object handler", Z_LVAL_P(object));
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
ALLOC_VARIANT(var_result);
|
||||
|
||||
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 */
|
||||
@@ -1001,7 +930,7 @@ PHP_FUNCTION(com_invoke)
|
||||
convert_to_long(object);
|
||||
obj = (comval *)zend_list_find(Z_LVAL_P(object), &type);
|
||||
if (!obj || (type != IS_COM)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s is not a COM object handler", Z_STRVAL_P(function_name));
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -1010,7 +939,7 @@ PHP_FUNCTION(com_invoke)
|
||||
|
||||
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);
|
||||
|
||||
@@ -1339,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);
|
||||
@@ -1546,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);
|
||||
}
|
||||
@@ -1700,105 +1629,63 @@ static void do_COM_propput(pval *return_value, comval *obj, pval *arg_property,
|
||||
}
|
||||
|
||||
|
||||
/* {{{ 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];
|
||||
|
||||
if (Z_TYPE_P(object) == IS_OBJECT && (Z_OBJCE_P(object) == &COM_class_entry || !strcmp(Z_OBJCE_P(object)->name, "COM"))) {
|
||||
zval **tmp;
|
||||
zend_hash_index_find(Z_OBJPROP_P(object), 0, (void**)&tmp);
|
||||
ZEND_FETCH_RESOURCE(obj, comval*, tmp, -1, "comval", IS_COM);
|
||||
} else if (Z_TYPE_P(object) == IS_RESOURCE) {
|
||||
ZEND_FETCH_RESOURCE(obj, comval*, &object, -1, "comval", IS_COM);
|
||||
}
|
||||
if (obj == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "parameter 1 is not a COM object handler");
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
/* obtain property/method handler */
|
||||
convert_to_string_ex(&function_name);
|
||||
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];
|
||||
|
||||
if (Z_TYPE_P(object) == IS_OBJECT && (Z_OBJCE_P(object) == &COM_class_entry || !strcmp(Z_OBJCE_P(object)->name, "COM"))) {
|
||||
zval **tmp;
|
||||
zend_hash_index_find(Z_OBJPROP_P(object), 0, (void**)&tmp);
|
||||
ZEND_FETCH_RESOURCE(obj, comval*, tmp, -1, "comval", IS_COM);
|
||||
} else if (Z_TYPE_P(object) == IS_RESOURCE) {
|
||||
ZEND_FETCH_RESOURCE(obj, comval*, &object, -1, "comval", IS_COM);
|
||||
}
|
||||
if (obj == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "parameter 1 is not a COM object handler");
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
/* obtain property/method handler */
|
||||
convert_to_string_ex(&function_name);
|
||||
|
||||
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);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -1886,24 +1773,19 @@ PHPAPI pval php_COM_get_property_handler(zend_property_reference *property_refer
|
||||
}
|
||||
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) {
|
||||
FREE_COM(obj_prop);
|
||||
|
||||
return_value = *object;
|
||||
ZVAL_ADDREF(&return_value);
|
||||
} else {
|
||||
RETVAL_COM(obj);
|
||||
return_value = *object;
|
||||
ZVAL_ADDREF(&return_value);
|
||||
} else {
|
||||
RETVAL_COM(obj);
|
||||
}
|
||||
return return_value;
|
||||
}
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
if (obj == obj_prop) {
|
||||
// not head
|
||||
pval_destructor(&overloaded_property->element);
|
||||
break;
|
||||
}
|
||||
|
||||
if (V_VT(var_result) == VT_DISPATCH) {
|
||||
@@ -1923,6 +1805,8 @@ PHPAPI pval php_COM_get_property_handler(zend_property_reference *property_refer
|
||||
FREE_COM(obj_prop);
|
||||
obj_prop = NULL;
|
||||
}
|
||||
|
||||
pval_destructor(&overloaded_property->element);
|
||||
}
|
||||
|
||||
if (obj_prop != NULL) {
|
||||
@@ -2095,7 +1979,7 @@ PHPAPI void php_COM_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_pro
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -2429,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;
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+10
-16
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
|
||||
@@ -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
-19
@@ -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
|
||||
@@ -29,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
|
||||
@@ -41,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)
|
||||
@@ -61,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
|
||||
+28
-130
@@ -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,18 +173,9 @@ 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);
|
||||
|
||||
/* Constants effecting the way CURLOPT_CLOSEPOLICY works */
|
||||
REGISTER_CURL_CONSTANT(CURLCLOSEPOLICY_LEAST_RECENTLY_USED);
|
||||
@@ -216,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);
|
||||
@@ -275,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;
|
||||
}
|
||||
/* }}} */
|
||||
@@ -303,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;
|
||||
@@ -568,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) {
|
||||
@@ -688,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:
|
||||
@@ -707,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;
|
||||
@@ -722,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:
|
||||
@@ -729,15 +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:
|
||||
case CURLOPT_SSLENGINE_DEFAULT: {
|
||||
case CURLOPT_SSL_CIPHER_LIST: {
|
||||
char *copystr = NULL;
|
||||
|
||||
convert_to_string_ex(zvalue);
|
||||
@@ -807,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);
|
||||
@@ -859,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 == '@') {
|
||||
@@ -934,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);
|
||||
@@ -957,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)
|
||||
@@ -989,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);
|
||||
@@ -1013,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)
|
||||
@@ -1030,16 +944,14 @@ 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);
|
||||
|
||||
curl_easy_getinfo(ch->cp, CURLINFO_EFFECTIVE_URL, &s_code);
|
||||
CAAS("url", s_code);
|
||||
curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_TYPE, &s_code);
|
||||
CAAS("content_type", s_code);
|
||||
curl_easy_getinfo(ch->cp, CURLINFO_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);
|
||||
@@ -1050,8 +962,6 @@ PHP_FUNCTION(curl_getinfo)
|
||||
CAAL("filetime", l_code);
|
||||
curl_easy_getinfo(ch->cp, CURLINFO_SSL_VERIFYRESULT, &l_code);
|
||||
CAAL("ssl_verify_result", l_code);
|
||||
curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_COUNT, &l_code);
|
||||
CAAL("redirect_count", l_code);
|
||||
curl_easy_getinfo(ch->cp, CURLINFO_TOTAL_TIME, &d_code);
|
||||
CAAD("total_time", d_code);
|
||||
curl_easy_getinfo(ch->cp, CURLINFO_NAMELOOKUP_TIME, &d_code);
|
||||
@@ -1072,19 +982,14 @@ PHP_FUNCTION(curl_getinfo)
|
||||
CAAD("download_content_length", d_code);
|
||||
curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_LENGTH_UPLOAD, &d_code);
|
||||
CAAD("upload_content_length", d_code);
|
||||
curl_easy_getinfo(ch->cp, CURLINFO_STARTTRANSFER_TIME, &d_code);
|
||||
CAAD("starttransfer_time", d_code);
|
||||
curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_TIME, &d_code);
|
||||
CAAD("redirect_time", d_code);
|
||||
} else {
|
||||
option = Z_LVAL_PP(zoption);
|
||||
switch (option) {
|
||||
case CURLINFO_EFFECTIVE_URL:
|
||||
case CURLINFO_CONTENT_TYPE: {
|
||||
char *s_code;
|
||||
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;
|
||||
}
|
||||
@@ -1092,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);
|
||||
@@ -1110,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);
|
||||
@@ -1188,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);
|
||||
@@ -1212,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-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: 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
|
||||
*/
|
||||
@@ -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)
|
||||
])
|
||||
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| 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: Evan Klinger <evan715@sirius.com> |
|
||||
| Timothy Whitfield <timothy@ametro.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "php.h"
|
||||
#include "ext/standard/info.h"
|
||||
#include "cybercash.h"
|
||||
|
||||
#if HAVE_MCK
|
||||
#include "mckcrypt.h"
|
||||
#include "base64.h"
|
||||
|
||||
/* {{{ cybercash_functions[]
|
||||
*/
|
||||
function_entry cybercash_functions[] = {
|
||||
PHP_FE(cybercash_encr, NULL)
|
||||
PHP_FE(cybercash_decr, NULL)
|
||||
PHP_FE(cybercash_base64_encode, NULL)
|
||||
PHP_FE(cybercash_base64_decode, NULL)
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
/* {{{ cybercash_module_entry
|
||||
*/
|
||||
zend_module_entry cybercash_module_entry = {
|
||||
STANDARD_MODULE_HEADER,
|
||||
"cybercash",
|
||||
cybercash_functions,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
PHP_MINFO(cybercash),
|
||||
NO_VERSION_YET,
|
||||
STANDARD_MODULE_PROPERTIES,
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
#ifdef COMPILE_DL_CYBERCASH
|
||||
ZEND_GET_MODULE(cybercash)
|
||||
#endif
|
||||
|
||||
/* {{{ PHP_MINFO_FUNCTION
|
||||
*/
|
||||
PHP_MINFO_FUNCTION(cybercash)
|
||||
{
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_row(2, "Cybercash Support", "enabled");
|
||||
php_info_print_table_end();
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto array cybercash_encr(string wmk, string sk, string data)
|
||||
Cybercash encrypt */
|
||||
PHP_FUNCTION(cybercash_encr)
|
||||
{
|
||||
zval **wmk, **sk, **inbuff;
|
||||
unsigned char *outbuff, *macbuff;
|
||||
unsigned int outAlloc, outLth;
|
||||
long errcode;
|
||||
|
||||
if (ZEND_NUM_ARGS() != 3 ||
|
||||
zend_get_parameters_ex(3, &wmk, &sk, &inbuff) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(wmk);
|
||||
convert_to_string_ex(sk);
|
||||
convert_to_string_ex(inbuff);
|
||||
|
||||
outAlloc = Z_STRLEN_PP(inbuff) + 10;
|
||||
|
||||
outbuff = (unsigned char *)emalloc(sizeof(unsigned char) * outAlloc);
|
||||
macbuff = (unsigned char *)emalloc(sizeof(unsigned char) * 20);
|
||||
|
||||
errcode = mck_encr(Z_STRVAL_PP(wmk),
|
||||
Z_STRVAL_PP(sk),
|
||||
Z_STRLEN_PP(inbuff) + 1,
|
||||
Z_STRVAL_PP(inbuff),
|
||||
outAlloc,
|
||||
outbuff,
|
||||
&outLth,
|
||||
macbuff);
|
||||
|
||||
if (array_init(return_value) == FAILURE) {
|
||||
php_error(E_WARNING, "%s(): Return value could not be initialized", get_active_function_name(TSRMLS_C));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
add_assoc_long(return_value, "errcode", errcode);
|
||||
|
||||
if (!errcode) {
|
||||
add_assoc_stringl(return_value, "outbuff", outbuff, outLth, 0);
|
||||
add_assoc_long(return_value,"outLth", outLth);
|
||||
add_assoc_stringl(return_value,"macbuff", macbuff, 20, 0);
|
||||
} else {
|
||||
efree(outbuff);
|
||||
efree(macbuff);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto array cybercash_decr(string wmp, string sk, string data)
|
||||
Cybercash decrypt */
|
||||
PHP_FUNCTION(cybercash_decr)
|
||||
{
|
||||
zval **wmk, **sk, **inbuff;
|
||||
unsigned char *outbuff, *macbuff;
|
||||
unsigned int outAlloc, outLth;
|
||||
long errcode;
|
||||
|
||||
|
||||
if (ZEND_NUM_ARGS() != 3 ||
|
||||
zend_get_parameters_ex(3, &wmk, &sk, &inbuff) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(wmk);
|
||||
convert_to_string_ex(sk);
|
||||
convert_to_string_ex(inbuff);
|
||||
|
||||
outAlloc = Z_STRLEN_PP(inbuff);
|
||||
|
||||
outbuff = (unsigned char *)emalloc(sizeof(unsigned char) * outAlloc);
|
||||
macbuff = (unsigned char *)emalloc(sizeof(unsigned char) * 20);
|
||||
|
||||
errcode = mck_decr(Z_STRVAL_PP(wmk),
|
||||
Z_STRVAL_PP(sk),
|
||||
Z_STRLEN_PP(inbuff),
|
||||
Z_STRVAL_PP(inbuff),
|
||||
outAlloc,
|
||||
outbuff,
|
||||
&outLth,
|
||||
macbuff);
|
||||
|
||||
if (array_init(return_value) == FAILURE) {
|
||||
php_error(E_WARNING, "%s(): Could not initialize return value", get_active_function_name(TSRMLS_C));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
add_assoc_long(return_value, "errcode", errcode);
|
||||
|
||||
if (!errcode) {
|
||||
add_assoc_stringl(return_value, "outbuff", outbuff, outLth, 0);
|
||||
add_assoc_long(return_value, "outLth", outLth);
|
||||
add_assoc_stringl(return_value, "macbuff", macbuff, 20, 0);
|
||||
} else {
|
||||
efree(outbuff);
|
||||
efree(macbuff);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string cybercash_base64_encode(string data)
|
||||
base64 encode data for cybercash */
|
||||
PHP_FUNCTION(cybercash_base64_encode)
|
||||
{
|
||||
zval **inbuff;
|
||||
char *outbuff;
|
||||
long ret_length;
|
||||
|
||||
if (ZEND_NUM_ARGS() != 1 ||
|
||||
zend_get_parameters_ex(1, &inbuff) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_string_ex(inbuff);
|
||||
|
||||
outbuff = (char *)emalloc(base64_enc_size((unsigned int)Z_STRLEN_PP(inbuff)));
|
||||
|
||||
ret_length = base64_encode(outbuff,
|
||||
Z_STRVAL_PP(inbuff),
|
||||
Z_STRLEN_PP(inbuff));
|
||||
|
||||
RETURN_STRINGL(outbuff, ret_length, 0);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string cybercash_base64_decode(string data)
|
||||
base64 decode data for cybercash */
|
||||
PHP_FUNCTION(cybercash_base64_decode)
|
||||
{
|
||||
zval **inbuff;
|
||||
char *outbuff;
|
||||
long ret_length;
|
||||
|
||||
if (ZEND_NUM_ARGS() != 1 ||
|
||||
zend_get_parameters_ex(1, &inbuff) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_string_ex(inbuff);
|
||||
|
||||
outbuff = (char *)emalloc(base64_dec_size((unsigned int)Z_STRLEN_PP(inbuff)));
|
||||
|
||||
ret_length = base64_decode(outbuff, Z_STRVAL_PP(inbuff), Z_STRLEN_PP(inbuff));
|
||||
|
||||
RETURN_STRINGL(outbuff, ret_length, 0);
|
||||
}
|
||||
/* }}} */
|
||||
#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,110 @@
|
||||
# Microsoft Developer Studio Project File - Name="cybercash" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=cybercash - Win32 Release_TS
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "cybercash.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "cybercash.mak" CFG="cybercash - Win32 Release_TS"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "cybercash - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "cybercash - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "cybercash - Win32 Release_TS"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release_TS"
|
||||
# PROP BASE Intermediate_Dir "Release_TS"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release_TS"
|
||||
# PROP Intermediate_Dir "Release_TS"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\..\Zend" /I "..\..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL_CYBERCASH" /D ZTS=1 /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CYBERCASH_EXPORTS" /D "COMPILE_DL_CYBERCASH" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_MCK=1 /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x406 /d "NDEBUG"
|
||||
# ADD RSC /l 0x406 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib cybercashi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 php4ts.lib user32.lib winspool.lib mckcrypto.lib kernel32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /nodefaultlib:"libcmt.lib" /out:"..\..\Release_TS/php_cybercash.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline"
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "cybercash - Win32 Debug_TS"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Debug_TS"
|
||||
# PROP BASE Intermediate_Dir "Debug_TS"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Debug_TS"
|
||||
# PROP Intermediate_Dir "Debug_TS"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL_CYBERCASH" /D ZTS=1 /YX /FD /c
|
||||
# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CYBERCASH_EXPORTS" /D "COMPILE_DL_CYBERCASH" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_MCK=1 /FR /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x406 /d "NDEBUG"
|
||||
# ADD RSC /l 0x406 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib cybercashi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts_debug.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 php4ts_debug.lib user32.lib winspool.lib mckcrypto.lib kernel32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /debug /machine:I386 /nodefaultlib:"libcmt.lib" /out:"..\..\Debug_TS/php_cybercash.dll" /libpath:"..\..\Debug_TS"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "cybercash - Win32 Release_TS"
|
||||
# Name "cybercash - Win32 Debug_TS"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cybercash.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cybercash.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -12,28 +12,29 @@
|
||||
| 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: Evan Klinger <evan715@sirius.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
#ifndef CYBERCASH_H
|
||||
#define CYBERCASH_H
|
||||
|
||||
/* incorporated from D.J.Bernstein's cdb-0.75 (http://cr.yp.to/cdb.html)*/
|
||||
|
||||
#ifndef UINT32_H
|
||||
#define UINT32_H
|
||||
#if HAVE_MCK
|
||||
|
||||
extern zend_module_entry cybercash_module_entry;
|
||||
#define cybercash_module_ptr &cybercash_module_entry
|
||||
|
||||
PHP_MINFO_FUNCTION(cybercash);
|
||||
PHP_FUNCTION(cybercash_encr);
|
||||
PHP_FUNCTION(cybercash_decr);
|
||||
PHP_FUNCTION(cybercash_base64_encode);
|
||||
PHP_FUNCTION(cybercash_base64_decode);
|
||||
|
||||
#if SIZEOF_INT == 4
|
||||
/* Most 32-bit and 64-bit systems have 32-bit ints */
|
||||
typedef unsigned int uint32;
|
||||
#elif SIZEOF_LONG == 4
|
||||
/* 16-bit systems? */
|
||||
typedef unsigned long uint32;
|
||||
#else
|
||||
#error Need type which holds 32 bits
|
||||
#define cybercash_module_ptr NULL
|
||||
#endif
|
||||
|
||||
void uint32_pack(char *out, uint32 in);
|
||||
void uint32_unpack(const char *in, uint32 *out);
|
||||
#define phpext_cybercash_ptr cybercash_module_ptr
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
|
||||
/*********************************************************************
|
||||
* Cyberlib - (C) American Metrocomm Internet Services *
|
||||
* by Timothy Whitfield <timothy@ametro.net> *
|
||||
* *
|
||||
* PHP Cybercash API - This requires that CyberCash support be *
|
||||
* compiled. *
|
||||
* *
|
||||
* *
|
||||
* This is an attempt to duplicate the cybercash API for PHP *
|
||||
* users. *
|
||||
*********************************************************************
|
||||
* This does not require merchant_conf for reasons that any file *
|
||||
* can be accessed by the web server can be accessed by any cgi. *
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
function SendCC2_1Server($merchant,$merchant_key,
|
||||
$url,$operation,$CCNVList)
|
||||
{
|
||||
/* We need to make the url. */
|
||||
$url=$url."cr21api.cgi/".$operation;
|
||||
|
||||
return SendCCServer($merchant,$merchant_key,$url,$CCNVList);
|
||||
}
|
||||
|
||||
function SendCCServer($merchant,$merchant_key,$url,$CCNVList)
|
||||
{
|
||||
/* Break the url into parts. */
|
||||
$url=parse_url($url);
|
||||
|
||||
/* Turn the name value pairs into a url encoded message. */
|
||||
$pairs="";
|
||||
$done=0;
|
||||
$more=list($key,$val)=each($CCNVList);
|
||||
while(!$done)
|
||||
{
|
||||
$pairs.=rtrim($key)."=".urlencode(rtrim($val));
|
||||
|
||||
$more=list($key,$val)=each($CCNVList);
|
||||
if($more)
|
||||
{
|
||||
$pairs.="&";
|
||||
}
|
||||
else
|
||||
{
|
||||
$done=1;
|
||||
}
|
||||
}
|
||||
|
||||
$encrypted_pairs=CCEncrypt($merchant_key,$pairs);
|
||||
$pairs_length=strlen($encrypted_pairs);
|
||||
|
||||
$message=sprintf("POST %s/%s HTTP/1.0\r\n",$url["path"],$merchant);
|
||||
$message.=sprintf("User-Agent: CCMCK-%s\r\n","3.2.0.5");
|
||||
$message.="Content-type: application/x-www-form-urlencoded\r\n";
|
||||
$message.=sprintf("Content-length: %d\r\n",$pairs_length);
|
||||
$message.="\r\n";
|
||||
$message.=$encrypted_pairs."\r\n";
|
||||
|
||||
$response=CCSocketSend($merchant_key,$url["host"],isset($url["port"])?$url["port"]:"",$message);
|
||||
return $response;
|
||||
}
|
||||
|
||||
function CCEncrypt($merchant_key,$pairs)
|
||||
{
|
||||
$session_key=sprintf("%s #%ld",date("D M j H:i:s Y"),getmypid());
|
||||
$enc_msg=cybercash_encr($merchant_key,$session_key,$pairs);
|
||||
$pairs=cybercash_base64_encode($enc_msg["outbuff"]);
|
||||
$mac=cybercash_base64_encode($enc_msg["macbuff"]);
|
||||
|
||||
/* This adds the information needed to decrypt. */
|
||||
$encrypted_pairs="message=".urlencode($pairs)."&";
|
||||
$encrypted_pairs.="session-key=".urlencode($session_key)."&";
|
||||
$encrypted_pairs.="mac=".urlencode($mac);
|
||||
|
||||
|
||||
return $encrypted_pairs;
|
||||
}
|
||||
|
||||
function CCSocketSend($merchant_key,$host,$port,$message)
|
||||
{
|
||||
|
||||
if(!$port)
|
||||
{
|
||||
$port="80";
|
||||
}
|
||||
|
||||
/*This opens the port. */
|
||||
$fd=fsockopen($host,$port);
|
||||
|
||||
/* Minor error checking. */
|
||||
if(!$fd)
|
||||
{
|
||||
$vars["MStatus"]="failure-hard";
|
||||
$vars["MErrMsg"]="Error contacting credit processor.";
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
/*This sends the message. */
|
||||
fputs($fd,$message);
|
||||
|
||||
/* We read the header in and parse at the same time. */
|
||||
|
||||
/* Retrieve header. */
|
||||
$i=0;
|
||||
$response="";
|
||||
while(!feof($fd) && $response != "\n")
|
||||
{
|
||||
$response="";
|
||||
$more="";
|
||||
while(!feof($fd) && $more != "\n")
|
||||
{
|
||||
$more=fgetc($fd);
|
||||
if($more != "\n" || $response=="")
|
||||
{
|
||||
if($more != "\r")
|
||||
{
|
||||
$response.=$more;
|
||||
}
|
||||
}
|
||||
}
|
||||
$header[$i++]=$response;
|
||||
}
|
||||
|
||||
/* We will now get the message. */
|
||||
$message="";
|
||||
while(!feof($fd))
|
||||
{
|
||||
$message.=fgets($fd,50);
|
||||
}
|
||||
|
||||
/* It should be ok to close the socket now. */
|
||||
fclose($fd);
|
||||
|
||||
/* This set of variables is encoded/encrypted. */
|
||||
$vars=CCGetVars($message);
|
||||
$vars["message"]=cybercash_base64_decode($vars["message"]);
|
||||
$vars["mac"]=cybercash_base64_decode($vars["mac"]);
|
||||
|
||||
/* Check for errors with the request/decryption. */
|
||||
/* message is base64 and encrypted. */
|
||||
$dec_msg=cybercash_decr($merchant_key,$vars["session-key"],
|
||||
$vars["message"]);
|
||||
|
||||
if($dec_msg["errcode"])
|
||||
{
|
||||
$vars["MStatus"]="failure-hard";
|
||||
$vars["MErrMsg"]="Response non-decodable.";
|
||||
return $vars;
|
||||
}
|
||||
|
||||
if($dec_msg["macbuff"] != $vars["mac"])
|
||||
{
|
||||
$vars["MStatus"]="failure-hard";
|
||||
$vars["MErrMsg"]="Signitures do not match.";
|
||||
return $vars;
|
||||
}
|
||||
|
||||
/* We will have to parse again to get more info. */
|
||||
$vars=CCGetVars($dec_msg["outbuff"]);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
function CCGetVars($message)
|
||||
{
|
||||
/* Retrieve variables.
|
||||
This function retrieves variables in var/value key pairs.
|
||||
So that $myvar["var"]==value
|
||||
*/
|
||||
|
||||
/* Need to find these variables too. */
|
||||
$cx=0;
|
||||
$response="";
|
||||
$more="";
|
||||
$message.="\n";
|
||||
$msg_len=strlen($message);
|
||||
|
||||
while($cx<=$msg_len)
|
||||
{
|
||||
$more="";
|
||||
$varname="";
|
||||
$varval="";
|
||||
while($cx<=$msg_len && $more != "&" && $more != "\n")
|
||||
{
|
||||
$more=substr($message,$cx,1);
|
||||
$cx++;
|
||||
if($more != "&" && $more != "=" && $more != "\n")
|
||||
{
|
||||
$response=$response.$more;
|
||||
}
|
||||
if($more=="=")
|
||||
{
|
||||
$varname=$response;
|
||||
$response="";
|
||||
}
|
||||
if($more=="&" || $more=="\n")
|
||||
{
|
||||
$varval=$response;
|
||||
$response="";
|
||||
}
|
||||
}
|
||||
|
||||
if($varname != "")
|
||||
{
|
||||
$cybervar[$varname]=urldecode($varval);
|
||||
}
|
||||
}
|
||||
|
||||
return $cybervar;
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
require "cyberlib.php";
|
||||
|
||||
$merchant=""; /* Your merchant ID goes here. */
|
||||
$merchant_key=""; /* Your merchant key goes here. */
|
||||
$payment_url="http://cr.cybercash.com/cgi-bin/";
|
||||
$auth_type="mauthonly";
|
||||
|
||||
$response=SendCC2_1Server($merchant,$merchant_key,$payment_url,
|
||||
$auth_type,array("Order-ID" => "2342322",
|
||||
"Amount" => "usd 11.50",
|
||||
"Card-Number" => "4111111111111111",
|
||||
"Card-Address" => "1600 Pennsylvania Avenue",
|
||||
"Card-City" => "Washington",
|
||||
"Card-State" => "DC",
|
||||
"Card-Zip" => "20500",
|
||||
"Card-Country" => "USA",
|
||||
"Card-Exp" => "12/99",
|
||||
"Card-Name" => "Bill Clinton"));
|
||||
|
||||
while(list($key,$val)=each($response))
|
||||
{
|
||||
echo $key."=".$val."<br>";
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,48 @@
|
||||
dnl
|
||||
dnl $Id$
|
||||
dnl
|
||||
|
||||
PHP_ARG_WITH(cybermut, for cybermut support,
|
||||
[ --with-cybermut[=DIR] Include CyberMut (french Credit Mutuel telepaiement)])
|
||||
|
||||
if test "$PHP_CYBERMUT" != "no"; then
|
||||
for i in /usr/local /usr $PHP_CYBERMUT; do
|
||||
if test -r $i/cm-mac.h; then
|
||||
CYBERMUT_INC_DIR=$i
|
||||
elif test -r $i/include/cm-mac.h; then
|
||||
CYBERMUT_INC_DIR=$i/include
|
||||
fi
|
||||
|
||||
if test -r $i/libcm-mac.a; then
|
||||
CYBERMUT_LIB_DIR=$i
|
||||
elif test -r $i/lib/libcm-mac.a; then
|
||||
CYBERMUT_LIB_DIR=$i/lib
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$CYBERMUT_INC_DIR"; then
|
||||
AC_MSG_ERROR(Could not find cm-mac.h Please make sure you have the
|
||||
CyberMut SDK installed. Use
|
||||
./configure --with-cybermut=<cybermut-dir> if necessary)
|
||||
fi
|
||||
|
||||
if test -z "$CYBERMUT_LIB_DIR"; then
|
||||
AC_MSG_ERROR(Could not find libcm-mac.a Please make sure you have the
|
||||
CyberMut SDK installed. Use
|
||||
./configure --with-cybermut=<cybermut-dir> if necessary)
|
||||
fi
|
||||
AC_MSG_RESULT(found in $CYBERMUT_LIB_DIR)
|
||||
|
||||
AC_MSG_RESULT(linking libcm-mac.a with libcybermut.a)
|
||||
ln -sf $CYBERMUT_LIB_DIR/libcm-mac.a $CYBERMUT_LIB_DIR/libcybermut.a
|
||||
|
||||
PHP_ADD_INCLUDE($CYBERMUT_INC_DIR)
|
||||
|
||||
PHP_SUBST(CYBERMUT_SHARED_LIBADD)
|
||||
PHP_ADD_LIBRARY_WITH_PATH(cybermut, $CYBERMUT_LIB_DIR, CYBERMUT_SHARED_LIBADD)
|
||||
|
||||
AC_DEFINE(HAVE_CYBERMUT, 1, [ ])
|
||||
|
||||
|
||||
PHP_NEW_EXTENSION(cybermut, cybermut.c, $ext_shared)
|
||||
fi
|
||||
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| 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: Sylvain PAGES <spages@free.fr> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "php.h"
|
||||
#include "php_ini.h"
|
||||
#include "php_cybermut.h"
|
||||
|
||||
#include "cm-mac.h"
|
||||
|
||||
/* If you declare any globals in php_cybermut.h uncomment this:
|
||||
ZEND_DECLARE_MODULE_GLOBALS(cybermut)
|
||||
*/
|
||||
|
||||
/* True global resources - no need for thread safety here */
|
||||
static int le_cybermut;
|
||||
|
||||
/* {{{ cybermut_functions[]
|
||||
*/
|
||||
function_entry cybermut_functions[] = {
|
||||
PHP_FE(cybermut_creerformulairecm, NULL)
|
||||
PHP_FE(cybermut_testmac, NULL)
|
||||
PHP_FE(cybermut_creerreponsecm, NULL)
|
||||
{NULL, NULL, NULL} /* Must be the last line in cybermut_functions[] */
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
/* {{{ cybermut_module_entry
|
||||
*/
|
||||
zend_module_entry cybermut_module_entry = {
|
||||
STANDARD_MODULE_HEADER,
|
||||
"cybermut",
|
||||
cybermut_functions,
|
||||
PHP_MINIT(cybermut),
|
||||
PHP_MSHUTDOWN(cybermut),
|
||||
NULL,
|
||||
NULL,
|
||||
PHP_MINFO(cybermut),
|
||||
NO_VERSION_YET,
|
||||
STANDARD_MODULE_PROPERTIES
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
#ifdef COMPILE_DL_CYBERMUT
|
||||
ZEND_GET_MODULE(cybermut)
|
||||
#endif
|
||||
|
||||
PHP_MINIT_FUNCTION(cybermut)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
PHP_MSHUTDOWN_FUNCTION(cybermut)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/* {{{ PHP_MINFO_FUNCTION
|
||||
*/
|
||||
PHP_MINFO_FUNCTION(cybermut)
|
||||
{
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_header(2, "cybermut support", "enabled");
|
||||
php_info_print_table_end();
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string cybermut_creerformulairecm(string url_CM, string version, string TPE, string montant, string ref_commande, string texte_libre, string url_retour, string url_retour_ok, string url_retour_err, string langue, string code_societe, string texte_bouton)
|
||||
Returns a string containing source HTML of the form of request for payment. This result corresponds to the last parameter "formulaire" of the original function which was removed */
|
||||
PHP_FUNCTION(cybermut_creerformulairecm)
|
||||
{
|
||||
zval **url_CM, **version, **TPE, **montant, **ref_commande, **texte_libre, **url_retour, **url_retour_ok, **url_retour_err, **langue, **code_societe, **texte_bouton;
|
||||
|
||||
char formulaire [10000];
|
||||
|
||||
if (ZEND_NUM_ARGS() != 12 || zend_get_parameters_ex(12, &url_CM, &version, &TPE, &montant, &ref_commande, &texte_libre, &url_retour, &url_retour_ok, &url_retour_err, &langue, &code_societe, &texte_bouton) == FAILURE){
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(url_CM);
|
||||
convert_to_string_ex(version);
|
||||
convert_to_string_ex(TPE);
|
||||
convert_to_string_ex(montant);
|
||||
convert_to_string_ex(ref_commande);
|
||||
convert_to_string_ex(texte_libre);
|
||||
convert_to_string_ex(url_retour);
|
||||
convert_to_string_ex(url_retour_ok);
|
||||
convert_to_string_ex(url_retour_err);
|
||||
convert_to_string_ex(langue);
|
||||
convert_to_string_ex(code_societe);
|
||||
convert_to_string_ex(texte_bouton);
|
||||
|
||||
CreerFormulaireCM ( Z_STRVAL_PP(url_CM), Z_STRVAL_PP(version), Z_STRVAL_PP(TPE), Z_STRVAL_PP(montant), Z_STRVAL_PP(ref_commande), Z_STRVAL_PP(texte_libre), Z_STRVAL_PP(url_retour), Z_STRVAL_PP(url_retour_ok), Z_STRVAL_PP(url_retour_err), Z_STRVAL_PP(langue), Z_STRVAL_PP(code_societe), Z_STRVAL_PP(texte_bouton), formulaire);
|
||||
|
||||
|
||||
RETURN_STRING(formulaire, 1);
|
||||
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto bool cybermut_testmac(string code_MAC, string version, string TPE, string cdate, string montant, string ref_commande, string texte_libre, string code_retour)
|
||||
Returns a boolean attesting that the authentification proceeded well. TRUE if the received message is authenticated and FALSE if not */
|
||||
PHP_FUNCTION(cybermut_testmac)
|
||||
{
|
||||
zval **code_MAC, **version, **TPE, **cdate, **montant, **ref_commande, **texte_libre, **code_retour;
|
||||
int cdr_test;
|
||||
|
||||
if (ZEND_NUM_ARGS() != 8 || zend_get_parameters_ex(8, &code_MAC, &version, &TPE, &cdate, &montant, &ref_commande, &texte_libre, &code_retour) == FAILURE){
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(code_MAC);
|
||||
convert_to_string_ex(version);
|
||||
convert_to_string_ex(TPE);
|
||||
convert_to_string_ex(cdate);
|
||||
convert_to_string_ex(montant);
|
||||
convert_to_string_ex(ref_commande);
|
||||
convert_to_string_ex(texte_libre);
|
||||
convert_to_string_ex(code_retour);
|
||||
|
||||
cdr_test = TestMAC ( Z_STRVAL_PP(code_MAC), Z_STRVAL_PP(version), Z_STRVAL_PP(TPE), Z_STRVAL_PP(cdate), Z_STRVAL_PP(montant), Z_STRVAL_PP(ref_commande), Z_STRVAL_PP(texte_libre), Z_STRVAL_PP(code_retour));
|
||||
|
||||
if (cdr_test == 1) {
|
||||
RETURN_TRUE;
|
||||
} else {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string cybermut_creerreponsecm(string phrase)
|
||||
Returns a string containing the message of acknowledgement of delivery (headers and body of the message). This result corresponds to the last parameter "reponse" of the original function which was removed */
|
||||
PHP_FUNCTION(cybermut_creerreponsecm)
|
||||
{
|
||||
zval **phrase;
|
||||
char buf[5000];
|
||||
|
||||
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &phrase) == FAILURE){
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(phrase);
|
||||
|
||||
CreerReponseCM( Z_STRVAL_PP(phrase), buf);
|
||||
|
||||
RETURN_STRING (buf, 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* 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,214 @@
|
||||
<reference id="ref.cybermut">
|
||||
<title>Credit Mutuel CyberMUT functions</title>
|
||||
<titleabbrev>CyberMUT</titleabbrev>
|
||||
<partintro>
|
||||
<simpara>
|
||||
This extension allows you to process credit cards transactions using Credit
|
||||
Mutuel CyberMUT system (<ulink url="http://www.creditmutuel.fr/centre_commercial/vendez_sur_internet.html">http://www.creditmutuel.fr/centre_commercial/vendez_sur_internet.html</ulink>).
|
||||
</simpara>
|
||||
<simpara>
|
||||
CynerMUT is a popular Web Payment Service in France, provided by the
|
||||
Credit Mutuel bank. If you are foreign in France, these functions will not
|
||||
be useful for you.
|
||||
</simpara>
|
||||
<simpara>
|
||||
These functions are only available if PHP has been compiled with the
|
||||
<option role="configure">--with-cybermut[=DIR]</option> option, where DIR is
|
||||
the location of libcm-mac.a and cm-mac.h. You will require the
|
||||
appropriate SDK for your platform, which may be sent to you after your
|
||||
CyberMUT's subscription (contact them via Web, or go to the nearest
|
||||
Credit Mutuel).
|
||||
</simpara>
|
||||
<simpara>
|
||||
The use of these functions is almost identical to the original functions,
|
||||
except for the parameters of return for CreerFormulaireCM and CreerReponseCM,
|
||||
which are returned directly by functions PHP, whereas they had passed in
|
||||
reference in the original functions.
|
||||
</simpara>
|
||||
<simpara>
|
||||
These functions have been added in PHP 4.0.4. ???
|
||||
</simpara>
|
||||
|
||||
<note><para>
|
||||
These functions only provide a link to CyberMUT SDK. Be sure to read the
|
||||
CynerMUT Developers Guide for full details of the required parameters.
|
||||
</para></note>
|
||||
</partintro>
|
||||
|
||||
<refentry id="function.cybermut_creerformulairecm">
|
||||
<refnamediv>
|
||||
<refname>cybermut_creerformulairecm</refname>
|
||||
<refpurpose>Generate HTML form of request for payment</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>string <function>pfpro_init</function></funcdef>
|
||||
<paramdef>string <parameter>url_CM</parameter></paramdef>
|
||||
<paramdef>string <parameter>version</parameter></paramdef>
|
||||
<paramdef>string <parameter>TPE</parameter></paramdef>
|
||||
<paramdef>string <parameter>montant</parameter></paramdef>
|
||||
<paramdef>string <parameter>ref_commande</parameter></paramdef>
|
||||
<paramdef>string <parameter>texte_libre</parameter></paramdef>
|
||||
<paramdef>string <parameter>url_retour</parameter></paramdef>
|
||||
<paramdef>string <parameter>url_retour_ok</parameter></paramdef>
|
||||
<paramdef>string <parameter>url_retour_err</parameter></paramdef>
|
||||
<paramdef>string <parameter>langue</parameter></paramdef>
|
||||
<paramdef>string <parameter>code_societe</parameter></paramdef>
|
||||
<paramdef>string <parameter>texte_bouton</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
<function>cynermut_creerformulairecm</function> is used to generate the
|
||||
HTML form of request for payment.
|
||||
</para>
|
||||
<para>
|
||||
See also <function>cybermut_testmac</function>
|
||||
<function>cybermut_creerreponsecm</function>.
|
||||
</para>
|
||||
<example>
|
||||
<title>First step of payment (equiv cgi1.c)</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
// Directory where are located the keys
|
||||
putenv("CMKEYDIR=/var/creditmut/cles");
|
||||
|
||||
// Version number
|
||||
$VERSION="1.2";
|
||||
|
||||
$retour = creditmut_creerformulairecm(
|
||||
"https://www.creditmutuel.fr/test/telepaiement/paiement.cgi",
|
||||
$VERSION,
|
||||
"1234567890",
|
||||
"300FRF",
|
||||
$REFERENCE,
|
||||
$TEXTE_LIBRE,
|
||||
$URL_RETOUR,
|
||||
$URL_RETOUR_OK,
|
||||
$URL_RETOUR_ERR,
|
||||
"francais",
|
||||
"company",
|
||||
"Paiement par carte bancaire");
|
||||
|
||||
echo $retour;
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<refentry id="function.cybermut_testmac">
|
||||
<refnamediv>
|
||||
<refname>cybermut_testmac</refname>
|
||||
<refpurpose>Make sure that there no was data diddling contained
|
||||
in the received message of confirmation </refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>bool <function>cybermut_testmac</function></funcdef>
|
||||
<paramdef>string <parameter>code_MAC</parameter></paramdef>
|
||||
<paramdef>string <parameter>version</parameter></paramdef>
|
||||
<paramdef>string <parameter>TPE</parameter></paramdef>
|
||||
<paramdef>string <parameter>cdate</parameter></paramdef>
|
||||
<paramdef>string <parameter>montant</parameter></paramdef>
|
||||
<paramdef>string <parameter>ref_commande</parameter></paramdef>
|
||||
<paramdef>string <parameter>texte_libre</parameter></paramdef>
|
||||
<paramdef>string <parameter>code-retour</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
<function>cybermut_testmac</function> is used to make sure that there was
|
||||
not data diddling contained in the received message of confirmation.
|
||||
Pay attention to parameters code-retour and texte-libre, which cannot be
|
||||
evaluated as is, because auf the dash. You must retrieve them by using:
|
||||
<programlisting role="php">
|
||||
$code_retour=$HTTP_GET_VARS["code-retour"];
|
||||
$texte_libre=$HTTP_GET_VARS["texte-libre"];
|
||||
</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
See also <function>cybermut_creerformulairecm</function>
|
||||
<function>cybermut_creerreponsecm</function>.
|
||||
</para>
|
||||
<example>
|
||||
<title>Last step of payment (equiv cgi2.c)</title>
|
||||
<programlisting role="php">
|
||||
<?php_track_vars?>
|
||||
<?php
|
||||
// Directory where are located the keys
|
||||
putenv("CMKEYDIR=/var/creditmut/cles");
|
||||
|
||||
// Version number
|
||||
$VERSION="1.2";
|
||||
|
||||
$texte_libre = $HTTP_GET_VARS["texte-libre"];
|
||||
$code_retour = $HTTP_GET_VARS["code-retour"];
|
||||
|
||||
$mac_ok = creditmut_testmac($MAC,$VERSION,$TPE,$date,$montant,$reference,$texte_libre,$code_retour);
|
||||
|
||||
if ($mac_ok) {
|
||||
|
||||
//
|
||||
// insert data processing here
|
||||
//
|
||||
//
|
||||
|
||||
$result=creditmut_creerreponsecm("OK");
|
||||
} else {
|
||||
$result=creditmut_creerreponsecm("Document Falsifie");}
|
||||
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<refentry id="function.cybermut_creerreponsecm">
|
||||
<refnamediv>
|
||||
<refname>cybermut_creerreponsecm</refname>
|
||||
<refpurpose>Generate the acknowledgement of delivery of the confirmation
|
||||
of payment</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>string <function>cybermut_creerreponsecm</function></funcdef>
|
||||
<paramdef>string <parameter>phrase</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Returns: string containing the message of aknowledgement of delivery.
|
||||
</para>
|
||||
<para>
|
||||
The parameter is "OK" if the message of confirmation of the payment
|
||||
were correctly auhentified by <function>cybermut_testmac</function>.
|
||||
Any other chain is regarded as an error message.
|
||||
</para>
|
||||
<para>
|
||||
See also <function>cybermut_creerformulairecm</function>
|
||||
<function>cybermut_testmac</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
</reference>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
-->
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| 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: Sylvain PAGES <spages@free.fr> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef PHP_CYBERMUT_H
|
||||
#define PHP_CYBERMUT_H
|
||||
|
||||
extern zend_module_entry cybermut_module_entry;
|
||||
#define phpext_cybermut_ptr &cybermut_module_entry
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
#define PHP_CYBERMUT_API __declspec(dllexport)
|
||||
#else
|
||||
#define PHP_CYBERMUT_API
|
||||
#endif
|
||||
|
||||
PHP_MINIT_FUNCTION(cybermut);
|
||||
PHP_MSHUTDOWN_FUNCTION(cybermut);
|
||||
PHP_RINIT_FUNCTION(cybermut);
|
||||
PHP_RSHUTDOWN_FUNCTION(cybermut);
|
||||
PHP_MINFO_FUNCTION(cybermut);
|
||||
|
||||
PHP_FUNCTION(confirm_cybermut_compiled); /* For testing, remove later. */
|
||||
PHP_FUNCTION(cybermut_creerformulairecm);
|
||||
PHP_FUNCTION(cybermut_testmac);
|
||||
PHP_FUNCTION(cybermut_creerreponsecm);
|
||||
|
||||
/*
|
||||
Declare any global variables you may need between the BEGIN
|
||||
and END macros here:
|
||||
|
||||
ZEND_BEGIN_MODULE_GLOBALS(cybermut)
|
||||
int global_variable;
|
||||
ZEND_END_MODULE_GLOBALS(cybermut)
|
||||
*/
|
||||
|
||||
/* In every function that needs to use variables in php_cybermut_globals,
|
||||
do call CYBERMUTLS_FETCH(); after declaring other variables used by
|
||||
that function, and always refer to them as CYBERMUTG(variable).
|
||||
You are encouraged to rename these macros something shorter, see
|
||||
examples in any other php module directory.
|
||||
*/
|
||||
|
||||
#ifdef ZTS
|
||||
#define CYBERMUTG(v) TSRMG(cybermut_globals_id, php_cybermut_globals *, v)
|
||||
#else
|
||||
#define CYBERMUTG(v) (cybermut_globals.v)
|
||||
#endif
|
||||
|
||||
#endif /* PHP_CYBERMUT_H */
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Check for cybermut presence
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("cybermut")) print "skip"; ?>
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php
|
||||
echo "cybermut extension is available";
|
||||
/*
|
||||
you can add regression tests for your extension here
|
||||
|
||||
the output of your test code has to be equal to the
|
||||
text in the --EXPECT-- section below for the tests
|
||||
to pass, differences between the output and the
|
||||
expected text are interpreted as failure
|
||||
|
||||
see php4/tests/README for further information on
|
||||
writing regression tests
|
||||
*/
|
||||
?>
|
||||
--EXPECT--
|
||||
cybermut extension is available
|
||||
+35
-71
@@ -3,81 +3,45 @@ dnl $Id$
|
||||
dnl
|
||||
|
||||
PHP_ARG_WITH(cyrus, for cyrus imap support,
|
||||
[ --with-cyrus[=dir] Include Cyrus IMAP support])
|
||||
[ --with-cyrus Include cyrus imap support])
|
||||
|
||||
if test "$PHP_CYRUS" != "no"; then
|
||||
found_cyrus=no
|
||||
found_sasl=no
|
||||
found_openssl=no
|
||||
found_cyrus=no
|
||||
found_sasl=no
|
||||
found_openssl=no
|
||||
for i in /usr /usr/local $PHP_CYRUS; do
|
||||
if test -r $i/include/cyrus/imclient.h && test "$found_cyrus" = "no"; then
|
||||
PHP_ADD_INCLUDE($i/include)
|
||||
PHP_SUBST(CYRUS_SHARED_LIBADD)
|
||||
PHP_ADD_LIBRARY_WITH_PATH(cyrus, $i/lib, CYRUS_SHARED_LIBADD)
|
||||
found_cyrus=yes
|
||||
fi
|
||||
if test -r $i/include/sasl.h && test "$found_sasl" = "no"; then
|
||||
PHP_ADD_INCLUDE($i/include)
|
||||
PHP_SUBST(SASL_SHARED_LIBADD)
|
||||
PHP_ADD_LIBRARY_WITH_PATH(sasl, $i/lib, SASL_SHARED_LIBADD)
|
||||
found_sasl=yes
|
||||
fi
|
||||
if test -r $i/include/openssl/ssl.h && test "$found_openssl" = "no" && test "$PHP_OPENSSL" = "no"; then
|
||||
PHP_SUBST(OPENSSL_SHARED_LIBADD)
|
||||
PHP_SUBST(CRYPTO_SHARED_LIBADD)
|
||||
PHP_ADD_LIBRARY_WITH_PATH(ssl, $i/lib, OPENSSL_SHARED_LIBADD)
|
||||
PHP_ADD_LIBRARY_WITH_PATH(crypto, $i/lib, CRYPTO_SHARED_LIBADD)
|
||||
found_openssl=yes
|
||||
fi
|
||||
done
|
||||
|
||||
dnl
|
||||
dnl Cyrus
|
||||
dnl
|
||||
for i in $PHP_CYRUS /usr/local /usr; do
|
||||
if test -r $i/include/cyrus/imclient.h && test "$found_cyrus" = "no"; then
|
||||
PHP_ADD_INCLUDE($i/include)
|
||||
PHP_ADD_LIBRARY_WITH_PATH(cyrus, $i/lib, CYRUS_SHARED_LIBADD)
|
||||
found_cyrus=yes
|
||||
CYRUS_INCPATH=$i/include
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
if test "$found_cyrus" = "no"; then
|
||||
AC_MSG_RESULT(not found)
|
||||
AC_MSG_ERROR(Please Re-install the cyrus distribution)
|
||||
fi
|
||||
|
||||
dnl Check that imclient_connect() accepts 4 args
|
||||
old_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS=-I$CYRUS_INCPATH
|
||||
AC_TRY_COMPILE([#include <stdio.h>
|
||||
#include <cyrus/imclient.h>], [imclient_connect(0,0,0,0)], [], [
|
||||
AC_MSG_ERROR(cyrus-imap version 2.0.8 or greater required)
|
||||
])
|
||||
CPPFLAGS=$old_CPPFLAGS
|
||||
|
||||
if test "$found_cyrus" = "no"; then
|
||||
AC_MSG_RESULT(not found)
|
||||
AC_MSG_ERROR(Please Re-install the cyrus distribution)
|
||||
fi
|
||||
if test "$found_sasl" = "no"; then
|
||||
AC_MSG_RESULT(sasl not found)
|
||||
AC_MSG_ERROR(Please Re-install the cyrus distribution)
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl sasl/sasl2
|
||||
dnl
|
||||
for i in $PHP_CYRUS /usr/local /usr; do
|
||||
if test -r $i/include/sasl.h && test "$found_sasl" = "no"; then
|
||||
PHP_ADD_INCLUDE($i/include)
|
||||
found_sasl=yes
|
||||
elif test -r $i/include/sasl/sasl.h && test "$found_sasl" = "no"; then
|
||||
PHP_ADD_INCLUDE($i/include/sasl)
|
||||
found_sasl=yes
|
||||
fi
|
||||
AC_DEFINE(HAVE_CYRUS,1,[ ])
|
||||
|
||||
if test "$found_sasl" = "yes"; then
|
||||
if test -f $i/lib/libsasl2.a || test -f $i/lib/libsasl2.$SHLIB_SUFFIX_NAME; then
|
||||
PHP_ADD_LIBRARY_WITH_PATH(sasl2, $i/lib, CYRUS_SHARED_LIBADD)
|
||||
else
|
||||
PHP_ADD_LIBRARY_WITH_PATH(sasl, $i/lib, CYRUS_SHARED_LIBADD)
|
||||
fi
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
|
||||
if test "$found_sasl" = "no"; then
|
||||
AC_MSG_RESULT(sasl not found)
|
||||
AC_MSG_ERROR(Please Re-install the cyrus distribution)
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl OpenSSL
|
||||
dnl
|
||||
if test "$PHP_OPENSSL" = "no"; then
|
||||
for i in $PHP_CYRUS /usr/local /usr; do
|
||||
if test -r $i/include/openssl/ssl.h; then
|
||||
PHP_ADD_LIBRARY_WITH_PATH(ssl, $i/lib, CYRUS_SHARED_LIBADD)
|
||||
PHP_ADD_LIBRARY_WITH_PATH(crypto, $i/lib, CYRUS_SHARED_LIBADD)
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
PHP_NEW_EXTENSION(cyrus, cyrus.c, $ext_shared)
|
||||
PHP_SUBST(CYRUS_SHARED_LIBADD)
|
||||
AC_DEFINE(HAVE_CYRUS,1,[ ])
|
||||
PHP_NEW_EXTENSION(cyrus, cyrus.c, $ext_shared)
|
||||
fi
|
||||
+1
-1
@@ -102,7 +102,7 @@ PHP_MINIT_FUNCTION(cyrus)
|
||||
PHP_MINFO_FUNCTION(cyrus)
|
||||
{
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_row(2, "Cyrus IMAP support", "enabled");
|
||||
php_info_print_table_header(2, "Cyrus IMAP support", "enabled");
|
||||
php_info_print_table_end();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ AC_DEFUN(AC_PREFERRED_DB_LIB,[
|
||||
|
||||
|
||||
PHP_ARG_WITH(db, for xDBM support,
|
||||
[ --with-db Include old xDBM support (deprecated use --with-dba)])
|
||||
[ --with-db Include old xDBM support (deprecated)])
|
||||
|
||||
if test "$PHP_DB" != "no"; then
|
||||
|
||||
|
||||
+84
-85
@@ -38,9 +38,15 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_FILE_H
|
||||
#ifdef PHP_31
|
||||
#include "os/nt/flock.h"
|
||||
#else
|
||||
#ifdef PHP_WIN32
|
||||
#include "win32/flock.h"
|
||||
#else
|
||||
#include <sys/file.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
@@ -160,8 +166,8 @@ dbm_info *php_find_dbm(pval *id TSRMLS_DC)
|
||||
int info_type;
|
||||
|
||||
if (Z_TYPE_P(id) == IS_STRING) {
|
||||
numitems = zend_hash_next_free_element(&EG(regular_list));
|
||||
for (i=1; i<numitems; i++) {
|
||||
numitems = zend_hash_num_elements(&EG(regular_list));
|
||||
for (i=1; i<=numitems; i++) {
|
||||
if (zend_hash_index_find(&EG(regular_list), i, (void **) &le)==FAILURE) {
|
||||
continue;
|
||||
}
|
||||
@@ -183,39 +189,6 @@ dbm_info *php_find_dbm(pval *id TSRMLS_DC)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto array dblist(void)
|
||||
Return an associative array id->filename */
|
||||
#if HELLY_0
|
||||
/* New function not needed yet */
|
||||
PHP_FUNCTION(db_id_list)
|
||||
{
|
||||
ulong numitems, i;
|
||||
zend_rsrc_list_entry *le;
|
||||
dbm_info *info;
|
||||
|
||||
if (ZEND_NUM_ARGS()!=0) {
|
||||
ZEND_WRONG_PARAM_COUNT();
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (array_init(return_value) == FAILURE) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to initialize array");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
numitems = zend_hash_next_free_element(&EG(regular_list));
|
||||
for (i=1; i<numitems; i++) {
|
||||
if (zend_hash_index_find(&EG(regular_list), i, (void **) &le)==FAILURE) {
|
||||
continue;
|
||||
}
|
||||
if (Z_TYPE_P(le) == le_db) {
|
||||
info = (dbm_info *)(le->ptr);
|
||||
add_next_index_string(return_value, info->filename, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
|
||||
/* {{{ php_get_info_db
|
||||
*/
|
||||
static char *php_get_info_db(void)
|
||||
@@ -322,7 +295,7 @@ dbm_info *php_dbm_open(char *filename, char *mode TSRMLS_DC)
|
||||
DBM_MODE_TYPE imode;
|
||||
|
||||
if (filename == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "NULL filename passed");
|
||||
php_error(E_WARNING, "%s(): NULL filename passed", get_active_function_name(TSRMLS_C));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -368,7 +341,7 @@ dbm_info *php_dbm_open(char *filename, char *mode TSRMLS_DC)
|
||||
lockfd = open(lockfn, O_RDWR|O_CREAT, 0644);
|
||||
close(lockfd);
|
||||
} else {
|
||||
php_error_docref1(NULL TSRMLS_CC, filename, E_WARNING, "File appears to be locked [%s]", lockfn);
|
||||
php_error(E_WARNING, "%s(): File appears to be locked [%s]", get_active_function_name(TSRMLS_C), lockfn);
|
||||
return -1;
|
||||
}
|
||||
#else /* NFS_HACK */
|
||||
@@ -379,7 +352,7 @@ dbm_info *php_dbm_open(char *filename, char *mode TSRMLS_DC)
|
||||
flock(lockfd, LOCK_EX);
|
||||
close(lockfd);
|
||||
} else {
|
||||
php_error_docref1(NULL TSRMLS_CC, filename, E_WARNING, "Unable to establish lock");
|
||||
php_error(E_WARNING, "%s(): Unable to establish lock: %s", get_active_function_name(TSRMLS_C), filename);
|
||||
}
|
||||
#endif /* else NFS_HACK */
|
||||
|
||||
@@ -396,7 +369,7 @@ dbm_info *php_dbm_open(char *filename, char *mode TSRMLS_DC)
|
||||
if (dbf) {
|
||||
info = (dbm_info *)emalloc(sizeof(dbm_info));
|
||||
if (!info) {
|
||||
php_error_docref1(NULL TSRMLS_CC, filename, E_ERROR, "Problem allocating memory!");
|
||||
php_error(E_ERROR, "%s(): problem allocating memory!", get_active_function_name(TSRMLS_C));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -408,7 +381,7 @@ dbm_info *php_dbm_open(char *filename, char *mode TSRMLS_DC)
|
||||
return info;
|
||||
} else {
|
||||
#if GDBM
|
||||
php_error_docref1(NULL TSRMLS_CC, filename, E_WARNING, "%d [%s], %d [%s]", gdbm_errno, gdbm_strerror(gdbm_errno), errno, strerror(errno));
|
||||
php_error(E_WARNING, "%s(%s): %d [%s], %d [%s]", get_active_function_name(TSRMLS_C), filename, gdbm_errno, gdbm_strerror(gdbm_errno), errno, strerror(errno));
|
||||
if (gdbm_errno)
|
||||
ret = gdbm_errno;
|
||||
else if (errno)
|
||||
@@ -418,13 +391,13 @@ dbm_info *php_dbm_open(char *filename, char *mode TSRMLS_DC)
|
||||
#else
|
||||
#if NDBM
|
||||
#if PHP_DEBUG
|
||||
php_error_docref1(NULL TSRMLS_CC, filename, E_WARNING, "errno = %d [%s]\n", errno, strerror(errno));
|
||||
php_error(E_WARNING, "%s(%s): errno = %d [%s]\n", get_active_function_name(TSRMLS_C), filename, errno, strerror(errno));
|
||||
#endif
|
||||
if (errno) ret=errno;
|
||||
else ret = -1;
|
||||
#else
|
||||
#if PHP_DEBUG
|
||||
php_error_docref1(NULL TSRMLS_CC, filename, E_WARNING, "errno = %d [%s]\n", errno, strerror(errno));
|
||||
php_error(E_WARNING, "%s(%s): errno = %d [%s]\n", get_active_function_name(TSRMLS_C), filename, errno, strerror(errno));
|
||||
#endif
|
||||
if (errno) ret=errno;
|
||||
else ret = -1;
|
||||
@@ -466,6 +439,7 @@ PHP_FUNCTION(dbmclose)
|
||||
*/
|
||||
void php_dbm_close(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||
{
|
||||
int ret = 0;
|
||||
dbm_info *info = (dbm_info *)rsrc->ptr;
|
||||
DBM_TYPE dbf;
|
||||
int lockfd;
|
||||
@@ -513,16 +487,50 @@ PHP_FUNCTION(dbminsert)
|
||||
|
||||
info = php_find_dbm(id TSRMLS_CC);
|
||||
if (!info) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %d", Z_LVAL_P(id));
|
||||
php_error(E_WARNING, "%s(): not a valid database identifier %d", get_active_function_name(TSRMLS_C), Z_LVAL_P(id));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ret = php_dbm_insert_replace(info, Z_STRVAL_P(key), Z_STRVAL_P(value), 0 TSRMLS_CC);
|
||||
ret = php_dbm_insert(info, Z_STRVAL_P(key), Z_STRVAL_P(value) TSRMLS_CC);
|
||||
RETURN_LONG(ret);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ php_dbm_insert
|
||||
*/
|
||||
int php_dbm_insert(dbm_info *info, char *key, char *value TSRMLS_DC) {
|
||||
datum key_datum, value_datum;
|
||||
int ret;
|
||||
DBM_TYPE dbf;
|
||||
|
||||
php_stripslashes(key, NULL TSRMLS_CC);
|
||||
php_stripslashes(value, NULL TSRMLS_CC);
|
||||
|
||||
value_datum.dptr = estrdup(value);
|
||||
value_datum.dsize = strlen(value);
|
||||
|
||||
key_datum.dptr = estrdup(key);
|
||||
key_datum.dsize = strlen(key);
|
||||
#if GDBM_FIX
|
||||
key_datum.dsize++;
|
||||
#endif
|
||||
|
||||
dbf = info->dbf;
|
||||
if (!dbf) {
|
||||
php_error(E_WARNING, "%s(): Unable to locate dbm file", get_active_function_name(TSRMLS_C));
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = DBM_STORE(dbf, key_datum, value_datum, DBM_INSERT);
|
||||
|
||||
/* free the memory */
|
||||
efree(key_datum.dptr); efree(value_datum.dptr);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int dbmreplace(int dbm_identifier, string key, string value)
|
||||
Replaces the value for a key in a dbm database */
|
||||
PHP_FUNCTION(dbmreplace)
|
||||
@@ -539,35 +547,32 @@ PHP_FUNCTION(dbmreplace)
|
||||
|
||||
info = php_find_dbm(id TSRMLS_CC);
|
||||
if (!info) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %d", Z_LVAL_P(id));
|
||||
php_error(E_WARNING, "%s(): not a valid database identifier %d", get_active_function_name(TSRMLS_C), Z_LVAL_P(id));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ret = php_dbm_insert_replace(info, Z_STRVAL_P(key), Z_STRVAL_P(value), 1 TSRMLS_CC);
|
||||
ret = php_dbm_replace(info, Z_STRVAL_P(key), Z_STRVAL_P(value) TSRMLS_CC);
|
||||
RETURN_LONG(ret);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_dbm_replace
|
||||
*/
|
||||
int php_dbm_insert_replace(dbm_info *info, char *key, char *value, int replace_mode TSRMLS_DC)
|
||||
int php_dbm_replace(dbm_info *info, char *key, char *value TSRMLS_DC)
|
||||
{
|
||||
DBM_TYPE dbf;
|
||||
int ret;
|
||||
datum key_datum, value_datum;
|
||||
|
||||
key = estrdup(key);
|
||||
value = estrdup(value);
|
||||
|
||||
if (PG(magic_quotes_runtime)) {
|
||||
php_stripslashes(key, NULL TSRMLS_CC);
|
||||
php_stripslashes(value, NULL TSRMLS_CC);
|
||||
}
|
||||
|
||||
value_datum.dptr = value;
|
||||
value_datum.dptr = estrdup(value);
|
||||
value_datum.dsize = strlen(value);
|
||||
|
||||
key_datum.dptr = key;
|
||||
key_datum.dptr = estrdup(key);
|
||||
key_datum.dsize = strlen(key);
|
||||
#if GDBM_FIX
|
||||
key_datum.dsize++;
|
||||
@@ -575,16 +580,12 @@ int php_dbm_insert_replace(dbm_info *info, char *key, char *value, int replace_m
|
||||
|
||||
dbf = info->dbf;
|
||||
if (!dbf) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to locate dbm file");
|
||||
ret = 1;
|
||||
} else {
|
||||
if (!replace_mode) {
|
||||
ret = DBM_STORE(dbf, key_datum, value_datum, DBM_INSERT);
|
||||
} else {
|
||||
ret = DBM_STORE(dbf, key_datum, value_datum, DBM_REPLACE);
|
||||
}
|
||||
php_error(E_WARNING, "%s(): Unable to locate dbm file", get_active_function_name(TSRMLS_C));
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = DBM_STORE(dbf, key_datum, value_datum, DBM_REPLACE);
|
||||
|
||||
/* free the memory */
|
||||
efree(key_datum.dptr); efree(value_datum.dptr);
|
||||
|
||||
@@ -607,7 +608,7 @@ PHP_FUNCTION(dbmfetch)
|
||||
|
||||
info = php_find_dbm(id TSRMLS_CC);
|
||||
if (!info) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %d", Z_LVAL_P(id));
|
||||
php_error(E_WARNING, "%s(): not a valid database identifier %d", get_active_function_name(TSRMLS_C), Z_LVAL_P(id));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -638,7 +639,7 @@ char *php_dbm_fetch(dbm_info *info, char *key TSRMLS_DC)
|
||||
|
||||
dbf = info->dbf;
|
||||
if (!dbf) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to locate dbm file");
|
||||
php_error(E_WARNING, "%s(): Unable to locate dbm file", get_active_function_name(TSRMLS_C));
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
@@ -683,7 +684,7 @@ PHP_FUNCTION(dbmexists)
|
||||
|
||||
info = php_find_dbm(id TSRMLS_CC);
|
||||
if (!info) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %d", Z_LVAL_P(id));
|
||||
php_error(E_WARNING, "%s(): not a valid database identifier %d", get_active_function_name(TSRMLS_C), Z_LVAL_P(id));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -707,7 +708,7 @@ int php_dbm_exists(dbm_info *info, char *key TSRMLS_DC) {
|
||||
|
||||
dbf = info->dbf;
|
||||
if (!dbf) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to locate dbm file");
|
||||
php_error(E_WARNING, "%s(): Unable to locate dbm file", get_active_function_name(TSRMLS_C));
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -732,7 +733,7 @@ PHP_FUNCTION(dbmdelete)
|
||||
|
||||
info = php_find_dbm(id TSRMLS_CC);
|
||||
if (!info) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %d", Z_LVAL_P(id));
|
||||
php_error(E_WARNING, "%s(): not a valid database identifier %d", get_active_function_name(TSRMLS_C), Z_LVAL_P(id));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -756,7 +757,7 @@ int php_dbm_delete(dbm_info *info, char *key TSRMLS_DC) {
|
||||
|
||||
dbf = info->dbf;
|
||||
if (!dbf) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to locate dbm file");
|
||||
php_error(E_WARNING, "%s(): Unable to locate dbm file", get_active_function_name(TSRMLS_C));
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -779,7 +780,7 @@ PHP_FUNCTION(dbmfirstkey)
|
||||
|
||||
info = php_find_dbm(id TSRMLS_CC);
|
||||
if (!info) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %d", Z_LVAL_P(id));
|
||||
php_error(E_WARNING, "%s(): not a valid database identifier %d", get_active_function_name(TSRMLS_C), Z_LVAL_P(id));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -801,7 +802,7 @@ char *php_dbm_first_key(dbm_info *info TSRMLS_DC) {
|
||||
|
||||
dbf = info->dbf;
|
||||
if (!dbf) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to locate dbm file");
|
||||
php_error(E_WARNING, "%s(): Unable to locate dbm file", get_active_function_name(TSRMLS_C));
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
@@ -841,7 +842,7 @@ PHP_FUNCTION(dbmnextkey)
|
||||
|
||||
info = php_find_dbm(id TSRMLS_CC);
|
||||
if (!info) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid database identifier %d", Z_LVAL_P(id));
|
||||
php_error(E_WARNING, "%s(): not a valid database identifier %d", get_active_function_name(TSRMLS_C), Z_LVAL_P(id));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -870,7 +871,7 @@ char *php_dbm_nextkey(dbm_info *info, char *key TSRMLS_DC)
|
||||
|
||||
dbf = info->dbf;
|
||||
if (!dbf) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to locate dbm file");
|
||||
php_error(E_WARNING, "%s(): Unable to locate dbm file", get_active_function_name(TSRMLS_C));
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
@@ -916,17 +917,17 @@ int flatfile_store(FILE *dbf, datum key_datum, datum value_datum, int mode) {
|
||||
fseek(dbf, 0L, SEEK_END);
|
||||
fprintf(dbf, "%d\n", key_datum.dsize);
|
||||
fflush(dbf);
|
||||
ret = fwrite(key_datum.dptr, sizeof(char), key_datum.dsize, dbf);
|
||||
ret = write(fileno(dbf), key_datum.dptr, key_datum.dsize);
|
||||
fprintf(dbf, "%d\n", value_datum.dsize);
|
||||
fflush(dbf);
|
||||
ret = fwrite(value_datum.dptr, sizeof(char), value_datum.dsize, dbf);
|
||||
ret = write(fileno(dbf), value_datum.dptr, value_datum.dsize);
|
||||
} else { /* DBM_REPLACE */
|
||||
flatfile_delete(dbf, key_datum);
|
||||
fprintf(dbf, "%d\n", key_datum.dsize);
|
||||
fflush(dbf);
|
||||
ret = fwrite(key_datum.dptr, sizeof(char), key_datum.dsize, dbf);
|
||||
ret = write(fileno(dbf), key_datum.dptr, key_datum.dsize);
|
||||
fprintf(dbf, "%d\n", value_datum.dsize);
|
||||
ret = fwrite(value_datum.dptr, sizeof(char), value_datum.dsize, dbf);
|
||||
ret = write(fileno(dbf), value_datum.dptr, value_datum.dsize);
|
||||
}
|
||||
|
||||
if (ret>0)
|
||||
@@ -948,9 +949,9 @@ datum flatfile_fetch(FILE *dbf, datum key_datum) {
|
||||
num = atoi(buf);
|
||||
if (num > buf_size) {
|
||||
buf_size+=num;
|
||||
buf = erealloc(buf, (buf_size+1)*sizeof(char));
|
||||
buf = emalloc((buf_size+1)*sizeof(char));
|
||||
}
|
||||
fread(buf, sizeof(char), num, dbf);
|
||||
read(fileno(dbf), buf, num);
|
||||
value_datum.dptr = buf;
|
||||
value_datum.dsize = num;
|
||||
}
|
||||
@@ -979,7 +980,8 @@ int flatfile_delete(FILE *dbf, datum key_datum) {
|
||||
num = atoi(buf);
|
||||
if (num > buf_size) {
|
||||
buf_size += num;
|
||||
buf = erealloc(buf, (buf_size+1)*sizeof(char));
|
||||
if (buf) efree(buf);
|
||||
buf = emalloc((buf_size+1)*sizeof(char));
|
||||
}
|
||||
pos = ftell(dbf);
|
||||
|
||||
@@ -1079,7 +1081,7 @@ datum flatfile_firstkey(FILE *dbf) {
|
||||
if (buf.dptr) efree(buf.dptr);
|
||||
buf.dptr = emalloc((buf_size+1)*sizeof(char));
|
||||
}
|
||||
num = fread(buf.dptr, sizeof(char), num, dbf);
|
||||
num=read(fileno(dbf), buf.dptr, num);
|
||||
if (num<0) break;
|
||||
buf.dsize = num;
|
||||
if (*(buf.dptr)!=0) {
|
||||
@@ -1093,7 +1095,7 @@ datum flatfile_firstkey(FILE *dbf) {
|
||||
if (buf.dptr) efree(buf.dptr);
|
||||
buf.dptr = emalloc((buf_size+1)*sizeof(char));
|
||||
}
|
||||
num = fread(buf.dptr, sizeof(char), num, dbf);
|
||||
num=read(fileno(dbf), buf.dptr, num);
|
||||
if (num<0) break;
|
||||
}
|
||||
if (buf.dptr) efree(buf.dptr);
|
||||
@@ -1119,7 +1121,7 @@ datum flatfile_nextkey(FILE *dbf) {
|
||||
if (buf.dptr) efree(buf.dptr);
|
||||
buf.dptr = emalloc((buf_size+1)*sizeof(char));
|
||||
}
|
||||
num = fread(buf.dptr, sizeof(char), num, dbf);
|
||||
num=read(fileno(dbf), buf.dptr, num);
|
||||
if (num<0) break;
|
||||
if (!fgets(buf.dptr, 15, dbf)) break;
|
||||
num = atoi(buf.dptr);
|
||||
@@ -1128,7 +1130,7 @@ datum flatfile_nextkey(FILE *dbf) {
|
||||
if (buf.dptr) efree(buf.dptr);
|
||||
buf.dptr = emalloc((buf_size+1)*sizeof(char));
|
||||
}
|
||||
num = fread(buf.dptr, sizeof(char), num, dbf);
|
||||
num=read(fileno(dbf), buf.dptr, num);
|
||||
if (num<0) break;
|
||||
buf.dsize = num;
|
||||
if (*(buf.dptr)!=0) {
|
||||
@@ -1176,9 +1178,6 @@ function_entry dbm_functions[] = {
|
||||
PHP_FE(dbmdelete, NULL)
|
||||
PHP_FE(dbmfirstkey, NULL)
|
||||
PHP_FE(dbmnextkey, NULL)
|
||||
#if HELLY_0
|
||||
PHP_FE(db_id_list, NULL)
|
||||
#endif
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
@@ -97,12 +97,20 @@ LINK32=link.exe
|
||||
|
||||
SOURCE=.\db.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\standard\flock_compat.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\standard\flock_compat.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\php_db.h
|
||||
# End Source File
|
||||
# End Group
|
||||
|
||||
+2
-1
@@ -54,8 +54,9 @@ typedef struct dbm_info {
|
||||
dbm_info *php_find_dbm(pval *id TSRMLS_DC);
|
||||
void php_dbm_close(zend_rsrc_list_entry *rsrc TSRMLS_DC);
|
||||
dbm_info *php_dbm_open(char *filename, char *mode TSRMLS_DC);
|
||||
int php_dbm_insert(dbm_info *info, char *key, char *value TSRMLS_DC);
|
||||
char *php_dbm_fetch(dbm_info *info, char *key TSRMLS_DC);
|
||||
int php_dbm_insert_replace(dbm_info *info, char *key, char *value, int replace_mode TSRMLS_DC);
|
||||
int php_dbm_replace(dbm_info *info, char *key, char *value TSRMLS_DC);
|
||||
int php_dbm_exists(dbm_info *info, char *key TSRMLS_DC);
|
||||
int php_dbm_delete(dbm_info *info, char *key TSRMLS_DC);
|
||||
char *php_dbm_first_key(dbm_info *info TSRMLS_DC);
|
||||
|
||||
@@ -2,15 +2,12 @@
|
||||
DBM File Creation Test
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("db")) print "skip"; ?>
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php
|
||||
require_once('test.inc');
|
||||
if (dbmopen($db_file, "n") && file_exists($db_file)) {
|
||||
echo "database file created\n";
|
||||
} else {
|
||||
echo "$db_file does not exist\n";
|
||||
}
|
||||
dbmclose($db_file);
|
||||
dbmopen("./test.dbm","n");
|
||||
dbmclose("./test.dbm");
|
||||
?>
|
||||
--EXPECT--
|
||||
database file created
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
--TEST--
|
||||
DBM Insert/Fetch Test
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("db")) print "skip";?>
|
||||
<?php if (!extension_loaded("db")) print "skip"; ?>
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php
|
||||
require_once('test.inc');
|
||||
if (dbmopen($db_file, "n")) {
|
||||
dbminsert($db_file, "key1", "This is a test insert");
|
||||
echo dbmfetch($db_file, "key1");
|
||||
dbmclose($db_file);
|
||||
} else {
|
||||
echo "Error creating database\n";
|
||||
}
|
||||
dbmopen("./test.dbm","n");
|
||||
dbminsert("./test.dbm","key1","This is a test insert");
|
||||
$a = dbmfetch("./test.dbm","key1");
|
||||
dbmclose("./test.dbm");
|
||||
echo $a
|
||||
?>
|
||||
--EXPECT--
|
||||
This is a test insert
|
||||
Loaded 100 of 1097 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user