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.
This commit is contained in:
Anthony Whitehead 2000-05-30 13:20:18 +00:00
parent 8c65f81676
commit c6449f307a
3 changed files with 82 additions and 51 deletions

View file

@ -13,14 +13,27 @@ if test "$PHP_NSAPI" != "no"; then
if test ! -d $PHP_NSAPI/bin ; 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) AC_MSG_ERROR(Please specify the path to the root of your Netscape server using --with-nsapi=DIR)
fi 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 PHP_BUILD_THREAD_SAFE
AC_ADD_INCLUDE($PHP_NSAPI/include)
AC_DEFINE(HAVE_NSAPI,1,[Whether you have a Netscape Server]) AC_DEFINE(HAVE_NSAPI,1,[Whether you have a Netscape Server])
PHP_SAPI=nsapi PHP_SAPI=nsapi
PHP_BUILD_SHARED PHP_BUILD_SHARED
INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED $PHP_NSAPI/bin/" INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED $PHP_NSAPI/bin/"
fi fi
INCLUDES="$INCLUDES -I$NSAPI_INCLUDE"
dnl ## Local Variables: dnl ## Local Variables:
dnl ## tab-width: 4 dnl ## tab-width: 4
dnl ## End: dnl ## End:

View file

@ -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 config files are located in:
/netscape/suitespot/httpd-servername/config <path-to-netscape-server>/https-servername/config
add the following line to mime.types add the following line to mime.types
type=magnus-internal/x-httpd-php exts=php 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! #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" Init fn="load-modules" funcs="php4_init,php4_close,php4_execute,php4_auth_trans" shlib="/php4/nsapiPHP4.dll"

View file

@ -20,16 +20,30 @@
* PHP includes * PHP includes
*/ */
#define NSAPI 1 #define NSAPI 1
#define XP_UNIX
#include "php.h" #include "php.h"
#include "php_variables.h"
#include "ext/standard/info.h" #include "ext/standard/info.h"
#include "php_ini.h" #include "php_ini.h"
#include "php_globals.h" #include "php_globals.h"
#include "SAPI.h" #include "SAPI.h"
#include "main.h" #include "main.h"
#include "php_version.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 * NSAPI includes
@ -44,7 +58,7 @@
/* for unix */ /* for unix */
#ifndef WINAPI #ifndef WINAPI
#define WINAPI #define WINAPI
#endif #endif
/* /*
@ -59,15 +73,10 @@
#define NSG(v) (request_context->v) #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) #if !defined(ZTS)
#define IF_ZTS(a) a #error "NSAPI module needs ZTS to be defined"
#define IF_NOT_ZTS(a)
#else
#define IF_ZTS(a)
#define IF_NOT_ZTS(a) a
static CRITICAL php_mutex;
#endif #endif
/* /*
@ -259,6 +268,31 @@ sapi_nsapi_read_cookies(SLS_D)
return cookie_string; 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 = { static sapi_module_struct sapi_module = {
"NSAPI", /* name */ "NSAPI", /* name */
@ -282,7 +316,7 @@ static sapi_module_struct sapi_module = {
sapi_nsapi_read_post, /* read POST data */ sapi_nsapi_read_post, /* read POST data */
sapi_nsapi_read_cookies, /* read Cookies */ sapi_nsapi_read_cookies, /* read Cookies */
NULL, /* register server variables */ sapi_nsapi_register_server_variables, /* register server variables */
NULL, /* Log message */ NULL, /* Log message */
NULL, /* Block interruptions */ NULL, /* Block interruptions */
@ -391,7 +425,7 @@ nsapi_request_ctor(NSLS_D SLS_DC)
if (uri != NULL) if (uri != NULL)
path_translated = request_translate_uri(uri, NSG(sn)); 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), log_error(LOG_INFORM, "nsapi_request_ctor", NSG(sn), NSG(rq),
"query_string = %s, " "query_string = %s, "
"uri = %s, " "uri = %s, "
@ -445,7 +479,7 @@ nsapi_module_main(NSLS_D SLS_DC)
file_handle.filename = SG(request_info).path_translated; file_handle.filename = SG(request_info).path_translated;
file_handle.free_filename = 0; file_handle.free_filename = 0;
#if 0 #if defined(NSAPI_DEBUG)
log_error(LOG_INFORM, "nsapi_module_main", NSG(sn), NSG(rq), log_error(LOG_INFORM, "nsapi_module_main", NSG(sn), NSG(rq),
"Parsing [%s]", SG(request_info).path_translated); "Parsing [%s]", SG(request_info).path_translated);
#endif #endif
@ -468,32 +502,20 @@ php4_close(void *vparam)
if (sapi_module.shutdown) { if (sapi_module.shutdown) {
sapi_module.shutdown(&sapi_module); sapi_module.shutdown(&sapi_module);
} }
IF_ZTS(
tsrm_shutdown(); tsrm_shutdown();
)
} }
int WINAPI int WINAPI
php4_init(pblock *pb, Session *sn, Request *rq) 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_startup(&sapi_module);
sapi_module.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"); log_error(LOG_INFORM, "php4_init", sn, rq, "Initialized PHP Module\n");
return REQ_PROCEED; return REQ_PROCEED;
} }
@ -511,29 +533,12 @@ php4_execute(pblock *pb, Session *sn, Request *rq)
request_context->sn = sn; request_context->sn = sn;
request_context->rq = rq; 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; SG(server_context) = request_context;
nsapi_request_ctor(NSLS_C SLS_CC); nsapi_request_ctor(NSLS_C SLS_CC);
retval = nsapi_module_main(NSLS_C SLS_CC); retval = nsapi_module_main(NSLS_C SLS_CC);
nsapi_request_dtor(NSLS_C SLS_CC); nsapi_request_dtor(NSLS_C SLS_CC);
IF_NOT_ZTS(
crit_exit(php_mutex);
)
free(request_context); free(request_context);
return (retval == SUCCESS) ? REQ_PROCEED : REQ_EXIT; return (retval == SUCCESS) ? REQ_PROCEED : REQ_EXIT;