version.c 17 KB

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