ZEND_EXTERN_MODULE_GLOBALS(http);
-#define GET_STATIC_PROP(n) *GET_STATIC_PROP_EX(http_response_object_ce, n)
+#define USE_STATIC_PROP() USE_STATIC_PROP_EX(http_response_object_ce)
+#define GET_STATIC_PROP(n) *GET_STATIC_PROP_EX(http_response_object_ce, n)
+#define SET_STATIC_PROP(n, v) SET_STATIC_PROP_EX(http_response_object_ce, n, v)
+#define SET_STATIC_PROP_STRING(n, s, d) SET_STATIC_PROP_STRING_EX(http_response_object_ce, n, s, d)
+#define SET_STATIC_PROP_STRINGL(n, s, l, d) SET_STATIC_PROP_STRINGL_EX(http_response_object_ce, n, s, l, d)
#define HTTP_BEGIN_ARGS(method, req_args) HTTP_BEGIN_ARGS_EX(HttpResponse, method, 0, req_args)
#define HTTP_EMPTY_ARGS(method, ret_ref) HTTP_EMPTY_ARGS_EX(HttpResponse, method, ret_ref)
DCL_STATIC_PROP(PROTECTED, bool, cache, 0);
DCL_STATIC_PROP(PROTECTED, bool, gzip, 0);
DCL_STATIC_PROP(PROTECTED, long, stream, 0);
- DCL_STATIC_PROP(PROTECTED, string, file, "");
- DCL_STATIC_PROP(PROTECTED, string, data, "");
- DCL_STATIC_PROP(PROTECTED, string, eTag, "");
+ DCL_STATIC_PROP_N(PROTECTED, file);
+ DCL_STATIC_PROP_N(PROTECTED, data);
+ DCL_STATIC_PROP_N(PROTECTED, eTag);
DCL_STATIC_PROP(PROTECTED, long, lastModified, 0);
- DCL_STATIC_PROP(PROTECTED, string, cacheControl, HTTP_DEFAULT_CACHECONTROL);
- DCL_STATIC_PROP(PROTECTED, string, contentType, INI_STR("default_content_type"));
- DCL_STATIC_PROP(PROTECTED, string, contentDisposition, "");
+ DCL_STATIC_PROP_N(PROTECTED, cacheControl);
+ DCL_STATIC_PROP_N(PROTECTED, contentType);
+ DCL_STATIC_PROP_N(PROTECTED, contentDisposition);
DCL_STATIC_PROP(PROTECTED, long, bufferSize, HTTP_SENDBUF_SIZE);
DCL_STATIC_PROP(PROTECTED, double, throttleDelay, 0.0);
}
RETURN_FALSE;
}
- ZVAL_LONG(GET_STATIC_PROP(cache), do_cache);
+ ZVAL_BOOL(GET_STATIC_PROP(cache), do_cache);
RETURN_TRUE;
}
/* }}} */
RETURN_FALSE;
}
- ZVAL_LONG(GET_STATIC_PROP(gzip), do_gzip);
+ ZVAL_BOOL(GET_STATIC_PROP(gzip), do_gzip);
RETURN_TRUE;
}
/* }}} */
http_error_ex(E_WARNING, HTTP_E_PARAM, "Cache-Control '%s' doesn't match public, private or no-cache", ccontrol);
RETURN_FALSE;
} else {
+ USE_STATIC_PROP();
spprintf(&cctl, 0, HTTP_CACHECONTROL_TEMPLATE, ccontrol, max_age);
- ZVAL_STRING_FREE(GET_STATIC_PROP(cacheControl), cctl, 0);
+ SET_STATIC_PROP_STRING(cacheControl, cctl, 0);
RETURN_TRUE;
}
}
RETURN_FALSE;
}
- ZVAL_STRINGL_FREE(GET_STATIC_PROP(contentType), ctype, ctype_len, 1);
+ USE_STATIC_PROP();
+ SET_STATIC_PROP_STRINGL(contentType, ctype, ctype_len, 1);
RETURN_TRUE;
}
/* }}} */
*/
PHP_METHOD(HttpResponse, setData)
{
- zval *the_data, *data;
+ zval *the_data, **data;
- if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/", &the_data)) {
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &the_data)) {
RETURN_FALSE;
}
-
convert_to_string_ex(&the_data);
- data = GET_STATIC_PROP(data);
- ZVAL_STRINGL_FREE(data, Z_STRVAL_P(the_data), Z_STRLEN_P(the_data), 1);
+
+ USE_STATIC_PROP();
+ SET_STATIC_PROP(data, the_data);
ZVAL_LONG(GET_STATIC_PROP(lastModified), http_last_modified(the_data, SEND_DATA));
ZVAL_LONG(GET_STATIC_PROP(mode), SEND_DATA);
RETURN_TRUE;
RETURN_FALSE;
}
+ USE_STATIC_PROP();
php_stream_from_zval(the_real_stream, &the_stream);
ZVAL_LONG(GET_STATIC_PROP(stream), Z_LVAL_P(the_stream));
ZVAL_LONG(GET_STATIC_PROP(lastModified), http_last_modified(the_real_stream, SEND_RSRC));
{
zval *the_file;
- if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/", &the_file)) {
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &the_file)) {
RETURN_FALSE;
}
convert_to_string_ex(&the_file);
- ZVAL_STRINGL_FREE(GET_STATIC_PROP(file), Z_STRVAL_P(the_file), Z_STRLEN_P(the_file), 1);
+ USE_STATIC_PROP();
+ SET_STATIC_PROP(file, the_file);
ZVAL_LONG(GET_STATIC_PROP(lastModified), http_last_modified(the_file, -1));
ZVAL_LONG(GET_STATIC_PROP(mode), -1);
#define ZVAL_STRING_FREE(z, s, d) \
{\
zval *__tmp = (z); \
- zval_dtor(__tmp); \
+ /*zval_ptr_dtor(&__tmp);*/ \
ZVAL_STRING(__tmp, (s), (d)); \
}
#define ZVAL_STRINGL_FREE(z, s, l, d) \
{\
zval *__tmp = (z); \
- zval_dtor(__tmp); \
+ /*zval_ptr_dtor(&__tmp);*/ \
ZVAL_STRINGL(__tmp, (s), (l), (d)); \
}
# define DCL_STATIC_PROP_Z(a, n, v) zend_declare_property(ce, (#n), sizeof(#n), (v), (ZEND_ACC_ ##a | ZEND_ACC_STATIC) TSRMLS_CC)
# define DCL_STATIC_PROP_N(a, n) zend_declare_property_null(ce, (#n), sizeof(#n), (ZEND_ACC_ ##a | ZEND_ACC_STATIC) TSRMLS_CC)
# define GET_STATIC_PROP_EX(ce, n) zend_std_get_static_property(ce, (#n), sizeof(#n), 0 TSRMLS_CC)
+# define USE_STATIC_PROP_EX(ce) zend_update_class_constants(ce TSRMLS_CC)
+# define SET_STATIC_PROP_EX(ce, n, v) \
+ { \
+ int refcount; \
+ zend_uchar is_ref; \
+ zval **__static = GET_STATIC_PROP_EX(ce, n); \
+ \
+ refcount = (*__static)->refcount; \
+ is_ref = (*__static)->is_ref; \
+ zval_dtor(*__static); \
+ **__static = *(v); \
+ zval_copy_ctor(*__static); \
+ (*__static)->refcount = refcount; \
+ (*__static)->is_ref = is_ref; \
+ }
+#define SET_STATIC_PROP_STRING_EX(ce, n, s, d) \
+ { \
+ zval *__tmp; \
+ MAKE_STD_ZVAL(__tmp); \
+ ZVAL_STRING(__tmp, (s), (d)); \
+ SET_STATIC_PROP_EX(ce, n, __tmp); \
+ efree(__tmp); \
+ }
+#define SET_STATIC_PROP_STRINGL_EX(ce, n, s, l, d) \
+ { \
+ zval *__tmp; \
+ MAKE_STD_ZVAL(__tmp); \
+ ZVAL_STRINGL(__tmp, (s), (l), (d)); \
+ SET_STATIC_PROP_EX(ce, n, __tmp); \
+ efree(__tmp); \
+ }
# define DCL_PROP(a, t, n, v) zend_declare_property_ ##t(ce, (#n), sizeof(#n), (v), (ZEND_ACC_ ##a) TSRMLS_CC)
# define DCL_PROP_Z(a, n, v) zend_declare_property(ce, (#n), sizeof(#n), (v), (ZEND_ACC_ ##a) TSRMLS_CC)
# define DCL_PROP_N(a, n) zend_declare_property_null(ce, (#n), sizeof(#n), (ZEND_ACC_ ##a) TSRMLS_CC)