define off_t
[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
35 #ifdef ZTS
36 void ***ts;
37 #endif
38 } php_http_cookie_list_t;
39
40 PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_init(php_http_cookie_list_t *list TSRMLS_DC);
41 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 TSRMLS_DC);
42 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);
43 PHP_HTTP_API void php_http_cookie_list_dtor(php_http_cookie_list_t *list);
44 PHP_HTTP_API void php_http_cookie_list_free(php_http_cookie_list_t **list);
45
46 #define php_http_cookie_list_has_cookie(list, name, name_len) zend_symtable_exists(&(list)->cookies, (name), (name_len)+1)
47 #define php_http_cookie_list_del_cookie(list, name, name_len) zend_symtable_del(&(list)->cookies, (name), (name_len)+1)
48 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);
49 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);
50
51 #define php_http_cookie_list_has_extra(list, name, name_len) zend_symtable_exists(&(list)->extras, (name), (name_len)+1)
52 #define php_http_cookie_list_del_extra(list, name, name_len) zend_symtable_del(&(list)->extras, (name), (name_len)+1)
53 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);
54 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);
55
56 PHP_HTTP_API void php_http_cookie_list_to_string(php_http_cookie_list_t *list, char **str, size_t *len);
57 PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_from_struct(php_http_cookie_list_t *list, zval *strct TSRMLS_DC);
58 PHP_HTTP_API void php_http_cookie_list_to_struct(php_http_cookie_list_t *list, zval *strct);
59
60 PHP_HTTP_API zend_class_entry *php_http_cookie_class_entry;
61
62 typedef struct php_http_cookie_object {
63 zend_object zo;
64 zend_object_value zv;
65 php_http_cookie_list_t *list;
66 } php_http_cookie_object_t;
67
68 zend_object_value php_http_cookie_object_new(zend_class_entry *ce TSRMLS_DC);
69 zend_object_value php_http_cookie_object_new_ex(zend_class_entry *ce, php_http_cookie_list_t *list, php_http_cookie_object_t **obj TSRMLS_DC);
70 zend_object_value php_http_cookie_object_clone(zval *this_ptr TSRMLS_DC);
71 void php_http_cookie_object_free(void *object TSRMLS_DC);
72
73 PHP_MINIT_FUNCTION(http_cookie);
74
75 #endif
76
77 /*
78 * Local variables:
79 * tab-width: 4
80 * c-basic-offset: 4
81 * End:
82 * vim600: noet sw=4 ts=4 fdm=marker
83 * vim<600: noet sw=4 ts=4
84 */