2
0

version.c 17 KB

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