- release 1.5.0RC2
[m6w6/ext-http] / http_cookie_api.c
index aff04abfef4f3d46bed6c5c70091c8f3722652bb..9b7c9b80f77d2fbe7cd16240583388b17341bd96 100644 (file)
@@ -6,7 +6,7 @@
     | 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-2007, Michael Wallner <mike@php.net>            |
     +--------------------------------------------------------------------+
 */
 
@@ -221,8 +221,8 @@ PHP_HTTP_API void _http_cookie_list_tostruct(http_cookie_list *list, zval *strct
        
        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);
 }
 /* }}} */
 
@@ -284,7 +284,7 @@ PHP_HTTP_API http_cookie_list *_http_cookie_list_fromstruct(http_cookie_list *li
        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));
        }
        
@@ -316,17 +316,14 @@ PHP_HTTP_API void _http_cookie_list_tostring(http_cookie_list *list, char **str,
 {
        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) {
+                       append_encoded(&buf, key.str, key.len-1, Z_STRVAL_PP(val), Z_STRLEN_PP(val));
                }
        }
        
@@ -342,10 +339,9 @@ PHP_HTTP_API void _http_cookie_list_tostring(http_cookie_list *list, char **str,
                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) {
+                       append_encoded(&buf, key.str, key.len-1, Z_STRVAL_PP(val), Z_STRLEN_PP(val));
                }
        }