From fdb62f9ce71978668417ba14c13422313f71a171 Mon Sep 17 00:00:00 2001 From: Shane Caraveo Date: Sat, 6 May 2000 23:05:29 +0000 Subject: [PATCH] nsapi now compiles under win32, untested --- sapi/nsapi/nsapi-readme.txt | 52 ++++++++++++++ sapi/nsapi/nsapi.c | 57 ++++++++++++--- sapi/nsapi/nsapiphp4.dsp | 135 ++++++++++++++++++++++++++++++++++++ 3 files changed, 236 insertions(+), 8 deletions(-) create mode 100644 sapi/nsapi/nsapi-readme.txt create mode 100644 sapi/nsapi/nsapiphp4.dsp diff --git a/sapi/nsapi/nsapi-readme.txt b/sapi/nsapi/nsapi-readme.txt new file mode 100644 index 0000000000..79b97636f5 --- /dev/null +++ b/sapi/nsapi/nsapi-readme.txt @@ -0,0 +1,52 @@ +nsapi configuration file information + +netscape config files are located in: +/netscape/suitespot/httpd-servername/config + +add the following line to mime.types + +type=magnus-internal/x-httpd-php exts=php + + +Add the following to obj.conf + +#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=php4_init errorString="Failed to initialize PHP!" + + +. +. +. +.#NOTE this next line should happen after all 'ObjectType' and before all 'AddLog' lines +Service fn="php4_execute" type="magnus-internal/x-httpd-php" +. +. + + + + +ObjectType fn="force-type" type="magnus-internal/x-httpd-php" +Service fn=php4_execute + + + +Authentication configuration + +PHP authentication cannot be used with any other authentication. ALL AUTHENTICATION IS +PASSED TO YOUR PHP SCRIPT. To configure PHP Authentication for the entire server, add +the following line: + + +AuthTrans fn=php4_auth_trans +. +. +. +. + + +To use PHP Authentication on a single directory, add the following: + + +AuthTrans fn=php4_auth_trans + diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c index 3ceb29c0ae..1791049125 100644 --- a/sapi/nsapi/nsapi.c +++ b/sapi/nsapi/nsapi.c @@ -19,6 +19,8 @@ /* * PHP includes */ +#define NSAPI 1 + #include "php.h" #include "ext/standard/info.h" @@ -40,6 +42,11 @@ #include "base/util.h" /* is_mozilla, getline */ #include "frame/log.h" /* log_error */ +/* for unix */ +#ifndef WINAPI +#define WINAPI +#endif + /* * Timeout for net_read(). This should probably go into php.ini */ @@ -128,7 +135,7 @@ sapi_nsapi_ub_write(const char *str, unsigned int str_length) SLS_FETCH(); rc = (nsapi_request_context *)SG(server_context); - retval = net_write(rc->sn->csd, str, str_length); + retval = net_write(rc->sn->csd, (char *)str, str_length); if (retval == IO_ERROR /*-1*/ || retval == IO_EOF /*0*/) return -1; else @@ -252,7 +259,7 @@ sapi_nsapi_read_cookies(SLS_D) return cookie_string; } -static sapi_module_struct nsapi_sapi_module = { +static sapi_module_struct sapi_module = { "NSAPI", /* name */ php_module_startup, /* startup */ @@ -315,7 +322,7 @@ nsapi_add_string(const char *name, const char *buf) pval->type = IS_STRING; pval->value.str.len = strlen(buf); pval->value.str.val = estrndup(buf, pval->value.str.len); - zend_hash_update(&EG(symbol_table), name, strlen(name) + 1, &pval, sizeof(zval *), NULL); + zend_hash_update(&EG(symbol_table), (char *)name, strlen(name) + 1, &pval, sizeof(zval *), NULL); } static void @@ -420,7 +427,7 @@ nsapi_request_dtor(NSLS_D SLS_DC) nsapi_free(SG(request_info).content_type); } -static int +int nsapi_module_main(NSLS_D SLS_DC) { int result; @@ -455,7 +462,18 @@ nsapi_module_main(NSLS_D SLS_DC) return SUCCESS; } -int +void WINAPI +php4_close(void *vparam) +{ + if (sapi_module.shutdown) { + sapi_module.shutdown(&sapi_module); + } + IF_ZTS( + tsrm_shutdown(); + ) +} + +int WINAPI php4_init(pblock *pb, Session *sn, Request *rq) { PLS_FETCH(); @@ -467,8 +485,8 @@ php4_init(pblock *pb, Session *sn, Request *rq) tsrm_startup(1, 1, 0); ) - sapi_startup(&nsapi_sapi_module); - sapi_module.startup(&nsapi_sapi_module); + sapi_startup(&sapi_module); + sapi_module.startup(&sapi_module); PG(expose_php) = 0; @@ -480,7 +498,7 @@ php4_init(pblock *pb, Session *sn, Request *rq) return REQ_PROCEED; } -int +int WINAPI php4_execute(pblock *pb, Session *sn, Request *rq) { int retval; @@ -520,3 +538,26 @@ php4_execute(pblock *pb, Session *sn, Request *rq) return (retval == SUCCESS) ? REQ_PROCEED : REQ_EXIT; } + +/********************************************************* +/ authentication +/ +/ we have to make a 'fake' authenticator for netscape so it +/ will pass authentication through to php, and allow us to +/ check authentication with our scripts. +/ +/ php4_auth_trans +/ main function called from netscape server to authenticate +/ a line in obj.conf: +/ funcs=php4_auth_trans shlib="path/to/this/phpnsapi.dll" +/ and: +/ +/ AuthTrans fn="php4_auth_trans" +/*********************************************************/ +int WINAPI +php4_auth_trans(pblock * pb, Session * sn, Request * rq) +{ + /*This is a DO NOTHING function that allows authentication information + to be passed through to PHP scripts.*/ + return REQ_PROCEED; +} diff --git a/sapi/nsapi/nsapiphp4.dsp b/sapi/nsapi/nsapiphp4.dsp new file mode 100644 index 0000000000..eb459e93bf --- /dev/null +++ b/sapi/nsapi/nsapiphp4.dsp @@ -0,0 +1,135 @@ +# Microsoft Developer Studio Project File - Name="NSAPIPHP4" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=NSAPIPHP4 - Win32 Debug_TS +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "NSAPIPHP4.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "NSAPIPHP4.mak" CFG="NSAPIPHP4 - Win32 Debug_TS" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "NSAPIPHP4 - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "NSAPIPHP4 - Win32 Release_TS_inline" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "NSAPIPHP4 - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "NSAPIPHP4 - Win32 Release_TS" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "NSAPIPHP4___Win32_Release_TS" +# PROP BASE Intermediate_Dir "NSAPIPHP4___Win32_Release_TS" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_TS" +# PROP Intermediate_Dir "Release_TS" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NSAPIPHP4_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "." /I "..\..\..\php_build\nsapi30\include\\" /I "..\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /D "XP_WIN32" /D ZEND_DEBUG=0 /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NSAPIPHP4_EXPORTS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 ns-httpd30.lib ZendTS.lib TSRM.lib php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x62000000" /dll /machine:I386 /libpath:"..\..\..\php_build\nsapi30\lib\\" /libpath:"..\..\Release_TS" /libpath:"..\..\TSRM\Release_TS" /libpath:"..\..\Zend\Release_TS" + +!ELSEIF "$(CFG)" == "NSAPIPHP4 - Win32 Release_TS_inline" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "NSAPIPHP4___Win32_Release_TS_inline" +# PROP BASE Intermediate_Dir "NSAPIPHP4___Win32_Release_TS_inline" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_TS_inline" +# PROP Intermediate_Dir "Release_TS_inline" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NSAPIPHP4_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "." /I "..\..\..\php_build\nsapi30\include\\" /I "..\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /D "XP_WIN32" /D ZEND_DEBUG=0 /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "ZEND_WIN32_FORCE_INLINE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NSAPIPHP4_EXPORTS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 ns-httpd30.lib ZendTS.lib TSRM.lib php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x62000000" /dll /machine:I386 /libpath:"..\..\..\php_build\nsapi30\lib\\" /libpath:"..\..\Release_TS_inline" /libpath:"..\..\TSRM\Release_TS_inline" /libpath:"..\..\Zend\Release_TS_inline" + +!ELSEIF "$(CFG)" == "NSAPIPHP4 - Win32 Debug_TS" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "NSAPIPHP4___Win32_Debug_TS" +# PROP BASE Intermediate_Dir "NSAPIPHP4___Win32_Debug_TS" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug_TS" +# PROP Intermediate_Dir "Debug_TS" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NSAPIPHP4_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I "..\..\..\php_build\nsapi30\include\\" /I "..\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /D "XP_WIN32" /D "_Debug_TS" /D ZEND_DEBUG=1 /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NSAPIPHP4_EXPORTS" /FR /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 ns-httpd30.lib php4ts_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x62000000" /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\php_build\nsapi30\lib\\" /libpath:"..\..\Debug_TS" /libpath:"..\..\TSRM\Debug_TS" /libpath:"..\..\Zend\Debug_TS" + +!ENDIF + +# Begin Target + +# Name "NSAPIPHP4 - Win32 Release_TS" +# Name "NSAPIPHP4 - Win32 Release_TS_inline" +# Name "NSAPIPHP4 - Win32 Debug_TS" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\nsapi.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project -- 2.40.0