Skip to content

Commit 2076e8a

Browse files
author
nono303
committed
use LIBCURL_VERSION_NUM to fix 44ec7e7
1 parent 72c54a5 commit 2076e8a

File tree

1 file changed

+73
-29
lines changed

1 file changed

+73
-29
lines changed

ext/curl/interface.c

Lines changed: 73 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,15 @@ PHP_MINFO_FUNCTION(curl)
278278
php_info_print_table_row(2, "Host", d->host);
279279

280280
// Features
281-
if (d->age >= CURLVERSION_ELEVENTH && d->feature_names) {
281+
#if LIBCURL_VERSION_NUM >= 0x075700 /* Available since 7.87.0 CURLVERSION_ELEVENTH */
282282
n = 0;
283283
p = (char **) d->feature_names;
284284
while (*p != NULL) {
285285
n += snprintf(str + n, sizeof(str) - n, "%s%s", *p, *(p + 1) != NULL ? ", " : "");
286286
p++;
287287
}
288288
php_info_print_table_row(2, "Features", str);
289-
} else {
289+
#else
290290
/* To update on each new cURL release using src/main.c in cURL sources */
291291
/* make sure to sync this list with curl_version as well */
292292
if (d->features) {
@@ -351,7 +351,7 @@ PHP_MINFO_FUNCTION(curl)
351351
}
352352
}
353353
}
354-
}
354+
#endif
355355

