version.c 16 KB

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