summaryrefslogtreecommitdiff
path: root/sapi
diff options
context:
space:
mode:
authorShane Caraveo <shane@php.net>2001-11-10 22:11:03 +0000
committerShane Caraveo <shane@php.net>2001-11-10 22:11:03 +0000
commit5664afaadc139dd0247ef567e2ceb6ec72473501 (patch)
treec393da17f22942588cae5ceb5e5b7c142440891a /sapi
parentf341f630d3fe6fe669f6a4cbf176f7a5e6f3f4db (diff)
downloadphp-git-5664afaadc139dd0247ef567e2ceb6ec72473501.tar.gz
Make the win32 fastcgi compilable with the php4ts projects.
Diffstat (limited to 'sapi')
-rw-r--r--sapi/fastcgi/fastcgi.c50
-rw-r--r--sapi/fastcgi/fastcgi.dsp99
2 files changed, 137 insertions, 12 deletions
diff --git a/sapi/fastcgi/fastcgi.c b/sapi/fastcgi/fastcgi.c
index 80b5c3c204..2779484999 100644
--- a/sapi/fastcgi/fastcgi.c
+++ b/sapi/fastcgi/fastcgi.c
@@ -17,7 +17,7 @@
*/
/* Debugging */
-/* #define DEBUG_FASTCGI 1 */
+/* #define DEBUG_FASTCGI 1 */
/* Two configurables for the FastCGI runner.
*
@@ -49,7 +49,11 @@
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
-#ifndef PHP_WIN32
+#ifdef PHP_WIN32
+#include <io.h>
+#include <fcntl.h>
+#include "win32/php_registry.h"
+#else
#include <sys/wait.h>
#endif
#include <sys/stat.h>
@@ -226,7 +230,7 @@ static void fastcgi_module_main(TSRMLS_D)
}
-static void init_request_info( TSRMLS_D )
+static int init_request_info( TSRMLS_D )
{
char *content_length = getenv("CONTENT_LENGTH");
char *content_type = getenv( "CONTENT_TYPE" );
@@ -250,7 +254,7 @@ static void init_request_info( TSRMLS_D )
SG(sapi_headers).http_response_code = 200;
SG(request_info).path_translated = pt;
- if (!pt) return;
+ if (!pt) return -1;
/*
* if the file doesn't exist, try to extract PATH_INFO out
* of it by stat'ing back through the '/'
@@ -292,12 +296,13 @@ static void init_request_info( TSRMLS_D )
#endif
php_handle_auth_data(auth TSRMLS_CC);
-
+ return 0;
}
void fastcgi_php_init(void)
{
+ TSRMLS_FETCH();
sapi_startup(&fastcgi_sapi_module);
fastcgi_sapi_module.startup(&fastcgi_sapi_module);
SG(server_context) = (void *) 1;
@@ -305,6 +310,7 @@ void fastcgi_php_init(void)
void fastcgi_php_shutdown(void)
{
+ TSRMLS_FETCH();
if (SG(server_context) != NULL) {
fastcgi_sapi_module.shutdown(&fastcgi_sapi_module);
sapi_shutdown();
@@ -349,6 +355,13 @@ int main(int argc, char *argv[])
int max_requests = 500;
int requests = 0;
int env_size, cgi_env_size;
+#ifdef ZTS
+ zend_compiler_globals *compiler_globals;
+ zend_executor_globals *executor_globals;
+ php_core_globals *core_globals;
+ sapi_globals_struct *sapi_globals;
+ void ***tsrm_ls;
+#endif
#ifdef DEBUG_FASTCGI
fprintf( stderr, "Initialising now, pid %d!\n", getpid() );
@@ -385,11 +398,27 @@ int main(int argc, char *argv[])
#endif
#endif
+#ifdef ZTS
+ tsrm_startup(1, 1, 0, NULL);
+#endif
sapi_startup(&fastcgi_sapi_module);
+#ifdef PHP_WIN32
+ _fmode = _O_BINARY; /*sets default for file streams to binary */
+ setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */
+ setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */
+ setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */
+#endif
if (php_module_startup(&fastcgi_sapi_module)==FAILURE) {
return FAILURE;
}
+#ifdef ZTS
+ compiler_globals = ts_resource(compiler_globals_id);
+ executor_globals = ts_resource(executor_globals_id);
+ core_globals = ts_resource(core_globals_id);
+ sapi_globals = ts_resource(sapi_globals_id);
+ tsrm_ls = ts_resource(0);
+#endif
/* How many times to run PHP scripts before dying */
if( getenv( "PHP_FCGI_MAX_REQUESTS" )) {
@@ -501,7 +530,13 @@ int main(int argc, char *argv[])
cgi_env, (cgi_env_size+1)*sizeof(char *) );
environ = merge_env;
- init_request_info(TSRMLS_C);
+ if (init_request_info(TSRMLS_C)!=0) {
+ /* we received some invalid environment */
+ //char *b = "Can't init the request\n";
+ //sapi_fastcgi_ub_write(b, strlen(b) TSRMLS_C);
+ //FCGX_Finish();
+ //break;
+ }
SG(server_context) = (void *) 1; /* avoid server_context==NULL checks */
CG(extended_info) = 0;
SG(request_info).argv0 = argv0;
@@ -526,6 +561,9 @@ int main(int argc, char *argv[])
}
}
+#ifdef ZTS
+ tsrm_shutdown();
+#endif
#ifdef DEBUG_FASTCGI
fprintf( stderr, "Exiting...\n" );
#endif
diff --git a/sapi/fastcgi/fastcgi.dsp b/sapi/fastcgi/fastcgi.dsp
index 446e5373ef..27269550ac 100644
--- a/sapi/fastcgi/fastcgi.dsp
+++ b/sapi/fastcgi/fastcgi.dsp
@@ -4,7 +4,7 @@
# TARGTYPE "Win32 (x86) Console Application" 0x0103
-CFG=fastcgi - Win32 Debug
+CFG=fastcgi - 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
@@ -13,12 +13,15 @@ CFG=fastcgi - Win32 Debug
!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 "fastcgi.mak" CFG="fastcgi - Win32 Debug"
+!MESSAGE NMAKE /f "fastcgi.mak" CFG="fastcgi - Win32 Debug_TS"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "fastcgi - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "fastcgi - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "fastcgi - Win32 Debug_TS" (based on "Win32 (x86) Console Application")
+!MESSAGE "fastcgi - Win32 Release_TS" (based on "Win32 (x86) Console Application")
+!MESSAGE "fastcgi - Win32 Release_TS_inline" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
@@ -51,7 +54,7 @@ BSC32=bscmake.exe
# 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 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 /subsystem:console /machine:I386
-# ADD LINK32 php4nts.lib libfcgi.lib winmm.lib wsock32.lib netapi32.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 /version:4.0 /subsystem:console /machine:I386 /nodefaultlib:"libc.lib" /out:"..\..\Release/php-fcgi.exe" /libpath:"..\..\Release" /libpath:"fcgi\lib"
+# ADD LINK32 php4nts.lib libfcgi.lib winmm.lib wsock32.lib netapi32.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 /version:4.0 /subsystem:console /machine:I386 /nodefaultlib:"libc.lib" /out:"..\..\Release/phpfcgi.exe" /libpath:"..\..\Release" /libpath:"fcgi\lib"
!ELSEIF "$(CFG)" == "fastcgi - Win32 Debug"
@@ -62,8 +65,8 @@ LINK32=link.exe
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "c:\php-fcgi"
-# PROP Intermediate_Dir "..\..\Debug"
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
@@ -76,7 +79,88 @@ BSC32=bscmake.exe
# 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 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 /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 winmm.lib wsock32.lib netapi32.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 php4nts_debug.lib libfcgi.lib /nologo /version:4.0 /subsystem:console /debug /machine:I386 /nodefaultlib:"libcd" /nodefaultlib:"libcmt" /out:"c:\php-fcgi\php-fcgi.exe" /pdbtype:sept /libpath:"..\..\Debug" /libpath:"fcgi\lib"
+# ADD LINK32 libfcgi.lib winmm.lib wsock32.lib netapi32.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 php4nts_debug.lib /nologo /version:4.0 /subsystem:console /debug /machine:I386 /nodefaultlib:"libcd" /nodefaultlib:"libcmt" /out:"..\Debug\phpfcgi.exe" /pdbtype:sept /libpath:"..\..\Debug" /libpath:"fcgi\lib"
+
+!ELSEIF "$(CFG)" == "fastcgi - Win32 Debug_TS"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "fastcgi___Win32_Debug_TS"
+# PROP BASE Intermediate_Dir "fastcgi___Win32_Debug_TS"
+# PROP BASE Ignore_Export_Lib 0
+# 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 /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\regex\\" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "fcgi\include" /D "DEBUG" /D "_DEBUG" /D "_CONSOLE" /D "MSVC5" /D "PHP_WIN32" /D ZEND_DEBUG=1 /D "ZEND_WIN32" /D "WIN32" /D "_MBCS" /FR /FD /GZ /c
+# SUBTRACT BASE CPP /YX
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\regex\\" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "fcgi\include" /D "DEBUG" /D "_DEBUG" /D "_CONSOLE" /D "MSVC5" /D "PHP_WIN32" /D "ZTS" /D ZEND_DEBUG=1 /D "ZEND_WIN32" /D "WIN32" /D "_MBCS" /FR /FD /GZ /c
+# SUBTRACT CPP /YX
+# 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 libfcgi.lib winmm.lib wsock32.lib netapi32.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 php4nts_debug.lib /nologo /version:4.0 /subsystem:console /debug /machine:I386 /nodefaultlib:"libcd" /nodefaultlib:"libcmt" /out:"c:\php-fcgi\php-fcgi.exe" /pdbtype:sept /libpath:"..\..\Debug" /libpath:"fcgi\lib"
+# ADD LINK32 libfcgi.lib winmm.lib wsock32.lib netapi32.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 php4ts_debug.lib /nologo /version:4.0 /subsystem:console /debug /machine:I386 /nodefaultlib:"libcd" /nodefaultlib:"libcmt" /out:"..\..\Debug_TS\phpfcgi.exe" /pdbtype:sept /libpath:"..\..\Debug_TS" /libpath:"fcgi\lib"
+
+!ELSEIF "$(CFG)" == "fastcgi - Win32 Release_TS"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "fastcgi___Win32_Release_TS"
+# PROP BASE Intermediate_Dir "fastcgi___Win32_Release_TS"
+# PROP BASE Ignore_Export_Lib 0
+# 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 /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\regex\\" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "fcgi\include" /D "NDEBUG" /D "_CONSOLE" /D ZEND_DEBUG=0 /D "MSVC5" /D "WIN32" /D "_MBCS" /D "ZEND_WIN32" /D "PHP_WIN32" /Fr /FD /c
+# SUBTRACT BASE CPP /YX
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\regex\\" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "fcgi\include" /D "NDEBUG" /D "_CONSOLE" /D ZEND_DEBUG=0 /D "MSVC5" /D "WIN32" /D "_MBCS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "ZTS" /Fr /FD /c
+# SUBTRACT CPP /YX
+# 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 php4nts.lib libfcgi.lib winmm.lib wsock32.lib netapi32.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 /version:4.0 /subsystem:console /machine:I386 /nodefaultlib:"libc.lib" /out:"..\..\Release/php-fcgi.exe" /libpath:"..\..\Release" /libpath:"fcgi\lib"
+# ADD LINK32 php4ts.lib libfcgi.lib winmm.lib wsock32.lib netapi32.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 /version:4.0 /subsystem:console /machine:I386 /nodefaultlib:"libc.lib" /out:"..\..\Release_TS/phpfcgi.exe" /libpath:"..\..\Release_TS" /libpath:"fcgi\lib"
+
+!ELSEIF "$(CFG)" == "fastcgi - Win32 Release_TS_inline"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "fastcgi___Win32_Release_TS_inline"
+# PROP BASE Intermediate_Dir "fastcgi___Win32_Release_TS_inline"
+# PROP BASE Ignore_Export_Lib 0
+# 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 /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\regex\\" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "fcgi\include" /D "NDEBUG" /D "_CONSOLE" /D ZEND_DEBUG=0 /D "MSVC5" /D "WIN32" /D "_MBCS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "ZTS" /Fr /FD /c
+# SUBTRACT BASE CPP /YX
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\regex\\" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "fcgi\include" /D "NDEBUG" /D "_CONSOLE" /D "ZEND_WIN32_FORCE_INLINE" /D ZEND_DEBUG=0 /D "MSVC5" /D "WIN32" /D "_MBCS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "ZTS" /Fr /FD /c
+# SUBTRACT CPP /YX
+# 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 php4ts.lib libfcgi.lib winmm.lib wsock32.lib netapi32.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 /version:4.0 /subsystem:console /machine:I386 /nodefaultlib:"libc.lib" /out:"..\..\Release_TS/phpfcgi.exe" /libpath:"..\..\Release_TS" /libpath:"fcgi\lib"
+# ADD LINK32 php4ts.lib libfcgi.lib winmm.lib wsock32.lib netapi32.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 /version:4.0 /subsystem:console /machine:I386 /nodefaultlib:"libc.lib" /out:"..\..\Release_TS_inline/phpfcgi.exe" /libpath:"..\..\Release_TS_inline" /libpath:"fcgi\lib"
!ENDIF
@@ -84,6 +168,9 @@ LINK32=link.exe
# Name "fastcgi - Win32 Release"
# Name "fastcgi - Win32 Debug"
+# Name "fastcgi - Win32 Debug_TS"
+# Name "fastcgi - Win32 Release_TS"
+# Name "fastcgi - Win32 Release_TS_inline"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"