X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=scripts%2Fgen_curlinfo.php;h=376a7e5e460e7674f13ea08a8a833befe8d3a6b8;hp=f9d83f653128008479d4ece2febe7596fb51489a;hb=b2be5b163e896bb9cbb3f28314551d0debf8408d;hpb=bdaebfc338f06807fd985f40a38006a968f5b574 diff --git a/scripts/gen_curlinfo.php b/scripts/gen_curlinfo.php old mode 100644 new mode 100755 index f9d83f6..376a7e5 --- a/scripts/gen_curlinfo.php +++ b/scripts/gen_curlinfo.php @@ -1,10 +1,10 @@ +#!/usr/bin/env php '7,14,1' + 'PRIMARY_IP' => '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)', + 'HTTP_VERSION' => 'PHP_HTTP_CURL_VERSION(7,50,0)' ); $exclude = array( - 'PRIVATE', 'LASTSOCKET', 'FTP_ENTRY_PATH' + 'ACTIVESOCKET', + 'CERTINFO', + 'COOKIELIST', + 'FTP_ENTRY_PATH', + 'LASTSOCKET', + 'PRIVATE', + 'RTSP_CLIENT_CSEQ', + 'RTSP_CSEQ_RECV', + 'RTSP_SERVER_CSEQ', + 'RTSP_SESSION_ID', + 'TLS_SESSION', + 'TLS_SSL_PTR', ); + $translate = array( 'HTTP_CONNECTCODE' => "connect_code", 'COOKIELIST' => 'cookies', @@ -41,31 +59,35 @@ $translate = array( $templates = array( 'STRING' => -' if (CURLE_OK == curl_easy_getinfo(request->ch, %s, &c)) { - add_assoc_string_ex(&array, "%s", sizeof("%2$s"), c ? c : "", 1); +' if (CURLE_OK == curl_easy_getinfo(ch, %s, &c)) { + ZVAL_STRING(&tmp, STR_PTR(c)); + zend_hash_str_update(info, "%s", lenof("%2$s"), &tmp); } ', 'DOUBLE' => -' if (CURLE_OK == curl_easy_getinfo(request->ch, %s, &d)) { - add_assoc_double_ex(&array, "%s", sizeof("%2$s"), d); +' if (CURLE_OK == curl_easy_getinfo(ch, %s, &d)) { + ZVAL_DOUBLE(&tmp, d); + zend_hash_str_update(info, "%s", lenof("%2$s"), &tmp); } ', 'LONG' => -' if (CURLE_OK == curl_easy_getinfo(request->ch, %s, &l)) { - add_assoc_long_ex(&array, "%s", sizeof("%2$s"), l); +' if (CURLE_OK == curl_easy_getinfo(ch, %s, &l)) { + ZVAL_LONG(&tmp, l); + zend_hash_str_update(info, "%s", lenof("%2$s"), &tmp); } ', -'SLIST' => -' if (CURLE_OK == curl_easy_getinfo(request->ch, %s, &s)) { - MAKE_STD_ZVAL(subarray); - array_init(subarray); +'SLIST' => +' if (CURLE_OK == curl_easy_getinfo(ch, %s, &s)) { + array_init(&tmp); for (p = s; p; p = p->next) { - add_next_index_string(subarray, p->data, 1); + if (p->data) { + add_next_index_string(&tmp, p->data); + } } - add_assoc_zval_ex(&array, "%s", sizeof("%2$s"), subarray); + zend_hash_str_update(info, "%s", lenof("%2$s"), &tmp); 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'); @@ -74,13 +96,13 @@ ob_start(); foreach ($infos as $info) { list(, $full, $short, $type) = $info; if (in_array($short, $exclude)) continue; - if (isset($ifdefs[$short])) printf("#if HTTP_CURL_VERSION(%s)\n", $ifdefs[$short]); + 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("http_request_info.c", - preg_replace('/(\/\* BEGIN \*\/\n).*(\/\* END \*\/)/s', '$1'. ob_get_contents() .'$2', - file_get_contents("http_request_info.c"))); +file_put_contents("src/php_http_client_curl.c", + preg_replace('/(\/\* BEGIN::CURLINFO \*\/\n).*(\n\s*\/\* END::CURLINFO \*\/)/s', '$1'. ob_get_contents() .'$2', + file_get_contents("src/php_http_client_curl.c"))); ?>