version.c 16 KB

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