- API cleanup: remove unset*() methods and make set*() methods capable of that
[m6w6/ext-http] / php_http_send_api.h
1 /*
2 +----------------------------------------------------------------------+
3 | PECL :: http |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.0 of the PHP license, that |
6 | is bundled with this package in the file LICENSE, and is available |
7 | through the world-wide-web at http://www.php.net/license/3_0.txt. |
8 | If you did not receive a copy of the PHP license and are unable to |
9 | obtain it through the world-wide-web, please send a note to |
10 | license@php.net so we can mail you a copy immediately. |
11 +----------------------------------------------------------------------+
12 | Copyright (c) 2004-2005 Michael Wallner <mike@php.net> |
13 +----------------------------------------------------------------------+
14 */
15
16 /* $Id$ */
17
18 #ifndef PHP_HTTP_SEND_API_H
19 #define PHP_HTTP_SEND_API_H
20
21 #include "SAPI.h"
22 #include "php_streams.h"
23 #include "php_http_std_defs.h"
24
25 typedef enum {
26 SEND_DATA,
27 SEND_RSRC
28 } http_send_mode;
29
30 #define http_send_status(s) sapi_header_op(SAPI_HEADER_SET_STATUS, (void *) (s) TSRMLS_CC)
31 #define http_send_header(n, v, r) _http_send_header_ex((n), strlen(n), (v), strlen(v), (r) TSRMLS_CC)
32 #define http_send_header_ex(n, nl, v, vl, r) _http_send_header_ex((n), (nl), (v), (vl), (r) TSRMLS_CC)
33 PHP_HTTP_API STATUS _http_send_header_ex(const char *name, size_t name_len, const char *value, size_t value_len, zend_bool replace TSRMLS_DC);
34 #define http_send_header_string(h) _http_send_status_header_ex(0, (h), 1 TSRMLS_CC)
35 #define http_send_header_string_ex(h, r) _http_send_status_header_ex(0, (h), (r) TSRMLS_CC)
36 #define http_send_status_header(s, h) _http_send_status_header_ex((s), (h), 1 TSRMLS_CC)
37 #define http_send_status_header_ex(s, h, r) _http_send_status_header_ex((s), (h), (r) TSRMLS_CC)
38 PHP_HTTP_API STATUS _http_send_status_header_ex(int status, const char *header, zend_bool replace TSRMLS_DC);
39
40 #define http_send_last_modified(t) _http_send_last_modified((t) TSRMLS_CC)
41 PHP_HTTP_API STATUS _http_send_last_modified(time_t t TSRMLS_DC);
42
43 #define http_send_etag(e, l) _http_send_etag((e), (l) TSRMLS_CC)
44 PHP_HTTP_API STATUS _http_send_etag(const char *etag, size_t etag_len TSRMLS_DC);
45
46 #define http_send_cache_control(cc, cl) http_send_header_ex("Cache-Control", lenof("Cache-Control"), (cc), (cl), 1)
47
48 #define http_send_content_type(c, l) _http_send_content_type((c), (l) TSRMLS_CC)
49 PHP_HTTP_API STATUS _http_send_content_type(const char *content_type, size_t ct_len TSRMLS_DC);
50
51 #define http_send_content_disposition(f, l, i) _http_send_content_disposition((f), (l), (i) TSRMLS_CC)
52 PHP_HTTP_API STATUS _http_send_content_disposition(const char *filename, size_t f_len, zend_bool send_inline TSRMLS_DC);
53
54 #define http_send_ranges(r, d, s, m) _http_send_ranges((r), (d), (s), (m) TSRMLS_CC)
55 PHP_HTTP_API STATUS _http_send_ranges(HashTable *ranges, const void *data, size_t size, http_send_mode mode TSRMLS_DC);
56
57 #define http_send_data(d, l) http_send((d), (l), SEND_DATA)
58 #define http_send(d, s, m) _http_send((d), (s), (m) TSRMLS_CC)
59 PHP_HTTP_API STATUS _http_send(const void *data, size_t data_size, http_send_mode mode TSRMLS_DC);
60
61 #define http_send_file(f) http_send_stream_ex(php_stream_open_wrapper(f, "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL), 1)
62 #define http_send_stream(s) http_send_stream_ex((s), 0)
63 #define http_send_stream_ex(s, c) _http_send_stream_ex((s), (c) TSRMLS_CC)
64 PHP_HTTP_API STATUS _http_send_stream_ex(php_stream *s, zend_bool close_stream TSRMLS_DC);
65
66 #endif
67
68 /*
69 * Local variables:
70 * tab-width: 4
71 * c-basic-offset: 4
72 * End:
73 * vim600: noet sw=4 ts=4 fdm=marker
74 * vim<600: noet sw=4 ts=4
75 */
76