]> granicus.if.org Git - php/commitdiff
- ws + cs
authorJani Taskinen <jani@php.net>
Tue, 8 Dec 2009 16:13:46 +0000 (16:13 +0000)
committerJani Taskinen <jani@php.net>
Tue, 8 Dec 2009 16:13:46 +0000 (16:13 +0000)
sapi/apache/libpre.c
sapi/apache/mod_php.c
sapi/apache/php_apache.c
sapi/apache/sapi_apache.c

index ade4098ac02cdbb2132ebaf862a11b95ccc10fc2..0af4c21be199cd23527ea30db30d81b57236014a 100644 (file)
@@ -33,7 +33,7 @@
 
 
 #ifdef __GNUC__
-#include <string.h>        /* memset */
+#include <string.h> /* memset */
 extern char _edata, _end ; /* end of DATA (start of BSS), end of BSS */
 #endif
 
@@ -41,15 +41,15 @@ int _lib_start()
 {
 /*     printf("Inside _lib_start\n");*/
 #ifdef __GNUC__
-    memset (&_edata, 0, &_end - &_edata);
+       memset (&_edata, 0, &_end - &_edata);
 #endif
-    return 0;
+       return 0;
 }
 
 int _lib_stop()
 {
 /*     printf("Inside _lib_stop\n");*/
-    return 0;
+       return 0;
 }
 
 #endif /* NETWARE */
index 0a3bedcdf274cf12c24a3d16149e48d0aecfeb78..d9c32cfa0481f983756c0f5a9ae48573e234e2c1 100644 (file)
@@ -76,7 +76,7 @@ typedef struct _php_per_dir_entry {
        uint key_length;
        uint value_length;
        int type;
-    char htaccess;
+       char htaccess;
 } php_per_dir_entry;
 
 /* some systems are missing these from their header files */
@@ -95,7 +95,7 @@ static void php_save_umask(void)
 static int sapi_apache_ub_write(const char *str, uint str_length TSRMLS_DC)
 {
        int ret=0;
-               
+
        if (SG(server_context)) {
                ret = rwrite(str, str_length, (request_rec *) SG(server_context));
        }
@@ -137,7 +137,7 @@ static int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC)
        if (!SG(read_post_bytes) && !ap_should_client_block(r)) {
                return total_read_bytes;
        }
+
        handler = signal(SIGPIPE, SIG_IGN);
        while (total_read_bytes<count_bytes) {
                hard_timeout("Read POST information", r); /* start timeout timer */
@@ -148,7 +148,7 @@ static int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC)
                }
                total_read_bytes += read_bytes;
        }
-       signal(SIGPIPE, handler);       
+       signal(SIGPIPE, handler);
        return total_read_bytes;
 }
 /* }}} */
@@ -334,10 +334,10 @@ static void php_apache_request_shutdown(void *dummy)
                AP(in_request) = 0;
                php_request_shutdown(dummy);
        }
-       SG(server_context) = NULL; 
-       /* 
-       * The server context (request) is NOT invalid by the time 
-       * run_cleanups() is called 
+       SG(server_context) = NULL;
+       /*
+       * The server context (request) is NOT invalid by the time
+       * run_cleanups() is called
        */
 }
 /* }}} */
