summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2015-02-10 10:09:53 +0100
committerAnatol Belski <ab@php.net>2015-02-10 10:09:53 +0100
commitd7c6c6539956043d2c577a4dc922280a88627984 (patch)
treec45e1b221ed01aec10bfc45a31a22d60e33f9fcc
parent400e65e955f08ad6ae57c1a15be04d5852107252 (diff)
parent56ec18c8affb71f7456508a7111748efdd40e115 (diff)
downloadphp-git-POST_PHP7_REMOVALS.tar.gz
Merge branch 'php7_removals'POST_PHP7_REMOVALS
-rw-r--r--NEWS1
-rw-r--r--UPGRADING21
-rw-r--r--ext/mssql/CREDITS2
-rw-r--r--ext/mssql/config.m456
-rw-r--r--ext/mssql/config.w3228
-rw-r--r--ext/mssql/mssql_win32_howto.txt35
-rw-r--r--ext/mssql/php_mssql.c2283
-rw-r--r--ext/mssql/php_mssql.h214
-rw-r--r--ext/sybase_ct/CREDITS2
-rw-r--r--ext/sybase_ct/config.m4120
-rw-r--r--ext/sybase_ct/config.w3221
-rw-r--r--ext/sybase_ct/php_sybase_ct.c2242
-rw-r--r--ext/sybase_ct/php_sybase_ct.h131
-rw-r--r--ext/sybase_ct/tests/bug22403.phpt88
-rw-r--r--ext/sybase_ct/tests/bug26407.phpt91
-rw-r--r--ext/sybase_ct/tests/bug27843.phpt54
-rw-r--r--ext/sybase_ct/tests/bug28354.phpt46
-rw-r--r--ext/sybase_ct/tests/bug29064.phpt143
-rw-r--r--ext/sybase_ct/tests/bug30312-withfree.phpt34
-rw-r--r--ext/sybase_ct/tests/bug30312.phpt27
-rw-r--r--ext/sybase_ct/tests/bug43578.phpt65
-rw-r--r--ext/sybase_ct/tests/bug6339.phpt24
-rw-r--r--ext/sybase_ct/tests/skipif.inc13
-rw-r--r--ext/sybase_ct/tests/test.inc86
-rw-r--r--ext/sybase_ct/tests/test_appname.phpt55
-rw-r--r--ext/sybase_ct/tests/test_close.phpt25
-rw-r--r--ext/sybase_ct/tests/test_close_default.phpt21
-rw-r--r--ext/sybase_ct/tests/test_close_notopen.phpt18
-rw-r--r--ext/sybase_ct/tests/test_connect.phpt19
-rw-r--r--ext/sybase_ct/tests/test_connection_caching.phpt26
-rw-r--r--ext/sybase_ct/tests/test_connectionbased_msghandler.phpt27
-rw-r--r--ext/sybase_ct/tests/test_fetch_object.phpt74
-rw-r--r--ext/sybase_ct/tests/test_fields.phpt76
-rw-r--r--ext/sybase_ct/tests/test_long.phpt80
-rw-r--r--ext/sybase_ct/tests/test_msghandler.phpt43
-rw-r--r--ext/sybase_ct/tests/test_msghandler_handled.phpt69
-rw-r--r--ext/sybase_ct/tests/test_query_nostore.phpt98
-rw-r--r--ext/sybase_ct/tests/test_types.phpt87
-rw-r--r--ext/sybase_ct/tests/test_unbuffered_no_full_fetch.phpt44
-rw-r--r--ext/sybase_ct/tests/test_unbuffered_query.phpt57
-rw-r--r--php.ini-development92
-rw-r--r--php.ini-production92
-rw-r--r--sapi/aolserver/CREDITS2
-rw-r--r--sapi/aolserver/README69
-rw-r--r--sapi/aolserver/aolserver.c624
-rw-r--r--sapi/aolserver/config.m431
-rw-r--r--sapi/aolserver/config.w3216
-rw-r--r--sapi/aolserver/php.sym2
-rw-r--r--sapi/apache/CREDITS3
-rw-r--r--sapi/apache/apMakefile.libdir4
-rw-r--r--sapi/apache/apMakefile.tmpl77
-rw-r--r--sapi/apache/config.m4273
-rw-r--r--sapi/apache/config.w3224
-rw-r--r--sapi/apache/libphp7.module.in11
-rw-r--r--sapi/apache/libpre.c55
-rw-r--r--sapi/apache/mod_php7.c1045
-rw-r--r--sapi/apache/mod_php7.exp1
-rw-r--r--sapi/apache/mod_php7.h60
-rw-r--r--sapi/apache/php.sym1
-rw-r--r--sapi/apache/php_apache.c607
-rw-r--r--sapi/apache/php_apache_http.h70
-rw-r--r--sapi/apache/sapi_apache.c73
-rw-r--r--sapi/apache2filter/CREDITS2
-rw-r--r--sapi/apache2filter/EXPERIMENTAL5
-rw-r--r--sapi/apache2filter/README71
-rw-r--r--sapi/apache2filter/apache_config.c217
-rw-r--r--sapi/apache2filter/config.m4139
-rwxr-xr-xsapi/apache2filter/config.w3239
-rw-r--r--sapi/apache2filter/php.sym1
-rw-r--r--sapi/apache2filter/php_apache.h77
-rw-r--r--sapi/apache2filter/php_functions.c425
-rw-r--r--sapi/apache2filter/sapi_apache2.c756
-rw-r--r--sapi/apache_hooks/CREDITS2
-rw-r--r--sapi/apache_hooks/README206
-rw-r--r--sapi/apache_hooks/apMakefile.libdir4
-rw-r--r--sapi/apache_hooks/apMakefile.tmpl77
-rw-r--r--sapi/apache_hooks/config.m4275
-rw-r--r--sapi/apache_hooks/config.w3221
-rw-r--r--sapi/apache_hooks/libphp7.module.in11
-rw-r--r--sapi/apache_hooks/mod_php7.c1478
-rw-r--r--sapi/apache_hooks/mod_php7.exp1
-rw-r--r--sapi/apache_hooks/mod_php7.h88
-rw-r--r--sapi/apache_hooks/php.sym1
-rw-r--r--sapi/apache_hooks/php_apache.c1970
-rw-r--r--sapi/apache_hooks/php_apache_http.h44
-rw-r--r--sapi/apache_hooks/sapi_apache.c131
-rw-r--r--sapi/caudium/CREDITS2
-rw-r--r--sapi/caudium/README16
-rw-r--r--sapi/caudium/TODO30
-rw-r--r--sapi/caudium/caudium.c782
-rw-r--r--sapi/caudium/config.m498
-rw-r--r--sapi/continuity/CREDITS2
-rw-r--r--sapi/continuity/capi.c507
-rw-r--r--sapi/continuity/config.m428
-rw-r--r--sapi/isapi/CREDITS2
-rw-r--r--sapi/isapi/config.m424
-rw-r--r--sapi/isapi/config.w3213
-rw-r--r--sapi/isapi/php.sym5
-rw-r--r--sapi/isapi/php7isapi.c971
-rw-r--r--sapi/isapi/php7isapi.def5
-rw-r--r--sapi/isapi/stresstest/getopt.c175
-rw-r--r--sapi/isapi/stresstest/getopt.h12
-rw-r--r--sapi/isapi/stresstest/notes.txt56
-rw-r--r--sapi/isapi/stresstest/stresstest.cpp936
-rw-r--r--sapi/milter/CREDITS2
-rw-r--r--sapi/milter/EXPERIMENTAL5
-rw-r--r--sapi/milter/Makefile.frag8
-rw-r--r--sapi/milter/TODO5
-rw-r--r--sapi/milter/config.m431
-rw-r--r--sapi/milter/getopt.c173
-rw-r--r--sapi/milter/milter.php132
-rw-r--r--sapi/milter/php_getopt.h7
-rw-r--r--sapi/milter/php_milter.c1196
-rw-r--r--sapi/milter/php_milter.h31
-rw-r--r--sapi/phttpd/CREDITS2
-rw-r--r--sapi/phttpd/README5
-rw-r--r--sapi/phttpd/config.m421
-rw-r--r--sapi/phttpd/php.sym4
-rw-r--r--sapi/phttpd/php_phttpd.h24
-rw-r--r--sapi/phttpd/phttpd.c300
-rw-r--r--sapi/pi3web/CREDITS2
-rw-r--r--sapi/pi3web/README50
-rw-r--r--sapi/pi3web/config.m427
-rw-r--r--sapi/pi3web/config.w3216
-rw-r--r--sapi/pi3web/php.sym0
-rw-r--r--sapi/pi3web/pi3web_sapi.c438
-rw-r--r--sapi/pi3web/pi3web_sapi.h102
-rw-r--r--sapi/roxen/README18
-rw-r--r--sapi/roxen/TODO33
-rw-r--r--sapi/roxen/config.m455
-rw-r--r--sapi/roxen/roxen.c725
-rw-r--r--sapi/thttpd/CREDITS2
-rw-r--r--sapi/thttpd/README85
-rw-r--r--sapi/thttpd/config.m439
-rw-r--r--sapi/thttpd/php.sym3
-rw-r--r--sapi/thttpd/php_thttpd.h35
-rw-r--r--sapi/thttpd/stub.c0
-rw-r--r--sapi/thttpd/thttpd.c766
-rw-r--r--sapi/thttpd/thttpd_patch2377
-rw-r--r--sapi/tux/CREDITS2
-rw-r--r--sapi/tux/README86
-rw-r--r--sapi/tux/config.m416
-rw-r--r--sapi/tux/php.sym2
-rw-r--r--sapi/tux/php_tux.c449
-rw-r--r--sapi/webjames/CREDITS2
-rw-r--r--sapi/webjames/README28
-rw-r--r--sapi/webjames/config.m421
-rw-r--r--sapi/webjames/php_webjames.h28
-rw-r--r--sapi/webjames/webjames.c327
149 files changed, 20 insertions, 27243 deletions
diff --git a/NEWS b/NEWS
index dcfe1a5ff7..667e172121 100644
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,7 @@
. Invalid octal literals in source code now produce compile errors, fixes PHPSadness #31. (Andrea)
. Removed dl() function on fpm-fcgi. (Nikita)
. Removed support for hexadecimal numeric strings. (Nikita)
+ . Removed obsolete extensions and SAPIs. See the full list in UPGRADING. (Anatol)
- Curl:
. Fixed bug #68937 (Segfault in curl_multi_exec). (Laruence)
diff --git a/UPGRADING b/UPGRADING
index 0ea6a09000..f992e1bfa4 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -9,7 +9,7 @@ PHP X.Y UPGRADE NOTES
5. Changed Functions
6. New Functions
7. New Classes and Interfaces
-8. Removed Extensions
+8. Removed Extensions and SAPIs
9. Other Changes to Extensions
10. New Global Constants
11. Changes to INI File Handling
@@ -170,9 +170,26 @@ PHP X.Y UPGRADE NOTES
========================================
-8. Removed Extensions
+8. Removed Extensions and SAPIs
========================================
+- sapi/aolserver
+- sapi/apache
+- sapi/apache_hooks
+- sapi/apache2filter
+- sapi/caudium
+- sapi/continuity
+- sapi/isapi
+- sapi/milter
+- sapi/phttpd
+- sapi/pi3web
+- sapi/roxen
+- sapi/thttpd
+- sapi/tux
+- sapi/webjames
+- ext/mssql
+- ext/sybase_ct
+For more details see https://wiki.php.net/rfc/removal_of_dead_sapis_and_exts
========================================
9. Other Changes to Extensions
diff --git a/ext/mssql/CREDITS b/ext/mssql/CREDITS
deleted file mode 100644
index 548684afca..0000000000
--- a/ext/mssql/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-MS SQL
-Frank M. Kromann
diff --git a/ext/mssql/config.m4 b/ext/mssql/config.m4
deleted file mode 100644
index 2a298af734..0000000000
--- a/ext/mssql/config.m4
+++ /dev/null
@@ -1,56 +0,0 @@
-dnl
-dnl $Id$
-dnl
-
-PHP_ARG_WITH(mssql,for MSSQL support via FreeTDS,
-[ --with-mssql[=DIR] Include MSSQL-DB support. DIR is the FreeTDS home
- directory [/usr/local/freetds]])
-
-if test "$PHP_MSSQL" != "no"; then
-
- if test "$PHP_MSSQL" = "yes"; then
- for i in /usr/local /usr; do
- if test -f $i/include/sybdb.h; then
- FREETDS_INSTALLATION_DIR=$i
- FREETDS_INCLUDE_DIR=$i/include
- break
- elif test -f $i/include/freetds/sybdb.h; then
- FREETDS_INSTALLATION_DIR=$i
- FREETDS_INCLUDE_DIR=$i/include/freetds
- break
- fi
- done
-
- if test -z "$FREETDS_INSTALLATION_DIR"; then
- AC_MSG_ERROR(Cannot find FreeTDS in known installation directories)
- fi
-
- elif test "$PHP_MSSQL" != "no"; then
-
- if test -f $PHP_MSSQL/include/sybdb.h; then
- FREETDS_INSTALLATION_DIR=$PHP_MSSQL
- FREETDS_INCLUDE_DIR=$PHP_MSSQL/include
- elif test -f $PHP_MSSQL/include/freetds/sybdb.h; then
- FREETDS_INSTALLATION_DIR=$PHP_MSSQL
- FREETDS_INCLUDE_DIR=$PHP_MSSQL/include/freetds
- else
- AC_MSG_ERROR(Directory $PHP_MSSQL is not a FreeTDS installation directory)
- fi
- fi
-
- if test ! -r "$FREETDS_INSTALLATION_DIR/$PHP_LIBDIR/libsybdb.a" && test ! -r "$FREETDS_INSTALLATION_DIR/$PHP_LIBDIR/libsybdb.so"; then
- AC_MSG_ERROR(Could not find $FREETDS_INSTALLATION_DIR/$PHP_LIBDIR/libsybdb.[a|so])
- fi
-
- PHP_ADD_INCLUDE($FREETDS_INCLUDE_DIR)
- PHP_ADD_LIBRARY_WITH_PATH(sybdb, $FREETDS_INSTALLATION_DIR/$PHP_LIBDIR, MSSQL_SHARED_LIBADD)
-
- PHP_NEW_EXTENSION(mssql, php_mssql.c, $ext_shared)
- AC_CHECK_LIB(dnet_stub, dnet_addr,
- [ PHP_ADD_LIBRARY_WITH_PATH(dnet_stub,,MSSQL_SHARED_LIBADD)
- AC_DEFINE(HAVE_LIBDNET_STUB,1,[ ])
- ])
- AC_DEFINE(HAVE_MSSQL,1,[ ])
- AC_DEFINE(HAVE_FREETDS,1,[ ])
- PHP_SUBST(MSSQL_SHARED_LIBADD)
-fi
diff --git a/ext/mssql/config.w32 b/ext/mssql/config.w32
deleted file mode 100644
index bd1f68669b..0000000000
--- a/ext/mssql/config.w32
+++ /dev/null
@@ -1,28 +0,0 @@
-// $Id$
-// vim:ft=javascript
-
-ARG_WITH("mssql", "mssql support", "no");
-
-if (PHP_MSSQL != "no") {
- if (CHECK_LIB("ntwdblib.lib", "mssql", "\\MSSQL7\\DevTools\\Lib;\\MSSQL7\\DevTools\\Lib;" + PHP_MSSQL) &&
- CHECK_HEADER_ADD_INCLUDE("sqlfront.h", "CFLAGS_MSSQL", "\\MSSQL7\\DevTools\\Include;\\MSSQL7\\DevTools\\Include" + PHP_MSSQL)) {
- EXTENSION("mssql", "php_mssql.c");
- AC_DEFINE('HAVE_MSSQL', 1, 'Have MSSQL support');
- ADD_FLAG("CFLAGS_MSSQL", "/D DBNTWIN32=1 /D MSSQL70=1");
- } else {
- WARNING("mssql not enabled; libraries and headers not found");
- }
-}
-
-ARG_WITH("dblib", "mssql support with freetds", "no");
-
-if (PHP_DBLIB != "no") {
- if (CHECK_LIB("dblib.lib", "dblib", PHP_PHP_BUILD + "\\freetds") &&
- CHECK_HEADER_ADD_INCLUDE("sybfront.h", "CFLAGS_DBLIB", PHP_PHP_BUILD + "\\freetds;" + PHP_DBLIB)) {
- EXTENSION("dblib", "php_mssql.c", null, null, null, "ext\\dblib");
- AC_DEFINE('HAVE_MSSQL', 1, 'Have MSSQL support');
- ADD_FLAG("CFLAGS_DBLIB", "/D HAVE_FREETDS=1 /D DBNTWIN32=1 /D MSSQL70=1 /D MSSQL_EXPORTS /D COMPILE_DL_MSSQL");
- } else {
- WARNING("dblib not enabled; libraries and headers not found");
- }
-}
diff --git a/ext/mssql/mssql_win32_howto.txt b/ext/mssql/mssql_win32_howto.txt
deleted file mode 100644
index 735226f88a..0000000000
--- a/ext/mssql/mssql_win32_howto.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-Rules for building MSSQL
-------------------------
-
-The MSSQL project contains 2 configurations.
-
-The files needed for each configurations are:
-
-Win32 Release_TS
-Win32 Debug_TS
-
- php_build\mssql-70\include\sqldb.h
- php_build\mssql-70\include\sqlfront.h
- php_build\mssql-70\lib\ntwdblib.lib
-
-php_build is a directory at the same level as php7.
-
-Start Visual Studio, load php_modules.dsw, select the MSSQL projects,
-configuration and build it.
-
-This module requires ntwdblib.dll and one or more of the following dll's
-
-dbmsadsn.dll
-dbmsrpcn.dll
-dbmsshrn.dll
-dbmssocn.dll for tcp/ip connections
-dbmsspxn.dll for ipx/spx connections
-dbmsvinn.dll
-dbnmpntw.dll for netbios connections
-
-All these files are installed while installing MS SQL Server. If the SQL Server
-is installed on another maschine you need to install the client tools on
-the web server as well.
-
-
- \ No newline at end of file
diff --git a/ext/mssql/php_mssql.c b/ext/mssql/php_mssql.c
deleted file mode 100644
index 08e118d281..0000000000
--- a/ext/mssql/php_mssql.c
+++ /dev/null
@@ -1,2283 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.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: Frank M. Kromann <frank@kromann.info> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifdef COMPILE_DL_MSSQL
-#define HAVE_MSSQL 1
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "php.h"
-#include "php_globals.h"
-#include "ext/standard/php_standard.h"
-#include "ext/standard/info.h"
-#include "php_mssql.h"
-#include "php_ini.h"
-
-#if HAVE_MSSQL
-#define SAFE_STRING(s) ((s)?(s):"")
-
-#define MSSQL_ASSOC 1<<0
-#define MSSQL_NUM 1<<1
-#define MSSQL_BOTH (MSSQL_ASSOC|MSSQL_NUM)
-
-static int le_result, le_link, le_plink, le_statement;
-
-static void php_mssql_get_column_content_with_type(mssql_link *mssql_ptr,int offset,zval *result, int column_type);
-static void php_mssql_get_column_content_without_type(mssql_link *mssql_ptr,int offset,zval *result, int column_type);
-
-static void _mssql_bind_hash_dtor(void *data);
-
-/* {{{ arginfo */
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mssql_connect, 0, 0, 0)
- ZEND_ARG_INFO(0, servername)
- ZEND_ARG_INFO(0, username)
- ZEND_ARG_INFO(0, password)
- ZEND_ARG_INFO(0, newlink)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mssql_close, 0, 0, 0)
- ZEND_ARG_INFO(0, link_identifier)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mssql_select_db, 0, 0, 1)
- ZEND_ARG_INFO(0, database_name)
- ZEND_ARG_INFO(0, link_identifier)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mssql_query, 0, 0, 1)
- ZEND_ARG_INFO(0, query)
- ZEND_ARG_INFO(0, link_identifier)
- ZEND_ARG_INFO(0, batch_size)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mssql_fetch_batch, 0, 0, 1)
- ZEND_ARG_INFO(0, result)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mssql_rows_affected, 0, 0, 1)
- ZEND_ARG_INFO(0, link_identifier)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_mssql_get_last_message, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mssql_fetch_field, 0, 0, 1)
- ZEND_ARG_INFO(0, result)
- ZEND_ARG_INFO(0, field_offset)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mssql_fetch_array, 0, 0, 1)
- ZEND_ARG_INFO(0, result)
- ZEND_ARG_INFO(0, result_type)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mssql_fetch_assoc, 0, 0, 1)
- ZEND_ARG_INFO(0, result_id)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mssql_field_length, 0, 0, 1)
- ZEND_ARG_INFO(0, result)
- ZEND_ARG_INFO(0, offset)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mssql_data_seek, 0, 0, 2)
- ZEND_ARG_INFO(0, result_identifier)
- ZEND_ARG_INFO(0, row_number)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mssql_result, 0, 0, 3)
- ZEND_ARG_INFO(0, result)
- ZEND_ARG_INFO(0, row)
- ZEND_ARG_INFO(0, field)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mssql_min_error_severity, 0, 0, 1)
- ZEND_ARG_INFO(0, severity)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mssql_init, 0, 0, 1)
- ZEND_ARG_INFO(0, sp_name)
- ZEND_ARG_INFO(0, link_identifier)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mssql_bind, 0, 0, 4)
- ZEND_ARG_INFO(0, stmt)
- ZEND_ARG_INFO(0, param_name)
- ZEND_ARG_INFO(1, var)
- ZEND_ARG_INFO(0, type)
- ZEND_ARG_INFO(0, is_output)
- ZEND_ARG_INFO(0, is_null)
- ZEND_ARG_INFO(0, maxlen)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mssql_execute, 0, 0, 1)
- ZEND_ARG_INFO(0, stmt)
- ZEND_ARG_INFO(0, skip_results)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mssql_free_statement, 0, 0, 1)
- ZEND_ARG_INFO(0, stmt)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mssql_guid_string, 0, 0, 1)
- ZEND_ARG_INFO(0, binary)
- ZEND_ARG_INFO(0, short_format)
-ZEND_END_ARG_INFO()
-/* }}} */
-
-/* {{{ mssql_functions
-*/
-const zend_function_entry mssql_functions[] = {
- PHP_FE(mssql_connect, arginfo_mssql_connect)
- PHP_FE(mssql_pconnect, arginfo_mssql_connect)
- PHP_FE(mssql_close, arginfo_mssql_close)
- PHP_FE(mssql_select_db, arginfo_mssql_select_db)
- PHP_FE(mssql_query, arginfo_mssql_query)
- PHP_FE(mssql_fetch_batch, arginfo_mssql_fetch_batch)
- PHP_FE(mssql_rows_affected, arginfo_mssql_rows_affected)
- PHP_FE(mssql_free_result, arginfo_mssql_fetch_batch)
- PHP_FE(mssql_get_last_message, arginfo_mssql_get_last_message)
- PHP_FE(mssql_num_rows, arginfo_mssql_fetch_batch)
- PHP_FE(mssql_num_fields, arginfo_mssql_fetch_batch)
- PHP_FE(mssql_fetch_field, arginfo_mssql_fetch_field)
- PHP_FE(mssql_fetch_row, arginfo_mssql_fetch_batch)
- PHP_FE(mssql_fetch_array, arginfo_mssql_fetch_array)
- PHP_FE(mssql_fetch_assoc, arginfo_mssql_fetch_assoc)
- PHP_FE(mssql_fetch_object, arginfo_mssql_fetch_batch)
- PHP_FE(mssql_field_length, arginfo_mssql_field_length)
- PHP_FE(mssql_field_name, arginfo_mssql_field_length)
- PHP_FE(mssql_field_type, arginfo_mssql_field_length)
- PHP_FE(mssql_data_seek, arginfo_mssql_data_seek)
- PHP_FE(mssql_field_seek, arginfo_mssql_fetch_field)
- PHP_FE(mssql_result, arginfo_mssql_result)
- PHP_FE(mssql_next_result, arginfo_mssql_fetch_assoc)
- PHP_FE(mssql_min_error_severity, arginfo_mssql_min_error_severity)
- PHP_FE(mssql_min_message_severity, arginfo_mssql_min_error_severity)
- PHP_FE(mssql_init, arginfo_mssql_init)
- PHP_FE(mssql_bind, arginfo_mssql_bind)
- PHP_FE(mssql_execute, arginfo_mssql_execute)
- PHP_FE(mssql_free_statement, arginfo_mssql_free_statement)
- PHP_FE(mssql_guid_string, arginfo_mssql_guid_string)
- PHP_FE_END
-};
-/* }}} */
-
-ZEND_DECLARE_MODULE_GLOBALS(mssql)
-static PHP_GINIT_FUNCTION(mssql);
-
-/* {{{ mssql_module_entry
-*/
-zend_module_entry mssql_module_entry =
-{
- STANDARD_MODULE_HEADER,
- "mssql",
- mssql_functions,
- PHP_MINIT(mssql),
- PHP_MSHUTDOWN(mssql),
- PHP_RINIT(mssql),
- PHP_RSHUTDOWN(mssql),
- PHP_MINFO(mssql),
- NO_VERSION_YET,
- PHP_MODULE_GLOBALS(mssql),
- PHP_GINIT(mssql),
- NULL,
- NULL,
- STANDARD_MODULE_PROPERTIES_EX
-};
-/* }}} */
-
-#ifdef COMPILE_DL_MSSQL
-ZEND_GET_MODULE(mssql)
-#endif
-
-#define CHECK_LINK(link) { if (link==-1) { php_error_docref(NULL, E_WARNING, "A link to the server could not be established"); RETURN_FALSE; } }
-
-/* {{{ PHP_INI_DISP
-*/
-static PHP_INI_DISP(display_text_size)
-{
- char *value;
-
- if (type == PHP_INI_DISPLAY_ORIG && ini_entry->modified) {
- value = ini_entry->orig_value;
- } else if (ini_entry->value) {
- value = ini_entry->value;
- } else {
- value = NULL;
- }
-
- if (atoi(value) == -1) {
- PUTS("Server default");
- } else {
- php_printf("%s", value);
- }
-}
-/* }}} */
-
-/* {{{ PHP_INI
-*/
-PHP_INI_BEGIN()
- STD_PHP_INI_BOOLEAN("mssql.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateBool, allow_persistent, zend_mssql_globals, mssql_globals)
- STD_PHP_INI_ENTRY_EX("mssql.max_persistent", "-1", PHP_INI_SYSTEM, OnUpdateLong, max_persistent, zend_mssql_globals, mssql_globals, display_link_numbers)
- STD_PHP_INI_ENTRY_EX("mssql.max_links", "-1", PHP_INI_SYSTEM, OnUpdateLong, max_links, zend_mssql_globals, mssql_globals, display_link_numbers)
- STD_PHP_INI_ENTRY_EX("mssql.min_error_severity", "10", PHP_INI_ALL, OnUpdateLong, cfg_min_error_severity, zend_mssql_globals, mssql_globals, display_link_numbers)
- STD_PHP_INI_ENTRY_EX("mssql.min_message_severity", "10", PHP_INI_ALL, OnUpdateLong, cfg_min_message_severity, zend_mssql_globals, mssql_globals, display_link_numbers)
- /*
- mssql.compatAbility_mode (with typo) was used for relatively long time.
- Unless it is fixed the old version is also kept for compatibility reasons.
- */
- STD_PHP_INI_BOOLEAN("mssql.compatability_mode", "0", PHP_INI_ALL, OnUpdateBool, compatibility_mode, zend_mssql_globals, mssql_globals)
- STD_PHP_INI_BOOLEAN("mssql.compatibility_mode", "0", PHP_INI_ALL, OnUpdateBool, compatibility_mode, zend_mssql_globals, mssql_globals)
- STD_PHP_INI_ENTRY_EX("mssql.connect_timeout", "5", PHP_INI_ALL, OnUpdateLong, connect_timeout, zend_mssql_globals, mssql_globals, display_link_numbers)
- STD_PHP_INI_ENTRY_EX("mssql.timeout", "60", PHP_INI_ALL, OnUpdateLong, timeout, zend_mssql_globals, mssql_globals, display_link_numbers)
- STD_PHP_INI_ENTRY_EX("mssql.textsize", "-1", PHP_INI_ALL, OnUpdateLong, textsize, zend_mssql_globals, mssql_globals, display_text_size)
- STD_PHP_INI_ENTRY_EX("mssql.textlimit", "-1", PHP_INI_ALL, OnUpdateLong, textlimit, zend_mssql_globals, mssql_globals, display_text_size)
- STD_PHP_INI_ENTRY_EX("mssql.batchsize", "0", PHP_INI_ALL, OnUpdateLong, batchsize, zend_mssql_globals, mssql_globals, display_link_numbers)
- STD_PHP_INI_BOOLEAN("mssql.datetimeconvert", "1", PHP_INI_ALL, OnUpdateBool, datetimeconvert, zend_mssql_globals, mssql_globals)
- STD_PHP_INI_BOOLEAN("mssql.secure_connection", "0", PHP_INI_SYSTEM, OnUpdateBool, secure_connection, zend_mssql_globals, mssql_globals)
- STD_PHP_INI_ENTRY_EX("mssql.max_procs", "-1", PHP_INI_ALL, OnUpdateLong, max_procs, zend_mssql_globals, mssql_globals, display_link_numbers)
-#ifdef HAVE_FREETDS
- STD_PHP_INI_ENTRY("mssql.charset", "", PHP_INI_ALL, OnUpdateString, charset, zend_mssql_globals, mssql_globals)
-#endif
-PHP_INI_END()
-/* }}} */
-
-/* error handler */
-static int php_mssql_error_handler(DBPROCESS *dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr)
-{
-
- if (severity >= MS_SQL_G(min_error_severity)) {
- php_error_docref(NULL, E_WARNING, "%s (severity %d)", dberrstr, severity);
- }
- return INT_CANCEL;
-}
-
-/* {{{ php_mssql_message_handler
-*/
-/* message handler */
-static int php_mssql_message_handler(DBPROCESS *dbproc, DBINT msgno,int msgstate, int severity,char *msgtext,char *srvname, char *procname,DBUSMALLINT line)
-{
-
- if (severity >= MS_SQL_G(min_message_severity)) {
- php_error_docref(NULL, E_WARNING, "message: %s (severity %d)", msgtext, severity);
- }
- if (MS_SQL_G(server_message)) {
- zend_string_free(MS_SQL_G(server_message));
- MS_SQL_G(server_message) = NULL;
- }
- MS_SQL_G(server_message) = estrdup(msgtext);
- return 0;
-}
-/* }}} */
-
-/* {{{ _clean_invalid_results
-*/
-static int _clean_invalid_results(zend_rsrc_list_entry *le)
-{
- if (Z_TYPE_P(le) == le_result) {
- mssql_link *mssql_ptr = ((mssql_result *) le->ptr)->mssql_ptr;
-
- if (!mssql_ptr->valid) {
- return 1;
- }
- }
- return 0;
-}
-/* }}} */
-
-/* {{{ _free_result
-*/
-static void _free_result(mssql_result *result, int free_fields)
-{
- int i,j;
-
- if (result->data) {
- for (i=0; i<result->num_rows; i++) {
- if (result->data[i]) {
- for (j=0; j<result->num_fields; j++) {
- zval_dtor(&result->data[i][j]);
- }
- efree(result->data[i]);
- }
- }
- efree(result->data);
- result->data = NULL;
- result->blocks_initialized = 0;
- }
-
- if (free_fields && result->fields) {
- for (i=0; i<result->num_fields; i++) {
- zend_string_free(result->fields[i].name);
- zend_string_free(result->fields[i].column_source);
- }
- efree(result->fields);
- }
-}
-/* }}} */
-
-/* {{{ _free_mssql_statement
-*/
-static void _free_mssql_statement(zend_rsrc_list_entry *rsrc)
-{
- mssql_statement *statement = (mssql_statement *)rsrc->ptr;
-
- if (statement->binds) {
- zend_hash_destroy(statement->binds);
- efree(statement->binds);
- }
-
- efree(statement);
-}
-/* }}} */
-
-/* {{{ _free_mssql_result
-*/
-static void _free_mssql_result(zend_rsrc_list_entry *rsrc)
-{
- mssql_result *result = (mssql_result *)rsrc->ptr;
-
- _free_result(result, 1);
- dbcancel(result->mssql_ptr->link);
- efree(result);
-}
-/* }}} */
-
-/* {{{ php_mssql_set_defaullt_link
-*/
-static void php_mssql_set_default_link(int id)
-{
- if (MS_SQL_G(default_link)!=-1) {
- zend_list_delete(MS_SQL_G(default_link));
- }
- MS_SQL_G(default_link) = id;
- zend_list_addref(id);
-}
-/* }}} */
-
-/* {{{ _close_mssql_link
-*/
-static void _close_mssql_link(zend_rsrc_list_entry *rsrc)
-{
- mssql_link *mssql_ptr = (mssql_link *)rsrc->ptr;
-
- mssql_ptr->valid = 0;
- zend_hash_apply(&EG(regular_list),(apply_func_t) _clean_invalid_results);
- dbclose(mssql_ptr->link);
- dbfreelogin(mssql_ptr->login);
- efree(mssql_ptr);
- MS_SQL_G(num_links)--;
-}
-/* }}} */
-
-/* {{{ _close_mssql_plink
-*/
-static void _close_mssql_plink(zend_rsrc_list_entry *rsrc)
-{
- mssql_link *mssql_ptr = (mssql_link *)rsrc->ptr;
-
- dbclose(mssql_ptr->link);
- dbfreelogin(mssql_ptr->login);
- free(mssql_ptr);
- MS_SQL_G(num_persistent)--;
- MS_SQL_G(num_links)--;
-}
-/* }}} */
-
-/* {{{ _mssql_bind_hash_dtor
-*/
-static void _mssql_bind_hash_dtor(void *data)
-{
- mssql_bind *bind= (mssql_bind *) data;
-
- zval_ptr_dtor(&(bind->zval));
-}
-/* }}} */
-
-/* {{{ PHP_GINIT_FUNCTION
-*/
-static PHP_GINIT_FUNCTION(mssql)
-{
- long compatibility_mode;
-
- mssql_globals->num_persistent = 0;
- mssql_globals->get_column_content = php_mssql_get_column_content_with_type;
- if (cfg_get_long("mssql.compatibility_mode", &compatibility_mode) == SUCCESS) {
- if (compatibility_mode) {
- mssql_globals->get_column_content = php_mssql_get_column_content_without_type;
- }
- }
-}
-/* }}} */
-
-/* {{{ PHP_MINIT_FUNCTION
-*/
-PHP_MINIT_FUNCTION(mssql)
-{
- REGISTER_INI_ENTRIES();
-
- le_statement = zend_register_list_destructors_ex(_free_mssql_statement, NULL, "mssql statement", module_number);
- le_result = zend_register_list_destructors_ex(_free_mssql_result, NULL, "mssql result", module_number);
- le_link = zend_register_list_destructors_ex(_close_mssql_link, NULL, "mssql link", module_number);
- le_plink = zend_register_list_destructors_ex(NULL, _close_mssql_plink, "mssql link persistent", module_number);
- Z_TYPE(mssql_module_entry) = type;
-
- if (dbinit()==FAIL) {
- return FAILURE;
- }
-
- /* BEGIN MSSQL data types for mssql_bind */
- REGISTER_LONG_CONSTANT("MSSQL_ASSOC", MSSQL_ASSOC, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("MSSQL_NUM", MSSQL_NUM, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("MSSQL_BOTH", MSSQL_BOTH, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("SQLTEXT",SQLTEXT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SQLVARCHAR",SQLVARCHAR, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SQLCHAR",SQLCHAR, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SQLINT1",SQLINT1, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SQLINT2",SQLINT2, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SQLINT4",SQLINT4, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SQLBIT",SQLBIT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SQLFLT4",SQLFLT4, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SQLFLT8",SQLFLT8, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SQLFLTN",SQLFLTN, CONST_CS | CONST_PERSISTENT);
- /* END MSSQL data types for mssql_bind */
-
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ PHP_MSHUTDOWN_FUNCTION
-*/
-PHP_MSHUTDOWN_FUNCTION(mssql)
-{
- UNREGISTER_INI_ENTRIES();
-#ifndef HAVE_FREETDS
- dbwinexit();
-#else
- dbexit();
-#endif
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ PHP_RINIT_FUNCTION
-*/
-PHP_RINIT_FUNCTION(mssql)
-{
- MS_SQL_G(default_link) = -1;
- MS_SQL_G(num_links) = MS_SQL_G(num_persistent);
- MS_SQL_G(appname) = estrndup("PHP 7", 5);
- MS_SQL_G(server_message) = NULL;
- MS_SQL_G(min_error_severity) = MS_SQL_G(cfg_min_error_severity);
- MS_SQL_G(min_message_severity) = MS_SQL_G(cfg_min_message_severity);
- if (MS_SQL_G(connect_timeout) < 1) MS_SQL_G(connect_timeout) = 1;
- if (MS_SQL_G(timeout) < 0) MS_SQL_G(timeout) = 60;
- if (MS_SQL_G(max_procs) != -1) {
- dbsetmaxprocs((TDS_SHORT)MS_SQL_G(max_procs));
- }
-
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ PHP_RSHUTDOWN_FUNCTION
-*/
-PHP_RSHUTDOWN_FUNCTION(mssql)
-{
- zend_string_free(MS_SQL_G(appname));
- MS_SQL_G(appname) = NULL;
- if (MS_SQL_G(server_message)) {
- zend_string_free(MS_SQL_G(server_message));
- MS_SQL_G(server_message) = NULL;
- }
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ PHP_MINFO_FUNCTION
-*/
-PHP_MINFO_FUNCTION(mssql)
-{
- char buf[32];
-
- php_info_print_table_start();
- php_info_print_table_header(2, "MSSQL Support", "enabled");
-
- snprintf(buf, sizeof(buf), "%ld", MS_SQL_G(num_persistent));
- php_info_print_table_row(2, "Active Persistent Links", buf);
- snprintf(buf, sizeof(buf), "%ld", MS_SQL_G(num_links));
- php_info_print_table_row(2, "Active Links", buf);
-
- php_info_print_table_row(2, "Library version", MSSQL_VERSION);
- php_info_print_table_end();
-
- DISPLAY_INI_ENTRIES();
-
-}
-/* }}} */
-
-/* {{{ php_mssql_do_connect
-*/
-static void php_mssql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
-{
- char *host = NULL, *user = NULL, *passwd = NULL;
- size_t host_len = 0, user_len = 0, passwd_len = 0;
- zend_bool new_link = 0;
- char *hashed_details;
- int hashed_details_length;
- mssql_link mssql, *mssql_ptr;
- char buffer[40];
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|sssb", &host, &host_len, &user, &user_len, &passwd, &passwd_len, &new_link) == FAILURE) {
- return;
- }
-
- /* Limit strings to 255 chars to prevent overflow issues in underlying libraries */
- if(host_len>255) {
- host[255] = '\0';
- }
- if(user_len>255) {
- user[255] = '\0';
- }
- if(passwd_len>255) {
- passwd[255] = '\0';
- }
-
- switch(ZEND_NUM_ARGS())
- {
- case 0:
- /* defaults */
- hashed_details_length=5+3;
- hashed_details = (char *) emalloc(hashed_details_length+1);
- strcpy(hashed_details, "mssql___");
- break;
- case 1:
- hashed_details_length = spprintf(&hashed_details, 0, "mssql_%s__", host);
- break;
- case 2:
- hashed_details_length = spprintf(&hashed_details, 0, "mssql_%s_%s_", host, user);
- break;
- case 3:
- case 4:
- hashed_details_length = spprintf(&hashed_details, 0, "mssql_%s_%s_%s", host, user, passwd);
- break;
- }
-
- if (hashed_details == NULL) {
- php_error_docref(NULL, E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
-
- dbsetlogintime(MS_SQL_G(connect_timeout));
- dbsettime(MS_SQL_G(timeout));
-
- /* set a DBLOGIN record */
- if ((mssql.login = dblogin()) == NULL) {
- php_error_docref(NULL, E_WARNING, "Unable to allocate login record");
- RETURN_FALSE;
- }
-
- DBERRHANDLE(mssql.login, (EHANDLEFUNC) php_mssql_error_handler);
- DBMSGHANDLE(mssql.login, (MHANDLEFUNC) php_mssql_message_handler);
-
-#ifndef HAVE_FREETDS
- if (MS_SQL_G(secure_connection)){
- DBSETLSECURE(mssql.login);
- }
- else {
-#endif
- if (user) {
- DBSETLUSER(mssql.login,user);
- }
- if (passwd) {
- DBSETLPWD(mssql.login,passwd);
- }
-#ifndef HAVE_FREETDS
- }
-#endif
-
-#ifdef HAVE_FREETDS
- if (MS_SQL_G(charset) && strlen(MS_SQL_G(charset))) {
- DBSETLCHARSET(mssql.login, MS_SQL_G(charset));
- }
-#endif
-
- DBSETLAPP(mssql.login,MS_SQL_G(appname));
- mssql.valid = 1;
-
-#ifndef HAVE_FREETDS
- DBSETLVERSION(mssql.login, DBVER60);
-#endif
-/* DBSETLTIME(mssql.login, TIMEOUT_INFINITE); */
-
- if (!MS_SQL_G(allow_persistent)) {
- persistent=0;
- }
- if (persistent) {
- zend_rsrc_list_entry *le;
-
- /* try to find if we already have this link in our persistent list */
- if (new_link || zend_hash_find(&EG(persistent_list), hashed_details, hashed_details_length + 1, (void **) &le)==FAILURE) { /* we don't */
- zend_rsrc_list_entry new_le;
-
- if (MS_SQL_G(max_links) != -1 && MS_SQL_G(num_links) >= MS_SQL_G(max_links)) {
- php_error_docref(NULL, E_WARNING, "Too many open links (%ld)", MS_SQL_G(num_links));
- efree(hashed_details);
- dbfreelogin(mssql.login);
- RETURN_FALSE;
- }
- if (MS_SQL_G(max_persistent) != -1 && MS_SQL_G(num_persistent) >= MS_SQL_G(max_persistent)) {
- php_error_docref(NULL, E_WARNING, "Too many open persistent links (%ld)", MS_SQL_G(num_persistent));
- efree(hashed_details);
- dbfreelogin(mssql.login);
- RETURN_FALSE;
- }
- /* create the link */
- if ((mssql.link = dbopen(mssql.login, host)) == FAIL) {
- php_error_docref(NULL, E_WARNING, "Unable to connect to server: %s", (host == NULL ? "" : host));
- efree(hashed_details);
- dbfreelogin(mssql.login);
- RETURN_FALSE;
- }
-
- if (DBSETOPT(mssql.link, DBBUFFER, "2")==FAIL) {
- efree(hashed_details);
- dbfreelogin(mssql.login);
- dbclose(mssql.link);
- RETURN_FALSE;
- }
-
-#ifndef HAVE_FREETDS
- if (MS_SQL_G(textlimit) != -1) {
- snprintf(buffer, sizeof(buffer), "%li", MS_SQL_G(textlimit));
- if (DBSETOPT(mssql.link, DBTEXTLIMIT, buffer)==FAIL) {
- efree(hashed_details);
- dbfreelogin(mssql.login);
- dbclose(mssql.link);
- RETURN_FALSE;
- }
- }
-#endif
- if (MS_SQL_G(textsize) != -1) {
- snprintf(buffer, sizeof(buffer), "SET TEXTSIZE %li", MS_SQL_G(textsize));
- dbcmd(mssql.link, buffer);
- dbsqlexec(mssql.link);
- dbresults(mssql.link);
- }
-
- /* hash it up */
- mssql_ptr = (mssql_link *) malloc(sizeof(mssql_link));
- if (!mssql_ptr) {
- efree(hashed_details);
- dbfreelogin(mssql.login);
- dbclose(mssql.link);
- RETURN_FALSE;
- }
-
- memcpy(mssql_ptr, &mssql, sizeof(mssql_link));
- Z_TYPE(new_le) = le_plink;
- new_le.ptr = mssql_ptr;
- if (zend_hash_update(&EG(persistent_list), hashed_details, hashed_details_length + 1, &new_le, sizeof(zend_rsrc_list_entry), NULL)==FAILURE) {
- free(mssql_ptr);
- efree(hashed_details);
- dbfreelogin(mssql.login);
- dbclose(mssql.link);
- RETURN_FALSE;
- }
- MS_SQL_G(num_persistent)++;
- MS_SQL_G(num_links)++;
- } else { /* we do */
- if (Z_TYPE_P(le) != le_plink) {
-#if BROKEN_MSSQL_PCONNECTS
- log_error("PHP/MS SQL: Hashed persistent link is not a MS SQL link!",php_rqst->server);
-#endif
- php_error_docref(NULL, E_WARNING, "Hashed persistent link is not a MS SQL link!");
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- mssql_ptr = (mssql_link *) le->ptr;
- /* test that the link hasn't died */
- if (DBDEAD(mssql_ptr->link) == TRUE) {
- dbclose(mssql_ptr->link);
-#if BROKEN_MSSQL_PCONNECTS
- log_error("PHP/MS SQL: Persistent link died, trying to reconnect...",php_rqst->server);
-#endif
- if ((mssql_ptr->link=dbopen(mssql_ptr->login,host))==NULL) {
-#if BROKEN_MSSQL_PCONNECTS
- log_error("PHP/MS SQL: Unable to reconnect!",php_rqst->server);
-#endif
- php_error_docref(NULL, E_WARNING, "Link to server lost, unable to reconnect");
- zend_hash_del(&EG(persistent_list), hashed_details, hashed_details_length+1);
- efree(hashed_details);
- dbfreelogin(mssql_ptr->login);
- RETURN_FALSE;
- }
-#if BROKEN_MSSQL_PCONNECTS
- log_error("PHP/MS SQL: Reconnect successful!",php_rqst->server);
-#endif
- if (DBSETOPT(mssql_ptr->link, DBBUFFER, "2")==FAIL) {
-#if BROKEN_MSSQL_PCONNECTS
- log_error("PHP/MS SQL: Unable to set required options",php_rqst->server);
-#endif
- zend_hash_del(&EG(persistent_list), hashed_details, hashed_details_length + 1);
- efree(hashed_details);
- dbfreelogin(mssql_ptr->login);
- dbclose(mssql_ptr->link);
- RETURN_FALSE;
- }
- }
- }
- ZEND_REGISTER_RESOURCE(return_value, mssql_ptr, le_plink);
- } else { /* non persistent */
- zend_rsrc_list_entry *index_ptr, new_index_ptr;
-
- /* first we check the hash for the hashed_details key. if it exists,
- * it should point us to the right offset where the actual mssql link sits.
- * if it doesn't, open a new mssql link, add it to the resource list,
- * and add a pointer to it with hashed_details as the key.
- */
- if (!new_link && zend_hash_find(&EG(regular_list), hashed_details, hashed_details_length + 1,(void **) &index_ptr)==SUCCESS) {
- int type,link;
- void *ptr;
-
- if (Z_TYPE_P(index_ptr) != le_index_ptr) {
- efree(hashed_details);
- dbfreelogin(mssql.login);
- RETURN_FALSE;
- }
- link = (int) index_ptr->ptr;
- ptr = zend_list_find(link,&type); /* check if the link is still there */
- if (ptr && (type==le_link || type==le_plink)) {
- zend_list_addref(link);
- Z_LVAL_P(return_value) = link;
- php_mssql_set_default_link(link);
- Z_TYPE_P(return_value) = IS_RESOURCE;
- dbfreelogin(mssql.login);
- efree(hashed_details);
- return;
- } else {
- zend_hash_del(&EG(regular_list), hashed_details, hashed_details_length + 1);
- }
- }
- if (MS_SQL_G(max_links) != -1 && MS_SQL_G(num_links) >= MS_SQL_G(max_links)) {
- php_error_docref(NULL, E_WARNING, "Too many open links (%ld)", MS_SQL_G(num_links));
- efree(hashed_details);
- dbfreelogin(mssql.login);
- RETURN_FALSE;
- }
-
- if ((mssql.link=dbopen(mssql.login, host))==NULL) {
- php_error_docref(NULL, E_WARNING, "Unable to connect to server: %s", (host == NULL ? "" : host));
- efree(hashed_details);
- dbfreelogin(mssql.login);
- RETURN_FALSE;
- }
-
- if (DBSETOPT(mssql.link, DBBUFFER,"2")==FAIL) {
- efree(hashed_details);
- dbfreelogin(mssql.login);
- dbclose(mssql.link);
- RETURN_FALSE;
- }
-
-#ifndef HAVE_FREETDS
- if (MS_SQL_G(textlimit) != -1) {
- snprintf(buffer, sizeof(buffer), "%li", MS_SQL_G(textlimit));
- if (DBSETOPT(mssql.link, DBTEXTLIMIT, buffer)==FAIL) {
- efree(hashed_details);
- dbfreelogin(mssql.login);
- dbclose(mssql.link);
- RETURN_FALSE;
- }
- }
-#endif
- if (MS_SQL_G(textsize) != -1) {
- snprintf(buffer, sizeof(buffer), "SET TEXTSIZE %li", MS_SQL_G(textsize));
- dbcmd(mssql.link, buffer);
- dbsqlexec(mssql.link);
- dbresults(mssql.link);
- }
-
- /* add it to the list */
- mssql_ptr = (mssql_link *) emalloc(sizeof(mssql_link));
- memcpy(mssql_ptr, &mssql, sizeof(mssql_link));
- ZEND_REGISTER_RESOURCE(return_value, mssql_ptr, le_link);
-
- /* add it to the hash */
- new_index_ptr.ptr = (void *) Z_LVAL_P(return_value);
- Z_TYPE(new_index_ptr) = le_index_ptr;
- if (zend_hash_update(&EG(regular_list), hashed_details, hashed_details_length + 1,(void *) &new_index_ptr, sizeof(zend_rsrc_list_entry),NULL)==FAILURE) {
- efree(hashed_details);
- RETURN_FALSE;
- }
- MS_SQL_G(num_links)++;
- }
- efree(hashed_details);
- php_mssql_set_default_link(Z_LVAL_P(return_value));
-}
-/* }}} */
-
-/* {{{ php_mssql_get_default_link
-*/
-static int php_mssql_get_default_link(INTERNAL_FUNCTION_PARAMETERS)
-{
- if (MS_SQL_G(default_link)==-1) { /* no link opened yet, implicitly open one */
- ht = 0;
- php_mssql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
- }
- return MS_SQL_G(default_link);
-}
-/* }}} */
-
-/* {{{ proto int mssql_connect([string servername [, string username [, string password [, bool new_link]]]])
- Establishes a connection to a MS-SQL server */
-PHP_FUNCTION(mssql_connect)
-{
- php_mssql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
-}
-/* }}} */
-
-/* {{{ proto int mssql_pconnect([string servername [, string username [, string password [, bool new_link]]]])
- Establishes a persistent connection to a MS-SQL server */
-PHP_FUNCTION(mssql_pconnect)
-{
- php_mssql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
-}
-/* }}} */
-
-/* {{{ proto bool mssql_close([resource conn_id])
- Closes a connection to a MS-SQL server */
-PHP_FUNCTION(mssql_close)
-{
- zval *mssql_link_index = NULL;
- int id = -1;
- mssql_link *mssql_ptr;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|r", &mssql_link_index) == FAILURE) {
- return;
- }
-
- if (mssql_link_index == NULL) {
- id = php_mssql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- CHECK_LINK(id);
- }
-
- ZEND_FETCH_RESOURCE2(mssql_ptr, mssql_link *, &mssql_link_index, id, "MS SQL-Link", le_link, le_plink);
-
- if (mssql_link_index) {
- zend_list_delete(Z_RESVAL_P(mssql_link_index));
- } else {
- zend_list_delete(id);
- }
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool mssql_select_db(string database_name [, resource conn_id])
- Select a MS-SQL database */
-PHP_FUNCTION(mssql_select_db)
-{
- char *db;
- zval *mssql_link_index = NULL;
- size_t db_len;
- int id = -1;
- mssql_link *mssql_ptr;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|r", &db, &db_len, &mssql_link_index) == FAILURE) {
- return;
- }
-
- if (mssql_link_index == NULL) {
- id = php_mssql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- CHECK_LINK(id);
- }
-
- ZEND_FETCH_RESOURCE2(mssql_ptr, mssql_link *, &mssql_link_index, id, "MS SQL-Link", le_link, le_plink);
-
- if (dbuse(mssql_ptr->link, db)==FAIL) {
- php_error_docref(NULL, E_WARNING, "Unable to select database: %s", db);
- RETURN_FALSE;
- } else {
- RETURN_TRUE;
- }
-}
-/* }}} */
-
-/* {{{ php_mssql_get_column_content_with_type
-*/
-static void php_mssql_get_column_content_with_type(mssql_link *mssql_ptr,int offset,zval *result, int column_type )
-{
- if (dbdata(mssql_ptr->link,offset) == NULL && dbdatlen(mssql_ptr->link,offset) == 0) {
- ZVAL_NULL(result);
- return;
- }
-
- switch (column_type)
- {
- case SQLBIT:
- case SQLINT1:
- case SQLINT2:
- case SQLINT4:
- case SQLINTN: {
- ZVAL_LONG(result, (long) anyintcol(offset));
- break;
- }
- case SQLCHAR:
- case SQLVARCHAR:
- case SQLTEXT: {
- int length;
- char *data = charcol(offset);
-
- length=dbdatlen(mssql_ptr->link,offset);
-#if ilia_0
- while (length>0 && data[length-1] == ' ') { /* nuke trailing whitespace */
- length--;
- }
-#endif
- ZVAL_STRINGL(result, data, length, 1);
- break;
- }
- case SQLFLT4:
- ZVAL_DOUBLE(result, (double) floatcol4(offset));
- break;
- case SQLMONEY:
- case SQLMONEY4:
- case SQLMONEYN: {
- DBFLT8 res_buf;
- dbconvert(NULL, column_type, dbdata(mssql_ptr->link,offset), 8, SQLFLT8, (LPBYTE)&res_buf, -1);
- ZVAL_DOUBLE(result, res_buf);
- }
- break;
- case SQLFLT8:
- ZVAL_DOUBLE(result, (double) floatcol8(offset));
- break;
-#ifdef SQLUNIQUE
- case SQLUNIQUE: {
-#else
- case 36: { /* FreeTDS hack */
-#endif
- char *data = charcol(offset);
-
- /* uniqueidentifier is a 16-byte binary number */
- ZVAL_STRINGL(result, data, 16, 1);
- }
- break;
- case SQLVARBINARY:
- case SQLBINARY:
- case SQLIMAGE: {
- int res_length = dbdatlen(mssql_ptr->link, offset);
-
- if (!res_length) {
- ZVAL_NULL(result);
- } else {
- ZVAL_STRINGL(result, (char *)dbdata(mssql_ptr->link, offset), res_length, 1);
- }
- }
- break;
- case SQLNUMERIC:
- default: {
- if (dbwillconvert(column_type,SQLCHAR)) {
- char *res_buf;
- DBDATEREC dateinfo;
- int res_length = dbdatlen(mssql_ptr->link,offset);
-
- if (res_length == -1) {
- res_length = 255;
- }
-
- if ((column_type != SQLDATETIME && column_type != SQLDATETIM4) || MS_SQL_G(datetimeconvert)) {
-
- switch (column_type) {
- case SQLDATETIME :
- case SQLDATETIM4 :
- res_length += 20;
- break;
- case SQLMONEY :
- case SQLMONEY4 :
- case SQLMONEYN :
- case SQLDECIMAL :
- case SQLNUMERIC :
- res_length += 5;
- case 127 :
- res_length += 20;
- break;
- }
-
- res_buf = (unsigned char *) emalloc(res_length+1);
- res_length = dbconvert(NULL,coltype(offset),dbdata(mssql_ptr->link,offset), res_length, SQLCHAR,res_buf,-1);
- res_buf[res_length] = '\0';
- } else {
- if (column_type == SQLDATETIM4) {
- DBDATETIME temp;
-
- dbconvert(NULL, SQLDATETIM4, dbdata(mssql_ptr->link,offset), -1, SQLDATETIME, (LPBYTE) &temp, -1);
- dbdatecrack(mssql_ptr->link, &dateinfo, &temp);
- } else {
- dbdatecrack(mssql_ptr->link, &dateinfo, (DBDATETIME *) dbdata(mssql_ptr->link,offset));
- }
-
- res_length = 19;
- spprintf(&res_buf, 0, "%d-%02d-%02d %02d:%02d:%02d" , dateinfo.year, dateinfo.month, dateinfo.day, dateinfo.hour, dateinfo.minute, dateinfo.second);
- }
-
- ZVAL_STRINGL(result, res_buf, res_length, 0);
- } else {
- php_error_docref(NULL, E_WARNING, "column %d has unknown data type (%d)", offset, coltype(offset));
- ZVAL_FALSE(result);
- }
- }
- }
-}
-/* }}} */
-
-/* {{{ php_mssql_get_column_content_without_type
-*/
-static void php_mssql_get_column_content_without_type(mssql_link *mssql_ptr,int offset,zval *result, int column_type)
-{
- if (dbdatlen(mssql_ptr->link,offset) == 0) {
- ZVAL_NULL(result);
- return;
- }
-
- if (column_type == SQLVARBINARY ||
- column_type == SQLBINARY ||
- column_type == SQLIMAGE) {
- DBBINARY *bin;
- unsigned char *res_buf;
- int res_length = dbdatlen(mssql_ptr->link, offset);
-
- if (res_length == 0) {
- ZVAL_NULL(result);
- return;
- } else if (res_length < 0) {
- ZVAL_FALSE(result);
- return;
- }
-
- res_buf = (unsigned char *) emalloc(res_length+1);
- bin = ((DBBINARY *)dbdata(mssql_ptr->link, offset));
- res_buf[res_length] = '\0';
- memcpy(res_buf, bin, res_length);
- ZVAL_STRINGL(result, res_buf, res_length, 0);
- }
- else if (dbwillconvert(coltype(offset),SQLCHAR)) {
- unsigned char *res_buf;
- DBDATEREC dateinfo;
- int res_length = dbdatlen(mssql_ptr->link,offset);
-
- if ((column_type != SQLDATETIME && column_type != SQLDATETIM4) || MS_SQL_G(datetimeconvert)) {
-
- switch (column_type) {
- case SQLDATETIME :
- case SQLDATETIM4 :
- res_length += 20;
- break;
- case SQLMONEY :
- case SQLMONEY4 :
- case SQLMONEYN :
- case SQLDECIMAL :
- case SQLNUMERIC :
- res_length += 5;
- case 127 :
- res_length += 20;
- break;
- }
-
- res_buf = (unsigned char *) emalloc(res_length+1);
- res_length = dbconvert(NULL,coltype(offset),dbdata(mssql_ptr->link,offset), res_length, SQLCHAR, res_buf, -1);
- res_buf[res_length] = '\0';
- } else {
- if (column_type == SQLDATETIM4) {
- DBDATETIME temp;
-
- dbconvert(NULL, SQLDATETIM4, dbdata(mssql_ptr->link,offset), -1, SQLDATETIME, (LPBYTE) &temp, -1);
- dbdatecrack(mssql_ptr->link, &dateinfo, &temp);
- } else {
- dbdatecrack(mssql_ptr->link, &dateinfo, (DBDATETIME *) dbdata(mssql_ptr->link,offset));
- }
-
- res_length = 19;
- spprintf(&res_buf, 0, "%d-%02d-%02d %02d:%02d:%02d" , dateinfo.year, dateinfo.month, dateinfo.day, dateinfo.hour, dateinfo.minute, dateinfo.second);
- }
-
- ZVAL_STRINGL(result, res_buf, res_length, 0);
- } else {
- php_error_docref(NULL, E_WARNING, "column %d has unknown data type (%d)", offset, coltype(offset));
- ZVAL_FALSE(result);
- }
-}
-/* }}} */
-
-/* {{{ _mssql_get_sp_result
-*/
-static void _mssql_get_sp_result(mssql_link *mssql_ptr, mssql_statement *statement)
-{
- int i, num_rets, type;
- char *parameter;
- mssql_bind *bind;
-
- /* Now to fetch RETVAL and OUTPUT values*/
- num_rets = dbnumrets(mssql_ptr->link);
-
- if (num_rets!=0) {
- for (i = 1; i <= num_rets; i++) {
- parameter = (char*)dbretname(mssql_ptr->link, i);
- type = dbrettype(mssql_ptr->link, i);
-
- if (statement->binds != NULL) { /* Maybe a non-parameter sp */
- if (zend_hash_find(statement->binds, parameter, strlen(parameter), (void**)&bind)==SUCCESS) {
- if (!dbretlen(mssql_ptr->link,i)) {
- ZVAL_NULL(bind->zval);
- }
- else {
- switch (type) {
- case SQLBIT:
- case SQLINT1:
- case SQLINT2:
- case SQLINT4:
- convert_to_long_ex(&bind->zval);
- /* FIXME this works only on little endian machine !!! */
- Z_LVAL_P(bind->zval) = *((int *)(dbretdata(mssql_ptr->link,i)));
- break;
-
- case SQLFLT4:
- case SQLFLT8:
- case SQLFLTN:
- case SQLMONEY4:
- case SQLMONEY:
- case SQLMONEYN:
- convert_to_double_ex(&bind->zval);
- Z_DVAL_P(bind->zval) = *((double *)(dbretdata(mssql_ptr->link,i)));
- break;
-
- case SQLCHAR:
- case SQLVARCHAR:
- case SQLTEXT:
- convert_to_string_ex(&bind->zval);
- Z_STRLEN_P(bind->zval) = dbretlen(mssql_ptr->link,i);
- Z_STRVAL_P(bind->zval) = estrndup(dbretdata(mssql_ptr->link,i),Z_STRLEN_P(bind->zval));
- break;
- /* TODO binary */
- }
- }
- }
- else {
- php_error_docref(NULL, E_WARNING, "An output parameter variable was not provided");
- }
- }
- }
- }
- if (statement->binds != NULL) { /* Maybe a non-parameter sp */
- if (zend_hash_find(statement->binds, "RETVAL", 6, (void**)&bind)==SUCCESS) {
- if (dbhasretstat(mssql_ptr->link)) {
- convert_to_long_ex(&bind->zval);
- Z_LVAL_P(bind->zval)=dbretstatus(mssql_ptr->link);
- }
- else {
- php_error_docref(NULL, E_WARNING, "stored procedure has no return value. Nothing was returned into RETVAL");
- }
- }
- }
-}
-/* }}} */
-
-/* {{{ _mssql_fetch_batch
-*/
-static int _mssql_fetch_batch(mssql_link *mssql_ptr, mssql_result *result, int retvalue)
-{
- int i, j = 0;
- char computed_buf[16];
-
- if (!result->have_fields) {
- for (i=0; i<result->num_fields; i++) {
- char *source = NULL;
- char *fname = (char *)dbcolname(mssql_ptr->link,i+1);
-
- if (*fname) {
- result->fields[i].name = estrdup(fname);
- } else {
- if (j>0) {
- snprintf(computed_buf,16,"computed%d",j);
- } else {
- strcpy(computed_buf,"computed");
- }
- result->fields[i].name = estrdup(computed_buf);
- j++;
- }
- result->fields[i].max_length = dbcollen(mssql_ptr->link,i+1);
- source = (char *)dbcolsource(mssql_ptr->link,i+1);
- if (source) {
- result->fields[i].column_source = estrdup(source);
- }
- else {
- result->fields[i].column_source = STR_EMPTY_ALLOC();
- }
-
- result->fields[i].type = coltype(i+1);
- /* set numeric flag */
- switch (result->fields[i].type) {
- case SQLINT1:
- case SQLINT2:
- case SQLINT4:
- case SQLINTN:
- case SQLFLT4:
- case SQLFLT8:
- case SQLNUMERIC:
- case SQLDECIMAL:
- result->fields[i].numeric = 1;
- break;
- case SQLCHAR:
- case SQLVARCHAR:
- case SQLTEXT:
- default:
- result->fields[i].numeric = 0;
- break;
- }
- }
- result->have_fields = 1;
- }
-
- i=0;
- if (!result->data) {
- result->data = (zval **) safe_emalloc(sizeof(zval *), MSSQL_ROWS_BLOCK*(++result->blocks_initialized), 0);
- }
- while (retvalue!=FAIL && retvalue!=NO_MORE_ROWS) {
- result->num_rows++;
- if (result->num_rows > result->blocks_initialized*MSSQL_ROWS_BLOCK) {
- result->data = (zval **) erealloc(result->data,sizeof(zval *)*MSSQL_ROWS_BLOCK*(++result->blocks_initialized));
- }
- result->data[i] = (zval *) safe_emalloc(sizeof(zval), result->num_fields, 0);
- for (j=0; j<result->num_fields; j++) {
- INIT_ZVAL(result->data[i][j]);
- MS_SQL_G(get_column_content(mssql_ptr, j+1, &result->data[i][j], result->fields[j].type));
- }
- if (i<result->batchsize || result->batchsize==0) {
- i++;
- dbclrbuf(mssql_ptr->link,DBLASTROW(mssql_ptr->link));
- retvalue=dbnextrow(mssql_ptr->link);
- }
- else
- break;
- result->lastresult = retvalue;
- }
- if (result->statement && (retvalue == NO_MORE_RESULTS || retvalue == NO_MORE_RPC_RESULTS)) {
- _mssql_get_sp_result(mssql_ptr, result->statement);
- }
- return i;
-}
-/* }}} */
-
-/* {{{ proto int mssql_fetch_batch(resource result_index)
- Returns the next batch of records */
-PHP_FUNCTION(mssql_fetch_batch)
-{
- zval *mssql_result_index;
- mssql_result *result;
- mssql_link *mssql_ptr;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &mssql_result_index) == FAILURE) {
- return;
- }
-
- if (Z_RESVAL_P(mssql_result_index) == 0) {
- RETURN_FALSE;
- }
-
- ZEND_FETCH_RESOURCE(result, mssql_result *, &mssql_result_index, -1, "MS SQL-result", le_result);
-
- mssql_ptr = result->mssql_ptr;
- _free_result(result, 0);
- result->cur_row=result->num_rows=0;
- result->num_rows = _mssql_fetch_batch(mssql_ptr, result, result->lastresult);
-
- RETURN_LONG(result->num_rows);
-}
-/* }}} */
-
-/* {{{ proto resource mssql_query(string query [, resource conn_id [, int batch_size]])
- Perform an SQL query on a MS-SQL server database */
-PHP_FUNCTION(mssql_query)
-{
- char *query;
- zval *mssql_link_index = NULL;
- size_t query_len;
- int retvalue, batchsize, num_fields;
- zend_long zbatchsize = 0;
- mssql_link *mssql_ptr;
- mssql_result *result;
- int id = -1;
-
- dbsettime(MS_SQL_G(timeout));
- batchsize = MS_SQL_G(batchsize);
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|rl", &query, &query_len, &mssql_link_index, &zbatchsize) == FAILURE) {
- return;
- }
-
- switch(ZEND_NUM_ARGS()) {
- case 1:
- id = php_mssql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- CHECK_LINK(id);
- break;
- case 3:
- batchsize = (int) zbatchsize;
- break;
- }
-
- ZEND_FETCH_RESOURCE2(mssql_ptr, mssql_link *, &mssql_link_index, id, "MS SQL-Link", le_link, le_plink);
-
- if (dbcmd(mssql_ptr->link, query)==FAIL) {
- php_error_docref(NULL, E_WARNING, "Unable to set query");
- RETURN_FALSE;
- }
- if (dbsqlexec(mssql_ptr->link)==FAIL || (retvalue = dbresults(mssql_ptr->link))==FAIL) {
- php_error_docref(NULL, E_WARNING, "Query failed");
- dbcancel(mssql_ptr->link);
- RETURN_FALSE;
- }
-
- /* Skip results not returning any columns */
- while ((num_fields = dbnumcols(mssql_ptr->link)) <= 0 && retvalue == SUCCEED) {
- retvalue = dbresults(mssql_ptr->link);
- }
-
- if (num_fields <= 0) {
- RETURN_TRUE;
- }
-
- retvalue=dbnextrow(mssql_ptr->link);
- if (retvalue==FAIL) {
- dbcancel(mssql_ptr->link);
- RETURN_FALSE;
- }
-
- result = (mssql_result *) emalloc(sizeof(mssql_result));
- result->statement = NULL;
- result->num_fields = num_fields;
- result->blocks_initialized = 1;
-
- result->batchsize = batchsize;
- result->data = NULL;
- result->blocks_initialized = 0;
- result->mssql_ptr = mssql_ptr;
- result->cur_field=result->cur_row=result->num_rows=0;
- result->have_fields = 0;
-
- result->fields = (mssql_field *) safe_emalloc(sizeof(mssql_field), result->num_fields, 0);
- result->num_rows = _mssql_fetch_batch(mssql_ptr, result, retvalue);
-
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
-}
-/* }}} */
-
-/* {{{ proto int mssql_rows_affected(resource conn_id)
- Returns the number of records affected by the query */
-PHP_FUNCTION(mssql_rows_affected)
-{
- zval *mssql_link_index;
- mssql_link *mssql_ptr;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &mssql_link_index) == FAILURE) {
- return;
- }
-
- ZEND_FETCH_RESOURCE2(mssql_ptr, mssql_link *, &mssql_link_index, -1, "MS SQL-Link", le_link, le_plink);
-
- RETURN_LONG(DBCOUNT(mssql_ptr->link));
-}
-/* }}} */
-
-/* {{{ proto bool mssql_free_result(resource result_index)
- Free a MS-SQL result index */
-PHP_FUNCTION(mssql_free_result)
-{
- zval *mssql_result_index;
- mssql_result *result;
- int retvalue;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &mssql_result_index) == FAILURE) {
- return;
- }
-
- if (Z_RESVAL_P(mssql_result_index) == 0) {
- RETURN_FALSE;
- }
-
- ZEND_FETCH_RESOURCE(result, mssql_result *, &mssql_result_index, -1, "MS SQL-result", le_result);
- /* Release remaining results */
- do {
- dbcanquery(result->mssql_ptr->link);
- retvalue = dbresults(result->mssql_ptr->link);
- } while (retvalue == SUCCEED);
-
- zend_list_delete(Z_RESVAL_P(mssql_result_index));
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto string mssql_get_last_message(void)
- Gets the last message from the MS-SQL server */
-PHP_FUNCTION(mssql_get_last_message)
-{
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- if (MS_SQL_G(server_message)) {
- RETURN_STRING(MS_SQL_G(server_message),1);
- } else {
- RETURN_STRING("",1);
- }
-}
-/* }}} */
-
-/* {{{ proto int mssql_num_rows(resource mssql_result_index)
- Returns the number of rows fetched in from the result id specified */
-PHP_FUNCTION(mssql_num_rows)
-{
- zval *mssql_result_index;
- mssql_result *result;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &mssql_result_index) == FAILURE) {
- return;
- }
-
- ZEND_FETCH_RESOURCE(result, mssql_result *, &mssql_result_index, -1, "MS SQL-result", le_result);
-
- RETURN_LONG(result->num_rows);
-}
-/* }}} */
-
-/* {{{ proto int mssql_num_fields(resource mssql_result_index)
- Returns the number of fields fetched in from the result id specified */
-PHP_FUNCTION(mssql_num_fields)
-{
- zval *mssql_result_index;
- mssql_result *result;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &mssql_result_index) == FAILURE) {
- return;
- }
-
- ZEND_FETCH_RESOURCE(result, mssql_result *, &mssql_result_index, -1, "MS SQL-result", le_result);
-
- RETURN_LONG(result->num_fields);
-}
-/* }}} */
-
-/* {{{ php_mssql_fetch_hash
-*/
-static void php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
-{
- zval *mssql_result_index;
- mssql_result *result;
- int i;
- zend_long resulttype = 0;
-
- switch (result_type) {
- case MSSQL_NUM:
- case MSSQL_ASSOC:
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &mssql_result_index) == FAILURE) {
- return;
- }
- break;
- case MSSQL_BOTH:
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &mssql_result_index, &resulttype) == FAILURE) {
- return;
- }
- result_type = (resulttype > 0 && (resulttype & MSSQL_BOTH)) ? resulttype : result_type;
- break;
- default:
- return;
- }
-
- ZEND_FETCH_RESOURCE(result, mssql_result *, &mssql_result_index, -1, "MS SQL-result", le_result);
-
- if (MS_SQL_G(server_message)) {
- zend_string_free(MS_SQL_G(server_message));
- MS_SQL_G(server_message) = NULL;
- }
-
- if (result->cur_row >= result->num_rows) {
- RETURN_FALSE;
- }
-
- array_init(return_value);
-
- for (i=0; i<result->num_fields; i++) {
- if (Z_TYPE(result->data[result->cur_row][i]) != IS_NULL) {
- char *data;
- int data_len;
-
- if (Z_TYPE(result->data[result->cur_row][i]) == IS_STRING) {
- data = Z_STRVAL(result->data[result->cur_row][i]);
- data_len = Z_STRLEN(result->data[result->cur_row][i]);
-
- if (result_type & MSSQL_NUM) {
- add_index_stringl(return_value, i, data, data_len);
- }
-
- if (result_type & MSSQL_ASSOC) {
- add_assoc_stringl(return_value, result->fields[i].name, data, data_len);
- }
- }
- else if (Z_TYPE(result->data[result->cur_row][i]) == IS_LONG) {
- if (result_type & MSSQL_NUM)
- add_index_long(return_value, i, Z_LVAL(result->data[result->cur_row][i]));
-
- if (result_type & MSSQL_ASSOC)
- add_assoc_long(return_value, result->fields[i].name, Z_LVAL(result->data[result->cur_row][i]));
- }
- else if (Z_TYPE(result->data[result->cur_row][i]) == IS_DOUBLE) {
- if (result_type & MSSQL_NUM)
- add_index_double(return_value, i, Z_DVAL(result->data[result->cur_row][i]));
-
- if (result_type & MSSQL_ASSOC)
- add_assoc_double(return_value, result->fields[i].name, Z_DVAL(result->data[result->cur_row][i]));
- }
- }
- else
- {
- if (result_type & MSSQL_NUM)
- add_index_null(return_value, i);
- if (result_type & MSSQL_ASSOC)
- add_assoc_null(return_value, result->fields[i].name);
- }
- }
- result->cur_row++;
-}
-/* }}} */
-
-/* {{{ proto array mssql_fetch_row(resource result_id)
- Returns an array of the current row in the result set specified by result_id */
-PHP_FUNCTION(mssql_fetch_row)
-{
- php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MSSQL_NUM);
-}
-/* }}} */
-
-/* {{{ proto object mssql_fetch_object(resource result_id)
- Returns a pseudo-object of the current row in the result set specified by result_id */
-PHP_FUNCTION(mssql_fetch_object)
-{
- php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MSSQL_ASSOC);
- if (Z_TYPE_P(return_value)==IS_ARRAY) {
- object_and_properties_init(return_value, ZEND_STANDARD_CLASS_DEF_PTR, Z_ARRVAL_P(return_value));
- }
-}
-/* }}} */
-
-/* {{{ proto array mssql_fetch_array(resource result_id [, int result_type])
- Returns an associative array of the current row in the result set specified by result_id */
-PHP_FUNCTION(mssql_fetch_array)
-{
- php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MSSQL_BOTH);
-}
-/* }}} */
-
-/* {{{ proto array mssql_fetch_assoc(resource result_id)
- Returns an associative array of the current row in the result set specified by result_id */
-PHP_FUNCTION(mssql_fetch_assoc)
-{
- php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MSSQL_ASSOC);
-}
-/* }}} */
-
-/* {{{ proto bool mssql_data_seek(resource result_id, int offset)
- Moves the internal row pointer of the MS-SQL result associated with the specified result identifier to pointer to the specified row number */
-PHP_FUNCTION(mssql_data_seek)
-{
- zval *mssql_result_index;
- zend_long offset;
- mssql_result *result;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &mssql_result_index, &offset) == FAILURE) {
- return;
- }
-
- ZEND_FETCH_RESOURCE(result, mssql_result *, &mssql_result_index, -1, "MS SQL-result", le_result);
-
- if (offset < 0 || offset >= result->num_rows) {
- php_error_docref(NULL, E_WARNING, "Bad row offset");
- RETURN_FALSE;
- }
-
- result->cur_row = offset;
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ php_mssql_get_field_name
-*/
-static char *php_mssql_get_field_name(int type)
-{
- switch (type) {
- case SQLBINARY:
- case SQLVARBINARY:
- return "blob";
- break;
- case SQLCHAR:
- case SQLVARCHAR:
- return "char";
- break;
- case SQLTEXT:
- return "text";
- break;
- case SQLDATETIME:
- case SQLDATETIM4:
- case SQLDATETIMN:
- return "datetime";
- break;
- case SQLDECIMAL:
- case SQLFLT4:
- case SQLFLT8:
- case SQLFLTN:
- return "real";
- break;
- case SQLINT1:
- case SQLINT2:
- case SQLINT4:
- case SQLINTN:
- return "int";
- break;
- case SQLNUMERIC:
- return "numeric";
- break;
- case SQLMONEY:
- case SQLMONEY4:
- case SQLMONEYN:
- return "money";
- break;
- case SQLBIT:
- return "bit";
- break;
- case SQLIMAGE:
- return "image";
- break;
-#ifdef SQLUNIQUE
- case SQLUNIQUE:
- return "uniqueidentifier";
- break;
-#endif
- default:
- return "unknown";
- break;
- }
-}
-/* }}} */
-
-/* {{{ proto object mssql_fetch_field(resource result_id [, int offset])
- Gets information about certain fields in a query result */
-PHP_FUNCTION(mssql_fetch_field)
-{
- zval *mssql_result_index;
- zend_long field_offset = -1;
- mssql_result *result;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &mssql_result_index, &field_offset) == FAILURE) {
- return;
- }
-
- ZEND_FETCH_RESOURCE(result, mssql_result *, &mssql_result_index, -1, "MS SQL-result", le_result);
-
- if (field_offset==-1) {
- field_offset = result->cur_field;
- result->cur_field++;
- }
-
- if (field_offset<0 || field_offset >= result->num_fields) {
- if (ZEND_NUM_ARGS()==2) { /* field specified explicitly */
- php_error_docref(NULL, E_WARNING, "Bad column offset");
- }
- RETURN_FALSE;
- }
-
- object_init(return_value);
-
- add_property_string(return_value, "name",result->fields[field_offset].name);
- add_property_long(return_value, "max_length",result->fields[field_offset].max_length);
- add_property_string(return_value, "column_source",result->fields[field_offset].column_source);
- add_property_long(return_value, "numeric", result->fields[field_offset].numeric);
- add_property_string(return_value, "type", php_mssql_get_field_name(Z_TYPE(result->fields[field_offset])));
-}
-/* }}} */
-
-/* {{{ proto int mssql_field_length(resource result_id [, int offset])
- Get the length of a MS-SQL field */
-PHP_FUNCTION(mssql_field_length)
-{
- zval *mssql_result_index;
- zend_long field_offset = -1;
- mssql_result *result;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &mssql_result_index, &field_offset) == FAILURE) {
- return;
- }
-
- ZEND_FETCH_RESOURCE(result, mssql_result *, &mssql_result_index, -1, "MS SQL-result", le_result);
-
- if (field_offset==-1) {
- field_offset = result->cur_field;
- result->cur_field++;
- }
-
- if (field_offset<0 || field_offset >= result->num_fields) {
- if (ZEND_NUM_ARGS()==2) { /* field specified explicitly */
- php_error_docref(NULL, E_WARNING, "Bad column offset");
- }
- RETURN_FALSE;
- }
-
- RETURN_LONG(result->fields[field_offset].max_length);
-}
-/* }}} */
-
-/* {{{ proto string mssql_field_name(resource result_id [, int offset])
- Returns the name of the field given by offset in the result set given by result_id */
-PHP_FUNCTION(mssql_field_name)
-{
- zval *mssql_result_index;
- zend_long field_offset = -1;
- mssql_result *result;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &mssql_result_index, &field_offset) == FAILURE) {
- return;
- }
-
- ZEND_FETCH_RESOURCE(result, mssql_result *, &mssql_result_index, -1, "MS SQL-result", le_result);
-
- if (field_offset==-1) {
- field_offset = result->cur_field;
- result->cur_field++;
- }
-
- if (field_offset<0 || field_offset >= result->num_fields) {
- if (ZEND_NUM_ARGS()==2) { /* field specified explicitly */
- php_error_docref(NULL, E_WARNING, "Bad column offset");
- }
- RETURN_FALSE;
- }
-
- RETURN_STRINGL(result->fields[field_offset].name, strlen(result->fields[field_offset].name), 1);
-}
-/* }}} */
-
-/* {{{ proto string mssql_field_type(resource result_id [, int offset])
- Returns the type of a field */
-PHP_FUNCTION(mssql_field_type)
-{
- zval *mssql_result_index;
- zend_long field_offset = -1;
- mssql_result *result;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &mssql_result_index, &field_offset) == FAILURE) {
- return;
- }
-
- ZEND_FETCH_RESOURCE(result, mssql_result *, &mssql_result_index, -1, "MS SQL-result", le_result);
-
- if (field_offset==-1) {
- field_offset = result->cur_field;
- result->cur_field++;
- }
-
- if (field_offset<0 || field_offset >= result->num_fields) {
- if (ZEND_NUM_ARGS()==2) { /* field specified explicitly */
- php_error_docref(NULL, E_WARNING, "Bad column offset");
- }
- RETURN_FALSE;
- }
-
- RETURN_STRINGL(php_mssql_get_field_name(Z_TYPE(result->fields[field_offset])), strlen(php_mssql_get_field_name(Z_TYPE(result->fields[field_offset]))), 1);
-}
-/* }}} */
-
-/* {{{ proto bool mssql_field_seek(resource result_id, int offset)
- Seeks to the specified field offset */
-PHP_FUNCTION(mssql_field_seek)
-{
- zval *mssql_result_index;
- zend_long field_offset;
- mssql_result *result;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &mssql_result_index, &field_offset) == FAILURE) {
- return;
- }
-
- ZEND_FETCH_RESOURCE(result, mssql_result *, &mssql_result_index, -1, "MS SQL-result", le_result);
-
- if (field_offset<0 || field_offset >= result->num_fields) {
- php_error_docref(NULL, E_WARNING, "Bad column offset");
- RETURN_FALSE;
- }
-
- result->cur_field = field_offset;
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto string mssql_result(resource result_id, int row, mixed field)
- Returns the contents of one cell from a MS-SQL result set */
-PHP_FUNCTION(mssql_result)
-{
- zval **field, *mssql_result_index;
- zend_long row;
- int field_offset=0;
- mssql_result *result;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlZ", &mssql_result_index, &row, &field) == FAILURE) {
- return;
- }
-
- ZEND_FETCH_RESOURCE(result, mssql_result *, &mssql_result_index, -1, "MS SQL-result", le_result);
-
- if (row < 0 || row >= result->num_rows) {
- php_error_docref(NULL, E_WARNING, "Bad row offset (%ld)", row);
- RETURN_FALSE;
- }
-
- switch(Z_TYPE_PP(field)) {
- case IS_STRING: {
- int i;
-
- for (i=0; i<result->num_fields; i++) {
- if (!strcasecmp(result->fields[i].name, Z_STRVAL_PP(field))) {
- field_offset = i;
- break;
- }
- }
- if (i>=result->num_fields) { /* no match found */
- php_error_docref(NULL, E_WARNING, "%s field not found in result", Z_STRVAL_PP(field));
- RETURN_FALSE;
- }
- break;
- }
- default:
- convert_to_long_ex(field);
- field_offset = Z_LVAL_PP(field);
- if (field_offset<0 || field_offset>=result->num_fields) {
- php_error_docref(NULL, E_WARNING, "Bad column offset specified");
- RETURN_FALSE;
- }
- break;
- }
-
- *return_value = result->data[row][field_offset];
- zval_copy_ctor(return_value);
-}
-/* }}} */
-
-/* {{{ proto bool mssql_next_result(resource result_id)
- Move the internal result pointer to the next result */
-PHP_FUNCTION(mssql_next_result)
-{
- zval *mssql_result_index;
- int retvalue;
- mssql_result *result;
- mssql_link *mssql_ptr;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &mssql_result_index) == FAILURE) {
- return;
- }
-
- ZEND_FETCH_RESOURCE(result, mssql_result *, &mssql_result_index, -1, "MS SQL-result", le_result);
-
- mssql_ptr = result->mssql_ptr;
- retvalue = dbresults(mssql_ptr->link);
-
- while (dbnumcols(mssql_ptr->link) <= 0 && retvalue == SUCCEED) {
- retvalue = dbresults(mssql_ptr->link);
- }
-
- if (retvalue == FAIL) {
- RETURN_FALSE;
- }
- else if (retvalue == NO_MORE_RESULTS || retvalue == NO_MORE_RPC_RESULTS) {
- if (result->statement) {
- _mssql_get_sp_result(mssql_ptr, result->statement);
- }
- RETURN_FALSE;
- }
- else {
- _free_result(result, 1);
- result->cur_row=result->num_fields=result->num_rows=0;
- dbclrbuf(mssql_ptr->link,DBLASTROW(mssql_ptr->link));
- retvalue = dbnextrow(mssql_ptr->link);
-
- result->num_fields = dbnumcols(mssql_ptr->link);
- result->fields = (mssql_field *) safe_emalloc(sizeof(mssql_field), result->num_fields, 0);
- result->have_fields = 0;
- result->num_rows = _mssql_fetch_batch(mssql_ptr, result, retvalue);
- RETURN_TRUE;
- }
-
-}
-/* }}} */
-
-
-/* {{{ proto void mssql_min_error_severity(int severity)
- Sets the lower error severity */
-PHP_FUNCTION(mssql_min_error_severity)
-{
- zend_long severity;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &severity) == FAILURE) {
- return;
- }
-
- MS_SQL_G(min_error_severity) = severity;
-}
-
-/* }}} */
-
-/* {{{ proto void mssql_min_message_severity(int severity)
- Sets the lower message severity */
-PHP_FUNCTION(mssql_min_message_severity)
-{
- zend_long severity;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &severity) == FAILURE) {
- return;
- }
-
- MS_SQL_G(min_message_severity) = severity;
-}
-/* }}} */
-
-/* {{{ proto int mssql_init(string sp_name [, resource conn_id])
- Initializes a stored procedure or a remote stored procedure */
-PHP_FUNCTION(mssql_init)
-{
- char *sp_name;
- size_t sp_name_len;
- zval *mssql_link_index = NULL;
- mssql_link *mssql_ptr;
- mssql_statement *statement;
- int id = -1;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|r", &sp_name, &sp_name_len, &mssql_link_index) == FAILURE) {
- return;
- }
-
- if (mssql_link_index == NULL) {
- id = php_mssql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- CHECK_LINK(id);
- }
-
- ZEND_FETCH_RESOURCE2(mssql_ptr, mssql_link *, &mssql_link_index, id, "MS SQL-Link", le_link, le_plink);
-
- if (dbrpcinit(mssql_ptr->link, sp_name,0)==FAIL) {
- php_error_docref(NULL, E_WARNING, "unable to init stored procedure");
- RETURN_FALSE;
- }
-
- statement=NULL;
- statement = ecalloc(1,sizeof(mssql_statement));
- statement->link = mssql_ptr;
- statement->executed=FALSE;
-
- statement->id = zend_list_insert(statement,le_statement);
-
- RETURN_RESOURCE(statement->id);
-}
-/* }}} */
-
-/* {{{ proto bool mssql_bind(resource stmt, string param_name, mixed var, int type [, bool is_output [, bool is_null [, int maxlen]]])
- Adds a parameter to a stored procedure or a remote stored procedure */
-PHP_FUNCTION(mssql_bind)
-{
- char *param_name;
- size_t param_name_len;
- int datalen;
- int status = 0;
- zend_long type = 0, maxlen = -1;
- zval *stmt, **var;
- zend_bool is_output = 0, is_null = 0;
- mssql_link *mssql_ptr;
- mssql_statement *statement;
- mssql_bind bind,*bindp;
- LPBYTE value = NULL;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsZl|bbl", &stmt, &param_name, &param_name_len, &var, &type, &is_output, &is_null, &maxlen) == FAILURE) {
- return;
- }
-
- if (ZEND_NUM_ARGS() == 7 && !is_output) {
- maxlen = -1;
- }
-
- ZEND_FETCH_RESOURCE(statement, mssql_statement *, &stmt, -1, "MS SQL-Statement", le_statement);
-
- if (statement==NULL) {
- RETURN_FALSE;
- }
- mssql_ptr=statement->link;
-
- /* modify datalen and maxlen according to dbrpcparam documentation */
- if ( (type==SQLVARCHAR) || (type==SQLCHAR) || (type==SQLTEXT) ) { /* variable-length type */
- if (is_null) {
- maxlen=0;
- datalen=0;
- } else {
- convert_to_string_ex(var);
- datalen=Z_STRLEN_PP(var);
- value=(LPBYTE)Z_STRVAL_PP(var);
- }
- } else {
- /* fixed-length type */
- if (is_null) {
- datalen=0;
- } else {
- datalen=-1;
- }
- maxlen=-1;
-
- switch (type) {
- case SQLFLT4:
- case SQLFLT8:
- case SQLFLTN:
- convert_to_double_ex(var);
- value=(LPBYTE)(&Z_DVAL_PP(var));
- break;
-
- case SQLBIT:
- case SQLINT1:
- case SQLINT2:
- case SQLINT4:
- convert_to_long_ex(var);
- value=(LPBYTE)(&Z_LVAL_PP(var));
- break;
-
- default:
- php_error_docref(NULL, E_WARNING, "unsupported type");
- RETURN_FALSE;
- break;
- }
- }
-
- if (is_output) {
- status=DBRPCRETURN;
- }
-
- /* hashtable of binds */
- if (! statement->binds) {
- ALLOC_HASHTABLE(statement->binds);
- zend_hash_init(statement->binds, 13, NULL, _mssql_bind_hash_dtor, 0);
- }
-
- if (zend_hash_exists(statement->binds, param_name, param_name_len)) {
- RETURN_FALSE;
- }
- else {
- memset((void*)&bind,0,sizeof(mssql_bind));
- zend_hash_add(statement->binds, param_name, param_name_len, &bind, sizeof(mssql_bind), (void **)&bindp);
- if( NULL == bindp ) RETURN_FALSE;
- bindp->zval=*var;
- zval_add_ref(var);
-
- /* no call to dbrpcparam if RETVAL */
- if ( strcmp("RETVAL", param_name)!=0 ) {
- if (dbrpcparam(mssql_ptr->link, param_name, (BYTE)status, type, maxlen, datalen, (LPBYTE)value)==FAIL) {
- php_error_docref(NULL, E_WARNING, "Unable to set parameter");
- RETURN_FALSE;
- }
- }
- }
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto mixed mssql_execute(resource stmt [, bool skip_results = false])
- Executes a stored procedure on a MS-SQL server database */
-PHP_FUNCTION(mssql_execute)
-{
- zval *stmt;
- zend_bool skip_results = 0;
- int retvalue, retval_results;
- mssql_link *mssql_ptr;
- mssql_statement *statement;
- mssql_result *result;
- int num_fields;
- int batchsize;
- int exec_retval;
-
- batchsize = MS_SQL_G(batchsize);
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|b", &stmt, &skip_results) == FAILURE) {
- return;
- }
-
- ZEND_FETCH_RESOURCE(statement, mssql_statement *, &stmt, -1, "MS SQL-Statement", le_statement);
-
- mssql_ptr=statement->link;
- exec_retval = dbrpcexec(mssql_ptr->link);
-
- if (exec_retval == FAIL || dbsqlok(mssql_ptr->link) == FAIL) {
- php_error_docref(NULL, E_WARNING, "stored procedure execution failed");
-
- if (exec_retval == FAIL) {
- dbcancel(mssql_ptr->link);
- }
-
- RETURN_FALSE;
- }
-
- retval_results=dbresults(mssql_ptr->link);
-
- if (retval_results==FAIL) {
- php_error_docref(NULL, E_WARNING, "could not retrieve results");
- dbcancel(mssql_ptr->link);
- RETURN_FALSE;
- }
-
- /* The following is just like mssql_query, fetch all rows from the first result
- * set into the row buffer.
- */
- result=NULL;
- if (retval_results == SUCCEED) {
- if (skip_results) {
- do {
- dbcanquery(mssql_ptr->link);
- retval_results = dbresults(mssql_ptr->link);
- } while (retval_results == SUCCEED);
- }
- else {
- /* Skip results not returning any columns */
- while ((num_fields = dbnumcols(mssql_ptr->link)) <= 0 && retval_results == SUCCEED) {
- retval_results = dbresults(mssql_ptr->link);
- }
- if ((num_fields = dbnumcols(mssql_ptr->link)) > 0) {
- retvalue = dbnextrow(mssql_ptr->link);
- result = (mssql_result *) emalloc(sizeof(mssql_result));
- result->batchsize = batchsize;
- result->blocks_initialized = 1;
- result->data = (zval **) safe_emalloc(sizeof(zval *), MSSQL_ROWS_BLOCK, 0);
- result->mssql_ptr = mssql_ptr;
- result->cur_field=result->cur_row=result->num_rows=0;
- result->num_fields = num_fields;
- result->have_fields = 0;
-
- result->fields = (mssql_field *) safe_emalloc(sizeof(mssql_field), num_fields, 0);
- result->statement = statement;
- result->num_rows = _mssql_fetch_batch(mssql_ptr, result, retvalue);
- }
- }
- }
- if (retval_results == NO_MORE_RESULTS || retval_results == NO_MORE_RPC_RESULTS) {
- _mssql_get_sp_result(mssql_ptr, statement);
- }
-
- if (result==NULL) {
- RETURN_TRUE; /* no recordset returned ...*/
- }
- else {
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
- }
-}
-/* }}} */
-
-/* {{{ proto bool mssql_free_statement(resource result_index)
- Free a MS-SQL statement index */
-PHP_FUNCTION(mssql_free_statement)
-{
- zval *mssql_statement_index;
- mssql_statement *statement;
- int retvalue;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &mssql_statement_index) == FAILURE) {
- return;
- }
-
- if (Z_RESVAL_P(mssql_statement_index) == 0) {
- RETURN_FALSE;
- }
-
- ZEND_FETCH_RESOURCE(statement, mssql_statement *, &mssql_statement_index, -1, "MS SQL-statement", le_statement);
- /* Release remaining results */
- do {
- dbcanquery(statement->link->link);
- retvalue = dbresults(statement->link->link);
- } while (retvalue == SUCCEED);
-
- zend_list_delete(Z_RESVAL_P(mssql_statement_index));
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto string mssql_guid_string(string binary [,bool short_format])
- Converts a 16 byte binary GUID to a string */
-PHP_FUNCTION(mssql_guid_string)
-{
- char *binary;
- size_t binary_len;
- zend_bool sf = 0;
- char buffer[32+1];
- char buffer2[36+1];
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &binary, &binary_len, &sf) == FAILURE) {
- return;
- }
-
- dbconvert(NULL, SQLBINARY, (BYTE*) binary, MIN(16, binary_len), SQLCHAR, buffer, -1);
-
- if (sf) {
- php_strtoupper(buffer, 32);
- RETURN_STRING(buffer, 1);
- }
- else {
- int i;
- /* FIXME this works only on little endian machine */
- for (i=0; i<4; i++) {
- buffer2[2*i] = buffer[6-2*i];
- buffer2[2*i+1] = buffer[7-2*i];
- }
- buffer2[8] = '-';
- for (i=0; i<2; i++) {
- buffer2[9+2*i] = buffer[10-2*i];
- buffer2[10+2*i] = buffer[11-2*i];
- }
- buffer2[13] = '-';
- for (i=0; i<2; i++) {
- buffer2[14+2*i] = buffer[14-2*i];
- buffer2[15+2*i] = buffer[15-2*i];
- }
- buffer2[18] = '-';
- for (i=0; i<4; i++) {
- buffer2[19+i] = buffer[16+i];
- }
- buffer2[23] = '-';
- for (i=0; i<12; i++) {
- buffer2[24+i] = buffer[20+i];
- }
- buffer2[36] = 0;
-
- php_strtoupper(buffer2, 36);
- RETURN_STRING(buffer2, 1);
- }
-}
-/* }}} */
-
-#endif
diff --git a/ext/mssql/php_mssql.h b/ext/mssql/php_mssql.h
deleted file mode 100644
index 18a82ef652..0000000000
--- a/ext/mssql/php_mssql.h
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.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: Frank M. Kromann <frank@kromann.info> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef PHP_MSSQL_H
-#define PHP_MSSQL_H
-
-
-#if HAVE_MSSQL
-#define MSDBLIB
-
-/* FreeTDS checks for PHP_MSSQL_API for avoid type redefinition */
-#ifdef HAVE_FREETDS
-#define PHP_MSSQL_API
-#endif
-
-#include <sqlfront.h>
-#include <sqldb.h>
-
-typedef short TDS_SHORT;
-#ifdef HAVE_FREETDS
-#define MSSQL_VERSION "FreeTDS"
-#define SQLTEXT SYBTEXT
-#define SQLCHAR SYBCHAR
-#define SQLVARCHAR SYBVARCHAR
-#define SQLINT1 SYBINT1
-#define SQLINT2 SYBINT2
-#define SQLINT4 SYBINT4
-#define SQLINTN SYBINTN
-#define SQLBIT SYBBIT
-#define SQLFLT4 SYBREAL
-#define SQLFLT8 SYBFLT8
-#define SQLFLTN SYBFLTN
-#define SQLDECIMAL SYBDECIMAL
-#define SQLNUMERIC SYBNUMERIC
-#define SQLDATETIME SYBDATETIME
-#define SQLDATETIM4 SYBDATETIME4
-#define SQLDATETIMN SYBDATETIMN
-#define SQLMONEY SYBMONEY
-#define SQLMONEY4 SYBMONEY4
-#define SQLMONEYN SYBMONEYN
-#define SQLIMAGE SYBIMAGE
-#define SQLBINARY SYBBINARY
-#define SQLVARBINARY SYBVARBINARY
-#ifdef SQLUNIQUE /* FreeTSD 0.61+ */
-#define SQLUNIQUE SYBUNIQUE
-#endif
-#define DBERRHANDLE(a, b) dberrhandle(b)
-#define DBMSGHANDLE(a, b) dbmsghandle(b)
-#define DBSETOPT(a, b, c) dbsetopt(a, b, c, -1)
-#define NO_MORE_RPC_RESULTS 3
-#ifndef dbfreelogin
-#define dbfreelogin dbloginfree
-#endif
-#define dbrpcexec dbrpcsend
-typedef unsigned char *LPBYTE;
-typedef float DBFLT4;
-#else
-#define MSSQL_VERSION "7.0"
-#define DBERRHANDLE(a, b) dbprocerrhandle(a, b)
-#define DBMSGHANDLE(a, b) dbprocmsghandle(a, b)
-#define EHANDLEFUNC DBERRHANDLE_PROC
-#define MHANDLEFUNC DBMSGHANDLE_PROC
-#define DBSETOPT(a, b, c) dbsetopt(a, b, c)
-#endif
-
-#define coltype(j) dbcoltype(mssql_ptr->link,j)
-#define intcol(i) ((int) *(DBINT *) dbdata(mssql_ptr->link,i))
-#define smallintcol(i) ((int) *(DBSMALLINT *) dbdata(mssql_ptr->link,i))
-#define tinyintcol(i) ((int) *(DBTINYINT *) dbdata(mssql_ptr->link,i))
-#define anyintcol(j) (coltype(j)==SQLINT4?intcol(j):(coltype(j)==SQLINT2?smallintcol(j):tinyintcol(j)))
-#define charcol(i) ((DBCHAR *) dbdata(mssql_ptr->link,i))
-#define floatcol4(i) (*(DBFLT4 *) dbdata(mssql_ptr->link,i))
-#define floatcol8(i) (*(DBFLT8 *) dbdata(mssql_ptr->link,i))
-
-#ifdef ZTS
-#include "TSRM.h"
-#endif
-
-extern zend_module_entry mssql_module_entry;
-#define mssql_module_ptr &mssql_module_entry
-
-PHP_MINIT_FUNCTION(mssql);
-PHP_MSHUTDOWN_FUNCTION(mssql);
-PHP_RINIT_FUNCTION(mssql);
-PHP_RSHUTDOWN_FUNCTION(mssql);
-PHP_MINFO_FUNCTION(mssql);
-
-PHP_FUNCTION(mssql_connect);
-PHP_FUNCTION(mssql_pconnect);
-PHP_FUNCTION(mssql_close);
-PHP_FUNCTION(mssql_select_db);
-PHP_FUNCTION(mssql_query);
-PHP_FUNCTION(mssql_fetch_batch);
-PHP_FUNCTION(mssql_rows_affected);
-PHP_FUNCTION(mssql_free_result);
-PHP_FUNCTION(mssql_get_last_message);
-PHP_FUNCTION(mssql_num_rows);
-PHP_FUNCTION(mssql_num_fields);
-PHP_FUNCTION(mssql_fetch_field);
-PHP_FUNCTION(mssql_fetch_row);
-PHP_FUNCTION(mssql_fetch_array);
-PHP_FUNCTION(mssql_fetch_assoc);
-PHP_FUNCTION(mssql_fetch_object);
-PHP_FUNCTION(mssql_field_length);
-PHP_FUNCTION(mssql_field_name);
-PHP_FUNCTION(mssql_field_type);
-PHP_FUNCTION(mssql_data_seek);
-PHP_FUNCTION(mssql_field_seek);
-PHP_FUNCTION(mssql_result);
-PHP_FUNCTION(mssql_next_result);
-PHP_FUNCTION(mssql_min_error_severity);
-PHP_FUNCTION(mssql_min_message_severity);
-PHP_FUNCTION(mssql_init);
-PHP_FUNCTION(mssql_bind);
-PHP_FUNCTION(mssql_execute);
-PHP_FUNCTION(mssql_free_statement);
-PHP_FUNCTION(mssql_guid_string);
-
-typedef struct mssql_link {
- LOGINREC *login;
- DBPROCESS *link;
- int valid;
-} mssql_link;
-
-typedef struct mssql_statement {
- int id;
- mssql_link *link;
- HashTable *binds;
- int executed;
-} mssql_statement;
-
-typedef struct {
-
- zval *zval;
- /* TODO: more data for special types (BLOBS, NUMERIC...) */
-} mssql_bind;
-
-ZEND_BEGIN_MODULE_GLOBALS(mssql)
- long default_link;
- long num_links,num_persistent;
- long max_links,max_persistent;
- zend_bool allow_persistent;
- char *appname;
- char *server_message;
-#ifdef HAVE_FREETDS
- char *charset;
-#endif
- long min_error_severity, min_message_severity;
- long cfg_min_error_severity, cfg_min_message_severity;
- long connect_timeout, timeout;
- zend_bool compatibility_mode;
- void (*get_column_content)(mssql_link *mssql_ptr,int offset,zval *result,int column_type );
- long textsize, textlimit, batchsize;
- zend_bool datetimeconvert;
- HashTable *resource_list, *resource_plist;
- zend_bool secure_connection;
- long max_procs;
-ZEND_END_MODULE_GLOBALS(mssql)
-
-#define MSSQL_ROWS_BLOCK 128
-
-typedef struct mssql_field {
- char *name,*column_source;
- long max_length;
- int numeric;
- int type;
-} mssql_field;
-
-typedef struct mssql_result {
- zval **data;
- mssql_field *fields;
- mssql_link *mssql_ptr;
- mssql_statement * statement;
- int batchsize;
- int lastresult;
- int blocks_initialized;
- int cur_row,cur_field;
- int num_rows,num_fields,have_fields;
-} mssql_result;
-
-
-#ifdef ZTS
-# define MS_SQL_G(v) TSRMG(mssql_globals_id, zend_mssql_globals *, v)
-#else
-# define MS_SQL_G(v) (mssql_globals.v)
-#endif
-
-#else
-
-#define mssql_module_ptr NULL
-
-#endif /* HAVE_MSSQL */
-
-#define phpext_mssql_ptr mssql_module_ptr
-
-#endif /* PHP_MSSQL_H */
diff --git a/ext/sybase_ct/CREDITS b/ext/sybase_ct/CREDITS
deleted file mode 100644
index f739a533c4..0000000000
--- a/ext/sybase_ct/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-Sybase-CT
-Zeev Suraski, Tom May, Timm Friebe
diff --git a/ext/sybase_ct/config.m4 b/ext/sybase_ct/config.m4
deleted file mode 100644
index 276fe12675..0000000000
--- a/ext/sybase_ct/config.m4
+++ /dev/null
@@ -1,120 +0,0 @@
-dnl
-dnl $Id$
-dnl
-
-PHP_ARG_WITH(sybase-ct, for Sybase-CT support,
-[ --with-sybase-ct[=DIR] Include Sybase-CT support. DIR is the Sybase home
- directory [/home/sybase]])
-
-if test "$PHP_SYBASE_CT" != "no"; then
-
- if test "$PHP_SYBASE" && test "$PHP_SYBASE" != "no" && test "$ext_shared" = "no"; then
- AC_MSG_ERROR([You can not use both --with-sybase and --with-sybase-ct in same build!])
- fi
-
- AC_DEFINE(HAVE_SYBASE_CT,1,[ ])
- PHP_NEW_EXTENSION(sybase_ct, php_sybase_ct.c, $ext_shared)
- PHP_SUBST(SYBASE_CT_SHARED_LIBADD)
-
- if test "$PHP_SYBASE_CT" = "yes"; then
- SYBASE_CT_INCDIR=/home/sybase/include
- SYBASE_CT_LIBDIR=/home/sybase/lib
- else
- SYBASE_CT_INCDIR=$PHP_SYBASE_CT/include
- SYBASE_CT_LIBDIR=$PHP_SYBASE_CT/lib
- fi
-
- dnl Determine whether we're building 64 or 32 bit...
- AC_CHECK_SIZEOF(long int, 4)
- AC_MSG_CHECKING([checking if we're on a 64-bit platform])
- if test "$ac_cv_sizeof_long_int" = "4"; then
- AC_MSG_RESULT([no])
- PHP_SYBASE_64=no
- else
- AC_MSG_RESULT([yes])
- PHP_SYBASE_64=yes
- fi
-
-
- AC_MSG_CHECKING([Checking for ctpublic.h])
- if test -f $SYBASE_CT_INCDIR/ctpublic.h; then
- AC_MSG_RESULT([found in $SYBASE_CT_INCDIR])
- PHP_ADD_INCLUDE($SYBASE_CT_INCDIR)
- else
- AC_MSG_ERROR([ctpublic.h missing!])
- fi
-
- AC_MSG_CHECKING([Checking Sybase libdir])
- AC_MSG_RESULT([Have $SYBASE_CT_LIBDIR])
-
- AC_MSG_CHECKING([Checking for Sybase platform libraries])
-
- PHP_ADD_LIBPATH($SYBASE_CT_LIBDIR, SYBASE_CT_SHARED_LIBADD)
- if test -f $SYBASE_CT_INCDIR/tds.h || test -f $SYBASE_CT_INCDIR/tds_sysdep_public.h; then
- PHP_ADD_LIBRARY(ct,, SYBASE_CT_SHARED_LIBADD)
- SYBASE_CT_LIBS="-L$SYBASE_CT_LIBDIR -lct"
- AC_MSG_RESULT([FreeTDS: $SYBASE_CT_LIBS])
- elif test -f $SYBASE_CT_LIBDIR/libsybct64.so && test $PHP_SYBASE_64 = "yes"; then
- PHP_ADD_LIBRARY(sybcs64,, SYBASE_CT_SHARED_LIBADD)
- PHP_ADD_LIBRARY(sybct64,, SYBASE_CT_SHARED_LIBADD)
- PHP_ADD_LIBRARY(sybcomn64,, SYBASE_CT_SHARED_LIBADD)
- PHP_ADD_LIBRARY(sybintl64,, SYBASE_CT_SHARED_LIBADD)
-
- ac_solid_uname_s=`uname -s 2>/dev/null`
- case $ac_solid_uname_s in
- *OSF*) ;; # Tru64/DEC OSF does NOT use the SYB_LP64 define
- *) CFLAGS="${CFLAGS} -DSYB_LP64" ;; #
- esac
- SYBASE_CT_LIBS="-L$SYBASE_CT_LIBDIR -lsybcs64 -lsybct64 -lsybcomn64 -lsybintl64"
- AC_MSG_RESULT([Sybase64: $SYBASE_CT_LIBS])
-
- PHP_CHECK_LIBRARY(sybtcl64, netg_errstr, [
- PHP_ADD_LIBRARY(sybtcl64,,SYBASE_CT_SHARED_LIBADD)
- ],[
- PHP_ADD_LIBRARY(sybtcl64,,SYBASE_CT_SHARED_LIBADD)
- ],[
- $SYBASE_CT_LIBS
- ])
-
- PHP_CHECK_LIBRARY(insck64, insck__getVdate, [PHP_ADD_LIBRARY(insck64,, SYBASE_CT_SHARED_LIBADD)],[],[-L$SYBASE_CT_LIBDIR])
- PHP_CHECK_LIBRARY(insck64, bsd_tcp, [PHP_ADD_LIBRARY(insck64,, SYBASE_CT_SHARED_LIBADD)],[],[-L$SYBASE_CT_LIBDIR])
- elif test -f $SYBASE_CT_LIBDIR/libsybct.so; then
- PHP_ADD_LIBRARY(sybcs,, SYBASE_CT_SHARED_LIBADD)
- PHP_ADD_LIBRARY(sybct,, SYBASE_CT_SHARED_LIBADD)
- PHP_ADD_LIBRARY(sybcomn,, SYBASE_CT_SHARED_LIBADD)
- PHP_ADD_LIBRARY(sybintl,, SYBASE_CT_SHARED_LIBADD)
-
- SYBASE_CT_LIBS="-L$SYBASE_CT_LIBDIR -lsybcs -lsybct -lsybcomn -lsybintl"
- AC_MSG_RESULT([Sybase32 syb-prefix: $SYBASE_CT_LIBS])
-
- PHP_CHECK_LIBRARY(sybtcl, netg_errstr, [
- PHP_ADD_LIBRARY(sybtcl,,SYBASE_CT_SHARED_LIBADD)
- ],[
- PHP_ADD_LIBRARY(sybtcl,,SYBASE_CT_SHARED_LIBADD)
- ],[
- $SYBASE_CT_LIBS
- ])
-
- PHP_CHECK_LIBRARY(insck, insck__getVdate, [PHP_ADD_LIBRARY(insck,, SYBASE_CT_SHARED_LIBADD)],[],[-L$SYBASE_CT_LIBDIR])
- PHP_CHECK_LIBRARY(insck, bsd_tcp, [PHP_ADD_LIBRARY(insck,, SYBASE_CT_SHARED_LIBADD)],[],[-L$SYBASE_CT_LIBDIR])
- else
- PHP_ADD_LIBRARY(cs,, SYBASE_CT_SHARED_LIBADD)
- PHP_ADD_LIBRARY(ct,, SYBASE_CT_SHARED_LIBADD)
- PHP_ADD_LIBRARY(comn,, SYBASE_CT_SHARED_LIBADD)
- PHP_ADD_LIBRARY(intl,, SYBASE_CT_SHARED_LIBADD)
-
- SYBASE_CT_LIBS="-L$SYBASE_CT_LIBDIR -lcs -lct -lcomn -lintl"
- AC_MSG_RESULT([Sybase32 default: $SYBASE_CT_LIBS])
-
- PHP_CHECK_LIBRARY(tcl, netg_errstr, [
- PHP_ADD_LIBRARY(tcl,,SYBASE_CT_SHARED_LIBADD)
- ],[
- PHP_ADD_LIBRARY(sybtcl,,SYBASE_CT_SHARED_LIBADD)
- ],[
- $SYBASE_CT_LIBS
- ])
-
- PHP_CHECK_LIBRARY(insck, insck__getVdate, [PHP_ADD_LIBRARY(insck,, SYBASE_CT_SHARED_LIBADD)],[],[-L$SYBASE_CT_LIBDIR])
- PHP_CHECK_LIBRARY(insck, bsd_tcp, [PHP_ADD_LIBRARY(insck,, SYBASE_CT_SHARED_LIBADD)],[],[-L$SYBASE_CT_LIBDIR])
- fi
-fi
diff --git a/ext/sybase_ct/config.w32 b/ext/sybase_ct/config.w32
deleted file mode 100644
index c773b623af..0000000000
--- a/ext/sybase_ct/config.w32
+++ /dev/null
@@ -1,21 +0,0 @@
-
-// $Id$
-// vim:ft=javascript
-
-ARG_WITH("sybase-ct", "SYBASE_CT support", "no");
-
-if (PHP_SYBASE_CT != "no") {
-
- if (CHECK_HEADER_ADD_INCLUDE("ctpublic.h", "CFLAGS_SYBASE_CT", PHP_PHP_BUILD + "\\sybase\\include;" + PHP_SYBASE_CT) &&
- (!X64 && CHECK_LIB("libsybcs.lib", "sybase_ct", PHP_PHP_BUILD + "\\sybase\\lib;" + PHP_SYBASE_CT) &&
- CHECK_LIB("libsybct.lib", "sybase_ct", PHP_PHP_BUILD + "\\sybase\\lib;" + PHP_SYBASE_CT) ||
- X64 && CHECK_LIB("libsybcs64.lib", "sybase_ct", PHP_PHP_BUILD + "\\sybase\\lib;" + PHP_SYBASE_CT) &&
- CHECK_LIB("libsybct64.lib", "sybase_ct", PHP_PHP_BUILD + "\\sybase\\lib;" + PHP_SYBASE_CT))
- ) {
- EXTENSION('sybase_ct', 'php_sybase_ct.c');
- AC_DEFINE('HAVE_SYBASE_CT', 1);
- } else {
- WARNING("sybase_ct not enabled; libraries and headers not found");
- }
-}
-
diff --git a/ext/sybase_ct/php_sybase_ct.c b/ext/sybase_ct/php_sybase_ct.c
deleted file mode 100644
index 5ed1fb4dd7..0000000000
--- a/ext/sybase_ct/php_sybase_ct.c
+++ /dev/null
@@ -1,2242 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- | Tom May <tom@go2net.com> |
- | Timm Friebe <php_sybase_ct@thekid.de> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "php.h"
-#include "php_sybase_ct.h"
-#include "ext/standard/php_standard.h"
-#include "ext/standard/info.h"
-#include "php_globals.h"
-#include "php_ini.h"
-
-/* True globals, no need for thread safety */
-static int le_link, le_plink, le_result;
-
-#if HAVE_SYBASE_CT
-
-ZEND_DECLARE_MODULE_GLOBALS(sybase)
-static PHP_GINIT_FUNCTION(sybase);
-static PHP_GSHUTDOWN_FUNCTION(sybase);
-
-/* {{{ arginfo */
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_connect, 0, 0, 0)
- ZEND_ARG_INFO(0, host)
- ZEND_ARG_INFO(0, user)
- ZEND_ARG_INFO(0, password)
- ZEND_ARG_INFO(0, charset)
- ZEND_ARG_INFO(0, appname)
- ZEND_ARG_INFO(0, new)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_pconnect, 0, 0, 0)
- ZEND_ARG_INFO(0, host)
- ZEND_ARG_INFO(0, user)
- ZEND_ARG_INFO(0, password)
- ZEND_ARG_INFO(0, charset)
- ZEND_ARG_INFO(0, appname)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_close, 0, 0, 0)
- ZEND_ARG_INFO(0, link_id)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_select_db, 0, 0, 1)
- ZEND_ARG_INFO(0, database)
- ZEND_ARG_INFO(0, link_id)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_query, 0, 0, 1)
- ZEND_ARG_INFO(0, query)
- ZEND_ARG_INFO(0, link_id)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_unbuffered_query, 0, 0, 1)
- ZEND_ARG_INFO(0, query)
- ZEND_ARG_INFO(0, link_id)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_free_result, 0, 0, 1)
- ZEND_ARG_INFO(0, result)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_get_last_message, 0, 0, 1)
- ZEND_ARG_INFO(0, d)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_num_rows, 0, 0, 1)
- ZEND_ARG_INFO(0, result)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_num_fields, 0, 0, 1)
- ZEND_ARG_INFO(0, result)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_fetch_row, 0, 0, 1)
- ZEND_ARG_INFO(0, result)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_fetch_object, 0, 0, 1)
- ZEND_ARG_INFO(0, result)
- ZEND_ARG_INFO(0, object)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_fetch_array, 0, 0, 1)
- ZEND_ARG_INFO(0, result)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_fetch_assoc, 0, 0, 1)
- ZEND_ARG_INFO(0, result)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_data_seek, 0, 0, 2)
- ZEND_ARG_INFO(0, result)
- ZEND_ARG_INFO(0, offset)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_fetch_field, 0, 0, 1)
- ZEND_ARG_INFO(0, result)
- ZEND_ARG_INFO(0, offset)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_field_seek, 0, 0, 2)
- ZEND_ARG_INFO(0, result)
- ZEND_ARG_INFO(0, offset)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_result, 0, 0, 3)
- ZEND_ARG_INFO(0, result)
- ZEND_ARG_INFO(0, row)
- ZEND_ARG_INFO(0, field)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_affected_rows, 0, 0, 0)
- ZEND_ARG_INFO(0, link_id)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_min_client_severity, 0, 0, 1)
- ZEND_ARG_INFO(0, severity)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_min_server_severity, 0, 0, 1)
- ZEND_ARG_INFO(0, severity)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_deadlock_retry_count, 0, 0, 1)
- ZEND_ARG_INFO(0, retry_count)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_set_message_handler, 0, 0, 1)
- ZEND_ARG_INFO(0, error_func)
- ZEND_ARG_INFO(0, connection)
-ZEND_END_ARG_INFO()
-/* }}} */
-
-const zend_function_entry sybase_functions[] = {
- PHP_FE(sybase_connect, arginfo_sybase_connect)
- PHP_FE(sybase_pconnect, arginfo_sybase_pconnect)
- PHP_FE(sybase_close, arginfo_sybase_close)
- PHP_FE(sybase_select_db, arginfo_sybase_select_db)
- PHP_FE(sybase_query, arginfo_sybase_query)
- PHP_FE(sybase_unbuffered_query, arginfo_sybase_unbuffered_query)
- PHP_FE(sybase_free_result, arginfo_sybase_free_result)
- PHP_FE(sybase_get_last_message, arginfo_sybase_get_last_message)
- PHP_FE(sybase_num_rows, arginfo_sybase_num_rows)
- PHP_FE(sybase_num_fields, arginfo_sybase_num_fields)
- PHP_FE(sybase_fetch_row, arginfo_sybase_fetch_row)
- PHP_FE(sybase_fetch_array, arginfo_sybase_fetch_array)
- PHP_FE(sybase_fetch_assoc, arginfo_sybase_fetch_assoc)
- PHP_FE(sybase_fetch_object, arginfo_sybase_fetch_object)
- PHP_FE(sybase_data_seek, arginfo_sybase_data_seek)
- PHP_FE(sybase_fetch_field, arginfo_sybase_fetch_field)
- PHP_FE(sybase_field_seek, arginfo_sybase_field_seek)
- PHP_FE(sybase_result, arginfo_sybase_result)
- PHP_FE(sybase_affected_rows, arginfo_sybase_affected_rows)
- PHP_FE(sybase_min_client_severity, arginfo_sybase_min_client_severity)
- PHP_FE(sybase_min_server_severity, arginfo_sybase_min_server_severity)
- PHP_FE(sybase_set_message_handler, arginfo_sybase_set_message_handler)
- PHP_FE(sybase_deadlock_retry_count, arginfo_sybase_deadlock_retry_count)
-
-#if !defined(PHP_WIN32) && !defined(HAVE_MSSQL)
- PHP_FALIAS(mssql_connect, sybase_connect, arginfo_sybase_connect)
- PHP_FALIAS(mssql_pconnect, sybase_pconnect, arginfo_sybase_pconnect)
- PHP_FALIAS(mssql_close, sybase_close, arginfo_sybase_close)
- PHP_FALIAS(mssql_select_db, sybase_select_db, arginfo_sybase_select_db)
- PHP_FALIAS(mssql_query, sybase_query, arginfo_sybase_query)
- PHP_FALIAS(mssql_unbuffered_query, sybase_unbuffered_query, arginfo_sybase_unbuffered_query)
- PHP_FALIAS(mssql_free_result, sybase_free_result, arginfo_sybase_free_result)
- PHP_FALIAS(mssql_get_last_message, sybase_get_last_message, arginfo_sybase_get_last_message)
- PHP_FALIAS(mssql_num_rows, sybase_num_rows, arginfo_sybase_num_rows)
- PHP_FALIAS(mssql_num_fields, sybase_num_fields, arginfo_sybase_num_fields)
- PHP_FALIAS(mssql_fetch_row, sybase_fetch_row, arginfo_sybase_fetch_row)
- PHP_FALIAS(mssql_fetch_array, sybase_fetch_array, arginfo_sybase_fetch_array)
- PHP_FALIAS(mssql_fetch_assoc, sybase_fetch_assoc, arginfo_sybase_fetch_assoc)
- PHP_FALIAS(mssql_fetch_object, sybase_fetch_object, arginfo_sybase_fetch_object)
- PHP_FALIAS(mssql_data_seek, sybase_data_seek, arginfo_sybase_data_seek)
- PHP_FALIAS(mssql_fetch_field, sybase_fetch_field, arginfo_sybase_fetch_field)
- PHP_FALIAS(mssql_field_seek, sybase_field_seek, arginfo_sybase_field_seek)
- PHP_FALIAS(mssql_result, sybase_result, arginfo_sybase_result)
- PHP_FALIAS(mssql_affected_rows, sybase_affected_rows, arginfo_sybase_affected_rows)
- PHP_FALIAS(mssql_min_client_severity, sybase_min_client_severity, arginfo_sybase_min_client_severity)
- PHP_FALIAS(mssql_min_server_severity, sybase_min_server_severity, arginfo_sybase_min_server_severity)
- PHP_FALIAS(mssql_set_message_handler, sybase_set_message_handler, arginfo_sybase_set_message_handler)
- PHP_FALIAS(mssql_deadlock_retry_count, sybase_deadlock_retry_count, arginfo_sybase_deadlock_retry_count)
-#endif
- PHP_FE_END
-};
-
-zend_module_entry sybase_module_entry = {
- STANDARD_MODULE_HEADER,
- "sybase_ct",
- sybase_functions,
- PHP_MINIT(sybase),
- PHP_MSHUTDOWN(sybase),
- PHP_RINIT(sybase),
- PHP_RSHUTDOWN(sybase),
- PHP_MINFO(sybase),
- NO_VERSION_YET,
- PHP_MODULE_GLOBALS(sybase),
- PHP_GINIT(sybase),
- PHP_GSHUTDOWN(sybase),
- NULL,
- STANDARD_MODULE_PROPERTIES_EX
-};
-
-/* static CS_CONTEXT *context; */
-
-#ifdef COMPILE_DL_SYBASE_CT
-ZEND_GET_MODULE(sybase)
-#endif
-
-ZEND_DECLARE_MODULE_GLOBALS(sybase)
-
-#define CHECK_LINK(link) { if (link==-1) { php_error_docref(NULL, E_WARNING, "Sybase: A link to the server could not be established"); RETURN_FALSE; } }
-
-
-static int _clean_invalid_results(zend_rsrc_list_entry *le)
-{
- if (Z_TYPE_P(le) == le_result) {
- sybase_link *sybase_ptr = ((sybase_result *) le->ptr)->sybase_ptr;
-
- if (!sybase_ptr->valid) {
- return 1;
- }
- }
- return 0;
-}
-
-#define efree_n(x) { efree(x); x = NULL; }
-#define efree_if(x) if (x) efree_n(x)
-
-#ifdef PHP_SYBASE_DEBUG
-#define FREE_SYBASE_RESULT(result) \
- if (result) { \
- fprintf(stderr, "_free_sybase_result(%p) called from line #%d\n", result, __LINE__); \
- fflush(stderr); \
- _free_sybase_result(result); \
- result = NULL; \
- }
-#else
-#define FREE_SYBASE_RESULT(result) \
- if (result) { \
- _free_sybase_result(result); \
- result = NULL; \
- }
-#endif
-static void _free_sybase_result(sybase_result *result)
-{
- int i, j;
-
- if (result->data) {
- for (i = 0; i < (result->store ? result->num_rows : MIN(1, result->num_rows)); i++) {
- for (j=0; j<result->num_fields; j++) {
- zval_dtor(&result->data[i][j]);
- }
- efree(result->data[i]);
- }
- efree(result->data);
- }
-
- if (result->fields) {
- for (i=0; i<result->num_fields; i++) {
- zend_string_free(result->fields[i].name);
- zend_string_free(result->fields[i].column_source);
- }
- efree(result->fields);
- }
-
- if (result->tmp_buffer) {
- for (i=0; i<result->num_fields; i++) {
- efree(result->tmp_buffer[i]);
- }
- efree(result->tmp_buffer);
- }
-
- efree_if(result->lengths);
- efree_if(result->indicators);
- efree_if(result->datafmt);
- efree_if(result->numerics);
- efree_if(result->types);
-
- efree(result);
-}
-
-/* Forward declaration */
-static int php_sybase_finish_results (sybase_result *result);
-
-static void php_free_sybase_result(zend_rsrc_list_entry *rsrc)
-{
- sybase_result *result = (sybase_result *)rsrc->ptr;
-
- /* Check to see if we've read all rows */
- if (result->sybase_ptr && result->sybase_ptr->active_result_index) {
- if (result->sybase_ptr->cmd) {
- ct_cancel(NULL, result->sybase_ptr->cmd, CS_CANCEL_ALL);
- }
- php_sybase_finish_results(result);
- }
-
- FREE_SYBASE_RESULT(result);
-}
-
-static void _close_sybase_link(zend_rsrc_list_entry *rsrc)
-{
- sybase_link *sybase_ptr = (sybase_link *)rsrc->ptr;
- CS_INT con_status;
-
- sybase_ptr->valid = 0;
- if (sybase_ptr->callback_name != NULL) {
- zval_ptr_dtor(&sybase_ptr->callback_name);
- sybase_ptr->callback_name= NULL;
- }
- zend_hash_apply(&EG(regular_list), (apply_func_t) _clean_invalid_results);
-
- /* Non-persistent connections will always be connected or we wouldn't
- * get here, but since we want to check the death status anyway
- * we might as well double-check the connect status.
- */
- if (ct_con_props(sybase_ptr->connection, CS_GET, CS_CON_STATUS,
- &con_status, CS_UNUSED, NULL)!=CS_SUCCEED) {
- php_error_docref(NULL, E_WARNING, "Sybase: Unable to get connection status on close");
- /* Assume the worst. */
- con_status = CS_CONSTAT_CONNECTED | CS_CONSTAT_DEAD;
- }
- if (con_status & CS_CONSTAT_CONNECTED) {
- if ((con_status & CS_CONSTAT_DEAD) || ct_close(sybase_ptr->connection, CS_UNUSED)!=CS_SUCCEED) {
- ct_close(sybase_ptr->connection, CS_FORCE_CLOSE);
- }
- }
-
- ct_cmd_drop(sybase_ptr->cmd);
- ct_con_drop(sybase_ptr->connection);
- efree(sybase_ptr);
- SybCtG(num_links)--;
-}
-
-
-static void _close_sybase_plink(zend_rsrc_list_entry *rsrc)
-{
- sybase_link *sybase_ptr = (sybase_link *)rsrc->ptr;
- CS_INT con_status;
-
- /* Persistent connections may have been closed before a failed
- * reopen attempt.
- */
- if (ct_con_props(sybase_ptr->connection, CS_GET, CS_CON_STATUS,
- &con_status, CS_UNUSED, NULL)!=CS_SUCCEED) {
- php_error_docref(NULL, E_WARNING, "Sybase: Unable to get connection status on close");
- /* Assume the worst. */
- con_status = CS_CONSTAT_CONNECTED | CS_CONSTAT_DEAD;
- }
- if (con_status & CS_CONSTAT_CONNECTED) {
- if ((con_status & CS_CONSTAT_DEAD) || ct_close(sybase_ptr->connection, CS_UNUSED)!=CS_SUCCEED) {
- ct_close(sybase_ptr->connection, CS_FORCE_CLOSE);
- }
- }
-
- ct_con_drop(sybase_ptr->connection);
- free(sybase_ptr);
- SybCtG(num_persistent)--;
- SybCtG(num_links)--;
-}
-
-
-static CS_RETCODE CS_PUBLIC _client_message_handler(CS_CONTEXT *context, CS_CONNECTION *connection, CS_CLIENTMSG *errmsg)
-{
-
- if (CS_SEVERITY(errmsg->msgnumber) >= SybCtG(min_client_severity)) {
- php_error_docref(NULL, E_WARNING, "Sybase: Client message: %s (severity %ld)", errmsg->msgstring, (long)CS_SEVERITY(errmsg->msgnumber));
- }
- zend_string_free(SybCtG(server_message));
- SybCtG(server_message) = estrdup(errmsg->msgstring);
-
-
- /* If this is a timeout message, return CS_FAIL to cancel the
- * operation and mark the connection as dead.
- */
- if (CS_SEVERITY(errmsg->msgnumber) == CS_SV_RETRY_FAIL &&
- CS_NUMBER(errmsg->msgnumber) == 63 &&
- CS_ORIGIN(errmsg->msgnumber) == 2 &&
- CS_LAYER(errmsg->msgnumber) == 1)
- {
- return CS_FAIL;
- }
-
- return CS_SUCCEED;
-}
-
-static int _call_message_handler(zval *callback_name, CS_SERVERMSG *srvmsg)
-{
- int handled = 0;
- zval *msgnumber, *severity, *state, *line, *text, *retval = NULL;
- zval **args[5];
-
- /* Border case - empty fcall */
- if (NULL == callback_name) return 0;
-
- /* Build arguments */
- MAKE_STD_ZVAL(msgnumber);
- ZVAL_LONG(msgnumber, srvmsg->msgnumber);
- args[0] = &msgnumber;
-
- MAKE_STD_ZVAL(severity);
- ZVAL_LONG(severity, srvmsg->severity);
- args[1] = &severity;
-
- MAKE_STD_ZVAL(state);
- ZVAL_LONG(state, srvmsg->state);
- args[2] = &state;
-
- MAKE_STD_ZVAL(line);
- ZVAL_LONG(line, srvmsg->line);
- args[3] = &line;
-
- MAKE_STD_ZVAL(text);
- ZVAL_STRING(text, srvmsg->text, 1);
- args[4] = &text;
-
- if (call_user_function_ex(EG(function_table), NULL, callback_name, &retval, 5, args, 0, NULL) == FAILURE) {
- zval expr_copy;
- int use_copy;
-
- use_copy = zend_make_printable_zval(callback_name, &expr_copy);
- php_error_docref(NULL, E_WARNING, "Sybase: Cannot call the messagehandler %s", Z_STRVAL(expr_copy));
- zval_dtor(&expr_copy);
- }
-
- if (retval) {
- handled = ((Z_TYPE_P(retval) != IS_BOOL) || (Z_BVAL_P(retval) != 0));
- zval_ptr_dtor(&retval);
- } else {
- handled = 0;
- }
-
- zval_ptr_dtor(&msgnumber);
- zval_ptr_dtor(&severity);
- zval_ptr_dtor(&state);
- zval_ptr_dtor(&line);
- zval_ptr_dtor(&text);
-
- return handled;
-}
-
-static CS_RETCODE CS_PUBLIC _server_message_handler(CS_CONTEXT *context, CS_CONNECTION *connection, CS_SERVERMSG *srvmsg)
-{
- sybase_link *sybase;
- int handled = 0;
-
- /* Remember the last server message in any case */
- zend_string_free(SybCtG(server_message));
- SybCtG(server_message) = estrdup(srvmsg->text);
-
- /* Retrieve sybase link */
- if (ct_con_props(connection, CS_GET, CS_USERDATA, &sybase, CS_SIZEOF(sybase), NULL) != CS_SUCCEED) {
- sybase = NULL;
- }
-
- /* If this is a deadlock message, set the connection's deadlock flag
- * so we will retry the request. Sorry about the bare constant here,
- * but it's not defined anywhere and it's a "well-known" number.
- */
- if (sybase && (srvmsg->msgnumber == 1205)) {
- sybase->deadlock = 1;
- }
-
- /* Check mininum server severity level */
- if (srvmsg->severity < SybCtG(min_server_severity)) {
- return CS_SUCCEED;
- }
-
- /* Call global message handler */
- handled = handled | _call_message_handler(SybCtG(callback_name), srvmsg);
-
- /* Call link specific message handler */
- if (sybase) {
- handled = handled | _call_message_handler(sybase->callback_name, srvmsg);
- }
-
- /* Spit out a warning if neither of them has handled this message */
- if (!handled) {
- php_error_docref(NULL, E_WARNING, "Sybase: Server message: %s (severity %ld, procedure %s)",
- srvmsg->text, (long)srvmsg->severity, ((srvmsg->proclen>0) ? srvmsg->proc : "N/A"));
- }
-
- return CS_SUCCEED;
-}
-
-
-PHP_INI_BEGIN()
- STD_PHP_INI_BOOLEAN("sybct.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateLong, allow_persistent, zend_sybase_globals, sybase_globals)
- STD_PHP_INI_ENTRY_EX("sybct.max_persistent", "-1", PHP_INI_SYSTEM, OnUpdateLong, max_persistent, zend_sybase_globals, sybase_globals, display_link_numbers)
- STD_PHP_INI_ENTRY_EX("sybct.max_links", "-1", PHP_INI_SYSTEM, OnUpdateLong, max_links, zend_sybase_globals, sybase_globals, display_link_numbers)
- STD_PHP_INI_ENTRY("sybct.min_server_severity", "10", PHP_INI_ALL, OnUpdateLong, min_server_severity, zend_sybase_globals, sybase_globals)
- STD_PHP_INI_ENTRY("sybct.min_client_severity", "10", PHP_INI_ALL, OnUpdateLong, min_client_severity, zend_sybase_globals, sybase_globals)
- STD_PHP_INI_ENTRY("sybct.login_timeout", "-1", PHP_INI_ALL, OnUpdateLong, login_timeout, zend_sybase_globals, sybase_globals)
- STD_PHP_INI_ENTRY("sybct.hostname", NULL, PHP_INI_ALL, OnUpdateString, hostname, zend_sybase_globals, sybase_globals)
- STD_PHP_INI_ENTRY_EX("sybct.deadlock_retry_count", "0", PHP_INI_ALL, OnUpdateLong, deadlock_retry_count, zend_sybase_globals, sybase_globals, display_link_numbers)
-PHP_INI_END()
-
-
-static PHP_GINIT_FUNCTION(sybase)
-{
- long opt;
-
- if (cs_ctx_alloc(CTLIB_VERSION, &sybase_globals->context)!=CS_SUCCEED || ct_init(sybase_globals->context, CTLIB_VERSION)!=CS_SUCCEED) {
- return;
- }
-
- /* Initialize message handlers */
- if (ct_callback(sybase_globals->context, NULL, CS_SET, CS_SERVERMSG_CB, (CS_VOID *)_server_message_handler)!=CS_SUCCEED) {
- php_error_docref(NULL, E_WARNING, "Sybase: Unable to set server message handler");
- }
-
- if (ct_callback(sybase_globals->context, NULL, CS_SET, CS_CLIENTMSG_CB, (CS_VOID *)_client_message_handler)!=CS_SUCCEED) {
- php_error_docref(NULL, E_WARNING, "Sybase: Unable to set client message handler");
- }
-
- /* Set datetime conversion format to "Nov 3 1998 8:06PM".
- * This is the default format for the ct-lib that comes with
- * Sybase ASE 11.5.1 for Solaris, but the Linux libraries that
- * come with 11.0.3.3 default to "03/11/98" which is singularly
- * useless. This levels the playing field for all platforms.
- */
- {
- CS_INT dt_convfmt = CS_DATES_SHORT;
- if (cs_dt_info(sybase_globals->context, CS_SET, NULL, CS_DT_CONVFMT, CS_UNUSED, &dt_convfmt, sizeof(dt_convfmt), NULL)!=CS_SUCCEED) {
- php_error_docref(NULL, E_WARNING, "Sybase: Unable to set datetime conversion format");
- }
- }
-
- /* Set the timeout, which is per context and can't be set with
- * ct_con_props(), so set it globally from the config value if
- * requested. The default is CS_NO_LIMIT.
- *
- * Note that despite some noise in the documentation about using
- * signals to implement timeouts, they are actually implemented
- * by using poll() or select() on Solaris and Linux.
- */
- if (cfg_get_long("sybct.timeout", &opt)==SUCCESS) {
- CS_INT cs_timeout = opt;
- if (ct_config(sybase_globals->context, CS_SET, CS_TIMEOUT, &cs_timeout, CS_UNUSED, NULL)!=CS_SUCCEED) {
- php_error_docref(NULL, E_WARNING, "Sybase: Unable to update the timeout");
- }
- }
-
- sybase_globals->num_persistent=0;
- sybase_globals->callback_name = NULL;
-}
-
-
-static PHP_GSHUTDOWN_FUNCTION(sybase)
-{
- ct_exit(sybase_globals->context, CS_UNUSED);
- cs_ctx_drop(sybase_globals->context);
-}
-
-PHP_MINIT_FUNCTION(sybase)
-{
- REGISTER_INI_ENTRIES();
-
- le_link = zend_register_list_destructors_ex(_close_sybase_link, NULL, "sybase-ct link", module_number);
- le_plink = zend_register_list_destructors_ex(NULL, _close_sybase_plink, "sybase-ct link persistent", module_number);
- le_result = zend_register_list_destructors_ex(php_free_sybase_result, NULL, "sybase-ct result", module_number);
-
- return SUCCESS;
-}
-
-
-
-PHP_RINIT_FUNCTION(sybase)
-{
- SybCtG(default_link)=-1;
- SybCtG(num_links) = SybCtG(num_persistent);
- SybCtG(appname) = estrndup("PHP " PHP_VERSION, sizeof("PHP " PHP_VERSION));
- SybCtG(server_message) = STR_EMPTY_ALLOC();
- return SUCCESS;
-}
-
-
-
-PHP_MSHUTDOWN_FUNCTION(sybase)
-{
- UNREGISTER_INI_ENTRIES();
-#if 0
- ct_exit(context, CS_UNUSED);
- cs_ctx_drop(context);
-#endif
- return SUCCESS;
-}
-
-
-PHP_RSHUTDOWN_FUNCTION(sybase)
-{
- efree(SybCtG(appname));
- SybCtG(appname) = NULL;
- if (SybCtG(callback_name)) {
- zval_ptr_dtor(&SybCtG(callback_name));
- SybCtG(callback_name)= NULL;
- }
- zend_string_free(SybCtG(server_message));
- SybCtG(server_message) = NULL;
- return SUCCESS;
-}
-
-
-static int php_sybase_do_connect_internal(sybase_link *sybase, char *host, char *user, char *passwd, char *charset, char *appname)
-{
- CS_LOCALE *tmp_locale;
- long packetsize;
-
- /* set a CS_CONNECTION record */
- if (ct_con_alloc(SybCtG(context), &sybase->connection)!=CS_SUCCEED) {
- php_error_docref(NULL, E_WARNING, "Sybase: Unable to allocate connection record");
- return 0;
- }
-
- /* Note - this saves a copy of sybase, not a pointer to it. */
- if (ct_con_props(sybase->connection, CS_SET, CS_USERDATA, &sybase, CS_SIZEOF(sybase), NULL)!=CS_SUCCEED) {
- php_error_docref(NULL, E_WARNING, "Sybase: Unable to set userdata");
- ct_con_drop(sybase->connection);
- return 0;
- }
-
- if (user) {
- ct_con_props(sybase->connection, CS_SET, CS_USERNAME, user, CS_NULLTERM, NULL);
- }
- if (passwd) {
- ct_con_props(sybase->connection, CS_SET, CS_PASSWORD, passwd, CS_NULLTERM, NULL);
- }
- if (appname) {
- ct_con_props(sybase->connection, CS_SET, CS_APPNAME, appname, CS_NULLTERM, NULL);
- } else {
- ct_con_props(sybase->connection, CS_SET, CS_APPNAME, SybCtG(appname), CS_NULLTERM, NULL);
- }
-
- if (SybCtG(hostname)) {
- ct_con_props(sybase->connection, CS_SET, CS_HOSTNAME, SybCtG(hostname), CS_NULLTERM, NULL);
- }
-
- if (charset) {
- if (cs_loc_alloc(SybCtG(context), &tmp_locale)!=CS_SUCCEED) {
- php_error_docref(NULL, E_WARNING, "Sybase: Unable to allocate locale information");
- } else {
- if (cs_locale(SybCtG(context), CS_SET, tmp_locale, CS_LC_ALL, NULL, CS_NULLTERM, NULL)!=CS_SUCCEED) {
- php_error_docref(NULL, E_WARNING, "Sybase: Unable to load default locale data");
- } else {
- if (cs_locale(SybCtG(context), CS_SET, tmp_locale, CS_SYB_CHARSET, charset, CS_NULLTERM, NULL)!=CS_SUCCEED) {
- php_error_docref(NULL, E_WARNING, "Sybase: Unable to update character set");
- } else {
- if (ct_con_props(sybase->connection, CS_SET, CS_LOC_PROP, tmp_locale, CS_UNUSED, NULL)!=CS_SUCCEED) {
- php_error_docref(NULL, E_WARNING, "Sybase: Unable to update connection properties");
- }
- }
- }
- }
- }
-
- if (cfg_get_long("sybct.packet_size", &packetsize) == SUCCESS) {
- if (ct_con_props(sybase->connection, CS_SET, CS_PACKETSIZE, (CS_VOID *)&packetsize, CS_UNUSED, NULL) != CS_SUCCEED) {
- php_error_docref(NULL, E_WARNING, "Sybase: Unable to update connection packetsize");
- }
- }
-
- /* Set the login timeout. Actually, the login timeout is per context
- * and not per connection, but we will update the context here to
- * allow for code such as the following:
- *
- * ini_set('sybct.login_timeout', $timeout);
- * sybase_connect(...)
- *
- * Note that preceding calls to sybase_connect() will now use the
- * updated value and not the default one!
- *
- * The default value for CS_LOGIN_TIMEOUT is 60 (1 minute).
- */
- if (SybCtG(login_timeout) != -1) {
- CS_INT cs_login_timeout = SybCtG(login_timeout);
- if (ct_config(SybCtG(context), CS_SET, CS_LOGIN_TIMEOUT, &cs_login_timeout, CS_UNUSED, NULL)!=CS_SUCCEED) {
- php_error_docref(NULL, E_WARNING, "Sybase: Unable to update the login timeout");
- }
- }
-
- sybase->valid = 1;
- sybase->dead = 0;
- sybase->active_result_index = 0;
- sybase->callback_name = NULL;
-
- /* create the link */
- if (ct_connect(sybase->connection, host, CS_NULLTERM)!=CS_SUCCEED) {
- php_error_docref(NULL, E_WARNING, "Sybase: Unable to connect");
- ct_con_drop(sybase->connection);
- return 0;
- }
-
- if (ct_cmd_alloc(sybase->connection, &sybase->cmd)!=CS_SUCCEED) {
- php_error_docref(NULL, E_WARNING, "Sybase: Unable to allocate command record");
- ct_close(sybase->connection, CS_UNUSED);
- ct_con_drop(sybase->connection);
- return 0;
- }
-
- return 1;
-}
-
-
-static void php_sybase_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
-{
- char *user = NULL, *passwd = NULL, *host = NULL, *charset = NULL, *appname = NULL;
- char *hashed_details;
- int hashed_details_length, len;
- zend_bool new = 0;
- sybase_link *sybase_ptr;
-
- host= user= passwd= charset= appname= NULL;
- if (persistent) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!s!s!s!", &host, &len, &user, &len, &passwd, &len, &charset, &len, &appname, &len) == FAILURE) {
- return;
- }
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!s!s!s!b", &host, &len, &user, &len, &passwd, &len, &charset, &len, &appname, &len, &new) == FAILURE) {
- return;
- }
- }
- hashed_details_length = spprintf(
- &hashed_details,
- 0,
- "sybase_%s_%s_%s_%s_%s",
- host ? host : "",
- user ? user : "",
- passwd ? passwd : "",
- charset ? charset : "",
- appname ? appname : ""
- );
-
- if (!SybCtG(allow_persistent)) {
- persistent=0;
- }
- if (persistent) {
- zend_rsrc_list_entry *le;
-
- /* try to find if we already have this link in our persistent list */
- if (zend_hash_find(&EG(persistent_list), hashed_details, hashed_details_length+1, (void **) &le)==FAILURE) { /* we don't */
- zend_rsrc_list_entry new_le;
-
- if (SybCtG(max_links)!=-1 && SybCtG(num_links)>=SybCtG(max_links)) {
- php_error_docref(NULL, E_WARNING, "Sybase: Too many open links (%ld)", SybCtG(num_links));
- efree(hashed_details);
- RETURN_FALSE;
- }
- if (SybCtG(max_persistent)!=-1 && SybCtG(num_persistent)>=SybCtG(max_persistent)) {
- php_error_docref(NULL, E_WARNING, "Sybase: Too many open persistent links (%ld)", SybCtG(num_persistent));
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- sybase_ptr = (sybase_link *) malloc(sizeof(sybase_link));
- if (!sybase_ptr) {
- efree(hashed_details);
- RETURN_FALSE;
- }
- if (!php_sybase_do_connect_internal(sybase_ptr, host, user, passwd, charset, appname)) {
- free(sybase_ptr);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- /* hash it up */
- Z_TYPE(new_le) = le_plink;
- new_le.ptr = sybase_ptr;
- if (zend_hash_update(&EG(persistent_list), hashed_details, hashed_details_length+1, (void *) &new_le, sizeof(zend_rsrc_list_entry), NULL)==FAILURE) {
- ct_close(sybase_ptr->connection, CS_UNUSED);
- ct_con_drop(sybase_ptr->connection);
- free(sybase_ptr);
- efree(hashed_details);
- RETURN_FALSE;
- }
- SybCtG(num_persistent)++;
- SybCtG(num_links)++;
- } else { /* we do */
- CS_INT con_status;
-
- if (Z_TYPE_P(le) != le_plink) {
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- sybase_ptr = (sybase_link *) le->ptr;
-
- /* If the link has died, close it and overwrite it with a new one. */
-
- if (ct_con_props(sybase_ptr->connection, CS_GET, CS_CON_STATUS,
- &con_status, CS_UNUSED, NULL)!=CS_SUCCEED) {
- php_error_docref(NULL, E_WARNING, "Sybase: Unable to get connection status");
- efree(hashed_details);
- RETURN_FALSE;
- }
- if (!(con_status & CS_CONSTAT_CONNECTED) || (con_status & CS_CONSTAT_DEAD) || sybase_ptr->dead) {
- sybase_link sybase;
-
- if (con_status & CS_CONSTAT_CONNECTED) {
- ct_close(sybase_ptr->connection, CS_FORCE_CLOSE);
- }
- /* Create a new connection, then replace the old
- * connection. If we fail to create a new connection,
- * put the old one back so there will be a connection,
- * even if it is a non-functional one. This is because
- * code may still be holding an id for this connection
- * so we can't free the CS_CONNECTION.
- * (This is actually totally hokey, it would be better
- * to just ct_con_drop() the connection and set
- * sybase_ptr->connection to NULL, then test it for
- * NULL before trying to use it elsewhere . . .)
- */
- memcpy(&sybase, sybase_ptr, sizeof(sybase_link));
- if (!php_sybase_do_connect_internal(sybase_ptr, host, user, passwd, charset, appname)) {
- memcpy(sybase_ptr, &sybase, sizeof(sybase_link));
- efree(hashed_details);
- RETURN_FALSE;
- }
- ct_con_drop(sybase.connection); /* drop old connection */
- }
- }
- ZEND_REGISTER_RESOURCE(return_value, sybase_ptr, le_plink);
- } else { /* non persistent */
- zend_rsrc_list_entry *index_ptr, new_index_ptr;
-
- /* first we check the hash for the hashed_details key. if it exists,
- * it should point us to the right offset where the actual sybase link sits.
- * if it doesn't, open a new sybase link, add it to the resource list,
- * and add a pointer to it with hashed_details as the key.
- */
- if (!new && zend_hash_find(&EG(regular_list), hashed_details, hashed_details_length+1, (void **) &index_ptr)==SUCCESS) {
- int type, link;
- void *ptr;
-
- if (Z_TYPE_P(index_ptr) != le_index_ptr) {
- efree(hashed_details);
- RETURN_FALSE;
- }
- link = (int) index_ptr->ptr;
- ptr = zend_list_find(link, &type); /* check if the link is still there */
- if (ptr && (type==le_link || type==le_plink)) {
- zend_list_addref(link);
- Z_LVAL_P(return_value) = SybCtG(default_link) = link;
- Z_TYPE_P(return_value) = IS_RESOURCE;
- efree(hashed_details);
- return;
- } else {
- zend_hash_del(&EG(regular_list), hashed_details, hashed_details_length+1);
- }
- }
- if (SybCtG(max_links)!=-1 && SybCtG(num_links)>=SybCtG(max_links)) {
- php_error_docref(NULL, E_WARNING, "Sybase: Too many open links (%ld)", SybCtG(num_links));
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- sybase_ptr = (sybase_link *) emalloc(sizeof(sybase_link));
- if (!php_sybase_do_connect_internal(sybase_ptr, host, user, passwd, charset, appname)) {
- efree(sybase_ptr);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- /* add it to the list */
- ZEND_REGISTER_RESOURCE(return_value, sybase_ptr, le_link);
-
- /* add it to the hash */
- new_index_ptr.ptr = (void *) Z_LVAL_P(return_value);
- Z_TYPE(new_index_ptr) = le_index_ptr;
- if (zend_hash_update(&EG(regular_list), hashed_details, hashed_details_length+1, (void *) &new_index_ptr, sizeof(zend_rsrc_list_entry), NULL)==FAILURE) {
- ct_close(sybase_ptr->connection, CS_UNUSED);
- ct_con_drop(sybase_ptr->connection);
- efree(sybase_ptr);
- efree(hashed_details);
- RETURN_FALSE;
- }
- SybCtG(num_links)++;
- }
- efree(hashed_details);
- SybCtG(default_link)=Z_LVAL_P(return_value);
- zend_list_addref(SybCtG(default_link));
-}
-
-
-static int php_sybase_get_default_link(INTERNAL_FUNCTION_PARAMETERS)
-{
- if (SybCtG(default_link)==-1) { /* no link opened yet, implicitly open one */
- ht = 0;
- php_sybase_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
- }
- return SybCtG(default_link);
-}
-
-
-/* {{{ proto int sybase_connect([string host [, string user [, string password [, string charset [, string appname [, bool new]]]]]])
- Open Sybase server connection */
-PHP_FUNCTION(sybase_connect)
-{
- php_sybase_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-
-/* }}} */
-
-/* {{{ proto int sybase_pconnect([string host [, string user [, string password [, string charset [, string appname]]]]])
- Open persistent Sybase connection */
-PHP_FUNCTION(sybase_pconnect)
-{
- php_sybase_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-
-/* }}} */
-
-inline static int php_sybase_connection_id(zval *sybase_link_index, int *id)
-{
- if (NULL == sybase_link_index) {
- if (-1 == SybCtG(default_link)) {
- return FAILURE;
- }
- *id = SybCtG(default_link);
- } else {
- *id = -1; /* explicit resource number */
- }
- return SUCCESS;
-}
-
-/* {{{ proto bool sybase_close([resource link_id])
- Close Sybase connection */
-PHP_FUNCTION(sybase_close)
-{
- zval *sybase_link_index = NULL;
- sybase_link *sybase_ptr;
- int id;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|r", &sybase_link_index) == FAILURE) {
- return;
- }
-
- if (php_sybase_connection_id(sybase_link_index, &id) == FAILURE) {
- php_error_docref(NULL, E_WARNING, "Sybase: No connection to close");
- RETURN_FALSE;
- }
-
- ZEND_FETCH_RESOURCE2(sybase_ptr, sybase_link *, &sybase_link_index, id, "Sybase-Link", le_link, le_plink);
-
- if (id == -1) {
- zend_list_delete(Z_RESVAL_P(sybase_link_index));
- }
- if (id != -1 || (sybase_link_index && Z_RESVAL_P(sybase_link_index) == SybCtG(default_link))) {
- zend_list_delete(SybCtG(default_link));
- SybCtG(default_link) = -1;
- }
-
- RETURN_TRUE;
-}
-
-/* }}} */
-
-
-static int exec_cmd(sybase_link *sybase_ptr, char *cmdbuf)
-{
- CS_RETCODE retcode;
- CS_INT restype;
- int failure=0;
-
- /* Fail if we already marked this connection dead. */
-
- if (sybase_ptr->dead) {
- return FAILURE;
- }
-
- /*
- ** Get a command handle, store the command string in it, and
- ** send it to the server.
- */
-
- if (ct_command(sybase_ptr->cmd, CS_LANG_CMD, cmdbuf, CS_NULLTERM, CS_UNUSED)!=CS_SUCCEED) {
- sybase_ptr->dead = 1;
- return FAILURE;
- }
- if (ct_send(sybase_ptr->cmd)!=CS_SUCCEED) {
- sybase_ptr->dead = 1;
- return FAILURE;
- }
-
- while ((retcode = ct_results(sybase_ptr->cmd, &restype))==CS_SUCCEED) {
- switch ((int) restype) {
- case CS_CMD_SUCCEED:
- case CS_CMD_DONE:
- break;
-
- case CS_CMD_FAIL:
- failure=1;
- break;
-
- case CS_STATUS_RESULT:
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_CURRENT);
- break;
-
- default:
- failure=1;
- break;
- }
- if (failure) {
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
- return FAILURE;
- }
- }
-
- switch (retcode) {
- case CS_END_RESULTS:
- return SUCCESS;
- break;
-
- case CS_FAIL:
- /* Hopefully this either cleans up the connection, or the
- * connection ends up marked dead so it will be reopened
- * if it is persistent. We may want to do
- * ct_close(CS_FORCE_CLOSE) if ct_cancel() fails; see the
- * doc for ct_results()==CS_FAIL.
- */
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
- /* Don't take chances with the vagaries of ct-lib. Mark it
- * dead ourselves.
- */
- sybase_ptr->dead = 1;
- return FAILURE;
-
- default:
- return FAILURE;
- }
-}
-
-
-/* {{{ proto bool sybase_select_db(string database [, resource link_id])
- Select Sybase database */
-PHP_FUNCTION(sybase_select_db)
-{
- zval *sybase_link_index = NULL;
- char *db, *cmdbuf;
- int id, len;
- sybase_link *sybase_ptr;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|r", &db, &len, &sybase_link_index) == FAILURE) {
- return;
- }
-
- if (php_sybase_connection_id(sybase_link_index, &id) == FAILURE) {
- php_error_docref(NULL, E_WARNING, "Sybase: No connection");
- RETURN_FALSE;
- }
-
- ZEND_FETCH_RESOURCE2(sybase_ptr, sybase_link *, &sybase_link_index, id, "Sybase-Link", le_link, le_plink);
-
- spprintf(&cmdbuf, 4 + len + 1, "use %s", db);
- if (exec_cmd(sybase_ptr, cmdbuf) == FAILURE) {
- efree(cmdbuf);
- RETURN_FALSE;
- } else {
- efree(cmdbuf);
- RETURN_TRUE;
- }
-}
-
-/* }}} */
-
-static int php_sybase_finish_results(sybase_result *result)
-{
- int i, fail;
- CS_RETCODE retcode;
- CS_INT restype;
-
- efree_n(result->datafmt);
- efree_n(result->lengths);
- efree_n(result->indicators);
- efree_n(result->numerics);
- efree_n(result->types);
- for (i=0; i<result->num_fields; i++) {
- efree(result->tmp_buffer[i]);
- }
- efree_n(result->tmp_buffer);
-
- /* Indicate we have read all rows */
- result->sybase_ptr->active_result_index= 0;
-
- /* The only restype we should get now is CS_CMD_DONE, possibly
- * followed by a CS_STATUS_RESULT/CS_CMD_SUCCEED/CS_CMD_DONE
- * sequence if the command was a stored procedure call. But we
- * still need to read and discard unexpected results. We might
- * want to return a failure in this case because the application
- * won't be getting all the results it asked for.
- */
- fail = 0;
- while ((retcode = ct_results(result->sybase_ptr->cmd, &restype))==CS_SUCCEED) {
- switch ((int) restype) {
- case CS_CMD_SUCCEED:
- case CS_CMD_DONE:
- break;
-
- case CS_CMD_FAIL:
- php_error_docref(NULL, E_WARNING, "Sybase: Command failed, canceling rest");
- ct_cancel(NULL, result->sybase_ptr->cmd, CS_CANCEL_ALL);
- fail = 1;
- break;
-
- case CS_COMPUTE_RESULT:
- case CS_CURSOR_RESULT:
- case CS_PARAM_RESULT:
- case CS_ROW_RESULT:
- /* Unexpected results, cancel them. */
- php_error_docref(NULL, E_NOTICE, "Sybase: Unexpected results, canceling current");
- ct_cancel(NULL, result->sybase_ptr->cmd, CS_CANCEL_CURRENT);
- break;
-
- case CS_STATUS_RESULT:
- /* Status result from a stored procedure, cancel it but do not tell user */
- ct_cancel(NULL, result->sybase_ptr->cmd, CS_CANCEL_CURRENT);
- break;
-
- default:
- php_error_docref(NULL, E_NOTICE, "Sybase: Unexpected results, canceling all");
- ct_cancel(NULL, result->sybase_ptr->cmd, CS_CANCEL_ALL);
- break;
- }
-
- if (fail) {
- break;
- }
- }
-
- switch (retcode) {
- case CS_END_RESULTS:
- /* Normal. */
- break;
-
- case CS_FAIL:
- /* Hopefully this either cleans up the connection, or the
- * connection ends up marked dead so it will be reopened
- * if it is persistent. We may want to do
- * ct_close(CS_FORCE_CLOSE) if ct_cancel() fails; see the
- * doc for ct_results()==CS_FAIL.
- */
- ct_cancel(NULL, result->sybase_ptr->cmd, CS_CANCEL_ALL);
- /* Don't take chances with the vagaries of ct-lib. Mark it
- * dead ourselves.
- */
- result->sybase_ptr->dead = 1;
-
- case CS_CANCELED:
- default:
- retcode = CS_FAIL;
- break;
- }
-
- return retcode;
-}
-
-#define RETURN_DOUBLE_VAL(result, buf, length) \
- if ((length - 1) <= EG(precision)) { \
- errno = 0; \
- Z_DVAL(result) = zend_strtod(buf, NULL); \
- if (errno != ERANGE) { \
- Z_TYPE(result) = IS_DOUBLE; \
- } else { \
- ZVAL_STRINGL(&result, buf, length- 1, 1); \
- } \
- } else { \
- ZVAL_STRINGL(&result, buf, length- 1, 1); \
- }
-
-static int php_sybase_fetch_result_row(sybase_result *result, int numrows)
-{
- int i, j;
- CS_INT retcode;
-
- /* We've already fetched everything */
- if (result->last_retcode == CS_END_DATA || result->last_retcode == CS_END_RESULTS) {
- return result->last_retcode;
- }
-
- if (numrows!=-1) numrows+= result->num_rows;
- while ((retcode=ct_fetch(result->sybase_ptr->cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, NULL))==CS_SUCCEED || retcode == CS_ROW_FAIL) {
- result->num_rows++;
- i= result->store ? result->num_rows- 1 : 0;
- if (i >= result->blocks_initialized*SYBASE_ROWS_BLOCK) {
- result->data = (zval **) safe_erealloc(result->data, SYBASE_ROWS_BLOCK*(++result->blocks_initialized), sizeof(zval *), 0);
- }
- if (result->store || 1 == result->num_rows) {
- result->data[i] = (zval *) safe_emalloc(sizeof(zval), result->num_fields, 0);
- }
-
- for (j = 0; j < result->num_fields; j++) {
-
- /* If we are in non-storing mode, free the previous result */
- if (!result->store && result->num_rows > 1 && Z_TYPE(result->data[i][j]) == IS_STRING) {
- efree(Z_STRVAL(result->data[i][j]));
- }
-
- if (result->indicators[j] == -1) { /* null value */
- ZVAL_NULL(&result->data[i][j]);
- } else {
- switch (result->numerics[j]) {
- case 1: {
- /* This indicates a long */
- ZVAL_LONG(&result->data[i][j], strtol(result->tmp_buffer[j], NULL, 10));
- break;
- }
-
- case 2: {
- /* This indicates a float */
- RETURN_DOUBLE_VAL(result->data[i][j], result->tmp_buffer[j], result->lengths[j]);
- break;
- }
-
- case 3: {
- /* This indicates either a long or a float, which ever fits */
- errno = 0;
- Z_LVAL(result->data[i][j]) = strtol(result->tmp_buffer[j], NULL, 10);
- if (errno == ERANGE) {
-
- /* An overflow occurred, so try to fit it into a double */
- RETURN_DOUBLE_VAL(result->data[i][j], result->tmp_buffer[j], result->lengths[j]);
- break;
- }
- Z_TYPE(result->data[i][j]) = IS_LONG;
- break;
- }
-
- default: {
- /* This indicates anything else, return it as string
- * FreeTDS doesn't correctly set result->indicators[j] correctly
- * for NULL fields in some version in conjunction with ASE 12.5
- * but instead sets result->lengths[j] to 0, which would lead to
- * a negative memory allocation (and thus a segfault).
- */
- if (result->lengths[j] < 1) {
- ZVAL_NULL(&result->data[i][j]);
- } else {
- ZVAL_STRINGL(&result->data[i][j], result->tmp_buffer[j], result->lengths[j]- 1, 1);
- }
- break;
- }
- }
- }
- }
- if (numrows!=-1 && result->num_rows>=numrows) break;
- }
-
- if (retcode==CS_ROW_FAIL) {
- php_error_docref(NULL, E_WARNING, "Sybase: Error reading row %d", result->num_rows);
- return retcode;
- }
- result->last_retcode= retcode;
- switch (retcode) {
- case CS_END_DATA:
- retcode = php_sybase_finish_results(result);
- break;
-
- case CS_ROW_FAIL:
- case CS_SUCCEED:
- break;
-
- default:
- FREE_SYBASE_RESULT(result);
- result = NULL;
- retcode = CS_FAIL; /* Just to be sure */
- break;
- }
-
- return retcode;
-}
-
-static sybase_result * php_sybase_fetch_result_set(sybase_link *sybase_ptr, int buffered, int store)
-{
- int num_fields;
- sybase_result *result;
- int i, j;
- CS_INT retcode;
-
- /* The following (if unbuffered) is more or less the equivalent of mysql_store_result().
- * fetch all rows from the server into the row buffer, thus:
- * 1) Being able to fire up another query without explicitly reading all rows
- * 2) Having numrows accessible
- */
- if (ct_res_info(sybase_ptr->cmd, CS_NUMDATA, &num_fields, CS_UNUSED, NULL)!=CS_SUCCEED) {
- return NULL;
- }
-
- result = (sybase_result *) emalloc(sizeof(sybase_result));
- result->data = (zval **) safe_emalloc(sizeof(zval *), SYBASE_ROWS_BLOCK, 0);
- result->fields = NULL;
- result->sybase_ptr = sybase_ptr;
- result->cur_field=result->cur_row=result->num_rows=0;
- result->num_fields = num_fields;
- result->last_retcode = 0;
- result->store= store;
- result->blocks_initialized= 1;
- result->tmp_buffer = (char **) safe_emalloc(sizeof(char *), num_fields, 0);
- result->lengths = (CS_INT *) safe_emalloc(sizeof(CS_INT), num_fields, 0);
- result->indicators = (CS_SMALLINT *) safe_emalloc(sizeof(CS_INT), num_fields, 0);
- result->datafmt = (CS_DATAFMT *) safe_emalloc(sizeof(CS_DATAFMT), num_fields, 0);
- result->numerics = (unsigned char *) safe_emalloc(sizeof(unsigned char), num_fields, 0);
- result->types = (CS_INT *) safe_emalloc(sizeof(CS_INT), num_fields, 0);
-
- for (i=0; i<num_fields; i++) {
- ct_describe(sybase_ptr->cmd, i+1, &result->datafmt[i]);
- result->types[i] = result->datafmt[i].datatype;
- switch (result->datafmt[i].datatype) {
- case CS_CHAR_TYPE:
- case CS_VARCHAR_TYPE:
- case CS_TEXT_TYPE:
- case CS_IMAGE_TYPE:
- result->datafmt[i].maxlength++;
- result->numerics[i] = 0;
- break;
- case CS_BINARY_TYPE:
- case CS_VARBINARY_TYPE:
- result->datafmt[i].maxlength *= 2;
- result->datafmt[i].maxlength++;
- result->numerics[i] = 0;
- break;
- case CS_BIT_TYPE:
- case CS_TINYINT_TYPE:
- result->datafmt[i].maxlength = 4;
- result->numerics[i] = 1;
- break;
- case CS_SMALLINT_TYPE:
- result->datafmt[i].maxlength = 7;
- result->numerics[i] = 1;
- break;
- case CS_INT_TYPE:
- result->datafmt[i].maxlength = 12;
- result->numerics[i] = 1;
- break;
- case CS_REAL_TYPE:
- case CS_FLOAT_TYPE:
- result->datafmt[i].maxlength = 24;
- result->numerics[i] = 2;
- break;
- case CS_MONEY_TYPE:
- case CS_MONEY4_TYPE:
- result->datafmt[i].maxlength = 24;
- result->numerics[i] = 2;
- break;
- case CS_DATETIME_TYPE:
- case CS_DATETIME4_TYPE:
- result->datafmt[i].maxlength = 30;
- result->numerics[i] = 0;
- break;
- case CS_NUMERIC_TYPE:
- case CS_DECIMAL_TYPE:
- result->datafmt[i].maxlength = result->datafmt[i].precision + 3;
- /* numeric(10) vs numeric(10, 1) */
- result->numerics[i] = (result->datafmt[i].scale == 0) ? 3 : 2;
- break;
- default:
- result->datafmt[i].maxlength++;
- result->numerics[i] = 0;
- break;
- }
- result->tmp_buffer[i] = (char *)emalloc(result->datafmt[i].maxlength);
- result->datafmt[i].datatype = CS_CHAR_TYPE;
- result->datafmt[i].format = CS_FMT_NULLTERM;
- ct_bind(sybase_ptr->cmd, i+1, &result->datafmt[i], result->tmp_buffer[i], &result->lengths[i], &result->indicators[i]);
- }
-
- result->fields = (sybase_field *) safe_emalloc(sizeof(sybase_field), num_fields, 0);
- j=0;
- for (i=0; i<num_fields; i++) {
- char computed_buf[16];
-
- if (result->datafmt[i].namelen>0) {
- result->fields[i].name = estrndup(result->datafmt[i].name, result->datafmt[i].namelen);
- } else {
- if (j>0) {
- snprintf(computed_buf, 16, "computed%d", j);
- } else {
- strcpy(computed_buf, "computed");
- }
- result->fields[i].name = estrdup(computed_buf);
- j++;
- }
- result->fields[i].column_source = STR_EMPTY_ALLOC();
- result->fields[i].max_length = result->datafmt[i].maxlength-1;
- result->fields[i].numeric = result->numerics[i];
- Z_TYPE(result->fields[i]) = result->types[i];
- }
-
- if (buffered) {
- retcode = CS_SUCCEED;
- } else {
- if ((retcode = php_sybase_fetch_result_row(result, -1)) == CS_FAIL) {
- return NULL;
- }
- }
-
- result->last_retcode = retcode;
- return result;
-}
-
-static void php_sybase_query (INTERNAL_FUNCTION_PARAMETERS, int buffered)
-{
- zval *sybase_link_index = NULL;
- zend_bool store = 1;
- char *query;
- size_t len, id, deadlock_count;
- sybase_link *sybase_ptr;
- sybase_result *result;
- CS_INT restype;
- CS_RETCODE retcode;
- enum {
- Q_RESULT, /* Success with results. */
- Q_SUCCESS, /* Success but no results. */
- Q_FAILURE, /* Failure, no results. */
- } status;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|rb", &query, &len, &sybase_link_index, &store) == FAILURE) {
- return;
- }
-
- if (!store && !buffered) {
- php_error_docref(NULL, E_NOTICE, "Sybase: Cannot use non-storing mode with buffered queries");
- store = 1;
- }
-
- if (php_sybase_connection_id(sybase_link_index, &id) == FAILURE) {
- php_error_docref(NULL, E_WARNING, "Sybase: No connection");
- RETURN_FALSE;
- }
-
- ZEND_FETCH_RESOURCE2(sybase_ptr, sybase_link *, &sybase_link_index, id, "Sybase-Link", le_link, le_plink);
-
- /* Fail if we already marked this connection dead. */
- if (sybase_ptr->dead) {
- RETURN_FALSE;
- }
-
- /* Check to see if a previous sybase_unbuffered_query has read all rows */
- if (sybase_ptr->active_result_index) {
- zval *tmp = NULL;
-
- php_error_docref(NULL, E_NOTICE, "Sybase: Called without first fetching all rows from a previous unbuffered query");
- if (sybase_ptr->cmd) {
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
- }
-
- /* Get the resultset and free it */
- ALLOC_ZVAL(tmp);
- Z_LVAL_P(tmp)= sybase_ptr->active_result_index;
- Z_TYPE_P(tmp)= IS_RESOURCE;
- INIT_PZVAL(tmp);
- ZEND_FETCH_RESOURCE(result, sybase_result *, &tmp, -1, "Sybase result", le_result);
-
- if (result) {
- php_sybase_finish_results(result);
- }
-
- zval_ptr_dtor(&tmp);
- zend_list_delete(sybase_ptr->active_result_index);
- sybase_ptr->active_result_index= 0;
- }
-
- /* Repeat until we don't deadlock. */
- deadlock_count= 0;
- for (;;) {
- result = NULL;
- sybase_ptr->deadlock = 0;
- sybase_ptr->affected_rows = 0;
-
- /* On Solaris 11.5, ct_command() can be moved outside the
- * loop, but not on Linux 11.0.
- */
- if (ct_command(sybase_ptr->cmd, CS_LANG_CMD, query, CS_NULLTERM, CS_UNUSED)!=CS_SUCCEED) {
- /* If this didn't work, the connection is screwed but
- * ct-lib might not set CS_CONSTAT_DEAD. So set our own
- * flag. This happens sometimes when the database is restarted
- * and/or its machine is rebooted, and ct_command() returns
- * CS_BUSY for some reason.
- */
- sybase_ptr->dead = 1;
- php_error_docref(NULL, E_WARNING, "Sybase: Connection is dead");
- RETURN_FALSE;
- }
-
- if (ct_send(sybase_ptr->cmd)!=CS_SUCCEED) {
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
- sybase_ptr->dead = 1;
- php_error_docref(NULL, E_WARNING, "Sybase: Cannot send command");
- RETURN_FALSE;
- }
-
- /* Use the first result set or succeed/fail status and discard the
- * others. Applications really shouldn't be making calls that
- * return multiple result sets, but if they do then we need to
- * properly read or cancel them or the connection will become
- * unusable.
- */
- if (ct_results(sybase_ptr->cmd, &restype)!=CS_SUCCEED) {
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
- sybase_ptr->dead = 1;
- php_error_docref(NULL, E_WARNING, "Sybase: Cannot read results");
- RETURN_FALSE;
- }
- switch ((int) restype) {
- case CS_CMD_FAIL:
- default:
- status = Q_FAILURE;
- break;
- case CS_CMD_SUCCEED:
- case CS_CMD_DONE: {
- CS_INT row_count;
- if (ct_res_info(sybase_ptr->cmd, CS_ROW_COUNT, &row_count, CS_UNUSED, NULL)==CS_SUCCEED) {
- sybase_ptr->affected_rows = (long)row_count;
- }
- }
- /* Fall through */
- case CS_COMPUTEFMT_RESULT:
- case CS_ROWFMT_RESULT:
- case CS_DESCRIBE_RESULT:
- case CS_MSG_RESULT:
- buffered= 0; /* These queries have no need for buffering */
- status = Q_SUCCESS;
- break;
- case CS_COMPUTE_RESULT:
- case CS_CURSOR_RESULT:
- case CS_PARAM_RESULT:
- case CS_ROW_RESULT:
- case CS_STATUS_RESULT:
- result = php_sybase_fetch_result_set(sybase_ptr, buffered, store);
- if (result == NULL) {
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
- RETURN_FALSE;
- }
- status = Q_RESULT;
- break;
- }
-
- /* Check for left-over results */
- if (!buffered && status != Q_RESULT) {
- while ((retcode = ct_results(sybase_ptr->cmd, &restype))==CS_SUCCEED) {
- switch ((int) restype) {
- case CS_CMD_SUCCEED:
- case CS_CMD_DONE:
- break;
-
- case CS_CMD_FAIL:
- status = Q_FAILURE;
- break;
-
- case CS_COMPUTE_RESULT:
- case CS_CURSOR_RESULT:
- case CS_PARAM_RESULT:
- case CS_ROW_RESULT:
- if (status != Q_RESULT) {
- result = php_sybase_fetch_result_set(sybase_ptr, buffered, store);
- if (result == NULL) {
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
- sybase_ptr->dead = 1;
- RETURN_FALSE;
- }
- status = Q_RESULT;
- retcode = result->last_retcode;
- } else {
- /* Unexpected results, cancel them. */
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_CURRENT);
- }
- break;
- case CS_STATUS_RESULT:
- /* Unexpected results, cancel them. */
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_CURRENT);
- break;
-
- default:
- status = Q_FAILURE;
- break;
- }
- if (status == Q_FAILURE) {
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
- }
- if (retcode == CS_END_RESULTS) {
- break;
- }
- }
- switch (retcode) {
- case CS_END_RESULTS:
- /* Normal. */
- break;
-
- case CS_FAIL:
- /* Hopefully this either cleans up the connection, or the
- * connection ends up marked dead so it will be reopened
- * if it is persistent. We may want to do
- * ct_close(CS_FORCE_CLOSE) if ct_cancel() fails; see the
- * doc for ct_results()==CS_FAIL.
- */
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
- /* Don't take chances with the vagaries of ct-lib. Mark it
- * dead ourselves.
- */
- sybase_ptr->dead = 1;
- case CS_CANCELED:
- default:
- status = Q_FAILURE;
- break;
- }
- }
-
- /* Retry deadlocks up until deadlock_retry_count times */
- if (sybase_ptr->deadlock && SybCtG(deadlock_retry_count) != -1 && ++deadlock_count > SybCtG(deadlock_retry_count)) {
- php_error_docref(NULL, E_WARNING, "Sybase: Retried deadlock %d times [max: %ld], giving up", deadlock_count- 1, SybCtG(deadlock_retry_count));
- FREE_SYBASE_RESULT(result);
- break;
- }
-
- /* If query completed without deadlock, break out of the loop.
- * Sometimes deadlock results in failures and sometimes not,
- * it seems to depend on the server flavor. But we want to
- * retry all deadlocks.
- */
- if (sybase_ptr->dead || sybase_ptr->deadlock == 0) {
- break;
- }
-
- /* Get rid of any results we may have fetched. This happens:
- * e.g., our result set may be a stored procedure status which
- * is returned even if the stored procedure deadlocks. As an
- * optimization, we could try not to fetch results in known
- * deadlock conditions, but deadlock is (should be) rare.
- */
- FREE_SYBASE_RESULT(result);
- }
-
- if (status == Q_SUCCESS) {
- RETURN_TRUE;
- }
-
- if (status == Q_FAILURE) {
- FREE_SYBASE_RESULT(result);
- RETURN_FALSE;
- }
-
- /* Indicate we have data in case of buffered queries */
- id= ZEND_REGISTER_RESOURCE(return_value, result, le_result);
- sybase_ptr->active_result_index= buffered ? id : 0;
-}
-
-/* {{{ proto int sybase_query(string query [, resource link_id])
- Send Sybase query */
-PHP_FUNCTION(sybase_query)
-{
- php_sybase_query(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-/* {{{ proto int sybase_unbuffered_query(string query [, resource link_id])
- Send Sybase query */
-PHP_FUNCTION(sybase_unbuffered_query)
-{
- php_sybase_query(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-
-/* {{{ proto bool sybase_free_result(resource result)
- Free result memory */
-PHP_FUNCTION(sybase_free_result)
-{
- zval *sybase_result_index = NULL;
- sybase_result *result;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &sybase_result_index) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(result, sybase_result *, &sybase_result_index, -1, "Sybase result", le_result);
-
- /* Did we fetch up until the end? */
- if (result->last_retcode != CS_END_DATA && result->last_retcode != CS_END_RESULTS) {
- /* php_error_docref(NULL, E_WARNING, "Sybase: canceling the rest of the results"); */
- ct_cancel(NULL, result->sybase_ptr->cmd, CS_CANCEL_ALL);
- php_sybase_finish_results(result);
- }
-
- zend_list_delete(Z_LVAL_P(sybase_result_index));
- RETURN_TRUE;
-}
-
-/* }}} */
-
-/* {{{ proto string sybase_get_last_message(void)
- Returns the last message from server (over min_message_severity) */
-PHP_FUNCTION(sybase_get_last_message)
-{
- RETURN_STRING(SybCtG(server_message), 1);
-}
-/* }}} */
-
-/* {{{ proto int sybase_num_rows(resource result)
- Get number of rows in result */
-PHP_FUNCTION(sybase_num_rows)
-{
- zval *sybase_result_index = NULL;
- sybase_result *result;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &sybase_result_index) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(result, sybase_result *, &sybase_result_index, -1, "Sybase result", le_result);
-
- Z_LVAL_P(return_value) = result->num_rows;
- Z_TYPE_P(return_value) = IS_LONG;
-}
-
-/* }}} */
-
-/* {{{ proto int sybase_num_fields(resource result)
- Get number of fields in result */
-PHP_FUNCTION(sybase_num_fields)
-{
- zval *sybase_result_index = NULL;
- sybase_result *result;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &sybase_result_index) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(result, sybase_result *, &sybase_result_index, -1, "Sybase result", le_result);
-
- Z_LVAL_P(return_value) = result->num_fields;
- Z_TYPE_P(return_value) = IS_LONG;
-}
-
-/* }}} */
-
-/* {{{ proto array sybase_fetch_row(resource result)
- Get row as enumerated array */
-PHP_FUNCTION(sybase_fetch_row)
-{
- zval *sybase_result_index = NULL;
- int i;
- sybase_result *result;
- zval *field_content;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &sybase_result_index) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(result, sybase_result *, &sybase_result_index, -1, "Sybase result", le_result);
-
- /* Unbuffered? */
- if (result->last_retcode != CS_END_DATA && result->last_retcode != CS_END_RESULTS) {
- php_sybase_fetch_result_row(result, 1);
- }
-
- /* At the end? */
- if (result->cur_row >= result->num_rows) {
- RETURN_FALSE;
- }
-
- array_init(return_value);
- for (i=0; i<result->num_fields; i++) {
- ALLOC_ZVAL(field_content);
- *field_content = result->data[result->store ? result->cur_row : 0][i];
- INIT_PZVAL(field_content);
- zval_copy_ctor(field_content);
- zend_hash_index_update(Z_ARRVAL_P(return_value), i, (void *) &field_content, sizeof(zval* ), NULL);
- }
- result->cur_row++;
-}
-
-/* }}} */
-
-static void php_sybase_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int numerics)
-{
- zval *sybase_result_index = NULL;
- sybase_result *result;
- int i, j;
- zval *tmp;
- char name[32];
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &sybase_result_index) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(result, sybase_result *, &sybase_result_index, -1, "Sybase result", le_result);
-
- /* Unbuffered ? Fetch next row */
- if (result->last_retcode != CS_END_DATA && result->last_retcode != CS_END_RESULTS) {
- php_sybase_fetch_result_row(result, 1);
- }
-
- /* At the end? */
- if (result->cur_row >= result->num_rows) {
- RETURN_FALSE;
- }
-
- array_init(return_value);
-
- j= 1;
- for (i=0; i<result->num_fields; i++) {
- ALLOC_ZVAL(tmp);
- *tmp = result->data[result->store ? result->cur_row : 0][i];
- INIT_PZVAL(tmp);
- zval_copy_ctor(tmp);
- if (numerics) {
- zend_hash_index_update(Z_ARRVAL_P(return_value), i, (void *) &tmp, sizeof(zval *), NULL);
- Z_ADDREF_P(tmp);
- }
-
- if (zend_hash_exists(Z_ARRVAL_P(return_value), result->fields[i].name, strlen(result->fields[i].name)+1)) {
- snprintf(name, 32, "%s%d", result->fields[i].name, j);
- result->fields[i].name= estrdup(name);
- j++;
- }
- zend_hash_update(Z_ARRVAL_P(return_value), result->fields[i].name, strlen(result->fields[i].name)+1, (void *) &tmp, sizeof(zval *), NULL);
- }
- result->cur_row++;
-}
-
-
-/* {{{ proto object sybase_fetch_object(resource result [, mixed object])
- Fetch row as object */
-PHP_FUNCTION(sybase_fetch_object)
-{
- zval *object = NULL;
- zval *sybase_result_index = NULL;
- zend_class_entry *ce = NULL;
- sybase_result *result;
-
- /* Was a second parameter given? */
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|z", &sybase_result_index, &object) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(result, sybase_result *, &sybase_result_index, -1, "Sybase result", le_result);
-
- ce = ZEND_STANDARD_CLASS_DEF_PTR;
- if (NULL != object) {
- switch (Z_TYPE_P(object)) {
- case IS_OBJECT: {
- ce = Z_OBJCE_P(object);
- break;
- }
-
- case IS_NULL: {
- /* Use default (ZEND_STANDARD_CLASS_DEF_PTR) */
- break;
- }
-
- default: {
- zend_class_entry **pce = NULL;
- convert_to_string(object);
-
- if (zend_lookup_class(Z_STRVAL_P(object), Z_STRLEN_P(object), &pce) == FAILURE) {
- php_error_docref(NULL, E_NOTICE, "Sybase: Class %s has not been declared", Z_STRVAL_P(object));
- /* Use default (ZEND_STANDARD_CLASS_DEF_PTR) */
- } else {
- ce = *pce;
- }
- }
- }
- }
-
- /* Reset no. of arguments to 1 so that we can use INTERNAL_FUNCTION_PARAM_PASSTHRU */
- ht= 1;
- php_sybase_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
- if (Z_TYPE_P(return_value) == IS_ARRAY) {
- object_and_properties_init(return_value, ce, Z_ARRVAL_P(return_value));
- }
-}
-/* }}} */
-
-/* {{{ proto array sybase_fetch_array(resource result)
- Fetch row as array */
-PHP_FUNCTION(sybase_fetch_array)
-{
- php_sybase_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-/* {{{ proto array sybase_fetch_assoc(resource result)
- Fetch row as array without numberic indices */
-PHP_FUNCTION(sybase_fetch_assoc)
-{
- php_sybase_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-/* {{{ proto bool sybase_data_seek(resource result, int offset)
- Move internal row pointer */
-PHP_FUNCTION(sybase_data_seek)
-{
- zval *sybase_result_index = NULL;
- long offset;
- sybase_result *result;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &sybase_result_index, &offset) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(result, sybase_result *, &sybase_result_index, -1, "Sybase result", le_result);
-
- /* Unbuffered ? */
- if (result->last_retcode != CS_END_DATA && result->last_retcode != CS_END_RESULTS && offset >= result->num_rows) {
- php_sybase_fetch_result_row(result, offset+ 1);
- }
-
- if (offset < 0 || offset >= result->num_rows) {
- php_error_docref(NULL, E_WARNING, "Sybase: Bad row offset %ld, must be betweem 0 and %d", offset, result->num_rows - 1);
- RETURN_FALSE;
- }
-
- result->cur_row = offset;
- RETURN_TRUE;
-}
-/* }}} */
-
-static char *php_sybase_get_field_name(CS_INT type)
-{
- switch (type) {
- case CS_CHAR_TYPE:
- case CS_VARCHAR_TYPE:
- case CS_TEXT_TYPE:
- return "string";
- break;
- case CS_IMAGE_TYPE:
- return "image";
- break;
- case CS_BINARY_TYPE:
- case CS_VARBINARY_TYPE:
- return "blob";
- break;
- case CS_BIT_TYPE:
- return "bit";
- break;
- case CS_TINYINT_TYPE:
- case CS_SMALLINT_TYPE:
- case CS_INT_TYPE:
- return "int";
- break;
- case CS_REAL_TYPE:
- case CS_FLOAT_TYPE:
- case CS_NUMERIC_TYPE:
- case CS_DECIMAL_TYPE:
- return "real";
- break;
- case CS_MONEY_TYPE:
- case CS_MONEY4_TYPE:
- return "money";
- break;
- case CS_DATETIME_TYPE:
- case CS_DATETIME4_TYPE:
- return "datetime";
- break;
- default:
- return "unknown";
- break;
- }
-}
-
-
-/* {{{ proto object sybase_fetch_field(resource result [, int offset])
- Get field information */
-PHP_FUNCTION(sybase_fetch_field)
-{
- zval *sybase_result_index = NULL;
- long field_offset = -1;
- sybase_result *result;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &sybase_result_index, &field_offset) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(result, sybase_result *, &sybase_result_index, -1, "Sybase result", le_result);
-
- if (field_offset == -1) {
- field_offset = result->cur_field;
- result->cur_field++;
- }
-
- if (field_offset < 0 || field_offset >= result->num_fields) {
- if (ZEND_NUM_ARGS() == 2) { /* field specified explicitly */
- php_error_docref(NULL, E_WARNING, "Sybase: Bad column offset");
- }
- RETURN_FALSE;
- }
-
- object_init(return_value);
-
- add_property_string(return_value, "name", result->fields[field_offset].name);
- add_property_long(return_value, "max_length", result->fields[field_offset].max_length);
- add_property_string(return_value, "column_source", result->fields[field_offset].column_source);
- add_property_long(return_value, "numeric", result->fields[field_offset].numeric);
- add_property_string(return_value, "type", php_sybase_get_field_name(Z_TYPE(result->fields[field_offset])));
-}
-/* }}} */
-
-
-/* {{{ proto bool sybase_field_seek(resource result, int offset)
- Set field offset */
-PHP_FUNCTION(sybase_field_seek)
-{
- zval *sybase_result_index = NULL;
- long field_offset;
- sybase_result *result;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &sybase_result_index, &field_offset) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(result, sybase_result *, &sybase_result_index, -1, "Sybase result", le_result);
-
- if (field_offset < 0 || field_offset >= result->num_fields) {
- php_error_docref(NULL, E_WARNING, "Sybase: Bad column offset");
- RETURN_FALSE;
- }
-
- result->cur_field = field_offset;
- RETURN_TRUE;
-}
-/* }}} */
-
-
-/* {{{ proto string sybase_result(resource result, int row, mixed field)
- Get result data */
-PHP_FUNCTION(sybase_result)
-{
- zval *field;
- zval *sybase_result_index = NULL;
- long row;
- int field_offset = 0;
- sybase_result *result;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlz", &sybase_result_index, &row, &field) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(result, sybase_result *, &sybase_result_index, -1, "Sybase result", le_result);
-
- /* Unbuffered ? */
- if (result->last_retcode != CS_END_DATA && result->last_retcode != CS_END_RESULTS && row >= result->num_rows) {
- php_sybase_fetch_result_row(result, row);
- }
-
- if (row < 0 || row >= result->num_rows) {
- php_error_docref(NULL, E_WARNING, "Sybase: Bad row offset (%ld)", row);
- RETURN_FALSE;
- }
-
- switch(Z_TYPE_P(field)) {
- case IS_STRING: {
- int i;
-
- for (i = 0; i < result->num_fields; i++) {
- if (strcasecmp(result->fields[i].name, Z_STRVAL_P(field)) == 0) {
- field_offset = i;
- break;
- }
- }
- if (i >= result->num_fields) { /* no match found */
- php_error_docref(NULL, E_WARNING, "Sybase: %s field not found in result", Z_STRVAL_P(field));
- RETURN_FALSE;
- }
- break;
- }
- default:
- convert_to_long(field);
- field_offset = Z_LVAL_P(field);
- if (field_offset < 0 || field_offset >= result->num_fields) {
- php_error_docref(NULL, E_WARNING, "Sybase: Bad column offset specified");
- RETURN_FALSE;
- }
- break;
- }
-
- *return_value = result->data[row][field_offset];
- zval_copy_ctor(return_value);
-}
-/* }}} */
-
-
-/* {{{ proto int sybase_affected_rows([resource link_id])
- Get number of affected rows in last query */
-PHP_FUNCTION(sybase_affected_rows)
-{
- zval *sybase_link_index = NULL;
- sybase_link *sybase_ptr;
- int id;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|r", &sybase_link_index) == FAILURE) {
- return;
- }
-
- if (php_sybase_connection_id(sybase_link_index, &id) == FAILURE) {
- php_error_docref(NULL, E_WARNING, "Sybase: No connection");
- RETURN_FALSE;
- }
-
- ZEND_FETCH_RESOURCE2(sybase_ptr, sybase_link *, &sybase_link_index, id, "Sybase-Link", le_link, le_plink);
-
- Z_LVAL_P(return_value) = sybase_ptr->affected_rows;
- Z_TYPE_P(return_value) = IS_LONG;
-}
-/* }}} */
-
-
-PHP_MINFO_FUNCTION(sybase)
-{
- char buf[32];
-
- php_info_print_table_start();
- php_info_print_table_header(2, "Sybase_CT Support", "enabled" );
- snprintf(buf, sizeof(buf), "%ld", SybCtG(num_persistent));
- php_info_print_table_row(2, "Active Persistent Links", buf);
- snprintf(buf, sizeof(buf), "%ld", SybCtG(num_links));
- php_info_print_table_row(2, "Active Links", buf);
- snprintf(buf, sizeof(buf), "%ld", SybCtG(min_server_severity));
- php_info_print_table_row(2, "Min server severity", buf);
- snprintf(buf, sizeof(buf), "%ld", SybCtG(min_client_severity));
- php_info_print_table_row(2, "Min client severity", buf);
- php_info_print_table_row(2, "Application Name", SybCtG(appname));
- snprintf(buf, sizeof(buf), "%ld", SybCtG(deadlock_retry_count));
- php_info_print_table_row(2, "Deadlock retry count", buf);
- php_info_print_table_end();
-
- DISPLAY_INI_ENTRIES();
-}
-
-
-/* {{{ proto void sybase_min_client_severity(int severity)
- Sets minimum client severity */
-PHP_FUNCTION(sybase_min_client_severity)
-{
- long severity;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &severity) == FAILURE) {
- return;
- }
-
- SybCtG(min_client_severity) = severity;
-}
-/* }}} */
-
-
-/* {{{ proto void sybase_min_server_severity(int severity)
- Sets minimum server severity */
-PHP_FUNCTION(sybase_min_server_severity)
-{
- long severity;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &severity) == FAILURE) {
- return;
- }
-
- SybCtG(min_server_severity) = severity;
-}
-/* }}} */
-
-/* {{{ proto void sybase_deadlock_retry_count(int retry_count)
- Sets deadlock retry count */
-PHP_FUNCTION(sybase_deadlock_retry_count)
-{
- long retry_count;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &retry_count) == FAILURE) {
- return;
- }
-
- SybCtG(deadlock_retry_count) = retry_count;
-}
-/* }}} */
-
-
-/* {{{ proto bool sybase_set_message_handler(mixed error_func [, resource connection])
- Set the error handler, to be called when a server message is raised.
- If error_func is NULL the handler will be deleted */
-PHP_FUNCTION(sybase_set_message_handler)
-{
- zend_fcall_info fci = empty_fcall_info;
- zend_fcall_info_cache cache = empty_fcall_info_cache;
- zval *sybase_link_index= NULL;
- sybase_link *sybase_ptr;
- zval **callback;
- int id;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "f!|r", &fci, &cache, &sybase_link_index) == FAILURE) {
- return;
- }
-
- if (php_sybase_connection_id(sybase_link_index, &id) == FAILURE) {
-
- /* Doesn't matter if we're not connected yet, use default */
- callback= &SybCtG(callback_name);
- } else if (-1 == id) {
-
- /* Connection-based message handler */
- ZEND_FETCH_RESOURCE2(sybase_ptr, sybase_link *, &sybase_link_index, id, "Sybase-Link", le_link, le_plink);
- callback= &sybase_ptr->callback_name;
- } else {
-
- /* Default message handler */
- callback= &SybCtG(callback_name);
- }
-
- /* Clean old callback */
- if (*callback) {
- zval_ptr_dtor(callback);
- *callback = NULL;
- }
-
- if (ZEND_FCI_INITIALIZED(fci)) {
- ALLOC_ZVAL(*callback);
- **callback = *fci.function_name;
- INIT_PZVAL(*callback);
- zval_copy_ctor(*callback);
- } else {
- callback= NULL;
- }
-
- RETURN_TRUE;
-}
-/* }}} */
-
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/sybase_ct/php_sybase_ct.h b/ext/sybase_ct/php_sybase_ct.h
deleted file mode 100644
index a517f3e637..0000000000
--- a/ext/sybase_ct/php_sybase_ct.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- | Timm Friebe <php_sybase_ct@thekid.de> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef PHP_SYBASE_CT_H
-#define PHP_SYBASE_CT_H
-
-#if HAVE_SYBASE_CT
-
-#define CTLIB_VERSION CS_VERSION_100
-
-extern zend_module_entry sybase_module_entry;
-#define sybase_module_ptr &sybase_module_entry
-
-PHP_MINIT_FUNCTION(sybase);
-PHP_MSHUTDOWN_FUNCTION(sybase);
-PHP_RINIT_FUNCTION(sybase);
-PHP_RSHUTDOWN_FUNCTION(sybase);
-PHP_MINFO_FUNCTION(sybase);
-
-PHP_FUNCTION(sybase_connect);
-PHP_FUNCTION(sybase_pconnect);
-PHP_FUNCTION(sybase_close);
-PHP_FUNCTION(sybase_select_db);
-PHP_FUNCTION(sybase_query);
-PHP_FUNCTION(sybase_unbuffered_query);
-PHP_FUNCTION(sybase_free_result);
-PHP_FUNCTION(sybase_get_last_message);
-PHP_FUNCTION(sybase_num_rows);
-PHP_FUNCTION(sybase_num_fields);
-PHP_FUNCTION(sybase_fetch_row);
-PHP_FUNCTION(sybase_fetch_array);
-PHP_FUNCTION(sybase_fetch_assoc);
-PHP_FUNCTION(sybase_fetch_object);
-PHP_FUNCTION(sybase_data_seek);
-PHP_FUNCTION(sybase_result);
-PHP_FUNCTION(sybase_affected_rows);
-PHP_FUNCTION(sybase_field_seek);
-PHP_FUNCTION(sybase_min_client_severity);
-PHP_FUNCTION(sybase_min_server_severity);
-PHP_FUNCTION(sybase_fetch_field);
-PHP_FUNCTION(sybase_set_message_handler);
-PHP_FUNCTION(sybase_deadlock_retry_count);
-
-#include <ctpublic.h>
-
-ZEND_BEGIN_MODULE_GLOBALS(sybase)
- long default_link;
- long num_links,num_persistent;
- long max_links,max_persistent;
- long login_timeout;
- long allow_persistent;
- char *appname;
- char *hostname;
- char *server_message;
- long min_server_severity, min_client_severity;
- long deadlock_retry_count;
- zval *callback_name;
- CS_CONTEXT *context;
-ZEND_END_MODULE_GLOBALS(sybase)
-
-typedef struct {
- CS_CONNECTION *connection;
- CS_COMMAND *cmd;
- int valid;
- int deadlock;
- int dead;
- int active_result_index;
- long affected_rows;
- zval *callback_name;
-} sybase_link;
-
-#define SYBASE_ROWS_BLOCK 128
-
-typedef struct {
- char *name,*column_source;
- int max_length, numeric;
- CS_INT type;
-} sybase_field;
-
-typedef struct {
- zval **data;
- sybase_field *fields;
- sybase_link *sybase_ptr;
- int cur_row,cur_field;
- int num_rows,num_fields;
-
- /* For unbuffered reads */
- CS_INT *lengths;
- CS_SMALLINT *indicators;
- char **tmp_buffer;
- unsigned char *numerics;
- CS_INT *types;
- CS_DATAFMT *datafmt;
- int blocks_initialized;
- CS_RETCODE last_retcode;
- int store;
-} sybase_result;
-
-#ifdef ZTS
-# define SybCtG(v) TSRMG(sybase_globals_id, zend_sybase_globals *, v)
-#else
-# define SybCtG(v) (sybase_globals.v)
-#endif
-
-#else
-
-#define sybase_module_ptr NULL
-
-#endif
-
-#define phpext_sybase_ct_ptr sybase_module_ptr
-
-#endif /* PHP_SYBASE_CT_H */
diff --git a/ext/sybase_ct/tests/bug22403.phpt b/ext/sybase_ct/tests/bug22403.phpt
deleted file mode 100644
index 20d5248ff4..0000000000
--- a/ext/sybase_ct/tests/bug22403.phpt
+++ /dev/null
@@ -1,88 +0,0 @@
---TEST--
-Sybase-CT bug #22403 (crash when executing a stored procedure without parameters)
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
- sybase_set_message_handler('sybase_msg_handler');
- error_reporting(error_reporting() & !E_NOTICE); // Suppress notices
-
- // Check if stored procedure already exists
- $sp_name= 'phpt_bug22403';
- var_dump(sybase_select_db(TEMPDB, $db));
- if (!sybase_select_single($db, 'select object_id("'.$sp_name.'")')) {
- echo "Stored procedure {$sp_name} not found, creating\n";
- var_dump(sybase_query('
- create proc '.$sp_name.' (@param int)
- as
- begin
- select @param
- select @param + 1
- return @param
- end
- '));
- } else {
- echo "Stored procedure {$sp_name} found, using\n";
- var_dump(TRUE);
- }
-
- // These don't work
- var_dump(sybase_select_ex($db, 'exec '.$sp_name));
- var_dump(sybase_select_ex($db, 'exec '.$sp_name.' "foo"'));
- var_dump(sybase_select_ex($db, 'exec does_not_exist'));
-
- // These do
- var_dump(sybase_select_ex($db, 'exec '.$sp_name.' NULL'));
- var_dump(sybase_select_ex($db, 'exec '.$sp_name.' 1'));
-
- // Clean up after ourselves
- var_dump(sybase_query('drop proc '.$sp_name));
-
- sybase_close($db);
-?>
---EXPECTF--
-bool(true)
-Stored procedure %s
-bool(true)
->>> Query: exec %s
-*** Caught Sybase Server Message #201 [Severity 16, state 2] at line 0
- %s
-<<< Return: boolean
-bool(false)
->>> Query: exec %s "foo"
-*** Caught Sybase Server Message #257 [Severity 16, state 1] at line 0
- %s
-<<< Return: boolean
-bool(false)
->>> Query: exec does_not_exist
-*** Caught Sybase Server Message #2812 [Severity 16, state %d] at line 1
- %s
-<<< Return: boolean
-bool(false)
->>> Query: exec %s NULL
-<<< Return: resource
-array(1) {
- [0]=>
- array(1) {
- ["computed"]=>
- NULL
- }
-}
->>> Query: exec %s 1
-<<< Return: resource
-array(1) {
- [0]=>
- array(1) {
- ["computed"]=>
- int(1)
- }
-}
-bool(true)
diff --git a/ext/sybase_ct/tests/bug26407.phpt b/ext/sybase_ct/tests/bug26407.phpt
deleted file mode 100644
index 27f5f99b9d..0000000000
--- a/ext/sybase_ct/tests/bug26407.phpt
+++ /dev/null
@@ -1,91 +0,0 @@
---TEST--
-Sybase-CT bug #26407 (Result set fetching broken around transactions)
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
-
- // Create temporary table
- $table= 'phpt_bug26407';
- var_dump(sybase_query('create table #'.$table.' ( the_big_answer int )', $db));
-
- // I
- var_dump(sybase_select_ex($db, '
- begin transaction
- -- anything producing a result set here will fail;
- -- however, print or update statements will work
- select "foo"
- commit
- -- anything afterwards will fail, too
- '));
-
- // II
- var_dump(sybase_select_ex($db, '
- begin transaction
- -- no result returned...
- update #'.$table.' set the_big_answer=42
- commit
- '));
-
- // III
- var_dump(sybase_select_ex($db, '
- select "foo"
- begin transaction
- -- do anything, even return a result set
- commit
- select "bar"
- '));
-
- sybase_close($db);
-?>
---EXPECTF--
-bool(true)
->>> Query:
- begin transaction
- -- anything producing a result set here will fail;
- -- however, print or update statements will work
- select "foo"
- commit
- -- anything afterwards will fail, too
-
-<<< Return: resource
-array(1) {
- [0]=>
- array(1) {
- ["computed"]=>
- string(3) "foo"
- }
-}
->>> Query:
- begin transaction
- -- no result returned...
- update #phpt_bug26407 set the_big_answer=42
- commit
-
-<<< Return: boolean
-bool(true)
->>> Query:
- select "foo"
- begin transaction
- -- do anything, even return a result set
- commit
- select "bar"
-
-
-Notice: sybase_query(): Sybase: Unexpected results, canceling current in %stest.inc on line %d
-<<< Return: resource
-array(1) {
- [0]=>
- array(1) {
- ["computed"]=>
- string(3) "foo"
- }
-}
diff --git a/ext/sybase_ct/tests/bug27843.phpt b/ext/sybase_ct/tests/bug27843.phpt
deleted file mode 100644
index 861d1f95e7..0000000000
--- a/ext/sybase_ct/tests/bug27843.phpt
+++ /dev/null
@@ -1,54 +0,0 @@
---TEST--
-Sybase-CT bug #27843 (notices when query is a stored procedure)
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
-
- // Check if stored procedure already exists
- $sp_name= 'phpt_bug27843';
- var_dump(sybase_select_db(TEMPDB, $db));
- if (!sybase_select_single($db, 'select object_id("'.$sp_name.'")')) {
- echo "Stored procedure {$sp_name} not found, creating\n";
- var_dump(sybase_query('
- create proc '.$sp_name.'
- as
- begin
- select 1
- end
- '));
- } else {
- echo "Stored procedure {$sp_name} found, using\n";
- var_dump(TRUE);
- }
-
- // Execute stored procedure
- var_dump(sybase_select_ex($db, 'exec '.$sp_name));
-
- // Clean up after ourselves
- var_dump(sybase_query('drop proc '.$sp_name, $db));
-
- sybase_close($db);
-?>
---EXPECTF--
-bool(true)
-Stored procedure %s
-bool(true)
->>> Query: exec phpt_bug27843
-<<< Return: resource
-array(1) {
- [0]=>
- array(1) {
- ["computed"]=>
- int(1)
- }
-}
-bool(true)
diff --git a/ext/sybase_ct/tests/bug28354.phpt b/ext/sybase_ct/tests/bug28354.phpt
deleted file mode 100644
index 018f7bddec..0000000000
--- a/ext/sybase_ct/tests/bug28354.phpt
+++ /dev/null
@@ -1,46 +0,0 @@
---TEST--
-Sybase-CT bug #28354 (sybase_free_result crash)
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
- sybase_set_message_handler('sybase_msg_handler');
- error_reporting(error_reporting() & !E_NOTICE); // Suppress notices
-
- // Check if stored procedure already exists
- $sp_name= 'phpt_bug28354';
- var_dump(sybase_select_db(TEMPDB, $db));
- if (!sybase_select_single($db, 'select object_id("'.$sp_name.'")')) {
- echo "Stored procedure {$sp_name} not found, creating\n";
- var_dump(sybase_query('
- create proc '.$sp_name.' as begin
- select @@version
- end
- '));
- } else {
- echo "Stored procedure {$sp_name} found, using\n";
- var_dump(TRUE);
- }
-
- $r= sybase_query('exec '.$sp_name, $db);
- $i= 0;
- while ($row= sybase_fetch_row($r)) {
- var_dump($i++, $row[0]);
- }
- sybase_free_result($r);
- sybase_close($db);
-?>
---EXPECTF--
-bool(true)
-Stored procedure %s
-bool(true)
-int(0)
-string(%d) "%s"
diff --git a/ext/sybase_ct/tests/bug29064.phpt b/ext/sybase_ct/tests/bug29064.phpt
deleted file mode 100644
index df13d28a1d..0000000000
--- a/ext/sybase_ct/tests/bug29064.phpt
+++ /dev/null
@@ -1,143 +0,0 @@
---TEST--
-Sybase-CT bug #29064 (Exact numeric/decimal/money datatypes lose precision)
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
-
- // Create a temporary table and fill it with test values
- var_dump(sybase_query('
- create table #test (
- test_decimal decimal(38, 6) null,
- test_numeric numeric(38, 12) null,
- test_money money null,
- test_bigint decimal(38, 0) null,
- test_int int null,
- test_smallmoney smallmoney null,
- test_smallint smallint null,
- test_tinyint tinyint null,
- test_real float null,
- test_double float null
- )
- ', $db));
- var_dump(sybase_query('
- insert into #test (
- test_decimal,
- test_numeric,
- test_money,
- test_bigint,
- test_int,
- test_smallmoney,
- test_smallint,
- test_tinyint,
- test_real,
- test_double
- ) values (
- 12345678901234567890123456789012.123456,
- 12345678901234567890123456.123456789012,
- 123456789012345.1234,
- 12345678901234567890123456789012345678,
- 1234567890,
- 123456.1234,
- 12345,
- 123,
- 123456789.12345679,
- 123456789.12345679
- )
- ', $db));
- var_dump(sybase_query('
- insert into #test (
- test_decimal,
- test_numeric,
- test_money,
- test_bigint,
- test_int,
- test_smallmoney,
- test_smallint,
- test_tinyint,
- test_real,
- test_double
- ) values (
- -12345678901234567890123456789012.123456,
- -12345678901234567890123456.123456789012,
- -123456789012345.1234,
- -12345678901234567890123456789012345678,
- -1234567890,
- -123456.1234,
- -12345,
- 255,
- -123456789.12345679,
- -123456789.12345679
- )
- ', $db));
-
- // Select the data
- var_dump(sybase_select_ex($db, 'select * from #test'));
-
- // Clean up and close connection
- var_dump(sybase_query('drop table #test', $db));
- sybase_close($db);
-?>
---EXPECTF--
-bool(true)
-bool(true)
-bool(true)
->>> Query: select * from #test
-<<< Return: resource
-array(2) {
- [0]=>
- array(10) {
- ["test_decimal"]=>
- string(39) "12345678901234567890123456789012.123456"
- ["test_numeric"]=>
- string(39) "12345678901234567890123456.123456789012"
- ["test_money"]=>
- string(18) "123456789012345.12"
- ["test_bigint"]=>
- string(38) "12345678901234567890123456789012345678"
- ["test_int"]=>
- int(1234567890)
- ["test_smallmoney"]=>
- float(123456.12)
- ["test_smallint"]=>
- int(12345)
- ["test_tinyint"]=>
- int(123)
- ["test_real"]=>
- string(18) "123456789.12345679"
- ["test_double"]=>
- string(18) "123456789.12345679"
- }
- [1]=>
- array(10) {
- ["test_decimal"]=>
- string(40) "-12345678901234567890123456789012.123456"
- ["test_numeric"]=>
- string(40) "-12345678901234567890123456.123456789012"
- ["test_money"]=>
- string(19) "-123456789012345.12"
- ["test_bigint"]=>
- string(39) "-12345678901234567890123456789012345678"
- ["test_int"]=>
- int(-1234567890)
- ["test_smallmoney"]=>
- float(-123456.12)
- ["test_smallint"]=>
- int(-12345)
- ["test_tinyint"]=>
- int(255)
- ["test_real"]=>
- string(19) "-123456789.12345679"
- ["test_double"]=>
- string(19) "-123456789.12345679"
- }
-}
-bool(true)
diff --git a/ext/sybase_ct/tests/bug30312-withfree.phpt b/ext/sybase_ct/tests/bug30312-withfree.phpt
deleted file mode 100644
index 0017865da4..0000000000
--- a/ext/sybase_ct/tests/bug30312-withfree.phpt
+++ /dev/null
@@ -1,34 +0,0 @@
---TEST--
-Sybase-CT bug #30312 (sybase_unbuffered_query calls, with free)
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
- error_reporting(error_reporting() & !E_NOTICE); // Suppress notices
-
- $db= sybase_connect_ex();
-
- $query= sybase_unbuffered_query('select datepart(yy, getdate())');
- $array= sybase_fetch_row($query);
- var_dump($array[0]);
- sybase_free_result($query);
-
- $query= sybase_unbuffered_query('select datepart(mm, getdate()), datepart(dd, getdate())');
- $array= sybase_fetch_row($query);
- var_dump($array);
- sybase_free_result($query);
-?>
---EXPECTF--
-int(%d)
-array(2) {
- [0]=>
- int(%d)
- [1]=>
- int(%d)
-}
diff --git a/ext/sybase_ct/tests/bug30312.phpt b/ext/sybase_ct/tests/bug30312.phpt
deleted file mode 100644
index 273b579d61..0000000000
--- a/ext/sybase_ct/tests/bug30312.phpt
+++ /dev/null
@@ -1,27 +0,0 @@
---TEST--
-Sybase-CT bug #30312 (sybase_unbuffered_query calls)
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
- error_reporting(error_reporting() & !E_NOTICE); // Suppress notices
-
- $db= sybase_connect_ex();
-
- $query= sybase_unbuffered_query('select datepart(yy, getdate())');
- $array= sybase_fetch_array($query);
- var_dump($array[0]);
-
- $query= sybase_unbuffered_query('select datepart(yy, getdate())');
- $array= sybase_fetch_array($query);
- var_dump($array[0]);
-?>
---EXPECTF--
-int(%d)
-int(%d)
diff --git a/ext/sybase_ct/tests/bug43578.phpt b/ext/sybase_ct/tests/bug43578.phpt
deleted file mode 100644
index 9f75b9c0ea..0000000000
--- a/ext/sybase_ct/tests/bug43578.phpt
+++ /dev/null
@@ -1,65 +0,0 @@
---TEST--
-Sybase-CT bug #43578 (Incurred fault #6 - if returned textfield ist empty)
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
-
- // Create a temporary table and fill it with test values
- var_dump(sybase_query('
- create table #Resource (
- Resource_ID int,
- DC_Rights text null
- )
- ', $db));
- var_dump(sybase_query('insert into #Resource values (123, NULL)', $db));
- var_dump(sybase_query('insert into #Resource values (124, "")', $db));
-
- // Select non-existent
- var_dump(sybase_select_ex($db, 'select DC_Rights from #Resource where Resource_ID = 122'));
-
- // Select null
- var_dump(sybase_select_ex($db, 'select DC_Rights from #Resource where Resource_ID = 123'));
-
- // Select empty
- var_dump(sybase_select_ex($db, 'select DC_Rights from #Resource where Resource_ID = 124'));
-
- // Clean up and close connection
- var_dump(sybase_query('drop table #Resource', $db));
- sybase_close($db);
-?>
---EXPECTF--
-bool(true)
-bool(true)
-bool(true)
->>> Query: select DC_Rights from #Resource where Resource_ID = 122
-<<< Return: resource
-array(0) {
-}
->>> Query: select DC_Rights from #Resource where Resource_ID = 123
-<<< Return: resource
-array(1) {
- [0]=>
- array(1) {
- ["DC_Rights"]=>
- NULL
- }
-}
->>> Query: select DC_Rights from #Resource where Resource_ID = 124
-<<< Return: resource
-array(1) {
- [0]=>
- array(1) {
- ["DC_Rights"]=>
- string(1) " "
- }
-}
-bool(true)
diff --git a/ext/sybase_ct/tests/bug6339.phpt b/ext/sybase_ct/tests/bug6339.phpt
deleted file mode 100644
index 3b0a072b4a..0000000000
--- a/ext/sybase_ct/tests/bug6339.phpt
+++ /dev/null
@@ -1,24 +0,0 @@
---TEST--
-Sybase-CT bug #6339 (invalid Sybase-link resource)
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- // Suppress "Changed database context" warnings
- sybase_min_server_severity(11);
- sybase_connect(HOST, USER, PASSWORD);
- var_dump(sybase_fetch_row(sybase_query('select 1')));
- sybase_close();
-?>
---EXPECTF--
-array(1) {
- [0]=>
- int(1)
-}
diff --git a/ext/sybase_ct/tests/skipif.inc b/ext/sybase_ct/tests/skipif.inc
deleted file mode 100644
index 55bf53aa77..0000000000
--- a/ext/sybase_ct/tests/skipif.inc
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require 'test.inc';
-
- if (!extension_loaded('sybase_ct')) die('skip Sybase-CT extension not loaded');
-
- sybase_min_server_severity(11);
- if (!@sybase_connect(HOST, USER, PASSWORD)) die('skip Unable to connect');
-?>
diff --git a/ext/sybase_ct/tests/test.inc b/ext/sybase_ct/tests/test.inc
deleted file mode 100644
index 8dd2f7fadf..0000000000
--- a/ext/sybase_ct/tests/test.inc
+++ /dev/null
@@ -1,86 +0,0 @@
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- // Change if needed
- define('HOST', getenv('PHP_SYBASE_HOST'));
- define('USER', getenv('PHP_SYBASE_USER'));
- define('PASSWORD', getenv('PHP_SYBASE_PASS'));
- define('TEMPDB', 'tempdb');
-
- // {{{ bool sybase_msg_handler(int msgnumber, int severity, int state, int line, string text)
- // Handles server messages
- function sybase_msg_handler($msgnumber, $severity, $state, $line, $text) {
- printf(
- "*** Caught Sybase Server Message #%d [Severity %d, state %d] at line %d\n '%s'\n",
- $msgnumber,
- $severity,
- $state,
- $line,
- chop($text)
- );
- }
- // }}}
-
- // {{{ public class sybase
- class sybase {
-
- // {{{ public static bool static_handler(int msgnumber, int severity, int state, int line, string text)
- // Handles server messages
- static function static_handler($msgnumber, $severity, $state, $line, $text) {
- return sybase_msg_handler($msgnumber, $severity, $state, $line, $text);
- }
- // }}}
-
- // {{{ public bool static_handler(int msgnumber, int severity, int state, int line, string text)
- // Handles server messages
- function handler($msgnumber, $severity, $state, $line, $text) {
- return sybase_msg_handler($msgnumber, $severity, $state, $line, $text);
- }
- // }}}
- }
- // }}}
-
- // {{{ void sybase_set_messagehandler_ex(string handler)
- // Sets the sybase message handler and dumps the result
- function sybase_set_messagehandler_ex($handler) {
- var_dump(sybase_set_message_handler($handler));
- }
-
- // {{{ resource sybase_connect_ex(string charset= NULL, string appname= NULL, bool new= FALSE)
- // Connect to the sybase server using the defines HOST, USER and PASSWORD
- function sybase_connect_ex($charset= NULL, $appname= NULL, $new= FALSE) {
- sybase_min_server_severity(11); // Suppress "changed database context"
- if (!($db= sybase_connect(HOST, USER, PASSWORD, $charset ? $charset : 'iso_1', $appname, $new))) {
- die('Connect to '.USER.'@'.HOST.' failed (using password: '.(PASSWORD ? 'yes' : 'no').')');
- }
- return $db;
- }
- // }}}
-
- // {{{ void sybase_select_ex(resource dbh, string query)
- // Returns all fetched rows from an SQL query
- function sybase_select_ex($dbh, $query) {
- printf(">>> Query: %s\n", $query);
- $h= sybase_query($query, $dbh);
- printf("<<< Return: %s\n", gettype($h));
- flush();
- if (!is_resource($h)) return $h;
-
- $return= array();
- while ($row= sybase_fetch_assoc($h)) {
- $return[]= $row;
- }
- return $return;
- }
-
- // {{{ mixed sybase_select_single(resource dbh, string query)
- // Fires an SQL query and returns the first value from the first row
- function sybase_select_single($dbh, $query) {
- $a = sybase_fetch_row(sybase_query($query, $dbh));
- return array_shift($a);
- }
- // }}}
-?>
diff --git a/ext/sybase_ct/tests/test_appname.phpt b/ext/sybase_ct/tests/test_appname.phpt
deleted file mode 100644
index 71f5c32f4d..0000000000
--- a/ext/sybase_ct/tests/test_appname.phpt
+++ /dev/null
@@ -1,55 +0,0 @@
---TEST--
-Sybase-CT application name
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- // {{{ bool compare_string(string expect, string actual)
- // Compares expect to a trimmed version of actual
- function compare_string($expect, $actual) {
- $trimmed= rtrim($actual, ' ');
- return (0 == strncmp($expect, $trimmed, strlen($trimmed)));
- }
- // }}}
-
- $program_name= 'phpt_test';
- $hostname= 'php.net';
- ini_set('sybct.hostname', $hostname);
-
- $db= sybase_connect_ex(NULL, $program_name);
- $r= sybase_select_ex($db, '
- select
- hostname,
- program_name
- from
- master..sysprocesses
- where
- program_name = "'.$program_name.'"'
- );
-
- var_dump(
- compare_string($program_name, $r[0]['program_name']),
- compare_string($hostname, $r[0]['hostname'])
- );
-
- sybase_close($db);
-?>
---EXPECTF--
->>> Query:
- select
- hostname,
- program_name
- from
- master..sysprocesses
- where
- program_name = "phpt_test"
-<<< Return: resource
-bool(true)
-bool(true)
diff --git a/ext/sybase_ct/tests/test_close.phpt b/ext/sybase_ct/tests/test_close.phpt
deleted file mode 100644
index e2c3ebcb60..0000000000
--- a/ext/sybase_ct/tests/test_close.phpt
+++ /dev/null
@@ -1,25 +0,0 @@
---TEST--
-Sybase-CT close
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
- var_dump($db);
- sybase_close($db);
- var_dump($db);
- var_dump(sybase_query('select getdate()', $db));
-?>
---EXPECTF--
-resource(%d) of type (sybase-ct link)
-resource(%d) of type (Unknown)
-
-Warning: sybase_query(): %d is not a valid Sybase-Link resource in %s on line %d
-bool(false)
diff --git a/ext/sybase_ct/tests/test_close_default.phpt b/ext/sybase_ct/tests/test_close_default.phpt
deleted file mode 100644
index a726a4747b..0000000000
--- a/ext/sybase_ct/tests/test_close_default.phpt
+++ /dev/null
@@ -1,21 +0,0 @@
---TEST--
-Sybase-CT close default connection
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- sybase_connect_ex();
- sybase_close();
- var_dump(sybase_query('select getdate()'));
-?>
---EXPECTF--
-
-Warning: sybase_query(): Sybase: No connection in %s on line %d
-bool(false)
diff --git a/ext/sybase_ct/tests/test_close_notopen.phpt b/ext/sybase_ct/tests/test_close_notopen.phpt
deleted file mode 100644
index 13b4571bc9..0000000000
--- a/ext/sybase_ct/tests/test_close_notopen.phpt
+++ /dev/null
@@ -1,18 +0,0 @@
---TEST--
-Sybase-CT close not open
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- sybase_close();
-?>
---EXPECTF--
-
-Warning: sybase_close(): Sybase: No connection to close in %s on line %d
diff --git a/ext/sybase_ct/tests/test_connect.phpt b/ext/sybase_ct/tests/test_connect.phpt
deleted file mode 100644
index e1e3eead38..0000000000
--- a/ext/sybase_ct/tests/test_connect.phpt
+++ /dev/null
@@ -1,19 +0,0 @@
---TEST--
-Sybase-CT connectivity
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
- var_dump($db);
- sybase_close($db);
-?>
---EXPECTF--
-resource(%d) of type (sybase-ct link)
diff --git a/ext/sybase_ct/tests/test_connection_caching.phpt b/ext/sybase_ct/tests/test_connection_caching.phpt
deleted file mode 100644
index d59aedebf6..0000000000
--- a/ext/sybase_ct/tests/test_connection_caching.phpt
+++ /dev/null
@@ -1,26 +0,0 @@
---TEST--
-Sybase-CT connection caching
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db1= sybase_connect_ex();
- $db2= sybase_connect_ex();
- $db3= sybase_connect_ex(NULL, NULL, $new= TRUE);
- var_dump($db1, $db2, $db3, (string)$db1 == (string)$db2, (string)$db2 == (string)$db3);
- sybase_close($db1);
-
-?>
---EXPECTF--
-resource(%d) of type (sybase-ct link)
-resource(%d) of type (sybase-ct link)
-resource(%d) of type (sybase-ct link)
-bool(true)
-bool(false)
diff --git a/ext/sybase_ct/tests/test_connectionbased_msghandler.phpt b/ext/sybase_ct/tests/test_connectionbased_msghandler.phpt
deleted file mode 100644
index 72e6b3a8dc..0000000000
--- a/ext/sybase_ct/tests/test_connectionbased_msghandler.phpt
+++ /dev/null
@@ -1,27 +0,0 @@
---TEST--
-Sybase-CT connection-based server message handler
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
- var_dump($db);
- var_dump(sybase_set_message_handler('sybase_msg_handler', $db));
- var_dump(sybase_select_ex($db, 'select getdate(NULL)'));
- sybase_close($db);
-?>
---EXPECTF--
-resource(%d) of type (sybase-ct link)
-bool(true)
->>> Query: select getdate(NULL)
-*** Caught Sybase Server Message #%d [Severity %d, state %d] at line %d
- %s
-<<< Return: boolean
-bool(false)
diff --git a/ext/sybase_ct/tests/test_fetch_object.phpt b/ext/sybase_ct/tests/test_fetch_object.phpt
deleted file mode 100644
index 2d225cd9cf..0000000000
--- a/ext/sybase_ct/tests/test_fetch_object.phpt
+++ /dev/null
@@ -1,74 +0,0 @@
---TEST--
-Sybase-CT sybase_fetch_object
---SKIPIF--
-<?php
- require('skipif.inc');
-?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- // {{{ class article
- class article { }
- // }}}
-
- // {{{ resource fetch_object(resource db, [mixed arg= NULL])
- // Fetches a resultset and returns it as an object
- function fetch_object($db, $arg= NULL) {
- return sybase_fetch_object(sybase_query('select
- 1 as "id",
- "Hello" as "caption",
- "timm" as "author",
- getdate() as "lastchange"
- ', $db), $arg);
- }
- // }}}
-
- $db= sybase_connect_ex();
-
- // Test with stdClass
- var_export(fetch_object($db)); echo "\n";
-
- // Test with userland class
- var_export(fetch_object($db, 'article')); echo "\n";
-
- // Test with object
- var_export(fetch_object($db, new article())); echo "\n";
-
- // Test with non-existent class
- var_export(fetch_object($db, '***')); echo "\n";
-
- sybase_close($db);
-?>
---EXPECTF--
-stdClass::__set_state(array(
- 'id' => 1,
- 'caption' => 'Hello',
- 'author' => 'timm',
- 'lastchange' => '%s',
-))
-article::__set_state(array(
- 'id' => 1,
- 'caption' => 'Hello',
- 'author' => 'timm',
- 'lastchange' => '%s',
-))
-article::__set_state(array(
- 'id' => 1,
- 'caption' => 'Hello',
- 'author' => 'timm',
- 'lastchange' => '%s',
-))
-
-Notice: sybase_fetch_object(): Sybase: Class *** has not been declared in %stest_fetch_object.php on line %d
-stdClass::__set_state(array(
- 'id' => 1,
- 'caption' => 'Hello',
- 'author' => 'timm',
- 'lastchange' => '%s',
-))
diff --git a/ext/sybase_ct/tests/test_fields.phpt b/ext/sybase_ct/tests/test_fields.phpt
deleted file mode 100644
index 46e932b85d..0000000000
--- a/ext/sybase_ct/tests/test_fields.phpt
+++ /dev/null
@@ -1,76 +0,0 @@
---TEST--
-Sybase-CT sybase_field_* functions
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
-
- // Issue a query
- $q= sybase_unbuffered_query('select
- 1 as "id",
- "Hello" as "caption",
- "timm" as "author",
- getdate() as "lastchange"
- ', $db, FALSE);
- var_dump($q);
-
- var_dump(sybase_num_fields($q));
-
- // Go through each field, dumping it
- while ($field= sybase_fetch_field($q)) {
- var_export($field); echo "\n";
- }
-
- // Seek to the second field and fetch it
- var_dump(sybase_field_seek($q, 1));
- var_export(sybase_fetch_field($q)); echo "\n";
-
- sybase_close($db);
-?>
---EXPECTF--
-resource(%d) of type (sybase-ct result)
-int(4)
-stdClass::__set_state(array(
- 'name' => 'id',
- 'max_length' => 11,
- 'column_source' => '',
- 'numeric' => 1,
- 'type' => 'int',
-))
-stdClass::__set_state(array(
- 'name' => 'caption',
- 'max_length' => 5,
- 'column_source' => '',
- 'numeric' => 0,
- 'type' => 'string',
-))
-stdClass::__set_state(array(
- 'name' => 'author',
- 'max_length' => 4,
- 'column_source' => '',
- 'numeric' => 0,
- 'type' => 'string',
-))
-stdClass::__set_state(array(
- 'name' => 'lastchange',
- 'max_length' => 29,
- 'column_source' => '',
- 'numeric' => 0,
- 'type' => 'datetime',
-))
-bool(true)
-stdClass::__set_state(array(
- 'name' => 'caption',
- 'max_length' => 5,
- 'column_source' => '',
- 'numeric' => 0,
- 'type' => 'string',
-))
diff --git a/ext/sybase_ct/tests/test_long.phpt b/ext/sybase_ct/tests/test_long.phpt
deleted file mode 100644
index de59bb93cb..0000000000
--- a/ext/sybase_ct/tests/test_long.phpt
+++ /dev/null
@@ -1,80 +0,0 @@
---TEST--
-Sybase-CT select LONG_MAX / LONG_MIN
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- define('LONG_MAX', is_int(2147483648) ? 9223372036854775807 : 2147483647);
- define('LONG_MIN', -LONG_MAX - 1);
-
- $db= sybase_connect_ex();
- var_dump(sybase_select_db(TEMPDB, $db));
-
- // Create table and insert some values
- var_dump(sybase_query('create table test_long (value numeric(20, 0))'));
- var_dump(sybase_query('insert test_long values ('.(LONG_MAX - 1).')'));
- var_dump(sybase_query('insert test_long values ('.(LONG_MAX).')'));
- var_dump(sybase_query('insert test_long values ('.(LONG_MAX + 1).')'));
- var_dump(sybase_query('insert test_long values ('.(LONG_MIN + 1).')'));
- var_dump(sybase_query('insert test_long values ('.(LONG_MIN).')'));
- var_dump(sybase_query('insert test_long values ('.(LONG_MIN - 1).')'));
-
- // Select values
- var_dump(sybase_select_ex($db, 'select value from test_long'));
-
- // Drop table
- var_dump(sybase_query('drop table test_long'));
-
- sybase_close($db);
-?>
---EXPECTF--
-bool(true)
-bool(true)
-bool(true)
-bool(true)
-bool(true)
-bool(true)
-bool(true)
-bool(true)
->>> Query: select value from test_long
-<<< Return: resource
-array(6) {
- [0]=>
- array(1) {
- ["value"]=>
- int(%s)
- }
- [1]=>
- array(1) {
- ["value"]=>
- int(%s)
- }
- [2]=>
- array(1) {
- ["value"]=>
- float(%s)
- }
- [3]=>
- array(1) {
- ["value"]=>
- int(-%s)
- }
- [4]=>
- array(1) {
- ["value"]=>
- int(-%s)
- }
- [5]=>
- array(1) {
- ["value"]=>
- float(-%s)
- }
-}
-bool(true)
diff --git a/ext/sybase_ct/tests/test_msghandler.phpt b/ext/sybase_ct/tests/test_msghandler.phpt
deleted file mode 100644
index 3189aaac21..0000000000
--- a/ext/sybase_ct/tests/test_msghandler.phpt
+++ /dev/null
@@ -1,43 +0,0 @@
---TEST--
-Sybase-CT server message handler
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
-
- echo 'Nonexistent: '; sybase_set_messagehandler_ex('function_does_not_exist');
- echo 'Static method: '; sybase_set_messagehandler_ex(array('sybase', 'static_handler'));
- echo 'Instance method: '; sybase_set_messagehandler_ex(array(new sybase(), 'handler'));
- echo 'Lambda function: '; sybase_set_messagehandler_ex(create_function('', 'return FALSE;'));
- echo 'Unset: '; sybase_set_messagehandler_ex(NULL);
- echo 'Incorrect type: '; sybase_set_messagehandler_ex(1);
- echo 'Function: '; sybase_set_messagehandler_ex('sybase_msg_handler');
-
- var_dump(sybase_select_ex($db, 'select getdate(NULL)'));
- sybase_close($db);
-?>
---EXPECTF--
-Nonexistent:
-Warning: sybase_set_message_handler() expects parameter 1 to be a valid callback, function 'function_does_not_exist' not found or invalid function name in %stest.inc on line %d
-NULL
-Static method: bool(true)
-Instance method: bool(true)
-Lambda function: bool(true)
-Unset: bool(true)
-Incorrect type:
-Warning: sybase_set_message_handler() expects parameter 1 to be a valid callback, no array or string given in %stest.inc on line %d
-NULL
-Function: bool(true)
->>> Query: select getdate(NULL)
-*** Caught Sybase Server Message #%d [Severity %d, state %d] at line %d
- %s
-<<< Return: boolean
-bool(false)
diff --git a/ext/sybase_ct/tests/test_msghandler_handled.phpt b/ext/sybase_ct/tests/test_msghandler_handled.phpt
deleted file mode 100644
index 5952c3b00b..0000000000
--- a/ext/sybase_ct/tests/test_msghandler_handled.phpt
+++ /dev/null
@@ -1,69 +0,0 @@
---TEST--
-Sybase-CT server message handler
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- // {{{ bool sybase_msg_handler(int msgnumber, int severity, int state, int line, string text)
- // Handles server messages
- function user_message_handler($msgnumber, $severity, $state, $line, $text) {
- switch ($msgnumber) {
- case 0: // print message
- printf("!!! %s\n", trim($text));
- return;
-
- case 174: // The function 'GETDATE' requires 0 arguments.
- case 11021: // Function GETDATE invoked with wrong number or type of argument(s)
- printf("*** Caught '%s'\n", trim($text));
- return;
- }
- printf("Cannot handle message #%d\n", $msgnumber);
- return FALSE; // Indicate we can't handle this
- }
- // }}}
-
- sybase_set_messagehandler_ex('user_message_handler');
- $db= sybase_connect_ex();
- sybase_min_server_severity(0);
-
- // These are handled
- var_dump(sybase_select_ex($db, 'select getdate(NULL)'));
- var_dump(sybase_select_ex($db, 'print "Hi"'));
-
- // These aren't
- var_dump(sybase_select_ex($db, 'use NULL'));
- var_dump(sybase_select_ex($db, 'select convert(datetime, "notadate")'));
-
- sybase_close($db);
-?>
---EXPECTF--
-bool(true)
->>> Query: select getdate(NULL)
-*** Caught '%s'
-<<< Return: boolean
-bool(false)
->>> Query: print "Hi"
-!!! Hi
-<<< Return: boolean
-bool(true)
->>> Query: use NULL
-Cannot handle message #156
-
-Warning: sybase_query(): Sybase: Server message: Incorrect syntax near the keyword 'NULL'.
- (severity 15, procedure N/A) in %s on line %d
-<<< Return: boolean
-bool(false)
->>> Query: select convert(datetime, "notadate")
-Cannot handle message #249
-
-Warning: sybase_query(): Sybase: Server message: Syntax error during explicit conversion of VARCHAR value 'notadate' to a DATETIME field.
- (severity 16, procedure N/A) in %s on line %d
-<<< Return: boolean
-bool(false)
diff --git a/ext/sybase_ct/tests/test_query_nostore.phpt b/ext/sybase_ct/tests/test_query_nostore.phpt
deleted file mode 100644
index 9d717ec2fd..0000000000
--- a/ext/sybase_ct/tests/test_query_nostore.phpt
+++ /dev/null
@@ -1,98 +0,0 @@
---TEST--
-Sybase-CT query without storing
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
-
- // Create test table and insert some data
- var_dump(sybase_query('
- create table #test (
- id numeric(10, 0) primary key not null,
- caption varchar(255) not null,
- author varchar(50) not null,
- link varchar(255) null,
- lastchange datetime default getdate() null
- )
- ', $db));
- var_dump(sybase_query('insert into #test (
- id, caption, author
- ) values (
- 1, "Hello", "timm"
- )
- ', $db));
- var_dump(sybase_query('insert into #test (
- id, caption, author, link
- ) values (
- 2, "World", "thekid", "http://thekid.de/"
- )
- ', $db));
- var_dump(sybase_query('insert into #test (
- id, caption, author
- ) values (
- 3, "PHP", "friebe"
- )
- ', $db));
-
- // Fetch data
- $q= sybase_unbuffered_query('select * from #test order by id', $db, FALSE);
- var_dump($q);
- while ($row= sybase_fetch_assoc($q)) {
- var_dump($row);
- }
-
- // Clean up and close connection
- var_dump(sybase_query('drop table #test'));
- sybase_close($db);
-?>
---EXPECTF--
-bool(true)
-bool(true)
-bool(true)
-bool(true)
-resource(%d) of type (sybase-ct result)
-array(5) {
- ["id"]=>
- int(1)
- ["caption"]=>
- string(5) "Hello"
- ["author"]=>
- string(4) "timm"
- ["link"]=>
- NULL
- ["lastchange"]=>
- string(%d) "%s"
-}
-array(5) {
- ["id"]=>
- int(2)
- ["caption"]=>
- string(5) "World"
- ["author"]=>
- string(6) "thekid"
- ["link"]=>
- string(17) "http://thekid.de/"
- ["lastchange"]=>
- string(%d) "%s"
-}
-array(5) {
- ["id"]=>
- int(3)
- ["caption"]=>
- string(3) "PHP"
- ["author"]=>
- string(6) "friebe"
- ["link"]=>
- NULL
- ["lastchange"]=>
- string(%d) "%s"
-}
-bool(true)
diff --git a/ext/sybase_ct/tests/test_types.phpt b/ext/sybase_ct/tests/test_types.phpt
deleted file mode 100644
index 735c02d843..0000000000
--- a/ext/sybase_ct/tests/test_types.phpt
+++ /dev/null
@@ -1,87 +0,0 @@
---TEST--
-Sybase-CT select and types
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- define('LONG_MAX', is_int(2147483648) ? 9223372036854775807 : 2147483647);
- define('LONG_MIN', -LONG_MAX - 1);
-
- $db= sybase_connect_ex();
- var_dump(sybase_select_ex($db, 'select
- 1 as "integer",
- '.(LONG_MIN).' as "integer_min",
- '.(LONG_MIN - 1).' as "integer_min_exceed",
- '.(LONG_MAX).' as "integer_max",
- '.(LONG_MAX + 1).' as "integer_max_exceed",
- 1.0 as "float",
- 12345678901234567890123456789012.123456 as "large_float",
- $22.36 as "money",
- "Binford" as "string",
- convert(datetime, "2004-01-23") as "date",
- NULL as "null",
- convert(bit, 1) as "bit",
- convert(smalldatetime, "2004-01-23") as "smalldate",
- convert(char(10), "char") as "char10"
- '));
-
- sybase_close($db);
-?>
---EXPECTF--
->>> Query: select
- 1 as "integer",
- -%s as "integer_min",
- -%s as "integer_min_exceed",
- %s as "integer_max",
- %s as "integer_max_exceed",
- 1.0 as "float",
- 12345678901234567890123456789012.123456 as "large_float",
- $22.36 as "money",
- "Binford" as "string",
- convert(datetime, "2004-01-23") as "date",
- NULL as "null",
- convert(bit, 1) as "bit",
- convert(smalldatetime, "2004-01-23") as "smalldate",
- convert(char(10), "char") as "char10"
-
-<<< Return: resource
-array(1) {
- [0]=>
- array(%d) {
- ["integer"]=>
- int(1)
- ["integer_min"]=>
- int(-%s)
- ["integer_min_exceed"]=>
- float(-%s)
- ["integer_max"]=>
- int(%s)
- ["integer_max_exceed"]=>
- float(%s)
- ["float"]=>
- float(1)
- ["large_float"]=>
- string(39) "12345678901234567890123456789012.123456"
- ["money"]=>
- float(22.36)
- ["string"]=>
- string(7) "Binford"
- ["date"]=>
- string(19) "Jan 23 2004 12:00AM"
- ["null"]=>
- NULL
- ["bit"]=>
- int(1)
- ["smalldate"]=>
- string(19) "Jan 23 2004 12:00AM"
- ["char10"]=>
- string(10) "char "
- }
-}
diff --git a/ext/sybase_ct/tests/test_unbuffered_no_full_fetch.phpt b/ext/sybase_ct/tests/test_unbuffered_no_full_fetch.phpt
deleted file mode 100644
index 5faf8fe4de..0000000000
--- a/ext/sybase_ct/tests/test_unbuffered_no_full_fetch.phpt
+++ /dev/null
@@ -1,44 +0,0 @@
---TEST--
-Sybase-CT unbuffered query without full fetching
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
- var_dump($db);
-
- // Fetch #1
- $q= sybase_unbuffered_query('select name from master..systypes', $db);
- var_dump($q, key(sybase_fetch_assoc($q)));
-
- // Fetch #2 - without having fetched all rows from previous query
- $q= sybase_unbuffered_query('select name from master..systypes', $db);
- var_dump($q, key(sybase_fetch_assoc($q)));
-
- // Fetch #3 - free first, without having fetched all rows from previous query
- sybase_free_result($q);
- $q= sybase_unbuffered_query('select name from master..systypes', $db);
- var_dump($q, key(sybase_fetch_assoc($q)));
-
- // Close - without having fetched all rows from previous query
- sybase_close($db);
- echo 'CLOSED';
-?>
---EXPECTF--
-resource(%d) of type (sybase-ct link)
-resource(%d) of type (sybase-ct result)
-string(4) "name"
-
-Notice: sybase_unbuffered_query(): Sybase: Called without first fetching all rows from a previous unbuffered query in %s on line %d
-resource(%d) of type (sybase-ct result)
-string(4) "name"
-resource(%d) of type (sybase-ct result)
-string(4) "name"
-CLOSED
diff --git a/ext/sybase_ct/tests/test_unbuffered_query.phpt b/ext/sybase_ct/tests/test_unbuffered_query.phpt
deleted file mode 100644
index b2be2f2304..0000000000
--- a/ext/sybase_ct/tests/test_unbuffered_query.phpt
+++ /dev/null
@@ -1,57 +0,0 @@
---TEST--
-Sybase-CT unbuffered query
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
- var_dump($db);
-
- // Test #1: num_rows
- $q= sybase_unbuffered_query('select name from master..systypes', $db);
- var_dump($q);
- $i= 0;
- while ($r= sybase_fetch_assoc($q)) {
- $i++;
- }
- var_dump($i, sybase_num_rows($q), $i == sybase_num_rows($q), $q);
- sybase_free_result($q);
- var_dump($q);
-
- // Test #2: after sybase_free_result, this should be an invalid resource
- var_dump(FALSE == sybase_num_rows($q));
-
- // Test #3: Seeking
- $q= sybase_unbuffered_query('select name from master..systypes', $db);
- var_dump($q);
- $j= 0;
- sybase_data_seek($q, 4);
- while ($r= sybase_fetch_assoc($q)) {
- $j++;
- }
- var_dump($i, $j, $i - $j);
-
- sybase_close($db);
-?>
---EXPECTF--
-resource(%d) of type (sybase-ct link)
-resource(%d) of type (sybase-ct result)
-int(%d)
-int(%d)
-bool(true)
-resource(%d) of type (sybase-ct result)
-resource(%d) of type (Unknown)
-
-Warning: sybase_num_rows(): %d is not a valid Sybase result resource in %stest_unbuffered_query.php on line %d
-bool(true)
-resource(%d) of type (sybase-ct result)
-int(%d)
-int(%d)
-int(4)
diff --git a/php.ini-development b/php.ini-development
index 9cf44fbffd..ffb1b51c73 100644
--- a/php.ini-development
+++ b/php.ini-development
@@ -897,7 +897,6 @@ default_socket_timeout = 60
;extension=php_soap.dll
;extension=php_sockets.dll
;extension=php_sqlite3.dll
-;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
@@ -1323,45 +1322,6 @@ pgsql.ignore_notice = 0
; http://php.net/pgsql.log-notice
pgsql.log_notice = 0
-[Sybase-CT]
-; Allow or prevent persistent links.
-; http://php.net/sybct.allow-persistent
-sybct.allow_persistent = On
-
-; Maximum number of persistent links. -1 means no limit.
-; http://php.net/sybct.max-persistent
-sybct.max_persistent = -1
-
-; Maximum number of links (persistent + non-persistent). -1 means no limit.
-; http://php.net/sybct.max-links
-sybct.max_links = -1
-
-; Minimum server message severity to display.
-; http://php.net/sybct.min-server-severity
-sybct.min_server_severity = 10
-
-; Minimum client message severity to display.
-; http://php.net/sybct.min-client-severity
-sybct.min_client_severity = 10
-
-; Set per-context timeout
-; http://php.net/sybct.timeout
-;sybct.timeout=
-
-;sybct.packet_size
-
-; The maximum time in seconds to wait for a connection attempt to succeed before returning failure.
-; Default: one minute
-;sybct.login_timeout=
-
-; The name of the host you claim to be connecting from, for display by sp_who.
-; Default: none
-;sybct.hostname=
-
-; Allows you to define how often deadlocks are to be retried. -1 means "forever".
-; Default: 0
-;sybct.deadlock_retry_count=
-
[bcmath]
; Number of decimal digits for all bcmath functions.
; http://php.net/bcmath.scale
@@ -1612,58 +1572,6 @@ url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
; http://php.net/session.upload-progress.min-freq
;session.upload_progress.min_freq = "1"
-[MSSQL]
-; Allow or prevent persistent links.
-mssql.allow_persistent = On
-
-; Maximum number of persistent links. -1 means no limit.
-mssql.max_persistent = -1
-
-; Maximum number of links (persistent+non persistent). -1 means no limit.
-mssql.max_links = -1
-
-; Minimum error severity to display.
-mssql.min_error_severity = 10
-
-; Minimum message severity to display.
-mssql.min_message_severity = 10
-
-; Compatibility mode with old versions of PHP 3.0.
-mssql.compatibility_mode = Off
-
-; Connect timeout
-;mssql.connect_timeout = 5
-
-; Query timeout
-;mssql.timeout = 60
-
-; Valid range 0 - 2147483647. Default = 4096.
-;mssql.textlimit = 4096
-
-; Valid range 0 - 2147483647. Default = 4096.
-;mssql.textsize = 4096
-
-; Limits the number of records in each batch. 0 = all records in one batch.
-;mssql.batchsize = 0
-
-; Specify how datetime and datetim4 columns are returned
-; On => Returns data converted to SQL server settings
-; Off => Returns values as YYYY-MM-DD hh:mm:ss
-;mssql.datetimeconvert = On
-
-; Use NT authentication when connecting to the server
-mssql.secure_connection = Off
-
-; Specify max number of processes. -1 = library default
-; msdlib defaults to 25
-; FreeTDS defaults to 4096
-;mssql.max_procs = -1
-
-; Specify client character set.
-; If empty or not set the client charset from freetds.conf is used
-; This is only used when compiled with FreeTDS
-;mssql.charset = "ISO-8859-1"
-
[Assertion]
; Assert(expr); active by default.
; http://php.net/assert.active
diff --git a/php.ini-production b/php.ini-production
index 2c3fa4d307..3ff9ac5a61 100644
--- a/php.ini-production
+++ b/php.ini-production
@@ -897,7 +897,6 @@ default_socket_timeout = 60
;extension=php_soap.dll
;extension=php_sockets.dll
;extension=php_sqlite3.dll
-;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
@@ -1323,45 +1322,6 @@ pgsql.ignore_notice = 0
; http://php.net/pgsql.log-notice
pgsql.log_notice = 0
-[Sybase-CT]
-; Allow or prevent persistent links.
-; http://php.net/sybct.allow-persistent
-sybct.allow_persistent = On
-
-; Maximum number of persistent links. -1 means no limit.
-; http://php.net/sybct.max-persistent
-sybct.max_persistent = -1
-
-; Maximum number of links (persistent + non-persistent). -1 means no limit.
-; http://php.net/sybct.max-links
-sybct.max_links = -1
-
-; Minimum server message severity to display.
-; http://php.net/sybct.min-server-severity
-sybct.min_server_severity = 10
-
-; Minimum client message severity to display.
-; http://php.net/sybct.min-client-severity
-sybct.min_client_severity = 10
-
-; Set per-context timeout
-; http://php.net/sybct.timeout
-;sybct.timeout=
-
-;sybct.packet_size
-
-; The maximum time in seconds to wait for a connection attempt to succeed before returning failure.
-; Default: one minute
-;sybct.login_timeout=
-
-; The name of the host you claim to be connecting from, for display by sp_who.
-; Default: none
-;sybct.hostname=
-
-; Allows you to define how often deadlocks are to be retried. -1 means "forever".
-; Default: 0
-;sybct.deadlock_retry_count=
-
[bcmath]
; Number of decimal digits for all bcmath functions.
; http://php.net/bcmath.scale
@@ -1612,58 +1572,6 @@ url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
; http://php.net/session.upload-progress.min-freq
;session.upload_progress.min_freq = "1"
-[MSSQL]
-; Allow or prevent persistent links.
-mssql.allow_persistent = On
-
-; Maximum number of persistent links. -1 means no limit.
-mssql.max_persistent = -1
-
-; Maximum number of links (persistent+non persistent). -1 means no limit.
-mssql.max_links = -1
-
-; Minimum error severity to display.
-mssql.min_error_severity = 10
-
-; Minimum message severity to display.
-mssql.min_message_severity = 10
-
-; Compatibility mode with old versions of PHP 3.0.
-mssql.compatibility_mode = Off
-
-; Connect timeout
-;mssql.connect_timeout = 5
-
-; Query timeout
-;mssql.timeout = 60
-
-; Valid range 0 - 2147483647. Default = 4096.
-;mssql.textlimit = 4096
-
-; Valid range 0 - 2147483647. Default = 4096.
-;mssql.textsize = 4096
-
-; Limits the number of records in each batch. 0 = all records in one batch.
-;mssql.batchsize = 0
-
-; Specify how datetime and datetim4 columns are returned
-; On => Returns data converted to SQL server settings
-; Off => Returns values as YYYY-MM-DD hh:mm:ss
-;mssql.datetimeconvert = On
-
-; Use NT authentication when connecting to the server
-mssql.secure_connection = Off
-
-; Specify max number of processes. -1 = library default
-; msdlib defaults to 25
-; FreeTDS defaults to 4096
-;mssql.max_procs = -1
-
-; Specify client character set.
-; If empty or not set the client charset from freetds.conf is used
-; This is only used when compiled with FreeTDS
-;mssql.charset = "ISO-8859-1"
-
[Assertion]
; Assert(expr); active by default.
; http://php.net/assert.active
diff --git a/sapi/aolserver/CREDITS b/sapi/aolserver/CREDITS
deleted file mode 100644
index 8f9a4af950..0000000000
--- a/sapi/aolserver/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-AOLserver
-Sascha Schumann
diff --git a/sapi/aolserver/README b/sapi/aolserver/README
deleted file mode 100644
index 86af6a54b3..0000000000
--- a/sapi/aolserver/README
+++ /dev/null
@@ -1,69 +0,0 @@
-AOLserver README ($Id$)
-
-To compile PHP 4.0 as a module for AOLserver, you need:
-
-- installed AOLserver 3.1 or later
- (see the note below for AOLserver 3.0)
-
-NOTE: You should not use this module in production. PHP is not 100% stable
- yet in threaded mode. To increase reliability enable the Global Lock
- by removing #define NO_GLOBAL_LOCK in main/main.c. Also don't use
- php_value as it will lead to races in a sub-system (use an ini file
- instead).
-
-
-1.) Configuring AOLserver
-
-Read doc/install.txt in the source distribution
-
-It usually boils down to changing the INST/PREFIX variable in
-include/Makefile.global and running make all install.
-
-2.) Configuring PHP
-
-$ ./configure \
- --with-aolserver=/path/to/installed/aolserver \
- <other options>
-
-NOTE: If you are still using AOLserver 3.0, you need to retain the
- AOLserver source code and pass another option to PHP:
-
- --with-aolserver-src=/path/to/source/distribution
-
-3.) Compiling and Installing PHP
-
-$ make install
-
-4.) Changing nsd.tcl
-
-a) New section
-
-Add a new section to pass options to PHP (required):
-
-ns_section "ns/server/${servername}/module/php"
-
-You can use the following commands in this section:
-
-The 'map' command will cause AOLserver to pass all requests to *.php to
-the PHP module (can be specified multiple times). Example:
-
-ns_param map *.php
-
-The 'php_value "name val"' command assigns the configuration option name
-the value val (can be used multiple times). Example:
-
-ns_param php_value "session.auto_start 1"
-
-b) Enabling PHP
-
-Then enable the PHP module:
-
-ns_section "ns/server/${servername}/modules"
-...
-ns_param php ${bindir}/libphp7.so
-
-
-=============================================================================
-This has been tested with AOLserver release 3.0.
-
-AOLserver support has been written by Sascha Schumann <sascha@schumann.cx>.
diff --git a/sapi/aolserver/aolserver.c b/sapi/aolserver/aolserver.c
deleted file mode 100644
index 4b6c5868b0..0000000000
--- a/sapi/aolserver/aolserver.c
+++ /dev/null
@@ -1,624 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.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> |
- +----------------------------------------------------------------------+
- */
-
-/*
- * TODO:
- * - write documentation
- * - CGI/1.1 conformance
- */
-
-/* $Id$ */
-
-/* conflict between PHP and AOLserver headers */
-#define Debug php_Debug
-#include "php.h"
-#undef Debug
-
-#ifdef HAVE_AOLSERVER
-
-#ifndef ZTS
-#error AOLserver module is only useable in thread-safe mode
-#endif
-
-#include "ext/standard/info.h"
-#define SECTION(name) PUTS("<h2>" name "</h2>\n")
-
-#define NS_BUF_SIZE 511
-
-#include "php_ini.h"
-#include "php_globals.h"
-#include "SAPI.h"
-#include "php_main.h"
-#include "php_variables.h"
-
-#include "ns.h"
-
-#include "php_version.h"
-
-/* This symbol is used by AOLserver to tell the API version we expect */
-
-int Ns_ModuleVersion = 1;
-
-#define NSG(v) TSRMG(ns_globals_id, ns_globals_struct *, v)
-
-/* php_ns_context is per-server (thus only once at all) */
-
-typedef struct {
- sapi_module_struct *sapi_module;
- char *ns_server;
- char *ns_module;
-} php_ns_context;
-
-/* ns_globals_struct is per-thread */
-
-typedef struct {
- Ns_Conn *conn;
- size_t data_avail;
-} ns_globals_struct;
-
-/* TSRM id */
-
-static int ns_globals_id;
-
-/* global context */
-
-static php_ns_context *global_context;
-
-static void php_ns_config(php_ns_context *ctx, char global);
-
-/*
- * php_ns_sapi_ub_write() writes data to the client connection.
- */
-
-static int
-php_ns_sapi_ub_write(const char *str, uint str_length)
-{
- int n;
- uint sent = 0;
-
- while (str_length > 0) {
- n = Ns_ConnWrite(NSG(conn), (void *) str, str_length);
-
- if (n == -1)
- php_handle_aborted_connection();
-
- str += n;
- sent += n;
- str_length -= n;
- }
-
- return sent;
-}
-
-/*
- * php_ns_sapi_header_handler() sets a HTTP reply header to be
- * sent to the client.
- */
-
-static int
-php_ns_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers)
-{
- char *header_name, *header_content;
- char *p;
-
- header_name = sapi_header->header;
- header_content = p = strchr(header_name, ':');
-
- if (p) {
- *p = '\0';
- do {
- header_content++;
- } while (*header_content == ' ');
-
- if (!strcasecmp(header_name, "Content-type")) {
- Ns_ConnSetTypeHeader(NSG(conn), header_content);
- } else {
- Ns_ConnSetHeaders(NSG(conn), header_name, header_content);
- }
-
- *p = ':';
- }
-
- sapi_free_header(sapi_header);
-
- return 0;
-}
-
-/*
- * php_ns_sapi_send_headers() flushes the headers to the client.
- * Called before real content is sent by PHP.
- */
-
-static int
-php_ns_sapi_send_headers(sapi_headers_struct *sapi_headers)
-{
- if(SG(sapi_headers).send_default_content_type) {
- Ns_ConnSetRequiredHeaders(NSG(conn), "text/html", 0);
- }
-
- Ns_ConnFlushHeaders(NSG(conn), SG(sapi_headers).http_response_code);
-
- return SAPI_HEADER_SENT_SUCCESSFULLY;
-}
-
-/*
- * php_ns_sapi_read_post() reads a specified number of bytes from
- * the client. Used for POST/PUT requests.
- */
-
-static int
-php_ns_sapi_read_post(char *buf, uint count_bytes)
-{
- uint max_read;
- uint total_read = 0;
-
- max_read = MIN(NSG(data_avail), count_bytes);
-
- total_read = Ns_ConnRead(NSG(conn), buf, max_read);
-
- if(total_read == NS_ERROR) {
- total_read = -1;
- } else {
- NSG(data_avail) -= total_read;
- }
-
- return total_read;
-}
-
-/*
- * php_ns_sapi_read_cookies() returns the Cookie header from
- * the HTTP request header
- */
-
-static char *php_ns_sapi_read_cookies(void)
-{
- int i;
- char *http_cookie = NULL;
-
- i = Ns_SetIFind(NSG(conn->headers), "cookie");
- if(i != -1) {
- http_cookie = Ns_SetValue(NSG(conn->headers), i);
- }
-
- return http_cookie;
-}
-
-static void php_info_aolserver(ZEND_MODULE_INFO_FUNC_ARGS)
-{
- char buf[512];
- int uptime = Ns_InfoUptime();
- int i;
-
- php_info_print_table_start();
- php_info_print_table_row(2, "SAPI module version", "$Id$");
- php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
- php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
- php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
- php_info_print_table_row(2, "Installation path", Ns_InfoHomePath());
- php_info_print_table_row(2, "Hostname of server", Ns_InfoHostname());
- php_info_print_table_row(2, "Source code label", Ns_InfoLabel());
- php_info_print_table_row(2, "Server platform", Ns_InfoPlatform());
- snprintf(buf, 511, "%s/%s", Ns_InfoServerName(), Ns_InfoServerVersion());
- php_info_print_table_row(2, "Server version", buf);
- snprintf(buf, 511, "%d day(s), %02d:%02d:%02d",
- uptime / 86400,
- (uptime / 3600) % 24,
- (uptime / 60) % 60,
- uptime % 60);
- php_info_print_table_row(2, "Server uptime", buf);
- php_info_print_table_end();
-
- SECTION("HTTP Headers Information");
- php_info_print_table_start();
- php_info_print_table_colspan_header(2, "HTTP Request Headers");
- php_info_print_table_row(2, "HTTP Request", NSG(conn)->request->line);
- for (i = 0; i < Ns_SetSize(NSG(conn)->headers); i++) {
- php_info_print_table_row(2, Ns_SetKey(NSG(conn)->headers, i), Ns_SetValue(NSG(conn)->headers, i));
- }
-
- php_info_print_table_colspan_header(2, "HTTP Response Headers");
- for (i = 0; i < Ns_SetSize(NSG(conn)->outputheaders); i++) {
- php_info_print_table_row(2, Ns_SetKey(NSG(conn)->outputheaders, i), Ns_SetValue(NSG(conn)->outputheaders, i));
- }
- php_info_print_table_end();
-}
-
-PHP_FUNCTION(getallheaders);
-
-/* {{{ arginfo */
-ZEND_BEGIN_ARG_INFO(arginfo_aolserver_getallheaders, 0)
-ZEND_END_ARG_INFO()
-/* }}} */
-
-static const zend_function_entry aolserver_functions[] = {
- PHP_FE(getallheaders, arginfo_aolserver_getallheaders)
- {NULL, NULL, NULL}
-};
-
-static zend_module_entry php_aolserver_module = {
- STANDARD_MODULE_HEADER,
- "AOLserver",
- aolserver_functions,
- NULL,
- NULL,
- NULL,
- NULL,
- php_info_aolserver,
- NULL,
- STANDARD_MODULE_PROPERTIES
-};
-
-PHP_FUNCTION(getallheaders)
-{
- int i;
-
- array_init(return_value);
-
- for (i = 0; i < Ns_SetSize(NSG(conn->headers)); i++) {
- char *key = Ns_SetKey(NSG(conn->headers), i);
- char *value = Ns_SetValue(NSG(conn->headers), i);
-
- add_assoc_string(return_value, key, value);
- }
-}
-
-static int
-php_ns_startup(sapi_module_struct *sapi_module)
-{
- if (php_module_startup(sapi_module, &php_aolserver_module, 1) == FAILURE) {
- return FAILURE;
- } else {
- return SUCCESS;
- }
-}
-
-
-/*
- * php_ns_sapi_register_variables() populates the php script environment
- * with a number of variables. HTTP_* variables are created for
- * the HTTP header data, so that a script can access these.
- */
-
-#define ADD_STRINGX(name, buf) \
- php_register_variable(name, buf, track_vars_array)
-
-#define ADD_STRING(name) \
- ADD_STRINGX(name, buf)
-
-static void
-php_ns_sapi_register_variables(zval *track_vars_array)
-{
- int i;
- char buf[NS_BUF_SIZE + 1];
- char *tmp;
-
- for(i = 0; i < Ns_SetSize(NSG(conn->headers)); i++) {
- char *key = Ns_SetKey(NSG(conn->headers), i);
- char *value = Ns_SetValue(NSG(conn->headers), i);
- char *p;
- char c;
-
- snprintf(buf, NS_BUF_SIZE, "HTTP_%s", key);
-
- for(p = buf + 5; (c = *p); p++) {
- c = toupper(c);
- if(c < 'A' || c > 'Z') {
- c = '_';
- }
- *p = c;
- }
-
- ADD_STRINGX(buf, value);
- }
-
- snprintf(buf, NS_BUF_SIZE, "%s/%s", Ns_InfoServerName(), Ns_InfoServerVersion());
- ADD_STRING("SERVER_SOFTWARE");
- snprintf(buf, NS_BUF_SIZE, "HTTP/%1.1f", NSG(conn)->request->version);
- ADD_STRING("SERVER_PROTOCOL");
-
- ADD_STRINGX("REQUEST_METHOD", NSG(conn)->request->method);
-
- if(NSG(conn)->request->query)
- ADD_STRINGX("QUERY_STRING", NSG(conn)->request->query);
-
- ADD_STRINGX("SERVER_BUILDDATE", Ns_InfoBuildDate());
-
- ADD_STRINGX("REMOTE_ADDR", Ns_ConnPeer(NSG(conn)));
-
- snprintf(buf, NS_BUF_SIZE, "%d", Ns_ConnPeerPort(NSG(conn)));
- ADD_STRING("REMOTE_PORT");
-
- snprintf(buf, NS_BUF_SIZE, "%d", Ns_ConnPort(NSG(conn)));
- ADD_STRING("SERVER_PORT");
-
- tmp = Ns_ConnHost(NSG(conn));
- if (tmp)
- ADD_STRINGX("SERVER_NAME", tmp);
-
- ADD_STRINGX("PATH_TRANSLATED", SG(request_info).path_translated);
- ADD_STRINGX("REQUEST_URI", SG(request_info).request_uri);
- ADD_STRINGX("PHP_SELF", SG(request_info).request_uri);
-
- ADD_STRINGX("GATEWAY_INTERFACE", "CGI/1.1");
-
- snprintf(buf, NS_BUF_SIZE, "%d", Ns_InfoBootTime());
- ADD_STRING("SERVER_BOOTTIME");
-}
-
-
-
-/* this structure is static (as in "it does not change") */
-
-static sapi_module_struct aolserver_sapi_module = {
- "aolserver",
- "AOLserver",
-
- php_ns_startup, /* startup */
- php_module_shutdown_wrapper, /* shutdown */
-
- NULL, /* activate */
- NULL, /* deactivate */
-
- php_ns_sapi_ub_write, /* unbuffered write */
- NULL, /* flush */
- NULL, /* get uid */
- NULL, /* getenv */
-
- php_error, /* error handler */
-
- php_ns_sapi_header_handler, /* header handler */
- php_ns_sapi_send_headers, /* send headers handler */
- NULL, /* send header handler */
-
- php_ns_sapi_read_post, /* read POST data */
- php_ns_sapi_read_cookies, /* read Cookies */
-
- php_ns_sapi_register_variables,
- NULL, /* Log message */
- NULL, /* Get request time */
- NULL, /* child terminate */
-
- STANDARD_SAPI_MODULE_PROPERTIES
-};
-
-/*
- * php_ns_module_main() is called by the per-request handler and
- * "executes" the script
- */
-
-static int
-php_ns_module_main(void)
-{
- zend_file_handle file_handle;
-
- file_handle.type = ZEND_HANDLE_FILENAME;
- file_handle.filename = SG(request_info).path_translated;
- file_handle.free_filename = 0;
- file_handle.opened_path = NULL;
-
- php_ns_config(global_context, 0);
- if (php_request_startup() == FAILURE) {
- return NS_ERROR;
- }
-
- php_execute_script(&file_handle);
- php_request_shutdown(NULL);
-
- return NS_OK;
-}
-
-/*
- * php_ns_request_ctor() initializes the per-request data structure
- * and fills it with data provided by the web server
- */
-
-static void
-php_ns_request_ctor(void)
-{
- char *server;
- Ns_DString ds;
- char *root;
- int index;
- char *tmp;
-
- server = Ns_ConnServer(NSG(conn));
-
-#define safe_strdup(x) ((x)?strdup((x)):NULL)
- SG(request_info).query_string = safe_strdup(NSG(conn->request->query));
-
- Ns_DStringInit(&ds);
- Ns_UrlToFile(&ds, server, NSG(conn->request->url));
-
- /* path_translated is the absolute path to the file */
- SG(request_info).path_translated = safe_strdup(Ns_DStringValue(&ds));
- Ns_DStringFree(&ds);
- root = Ns_PageRoot(server);
- SG(request_info).request_uri = strdup(SG(request_info).path_translated + strlen(root));
- SG(request_info).request_method = NSG(conn)->request->method;
- if(NSG(conn)->request->version > 1.0) SG(request_info).proto_num = 1001;
- else SG(request_info).proto_num = 1000;
- SG(request_info).content_length = Ns_ConnContentLength(NSG(conn));
- index = Ns_SetIFind(NSG(conn)->headers, "content-type");
- SG(request_info).content_type = index == -1 ? NULL :
- Ns_SetValue(NSG(conn)->headers, index);
- SG(sapi_headers).http_response_code = 200;
-
- tmp = Ns_ConnAuthUser(NSG(conn));
- if (tmp)
- tmp = estrdup(tmp);
- SG(request_info).auth_user = tmp;
-
- tmp = Ns_ConnAuthPasswd(NSG(conn));
- if (tmp)
- tmp = estrdup(tmp);
- SG(request_info).auth_password = tmp;
-
- NSG(data_avail) = SG(request_info).content_length;
-}
-
-/*
- * php_ns_request_dtor() destroys all data associated with
- * the per-request structure
- */
-
-static void
-php_ns_request_dtor(void)
-{
- free(SG(request_info).path_translated);
- if (SG(request_info).query_string)
- free(SG(request_info).query_string);
- free(SG(request_info).request_uri);
-}
-
-/*
- * The php_ns_request_handler() is called per request and handles
- * everything for one request.
- */
-
-static int
-php_ns_request_handler(void *context, Ns_Conn *conn)
-{
- int status = NS_OK;
-
- NSG(conn) = conn;
-
- SG(server_context) = global_context;
-
- php_ns_request_ctor();
-
- status = php_ns_module_main();
-
- php_ns_request_dtor();
-
- return status;
-}
-
-/*
- * php_ns_config() fetches the configuration data.
- *
- * It understands the "map" and "php_value" command.
- */
-
-static void
-php_ns_config(php_ns_context *ctx, char global)
-{
- int i;
- char *path;
- Ns_Set *set;
-
- path = Ns_ConfigGetPath(ctx->ns_server, ctx->ns_module, NULL);
- set = Ns_ConfigGetSection(path);
-
- for (i = 0; set && i < Ns_SetSize(set); i++) {
- char *key = Ns_SetKey(set, i);
- char *value = Ns_SetValue(set, i);
-
- if (global && !strcasecmp(key, "map")) {
- Ns_Log(Notice, "Registering PHP for \"%s\"", value);
- Ns_RegisterRequest(ctx->ns_server, "GET", value, php_ns_request_handler, NULL, ctx, 0);
- Ns_RegisterRequest(ctx->ns_server, "POST", value, php_ns_request_handler, NULL, ctx, 0);
- Ns_RegisterRequest(ctx->ns_server, "HEAD", value, php_ns_request_handler, NULL, ctx, 0);
-
- /*
- * Deactivated for now. The ini system will cause random crashes when
- * accessed from here (since there are no locks to protect the global
- * known_directives)
- */
-
- } else if (!global && !strcasecmp(key, "php_value")) {
- Ns_Log(Notice, "php_value has been deactivated temporarily. Please use a php.ini file to pass directives to PHP. Thanks.");
-#if 0
- char *val;
-
- val = strchr(value, ' ');
- if (val) {
- char *new_key;
-
- new_key = estrndup(value, val - value);
-
- do {
- val++;
- } while(*val == ' ');
-
- Ns_Log(Debug, "PHP configuration option '%s=%s'", new_key, val);
- zend_alter_ini_entry(new_key, strlen(new_key) + 1, val,
- strlen(val) + 1, PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
-
- efree(new_key);
- }
-#endif
- }
-
- }
-}
-
-/*
- * php_ns_server_shutdown() performs the last steps before the
- * server exits. Shutdowns basic services and frees memory
- */
-
-static void
-php_ns_server_shutdown(void *context)
-{
- php_ns_context *ctx = (php_ns_context *) context;
-
- ctx->sapi_module->shutdown(ctx->sapi_module);
- sapi_shutdown();
- tsrm_shutdown();
-
- free(ctx->ns_module);
- free(ctx->ns_server);
- free(ctx);
-}
-
-/*
- * Ns_ModuleInit() is called by AOLserver once at startup
- *
- * This functions allocates basic structures and initializes
- * basic services.
- */
-
-int Ns_ModuleInit(char *server, char *module)
-{
- php_ns_context *ctx;
-
- tsrm_startup(1, 1, 0, NULL);
- sapi_startup(&aolserver_sapi_module);
- sapi_module.startup(&aolserver_sapi_module);
-
- /* TSRM is used to allocate a per-thread structure */
- ts_allocate_id(&ns_globals_id, sizeof(ns_globals_struct), NULL, NULL);
-
- /* the context contains data valid for all threads */
- ctx = malloc(sizeof *ctx);
- ctx->sapi_module = &aolserver_sapi_module;
- ctx->ns_server = strdup(server);
- ctx->ns_module = strdup(module);
-
- /* read the configuration */
- php_ns_config(ctx, 1);
-
- global_context = ctx;
-
- /* register shutdown handler */
- Ns_RegisterServerShutdown(server, php_ns_server_shutdown, ctx);
-
- return NS_OK;
-}
-
-#endif
diff --git a/sapi/aolserver/config.m4 b/sapi/aolserver/config.m4
deleted file mode 100644
index a193bfd058..0000000000
--- a/sapi/aolserver/config.m4
+++ /dev/null
@@ -1,31 +0,0 @@
-dnl
-dnl $Id$
-dnl
-
-PHP_ARG_WITH(aolserver,,
-[ --with-aolserver=DIR Specify path to the installed AOLserver], no, no)
-
-AC_MSG_CHECKING([for AOLserver support])
-
-if test "$PHP_AOLSERVER" != "no"; then
- if test -d "$PHP_AOLSERVER/include"; then
- PHP_AOLSERVER_SRC=$PHP_AOLSERVER
- fi
- if test -z "$PHP_AOLSERVER_SRC" || test ! -d $PHP_AOLSERVER_SRC/include; then
- AC_MSG_ERROR(Please specify the path to the source distribution of AOLserver using --with-aolserver-src=DIR)
- fi
- if test ! -d $PHP_AOLSERVER/bin ; then
- AC_MSG_ERROR(Please specify the path to the root of AOLserver using --with-aolserver=DIR)
- fi
- PHP_BUILD_THREAD_SAFE
- PHP_ADD_INCLUDE($PHP_AOLSERVER_SRC/include)
- AC_DEFINE(HAVE_AOLSERVER,1,[Whether you have AOLserver])
- PHP_SELECT_SAPI(aolserver, shared, aolserver.c)
- INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED \$(INSTALL_ROOT)$PHP_AOLSERVER/bin/"
-fi
-
-AC_MSG_RESULT([$PHP_AOLSERVER])
-
-dnl ## Local Variables:
-dnl ## tab-width: 4
-dnl ## End:
diff --git a/sapi/aolserver/config.w32 b/sapi/aolserver/config.w32
deleted file mode 100644
index 75b4361efc..0000000000
--- a/sapi/aolserver/config.w32
+++ /dev/null
@@ -1,16 +0,0 @@
-// vim:ft=javascript
-// $Id$
-
-ARG_WITH('aolserver', 'Build AOLserver support', 'no');
-
-if (PHP_AOLSERVER != "no") {
- if (PHP_ZTS == "no") {
- WARNING("AOLSERVER module requires an --enable-zts build of PHP");
- } else {
- if (CHECK_HEADER_ADD_INCLUDE("ns.h", "CFLAGS_AOLSERVER", PHP_AOLSERVER) && CHECK_LIB("nsd.lib", "aolserver", PHP_AOLSERVER)) {
- SAPI('aolserver', 'aolserver.c', 'php' + PHP_VERSION + 'aolserver.so', '/D XP_WIN32 ');
- } else {
- WARNING("sapi/aolserver not enabled: Could not find libraries/headers");
- }
- }
-}
diff --git a/sapi/aolserver/php.sym b/sapi/aolserver/php.sym
deleted file mode 100644
index b401ffd2b3..0000000000
--- a/sapi/aolserver/php.sym
+++ /dev/null
@@ -1,2 +0,0 @@
-Ns_ModuleVersion
-Ns_ModuleInit
diff --git a/sapi/apache/CREDITS b/sapi/apache/CREDITS
deleted file mode 100644
index 991deb5633..0000000000
--- a/sapi/apache/CREDITS
+++ /dev/null
@@ -1,3 +0,0 @@
-Apache 1.3
-Rasmus Lerdorf, Zeev Suraski, Stig Bakken, David Sklar
-
diff --git a/sapi/apache/apMakefile.libdir b/sapi/apache/apMakefile.libdir
deleted file mode 100644
index 7b5254013a..0000000000
--- a/sapi/apache/apMakefile.libdir
+++ /dev/null
@@ -1,4 +0,0 @@
-This is a place-holder which indicates to Configure that it shouldn't
-provide the default targets when building the Makefile in this directory.
-Instead it'll just prepend all the important variable definitions, and
-copy the Makefile.tmpl onto the end.
diff --git a/sapi/apache/apMakefile.tmpl b/sapi/apache/apMakefile.tmpl
deleted file mode 100644
index c8b174775e..0000000000
--- a/sapi/apache/apMakefile.tmpl
+++ /dev/null
@@ -1,77 +0,0 @@
-##
-## Apache 1.3 Makefile template for PHP 7.0 Module
-## [src/modules/php7/Makefile.tmpl]
-##
-
-# the parametrized target
-LIB=libphp7.$(LIBEXT)
-
-# objects for building the static library
-OBJS=mod_php7.o
-OBJS_LIB=libmodphp7.a
-
-# objects for building the shared object library
-SHLIB_OBJS=mod_php7.so-o
-SHLIB_OBJS_LIB=libmodphp7.a
-
-# the general targets
-all: lib
-lib: $(LIB)
-
-# build the static library by merging the object files
-libphp7.a: $(OBJS) $(OBJS_LIB)
- cp $(OBJS_LIB) $@
- ar r $@ $(OBJS)
- $(RANLIB) $@
-
-# ugly hack to support older Apache-1.3 betas that don't set $LIBEXT
-libphp7.: $(OBJS) $(OBJS_LIB)
- cp $(OBJS_LIB) $@
- ar r $@ $(OBJS)
- $(RANLIB) $@
- cp libphp7. libphp7.a
-
-# build the shared object library by linking the object files
-libphp7.so: $(SHLIB_OBJS) $(SHLIB_OBJS_LIB)
- rm -f $@
- $(LD_SHLIB) $(LDFLAGS_SHLIB) -o $@ $(SHLIB_OBJS) $(SHLIB_OBJS_LIB) $(LIBS) $(PHP_LIBS)
-
-# 1. extension .o for shared objects cannot be used here because
-# first these files aren't still shared objects and second we
-# have to use a different name to trigger the different
-# implicit Make rule
-# 2. extension -so.o (as used elsewhere) cannot be used because
-# the suffix feature of Make really wants just .x, so we use
-# extension .so-o
-.SUFFIXES: .o .so-o
-.c.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(PHP_CFLAGS) $(CPPFLAGS) $(SPACER) $<
-.c.so-o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(CFLAGS_SHLIB) $(PHP_CFLAGS) $(CPPFLAGS) $(SPACER) $< && mv $*.o $*.so-o
-
-# cleanup
-clean:
- -rm -f $(OBJS) $(SHLIB_OBJS) $(LIB)
-
-# We really don't expect end users to use this rule. It works only with
-# gcc, and rebuilds Makefile.tmpl. You have to re-run Configure after
-# using it.
-depend:
- cp Makefile.tmpl Makefile.tmpl.bak \
- && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.tmpl > Makefile.new \
- && gcc -MM $(INCLUDES) $(CFLAGS) $(PHP_CFLAGS) $(CPPFLAGS) *.c >> Makefile.new \
- && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' Makefile.new \
- > Makefile.tmpl \
- && rm Makefile.new
-
-#Dependencies
-
-$(OBJS): Makefile
-
-# DO NOT REMOVE
-mod_php7.o: mod_php7.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \
- $(INCDIR)/buff.h \
- $(INCDIR)/http_config.h \
- $(INCDIR)/http_core.h $(INCDIR)/http_main.h \
- $(INCDIR)/http_protocol.h $(INCDIR)/http_request.h \
- $(INCDIR)/http_log.h $(INCDIR)/util_script.h mod_php7.h
diff --git a/sapi/apache/config.m4 b/sapi/apache/config.m4
deleted file mode 100644
index f5bfde4d68..0000000000
--- a/sapi/apache/config.m4
+++ /dev/null
@@ -1,273 +0,0 @@
-dnl
-dnl $Id$
-dnl
-AC_DEFUN([PHP_APACHE_FD_CHECK], [
-AC_CACHE_CHECK([for member fd in BUFF *],ac_cv_php_fd_in_buff,[
- save=$CPPFLAGS
- if test -n "$APXS_INCLUDEDIR"; then
- CPPFLAGS="$CPPFLAGS -I$APXS_INCLUDEDIR"
- else
- CPPFLAGS="$CPPFLAGS $APACHE_INCLUDE"
- fi
- AC_TRY_COMPILE([#include <httpd.h>],[conn_rec *c; int fd = c->client->fd;],[
- ac_cv_php_fd_in_buff=yes],[ac_cv_php_fd_in_buff=no],[ac_cv_php_fd_in_buff=no])
- CPPFLAGS=$save
-])
-if test "$ac_cv_php_fd_in_buff" = "yes"; then
- AC_DEFINE(PHP_APACHE_HAVE_CLIENT_FD,1,[ ])
-fi
-])
-
-dnl Apache 1.x shared module
-PHP_ARG_WITH(apxs,,
-[ --with-apxs[=FILE] Build shared Apache 1.x module. FILE is the optional
- pathname to the Apache apxs tool [apxs]], no, no)
-
-AC_MSG_CHECKING([for Apache 1.x module support via DSO through APXS])
-
-if test "$PHP_APXS" != "no"; then
- if test "$PHP_APXS" = "yes"; then
- APXS=apxs
- $APXS -q CFLAGS >/dev/null 2>&1
- if test "$?" != "0" && test -x /usr/sbin/apxs; then #SUSE 6.x
- APXS=/usr/sbin/apxs
- fi
- else
- PHP_EXPAND_PATH($PHP_APXS, APXS)
- fi
-
- $APXS -q CFLAGS >/dev/null 2>&1
- if test "$?" != "0"; then
- AC_MSG_RESULT()
- AC_MSG_RESULT()
- AC_MSG_RESULT([Sorry, I was not able to successfully run APXS. Possible reasons:])
- AC_MSG_RESULT()
- AC_MSG_RESULT([1. Perl is not installed;])
- AC_MSG_RESULT([2. Apache was not compiled with DSO support (--enable-module=so);])
- AC_MSG_RESULT([3. 'apxs' is not in your path. Try to use --with-apxs=/path/to/apxs])
- AC_MSG_RESULT([The output of $APXS follows])
- $APXS -q CFLAGS
- AC_MSG_ERROR([Aborting])
- fi
-
- APXS_LDFLAGS="@SYBASE_LFLAGS@ @SYBASE_LIBS@ @SYBASE_CT_LFLAGS@ @SYBASE_CT_LIBS@"
- APXS_INCLUDEDIR=`$APXS -q INCLUDEDIR`
- APXS_CFLAGS=`$APXS -q CFLAGS`
- APXS_HTTPD=`$APXS -q SBINDIR`/`$APXS -q TARGET`
- APACHE_INCLUDE=-I$APXS_INCLUDEDIR
-
- # Test that we're trying to configure with apache 1.x
- PHP_AP_EXTRACT_VERSION($APXS_HTTPD)
- if test "$APACHE_VERSION" -ge 2000000; then
- AC_MSG_ERROR([You have enabled Apache 1.3 support while your server is Apache 2. Please use the appropriate switch --with-apxs2])
- fi
-
- for flag in $APXS_CFLAGS; do
- case $flag in
- -D*) APACHE_CPPFLAGS="$APACHE_CPPFLAGS $flag";;
- esac
- done
-
- case $host_alias in
- *aix*)
- APXS_LIBEXECDIR=`$APXS -q LIBEXECDIR`
- EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-brtl -Wl,-bI:$APXS_LIBEXECDIR/httpd.exp"
- PHP_AIX_LDFLAGS="-Wl,-brtl"
- build_type=shared
- ;;
- *darwin*)
- MH_BUNDLE_FLAGS="-dynamic -twolevel_namespace -bundle -bundle_loader $APXS_HTTPD"
- PHP_SUBST(MH_BUNDLE_FLAGS)
- SAPI_SHARED=libs/libphp7.so
- build_type=bundle
- ;;
- *)
- build_type=shared
- ;;
- esac
-
- PHP_SELECT_SAPI(apache, $build_type, sapi_apache.c mod_php7.c php_apache.c, $APACHE_CPPFLAGS -I$APXS_INCLUDEDIR)
-
- # Test whether apxs support -S option
- $APXS -q -S CFLAGS="$APXS_CFLAGS" CFLAGS >/dev/null 2>&1
-
- if test "$?" != "0"; then
- APACHE_INSTALL="$APXS -i -a -n php7 $SAPI_SHARED" # Old apxs does not have -S option
- else
- APXS_LIBEXECDIR='$(INSTALL_ROOT)'`$APXS -q LIBEXECDIR`
- if test -z `$APXS -q SYSCONFDIR`; then
- APACHE_INSTALL="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
- $APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
- -i -n php7 $SAPI_SHARED"
- else
- APXS_SYSCONFDIR='$(INSTALL_ROOT)'`$APXS -q SYSCONFDIR`
- APACHE_INSTALL="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
- \$(mkinstalldirs) '$APXS_SYSCONFDIR' && \
- $APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
- -S SYSCONFDIR='$APXS_SYSCONFDIR' \
- -i -a -n php7 $SAPI_SHARED"
- fi
- fi
-
- if test -z "`$APXS -q LD_SHLIB`" || test "`$APXS -q LIBEXECDIR`" = "modules"; then
- PHP_APXS_BROKEN=yes
- fi
- STRONGHOLD=
- AC_DEFINE(HAVE_AP_CONFIG_H,1,[ ])
- AC_DEFINE(HAVE_AP_COMPAT_H,1,[ ])
- AC_DEFINE(HAVE_APACHE,1,[ ])
- AC_MSG_RESULT(yes)
-else
- AC_MSG_RESULT(no)
-fi
-
-dnl Apache 1.x static module
-PHP_ARG_WITH(apache,,
-[ --with-apache[=DIR] Build Apache 1.x module. DIR is the top-level Apache
- build directory [/usr/local/apache]], no, no)
-
-AC_MSG_CHECKING([for Apache 1.x module support])
-
-if test "$PHP_SAPI" != "apache" && test "$PHP_APACHE" != "no"; then
-
- if test "$PHP_APACHE" = "yes"; then
- # Apache's default directory
- PHP_APACHE=/usr/local/apache
- fi
-
- APACHE_INSTALL_FILES="\$(srcdir)/sapi/apache/mod_php7.* sapi/apache/libphp7.module"
-
- AC_DEFINE(HAVE_APACHE,1,[ ])
- APACHE_MODULE=yes
- PHP_EXPAND_PATH($PHP_APACHE, PHP_APACHE)
- # For Apache 1.2.x
- if test -f $PHP_APACHE/src/httpd.h; then
- APACHE_INCLUDE=-I$PHP_APACHE/src
- APACHE_TARGET=$PHP_APACHE/src
- PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php7.c php_apache.c, $APACHE_INCLUDE)
- APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_INSTALL_FILES $APACHE_TARGET"
- PHP_LIBS="-L. -lphp3"
- AC_MSG_RESULT([yes - Apache 1.2.x])
- STRONGHOLD=
- if test -f $PHP_APACHE/src/ap_config.h; then
- AC_DEFINE(HAVE_AP_CONFIG_H,1,[ ])
- fi
- # For Apache 2.0.x
- elif test -f $PHP_APACHE/include/httpd.h && test -f $PHP_APACHE/srclib/apr/include/apr_general.h ; then
- AC_MSG_ERROR([Use --with-apxs2 with Apache 2.x!])
- # For Apache 1.3.x
- elif test -f $PHP_APACHE/src/main/httpd.h; then
- APACHE_HAS_REGEX=1
- APACHE_INCLUDE="-I$PHP_APACHE/src/main -I$PHP_APACHE/src/os/unix -I$PHP_APACHE/src/ap"
- APACHE_TARGET=$PHP_APACHE/src/modules/php7
- if test ! -d $APACHE_TARGET; then
- mkdir $APACHE_TARGET
- fi
- PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php7.c php_apache.c, $APACHE_INCLUDE)
- APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp7.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache/apMakefile.libdir $APACHE_TARGET/Makefile.libdir"
- PHP_LIBS="-Lmodules/php7 -L../modules/php7 -L../../modules/php7 -lmodphp7"
- AC_MSG_RESULT([yes - Apache 1.3.x])
- STRONGHOLD=
- if test -f $PHP_APACHE/src/include/ap_config.h; then
- AC_DEFINE(HAVE_AP_CONFIG_H, 1, [ ])
- fi
- if test -f $PHP_APACHE/src/include/ap_compat.h; then
- AC_DEFINE(HAVE_AP_COMPAT_H, 1, [ ])
- if test ! -f $PHP_APACHE/src/include/ap_config_auto.h; then
- AC_MSG_ERROR([Please run Apache\'s configure or src/Configure program once and try again])
- fi
- elif test -f $PHP_APACHE/src/include/compat.h; then
- AC_DEFINE(HAVE_OLD_COMPAT_H, 1, [ ])
- fi
- # Also for Apache 1.3.x
- elif test -f $PHP_APACHE/src/include/httpd.h; then
- APACHE_HAS_REGEX=1
- APACHE_INCLUDE="-I$PHP_APACHE/src/include -I$PHP_APACHE/src/os/unix"
- APACHE_TARGET=$PHP_APACHE/src/modules/php7
- if test ! -d $APACHE_TARGET; then
- mkdir $APACHE_TARGET
- fi
- PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php7.c php_apache.c, $APACHE_INCLUDE)
- PHP_LIBS="-Lmodules/php7 -L../modules/php7 -L../../modules/php7 -lmodphp7"
- APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp7.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache/apMakefile.libdir $APACHE_TARGET/Makefile.libdir"
- AC_MSG_RESULT([yes - Apache 1.3.x])
- STRONGHOLD=
- if test -f $PHP_APACHE/src/include/ap_config.h; then
- AC_DEFINE(HAVE_AP_CONFIG_H, 1, [ ])
- fi
- if test -f $PHP_APACHE/src/include/ap_compat.h; then
- AC_DEFINE(HAVE_AP_COMPAT_H, 1, [ ])
- if test ! -f $PHP_APACHE/src/include/ap_config_auto.h; then
- AC_MSG_ERROR([Please run Apache\'s configure or src/Configure program once and try again])
- fi
- elif test -f $PHP_APACHE/src/include/compat.h; then
- AC_DEFINE(HAVE_OLD_COMPAT_H, 1, [ ])
- fi
- # For StrongHold 2.2
- elif test -f $PHP_APACHE/apache/httpd.h; then
- APACHE_INCLUDE="-I$PHP_APACHE/apache -I$PHP_APACHE/ssl/include"
- APACHE_TARGET=$PHP_APACHE/apache
- PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php7.c php_apache.c, $APACHE_INCLUDE)
- PHP_LIBS="-Lmodules/php7 -L../modules/php7 -L../../modules/php7 -lmodphp7"
- APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp7.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET"
- STRONGHOLD=-DSTRONGHOLD=1
- AC_MSG_RESULT([yes - StrongHold])
- if test -f $PHP_APACHE/apache/ap_config.h; then
- AC_DEFINE(HAVE_AP_CONFIG_H, 1, [ ])
- fi
- if test -f $PHP_APACHE/src/ap_compat.h; then
- AC_DEFINE(HAVE_AP_COMPAT_H, 1, [ ])
- if test ! -f $PHP_APACHE/src/include/ap_config_auto.h; then
- AC_MSG_ERROR([Please run Apache\'s configure or src/Configure program once and try again])
- fi
- elif test -f $PHP_APACHE/src/compat.h; then
- AC_DEFINE(HAVE_OLD_COMPAT_H, 1, [ ])
- fi
- else
- AC_MSG_RESULT(no)
- AC_MSG_ERROR([Invalid Apache directory - unable to find httpd.h under $PHP_APACHE])
- fi
-else
- AC_MSG_RESULT(no)
-fi
-
-# compatibility
-if test -z "$enable_mod_charset" && test "$with_mod_charset"; then
- enable_mod_charset=$with_mod_charset
-fi
-
-PHP_ARG_ENABLE(mod-charset, whether to enable Apache charset compatibility option,
-[ --enable-mod-charset APACHE: Enable transfer tables for mod_charset (Rus Apache)], no, no)
-
-if test "$PHP_MOD_CHARSET" = "yes"; then
- AC_DEFINE(USE_TRANSFER_TABLES, 1, [ ])
-fi
-
-dnl Build as static module
-if test "$APACHE_MODULE" = "yes"; then
- PHP_TARGET_RDYNAMIC
- $php_shtool mkdir -p sapi/apache
- PHP_OUTPUT(sapi/apache/libphp7.module)
-fi
-
-dnl General
-if test -n "$APACHE_INSTALL"; then
- if test "x$APXS" != "x" -a "`uname -sv`" = "AIX 4" -a "$GCC" != "yes"; then
- APXS_EXP=-bE:sapi/apache/mod_php7.exp
- fi
-
- PHP_APACHE_FD_CHECK
- INSTALL_IT=$APACHE_INSTALL
-
- PHP_SUBST(APXS_EXP)
- PHP_SUBST(APACHE_INCLUDE)
- PHP_SUBST(APACHE_TARGET)
- PHP_SUBST(APXS)
- PHP_SUBST(APXS_LDFLAGS)
- PHP_SUBST(APACHE_INSTALL)
- PHP_SUBST(STRONGHOLD)
-fi
-
-dnl ## Local Variables:
-dnl ## tab-width: 4
-dnl ## End:
diff --git a/sapi/apache/config.w32 b/sapi/apache/config.w32
deleted file mode 100644
index e5b72f1bcf..0000000000
--- a/sapi/apache/config.w32
+++ /dev/null
@@ -1,24 +0,0 @@
-// vim:ft=javascript
-// $Id$
-
-ARG_ENABLE('apache', 'Build Apache 1.3.x version of PHP', 'no');
-
-ARG_WITH('apache-includes', 'Where to find Apache 1.3 headers', null);
-ARG_WITH('apache-libs', 'Where to find Apache 1.3 libraries', null);
-
-if (PHP_APACHE != "no") {
- if (CHECK_HEADER_ADD_INCLUDE("httpd.h", "CFLAGS_APACHE", php_usual_include_suspects +
- ";" + PROGRAM_FILES + "\\Apache Group\\Apache\\include" +
- ";" + PHP_PHP_BUILD + "\\apache\\src\\include") &&
- CHECK_LIB("ApacheCore.lib", "apache", php_usual_lib_suspects +
- ';' + PROGRAM_FILES + '\\Apache Group\\Apache\\libexec' +
- ";" + PHP_PHP_BUILD + "\\apache\\src\\corer")) {
- // We need to play tricks to get our readdir.h used by apache
- // headers
- SAPI('apache', 'mod_php7.c sapi_apache.c php_apache.c',
- 'php' + PHP_VERSION + 'apache.dll',
- '/D APACHEPHP7_EXPORTS /D APACHE_READDIR_H /I win32');
- } else {
- WARNING("Could not find apache libraries/headers");
- }
-}
diff --git a/sapi/apache/libphp7.module.in b/sapi/apache/libphp7.module.in
deleted file mode 100644
index 892df4d5cc..0000000000
--- a/sapi/apache/libphp7.module.in
+++ /dev/null
@@ -1,11 +0,0 @@
-Name: php7_module
-ConfigStart
- RULE_WANTHSREGEX=no
- RULE_HIDE=yes
- PHP_LIBS="@NATIVE_RPATHS@ @PHP_LDFLAGS@ @PHP_LIBS@ @EXTRA_LDFLAGS@ @EXTRA_LIBS@ $LIBS"
- PHP_CFLAGS="$CFLAGS @OPENSSL_INCDIR_OPT@ -I@php_abs_top_builddir@/main -I@php_abs_top_builddir@/Zend -I@php_abs_top_builddir@/TSRM -I@php_abs_top_srcdir@ -I@php_abs_top_srcdir@/sapi/apache -I@php_abs_top_srcdir@/main -I@php_abs_top_srcdir@/Zend -I@php_abs_top_srcdir@/TSRM"
- my_outfile="Makefile.config"
- echo "PHP_CFLAGS=$PHP_CFLAGS" >>$my_outfile
- echo "PHP_LIBS=$PHP_LIBS" >>$my_outfile
- LIBS=$PHP_LIBS
-ConfigEnd
diff --git a/sapi/apache/libpre.c b/sapi/apache/libpre.c
deleted file mode 100644
index 94385dbbd1..0000000000
--- a/sapi/apache/libpre.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.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: |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifdef NETWARE
-
-/* ------------------------------------------------------------------
- * These functions are to be called when the shared NLM starts and
- * stops. By using these functions instead of defining a main()
- * and calling ExitThread(TSR_THREAD, 0), the load time of the
- * shared NLM is faster and memory size reduced.
- *
- * You may also want to override these in your own Apache module
- * to do any cleanup other than the mechanism Apache modules provide.
- * ------------------------------------------------------------------
- */
-
-
-#ifdef __GNUC__
-#include <string.h> /* memset */
-extern char _edata, _end ; /* end of DATA (start of BSS), end of BSS */
-#endif
-
-int _lib_start()
-{
-/* printf("Inside _lib_start\n");*/
-#ifdef __GNUC__
- memset (&_edata, 0, &_end - &_edata);
-#endif
- return 0;
-}
-
-int _lib_stop()
-{
-/* printf("Inside _lib_stop\n");*/
- return 0;
-}
-
-#endif /* NETWARE */
diff --git a/sapi/apache/mod_php7.c b/sapi/apache/mod_php7.c
deleted file mode 100644
index 27d6579da8..0000000000
--- a/sapi/apache/mod_php7.c
+++ /dev/null
@@ -1,1045 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@php.net> |
- | (with helpful hints from Dean Gaudet <dgaudet@arctic.org> |
- | PHP 4.0 patches by Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include "php_apache_http.h"
-#include "http_conf_globals.h"
-
-#ifdef NETWARE
-#define SIGPIPE SIGINT
-#endif
-
-#undef shutdown
-
-/* {{{ Prototypes
- */
-int apache_php_module_main(request_rec *r, int display_source_mode);
-static void php_save_umask(void);
-static void php_restore_umask(void);
-static int sapi_apache_read_post(char *buffer, uint count_bytes);
-static char *sapi_apache_read_cookies(void);
-static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers);
-static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers);
-static int send_php(request_rec *r, int display_source_mode, char *filename);
-static int send_parsed_php(request_rec * r);
-static int send_parsed_php_source(request_rec * r);
-static int php_xbithack_handler(request_rec * r);
-static void php_init_handler(server_rec *s, pool *p);
-/* }}} */
-
-#if MODULE_MAGIC_NUMBER >= 19970728
-static void php_child_exit_handler(server_rec *s, pool *p);
-#endif
-
-#if MODULE_MAGIC_NUMBER > 19961007
-#define CONST_PREFIX const
-#else
-#define CONST_PREFIX
-#endif
-static CONST_PREFIX char *php_apache_value_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode);
-static CONST_PREFIX char *php_apache_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2);
-static CONST_PREFIX char *php_apache_admin_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2);
-static CONST_PREFIX char *php_apache_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2);
-static CONST_PREFIX char *php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode);
-static CONST_PREFIX char *php_apache_admin_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2);
-
-/* ### these should be defined in mod_php7.h or somewhere else */
-#define USE_PATH 1
-#define IGNORE_URL 2
-#define MAX_STATUS_LENGTH sizeof("xxxx LONGEST POSSIBLE STATUS DESCRIPTION")
-
-module MODULE_VAR_EXPORT php7_module;
-
-int saved_umask;
-static unsigned char apache_php_initialized;
-
-typedef struct _php_per_dir_entry {
- char *key;
- char *value;
- uint key_length;
- uint value_length;
- int type;
- char htaccess;
-} php_per_dir_entry;
-
-/* some systems are missing these from their header files */
-
-/* {{{ php_save_umask
- */
-static void php_save_umask(void)
-{
- saved_umask = umask(077);
- umask(saved_umask);
-}
-/* }}} */
-
-/* {{{ sapi_apache_ub_write
- */
-static int sapi_apache_ub_write(const char *str, uint str_length)
-{
- int ret=0;
-
- if (SG(server_context)) {
- ret = rwrite(str, str_length, (request_rec *) SG(server_context));
- }
- if (ret != str_length) {
- php_handle_aborted_connection();
- }
- return ret;
-}
-/* }}} */
-
-/* {{{ sapi_apache_flush
- */
-static void sapi_apache_flush(void *server_context)
-{
- if (server_context) {
-#if MODULE_MAGIC_NUMBER > 19970110
- rflush((request_rec *) server_context);
-#else
- bflush((request_rec *) server_context->connection->client);
-#endif
- }
-}
-/* }}} */
-
-/* {{{ sapi_apache_read_post
- */
-static int sapi_apache_read_post(char *buffer, uint count_bytes)
-{
- int total_read_bytes=0, read_bytes;
- request_rec *r = (request_rec *) SG(server_context);
- void (*handler)(int);
-
- /*
- * This handles the situation where the browser sends a Expect: 100-continue header
- * and needs to receive confirmation from the server on whether or not it can send
- * the rest of the request. RFC 2616
- *
- */
- if (!SG(read_post_bytes) && !ap_should_client_block(r)) {
- return total_read_bytes;
- }
-
- handler = signal(SIGPIPE, SIG_IGN);
- while (total_read_bytes<count_bytes) {
- hard_timeout("Read POST information", r); /* start timeout timer */
- read_bytes = get_client_block(r, buffer+total_read_bytes, count_bytes-total_read_bytes);
- reset_timeout(r);
- if (read_bytes<=0) {
- break;
- }
- total_read_bytes += read_bytes;
- }
- signal(SIGPIPE, handler);
- return total_read_bytes;
-}
-/* }}} */
-
-/* {{{ sapi_apache_read_cookies
- */
-static char *sapi_apache_read_cookies(void)
-{
- return (char *) table_get(((request_rec *) SG(server_context))->subprocess_env, "HTTP_COOKIE");
-}
-/* }}} */
-
-/* {{{ sapi_apache_header_handler
- */
-static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers)
-{
- char *header_name, *header_content, *p;
- request_rec *r = (request_rec *) SG(server_context);
- if(!r) {
- return 0;
- }
-
- switch(op) {
- case SAPI_HEADER_DELETE_ALL:
- clear_table(r->headers_out);
- return 0;
-
- case SAPI_HEADER_DELETE:
- table_unset(r->headers_out, sapi_header->header);
- return 0;
-
- case SAPI_HEADER_ADD:
- case SAPI_HEADER_REPLACE:
- header_name = sapi_header->header;
-
- header_content = p = strchr(header_name, ':');
- if (!p) {
- return 0;
- }
-
- *p = 0;
- do {
- header_content++;
- } while (*header_content==' ');
-
- if (!strcasecmp(header_name, "Content-Type")) {
- r->content_type = pstrdup(r->pool, header_content);
- } else if (!strcasecmp(header_name, "Content-Length")) {
- ap_set_content_length(r, strtol(header_content, (char **)NULL, 10));
- } else if (!strcasecmp(header_name, "Set-Cookie")) {
- table_add(r->headers_out, header_name, header_content);
- } else if (op == SAPI_HEADER_REPLACE) {
- table_set(r->headers_out, header_name, header_content);
- } else {
- table_add(r->headers_out, header_name, header_content);
- }
-
- *p = ':'; /* a well behaved header handler shouldn't change its original arguments */
-
- return SAPI_HEADER_ADD;
-
- default:
- return 0;
- }
-}
-/* }}} */
-
-/* {{{ sapi_apache_send_headers
- */
-static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers)
-{
- request_rec *r = SG(server_context);
- const char *sline = SG(sapi_headers).http_status_line;
- int sline_len;
-
- if(r == NULL) { /* server_context is not here anymore */
- return SAPI_HEADER_SEND_FAILED;
- }
-
- r->status = SG(sapi_headers).http_response_code;
-
- /* httpd requires that r->status_line is set to the first digit of
- * the status-code: */
- if (sline && ((sline_len = strlen(sline)) > 12) && strncmp(sline, "HTTP/1.", 7) == 0 && sline[8] == ' ' && sline[12] == ' ') {
- if ((sline_len - 9) > MAX_STATUS_LENGTH) {
- r->status_line = ap_pstrndup(r->pool, sline + 9, MAX_STATUS_LENGTH);
- } else {
- r->status_line = ap_pstrndup(r->pool, sline + 9, sline_len - 9);
- }
- }
-
- if(r->status==304) {
- send_error_response(r,0);
- } else {
- send_http_header(r);
- }
- return SAPI_HEADER_SENT_SUCCESSFULLY;
-}
-/* }}} */
-
-/* {{{ sapi_apache_register_server_variables
- */
-static void sapi_apache_register_server_variables(zval *track_vars_array)
-{
- register int i;
- array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env);
- table_entry *elts = (table_entry *) arr->elts;
- zval *path_translated;
- HashTable *symbol_table;
- unsigned int new_val_len;
-
- for (i = 0; i < arr->nelts; i++) {
- char *val;
- int val_len;
-
- if (elts[i].val) {
- val = elts[i].val;
- } else {
- val = "";
- }
- val_len = strlen(val);
- if (sapi_module.input_filter(PARSE_SERVER, elts[i].key, &val, val_len, &new_val_len)) {
- php_register_variable_safe(elts[i].key, val, new_val_len, track_vars_array);
- }
- }
-
- /* If PATH_TRANSLATED doesn't exist, copy it from SCRIPT_FILENAME */
- if (track_vars_array) {
- symbol_table = Z_ARRVAL_P(track_vars_array);
- } else {
- symbol_table = NULL;
- }
- if (symbol_table
- && !zend_hash_str_exists(symbol_table, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED")-1)
- && (path_translated = zend_hash_str_find(symbol_table, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME")-1)) != NULL) {
- php_register_variable("PATH_TRANSLATED", Z_STRVAL_P(path_translated), track_vars_array);
- }
-
- if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", &((request_rec *) SG(server_context))->uri, strlen(((request_rec *) SG(server_context))->uri), &new_val_len)) {
- php_register_variable("PHP_SELF", ((request_rec *) SG(server_context))->uri, track_vars_array);
- }
-}
-/* }}} */
-
-/* {{{ php_apache_startup
- */
-static int php_apache_startup(sapi_module_struct *sapi_module)
-{
- if (php_module_startup(sapi_module, &apache_module_entry, 1) == FAILURE) {
- return FAILURE;
- } else {
- return SUCCESS;
- }
-}
-/* }}} */
-
-/* {{{ php_apache_log_message
- */
-static void php_apache_log_message(char *message)
-{
- if (SG(server_context)) {
-#if MODULE_MAGIC_NUMBER >= 19970831
- aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, ((request_rec *) SG(server_context))->server, "%s", message);
-#else
- log_error(message, ((request_rec *) SG(server_context))->server);
-#endif
- } else {
- fprintf(stderr, "%s\n", message);
- }
-}
-/* }}} */
-
-/* {{{ php_apache_request_shutdown
- */
-static void php_apache_request_shutdown(void *dummy)
-{
-
- php_output_set_status(PHP_OUTPUT_DISABLED);
- if (AP(in_request)) {
- AP(in_request) = 0;
- php_request_shutdown(dummy);
- }
- SG(server_context) = NULL;
- /*
- * The server context (request) is NOT invalid by the time
- * run_cleanups() is called
- */
-}
-/* }}} */
-
-/* {{{ php_apache_sapi_activate
- */
-static int php_apache_sapi_activate(void)
-{
- request_rec *r = (request_rec *) SG(server_context);
-
- /*
- * For the Apache module version, this bit of code registers a cleanup
- * function that gets triggered when our request pool is destroyed.
- * We need this because at any point in our code we can be interrupted
- * and that may happen before we have had time to free our memory.
- * The php_request_shutdown function needs to free all outstanding allocated
- * memory.
- */
- block_alarms();
- register_cleanup(r->pool, NULL, php_apache_request_shutdown, php_request_shutdown_for_exec);
- AP(in_request)=1;
- unblock_alarms();
-
- /* Override the default headers_only value - sometimes "GET" requests should actually only
- * send headers.
- */
- SG(request_info).headers_only = r->header_only;
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ php_apache_get_stat
- */
-static struct stat *php_apache_get_stat(void)
-{
- return &((request_rec *) SG(server_context))->finfo;
-}
-/* }}} */
-
-/* {{{ php_apache_getenv
- */
-static char *php_apache_getenv(char *name, size_t name_len)
-{
- if (SG(server_context) == NULL) {
- return NULL;
- }
-
- return (char *) table_get(((request_rec *) SG(server_context))->subprocess_env, name);
-}
-/* }}} */
-
-/* {{{ sapi_apache_get_fd
- */
-static int sapi_apache_get_fd(int *nfd)
-{
-#if PHP_APACHE_HAVE_CLIENT_FD
- request_rec *r = SG(server_context);
- int fd;
-
- fd = r->connection->client->fd;
-
- if (fd >= 0) {
- if (nfd) *nfd = fd;
- return SUCCESS;
- }
-#endif
- return FAILURE;
-}
-/* }}} */
-
-/* {{{ sapi_apache_force_http_10
- */
-static int sapi_apache_force_http_10(void)
-{
- request_rec *r = SG(server_context);
-
- r->proto_num = HTTP_VERSION(1,0);
-
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ sapi_apache_get_target_uid
- */
-static int sapi_apache_get_target_uid(uid_t *obj)
-{
- *obj = ap_user_id;
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ sapi_apache_get_target_gid
- */
-static int sapi_apache_get_target_gid(gid_t *obj)
-{
- *obj = ap_group_id;
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ php_apache_get_request_time
- */
-static double php_apache_get_request_time(void)
-{
- return (double) ((request_rec *)SG(server_context))->request_time;
-}
-/* }}} */
-
-/* {{{ sapi_apache_child_terminate
- */
-static void sapi_apache_child_terminate(void)
-{
-#ifndef MULTITHREAD
- ap_child_terminate((request_rec *)SG(server_context));
-#endif
-}
-/* }}} */
-
-/* {{{ sapi_module_struct apache_sapi_module
- */
-static sapi_module_struct apache_sapi_module = {
- "apache", /* name */
- "Apache", /* pretty name */
-
- php_apache_startup, /* startup */
- php_module_shutdown_wrapper, /* shutdown */
-
- php_apache_sapi_activate, /* activate */
- NULL, /* deactivate */
-
- sapi_apache_ub_write, /* unbuffered write */
- sapi_apache_flush, /* flush */
- php_apache_get_stat, /* get uid */
- php_apache_getenv, /* getenv */
-
- php_error, /* error handler */
-
- sapi_apache_header_handler, /* header handler */
- sapi_apache_send_headers, /* send headers handler */
- NULL, /* send header handler */
-
- sapi_apache_read_post, /* read POST data */
- sapi_apache_read_cookies, /* read Cookies */
-
- sapi_apache_register_server_variables, /* register server variables */
- php_apache_log_message, /* Log message */
- php_apache_get_request_time, /* Get request time */
- sapi_apache_child_terminate,
-
- NULL, /* php.ini path override */
-
-#ifdef PHP_WIN32
- NULL,
- NULL,
-#else
- block_alarms, /* Block interruptions */
- unblock_alarms, /* Unblock interruptions */
-#endif
-
- NULL, /* default post reader */
- NULL, /* treat data */
- NULL, /* exe location */
- 0, /* ini ignore */
- 0, /* ini ignore cwd */
- sapi_apache_get_fd,
- sapi_apache_force_http_10,
- sapi_apache_get_target_uid,
- sapi_apache_get_target_gid
-};
-/* }}} */
-
-/* {{{ php_restore_umask
- */
-static void php_restore_umask(void)
-{
- umask(saved_umask);
-}
-/* }}} */
-
-/* {{{ init_request_info
- */
-static void init_request_info(void)
-{
- request_rec *r = ((request_rec *) SG(server_context));
- char *content_length = (char *) table_get(r->subprocess_env, "CONTENT_LENGTH");
- const char *authorization=NULL;
- char *tmp, *tmp_user;
-
- SG(request_info).query_string = r->args;
- SG(request_info).path_translated = r->filename;
- SG(request_info).request_uri = r->uri;
- SG(request_info).request_method = (char *)r->method;
- SG(request_info).content_type = (char *) table_get(r->subprocess_env, "CONTENT_TYPE");
- SG(request_info).content_length = (content_length ? atol(content_length) : 0);
- SG(sapi_headers).http_response_code = r->status;
- SG(request_info).proto_num = r->proto_num;
-
- if (r->headers_in) {
- authorization = table_get(r->headers_in, "Authorization");
- }
-
- SG(request_info).auth_user = NULL;
- SG(request_info).auth_password = NULL;
- SG(request_info).auth_digest = NULL;
-
- if (authorization) {
- char *p = getword(r->pool, &authorization, ' ');
- if (!strcasecmp(p, "Basic")) {
- tmp = uudecode(r->pool, authorization);
- tmp_user = getword_nulls_nc(r->pool, &tmp, ':');
- if (tmp_user) {
- r->connection->user = pstrdup(r->connection->pool, tmp_user);
- r->connection->ap_auth_type = "Basic";
- SG(request_info).auth_user = estrdup(tmp_user);
- }
- if (tmp) {
- SG(request_info).auth_password = estrdup(tmp);
- }
- } else if (!strcasecmp(p, "Digest")) {
- r->connection->ap_auth_type = "Digest";
- SG(request_info).auth_digest = estrdup(authorization);
- }
- }
-}
-/* }}} */
-
-/* {{{ php_apache_alter_ini_entries
- */
-static int php_apache_alter_ini_entries(php_per_dir_entry *per_dir_entry)
-{
- zend_string *key = zend_string_init(per_dir_entry->key, per_dir_entry->key_length, 0);
- zend_alter_ini_entry_chars(key, per_dir_entry->value, per_dir_entry->value_length, per_dir_entry->type, per_dir_entry->htaccess?PHP_INI_STAGE_HTACCESS:PHP_INI_STAGE_ACTIVATE);
- zend_string_release(key);
- return 0;
-}
-/* }}} */
-
-/* {{{ php_apache_get_default_mimetype
- */
-static char *php_apache_get_default_mimetype(request_rec *r)
-{
-
- char *mimetype;
- if (SG(default_mimetype) || SG(default_charset)) {
- /* Assume output will be of the default MIME type. Individual
- scripts may change this later. */
- char *tmpmimetype;
- tmpmimetype = sapi_get_default_content_type();
- mimetype = pstrdup(r->pool, tmpmimetype);
- efree(tmpmimetype);
- } else {
- mimetype = SAPI_DEFAULT_MIMETYPE "; charset=" SAPI_DEFAULT_CHARSET;
- }
- return mimetype;
-}
-/* }}} */
-
-/* {{{ send_php
- */
-static int send_php(request_rec *r, int display_source_mode, char *filename)
-{
- int retval;
- HashTable *per_dir_conf;
-
- if (AP(in_request)) {
- zend_file_handle fh;
-
- fh.filename = r->filename;
- fh.opened_path = NULL;
- fh.free_filename = 0;
- fh.type = ZEND_HANDLE_FILENAME;
-
- zend_execute_scripts(ZEND_INCLUDE, NULL, 1, &fh);
- return OK;
- }
-
- SG(server_context) = r;
-
- zend_first_try {
-
- /* Make sure file exists */
- if (filename == NULL && r->finfo.st_mode == 0) {
- return DECLINED;
- }
-
- per_dir_conf = (HashTable *) get_module_config(r->per_dir_config, &php7_module);
- if (per_dir_conf) {
- zend_hash_apply((HashTable *) per_dir_conf, (apply_func_t) php_apache_alter_ini_entries);
- }
-
- /* If PHP parser engine has been turned off with an "engine off"
- * directive, then decline to handle this request
- */
- if (!AP(engine)) {
- r->content_type = php_apache_get_default_mimetype(r);
- zend_try {
- zend_ini_deactivate();
- } zend_end_try();
- return DECLINED;
- }
- if (filename == NULL) {
- filename = r->filename;
- }
-
- /* Apache 1.2 has a more complex mechanism for reading POST data */
-#if MODULE_MAGIC_NUMBER > 19961007
- if ((retval = setup_client_block(r, REQUEST_CHUNKED_DECHUNK))) {
- zend_try {
- zend_ini_deactivate();
- } zend_end_try();
- return retval;
- }
-#endif
-
- if (AP(last_modified)) {
-#if MODULE_MAGIC_NUMBER < 19970912
- if ((retval = set_last_modified(r, r->finfo.st_mtime))) {
- zend_try {
- zend_ini_deactivate();
- } zend_end_try();
- return retval;
- }
-#else
- update_mtime (r, r->finfo.st_mtime);
- set_last_modified(r);
- set_etag(r);
-#endif
- }
- /* Assume output will be of the default MIME type. Individual
- scripts may change this later in the request. */
- r->content_type = php_apache_get_default_mimetype(r);
-
- /* Init timeout */
- hard_timeout("send", r);
-
- php_save_umask();
- add_common_vars(r);
- add_cgi_vars(r);
-
- init_request_info();
- apache_php_module_main(r, display_source_mode);
-
- /* Done, restore umask, turn off timeout, close file and return */
- php_restore_umask();
- kill_timeout(r);
- } zend_end_try();
-
- return OK;
-}
-/* }}} */
-
-/* {{{ send_parsed_php
- */
-static int send_parsed_php(request_rec * r)
-{
- int result = send_php(r, 0, NULL);
-
- ap_table_setn(r->notes, "mod_php_memory_usage",
- ap_psprintf(r->pool, "%lu", zend_memory_peak_usage(1)));
-
- return result;
-}
-/* }}} */
-
-/* {{{ send_parsed_php_source
- */
-static int send_parsed_php_source(request_rec * r)
-{
- return send_php(r, 1, NULL);
-}
-/* }}} */
-
-/* {{{ destroy_per_dir_entry
- */
-static void destroy_per_dir_entry(zval *zv)
-{
- php_per_dir_entry *per_dir_entry = Z_PTR_P(zv);
-
- free(per_dir_entry->key);
- free(per_dir_entry->value);
- free(per_dir_entry);
-}
-/* }}} */
-
-/* {{{ copy_per_dir_entry
- */
-static void copy_per_dir_entry(zval *zv)
-{
- php_per_dir_entry *old_per_dir_entry = Z_PTR_P(zv);
- php_per_dir_entry *new_per_dir_entry = malloc(sizeof(php_per_dir_entry));
-
- memcpy(new_per_dir_entry, old_per_dir_entry, sizeof(php_per_dir_entry));
- Z_PTR_P(zv) = new_per_dir_entry;
-
- new_per_dir_entry->key = (char *) malloc(old_per_dir_entry->key_length+1);
- memcpy(new_per_dir_entry->key, old_per_dir_entry->key, old_per_dir_entry->key_length);
- new_per_dir_entry->key[new_per_dir_entry->key_length] = 0;
-
- new_per_dir_entry->value = (char *) malloc(old_per_dir_entry->value_length+1);
- memcpy(new_per_dir_entry->value, old_per_dir_entry->value, old_per_dir_entry->value_length);
- new_per_dir_entry->value[new_per_dir_entry->value_length] = 0;
-}
-/* }}} */
-
-/* {{{ should_overwrite_per_dir_entry
- */
-static zend_bool should_overwrite_per_dir_entry(HashTable *target_ht, zval *zv, zend_hash_key *hash_key, void *pData)
-{
- php_per_dir_entry *new_per_dir_entry = Z_PTR_P(zv);
- php_per_dir_entry *orig_per_dir_entry;
-
- if ((orig_per_dir_entry = zend_hash_find_ptr(target_ht, hash_key->key)) == NULL) {
- return 1; /* does not exist in dest, copy from source */
- }
-
- if (orig_per_dir_entry->type==PHP_INI_SYSTEM
- && new_per_dir_entry->type!=PHP_INI_SYSTEM) {
- return 0;
- } else {
- return 1;
- }
-}
-/* }}} */
-
-/* {{{ php_destroy_per_dir_info
- */
-static void php_destroy_per_dir_info(HashTable *per_dir_info)
-{
- zend_hash_destroy(per_dir_info);
- free(per_dir_info);
-}
-/* }}} */
-
-/* {{{ php_create_dir
- */
-static void *php_create_dir(pool *p, char *dummy)
-{
- HashTable *per_dir_info;
-
- per_dir_info = (HashTable *) malloc(sizeof(HashTable));
- zend_hash_init_ex(per_dir_info, 5, NULL, destroy_per_dir_entry, 1, 0);
- register_cleanup(p, (void *) per_dir_info, (void (*)(void *)) php_destroy_per_dir_info, (void (*)(void *)) zend_hash_destroy);
-
- return per_dir_info;
-}
-/* }}} */
-
-/* {{{ php_merge_dir
- */
-static void *php_merge_dir(pool *p, void *basev, void *addv)
-{
- /* This function *must* not modify addv or basev */
- HashTable *new;
-
- /* need a copy of addv to merge */
- new = php_create_dir(p, "php_merge_dir");
- zend_hash_copy(new, (HashTable *) basev, copy_per_dir_entry);
-
- zend_hash_merge_ex(new, (HashTable *) addv, copy_per_dir_entry, should_overwrite_per_dir_entry, NULL);
- return new;
-}
-/* }}} */
-
-/* {{{ php_apache_value_handler_ex
- */
-static CONST_PREFIX char *php_apache_value_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode)
-{
- php_per_dir_entry per_dir_entry;
-
- if (!apache_php_initialized) {
- apache_php_initialized = 1;
-#ifdef ZTS
- tsrm_startup(1, 1, 0, NULL);
-#endif
- sapi_startup(&apache_sapi_module);
- php_apache_startup(&apache_sapi_module);
- }
- per_dir_entry.type = mode;
- per_dir_entry.htaccess = ((cmd->override & (RSRC_CONF|ACCESS_CONF)) == 0);
-
- if (strcasecmp(arg2, "none") == 0) {
- arg2 = "";
- }
-
- per_dir_entry.key_length = strlen(arg1);
- per_dir_entry.value_length = strlen(arg2);
-
- per_dir_entry.key = (char *) malloc(per_dir_entry.key_length+1);
- memcpy(per_dir_entry.key, arg1, per_dir_entry.key_length);
- per_dir_entry.key[per_dir_entry.key_length] = 0;
-
- per_dir_entry.value = (char *) malloc(per_dir_entry.value_length+1);
- memcpy(per_dir_entry.value, arg2, per_dir_entry.value_length);
- per_dir_entry.value[per_dir_entry.value_length] = 0;
-
- zend_hash_str_update_mem(conf, per_dir_entry.key, per_dir_entry.key_length, &per_dir_entry, sizeof(php_per_dir_entry));
- return NULL;
-}
-/* }}} */
-
-/* {{{ php_apache_value_handler
- */
-static CONST_PREFIX char *php_apache_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2)
-{
- return php_apache_value_handler_ex(cmd, conf, arg1, arg2, PHP_INI_PERDIR);
-}
-/* }}} */
-
-/* {{{ php_apache_admin_value_handler
- */
-static CONST_PREFIX char *php_apache_admin_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2)
-{
- return php_apache_value_handler_ex(cmd, conf, arg1, arg2, PHP_INI_SYSTEM);
-}
-/* }}} */
-
-/* {{{ php_apache_flag_handler_ex
- */
-static CONST_PREFIX char *php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode)
-{
- char bool_val[2];
-
- if (!strcasecmp(arg2, "On") || (arg2[0] == '1' && arg2[1] == '\0')) {
- bool_val[0] = '1';
- } else {
- bool_val[0] = '0';
- }
- bool_val[1] = 0;
-
- return php_apache_value_handler_ex(cmd, conf, arg1, bool_val, mode);
-}
-/* }}} */
-
-/* {{{ php_apache_flag_handler
- */
-static CONST_PREFIX char *php_apache_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2)
-{
- return php_apache_flag_handler_ex(cmd, conf, arg1, arg2, PHP_INI_PERDIR);
-}
-/* }}} */
-
-/* {{{ php_apache_admin_flag_handler
- */
-static CONST_PREFIX char *php_apache_admin_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2)
-{
- return php_apache_flag_handler_ex(cmd, conf, arg1, arg2, PHP_INI_SYSTEM);
-}
-/* }}} */
-
-/* {{{ php_apache_phpini_set
- */
-static CONST_PREFIX char *php_apache_phpini_set(cmd_parms *cmd, HashTable *conf, char *arg)
-{
- if (apache_sapi_module.php_ini_path_override) {
- return "Only first PHPINIDir directive honored per configuration tree - subsequent ones ignored";
- }
- apache_sapi_module.php_ini_path_override = ap_server_root_relative(cmd->pool, arg);
- return NULL;
-}
-/* }}} */
-
-/* {{{ int php_xbithack_handler(request_rec * r)
- */
-static int php_xbithack_handler(request_rec * r)
-{
- HashTable *per_dir_conf;
-
- if (!(r->finfo.st_mode & S_IXUSR)) {
- return DECLINED;
- }
- per_dir_conf = (HashTable *) get_module_config(r->per_dir_config, &php7_module);
- if (per_dir_conf) {
- zend_hash_apply((HashTable *) per_dir_conf, (apply_func_t) php_apache_alter_ini_entries);
- }
- if(!AP(xbithack)) {
- zend_try {
- zend_ini_deactivate();
- } zend_end_try();
- return DECLINED;
- }
- return send_parsed_php(r);
-}
-/* }}} */
-
-/* {{{ apache_php_module_shutdown_wrapper
- */
-static void apache_php_module_shutdown_wrapper(void)
-{
- apache_php_initialized = 0;
- apache_sapi_module.shutdown(&apache_sapi_module);
-
-#if MODULE_MAGIC_NUMBER >= 19970728
- /* This function is only called on server exit if the apache API
- * child_exit handler exists, so shutdown globally
- */
- sapi_shutdown();
-#endif
-
-#ifdef ZTS
- tsrm_shutdown();
-#endif
-}
-/* }}} */
-
-#if MODULE_MAGIC_NUMBER >= 19970728
-/* {{{ php_child_exit_handler
- */
-static void php_child_exit_handler(server_rec *s, pool *p)
-{
-/* apache_php_initialized = 0; */
- apache_sapi_module.shutdown(&apache_sapi_module);
-
-#ifdef ZTS
- tsrm_shutdown();
-#endif
-}
-/* }}} */
-#endif
-
-/* {{{ void php_init_handler(server_rec *s, pool *p)
- */
-static void php_init_handler(server_rec *s, pool *p)
-{
- register_cleanup(p, NULL, (void (*)(void *))apache_php_module_shutdown_wrapper, (void (*)(void *))php_module_shutdown_for_exec);
- if (!apache_php_initialized) {
- apache_php_initialized = 1;
-#ifdef ZTS
- tsrm_startup(1, 1, 0, NULL);
-#endif
- sapi_startup(&apache_sapi_module);
- php_apache_startup(&apache_sapi_module);
- }
-#if MODULE_MAGIC_NUMBER >= 19980527
- {
- if (PG(expose_php)) {
- ap_add_version_component("PHP/" PHP_VERSION);
- }
- }
-#endif
-}
-/* }}} */
-
-/* {{{ handler_rec php_handlers[]
- */
-handler_rec php_handlers[] =
-{
- {"application/x-httpd-php", send_parsed_php},
- {"application/x-httpd-php-source", send_parsed_php_source},
- {"text/html", php_xbithack_handler},
- {NULL}
-};
-/* }}} */
-
-/* {{{ command_rec php_commands[]
- */
-command_rec php_commands[] =
-{
- {"php_value", php_apache_value_handler, NULL, OR_OPTIONS, TAKE2, "PHP Value Modifier"},
- {"php_flag", php_apache_flag_handler, NULL, OR_OPTIONS, TAKE2, "PHP Flag Modifier"},
- {"php_admin_value", php_apache_admin_value_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Value Modifier (Admin)"},
- {"php_admin_flag", php_apache_admin_flag_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Flag Modifier (Admin)"},
- {"PHPINIDir", php_apache_phpini_set, NULL, RSRC_CONF, TAKE1, "Directory containing the php.ini file"},
- {NULL}
-};
-/* }}} */
-
-/* {{{ odule MODULE_VAR_EXPORT php7_module
- */
-module MODULE_VAR_EXPORT php7_module =
-{
- STANDARD_MODULE_STUFF,
- php_init_handler, /* initializer */
- php_create_dir, /* per-directory config creator */
- php_merge_dir, /* dir merger */
- NULL, /* per-server config creator */
- NULL, /* merge server config */
- php_commands, /* command table */
- php_handlers, /* handlers */
- NULL, /* filename translation */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- NULL, /* fixups */
- NULL /* logger */
-#if MODULE_MAGIC_NUMBER >= 19970103
- , NULL /* header parser */
-#endif
-#if MODULE_MAGIC_NUMBER >= 19970719
- , NULL /* child_init */
-#endif
-#if MODULE_MAGIC_NUMBER >= 19970728
- , php_child_exit_handler /* child_exit */
-#endif
-#if MODULE_MAGIC_NUMBER >= 19970902
- , NULL /* post read-request */
-#endif
-};
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/sapi/apache/mod_php7.exp b/sapi/apache/mod_php7.exp
deleted file mode 100644
index 1469b0314d..0000000000
--- a/sapi/apache/mod_php7.exp
+++ /dev/null
@@ -1 +0,0 @@
-php7_module
diff --git a/sapi/apache/mod_php7.h b/sapi/apache/mod_php7.h
deleted file mode 100644
index 81b6b30b42..0000000000
--- a/sapi/apache/mod_php7.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Rasmus Lerdorf <rasmus@php.net> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#ifndef MOD_PHP7_H
-#define MOD_PHP7_H
-
-#if !defined(WIN32) && !defined(WINNT)
-#ifndef MODULE_VAR_EXPORT
-#define MODULE_VAR_EXPORT
-#endif
-#endif
-
-typedef struct {
- long engine;
- long last_modified;
- long xbithack;
- long terminate_child;
- zend_bool in_request;
-} php_apache_info_struct;
-
-extern zend_module_entry apache_module_entry;
-
-#ifdef ZTS
-extern int php_apache_info_id;
-#define AP(v) TSRMG(php_apache_info_id, php_apache_info_struct *, v)
-#else
-extern php_apache_info_struct php_apache_info;
-#define AP(v) (php_apache_info.v)
-#endif
-
-/* fix for gcc4 visibility patch */
-#ifndef PHP_WIN32
-# undef MODULE_VAR_EXPORT
-# define MODULE_VAR_EXPORT PHPAPI
-#endif
-
-#endif /* MOD_PHP7_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/sapi/apache/php.sym b/sapi/apache/php.sym
deleted file mode 100644
index 1469b0314d..0000000000
--- a/sapi/apache/php.sym
+++ /dev/null
@@ -1 +0,0 @@
-php7_module
diff --git a/sapi/apache/php_apache.c b/sapi/apache/php_apache.c
deleted file mode 100644
index 33d8a72b99..0000000000
--- a/sapi/apache/php_apache.c
+++ /dev/null
@@ -1,607 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Stig Sæther Bakken <ssb@php.net> |
- | David Sklar <sklar@student.net> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include "php_apache_http.h"
-
-#if defined(PHP_WIN32) || defined(NETWARE)
-#include "zend.h"
-#include "ap_compat.h"
-#endif
-
-#ifdef ZTS
-int php_apache_info_id;
-#else
-php_apache_info_struct php_apache_info;
-#endif
-
-#define SECTION(name) PUTS("<h2>" name "</h2>\n")
-
-#ifndef PHP_WIN32
-extern module *top_module;
-extern module **ap_loaded_modules;
-#else
-extern __declspec(dllimport) module *top_module;
-extern __declspec(dllimport) module **ap_loaded_modules;
-#endif
-
-PHP_FUNCTION(virtual);
-PHP_FUNCTION(apache_request_headers);
-PHP_FUNCTION(apache_response_headers);
-PHP_FUNCTION(apachelog);
-PHP_FUNCTION(apache_note);
-PHP_FUNCTION(apache_lookup_uri);
-PHP_FUNCTION(apache_child_terminate);
-PHP_FUNCTION(apache_setenv);
-PHP_FUNCTION(apache_get_version);
-PHP_FUNCTION(apache_get_modules);
-PHP_FUNCTION(apache_reset_timeout);
-
-PHP_MINFO_FUNCTION(apache);
-
-ZEND_BEGIN_ARG_INFO(arginfo_apache_child_terminate, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_apache_note, 0, 0, 1)
- ZEND_ARG_INFO(0, note_name)
- ZEND_ARG_INFO(0, note_value)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_apache_virtual, 0, 0, 1)
- ZEND_ARG_INFO(0, filename)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_apache_request_headers, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_apache_response_headers, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_apache_setenv, 0, 0, 2)
- ZEND_ARG_INFO(0, variable)
- ZEND_ARG_INFO(0, value)
- ZEND_ARG_INFO(0, walk_to_top)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_apache_lookup_uri, 0, 0, 1)
- ZEND_ARG_INFO(0, uri)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_apache_get_version, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_apache_get_modules, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_apache_reset_timeout, 0)
-ZEND_END_ARG_INFO()
-
-
-
-const zend_function_entry apache_functions[] = {
- PHP_FE(virtual, arginfo_apache_virtual)
- PHP_FE(apache_request_headers, arginfo_apache_request_headers)
- PHP_FE(apache_note, arginfo_apache_note)
- PHP_FE(apache_lookup_uri, arginfo_apache_lookup_uri)
- PHP_FE(apache_child_terminate, arginfo_apache_child_terminate)
- PHP_FE(apache_setenv, arginfo_apache_setenv)
- PHP_FE(apache_response_headers, arginfo_apache_response_headers)
- PHP_FE(apache_get_version, arginfo_apache_get_version)
- PHP_FE(apache_get_modules, arginfo_apache_get_modules)
- PHP_FE(apache_reset_timeout, arginfo_apache_reset_timeout)
- PHP_FALIAS(getallheaders, apache_request_headers, arginfo_apache_request_headers)
- {NULL, NULL, NULL}
-};
-
-
-PHP_INI_BEGIN()
- STD_PHP_INI_ENTRY("xbithack", "0", PHP_INI_ALL, OnUpdateLong, xbithack, php_apache_info_struct, php_apache_info)
- STD_PHP_INI_ENTRY("engine", "1", PHP_INI_ALL, OnUpdateLong, engine, php_apache_info_struct, php_apache_info)
- STD_PHP_INI_ENTRY("last_modified", "0", PHP_INI_ALL, OnUpdateLong, last_modified, php_apache_info_struct, php_apache_info)
- STD_PHP_INI_ENTRY("child_terminate", "0", PHP_INI_ALL, OnUpdateLong, terminate_child, php_apache_info_struct, php_apache_info)
-PHP_INI_END()
-
-
-
-static void php_apache_globals_ctor(php_apache_info_struct *apache_globals)
-{
- apache_globals->in_request = 0;
-}
-
-
-static PHP_MINIT_FUNCTION(apache)
-{
-#ifdef ZTS
- ts_allocate_id(&php_apache_info_id, sizeof(php_apache_info_struct), (ts_allocate_ctor) php_apache_globals_ctor, NULL);
-#else
- php_apache_globals_ctor(&php_apache_info);
-#endif
- REGISTER_INI_ENTRIES();
- return SUCCESS;
-}
-
-
-static PHP_MSHUTDOWN_FUNCTION(apache)
-{
- UNREGISTER_INI_ENTRIES();
- return SUCCESS;
-}
-
-zend_module_entry apache_module_entry = {
- STANDARD_MODULE_HEADER,
- "apache",
- apache_functions,
- PHP_MINIT(apache),
- PHP_MSHUTDOWN(apache),
- NULL,
- NULL,
- PHP_MINFO(apache),
- NO_VERSION_YET,
- STANDARD_MODULE_PROPERTIES
-};
-
-/* {{{ PHP_MINFO_FUNCTION
- */
-PHP_MINFO_FUNCTION(apache)
-{
- char *apv = (char *) ap_get_server_version();
- module *modp = NULL;
- char output_buf[128];
-#if !defined(WIN32) && !defined(WINNT)
- char name[64];
- char modulenames[1024];
- char *p;
-#endif
- server_rec *serv;
- extern char server_root[MAX_STRING_LEN];
- extern uid_t user_id;
- extern char *user_name;
- extern gid_t group_id;
- extern int max_requests_per_child;
-
- serv = ((request_rec *) SG(server_context))->server;
-
-
- php_info_print_table_start();
-
-#ifdef PHP_WIN32
- php_info_print_table_row(1, "Apache for Windows 95/NT");
- php_info_print_table_end();
- php_info_print_table_start();
-#elif defined(NETWARE)
- php_info_print_table_row(1, "Apache for NetWare");
- php_info_print_table_end();
- php_info_print_table_start();
-#else
- php_info_print_table_row(2, "APACHE_INCLUDE", PHP_APACHE_INCLUDE);
- php_info_print_table_row(2, "APACHE_TARGET", PHP_APACHE_TARGET);
-#endif
-
- if (apv && *apv) {
- php_info_print_table_row(2, "Apache Version", apv);
- }
-
-#ifdef APACHE_RELEASE
- snprintf(output_buf, sizeof(output_buf), "%d", APACHE_RELEASE);
- php_info_print_table_row(2, "Apache Release", output_buf);
-#endif
- snprintf(output_buf, sizeof(output_buf), "%d", MODULE_MAGIC_NUMBER);
- php_info_print_table_row(2, "Apache API Version", output_buf);
- snprintf(output_buf, sizeof(output_buf), "%s:%u", serv->server_hostname, serv->port);
- php_info_print_table_row(2, "Hostname:Port", output_buf);
-#if !defined(WIN32) && !defined(WINNT)
- snprintf(output_buf, sizeof(output_buf), "%s(%d)/%d", user_name, (int)user_id, (int)group_id);
- php_info_print_table_row(2, "User/Group", output_buf);
- snprintf(output_buf, sizeof(output_buf), "Per Child: %d - Keep Alive: %s - Max Per Connection: %d", max_requests_per_child, serv->keep_alive ? "on":"off", serv->keep_alive_max);
- php_info_print_table_row(2, "Max Requests", output_buf);
-#endif
- snprintf(output_buf, sizeof(output_buf), "Connection: %d - Keep-Alive: %d", serv->timeout, serv->keep_alive_timeout);
- php_info_print_table_row(2, "Timeouts", output_buf);
-#if !defined(WIN32) && !defined(WINNT)
-/*
- This block seems to be working on NetWare; But it seems to be showing
- all modules instead of just the loaded ones
-*/
- php_info_print_table_row(2, "Server Root", server_root);
-
- strcpy(modulenames, "");
- for(modp = top_module; modp; modp = modp->next) {
- strlcpy(name, modp->name, sizeof(name));
- if ((p = strrchr(name, '.'))) {
- *p='\0'; /* Cut off ugly .c extensions on module names */
- }
- strlcat(modulenames, name, sizeof(modulenames));
- if (modp->next) {
- strlcat(modulenames, ", ", sizeof(modulenames));
- }
- }
- php_info_print_table_row(2, "Loaded Modules", modulenames);
-#endif
-
- php_info_print_table_end();
-
- DISPLAY_INI_ENTRIES();
-
- {
- register int i;
- array_header *arr;
- table_entry *elts;
- request_rec *r;
-
- r = ((request_rec *) SG(server_context));
- arr = table_elts(r->subprocess_env);
- elts = (table_entry *)arr->elts;
-
- SECTION("Apache Environment");
- php_info_print_table_start();
- php_info_print_table_header(2, "Variable", "Value");
- for (i=0; i < arr->nelts; i++) {
- php_info_print_table_row(2, elts[i].key, elts[i].val);
- }
- php_info_print_table_end();
- }
-
- {
- array_header *env_arr;
- table_entry *env;
- int i;
- request_rec *r;
-
- r = ((request_rec *) SG(server_context));
- SECTION("HTTP Headers Information");
- php_info_print_table_start();
- php_info_print_table_colspan_header(2, "HTTP Request Headers");
- php_info_print_table_row(2, "HTTP Request", r->the_request);
- env_arr = table_elts(r->headers_in);
- env = (table_entry *)env_arr->elts;
- for (i = 0; i < env_arr->nelts; ++i) {
- if (env[i].key) {
- php_info_print_table_row(2, env[i].key, env[i].val);
- }
- }
- php_info_print_table_colspan_header(2, "HTTP Response Headers");
- env_arr = table_elts(r->headers_out);
- env = (table_entry *)env_arr->elts;
- for(i = 0; i < env_arr->nelts; ++i) {
- if (env[i].key) {
- php_info_print_table_row(2, env[i].key, env[i].val);
- }
- }
- php_info_print_table_end();
- }
-}
-/* }}} */
-
-/* {{{ proto bool apache_child_terminate(void)
- Terminate apache process after this request */
-PHP_FUNCTION(apache_child_terminate)
-{
-#ifndef MULTITHREAD
- if (AP(terminate_child)) {
- ap_child_terminate( ((request_rec *)SG(server_context)) );
- RETURN_TRUE;
- } else { /* tell them to get lost! */
- php_error_docref(NULL, E_WARNING, "This function is disabled");
- RETURN_FALSE;
- }
-#else
- php_error_docref(NULL, E_WARNING, "This function is not supported in this build");
- RETURN_FALSE;
-#endif
-}
-/* }}} */
-
-/* {{{ proto string apache_note(string note_name [, string note_value])
- Get and set Apache request notes */
-PHP_FUNCTION(apache_note)
-{
- char *note_name, *note_val = NULL;
- int note_name_len, note_val_len;
- char *old_val;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &note_name, &note_name_len, &note_val, &note_val_len) == FAILURE) {
- return;
- }
-
- old_val = (char *) table_get(((request_rec *)SG(server_context))->notes, note_name);
-
- if (note_val) {
- table_set(((request_rec *)SG(server_context))->notes, note_name, note_val);
- }
-
- if (old_val) {
- RETURN_STRING(old_val);
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto bool virtual(string filename)
- Perform an Apache sub-request */
-/* This function is equivalent to <!--#include virtual...-->
- * in mod_include. It does an Apache sub-request. It is useful
- * for including CGI scripts or .shtml files, or anything else
- * that you'd parse through Apache (for .phtml files, you'd probably
- * want to use <?Include>. This only works when PHP is compiled
- * as an Apache module, since it uses the Apache API for doing
- * sub requests.
- */
-PHP_FUNCTION(virtual)
-{
- char *filename;
- int filename_len;
- request_rec *rr = NULL;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &filename, &filename_len) == FAILURE) {
- return;
- }
-
- if (!(rr = sub_req_lookup_uri (filename, ((request_rec *) SG(server_context))))) {
- php_error_docref(NULL, E_WARNING, "Unable to include '%s' - URI lookup failed", filename);
- if (rr)
- destroy_sub_req (rr);
- RETURN_FALSE;
- }
-
- if (rr->status != 200) {
- php_error_docref(NULL, E_WARNING, "Unable to include '%s' - error finding URI", filename);
- if (rr)
- destroy_sub_req (rr);
- RETURN_FALSE;
- }
-
- php_output_end_all();
- php_header();
-
- if (run_sub_req(rr)) {
- php_error_docref(NULL, E_WARNING, "Unable to include '%s' - request execution failed", filename);
- if (rr)
- destroy_sub_req (rr);
- RETURN_FALSE;
- }
-
- if (rr)
- destroy_sub_req (rr);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto array getallheaders(void)
- Alias for apache_request_headers() */
-/* }}} */
-
-/* {{{ proto array apache_request_headers(void)
- Fetch all HTTP request headers */
-PHP_FUNCTION(apache_request_headers)
-{
- array_header *env_arr;
- table_entry *tenv;
- int i;
-
- array_init(return_value);
- env_arr = table_elts(((request_rec *) SG(server_context))->headers_in);
- tenv = (table_entry *)env_arr->elts;
- for (i = 0; i < env_arr->nelts; ++i) {
- if (!tenv[i].key) {
- continue;
- }
- if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val)==FAILURE) {
- RETURN_FALSE;
- }
- }
-}
-/* }}} */
-
-/* {{{ proto array apache_response_headers(void)
- Fetch all HTTP response headers */
-PHP_FUNCTION(apache_response_headers)
-{
- array_header *env_arr;
- table_entry *tenv;
- int i;
-
- array_init(return_value);
- env_arr = table_elts(((request_rec *) SG(server_context))->headers_out);
- tenv = (table_entry *)env_arr->elts;
- for (i = 0; i < env_arr->nelts; ++i) {
- if (!tenv[i].key) continue;
- if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val)==FAILURE) {
- RETURN_FALSE;
- }
- }
-}
-/* }}} */
-
-/* {{{ proto bool apache_setenv(string variable, string value [, bool walk_to_top])
- Set an Apache subprocess_env variable */
-PHP_FUNCTION(apache_setenv)
-{
- int var_len, val_len;
- zend_bool top=0;
- char *var = NULL, *val = NULL;
- request_rec *r = (request_rec *) SG(server_context);
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|b", &var, &var_len, &val, &val_len, &top) == FAILURE) {
- return;
- }
-
- while(top) {
- if(r->prev) r = r->prev;
- else break;
- }
-
- ap_table_setn(r->subprocess_env, ap_pstrndup(r->pool, var, var_len), ap_pstrndup(r->pool, val, val_len));
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto object apache_lookup_uri(string URI)
- Perform a partial request of the given URI to obtain information about it */
-PHP_FUNCTION(apache_lookup_uri)
-{
- char *filename;
- int filename_len;
- request_rec *rr=NULL;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &filename, &filename_len) == FAILURE) {
- return;
- }
-
- if (!(rr = sub_req_lookup_uri(filename, ((request_rec *) SG(server_context))))) {
- php_error_docref(NULL, E_WARNING, "URI lookup failed '%s'", filename);
- RETURN_FALSE;
- }
-
- object_init(return_value);
- add_property_long(return_value,"status", rr->status);
-
- if (rr->the_request) {
- add_property_string(return_value,"the_request", rr->the_request);
- }
- if (rr->status_line) {
- add_property_string(return_value,"status_line", (char *)rr->status_line);
- }
- if (rr->method) {
- add_property_string(return_value,"method", (char *)rr->method);
- }
- if (rr->content_type) {
- add_property_string(return_value,"content_type", (char *)rr->content_type);
- }
- if (rr->handler) {
- add_property_string(return_value,"handler", (char *)rr->handler);
- }
- if (rr->uri) {
- add_property_string(return_value,"uri", rr->uri);
- }
- if (rr->filename) {
- add_property_string(return_value,"filename", rr->filename);
- }
- if (rr->path_info) {
- add_property_string(return_value,"path_info", rr->path_info);
- }
- if (rr->args) {
- add_property_string(return_value,"args", rr->args);
- }
- if (rr->boundary) {
- add_property_string(return_value,"boundary", rr->boundary);
- }
-
- add_property_long(return_value,"no_cache", rr->no_cache);
- add_property_long(return_value,"no_local_copy", rr->no_local_copy);
- add_property_long(return_value,"allowed", rr->allowed);
- add_property_long(return_value,"sent_bodyct", rr->sent_bodyct);
- add_property_long(return_value,"bytes_sent", rr->bytes_sent);
- add_property_long(return_value,"byterange", rr->byterange);
- add_property_long(return_value,"clength", rr->clength);
-
-#if MODULE_MAGIC_NUMBER >= 19980324
- if (rr->unparsed_uri) {
- add_property_string(return_value,"unparsed_uri", rr->unparsed_uri);
- }
- if(rr->mtime) {
- add_property_long(return_value,"mtime", rr->mtime);
- }
-#endif
- if(rr->request_time) {
- add_property_long(return_value,"request_time", rr->request_time);
- }
-
- destroy_sub_req(rr);
-}
-/* }}} */
-
-
-#if 0
-/*
-This function is most likely a bad idea. Just playing with it for now.
-*/
-PHP_FUNCTION(apache_exec_uri)
-{
- char *filename;
- int filename_len;
- request_rec *rr=NULL;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &filename, &filename_len) == FAILURE) {
- return;
- }
-
- if(!(rr = ap_sub_req_lookup_uri(filename, ((request_rec *) SG(server_context))))) {
- php_error_docref(NULL, E_WARNING, "URI lookup failed", filename);
- RETURN_FALSE;
- }
-
- RETVAL_LONG(ap_run_sub_req(rr));
- ap_destroy_sub_req(rr);
-}
-#endif
-
-/* {{{ proto string apache_get_version(void)
- Fetch Apache version */
-PHP_FUNCTION(apache_get_version)
-{
- char *apv = (char *) ap_get_server_version();
-
- if (apv && *apv) {
- RETURN_STRING(apv);
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto array apache_get_modules(void)
- Get a list of loaded Apache modules */
-PHP_FUNCTION(apache_get_modules)
-{
- int n;
- char *p;
-
- array_init(return_value);
-
- for (n = 0; ap_loaded_modules[n]; ++n) {
- char *s = (char *) ap_loaded_modules[n]->name;
- if ((p = strchr(s, '.'))) {
- add_next_index_stringl(return_value, s, (p - s));
- } else {
- add_next_index_string(return_value, s);
- }
- }
-}
-/* }}} */
-
-/* {{{ proto bool apache_reset_timeout(void)
- Reset the Apache write timer */
-PHP_FUNCTION(apache_reset_timeout)
-{
- ap_reset_timeout((request_rec *)SG(server_context));
- RETURN_TRUE;
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/sapi/apache/php_apache_http.h b/sapi/apache/php_apache_http.h
deleted file mode 100644
index 00bb9ca91a..0000000000
--- a/sapi/apache/php_apache_http.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Stig Sæther Bakken <ssb@php.net> |
- | David Sklar <sklar@student.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#define NO_REGEX_EXTRA_H
-
-#ifdef WIN32
-#include <stddef.h>
-#endif
-
-#ifdef NETWARE
-#include <netinet/in.h>
-#endif
-
-#include "zend.h"
-#include "ext/ereg/php_regex.h"
-#include "php_compat.h"
-
-#ifdef HAVE_OPENSSL_EXT
-/* zlib typedefs free_func which causes problems if the SSL includes happen
- * after zlib.h is included */
-# include <openssl/ssl.h>
-#endif
-
-#ifdef regex_t
-#undef regex_t
-#endif
-
-#include "httpd.h"
-#include "http_config.h"
-
-#if MODULE_MAGIC_NUMBER > 19980712
-# include "ap_compat.h"
-#else
-# if MODULE_MAGIC_NUMBER > 19980324
-# include "compat.h"
-# endif
-#endif
-
-#include "http_core.h"
-#include "http_main.h"
-#include "http_protocol.h"
-#include "http_request.h"
-#include "http_log.h"
-#include "util_script.h"
-
-#include "php_variables.h"
-#include "php_main.h"
-#include "php_ini.h"
-#include "ext/standard/php_standard.h"
-
-#include "mod_php7.h"
diff --git a/sapi/apache/sapi_apache.c b/sapi/apache/sapi_apache.c
deleted file mode 100644
index 302055ef25..0000000000
--- a/sapi/apache/sapi_apache.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@php.net> |
- | (with helpful hints from Dean Gaudet <dgaudet@arctic.org> |
- | PHP 4.0 patches by: |
- | Zeev Suraski <zeev@zend.com> |
- | Stig Bakken <ssb@php.net> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include "php_apache_http.h"
-
-/* {{{ apache_php_module_main
- */
-int apache_php_module_main(request_rec *r, int display_source_mode)
-{
- int retval = OK;
- zend_file_handle file_handle;
-
- if (php_request_startup() == FAILURE) {
- return FAILURE;
- }
- /* sending a file handle to another dll is not working
- so let zend open it. */
-
- if (display_source_mode) {
- zend_syntax_highlighter_ini syntax_highlighter_ini;
-
- php_get_highlight_struct(&syntax_highlighter_ini);
- if (highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini) != SUCCESS) {
- retval = NOT_FOUND;
- }
- } else {
- file_handle.type = ZEND_HANDLE_FILENAME;
- file_handle.handle.fd = 0;
- file_handle.filename = SG(request_info).path_translated;
- file_handle.opened_path = NULL;
- file_handle.free_filename = 0;
-
- (void) php_execute_script(&file_handle);
- }
-
- AP(in_request) = 0;
-
- zend_try {
- php_request_shutdown(NULL);
- } zend_end_try();
-
- return retval;
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/sapi/apache2filter/CREDITS b/sapi/apache2filter/CREDITS
deleted file mode 100644
index c298a9bf6a..0000000000
--- a/sapi/apache2filter/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-Apache 2.0 Filter
-Sascha Schumann, Aaron Bannert
diff --git a/sapi/apache2filter/EXPERIMENTAL b/sapi/apache2filter/EXPERIMENTAL
deleted file mode 100644
index 293159a693..0000000000
--- a/sapi/apache2filter/EXPERIMENTAL
+++ /dev/null
@@ -1,5 +0,0 @@
-this module is experimental,
-its functions may change their names
-or move to extension all together
-so do not rely to much on them
-you have been warned!
diff --git a/sapi/apache2filter/README b/sapi/apache2filter/README
deleted file mode 100644
index bd6eb17066..0000000000
--- a/sapi/apache2filter/README
+++ /dev/null
@@ -1,71 +0,0 @@
-WHAT IS THIS?
-
- This module exploits the layered I/O support in Apache 2.0.
-
-HOW DOES IT WORK?
-
- In Apache 2.0, you have handlers which generate content (like
- reading a script from disk). The content goes then through
- a chain of filters. PHP can be such a filter, so that it processes
- your script and hands the output to the next filter (which will
- usually cause a write to the network).
-
-DOES IT WORK?
-
- It is experimental as interfaces in Apache 2.0 might change in the
- future.
-
-HOW TO INSTALL
-
- This SAPI module is known to work with Apache 2.0.40.
-
- $ cd apache-2.x
- $ cd src
- $ ./configure --enable-so
- $ make install
-
- For testing purposes, you might want to use --with-mpm=prefork.
- (Albeit PHP also works with threaded MPMs.)
-
- Configure PHP 4:
-
- $ cd php-4.x
- $ ./configure --with-apxs2=/path/to/apache-2.0/bin/apxs
- $ make install
-
- At the end of conf/httpd.conf, add:
-
- AddType application/x-httpd-php .php
-
- If you would like to enable source code highlighting functionality add:
-
- AddType application/x-httpd-php-source .phps
-
- That's it. Now start bin/httpd.
-
-HOW TO CONFIGURE
-
- The Apache 2.0 PHP module supports a new configuration directive that
- allows an admin to override the php.ini search path. For example,
- place your php.ini file in Apache's ServerRoot/conf directory and
- add this to your httpd.conf file:
-
- PHPINIDir "conf"
-
-DEBUGGING APACHE AND PHP
-
- To debug Apache, we recommend:
-
- 1. Use the Prefork MPM (Apache 1.3-like process model) by
- configuring Apache with '--with-mpm=prefork'.
- 2. Start httpd using -DONE_PROCESS (e.g. (gdb) r -DONE_PROCESS).
-
- If you want to debug a part of the PHP startup procedure, set a
- breakpoint on 'load_module'. Step through it until apr_dso_load() is
- done. Then you can set a breakpoint on any PHP-related symbol.
-
-TODO
-
- PHP functions like apache_sub_req (see php_functions.c)
- Protocol handlers
- Passing script data to engine without temporary file
diff --git a/sapi/apache2filter/apache_config.c b/sapi/apache2filter/apache_config.c
deleted file mode 100644
index ed27616d16..0000000000
--- a/sapi/apache2filter/apache_config.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.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> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
-
-#include "php.h"
-#include "php_ini.h"
-#include "php_apache.h"
-
-#include "apr_strings.h"
-#include "ap_config.h"
-#include "util_filter.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_request.h"
-#include "http_core.h"
-#include "http_protocol.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "util_script.h"
-#include "http_core.h"
-
-#ifdef PHP_AP_DEBUG
-#define phpapdebug(a) fprintf a
-#else
-#define phpapdebug(a)
-#endif
-
-typedef struct {
- HashTable config;
-} php_conf_rec;
-
-typedef struct {
- char *value;
- size_t value_len;
- char status;
- char htaccess;
-} php_dir_entry;
-
-static const char *real_value_hnd(cmd_parms *cmd, void *dummy, const char *name, const char *value, int status)
-{
- php_conf_rec *d = dummy;
- php_dir_entry e;
-
- phpapdebug((stderr, "Getting %s=%s for %p (%d)\n", name, value, dummy, zend_hash_num_elements(&d->config)));
-
- if (!strncasecmp(value, "none", sizeof("none"))) {
- value = "";
- }
-
- e.value = apr_pstrdup(cmd->pool, value);
- e.value_len = strlen(value);
- e.status = status;
- e.htaccess = ((cmd->override & (RSRC_CONF|ACCESS_CONF)) == 0);
-
- zend_hash_update(&d->config, (char *) name, strlen(name) + 1, &e, sizeof(e), NULL);
- return NULL;
-}
-
-static const char *php_apache_value_handler(cmd_parms *cmd, void *dummy, const char *name, const char *value)
-{
- return real_value_hnd(cmd, dummy, name, value, PHP_INI_PERDIR);
-}
-
-static const char *php_apache_admin_value_handler(cmd_parms *cmd, void *dummy, const char *name, const char *value)
-{
- return real_value_hnd(cmd, dummy, name, value, PHP_INI_SYSTEM);
-}
-
-static const char *real_flag_hnd(cmd_parms *cmd, void *dummy, const char *arg1, const char *arg2, int status)
-{
- char bool_val[2];
-
- if (!strcasecmp(arg2, "On") || (arg2[0] == '1' && arg2[1] == '\0')) {
- bool_val[0] = '1';
- } else {
- bool_val[0] = '0';
- }
- bool_val[1] = 0;
-
- return real_value_hnd(cmd, dummy, arg1, bool_val, status);
-}
-
-static const char *php_apache_flag_handler(cmd_parms *cmd, void *dummy, const char *name, const char *value)
-{
- return real_flag_hnd(cmd, dummy, name, value, PHP_INI_PERDIR);
-}
-
-static const char *php_apache_admin_flag_handler(cmd_parms *cmd, void *dummy, const char *name, const char *value)
-{
- return real_flag_hnd(cmd, dummy, name, value, PHP_INI_SYSTEM);
-}
-
-static const char *php_apache_phpini_set(cmd_parms *cmd, void *mconfig, const char *arg)
-{
- if (apache2_php_ini_path_override) {
- return "Only first PHPINIDir directive honored per configuration tree - subsequent ones ignored";
- }
- apache2_php_ini_path_override = ap_server_root_relative(cmd->pool, arg);
- return NULL;
-}
-
-
-void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf)
-{
- php_conf_rec *d = base_conf, *e = new_conf, *n = NULL;
- php_dir_entry *pe;
- php_dir_entry *data;
- char *str;
- uint str_len;
- ulong num_index;
-
- n = create_php_config(p, "merge_php_config");
- zend_hash_copy(&n->config, &e->config, NULL, NULL, sizeof(php_dir_entry));
-
- phpapdebug((stderr, "Merge dir (%p)+(%p)=(%p)\n", base_conf, new_conf, n));
- for (zend_hash_internal_pointer_reset(&d->config);
- zend_hash_get_current_key(&d->config, &str, &str_len,
- &num_index) == HASH_KEY_IS_STRING;
- zend_hash_move_forward(&d->config)) {
- pe = NULL;
- zend_hash_get_current_data(&d->config, (void **) &data);
- if ((pe = zend_hash_find(&n->config, str, str_len) != NULL) != NULL) {
- if (pe->status >= data->status) continue;
- }
- zend_hash_update(&n->config, str, str_len, data, sizeof(*data), NULL);
- phpapdebug((stderr, "ADDING/OVERWRITING %s (%d vs. %d)\n", str, data->status, pe?pe->status:-1));
- }
-
- return n;
-}
-
-char *get_php_config(void *conf, char *name, size_t name_len)
-{
- php_conf_rec *d = conf;
- php_dir_entry *pe;
-
- if ((pe = zend_hash_find(&d->config, name, name_len)) != NULL) {
- return pe->value;
- }
-
- return "";
-}
-
-void apply_config(void *dummy)
-{
- php_conf_rec *d = dummy;
- char *str;
- uint str_len;
- php_dir_entry *data;
-
- for (zend_hash_internal_pointer_reset(&d->config);
- zend_hash_get_current_key(&d->config, &str, &str_len, NULL) == HASH_KEY_IS_STRING;
- zend_hash_move_forward(&d->config)) {
- zend_hash_get_current_data(&d->config, (void **) &data);
- phpapdebug((stderr, "APPLYING (%s)(%s)\n", str, data->value));
- if (zend_alter_ini_entry(str, str_len, data->value, data->value_len, data->status, data->htaccess?PHP_INI_STAGE_HTACCESS:PHP_INI_STAGE_ACTIVATE) == FAILURE) {
- phpapdebug((stderr, "..FAILED\n"));
- }
- }
-}
-
-const command_rec php_dir_cmds[] =
-{
- AP_INIT_TAKE2("php_value", php_apache_value_handler, NULL, OR_OPTIONS, "PHP Value Modifier"),
- AP_INIT_TAKE2("php_flag", php_apache_flag_handler, NULL, OR_OPTIONS, "PHP Flag Modifier"),
- AP_INIT_TAKE2("php_admin_value", php_apache_admin_value_handler, NULL, ACCESS_CONF|RSRC_CONF, "PHP Value Modifier (Admin)"),
- AP_INIT_TAKE2("php_admin_flag", php_apache_admin_flag_handler, NULL, ACCESS_CONF|RSRC_CONF, "PHP Flag Modifier (Admin)"),
- AP_INIT_TAKE1("PHPINIDir", php_apache_phpini_set, NULL, RSRC_CONF, "Directory containing the php.ini file"),
- {NULL}
-};
-
-static apr_status_t destroy_php_config(void *data)
-{
- php_conf_rec *d = data;
-
- phpapdebug((stderr, "Destroying config %p\n", data));
- zend_hash_destroy(&d->config);
-
- return APR_SUCCESS;
-}
-
-void *create_php_config(apr_pool_t *p, char *dummy)
-{
- php_conf_rec *newx = (php_conf_rec *) apr_pcalloc(p, sizeof(*newx));
-
- phpapdebug((stderr, "Creating new config (%p) for %s\n", newx, dummy));
- zend_hash_init(&newx->config, 0, NULL, NULL, 1);
- apr_pool_cleanup_register(p, newx, destroy_php_config, apr_pool_cleanup_null);
- return (void *) newx;
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/sapi/apache2filter/config.m4 b/sapi/apache2filter/config.m4
deleted file mode 100644
index 11cc051015..0000000000
--- a/sapi/apache2filter/config.m4
+++ /dev/null
@@ -1,139 +0,0 @@
-dnl
-dnl $Id$
-dnl
-
-PHP_ARG_WITH(apxs2filter,,
-[ --with-apxs2filter[=FILE]
- EXPERIMENTAL: Build shared Apache 2.0 Filter module. FILE is the optional
- pathname to the Apache apxs tool [apxs]], no, no)
-
-AC_MSG_CHECKING([for Apache 2.0 filter-module support via DSO through APXS])
-
-if test "$PHP_APXS2FILTER" != "no"; then
- if test "$PHP_APXS2FILTER" = "yes"; then
- APXS=apxs
- $APXS -q CFLAGS >/dev/null 2>&1
- if test "$?" != "0" && test -x /usr/sbin/apxs; then
- APXS=/usr/sbin/apxs
- fi
- else
- PHP_EXPAND_PATH($PHP_APXS2FILTER, APXS)
- fi
-
- $APXS -q CFLAGS >/dev/null 2>&1
- if test "$?" != "0"; then
- AC_MSG_RESULT()
- AC_MSG_RESULT()
- AC_MSG_RESULT([Sorry, I cannot run apxs. Possible reasons follow:])
- AC_MSG_RESULT()
- AC_MSG_RESULT([1. Perl is not installed])
- AC_MSG_RESULT([2. apxs was not found. Try to pass the path using --with-apxs2filter=/path/to/apxs])
- AC_MSG_RESULT([3. Apache was not built using --enable-so (the apxs usage page is displayed)])
- AC_MSG_RESULT()
- AC_MSG_RESULT([The output of $APXS follows:])
- $APXS -q CFLAGS
- AC_MSG_ERROR([Aborting])
- fi
-
- APXS_INCLUDEDIR=`$APXS -q INCLUDEDIR`
- APXS_BINDIR=`$APXS -q BINDIR`
- APXS_HTTPD=`$APXS -q SBINDIR`/`$APXS -q TARGET`
- APXS_CFLAGS=`$APXS -q CFLAGS`
- APU_BINDIR=`$APXS -q APU_BINDIR`
- APR_BINDIR=`$APXS -q APR_BINDIR`
-
- # Pick up ap[ru]-N-config if using httpd >=2.1
- APR_CONFIG=`$APXS -q APR_CONFIG 2>/dev/null ||
- echo $APR_BINDIR/apr-config`
- APU_CONFIG=`$APXS -q APU_CONFIG 2>/dev/null ||
- echo $APU_BINDIR/apu-config`
-
- APR_CFLAGS="`$APR_CONFIG --cppflags --includes`"
- APU_CFLAGS="`$APU_CONFIG --includes`"
-
- for flag in $APXS_CFLAGS; do
- case $flag in
- -D*) APACHE_CPPFLAGS="$APACHE_CPPFLAGS $flag";;
- esac
- done
-
- APACHE_CFLAGS="$APACHE_CPPFLAGS -I$APXS_INCLUDEDIR $APR_CFLAGS $APU_CFLAGS"
-
- # Test that we're trying to configure with apache 2.x
- PHP_AP_EXTRACT_VERSION($APXS_HTTPD)
- if test "$APACHE_VERSION" -le 2000000; then
- AC_MSG_ERROR([You have enabled Apache 2 support while your server is Apache 1.3. Please use the appropriate switch --with-apxs (without the 2)])
- elif test "$APACHE_VERSION" -lt 2000040; then
- AC_MSG_ERROR([Please note that Apache version >= 2.0.40 is required])
- fi
-
- APXS_LIBEXECDIR='$(INSTALL_ROOT)'`$APXS -q LIBEXECDIR`
- if test -z `$APXS -q SYSCONFDIR`; then
- INSTALL_IT="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
- $APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
- -i -n php7"
- else
- APXS_SYSCONFDIR='$(INSTALL_ROOT)'`$APXS -q SYSCONFDIR`
- INSTALL_IT="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
- \$(mkinstalldirs) '$APXS_SYSCONFDIR' && \
- $APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
- -S SYSCONFDIR='$APXS_SYSCONFDIR' \
- -i -a -n php7"
- fi
-
- case $host_alias in
- *aix*)
- EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-brtl -Wl,-bI:$APXS_LIBEXECDIR/httpd.exp"
- PHP_SELECT_SAPI(apache2filter, shared, sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
- INSTALL_IT="$INSTALL_IT $SAPI_LIBTOOL"
- ;;
- *darwin*)
- dnl When using bundles on Darwin, we must resolve all symbols. However,
- dnl the linker does not recursively look at the bundle loader and
- dnl pull in its dependencies. Therefore, we must pull in the APR
- dnl and APR-util libraries.
- if test -x "$APR_CONFIG"; then
- MH_BUNDLE_FLAGS="`$APR_CONFIG --ldflags --link-ld --libs`"
- fi
- if test -x "$APU_CONFIG"; then
- MH_BUNDLE_FLAGS="`$APU_CONFIG --ldflags --link-ld --libs` $MH_BUNDLE_FLAGS"
- fi
- MH_BUNDLE_FLAGS="-bundle -bundle_loader $APXS_HTTPD $MH_BUNDLE_FLAGS"
- PHP_SUBST(MH_BUNDLE_FLAGS)
- PHP_SELECT_SAPI(apache2filter, bundle, sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
- SAPI_SHARED=libs/libphp7.so
- INSTALL_IT="$INSTALL_IT $SAPI_SHARED"
- ;;
- *beos*)
- if test -f _APP_; then `rm _APP_`; fi
- `ln -s $APXS_BINDIR/httpd _APP_`
- EXTRA_LIBS="$EXTRA_LIBS _APP_"
- PHP_SELECT_SAPI(apache2filter, shared, sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
- INSTALL_IT="$INSTALL_IT $SAPI_LIBTOOL"
- ;;
- *)
- PHP_SELECT_SAPI(apache2filter, shared, sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
- INSTALL_IT="$INSTALL_IT $SAPI_LIBTOOL"
- ;;
- esac
-
- if test "$APACHE_VERSION" -lt 2004001; then
- APXS_MPM=`$APXS -q MPM_NAME`
- if test "$APXS_MPM" != "prefork" && test "$APXS_MPM" != "peruser" && test "$APXS_MPM" != "itk"; then
- PHP_BUILD_THREAD_SAFE
- fi
- else
- APACHE_THREADED_MPM=`$APXS_HTTPD -V | grep 'threaded:.*yes'`
- if test -n "$APACHE_THREADED_MPM"; then
- PHP_BUILD_THREAD_SAFE
- fi
- fi
- AC_MSG_RESULT(yes)
- PHP_SUBST(APXS)
-else
- AC_MSG_RESULT(no)
-fi
-
-dnl ## Local Variables:
-dnl ## tab-width: 4
-dnl ## End:
diff --git a/sapi/apache2filter/config.w32 b/sapi/apache2filter/config.w32
deleted file mode 100755
index 361d031074..0000000000
--- a/sapi/apache2filter/config.w32
+++ /dev/null
@@ -1,39 +0,0 @@
-// vim:ft=javascript
-// $Id$
-
-ARG_ENABLE('apache2filter', 'Build Apache 2.x filter', 'no');
-
-if (PHP_APACHE2FILTER != "no") {
- if (PHP_ZTS == "no") {
- WARNING("Apache2 module requires an --enable-zts build of PHP on windows");
- } else if (CHECK_HEADER_ADD_INCLUDE("httpd.h", "CFLAGS_APACHE2FILTER", PHP_PHP_BUILD + "\\include\\apache2") &&
- CHECK_LIB("libhttpd.lib", "apache2filter", PHP_PHP_BUILD + "\\lib\\apache2") &&
- CHECK_LIB("libapr.lib", "apache2filter", PHP_PHP_BUILD + "\\lib\\apache2") &&
- CHECK_LIB("libaprutil.lib", "apache2filter", PHP_PHP_BUILD + "\\lib\\apache2")
- ) {
- SAPI('apache2filter', 'sapi_apache2.c apache_config.c php_functions.c',
- 'php' + PHP_VERSION + 'apache2_filter.dll',
- '/D PHP_APACHE2_EXPORTS /I win32');
- } else {
- WARNING("Could not find apache2 filter libraries/headers");
- }
-}
-
-ARG_ENABLE('apache2-2filter', 'Build Apache 2.2.x filter', 'no');
-
-if (PHP_APACHE2_2FILTER != "no") {
- if (PHP_ZTS == "no") {
- WARNING("Apache2 module requires an --enable-zts build of PHP on windows");
- } else if (CHECK_HEADER_ADD_INCLUDE("httpd.h", "CFLAGS_APACHE2_2FILTER", PHP_PHP_BUILD + "\\include\\apache2_2") &&
- CHECK_LIB("libhttpd.lib", "apache2_2filter", PHP_PHP_BUILD + "\\lib\\apache2_2") &&
- CHECK_LIB("libapr-1.lib", "apache2_2filter", PHP_PHP_BUILD + "\\lib\\apache2_2") &&
- CHECK_LIB("libaprutil-1.lib", "apache2_2filter", PHP_PHP_BUILD + "\\lib\\apache2_2")
- ) {
- SAPI('apache2_2filter', 'sapi_apache2.c apache_config.c php_functions.c',
- 'php' + PHP_VERSION + 'apache2_2_filter.dll',
- '/D PHP_APACHE2_EXPORTS /I win32',
- 'sapi\\apache2_2filter');
- } else {
- WARNING("Could not find apache2.2 filter libraries/headers");
- }
-}
diff --git a/sapi/apache2filter/php.sym b/sapi/apache2filter/php.sym
deleted file mode 100644
index 1469b0314d..0000000000
--- a/sapi/apache2filter/php.sym
+++ /dev/null
@@ -1 +0,0 @@
-php7_module
diff --git a/sapi/apache2filter/php_apache.h b/sapi/apache2filter/php_apache.h
deleted file mode 100644
index 72d4896820..0000000000
--- a/sapi/apache2filter/php_apache.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.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> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef PHP_APACHE_H
-#define PHP_APACHE_H
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-
-/* Declare this so we can get to it from outside the sapi_apache2.c file */
-extern module AP_MODULE_DECLARE_DATA php7_module;
-
-/* A way to specify the location of the php.ini dir in an apache directive */
-extern char *apache2_php_ini_path_override;
-
-/* The server_context used by PHP */
-typedef struct php_struct {
- int state;
- request_rec *r;
- ap_filter_t *f; /* downstream output filters after the PHP filter. */
- /* stat structure of the current file */
- struct stat finfo;
- /* Set-aside request body bucket brigade */
- apr_bucket_brigade *post_data;
- /* Whether or not we've processed PHP in the output filters yet. */
- int request_processed;
-} php_struct;
-
-typedef struct _php_apr_bucket_brigade {
- apr_bucket_brigade *bb;
-} php_apr_bucket_brigade;
-
-void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf);
-void *create_php_config(apr_pool_t *p, char *dummy);
-char *get_php_config(void *conf, char *name, size_t name_len);
-void apply_config(void *);
-extern const command_rec php_dir_cmds[];
-
-static size_t php_apache_read_stream(void *, char *, size_t);
-static size_t php_apache_fsizer_stream(void *);
-
-#define APR_ARRAY_FOREACH_OPEN(arr, key, val) \
-{ \
- apr_table_entry_t *elts; \
- int i; \
- elts = (apr_table_entry_t *) arr->elts; \
- for (i = 0; i < arr->nelts; i++) { \
- key = elts[i].key; \
- val = elts[i].val;
-
-#define APR_ARRAY_FOREACH_CLOSE() }}
-
-/* fix for gcc4 visibility patch */
-#ifndef PHP_WIN32
-# undef AP_MODULE_DECLARE_DATA
-# define AP_MODULE_DECLARE_DATA PHPAPI
-#endif
-
-#endif /* PHP_APACHE_H */
diff --git a/sapi/apache2filter/php_functions.c b/sapi/apache2filter/php_functions.c
deleted file mode 100644
index 061fc7b26c..0000000000
--- a/sapi/apache2filter/php_functions.c
+++ /dev/null
@@ -1,425 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.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> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-
-#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
-
-#include "php.h"
-#include "zend_smart_str.h"
-#include "ext/standard/info.h"
-#include "SAPI.h"
-
-#define CORE_PRIVATE
-#include "apr_strings.h"
-#include "apr_time.h"
-#include "ap_config.h"
-#include "util_filter.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_request.h"
-#include "http_core.h"
-#include "http_protocol.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "util_script.h"
-#include "http_core.h"
-
-#include "php_apache.h"
-
-static request_rec *php_apache_lookup_uri(char *filename)
-{
- php_struct *ctx;
-
- if (!filename) {
- return NULL;
- }
-
- ctx = SG(server_context);
- return ap_sub_req_lookup_uri(filename, ctx->f->r, ctx->f->next);
-}
-
-/* {{{ proto bool virtual(string uri)
- Perform an apache sub-request */
-PHP_FUNCTION(virtual)
-{
- char *filename;
- int filename_len;
- request_rec *rr;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &filename, &filename_len) == FAILURE) {
- return;
- }
-
- if (!(rr = php_apache_lookup_uri(filename))) {
- php_error_docref(NULL, E_WARNING, "Unable to include '%s' - URI lookup failed", filename);
- RETURN_FALSE;
- }
-
- if (rr->status == HTTP_OK) {
- if (ap_run_sub_req(rr)) {
- php_error_docref(NULL, E_WARNING, "Unable to include '%s' - request execution failed", filename);
- ap_destroy_sub_req(rr);
- RETURN_FALSE;
- }
- ap_destroy_sub_req(rr);
- RETURN_TRUE;
- }
-
- php_error_docref(NULL, E_WARNING, "Unable to include '%s' - error finding URI", filename);
- ap_destroy_sub_req(rr);
- RETURN_FALSE;
-}
-/* }}} */
-
-#define ADD_LONG(name) \
- add_property_long(return_value, #name, rr->name)
-#define ADD_TIME(name) \
- add_property_long(return_value, #name, apr_time_sec(rr->name));
-#define ADD_STRING(name) \
- if (rr->name) add_property_string(return_value, #name, (char *) rr->name)
-
-PHP_FUNCTION(apache_lookup_uri)
-{
- request_rec *rr;
- char *filename;
- int filename_len;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &filename, &filename_len) == FAILURE) {
- return;
- }
-
- if (!(rr = php_apache_lookup_uri(filename))) {
- php_error_docref(NULL, E_WARNING, "Unable to include '%s' - URI lookup failed", filename);
- RETURN_FALSE;
- }
-
- if (rr->status == HTTP_OK) {
- object_init(return_value);
-
- ADD_LONG(status);
- ADD_STRING(the_request);
- ADD_STRING(status_line);
- ADD_STRING(method);
- ADD_TIME(mtime);
- ADD_LONG(clength);
-#if MODULE_MAGIC_NUMBER < 20020506
- ADD_STRING(boundary);
-#endif
- ADD_STRING(range);
- ADD_LONG(chunked);
- ADD_STRING(content_type);
- ADD_STRING(handler);
- ADD_LONG(no_cache);
- ADD_LONG(no_local_copy);
- ADD_STRING(unparsed_uri);
- ADD_STRING(uri);
- ADD_STRING(filename);
- ADD_STRING(path_info);
- ADD_STRING(args);
- ADD_LONG(allowed);
- ADD_LONG(sent_bodyct);
- ADD_LONG(bytes_sent);
- ADD_LONG(mtime);
- ADD_TIME(request_time);
-
- ap_destroy_sub_req(rr);
- return;
- }
-
- php_error_docref(NULL, E_WARNING, "Unable to include '%s' - error finding URI", filename);
- ap_destroy_sub_req(rr);
- RETURN_FALSE;
-}
-
-/* {{{ proto array getallheaders(void)
- Fetch all HTTP request headers */
-PHP_FUNCTION(apache_request_headers)
-{
- php_struct *ctx;
- const apr_array_header_t *arr;
- char *key, *val;
-
- array_init(return_value);
-
- ctx = SG(server_context);
- arr = apr_table_elts(ctx->f->r->headers_in);
-
- APR_ARRAY_FOREACH_OPEN(arr, key, val)
- if (!val) val = "";
- add_assoc_string(return_value, key, val);
- APR_ARRAY_FOREACH_CLOSE()
-}
-/* }}} */
-
-/* {{{ proto array apache_response_headers(void)
- Fetch all HTTP response headers */
-PHP_FUNCTION(apache_response_headers)
-{
- php_struct *ctx;
- const apr_array_header_t *arr;
- char *key, *val;
-
- array_init(return_value);
-
- ctx = SG(server_context);
- arr = apr_table_elts(ctx->f->r->headers_out);
-
- APR_ARRAY_FOREACH_OPEN(arr, key, val)
- if (!val) val = "";
- add_assoc_string(return_value, key, val);
- APR_ARRAY_FOREACH_CLOSE()
-}
-/* }}} */
-
-/* {{{ proto string apache_note(string note_name [, string note_value])
- Get and set Apache request notes */
-PHP_FUNCTION(apache_note)
-{
- php_struct *ctx;
- char *note_name, *note_val = NULL;
- int note_name_len, note_val_len;
- char *old_note_val=NULL;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &note_name, &note_name_len, &note_val, &note_val_len) == FAILURE) {
- return;
- }
-
- ctx = SG(server_context);
-
- old_note_val = (char *) apr_table_get(ctx->r->notes, note_name);
-
- if (note_val) {
- apr_table_set(ctx->r->notes, note_name, note_val);
- }
-
- if (old_note_val) {
- RETURN_STRING(old_note_val, 1);
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-
-
-/* {{{ proto bool apache_setenv(string variable, string value [, bool walk_to_top])
- Set an Apache subprocess_env variable */
-PHP_FUNCTION(apache_setenv)
-{
- php_struct *ctx;
- char *variable=NULL, *string_val=NULL;
- int variable_len, string_val_len;
- zend_bool walk_to_top = 0;
- int arg_count = ZEND_NUM_ARGS();
-
- if (zend_parse_parameters(arg_count, "ss|b", &variable, &variable_len, &string_val, &string_val_len, &walk_to_top) == FAILURE) {
- return;
- }
-
- ctx = SG(server_context);
-
- if (arg_count == 3 && walk_to_top) {
- while(ctx->f->r->prev) {
- ctx->f->r = ctx->f->r->prev;
- }
- }
-
- apr_table_set(ctx->r->subprocess_env, variable, string_val);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool apache_getenv(string variable [, bool walk_to_top])
- Get an Apache subprocess_env variable */
-PHP_FUNCTION(apache_getenv)
-{
- php_struct *ctx;
- char *variable=NULL;
- int variable_len;
- zend_bool walk_to_top = 0;
- int arg_count = ZEND_NUM_ARGS();
- char *env_val=NULL;
-
- if (zend_parse_parameters(arg_count, "s|b", &variable, &variable_len, &walk_to_top) == FAILURE) {
- return;
- }
-
- ctx = SG(server_context);
-
- if (arg_count == 2 && walk_to_top) {
- while(ctx->f->r->prev) {
- ctx->f->r = ctx->f->r->prev;
- }
- }
-
- env_val = (char*) apr_table_get(ctx->r->subprocess_env, variable);
- if (env_val != NULL) {
- RETURN_STRING(env_val, 1);
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-
-static char *php_apache_get_version()
-{
-#if MODULE_MAGIC_NUMBER_MAJOR >= 20060905
- return (char *) ap_get_server_banner();
-#else
- return (char *) ap_get_server_version();
-#endif
-}
-
-/* {{{ proto string apache_get_version(void)
- Fetch Apache version */
-PHP_FUNCTION(apache_get_version)
-{
- char *apv = php_apache_get_version();
-
- if (apv && *apv) {
- RETURN_STRING(apv, 1);
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto array apache_get_modules(void)
- Get a list of loaded Apache modules */
-PHP_FUNCTION(apache_get_modules)
-{
- int n;
- char *p;
-
- array_init(return_value);
-
- for (n = 0; ap_loaded_modules[n]; ++n) {
- char *s = (char *) ap_loaded_modules[n]->name;
- if ((p = strchr(s, '.'))) {
- add_next_index_stringl(return_value, s, (p - s));
- } else {
- add_next_index_string(return_value, s);
- }
- }
-}
-/* }}} */
-
-PHP_MINFO_FUNCTION(apache)
-{
- char *apv = php_apache_get_version();
- smart_str tmp1 = {0};
- int n;
- char *p;
-
- for (n = 0; ap_loaded_modules[n]; ++n) {
- char *s = (char *) ap_loaded_modules[n]->name;
- if ((p = strchr(s, '.'))) {
- smart_str_appendl(&tmp1, s, (p - s));
- } else {
- smart_str_appends(&tmp1, s);
- }
- smart_str_appendc(&tmp1, ' ');
- }
- if ((tmp1.len - 1) >= 0) {
- tmp1.c[tmp1.len - 1] = '\0';
- }
-
- php_info_print_table_start();
- if (apv && *apv) {
- php_info_print_table_row(2, "Apache Version", apv);
- }
- php_info_print_table_row(2, "Loaded Modules", tmp1.c);
- smart_str_free(&tmp1);
- php_info_print_table_end();
-}
-
-/* {{{ arginfo */
-ZEND_BEGIN_ARG_INFO_EX(arginfo_apache2filter_lookup_uri, 0, 0, 1)
- ZEND_ARG_INFO(0, filename)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_apache2filter_virtual, 0, 0, 1)
- ZEND_ARG_INFO(0, uri)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_apache2filter_getallheaders, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_apache2filter_response_headers, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_apache2filter_note, 0, 0, 1)
- ZEND_ARG_INFO(0, note_name)
- ZEND_ARG_INFO(0, note_value)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_apache2filter_setenv, 0, 0, 2)
- ZEND_ARG_INFO(0, variable)
- ZEND_ARG_INFO(0, value)
- ZEND_ARG_INFO(0, walk_to_top)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_apache2filter_getenv, 0, 0, 1)
- ZEND_ARG_INFO(0, variable)
- ZEND_ARG_INFO(0, walk_to_top)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_apache2filter_get_version, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_apache2filter_get_modules, 0)
-ZEND_END_ARG_INFO()
-/* }}} */
-
-static const zend_function_entry apache_functions[] = {
- PHP_FE(apache_lookup_uri, arginfo_apache2filter_lookup_uri)
- PHP_FE(virtual, arginfo_apache2filter_virtual)
- PHP_FE(apache_request_headers, arginfo_apache2filter_getallheaders)
- PHP_FE(apache_response_headers, arginfo_apache2filter_response_headers)
- PHP_FE(apache_setenv, arginfo_apache2filter_setenv)
- PHP_FE(apache_getenv, arginfo_apache2filter_getenv)
- PHP_FE(apache_note, arginfo_apache2filter_note)
- PHP_FE(apache_get_version, arginfo_apache2filter_get_version)
- PHP_FE(apache_get_modules, arginfo_apache2filter_get_modules)
- PHP_FALIAS(getallheaders, apache_request_headers, arginfo_apache2filter_getallheaders)
- {NULL, NULL, NULL}
-};
-
-zend_module_entry php_apache_module = {
- STANDARD_MODULE_HEADER,
- "apache2filter",
- apache_functions,
- NULL,
- NULL,
- NULL,
- NULL,
- PHP_MINFO(apache),
- NULL,
- STANDARD_MODULE_PROPERTIES
-};
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c
deleted file mode 100644
index 3b639db61a..0000000000
--- a/sapi/apache2filter/sapi_apache2.c
+++ /dev/null
@@ -1,756 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <sascha@schumann.cx> |
- | Parts based on Apache 1.3 SAPI module by |
- | Rasmus Lerdorf and Zeev Suraski |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include <fcntl.h>
-
-#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
-
-#include "php.h"
-#include "php_main.h"
-#include "php_ini.h"
-#include "php_variables.h"
-#include "SAPI.h"
-
-#include "zend_smart_str.h"
-#ifndef NETWARE
-#include "ext/standard/php_standard.h"
-#else
-#include "ext/standard/basic_functions.h"
-#endif
-
-#include "apr_strings.h"
-#include "ap_config.h"
-#include "apr_buckets.h"
-#include "util_filter.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_request.h"
-#include "http_core.h"
-#include "http_protocol.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "util_script.h"
-#include "http_core.h"
-#include "ap_mpm.h"
-
-#include "php_apache.h"
-
-/* UnixWare and Netware define shutdown to _shutdown, which causes problems later
- * on when using a structure member named shutdown. Since this source
- * file does not use the system call shutdown, it is safe to #undef it.
- */
-#undef shutdown
-
-/* A way to specify the location of the php.ini dir in an apache directive */
-char *apache2_php_ini_path_override = NULL;
-
-static int
-php_apache_sapi_ub_write(const char *str, uint str_length)
-{
- apr_bucket *b;
- apr_bucket_brigade *bb;
- apr_bucket_alloc_t *ba;
- ap_filter_t *f; /* remaining output filters */
- php_struct *ctx;
-
- ctx = SG(server_context);
- f = ctx->f;
-
- if (str_length == 0) return 0;
-
- ba = f->c->bucket_alloc;
- bb = apr_brigade_create(ctx->r->pool, ba);
-
- b = apr_bucket_transient_create(str, str_length, ba);
- APR_BRIGADE_INSERT_TAIL(bb, b);
-
- if (ap_pass_brigade(f->next, bb) != APR_SUCCESS || ctx->r->connection->aborted) {
- php_handle_aborted_connection();
- }
-
- return str_length; /* we always consume all the data passed to us. */
-}
-
-static int
-php_apache_sapi_header_handler(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers)
-{
- php_struct *ctx;
- char *val, *ptr;
-
- ctx = SG(server_context);
-
- switch(op) {
- case SAPI_HEADER_DELETE:
- apr_table_unset(ctx->r->headers_out, sapi_header->header);
- return 0;
-
- case SAPI_HEADER_DELETE_ALL:
- apr_table_clear(ctx->r->headers_out);
- return 0;
-
- case SAPI_HEADER_ADD:
- case SAPI_HEADER_REPLACE:
- val = strchr(sapi_header->header, ':');
-
- if (!val) {
- sapi_free_header(sapi_header);
- return 0;
- }
- ptr = val;
-
- *val = '\0';
-
- do {
- val++;
- } while (*val == ' ');
-
- if (!strcasecmp(sapi_header->header, "content-type"))
- ctx->r->content_type = apr_pstrdup(ctx->r->pool, val);
- else if (!strcasecmp(sapi_header->header, "content-length"))
- ap_set_content_length(ctx->r, strtol(val, (char **)NULL, 10));
- else if (op == SAPI_HEADER_REPLACE)
- apr_table_set(ctx->r->headers_out, sapi_header->header, val);
- else
- apr_table_add(ctx->r->headers_out, sapi_header->header, val);
-
- *ptr = ':';
- return SAPI_HEADER_ADD;
-
- default:
- return 0;
- }
-}
-
-static int
-php_apache_sapi_send_headers(sapi_headers_struct *sapi_headers)
-{
- php_struct *ctx = SG(server_context);
-
- ctx->r->status = SG(sapi_headers).http_response_code;
-
- return SAPI_HEADER_SENT_SUCCESSFULLY;
-}
-
-static int
-php_apache_sapi_read_post(char *buf, uint count_bytes)
-{
- apr_size_t len;
- php_struct *ctx = SG(server_context);
- apr_bucket_brigade *brigade;
- apr_bucket *partition;
-
- brigade = ctx->post_data;
- len = count_bytes;
-
- switch (apr_brigade_partition(ctx->post_data, count_bytes, &partition)) {
- case APR_SUCCESS:
- apr_brigade_flatten(ctx->post_data, buf, &len);
- brigade = apr_brigade_split(ctx->post_data, partition);
- apr_brigade_destroy(ctx->post_data);
- ctx->post_data = brigade;
- break;
- case APR_INCOMPLETE:
- apr_brigade_flatten(ctx->post_data, buf, &len);
- apr_brigade_cleanup(ctx->post_data);
- break;
- }
-
- return len;
-}
-static struct stat*
-php_apache_sapi_get_stat(void)
-{
- php_struct *ctx = SG(server_context);
-
- ctx->finfo.st_uid = ctx->r->finfo.user;
- ctx->finfo.st_gid = ctx->r->finfo.group;
- ctx->finfo.st_dev = ctx->r->finfo.device;
- ctx->finfo.st_ino = ctx->r->finfo.inode;
-#ifdef NETWARE
- ctx->finfo.st_atime.tv_sec = apr_time_sec(ctx->r->finfo.atime);
- ctx->finfo.st_mtime.tv_sec = apr_time_sec(ctx->r->finfo.mtime);
- ctx->finfo.st_ctime.tv_sec = apr_time_sec(ctx->r->finfo.ctime);
-#else
- ctx->finfo.st_atime = apr_time_sec(ctx->r->finfo.atime);
- ctx->finfo.st_mtime = apr_time_sec(ctx->r->finfo.mtime);
- ctx->finfo.st_ctime = apr_time_sec(ctx->r->finfo.ctime);
-#endif
-
- ctx->finfo.st_size = ctx->r->finfo.size;
- ctx->finfo.st_nlink = ctx->r->finfo.nlink;
-
- return &ctx->finfo;
-}
-
-static char *
-php_apache_sapi_read_cookies(void)
-{
- php_struct *ctx = SG(server_context);
- const char *http_cookie;
-
- http_cookie = apr_table_get(ctx->r->headers_in, "cookie");
-
- /* The SAPI interface should use 'const char *' */
- return (char *) http_cookie;
-}
-
-static char *
-php_apache_sapi_getenv(char *name, size_t name_len)
-{
- php_struct *ctx = SG(server_context);
- const char *env_var;
-
- env_var = apr_table_get(ctx->r->subprocess_env, name);
-
- return (char *) env_var;
-}
-
-static void
-php_apache_sapi_register_variables(zval *track_vars_array)
-{
- php_struct *ctx = SG(server_context);
- const apr_array_header_t *arr = apr_table_elts(ctx->r->subprocess_env);
- char *key, *val;
- unsigned int new_val_len;
-
- APR_ARRAY_FOREACH_OPEN(arr, key, val)
- if (!val) {
- val = "";
- }
- if (sapi_module.input_filter(PARSE_SERVER, key, &val, strlen(val), &new_val_len)) {
- php_register_variable_safe(key, val, new_val_len, track_vars_array);
- }
- APR_ARRAY_FOREACH_CLOSE()
-
- php_register_variable("PHP_SELF", ctx->r->uri, track_vars_array);
- if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", &ctx->r->uri, strlen(ctx->r->uri), &new_val_len)) {
- php_register_variable_safe("PHP_SELF", ctx->r->uri, new_val_len, track_vars_array);
- }
-}
-
-static void
-php_apache_sapi_flush(void *server_context)
-{
- php_struct *ctx;
- apr_bucket_brigade *bb;
- apr_bucket_alloc_t *ba;
- apr_bucket *b;
- ap_filter_t *f; /* output filters */
-
- ctx = server_context;
-
- /* If we haven't registered a server_context yet,
- * then don't bother flushing. */
- if (!server_context)
- return;
-
- sapi_send_headers();
-
- ctx->r->status = SG(sapi_headers).http_response_code;
- SG(headers_sent) = 1;
-
- f = ctx->f;
-
- /* Send a flush bucket down the filter chain. The current default
- * handler seems to act on the first flush bucket, but ignores
- * all further flush buckets.
- */
-
- ba = ctx->r->connection->bucket_alloc;
- bb = apr_brigade_create(ctx->r->pool, ba);
- b = apr_bucket_flush_create(ba);
- APR_BRIGADE_INSERT_TAIL(bb, b);
- if (ap_pass_brigade(f->next, bb) != APR_SUCCESS || ctx->r->connection->aborted) {
- php_handle_aborted_connection();
- }
-}
-
-static void php_apache_sapi_log_message(char *msg)
-{
- php_struct *ctx;
-
- ctx = SG(server_context);
-
- if (ctx == NULL) { /* we haven't initialized our ctx yet, oh well */
- ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, 0, NULL, "%s", msg);
- }
- else {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, ctx->r->server, "%s", msg);
- }
-}
-
-static int
-php_apache_disable_caching(ap_filter_t *f)
-{
- /* Identify PHP scripts as non-cacheable, thus preventing
- * Apache from sending a 304 status when the browser sends
- * If-Modified-Since header.
- */
- f->r->no_local_copy = 1;
-
- return OK;
-}
-
-static double php_apache_sapi_get_request_time(void)
-{
- php_struct *ctx = SG(server_context);
- return ((double) apr_time_as_msec(ctx->r->request_time)) / 1000.0;
-}
-
-extern zend_module_entry php_apache_module;
-
-static int php_apache2_startup(sapi_module_struct *sapi_module)
-{
- if (php_module_startup(sapi_module, &php_apache_module, 1)==FAILURE) {
- return FAILURE;
- }
- return SUCCESS;
-}
-
-static sapi_module_struct apache2_sapi_module = {
- "apache2filter",
- "Apache 2.0 Filter",
-
- php_apache2_startup, /* startup */
- php_module_shutdown_wrapper, /* shutdown */
-
- NULL, /* activate */
- NULL, /* deactivate */
-
- php_apache_sapi_ub_write, /* unbuffered write */
- php_apache_sapi_flush, /* flush */
- php_apache_sapi_get_stat, /* get uid */
- php_apache_sapi_getenv, /* getenv */
-
- php_error, /* error handler */
-
- php_apache_sapi_header_handler, /* header handler */
- php_apache_sapi_send_headers, /* send headers handler */
- NULL, /* send header handler */
-
- php_apache_sapi_read_post, /* read POST data */
- php_apache_sapi_read_cookies, /* read Cookies */
-
- php_apache_sapi_register_variables,
- php_apache_sapi_log_message, /* Log message */
- php_apache_sapi_get_request_time, /* Get Request Time */
- NULL, /* Child terminate */
-
- STANDARD_SAPI_MODULE_PROPERTIES
-};
-
-static int php_input_filter(ap_filter_t *f, apr_bucket_brigade *bb,
- ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes)
-{
- php_struct *ctx;
- apr_status_t rv;
-
- if (f->r->proxyreq) {
- return ap_get_brigade(f->next, bb, mode, block, readbytes);
- }
-
- ctx = SG(server_context);
- if (ctx == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, f->r,
- "php failed to get server context");
- return HTTP_INTERNAL_SERVER_ERROR;
- }
-
- if ((rv = ap_get_brigade(f->next, bb, mode, block, readbytes)) != APR_SUCCESS) {
- return rv;
- }
-
- if (!ctx->post_data) {
- ctx->post_data = apr_brigade_create(f->r->pool, f->c->bucket_alloc);
- }
- if ((rv = ap_save_brigade(f, &ctx->post_data, &bb, f->r->pool)) != APR_SUCCESS) {
- return rv;
- }
- apr_brigade_cleanup(bb);
- APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_eos_create(bb->bucket_alloc));
-
- return APR_SUCCESS;
-}
-
-static void php_apache_request_ctor(ap_filter_t *f, php_struct *ctx)
-{
- char *content_type;
- char *content_length;
- const char *auth;
-
- PG(during_request_startup) = 0;
- SG(sapi_headers).http_response_code = !f->r->status ? HTTP_OK : f->r->status;
- SG(request_info).content_type = apr_table_get(f->r->headers_in, "Content-Type");
-#undef safe_strdup
-#define safe_strdup(x) ((x)?strdup((x)):NULL)
- SG(request_info).query_string = safe_strdup(f->r->args);
- SG(request_info).request_method = f->r->method;
- SG(request_info).proto_num = f->r->proto_num;
- SG(request_info).request_uri = safe_strdup(f->r->uri);
- SG(request_info).path_translated = safe_strdup(f->r->filename);
- f->r->no_local_copy = 1;
- content_type = sapi_get_default_content_type();
- f->r->content_type = apr_pstrdup(f->r->pool, content_type);
-
- efree(content_type);
-
- content_length = (char *) apr_table_get(f->r->headers_in, "Content-Length");
- SG(request_info).content_length = (content_length ? atol(content_length) : 0);
-
- apr_table_unset(f->r->headers_out, "Content-Length");
- apr_table_unset(f->r->headers_out, "Last-Modified");
- apr_table_unset(f->r->headers_out, "Expires");
- apr_table_unset(f->r->headers_out, "ETag");
-
- auth = apr_table_get(f->r->headers_in, "Authorization");
- php_handle_auth_data(auth);
-
- if (SG(request_info).auth_user == NULL && f->r->user) {
- SG(request_info).auth_user = estrdup(f->r->user);
- }
-
- ctx->r->user = apr_pstrdup(ctx->r->pool, SG(request_info).auth_user);
-
- php_request_startup();
-}
-
-static void php_apache_request_dtor(ap_filter_t *f)
-{
- php_apr_bucket_brigade *pbb = (php_apr_bucket_brigade *)f->ctx;
-
- php_request_shutdown(NULL);
-
- if (SG(request_info).query_string) {
- free(SG(request_info).query_string);
- }
- if (SG(request_info).request_uri) {
- free(SG(request_info).request_uri);
- }
- if (SG(request_info).path_translated) {
- free(SG(request_info).path_translated);
- }
-
- apr_brigade_destroy(pbb->bb);
-}
-
-static int php_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
-{
- php_struct *ctx;
- void *conf = ap_get_module_config(f->r->per_dir_config, &php7_module);
- char *p = get_php_config(conf, "engine", sizeof("engine"));
- zend_file_handle zfd;
- php_apr_bucket_brigade *pbb;
- apr_bucket *b;
-
- if (f->r->proxyreq) {
- zend_try {
- zend_ini_deactivate();
- } zend_end_try();
- return ap_pass_brigade(f->next, bb);
- }
-
- /* handle situations where user turns the engine off */
- if (*p == '0') {
- zend_try {
- zend_ini_deactivate();
- } zend_end_try();
- return ap_pass_brigade(f->next, bb);
- }
-
- if(f->ctx) {
- pbb = (php_apr_bucket_brigade *)f->ctx;
- } else {
- pbb = f->ctx = apr_palloc(f->r->pool, sizeof(*pbb));
- pbb->bb = apr_brigade_create(f->r->pool, f->c->bucket_alloc);
- }
-
- if(ap_save_brigade(NULL, &pbb->bb, &bb, f->r->pool) != APR_SUCCESS) {
- /* Bad */
- }
-
- apr_brigade_cleanup(bb);
-
- /* Check to see if the last bucket in this brigade, it not
- * we have to wait until then. */
- if(!APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(pbb->bb))) {
- return 0;
- }
-
- /* Setup the CGI variables if this is the main request.. */
- if (f->r->main == NULL ||
- /* .. or if the sub-request envinronment differs from the main-request. */
- f->r->subprocess_env != f->r->main->subprocess_env
- ) {
- /* setup standard CGI variables */
- ap_add_common_vars(f->r);
- ap_add_cgi_vars(f->r);
- }
-
- ctx = SG(server_context);
- if (ctx == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, f->r,
- "php failed to get server context");
- zend_try {
- zend_ini_deactivate();
- } zend_end_try();
- return HTTP_INTERNAL_SERVER_ERROR;
- }
-
- ctx->f = f->next; /* save whatever filters are after us in the chain. */
-
- if (ctx->request_processed) {
- zend_try {
- zend_ini_deactivate();
- } zend_end_try();
- return ap_pass_brigade(f->next, bb);
- }
-
- apply_config(conf);
- php_apache_request_ctor(f, ctx);
-
- /* It'd be nice if we could highlight based of a zend_file_handle here....
- * ...but we can't. */
-
- zfd.type = ZEND_HANDLE_STREAM;
-
- zfd.handle.stream.handle = pbb;
- zfd.handle.stream.reader = php_apache_read_stream;
- zfd.handle.stream.closer = NULL;
- zfd.handle.stream.fsizer = php_apache_fsizer_stream;
- zfd.handle.stream.isatty = 0;
-
- zfd.filename = f->r->filename;
- zfd.opened_path = NULL;
- zfd.free_filename = 0;
-
- php_execute_script(&zfd);
-
- apr_table_set(ctx->r->notes, "mod_php_memory_usage",
- apr_psprintf(ctx->r->pool, "%lu", (unsigned long) zend_memory_peak_usage(1)));
-
- php_apache_request_dtor(f);
-
- if (!f->r->main) {
- ctx->request_processed = 1;
- }
-
- b = apr_bucket_eos_create(f->c->bucket_alloc);
- APR_BRIGADE_INSERT_TAIL(pbb->bb, b);
-
- /* Pass whatever is left on the brigade. */
- return ap_pass_brigade(f->next, pbb->bb);
-}
-
-static apr_status_t
-php_apache_server_shutdown(void *tmp)
-{
- apache2_sapi_module.shutdown(&apache2_sapi_module);
- sapi_shutdown();
-#ifdef ZTS
- tsrm_shutdown();
-#endif
- return APR_SUCCESS;
-}
-
-static void php_apache_add_version(apr_pool_t *p)
-{
- if (PG(expose_php)) {
- ap_add_version_component(p, "PHP/" PHP_VERSION);
- }
-}
-
-static int php_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp)
-{
-#ifndef ZTS
- int threaded_mpm;
-
- ap_mpm_query(AP_MPMQ_IS_THREADED, &threaded_mpm);
- if(threaded_mpm) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, 0, 0, "Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP.");
- return DONE;
- }
-#endif
- /* When this is NULL, apache won't override the hard-coded default
- * php.ini path setting. */
- apache2_php_ini_path_override = NULL;
- return OK;
-}
-
-static int
-php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog,
- apr_pool_t *ptemp, server_rec *s)
-{
- void *data = NULL;
- const char *userdata_key = "apache2filter_post_config";
-
- /* Apache will load, unload and then reload a DSO module. This
- * prevents us from starting PHP until the second load. */
- apr_pool_userdata_get(&data, userdata_key, s->process->pool);
- if (data == NULL) {
- /* We must use set() here and *not* setn(), otherwise the
- * static string pointed to by userdata_key will be mapped
- * to a different location when the DSO is reloaded and the
- * pointers won't match, causing get() to return NULL when
- * we expected it to return non-NULL. */
- apr_pool_userdata_set((const void *)1, userdata_key,
- apr_pool_cleanup_null, s->process->pool);
- return OK;
- }
-
- /* Set up our overridden path. */
- if (apache2_php_ini_path_override) {
- apache2_sapi_module.php_ini_path_override = apache2_php_ini_path_override;
- }
-#ifdef ZTS
- tsrm_startup(1, 1, 0, NULL);
-#endif
- sapi_startup(&apache2_sapi_module);
- apache2_sapi_module.startup(&apache2_sapi_module);
- apr_pool_cleanup_register(pconf, NULL, php_apache_server_shutdown, apr_pool_cleanup_null);
- php_apache_add_version(pconf);
-
- return OK;
-}
-
-static void php_add_filter(request_rec *r, ap_filter_t *f)
-{
- int output = (f == r->output_filters);
-
- /* for those who still have Set*Filter PHP configured */
- while (f) {
- if (strcmp(f->frec->name, "PHP") == 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING,
- 0, r->server,
- "\"Set%sFilter PHP\" already configured for %s",
- output ? "Output" : "Input", r->uri);
- return;
- }
- f = f->next;
- }
-
- if (output) {
- ap_add_output_filter("PHP", NULL, r, r->connection);
- } else {
- ap_add_input_filter("PHP", NULL, r, r->connection);
- }
-}
-
-static void php_insert_filter(request_rec *r)
-{
- int content_type_len = strlen("application/x-httpd-php");
-
- if (r->content_type && !strncmp(r->content_type, "application/x-httpd-php", content_type_len-1)) {
- if (r->content_type[content_type_len] == '\0' || !strncmp(r->content_type+content_type_len, "-source", sizeof("-source"))) {
- php_add_filter(r, r->output_filters);
- php_add_filter(r, r->input_filters);
- }
- }
-}
-
-static apr_status_t php_server_context_cleanup(void *data_)
-{
- void **data = data_;
- *data = NULL;
- return APR_SUCCESS;
-}
-
-static int php_post_read_request(request_rec *r)
-{
- php_struct *ctx;
-
- /* Initialize filter context */
- SG(server_context) = ctx = apr_pcalloc(r->pool, sizeof(*ctx));
-
- /* register a cleanup so we clear out the SG(server_context)
- * after each request. Note: We pass in the pointer to the
- * server_context in case this is handled by a different thread. */
- apr_pool_cleanup_register(r->pool, (void *)&SG(server_context),
- php_server_context_cleanup,
- apr_pool_cleanup_null);
-
- /* Save the entire request, so we can get the input or output
- * filters if we need them. */
- ctx->r = r;
-
- return OK;
-}
-
-static void php_register_hook(apr_pool_t *p)
-{
- ap_hook_pre_config(php_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
- ap_hook_post_config(php_apache_server_startup, NULL, NULL, APR_HOOK_MIDDLE);
- ap_hook_insert_filter(php_insert_filter, NULL, NULL, APR_HOOK_MIDDLE);
- ap_hook_post_read_request(php_post_read_request, NULL, NULL, APR_HOOK_MIDDLE);
- ap_register_output_filter("PHP", php_output_filter, php_apache_disable_caching, AP_FTYPE_RESOURCE);
- ap_register_input_filter("PHP", php_input_filter, php_apache_disable_caching, AP_FTYPE_RESOURCE);
-}
-
-static size_t php_apache_read_stream(void *handle, char *buf, size_t wantlen)
-{
- php_apr_bucket_brigade *pbb = (php_apr_bucket_brigade *)handle;
- apr_bucket_brigade *rbb;
- apr_size_t readlen;
- apr_bucket *b = NULL;
-
- rbb = pbb->bb;
-
- if((apr_brigade_partition(pbb->bb, wantlen, &b) == APR_SUCCESS) && b){
- pbb->bb = apr_brigade_split(rbb, b);
- }
-
- readlen = wantlen;
- apr_brigade_flatten(rbb, buf, &readlen);
- apr_brigade_cleanup(rbb);
-
- return readlen;
-}
-
-static size_t php_apache_fsizer_stream(void *handle)
-{
- php_apr_bucket_brigade *pbb = (php_apr_bucket_brigade *)handle;
- apr_off_t actual = 0;
-
- if (apr_brigade_length(pbb->bb, 1, &actual) == APR_SUCCESS) {
- return actual;
- }
-
- return 0;
-}
-
-AP_MODULE_DECLARE_DATA module php7_module = {
- STANDARD20_MODULE_STUFF,
- create_php_config, /* create per-directory config structure */
- merge_php_config, /* merge per-directory config structures */
- NULL, /* create per-server config structure */
- NULL, /* merge per-server config structures */
- php_dir_cmds, /* command apr_table_t */
- php_register_hook /* register hooks */
-};
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/sapi/apache_hooks/CREDITS b/sapi/apache_hooks/CREDITS
deleted file mode 100644
index 86ac27d0b7..0000000000
--- a/sapi/apache_hooks/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-Apache 1.3 (apache_hooks)
-Rasmus Lerdorf, Zeev Suraski, Stig Bakken, David Sklar, George Schlossnagle, Lukas Schroeder
diff --git a/sapi/apache_hooks/README b/sapi/apache_hooks/README
deleted file mode 100644
index 9a5a3e2b64..0000000000
--- a/sapi/apache_hooks/README
+++ /dev/null
@@ -1,206 +0,0 @@
-This is very beta documentation. Clearly better stuff can and will follow.
-
-INTRO:
-
-apache_hooks is a full super-set enhancement of the apache 1.3 sapi that allows for
-php code to be run on the apache request object at every stage of the apache
-request. It supports all of the apache 1.3 sapi commands and configurations, and
-additionally supports the following httpd.conf directives:
-
-
-HTTPD.CONF DIRECTIEVS:
-
-phpRequire /path/to/file = requires a file at the beginning of an
-initial apache request
-
-phpUriHandler /path/to/file = registers a hook that will run the
-specified file at the uri translation stage of the apache request
-phpUriHandler Class::Method = registers a hook to run Class::Method at
-the uri translation stage of the apache request
-
-phpPostReadHandler /path/to/file = hook for post-read phase
-phpPostReadHandlerMethod Class::Method
-
-phpHeaderHandler = hook for header parsing phase
-phpHeaderHandlerMethod
-
-phpAuthHandler = hook for authentication phase
-phpAuthHandlerMethod
-
-phpAccessHandler = hook for access control phase
-phpAccessHandlerMethod
-
-phpTypeHandler = hook for Type Checking phase
-phpTypeHandlerMethod
-
-phpFixupHandler = hook for 'fixup' phase
-phpFixupHandlerMethod
-
-phpLoggerHandler = hook for logging phase
-phpLoggerHandlerMethod
-
-AddHandler php-script = set's up a special type handler
-phpResponseHandler /path/to/file = sets file to be called to handle
-response phase
-phpResponseHandlerMethod Class::Method
-
-
-All handlers may be stacked, i.e. you can list multiple handler directives
-in a single scope and they will be run in order.
-
-
-EXAMPLES:
-
-So, to set up a 'hello world' location handler (so that any request to
-/hello/* returns hello world) you can:
-
-phpRequire /tmp/setup.php
-<Location /hello>
-AddHandler php-script
-phpResponseHandlerMethod Hello::World
-</Location>
-
-with
-#/tmp/setup.php
-<?
-class Hello {
- function World() {
- global $request;
- $request->send_http_header();
- echo "Hello World";
- }
-}
-?>
-
-$request is the apache request. It is instantiated at all stages
-automatically. The methods of that class are:
-
-getallheaders
-args
-boundary
-content_encoding
-content_type
-filename
-handler
-hostname
-method
-path_info
-protocol
-status_line
-the_request
-unparsed_uri
-uri
-allowed
-bytes_sent
-chunked
-content_length
-header_only
-method_number
-mtime
-no_cache
-no_local_copy
-proto_num
-proxyreq
-read_body
-remaining
-request_time
-status
-headers_in
-headers_out
-err_headers_out
-auth_name
-auth_type
-basic_auth_pw
-discard_request_body
-is_initial_req
-meets_conditions
-remote_host
-satisfies
-server_port
-set_etag
-set_last_modified
-some_auth_required
-update_mtime
-send_http_header
-basic_http_header
-send_header_field
-send_http_trace
-send_http_options
-send_error_response
-set_content_length
-set_keepalive
-rputs
-log_error
-lookup_uri
-lookup_file
-method_uri
-run
-internal_redirect
-
-
-These all wrap the ap_* apache EXPORT_API functions using the same
-semantics (and are also the same as the Apache::Request methods in
-mod_perl if you are familiar with that)
-
-So, a uri handler to redirect all non-local traffic to /404.php (an
-error page) would be
-
-phpUriHandler /tmp/uri.php
-
-#/tmp/uri.php
-<?
- if($REMOTE_ADDR != '127.0.0.1') {
- $request->uri('/404.php');
- }
- return OK;
-?>
-
-It's important to note that since this is called from the uri
-translations phase, this validation is performed for every request to
-the server, not just for php pages.
-
-Also, scope is shared between all the hooks. So in the above, we could
-merge the two and do something like:
-
-#/tmp/uri.php
-<?
- if($REMOTE_ADDR != '127.0.0.1') {
- $whoami = 'Stranger';
- }
- else {
- $whoami = 'Friend';
- }
- return DECLINED; # because we're not redirecting, just messing around
-?>
-
-and then:
-
-#/tmp/setup.php
-<?
-class Hello {
- function World() {
- global $request;
- global $whoami;
- $request->send_http_header();
- echo "Hello $whoami";
- }
-}
-?>
-
-These variables are also in the same scope as a script if your script is
-being handled by the standard application/x-httpd-php handler.
-
-This allows you to make decisions and pass data between your handlers
-and scripts at all stages.
-
-The above are clearly trite examples, but hopefully give you a starting
-point.
-
-One note: all handlers can be validly re-entered 'in sub-requests'.
-For this reason you should not define functions/classes here without
-anti-redefinition guards (I would just recommend putting them in an
-include and using include_one). This is not true for phpRequire, which
-is only entered once, at the main request, and so it is safe to make
-function/class declarations there (in fact that's what it's for).
-
-Hope that helps!
diff --git a/sapi/apache_hooks/apMakefile.libdir b/sapi/apache_hooks/apMakefile.libdir
deleted file mode 100644
index 7b5254013a..0000000000
--- a/sapi/apache_hooks/apMakefile.libdir
+++ /dev/null
@@ -1,4 +0,0 @@
-This is a place-holder which indicates to Configure that it shouldn't
-provide the default targets when building the Makefile in this directory.
-Instead it'll just prepend all the important variable definitions, and
-copy the Makefile.tmpl onto the end.
diff --git a/sapi/apache_hooks/apMakefile.tmpl b/sapi/apache_hooks/apMakefile.tmpl
deleted file mode 100644
index 1e5e465f65..0000000000
--- a/sapi/apache_hooks/apMakefile.tmpl
+++ /dev/null
@@ -1,77 +0,0 @@
-##
-## Apache 1.3 Makefile template for PHP 4.0 Module
-## [src/modules/php7/Makefile.tmpl]
-##
-
-# the parametrized target
-LIB=libphp7.$(LIBEXT)
-
-# objects for building the static library
-OBJS=mod_php7.o
-OBJS_LIB=libmodphp7.a
-
-# objects for building the shared object library
-SHLIB_OBJS=mod_php7.so-o
-SHLIB_OBJS_LIB=libmodphp7.a
-
-# the general targets
-all: lib
-lib: $(LIB)
-
-# build the static library by merging the object files
-libphp7.a: $(OBJS) $(OBJS_LIB)
- cp $(OBJS_LIB) $@
- ar r $@ $(OBJS)
- $(RANLIB) $@
-
-# ugly hack to support older Apache-1.3 betas that don't set $LIBEXT
-libphp7.: $(OBJS) $(OBJS_LIB)
- cp $(OBJS_LIB) $@
- ar r $@ $(OBJS)
- $(RANLIB) $@
- cp libphp7. libphp7.a
-
-# build the shared object library by linking the object files
-libphp7.so: $(SHLIB_OBJS) $(SHLIB_OBJS_LIB)
- rm -f $@
- $(LD_SHLIB) $(LDFLAGS_SHLIB) -o $@ $(SHLIB_OBJS) $(SHLIB_OBJS_LIB) $(LIBS) $(PHP_LIBS)
-
-# 1. extension .o for shared objects cannot be used here because
-# first these files aren't still shared objects and second we
-# have to use a different name to trigger the different
-# implicit Make rule
-# 2. extension -so.o (as used elsewhere) cannot be used because
-# the suffix feature of Make really wants just .x, so we use
-# extension .so-o
-.SUFFIXES: .o .so-o
-.c.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(PHP_CFLAGS) $(CPPFLAGS) $(SPACER) $<
-.c.so-o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(CFLAGS_SHLIB) $(PHP_CFLAGS) $(CPPFLAGS) $(SPACER) $< && mv $*.o $*.so-o
-
-# cleanup
-clean:
- -rm -f $(OBJS) $(SHLIB_OBJS) $(LIB)
-
-# We really don't expect end users to use this rule. It works only with
-# gcc, and rebuilds Makefile.tmpl. You have to re-run Configure after
-# using it.
-depend:
- cp Makefile.tmpl Makefile.tmpl.bak \
- && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.tmpl > Makefile.new \
- && gcc -MM $(INCLUDES) $(CFLAGS) $(PHP_CFLAGS) $(CPPFLAGS) *.c >> Makefile.new \
- && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' Makefile.new \
- > Makefile.tmpl \
- && rm Makefile.new
-
-#Dependencies
-
-$(OBJS): Makefile
-
-# DO NOT REMOVE
-mod_php7.o: mod_php7.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \
- $(INCDIR)/buff.h \
- $(INCDIR)/http_config.h \
- $(INCDIR)/http_core.h $(INCDIR)/http_main.h \
- $(INCDIR)/http_protocol.h $(INCDIR)/http_request.h \
- $(INCDIR)/http_log.h $(INCDIR)/util_script.h mod_php7.h
diff --git a/sapi/apache_hooks/config.m4 b/sapi/apache_hooks/config.m4
deleted file mode 100644
index a1ee213492..0000000000
--- a/sapi/apache_hooks/config.m4
+++ /dev/null
@@ -1,275 +0,0 @@
-dnl
-dnl $Id$
-dnl
-AC_DEFUN([PHP_APACHE_FD_CHECK], [
-AC_CACHE_CHECK([for member fd in BUFF *],ac_cv_php_fd_in_buff,[
- save=$CPPFLAGS
- if test -n "$APXS_INCLUDEDIR"; then
- CPPFLAGS="$CPPFLAGS -I$APXS_INCLUDEDIR"
- else
- CPPFLAGS="$CPPFLAGS $APACHE_INCLUDE"
- fi
- AC_TRY_COMPILE([#include <httpd.h>],[conn_rec *c; int fd = c->client->fd;],[
- ac_cv_php_fd_in_buff=yes],[ac_cv_php_fd_in_buff=no],[ac_cv_php_fd_in_buff=no])
- CPPFLAGS=$save
-])
-if test "$ac_cv_php_fd_in_buff" = "yes"; then
- AC_DEFINE(PHP_APACHE_HAVE_CLIENT_FD,1,[ ])
-fi
-])
-
-dnl Apache 1.x shared module
-PHP_ARG_WITH(apache-hooks,,
-[ --with-apache-hooks[=FILE]
- EXPERIMENTAL: Build shared Apache 1.x module. FILE is the optional
- pathname to the Apache apxs tool [apxs]], no, no)
-
-AC_MSG_CHECKING([for Apache 1.x (hooks) module support via DSO through APXS])
-
-if test "$PHP_APACHE_HOOKS" != "no"; then
- if test "$PHP_APACHE_HOOKS" = "yes"; then
- APXS=apxs
- $APXS -q CFLAGS >/dev/null 2>&1
- if test "$?" != "0" && test -x /usr/sbin/apxs; then #SUSE 6.x
- APXS=/usr/sbin/apxs
- fi
- else
- PHP_EXPAND_PATH($PHP_APACHE_HOOKS, APXS)
- fi
-
- $APXS -q CFLAGS >/dev/null 2>&1
- if test "$?" != "0"; then
- AC_MSG_RESULT()
- AC_MSG_RESULT()
- AC_MSG_RESULT([Sorry, I was not able to successfully run APXS. Possible reasons:])
- AC_MSG_RESULT()
- AC_MSG_RESULT([1. Perl is not installed;])
- AC_MSG_RESULT([2. Apache was not compiled with DSO support (--enable-module=so);])
- AC_MSG_RESULT([3. 'apxs' is not in your path. Try to use --with-apxs=/path/to/apxs])
- AC_MSG_RESULT([The output of $APXS follows])
- $APXS -q CFLAGS
- AC_MSG_ERROR([Aborting])
- fi
-
- APXS_LDFLAGS="@SYBASE_LFLAGS@ @SYBASE_LIBS@ @SYBASE_CT_LFLAGS@ @SYBASE_CT_LIBS@"
- APXS_INCLUDEDIR=`$APXS -q INCLUDEDIR`
- APXS_CFLAGS=`$APXS -q CFLAGS`
- APXS_HTTPD=`$APXS -q SBINDIR`/`$APXS -q TARGET`
- APACHE_INCLUDE=-I$APXS_INCLUDEDIR
-
- # Test that we're trying to configure with apache 1.x
- PHP_AP_EXTRACT_VERSION($APXS_HTTPD)
- if test "$APACHE_VERSION" -ge 2000000; then
- AC_MSG_ERROR([You have enabled Apache 1.3 support while your server is Apache 2. Please use the appropriate switch --with-apxs2])
- fi
-
- for flag in $APXS_CFLAGS; do
- case $flag in
- -D*) APACHE_CPPFLAGS="$APACHE_CPPFLAGS $flag";;
- esac
- done
-
- case $host_alias in
- *aix*)
- APXS_LIBEXECDIR=`$APXS -q LIBEXECDIR`
- EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-brtl -Wl,-bI:$APXS_LIBEXECDIR/httpd.exp"
- PHP_AIX_LDFLAGS="-Wl,-brtl"
- build_type=shared
- ;;
- *darwin*)
- MH_BUNDLE_FLAGS="-dynamic -twolevel_namespace -bundle -bundle_loader $APXS_HTTPD"
- PHP_SUBST(MH_BUNDLE_FLAGS)
- SAPI_SHARED=libs/libphp7.so
- build_type=bundle
- ;;
- *)
- build_type=shared
- ;;
- esac
-
- PHP_SELECT_SAPI(apache_hooks, $build_type, sapi_apache.c mod_php7.c php_apache.c, $APACHE_CPPFLAGS -I$APXS_INCLUDEDIR)
-
- # Test whether apxs support -S option
- $APXS -q -S CFLAGS="$APXS_CFLAGS" CFLAGS >/dev/null 2>&1
-
- if test "$?" != "0"; then
- APACHE_HOOKS_INSTALL="$APXS -i -a -n php7 $SAPI_SHARED" # Old apxs does not have -S option
- else
- APXS_LIBEXECDIR='$(INSTALL_ROOT)'`$APXS -q LIBEXECDIR`
- if test -z `$APXS -q SYSCONFDIR`; then
- APACHE_HOOKS_INSTALL="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
- $APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
- -i -n php7 $SAPI_SHARED"
- else
- APXS_SYSCONFDIR='$(INSTALL_ROOT)'`$APXS -q SYSCONFDIR`
- APACHE_HOOKS_INSTALL="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
- \$(mkinstalldirs) '$APXS_SYSCONFDIR' && \
- $APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
- -S SYSCONFDIR='$APXS_SYSCONFDIR' \
- -i -a -n php7 $SAPI_SHARED"
- fi
- fi
-
- if test -z "`$APXS -q LD_SHLIB`" || test "`$APXS -q LIBEXECDIR`" = "modules"; then
- PHP_APXS_BROKEN=yes
- fi
- STRONGHOLD=
- AC_DEFINE(HAVE_AP_CONFIG_H,1,[ ])
- AC_DEFINE(HAVE_AP_COMPAT_H,1,[ ])
- AC_DEFINE(HAVE_APACHE_HOOKS,1,[ ])
- AC_MSG_RESULT(yes)
-else
- AC_MSG_RESULT(no)
-fi
-
-dnl Apache 1.x static module
-PHP_ARG_WITH(apache-hooks-static,,
-[ --with-apache-hooks-static[=DIR]
- EXPERIMENTAL: Build Apache 1.x module. DIR is the top-level Apache
- build directory [/usr/local/apache]], no, no)
-
-AC_MSG_CHECKING(for Apache 1.x (hooks) module support)
-
-if test "$PHP_SAPI" != "apache" && test "$PHP_SAPI" != "apache_hooks" && test "$PHP_APACHE_HOOKS_STATIC" != "no"; then
-
- if test "$PHP_APACHE_HOOKS_STATIC" = "yes"; then
- # Apache's default directory
- PHP_APACHE_HOOKS_STATIC=/usr/local/apache
- fi
-
- APACHE_HOOKS_INSTALL_FILES="\$(srcdir)/sapi/apache_hooks/mod_php7.* sapi/apache_hooks/libphp7.module"
-
- AC_DEFINE(HAVE_APACHE,1,[ ])
- APACHE_HOOKS_MODULE=yes
- PHP_EXPAND_PATH($PHP_APACHE_HOOKS_STATIC, PHP_APACHE_HOOKS_STATIC)
- # For Apache 1.2.x
- if test -f $PHP_APACHE_HOOKS_STATIC/src/httpd.h; then
- APACHE_INCLUDE=-I$PHP_APACHE_HOOKS_STATIC/src
- APACHE_TARGET=$PHP_APACHE_HOOKS_STATIC/src
- PHP_SELECT_SAPI(apache_hooks, static, sapi_apache.c mod_php7.c php_apache.c, $APACHE_INCLUDE)
- APACHE_HOOKS_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_HOOKS_INSTALL_FILES $APACHE_TARGET"
- PHP_LIBS="-L. -lphp3"
- AC_MSG_RESULT([yes - Apache 1.2.x])
- STRONGHOLD=
- if test -f $PHP_APACHE_HOOKS_STATIC/src/ap_config.h; then
- AC_DEFINE(HAVE_AP_CONFIG_H,1,[ ])
- fi
- # For Apache 2.0.x
- elif test -f $PHP_APACHE_HOOKS_STATIC/include/httpd.h && test -f $PHP_APACHE_HOOKS_STATIC/srclib/apr/include/apr_general.h ; then
- AC_MSG_ERROR([Use --with-apxs2 with Apache 2.x!])
- # For Apache 1.3.x
- elif test -f $PHP_APACHE_HOOKS_STATIC/src/main/httpd.h; then
- APACHE_HAS_REGEX=1
- APACHE_INCLUDE="-I$PHP_APACHE_HOOKS_STATIC/src/main -I$PHP_APACHE_HOOKS_STATIC/src/os/unix -I$PHP_APACHE_HOOKS_STATIC/src/ap"
- APACHE_TARGET=$PHP_APACHE_HOOKS_STATIC/src/modules/php7
- if test ! -d $APACHE_TARGET; then
- mkdir $APACHE_TARGET
- fi
- PHP_SELECT_SAPI(apache_hooks, static, sapi_apache.c mod_php7.c php_apache.c, $APACHE_INCLUDE)
- APACHE_HOOKS_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp7.a; cp $APACHE_HOOKS_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache_hooks/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache_hooks/apMakefile.libdir $APACHE_TARGET/Makefile.libdir"
- PHP_LIBS="-Lmodules/php7 -L../modules/php7 -L../../modules/php7 -lmodphp7"
- AC_MSG_RESULT([yes - Apache 1.3.x])
- STRONGHOLD=
- if test -f $PHP_APACHE_HOOKS_STATIC/src/include/ap_config.h; then
- AC_DEFINE(HAVE_AP_CONFIG_H, 1, [ ])
- fi
- if test -f $PHP_APACHE_HOOKS_STATIC/src/include/ap_compat.h; then
- AC_DEFINE(HAVE_AP_COMPAT_H, 1, [ ])
- if test ! -f $PHP_APACHE_HOOKS_STATIC/src/include/ap_config_auto.h; then
- AC_MSG_ERROR([Please run Apache\'s configure or src/Configure program once and try again])
- fi
- elif test -f $PHP_APACHE_HOOKS_STATIC/src/include/compat.h; then
- AC_DEFINE(HAVE_OLD_COMPAT_H, 1, [ ])
- fi
- # Also for Apache 1.3.x
- elif test -f $PHP_APACHE_HOOKS_STATIC/src/include/httpd.h; then
- APACHE_HAS_REGEX=1
- APACHE_INCLUDE="-I$PHP_APACHE_HOOKS_STATIC/src/include -I$PHP_APACHE_HOOKS_STATIC/src/os/unix"
- APACHE_TARGET=$PHP_APACHE_HOOKS_STATIC/src/modules/php7
- if test ! -d $APACHE_TARGET; then
- mkdir $APACHE_TARGET
- fi
- PHP_SELECT_SAPI(apache_hooks, static, sapi_apache.c mod_php7.c php_apache.c, $APACHE_INCLUDE)
- PHP_LIBS="-Lmodules/php7 -L../modules/php7 -L../../modules/php7 -lmodphp7"
- APACHE_HOOKS_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp7.a; cp $APACHE_HOOKS_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache_hooks/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache_hooks/apMakefile.libdir $APACHE_TARGET/Makefile.libdir"
- AC_MSG_RESULT([yes - Apache 1.3.x])
- STRONGHOLD=
- if test -f $PHP_APACHE_HOOKS_STATIC/src/include/ap_config.h; then
- AC_DEFINE(HAVE_AP_CONFIG_H, 1, [ ])
- fi
- if test -f $PHP_APACHE_HOOKS_STATIC/src/include/ap_compat.h; then
- AC_DEFINE(HAVE_AP_COMPAT_H, 1, [ ])
- if test ! -f $PHP_APACHE_HOOKS_STATIC/src/include/ap_config_auto.h; then
- AC_MSG_ERROR([Please run Apache\'s configure or src/Configure program once and try again])
- fi
- elif test -f $PHP_APACHE_HOOKS_STATIC/src/include/compat.h; then
- AC_DEFINE(HAVE_OLD_COMPAT_H, 1, [ ])
- fi
- # For StrongHold 2.2
- elif test -f $PHP_APACHE_HOOKS_STATIC/apache/httpd.h; then
- APACHE_INCLUDE="-I$PHP_APACHE_HOOKS_STATIC/apache -I$PHP_APACHE_HOOKS_STATIC/ssl/include"
- APACHE_TARGET=$PHP_APACHE_HOOKS_STATIC/apache
- PHP_SELECT_SAPI(apache_hooks, static, sapi_apache.c mod_php7.c php_apache.c, $APACHE_INCLUDE)
- PHP_LIBS="-Lmodules/php7 -L../modules/php7 -L../../modules/php7 -lmodphp7"
- APACHE_HOOKS_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp7.a; cp $APACHE_HOOKS_INSTALL_FILES $APACHE_TARGET"
- STRONGHOLD=-DSTRONGHOLD=1
- AC_MSG_RESULT([yes - StrongHold])
- if test -f $PHP_APACHE_HOOKS_STATIC/apache/ap_config.h; then
- AC_DEFINE(HAVE_AP_CONFIG_H, 1, [ ])
- fi
- if test -f $PHP_APACHE_HOOKS_STATIC/src/ap_compat.h; then
- AC_DEFINE(HAVE_AP_COMPAT_H, 1, [ ])
- if test ! -f $PHP_APACHE_HOOKS_STATIC/src/include/ap_config_auto.h; then
- AC_MSG_ERROR([Please run Apache\'s configure or src/Configure program once and try again])
- fi
- elif test -f $PHP_APACHE_HOOKS_STATIC/src/compat.h; then
- AC_DEFINE(HAVE_OLD_COMPAT_H, 1, [ ])
- fi
- else
- AC_MSG_RESULT(no)
- AC_MSG_ERROR([Invalid Apache directory - unable to find httpd.h under $PHP_APACHE_HOOKS_STATIC])
- fi
-else
- AC_MSG_RESULT(no)
-fi
-
-# compatibility
-if test -z "$enable_mod_charset" && test "$with_mod_charset"; then
- enable_mod_charset=$with_mod_charset
-fi
-
-PHP_ARG_ENABLE(mod-charset, whether to enable Apache charset compatibility option,
-[ --enable-mod-charset APACHE (hooks): Enable transfer tables for mod_charset (Rus Apache)], no, no)
-
-if test "$PHP_MOD_CHARSET" = "yes"; then
- AC_DEFINE(USE_TRANSFER_TABLES, 1, [ ])
-fi
-
-dnl Build as static module
-if test "$APACHE_HOOKS_MODULE" = "yes"; then
- PHP_TARGET_RDYNAMIC
- $php_shtool mkdir -p sapi/apache_hooks
- PHP_OUTPUT(sapi/apache_hooks/libphp7.module)
-fi
-
-dnl General
-if test -n "$APACHE_HOOKS_INSTALL"; then
- if test "x$APXS" != "x" -a "`uname -sv`" = "AIX 4" -a "$GCC" != "yes"; then
- APXS_EXP=-bE:sapi/apache_hooks/mod_php7.exp
- fi
-
- PHP_APACHE_FD_CHECK
- INSTALL_IT=$APACHE_HOOKS_INSTALL
-
- PHP_SUBST(APXS_EXP)
- PHP_SUBST(APACHE_INCLUDE)
- PHP_SUBST(APACHE_TARGET)
- PHP_SUBST(APXS)
- PHP_SUBST(APXS_LDFLAGS)
- PHP_SUBST(APACHE_HOOKS_INSTALL)
- PHP_SUBST(STRONGHOLD)
-fi
-
-dnl ## Local Variables:
-dnl ## tab-width: 4
-dnl ## End:
diff --git a/sapi/apache_hooks/config.w32 b/sapi/apache_hooks/config.w32
deleted file mode 100644
index 1c9129e615..0000000000
--- a/sapi/apache_hooks/config.w32
+++ /dev/null
@@ -1,21 +0,0 @@
-// vim:ft=javascript
-// $Id$
-
-ARG_WITH('apache-hooks', 'Build Apache 1.3.x (hooks) version of PHP', 'no');
-
-if (PHP_APACHE_HOOKS != "no") {
- if (CHECK_HEADER_ADD_INCLUDE("httpd.h", "CFLAGS_APACHE_HOOKS", php_usual_include_suspects +
- ";" + PROGRAM_FILES + "\\Apache Group\\Apache\\include" +
- ";" + PHP_PHP_BUILD + "\\apache\\src\\include") &&
- CHECK_LIB("ApacheCore.lib", "apache_hooks", php_usual_lib_suspects +
- ';' + PROGRAM_FILES + '\\Apache Group\\Apache\\libexec' +
- ";" + PHP_PHP_BUILD + "\\apache\\src\\corer")) {
- // We need to play tricks to get our readdir.h used by apache
- // headers
- SAPI('apache_hooks', 'mod_php7.c sapi_apache.c php_apache.c',
- 'php' + PHP_VERSION + 'apache_hooks.dll',
- '/D APACHEPHP7_EXPORTS /D APACHE_READDIR_H /I win32');
- } else {
- WARNING("Could not find apache libraries/headers");
- }
-}
diff --git a/sapi/apache_hooks/libphp7.module.in b/sapi/apache_hooks/libphp7.module.in
deleted file mode 100644
index 5bea79ef95..0000000000
--- a/sapi/apache_hooks/libphp7.module.in
+++ /dev/null
@@ -1,11 +0,0 @@
-Name: php7_module
-ConfigStart
- RULE_WANTHSREGEX=no
- RULE_HIDE=yes
- PHP_LIBS="@NATIVE_RPATHS@ @PHP_LDFLAGS@ @PHP_LIBS@ @EXTRA_LIBS@ $LIBS"
- PHP_CFLAGS="$CFLAGS @OPENSSL_INCDIR_OPT@ -I@php_abs_top_builddir@/main -I@php_abs_top_builddir@/Zend -I@php_abs_top_builddir@/TSRM -I@php_abs_top_srcdir@ -I@php_abs_top_srcdir@/sapi/apache -I@php_abs_top_srcdir@/main -I@php_abs_top_srcdir@/Zend -I@php_abs_top_srcdir@/TSRM"
- my_outfile="Makefile.config"
- echo "PHP_CFLAGS=$PHP_CFLAGS" >>$my_outfile
- echo "PHP_LIBS=$PHP_LIBS" >>$my_outfile
- LIBS=$PHP_LIBS
-ConfigEnd
diff --git a/sapi/apache_hooks/mod_php7.c b/sapi/apache_hooks/mod_php7.c
deleted file mode 100644
index 6eb15f3ef8..0000000000
--- a/sapi/apache_hooks/mod_php7.c
+++ /dev/null
@@ -1,1478 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 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/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@php.net> |
- | (with helpful hints from Dean Gaudet <dgaudet@arctic.org> |
- | PHP 4.0 patches by Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include "php_apache_http.h"
-
-#ifdef NETWARE
-#define SIGPIPE SIGINT
-#endif
-
-#undef shutdown
-
-/* {{{ Prototypes
- */
-int apache_php_module_main(request_rec *r, int display_source_mode);
-static void php_save_umask(void);
-static void php_restore_umask(void);
-static int sapi_apache_read_post(char *buffer, uint count_bytes);
-static char *sapi_apache_read_cookies(void);
-static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers);
-static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers);
-static int send_php(request_rec *r, int display_source_mode, char *filename);
-static int send_parsed_php(request_rec * r);
-static int send_parsed_php_source(request_rec * r);
-static int php_xbithack_handler(request_rec * r);
-static void php_init_handler(server_rec *s, pool *p);
-/* }}} */
-
-#if MODULE_MAGIC_NUMBER >= 19970728
-static void php_child_exit_handler(server_rec *s, pool *p);
-#endif
-
-#if MODULE_MAGIC_NUMBER > 19961007
-#define CONST_PREFIX const
-#else
-#define CONST_PREFIX
-#endif
-
-
-typedef struct _sapi_stack {
- int top, max, persistent;
- void **elements;
-} sapi_stack;
-
-typedef struct _php_per_dir_config {
- HashTable *ini_settings;
- sapi_stack headers_handlers;
- sapi_stack auth_handlers;
- sapi_stack access_handlers;
- sapi_stack type_handlers;
- sapi_stack fixup_handlers;
- sapi_stack logger_handlers;
- sapi_stack post_read_handlers;
- sapi_stack response_handlers;
-} php_per_dir_config;
-
-typedef struct _php_per_server_config {
- sapi_stack uri_handlers;
- sapi_stack requires;
-} php_per_server_config;
-
-
-static CONST_PREFIX char *php_apache_value_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode);
-static CONST_PREFIX char *php_apache_value_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1, char *arg2);
-static CONST_PREFIX char *php_apache_admin_value_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1, char *arg2);
-static CONST_PREFIX char *php_apache_flag_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1, char *arg2);
-static CONST_PREFIX char *php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode);
-static CONST_PREFIX char *php_apache_admin_flag_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1, char *arg2);
-
-/* ### these should be defined in mod_php7.h or somewhere else */
-#define USE_PATH 1
-#define IGNORE_URL 2
-
-module MODULE_VAR_EXPORT php7_module;
-
-int saved_umask;
-/* static int setup_env = 0; */
-static unsigned char apache_php_initialized;
-
-typedef struct _php_per_dir_entry {
- char *key;
- char *value;
- uint key_length;
- uint value_length;
- int type;
-} php_per_dir_entry;
-
-/* some systems are missing these from their header files */
-
-/* {{{ zend stack utility functions
- */
-
-/* This code is ripped part and parcel from zend_stack.[ch]. Assuming that the
- patch supporting zend_stack_init_ex is applied, all but the bottom two
- module-specific iterators will be removed
- */
-
-int sapi_stack_init_ex(sapi_stack *stack, int persistent)
-{
- stack->top = 0;
- stack->persistent = persistent;
- stack->elements = (void **) pemalloc(sizeof(void **) * STACK_BLOCK_SIZE, persistent);
- if (!stack->elements) {
- return FAILURE;
- } else {
- stack->max = STACK_BLOCK_SIZE;
- return SUCCESS;
- }
-}
-int sapi_stack_push(sapi_stack *stack, void *element)
-{
- if (stack->top >= stack->max) { /* we need to allocate more memory */
- stack->elements = (void **) perealloc(stack->elements,
- (sizeof(void **) * (stack->max += STACK_BLOCK_SIZE)), stack->persistent);
- if (!stack->elements) {
- return FAILURE;
- }
- }
- stack->elements[stack->top] = (void *) element;
- return stack->top++;
-}
-void* sapi_stack_pop(sapi_stack *stack) {
- if(stack->top == 0) {
- return NULL;
- }
- else {
- return stack->elements[--stack->top];
- }
-}
-
-int sapi_stack_destroy(sapi_stack *stack)
-{
- return SUCCESS;
-}
-
-int sapi_stack_apply_with_argument_all(sapi_stack *stack, int type, int (*apply_function)(void *element, void *arg), void *arg)
-{
- int i, retval;
-
- switch (type) {
- case ZEND_STACK_APPLY_TOPDOWN:
- for (i=stack->top-1; i>=0; i--) {
- retval = apply_function(stack->elements[i], arg);
- }
- break;
- case ZEND_STACK_APPLY_BOTTOMUP:
- for (i=0; i<stack->top; i++) {
- retval = apply_function(stack->elements[i], arg);
- }
- break;
- }
- return retval;
-}
-
-
-int sapi_stack_apply_with_argument_stop_if_equals(sapi_stack *stack, int type, int (*apply_function)(void *element, void *arg), void *arg, int stopval)
-{
- int i;
- int ret = DECLINED;
- switch (type) {
- case ZEND_STACK_APPLY_TOPDOWN:
- for (i=stack->top-1; i>=0; i--) {
- if ((ret = apply_function(stack->elements[i], arg)) == stopval) {
- break;
- }
- }
- break;
- case ZEND_STACK_APPLY_BOTTOMUP:
- for (i=0; i<stack->top; i++) {
- if ((ret = apply_function(stack->elements[i], arg)) == stopval) {
- break;
- }
- }
- break;
- }
- return ret;
-}
-
-int sapi_stack_apply_with_argument_stop_if_http_error(sapi_stack *stack, int type, int (*apply_function)(void *element, void *arg), void *arg)
-{
- int i;
- int ret = DECLINED;
- switch (type) {
- case ZEND_STACK_APPLY_TOPDOWN:
- for (i=stack->top-1; i>=0; i--) {
- if ((ret = apply_function(stack->elements[i], arg)) > 0) {
- break;
- }
- }
- break;
- case ZEND_STACK_APPLY_BOTTOMUP:
- for (i=0; i<stack->top; i++) {
- if ((ret = apply_function(stack->elements[i], arg)) > 0) {
- break;
- }
- }
- break;
- }
- return ret;
-}
-
-void php_handler_stack_destroy(sapi_stack *stack)
-{
- php_handler *ph;
- while((ph = (php_handler *)sapi_stack_pop(stack)) != NULL) {
- free(ph->name);
- free(ph);
- }
-}
-/* }}} */
-
-/* {{{ php_save_umask
- */
-static void php_save_umask(void)
-{
- saved_umask = umask(077);
- umask(saved_umask);
-}
-/* }}} */
-
-/* {{{ sapi_apache_ub_write
- */
-static int sapi_apache_ub_write(const char *str, uint str_length)
-{
- int ret=0;
-
- if (SG(server_context)) {
- ret = rwrite(str, str_length, (request_rec *) SG(server_context));
- }
- if (ret != str_length) {
- php_handle_aborted_connection();
- }
- return ret;
-}
-/* }}} */
-
-/* {{{ sapi_apache_flush
- */
-static void sapi_apache_flush(void *server_context)
-{
- if (server_context) {
-#if MODULE_MAGIC_NUMBER > 19970110
- rflush((request_rec *) server_context);
-#else
- bflush((request_rec *) server_context->connection->client);
-#endif
- }
-}
-/* }}} */
-
-/* {{{ sapi_apache_read_post
- */
-static int sapi_apache_read_post(char *buffer, uint count_bytes)
-{
- uint total_read_bytes=0, read_bytes;
- request_rec *r = (request_rec *) SG(server_context);
- void (*handler)(int);
-
- /*
- * This handles the situation where the browser sends a Expect: 100-continue header
- * and needs to receive confirmation from the server on whether or not it can send
- * the rest of the request. RFC 2616
- *
- */
- if (!SG(read_post_bytes) && !ap_should_client_block(r)) {
- return total_read_bytes;
- }
-
- handler = signal(SIGPIPE, SIG_IGN);
- while (total_read_bytes<count_bytes) {
- hard_timeout("Read POST information", r); /* start timeout timer */
- read_bytes = get_client_block(r, buffer+total_read_bytes, count_bytes-total_read_bytes);
- reset_timeout(r);
- if (read_bytes<=0) {
- break;
- }
- total_read_bytes += read_bytes;
- }
- signal(SIGPIPE, handler);
- return total_read_bytes;
-}
-/* }}} */
-
-/* {{{ sapi_apache_read_cookies
- */
-static char *sapi_apache_read_cookies(void)
-{
- return (char *) table_get(((request_rec *) SG(server_context))->subprocess_env, "HTTP_COOKIE");
-}
-/* }}} */
-
-/* {{{ sapi_apache_header_handler
- */
-static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers)
-{
- char *header_name, *header_content, *p;
- request_rec *r = (request_rec *) SG(server_context);
- if(!r) {
- return 0;
- }
-
- switch(op) {
- case SAPI_HEADER_DELETE_ALL:
- clear_table(r->headers_out);
- return 0;
-
- case SAPI_HEADER_DELETE:
- table_unset(r->headers_out, sapi_header->header);
- return 0;
-
- case SAPI_HEADER_ADD:
- case SAPI_HEADER_REPLACE:
- header_name = sapi_header->header;
-
- header_content = p = strchr(header_name, ':');
- if (!p) {
- return 0;
- }
-
- *p = 0;
- do {
- header_content++;
- } while (*header_content==' ');
-
- if (!strcasecmp(header_name, "Content-Type")) {
- r->content_type = pstrdup(r->pool, header_content);
- } else if (!strcasecmp(header_name, "Set-Cookie")) {
- table_add(r->headers_out, header_name, header_content);
- } else if (op == SAPI_HEADER_REPLACE) {
- table_set(r->headers_out, header_name, header_content);
- } else {
- table_add(r->headers_out, header_name, header_content);
- }
-
- *p = ':'; /* a well behaved header handler shouldn't change its original arguments */
-
- return SAPI_HEADER_ADD;
-
- default:
- return 0;
- }
-}
-/* }}} */
-
-/* {{{ sapi_apache_send_headers
- */
-static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers)
-{
- if(SG(server_context) == NULL) { /* server_context is not here anymore */
- return SAPI_HEADER_SEND_FAILED;
- }
-
- ((request_rec *) SG(server_context))->status = SG(sapi_headers).http_response_code;
- /* check that we haven't sent headers already, we use our own
- * headers_sent since we may send headers at anytime
- */
- if(!AP(headers_sent)) {
- send_http_header((request_rec *) SG(server_context));
- AP(headers_sent) = 1;
- }
- return SAPI_HEADER_SENT_SUCCESSFULLY;
-}
-/* }}} */
-
-/* {{{ sapi_apache_register_server_variables
- */
-static void sapi_apache_register_server_variables(zval *track_vars_array)
-{
- register int i;
- array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env);
- table_entry *elts = (table_entry *) arr->elts;
- zval **path_translated;
- HashTable *symbol_table;
-
- for (i = 0; i < arr->nelts; i++) {
- char *val;
-
- if (elts[i].val) {
- val = elts[i].val;
- } else {
- val = "";
- }
- php_register_variable(elts[i].key, val, track_vars_array );
- }
-
- /* If PATH_TRANSLATED doesn't exist, copy it from SCRIPT_FILENAME */
- if (track_vars_array) {
- symbol_table = track_vars_array->value.ht;
- } else {
- symbol_table = NULL;
- }
- if (symbol_table
- && !zend_hash_exists(symbol_table, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"))
- && zend_hash_find(symbol_table, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &path_translated)==SUCCESS) {
- php_register_variable("PATH_TRANSLATED", Z_STRVAL_PP(path_translated), track_vars_array);
- }
-
- php_register_variable("PHP_SELF", ((request_rec *) SG(server_context))->uri, track_vars_array);
-}
-/* }}} */
-
-/* {{{ php_apache_startup
- */
-static int php_apache_startup(sapi_module_struct *sapi_module)
-{
- if (php_module_startup(sapi_module, &apache_module_entry, 1) == FAILURE) {
- return FAILURE;
- } else {
- return SUCCESS;
- }
-}
-/* }}} */
-
-/* {{{ php_apache_log_message
- */
-static void php_apache_log_message(char *message)
-{
- if (SG(server_context)) {
-#if MODULE_MAGIC_NUMBER >= 19970831
- aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, ((request_rec *) SG(server_context))->server, "%s", message);
-#else
- log_error(message, ((request_rec *) SG(server_context))->server);
-#endif
- } else {
- fprintf(stderr, "%s", message);
- fprintf(stderr, "\n");
- }
-}
-/* }}} */
-
-/* {{{ php_apache_request_shutdown
- */
-static void php_apache_request_shutdown(void *dummy)
-{
- AP(current_hook) = AP_CLEANUP;
- php_output_set_status(PHP_OUTPUT_DISABLED);
- SG(server_context) = NULL; /* The server context (request) is invalid by the time run_cleanups() is called */
- if(SG(sapi_started)) {
- php_request_shutdown(dummy);
- SG(sapi_started) = 0;
- }
- AP(in_request) = 0;
- if(AP(setup_env)) {
- AP(setup_env) = 0;
- }
- AP(current_hook) = AP_WAITING_FOR_REQUEST;
- AP(headers_sent) = 0;
-}
-/* }}} */
-
-/* {{{ php_apache_sapi_activate
- */
-static int php_apache_sapi_activate(void)
-{
- request_rec *r = (request_rec *) SG(server_context);
-
- /*
- * For the Apache module version, this bit of code registers a cleanup
- * function that gets triggered when our request pool is destroyed.
- * We need this because at any point in our code we can be interrupted
- * and that may happen before we have had time to free our memory.
- * The php_request_shutdown function needs to free all outstanding allocated
- * memory.
- */
- block_alarms();
- register_cleanup(r->pool, NULL, php_apache_request_shutdown, php_request_shutdown_for_exec);
- AP(in_request)=1;
- unblock_alarms();
-
- /* Override the default headers_only value - sometimes "GET" requests should actually only
- * send headers.
- */
- SG(request_info).headers_only = r->header_only;
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ php_apache_get_stat
- */
-static struct stat *php_apache_get_stat(void)
-{
- return &((request_rec *) SG(server_context))->finfo;
-}
-/* }}} */
-
-/* {{{ php_apache_getenv
- */
-static char *php_apache_getenv(char *name, size_t name_len)
-{
- return (char *) table_get(((request_rec *) SG(server_context))->subprocess_env, name);
-}
-/* }}} */
-
-/* {{{ sapi_module_struct apache_sapi_module
- */
-static sapi_module_struct apache_sapi_module = {
- "apache", /* name */
- "Apache", /* pretty name */
-
- php_apache_startup, /* startup */
- php_module_shutdown_wrapper, /* shutdown */
-
- php_apache_sapi_activate, /* activate */
- NULL, /* deactivate */
-
- sapi_apache_ub_write, /* unbuffered write */
- sapi_apache_flush, /* flush */
- php_apache_get_stat, /* get uid */
- php_apache_getenv, /* getenv */
-
- php_error, /* error handler */
-
- sapi_apache_header_handler, /* header handler */
- sapi_apache_send_headers, /* send headers handler */
- NULL, /* send header handler */
-
- sapi_apache_read_post, /* read POST data */
- sapi_apache_read_cookies, /* read Cookies */
-
- sapi_apache_register_server_variables, /* register server variables */
- php_apache_log_message, /* Log message */
- NULL, /* Get request time */
- NULL, /* child terminate */
-
- NULL, /* php.ini path override */
-
-#ifdef PHP_WIN32
- NULL,
- NULL,
-#else
- block_alarms, /* Block interruptions */
- unblock_alarms, /* Unblock interruptions */
-#endif
-
- NULL, /* default post reader */
- NULL, /* treat data */
- NULL, /* exe location */
- 0, /* ini ignore */
- NULL
-
-};
-/* }}} */
-
-/* {{{ php_restore_umask
- */
-static void php_restore_umask(void)
-{
- umask(saved_umask);
-}
-/* }}} */
-
-/* {{{ init_request_info
- */
-static void init_request_info(void)
-{
- request_rec *r = ((request_rec *) SG(server_context));
- char *content_length = (char *) table_get(r->subprocess_env, "CONTENT_LENGTH");
- const char *authorization=NULL;
- char *tmp, *tmp_user;
-
- SG(request_info).query_string = r->args;
- SG(request_info).path_translated = r->filename;
- SG(request_info).request_uri = r->uri;
- SG(request_info).request_method = (char *)r->method;
- SG(request_info).proto_num = r->proto_num;
- SG(request_info).content_type = (char *) table_get(r->subprocess_env, "CONTENT_TYPE");
- SG(request_info).content_length = (content_length ? atol(content_length) : 0);
- SG(sapi_headers).http_response_code = r->status;
-
- if (r->headers_in) {
- authorization = table_get(r->headers_in, "Authorization");
- }
-
- SG(request_info).auth_user = NULL;
- SG(request_info).auth_password = NULL;
-
- if (authorization && !auth_type(r)) {
- if (!strcasecmp(getword(r->pool, &authorization, ' '), "Basic")) {
- tmp = uudecode(r->pool, authorization);
- tmp_user = getword_nulls_nc(r->pool, &tmp, ':');
- if (tmp_user) {
- r->connection->user = pstrdup(r->connection->pool, tmp_user);
- r->connection->ap_auth_type = "Basic";
- SG(request_info).auth_user = estrdup(tmp_user);
- }
- if (tmp) {
- SG(request_info).auth_password = estrdup(tmp);
- }
- } else if (!strcasecmp(getword(r->pool, &authorization, ' '), "Digest")) {
- r->connection->ap_auth_type = "Digest";
- SG(request_info).auth_digest = estrdup(authorization);
- }
- }
-}
-/* }}} */
-
-/* {{{ php_apache_alter_ini_entries
- */
-static int php_apache_alter_ini_entries(php_per_dir_entry *per_dir_entry)
-{
- zend_alter_ini_entry(per_dir_entry->key, per_dir_entry->key_length+1, per_dir_entry->value, per_dir_entry->value_length, per_dir_entry->type, PHP_INI_STAGE_ACTIVATE);
- return 0;
-}
-/* }}} */
-
-/* {{{ php_apache_get_default_mimetype
- */
-static char *php_apache_get_default_mimetype(request_rec *r)
-{
-
- char *mimetype;
- if (SG(default_mimetype) || SG(default_charset)) {
- /* Assume output will be of the default MIME type. Individual
- scripts may change this later. */
- char *tmpmimetype;
- tmpmimetype = sapi_get_default_content_type();
- mimetype = pstrdup(r->pool, tmpmimetype);
- efree(tmpmimetype);
- } else {
- mimetype = SAPI_DEFAULT_MIMETYPE "; charset=" SAPI_DEFAULT_CHARSET;
- }
- return mimetype;
-}
-/* }}} */
-
-/* {{{ send_php
- */
-static int send_php(request_rec *r, int display_source_mode, char *filename)
-{
- int retval;
- php_per_dir_config *per_dir_conf;
- if (AP(in_request)) {
- zend_file_handle fh;
-
- fh.filename = r->filename;
- fh.opened_path = NULL;
- fh.free_filename = 0;
- fh.type = ZEND_HANDLE_FILENAME;
-
- zend_execute_scripts(ZEND_INCLUDE, NULL, 1, &fh);
- return OK;
- }
-
- zend_first_try {
-
- /* Make sure file exists */
- if (filename == NULL && r->finfo.st_mode == 0) {
- return DECLINED;
- }
-
- per_dir_conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
- if (per_dir_conf) {
- zend_hash_apply((HashTable *) per_dir_conf->ini_settings, (apply_func_t) php_apache_alter_ini_entries);
- }
-
- /* If PHP parser engine has been turned off with an "engine off"
- * directive, then decline to handle this request
- */
- if (!AP(engine)) {
- r->content_type = php_apache_get_default_mimetype(r);
- r->allowed |= (1 << METHODS) - 1;
- zend_try {
- zend_ini_deactivate();
- } zend_end_try();
- return DECLINED;
- }
- if (filename == NULL) {
- filename = r->filename;
- }
-
- /* Apache 1.2 has a more complex mechanism for reading POST data */
-#if MODULE_MAGIC_NUMBER > 19961007
- if ((retval = setup_client_block(r, REQUEST_CHUNKED_ERROR))) {
- zend_try {
- zend_ini_deactivate();
- } zend_end_try();
- return retval;
- }
-#endif
-
- if (AP(last_modified)) {
-#if MODULE_MAGIC_NUMBER < 19970912
- if ((retval = set_last_modified(r, r->finfo.st_mtime))) {
- zend_try {
- zend_ini_deactivate();
- } zend_end_try();
- return retval;
- }
-#else
- update_mtime (r, r->finfo.st_mtime);
- set_last_modified(r);
- set_etag(r);
-#endif
- }
- /* Assume output will be of the default MIME type. Individual
- scripts may change this later in the request. */
- r->content_type = php_apache_get_default_mimetype(r);
-
- /* Init timeout */
- hard_timeout("send", r);
-
- SG(server_context) = r;
-
- php_save_umask();
- if(!AP(setup_env)) {
- AP(setup_env) = 1;
- add_common_vars(r);
- add_cgi_vars(r);
- }
- init_request_info();
- apache_php_module_main(r, display_source_mode);
-
- /* Done, restore umask, turn off timeout, close file and return */
- php_restore_umask();
- kill_timeout(r);
- } zend_end_try();
-
- return OK;
-}
-/* }}} */
-
-/* {{{ send_parsed_php
- */
-static int send_parsed_php(request_rec * r)
-{
- int result = send_php(r, 0, NULL);
-
- ap_table_setn(r->notes, "mod_php_memory_usage",
- ap_psprintf(r->pool, "%u", zend_memory_peak_usage(1)));
-
- return result;
-}
-/* }}} */
-
-/* {{{ send_parsed_php_source
- */
-static int send_parsed_php_source(request_rec * r)
-{
- return send_php(r, 1, NULL);
-}
-/* }}} */
-
-
-/* {{{ destroy_per_dir_entry
- */
-static void destroy_per_dir_entry(php_per_dir_entry *per_dir_entry)
-{
- free(per_dir_entry->key);
- free(per_dir_entry->value);
-}
-/* }}} */
-
-/* {{{ copy_per_dir_entry
- */
-static void copy_per_dir_entry(php_per_dir_entry *per_dir_entry)
-{
- php_per_dir_entry tmp = *per_dir_entry;
-
- per_dir_entry->key = (char *) malloc(tmp.key_length+1);
- memcpy(per_dir_entry->key, tmp.key, tmp.key_length);
- per_dir_entry->key[per_dir_entry->key_length] = 0;
-
- per_dir_entry->value = (char *) malloc(tmp.value_length+1);
- memcpy(per_dir_entry->value, tmp.value, tmp.value_length);
- per_dir_entry->value[per_dir_entry->value_length] = 0;
-}
-/* }}} */
-
-/* {{{ should_overwrite_per_dir_entry;
-
- */
-static zend_bool should_overwrite_per_dir_entry(HashTable *target_ht, php_per_dir_entry *orig_per_dir_entry, zend_hash_key *hash_key, void *pData)
-{
- php_per_dir_entry *new_per_dir_entry;
-
- if (zend_hash_find(target_ht, hash_key->arKey, hash_key->nKeyLength, (void **) &new_per_dir_entry)==FAILURE) {
- return 1; /* does not exist in dest, copy from source */
- }
-
- if (new_per_dir_entry->type==PHP_INI_SYSTEM
- && orig_per_dir_entry->type!=PHP_INI_SYSTEM) {
- return 1;
- } else {
- return 0;
- }
-}
-/* }}} */
-/* {{{ php_destroy_per_server_info
- */
-static void php_destroy_per_server_info(php_per_server_config *conf)
-{
- php_handler_stack_destroy(&conf->requires);
- php_handler_stack_destroy(&conf->uri_handlers);
-}
-/* }}} */
-
-/* {{{ php_destroy_per_dir_info
- */
-static void php_destroy_per_dir_info(php_per_dir_config *conf)
-{
- zend_hash_destroy(conf->ini_settings);
- php_handler_stack_destroy(&conf->response_handlers);
- php_handler_stack_destroy(&conf->auth_handlers);
- php_handler_stack_destroy(&conf->access_handlers);
- php_handler_stack_destroy(&conf->type_handlers);
- php_handler_stack_destroy(&conf->fixup_handlers);
- php_handler_stack_destroy(&conf->logger_handlers);
- php_handler_stack_destroy(&conf->post_read_handlers);
- php_handler_stack_destroy(&conf->headers_handlers);
- free(conf->ini_settings);
-}
-/* }}} */
-
-/* {{{ php_create_server
- */
-static void *php_create_server(pool *p, char *dummy)
-{
- php_per_server_config *conf;
- conf = (php_per_server_config *) malloc(sizeof(php_per_server_config));
- register_cleanup(p, (void *) conf, (void (*)(void *)) php_destroy_per_server_info, (void (*)(void *)) php_destroy_per_server_info);
-
- sapi_stack_init_ex(&conf->requires, 1);
- sapi_stack_init_ex(&conf->uri_handlers, 1);
- return conf;
-}
-
-/* }}} */
-
-
-/* {{{ php_create_dir
- */
-static void *php_create_dir(pool *p, char *dummy)
-{
- php_per_dir_config *conf;
- conf = (php_per_dir_config *) malloc(sizeof(php_per_dir_config));
- conf->ini_settings = (HashTable *) malloc(sizeof(HashTable));
- zend_hash_init_ex(conf->ini_settings, 5, NULL, (void (*)(void *)) destroy_per_dir_entry, 1, 0);
- sapi_stack_init_ex(&conf->response_handlers, 1);
- sapi_stack_init_ex(&conf->headers_handlers, 1);
- sapi_stack_init_ex(&conf->auth_handlers, 1);
- sapi_stack_init_ex(&conf->access_handlers, 1);
- sapi_stack_init_ex(&conf->type_handlers, 1);
- sapi_stack_init_ex(&conf->fixup_handlers, 1);
- sapi_stack_init_ex(&conf->logger_handlers, 1);
- sapi_stack_init_ex(&conf->post_read_handlers, 1);
- register_cleanup(p, (void *) conf, (void (*)(void *)) php_destroy_per_dir_info, (void (*)(void *)) php_destroy_per_dir_info);
-
- return conf;
-}
-
-/* }}} */
-
-/* {{{ php_merge_dir
- */
-static void *php_merge_dir(pool *p, void *basev, void *addv)
-{
- php_per_dir_config *a = (php_per_dir_config *) addv;
- php_per_dir_config *b = (php_per_dir_config *) basev;
- /* This function *must* return addv, and not modify basev */
- zend_hash_merge_ex((HashTable *) a->ini_settings, (HashTable *) b->ini_settings, (copy_ctor_func_t) copy_per_dir_entry, sizeof(php_per_dir_entry), (merge_checker_func_t) should_overwrite_per_dir_entry, NULL);
- a->headers_handlers = (a->headers_handlers.top)?a->headers_handlers:b->headers_handlers;
- a->auth_handlers = (a->auth_handlers.top)?a->auth_handlers:b->auth_handlers;
- a->access_handlers = (a->access_handlers.top)?a->access_handlers:b->access_handlers;
- a->type_handlers = (a->type_handlers.top)?a->type_handlers:b->type_handlers;
- a->fixup_handlers = (a->fixup_handlers.top)?a->fixup_handlers:b->fixup_handlers;
- a->logger_handlers = (a->logger_handlers.top)?a->logger_handlers:b->logger_handlers;
- a->post_read_handlers = (a->post_read_handlers.top)?a->post_read_handlers:b->post_read_handlers;
- a->response_handlers = (a->response_handlers.top)?a->response_handlers:b->response_handlers;
- return a;
-}
-/* }}} */
-
-/* {{{ php_apache_value_handler_ex
- */
-static CONST_PREFIX char *php_apache_value_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode)
-{
- php_per_dir_entry per_dir_entry;
-
- if (!apache_php_initialized) {
- apache_php_initialized = 1;
-#ifdef ZTS
- tsrm_startup(1, 1, 0, NULL);
-#endif
- sapi_startup(&apache_sapi_module);
- php_apache_startup(&apache_sapi_module);
- }
- per_dir_entry.type = mode;
-
- if (strcasecmp(arg2, "none") == 0) {
- arg2 = "";
- }
-
- per_dir_entry.key_length = strlen(arg1);
- per_dir_entry.value_length = strlen(arg2);
-
- per_dir_entry.key = (char *) malloc(per_dir_entry.key_length+1);
- memcpy(per_dir_entry.key, arg1, per_dir_entry.key_length);
- per_dir_entry.key[per_dir_entry.key_length] = 0;
-
- per_dir_entry.value = (char *) malloc(per_dir_entry.value_length+1);
- memcpy(per_dir_entry.value, arg2, per_dir_entry.value_length);
- per_dir_entry.value[per_dir_entry.value_length] = 0;
-
- zend_hash_update(conf, per_dir_entry.key, per_dir_entry.key_length, &per_dir_entry, sizeof(php_per_dir_entry), NULL);
- return NULL;
-}
-/* }}} */
-
-static CONST_PREFIX char *php_set_server_handler(server_rec *s, char *arg1, long handler_stage, long handler_type)
-{
- php_per_server_config *conf;
- php_handler *handler;
- handler = (php_handler *) malloc(sizeof(php_handler));
- handler->type = handler_type;
- handler->stage = handler_stage;
- handler->name = strdup(arg1);
- conf = get_module_config(s->module_config, &php7_module);
- switch(handler_stage) {
- case AP_URI_TRANS:
- sapi_stack_push(&conf->uri_handlers, handler);
- break;
- default:
- sapi_stack_push(&conf->requires, handler);
- break;
- }
- return NULL;
-}
-
-static CONST_PREFIX char *php_set_dir_handler(php_per_dir_config *conf, char *arg1, long handler_stage, long handler_type)
-{
- php_handler *handler;
- handler = (php_handler *) malloc(sizeof(php_handler));
- handler->type = handler_type;
- handler->stage = handler_stage;
- handler->name = strdup(arg1);
- switch(handler_stage) {
- case AP_POST_READ:
- sapi_stack_push(&conf->post_read_handlers, handler);
- break;
- case AP_HEADER_PARSE:
- sapi_stack_push(&conf->headers_handlers, handler);
- break;
- case AP_ACCESS_CONTROL:
- sapi_stack_push(&conf->access_handlers, handler);
- break;
- case AP_AUTHENTICATION:
- sapi_stack_push(&conf->auth_handlers, handler);
- break;
- case AP_AUTHORIZATION:
- break;
- case AP_TYPE_CHECKING:
- sapi_stack_push(&conf->type_handlers, handler);
- break;
- case AP_FIXUP:
- sapi_stack_push(&conf->fixup_handlers, handler);
- break;
- case AP_RESPONSE:
- sapi_stack_push(&conf->response_handlers, handler);
- break;
- case AP_LOGGING:
- sapi_stack_push(&conf->logger_handlers, handler);
- break;
- default:
- break;
- }
- return NULL;
-}
-
-/* {{{ php_set_uri_handler
- */
-static CONST_PREFIX char *php_set_uri_handler(cmd_parms *cmd, void *dummy, char *arg1)
-{
- return php_set_server_handler(cmd->server, arg1, AP_URI_TRANS, AP_HANDLER_TYPE_FILE);
-}
-/* }}} */
-
-/* {{{ php_set_uri_handler_code */
-static CONST_PREFIX char *php_set_uri_handler_code(cmd_parms *cmd, void *dummy, char *arg1)
-{
- return php_set_server_handler(cmd->server, arg1, AP_URI_TRANS, AP_HANDLER_TYPE_METHOD);
-}
-/* }}} */
-
-/* {{{ php_set_header_handler
- */
-static CONST_PREFIX char *php_set_header_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1)
-{
- return php_set_dir_handler(conf, arg1, AP_HEADER_PARSE, AP_HANDLER_TYPE_FILE);
-}
-static CONST_PREFIX char *php_set_header_handler_code(cmd_parms *cmd, php_per_dir_config *conf, char *arg1)
-{
- return php_set_dir_handler(conf, arg1, AP_HEADER_PARSE, AP_HANDLER_TYPE_METHOD);
-}
-/* }}} */
-
-/* {{{ php_set_auth_handler
- */
-static CONST_PREFIX char *php_set_auth_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1)
-{
- return php_set_dir_handler(conf, arg1, AP_AUTHENTICATION, AP_HANDLER_TYPE_FILE);
-}
-static CONST_PREFIX char *php_set_auth_handler_code(cmd_parms *cmd, php_per_dir_config *conf, char *arg1)
-{
- return php_set_dir_handler(conf, arg1, AP_AUTHENTICATION, AP_HANDLER_TYPE_METHOD);
-}
-
-/* }}} */
-
-/* {{{ php_set_access_handler
- */
-static CONST_PREFIX char *php_set_access_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1)
-{
- return php_set_dir_handler(conf, arg1, AP_ACCESS_CONTROL, AP_HANDLER_TYPE_FILE);
-}
-static CONST_PREFIX char *php_set_access_handler_code(cmd_parms *cmd, php_per_dir_config *conf, char *arg1)
-{
- return php_set_dir_handler(conf, arg1, AP_ACCESS_CONTROL, AP_HANDLER_TYPE_METHOD);
-}
-
-/* }}} */
-
-/* {{{ php_set_type_handler
- */
-static CONST_PREFIX char *php_set_type_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1)
-{
- return php_set_dir_handler(conf, arg1, AP_TYPE_CHECKING, AP_HANDLER_TYPE_FILE);
-}
-static CONST_PREFIX char *php_set_type_handler_code(cmd_parms *cmd, php_per_dir_config *conf, char *arg1)
-{
- return php_set_dir_handler(conf, arg1, AP_TYPE_CHECKING, AP_HANDLER_TYPE_METHOD);
-}
-
-/* }}} */
-
-/* {{{ php_set_fixup_handler
- */
-static CONST_PREFIX char *php_set_fixup_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1)
-{
- return php_set_dir_handler(conf, arg1, AP_FIXUP, AP_HANDLER_TYPE_FILE);
-}
-static CONST_PREFIX char *php_set_fixup_handler_code(cmd_parms *cmd, php_per_dir_config *conf, char *arg1)
-{
- return php_set_dir_handler(conf, arg1, AP_FIXUP, AP_HANDLER_TYPE_METHOD);
-}
-/* }}} */
-
-/* {{{ php_set_logger_handler
- */
-static CONST_PREFIX char *php_set_logger_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1)
-{
- return php_set_dir_handler(conf, arg1, AP_LOGGING, AP_HANDLER_TYPE_FILE);
-}
-static CONST_PREFIX char *php_set_logger_handler_code(cmd_parms *cmd, php_per_dir_config *conf, char *arg1)
-{
- return php_set_dir_handler(conf, arg1, AP_LOGGING, AP_HANDLER_TYPE_METHOD);
-}
-
-/* }}} */
-
-/* {{{ php_set_post_read_handler
- */
-static CONST_PREFIX char *php_set_post_read_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1)
-{
- return php_set_dir_handler(conf, arg1, AP_POST_READ, AP_HANDLER_TYPE_FILE);
-}
-static CONST_PREFIX char *php_set_post_read_handler_code(cmd_parms *cmd, php_per_dir_config *conf, char *arg1)
-{
- return php_set_dir_handler(conf, arg1, AP_POST_READ, AP_HANDLER_TYPE_METHOD);
-}
-
-
-/* }}} */
-
-/* {{{ php_set_require
- */
-
-static CONST_PREFIX char *php_set_require(cmd_parms *cmd, void *dummy, char *arg1)
-{
- return php_set_server_handler(cmd->server, arg1, 0, AP_HANDLER_TYPE_FILE);
-}
-/* }}} */
-
-/* {{{ php_set_response_handler
- */
-static CONST_PREFIX char *php_set_response_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1)
-{
- return php_set_dir_handler(conf, arg1, AP_RESPONSE, AP_HANDLER_TYPE_FILE);
-}
-static CONST_PREFIX char *php_set_response_handler_code(cmd_parms *cmd, php_per_dir_config *conf, char *arg1)
-{
- return php_set_dir_handler(conf, arg1, AP_RESPONSE, AP_HANDLER_TYPE_METHOD);
-}
-/* }}} */
-
-/* {{{ php_apache_value_handler
- */
-static CONST_PREFIX char *php_apache_value_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1, char *arg2)
-{
- return php_apache_value_handler_ex(cmd, conf->ini_settings, arg1, arg2, PHP_INI_PERDIR);
-}
-/* }}} */
-
-/* {{{ php_apache_admin_value_handler
- */
-static CONST_PREFIX char *php_apache_admin_value_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1, char *arg2)
-{
- return php_apache_value_handler_ex(cmd, conf->ini_settings, arg1, arg2, PHP_INI_SYSTEM);
-}
-/* }}} */
-
-/* {{{ php_apache_flag_handler_ex
- */
-static CONST_PREFIX char *php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode)
-{
- char bool_val[2];
-
- if (!strcasecmp(arg2, "On")) {
- bool_val[0] = '1';
- } else {
- bool_val[0] = '0';
- }
- bool_val[1] = 0;
-
- return php_apache_value_handler_ex(cmd, conf, arg1, bool_val, mode);
-}
-/* }}} */
-
-/* {{{ php_apache_flag_handler
- */
-static CONST_PREFIX char *php_apache_flag_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1, char *arg2)
-{
- return php_apache_flag_handler_ex(cmd, conf->ini_settings, arg1, arg2, PHP_INI_PERDIR);
-}
-/* }}} */
-
-/* {{{ php_apache_admin_flag_handler
- */
-static CONST_PREFIX char *php_apache_admin_flag_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1, char *arg2)
-{
- return php_apache_flag_handler_ex(cmd, conf->ini_settings, arg1, arg2, PHP_INI_SYSTEM);
-}
-/* }}} */
-
-/* {{{ php_apache_phpini_set
- */
-static CONST_PREFIX char *php_apache_phpini_set(cmd_parms *cmd, HashTable *conf, char *arg)
-{
- if (apache_sapi_module.php_ini_path_override) {
- return "Only first PHPINIDir directive honored per configuration tree - subsequent ones ignored";
- }
- apache_sapi_module.php_ini_path_override = ap_server_root_relative(cmd->pool, arg);
- return NULL;
-}
-/* }}} */
-
-/* {{{ int php_xbithack_handler(request_rec * r)
- */
-static int php_xbithack_handler(request_rec * r)
-{
- php_per_dir_config *conf;
-
- if (!(r->finfo.st_mode & S_IXUSR)) {
- r->allowed |= (1 << METHODS) - 1;
- return DECLINED;
- }
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
- if (conf) {
- zend_hash_apply((HashTable *) conf->ini_settings, (apply_func_t) php_apache_alter_ini_entries);
- }
- if(!AP(xbithack)) {
- r->allowed |= (1 << METHODS) - 1;
- zend_try {
- zend_ini_deactivate();
- } zend_end_try();
- return DECLINED;
- }
- return send_parsed_php(r);
-}
-/* }}} */
-
-/* {{{ apache_php_module_shutdown_wrapper
- */
-static void apache_php_module_shutdown_wrapper(void)
-{
- apache_php_initialized = 0;
- apache_sapi_module.shutdown(&apache_sapi_module);
-
-#if MODULE_MAGIC_NUMBER >= 19970728
- /* This function is only called on server exit if the apache API
- * child_exit handler exists, so shutdown globally
- */
- sapi_shutdown();
-#endif
-
-#ifdef ZTS
- tsrm_shutdown();
-#endif
-}
-/* }}} */
-
-#if MODULE_MAGIC_NUMBER >= 19970728
-/* {{{ php_child_exit_handler
- */
-static void php_child_exit_handler(server_rec *s, pool *p)
-{
-/* apache_php_initialized = 0; */
- apache_sapi_module.shutdown(&apache_sapi_module);
-
-#ifdef ZTS
- tsrm_shutdown();
-#endif
-}
-/* }}} */
-#endif
-
-/* {{{ void php_init_handler(server_rec *s, pool *p)
- */
-static void php_init_handler(server_rec *s, pool *p)
-{
- register_cleanup(p, NULL, (void (*)(void *))apache_php_module_shutdown_wrapper, (void (*)(void *))php_module_shutdown_for_exec);
- if (!apache_php_initialized) {
- apache_php_initialized = 1;
-#ifdef ZTS
- tsrm_startup(1, 1, 0, NULL);
-#endif
- sapi_startup(&apache_sapi_module);
- php_apache_startup(&apache_sapi_module);
- }
-#if MODULE_MAGIC_NUMBER >= 19980527
- {
- if (PG(expose_php)) {
- ap_add_version_component("PHP/" PHP_VERSION);
- }
- }
-#endif
-}
-/* }}} */
-
-static int php_run_hook(php_handler *handler, request_rec *r)
-{
- zval *ret = NULL;
- php_per_dir_config *conf;
-
-
- if(!AP(apache_config_loaded)) {
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
- if (conf)
- zend_hash_apply((HashTable *)conf->ini_settings, (apply_func_t) php_apache_alter_ini_entries);
- AP(apache_config_loaded) = 1;
- }
- if (!handler->name) {
- return DECLINED;
- }
- php_save_umask();
- if (!AP(setup_env)) {
- AP(setup_env) = 1;
- add_common_vars(r);
- add_cgi_vars(r);
- }
- SG(server_context) = r;
- init_request_info();
- apache_php_module_hook(r, handler, &ret);
- php_restore_umask();
- kill_timeout(r);
- if (ret) {
- convert_to_long(ret);
- return Z_LVAL_P(ret);
- }
- return HTTP_INTERNAL_SERVER_ERROR;
-}
-
-
-static int php_uri_translation(request_rec *r)
-{
- php_per_server_config *conf;
- AP(current_hook) = AP_URI_TRANS;
- conf = (php_per_server_config *) get_module_config(r->server->module_config, &php7_module);
- return sapi_stack_apply_with_argument_stop_if_equals(&conf->uri_handlers,
- ZEND_STACK_APPLY_BOTTOMUP,
- (int (*)(void *element, void *)) php_run_hook, r, OK);
-}
-
-static int php_header_hook(request_rec *r)
-{
- php_per_dir_config *conf;
- AP(current_hook) = AP_HEADER_PARSE;
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
- return sapi_stack_apply_with_argument_stop_if_http_error(&conf->headers_handlers,
- ZEND_STACK_APPLY_BOTTOMUP,
- (int (*)(void *element, void *)) php_run_hook, r);
-}
-
-static int php_auth_hook(request_rec *r)
-{
- php_per_dir_config *conf;
- AP(current_hook) = AP_AUTHENTICATION;
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
- return sapi_stack_apply_with_argument_stop_if_equals(&conf->auth_handlers,
- ZEND_STACK_APPLY_BOTTOMUP,
- (int (*)(void *element, void *)) php_run_hook, r, OK);
-}
-
-static int php_access_hook(request_rec *r)
-{
- php_per_dir_config *conf;
- int status = DECLINED;
- AP(current_hook) = AP_ACCESS_CONTROL;
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
- status = sapi_stack_apply_with_argument_stop_if_http_error(&conf->access_handlers,
- ZEND_STACK_APPLY_BOTTOMUP,
- (int (*)(void *element, void *)) php_run_hook, r);
- return status;
-
-}
-
-static int php_type_hook(request_rec *r)
-{
- php_per_dir_config *conf;
- AP(current_hook) = AP_TYPE_CHECKING;
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
- return sapi_stack_apply_with_argument_stop_if_equals(&conf->type_handlers,
- ZEND_STACK_APPLY_BOTTOMUP,
- (int (*)(void *element, void *)) php_run_hook,
- r, OK);
-}
-
-static int php_fixup_hook(request_rec *r)
-{
- php_per_dir_config *conf;
- AP(current_hook) = AP_FIXUP;
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
- return sapi_stack_apply_with_argument_stop_if_http_error(&conf->fixup_handlers,
- ZEND_STACK_APPLY_BOTTOMUP,
- (int (*)(void *element, void *)) php_run_hook,
- r);
-}
-
-static int php_logger_hook(request_rec *r)
-{
- php_per_dir_config *conf;
- AP(current_hook) = AP_LOGGING;
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
- return sapi_stack_apply_with_argument_stop_if_http_error(&conf->logger_handlers,
- ZEND_STACK_APPLY_BOTTOMUP,
- (int (*)(void *element, void *)) php_run_hook,
- r);
-}
-
-static int php_post_read_hook(request_rec *r)
-{
- php_per_dir_config *conf;
- php_per_server_config *svr;
- AP(current_hook) = AP_POST_READ;
- svr = get_module_config(r->server->module_config, &php7_module);
- if(ap_is_initial_req(r)) {
- sapi_stack_apply_with_argument_all(&svr->requires, ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *element, void *)) php_run_hook, r);
- }
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
- return sapi_stack_apply_with_argument_stop_if_http_error(&conf->post_read_handlers,
- ZEND_STACK_APPLY_BOTTOMUP,
- (int (*)(void *element, void *)) php_run_hook, r);
-}
-
-static int php_response_handler(request_rec *r)
-{
- php_per_dir_config *conf;
- AP(current_hook) = AP_RESPONSE;
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
- return sapi_stack_apply_with_argument_all(&conf->response_handlers, ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *element, void *)) php_run_hook, r);
-}
-
-/* {{{ handler_rec php_handlers[]
- */
-handler_rec php_handlers[] =
-{
- {"application/x-httpd-php", send_parsed_php},
- {"application/x-httpd-php-source", send_parsed_php_source},
- {"text/html", php_xbithack_handler},
- {"php-script", php_response_handler},
- {NULL}
-};
-/* }}} */
-
-/* {{{ command_rec php_commands[]
- */
-command_rec php_commands[] =
-{
- {"php_value", php_apache_value_handler, NULL, OR_OPTIONS, TAKE2, "PHP Value Modifier"},
- {"phpUriHandler", php_set_uri_handler, NULL, RSRC_CONF, TAKE1, "PHP Value Modifier"},
- {"phpUriHandlerMethod", php_set_uri_handler_code, NULL, RSRC_CONF, TAKE1, "PHP Value Modifier"},
-#if MODULE_MAGIC_NUMBER >= 19970103
- {"phpHeaderHandler", php_set_header_handler, NULL, OR_OPTIONS, TAKE1, "PHP Value Modifier"},
- {"phpHeaderHandlerMethod", php_set_header_handler_code, NULL, OR_OPTIONS, TAKE1, "PHP Value Modifier"},
-#endif
- {"phpAuthHandler", php_set_auth_handler, NULL, OR_OPTIONS, TAKE1, "PHP Value Modifier"},
- {"phpAuthHandlerMethod", php_set_auth_handler_code, NULL, OR_OPTIONS, TAKE1, "PHP Value Modifier"},
- {"phpAccessHandler", php_set_access_handler, NULL, OR_OPTIONS, TAKE1, "PHP Value Modifier"},
- {"phpAccessHandlerMethod", php_set_access_handler_code, NULL, OR_OPTIONS, TAKE1, "PHP Value Modifier"},
- {"phpTypeHandler", php_set_type_handler, NULL, OR_OPTIONS, TAKE1, "PHP Value Modifier"},
- {"phpTypeHandlerMethod", php_set_type_handler_code, NULL, OR_OPTIONS, TAKE1, "PHP Value Modifier"},
- {"phpFixupHandler", php_set_fixup_handler, NULL, OR_OPTIONS, TAKE1, "PHP Value Modifier"},
- {"phpFixupHandlerMethod", php_set_fixup_handler_code, NULL, OR_OPTIONS, TAKE1, "PHP Value Modifier"},
- {"phpLoggerHandler", php_set_logger_handler, NULL, OR_OPTIONS, TAKE1, "PHP Value Modifier"},
- {"phpLoggerHandlerMethod", php_set_logger_handler_code, NULL, OR_OPTIONS, TAKE1, "PHP Value Modifier"},
-#if MODULE_MAGIC_NUMBER >= 19970902
- {"phpPostReadHandler", php_set_post_read_handler, NULL, OR_OPTIONS, TAKE1, "PHP Value Modifier"},
- {"phpPostReadHandlerMethod", php_set_post_read_handler_code, NULL, OR_OPTIONS, TAKE1, "PHP Value Modifier"},
- {"phpRequire", php_set_require, NULL, OR_OPTIONS, TAKE1, "PHP Value Modifier"},
- {"phpResponseHandler", php_set_response_handler, NULL, OR_OPTIONS, TAKE1, "PHP Value Modifier"},
- {"phpResponseHandlerMethod", php_set_response_handler_code, NULL, OR_OPTIONS, TAKE1, "PHP Value Modifier"},
-#endif
- {"php_flag", php_apache_flag_handler, NULL, OR_OPTIONS, TAKE2, "PHP Flag Modifier"},
- {"php_admin_value", php_apache_admin_value_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Value Modifier (Admin)"},
- {"php_admin_flag", php_apache_admin_flag_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Flag Modifier (Admin)"},
- {"PHPINIDir", php_apache_phpini_set, NULL, RSRC_CONF, TAKE1, "Directory containing the php.ini file"},
- {NULL}
-};
-/* }}} */
-
-/* {{{ module MODULE_VAR_EXPORT php7_module
- */
-module MODULE_VAR_EXPORT php7_module =
-{
- STANDARD_MODULE_STUFF,
- php_init_handler, /* initializer */
- php_create_dir, /* per-directory config creator */
- php_merge_dir, /* dir merger */
- php_create_server, /* per-server config creator */
- NULL, /* merge server config */
- php_commands, /* command table */
- php_handlers, /* handlers */
- php_uri_translation, /* filename translation */
- NULL, /* check_user_id */
- php_auth_hook, /* check auth */
- php_access_hook, /* check access */
- php_type_hook, /* type_checker */
- php_fixup_hook, /* fixups */
- php_logger_hook /* logger */
-#if MODULE_MAGIC_NUMBER >= 19970103
- , php_header_hook /* header parser */
-#endif
-#if MODULE_MAGIC_NUMBER >= 19970719
- , NULL /* child_init */
-#endif
-#if MODULE_MAGIC_NUMBER >= 19970728
- , php_child_exit_handler /* child_exit */
-#endif
-#if MODULE_MAGIC_NUMBER >= 19970902
- , php_post_read_hook /* post read-request */
-#endif
-};
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/sapi/apache_hooks/mod_php7.exp b/sapi/apache_hooks/mod_php7.exp
deleted file mode 100644
index 1469b0314d..0000000000
--- a/sapi/apache_hooks/mod_php7.exp
+++ /dev/null
@@ -1 +0,0 @@
-php7_module
diff --git a/sapi/apache_hooks/mod_php7.h b/sapi/apache_hooks/mod_php7.h
deleted file mode 100644
index 34fc20bd31..0000000000
--- a/sapi/apache_hooks/mod_php7.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Rasmus Lerdorf <rasmus@php.net> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#ifndef MOD_PHP7_H
-#define MOD_PHP7_H
-
-#if !defined(WIN32) && !defined(WINNT)
-#ifndef MODULE_VAR_EXPORT
-#define MODULE_VAR_EXPORT
-#endif
-#endif
-
-typedef struct {
- long engine;
- long last_modified;
- long xbithack;
- long terminate_child;
- long setup_env;
- long current_hook;
- zend_bool in_request;
- zend_bool apache_config_loaded;
- zend_bool headers_sent;
-} php_apache_info_struct;
-
-typedef struct _php_handler {
- long type;
- long stage;
- char *name;
-} php_handler;
-
-#define AP_HANDLER_TYPE_FILE 0
-#define AP_HANDLER_TYPE_METHOD 1
-
-extern zend_module_entry apache_module_entry;
-
-#ifdef ZTS
-extern int php_apache_info_id;
-#define AP(v) TSRMG(php_apache_info_id, php_apache_info_struct *, v)
-#else
-extern php_apache_info_struct php_apache_info;
-#define AP(v) (php_apache_info.v)
-#endif
-
-/* defines for the various stages of the apache request */
-#define AP_WAITING_FOR_REQUEST 0
-#define AP_POST_READ 1
-#define AP_URI_TRANS 2
-#define AP_HEADER_PARSE 3
-#define AP_ACCESS_CONTROL 4
-#define AP_AUTHENTICATION 5
-#define AP_AUTHORIZATION 6
-#define AP_TYPE_CHECKING 7
-#define AP_FIXUP 8
-#define AP_RESPONSE 9
-#define AP_LOGGING 10
-#define AP_CLEANUP 11
-
-
-/* fix for gcc4 visibility patch */
-#ifndef PHP_WIN32
-# undef MODULE_VAR_EXPORT
-# define MODULE_VAR_EXPORT PHPAPI
-#endif
-
-#endif /* MOD_PHP7_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/sapi/apache_hooks/php.sym b/sapi/apache_hooks/php.sym
deleted file mode 100644
index 1469b0314d..0000000000
--- a/sapi/apache_hooks/php.sym
+++ /dev/null
@@ -1 +0,0 @@
-php7_module
diff --git a/sapi/apache_hooks/php_apache.c b/sapi/apache_hooks/php_apache.c
deleted file mode 100644
index 55581b9bb8..0000000000
--- a/sapi/apache_hooks/php_apache.c
+++ /dev/null
@@ -1,1970 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Stig Sæther Bakken <ssb@php.net> |
- | David Sklar <sklar@student.net> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include "php_apache_http.h"
-
-#if defined(PHP_WIN32) || defined(NETWARE)
-#include "zend.h"
-#include "ap_compat.h"
-#else
-#include <build-defs.h>
-#endif
-
-#ifdef ZTS
-int php_apache_info_id;
-#else
-php_apache_info_struct php_apache_info;
-#endif
-
-#define SECTION(name) PUTS("<H2 align=\"center\">" name "</H2>\n")
-
-#undef offsetof
-#define offsetof(s_type,field) ((size_t)&(((s_type*)0)->field))
-
-extern module *top_module;
-extern module **ap_loaded_modules;
-static int le_apachereq;
-static zend_class_entry *apacherequest_class_entry;
-
-static void apache_table_to_zval(table *, zval *return_value);
-
-PHP_FUNCTION(virtual);
-PHP_FUNCTION(apache_request_headers);
-PHP_FUNCTION(apache_response_headers);
-PHP_FUNCTION(apachelog);
-PHP_FUNCTION(apache_note);
-PHP_FUNCTION(apache_lookup_uri);
-PHP_FUNCTION(apache_child_terminate);
-PHP_FUNCTION(apache_setenv);
-PHP_FUNCTION(apache_get_version);
-PHP_FUNCTION(apache_get_modules);
-
-PHP_MINFO_FUNCTION(apache);
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_apachehooks_virtual, 0, 0, 1)
- ZEND_ARG_INFO(0, filename)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_apachehooks_setenv, 0, 0, 2)
- ZEND_ARG_INFO(0, variable)
- ZEND_ARG_INFO(0, value)
- ZEND_ARG_INFO(0, walk_to_top)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_apachehooks_lookup_uri, 0, 0, 1)
- ZEND_ARG_INFO(0, uri)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_apachehooks__void, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_apachehooks_note, 0, 0, 1)
- ZEND_ARG_INFO(0, note_name)
- ZEND_ARG_INFO(0, note_value)
-ZEND_END_ARG_INFO()
-
-const zend_function_entry apache_functions[] = {
- PHP_FE(virtual, arginfo_apachehooks_virtual)
- PHP_FE(apache_request_headers, arginfo_apachehooks__void)
- PHP_FE(apache_note, arginfo_apachehooks_note)
- PHP_FE(apache_lookup_uri, arginfo_apachehooks_lookup_uri)
- PHP_FE(apache_child_terminate, arginfo_apachehooks__void)
- PHP_FE(apache_setenv, arginfo_apachehooks_setenv)
- PHP_FE(apache_response_headers, arginfo_apachehooks__void)
- PHP_FE(apache_get_version, arginfo_apachehooks__void)
- PHP_FE(apache_get_modules, arginfo_apachehooks__void)
- PHP_FALIAS(getallheaders, apache_request_headers, arginfo_apachehooks__void)
- {NULL, NULL, NULL}
-};
-
-/* {{{ php_apache ini entries
- */
-PHP_INI_BEGIN()
- STD_PHP_INI_ENTRY("xbithack", "0", PHP_INI_ALL, OnUpdateLong, xbithack, php_apache_info_struct, php_apache_info)
- STD_PHP_INI_ENTRY("engine", "1", PHP_INI_ALL, OnUpdateLong, engine, php_apache_info_struct, php_apache_info)
- STD_PHP_INI_ENTRY("last_modified", "0", PHP_INI_ALL, OnUpdateLong, last_modified, php_apache_info_struct, php_apache_info)
- STD_PHP_INI_ENTRY("child_terminate", "0", PHP_INI_ALL, OnUpdateLong, terminate_child, php_apache_info_struct, php_apache_info)
-PHP_INI_END()
-/* }}} */
-
-static void php_apache_globals_ctor(php_apache_info_struct *apache_globals)
-{
- apache_globals->in_request = 0;
-}
-
-
-#define APREQ_GET_THIS(ZVAL) if (NULL == (ZVAL = getThis())) { \
- php_error(E_WARNING, "%s(): underlying ApacheRequest object missing", \
- get_active_function_name()); \
- RETURN_FALSE; \
- }
-#define APREQ_GET_REQUEST(ZVAL, R) APREQ_GET_THIS(ZVAL); \
- R = get_apache_request(ZVAL)
-
-static void php_apache_request_free(zend_rsrc_list_entry *rsrc)
-{
- zval *z = (zval *)rsrc->ptr;
-/* fprintf(stderr, "%s() %p\n", __FUNCTION__, z); */
- zval_ptr_dtor(&z);
-}
-
-static request_rec *get_apache_request(zval *z)
-{
- request_rec *r;
- zval **addr;
-
- if (NULL == z) {
- php_error(E_WARNING, "get_apache_request() invalid wrapper passed");
- return NULL;
- }
-
- if (Z_TYPE_P(z) != IS_OBJECT) {
- php_error(E_WARNING, "%s(): wrapper is not an object", get_active_function_name());
- return NULL;
- }
-
- if (zend_hash_index_find(Z_OBJPROP_P(z), 0, (void **)&addr) == FAILURE) {
- php_error(E_WARNING, "%s(): underlying object missing", get_active_function_name());
- return NULL;
- }
-
- r = (request_rec *)Z_LVAL_PP(addr);
- if (!r) {
- php_error(E_WARNING, "%s(): request_rec invalid", get_active_function_name());
- return NULL;
- }
-
- return r;
-}
-
-/* {{{ php_apache_request_new(request_rec *r)
- * create a new zval-instance for ApacheRequest that wraps request_rec
- */
-zval *php_apache_request_new(request_rec *r)
-{
- zval *req;
- zval *addr;
-
- MAKE_STD_ZVAL(addr);
- Z_TYPE_P(addr) = IS_LONG;
- Z_LVAL_P(addr) = (int) r;
-
- MAKE_STD_ZVAL(req);
- object_init_ex(req, apacherequest_class_entry);
- zend_hash_index_update(Z_OBJPROP_P(req), 0, &addr, sizeof(zval *), NULL);
-
- return req;
-}
-/* }}} */
-
-/* {{{ apache_request_read_string_slot()
- */
-static void apache_request_read_string_slot(int offset, INTERNAL_FUNCTION_PARAMETERS)
-{
- zval *id;
- request_rec *r;
- char *s;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- s = *(char **)((char*)r + offset);
-
- if (s) {
- RETURN_STRING(s, 1);
- }
-
- RETURN_EMPTY_STRING();
-}
-/* }}} */
-
-
-/* {{{ apache_request_string_slot()
- */
-static void apache_request_string_slot(int offset, INTERNAL_FUNCTION_PARAMETERS)
-{
- zval *id;
- request_rec *r;
- char *old_value, *new_value = NULL;
- int new_value_len;
- char **target;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &new_value, &new_value_len) == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- target = (char **)((char*)r + offset);
- old_value = *target;
-
- if (new_value) {
- *target = ap_pstrdup(r->pool, new_value);
- }
-
- if (old_value) {
- RETURN_STRING(old_value, 1);
- }
-
- RETURN_EMPTY_STRING();
-}
-/* }}} */
-
-/* {{{ apache_request_read_int_slot()
- */
-static void apache_request_read_int_slot(int offset, INTERNAL_FUNCTION_PARAMETERS)
-{
- zval *id;
- request_rec *r;
- long l;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- l = *(long *)((char*)r + offset);
-
- RETURN_LONG(l);
-}
-/* }}} */
-
-/* {{{ apache_request_int_slot()
- */
-static void apache_request_int_slot(int offset, INTERNAL_FUNCTION_PARAMETERS)
-{
- zval *id;
- request_rec *r;
- long old_value, new_value;
- long *target;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &new_value) == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- target = (long *)((char*)r + offset);
- old_value = *target;
-
- switch (ZEND_NUM_ARGS()) {
- case 0:
- break;
- case 1:
- *target = new_value;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- RETURN_LONG(old_value);
-}
-/* }}} */
-
-
-/* {{{ access string slots of request rec
- */
-
-/* {{{ proto string ApacheRequest::filename([string new_filename])
- */
-PHP_FUNCTION(apache_request_filename)
-{
- apache_request_string_slot(offsetof(request_rec, filename), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto string ApacheRequest::uri([string new_uri])
- */
-PHP_FUNCTION(apache_request_uri)
-{
- apache_request_string_slot(offsetof(request_rec, uri), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto string ApacheRequest::unparsed_uri([string new_unparsed_uri])
- */
-PHP_FUNCTION(apache_request_unparsed_uri)
-{
- apache_request_string_slot(offsetof(request_rec, unparsed_uri), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto string ApacheRequest::path_info([string new_path_info])
- */
-PHP_FUNCTION(apache_request_path_info)
-{
- apache_request_string_slot(offsetof(request_rec, path_info), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto string ApacheRequest::args([string new_args])
- */
-PHP_FUNCTION(apache_request_args)
-{
- apache_request_string_slot(offsetof(request_rec, args), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto string ApacheRequest::boundary()
- */
-PHP_FUNCTION(apache_request_boundary)
-{
- apache_request_read_string_slot(offsetof(request_rec, boundary), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-
-/* {{{ proto string ApacheRequest::content_type([string new_type])
- */
-PHP_FUNCTION(apache_request_content_type)
-{
- apache_request_string_slot(offsetof(request_rec, content_type), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto string ApacheRequest::content_encoding([string new_encoding])
- */
-PHP_FUNCTION(apache_request_content_encoding)
-{
- apache_request_string_slot(offsetof(request_rec, content_encoding), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto string ApacheRequest::handler([string new_handler])
- */
-PHP_FUNCTION(apache_request_handler)
-{
- apache_request_string_slot(offsetof(request_rec, handler), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto string ApacheRequest::the_request()
- */
-PHP_FUNCTION(apache_request_the_request)
-{
- apache_request_read_string_slot(offsetof(request_rec, the_request), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto string ApacheRequest::protocol()
- */
-PHP_FUNCTION(apache_request_protocol)
-{
- apache_request_read_string_slot(offsetof(request_rec, protocol), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto string ApacheRequest::hostname()
- */
-PHP_FUNCTION(apache_request_hostname)
-{
- apache_request_read_string_slot(offsetof(request_rec, hostname), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto string ApacheRequest::status_line([string new_status_line])
- */
-PHP_FUNCTION(apache_request_status_line)
-{
- apache_request_string_slot(offsetof(request_rec, status_line), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto string ApacheRequest::method()
- */
-PHP_FUNCTION(apache_request_method)
-{
- apache_request_read_string_slot(offsetof(request_rec, method), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* }}} access string slots of request rec */
-
-/* {{{ access int slots of request_rec
- */
-
-/* {{{ proto int ApacheRequest::proto_num()
- */
-PHP_FUNCTION(apache_request_proto_num)
-{
- apache_request_read_int_slot(offsetof(request_rec, proto_num), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto int ApacheRequest::assbackwards()
- */
-PHP_FUNCTION(apache_request_assbackwards)
-{
- apache_request_read_int_slot(offsetof(request_rec, assbackwards), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-
-/* {{{ proto int ApacheRequest::proxyreq([int new_proxyreq])
- */
-PHP_FUNCTION(apache_request_proxyreq)
-{
- apache_request_int_slot(offsetof(request_rec, proxyreq), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto int ApacheRequest::chunked()
- */
-PHP_FUNCTION(apache_request_chunked)
-{
- apache_request_read_int_slot(offsetof(request_rec, chunked), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-
-/* {{{ proto int ApacheRequest::header_only()
- */
-PHP_FUNCTION(apache_request_header_only)
-{
- apache_request_read_int_slot(offsetof(request_rec, header_only), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto int ApacheRequest::request_time()
- */
-PHP_FUNCTION(apache_request_request_time)
-{
- apache_request_read_int_slot(offsetof(request_rec, request_time), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto int ApacheRequest::status([int new_status])
- */
-PHP_FUNCTION(apache_request_status)
-{
- apache_request_int_slot(offsetof(request_rec, status), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto int ApacheRequest::method_number([int method_number])
- */
-PHP_FUNCTION(apache_request_method_number)
-{
- apache_request_read_int_slot(offsetof(request_rec, method_number), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto int ApacheRequest::allowed([int allowed])
- */
-PHP_FUNCTION(apache_request_allowed)
-{
- apache_request_int_slot(offsetof(request_rec, allowed), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto int ApacheRequest::bytes_sent()
- */
-PHP_FUNCTION(apache_request_bytes_sent)
-{
- apache_request_read_int_slot(offsetof(request_rec, bytes_sent), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto int ApacheRequest::mtime()
- */
-PHP_FUNCTION(apache_request_mtime)
-{
- apache_request_read_int_slot(offsetof(request_rec, mtime), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto int ApacheRequest::content_length([int new_content_length])
- */
-PHP_FUNCTION(apache_request_content_length)
-{
- zval *id;
- long zlen;
- request_rec *r;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &zlen) == FAILURE) {
- return;
- }
-
- if (ZEND_NUM_ARGS() == 0) {
- apache_request_read_int_slot(offsetof(request_rec, clength), INTERNAL_FUNCTION_PARAM_PASSTHRU);
- } else {
- APREQ_GET_REQUEST(id, r);
-
- (void)ap_set_content_length(r, zlen);
- RETURN_TRUE;
- }
-}
-/* }}} */
-
-/* {{{ proto int ApacheRequest::remaining()
- */
-PHP_FUNCTION(apache_request_remaining)
-{
- apache_request_read_int_slot(offsetof(request_rec, remaining), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto int ApacheRequest::no_cache()
- */
-PHP_FUNCTION(apache_request_no_cache)
-{
- apache_request_int_slot(offsetof(request_rec, no_cache), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto int ApacheRequest::no_local_copy()
- */
-PHP_FUNCTION(apache_request_no_local_copy)
-{
- apache_request_int_slot(offsetof(request_rec, no_local_copy), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto int ApacheRequest::read_body()
- */
-PHP_FUNCTION(apache_request_read_body)
-{
- apache_request_int_slot(offsetof(request_rec, read_body), INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-
-/* }}} access int slots of request_rec */
-
-
-/* {{{ proto array apache_request_headers_in()
- * fetch all incoming request headers
- */
-PHP_FUNCTION(apache_request_headers_in)
-{
- zval *id;
- request_rec *r;
-
- APREQ_GET_REQUEST(id, r);
-
- apache_table_to_zval(r->headers_in, return_value);
-}
-/* }}} */
-
-
-/* {{{ add_header_to_table
-*/
-static void add_header_to_table(table *t, INTERNAL_FUNCTION_PARAMETERS)
-{
- zval *first = NULL;
- zval *second = NULL;
- zval **entry, **value;
- char *string_key;
- uint string_key_len;
- ulong num_key;
-
- zend_bool replace = 0;
- HashPosition pos;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|zb", &first, &second, &replace) == FAILURE) {
- RETURN_FALSE;
- }
-
- if (Z_TYPE_P(first) == IS_ARRAY) {
- switch(ZEND_NUM_ARGS()) {
- case 1:
- case 3:
- zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(first), &pos);
- while (zend_hash_get_current_data_ex(Z_ARRVAL_P(first), (void **)&entry, &pos) == SUCCESS) {
- switch(zend_hash_get_current_key_ex(Z_ARRVAL_P(first), &string_key, &string_key_len, &num_key, &pos)) {
- case HASH_KEY_IS_STRING:
- if (zend_hash_find(Z_ARRVAL_P(first), string_key, string_key_len, (void **)&value) == FAILURE) {
- zend_hash_move_forward_ex(Z_ARRVAL_P(first), &pos);
- continue;
- }
- if (!value) {
- zend_hash_move_forward_ex(Z_ARRVAL_P(first), &pos);
- continue;
- }
-
- convert_to_string_ex(value);
- if (replace) {
- ap_table_set(t, string_key, Z_STRVAL_PP(value));
- } else {
- ap_table_merge(t, string_key, Z_STRVAL_PP(value));
- }
- break;
- case HASH_KEY_IS_LONG:
- default:
- php_error(E_WARNING, "%s(): Can only add STRING keys to headers!", get_active_function_name());
- break;
- }
-
- zend_hash_move_forward_ex(Z_ARRVAL_P(first), &pos);
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
- } else if (Z_TYPE_P(first) == IS_STRING) {
- switch(ZEND_NUM_ARGS()) {
- case 2:
- case 3:
- convert_to_string_ex(&second);
- if (replace) {
- ap_table_set(t, Z_STRVAL_P(first), Z_STRVAL_P(second));
- } else {
- ap_table_merge(t, Z_STRVAL_P(first), Z_STRVAL_P(second));
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
- } else {
- RETURN_FALSE;
- }
-}
-
-/* }}} */
-
-
-/* {{{ proto array apache_request_headers_out([{string name|array list} [, string value [, bool replace = false]]])
- * fetch all outgoing request headers
- */
-PHP_FUNCTION(apache_request_headers_out)
-{
- zval *id;
- request_rec *r;
-
- APREQ_GET_REQUEST(id, r);
-
- if (ZEND_NUM_ARGS() > 0) {
- add_header_to_table(r->headers_out, INTERNAL_FUNCTION_PARAM_PASSTHRU);
- }
-
- apache_table_to_zval(r->headers_out, return_value);
-}
-/* }}} */
-
-
-/* {{{ proto array apache_request_err_headers_out([{string name|array list} [, string value [, bool replace = false]]])
- * fetch all headers that go out in case of an error or a subrequest
- */
-PHP_FUNCTION(apache_request_err_headers_out)
-{
- zval *id;
- request_rec *r;
-
- APREQ_GET_REQUEST(id, r);
-
- if (ZEND_NUM_ARGS() > 0) {
- add_header_to_table(r->err_headers_out, INTERNAL_FUNCTION_PARAM_PASSTHRU);
- }
-
- apache_table_to_zval(r->err_headers_out, return_value);
-}
-/* }}} */
-
-
-/* {{{ proxy functions for the ap_* functions family
- */
-
-/* {{{ proto int apache_request_server_port()
- */
-PHP_FUNCTION(apache_request_server_port)
-{
- zval *id;
- request_rec *r;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- RETURN_LONG(ap_get_server_port(r));
-}
-/* }}} */
-
-/* {{{ proto int apache_request_remote_host([int type])
- */
-PHP_FUNCTION(apache_request_remote_host)
-{
- zval *id;
- long type = 0;
- request_rec *r;
- char *res;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &type) == FAILURE) {
- return;
- }
-
- if (!type) {
- type = REMOTE_NAME;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- res = (char *)ap_get_remote_host(r->connection, r->per_dir_config, (int)type);
-
- if (res) {
- RETURN_STRING(res, 1);
- }
-
- RETURN_EMPTY_STRING();
-}
-/* }}} */
-
-/* {{{ proto long apache_request_update_mtime([int dependency_mtime])
- */
-PHP_FUNCTION(apache_request_update_mtime)
-{
- zval *id;
- request_rec *r;
- long mtime = 0;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &mtime) == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- RETURN_LONG(ap_update_mtime(r, (int) mtime));
-}
-/* }}} */
-
-
-/* {{{ proto void apache_request_set_etag()
- */
-PHP_FUNCTION(apache_request_set_etag)
-{
- zval *id;
- request_rec *r;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- ap_set_etag(r);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void apache_request_set_last_modified()
- */
-PHP_FUNCTION(apache_request_set_last_modified)
-{
- zval *id;
- request_rec *r;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- ap_set_last_modified(r);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto long apache_request_meets_conditions()
- */
-PHP_FUNCTION(apache_request_meets_conditions)
-{
- zval *id;
- request_rec *r;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- RETURN_LONG(ap_meets_conditions(r));
-}
-/* }}} */
-
-/* {{{ proto long apache_request_discard_request_body()
- */
-PHP_FUNCTION(apache_request_discard_request_body)
-{
- zval *id;
- request_rec *r;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- RETURN_LONG(ap_discard_request_body(r));
-}
-/* }}} */
-
-/* {{{ proto long apache_request_satisfies()
- */
-PHP_FUNCTION(apache_request_satisfies)
-{
- zval *id;
- request_rec *r;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- RETURN_LONG(ap_satisfies(r));
-}
-/* }}} */
-
-
-/* {{{ proto bool apache_request_is_initial_req()
- */
-PHP_FUNCTION(apache_request_is_initial_req)
-{
- zval *id;
- request_rec *r;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- RETURN_BOOL(ap_is_initial_req(r));
-}
-/* }}} */
-
-/* {{{ proto bool apache_request_some_auth_required()
- */
-PHP_FUNCTION(apache_request_some_auth_required)
-{
- zval *id;
- request_rec *r;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- RETURN_BOOL(ap_some_auth_required(r));
-}
-/* }}} */
-
-/* {{{ proto string apache_request_auth_type()
- */
-PHP_FUNCTION(apache_request_auth_type)
-{
- zval *id;
- request_rec *r;
- char *t;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- t = (char *)ap_auth_type(r);
- if (!t) {
- RETURN_NULL();
- }
-
- RETURN_STRING(t, 1);
-}
-/* }}} */
-
-/* {{{ proto string apache_request_auth_name()
- */
-PHP_FUNCTION(apache_request_auth_name)
-{
- zval *id;
- request_rec *r;
- char *t;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- t = (char *)ap_auth_name(r);
- if (!t) {
- RETURN_NULL();
- }
-
- RETURN_STRING(t, 1);
-}
-/* }}} */
-
-/* {{{ proto apache_request_basic_auth_pw()
- */
-PHP_FUNCTION(apache_request_basic_auth_pw)
-{
- zval *id, *zpw;
- request_rec *r;
- const char *pw;
- long status;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &zpw) == FAILURE) {
- return;
- }
-
- if (!PZVAL_IS_REF(zpw)) {
- zend_error(E_WARNING, "Parameter wasn't passed by reference");
- RETURN_NULL();
- }
-
- APREQ_GET_REQUEST(id, r);
-
- pw = NULL;
- status = ap_get_basic_auth_pw(r, &pw);
- if (status == OK && pw) {
- ZVAL_STRING(zpw, (char *)pw, 1);
- } else {
- ZVAL_NULL(zpw);
- }
- RETURN_LONG(status);
-}
-/* }}} */
-
-
-/* http_protocol.h */
-
-PHP_FUNCTION(apache_request_send_http_header)
-{
- zval *id;
- request_rec *r;
- char *type = NULL;
- int typelen;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() , "|s", &type, &typelen) == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
- if(type) {
- r->content_type = pstrdup(r->pool, type);
- }
- ap_send_http_header(r);
- SG(headers_sent) = 1;
- AP(headers_sent) = 1;
- RETURN_TRUE;
-}
-
-PHP_FUNCTION(apache_request_basic_http_header)
-{
- zval *id;
- request_rec *r;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- ap_basic_http_header((request_rec *)SG(server_context));
- SG(headers_sent) = 1;
- AP(headers_sent) = 1;
- RETURN_TRUE;
-}
-
-PHP_FUNCTION(apache_request_send_http_trace)
-{
- zval *id;
- request_rec *r;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- ap_send_http_trace((request_rec *)SG(server_context));
- SG(headers_sent) = 1;
- AP(headers_sent) = 1;
- RETURN_TRUE;
-}
-
-PHP_FUNCTION(apache_request_send_http_options)
-{
- zval *id;
- request_rec *r;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- ap_send_http_options((request_rec *)SG(server_context));
- SG(headers_sent) = 1;
- AP(headers_sent) = 1;
- RETURN_TRUE;
-}
-
-PHP_FUNCTION(apache_request_send_error_response)
-{
- zval *id;
- request_rec *r;
- long rec = 0;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &rec) == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
- ap_send_error_response(r, (int) rec);
- RETURN_TRUE;
-}
-
-PHP_FUNCTION(apache_request_set_content_length)
-{
- long length;
- zval *id;
- request_rec *r;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &length) == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- ap_set_content_length(r, length);
- RETURN_TRUE;
-}
-
-PHP_FUNCTION(apache_request_set_keepalive)
-{
- zval *id;
- request_rec *r;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
- ap_set_keepalive(r);
- RETURN_TRUE;
-}
-
-/* This stuff should use streams or however this is implemented now
-
-PHP_FUNCTION(apache_request_send_fd)
-{
-}
-
-PHP_FUNCTION(apache_request_send_fd_length)
-{
-}
-*/
-
-/* These are for overriding default output behaviour */
-PHP_FUNCTION(apache_request_rputs)
-{
- char *buffer;
- int buffer_len;
- zval *id;
- request_rec *r;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &buffer, &buffer_len) == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
- ap_rwrite(buffer, buffer_len, (request_rec*)SG(server_context));
-}
-
-/* This stuff would be useful for custom POST handlers,
- which should be supported. Probably by not using
- sapi_activate at all inside a phpResponseHandler
- and instead using a builtin composed of the below
- calls as a apache_read_request_body() and allow
- people to custom craft their own.
-
-PHP_FUNCTION(apache_request_setup_client_block)
-{
-}
-
-PHP_FUNCTION(apache_request_should_client_block)
-{
-}
-
-PHP_FUNCTION(apache_request_get_client_block)
-{
-}
-
-PHP_FUNCTION(apache_request_discard_request_body)
-{
-}
-*/
-
-/* http_log.h */
-
-/* {{{ proto boolean apache_request_log_error(string message, [long facility])
- */
-PHP_FUNCTION(apache_request_log_error)
-{
- zval *id;
- char *z_errstr;
- int z_errstr_len;
- long facility = APLOG_ERR;
- request_rec *r;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &z_errstr, &z_errstr_len, &facility) == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
- ap_log_error(APLOG_MARK, (int) facility, r->server, "%s", z_errstr);
- RETURN_TRUE;
-}
-/* }}} */
-/* http_main.h */
-
-/* {{{ proto object apache_request_sub_req_lookup_uri(string uri)
- Returns sub-request for the specified uri. You would
- need to run it yourself with run()
-*/
-PHP_FUNCTION(apache_request_sub_req_lookup_uri)
-{
- zval *id;
- char *file;
- int file_len;
- request_rec *r, *sub_r;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &file, &file_len) == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
- sub_r = ap_sub_req_lookup_uri(file, r);
-
- if (!sub_r) {
- RETURN_FALSE;
- }
- return_value = php_apache_request_new(sub_r);
-}
-/* }}} */
-
-/* {{{ proto object apache_request_sub_req_lookup_file(string file)
- Returns sub-request for the specified file. You would
- need to run it yourself with run().
-*/
-PHP_FUNCTION(apache_request_sub_req_lookup_file)
-{
- zval *id;
- char *file;
- int file_len;
- request_rec *r, *sub_r;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &file, &file_len) == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- sub_r = ap_sub_req_lookup_file(file, r);
-
- if (!sub_r) {
- RETURN_FALSE;
- }
- return_value = php_apache_request_new(sub_r);
-}
-/* }}} */
-
-/* {{{ proto object apache_request_sub_req_method_uri(string method, string uri)
- Returns sub-request for the specified file. You would
- need to run it yourself with run().
-*/
-PHP_FUNCTION(apache_request_sub_req_method_uri)
-{
- zval *id;
- char *file, *method;
- int file_len, method_len;
- request_rec *r, *sub_r;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &method, &method_len, &file, &file_len) == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- sub_r = ap_sub_req_method_uri(method, file, r);
-
- if (!sub_r) {
- RETURN_FALSE;
- }
- return_value = php_apache_request_new(sub_r);
-}
-/* }}} */
-
-/* {{{ proto long apache_request_run()
- This is a wrapper for ap_sub_run_req and ap_destory_sub_req. It takes
- sub_request, runs it, destroys it, and returns it's status.
-*/
-PHP_FUNCTION(apache_request_run)
-{
- zval *id;
- request_rec *r;
- int status;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
- if (!r || ap_is_initial_req(r)) {
- RETURN_FALSE;
- }
- status = ap_run_sub_req(r);
- ap_destroy_sub_req(r);
- RETURN_LONG(status);
-}
-/* }}} */
-
-PHP_FUNCTION(apache_request_internal_redirect)
-{
- zval *id;
- char *new_uri;
- int new_uri_len;
- request_rec *r;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &new_uri, &new_uri_len) == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- ap_internal_redirect(new_uri, r);
-}
-
-PHP_FUNCTION(apache_request_send_header_field)
-{
- char *fieldname, *fieldval;
- int fieldname_len, fieldval_len;
- zval *id;
- request_rec *r;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fieldname, &fieldname_len, &fieldval, &fieldval_len) == FAILURE) {
- return;
- }
-
- APREQ_GET_REQUEST(id, r);
-
- ap_send_header_field(r, fieldname, fieldval);
- SG(headers_sent) = 1;
- AP(headers_sent) = 1;
-}
-
-
-
-/* }}} */
-
-/* {{{ php_apache_request_class_functions
- */
-const static zend_function_entry php_apache_request_class_functions[] = {
- /* string slots */
- PHP_FALIAS(args, apache_request_args, NULL)
- PHP_FALIAS(boundary, apache_request_boundary, NULL)
- PHP_FALIAS(content_encoding, apache_request_content_encoding, NULL)
- PHP_FALIAS(content_type, apache_request_content_type, NULL)
- PHP_FALIAS(filename, apache_request_filename, NULL)
- PHP_FALIAS(handler, apache_request_handler, NULL)
- PHP_FALIAS(hostname, apache_request_hostname, NULL)
- PHP_FALIAS(method, apache_request_method, NULL)
- PHP_FALIAS(path_info, apache_request_path_info, NULL)
- PHP_FALIAS(protocol, apache_request_protocol, NULL)
- PHP_FALIAS(status_line, apache_request_status_line, NULL)
- PHP_FALIAS(the_request, apache_request_the_request, NULL)
- PHP_FALIAS(unparsed_uri, apache_request_unparsed_uri, NULL)
- PHP_FALIAS(uri, apache_request_uri, NULL)
-
- /* int slots */
- PHP_FALIAS(allowed, apache_request_allowed, NULL)
- PHP_FALIAS(bytes_sent, apache_request_bytes_sent, NULL)
- PHP_FALIAS(chunked, apache_request_chunked, NULL)
- PHP_FALIAS(content_length, apache_request_content_length, NULL)
- PHP_FALIAS(header_only, apache_request_header_only, NULL)
- PHP_FALIAS(method_number, apache_request_method_number, NULL)
- PHP_FALIAS(mtime, apache_request_mtime, NULL)
- PHP_FALIAS(no_cache, apache_request_no_cache, NULL)
- PHP_FALIAS(no_local_copy, apache_request_no_local_copy, NULL)
- PHP_FALIAS(proto_num, apache_request_proto_num, NULL)
- PHP_FALIAS(proxyreq, apache_request_proxyreq, NULL)
- PHP_FALIAS(read_body, apache_request_read_body, NULL)
- PHP_FALIAS(remaining, apache_request_remaining, NULL)
- PHP_FALIAS(request_time, apache_request_request_time, NULL)
- PHP_FALIAS(status, apache_request_status, NULL)
-
- /* tables & arrays */
- PHP_FALIAS(headers_in, apache_request_headers_in, NULL)
- PHP_FALIAS(headers_out, apache_request_headers_out, NULL)
- PHP_FALIAS(err_headers_out, apache_request_err_headers_out, NULL)
-
-
- /* proxy functions for the ap_* functions family */
-#undef auth_name
-#undef auth_type
-#undef discard_request_body
-#undef is_initial_req
-#undef meets_conditions
-#undef satisfies
-#undef set_etag
-#undef set_last_modified
-#undef some_auth_required
-#undef update_mtime
-#undef send_http_header
-#undef send_header_field
-#undef basic_http_header
-#undef send_http_trace
-#undef send_http_options
-#undef send_error_response
-#undef set_content_length
-#undef set_keepalive
-#undef rputs
-#undef log_error
-#undef lookup_uri
-#undef lookup_file
-#undef method_uri
-#undef run
-#undef internal_redirect
- PHP_FALIAS(auth_name, apache_request_auth_name, NULL)
- PHP_FALIAS(auth_type, apache_request_auth_type, NULL)
- PHP_FALIAS(basic_auth_pw, apache_request_basic_auth_pw, NULL)
- PHP_FALIAS(discard_request_body, apache_request_discard_request_body, NULL)
- PHP_FALIAS(is_initial_req, apache_request_is_initial_req, NULL)
- PHP_FALIAS(meets_conditions, apache_request_meets_conditions, NULL)
- PHP_FALIAS(remote_host, apache_request_remote_host, NULL)
- PHP_FALIAS(satisfies, apache_request_satisfies, NULL)
- PHP_FALIAS(server_port, apache_request_server_port, NULL)
- PHP_FALIAS(set_etag, apache_request_set_etag, NULL)
- PHP_FALIAS(set_last_modified, apache_request_set_last_modified, NULL)
- PHP_FALIAS(some_auth_required, apache_request_some_auth_required, NULL)
- PHP_FALIAS(update_mtime, apache_request_update_mtime, NULL)
- PHP_FALIAS(send_http_header, apache_request_send_http_header, NULL)
- PHP_FALIAS(basic_http_header, apache_request_basic_http_header, NULL)
- PHP_FALIAS(send_header_field, apache_request_send_header_field, NULL)
- PHP_FALIAS(send_http_trace, apache_request_send_http_trace, NULL)
- PHP_FALIAS(send_http_options, apache_request_send_http_trace, NULL)
- PHP_FALIAS(send_error_response, apache_request_send_error_response, NULL)
- PHP_FALIAS(set_content_length, apache_request_set_content_length, NULL)
- PHP_FALIAS(set_keepalive, apache_request_set_keepalive, NULL)
- PHP_FALIAS(rputs, apache_request_rputs, NULL)
- PHP_FALIAS(log_error, apache_request_log_error, NULL)
- PHP_FALIAS(lookup_uri, apache_request_sub_req_lookup_uri, NULL)
- PHP_FALIAS(lookup_file, apache_request_sub_req_lookup_file, NULL)
- PHP_FALIAS(method_uri, apache_request_sub_req_method_uri, NULL)
- PHP_FALIAS(run, apache_request_run, NULL)
- PHP_FALIAS(internal_redirect, apache_request_internal_redirect, NULL)
- PHP_FE_END
-};
-/* }}} */
-
-
-static PHP_MINIT_FUNCTION(apache)
-{
- zend_class_entry ce;
-
-#ifdef ZTS
- ts_allocate_id(&php_apache_info_id, sizeof(php_apache_info_struct), (ts_allocate_ctor) php_apache_globals_ctor, NULL);
-#else
- php_apache_globals_ctor(&php_apache_info);
-#endif
- REGISTER_INI_ENTRIES();
-
-
- le_apachereq = zend_register_list_destructors_ex(php_apache_request_free, NULL, "ApacheRequest", module_number);
- INIT_OVERLOADED_CLASS_ENTRY(ce, "ApacheRequest", php_apache_request_class_functions, NULL, NULL, NULL);
- apacherequest_class_entry = zend_register_internal_class_ex(&ce, NULL);
-
- REGISTER_LONG_CONSTANT("OK", OK, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("DECLINED", DECLINED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FORBIDDEN", FORBIDDEN, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("AUTH_REQUIRED", AUTH_REQUIRED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("DONE", DONE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SERVER_ERROR", SERVER_ERROR, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("REDIRECT", REDIRECT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("BAD_REQUEST", BAD_REQUEST, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("NOT_FOUND", NOT_FOUND, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_CONTINUE", HTTP_CONTINUE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_SWITCHING_PROTOCOLS", HTTP_SWITCHING_PROTOCOLS, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_PROCESSING", HTTP_PROCESSING, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_OK", HTTP_OK, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_CREATED", HTTP_CREATED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_ACCEPTED", HTTP_ACCEPTED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_NON_AUTHORITATIVE", HTTP_NON_AUTHORITATIVE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_NO_CONTENT", HTTP_NO_CONTENT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_RESET_CONTENT", HTTP_RESET_CONTENT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_PARTIAL_CONTENT", HTTP_PARTIAL_CONTENT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_MULTI_STATUS", HTTP_MULTI_STATUS, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_MULTIPLE_CHOICES", HTTP_MULTIPLE_CHOICES, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_MOVED_PERMANENTLY", HTTP_MOVED_PERMANENTLY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_MOVED_TEMPORARILY", HTTP_MOVED_TEMPORARILY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_SEE_OTHER", HTTP_SEE_OTHER, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_NOT_MODIFIED", HTTP_NOT_MODIFIED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_USE_PROXY", HTTP_USE_PROXY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_TEMPORARY_REDIRECT", HTTP_TEMPORARY_REDIRECT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_BAD_REQUEST", HTTP_BAD_REQUEST, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_UNAUTHORIZED", HTTP_UNAUTHORIZED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_PAYMENT_REQUIRED", HTTP_PAYMENT_REQUIRED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_FORBIDDEN", HTTP_FORBIDDEN, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_NOT_FOUND", HTTP_NOT_FOUND, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_METHOD_NOT_ALLOWED", HTTP_METHOD_NOT_ALLOWED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_NOT_ACCEPTABLE", HTTP_NOT_ACCEPTABLE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_PROXY_AUTHENTICATION_REQUIRED", HTTP_PROXY_AUTHENTICATION_REQUIRED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_REQUEST_TIME_OUT", HTTP_REQUEST_TIME_OUT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_CONFLICT", HTTP_CONFLICT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_GONE", HTTP_GONE, CONST_CS | CONST_PERSISTENT);REGISTER_LONG_CONSTANT("HTTP_LENGTH_REQUIRED", HTTP_LENGTH_REQUIRED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_PRECONDITION_FAILED", HTTP_PRECONDITION_FAILED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_REQUEST_ENTITY_TOO_LARGE", HTTP_REQUEST_ENTITY_TOO_LARGE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_REQUEST_URI_TOO_LARGE", HTTP_REQUEST_URI_TOO_LARGE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_UNSUPPORTED_MEDIA_TYPE", HTTP_UNSUPPORTED_MEDIA_TYPE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_RANGE_NOT_SATISFIABLE", HTTP_RANGE_NOT_SATISFIABLE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_EXPECTATION_FAILED", HTTP_EXPECTATION_FAILED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_UNPROCESSABLE_ENTITY", HTTP_UNPROCESSABLE_ENTITY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_LOCKED", HTTP_LOCKED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_FAILED_DEPENDENCY", HTTP_FAILED_DEPENDENCY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_INTERNAL_SERVER_ERROR", HTTP_INTERNAL_SERVER_ERROR, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_NOT_IMPLEMENTED", HTTP_NOT_IMPLEMENTED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_BAD_GATEWAY", HTTP_BAD_GATEWAY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_SERVICE_UNAVAILABLE", HTTP_SERVICE_UNAVAILABLE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_GATEWAY_TIME_OUT", HTTP_GATEWAY_TIME_OUT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_VERSION_NOT_SUPPORTED", HTTP_VERSION_NOT_SUPPORTED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_VARIANT_ALSO_VARIES", HTTP_VARIANT_ALSO_VARIES, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_INSUFFICIENT_STORAGE", HTTP_INSUFFICIENT_STORAGE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_NOT_EXTENDED", HTTP_NOT_EXTENDED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("APLOG_EMERG", APLOG_EMERG, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("APLOG_ALERT", APLOG_ALERT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("APLOG_CRIT", APLOG_CRIT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("APLOG_ERR", APLOG_ERR, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("APLOG_WARNING", APLOG_WARNING, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("APLOG_NOTICE", APLOG_NOTICE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("APLOG_INFO", APLOG_INFO, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("APLOG_DEBUG", APLOG_DEBUG, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("M_GET", M_GET, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("M_PUT", M_PUT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("M_POST", M_POST, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("M_DELETE", M_DELETE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("M_CONNECT", M_CONNECT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("M_OPTIONS", M_OPTIONS, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("M_TRACE", M_TRACE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("M_PATCH", M_PATCH, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("M_PROPFIND", M_PROPFIND, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("M_PROPPATCH", M_PROPPATCH, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("M_MKCOL", M_MKCOL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("M_COPY", M_COPY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("M_MOVE", M_MOVE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("M_LOCK", M_LOCK, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("M_UNLOCK", M_UNLOCK, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("M_INVALID", M_INVALID, CONST_CS | CONST_PERSISTENT);
-
- /* Possible values for request_rec.read_body (set by handling module):
- * REQUEST_NO_BODY Send 413 error if message has any body
- * REQUEST_CHUNKED_ERROR Send 411 error if body without Content-Length
- * REQUEST_CHUNKED_DECHUNK If chunked, remove the chunks for me.
- * REQUEST_CHUNKED_PASS Pass the chunks to me without removal.
- */
- REGISTER_LONG_CONSTANT("REQUEST_NO_BODY", REQUEST_NO_BODY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("REQUEST_CHUNKED_ERROR", REQUEST_CHUNKED_ERROR, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("REQUEST_CHUNKED_DECHUNK", REQUEST_CHUNKED_DECHUNK, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("REQUEST_CHUNKED_PASS", REQUEST_CHUNKED_PASS, CONST_CS | CONST_PERSISTENT);
-
- /* resolve types for remote_host() */
- REGISTER_LONG_CONSTANT("REMOTE_HOST", REMOTE_HOST, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("REMOTE_NAME", REMOTE_NAME, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("REMOTE_NOLOOKUP", REMOTE_NOLOOKUP, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("REMOTE_DOUBLE_REV", REMOTE_DOUBLE_REV, CONST_CS | CONST_PERSISTENT);
-
- return SUCCESS;
-}
-
-
-static PHP_MSHUTDOWN_FUNCTION(apache)
-{
- UNREGISTER_INI_ENTRIES();
- return SUCCESS;
-}
-
-zend_module_entry apache_module_entry = {
- STANDARD_MODULE_HEADER,
- "apache",
- apache_functions,
- PHP_MINIT(apache),
- PHP_MSHUTDOWN(apache),
- NULL,
- NULL,
- PHP_MINFO(apache),
- NO_VERSION_YET,
- STANDARD_MODULE_PROPERTIES
-};
-
-/* {{{ proto bool apache_child_terminate(void)
- Terminate apache process after this request */
-PHP_FUNCTION(apache_child_terminate)
-{
-#ifndef MULTITHREAD
- if (AP(terminate_child)) {
- ap_child_terminate( ((request_rec *)SG(server_context)) );
- RETURN_TRUE;
- } else { /* tell them to get lost! */
- php_error(E_WARNING, "apache.child_terminate is disabled");
- RETURN_FALSE;
- }
-#else
- php_error(E_WARNING, "apache_child_terminate() is not supported in this build");
- RETURN_FALSE;
-#endif
-}
-/* }}} */
-
-/* {{{ proto string apache_note(string note_name [, string note_value])
- Get and set Apache request notes */
-PHP_FUNCTION(apache_note)
-{
- char *arg_name, *arg_val = NULL;
- int arg_name_len, arg_val_len;
- char *note_val;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &arg_name, &arg_name_len, &arg_val, &arg_val_len) == FAILURE) {
- return;
- }
-
- note_val = (char *) table_get(((request_rec *)SG(server_context))->notes, arg_name);
-
- if (arg_val) {
- table_set(((request_rec *)SG(server_context))->notes, arg_name, arg_val);
- }
-
- if (!note_val) {
- RETURN_FALSE;
- }
-
- RETURN_STRING(note_val, 1);
-}
-/* }}} */
-
-/* {{{ PHP_MINFO_FUNCTION
- */
-PHP_MINFO_FUNCTION(apache)
-{
- module *modp = NULL;
- char output_buf[128];
-#if !defined(WIN32) && !defined(WINNT)
- char name[64];
- char modulenames[1024];
- char *p;
-#endif
- server_rec *serv;
- extern char server_root[MAX_STRING_LEN];
- extern uid_t user_id;
- extern char *user_name;
- extern gid_t group_id;
- extern int max_requests_per_child;
-
- serv = ((request_rec *) SG(server_context))->server;
-
-
- php_info_print_table_start();
-
-#ifdef PHP_WIN32
- php_info_print_table_row(1, "Apache for Windows 95/NT");
- php_info_print_table_end();
- php_info_print_table_start();
-#elif defined(NETWARE)
- php_info_print_table_row(1, "Apache for NetWare");
- php_info_print_table_end();
- php_info_print_table_start();
-#else
- php_info_print_table_row(2, "APACHE_INCLUDE", PHP_APACHE_INCLUDE);
- php_info_print_table_row(2, "APACHE_TARGET", PHP_APACHE_TARGET);
-#endif
-
- php_info_print_table_row(2, "Apache Version", SERVER_VERSION);
-
-#ifdef APACHE_RELEASE
- snprintf(output_buf, sizeof(output_buf), "%d", APACHE_RELEASE);
- php_info_print_table_row(2, "Apache Release", output_buf);
-#endif
- snprintf(output_buf, sizeof(output_buf), "%d", MODULE_MAGIC_NUMBER);
- php_info_print_table_row(2, "Apache API Version", output_buf);
- snprintf(output_buf, sizeof(output_buf), "%s:%u", serv->server_hostname, serv->port);
- php_info_print_table_row(2, "Hostname:Port", output_buf);
-#if !defined(WIN32) && !defined(WINNT)
- snprintf(output_buf, sizeof(output_buf), "%s(%d)/%d", user_name, (int)user_id, (int)group_id);
- php_info_print_table_row(2, "User/Group", output_buf);
- snprintf(output_buf, sizeof(output_buf), "Per Child: %d - Keep Alive: %s - Max Per Connection: %d", max_requests_per_child, serv->keep_alive ? "on":"off", serv->keep_alive_max);
- php_info_print_table_row(2, "Max Requests", output_buf);
-#endif
- snprintf(output_buf, sizeof(output_buf), "Connection: %d - Keep-Alive: %d", serv->timeout, serv->keep_alive_timeout);
- php_info_print_table_row(2, "Timeouts", output_buf);
-#if !defined(WIN32) && !defined(WINNT)
-/*
- This block seems to be working on NetWare; But it seems to be showing
- all modules instead of just the loaded ones
-*/
- php_info_print_table_row(2, "Server Root", server_root);
-
- strcpy(modulenames, "");
- for(modp = top_module; modp; modp = modp->next) {
- strlcpy(name, modp->name, sizeof(name));
- if ((p = strrchr(name, '.'))) {
- *p='\0'; /* Cut off ugly .c extensions on module names */
- }
- strlcat(modulenames, name, sizeof(modulenames));
- if (modp->next) {
- strlcat(modulenames, ", ", sizeof(modulenames));
- }
- }
- php_info_print_table_row(2, "Loaded Modules", modulenames);
-#endif
-
- php_info_print_table_end();
-
- DISPLAY_INI_ENTRIES();
-
- {
- register int i;
- array_header *arr;
- table_entry *elts;
- request_rec *r;
-
- r = ((request_rec *) SG(server_context));
- arr = table_elts(r->subprocess_env);
- elts = (table_entry *)arr->elts;
-
- SECTION("Apache Environment");
- php_info_print_table_start();
- php_info_print_table_header(2, "Variable", "Value");
- for (i=0; i < arr->nelts; i++) {
- php_info_print_table_row(2, elts[i].key, elts[i].val);
- }
- php_info_print_table_end();
- }
-
- {
- array_header *env_arr;
- table_entry *env;
- int i;
- request_rec *r;
-
- r = ((request_rec *) SG(server_context));
- SECTION("HTTP Headers Information");
- php_info_print_table_start();
- php_info_print_table_colspan_header(2, "HTTP Request Headers");
- php_info_print_table_row(2, "HTTP Request", r->the_request);
- env_arr = table_elts(r->headers_in);
- env = (table_entry *)env_arr->elts;
- for (i = 0; i < env_arr->nelts; ++i) {
- if (env[i].key) {
- php_info_print_table_row(2, env[i].key, env[i].val);
- }
- }
- php_info_print_table_colspan_header(2, "HTTP Response Headers");
- env_arr = table_elts(r->headers_out);
- env = (table_entry *)env_arr->elts;
- for(i = 0; i < env_arr->nelts; ++i) {
- if (env[i].key) {
- php_info_print_table_row(2, env[i].key, env[i].val);
- }
- }
- php_info_print_table_end();
- }
-}
-/* }}} */
-
-/* {{{ proto bool virtual(string filename)
- Perform an Apache sub-request */
-/* This function is equivalent to <!--#include virtual...-->
- * in mod_include. It does an Apache sub-request. It is useful
- * for including CGI scripts or .shtml files, or anything else
- * that you'd parse through Apache (for .phtml files, you'd probably
- * want to use <?Include>. This only works when PHP is compiled
- * as an Apache module, since it uses the Apache API for doing
- * sub requests.
- */
-PHP_FUNCTION(virtual)
-{
- char *filename;
- int filename_len;
- request_rec *rr = NULL;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &filename, &filename_len) == FAILURE) {
- return;
- }
-
- if (!(rr = sub_req_lookup_uri (filename, ((request_rec *) SG(server_context))))) {
- php_error(E_WARNING, "Unable to include '%s' - URI lookup failed", filename);
- if (rr)
- destroy_sub_req (rr);
- RETURN_FALSE;
- }
-
- if (rr->status != 200) {
- php_error(E_WARNING, "Unable to include '%s' - error finding URI", filename);
- if (rr)
- destroy_sub_req (rr);
- RETURN_FALSE;
- }
-
- php_output_end_all();
- php_header();
-
- if (run_sub_req(rr)) {
- php_error(E_WARNING, "Unable to include '%s' - request execution failed", filename);
- if (rr)
- destroy_sub_req (rr);
- RETURN_FALSE;
- }
-
- if (rr)
- destroy_sub_req (rr);
- RETURN_TRUE;
-}
-/* }}} */
-
-
-/* {{{ apache_table_to_zval(table *, zval *return_value)
- Fetch all HTTP request headers */
-static void apache_table_to_zval(table *t, zval *return_value)
-{
- array_header *env_arr;
- table_entry *tenv;
- int i;
-
- array_init(return_value);
- env_arr = table_elts(t);
- tenv = (table_entry *)env_arr->elts;
- for (i = 0; i < env_arr->nelts; ++i) {
- if (!tenv[i].key) {
- continue;
- }
- if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val)==FAILURE) {
- RETURN_FALSE;
- }
- }
-
-}
-/* }}} */
-
-
-/* {{{ proto array getallheaders(void)
-*/
-/* Alias for apache_request_headers() */
-/* }}} */
-
-/* {{{ proto array apache_request_headers(void)
- Fetch all HTTP request headers */
-PHP_FUNCTION(apache_request_headers)
-{
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- apache_table_to_zval(((request_rec *)SG(server_context))->headers_in, return_value);
-}
-/* }}} */
-
-/* {{{ proto array apache_response_headers(void)
- Fetch all HTTP response headers */
-PHP_FUNCTION(apache_response_headers)
-{
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- apache_table_to_zval(((request_rec *) SG(server_context))->headers_out, return_value);
-}
-/* }}} */
-
-/* {{{ proto bool apache_setenv(string variable, string value [, bool walk_to_top])
- Set an Apache subprocess_env variable */
-PHP_FUNCTION(apache_setenv)
-{
- int var_len, val_len;
- zend_bool top=0;
- char *var = NULL, *val = NULL;
- request_rec *r = (request_rec *) SG(server_context);
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|b", &var, &var_len, &val, &val_len, &top) == FAILURE) {
- RETURN_FALSE;
- }
-
- while(top) {
- if (r->prev) {
- r = r->prev;
- }
- else break;
- }
-
- ap_table_setn(r->subprocess_env, ap_pstrndup(r->pool, var, var_len), ap_pstrndup(r->pool, val, val_len));
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto object apache_lookup_uri(string URI)
- Perform a partial request of the given URI to obtain information about it */
-PHP_FUNCTION(apache_lookup_uri)
-{
- char *filename;
- int filename_len;
- request_rec *rr=NULL;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &filename, &filename_len) == FAILURE) {
- return;
- }
-
- if(!(rr = sub_req_lookup_uri(filename, ((request_rec *) SG(server_context))))) {
- php_error(E_WARNING, "URI lookup failed", filename);
- RETURN_FALSE;
- }
-
- object_init(return_value);
- add_property_long(return_value,"status", rr->status);
-
- if (rr->the_request) {
- add_property_string(return_value,"the_request", rr->the_request);
- }
- if (rr->status_line) {
- add_property_string(return_value,"status_line", (char *)rr->status_line);
- }
- if (rr->method) {
- add_property_string(return_value,"method", (char *)rr->method);
- }
- if (rr->content_type) {
- add_property_string(return_value,"content_type", (char *)rr->content_type);
- }
- if (rr->handler) {
- add_property_string(return_value,"handler", (char *)rr->handler);
- }
- if (rr->uri) {
- add_property_string(return_value,"uri", rr->uri);
- }
- if (rr->filename) {
- add_property_string(return_value,"filename", rr->filename);
- }
- if (rr->path_info) {
- add_property_string(return_value,"path_info", rr->path_info);
- }
- if (rr->args) {
- add_property_string(return_value,"args", rr->args);
- }
- if (rr->boundary) {
- add_property_string(return_value,"boundary", rr->boundary);
- }
- add_property_long(return_value,"no_cache", rr->no_cache);
- add_property_long(return_value,"no_local_copy", rr->no_local_copy);
- add_property_long(return_value,"allowed", rr->allowed);
- add_property_long(return_value,"sent_bodyct", rr->sent_bodyct);
- add_property_long(return_value,"bytes_sent", rr->bytes_sent);
- add_property_long(return_value,"byterange", rr->byterange);
- add_property_long(return_value,"clength", rr->clength);
-
-#if MODULE_MAGIC_NUMBER >= 19980324
- if (rr->unparsed_uri) {
- add_property_string(return_value,"unparsed_uri", rr->unparsed_uri);
- }
- if(rr->mtime) {
- add_property_long(return_value,"mtime", rr->mtime);
- }
-#endif
- if(rr->request_time) {
- add_property_long(return_value,"request_time", rr->request_time);
- }
-
- destroy_sub_req(rr);
-}
-/* }}} */
-
-
-#if 0
-/*
-This function is most likely a bad idea. Just playing with it for now.
-*/
-
-PHP_FUNCTION(apache_exec_uri)
-{
- zval **filename;
- request_rec *rr=NULL;
-
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &filename) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string_ex(filename);
-
- if(!(rr = ap_sub_req_lookup_uri((*filename)->value.str.val, ((request_rec *) SG(server_context))))) {
- php_error(E_WARNING, "URI lookup failed", (*filename)->value.str.val);
- RETURN_FALSE;
- }
- RETVAL_LONG(ap_run_sub_req(rr));
- ap_destroy_sub_req(rr);
-}
-#endif
-
-/* {{{ proto string apache_get_version(void)
- Fetch Apache version */
-PHP_FUNCTION(apache_get_version)
-{
- char *apv = (char *) ap_get_server_version();
-
- if (apv && *apv) {
- RETURN_STRING(apv, 1);
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto array apache_get_modules(void)
- Get a list of loaded Apache modules */
-PHP_FUNCTION(apache_get_modules)
-{
- int n;
- char *p;
-
- array_init(return_value);
-
- for (n = 0; ap_loaded_modules[n]; ++n) {
- char *s = (char *) ap_loaded_modules[n]->name;
- if ((p = strchr(s, '.'))) {
- add_next_index_stringl(return_value, s, (p - s));
- } else {
- add_next_index_string(return_value, s);
- }
- }
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/sapi/apache_hooks/php_apache_http.h b/sapi/apache_hooks/php_apache_http.h
deleted file mode 100644
index 5684de9179..0000000000
--- a/sapi/apache_hooks/php_apache_http.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#define NO_REGEX_EXTRA_H
-
-#ifdef WIN32
-#include <winsock2.h>
-#include <stddef.h>
-#endif
-
-#ifdef NETWARE
-#include <netinet/in.h>
-#endif
-
-#include "zend.h"
-#include "zend_stack.h"
-#include "ext/ereg/php_regex.h"
-
-#include "httpd.h"
-#include "http_config.h"
-
-#if MODULE_MAGIC_NUMBER > 19980712
-# include "ap_compat.h"
-#else
-# if MODULE_MAGIC_NUMBER > 19980324
-# include "compat.h"
-# endif
-#endif
-
-#include "http_core.h"
-#include "http_main.h"
-#include "http_protocol.h"
-#include "http_request.h"
-#include "http_log.h"
-#include "util_script.h"
-
-#include "php_variables.h"
-#include "php_main.h"
-#include "php_ini.h"
-#include "ext/standard/php_standard.h"
-
-#include "mod_php7.h"
-
-
-zval *php_apache_request_new(request_rec *r);
-
-int apache_php_module_hook(request_rec *r, php_handler *handler, zval **ret);
diff --git a/sapi/apache_hooks/sapi_apache.c b/sapi/apache_hooks/sapi_apache.c
deleted file mode 100644
index dd5a6b60ea..0000000000
--- a/sapi/apache_hooks/sapi_apache.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@php.net> |
- | (with helpful hints from Dean Gaudet <dgaudet@arctic.org> |
- | PHP 4.0 patches by: |
- | Zeev Suraski <zeev@zend.com> |
- | Stig Bakken <ssb@php.net> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include "php_apache_http.h"
-
-/* {{{ apache_php_module_main
- */
-int apache_php_module_main(request_rec *r, int display_source_mode)
-{
- zend_file_handle file_handle;
-
- if (php_request_startup() == FAILURE) {
- return FAILURE;
- }
- /* sending a file handle to another dll is not working
- so let zend open it. */
-
- if (display_source_mode) {
- zend_syntax_highlighter_ini syntax_highlighter_ini;
-
- php_get_highlight_struct(&syntax_highlighter_ini);
- if (highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini)){
- return OK;
- } else {
- return NOT_FOUND;
- }
- } else {
- file_handle.type = ZEND_HANDLE_FILENAME;
- file_handle.handle.fd = 0;
- file_handle.filename = SG(request_info).path_translated;
- file_handle.opened_path = NULL;
- file_handle.free_filename = 0;
- (void) php_execute_script(&file_handle);
- }
- AP(in_request) = 0;
-
- return (OK);
-}
-/* }}} */
-
-/* {{{ apache_php_module_hook
- */
-int apache_php_module_hook(request_rec *r, php_handler *handler, zval **ret)
-{
- zend_file_handle file_handle;
- zval *req;
- char *tmp;
-
-#if PHP_SIGCHILD
- signal(SIGCHLD, sigchld_handler);
-#endif
- if(AP(current_hook) == AP_RESPONSE) {
- if (php_request_startup_for_hook() == FAILURE)
- return FAILURE;
- }
- else {
- if (php_request_startup_for_hook() == FAILURE)
- return FAILURE;
- }
-
- req = php_apache_request_new(r);
- php_register_variable_ex("request", req, PG(http_globals)[TRACK_VARS_SERVER]);
-
- switch(handler->type) {
- case AP_HANDLER_TYPE_FILE:
- php_register_variable("PHP_SELF_HOOK", handler->name, PG(http_globals)[TRACK_VARS_SERVER]);
- memset(&file_handle, 0, sizeof(file_handle));
- file_handle.type = ZEND_HANDLE_FILENAME;
- file_handle.filename = handler->name;
- (void) php_execute_simple_script(&file_handle, ret);
- break;
- case AP_HANDLER_TYPE_METHOD:
- if( (tmp = strstr(handler->name, "::")) != NULL && *(tmp+2) != '\0' ) {
- zval *class;
- zval *method;
- *tmp = '\0';
- ALLOC_ZVAL(class);
- ZVAL_STRING(class, handler->name, 1);
- ALLOC_ZVAL(method);
- ZVAL_STRING(method, tmp +2, 1);
- *tmp = ':';
- call_user_function_ex(EG(function_table), &class, method, ret, 0, NULL, 0, NULL);
- zval_dtor(class);
- zval_dtor(method);
- }
- else {
- php_error(E_ERROR, "Unable to call %s - not a Class::Method\n", handler->name);
- /* not a class::method */
- }
- break;
- default:
- /* not a valid type */
- assert(0);
- break;
- }
- zval_dtor(req);
- AP(in_request) = 0;
-
- return OK;
-}
-
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/sapi/caudium/CREDITS b/sapi/caudium/CREDITS
deleted file mode 100644
index 45789dbdfe..0000000000
--- a/sapi/caudium/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-Caudium / Roxen
-David Hedbor
diff --git a/sapi/caudium/README b/sapi/caudium/README
deleted file mode 100644
index 86ef65655d..0000000000
--- a/sapi/caudium/README
+++ /dev/null
@@ -1,16 +0,0 @@
-Embedded Caudium PHP support. It seems to work but isn't tested
-much. Due to a design choice it requires _Pike_ threads and a
-thread-safe PHP. It doesn't however require _Caudium_ to run in
-threaded mode. Due to the design, utilization of multiple processors
-should be pretty good.
-
-It requires a new Pike 7.0 and Caudium. It will not work with
-Roxen. Also, with the help of the VIRTUAL_DIR code in PHP, PHP
-execution should be very similar to that of mod_php or the cgi
-script.
-
-If you have any questions, please contact me, David Hedbor
-(neotron@php.net or neotron@caudium.net). For more information on
-Caudium, see http://caudium.net/ and http://caudium.org/.
-
-
diff --git a/sapi/caudium/TODO b/sapi/caudium/TODO
deleted file mode 100644
index b8217c5934..0000000000
--- a/sapi/caudium/TODO
+++ /dev/null
@@ -1,30 +0,0 @@
-TODO:
-
-- per-virtual-server configuration
-- configurable limit of number of concurrent PHP executions
-- fix setting of auth info.
-
-FIXED:
-+ => fixed
-- => not fixed and no fix planned
-? => Maybe fixed, maybe not.
-
-+ Allow multiple headers
- This is now fixed.
-+ fix backtraces
- Uses th_farm, thus problem is fixed
-+ exit in PHP exits Caudium
- Name conflict with do_exit in Pike and PHP. Reported to both teams.
-+ POST newline added?
- Was a Caudium bug.
-+ use th_farm
- Yeppers. Works great.
-- change cwd in single threaded mode
- There will be no single threaded mode support. The Caudium module
- will requite PHP ZTS and Pike threads to run. Single threaded PHP
- is rather uninteresting anyway.
-? Recursive mutex lock problem:
- Dunno if this is fixed. Major rewrite so it would have to be
- retested.
-
-
diff --git a/sapi/caudium/caudium.c b/sapi/caudium/caudium.c
deleted file mode 100644
index 9a00b1620a..0000000000
--- a/sapi/caudium/caudium.c
+++ /dev/null
@@ -1,782 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.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: David Hedbor <neotron@php.net> |
- | Based on aolserver SAPI by Sascha Schumann <sascha@schumann.cx> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-#ifdef HAVE_CAUDIUM
-
-#include "php_ini.h"
-#include "php_globals.h"
-#include "SAPI.h"
-#include "php_main.h"
-#include "ext/standard/info.h"
-
-#include "php_version.h"
-
-/* Pike Include Files
- *
- * conflicts with pike avoided by only using long names. Requires a new
- * Pike 0.7 since it was implemented for this interface only.
- *
- */
-#define NO_PIKE_SHORTHAND
-
-/* Ok, we are now using Pike level threads to handle PHP7 since
- * the nice th_farm threads aren't working on Linux with glibc 2.2
- * (why this is I don't know).
- */
-#define USE_PIKE_LEVEL_THREADS
-
-#include <fdlib.h>
-#include <program.h>
-#include <pike_types.h>
-#include <interpret.h>
-#include <module_support.h>
-#include <array.h>
-#include <backend.h>
-#include <stralloc.h>
-#include <mapping.h>
-#include <object.h>
-#include <threads.h>
-#include <builtin_functions.h>
-#include <operators.h>
-#include <version.h>
-
-#if (PIKE_MAJOR_VERSION == 7 && PIKE_MINOR_VERSION == 1 && PIKE_BUILD_VERSION >= 12) || PIKE_MAJOR_VERSION > 7 || (PIKE_MAJOR_VERSION == 7 && PIKE_MINOR_VERSION > 1)
-# include "pike_error.h"
-#else
-# include "error.h"
-# ifndef Pike_error
-# define Pike_error error
-# endif
-#endif
-
-/* Pike 7.x and newer */
-#define MY_MAPPING_LOOP(md, COUNT, KEY) \
- for(COUNT=0;COUNT < md->data->hashsize; COUNT++ ) \
- for(KEY=md->data->hash[COUNT];KEY;KEY=KEY->next)
-
-#ifndef ZTS
-/* Need thread safety */
-#error You need to compile PHP with threads.
-#endif
-
-#ifndef PIKE_THREADS
-#error The PHP7 module requires that your Pike has thread support.
-#endif
-
-#undef HIDE_GLOBAL_VARIABLES
-#undef REVEAL_GLOBAL_VARIABLES
-#define HIDE_GLOBAL_VARIABLES()
-#define REVEAL_GLOBAL_VARIABLES()
-
-/* php_caudium_request is per-request object storage */
-
-typedef struct
-{
- struct mapping *request_data;
- struct object *my_fd_obj;
- struct svalue done_cb;
- struct pike_string *filename;
- int my_fd;
- int written;
- TSRMLS_D;
-} php_caudium_request;
-
-
-void pike_module_init(void);
-void pike_module_exit(void);
-static void free_struct(void);
-void f_php_caudium_request_handler(INT32 args);
-
-/* Defines to get to the data supplied when the script is started. */
-
-/* Per thread storage area id... */
-static int caudium_globals_id;
-
-#define GET_THIS() php_caudium_request *_request = ts_resource(caudium_globals_id)
-#define THIS _request
-#define PTHIS ((php_caudium_request *)(Pike_fp->current_storage))
-/* File descriptor integer. Used to write directly to the FD without
- * passing Pike
- */
-#define MY_FD (THIS->my_fd)
-
-/* FD object. Really a PHPScript object from Pike which implements a couple
- * of functions to handle headers, writing and buffering.
- */
-#define MY_FD_OBJ ((struct object *)(THIS->my_fd_obj))
-
-/* Mapping with data supplied from the calling Caudium module. Contains
- * a mapping with headers, an FD object etc.
- */
-#define REQUEST_DATA ((struct mapping *)(THIS->request_data))
-
-extern int fd_from_object(struct object *o);
-static unsigned char caudium_php_initialized;
-
-#ifndef mt_lock_interpreter
-#define mt_lock_interpreter() mt_lock(&interpreter_lock);
-#define mt_unlock_interpreter() mt_unlock(&interpreter_lock);
-#endif
-
-
-/* This allows calling of pike functions from the PHP callbacks,
- * which requires the Pike interpreter to be locked.
- */
-#define THREAD_SAFE_RUN(COMMAND, what) do {\
- struct thread_state *state;\
- if((state = thread_state_for_id(th_self()))!=NULL) {\
- if(!state->swapped) {\
- COMMAND;\
- } else {\
- mt_lock_interpreter();\
- SWAP_IN_THREAD(state);\
- COMMAND;\
- SWAP_OUT_THREAD(state);\
- mt_unlock_interpreter();\
- }\
- }\
-} while(0)
-
-
-
-/* Low level header lookup. Basically looks for the named header in the mapping
- * headers in the supplied options mapping.
- */
-
-INLINE static struct svalue *lookup_header(char *headername)
-{
- struct svalue *headers, *value;
- struct pike_string *sind;
- GET_THIS();
- sind = make_shared_string("env");
- headers = low_mapping_string_lookup(REQUEST_DATA, sind);
- free_string(sind);
- if(!headers || headers->type != PIKE_T_MAPPING) return NULL;
- sind = make_shared_string(headername);
- value = low_mapping_string_lookup(headers->u.mapping, sind);
- free_string(sind);
- if(!value) return NULL;
- return value;
-}
-
-/* Lookup a header in the mapping and return the value as a string, or
- * return the default if it's missing
- */
-INLINE static char *lookup_string_header(char *headername, char *default_value)
-{
- struct svalue *head = NULL;
- THREAD_SAFE_RUN(head = lookup_header(headername), "header lookup");
- if(!head || head->type != PIKE_T_STRING)
- return default_value;
- return head->u.string->str;
-}
-
-/* Lookup a header in the mapping and return the value as if it's an integer
- * and otherwise return the default.
- */
-INLINE static int lookup_integer_header(char *headername, int default_value)
-{
- struct svalue *head = NULL;
- THREAD_SAFE_RUN(head = lookup_header(headername), "header lookup");
- if(!head || head->type != PIKE_T_INT)
- return default_value;
- return head->u.integer;
-}
-
-/*
- * php_caudium_low_ub_write() writes data to the client connection. Might be
- * rewritten to do more direct IO to save CPU and the need to lock the
- * interpreter for better threading.
- */
-
-INLINE static int
-php_caudium_low_ub_write(const char *str, uint str_length) {
- int sent_bytes = 0;
- struct pike_string *to_write = NULL;
- GET_THIS();
- if(!MY_FD_OBJ->prog) {
- PG(connection_status) = PHP_CONNECTION_ABORTED;
- zend_bailout();
- return -1;
- }
- to_write = make_shared_binary_string(str, str_length);
- push_string(to_write);
- safe_apply(MY_FD_OBJ, "write", 1);
- if(Pike_sp[-1].type == PIKE_T_INT)
- sent_bytes = Pike_sp[-1].u.integer;
- pop_stack();
- if(sent_bytes != str_length) {
- /* This means the connection is closed. Dead. Gone. *sniff* */
- PG(connection_status) = PHP_CONNECTION_ABORTED;
- zend_bailout();
- }
- return sent_bytes;
-}
-
-/*
- * php_caudium_sapi_ub_write() calls php_caudium_low_ub_write in a Pike thread
- * safe manner or writes directly to the output FD if RXML post-parsing is
- * disabled.
- */
-
-static int
-php_caudium_sapi_ub_write(const char *str, uint str_length)
-{
- GET_THIS();
- int sent_bytes = 0, fd = MY_FD;
- if(fd)
- {
- for(sent_bytes=0;sent_bytes < str_length;)
- {
- int written;
- written = fd_write(fd, str + sent_bytes, str_length - sent_bytes);
- if(written < 0)
- {
- switch(errno)
- {
- default:
- /* This means the connection is closed. Dead. Gone. *sniff* */
- PG(connection_status) = PHP_CONNECTION_ABORTED;
- zend_bailout();
- THIS->written += sent_bytes;
- return sent_bytes;
- case EINTR:
- case EWOULDBLOCK:
- continue;
- }
- } else {
- sent_bytes += written;
- }
- }
- THIS->written += sent_bytes;
- } else {
- THREAD_SAFE_RUN(sent_bytes = php_caudium_low_ub_write(str, str_length),
- "write");
- }
- return sent_bytes;
-}
-
-/* php_caudium_set_header() sets a header in the header mapping. Called in a
- * thread safe manner from php_caudium_sapi_header_handler.
- */
-INLINE static void
-php_caudium_set_header(char *header_name, char *value, char *p)
-{
- struct svalue hsval;
- struct pike_string *hval, *ind, *hind;
- struct mapping *headermap;
- struct svalue *s_headermap, *soldval;
- int vallen;
- GET_THIS();
- /* hval = make_shared_string(value); */
- ind = make_shared_string(" _headers");
- hind = make_shared_binary_string(header_name,
- (int)(p - header_name));
-
- s_headermap = low_mapping_string_lookup(REQUEST_DATA, ind);
- if(!s_headermap || s_headermap->type != PIKE_T_MAPPING)
- {
- struct svalue mappie;
- mappie.type = PIKE_T_MAPPING;
- headermap = allocate_mapping(1);
- mappie.u.mapping = headermap;
- mapping_string_insert(REQUEST_DATA, ind, &mappie);
- free_mapping(headermap);
- hval = make_shared_string(value);
- } else {
- headermap = s_headermap->u.mapping;
- soldval = low_mapping_string_lookup(headermap, hind);
- vallen = strlen(value);
- if(soldval != NULL &&
- soldval->type == PIKE_T_STRING &&
- soldval->u.string->size_shift == 0) {
- /* Existing, valid header. Prepend.*/
- hval = begin_shared_string(soldval->u.string->len + 1 + vallen);
- MEMCPY(hval->str, soldval->u.string->str, soldval->u.string->len);
- STR0(hval)[soldval->u.string->len] = '\0';
- MEMCPY(hval->str+soldval->u.string->len+1, value, vallen);
- hval = end_shared_string(hval);
- } else {
- hval = make_shared_string(value);
- }
- }
- hsval.type = PIKE_T_STRING;
- hsval.u.string = hval;
-
- mapping_string_insert(headermap, hind, &hsval);
-
- free_string(hval);
- free_string(ind);
- free_string(hind);
-}
-
-/*
- * php_caudium_sapi_header_handler() sets a HTTP reply header to be
- * sent to the client.
- */
-static int
-php_caudium_sapi_header_handler(sapi_header_struct *sapi_header,
- sapi_headers_struct *sapi_headers)
-{
- char *header_name, *header_content, *p;
- header_name = sapi_header->header;
- header_content = p = strchr(header_name, ':');
-
- if(p) {
- do {
- header_content++;
- } while(*header_content == ' ');
- THREAD_SAFE_RUN(php_caudium_set_header(header_name, header_content, p), "header handler");
- }
- sapi_free_header(sapi_header);
- return 0;
-}
-
-/*
- * php_caudium_sapi_send_headers() flushes the headers to the client.
- * Called before real content is sent by PHP.
- */
-
-INLINE static int
-php_caudium_low_send_headers(sapi_headers_struct *sapi_headers)
-{
- struct pike_string *ind;
- struct svalue *s_headermap;
- GET_THIS();
- if(!MY_FD_OBJ->prog) {
- PG(connection_status) = PHP_CONNECTION_ABORTED;
- zend_bailout();
- return SAPI_HEADER_SEND_FAILED;
- }
- ind = make_shared_string(" _headers");
- s_headermap = low_mapping_string_lookup(REQUEST_DATA, ind);
- free_string(ind);
-
- push_int(SG(sapi_headers).http_response_code);
- if(s_headermap && s_headermap->type == PIKE_T_MAPPING)
- ref_push_mapping(s_headermap->u.mapping);
- else
- push_int(0);
- safe_apply(MY_FD_OBJ, "send_headers", 2);
- pop_stack();
-
- return SAPI_HEADER_SENT_SUCCESSFULLY;
-}
-
-static int
-php_caudium_sapi_send_headers(sapi_headers_struct *sapi_headers)
-{
- int res = 0;
- THREAD_SAFE_RUN(res = php_caudium_low_send_headers(sapi_headers), "send headers");
- return res;
-}
-
-/*
- * php_caudium_sapi_read_post() reads a specified number of bytes from
- * the client. Used for POST/PUT requests.
- */
-
-INLINE static int php_caudium_low_read_post(char *buf, uint count_bytes)
-{
- uint total_read = 0;
- GET_THIS();
-
- if(!MY_FD_OBJ->prog)
- {
- PG(connection_status) = PHP_CONNECTION_ABORTED;
- zend_bailout();
- return -1;
- }
- push_int(count_bytes);
- safe_apply(MY_FD_OBJ, "read_post", 1);
- if(Pike_sp[-1].type == PIKE_T_STRING) {
- MEMCPY(buf, Pike_sp[-1].u.string->str,
- (total_read = Pike_sp[-1].u.string->len));
- buf[total_read] = '\0';
- } else
- total_read = 0;
- pop_stack();
- return total_read;
-}
-
-static int
-php_caudium_sapi_read_post(char *buf, uint count_bytes)
-{
- uint total_read = 0;
- THREAD_SAFE_RUN(total_read = php_caudium_low_read_post(buf, count_bytes), "read post");
- return total_read;
-}
-
-/*
- * php_caudium_sapi_read_cookies() returns the Cookie header from
- * the HTTP request header
- */
-
-static char *
-php_caudium_sapi_read_cookies(void)
-{
- char *cookies;
- cookies = lookup_string_header("HTTP_COOKIE", NULL);
- return cookies;
-}
-
-static void php_info_caudium(ZEND_MODULE_INFO_FUNC_ARGS)
-{
- /* char buf[512]; */
- php_info_print_table_start();
- php_info_print_table_row(2, "SAPI module version", "$Id$");
- /* php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
- php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
- php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
- php_info_print_table_row(2, "Installation path", Ns_InfoHomePath());
- php_info_print_table_row(2, "Hostname of server", Ns_InfoHostname());
- php_info_print_table_row(2, "Source code label", Ns_InfoLabel());
- php_info_print_table_row(2, "Server platform", Ns_InfoPlatform());
- snprintf(buf, 511, "%s/%s", Ns_InfoServerName(), Ns_InfoServerVersion());
- php_info_print_table_row(2, "Server version", buf);
- snprintf(buf, 511, "%d day(s), %02d:%02d:%02d",
- uptime / 86400,
- (uptime / 3600) % 24,
- (uptime / 60) % 60,
- uptime % 60);
- php_info_print_table_row(2, "Server uptime", buf);
- */
- php_info_print_table_end();
-}
-
-static zend_module_entry php_caudium_module = {
- STANDARD_MODULE_HEADER,
- "Caudium",
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- php_info_caudium,
- NULL,
- STANDARD_MODULE_PROPERTIES
-};
-
-
-INLINE static void low_sapi_caudium_register_variables(zval *track_vars_array)
-{
- int i;
- struct keypair *k;
- struct svalue *headers;
- struct pike_string *sind;
- struct svalue *ind;
- struct svalue *val;
- GET_THIS();
- php_register_variable("PHP_SELF", SG(request_info).request_uri,
- track_vars_array);
- php_register_variable("GATEWAY_INTERFACE", "CGI/1.1",
- track_vars_array);
- php_register_variable("REQUEST_METHOD",
- (char *) SG(request_info).request_method,
- track_vars_array);
- php_register_variable("REQUEST_URI", SG(request_info).request_uri,
- track_vars_array);
- php_register_variable("PATH_TRANSLATED", SG(request_info).path_translated,
- track_vars_array);
-
- sind = make_shared_string("env");
- headers = low_mapping_string_lookup(REQUEST_DATA, sind);
- free_string(sind);
- if(headers && headers->type == PIKE_T_MAPPING) {
- MY_MAPPING_LOOP(headers->u.mapping, i, k) {
- ind = &k->ind;
- val = &k->val;
- if(ind && ind->type == PIKE_T_STRING &&
- val && val->type == PIKE_T_STRING) {
- php_register_variable(ind->u.string->str, val->u.string->str,
- track_vars_array );
- }
- }
- }
-}
-
-static void sapi_caudium_register_variables(zval *track_vars_array)
-{
- THREAD_SAFE_RUN(low_sapi_caudium_register_variables(track_vars_array), "register_variables");
-}
-
-
-static int php_caudium_startup(sapi_module_struct *sapi_module)
-{
- if (php_module_startup(sapi_module, &php_caudium_module, 1)==FAILURE) {
- return FAILURE;
- }
- return SUCCESS;
-}
-
-
-/* this structure is static (as in "it does not change") */
-static sapi_module_struct caudium_sapi_module = {
- "caudium",
- "Caudium",
- php_caudium_startup, /* startup */
- php_module_shutdown_wrapper, /* shutdown */
- NULL, /* activate */
- NULL, /* deactivate */
- php_caudium_sapi_ub_write, /* unbuffered write */
- NULL, /* flush */
- NULL, /* get uid */
- NULL, /* getenv */
- php_error, /* error handler */
- php_caudium_sapi_header_handler, /* header handler */
- php_caudium_sapi_send_headers, /* send headers handler */
- NULL, /* send header handler */
- php_caudium_sapi_read_post, /* read POST data */
- php_caudium_sapi_read_cookies, /* read cookies */
- sapi_caudium_register_variables, /* register server variables */
- NULL, /* Log message */
- NULL, /* Get request time */
- NULL, /* Child terminate */
-
- STANDARD_SAPI_MODULE_PROPERTIES
-};
-
-/*
- * php_caudium_module_main() is called by the per-request handler and
- * "executes" the script
- */
-
-static void php_caudium_module_main(php_caudium_request *ureq)
-{
- int res;
- zend_file_handle file_handle;
-#ifndef USE_PIKE_LEVEL_THREADS
- struct thread_state *state;
- extern struct program *thread_id_prog;
-#endif
- GET_THIS();
- THIS->filename = ureq->filename;
- THIS->done_cb = ureq->done_cb;
- THIS->my_fd_obj = ureq->my_fd_obj;
- THIS->my_fd = ureq->my_fd;
- THIS->request_data = ureq->request_data;
- free(ureq);
-
-#ifndef USE_PIKE_LEVEL_THREADS
- mt_lock_interpreter();
- init_interpreter();
-#if PIKE_MAJOR_VERSION == 7 && PIKE_MINOR_VERSION < 1
- thread_id = low_clone(thread_id_prog);
- state = OBJ2THREAD(thread_id);
- Pike_stack_top=((char *)&state)+ (thread_stack_size-16384) * STACK_DIRECTION;
- recoveries = NULL;
- call_c_initializers(thread_id);
- OBJ2THREAD(thread_id)->id=th_self();
- num_threads++;
- thread_table_insert(thread_id);
- state->status=THREAD_RUNNING;
-#else
- Pike_interpreter.thread_id = low_clone(thread_id_prog);
- state = OBJ2THREAD(Pike_interpreter.thread_id);
- Pike_interpreter.stack_top=((char *)&state)+ (thread_stack_size-16384) * STACK_DIRECTION;
- Pike_interpreter.recoveries = NULL;
- call_c_initializers(Pike_interpreter.thread_id);
- state->id=th_self();
- /* SWAP_OUT_THREAD(OBJ2THREAD(Pike_interpreter.thread_id)); */
- num_threads++;
- thread_table_insert(Pike_interpreter.thread_id);
- state->status=THREAD_RUNNING;
-#endif
- state->swapped = 0;
-#endif
- SG(request_info).query_string = lookup_string_header("QUERY_STRING", 0);
- SG(server_context) = (void *)1; /* avoid server_context == NULL */
-
- /* path_translated is apparently the absolute path to the file, not
- the translated PATH_INFO
- */
- SG(request_info).path_translated =
- lookup_string_header("SCRIPT_FILENAME", NULL);
- SG(request_info).request_uri = lookup_string_header("DOCUMENT_URI", NULL);
- if(!SG(request_info).request_uri)
- SG(request_info).request_uri = lookup_string_header("SCRIPT_NAME", NULL);
- SG(request_info).request_method = lookup_string_header("REQUEST_METHOD", "GET");
- SG(request_info).content_length = lookup_integer_header("HTTP_CONTENT_LENGTH", 0);
- SG(request_info).content_type = lookup_string_header("HTTP_CONTENT_TYPE", NULL);
- SG(sapi_headers).http_response_code = 200;
- if (!strcmp(SG(request_info).request_method, "HEAD")) {
- SG(request_info).headers_only = 1;
- } else {
- SG(request_info).headers_only = 0;
- }
-
- /* Let PHP7 handle the deconding of the AUTH */
- php_handle_auth_data(lookup_string_header("HTTP_AUTHORIZATION", NULL), );
- /* Swap out this thread and release the interpreter lock to allow
- * Pike threads to run. We wait since the above would otherwise require
- * a lot of unlock/lock.
- */
-#ifndef USE_PIKE_LEVEL_THREADS
- SWAP_OUT_THREAD(state);
- mt_unlock_interpreter();
-#else
- THREADS_ALLOW();
-#endif
-
- file_handle.type = ZEND_HANDLE_FILENAME;
- file_handle.filename = THIS->filename->str;
- file_handle.opened_path = NULL;
- file_handle.free_filename = 0;
-
- THIS->written = 0;
- res = php_request_startup();
-
- if(res == FAILURE) {
- THREAD_SAFE_RUN({
- apply_svalue(&THIS->done_cb, 0);
- pop_stack();
- free_struct();
- }, "Negative run response");
- } else {
- php_execute_script(&file_handle);
- php_request_shutdown(NULL);
- THREAD_SAFE_RUN({
- push_int(THIS->written);
- apply_svalue(&THIS->done_cb, 1);
- pop_stack();
- free_struct();
- }, "positive run response");
- }
-
-#ifndef USE_PIKE_LEVEL_THREADS
- mt_lock_interpreter();
- SWAP_IN_THREAD(state);
-#if PIKE_MAJOR_VERSION == 7 && PIKE_MINOR_VERSION < 1
- state->status=THREAD_EXITED;
- co_signal(& state->status_change);
- thread_table_delete(thread_id);
- free_object(thread_id);
- thread_id=NULL;
-#else
- state->status=THREAD_EXITED;
- co_signal(& state->status_change);
- thread_table_delete(Pike_interpreter.thread_id);
- free_object(Pike_interpreter.thread_id);
- Pike_interpreter.thread_id=NULL;
-#endif
- cleanup_interpret();
- num_threads--;
- mt_unlock_interpreter();
-#else
- THREADS_DISALLOW();
-#endif
-}
-
-/*
- * The php_caudium_request_handler() is called per request and handles
- * everything for one request.
- */
-
-void f_php_caudium_request_handler(INT32 args)
-{
- struct object *my_fd_obj;
- struct mapping *request_data;
- struct svalue *done_callback;
- struct pike_string *script;
- struct svalue *raw_fd;
- struct pike_string *ind;
- php_caudium_request *_request;
- THIS = malloc(sizeof(php_caudium_request));
- if(THIS == NULL)
- Pike_error("Out of memory.");
-
- get_all_args("PHP5.Interpreter->run", args, "%S%m%O%*", &script,
- &request_data, &my_fd_obj, &done_callback);
- if(done_callback->type != PIKE_T_FUNCTION)
- Pike_error("PHP5.Interpreter->run: Bad argument 4, expected function.\n");
- add_ref(request_data);
- add_ref(my_fd_obj);
- add_ref(script);
-
- THIS->request_data = request_data;
- THIS->my_fd_obj = my_fd_obj;
- THIS->filename = script;
- assign_svalue_no_free(&THIS->done_cb, done_callback);
-
- ind = make_shared_binary_string("my_fd", 5);
- raw_fd = low_mapping_string_lookup(THIS->request_data, ind);
- if(raw_fd && raw_fd->type == PIKE_T_OBJECT)
- {
- int fd = fd_from_object(raw_fd->u.object);
- if(fd == -1)
- THIS->my_fd = 0; /* Don't send directly to this FD... */
- else
- THIS->my_fd = fd;
- } else
- THIS->my_fd = 0;
-#ifdef USE_PIKE_LEVEL_THREADS
- php_caudium_module_main(THIS);
-#else
- th_farm((void (*)(void *))php_caudium_module_main, THIS);
-#endif
- pop_n_elems(args);
-}
-
-static void free_struct(void)
-{
- GET_THIS();
- if(THIS->request_data) free_mapping(THIS->request_data);
- if(THIS->my_fd_obj) free_object(THIS->my_fd_obj);
- free_svalue(&THIS->done_cb);
- if(THIS->filename) free_string(THIS->filename);
- MEMSET(THIS, 0, sizeof(php_caudium_request));
-}
-
-
-/*
- * pike_module_init() is called by Pike once at startup
- *
- * This functions allocates basic structures
- */
-
-void pike_module_init( void )
-{
- if (!caudium_php_initialized) {
- caudium_php_initialized = 1;
- tsrm_startup(1, 1, 0, NULL);
- ts_allocate_id(&caudium_globals_id, sizeof(php_caudium_request), NULL, NULL);
- sapi_startup(&caudium_sapi_module);
- sapi_module.startup(&caudium_sapi_module);
- }
- start_new_program(); /* Text */
- pike_add_function("run", f_php_caudium_request_handler,
- "function(string, mapping, object, function:void)", 0);
- end_class("Interpreter", 0);
-}
-
-/*
- * pike_module_exit() performs the last steps before the
- * server exists. Shutdowns basic services and frees memory
- */
-
-void pike_module_exit(void)
-{
- caudium_php_initialized = 0;
- sapi_module.shutdown(&caudium_sapi_module);
- tsrm_shutdown();
-}
-#endif
diff --git a/sapi/caudium/config.m4 b/sapi/caudium/config.m4
deleted file mode 100644
index 13a6b2943e..0000000000
--- a/sapi/caudium/config.m4
+++ /dev/null
@@ -1,98 +0,0 @@
-dnl
-dnl $Id$
-dnl
-
-RESULT=no
-PHP_ARG_WITH(caudium,,
-[ --with-caudium[=DIR] Build PHP as a Pike module for use with Caudium.
- DIR is the Caudium server dir [/usr/local/caudium/server]], no, no)
-
-AC_MSG_CHECKING([for Caudium support])
-
-if test "$PHP_CAUDIUM" != "no"; then
- if test "$prefix" = "NONE"; then CPREF=/usr/local/; fi
- if test ! -d $PHP_CAUDIUM ; then
- if test "$prefix" = "NONE"; then
- PHP_CAUDIUM=/usr/local/caudium/server/
- else
- PHP_CAUDIUM=$prefix/caudium/server/
- fi
- fi
- if test -f $PHP_CAUDIUM/bin/caudium; then
- PIKE=$PHP_CAUDIUM/bin/caudium
- elif test -f $PHP_CAUDIUM/bin/pike; then
- PIKE=$PHP_CAUDIUM/bin/pike
- else
- AC_MSG_ERROR([Could not find a pike in $PHP_CAUDIUM/bin/])
- fi
- if $PIKE -e 'float v; int rel;sscanf(version(), "Pike v%f release %d", v, rel);v += rel/10000.0; if(v < 7.0268) exit(1); exit(0);'; then
- PIKE_MODULE_DIR=`$PIKE --show-paths 2>&1| grep '^Module' | sed -e 's/.*: //'`
- PIKE_INCLUDE_DIR=`echo $PIKE_MODULE_DIR | sed -e 's,lib/pike/modules,include/pike,' -e 's,lib/modules,include/pike,' `
- if test -z "$PIKE_INCLUDE_DIR" || test -z "$PIKE_MODULE_DIR"; then
- AC_MSG_ERROR(Failed to figure out Pike module and include directories)
- fi
- AC_MSG_RESULT(yes)
- PIKE=`echo $PIKE | pike -e 'int tries=100;
- string orig,pike=Stdio.File("stdin")->read()-"\n";
- orig=pike;
- if(search(orig, "/"))
- orig = combine_path(getcwd(), orig);
- while(!catch(pike=readlink(pike)) && tries--)
- ;
- write(combine_path(dirname(orig), pike)); '`
- PHP_ADD_INCLUDE($PIKE_INCLUDE_DIR)
- if test "$prefix" != "NONE"; then
- PIKE_C_INCLUDE=$prefix/include/`basename $PIKE`
- else
- PIKE_C_INCLUDE=/usr/local/include/`basename $PIKE`
- fi
- AC_MSG_CHECKING([for C includes in $PIKE_C_INCLUDE])
- if test -f $PIKE_C_INCLUDE/version.h; then
- PIKE_TEST_VER=`$PIKE -e 'string v; int rel;sscanf(version(), "Pike v%s release %d", v, rel); write(v+"."+rel);'`
- ###### VERSION MATCH CHECK #######
- PMAJOR="^#define PIKE_MAJOR_VERSION"
- PMINOR="^#define PIKE_MINOR_VERSION"
- PBUILD="^#define PIKE_BUILD_VERSION"
-
- PIKE_CMAJOR_VERSION=0
- PIKE_CMINOR_VERSION=0
- PIKE_CBUILD_VERSION=0
-
- PIKE_CMAJOR_VERSION=`grep "$PMAJOR" $PIKE_C_INCLUDE/version.h | sed -e 's/\(#define.*N \)\(.*\)/\2/'`
- if test -z "$PIKE_CMAJOR_VERSION"; then
- if test -n "`grep f_version $PIKE_C_INCLUDE/version.h`"; then
- PIKE_CMAJOR_VERSION=6
- fi
- else
- PIKE_CMINOR_VERSION=`grep "$PMINOR" $PIKE_C_INCLUDE/version.h | sed -e 's/\(#define.*N \)\(.*\)/\2/'`
- PIKE_CBUILD_VERSION=`grep "$PBUILD" $PIKE_C_INCLUDE/version.h | sed -e 's/\(#define.*N \)\(.*\)/\2/'`
- fi
-
- if test "$PIKE_TEST_VER" = "${PIKE_CMAJOR_VERSION}.${PIKE_CMINOR_VERSION}.${PIKE_CBUILD_VERSION}"; then
- PHP_ADD_INCLUDE($PIKE_C_INCLUDE)
- PIKE_INCLUDE_DIR="$PIKE_INCLUDE_DIR, $PIKE_C_INCLUDE"
- AC_MSG_RESULT(found)
- else
- AC_MSG_RESULT(version mismatch)
- fi
- else
- AC_MSG_RESULT(not found)
- fi
- else
- AC_MSG_ERROR([Caudium PHP7 requires Pike 7.0 or newer])
- fi
- PIKE_VERSION=`$PIKE -e 'string v; int rel;sscanf(version(), "Pike v%s release %d", v, rel); write(v+"."+rel);'`
- AC_DEFINE(HAVE_CAUDIUM,1,[Whether to compile with Caudium support])
- PHP_SELECT_SAPI(caudium, shared, caudium.c)
- INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED $PHP_CAUDIUM/lib/$PIKE_VERSION/PHP7.so"
- RESULT=" *** Pike binary used: $PIKE
- *** Pike include dir(s) used: $PIKE_INCLUDE_DIR
- *** Pike version: $PIKE_VERSION"
- dnl Always use threads since thread-free support really blows.
- PHP_BUILD_THREAD_SAFE
-fi
-AC_MSG_RESULT($RESULT)
-
-dnl ## Local Variables:
-dnl ## tab-width: 4
-dnl ## End:
diff --git a/sapi/continuity/CREDITS b/sapi/continuity/CREDITS
deleted file mode 100644
index 35335e9266..0000000000
--- a/sapi/continuity/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-Continuity
-Alex Leigh (based on nsapi code)
diff --git a/sapi/continuity/capi.c b/sapi/continuity/capi.c
deleted file mode 100644
index 2f943e3be0..0000000000
--- a/sapi/continuity/capi.c
+++ /dev/null
@@ -1,507 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.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: Alex Leigh <php (at) postfin (dot) com> |
- +----------------------------------------------------------------------+
-*/
-
-/* For more information on Continuity: http://www.ashpool.com/ */
-
-/*
- * This code is based on the PHP5 SAPI module for NSAPI by Jayakumar
- * Muthukumarasamy
- */
-
-/* PHP includes */
-#define CONTINUITY 1
-#define CAPI_DEBUG
-
-/* Define for CDP specific extensions */
-#undef CONTINUITY_CDPEXT
-
-#include "php.h"
-#include "php_variables.h"
-#include "ext/standard/info.h"
-#include "php_ini.h"
-#include "php_globals.h"
-#include "SAPI.h"
-#include "php_main.h"
-#include "php_version.h"
-#include "TSRM.h"
-#include "ext/standard/php_standard.h"
-
-/*
- * CAPI includes
- */
-#include <continuity.h>
-#include <http.h>
-
-#define NSLS_D struct capi_request_context *request_context
-#define NSLS_DC , NSLS_D
-#define NSLS_C request_context
-#define NSLS_CC , NSLS_C
-#define NSG(v) (request_context->v)
-
-/*
- * ZTS needs to be defined for CAPI to work
- */
-#if !defined(ZTS)
-#error "CAPI module needs ZTS to be defined"
-#endif
-
-/*
- * Structure to encapsulate the CAPI request in SAPI
- */
-typedef struct capi_request_context {
- httpTtrans *t;
- int read_post_bytes;
-} capi_request_context;
-
-/**************/
-
-PHP_MINIT_FUNCTION(continuity);
-PHP_MSHUTDOWN_FUNCTION(continuity);
-PHP_RINIT_FUNCTION(continuity);
-PHP_RSHUTDOWN_FUNCTION(continuity);
-PHP_MINFO_FUNCTION(continuity);
-
-PHP_FUNCTION(continuity_virtual);
-PHP_FUNCTION(continuity_request_headers);
-PHP_FUNCTION(continuity_response_headers);
-
-const zend_function_entry continuity_functions[] = {
- {NULL, NULL, NULL}
-};
-
-zend_module_entry continuity_module_entry = {
- STANDARD_MODULE_HEADER,
- "continuity",
- continuity_functions,
- PHP_MINIT(continuity),
- PHP_MSHUTDOWN(continuity),
- NULL,
- NULL,
- PHP_MINFO(continuity),
- NO_VERSION_YET,
- STANDARD_MODULE_PROPERTIES
-};
-
-PHP_MINIT_FUNCTION(continuity)
-{
- return SUCCESS;
-}
-
-PHP_MSHUTDOWN_FUNCTION(continuity)
-{
- return SUCCESS;
-}
-
-PHP_MINFO_FUNCTION(continuity)
-{
- php_info_print_table_start();
- php_info_print_table_row(2, "Continuity Module Revision", "$Id$");
- php_info_print_table_row(2, "Server Version", conFget_build());
-#ifdef CONTINUITY_CDPEXT
- php_info_print_table_row(2,"CDP Extensions", "enabled");
-#else
- php_info_print_table_row(2,"CDP Extensions", "disabled");
-#endif
- php_info_print_table_end();
-
-/* DISPLAY_INI_ENTRIES(); */
-}
-
-/**************/
-
-/*
- * sapi_capi_ub_write: Write len bytes to the connection output.
- */
-static int sapi_capi_ub_write(const char *str, unsigned int str_length)
-{
- int retval;
- capi_request_context *rc;
-
- rc = (capi_request_context *) SG(server_context);
- retval = httpFwrite(rc->t, (char *) str, str_length);
- if (retval == -1 || retval == 0)
- php_handle_aborted_connection();
- return retval;
-}
-
-/*
- * sapi_capi_header_handler: Add/update response headers with those provided
- * by the PHP engine.
- */
-static int sapi_capi_header_handler(sapi_header_struct * sapi_header, sapi_headers_struct * sapi_headers)
-{
- char *header_name, *header_content, *p;
- capi_request_context *rc = (capi_request_context *) SG(server_context);
-
- lstFset_delete_key(rc->t->res_hdrs, "Content-Type");
-
- header_name = sapi_header->header;
- header_content = p = strchr(header_name, ':');
- if (p == NULL) {
- return 0;
- }
- *p = 0;
- do {
- header_content++;
- } while (*header_content == ' ');
-
- lstFset_add(rc->t->res_hdrs, header_name, header_content);
-
- *p = ':'; /* restore '*p' */
-
- efree(sapi_header->header);
-
- return 0; /* don't use the default SAPI mechanism, CAPI
- * duplicates this functionality */
-}
-
-/*
- * sapi_capi_send_headers: Transmit the headers to the client. This has the
- * effect of starting the response under Continuity.
- */
-static int sapi_capi_send_headers(sapi_headers_struct * sapi_headers)
-{
- int retval;
- capi_request_context *rc = (capi_request_context *) SG(server_context);
-
- /*
- * We could probably just do this in the header_handler. But, I don't know
- * what the implication of doing it there is.
- */
-
- if (SG(sapi_headers).send_default_content_type) {
- /* lstFset_delete_key(rc->t->res_hdrs, "Content-Type"); */
- lstFset_update(rc->t->res_hdrs, "Content-Type", "text/html");
- }
- httpFset_status(rc->t, SG(sapi_headers).http_response_code, NULL);
- httpFstart_response(rc->t);
-
- return SAPI_HEADER_SENT_SUCCESSFULLY;
-
-}
-
-static int sapi_capi_read_post(char *buffer, uint count_bytes)
-{
- unsigned int max_read, total_read = 0;
- capi_request_context *rc = (capi_request_context *) SG(server_context);
-
- if (rc->read_post_bytes == -1) {
- max_read = MIN(count_bytes, SG(request_info).content_length);
- } else {
- if (rc->read_post_bytes == 0)
- return 0;
- max_read = MIN(count_bytes, (SG(request_info).content_length - rc->read_post_bytes));
- }
-
- total_read = httpFread(rc->t, buffer, max_read);
-
- if (total_read < 0)
- total_read = -1;
- else
- rc->read_post_bytes = total_read;
-
- return total_read;
-}
-
-/*
- * sapi_capi_read_cookies: Return cookie information into PHP.
- */
-static char *sapi_capi_read_cookies(void)
-{
- char *cookie_string;
- capi_request_context *rc = (capi_request_context *) SG(server_context);
-
- cookie_string = lstFset_get(rc->t->req_hdrs, "cookie");
- return cookie_string;
-}
-
-static void sapi_capi_register_server_variables(zval * track_vars_array)
-{
- capi_request_context *rc = (capi_request_context *) SG(server_context);
- size_t i;
- char *value;
- char buf[128];
-
- /* PHP_SELF and REQUEST_URI */
- value = lstFset_get(rc->t->vars, "uri");
- if (value != NULL) {
- php_register_variable("PHP_SELF", value, track_vars_array);
- php_register_variable("REQUEST_URI", value, track_vars_array);
- }
-
- /* COUNTRY CODE */
- value = lstFset_get(rc->t->vars, "ccode");
- if(value!=NULL)
- php_register_variable("COUNTRY_CODE", value, track_vars_array);
-
- /* argv */
- value = lstFset_get(rc->t->vars, "query");
- if (value != NULL)
- php_register_variable("argv", value, track_vars_array);
-
- /* GATEWAY_INTERFACE */
- php_register_variable("GATEWAY_INTERFACE", "CGI/1.1", track_vars_array);
-
- /* SERVER_NAME and HTTP_HOST */
- value = lstFset_get(rc->t->req_hdrs, "host");
- if (value != NULL) {
- php_register_variable("HTTP_HOST", value, track_vars_array);
- /* TODO: This should probably scrub the port value if one is present. */
- php_register_variable("SERVER_NAME", value, track_vars_array);
- }
- /* SERVER_SOFTWARE */
- value = lstFset_get(rc->t->res_hdrs, "Server");
- if (value != NULL)
- php_register_variable("SERVER_SOFTWARE", value, track_vars_array);
-
- /* SERVER_PROTOCOL */
- value = lstFset_get(rc->t->vars, "protocol");
- if (value != NULL)
- php_register_variable("SERVER_PROTOCOL", value, track_vars_array);
-
- /* REQUEST_METHOD */
- value = lstFset_get(rc->t->vars, "method");
- if (value != NULL)
- php_register_variable("REQUEST_METHOD", value, track_vars_array);
-
- /* QUERY_STRING */
- value = lstFset_get(rc->t->vars, "query");
- if (value != NULL)
- php_register_variable("QUERY_STRING", value, track_vars_array);
-
- /* DOCUMENT_ROOT */
- value = lstFset_get(rc->t->vars, "docroot");
- if (value != NULL)
- php_register_variable("DOCUMENT_ROOT", value, track_vars_array);
-
- /* HTTP_ACCEPT */
- value = lstFset_get(rc->t->req_hdrs, "accept");
- if (value != NULL)
- php_register_variable("HTTP_ACCEPT", value, track_vars_array);
-
- /* HTTP_ACCEPT_CHARSET */
- value = lstFset_get(rc->t->req_hdrs, "accept-charset");
- if (value != NULL)
- php_register_variable("HTTP_ACCEPT_CHARSET", value, track_vars_array);
-
- /* HTTP_ACCEPT_ENCODING */
- value = lstFset_get(rc->t->req_hdrs, "accept-encoding");
- if (value != NULL)
- php_register_variable("HTTP_ACCEPT_ENCODING", value, track_vars_array);
-
- /* HTTP_ACCEPT_LANGUAGE */
- value = lstFset_get(rc->t->req_hdrs, "accept-language");
- if (value != NULL)
- php_register_variable("HTTP_ACCEPT_LANGUAGE", value, track_vars_array);
-
- /* HTTP_CONNECTION */
- value = lstFset_get(rc->t->req_hdrs, "connection");
- if (value != NULL)
- php_register_variable("HTTP_CONNECTION", value, track_vars_array);
-
- /* HTTP_REFERER */
- value = lstFset_get(rc->t->req_hdrs, "referer");
- if (value != NULL)
- php_register_variable("HTTP_REFERER", value, track_vars_array);
-
- /* HTTP_USER_AGENT */
- value = lstFset_get(rc->t->req_hdrs, "user-agent");
- if (value != NULL)
- php_register_variable("HTTP_USER_AGENT", value, track_vars_array);
-
- /* REMOTE_ADDR */
- utlFip_to_str(rc->t->cli_ipv4_addr, buf, sizeof(buf));
- php_register_variable("REMOTE_ADDR", buf, track_vars_array);
-
- /* REMOTE_PORT */
-
- /* SCRIPT_FILENAME and PATH_TRANSLATED */
- value = lstFset_get(rc->t->vars, "path");
- if (value != NULL) {
- php_register_variable("SCRIPT_FILENAME", value, track_vars_array);
- php_register_variable("PATH_TRANSLATED", value, track_vars_array);
- }
- /* SERVER_ADMIN */
- /* Not applicable */
-
- /* SERVER_PORT */
-
-}
-
-static void capi_log_message(char *message)
-{
- capi_request_context *rc = (capi_request_context *) SG(server_context);
- logFmsg(0, "mod/php: %s", message);
-}
-
-static int php_capi_startup(sapi_module_struct *sapi_module);
-
-sapi_module_struct capi_sapi_module = {
- "Continuity", /* name */
- "Continuity Server Enterprise Edition", /* pretty name */
-
- php_capi_startup, /* startup */
- php_module_shutdown_wrapper, /* shutdown */
-
- NULL, /* activate */
- NULL, /* deactivate */
-
- sapi_capi_ub_write, /* unbuffered write */
- NULL, /* flush */
- NULL, /* get uid */
- NULL, /* getenv */
-
- php_error, /* error handler */
-
- sapi_capi_header_handler, /* header handler */
- sapi_capi_send_headers, /* send headers handler */
- NULL, /* send header handler */
-
- sapi_capi_read_post, /* read POST data */
- sapi_capi_read_cookies, /* read Cookies */
-
- sapi_capi_register_server_variables, /* register server variables */
- capi_log_message, /* Log message */
- NULL, /* Get request time */
- NULL, /* Child terminate */
-
- NULL, /* Block interruptions */
- NULL, /* Unblock interruptions */
-
- STANDARD_SAPI_MODULE_PROPERTIES
-};
-
-static int php_capi_startup(sapi_module_struct *sapi_module) {
- if(php_module_startup(sapi_module,&continuity_module_entry,1)==FAILURE) {
- return FAILURE;
- }
- return SUCCESS;
-}
-
-
-static char *
- capi_strdup(char *str)
-{
- if (str != NULL)
- return strFcopy(str);
- return NULL;
-}
-
-static void capi_free(void *addr)
-{
- if (addr != NULL)
- free(addr);
-}
-
-static void capi_request_ctor(NSLS_D)
-{
- char *query_string = lstFset_get(NSG(t->vars), "query");
- char *uri = lstFset_get(NSG(t->vars), "uri");
- char *path_info = lstFset_get(NSG(t->vars), "path-info");
- char *path_translated = lstFset_get(NSG(t->vars), "path");
- char *request_method = lstFset_get(NSG(t->vars), "method");
- char *content_type = lstFset_get(NSG(t->req_hdrs), "content-type");
- char *content_length = lstFset_get(NSG(t->req_hdrs), "content-length");
-
- SG(request_info).query_string = capi_strdup(query_string);
- SG(request_info).request_uri = capi_strdup(uri);
- SG(request_info).request_method = capi_strdup(request_method);
- SG(request_info).path_translated = capi_strdup(path_translated);
- SG(request_info).content_type = capi_strdup(content_type);
- SG(request_info).content_length = (content_length == NULL) ? 0 : strtoul(content_length, 0, 0);
- SG(sapi_headers).http_response_code = 200;
-}
-
-static void capi_request_dtor(NSLS_D)
-{
- capi_free(SG(request_info).query_string);
- capi_free(SG(request_info).request_uri);
- capi_free(SG(request_info).request_method);
- capi_free(SG(request_info).path_translated);
- capi_free(SG(request_info).content_type);
-}
-
-int capi_module_main(NSLS_D)
-{
- zend_file_handle file_handle;
-
- if (php_request_startup() == FAILURE) {
- return FAILURE;
- }
- file_handle.type = ZEND_HANDLE_FILENAME;
- file_handle.filename = SG(request_info).path_translated;
- file_handle.free_filename = 0;
- file_handle.opened_path = NULL;
-
- php_execute_script(&file_handle);
- php_request_shutdown(NULL);
-
- return SUCCESS;
-}
-
-int phpFinit(lstTset * opt)
-{
- php_core_globals *core_globals;
-
- tsrm_startup(128, 1, 0, NULL);
- core_globals = ts_resource(core_globals_id);
-
- logFmsg(0, "mod/php: PHP Interface v3 (module)");
- logFmsg(0, "mod/php: Copyright (c) 1999-2015 The PHP Group. All rights reserved.");
-
- sapi_startup(&capi_sapi_module);
- capi_sapi_module.startup(&capi_sapi_module);
-
- return STATUS_PROCEED;
-}
-
-int phpFservice(httpTtrans * t, lstTset * opts)
-{
- int retval;
- capi_request_context *request_context;
-
-
- request_context = (capi_request_context *) malloc(sizeof(capi_request_context));
- request_context->t = t;
- request_context->read_post_bytes = -1;
-
- SG(server_context) = request_context;
-
- capi_request_ctor(NSLS_C);
- retval = capi_module_main(NSLS_C);
- capi_request_dtor(NSLS_C);
-
- free(request_context);
-
- /*
- * This call is ostensibly provided to free the memory from PHP/TSRM when
- * the thread terminated, but, it leaks a structure in some hash list
- * according to the developers. Not calling this will leak the entire
- * interpreter, around 100k, but calling it and then terminating the
- * thread will leak the struct (around a k). The only answer with the
- * current TSRM implementation is to reuse the threads that allocate TSRM
- * resources.
- */
- /* ts_free_thread(); */
-
- if (retval == SUCCESS) {
- return STATUS_EXIT;
- } else {
- return STATUS_ERROR;
- }
-}
diff --git a/sapi/continuity/config.m4 b/sapi/continuity/config.m4
deleted file mode 100644
index 8d2741921a..0000000000
--- a/sapi/continuity/config.m4
+++ /dev/null
@@ -1,28 +0,0 @@
-dnl ## $Id$ -*- sh -*-
-
-PHP_ARG_WITH(continuity, for Continuity support,
-[ --with-continuity=DIR Build PHP as Continuity Server module.
- DIR is path to the installed Continuity Server root], no, no)
-
-if test "$PHP_CONTINUITY" != "no"; then
- if test ! -d $PHP_CONTINUITY; then
- AC_MSG_ERROR([Please specify the path to the root of your Continuity server using --with-continuity=DIR])
- fi
- AC_MSG_CHECKING([for Continuity include files])
- if test -d $PHP_CONTINUITY/include ; then
- CAPI_INCLUDE=$PHP_CONTINUITY/include
- AC_MSG_RESULT([Continuity Binary Distribution])
- else
- AC_MSG_ERROR([Cannot find your CAPI include files in either DIR/src or DIR/include])
- fi
-
- PHP_SELECT_SAPI(continuity, shared, capi.c)
- PHP_ADD_INCLUDE($CAPI_INCLUDE)
- PHP_BUILD_THREAD_SAFE
- AC_DEFINE(HAVE_CONTINUITY, 1, [Whether you have a Continuity Server])
- INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED \$(INSTALL_ROOT)$PHP_CONTINUITY/lib/"
-fi
-
-dnl ## Local Variables:
-dnl ## tab-width: 4
-dnl ## End:
diff --git a/sapi/isapi/CREDITS b/sapi/isapi/CREDITS
deleted file mode 100644
index 11c6fdc73c..0000000000
--- a/sapi/isapi/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-ISAPI
-Andi Gutmans, Zeev Suraski
diff --git a/sapi/isapi/config.m4 b/sapi/isapi/config.m4
deleted file mode 100644
index 4073173eaf..0000000000
--- a/sapi/isapi/config.m4
+++ /dev/null
@@ -1,24 +0,0 @@
-dnl
-dnl $Id$
-dnl
-
-PHP_ARG_WITH(isapi, for Zeus ISAPI support,
-[ --with-isapi[=DIR] Build PHP as an ISAPI module for use with Zeus], no, no)
-
-if test "$PHP_ISAPI" != "no"; then
- if test "$PHP_ISAPI" = "yes"; then
- ZEUSPATH=/usr/local/zeus # the default
- else
- ZEUSPATH=$PHP_ISAPI
- fi
- test -f "$ZEUSPATH/web/include/httpext.h" || AC_MSG_ERROR(Unable to find httpext.h in $ZEUSPATH/web/include)
- PHP_BUILD_THREAD_SAFE
- AC_DEFINE(WITH_ZEUS, 1, [ ])
- PHP_ADD_INCLUDE($ZEUSPATH/web/include)
- PHP_SELECT_SAPI(isapi, shared, php7isapi.c)
- INSTALL_IT="\$(SHELL) \$(srcdir)/install-sh -m 0755 $SAPI_SHARED \$(INSTALL_ROOT)$ZEUSPATH/web/bin/"
-fi
-
-dnl ## Local Variables:
-dnl ## tab-width: 4
-dnl ## End:
diff --git a/sapi/isapi/config.w32 b/sapi/isapi/config.w32
deleted file mode 100644
index 5a359f11b2..0000000000
--- a/sapi/isapi/config.w32
+++ /dev/null
@@ -1,13 +0,0 @@
-// vim:ft=javascript
-// $Id$
-
-ARG_ENABLE('isapi', 'Build ISAPI version of PHP', 'no');
-
-if (PHP_ISAPI == "yes") {
- if (PHP_ZTS == "no") {
- WARNING("ISAPI module requires an --enable-zts build of PHP");
- } else {
- SAPI('isapi', 'php7isapi.c', 'php' + PHP_VERSION + 'isapi.dll', '/D PHP7ISAPI_EXPORTS');
- ADD_FLAG('LDFLAGS_ISAPI', '/DEF:sapi\\isapi\\php7isapi.def');
- }
-}
diff --git a/sapi/isapi/php.sym b/sapi/isapi/php.sym
deleted file mode 100644
index 34b50b851c..0000000000
--- a/sapi/isapi/php.sym
+++ /dev/null
@@ -1,5 +0,0 @@
-GetFilterVersion
-HttpFilterProc
-GetExtensionVersion
-HttpExtensionProc
-ZSLMain
diff --git a/sapi/isapi/php7isapi.c b/sapi/isapi/php7isapi.c
deleted file mode 100644
index 627c20c18c..0000000000
--- a/sapi/isapi/php7isapi.c
+++ /dev/null
@@ -1,971 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- | Ben Mansell <ben@zeus.com> (Zeus Support) |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include "php.h"
-#include <httpext.h>
-#include <httpfilt.h>
-#include <httpext.h>
-#include "php_main.h"
-#include "SAPI.h"
-#include "php_globals.h"
-#include "ext/standard/info.h"
-#include "php_variables.h"
-#include "php_ini.h"
-
-#ifdef PHP_WIN32
-# include <process.h>
-#else
-# define __try
-# define __except(val)
-# define __declspec(foo)
-#endif
-
-
-#ifdef WITH_ZEUS
-# include "httpext.h"
-# include <errno.h>
-# define GetLastError() errno
-#endif
-
-#ifdef PHP_WIN32
-#define PHP_ENABLE_SEH
-#endif
-
-/*
-uncomment the following lines to turn off
-exception trapping when running under a debugger
-
-#ifdef _DEBUG
-#undef PHP_ENABLE_SEH
-#endif
-*/
-
-#define MAX_STATUS_LENGTH sizeof("xxxx LONGEST POSSIBLE STATUS DESCRIPTION")
-#define ISAPI_SERVER_VAR_BUF_SIZE 1024
-#define ISAPI_POST_DATA_BUF 1024
-
-static zend_bool bFilterLoaded=0;
-static zend_bool bTerminateThreadsOnError=0;
-
-static char *isapi_special_server_variable_names[] = {
- "ALL_HTTP",
- "HTTPS",
-#ifndef WITH_ZEUS
- "SCRIPT_NAME",
-#endif
- NULL
-};
-
-#define NUM_SPECIAL_VARS (sizeof(isapi_special_server_variable_names)/sizeof(char *))
-#define SPECIAL_VAR_ALL_HTTP 0
-#define SPECIAL_VAR_HTTPS 1
-#define SPECIAL_VAR_PHP_SELF 2
-
-static char *isapi_server_variable_names[] = {
- "AUTH_PASSWORD",
- "AUTH_TYPE",
- "AUTH_USER",
- "CONTENT_LENGTH",
- "CONTENT_TYPE",
- "PATH_TRANSLATED",
- "QUERY_STRING",
- "REMOTE_ADDR",
- "REMOTE_HOST",
- "REMOTE_USER",
- "REQUEST_METHOD",
- "SERVER_NAME",
- "SERVER_PORT",
- "SERVER_PROTOCOL",
- "SERVER_SOFTWARE",
-#ifndef WITH_ZEUS
- "APPL_MD_PATH",
- "APPL_PHYSICAL_PATH",
- "INSTANCE_ID",
- "INSTANCE_META_PATH",
- "LOGON_USER",
- "REQUEST_URI",
- "URL",
-#else
- "DOCUMENT_ROOT",
-#endif
- NULL
-};
-
-
-static char *isapi_secure_server_variable_names[] = {
- "CERT_COOKIE",
- "CERT_FLAGS",
- "CERT_ISSUER",
- "CERT_KEYSIZE",
- "CERT_SECRETKEYSIZE",
- "CERT_SERIALNUMBER",
- "CERT_SERVER_ISSUER",
- "CERT_SERVER_SUBJECT",
- "CERT_SUBJECT",
- "HTTPS_KEYSIZE",
- "HTTPS_SECRETKEYSIZE",
- "HTTPS_SERVER_ISSUER",
- "HTTPS_SERVER_SUBJECT",
- "SERVER_PORT_SECURE",
-#ifdef WITH_ZEUS
- "SSL_CLIENT_CN",
- "SSL_CLIENT_EMAIL",
- "SSL_CLIENT_OU",
- "SSL_CLIENT_O",
- "SSL_CLIENT_L",
- "SSL_CLIENT_ST",
- "SSL_CLIENT_C",
- "SSL_CLIENT_I_CN",
- "SSL_CLIENT_I_EMAIL",
- "SSL_CLIENT_I_OU",
- "SSL_CLIENT_I_O",
- "SSL_CLIENT_I_L",
- "SSL_CLIENT_I_ST",
- "SSL_CLIENT_I_C",
-#endif
- NULL
-};
-
-
-static void php_info_isapi(ZEND_MODULE_INFO_FUNC_ARGS)
-{
- char **p;
- char variable_buf[ISAPI_SERVER_VAR_BUF_SIZE];
- DWORD variable_len;
- char **all_variables[] = {
- isapi_server_variable_names,
- isapi_special_server_variable_names,
- isapi_secure_server_variable_names,
- NULL
- };
- char ***server_variable_names;
- LPEXTENSION_CONTROL_BLOCK lpECB;
-
- lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context);
-
- php_info_print_table_start();
- php_info_print_table_header(2, "Server Variable", "Value");
- server_variable_names = all_variables;
- while (*server_variable_names) {
- p = *server_variable_names;
- while (*p) {
- variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
- if (lpECB->GetServerVariable(lpECB->ConnID, *p, variable_buf, &variable_len)
- && variable_buf[0]) {
- php_info_print_table_row(2, *p, variable_buf);
- } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
- char *tmp_variable_buf;
-
- tmp_variable_buf = (char *) emalloc(variable_len);
- if (lpECB->GetServerVariable(lpECB->ConnID, *p, tmp_variable_buf, &variable_len)
- && variable_buf[0]) {
- php_info_print_table_row(2, *p, tmp_variable_buf);
- }
- efree(tmp_variable_buf);
- }
- p++;
- }
- server_variable_names++;
- }
- php_info_print_table_end();
-}
-
-
-static zend_module_entry php_isapi_module = {
- STANDARD_MODULE_HEADER,
- "ISAPI",
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- php_info_isapi,
- NULL,
- STANDARD_MODULE_PROPERTIES
-};
-
-
-static int sapi_isapi_ub_write(const char *str, uint str_length)
-{
- DWORD num_bytes = str_length;
- LPEXTENSION_CONTROL_BLOCK ecb;
-
- ecb = (LPEXTENSION_CONTROL_BLOCK) SG(server_context);
- if (ecb->WriteClient(ecb->ConnID, (char *) str, &num_bytes, HSE_IO_SYNC) == FALSE) {
- php_handle_aborted_connection();
- }
- return num_bytes;
-}
-
-
-static int sapi_isapi_header_handler(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers)
-{
- return SAPI_HEADER_ADD;
-}
-
-
-
-static void accumulate_header_length(sapi_header_struct *sapi_header, uint *total_length)
-{
- *total_length += sapi_header->header_len+2;
-}
-
-
-static void concat_header(sapi_header_struct *sapi_header, char **combined_headers_ptr)
-{
- memcpy(*combined_headers_ptr, sapi_header->header, sapi_header->header_len);
- *combined_headers_ptr += sapi_header->header_len;
- **combined_headers_ptr = '\r';
- (*combined_headers_ptr)++;
- **combined_headers_ptr = '\n';
- (*combined_headers_ptr)++;
-}
-
-
-static int sapi_isapi_send_headers(sapi_headers_struct *sapi_headers)
-{
- uint total_length = 2; /* account for the trailing \r\n */
- char *combined_headers, *combined_headers_ptr;
- LPEXTENSION_CONTROL_BLOCK lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context);
- HSE_SEND_HEADER_EX_INFO header_info;
- sapi_header_struct default_content_type;
- char *status_buf = NULL;
-
- /* Obtain headers length */
- if (SG(sapi_headers).send_default_content_type) {
- sapi_get_default_content_type_header(&default_content_type);
- accumulate_header_length(&default_content_type, (void *) &total_length);
- }
- zend_llist_apply_with_argument(&SG(sapi_headers).headers, (llist_apply_with_arg_func_t) accumulate_header_length, (void *) &total_length);
-
- /* Generate headers */
- combined_headers = (char *) emalloc(total_length+1);
- combined_headers_ptr = combined_headers;
- if (SG(sapi_headers).send_default_content_type) {
- concat_header(&default_content_type, (void *) &combined_headers_ptr);
- sapi_free_header(&default_content_type); /* we no longer need it */
- }
- zend_llist_apply_with_argument(&SG(sapi_headers).headers, (llist_apply_with_arg_func_t) concat_header, (void *) &combined_headers_ptr);
- *combined_headers_ptr++ = '\r';
- *combined_headers_ptr++ = '\n';
- *combined_headers_ptr = 0;
-
- switch (SG(sapi_headers).http_response_code) {
- case 200:
- header_info.pszStatus = "200 OK";
- break;
- case 302:
- header_info.pszStatus = "302 Moved Temporarily";
- break;
- case 401:
- header_info.pszStatus = "401 Authorization Required";
- break;
- default: {
- const char *sline = SG(sapi_headers).http_status_line;
- int sline_len;
-
- /* httpd requires that r->status_line is set to the first digit of
- * the status-code: */
- if (sline && ((sline_len = strlen(sline)) > 12) && strncmp(sline, "HTTP/1.", 7) == 0 && sline[8] == ' ') {
- if ((sline_len - 9) > MAX_STATUS_LENGTH) {
- status_buf = estrndup(sline + 9, MAX_STATUS_LENGTH);
- } else {
- status_buf = estrndup(sline + 9, sline_len - 9);
- }
- } else {
- status_buf = emalloc(MAX_STATUS_LENGTH + 1);
- snprintf(status_buf, MAX_STATUS_LENGTH, "%d Undescribed", SG(sapi_headers).http_response_code);
- }
- header_info.pszStatus = status_buf;
- break;
- }
- }
- header_info.cchStatus = strlen(header_info.pszStatus);
- header_info.pszHeader = combined_headers;
- header_info.cchHeader = total_length;
- header_info.fKeepConn = FALSE;
- lpECB->dwHttpStatusCode = SG(sapi_headers).http_response_code;
-
- lpECB->ServerSupportFunction(lpECB->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &header_info, NULL, NULL);
-
- efree(combined_headers);
- if (status_buf) {
- efree(status_buf);
- }
- return SAPI_HEADER_SENT_SUCCESSFULLY;
-}
-
-
-static int php_isapi_startup(sapi_module_struct *sapi_module)
-{
- if (php_module_startup(sapi_module, &php_isapi_module, 1)==FAILURE) {
- return FAILURE;
- } else {
- bTerminateThreadsOnError = (zend_bool) INI_INT("isapi.terminate_threads_on_error");
- return SUCCESS;
- }
-}
-
-
-static int sapi_isapi_read_post(char *buffer, uint count_bytes)
-{
- LPEXTENSION_CONTROL_BLOCK lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context);
- DWORD read_from_buf=0;
- DWORD read_from_input=0;
- DWORD total_read=0;
-
- if ((DWORD) SG(read_post_bytes) < lpECB->cbAvailable) {
- read_from_buf = MIN(lpECB->cbAvailable-SG(read_post_bytes), count_bytes);
- memcpy(buffer, lpECB->lpbData+SG(read_post_bytes), read_from_buf);
- total_read += read_from_buf;
- }
- if (read_from_buf<count_bytes
- && (SG(read_post_bytes)+read_from_buf) < lpECB->cbTotalBytes) {
- DWORD cbRead=0, cbSize;
-
- read_from_input = MIN(count_bytes-read_from_buf, lpECB->cbTotalBytes-SG(read_post_bytes)-read_from_buf);
- while (cbRead < read_from_input) {
- cbSize = read_from_input - cbRead;
- if (!lpECB->ReadClient(lpECB->ConnID, buffer+read_from_buf+cbRead, &cbSize) || cbSize==0) {
- break;
- }
- cbRead += cbSize;
- }
- total_read += cbRead;
- }
- return total_read;
-}
-
-
-static char *sapi_isapi_read_cookies(void)
-{
- LPEXTENSION_CONTROL_BLOCK lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context);
- char variable_buf[ISAPI_SERVER_VAR_BUF_SIZE];
- DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
-
- if (lpECB->GetServerVariable(lpECB->ConnID, "HTTP_COOKIE", variable_buf, &variable_len)) {
- return estrndup(variable_buf, variable_len);
- } else if (GetLastError()==ERROR_INSUFFICIENT_BUFFER) {
- char *tmp_variable_buf = (char *) emalloc(variable_len+1);
-
- if (lpECB->GetServerVariable(lpECB->ConnID, "HTTP_COOKIE", tmp_variable_buf, &variable_len)) {
- tmp_variable_buf[variable_len] = 0;
- return tmp_variable_buf;
- } else {
- efree(tmp_variable_buf);
- }
- }
- return STR_EMPTY_ALLOC();
-}
-
-
-#ifdef WITH_ZEUS
-
-static void sapi_isapi_register_zeus_ssl_variables(LPEXTENSION_CONTROL_BLOCK lpECB, zval *track_vars_array)
-{
- char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE];
- DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
- char static_cons_buf[ISAPI_SERVER_VAR_BUF_SIZE];
- /*
- * We need to construct the /C=.../ST=...
- * DN's for SSL_CLIENT_DN and SSL_CLIENT_I_DN
- */
- strcpy( static_cons_buf, "/C=" );
- if( lpECB->GetServerVariable( lpECB->ConnID, "SSL_CLIENT_C", static_variable_buf, &variable_len ) && static_variable_buf[0] ) {
- strlcat( static_cons_buf, static_variable_buf, ISAPI_SERVER_VAR_BUF_SIZE);
- }
- strlcat( static_cons_buf, "/ST=", ISAPI_SERVER_VAR_BUF_SIZE);
- variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
- if( lpECB->GetServerVariable( lpECB->ConnID, "SSL_CLIENT_ST", static_variable_buf, &variable_len ) && static_variable_buf[0] ) {
- strlcat( static_cons_buf, static_variable_buf, ISAPI_SERVER_VAR_BUF_SIZE );
- }
- php_register_variable( "SSL_CLIENT_DN", static_cons_buf, track_vars_array );
-
- strcpy( static_cons_buf, "/C=" );
- variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
- if( lpECB->GetServerVariable( lpECB->ConnID, "SSL_CLIENT_I_C", static_variable_buf, &variable_len ) && static_variable_buf[0] ) {
- strlcat( static_cons_buf, static_variable_buf, ISAPI_SERVER_VAR_BUF_SIZE );
- }
- strlcat( static_cons_buf, "/ST=", ISAPI_SERVER_VAR_BUF_SIZE);
- variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
- if( lpECB->GetServerVariable( lpECB->ConnID, "SSL_CLIENT_I_ST", static_variable_buf, &variable_len ) && static_variable_buf[0] ) {
- strlcat( static_cons_buf, static_variable_buf, ISAPI_SERVER_VAR_BUF_SIZE );
- }
- php_register_variable( "SSL_CLIENT_I_DN", static_cons_buf, track_vars_array );
-}
-
-static void sapi_isapi_register_zeus_variables(LPEXTENSION_CONTROL_BLOCK lpECB, zval *track_vars_array)
-{
- char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE];
- DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
- DWORD scriptname_len = ISAPI_SERVER_VAR_BUF_SIZE;
- DWORD pathinfo_len = 0;
- char *strtok_buf = NULL;
-
- /* Get SCRIPT_NAME, we use this to work out which bit of the URL
- * belongs in PHP's version of PATH_INFO
- */
- lpECB->GetServerVariable(lpECB->ConnID, "SCRIPT_NAME", static_variable_buf, &scriptname_len);
-
- /* Adjust Zeus' version of PATH_INFO, set PHP_SELF,
- * and generate REQUEST_URI
- */
- if ( lpECB->GetServerVariable(lpECB->ConnID, "PATH_INFO", static_variable_buf, &variable_len) && static_variable_buf[0] ) {
-
- /* PHP_SELF is just PATH_INFO */
- php_register_variable( "PHP_SELF", static_variable_buf, track_vars_array );
-
- /* Chop off filename to get just the 'real' PATH_INFO' */
- pathinfo_len = variable_len - scriptname_len;
- php_register_variable( "PATH_INFO", static_variable_buf + scriptname_len - 1, track_vars_array );
- /* append query string to give url... extra byte for '?' */
- if ( strlen(lpECB->lpszQueryString) + variable_len + 1 < ISAPI_SERVER_VAR_BUF_SIZE ) {
- /* append query string only if it is present... */
- if ( strlen(lpECB->lpszQueryString) ) {
- static_variable_buf[ variable_len - 1 ] = '?';
- strcpy( static_variable_buf + variable_len, lpECB->lpszQueryString );
- }
- php_register_variable( "URL", static_variable_buf, track_vars_array );
- php_register_variable( "REQUEST_URI", static_variable_buf, track_vars_array );
- }
- }
-
- /* Get and adjust PATH_TRANSLATED to what PHP wants */
- variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
- if ( lpECB->GetServerVariable(lpECB->ConnID, "PATH_TRANSLATED", static_variable_buf, &variable_len) && static_variable_buf[0] ) {
- static_variable_buf[ variable_len - pathinfo_len - 1 ] = '\0';
- php_register_variable( "PATH_TRANSLATED", static_variable_buf, track_vars_array );
- }
-
- /* Bring in the AUTHENTICATION stuff as needed */
- variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
- if ( lpECB->GetServerVariable(lpECB->ConnID, "AUTH_USER", static_variable_buf, &variable_len) && static_variable_buf[0] ) {
- php_register_variable( "PHP_AUTH_USER", static_variable_buf, track_vars_array );
- }
- variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
- if ( lpECB->GetServerVariable(lpECB->ConnID, "AUTH_PASSWORD", static_variable_buf, &variable_len) && static_variable_buf[0] ) {
- php_register_variable( "PHP_AUTH_PW", static_variable_buf, track_vars_array );
- }
- variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
- if ( lpECB->GetServerVariable(lpECB->ConnID, "AUTH_TYPE", static_variable_buf, &variable_len) && static_variable_buf[0] ) {
- php_register_variable( "AUTH_TYPE", static_variable_buf, track_vars_array );
- }
-
- /* And now, for the SSL variables (if applicable) */
- variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
- if ( lpECB->GetServerVariable(lpECB->ConnID, "CERT_COOKIE", static_variable_buf, &variable_len) && static_variable_buf[0] ) {
- sapi_isapi_register_zeus_ssl_variables( lpECB, track_vars_array );
- }
- /* Copy some of the variables we need to meet Apache specs */
- variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
- if ( lpECB->GetServerVariable(lpECB->ConnID, "SERVER_SOFTWARE", static_variable_buf, &variable_len) && static_variable_buf[0] ) {
- php_register_variable( "SERVER_SIGNATURE", static_variable_buf, track_vars_array );
- }
-}
-#else
-
-static void sapi_isapi_register_iis_variables(LPEXTENSION_CONTROL_BLOCK lpECB, zval *track_vars_array)
-{
- char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE];
- char path_info_buf[ISAPI_SERVER_VAR_BUF_SIZE];
- DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
- DWORD scriptname_len = ISAPI_SERVER_VAR_BUF_SIZE;
- DWORD pathinfo_len = 0;
- HSE_URL_MAPEX_INFO humi;
-
- /* Get SCRIPT_NAME, we use this to work out which bit of the URL
- * belongs in PHP's version of PATH_INFO. SCRIPT_NAME also becomes PHP_SELF.
- */
- lpECB->GetServerVariable(lpECB->ConnID, "SCRIPT_NAME", static_variable_buf, &scriptname_len);
- php_register_variable("SCRIPT_FILENAME", SG(request_info).path_translated, track_vars_array);
-
- /* Adjust IIS' version of PATH_INFO, set PHP_SELF,
- * and generate REQUEST_URI
- * Get and adjust PATH_TRANSLATED to what PHP wants
- */
- if ( lpECB->GetServerVariable(lpECB->ConnID, "PATH_INFO", static_variable_buf, &variable_len) && static_variable_buf[0] ) {
-
- /* Chop off filename to get just the 'real' PATH_INFO' */
- php_register_variable( "ORIG_PATH_INFO", static_variable_buf, track_vars_array );
- pathinfo_len = variable_len - scriptname_len;
- strncpy(path_info_buf, static_variable_buf + scriptname_len - 1, sizeof(path_info_buf)-1);
- php_register_variable( "PATH_INFO", path_info_buf, track_vars_array );
- /* append query string to give url... extra byte for '?' */
- if ( strlen(lpECB->lpszQueryString) + variable_len + 1 < ISAPI_SERVER_VAR_BUF_SIZE ) {
- /* append query string only if it is present... */
- if ( strlen(lpECB->lpszQueryString) ) {
- static_variable_buf[ variable_len - 1 ] = '?';
- strcpy( static_variable_buf + variable_len, lpECB->lpszQueryString );
- }
- php_register_variable( "URL", static_variable_buf, track_vars_array );
- php_register_variable( "REQUEST_URI", static_variable_buf, track_vars_array );
- }
- variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
- if ( lpECB->GetServerVariable(lpECB->ConnID, "PATH_TRANSLATED", static_variable_buf, &variable_len) && static_variable_buf[0] ) {
- php_register_variable( "ORIG_PATH_TRANSLATED", static_variable_buf, track_vars_array );
- }
- if (lpECB->ServerSupportFunction(lpECB->ConnID, HSE_REQ_MAP_URL_TO_PATH_EX, path_info_buf, &pathinfo_len, (LPDWORD) &humi)) {
- /* Remove trailing \ */
- if (humi.lpszPath[variable_len-2] == '\\') {
- humi.lpszPath[variable_len-2] = 0;
- }
- php_register_variable("PATH_TRANSLATED", humi.lpszPath, track_vars_array);
- }
- }
-
- static_variable_buf[0] = '/';
- static_variable_buf[1] = 0;
- variable_len = 2;
- if (lpECB->ServerSupportFunction(lpECB->ConnID, HSE_REQ_MAP_URL_TO_PATH_EX, static_variable_buf, &variable_len, (LPDWORD) &humi)) {
- /* Remove trailing \ */
- if (humi.lpszPath[variable_len-2] == '\\') {
- humi.lpszPath[variable_len-2] = 0;
- }
- php_register_variable("DOCUMENT_ROOT", humi.lpszPath, track_vars_array);
- }
-
- if (!SG(request_info).auth_user || !SG(request_info).auth_password ||
- !SG(request_info).auth_user[0] || !SG(request_info).auth_password[0]) {
- variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
- if (lpECB->GetServerVariable(lpECB->ConnID, "HTTP_AUTHORIZATION", static_variable_buf, &variable_len)
- && static_variable_buf[0]) {
- php_handle_auth_data(static_variable_buf);
- }
- }
-
- if (SG(request_info).auth_user) {
- php_register_variable("PHP_AUTH_USER", SG(request_info).auth_user, track_vars_array );
- }
- if (SG(request_info).auth_password) {
- php_register_variable("PHP_AUTH_PW", SG(request_info).auth_password, track_vars_array );
- }
-}
-#endif
-
-static void sapi_isapi_register_server_variables2(char **server_variables, LPEXTENSION_CONTROL_BLOCK lpECB, zval *track_vars_array, char **recorded_values)
-{
- char **p=server_variables;
- DWORD variable_len;
- char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE];
- char *variable_buf;
-
- while (*p) {
- variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
- if (lpECB->GetServerVariable(lpECB->ConnID, *p, static_variable_buf, &variable_len)
- && static_variable_buf[0]) {
- php_register_variable(*p, static_variable_buf, track_vars_array);
- if (recorded_values) {
- recorded_values[p-server_variables] = estrndup(static_variable_buf, variable_len);
- }
- } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
- variable_buf = (char *) emalloc(variable_len+1);
- if (lpECB->GetServerVariable(lpECB->ConnID, *p, variable_buf, &variable_len)
- && variable_buf[0]) {
- php_register_variable(*p, variable_buf, track_vars_array);
- }
- if (recorded_values) {
- recorded_values[p-server_variables] = variable_buf;
- } else {
- efree(variable_buf);
- }
- } else { /* for compatibility with Apache SAPIs */
- php_register_variable(*p, "", track_vars_array);
- }
- p++;
- }
-}
-
-
-static void sapi_isapi_register_server_variables(zval *track_vars_array)
-{
- DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
- char *variable;
- char *strtok_buf = NULL;
- char *isapi_special_server_variables[NUM_SPECIAL_VARS];
- LPEXTENSION_CONTROL_BLOCK lpECB;
-
- lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context);
-
- /* Register the special ISAPI variables */
- memset(isapi_special_server_variables, 0, sizeof(isapi_special_server_variables));
- sapi_isapi_register_server_variables2(isapi_special_server_variable_names, lpECB, track_vars_array, isapi_special_server_variables);
- if (SG(request_info).cookie_data) {
- php_register_variable("HTTP_COOKIE", SG(request_info).cookie_data, track_vars_array);
- }
-
- /* Register the standard ISAPI variables */
- sapi_isapi_register_server_variables2(isapi_server_variable_names, lpECB, track_vars_array, NULL);
-
- if (isapi_special_server_variables[SPECIAL_VAR_HTTPS]
- && (atoi(isapi_special_server_variables[SPECIAL_VAR_HTTPS])
- || !strcasecmp(isapi_special_server_variables[SPECIAL_VAR_HTTPS], "on"))
- ) {
- /* Register SSL ISAPI variables */
- sapi_isapi_register_server_variables2(isapi_secure_server_variable_names, lpECB, track_vars_array, NULL);
- }
-
- if (isapi_special_server_variables[SPECIAL_VAR_HTTPS]) {
- efree(isapi_special_server_variables[SPECIAL_VAR_HTTPS]);
- }
-
-
-#ifdef WITH_ZEUS
- sapi_isapi_register_zeus_variables(lpECB, track_vars_array);
-#else
- sapi_isapi_register_iis_variables(lpECB, track_vars_array);
-#endif
-
- /* PHP_SELF support */
- if (isapi_special_server_variables[SPECIAL_VAR_PHP_SELF]) {
- php_register_variable("PHP_SELF", isapi_special_server_variables[SPECIAL_VAR_PHP_SELF], track_vars_array);
- efree(isapi_special_server_variables[SPECIAL_VAR_PHP_SELF]);
- }
-
- if (isapi_special_server_variables[SPECIAL_VAR_ALL_HTTP]) {
- /* Register the internal bits of ALL_HTTP */
- variable = php_strtok_r(isapi_special_server_variables[SPECIAL_VAR_ALL_HTTP], "\r\n", &strtok_buf);
- while (variable) {
- char *colon = strchr(variable, ':');
-
- if (colon) {
- char *value = colon+1;
-
- while (*value==' ') {
- value++;
- }
- *colon = 0;
- php_register_variable(variable, value, track_vars_array);
- *colon = ':';
- }
- variable = php_strtok_r(NULL, "\r\n", &strtok_buf);
- }
- efree(isapi_special_server_variables[SPECIAL_VAR_ALL_HTTP]);
- }
-}
-
-
-static sapi_module_struct isapi_sapi_module = {
- "isapi", /* name */
- "ISAPI", /* pretty name */
-
- php_isapi_startup, /* startup */
- php_module_shutdown_wrapper, /* shutdown */
-
- NULL, /* activate */
- NULL, /* deactivate */
-
- sapi_isapi_ub_write, /* unbuffered write */
- NULL, /* flush */
- NULL, /* get uid */
- NULL, /* getenv */
-
- php_error, /* error handler */
-
- sapi_isapi_header_handler, /* header handler */
- sapi_isapi_send_headers, /* send headers handler */
- NULL, /* send header handler */
-
- sapi_isapi_read_post, /* read POST data */
- sapi_isapi_read_cookies, /* read Cookies */
-
- sapi_isapi_register_server_variables, /* register server variables */
- NULL, /* Log message */
- NULL, /* Get request time */
- NULL, /* Child terminate */
-
- STANDARD_SAPI_MODULE_PROPERTIES
-};
-
-
-BOOL WINAPI GetFilterVersion(PHTTP_FILTER_VERSION pFilterVersion)
-{
- bFilterLoaded = 1;
- pFilterVersion->dwFilterVersion = HTTP_FILTER_REVISION;
- strcpy(pFilterVersion->lpszFilterDesc, isapi_sapi_module.pretty_name);
- pFilterVersion->dwFlags= (SF_NOTIFY_AUTHENTICATION | SF_NOTIFY_PREPROC_HEADERS);
- return TRUE;
-}
-
-
-DWORD WINAPI HttpFilterProc(PHTTP_FILTER_CONTEXT pfc, DWORD notificationType, LPVOID pvNotification)
-{
-
- switch (notificationType) {
- case SF_NOTIFY_PREPROC_HEADERS:
- SG(request_info).auth_user = NULL;
- SG(request_info).auth_password = NULL;
- SG(request_info).auth_digest = NULL;
- break;
- case SF_NOTIFY_AUTHENTICATION: {
- char *auth_user = ((HTTP_FILTER_AUTHENT *) pvNotification)->pszUser;
- char *auth_password = ((HTTP_FILTER_AUTHENT *) pvNotification)->pszPassword;
-
- if (auth_user && auth_user[0]) {
- SG(request_info).auth_user = estrdup(auth_user);
- }
- if (auth_password && auth_password[0]) {
- SG(request_info).auth_password = estrdup(auth_password);
- }
- return SF_STATUS_REQ_HANDLED_NOTIFICATION;
- }
- break;
- }
- return SF_STATUS_REQ_NEXT_NOTIFICATION;
-}
-
-
-static void init_request_info(LPEXTENSION_CONTROL_BLOCK lpECB)
-{
- DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
- char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE];
-#ifndef WITH_ZEUS
- HSE_URL_MAPEX_INFO humi;
-#endif
-
- SG(request_info).request_method = lpECB->lpszMethod;
- SG(request_info).query_string = lpECB->lpszQueryString;
- SG(request_info).request_uri = lpECB->lpszPathInfo;
- SG(request_info).content_type = lpECB->lpszContentType;
- SG(request_info).content_length = lpECB->cbTotalBytes;
- SG(sapi_headers).http_response_code = 200; /* I think dwHttpStatusCode is invalid at this stage -RL */
- if (!bFilterLoaded) { /* we don't have valid ISAPI Filter information */
- SG(request_info).auth_user = SG(request_info).auth_password = SG(request_info).auth_digest = NULL;
- }
-
-#ifdef WITH_ZEUS
- /* PATH_TRANSLATED can contain extra PATH_INFO stuff after the
- * file being loaded, so we must use SCRIPT_FILENAME instead
- */
- if(lpECB->GetServerVariable(lpECB->ConnID, "SCRIPT_FILENAME", static_variable_buf, &variable_len)) {
- SG(request_info).path_translated = estrdup(static_variable_buf);
- } else
-#else
- /* happily, IIS gives us SCRIPT_NAME which is correct (without PATH_INFO stuff)
- so we can just map that to the physical path and we have our filename */
-
- lpECB->GetServerVariable(lpECB->ConnID, "SCRIPT_NAME", static_variable_buf, &variable_len);
- if (lpECB->ServerSupportFunction(lpECB->ConnID, HSE_REQ_MAP_URL_TO_PATH_EX, static_variable_buf, &variable_len, (LPDWORD) &humi)) {
- SG(request_info).path_translated = estrdup(humi.lpszPath);
- } else
-#endif
- /* if mapping fails, default to what the server tells us */
- SG(request_info).path_translated = estrdup(lpECB->lpszPathTranslated);
-
- /* some server configurations allow '..' to slip through in the
- translated path. We'll just refuse to handle such a path. */
- if (strstr(SG(request_info).path_translated,"..")) {
- SG(sapi_headers).http_response_code = 404;
- efree(SG(request_info).path_translated);
- SG(request_info).path_translated = NULL;
- }
-}
-
-
-static void php_isapi_report_exception(char *message, int message_len)
-{
- if (!SG(headers_sent)) {
- HSE_SEND_HEADER_EX_INFO header_info;
- LPEXTENSION_CONTROL_BLOCK lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context);
-
- header_info.pszStatus = "500 Internal Server Error";
- header_info.cchStatus = strlen(header_info.pszStatus);
- header_info.pszHeader = "Content-Type: text/html\r\n\r\n";
- header_info.cchHeader = strlen(header_info.pszHeader);
-
- lpECB->dwHttpStatusCode = 500;
- lpECB->ServerSupportFunction(lpECB->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &header_info, NULL, NULL);
- SG(headers_sent)=1;
- }
- sapi_isapi_ub_write(message, message_len);
-}
-
-
-BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO *pVer)
-{
- pVer->dwExtensionVersion = HSE_VERSION;
-#ifdef WITH_ZEUS
- strncpy( pVer->lpszExtensionDesc, isapi_sapi_module.name, HSE_MAX_EXT_DLL_NAME_LEN);
-#else
- lstrcpyn(pVer->lpszExtensionDesc, isapi_sapi_module.name, HSE_MAX_EXT_DLL_NAME_LEN);
-#endif
- return TRUE;
-}
-
-
-static void my_endthread()
-{
-#ifdef PHP_WIN32
- if (bTerminateThreadsOnError) {
- _endthread();
- }
-#endif
-}
-
-#ifdef PHP_WIN32
-/* ep is accessible only in the context of the __except expression,
- * so we have to call this function to obtain it.
- */
-BOOL exceptionhandler(LPEXCEPTION_POINTERS *e, LPEXCEPTION_POINTERS ep)
-{
- *e=ep;
- return TRUE;
-}
-#endif
-
-DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB)
-{
- zend_file_handle file_handle;
- zend_bool stack_overflown=0;
- int retval = FAILURE;
-#ifdef PHP_ENABLE_SEH
- LPEXCEPTION_POINTERS e;
-#endif
-
- zend_first_try {
-#ifdef PHP_ENABLE_SEH
- __try {
-#endif
- init_request_info(lpECB);
- SG(server_context) = lpECB;
-
- php_request_startup();
-
- file_handle.filename = SG(request_info).path_translated;
- file_handle.free_filename = 0;
- file_handle.type = ZEND_HANDLE_FILENAME;
- file_handle.opened_path = NULL;
-
- /* open the script here so we can 404 if it fails */
- if (file_handle.filename)
- retval = php_fopen_primary_script(&file_handle);
-
- if (!file_handle.filename || retval == FAILURE) {
- SG(sapi_headers).http_response_code = 404;
- PUTS("No input file specified.\n");
- } else {
- php_execute_script(&file_handle);
- }
-
- if (SG(request_info).cookie_data) {
- efree(SG(request_info).cookie_data);
- }
- if (SG(request_info).path_translated)
- efree(SG(request_info).path_translated);
-#ifdef PHP_ENABLE_SEH
- } __except(exceptionhandler(&e, GetExceptionInformation())) {
- char buf[1024];
- if (_exception_code()==EXCEPTION_STACK_OVERFLOW) {
- LPBYTE lpPage;
- static SYSTEM_INFO si;
- static MEMORY_BASIC_INFORMATION mi;
- static DWORD dwOldProtect;
-
- GetSystemInfo(&si);
-
- /* Get page ESP is pointing to */
- _asm mov lpPage, esp;
-
- /* Get stack allocation base */
- VirtualQuery(lpPage, &mi, sizeof(mi));
-
- /* Go to the page below the current page */
- lpPage = (LPBYTE) (mi.BaseAddress) - si.dwPageSize;
-
- /* Free pages below current page */
- if (!VirtualFree(mi.AllocationBase, (LPBYTE)lpPage - (LPBYTE) mi.AllocationBase, MEM_DECOMMIT)) {
- _endthread();
- }
-
- /* Restore the guard page */
- if (!VirtualProtect(lpPage, si.dwPageSize, PAGE_GUARD | PAGE_READWRITE, &dwOldProtect)) {
- _endthread();
- }
-
- CG(unclean_shutdown)=1;
- _snprintf(buf, sizeof(buf)-1,"PHP has encountered a Stack overflow");
- php_isapi_report_exception(buf, strlen(buf));
- } else if (_exception_code()==EXCEPTION_ACCESS_VIOLATION) {
- _snprintf(buf, sizeof(buf)-1,"PHP has encountered an Access Violation at %p", e->ExceptionRecord->ExceptionAddress);
- php_isapi_report_exception(buf, strlen(buf));
- my_endthread();
- } else {
- _snprintf(buf, sizeof(buf)-1,"PHP has encountered an Unhandled Exception Code %d at %p", e->ExceptionRecord->ExceptionCode , e->ExceptionRecord->ExceptionAddress);
- php_isapi_report_exception(buf, strlen(buf));
- my_endthread();
- }
- }
-#endif
-#ifdef PHP_ENABLE_SEH
- __try {
- php_request_shutdown(NULL);
- } __except(EXCEPTION_EXECUTE_HANDLER) {
- my_endthread();
- }
-#else
- php_request_shutdown(NULL);
-#endif
- } zend_catch {
- zend_try {
- php_request_shutdown(NULL);
- } zend_end_try();
- return HSE_STATUS_ERROR;
- } zend_end_try();
-
- return HSE_STATUS_SUCCESS;
-}
-
-
-
-__declspec(dllexport) BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
-{
- switch (fdwReason) {
- case DLL_PROCESS_ATTACH:
-#ifdef WITH_ZEUS
- tsrm_startup(128, 1, TSRM_ERROR_LEVEL_CORE, "TSRM.log");
-#else
- tsrm_startup(128, 1, TSRM_ERROR_LEVEL_CORE, "C:\\TSRM.log");
-#endif
- sapi_startup(&isapi_sapi_module);
- if (isapi_sapi_module.startup) {
- isapi_sapi_module.startup(&sapi_module);
- }
- break;
- case DLL_THREAD_ATTACH:
- break;
- case DLL_THREAD_DETACH:
- ts_free_thread();
- break;
- case DLL_PROCESS_DETACH:
- if (isapi_sapi_module.shutdown) {
- isapi_sapi_module.shutdown(&sapi_module);
- }
- sapi_shutdown();
- tsrm_shutdown();
- break;
- }
- return TRUE;
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/sapi/isapi/php7isapi.def b/sapi/isapi/php7isapi.def
deleted file mode 100644
index 596023ef55..0000000000
--- a/sapi/isapi/php7isapi.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
-HttpFilterProc
-GetFilterVersion
-HttpExtensionProc
-GetExtensionVersion
diff --git a/sapi/isapi/stresstest/getopt.c b/sapi/isapi/stresstest/getopt.c
deleted file mode 100644
index 21056bf883..0000000000
--- a/sapi/isapi/stresstest/getopt.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/* Borrowed from Apache NT Port */
-
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <stdlib.h>
-#include "getopt.h"
-#define OPTERRCOLON (1)
-#define OPTERRNF (2)
-#define OPTERRARG (3)
-
-
-char *ap_optarg;
-int ap_optind = 1;
-static int ap_opterr = 1;
-static int ap_optopt;
-
-static int
-ap_optiserr(int argc, char * const *argv, int oint, const char *optstr,
- int optchr, int err)
-{
- if (ap_opterr)
- {
- fprintf(stderr, "Error in argument %d, char %d: ", oint, optchr+1);
- switch(err)
- {
- case OPTERRCOLON:
- fprintf(stderr, ": in flags\n");
- break;
- case OPTERRNF:
- fprintf(stderr, "option not found %c\n", argv[oint][optchr]);
- break;
- case OPTERRARG:
- fprintf(stderr, "no argument for option %c\n", argv[oint][optchr]);
- break;
- default:
- fprintf(stderr, "unknown\n");
- break;
- }
- }
- ap_optopt = argv[oint][optchr];
- return('?');
-}
-
-int ap_getopt(int argc, char* const *argv, const char *optstr)
-{
- static int optchr = 0;
- static int dash = 0; /* have already seen the - */
-
- char *cp;
-
- if (ap_optind >= argc)
- return(EOF);
- if (!dash && (argv[ap_optind][0] != '-'))
- return(EOF);
- if (!dash && (argv[ap_optind][0] == '-') && !argv[ap_optind][1])
- {
- /*
- * use to specify stdin. Need to let pgm process this and
- * the following args
- */
- return(EOF);
- }
- if ((argv[ap_optind][0] == '-') && (argv[ap_optind][1] == '-'))
- {
- /* -- indicates end of args */
- ap_optind++;
- return(EOF);
- }
- if (!dash)
- {
- assert((argv[ap_optind][0] == '-') && argv[ap_optind][1]);
- dash = 1;
- optchr = 1;
- }
-
- /* Check if the guy tries to do a -: kind of flag */
- assert(dash);
- if (argv[ap_optind][optchr] == ':')
- {
- dash = 0;
- ap_optind++;
- return(ap_optiserr(argc, argv, ap_optind-1, optstr, optchr, OPTERRCOLON));
- }
- if (!(cp = strchr(optstr, argv[ap_optind][optchr])))
- {
- int errind = ap_optind;
- int errchr = optchr;
-
- if (!argv[ap_optind][optchr+1])
- {
- dash = 0;
- ap_optind++;
- }
- else
- optchr++;
- return(ap_optiserr(argc, argv, errind, optstr, errchr, OPTERRNF));
- }
- if (cp[1] == ':')
- {
- /* Check for cases where the value of the argument
- is in the form -<arg> <val> or in the form -<arg><val> */
- dash = 0;
- if(!argv[ap_optind][2]) {
- ap_optind++;
- if (ap_optind == argc)
- return(ap_optiserr(argc, argv, ap_optind-1, optstr, optchr, OPTERRARG));
- ap_optarg = argv[ap_optind++];
- }
- else
- {
- ap_optarg = &argv[ap_optind][2];
- ap_optind++;
- }
- return(*cp);
- }
- else
- {
- if (!argv[ap_optind][optchr+1])
- {
- dash = 0;
- ap_optind++;
- }
- else
- optchr++;
- return(*cp);
- }
- assert(0);
- return(0);
-}
-
-#ifdef TESTGETOPT
-int
- main (int argc, char **argv)
- {
- int c;
- extern char *ap_optarg;
- extern int ap_optind;
- int aflg = 0;
- int bflg = 0;
- int errflg = 0;
- char *ofile = NULL;
-
- while ((c = ap_getopt(argc, argv, "abo:")) != EOF)
- switch (c) {
- case 'a':
- if (bflg)
- errflg++;
- else
- aflg++;
- break;
- case 'b':
- if (aflg)
- errflg++;
- else
- bflg++;
- break;
- case 'o':
- ofile = ap_optarg;
- (void)printf("ofile = %s\n", ofile);
- break;
- case '?':
- errflg++;
- }
- if (errflg) {
- (void)fprintf(stderr,
- "usage: cmd [-a|-b] [-o <filename>] files...\n");
- exit (2);
- }
- for ( ; ap_optind < argc; ap_optind++)
- (void)printf("%s\n", argv[ap_optind]);
- return 0;
- }
-
-#endif /* TESTGETOPT */
diff --git a/sapi/isapi/stresstest/getopt.h b/sapi/isapi/stresstest/getopt.h
deleted file mode 100644
index 6d4139bfe0..0000000000
--- a/sapi/isapi/stresstest/getopt.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Borrowed from Apache NT Port */
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern char *ap_optarg;
-extern int ap_optind;
-
-int ap_getopt(int argc, char* const *argv, const char *optstr);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/sapi/isapi/stresstest/notes.txt b/sapi/isapi/stresstest/notes.txt
deleted file mode 100644
index e6d10dd486..0000000000
--- a/sapi/isapi/stresstest/notes.txt
+++ /dev/null
@@ -1,56 +0,0 @@
-This stress test program is for debugging threading issues with the ISAPI
-module.
-
-2 ways to use it:
-
-1: test any php script file on multiple threads
-2: run the php test scripts bundled with the source code
-
-
-
-GLOBAL SETTINGS
-===============
-
-If you need to set special environement variables, in addition to your
-regular environment, create a file that contains them, one setting per line:
-
-MY_ENV_VAR=XXXXXXXX
-
-This can be used to simulate ISAPI environment variables if need be.
-
-By default, stress test uses 10 threads. To change this, change the define
-NUM_THREADS in stresstest.cpp.
-
-
-
-1: Test any php script file on multiple threads
-===============================================
-
-Create a file that contains a list of php script files, one per line. If
-you need to provide input, place the GET data, or Query String, after the
-filename. File contents would look like:
-
-e:\inetpub\pages\index.php
-e:\inetpub\pages\info.php
-e:\inetpub\pages\test.php a=1&b=2
-
-Run: stresstest L files.txt
-
-
-
-2: Run the php test scripts bundled with the source code
-========================================================
-
-supply the path to the parent of the "tests" directory (expect a couple
-long pauses for a couple of the larger tests)
-
-Run: stresstest T c:\php7-source
-
-
-
-TODO:
-
-* Make more options configurable: number of threads, iterations, etc.
-* Improve stdout output to make it more useful
-* Implement support for SKIPIF
-* Improve speed of CompareFile function (too slow on big files).
diff --git a/sapi/isapi/stresstest/stresstest.cpp b/sapi/isapi/stresstest/stresstest.cpp
deleted file mode 100644
index ddb06473c2..0000000000
--- a/sapi/isapi/stresstest/stresstest.cpp
+++ /dev/null
@@ -1,936 +0,0 @@
-/*
- * ======================================================================= *
- * File: stress .c *
- * stress tester for isapi dll's *
- * based on cgiwrap *
- * ======================================================================= *
- *
-*/
-#define WIN32_LEAN_AND_MEAN
-#include <afx.h>
-#include <afxtempl.h>
-#include <winbase.h>
-#include <winerror.h>
-#include <httpext.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "getopt.h"
-
-// These are things that go out in the Response Header
-//
-#define HTTP_VER "HTTP/1.0"
-#define SERVER_VERSION "Http-Srv-Beta2/1.0"
-
-//
-// Simple wrappers for the heap APIS
-//
-#define xmalloc(s) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (s))
-#define xfree(s) HeapFree(GetProcessHeap(), 0, (s))
-
-//
-// The mandatory exports from the ISAPI DLL
-//
-DWORD numThreads = 1;
-DWORD iterations = 1;
-
-HANDLE StartNow;
-// quick and dirty environment
-typedef CMapStringToString TEnvironment;
-TEnvironment IsapiEnvironment;
-
-typedef struct _TResults {
- LONG ok;
- LONG bad;
-} TResults;
-
-CStringArray IsapiFileList; // list of filenames
-CStringArray TestNames; // --TEST--
-CStringArray IsapiGetData; // --GET--
-CStringArray IsapiPostData; // --POST--
-CStringArray IsapiMatchData; // --EXPECT--
-CArray<TResults, TResults> Results;
-
-typedef struct _TIsapiContext {
- HANDLE in;
- HANDLE out;
- DWORD tid;
- TEnvironment env;
- HANDLE waitEvent;
-} TIsapiContext;
-
-//
-// Prototypes of the functions this sample implements
-//
-extern "C" {
-HINSTANCE hDll;
-typedef BOOL (WINAPI *VersionProc)(HSE_VERSION_INFO *) ;
-typedef DWORD (WINAPI *HttpExtProc)(EXTENSION_CONTROL_BLOCK *);
-typedef BOOL (WINAPI *TerminateProc) (DWORD);
-BOOL WINAPI FillExtensionControlBlock(EXTENSION_CONTROL_BLOCK *, TIsapiContext *) ;
-BOOL WINAPI GetServerVariable(HCONN, LPSTR, LPVOID, LPDWORD );
-BOOL WINAPI ReadClient(HCONN, LPVOID, LPDWORD);
-BOOL WINAPI WriteClient(HCONN, LPVOID, LPDWORD, DWORD);
-BOOL WINAPI ServerSupportFunction(HCONN, DWORD, LPVOID, LPDWORD, LPDWORD);
-VersionProc IsapiGetExtensionVersion;
-HttpExtProc IsapiHttpExtensionProc;
-TerminateProc TerminateExtensionProc;
-HSE_VERSION_INFO version_info;
-}
-
-char * MakeDateStr(VOID);
-char * GetEnv(char *);
-
-
-
-
-DWORD CALLBACK IsapiThread(void *);
-int stress_main(const char *filename,
- const char *arg,
- const char *postfile,
- const char *matchdata);
-
-
-
-BOOL bUseTestFiles = FALSE;
-char temppath[MAX_PATH];
-
-void stripcrlf(char *line)
-{
- DWORD l = strlen(line)-1;
- if (line[l]==10 || line[l]==13) line[l]=0;
- l = strlen(line)-1;
- if (line[l]==10 || line[l]==13) line[l]=0;
-}
-
-#define COMPARE_BUF_SIZE 1024
-
-BOOL CompareFiles(const char*f1, const char*f2)
-{
- FILE *fp1, *fp2;
- bool retval;
- char buf1[COMPARE_BUF_SIZE], buf2[COMPARE_BUF_SIZE];
- int length1, length2;
-
- if ((fp1=fopen(f1, "r"))==NULL) {
- return FALSE;
- }
-
- if ((fp2=fopen(f2, "r"))==NULL) {
- fclose(fp1);
- return FALSE;
- }
-
- retval = TRUE; // success oriented
- while (true) {
- length1 = fread(buf1, 1, sizeof(buf1), fp1);
- length2 = fread(buf2, 1, sizeof(buf2), fp2);
-
- // check for end of file
- if (feof(fp1)) {
- if (!feof(fp2)) {
- retval = FALSE;
- }
- break;
- } else if (feof(fp2)) {
- if (!feof(fp1)) {
- retval = FALSE;
- }
- break;
- }
-
- // compare data
- if (length1!=length2
- || memcmp(buf1, buf2, length1)!=0) {
- retval = FALSE;
- break;
- }
- }
- fclose(fp1);
- fclose(fp2);
-
- return retval;
-}
-
-
-BOOL CompareStringWithFile(const char *filename, const char *str, unsigned int str_length)
-{
- FILE *fp;
- bool retval;
- char buf[COMPARE_BUF_SIZE];
- unsigned int offset=0, readbytes;
- fprintf(stderr, "test %s\n",filename);
- if ((fp=fopen(filename, "rb"))==NULL) {
- fprintf(stderr, "Error opening %s\n",filename);
- return FALSE;
- }
-
- retval = TRUE; // success oriented
- while (true) {
- readbytes = fread(buf, 1, sizeof(buf), fp);
-
- // check for end of file
-
- if (offset+readbytes > str_length
- || memcmp(buf, str+offset, readbytes)!=NULL) {
- fprintf(stderr, "File missmatch %s\n",filename);
- retval = FALSE;
- break;
- }
- if (feof(fp)) {
- if (!retval) fprintf(stderr, "File zero length %s\n",filename);
- break;
- }
- }
- fclose(fp);
-
- return retval;
-}
-
-
-BOOL ReadGlobalEnvironment(const char *environment)
-{
- if (environment) {
- FILE *fp = fopen(environment, "r");
- DWORD i=0;
- if (fp) {
- char line[2048];
- while (fgets(line, sizeof(line)-1, fp)) {
- // file.php arg1 arg2 etc.
- char *p = strchr(line, '=');
- if (p) {
- *p=0;
- IsapiEnvironment[line]=p+1;
- }
- }
- fclose(fp);
- return IsapiEnvironment.GetCount() > 0;
- }
- }
- return FALSE;
-}
-
-BOOL ReadFileList(const char *filelist)
-{
- FILE *fp = fopen(filelist, "r");
- if (!fp) {
- printf("Unable to open %s\r\n", filelist);
- }
- char line[2048];
- int i=0;
- while (fgets(line, sizeof(line)-1, fp)) {
- // file.php arg1 arg2 etc.
- stripcrlf(line);
- if (strlen(line)>3) {
- char *p = strchr(line, ' ');
- if (p) {
- *p = 0;
- // get file
-
- IsapiFileList.Add(line);
- IsapiGetData.Add(p+1);
- } else {
- // just a filename is all
- IsapiFileList.Add(line);
- IsapiGetData.Add("");
- }
- }
-
- // future use
- IsapiPostData.Add("");
- IsapiMatchData.Add("");
- TestNames.Add("");
-
- i++;
- }
- Results.SetSize(TestNames.GetSize());
-
- fclose(fp);
- return IsapiFileList.GetSize() > 0;
-}
-
-void DoThreads() {
-
- if (IsapiFileList.GetSize() == 0) {
- printf("No Files to test\n");
- return;
- }
-
- printf("Starting Threads...\n");
- // loop creating threads
- DWORD tid;
- HANDLE *threads = new HANDLE[numThreads];
- DWORD i;
- for (i=0; i< numThreads; i++) {
- threads[i]=CreateThread(NULL, 0, IsapiThread, NULL, CREATE_SUSPENDED, &tid);
- }
- for (i=0; i< numThreads; i++) {
- if (threads[i]) ResumeThread(threads[i]);
- }
- // wait for threads to finish
- WaitForMultipleObjects(numThreads, threads, TRUE, INFINITE);
- for (i=0; i< numThreads; i++) {
- CloseHandle(threads[i]);
- }
- delete [] threads;
-}
-
-void DoFileList(const char *filelist, const char *environment)
-{
- // read config files
-
- if (!ReadFileList(filelist)) {
- printf("No Files to test!\r\n");
- return;
- }
-
- ReadGlobalEnvironment(environment);
-
- DoThreads();
-}
-
-
-/**
- * ParseTestFile
- * parse a single phpt file and add it to the arrays
- */
-BOOL ParseTestFile(const char *path, const char *fn)
-{
- // parse the test file
- char filename[MAX_PATH];
- _snprintf(filename, sizeof(filename)-1, "%s\\%s", path, fn);
- char line[1024];
- memset(line, 0, sizeof(line));
- CString cTest, cSkipIf, cPost, cGet, cFile, cExpect;
- printf("Reading %s\r\n", filename);
-
- enum state {none, test, skipif, post, get, file, expect} parsestate = none;
-
- FILE *fp = fopen(filename, "rb");
- char *tn = _tempnam(temppath,"pht.");
- char *en = _tempnam(temppath,"exp.");
- FILE *ft = fopen(tn, "wb+");
- FILE *fe = fopen(en, "wb+");
- if (fp && ft && fe) {
- while (fgets(line, sizeof(line)-1, fp)) {
- if (line[0]=='-') {
- if (_strnicmp(line, "--TEST--", 8)==0) {
- parsestate = test;
- continue;
- } else if (_strnicmp(line, "--SKIPIF--", 10)==0) {
- parsestate = skipif;
- continue;
- } else if (_strnicmp(line, "--POST--", 8)==0) {
- parsestate = post;
- continue;
- } else if (_strnicmp(line, "--GET--", 7)==0) {
- parsestate = get;
- continue;
- } else if (_strnicmp(line, "--FILE--", 8)==0) {
- parsestate = file;
- continue;
- } else if (_strnicmp(line, "--EXPECT--", 10)==0) {
- parsestate = expect;
- continue;
- }
- }
- switch (parsestate) {
- case test:
- stripcrlf(line);
- cTest = line;
- break;
- case skipif:
- cSkipIf += line;
- break;
- case post:
- cPost += line;
- break;
- case get:
- cGet += line;
- break;
- case file:
- fputs(line, ft);
- break;
- case expect:
- fputs(line, fe);
- break;
- }
- }
-
- fclose(fp);
- fclose(ft);
- fclose(fe);
-
- if (!cTest.IsEmpty()) {
- IsapiFileList.Add(tn);
- TestNames.Add(cTest);
- IsapiGetData.Add(cGet);
- IsapiPostData.Add(cPost);
- IsapiMatchData.Add(en);
- free(tn);
- free(en);
- return TRUE;
- }
- }
- free(tn);
- free(en);
- return FALSE;
-}
-
-
-/**
- * GetTestFiles
- * Recurse through the path and subdirectories, parse each phpt file
- */
-BOOL GetTestFiles(const char *path)
-{
- // find all files .phpt under testpath\tests
- char FindPath[MAX_PATH];
- WIN32_FIND_DATA fd;
- memset(&fd, 0, sizeof(WIN32_FIND_DATA));
-
- _snprintf(FindPath, sizeof(FindPath)-1, "%s\\*.*", path);
- HANDLE fh = FindFirstFile(FindPath, &fd);
- if (fh != INVALID_HANDLE_VALUE) {
- do {
- if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
- !strchr(fd.cFileName, '.')) {
- // subdirectory, recurse into it
- char NewFindPath[MAX_PATH];
- _snprintf(NewFindPath, sizeof(NewFindPath)-1, "%s\\%s", path, fd.cFileName);
- GetTestFiles(NewFindPath);
- } else if (strstr(fd.cFileName, ".phpt")) {
- // got test file, parse it now
- if (ParseTestFile(path, fd.cFileName)) {
- printf("Test File Added: %s\\%s\r\n", path, fd.cFileName);
- }
- }
- memset(&fd, 0, sizeof(WIN32_FIND_DATA));
- } while (FindNextFile(fh, &fd) != 0);
- FindClose(fh);
- }
- return IsapiFileList.GetSize() > 0;
-}
-
-void DeleteTempFiles(const char *mask)
-{
- char FindPath[MAX_PATH];
- WIN32_FIND_DATA fd;
- memset(&fd, 0, sizeof(WIN32_FIND_DATA));
-
- _snprintf(FindPath, sizeof(FindPath)-1, "%s\\%s", temppath, mask);
- HANDLE fh = FindFirstFile(FindPath, &fd);
- if (fh != INVALID_HANDLE_VALUE) {
- do {
- char NewFindPath[MAX_PATH];
- _snprintf(NewFindPath, sizeof(NewFindPath)-1, "%s\\%s", temppath, fd.cFileName);
- DeleteFile(NewFindPath);
- memset(&fd, 0, sizeof(WIN32_FIND_DATA));
- } while (FindNextFile(fh, &fd) != 0);
- FindClose(fh);
- }
-}
-
-void DoTestFiles(const char *filelist, const char *environment)
-{
- if (!GetTestFiles(filelist)) {
- printf("No Files to test!\r\n");
- return;
- }
-
- Results.SetSize(IsapiFileList.GetSize());
-
- ReadGlobalEnvironment(environment);
-
- DoThreads();
-
- printf("\r\nRESULTS:\r\n");
- // show results:
- DWORD r = Results.GetSize();
- for (DWORD i=0; i< r; i++) {
- TResults result = Results.GetAt(i);
- printf("%s\r\nOK: %d FAILED: %d\r\n", TestNames.GetAt(i), result.ok, result.bad);
- }
-
- // delete temp files
- printf("Deleting Temp Files\r\n");
- DeleteTempFiles("exp.*");
- DeleteTempFiles("pht.*");
- printf("Done\r\n");
-}
-
-#define OPTSTRING "m:f:d:h:t:i:"
-static void _usage(char *argv0)
-{
- char *prog;
-
- prog = strrchr(argv0, '/');
- if (prog) {
- prog++;
- } else {
- prog = "stresstest";
- }
-
- printf("Usage: %s -m <isapi.dll> -d|-l <file> [-t <numthreads>] [-i <numiterations>]\n"
- " -m path to isapi dll\n"
- " -d <directory> php directory (to run php test files).\n"
- " -f <file> file containing list of files to run\n"
- " -t number of threads to use (default=1)\n"
- " -i number of iterations per thread (default=1)\n"
- " -h This help\n", prog);
-}
-int main(int argc, char* argv[])
-{
- LPVOID lpMsgBuf;
- char *filelist=NULL, *environment=NULL, *module=NULL;
- int c = NULL;
- while ((c=ap_getopt(argc, argv, OPTSTRING))!=-1) {
- switch (c) {
- case 'd':
- bUseTestFiles = TRUE;
- filelist = strdup(ap_optarg);
- break;
- case 'f':
- bUseTestFiles = FALSE;
- filelist = strdup(ap_optarg);
- break;
- case 'e':
- environment = strdup(ap_optarg);
- break;
- case 't':
- numThreads = atoi(ap_optarg);
- break;
- case 'i':
- iterations = atoi(ap_optarg);
- break;
- case 'm':
- module = strdup(ap_optarg);
- break;
- case 'h':
- _usage(argv[0]);
- exit(0);
- break;
- }
- }
- if (!module || !filelist) {
- _usage(argv[0]);
- exit(0);
- }
-
- GetTempPath(sizeof(temppath), temppath);
- hDll = LoadLibrary(module); // Load our DLL
-
- if (!hDll) {
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPTSTR) &lpMsgBuf,
- 0,
- NULL
- );
- fprintf(stderr,"Error: Dll 'php7isapi.dll' not found -%d\n%s\n", GetLastError(), lpMsgBuf);
- free (module);
- free(filelist);
- LocalFree( lpMsgBuf );
- return -1;
- }
-
- //
- // Find the exported functions
-
- IsapiGetExtensionVersion = (VersionProc)GetProcAddress(hDll,"GetExtensionVersion");
- if (!IsapiGetExtensionVersion) {
- fprintf(stderr,"Can't Get Extension Version %d\n", GetLastError());
- free (module);
- free(filelist);
- return -1;
- }
- IsapiHttpExtensionProc = (HttpExtProc)GetProcAddress(hDll,"HttpExtensionProc");
- if (!IsapiHttpExtensionProc) {
- fprintf(stderr,"Can't Get Extension proc %d\n", GetLastError());
- free (module);
- free(filelist);
- return -1;
- }
- TerminateExtensionProc = (TerminateProc) GetProcAddress(hDll,
- "TerminateExtension");
-
- // This should really check if the version information matches what we
- // expect.
- //
- if (!IsapiGetExtensionVersion(&version_info) ) {
- fprintf(stderr,"Fatal: GetExtensionVersion failed\n");
- free (module);
- free(filelist);
- return -1;
- }
-
- if (bUseTestFiles) {
- char TestPath[MAX_PATH];
- if (filelist != NULL)
- _snprintf(TestPath, sizeof(TestPath)-1, "%s\\tests", filelist);
- else strcpy(TestPath, "tests");
- DoTestFiles(TestPath, environment);
- } else {
- DoFileList(filelist, environment);
- }
-
- // cleanup
- if (TerminateExtensionProc) TerminateExtensionProc(0);
-
- // We should really free memory (e.g., from GetEnv), but we'll be dead
- // soon enough
-
- FreeLibrary(hDll);
- free (module);
- free(filelist);
- return 0;
-}
-
-
-DWORD CALLBACK IsapiThread(void *p)
-{
- DWORD filecount = IsapiFileList.GetSize();
-
- for (DWORD j=0; j<iterations; j++) {
- for (DWORD i=0; i<filecount; i++) {
- // execute each file
- CString testname = TestNames.GetAt(i);
- BOOL ok = FALSE;
- if (stress_main(IsapiFileList.GetAt(i),
- IsapiGetData.GetAt(i),
- IsapiPostData.GetAt(i),
- IsapiMatchData.GetAt(i))) {
- InterlockedIncrement(&Results[i].ok);
- ok = TRUE;
- } else {
- InterlockedIncrement(&Results[i].bad);
- ok = FALSE;
- }
-
- if (testname.IsEmpty()) {
- printf("Thread %d File %s\n", GetCurrentThreadId(), IsapiFileList.GetAt(i));
- } else {
- printf("tid %d: %s %s\n", GetCurrentThreadId(), testname, ok?"OK":"FAIL");
- }
- Sleep(10);
- }
- }
- printf("Thread ending...\n");
- return 0;
-}
-
-/*
- * ======================================================================= *
- * In the startup of this program, we look at our executable name and *
- * replace the ".EXE" with ".DLL" to find the ISAPI DLL we need to load. *
- * This means that the executable need only be given the same "name" as *
- * the DLL to load. There is no recompilation required. *
- * ======================================================================= *
-*/
-BOOL stress_main(const char *filename,
- const char *arg,
- const char *postdata,
- const char *matchdata)
-{
-
- EXTENSION_CONTROL_BLOCK ECB;
- DWORD rc;
- TIsapiContext context;
-
- // open output and input files
- context.tid = GetCurrentThreadId();
- CString fname;
- fname.Format("%08X.out", context.tid);
-
- context.out = CreateFile(fname, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH, NULL);
- if (context.out==INVALID_HANDLE_VALUE) {
- printf("failed to open output file %s\n", fname);
- return 0;
- }
-
- // not using post files
- context.in = INVALID_HANDLE_VALUE;
-
- //
- // Fill the ECB with the necessary information
- //
- if (!FillExtensionControlBlock(&ECB, &context) ) {
- fprintf(stderr,"Fill Ext Block Failed\n");
- return -1;
- }
-
- // check for command line argument,
- // first arg = filename
- // this is added for testing php from command line
-
- context.env.RemoveAll();
- context.env["PATH_TRANSLATED"]= filename;
- context.env["SCRIPT_MAP"]= filename;
- context.env["CONTENT_TYPE"]= "";
- context.env["CONTENT_LENGTH"]= "";
- context.env["QUERY_STRING"]= arg;
- context.env["METHOD"]="GET";
- context.env["PATH_INFO"] = "";
- context.waitEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- char buf[MAX_PATH];
- if (postdata && *postdata !=0) {
- ECB.cbAvailable = strlen(postdata);
- ECB.cbTotalBytes = ECB.cbAvailable;
- ECB.lpbData = (unsigned char *)postdata;
- context.env["METHOD"]="POST";
-
- _snprintf(buf, sizeof(buf)-1, "%d", ECB.cbTotalBytes);
- context.env["CONTENT_LENGTH"]=buf;
-
- context.env["CONTENT_TYPE"]="application/x-www-form-urlencoded";
- }
- ECB.lpszMethod = strdup(context.env["METHOD"]);
- ECB.lpszPathTranslated = strdup(filename);
- ECB.lpszQueryString = strdup(arg);
- ECB.lpszPathInfo = strdup(context.env["PATH_INFO"]);
-
-
- // Call the DLL
- //
- rc = IsapiHttpExtensionProc(&ECB);
- if (rc == HSE_STATUS_PENDING) {
- // We will exit in ServerSupportFunction
- WaitForSingleObject(context.waitEvent, INFINITE);
- }
- CloseHandle(context.waitEvent);
- //Sleep(75);
- free(ECB.lpszPathTranslated);
- free(ECB.lpszQueryString);
- free(ECB.lpszMethod);
- free(ECB.lpszPathInfo);
-
- BOOL ok = TRUE;
-
- if (context.out != INVALID_HANDLE_VALUE) CloseHandle(context.out);
-
- // compare the output with the EXPECT section
- if (matchdata && *matchdata != 0) {
- ok = CompareFiles(fname, matchdata);
- }
-
- DeleteFile(fname);
-
- return ok;
-
-}
-//
-// GetServerVariable() is how the DLL calls the main program to figure out
-// the environment variables it needs. This is a required function.
-//
-BOOL WINAPI GetServerVariable(HCONN hConn, LPSTR lpszVariableName,
- LPVOID lpBuffer, LPDWORD lpdwSize){
-
- DWORD rc;
- CString value;
- TIsapiContext *c = (TIsapiContext *)hConn;
- if (!c) return FALSE;
-
- if (IsapiEnvironment.Lookup(lpszVariableName, value)) {
- rc = value.GetLength();
- strncpy((char *)lpBuffer, value, *lpdwSize-1);
- } else if (c->env.Lookup(lpszVariableName, value)) {
- rc = value.GetLength();
- strncpy((char *)lpBuffer, value, *lpdwSize-1);
- } else
- rc = GetEnvironmentVariable(lpszVariableName, (char *)lpBuffer, *lpdwSize) ;
-
- if (!rc) { // return of 0 indicates the variable was not found
- SetLastError(ERROR_NO_DATA);
- return FALSE;
- }
-
- if (rc > *lpdwSize) {
- SetLastError(ERROR_INSUFFICIENT_BUFFER);
- return FALSE;
- }
-
- *lpdwSize =rc + 1 ; // GetEnvironmentVariable does not count the NULL
-
- return TRUE;
-
-}
-//
-// Again, we don't have an HCONN, so we simply wrap ReadClient() to
-// ReadFile on stdin. The semantics of the two functions are the same
-//
-BOOL WINAPI ReadClient(HCONN hConn, LPVOID lpBuffer, LPDWORD lpdwSize) {
- TIsapiContext *c = (TIsapiContext *)hConn;
- if (!c) return FALSE;
-
- if (c->in != INVALID_HANDLE_VALUE)
- return ReadFile(c->in, lpBuffer, (*lpdwSize), lpdwSize, NULL);
-
- return FALSE;
-}
-//
-// ditto for WriteClient()
-//
-BOOL WINAPI WriteClient(HCONN hConn, LPVOID lpBuffer, LPDWORD lpdwSize,
- DWORD dwReserved) {
- TIsapiContext *c = (TIsapiContext *)hConn;
- if (!c) return FALSE;
-
- if (c->out != INVALID_HANDLE_VALUE)
- return WriteFile(c->out, lpBuffer, *lpdwSize, lpdwSize, NULL);
- return FALSE;
-}
-//
-// This is a special callback function used by the DLL for certain extra
-// functionality. Look at the API help for details.
-//
-BOOL WINAPI ServerSupportFunction(HCONN hConn, DWORD dwHSERequest,
- LPVOID lpvBuffer, LPDWORD lpdwSize, LPDWORD lpdwDataType){
-
- TIsapiContext *c = (TIsapiContext *)hConn;
- char *lpszRespBuf;
- char * temp = NULL;
- DWORD dwBytes;
- BOOL bRet = TRUE;
-
- switch(dwHSERequest) {
- case (HSE_REQ_SEND_RESPONSE_HEADER) :
- lpszRespBuf = (char *)xmalloc(*lpdwSize);//+ 80);//accommodate our header
- if (!lpszRespBuf)
- return FALSE;
- wsprintf(lpszRespBuf,"%s",
- //HTTP_VER,
-
- /* Default response is 200 Ok */
-
- //lpvBuffer?lpvBuffer:"200 Ok",
-
- /* Create a string for the time. */
- //temp=MakeDateStr(),
-
- //SERVER_VERSION,
-
- /* If this exists, it is a pointer to a data buffer to
- be sent. */
- lpdwDataType?(char *)lpdwDataType:NULL);
-
- if (temp) xfree(temp);
-
- dwBytes = strlen(lpszRespBuf);
- bRet = WriteClient(0, lpszRespBuf, &dwBytes, 0);
- xfree(lpszRespBuf);
-
- break;
- //
- // A real server would do cleanup here
- case (HSE_REQ_DONE_WITH_SESSION):
- SetEvent(c->waitEvent);
- //ExitThread(0);
- break;
-
- //
- // This sends a redirect (temporary) to the client.
- // The header construction is similar to RESPONSE_HEADER above.
- //
- case (HSE_REQ_SEND_URL_REDIRECT_RESP):
- lpszRespBuf = (char *)xmalloc(*lpdwSize +80) ;
- if (!lpszRespBuf)
- return FALSE;
- wsprintf(lpszRespBuf,"%s %s %s\r\n",
- HTTP_VER,
- "302 Moved Temporarily",
- (lpdwSize > 0)?lpvBuffer:0);
- xfree(temp);
- dwBytes = strlen(lpszRespBuf);
- bRet = WriteClient(0, lpszRespBuf, &dwBytes, 0);
- xfree(lpszRespBuf);
- break;
- default:
- return FALSE;
- break;
- }
- return bRet;
-
-}
-//
-// Makes a string of the date and time from GetSystemTime().
-// This is in UTC, as required by the HTTP spec.`
-//
-char * MakeDateStr(void){
- SYSTEMTIME systime;
- char *szDate= (char *)xmalloc(64);
-
- char * DaysofWeek[] = {"Sun","Mon","Tue","Wed","Thurs","Fri","Sat"};
- char * Months[] = {"NULL","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug",
- "Sep","Oct","Nov","Dec"};
-
- GetSystemTime(&systime);
-
- wsprintf(szDate,"%s, %d %s %d %d:%d.%d", DaysofWeek[systime.wDayOfWeek],
- systime.wDay,
- Months[systime.wMonth],
- systime.wYear,
- systime.wHour, systime.wMinute,
- systime.wSecond );
-
- return szDate;
-}
-//
-// Fill the ECB up
-//
-BOOL WINAPI FillExtensionControlBlock(EXTENSION_CONTROL_BLOCK *ECB, TIsapiContext *context) {
-
- char * temp;
- ECB->cbSize = sizeof(EXTENSION_CONTROL_BLOCK);
- ECB->dwVersion = MAKELONG(HSE_VERSION_MINOR, HSE_VERSION_MAJOR);
- ECB->ConnID = (void *)context;
- //
- // Pointers to the functions the DLL will call.
- //
- ECB->GetServerVariable = GetServerVariable;
- ECB->ReadClient = ReadClient;
- ECB->WriteClient = WriteClient;
- ECB->ServerSupportFunction = ServerSupportFunction;
-
- //
- // Fill in the standard CGI environment variables
- //
- ECB->lpszMethod = GetEnv("REQUEST_METHOD");
- if (!ECB->lpszMethod) ECB->lpszMethod = "GET";
-
- ECB->lpszQueryString = GetEnv("QUERY_STRING");
- ECB->lpszPathInfo = GetEnv("PATH_INFO");
- ECB->lpszPathTranslated = GetEnv("PATH_TRANSLATED");
- ECB->cbTotalBytes=( (temp=GetEnv("CONTENT_LENGTH")) ? (atoi(temp)): 0);
- ECB->cbAvailable = 0;
- ECB->lpbData = (unsigned char *)"";
- ECB->lpszContentType = GetEnv("CONTENT_TYPE");
- return TRUE;
-
-}
-
-//
-// Works like _getenv(), but uses win32 functions instead.
-//
-char *GetEnv(LPSTR lpszEnvVar)
-{
-
- char *var, dummy;
- DWORD dwLen;
-
- if (!lpszEnvVar)
- return "";
-
- dwLen =GetEnvironmentVariable(lpszEnvVar, &dummy, 1);
-
- if (dwLen == 0)
- return "";
-
- var = (char *)xmalloc(dwLen);
- if (!var)
- return "";
- (void)GetEnvironmentVariable(lpszEnvVar, var, dwLen);
-
- return var;
-}
diff --git a/sapi/milter/CREDITS b/sapi/milter/CREDITS
deleted file mode 100644
index cd00d6774b..0000000000
--- a/sapi/milter/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-Sendmail Milter
-Harald Radi
diff --git a/sapi/milter/EXPERIMENTAL b/sapi/milter/EXPERIMENTAL
deleted file mode 100644
index 293159a693..0000000000
--- a/sapi/milter/EXPERIMENTAL
+++ /dev/null
@@ -1,5 +0,0 @@
-this module is experimental,
-its functions may change their names
-or move to extension all together
-so do not rely to much on them
-you have been warned!
diff --git a/sapi/milter/Makefile.frag b/sapi/milter/Makefile.frag
deleted file mode 100644
index f193f56b01..0000000000
--- a/sapi/milter/Makefile.frag
+++ /dev/null
@@ -1,8 +0,0 @@
-milter: $(SAPI_MILTER_PATH)
-
-$(SAPI_MILTER_PATH): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_MILTER_OBJS)
- $(BUILD_MILTER)
-
-install-milter: $(SAPI_MILTER_PATH)
- @$(INSTALL) -m 0755 $(SAPI_MILTER_PATH) $(INSTALL_ROOT)$(bindir)/php-milter
-
diff --git a/sapi/milter/TODO b/sapi/milter/TODO
deleted file mode 100644
index 4a427ea131..0000000000
--- a/sapi/milter/TODO
+++ /dev/null
@@ -1,5 +0,0 @@
-threaded version still leaks mem, don't know why
-extensions aren't loaded
-stdout to syslog
-testing
-documentation \ No newline at end of file
diff --git a/sapi/milter/config.m4 b/sapi/milter/config.m4
deleted file mode 100644
index a69ab2e1e7..0000000000
--- a/sapi/milter/config.m4
+++ /dev/null
@@ -1,31 +0,0 @@
-dnl
-dnl $Id$
-dnl
-
-PHP_ARG_WITH(milter, for Milter support,
-[ --with-milter[=DIR] Build PHP as Milter application], no, no)
-
-if test "$PHP_MILTER" != "no"; then
- if test "$PHP_MILTER" = "yes"; then
- if test -f /usr/lib/libmilter.a ; then
- MILTERPATH=/usr/lib
- else
- if test -f /usr/lib/libmilter/libmilter.a ; then
- MILTERPATH=/usr/lib/libmilter
- else
- AC_MSG_ERROR([Unable to find libmilter.a])
- fi
- fi
- else
- MILTERPATH=$PHP_MILTER
- fi
-
- SAPI_MILTER_PATH=sapi/milter/php-milter
- PHP_BUILD_THREAD_SAFE
- PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/sapi/milter/Makefile.frag,$abs_srcdir/sapi/milter,sapi/milter)
- PHP_SELECT_SAPI(milter, program, php_milter.c getopt.c,,'$(SAPI_MILTER_PATH)')
- PHP_ADD_LIBRARY_WITH_PATH(milter, $MILTERPATH,)
- BUILD_MILTER="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_MILTER_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_MILTER_PATH)"
- PHP_SUBST(SAPI_MILTER_PATH)
- PHP_SUBST(BUILD_MILTER)
-fi
diff --git a/sapi/milter/getopt.c b/sapi/milter/getopt.c
deleted file mode 100644
index df2c77f94c..0000000000
--- a/sapi/milter/getopt.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/* Borrowed from Apache NT Port */
-
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <stdlib.h>
-#include "php_getopt.h"
-#define OPTERRCOLON (1)
-#define OPTERRNF (2)
-#define OPTERRARG (3)
-
-
-char *ap_php_optarg;
-int ap_php_optind = 1;
-static int ap_php_opterr = 1;
-
-static int
-ap_php_optiserr(int argc, char * const *argv, int oint, const char *optstr,
- int optchr, int err)
-{
- if (ap_php_opterr)
- {
- fprintf(stderr, "Error in argument %d, char %d: ", oint, optchr+1);
- switch(err)
- {
- case OPTERRCOLON:
- fprintf(stderr, ": in flags\n");
- break;
- case OPTERRNF:
- fprintf(stderr, "option not found %c\n", argv[oint][optchr]);
- break;
- case OPTERRARG:
- fprintf(stderr, "no argument for option %c\n", argv[oint][optchr]);
- break;
- default:
- fprintf(stderr, "unknown\n");
- break;
- }
- }
- return('?');
-}
-
-int ap_php_getopt(int argc, char* const *argv, const char *optstr)
-{
- static int optchr = 0;
- static int dash = 0; /* have already seen the - */
-
- char *cp;
-
- if (ap_php_optind >= argc)
- return(EOF);
- if (!dash && (argv[ap_php_optind][0] != '-'))
- return(EOF);
- if (!dash && (argv[ap_php_optind][0] == '-') && !argv[ap_php_optind][1])
- {
- /*
- * use to specify stdin. Need to let pgm process this and
- * the following args
- */
- return(EOF);
- }
- if ((argv[ap_php_optind][0] == '-') && (argv[ap_php_optind][1] == '-'))
- {
- /* -- indicates end of args */
- ap_php_optind++;
- return(EOF);
- }
- if (!dash)
- {
- assert((argv[ap_php_optind][0] == '-') && argv[ap_php_optind][1]);
- dash = 1;
- optchr = 1;
- }
-
- /* Check if the guy tries to do a -: kind of flag */
- assert(dash);
- if (argv[ap_php_optind][optchr] == ':')
- {
- dash = 0;
- ap_php_optind++;
- return(ap_php_optiserr(argc, argv, ap_php_optind-1, optstr, optchr, OPTERRCOLON));
- }
- if (!(cp = strchr(optstr, argv[ap_php_optind][optchr])))
- {
- int errind = ap_php_optind;
- int errchr = optchr;
-
- if (!argv[ap_php_optind][optchr+1])
- {
- dash = 0;
- ap_php_optind++;
- }
- else
- optchr++;
- return(ap_php_optiserr(argc, argv, errind, optstr, errchr, OPTERRNF));
- }
- if (cp[1] == ':')
- {
- /* Check for cases where the value of the argument
- is in the form -<arg> <val> or in the form -<arg><val> */
- dash = 0;
- if(!argv[ap_php_optind][2]) {
- ap_php_optind++;
- if (ap_php_optind == argc)
- return(ap_php_optiserr(argc, argv, ap_php_optind-1, optstr, optchr, OPTERRARG));
- ap_php_optarg = argv[ap_php_optind++];
- }
- else
- {
- ap_php_optarg = &argv[ap_php_optind][2];
- ap_php_optind++;
- }
- return(*cp);
- }
- else
- {
- if (!argv[ap_php_optind][optchr+1])
- {
- dash = 0;
- ap_php_optind++;
- }
- else
- optchr++;
- return(*cp);
- }
- assert(0);
- return(0); /* never reached */
-}
-
-#ifdef TESTGETOPT
-int
- main (int argc, char **argv)
- {
- int c;
- extern char *ap_php_optarg;
- extern int ap_php_optind;
- int aflg = 0;
- int bflg = 0;
- int errflg = 0;
- char *ofile = NULL;
-
- while ((c = ap_php_getopt(argc, argv, "abo:")) != EOF)
- switch (c) {
- case 'a':
- if (bflg)
- errflg++;
- else
- aflg++;
- break;
- case 'b':
- if (aflg)
- errflg++;
- else
- bflg++;
- break;
- case 'o':
- ofile = ap_php_optarg;
- (void)printf("ofile = %s\n", ofile);
- break;
- case '?':
- errflg++;
- }
- if (errflg) {
- (void)fprintf(stderr,
- "usage: cmd [-a|-b] [-o <filename>] files...\n");
- exit (2);
- }
- for ( ; ap_php_optind < argc; ap_php_optind++)
- (void)printf("%s\n", argv[ap_php_optind]);
- return 0;
- }
-
-#endif /* TESTGETOPT */
diff --git a/sapi/milter/milter.php b/sapi/milter/milter.php
deleted file mode 100644
index 0878f2a4d9..0000000000
--- a/sapi/milter/milter.php
+++ /dev/null
@@ -1,132 +0,0 @@
-<?php
-/**
- * example milter script
- *
- * run: php-milter -D -p /path/to/sock milter.php
- *
- * for details on how to set up sendmail and configure the milter see
- * http://www.sendmail.com/partner/resources/development/milter_api/
- *
- * for api details see
- * http://www.sendmail.com/partner/resources/development/milter_api/api.html
- *
- * below is a list of all callbacks, that are available through the milter sapi,
- * if you leave one or more out they simply won't get called (e.g. if you secify an
- * empty php file, the milter would do nothing :)
- */
-
-/**
- * this function is called once on sapi startup,
- * here you can specify the actions the filter may take
- *
- * see http://www.sendmail.com/partner/resources/development/milter_api/smfi_register.html#flags
- */
-
-function milter_log($msg)
-{
- $GLOBALS['log'] = fopen("/tmp/milter.log", "a");
- fwrite($GLOBALS['log'], date("[H:i:s d.m.Y]") . "\t{$msg}\n");
- fclose($GLOBALS['log']);
-}
-
-function milter_init() {
- milter_log("-- startup --");
- milter_log("milter_init()");
- smfi_setflags(SMFIF_ADDHDRS);
-}
-
-/**
- * is called once, at the start of each SMTP connection
- */
-function milter_connect($connect)
-{
- milter_log("milter_connect('$connect')");
-}
-
-/**
- * is called whenever the client sends a HELO/EHLO command.
- * It may therefore be called between zero and three times.
- */
-function milter_helo($helo)
-{
- milter_log("milter_helo('$helo')");
-}
-
-/**
- * is called once at the beginning of each message,
- * before milter_envrcpt.
- */
-function milter_envfrom($args)
-{
- milter_log("milter_envfrom(args[])");
- foreach ($args as $ix => $arg) {
- milter_log("\targs[$ix] = $arg");
- }
-}
-
-/**
- * is called once per recipient, hence one or more times per message,
- * immediately after milter_envfrom
- */
-function milter_envrcpt($args)
-{
- milter_log("milter_envrcpt(args[])");
- foreach ($args as $ix => $arg) {
- milter_log("\targs[$ix] = $arg");
- }
-}
-
-/**
- * is called zero or more times between milter_envrcpt and milter_eoh,
- * once per message header
- */
-function milter_header($header, $value)
-{
- milter_log("milter_header('$header', '$value')");
-}
-
-/**
- * is called once after all headers have been sent and processed.
- */
-function milter_eoh()
-{
- milter_log("milter_eoh()");
-}
-
-/**
- * is called zero or more times between milter_eoh and milter_eom.
- */
-function milter_body($bodypart)
-{
- milter_log("milter_body('$bodypart')");
-}
-
-/**
- * is called once after all calls to milter_body for a given message.
- * most of the api functions, that alter the message can only be called
- * within this callback.
- */
-function milter_eom()
-{
- milter_log("milter_eom()");
- /* add PHP header to the message */
- smfi_addheader("X-PHP", phpversion());
-}
-
-/**
- * may be called at any time during message processing
- * (i.e. between some message-oriented routine and milter_eom).
- */
-function milter_abort()
-{
- milter_log("milter_abort()");
-}
-
-/**
- * is always called once at the end of each connection.
- */
-function milter_close()
-{
- milter_log("milter_close()");
-}
-?>
diff --git a/sapi/milter/php_getopt.h b/sapi/milter/php_getopt.h
deleted file mode 100644
index 40da432b59..0000000000
--- a/sapi/milter/php_getopt.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Borrowed from Apache NT Port */
-#include "php.h"
-
-extern char *ap_php_optarg;
-extern int ap_php_optind;
-
-int ap_php_getopt(int argc, char* const *argv, const char *optstr);
diff --git a/sapi/milter/php_milter.c b/sapi/milter/php_milter.c
deleted file mode 100644
index 73a0667326..0000000000
--- a/sapi/milter/php_milter.c
+++ /dev/null
@@ -1,1196 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.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: Harald Radi <phanto@php.net> |
- | Parts based on CGI SAPI Module by |
- | Rasmus Lerdorf, Stig Bakken and Zeev Suraski |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#include "php.h"
-#include "php_globals.h"
-#include "php_variables.h"
-#include "zend_modules.h"
-
-#ifndef ZTS
-#error SRM sapi module is only useable in thread-safe mode
-#endif
-
-#include "SAPI.h"
-
-#include <stdio.h>
-#include "php.h"
-#if HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#if HAVE_SIGNAL_H
-#include <signal.h>
-#endif
-#if HAVE_SETLOCALE
-#include <locale.h>
-#endif
-#include "zend.h"
-#include "zend_extensions.h"
-#include "php_ini.h"
-#include "php_globals.h"
-#include "php_main.h"
-#include "fopen_wrappers.h"
-#include "ext/standard/php_standard.h"
-
-#ifdef __riscos__
-#include <unixlib/local.h>
-#endif
-
-#include "zend_compile.h"
-#include "zend_execute.h"
-#include "zend_highlight.h"
-#include "zend_indent.h"
-
-#include "libmilter/mfapi.h"
-
-#include "php_getopt.h"
-
-#define OPTSTRING "ac:d:Def:hnp:vVz:?"
-#define MG(v) TSRMG(milter_globals_id, zend_milter_globals *, v)
-
-#define IS_NONE "%s(): This function must not be called outside of a milter callback function's scope"
-#define NOT_EOM "%s(): This function can only be used inside the milter_eom callback's scope"
-#define NOT_INIT "%s(): This function can only be used inside the milter_init callback's scope"
-
-#define MLFI_NONE 0
-#define MLFI_CONNECT 1
-#define MLFI_HELO 2
-#define MLFI_ENVFROM 3
-#define MLFI_ENVRCPT 4
-#define MLFI_HEADER 5
-#define MLFI_EOH 6
-#define MLFI_BODY 7
-#define MLFI_EOM 8
-#define MLFI_ABORT 9
-#define MLFI_CLOSE 10
-#define MLFI_INIT 11
-
-/* {{{ globals
- */
-extern char *ap_php_optarg;
-extern int ap_php_optind;
-
-static int flag_debug=0;
-static char *filename = NULL;
-
-/* per thread */
-ZEND_BEGIN_MODULE_GLOBALS(milter)
- SMFICTX *ctx;
- int state;
- int initialized;
-ZEND_END_MODULE_GLOBALS(milter)
-
-ZEND_DECLARE_MODULE_GLOBALS(milter)
-/* }}} */
-
-/* this method is called only once when the milter starts */
-/* {{{ Init Milter
-*/
-static int mlfi_init()
-{
- int ret = 0;
- zend_file_handle file_handle;
- zval function_name, retval;
- int status;
-
- /* request startup */
- if (php_request_startup()==FAILURE) {
- SG(headers_sent) = 1;
- SG(request_info).no_headers = 1;
- php_request_shutdown((void *) 0);
-
- return -1;
- }
-
- /* disable headers */
- SG(headers_sent) = 1;
- SG(request_info).no_headers = 1;
-
- if (filename == NULL) {
- php_printf("No input file specified");
- return SMFIS_TEMPFAIL;
- }
-
- if (!(file_handle.handle.fp = VCWD_FOPEN(filename, "rb"))) {
- php_printf("Could not open input file: %s\n", filename);
- return SMFIS_TEMPFAIL;
- }
-
- file_handle.type = ZEND_HANDLE_FP;
- file_handle.filename = filename;
- file_handle.free_filename = 0;
- file_handle.opened_path = NULL;
-
- php_execute_script(&file_handle);
-
- /* call userland */
- INIT_ZVAL(function_name);
-
- ZVAL_STRING(&function_name, "milter_init", 0);
-
- /* set the milter context for possible use in API functions */
- MG(state) = MLFI_INIT;
-
- status = call_user_function(CG(function_table), NULL, &function_name, &retval, 0, NULL);
-
- MG(state) = MLFI_NONE;
- MG(initialized) = 1;
-
- if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
- ret = Z_LVAL(retval);
- }
-
- php_request_shutdown((void *) 0);
-
- return ret;
-}
-/* }}} */
-
-/* {{{ Milter callback functions
- */
-
-/* connection info filter, is called whenever sendmail connects to the milter */
-/* {{{ mlfi_connect()
-*/
-static sfsistat mlfi_connect(SMFICTX *ctx, char *hostname, _SOCK_ADDR *hostaddr)
-{
- zend_file_handle file_handle;
- zval function_name, retval, *param[1];
- int status;
-
- /* request startup */
- if (php_request_startup()==FAILURE) {
- SG(headers_sent) = 1;
- SG(request_info).no_headers = 1;
- php_request_shutdown((void *) 0);
-
- return SMFIS_TEMPFAIL;
- }
-
- /* disable headers */
- SG(headers_sent) = 1;
- SG(request_info).no_headers = 1;
-
- if (filename == NULL) {
- php_printf("No input file specified");
- return SMFIS_TEMPFAIL;
- }
-
- if (!(file_handle.handle.fp = VCWD_FOPEN(filename, "rb"))) {
- php_printf("Could not open input file: %s\n", filename);
- return SMFIS_TEMPFAIL;
- }
-
- file_handle.type = ZEND_HANDLE_FP;
- file_handle.filename = filename;
- file_handle.free_filename = 0;
- file_handle.opened_path = NULL;
-
- php_execute_script(&file_handle);
-
- /* call userland */
- INIT_ZVAL(function_name);
-
- ALLOC_ZVAL(param[0]);
- INIT_PZVAL(param[0]);
-
- ZVAL_STRING(&function_name, "milter_connect", 0);
- ZVAL_STRING(param[0], hostname, 1);
-
- /* set the milter context for possible use in API functions */
- MG(ctx) = ctx;
- MG(state) = MLFI_CONNECT;
-
- status = call_user_function(CG(function_table), NULL, &function_name, &retval, 1, param);
-
- MG(state) = MLFI_NONE;
- zval_ptr_dtor(param);
- if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
- return Z_LVAL(retval);
- }
-
- return SMFIS_CONTINUE;
-}
-/* }}} */
-
-/* SMTP HELO command filter */
-/* {{{ mlfi_helo()
-*/
-static sfsistat mlfi_helo(SMFICTX *ctx, char *helohost)
-{
- zval function_name, retval, *param[1];
- int status;
-
- /* call userland */
- INIT_ZVAL(function_name);
-
- ALLOC_ZVAL(param[0]);
- INIT_PZVAL(param[0]);
-
- ZVAL_STRING(&function_name, "milter_helo", 0);
- ZVAL_STRING(param[0], helohost, 1);
-
- /* set the milter context for possible use in API functions */
- MG(ctx) = ctx;
- MG(state) = MLFI_HELO;
-
- status = call_user_function(CG(function_table), NULL, &function_name, &retval, 1, param);
-
- MG(state) = MLFI_NONE;
- zval_ptr_dtor(param);
-
- if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
- return Z_LVAL(retval);
- }
-
- return SMFIS_CONTINUE;
-}
-/* }}} */
-
-/* envelope sender filter */
-/* {{{ mlfi_envform()
-*/
-static sfsistat mlfi_envfrom(SMFICTX *ctx, char **argv)
-{
- zval function_name, retval, *param[1];
- int status;
-
- /* call userland */
- INIT_ZVAL(function_name);
-
- ALLOC_ZVAL(param[0]);
- INIT_PZVAL(param[0]);
-
- ZVAL_STRING(&function_name, "milter_envfrom", 0);
- array_init(param[0]);
-
- while (*argv) {
- add_next_index_string(param[0], *argv);
- argv++;
- }
-
- /* set the milter context for possible use in API functions */
- MG(ctx) = ctx;
- MG(state) = MLFI_ENVFROM;
-
- status = call_user_function(CG(function_table), NULL, &function_name, &retval, 1, param);
-
- MG(state) = MLFI_NONE;
- zval_ptr_dtor(param);
-
- if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
- return Z_LVAL(retval);
- }
-
- return SMFIS_CONTINUE;
-}
-/* }}} */
-
-/* envelope recipient filter */
-/* {{{ mlfi_envrcpt()
-*/
-static sfsistat mlfi_envrcpt(SMFICTX *ctx, char **argv)
-{
- zval function_name, retval, *param[1];
- int status;
-
- /* call userland */
- INIT_ZVAL(function_name);
-
- ALLOC_ZVAL(param[0]);
- INIT_PZVAL(param[0]);
-
- ZVAL_STRING(&function_name, "milter_envrcpt", 0);
- array_init(param[0]);
-
- while (*argv) {
- add_next_index_string(param[0], *argv);
- argv++;
- }
-
- /* set the milter context for possible use in API functions */
- MG(ctx) = ctx;
- MG(state) = MLFI_ENVRCPT;
-
- status = call_user_function(CG(function_table), NULL, &function_name, &retval, 1, param);
-
- MG(state) = MLFI_NONE;
-
- zval_ptr_dtor(param);
-
- if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
- return Z_LVAL(retval);
- }
-
- return SMFIS_CONTINUE;
-}
-/* }}} */
-
-/* header filter */
-/* {{{ mlfi_header()
-*/
-static sfsistat mlfi_header(SMFICTX *ctx, char *headerf, char *headerv)
-{
- zval function_name, retval, *param[2];
- int status;
-
- /* call userland */
- INIT_ZVAL(function_name);
-
- ALLOC_ZVAL(param[0]);
- ALLOC_ZVAL(param[1]);
- INIT_PZVAL(param[0]);
- INIT_PZVAL(param[1]);
-
- ZVAL_STRING(&function_name, "milter_header", 0);
- ZVAL_STRING(param[0], headerf, 1);
- ZVAL_STRING(param[1], headerv, 1);
-
- /* set the milter context for possible use in API functions */
- MG(ctx) = ctx;
- MG(state) = MLFI_HEADER;
-
- status = call_user_function(CG(function_table), NULL, &function_name, &retval, 2, param);
-
- MG(state) = MLFI_NONE;
-
- zval_ptr_dtor(&param[0]);
- zval_ptr_dtor(&param[1]);
-
- if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
- return Z_LVAL(retval);
- }
-
- return SMFIS_CONTINUE;
-}
-/* }}} */
-
-/* end of header */
-/* {{{ mlfi_eoh()
-*/
-static sfsistat mlfi_eoh(SMFICTX *ctx)
-{
- zval function_name, retval;
- int status;
-
- /* call userland */
- INIT_ZVAL(function_name);
- ZVAL_STRING(&function_name, "milter_eoh", 0);
-
- /* set the milter context for possible use in API functions */
- MG(ctx) = ctx;
- MG(state) = MLFI_EOH;
-
- status = call_user_function(CG(function_table), NULL, &function_name, &retval, 0, NULL);
-
- MG(state) = MLFI_NONE;
-
- if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
- return Z_LVAL(retval);
- }
-
- return SMFIS_CONTINUE;
-}
-/* }}} */
-
-/* body block */
-/* {{{ mlfi_body()
-*/
-static sfsistat mlfi_body(SMFICTX *ctx, u_char *bodyp, size_t len)
-{
- zval function_name, retval, *param[1];
- int status;
-
- /* call userland */
- INIT_ZVAL(function_name);
-
- ALLOC_ZVAL(param[0]);
- INIT_PZVAL(param[0]);
-
- ZVAL_STRING(&function_name, "milter_body", 0);
- ZVAL_STRINGL(param[0], (char*)bodyp, len, 1); /*alex*/
-
- /* set the milter context for possible use in API functions */
- MG(ctx) = ctx;
- MG(state) = MLFI_BODY;
-
- status = call_user_function(CG(function_table), NULL, &function_name, &retval, 1, param);
-
- MG(state) = MLFI_NONE;
-
- zval_ptr_dtor(param);
-
- if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
- return Z_LVAL(retval);
- }
-
- return SMFIS_CONTINUE;
-}
-/* }}} */
-
-/* end of message */
-/* {{{ mlfi_eom()
-*/
-static sfsistat mlfi_eom(SMFICTX *ctx)
-{
- zval function_name, retval;
- int status;
-
- /* call userland */
- INIT_ZVAL(function_name);
- ZVAL_STRING(&function_name, "milter_eom", 0);
-
- /* set the milter context for possible use in API functions */
- MG(ctx) = ctx;
- MG(state) = MLFI_EOM;
-
- status = call_user_function(CG(function_table), NULL, &function_name, &retval, 0, NULL);
-
- MG(state) = MLFI_NONE;
-
- if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
- return Z_LVAL(retval);
- }
-
- return SMFIS_CONTINUE;
-}
-/* }}} */
-
-/* message aborted */
-/* {{{ mlfi_abort()
-*/
-static sfsistat mlfi_abort(SMFICTX *ctx)
-{
- zval function_name, retval;
- int status;
-
- /* call userland */
- INIT_ZVAL(function_name);
- ZVAL_STRING(&function_name, "milter_abort", 0);
-
- /* set the milter context for possible use in API functions */
- MG(ctx) = ctx;
- MG(state) = MLFI_ABORT;
-
- status = call_user_function(CG(function_table), NULL, &function_name, &retval, 0, NULL);
-
- MG(state) = MLFI_NONE;
-
- if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
- return Z_LVAL(retval);
- }
-
- return SMFIS_CONTINUE;
-}
-/* }}} */
-
-/* connection cleanup */
-/* {{{ mlfi_close()
-*/
-static sfsistat mlfi_close(SMFICTX *ctx)
-{
- int ret = SMFIS_CONTINUE;
- zval function_name, retval;
- int status;
-
- if (!SG(sapi_started) && SUCCESS != php_request_startup()) {
- return ret;
- }
-
- /* call userland */
- INIT_ZVAL(function_name);
- ZVAL_STRING(&function_name, "milter_close", 0);
-
- /* set the milter context for possible use in API functions */
- MG(ctx) = ctx;
- MG(state) = MLFI_CLOSE;
-
- status = call_user_function(CG(function_table), NULL, &function_name, &retval, 0, NULL);
-
- MG(state) = MLFI_NONE;
-
- if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
- ret = Z_LVAL(retval);
- }
-
- php_request_shutdown((void *) 0);
-
- return ret;
-}
-/* }}} */
-/* }}} */
-
-/* {{{ Milter entry struct
- */
-static struct smfiDesc smfilter = {
- "php-milter", /* filter name */
- SMFI_VERSION, /* version code -- leave untouched */
- 0, /* flags */
- mlfi_connect, /* info filter callback */
- mlfi_helo, /* HELO filter callback */
- mlfi_envfrom, /* envelope filter callback */
- mlfi_envrcpt, /* envelope recipient filter callback */
- mlfi_header, /* header filter callback */
- mlfi_eoh, /* end of header callback */
- mlfi_body, /* body filter callback */
- mlfi_eom, /* end of message callback */
- mlfi_abort, /* message aborted callback */
- mlfi_close, /* connection cleanup callback */
-};
-/* }}} */
-
-/* {{{ PHP Milter API
- */
-
-/* {{{ proto void smfi_setflags(long flags)
- Sets the flags describing the actions the filter may take. */
-PHP_FUNCTION(smfi_setflags)
-{
- long flags;
-
- /* valid only in the init callback */
- if (MG(state) != MLFI_INIT) {
- php_error(E_WARNING, NOT_INIT, get_active_function_name());
- } else if (zend_parse_parameters(1, "l", &flags) == SUCCESS) {
- flags = flags & (SMFIF_ADDHDRS|SMFIF_CHGHDRS|SMFIF_CHGBODY|SMFIF_ADDRCPT|SMFIF_DELRCPT);
- smfilter.xxfi_flags = flags;
- }
-}
-/* }}} */
-
-/* {{{ proto void smfi_settimeout(long timeout)
- Sets the number of seconds libmilter will wait for an MTA connection before timing out a socket. */
-PHP_FUNCTION(smfi_settimeout)
-{
- long timeout;
-
- /* valid only in the init callback */
- if (MG(state) != MLFI_INIT) {
- php_error(E_WARNING, NOT_INIT, get_active_function_name());
- } else if (zend_parse_parameters(1, "l", &timeout) == SUCCESS) {
- smfi_settimeout(timeout);
- }
-}
-/* }}} */
-
-/* {{{ proto string smfi_getsymval(string macro)
- Returns the value of the given macro or NULL if the macro is not defined. */
-PHP_FUNCTION(smfi_getsymval)
-{
- char *symname, *ret;
- int len;
-
- /* valid in any callback */
- if (MG(state) == MLFI_NONE) {
- php_error(E_WARNING, IS_NONE, get_active_function_name());
- } else if (zend_parse_parameters(1, "s", &symname, &len) == SUCCESS) {
- if ((ret = smfi_getsymval(MG(ctx), symname)) != NULL) {
- RETURN_STRING(ret, 1);
- }
- }
-
- RETURN_NULL();
-}
-/* }}} */
-
-/* {{{ proto bool smfi_setreply(string rcode, string xcode, string message)
- Directly set the SMTP error reply code for this connection.
- This code will be used on subsequent error replies resulting from actions taken by this filter. */
-PHP_FUNCTION(smfi_setreply)
-{
- char *rcode, *xcode, *message;
- int len;
-
- /* valid in any callback */
- if (MG(state) == MLFI_NONE) {
- php_error(E_WARNING, IS_NONE, get_active_function_name());
- } else if (zend_parse_parameters(3, "sss", &rcode, &len, &xcode, &len, &message, &len) == SUCCESS) {
- if (smfi_setreply(MG(ctx), rcode, xcode, message) == MI_SUCCESS) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto bool smfi_addheader(string headerf, string headerv)
- Adds a header to the current message. */
-PHP_FUNCTION(smfi_addheader)
-{
- char *f, *v;
- int len;
-
- /* valid only in milter_eom */
- if (MG(state) != MLFI_EOM) {
- php_error(E_WARNING, NOT_EOM, get_active_function_name());
- } else if (zend_parse_parameters(2, "ss", &f, &len, &v, &len) == SUCCESS) {
- if (smfi_addheader(MG(ctx), f, v) == MI_SUCCESS) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto bool smfi_chgheader(string headerf, string headerv)
- Changes a header's value for the current message. */
-PHP_FUNCTION(smfi_chgheader)
-{
- char *f, *v;
- long idx;
- int len;
-
- /* valid only in milter_eom */
- if (MG(state) != MLFI_EOM) {
- php_error(E_WARNING, NOT_EOM, get_active_function_name());
- } else if (zend_parse_parameters(3, "sls", &f, &len, &idx, &v, &len) == SUCCESS) {
- if (smfi_chgheader(MG(ctx), f, idx, v) == MI_SUCCESS) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto bool smfi_addrcpt(string rcpt)
- Add a recipient to the message envelope. */
-PHP_FUNCTION(smfi_addrcpt)
-{
- char *rcpt;
- int len;
-
- /* valid only in milter_eom */
- if (MG(state) != MLFI_EOM) {
- php_error(E_WARNING, NOT_EOM, get_active_function_name());
- } else if (zend_parse_parameters(1, "s", &rcpt, &len) == SUCCESS) {
- if (smfi_addrcpt(MG(ctx), rcpt) == MI_SUCCESS) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto bool smfi_delrcpt(string rcpt)
- Removes the named recipient from the current message's envelope. */
-PHP_FUNCTION(smfi_delrcpt)
-{
- char *rcpt;
- int len;
-
- /* valid only in milter_eom */
- if (MG(state) != MLFI_EOM) {
- php_error(E_WARNING, NOT_EOM, get_active_function_name());
- } else if (zend_parse_parameters(1, "s", &rcpt, &len) == SUCCESS) {
- if (smfi_delrcpt(MG(ctx), rcpt) == MI_SUCCESS) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto bool smfi_replacebody(string body)
- Replaces the body of the current message. If called more than once,
- subsequent calls result in data being appended to the new body. */
-PHP_FUNCTION(smfi_replacebody)
-{
- char *body;
- int len;
-
- /* valid only in milter_eom */
- if (MG(state) != MLFI_EOM) {
- php_error(E_WARNING, NOT_EOM, get_active_function_name());
- } else if (zend_parse_parameters(1, "s", &body, &len) == SUCCESS) {
- if (smfi_replacebody(MG(ctx), (u_char*)body, len) == MI_SUCCESS) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ PHP_MINIT_FUNCTION
- */
-PHP_MINIT_FUNCTION(milter)
-{
- REGISTER_LONG_CONSTANT("SMFIS_CONTINUE", SMFIS_CONTINUE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SMFIS_REJECT", SMFIS_REJECT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SMFIS_DISCARD", SMFIS_DISCARD, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SMFIS_ACCEPT", SMFIS_ACCEPT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SMFIS_TEMPFAIL", SMFIS_TEMPFAIL, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("SMFIF_ADDHDRS", SMFIF_ADDHDRS, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SMFIF_CHGHDRS", SMFIF_CHGHDRS, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SMFIF_CHGBODY", SMFIF_CHGBODY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SMFIF_ADDRCPT", SMFIF_ADDRCPT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SMFIF_DELRCPT", SMFIF_DELRCPT, CONST_CS | CONST_PERSISTENT);
-
- ZEND_INIT_MODULE_GLOBALS(milter, NULL, NULL);
-
- MG(state) = MLFI_NONE;
- MG(initialized) = 0;
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ PHP_MINFO_FUNCTION
- */
-PHP_MINFO_FUNCTION(milter)
-{
- php_info_print_table_start();
- php_info_print_table_header(2, "Milter support", "enabled");
- php_info_print_table_end();
-}
-/* }}} */
-/* }}} */
-
-/* {{{ arginfo */
-ZEND_BEGIN_ARG_INFO_EX(arginfo_smfi_setflags, 0, 0, 1)
- ZEND_ARG_INFO(0, flags)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_smfi_settimeout, 0, 0, 1)
- ZEND_ARG_INFO(0, timeout)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_smfi_getsymval, 0, 0, 1)
- ZEND_ARG_INFO(0, macro)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_smfi_setreply, 0, 0, 3)
- ZEND_ARG_INFO(0, rcode)
- ZEND_ARG_INFO(0, xcode)
- ZEND_ARG_INFO(0, message)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_smfi_addheader, 0, 0, 2)
- ZEND_ARG_INFO(0, headerf)
- ZEND_ARG_INFO(0, headerv)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_smfi_chgheader, 0, 0, 2)
- ZEND_ARG_INFO(0, headerf)
- ZEND_ARG_INFO(0, headerv)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_smfi_addrcpt, 0, 0, 1)
- ZEND_ARG_INFO(0, rcpt)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_smfi_delrcpt, 0, 0, 1)
- ZEND_ARG_INFO(0, rcpt)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_smfi_replacebody, 0, 0, 1)
- ZEND_ARG_INFO(0, body)
-ZEND_END_ARG_INFO()
-/* }}} */
-
-/* {{{ milter_functions[]
-*/
-const static zend_function_entry milter_functions[] = {
- PHP_FE(smfi_setflags, arginfo_smfi_setflags)
- PHP_FE(smfi_settimeout, arginfo_smfi_settimeout)
- PHP_FE(smfi_getsymval, arginfo_smfi_getsymval)
- PHP_FE(smfi_setreply, arginfo_smfi_setreply)
- PHP_FE(smfi_addheader, arginfo_smfi_addheader)
- PHP_FE(smfi_chgheader, arginfo_smfi_chgheader)
- PHP_FE(smfi_addrcpt, arginfo_smfi_addrcpt)
- PHP_FE(smfi_delrcpt, arginfo_smfi_delrcpt)
- PHP_FE(smfi_replacebody, arginfo_smfi_replacebody)
- PHP_FE_END
-};
-/* }}} */
-
-/* {{{ Zend module entry
-*/
-static zend_module_entry php_milter_module = {
- STANDARD_MODULE_HEADER,
- "Milter",
- milter_functions,
- PHP_MINIT(milter),
- NULL,
- NULL,
- NULL,
- PHP_MINFO(milter),
- "0.1.0",
- STANDARD_MODULE_PROPERTIES
-};
-/* }}} */
-
-/* {{{ Milter SAPI
-*/
-static int sapi_milter_ub_write(const char *str, uint str_length)
-{
- return str_length;
-}
-
-static void sapi_milter_register_variables(zval *track_vars_array)
-{
- php_register_variable ("SERVER_SOFTWARE", "Sendmail Milter", track_vars_array);
-}
-
-static int sapi_milter_post_read(char *buf, uint count_bytes)
-{
- return 0;
-}
-
-static char* sapi_milter_read_cookies(void)
-{
- return NULL;
-}
-
-static int sapi_milter_send_headers(sapi_headers_struct *sapi_headers)
-{
- return SAPI_HEADER_SENT_SUCCESSFULLY;
-}
-
-static int php_milter_startup(sapi_module_struct *sapi_module)
-{
- if (php_module_startup(sapi_module, &php_milter_module, 1) == FAILURE) {
- return FAILURE;
- }
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ sapi_module_struct milter_sapi_module
-*/
-static sapi_module_struct milter_sapi_module = {
- "milter", /* name */
- "Sendmail Milter SAPI", /* pretty name */
-
- php_milter_startup, /* startup */
- php_module_shutdown_wrapper, /* shutdown */
-
- NULL, /* activate */
- NULL, /* deactivate */
-
- sapi_milter_ub_write, /* unbuffered write */
- NULL, /* flush */
- NULL, /* get uid */
- NULL, /* getenv */
-
- php_error, /* error handler */
-
- NULL, /* header handler */
- sapi_milter_send_headers, /* send headers handler */
- NULL, /* send header handler */
-
- sapi_milter_post_read, /* read POST data */
- sapi_milter_read_cookies, /* read Cookies */
-
- sapi_milter_register_variables, /* register server variables */
- NULL, /* Log message */
- NULL, /* Get request time */
- NULL, /* Child terminate */
-
- NULL, /* Block interruptions */
- NULL, /* Unblock interruptions */
-
- STANDARD_SAPI_MODULE_PROPERTIES
-};
-/* }}} */
-
-/****
-* ripped from cli, has to be cleaned up !
-*/
-
-/* {{{ php_milter_usage
-*/
-static void php_milter_usage(char *argv0)
-{
- char *prog;
-
- prog = strrchr(argv0, '/');
- if (prog) {
- prog++;
- } else {
- prog = "php-milter";
- }
-
- printf( "Usage: %s [options] [-f] <file> [args...]\n"
- " %s [options] [-- args...]\n"
- " -a Run interactively\n"
- " -c <path>|<file> Look for php.ini file in this directory\n"
- " -n No php.ini file will be used\n"
- " -d foo[=bar] Define INI entry foo with value 'bar'\n"
- " -D run as daemon\n"
- " -e Generate extended information for debugger/profiler\n"
- " -f <file> Parse <file>.\n"
- " -h This help\n"
- " -p <socket> path to create socket\n"
- " -v Version number\n"
- " -V <n> set debug level to n (1 or 2).\n"
- " -z <file> Load Zend extension <file>.\n"
- " args... Arguments passed to script. Use -- args when first argument \n"
- " starts with - or script is read from stdin\n"
- , prog, prog);
-}
-/* }}} */
-
-static void define_command_line_ini_entry(char *arg) /* {{{ */
-{
- char *name, *value;
-
- name = arg;
- value = strchr(arg, '=');
- if (value) {
- *value = 0;
- value++;
- } else {
- value = "1";
- }
- zend_alter_ini_entry(name, strlen(name)+1, value, strlen(value), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
-}
-/* }}} */
-
-/* {{{ main
-*/
-int main(int argc, char *argv[])
-{
- char *sock = NULL;
- int dofork = 0;
-
- int exit_status = SUCCESS;
- int c;
-/* temporary locals */
- int orig_optind=ap_php_optind;
- char *orig_optarg=ap_php_optarg;
- int interactive=0;
- char *param_error=NULL;
-/* end of temporary locals */
-
- void ***tsrm_ls;
-
-#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
-
-
- tsrm_startup(1, 1, 0, NULL);
- tsrm_ls = ts_resource(0);
- sapi_startup(&milter_sapi_module);
-
- while ((c=ap_php_getopt(argc, argv, OPTSTRING))!=-1) {
- switch (c) {
- case 'c':
- milter_sapi_module.php_ini_path_override = strdup(ap_php_optarg);
- break;
- case 'n':
- milter_sapi_module.php_ini_ignore = 1;
- break;
- }
- }
- ap_php_optind = orig_optind;
- ap_php_optarg = orig_optarg;
-
- milter_sapi_module.executable_location = argv[0];
-
-
- sapi_module.startup(&milter_sapi_module);
-
- zend_first_try {
- while ((c=ap_php_getopt(argc, argv, OPTSTRING))!=-1) {
- switch (c) {
- case '?':
- php_output_tearup();
- SG(headers_sent) = 1;
- php_milter_usage(argv[0]);
- php_output_teardown();
- exit(1);
- break;
- }
- }
- ap_php_optind = orig_optind;
- ap_php_optarg = orig_optarg;
-
- /* Set some CLI defaults */
- SG(options) |= SAPI_OPTION_NO_CHDIR;
- zend_alter_ini_entry("html_errors", 12, "0", 1, PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
- zend_alter_ini_entry("max_execution_time", 19, "0", 1, PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
-
- zend_uv.html_errors = 0; /* tell the engine we're in non-html mode */
-
- while ((c = ap_php_getopt(argc, argv, OPTSTRING)) != -1) {
- switch (c) {
-
- case 'a': /* interactive mode */
- printf("Interactive mode enabled\n\n");
- interactive=1;
- break;
-
- case 'C': /* don't chdir to the script directory */
- /* This is default so NOP */
- break;
- case 'd': /* define ini entries on command line */
- define_command_line_ini_entry(ap_php_optarg);
- break;
-
- case 'D': /* daemon */
- dofork = 1;
- break;
-
- case 'e': /* enable extended info output */
- CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO;
- break;
-
- case 'f': /* parse file */
- filename = ap_php_optarg;
- break;
-
- case 'h': /* help & quit */
- case '?':
- php_output_tearup();
- SG(headers_sent) = 1;
- php_milter_usage(argv[0]);
- php_output_teardown();
- exit(1);
- break;
-
- case 'p': /* socket */
- sock = strdup(ap_php_optarg);
- break;
-
- case 'v': /* show php version & quit */
- if (php_request_startup()==FAILURE) {
- zend_ini_deactivate();
- php_module_shutdown();
- sapi_shutdown();
- tsrm_shutdown();
-
- exit(1);
- }
- SG(headers_sent) = 1;
- SG(request_info).no_headers = 1;
- php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2015 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
- php_output_teardown();
- exit(1);
- break;
-
- case 'V': /* verbose */
- flag_debug = atoi(ap_php_optarg);
- break;
-
- case 'z': /* load extension file */
- zend_load_extension(ap_php_optarg);
- break;
-
- default:
- break;
- }
- }
-
- if (param_error) {
- SG(headers_sent) = 1;
- SG(request_info).no_headers = 1;
- PUTS(param_error);
- exit(1);
- }
-
- /* only set script_file if not set already and not in direct mode and not at end of parameter list */
- if (argc > ap_php_optind && !filename) {
- filename=argv[ap_php_optind];
- ap_php_optind++;
- }
-
- /* check if file exists, exit else */
-
- if (dofork) {
- switch(fork()) {
- case -1: /* Uh-oh, we have a problem forking. */
- fprintf(stderr, "Uh-oh, couldn't fork!\n");
- exit(errno);
- break;
- case 0: /* Child */
- break;
- default: /* Parent */
- exit(0);
- }
- }
-
- if (sock) {
- struct stat junk;
- if (stat(sock,&junk) == 0) unlink(sock);
- }
-
- openlog("php-milter", LOG_PID, LOG_MAIL);
-
- if ((exit_status = mlfi_init())) {
- syslog(1, "mlfi_init failed.");
- closelog();
- goto err;
- }
-
- smfi_setconn(sock);
- if (smfi_register(smfilter) == MI_FAILURE) {
- syslog(1, "smfi_register failed.");
- fprintf(stderr, "smfi_register failed\n");
- closelog();
- goto err;
- } else {
- exit_status = smfi_main();
- }
-
- closelog();
-
- if (milter_sapi_module.php_ini_path_override) {
- free(milter_sapi_module.php_ini_path_override);
- }
-
- } zend_catch {
- exit_status = EG(exit_status);
- } zend_end_try();
-
-err:
- php_module_shutdown();
- sapi_shutdown();
- tsrm_shutdown();
-
- exit(exit_status);
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/sapi/milter/php_milter.h b/sapi/milter/php_milter.h
deleted file mode 100644
index 72d7ac51ee..0000000000
--- a/sapi/milter/php_milter.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef PHP_MILTER_H
-#define PHP_MILTER_H
-
-#include "libmilter/mfapi.h"
-
-#define MLFI_NONE 0
-#define MLFI_CONNECT 1
-#define MLFI_HELO 2
-#define MLFI_ENVFROM 3
-#define MLFI_ENVRCPT 4
-#define MLFI_HEADER 5
-#define MLFI_EOH 6
-#define MLFI_BODY 7
-#define MLFI_EOM 8
-#define MLFI_ABORT 9
-#define MLFI_CLOSE 10
-#define MLFI_INIT 11
-
-#define MG(v) TSRMG(milter_globals_id, zend_milter_globals *, v)
-
-typedef struct {
- pthread_t thread;
- MUTEX_T receiver;
- MUTEX_T sender;
- SMFICTX *ctx;
- sfsistat retval;
- int message;
- void **args;
-} worker_thread;
-
-#endif
diff --git a/sapi/phttpd/CREDITS b/sapi/phttpd/CREDITS
deleted file mode 100644
index 134cc54825..0000000000
--- a/sapi/phttpd/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-phttpd
-Thies C. Arntzen
diff --git a/sapi/phttpd/README b/sapi/phttpd/README
deleted file mode 100644
index cdb6f7c381..0000000000
--- a/sapi/phttpd/README
+++ /dev/null
@@ -1,5 +0,0 @@
-phttpd sapi module.
-
-THIS IS BY NO MEANS COMPLETE NOR USABLE RIGHT NOW!
-
-thies@thieso.net 03.01.2000
diff --git a/sapi/phttpd/config.m4 b/sapi/phttpd/config.m4
deleted file mode 100644
index 91339a5278..0000000000
--- a/sapi/phttpd/config.m4
+++ /dev/null
@@ -1,21 +0,0 @@
-dnl
-dnl $Id$
-dnl
-
-PHP_ARG_WITH(phttpd, for PHTTPD support,
-[ --with-phttpd=DIR Build PHP as phttpd module], no, no)
-
-if test "$PHP_PHTTPD" != "no"; then
- if test ! -d $PHP_PHTTPD ; then
- AC_MSG_ERROR([You did not specify a directory])
- fi
- PHP_BUILD_THREAD_SAFE
- PHP_ADD_INCLUDE($PHP_PHTTPD/include)
- AC_DEFINE(HAVE_PHTTPD, 1, [Whether you have phttpd])
- PHP_SELECT_SAPI(phttpd, shared, phttpd.c)
- INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED \$(INSTALL_ROOT)$PHP_PHTTPD/modules/"
-fi
-
-dnl ## Local Variables:
-dnl ## tab-width: 4
-dnl ## End:
diff --git a/sapi/phttpd/php.sym b/sapi/phttpd/php.sym
deleted file mode 100644
index f10b883a99..0000000000
--- a/sapi/phttpd/php.sym
+++ /dev/null
@@ -1,4 +0,0 @@
-pm_init
-pm_exit
-pm_request
-
diff --git a/sapi/phttpd/php_phttpd.h b/sapi/phttpd/php_phttpd.h
deleted file mode 100644
index af53d188e2..0000000000
--- a/sapi/phttpd/php_phttpd.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.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: Thies C. Arntzen <thies@thieso.net> |
- +----------------------------------------------------------------------+
-*/
-
-#ifndef PHP_PHTTPD_H
-#define PHP_PHTTPD_H
-
-#include <phttpd.h>
-
-#endif
diff --git a/sapi/phttpd/phttpd.c b/sapi/phttpd/phttpd.c
deleted file mode 100644
index d47cdc94cc..0000000000
--- a/sapi/phttpd/phttpd.c
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.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: Thies C. Arntzen <thies@thieso.net> |
- | Based on aolserver SAPI by Sascha Schumann <sascha@schumann.cx> |
- +----------------------------------------------------------------------+
-*/
-
-#include "php.h"
-#include "SAPI.h"
-#include "php_main.h"
-
-#ifdef HAVE_PHTTPD
-
-#include "ext/standard/info.h"
-
-#ifndef ZTS
-#error PHTTPD module is only useable in thread-safe mode
-#endif
-
-#include "php_phttpd.h"
-
-typedef struct {
- struct connectioninfo *cip;
- struct stat sb;
-} phttpd_globals_struct;
-
-static int ph_globals_id;
-
-#define PHG(v) TSRMG(ph_globals_id, phttpd_globals_struct *, v)
-
-static int
-php_phttpd_startup(sapi_module_struct *sapi_module)
-{
- fprintf(stderr,"***php_phttpd_startup\n");
-
- if (php_module_startup(sapi_module, NULL, 0)) {
- return FAILURE;
- } else {
- return SUCCESS;
- }
-}
-
-static int
-php_phttpd_sapi_ub_write(const char *str, uint str_length)
-{
- int sent_bytes;
-
- sent_bytes = fd_write(PHG(cip)->fd, str, str_length);
-
- if (sent_bytes == -1) {
- php_handle_aborted_connection();
- }
-
- return sent_bytes;
-}
-
-static int
-php_phttpd_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers)
-{
- char *header_name, *header_content;
- char *p;
-
- http_sendheaders(PHG(cip)->fd, PHG(cip), SG(sapi_headers).http_response_code, NULL);
-
- header_name = sapi_header->header;
- header_content = p = strchr(header_name, ':');
-
- if (p) {
- *p = '\0';
- do {
- header_content++;
- } while (*header_content == ' ');
-
- fd_printf(PHG(cip)->fd,"%s: %s\n", header_name, header_content);
-
- *p = ':';
- }
-
- sapi_free_header(sapi_header);
-
- return 0;
-}
-
-static int
-php_phttpd_sapi_send_headers(sapi_headers_struct *sapi_headers)
-{
- if (SG(sapi_headers).send_default_content_type) {
- fd_printf(PHG(cip)->fd,"Content-Type: text/html\n");
- }
-
- fd_putc('\n', PHG(cip)->fd);
-
- return SAPI_HEADER_SENT_SUCCESSFULLY;
-}
-
-static char *
-php_phttpd_sapi_read_cookies(void)
-{
-
-/*
- int i;
- char *http_cookie = NULL;
-
- i = Ns_SetIFind(NSG(conn->headers), "cookie");
- if(i != -1) {
- http_cookie = Ns_SetValue(NSG(conn->headers), i);
- }
-
- return http_cookie;
-*/
- fprintf(stderr,"***php_phttpd_sapi_read_cookies\n");
-
- return 0;
-}
-
-static int
-php_phttpd_sapi_read_post(char *buf, uint count_bytes)
-{
-/*
- uint max_read;
- uint total_read = 0;
-
- max_read = MIN(NSG(data_avail), count_bytes);
-
- total_read = Ns_ConnRead(NSG(conn), buf, max_read);
-
- if(total_read == NS_ERROR) {
- total_read = -1;
- } else {
- NSG(data_avail) -= total_read;
- }
-
- return total_read;
-*/
- fprintf(stderr,"***php_phttpd_sapi_read_post\n");
- return 0;
-}
-
-static sapi_module_struct phttpd_sapi_module = {
- "phttpd",
- "PHTTPD",
-
- php_phttpd_startup, /* startup */
- php_module_shutdown_wrapper, /* shutdown */
-
- NULL, /* activate */
- NULL, /* deactivate */
-
- php_phttpd_sapi_ub_write, /* unbuffered write */
- NULL, /* flush */
- NULL, /* get uid */
- NULL, /* getenv */
-
- php_error, /* error handler */
-
- php_phttpd_sapi_header_handler, /* header handler */
- php_phttpd_sapi_send_headers, /* send headers handler */
- NULL, /* send header handler */
-
- php_phttpd_sapi_read_post, /* read POST data */
- php_phttpd_sapi_read_cookies, /* read Cookies */
-
- NULL, /* register server variables */
- NULL, /* Log message */
- NULL, /* Get request time */
- NULL, /* Child terminate */
-
- STANDARD_SAPI_MODULE_PROPERTIES
-};
-
-static void
-php_phttpd_request_ctor(void)
-{
- memset(&SG(request_info), 0, sizeof(sapi_globals_struct)); /* pfusch! */
-
- SG(request_info).query_string = PHG(cip)->hip->request;
- SG(request_info).request_method = PHG(cip)->hip->method;
- SG(request_info).path_translated = malloc(MAXPATHLEN);
- SG(sapi_headers).http_response_code = 200;
- if (url_expand(PHG(cip)->hip->url, SG(request_info).path_translated, MAXPATHLEN, &PHG(sb), NULL, NULL) == NULL) {
- /* handle error */
- }
-
-#if 0
- char *server;
- Ns_DString ds;
- char *root;
- int index;
- char *tmp;
-
- server = Ns_ConnServer(NSG(conn));
-
- Ns_DStringInit(&ds);
- Ns_UrlToFile(&ds, server, NSG(conn->request->url));
-
- /* path_translated is the absolute path to the file */
- SG(request_info).path_translated = strdup(Ns_DStringValue(&ds));
- Ns_DStringFree(&ds);
- root = Ns_PageRoot(server);
- SG(request_info).request_uri = SG(request_info).path_translated + strlen(root);
- SG(request_info).content_length = Ns_ConnContentLength(NSG(conn));
- index = Ns_SetIFind(NSG(conn)->headers, "content-type");
- SG(request_info).content_type = index == -1 ? NULL :
- Ns_SetValue(NSG(conn)->headers, index);
-
- tmp = Ns_ConnAuthUser(NSG(conn));
- if(tmp) {
- tmp = estrdup(tmp);
- }
- SG(request_info).auth_user = tmp;
-
- tmp = Ns_ConnAuthPasswd(NSG(conn));
- if(tmp) {
- tmp = estrdup(tmp);
- }
- SG(request_info).auth_password = tmp;
-
- NSG(data_avail) = SG(request_info).content_length;
-#endif
-}
-
-static void
-php_phttpd_request_dtor(void)
-{
- free(SG(request_info).path_translated);
-}
-
-
-int php_doit(void)
-{
- struct stat sb;
- zend_file_handle file_handle;
- struct httpinfo *hip = PHG(cip)->hip;
-
- if (php_request_startup() == FAILURE) {
- return -1;
- }
-
- file_handle.type = ZEND_HANDLE_FILENAME;
- file_handle.filename = SG(request_info).path_translated;
- file_handle.free_filename = 0;
-
-/*
- php_phttpd_hash_environment();
-*/
- php_execute_script(&file_handle);
- php_request_shutdown(NULL);
-
- return SG(sapi_headers).http_response_code;
-}
-
-int pm_init(const char **argv)
-{
- tsrm_startup(1, 1, 0, NULL);
- sapi_startup(&phttpd_sapi_module);
- phttpd_sapi_module.startup(&phttpd_sapi_module);
-
- ts_allocate_id(&ph_globals_id, sizeof(phttpd_globals_struct), NULL, NULL);
-
- return 0;
-}
-
-void pm_exit(void)
-{
- fprintf(stderr,"***pm_exit\n");
-}
-
-int pm_request(struct connectioninfo *cip)
-{
- struct httpinfo *hip = cip->hip;
- int status;
-
- if (strcasecmp(hip->method, "GET") == 0 ||
- strcasecmp(hip->method, "HEAD") == 0 ||
- strcasecmp(hip->method, "POST") == 0) {
- PHG(cip) = cip;
-
- php_phttpd_request_ctor();
- status = php_doit();
- php_phttpd_request_dtor();
-
- return status;
- } else {
- return -2;
- }
-}
-
-#endif
diff --git a/sapi/pi3web/CREDITS b/sapi/pi3web/CREDITS
deleted file mode 100644
index c4541f89da..0000000000
--- a/sapi/pi3web/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-pi3web
-Holger Zimmermann
diff --git a/sapi/pi3web/README b/sapi/pi3web/README
deleted file mode 100644
index e7726edcf4..0000000000
--- a/sapi/pi3web/README
+++ /dev/null
@@ -1,50 +0,0 @@
-PHP7 Module
-==========
-This module requires PHP7 as thread safe shared library. Have a look
-into the INSTALL file which accompanies that distribution.
-
-If you distribute this software bundled with the PHP software in source
-or binary form, then you must adhere to the PHP copyright conditions -
-the terms are reasonable.
-
-You should have checked out and built the PHP7 source package from the
-PHP CVS tree into the Pi3Web source directory called 'PHP7' first. Then
-build PHP7 as Pi3Web module and after that build the Pi3Web PHP7 wrapper:
-
-1. Checkout PHP7
-================
-cvs -d :pserver:cvsread@cvs.php.net:/repository login
-The required password is phpfi
-
-cvs -z3 -d :pserver:cvsread@cvs.php.net:/repository co php7
-
-You must also checkout the TSRM and the ZEND module from the ZEND cvs tree
-into the PHP7 root directory
-
-cvs -d :pserver:cvsread@cvs.zend.com:/repository login
-The required password is zend
-
-cvs -z3 -d :pserver:cvsread@cvs.zend.com:/repository co Zend TSRM
-
-2. Build PHP7
-=============
-2.1 POSIX
----------
-cd ./php7
-./buildconf
-./configure --with-pi3web
-make
-
-2.2 Win32
----------
-other required downloads from the php website
- - bison 1.25
- - bindlib32
- - number4.tar.gz
-nmake php7dllts.mak
-
-3. Build Pi3Web PHP7 wrapper
-============================
-Run make in the Pi3Web /Source/PHP7 directory.
-
-For further information refer to http://www.php.net/version4/
diff --git a/sapi/pi3web/config.m4 b/sapi/pi3web/config.m4
deleted file mode 100644
index 42ff164394..0000000000
--- a/sapi/pi3web/config.m4
+++ /dev/null
@@ -1,27 +0,0 @@
-dnl
-dnl $Id$
-dnl
-
-PHP_ARG_WITH(pi3web, for Pi3Web support,
-[ --with-pi3web[=DIR] Build PHP as Pi3Web module], no, no)
-
-if test "$PHP_PI3WEB" != "no"; then
- if test "$PHP_PI3WEB" = "yes"; then
- PI3PATH=../.. # the default
- else
- PI3PATH=$PHP_PI3WEB
- fi
- test -f "$PI3PATH/PiAPI/PiAPI.h" || AC_MSG_ERROR([Unable to find PiAPI.h in $PI3PATH/PiAPI])
- PHP_BUILD_THREAD_SAFE
- AC_DEFINE(WITH_PI3WEB, 1, [whether you want Pi3Web support])
- PHP_ADD_INCLUDE($PI3PATH/PiAPI)
- PHP_ADD_INCLUDE($PI3PATH/Pi2API)
- PHP_ADD_INCLUDE($PI3PATH/Pi3API)
- PHP_ADD_INCLUDE($PI3PATH/PHP7)
- PHP_SELECT_SAPI(pi3web, shared, pi3web_sapi.c)
- INSTALL_IT="\$(SHELL) \$(srcdir)/install-sh -m 0755 $SAPI_SHARED \$(INSTALL_ROOT)$PI3PATH/bin/"
-fi
-
-dnl ## Local Variables:
-dnl ## tab-width: 4
-dnl ## End:
diff --git a/sapi/pi3web/config.w32 b/sapi/pi3web/config.w32
deleted file mode 100644
index 9441784468..0000000000
--- a/sapi/pi3web/config.w32
+++ /dev/null
@@ -1,16 +0,0 @@
-// vim:ft=javascript
-// $Id$
-
-ARG_WITH('pi3web', 'Pi3Web', 'no');
-
-if (PHP_PI3WEB != "no") {
- if (CHECK_HEADER_ADD_INCLUDE('PiAPI.h', 'CFLAGS_PI3WEB', PHP_PHP_BUILD + "\\Pi3Web\\include;" + PHP_PI3WEB) &&
- CHECK_LIB('piapi.lib', 'pi3web', PHP_PHP_BUILD + "\\Pi3Web\\lib;" + PHP_PI3WEB) &&
- CHECK_LIB('pi2api.lib', 'pi3web', PHP_PHP_BUILD + "\\Pi3Web\\lib;" + PHP_PI3WEB) &&
- CHECK_LIB('pi3api.lib', 'pi3web', PHP_PHP_BUILD + "\\Pi3Web\\lib;" + PHP_PI3WEB)) {
- SAPI('pi3web', 'pi3web_sapi.c', 'php' + PHP_VERSION + 'pi3web.dll', '/D PHP7PI3WEB_EXPORTS');
- AC_DEFINE('WITH_PI3WEB', 1);
- } else {
- WARNING('Pi3Web not enabled; headers/libraries not found');
- }
-}
diff --git a/sapi/pi3web/php.sym b/sapi/pi3web/php.sym
deleted file mode 100644
index e69de29bb2..0000000000
--- a/sapi/pi3web/php.sym
+++ /dev/null
diff --git a/sapi/pi3web/pi3web_sapi.c b/sapi/pi3web/pi3web_sapi.c
deleted file mode 100644
index a91660ca6f..0000000000
--- a/sapi/pi3web/pi3web_sapi.c
+++ /dev/null
@@ -1,438 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.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. |
- +----------------------------------------------------------------------+
- | Pi3Web version 2.0 |
- +----------------------------------------------------------------------+
- | This file is committed by the Pi3 development group. |
- | (pi3web.sourceforge.net) |
- | |
- | Author: Holger Zimmermann (zimpel@users.sourceforge.net) |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
-
-#include "php.h"
-#include "php_main.h"
-#include "php_variables.h"
-#include "SAPI.h"
-#include "php_globals.h"
-#include "ext/standard/info.h"
-#include "zend_highlight.h"
-#include "zend_indent.h"
-#include "zend_alloc.h"
-#include "ext/standard/basic_functions.h"
-#include "TSRM/TSRM.h"
-#include "PiAPI.h"
-#include "Pi3API.h"
-
-#include "pi3web_sapi.h"
-
-#define PI3WEB_SERVER_VAR_BUF_SIZE 1024
-
-int IWasLoaded=0;
-
-
-static void php_info_pi3web(ZEND_MODULE_INFO_FUNC_ARGS)
-{
- char variable_buf[PI3WEB_SERVER_VAR_BUF_SIZE];
- DWORD variable_len;
- LPCONTROL_BLOCK lpCB = (LPCONTROL_BLOCK) SG(server_context);
- PIDB *pDB = (PIDB *)lpCB->GetVariableNames(lpCB->ConnID);
- PIDBIterator *pIter = PIDB_getIterator( pDB, PIDBTYPE_STRING, 0, 0 );
-
- PUTS("<table border=0 cellpadding=3 cellspacing=1 width=600 align=center>\n");
- PUTS("<tr><th colspan=2 bgcolor=\"" PHP_HEADER_COLOR "\">Pi3Web Server Information</th></tr>\n");
- php_info_print_table_header(2, "Information Field", "Value");
- php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id$");
- php_info_print_table_row(2, "Server Name Stamp", HTTPCore_getServerStamp());
- snprintf(variable_buf, 511, "%d", HTTPCore_debugEnabled());
- php_info_print_table_row(2, "Debug Enabled", variable_buf);
- PIPlatform_getCurrentDirectory( variable_buf, PI3WEB_SERVER_VAR_BUF_SIZE);
- php_info_print_table_row(2, "Current Path", variable_buf);
- if (lpCB->GetServerVariable(lpCB->ConnID, "SERVER_NAME", variable_buf, &variable_len)
- && variable_buf[0]) {
- php_info_print_table_row(2, "Main Virtual Hostname", variable_buf);
- };
- snprintf(variable_buf, 511, "%d", PIPlatform_getProcessId());
- php_info_print_table_row(2, "Server PID", variable_buf);
- php_info_print_table_row(2, "Server Platform", PIPlatform_getDescription());
-
- PUTS("</table><br />");
-
- PUTS("<table border=0 cellpadding=3 cellspacing=1 width=600 align=center>\n");
- PUTS("<tr><th colspan=2 bgcolor=\"" PHP_HEADER_COLOR "\">HTTP Request Information</th></tr>\n");
- php_info_print_table_row(2, "HTTP Request Line", lpCB->lpszReq);
- PUTS("<tr><th colspan=2 bgcolor=\"" PHP_HEADER_COLOR "\">HTTP Headers</th></tr>\n");
- php_info_print_table_header(2, "Server Variable", "Value");
-
- /* --- loop over all registered server variables --- */
- for(; pIter && PIDBIterator_atValidElement( pIter ); PIDBIterator_next( pIter ) )
- {
- PCHAR pKey;
- PIDBIterator_current( pIter, &pKey );
- if ( !pKey ) { /* sanity */ continue; };
-
- variable_len = PI3WEB_SERVER_VAR_BUF_SIZE;
- if (lpCB->GetServerVariable(lpCB->ConnID, pKey, variable_buf, &variable_len)
- && variable_buf[0]) {
- php_info_print_table_row(2, pKey, variable_buf);
- } else if (PIPlatform_getLastError() == PIAPI_EINVAL) {
- char *tmp_variable_buf;
-
- tmp_variable_buf = (char *) emalloc(variable_len);
- if (lpCB->GetServerVariable(lpCB->ConnID, pKey, tmp_variable_buf, &variable_len)
- && variable_buf[0]) {
- php_info_print_table_row(2, pKey, tmp_variable_buf);
- }
- efree(tmp_variable_buf);
- }
- }
-
- PUTS("</table>");
-}
-
-
-static zend_module_entry php_pi3web_module = {
- STANDARD_MODULE_HEADER,
- "PI3WEB",
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- php_info_pi3web,
- NULL,
- STANDARD_MODULE_PROPERTIES
-};
-
-
-static int zend_pi3web_ub_write(const char *str, uint str_length)
-{
- DWORD num_bytes = str_length;
- LPCONTROL_BLOCK cb;
-
- cb = (LPCONTROL_BLOCK) SG(server_context);
-
- if ( !IWasLoaded ) return 0;
- cb->WriteClient(cb->ConnID, (char *) str, &num_bytes, 0 );
-
- if (num_bytes != str_length)
- php_handle_aborted_connection();
- return num_bytes;
-}
-
-
-static int sapi_pi3web_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers)
-{
- return SAPI_HEADER_ADD;
-}
-
-
-static void accumulate_header_length(sapi_header_struct *sapi_header, uint *total_length)
-{
- *total_length += sapi_header->header_len+2;
-}
-
-
-static void concat_header(sapi_header_struct *sapi_header, char **combined_headers_ptr)
-{
- memcpy(*combined_headers_ptr, sapi_header->header, sapi_header->header_len);
- *combined_headers_ptr += sapi_header->header_len;
- **combined_headers_ptr = '\r';
- (*combined_headers_ptr)++;
- **combined_headers_ptr = '\n';
- (*combined_headers_ptr)++;
-}
-
-
-static int sapi_pi3web_send_headers(sapi_headers_struct *sapi_headers)
-{
- uint total_length = 2; /* account for the trailing \r\n */
- char *combined_headers, *combined_headers_ptr;
- LPCONTROL_BLOCK lpCB = (LPCONTROL_BLOCK) SG(server_context);
- sapi_header_struct default_content_type;
-
- if ( !IWasLoaded ) return SAPI_HEADER_SENT_SUCCESSFULLY;
-
-
- if (SG(sapi_headers).send_default_content_type) {
- sapi_get_default_content_type_header(&default_content_type);
- accumulate_header_length(&default_content_type, (void *) &total_length);
- }
- zend_llist_apply_with_argument(&SG(sapi_headers).headers, (llist_apply_with_arg_func_t) accumulate_header_length, (void *) &total_length);
-
- /* Generate headers */
- combined_headers = (char *) emalloc(total_length+1);
- combined_headers_ptr = combined_headers;
- if (SG(sapi_headers).send_default_content_type) {
- concat_header(&default_content_type, (void *) &combined_headers_ptr);
- sapi_free_header(&default_content_type); /* we no longer need it */
- }
- zend_llist_apply_with_argument(&SG(sapi_headers).headers, (llist_apply_with_arg_func_t) concat_header, (void *) &combined_headers_ptr);
- *combined_headers_ptr++ = '\r';
- *combined_headers_ptr++ = '\n';
- *combined_headers_ptr = 0;
-
- lpCB->dwHttpStatusCode = SG(sapi_headers).http_response_code;
- lpCB->SendHeaderFunction(lpCB->ConnID, &total_length, (LPDWORD) combined_headers);
-
- efree(combined_headers);
- if (SG(sapi_headers).http_status_line) {
- efree(SG(sapi_headers).http_status_line);
- SG(sapi_headers).http_status_line = 0;
- }
- return SAPI_HEADER_SENT_SUCCESSFULLY;
-}
-
-
-static int php_pi3web_startup(sapi_module_struct *sapi_module)
-{
- if (php_module_startup(sapi_module, &php_pi3web_module, 1)==FAILURE) {
- return FAILURE;
- } else {
- return SUCCESS;
- }
-}
-
-
-static int sapi_pi3web_read_post(char *buffer, uint count_bytes)
-{
- LPCONTROL_BLOCK lpCB = (LPCONTROL_BLOCK) SG(server_context);
- DWORD read_from_buf=0;
- DWORD read_from_input=0;
- DWORD total_read=0;
-
- if ((DWORD)SG(read_post_bytes) < lpCB->cbAvailable) {
- read_from_buf = MIN(lpCB->cbAvailable-SG(read_post_bytes), count_bytes);
- memcpy(buffer, lpCB->lpbData+SG(read_post_bytes), read_from_buf);
- total_read += read_from_buf;
- }
- if (read_from_buf<count_bytes
- && (SG(read_post_bytes)+read_from_buf) < lpCB->cbTotalBytes) {
- DWORD cbRead=0, cbSize;
-
- read_from_input = MIN(count_bytes-read_from_buf, lpCB->cbTotalBytes-SG(read_post_bytes)-read_from_buf);
- while (cbRead < read_from_input) {
- cbSize = read_from_input - cbRead;
- if (!lpCB->ReadClient(lpCB->ConnID, buffer+read_from_buf+cbRead, &cbSize) || cbSize==0) {
- break;
- }
- cbRead += cbSize;
- }
- total_read += cbRead;
- }
-
- /* removed after re-testing POST with Pi3Web 2.0.2 */
- /* SG(read_post_bytes) += total_read; */
- return total_read;
-}
-
-
-static char *sapi_pi3web_read_cookies(void)
-{
- LPCONTROL_BLOCK lpCB = (LPCONTROL_BLOCK) SG(server_context);
- char variable_buf[PI3WEB_SERVER_VAR_BUF_SIZE];
- DWORD variable_len = PI3WEB_SERVER_VAR_BUF_SIZE;
-
- if (lpCB->GetServerVariable(lpCB->ConnID, "HTTP_COOKIE", variable_buf, &variable_len)) {
- return estrndup(variable_buf, variable_len);
- } else if (PIPlatform_getLastError()==PIAPI_EINVAL) {
- char *tmp_variable_buf = (char *) emalloc(variable_len+1);
-
- if (lpCB->GetServerVariable(lpCB->ConnID, "HTTP_COOKIE", tmp_variable_buf, &variable_len)) {
- tmp_variable_buf[variable_len] = 0;
- return tmp_variable_buf;
- } else {
- efree(tmp_variable_buf);
- }
- }
- return NULL;
-}
-
-static void init_request_info(LPCONTROL_BLOCK lpCB)
-{
- SG(server_context) = lpCB;
- SG(request_info).request_method = lpCB->lpszMethod;
- SG(request_info).query_string = lpCB->lpszQueryString;
- SG(request_info).path_translated = lpCB->lpszPathTranslated;
- SG(request_info).request_uri = lpCB->lpszUri;
- SG(request_info).content_type = lpCB->lpszContentType;
- SG(request_info).content_length = lpCB->cbTotalBytes;
- SG(request_info).auth_user = (lpCB->lpszUser) ? (char *)estrdup((const char *)(lpCB->lpszUser)) : 0;
- SG(request_info).auth_password = (lpCB->lpszPassword) ? (char *)estrdup((const char *)(lpCB->lpszPassword)) : 0;
- SG(sapi_headers).http_response_code = 200;
-}
-
-static void sapi_pi3web_register_variables(zval *track_vars_array)
-{
- char static_variable_buf[PI3WEB_SERVER_VAR_BUF_SIZE];
- char *variable_buf;
- DWORD variable_len = PI3WEB_SERVER_VAR_BUF_SIZE;
- LPCONTROL_BLOCK lpCB = (LPCONTROL_BLOCK) SG(server_context);
- PIDB *pDB = (PIDB *)lpCB->GetVariableNames(lpCB->ConnID);
- PIDBIterator *pIter = PIDB_getIterator( pDB, PIDBTYPE_STRING, 0, 0 );
-
- /* --- loop over all registered server variables --- */
- for(; pIter && PIDBIterator_atValidElement( pIter ); PIDBIterator_next( pIter ) )
- {
- PCHAR pKey;
- PIDBIterator_current( pIter, &pKey );
- if ( !pKey ) { /* sanity */ continue; };
-
- variable_len = PI3WEB_SERVER_VAR_BUF_SIZE;
- if (lpCB->GetServerVariable(lpCB->ConnID, pKey, static_variable_buf, &variable_len)
- && (variable_len > 1)) {
- php_register_variable(pKey, static_variable_buf, track_vars_array);
- } else if (PIPlatform_getLastError()==PIAPI_EINVAL) {
- variable_buf = (char *) emalloc(variable_len);
- if (lpCB->GetServerVariable(lpCB->ConnID, pKey, variable_buf, &variable_len)) {
- php_register_variable(pKey, variable_buf, track_vars_array);
- }
- efree(variable_buf);
- }
-
- }
-
-
- /* PHP_SELF support */
- variable_len = PI3WEB_SERVER_VAR_BUF_SIZE;
- if (lpCB->GetServerVariable(lpCB->ConnID, "SCRIPT_NAME", static_variable_buf, &variable_len)
- && (variable_len > 1)) {
- php_register_variable("PHP_SELF", static_variable_buf, track_vars_array);
- }
-}
-
-static sapi_module_struct pi3web_sapi_module = {
- "pi3web", /* name */
- "PI3WEB", /* pretty name */
-
- php_pi3web_startup, /* startup */
- php_module_shutdown_wrapper, /* shutdown */
- NULL, /* activate */
- NULL, /* deactivate */
- zend_pi3web_ub_write, /* unbuffered write */
- NULL, /* flush */
- NULL, /* get uid */
- NULL, /* getenv */
- php_error, /* error handler */
- sapi_pi3web_header_handler, /* header handler */
- sapi_pi3web_send_headers, /* send headers handler */
- NULL, /* send header handler */
- sapi_pi3web_read_post, /* read POST data */
- sapi_pi3web_read_cookies, /* read Cookies */
- sapi_pi3web_register_variables, /* register server variables */
- NULL, /* Log message */
- NULL, /* Get request time */
- NULL, /* Child terminate */
-
- STANDARD_SAPI_MODULE_PROPERTIES
-};
-
-MODULE_API DWORD PHP7_wrapper(LPCONTROL_BLOCK lpCB)
-{
- zend_file_handle file_handle = {0};
- int iRet = PIAPI_COMPLETED;
-
- zend_first_try {
- file_handle.filename = lpCB->lpszFileName;
- file_handle.free_filename = 0;
- file_handle.type = ZEND_HANDLE_FILENAME;
- file_handle.opened_path = NULL;
-
- init_request_info(lpCB);
- php_request_startup();
-
- switch ( lpCB->dwBehavior ) {
- case PHP_MODE_STANDARD:
- iRet = ( php_execute_script( &file_handle ) ) ?
- PIAPI_COMPLETED : PIAPI_ERROR;
- break;
- case PHP_MODE_HIGHLIGHT: {
- zend_syntax_highlighter_ini syntax_highlighter_ini;
- if ( open_file_for_scanning( &file_handle ) == SUCCESS )
- {
- php_get_highlight_struct( &syntax_highlighter_ini );
- zend_highlight( &syntax_highlighter_ini );
- }
- else
- {
- iRet = PIAPI_ERROR;
- };
- };
- break;
- case PHP_MODE_INDENT: {
- sapi_header_line ctr = {0};
-
- ctr.line = "Content-Type: text/plain";
- ctr.line_len = strlen(ctr.line);
-
- sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
- }
- if ( open_file_for_scanning( &file_handle ) == SUCCESS )
- {
- zend_indent();
- }
- else
- {
- iRet = PIAPI_ERROR;
- };
- break;
- case PHP_MODE_LINT:
- iRet = (php_lint_script(&file_handle) == SUCCESS) ?
- PIAPI_COMPLETED : PIAPI_ERROR;
- break;
- default:
- iRet = PIAPI_ERROR;;
- }
-
- if (SG(request_info).cookie_data) {
- efree(SG(request_info).cookie_data);
- };
-
- php_request_shutdown(NULL);
- } zend_catch {
- iRet = PIAPI_ERROR;
- } zend_end_try();
- return iRet;
-}
-
-MODULE_API BOOL PHP7_startup() {
- tsrm_startup(1, 1, 0, NULL);
- sapi_startup(&pi3web_sapi_module);
- if (pi3web_sapi_module.startup) {
- pi3web_sapi_module.startup(&pi3web_sapi_module);
- };
- IWasLoaded = 1;
- return IWasLoaded;
-};
-
-MODULE_API BOOL PHP7_shutdown() {
- if (pi3web_sapi_module.shutdown) {
- pi3web_sapi_module.shutdown(&pi3web_sapi_module);
- };
- sapi_shutdown();
- tsrm_shutdown();
- IWasLoaded = 0;
- return !IWasLoaded;
-};
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/sapi/pi3web/pi3web_sapi.h b/sapi/pi3web/pi3web_sapi.h
deleted file mode 100644
index 70eec611b4..0000000000
--- a/sapi/pi3web/pi3web_sapi.h
+++ /dev/null
@@ -1,102 +0,0 @@
-#ifndef _PI3WEB_SAPI_H_
-#define _PI3WEB_SAPI_H_
-
-#ifdef PHP_WIN32
-# include <windows.h>
-# ifdef PHP7PI3WEB_EXPORTS
-# define MODULE_API __declspec(dllexport)
-# else
-# define MODULE_API __declspec(dllimport)
-# endif
-#else
-# if defined(__GNUC__) && __GNUC__ >= 4
-# define MODULE_API __attribute__ ((visibility("default")))
-# else
-# define MODULE_API
-# endif
-# define far
-
- typedef int BOOL;
- typedef void far *LPVOID;
- typedef unsigned long DWORD;
- typedef DWORD far *LPDWORD;
- typedef char CHAR;
- typedef CHAR *LPSTR;
- typedef unsigned char BYTE;
- typedef BYTE far *LPBYTE;
-#endif
-
- typedef LPVOID HCONN;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define PHP_MODE_STANDARD 1
-#define PHP_MODE_HIGHLIGHT 2
-#define PHP_MODE_INDENT 3
-#define PHP_MODE_LINT 4
-
-//
-// passed to the procedure on a new request
-//
-typedef struct _CONTROL_BLOCK {
- DWORD cbSize; // size of this struct.
- HCONN ConnID; // Context number not to be modified!
- DWORD dwHttpStatusCode; // HTTP Status code
- CHAR lpszLogData[80]; // null terminated log info
-
- LPSTR lpszMethod; // REQUEST_METHOD
- LPSTR lpszQueryString; // QUERY_STRING
- LPSTR lpszPathInfo; // PATH_INFO
- LPSTR lpszPathTranslated; // PATH_TRANSLATED
- LPSTR lpszFileName; // FileName to PHP3 physical file
- LPSTR lpszUri; // The request URI
- LPSTR lpszReq; // The whole HTTP request line
- LPSTR lpszUser; // The authenticated user
- LPSTR lpszPassword; // The authenticated password
-
- DWORD cbTotalBytes; // Total bytes indicated from client
- DWORD cbAvailable; // Available number of bytes
- LPBYTE lpbData; // pointer to cbAvailable bytes
-
- LPSTR lpszContentType; // Content type of client data
- DWORD dwBehavior; // PHP behavior (standard, highlight, intend
-
-
- LPVOID (* GetVariableNames) (HCONN hConn);
-
- BOOL (* GetServerVariable) ( HCONN hConn,
- LPSTR lpszVariableName,
- LPVOID lpvBuffer,
- LPDWORD lpdwSize );
-
- BOOL (* WriteClient) ( HCONN hConn,
- LPVOID lpvBuffer,
- LPDWORD lpdwBytes,
- DWORD dwReserved );
-
- BOOL (* ReadClient) ( HCONN hConn,
- LPVOID lpvBuffer,
- LPDWORD lpdwSize );
-
- BOOL (* SendHeaderFunction)( HCONN hConn,
- LPDWORD lpdwSize,
- LPDWORD lpdwDataType );
-
-} CONTROL_BLOCK, *LPCONTROL_BLOCK;
-
-MODULE_API DWORD PHP7_wrapper(LPCONTROL_BLOCK lpCB);
-MODULE_API BOOL PHP7_startup();
-MODULE_API BOOL PHP7_shutdown();
-
-// the following type declaration is for the server side
-typedef DWORD ( * PFN_WRAPPERFUNC )( CONTROL_BLOCK *pCB );
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // end definition _PI3WEB_SAPI_H_
diff --git a/sapi/roxen/README b/sapi/roxen/README
deleted file mode 100644
index 59c215cba0..0000000000
--- a/sapi/roxen/README
+++ /dev/null
@@ -1,18 +0,0 @@
-Roxen PHP support. Early version. Don't expect to be able to get it to
-work. Requires Pike 0.7.79 and Roxen 1.4. Anything less won't work.
-
-The module is now thread safe, in a couple of different modes. First
-mode, the default, uses a process global PHP lock in the Roxen
-module. This means that all PHP-requests are serialized (ie only one
-script is executed at any one time). The second option is using ZTS
-(Zend Thread Safe mode). Unless --enable-roxen-zts is specified, this
-won't be used.
-
-This solution now works fine and is recommended. Multiple PHP7
-requests will be run in parallell. The maximum number of parallell
-PHP7-execution is limited to the number of handle threads Roxen is
-started with.
-
-Support for this module is lacking. Please contact Roxen Internet
-Software for support and help. See http://www.roxen.com/company/contact/
-for contact information.
diff --git a/sapi/roxen/TODO b/sapi/roxen/TODO
deleted file mode 100644
index 47143f1be1..0000000000
--- a/sapi/roxen/TODO
+++ /dev/null
@@ -1,33 +0,0 @@
-BUGS:
-
-- fix backtraces
-- exit in PHP exits Roxen
-- POST newline added?
-- Rewriting header handling so that more than one header with the same
- name can be set (most importantly, cookies).
-- Recursive mutex lock problem:
-
- And another error (when trying to include a class)
-
- Recursive mutex locks!
- /Usr/local/pike/7.0.54/lib/modules/PHP7.so.Interpreter:
- run("/home/www/www.tx.pl/news/test.php",mapping[3],modules/scripting/php7.pike.PHPScript(),modules/scripting/php7.pike.PHPScript.done)
- modules/scripting/php7.pike:169: run()
- base_server/roxen.pike:569: handler_thread(3).
-
- And after this every access to any php script (on other virtual sites
- also) ends (of course there is no proper output) with this error:
-
- Php4.Interpreter->run: Tried to run a PHP-script from a PHP
- callback!/usr/local/pike/7.0.54/lib/modules/PHP7.so.Interpreter:
- run("/home/www/biall.com.pl/index.php3",mapping[2],modules/scripting/php7.pike.PHPScript(),modules/scripting/php7.pike.PHPScript.done)
- modules/scripting/php7.pike:169: run()
- base_server/roxen.pike:569: handler_thread(3).
-
-
-ADDITIONS:
-
-- use th_farm
-- change cwd in single threaded mode
-- per-virtual-server configuration
-
diff --git a/sapi/roxen/config.m4 b/sapi/roxen/config.m4
deleted file mode 100644
index d536ac571b..0000000000
--- a/sapi/roxen/config.m4
+++ /dev/null
@@ -1,55 +0,0 @@
-dnl
-dnl $Id$
-dnl
-
-PHP_ARG_WITH(roxen,,
-[ --with-roxen=DIR Build PHP as a Pike module. DIR is the base Roxen
- directory, normally /usr/local/roxen/server], no, no)
-
-PHP_ARG_ENABLE(roxen-zts, whether Roxen module is build using ZTS,
-[ --enable-roxen-zts ROXEN: Build the Roxen module using Zend Thread Safety], no, no)
-
-RESULT=
-AC_MSG_CHECKING([for Roxen/Pike support])
-if test "$PHP_ROXEN" != "no"; then
- if test ! -d $PHP_ROXEN ; then
- AC_MSG_ERROR([You did not specify a directory])
- fi
- if test -f $PHP_ROXEN/bin/roxen; then
- PIKE=$PHP_ROXEN/bin/roxen
- elif test -f $PHP_ROXEN/bin/pike; then
- PIKE=$PHP_ROXEN/bin/pike
- else
- AC_MSG_ERROR([Could not find a pike in $PHP_ROXEN/bin/])
- fi
-
- if $PIKE -e 'float v; catch(v = __VERSION__ + (__BUILD__/10000.0)); if(v < 0.7079) exit(1); exit(0);'; then
- PIKE_MODULE_DIR=`$PIKE --show-paths 2>&1| grep '^Module' | sed -e 's/.*: //'`
- PIKE_INCLUDE_DIR=`echo $PIKE_MODULE_DIR | sed -e 's,lib/pike/modules,include/pike,' -e 's,lib/modules,include/pike,'`
- if test -z "$PIKE_INCLUDE_DIR" || test -z "$PIKE_MODULE_DIR"; then
- AC_MSG_ERROR([Failed to figure out Pike module and include directories])
- fi
- else
- AC_MSG_ERROR([Roxen/PHP requires Pike 0.7.79 or newer])
- fi
-
- PHP_ADD_INCLUDE($PIKE_INCLUDE_DIR)
- AC_DEFINE(HAVE_ROXEN, 1, [Whether you use Roxen])
- PHP_SELECT_SAPI(roxen, shared, roxen.c)
- INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED $PIKE_MODULE_DIR/PHP7.so"
- RESULT="yes
- Pike binary used: $PIKE
- Pike include dir: $PIKE_INCLUDE_DIR
- Pike module directory: $PIKE_MODULE_DIR"
- PIKE_INCLUDE_DIR=" -I$PIKE_INCLUDE_DIR "
-
- if test "$PHP_ROXEN_ZTS" != "no"; then
- PHP_BUILD_THREAD_SAFE
- AC_DEFINE(ROXEN_USE_ZTS, 1, [Whether to use Roxen in ZTS mode])
- fi
-fi
-AC_MSG_RESULT([$RESULT])
-
-dnl ## Local Variables:
-dnl ## tab-width: 4
-dnl ## End:
diff --git a/sapi/roxen/roxen.c b/sapi/roxen/roxen.c
deleted file mode 100644
index 4afba3829c..0000000000
--- a/sapi/roxen/roxen.c
+++ /dev/null
@@ -1,725 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.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: David Hedbor <neotron@php.net> |
- | Based on aolserver SAPI by Sascha Schumann <sascha@schumann.cx> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-#ifdef HAVE_ROXEN
-
-#include "php_ini.h"
-#include "php_globals.h"
-#include "SAPI.h"
-#include "php_main.h"
-#include "ext/standard/info.h"
-
-#include "php_version.h"
-
-#ifndef ZTS
-/* Only valid if thread safety is enabled. */
-#undef ROXEN_USE_ZTS
-#endif
-
-
-/* Pike Include Files
- *
- * conflicts with pike avoided by only using long names. Requires a new
- * Pike 0.7 since it was implemented for this interface only.
- *
- */
-#define NO_PIKE_SHORTHAND
-
-#include <fdlib.h>
-#include <program.h>
-#include <pike_types.h>
-#include <interpret.h>
-#include <module_support.h>
-#include <error.h>
-#include <array.h>
-#include <backend.h>
-#include <stralloc.h>
-#include <mapping.h>
-#include <object.h>
-#include <threads.h>
-#include <builtin_functions.h>
-#include <operators.h>
-
-#undef HIDE_GLOBAL_VARIABLES
-#undef REVEAL_GLOBAL_VARIABLES
-#define HIDE_GLOBAL_VARIABLES()
-#define REVEAL_GLOBAL_VARIABLES()
-
-/* php_roxen_request is per-request object storage */
-
-typedef struct
-{
- struct mapping *request_data;
- struct object *my_fd_obj;
- int my_fd;
- char *filename;
-} php_roxen_request;
-
-
-/* Defines to get to the data supplied when the script is started. */
-
-#ifdef ROXEN_USE_ZTS
-
-/* ZTS does work now, but it seems like it's faster using the "serialization"
- * method I previously used. Thus it's not used unless ROXEN_USE_ZTS is defined.
- */
-
-/* Per thread storage area id... */
-static int roxen_globals_id;
-
-# define GET_THIS() php_roxen_request *_request = ts_resource(roxen_globals_id)
-# define THIS _request
-#else
-static php_roxen_request *current_request = NULL;
-
-# define GET_THIS() current_request = ((php_roxen_request *)Pike_fp->current_storage)
-# define THIS current_request
-#endif
-
-/* File descriptor integer. Used to write directly to the FD without
- * passing Pike
- */
-#define MY_FD (THIS->my_fd)
-
-/* FD object. Really a PHPScript object from Pike which implements a couple
- * of functions to handle headers, writing and buffering.
- */
-#define MY_FD_OBJ ((struct object *)(THIS->my_fd_obj))
-
-/* Mapping with data supplied from the calling Roxen module. Contains
- * a mapping with headers, an FD object etc.
- */
-#define REQUEST_DATA ((struct mapping *)(THIS->request_data))
-
-
-#if defined(_REENTRANT) && !defined(ROXEN_USE_ZTS)
-/* Lock used to serialize the PHP execution. If ROXEN_USE_ZTS is defined, we
- * are using the PHP thread safe mechanism instead.
- */
-static PIKE_MUTEX_T roxen_php_execution_lock;
-# define PHP_INIT_LOCK() mt_init(&roxen_php_execution_lock)
-# define PHP_LOCK(X) THREADS_ALLOW();mt_lock(&roxen_php_execution_lock);THREADS_DISALLOW()
-# define PHP_UNLOCK(X) mt_unlock(&roxen_php_execution_lock);
-# define PHP_DESTROY() mt_destroy(&roxen_php_execution_lock)
-#else /* !_REENTRANT */
-# define PHP_INIT_LOCK()
-# define PHP_LOCK(X)
-# define PHP_UNLOCK(X)
-# define PHP_DESTROY()
-#endif /* _REENTRANT */
-
-extern int fd_from_object(struct object *o);
-static unsigned char roxen_php_initialized;
-
-/* This allows calling of pike functions from the PHP callbacks,
- * which requires the Pike interpreter to be locked.
- */
-#define THREAD_SAFE_RUN(COMMAND, what) do {\
- struct thread_state *state;\
- if((state = thread_state_for_id(th_self()))!=NULL) {\
- if(!state->swapped) {\
- COMMAND;\
- } else {\
- mt_lock(&interpreter_lock);\
- SWAP_IN_THREAD(state);\
- COMMAND;\
- SWAP_OUT_THREAD(state);\
- mt_unlock(&interpreter_lock);\
- }\
- }\
-} while(0)
-
-struct program *php_program;
-
-
-/* To avoid executing a PHP script from a PHP callback, which would
- * create a deadlock, a global thread id is used. If the thread calling the
- * php-script is the same as the current thread, it fails.
- */
-static int current_thread = -1;
-
-
-/* Low level header lookup. Basically looks for the named header in the mapping
- * headers in the supplied options mapping.
- */
-
-static INLINE struct svalue *lookup_header(char *headername)
-{
- struct svalue *headers, *value;
- struct pike_string *sind;
-#ifdef ROXEN_USE_ZTS
- GET_THIS();
-#endif
- sind = make_shared_string("env");
- headers = low_mapping_string_lookup(REQUEST_DATA, sind);
- free_string(sind);
- if(!headers || headers->type != PIKE_T_MAPPING) return NULL;
- sind = make_shared_string(headername);
- value = low_mapping_string_lookup(headers->u.mapping, sind);
- free_string(sind);
- if(!value) return NULL;
- return value;
-}
-
-/* Lookup a header in the mapping and return the value as a string, or
- * return the default if it's missing
- */
-INLINE static char *lookup_string_header(char *headername, char *default_value)
-{
- struct svalue *head = NULL;
- THREAD_SAFE_RUN(head = lookup_header(headername), "header lookup");
- if(!head || head->type != PIKE_T_STRING)
- return default_value;
- return head->u.string->str;
-}
-
-/* Lookup a header in the mapping and return the value as if it's an integer
- * and otherwise return the default.
- */
-INLINE static int lookup_integer_header(char *headername, int default_value)
-{
- struct svalue *head = NULL;
- THREAD_SAFE_RUN(head = lookup_header(headername), "header lookup");
- if(!head || head->type != PIKE_T_INT)
- return default_value;
- return head->u.integer;
-}
-
-/*
- * php_roxen_low_ub_write() writes data to the client connection. Might be
- * rewritten to do more direct IO to save CPU and the need to lock the *
- * interpreter for better threading.
- */
-
-static int
-php_roxen_low_ub_write(const char *str, uint str_length) {
- int sent_bytes = 0;
- struct pike_string *to_write = NULL;
-#ifdef ROXEN_USE_ZTS
- GET_THIS();
-#endif
-
- if(!MY_FD_OBJ->prog) {
- PG(connection_status) = PHP_CONNECTION_ABORTED;
- zend_bailout();
- return -1;
- }
- to_write = make_shared_binary_string(str, str_length);
- push_string(to_write);
- safe_apply(MY_FD_OBJ, "write", 1);
- if(Pike_sp[-1].type == PIKE_T_INT)
- sent_bytes = Pike_sp[-1].u.integer;
- pop_stack();
- if(sent_bytes != str_length) {
- /* This means the connection is closed. Dead. Gone. *sniff* */
- php_handle_aborted_connection();
- }
- return sent_bytes;
-}
-
-/*
- * php_roxen_sapi_ub_write() calls php_roxen_low_ub_write in a Pike thread
- * safe manner.
- */
-
-static int
-php_roxen_sapi_ub_write(const char *str, uint str_length)
-{
-#ifdef ROXEN_USE_ZTS
- GET_THIS();
-#endif
-
- int sent_bytes = 0, fd = MY_FD;
- if(fd)
- {
- for(sent_bytes=0;sent_bytes < str_length;)
- {
- int written;
- written = fd_write(fd, str + sent_bytes, str_length - sent_bytes);
- if(written < 0)
- {
- switch(errno)
- {
- default:
- /* This means the connection is closed. Dead. Gone. *sniff* */
- PG(connection_status) = PHP_CONNECTION_ABORTED;
- zend_bailout();
- return sent_bytes;
- case EINTR:
- case EWOULDBLOCK:
- continue;
- }
-
- } else {
- sent_bytes += written;
- }
- }
- } else {
- THREAD_SAFE_RUN(sent_bytes = php_roxen_low_ub_write(str, str_length),
- "write");
- }
- return sent_bytes;
-}
-
-/* php_roxen_set_header() sets a header in the header mapping. Called in a
- * thread safe manner from php_roxen_sapi_header_handler.
- */
-static void php_roxen_set_header(char *header_name, char *value, char *p)
-{
- struct svalue hsval;
- struct pike_string *hval, *ind, *hind;
- struct mapping *headermap;
- struct svalue *s_headermap;
-#ifdef ROXEN_USE_ZTS
- GET_THIS();
-#endif
- hval = make_shared_string(value);
- ind = make_shared_string(" _headers");
- hind = make_shared_binary_string(header_name,
- (int)(p - header_name));
-
- s_headermap = low_mapping_string_lookup(REQUEST_DATA, ind);
- if(!s_headermap)
- {
- struct svalue mappie;
- mappie.type = PIKE_T_MAPPING;
- headermap = allocate_mapping(1);
- mappie.u.mapping = headermap;
- mapping_string_insert(REQUEST_DATA, ind, &mappie);
- free_mapping(headermap);
- } else
- headermap = s_headermap->u.mapping;
-
- hsval.type = PIKE_T_STRING;
- hsval.u.string = hval;
- mapping_string_insert(headermap, hind, &hsval);
-
- free_string(hval);
- free_string(ind);
- free_string(hind);
-}
-
-/*
- * php_roxen_sapi_header_handler() sets a HTTP reply header to be
- * sent to the client.
- */
-static int
-php_roxen_sapi_header_handler(sapi_header_struct *sapi_header,
- sapi_headers_struct *sapi_headers)
-{
- char *header_name, *header_content, *p;
- header_name = sapi_header->header;
- header_content = p = strchr(header_name, ':');
-
- if(p) {
- do {
- header_content++;
- } while(*header_content == ' ');
- THREAD_SAFE_RUN(php_roxen_set_header(header_name, header_content, p), "header handler");
- }
- sapi_free_header(sapi_header);
- return 0;
-}
-
-/*
- * php_roxen_sapi_send_headers() flushes the headers to the client.
- * Called before real content is sent by PHP.
- */
-
-static int
-php_roxen_low_send_headers(sapi_headers_struct *sapi_headers)
-{
- struct pike_string *ind;
- struct svalue *s_headermap;
-#ifdef ROXEN_USE_ZTS
- GET_THIS();
-#endif
-
- if(!MY_FD_OBJ->prog) {
- PG(connection_status) = PHP_CONNECTION_ABORTED;
- zend_bailout();
- return SAPI_HEADER_SEND_FAILED;
- }
- ind = make_shared_string(" _headers");
- s_headermap = low_mapping_string_lookup(REQUEST_DATA, ind);
- free_string(ind);
-
- push_int(SG(sapi_headers).http_response_code);
- if(s_headermap && s_headermap->type == PIKE_T_MAPPING)
- ref_push_mapping(s_headermap->u.mapping);
- else
- push_int(0);
- safe_apply(MY_FD_OBJ, "send_headers", 2);
- pop_stack();
-
- return SAPI_HEADER_SENT_SUCCESSFULLY;
-}
-
-static int
-php_roxen_sapi_send_headers(sapi_headers_struct *sapi_headers)
-{
- int res = 0;
- THREAD_SAFE_RUN(res = php_roxen_low_send_headers(sapi_headers), "send headers");
- return res;
-}
-
-/*
- * php_roxen_sapi_read_post() reads a specified number of bytes from
- * the client. Used for POST/PUT requests.
- */
-
-INLINE static int php_roxen_low_read_post(char *buf, uint count_bytes)
-{
- uint total_read = 0;
-#ifdef ROXEN_USE_ZTS
- GET_THIS();
-#endif
-
- if(!MY_FD_OBJ->prog)
- {
- PG(connection_status) = PHP_CONNECTION_ABORTED;
- zend_bailout();
- return -1;
- }
- push_int(count_bytes);
- safe_apply(MY_FD_OBJ, "read_post", 1);
- if(Pike_sp[-1].type == PIKE_T_STRING) {
- MEMCPY(buf, Pike_sp[-1].u.string->str,
- (total_read = Pike_sp[-1].u.string->len));
- buf[total_read] = '\0';
- } else
- total_read = 0;
- pop_stack();
- return total_read;
-}
-
-static int
-php_roxen_sapi_read_post(char *buf, uint count_bytes)
-{
- uint total_read = 0;
- THREAD_SAFE_RUN(total_read = php_roxen_low_read_post(buf, count_bytes), "read post");
- return total_read;
-}
-
-/*
- * php_roxen_sapi_read_cookies() returns the Cookie header from
- * the HTTP request header
- */
-
-static char *
-php_roxen_sapi_read_cookies(void)
-{
- char *cookies;
- cookies = lookup_string_header("HTTP_COOKIE", NULL);
- return cookies;
-}
-
-static void php_info_roxen(ZEND_MODULE_INFO_FUNC_ARGS)
-{
- /* char buf[512]; */
- php_info_print_table_start();
- php_info_print_table_row(2, "SAPI module version", "$Id$");
- /* php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
- php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
- php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
- php_info_print_table_row(2, "Installation path", Ns_InfoHomePath());
- php_info_print_table_row(2, "Hostname of server", Ns_InfoHostname());
- php_info_print_table_row(2, "Source code label", Ns_InfoLabel());
- php_info_print_table_row(2, "Server platform", Ns_InfoPlatform());
- snprintf(buf, 511, "%s/%s", Ns_InfoServerName(), Ns_InfoServerVersion());
- php_info_print_table_row(2, "Server version", buf);
- snprintf(buf, 511, "%d day(s), %02d:%02d:%02d",
- uptime / 86400,
- (uptime / 3600) % 24,
- (uptime / 60) % 60,
- uptime % 60);
- php_info_print_table_row(2, "Server uptime", buf);
- */
- php_info_print_table_end();
-}
-
-static zend_module_entry php_roxen_module = {
- STANDARD_MODULE_HEADER,
- "Roxen",
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- php_info_roxen,
- NULL,
- STANDARD_MODULE_PROPERTIES
-};
-
-static int php_roxen_startup(sapi_module_struct *sapi_module)
-{
- if(php_module_startup(sapi_module, &php_roxen_module, 1) == FAILURE) {
- return FAILURE;
- } else {
- return SUCCESS;
- }
-}
-
-/* this structure is static (as in "it does not change") */
-
-static sapi_module_struct roxen_sapi_module = {
- "roxen",
- "Roxen",
- php_roxen_startup, /* startup */
- php_module_shutdown_wrapper, /* shutdown */
- NULL, /* activate */
- NULL, /* deactivate */
- php_roxen_sapi_ub_write, /* unbuffered write */
- NULL, /* flush */
- NULL, /* get uid */
- NULL, /* getenv */
- php_error, /* error handler */
- php_roxen_sapi_header_handler, /* header handler */
- php_roxen_sapi_send_headers, /* send headers handler */
- NULL, /* send header handler */
- php_roxen_sapi_read_post, /* read POST data */
- php_roxen_sapi_read_cookies, /* read Cookies */
- NULL, /* register server variables */
- NULL, /* Log message */
- NULL, /* Get request time */
- NULL, /* Child terminate */
-
- STANDARD_SAPI_MODULE_PROPERTIES
-};
-
-/*
- * php_roxen_hash_environment() populates the php script environment
- * with a number of variables. HTTP_* variables are created for
- * the HTTP header data, so that a script can access these.
- */
-#define ADD_STRING(name) \
- MAKE_STD_ZVAL(zvalue); \
- zvalue->type = IS_STRING; \
- zvalue->value.str.len = strlen(buf); \
- zvalue->value.str.val = estrndup(buf, zvalue->value.str.len); \
- zend_hash_update(&EG(symbol_table), name, sizeof(name), \
- &zvalue, sizeof(zval *), NULL)
-
-static void
-php_roxen_hash_environment(void)
-{
- int i;
- char buf[512];
- zval *zvalue;
- struct svalue *headers;
- struct pike_string *sind;
- struct array *indices;
- struct svalue *ind, *val;
-#ifdef ROXEN_USE_ZTS
- GET_THIS();
-#endif
- sind = make_shared_string("env");
- headers = low_mapping_string_lookup(REQUEST_DATA, sind);
- free_string(sind);
- if(headers && headers->type == PIKE_T_MAPPING) {
- indices = mapping_indices(headers->u.mapping);
- for(i = 0; i < indices->size; i++) {
- ind = &indices->item[i];
- val = low_mapping_lookup(headers->u.mapping, ind);
- if(ind && ind->type == PIKE_T_STRING &&
- val && val->type == PIKE_T_STRING) {
- int buf_len;
- buf_len = MIN(511, ind->u.string->len);
- strncpy(buf, ind->u.string->str, buf_len);
- buf[buf_len] = '\0'; /* Terminate correctly */
- MAKE_STD_ZVAL(zvalue);
- zvalue->type = IS_STRING;
- zvalue->value.str.len = val->u.string->len;
- zvalue->value.str.val = estrndup(val->u.string->str, zvalue->value.str.len);
-
- zend_hash_update(&EG(symbol_table), buf, buf_len + 1, &zvalue, sizeof(zval *), NULL);
- }
- }
- free_array(indices);
- }
-
- /*
- MAKE_STD_ZVAL(zvalue);
- zvalue->type = IS_LONG;
- zvalue->value.lval = Ns_InfoBootTime();
- zend_hash_update(&EG(symbol_table), "SERVER_BOOTTIME", sizeof("SERVER_BOOTTIME"), &zvalue, sizeof(zval *), NULL);
- */
-}
-
-/*
- * php_roxen_module_main() is called by the per-request handler and
- * "executes" the script
- */
-
-static int php_roxen_module_main(void)
-{
- int res, len;
- char *dir;
- zend_file_handle file_handle;
-#ifdef ROXEN_USE_ZTS
- GET_THIS();
-#endif
-
- file_handle.type = ZEND_HANDLE_FILENAME;
- file_handle.filename = THIS->filename;
- file_handle.free_filename = 0;
- file_handle.opened_path = NULL;
-
- THREADS_ALLOW();
- res = php_request_startup();
- THREADS_DISALLOW();
- if(res == FAILURE) {
- return 0;
- }
- php_roxen_hash_environment();
- THREADS_ALLOW();
- php_execute_script(&file_handle);
- php_request_shutdown(NULL);
- THREADS_DISALLOW();
- return 1;
-}
-
-/*
- * The php_roxen_request_handler() is called per request and handles
- * everything for one request.
- */
-
-void f_php_roxen_request_handler(INT32 args)
-{
- struct object *my_fd_obj;
- struct mapping *request_data;
- struct svalue *done_callback, *raw_fd;
- struct pike_string *script, *ind;
- int status = 1;
-#ifdef ROXEN_USE_ZTS
- GET_THIS();
-#endif
-
- if(current_thread == th_self())
- php_error(E_WARNING, "PHP7.Interpreter->run: Tried to run a PHP-script from a PHP "
- "callback!");
- get_all_args("PHP7.Interpreter->run", args, "%S%m%O%*", &script,
- &request_data, &my_fd_obj, &done_callback);
- if(done_callback->type != PIKE_T_FUNCTION)
- php_error(E_WARNING, "PHP7.Interpreter->run: Bad argument 4, expected function.\n");
- PHP_LOCK(THIS); /* Need to lock here or reusing the same object might cause
- * problems in changing stuff in that object */
-#ifndef ROXEN_USE_ZTS
- GET_THIS();
-#endif
- THIS->request_data = request_data;
- THIS->my_fd_obj = my_fd_obj;
- THIS->filename = script->str;
- current_thread = th_self();
- SG(request_info).query_string = lookup_string_header("QUERY_STRING", 0);
- SG(server_context) = (void *)1; /* avoid server_context == NULL */
-
- /* path_translated is apparently the absolute path to the file, not
- the translated PATH_INFO
- */
- SG(request_info).path_translated =
- lookup_string_header("SCRIPT_FILENAME", NULL);
- SG(request_info).request_uri = lookup_string_header("DOCUMENT_URI", NULL);
- if(!SG(request_info).request_uri)
- SG(request_info).request_uri = lookup_string_header("SCRIPT_NAME", NULL);
- SG(request_info).request_method = lookup_string_header("REQUEST_METHOD", "GET");
- SG(request_info).content_length = lookup_integer_header("HTTP_CONTENT_LENGTH", 0);
- SG(request_info).content_type = lookup_string_header("HTTP_CONTENT_TYPE", NULL);
- SG(sapi_headers).http_response_code = 200;
-
- /* FIXME: Check for auth stuff needs to be fixed... */
- SG(request_info).auth_user = NULL;
- SG(request_info).auth_password = NULL;
-
- ind = make_shared_binary_string("my_fd", 5);
- raw_fd = low_mapping_string_lookup(THIS->request_data, ind);
- if(raw_fd && raw_fd->type == PIKE_T_OBJECT)
- {
- int fd = fd_from_object(raw_fd->u.object);
- if(fd == -1)
- php_error(E_WARNING, "PHP7.Interpreter->run: my_fd object not open or not an FD.\n");
- THIS->my_fd = fd;
- } else
- THIS->my_fd = 0;
-
- status = php_roxen_module_main();
- current_thread = -1;
-
- apply_svalue(done_callback, 0);
- pop_stack();
- pop_n_elems(args);
- push_int(status);
- PHP_UNLOCK(THIS);
-}
-
-
-/* Clear the object global struct */
-static void clear_struct(struct object *o)
-{
- MEMSET(Pike_fp->current_storage, 0, sizeof(php_roxen_request));
-}
-
-
-/*
- * pike_module_init() is called by Pike once at startup
- *
- * This functions allocates basic structures
- */
-
-void pike_module_init( void )
-{
- if (!roxen_php_initialized) {
-#ifdef ZTS
- tsrm_startup(1, 1, 0, NULL);
-#ifdef ROXEN_USE_ZTS
- ts_allocate_id(&roxen_globals_id, sizeof(php_roxen_request), NULL, NULL);
-#endif
-#endif
- sapi_startup(&roxen_sapi_module);
- /*php_roxen_startup(&roxen_sapi_module); removed - should be called from SAPI activation*/
- roxen_php_initialized = 1;
- PHP_INIT_LOCK();
- }
- start_new_program(); /* Text */
- ADD_STORAGE(php_roxen_request);
- set_init_callback(clear_struct);
- pike_add_function("run", f_php_roxen_request_handler,
- "function(string, mapping, object, function:int)", 0);
- add_program_constant("Interpreter", (php_program = end_program()), 0);
-}
-
-/*
- * pike_module_exit() performs the last steps before the
- * server exists. Shutdowns basic services and frees memory
- */
-
-void pike_module_exit(void)
-{
- roxen_php_initialized = 0;
- roxen_sapi_module.shutdown(&roxen_sapi_module);
- if(php_program) free_program(php_program);
-#ifdef ZTS
- tsrm_shutdown();
-#endif
- PHP_DESTROY();
-}
-#endif
diff --git a/sapi/thttpd/CREDITS b/sapi/thttpd/CREDITS
deleted file mode 100644
index 8f02f36f4f..0000000000
--- a/sapi/thttpd/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-thttpd
-Sascha Schumann
diff --git a/sapi/thttpd/README b/sapi/thttpd/README
deleted file mode 100644
index 1e80a01956..0000000000
--- a/sapi/thttpd/README
+++ /dev/null
@@ -1,85 +0,0 @@
-README FOR THTTPD MODULE (by Sascha Schumann)
-($Date$)
-
- This is a SAPI module for PHP 4.x supporting thttpd, the tiny,
- turbo, throttling HTTP server by Jef Poskanzer.
-
- NOTE: All HTTP requests will be serialized. That means, one long running
- script will block all other requests. Choose another web server,
- if you want to execute arbitrarily long running scripts.
-
- The module contains a patch against version 2.21b of thttpd. The patch
- fixes a number of bugs and adds some functionality:
-
- - HTTP/1.1 Persistent Connection/Pipeline Support
- - PHP Scripting (**.php by default)
- - Highlighting PHP Scripts (**.phps by default)
- - Fast Accept Loop (unique to PHP)
- - Periodic Connection Expiring (unique to PHP)
- - Log to stdout (logfile=-)
- - Fixes the Host: header vulnerability (affects vhosts only)
- - Asynchronous request body handling (e.g. for POSTs)
- - Accept filter for Linux
- - Fix for non-blocking sending of thttpd-generated responses
-
- You can configure the filename extensions by creating a config file for
- thttpd and setting these entries:
-
- phppat=PATTERN
- phpspat=PATTERN
-
- The PATTERN has the same format as defined here:
-
- http://acme.com/software/thttpd/options.html#CGI_PATTERN
-
- "**.php" means: match any file ending in .php in any directory.
- Setting the pattern from the command line is not supported.
-
- NOTE: This version supports *only* thttpd 2.21b, no prior or later
- version.
-
- This is a functional and stable module (it runs a large application
- like IMP 2.2.0 without any problems). Its original intention was to
- demonstrate the ability of PHP to work in every web server environment.
-
-REQUIRED DOWNLOADS
-
- 1. thttpd 2.21b (2.20 or +2.22beta will _not_ work)
-
- Full Distribution:
- http://www.acme.com/software/thttpd/thttpd-2.21b.tar.gz
-
- 2. PHP 4.x
-
- Download:
- http://www.php.net/
-
- Snapshots from CVS:
- http://snaps.php.net/
-
-
-BUILD INSTRUCTIONS
-
- 1. Extract software packages
-
- $ gunzip -c thttpd-2.xx.tar.gz | tar xf -
- $ gunzip -c php-*.tar.gz | tar xf -
-
- 2. Prepare PHP
-
- $ cd php-*
- $ ./configure \
- --with-thttpd=../thttpd-2.xx \
- <further PHP options>
- $ make install
- $ cd ..
-
- You can see the list of valid PHP options by executing
-
- $ ./configure --help
-
- 3. Configure, compile, install thttpd
-
- Now follow the thttpd instructions. The Makefile template of
- thttpd was changed to automatically use the components
- required by PHP.
diff --git a/sapi/thttpd/config.m4 b/sapi/thttpd/config.m4
deleted file mode 100644
index fddb709d92..0000000000
--- a/sapi/thttpd/config.m4
+++ /dev/null
@@ -1,39 +0,0 @@
-dnl
-dnl $Id$
-dnl
-
-PHP_ARG_WITH(thttpd,,
-[ --with-thttpd=SRCDIR Build PHP as thttpd module], no, no)
-
-AC_MSG_CHECKING([for thttpd])
-
-if test "$PHP_THTTPD" != "no"; then
- if test ! -d $PHP_THTTPD; then
- AC_MSG_RESULT(thttpd directory does not exist ($PHP_THTTPD))
- fi
-
- PHP_EXPAND_PATH($PHP_THTTPD, THTTPD)
-
- if grep thttpd.2.21b $PHP_THTTPD/version.h >/dev/null; then
- patch="test -f $THTTPD/php_patched || \
- (cd $THTTPD && patch -p1 < $abs_srcdir/sapi/thttpd/thttpd_patch && touch php_patched)"
-
- elif grep Premium $PHP_THTTPD/version.h >/dev/null; then
- patch=
- else
- AC_MSG_ERROR([This version only supports thttpd-2.21b and Premium thttpd])
- fi
- PHP_TARGET_RDYNAMIC
- INSTALL_IT="\
- echo 'PHP_LIBS = -L. -lphp7 \$(PHP_LIBS) \$(EXTRA_LIBS)' > $THTTPD/php_makefile; \
- echo 'PHP_LDFLAGS = \$(NATIVE_RPATHS) \$(PHP_LDFLAGS)' >> $THTTPD/php_makefile; \
- echo 'PHP_CFLAGS = \$(COMMON_FLAGS) \$(CFLAGS_CLEAN) \$(CPPFLAGS) \$(EXTRA_CFLAGS)' >> $THTTPD/php_makefile; \
- rm -f $THTTPD/php_thttpd.c $THTTPD/php_thttpd.h $THTTPD/libphp7.a; \
- \$(LN_S) $abs_srcdir/sapi/thttpd/thttpd.c $THTTPD/php_thttpd.c; \
- \$(LN_S) $abs_srcdir/sapi/thttpd/php_thttpd.h $abs_builddir/$SAPI_STATIC $THTTPD/;\
- $patch"
- PHP_THTTPD="yes, using $THTTPD"
- PHP_ADD_INCLUDE($THTTPD)
- PHP_SELECT_SAPI(thttpd, static)
-fi
-AC_MSG_RESULT($PHP_THTTPD)
diff --git a/sapi/thttpd/php.sym b/sapi/thttpd/php.sym
deleted file mode 100644
index 2214d3964d..0000000000
--- a/sapi/thttpd/php.sym
+++ /dev/null
@@ -1,3 +0,0 @@
-thttpd_php_request
-thttpd_php_init
-thttpd_php_shutdown
diff --git a/sapi/thttpd/php_thttpd.h b/sapi/thttpd/php_thttpd.h
deleted file mode 100644
index ace252a356..0000000000
--- a/sapi/thttpd/php_thttpd.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.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_THTTPD_H
-#define PHP_THTTPD_H
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <libhttpd.h>
-
-void thttpd_php_shutdown(void);
-void thttpd_php_init(void);
-off_t thttpd_php_request(httpd_conn *hc, int show_source);
-
-void thttpd_register_on_close(void (*)(int));
-void thttpd_closed_conn(int fd);
-int thttpd_get_fd(void);
-void thttpd_set_dont_close(void);
-
-#endif
diff --git a/sapi/thttpd/stub.c b/sapi/thttpd/stub.c
deleted file mode 100644
index e69de29bb2..0000000000
--- a/sapi/thttpd/stub.c
+++ /dev/null
diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c
deleted file mode 100644
index ad4e8e366e..0000000000
--- a/sapi/thttpd/thttpd.c
+++ /dev/null
@@ -1,766 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.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> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#include "php.h"
-#include "SAPI.h"
-#include "php_main.h"
-#include "php_thttpd.h"
-#include "php_variables.h"
-#include "version.h"
-#include "php_ini.h"
-#include "zend_highlight.h"
-
-#include "zend_smart_str.h"
-
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#ifdef HAVE_GETNAMEINFO
-#include <sys/socket.h>
-#include <netdb.h>
-#endif
-
-typedef struct {
- httpd_conn *hc;
- void (*on_close)(int);
-
- size_t unconsumed_length;
- smart_str sbuf;
- int seen_cl;
- int seen_cn;
-} php_thttpd_globals;
-
-#define PHP_SYS_CALL(x) do { x } while (n == -1 && errno == EINTR)
-
-#ifdef PREMIUM_THTTPD
-# define do_keep_alive persistent
-#endif
-
-#ifdef ZTS
-static int thttpd_globals_id;
-#define TG(v) TSRMG(thttpd_globals_id, php_thttpd_globals *, v)
-#else
-static php_thttpd_globals thttpd_globals;
-#define TG(v) (thttpd_globals.v)
-#endif
-
-static int sapi_thttpd_ub_write(const char *str, uint str_length)
-{
- int n;
- uint sent = 0;
-
- if (TG(sbuf).c != 0) {
- smart_str_appendl_ex(&TG(sbuf), str, str_length, 1);
- return str_length;
- }
-
- while (str_length > 0) {
- PHP_SYS_CALL(n = send(TG(hc)->conn_fd, str, str_length, 0););
-
- if (n == -1) {
- if (errno == EAGAIN) {
- smart_str_appendl_ex(&TG(sbuf), str, str_length, 1);
-
- return sent + str_length;
- } else
- php_handle_aborted_connection();
- }
-
- TG(hc)->bytes_sent += n;
- str += n;
- sent += n;
- str_length -= n;
- }
-
- return sent;
-}
-
-#define COMBINE_HEADERS 64
-
-#if defined(IOV_MAX)
-# if IOV_MAX - 64 <= 0
-# define SERIALIZE_HEADERS
-# endif
-#endif
-
-static int do_writev(struct iovec *vec, int nvec, int len)
-{
- int n;
-
- assert(nvec <= IOV_MAX);
-
- if (TG(sbuf).c == 0) {
- PHP_SYS_CALL(n = writev(TG(hc)->conn_fd, vec, nvec););
-
- if (n == -1) {
- if (errno == EAGAIN) {
- n = 0;
- } else {
- php_handle_aborted_connection();
- }
- }
-
-
- TG(hc)->bytes_sent += n;
- } else {
- n = 0;
- }
-
- if (n < len) {
- int i;
-
- /* merge all unwritten data into sbuf */
- for (i = 0; i < nvec; vec++, i++) {
- /* has this vector been written completely? */
- if (n >= vec->iov_len) {
- /* yes, proceed */
- n -= vec->iov_len;
- continue;
- }
-
- if (n > 0) {
- /* adjust vector */
- vec->iov_base = (char *) vec->iov_base + n;
- vec->iov_len -= n;
- n = 0;
- }
-
- smart_str_appendl_ex(&TG(sbuf), vec->iov_base, vec->iov_len, 1);
- }
- }
-
- return 0;
-}
-
-#ifdef SERIALIZE_HEADERS
-# define ADD_VEC(str,l) smart_str_appendl(&vec_str, (str), (l))
-# define VEC_BASE() smart_str vec_str = {0}
-# define VEC_FREE() smart_str_free(&vec_str)
-#else
-# define ADD_VEC(str,l) vec[n].iov_base=str;len += (vec[n].iov_len=l); n++
-# define VEC_BASE() struct iovec vec[COMBINE_HEADERS]
-# define VEC_FREE() do {} while (0)
-#endif
-
-#define ADD_VEC_S(str) ADD_VEC((str), sizeof(str)-1)
-
-#define CL_TOKEN "Content-length: "
-#define CN_TOKEN "Connection: "
-#define KA_DO "Connection: keep-alive\r\n"
-#define KA_NO "Connection: close\r\n"
-#define DEF_CT "Content-Type: text/html\r\n"
-
-static int sapi_thttpd_send_headers(sapi_headers_struct *sapi_headers)
-{
- char buf[1024], *p;
- VEC_BASE();
- int n = 0;
- zend_llist_position pos;
- sapi_header_struct *h;
- size_t len = 0;
-
- if (!SG(sapi_headers).http_status_line) {
- ADD_VEC_S("HTTP/1.1 ");
- p = zend_print_long_to_buf(buf+sizeof(buf)-1,
- SG(sapi_headers).http_response_code);
- ADD_VEC(p, strlen(p));
- ADD_VEC_S(" HTTP\r\n");
- } else {
- ADD_VEC(SG(sapi_headers).http_status_line,
- strlen(SG(sapi_headers).http_status_line));
- ADD_VEC("\r\n", 2);
- }
- TG(hc)->status = SG(sapi_headers).http_response_code;
-
- if (SG(sapi_headers).send_default_content_type) {
- ADD_VEC(DEF_CT, strlen(DEF_CT));
- }
-
- h = zend_llist_get_first_ex(&sapi_headers->headers, &pos);
- while (h) {
-
- switch (h->header[0]) {
- case 'c': case 'C':
- if (!TG(seen_cl) && strncasecmp(h->header, CL_TOKEN, sizeof(CL_TOKEN)-1) == 0) {
- TG(seen_cl) = 1;
- } else if (!TG(seen_cn) && strncasecmp(h->header, CN_TOKEN, sizeof(CN_TOKEN)-1) == 0) {
- TG(seen_cn) = 1;
- }
- }
-
- ADD_VEC(h->header, h->header_len);
-#ifndef SERIALIZE_HEADERS
- if (n >= COMBINE_HEADERS - 1) {
- len = do_writev(vec, n, len);
- n = 0;
- }
-#endif
- ADD_VEC("\r\n", 2);
-
- h = zend_llist_get_next_ex(&sapi_headers->headers, &pos);
- }
-
- if (TG(seen_cl) && !TG(seen_cn) && TG(hc)->do_keep_alive) {
- ADD_VEC(KA_DO, sizeof(KA_DO)-1);
- } else {
- TG(hc)->do_keep_alive = 0;
- ADD_VEC(KA_NO, sizeof(KA_NO)-1);
- }
-
- ADD_VEC("\r\n", 2);
-
-#ifdef SERIALIZE_HEADERS
- sapi_thttpd_ub_write(vec_str.c, vec_str.len);
-#else
- do_writev(vec, n, len);
-#endif
-
- VEC_FREE();
-
- return SAPI_HEADER_SENT_SUCCESSFULLY;
-}
-
-/* to understand this, read cgi_interpose_input() in libhttpd.c */
-#define SIZEOF_UNCONSUMED_BYTES() (TG(hc)->read_idx - TG(hc)->checked_idx)
-#define CONSUME_BYTES(n) do { TG(hc)->checked_idx += (n); } while (0)
-
-
-static int sapi_thttpd_read_post(char *buffer, uint count_bytes)
-{
- size_t read_bytes = 0;
-
- if (TG(unconsumed_length) > 0) {
- read_bytes = MIN(TG(unconsumed_length), count_bytes);
- memcpy(buffer, TG(hc)->read_buf + TG(hc)->checked_idx, read_bytes);
- TG(unconsumed_length) -= read_bytes;
- CONSUME_BYTES(read_bytes);
- }
-
- return read_bytes;
-}
-
-static char *sapi_thttpd_read_cookies(void)
-{
- return TG(hc)->cookie;
-}
-
-#define BUF_SIZE 512
-#define ADD_STRING_EX(name,buf) \
- php_register_variable(name, buf, track_vars_array)
-#define ADD_STRING(name) ADD_STRING_EX((name), buf)
-
-static void sapi_thttpd_register_variables(zval *track_vars_array)
-{
- char buf[BUF_SIZE + 1];
- char *p;
-
- php_register_variable("PHP_SELF", SG(request_info).request_uri, track_vars_array);
- php_register_variable("SERVER_SOFTWARE", SERVER_SOFTWARE, track_vars_array);
- php_register_variable("GATEWAY_INTERFACE", "CGI/1.1", track_vars_array);
- php_register_variable("REQUEST_METHOD", (char *) SG(request_info).request_method, track_vars_array);
- php_register_variable("REQUEST_URI", SG(request_info).request_uri, track_vars_array);
- php_register_variable("PATH_TRANSLATED", SG(request_info).path_translated, track_vars_array);
-
- if (TG(hc)->one_one) {
- php_register_variable("SERVER_PROTOCOL", "HTTP/1.1", track_vars_array);
- } else {
- php_register_variable("SERVER_PROTOCOL", "HTTP/1.0", track_vars_array);
- }
-
- p = httpd_ntoa(&TG(hc)->client_addr);
-
- ADD_STRING_EX("REMOTE_ADDR", p);
- ADD_STRING_EX("REMOTE_HOST", p);
-
- ADD_STRING_EX("SERVER_PORT",
- zend_print_long_to_buf(buf + sizeof(buf) - 1,
- TG(hc)->hs->port));
-
- buf[0] = '/';
- memcpy(buf + 1, TG(hc)->pathinfo, strlen(TG(hc)->pathinfo) + 1);
- ADD_STRING("PATH_INFO");
-
- buf[0] = '/';
- memcpy(buf + 1, TG(hc)->origfilename, strlen(TG(hc)->origfilename) + 1);
- ADD_STRING("SCRIPT_NAME");
-
-#define CONDADD(name, field) \
- if (TG(hc)->field[0]) { \
- php_register_variable(#name, TG(hc)->field, track_vars_array); \
- }
-
- CONDADD(QUERY_STRING, query);
- CONDADD(HTTP_HOST, hdrhost);
- CONDADD(HTTP_REFERER, referer);
- CONDADD(HTTP_USER_AGENT, useragent);
- CONDADD(HTTP_ACCEPT, accept);
- CONDADD(HTTP_ACCEPT_LANGUAGE, acceptl);
- CONDADD(HTTP_ACCEPT_ENCODING, accepte);
- CONDADD(HTTP_COOKIE, cookie);
- CONDADD(CONTENT_TYPE, contenttype);
- CONDADD(REMOTE_USER, remoteuser);
- CONDADD(SERVER_PROTOCOL, protocol);
-
- if (TG(hc)->contentlength != -1) {
- ADD_STRING_EX("CONTENT_LENGTH",
- zend_print_long_to_buf(buf + sizeof(buf) - 1,
- TG(hc)->contentlength));
- }
-
- if (TG(hc)->authorization[0])
- php_register_variable("AUTH_TYPE", "Basic", track_vars_array);
-}
-
-static PHP_MINIT_FUNCTION(thttpd)
-{
- return SUCCESS;
-}
-
-static zend_module_entry php_thttpd_module = {
- STANDARD_MODULE_HEADER,
- "thttpd",
- NULL,
- PHP_MINIT(thttpd),
- NULL,
- NULL,
- NULL,
- NULL, /* info */
- NULL,
- STANDARD_MODULE_PROPERTIES
-};
-
-static int php_thttpd_startup(sapi_module_struct *sapi_module)
-{
-#if PHP_API_VERSION >= 20020918
- if (php_module_startup(sapi_module, &php_thttpd_module, 1) == FAILURE) {
-#else
- /* No here to zend_startup_module() as 5.6 and older does not have that parameter */
- if (php_module_startup(sapi_module) == FAILURE
- || zend_startup_module(&php_thttpd_module) == FAILURE) {
-#endif
- return FAILURE;
- }
- return SUCCESS;
-}
-
-static int sapi_thttpd_get_fd(int *nfd)
-{
- if (nfd) *nfd = TG(hc)->conn_fd;
- return SUCCESS;
-}
-
-static sapi_module_struct thttpd_sapi_module = {
- "thttpd",
- "thttpd",
-
- php_thttpd_startup,
- php_module_shutdown_wrapper,
-
- NULL, /* activate */
- NULL, /* deactivate */
-
- sapi_thttpd_ub_write,
- NULL,
- NULL, /* get uid */
- NULL, /* getenv */
-
- php_error,
-
- NULL,
- sapi_thttpd_send_headers,
- NULL,
- sapi_thttpd_read_post,
- sapi_thttpd_read_cookies,
-
- sapi_thttpd_register_variables,
- NULL, /* Log message */
- NULL, /* Get request time */
- NULL, /* Child terminate */
-
- NULL, /* php.ini path override */
- NULL, /* Block interruptions */
- NULL, /* Unblock interruptions */
-
- NULL,
- NULL,
- NULL,
- 0,
- sapi_thttpd_get_fd
-};
-
-static void thttpd_module_main(int show_source)
-{
- zend_file_handle file_handle;
-
- if (php_request_startup() == FAILURE) {
- return;
- }
-
- if (show_source) {
- zend_syntax_highlighter_ini syntax_highlighter_ini;
-
- php_get_highlight_struct(&syntax_highlighter_ini);
- highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini);
- } else {
- file_handle.type = ZEND_HANDLE_FILENAME;
- file_handle.filename = SG(request_info).path_translated;
- file_handle.free_filename = 0;
- file_handle.opened_path = NULL;
-
- php_execute_script(&file_handle);
- }
-
- php_request_shutdown(NULL);
-}
-
-static void thttpd_request_ctor(void)
-{
- smart_str s = {0};
-
- TG(seen_cl) = 0;
- TG(seen_cn) = 0;
- TG(sbuf).c = 0;
- SG(request_info).query_string = TG(hc)->query?strdup(TG(hc)->query):NULL;
-
- smart_str_appends_ex(&s, TG(hc)->hs->cwd, 1);
- smart_str_appends_ex(&s, TG(hc)->expnfilename, 1);
- smart_str_0(&s);
- SG(request_info).path_translated = s.c;
-
- s.c = NULL;
- smart_str_appendc_ex(&s, '/', 1);
- smart_str_appends_ex(&s, TG(hc)->origfilename, 1);
- smart_str_0(&s);
- SG(request_info).request_uri = s.c;
- SG(request_info).request_method = httpd_method_str(TG(hc)->method);
- if (TG(hc)->one_one) SG(request_info).proto_num = 1001;
- else SG(request_info).proto_num = 1000;
- SG(sapi_headers).http_response_code = 200;
- if (TG(hc)->contenttype)
- SG(request_info).content_type = strdup(TG(hc)->contenttype);
- SG(request_info).content_length = TG(hc)->contentlength == -1 ? 0
- : TG(hc)->contentlength;
-
- TG(unconsumed_length) = SG(request_info).content_length;
-
- php_handle_auth_data(TG(hc)->authorization);
-}
-
-static void thttpd_request_dtor(void)
-{
- smart_str_free(&TG(sbuf));
- if (SG(request_info).query_string)
- free(SG(request_info).query_string);
- free(SG(request_info).request_uri);
- free(SG(request_info).path_translated);
- if (SG(request_info).content_type)
- free(SG(request_info).content_type);
-}
-
-#ifdef ZTS
-
-#ifdef TSRM_ST
-#define thread_create_simple_detached(n) st_thread_create(n, NULL, 0, 0)
-#define thread_usleep(n) st_usleep(n)
-#define thread_exit() st_thread_exit(NULL)
-/* No preemption, simple operations are safe */
-#define thread_atomic_inc(n) (++n)
-#define thread_atomic_dec(n) (--n)
-#else
-#error No thread primitives available
-#endif
-
-/* We might want to replace this with a STAILQ */
-typedef struct qreq {
- httpd_conn *hc;
- struct qreq *next;
-} qreq_t;
-
-static MUTEX_T qr_lock;
-static qreq_t *queued_requests;
-static qreq_t *last_qr;
-static int nr_free_threads;
-static int nr_threads;
-static int max_threads = 50;
-
-#define HANDLE_STRINGS() { \
- HANDLE_STR(encodedurl); \
- HANDLE_STR(decodedurl); \
- HANDLE_STR(origfilename); \
- HANDLE_STR(expnfilename); \
- HANDLE_STR(pathinfo); \
- HANDLE_STR(query); \
- HANDLE_STR(referer); \
- HANDLE_STR(useragent); \
- HANDLE_STR(accept); \
- HANDLE_STR(accepte); \
- HANDLE_STR(acceptl); \
- HANDLE_STR(cookie); \
- HANDLE_STR(contenttype); \
- HANDLE_STR(authorization); \
- HANDLE_STR(remoteuser); \
- }
-
-static httpd_conn *duplicate_conn(httpd_conn *hc, httpd_conn *nhc)
-{
- memcpy(nhc, hc, sizeof(*nhc));
-
-#define HANDLE_STR(m) nhc->m = nhc->m ? strdup(nhc->m) : NULL
- HANDLE_STRINGS();
-#undef HANDLE_STR
-
- return nhc;
-}
-
-static void destroy_conn(httpd_conn *hc)
-{
-#define HANDLE_STR(m) if (hc->m) free(hc->m)
- HANDLE_STRINGS();
-#undef HANDLE_STR
-}
-
-static httpd_conn *dequeue_request(void)
-{
- httpd_conn *ret = NULL;
- qreq_t *m;
-
- tsrm_mutex_lock(qr_lock);
- if (queued_requests) {
- m = queued_requests;
- ret = m->hc;
- if (!(queued_requests = m->next))
- last_qr = NULL;
- free(m);
- }
- tsrm_mutex_unlock(qr_lock);
-
- return ret;
-}
-
-static void *worker_thread(void *);
-
-static void queue_request(httpd_conn *hc)
-{
- qreq_t *m;
- httpd_conn *nhc;
-
- /* Mark as long-running request */
- hc->file_address = (char *) 1;
-
- /*
- * We cannot synchronously revoke accesses to hc in the worker
- * thread, so we need to pass a copy of hc to the worker thread.
- */
- nhc = malloc(sizeof *nhc);
- duplicate_conn(hc, nhc);
-
- /* Allocate request queue container */
- m = malloc(sizeof *m);
- m->hc = nhc;
- m->next = NULL;
-
- tsrm_mutex_lock(qr_lock);
- /* Create new threads when reaching a certain threshold */
- if (nr_threads < max_threads && nr_free_threads < 2) {
- nr_threads++; /* protected by qr_lock */
-
- thread_atomic_inc(nr_free_threads);
- thread_create_simple_detached(worker_thread);
- }
- /* Insert container into request queue */
- if (queued_requests)
- last_qr->next = m;
- else
- queued_requests = m;
- last_qr = m;
- tsrm_mutex_unlock(qr_lock);
-}
-
-static off_t thttpd_real_php_request(httpd_conn *hc, int);
-
-static void *worker_thread(void *dummy)
-{
- int do_work = 50;
- httpd_conn *hc;
-
- while (do_work) {
- hc = dequeue_request();
-
- if (!hc) {
-/* do_work--; */
- thread_usleep(500000);
- continue;
- }
-/* do_work = 50; */
-
- thread_atomic_dec(nr_free_threads);
-
- thttpd_real_php_request(hc, 0);
- shutdown(hc->conn_fd, 0);
- destroy_conn(hc);
- free(hc);
-
- thread_atomic_inc(nr_free_threads);
- }
- thread_atomic_dec(nr_free_threads);
- thread_atomic_dec(nr_threads);
- thread_exit();
-}
-
-static void remove_dead_conn(int fd)
-{
- qreq_t *m, *prev = NULL;
-
- tsrm_mutex_lock(qr_lock);
- m = queued_requests;
- while (m) {
- if (m->hc->conn_fd == fd) {
- if (prev)
- if (!(prev->next = m->next))
- last_qr = prev;
- else
- if (!(queued_requests = m->next))
- last_qr = NULL;
- destroy_conn(m->hc);
- free(m->hc);
- free(m);
- break;
- }
- prev = m;
- m = m->next;
- }
- tsrm_mutex_unlock(qr_lock);
-}
-
-#endif
-
-static off_t thttpd_real_php_request(httpd_conn *hc, int show_source)
-{
- TG(hc) = hc;
- hc->bytes_sent = 0;
-
- if (hc->contentlength != -1) {
- hc->should_linger = 1;
- hc->do_keep_alive = 0;
- }
-
- if (hc->contentlength != -1
- && SIZEOF_UNCONSUMED_BYTES() < hc->contentlength) {
- hc->read_body_into_mem = 1;
- return 0;
- }
-
- thttpd_request_ctor();
-
- thttpd_module_main(show_source);
-
- /* disable kl, if no content-length was seen or Connection: was set */
- if (TG(seen_cl) == 0 || TG(seen_cn) == 1) {
- TG(hc)->do_keep_alive = 0;
- }
-
- if (TG(sbuf).c != 0) {
- if (TG(hc)->response)
- free(TG(hc)->response);
-
- TG(hc)->response = TG(sbuf).c;
- TG(hc)->responselen = TG(sbuf).len;
- TG(hc)->maxresponse = TG(sbuf).a;
-
- TG(sbuf).c = 0;
- TG(sbuf).len = 0;
- TG(sbuf).a = 0;
- }
-
- thttpd_request_dtor();
-
- return 0;
-}
-
-off_t thttpd_php_request(httpd_conn *hc, int show_source)
-{
-#ifdef ZTS
- queue_request(hc);
-#else
- return thttpd_real_php_request(hc, show_source);
-#endif
-}
-
-void thttpd_register_on_close(void (*arg)(int))
-{
- TG(on_close) = arg;
-}
-
-void thttpd_closed_conn(int fd)
-{
- if (TG(on_close)) TG(on_close)(fd);
-}
-
-int thttpd_get_fd(void)
-{
- return TG(hc)->conn_fd;
-}
-
-void thttpd_set_dont_close(void)
-{
-#ifndef PREMIUM_THTTPD
- TG(hc)->file_address = (char *) 1;
-#endif
-}
-
-
-void thttpd_php_init(void)
-{
- char *ini;
-
-#ifdef ZTS
- tsrm_startup(1, 1, 0, NULL);
- ts_allocate_id(&thttpd_globals_id, sizeof(php_thttpd_globals), NULL, NULL);
- qr_lock = tsrm_mutex_alloc();
- thttpd_register_on_close(remove_dead_conn);
-#endif
-
- if ((ini = getenv("PHP_INI_PATH"))) {
- thttpd_sapi_module.php_ini_path_override = ini;
- }
-
- sapi_startup(&thttpd_sapi_module);
- thttpd_sapi_module.startup(&thttpd_sapi_module);
-
- {
-
- SG(server_context) = (void *) 1;
- }
-}
-
-void thttpd_php_shutdown(void)
-{
-
- if (SG(server_context) != NULL) {
- thttpd_sapi_module.shutdown(&thttpd_sapi_module);
- sapi_shutdown();
-#ifdef ZTS
- tsrm_shutdown();
-#endif
- }
-}
diff --git a/sapi/thttpd/thttpd_patch b/sapi/thttpd/thttpd_patch
deleted file mode 100644
index 1463d8fe0a..0000000000
--- a/sapi/thttpd/thttpd_patch
+++ /dev/null
@@ -1,2377 +0,0 @@
-diff -ur thttpd-2.21b/Makefile.in thttpd-2.21b-cool/Makefile.in
---- thttpd-2.21b/Makefile.in Thu Mar 29 20:36:21 2001
-+++ thttpd-2.21b-cool/Makefile.in Sat Sep 20 14:43:20 2003
-@@ -46,13 +46,15 @@
-
- # You shouldn't need to edit anything below here.
-
-+include php_makefile
-+
- CC = @CC@
- CCOPT = @V_CCOPT@
- DEFS = @DEFS@
--INCLS = -I.
-+INCLS = -I. $(PHP_CFLAGS)
- CFLAGS = $(CCOPT) $(DEFS) $(INCLS)
--LDFLAGS = @LDFLAGS@
--LIBS = @LIBS@
-+LDFLAGS = @LDFLAGS@ $(PHP_LDFLAGS)
-+LIBS = @LIBS@ $(PHP_LIBS)
- NETLIBS = @V_NETLIBS@
- INSTALL = @INSTALL@
-
-@@ -62,7 +64,7 @@
- @rm -f $@
- $(CC) $(CFLAGS) -c $*.c
-
--SRC = thttpd.c libhttpd.c fdwatch.c mmc.c timers.c match.c tdate_parse.c syslog.c
-+SRC = thttpd.c libhttpd.c fdwatch.c mmc.c timers.c match.c tdate_parse.c syslog.c php_thttpd.c
-
- OBJ = $(SRC:.c=.o) @LIBOBJS@
-
-@@ -77,7 +79,7 @@
- all: this subdirs
- this: $(ALL)
-
--thttpd: $(OBJ)
-+thttpd: $(OBJ) libphp7.a
- @rm -f $@
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) $(NETLIBS)
-
-diff -ur thttpd-2.21b/config.h thttpd-2.21b-cool/config.h
---- thttpd-2.21b/config.h Mon Apr 9 23:57:36 2001
-+++ thttpd-2.21b-cool/config.h Sat Sep 20 14:43:20 2003
-@@ -82,6 +82,11 @@
- */
- #define IDLE_READ_TIMELIMIT 60
-
-+/* CONFIGURE: How many seconds to allow for reading the subsequent requests
-+** on a keep-alive connection. Should be simiar to LINGER_TIME
-+*/
-+#define IDLE_KEEPALIVE_TIMELIMIT 2
-+
- /* CONFIGURE: How many seconds before an idle connection gets closed.
- */
- #define IDLE_SEND_TIMELIMIT 300
-@@ -316,7 +321,7 @@
- /* CONFIGURE: A list of index filenames to check. The files are searched
- ** for in this order.
- */
--#define INDEX_NAMES "index.html", "index.htm", "Default.htm", "index.cgi"
-+#define INDEX_NAMES "index.php", "index.html", "index.htm", "Default.htm", "index.cgi"
-
- /* CONFIGURE: If this is defined then thttpd will automatically generate
- ** index pages for directories that don't have an explicit index file.
-diff -ur thttpd-2.21b/configure thttpd-2.21b-cool/configure
---- thttpd-2.21b/configure Sat Apr 21 02:07:14 2001
-+++ thttpd-2.21b-cool/configure Sat Sep 20 14:43:20 2003
-@@ -1021,7 +1021,7 @@
- fi
- echo "$ac_t""$CPP" 1>&6
-
--for ac_hdr in fcntl.h grp.h memory.h paths.h poll.h sys/poll.h sys/event.h osreldate.h
-+for ac_hdr in fcntl.h grp.h memory.h paths.h poll.h sys/poll.h sys/event.h osreldate.h netinet/tcp.h
- do
- ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
- echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-diff -ur thttpd-2.21b/configure.in thttpd-2.21b-cool/configure.in
---- thttpd-2.21b/configure.in Sat Apr 21 02:06:23 2001
-+++ thttpd-2.21b-cool/configure.in Sat Sep 20 14:43:20 2003
-@@ -64,7 +64,7 @@
- AC_MSG_RESULT(no)
- fi
-
--AC_CHECK_HEADERS(fcntl.h grp.h memory.h paths.h poll.h sys/poll.h sys/event.h osreldate.h)
-+AC_CHECK_HEADERS(fcntl.h grp.h memory.h paths.h poll.h sys/poll.h sys/event.h osreldate.h netinet/tcp.h)
- AC_HEADER_TIME
- AC_HEADER_DIRENT
-
-diff -ur thttpd-2.21b/fdwatch.c thttpd-2.21b-cool/fdwatch.c
---- thttpd-2.21b/fdwatch.c Fri Apr 13 07:36:08 2001
-+++ thttpd-2.21b-cool/fdwatch.c Sat Sep 20 14:43:20 2003
-@@ -419,6 +419,7 @@
- if ( pollfds == (struct pollfd*) 0 || poll_fdidx == (int*) 0 ||
- poll_rfdidx == (int*) 0 )
- return -1;
-+ memset(pollfds, 0, sizeof(struct pollfd) * nfiles);
- return 0;
- }
-
-@@ -460,7 +461,7 @@
-
- ridx = 0;
- for ( i = 0; i < npollfds; ++i )
-- if ( pollfds[i].revents & ( POLLIN | POLLOUT ) )
-+ if ( pollfds[i].revents & ( POLLIN | POLLOUT | POLLERR | POLLHUP | POLLNVAL ) )
- poll_rfdidx[ridx++] = pollfds[i].fd;
-
- return r;
-@@ -472,8 +473,8 @@
- {
- switch ( fd_rw[fd] )
- {
-- case FDW_READ: return pollfds[poll_fdidx[fd]].revents & POLLIN;
-- case FDW_WRITE: return pollfds[poll_fdidx[fd]].revents & POLLOUT;
-+ case FDW_READ: return pollfds[poll_fdidx[fd]].revents & ( POLLIN | POLLERR | POLLHUP | POLLNVAL );
-+ case FDW_WRITE: return pollfds[poll_fdidx[fd]].revents & ( POLLOUT | POLLERR | POLLHUP | POLLNVAL );
- default: return 0;
- }
- }
-diff -ur thttpd-2.21b/libhttpd.c thttpd-2.21b-cool/libhttpd.c
---- thttpd-2.21b/libhttpd.c Tue Apr 24 00:42:40 2001
-+++ thttpd-2.21b-cool/libhttpd.c Sat Sep 20 14:43:29 2003
-@@ -56,6 +56,10 @@
- #include <unistd.h>
- #include <stdarg.h>
-
-+#ifdef HAVE_NETINET_TCP_H
-+#include <netinet/tcp.h>
-+#endif
-+
- #ifdef HAVE_OSRELDATE_H
- #include <osreldate.h>
- #endif /* HAVE_OSRELDATE_H */
-@@ -85,6 +89,12 @@
- #include "match.h"
- #include "tdate_parse.h"
-
-+#include "php_thttpd.h"
-+
-+#ifdef __CYGWIN__
-+# define timezone _timezone
-+#endif
-+
- #ifndef STDIN_FILENO
- #define STDIN_FILENO 0
- #endif
-@@ -111,7 +121,7 @@
- static int initialize_listen_socket( httpd_sockaddr* saP );
- static void unlisten( httpd_server* hs );
- static void add_response( httpd_conn* hc, char* str );
--static void send_mime( httpd_conn* hc, int status, char* title, char* encodings, char* extraheads, char* type, int length, time_t mod );
-+static void send_mime( httpd_conn* hc, int status, char* title, char* encodings, char* extraheads, char* type, int length, time_t mod, const char *, size_t );
- static void send_response( httpd_conn* hc, int status, char* title, char* extraheads, char* form, char* arg );
- static void send_response_tail( httpd_conn* hc );
- static void defang( char* str, char* dfstr, int dfsize );
-@@ -242,6 +252,10 @@
- free( (void*) hs->cwd );
- if ( hs->cgi_pattern != (char*) 0 )
- free( (void*) hs->cgi_pattern );
-+ if ( hs->php_pattern != (char*) 0 )
-+ free( (void*) hs->php_pattern );
-+ if ( hs->phps_pattern != (char*) 0 )
-+ free( (void*) hs->phps_pattern );
- if ( hs->charset != (char*) 0 )
- free( (void*) hs->charset );
- if ( hs->url_pattern != (char*) 0 )
-@@ -249,6 +263,7 @@
- if ( hs->local_pattern != (char*) 0 )
- free( (void*) hs->local_pattern );
- free( (void*) hs );
-+ thttpd_php_shutdown();
- }
-
-
-@@ -257,7 +272,8 @@
- char* hostname, httpd_sockaddr* sa4P, httpd_sockaddr* sa6P, int port,
- char* cgi_pattern, char* charset, char* cwd, int no_log, FILE* logfp,
- int no_symlink, int vhost, int global_passwd, char* url_pattern,
-- char* local_pattern, int no_empty_referers )
-+ char* local_pattern, int no_empty_referers, char* php_pattern,
-+ char* phps_pattern )
- {
- httpd_server* hs;
- static char ghnbuf[256];
-@@ -312,6 +328,8 @@
- }
-
- hs->port = port;
-+ hs->php_pattern = strdup(php_pattern);
-+ hs->phps_pattern = strdup(phps_pattern);
- if ( cgi_pattern == (char*) 0 )
- hs->cgi_pattern = (char*) 0;
- else
-@@ -329,7 +347,7 @@
- while ( ( cp = strstr( hs->cgi_pattern, "|/" ) ) != (char*) 0 )
- (void) strcpy( cp + 1, cp + 2 );
- }
-- hs->charset = strdup( charset );
-+ hs->charset = strdup( charset );
- hs->cwd = strdup( cwd );
- if ( hs->cwd == (char*) 0 )
- {
-@@ -385,6 +403,8 @@
- return (httpd_server*) 0;
- }
-
-+ thttpd_php_init();
-+
- /* Done initializing. */
- if ( hs->binding_hostname == (char*) 0 )
- syslog( LOG_INFO, "%.80s starting on port %d", SERVER_SOFTWARE, hs->port );
-@@ -418,6 +438,11 @@
- }
- (void) fcntl( listen_fd, F_SETFD, 1 );
-
-+#if defined(TCP_DEFER_ACCEPT) && defined(SOL_TCP)
-+ on = 30; /* give clients 30s to send first data packet */
-+ setsockopt(listen_fd, SOL_TCP, TCP_DEFER_ACCEPT, &on, sizeof(on));
-+#endif
-+
- /* Allow reuse of local addresses. */
- on = 1;
- if ( setsockopt(
-@@ -582,6 +607,9 @@
- /* And send it, if necessary. */
- if ( hc->responselen > 0 )
- {
-+/*
-+printf("**RESPONSE [%d]** len = %d\n%*.*s\n", hc->conn_fd, hc->responselen, hc->responselen, hc->responselen, hc->response);
-+*/
- (void) write( hc->conn_fd, hc->response, hc->responselen );
- hc->responselen = 0;
- }
-@@ -619,18 +647,22 @@
- }
- }
-
-+extern time_t httpd_time_now;
-+extern char httpd_now_buf[];
-+
-+#define SMART_STR_USE_REALLOC
-+
-+#include "zend_smart_str.h"
-
- static void
--send_mime( httpd_conn* hc, int status, char* title, char* encodings, char* extraheads, char* type, int length, time_t mod )
-+send_mime( httpd_conn* hc, int status, char* title, char* encodings, char* extraheads, char* type, int length, time_t mod, const char *last_modified, size_t last_modified_len)
- {
-- time_t now;
- const char* rfc1123fmt = "%a, %d %b %Y %H:%M:%S GMT";
-- char nowbuf[100];
- char modbuf[100];
-- char fixed_type[500];
-- char buf[1000];
- int partial_content;
--
-+ smart_str s = {0};
-+ int type_len;
-+
- hc->status = status;
- hc->bytes_to_send = length;
- if ( hc->mime_flag )
-@@ -649,41 +681,89 @@
- else
- partial_content = 0;
-
-- now = time( (time_t*) 0 );
- if ( mod == (time_t) 0 )
-- mod = now;
-- (void) strftime( nowbuf, sizeof(nowbuf), rfc1123fmt, gmtime( &now ) );
-- (void) strftime( modbuf, sizeof(modbuf), rfc1123fmt, gmtime( &mod ) );
-- (void) my_snprintf(
-- fixed_type, sizeof(fixed_type), type, hc->hs->charset );
-- (void) my_snprintf( buf, sizeof(buf),
-- "%.20s %d %s\r\nServer: %s\r\nContent-Type: %s\r\nDate: %s\r\nLast-Modified: %s\r\nAccept-Ranges: bytes\r\nConnection: close\r\n",
-- hc->protocol, status, title, EXPOSED_SERVER_SOFTWARE, fixed_type,
-- nowbuf, modbuf );
-- add_response( hc, buf );
-+ mod = httpd_time_now;
-+
-+ if (last_modified == 0) {
-+ (void) strftime( modbuf, sizeof(modbuf), rfc1123fmt, gmtime( &mod ) );
-+ last_modified = modbuf;
-+ last_modified_len = strlen(modbuf);
-+ }
-+
-+ type_len = strlen(type);
-+
-+ if (hc->response) {
-+ s.c = hc->response;
-+ s.len = 0;
-+ s.a = hc->maxresponse;
-+ hc->response = 0;
-+ hc->maxresponse = 0;
-+ }
-+
-+ smart_str_appends(&s, "HTTP/1.1 ");
-+ smart_str_append_long(&s, status);
-+ smart_str_appends(&s, " HTTP\r\nServer: " EXPOSED_SERVER_SOFTWARE "\r\n"
-+ "Content-Type: ");
-+
-+ if (type[type_len-2] == '%' && type[type_len-1] == 's') {
-+ smart_str_appendl(&s, type, type_len - 2);
-+ smart_str_appends(&s, hc->hs->charset);
-+ } else {
-+ smart_str_appendl(&s, type, type_len);
-+ }
-+
-+
-+ smart_str_appends(&s, "\r\nDate: ");
-+ smart_str_appends(&s, httpd_now_buf);
-+ smart_str_appends(&s, "\r\nLast-Modified: ");
-+ smart_str_appendl(&s, last_modified, last_modified_len);
-+ smart_str_appends(&s, "\r\nAccept-Ranges: bytes\r\n");
-+
- if ( encodings[0] != '\0' )
- {
-- (void) my_snprintf( buf, sizeof(buf),
-- "Content-Encoding: %s\r\n", encodings );
-- add_response( hc, buf );
-+ smart_str_appends(&s, "Content-Encoding: ");
-+ smart_str_appends(&s, encodings);
-+ smart_str_appends(&s, "\r\n");
- }
- if ( partial_content )
- {
-- (void) my_snprintf( buf, sizeof(buf),
-- "Content-Range: bytes %ld-%ld/%d\r\nContent-Length: %ld\r\n",
-- (long) hc->init_byte_loc, (long) hc->end_byte_loc, length,
-- (long) ( hc->end_byte_loc - hc->init_byte_loc + 1 ) );
-- add_response( hc, buf );
-+
-+ smart_str_appends(&s, "Content-Range: bytes ");
-+ smart_str_append_long(&s, hc->init_byte_loc);
-+ smart_str_appendc(&s, '-');
-+ smart_str_append_long(&s, hc->end_byte_loc);
-+ smart_str_appendc(&s, '/');
-+ smart_str_append_long(&s, length);
-+ smart_str_appends(&s, "\r\nContent-Length: ");
-+ smart_str_append_long(&s, hc->end_byte_loc - hc->init_byte_loc + 1);
-+ smart_str_appends(&s, "\r\n");
-+
- }
- else if ( length >= 0 )
- {
-- (void) my_snprintf( buf, sizeof(buf),
-- "Content-Length: %d\r\n", length );
-- add_response( hc, buf );
-+ smart_str_appends(&s, "Content-Length: ");
-+ smart_str_append_long(&s, length);
-+ smart_str_appends(&s, "\r\n");
- }
-+ else {
-+ hc->do_keep_alive = 0;
-+ }
- if ( extraheads[0] != '\0' )
-- add_response( hc, extraheads );
-- add_response( hc, "\r\n" );
-+ smart_str_appends(&s, extraheads);
-+ if (hc->do_keep_alive) {
-+ smart_str_appends(&s, "Connection: keep-alive\r\n\r\n" );
-+ } else {
-+ smart_str_appends(&s, "Connection: close\r\n\r\n" );
-+ }
-+ smart_str_0(&s);
-+
-+ if (hc->response) {
-+ free(hc->response);
-+ }
-+ hc->response = s.c;
-+ hc->maxresponse = s.a;
-+ hc->responselen = s.len;
-+
- }
- }
-
-@@ -725,7 +805,7 @@
- {
- char defanged_arg[1000], buf[2000];
-
-- send_mime( hc, status, title, "", extraheads, "text/html", -1, 0 );
-+ send_mime( hc, status, title, "", extraheads, "text/html", -1, 0, 0, 0 );
- (void) my_snprintf( buf, sizeof(buf),
- "<HTML><HEAD><TITLE>%d %s</TITLE></HEAD>\n<BODY BGCOLOR=\"#cc9999\"><H2>%d %s</H2>\n",
- status, title, status, title );
-@@ -764,7 +844,7 @@
- char* cp2;
-
- for ( cp1 = str, cp2 = dfstr;
-- *cp1 != '\0' && cp2 - dfstr < dfsize - 1;
-+ *cp1 != '\0' && cp2 - dfstr < dfsize - 5;
- ++cp1, ++cp2 )
- {
- switch ( *cp1 )
-@@ -834,7 +914,7 @@
- fp = fopen( filename, "r" );
- if ( fp == (FILE*) 0 )
- return 0;
-- send_mime( hc, status, title, "", extraheads, "text/html", -1, 0 );
-+ send_mime( hc, status, title, "", extraheads, "text/html", -1, 0, 0, 0 );
- for (;;)
- {
- r = fread( buf, 1, sizeof(buf) - 1, fp );
-@@ -1336,6 +1416,9 @@
- if ( hc->tildemapped )
- return 1;
-
-+ if ( hc->hostname[0] == '.' || strchr( hc->hostname, '/' ) != (char*) 0 )
-+ return 0;
-+
- /* Figure out the host directory. */
- #ifdef VHOST_DIRLEVELS
- httpd_realloc_str(
-@@ -1436,7 +1519,7 @@
- restlen = strlen( path );
- httpd_realloc_str( &rest, &maxrest, restlen );
- (void) strcpy( rest, path );
-- if ( rest[restlen - 1] == '/' )
-+ if ( restlen > 0 && rest[restlen - 1] == '/' )
- rest[--restlen] = '\0'; /* trim trailing slash */
- if ( ! tildemapped )
- /* Remove any leading slashes. */
-@@ -1603,6 +1686,70 @@
-
-
- int
-+httpd_request_reset(httpd_conn* hc, int preserve_read_buf )
-+{
-+ if (!preserve_read_buf) {
-+ hc->read_idx = 0;
-+ hc->checked_idx = 0;
-+ }
-+
-+ if (hc->read_buf_is_mmap) {
-+ hc->read_buf_is_mmap = 0;
-+ munmap(hc->read_buf, hc->read_size);
-+ hc->read_buf = NULL;
-+ hc->read_size = 0;
-+ httpd_realloc_str( &hc->read_buf, &hc->read_size, 500 );
-+ }
-+ hc->checked_state = CHST_FIRSTWORD;
-+ hc->method = METHOD_UNKNOWN;
-+ hc->status = 0;
-+ hc->bytes_to_send = 0;
-+ hc->bytes_sent = 0;
-+ hc->encodedurl = "";
-+ hc->decodedurl[0] = '\0';
-+ hc->protocol = "UNKNOWN";
-+ hc->origfilename[0] = '\0';
-+ hc->expnfilename[0] = '\0';
-+ hc->encodings[0] = '\0';
-+ hc->pathinfo[0] = '\0';
-+ hc->query[0] = '\0';
-+ hc->referer = "";
-+ hc->useragent = "";
-+ hc->accept[0] = '\0';
-+ hc->accepte[0] = '\0';
-+ hc->acceptl = "";
-+ hc->cookie = "";
-+ hc->contenttype = "";
-+ hc->reqhost[0] = '\0';
-+ hc->hdrhost = "";
-+ hc->hostdir[0] = '\0';
-+ hc->authorization = "";
-+ hc->remoteuser[0] = '\0';
-+ hc->response[0] = '\0';
-+#ifdef TILDE_MAP_2
-+ hc->altdir[0] = '\0';
-+#endif /* TILDE_MAP_2 */
-+ hc->responselen = 0;
-+ hc->if_modified_since = (time_t) -1;
-+ hc->range_if = (time_t) -1;
-+ hc->contentlength = -1;
-+ hc->type = "";
-+ hc->hostname = (char*) 0;
-+ hc->mime_flag = 1;
-+ hc->one_one = 0;
-+ hc->got_range = 0;
-+ hc->tildemapped = 0;
-+ hc->init_byte_loc = 0;
-+ hc->end_byte_loc = -1;
-+ hc->keep_alive = 0;
-+ hc->do_keep_alive = 0;
-+ hc->should_linger = 0;
-+ hc->file_address = (char*) 0;
-+ hc->read_body_into_mem = 0;
-+ return GC_OK;
-+}
-+
-+int
- httpd_get_conn( httpd_server* hs, int listen_fd, httpd_conn* hc )
- {
- httpd_sockaddr sa;
-@@ -1612,6 +1759,7 @@
- {
- hc->read_size = 0;
- httpd_realloc_str( &hc->read_buf, &hc->read_size, 500 );
-+ hc->read_buf_is_mmap = 0;
- hc->maxdecodedurl =
- hc->maxorigfilename = hc->maxexpnfilename = hc->maxencodings =
- hc->maxpathinfo = hc->maxquery = hc->maxaccept =
-@@ -1631,12 +1779,19 @@
- httpd_realloc_str( &hc->reqhost, &hc->maxreqhost, 0 );
- httpd_realloc_str( &hc->hostdir, &hc->maxhostdir, 0 );
- httpd_realloc_str( &hc->remoteuser, &hc->maxremoteuser, 0 );
-- httpd_realloc_str( &hc->response, &hc->maxresponse, 0 );
-+ httpd_realloc_str( &hc->response, &hc->maxresponse, 350 );
- #ifdef TILDE_MAP_2
- httpd_realloc_str( &hc->altdir, &hc->maxaltdir, 0 );
- #endif /* TILDE_MAP_2 */
- hc->initialized = 1;
- }
-+ if (hc->read_buf_is_mmap) {
-+ hc->read_buf_is_mmap = 0;
-+ munmap(hc->read_buf, hc->read_size);
-+ hc->read_buf = NULL;
-+ hc->read_size = 0;
-+ httpd_realloc_str( &hc->read_buf, &hc->read_size, 500 );
-+ }
-
- /* Accept the new connection. */
- sz = sizeof(sa);
-@@ -1657,53 +1812,12 @@
- hc->hs = hs;
- memset( &hc->client_addr, 0, sizeof(hc->client_addr) );
- memcpy( &hc->client_addr, &sa, sockaddr_len( &sa ) );
-- hc->read_idx = 0;
-- hc->checked_idx = 0;
-- hc->checked_state = CHST_FIRSTWORD;
-- hc->method = METHOD_UNKNOWN;
-- hc->status = 0;
-- hc->bytes_to_send = 0;
-- hc->bytes_sent = 0;
-- hc->encodedurl = "";
-- hc->decodedurl[0] = '\0';
-- hc->protocol = "UNKNOWN";
-- hc->origfilename[0] = '\0';
-- hc->expnfilename[0] = '\0';
-- hc->encodings[0] = '\0';
-- hc->pathinfo[0] = '\0';
-- hc->query[0] = '\0';
-- hc->referer = "";
-- hc->useragent = "";
-- hc->accept[0] = '\0';
-- hc->accepte[0] = '\0';
-- hc->acceptl = "";
-- hc->cookie = "";
-- hc->contenttype = "";
-- hc->reqhost[0] = '\0';
-- hc->hdrhost = "";
-- hc->hostdir[0] = '\0';
-- hc->authorization = "";
-- hc->remoteuser[0] = '\0';
-- hc->response[0] = '\0';
--#ifdef TILDE_MAP_2
-- hc->altdir[0] = '\0';
--#endif /* TILDE_MAP_2 */
-- hc->responselen = 0;
-- hc->if_modified_since = (time_t) -1;
-- hc->range_if = (time_t) -1;
-- hc->contentlength = -1;
-- hc->type = "";
-- hc->hostname = (char*) 0;
-- hc->mime_flag = 1;
-- hc->one_one = 0;
-- hc->got_range = 0;
-- hc->tildemapped = 0;
-- hc->init_byte_loc = 0;
-- hc->end_byte_loc = -1;
-- hc->keep_alive = 0;
-- hc->should_linger = 0;
-- hc->file_address = (char*) 0;
-- return GC_OK;
-+
-+/*
-+printf("doing httpd_get_con(%d)\n", hc->conn_fd);
-+*/
-+
-+ return httpd_request_reset(hc, 0);
- }
-
-
-@@ -1720,6 +1834,9 @@
- {
- char c;
-
-+/*
-+printf("**REQUEST [%d]**\n%*.*s\n", hc->conn_fd, hc->read_idx, hc->read_idx, hc->read_buf);
-+*/
- for ( ; hc->checked_idx < hc->read_idx; ++hc->checked_idx )
- {
- c = hc->read_buf[hc->checked_idx];
-@@ -1912,8 +2029,11 @@
- eol = strpbrk( protocol, " \t\n\r" );
- if ( eol != (char*) 0 )
- *eol = '\0';
-- if ( strcasecmp( protocol, "HTTP/1.0" ) != 0 )
-+ if ( strcasecmp( protocol, "HTTP/1.0" ) != 0 ) {
- hc->one_one = 1;
-+ hc->keep_alive = 1;
-+ hc->do_keep_alive = 1;
-+ }
- }
- }
- /* Check for HTTP/1.1 absolute URL. */
-@@ -2129,6 +2249,7 @@
- cp = &buf[11];
- cp += strspn( cp, " \t" );
- if ( strcasecmp( cp, "keep-alive" ) == 0 )
-+ hc->do_keep_alive = 1;
- hc->keep_alive = 1;
- }
- #ifdef LOG_UNKNOWN_HEADERS
-@@ -2168,6 +2289,9 @@
- }
- }
-
-+/*
-+printf("one_one = %d keep_alive = %d\n", hc->one_one, hc->keep_alive);
-+*/
- if ( hc->one_one )
- {
- /* Check that HTTP/1.1 requests specify a host, as required. */
-@@ -2177,14 +2301,14 @@
- return -1;
- }
-
-- /* If the client wants to do keep-alives, it might also be doing
-- ** pipelining. There's no way for us to tell. Since we don't
-- ** implement keep-alives yet, if we close such a connection there
-- ** might be unread pipelined requests waiting. So, we have to
-- ** do a lingering close.
-+ /*
-+ ** Disable keep alive support for bad browsers,
-+ ** list taken from Apache 1.3.19
- */
-- if ( hc->keep_alive )
-- hc->should_linger = 1;
-+ if ( hc->do_keep_alive &&
-+ ( strstr(hc->useragent, "Mozilla/2") != NULL ||
-+ strstr(hc->useragent, "MSIE 4.0b2;") != NULL))
-+ hc->do_keep_alive = 0;
- }
-
- /* Ok, the request has been parsed. Now we resolve stuff that
-@@ -2349,15 +2473,24 @@
-
-
- void
--httpd_close_conn( httpd_conn* hc, struct timeval* nowP )
-- {
-- make_log_entry( hc, nowP );
-+httpd_complete_request( httpd_conn* hc, struct timeval* nowP)
-+{
-+ if (hc->method != METHOD_UNKNOWN)
-+ make_log_entry( hc, nowP );
-
-- if ( hc->file_address != (char*) 0 )
-+ if ( hc->file_address == (char*) 1 )
-+ {
-+ thttpd_closed_conn(hc->conn_fd);
-+ } else if ( hc->file_address != (char*) 0 )
- {
- mmc_unmap( hc->file_address, &(hc->sb), nowP );
- hc->file_address = (char*) 0;
- }
-+ }
-+
-+void
-+httpd_close_conn( httpd_conn* hc, struct timeval* nowP )
-+{
- if ( hc->conn_fd >= 0 )
- {
- (void) close( hc->conn_fd );
-@@ -2370,7 +2503,12 @@
- {
- if ( hc->initialized )
- {
-- free( (void*) hc->read_buf );
-+
-+ if ( hc->read_buf_is_mmap ) {
-+ munmap( hc->read_buf, hc->read_size );
-+ } else {
-+ free( (void*) hc->read_buf );
-+ }
- free( (void*) hc->decodedurl );
- free( (void*) hc->origfilename );
- free( (void*) hc->expnfilename );
-@@ -2556,7 +2694,7 @@
- return -1;
- }
-
-- send_mime( hc, 200, ok200title, "", "", "text/html", -1, hc->sb.st_mtime );
-+ send_mime( hc, 200, ok200title, "", "", "text/html", -1, hc->sb.st_mtime, 0, 0 );
- if ( hc->method == METHOD_HEAD )
- closedir( dirp );
- else if ( hc->method == METHOD_GET )
-@@ -3026,11 +3164,9 @@
- post_post_garbage_hack( httpd_conn* hc )
- {
- char buf[2];
-- int r;
-
-- r = recv( hc->conn_fd, buf, sizeof(buf), MSG_PEEK );
-- if ( r > 0 )
-- (void) read( hc->conn_fd, buf, r );
-+ fcntl(hc->conn_fd, F_SETFL, O_NONBLOCK);
-+ (void) read( hc->conn_fd, buf, 2 );
- }
-
-
-@@ -3313,6 +3449,11 @@
- int r;
- ClientData client_data;
-
-+ /*
-+ ** We are not going to leave the socket open after a CGI... too hard
-+ */
-+ hc->do_keep_alive = 0;
-+
- if ( hc->method == METHOD_GET || hc->method == METHOD_POST )
- {
- httpd_clear_ndelay( hc->conn_fd );
-@@ -3369,6 +3510,7 @@
- int expnlen, indxlen;
- char* cp;
- char* pi;
-+ int nocache = 0;
-
- expnlen = strlen( hc->expnfilename );
-
-@@ -3561,6 +3703,16 @@
- match( hc->hs->cgi_pattern, hc->expnfilename ) )
- return cgi( hc );
-
-+ if ( hc->hs->php_pattern != (char*) 0 &&
-+ match( hc->hs->php_pattern, hc->expnfilename)) {
-+ return thttpd_php_request( hc, 0 );
-+ }
-+
-+ if ( hc->hs->phps_pattern != (char*) 0 &&
-+ match( hc->hs->phps_pattern, hc->expnfilename)) {
-+ return thttpd_php_request( hc, 1 );
-+ }
-+
- /* It's not CGI. If it's executable or there's pathinfo, someone's
- ** trying to either serve or run a non-CGI file as CGI. Either case
- ** is prohibited.
-@@ -3594,32 +3746,46 @@
- hc->end_byte_loc = hc->sb.st_size - 1;
-
- figure_mime( hc );
-+ if ( strncmp(hc->decodedurl, "/nocache/", sizeof("/nocache/") - 1 ) == 0 )
-+ nocache = 1;
-
- if ( hc->method == METHOD_HEAD )
- {
- send_mime(
- hc, 200, ok200title, hc->encodings, "", hc->type, hc->sb.st_size,
-- hc->sb.st_mtime );
-+ hc->sb.st_mtime, 0, 0 );
- }
-- else if ( hc->if_modified_since != (time_t) -1 &&
-+ else if ( !nocache && hc->if_modified_since != (time_t) -1 &&
- hc->if_modified_since >= hc->sb.st_mtime )
- {
-- hc->method = METHOD_HEAD;
- send_mime(
-- hc, 304, err304title, hc->encodings, "", hc->type, hc->sb.st_size,
-- hc->sb.st_mtime );
-+ hc, 304, err304title, hc->encodings, "", hc->type, -1,
-+ hc->sb.st_mtime, 0, 0 );
- }
- else
- {
-- hc->file_address = mmc_map( hc->expnfilename, &(hc->sb), nowP );
-+ char *extraheads = "";
-+ char *lm;
-+ size_t lml;
-+
-+ if ( nocache )
-+ {
-+ extraheads = "Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\n"
-+ "Cache-Control: no-store, no-cache, must-revalidate, "
-+ "post-check=0, pre-check=0\r\n"
-+ "Pragma: no-cache\r\n";
-+ }
-+
-+ hc->file_address = mmc_map( hc->expnfilename, &(hc->sb), nowP, nocache, &lm, &lml );
- if ( hc->file_address == (char*) 0 )
- {
- httpd_send_err( hc, 500, err500title, "", err500form, hc->encodedurl );
- return -1;
- }
-+
- send_mime(
-- hc, 200, ok200title, hc->encodings, "", hc->type, hc->sb.st_size,
-- hc->sb.st_mtime );
-+ hc, 200, ok200title, hc->encodings, extraheads, hc->type, hc->sb.st_size,
-+ hc->sb.st_mtime, lm, lml );
- }
-
- return 0;
-@@ -3638,6 +3804,9 @@
- return r;
- }
-
-+#define smart_str_append_const(a,b) smart_str_appendl(a,b,sizeof(b)-1)
-+
-+static smart_str bentries;
-
- static void
- make_log_entry( httpd_conn* hc, struct timeval* nowP )
-@@ -3648,88 +3817,62 @@
-
- if ( hc->hs->no_log )
- return;
--
-- /* This is straight CERN Combined Log Format - the only tweak
-- ** being that if we're using syslog() we leave out the date, because
-- ** syslogd puts it in. The included syslogtocern script turns the
-- ** results into true CERN format.
-- */
--
- /* Format remote user. */
- if ( hc->remoteuser[0] != '\0' )
-- ru = hc->remoteuser;
-+ ru = hc->remoteuser;
- else
-- ru = "-";
-+ ru = "-";
- /* If we're vhosting, prepend the hostname to the url. This is
- ** a little weird, perhaps writing separate log files for
- ** each vhost would make more sense.
- */
-- if ( hc->hs->vhost && ! hc->tildemapped )
-- (void) my_snprintf( url, sizeof(url),
-- "/%.100s%.200s",
-- hc->hostname == (char*) 0 ? hc->hs->server_hostname : hc->hostname,
-- hc->encodedurl );
-- else
-- (void) my_snprintf( url, sizeof(url),
-- "%.200s", hc->encodedurl );
-- /* Format the bytes. */
-- if ( (long) hc->bytes_sent >= 0 )
-- (void) my_snprintf( bytes, sizeof(bytes),
-- "%ld", (long) hc->bytes_sent );
-- else
-- (void) strcpy( bytes, "-" );
-
- /* Logfile or syslog? */
- if ( hc->hs->logfp != (FILE*) 0 )
-- {
-- time_t now;
-- struct tm* t;
-- const char* cernfmt_nozone = "%d/%b/%Y:%H:%M:%S";
-- char date_nozone[100];
-- int zone;
-- char sign;
-- char date[100];
--
-- /* Get the current time, if necessary. */
-- if ( nowP != (struct timeval*) 0 )
-- now = nowP->tv_sec;
-- else
-- now = time( (time_t*) 0 );
-- /* Format the time, forcing a numeric timezone (some log analyzers
-- ** are stoooopid about this).
-- */
-- t = localtime( &now );
-- (void) strftime( date_nozone, sizeof(date_nozone), cernfmt_nozone, t );
--#ifdef HAVE_TM_GMTOFF
-- zone = t->tm_gmtoff / 60L;
--#else
-- zone = -timezone / 60L;
-- /* Probably have to add something about daylight time here. */
--#endif
-- if ( zone >= 0 )
-- sign = '+';
-- else
-- {
-- sign = '-';
-- zone = -zone;
-- }
-- zone = ( zone / 60 ) * 100 + zone % 60;
-- (void) my_snprintf( date, sizeof(date),
-- "%s %c%04d", date_nozone, sign, zone );
-- /* And write the log entry. */
-- (void) fprintf( hc->hs->logfp,
-- "%.80s - %.80s [%s] \"%.80s %.300s %.80s\" %d %s \"%.200s\" \"%.80s\"\n",
-- httpd_ntoa( &hc->client_addr ), ru, date,
-- httpd_method_str( hc->method ), url, hc->protocol,
-- hc->status, bytes, hc->referer, hc->useragent );
-- (void) fflush( hc->hs->logfp ); /* don't need to flush every time */
-- }
-- else
-- syslog( LOG_INFO,
-- "%.80s - %.80s \"%.80s %.200s %.80s\" %d %s \"%.200s\" \"%.80s\"",
-- httpd_ntoa( &hc->client_addr ), ru,
-- httpd_method_str( hc->method ), url, hc->protocol,
-- hc->status, bytes, hc->referer, hc->useragent );
-+ {
-+ /* XXXXXXX */
-+
-+ smart_str_appends(&bentries, httpd_ntoa(&hc->client_addr));
-+ smart_str_append_const(&bentries, " - ");
-+ smart_str_appends(&bentries, ru);
-+ smart_str_append_const(&bentries, " [");
-+ smart_str_appendl(&bentries, hc->hs->log_date, hc->hs->log_date_len);
-+ smart_str_append_const(&bentries, "] \"");
-+ smart_str_appends(&bentries, httpd_method_str(hc->method));
-+ smart_str_appendc(&bentries, ' ');
-+
-+ if (hc->hs->vhost && ! hc->tildemapped) {
-+ smart_str_appendc(&bentries, '/');
-+ if (hc->hostname)
-+ smart_str_appends(&bentries, hc->hostname);
-+ else
-+ smart_str_appends(&bentries, hc->hs->server_hostname);
-+ }
-+ smart_str_appends(&bentries, hc->encodedurl);
-+
-+ smart_str_appendc(&bentries, ' ');
-+ smart_str_appends(&bentries, hc->protocol);
-+ smart_str_append_const(&bentries, "\" ");
-+ smart_str_append_long(&bentries, hc->status);
-+ if (hc->bytes_sent >= 0) {
-+ smart_str_appendc(&bentries, ' ');
-+ smart_str_append_long(&bentries, hc->bytes_sent);
-+ smart_str_append_const(&bentries, " \"");
-+ } else {
-+ smart_str_append_const(&bentries, " - \"");
-+ }
-+ smart_str_appends(&bentries, hc->referer);
-+ smart_str_append_const(&bentries, "\" \"");
-+ smart_str_appends(&bentries, hc->useragent);
-+ smart_str_append_const(&bentries, "\"\n");
-+
-+ if (bentries.len > 16384) {
-+ int fd = fileno(hc->hs->logfp);
-+ write(fd, bentries.c, bentries.len);
-+ bentries.len = 0;
-+ }
-+ }
-+
- }
-
-
-@@ -3840,7 +3983,24 @@
- {
- #ifdef HAVE_GETNAMEINFO
- static char str[200];
-+ static smart_str httpd_ntoa_buf;
-+
-+ if (saP->sa_in.sin_family == AF_INET) {
-+ unsigned long n = ntohl(saP->sa_in.sin_addr.s_addr);
-
-+ httpd_ntoa_buf.len = 0;
-+ smart_str_append_long(&httpd_ntoa_buf, (n >> 24));
-+ smart_str_appendc(&httpd_ntoa_buf, '.');
-+ smart_str_append_long(&httpd_ntoa_buf, (n >> 16) & 255);
-+ smart_str_appendc(&httpd_ntoa_buf, '.');
-+ smart_str_append_long(&httpd_ntoa_buf, (n >> 8) & 255);
-+ smart_str_appendc(&httpd_ntoa_buf, '.');
-+ smart_str_append_long(&httpd_ntoa_buf, (n >> 0) & 255);
-+ smart_str_0(&httpd_ntoa_buf);
-+
-+ return httpd_ntoa_buf.c;
-+ }
-+
- if ( getnameinfo( &saP->sa, sockaddr_len( saP ), str, sizeof(str), 0, 0, NI_NUMERICHOST ) != 0 )
- {
- str[0] = '?';
-diff -ur thttpd-2.21b/libhttpd.h thttpd-2.21b-cool/libhttpd.h
---- thttpd-2.21b/libhttpd.h Tue Apr 24 00:36:50 2001
-+++ thttpd-2.21b-cool/libhttpd.h Sat Sep 20 14:43:20 2003
-@@ -69,6 +69,8 @@
- char* server_hostname;
- int port;
- char* cgi_pattern;
-+ char* php_pattern;
-+ char* phps_pattern;
- char* charset;
- char* cwd;
- int listen4_fd, listen6_fd;
-@@ -80,6 +82,8 @@
- char* url_pattern;
- char* local_pattern;
- int no_empty_referers;
-+ size_t log_date_len;
-+ char log_date[100];
- } httpd_server;
-
- /* A connection. */
-@@ -88,6 +92,7 @@
- httpd_server* hs;
- httpd_sockaddr client_addr;
- char* read_buf;
-+ char read_buf_is_mmap;
- int read_size, read_idx, checked_idx;
- int checked_state;
- int method;
-@@ -132,11 +137,12 @@
- int got_range;
- int tildemapped; /* this connection got tilde-mapped */
- off_t init_byte_loc, end_byte_loc;
-- int keep_alive;
-+ int keep_alive, do_keep_alive;
- int should_linger;
- struct stat sb;
- int conn_fd;
- char* file_address;
-+ char read_body_into_mem;
- } httpd_conn;
-
- /* Methods. */
-@@ -168,7 +174,8 @@
- char* hostname, httpd_sockaddr* sa4P, httpd_sockaddr* sa6P, int port,
- char* cgi_pattern, char* charset, char* cwd, int no_log, FILE* logfp,
- int no_symlink, int vhost, int global_passwd, char* url_pattern,
-- char* local_pattern, int no_empty_referers );
-+ char* local_pattern, int no_empty_referers, char* php_pattern,
-+ char* phps_pattern );
-
- /* Change the log file. */
- extern void httpd_set_logfp( httpd_server* hs, FILE* logfp );
-@@ -229,6 +236,8 @@
- ** If you don't have a current timeval handy just pass in 0.
- */
- extern void httpd_close_conn( httpd_conn* hc, struct timeval* nowP );
-+void httpd_complete_request( httpd_conn* hc, struct timeval* nowP);
-+int httpd_request_reset(httpd_conn* hc,int );
-
- /* Call this to de-initialize a connection struct and *really* free the
- ** mallocced strings.
-diff -ur thttpd-2.21b/mime_encodings.txt thttpd-2.21b-cool/mime_encodings.txt
---- thttpd-2.21b/mime_encodings.txt Wed May 10 03:22:28 2000
-+++ thttpd-2.21b-cool/mime_encodings.txt Sat Sep 20 14:43:20 2003
-@@ -3,6 +3,6 @@
- # A list of file extensions followed by the corresponding MIME encoding.
- # Extensions not found in the table proceed to the mime_types table.
-
--Z x-compress
--gz x-gzip
-+Z compress
-+gz gzip
- uu x-uuencode
-diff -ur thttpd-2.21b/mime_types.txt thttpd-2.21b-cool/mime_types.txt
---- thttpd-2.21b/mime_types.txt Sat Apr 14 04:53:30 2001
-+++ thttpd-2.21b-cool/mime_types.txt Sat Sep 20 14:43:20 2003
-@@ -1,135 +1,138 @@
--# mime_types.txt
--#
--# A list of file extensions followed by the corresponding MIME type.
--# Extensions not found in the table are returned as text/plain.
--
--html text/html; charset=%s
--htm text/html; charset=%s
--txt text/plain; charset=%s
--rtx text/richtext
--etx text/x-setext
--tsv text/tab-separated-values
--css text/css
--xml text/xml
--dtd text/xml
--
--gif image/gif
--jpg image/jpeg
--jpeg image/jpeg
--jpe image/jpeg
--jfif image/jpeg
--tif image/tiff
--tiff image/tiff
--pbm image/x-portable-bitmap
--pgm image/x-portable-graymap
--ppm image/x-portable-pixmap
--pnm image/x-portable-anymap
--xbm image/x-xbitmap
--xpm image/x-xpixmap
--xwd image/x-xwindowdump
--ief image/ief
--png image/png
--
--au audio/basic
--snd audio/basic
--aif audio/x-aiff
--aiff audio/x-aiff
--aifc audio/x-aiff
--ra audio/x-pn-realaudio
--ram audio/x-pn-realaudio
--rm audio/x-pn-realaudio
--rpm audio/x-pn-realaudio-plugin
--wav audio/wav
--mid audio/midi
--midi audio/midi
--kar audio/midi
--mpga audio/mpeg
--mp2 audio/mpeg
--mp3 audio/mpeg
--
--mpeg video/mpeg
--mpg video/mpeg
--mpe video/mpeg
--qt video/quicktime
--mov video/quicktime
--avi video/x-msvideo
--movie video/x-sgi-movie
--mv video/x-sgi-movie
--vx video/x-rad-screenplay
--
--a application/octet-stream
-+ez application/andrew-inset
-+hqx application/mac-binhex40
-+cpt application/mac-compactpro
-+doc application/msword
- bin application/octet-stream
-+dms application/octet-stream
-+lha application/octet-stream
-+lzh application/octet-stream
- exe application/octet-stream
--dump application/octet-stream
--o application/octet-stream
--class application/java
--js application/x-javascript
-+class application/octet-stream
-+so application/octet-stream
-+dll application/octet-stream
-+oda application/oda
-+pdf application/pdf
- ai application/postscript
- eps application/postscript
- ps application/postscript
--dir application/x-director
-+smi application/smil
-+smil application/smil
-+mif application/vnd.mif
-+xls application/vnd.ms-excel
-+ppt application/vnd.ms-powerpoint
-+wbxml application/vnd.wap.wbxml
-+wmlc application/vnd.wap.wmlc
-+wmlsc application/vnd.wap.wmlscriptc
-+bcpio application/x-bcpio
-+vcd application/x-cdlink
-+pgn application/x-chess-pgn
-+cpio application/x-cpio
-+csh application/x-csh
- dcr application/x-director
-+dir application/x-director
- dxr application/x-director
--fgd application/x-director
--aam application/x-authorware-map
--aas application/x-authorware-seg
--aab application/x-authorware-bin
--fh4 image/x-freehand
--fh7 image/x-freehand
--fh5 image/x-freehand
--fhc image/x-freehand
--fh image/x-freehand
--spl application/futuresplash
--swf application/x-shockwave-flash
- dvi application/x-dvi
-+spl application/x-futuresplash
- gtar application/x-gtar
- hdf application/x-hdf
--hqx application/mac-binhex40
--iv application/x-inventor
-+js application/x-javascript
-+skp application/x-koan
-+skd application/x-koan
-+skt application/x-koan
-+skm application/x-koan
- latex application/x-latex
--man application/x-troff-man
--me application/x-troff-me
--mif application/x-mif
--ms application/x-troff-ms
--oda application/oda
--pdf application/pdf
--rtf application/rtf
--bcpio application/x-bcpio
--cpio application/x-cpio
--sv4cpio application/x-sv4cpio
--sv4crc application/x-sv4crc
--sh application/x-shar
-+nc application/x-netcdf
-+cdf application/x-netcdf
-+sh application/x-sh
- shar application/x-shar
-+swf application/x-shockwave-flash
- sit application/x-stuffit
-+sv4cpio application/x-sv4cpio
-+sv4crc application/x-sv4crc
- tar application/x-tar
-+tcl application/x-tcl
- tex application/x-tex
--texi application/x-texinfo
- texinfo application/x-texinfo
-+texi application/x-texinfo
-+t application/x-troff
- tr application/x-troff
- roff application/x-troff
- man application/x-troff-man
- me application/x-troff-me
- ms application/x-troff-ms
--zip application/x-zip-compressed
--tsp application/dsptype
--wsrc application/x-wais-source
- ustar application/x-ustar
--cdf application/x-netcdf
--nc application/x-netcdf
--doc application/msword
--ppt application/powerpoint
--
--crt application/x-x509-ca-cert
--crl application/x-pkcs7-crl
--
-+src application/x-wais-source
-+xhtml application/xhtml+xml
-+xht application/xhtml+xml
-+zip application/zip
-+au audio/basic
-+snd audio/basic
-+mid audio/midi
-+midi audio/midi
-+kar audio/midi
-+mpga audio/mpeg
-+mp2 audio/mpeg
-+mp3 audio/mpeg
-+aif audio/x-aiff
-+aiff audio/x-aiff
-+aifc audio/x-aiff
-+m3u audio/x-mpegurl
-+ram audio/x-pn-realaudio
-+rm audio/x-pn-realaudio
-+rpm audio/x-pn-realaudio-plugin
-+ra audio/x-realaudio
-+wav audio/x-wav
-+pdb chemical/x-pdb
-+xyz chemical/x-xyz
-+bmp image/bmp
-+gif image/gif
-+ief image/ief
-+jpeg image/jpeg
-+jpg image/jpeg
-+jpe image/jpeg
-+png image/png
-+tiff image/tiff
-+tif image/tiff
-+djvu image/vnd.djvu
-+djv image/vnd.djvu
-+wbmp image/vnd.wap.wbmp
-+ras image/x-cmu-raster
-+pnm image/x-portable-anymap
-+pbm image/x-portable-bitmap
-+pgm image/x-portable-graymap
-+ppm image/x-portable-pixmap
-+rgb image/x-rgb
-+xbm image/x-xbitmap
-+xpm image/x-xpixmap
-+xwd image/x-xwindowdump
-+igs model/iges
-+iges model/iges
-+msh model/mesh
-+mesh model/mesh
-+silo model/mesh
- wrl model/vrml
- vrml model/vrml
--mime message/rfc822
--
--pac application/x-ns-proxy-autoconfig
--
-+css text/css
-+html text/html; charset=%s
-+htm text/html; charset=%s
-+asc text/plain; charset=%s
-+txt text/plain; charset=%s
-+rtx text/richtext
-+rtf text/rtf
-+sgml text/sgml
-+sgm text/sgml
-+tsv text/tab-separated-values
- wml text/vnd.wap.wml
--wmlc application/vnd.wap.wmlc
- wmls text/vnd.wap.wmlscript
--wmlsc application/vnd.wap.wmlscriptc
--wbmp image/vnd.wap.wbmp
-+etx text/x-setext
-+xml text/xml
-+xsl text/xml
-+mpeg video/mpeg
-+mpg video/mpeg
-+mpe video/mpeg
-+qt video/quicktime
-+mov video/quicktime
-+mxu video/vnd.mpegurl
-+avi video/x-msvideo
-+movie video/x-sgi-movie
-+ice x-conference/x-cooltalk
-diff -ur thttpd-2.21b/mmc.c thttpd-2.21b-cool/mmc.c
---- thttpd-2.21b/mmc.c Fri Apr 13 23:02:15 2001
-+++ thttpd-2.21b-cool/mmc.c Sat Sep 20 14:43:20 2003
-@@ -70,6 +70,9 @@
- unsigned int hash;
- int hash_idx;
- struct MapStruct* next;
-+ char nocache;
-+ size_t last_modified_len;
-+ char last_modified[100];
- } Map;
-
-
-@@ -93,12 +96,13 @@
-
-
- void*
--mmc_map( char* filename, struct stat* sbP, struct timeval* nowP )
-+mmc_map( char* filename, struct stat* sbP, struct timeval* nowP, int nocache, char **last_modified, size_t *last_modified_len )
- {
- time_t now;
- struct stat sb;
- Map* m;
- int fd;
-+ const char* rfc1123fmt = "%a, %d %b %Y %H:%M:%S GMT";
-
- /* Stat the file, if necessary. */
- if ( sbP != (struct stat*) 0 )
-@@ -130,7 +134,7 @@
- /* Yep. Just return the existing map */
- ++m->refcount;
- m->reftime = now;
-- return m->addr;
-+ goto done;
- }
-
- /* Open the file. */
-@@ -167,12 +171,13 @@
- m->ctime = sb.st_ctime;
- m->refcount = 1;
- m->reftime = now;
-+ m->nocache = (char) nocache;
-
- /* Avoid doing anything for zero-length files; some systems don't like
- ** to mmap them, other systems dislike mallocing zero bytes.
- */
- if ( m->size == 0 )
-- m->addr = (void*) 1; /* arbitrary non-NULL address */
-+ m->addr = (void*) 5; /* arbitrary non-NULL address */
- else
- {
- #ifdef HAVE_MMAP
-@@ -223,6 +228,13 @@
- maps = m;
- ++map_count;
-
-+ strftime( m->last_modified, sizeof(m->last_modified), rfc1123fmt, gmtime( &sb.st_mtime ) );
-+ m->last_modified_len = strlen(m->last_modified);
-+
-+done:
-+ *last_modified = m->last_modified;
-+ *last_modified_len = m->last_modified_len;
-+
- /* And return the address. */
- return m->addr;
- }
-@@ -231,27 +243,32 @@
- void
- mmc_unmap( void* addr, struct stat* sbP, struct timeval* nowP )
- {
-- Map* m = (Map*) 0;
-+ Map* m = (Map*) 0, **mm = &maps;
-
- /* Find the Map entry for this address. First try a hash. */
- if ( sbP != (struct stat*) 0 )
- {
- m = find_hash( sbP->st_ino, sbP->st_dev, sbP->st_size, sbP->st_ctime );
-- if ( m != (Map*) 0 && m->addr != addr )
-+ if ( m != (Map*) 0 && ( m->addr != addr || m->nocache == 1 ) )
- m = (Map*) 0;
- }
- /* If that didn't work, try a full search. */
- if ( m == (Map*) 0 )
-- for ( m = maps; m != (Map*) 0; m = m->next )
-+ for ( m = maps; m != (Map*) 0; m = m->next ) {
- if ( m->addr == addr )
- break;
-+ mm = &m->next;
-+ }
- if ( m == (Map*) 0 )
- syslog( LOG_ERR, "mmc_unmap failed to find entry!" );
- else if ( m->refcount <= 0 )
- syslog( LOG_ERR, "mmc_unmap found zero or negative refcount!" );
- else
- {
-- --m->refcount;
-+ if ( --m->refcount == 0 && m->nocache == 1 ) {
-+ really_unmap( mm );
-+ return;
-+ }
- if ( nowP != (struct timeval*) 0 )
- m->reftime = nowP->tv_sec;
- else
-diff -ur thttpd-2.21b/mmc.h thttpd-2.21b-cool/mmc.h
---- thttpd-2.21b/mmc.h Fri Apr 13 07:36:54 2001
-+++ thttpd-2.21b-cool/mmc.h Sat Sep 20 14:43:20 2003
-@@ -31,8 +31,9 @@
- /* Returns an mmap()ed area for the given file, or (void*) 0 on errors.
- ** If you have a stat buffer on the file, pass it in, otherwise pass 0.
- ** Same for the current time.
-+** Set nocache to 1, if this entry is supposed to be removed quickly.
- */
--extern void* mmc_map( char* filename, struct stat* sbP, struct timeval* nowP );
-+extern void* mmc_map( char* filename, struct stat* sbP, struct timeval* nowP, int nocache, char **last_modified, size_t *last_modified_len );
-
- /* Done with an mmap()ed area that was returned by mmc_map().
- ** If you have a stat buffer on the file, pass it in, otherwise pass 0.
-diff -ur thttpd-2.21b/thttpd.c thttpd-2.21b-cool/thttpd.c
---- thttpd-2.21b/thttpd.c Tue Apr 24 00:41:57 2001
-+++ thttpd-2.21b-cool/thttpd.c Sat Sep 20 14:43:20 2003
-@@ -53,6 +53,10 @@
- #endif
- #include <unistd.h>
-
-+#include <sys/mman.h>
-+
-+#include <limits.h>
-+
- #include "fdwatch.h"
- #include "libhttpd.h"
- #include "mmc.h"
-@@ -66,6 +70,8 @@
- static char* dir;
- static int do_chroot, no_log, no_symlink, do_vhost, do_global_passwd;
- static char* cgi_pattern;
-+static char* php_pattern;
-+static char* phps_pattern;
- static char* url_pattern;
- static int no_empty_referers;
- static char* local_pattern;
-@@ -95,10 +101,10 @@
- httpd_conn* hc;
- int tnums[MAXTHROTTLENUMS]; /* throttle indexes */
- int numtnums;
-+ int keep_alive;
- long limit;
- time_t started_at;
-- Timer* idle_read_timer;
-- Timer* idle_send_timer;
-+ time_t last_io;
- Timer* wakeup_timer;
- Timer* linger_timer;
- long wouldblock_delay;
-@@ -106,17 +112,22 @@
- off_t bytes_sent;
- off_t bytes_to_send;
- } connecttab;
--static connecttab* connects;
-+static connecttab* connects, **free_connects;
-+static int next_free_connect;
- static int numconnects, maxconnects;
- static int httpd_conn_count;
-
- /* The connection states. */
--#define CNST_FREE 0
--#define CNST_READING 1
--#define CNST_SENDING 2
--#define CNST_PAUSING 3
--#define CNST_LINGERING 4
--
-+enum {
-+ CNST_FREE = 0,
-+ CNST_READING,
-+ CNST_SENDING,
-+ CNST_PAUSING,
-+ CNST_LINGERING,
-+ CNST_SENDING_RESP,
-+ CNST_READING_BODY,
-+ CNST_TOTAL_NR
-+};
-
- static httpd_server* hs = (httpd_server*) 0;
- int terminate = 0;
-@@ -140,23 +151,32 @@
- static int handle_newconnect( struct timeval* tvP, int listen_fd );
- static void handle_read( connecttab* c, struct timeval* tvP );
- static void handle_send( connecttab* c, struct timeval* tvP );
-+static void handle_send_resp( connecttab* c, struct timeval* tvP );
-+static void handle_read_body( connecttab* c, struct timeval* tvP );
- static void handle_linger( connecttab* c, struct timeval* tvP );
- static int check_throttles( connecttab* c );
-+static void timeout_conns( ClientData client_data, struct timeval* nowP );
- static void clear_throttles( connecttab* c, struct timeval* tvP );
- static void update_throttles( ClientData client_data, struct timeval* nowP );
--static void clear_connection( connecttab* c, struct timeval* tvP );
-+static void clear_connection( connecttab* c, struct timeval* tvP, int );
- static void really_clear_connection( connecttab* c, struct timeval* tvP );
--static void idle_read_connection( ClientData client_data, struct timeval* nowP );
--static void idle_send_connection( ClientData client_data, struct timeval* nowP );
- static void wakeup_connection( ClientData client_data, struct timeval* nowP );
- static void linger_clear_connection( ClientData client_data, struct timeval* nowP );
- static void occasional( ClientData client_data, struct timeval* nowP );
-+static void periodic_jobs( ClientData client_data, struct timeval* nowP );
- #ifdef STATS_TIME
- static void show_stats( ClientData client_data, struct timeval* nowP );
- #endif /* STATS_TIME */
- static void logstats( struct timeval* nowP );
- static void thttpd_logstats( long secs );
-+static void boot_request(connecttab *c, struct timeval *tvP);
-+
-+typedef void (*handler_func)(connecttab*, struct timeval *);
-+
-+handler_func handler_array[CNST_TOTAL_NR] =
-+{NULL, handle_read, handle_send, NULL, handle_linger, handle_send_resp, handle_read_body};
-
-+#define RUN_HANDLER(type, c) if (handler_array[type]) handler_array[type](c, &tv)
-
- static void
- handle_term( int sig )
-@@ -177,7 +197,7 @@
- return;
-
- /* Re-open the log file. */
-- if ( logfile != (char*) 0 )
-+ if ( logfile != (char*) 0 && strcmp(logfile, "-") != 0)
- {
- logfp = fopen( logfile, "a" );
- if ( logfp == (FILE*) 0 )
-@@ -198,6 +218,8 @@
- }
-
-
-+time_t httpd_time_now;
-+
- static void
- handle_usr2( int sig )
- {
-@@ -217,7 +239,6 @@
- int num_ready;
- int cnum, ridx;
- connecttab* c;
-- httpd_conn* hc;
- httpd_sockaddr sa4;
- httpd_sockaddr sa6;
- int gotv4, gotv6;
-@@ -270,7 +291,9 @@
- no_log = 1;
- logfp = (FILE*) 0;
- }
-- else
-+ else if (strcmp(logfile, "-") == 0) {
-+ logfp = stdout;
-+ } else
- {
- logfp = fopen( logfile, "a" );
- if ( logfp == (FILE*) 0 )
-@@ -420,7 +443,8 @@
- hostname,
- gotv4 ? &sa4 : (httpd_sockaddr*) 0, gotv6 ? &sa6 : (httpd_sockaddr*) 0,
- port, cgi_pattern, charset, cwd, no_log, logfp, no_symlink, do_vhost,
-- do_global_passwd, url_pattern, local_pattern, no_empty_referers );
-+ do_global_passwd, url_pattern, local_pattern, no_empty_referers,
-+ php_pattern, phps_pattern);
- if ( hs == (httpd_server*) 0 )
- exit( 1 );
-
-@@ -430,6 +454,12 @@
- syslog( LOG_CRIT, "tmr_create(occasional) failed" );
- exit( 1 );
- }
-+
-+ if (tmr_create(0, timeout_conns, JunkClientData, 30 * 1000, 1) == 0) {
-+ syslog(LOG_CRIT, "tmr_create(timeout_conns) failed");
-+ exit(1);
-+ }
-+
- if ( numthrottles > 0 )
- {
- /* Set up the throttles timer. */
-@@ -439,6 +469,12 @@
- exit( 1 );
- }
- }
-+
-+ if (tmr_create(0, periodic_jobs, JunkClientData, 2000, 1) == 0) {
-+ syslog(LOG_CRIT, "tmr_create failed");
-+ exit(1);
-+ }
-+
- #ifdef STATS_TIME
- /* Set up the stats timer. */
- if ( tmr_create( (struct timeval*) 0, show_stats, JunkClientData, STATS_TIME * 1000L, 1 ) == (Timer*) 0 )
-@@ -454,12 +490,14 @@
- /* If we're root, try to become someone else. */
- if ( getuid() == 0 )
- {
-+#ifndef __CYGWIN__
- /* Set aux groups to null. */
- if ( setgroups( 0, (const gid_t*) 0 ) < 0 )
- {
- syslog( LOG_CRIT, "setgroups - %m" );
- exit( 1 );
- }
-+#endif
- /* Set primary group. */
- if ( setgid( gid ) < 0 )
- {
-@@ -495,13 +533,17 @@
- }
- maxconnects -= SPARE_FDS;
- connects = NEW( connecttab, maxconnects );
-+ free_connects = malloc(sizeof(connecttab *) * maxconnects);
-+ next_free_connect = maxconnects;
- if ( connects == (connecttab*) 0 )
- {
- syslog( LOG_CRIT, "out of memory allocating a connecttab" );
- exit( 1 );
- }
-+
- for ( cnum = 0; cnum < maxconnects; ++cnum )
- {
-+ free_connects[cnum] = &connects[maxconnects - cnum - 1];
- connects[cnum].conn_state = CNST_FREE;
- connects[cnum].hc = (httpd_conn*) 0;
- }
-@@ -518,6 +560,9 @@
-
- /* Main loop. */
- (void) gettimeofday( &tv, (struct timezone*) 0 );
-+ httpd_time_now = tv.tv_sec;
-+ periodic_jobs(JunkClientData, &tv);
-+
- while ( ( ! terminate ) || numconnects > 0 )
- {
- /* Do the fd watch. */
-@@ -530,6 +575,7 @@
- exit( 1 );
- }
- (void) gettimeofday( &tv, (struct timezone*) 0 );
-+ httpd_time_now = tv.tv_sec;
- if ( num_ready == 0 )
- {
- /* No fd's are ready - run the timers. */
-@@ -565,16 +611,10 @@
- c = (connecttab*) fdwatch_get_client_data( ridx );
- if ( c == (connecttab*) 0 )
- continue;
-- hc = c->hc;
-- if ( c->conn_state == CNST_READING &&
-- fdwatch_check_fd( hc->conn_fd ) )
-- handle_read( c, &tv );
-- else if ( c->conn_state == CNST_SENDING &&
-- fdwatch_check_fd( hc->conn_fd ) )
-- handle_send( c, &tv );
-- else if ( c->conn_state == CNST_LINGERING &&
-- fdwatch_check_fd( hc->conn_fd ) )
-- handle_linger( c, &tv );
-+#if DO_UNNECESSARY_CHECK_FD
-+ fdwatch_check_fd(c->hc->conn_fd);
-+#endif
-+ RUN_HANDLER(c->conn_state, c);
- }
- tmr_run( &tv );
-
-@@ -627,6 +667,8 @@
- #else /* CGI_PATTERN */
- cgi_pattern = (char*) 0;
- #endif /* CGI_PATTERN */
-+ php_pattern = "**.php";
-+ phps_pattern = "**.phps";
- url_pattern = (char*) 0;
- no_empty_referers = 0;
- local_pattern = (char*) 0;
-@@ -833,6 +875,16 @@
- value_required( name, value );
- cgi_pattern = e_strdup( value );
- }
-+ else if ( strcasecmp( name, "phppat" ) == 0 )
-+ {
-+ value_required( name, value );
-+ php_pattern = e_strdup( value );
-+ }
-+ else if ( strcasecmp( name, "phpspat" ) == 0 )
-+ {
-+ value_required( name, value );
-+ phps_pattern = e_strdup( value );
-+ }
- else if ( strcasecmp( name, "urlpat" ) == 0 )
- {
- value_required( name, value );
-@@ -1196,8 +1248,10 @@
- logstats( &tv );
- for ( cnum = 0; cnum < maxconnects; ++cnum )
- {
-- if ( connects[cnum].conn_state != CNST_FREE )
-+ if ( connects[cnum].conn_state != CNST_FREE ) {
-+ httpd_complete_request( connects[cnum].hc, &tv );
- httpd_close_conn( connects[cnum].hc, &tv );
-+ }
- if ( connects[cnum].hc != (httpd_conn*) 0 )
- {
- httpd_destroy_conn( connects[cnum].hc );
-@@ -1214,6 +1268,7 @@
- }
- mmc_destroy();
- tmr_destroy();
-+ free( (void*) free_connects );
- free( (void*) connects );
- if ( throttles != (throttletab*) 0 )
- free( (void*) throttles );
-@@ -1234,7 +1289,7 @@
- for (;;)
- {
- /* Is there room in the connection table? */
-- if ( numconnects >= maxconnects )
-+ if ( numconnects >= maxconnects || next_free_connect == 0 )
- {
- /* Out of connection slots. Run the timers, then the
- ** existing connections, and maybe we'll free up a slot
-@@ -1245,10 +1300,10 @@
- return 0;
- }
- /* Find a free connection entry. */
-- for ( cnum = 0; cnum < maxconnects; ++cnum )
-- if ( connects[cnum].conn_state == CNST_FREE )
-- break;
-- c = &connects[cnum];
-+
-+ c = free_connects[--next_free_connect];
-+ free_connects[next_free_connect] = NULL;
-+
- /* Make the httpd_conn if necessary. */
- if ( c->hc == (httpd_conn*) 0 )
- {
-@@ -1267,24 +1322,18 @@
- {
- case GC_FAIL:
- case GC_NO_MORE:
-+ free_connects[next_free_connect++] = c;
- return 1;
- }
- c->conn_state = CNST_READING;
- ++numconnects;
- client_data.p = c;
-- c->idle_read_timer = tmr_create(
-- tvP, idle_read_connection, client_data, IDLE_READ_TIMELIMIT * 1000L,
-- 0 );
-- if ( c->idle_read_timer == (Timer*) 0 )
-- {
-- syslog( LOG_CRIT, "tmr_create(idle_read_connection) failed" );
-- exit( 1 );
-- }
-- c->idle_send_timer = (Timer*) 0;
- c->wakeup_timer = (Timer*) 0;
- c->linger_timer = (Timer*) 0;
- c->bytes_sent = 0;
- c->numtnums = 0;
-+ c->keep_alive = 0;
-+ c->last_io = httpd_time_now;
-
- /* Set the connection file descriptor to no-delay mode. */
- httpd_set_ndelay( c->hc->conn_fd );
-@@ -1298,11 +1347,100 @@
- }
-
-
-+#define FIXUP(x) if (hc->x >= oldptr && hc->x < pe) hc->x += d
-+
-+static void
-+realign_hc(httpd_conn *hc, char *oldptr)
-+{
-+ int d = hc->read_buf - oldptr;
-+ char *pe = oldptr + hc->checked_idx;
-+
-+ FIXUP(encodedurl);
-+ FIXUP(protocol);
-+ FIXUP(referer);
-+ FIXUP(useragent);
-+ FIXUP(acceptl);
-+ FIXUP(cookie);
-+ FIXUP(contenttype);
-+ FIXUP(hdrhost);
-+ FIXUP(authorization);
-+}
-+
-+#undef FIXUP
-+
-+static void
-+setup_read_body(connecttab *c, struct timeval *tvP)
-+{
-+ httpd_conn *hc = c->hc;
-+ int already, missing;
-+ char *oldptr = hc->read_buf;
-+
-+ c->conn_state = CNST_READING_BODY;
-+
-+ hc->read_body_into_mem = 0;
-+
-+ already = hc->read_idx - hc->checked_idx;
-+ missing = hc->contentlength - already;
-+
-+ if (missing > 16384) {
-+ char filename[] = "/tmp/thttpd.upload.XXXXXX";
-+ int tmp = mkstemp(filename);
-+
-+ if (tmp >= 0) {
-+ void *p;
-+ size_t sz = hc->contentlength + hc->checked_idx + 10;
-+
-+ unlink(filename);
-+
-+ ftruncate(tmp, sz);
-+ p = mmap(NULL, sz,
-+ PROT_READ|PROT_WRITE, MAP_PRIVATE, tmp, 0);
-+
-+ if (p != MAP_FAILED) {
-+ memcpy(p, hc->read_buf, hc->read_idx);
-+ free(hc->read_buf);
-+ hc->read_size = sz;
-+ hc->read_buf = p;
-+ hc->read_buf_is_mmap = 1;
-+ }
-+ close(tmp);
-+ }
-+
-+ if (!hc->read_buf_is_mmap) {
-+ clear_connection( c, tvP, 0 );
-+ return;
-+ }
-+ } else if (missing > 0) {
-+ httpd_realloc_str(&hc->read_buf, &hc->read_size, hc->checked_idx + hc->contentlength + 10);
-+ }
-+ if (oldptr != hc->read_buf) realign_hc(hc, oldptr);
-+
-+ fdwatch_del_fd( hc->conn_fd );
-+ fdwatch_add_fd( hc->conn_fd, c, FDW_READ );
-+}
-+
-+static void
-+setup_sending(connecttab *c, int state, struct timeval *tvP)
-+{
-+ httpd_conn *hc = c->hc;
-+ ClientData client_data;
-+
-+ c->conn_state = state;
-+ c->started_at = tvP->tv_sec;
-+ c->wouldblock_delay = 0;
-+ client_data.p = c;
-+
-+ fdwatch_del_fd( hc->conn_fd );
-+ fdwatch_add_fd( hc->conn_fd, c, FDW_WRITE );
-+}
-+
-+static void handle_request( connecttab *c, struct timeval *tvP);
-+
-+
- static void
- handle_read( connecttab* c, struct timeval* tvP )
- {
- int sz;
-- ClientData client_data;
- httpd_conn* hc = c->hc;
-
- /* Is there room in our buffer to read more bytes? */
-@@ -1311,7 +1449,7 @@
- if ( hc->read_size > 5000 )
- {
- httpd_send_err( hc, 400, httpd_err400title, "", httpd_err400form, "" );
-- clear_connection( c, tvP );
-+ clear_connection( c, tvP, 0 );
- return;
- }
- httpd_realloc_str(
-@@ -1327,14 +1465,53 @@
- ** EWOULDBLOCK; however, this apparently can happen if a packet gets
- ** garbled.
- */
-- if ( sz == 0 || ( sz < 0 && ( errno != EWOULDBLOCK ) ) )
-- {
-- httpd_send_err( hc, 400, httpd_err400title, "", httpd_err400form, "" );
-- clear_connection( c, tvP );
-+ if ( sz == 0 ) {
-+ if (! c->keep_alive) {
-+ httpd_send_err( hc, 400, httpd_err400title, "", httpd_err400form, "" );
-+ }
-+ clear_connection( c, tvP, 0 );
-+ return;
-+ } else if ( sz < 0 ) {
-+ if (errno != EWOULDBLOCK) {
-+ clear_connection( c, tvP, 0 );
-+ }
- return;
-+ }
-+
-+ /* If this is a persistent PHP connection, we must not receive
-+ ** any further requests on this connection. Some broken HTTP/1.1
-+ ** implementations (e.g. Mozilla 1.0.1) are known to do
-+ ** pipelining on a connection, although a prior response included
-+ ** Connection: close
-+ */
-+ if (c->hc->file_address == (char *) 1) {
-+ return;
-+ }
-+
-+ c->last_io = httpd_time_now;
-+ if (sz > 0) hc->read_idx += sz;
-+
-+ /*
-+ ** if we start getting new data on this socket, "promote" it
-+ ** to read timeout
-+ */
-+ if ( hc->keep_alive ) {
-+ ClientData client_data;
-+
-+
-+ client_data.p = c;
-+
-+ hc->keep_alive = 0;
-+ }
-+ handle_request(c, tvP);
- }
-- hc->read_idx += sz;
-
-+
-+static void
-+handle_request( connecttab *c, struct timeval *tvP)
-+{
-+ httpd_conn* hc = c->hc;
-+
- /* Do we have a complete request yet? */
- switch ( httpd_got_request( hc ) )
- {
-@@ -1342,14 +1519,14 @@
- return;
- case GR_BAD_REQUEST:
- httpd_send_err( hc, 400, httpd_err400title, "", httpd_err400form, "" );
-- clear_connection( c, tvP );
-+ clear_connection( c, tvP, 0 );
- return;
- }
-
- /* Yes. Try parsing and resolving it. */
- if ( httpd_parse_request( hc ) < 0 )
- {
-- clear_connection( c, tvP );
-+ clear_connection( c, tvP, 0 );
- return;
- }
-
-@@ -1358,18 +1535,28 @@
- {
- httpd_send_err(
- hc, 503, httpd_err503title, "", httpd_err503form, hc->encodedurl );
-- clear_connection( c, tvP );
-+ clear_connection( c, tvP, 0 );
- return;
- }
-+ boot_request(c, tvP);
-+}
-
-+static void boot_request(connecttab *c, struct timeval *tvP)
-+{
-+ httpd_conn *hc = c->hc;
- /* Start the connection going. */
- if ( httpd_start_request( hc, tvP ) < 0 )
- {
- /* Something went wrong. Close down the connection. */
-- clear_connection( c, tvP );
-+ clear_connection( c, tvP, 0 );
- return;
- }
-
-+ if ( hc->read_body_into_mem ) {
-+ setup_read_body( c, tvP );
-+ return;
-+ }
-+
- /* Fill in bytes_to_send. */
- if ( hc->got_range )
- {
-@@ -1384,37 +1571,25 @@
- {
- /* No file address means someone else is handling it. */
- c->bytes_sent = hc->bytes_sent;
-- clear_connection( c, tvP );
-+ clear_connection( c, tvP, 1 );
- return;
- }
-+ if (hc->file_address == (char *) 1) {
-+ c->last_io = (time_t) LONG_MAX;
-+ c->wouldblock_delay = 0;
-+ return;
-+ }
- if ( c->bytes_sent >= c->bytes_to_send )
- {
- /* There's nothing to send. */
-- clear_connection( c, tvP );
-+ clear_connection( c, tvP, 1 );
- return;
- }
-
- /* Cool, we have a valid connection and a file to send to it. */
-- c->conn_state = CNST_SENDING;
-- c->started_at = tvP->tv_sec;
-- c->wouldblock_delay = 0;
-- client_data.p = c;
-- tmr_cancel( c->idle_read_timer );
-- c->idle_read_timer = (Timer*) 0;
-- c->idle_send_timer = tmr_create(
-- tvP, idle_send_connection, client_data, IDLE_SEND_TIMELIMIT * 1000L,
-- 0 );
-- if ( c->idle_send_timer == (Timer*) 0 )
-- {
-- syslog( LOG_CRIT, "tmr_create(idle_send_connection) failed" );
-- exit( 1 );
-- }
--
-- fdwatch_del_fd( hc->conn_fd );
-- fdwatch_add_fd( hc->conn_fd, c, FDW_WRITE );
-+ setup_sending(c, CNST_SENDING, tvP);
- }
-
--
- static void
- handle_send( connecttab* c, struct timeval* tvP )
- {
-@@ -1443,6 +1618,9 @@
- iv[1].iov_base = &(hc->file_address[c->bytes_sent]);
- iv[1].iov_len = MIN( c->bytes_to_send - c->bytes_sent, c->limit );
- sz = writev( hc->conn_fd, iv, 2 );
-+/*
-+printf("**RESPONSE2 [%d]** len = %d\n%*.*s\n", hc->conn_fd, hc->responselen, hc->responselen, hc->responselen, hc->response);
-+*/
- }
-
- if ( sz == 0 ||
-@@ -1486,12 +1664,12 @@
- */
- if ( errno != EPIPE && errno != EINVAL && errno != ECONNRESET )
- syslog( LOG_ERR, "write - %m sending %.80s", hc->encodedurl );
-- clear_connection( c, tvP );
-+ clear_connection( c, tvP, 0 );
- return;
- }
-
- /* Ok, we wrote something. */
-- tmr_reset( tvP, c->idle_send_timer );
-+ c->last_io = httpd_time_now;
- /* Was this a headers + file writev()? */
- if ( hc->responselen > 0 )
- {
-@@ -1500,7 +1678,7 @@
- {
- /* Yes; move the unwritten part to the front of the buffer. */
- int newlen = hc->responselen - sz;
-- (void) memcpy( hc->response, &(hc->response[sz]), newlen );
-+ (void) memmove( hc->response, &(hc->response[sz]), newlen );
- hc->responselen = newlen;
- sz = 0;
- }
-@@ -1519,7 +1697,7 @@
- if ( c->bytes_sent >= c->bytes_to_send )
- {
- /* This connection is finished! */
-- clear_connection( c, tvP );
-+ clear_connection( c, tvP, 1 );
- return;
- }
-
-@@ -1560,6 +1738,9 @@
- char buf[1024];
- int r;
-
-+/*
-+printf("*LINGER read\n");
-+*/
- /* In lingering-close mode we just read and ignore bytes. An error
- ** or EOF ends things, otherwise we go until a timeout.
- */
-@@ -1569,6 +1750,63 @@
- }
-
-
-+static void
-+handle_read_body(connecttab *c, struct timeval *tvP)
-+{
-+ httpd_conn *hc = c->hc;
-+ int n;
-+
-+ n = read(hc->conn_fd, hc->read_buf + hc->read_idx,
-+ hc->contentlength - (hc->read_idx - hc->checked_idx));
-+
-+ if (n <= 0) {
-+ if (errno == EAGAIN)
-+ return;
-+ clear_connection(c, tvP, 0);
-+ return;
-+ }
-+
-+ c->last_io = httpd_time_now;
-+
-+ hc->read_idx += n;
-+
-+ if (hc->contentlength == hc->read_idx - hc->checked_idx) {
-+ boot_request(c, tvP);
-+ return;
-+ }
-+}
-+
-+static void
-+handle_send_resp(connecttab *c, struct timeval *tvP)
-+{
-+ httpd_conn* hc = c->hc;
-+ int n = send(hc->conn_fd, hc->response, hc->responselen, 0);
-+ int dokeep = 1;
-+
-+ if (n < 0) {
-+ if (errno == EAGAIN)
-+ return;
-+
-+ dokeep = 0;
-+ goto clear;
-+ }
-+
-+ c->last_io = httpd_time_now;
-+
-+ if (n == hc->responselen) {
-+clear:
-+ hc->response = realloc(hc->response, hc->maxresponse + 1);
-+ hc->responselen = 0;
-+
-+ clear_connection(c, tvP, dokeep);
-+ return;
-+ }
-+
-+ hc->responselen -= n;
-+
-+ memmove(hc->response, hc->response + n, hc->responselen);
-+}
-+
- static int
- check_throttles( connecttab* c )
- {
-@@ -1635,23 +1873,18 @@
-
-
- static void
--clear_connection( connecttab* c, struct timeval* tvP )
-+clear_connection( connecttab* c, struct timeval* tvP, int doKeep )
- {
- ClientData client_data;
-+ int linger;
-
- /* If we haven't actually sent the buffered response yet, do so now. */
-- httpd_write_response( c->hc );
-+ if (c->hc->responselen && c->conn_state != CNST_SENDING_RESP) {
-+ setup_sending(c, CNST_SENDING_RESP, tvP);
-
-- if ( c->idle_read_timer != (Timer*) 0 )
-- {
-- tmr_cancel( c->idle_read_timer );
-- c->idle_read_timer = 0;
-- }
-- if ( c->idle_send_timer != (Timer*) 0 )
-- {
-- tmr_cancel( c->idle_send_timer );
-- c->idle_send_timer = 0;
-+ return;
- }
-+
- if ( c->wakeup_timer != (Timer*) 0 )
- {
- tmr_cancel( c->wakeup_timer );
-@@ -1669,13 +1902,36 @@
- ** circumstances that make a lingering close necessary. If the flag
- ** isn't set we do the real close now.
- */
-- if ( c->hc->should_linger )
-+
-+ if ( c->hc->do_keep_alive && doKeep)
- {
-- c->conn_state = CNST_LINGERING;
-+ httpd_conn *hc = c->hc;
-+ c->conn_state = CNST_READING;
-+
-+ client_data.p = c;
-+ c->bytes_sent = 0;
-+ c->numtnums = 0;
-+ c->keep_alive = 1;
-+
-+ httpd_complete_request( c->hc, tvP );
-+
- fdwatch_del_fd( c->hc->conn_fd );
- fdwatch_add_fd( c->hc->conn_fd, c, FDW_READ );
-+
-+ httpd_request_reset( c->hc, 1 );
-+
-+ hc->read_idx -= hc->checked_idx;
-+ memmove(hc->read_buf, hc->read_buf + hc->checked_idx, hc->read_idx);
-+ hc->checked_idx = 0;
-+
- /* Make sure we are still in no-delay mode. */
- httpd_set_ndelay( c->hc->conn_fd );
-+ handle_request(c, tvP);
-+ }
-+ else if ( c->hc->should_linger )
-+ {
-+ c->conn_state = CNST_LINGERING;
-+
- client_data.p = c;
- c->linger_timer = tmr_create(
- tvP, linger_clear_connection, client_data, LINGER_TIME * 1000L, 0 );
-@@ -1684,9 +1940,19 @@
- syslog( LOG_CRIT, "tmr_create(linger_clear_connection) failed" );
- exit( 1 );
- }
-+
-+ httpd_complete_request( c->hc, tvP );
-+
-+ fdwatch_del_fd( c->hc->conn_fd );
-+ fdwatch_add_fd( c->hc->conn_fd, c, FDW_READ );
-+ /* Make sure we are still in no-delay mode. */
-+ httpd_set_ndelay( c->hc->conn_fd );
- }
-- else
-+ else
-+ {
-+ httpd_complete_request( c->hc, tvP );
- really_clear_connection( c, tvP );
-+ }
- }
-
-
-@@ -1702,45 +1968,12 @@
- tmr_cancel( c->linger_timer );
- c->linger_timer = 0;
- }
-+ free_connects[next_free_connect++] = c;
- c->conn_state = CNST_FREE;
- --numconnects;
- }
-
-
--static void
--idle_read_connection( ClientData client_data, struct timeval* nowP )
-- {
-- connecttab* c;
--
-- c = (connecttab*) client_data.p;
-- c->idle_read_timer = (Timer*) 0;
-- if ( c->conn_state != CNST_FREE )
-- {
-- syslog( LOG_INFO,
-- "%.80s connection timed out reading",
-- httpd_ntoa( &c->hc->client_addr ) );
-- httpd_send_err( c->hc, 408, httpd_err408title, "", httpd_err408form, "" );
-- clear_connection( c, nowP );
-- }
-- }
--
--
--static void
--idle_send_connection( ClientData client_data, struct timeval* nowP )
-- {
-- connecttab* c;
--
-- c = (connecttab*) client_data.p;
-- c->idle_send_timer = (Timer*) 0;
-- if ( c->conn_state != CNST_FREE )
-- {
-- syslog( LOG_INFO,
-- "%.80s connection timed out sending",
-- httpd_ntoa( &c->hc->client_addr ) );
-- clear_connection( c, nowP );
-- }
-- }
--
-
- static void
- wakeup_connection( ClientData client_data, struct timeval* nowP )
-@@ -1783,6 +2016,43 @@
- }
- #endif /* STATS_TIME */
-
-+char httpd_now_buf[100];
-+
-+
-+
-+static void
-+periodic_jobs( ClientData client_data, struct timeval* nowP )
-+{
-+ const char* rfc1123fmt = "%a, %d %b %Y %H:%M:%S GMT";
-+ struct tm *t;
-+ char date_nozone[100];
-+ const char* cernfmt_nozone = "%d/%b/%Y:%H:%M:%S";
-+ char data[100];
-+ int zone;
-+ char sign;
-+
-+ strftime( httpd_now_buf, sizeof(httpd_now_buf), rfc1123fmt, gmtime( &nowP->tv_sec ) );
-+
-+ t = localtime(&nowP->tv_sec);
-+ strftime( date_nozone, sizeof(date_nozone), cernfmt_nozone, t );
-+#ifdef HAVE_TM_GMTOFF
-+ zone = t->tm_gmtoff / 60L;
-+#else
-+ zone = -timezone / 60L;
-+ /* Probably have to add something about daylight time here. */
-+#endif
-+ if ( zone >= 0 )
-+ sign = '+';
-+ else
-+ {
-+ sign = '-';
-+ zone = -zone;
-+ }
-+ zone = ( zone / 60 ) * 100 + zone % 60;
-+ hs->log_date_len = sprintf( hs->log_date, "%s %c%04d", date_nozone, sign,
-+ zone );
-+}
-+
-
- /* Generate debugging statistics syslog messages for all packages. */
- static void
-@@ -1826,3 +2096,42 @@
- stats_connections = stats_bytes = 0L;
- stats_simultaneous = 0;
- }
-+
-+static void
-+timeout_conns(ClientData client_data, struct timeval *nowP)
-+{
-+ connecttab *c = connects, *ce = c + maxconnects;
-+ time_t now = nowP->tv_sec;
-+ int r = 0, w = 0;
-+ int checked = 0;
-+
-+ while (c < ce) {
-+ switch (c->conn_state) {
-+ case CNST_SENDING:
-+ case CNST_SENDING_RESP:
-+ checked++;
-+ if ((now - c->last_io) > IDLE_SEND_TIMELIMIT) {
-+ clear_connection( c, nowP, 0 );
-+ w++;
-+ }
-+ break;
-+ case CNST_READING:
-+ case CNST_READING_BODY:
-+ checked++;
-+ if ((now - c->last_io) > IDLE_READ_TIMELIMIT) {
-+ clear_connection( c, nowP, 0 );
-+ r++;
-+ }
-+ break;
-+ case CNST_FREE: break;
-+ default: checked++; break;
-+ }
-+ c++;
-+ if (checked >= numconnects) break;
-+ }
-+
-+ if (r > 0 || w > 0) {
-+ syslog(LOG_INFO, "Expired %d/%d connections in read/write state", r, w);
-+ }
-+}
-+
-diff -ur thttpd-2.21b/version.h thttpd-2.21b-cool/version.h
---- thttpd-2.21b/version.h Tue Apr 24 04:05:23 2001
-+++ thttpd-2.21b-cool/version.h Sat Sep 20 14:43:20 2003
-@@ -3,7 +3,7 @@
- #ifndef _VERSION_H_
- #define _VERSION_H_
-
--#define SERVER_SOFTWARE "thttpd/2.21b 23apr2001"
-+#define SERVER_SOFTWARE "thttpd/2.21b PHP/20030920"
- #define SERVER_ADDRESS "http://www.acme.com/software/thttpd/"
-
- #endif /* _VERSION_H_ */
diff --git a/sapi/tux/CREDITS b/sapi/tux/CREDITS
deleted file mode 100644
index 3b7aa70c01..0000000000
--- a/sapi/tux/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-tux
-Sascha Schumann
diff --git a/sapi/tux/README b/sapi/tux/README
deleted file mode 100644
index 3c5ebc56ba..0000000000
--- a/sapi/tux/README
+++ /dev/null
@@ -1,86 +0,0 @@
-README FOR THE TUX MODULE (by Sascha Schumann)
-($Date$)
-
- This is a SAPI module for the TUX web-server by Ingo Molnar.
-
- The special thing about TUX is that it is integrated into the Linux
- kernel and thus provides high-speed serving of static files.
-
- The web-server provides a user-space API which allows arbitrary
- plug-ins to be made available.
-
- All requests to the PHP userspace module are currently serialized.
-
- This module is of alpha quality. Due to incomplete APIs, HTTP
- authentication and handling of POST requests has not been
- implemented yet.
-
- SECURITY NOTE: PHP will happily run everything under the
- web-root through the parser; so be careful what you put
- there.
-
- Note that requests are served in a chroot'ed environment.
- The initialization of PHP does not take place in the chroot'ed
- environment, so that e.g. /usr/local/lib/php.ini is treated
- as usual.
-
-REQUIRED DOWNLOADS
-
- 1. TUX
-
- http://people.redhat.com/~mingo/TUX-patches/QuickStart-TUX.txt
-
- 2. PHP 4.0.x
-
- Download:
- http://www.php.net/
-
- Snapshots from CVS:
- http://snaps.php.net/
-
-
-BUILD INSTRUCTIONS
-
- 1. Install TUX as outlined in the QuickStart text.
- Create /tux-modules where modules will reside.
-
- 2. Prepare PHP
-
- $ cd php-*
- $ ./configure \
- --with-tux=/tux-modules \
- <further PHP options>
- # make install
-
- You can see the list of valid PHP options by executing
-
- $ ./configure --help
-
- 3. Touch a file in your web-root 'php7.tux'. This will
- cause requests to '/php7.tux' to be redirected to the
- userspace module php7.tux.
-
- 4. Start TUX with something like
-
- # tux -d -t 8 -r /www -m /tux-modules php7.tux
-
- (daemon mode, eight threads, web-root /www, modules in
- /tux-modules, load php7.tux)
-
- BEFORE running this command, the kernel side of TUX has to
- be properly setup.
-
- 5. Try to access
-
- http://yourserver/php7.tux?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000
-
- It should display the PHP credits page.
-
- To access a script /foo/bar.php, use
-
- http://yourserver/php7.tux?/foo/bar.php
-
- Parameters can be appended:
-
- http://yourserver/php7.tux?/foo/bar.php&var=value
-
diff --git a/sapi/tux/config.m4 b/sapi/tux/config.m4
deleted file mode 100644
index db4be82cf1..0000000000
--- a/sapi/tux/config.m4
+++ /dev/null
@@ -1,16 +0,0 @@
-dnl
-dnl $Id$
-dnl
-
-PHP_ARG_WITH(tux,,
-[ --with-tux=MODULEDIR Build PHP as a TUX module (Linux only)], no, no)
-
-AC_MSG_CHECKING([for TUX])
-if test "$PHP_TUX" != "no"; then
- INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED $PHP_TUX/php7.tux.so"
- AC_CHECK_HEADERS(tuxmodule.h,[:],[AC_MSG_ERROR([Cannot find tuxmodule.h])])
- PHP_SELECT_SAPI(tux, shared, php_tux.c)
- AC_MSG_RESULT([$PHP_TUX])
-else
- AC_MSG_RESULT(no)
-fi
diff --git a/sapi/tux/php.sym b/sapi/tux/php.sym
deleted file mode 100644
index b968c5f5a2..0000000000
--- a/sapi/tux/php.sym
+++ /dev/null
@@ -1,2 +0,0 @@
-TUXAPI_handle_events
-TUXAPI_init
diff --git a/sapi/tux/php_tux.c b/sapi/tux/php_tux.c
deleted file mode 100644
index 11755e18e2..0000000000
--- a/sapi/tux/php_tux.c
+++ /dev/null
@@ -1,449 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.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> |
- +----------------------------------------------------------------------+
-*/
-
-#include "php.h"
-#include "SAPI.h"
-#include "php_main.h"
-#include "php_variables.h"
-
-#include "zend_smart_str.h"
-
-#include "tuxmodule.h"
-
-#include <sys/uio.h>
-
-#if 0
-#include <pthread.h>
-#endif
-
-void tux_closed_conn(int fd);
-
-enum {
- PHP_TUX_BACKGROUND_CONN = 1
-};
-
-typedef struct {
- user_req_t *req;
- void (*on_close)(int);
- int tux_action;
- struct iovec *header_vec;
- int number_vec;
-} php_tux_globals;
-
-static php_tux_globals tux_globals;
-
-#define TG(v) (tux_globals.v)
-
-static int sapi_tux_ub_write(const char *str, uint str_length)
-{
- int n;
- int m;
- const char *estr;
-
- /* combine headers and body */
- if (TG(number_vec)) {
- struct iovec *vec = TG(header_vec);
-
- n = TG(number_vec);
- vec[n].iov_base = (void *) str;
- vec[n++].iov_len = str_length;
-
- /* XXX: this might need more complete error handling */
- if ((m = writev(TG(req)->sock, vec, n)) == -1 && errno == EPIPE)
- php_handle_aborted_connection();
-
- if (m > 0)
- TG(req)->bytes_sent += str_length;
-
- TG(number_vec) = 0;
- return str_length;
- }
-
- estr = str + str_length;
-
- while (str < estr) {
- n = send(TG(req)->sock, str, estr - str, 0);
-
- if (n == -1 && errno == EPIPE)
- php_handle_aborted_connection();
- if (n == -1 && errno == EAGAIN)
- continue;
- if (n <= 0)
- return n;
-
- str += n;
- }
-
- n = str_length - (estr - str);
-
- TG(req)->bytes_sent += n;
-
- return n;
-}
-
-static int sapi_tux_send_headers(sapi_headers_struct *sapi_headers)
-{
- char buf[1024];
- struct iovec *vec;
- int n;
- int max_headers;
- zend_llist_position pos;
- sapi_header_struct *h;
- size_t len;
- char *status_line;
- int locate_cl;
-
- max_headers = 30;
- n = 1;
-
- vec = malloc(sizeof(struct iovec) * max_headers);
- status_line = malloc(30);
-
- /* safe sprintf use */
- len = slprintf(status_line, 30, "HTTP/1.1 %d NA\r\n", SG(sapi_headers).http_response_code);
-
- vec[0].iov_base = status_line;
- vec[0].iov_len = len;
-
- TG(req)->http_status = SG(sapi_headers).http_response_code;
-
- if (TG(tux_action) == TUX_ACTION_FINISH_CLOSE_REQ && TG(req)->http_version == HTTP_1_1)
- locate_cl = 1;
- else
- locate_cl = 0;
-
- h = zend_llist_get_first_ex(&sapi_headers->headers, &pos);
- while (h) {
- if (locate_cl
- && strncasecmp(h->header, "Content-length:", sizeof("Content-length:")-1) == 0) {
- TG(tux_action) = TUX_ACTION_FINISH_REQ;
- locate_cl = 0;
- }
-
- vec[n].iov_base = h->header;
- vec[n++].iov_len = h->header_len;
- if (n >= max_headers - 3) {
- max_headers *= 2;
- vec = realloc(vec, sizeof(struct iovec) * max_headers);
- }
- vec[n].iov_base = "\r\n";
- vec[n++].iov_len = 2;
-
- h = zend_llist_get_next_ex(&sapi_headers->headers, &pos);
- }
-
- vec[n].iov_base = "\r\n";
- vec[n++].iov_len = 2;
-
- TG(number_vec) = n;
- TG(header_vec) = vec;
-
-
- return SAPI_HEADER_SENT_SUCCESSFULLY;
-}
-
-static int sapi_tux_read_post(char *buffer, uint count_bytes)
-{
-#if 0
- int amount = 0;
-
- TG(req)->objectlen = count_bytes;
- TG(req)->object_addr = buffer;
- if (tux(TUX_ACTION_READ_POST_DATA, TG(req)))
- return 0;
-
- TG(read_post_data) = 1;
-
- return TG(req)->objectlen;
-#else
- return 0;
-#endif
-}
-
-static char *sapi_tux_read_cookies(void)
-{
- return TG(req)->cookies;
-}
-
-#define BUF_SIZE 512
-#define ADD_STRING(name) \
- php_register_variable(name, buf, track_vars_array)
-
-static void sapi_tux_register_variables(zval *track_vars_array)
-{
- char buf[BUF_SIZE + 1];
- char *p;
- sapi_header_line ctr = {0};
-
- ctr.line = buf;
- ctr.line_len = slprintf(buf, sizeof(buf), "Server: %s", TUXAPI_version);
- sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
-
- php_register_variable("PHP_SELF", SG(request_info).request_uri, track_vars_array);
- php_register_variable("SERVER_SOFTWARE", TUXAPI_version, track_vars_array);
- php_register_variable("GATEWAY_INTERFACE", "CGI/1.1", track_vars_array);
- php_register_variable("REQUEST_METHOD", (char *) SG(request_info).request_method, track_vars_array);
- php_register_variable("DOCUMENT_ROOT", TUXAPI_docroot, track_vars_array);
- php_register_variable("SERVER_NAME", TUXAPI_servername, track_vars_array);
- php_register_variable("REQUEST_URI", SG(request_info).request_uri, track_vars_array);
- php_register_variable("PATH_TRANSLATED", SG(request_info).path_translated, track_vars_array);
-
- p = inet_ntoa(TG(req)->client_host);
- /* string representation of IPs are never larger than 512 bytes */
- if (p) {
- memcpy(buf, p, strlen(p) + 1);
- ADD_STRING("REMOTE_ADDR");
- ADD_STRING("REMOTE_HOST");
- }
-
- snprintf(buf, sizeof(buf), "%d", CGI_SERVER_PORT(TG(req)));
- ADD_STRING("SERVER_PORT");
-
-#if 0
- snprintf(buf, BUF_SIZE, "/%s", TG(hc)->pathinfo);
- ADD_STRING("PATH_INFO");
-
- snprintf(buf, BUF_SIZE, "/%s", TG(hc)->origfilename);
- ADD_STRING("SCRIPT_NAME");
-#endif
-
-#define CONDADD(name, field) \
- if (TG(req)->field[0]) { \
- php_register_variable(#name, TG(req)->field, track_vars_array); \
- }
-
- CONDADD(HTTP_REFERER, referer);
- CONDADD(HTTP_USER_AGENT, user_agent);
- CONDADD(HTTP_ACCEPT, accept);
- CONDADD(HTTP_ACCEPT_ENCODING, accept_encoding);
- CONDADD(HTTP_ACCEPT_LANGUAGE, accept_language);
- CONDADD(HTTP_COOKIE, cookies);
- CONDADD(CONTENT_TYPE, content_type);
-
-#if 0
- if (TG(hc)->contentlength != -1) {
- snprintf(buf, sizeof(buf), "%ld", (long) TG(hc)->contentlength);
- ADD_STRING("CONTENT_LENGTH");
- }
-#endif
-
-#if 0
- if (TG(hc)->authorization[0])
- php_register_variable("AUTH_TYPE", "Basic", track_vars_array);
-#endif
-}
-
-
-static int php_tux_startup(sapi_module_struct *sapi_module)
-{
- if (php_module_startup(sapi_module, NULL, 0)==FAILURE) {
- return FAILURE;
- } else {
- return SUCCESS;
- }
-}
-
-static sapi_module_struct tux_sapi_module = {
- "tux",
- "tux",
-
- php_tux_startup,
- php_module_shutdown_wrapper,
-
- NULL, /* activate */
- NULL, /* deactivate */
-
- sapi_tux_ub_write,
- NULL,
- NULL, /* get uid */
- NULL, /* getenv */
-
- php_error,
-
- NULL,
- sapi_tux_send_headers,
- NULL,
- sapi_tux_read_post,
- sapi_tux_read_cookies,
-
- sapi_tux_register_variables,
- NULL, /* Log message */
- NULL, /* Get request time */
- NULL, /* Child terminate */
-
- STANDARD_SAPI_MODULE_PROPERTIES
-};
-
-static void tux_module_main(void)
-{
- zend_file_handle file_handle;
-
- 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() == FAILURE) {
- return;
- }
-
- php_execute_script(&file_handle);
- php_request_shutdown(NULL);
-}
-
-static void tux_request_ctor(void)
-{
- char buf[1024];
- int offset;
- size_t filename_len;
- size_t cwd_len;
- smart_str s = {0};
- char *p;
-
- TG(number_vec) = 0;
- TG(header_vec) = NULL;
- SG(request_info).query_string = strdup(TG(req)->query);
-
- smart_str_appends_ex(&s, "/", 1);
- smart_str_appends_ex(&s, TG(req)->query, 1);
- smart_str_0(&s);
- p = strchr(s.c, '&');
- if (p)
- *p = '\0';
- SG(request_info).path_translated = s.c;
-
- s.c = NULL;
- smart_str_appendc_ex(&s, '/', 1);
- smart_str_appends_ex(&s, TG(req)->objectname, 1);
- smart_str_0(&s);
- SG(request_info).request_uri = s.c;
- SG(request_info).request_method = CGI_REQUEST_METHOD(TG(req));
- if(TG(req)->http_version == HTTP_1_1) SG(request_info).proto_num = 1001;
- else SG(request_info).proto_num = 1000;
- SG(sapi_headers).http_response_code = 200;
- SG(request_info).content_type = TG(req)->content_type;
- SG(request_info).content_length = 0; /* TG(req)->contentlength; */
-
-#if 0
- php_handle_auth_data(TG(hc)->authorization);
-#endif
-}
-
-static void tux_request_dtor(void)
-{
- if (TG(header_vec)) {
- /* free status_line */
- free(TG(header_vec)[0].iov_base);
- free(TG(header_vec));
- }
- if (SG(request_info).query_string)
- free(SG(request_info).query_string);
- free(SG(request_info).request_uri);
- free(SG(request_info).path_translated);
-}
-
-#if 0
-static void *separate_thread(void *bla)
-{
- int fd;
- int i = 0;
-
- fd = (int) bla;
-
- while (i++ < 5) {
- send(fd, "test<br />\n", 9, 0);
- sleep(1);
- }
-
- tux(TUX_ACTION_CONTINUE_REQ, (user_req_t *) fd);
- /* We HAVE to trigger some event on the fd. Otherwise
- fast_thread won't wake up, so that the eventloop
- won't be entered -> TUX hangs */
- shutdown(fd, 2);
- pthread_exit(NULL);
-}
-#endif
-
-int TUXAPI_handle_events(user_req_t *req)
-{
-
- if (req->event == PHP_TUX_BACKGROUND_CONN) {
- tux_closed_conn(req->sock);
- return tux(TUX_ACTION_FINISH_CLOSE_REQ, req);
- }
-
- TG(req) = req;
- TG(tux_action) = TUX_ACTION_FINISH_CLOSE_REQ;
-
- tux_request_ctor();
-
- tux_module_main();
-
- tux_request_dtor();
-
- return tux(TG(tux_action), req);
-}
-
-void tux_register_on_close(void (*arg)(int))
-{
- TG(on_close) = arg;
-}
-
-void tux_closed_conn(int fd)
-{
-
- if (TG(on_close)) TG(on_close)(fd);
-}
-
-int tux_get_fd(void)
-{
-
- return TG(req)->sock;
-}
-
-void tux_set_dont_close(void)
-{
-
- TG(req)->event = PHP_TUX_BACKGROUND_CONN;
- tux(TUX_ACTION_POSTPONE_REQ, TG(req));
- TG(tux_action) = TUX_ACTION_EVENTLOOP;
-}
-
-void TUXAPI_init(void)
-{
- sapi_startup(&tux_sapi_module);
- tux_sapi_module.startup(&tux_sapi_module);
- SG(server_context) = (void *) 1;
-}
-
-void doesnotmatter_fini(void)
-{
- if (SG(server_context) != NULL) {
- tux_sapi_module.shutdown(&tux_sapi_module);
- sapi_shutdown();
- }
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/sapi/webjames/CREDITS b/sapi/webjames/CREDITS
deleted file mode 100644
index 73a7983e92..0000000000
--- a/sapi/webjames/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-WebJames
-Alex Waugh
diff --git a/sapi/webjames/README b/sapi/webjames/README
deleted file mode 100644
index 15a7be3de0..0000000000
--- a/sapi/webjames/README
+++ /dev/null
@@ -1,28 +0,0 @@
-README for WebJames SAPI module
-by Alex Waugh <alex@alexwaugh.com>
-
-This is a SAPI module for the WebJames HTTP server, which runs on the
-RISC OS operating system.
-
-
-DOWNLOADS
-
-A recent (February 2002 or later) version of the GCCSDK cross compiler
-http://www.hard-mofo.dsvr.net/
-
-WebJames 0.35 or later
-http://www.webjames.alexwaugh.com/
-
-
-BUILDING
-
-$ cd php7
-$ ./configure \
- --host=arm-riscos-aof \
- --with-webjames=../webjames/src \
- --with-config-file-path=/Choices: \
- other PHP options
-$ make install
-$ cd ../webjames
-$ ./configure --enable-php
-$ make
diff --git a/sapi/webjames/config.m4 b/sapi/webjames/config.m4
deleted file mode 100644
index 78c8a1936d..0000000000
--- a/sapi/webjames/config.m4
+++ /dev/null
@@ -1,21 +0,0 @@
-dnl
-dnl $Id$
-dnl
-
-PHP_ARG_WITH(webjames,,
-[ --with-webjames=SRCDIR Build PHP as a WebJames module (RISC OS only)], no, no)
-
-AC_MSG_CHECKING([for webjames])
-
-if test "$PHP_WEBJAMES" != "no"; then
- PHP_EXPAND_PATH($PHP_WEBJAMES, PHP_WEBJAMES)
- INSTALL_IT="\
- echo 'PHP_LIBS = -l$abs_srcdir/$SAPI_STATIC \$(PHP_LIBS) \$(EXTRA_LIBS)' > $PHP_WEBJAMES/build/php; \
- echo 'PHP_LDFLAGS = \$(NATIVE_RPATHS) \$(PHP_LDFLAGS)' >> $PHP_WEBJAMES/build/php; \
- echo 'PHP_CFLAGS = -DPHP \$(COMMON_FLAGS) \$(EXTRA_CFLAGS) -I$abs_srcdir/sapi/webjames' >> $PHP_WEBJAMES/build/php;"
- PHP_ADD_INCLUDE($PHP_WEBJAMES)
- PHP_SELECT_SAPI(webjames, static, webjames.c)
- AC_MSG_RESULT([yes, using $PHP_WEBJAMES])
-else
- AC_MSG_RESULT(no)
-fi
diff --git a/sapi/webjames/php_webjames.h b/sapi/webjames/php_webjames.h
deleted file mode 100644
index 63a9b047fb..0000000000
--- a/sapi/webjames/php_webjames.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.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: Alex Waugh <alex@alexwaugh.com> |
- +----------------------------------------------------------------------+
-*/
-
-#ifndef PHP_WEBJAMES_H
-#define PHP_WEBJAMES_H
-
-#include "webjames.h"
-
-void webjames_php_shutdown(void);
-int webjames_php_init(void);
-void webjames_php_request(struct connection *conn);
-
-#endif
diff --git a/sapi/webjames/webjames.c b/sapi/webjames/webjames.c
deleted file mode 100644
index 02c7dcf1c1..0000000000
--- a/sapi/webjames/webjames.c
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.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: Alex Waugh <alex@alexwaugh.com> |
- +----------------------------------------------------------------------+
-*/
-
-
-#include "php.h"
-#include "SAPI.h"
-#include "php_main.h"
-#include "php_variables.h"
-
-#define WEBJAMES_PHP_ONLY
-#include "php_webjames.h"
-
-#include <unixlib/local.h>
-
-#define WEBJAMES_SAPI_VERSION "1.0.2"
-
-typedef struct {
- struct connection *conn; /*structure holding all the details of the current request*/
- int bodyread; /*amount of POST body read*/
- closefn oldclose; /*function to call to close the connection*/
-} php_webjames_globals;
-
-static php_webjames_globals webjames_globals;
-
-#define WG(v) (webjames_globals.v)
-
-static int sapi_webjames_ub_write(const char *str, uint str_length)
-/*unbuffered write - send data straight out to socket*/
-{
- int totalbytes = 0;
-
- do {
- int bytes;
- bytes = webjames_writebuffer(WG(conn),str,str_length);
- if (bytes<0) {
- PG(connection_status) = PHP_CONNECTION_ABORTED;
- if (!PG(ignore_user_abort)) {
- zend_bailout();
- }
- return bytes;
- }
- str += bytes;
- str_length -= bytes;
- totalbytes += bytes;
- } while (str_length);
- return totalbytes;
-}
-
-static void sapi_webjames_send_header(sapi_header_struct *sapi_header, void *server_context)
-/*send an HTTP header*/
-{
- char *header = sapi_header->header;
- int len = sapi_header->header_len;
- if (WG(conn)->flags.outputheaders) {
- while (sapi_header && len > 0) {
- int bytes;
- bytes = webjames_writebuffer(WG(conn), header, len);
- if (bytes<0) {
- PG(connection_status) = PHP_CONNECTION_ABORTED;
- if (!PG(ignore_user_abort)) {
- zend_bailout();
- }
- return;
- }
- header += bytes;
- len -= bytes;
- }
- webjames_writestring(WG(conn), "\r\n");
- }
-}
-
-static int sapi_webjames_read_post(char *buffer, uint count_bytes)
-/*read some of the post data*/
-{
- if (WG(conn)->body==NULL) return 0;
- if (count_bytes+WG(bodyread)>WG(conn)->bodysize) count_bytes=WG(conn)->bodysize-WG(bodyread);
- memcpy(buffer, WG(conn)->body+WG(bodyread), count_bytes);
- WG(bodyread)+=count_bytes;
- return count_bytes;
-}
-
-static char *sapi_webjames_read_cookies(void)
-{
- return WG(conn)->cookie;
-}
-
-#define BUF_SIZE 512
-#define ADD_STRING(name,string)\
- php_register_variable(name, string, track_vars_array)
-
-#define ADD_NUM(name,field) {\
- snprintf(buf, BUF_SIZE, "%d", WG(conn)->field);\
- php_register_variable(name, buf, track_vars_array);\
-}
-
-#define ADD_FIELD(name, field) \
- if (WG(conn)->field) { \
- php_register_variable(name, WG(conn)->field, track_vars_array); \
- }
-
-static void sapi_webjames_register_variables(zval *track_vars_array)
-{
- char buf[BUF_SIZE + 1];
- char *docroot;
-
- buf[BUF_SIZE] = '\0';
-
- ADD_STRING("SERVER_SOFTWARE", configuration.server);
- ADD_STRING("SERVER_NAME", configuration.serverip);
- ADD_FIELD("SERVER_PROTOCOL", protocol);
- ADD_NUM("SERVER_PORT", port);
- ADD_STRING("SERVER_ADMIN",configuration.webmaster);
- ADD_STRING("GATEWAY_INTERFACE", "CGI/1.1");
-
- docroot = __unixify(WG(conn)->homedir,0,NULL,1024,0);
- if (docroot) ADD_STRING("DOCUMENT_ROOT", docroot);
-
- ADD_FIELD("REQUEST_METHOD", methodstr);
- ADD_FIELD("REQUEST_URI", requesturi);
- ADD_STRING("PATH_TRANSLATED", SG(request_info).path_translated);
- ADD_FIELD("SCRIPT_NAME", uri);
- ADD_FIELD("PHP_SELF", uri);
- ADD_FIELD("QUERY_STRING", args);
-
-
- snprintf(buf, BUF_SIZE, "%d.%d.%d.%d", WG(conn)->ipaddr[0], WG(conn)->ipaddr[1], WG(conn)->ipaddr[2], WG(conn)->ipaddr[3]);
- ADD_STRING("REMOTE_ADDR", buf);
- if (WG(conn)->dnsstatus == DNS_OK) ADD_FIELD("REMOTE_HOST", host);
-
- if ((WG(conn)->method == METHOD_POST) || (WG(conn)->method == METHOD_PUT)) {
- ADD_NUM("CONTENT_LENGTH", bodysize);
- ADD_FIELD("CONTENT_TYPE", type);
- }
-
- if ((WG(conn)->method == METHOD_PUT) || (WG(conn)->method == METHOD_DELETE)) ADD_FIELD("ENTITY_PATH", requesturi);
-
- if (WG(conn)->pwd) {
- ADD_STRING("AUTH_TYPE", "basic");
- ADD_FIELD("REMOTE_USER", authorization);
- }
-
- ADD_FIELD("HTTP_COOKIE", cookie);
- ADD_FIELD("HTTP_USER_AGENT", useragent);
- ADD_FIELD("HTTP_REFERER", referer);
- ADD_FIELD("HTTP_ACCEPT", accept);
- ADD_FIELD("HTTP_ACCEPT_LANGUAGE", acceptlanguage);
- ADD_FIELD("HTTP_ACCEPT_CHARSET", acceptcharset);
- ADD_FIELD("HTTP_ACCEPT_ENCODING", acceptencoding);
-}
-
-static void webjames_module_main(void)
-{
- zend_file_handle file_handle;
- FILE *fp=NULL;
- char *path;
-
- /* Convert filename to Unix format*/
- __riscosify_control|=__RISCOSIFY_STRICT_UNIX_SPECS;
- path = __unixify(WG(conn)->filename,0,NULL,1024,0);
- if (path) SG(request_info).path_translated = estrdup(path);
-
- SG(request_info).query_string = WG(conn)->args;
- SG(request_info).request_uri = WG(conn)->requesturi;
- SG(request_info).request_method = WG(conn)->methodstr;
- if (WG(conn)->method==METHOD_HEAD) {
- SG(request_info).headers_only = 1;
- } else {
- SG(request_info).headers_only = 0;
- }
- SG(sapi_headers).http_response_code = 200;
- SG(request_info).content_type = WG(conn)->type;
- SG(request_info).content_length = WG(conn)->bodysize;
-
- SG(request_info).auth_user = NULL;
- SG(request_info).auth_password = NULL;
- if (WG(conn)->authorization) {
- char *colon=strchr(WG(conn)->authorization,':');
- if (colon) {
- SG(request_info).auth_user = emalloc(colon-WG(conn)->authorization+1);
- if (SG(request_info).auth_user) {
- memcpy(SG(request_info).auth_user,WG(conn)->authorization,colon-WG(conn)->authorization);
- SG(request_info).auth_user[colon-WG(conn)->authorization]='\0';
- SG(request_info).auth_password = estrdup(colon+1);
- }
- }
- }
-
- /*ensure that syslog calls get logged separately from WebJames' main log */
- openlog("PHP",0,0);
-
- 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() == FAILURE) {
- return;
- }
-
- php_execute_script(&file_handle);
- php_request_shutdown(NULL);
-}
-
-static void webjames_php_close(struct connection *conn, int force)
-/*called by webjames if it wants to close the connection*/
-{
-
- php_request_shutdown(NULL);
- WG(oldclose)(conn,force);
-}
-
-void webjames_php_request(struct connection *conn)
-/*called by WebJames to start handler*/
-{
-
- WG(conn) = conn;
- WG(bodyread) = 0;
- WG(oldclose) = conn->close;
- conn->close=webjames_php_close;
-
- webjames_module_main();
-
- WG(oldclose)(WG(conn), 0);
-}
-
-static void php_info_webjames(ZEND_MODULE_INFO_FUNC_ARGS)
-{
- php_info_print_table_start();
- php_info_print_table_row(2, "SAPI module version", WEBJAMES_SAPI_VERSION);
- php_info_print_table_row(2, "WebJames version", WEBJAMES_VERSION " (" WEBJAMES_DATE ")");
- php_info_print_table_end();
-}
-
-static zend_module_entry php_webjames_module = {
-#if ZEND_MODULE_API_NO >= 20010901
- STANDARD_MODULE_HEADER,
-#endif
- "WebJames",
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- php_info_webjames,
-#if ZEND_MODULE_API_NO >= 20010901
- WEBJAMES_SAPI_VERSION,
-#endif
- STANDARD_MODULE_PROPERTIES
-};
-
-
-static int php_webjames_startup(sapi_module_struct *sapi_module)
-{
- if(php_module_startup(sapi_module, &php_webjames_module, 1) == FAILURE) {
- return FAILURE;
- } else {
- return SUCCESS;
- }
-}
-
-static sapi_module_struct sapi_module = {
- "webjames", /* name */
- "WebJames", /* pretty name */
-
- php_webjames_startup, /* startup */
- php_module_shutdown_wrapper, /* shutdown */
-
- NULL, /* activate */
- NULL, /* deactivate */
-
- sapi_webjames_ub_write, /* unbuffered write */
- NULL, /* flush */
- NULL, /* get uid */
- NULL, /* getenv */
-
- php_error, /* error handler */
-
- NULL, /* header handler */
- NULL, /* send headers handler */
- sapi_webjames_send_header, /* send header handler */
- sapi_webjames_read_post, /* read POST data */
- sapi_webjames_read_cookies, /* read Cookies */
-
- sapi_webjames_register_variables, /* register server variables */
- NULL, /* Log message */
- NULL, /* Get request time */
- NULL, /* Child terminate */
-
- STANDARD_SAPI_MODULE_PROPERTIES
-};
-
-int webjames_php_init(void)
-/*called when WebJames initialises*/
-{
- if (strcmp(configuration.webjames_h_revision,WEBJAMES_H_REVISION)!=0) {
- /*This file was compiled against a different revision of
- webjames.h than webjames was, which could be bad news*/
- webjames_writelog(0,"PHP module is compiled for WebJames (%s) and was linked with a different version (%s)",WEBJAMES_H_REVISION,configuration.webjames_h_revision);
- return 0; /*failed to initialise*/
- }
- sapi_startup(&sapi_module);
- sapi_module.startup(&sapi_module);
- SG(server_context) = (void *) 1;
- return 1; /*initialised correctly*/
-}
-
-void webjames_php_shutdown(void)
-/*called when WebJames is about to quit*/
-{
- sapi_module.shutdown(&sapi_module);
- sapi_shutdown();
-}