remove superfluous buffer macros
authorMichael Wallner <mike@php.net>
Thu, 13 Dec 2012 15:46:33 +0000 (15:46 +0000)
committerMichael Wallner <mike@php.net>
Thu, 13 Dec 2012 15:46:33 +0000 (15:46 +0000)
php_http.h
php_http_buffer.h
php_http_cookie.c
php_http_curl_client.c
php_http_encoding.c
php_http_env.c
php_http_env_response.c
php_http_filter.c
php_http_message.c
php_http_message_parser.c

index dfd7ca58d77c7cf60d3e65cf19d997766a966a27..2ad3168f805dfa05f4b0999acab13e82e95f15c7 100644 (file)
@@ -13,7 +13,7 @@
 #ifndef PHP_EXT_HTTP_H
 #define PHP_EXT_HTTP_H
 
-#define PHP_HTTP_EXT_VERSION "2.0.0beta2"
+#define PHP_HTTP_EXT_VERSION "2.0.0beta3"
 
 zend_module_entry http_module_entry;
 #define phpext_http_ptr &http_module_entry
index 012c8cffb15cbd4968e8fe93cffd068076e278fe..93776d527c1677d573f22f2eba0671393d6b6714 100644 (file)
@@ -74,8 +74,6 @@ static inline void *estrndup(void *p, size_t s)
 #endif
 
 #define PHP_HTTP_BUFFER(p) ((php_http_buffer_t *) (p))
-#define PHP_HTTP_BUFFER_VAL(p) (PHP_HTTP_BUFFER(p))->data
-#define PHP_HTTP_BUFFER_LEN(p) (PHP_HTTP_BUFFER(p))->used
 
 #define FREE_PHP_HTTP_BUFFER_PTR(STR) pefree(STR, STR->pmem)
 #define FREE_PHP_HTTP_BUFFER_VAL(STR) php_http_buffer_dtor(STR)
@@ -83,16 +81,21 @@ static inline void *estrndup(void *p, size_t s)
 #define FREE_PHP_HTTP_BUFFER(free, STR) \
        switch (free) \
        { \
-               case PHP_HTTP_BUFFER_FREE_NOT:                                                  break; \
-               case PHP_HTTP_BUFFER_FREE_PTR:  pefree(STR, STR->pmem); break; \
-               case PHP_HTTP_BUFFER_FREE_VAL:  php_http_buffer_dtor(STR);              break; \
-               case PHP_HTTP_BUFFER_FREE_ALL: \
-               { \
-                       php_http_buffer_t *PTR = (STR); \
-                       php_http_buffer_free(&PTR); \
-               } \
+       case PHP_HTTP_BUFFER_FREE_NOT: \
+               break; \
+       case PHP_HTTP_BUFFER_FREE_PTR: \
+               pefree(STR, STR->pmem); break; \
+               break; \
+       case PHP_HTTP_BUFFER_FREE_VAL: \
+               php_http_buffer_dtor(STR); \
+               break; \
+       case PHP_HTTP_BUFFER_FREE_ALL: { \
+               php_http_buffer_t *PTR = (STR); \
+               php_http_buffer_free(&PTR); \
+               break; \
+       } \
+       default:\
                break; \
-               default:                                                                                break; \
        }
 
 #define RETURN_PHP_HTTP_BUFFER_PTR(STR) RETURN_PHP_HTTP_BUFFER((STR), PHP_HTTP_BUFFER_FREE_PTR, 0)
index 5b8878306f76fd51c3a9fde1f9f6fea953ca54a7..b767bbbb7e83d974b716ff19ed435068536c9150 100644 (file)
@@ -339,8 +339,8 @@ PHP_HTTP_API void php_http_cookie_list_to_string(php_http_cookie_list_t *list, c
        }
        
        php_http_buffer_fix(&buf);
-       *str = PHP_HTTP_BUFFER_VAL(&buf);
-       *len = PHP_HTTP_BUFFER_LEN(&buf);
+       *str = buf.data;
+       *len = buf.used;
 }
 
 #define PHP_HTTP_BEGIN_ARGS(method, req_args)  PHP_HTTP_BEGIN_ARGS_EX(HttpCookie, method, 0, req_args)
index 640f3bbf5cdf5365aebb45d913eabcfc1116dbe3..621e05b3d54b5587e388af31e7eaf03e7a480c92 100644 (file)
@@ -436,8 +436,8 @@ static STATUS php_http_curl_client_option_set_cookies(php_http_option_t *opt, zv
                        }
 
                        php_http_buffer_fix(&curl->options.cookies);
