- initialize local zvals used as HashTable containers
authorMichael Wallner <mike@php.net>
Mon, 19 Sep 2005 15:07:59 +0000 (15:07 +0000)
committerMichael Wallner <mike@php.net>
Mon, 19 Sep 2005 15:07:59 +0000 (15:07 +0000)
- added another function missing in WONKY (zend_update_property_stringl)
- added PHP4 compile fix (RETVAL_ZVAL)
- ditch warnings

12 files changed:
http_api.c
http_headers_api.c
http_info_api.c
http_message_api.c
http_message_object.c
http_request_api.c
http_request_method_api.c
http_request_object.c
http_response_object.c
missing.c
missing.h
php_http_std_defs.h

index f59a7d0a75cf2d7fd7561b624d2068ff9406d840..abc2c9beeb155a925b1b4e8dcf52568bc8ba0d86 100644 (file)
@@ -85,7 +85,7 @@ STATUS _http_parse_key_list(const char *list, HashTable *items, char separator,
        int vallen = 0, keylen = 0, done = 0;
        zval array;
 
        int vallen = 0, keylen = 0, done = 0;
        zval array;
 
-       Z_ARRVAL(array) = items;
+       INIT_ZARR(array, items);
 
        if (!(val = strchr(list, '='))) {
                return FAILURE;
 
        if (!(val = strchr(list, '='))) {
                return FAILURE;
index e320f46b8ca2864e108c70d425464361ef86a7da..4f255fe206a2aa656b0190d6f5b23ba06dbd6331 100644 (file)
@@ -331,7 +331,10 @@ PHP_HTTP_API STATUS _http_parse_headers_ex(const char *header, HashTable *header
        size_t header_len;
        zval array;
 
        size_t header_len;
        zval array;
 
+       INIT_PZVAL(&array);
+       Z_TYPE_P(array) = IS_ARRAY;
        Z_ARRVAL(array) = headers;
        Z_ARRVAL(array) = headers;
+       
        if (body) {
                header_len = body - header;
        } else {
        if (body) {
                header_len = body - header;
        } else {
@@ -341,7 +344,7 @@ PHP_HTTP_API STATUS _http_parse_headers_ex(const char *header, HashTable *header
 
        while (header_len >= (size_t) (line - begin)) {
                int value_len = 0;
 
        while (header_len >= (size_t) (line - begin)) {
                int value_len = 0;
-
+               /* note: valgrind may choke on that -- should be safe though */
                switch (*line++)
                {
                        case ':':
                switch (*line++)
                {
                        case ':':
index a6b12139e3d56126dc1e15e9c62fb2c11b2af7d3..0e9b6487e941a69a25c5a95ac23f52665b5c1138 100644 (file)
@@ -32,7 +32,8 @@ ZEND_EXTERN_MODULE_GLOBALS(http);
 PHP_HTTP_API void _http_info_default_callback(void **nothing, HashTable **headers, http_info *info TSRMLS_DC)
 {
        zval array;
 PHP_HTTP_API void _http_info_default_callback(void **nothing, HashTable **headers, http_info *info TSRMLS_DC)
 {
        zval array;
-       Z_ARRVAL(array) = *headers;
+       
+       INIT_ZARR(array, *headers);
        
        switch (info->type)
        {
        
        switch (info->type)
        {
index 15fa449eb21eef2e2453152da7cacf163d58c68b..36b3098737ce0e672137d881b8214bc74d1bd115 100644 (file)
@@ -312,8 +312,7 @@ PHP_HTTP_API void _http_message_tostruct_recursive(http_message *msg, zval *obj
        zval strct;
        zval *headers;
        
        zval strct;
        zval *headers;
        
-       Z_TYPE(strct) = IS_ARRAY;
-       Z_ARRVAL(strct) = HASH_OF(obj);
+       INIT_ZARR(strct, HASH_OF(obj));
        
        add_assoc_long(&strct, "type", msg->type);
        add_assoc_double(&strct, "httpVersion", msg->http.version);
        
        add_assoc_long(&strct, "type", msg->type);
        add_assoc_double(&strct, "httpVersion", msg->http.version);
@@ -394,6 +393,8 @@ PHP_HTTP_API STATUS _http_message_send(http_message *message TSRMLS_DC)
                        char *uri = NULL;
                        zval **zhost, options, headers;
 
                        char *uri = NULL;
                        zval **zhost, options, headers;
 
+                       INIT_PZVAL(&options);
+                       INIT_PZVAL(&headers);
                        array_init(&options);
                        array_init(&headers);
                        zend_hash_copy(Z_ARRVAL(headers), &message->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
                        array_init(&options);
                        array_init(&headers);
                        zend_hash_copy(Z_ARRVAL(headers), &message->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
index b187f559c02f199d4bff19c1b970de10415575c4..cd64d31a4f0bd87f788b5087736f56a6f559ef10 100644 (file)
@@ -409,7 +409,7 @@ static HashTable *_http_message_object_get_props(zval *object TSRMLS_DC)
                zval array; \
                char *m_prop_name; \
                int m_prop_len; \
                zval array; \
                char *m_prop_name; \
                int m_prop_len; \
-               Z_ARRVAL(array) = OBJ_PROP(obj); \
+               INIT_ZARR(array, OBJ_PROP(obj)); \
                zend_mangle_property_name(&m_prop_name, &m_prop_len, "*", 1, name, lenof(name), 1); \
                add_assoc_ ##ptype## _ex(&array, m_prop_name, sizeof(name)+4, val); \
        }
                zend_mangle_property_name(&m_prop_name, &m_prop_len, "*", 1, name, lenof(name), 1); \
                add_assoc_ ##ptype## _ex(&array, m_prop_name, sizeof(name)+4, val); \
        }
@@ -419,7 +419,7 @@ static HashTable *_http_message_object_get_props(zval *object TSRMLS_DC)
                zval array; \
                char *m_prop_name; \
                int m_prop_len; \
                zval array; \
                char *m_prop_name; \
                int m_prop_len; \
-               Z_ARRVAL(array) = OBJ_PROP(obj); \
+               INIT_ZARR(array, OBJ_PROP(obj)); \
                zend_mangle_property_name(&m_prop_name, &m_prop_len, "*", 1, name, lenof(name), 1); \
                add_assoc_stringl_ex(&array, m_prop_name, sizeof(name)+4, val, len, 1); \
        }
                zend_mangle_property_name(&m_prop_name, &m_prop_len, "*", 1, name, lenof(name), 1); \
                add_assoc_stringl_ex(&array, m_prop_name, sizeof(name)+4, val, len, 1); \
        }
@@ -557,7 +557,7 @@ PHP_METHOD(HttpMessage, getHeaders)
                zval headers;
                getObject(http_message_object, obj);
 
                zval headers;
                getObject(http_message_object, obj);
 
-               Z_ARRVAL(headers) = &obj->message->hdrs;
+               INIT_ZARR(headers, &obj->message->hdrs);
                array_init(return_value);
                array_copy(&headers, return_value);
        }
                array_init(return_value);
                array_copy(&headers, return_value);
        }
@@ -578,7 +578,7 @@ PHP_METHOD(HttpMessage, setHeaders)
        }
 
        zend_hash_clean(&obj->message->hdrs);
        }
 
        zend_hash_clean(&obj->message->hdrs);
-       Z_ARRVAL(old_headers) = &obj->message->hdrs;
+       INIT_ZARR(old_headers, &obj->message->hdrs);
        array_copy(new_headers, &old_headers);
 }
 /* }}} */
        array_copy(new_headers, &old_headers);
 }
 /* }}} */
@@ -597,7 +597,7 @@ PHP_METHOD(HttpMessage, addHeaders)
                return;
        }
 
                return;
        }
 
-       Z_ARRVAL(old_headers) = &obj->message->hdrs;
+       INIT_ZARR(old_headers, &obj->message->hdrs);
        if (append) {
                array_append(new_headers, &old_headers);
        } else {
        if (append) {
                array_append(new_headers, &old_headers);
        } else {
index eb2906bc846073e7e68921b41564485792ffe5db..8b195f80a644647d6e3f0048f0a538208628a385 100644 (file)
@@ -685,7 +685,7 @@ PHP_HTTP_API STATUS _http_request_exec(CURL *ch, HashTable *info, phpstr *respon
 PHP_HTTP_API void _http_request_info(CURL *ch, HashTable *info TSRMLS_DC)
 {
        zval array;
 PHP_HTTP_API void _http_request_info(CURL *ch, HashTable *info TSRMLS_DC)
 {
        zval array;
-       Z_ARRVAL(array) = info;
+       INIT_ZARR(array, info);
 
        HTTP_CURL_INFO(EFFECTIVE_URL);
 #if LIBCURL_VERSION_NUM >= 0x070a07
 
        HTTP_CURL_INFO(EFFECTIVE_URL);
 #if LIBCURL_VERSION_NUM >= 0x070a07
index 57636d088b2b065e7e050bc3015a6859803ea2cf..28365f73edc080d473b32b78694dd861ab97692e 100644 (file)
@@ -167,7 +167,7 @@ PHP_HTTP_API unsigned long _http_request_method_register(const char *method_name
        }
        method[method_len] = '\0';
        
        }
        method[method_len] = '\0';
        
-       Z_ARRVAL(array) = &HTTP_G(request).methods.custom;
+       INIT_ZARR(array, &HTTP_G(request).methods.custom);
        add_next_index_stringl(&array, method, method_len, 0);
 
        method_len = spprintf(&http_method, 0, "HTTP_METH_%s", method);
        add_next_index_stringl(&array, method, method_len, 0);
 
        method_len = spprintf(&http_method, 0, "HTTP_METH_%s", method);
index 0a6c5d1a4ea47df32b7f84a8708e2199ab6bcaae..f1f2551d0328e4094651256ee1ce3b79b60a587f 100644 (file)
@@ -344,6 +344,7 @@ static inline void _http_request_object_declare_default_properties(TSRMLS_D)
 
        DCL_PROP(PUBLIC, bool, recordHistory, 1);
 
 
        DCL_PROP(PUBLIC, bool, recordHistory, 1);
 
+#ifndef WONKY
        /*
         * Request Method Constants
         */
        /*
         * Request Method Constants
         */
@@ -388,6 +389,7 @@ static inline void _http_request_object_declare_default_properties(TSRMLS_D)
        DCL_CONST(long, "AUTH_NTLM", CURLAUTH_NTLM);
        DCL_CONST(long, "AUTH_ANY", CURLAUTH_ANY);
 #      endif /* LIBCURL_VERSION_NUM */
        DCL_CONST(long, "AUTH_NTLM", CURLAUTH_NTLM);
        DCL_CONST(long, "AUTH_ANY", CURLAUTH_ANY);
 #      endif /* LIBCURL_VERSION_NUM */
+#endif /* WONKY */
 }
 
 void _http_request_object_free(zend_object *object TSRMLS_DC)
 }
 
 void _http_request_object_free(zend_object *object TSRMLS_DC)
index 7de10dce104bd3e245a5ee0026fa59e969881ca7..ba1ae4073ef9991f805aacd681735f8d12fadbbc 100644 (file)
@@ -237,10 +237,11 @@ static inline void _http_response_object_declare_default_properties(TSRMLS_D)
        DCL_STATIC_PROP(PROTECTED, long, bufferSize, HTTP_SENDBUF_SIZE);
        DCL_STATIC_PROP(PROTECTED, double, throttleDelay, 0.0);
 
        DCL_STATIC_PROP(PROTECTED, long, bufferSize, HTTP_SENDBUF_SIZE);
        DCL_STATIC_PROP(PROTECTED, double, throttleDelay, 0.0);
 
+#ifndef WONKY
        DCL_CONST(long, "ETAG_MD5", HTTP_ETAG_MD5);
        DCL_CONST(long, "ETAG_SHA1", HTTP_ETAG_SHA1);
        
        DCL_CONST(long, "ETAG_MD5", HTTP_ETAG_MD5);
        DCL_CONST(long, "ETAG_SHA1", HTTP_ETAG_SHA1);
        
-#ifdef HTTP_HAVE_MHASH
+#      ifdef HTTP_HAVE_MHASH
        {
                int l, i, c = mhash_count();
                
        {
                int l, i, c = mhash_count();
                
@@ -254,7 +255,8 @@ static inline void _http_response_object_declare_default_properties(TSRMLS_D)
                        }
                }
        }
                        }
                }
        }
-#endif
+#      endif /* HTTP_HAVE_MHASH */
+#endif /* WONKY */
 }
 
 static void _http_grab_response_headers(void *data, void *arg TSRMLS_DC)
 }
 
 static void _http_grab_response_headers(void *data, void *arg TSRMLS_DC)
@@ -880,7 +882,7 @@ PHP_METHOD(HttpResponse, getFile)
  */
 PHP_METHOD(HttpResponse, send)
 {
  */
 PHP_METHOD(HttpResponse, send)
 {
-       zval *sent, *headers;
+       zval *sent;
        zend_bool clean_ob = 1;
 
        if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &clean_ob)) {
        zend_bool clean_ob = 1;
 
        if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &clean_ob)) {
index 7febedf19d579b9892b633da254ef4165e5a6a2c..9d9b9412cf8ad31bd54251e10c9b969bb324b454 100644 (file)
--- a/missing.c
+++ b/missing.c
@@ -47,6 +47,18 @@ void zend_update_property_bool(zend_class_entry *scope, zval *object, char *name
        ZVAL_BOOL(tmp, value);
        zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);
 }
        ZVAL_BOOL(tmp, value);
        zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);
 }
