cvs: php4 /sapi/pi3web pi3web_sapi.c pi3web_sapi.h
| From: | Holger Zimmermann | Date: | Sat, 23 Feb 2002 15:17:00 +0000 |
| Subject: | cvs: php4 /sapi/pi3web pi3web_sapi.c pi3web_sapi.h | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-8820@lists.php.net to get a copy of this message | ||
holger Sat Feb 23 10:17:00 2002 EDT
Modified files:
/php4/sapi/pi3web pi3web_sapi.c pi3web_sapi.h
Log:
Fixed functionality to read in server variables.
Index: php4/sapi/pi3web/pi3web_sapi.c
diff -u php4/sapi/pi3web/pi3web_sapi.c:1.39 php4/sapi/pi3web/pi3web_sapi.c:1.40
--- php4/sapi/pi3web/pi3web_sapi.c:1.39 Thu Feb 14 15:16:07 2002
+++ php4/sapi/pi3web/pi3web_sapi.c Sat Feb 23 10:16:59 2002
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pi3web_sapi.c,v 1.39 2002/02/14 20:16:07 derick Exp $ */
+/* $Id: pi3web_sapi.c,v 1.40 2002/02/23 15:16:59 holger Exp $ */
#include "pi3web_sapi.h"
#include "php.h"
@@ -77,7 +77,7 @@
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.39 2002/02/14 20:16:07 derick Exp $");
+ php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: pi3web_sapi.c,v
1.40 2002/02/23 15:16:59 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);
@@ -276,32 +276,6 @@
return NULL;
}
-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 */
- NULL, /* register server variables */
- NULL, /* Log message */
- NULL, /* Block interruptions */
- NULL, /* Unblock interruptions */
-
- STANDARD_SAPI_MODULE_PROPERTIES
-};
-
static void init_request_info(LPCONTROL_BLOCK lpCB TSRMLS_DC)
{
char *path_end = strrchr(lpCB->lpszFileName, PHP_DIR_SEPARATOR);
@@ -319,17 +293,42 @@
SG(sapi_headers).http_response_code = 200;
}
-static void hash_pi3web_variables(TSRMLS_D)
+static void sapi_pi3web_register_variables(zval *track_vars_array TSRMLS_DC)
{
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 lpCB = (LPCONTROL_BLOCK) SG(server_context);
+ char **p = pi3web_server_variables;
+ p++; // Jump over ALL_HTTP;
- lpCB = (LPCONTROL_BLOCK) SG(server_context);
+ /* 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)
+ && static_variable_buf[0]) {
+ php_register_variable(*p, 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)
+ && variable_buf[0]) {
+ php_register_variable(*p, variable_buf, track_vars_array TSRMLS_CC);
+ }
+ efree(variable_buf);
+ }
+ p++;
+ }
+ /* PHP_SELF support */
+ variable_len = PI3WEB_SERVER_VAR_BUF_SIZE;
+ if (lpCB->GetServerVariable(lpCB->ConnID, "SCRIPT_NAME", static_variable_buf,
&variable_len)
+ && static_variable_buf[0]) {
+ 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_buf = static_variable_buf;
} else {
@@ -349,18 +348,11 @@
if (colon) {
char *value = colon+1;
- zval *entry;
- ALLOC_ZVAL(entry);
-
while (*value==' ') {
value++;
}
*colon = 0;
- INIT_PZVAL(entry);
- entry->value.str.len = strlen(value);
- entry->value.str.val = estrndup(value, entry->value.str.len);
- entry->type = IS_STRING;
- zend_hash_add(&EG(symbol_table), variable, strlen(variable)+1, &entry, sizeof(zval *),
NULL);
+ php_register_variable(variable, value, track_vars_array TSRMLS_CC);
*colon = ':';
}
variable = php_strtok_r(NULL, "\r\n", &strtok_buf);
@@ -370,6 +362,31 @@
}
}
+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, /* Block interruptions */
+ NULL, /* Unblock interruptions */
+
+ STANDARD_SAPI_MODULE_PROPERTIES
+};
DWORD PHP4_wrapper(LPCONTROL_BLOCK lpCB)
{
@@ -386,8 +403,6 @@
init_request_info(lpCB TSRMLS_CC);
php_request_startup(TSRMLS_C);
-
- hash_pi3web_variables(TSRMLS_C);
switch ( lpCB->dwBehavior ) {
case PHP_MODE_STANDARD:
Index: php4/sapi/pi3web/pi3web_sapi.h
diff -u php4/sapi/pi3web/pi3web_sapi.h:1.3 php4/sapi/pi3web/pi3web_sapi.h:1.4
--- php4/sapi/pi3web/pi3web_sapi.h:1.3 Fri Jul 20 17:00:17 2001
+++ php4/sapi/pi3web/pi3web_sapi.h Sat Feb 23 10:17:00 2002
@@ -37,7 +37,6 @@
// passed to the procedure on a new request
//
typedef struct _CONTROL_BLOCK {
- void *pPIHTTP;
DWORD cbSize; // size of this struct.
HCONN ConnID; // Context number not to be modified!
DWORD dwHttpStatusCode; // HTTP Status code