@@ -346,7 +346,7 @@ static void php_apache_request_shutdown(void *dummy)
  */
 static int php_apache_sapi_activate(TSRMLS_D)
 {
-       request_rec *r = (request_rec *) SG(server_context); 
+       request_rec *r = (request_rec *) SG(server_context);
 
        /*
         * For the Apache module version, this bit of code registers a cleanup
@@ -354,7 +354,7 @@ static int php_apache_sapi_activate(TSRMLS_D)
         * 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.  
+        * memory.
         */
        block_alarms();
        register_cleanup(r->pool, NULL, php_apache_request_shutdown, php_request_shutdown_for_exec);
@@ -398,7 +398,7 @@ static int sapi_apache_get_fd(int *nfd TSRMLS_DC)
        int fd;
 
        fd = r->connection->client->fd;
-       
+
        if (fd >= 0) {
                if (nfd) *nfd = fd;
                return SUCCESS;
@@ -413,9 +413,9 @@ static int sapi_apache_get_fd(int *nfd TSRMLS_DC)
 static int sapi_apache_force_http_10(TSRMLS_D)
 {
        request_rec *r = SG(server_context);
-       
+
        r->proto_num = HTTP_VERSION(1,0);
-       
+
        return SUCCESS;
 }
 /* }}} */
@@ -461,7 +461,7 @@ static void sapi_apache_child_terminate(TSRMLS_D)
 static sapi_module_struct apache_sapi_module = {
        "apache",                                               /* name */
        "Apache",                                               /* pretty name */
-                                                                       
+
        php_apache_startup,                             /* startup */
        php_module_shutdown_wrapper,    /* shutdown */
 
@@ -576,11 +576,11 @@ static int php_apache_alter_ini_entries(php_per_dir_entry *per_dir_entry TSRMLS_
  */
 static char *php_apache_get_default_mimetype(request_rec *r TSRMLS_DC)
 {
-       
        char *mimetype;
+       char *tmpmimetype;
+
        /* Assume output will be of the default MIME type.  Individual
           scripts may change this later. */
-       char *tmpmimetype;
        tmpmimetype = sapi_get_default_content_type(TSRMLS_C);
        mimetype = pstrdup(r->pool, tmpmimetype);
        efree(tmpmimetype);
@@ -621,7 +621,7 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
                if (per_dir_conf) {
                        zend_hash_apply((HashTable *) per_dir_conf, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC);
                }
-               
+
                /* If PHP parser engine has been turned off with an "engine off"
                 * directive, then decline to handle this request
                 */
@@ -689,9 +689,8 @@ static int send_parsed_php(request_rec * r)
 {
        int result = send_php(r, 0, NULL);
        TSRMLS_FETCH();
-       ap_table_setn(r->notes, "mod_php_memory_usage",
-               ap_psprintf(r->pool, "%lu", zend_memory_peak_usage(1 TSRMLS_CC)));
+
+       ap_table_setn(r->notes, "mod_php_memory_usage", ap_psprintf(r->pool, "%lu", zend_memory_peak_usage(1 TSRMLS_CC)));
 
        return result;
 }
@@ -853,7 +852,7 @@ static CONST_PREFIX char *php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *
                bool_val[0] = '0';
        }
        bool_val[1] = 0;
-       
+
        return php_apache_value_handler_ex(cmd, conf, arg1, bool_val, mode);
 }
 /* }}} */
@@ -919,7 +918,7 @@ static void apache_php_module_shutdown_wrapper(void)
 
 #if MODULE_MAGIC_NUMBER >= 19970728
        /* This function is only called on server exit if the apache API
-        * child_exit handler exists, so shutdown globally 
+        * child_exit handler exists, so shutdown globally
         */
        sapi_shutdown();
 #endif
@@ -988,7 +987,7 @@ command_rec php_commands[] =
        {"php_flag",            php_apache_flag_handler, NULL, OR_OPTIONS, TAKE2, "PHP Flag Modifier"},
        {"php_admin_value",     php_apache_admin_value_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Value Modifier (Admin)"},
        {"php_admin_flag",      php_apache_admin_flag_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Flag Modifier (Admin)"},
-       {"PHPINIDir",       php_apache_phpini_set, NULL, RSRC_CONF, TAKE1, "Directory containing the php.ini file"},
+       {"PHPINIDir",           php_apache_phpini_set, NULL, RSRC_CONF, TAKE1, "Directory containing the php.ini file"},
        {NULL}
 };
 /* }}} */
@@ -1008,7 +1007,7 @@ module MODULE_VAR_EXPORT php6_module =
        php_create_dir,                         /* per-directory config creator */
        php_merge_dir,                          /* dir merger */
        NULL,                                           /* per-server config creator */
-       NULL,                                           /* merge server config */
+       NULL,                                           /* merge server config */
        php_commands,                           /* command table */
        php_handlers,                           /* handlers */
        NULL,                                           /* filename translation */
@@ -1022,7 +1021,7 @@ module MODULE_VAR_EXPORT php6_module =
        , NULL                                          /* header parser */
 #endif
 #if MODULE_MAGIC_NUMBER >= 19970719
-       , NULL                                  /* child_init */
+       , NULL                                          /* child_init */
 #endif
 #if MODULE_MAGIC_NUMBER >= 19970728
        , php_child_exit_handler                /* child_exit */
index c5fccaf0d1efd2150911ac0b166ee369b20ccc5d..d08e7c346ebf9c31659fb255bdd1985c88c44fe8 100644 (file)
@@ -93,8 +93,6 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_INFO(arginfo_apache_reset_timeout, 0)
 ZEND_END_ARG_INFO()
 
-
-
 const zend_function_entry apache_functions[] = {
        PHP_FE(virtual,                                                                 arginfo_apache_virtual)
        PHP_FE(apache_request_headers,                                  arginfo_apache_request_headers)
@@ -110,7 +108,6 @@ const zend_function_entry apache_functions[] = {
        {NULL, NULL, NULL}
 };
 
-
 PHP_INI_BEGIN()
        STD_PHP_INI_ENTRY("xbithack",                   "0",                            PHP_INI_ALL,            OnUpdateLong,           xbithack, php_apache_info_struct, php_apache_info)
        STD_PHP_INI_ENTRY("engine",                             "1",                            PHP_INI_ALL,            OnUpdateLong,           engine, php_apache_info_struct, php_apache_info)
@@ -118,14 +115,11 @@ PHP_INI_BEGIN()
        STD_PHP_INI_ENTRY("child_terminate",    "0",                            PHP_INI_ALL,            OnUpdateLong,           terminate_child, php_apache_info_struct, php_apache_info)
 PHP_INI_END()
 
-
-
 static void php_apache_globals_ctor(php_apache_info_struct *apache_globals TSRMLS_DC)
 {
        apache_globals->in_request = 0;
 }
 
-
 static PHP_MINIT_FUNCTION(apache)
 {
 #ifdef ZTS
@@ -137,7 +131,6 @@ static PHP_MINIT_FUNCTION(apache)
        return SUCCESS;
 }
 
-
 static PHP_MSHUTDOWN_FUNCTION(apache)
 {
        UNREGISTER_INI_ENTRIES();
@@ -146,62 +139,17 @@ static PHP_MSHUTDOWN_FUNCTION(apache)
 
 zend_module_entry apache_module_entry = {
        STANDARD_MODULE_HEADER,
-       "apache", 
-       apache_functions, 
-       PHP_MINIT(apache), 
-       PHP_MSHUTDOWN(apache), 
-       NULL, 
-       NULL, 
-       PHP_MINFO(apache), 
+       "apache",
+       apache_functions,
+       PHP_MINIT(apache),
+       PHP_MSHUTDOWN(apache),
+       NULL,
+       NULL,
+       PHP_MINFO(apache),
        NO_VERSION_YET,
        STANDARD_MODULE_PROPERTIES
 };
 
-/* {{{ proto bool apache_child_terminate(void)
-   Terminate apache process after this request */
-PHP_FUNCTION(apache_child_terminate)
-{
-#ifndef MULTITHREAD
-       if (AP(terminate_child)) {
-               ap_child_terminate( ((request_rec *)SG(server_context)) );
-               RETURN_TRUE;
-       } else { /* tell them to get lost! */
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "This function is disabled");
-               RETURN_FALSE;
-       }
-#else
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "This function is not supported in this build");
-               RETURN_FALSE;
-#endif
-}
-/* }}} */
-
-/* {{{ proto string apache_note(string note_name [, string note_value])
-   Get and set Apache request notes */
-PHP_FUNCTION(apache_note)
-{
-       char *note_name, *note_val = NULL;
-       int note_name_len, note_val_len;
-       char *old_val;
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &note_name, &note_name_len, &note_val, &note_val_len) == FAILURE) {
-               return;
-       }
-
-       old_val = (char *) table_get(((request_rec *)SG(server_context))->notes, note_name);
-
-       if (note_val) {
-               table_set(((request_rec *)SG(server_context))->notes, note_name, note_val);
-       }
-
-       if (old_val) {
-               RETURN_STRING(old_val, 1);
-       }
-
-       RETURN_FALSE;
-}
-/* }}} */
-
 /* {{{ PHP_MINFO_FUNCTION
  */
 PHP_MINFO_FUNCTION(apache)
@@ -223,7 +171,6 @@ PHP_MINFO_FUNCTION(apache)
 
        serv = ((request_rec *) SG(server_context))->server;
 
-
        php_info_print_table_start();
 
 #ifdef PHP_WIN32
@@ -241,7 +188,7 @@ PHP_MINFO_FUNCTION(apache)
 
        if (apv && *apv) {
                php_info_print_table_row(2, "Apache Version", apv);
-       } 
+       }
 
 #ifdef APACHE_RELEASE
        snprintf(output_buf, sizeof(output_buf), "%d", APACHE_RELEASE);
@@ -267,7 +214,7 @@ PHP_MINFO_FUNCTION(apache)
        php_info_print_table_row(2, "Server Root", server_root);
 
        strcpy(modulenames, "");
-       for(modp = top_module; modp; modp = modp->next) {
+       for (modp = top_module; modp; modp = modp->next) {
                strlcpy(name, modp->name, sizeof(name));
                if ((p = strrchr(name, '.'))) {
                        *p='\0'; /* Cut off ugly .c extensions on module names */
@@ -293,14 +240,14 @@ PHP_MINFO_FUNCTION(apache)
                r = ((request_rec *) SG(server_context));
                arr = table_elts(r->subprocess_env);
                elts = (table_entry *)arr->elts;
-               
+
                SECTION("Apache Environment");
-               php_info_print_table_start();   
+               php_info_print_table_start();
                php_info_print_table_header(2, "Variable", "Value");
                for (i=0; i < arr->nelts; i++) {
                        php_info_print_table_row(2, elts[i].key, elts[i].val);
                }
-               php_info_print_table_end();     
+               php_info_print_table_end();
        }
 
        {
@@ -308,7 +255,7 @@ PHP_MINFO_FUNCTION(apache)
                table_entry *env;
                int i;
                request_rec *r;
-               
+
                r = ((request_rec *) SG(server_context));
                SECTION("HTTP Headers Information");
                php_info_print_table_start();
@@ -324,7 +271,7 @@ PHP_MINFO_FUNCTION(apache)
                php_info_print_table_colspan_header(2, "HTTP Response Headers");
                env_arr = table_elts(r->headers_out);
                env = (table_entry *)env_arr->elts;
-               for(i = 0; i < env_arr->nelts; ++i) {
+               for (i = 0; i < env_arr->nelts; ++i) {
                        if (env[i].key) {
                                php_info_print_table_row(2, env[i].key, env[i].val);
                        }
@@ -334,6 +281,51 @@ PHP_MINFO_FUNCTION(apache)
 }
 /* }}} */
 
+/* {{{ proto bool apache_child_terminate(void)
+   Terminate apache process after this request */
+PHP_FUNCTION(apache_child_terminate)
+{
+#ifndef MULTITHREAD
+       if (AP(terminate_child)) {
+               ap_child_terminate( ((request_rec *)SG(server_context)) );
+               RETURN_TRUE;
+       } else { /* tell them to get lost! */
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "This function is disabled");
+               RETURN_FALSE;
+       }
+#else
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "This function is not supported in this build");
+               RETURN_FALSE;
+#endif
+}
+/* }}} */
+
+/* {{{ proto string apache_note(string note_name [, string note_value])
+   Get and set Apache request notes */
+PHP_FUNCTION(apache_note)
+{
+       char *note_name, *note_val = NULL;
+       int note_name_len, note_val_len;
+       char *old_val;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &note_name, &note_name_len, &note_val, &note_val_len) == FAILURE) {
+               return;
+       }
+
+       old_val = (char *) table_get(((request_rec *)SG(server_context))->notes, note_name);
+
+       if (note_val) {
+               table_set(((request_rec *)SG(server_context))->notes, note_name, note_val);
+       }
+
+       if (old_val) {
+               RETURN_STRING(old_val, 1);
+       }
+
+       RETURN_FALSE;
+}
+/* }}} */
+
 /* {{{ proto bool virtual(string filename)
    Perform an Apache sub-request */
 /* This function is equivalent to <!--#include virtual...-->
@@ -353,18 +345,20 @@ PHP_FUNCTION(virtual)
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
                return;
        }
-       
+
        if (!(rr = sub_req_lookup_uri (filename, ((request_rec *) SG(server_context))))) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - URI lookup failed", filename);
-               if (rr)
+               if (rr) {
                        destroy_sub_req (rr);
+               }
                RETURN_FALSE;
        }
 
        if (rr->status != 200) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - error finding URI", filename);
-               if (rr)
+               if (rr) {
                        destroy_sub_req (rr);
+               }
                RETURN_FALSE;
        }
 
@@ -373,14 +367,15 @@ PHP_FUNCTION(virtual)
 
        if (run_sub_req(rr)) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - request execution failed", filename);
-               if (rr)
+               if (rr) {
                        destroy_sub_req (rr);
+               }
                RETURN_FALSE;
        }
 
-       if (rr)
+       if (rr) {
                destroy_sub_req (rr);
-
+       }
        RETURN_TRUE;
 }
 /* }}} */
@@ -393,19 +388,19 @@ PHP_FUNCTION(virtual)
    Fetch all HTTP request headers */
 PHP_FUNCTION(apache_request_headers)
 {
-    array_header *env_arr;
-    table_entry *tenv;
-    int i;
-       
-    array_init(return_value);
-    env_arr = table_elts(((request_rec *) SG(server_context))->headers_in);
-    tenv = (table_entry *)env_arr->elts;
-    for (i = 0; i < env_arr->nelts; ++i) {
+       array_header *env_arr;
+       table_entry *tenv;
+       int i;
+
+       array_init(return_value);
+       env_arr = table_elts(((request_rec *) SG(server_context))->headers_in);
+       tenv = (table_entry *)env_arr->elts;
+       for (i = 0; i < env_arr->nelts; ++i) {
                if (!tenv[i].key) {
                        continue;
                }
                add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val, 1);
-    }
+       }
 }
 /* }}} */
 