+
+void zend_update_property_stringl(zend_class_entry *scope, zval *object, char *name, int name_length, char *value, int value_len TSRMLS_DC)
+{
+       zval *tmp;
+       
+       ALLOC_ZVAL(tmp);
+       tmp->is_ref = 0;
+       tmp->refcount = 0;
+       ZVAL_STRINGL(tmp, value, value_len, 1);
+       zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);
+}
+
 #endif
 
 /*
 #endif
 
 /*
index d1f53e5c485c4cb434a094fd3eb8c0a6c8dc8dfa..e76b078b3ccde9777056ea555910026b6209d23d 100644 (file)
--- a/missing.h
+++ b/missing.h
@@ -30,6 +30,8 @@ extern void zend_update_property_double(zend_class_entry *scope, zval *object, c
 
 extern int zend_declare_property_bool(zend_class_entry *ce, char *name, int name_length, long value, int access_type TSRMLS_DC);
 extern void zend_update_property_bool(zend_class_entry *scope, zval *object, char *name, int name_length, long value TSRMLS_DC);
 
 extern int zend_declare_property_bool(zend_class_entry *ce, char *name, int name_length, long value, int access_type TSRMLS_DC);
 extern void zend_update_property_bool(zend_class_entry *scope, zval *object, char *name, int name_length, long value TSRMLS_DC);
+
+extern void zend_update_property_stringl(zend_class_entry *scope, zval *object, char *name, int name_length, char *value, int value_len TSRMLS_DC);
 #endif
 
 #endif
 #endif
 
 #endif
index c212d30d1b85f8efc1136e2e93994d5181d9092d..ce42260c357a0eae495dea035be0739fb08e113f 100644 (file)
@@ -52,6 +52,13 @@ typedef int STATUS;
        }
 #endif
 
        }
 #endif
 
+#define INIT_ZARR(zv, ht) \
+       { \
+               INIT_PZVAL(&(zv)); \
+               Z_TYPE(zv) = IS_ARRAY; \
+               Z_ARRVAL(zv) = (ht); \
+       }
+
 /* return bool (v == SUCCESS) */
 #define RETVAL_SUCCESS(v) RETVAL_BOOL(SUCCESS == (v))
 #define RETURN_SUCCESS(v) RETURN_BOOL(SUCCESS == (v))
 /* return bool (v == SUCCESS) */
 #define RETVAL_SUCCESS(v) RETVAL_BOOL(SUCCESS == (v))
 #define RETURN_SUCCESS(v) RETURN_BOOL(SUCCESS == (v))
