summaryrefslogtreecommitdiff
path: root/main/main.c
diff options
context:
space:
mode:
authorGeorge Schlossnagle <gschlossnagle@php.net>2002-11-18 00:59:23 +0000
committerGeorge Schlossnagle <gschlossnagle@php.net>2002-11-18 00:59:23 +0000
commit99c7ddc3a8f9ecf1a3968f6e59dc9d95106bb0c7 (patch)
tree9f8c0a9c6624eebc713f72d18e09ec311a22aef2 /main/main.c
parenta3e9ae20d9b4d2d96becc2f4a94d3a876fe2b3a2 (diff)
downloadphp-git-99c7ddc3a8f9ecf1a3968f6e59dc9d95106bb0c7.tar.gz
added support functions for the apache_hooks SAPI
Diffstat (limited to 'main/main.c')
-rw-r--r--main/main.c154
1 files changed, 154 insertions, 0 deletions
diff --git a/main/main.c b/main/main.c
index 5cf1ac2ef2..1f9f045a51 100644
--- a/main/main.c
+++ b/main/main.c
@@ -811,8 +811,39 @@ static void sigchld_handler(int apar)
static int php_hash_environment(TSRMLS_D);
+/* {{{ php_start_sapi()
+ */
+static int php_start_sapi()
+{
+ int retval = SUCCESS;
+
+ if(!SG(sapi_started)) {
+ zend_try {
+ PG(during_request_startup) = 1;
+
+ /* initialize global variables */
+ PG(modules_activated) = 0;
+ PG(header_is_being_sent) = 0;
+ PG(connection_status) = PHP_CONNECTION_NORMAL;
+
+ zend_activate(TSRMLS_C);
+ zend_set_timeout(EG(timeout_seconds));
+ zend_activate_modules(TSRMLS_C);
+ PG(modules_activated)=1;
+ } zend_catch {
+ retval = FAILURE;
+ } zend_end_try();
+
+ SG(sapi_started) = 1;
+ }
+ return retval;
+}
+
+/* }}} */
+
/* {{{ php_request_startup
*/
+ #ifndef APACHE_HOOKS
int php_request_startup(TSRMLS_D)
{
int retval = SUCCESS;
@@ -868,6 +899,56 @@ int php_request_startup(TSRMLS_D)
return retval;
}
+# else
+int php_request_startup(TSRMLS_D)
+{
+ int retval = SUCCESS;
+
+#if PHP_SIGCHILD
+ signal(SIGCHLD, sigchld_handler);
+#endif
+
+ if (php_start_sapi() == FAILURE)
+ return FAILURE;
+
+ php_output_activate(TSRMLS_C);
+ sapi_activate(TSRMLS_C);
+ php_hash_environment(TSRMLS_C);
+
+ zend_try {
+ PG(during_request_startup) = 1;
+ php_output_activate(TSRMLS_C);
+ if (PG(expose_php)) {
+ sapi_add_header(SAPI_PHP_VERSION_HEADER, sizeof(SAPI_PHP_VERSION_HEADER)-1, 1);
+ }
+ } zend_catch {
+ retval = FAILURE;
+ } zend_end_try();
+
+ return retval;
+}
+# endif
+/* }}} */
+
+/* {{{ php_request_startup_for_hook
+ */
+int php_request_startup_for_hook(TSRMLS_D)
+{
+ int retval = SUCCESS;
+
+#if PHP_SIGCHLD
+ signal(SIGCHLD, sigchld_handler);
+#endif
+
+ if (php_start_sapi() == FAILURE)
+ return FAILURE;
+
+ php_output_activate(TSRMLS_C);
+ sapi_activate_headers_only(TSRMLS_C);
+ php_hash_environment(TSRMLS_C);
+
+ return retval;
+}
/* }}} */
/* {{{ php_request_shutdown_for_exec
@@ -882,6 +963,44 @@ void php_request_shutdown_for_exec(void *dummy)
}
/* }}} */
+/* {{{ php_request_shutdown_for_hook
+ */
+void php_request_shutdown_for_hook(void *dummy)
+{
+ TSRMLS_FETCH();
+ if (PG(modules_activated)) zend_try {
+ php_call_shutdown_functions();
+ } zend_end_try();
+
+ if (PG(modules_activated)) {
+ zend_deactivate_modules(TSRMLS_C);
+ }
+
+ zend_try {
+ int i;
+
+ for (i = 0; i < NUM_TRACK_VARS; i++) {
+ zval_ptr_dtor(&PG(http_globals)[i]);
+ }
+ } zend_end_try();
+
+ zend_deactivate(TSRMLS_C);
+
+ zend_try {
+ sapi_deactivate(TSRMLS_C);
+ } zend_end_try();
+
+ zend_try {
+ shutdown_memory_manager(CG(unclean_shutdown), 0);
+ } zend_end_try();
+
+ zend_try {
+ zend_unset_timeout(TSRMLS_C);
+ } zend_end_try();
+}
+
+/* }}} */
+
/* {{{ php_request_shutdown
*/
void php_request_shutdown(void *dummy)
@@ -1562,6 +1681,41 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
}
/* }}} */
+/* {{{ php_execute_simple_script
+ */
+PHPAPI int php_execute_simple_script(zend_file_handle *primary_file, zval **ret TSRMLS_DC)
+{
+ char *old_cwd;
+
+ EG(exit_status) = 0;
+#define OLD_CWD_SIZE 4096
+ old_cwd = do_alloca(OLD_CWD_SIZE);
+ old_cwd[0] = '\0';
+
+ zend_try {
+#ifdef PHP_WIN32
+ UpdateIniFromRegistry(primary_file->filename TSRMLS_CC);
+#endif
+
+ PG(during_request_startup) = 0;
+
+ if (primary_file->type == ZEND_HANDLE_FILENAME
+ && primary_file->filename) {
+ VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1);
+ VCWD_CHDIR_FILE(primary_file->filename);
+ }
+ zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, ret, 1, primary_file);
+ } zend_end_try();
+
+ if (old_cwd[0] != '\0') {
+ VCWD_CHDIR(old_cwd);
+ }
+
+ free_alloca(old_cwd);
+ return EG(exit_status);
+}
+/* }}} */
+
/* {{{ php_handle_aborted_connection
*/
PHPAPI void php_handle_aborted_connection(void)