version.c 17 KB

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