NSAPI: patch for environment vars
| From: | Whitehead Anthony | Date: | Thu, 25 May 2000 18:43:53 +0000 |
| Subject: | NSAPI: patch for environment vars | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-19433@lists.php.net to get a copy of this message | ||
Hiyas,
Ok, here is a small patch which adds the request header vars, including
the PHP_SELF. This is just a very quick hack which builds on the code
already present and should give a good starting point to add the rest
of the needed variables. If anyone is currently maintaining this module
can they contact me so we can coordinate our efforts and get this puppy
into a final stable version.
This patch should be applied to PHP4.0.0 with the ZTS patch already present.
-Anthony Whitehead
Swedish Social Security Ministry
--- nsapi.c.origThu May 25 18:03:49 2000
+++ nsapi.c Thu May 25 19:33:01 2000
@@ -23,6 +23,7 @@
#define XP_UNIX
#include "php.h"
+#include "php_variables.h"
#include "ext/standard/info.h"
#include "php_ini.h"
#include "php_globals.h"
@@ -30,6 +31,7 @@
#include "main.h"
#include "php_version.h"
#include "TSRM.h"
+#include "ext/standard/php_standard.h"
/*
* If neither XP_UNIX not XP_WIN32 is defined, try to guess which one.
@@ -266,6 +268,31 @@
return cookie_string;
}
+static void
+sapi_nsapi_register_server_variables(zval *track_vars_array ELS_DC SLS_DC
PLS_DC)
+{
+ nsapi_request_context *rc = (nsapi_request_context *)SG(server_context);
+ size_t i;
+ char *value = NULL;
+ char buf[128];
+
+ *buf = 0;
+ for (i = 0; i < nsapi_reqpb_size; i++) {
+ if ((value = pblock_findval(nsapi_reqpb[i].nsapi_eq,
rc->rq->reqpb)) == NULL) {
+ value = buf;
+ }
+ php_register_variable( (char *)nsapi_reqpb[i].env_var, value,
track_vars_array ELS_CC PLS_CC );
+ }
+
+ /*
+ * Special PHP_SELF variable.
+ */
+ value = pblock_findval( "uri", rc->rq->reqpb );
+ if( value != NULL ) {
+ php_register_variable( "PHP_SELF", value, track_vars_array
ELS_CC
PLS_CC );
+ }
+}
+
static sapi_module_struct sapi_module = {
"NSAPI", /* name */
@@ -289,7 +316,7 @@
sapi_nsapi_read_post, /* read POST data */
sapi_nsapi_read_cookies, /* read Cookies */
- NULL, /* register server variables */
+ sapi_nsapi_register_server_variables, /* register server variables */
NULL, /* Log message */
NULL, /* Block interruptions */