356356
// Protocols
357357
n = 0;
@@ -379,39 +379,61 @@ PHP_MINFO_FUNCTION(curl)
379379
if (d->libz_version) {
380380
php_info_print_table_row(2, "Zlib Version", d->libz_version);
381381
}
382-
if (d->age >= CURLVERSION_SECOND && d->ares) {
382+
#if LIBCURL_VERSION_NUM >= 0x070B01 /* Available since 7.11.1 CURLVERSION_SECOND */
383+
if (d->ares) {
383384
php_info_print_table_row(2, "c-ares Version", d->ares);
384385
}
385-
if (d->age >= CURLVERSION_THIRD && d->libidn) {
386+
#endif
387+
#if LIBCURL_VERSION_NUM >= 0x070C00 /* Available since 7.12.0 CURLVERSION_THIRD */
388+
if (d->libidn) {
386389
php_info_print_table_row(2, "Libidn Version", d->libidn);
387390
}
388-
if (d->age >= CURLVERSION_FOURTH && d->iconv_ver_num) {
391+
#endif
392+
#if LIBCURL_VERSION_NUM >= 0x071001 /* Available since 7.16.1 CURLVERSION_FOURTH */
393+
if (d->iconv_ver_num) {
389394
php_info_print_table_row(2, "Iconv Version", d->iconv_ver_num);
390395
}
391-
if (d->age >= CURLVERSION_FOURTH && d->libssh_version) {
396+
#endif
397+
#if LIBCURL_VERSION_NUM >= 0x071001 /* Available since 7.16.1 CURLVERSION_FOURTH */
398+
if (d->libssh_version) {
392399
php_info_print_table_row(2, "Libssh Version", d->libssh_version);
393400
}
394-
if (d->age >= CURLVERSION_FIFTH && d->brotli_version) {
401+
#endif
402+
#if LIBCURL_VERSION_NUM >= 0x073900 /* Available since 7.57.0 CURLVERSION_FIFTH */
403+
if (d->brotli_version) {
395404
php_info_print_table_row(2, "Brotli Version", d->brotli_version);
396405
}
397-
if (d->age >= CURLVERSION_SIXTH && d->nghttp2_version) {
406+
#endif
407+
#if LIBCURL_VERSION_NUM >= 0x074200 /* Available since 7.66.0 CURLVERSION_SIXTH */
408+
if (d->nghttp2_version) {
398409
php_info_print_table_row(2, "Nghttp2 Version", d->nghttp2_version);
399410
}
400-
if (d->age >= CURLVERSION_SIXTH && d->quic_version) {
411+
#endif
412+
#if LIBCURL_VERSION_NUM >= 0x074200 /* Available since 7.66.0 CURLVERSION_SIXTH */
413+
if (d->quic_version) {
401414
php_info_print_table_row(2, "QUIC Version", d->quic_version);
402415
}
403-
if (d->age >= CURLVERSION_EIGHTH && d->zstd_version) {
416+
#endif
417+
#if LIBCURL_VERSION_NUM >= 0x074800 /* Available since 7.72.0 CURLVERSION_EIGHTH */
418+
if (d->zstd_version) {
404419
php_info_print_table_row(2, "Zstd Version", d->zstd_version);
405420
}
406-
if (d->age >= CURLVERSION_NINTH && d->hyper_version) {
421+
#endif
422+
#if LIBCURL_VERSION_NUM >= 0x074b00 /* Available since 7.75.0 CURLVERSION_NINTH */
423+
if ( d->hyper_version) {
407424
php_info_print_table_row(2, "Hyper Version", d->hyper_version);
408425
}
409-
if (d->age >= CURLVERSION_TENTH && d->gsasl_version) {
426+
#endif
427+
#if LIBCURL_VERSION_NUM >= 0x074d00 /* Available since 7.77.0 CURLVERSION_TENTH */
428+
if (d->gsasl_version) {
410429
php_info_print_table_row(2, "GNU SASL Version", d->gsasl_version);
411430
}
412-
if (d->age >= CURLVERSION_TWELFTH && d->rtmp_version) {
431+
#endif
432+
#if LIBCURL_VERSION_NUM >= 0x080800 /* Available since 8.8.0 CURLVERSION_TWELFTH */
433+
if (d->rtmp_version) {
413434
php_info_print_table_row(2, "RTMP Version", d->rtmp_version);
414435
}
436+
#endif
415437

416438
php_info_print_table_end();
417439

@@ -1074,15 +1096,15 @@ PHP_FUNCTION(curl_version)
10741096
/* Add an array of features */
10751097
zval feature_list;
10761098
array_init(&feature_list);
1077-
if (d->age >= CURLVERSION_ELEVENTH && d->feature_names) {
1099+
#if defined(CURLVERSION_ELEVENTH) && CURLVERSION_NOW >= CURLVERSION_ELEVENTH
10781100
{
10791101
char **p = (char **) d->feature_names;
10801102
while (*p != NULL) {
10811103
add_next_index_string(&feature_list, *p);
10821104
p++;
10831105
}
10841106
}
1085-
} else {
1107+
#else
10861108
{
10871109
struct feat {
10881110
const char *name;
@@ -1144,7 +1166,7 @@ PHP_FUNCTION(curl_version)
11441166
}
11451167
}
11461168
}
1147-
}
1169+
#endif
11481170
CAAZ("feature_list", &feature_list);
11491171

11501172
/* Add an array of protocols */
@@ -1177,39 +1199,61 @@ PHP_FUNCTION(curl_version)
11771199
if (d->libz_version) {
11781200
add_assoc_string (&feature_version, "libz", d->libz_version);
11791201
}
1180-
if (d->age >= CURLVERSION_SECOND && d->ares) {
1202+
#if LIBCURL_VERSION_NUM >= 0x070B01 /* Available since 7.11.1 CURLVERSION_SECOND */
1203+
if (d->ares) {
11811204
add_assoc_string (&feature_version, "ares", d->ares);
11821205
}
1183-
if (d->age >= CURLVERSION_THIRD && d->libidn) {
1206+
#endif
1207+
#if LIBCURL_VERSION_NUM >= 0x070C00 /* Available since 7.12.0 CURLVERSION_THIRD */
1208+
if (d->libidn) {
11841209
add_assoc_string (&feature_version, "libidn", d->libidn);
11851210
}
1186-
if (d->age >= CURLVERSION_FOURTH && d->iconv_ver_num) {
1187-
CAAL("version_iconv", d->iconv_ver_num);
1211+
#endif
1212+
#if LIBCURL_VERSION_NUM >= 0x071001 /* Available since 7.16.1 CURLVERSION_FOURTH */
1213+
if (d->iconv_ver_num) {
1214+
add_assoc_string (&feature_version, "iconv", d->iconv_ver_num);
11881215
}
1189-
if (d->age >= CURLVERSION_FOURTH && d->libssh_version) {
1216+
#endif
1217+
#if LIBCURL_VERSION_NUM >= 0x071001 /* Available since 7.16.1 CURLVERSION_FOURTH */
1218+
if (d->libssh_version) {
11901219
add_assoc_string (&feature_version, "libssh", d->libssh_version);
11911220
}
1192-
if (d->age >= CURLVERSION_FIFTH && d->brotli_version) {
1221+
#endif
1222+
#if LIBCURL_VERSION_NUM >= 0x073900 /* Available since 7.57.0 CURLVERSION_FIFTH */
1223+
if (d->brotli_version) {
11931224
add_assoc_string (&feature_version, "brotli", d->brotli_version);
11941225
}
1195-
if (d->age >= CURLVERSION_SIXTH && d->nghttp2_version) {
1226+
#endif
1227+
#if LIBCURL_VERSION_NUM >= 0x074200 /* Available since 7.66.0 CURLVERSION_SIXTH */
1228+
if (d->nghttp2_version) {
11961229
add_assoc_string (&feature_version, "nghttp2", d->nghttp2_version);
11971230
}
1198-
if (d->age >= CURLVERSION_SIXTH && d->quic_version) {
1231+
#endif
1232+
#if LIBCURL_VERSION_NUM >= 0x074200 /* Available since 7.66.0 CURLVERSION_SIXTH */
1233+
if (d->quic_version) {
11991234
add_assoc_string (&feature_version, "quic", d->quic_version);
12001235
}
1201-
if (d->age >= CURLVERSION_EIGHTH && d->zstd_version) {
1236+
#endif
1237+
#if LIBCURL_VERSION_NUM >= 0x074800 /* Available since 7.72.0 CURLVERSION_EIGHTH */
1238+
if (d->zstd_version) {
12021239
add_assoc_string (&feature_version, "zstd", d->zstd_version);
12031240
}
1204-
if (d->age >= CURLVERSION_NINTH && d->hyper_version) {
1241+
#endif
1242+
#if LIBCURL_VERSION_NUM >= 0x074b00 /* Available since 7.75.0 CURLVERSION_NINTH */
1243+
if (d->hyper_version) {
12051244
add_assoc_string (&feature_version, "hyper", d->hyper_version);
12061245
}
1207-
if (d->age >= CURLVERSION_TENTH && d->gsasl_version) {
1246+
#endif
1247+
#if LIBCURL_VERSION_NUM >= 0x074d00 /* Available since 7.77.0 CURLVERSION_TENTH */
1248+
if (d->gsasl_version) {
12081249
add_assoc_string (&feature_version, "gsasl", d->gsasl_version);
12091250
}
1210-
if (d->age >= CURLVERSION_TWELFTH && d->rtmp_version) {
1251+
#endif
1252+
#if LIBCURL_VERSION_NUM >= 0x080800 /* Available since 8.8.0 CURLVERSION_TWELFTH */
1253+
if (d->rtmp_version) {
12111254
add_assoc_string (&feature_version, "rtmp", d->rtmp_version);
12121255
}
1256+
#endif
12131257
CAAZ("feature_versions", &feature_version);
12141258
}
12151259
/* }}} */

0 commit comments

Comments
 (0)