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:
-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"
* 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
/* for unix */
#ifndef WINAPI
-#define WINAPI
+ #define WINAPI
#endif
/*
#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
/*
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 */
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 */
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, "
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
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;
}
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;