@@ -440,8 +435,10 @@ PHP_FUNCTION(apache_setenv)
                return;
        }
 
-       while(top) {
-               if(r->prev) r = r->prev;
+       while (top) {
+               if (r->prev) {
+                       r = r->prev;
+               }
                else break;
        }
 
@@ -474,16 +471,16 @@ PHP_FUNCTION(apache_lookup_uri)
                add_property_string(return_value,"the_request", rr->the_request, 1);
        }
        if (rr->status_line) {
-               add_property_string(return_value,"status_line", (char *)rr->status_line, 1);            
+               add_property_string(return_value,"status_line", (char *)rr->status_line, 1);
        }
        if (rr->method) {
-               add_property_string(return_value,"method", (char *)rr->method, 1);              
+               add_property_string(return_value,"method", (char *)rr->method, 1);
        }
        if (rr->content_type) {
                add_property_string(return_value,"content_type", (char *)rr->content_type, 1);
        }
        if (rr->handler) {
-               add_property_string(return_value,"handler", (char *)rr->handler, 1);            
+               add_property_string(return_value,"handler", (char *)rr->handler, 1);
        }
        if (rr->uri) {
                add_property_string(return_value,"uri", rr->uri, 1);
@@ -513,11 +510,11 @@ PHP_FUNCTION(apache_lookup_uri)
        if (rr->unparsed_uri) {
                add_property_string(return_value,"unparsed_uri", rr->unparsed_uri, 1);
        }
-       if(rr->mtime) {
+       if (rr->mtime) {
                add_property_long(return_value,"mtime", rr->mtime);
        }
 #endif
-       if(rr->request_time) {
+       if (rr->request_time) {
                add_property_long(return_value,"request_time", rr->request_time);
        }
 
@@ -540,7 +537,7 @@ PHP_FUNCTION(apache_exec_uri)
                return;
        }
 
-       if(!(rr = ap_sub_req_lookup_uri(filename, ((request_rec *) SG(server_context))))) {
+       if (!(rr = ap_sub_req_lookup_uri(filename, ((request_rec *) SG(server_context))))) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "URI lookup failed", filename);
                RETURN_FALSE;
        }
@@ -570,16 +567,16 @@ PHP_FUNCTION(apache_get_modules)
 {
        int n;
        char *p;
-       
+
        array_init(return_value);
-       
+
        for (n = 0; ap_loaded_modules[n]; ++n) {
                char *s = (char *) ap_loaded_modules[n]->name;
                if ((p = strchr(s, '.'))) {
                        add_next_index_stringl(return_value, s, (p - s), 1);
                } else {
                        add_next_index_string(return_value, s, 1);
-               }       
+               }
        }
 }
 /* }}} */
index efac888b162fbd42a83dd237e619d9551b97e920..031d2039cdabe3387274e9caa5b4458a1af63ada 100644 (file)
@@ -27,7 +27,7 @@
  */
 int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC)
 {
-       int retval = OK;        
+       int retval = OK;
        zend_file_handle file_handle;
 
        if (php_request_startup(TSRMLS_C) == FAILURE) {
@@ -35,7 +35,7 @@ int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC)
        }
        /* sending a file handle to another dll is not working
           so let zend open it. */
-       
+
        if (display_source_mode) {
                zend_syntax_highlighter_ini syntax_highlighter_ini;
 
@@ -54,11 +54,11 @@ int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC)
        }
 
        AP(in_request) = 0;
-       
+
        zend_try {
                php_request_shutdown(NULL);
        } zend_end_try();
-       
+
        return retval;
 }
 /* }}} */