holger Sun Dec 5 04:48:48 2004 EDT
Modified files: (Branch: PHP_4_3)
/php-src/sapi/pi3web pi3web_sapi.c php4pi3web.dsp pi3web_sapi.h
Log:
Replaced static server variables by function call and configurable list at
the Pi3Web server side.
http://cvs.php.net/diff.php/php-src/sapi/pi3web/pi3web_sapi.c?r1=1.46.2.6&r2=1.46.2.7&ty=u
Index: php-src/sapi/pi3web/pi3web_sapi.c
diff -u php-src/sapi/pi3web/pi3web_sapi.c:1.46.2.6
php-src/sapi/pi3web/pi3web_sapi.c:1.46.2.7
--- php-src/sapi/pi3web/pi3web_sapi.c:1.46.2.6 Mon Jun 2 13:14:10 2003
+++ php-src/sapi/pi3web/pi3web_sapi.c Sun Dec 5 04:48:48 2004
@@ -21,11 +21,10 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pi3web_sapi.c,v 1.46.2.6 2003/06/02 17:14:10 holger Exp $ */
+/* $Id: pi3web_sapi.c,v 1.46.2.7 2004/12/05 09:48:48 holger Exp $ */
#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
-#include "pi3web_sapi.h"
#include "php.h"
#include "php_main.h"
#include "php_variables.h"
@@ -40,45 +39,25 @@
#include "PiAPI.h"
#include "Pi3API.h"
+#include "pi3web_sapi.h"
+
#define PI3WEB_SERVER_VAR_BUF_SIZE 1024
int IWasLoaded=0;
-static char *pi3web_server_variables[] = {
- "ALL_HTTP",
- "AUTH_TYPE",
- "CONTENT_LENGTH",
- "CONTENT_TYPE",
- "GATEWAY_INTERFACE",
- "PATH_INFO",
- "PATH_TRANSLATED",
- "QUERY_STRING",
- "REQUEST_METHOD",
- "REMOTE_ADDR",
- "REMOTE_HOST",
- "REMOTE_USER",
- "SCRIPT_NAME",
- "SERVER_NAME",
- "SERVER_PORT",
- "SERVER_PROTOCOL",
- "SERVER_SOFTWARE",
- NULL
-};
-
static void php_info_pi3web(ZEND_MODULE_INFO_FUNC_ARGS)
{
- char **p = pi3web_server_variables;
char variable_buf[PI3WEB_SERVER_VAR_BUF_SIZE];
DWORD variable_len;
- LPCONTROL_BLOCK lpCB;
-
- lpCB = (LPCONTROL_BLOCK) SG(server_context);
+ 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:
pi3web_sapi.c,v 1.46.2.6 2003/06/02 17:14:10 holger Exp $");
+ php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id:
pi3web_sapi.c,v 1.46.2.7 2004/12/05 09:48:48 holger Exp $");
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);
@@ -99,22 +78,28 @@
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");
- while (*p) {
+
+ /* --- 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, *p, variable_buf,
&variable_len)
+ if (lpCB->GetServerVariable(lpCB->ConnID, pKey, variable_buf,
&variable_len)
&& variable_buf[0]) {
- php_info_print_table_row(2, *p, variable_buf);
+ 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, *p,
tmp_variable_buf, &variable_len)
+ if (lpCB->GetServerVariable(lpCB->ConnID, pKey,
tmp_variable_buf, &variable_len)
&& variable_buf[0]) {
- php_info_print_table_row(2, *p,
tmp_variable_buf);
+ php_info_print_table_row(2, pKey,
tmp_variable_buf);
}
efree(tmp_variable_buf);
}
- p++;
}
PUTS("</table>");
@@ -297,26 +282,29 @@
char static_variable_buf[PI3WEB_SERVER_VAR_BUF_SIZE];
char *variable_buf;
DWORD variable_len = PI3WEB_SERVER_VAR_BUF_SIZE;
- char *variable;
- char *strtok_buf = NULL;
LPCONTROL_BLOCK lpCB = (LPCONTROL_BLOCK) SG(server_context);
- char **p = pi3web_server_variables;
- p++; // Jump over ALL_HTTP;
+ 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; };
- /* Register the standard server variables */
- while (*p) {
variable_len = PI3WEB_SERVER_VAR_BUF_SIZE;
- if (lpCB->GetServerVariable(lpCB->ConnID, *p,
static_variable_buf, &variable_len)
+ if (lpCB->GetServerVariable(lpCB->ConnID, pKey,
static_variable_buf, &variable_len)
&& (variable_len > 1)) {
- php_register_variable(*p, static_variable_buf,
track_vars_array TSRMLS_CC);
+ php_register_variable(pKey, static_variable_buf,
track_vars_array TSRMLS_CC);
} else if (PIPlatform_getLastError()==PIAPI_EINVAL) {
variable_buf = (char *) emalloc(variable_len);
- if (lpCB->GetServerVariable(lpCB->ConnID, *p,
variable_buf, &variable_len)) {
- php_register_variable(*p, variable_buf,
track_vars_array TSRMLS_CC);
+ if (lpCB->GetServerVariable(lpCB->ConnID, pKey,
variable_buf, &variable_len)) {
+ php_register_variable(pKey, variable_buf,
track_vars_array TSRMLS_CC);
}
efree(variable_buf);
}
- p++;
+
}
/* PHP_SELF support */
@@ -325,40 +313,6 @@
&& (variable_len > 1)) {
php_register_variable("PHP_SELF", static_variable_buf,
track_vars_array TSRMLS_CC);
}
-
- variable_len = PI3WEB_SERVER_VAR_BUF_SIZE;
- if (lpCB->GetServerVariable(lpCB->ConnID, "ALL_HTTP",
static_variable_buf, &variable_len)
- && (variable_len > 1)) {
- variable_buf = static_variable_buf;
- } else {
- if (PIPlatform_getLastError()==PIAPI_EINVAL) {
- variable_buf = (char *) emalloc(variable_len);
- if (!lpCB->GetServerVariable(lpCB->ConnID, "ALL_HTTP",
variable_buf, &variable_len)) {
- efree(variable_buf);
- return;
- }
- } else {
- return;
- }
- }
- variable = php_strtok_r(variable_buf, "\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
TSRMLS_CC);
- *colon = ':';
- }
- variable = php_strtok_r(NULL, "\r\n", &strtok_buf);
- }
- if (variable_buf!=static_variable_buf) {
- efree(variable_buf);
- }
}
static sapi_module_struct pi3web_sapi_module = {
http://cvs.php.net/diff.php/php-src/sapi/pi3web/php4pi3web.dsp?r1=1.2.12.1&r2=1.2.12.2&ty=u
Index: php-src/sapi/pi3web/php4pi3web.dsp
diff -u php-src/sapi/pi3web/php4pi3web.dsp:1.2.12.1
php-src/sapi/pi3web/php4pi3web.dsp:1.2.12.2
--- php-src/sapi/pi3web/php4pi3web.dsp:1.2.12.1 Sun Jun 29 20:44:03 2003
+++ php-src/sapi/pi3web/php4pi3web.dsp Sun Dec 5 04:48:48 2004
@@ -43,7 +43,7 @@
# PROP Intermediate_Dir "Debug_TS"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D
"_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "php4pi3web_EXPORTS" /YX /FD /GZ /c
+# ADD BASE CPP /nologo /MTd /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D
"_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP4PI3WEB_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "...\..\include" /I "..\..\win32" /I
"..\..\Zend" /I "..\.." /I "..\..\main" /I "..\..\TSRM" /D "_DEBUG" /D
ZEND_DEBUG=1 /D "_WINDOWS" /D "_USRDLL" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32"
/D "WIN32" /D "_MBCS" /D "PHP4PI3WEB_EXPORTS" /FR /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
@@ -69,7 +69,7 @@
# PROP Intermediate_Dir "Release_TS"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D
"_MBCS" /D "_USRDLL" /D "php4pi3web_EXPORTS" /YX /FD /c
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D
"_MBCS" /D "_USRDLL" /D "PHP4PI3WEB_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I
"..\..\Zend" /I "..\.." /I "..\..\main" /I "..\..\TSRM" /D "NDEBUG" /D
ZEND_DEBUG=0 /D "_WINDOWS" /D "_USRDLL" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32"
/D "WIN32" /D "_MBCS" /D "PHP4PI3WEB_EXPORTS" /FR /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
http://cvs.php.net/diff.php/php-src/sapi/pi3web/pi3web_sapi.h?r1=1.4.8.1&r2=1.4.8.2&ty=u
Index: php-src/sapi/pi3web/pi3web_sapi.h
diff -u php-src/sapi/pi3web/pi3web_sapi.h:1.4.8.1
php-src/sapi/pi3web/pi3web_sapi.h:1.4.8.2
--- php-src/sapi/pi3web/pi3web_sapi.h:1.4.8.1 Mon Jun 2 13:14:10 2003
+++ php-src/sapi/pi3web/pi3web_sapi.h Sun Dec 5 04:48:48 2004
@@ -3,7 +3,6 @@
#ifdef PHP_WIN32
# include <windows.h>
-# include <httpext.h>
# ifdef PHP4PI3WEB_EXPORTS
# define MODULE_API __declspec(dllexport)
# else
@@ -15,7 +14,6 @@
typedef int BOOL;
typedef void far *LPVOID;
- typedef LPVOID HCONN;
typedef unsigned long DWORD;
typedef DWORD far *LPDWORD;
typedef char CHAR;
@@ -24,6 +22,8 @@
typedef BYTE far *LPBYTE;
#endif
+ typedef LPVOID HCONN;
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -59,17 +59,19 @@
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 ConnID,
- LPVOID Buffer,
+ BOOL (* WriteClient) ( HCONN hConn,
+ LPVOID lpvBuffer,
LPDWORD lpdwBytes,
DWORD dwReserved );
- BOOL (* ReadClient) ( HCONN ConnID,
+ BOOL (* ReadClient) ( HCONN hConn,
LPVOID lpvBuffer,
LPDWORD lpdwSize );
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php