X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=http_curl_api.c;h=3dc462cdc95a3f8d539121b0efdfc2d23fcd4802;hb=fc73263920c3b5af2f0266d51cd80c0a50017807;hp=9ee8afedb7401ca21427f20404d0561e857bd7e8;hpb=a268ede6ed45dc674906efd6fc8710012841e75e;p=m6w6%2Fext-http diff --git a/http_curl_api.c b/http_curl_api.c index 9ee8afe..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) \ { \