REGISTER_INI_ENTRIES();
- if ( (SUCCESS != http_support_global_init()) ||
- (SUCCESS != http_headers_global_init()) ||
- (SUCCESS != http_cache_global_init()) ||
- (SUCCESS != http_request_method_global_init())) {
- return FAILURE;
- }
+ if ( (SUCCESS != PHP_MINIT_CALL(http_support)) ||
+ (SUCCESS != PHP_MINIT_CALL(http_headers)) ||
+ (SUCCESS != PHP_MINIT_CALL(http_cache)) ||
#ifdef HTTP_HAVE_CURL
- if (SUCCESS != http_request_global_init()) {
+ (SUCCESS != PHP_MINIT_CALL(http_request)) ||
+#endif /* HTTP_HAVE_CURL */
+ (SUCCESS != PHP_MINIT_CALL(http_request_method))) {
return FAILURE;
}
-#endif /* HTTP_HAVE_CURL */
#ifdef ZEND_ENGINE_2
- http_util_object_init();
- http_message_object_init();
+ if ( (SUCCESS != PHP_MINIT_CALL(http_util_object)) ||
+ (SUCCESS != PHP_MINIT_CALL(http_message_object)) ||
# ifndef WONKY
- http_response_object_init();
-# endif
+ (SUCCESS != PHP_MINIT_CALL(http_response_object)) ||
+# endif /* WONKY */
# ifdef HTTP_HAVE_CURL
- http_request_object_init();
- http_requestpool_object_init();
+ (SUCCESS != PHP_MINIT_CALL(http_request_object)) ||
+ (SUCCESS != PHP_MINIT_CALL(http_requestpool_object)) ||
# endif /* HTTP_HAVE_CURL */
- http_exception_object_init();
+ (SUCCESS != PHP_MINIT_CALL(http_exception_object))) {
+ return FAILURE;
+ }
#endif /* ZEND_ENGINE_2 */
return SUCCESS;
{
UNREGISTER_INI_ENTRIES();
#ifdef HTTP_HAVE_CURL
- http_request_global_cleanup();
+ return PHP_MSHUTDOWN_CALL(http_request);
#endif
return SUCCESS;
}
/* {{{ PHP_RSHUTDOWN_FUNCTION */
PHP_RSHUTDOWN_FUNCTION(http)
{
-#if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL)
- int i, c = zend_hash_num_elements(&HTTP_G(request).methods.custom);
+ STATUS status = SUCCESS;
- for (i = 0; i < c; ++i) {
- http_request_method_unregister(HTTP_MAX_REQUEST_METHOD + i);
- }
+#if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL)
+ status = PHP_RSHUTDOWN_CALL(http_request_method);
#endif
+
http_globals_free(HTTP_GLOBALS);
- return SUCCESS;
+ return status;
}
/* }}} */
static zend_bool http_support_ssl;
-STATUS _http_support_global_init(INIT_FUNC_ARGS)
+PHP_MINIT_FUNCTION(http_support)
{
http_support_ssl = http_request_supports_ssl();
ZEND_EXTERN_MODULE_GLOBALS(http);
-STATUS _http_cache_global_init(INIT_FUNC_ARGS)
+PHP_MINIT_FUNCTION(http_cache)
{
HTTP_LONG_CONSTANT("HTTP_ETAG_MD5", HTTP_ETAG_MD5);
HTTP_LONG_CONSTANT("HTTP_ETAG_SHA1", HTTP_ETAG_SHA1);
zend_class_entry *HTTP_EX_CE(response);
zend_class_entry *HTTP_EX_CE(url);
-void _http_exception_object_init(INIT_FUNC_ARGS)
+PHP_MINIT_FUNCTION(http_exception_object)
{
HTTP_REGISTER_EXCEPTION(HttpException, http_exception_object_ce, zend_exception_get_default());
HTTP_REGISTER_EXCEPTION(HttpRuntimeException, HTTP_EX_CE(runtime), HTTP_EX_DEF_CE);
HTTP_LONG_CONSTANT("HTTP_E_SOCKET", HTTP_E_SOCKET);
HTTP_LONG_CONSTANT("HTTP_E_RESPONSE", HTTP_E_RESPONSE);
HTTP_LONG_CONSTANT("HTTP_E_URL", HTTP_E_URL);
+
+ return SUCCESS;
}
zend_class_entry *_http_exception_get_default()
* - compress: bool, whether to allow gzip/deflate content encoding
* (defaults to true)
* - port: int, use another port as specified in the url
- * - referer: string, the referer to sends
+ * - referer: string, the referer to send
* - useragent: string, the user agent to send
* (defaults to PECL::HTTP/version (PHP/version)))
* - headers: array, list of custom headers as associative array
# define HTTP_DBG_NEG 0
#endif
-/* {{{ STATUS http_headers_global_init() */
-STATUS _http_headers_global_init(INIT_FUNC_ARGS)
+/* {{{ */
+PHP_MINIT_FUNCTION(http_headers)
{
HTTP_LONG_CONSTANT("HTTP_REDIRECT", HTTP_REDIRECT);
HTTP_LONG_CONSTANT("HTTP_REDIRECT_PERM", HTTP_REDIRECT_PERM);
};
static zend_object_handlers http_message_object_handlers;
-void _http_message_object_init(INIT_FUNC_ARGS)
+PHP_MINIT_FUNCTION(http_message_object)
{
HTTP_REGISTER_CLASS_EX(HttpMessage, http_message_object, NULL, 0);
http_message_object_handlers.write_property = http_message_object_write_prop;
http_message_object_handlers.get_properties = http_message_object_get_props;
http_message_object_handlers.get_property_ptr_ptr = NULL;
+
+ return SUCCESS;
}
zend_object_value _http_message_object_new(zend_class_entry *ce TSRMLS_DC)
static inline void http_ssl_cleanup(void);
#endif
-STATUS _http_request_global_init(INIT_FUNC_ARGS)
+PHP_MINIT_FUNCTION(http_request)
{
if (CURLE_OK != curl_global_init(CURL_GLOBAL_ALL)) {
return FAILURE;
return SUCCESS;
}
-void _http_request_global_cleanup(TSRMLS_D)
+PHP_MSHUTDOWN_FUNCTION(http_request)
{
curl_global_cleanup();
#ifdef HTTP_NEED_SSL
http_ssl_cleanup();
#endif
+ return SUCCESS;
}
#ifndef HAVE_CURL_EASY_STRERROR
};
/* }}} */
-STATUS _http_request_method_global_init(INIT_FUNC_ARGS)
+PHP_MINIT_FUNCTION(http_request_method)
{
/* HTTP/1.1 */
HTTP_LONG_CONSTANT("HTTP_METH_GET", HTTP_GET);
return SUCCESS;
}
+PHP_RSHUTDOWN_FUNCTION(http_request_method)
+{
+ int i, c = zend_hash_num_elements(&HTTP_G(request).methods.custom);
+
+ for (i = 0; i < c; ++i) {
+ http_request_method_unregister(HTTP_MAX_REQUEST_METHOD + i);
+ }
+
+ return SUCCESS;
+}
+
/* {{{ char *http_request_method_name(http_request_method) */
PHP_HTTP_API const char *_http_request_method_name(http_request_method m TSRMLS_DC)
{
};
static zend_object_handlers http_request_object_handlers;
-void _http_request_object_init(INIT_FUNC_ARGS)
+PHP_MINIT_FUNCTION(http_request_object)
{
HTTP_REGISTER_CLASS_EX(HttpRequest, http_request_object, NULL, 0);
+ return SUCCESS;
}
zend_object_value _http_request_object_new(zend_class_entry *ce TSRMLS_DC)
};
static zend_object_handlers http_requestpool_object_handlers;
-void _http_requestpool_object_init(INIT_FUNC_ARGS)
+PHP_MINIT_FUNCTION(http_requestpool_object)
{
HTTP_REGISTER_CLASS_EX(HttpRequestPool, http_requestpool_object, NULL, 0);
zend_class_implements(http_requestpool_object_ce TSRMLS_CC, 1, zend_ce_iterator);
+ return SUCCESS;
}
zend_object_value _http_requestpool_object_new(zend_class_entry *ce TSRMLS_DC)
EMPTY_FUNCTION_ENTRY
};
-void _http_response_object_init(INIT_FUNC_ARGS)
+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)
EMPTY_FUNCTION_ENTRY
};
-void _http_util_object_init(INIT_FUNC_ARGS)
+PHP_MINIT_FUNCTION(http_util_object)
{
HTTP_REGISTER_CLASS(HttpUtil, http_util_object, NULL, 0);
+ return SUCCESS;
}
#endif /* ZEND_ENGINE_2 */
#ifndef PHP_EXT_HTTP_H
#define PHP_EXT_HTTP_H
-#define HTTP_PEXT_VERSION "0.15.0"
+#define HTTP_PEXT_VERSION "0.15.1dev"
/* make compile on Win32 */
#ifdef HTTP_HAVE_CURL
#define HTTP_SUPPORT_MHASHETAGS 0x10L
#define HTTP_SUPPORT_SSLREQUESTS 0x20L
-#define http_support_global_init() _http_support_global_init(INIT_FUNC_ARGS_PASSTHRU)
-extern STATUS _http_support_global_init(INIT_FUNC_ARGS);
+extern PHP_MINIT_FUNCTION(http_support);
#define http_support(f) _http_support(f)
PHP_HTTP_API long _http_support(long feature);
ZEND_EXTERN_MODULE_GLOBALS(http);
-#define http_cache_global_init() _http_cache_global_init(INIT_FUNC_ARGS_PASSTHRU)
-extern STATUS _http_cache_global_init(INIT_FUNC_ARGS);
-
typedef enum {
HTTP_ETAG_CRC32 = -3,
HTTP_ETAG_MD5 = -2,
HTTP_ETAG_SHA1 = -1,
} http_etag_mode;
+extern PHP_MINIT_FUNCTION(http_cache);
+
#ifdef HTTP_HAVE_MHASH
static void *http_etag_alloc_mhash_digest(size_t size)
{
#define http_encoding_uncompress(d, dl, r, rl) _http_encoding_uncompress((d), (dl), (r), (rl) TSRMLS_CC)
PHP_HTTP_API STATUS _http_encoding_uncompress(const char *data, size_t data_len, char **decoded, size_t *decoded_len TSRMLS_DC);
-#endif
+#endif /* HTTP_HAVE_ZLIB */
+
#endif
/*
#define PHP_HTTP_EXCEPTION_OBJECT_H
#ifdef ZEND_ENGINE_2
+PHP_MINIT_FUNCTION(http_exception_object);
+
extern zend_class_entry *http_exception_object_ce;
extern zend_function_entry http_exception_object_fe[];
-#define http_exception_object_init() _http_exception_object_init(INIT_FUNC_ARGS_PASSTHRU)
-extern void _http_exception_object_init(INIT_FUNC_ARGS);
-
#define http_exception_get_default _http_exception_get_default
extern zend_class_entry *_http_exception_get_default();
RANGE_ERR
} http_range_status;
-#define http_headers_global_init() _http_headers_global_init(INIT_FUNC_ARGS_PASSTHRU)
-extern STATUS _http_headers_global_init(INIT_FUNC_ARGS);
+extern PHP_MINIT_FUNCTION(http_headers);
#define http_parse_headers(h, a) _http_parse_headers_ex((h), Z_ARRVAL_P(a), 1, http_info_default_callback, NULL TSRMLS_CC)
#define http_parse_headers_ex(h, ht, p) _http_parse_headers_ex((h), (ht), (p), http_info_default_callback, NULL TSRMLS_CC)
extern zend_class_entry *http_message_object_ce;
extern zend_function_entry http_message_object_fe[];
-#define http_message_object_init() _http_message_object_init(INIT_FUNC_ARGS_PASSTHRU)
-extern void _http_message_object_init(INIT_FUNC_ARGS);
+extern PHP_MINIT_FUNCTION(http_message_object);
+
#define http_message_object_new _http_message_object_new
extern zend_object_value _http_message_object_new(zend_class_entry *ce TSRMLS_DC);
#define http_message_object_new_ex(ce, msg) _http_message_object_new_ex(ce, msg TSRMLS_CC)
#endif
#include <curl/curl.h>
-#define http_request_global_init() _http_request_global_init(INIT_FUNC_ARGS_PASSTHRU)
-extern STATUS _http_request_global_init(INIT_FUNC_ARGS);
-#define http_request_global_cleanup() _http_request_global_cleanup(TSRMLS_C)
-extern void _http_request_global_cleanup(TSRMLS_D);
+extern PHP_MINIT_FUNCTION(http_request);
+extern PHP_MSHUTDOWN_FUNCTION(http_request);
#define HTTP_REQUEST_BODY_CSTRING 1
#define HTTP_REQUEST_BODY_CURLPOST 2
HTTP_MAX_REQUEST_METHOD = 28
} http_request_method;
-#define http_request_method_global_init() _http_request_method_global_init(INIT_FUNC_ARGS_PASSTHRU)
-STATUS _http_request_method_global_init(INIT_FUNC_ARGS);
-
#define HTTP_STD_REQUEST_METHOD(m) ((m > HTTP_NO_REQUEST_METHOD) && (m < HTTP_MAX_REQUEST_METHOD))
#define HTTP_CUSTOM_REQUEST_METHOD(m) (m - HTTP_MAX_REQUEST_METHOD)
+extern PHP_MINIT_FUNCTION(http_request_method);
+extern PHP_RSHUTDOWN_FUNCTION(http_request_method);
+
#define http_request_method_name(m) _http_request_method_name((m) TSRMLS_CC)
PHP_HTTP_API const char *_http_request_method_name(http_request_method m TSRMLS_DC);
extern zend_class_entry *http_request_object_ce;
extern zend_function_entry http_request_object_fe[];
-#define http_request_object_init() _http_request_object_init(INIT_FUNC_ARGS_PASSTHRU)
-extern void _http_request_object_init(INIT_FUNC_ARGS);
+extern PHP_MINIT_FUNCTION(http_request_object);
+
#define http_request_object_new _http_request_object_new
extern zend_object_value _http_request_object_new(zend_class_entry *ce TSRMLS_DC);
#define http_request_object_free _http_request_object_free
extern zend_class_entry *http_requestpool_object_ce;
extern zend_function_entry http_requestpool_object_fe[];
-#define http_requestpool_object_init() _http_requestpool_object_init(INIT_FUNC_ARGS_PASSTHRU)
-extern void _http_requestpool_object_init(INIT_FUNC_ARGS);
+extern PHP_MINIT_FUNCTION(http_requestpool_object);
+
#define http_requestpool_object_new _http_requestpool_object_new
extern zend_object_value _http_requestpool_object_new(zend_class_entry *ce TSRMLS_DC);
#define http_requestpool_object_free _http_requestpool_object_free
extern zend_class_entry *http_response_object_ce;
extern zend_function_entry http_response_object_fe[];
-#define http_response_object_init() _http_response_object_init(INIT_FUNC_ARGS_PASSTHRU)
-extern void _http_response_object_init(INIT_FUNC_ARGS);
+extern PHP_MINIT_FUNCTION(http_response_object);
PHP_METHOD(HttpResponse, setHeader);
PHP_METHOD(HttpResponse, getHeader);
#define RETURN_ZVAL(zv, copy, dtor) { RETVAL_ZVAL(zv, copy, dtor); return; }
#endif
+#define PHP_MINIT_CALL(func) PHP_MINIT(func)(INIT_FUNC_ARGS_PASSTHRU)
+#define PHP_RINIT_CALL(func) PHP_RINIT(func)(INIT_FUNC_ARGS_PASSTHRU)
+#define PHP_MSHUTDOWN_CALL(func) PHP_MSHUTDOWN(func)(SHUTDOWN_FUNC_ARGS_PASSTHRU)
+#define PHP_RSHUTDOWN_CALL(func) PHP_RSHUTDOWN(func)(SHUTDOWN_FUNC_ARGS_PASSTHRU)
#endif /* PHP_HTTP_STD_DEFS_H */
extern zend_class_entry *http_util_object_ce;
extern zend_function_entry http_util_object_fe[];
-#define http_util_object_init() _http_util_object_init(INIT_FUNC_ARGS_PASSTHRU)
-extern void _http_util_object_init(INIT_FUNC_ARGS);
+extern PHP_MINIT_FUNCTION(http_util_object);
PHP_METHOD(HttpUtil, date);
PHP_METHOD(HttpUtil, absoluteUri);