-                       if (PHP_HTTP_BUFFER_LEN(&curl->options.cookies)) {
-                               if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIE, PHP_HTTP_BUFFER_VAL(&curl->options.cookies))) {
+                       if (curl->options.cookies.used) {
+                               if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIE, curl->options.cookies.data)) {
                                        return FAILURE;
                                }
                        }
@@ -506,7 +506,7 @@ static STATUS php_http_curl_client_option_set_etag(php_http_option_t *opt, zval
        php_http_buffer_init(&header);
        php_http_buffer_appendf(&header, is_quoted?"%s: %s":"%s: \"%s\"", curl->options.range_request?"If-Match":"If-None-Match", Z_STRVAL_P(val));
        php_http_buffer_fix(&header);
-       curl->options.headers = curl_slist_append(curl->options.headers, PHP_HTTP_BUFFER_VAL(&header));
+       curl->options.headers = curl_slist_append(curl->options.headers, header.data);
        php_http_buffer_dtor(&header);
        return SUCCESS;
 }
@@ -543,14 +543,14 @@ static STATUS php_http_curl_client_option_set_range(php_http_option_t *opt, zval
                        }
                }
 
-               if (PHP_HTTP_BUFFER_LEN(&curl->options.ranges)) {
+               if (curl->options.ranges.used) {
                        curl->options.range_request = 1;
                        /* ditch last comma */
-                       PHP_HTTP_BUFFER_VAL(&curl->options.ranges)[PHP_HTTP_BUFFER_LEN(&curl->options.ranges)-- -1] = '\0';
+                       curl->options.ranges.data[curl->options.ranges.used - 1] = '\0';
                }
        }
 
-       if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_RANGE, PHP_HTTP_BUFFER_VAL(&curl->options.ranges))) {
+       if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_RANGE, curl->options.ranges.data)) {
                return FAILURE;
        }
        return SUCCESS;
