From: Michael Wallner Date: Fri, 23 Mar 2012 09:46:16 +0000 (+0000) Subject: update curl info X-Git-Tag: DEV_2-before-client~6 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=4957436be59f65fae9cdbaec1dc865acc680862f;p=m6w6%2Fext-http update curl info --- diff --git a/gen_curlinfo.php b/gen_curlinfo.php new file mode 100644 index 0000000..726fd48 --- /dev/null +++ b/gen_curlinfo.php @@ -0,0 +1,98 @@ +#!/usr/bin/env php + 'PHP_HTTP_CURL_VERSION(7,19,0)', + 'APPCONNECT_TIME' => 'PHP_HTTP_CURL_VERSION(7,19,0)', + 'CONDITION_UNMET' => 'PHP_HTTP_CURL_VERSION(7,19,4)', + 'PRIMARY_PORT' => 'PHP_HTTP_CURL_VERSION(7,21,0)', + 'LOCAL_PORT' => 'PHP_HTTP_CURL_VERSION(7,21,0)', + 'LOCAL_IP' => 'PHP_HTTP_CURL_VERSION(7,21,0)', +); +$exclude = array( + 'PRIVATE', 'LASTSOCKET', 'FTP_ENTRY_PATH', 'CERTINFO', + 'RTSP_SESSION_ID', 'RTSP_CLIENT_CSEQ', 'RTSP_SERVER_CSEQ', 'RTSP_CSEQ_RECV' +); + +$translate = array( + 'HTTP_CONNECTCODE' => "connect_code", + 'COOKIELIST' => 'cookies', +); + +$templates = array( +'STRING' => +' if (CURLE_OK == curl_easy_getinfo(ch, %s, &c)) { + add_assoc_string_ex(&array, "%s", sizeof("%2$s"), c ? c : "", 1); + } +', +'DOUBLE' => +' if (CURLE_OK == curl_easy_getinfo(ch, %s, &d)) { + add_assoc_double_ex(&array, "%s", sizeof("%2$s"), d); + } +', +'LONG' => +' if (CURLE_OK == curl_easy_getinfo(ch, %s, &l)) { + add_assoc_long_ex(&array, "%s", sizeof("%2$s"), l); + } +', +'SLIST' => +' if (CURLE_OK == curl_easy_getinfo(ch, %s, &s)) { + MAKE_STD_ZVAL(subarray); + array_init(subarray); + for (p = s; p; p = p->next) { + if (p->data) { + add_next_index_string(subarray, p->data, 1); + } + } + add_assoc_zval_ex(&array, "%s", sizeof("%2$s"), subarray); + curl_slist_free_all(s); + } +', +); + +$infos = file_re('curl.h', '/^\s*(CURLINFO_(\w+))\s*=\s*CURLINFO_(STRING|LONG|DOUBLE|SLIST)\s*\+\s*\d+\s*,?\s*$/m'); + +ob_start(); +foreach ($infos as $info) { + list(, $full, $short, $type) = $info; + if (in_array($short, $exclude)) continue; + if (isset($ifdefs[$short])) printf("#if %s\n", $ifdefs[$short]); + printf($templates[$type], $full, strtolower((isset($translate[$short])) ? $translate[$short] : $short)); + if (isset($ifdefs[$short])) printf("#endif\n"); +} + +file_put_contents("php_http_curl.c", + preg_replace('/(\/\* BEGIN::CURLINFO \*\/\n).*(\n\s*\/\* END::CURLINFO \*\/)/s', '$1'. ob_get_contents() .'$2', + file_get_contents("php_http_curl.c"))); + +?> diff --git a/php_http_curl.c b/php_http_curl.c index f4a4244..5fea9fe 100644 --- a/php_http_curl.c +++ b/php_http_curl.c @@ -1085,7 +1085,6 @@ static STATUS get_info(CURL *ch, HashTable *info) add_assoc_zval_ex(&array, "ssl_engines", sizeof("ssl_engines"), subarray); curl_slist_free_all(s); } -#if PHP_HTTP_CURL_VERSION(7,14,1) if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_COOKIELIST, &s)) { MAKE_STD_ZVAL(subarray); array_init(subarray); @@ -1097,12 +1096,9 @@ static STATUS get_info(CURL *ch, HashTable *info) add_assoc_zval_ex(&array, "cookies", sizeof("cookies"), subarray); curl_slist_free_all(s); } -#endif -#if PHP_HTTP_CURL_VERSION(7,18,2) if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_REDIRECT_URL, &c)) { add_assoc_string_ex(&array, "redirect_url", sizeof("redirect_url"), c ? c : "", 1); } -#endif #if PHP_HTTP_CURL_VERSION(7,19,0) if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_PRIMARY_IP, &c)) { add_assoc_string_ex(&array, "primary_ip", sizeof("primary_ip"), c ? c : "", 1); @@ -1118,7 +1114,24 @@ static STATUS get_info(CURL *ch, HashTable *info) add_assoc_long_ex(&array, "condition_unmet", sizeof("condition_unmet"), l); } #endif +#if PHP_HTTP_CURL_VERSION(7,21,0) + if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_PRIMARY_PORT, &l)) { + add_assoc_long_ex(&array, "primary_port", sizeof("primary_port"), l); + } +#endif +#if PHP_HTTP_CURL_VERSION(7,21,0) + if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_LOCAL_IP, &c)) { + add_assoc_string_ex(&array, "local_ip", sizeof("local_ip"), c ? c : "", 1); + } +#endif +#if PHP_HTTP_CURL_VERSION(7,21,0) + if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_LOCAL_PORT, &l)) { + add_assoc_long_ex(&array, "local_port", sizeof("local_port"), l); + } +#endif + /* END::CURLINFO */ + #if PHP_HTTP_CURL_VERSION(7,19,1) && defined(PHP_HTTP_HAVE_OPENSSL) { int i;