header cleanups and fix some warnings
authorMichael Wallner <mike@php.net>
Mon, 9 Jan 2012 17:39:57 +0000 (17:39 +0000)
committerMichael Wallner <mike@php.net>
Mon, 9 Jan 2012 17:39:57 +0000 (17:39 +0000)
47 files changed:
php_http.c
php_http.h
php_http_api.h [new file with mode: 0644]
php_http_buffer.c
php_http_cookie.c
php_http_curl.c
php_http_curl.h
php_http_encoding.c
php_http_env.c
php_http_env.h
php_http_env_response.c
php_http_etag.c
php_http_exception.c
php_http_filter.c
php_http_header_parser.c
php_http_headers.c
php_http_info.c
php_http_message.c
php_http_message.h
php_http_message_body.c
php_http_message_parser.c
php_http_misc.c
php_http_negotiate.c
php_http_neon.c
php_http_neon.h
php_http_object.c
php_http_params.c
php_http_persistent_handle.c
php_http_persistent_handle.h
php_http_property_proxy.c
php_http_querystring.c
php_http_request.c
php_http_request.h
php_http_request_datashare.c
php_http_request_datashare.h
php_http_request_factory.c
php_http_request_factory.h
php_http_request_info.c
php_http_request_method.c
php_http_request_pool.c
php_http_request_pool.h
php_http_resource_factory.c
php_http_strlist.c
php_http_url.c
php_http_version.c
reflection2php.php
tests/requestpool001.phpt

index 9e97610..cd95f48 100644 (file)
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
+
+#include <php_ini.h>
+#include <ext/standard/php_string.h>
+#include <ext/standard/info.h>
 
 #include <zlib.h>
+
 #if PHP_HTTP_HAVE_CURL
 #      include <curl/curl.h>
 #      if PHP_HTTP_HAVE_EVENT
 #      endif
 #endif
 #if PHP_HTTP_HAVE_NEON
-#      include "neon/ne_utils.h"
+#      include <neon/ne_utils.h>
 #endif
 #if PHP_HTTP_HAVE_SERF
-#      include "serf.h"
+#      include <serf.h>
 #endif
 
-#include <main/php_ini.h>
-#include <ext/standard/info.h>
-#include <Zend/zend_extensions.h>
-
 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}
index 3ea3f3d..94ed04e 100644 (file)
 
 #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 <winsock2.h>
-#elif defined(HAVE_NETDB_H)
-#      define PHP_HTTP_HAVE_NETDB
-#      include <netdb.h>
-#      ifdef HAVE_UNISTD_H
-#              include <unistd.h>
-#      endif
-#endif
-
-#include <ctype.h>
-#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 (file)
index 0000000..5cf64c9
--- /dev/null
@@ -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 <mike@php.net>            |
+    +--------------------------------------------------------------------+
+*/
+
+#ifndef PHP_HTTP_API_H
+#define PHP_HTTP_API_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <php.h>
+#include <php_config.h>
+#include <SAPI.h>
+#include <zend_interfaces.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;
+
+#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 <winsock2.h>
+#elif defined(HAVE_NETDB_H)
+#      define PHP_HTTP_HAVE_NETDB
+#      include <netdb.h>
+#      ifdef HAVE_UNISTD_H
+#              include <unistd.h>
+#      endif
+#endif
+
+#include <ctype.h>
+#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
+ */
index 7736259..5a3927e 100644 (file)
@@ -10,7 +10,7 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php.h"
+#include <php.h>
 #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)
index ca437ec..8066f82 100644 (file)
@@ -10,7 +10,7 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
 #include <ext/date/php_date.h>
 
index adf7885..5e58828 100644 (file)
     +--------------------------------------------------------------------+
 */
 
-#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 <curl/curl.h>
 #define PHP_HTTP_CURL_VERSION(x, y, z) (LIBCURL_VERSION_NUM >= (((x)<<16) + ((y)<<8) + (z)))
 
@@ -25,7 +22,6 @@
 #endif
 
 #include <ext/spl/spl_iterators.h>
