7 fprintf(STDERR
, "FAILURE: %s\n", error_get_last()["message"]);
11 function file_re($file, $pattern, $all = true) {
14 $path or $path = isset($_SERVER['argv'][1]) ?
$_SERVER['argv'][1].'/include/curl/' : "/usr/local/include/curl/";
16 if ($content = file_get_contents($path . $file)) {
18 if (preg_match_all($pattern, $content, $matches, PREG_SET_ORDER
)) {
22 if (preg_match($pattern, $content, $matches)) {
26 trigger_error("no match in $file for $pattern");
32 'PRIMARY_IP' => 'PHP_HTTP_CURL_VERSION(7,19,0)',
33 'APPCONNECT_TIME' => 'PHP_HTTP_CURL_VERSION(7,19,0)',
34 'CONDITION_UNMET' => 'PHP_HTTP_CURL_VERSION(7,19,4)',
35 'PRIMARY_PORT' => 'PHP_HTTP_CURL_VERSION(7,21,0)',
36 'LOCAL_PORT' => 'PHP_HTTP_CURL_VERSION(7,21,0)',
37 'LOCAL_IP' => 'PHP_HTTP_CURL_VERSION(7,21,0)',
38 'HTTP_VERSION' => 'PHP_HTTP_CURL_VERSION(7,50,0)',
39 'PROXY_SSL_VERIFYRESULT' => 'PHP_HTTP_CURL_VERSION(7,52,0)',
40 'PROTOCOL' => 'PHP_HTTP_CURL_VERSION(7,52,0)',
41 'SCHEME' => 'PHP_HTTP_CURL_VERSION(7,52,0)',
42 'RETRY_AFTER' => 'PHP_HTTP_CURL_VERSION(7,66,0)',
43 'EFFECTIVE_METHOD' => 'PHP_HTTP_CURL_VERSION(7,72,0)',
44 'PROXY_ERROR' => 'PHP_HTTP_CURL_VERSION(7,73,0)',
62 'HTTP_CONNECTCODE' => "connect_code",
63 'COOKIELIST' => 'cookies',
68 ' if (CURLE_OK == curl_easy_getinfo(ch, %s, &c)) {
69 ZVAL_STRING(&tmp, STR_PTR(c));
70 zend_hash_str_update(info, "%s", lenof("%2$s"), &tmp);
74 ' if (CURLE_OK == curl_easy_getinfo(ch, %s, &d)) {
76 zend_hash_str_update(info, "%s", lenof("%2$s"), &tmp);
80 ' if (CURLE_OK == curl_easy_getinfo(ch, %s, &l)) {
82 zend_hash_str_update(info, "%s", lenof("%2$s"), &tmp);
86 ' if (CURLE_OK == curl_easy_getinfo(ch, %s, &o)) {
88 zend_hash_str_update(info, "%s", lenof("%2$s"), &tmp);
92 ' if (CURLE_OK == curl_easy_getinfo(ch, %s, &s)) {
94 for (p = s; p; p = p->next) {
96 add_next_index_string(&tmp, p->data);
99 zend_hash_str_update(info, "%s", lenof("%2$s"), &tmp);
100 curl_slist_free_all(s);
105 $infos = file_re('curl.h', '/^\s*(CURLINFO_(\w+))\s*=\s*CURLINFO_(STRING|LONG|DOUBLE|SLIST|OFF_T)\s*\+\s*\d+\s*,?\s*$/m');
108 foreach ($infos as $info) {
109 list(, $full, $short, $type) = $info;
110 if (in_array($short, $exclude) ||
substr($short, -2) === "_T") continue;
111 if (isset($ifdefs[$short])) printf("#if %s\n", $ifdefs[$short]);
112 printf($templates[$type], $full, strtolower((isset($translate[$short])) ?
$translate[$short] : $short));
113 if (isset($ifdefs[$short])) printf("#endif\n");
116 file_put_contents("src/php_http_client_curl.c",
117 preg_replace('/(\/\* BEGIN::CURLINFO \*\/\n).*(\n\s*\/\* END::CURLINFO \*\/)/s', '$1'. ob_get_contents() .'$2',
118 file_get_contents("src/php_http_client_curl.c")));