- fix non-ZTS build, thanks Hannes
[m6w6/ext-http] / http_message_object.c
index f1768b6adc339e5e80945288047460e24f67795a..c5a219f49a303144e1c8f9b333d8a07271f6615b 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>            |
     +--------------------------------------------------------------------+
 */
 
@@ -150,7 +150,7 @@ static void _http_message_object_write_prop(zval *object, zval *member, zval *va
 #define http_message_object_get_props _http_message_object_get_props
 static HashTable *_http_message_object_get_props(zval *object TSRMLS_DC);
 
-#define OBJ_PROP_CE http_message_object_ce
+#define THIS_CE http_message_object_ce
 zend_class_entry *http_message_object_ce;
 zend_function_entry http_message_object_fe[] = {
        HTTP_MESSAGE_ME(__construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
@@ -228,20 +228,20 @@ PHP_MINIT_FUNCTION(http_message_object)
        http_message_object_handlers.get_properties = http_message_object_get_props;
        http_message_object_handlers.get_property_ptr_ptr = NULL;
        
-       DCL_PROP(PROTECTED, long, type, HTTP_MSG_NONE);
-       DCL_PROP(PROTECTED, string, body, "");
-       DCL_PROP(PROTECTED, string, requestMethod, "");
-       DCL_PROP(PROTECTED, string, requestUrl, "");
-       DCL_PROP(PROTECTED, string, responseStatus, "");
-       DCL_PROP(PROTECTED, long, responseCode, 0);
-       DCL_PROP_N(PROTECTED, httpVersion);
-       DCL_PROP_N(PROTECTED, headers);
-       DCL_PROP_N(PROTECTED, parentMessage);
+       zend_declare_property_long(THIS_CE, ZEND_STRS("type")-1, HTTP_MSG_NONE, ZEND_ACC_PROTECTED TSRMLS_CC);
+       zend_declare_property_string(THIS_CE, ZEND_STRS("body")-1, "", ZEND_ACC_PROTECTED TSRMLS_CC);
+       zend_declare_property_string(THIS_CE, ZEND_STRS("requestMethod")-1, "", ZEND_ACC_PROTECTED TSRMLS_CC);
+       zend_declare_property_string(THIS_CE, ZEND_STRS("requestUrl")-1, "", ZEND_ACC_PROTECTED TSRMLS_CC);
+       zend_declare_property_string(THIS_CE, ZEND_STRS("responseStatus")-1, "", ZEND_ACC_PROTECTED TSRMLS_CC);
+       zend_declare_property_long(THIS_CE, ZEND_STRS("responseCode")-1, 0, ZEND_ACC_PROTECTED TSRMLS_CC);
+       zend_declare_property_null(THIS_CE, ZEND_STRS("httpVersion")-1, ZEND_ACC_PROTECTED TSRMLS_CC);
+       zend_declare_property_null(THIS_CE, ZEND_STRS("headers")-1, ZEND_ACC_PROTECTED TSRMLS_CC);
+       zend_declare_property_null(THIS_CE, ZEND_STRS("parentMessage")-1, ZEND_ACC_PROTECTED TSRMLS_CC);
        
 #ifndef WONKY
-       DCL_CONST(long, "TYPE_NONE", HTTP_MSG_NONE);
-       DCL_CONST(long, "TYPE_REQUEST", HTTP_MSG_REQUEST);
-       DCL_CONST(long, "TYPE_RESPONSE", HTTP_MSG_RESPONSE);
+       zend_declare_class_constant_long(THIS_CE, ZEND_STRS("TYPE_NONE")-1, HTTP_MSG_NONE TSRMLS_CC);
+       zend_declare_class_constant_long(THIS_CE, ZEND_STRS("TYPE_REQUEST")-1, HTTP_MSG_REQUEST TSRMLS_CC);
+       zend_declare_class_constant_long(THIS_CE, ZEND_STRS("TYPE_RESPONSE")-1, HTTP_MSG_RESPONSE TSRMLS_CC);
 #endif
        
        HTTP_LONG_CONSTANT("HTTP_MSG_NONE", HTTP_MSG_NONE);
@@ -412,7 +412,7 @@ static zval *_http_message_object_read_prop(zval *object, zval *member, int type
        http_message *msg = obj->message;
        zval *return_value;
 #ifdef WONKY
-       ulong h = zend_get_hash_value(Z_STRVAL_P(member), Z_STRLEN_P(member)+1);
+       ulong h = zend_hash_func(Z_STRVAL_P(member), Z_STRLEN_P(member)+1);
 #else
        zend_property_info *pinfo = zend_get_property_info(obj->zo.ce, member, 1 TSRMLS_CC);
        
@@ -520,7 +520,7 @@ static void _http_message_object_write_prop(zval *object, zval *member, zval *va
        http_message *msg = obj->message;
        zval *cpy = NULL;
 #ifdef WONKY
-       ulong h = zend_get_hash_value(Z_STRVAL_P(member), Z_STRLEN_P(member) + 1);
+       ulong h = zend_hash_func(Z_STRVAL_P(member), Z_STRLEN_P(member) + 1);
 #else
        zend_property_info *pinfo = zend_get_property_info(obj->zo.ce, member, 1 TSRMLS_CC);
        
@@ -909,10 +909,10 @@ PHP_METHOD(HttpMessage, getInfo)
                
                switch (obj->message->type) {
                        case HTTP_MSG_REQUEST:
-                               Z_STRLEN_P(return_value) = spprintf(&Z_STRVAL_P(return_value), 0, "%s %s HTTP/%0.1f", obj->message->http.info.request.method, obj->message->http.info.request.url, obj->message->http.version);
+                               Z_STRLEN_P(return_value) = spprintf(&Z_STRVAL_P(return_value), 0, HTTP_INFO_REQUEST_FMT_ARGS(&obj->message->http, ""));
                                break;
                        case HTTP_MSG_RESPONSE:
-                               Z_STRLEN_P(return_value) = spprintf(&Z_STRVAL_P(return_value), 0, "HTTP/%0.1f %d %s", obj->message->http.version, obj->message->http.info.response.code, obj->message->http.info.response.status);
+                               Z_STRLEN_P(return_value) = spprintf(&Z_STRVAL_P(return_value), 0, HTTP_INFO_RESPONSE_FMT_ARGS(&obj->message->http, ""));
                                break;
                        default:
                                RETURN_NULL();