-#include <Zend/zend_interfaces.h>
 
 
 typedef struct php_http_curl_request {
index bd1c61a..398c3ae 100644 (file)
 
 #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);
index 48eb1c3..b34594c 100644 (file)
@@ -10,7 +10,7 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
 #include <zlib.h>
 
index f8485f5..789f42b 100644 (file)
@@ -10,9 +10,7 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
-
-#include <main/SAPI.h>
+#include "php_http_api.h"
 
 PHP_RINIT_FUNCTION(http_env)
 {
index 8fbc6c8..62e22cd 100644 (file)
@@ -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 {
index 0d47904..bc30b3c 100644 (file)
@@ -10,9 +10,8 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
-#include <main/SAPI.h>
 #include <ext/date/php_date.h>
 #include <ext/standard/php_string.h>
 
index 543ce5f..891717d 100644 (file)
@@ -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)))) {
index 698e047..99c3648 100644 (file)
@@ -10,9 +10,9 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
-#include <Zend/zend_exceptions.h>
+#include <zend_exceptions.h>
 
 #ifndef PHP_HTTP_DBG_EXCEPTIONS
 #      define PHP_HTTP_DBG_EXCEPTIONS 0
index cdbc408..9b1c8db 100644 (file)
@@ -10,7 +10,7 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
 PHP_MINIT_FUNCTION(http_filter)
 {
index d0b6c52..2ad9022 100644 (file)
@@ -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;
index a2e59de..3173edb 100644 (file)
@@ -10,9 +10,7 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
-
-#include <Zend/zend_interfaces.h>
+#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)
 {
index 80d4ad8..3bde791 100644 (file)
@@ -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)
 {
index a99a0bb..07f793b 100644 (file)
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
-#include <main/SAPI.h>
+#include <SAPI.h>
 #include <ext/spl/spl_iterators.h>
-#include <Zend/zend_interfaces.h>
+#include <zend_interfaces.h>
 
 PHP_HTTP_API zend_bool php_http_message_info_callback(php_http_message_t **message, HashTable **headers, php_http_info_t *info TSRMLS_DC)
 {
index 1890e57..db47fc6 100644 (file)
@@ -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))
index a52e826..cfe0f48 100644 (file)
@@ -10,9 +10,8 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
-#include <libgen.h>
 #include <ext/standard/php_lcg.h>
 #include <ext/standard/php_string.h>
 
index 3eb8571..cf4d4fa 100644 (file)
@@ -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;
index db588ea..4df85cf 100644 (file)
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
 #include <ext/standard/php_lcg.h>
 #include <ext/standard/php_string.h>
-#include <Zend/zend_exceptions.h>
+#include <zend_exceptions.h>
 
 /* 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);
index 9365ce6..928a31d 100644 (file)
@@ -10,7 +10,7 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
 #include <ext/standard/php_string.h>
 
index 97ebc62..7bf1069 100644 (file)
@@ -10,7 +10,7 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
 #if PHP_HTTP_HAVE_NEON
 
index 512dabe..19b522d 100644 (file)
@@ -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);
index 215ae8c..39e9116 100644 (file)
@@ -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;
                }
        }
 }
index f7c7b7b..4b0e3f4 100644 (file)
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
 #include <ext/standard/php_string.h>
-#include <Zend/zend_interfaces.h>
+#include <zend_interfaces.h>
 
 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};
index 06a5024..5842035 100644 (file)
@@ -10,7 +10,7 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
 #ifndef PHP_HTTP_DEBUG_PHANDLES
 #      define PHP_HTTP_DEBUG_PHANDLES 0
index 19b84b7..4c43374 100644 (file)
@@ -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;
 
index 908ae9f..ff768ba 100644 (file)
@@ -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)
 {
index 364d2ee..eeeeb20 100644 (file)
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
-#include <main/php_variables.h>
+#include <php_variables.h>
 #include <ext/spl/spl_array.h>
-#include <Zend/zend_interfaces.h>
+#include <zend_interfaces.h>
 
 #ifdef PHP_HTTP_HAVE_ICONV
 #      undef PHP_ATOM_INC
index d65ea5c..9bd820c 100644 (file)
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
 #include <ext/spl/spl_observer.h>
 #include <ext/spl/spl_iterators.h>
-#include <Zend/zend_interfaces.h>
 
 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;
index 5dc0750..6c0c0c9 100644 (file)
@@ -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 {
index 182ff1a..8bbaeb9 100644 (file)
@@ -10,7 +10,7 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
 #include <curl/curl.h>
 #include <ext/standard/php_string.h>
index 7a30b66..5ef6328 100644 (file)
@@ -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,
index f13318e..e69f6d1 100644 (file)
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
 #include <ext/standard/php_string.h>
 #include <ext/spl/spl_observer.h>
-#include <Zend/zend_interfaces.h>
 
 /*
  * array of name => php_http_request_factory_driver_t*
index 04db43b..f443c12 100644 (file)
@@ -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;
index ecfe8cd..a75cd0c 100644 (file)
@@ -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)
 {
index b4b3567..654ae8c 100644 (file)
@@ -10,9 +10,7 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
-
-#include <Zend/zend_interfaces.h>
+#include "php_http_api.h"
 
 static PHP_HTTP_STRLIST(php_http_request_methods) =
        PHP_HTTP_STRLIST_ITEM("UNKNOWN")
index ec3e5ca..0876809 100644 (file)
@@ -10,9 +10,8 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
-#include <Zend/zend_interfaces.h>
 #include <ext/spl/spl_iterators.h>
 
 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)
index d2b6eb4..9984642 100644 (file)
@@ -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,
index 390d882..3135e47 100644 (file)
@@ -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))
 {
index ee46786..35acf40 100644 (file)
@@ -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)
 {
index fd4ec2b..7fe1664 100644 (file)
@@ -10,9 +10,9 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
-#include <main/SAPI.h>
+#include <SAPI.h>
 #include <ext/standard/php_string.h>
 
 static inline char *localhostname(void)
index 4561b8f..ffe62f1 100644 (file)
@@ -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)
 {
index 4f04c28..7768eeb 100755 (executable)
@@ -32,6 +32,31 @@ if (!strlen($ext = $argv[1]))
        die(sprintf("Usage: %s <ext>\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));
index 3ca1683..a65ada4 100644 (file)
@@ -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);