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