# you better don't look inside
[m6w6/ext-http] / http_encoding_api.c
index c16bc1a8722ecb1c0f7c3783c91c75a0406c79e6..7b726c879b75938e45a18a74d0737bec5fa6c516 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
-
-#include "php_http_encoding_api.h"
 #include "php_http.h"
-#include "php_http_api.h"
 
-#ifdef HTTP_HAVE_ZLIB
-#      include "php_http_send_api.h"
-#      include "php_http_headers_api.h"
-#      include <zlib.h>
-#endif
+#include "php_http_api.h"
+#include "php_http_encoding_api.h"
+#include "php_http_send_api.h"
+#include "php_http_headers_api.h"
 
 ZEND_EXTERN_MODULE_GLOBALS(http);
 
@@ -72,7 +67,7 @@ PHP_HTTP_API const char *_http_encoding_dechunk(const char *encoded, size_t enco
                                return encoded + encoded_len;
                        } else {
                                efree(*decoded);
-                               http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Expected chunk size at pos %lu of %lu but got trash", (ulong) (n_ptr - encoded), (ulong) encoded_len);
+                               http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Expected chunk size at pos %tu of %zu but got trash", n_ptr - encoded, encoded_len);
                                return NULL;
                        }
                }
@@ -85,16 +80,16 @@ PHP_HTTP_API const char *_http_encoding_dechunk(const char *encoded, size_t enco
                /* there should be CRLF after the chunk size, but we'll ignore SP+ too */
                if (*n_ptr && !eol_match(&n_ptr, &eol_len)) {
                        if (eol_len == 2) {
-                               http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Expected CRLF at pos %lu of %lu but got 0x%02X 0x%02X", (ulong) (n_ptr - encoded), (ulong) encoded_len, *n_ptr, *(n_ptr + 1));
+                               http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Expected CRLF at pos %tu of %zu but got 0x%02X 0x%02X", n_ptr - encoded, encoded_len, *n_ptr, *(n_ptr + 1));
                        } else {
-                               http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Expected LF at pos %lu of %lu but got 0x%02X", (ulong) (n_ptr - encoded), (ulong) encoded_len, *n_ptr);
+                               http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Expected LF at pos %tu of %zu but got 0x%02X", n_ptr - encoded, encoded_len, *n_ptr);
                        }
                }
                n_ptr += eol_len;
                
                /* chunk size pretends more data than we actually got, so it's probably a truncated message */
                if (chunk_len > (rest = encoded + encoded_len - n_ptr)) {
-                       http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Truncated message: chunk size %lu exceeds remaining data size %lu at pos %lu of %lu", chunk_len, rest, (ulong) (n_ptr - encoded), (ulong) encoded_len);
+                       http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Truncated message: chunk size %lu exceeds remaining data size %lu at pos %tu of %zu", chunk_len, rest, n_ptr - encoded, encoded_len);
                        chunk_len = rest;
                }
 
@@ -520,7 +515,7 @@ PHP_HTTP_API STATUS _http_encoding_stream_init(http_encoding_stream *s, int gzip
                HTTP_ENCODING_STREAM_ERROR(status, NULL);
        }
        
-       if (s->gzip = gzip) {
+       if ((s->gzip = gzip)) {
                s->crc = crc32(0L, Z_NULL, 0);
                *encoded_len = sizeof(http_encoding_gzip_header);
                *encoded = emalloc(*encoded_len);
@@ -604,7 +599,7 @@ PHP_HTTP_API zend_bool _http_encoding_response_start(size_t content_length TSRML
                        if (content_length) {
                                char cl_header_str[128];
                                size_t cl_header_len;
-                               cl_header_len = snprintf(cl_header_str, lenof(cl_header_str), "Content-Length: %lu", (ulong) content_length);
+                               cl_header_len = snprintf(cl_header_str, lenof(cl_header_str), "Content-Length: %zu", content_length);
                                http_send_header_string_ex(cl_header_str, cl_header_len, 1);
                        }
                } else {
@@ -622,7 +617,7 @@ PHP_HTTP_API zend_bool _http_encoding_response_start(size_t content_length TSRML
                        
                        HTTP_G(send).gzip_encoding = 0;
                        
-                       if (selected = http_negotiate_encoding(&zsupported)) {
+                       if ((selected = http_negotiate_encoding(&zsupported))) {
                                STATUS hs = FAILURE;
                                char *encoding = NULL;
                                ulong idx;