- allow to avoid deps on shared extensions on build time
[m6w6/ext-http] / php_http_cookie_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-2006, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
11 */
12
13 /* $Id$ */
14
15 #ifndef PHP_HTTP_COOKIE_API_H
16 #define PHP_HTTP_COOKIE_API_H
17
18 #define HTTP_COOKIE_SECURE 0x10L
19 #define HTTP_COOKIE_HTTPONLY 0x20L
20
21 #define HTTP_COOKIE_PARSE_RAW 0x01L
22
23 extern PHP_MINIT_FUNCTION(http_cookie);
24
25 /*
26 generally a netscape cookie compliant struct, recognizing httpOnly attribute, too;
27 cookie params like those from rfc2109 and rfc2965 are just put into extras, if
28 one specifies them in allowed extras, else they're treated like cookies themself
29 */
30 typedef struct _http_cookie_list_t {
31 HashTable cookies;
32 HashTable extras;
33 long flags;
34 char *path;
35 char *domain;
36 time_t expires;
37 } http_cookie_list;
38
39 #define http_cookie_list_new() _http_cookie_list_init(NULL ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC TSRMLS_CC)
40 #define http_cookie_list_init(l) _http_cookie_list_init((l) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC TSRMLS_CC)
41 PHP_HTTP_API http_cookie_list *_http_cookie_list_init(http_cookie_list *list ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC);
42
43 #define http_cookie_list_dtor(l) _http_cookie_list_dtor((l) TSRMLS_CC)
44 PHP_HTTP_API void _http_cookie_list_dtor(http_cookie_list *list TSRMLS_DC);
45
46 #define http_cookie_list_free(l) _http_cookie_list_free((l) TSRMLS_CC)
47 PHP_HTTP_API void _http_cookie_list_free(http_cookie_list **list TSRMLS_DC);
48
49 #define http_cookie_list_has_cookie(list, name, name_len) zend_hash_exists(&(list)->cookies, (name), (name_len)+1)
50 #define http_cookie_list_has_extra(list, name, name_len) zend_hash_exists(&(list)->extras, (name), (name_len)+1)
51
52 #define http_cookie_list_add_cookie(l, n, nl, v, vl) _http_cookie_list_add_cookie((l), (n), (nl), (v), (vl) TSRMLS_CC)
53 PHP_HTTP_API void _http_cookie_list_add_cookie(http_cookie_list *list, const char *name, size_t name_len, const char *value, size_t value_len TSRMLS_DC);
54
55 #define http_cookie_list_add_extra(l, n , nl, v, vl) _http_cookie_list_add_extra((l), (n), (nl), (v), (vl) TSRMLS_CC)
56 PHP_HTTP_API void _http_cookie_list_add_extra(http_cookie_list *list, const char *name, size_t name_len, const char *value, size_t value_len TSRMLS_DC);
57
58 #define http_cookie_list_get_cookie(l, n, nl) _http_cookie_list_get_cookie((l), (n), (nl) TSRMLS_CC)
59 PHP_HTTP_API const char *_http_cookie_list_get_cookie(http_cookie_list *list, const char *name, size_t name_len TSRMLS_DC);
60
61 #define http_cookie_list_get_extra(l, n, nl) _http_cookie_list_get_extra((l), (n), (nl) TSRMLS_CC)
62 PHP_HTTP_API const char *_http_cookie_list_get_extra(http_cookie_list *list, const char *name, size_t name_len TSRMLS_DC);
63
64 #define http_parse_cookie(s) _http_parse_cookie_ex(NULL, (s), 0, NULL TSRMLS_CC)
65 #define http_parse_cookie_ex(l, s, f, a) _http_parse_cookie_ex((l), (s), (f), (a) TSRMLS_CC)
66 PHP_HTTP_API http_cookie_list *_http_parse_cookie_ex(http_cookie_list * list, const char *string, long flags, char **allowed_extras TSRMLS_DC);
67
68 #define http_cookie_list_tostruct(l, s) _http_cookie_list_tostruct((l), (s) TSRMLS_CC)
69 PHP_HTTP_API void _http_cookie_list_tostruct(http_cookie_list *list, zval *strct TSRMLS_DC);
70
71 #endif
72
73 /*
74 * Local variables:
75 * tab-width: 4
76 * c-basic-offset: 4
77 * End:
78 * vim600: noet sw=4 ts=4 fdm=marker
79 * vim<600: noet sw=4 ts=4
80 */