# define PHP_HTTP_DBG_EXCEPTIONS 0
#endif
-zend_class_entry *PHP_HTTP_EX_DEF_CE;
-zend_class_entry *PHP_HTTP_EX_CE(runtime);
-zend_class_entry *PHP_HTTP_EX_CE(header);
-zend_class_entry *PHP_HTTP_EX_CE(malformed_headers);
-zend_class_entry *PHP_HTTP_EX_CE(request_method);
-zend_class_entry *PHP_HTTP_EX_CE(message);
-zend_class_entry *PHP_HTTP_EX_CE(message_type);
-zend_class_entry *PHP_HTTP_EX_CE(message_body);
-zend_class_entry *PHP_HTTP_EX_CE(invalid_param);
-zend_class_entry *PHP_HTTP_EX_CE(encoding);
-zend_class_entry *PHP_HTTP_EX_CE(request);
-zend_class_entry *PHP_HTTP_EX_CE(request_pool);
-zend_class_entry *PHP_HTTP_EX_CE(request_datashare);
-zend_class_entry *PHP_HTTP_EX_CE(request_factory);
-zend_class_entry *PHP_HTTP_EX_CE(socket);
-zend_class_entry *PHP_HTTP_EX_CE(response);
-zend_class_entry *PHP_HTTP_EX_CE(url);
-zend_class_entry *PHP_HTTP_EX_CE(querystring);
-zend_class_entry *PHP_HTTP_EX_CE(cookie);
+zend_class_entry *php_http_exception_class_entry;
zend_function_entry php_http_exception_method_entry[] = {
EMPTY_FUNCTION_ENTRY
PHP_MINIT_FUNCTION(http_exception)
{
- PHP_HTTP_REGISTER_EXCEPTION(Exception, PHP_HTTP_EX_DEF_CE, zend_exception_get_default(TSRMLS_C));
+ PHP_HTTP_REGISTER_EXCEPTION(Exception, php_http_exception_class_entry, zend_exception_get_default(TSRMLS_C));
- PHP_HTTP_REGISTER_EXCEPTION(RuntimeException, PHP_HTTP_EX_CE(runtime), PHP_HTTP_EX_DEF_CE);
- PHP_HTTP_REGISTER_EXCEPTION(InvalidParamException, PHP_HTTP_EX_CE(invalid_param), PHP_HTTP_EX_DEF_CE);
- PHP_HTTP_REGISTER_EXCEPTION(HeaderException, PHP_HTTP_EX_CE(header), PHP_HTTP_EX_DEF_CE);
- PHP_HTTP_REGISTER_EXCEPTION(MalformedHeadersException, PHP_HTTP_EX_CE(malformed_headers), PHP_HTTP_EX_DEF_CE);
- PHP_HTTP_REGISTER_EXCEPTION(RequestMethodException, PHP_HTTP_EX_CE(request_method), PHP_HTTP_EX_DEF_CE);
- PHP_HTTP_REGISTER_EXCEPTION(MessageException, PHP_HTTP_EX_CE(message), PHP_HTTP_EX_DEF_CE);
- PHP_HTTP_REGISTER_EXCEPTION(MessageTypeException, PHP_HTTP_EX_CE(message_type), PHP_HTTP_EX_DEF_CE);
- PHP_HTTP_REGISTER_EXCEPTION(MessageBodyException, PHP_HTTP_EX_CE(message_body), PHP_HTTP_EX_DEF_CE);
- PHP_HTTP_REGISTER_EXCEPTION(EncodingException, PHP_HTTP_EX_CE(encoding), PHP_HTTP_EX_DEF_CE);
- PHP_HTTP_REGISTER_EXCEPTION(RequestException, PHP_HTTP_EX_CE(request), PHP_HTTP_EX_DEF_CE);
-
- zend_declare_property_long(PHP_HTTP_EX_CE(request), "curlCode", lenof("curlCode"), 0, ZEND_ACC_PUBLIC TSRMLS_CC);
-
- PHP_HTTP_REGISTER_EXCEPTION(RequestPoolException, PHP_HTTP_EX_CE(request_pool), PHP_HTTP_EX_DEF_CE);
- PHP_HTTP_REGISTER_EXCEPTION(RequestDataShareException, PHP_HTTP_EX_CE(request_datashare), PHP_HTTP_EX_DEF_CE);
- PHP_HTTP_REGISTER_EXCEPTION(RequestFactoryException, PHP_HTTP_EX_CE(request_factory), PHP_HTTP_EX_DEF_CE);
- PHP_HTTP_REGISTER_EXCEPTION(SocketException, PHP_HTTP_EX_CE(socket), PHP_HTTP_EX_DEF_CE);
- PHP_HTTP_REGISTER_EXCEPTION(ResponseException, PHP_HTTP_EX_CE(response), PHP_HTTP_EX_DEF_CE);
- PHP_HTTP_REGISTER_EXCEPTION(UrlException, PHP_HTTP_EX_CE(url), PHP_HTTP_EX_DEF_CE);
- PHP_HTTP_REGISTER_EXCEPTION(QueryStringException, PHP_HTTP_EX_CE(querystring), PHP_HTTP_EX_DEF_CE);
- PHP_HTTP_REGISTER_EXCEPTION(CookieException, PHP_HTTP_EX_CE(cookie), PHP_HTTP_EX_DEF_CE);
+ zend_declare_class_constant_long(php_http_exception_class_entry, ZEND_STRL("E_UNKNOWN"), PHP_HTTP_E_UNKNOWN TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_exception_class_entry, ZEND_STRL("E_RUNTIME"), PHP_HTTP_E_RUNTIME TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_exception_class_entry, ZEND_STRL("E_INVALID_PARAM"), PHP_HTTP_E_INVALID_PARAM TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_exception_class_entry, ZEND_STRL("E_HEADER"), PHP_HTTP_E_HEADER TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_exception_class_entry, ZEND_STRL("E_MALFORMED_HEADERS"), PHP_HTTP_E_MALFORMED_HEADERS TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_exception_class_entry, ZEND_STRL("E_MESSAGE"), PHP_HTTP_E_MESSAGE TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_exception_class_entry, ZEND_STRL("E_MESSAGE_TYPE"), PHP_HTTP_E_MESSAGE_TYPE TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_exception_class_entry, ZEND_STRL("E_MESSAGE_BODY"), PHP_HTTP_E_MESSAGE_BODY TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_exception_class_entry, ZEND_STRL("E_ENCODING"), PHP_HTTP_E_ENCODING TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_exception_class_entry, ZEND_STRL("E_REQUEST"), PHP_HTTP_E_REQUEST TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_exception_class_entry, ZEND_STRL("E_REQUEST_POOL"), PHP_HTTP_E_REQUEST_POOL TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_exception_class_entry, ZEND_STRL("E_REQUEST_DATASHARE"), PHP_HTTP_E_REQUEST_DATASHARE TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_exception_class_entry, ZEND_STRL("E_REQUEST_FACTORY"), PHP_HTTP_E_REQUEST_FACTORY TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_exception_class_entry, ZEND_STRL("E_REQUEST_METHOD"), PHP_HTTP_E_REQUEST_METHOD TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_exception_class_entry, ZEND_STRL("E_SOCKET"), PHP_HTTP_E_SOCKET TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_exception_class_entry, ZEND_STRL("E_RESPONSE"), PHP_HTTP_E_RESPONSE TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_exception_class_entry, ZEND_STRL("E_URL"), PHP_HTTP_E_URL TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_exception_class_entry, ZEND_STRL("E_QUERYSTRING"), PHP_HTTP_E_QUERYSTRING TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_exception_class_entry, ZEND_STRL("E_COOKIE"), PHP_HTTP_E_COOKIE TSRMLS_CC);
#if PHP_HTTP_DBG_EXCEPTIONS
zend_throw_exception_hook = php_http_exception_hook;
return SUCCESS;
}
-zend_class_entry *php_http_exception_get_default(void)
-{
- return PHP_HTTP_EX_DEF_CE;
-}
-
-zend_class_entry *php_http_exception_get_for_code(long code)
-{
- zend_class_entry *ex = PHP_HTTP_EX_DEF_CE;
-
- switch (code) {
- case PHP_HTTP_E_RUNTIME: ex = PHP_HTTP_EX_CE(runtime); break;
- case PHP_HTTP_E_INVALID_PARAM: ex = PHP_HTTP_EX_CE(invalid_param); break;
- case PHP_HTTP_E_HEADER: ex = PHP_HTTP_EX_CE(header); break;
- case PHP_HTTP_E_MALFORMED_HEADERS: ex = PHP_HTTP_EX_CE(malformed_headers); break;
- case PHP_HTTP_E_REQUEST_METHOD: ex = PHP_HTTP_EX_CE(request_method); break;
- case PHP_HTTP_E_MESSAGE: ex = PHP_HTTP_EX_CE(message); break;
- case PHP_HTTP_E_MESSAGE_TYPE: ex = PHP_HTTP_EX_CE(message_type); break;
- case PHP_HTTP_E_MESSAGE_BODY: ex = PHP_HTTP_EX_CE(message_body); break;
- case PHP_HTTP_E_ENCODING: ex = PHP_HTTP_EX_CE(encoding); break;
- case PHP_HTTP_E_REQUEST: ex = PHP_HTTP_EX_CE(request); break;
- case PHP_HTTP_E_REQUEST_POOL: ex = PHP_HTTP_EX_CE(request_pool); break;
- case PHP_HTTP_E_REQUEST_DATASHARE: ex = PHP_HTTP_EX_CE(request_datashare); break;
- case PHP_HTTP_E_REQUEST_FACTORY: ex = PHP_HTTP_EX_CE(request_factory); break;
- case PHP_HTTP_E_SOCKET: ex = PHP_HTTP_EX_CE(socket); break;
- case PHP_HTTP_E_RESPONSE: ex = PHP_HTTP_EX_CE(response); break;
- case PHP_HTTP_E_URL: ex = PHP_HTTP_EX_CE(url); break;
- case PHP_HTTP_E_QUERYSTRING: ex = PHP_HTTP_EX_CE(querystring); break;
- case PHP_HTTP_E_COOKIE: ex = PHP_HTTP_EX_CE(cookie); break;
- }
-
- return ex;
-}
-
/*
* Local variables:
* tab-width: 4
PHP_MINIT_FUNCTION(http_exception_object);
-#define PHP_HTTP_EX_DEF_CE php_http_exception_class_entry
-#define PHP_HTTP_EX_CE(name) php_http_ ##name## _exception_class_entry
-
-extern zend_class_entry *PHP_HTTP_EX_DEF_CE;
-extern zend_class_entry *PHP_HTTP_EX_CE(runtime);
-extern zend_class_entry *PHP_HTTP_EX_CE(header);
-extern zend_class_entry *PHP_HTTP_EX_CE(malformed_headers);
-extern zend_class_entry *PHP_HTTP_EX_CE(request_method);
-extern zend_class_entry *PHP_HTTP_EX_CE(message);
-extern zend_class_entry *PHP_HTTP_EX_CE(message_type);
-extern zend_class_entry *PHP_HTTP_EX_CE(invalid_param);
-extern zend_class_entry *PHP_HTTP_EX_CE(encoding);
-extern zend_class_entry *PHP_HTTP_EX_CE(request);
-extern zend_class_entry *PHP_HTTP_EX_CE(request_pool);
-extern zend_class_entry *PHP_HTTP_EX_CE(request_datashare);
-extern zend_class_entry *PHP_HTTP_EX_CE(request_factory);
-extern zend_class_entry *PHP_HTTP_EX_CE(socket);
-extern zend_class_entry *PHP_HTTP_EX_CE(response);
-extern zend_class_entry *PHP_HTTP_EX_CE(url);
-extern zend_class_entry *PHP_HTTP_EX_CE(querystring);
-extern zend_class_entry *PHP_HTTP_EX_CE(cookie);
+extern zend_class_entry *php_http_exception_class_entry;
extern zend_function_entry php_http_exception_method_entry[];
-PHP_HTTP_API zend_class_entry *php_http_exception_get_default(void);
-PHP_HTTP_API zend_class_entry *php_http_exception_get_for_code(long code);
-
PHP_MINIT_FUNCTION(http_exception);
#endif
Z_ARRVAL_P(zv) = (ht); \
}
-static inline zval *php_http_zsep(int type, zval *z)
+static inline zval *php_http_ztyp(int type, zval *z)
{
SEPARATE_ARG_IF_REF(z);
if (Z_TYPE_P(z) != type) {
return z;
}
+static inline zval *php_http_zsep(zend_bool add_ref, int type, zval *z) {
+ if (add_ref) {
+ Z_ADDREF_P(z);
+ }
+ if (Z_TYPE_P(z) != type) {
+ switch (type) {
+ case IS_NULL: convert_to_null_ex(&z); break;
+ case IS_BOOL: convert_to_boolean_ex(&z); break;
+ case IS_LONG: convert_to_long_ex(&z); break;
+ case IS_DOUBLE: convert_to_double_ex(&z); break;
+ case IS_STRING: convert_to_string_ex(&z); break;
+ case IS_ARRAY: convert_to_array_ex(&z); break;
+ case IS_OBJECT: convert_to_object_ex(&z); break;
+ }
+ } else {
+ SEPARATE_ZVAL_IF_NOT_REF(&z);
+ }
+ return z;
+}
+
/* return bool (v == SUCCESS) */
#define RETVAL_SUCCESS(v) RETVAL_BOOL(SUCCESS == (v))
ZEND_ARG_PASS_INFO(0) \
ZEND_ARG_PASS_INFO(1) \
ZEND_END_ARG_INFO(); \
+\
+ ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_3, 0) \
+ ZEND_ARG_PASS_INFO(0) \
+ ZEND_ARG_PASS_INFO(0) \
+ ZEND_ARG_PASS_INFO(1) \
+ ZEND_END_ARG_INFO(); \
\
ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_4, 0) \
ZEND_ARG_PASS_INFO(0) \
#define HE_ERROR E_ERROR TSRMLS_CC
typedef enum php_http_error {
+ PHP_HTTP_E_UNKNOWN = 0,
PHP_HTTP_E_RUNTIME,
PHP_HTTP_E_INVALID_PARAM,
PHP_HTTP_E_HEADER,