}
SG(request_info).cookie_data = sapi_module.read_cookies(SLS_C);
}
+ if (sapi_module.activate) {
+ sapi_module.activate(SLS_C);
+ }
}
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)
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);
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");
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();
}
php_ns_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
+ NULL, /* activate */
+ NULL, /* deactivate */
+
php_ns_sapi_ub_write, /* unbuffered write */
NULL, /* flush */
}
+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 */
#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)
}
}
+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 */
#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;
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 - */
/* 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);
php_isapi_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
+ NULL, /* activate */
+ NULL, /* deactivate */
+
sapi_isapi_ub_write, /* unbuffered write */
NULL, /* flush */
php_phttpd_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
+ NULL, /* activate */
+ NULL, /* deactivate */
+
php_phttpd_sapi_ub_write, /* unbuffered write */
NULL, /* flush */
php_module_startup, /* startup */
pike_module_exit, /* shutdown */
+ NULL, /* activate */
+ NULL, /* deactivate */
+
php_roxen_sapi_ub_write, /* unbuffered write */
NULL, /* flush */
php_module_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
+ NULL, /* activate */
+ NULL, /* deactivate */
+
sapi_servlet_ub_write, /* unbuffered write */
NULL, /* flush */
php_module_startup,
php_module_shutdown_wrapper,
+ NULL, /* activate */
+ NULL, /* deactivate */
+
sapi_thttpd_ub_write,
NULL,