version.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) Daniel Stenberg, <[email protected]>, 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 <cm3p/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. {
  195. int num = psl_check_version_number(0);
  196. msnprintf(psl_version, sizeof(psl_version), "libpsl/%d.%d.%d",
  197. num >> 16, (num >> 8) & 0xff, num & 0xff);
  198. src[i++] = psl_version;
  199. }
  200. #endif
  201. #ifdef USE_SSH
  202. Curl_ssh_version(ssh_version, sizeof(ssh_version));
  203. src[i++] = ssh_version;
  204. #endif
  205. #ifdef USE_NGHTTP2
  206. Curl_http2_ver(h2_version, sizeof(h2_version));
  207. src[i++] = h2_version;
  208. #endif
  209. #ifdef ENABLE_QUIC
  210. Curl_quic_ver(h3_version, sizeof(h3_version));
  211. src[i++] = h3_version;
  212. #endif
  213. #ifdef USE_LIBRTMP
  214. {
  215. char suff[2];
  216. if(RTMP_LIB_VERSION & 0xff) {
  217. suff[0] = (RTMP_LIB_VERSION & 0xff) + 'a' - 1;
  218. suff[1] = '\0';
  219. }
  220. else
  221. suff[0] = '\0';
  222. msnprintf(rtmp_version, sizeof(rtmp_version), "librtmp/%d.%d%s",
  223. RTMP_LIB_VERSION >> 16, (RTMP_LIB_VERSION >> 8) & 0xff,
  224. suff);
  225. src[i++] = rtmp_version;
  226. }
  227. #endif
  228. #ifdef USE_HYPER
  229. msnprintf(hyper_buf, sizeof(hyper_buf), "Hyper/%s", hyper_version());
  230. src[i++] = hyper_buf;
  231. #endif
  232. #ifdef USE_GSASL
  233. msnprintf(gsasl_buf, sizeof(gsasl_buf), "libgsasl/%s",
  234. gsasl_check_version(NULL));
  235. src[i++] = gsasl_buf;
  236. #endif
  237. #ifdef USE_OPENLDAP
  238. {
  239. LDAPAPIInfo api;
  240. api.ldapai_info_version = LDAP_API_INFO_VERSION;
  241. if(ldap_get_option(NULL, LDAP_OPT_API_INFO, &api) == LDAP_OPT_SUCCESS) {
  242. unsigned int patch = api.ldapai_vendor_version % 100;
  243. unsigned int major = api.ldapai_vendor_version / 10000;
  244. unsigned int minor =
  245. ((api.ldapai_vendor_version - major * 10000) - patch) / 100;
  246. msnprintf(ldap_buf, sizeof(ldap_buf), "%s/%u.%u.%u",
  247. api.ldapai_vendor_name, major, minor, patch);
  248. src[i++] = ldap_buf;
  249. ldap_memfree(api.ldapai_vendor_name);
  250. ber_memvfree((void **)api.ldapai_extensions);
  251. }
  252. }
  253. #endif
  254. DEBUGASSERT(i <= VERSION_PARTS);
  255. outp = &out[0];
  256. outlen = sizeof(out);
  257. for(j = 0; j < i; j++) {
  258. size_t n = strlen(src[j]);
  259. /* we need room for a space, the string and the final zero */
  260. if(outlen <= (n + 2))
  261. break;
  262. if(j) {
  263. /* prepend a space if not the first */
  264. *outp++ = ' ';
  265. outlen--;
  266. }
  267. memcpy(outp, src[j], n);
  268. outp += n;
  269. outlen -= n;
  270. }
  271. *outp = 0;
  272. return out;
  273. }
  274. /* data for curl_version_info
  275. Keep the list sorted alphabetically. It is also written so that each
  276. protocol line has its own #if line to make things easier on the eye.
  277. */
  278. static const char * const supported_protocols[] = {
  279. #ifndef CURL_DISABLE_DICT
  280. "dict",
  281. #endif
  282. #ifndef CURL_DISABLE_FILE
  283. "file",
  284. #endif
  285. #ifndef CURL_DISABLE_FTP
  286. "ftp",
  287. #endif
  288. #if defined(USE_SSL) && !defined(CURL_DISABLE_FTP)
  289. "ftps",
  290. #endif
  291. #ifndef CURL_DISABLE_GOPHER
  292. "gopher",
  293. #endif
  294. #if defined(USE_SSL) && !defined(CURL_DISABLE_GOPHER)
  295. "gophers",
  296. #endif
  297. #ifndef CURL_DISABLE_HTTP
  298. "http",
  299. #endif
  300. #if defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)
  301. "https",
  302. #endif
  303. #ifndef CURL_DISABLE_IMAP
  304. "imap",
  305. #endif
  306. #if defined(USE_SSL) && !defined(CURL_DISABLE_IMAP)
  307. "imaps",
  308. #endif
  309. #ifndef CURL_DISABLE_LDAP
  310. "ldap",
  311. #if !defined(CURL_DISABLE_LDAPS) && \
  312. ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \
  313. (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL)))
  314. "ldaps",
  315. #endif
  316. #endif
  317. #ifndef CURL_DISABLE_MQTT
  318. "mqtt",
  319. #endif
  320. #ifndef CURL_DISABLE_POP3
  321. "pop3",
  322. #endif
  323. #if defined(USE_SSL) && !defined(CURL_DISABLE_POP3)
  324. "pop3s",
  325. #endif
  326. #ifdef USE_LIBRTMP
  327. "rtmp",
  328. "rtmpe",
  329. "rtmps",
  330. "rtmpt",
  331. "rtmpte",
  332. "rtmpts",
  333. #endif
  334. #ifndef CURL_DISABLE_RTSP
  335. "rtsp",
  336. #endif
  337. #if defined(USE_SSH) && !defined(USE_WOLFSSH)
  338. "scp",
  339. #endif
  340. #ifdef USE_SSH
  341. "sftp",
  342. #endif
  343. #if !defined(CURL_DISABLE_SMB) && defined(USE_CURL_NTLM_CORE)
  344. "smb",
  345. # ifdef USE_SSL
  346. "smbs",
  347. # endif
  348. #endif
  349. #ifndef CURL_DISABLE_SMTP
  350. "smtp",
  351. #endif
  352. #if defined(USE_SSL) && !defined(CURL_DISABLE_SMTP)
  353. "smtps",
  354. #endif
  355. #ifndef CURL_DISABLE_TELNET
  356. "telnet",
  357. #endif
  358. #ifndef CURL_DISABLE_TFTP
  359. "tftp",
  360. #endif
  361. #ifdef USE_WEBSOCKETS
  362. "ws",
  363. #endif
  364. #if defined(USE_SSL) && defined(USE_WEBSOCKETS)
  365. "wss",
  366. #endif
  367. NULL
  368. };
  369. /*
  370. * Feature presence run-time check functions.
  371. *
  372. * Warning: the value returned by these should not change between
  373. * curl_global_init() and curl_global_cleanup() calls.
  374. */
  375. #if defined(USE_LIBIDN2)
  376. static int idn_present(curl_version_info_data *info)
  377. {
  378. return info->libidn != NULL;
  379. }
  380. #else
  381. #define idn_present NULL
  382. #endif
  383. #if defined(USE_SSL) && !defined(CURL_DISABLE_PROXY) && \
  384. !defined(CURL_DISABLE_HTTP)
  385. static int https_proxy_present(curl_version_info_data *info)
  386. {
  387. (void) info;
  388. return Curl_ssl_supports(NULL, SSLSUPP_HTTPS_PROXY);
  389. }
  390. #endif
  391. /*
  392. * Features table.
  393. *
  394. * Keep the features alphabetically sorted.
  395. * Use FEATURE() macro to define an entry: this allows documentation check.
  396. */
  397. #define FEATURE(name, present, bitmask) {(name), (present), (bitmask)}
  398. struct feat {
  399. const char *name;
  400. int (*present)(curl_version_info_data *info);
  401. int bitmask;
  402. };
  403. static const struct feat features_table[] = {
  404. #ifndef CURL_DISABLE_ALTSVC
  405. FEATURE("alt-svc", NULL, CURL_VERSION_ALTSVC),
  406. #endif
  407. #ifdef CURLRES_ASYNCH
  408. FEATURE("AsynchDNS", NULL, CURL_VERSION_ASYNCHDNS),
  409. #endif
  410. #ifdef HAVE_BROTLI
  411. FEATURE("brotli", NULL, CURL_VERSION_BROTLI),
  412. #endif
  413. #ifdef DEBUGBUILD
  414. FEATURE("Debug", NULL, CURL_VERSION_DEBUG),
  415. #endif
  416. #ifdef USE_GSASL
  417. FEATURE("gsasl", NULL, CURL_VERSION_GSASL),
  418. #endif
  419. #ifdef HAVE_GSSAPI
  420. FEATURE("GSS-API", NULL, CURL_VERSION_GSSAPI),
  421. #endif
  422. #ifndef CURL_DISABLE_HSTS
  423. FEATURE("HSTS", NULL, CURL_VERSION_HSTS),
  424. #endif
  425. #if defined(USE_NGHTTP2)
  426. FEATURE("HTTP2", NULL, CURL_VERSION_HTTP2),
  427. #endif
  428. #if defined(ENABLE_QUIC)
  429. FEATURE("HTTP3", NULL, CURL_VERSION_HTTP3),
  430. #endif
  431. #if defined(USE_SSL) && !defined(CURL_DISABLE_PROXY) && \
  432. !defined(CURL_DISABLE_HTTP)
  433. FEATURE("HTTPS-proxy", https_proxy_present, CURL_VERSION_HTTPS_PROXY),
  434. #endif
  435. #if defined(USE_LIBIDN2) || defined(USE_WIN32_IDN)
  436. FEATURE("IDN", idn_present, CURL_VERSION_IDN),
  437. #endif
  438. #ifdef ENABLE_IPV6
  439. FEATURE("IPv6", NULL, CURL_VERSION_IPV6),
  440. #endif
  441. #ifdef USE_KERBEROS5
  442. FEATURE("Kerberos", NULL, CURL_VERSION_KERBEROS5),
  443. #endif
  444. #if (SIZEOF_CURL_OFF_T > 4) && \
  445. ( (SIZEOF_OFF_T > 4) || defined(USE_WIN32_LARGE_FILES) )
  446. FEATURE("Largefile", NULL, CURL_VERSION_LARGEFILE),
  447. #endif
  448. #ifdef HAVE_LIBZ
  449. FEATURE("libz", NULL, CURL_VERSION_LIBZ),
  450. #endif
  451. #ifdef CURL_WITH_MULTI_SSL
  452. FEATURE("MultiSSL", NULL, CURL_VERSION_MULTI_SSL),
  453. #endif
  454. #ifdef USE_NTLM
  455. FEATURE("NTLM", NULL, CURL_VERSION_NTLM),
  456. #endif
  457. #if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \
  458. defined(NTLM_WB_ENABLED)
  459. FEATURE("NTLM_WB", NULL, CURL_VERSION_NTLM_WB),
  460. #endif
  461. #if defined(USE_LIBPSL)
  462. FEATURE("PSL", NULL, CURL_VERSION_PSL),
  463. #endif
  464. #ifdef USE_SPNEGO
  465. FEATURE("SPNEGO", NULL, CURL_VERSION_SPNEGO),
  466. #endif
  467. #ifdef USE_SSL
  468. FEATURE("SSL", NULL, CURL_VERSION_SSL),
  469. #endif
  470. #ifdef USE_WINDOWS_SSPI
  471. FEATURE("SSPI", NULL, CURL_VERSION_SSPI),
  472. #endif
  473. #ifdef GLOBAL_INIT_IS_THREADSAFE
  474. FEATURE("threadsafe", NULL, CURL_VERSION_THREADSAFE),
  475. #endif
  476. #ifdef USE_TLS_SRP
  477. FEATURE("TLS-SRP", NULL, CURL_VERSION_TLSAUTH_SRP),
  478. #endif
  479. #ifdef CURLDEBUG
  480. FEATURE("TrackMemory", NULL, CURL_VERSION_CURLDEBUG),
  481. #endif
  482. #if defined(_WIN32) && defined(UNICODE) && defined(_UNICODE)
  483. FEATURE("Unicode", NULL, CURL_VERSION_UNICODE),
  484. #endif
  485. #ifdef USE_UNIX_SOCKETS
  486. FEATURE("UnixSockets", NULL, CURL_VERSION_UNIX_SOCKETS),
  487. #endif
  488. #ifdef HAVE_ZSTD
  489. FEATURE("zstd", NULL, CURL_VERSION_ZSTD),
  490. #endif
  491. {NULL, NULL, 0}
  492. };
  493. static const char *feature_names[sizeof(features_table) /
  494. sizeof(features_table[0])] = {NULL};
  495. static curl_version_info_data version_info = {
  496. CURLVERSION_NOW,
  497. LIBCURL_VERSION,
  498. LIBCURL_VERSION_NUM,
  499. OS, /* as found by configure or set by hand at build-time */
  500. 0, /* features bitmask is built at run-time */
  501. NULL, /* ssl_version */
  502. 0, /* ssl_version_num, this is kept at zero */
  503. NULL, /* zlib_version */
  504. supported_protocols,
  505. NULL, /* c-ares version */
  506. 0, /* c-ares version numerical */
  507. NULL, /* libidn version */
  508. 0, /* iconv version */
  509. NULL, /* ssh lib version */
  510. 0, /* brotli_ver_num */
  511. NULL, /* brotli version */
  512. 0, /* nghttp2 version number */
  513. NULL, /* nghttp2 version string */
  514. NULL, /* quic library string */
  515. #ifdef CURL_CA_BUNDLE
  516. CURL_CA_BUNDLE, /* cainfo */
  517. #else
  518. NULL,
  519. #endif
  520. #ifdef CURL_CA_PATH
  521. CURL_CA_PATH, /* capath */
  522. #else
  523. NULL,
  524. #endif
  525. 0, /* zstd_ver_num */
  526. NULL, /* zstd version */
  527. NULL, /* Hyper version */
  528. NULL, /* gsasl version */
  529. feature_names
  530. };
  531. curl_version_info_data *curl_version_info(CURLversion stamp)
  532. {
  533. size_t n;
  534. const struct feat *p;
  535. int features = 0;
  536. #if defined(USE_SSH)
  537. static char ssh_buffer[80];
  538. #endif
  539. #ifdef USE_SSL
  540. #ifdef CURL_WITH_MULTI_SSL
  541. static char ssl_buffer[200];
  542. #else
  543. static char ssl_buffer[80];
  544. #endif
  545. #endif
  546. #ifdef HAVE_BROTLI
  547. static char brotli_buffer[80];
  548. #endif
  549. #ifdef HAVE_ZSTD
  550. static char zstd_buffer[80];
  551. #endif
  552. (void)stamp; /* avoid compiler warnings, we don't use this */
  553. #ifdef USE_SSL
  554. Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer));
  555. version_info.ssl_version = ssl_buffer;
  556. #endif
  557. #ifdef HAVE_LIBZ
  558. version_info.libz_version = zlibVersion();
  559. /* libz left NULL if non-existing */
  560. #endif
  561. #ifdef USE_ARES
  562. {
  563. int aresnum;
  564. version_info.ares = ares_version(&aresnum);
  565. version_info.ares_num = aresnum;
  566. }
  567. #endif
  568. #ifdef USE_LIBIDN2
  569. /* This returns a version string if we use the given version or later,
  570. otherwise it returns NULL */
  571. version_info.libidn = idn2_check_version(IDN2_VERSION);
  572. #endif
  573. #if defined(USE_SSH)
  574. Curl_ssh_version(ssh_buffer, sizeof(ssh_buffer));
  575. version_info.libssh_version = ssh_buffer;
  576. #endif
  577. #ifdef HAVE_BROTLI
  578. version_info.brotli_ver_num = BrotliDecoderVersion();
  579. brotli_version(brotli_buffer, sizeof(brotli_buffer));
  580. version_info.brotli_version = brotli_buffer;
  581. #endif
  582. #ifdef HAVE_ZSTD
  583. version_info.zstd_ver_num = (unsigned int)ZSTD_versionNumber();
  584. zstd_version(zstd_buffer, sizeof(zstd_buffer));
  585. version_info.zstd_version = zstd_buffer;
  586. #endif
  587. #ifdef USE_NGHTTP2
  588. {
  589. nghttp2_info *h2 = nghttp2_version(0);
  590. version_info.nghttp2_ver_num = h2->version_num;
  591. version_info.nghttp2_version = h2->version_str;
  592. }
  593. #endif
  594. #ifdef ENABLE_QUIC
  595. {
  596. static char quicbuffer[80];
  597. Curl_quic_ver(quicbuffer, sizeof(quicbuffer));
  598. version_info.quic_version = quicbuffer;
  599. }
  600. #endif
  601. #ifdef USE_HYPER
  602. {
  603. static char hyper_buffer[30];
  604. msnprintf(hyper_buffer, sizeof(hyper_buffer), "Hyper/%s", hyper_version());
  605. version_info.hyper_version = hyper_buffer;
  606. }
  607. #endif
  608. #ifdef USE_GSASL
  609. {
  610. version_info.gsasl_version = gsasl_check_version(NULL);
  611. }
  612. #endif
  613. /* Get available features, build bitmask and names array. */
  614. n = 0;
  615. for(p = features_table; p->name; p++)
  616. if(!p->present || p->present(&version_info)) {
  617. features |= p->bitmask;
  618. feature_names[n++] = p->name;
  619. }
  620. feature_names[n] = NULL; /* Terminate array. */
  621. version_info.features = features;
  622. return &version_info;
  623. }