mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-09 18:20:50 +00:00
Compare commits
34
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d632b7e916 | ||
|
|
00ff97638e | ||
|
|
e4c41cdeb2 | ||
|
|
ee32b0b4a7 | ||
|
|
0613e48b8e | ||
|
|
8522d30081 | ||
|
|
2b82b1c47a | ||
|
|
daf68d8d91 | ||
|
|
8f710d827e | ||
|
|
74ffa31da1 | ||
|
|
d4b7d08019 | ||
|
|
e7875fc20d | ||
|
|
f446cc2e3f | ||
|
|
715b32f618 | ||
|
|
5fb6dda2fc | ||
|
|
f00c18ad23 | ||
|
|
ad8426b7d3 | ||
|
|
eb2afa6cfb | ||
|
|
d16d5eb9f6 | ||
|
|
3b6a30dd6b | ||
|
|
36393c74f5 | ||
|
|
4a58dd0b64 | ||
|
|
3ab749ce27 | ||
|
|
5fe65aa136 | ||
|
|
5ce1dc591b | ||
|
|
fb5d197a99 | ||
|
|
ab5900f9bb | ||
|
|
45c5791d5e | ||
|
|
1ab8f39f47 | ||
|
|
6a6318d4be | ||
|
|
de3c9594e4 | ||
|
|
8bb1eb9d01 | ||
|
|
f48c985537 | ||
|
|
57293eea0b |
No files matched your search
+1
-1
@@ -18,7 +18,7 @@ LTLIBRARY_LIBADD = $(LTLIBRARY_DEPENDENCIES) $(EXTRA_LIBS)
|
||||
|
||||
PROGRAM_NAME = php
|
||||
PROGRAM_SOURCES = stub.c
|
||||
PROGRAM_LDADD = libphp4.la
|
||||
PROGRAM_LDADD = libphp4.la $(EXT_PROGRAM_LDADD)
|
||||
PROGRAM_LDFLAGS = -export-dynamic
|
||||
PROGRAM_DEPENDENCIES = $(PROGRAM_LDADD)
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ PHP 4.0 NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
|
||||
?? ??? 200?, Version 4.0.5
|
||||
- IMPORTANT: removed /F modifier handling from preg_replace(). Instead
|
||||
one should use new preg_replace_callback() function. (Andrei)
|
||||
- Added array_reduce(), which allows iterative reduction of an array
|
||||
to a single value via a callback function. (Andrei)
|
||||
- The imageloadfont function of the gd extension should be not platform
|
||||
|
||||
+97
-128
@@ -1,157 +1,126 @@
|
||||
Using PHP4 with the Zeus Web Server
|
||||
-----------------------------------
|
||||
|
||||
Zeus fully supports running PHP in combination with our webserver. A
|
||||
significant improvement in PHP 4 is that you can now run PHP as an
|
||||
ISAPI module, giving great performance benefits over traditional CGI
|
||||
code.
|
||||
Zeus fully supports running PHP in combination with our
|
||||
webserver. There are three different interfaces that can be used to
|
||||
enable PHP:
|
||||
|
||||
Note that you will need to be running at least version 3.3.8 of the
|
||||
webserver. If you are running an earlier version, please see our
|
||||
website (http://www.zeus.com) for upgrade instructions.
|
||||
Earlier versions of Zeus (3.3.6) can also run PHP, but it is
|
||||
suggested that you upgrade for full compatibility.
|
||||
* CGI
|
||||
* ISAPI
|
||||
* FastCGI
|
||||
|
||||
You should compile PHP using the gcc compiler. Other compilers may
|
||||
cause build errors.
|
||||
Of the three, we recommend using FastCGI, which has been tested and
|
||||
benchmarked as providing the best performance and reliability.
|
||||
|
||||
To build the ISAPI version of PHP, start the configuration with:
|
||||
Full details of how to install PHP are available from our
|
||||
website, at:
|
||||
|
||||
./configure --with-zeus=/usr/local/zeus
|
||||
http://support.zeus.com/products/php.html
|
||||
|
||||
Obviously, replace /usr/local/zeus with the location of where you have
|
||||
installed Zeus on your machine. For PHP to build successfully, you
|
||||
need to have 3.3.6 already installed, because the code relies on the
|
||||
presence of header files provided with the latest version.
|
||||
|
||||
You may have to adjust the environment variable LDFLAGS and EXTRA_LIBS
|
||||
in order to link in extra libraries. This depends on the platform on
|
||||
which you are building and also on the compiler used (see below). A
|
||||
standard GNU/Linux install with GCC should build fine with no changes.
|
||||
If you have any problems, please check the support site for more
|
||||
up-to-date information and advice.
|
||||
|
||||
|
||||
Configuring the webserver
|
||||
-------------------------
|
||||
Quick guide to installing FastCGI with Zeus
|
||||
-------------------------------------------
|
||||
|
||||
After running 'make' and 'make install', you will have a 'libphp4.so'
|
||||
file. Copy this file into a directory reserved for ISAPI
|
||||
binaries. Now, perform the following steps for each virtual server
|
||||
that you wish to run PHP on:
|
||||
Step 1 - obtain and install FastCGI development kit.
|
||||
|
||||
1) On the Admin server, go to 'edit server->path mapping'
|
||||
2) Add an alias to the directory with libphp4.so in it, mapped to
|
||||
/isapi/ (or a location of your choice). Make sure you set the alias
|
||||
type to ISAPI.
|
||||
3) Click 'update'
|
||||
4) Add a handler for file extension 'php' to be run by /isapi/libphp4.so
|
||||
5) Click 'update', then go back to the previous page.
|
||||
6) Click on the 'module configuration' button, ensure that ISAPI
|
||||
support is ticked.
|
||||
7) Click on the ISAPI link. At the bottom of the page, click the
|
||||
checkbox for running ISAPI extensions 'out of process'.
|
||||
8) Click 'update'. Then restart the virtual server. Done!
|
||||
Grab the package from:
|
||||
http://www.fastcgi.com/dist/devkit_2.2.0.tar.gz
|
||||
|
||||
Extract the package and follow the instructions:
|
||||
./configure
|
||||
make
|
||||
make export
|
||||
(run the last as root)
|
||||
|
||||
This will install to /usr/local/lib/libfcgi.a
|
||||
and /usr/local/include/*fcgi*
|
||||
|
||||
|
||||
Troubleshooting
|
||||
---------------
|
||||
|
||||
*) Why does the compile fail at Zend/zend-scanner-cc.cc
|
||||
or Zend/zend-parser.c ?
|
||||
Step 2 - Compile PHP as FastCGI.
|
||||
|
||||
These source files are auto-generated from the corresponding .y files.
|
||||
The default distribution of PHP contains pre-generated versions of these
|
||||
files that have caused problems for some people. The simplest solution is
|
||||
to delete the files. They will then be rebuilt correctly. You must have the
|
||||
following GNU tools to do this:
|
||||
Compile as follows:
|
||||
./configure --with-fastcgi
|
||||
make
|
||||
|
||||
bison 1.28 or later
|
||||
flex 2.5.4 or later
|
||||
Note that PHP has many options to the configure script -
|
||||
e.g. --with-mysql. You will probably want to select your usual options
|
||||
before compiling; the above is just a bare minimum, for illustration.
|
||||
|
||||
*) Why does my PHP library fail to load?
|
||||
|
||||
After configuring Zeus, if you get a '502 Bad Gateway' error when
|
||||
accessing a PHP page, there are problems loading the PHP
|
||||
library. Check the error log ($ZEUSHOME/web/log/errors) for errors.
|
||||
|
||||
Failing to load the PHP ISAPI module is likely to be due to unresolved
|
||||
symbols in the module. A way to check for this is to visit our support
|
||||
page at http://support.zeus.com/faq/entries/isapi_error.html and run
|
||||
the program there on your libphp4.so. It will list any unresolved
|
||||
symbols.
|
||||
|
||||
*) My libphp4.so has unresolved symbols. How do I fix this?
|
||||
|
||||
You must ensure that the PHP build process links in the appropriate
|
||||
libraries that contain these symbols! The libraries required will
|
||||
depend on the platform you are running PHP on.
|
||||
|
||||
You may need to set one or two environment variables before running
|
||||
the 'configure' program to set up PHP; LDFLAGS and EXTRA_LIBS. Make
|
||||
sure that you also export these variables to the build process.
|
||||
(Type 'export LDFLAGS EXTRA_LIBS' in the shell to do this.)
|
||||
|
||||
If you are using 3rd party tools and libraries which are installed
|
||||
in non-standard locations, you may need to set the environment
|
||||
variable LD_LIBRARY_PATH to point to the library's location, prior
|
||||
to running the Zeus Web Server. For example, if you have compiled
|
||||
external MySQL support, and mysql is installed in /usr/local/mysql,
|
||||
you should set LD_LIBRARY_PATH to '/usr/local/mysql/lib/mysql'
|
||||
and then 'export LD_LIBRARY_PATH'. For convenience, you should add
|
||||
this to the 'start-zeus' script provided.
|
||||
|
||||
Yet another method of ensuring the linked libraries are found is to
|
||||
set the environment variable LD_RUN_PATH before compiling PHP. This
|
||||
works in a similar way to LD_LIBRARY_PATH, but at compile-time.
|
||||
Libraries produced with this envrionment variable set will have its
|
||||
value 'burned' into the resultant binary, specifying a runtime
|
||||
search pth to locate other required libraries such as MySQL.
|
||||
|
||||
On Linux, you can also tell the dynamic linker where to find the
|
||||
libraries, by adding '/usr/local/mysql/lib/mysql' to the file
|
||||
/etc/ld.so.conf - after editting this file, run 'ldconfig' as root,
|
||||
to use the changes.
|
||||
After compilation finishes, you will be left with an executable
|
||||
program called 'php'. Copy this into your document root, under a
|
||||
dedicated FastCGI directory (e.g. $DOCROOT/fcgi-bin/php)
|
||||
|
||||
|
||||
Specific examples:
|
||||
Step 3 - configure Zeus
|
||||
|
||||
Solaris + gcc:
|
||||
Ensure you run ./configure with the `--enable-libgcc' parameter. You
|
||||
may need to set LDFLAGS to '-L/usr/local/egcs/lib' (path depends on
|
||||
your gcc installation)
|
||||
Four stages:
|
||||
- enable FastCGI
|
||||
- configure FastCGI
|
||||
- setup alias for FastCGI
|
||||
- setup alias for PHP
|
||||
|
||||
FreeBSD 4:
|
||||
Some people may find they need to run ./configure with the
|
||||
'--enable-libgcc' compile option too.
|
||||
1) Using the admin server, go to the 'module configuration' page for
|
||||
your virtual server, and ensure that 'fastcgi' is enabled (select the
|
||||
tickbox to the left).
|
||||
|
||||
2) While we can run FastCGI's locally, there are known problems with
|
||||
some OS's (specifically, the communication between web server and
|
||||
FastCGI happens over a unix domain socket, and some OS's have trouble
|
||||
sustaining high connection rates over these sockets). So instead, we
|
||||
are going to set up the PHP FastCGI to run 'remotely' over localhost
|
||||
(this uses TCP sockets, which do not suffer this problem). Go to the
|
||||
'fastcgi configuration' page, and under 'add remote fastcgi':
|
||||
Add Remote FastCGI
|
||||
Docroot path /fcgi-bin/php
|
||||
Remote machine localhost:8002
|
||||
The first entry is where you saved PHP, above.
|
||||
The second entry is localhost:<any unused port>
|
||||
We will start the FastCGI listening on this port shortly.
|
||||
Click 'update' to commit these changes.
|
||||
|
||||
3) Go to the path mapping module and add an alias for FastCGI:
|
||||
Add Alias
|
||||
Docroot path /fcgi-bin
|
||||
Filesystem directory /path/to/docroot/fcgi-bin
|
||||
Alias type fastcgi
|
||||
Click 'update' to commit these changes
|
||||
|
||||
4) Also on the path mapping module, add a handler for PHP:
|
||||
Add handler
|
||||
File extension php
|
||||
Handler /fcgi-bin/php
|
||||
Click 'update' to commit these changes
|
||||
|
||||
Finally restart your virtual server for these changes to take effect.
|
||||
|
||||
|
||||
Performance issues
|
||||
==================
|
||||
Step 4 - start PHP as a FastCGI runner
|
||||
|
||||
To make PHP run fast under Zeus, check the following points:
|
||||
When you start PHP, it will pre-fork a given number of child processes
|
||||
to handle incoming PHP requests. Each process will handle a given
|
||||
number of requests before exiting (and being replaced by a newly
|
||||
forked process). You can control these two parameters by setting the
|
||||
following environment variables BEFORE starting the FastCGI runner:
|
||||
|
||||
1) Run PHP as an ISAPI module, not a CGI - compile it with the --with-zeus=...
|
||||
flag!
|
||||
PHP_FCGI_CHILDREN - the number of child processes to pre-fork. If not
|
||||
set, defaults to 8.
|
||||
|
||||
2) Tune the ISAPI runner to your required workload. There are several
|
||||
tuneables that can be given. These are set by adding the appropriate
|
||||
lines to the $ZEUSHOME/web/global.cfg file. Changes to this file will only
|
||||
be picked up after the web server is restarted (run stop-zeus ; start-zeus)
|
||||
PHP_FCGI_MAX_REQUESTS - the number of requests each PHP child process
|
||||
handles before exiting. If not set, defaults to 500.
|
||||
|
||||
tuning!modules!isapi!external!maxthreads xxx
|
||||
To start the FastCGI runner, execute '$ZEUSHOME/web/bin/fcgirunner
|
||||
8002 $DOCROOT/fcgi-bin/php'. Substitute the appropriate values for
|
||||
$ZEUSHOME and $DOCROOT; also substitute for 8002 the port you chose,
|
||||
above.
|
||||
|
||||
- Sets the maximum number of threads that the ISAPI runner will spawn. If
|
||||
further PHP page requests arrive, they will be queued until a current
|
||||
page is finished. For busy websites, we suggest increasing this value
|
||||
(defaults to 16). Replace the 'xxx' in the above line with the required
|
||||
number of threads. Note that the threads are equally shared between
|
||||
ISAPI extensions and filters, so if you want to handle 100 concurrent
|
||||
PHP page requests, set this tuneable to 200.
|
||||
|
||||
tuning!modules!isapi!external!minthreads xxx
|
||||
|
||||
- Sets the minimum number of threads. Idle threads will be kept in a pool,
|
||||
which avoids costly thread creation/deletion.
|
||||
|
||||
|
||||
For more information and help with Zeus, please visit our website:
|
||||
http://support.zeus.com
|
||||
To stop the runner (e.g. to experiment with the above environment
|
||||
variables) you will need to manually stop and running PHP
|
||||
processes. (Use 'ps' and 'kill'). As it is PHP which is forking lots
|
||||
of children and not the runner, Zeus unfortunately cannot keep track
|
||||
of what processes are running, sorry. A typical command line may look
|
||||
like 'ps -efl | grep $DOCROOT/fcgi-bin/php | grep -v grep | awk
|
||||
'{print $4}' | xargs kill'
|
||||
+16
-7
@@ -51,7 +51,7 @@ dnl ## All of these are normally in the extension directories.
|
||||
dnl ## Diversion 5 is the last one. Here we generate files and clean up.
|
||||
|
||||
dnl ## This is where the version number is changed from now on!
|
||||
AM_INIT_AUTOMAKE(php, 4.0.5-dev, nodefine)
|
||||
AM_INIT_AUTOMAKE(php, 4.0.5RC4, nodefine)
|
||||
|
||||
PHP_VERSION=$VERSION
|
||||
echo "/* automatically generated by configure */" > php_version.h.new
|
||||
@@ -107,7 +107,8 @@ case "$host_alias" in
|
||||
*bsdi*)
|
||||
BSD_MAKEFILE=yes;;
|
||||
*beos*)
|
||||
LIBS="$LIBS -lbe -lroot"
|
||||
beos_threads=1
|
||||
LIBS="$LIBS -lbe -lroot";;
|
||||
esac
|
||||
|
||||
AM_PROG_CC_STDC
|
||||
@@ -249,11 +250,13 @@ dnl The sin may be in a library which need not be specifed
|
||||
dnl as well as res_search resides in libsocket
|
||||
AC_CHECK_LIB(m, sin)
|
||||
|
||||
AC_CHECK_LIB(bind, inet_aton, [
|
||||
AC_ADD_LIBRARY(bind)
|
||||
AC_DEFINE(HAVE_LIBBIND,1,[Whether you have bind]) ], [
|
||||
AC_CHECK_LIB(resolv, inet_aton)
|
||||
])
|
||||
dnl Only include libbind if inet_aton is not found in
|
||||
dnl libresolv.
|
||||
AC_CHECK_LIB(resolv, inet_aton. [], [
|
||||
AC_CHECK_LIB(bind, inet_aton, [], [
|
||||
AC_CHECK_LIB(bind, __inet_aton)
|
||||
])
|
||||
])
|
||||
|
||||
dnl The res_search may be in libsocket as well, and if it is
|
||||
dnl make sure to check for dn_skipname in libresolv, or if res_search
|
||||
@@ -389,6 +392,7 @@ putenv \
|
||||
random \
|
||||
rand_r \
|
||||
regcomp \
|
||||
res_search \
|
||||
setitimer \
|
||||
setlocale \
|
||||
localeconv \
|
||||
@@ -644,6 +648,11 @@ if test "$PHP_SAPI" = "cgi"; then
|
||||
PHP_PROGRAM=php
|
||||
fi
|
||||
|
||||
if test "$PHP_SAPI" = "fastcgi"; then
|
||||
PHP_PROGRAM=php
|
||||
fi
|
||||
|
||||
|
||||
PHP_REGEX
|
||||
|
||||
PHP_CONFIGURE_PART(Configuring Zend)
|
||||
|
||||
@@ -33,6 +33,13 @@
|
||||
|
||||
#if HAVE_CPDFLIB
|
||||
|
||||
/* The macro T is defined in the IMAP headers and clashes with a function
|
||||
declaration here. Get rid of it. */
|
||||
|
||||
#ifdef T
|
||||
#undef T
|
||||
#endif
|
||||
|
||||
#include <cpdflib.h>
|
||||
|
||||
extern zend_module_entry cpdf_module_entry;
|
||||
|
||||
+12
-10
@@ -108,11 +108,13 @@ static void phpi_FDFClose(zend_rsrc_list_entry *rsrc)
|
||||
(void)FDFClose(fdf);
|
||||
}
|
||||
|
||||
static sapi_post_entry supported_post_entries[] = {
|
||||
#if HAVE_FDFLIB
|
||||
{ "application/vnd.fdf", sizeof("application/vnd.fdf")-1, php_default_post_reader, fdf_post_handler},
|
||||
#endif
|
||||
{ NULL, 0, NULL }
|
||||
#define FDF_POST_CONTENT_TYPE "application/vnd.fdf"
|
||||
|
||||
static sapi_post_entry php_fdf_post_entry = {
|
||||
FDF_POST_CONTENT_TYPE,
|
||||
sizeof(FDF_POST_CONTENT_TYPE)-1,
|
||||
sapi_read_standard_form_data,
|
||||
fdf_post_handler
|
||||
};
|
||||
|
||||
|
||||
@@ -123,9 +125,9 @@ PHP_MINIT_FUNCTION(fdf)
|
||||
FDF_GLOBAL(le_fdf) = zend_register_list_destructors_ex(phpi_FDFClose, NULL, "fdf", module_number);
|
||||
|
||||
/* add handler for Acrobat FDF form post requests */
|
||||
sapi_add_post_entry("application/vnd.fdf", php_default_post_reader, fdf_post_handler);
|
||||
sapi_register_post_entry(&php_fdf_post_entry);
|
||||
|
||||
/* Constants used by fdf_set_opt() */
|
||||
/* Constants used by fdf_set_opt() */
|
||||
REGISTER_LONG_CONSTANT("FDFValue", FDFValue, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("FDFStatus", FDFStatus, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("FDFFile", FDFFile, CONST_CS | CONST_PERSISTENT);
|
||||
@@ -176,7 +178,7 @@ PHP_MSHUTDOWN_FUNCTION(fdf)
|
||||
FDFErc err;
|
||||
|
||||
/* remove handler for Acrobat FDF form post requests */
|
||||
sapi_remove_post_entry("application/vnd.fdf");
|
||||
sapi_unregister_post_entry(&php_fdf_post_entry);
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
return SUCCESS;
|
||||
@@ -769,10 +771,9 @@ SAPI_POST_HANDLER_FUNC(fdf_post_handler)
|
||||
char *name=NULL,*value=NULL,*p;
|
||||
int name_len=0,value_len=0;
|
||||
char *lastfieldname =NULL;
|
||||
char *strtok_buf = NULL;
|
||||
char *filename = NULL;
|
||||
FDFErc err;
|
||||
ASInt32 nBytes, datalen;
|
||||
ASInt32 nBytes;
|
||||
zval *array_ptr = (zval *) arg;
|
||||
ELS_FETCH();
|
||||
PLS_FETCH();
|
||||
@@ -811,6 +812,7 @@ SAPI_POST_HANDLER_FUNC(fdf_post_handler)
|
||||
err = FDFGetValue(theFDF,name,value,value_len-1,&nBytes);
|
||||
if(err == FDFErcOK && nBytes != 0) {
|
||||
for(p=value;*p;p++) if(*p=='\r') *p='\n';
|
||||
if(lastfieldname) efree(lastfieldname);
|
||||
lastfieldname = estrdup(name);
|
||||
php_register_variable(name, value, array_ptr ELS_CC PLS_CC);
|
||||
}
|
||||
|
||||
-103
@@ -1,103 +0,0 @@
|
||||
#ifndef _INCLUDED_IMAP_H
|
||||
#define _INCLUDED_IMAP_H
|
||||
|
||||
#if COMPILE_DL
|
||||
#undef HAVE_IMAP
|
||||
#define HAVE_IMAP 1
|
||||
#endif
|
||||
|
||||
#if HAVE_IMAP
|
||||
|
||||
#ifndef PHP_WIN32
|
||||
#include "build-defs.h"
|
||||
#endif
|
||||
|
||||
/* Functions accessable to PHP */
|
||||
extern zend_module_entry imap_module_entry;
|
||||
#define imap_module_ptr &imap_module_entry
|
||||
|
||||
extern PHP_MINIT_FUNCTION(imap);
|
||||
extern PHP_RINIT_FUNCTION(imap);
|
||||
extern PHP_RSHUTDOWN_FUNCTION(imap);
|
||||
PHP_MINFO_FUNCTION(imap);
|
||||
PHP_FUNCTION(imap_open);
|
||||
PHP_FUNCTION(imap_popen);
|
||||
PHP_FUNCTION(imap_reopen);
|
||||
PHP_FUNCTION(imap_num_msg);
|
||||
PHP_FUNCTION(imap_num_recent);
|
||||
PHP_FUNCTION(imap_headers);
|
||||
PHP_FUNCTION(imap_headerinfo);
|
||||
PHP_FUNCTION(imap_rfc822_parse_headers);
|
||||
PHP_FUNCTION(imap_body);
|
||||
PHP_FUNCTION(imap_fetchstructure);
|
||||
PHP_FUNCTION(imap_fetchbody);
|
||||
PHP_FUNCTION(imap_expunge);
|
||||
PHP_FUNCTION(imap_delete);
|
||||
PHP_FUNCTION(imap_undelete);
|
||||
PHP_FUNCTION(imap_check);
|
||||
PHP_FUNCTION(imap_close);
|
||||
PHP_FUNCTION(imap_mail_copy);
|
||||
PHP_FUNCTION(imap_mail_move);
|
||||
PHP_FUNCTION(imap_createmailbox);
|
||||
PHP_FUNCTION(imap_renamemailbox);
|
||||
PHP_FUNCTION(imap_deletemailbox);
|
||||
PHP_FUNCTION(imap_listmailbox);
|
||||
PHP_FUNCTION(imap_scanmailbox);
|
||||
PHP_FUNCTION(imap_subscribe);
|
||||
PHP_FUNCTION(imap_unsubscribe);
|
||||
PHP_FUNCTION(imap_append);
|
||||
PHP_FUNCTION(imap_ping);
|
||||
PHP_FUNCTION(imap_base64);
|
||||
PHP_FUNCTION(imap_qprint);
|
||||
PHP_FUNCTION(imap_8bit);
|
||||
PHP_FUNCTION(imap_binary);
|
||||
PHP_FUNCTION(imap_mailboxmsginfo);
|
||||
PHP_FUNCTION(imap_rfc822_write_address);
|
||||
PHP_FUNCTION(imap_rfc822_parse_adrlist);
|
||||
PHP_FUNCTION(imap_setflag_full);
|
||||
PHP_FUNCTION(imap_clearflag_full);
|
||||
PHP_FUNCTION(imap_sort);
|
||||
PHP_FUNCTION(imap_fetchheader);
|
||||
PHP_FUNCTION(imap_fetchtext);
|
||||
PHP_FUNCTION(imap_uid);
|
||||
PHP_FUNCTION(imap_msgno);
|
||||
PHP_FUNCTION(imap_list);
|
||||
PHP_FUNCTION(imap_list_full);
|
||||
PHP_FUNCTION(imap_listscan);
|
||||
PHP_FUNCTION(imap_lsub);
|
||||
PHP_FUNCTION(imap_lsub_full);
|
||||
PHP_FUNCTION(imap_create);
|
||||
PHP_FUNCTION(imap_rename);
|
||||
PHP_FUNCTION(imap_status);
|
||||
PHP_FUNCTION(imap_bodystruct);
|
||||
PHP_FUNCTION(imap_fetch_overview);
|
||||
PHP_FUNCTION(imap_mail_compose);
|
||||
PHP_FUNCTION(imap_alerts);
|
||||
PHP_FUNCTION(imap_errors);
|
||||
PHP_FUNCTION(imap_last_error);
|
||||
PHP_FUNCTION(imap_mail);
|
||||
PHP_FUNCTION(imap_search);
|
||||
PHP_FUNCTION(imap_utf8);
|
||||
PHP_FUNCTION(imap_utf7_decode);
|
||||
PHP_FUNCTION(imap_utf7_encode);
|
||||
PHP_FUNCTION(imap_mime_header_decode);
|
||||
#else
|
||||
#define imap_module_ptr NULL
|
||||
#endif /* HAVE_IMAP */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define phpext_imap_ptr imap_module_ptr
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
| Andrew Skalski <askalski@chekinc.com> |
|
||||
| Hartmut Holzgraefe <hartmut@six.de> |
|
||||
| Jani Taskinen <sniper@iki.fi> |
|
||||
| Daniel R Kalowsky <dank@deadmime.org> |
|
||||
| PHP 4.0 updates: Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -366,6 +367,8 @@ MESSAGELIST *mail_newmessagelist(void)
|
||||
*/
|
||||
void mail_getquota(MAILSTREAM *stream, char *qroot,QUOTALIST *qlist)
|
||||
{
|
||||
IMAPLS_FETCH();
|
||||
|
||||
/* this should only be run through once */
|
||||
for (; qlist; qlist = qlist->next)
|
||||
{
|
||||
@@ -1022,6 +1025,8 @@ PHP_FUNCTION(imap_get_quota)
|
||||
int ind, ind_type;
|
||||
pils *imap_le_struct;
|
||||
|
||||
IMAPLS_FETCH();
|
||||
|
||||
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &qroot) == FAILURE) {
|
||||
ZEND_WRONG_PARAM_COUNT();
|
||||
}
|
||||
|
||||
+3
-1
@@ -1211,7 +1211,7 @@ static void php_mcrypt_do_crypt (char* cipher, zval **key, zval **data, char *mo
|
||||
int block_size, max_key_length, use_key_length, i, count, iv_size;
|
||||
unsigned long int data_size;
|
||||
int *key_length_sizes;
|
||||
char *key_s, *iv_s;
|
||||
char *key_s = NULL, *iv_s;
|
||||
char *data_s;
|
||||
MCRYPT td;
|
||||
MCLS_FETCH();
|
||||
@@ -1309,6 +1309,8 @@ static void php_mcrypt_do_crypt (char* cipher, zval **key, zval **data, char *mo
|
||||
mcrypt_generic_end (td);
|
||||
if (iv_s != NULL)
|
||||
efree (iv_s);
|
||||
if (key_s != NULL)
|
||||
efree (key_s);
|
||||
efree (data_s);
|
||||
mcrypt_module_close (td);
|
||||
}
|
||||
|
||||
+11
-9
@@ -1,15 +1,12 @@
|
||||
dnl $Id$
|
||||
dnl config.m4 for extension libming
|
||||
dnl don't forget to call PHP_EXTENSION(ming)
|
||||
dnl This file is a modified version of config.m4
|
||||
dnl in php4/ext/mcrypt
|
||||
|
||||
PHP_ARG_WITH(ming, for ming support,
|
||||
PHP_ARG_WITH(ming, whether to include ming support,
|
||||
[ --with-ming[=DIR] Include ming support])
|
||||
|
||||
if test "$PHP_MING" != "no"; then
|
||||
for i in /usr/lib /usr/local /usr $PHP_MING; do
|
||||
if test -r $i/libming.so; then
|
||||
for i in $PHP_MING /usr/local /usr; do
|
||||
if test -r $i/lib/libming.so; then
|
||||
MING_DIR=$i
|
||||
fi
|
||||
done
|
||||
@@ -18,11 +15,16 @@ if test "$PHP_MING" != "no"; then
|
||||
AC_MSG_ERROR(Please reinstall libming.so - I cannot find libming.so)
|
||||
fi
|
||||
|
||||
AC_ADD_INCLUDE($MING_DIR)
|
||||
AC_ADD_INCLUDE($MING_DIR/include)
|
||||
|
||||
PHP_SUBST(MING_SHARED_LIBADD)
|
||||
AC_ADD_LIBRARY_WITH_PATH(ming, $MING_DIR, MING_SHARED_LIBADD)
|
||||
AC_DEFINE(HAVE_MING,1,[ ])
|
||||
AC_ADD_LIBRARY_WITH_PATH(ming, $MING_DIR/lib, MING_SHARED_LIBADD)
|
||||
|
||||
AC_CHECK_LIB(ming, Ming_setScale, [
|
||||
AC_DEFINE(HAVE_MING,1,[ ])
|
||||
],[
|
||||
AC_MSG_ERROR(Ming library 0.1.0 or greater required.)
|
||||
])
|
||||
|
||||
PHP_EXTENSION(ming, $ext_shared)
|
||||
fi
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#if HAVE_MING
|
||||
#include "ext/standard/info.h"
|
||||
#include "ext/standard/file.h"
|
||||
#include "php_ming.h"
|
||||
|
||||
static zend_function_entry ming_functions[] = {
|
||||
@@ -2955,7 +2956,9 @@ PHP_MINIT_FUNCTION(ming)
|
||||
CONSTANT("SWFTEXTFIELD_WORDWRAP", SWFTEXTFIELD_WORDWRAP);
|
||||
CONSTANT("SWFTEXTFIELD_DRAWBOX", SWFTEXTFIELD_DRAWBOX);
|
||||
CONSTANT("SWFTEXTFIELD_NOSELECT", SWFTEXTFIELD_NOSELECT);
|
||||
#ifdef SWFTEXTFIELD_HTML
|
||||
CONSTANT("SWFTEXTFIELD_HTML", SWFTEXTFIELD_HTML);
|
||||
#endif
|
||||
|
||||
/* flags for SWFTextField_align */
|
||||
CONSTANT("SWFTEXTFIELD_ALIGN_LEFT", SWFTEXTFIELD_ALIGN_LEFT);
|
||||
|
||||
@@ -1710,7 +1710,6 @@ int ora_set_param_values(oraCursor *cursor, int isout)
|
||||
|
||||
if (zend_hash_find(&EG(symbol_table), paramname, strlen(paramname) + 1, (void **)&pdata) == FAILURE){
|
||||
php_error(E_WARNING, "Can't find variable for parameter");
|
||||
efree(paramname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1725,8 +1724,6 @@ int ora_set_param_values(oraCursor *cursor, int isout)
|
||||
|
||||
strncpy(param->progv, (*pdata)->value.str.val, len);
|
||||
param->progv[len] = '\0';
|
||||
|
||||
efree(paramname);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
dnl $Id$
|
||||
dnl config.m4 for extension pcre
|
||||
|
||||
dnl By default we'll compile and link against the bundled PCRE library
|
||||
dnl if DIR is supplied, we'll use that for linking
|
||||
|
||||
PHP_ARG_WITH(pcre-regex,whether to include PCRE support,
|
||||
[ --without-pcre-regex Do not include Perl Compatible Regular Expressions
|
||||
support. Use --with-pcre-regex=DIR to specify DIR
|
||||
where PCRE's include and library files are located,
|
||||
if not using bundled library.],yes)
|
||||
|
||||
if test "$PHP_PCRE_REGEX" != "no"; then
|
||||
PHP_EXTENSION(pcre, $ext_shared)
|
||||
if test "$PHP_PCRE_REGEX" = "yes"; then
|
||||
PCRE_LIBADD=pcrelib/libpcre.la
|
||||
PCRE_SHARED_LIBADD=pcrelib/libpcre.la
|
||||
PCRE_SUBDIRS=pcrelib
|
||||
CPPFLAGS="$CPPFLAGS -DSUPPORT_UTF8"
|
||||
PHP_SUBST(PCRE_LIBADD)
|
||||
PHP_SUBST(PCRE_SUBDIRS)
|
||||
AC_DEFINE(HAVE_BUNDLED_PCRE, 1, [ ])
|
||||
PHP_FAST_OUTPUT($ext_builddir/pcrelib/Makefile)
|
||||
LIB_BUILD($ext_builddir/pcrelib,$ext_shared,yes)
|
||||
else
|
||||
test -f $PHP_PCRE_REGEX/pcre.h && PCRE_INCDIR=$PHP_PCRE_REGEX
|
||||
test -f $PHP_PCRE_REGEX/include/pcre.h && PCRE_INCDIR=$PHP_PCRE_REGEX/include
|
||||
|
||||
if test -z "$PCRE_INCDIR"; then
|
||||
AC_MSG_RESULT(Could not find pcre.h in $PHP_PCRE_REGEX)
|
||||
fi
|
||||
|
||||
changequote({,})
|
||||
pcre_major=`grep PCRE_MAJOR $PCRE_INCDIR/pcre.h | sed -e 's/[^0-9]//g'`
|
||||
pcre_minor=`grep PCRE_MINOR $PCRE_INCDIR/pcre.h | sed -e 's/[^0-9]//g'`
|
||||
changequote([,])
|
||||
pcre_minor_length=`echo "$pcre_minor" | wc -c | sed -e 's/[^0-9]//g'`
|
||||
if test "$pcre_minor_length" -eq 2 ; then
|
||||
pcre_minor="$pcre_minor"0
|
||||
fi
|
||||
pcre_version=$pcre_major$pcre_minor
|
||||
if test "$pcre_version" -lt 208; then
|
||||
AC_MSG_ERROR(The PCRE extension requires PCRE library version >= 2.08)
|
||||
fi
|
||||
|
||||
test -f $PHP_PCRE_REGEX/libpcre.a && PCRE_LIBDIR="$PHP_PCRE_REGEX"
|
||||
test -f $PHP_PCRE_REGEX/lib/libpcre.a && PCRE_LIBDIR="$PHP_PCRE_REGEX/lib"
|
||||
|
||||
if test -z "$PCRE_LIBDIR" ; then
|
||||
AC_MSG_ERROR(Could not find libpcre.a in $PHP_PCRE_REGEX)
|
||||
fi
|
||||
|
||||
AC_ADD_LIBRARY_WITH_PATH(pcre, $PCRE_LIBDIR, PCRE_SHARED_LIBADD)
|
||||
|
||||
AC_ADD_INCLUDE($PCRE_INCDIR)
|
||||
AC_DEFINE(HAVE_PCRE, 1, [ ])
|
||||
fi
|
||||
fi
|
||||
PHP_SUBST(PCRE_SHARED_LIBADD)
|
||||
|
||||
|
||||
AC_CHECK_FUNC(memmove, [], [AC_DEFINE(USE_BCOPY, 1, [ ])])
|
||||
@@ -26,6 +26,8 @@ PHP_ARG_WITH(pdflib,whether to include PDFlib support,
|
||||
AC_ADD_LIBRARY(jpeg)
|
||||
AC_ADD_LIBRARY(z)
|
||||
;;
|
||||
no)
|
||||
;;
|
||||
*)
|
||||
test -f $withval/include/pdflib.h && PDFLIB_INCLUDE="$withval/include"
|
||||
if test -n "$PDFLIB_INCLUDE" ; then
|
||||
|
||||
+6
-1
@@ -501,7 +501,8 @@ PHP_FUNCTION(pg_pconnect)
|
||||
PHP_FUNCTION(pg_close)
|
||||
{
|
||||
zval **pgsql_link = NULL;
|
||||
int id;
|
||||
void *ptr;
|
||||
int id, type;
|
||||
PGconn *pgsql;
|
||||
PGLS_FETCH();
|
||||
|
||||
@@ -527,6 +528,10 @@ PHP_FUNCTION(pg_close)
|
||||
|
||||
if (id==-1) { /* explicit resource number */
|
||||
zend_list_delete(Z_RESVAL_PP(pgsql_link));
|
||||
ptr = zend_list_find(Z_RESVAL_PP(pgsql_link),&type);
|
||||
if (ptr && (type==le_link || type==le_plink)) {
|
||||
RETURN_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (id!=-1
|
||||
|
||||
@@ -1130,6 +1130,7 @@ PHP_FUNCTION(bind)
|
||||
if (sock_type->sa_family == AF_UNIX) {
|
||||
struct sockaddr_un *sa = (struct sockaddr_un *) sock_type;
|
||||
memset(sa, 0, sizeof(sa_storage)); /* This is safe -> sock_type = &sa_storage -> sa = sock_type */
|
||||
sa->sun_family = AF_UNIX;
|
||||
snprintf(sa->sun_path, 108, "%s", Z_STRVAL_PP(arg1));
|
||||
ret = bind(Z_LVAL_PP(arg0), (struct sockaddr *) sa, SUN_LEN(sa));
|
||||
} else if (sock_type->sa_family == AF_INET) {
|
||||
|
||||
@@ -247,7 +247,7 @@ function_entry basic_functions[] = {
|
||||
PHP_FE(gethostbyaddr, NULL)
|
||||
PHP_FE(gethostbyname, NULL)
|
||||
PHP_FE(gethostbynamel, NULL)
|
||||
#if HAVE_LIBBIND && !(defined(__BEOS__)||defined(PHP_WIN32))
|
||||
#if HAVE_RES_SEARCH && !(defined(__BEOS__)||defined(PHP_WIN32))
|
||||
PHP_FE(checkdnsrr, NULL)
|
||||
PHP_FE(getmxrr, second_and_third_args_force_ref)
|
||||
#else
|
||||
@@ -2471,6 +2471,7 @@ PHP_FUNCTION(move_uploaded_file)
|
||||
zval **path, **new_path;
|
||||
zend_bool successful=0;
|
||||
SLS_FETCH();
|
||||
PLS_FETCH();
|
||||
|
||||
if (!SG(rfc1867_uploaded_files)) {
|
||||
RETURN_FALSE;
|
||||
@@ -2485,7 +2486,11 @@ PHP_FUNCTION(move_uploaded_file)
|
||||
if (!zend_hash_exists(SG(rfc1867_uploaded_files), Z_STRVAL_PP(path), Z_STRLEN_PP(path)+1)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(new_path), NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
V_UNLINK(Z_STRVAL_PP(new_path));
|
||||
if (rename(Z_STRVAL_PP(path), Z_STRVAL_PP(new_path))==0) {
|
||||
successful=1;
|
||||
|
||||
@@ -98,6 +98,14 @@ PHPAPI void php_print_credits(int flag)
|
||||
php_info_print_table_end();
|
||||
}
|
||||
|
||||
if (flag & PHP_CREDITS_WEB) {
|
||||
/* Website Team */
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_header(1, "PHP Website Team");
|
||||
php_info_print_table_row(1, "Hojtsy Gabor, Colin Viebrock, Jim Winstead");
|
||||
php_info_print_table_end();
|
||||
}
|
||||
|
||||
if (flag & PHP_CREDITS_FULLPAGE) {
|
||||
PUTS("</body></html>\n");
|
||||
}
|
||||
|
||||
@@ -19,6 +19,11 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef CREDITS_H
|
||||
#define CREDITS_H
|
||||
|
||||
#ifndef HAVE_CREDITS_DEFS
|
||||
#define HAVE_CREDITS_DEFS
|
||||
|
||||
#define PHP_CREDITS_GROUP (1<<0)
|
||||
#define PHP_CREDITS_GENERAL (1<<1)
|
||||
@@ -26,7 +31,12 @@
|
||||
#define PHP_CREDITS_MODULES (1<<3)
|
||||
#define PHP_CREDITS_DOCS (1<<4)
|
||||
#define PHP_CREDITS_FULLPAGE (1<<5)
|
||||
#define PHP_CREDITS_QA (1<<6)
|
||||
#define PHP_CREDITS_WEB (1<<7)
|
||||
#define PHP_CREDITS_ALL 0xFFFFFFFF
|
||||
|
||||
#endif /* HAVE_CREDITS_DEFS */
|
||||
|
||||
PHPAPI void php_print_credits(int flag);
|
||||
|
||||
#endif
|
||||
+1
-1
@@ -167,7 +167,7 @@ char *php_gethostbyname(char *name)
|
||||
return estrdup(inet_ntoa(in));
|
||||
}
|
||||
|
||||
#if HAVE_LIBBIND && !(defined(__BEOS__)||defined(PHP_WIN32))
|
||||
#if HAVE_RES_SEARCH && !(defined(__BEOS__)||defined(PHP_WIN32))
|
||||
|
||||
/* {{{ proto int checkdnsrr(string host [, string type])
|
||||
Check DNS records corresponding to a given Internet host name or IP address */
|
||||
|
||||
+2
-1
@@ -25,7 +25,8 @@
|
||||
PHP_FUNCTION(gethostbyaddr);
|
||||
PHP_FUNCTION(gethostbyname);
|
||||
PHP_FUNCTION(gethostbynamel);
|
||||
#if !defined(PHP_WIN32)||(HAVE_LIBBIND)
|
||||
|
||||
#if HAVE_RES_SEARCH && !(defined(__BEOS__)||defined(PHP_WIN32))
|
||||
PHP_FUNCTION(checkdnsrr);
|
||||
PHP_FUNCTION(getmxrr);
|
||||
#endif
|
||||
|
||||
@@ -1703,6 +1703,10 @@ PHP_FUNCTION(copy)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (PG(safe_mode) &&(!php_checkuid((*target)->value.str.val, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (php_copy_file(Z_STRVAL_PP(source), Z_STRVAL_PP(target))==SUCCESS) {
|
||||
RETURN_TRUE;
|
||||
} else {
|
||||
|
||||
@@ -92,7 +92,7 @@ static char *php_convert_to_decimal(double arg, int ndigits, int *decpt, int *si
|
||||
while (p1 < &cvt_buf[NDIG])
|
||||
*p++ = *p1++;
|
||||
} else if (arg > 0) {
|
||||
while ((fj = arg * 10) < 1) {
|
||||
while ((fj = arg * 10.0) < 0.9999999) {
|
||||
arg = fj;
|
||||
r2--;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#define PHP_INFO_LICENSE (1<<6)
|
||||
#define PHP_INFO_ALL 0xFFFFFFFF
|
||||
|
||||
#ifndef HAVE_CREDITS_DEFS
|
||||
#define HAVE_CREDITS_DEFS
|
||||
|
||||
#define PHP_CREDITS_GROUP (1<<0)
|
||||
#define PHP_CREDITS_GENERAL (1<<1)
|
||||
@@ -43,8 +45,11 @@
|
||||
#define PHP_CREDITS_DOCS (1<<4)
|
||||
#define PHP_CREDITS_FULLPAGE (1<<5)
|
||||
#define PHP_CREDITS_QA (1<<6)
|
||||
#define PHP_CREDITS_WEB (1<<7)
|
||||
#define PHP_CREDITS_ALL 0xFFFFFFFF
|
||||
|
||||
#endif /* HAVE_CREDITS_DEFS */
|
||||
|
||||
#define PHP_LOGO_GUID "PHPE9568F34-D428-11d2-A769-00AA001ACF42"
|
||||
#define PHP_EGG_LOGO_GUID "PHPE9568F36-D428-11d2-A769-00AA001ACF42"
|
||||
#define ZEND_LOGO_GUID "PHPE9568F35-D428-11d2-A769-00AA001ACF42"
|
||||
|
||||
@@ -157,6 +157,7 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush)
|
||||
orig_buffer->value.str.len = OG(active_ob_buffer).text_length;
|
||||
orig_buffer->type = IS_STRING;
|
||||
orig_buffer->refcount=2; /* don't let call_user_function() destroy our buffer */
|
||||
orig_buffer->is_ref=1;
|
||||
|
||||
ALLOC_INIT_ZVAL(z_status);
|
||||
Z_TYPE_P(z_status) = IS_LONG;
|
||||
|
||||
@@ -1105,6 +1105,9 @@ cygwin* | mingw*)
|
||||
with_gnu_ld=no
|
||||
fi
|
||||
;;
|
||||
openbsd*)
|
||||
with_gnu_ld=no
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
@@ -1402,10 +1405,21 @@ else
|
||||
;;
|
||||
|
||||
openbsd*)
|
||||
archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts'
|
||||
hardcode_libdir_flag_spec='-R$libdir'
|
||||
hardcode_direct=yes
|
||||
hardcode_shlibpath_var=no
|
||||
case "$host_os" in
|
||||
openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
|
||||
archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts'
|
||||
hardcode_libdir_flag_spec='-R$libdir'
|
||||
;;
|
||||
*)
|
||||
archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linkopts'
|
||||
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
|
||||
if [ "`/usr/bin/file /usr/lib/libc.so.* | grep ELF`" != "" ]; then
|
||||
export_dynamic_flag_spec='${wl}-E'
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
os2*)
|
||||
@@ -2019,13 +2033,10 @@ netbsd*)
|
||||
|
||||
openbsd*)
|
||||
version_type=sunos
|
||||
if test "$with_gnu_ld" = yes; then
|
||||
need_lib_prefix=no
|
||||
need_version=no
|
||||
fi
|
||||
library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix'
|
||||
finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
|
||||
shlibpath_var=LD_LIBRARY_PATH
|
||||
deplibs_check_method='pass_all'
|
||||
;;
|
||||
|
||||
os2*)
|
||||
|
||||
+1
-44
@@ -97,7 +97,7 @@ SAPI_API void sapi_free_header(sapi_header_struct *sapi_header)
|
||||
|
||||
SAPI_API void sapi_handle_post(void *arg SLS_DC)
|
||||
{
|
||||
if (SG(request_info).post_entry) {
|
||||
if (SG(request_info).post_entry && SG(request_info).content_type_dup) {
|
||||
SG(request_info).post_entry->post_handler(SG(request_info).content_type_dup, arg SLS_CC);
|
||||
if (SG(request_info).post_data) {
|
||||
efree(SG(request_info).post_data);
|
||||
@@ -538,49 +538,6 @@ SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry)
|
||||
zend_hash_del(&known_post_content_types, post_entry->content_type, post_entry->content_type_len+1);
|
||||
}
|
||||
|
||||
SAPI_API int sapi_add_post_entry(char *content_type
|
||||
, void (*post_reader)(SLS_D)
|
||||
, void (*post_handler)(char *content_type_dup
|
||||
, void *arg SLS_DC)) {
|
||||
|
||||
sapi_post_entry *post_entry = (sapi_post_entry *)malloc(sizeof(sapi_post_entry));
|
||||
if(!post_entry) return 0;
|
||||
|
||||
post_entry->content_type = strdup(content_type);
|
||||
if(post_entry->content_type == NULL) return 0;
|
||||
post_entry->content_type_len = strlen(content_type);
|
||||
post_entry->post_reader = post_reader;
|
||||
post_entry->post_handler = post_handler;
|
||||
|
||||
return zend_hash_add(&known_post_content_types
|
||||
, post_entry->content_type
|
||||
, post_entry->content_type_len+1
|
||||
, (void *) post_entry
|
||||
, sizeof(sapi_post_entry)
|
||||
, NULL
|
||||
);
|
||||
}
|
||||
|
||||
SAPI_API void sapi_remove_post_entry(char *content_type) {
|
||||
sapi_post_entry *post_entry;
|
||||
|
||||
zend_hash_find(&known_post_content_types
|
||||
,content_type
|
||||
,strlen(content_type)+1
|
||||
,(void **)&post_entry
|
||||
);
|
||||
|
||||
if(post_entry != NULL) {
|
||||
zend_hash_del(&known_post_content_types
|
||||
,content_type
|
||||
,strlen(content_type)+1
|
||||
);
|
||||
free(post_entry->content_type);
|
||||
free(post_entry);
|
||||
} else {
|
||||
php_error(E_WARNING,"unregister post handler failed in fdf");
|
||||
}
|
||||
}
|
||||
|
||||
SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(SLS_D))
|
||||
{
|
||||
|
||||
@@ -146,10 +146,6 @@ SAPI_API void sapi_handle_post(void *arg SLS_DC);
|
||||
|
||||
SAPI_API int sapi_register_post_entries(sapi_post_entry *post_entry);
|
||||
SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry);
|
||||
SAPI_API int sapi_add_post_entry(char *content_type
|
||||
, void (*post_reader)(SLS_D)
|
||||
, void (*post_handler)(char *content_type_dup, void *arg SLS_DC));
|
||||
SAPI_API void sapi_remove_post_entry(char *content_type);
|
||||
SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry);
|
||||
SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(SLS_D));
|
||||
|
||||
|
||||
+1
-4
@@ -870,10 +870,7 @@ int php_module_startup(sapi_module_struct *sf)
|
||||
which is always an internal extension and to be initialized
|
||||
ahead of all other internals
|
||||
*/
|
||||
if (php_startup_loaded_extensions() == FAILURE) {
|
||||
php_printf("Unable to start loaded modules\n");
|
||||
return FAILURE;
|
||||
}
|
||||
php_ini_delayed_modules_startup();
|
||||
|
||||
/* disable certain functions as requested by php.ini */
|
||||
php_disable_functions();
|
||||
|
||||
@@ -157,6 +157,7 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush)
|
||||
orig_buffer->value.str.len = OG(active_ob_buffer).text_length;
|
||||
orig_buffer->type = IS_STRING;
|
||||
orig_buffer->refcount=2; /* don't let call_user_function() destroy our buffer */
|
||||
orig_buffer->is_ref=1;
|
||||
|
||||
ALLOC_INIT_ZVAL(z_status);
|
||||
Z_TYPE_P(z_status) = IS_LONG;
|
||||
|
||||
+39
-64
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP version 4.0 |
|
||||
| PHP version 4.0 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2001 The PHP Group |
|
||||
| Copyright (c) 1997-2001 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. |
|
||||
| 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. |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Zeev Suraski <zeev@zend.com> |
|
||||
| Author: Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
@@ -24,15 +24,19 @@
|
||||
#include "ext/standard/dl.h"
|
||||
#include "zend_extensions.h"
|
||||
|
||||
/* True globals */
|
||||
static HashTable configuration_hash;
|
||||
PHPAPI char *php_ini_opened_path=NULL;
|
||||
|
||||
typedef struct _php_extension_lists {
|
||||
zend_llist engine;
|
||||
zend_llist functions;
|
||||
} php_extension_lists;
|
||||
|
||||
|
||||
/* True globals */
|
||||
static HashTable configuration_hash;
|
||||
PHPAPI char *php_ini_opened_path=NULL;
|
||||
static php_extension_lists extension_lists;
|
||||
|
||||
|
||||
static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type)
|
||||
{
|
||||
if (ini_entry->displayer) {
|
||||
@@ -121,9 +125,8 @@ static void pvalue_config_destructor(zval *pvalue)
|
||||
}
|
||||
}
|
||||
|
||||
static void php_config_ini_parser_cb(zval *arg1, zval *arg2, int callback_type, void *arg_list)
|
||||
static void php_config_ini_parser_cb(zval *arg1, zval *arg2, int callback_type, void *arg)
|
||||
{
|
||||
php_extension_lists *extension_lists =(php_extension_lists * )arg_list;
|
||||
switch (callback_type) {
|
||||
case ZEND_INI_PARSER_ENTRY: {
|
||||
zval *entry;
|
||||
@@ -132,12 +135,16 @@ static void php_config_ini_parser_cb(zval *arg1, zval *arg2, int callback_type,
|
||||
break;
|
||||
}
|
||||
if (!strcasecmp(Z_STRVAL_P(arg1), "extension")) { /* load function module */
|
||||
char *extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2));
|
||||
zend_llist_add_element(&extension_lists->functions, &extension_name);
|
||||
zval copy;
|
||||
|
||||
copy = *arg2;
|
||||
zval_copy_ctor(©);
|
||||
copy.refcount = 0;
|
||||
zend_llist_add_element(&extension_lists.functions, ©);
|
||||
} else if (!strcasecmp(Z_STRVAL_P(arg1), ZEND_EXTENSION_TOKEN)) { /* load Zend extension */
|
||||
char *extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2));
|
||||
|
||||
zend_llist_add_element(&extension_lists->engine, &extension_name);
|
||||
zend_llist_add_element(&extension_lists.engine, &extension_name);
|
||||
} else {
|
||||
zend_hash_update(&configuration_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, arg2, sizeof(zval), (void **) &entry);
|
||||
Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry));
|
||||
@@ -150,35 +157,12 @@ static void php_config_ini_parser_cb(zval *arg1, zval *arg2, int callback_type,
|
||||
}
|
||||
|
||||
|
||||
static zend_llist *php_load_extension_list = NULL;
|
||||
|
||||
static void php_startup_loaded_extension_cb(void *arg){
|
||||
zval *extension, ret;
|
||||
|
||||
MAKE_STD_ZVAL(extension);
|
||||
ZVAL_STRING(extension,*((char **) arg),0);
|
||||
php_dl(extension, MODULE_PERSISTENT, &ret);
|
||||
FREE_ZVAL(extension);
|
||||
}
|
||||
|
||||
int php_startup_loaded_extensions(void)
|
||||
{
|
||||
if(php_load_extension_list) {
|
||||
zend_llist_apply(php_load_extension_list, php_startup_loaded_extension_cb);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
static void php_load_function_extension_cb(void *arg)
|
||||
{
|
||||
char *extension = estrdup(*((char **)arg));
|
||||
zval *extension = (zval *) arg;
|
||||
zval zval;
|
||||
|
||||
if(! php_load_extension_list) {
|
||||
php_load_extension_list=(zend_llist*)malloc(sizeof(zend_llist));
|
||||
zend_llist_init(php_load_extension_list, sizeof(char **), (void(*)(void *))free_estring, 1);
|
||||
}
|
||||
|
||||
zend_llist_add_element(php_load_extension_list, &extension);
|
||||
php_dl(extension, MODULE_PERSISTENT, &zval);
|
||||
}
|
||||
|
||||
|
||||
@@ -195,24 +179,14 @@ int php_init_config(char *php_ini_path_override)
|
||||
char *open_basedir;
|
||||
int free_ini_search_path=0;
|
||||
zend_file_handle fh;
|
||||
php_extension_lists extension_lists;
|
||||
PLS_FETCH();
|
||||
|
||||
if (zend_hash_init(&configuration_hash, 0, NULL, (dtor_func_t) pvalue_config_destructor, 1)==FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
/* some extensions may be configured by ini entries
|
||||
if we would load them right away upon finding an extension
|
||||
entry we would have to use the config cache directly as
|
||||
the ini mechanism is not finaly initialized yet and we
|
||||
would introduce a order dependency in the ini file.
|
||||
to avoid this we temporarily store the extensions to
|
||||
be loaded in linked lists and process theese immediately
|
||||
*after* we have finished setting up the ini mechanism
|
||||
*/
|
||||
zend_llist_init(&extension_lists.engine , sizeof(char **), (void(*)(void *))free_estring, 1);
|
||||
zend_llist_init(&extension_lists.functions, sizeof(char **), (void(*)(void *))free_estring, 1);
|
||||
zend_llist_init(&extension_lists.engine, sizeof(zval), free_estring, 1);
|
||||
zend_llist_init(&extension_lists.functions, sizeof(zval), ZVAL_DESTRUCTOR, 1);
|
||||
|
||||
safe_mode_state = PG(safe_mode);
|
||||
open_basedir = PG(open_basedir);
|
||||
@@ -268,15 +242,6 @@ int php_init_config(char *php_ini_path_override)
|
||||
fh.filename = php_ini_opened_path;
|
||||
|
||||
zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
|
||||
|
||||
/* now that we are done with the configuration settings
|
||||
we can load all requested extensions
|
||||
*/
|
||||
zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb);
|
||||
zend_llist_apply(&extension_lists.functions, php_load_function_extension_cb);
|
||||
|
||||
zend_llist_destroy(&extension_lists.engine);
|
||||
zend_llist_destroy(&extension_lists.functions);
|
||||
|
||||
if (php_ini_opened_path) {
|
||||
zval tmp;
|
||||
@@ -302,6 +267,16 @@ int php_shutdown_config(void)
|
||||
}
|
||||
|
||||
|
||||
void php_ini_delayed_modules_startup(void)
|
||||
{
|
||||
zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb);
|
||||
zend_llist_apply(&extension_lists.functions, php_load_function_extension_cb);
|
||||
|
||||
zend_llist_destroy(&extension_lists.engine);
|
||||
zend_llist_destroy(&extension_lists.functions);
|
||||
}
|
||||
|
||||
|
||||
zval *cfg_get_entry(char *name, uint name_length)
|
||||
{
|
||||
zval *tmp;
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@
|
||||
|
||||
int php_init_config(char *php_ini_path_override);
|
||||
int php_shutdown_config(void);
|
||||
int php_startup_loaded_extensions(void);
|
||||
void php_ini_delayed_modules_startup(void);
|
||||
zval *cfg_get_entry(char *name, uint name_length);
|
||||
|
||||
#define PHP_INI_USER ZEND_INI_USER
|
||||
|
||||
@@ -1,283 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP version 4.0 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997, 1998, 1999, 2000 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: Sander Steffann (sander@steffann.nl) |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#include "php.h"
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifndef MAXSYMLINKS
|
||||
#define MAXSYMLINKS 32
|
||||
#endif
|
||||
|
||||
#ifndef S_ISDIR
|
||||
#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
char *php_realpath(char *path, char resolved_path[]);
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
#define IS_SLASH(p) ((p) == '/' || (p) == '\\')
|
||||
#else
|
||||
#define IS_SLASH(p) ((p) == '/')
|
||||
#endif
|
||||
|
||||
char *php_realpath(char *path, char resolved_path []) {
|
||||
char path_construction[MAXPATHLEN]; /* We build the result in here */
|
||||
char *writepos; /* Position to write next char */
|
||||
|
||||
char path_copy[MAXPATHLEN]; /* A work-copy of the path */
|
||||
char *workpos; /* working position in *path */
|
||||
|
||||
#if !defined(PHP_WIN32)
|
||||
char buf[MAXPATHLEN]; /* Buffer for readlink */
|
||||
int linklength; /* The result from readlink */
|
||||
#endif
|
||||
int linkcount = 0; /* Count symlinks to avoid loops */
|
||||
|
||||
struct stat filestat; /* result from stat */
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
char *temppos; /* position while counting '.' */
|
||||
int dotcount; /* number of '.' */
|
||||
int t; /* counter */
|
||||
#endif
|
||||
|
||||
/* Set the work-position to the beginning of the given path */
|
||||
strcpy(path_copy, path);
|
||||
workpos = path_copy;
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
/* Find out where we start - Windows version */
|
||||
if (IS_SLASH(*workpos)) {
|
||||
/* We start at the root of the current drive */
|
||||
/* Get the current directory */
|
||||
if (V_GETCWD(path_construction, MAXPATHLEN-1) == NULL) {
|
||||
/* Unable to get cwd */
|
||||
resolved_path[0] = 0;
|
||||
return NULL;
|
||||
}
|
||||
/* We only need the first three chars (for example "C:\") */
|
||||
path_construction[3] = 0;
|
||||
workpos++;
|
||||
} else if (workpos[1] == ':') {
|
||||
/* A drive-letter is specified, copy it */
|
||||
strncpy(path_construction, path, 2);
|
||||
strcat(path_construction, "\\");
|
||||
workpos++;
|
||||
workpos++;
|
||||
} else {
|
||||
/* Use the current directory */
|
||||
if (V_GETCWD(path_construction, MAXPATHLEN-1) == NULL) {
|
||||
/* Unable to get cwd */
|
||||
resolved_path[0] = 0;
|
||||
return NULL;
|
||||
}
|
||||
strcat(path_construction, "\\");
|
||||
}
|
||||
#else
|
||||
/* Find out where we start - Unix version */
|
||||
if (*workpos == '/') {
|
||||
/* We start at the root */
|
||||
strcpy(path_construction, "/");
|
||||
workpos++;
|
||||
} else {
|
||||
/* Use the current directory */
|
||||
if (V_GETCWD(path_construction, MAXPATHLEN-1) == NULL) {
|
||||
/* Unable to get cwd */
|
||||
resolved_path[0] = 0;
|
||||
return NULL;
|
||||
}
|
||||
strcat(path_construction, "/");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Set the next-char-position */
|
||||
writepos = &path_construction[strlen(path_construction)];
|
||||
|
||||
/* Go to the end, then stop */
|
||||
while(*workpos != 0) {
|
||||
/* Strip (back)slashes */
|
||||
while(IS_SLASH(*workpos)) workpos++;
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
/* reset dotcount */
|
||||
dotcount = 0;
|
||||
|
||||
/* Look for .. */
|
||||
if ((workpos[0] == '.') && (workpos[1] != 0)) {
|
||||
/* Windows accepts \...\ as \..\..\, \....\ as \..\..\..\, etc */
|
||||
/* At least Win98 does */
|
||||
|
||||
temppos = workpos;
|
||||
while(*temppos++ == '.') {
|
||||
dotcount++;
|
||||
if (!IS_SLASH(*temppos) && (*temppos != 0) && (*temppos != '.')) {
|
||||
/* This is not a /../ component, but a filename that starts with '.' */
|
||||
dotcount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Go back dotcount-1 times */
|
||||
for (t=0 ; t<(dotcount-1) ; t++) {
|
||||
workpos++; /* move to next '.' */
|
||||
|
||||
/* Can we still go back? */
|
||||
if ((writepos-3) <= path_construction) return NULL;
|
||||
|
||||
/* Go back */
|
||||
writepos--; /* move to '\' */
|
||||
writepos--;
|
||||
while(!IS_SLASH(*writepos)) writepos--; /* skip until previous '\\' */
|
||||
}
|
||||
workpos++;
|
||||
}
|
||||
|
||||
/* No special case */
|
||||
if (dotcount == 0) {
|
||||
/* Append */
|
||||
while(!IS_SLASH(*workpos) && (*workpos != 0)) {
|
||||
*writepos++ = *workpos++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Just one '.', go to next element */
|
||||
if (dotcount == 1) {
|
||||
while(!IS_SLASH(*workpos) && (*workpos != 0)) {
|
||||
*workpos++;
|
||||
}
|
||||
|
||||
/* Avoid double \ in the result */
|
||||
writepos--;
|
||||
}
|
||||
|
||||
/* If it was a directory, append a slash */
|
||||
if (IS_SLASH(*workpos)) {
|
||||
*writepos++ = *workpos++;
|
||||
}
|
||||
*writepos = 0;
|
||||
#else /* defined(PHP_WIN32) */
|
||||
/* Look for .. */
|
||||
if ((workpos[0] == '.') && (workpos[1] != 0)) {
|
||||
if ((workpos[1] == '.') && ((workpos[2] == '/') || (workpos[2] == 0))) {
|
||||
/* One directory back */
|
||||
/* Set pointers to right position */
|
||||
workpos++; /* move to second '.' */
|
||||
workpos++; /* move to '/' */
|
||||
|
||||
/* Only apply .. if not in root */
|
||||
if ((writepos-1) > path_construction) {
|
||||
writepos--; /* move to '/' */
|
||||
while(*--writepos != '/') ; /* skip until previous '/' */
|
||||
}
|
||||
} else {
|
||||
if (workpos[1] == '/') {
|
||||
/* Found a /./ skip it */
|
||||
workpos++; /* move to '/' */
|
||||
|
||||
/* Avoid double / in the result */
|
||||
writepos--;
|
||||
} else {
|
||||
/* No special case, the name just started with a . */
|
||||
/* Append */
|
||||
while((*workpos != '/') && (*workpos != 0)) {
|
||||
*writepos++ = *workpos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* No special case */
|
||||
/* Append */
|
||||
while((*workpos != '/') && (*workpos != 0)) {
|
||||
*writepos++ = *workpos++;
|
||||
}
|
||||
}
|
||||
|
||||
#if HAVE_SYMLINK
|
||||
/* We are going to use path_construction, so close it */
|
||||
*writepos = 0;
|
||||
|
||||
/* Check the current location to see if it is a symlink */
|
||||
if((linklength = readlink(path_construction, buf, MAXPATHLEN)) != -1) {
|
||||
/* Check linkcount */
|
||||
if (linkcount > MAXSYMLINKS) return NULL;
|
||||
|
||||
/* Count this symlink */
|
||||
linkcount++;
|
||||
|
||||
/* Set end of buf */
|
||||
buf[linklength] = 0;
|
||||
|
||||
/* Check for overflow */
|
||||
if ((strlen(workpos) + strlen(buf) + 1) >= MAXPATHLEN) return NULL;
|
||||
|
||||
/* Remove the symlink-component wrom path_construction */
|
||||
writepos--; /* move to '/' */
|
||||
while(*--writepos != '/') ; /* skip until previous '/' */
|
||||
*++writepos = 0; /* end of string after '/' */
|
||||
|
||||
/* If the symlink starts with a '/', empty path_construction */
|
||||
if (*buf == '/') {
|
||||
*path_construction = 0;
|
||||
writepos = path_construction;
|
||||
}
|
||||
|
||||
/* Insert symlink into path_copy */
|
||||
strcat(buf, workpos);
|
||||
strcpy(path_copy, buf);
|
||||
workpos = path_copy;
|
||||
}
|
||||
#endif /* HAVE_SYMLINK */
|
||||
|
||||
/* If it was a directory, append a slash */
|
||||
if (*workpos == '/') {
|
||||
*writepos++ = *workpos++;
|
||||
}
|
||||
*writepos = 0;
|
||||
#endif /* defined(PHP_WIN32) */
|
||||
}
|
||||
|
||||
/* Check if the resolved path is a directory */
|
||||
if (V_STAT(path_construction, &filestat) != 0) {
|
||||
if (errno != ENOENT) return NULL;
|
||||
} else {
|
||||
if (S_ISDIR(filestat.st_mode)) {
|
||||
/* It's a directory, append a / if needed */
|
||||
if (*(writepos-1) != '/') {
|
||||
/* Check for overflow */
|
||||
if ((strlen(workpos) + 2) >= MAXPATHLEN) {
|
||||
return NULL;
|
||||
}
|
||||
*writepos++ = '/';
|
||||
*writepos = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
strcpy(resolved_path, path_construction);
|
||||
return resolved_path;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
+2
-13
@@ -277,13 +277,7 @@ void php_treat_data(int arg, char *str, zval* destArray ELS_DC PLS_DC SLS_DC)
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg == PARSE_COOKIE) {
|
||||
var = php_strtok_r(res, ";", &strtok_buf);
|
||||
} else if (arg == PARSE_POST) {
|
||||
var = php_strtok_r(res, "&", &strtok_buf);
|
||||
} else {
|
||||
var = php_strtok_r(res, PG(arg_separator), &strtok_buf);
|
||||
}
|
||||
var = php_strtok_r(res, ";&", &strtok_buf);
|
||||
|
||||
while (var) {
|
||||
val = strchr(var, '=');
|
||||
@@ -295,11 +289,7 @@ void php_treat_data(int arg, char *str, zval* destArray ELS_DC PLS_DC SLS_DC)
|
||||
val_len = php_url_decode(val, strlen(val));
|
||||
php_register_variable_safe(var, val, val_len, array_ptr ELS_CC PLS_CC);
|
||||
}
|
||||
if (arg == PARSE_COOKIE) {
|
||||
var = php_strtok_r(NULL, ";", &strtok_buf);
|
||||
} else {
|
||||
var = php_strtok_r(NULL, PG(arg_separator), &strtok_buf);
|
||||
}
|
||||
var = php_strtok_r(NULL, ";&", &strtok_buf);
|
||||
}
|
||||
if (free_buffer) {
|
||||
efree(res);
|
||||
@@ -307,7 +297,6 @@ void php_treat_data(int arg, char *str, zval* destArray ELS_DC PLS_DC SLS_DC)
|
||||
}
|
||||
|
||||
|
||||
|
||||
void php_import_environment_variables(zval *array_ptr ELS_DC PLS_DC)
|
||||
{
|
||||
char **env, *p, *t;
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
/* automatically generated by configure */
|
||||
/* edit configure.in to change version number */
|
||||
#define PHP_VERSION "4.0.5-dev"
|
||||
#define PHP_VERSION "4.0.5RC4"
|
||||
+46
-37
@@ -25,12 +25,16 @@ require_once "Cache/Error.php";
|
||||
*
|
||||
* TODO: Simple usage example goes here.
|
||||
*
|
||||
* WARNING: No File/DB-Table-Row locking is implemented yet,
|
||||
* it's possible, that you get corrupted data-entries under
|
||||
* bad circumstances (especially with the file container)
|
||||
*
|
||||
* @author Ulf Wendel <ulf.wendel@phpdoc.de>
|
||||
* @version $Id$
|
||||
* @package Cache
|
||||
* @access public
|
||||
* @access public
|
||||
*/
|
||||
class Cache {
|
||||
class Cache extends PEAR {
|
||||
|
||||
/**
|
||||
* Disables the caching.
|
||||
@@ -45,8 +49,8 @@ class Cache {
|
||||
/**
|
||||
* Garbage collection: probability in seconds
|
||||
*
|
||||
* If set to a value above 0 a garbage collection will
|
||||
* flush all cache entries older than the specified number
|
||||
* If set to a value above 0 a garbage collection will
|
||||
* flush all cache entries older than the specified number
|
||||
* of seconds.
|
||||
*
|
||||
* @var integer
|
||||
@@ -68,35 +72,40 @@ class Cache {
|
||||
|
||||
/**
|
||||
* Storage container object.
|
||||
*
|
||||
*
|
||||
* @var object Cache_Container
|
||||
*/
|
||||
*/
|
||||
var $container;
|
||||
|
||||
//
|
||||
// public methods
|
||||
//
|
||||
|
||||
/**
|
||||
/**
|
||||
*
|
||||
* @param string Name of storage container class
|
||||
* @param array Array with storage class dependend config options
|
||||
*/
|
||||
function Cache($storage_driver, $storage_options = "")
|
||||
{
|
||||
$this->PEAR();
|
||||
$storage_driver = strtolower($storage_driver);
|
||||
$storage_class = 'Cache_Container_' . $storage_driver;
|
||||
$storage_classfile = 'Cache/Container/' . $storage_driver . '.php';
|
||||
|
||||
include_once $storage_classfile;
|
||||
$this->container = new $storage_class($storage_options);
|
||||
}
|
||||
|
||||
//deconstructor
|
||||
function _Cache()
|
||||
{
|
||||
$this->garbageCollection();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the requested dataset it if exists and is not expired
|
||||
*
|
||||
*
|
||||
* @param string dataset ID
|
||||
* @param string cache group
|
||||
* @return mixed cached data or NULL on failure
|
||||
@@ -105,16 +114,16 @@ class Cache {
|
||||
function get($id, $group = "default") {
|
||||
if ($this->no_cache)
|
||||
return "";
|
||||
|
||||
|
||||
if ($this->isCached($id, $group) && !$this->isExpired($id, $group))
|
||||
return $this->load($id, $group);
|
||||
|
||||
return NULL;
|
||||
|
||||
return NULL;
|
||||
} // end func get
|
||||
|
||||
/**
|
||||
* Stores the given data in the cache.
|
||||
*
|
||||
*
|
||||
* @param string dataset ID used as cache identifier
|
||||
* @param mixed data to cache
|
||||
* @param integer lifetime of the cached data in seconds - 0 for endless
|
||||
@@ -125,13 +134,13 @@ class Cache {
|
||||
function save($id, $data, $expires = 0, $group = "default") {
|
||||
if ($this->no_cache)
|
||||
return true;
|
||||
|
||||
|
||||
return $this->container->save($id, $data, $expires, $group, "");
|
||||
} // end func save
|
||||
|
||||
/**
|
||||
* Stores a dataset without additional userdefined data.
|
||||
*
|
||||
*
|
||||
* @param string dataset ID
|
||||
* @param mixed data to store
|
||||
* @param string additional userdefined data
|
||||
@@ -151,16 +160,16 @@ class Cache {
|
||||
|
||||
/**
|
||||
* Loads the given ID from the cache.
|
||||
*
|
||||
*
|
||||
* @param string dataset ID
|
||||
* @param string cache group
|
||||
* @return mixed cached data or NULL on failure
|
||||
* @return mixed cached data or NULL on failure
|
||||
* @access public
|
||||
*/
|
||||
function load($id, $group = "default") {
|
||||
if ($this->no_cache)
|
||||
return "";
|
||||
|
||||
|
||||
return $this->container->load($id, $group);
|
||||
} // end func load
|
||||
|
||||
@@ -176,13 +185,13 @@ class Cache {
|
||||
function getUserdata($id, $group = "default") {
|
||||
if ($this->no_cache)
|
||||
return "";
|
||||
|
||||
|
||||
return $this->container->getUserdata($id, $group);
|
||||
} // end func getUserdata
|
||||
|
||||
/**
|
||||
* Removes the specified dataset from the cache.
|
||||
*
|
||||
*
|
||||
* @param string dataset ID
|
||||
* @param string cache group
|
||||
* @return boolean
|
||||
@@ -191,28 +200,28 @@ class Cache {
|
||||
function delete($id, $group = "default") {
|
||||
if ($this->no_cache)
|
||||
return true;
|
||||
|
||||
|
||||
return $this->container->delete($id, $group);
|
||||
} // end func delete
|
||||
|
||||
/**
|
||||
* Flushes the cache - removes all data from it
|
||||
*
|
||||
*
|
||||
* @param string cache group, if empty all groups will be flashed
|
||||
* @return integer number of removed datasets
|
||||
*/
|
||||
function flush($group = "") {
|
||||
if ($this->no_cache)
|
||||
return true;
|
||||
|
||||
|
||||
return $this->container->flush($group);
|
||||
} // end func flush
|
||||
|
||||
/**
|
||||
* Checks if a dataset exists.
|
||||
*
|
||||
*
|
||||
* Note: this does not say that the cached data is not expired!
|
||||
*
|
||||
*
|
||||
* @param string dataset ID
|
||||
* @param string cache group
|
||||
* @return boolean
|
||||
@@ -221,20 +230,20 @@ class Cache {
|
||||
function isCached($id, $group = "default") {
|
||||
if ($this->no_cache)
|
||||
return false;
|
||||
|
||||
|
||||
return $this->container->isCached($id, $group);
|
||||
} // end func isCached
|
||||
|
||||
/**
|
||||
* Checks if a dataset is expired
|
||||
*
|
||||
*
|
||||
* @param string dataset ID
|
||||
* @param string cache group
|
||||
* @param integer maximum age for the cached data in seconds - 0 for endless
|
||||
* If the cached data is older but the given lifetime it will
|
||||
* be removed from the cache. You don't have to provide this
|
||||
* argument if you call isExpired(). Every dataset knows
|
||||
* it's expire date and will be removed automatically. Use
|
||||
* be removed from the cache. You don't have to provide this
|
||||
* argument if you call isExpired(). Every dataset knows
|
||||
* it's expire date and will be removed automatically. Use
|
||||
* this only if you know what you're doing...
|
||||
* @return boolean
|
||||
* @access public
|
||||
@@ -242,13 +251,13 @@ class Cache {
|
||||
function isExpired($id, $group = "default", $max_age = 0) {
|
||||
if ($this->no_cache)
|
||||
return true;
|
||||
|
||||
|
||||
return $this->container->isExpired($id, $group, $max_age);
|
||||
} // end func isExpired
|
||||
|
||||
/**
|
||||
* Generates a "unique" ID for the given value
|
||||
*
|
||||
*
|
||||
* This is a quick but dirty hack to get a "unique" ID for a any kind of variable.
|
||||
* ID clashes might occur from time to time although they are extreme unlikely!
|
||||
*
|
||||
@@ -263,24 +272,24 @@ class Cache {
|
||||
|
||||
/**
|
||||
* Calls the garbage collector of the storage object with a certain probability
|
||||
*
|
||||
*
|
||||
* @param boolean Force a garbage collection run?
|
||||
* @see $gc_probability, $gc_time
|
||||
*/
|
||||
function garbageCollection($force = false) {
|
||||
static $last_run = 0;
|
||||
|
||||
|
||||
if ($this->no_cache)
|
||||
return;
|
||||
|
||||
srand((double) microtime() * 1000000);
|
||||
|
||||
|
||||
// time and probability based
|
||||
if (($force) || ($last_run && $last_run < time() + $this->gc_time) || (rand(1, 100) < $this->gc_probability)) {
|
||||
$this->container->garbageCollection();
|
||||
$last_run = time();
|
||||
}
|
||||
} // end func garbageCollection
|
||||
|
||||
} // end class cache
|
||||
|
||||
} // end class cache
|
||||
?>
|
||||
+120
-42
@@ -21,6 +21,8 @@
|
||||
/*
|
||||
* TODO:
|
||||
* - look for test-specific php.ini files
|
||||
* - implement module skipping for PEAR
|
||||
* - do not test PEAR components if base class and/or component class cannot be instanciated
|
||||
*/
|
||||
|
||||
ob_implicit_flush();
|
||||
@@ -30,6 +32,9 @@ define('TEST_FAILED', -1);
|
||||
define('TEST_SKIPPED', -2);
|
||||
define('TEST_INTERNAL_ERROR', -3);
|
||||
|
||||
define('EXT_DIR_NAME','/php4/ext/');
|
||||
define('EXT_DIR_NAME_LEN',strlen(EXT_DIR_NAME));
|
||||
|
||||
initialize();
|
||||
/*
|
||||
$opts = parse_options(&$argc, &$argv);
|
||||
@@ -67,6 +72,43 @@ function dowriteln($str)
|
||||
dowrite("$str\n");
|
||||
}
|
||||
|
||||
function create_compiled_in_modules_list() {
|
||||
global $php,$compiled_in_modules;
|
||||
$ret=`$php -m`;
|
||||
|
||||
$compiled_in_modules=explode("\n",$ret);
|
||||
foreach ($compiled_in_modules AS $key => $value) {
|
||||
if (!$value
|
||||
|| strchr($value,' ') ) unset($compiled_in_modules[$key]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function extract_module_name_from_path($path) {
|
||||
if ($pos1=strpos($path,EXT_DIR_NAME)) {
|
||||
$pos3=strpos($path,'/',$pos1+EXT_DIR_NAME_LEN);
|
||||
return substr($path,$pos2=$pos1+EXT_DIR_NAME_LEN,$pos3-$pos2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function create_found_tests_4_modules_list() {
|
||||
global $modules_2_test,$testdirs;
|
||||
|
||||
foreach ($testdirs AS $path) {
|
||||
if ($mod_name=extract_module_name_from_path($path))
|
||||
$modules_2_test[$mod_name]=TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
function create_modules_2_test_list() {
|
||||
global $compiled_in_modules,$modules_2_test,$modules_available;
|
||||
foreach ($compiled_in_modules AS $value)
|
||||
if ($modules_2_test[$value]) $modules_available[]=$value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function initialize()
|
||||
{
|
||||
global $term, $windows_p, $php, $skip, $testdirs, $tmpfile,
|
||||
@@ -87,19 +129,22 @@ function initialize()
|
||||
|
||||
$windows_p = (substr(php_uname(), 0, 7) == "Windows");
|
||||
if ($windows_p) {
|
||||
if (file_exists('Release_TS_inline/php.exe')) {
|
||||
$php = 'Release_TS_inline\php.exe';
|
||||
} elseif (file_exists('Release_TS/php.exe')) {
|
||||
$php = 'Release_TS\php.exe';
|
||||
if (file_exists('Release_TS_inline\\php.exe')) {
|
||||
$php = 'Release_TS_inline\\php.exe';
|
||||
} elseif (file_exists('Release_TS\\php.exe')) {
|
||||
$php = 'Release_TS\\php.exe';
|
||||
} else {
|
||||
$php = "./php.exe";
|
||||
$php=trim($windows_p ? `cd`:`pwd`).'\\php';
|
||||
}
|
||||
} else {
|
||||
$php = $GLOBALS["TOP_BUILDDIR"]."/php";
|
||||
// $php = $GLOBALS["TOP_BUILDDIR"]."/php"; // where should be the origin of this variable
|
||||
$php=trim(`pwd`).'/php';
|
||||
}
|
||||
|
||||
create_compiled_in_modules_list();
|
||||
|
||||
if (!is_executable($php)) {
|
||||
dowriteln("PHP CGI binary ($php) not executable.");
|
||||
dowriteln("PHP CGI binary ($php) is not executable.");
|
||||
dowriteln("Please compile PHP as a CGI executable and try again.");
|
||||
exit;
|
||||
}
|
||||
@@ -139,7 +184,7 @@ function &parse_options(&$argc, &$argv)
|
||||
function do_testing($argc, &$argv)
|
||||
{
|
||||
global $term, $windows_p, $php, $skip, $testdirs, $tmpfile, $opts,
|
||||
$skipped, $failed, $passed, $total, $term_bold, $term_norm;
|
||||
$skipped, $failed, $passed, $total, $term_bold, $term_norm, $skipped_extensions;
|
||||
|
||||
if ($argc > 1) {
|
||||
if (is_dir($argv[1])) {
|
||||
@@ -162,11 +207,15 @@ function do_testing($argc, &$argv)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$dir = $GLOBALS["TOP_SRCDIR"];
|
||||
// $dir = $GLOBALS["TOP_SRCDIR"]; // XXX ??? where should this variable be set?
|
||||
$dir=str_replace('\\','/',trim(($windows_p ? `cd`:`pwd`)));
|
||||
}
|
||||
|
||||
if (isset($dir) && $dir) {
|
||||
find_testdirs($dir);
|
||||
|
||||
create_found_tests_4_modules_list();
|
||||
create_modules_2_test_list();
|
||||
|
||||
for ($i = 0; $i < sizeof($testdirs); $i++) {
|
||||
run_tests_in_dir($testdirs[$i]);
|
||||
}
|
||||
@@ -194,6 +243,9 @@ function do_testing($argc, &$argv)
|
||||
dowriteln(sprintf("Tests skipped: %4d (%s%%)", $skipped, $skipped_pstr));
|
||||
dowriteln(sprintf("Tests failed: %4d (%s%%)", $failed, $failed_pstr));
|
||||
dowriteln(sprintf("Tests passed: %4d (%s%%)", $passed, $passed_pstr));
|
||||
dowriteln("=============================");
|
||||
dowriteln("Skipped ".sizeof($skipped_extensions)." extensions.");
|
||||
|
||||
}
|
||||
|
||||
function find_testdirs($dir = '.', $first_pass = true)
|
||||
@@ -210,20 +262,27 @@ function find_testdirs($dir = '.', $first_pass = true)
|
||||
}
|
||||
while ($ent = readdir($dp)) {
|
||||
$path = "$dir/$ent";
|
||||
if ((isset($skip[$ent]) && $skip[$ent]) || substr($ent, 0, 1) == "." || !is_dir($path)) {
|
||||
|
||||
if ((isset($skip[$ent]) && $skip[$ent])
|
||||
|| substr($ent, 0, 1) == "."
|
||||
|| !is_dir($path)
|
||||
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (strstr("/$path/", "/tests/")) {
|
||||
$testdirs[] = $path;
|
||||
}
|
||||
find_testdirs($path, false);
|
||||
}
|
||||
closedir($dp);
|
||||
|
||||
}
|
||||
|
||||
function run_tests_in_dir($dir = '.')
|
||||
{
|
||||
global $skip, $skipped, $failed, $passed, $total, $opts, $tests_in_dir;
|
||||
global $skip, $skipped, $failed, $passed, $total, $opts, $tests_in_dir,$modules_available,$skipped_extensions;
|
||||
$dp = opendir($dir);
|
||||
if (!$dp) {
|
||||
print "Warning: could not run tests in $dir\n";
|
||||
@@ -245,29 +304,39 @@ function run_tests_in_dir($dir = '.')
|
||||
if (sizeof($testfiles) == 0) {
|
||||
return;
|
||||
}
|
||||
dowriteln("%bRunning tests in $dir%B");
|
||||
dowriteln("=================".str_repeat("=", strlen($dir)));
|
||||
sort($testfiles);
|
||||
for ($i = 0; $i < sizeof($testfiles); $i++) {
|
||||
switch (run_test($testfiles[$i])) {
|
||||
case TEST_SKIPPED:
|
||||
case TEST_INTERNAL_ERROR:
|
||||
$skipped++;
|
||||
break;
|
||||
case TEST_FAILED:
|
||||
$failed++;
|
||||
break;
|
||||
case TEST_PASSED:
|
||||
$passed++;
|
||||
break;
|
||||
|
||||
if ($mod_name=extract_module_name_from_path($dir)) {
|
||||
if ($ext_found=in_array($mod_name,$modules_available))
|
||||
dowriteln("Testing extension: $mod_name");
|
||||
else $skipped_extensions[$mod_name]=TRUE;
|
||||
}
|
||||
|
||||
if ($ext_found!==FALSE) {
|
||||
dowriteln("%bRunning tests in $dir%B");
|
||||
dowriteln("=================".str_repeat("=", strlen($dir)));
|
||||
sort($testfiles);
|
||||
for ($i = 0; $i < sizeof($testfiles); $i++) {
|
||||
switch (run_test($testfiles[$i])) {
|
||||
case TEST_SKIPPED:
|
||||
case TEST_INTERNAL_ERROR:
|
||||
$skipped++;
|
||||
break;
|
||||
case TEST_FAILED:
|
||||
$failed++;
|
||||
break;
|
||||
case TEST_PASSED:
|
||||
$passed++;
|
||||
break;
|
||||
}
|
||||
$total++;
|
||||
}
|
||||
$total++;
|
||||
if ($oskipped + (isset($tests_in_dir[$dir])?$tests_in_dir[$dir]:0) == $skipped) {
|
||||
$skippednow = $skipped - $oskipped;
|
||||
dowriteln("[all $skippednow test(s) skipped]");
|
||||
}
|
||||
dowriteln("");
|
||||
}
|
||||
if ($oskipped + (isset($tests_in_dir[$dir])?$tests_in_dir[$dir]:0) == $skipped) {
|
||||
$skippednow = $skipped - $oskipped;
|
||||
dowriteln("[all $skippednow test(s) skipped]");
|
||||
}
|
||||
dowriteln("");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -286,7 +355,7 @@ function delete_tmpfiles()
|
||||
reset($tmpfile);
|
||||
while (list($k, $v) = each($tmpfile)) {
|
||||
if (file_exists($v)) {
|
||||
//print "unlink($v): "; var_dump(unlink($v));
|
||||
//print "unlink($v): "; var_dump(unlink($v));
|
||||
unlink($v);
|
||||
}
|
||||
}
|
||||
@@ -301,26 +370,30 @@ function delete_tmpfiles()
|
||||
* @return bool whether the files were "equal"
|
||||
*/
|
||||
function compare_results($file1, $file2)
|
||||
{
|
||||
{
|
||||
$data1 = $data2 = "";
|
||||
if (!($fp1 = @fopen($file1, "r")) || !($fp2 = @fopen($file2, "r"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (!(feof($fp1) || feof($fp2))) {
|
||||
if (!feof($fp1) && trim($line1 = fgets($fp1, 10240)) != "") {
|
||||
//print "adding line1 $line1\n";
|
||||
$data1 .= $line1;
|
||||
|
||||
$data1 .= trim($line1);
|
||||
}
|
||||
if (!feof($fp2) && trim($line2 = fgets($fp2, 10240)) != "") {
|
||||
//print "adding line2 $line2\n";
|
||||
$data2 .= $line2;
|
||||
|
||||
$data2 .= trim($line2);
|
||||
}
|
||||
}
|
||||
fclose($fp1);
|
||||
fclose($fp2);
|
||||
if (trim($data1) != trim($data2)) {
|
||||
//print "data1=";var_dump($data1);
|
||||
//print "data2=";var_dump($data2);
|
||||
if ((trim($data1) != trim($data2))
|
||||
|| ($data1=='' && $data2=='')) {
|
||||
//print "data1=";var_dump($data1);
|
||||
//print "data2=";var_dump($data2);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -341,11 +414,13 @@ function run_test($file)
|
||||
$tmpfile["FILE"] = tempnam($tmpdir, $tmpfix);
|
||||
$tmpfile["SKIPIF"] = tempnam($tmpdir, $tmpfix);
|
||||
$tmpfile["POST"] = tempnam($tmpdir, $tmpfix);
|
||||
|
||||
$tmpfile["EXPECT"] = tempnam($tmpdir, $tmpfix);
|
||||
$tmpfile["OUTPUT"] = tempnam($tmpdir, $tmpfix);
|
||||
|
||||
|
||||
while ($line = fgets($fp, 4096)) {
|
||||
if (preg_match('/^--([A-Z]+)--$/', $line, $matches)) {
|
||||
if (preg_match('/^--([A-Z]+)--/', $line, $matches)) {
|
||||
$var = $matches[1];
|
||||
if (isset($tmpfile[$var]) && $tmpfile[$var]) {
|
||||
$fps[$var] = @fopen($tmpfile[$var], "w");
|
||||
@@ -409,6 +484,8 @@ function run_test($file)
|
||||
putenv("CONTENT_LENGTH=");
|
||||
}
|
||||
if (isset($fps["POST"])) {
|
||||
|
||||
// XXX Fix me, I do not work on win32 (?)
|
||||
$cmd = "$php -q $tmpfile[FILE] < $tmpfile[POST]";
|
||||
} else {
|
||||
$cmd = "$php -q $tmpfile[FILE]";
|
||||
@@ -419,6 +496,7 @@ function run_test($file)
|
||||
delete_tmpfiles();
|
||||
return TEST_INTERNAL_ERROR;
|
||||
}
|
||||
//echo $cmd;
|
||||
$cp = popen($cmd, "r");
|
||||
if (!$cp) {
|
||||
dowriteln("Error: could not execute: $cmd");
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
fastcgi
|
||||
Ben Mansell
|
||||
Stephen Landamore
|
||||
Daniel Silverstone
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
LTLIBRARY_NAME = libsapi.la
|
||||
LTLIBRARY_SOURCES = fastcgi.c
|
||||
|
||||
include $(top_srcdir)/build/ltlib.mk
|
||||
@@ -0,0 +1,17 @@
|
||||
FastCGI module
|
||||
--------------
|
||||
|
||||
This module requires the FastCGI development kit, available from
|
||||
http://www.fastcgi.com/
|
||||
|
||||
Before building PHP, please enter the dev kit, and run:
|
||||
|
||||
./configure
|
||||
make
|
||||
make export
|
||||
|
||||
This will compile the library code required for the FastCGI module. All
|
||||
that is then required is to configure PHP with the '--with-fastcgi' option.
|
||||
After making the code, you will end up with a binary file called 'php'.
|
||||
Installation of this file will depend on the web server being used, please
|
||||
see their documentation for details.
|
||||
@@ -0,0 +1,22 @@
|
||||
AC_MSG_CHECKING(for FastCGI support)
|
||||
AC_ARG_WITH(fastcgi,
|
||||
[ --with-fastcgi=SRCDIR Build PHP as FastCGI application],[
|
||||
if test "$withval" = "yes"; then
|
||||
FASTCGIPATH=/usr/local
|
||||
else
|
||||
FASTCGIPATH=$withval
|
||||
fi
|
||||
test -f "$FASTCGIPATH/lib/libfcgi.a" || AC_MSG_ERROR(Unable to find libfcgi.a in $FASTCGIPATH/lib)
|
||||
test -f "$FASTCGIPATH/include/fastcgi.h" || AC_MSG_ERROR(Unable to find fastcgi.h in $FASTCGIPATH/include)
|
||||
PHP_SAPI=fastcgi
|
||||
PHP_LIBS=$FASTCGIPATH/lib/libfcgi.a
|
||||
AC_ADD_INCLUDE($FASTCGIPATH/include)
|
||||
EXT_PROGRAM_LDADD="$EXT_PROGRAM_LDADD $FASTCGIPATH/lib/libfcgi.a"
|
||||
INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_PROGRAM \$(bindir)/$SAPI_FASTCGI"
|
||||
RESULT="yes"
|
||||
PHP_SUBST(FASTCGI_LIBADD)
|
||||
PHP_SUBST(EXT_PROGRAM_LDADD)
|
||||
],[
|
||||
RESULT="no"
|
||||
])
|
||||
AC_MSG_RESULT($RESULT)
|
||||
@@ -0,0 +1,432 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP version 4.0 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2001 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: Ben Mansell <php@slimyhorror.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* Debugging */
|
||||
/* #define DEBUG_FASTCGI 1 */
|
||||
|
||||
/* Two configurables for the FastCGI runner.
|
||||
*
|
||||
* PHP_FCGI_CHILDREN - if set, the FastCGI will pre-fork this many processes
|
||||
* which will accept requests.
|
||||
*
|
||||
* PHP_FCGI_MAX_REQUESTS - if set, the runner will kill itself after handling
|
||||
* the given number of requests. This is to curb any
|
||||
* memory leaks in PHP.
|
||||
*/
|
||||
|
||||
|
||||
/* The following code is based mainly on the thttpd sapi and the original
|
||||
* CGI code, no doubt with many new and interesting bugs created... :)
|
||||
*/
|
||||
|
||||
#include "php.h"
|
||||
#include "SAPI.h"
|
||||
#include "php_main.h"
|
||||
#include "php_fastcgi.h"
|
||||
#include "php_variables.h"
|
||||
|
||||
#include "fcgi_config.h"
|
||||
#include "fcgiapp.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
||||
#define TLS_D
|
||||
#define TLS_DC
|
||||
#define TLS_C
|
||||
#define TLS_CC
|
||||
#define TLS_FETCH()
|
||||
|
||||
|
||||
FCGX_Stream *in, *out, *err;
|
||||
FCGX_ParamArray envp;
|
||||
char *path_info = NULL;
|
||||
|
||||
/* Our original environment from when the FastCGI first started */
|
||||
char **orig_env;
|
||||
|
||||
/* The environment given by the FastCGI */
|
||||
char **cgi_env;
|
||||
|
||||
/* The manufactured environment, from merging the base environ with
|
||||
* the parameters set by the per-connection environment
|
||||
*/
|
||||
char **merge_env;
|
||||
|
||||
|
||||
static int sapi_fastcgi_ub_write(const char *str, uint str_length)
|
||||
{
|
||||
uint sent = FCGX_PutStr( str, str_length, out );
|
||||
return sent;
|
||||
}
|
||||
|
||||
|
||||
static void sapi_fastcgi_flush( void *server_context )
|
||||
{
|
||||
if( FCGX_FFlush( out ) == -1 ) {
|
||||
php_handle_aborted_connection();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void sapi_fastcgi_send_header(sapi_header_struct *sapi_header, void *server_context)
|
||||
{
|
||||
if( sapi_header ) {
|
||||
#ifdef DEBUG_FASTCGI
|
||||
fprintf( stderr, "Header: %s\n", sapi_header->header );
|
||||
#endif
|
||||
FCGX_PutStr( sapi_header->header, sapi_header->header_len, out );
|
||||
}
|
||||
FCGX_PutStr( "\r\n", 2, out );
|
||||
}
|
||||
|
||||
static int sapi_fastcgi_read_post(char *buffer, uint count_bytes SLS_DC)
|
||||
{
|
||||
size_t read_bytes = 0, tmp;
|
||||
int c;
|
||||
char *pos = buffer;
|
||||
TLS_FETCH();
|
||||
|
||||
while( count_bytes ) {
|
||||
c = FCGX_GetStr( pos, count_bytes, in );
|
||||
read_bytes += c;
|
||||
count_bytes -= c;
|
||||
pos += c;
|
||||
if( !c ) break;
|
||||
}
|
||||
return read_bytes;
|
||||
}
|
||||
|
||||
static char *sapi_fastcgi_read_cookies(SLS_D)
|
||||
{
|
||||
return getenv( "HTTP_COOKIE" );
|
||||
}
|
||||
|
||||
|
||||
static void sapi_fastcgi_register_variables(zval *track_vars_array ELS_DC SLS_DC PLS_DC)
|
||||
{
|
||||
char *self = getenv("REQUEST_URI");
|
||||
char *ptr = strchr( self, '?' );
|
||||
|
||||
/* In CGI mode, we consider the environment to be a part of the server
|
||||
* variables
|
||||
*/
|
||||
php_import_environment_variables(track_vars_array ELS_CC PLS_CC);
|
||||
|
||||
/* strip query string off this */
|
||||
if ( ptr ) *ptr = 0;
|
||||
php_register_variable( "PHP_SELF", getenv("REQUEST_URI"), track_vars_array ELS_CC PLS_CC);
|
||||
if ( ptr ) *ptr = '?';
|
||||
}
|
||||
|
||||
|
||||
static sapi_module_struct fastcgi_sapi_module = {
|
||||
"fastcgi",
|
||||
"FastCGI",
|
||||
|
||||
php_module_startup,
|
||||
php_module_shutdown_wrapper,
|
||||
|
||||
NULL, /* activate */
|
||||
NULL, /* deactivate */
|
||||
|
||||
sapi_fastcgi_ub_write,
|
||||
sapi_fastcgi_flush,
|
||||
NULL, /* get uid */
|
||||
NULL, /* getenv */
|
||||
|
||||
php_error,
|
||||
|
||||
NULL,
|
||||
NULL,
|
||||
sapi_fastcgi_send_header,
|
||||
sapi_fastcgi_read_post,
|
||||
sapi_fastcgi_read_cookies,
|
||||
|
||||
sapi_fastcgi_register_variables,
|
||||
NULL, /* Log message */
|
||||
|
||||
NULL, /* Block interruptions */
|
||||
NULL, /* Unblock interruptions */
|
||||
|
||||
STANDARD_SAPI_MODULE_PROPERTIES
|
||||
};
|
||||
|
||||
static void fastcgi_module_main(TLS_D SLS_DC)
|
||||
{
|
||||
zend_file_handle file_handle;
|
||||
CLS_FETCH();
|
||||
ELS_FETCH();
|
||||
PLS_FETCH();
|
||||
|
||||
file_handle.type = ZEND_HANDLE_FILENAME;
|
||||
file_handle.filename = SG(request_info).path_translated;
|
||||
file_handle.free_filename = 0;
|
||||
file_handle.opened_path = NULL;
|
||||
|
||||
if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC) == SUCCESS) {
|
||||
php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC);
|
||||
}
|
||||
php_request_shutdown(NULL);
|
||||
}
|
||||
|
||||
|
||||
static void init_request_info( SLS_D )
|
||||
{
|
||||
char *content_length = getenv("CONTENT_LENGTH");
|
||||
char *content_type = getenv( "CONTENT_TYPE" );
|
||||
const char *auth;
|
||||
struct stat st;
|
||||
char *pi = getenv( "PATH_INFO" );
|
||||
char *pt = getenv( "PATH_TRANSLATED" );
|
||||
path_info = strdup( pi );
|
||||
|
||||
SG(request_info).request_method = getenv("REQUEST_METHOD");
|
||||
SG(request_info).query_string = getenv("QUERY_STRING");
|
||||
SG(request_info).request_uri = path_info;
|
||||
SG(request_info).content_type = ( content_type ? content_type : "" );
|
||||
SG(request_info).content_length = (content_length?atoi(content_length):0);
|
||||
SG(sapi_headers).http_response_code = 200;
|
||||
|
||||
SG(request_info).path_translated = pt;
|
||||
/*
|
||||
* if the file doesn't exist, try to extract PATH_INFO out
|
||||
* of it by stat'ing back through the '/'
|
||||
*/
|
||||
if ( stat( pt, &st ) == -1 ) {
|
||||
int len = strlen(pt);
|
||||
char *ptr;
|
||||
while( ptr = strrchr(pt,'/') ) {
|
||||
*ptr = 0;
|
||||
if ( stat(pt,&st) == 0 && S_ISREG(st.st_mode) ) {
|
||||
/*
|
||||
* okay, we found the base script!
|
||||
* work out how many chars we had to strip off;
|
||||
* then we can modify PATH_INFO
|
||||
* accordingly
|
||||
*/
|
||||
int slen = len - strlen(pt);
|
||||
if ( pi ) {
|
||||
int pilen = strlen( pi );
|
||||
strcpy( pi, pi + pilen - slen );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* if we stripped out all the '/' and still didn't find
|
||||
* a valid path... we will fail, badly. of course we would
|
||||
* have failed anyway... is there a nice way to error?
|
||||
*/
|
||||
} else {
|
||||
/* the first stat succeeded... */
|
||||
if ( pi ) *pi = 0;
|
||||
}
|
||||
|
||||
/* The CGI RFC allows servers to pass on unvalidated Authorization data */
|
||||
auth = getenv("HTTP_AUTHORIZATION");
|
||||
#ifdef DEBUG_FASTCGI
|
||||
fprintf( stderr, "Authorization: %s\n", auth );
|
||||
#endif
|
||||
php_handle_auth_data(auth SLS_CC);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void fastcgi_php_init(void)
|
||||
{
|
||||
sapi_startup(&fastcgi_sapi_module);
|
||||
fastcgi_sapi_module.startup(&fastcgi_sapi_module);
|
||||
SG(server_context) = (void *) 1;
|
||||
}
|
||||
|
||||
void fastcgi_php_shutdown(void)
|
||||
{
|
||||
if (SG(server_context) != NULL) {
|
||||
fastcgi_sapi_module.shutdown(&fastcgi_sapi_module);
|
||||
sapi_shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int exit_status = SUCCESS;
|
||||
int c, i, len;
|
||||
zend_file_handle file_handle;
|
||||
char *s;
|
||||
char *argv0=NULL;
|
||||
char *script_file=NULL;
|
||||
zend_llist global_vars;
|
||||
int children = 8;
|
||||
int max_requests = 500;
|
||||
int requests = 0;
|
||||
int status;
|
||||
int env_size;
|
||||
|
||||
#ifdef FASTCGI_DEBUG
|
||||
fprintf( stderr, "Initialising now!\n" );
|
||||
#endif
|
||||
|
||||
/* Calculate environment size */
|
||||
env_size = 0;
|
||||
while( environ[ env_size ] ) { env_size++; }
|
||||
/* Also include the final NULL pointer */
|
||||
env_size++;
|
||||
|
||||
/* Allocate for our environment */
|
||||
orig_env = malloc( env_size * sizeof( char *));
|
||||
if( !orig_env ) {
|
||||
perror( "Can't malloc environment" );
|
||||
exit( 1 );
|
||||
}
|
||||
memcpy( orig_env, environ, env_size * sizeof( char *));
|
||||
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
#if defined(SIGPIPE) && defined(SIG_IGN)
|
||||
signal(SIGPIPE,SIG_IGN); /* ignore SIGPIPE in standalone mode so
|
||||
that sockets created via fsockopen()
|
||||
don't kill PHP if the remote site
|
||||
closes it. in apache|apxs mode apache
|
||||
does that for us! thies@thieso.net
|
||||
20000419 */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
sapi_startup(&fastcgi_sapi_module);
|
||||
|
||||
if (php_module_startup(&fastcgi_sapi_module)==FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
/* How many times to run PHP scripts before dying */
|
||||
if( getenv( "PHP_FCGI_MAX_REQUESTS" )) {
|
||||
max_requests = atoi( getenv( "PHP_FCGI_MAX_REQUESTS" ));
|
||||
if( !max_requests ) {
|
||||
fprintf( stderr,
|
||||
"PHP_FCGI_MAX_REQUESTS is not valid\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
/* Pre-fork, if required */
|
||||
if( getenv( "PHP_FCGI_CHILDREN" )) {
|
||||
children = atoi( getenv( "PHP_FCGI_CHILDREN" ));
|
||||
if( !children ) {
|
||||
fprintf( stderr,
|
||||
"PHP_FCGI_CHILDREN is not valid\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
if( children ) {
|
||||
int parent = 1;
|
||||
int running = 0;
|
||||
while( parent ) {
|
||||
do {
|
||||
#ifdef FASTCGI_DEBUG
|
||||
fprintf( stderr, "Forking, %d running\n",
|
||||
running );
|
||||
#endif
|
||||
switch( fork() ) {
|
||||
case 0:
|
||||
/* One of the children.
|
||||
* Make sure we don't go round the
|
||||
* fork loop any more
|
||||
*/
|
||||
parent = 0;
|
||||
break;
|
||||
case -1:
|
||||
perror( "php (pre-forking)" );
|
||||
exit( 1 );
|
||||
break;
|
||||
default:
|
||||
/* Fine */
|
||||
running++;
|
||||
break;
|
||||
}
|
||||
} while( parent && ( running < children ));
|
||||
|
||||
if( parent ) {
|
||||
wait( &status );
|
||||
running--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Main FastCGI loop */
|
||||
#ifdef FASTCGI_DEBUG
|
||||
fprintf( stderr, "Going into accept loop\n" );
|
||||
#endif
|
||||
|
||||
while( FCGX_Accept( &in, &out, &err, &cgi_env ) >= 0 ) {
|
||||
|
||||
#ifdef FASTCGI_DEBUG
|
||||
fprintf( stderr, "Got accept\n" );
|
||||
#endif
|
||||
|
||||
/* Allocate for our environment */
|
||||
merge_env = malloc( env_size * sizeof( char *));
|
||||
if( !merge_env ) {
|
||||
perror( "Can't malloc environment" );
|
||||
exit( 1 );
|
||||
}
|
||||
memcpy( merge_env, orig_env, env_size * sizeof( char *));
|
||||
|
||||
/* Use the new environment */
|
||||
environ = merge_env;
|
||||
|
||||
/* Populate our environment with the CGI's */
|
||||
for( i = 0; cgi_env[ i ]; i++ ) {
|
||||
putenv( cgi_env[ i ] );
|
||||
}
|
||||
|
||||
init_request_info( TLS_C SLS_CC );
|
||||
SG(server_context) = (void *) 1; /* avoid server_context==NULL checks */
|
||||
CG(extended_info) = 0;
|
||||
SG(request_info).argv0 = argv0;
|
||||
zend_llist_init(&global_vars, sizeof(char *), NULL, 0);
|
||||
|
||||
fastcgi_module_main( TLS_C SLS_CC );
|
||||
if( path_info ) {
|
||||
free( path_info );
|
||||
path_info = NULL;
|
||||
}
|
||||
|
||||
/* TODO: We should free our environment here, but
|
||||
* some platforms are unhappy if they've altered our
|
||||
* existing environment and we then free() the new
|
||||
* environ pointer
|
||||
*/
|
||||
|
||||
requests++;
|
||||
if( max_requests && ( requests == max_requests )) {
|
||||
FCGX_Finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FASTCGI_DEBUG
|
||||
fprintf( stderr, "Exiting...\n" );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP version 4.0 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2001 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: Sascha Schumann <sascha@schumann.cx> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef PHP_FASTCGI_H
|
||||
#define PHP_FASTCGI_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
void fastcgi_php_shutdown(void);
|
||||
void fastcgi_php_init(void);
|
||||
|
||||
#endif
|
||||
@@ -2,8 +2,8 @@ dnl ## $Id$ -*- sh -*-
|
||||
|
||||
RESULT=no
|
||||
AC_MSG_CHECKING(for Zeus ISAPI support)
|
||||
AC_ARG_WITH(zeus,
|
||||
[ --with-zeus=DIR Build PHP as an ISAPI module for use with Zeus.],
|
||||
AC_ARG_WITH(isapi,
|
||||
[ --with-isapi=DIR Build PHP as an ISAPI module for use with Zeus.],
|
||||
[
|
||||
if test "$withval" = "yes"; then
|
||||
ZEUSPATH=/usr/local/zeus # the default
|
||||
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
#include "php.h"
|
||||
|
||||
#ifndef HAVE_STRTOK_R
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 Softweyr LLC. All rights reserved.
|
||||
*
|
||||
* strtok_r, from Berkeley strtok
|
||||
* Oct 13, 1998 by Wes Peters <wes@softweyr.com>
|
||||
*
|
||||
* Copyright (c) 1988, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notices, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notices, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
*
|
||||
* This product includes software developed by Softweyr LLC, the
|
||||
* University of California, Berkeley, and its contributors.
|
||||
*
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY SOFTWEYR LLC, THE REGENTS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTWEYR LLC, THE
|
||||
* REGENTS, OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
char *
|
||||
strtok_r(char *s, const char *delim, char **last)
|
||||
{
|
||||
char *spanp;
|
||||
int c, sc;
|
||||
char *tok;
|
||||
|
||||
if (s == NULL && (s = *last) == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Skip (span) leading delimiters (s += strspn(s, delim), sort of).
|
||||
*/
|
||||
cont:
|
||||
c = *s++;
|
||||
for (spanp = (char *)delim; (sc = *spanp++) != 0; )
|
||||
{
|
||||
if (c == sc)
|
||||
{
|
||||
goto cont;
|
||||
}
|
||||
}
|
||||
|
||||
if (c == 0) /* no non-delimiter characters */
|
||||
{
|
||||
*last = NULL;
|
||||
return NULL;
|
||||
}
|
||||
tok = s - 1;
|
||||
|
||||
/*
|
||||
* Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
|
||||
* Note that delim must have one NUL; we stop if we see that, too.
|
||||
*/
|
||||
for (;;)
|
||||
{
|
||||
c = *s++;
|
||||
spanp = (char *)delim;
|
||||
do
|
||||
{
|
||||
if ((sc = *spanp++) == c)
|
||||
{
|
||||
if (c == 0)
|
||||
{
|
||||
s = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *w = s - 1;
|
||||
*w = '\0';
|
||||
}
|
||||
*last = s;
|
||||
return tok;
|
||||
}
|
||||
}
|
||||
while (sc != 0);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user