Merge branch 'master' into phpng
[m6w6/ext-http] / php_http_cookie.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-2014, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
11 */
12
13 #ifndef PHP_HTTP_COOKIE_H
14 #define PHP_HTTP_COOKIE_H
15
16 #define PHP_HTTP_COOKIE_SECURE 0x10L
17 #define PHP_HTTP_COOKIE_HTTPONLY 0x20L
18
19 #define PHP_HTTP_COOKIE_PARSE_RAW 0x01L
20
21 /*
22 generally a netscape cookie compliant struct, recognizing httpOnly attribute, too;
23 cookie params like those from rfc2109 and rfc2965 are just put into extras, if
24 one specifies them in allowed extras, else they're treated like cookies themself
25 */
26 typedef struct php_http_cookie_list {
27 HashTable cookies;
28 HashTable extras;
29 long flags;
30 char *path;
31 char *domain;
32 time_t expires;
33 time_t max_age;
34 } php_http_cookie_list_t;
35
36 PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_init(php_http_cookie_list_t *list);
37 PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_parse(php_http_cookie_list_t *list, const char *str, size_t len, long flags, char **allowed_extras);
38 PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_copy(php_http_cookie_list_t *from, php_http_cookie_list_t *to);
39 PHP_HTTP_API void php_http_cookie_list_dtor(php_http_cookie_list_t *list);
40 PHP_HTTP_API void php_http_cookie_list_free(php_http_cookie_list_t **list);
41
42 #define php_http_cookie_list_has_cookie(list, name, name_len) zend_symtable_str_exists(&(list)->cookies, (name), (name_len))
43 #define php_http_cookie_list_del_cookie(list, name, name_len) zend_symtable_str_del(&(list)->cookies, (name), (name_len))
44 PHP_HTTP_API void php_http_cookie_list_add_cookie(php_http_cookie_list_t *list, const char *name, size_t name_len, const char *value, size_t value_len);
45 PHP_HTTP_API const char *php_http_cookie_list_get_cookie(php_http_cookie_list_t *list, const char *name, size_t name_len, zval *cookie);
46
47 #define php_http_cookie_list_has_extra(list, name, name_len) zend_symtable_str_exists(&(list)->extras, (name), (name_len))
48 #define php_http_cookie_list_del_extra(list, name, name_len) zend_symtable_str_del(&(list)->extras, (name), (name_len))
49 PHP_HTTP_API void php_http_cookie_list_add_extra(php_http_cookie_list_t *list, const char *name, size_t name_len, const char *value, size_t value_len);
50 PHP_HTTP_API const char *php_http_cookie_list_get_extra(php_http_cookie_list_t *list, const char *name, size_t name_len, zval *extra);
51
52 PHP_HTTP_API void php_http_cookie_list_to_string(php_http_cookie_list_t *list, char **str, size_t *len);
53 PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_from_struct(php_http_cookie_list_t *list, zval *strct);
54 PHP_HTTP_API void php_http_cookie_list_to_struct(php_http_cookie_list_t *list, zval *strct);
55
56 PHP_HTTP_API zend_class_entry *php_http_cookie_class_entry;
57
58 typedef struct php_http_cookie_object {
59 php_http_cookie_list_t *list;
60 zend_object zo;
61 } php_http_cookie_object_t;
62
63 zend_object *php_http_cookie_object_new(zend_class_entry *ce);
64 php_http_cookie_object_t *php_http_cookie_object_new_ex(zend_class_entry *ce, php_http_cookie_list_t *list);
65 zend_object *php_http_cookie_object_clone(zval *this_ptr);
66 void php_http_cookie_object_free(zend_object *object TSRMLS_DC);
67
68 PHP_MINIT_FUNCTION(http_cookie);
69
70 #endif
71
72 /*
73 * Local variables:
74 * tab-width: 4
75 * c-basic-offset: 4
76 * End:
77 * vim600: noet sw=4 ts=4 fdm=marker
78 * vim<600: noet sw=4 ts=4
79 */