#include "phpstr/phpstr.h"
+ZEND_EXTERN_MODULE_GLOBALS(http);
+
#define HTTP_BEGIN_ARGS(method, ret_ref, req_args) HTTP_BEGIN_ARGS_EX(HttpMessage, method, ret_ref, req_args)
#define HTTP_EMPTY_ARGS(method, ret_ref) HTTP_EMPTY_ARGS_EX(HttpMessage, method, ret_ref)
#define HTTP_MESSAGE_ME(method, visibility) PHP_ME(HttpMessage, method, HTTP_ARGS(HttpMessage, method), visibility)
ALLOC_HASHTABLE(OBJ_PROP(o));
zend_hash_init(OBJ_PROP(o), 0, NULL, ZVAL_PTR_DTOR, 0);
- ov.handle = zend_objects_store_put(o, (zend_objects_store_dtor_t) zend_objects_destroy_object, http_message_object_free, NULL TSRMLS_CC);
+ ov.handle = putObject(http_message_object, o);
ov.handlers = &http_message_object_handlers;
return ov;
fprintf(stderr, "Read HttpMessage::$%s\n", Z_STRVAL_P(member));
#endif
if (!EG(scope) || !instanceof_function(EG(scope), obj->zo.ce TSRMLS_CC)) {
- zend_error(E_WARNING, "Cannot access protected property %s::$%s", obj->zo.ce->name, Z_STRVAL_P(member));
+ zend_error(HE_WARNING, "Cannot access protected property %s::$%s", obj->zo.ce->name, Z_STRVAL_P(member));
return EG(uninitialized_zval_ptr);
}
fprintf(stderr, "Write HttpMessage::$%s\n", Z_STRVAL_P(member));
#endif
if (!EG(scope) || !instanceof_function(EG(scope), obj->zo.ce TSRMLS_CC)) {
- zend_error(E_WARNING, "Cannot access protected property %s::$%s", obj->zo.ce->name, Z_STRVAL_P(member));
+ zend_error(HE_WARNING, "Cannot access protected property %s::$%s", obj->zo.ce->name, Z_STRVAL_P(member));
}
switch (zend_get_hash_value(Z_STRVAL_P(member), Z_STRLEN_P(member) + 1))
{
case HTTP_MSG_PROPHASH_TYPE:
convert_to_long_ex(&value);
- if (Z_LVAL_P(value) != msg->type) {
+ if ((http_message_type) Z_LVAL_P(value) != msg->type) {
if (HTTP_MSG_TYPE(REQUEST, msg)) {
if (msg->info.request.method) {
efree(msg->info.request.method);
getObject(http_message_object, obj);
if (!HTTP_MSG_TYPE(RESPONSE, obj->message)) {
- http_error(E_NOTICE, HTTP_E_MSG, "HttpMessage is not of type HTTP_MSG_RESPONSE");
+ http_error(HE_NOTICE, HTTP_E_MESSAGE_TYPE, "HttpMessage is not of type HTTP_MSG_RESPONSE");
RETURN_NULL();
}
getObject(http_message_object, obj);
if (!HTTP_MSG_TYPE(RESPONSE, obj->message)) {
- http_error(E_WARNING, HTTP_E_MSG, "HttpMessage is not of type HTTP_MSG_RESPONSE");
+ http_error(HE_WARNING, HTTP_E_MESSAGE_TYPE, "HttpMessage is not of type HTTP_MSG_RESPONSE");
RETURN_FALSE;
}
RETURN_FALSE;
}
if (code < 100 || code > 510) {
- http_error_ex(E_WARNING, HTTP_E_PARAM, "Invalid response code (100-510): %ld", code);
+ http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, "Invalid response code (100-510): %ld", code);
RETURN_FALSE;
}
getObject(http_message_object, obj);
if (!HTTP_MSG_TYPE(REQUEST, obj->message)) {
- http_error(E_NOTICE, HTTP_E_MSG, "HttpMessage is not of type HTTP_MSG_REQUEST");
+ http_error(HE_NOTICE, HTTP_E_MESSAGE_TYPE, "HttpMessage is not of type HTTP_MSG_REQUEST");
RETURN_NULL();
}
getObject(http_message_object, obj);
if (!HTTP_MSG_TYPE(REQUEST, obj->message)) {
- http_error(E_WARNING, HTTP_E_MSG, "HttpMessage is not of type HTTP_MSG_REQUEST");
+ http_error(HE_WARNING, HTTP_E_MESSAGE_TYPE, "HttpMessage is not of type HTTP_MSG_REQUEST");
RETURN_FALSE;
}
RETURN_FALSE;
}
if (method_len < 1) {
- http_error(E_WARNING, HTTP_E_PARAM, "Cannot set HttpMessage::requestMethod to an empty string");
+ http_error(HE_WARNING, HTTP_E_INVALID_PARAM, "Cannot set HttpMessage::requestMethod to an empty string");
RETURN_FALSE;
}
if (SUCCESS != http_check_method(method)) {
- http_error_ex(E_WARNING, HTTP_E_PARAM, "Unkown request method: %s", method);
+ http_error_ex(HE_WARNING, HTTP_E_REQUEST_METHOD, "Unkown request method: %s", method);
RETURN_FALSE;
}
getObject(http_message_object, obj);
if (!HTTP_MSG_TYPE(REQUEST, obj->message)) {
- http_error(E_WARNING, HTTP_E_MSG, "HttpMessage is not of type HTTP_MSG_REQUEST");
+ http_error(HE_WARNING, HTTP_E_MESSAGE_TYPE, "HttpMessage is not of type HTTP_MSG_REQUEST");
RETURN_NULL();
}
getObject(http_message_object, obj);
if (!HTTP_MSG_TYPE(REQUEST, obj->message)) {
- http_error(E_WARNING, HTTP_E_MSG, "HttpMessage is not of type HTTP_MSG_REQUEST");
+ http_error(HE_WARNING, HTTP_E_MESSAGE_TYPE, "HttpMessage is not of type HTTP_MSG_REQUEST");
RETURN_FALSE;
}
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &URI, &URIlen)) {
RETURN_FALSE;
}
if (URIlen < 1) {
- http_error(E_WARNING, HTTP_E_PARAM, "Cannot set HttpMessage::requestUri to an empty string");
+ http_error(HE_WARNING, HTTP_E_INVALID_PARAM, "Cannot set HttpMessage::requestUri to an empty string");
RETURN_FALSE;
}
}
if (HTTP_MSG_TYPE(NONE, obj->message)) {
- http_error(E_WARNING, HTTP_E_MSG, "Message is neither of type HTTP_MSG_RESPONSE nor HTTP_MSG_REQUEST");
+ http_error(HE_WARNING, HTTP_E_MESSAGE_TYPE, "Message is neither of type HTTP_MSG_RESPONSE nor HTTP_MSG_REQUEST");
RETURN_FALSE;
}
convert_to_double(zv);
sprintf(v, "%1.1lf", Z_DVAL_P(zv));
if (strcmp(v, "1.0") && strcmp(v, "1.1")) {
- http_error_ex(E_WARNING, HTTP_E_PARAM, "Invalid HTTP protocol version (1.0 or 1.1): %s", v);
+ http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, "Invalid HTTP protocol version (1.0 or 1.1): %s", v);
RETURN_FALSE;
}