- ws
[m6w6/ext-http] / http_response_object.c
index 011944d71e7f0b5ae6a03a437cf79ba281356c2b..29f264a00d5ab4a6d638ce646cb5706dbb398ae2 100644 (file)
 #include "php_http_response_object.h"
 #include "php_http_send_api.h"
 
-#define GET_STATIC_PROP(n)                     *GET_STATIC_PROP_EX(http_response_object_ce, n)
-#define UPD_STATIC_PROP(t, n, v)       UPD_STATIC_PROP_EX(http_response_object_ce, t, n, v)
-#define SET_STATIC_PROP(n, v)          SET_STATIC_PROP_EX(http_response_object_ce, n, v)
-#define UPD_STATIC_STRL(n, v, l)       UPD_STATIC_STRL_EX(http_response_object_ce, n, v, l)
-
 #define HTTP_BEGIN_ARGS(method, req_args)              HTTP_BEGIN_ARGS_EX(HttpResponse, method, 0, req_args)
 #define HTTP_EMPTY_ARGS(method)                                        HTTP_EMPTY_ARGS_EX(HttpResponse, method, 0)
 #define HTTP_RESPONSE_ME(method, visibility)   PHP_ME(HttpResponse, method, HTTP_ARGS(HttpResponse, method), visibility|ZEND_ACC_STATIC)
@@ -136,11 +131,10 @@ HTTP_END_ARGS;
 HTTP_EMPTY_ARGS(getRequestHeaders);
 HTTP_EMPTY_ARGS(getRequestBody);
 
-#define http_response_object_declare_default_properties() _http_response_object_declare_default_properties(TSRMLS_C)
-static inline void _http_response_object_declare_default_properties(TSRMLS_D);
 #define http_grab_response_headers _http_grab_response_headers
 static void _http_grab_response_headers(void *data, void *arg TSRMLS_DC);
 
+#define OBJ_PROP_CE http_response_object_ce
 zend_class_entry *http_response_object_ce;
 zend_function_entry http_response_object_fe[] = {
 
@@ -199,14 +193,7 @@ zend_function_entry http_response_object_fe[] = {
 PHP_MINIT_FUNCTION(http_response_object)
 {
        HTTP_REGISTER_CLASS(HttpResponse, http_response_object, NULL, 0);
-       http_response_object_declare_default_properties();
-       return SUCCESS;
-}
-
-static inline void _http_response_object_declare_default_properties(TSRMLS_D)
-{
-       zend_class_entry *ce = http_response_object_ce;
-
+       
        DCL_STATIC_PROP(PRIVATE, bool, sent, 0);
        DCL_STATIC_PROP(PRIVATE, bool, catch, 0);
        DCL_STATIC_PROP(PRIVATE, long, mode, -1);
@@ -231,6 +218,8 @@ static inline void _http_response_object_declare_default_properties(TSRMLS_D)
        DCL_CONST(long, "REDIRECT_PROXY", HTTP_REDIRECT_PROXY);
        DCL_CONST(long, "REDIRECT_TEMP", HTTP_REDIRECT_TEMP);
 #endif /* WONKY */
+       
+       return SUCCESS;
 }
 
 static void _http_grab_response_headers(void *data, void *arg TSRMLS_DC)
@@ -567,15 +556,12 @@ PHP_METHOD(HttpResponse, getContentType)
  */
 PHP_METHOD(HttpResponse, guessContentType)
 {
+#ifdef HTTP_HAVE_MAGIC
        char *magic_file, *ct = NULL;
        int magic_file_len;
-       long magic_mode = 0;
+       long magic_mode = MAGIC_MIME;
        
        RETVAL_FALSE;
-       
-#ifdef HTTP_HAVE_MAGIC
-       magic_mode = MAGIC_MIME;
-       
        SET_EH_THROW_HTTP();
        if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &magic_file, &magic_file_len, &magic_mode)) {
                switch (Z_LVAL_P(GET_STATIC_PROP(mode))) {
@@ -608,6 +594,7 @@ PHP_METHOD(HttpResponse, guessContentType)
        SET_EH_NORMAL();
 #else
        http_error(HE_THROW, HTTP_E_RUNTIME, "Cannot guess Content-Type; libmagic not available");
+       RETURN_FALSE;
 #endif
 }
 /* }}} */