@@ -366,6 +373,31 @@ typedef int STATUS;
 #      endif
 #endif
 
 #      endif
 #endif
 
+#ifndef ZVAL_ZVAL
+#define ZVAL_ZVAL(z, zv, copy, dtor) {  \
+               int is_ref, refcount;           \
+               is_ref = (z)->is_ref;           \
+               refcount = (z)->refcount;       \
+               *(z) = *(zv);                   \
+               if (copy) {                     \
+                       zval_copy_ctor(z);          \
+           }                               \
+               if (dtor) {                     \
+                       if (!copy) {                \
+                               ZVAL_NULL(zv);          \
+                       }                           \
+                       zval_ptr_dtor(&zv);         \
+           }                               \
+               (z)->is_ref = is_ref;           \
+               (z)->refcount = refcount;       \
+       }
+#endif
+#ifndef RETVAL_ZVAL
+#define RETVAL_ZVAL(zv, copy, dtor)            ZVAL_ZVAL(return_value, zv, copy, dtor)
+#endif
+#ifndef RETURN_ZVAL
+#define RETURN_ZVAL(zv, copy, dtor)            { RETVAL_ZVAL(zv, copy, dtor); return; }
+#endif
 
 
 #endif /* PHP_HTTP_STD_DEFS_H */
 
 
 #endif /* PHP_HTTP_STD_DEFS_H */