summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>2000-02-10 16:44:59 +0000
committerZeev Suraski <zeev@php.net>2000-02-10 16:44:59 +0000
commit073b148167887c51f30fff8f7c569fcf28c5bb72 (patch)
tree0e7362611b67eb01a95c7ef65322aef0a1b05411
parent59b53ea2c8f1dbb4797ffac2a31caad392927b48 (diff)
downloadphp-git-073b148167887c51f30fff8f7c569fcf28c5bb72.tar.gz
More abstraction
-rw-r--r--main/SAPI.c6
-rw-r--r--main/SAPI.h3
-rw-r--r--main/main.c26
-rw-r--r--sapi/aolserver/aolserver.c3
-rw-r--r--sapi/apache/mod_php4.c19
-rw-r--r--sapi/cgi/cgi_main.c17
-rw-r--r--sapi/cgi/getopt.c6
-rw-r--r--sapi/cgi/php_getopt.h6
-rw-r--r--sapi/isapi/php4isapi.c3
-rw-r--r--sapi/phttpd/phttpd.c3
-rw-r--r--sapi/roxen/roxen.c3
-rw-r--r--sapi/servlet/servlet.c3
-rw-r--r--sapi/thttpd/thttpd.c3
13 files changed, 68 insertions, 33 deletions
diff --git a/main/SAPI.c b/main/SAPI.c
index 2da12e5b83..54de23facf 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -192,6 +192,9 @@ SAPI_API void sapi_activate(SLS_D)
}
SG(request_info).cookie_data = sapi_module.read_cookies(SLS_C);
}
+ if (sapi_module.activate) {
+ sapi_module.activate(SLS_C);
+ }
}
@@ -201,6 +204,9 @@ SAPI_API void sapi_deactivate(SLS_D)
if (SG(request_info).post_data) {
efree(SG(request_info).post_data);
}
+ if (sapi_module.deactivate) {
+ sapi_module.deactivate(SLS_C);
+ }
}
static int sapi_extract_response_code(const char *header_line)
diff --git a/main/SAPI.h b/main/SAPI.h
index 60fc8efc6d..625d5d9919 100644
--- a/main/SAPI.h
+++ b/main/SAPI.h
@@ -135,6 +135,9 @@ struct _sapi_module_struct {
int (*startup)(struct _sapi_module_struct *sapi_module);
int (*shutdown)(struct _sapi_module_struct *sapi_module);
+ int (*activate)(SLS_D);
+ int (*deactivate)(SLS_D);
+
int (*ub_write)(const char *str, unsigned int str_length);
void (*flush)(void *server_context);
diff --git a/main/main.c b/main/main.c
index 3df5d5e5dc..329533de33 100644
--- a/main/main.c
+++ b/main/main.c
@@ -623,24 +623,8 @@ int php_request_startup(CLS_D ELS_DC PLS_DC SLS_DC)
php_output_startup();
-#if APACHE
- /*
- * For the Apache module version, this bit of code registers a cleanup
- * function that gets triggered when our request pool is destroyed.
- * We need this because at any point in our code we can be interrupted
- * and that may happen before we have had time to free our memory.
- * The php_request_shutdown function needs to free all outstanding allocated
- * memory.
- */
- block_alarms();
- register_cleanup(((request_rec *) SG(server_context))->pool, NULL, php_request_shutdown, php_request_shutdown_for_exec);
- unblock_alarms();
-#endif
-
/* initialize global variables */
- {
- PG(header_is_being_sent)=0;
- }
+ PG(header_is_being_sent)=0;
if (php_init_request_info(NULL)) {
php_printf("Unable to initialize request info.\n");
@@ -694,14 +678,6 @@ void php_request_shutdown(void *dummy)
shutdown_memory_manager(CG(unclean_shutdown), 0);
php_unset_timeout();
-#if CGI_BINARY
- fflush(stdout);
- if(request_info.php_argv0) {
- free(request_info.php_argv0);
- request_info.php_argv0 = NULL;
- }
-#endif
-
global_unlock();
}
diff --git a/sapi/aolserver/aolserver.c b/sapi/aolserver/aolserver.c
index eeb3b1c807..7ba56d4e68 100644
--- a/sapi/aolserver/aolserver.c
+++ b/sapi/aolserver/aolserver.c
@@ -297,6 +297,9 @@ static sapi_module_struct sapi_module = {
php_ns_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
+ NULL, /* activate */
+ NULL, /* deactivate */
+
php_ns_sapi_ub_write, /* unbuffered write */
NULL, /* flush */
diff --git a/sapi/apache/mod_php4.c b/sapi/apache/mod_php4.c
index c7ac6cd8c3..5d05e01f52 100644
--- a/sapi/apache/mod_php4.c
+++ b/sapi/apache/mod_php4.c
@@ -284,12 +284,31 @@ static void php_apache_log_message(char *message)
}
+static int php_apache_sapi_activate(SLS_D)
+{
+ /*
+ * For the Apache module version, this bit of code registers a cleanup
+ * function that gets triggered when our request pool is destroyed.
+ * We need this because at any point in our code we can be interrupted
+ * and that may happen before we have had time to free our memory.
+ * The php_request_shutdown function needs to free all outstanding allocated
+ * memory.
+ */
+ block_alarms();
+ register_cleanup(((request_rec *) (server_context))->pool, NULL, php_request_shutdown, php_request_shutdown_for_exec);
+ unblock_alarms();
+}
+
+
static sapi_module_struct sapi_module = {
"Apache", /* name */
php_apache_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
+ php_apache_sapi_activate, /* activate */
+ NULL, /* deactivate */
+
sapi_apache_ub_write, /* unbuffered write */
sapi_apache_flush, /* flush */
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index eb51a9ef95..1d2b5ce653 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -78,8 +78,8 @@ PHPAPI extern char *php_ini_path;
#define PHP_MODE_HIGHLIGHT 2
#define PHP_MODE_INDENT 3
-PHPAPI extern char *ap_php_optarg;
-PHPAPI extern int ap_php_optind;
+extern char *ap_php_optarg;
+extern int ap_php_optind;
static int sapi_cgibin_ub_write(const char *str, uint str_length)
@@ -165,6 +165,16 @@ static void sapi_cgi_log_message(char *message)
}
}
+static int sapi_cgi_activate(SLS_D)
+{
+ fflush(stdout);
+ if(request_info.php_argv0) {
+ free(request_info.php_argv0);
+ request_info.php_argv0 = NULL;
+ }
+ return SUCCESS;
+}
+
static sapi_module_struct sapi_module = {
"CGI", /* name */
@@ -172,6 +182,9 @@ static sapi_module_struct sapi_module = {
php_module_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
+ NULL, /* activate */
+ sapi_cgi_activate, /* deactivate */
+
sapi_cgibin_ub_write, /* unbuffered write */
sapi_cgibin_flush, /* flush */
diff --git a/sapi/cgi/getopt.c b/sapi/cgi/getopt.c
index e34356a6b0..4d9187ba8e 100644
--- a/sapi/cgi/getopt.c
+++ b/sapi/cgi/getopt.c
@@ -10,8 +10,8 @@
#define OPTERRARG (3)
-PHPAPI char *ap_php_optarg;
-PHPAPI int ap_php_optind = 1;
+char *ap_php_optarg;
+int ap_php_optind = 1;
static int ap_php_opterr = 1;
static int ap_php_optopt;
@@ -42,7 +42,7 @@ ap_php_optiserr(int argc, char * const *argv, int oint, const char *optstr,
return('?');
}
-PHPAPI int ap_php_getopt(int argc, char* const *argv, const char *optstr)
+int ap_php_getopt(int argc, char* const *argv, const char *optstr)
{
static int optchr = 0;
static int dash = 0; /* have already seen the - */
diff --git a/sapi/cgi/php_getopt.h b/sapi/cgi/php_getopt.h
index 5f3af64b64..3b1356d6cd 100644
--- a/sapi/cgi/php_getopt.h
+++ b/sapi/cgi/php_getopt.h
@@ -1,9 +1,9 @@
/* Borrowed from Apache NT Port */
#include "php.h"
-PHPAPI extern char *ap_php_optarg;
-PHPAPI extern int ap_php_optind;
+extern char *ap_php_optarg;
+extern int ap_php_optind;
extern int ap_php_opterr;
extern int ap_php_optopt;
-PHPAPI int ap_php_getopt(int argc, char* const *argv, const char *optstr);
+int ap_php_getopt(int argc, char* const *argv, const char *optstr);
diff --git a/sapi/isapi/php4isapi.c b/sapi/isapi/php4isapi.c
index 83e8c04ad2..9ef51cbb1f 100644
--- a/sapi/isapi/php4isapi.c
+++ b/sapi/isapi/php4isapi.c
@@ -345,6 +345,9 @@ static sapi_module_struct sapi_module = {
php_isapi_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
+ NULL, /* activate */
+ NULL, /* deactivate */
+
sapi_isapi_ub_write, /* unbuffered write */
NULL, /* flush */
diff --git a/sapi/phttpd/phttpd.c b/sapi/phttpd/phttpd.c
index a766816899..7c98cd70a3 100644
--- a/sapi/phttpd/phttpd.c
+++ b/sapi/phttpd/phttpd.c
@@ -167,6 +167,9 @@ static sapi_module_struct sapi_module = {
php_phttpd_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
+ NULL, /* activate */
+ NULL, /* deactivate */
+
php_phttpd_sapi_ub_write, /* unbuffered write */
NULL, /* flush */
diff --git a/sapi/roxen/roxen.c b/sapi/roxen/roxen.c
index 7c797667e6..cff4324f9d 100644
--- a/sapi/roxen/roxen.c
+++ b/sapi/roxen/roxen.c
@@ -521,6 +521,9 @@ static sapi_module_struct sapi_module = {
php_module_startup, /* startup */
pike_module_exit, /* shutdown */
+ NULL, /* activate */
+ NULL, /* deactivate */
+
php_roxen_sapi_ub_write, /* unbuffered write */
NULL, /* flush */
diff --git a/sapi/servlet/servlet.c b/sapi/servlet/servlet.c
index 3cc4e6e3dc..645528b86c 100644
--- a/sapi/servlet/servlet.c
+++ b/sapi/servlet/servlet.c
@@ -216,6 +216,9 @@ static sapi_module_struct sapi_module = {
php_module_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
+ NULL, /* activate */
+ NULL, /* deactivate */
+
sapi_servlet_ub_write, /* unbuffered write */
NULL, /* flush */
diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c
index 3633475129..2a39f189a4 100644
--- a/sapi/thttpd/thttpd.c
+++ b/sapi/thttpd/thttpd.c
@@ -107,6 +107,9 @@ static sapi_module_struct sapi_module = {
php_module_startup,
php_module_shutdown_wrapper,
+ NULL, /* activate */
+ NULL, /* deactivate */
+
sapi_thttpd_ub_write,
NULL,