version.c 16 KB

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