/src/CMake/Utilities/cmcurl/lib/version.c
Line | Count | Source |
1 | | /*************************************************************************** |
2 | | * _ _ ____ _ |
3 | | * Project ___| | | | _ \| | |
4 | | * / __| | | | |_) | | |
5 | | * | (__| |_| | _ <| |___ |
6 | | * \___|\___/|_| \_\_____| |
7 | | * |
8 | | * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. |
9 | | * |
10 | | * This software is licensed as described in the file COPYING, which |
11 | | * you should have received as part of this distribution. The terms |
12 | | * are also available at https://curl.se/docs/copyright.html. |
13 | | * |
14 | | * You may opt to use, copy, modify, merge, publish, distribute and/or sell |
15 | | * copies of the Software, and permit persons to whom the Software is |
16 | | * furnished to do so, under the terms of the COPYING file. |
17 | | * |
18 | | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
19 | | * KIND, either express or implied. |
20 | | * |
21 | | * SPDX-License-Identifier: curl |
22 | | * |
23 | | ***************************************************************************/ |
24 | | #include "curl_setup.h" |
25 | | |
26 | | #ifdef USE_NGHTTP2 |
27 | | #include <nghttp2/nghttp2.h> |
28 | | #endif |
29 | | |
30 | | #include "urldata.h" |
31 | | #include "vtls/vtls.h" |
32 | | #include "http2.h" |
33 | | #include "vssh/ssh.h" |
34 | | #include "vquic/vquic.h" |
35 | | #include "easy_lock.h" |
36 | | |
37 | | #ifdef USE_ARES |
38 | | # include <ares.h> |
39 | | #endif |
40 | | |
41 | | #ifdef USE_LIBIDN2 |
42 | | #include <idn2.h> |
43 | | #endif |
44 | | |
45 | | #ifdef USE_LIBPSL |
46 | | #include <libpsl.h> |
47 | | #endif |
48 | | |
49 | | #ifdef USE_LIBRTMP |
50 | | #include <librtmp/rtmp.h> |
51 | | #include "curl_rtmp.h" |
52 | | #endif |
53 | | |
54 | | #ifdef HAVE_LIBZ |
55 | | #include <cm3p/zlib.h> |
56 | | #endif |
57 | | |
58 | | #ifdef HAVE_BROTLI |
59 | | #if defined(__GNUC__) || defined(__clang__) |
60 | | /* Ignore -Wvla warnings in brotli headers */ |
61 | | #pragma GCC diagnostic push |
62 | | #pragma GCC diagnostic ignored "-Wvla" |
63 | | #endif |
64 | | #include <brotli/decode.h> |
65 | | #if defined(__GNUC__) || defined(__clang__) |
66 | | #pragma GCC diagnostic pop |
67 | | #endif |
68 | | #endif |
69 | | |
70 | | #ifdef HAVE_ZSTD |
71 | | #include <zstd.h> |
72 | | #endif |
73 | | |
74 | | #ifdef USE_GSASL |
75 | | #include <gsasl.h> |
76 | | #endif |
77 | | |
78 | | #ifndef CURL_DISABLE_LDAP |
79 | | #include "curl_ldap.h" |
80 | | #endif |
81 | | |
82 | | #ifdef HAVE_BROTLI |
83 | | static void brotli_version(char *buf, size_t bufsz) |
84 | | { |
85 | | uint32_t brotli_version = BrotliDecoderVersion(); |
86 | | unsigned int major = brotli_version >> 24; |
87 | | unsigned int minor = (brotli_version & 0x00FFFFFF) >> 12; |
88 | | unsigned int patch = brotli_version & 0x00000FFF; |
89 | | (void)curl_msnprintf(buf, bufsz, "brotli/%u.%u.%u", major, minor, patch); |
90 | | } |
91 | | #endif |
92 | | |
93 | | #ifdef HAVE_ZSTD |
94 | | static void zstd_version(char *buf, size_t bufsz) |
95 | | { |
96 | | unsigned int version = ZSTD_versionNumber(); |
97 | | unsigned int major = version / (100 * 100); |
98 | | unsigned int minor = (version - (major * 100 * 100)) / 100; |
99 | | unsigned int patch = version - (major * 100 * 100) - (minor * 100); |
100 | | (void)curl_msnprintf(buf, bufsz, "zstd/%u.%u.%u", major, minor, patch); |
101 | | } |
102 | | #endif |
103 | | |
104 | | #ifdef USE_LIBPSL |
105 | | static void psl_version(char *buf, size_t bufsz) |
106 | | { |
107 | | #if defined(PSL_VERSION_MAJOR) && (PSL_VERSION_MAJOR > 0 || \ |
108 | | PSL_VERSION_MINOR >= 11) |
109 | | int num = psl_check_version_number(0); |
110 | | curl_msnprintf(buf, bufsz, "libpsl/%d.%d.%d", |
111 | | num >> 16, (num >> 8) & 0xff, num & 0xff); |
112 | | #else |
113 | | curl_msnprintf(buf, bufsz, "libpsl/%s", psl_get_version()); |
114 | | #endif |
115 | | } |
116 | | #endif |
117 | | |
118 | | #if defined(USE_LIBIDN2) || defined(USE_WIN32_IDN) || defined(USE_APPLE_IDN) |
119 | | #define USE_IDN |
120 | | #endif |
121 | | |
122 | | #ifdef USE_IDN |
123 | | static void idn_version(char *buf, size_t bufsz) |
124 | | { |
125 | | #ifdef USE_LIBIDN2 |
126 | | curl_msnprintf(buf, bufsz, "libidn2/%s", idn2_check_version(NULL)); |
127 | | #elif defined(USE_WIN32_IDN) |
128 | | curl_msnprintf(buf, bufsz, "WinIDN"); |
129 | | #elif defined(USE_APPLE_IDN) |
130 | | curl_msnprintf(buf, bufsz, "AppleIDN"); |
131 | | #endif |
132 | | } |
133 | | #endif |
134 | | |
135 | | /* |
136 | | * curl_version() returns a pointer to a static buffer. |
137 | | * |
138 | | * It is implemented to work multi-threaded by making sure repeated invokes |
139 | | * generate the exact same string and never write any temporary data like |
140 | | * zeros in the data. |
141 | | */ |
142 | | |
143 | | #define VERSION_PARTS 16 /* number of substrings we can concatenate */ |
144 | | |
145 | | char *curl_version(void) |
146 | 0 | { |
147 | 0 | static char out[300]; |
148 | 0 | char *outp; |
149 | 0 | size_t outlen; |
150 | 0 | const char *src[VERSION_PARTS]; |
151 | | #ifdef USE_SSL |
152 | | char ssl_version[200]; |
153 | | #endif |
154 | 0 | #ifdef HAVE_LIBZ |
155 | 0 | char z_version[30]; |
156 | 0 | #endif |
157 | | #ifdef HAVE_BROTLI |
158 | | char br_version[30]; |
159 | | #endif |
160 | | #ifdef HAVE_ZSTD |
161 | | char zstd_ver[30]; |
162 | | #endif |
163 | | #ifdef USE_ARES |
164 | | char cares_version[30]; |
165 | | #endif |
166 | | #ifdef USE_IDN |
167 | | char idn_ver[30]; |
168 | | #endif |
169 | | #ifdef USE_LIBPSL |
170 | | char psl_ver[30]; |
171 | | #endif |
172 | | #ifdef USE_SSH |
173 | | char ssh_version[30]; |
174 | | #endif |
175 | 0 | #if !defined(CURL_DISABLE_HTTP) && defined(USE_NGHTTP2) |
176 | 0 | char h2_version[30]; |
177 | 0 | #endif |
178 | | #if !defined(CURL_DISABLE_HTTP) && defined(USE_HTTP3) |
179 | | char h3_version[30]; |
180 | | #endif |
181 | | #ifdef USE_LIBRTMP |
182 | | char rtmp_version[30]; |
183 | | #endif |
184 | | #ifdef USE_GSASL |
185 | | char gsasl_buf[30]; |
186 | | #endif |
187 | | #ifdef HAVE_GSSAPI |
188 | | char gss_buf[40]; |
189 | | #endif |
190 | | #ifndef CURL_DISABLE_LDAP |
191 | | char ldap_buf[30]; |
192 | | #endif |
193 | 0 | int i = 0; |
194 | 0 | int j; |
195 | |
|
196 | | #ifdef DEBUGBUILD |
197 | | /* Override version string when environment variable CURL_VERSION is set */ |
198 | | const char *debugversion = getenv("CURL_VERSION"); |
199 | | if(debugversion) { |
200 | | curl_msnprintf(out, sizeof(out), "%s", debugversion); |
201 | | return out; |
202 | | } |
203 | | #endif |
204 | |
|
205 | 0 | src[i++] = LIBCURL_NAME "/" LIBCURL_VERSION; |
206 | | #ifdef USE_SSL |
207 | | Curl_ssl_version(ssl_version, sizeof(ssl_version)); |
208 | | src[i++] = ssl_version; |
209 | | #endif |
210 | 0 | #ifdef HAVE_LIBZ |
211 | 0 | curl_msnprintf(z_version, sizeof(z_version), "zlib/%s", zlibVersion()); |
212 | 0 | src[i++] = z_version; |
213 | 0 | #endif |
214 | | #ifdef HAVE_BROTLI |
215 | | brotli_version(br_version, sizeof(br_version)); |
216 | | src[i++] = br_version; |
217 | | #endif |
218 | | #ifdef HAVE_ZSTD |
219 | | zstd_version(zstd_ver, sizeof(zstd_ver)); |
220 | | src[i++] = zstd_ver; |
221 | | #endif |
222 | | #ifdef USE_ARES |
223 | | curl_msnprintf(cares_version, sizeof(cares_version), |
224 | | "c-ares/%s", ares_version(NULL)); |
225 | | src[i++] = cares_version; |
226 | | #endif |
227 | | #ifdef USE_IDN |
228 | | idn_version(idn_ver, sizeof(idn_ver)); |
229 | | src[i++] = idn_ver; |
230 | | #endif |
231 | | #ifdef USE_LIBPSL |
232 | | psl_version(psl_ver, sizeof(psl_ver)); |
233 | | src[i++] = psl_ver; |
234 | | #endif |
235 | | #ifdef USE_SSH |
236 | | Curl_ssh_version(ssh_version, sizeof(ssh_version)); |
237 | | src[i++] = ssh_version; |
238 | | #endif |
239 | 0 | #if !defined(CURL_DISABLE_HTTP) && defined(USE_NGHTTP2) |
240 | 0 | Curl_http2_ver(h2_version, sizeof(h2_version)); |
241 | 0 | src[i++] = h2_version; |
242 | 0 | #endif |
243 | | #if !defined(CURL_DISABLE_HTTP) && defined(USE_HTTP3) |
244 | | Curl_quic_ver(h3_version, sizeof(h3_version)); |
245 | | src[i++] = h3_version; |
246 | | #endif |
247 | | #ifdef USE_LIBRTMP |
248 | | Curl_rtmp_version(rtmp_version, sizeof(rtmp_version)); |
249 | | src[i++] = rtmp_version; |
250 | | #endif |
251 | | #ifdef USE_GSASL |
252 | | curl_msnprintf(gsasl_buf, sizeof(gsasl_buf), "libgsasl/%s", |
253 | | gsasl_check_version(NULL)); |
254 | | src[i++] = gsasl_buf; |
255 | | #endif |
256 | | #ifdef HAVE_GSSAPI |
257 | | #ifdef HAVE_GSSGNU |
258 | | curl_msnprintf(gss_buf, sizeof(gss_buf), "libgss/%s", |
259 | | GSS_VERSION); |
260 | | #elif defined(CURL_KRB5_VERSION) |
261 | | curl_msnprintf(gss_buf, sizeof(gss_buf), "mit-krb5/%s", |
262 | | CURL_KRB5_VERSION); |
263 | | #else |
264 | | curl_msnprintf(gss_buf, sizeof(gss_buf), "mit-krb5"); |
265 | | #endif |
266 | | src[i++] = gss_buf; |
267 | | #endif /* HAVE_GSSAPI */ |
268 | | #ifndef CURL_DISABLE_LDAP |
269 | | Curl_ldap_version(ldap_buf, sizeof(ldap_buf)); |
270 | | src[i++] = ldap_buf; |
271 | | #endif |
272 | |
|
273 | 0 | DEBUGASSERT(i <= VERSION_PARTS); |
274 | |
|
275 | 0 | outp = &out[0]; |
276 | 0 | outlen = sizeof(out); |
277 | 0 | for(j = 0; j < i; j++) { |
278 | 0 | size_t n = strlen(src[j]); |
279 | | /* we need room for a space, the string and the final zero */ |
280 | 0 | if(outlen <= (n + 2)) |
281 | 0 | break; |
282 | 0 | if(j) { |
283 | | /* prepend a space if not the first */ |
284 | 0 | *outp++ = ' '; |
285 | 0 | outlen--; |
286 | 0 | } |
287 | 0 | memcpy(outp, src[j], n); |
288 | 0 | outp += n; |
289 | 0 | outlen -= n; |
290 | 0 | } |
291 | 0 | *outp = 0; |
292 | |
|
293 | 0 | return out; |
294 | 0 | } |
295 | | |
296 | | /* data for curl_version_info |
297 | | |
298 | | Keep the list sorted alphabetically. It is also written so that each |
299 | | protocol line has its own #if line to make things easier on the eye. |
300 | | */ |
301 | | |
302 | | static const char * const supported_protocols[] = { |
303 | | #ifndef CURL_DISABLE_DICT |
304 | | "dict", |
305 | | #endif |
306 | | #ifndef CURL_DISABLE_FILE |
307 | | "file", |
308 | | #endif |
309 | | #ifndef CURL_DISABLE_FTP |
310 | | "ftp", |
311 | | #endif |
312 | | #if defined(USE_SSL) && !defined(CURL_DISABLE_FTP) |
313 | | "ftps", |
314 | | #endif |
315 | | #ifndef CURL_DISABLE_GOPHER |
316 | | "gopher", |
317 | | #endif |
318 | | #if defined(USE_SSL) && !defined(CURL_DISABLE_GOPHER) |
319 | | "gophers", |
320 | | #endif |
321 | | #ifndef CURL_DISABLE_HTTP |
322 | | "http", |
323 | | #endif |
324 | | #if defined(USE_SSL) && !defined(CURL_DISABLE_HTTP) |
325 | | "https", |
326 | | #endif |
327 | | #ifndef CURL_DISABLE_IMAP |
328 | | "imap", |
329 | | #endif |
330 | | #if defined(USE_SSL) && !defined(CURL_DISABLE_IMAP) |
331 | | "imaps", |
332 | | #endif |
333 | | #ifndef CURL_DISABLE_LDAP |
334 | | "ldap", |
335 | | #if !defined(CURL_DISABLE_LDAPS) && \ |
336 | | ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \ |
337 | | (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL))) |
338 | | "ldaps", |
339 | | #endif |
340 | | #endif |
341 | | #ifndef CURL_DISABLE_MQTT |
342 | | "mqtt", |
343 | | #endif |
344 | | #ifndef CURL_DISABLE_POP3 |
345 | | "pop3", |
346 | | #endif |
347 | | #if defined(USE_SSL) && !defined(CURL_DISABLE_POP3) |
348 | | "pop3s", |
349 | | #endif |
350 | | #ifdef USE_LIBRTMP |
351 | | "rtmp", |
352 | | "rtmpe", |
353 | | "rtmps", |
354 | | "rtmpt", |
355 | | "rtmpte", |
356 | | "rtmpts", |
357 | | #endif |
358 | | #ifndef CURL_DISABLE_RTSP |
359 | | "rtsp", |
360 | | #endif |
361 | | #ifdef USE_SSH |
362 | | "scp", |
363 | | "sftp", |
364 | | #endif |
365 | | #if !defined(CURL_DISABLE_SMB) && defined(USE_CURL_NTLM_CORE) |
366 | | "smb", |
367 | | # ifdef USE_SSL |
368 | | "smbs", |
369 | | # endif |
370 | | #endif |
371 | | #ifndef CURL_DISABLE_SMTP |
372 | | "smtp", |
373 | | #endif |
374 | | #if defined(USE_SSL) && !defined(CURL_DISABLE_SMTP) |
375 | | "smtps", |
376 | | #endif |
377 | | #ifndef CURL_DISABLE_TELNET |
378 | | "telnet", |
379 | | #endif |
380 | | #ifndef CURL_DISABLE_TFTP |
381 | | "tftp", |
382 | | #endif |
383 | | #ifndef CURL_DISABLE_HTTP |
384 | | /* WebSocket support relies on HTTP */ |
385 | | #ifndef CURL_DISABLE_WEBSOCKETS |
386 | | "ws", |
387 | | #endif |
388 | | #if defined(USE_SSL) && !defined(CURL_DISABLE_WEBSOCKETS) |
389 | | "wss", |
390 | | #endif |
391 | | #endif |
392 | | |
393 | | NULL |
394 | | }; |
395 | | |
396 | | /* |
397 | | * Feature presence runtime check functions. |
398 | | * |
399 | | * Warning: the value returned by these should not change between |
400 | | * curl_global_init() and curl_global_cleanup() calls. |
401 | | */ |
402 | | |
403 | | #if defined(USE_LIBIDN2) || defined(USE_WIN32_IDN) || defined(USE_APPLE_IDN) |
404 | | static int idn_present(curl_version_info_data *info) |
405 | | { |
406 | | #if defined(USE_WIN32_IDN) || defined(USE_APPLE_IDN) |
407 | | (void)info; |
408 | | return TRUE; |
409 | | #else |
410 | | return info->libidn != NULL; |
411 | | #endif |
412 | | } |
413 | | #endif |
414 | | |
415 | | #if defined(USE_SSL) && !defined(CURL_DISABLE_PROXY) && \ |
416 | | !defined(CURL_DISABLE_HTTP) |
417 | | static int https_proxy_present(curl_version_info_data *info) |
418 | | { |
419 | | (void)info; |
420 | | return Curl_ssl_supports(NULL, SSLSUPP_HTTPS_PROXY); |
421 | | } |
422 | | #endif |
423 | | |
424 | | #if defined(USE_SSL) && defined(USE_ECH) |
425 | | static int ech_present(curl_version_info_data *info) |
426 | | { |
427 | | (void)info; |
428 | | return Curl_ssl_supports(NULL, SSLSUPP_ECH); |
429 | | } |
430 | | #endif |
431 | | |
432 | | /* |
433 | | * Features table. |
434 | | * |
435 | | * Keep the features alphabetically sorted. |
436 | | * Use FEATURE() macro to define an entry: this allows documentation check. |
437 | | */ |
438 | | |
439 | | #define FEATURE(name, present, bitmask) { (name), (present), (bitmask) } |
440 | | |
441 | | struct feat { |
442 | | const char *name; |
443 | | int (*present)(curl_version_info_data *info); |
444 | | int bitmask; |
445 | | }; |
446 | | |
447 | | static const struct feat features_table[] = { |
448 | | #ifndef CURL_DISABLE_ALTSVC |
449 | | FEATURE("alt-svc", NULL, CURL_VERSION_ALTSVC), |
450 | | #endif |
451 | | #if defined(USE_ARES) && defined(CURLRES_THREADED) && defined(USE_HTTPSRR) |
452 | | FEATURE("asyn-rr", NULL, 0), |
453 | | #endif |
454 | | #ifdef CURLRES_ASYNCH |
455 | | FEATURE("AsynchDNS", NULL, CURL_VERSION_ASYNCHDNS), |
456 | | #endif |
457 | | #ifdef HAVE_BROTLI |
458 | | FEATURE("brotli", NULL, CURL_VERSION_BROTLI), |
459 | | #endif |
460 | | #ifdef DEBUGBUILD |
461 | | FEATURE("Debug", NULL, CURL_VERSION_DEBUG), |
462 | | #endif |
463 | | #if defined(USE_SSL) && defined(USE_ECH) |
464 | | FEATURE("ECH", ech_present, 0), |
465 | | |
466 | | #ifndef USE_HTTPSRR |
467 | | #error "ECH enabled but not HTTPSRR, must be a config error" |
468 | | #endif |
469 | | #endif |
470 | | #ifdef USE_GSASL |
471 | | FEATURE("gsasl", NULL, CURL_VERSION_GSASL), |
472 | | #endif |
473 | | #ifdef HAVE_GSSAPI |
474 | | FEATURE("GSS-API", NULL, CURL_VERSION_GSSAPI), |
475 | | #endif |
476 | | #ifndef CURL_DISABLE_HSTS |
477 | | FEATURE("HSTS", NULL, CURL_VERSION_HSTS), |
478 | | #endif |
479 | | #if !defined(CURL_DISABLE_HTTP) && defined(USE_NGHTTP2) |
480 | | FEATURE("HTTP2", NULL, CURL_VERSION_HTTP2), |
481 | | #endif |
482 | | #if !defined(CURL_DISABLE_HTTP) && defined(USE_HTTP3) |
483 | | FEATURE("HTTP3", NULL, CURL_VERSION_HTTP3), |
484 | | #endif |
485 | | #if defined(USE_SSL) && !defined(CURL_DISABLE_PROXY) && \ |
486 | | !defined(CURL_DISABLE_HTTP) |
487 | | FEATURE("HTTPS-proxy", https_proxy_present, CURL_VERSION_HTTPS_PROXY), |
488 | | #endif |
489 | | #ifdef USE_HTTPSRR |
490 | | FEATURE("HTTPSRR", NULL, 0), |
491 | | #endif |
492 | | #if defined(USE_LIBIDN2) || defined(USE_WIN32_IDN) || defined(USE_APPLE_IDN) |
493 | | FEATURE("IDN", idn_present, CURL_VERSION_IDN), |
494 | | #endif |
495 | | #ifdef USE_IPV6 |
496 | | FEATURE("IPv6", NULL, CURL_VERSION_IPV6), |
497 | | #endif |
498 | | #ifdef USE_KERBEROS5 |
499 | | FEATURE("Kerberos", NULL, CURL_VERSION_KERBEROS5), |
500 | | #endif |
501 | | #if (SIZEOF_CURL_OFF_T > 4) && ((SIZEOF_OFF_T > 4) || defined(_WIN32)) |
502 | | FEATURE("Largefile", NULL, CURL_VERSION_LARGEFILE), |
503 | | #endif |
504 | | #ifdef HAVE_LIBZ |
505 | | FEATURE("libz", NULL, CURL_VERSION_LIBZ), |
506 | | #endif |
507 | | #ifdef CURL_WITH_MULTI_SSL |
508 | | FEATURE("MultiSSL", NULL, CURL_VERSION_MULTI_SSL), |
509 | | #endif |
510 | | #ifdef USE_NTLM |
511 | | FEATURE("NTLM", NULL, CURL_VERSION_NTLM), |
512 | | #endif |
513 | | #ifdef USE_LIBPSL |
514 | | FEATURE("PSL", NULL, CURL_VERSION_PSL), |
515 | | #endif |
516 | | #ifdef USE_APPLE_SECTRUST |
517 | | FEATURE("AppleSecTrust", NULL, 0), |
518 | | #endif |
519 | | #ifdef USE_SPNEGO |
520 | | FEATURE("SPNEGO", NULL, CURL_VERSION_SPNEGO), |
521 | | #endif |
522 | | #ifdef USE_SSL |
523 | | FEATURE("SSL", NULL, CURL_VERSION_SSL), |
524 | | #endif |
525 | | #ifdef USE_SSLS_EXPORT |
526 | | FEATURE("SSLS-EXPORT", NULL, 0), |
527 | | #endif |
528 | | #ifdef USE_WINDOWS_SSPI |
529 | | FEATURE("SSPI", NULL, CURL_VERSION_SSPI), |
530 | | #endif |
531 | | #ifdef GLOBAL_INIT_IS_THREADSAFE |
532 | | FEATURE("threadsafe", NULL, CURL_VERSION_THREADSAFE), |
533 | | #endif |
534 | | #ifdef USE_TLS_SRP |
535 | | FEATURE("TLS-SRP", NULL, CURL_VERSION_TLSAUTH_SRP), |
536 | | #endif |
537 | | #ifdef CURLDEBUG |
538 | | FEATURE("TrackMemory", NULL, CURL_VERSION_CURLDEBUG), |
539 | | #endif |
540 | | #if defined(_WIN32) && defined(UNICODE) && defined(_UNICODE) |
541 | | FEATURE("Unicode", NULL, CURL_VERSION_UNICODE), |
542 | | #endif |
543 | | #ifdef USE_UNIX_SOCKETS |
544 | | FEATURE("UnixSockets", NULL, CURL_VERSION_UNIX_SOCKETS), |
545 | | #endif |
546 | | #ifdef HAVE_ZSTD |
547 | | FEATURE("zstd", NULL, CURL_VERSION_ZSTD), |
548 | | #endif |
549 | | {NULL, NULL, 0} |
550 | | }; |
551 | | |
552 | | static const char *feature_names[CURL_ARRAYSIZE(features_table)] = { NULL }; |
553 | | |
554 | | static curl_version_info_data version_info = { |
555 | | CURLVERSION_NOW, |
556 | | LIBCURL_VERSION, |
557 | | LIBCURL_VERSION_NUM, |
558 | | CURL_OS, /* as found by configure or set by hand at build-time */ |
559 | | 0, /* features bitmask is built at runtime */ |
560 | | NULL, /* ssl_version */ |
561 | | 0, /* ssl_version_num, this is kept at zero */ |
562 | | NULL, /* zlib_version */ |
563 | | supported_protocols, |
564 | | NULL, /* c-ares version */ |
565 | | 0, /* c-ares version numerical */ |
566 | | NULL, /* libidn version */ |
567 | | 0, /* iconv version */ |
568 | | NULL, /* ssh lib version */ |
569 | | 0, /* brotli_ver_num */ |
570 | | NULL, /* brotli version */ |
571 | | 0, /* nghttp2 version number */ |
572 | | NULL, /* nghttp2 version string */ |
573 | | NULL, /* quic library string */ |
574 | | #ifdef CURL_CA_BUNDLE |
575 | | CURL_CA_BUNDLE, /* cainfo */ |
576 | | #else |
577 | | NULL, |
578 | | #endif |
579 | | #ifdef CURL_CA_PATH |
580 | | CURL_CA_PATH, /* capath */ |
581 | | #else |
582 | | NULL, |
583 | | #endif |
584 | | 0, /* zstd_ver_num */ |
585 | | NULL, /* zstd version */ |
586 | | NULL, /* Hyper version */ |
587 | | NULL, /* gsasl version */ |
588 | | feature_names, |
589 | | NULL /* rtmp version */ |
590 | | }; |
591 | | |
592 | | curl_version_info_data *curl_version_info(CURLversion stamp) |
593 | 0 | { |
594 | 0 | size_t n; |
595 | 0 | const struct feat *p; |
596 | 0 | int features = 0; |
597 | |
|
598 | | #ifdef USE_SSH |
599 | | static char ssh_buf[80]; /* 'ssh_buffer' clashes with libssh/libssh.h */ |
600 | | #endif |
601 | | #ifdef USE_SSL |
602 | | #ifdef CURL_WITH_MULTI_SSL |
603 | | static char ssl_buffer[200]; |
604 | | #else |
605 | | static char ssl_buffer[80]; |
606 | | #endif |
607 | | #endif |
608 | | #ifdef HAVE_BROTLI |
609 | | static char brotli_buffer[80]; |
610 | | #endif |
611 | | #ifdef HAVE_ZSTD |
612 | | static char zstd_buffer[80]; |
613 | | #endif |
614 | |
|
615 | 0 | (void)stamp; |
616 | |
|
617 | | #ifdef USE_SSL |
618 | | Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer)); |
619 | | version_info.ssl_version = ssl_buffer; |
620 | | #endif |
621 | |
|
622 | 0 | #ifdef HAVE_LIBZ |
623 | 0 | version_info.libz_version = zlibVersion(); |
624 | | /* libz left NULL if non-existing */ |
625 | 0 | #endif |
626 | | #ifdef USE_ARES |
627 | | { |
628 | | int aresnum; |
629 | | version_info.ares = ares_version(&aresnum); |
630 | | version_info.ares_num = aresnum; |
631 | | } |
632 | | #endif |
633 | | #ifdef USE_LIBIDN2 |
634 | | /* This returns a version string if we use the given version or later, |
635 | | otherwise it returns NULL */ |
636 | | version_info.libidn = idn2_check_version(IDN2_VERSION); |
637 | | #endif |
638 | |
|
639 | | #ifdef USE_SSH |
640 | | Curl_ssh_version(ssh_buf, sizeof(ssh_buf)); |
641 | | version_info.libssh_version = ssh_buf; |
642 | | #endif |
643 | |
|
644 | | #ifdef HAVE_BROTLI |
645 | | version_info.brotli_ver_num = BrotliDecoderVersion(); |
646 | | brotli_version(brotli_buffer, sizeof(brotli_buffer)); |
647 | | version_info.brotli_version = brotli_buffer; |
648 | | #endif |
649 | |
|
650 | | #ifdef HAVE_ZSTD |
651 | | version_info.zstd_ver_num = (unsigned int)ZSTD_versionNumber(); |
652 | | zstd_version(zstd_buffer, sizeof(zstd_buffer)); |
653 | | version_info.zstd_version = zstd_buffer; |
654 | | #endif |
655 | |
|
656 | 0 | #ifdef USE_NGHTTP2 |
657 | 0 | { |
658 | 0 | nghttp2_info *h2 = nghttp2_version(0); |
659 | 0 | version_info.nghttp2_ver_num = (unsigned int)h2->version_num; |
660 | 0 | version_info.nghttp2_version = h2->version_str; |
661 | 0 | } |
662 | 0 | #endif |
663 | |
|
664 | | #if !defined(CURL_DISABLE_HTTP) && defined(USE_HTTP3) |
665 | | { |
666 | | static char quicbuffer[80]; |
667 | | Curl_quic_ver(quicbuffer, sizeof(quicbuffer)); |
668 | | version_info.quic_version = quicbuffer; |
669 | | } |
670 | | #endif |
671 | |
|
672 | | #ifdef USE_GSASL |
673 | | { |
674 | | version_info.gsasl_version = gsasl_check_version(NULL); |
675 | | } |
676 | | #endif |
677 | | |
678 | | /* Get available features, build bitmask and names array. */ |
679 | 0 | n = 0; |
680 | 0 | for(p = features_table; p->name; p++) |
681 | 0 | if(!p->present || p->present(&version_info)) { |
682 | 0 | features |= p->bitmask; |
683 | 0 | feature_names[n++] = p->name; |
684 | 0 | } |
685 | |
|
686 | 0 | feature_names[n] = NULL; /* Terminate array. */ |
687 | 0 | version_info.features = features; |
688 | |
|
689 | | #ifdef USE_LIBRTMP |
690 | | { |
691 | | static char rtmp_version[30]; |
692 | | Curl_rtmp_version(rtmp_version, sizeof(rtmp_version)); |
693 | | version_info.rtmp_version = rtmp_version; |
694 | | } |
695 | | #endif |
696 | |
|
697 | 0 | return &version_info; |
698 | 0 | } |