X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_curl_api.c;h=3dc462cdc95a3f8d539121b0efdfc2d23fcd4802;hp=0669db4d22f6d9379f5f18872f9a288aa64b5879;hb=fc73263920c3b5af2f0266d51cd80c0a50017807;hpb=c201441545e852d5d2b6d359a772211995350575 diff --git a/http_curl_api.c b/http_curl_api.c index 0669db4..3dc462c 100644 --- a/http_curl_api.c +++ b/http_curl_api.c @@ -20,14 +20,10 @@ #endif #ifdef PHP_WIN32 -# define _WINSOCKAPI_ -# define ZEND_INCLUDE_FULL_WINDOWS_HEADERS # include -# include #endif #include -#include #include "php.h" #include "php_http.h" @@ -49,6 +45,11 @@ ZEND_DECLARE_MODULE_GLOBALS(http) # define http_curl_reset(ch) #endif +/* FIXXME: correct version where strerror is supported! */ +#if LIBCURL_VERSION_NUM < 0x070b01 +# define curl_easy_strerror(code) "unkown error" +#endif + #define http_curl_startup(ch, clean_curl, URL, options) \ if (!ch) { \ if (!(ch = curl_easy_init())) { \ @@ -72,8 +73,6 @@ ZEND_DECLARE_MODULE_GLOBALS(http) } \ } - - #define http_curl_cleanup(ch, clean_curl) \ http_curl_freestr(); \ http_curl_freebuf(); \ @@ -85,11 +84,15 @@ ZEND_DECLARE_MODULE_GLOBALS(http) #define http_curl_freestr() \ zend_llist_clean(&HTTP_G(to_free)) -#define http_curl_initbuf() http_curl_initbuf_ex(0) +#define http_curl_initbuf() \ + http_curl_initbuf_ex(0) #define http_curl_initbuf_ex(chunk_size) \ { \ - size_t size = (chunk_size > 0) ? chunk_size : HTTP_CURLBUF_SIZE; \ + size_t size = chunk_size; \ + if (size < 1) { \ + size = HTTP_CURLBUF_SIZE; \ + } \ http_curl_freebuf(); \ HTTP_G(curlbuf).data = emalloc(size); \ HTTP_G(curlbuf).free = size; \ @@ -106,9 +109,9 @@ ZEND_DECLARE_MODULE_GLOBALS(http) HTTP_G(curlbuf).size = 0; #define http_curl_copybuf(data, size) \ - * size = HTTP_G(curlbuf).used; \ - * data = ecalloc(1, HTTP_G(curlbuf).used + 1); \ - memcpy(* data, HTTP_G(curlbuf).data, * size); + *size = HTTP_G(curlbuf).used; \ + *data = ecalloc(1, HTTP_G(curlbuf).used + 1); \ + memcpy(*data, HTTP_G(curlbuf).data, HTTP_G(curlbuf).used); #define http_curl_sizebuf(for_size) \ { \ @@ -494,7 +497,7 @@ PHP_HTTP_API STATUS _http_get_ex(CURL *ch, const char *URL, HashTable *options, http_curl_startup(ch, clean_curl, URL, options); curl_easy_setopt(ch, CURLOPT_HTTPGET, 1); http_curl_perform(ch, clean_curl); - + if (info) { http_curl_getinfo(ch, info); }