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 9e976106ab79df29fe833683b4af41c0e722e84a..cd95f48d1af30898bdea133b940514b0190cf964 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 3ea3f3da47db3b2b2c66c2e573cdaf69f7bc0d79..94ed04e92afd9df72607be3b1b4bdcf684f65d8b 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 7736259a78622a41827124f22d5792a4dd7d272c..5a3927e17cfc7dc9071641fc2d68da5d65ca6e75 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 ca437ec9cac14183d3517e96a445d36ef586406a..8066f82ff45cc3cbed2f15b96a2bcbf2e2d2059a 100644 (file)
@@ -10,7 +10,7 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
 #include <ext/date/php_date.h>
 
index adf7885a6676246875363224d42fb89e95e15186..5e588283570d87fd64e53df8c5abf5e130ac422a 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 bd1c61ab5f686c6d9f8f9ccc2cf4664aefb0f399..398c3ae39dc63a8d227e89fc579f14665d8c926b 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 48eb1c36eef2bf1436bd857d15a27ad086c81d56..b34594ccbaead8bfc5622065162e449aa8cda7da 100644 (file)
@@ -10,7 +10,7 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
 #include <zlib.h>
 
index f8485f57875a72eab436ac3c15718de70d65f332..789f42b7b84c0ded07280b71402a08aef71091fe 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 8fbc6c868e9a1d443b9e154c68c7f2aa3a5a9cbf..62e22cd1babbc0bdfd9605407833f78ba72891ef 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 0d47904ed0660690221a860619072584a2c1c053..bc30b3c0d1adf50b3e90c4e000f197dd0871dea0 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 543ce5fcf4078721953e94b8edebb7e12c737972..891717d0bf8a6e46573f83a262b1bcd2beafca44 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 698e047b17d91bd25883d9b39167073c628af8b9..99c3648575c3b2e982bb3ca2f75db530104b4ce3 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 cdbc4088b4a5edbf8655144376a3eaece71c79c8..9b1c8db284acccf821ecf56a1f6216c4c2796598 100644 (file)
@@ -10,7 +10,7 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
 PHP_MINIT_FUNCTION(http_filter)
 {
index d0b6c52e4d7aee512262976522c7bd70ae63d7be..2ad902280897ee852982238bd435d7668289fe3b 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 a2e59de13f6872a7379389161ebf17cf0022c16e..3173edb680baa29a27239ad5c635f03de23bc3cd 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 80d4ad8d480696dbc8d80caeadb3300094e0fdf9..3bde791031e12b4d8d7e28849159fd29cf6af656 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 a99a0bb2ecf42ca70e7ab45c4f6379e480b5d62d..07f793b6d1f99e7510381e6882e3d3f021b507e4 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 1890e575bbaa4bc31326e920e611200798cabc7c..db47fc6c226308540e9eeae7ac0ee8b32c835c9d 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 a52e8264acb741c6651ce471265f8eaff1485e19..cfe0f48326d5ce86f29573ef25cdffc28ab61499 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 3eb85719f2e8fe5523852976fef814cc5e8c0cf2..cf4d4fa3ec48cd0aabeea3cac9198770abff7506 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 db588ea6be2697b50971db70f94284c00ad7273d..4df85cfee6b3f421c9e53009bf5a64de502d6839 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 9365ce6c4d437e0de344afc2f449f603962e9fb5..928a31df18a81eaa4d4cbd26bd23dcacea6cca0a 100644 (file)
@@ -10,7 +10,7 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
 #include <ext/standard/php_string.h>
 
index 97ebc628df2b7a378bc0d396abb94a14ce483866..7bf106913ceeb9fb42f27965ce3ec416d4bd6d0b 100644 (file)
@@ -10,7 +10,7 @@
     +--------------------------------------------------------------------+
 */
 
-#include "php_http.h"
+#include "php_http_api.h"
 
 #if PHP_HTTP_HAVE_NEON
 
index 512dabebdac0b48c79517f5517e38b26f2c7aa15..19b522df8186e6b91afb48fbe90a7204dcb595bd 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 215ae8cbceca9b0713ce4af03d0674e2e18b1718..39e9116cbac20e9a95ba3df1d8ddaa33ff3b25ce 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 f7c7b7bb09966895f54bda98e87faa05ced60095..4b0e3f4b72cd20cc4cb6e4b99c4789becb875849 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 06a502458b8108895d3299fcc65cd1e60d14a9b6..5842035ed3a312a306a0450e63e6404c2a76571b 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 19b84b751f74de259127789da022c7714dd53756..4c43374cf2fdeb64c50fc997d2fe80155afa2957 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 908ae9f071214b860c9aeca11b9338d3ed12c0bb..ff768ba2afc3a340a9923237d3ac71d3de8ebf3b 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 364d2ee6bf637f7a24c1e1d2d3c8f232e4908a7c..eeeeb2063842bd5df14ebb611b7889e29813a274 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 d65ea5c3e57e2d4ec6404032388c976f86854f33..9bd820cd80f4ecde228862b56b6d7983bb4ff89a 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 5dc0750c42466bdb86f71d2cf0bfaaae89d1e468..6c0c0c9469cdebabe41b7d94247c66251d322d95 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 182ff1add60dbe72fd4292a907a1a25eede83a7b..8bbaeb99747d2161c34ae42e8e4f77af8d9b8f78 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 7a30b66dd94df2f706b2a91968c39332bdc494a2..5ef63282f3fb59ee9065904d34e0a128fa6b4dac 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 f13318e5b5f09fd33750ec08d7c4ecc92323c606..e69f6d1886849ec2aaa58c7295a6d57c11837303 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 04db43b1d971feff80ce1c5a7fc70c57d86cedac..f443c1296699d61329c02b8e5c2e1bc2511ca613 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 ecfe8cd420d2f9f85ab8defc14e318260c748285..a75cd0cc3f6637aea8c8edfdb85e2226ffe09aae 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 b4b3567e144844e0a1a83a211b9014483771a38e..654ae8c0b13a31c2586f3acefc10007817d73464 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 ec3e5ca9cc8df8998d66fd12189d838086a9e422..08768096071e12aea696f041ac553154f64ccab9 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 d2b6eb47310ed7edc4ae7c58d5c6f3b035831968..9984642823334fa4df09147fed0c966da3444286 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 390d882c155425753396a0b912d44b830aa899f9..3135e4786f2929359c3c81c6af3881ebaefd58ba 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 ee46786e84f705511308250039126a5e9857854b..35acf409323430cd491b1151d4abc54033aa344a 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 fd4ec2bf11db3f06cec4d0cc5080c24dcd3387d2..7fe16645338910d10be2d7fae4751cdd96ef16ea 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 4561b8fbd13d851fa53e3be68f150c7da942b780..ffe62f188851373ebfd243704ff05d0ce2fe5209 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 4f04c28d381670bf21b233abdebcfa0ffb7ac9e4..7768eeb9a65a027979a497bf152408beae469f2d 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 3ca16837c7e4fdaebc48f2030235cfa706ea539a..a65ada45894b0105b33d3d5dbea0f1317f0e29e8 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);