@@ -1198,7 +1198,7 @@ PHP_HTTP_API STATUS php_http_curl_client_prepare(php_http_client_t *h, php_http_
 
                                php_http_buffer_appendf(&header, "%s: %s", header_key.str, Z_STRVAL_P(header_cpy));
                                php_http_buffer_fix(&header);
-                               curl->options.headers = curl_slist_append(curl->options.headers, PHP_HTTP_BUFFER_VAL(&header));
+                               curl->options.headers = curl_slist_append(curl->options.headers, header.data);
                                php_http_buffer_reset(&header);
 
                                zval_ptr_dtor(&header_cpy);
index a1667fc0fdc645be68540c69cf75fc670ccdb40e..9767ee490078a0d57109d78bd5d9e5ef4e305f91 100644 (file)
@@ -431,7 +431,7 @@ static php_http_encoding_stream_t *deflate_copy(php_http_encoding_stream_t *from
 
        if (Z_OK == (status = deflateCopy(to_ctx, from_ctx))) {
                if ((to_ctx->opaque = php_http_buffer_init_ex(NULL, PHP_HTTP_DEFLATE_BUFFER_SIZE, p ? PHP_HTTP_BUFFER_INIT_PERSISTENT : 0))) {
-                       php_http_buffer_append(to_ctx->opaque, PHP_HTTP_BUFFER_VAL(from_ctx->opaque), PHP_HTTP_BUFFER_LEN(from_ctx->opaque));
+                       php_http_buffer_append(to_ctx->opaque, PHP_HTTP_BUFFER(from_ctx->opaque)->data, PHP_HTTP_BUFFER(from_ctx->opaque)->used);
                        to->ctx = to_ctx;
                        return to;
                }
@@ -450,7 +450,7 @@ static php_http_encoding_stream_t *inflate_copy(php_http_encoding_stream_t *from
 
        if (Z_OK == (status = inflateCopy(to_ctx, from_ctx))) {
                if ((to_ctx->opaque = php_http_buffer_init_ex(NULL, PHP_HTTP_DEFLATE_BUFFER_SIZE, p ? PHP_HTTP_BUFFER_INIT_PERSISTENT : 0))) {
-                       php_http_buffer_append(to_ctx->opaque, PHP_HTTP_BUFFER_VAL(from_ctx->opaque), PHP_HTTP_BUFFER_LEN(from_ctx->opaque));
+                       php_http_buffer_append(to_ctx->opaque, PHP_HTTP_BUFFER(from_ctx->opaque)->data, PHP_HTTP_BUFFER(from_ctx->opaque)->used);
                        to->ctx = to_ctx;
                        return to;
                }
@@ -470,7 +470,7 @@ static php_http_encoding_stream_t *dechunk_copy(php_http_encoding_stream_t *from
        if (php_http_buffer_init_ex(&to_ctx->buffer, PHP_HTTP_BUFFER_DEFAULT_SIZE, p ? PHP_HTTP_BUFFER_INIT_PERSISTENT : 0)) {
                to_ctx->hexlen = from_ctx->hexlen;
                to_ctx->zeroed = from_ctx->zeroed;
-               php_http_buffer_append(&to_ctx->buffer, PHP_HTTP_BUFFER_VAL(&from_ctx->buffer), PHP_HTTP_BUFFER_LEN(&from_ctx->buffer));
+               php_http_buffer_append(&to_ctx->buffer, from_ctx->buffer.data, from_ctx->buffer.used);
                to->ctx = to_ctx;
                return to;
        }
@@ -488,8 +488,8 @@ static STATUS deflate_update(php_http_encoding_stream_t *s, const char *data, si
        /* append input to our buffer */
        php_http_buffer_append(PHP_HTTP_BUFFER(ctx->opaque), data, data_len);
        
-       ctx->next_in = (Bytef *) PHP_HTTP_BUFFER_VAL(ctx->opaque);
-       ctx->avail_in = PHP_HTTP_BUFFER_LEN(ctx->opaque);
+       ctx->next_in = (Bytef *) PHP_HTTP_BUFFER(ctx->opaque)->data;
+       ctx->avail_in = PHP_HTTP_BUFFER(ctx->opaque)->used;
        
        /* deflate */
        *encoded_len = PHP_HTTP_DEFLATE_BUFFER_SIZE_GUESS(data_len);
@@ -502,7 +502,7 @@ static STATUS deflate_update(php_http_encoding_stream_t *s, const char *data, si
                case Z_STREAM_END:
                        /* cut processed chunk off the buffer */
                        if (ctx->avail_in) {
-                               php_http_buffer_cut(PHP_HTTP_BUFFER(ctx->opaque), 0, PHP_HTTP_BUFFER_LEN(ctx->opaque) - ctx->avail_in);
+                               php_http_buffer_cut(PHP_HTTP_BUFFER(ctx->opaque), 0, PHP_HTTP_BUFFER(ctx->opaque)->used - ctx->avail_in);
                        } else {
                                php_http_buffer_reset(PHP_HTTP_BUFFER(ctx->opaque));
                        }
@@ -530,15 +530,15 @@ static STATUS inflate_update(php_http_encoding_stream_t *s, const char *data, si
        php_http_buffer_append(PHP_HTTP_BUFFER(ctx->opaque), data, data_len);
 
 retry_raw_inflate:
-       ctx->next_in = (Bytef *) PHP_HTTP_BUFFER_VAL(ctx->opaque);
-       ctx->avail_in = PHP_HTTP_BUFFER_LEN(ctx->opaque);
+       ctx->next_in = (Bytef *) PHP_HTTP_BUFFER(ctx->opaque)->data;
+       ctx->avail_in = PHP_HTTP_BUFFER(ctx->opaque)->used;
        
        switch (status = php_http_inflate_rounds(ctx, PHP_HTTP_ENCODING_STREAM_FLUSH_FLAG(s->flags), decoded, decoded_len)) {
                case Z_OK:
                case Z_STREAM_END:
                        /* cut off */
                        if (ctx->avail_in) {
-                               php_http_buffer_cut(PHP_HTTP_BUFFER(ctx->opaque), 0, PHP_HTTP_BUFFER_LEN(ctx->opaque) - ctx->avail_in);
+                               php_http_buffer_cut(PHP_HTTP_BUFFER(ctx->opaque), 0, PHP_HTTP_BUFFER(ctx->opaque)->used - ctx->avail_in);
                        } else {
                                php_http_buffer_reset(PHP_HTTP_BUFFER(ctx->opaque));
                        }
@@ -580,20 +580,20 @@ static STATUS dechunk_update(php_http_encoding_stream_t *s, const char *data, si
        php_http_buffer_init(&tmp);
 
        /* we have data in our buffer */
-       while (PHP_HTTP_BUFFER_LEN(&ctx->buffer)) {
+       while (ctx->buffer.used) {
 
                /* we already know the size of the chunk and are waiting for data */
                if (ctx->hexlen) {
 
                        /* not enough data buffered */
-                       if (PHP_HTTP_BUFFER_LEN(&ctx->buffer) < ctx->hexlen) {
+                       if (ctx->buffer.used < ctx->hexlen) {
 
                                /* flush anyway? */
                                if (s->flags & PHP_HTTP_ENCODING_STREAM_FLUSH_FULL) {
                                        /* flush all data (should only be chunk data) */
-                                       php_http_buffer_append(&tmp, PHP_HTTP_BUFFER_VAL(&ctx->buffer), PHP_HTTP_BUFFER_LEN(&ctx->buffer));
+                                       php_http_buffer_append(&tmp, ctx->buffer.data, ctx->buffer.used);
                                        /* waiting for less data now */
-                                       ctx->hexlen -= PHP_HTTP_BUFFER_LEN(&ctx->buffer);
+                                       ctx->hexlen -= ctx->buffer.used;
                                        /* no more buffered data */
                                        php_http_buffer_reset(&ctx->buffer);
                                        /* break */
@@ -607,9 +607,9 @@ static STATUS dechunk_update(php_http_encoding_stream_t *s, const char *data, si
 
                        /* we seem to have all data of the chunk */
                        else {
-                               php_http_buffer_append(&tmp, PHP_HTTP_BUFFER_VAL(&ctx->buffer), ctx->hexlen);
+                               php_http_buffer_append(&tmp, ctx->buffer.data, ctx->hexlen);
                                /* remove outgoing data from the buffer */
-                               php_http_buffer_cut(PHP_HTTP_BUFFER(&ctx->buffer), 0, ctx->hexlen);
+                               php_http_buffer_cut(&ctx->buffer, 0, ctx->hexlen);
                                /* reset hexlen */
                                ctx->hexlen = 0;
                                /* continue */
@@ -621,50 +621,50 @@ static STATUS dechunk_update(php_http_encoding_stream_t *s, const char *data, si
                        size_t off = 0;
 
                        /* ignore preceeding CRLFs (too loose?) */
-                       while (off < PHP_HTTP_BUFFER_LEN(&ctx->buffer) && (
-                                       PHP_HTTP_BUFFER_VAL(&ctx->buffer)[off] == '\n' ||
-                                       PHP_HTTP_BUFFER_VAL(&ctx->buffer)[off] == '\r')) {
+                       while (off < ctx->buffer.used && (
+                                       ctx->buffer.data[off] == '\n' ||
+                                       ctx->buffer.data[off] == '\r')) {
                                ++off;
                        }
                        if (off) {
-                               php_http_buffer_cut(PHP_HTTP_BUFFER(&ctx->buffer), 0, off);
+                               php_http_buffer_cut(&ctx->buffer, 0, off);
                        }
 
                        /* still data there? */
-                       if (PHP_HTTP_BUFFER_LEN(&ctx->buffer)) {
+                       if (ctx->buffer.used) {
                                int eollen;
                                const char *eolstr;
 
                                /* we need eol, so we can be sure we have all hex digits */
                                php_http_buffer_fix(&ctx->buffer);
-                               if ((eolstr = php_http_locate_bin_eol(PHP_HTTP_BUFFER_VAL(&ctx->buffer), PHP_HTTP_BUFFER_LEN(&ctx->buffer), &eollen))) {
+                               if ((eolstr = php_http_locate_bin_eol(ctx->buffer.data, ctx->buffer.used, &eollen))) {
                                        char *stop = NULL;
 
                                        /* read in chunk size */
-                                       ctx->hexlen = strtoul(PHP_HTTP_BUFFER_VAL(&ctx->buffer), &stop, 16);
+                                       ctx->hexlen = strtoul(ctx->buffer.data, &stop, 16);
 
                                        /*      if strtoul() stops at the beginning of the buffered data
-                                               there's domething oddly wrong, i.e. bad input */
-                                       if (stop == PHP_HTTP_BUFFER_VAL(&ctx->buffer)) {
+                                               there's something oddly wrong, i.e. bad input */
+                                       if (stop == ctx->buffer.data) {
                                                php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Failed to parse chunk len from '%.*s'", MIN(16, ctx->buffer.used), ctx->buffer.data);
                                                php_http_buffer_dtor(&tmp);
                                                return FAILURE;
                                        }
 
                                        /* cut out <chunk size hex><chunk extension><eol> */
-                                       php_http_buffer_cut(PHP_HTTP_BUFFER(&ctx->buffer), 0, eolstr + eollen - PHP_HTTP_BUFFER_VAL(&ctx->buffer));
+                                       php_http_buffer_cut(&ctx->buffer, 0, eolstr + eollen - ctx->buffer.data);
                                        /* buffer->hexlen is 0 now or contains the size of the next chunk */
                                        if (!ctx->hexlen) {
                                                size_t off = 0;
 
                                                /* ignore following CRLFs (too loose?) */
-                                               while (off < PHP_HTTP_BUFFER_LEN(&ctx->buffer) && (
-                                                               PHP_HTTP_BUFFER_VAL(&ctx->buffer)[off] == '\n' ||
-                                                               PHP_HTTP_BUFFER_VAL(&ctx->buffer)[off] == '\r')) {
+                                               while (off < ctx->buffer.used && (
+                                                               ctx->buffer.data[off] == '\n' ||
+                                                               ctx->buffer.data[off] == '\r')) {
                                                        ++off;
                                                }
                                                if (off) {
-                                                       php_http_buffer_cut(PHP_HTTP_BUFFER(&ctx->buffer), 0, off);
+                                                       php_http_buffer_cut(&ctx->buffer, 0, off);
                                                }
 
                                                ctx->zeroed = 1;
@@ -681,8 +681,8 @@ static STATUS dechunk_update(php_http_encoding_stream_t *s, const char *data, si
        }
 
        php_http_buffer_fix(&tmp);
-       *decoded = PHP_HTTP_BUFFER_VAL(&tmp);
-       *decoded_len = PHP_HTTP_BUFFER_LEN(&tmp);
+       *decoded = tmp.data;
+       *decoded_len = tmp.used;
 
        return SUCCESS;
 }
@@ -725,7 +725,7 @@ static STATUS dechunk_flush(php_http_encoding_stream_t *s, char **decoded, size_
                php_http_buffer_fix(&ctx->buffer);
                php_http_buffer_data(&ctx->buffer, decoded, decoded_len);
                /* waiting for less data now */
-               ctx->hexlen -= PHP_HTTP_BUFFER_LEN(&ctx->buffer);
+               ctx->hexlen -= ctx->buffer.used;
                /* no more buffered data */
                php_http_buffer_reset(&ctx->buffer);
        } else {
@@ -746,8 +746,8 @@ static STATUS deflate_finish(php_http_encoding_stream_t *s, char **encoded, size
        *encoded = emalloc(*encoded_len);
        
        /* deflate remaining input */
-       ctx->next_in = (Bytef *) PHP_HTTP_BUFFER_VAL(ctx->opaque);
-       ctx->avail_in = PHP_HTTP_BUFFER_LEN(ctx->opaque);
+       ctx->next_in = (Bytef *) PHP_HTTP_BUFFER(ctx->opaque)->data;
+       ctx->avail_in = PHP_HTTP_BUFFER(ctx->opaque)->used;
        
        ctx->avail_out = *encoded_len;
        ctx->next_out = (Bytef *) *encoded;
@@ -757,8 +757,8 @@ static STATUS deflate_finish(php_http_encoding_stream_t *s, char **encoded, size
        } while (Z_OK == status);
        
        if (Z_STREAM_END == status) {
-               /* cut processed intp off */
-               php_http_buffer_cut(PHP_HTTP_BUFFER(ctx->opaque), 0, PHP_HTTP_BUFFER_LEN(ctx->opaque) - ctx->avail_in);
+               /* cut processed input off */
+               php_http_buffer_cut(PHP_HTTP_BUFFER(ctx->opaque), 0, PHP_HTTP_BUFFER(ctx->opaque)->used - ctx->avail_in);
                
                /* size down */
                *encoded_len -= ctx->avail_out;
@@ -779,25 +779,25 @@ static STATUS inflate_finish(php_http_encoding_stream_t *s, char **decoded, size
        z_streamp ctx = s->ctx;
        TSRMLS_FETCH_FROM_CTX(s->ts);
        
-       if (!PHP_HTTP_BUFFER_LEN(ctx->opaque)) {
+       if (!PHP_HTTP_BUFFER(ctx->opaque)->used) {
                *decoded = NULL;
                *decoded_len = 0;
                return SUCCESS;
        }
        
-       *decoded_len = (PHP_HTTP_BUFFER_LEN(ctx->opaque) + 1) * PHP_HTTP_INFLATE_ROUNDS;
+       *decoded_len = (PHP_HTTP_BUFFER(ctx->opaque)->used + 1) * PHP_HTTP_INFLATE_ROUNDS;
        *decoded = emalloc(*decoded_len);
        
        /* inflate remaining input */
-       ctx->next_in = (Bytef *) PHP_HTTP_BUFFER_VAL(ctx->opaque);
-       ctx->avail_in = PHP_HTTP_BUFFER_LEN(ctx->opaque);
+       ctx->next_in = (Bytef *) PHP_HTTP_BUFFER(ctx->opaque)->data;
+       ctx->avail_in = PHP_HTTP_BUFFER(ctx->opaque)->used;
        
        ctx->avail_out = *decoded_len;
        ctx->next_out = (Bytef *) *decoded;
        
        if (Z_STREAM_END == (status = inflate(ctx, Z_FINISH))) {
                /* cut processed input off */
-               php_http_buffer_cut(PHP_HTTP_BUFFER(ctx->opaque), 0, PHP_HTTP_BUFFER_LEN(ctx->opaque) - ctx->avail_in);
+               php_http_buffer_cut(PHP_HTTP_BUFFER(ctx->opaque), 0, PHP_HTTP_BUFFER(ctx->opaque)->used - ctx->avail_in);
                
                /* size down */
                *decoded_len -= ctx->avail_out;
@@ -815,13 +815,13 @@ static STATUS inflate_finish(php_http_encoding_stream_t *s, char **decoded, size
 static zend_bool deflate_done(php_http_encoding_stream_t *s)
 {
        z_streamp ctx = s->ctx;
-       return !ctx->avail_in && !PHP_HTTP_BUFFER_LEN(ctx->opaque);
+       return !ctx->avail_in && !PHP_HTTP_BUFFER(ctx->opaque)->used;
 }
 
 static zend_bool inflate_done(php_http_encoding_stream_t *s)
 {
        z_streamp ctx = s->ctx;
-       return !ctx->avail_in && !PHP_HTTP_BUFFER_LEN(ctx->opaque);
+       return !ctx->avail_in && !PHP_HTTP_BUFFER(ctx->opaque)->used;
 }
 
 static zend_bool dechunk_done(php_http_encoding_stream_t *s)
index f2d4a38dec43adad76ee3e9ddcfdf21349b05dd2..74194c43a929c8dba1c014da1aa6f64ce3235520 100644 (file)
@@ -417,7 +417,7 @@ PHP_HTTP_API STATUS php_http_env_get_response_headers(HashTable *headers_ht TSRM
        zend_llist_apply_with_argument(&SG(sapi_headers).headers, grab_headers, &headers TSRMLS_CC);
        php_http_buffer_fix(&headers);
 
-       status = php_http_headers_parse(PHP_HTTP_BUFFER_VAL(&headers), PHP_HTTP_BUFFER_LEN(&headers), headers_ht, NULL, NULL TSRMLS_CC);
+       status = php_http_headers_parse(headers.data, headers.used, headers_ht, NULL, NULL TSRMLS_CC);
        php_http_buffer_dtor(&headers);
 
        return status;
index 2c7547e0e40ae2419a4dc723bd0afdb8bbdc17b4..b64aefd1e74d05ee6709d7f1b923e409b4eed8d5 100644 (file)
@@ -386,7 +386,7 @@ static STATUS php_http_env_response_send_head(php_http_env_response_t *r)
 
                        php_http_buffer_init(&buf);
                        if (php_http_params_to_string(&buf, Z_ARRVAL_P(zoption_copy), ZEND_STRL(","), ZEND_STRL(";"), ZEND_STRL("="), PHP_HTTP_PARAMS_DEFAULT TSRMLS_CC)) {
-                               ret = php_http_env_set_response_header_format(0, 1 TSRMLS_CC, "Content-Disposition: %s", PHP_HTTP_BUFFER_VAL(&buf));
+                               ret = php_http_env_set_response_header_format(0, 1 TSRMLS_CC, "Content-Disposition: %s", buf.data);
                        }
 
                        php_http_buffer_dtor(&buf);
index dd4fa14d293871092eae5bc145b06edc19ec25fd..c3aaf2d629df219ca5785c8e29af5cf4636b251c 100644 (file)
@@ -107,23 +107,23 @@ static PHP_HTTP_FILTER_FUNCTION(chunked_decode)
        }
 
        /* we have data in our buffer */
-       while (PHP_HTTP_BUFFER_LEN(buffer)) {
+       while (PHP_HTTP_BUFFER(buffer)->used) {
        
                /* we already know the size of the chunk and are waiting for data */
                if (buffer->hexlen) {
                
                        /* not enough data buffered */
-                       if (PHP_HTTP_BUFFER_LEN(buffer) < buffer->hexlen) {
+                       if (PHP_HTTP_BUFFER(buffer)->used < buffer->hexlen) {
                        
                                /* flush anyway? */
                                if (flags & PSFS_FLAG_FLUSH_INC) {
                                
                                        /* flush all data (should only be chunk data) */
                                        out_avail = 1;
-                                       NEW_BUCKET(PHP_HTTP_BUFFER_VAL(buffer), PHP_HTTP_BUFFER_LEN(buffer));
+                                       NEW_BUCKET(PHP_HTTP_BUFFER(buffer)->data, PHP_HTTP_BUFFER(buffer)->used);
                                        
                                        /* waiting for less data now */
-                                       buffer->hexlen -= PHP_HTTP_BUFFER_LEN(buffer);
+                                       buffer->hexlen -= PHP_HTTP_BUFFER(buffer)->used;
                                        /* no more buffered data */
                                        php_http_buffer_reset(PHP_HTTP_BUFFER(buffer));
                                        /* break */
@@ -138,7 +138,7 @@ static PHP_HTTP_FILTER_FUNCTION(chunked_decode)
                        /* we seem to have all data of the chunk */
                        else {
                                out_avail = 1;
-                               NEW_BUCKET(PHP_HTTP_BUFFER_VAL(buffer), buffer->hexlen);
+                               NEW_BUCKET(PHP_HTTP_BUFFER(buffer)->data, buffer->hexlen);
                                
                                /* remove outgoing data from the buffer */
                                php_http_buffer_cut(PHP_HTTP_BUFFER(buffer), 0, buffer->hexlen);
@@ -153,9 +153,9 @@ static PHP_HTTP_FILTER_FUNCTION(chunked_decode)
                        size_t off = 0;
                        
                        /* ignore preceeding CRLFs (too loose?) */
-                       while (off < PHP_HTTP_BUFFER_LEN(buffer) && (
-                                       PHP_HTTP_BUFFER_VAL(buffer)[off] == '\n' || 
-                                       PHP_HTTP_BUFFER_VAL(buffer)[off] == '\r')) {
+                       while (off < PHP_HTTP_BUFFER(buffer)->used && (
+                                       PHP_HTTP_BUFFER(buffer)->data[off] == '\n' || 
+                                       PHP_HTTP_BUFFER(buffer)->data[off] == '\r')) {
                                ++off;
                        }
                        if (off) {
@@ -163,26 +163,26 @@ static PHP_HTTP_FILTER_FUNCTION(chunked_decode)
                        }
                        
                        /* still data there? */
-                       if (PHP_HTTP_BUFFER_LEN(buffer)) {
+                       if (PHP_HTTP_BUFFER(buffer)->used) {
                                int eollen;
                                const char *eolstr;
                                
                                /* we need eol, so we can be sure we have all hex digits */
                                php_http_buffer_fix(PHP_HTTP_BUFFER(buffer));
-                               if ((eolstr = php_http_locate_bin_eol(PHP_HTTP_BUFFER_VAL(buffer), PHP_HTTP_BUFFER_LEN(buffer), &eollen))) {
+                               if ((eolstr = php_http_locate_bin_eol(PHP_HTTP_BUFFER(buffer)->data, PHP_HTTP_BUFFER(buffer)->used, &eollen))) {
                                        char *stop = NULL;
                                        
                                        /* read in chunk size */
-                                       buffer->hexlen = strtoul(PHP_HTTP_BUFFER_VAL(buffer), &stop, 16);
+                                       buffer->hexlen = strtoul(PHP_HTTP_BUFFER(buffer)->data, &stop, 16);
                                        
                                        /*      if strtoul() stops at the beginning of the buffered data
                                                there's something oddly wrong, i.e. bad input */
-                                       if (stop == PHP_HTTP_BUFFER_VAL(buffer)) {
+                                       if (stop == PHP_HTTP_BUFFER(buffer)->data) {
                                                return PSFS_ERR_FATAL;
                                        }
                                        
                                        /* cut out <chunk size hex><chunk extension><eol> */
-                                       php_http_buffer_cut(PHP_HTTP_BUFFER(buffer), 0, eolstr + eollen - PHP_HTTP_BUFFER_VAL(buffer));
+                                       php_http_buffer_cut(PHP_HTTP_BUFFER(buffer), 0, eolstr + eollen - PHP_HTTP_BUFFER(buffer)->data);
                                        /* buffer->hexlen is 0 now or contains the size of the next chunk */
                                        if (!buffer->hexlen) {
                                                php_stream_notify_info(stream->context, PHP_STREAM_NOTIFY_COMPLETED, NULL, 0);
@@ -199,9 +199,9 @@ static PHP_HTTP_FILTER_FUNCTION(chunked_decode)
        }
        
        /* flush before close, but only if we are already waiting for more data */
-       if (PHP_HTTP_FILTER_IS_CLOSING(stream, flags) && buffer->hexlen && PHP_HTTP_BUFFER_LEN(buffer)) {
+       if (PHP_HTTP_FILTER_IS_CLOSING(stream, flags) && buffer->hexlen && PHP_HTTP_BUFFER(buffer)->used) {
                out_avail = 1;
-               NEW_BUCKET(PHP_HTTP_BUFFER_VAL(buffer), PHP_HTTP_BUFFER_LEN(buffer));
+               NEW_BUCKET(PHP_HTTP_BUFFER(buffer)->data, PHP_HTTP_BUFFER(buffer)->used);
                php_http_buffer_reset(PHP_HTTP_BUFFER(buffer));
                buffer->hexlen = 0;
        }
@@ -245,7 +245,7 @@ static PHP_HTTP_FILTER_FUNCTION(chunked_encode)
                php_http_buffer_appends(&buf, PHP_HTTP_CRLF);
 
                /* pass through */
-               NEW_BUCKET(PHP_HTTP_BUFFER_VAL(&buf), PHP_HTTP_BUFFER_LEN(&buf));
+               NEW_BUCKET(buf.data, buf.used);
                /* reset */
                php_http_buffer_reset(&buf);
                php_stream_bucket_delref(ptr TSRMLS_CC);
index 43a54290ef6ad5fca0fb493d3f63610c8309c054..39f857d5d7c280d30f140311d94f965190384f6a 100644 (file)
@@ -20,7 +20,7 @@ PHP_HTTP_API zend_bool php_http_message_info_callback(php_http_message_t **messa
        php_http_message_t *old = *message;
 
        /* advance message */
-       if (!old || old->type || zend_hash_num_elements(&old->hdrs) || PHP_HTTP_BUFFER_LEN(old)) {
+       if (!old || old->type || zend_hash_num_elements(&old->hdrs)) {
                (*message) = php_http_message_init(NULL, 0 TSRMLS_CC);
                (*message)->parent = old;
                if (headers) {
@@ -322,11 +322,11 @@ static zval *message_header_strval(zval **header TSRMLS_DC)
                FOREACH_VAL(pos, *header, val) {
                        zval *strval = message_header_strval(val TSRMLS_CC);
 
-                       php_http_buffer_appendf(&str, PHP_HTTP_BUFFER_LEN(&str) ? ", %s":"%s", Z_STRVAL_P(strval));
+                       php_http_buffer_appendf(&str, str.used ? ", %s":"%s", Z_STRVAL_P(strval));
                        zval_ptr_dtor(&strval);
                }
                php_http_buffer_fix(&str);
-               ZVAL_STRINGL(ret, PHP_HTTP_BUFFER_VAL(&str), PHP_HTTP_BUFFER_LEN(&str), 0);
+               ZVAL_STRINGL(ret, str.data, str.used, 0);
        } else  {
                ret = php_http_zsep(1, IS_STRING, *header);
        }
@@ -398,7 +398,7 @@ PHP_HTTP_API void php_http_message_to_callback(php_http_message_t *msg, php_http
 
        php_http_buffer_init_ex(&str, 0x1000, 0);
        message_headers(msg, &str);
-       cb(cb_arg, PHP_HTTP_BUFFER_VAL(&str), PHP_HTTP_BUFFER_LEN(&str));
+       cb(cb_arg, str.data, str.used);
        php_http_buffer_dtor(&str);
 
        if (php_http_message_body_size(&msg->body)) {
index 634a7648642d6a2b3991cbfbf6f717b779430ade..3e46674cf3dfa728a62b95a2d93f99fcbd4eb315 100644 (file)
@@ -458,7 +458,7 @@ PHP_HTTP_API php_http_message_parser_state_t php_http_message_parser_parse(php_h
                                len = dec_len;
 
                                if (php_http_encoding_stream_done(parser->dechunk)) {
-                                       cut = buffer->used - PHP_HTTP_BUFFER_LEN(parser->dechunk->ctx);
+                                       cut = buffer->used - PHP_HTTP_BUFFER(parser->dechunk->ctx)->used;
                                        php_http_message_parser_state_push(parser, 2, PHP_HTTP_MESSAGE_PARSER_STATE_BODY_DONE, PHP_HTTP_MESSAGE_PARSER_STATE_BODY);
                                } else {
                                        cut = buffer->used;