From: Michael Wallner Date: Mon, 9 Jan 2012 17:39:57 +0000 (+0000) Subject: header cleanups and fix some warnings X-Git-Tag: DEV_2-before-client~79 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=commitdiff_plain;h=29a54250b58e444974ae19840194e214cab80bd5 header cleanups and fix some warnings --- diff --git a/php_http.c b/php_http.c index 9e97610..cd95f48 100644 --- a/php_http.c +++ b/php_http.c @@ -10,9 +10,14 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" + +#include +#include +#include #include + #if PHP_HTTP_HAVE_CURL # include # if PHP_HTTP_HAVE_EVENT @@ -20,16 +25,12 @@ # endif #endif #if PHP_HTTP_HAVE_NEON -# include "neon/ne_utils.h" +# include #endif #if PHP_HTTP_HAVE_SERF -# include "serf.h" +# include #endif -#include
-#include -#include - ZEND_DECLARE_MODULE_GLOBALS(php_http); #ifdef COMPILE_DL_HTTP @@ -48,13 +49,13 @@ PHP_MINFO_FUNCTION(http); static zend_module_dep http_module_deps[] = { ZEND_MOD_REQUIRED("spl") -#if PHP_HTTP_HAVE_HASH +#ifdef PHP_HTTP_HAVE_HASH ZEND_MOD_REQUIRED("hash") #endif -#if PHP_HTTP_HAVE_ICONV +#ifdef PHP_HTTP_HAVE_ICONV ZEND_MOD_REQUIRED("iconv") #endif -#if PHP_HTTP_HAVE_EVENT +#ifdef PHP_HTTP_HAVE_EVENT ZEND_MOD_CONFLICTS("event") #endif {NULL, NULL, NULL, 0} diff --git a/php_http.h b/php_http.h index 3ea3f3d..94ed04e 100644 --- a/php_http.h +++ b/php_http.h @@ -15,57 +15,6 @@ #define PHP_HTTP_EXT_VERSION "2.0.0dev" -#ifdef HAVE_CONFIG_H -# include "config.h" -#else -# ifndef PHP_WIN32 -# include "php_config.h" -# endif -#endif - -#include "php.h" -#if defined(PHP_WIN32) -# if defined(PHP_HTTP_EXPORTS) -# define PHP_HTTP_API __declspec(dllexport) -# elif defined(COMPILE_DL_HTTP) -# define PHP_HTTP_API __declspec(dllimport) -# else -# define PHP_HTTP_API -# endif -#else -# define PHP_HTTP_API -#endif - -/* make functions that return SUCCESS|FAILURE more obvious */ -typedef int STATUS; - -#include "php_http_buffer.h" -#include "php_http_strlist.h" - -#if (defined(HAVE_ICONV) || defined(PHP_HTTP_HAVE_EXT_ICONV)) && (PHP_HTTP_SHARED_DEPS || !defined(COMPILE_DL_ICONV)) -# define PHP_HTTP_HAVE_ICONV -#endif - -#if (defined(HAVE_HASH_EXT) || defined(PHP_HTTP_HAVE_EXT_HASH)) && (PHP_HTTP_SHARED_DEPS || !defined(COMPILE_DL_HASH)) && defined(PHP_HTTP_HAVE_PHP_HASH_H) -# define PHP_HTTP_HAVE_HASH -#endif - -#ifdef PHP_WIN32 -# define CURL_STATICLIB -# define PHP_HTTP_HAVE_NETDB -# include -#elif defined(HAVE_NETDB_H) -# define PHP_HTTP_HAVE_NETDB -# include -# ifdef HAVE_UNISTD_H -# include -# endif -#endif - -#include -#define PHP_HTTP_IS_CTYPE(type, c) is##type((int) (unsigned char) (c)) -#define PHP_HTTP_TO_CTYPE(type, c) to##type((int) (unsigned char) (c)) - extern zend_module_entry http_module_entry; #define phpext_http_ptr &http_module_entry @@ -80,60 +29,6 @@ extern void _dpf(int type, const char *data, size_t length); # define _dpf(t,s,l); #endif -#include "php_http_misc.h" - -#include "php_http_cookie.h" -#include "php_http_encoding.h" -#include "php_http_env.h" -#include "php_http_env_response.h" -#include "php_http_etag.h" -#include "php_http_exception.h" -#include "php_http_filter.h" -#include "php_http_headers.h" -#include "php_http_info.h" -#include "php_http_header_parser.h" -#include "php_http_message_body.h" -#include "php_http_message.h" -#include "php_http_message_parser.h" -#include "php_http_negotiate.h" -#include "php_http_object.h" -#include "php_http_params.h" -#include "php_http_resource_factory.h" -#include "php_http_persistent_handle.h" -#include "php_http_property_proxy.h" -#include "php_http_querystring.h" -#include "php_http_request_datashare.h" -#include "php_http_request_factory.h" -#include "php_http_request.h" -#include "php_http_curl.h" -#include "php_http_neon.h" -#include "php_http_serf.h" -#include "php_http_request_method.h" -#include "php_http_request_pool.h" -#include "php_http_url.h" -#include "php_http_version.h" - -ZEND_BEGIN_MODULE_GLOBALS(php_http) - struct php_http_env_globals env; - struct php_http_persistent_handle_globals persistent_handle; - struct php_http_request_datashare_globals request_datashare; -#if PHP_HTTP_HAVE_CURL && PHP_HTTP_HAVE_EVENT - struct php_http_curl_globals curl; -#endif -ZEND_END_MODULE_GLOBALS(php_http) - -ZEND_EXTERN_MODULE_GLOBALS(php_http); - -#ifdef ZTS -# include "TSRM/TSRM.h" -# define PHP_HTTP_G ((zend_php_http_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(php_http_globals_id)]) -# undef TSRMLS_FETCH_FROM_CTX -# define TSRMLS_FETCH_FROM_CTX(ctx) void ***tsrm_ls = ((ctx)?(ctx):ts_resource_ex(0, NULL)) -#else -# define PHP_HTTP_G (&php_http_globals) -#endif - - #endif /* PHP_EXT_HTTP_H */ /* diff --git a/php_http_api.h b/php_http_api.h new file mode 100644 index 0000000..5cf64c9 --- /dev/null +++ b/php_http_api.h @@ -0,0 +1,130 @@ +/* + +--------------------------------------------------------------------+ + | PECL :: http | + +--------------------------------------------------------------------+ + | Redistribution and use in source and binary forms, with or without | + | modification, are permitted provided that the conditions mentioned | + | in the accompanying LICENSE file are met. | + +--------------------------------------------------------------------+ + | Copyright (c) 2004-2011, Michael Wallner | + +--------------------------------------------------------------------+ +*/ + +#ifndef PHP_HTTP_API_H +#define PHP_HTTP_API_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#if defined(PHP_WIN32) +# if defined(PHP_HTTP_EXPORTS) +# define PHP_HTTP_API __declspec(dllexport) +# elif defined(COMPILE_DL_HTTP) +# define PHP_HTTP_API __declspec(dllimport) +# else +# define PHP_HTTP_API +# endif +#else +# define PHP_HTTP_API +#endif + +/* make functions that return SUCCESS|FAILURE more obvious */ +typedef int STATUS; + +#if (defined(HAVE_ICONV) || defined(PHP_HTTP_HAVE_EXT_ICONV)) && (PHP_HTTP_SHARED_DEPS || !defined(COMPILE_DL_ICONV)) +# define PHP_HTTP_HAVE_ICONV +#endif + +#if (defined(HAVE_HASH_EXT) || defined(PHP_HTTP_HAVE_EXT_HASH)) && (PHP_HTTP_SHARED_DEPS || !defined(COMPILE_DL_HASH)) && defined(PHP_HTTP_HAVE_PHP_HASH_H) +# define PHP_HTTP_HAVE_HASH +#endif + +#ifdef PHP_WIN32 +# define CURL_STATICLIB +# define PHP_HTTP_HAVE_NETDB +# include +#elif defined(HAVE_NETDB_H) +# define PHP_HTTP_HAVE_NETDB +# include +# ifdef HAVE_UNISTD_H +# include +# endif +#endif + +#include +#define PHP_HTTP_IS_CTYPE(type, c) is##type((int) (unsigned char) (c)) +#define PHP_HTTP_TO_CTYPE(type, c) to##type((int) (unsigned char) (c)) + +#include "php_http_buffer.h" +#include "php_http_strlist.h" +#include "php_http_misc.h" +#include "php_http_resource_factory.h" + +#include "php_http.h" +#include "php_http_cookie.h" +#include "php_http_curl.h" +#include "php_http_encoding.h" +#include "php_http_env.h" +#include "php_http_env_response.h" +#include "php_http_etag.h" +#include "php_http_exception.h" +#include "php_http_filter.h" +#include "php_http_header_parser.h" +#include "php_http_headers.h" +#include "php_http_info.h" +#include "php_http_message.h" +#include "php_http_message_body.h" +#include "php_http_message_parser.h" +#include "php_http_negotiate.h" +#include "php_http_neon.h" +#include "php_http_object.h" +#include "php_http_params.h" +#include "php_http_persistent_handle.h" +#include "php_http_property_proxy.h" +#include "php_http_querystring.h" +#include "php_http_request.h" +#include "php_http_request_datashare.h" +#include "php_http_request_factory.h" +#include "php_http_request_method.h" +#include "php_http_request_pool.h" +#include "php_http_serf.h" +#include "php_http_url.h" +#include "php_http_version.h" + +ZEND_BEGIN_MODULE_GLOBALS(php_http) + struct php_http_env_globals env; + struct php_http_persistent_handle_globals persistent_handle; + struct php_http_request_datashare_globals request_datashare; +#if PHP_HTTP_HAVE_CURL && PHP_HTTP_HAVE_EVENT + struct php_http_curl_globals curl; +#endif +ZEND_END_MODULE_GLOBALS(php_http) + +ZEND_EXTERN_MODULE_GLOBALS(php_http); + +#ifdef ZTS +# include "TSRM/TSRM.h" +# define PHP_HTTP_G ((zend_php_http_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(php_http_globals_id)]) +# undef TSRMLS_FETCH_FROM_CTX +# define TSRMLS_FETCH_FROM_CTX(ctx) void ***tsrm_ls = ((ctx)?(ctx):ts_resource_ex(0, NULL)) +#else +# define PHP_HTTP_G (&php_http_globals) +#endif + +#endif /* PHP_HTTP_API_H */ + + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/php_http_buffer.c b/php_http_buffer.c index 7736259..5a3927e 100644 --- a/php_http_buffer.c +++ b/php_http_buffer.c @@ -10,7 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php.h" +#include #include "php_http_buffer.h" PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_init_ex(php_http_buffer_t *buf, size_t chunk_size, int flags) diff --git a/php_http_cookie.c b/php_http_cookie.c index ca437ec..8066f82 100644 --- a/php_http_cookie.c +++ b/php_http_cookie.c @@ -10,7 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" #include diff --git a/php_http_curl.c b/php_http_curl.c index adf7885..5e58828 100644 --- a/php_http_curl.c +++ b/php_http_curl.c @@ -10,13 +10,10 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" #if PHP_HTTP_HAVE_CURL -#include "php_http_request.h" -#include "php_http_request_pool.h" - #include #define PHP_HTTP_CURL_VERSION(x, y, z) (LIBCURL_VERSION_NUM >= (((x)<<16) + ((y)<<8) + (z))) @@ -25,7 +22,6 @@ #endif #include -#include typedef struct php_http_curl_request { diff --git a/php_http_curl.h b/php_http_curl.h index bd1c61a..398c3ae 100644 --- a/php_http_curl.h +++ b/php_http_curl.h @@ -15,6 +15,10 @@ #if PHP_HTTP_HAVE_CURL +#include "php_http_request.h" +#include "php_http_request_pool.h" +#include "php_http_request_datashare.h" + PHP_HTTP_API php_http_request_ops_t *php_http_curl_get_request_ops(void); PHP_HTTP_API php_http_request_pool_ops_t *php_http_curl_get_request_pool_ops(void); PHP_HTTP_API php_http_request_datashare_ops_t *php_http_curl_get_request_datashare_ops(void); diff --git a/php_http_encoding.c b/php_http_encoding.c index 48eb1c3..b34594c 100644 --- a/php_http_encoding.c +++ b/php_http_encoding.c @@ -10,7 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" #include diff --git a/php_http_env.c b/php_http_env.c index f8485f5..789f42b 100644 --- a/php_http_env.c +++ b/php_http_env.c @@ -10,9 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" - -#include
+#include "php_http_api.h" PHP_RINIT_FUNCTION(http_env) { diff --git a/php_http_env.h b/php_http_env.h index 8fbc6c8..62e22cd 100644 --- a/php_http_env.h +++ b/php_http_env.h @@ -14,7 +14,6 @@ #define PHP_HTTP_ENV_H #include "php_http_message_body.h" -#include "php_http_encoding.h" #include "php_http_version.h" struct php_http_env_globals { diff --git a/php_http_env_response.c b/php_http_env_response.c index 0d47904..bc30b3c 100644 --- a/php_http_env_response.c +++ b/php_http_env_response.c @@ -10,9 +10,8 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" -#include
#include #include diff --git a/php_http_etag.c b/php_http_etag.c index 543ce5f..891717d 100644 --- a/php_http_etag.c +++ b/php_http_etag.c @@ -10,9 +10,9 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" -#if PHP_HTTP_HAVE_HASH +#ifdef PHP_HTTP_HAVE_HASH # include "php_hash.h" #endif @@ -25,7 +25,7 @@ PHP_HTTP_API php_http_etag_t *php_http_etag_init(const char *mode TSRMLS_DC) void *ctx; php_http_etag_t *e; -#if PHP_HTTP_HAVE_HASH +#ifdef PHP_HTTP_HAVE_HASH const php_hash_ops *eho = NULL; if (mode && (eho = php_hash_fetch_ops(mode, strlen(mode)))) { @@ -57,7 +57,7 @@ PHP_HTTP_API char *php_http_etag_finish(php_http_etag_t *e) unsigned char digest[128] = {0}; char *etag = NULL; -#if PHP_HTTP_HAVE_HASH +#ifdef PHP_HTTP_HAVE_HASH const php_hash_ops *eho = NULL; if (e->mode && (eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) { @@ -84,7 +84,7 @@ PHP_HTTP_API char *php_http_etag_finish(php_http_etag_t *e) PHP_HTTP_API size_t php_http_etag_update(php_http_etag_t *e, const char *data_ptr, size_t data_len) { -#if PHP_HTTP_HAVE_HASH +#ifdef PHP_HTTP_HAVE_HASH const php_hash_ops *eho = NULL; if (e->mode && (eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) { diff --git a/php_http_exception.c b/php_http_exception.c index 698e047..99c3648 100644 --- a/php_http_exception.c +++ b/php_http_exception.c @@ -10,9 +10,9 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" -#include +#include #ifndef PHP_HTTP_DBG_EXCEPTIONS # define PHP_HTTP_DBG_EXCEPTIONS 0 diff --git a/php_http_filter.c b/php_http_filter.c index cdbc408..9b1c8db 100644 --- a/php_http_filter.c +++ b/php_http_filter.c @@ -10,7 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" PHP_MINIT_FUNCTION(http_filter) { diff --git a/php_http_header_parser.c b/php_http_header_parser.c index d0b6c52..2ad9022 100644 --- a/php_http_header_parser.c +++ b/php_http_header_parser.c @@ -10,7 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" typedef struct php_http_header_parser_state_spec { php_http_header_parser_state_t state; diff --git a/php_http_headers.c b/php_http_headers.c index a2e59de..3173edb 100644 --- a/php_http_headers.c +++ b/php_http_headers.c @@ -10,9 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" - -#include +#include "php_http_api.h" PHP_HTTP_API STATUS php_http_headers_parse(const char *header, size_t length, HashTable *headers, php_http_info_callback_t callback_func, void **callback_data TSRMLS_DC) { diff --git a/php_http_info.c b/php_http_info.c index 80d4ad8..3bde791 100644 --- a/php_http_info.c +++ b/php_http_info.c @@ -10,7 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" PHP_HTTP_API void php_http_info_default_callback(void **nothing, HashTable **headers, php_http_info_t *info TSRMLS_DC) { diff --git a/php_http_message.c b/php_http_message.c index a99a0bb..07f793b 100644 --- a/php_http_message.c +++ b/php_http_message.c @@ -10,11 +10,11 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" -#include
+#include #include -#include +#include PHP_HTTP_API zend_bool php_http_message_info_callback(php_http_message_t **message, HashTable **headers, php_http_info_t *info TSRMLS_DC) { diff --git a/php_http_message.h b/php_http_message.h index 1890e57..db47fc6 100644 --- a/php_http_message.h +++ b/php_http_message.h @@ -13,6 +13,8 @@ #ifndef PHP_HTTP_MESSAGE_H #define PHP_HTTP_MESSAGE_H +#include "php_http_message_body.h" + /* required minimum length of an HTTP message "HTTP/1.1" */ #define PHP_HTTP_MESSAGE_MIN_SIZE 8 #define PHP_HTTP_MESSAGE_TYPE(TYPE, msg) ((msg) && ((msg)->type == PHP_HTTP_ ##TYPE)) diff --git a/php_http_message_body.c b/php_http_message_body.c index a52e826..cfe0f48 100644 --- a/php_http_message_body.c +++ b/php_http_message_body.c @@ -10,9 +10,8 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" -#include #include #include diff --git a/php_http_message_parser.c b/php_http_message_parser.c index 3eb8571..cf4d4fa 100644 --- a/php_http_message_parser.c +++ b/php_http_message_parser.c @@ -10,7 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" typedef struct php_http_message_parser_state_spec { php_http_message_parser_state_t state; diff --git a/php_http_misc.c b/php_http_misc.c index db588ea..4df85cf 100644 --- a/php_http_misc.c +++ b/php_http_misc.c @@ -10,11 +10,11 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" #include #include -#include +#include /* SLEEP */ @@ -37,7 +37,7 @@ PHP_HTTP_API void php_http_sleep(double s) #else struct timeval timeout; - timeout.tv.sec = (time_t) s; + timeout.tv_sec = (time_t) s; timeout.tv_usec = PHP_HTTP_USEC(s) % PHP_HTTP_MCROSEC; select(0, NULL, NULL, NULL, &timeout); diff --git a/php_http_negotiate.c b/php_http_negotiate.c index 9365ce6..928a31d 100644 --- a/php_http_negotiate.c +++ b/php_http_negotiate.c @@ -10,7 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" #include diff --git a/php_http_neon.c b/php_http_neon.c index 97ebc62..7bf1069 100644 --- a/php_http_neon.c +++ b/php_http_neon.c @@ -10,7 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" #if PHP_HTTP_HAVE_NEON diff --git a/php_http_neon.h b/php_http_neon.h index 512dabe..19b522d 100644 --- a/php_http_neon.h +++ b/php_http_neon.h @@ -15,6 +15,8 @@ #if PHP_HTTP_HAVE_NEON +#include "php_http_request.h" + php_http_request_ops_t *php_http_neon_get_request_ops(void); PHP_MINIT_FUNCTION(http_neon); diff --git a/php_http_object.c b/php_http_object.c index 215ae8c..39e9116 100644 --- a/php_http_object.c +++ b/php_http_object.c @@ -10,7 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" STATUS php_http_new(zend_object_value *ov, zend_class_entry *ce, php_http_new_t create, zend_class_entry *parent_ce, void *intern_ptr, void **obj_ptr TSRMLS_DC) { @@ -150,6 +150,7 @@ PHP_METHOD(HttpObject, setErrorHandling) default: php_http_error(HE_WARNING, PHP_HTTP_E_RUNTIME, "unknown error handling code (%ld)", eh); + break; } } @@ -175,6 +176,7 @@ PHP_METHOD(HttpObject, setDefaultErrorHandling) default: php_http_error(HE_WARNING, PHP_HTTP_E_RUNTIME, "unknown error handling code (%ld)", eh); + break; } } } diff --git a/php_http_params.c b/php_http_params.c index f7c7b7b..4b0e3f4 100644 --- a/php_http_params.c +++ b/php_http_params.c @@ -10,10 +10,10 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" #include -#include +#include static php_http_params_token_t def_param_sep = {",", 1}, *def_param_sep_ptr[] = {&def_param_sep, NULL}; static php_http_params_token_t def_arg_sep = {";", 1}, *def_arg_sep_ptr[] = {&def_arg_sep, NULL}; diff --git a/php_http_persistent_handle.c b/php_http_persistent_handle.c index 06a5024..5842035 100644 --- a/php_http_persistent_handle.c +++ b/php_http_persistent_handle.c @@ -10,7 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" #ifndef PHP_HTTP_DEBUG_PHANDLES # define PHP_HTTP_DEBUG_PHANDLES 0 diff --git a/php_http_persistent_handle.h b/php_http_persistent_handle.h index 19b84b7..4c43374 100644 --- a/php_http_persistent_handle.h +++ b/php_http_persistent_handle.h @@ -13,8 +13,6 @@ #ifndef PHP_HTTP_PERSISTENT_HANDLE_H #define PHP_HTTP_PERSISTENT_HANDLE_H -#include "php_http_resource_factory.h" - typedef struct php_http_persistent_handle_factory { void *provider; diff --git a/php_http_property_proxy.c b/php_http_property_proxy.c index 908ae9f..ff768ba 100644 --- a/php_http_property_proxy.c +++ b/php_http_property_proxy.c @@ -10,7 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" php_http_property_proxy_t *php_http_property_proxy_init(php_http_property_proxy_t *proxy, zval *object, zval *member TSRMLS_DC) { diff --git a/php_http_querystring.c b/php_http_querystring.c index 364d2ee..eeeeb20 100644 --- a/php_http_querystring.c +++ b/php_http_querystring.c @@ -10,11 +10,11 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" -#include
+#include #include -#include +#include #ifdef PHP_HTTP_HAVE_ICONV # undef PHP_ATOM_INC diff --git a/php_http_request.c b/php_http_request.c index d65ea5c..9bd820c 100644 --- a/php_http_request.c +++ b/php_http_request.c @@ -10,11 +10,10 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" #include #include -#include PHP_HTTP_API php_http_request_t *php_http_request_init(php_http_request_t *h, php_http_request_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC) { @@ -546,6 +545,7 @@ STATUS php_http_request_object_responsehandler(php_http_request_object_t *obj, z static int apply_pretty_key(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) { if (hash_key->arKey && hash_key->nKeyLength > 1) { + /* FIXME: this seems evil */ hash_key->h = zend_hash_func(php_http_pretty_key(hash_key->arKey, hash_key->nKeyLength - 1, 1, 0), hash_key->nKeyLength); } return ZEND_HASH_APPLY_KEEP; diff --git a/php_http_request.h b/php_http_request.h index 5dc0750..6c0c0c9 100644 --- a/php_http_request.h +++ b/php_http_request.h @@ -13,9 +13,9 @@ #ifndef PHP_HTTP_REQUEST_H #define PHP_HTTP_REQUEST_H +#include "php_http_request_method.h" #include "php_http_message_body.h" #include "php_http_message_parser.h" -#include "php_http_request_method.h" typedef struct php_http_request_progress_state { struct { diff --git a/php_http_request_datashare.c b/php_http_request_datashare.c index 182ff1a..8bbaeb9 100644 --- a/php_http_request_datashare.c +++ b/php_http_request_datashare.c @@ -10,7 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" #include #include diff --git a/php_http_request_datashare.h b/php_http_request_datashare.h index 7a30b66..5ef6328 100644 --- a/php_http_request_datashare.h +++ b/php_http_request_datashare.h @@ -13,8 +13,6 @@ #ifndef PHP_HTTP_REQUEST_DATASHARE_H #define PHP_HTTP_REQUEST_DATASHARE_H -#include "php_http_request.h" - typedef enum php_http_request_datashare_setopt_opt { PHP_HTTP_REQUEST_DATASHARE_OPT_COOKIES, PHP_HTTP_REQUEST_DATASHARE_OPT_RESOLVER, diff --git a/php_http_request_factory.c b/php_http_request_factory.c index f13318e..e69f6d1 100644 --- a/php_http_request_factory.c +++ b/php_http_request_factory.c @@ -10,11 +10,10 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" #include #include -#include /* * array of name => php_http_request_factory_driver_t* diff --git a/php_http_request_factory.h b/php_http_request_factory.h index 04db43b..f443c12 100644 --- a/php_http_request_factory.h +++ b/php_http_request_factory.h @@ -15,6 +15,7 @@ #include "php_http_request.h" #include "php_http_request_pool.h" +#include "php_http_request_datashare.h" typedef struct php_http_request_factory_driver { php_http_request_ops_t *request_ops; diff --git a/php_http_request_info.c b/php_http_request_info.c index ecfe8cd..a75cd0c 100644 --- a/php_http_request_info.c +++ b/php_http_request_info.c @@ -10,7 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" PHP_HTTP_API void php_http_request_info(php_http_request_t *request, HashTable *info) { diff --git a/php_http_request_method.c b/php_http_request_method.c index b4b3567..654ae8c 100644 --- a/php_http_request_method.c +++ b/php_http_request_method.c @@ -10,9 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" - -#include +#include "php_http_api.h" static PHP_HTTP_STRLIST(php_http_request_methods) = PHP_HTTP_STRLIST_ITEM("UNKNOWN") diff --git a/php_http_request_pool.c b/php_http_request_pool.c index ec3e5ca..0876809 100644 --- a/php_http_request_pool.c +++ b/php_http_request_pool.c @@ -10,9 +10,8 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" -#include #include PHP_HTTP_API php_http_request_pool_t *php_http_request_pool_init(php_http_request_pool_t *h, php_http_request_pool_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC) diff --git a/php_http_request_pool.h b/php_http_request_pool.h index d2b6eb4..9984642 100644 --- a/php_http_request_pool.h +++ b/php_http_request_pool.h @@ -13,8 +13,6 @@ #ifndef PHP_HTTP_REQUESTPOOL_H #define PHP_HTTP_REQUESTPOOL_H -#include "php_http_request.h" - typedef enum php_http_request_pool_setopt_opt { PHP_HTTP_REQUEST_POOL_OPT_ENABLE_PIPELINING, PHP_HTTP_REQUEST_POOL_OPT_USE_EVENTS, diff --git a/php_http_resource_factory.c b/php_http_resource_factory.c index 390d882..3135e47 100644 --- a/php_http_resource_factory.c +++ b/php_http_resource_factory.c @@ -10,8 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" -#include "php_http_resource_factory.h" +#include "php_http_api.h" PHP_HTTP_API php_http_resource_factory_t *php_http_resource_factory_init(php_http_resource_factory_t *f, php_http_resource_factory_ops_t *fops, void *data, void (*dtor)(void *data)) { diff --git a/php_http_strlist.c b/php_http_strlist.c index ee46786..35acf40 100644 --- a/php_http_strlist.c +++ b/php_http_strlist.c @@ -10,7 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" PHP_HTTP_API php_http_strlist_iterator_t *php_http_strlist_iterator_init(php_http_strlist_iterator_t *iter, const char list[], unsigned factor) { diff --git a/php_http_url.c b/php_http_url.c index fd4ec2b..7fe1664 100644 --- a/php_http_url.c +++ b/php_http_url.c @@ -10,9 +10,9 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" -#include
+#include #include static inline char *localhostname(void) diff --git a/php_http_version.c b/php_http_version.c index 4561b8f..ffe62f1 100644 --- a/php_http_version.c +++ b/php_http_version.c @@ -10,7 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" +#include "php_http_api.h" PHP_HTTP_API php_http_version_t *php_http_version_init(php_http_version_t *v, unsigned major, unsigned minor TSRMLS_DC) { diff --git a/reflection2php.php b/reflection2php.php index 4f04c28..7768eeb 100755 --- a/reflection2php.php +++ b/reflection2php.php @@ -32,6 +32,31 @@ if (!strlen($ext = $argv[1])) die(sprintf("Usage: %s \n", $argv[0])); $ext = new ReflectionExtension($ext); +foreach ($ext->getConstants() as $constant => $value) { + printf("const %s = %s;\n", $constant, $value); +} +printf("\n"); + +foreach ($ext->getFunctions() as $f) { + printf("function %s(", $f->getName()); + $ps = array(); + foreach ($f->getParameters() as $p) { + $p1 = sprintf("%s%s\$%s", t($p), $p->isPassedByReference()?"&":"", $p->getName()); + if ($p->isOptional()) { + if ($p->isDefaultValueAvailable()) { + $p1 .= sprintf(" = %s", var_export($p->getDefaultValue(), true)); + } elseif (!($p->isArray() || $p->getClass()) || $p->allowsNull()) { + $p1 .= " = NULL"; + } elseif ($p->isArray()) { + $p1 .= " = array()"; + } + } + $ps[] = $p1; + } + printf("%s) {\n}\n", implode(", ", $ps)); +} +printf("\n"); + foreach ($ext->getClasses() as $class) { printf("%s%s %s ", m($class->getModifiers()), $class->isInterface() ? "interface":"class" ,$class->getName()); @@ -62,11 +87,15 @@ foreach ($ext->getClasses() as $class) { $ps = array(); foreach ($m->getParameters() as $p) { $p1 = sprintf("%s%s\$%s", t($p), $p->isPassedByReference()?"&":"", $p->getName()); - if ($p->isDefaultValueAvailable()) { - $p1 .= sprintf(" = %s", var_export($p->getDefaultValue(), true)); - } elseif ($p->allowsNull() || $p->isOptional()) { - $p1 .= sprintf(" = NULL"); - } + if ($p->isOptional()) { + if ($p->isDefaultValueAvailable()) { + $p1 .= sprintf(" = %s", var_export($p->getDefaultValue(), true)); + } elseif (!($p->isArray() || $p->getClass()) || $p->allowsNull()) { + $p1 .= sprintf(" = NULL"); + } elseif ($p->isArray()) { + $p1 .= " = array()"; + } + } $ps[] = $p1; } printf("%s) {\n\t}\n", implode(", ", $ps)); diff --git a/tests/requestpool001.phpt b/tests/requestpool001.phpt index 3ca1683..a65ada4 100644 --- a/tests/requestpool001.phpt +++ b/tests/requestpool001.phpt @@ -122,7 +122,7 @@ define('RMAX', 10); chdir(__DIR__); $time = microtime(true); -$factory = new HttpRequestFactory("curl", array("requestPoolClass" => "Pool")); +$factory = new HttpRequestFactory(array("driver" => "curl", "requestPoolClass" => "Pool")); $factory->createPool()->run($factory); printf("Elapsed: %0.3fs\n", microtime(true)-$time);