cvs: /php4 SAPI.c SAPI.h main.c /php4/sapi/aolserver aolserver.c /php4/sapi/apache mod_php4.c /php4/sapi/cgi cgi_main.c getopt.c php_getopt.h
/php4/sapi/isapi php4isapi.c /php4/sapi/phttpd phttpd.c /php4/sapi/roxen roxen.c /php4/sapi/servlet servlet.c /php4/sapi/thttpd thttpd.c
| From: | Zeev Suraski | Date: | Thu, 10 Feb 2000 16:45:30 +0000 |
| Subject: | cvs: /php4 SAPI.c SAPI.h main.c /php4/sapi/aolserver aolserver.c /php4/sapi/apache mod_php4.c /php4/sapi/cgi cgi_main.c getopt.c php_getopt.h /php4/sapi/isapi php4isapi.c /php4/sapi/phttpd phttpd.c /php4/sapi/roxen roxen.c /php4/sapi/servlet servlet.c /php4/sapi/thttpd thttpd.c |
||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-10036@lists.php.net to get a copy of this message | ||
zeev Thu Feb 10 08:45:30 2000 EDT
Modified files:
/php4 SAPI.c SAPI.h main.c
/php4/sapi/aolserver aolserver.c
/php4/sapi/apache mod_php4.c
/php4/sapi/cgi cgi_main.c getopt.c php_getopt.h
/php4/sapi/isapi php4isapi.c
/php4/sapi/phttpd phttpd.c
/php4/sapi/roxen roxen.c
/php4/sapi/servlet servlet.c
/php4/sapi/thttpd thttpd.c
Log:
More abstraction
Index: php4/SAPI.c
diff -u php4/SAPI.c:1.42 php4/SAPI.c:1.43
--- php4/SAPI.c:1.42 Fri Feb 4 06:54:29 2000
+++ php4/SAPI.c Thu Feb 10 08:44:58 2000
@@ -192,6 +192,9 @@
}
SG(request_info).cookie_data = sapi_module.read_cookies(SLS_C);
}
+ if (sapi_module.activate) {
+ sapi_module.activate(SLS_C);
+ }
}
@@ -200,6 +203,9 @@
zend_llist_destroy(&SG(sapi_headers).headers);
if (SG(request_info).post_data) {
efree(SG(request_info).post_data);
+ }
+ if (sapi_module.deactivate) {
+ sapi_module.deactivate(SLS_C);
}
}
Index: php4/SAPI.h
diff -u php4/SAPI.h:1.28 php4/SAPI.h:1.29
--- php4/SAPI.h:1.28 Thu Feb 10 07:55:09 2000
+++ php4/SAPI.h Thu Feb 10 08:44:58 2000
@@ -135,6 +135,9 @@
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);
Index: php4/main.c
diff -u php4/main.c:1.194 php4/main.c:1.195
--- php4/main.c:1.194 Thu Feb 10 08:27:27 2000
+++ php4/main.c Thu Feb 10 08:44:58 2000
@@ -19,7 +19,7 @@
*/
-/* $Id: main.c,v 1.194 2000/02/10 16:27:27 zeev Exp $ */
+/* $Id: main.c,v 1.195 2000/02/10 16:44:58 zeev Exp $ */
#include <stdio.h>
@@ -623,24 +623,8 @@
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");
@@ -693,14 +677,6 @@
php_destroy_request_info(NULL);
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();
}
Index: php4/sapi/aolserver/aolserver.c
diff -u php4/sapi/aolserver/aolserver.c:1.31 php4/sapi/aolserver/aolserver.c:1.32
--- php4/sapi/aolserver/aolserver.c:1.31 Thu Feb 10 07:55:09 2000
+++ php4/sapi/aolserver/aolserver.c Thu Feb 10 08:44:58 2000
@@ -22,7 +22,7 @@
* - CGI/1.1 conformance
*/
-/* $Id: aolserver.c,v 1.31 2000/02/10 15:55:09 zeev Exp $ */
+/* $Id: aolserver.c,v 1.32 2000/02/10 16:44:58 zeev Exp $ */
/* conflict between PHP and AOLserver headers */
#define Debug php_Debug
@@ -206,7 +206,7 @@
NSLS_FETCH();
PUTS("<table border=5 width=600>\n");
- php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c,v 1.31
2000/02/10 15:55:09 zeev Exp $");
+ php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c,v 1.32
2000/02/10 16:44:58 zeev Exp $");
php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
@@ -296,6 +296,9 @@
php_ns_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
+
+ NULL, /* activate */
+ NULL, /* deactivate */
php_ns_sapi_ub_write, /* unbuffered write */
NULL, /* flush */
Index: php4/sapi/apache/mod_php4.c
diff -u php4/sapi/apache/mod_php4.c:1.22 php4/sapi/apache/mod_php4.c:1.23
--- php4/sapi/apache/mod_php4.c:1.22 Thu Feb 10 07:55:09 2000
+++ php4/sapi/apache/mod_php4.c Thu Feb 10 08:44:58 2000
@@ -17,7 +17,7 @@
| PHP 4.0 patches by Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
-/* $Id: mod_php4.c,v 1.22 2000/02/10 15:55:09 zeev Exp $ */
+/* $Id: mod_php4.c,v 1.23 2000/02/10 16:44:58 zeev Exp $ */
#include "zend.h"
#include "php.h"
@@ -284,11 +284,30 @@
}
+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 */
Index: php4/sapi/cgi/cgi_main.c
diff -u php4/sapi/cgi/cgi_main.c:1.20 php4/sapi/cgi/cgi_main.c:1.21
--- php4/sapi/cgi/cgi_main.c:1.20 Thu Feb 10 08:27:28 2000
+++ php4/sapi/cgi/cgi_main.c Thu Feb 10 08:44:58 2000
@@ -78,8 +78,8 @@
#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,12 +165,25 @@
}
}
+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 */
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 */
Index: php4/sapi/cgi/getopt.c
diff -u php4/sapi/cgi/getopt.c:1.1 php4/sapi/cgi/getopt.c:1.2
--- php4/sapi/cgi/getopt.c:1.1 Thu Feb 10 08:27:28 2000
+++ php4/sapi/cgi/getopt.c Thu Feb 10 08:44:58 2000
@@ -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 @@
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 - */
Index: php4/sapi/cgi/php_getopt.h
diff -u php4/sapi/cgi/php_getopt.h:1.1 php4/sapi/cgi/php_getopt.h:1.2
--- php4/sapi/cgi/php_getopt.h:1.1 Thu Feb 10 08:27:28 2000
+++ php4/sapi/cgi/php_getopt.h Thu Feb 10 08:44:58 2000
@@ -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);
Index: php4/sapi/isapi/php4isapi.c
diff -u php4/sapi/isapi/php4isapi.c:1.17 php4/sapi/isapi/php4isapi.c:1.18
--- php4/sapi/isapi/php4isapi.c:1.17 Thu Feb 10 07:55:09 2000
+++ php4/sapi/isapi/php4isapi.c Thu Feb 10 08:44:59 2000
@@ -345,6 +345,9 @@
php_isapi_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
+ NULL, /* activate */
+ NULL, /* deactivate */
+
sapi_isapi_ub_write, /* unbuffered write */
NULL, /* flush */
Index: php4/sapi/phttpd/phttpd.c
diff -u php4/sapi/phttpd/phttpd.c:1.9 php4/sapi/phttpd/phttpd.c:1.10
--- php4/sapi/phttpd/phttpd.c:1.9 Thu Feb 10 07:55:10 2000
+++ php4/sapi/phttpd/phttpd.c Thu Feb 10 08:44:59 2000
@@ -167,6 +167,9 @@
php_phttpd_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
+ NULL, /* activate */
+ NULL, /* deactivate */
+
php_phttpd_sapi_ub_write, /* unbuffered write */
NULL, /* flush */
Index: php4/sapi/roxen/roxen.c
diff -u php4/sapi/roxen/roxen.c:1.15 php4/sapi/roxen/roxen.c:1.16
--- php4/sapi/roxen/roxen.c:1.15 Thu Feb 10 07:55:10 2000
+++ php4/sapi/roxen/roxen.c Thu Feb 10 08:44:59 2000
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: roxen.c,v 1.15 2000/02/10 15:55:10 zeev Exp $ */
+/* $Id: roxen.c,v 1.16 2000/02/10 16:44:59 zeev Exp $ */
#include "php.h"
#ifdef HAVE_ROXEN
@@ -470,7 +470,7 @@
/* char buf[512]; */
PUTS("<table border=5 width=600>\n");
- php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.15 2000/02/10
15:55:10 zeev Exp $");
+ php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.16 2000/02/10
16:44:59 zeev Exp $");
/* php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
@@ -520,6 +520,9 @@
php_module_startup, /* startup */
pike_module_exit, /* shutdown */
+
+ NULL, /* activate */
+ NULL, /* deactivate */
php_roxen_sapi_ub_write, /* unbuffered write */
NULL, /* flush */
Index: php4/sapi/servlet/servlet.c
diff -u php4/sapi/servlet/servlet.c:1.14 php4/sapi/servlet/servlet.c:1.15
--- php4/sapi/servlet/servlet.c:1.14 Thu Feb 10 08:27:28 2000
+++ php4/sapi/servlet/servlet.c Thu Feb 10 08:44:59 2000
@@ -216,6 +216,9 @@
php_module_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
+ NULL, /* activate */
+ NULL, /* deactivate */
+
sapi_servlet_ub_write, /* unbuffered write */
NULL, /* flush */
Index: php4/sapi/thttpd/thttpd.c
diff -u php4/sapi/thttpd/thttpd.c:1.6 php4/sapi/thttpd/thttpd.c:1.7
--- php4/sapi/thttpd/thttpd.c:1.6 Thu Feb 10 07:55:10 2000
+++ php4/sapi/thttpd/thttpd.c Thu Feb 10 08:44:59 2000
@@ -107,6 +107,9 @@
php_module_startup,
php_module_shutdown_wrapper,
+ NULL, /* activate */
+ NULL, /* deactivate */
+
sapi_thttpd_ub_write,
NULL,