- Fixed build on php-trunk
[m6w6/ext-http] / scripts / gen_curlinfo.php
index f9d83f653128008479d4ece2febe7596fb51489a..f234685ea7abc8c36b4a936427e9325315b3a031 100644 (file)
@@ -1,10 +1,13 @@
+#!/usr/bin/env php
 <?php
 // $Id$
 
 error_reporting(0);
 
 function failure() {
-       fprintf(STDERR, "FAILURE: %s\n", error_get_last());
+       // this is why error_get_last() should return a stdClass object
+       $error = error_get_last();
+       fprintf(STDERR, "FAILURE: %s\n", $error["message"]);
        exit(-1);
 }
 
@@ -29,10 +32,14 @@ function file_re($file, $pattern, $all = true) {
 }
 
 $ifdefs = array(
-       'COOKIELIST' => '7,14,1'
+       'COOKIELIST' => 'HTTP_CURL_VERSION(7,14,1)',
+       'PRIMARY_IP' => 'HTTP_CURL_VERSION(7,19,0)',
+       'APPCONNECT_TIME' => 'HTTP_CURL_VERSION(7,19,0)',
+       'REDIRECT_URL' => 'HTTP_CURL_VERSION(7,18,2)',
+       'CONDITION_UNMET' => 'HTTP_CURL_VERSION(7,19,4)',
 );
 $exclude = array(
-       'PRIVATE', 'LASTSOCKET', 'FTP_ENTRY_PATH'
+       'PRIVATE', 'LASTSOCKET', 'FTP_ENTRY_PATH', 'CERTINFO',
 );
 $translate = array(
        'HTTP_CONNECTCODE' => "connect_code",
@@ -55,17 +62,19 @@ $templates = array(
                add_assoc_long_ex(&array, "%s", sizeof("%2$s"), l);
        }
 ',
-'SLIST' => 
+'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);
+                       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');
@@ -74,7 +83,7 @@ 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");
 }