version.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  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. static int https_proxy_present(curl_version_info_data *info)
  381. {
  382. (void) info;
  383. return Curl_ssl_supports(NULL, SSLSUPP_HTTPS_PROXY);
  384. }
  385. #endif
  386. /*
  387. * Features table.
  388. *
  389. * Keep the features alphabetically sorted.
  390. * Use FEATURE() macro to define an entry: this allows documentation check.
  391. */
  392. #define FEATURE(name, present, bitmask) {(name), (present), (bitmask)}
  393. struct feat {
  394. const char *name;
  395. int (*present)(curl_version_info_data *info);
  396. int bitmask;
  397. };
  398. static const struct feat features_table[] = {
  399. #ifndef CURL_DISABLE_ALTSVC
  400. FEATURE("alt-svc", NULL, CURL_VERSION_ALTSVC),
  401. #endif
  402. #ifdef CURLRES_ASYNCH
  403. FEATURE("AsynchDNS", NULL, CURL_VERSION_ASYNCHDNS),
  404. #endif
  405. #ifdef HAVE_BROTLI
  406. FEATURE("brotli", NULL, CURL_VERSION_BROTLI),
  407. #endif
  408. #ifdef DEBUGBUILD
  409. FEATURE("Debug", NULL, CURL_VERSION_DEBUG),
  410. #endif
  411. #ifdef USE_GSASL
  412. FEATURE("gsasl", NULL, CURL_VERSION_GSASL),
  413. #endif
  414. #ifdef HAVE_GSSAPI
  415. FEATURE("GSS-API", NULL, CURL_VERSION_GSSAPI),
  416. #endif
  417. #ifndef CURL_DISABLE_HSTS
  418. FEATURE("HSTS", NULL, CURL_VERSION_HSTS),
  419. #endif
  420. #if defined(USE_NGHTTP2) || defined(USE_HYPER)
  421. FEATURE("HTTP2", NULL, CURL_VERSION_HTTP2),
  422. #endif
  423. #if defined(ENABLE_QUIC)
  424. FEATURE("HTTP3", NULL, CURL_VERSION_HTTP3),
  425. #endif
  426. #if defined(USE_SSL) && !defined(CURL_DISABLE_PROXY)
  427. FEATURE("HTTPS-proxy", https_proxy_present, CURL_VERSION_HTTPS_PROXY),
  428. #endif
  429. #if defined(USE_LIBIDN2) || defined(USE_WIN32_IDN)
  430. FEATURE("IDN", idn_present, CURL_VERSION_IDN),
  431. #endif
  432. #ifdef ENABLE_IPV6
  433. FEATURE("IPv6", NULL, CURL_VERSION_IPV6),
  434. #endif
  435. #ifdef USE_KERBEROS5
  436. FEATURE("Kerberos", NULL, CURL_VERSION_KERBEROS5),
  437. #endif
  438. #if (SIZEOF_CURL_OFF_T > 4) && \
  439. ( (SIZEOF_OFF_T > 4) || defined(USE_WIN32_LARGE_FILES) )
  440. FEATURE("Largefile", NULL, CURL_VERSION_LARGEFILE),
  441. #endif
  442. #ifdef HAVE_LIBZ
  443. FEATURE("libz", NULL, CURL_VERSION_LIBZ),
  444. #endif
  445. #ifdef CURL_WITH_MULTI_SSL
  446. FEATURE("MultiSSL", NULL, CURL_VERSION_MULTI_SSL),
  447. #endif
  448. #ifdef USE_NTLM
  449. FEATURE("NTLM", NULL, CURL_VERSION_NTLM),
  450. #endif
  451. #if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \
  452. defined(NTLM_WB_ENABLED)
  453. FEATURE("NTLM_WB", NULL, CURL_VERSION_NTLM_WB),
  454. #endif
  455. #if defined(USE_LIBPSL)
  456. FEATURE("PSL", NULL, CURL_VERSION_PSL),
  457. #endif
  458. #ifdef USE_SPNEGO
  459. FEATURE("SPNEGO", NULL, CURL_VERSION_SPNEGO),
  460. #endif
  461. #ifdef USE_SSL
  462. FEATURE("SSL", NULL, CURL_VERSION_SSL),
  463. #endif
  464. #ifdef USE_WINDOWS_SSPI
  465. FEATURE("SSPI", NULL, CURL_VERSION_SSPI),
  466. #endif
  467. #ifdef GLOBAL_INIT_IS_THREADSAFE
  468. FEATURE("threadsafe", NULL, CURL_VERSION_THREADSAFE),
  469. #endif
  470. #ifdef USE_TLS_SRP
  471. FEATURE("TLS-SRP", NULL, CURL_VERSION_TLSAUTH_SRP),
  472. #endif
  473. #ifdef CURLDEBUG
  474. FEATURE("TrackMemory", NULL, CURL_VERSION_CURLDEBUG),
  475. #endif
  476. #if defined(WIN32) && defined(UNICODE) && defined(_UNICODE)
  477. FEATURE("Unicode", NULL, CURL_VERSION_UNICODE),
  478. #endif
  479. #ifdef USE_UNIX_SOCKETS
  480. FEATURE("UnixSockets", NULL, CURL_VERSION_UNIX_SOCKETS),
  481. #endif
  482. #ifdef HAVE_ZSTD
  483. FEATURE("zstd", NULL, CURL_VERSION_ZSTD),
  484. #endif
  485. {NULL, NULL, 0}
  486. };
  487. static const char *feature_names[sizeof(features_table) /
  488. sizeof(features_table[0])] = {NULL};
  489. static curl_version_info_data version_info = {
  490. CURLVERSION_NOW,
  491. LIBCURL_VERSION,
  492. LIBCURL_VERSION_NUM,
  493. OS, /* as found by configure or set by hand at build-time */
  494. 0, /* features bitmask is built at run-time */
  495. NULL, /* ssl_version */
  496. 0, /* ssl_version_num, this is kept at zero */
  497. NULL, /* zlib_version */
  498. supported_protocols,
  499. NULL, /* c-ares version */
  500. 0, /* c-ares version numerical */
  501. NULL, /* libidn version */
  502. 0, /* iconv version */
  503. NULL, /* ssh lib version */
  504. 0, /* brotli_ver_num */
  505. NULL, /* brotli version */
  506. 0, /* nghttp2 version number */
  507. NULL, /* nghttp2 version string */
  508. NULL, /* quic library string */
  509. #ifdef CURL_CA_BUNDLE
  510. CURL_CA_BUNDLE, /* cainfo */
  511. #else
  512. NULL,
  513. #endif
  514. #ifdef CURL_CA_PATH
  515. CURL_CA_PATH, /* capath */
  516. #else
  517. NULL,
  518. #endif
  519. 0, /* zstd_ver_num */
  520. NULL, /* zstd version */
  521. NULL, /* Hyper version */
  522. NULL, /* gsasl version */
  523. feature_names
  524. };
  525. curl_version_info_data *curl_version_info(CURLversion stamp)
  526. {
  527. size_t n;
  528. const struct feat *p;
  529. int features = 0;
  530. #if defined(USE_SSH)
  531. static char ssh_buffer[80];
  532. #endif
  533. #ifdef USE_SSL
  534. #ifdef CURL_WITH_MULTI_SSL
  535. static char ssl_buffer[200];
  536. #else
  537. static char ssl_buffer[80];
  538. #endif
  539. #endif
  540. #ifdef HAVE_BROTLI
  541. static char brotli_buffer[80];
  542. #endif
  543. #ifdef HAVE_ZSTD
  544. static char zstd_buffer[80];
  545. #endif
  546. (void)stamp; /* avoid compiler warnings, we don't use this */
  547. #ifdef USE_SSL
  548. Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer));
  549. version_info.ssl_version = ssl_buffer;
  550. #endif
  551. #ifdef HAVE_LIBZ
  552. version_info.libz_version = zlibVersion();
  553. /* libz left NULL if non-existing */
  554. #endif
  555. #ifdef USE_ARES
  556. {
  557. int aresnum;
  558. version_info.ares = ares_version(&aresnum);
  559. version_info.ares_num = aresnum;
  560. }
  561. #endif
  562. #ifdef USE_LIBIDN2
  563. /* This returns a version string if we use the given version or later,
  564. otherwise it returns NULL */
  565. version_info.libidn = idn2_check_version(IDN2_VERSION);
  566. #endif
  567. #if defined(USE_SSH)
  568. Curl_ssh_version(ssh_buffer, sizeof(ssh_buffer));
  569. version_info.libssh_version = ssh_buffer;
  570. #endif
  571. #ifdef HAVE_BROTLI
  572. version_info.brotli_ver_num = BrotliDecoderVersion();
  573. brotli_version(brotli_buffer, sizeof(brotli_buffer));
  574. version_info.brotli_version = brotli_buffer;
  575. #endif
  576. #ifdef HAVE_ZSTD
  577. version_info.zstd_ver_num = (unsigned int)ZSTD_versionNumber();
  578. zstd_version(zstd_buffer, sizeof(zstd_buffer));
  579. version_info.zstd_version = zstd_buffer;
  580. #endif
  581. #ifdef USE_NGHTTP2
  582. {
  583. nghttp2_info *h2 = nghttp2_version(0);
  584. version_info.nghttp2_ver_num = h2->version_num;
  585. version_info.nghttp2_version = h2->version_str;
  586. }
  587. #endif
  588. #ifdef ENABLE_QUIC
  589. {
  590. static char quicbuffer[80];
  591. Curl_quic_ver(quicbuffer, sizeof(quicbuffer));
  592. version_info.quic_version = quicbuffer;
  593. }
  594. #endif
  595. #ifdef USE_HYPER
  596. {
  597. static char hyper_buffer[30];
  598. msnprintf(hyper_buffer, sizeof(hyper_buffer), "Hyper/%s", hyper_version());
  599. version_info.hyper_version = hyper_buffer;
  600. }
  601. #endif
  602. #ifdef USE_GSASL
  603. {
  604. version_info.gsasl_version = gsasl_check_version(NULL);
  605. }
  606. #endif
  607. /* Get available features, build bitmask and names array. */
  608. n = 0;
  609. for(p = features_table; p->name; p++)
  610. if(!p->present || p->present(&version_info)) {
  611. features |= p->bitmask;
  612. feature_names[n++] = p->name;
  613. }
  614. feature_names[n] = NULL; /* Terminate array. */
  615. version_info.features = features;
  616. return &version_info;
  617. }