summaryrefslogtreecommitdiff
path: root/cgi_main.c
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>1999-04-26 14:00:49 +0000
committerZeev Suraski <zeev@php.net>1999-04-26 14:00:49 +0000
commit7942eaf38138ef8751a447dadb930a129528fb6b (patch)
treecee4b5eca81082809a9e5bb903173952f45e9501 /cgi_main.c
parent050cb7cfe3da61621b6d01a0b013642543f44521 (diff)
downloadphp-git-7942eaf38138ef8751a447dadb930a129528fb6b.tar.gz
* Plenty of thread safety and Win32 work.
* Changed PHP4 to compile as a DLL, both ISAPI and the the CGI run with the same DLL. * Switched to using the DLL runtime library under Win32. PHP will NOT work if compiled against the static library! * Removed yesterday's php4libts project (with php4dllts, it's obsolete). This *does* affect thread-unsafe Windows as well - the thread unsafe CGI is also dependant on the thread-unsafe DLL.
Diffstat (limited to 'cgi_main.c')
-rw-r--r--cgi_main.c66
1 files changed, 49 insertions, 17 deletions
diff --git a/cgi_main.c b/cgi_main.c
index 4d4ab20a47..d53905390c 100644
--- a/cgi_main.c
+++ b/cgi_main.c
@@ -45,6 +45,7 @@
#include "zend_highlight.h"
#include "zend_indent.h"
+
#if USE_SAPI
#include "serverapi/sapi.h"
void *gLock;
@@ -57,12 +58,14 @@ struct sapi_request_info *sapi_rqst;
#include "getopt.h"
#endif
-extern char *php3_ini_path;
+PHPAPI extern char *php3_ini_path;
#define PHP_MODE_STANDARD 1
#define PHP_MODE_HIGHLIGHT 2
#define PHP_MODE_INDENT 3
+PHPAPI extern char *optarg;
+PHPAPI extern int optind;
static int zend_cgibin_ub_write(const char *str, uint str_length)
@@ -71,11 +74,40 @@ static int zend_cgibin_ub_write(const char *str, uint str_length)
}
-sapi_functions_struct sapi_functions = {
+static sapi_functions_struct sapi_functions = {
zend_cgibin_ub_write
};
+static void php_cgi_usage(char *argv0)
+{
+ char *prog;
+
+ prog = strrchr(argv0, '/');
+ if (prog) {
+ prog++;
+ } else {
+ prog = "php";
+ }
+
+ php3_printf("Usage: %s [-q] [-h]"
+ " [-s]"
+ " [-v] [-i] [-f <file>] | "
+ "{<file> [args...]}\n"
+ " -q Quiet-mode. Suppress HTTP Header output.\n"
+ " -s Display colour syntax highlighted source.\n"
+ " -f<file> Parse <file>. Implies `-q'\n"
+ " -v Version number\n"
+ " -c<path> Look for php3.ini file in this directory\n"
+#if SUPPORT_INTERACTIVE
+ " -a Run interactively\n"
+#endif
+ " -e Generate extended information for debugger/profiler\n"
+ " -i PHP information\n"
+ " -h This help\n", prog);
+}
+
+
int main(int argc, char *argv[])
{
int cgi = 0, c, i, len;
@@ -144,7 +176,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
#endif /* FORCE_CGI_REDIRECT */
}
- if (php3_module_startup()==FAILURE) {
+ if (php_module_startup(&sapi_functions)==FAILURE) {
return FAILURE;
}
#ifdef ZTS
@@ -161,8 +193,8 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
switch (c) {
case 'f':
if (!_cgi_started){
- if (php3_request_startup(CLS_C ELS_CC PLS_CC)==FAILURE) {
- php3_module_shutdown();
+ if (php_request_startup(CLS_C ELS_CC PLS_CC)==FAILURE) {
+ php_module_shutdown();
return FAILURE;
}
}
@@ -174,8 +206,8 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
break;
case 'v':
if (!_cgi_started) {
- if (php3_request_startup(CLS_C ELS_CC PLS_CC)==FAILURE) {
- php3_module_shutdown();
+ if (php_request_startup(CLS_C ELS_CC PLS_CC)==FAILURE) {
+ php_module_shutdown();
return FAILURE;
}
}
@@ -184,8 +216,8 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
break;
case 'i':
if (!_cgi_started) {
- if (php3_request_startup(CLS_C ELS_CC PLS_CC)==FAILURE) {
- php3_module_shutdown();
+ if (php_request_startup(CLS_C ELS_CC PLS_CC)==FAILURE) {
+ php_module_shutdown();
return FAILURE;
}
}
@@ -218,7 +250,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
case '?':
php3_noheader();
zend_output_startup();
- _php3_usage(argv[0]);
+ php_cgi_usage(argv[0]);
exit(1);
break;
default:
@@ -232,8 +264,8 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
#endif
if (!_cgi_started) {
- if (php3_request_startup(CLS_C ELS_CC PLS_CC)==FAILURE) {
- php3_module_shutdown();
+ if (php_request_startup(CLS_C ELS_CC PLS_CC)==FAILURE) {
+ php_module_shutdown();
return FAILURE;
}
}
@@ -286,8 +318,8 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
}
}
#endif
- php3_request_shutdown((void *) 0);
- php3_module_shutdown();
+ php_request_shutdown((void *) 0);
+ php_module_shutdown();
return FAILURE;
} else if (file_handle.handle.fp && file_handle.handle.fp!=stdin) {
/* #!php support */
@@ -304,7 +336,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
switch (behavior) {
case PHP_MODE_STANDARD:
- php3_parse(&file_handle CLS_CC ELS_CC PLS_CC);
+ php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC);
break;
case PHP_MODE_HIGHLIGHT: {
zend_syntax_highlighter_ini syntax_highlighter_ini;
@@ -326,7 +358,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
}
php3_header(); /* Make sure headers have been sent */
- php3_request_shutdown((void *) 0);
- php3_module_shutdown();
+ php_request_shutdown((void *) 0);
+ php_module_shutdown();
return SUCCESS;
}