remove superfluous buffer macros
[m6w6/ext-http] / php_http_buffer.h
index ee78c41165f048ea5bd4b505c3dd141401dc4f7c..93776d527c1677d573f22f2eba0671393d6b6714 100644 (file)
@@ -1,8 +1,17 @@
+/*
+    +--------------------------------------------------------------------+
+    | PECL :: http                                                       |
+    +--------------------------------------------------------------------+
+    | Redistribution and use in source and binary forms, with or without |
+    | modification, are permitted provided that the conditions mentioned |
+    | in the accompanying LICENSE file are met.                          |
+    +--------------------------------------------------------------------+
+    | Copyright (c) 2004-2011, Michael Wallner <mike@php.net>            |
+    +--------------------------------------------------------------------+
+*/
 
-/* $Id: php_http_buffer_t.h 229282 2007-02-07 15:31:50Z mike $ */
-
-#ifndef _PHP_HTTP_BUFFER_H
-#define _PHP_HTTP_BUFFER_H
+#ifndef PHP_HTTP_BUFFER_H
+#define PHP_HTTP_BUFFER_H
 
 #ifndef PHP_HTTP_BUFFER_DEFAULT_SIZE
 #      define PHP_HTTP_BUFFER_DEFAULT_SIZE 256
@@ -65,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)
@@ -74,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)
@@ -142,6 +154,8 @@ PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_from_string_ex(php_http_b
 #define php_http_buffer_resize(b, s) php_http_buffer_resize_ex((b), (s), 0, 0)
 PHP_HTTP_BUFFER_API size_t php_http_buffer_resize_ex(php_http_buffer_t *buf, size_t len, size_t override_size, int allow_error);
 
+PHP_HTTP_BUFFER_API char *php_http_buffer_account(php_http_buffer_t *buf, size_t to_account);
+
 /* shrink memory chunk to actually used size (+1) */
 PHP_HTTP_BUFFER_API size_t php_http_buffer_shrink(php_http_buffer_t *buf);
 
@@ -208,7 +222,9 @@ PHP_HTTP_BUFFER_API void php_http_buffer_free(php_http_buffer_t **buf);
 /* stores data in a php_http_buffer_t until it reaches chunk_size */
 PHP_HTTP_BUFFER_API size_t php_http_buffer_chunk_buffer(php_http_buffer_t **s, const char *data, size_t data_len, char **chunk, size_t chunk_size);
 
-typedef size_t (*php_http_buffer_pass_func_t)(void *opaque, const char *, size_t TSRMLS_DC);
+typedef size_t (*php_http_buffer_pass_func_t)(void *opaque, char *, size_t TSRMLS_DC);
+
+PHP_HTTP_BUFFER_API ssize_t php_http_buffer_passthru(php_http_buffer_t **s, size_t chunk_size, php_http_buffer_pass_func_t passin, void *passin_arg, php_http_buffer_pass_func_t passon, void *passon_arg TSRMLS_DC);
 
 /* wrapper around php_http_buffer_chunk_buffer, which passes available chunks to passthru() */
 PHP_HTTP_BUFFER_API void php_http_buffer_chunked_output(php_http_buffer_t **s, const char *data, size_t data_len, size_t chunk_size, php_http_buffer_pass_func_t passout, void *opaque TSRMLS_DC);