| modification, are permitted provided that the conditions mentioned |
| in the accompanying LICENSE file are met. |
+--------------------------------------------------------------------+
- | Copyright (c) 2004-2006, Michael Wallner <mike@php.net> |
+ | Copyright (c) 2004-2010, Michael Wallner <mike@php.net> |
+--------------------------------------------------------------------+
*/
PHP_HTTP_API const char *_http_cookie_list_get_cookie(http_cookie_list *list, const char *name, size_t name_len TSRMLS_DC)
{
zval **cookie = NULL;
- if ((SUCCESS != zend_hash_find(&list->cookies, (char *) name, name_len + 1, (void *) &cookie)) || (Z_TYPE_PP(cookie) != IS_STRING)) {
+ if ((SUCCESS != zend_hash_find(&list->cookies, HTTP_ZAPI_CONST_CAST(char *) name, name_len + 1, (void *) &cookie)) || (Z_TYPE_PP(cookie) != IS_STRING)) {
return NULL;
}
return Z_STRVAL_PP(cookie);
PHP_HTTP_API const char *_http_cookie_list_get_extra(http_cookie_list *list, const char *name, size_t name_len TSRMLS_DC)
{
zval **extra = NULL;
- if ((SUCCESS != zend_hash_find(&list->extras, (char *) name, name_len + 1, (void *) &extra)) || (Z_TYPE_PP(extra) != IS_STRING)) {
+ if ((SUCCESS != zend_hash_find(&list->extras, HTTP_ZAPI_CONST_CAST(char *) name, name_len + 1, (void *) &extra)) || (Z_TYPE_PP(extra) != IS_STRING)) {
return NULL;
}
return Z_STRVAL_PP(extra);
add_assoc_long(&array, "flags", list->flags);
add_assoc_long(&array, "expires", (long) list->expires);
- add_assoc_string(&array, "path", list->path?list->path:"", 1);
- add_assoc_string(&array, "domain", list->domain?list->domain:"", 1);
+ add_assoc_string(&array, "path", STR_PTR(list->path), 1);
+ add_assoc_string(&array, "domain", STR_PTR(list->domain), 1);
}
/* }}} */
list->flags = (long) Z_DVAL_PP(tmp);
break;
case IS_STRING:
- cpy = zval_copy(IS_LONG, *tmp);
+ cpy = http_zsep(IS_LONG, *tmp);
list->flags = Z_LVAL_P(cpy);
- zval_free(&cpy);
+ zval_ptr_dtor(&cpy);
break;
default:
break;
list->expires = (long) Z_DVAL_PP(tmp);
break;
case IS_STRING:
- cpy = zval_copy(IS_LONG, *tmp);
+ cpy = http_zsep(IS_LONG, *tmp);
if (Z_LVAL_P(cpy)) {
list->expires = Z_LVAL_P(cpy);
} else {
list->expires = expires;
}
}
- zval_free(&cpy);
+ zval_ptr_dtor(&cpy);
break;
default:
break;
if (SUCCESS == zend_hash_find(ht, "path", sizeof("path"), (void *) &tmp) && Z_TYPE_PP(tmp) == IS_STRING) {
list->path = estrndup(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
}
- if (SUCCESS == zend_hash_find(ht, "domain", sizeof("domain"), (void *) &tmp)) {
+ if (SUCCESS == zend_hash_find(ht, "domain", sizeof("domain"), (void *) &tmp) && Z_TYPE_PP(tmp) == IS_STRING) {
list->domain = estrndup(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
}
{
phpstr buf;
zval **val;
- ulong idx = 0;
- uint keylen = 0;
- char *key = NULL;
+ HashKey key = initHashKey(0);
HashPosition pos;
phpstr_init(&buf);
- FOREACH_HASH_KEYLENVAL(pos, &list->cookies, key, keylen, idx, val) {
- if (key && keylen) {
- append_encoded(&buf, key, keylen-1, Z_STRVAL_PP(val), Z_STRLEN_PP(val));
- key = NULL;
+ FOREACH_HASH_KEYVAL(pos, &list->cookies, key, val) {
+ if (key.type == HASH_KEY_IS_STRING && key.len) {
+ zval *tmp = http_zsep(IS_STRING, *val);
+ append_encoded(&buf, key.str, key.len-1, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
+ zval_ptr_dtor(&tmp);
}
}
efree(date);
}
- FOREACH_HASH_KEYLENVAL(pos, &list->extras, key, keylen, idx, val) {
- if (key && keylen) {
- append_encoded(&buf, key, keylen-1, Z_STRVAL_PP(val), Z_STRLEN_PP(val));
- key = NULL;
+ FOREACH_HASH_KEYVAL(pos, &list->extras, key, val) {
+ if (key.type == HASH_KEY_IS_STRING && key.len) {
+ zval *tmp = http_zsep(IS_STRING, *val);
+ append_encoded(&buf, key.str, key.len-1, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
}
}