version.c 17 KB

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