- consistent usage of HTTP_G macro (only)
authorMichael Wallner <mike@php.net>
Tue, 7 Feb 2006 21:31:34 +0000 (21:31 +0000)
committerMichael Wallner <mike@php.net>
Tue, 7 Feb 2006 21:31:34 +0000 (21:31 +0000)
http.c
http_api.c
http_cache_api.c
http_encoding_api.c
http_functions.c
http_request_method_api.c
http_response_object.c
http_send_api.c
php_http.h
php_http_cache_api.h
php_http_std_defs.h

diff --git a/http.c b/http.c
index 831040916bf2eef7a72ff7e082ddf55644d75d18..76d4dff7e7ba86e7e354bd203083ae3ea554b5f3 100644 (file)
--- a/http.c
+++ b/http.c
@@ -290,11 +290,11 @@ PHP_MSHUTDOWN_FUNCTION(http)
 /* {{{ PHP_RINIT_FUNCTION */
 PHP_RINIT_FUNCTION(http)
 {
-       http_globals_init(HTTP_GLOBALS);
+       http_globals_init(HTTP_G);
 
-       if (HTTP_G(request).methods.allowed) {
-               http_check_allowed_methods(HTTP_G(request).methods.allowed, 
-                       strlen(HTTP_G(request).methods.allowed));
+       if (HTTP_G->request.methods.allowed) {
+               http_check_allowed_methods(HTTP_G->request.methods.allowed, 
+                       strlen(HTTP_G->request.methods.allowed));
        }
 
        if (    (SUCCESS != PHP_RINIT_CALL(http_request_method))
@@ -322,7 +322,7 @@ PHP_RSHUTDOWN_FUNCTION(http)
                status = FAILURE;
        }
        
-       http_globals_free(HTTP_GLOBALS);
+       http_globals_free(HTTP_G);
        return status;
 }
 /* }}} */
@@ -391,12 +391,11 @@ PHP_MINFO_FUNCTION(http)
        php_info_print_table_colspan_header(2, "Request Methods");
        {
                int i;
-               getGlobals(G);
                phpstr *custom_request_methods = phpstr_new();
                phpstr *known_request_methods = phpstr_from_string(HTTP_KNOWN_METHODS, lenof(HTTP_KNOWN_METHODS));
-               http_request_method_entry **ptr = G->request.methods.custom.entries;
+               http_request_method_entry **ptr = HTTP_G->request.methods.custom.entries;
 
-               for (i = 0; i < G->request.methods.custom.count; ++i) {
+               for (i = 0; i < HTTP_G->request.methods.custom.count; ++i) {
                        if (ptr[i]) {
                                phpstr_appendf(custom_request_methods, "%s, ", ptr[i]->name);
                        }
@@ -409,7 +408,7 @@ PHP_MINFO_FUNCTION(http)
                php_info_print_table_row(2, "Known", PHPSTR_VAL(known_request_methods));
                php_info_print_table_row(2, "Custom",
                        PHPSTR_LEN(custom_request_methods) ? PHPSTR_VAL(custom_request_methods) : "none registered");
-               php_info_print_table_row(2, "Allowed", strlen(G->request.methods.allowed) ? G->request.methods.allowed : "(ANY)");
+               php_info_print_table_row(2, "Allowed", strlen(HTTP_G->request.methods.allowed) ? HTTP_G->request.methods.allowed : "(ANY)");
                
                phpstr_free(&known_request_methods);
                phpstr_free(&custom_request_methods);
index 3969b82fd156d50ca69037893b199964713adbf7..549d283918b067ef7f35b465e4366e37c1720c26 100644 (file)
@@ -219,7 +219,7 @@ void _http_log_ex(char *file, const char *ident, const char *message TSRMLS_DC)
        }
        
        HTTP_LOG_WRITE(file, ident, message);
-       HTTP_LOG_WRITE(HTTP_G(log).composite, ident, message);
+       HTTP_LOG_WRITE(HTTP_G->log.composite, ident, message);
 }
 /* }}} */
 
@@ -247,20 +247,20 @@ STATUS _http_exit_ex(int status, char *header, char *body, zend_bool send_header
        
        switch (status)
        {
-               case 301:       http_log(HTTP_G(log).redirect, "301-REDIRECT", header);                 break;
-               case 302:       http_log(HTTP_G(log).redirect, "302-REDIRECT", header);                 break;
-               case 303:       http_log(HTTP_G(log).redirect, "303-REDIRECT", header);                 break;
-               case 305:       http_log(HTTP_G(log).redirect, "305-REDIRECT", header);                 break;
-               case 307:       http_log(HTTP_G(log).redirect, "307-REDIRECT", header);                 break;
-               case 304:       http_log(HTTP_G(log).cache, "304-CACHE", header);                               break;
-               case 405:       http_log(HTTP_G(log).allowed_methods, "405-ALLOWED", header);   break;
+               case 301:       http_log(HTTP_G->log.redirect, "301-REDIRECT", header);                 break;
+               case 302:       http_log(HTTP_G->log.redirect, "302-REDIRECT", header);                 break;
+               case 303:       http_log(HTTP_G->log.redirect, "303-REDIRECT", header);                 break;
+               case 305:       http_log(HTTP_G->log.redirect, "305-REDIRECT", header);                 break;
+               case 307:       http_log(HTTP_G->log.redirect, "307-REDIRECT", header);                 break;
+               case 304:       http_log(HTTP_G->log.cache, "304-CACHE", header);                               break;
+               case 405:       http_log(HTTP_G->log.allowed_methods, "405-ALLOWED", header);   break;
                default:        http_log(NULL, header, body);                                                                   break;
        }
        
        STR_FREE(header);
        STR_FREE(body);
        
-       if (HTTP_G(force_exit)) {
+       if (HTTP_G->force_exit) {
                zend_bailout();
        } else {
                php_ob_set_internal_handler(http_ob_blackhole, 4096, "blackhole", 0 TSRMLS_CC);
@@ -317,11 +317,11 @@ PHP_HTTP_API STATUS _http_get_request_body_ex(char **body, size_t *length, zend_
                        *body = estrndup(*body, *length);
                }
                return SUCCESS;
-       } else if (sapi_module.read_post && !HTTP_G(read_post_data)) {
+       } else if (sapi_module.read_post && !HTTP_G->read_post_data) {
                char buf[4096];
                int len;
                
-               HTTP_G(read_post_data) = 1;
+               HTTP_G->read_post_data = 1;
                
                while (0 < (len = sapi_module.read_post(buf, sizeof(buf) TSRMLS_CC))) {
                        *body = erealloc(*body, *length + len + 1);
@@ -357,8 +357,8 @@ PHP_HTTP_API php_stream *_http_get_request_body_stream(TSRMLS_D)
        
        if (SG(request_info).raw_post_data) {
                s = php_stream_open_wrapper("php://input", "rb", 0, NULL);
-       } else if (sapi_module.read_post && !HTTP_G(read_post_data)) {
-               HTTP_G(read_post_data) = 1;
+       } else if (sapi_module.read_post && !HTTP_G->read_post_data) {
+               HTTP_G->read_post_data = 1;
                
                if ((s = php_stream_temp_new())) {
                        char buf[4096];
index c8ab27cdd8bac0fa322d56a80eb2823f1030285d..a03a9616f1dba581c81b7b706681dc268a57c1c1 100644 (file)
@@ -183,17 +183,17 @@ PHP_HTTP_API STATUS _http_start_ob_etaghandler(TSRMLS_D)
                return FAILURE;
        }
        
-       HTTP_G(etag).started = 1;
-       return php_start_ob_buffer_named("ob_etaghandler", HTTP_G(send).buffer_size, 1 TSRMLS_CC);
+       HTTP_G->etag.started = 1;
+       return php_start_ob_buffer_named("ob_etaghandler", HTTP_G->send.buffer_size, 1 TSRMLS_CC);
 }
 
 PHP_HTTP_API zend_bool _http_interrupt_ob_etaghandler(TSRMLS_D)
 {
-       if (HTTP_G(etag).started) {
-               HTTP_G(etag).started = 0;
-               if (HTTP_G(etag).ctx) {
-                       efree(HTTP_G(etag).ctx);
-                       HTTP_G(etag).ctx = NULL;
+       if (HTTP_G->etag.started) {
+               HTTP_G->etag.started = 0;
+               if (HTTP_G->etag.ctx) {
+                       efree(HTTP_G->etag.ctx);
+                       HTTP_G->etag.ctx = NULL;
                }
                return 1;
        }
@@ -209,21 +209,21 @@ void _http_ob_etaghandler(char *output, uint output_len,
        *handled_output = estrndup(output, output_len);
        
        /* are we supposed to run? */
-       if (HTTP_G(etag).started) {
+       if (HTTP_G->etag.started) {
                /* initialize the etag context */
                if (mode & PHP_OUTPUT_HANDLER_START) {
-                       HTTP_G(etag).ctx = http_etag_init();
+                       HTTP_G->etag.ctx = http_etag_init();
                }
                
                /* update */
-               http_etag_update(HTTP_G(etag).ctx, output, output_len);
+               http_etag_update(HTTP_G->etag.ctx, output, output_len);
                
                /* finish */
                if (mode & PHP_OUTPUT_HANDLER_END) {
                        char *sent_header = NULL;
-                       char *etag = http_etag_finish(HTTP_G(etag).ctx);
+                       char *etag = http_etag_finish(HTTP_G->etag.ctx);
                        
-                       HTTP_G(etag).ctx = NULL;
+                       HTTP_G->etag.ctx = NULL;
                        
                        http_send_cache_control(HTTP_DEFAULT_CACHECONTROL, lenof(HTTP_DEFAULT_CACHECONTROL));
                        http_send_etag_ex(etag, strlen(etag), &sent_header);
index dc575cdf0d673196df1d8fa4fa7ae7fef6c0a7f0..f732d43ad2ccbecadbdd4f11324069804735e997 100644 (file)
@@ -40,12 +40,10 @@ PHP_MINIT_FUNCTION(http_encoding)
 
 PHP_RINIT_FUNCTION(http_encoding)
 {
-       getGlobals(G);
-       
-       if (G->send.inflate.start_auto) {
+       if (HTTP_G->send.inflate.start_auto) {
                php_ob_set_internal_handler(_http_ob_inflatehandler, HTTP_INFLATE_BUFFER_SIZE, "http inflate", 0 TSRMLS_CC);
        }
-       if (G->send.deflate.start_auto) {
+       if (HTTP_G->send.deflate.start_auto) {
                php_ob_set_internal_handler(_http_ob_deflatehandler, HTTP_DEFLATE_BUFFER_SIZE, "http deflate", 0 TSRMLS_CC);
        }
        return SUCCESS;
@@ -53,13 +51,11 @@ PHP_RINIT_FUNCTION(http_encoding)
 
 PHP_RSHUTDOWN_FUNCTION(http_encoding)
 {
-       getGlobals(G);
-       
-       if (G->send.deflate.stream) {
-               http_encoding_deflate_stream_free((http_encoding_stream **) &G->send.deflate.stream);
+       if (HTTP_G->send.deflate.stream) {
+               http_encoding_deflate_stream_free((http_encoding_stream **) &HTTP_G->send.deflate.stream);
        }
-       if (G->send.inflate.stream) {
-               http_encoding_inflate_stream_free((http_encoding_stream **) &G->send.inflate.stream);
+       if (HTTP_G->send.inflate.stream) {
+               http_encoding_inflate_stream_free((http_encoding_stream **) &HTTP_G->send.inflate.stream);
        }
        return SUCCESS;
 }
@@ -161,9 +157,9 @@ PHP_HTTP_API int _http_encoding_response_start(size_t content_length TSRMLS_DC)
 {
        if (    php_ob_handler_used("ob_gzhandler" TSRMLS_CC) ||
                        php_ob_handler_used("zlib output compression" TSRMLS_CC)) {
-               HTTP_G(send).deflate.encoding = 0;
+               HTTP_G->send.deflate.encoding = 0;
        } else {
-               if (!HTTP_G(send).deflate.encoding) {
+               if (!HTTP_G->send.deflate.encoding) {
                        /* emit a content-length header */
                        if (content_length) {
                                char cl_header_str[128];
@@ -173,7 +169,7 @@ PHP_HTTP_API int _http_encoding_response_start(size_t content_length TSRMLS_DC)
                        }
                } else {
 #ifndef HTTP_HAVE_ZLIB
-                       HTTP_G(send).deflate.encoding = 0;
+                       HTTP_G->send.deflate.encoding = 0;
                        php_start_ob_buffer_named("ob_gzhandler", 0, 0 TSRMLS_CC);
 #else
                        HashTable *selected;
@@ -185,7 +181,7 @@ PHP_HTTP_API int _http_encoding_response_start(size_t content_length TSRMLS_DC)
                        add_next_index_stringl(&zsupported, "x-gzip", lenof("x-gzip"), 1);
                        add_next_index_stringl(&zsupported, "deflate", lenof("deflate"), 1);
                        
-                       HTTP_G(send).deflate.encoding = 0;
+                       HTTP_G->send.deflate.encoding = 0;
                        
                        if ((selected = http_negotiate_encoding(&zsupported))) {
                                STATUS hs = FAILURE;
@@ -195,11 +191,11 @@ PHP_HTTP_API int _http_encoding_response_start(size_t content_length TSRMLS_DC)
                                if (HASH_KEY_IS_STRING == zend_hash_get_current_key(selected, &encoding, &idx, 0) && encoding) {
                                        if (!strcmp(encoding, "gzip") || !strcmp(encoding, "x-gzip")) {
                                                if (SUCCESS == (hs = http_send_header_string("Content-Encoding: gzip"))) {
-                                                       HTTP_G(send).deflate.encoding = HTTP_ENCODING_GZIP;
+                                                       HTTP_G->send.deflate.encoding = HTTP_ENCODING_GZIP;
                                                }
                                        } else if (!strcmp(encoding, "deflate")) {
                                                if (SUCCESS == (hs = http_send_header_string("Content-Encoding: deflate"))) {
-                                                       HTTP_G(send).deflate.encoding = HTTP_ENCODING_DEFLATE;
+                                                       HTTP_G->send.deflate.encoding = HTTP_ENCODING_DEFLATE;
                                                }
                                        }
                                        if (SUCCESS == hs) {
@@ -212,7 +208,7 @@ PHP_HTTP_API int _http_encoding_response_start(size_t content_length TSRMLS_DC)
                        }
                        
                        zval_dtor(&zsupported);
-                       return HTTP_G(send).deflate.encoding;
+                       return HTTP_G->send.deflate.encoding;
 #endif
                }
        }
@@ -703,20 +699,18 @@ PHP_HTTP_API void _http_encoding_inflate_stream_free(http_encoding_stream **s TS
 /* {{{ void http_ob_deflatehandler(char *, uint, char **, uint *, int) */
 void _http_ob_deflatehandler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC)
 {
-       getGlobals(G);
-       
        *handled_output = NULL;
        *handled_output_len = 0;
        
        if (mode & PHP_OUTPUT_HANDLER_START) {
                int flags;
                
-               if (G->send.deflate.stream) {
+               if (HTTP_G->send.deflate.stream) {
                        zend_error(E_ERROR, "ob_deflatehandler() can only be used once");
                        return;
                }
                
-               G->send.deflate.encoding = !0;
+               HTTP_G->send.deflate.encoding = !0;
                
                switch (http_encoding_response_start(0))
                {
@@ -733,19 +727,19 @@ void _http_ob_deflatehandler(char *output, uint output_len, char **handled_outpu
                        break;
                }
                
-               flags |= (G->send.deflate.start_flags &~ 0xf0);
-               G->send.deflate.stream = http_encoding_deflate_stream_init(NULL, flags);
+               flags |= (HTTP_G->send.deflate.start_flags &~ 0xf0);
+               HTTP_G->send.deflate.stream = http_encoding_deflate_stream_init(NULL, flags);
        }
        
-       if (G->send.deflate.stream) {
-               http_encoding_deflate_stream_update((http_encoding_stream *) G->send.deflate.stream, output, output_len, handled_output, handled_output_len);
+       if (HTTP_G->send.deflate.stream) {
+               http_encoding_deflate_stream_update((http_encoding_stream *) HTTP_G->send.deflate.stream, output, output_len, handled_output, handled_output_len);
                
                if (mode & PHP_OUTPUT_HANDLER_END) {
                        char *remaining = NULL;
                        size_t remaining_len = 0;
                        
-                       http_encoding_deflate_stream_finish((http_encoding_stream *) G->send.deflate.stream, &remaining, &remaining_len);
-                       http_encoding_deflate_stream_free((http_encoding_stream **) &G->send.deflate.stream);
+                       http_encoding_deflate_stream_finish((http_encoding_stream *) HTTP_G->send.deflate.stream, &remaining, &remaining_len);
+                       http_encoding_deflate_stream_free((http_encoding_stream **) &HTTP_G->send.deflate.stream);
                        if (remaining) {
                                *handled_output = erealloc(*handled_output, *handled_output_len + remaining_len + 1);
                                memcpy(*handled_output + *handled_output_len, remaining, remaining_len);
@@ -763,28 +757,26 @@ deflate_passthru_plain:
 /* {{{ void http_ob_inflatehandler(char *, uint, char **, uint *, int) */
 void _http_ob_inflatehandler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC)
 {
-       getGlobals(G);
-       
        *handled_output = NULL;
        *handled_output_len = 0;
        
        if (mode & PHP_OUTPUT_HANDLER_START) {
-               if (G->send.inflate.stream) {
+               if (HTTP_G->send.inflate.stream) {
                        zend_error(E_ERROR, "ob_inflatehandler() can only be used once");
                        return;
                }
-               G->send.inflate.stream = http_encoding_inflate_stream_init(NULL, (HTTP_G(send).inflate.start_flags &~ 0xf0));
+               HTTP_G->send.inflate.stream = http_encoding_inflate_stream_init(NULL, (HTTP_G->send.inflate.start_flags &~ 0xf0));
        }
        
-       if (G->send.inflate.stream) {
-               http_encoding_inflate_stream_update((http_encoding_stream *) G->send.inflate.stream, output, output_len, handled_output, handled_output_len);
+       if (HTTP_G->send.inflate.stream) {
+               http_encoding_inflate_stream_update((http_encoding_stream *) HTTP_G->send.inflate.stream, output, output_len, handled_output, handled_output_len);
                
                if (mode & PHP_OUTPUT_HANDLER_END) {
                        char *remaining = NULL;
                        size_t remaining_len = 0;
                        
-                       http_encoding_inflate_stream_finish((http_encoding_stream *) G->send.inflate.stream, &remaining, &remaining_len);
-                       http_encoding_inflate_stream_free((http_encoding_stream **) &G->send.inflate.stream);
+                       http_encoding_inflate_stream_finish((http_encoding_stream *) HTTP_G->send.inflate.stream, &remaining, &remaining_len);
+                       http_encoding_inflate_stream_free((http_encoding_stream **) &HTTP_G->send.inflate.stream);
                        if (remaining) {
                                *handled_output = erealloc(*handled_output, *handled_output_len + remaining_len + 1);
                                memcpy(*handled_output + *handled_output_len, remaining, remaining_len);
index 665facf7765ad01187cb0655975c0e95435b01fa..907ee92c5033643f0dd6b058bf3757af7bd820b3 100644 (file)
@@ -702,8 +702,8 @@ PHP_FUNCTION(http_throttle)
                return;
        }
 
-       HTTP_G(send).throttle_delay = interval;
-       HTTP_G(send).buffer_size = chunk_size;
+       HTTP_G->send.throttle_delay = interval;
+       HTTP_G->send.buffer_size = chunk_size;
 }
 /* }}} */
 
index 4cc0a6ae14f5fffd1d1cfae7ee30edecc15a9f0d..498dbe2f54b6644cc6fa0b9231c84dd4696fe35e 100644 (file)
@@ -101,7 +101,7 @@ PHP_MINIT_FUNCTION(http_request_method)
 
 PHP_RINIT_FUNCTION(http_request_method)
 {
-       HTTP_G(request).methods.custom.entries = ecalloc(1, sizeof(http_request_method_entry *));
+       HTTP_G->request.methods.custom.entries = ecalloc(1, sizeof(http_request_method_entry *));
        
        return SUCCESS;
 }
@@ -109,15 +109,14 @@ PHP_RINIT_FUNCTION(http_request_method)
 PHP_RSHUTDOWN_FUNCTION(http_request_method)
 {
        int i;
-       getGlobals(G);
-       http_request_method_entry **ptr = G->request.methods.custom.entries;
+       http_request_method_entry **ptr = HTTP_G->request.methods.custom.entries;
        
-       for (i = 0; i < G->request.methods.custom.count; ++i) {
+       for (i = 0; i < HTTP_G->request.methods.custom.count; ++i) {
                if (ptr[i]) {
                        http_request_method_unregister(HTTP_CUSTOM_REQUEST_METHOD_START + i);
                }
        }
-       efree(G->request.methods.custom.entries);
+       efree(HTTP_G->request.methods.custom.entries);
        
        return SUCCESS;
 }
@@ -126,15 +125,14 @@ PHP_RSHUTDOWN_FUNCTION(http_request_method)
 /* {{{ char *http_request_method_name(http_request_method) */
 PHP_HTTP_API const char *_http_request_method_name(http_request_method m TSRMLS_DC)
 {
-       getGlobals(G);
-       http_request_method_entry **ptr = G->request.methods.custom.entries;
+       http_request_method_entry **ptr = HTTP_G->request.methods.custom.entries;
 
        if (HTTP_STD_REQUEST_METHOD(m)) {
                return http_request_methods[m];
        }
 
        if (    (HTTP_CUSTOM_REQUEST_METHOD(m) >= 0) && 
-                       (HTTP_CUSTOM_REQUEST_METHOD(m) < G->request.methods.custom.count) &&
+                       (HTTP_CUSTOM_REQUEST_METHOD(m) < HTTP_G->request.methods.custom.count) &&
                        (ptr[HTTP_CUSTOM_REQUEST_METHOD(m)])) {
                return ptr[HTTP_CUSTOM_REQUEST_METHOD(m)]->name;
        }
@@ -147,8 +145,7 @@ PHP_HTTP_API const char *_http_request_method_name(http_request_method m TSRMLS_
 PHP_HTTP_API int _http_request_method_exists(zend_bool by_name, http_request_method id, const char *name TSRMLS_DC)
 {
        int i;
-       getGlobals(G);
-       http_request_method_entry **ptr = G->request.methods.custom.entries;
+       http_request_method_entry **ptr = HTTP_G->request.methods.custom.entries;
        
        if (by_name) {
                for (i = HTTP_MIN_REQUEST_METHOD; i < HTTP_MAX_REQUEST_METHOD; ++i) {
@@ -156,7 +153,7 @@ PHP_HTTP_API int _http_request_method_exists(zend_bool by_name, http_request_met
                                return i;
                        }
                }
-               for (i = 0; i < G->request.methods.custom.count; ++i) {
+               for (i = 0; i < HTTP_G->request.methods.custom.count; ++i) {
                        if (ptr[i] && !strcasecmp(name, ptr[i]->name)) {
                                return HTTP_CUSTOM_REQUEST_METHOD_START + i;
                        }
@@ -164,7 +161,7 @@ PHP_HTTP_API int _http_request_method_exists(zend_bool by_name, http_request_met
        } else if (HTTP_STD_REQUEST_METHOD(id)) {
                return id;
        } else if (     (HTTP_CUSTOM_REQUEST_METHOD(id) >= 0) && 
-                               (HTTP_CUSTOM_REQUEST_METHOD(id) < G->request.methods.custom.count) && 
+                               (HTTP_CUSTOM_REQUEST_METHOD(id) < HTTP_G->request.methods.custom.count) && 
                                (ptr[HTTP_CUSTOM_REQUEST_METHOD(id)])) {
                return id;
        }
@@ -178,8 +175,7 @@ PHP_HTTP_API int _http_request_method_register(const char *method_name, int meth
 {
        int i, meth_num;
        char *http_method, *method, *mconst;
-       getGlobals(G);
-       http_request_method_entry **ptr = G->request.methods.custom.entries;
+       http_request_method_entry **ptr = HTTP_G->request.methods.custom.entries;
        
        if (!isalpha(*method_name)) {
                http_error_ex(HE_WARNING, HTTP_E_REQUEST_METHOD, "Request method does not start with a character (%s)", method_name);
@@ -215,12 +211,12 @@ PHP_HTTP_API int _http_request_method_register(const char *method_name, int meth
        method[method_name_len] = '\0';
        mconst[method_name_len] = '\0';
        
-       ptr = erealloc(ptr, sizeof(http_request_method_entry *) * (G->request.methods.custom.count + 1));
-       G->request.methods.custom.entries = ptr;
-       ptr[G->request.methods.custom.count] = emalloc(sizeof(http_request_method_entry));
-       ptr[G->request.methods.custom.count]->name = method;
-       ptr[G->request.methods.custom.count]->cnst = mconst;
-       meth_num = HTTP_CUSTOM_REQUEST_METHOD_START + G->request.methods.custom.count++;
+       ptr = erealloc(ptr, sizeof(http_request_method_entry *) * (HTTP_G->request.methods.custom.count + 1));
+       HTTP_G->request.methods.custom.entries = ptr;
+       ptr[HTTP_G->request.methods.custom.count] = emalloc(sizeof(http_request_method_entry));
+       ptr[HTTP_G->request.methods.custom.count]->name = method;
+       ptr[HTTP_G->request.methods.custom.count]->cnst = mconst;
+       meth_num = HTTP_CUSTOM_REQUEST_METHOD_START + HTTP_G->request.methods.custom.count++;
 
        method_name_len = spprintf(&http_method, 0, "HTTP_METH_%s", mconst);
        zend_register_long_constant(http_method, method_name_len + 1, meth_num, CONST_CS, http_module_number TSRMLS_CC);
@@ -241,8 +237,7 @@ PHP_HTTP_API STATUS _http_request_method_unregister(int method TSRMLS_DC)
 {
        char *http_method;
        int method_len;
-       getGlobals(G);
-       http_request_method_entry **ptr = G->request.methods.custom.entries;
+       http_request_method_entry **ptr = HTTP_G->request.methods.custom.entries;
        
        if (HTTP_STD_REQUEST_METHOD(method)) {
                http_error_ex(HE_WARNING, HTTP_E_REQUEST_METHOD, "Standard request methods cannot be unregistered");
@@ -250,7 +245,7 @@ PHP_HTTP_API STATUS _http_request_method_unregister(int method TSRMLS_DC)
        }
 
        if (    (HTTP_CUSTOM_REQUEST_METHOD(method) < 0) ||
-                       (HTTP_CUSTOM_REQUEST_METHOD(method) > G->request.methods.custom.count) ||
+                       (HTTP_CUSTOM_REQUEST_METHOD(method) > HTTP_G->request.methods.custom.count) ||
                        (!ptr[HTTP_CUSTOM_REQUEST_METHOD(method)])) {
                http_error_ex(HE_NOTICE, HTTP_E_REQUEST_METHOD, "Custom request method with id %lu does not exist", method);
                return FAILURE;
@@ -276,7 +271,8 @@ PHP_HTTP_API STATUS _http_request_method_unregister(int method TSRMLS_DC)
        
        efree(ptr[HTTP_CUSTOM_REQUEST_METHOD(method)]->name);
        efree(ptr[HTTP_CUSTOM_REQUEST_METHOD(method)]->cnst);
-       STR_SET(ptr[HTTP_CUSTOM_REQUEST_METHOD(method)], NULL);
+       efree(ptr[HTTP_CUSTOM_REQUEST_METHOD(method)]);
+       ptr[HTTP_CUSTOM_REQUEST_METHOD(method)] = NULL;
        
        return SUCCESS;
 }
index e011e7e16c671f0c2c526dcaf15422bee736e85f..af6241b9e316293522390faf3500400dee3dd09b 100644 (file)
@@ -1085,7 +1085,7 @@ PHP_METHOD(HttpResponse, send)
 
        if (clean_ob) {
                /* interrupt on-the-fly etag generation */
-               HTTP_G(etag).started = 0;
+               HTTP_G->etag.started = 0;
                /* discard previous output buffers */
                php_end_ob_buffers(0 TSRMLS_CC);
        }
@@ -1145,17 +1145,17 @@ PHP_METHOD(HttpResponse, send)
        {
                zval *bsize_p, *bsize = convert_to_type_ex(IS_LONG, GET_STATIC_PROP(bufferSize), &bsize_p);
                zval *delay_p, *delay = convert_to_type_ex(IS_DOUBLE, GET_STATIC_PROP(throttleDelay), &delay_p);
-               HTTP_G(send).buffer_size    = Z_LVAL_P(bsize);
-               HTTP_G(send).throttle_delay = Z_DVAL_P(delay);
+               HTTP_G->send.buffer_size    = Z_LVAL_P(bsize);
+               HTTP_G->send.throttle_delay = Z_DVAL_P(delay);
                if (bsize_p) zval_ptr_dtor(&bsize_p);
                if (delay_p) zval_ptr_dtor(&delay_p);
        }
 
        /* gzip */
-       HTTP_G(send).deflate.encoding = zval_is_true(GET_STATIC_PROP(gzip));
+       HTTP_G->send.deflate.encoding = zval_is_true(GET_STATIC_PROP(gzip));
        
        /* start ob */
-       php_start_ob_buffer(NULL, HTTP_G(send).buffer_size, 0 TSRMLS_CC);
+       php_start_ob_buffer(NULL, HTTP_G->send.buffer_size, 0 TSRMLS_CC);
 
        /* send */
        switch (Z_LVAL_P(GET_STATIC_PROP(mode)))
index 0db19b36a9c509640b7ff644fd46c21208eda75e..1c6fd6bad2287554ba07bab270d9ebabdfe377ee 100644 (file)
@@ -41,16 +41,16 @@ static inline void _http_flush(const char *data, size_t data_len TSRMLS_DC)
 #define HTTP_NANOSEC (1000 * 1000 * 1000)
 #define HTTP_DIFFSEC (0.001)
 
-       if (HTTP_G(send).throttle_delay >= HTTP_DIFFSEC) {
+       if (HTTP_G->send.throttle_delay >= HTTP_DIFFSEC) {
 #if defined(PHP_WIN32)
-               Sleep((DWORD) HTTP_MSEC(HTTP_G(send).throttle_delay));
+               Sleep((DWORD) HTTP_MSEC(HTTP_G->send.throttle_delay));
 #elif defined(HAVE_USLEEP)
-               usleep(HTTP_USEC(HTTP_G(send).throttle_delay));
+               usleep(HTTP_USEC(HTTP_G->send.throttle_delay));
 #elif defined(HAVE_NANOSLEEP)
                struct timespec req, rem;
 
-               req.tv_sec = (time_t) HTTP_G(send).throttle_delay;
-               req.tv_nsec = HTTP_NSEC(HTTP_G(send).throttle_delay) % HTTP_NANOSEC;
+               req.tv_sec = (time_t) HTTP_G->send.throttle_delay;
+               req.tv_nsec = HTTP_NSEC(HTTP_G->send.throttle_delay) % HTTP_NANOSEC;
 
                while (nanosleep(&req, &rem) && (errno == EINTR) && (HTTP_NSEC(rem.tv_sec) + rem.tv_nsec) > HTTP_NSEC(HTTP_DIFFSEC))) {
                        req.tv_sec = rem.tv_sec;
@@ -81,20 +81,20 @@ static inline void _http_send_response_start(void **buffer, size_t content_lengt
 #define http_send_response_data_plain(b, d, dl) _http_send_response_data_plain((b), (d), (dl) TSRMLS_CC)
 static inline void _http_send_response_data_plain(void **buffer, const char *data, size_t data_len TSRMLS_DC)
 {
-       if (HTTP_G(send).deflate.encoding) {
+       if (HTTP_G->send.deflate.encoding) {
 #ifdef HTTP_HAVE_ZLIB
                char *encoded;
                size_t encoded_len;
                http_encoding_stream *s = *((http_encoding_stream **) buffer);
                
                http_encoding_deflate_stream_update(s, data, data_len, &encoded, &encoded_len);
-               phpstr_chunked_output((phpstr **) &s->storage, encoded, encoded_len, HTTP_G(send).buffer_size, _http_flush TSRMLS_CC);
+               phpstr_chunked_output((phpstr **) &s->storage, encoded, encoded_len, HTTP_G->send.buffer_size, _http_flush TSRMLS_CC);
                efree(encoded);
 #else
                http_error(HE_ERROR, HTTP_E_RESPONSE, "Attempt to send GZIP response despite being able to do so; please report this bug");
 #endif
        } else {
-               phpstr_chunked_output((phpstr **) buffer, data, data_len, HTTP_G(send).buffer_size, _http_flush TSRMLS_CC);
+               phpstr_chunked_output((phpstr **) buffer, data, data_len, HTTP_G->send.buffer_size, _http_flush TSRMLS_CC);
        }
 }
 /* }}} */
@@ -152,7 +152,7 @@ static inline void _http_send_response_data_fetch(void **buffer, const void *dat
 #define http_send_response_finish(b) _http_send_response_finish((b) TSRMLS_CC)
 static inline void _http_send_response_finish(void **buffer TSRMLS_DC)
 {
-       if (HTTP_G(send).deflate.encoding) {
+       if (HTTP_G->send.deflate.encoding) {
 #ifdef HTTP_HAVE_ZLIB
                char *encoded = NULL;
                size_t encoded_len = 0;
@@ -231,7 +231,7 @@ PHP_HTTP_API STATUS _http_send_last_modified_ex(time_t t, char **sent_header TSR
        efree(date);
 
        /* remember */
-       HTTP_G(send).last_modified = t;
+       HTTP_G->send.last_modified = t;
 
        return ret;
 }
@@ -244,12 +244,12 @@ PHP_HTTP_API STATUS _http_send_etag_ex(const char *etag, size_t etag_len, char *
        char *etag_header;
 
        if (!etag_len){
-               http_error_ex(HE_WARNING, HTTP_E_HEADER, "Attempt to send empty ETag (previous: %s)\n", HTTP_G(send).unquoted_etag);
+               http_error_ex(HE_WARNING, HTTP_E_HEADER, "Attempt to send empty ETag (previous: %s)\n", HTTP_G->send.unquoted_etag);
                return FAILURE;
        }
 
        /* remember */
-       STR_SET(HTTP_G(send).unquoted_etag, estrndup(etag, etag_len));
+       STR_SET(HTTP_G->send.unquoted_etag, estrndup(etag, etag_len));
 
        etag_len = spprintf(&etag_header, 0, "ETag: \"%s\"", etag);
        status = http_send_header_string_ex(etag_header, etag_len, 1);
@@ -270,8 +270,8 @@ PHP_HTTP_API STATUS _http_send_content_type(const char *content_type, size_t ct_
        HTTP_CHECK_CONTENT_TYPE(content_type, return FAILURE);
 
        /* remember for multiple ranges */
-       STR_FREE(HTTP_G(send).content_type);
-       HTTP_G(send).content_type = estrndup(content_type, ct_len);
+       STR_FREE(HTTP_G->send.content_type);
+       HTTP_G->send.content_type = estrndup(content_type, ct_len);
 
        return http_send_header_ex("Content-Type", lenof("Content-Type"), content_type, ct_len, 1, NULL);
 }
@@ -329,9 +329,9 @@ PHP_HTTP_API STATUS _http_send_ex(const void *data_ptr, size_t data_size, http_s
                case RANGE_OK:
                {
                        /* Range Request - only send ranges if entity hasn't changed */
-                       if (    http_match_etag_ex("HTTP_IF_MATCH", HTTP_G(send).unquoted_etag, 0) &&
-                                       http_match_last_modified_ex("HTTP_IF_UNMODIFIED_SINCE", HTTP_G(send).last_modified, 0) &&
-                                       http_match_last_modified_ex("HTTP_UNLESS_MODIFIED_SINCE", HTTP_G(send).last_modified, 0)) {
+                       if (    http_match_etag_ex("HTTP_IF_MATCH", HTTP_G->send.unquoted_etag, 0) &&
+                                       http_match_last_modified_ex("HTTP_IF_UNMODIFIED_SINCE", HTTP_G->send.last_modified, 0) &&
+                                       http_match_last_modified_ex("HTTP_UNLESS_MODIFIED_SINCE", HTTP_G->send.last_modified, 0)) {
                                
                                if (zend_hash_num_elements(&ranges) == 1) {
                                        /* single range */
@@ -355,7 +355,7 @@ PHP_HTTP_API STATUS _http_send_ex(const void *data_ptr, size_t data_size, http_s
                                        /* multi range */
                                        HashPosition pos;
                                        zval **range, **begin, **end;
-                                       const char *content_type = HTTP_G(send).content_type;
+                                       const char *content_type = HTTP_G->send.content_type;
                                        char boundary_str[32], range_header_str[256];
                                        size_t boundary_len, range_header_len;
                                        
@@ -419,9 +419,9 @@ PHP_HTTP_API STATUS _http_send_ex(const void *data_ptr, size_t data_size, http_s
                        }
                
                        /* send 304 Not Modified if last modified matches */
-                       if (!no_cache && http_match_last_modified("HTTP_IF_MODIFIED_SINCE", HTTP_G(send).last_modified)) {
+                       if (!no_cache && http_match_last_modified("HTTP_IF_MODIFIED_SINCE", HTTP_G->send.last_modified)) {
                                char *sent_header = NULL;
-                               http_send_last_modified_ex(HTTP_G(send).last_modified, &sent_header);
+                               http_send_last_modified_ex(HTTP_G->send.last_modified, &sent_header);
                                return http_exit_ex(304, sent_header, NULL, 0);
                        }
                        
index 4aa2679dd2ccb5a7b76574c7422f0ba43085dd7c..7302098ea1fa4a02308255c30ba11c6ca1ae1eed 100644 (file)
@@ -35,7 +35,7 @@
 #              define HTTP_HAVE_SAPI_RTIME
 #              define HTTP_GET_REQUEST_TIME() sapi_get_request_time(TSRMLS_C)
 #      else
-#              define HTTP_GET_REQUEST_TIME() HTTP_G(request_time)
+#              define HTTP_GET_REQUEST_TIME() HTTP_G->request_time
 #      endif
 #      include "SAPI.h"
 #endif
@@ -139,13 +139,10 @@ ZEND_EXTERN_MODULE_GLOBALS(http);
 
 #ifdef ZTS
 #      include "TSRM.h"
-#      define HTTP_G(v) TSRMG(http_globals_id, zend_http_globals *, v)
-#      define HTTP_GLOBALS ((zend_http_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(http_globals_id)])
+#      define HTTP_G ((zend_http_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(http_globals_id)])
 #else
-#      define HTTP_G(v) (http_globals.v)
-#      define HTTP_GLOBALS (&http_globals)
+#      define HTTP_G (&http_globals)
 #endif
-#define getGlobals(G) zend_http_globals *G = HTTP_GLOBALS
 
 PHP_FUNCTION(http_test);
 PHP_FUNCTION(http_date);
index a1d62eef20d922e2431963317bd1ce793502ebfc..6c2121c9c787f9571aeb454317ba47b560e01b9c 100644 (file)
@@ -51,7 +51,7 @@ static inline char *_http_etag_digest(const unsigned char *digest, int len)
 static inline void *_http_etag_init(TSRMLS_D)
 {
        void *ctx = NULL;
-       char *mode = HTTP_G(etag).mode;
+       char *mode = HTTP_G->etag.mode;
        
 #ifdef HTTP_HAVE_EXT_HASH
        php_hash_ops *eho = NULL;
@@ -77,7 +77,7 @@ static inline void *_http_etag_init(TSRMLS_D)
 static inline char *_http_etag_finish(void *ctx TSRMLS_DC)
 {
        unsigned char digest[128] = {0};
-       char *etag = NULL, *mode = HTTP_G(etag).mode;
+       char *etag = NULL, *mode = HTTP_G->etag.mode;
        
 #ifdef HTTP_HAVE_EXT_HASH
        php_hash_ops *eho = NULL;
@@ -105,7 +105,7 @@ static inline char *_http_etag_finish(void *ctx TSRMLS_DC)
 #define http_etag_update(c, d, l) _http_etag_update((c), (d), (l) TSRMLS_CC)
 static inline void _http_etag_update(void *ctx, const char *data_ptr, size_t data_len TSRMLS_DC)
 {
-       char *mode = HTTP_G(etag).mode;
+       char *mode = HTTP_G->etag.mode;
 #ifdef HTTP_HAVE_EXT_HASH
        php_hash_ops *eho = NULL;
        
index 92defa0e2e6df3f1fd67966b1b000f10c5b11e2d..1b3d3bc1107020447bc11c684620ff055c28e6c3 100644 (file)
@@ -288,9 +288,9 @@ typedef int STATUS;
 #endif
 #ifdef ZEND_ENGINE_2
 #      define HE_THROW         E_THROW TSRMLS_CC
-#      define HE_NOTICE        (HTTP_G(only_exceptions) ? E_THROW : E_NOTICE) TSRMLS_CC
-#      define HE_WARNING       (HTTP_G(only_exceptions) ? E_THROW : E_WARNING) TSRMLS_CC
-#      define HE_ERROR         (HTTP_G(only_exceptions) ? E_THROW : E_ERROR) TSRMLS_CC
+#      define HE_NOTICE        (HTTP_G->only_exceptions ? E_THROW : E_NOTICE) TSRMLS_CC
+#      define HE_WARNING       (HTTP_G->only_exceptions ? E_THROW : E_WARNING) TSRMLS_CC
+#      define HE_ERROR         (HTTP_G->only_exceptions ? E_THROW : E_ERROR) TSRMLS_CC
 #else
 #      define HE_THROW         E_WARNING TSRMLS_CC
 #      define HE_NOTICE        E_NOTICE TSRMLS_CC