X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=scripts%2Fgen_curlinfo.php;fp=scripts%2Fgen_curlinfo.php;h=129833a2a9fe87c435eabfff2ebe482a19032520;hp=0000000000000000000000000000000000000000;hb=aebfa7783e7b280bff4975649b20494e5eb932bc;hpb=2a929fe95c4303891769139d42440a3670e76033 diff --git a/scripts/gen_curlinfo.php b/scripts/gen_curlinfo.php new file mode 100644 index 0000000..129833a --- /dev/null +++ b/scripts/gen_curlinfo.php @@ -0,0 +1,95 @@ + '7,14,1' +); +$exclude = array( + 'PRIVATE', 'LASTSOCKET', 'FTP_ENTRY_PATH' +); +$translate = array( + 'HTTP_CONNECTCODE' => "connect_code" +); + +$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); + } +', +'DOUBLE' => +' if (CURLE_OK == curl_easy_getinfo(request->ch, %s, &d)) { + add_assoc_double_ex(&array, "%s", sizeof("%2$s"), d); + } +', +'LONG' => +' if (CURLE_OK == curl_easy_getinfo(request->ch, %s, &l)) { + add_assoc_long_ex(&array, "%s", sizeof("%2$s"), l); + } +', +'SLIST' => +' if (CURLE_OK == curl_easy_getinfo(request->ch, %s, &s)) { + MAKE_STD_ZVAL(subarray); + array_init(subarray); + for (p = s; p; p = p->next) { + add_next_index_string(subarray, p->data, 1); + } + add_assoc_zval_ex(&array, "%s", sizeof("%2$s"), subarray); + curl_slist_free_all(s); + } +' +); + +$types = file_re('curl.h', '/^#\s*define\s+CURLINFO_(STRING|LONG|DOUBLE|SLIST|MASK|TYPEMASK)\s+(0x[0-9a-fA-F]+)\s*$/m'); +$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 HTTP_CURL_VERSION(%s)\n", $ifdefs[$short]); + if (isset($translate[$short])) $short = $translate[$short]; + printf($templates[$type], $full, strtolower($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"))); + +?>