- fix inclusion of zlib.h
[m6w6/ext-http] / php_http_encoding_api.h
1 /*
2 +--------------------------------------------------------------------+
3 | PECL :: http |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2005, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
11 */
12
13 /* $Id$ */
14
15 #ifndef PHP_HTTP_ENCODING_API_H
16 #define PHP_HTTP_ENCODING_API_H
17
18 #define http_encoding_dechunk(e, el, d, dl) _http_encoding_dechunk((e), (el), (d), (dl) TSRMLS_CC)
19 PHP_HTTP_API const char *_http_encoding_dechunk(const char *encoded, size_t encoded_len, char **decoded, size_t *decoded_len TSRMLS_DC);
20
21 #define http_encoding_response_start(cl) _http_encoding_response_start((cl) TSRMLS_CC)
22 PHP_HTTP_API zend_bool _http_encoding_response_start(size_t content_length TSRMLS_DC);
23
24 #ifdef HTTP_HAVE_ZLIB
25
26 /* max count of uncompress trials, alloc_size <<= 2 for each try */
27 #define HTTP_ENCODING_MAXTRY 10
28 /* safe padding */
29 #define HTTP_ENCODING_SAFPAD 10
30 /* add 1% extra space in case we need to encode widely differing (binary) data */
31 #define HTTP_ENCODING_BUFLEN(l) (l + (l / 100) + HTTP_ENCODING_SAFPAD)
32
33 typedef enum {
34 HTTP_ENCODING_NONE = 0,
35 HTTP_ENCODING_GZIP,
36 HTTP_ENCODING_DEFLATE,
37 } http_encoding_type;
38
39 #define HTTP_ENCODING_STREAM_GZIP_HEADER 0x1
40 #define HTTP_ENCODING_STREAM_ZLIB_HEADER 0x2
41 #define HTTP_ENCODING_STREAM_PERSISTENT 0x4
42
43 typedef struct {
44 z_stream Z;
45 int gzip;
46 int persistent;
47 ulong crc;
48 void *storage;
49 } http_encoding_stream;
50
51 #define http_encoding_stream_init(s, g, l, e, el) _http_encoding_stream_init((s), (g), (l), (e), (el) TSRMLS_CC)
52 PHP_HTTP_API STATUS _http_encoding_stream_init(http_encoding_stream *s, int flags, int level, char **encoded, size_t *encoded_len TSRMLS_DC);
53 #define http_encoding_stream_update(s, d, dl, e, el) _http_encoding_stream_update((s), (d), (dl), (e), (el) TSRMLS_CC)
54 PHP_HTTP_API STATUS _http_encoding_stream_update(http_encoding_stream *s, const char *data, size_t data_len, char **encoded, size_t *encoded_len TSRMLS_DC);
55 #define http_encoding_stream_finish(s, e, el) _http_encoding_stream_finish((s), (e), (el) TSRMLS_CC)
56 PHP_HTTP_API STATUS _http_encoding_stream_finish(http_encoding_stream *s, char **encoded, size_t *encoded_len TSRMLS_DC);
57
58 #define http_encoding_gzencode_verify(d, dl, e, el) _http_encoding_gzencode_verify((d), (dl), (e), (el), HE_NOTICE)
59 PHP_HTTP_API STATUS _http_encoding_gzencode_verify(const char *data, size_t data_len, const char **encoded, size_t *encoded_len, int error_level TSRMLS_DC);
60 #define http_encoding_gzdecode_verify(e, el, d, dl) _http_encoding_gzdecode_verify((e), (el), (d), (dl), HE_NOTICE)
61 PHP_HTTP_API STATUS _http_encoding_gzdecode_verify(const char *data, size_t data_len, const char *decoded, size_t decoded_len, int error_level TSRMLS_DC);
62
63 #define http_encoding_gzencode(l, m, d, dl, r, rl) _http_encoding_gzencode((l), (m), (d), (dl), (r), (rl) TSRMLS_CC)
64 PHP_HTTP_API STATUS _http_encoding_gzencode(int level, int mtime, const char *data, size_t data_len, char **encoded, size_t *encoded_len TSRMLS_DC);
65 #define http_encoding_gzdecode(d, dl, r, rl) _http_encoding_gzdecode((d), (dl), (r), (rl) TSRMLS_CC)
66 PHP_HTTP_API STATUS _http_encoding_gzdecode(const char *data, size_t data_len, char **decoded, size_t *decoded_len TSRMLS_DC);
67 #define http_encoding_deflate(l, h, d, dl, r, rl) _http_encoding_deflate((l), (h), (d), (dl), (r), (rl) TSRMLS_CC)
68 PHP_HTTP_API STATUS _http_encoding_deflate(int level, int zhdr, const char *data, size_t data_len, char **encoded, size_t *encoded_len TSRMLS_DC);
69 #define http_encoding_inflate(d, dl, r, rl) _http_encoding_inflate((d), (dl), (r), (rl) TSRMLS_CC)
70 PHP_HTTP_API STATUS _http_encoding_inflate(const char *data, size_t data_len, char **decoded, size_t *decoded_len TSRMLS_DC);
71
72 #endif /* HTTP_HAVE_ZLIB */
73
74 #endif
75
76 /*
77 * Local variables:
78 * tab-width: 4
79 * c-basic-offset: 4
80 * End:
81 * vim600: noet sw=4 ts=4 fdm=marker
82 * vim<600: noet sw=4 ts=4
83 */
84