summaryrefslogtreecommitdiff
path: root/sapi
diff options
context:
space:
mode:
authorAnthony Whitehead <antw@php.net>2000-05-30 13:20:18 +0000
committerAnthony Whitehead <antw@php.net>2000-05-30 13:20:18 +0000
commitc6449f307aaf604295d5429ac0611a9307d142bb (patch)
treec7ac310e3da4b94a6f61c50eb2cdafdd690a9df6 /sapi
parent8c65f816764e9890a4bc1f560ea3c70affff4b05 (diff)
downloadphp-git-c6449f307aaf604295d5429ac0611a9307d142bb.tar.gz
Altered NSAPI autoconf to check for location of include files automatically, tested for Netscape 3.x and iPlanet 4.x.
Added very basic variable support for usefull things such as PHP_SELF. I'll extend this to supply this rest of the variables soon. Commited a patch to activate ZTS in the NSAPI module, this patch comes from Jayakumar Muthukumarasamy.
Diffstat (limited to 'sapi')
-rw-r--r--sapi/nsapi/config.m415
-rw-r--r--sapi/nsapi/nsapi-readme.txt19
-rw-r--r--sapi/nsapi/nsapi.c99
3 files changed, 82 insertions, 51 deletions
diff --git a/sapi/nsapi/config.m4 b/sapi/nsapi/config.m4
index 202e4ad9f8..0a553a171b 100644
--- a/sapi/nsapi/config.m4
+++ b/sapi/nsapi/config.m4
@@ -13,14 +13,27 @@ if test "$PHP_NSAPI" != "no"; then
if test ! -d $PHP_NSAPI/bin ; then
AC_MSG_ERROR(Please specify the path to the root of your Netscape server using --with-nsapi=DIR)
fi
+ AC_MSG_CHECKING(for NSAPI include files)
+ NSAPI_INCLUDE=""
+ if test -d $PHP_NSAPI/include ; then
+ NSAPI_INCLUDE=$PHP_NSAPI/include
+ AC_MSG_RESULT(Netscape-Enterprise/3.x style)
+ elif test -d $PHP_NSAPI/plugins/include ; then
+ NSAPI_INCLUDE=$PHP_NSAPI/plugins/include
+ AC_MSG_RESULT(iPlanet/4.x style)
+ else
+ AC_MSG_ERROR(Please check you have nsapi.h in either DIR/include or DIR/plugins/include)
+ fi
+ AC_ADD_INCLUDE($NSAPI_INCLUDE)
PHP_BUILD_THREAD_SAFE
- AC_ADD_INCLUDE($PHP_NSAPI/include)
AC_DEFINE(HAVE_NSAPI,1,[Whether you have a Netscape Server])
PHP_SAPI=nsapi
PHP_BUILD_SHARED
INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED $PHP_NSAPI/bin/"
fi
+INCLUDES="$INCLUDES -I$NSAPI_INCLUDE"
+
dnl ## Local Variables:
dnl ## tab-width: 4
dnl ## End:
diff --git a/sapi/nsapi/nsapi-readme.txt b/sapi/nsapi/nsapi-readme.txt
index 79b97636f5..2862a44e02 100644
--- a/sapi/nsapi/nsapi-readme.txt
+++ b/sapi/nsapi/nsapi-readme.txt
@@ -1,14 +1,27 @@
-nsapi configuration file information
+Configuration of your Netscape or iPlanet Web Server for PHP4
+-------------------------------------------------------------
+
+These instructions are targetted at Netscape Enterprise Web Server
+and SUN/Netscape Alliance iPlanet Web Server. On other web servers
+your milage may vary.
+
+Firstly you may need to add some paths to the LD_LIBRARY_PATH
+environment for netscape to find all the shared libs. This is
+best done in the start script for your netscape server.
+Windows users can probably skip this step. The start
+script is located in:
+<path-to-netscape-server>/https-servername/start
netscape config files are located in:
-/netscape/suitespot/httpd-servername/config
+<path-to-netscape-server>/https-servername/config
add the following line to mime.types
type=magnus-internal/x-httpd-php exts=php
-Add the following to obj.conf
+Add the following to obj.conf, shlib will vary depending on your OS, for unix it
+will be something like "<path-to-netscape-server>/bin/libphp4.so".
#note place following two lines after mime types init!
Init fn="load-modules" funcs="php4_init,php4_close,php4_execute,php4_auth_trans" shlib="/php4/nsapiPHP4.dll"
diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c
index b0f50b6ec5..e413c6ed25 100644
--- a/sapi/nsapi/nsapi.c
+++ b/sapi/nsapi/nsapi.c
@@ -20,16 +20,30 @@
* PHP includes
*/
#define NSAPI 1
+#define XP_UNIX
#include "php.h"
-
+#include "php_variables.h"
#include "ext/standard/info.h"
-
#include "php_ini.h"
#include "php_globals.h"
#include "SAPI.h"
#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.
+ * Ideally, this should be done by the configure script.
+ */
+#if !defined(XP_UNIX) && !defined(XP_WIN32)
+ #if defined(WIN32)
+ #define XP_WIN32
+ #else
+ #define XP_UNIX
+ #endif
+#endif
/*
* NSAPI includes
@@ -44,7 +58,7 @@
/* for unix */
#ifndef WINAPI
-#define WINAPI
+ #define WINAPI
#endif
/*
@@ -59,15 +73,10 @@
#define NSG(v) (request_context->v)
/*
- * Currently, this doesn't work with ZTS.
+ * ZTS needs to be defined for NSAPI to work
*/
-#if defined(ZTS)
- #define IF_ZTS(a) a
- #define IF_NOT_ZTS(a)
-#else
- #define IF_ZTS(a)
- #define IF_NOT_ZTS(a) a
- static CRITICAL php_mutex;
+#if !defined(ZTS)
+ #error "NSAPI module needs ZTS to be defined"
#endif
/*
@@ -259,6 +268,31 @@ sapi_nsapi_read_cookies(SLS_D)
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 */
@@ -282,7 +316,7 @@ static sapi_module_struct sapi_module = {
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 */
@@ -391,7 +425,7 @@ nsapi_request_ctor(NSLS_D SLS_DC)
if (uri != NULL)
path_translated = request_translate_uri(uri, NSG(sn));
-#if 0
+#if defined(NSAPI_DEBUG)
log_error(LOG_INFORM, "nsapi_request_ctor", NSG(sn), NSG(rq),
"query_string = %s, "
"uri = %s, "
@@ -445,7 +479,7 @@ nsapi_module_main(NSLS_D SLS_DC)
file_handle.filename = SG(request_info).path_translated;
file_handle.free_filename = 0;
-#if 0
+#if defined(NSAPI_DEBUG)
log_error(LOG_INFORM, "nsapi_module_main", NSG(sn), NSG(rq),
"Parsing [%s]", SG(request_info).path_translated);
#endif
@@ -468,32 +502,20 @@ php4_close(void *vparam)
if (sapi_module.shutdown) {
sapi_module.shutdown(&sapi_module);
}
- IF_ZTS(
- tsrm_shutdown();
- )
+ tsrm_shutdown();
}
int WINAPI
php4_init(pblock *pb, Session *sn, Request *rq)
{
- PLS_FETCH();
+ php_core_globals *core_globals;
- /*
- * TSRM has not been tested.
- */
- IF_ZTS(
- tsrm_startup(1, 1, 0);
- )
+ tsrm_startup(1, 1, 0);
+ core_globals = ts_resource(core_globals_id);
sapi_startup(&sapi_module);
sapi_module.startup(&sapi_module);
- PG(expose_php) = 0;
-
- IF_NOT_ZTS(
- php_mutex = crit_init();
- )
-
log_error(LOG_INFORM, "php4_init", sn, rq, "Initialized PHP Module\n");
return REQ_PROCEED;
}
@@ -511,29 +533,12 @@ php4_execute(pblock *pb, Session *sn, Request *rq)
request_context->sn = sn;
request_context->rq = rq;
- /*
- * Single thread the execution, if ZTS is not enabled. Need to
- * understand the behavior of Netscape server when the client
- * cancels a request when it is in progress. This could cause
- * a deadlock if the thread handling the specific client is not
- * cancelled because the php_mutex will likely remain locked
- * until the request that was cancelled completes. The behavior
- * is also going to be platform specific.
- */
- IF_NOT_ZTS(
- crit_enter(php_mutex);
- )
-
SG(server_context) = request_context;
nsapi_request_ctor(NSLS_C SLS_CC);
retval = nsapi_module_main(NSLS_C SLS_CC);
nsapi_request_dtor(NSLS_C SLS_CC);
- IF_NOT_ZTS(
- crit_exit(php_mutex);
- )
-
free(request_context);
return (retval == SUCCESS) ? REQ_PROCEED : REQ_EXIT;