if (!list) {
list = emalloc(sizeof(*list));
}
-
+
zend_hash_init(&list->cookies, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_init(&list->extras, 0, NULL, ZVAL_PTR_DTOR, 0);
-
+
list->path = NULL;
list->domain = NULL;
list->expires = -1;
list->max_age = -1;
list->flags = 0;
-
+
return list;
}
if (list) {
zend_hash_destroy(&list->cookies);
zend_hash_destroy(&list->extras);
-
+
PTR_SET(list->path, NULL);
PTR_SET(list->domain, NULL);
}
{
zval cookies, extras, tmp;
HashTable *ht = HASH_OF(strct);
-
+
array_init_size(&cookies, zend_hash_num_elements(&list->cookies));
array_copy(&list->cookies, Z_ARRVAL(cookies));
zend_symtable_str_update(ht, ZEND_STRL("cookies"), &cookies);
-
+
array_init_size(&extras, zend_hash_num_elements(&list->extras));
array_copy(&list->extras, Z_ARRVAL(extras));
zend_symtable_str_update(ht, ZEND_STRL("extras"), &extras);
-
+
ZVAL_LONG(&tmp, list->flags);
zend_symtable_str_update(ht, ZEND_STRL("flags"), &tmp);
ZVAL_LONG(&tmp, list->expires);
list->domain = estrndup(str->val, str->len);
zend_string_release(str);
}
-
+
return list;
}
static inline void append_encoded(php_http_buffer_t *buf, const char *key, size_t key_len, const char *val, size_t val_len)
{
zend_string *enc_str[2];
-
+
enc_str[0] = php_raw_url_encode(key, key_len);
enc_str[1] = php_raw_url_encode(val, val_len);
-
+
php_http_buffer_append(buf, enc_str[0]->val, enc_str[0]->len);
php_http_buffer_appends(buf, "=");
php_http_buffer_append(buf, enc_str[1]->val, enc_str[1]->len);
php_http_buffer_appends(buf, "; ");
-
+
zend_string_release(enc_str[0]);
zend_string_release(enc_str[1]);
}
php_http_buffer_t buf;
zend_hash_key key;
zval *val;
-
+
php_http_buffer_init(&buf);
ZEND_HASH_FOREACH_KEY_VAL(&list->cookies, key.h, key.key, val)
zend_string_release(str);
}
ZEND_HASH_FOREACH_END();
-
+
if (list->domain && *list->domain) {
php_http_buffer_appendf(&buf, "domain=%s; ", list->domain);
}
if (list->max_age >= 0) {
php_http_buffer_appendf(&buf, "max-age=%ld; ", list->max_age);
}
-
+
ZEND_HASH_FOREACH_KEY_VAL(&list->extras, key.h, key.key, val)
{
zend_string *str = zval_get_string(val);
zend_string_release(str);
}
ZEND_HASH_FOREACH_END();
-
+
if (list->flags & PHP_HTTP_COOKIE_SECURE) {
php_http_buffer_appends(&buf, "secure; ");
}
if (list->flags & PHP_HTTP_COOKIE_HTTPONLY) {
php_http_buffer_appends(&buf, "httpOnly; ");
}
-
+
php_http_buffer_fix(&buf);
*str = buf.data;
*len = buf.used;
HashTable *allowed_extras = NULL;
zend_error_handling zeh;
- php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|z!lH", &zcookie, &flags, &allowed_extras), invalid_arg, return);
+ php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|z!lH/", &zcookie, &flags, &allowed_extras), invalid_arg, return);
obj = PHP_HTTP_OBJ(NULL, getThis());
HashTable *cookies = NULL;
php_http_cookie_object_t *obj;
- php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|H", &cookies), invalid_arg, return);
+ php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|H/", &cookies), invalid_arg, return);
obj = PHP_HTTP_OBJ(NULL, getThis());
HashTable *cookies = NULL;
php_http_cookie_object_t *obj;
- php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "H", &cookies), invalid_arg, return);
+ php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "H/", &cookies), invalid_arg, return);
obj = PHP_HTTP_OBJ(NULL, getThis());
HashTable *extras = NULL;
php_http_cookie_object_t *obj;
- php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|H", &extras), invalid_arg, return);
+ php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|H/", &extras), invalid_arg, return);
obj = PHP_HTTP_OBJ(NULL, getThis());
HashTable *extras = NULL;
php_http_cookie_object_t *obj;
- php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "H", &extras), invalid_arg, return);
+ php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "H/", &extras), invalid_arg, return);
obj = PHP_HTTP_OBJ(NULL, getThis());
}
ZEND_BEGIN_ARG_INFO_EX(ai_HttpCookie_toString, 0, 0, 0)
-ZEND_END_ARG_INFO();;
+ZEND_END_ARG_INFO();
static PHP_METHOD(HttpCookie, toString)
{
php_http_cookie_object_t *obj;