version.c 17 KB

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