]> granicus.if.org Git - php/commitdiff
More abstraction
authorZeev Suraski <zeev@php.net>
Thu, 10 Feb 2000 16:44:59 +0000 (16:44 +0000)
committerZeev Suraski <zeev@php.net>
Thu, 10 Feb 2000 16:44:59 +0000 (16:44 +0000)
13 files changed:
main/SAPI.c
main/SAPI.h
main/main.c
sapi/aolserver/aolserver.c
sapi/apache/mod_php4.c
sapi/cgi/cgi_main.c
sapi/cgi/getopt.c
sapi/cgi/php_getopt.h
sapi/isapi/php4isapi.c
sapi/phttpd/phttpd.c
sapi/roxen/roxen.c
sapi/servlet/servlet.c
sapi/thttpd/thttpd.c

index 2da12e5b836c2375facd74df32c7ea573bcfecc4..54de23facfa11ca4dbadbc23885478346e844e5c 100644 (file)
@@ -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)
index 60fc8efc6d45b548dd0db667f3f42735e4bd5bef..625d5d9919dc14d44d3e7f645d9f5b5e338d3073 100644 (file)
@@ -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);
 
index 3df5d5e5dc01c235a76f58eef520bffa69323b89..329533de33b60fe9025191fdee0135cc072a798b 100644 (file)
@@ -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();
 }
 
index eeb3b1c80772cdcc2e16ccd1e17655454615eaa7..7ba56d4e685ae82999b8c2f3bad4b587daa37135 100644 (file)
@@ -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 */
 
index c7ac6cd8c30eb549701e8412ef0aa2b02860b7e1..5d05e01f5208bddaef3254f3045cb05d116816a9 100644 (file)
@@ -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 */
 
index eb51a9ef95625dce0ddc9ad715cfd54a6b40d02d..1d2b5ce653e0ea5015df878aa7ea4ab2ad3f2b68 100644 (file)
@@ -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 */
 
index e34356a6b0065948613ffd3d8e5c71791369f7c0..4d9187ba8e8c330167e659bf0b9a41ac1a58a991 100644 (file)
@@ -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 - */
index 5f3af64b6432e2781acb328f37e88b93c931776e..3b1356d6cdd103f3892e5117f48e84d816121f56 100644 (file)
@@ -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 83e8c04ad2bb41484c258aac781a98ed7456220c..9ef51cbb1f38a6708e9bb898876abf6b05162b01 100644 (file)
@@ -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 */
 
index a766816899330d551857c9fe7146727c56f77edc..7c98cd70a3e7f48d413cf0e0c306c1b12c158b2f 100644 (file)
@@ -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 */
  
index 7c797667e6fe674979aa8a935d562ff571e4f685..cff4324f9d85d85f0b9ca48c9631060b5b454a33 100644 (file)
@@ -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 */
 
index 3cc4e6e3dcdf1c33070b9837c1cc6c0af9011835..645528b86c71896e1f4a4de191ee07f901483768 100644 (file)
@@ -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 */
 
index 363347512904c77ad97aa5cc8ee40f6d7db72358..2a39f189a4b4830f30615457c7a68ad9467f0da5 100644 (file)
@@ -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,