Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * _ _ ____ _ |
| 3 | * Project ___| | | | _ \| | |
| 4 | * / __| | | | |_) | | |
| 5 | * | (__| |_| | _ <| |___ |
| 6 | * \___|\___/|_| \_\_____| |
| 7 | * |
Elliott Hughes | 1ef06ba | 2018-05-30 15:43:58 -0700 | [diff] [blame] | 8 | * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 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 |
Alex Deymo | 8f1a214 | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 12 | * are also available at https://curl.haxx.se/docs/copyright.html. |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 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 | ***************************************************************************/ |
| 22 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 23 | #include "curl_setup.h" |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 24 | |
| 25 | #include <curl/curl.h> |
| 26 | #include "urldata.h" |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 27 | #include "vtls/vtls.h" |
| 28 | #include "http2.h" |
Elliott Hughes | 0128fe4 | 2018-02-27 14:57:55 -0800 | [diff] [blame] | 29 | #include "ssh.h" |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 30 | #include "curl_printf.h" |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 31 | |
| 32 | #ifdef USE_ARES |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 33 | # if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \ |
| 34 | (defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)) |
| 35 | # define CARES_STATICLIB |
| 36 | # endif |
| 37 | # include <ares.h> |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 38 | #endif |
| 39 | |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 40 | #ifdef USE_LIBIDN2 |
| 41 | #include <idn2.h> |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 42 | #endif |
| 43 | |
Alex Deymo | 8f1a214 | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 44 | #ifdef USE_LIBPSL |
| 45 | #include <libpsl.h> |
| 46 | #endif |
| 47 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 48 | #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS) |
| 49 | #include <iconv.h> |
| 50 | #endif |
| 51 | |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 52 | #ifdef USE_LIBRTMP |
| 53 | #include <librtmp/rtmp.h> |
| 54 | #endif |
| 55 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 56 | #ifdef USE_LIBSSH2 |
| 57 | #include <libssh2.h> |
| 58 | #endif |
| 59 | |
| 60 | #ifdef HAVE_LIBSSH2_VERSION |
| 61 | /* get it run-time if possible */ |
| 62 | #define CURL_LIBSSH2_VERSION libssh2_version(0) |
| 63 | #else |
| 64 | /* use build-time if run-time not possible */ |
| 65 | #define CURL_LIBSSH2_VERSION LIBSSH2_VERSION |
| 66 | #endif |
| 67 | |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 68 | #ifdef HAVE_ZLIB_H |
| 69 | #include <zlib.h> |
| 70 | #ifdef __SYMBIAN32__ |
| 71 | /* zlib pollutes the namespace with this definition */ |
| 72 | #undef WIN32 |
| 73 | #endif |
| 74 | #endif |
| 75 | |
| 76 | #ifdef HAVE_BROTLI |
| 77 | #include <brotli/decode.h> |
| 78 | #endif |
| 79 | |
Alex Deymo | 8f1a214 | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 80 | void Curl_version_init(void); |
| 81 | |
| 82 | /* For thread safety purposes this function is called by global_init so that |
| 83 | the static data in both version functions is initialized. */ |
| 84 | void Curl_version_init(void) |
| 85 | { |
| 86 | curl_version(); |
| 87 | curl_version_info(CURLVERSION_NOW); |
| 88 | } |
| 89 | |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 90 | #ifdef HAVE_BROTLI |
| 91 | static size_t brotli_version(char *buf, size_t bufsz) |
| 92 | { |
| 93 | uint32_t brotli_version = BrotliDecoderVersion(); |
| 94 | unsigned int major = brotli_version >> 24; |
| 95 | unsigned int minor = (brotli_version & 0x00FFFFFF) >> 12; |
| 96 | unsigned int patch = brotli_version & 0x00000FFF; |
| 97 | |
| 98 | return snprintf(buf, bufsz, "%u.%u.%u", major, minor, patch); |
| 99 | } |
| 100 | #endif |
| 101 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 102 | char *curl_version(void) |
| 103 | { |
Alex Deymo | 8f1a214 | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 104 | static bool initialized; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 105 | static char version[200]; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 106 | char *ptr = version; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 107 | size_t len; |
| 108 | size_t left = sizeof(version); |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 109 | |
Alex Deymo | 8f1a214 | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 110 | if(initialized) |
| 111 | return version; |
| 112 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 113 | strcpy(ptr, LIBCURL_NAME "/" LIBCURL_VERSION); |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 114 | len = strlen(ptr); |
| 115 | left -= len; |
| 116 | ptr += len; |
| 117 | |
| 118 | if(left > 1) { |
| 119 | len = Curl_ssl_version(ptr + 1, left - 1); |
| 120 | |
| 121 | if(len > 0) { |
| 122 | *ptr = ' '; |
| 123 | left -= ++len; |
| 124 | ptr += len; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | #ifdef HAVE_LIBZ |
| 129 | len = snprintf(ptr, left, " zlib/%s", zlibVersion()); |
| 130 | left -= len; |
| 131 | ptr += len; |
| 132 | #endif |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 133 | #ifdef HAVE_BROTLI |
| 134 | len = snprintf(ptr, left, "%s", " brotli/"); |
| 135 | left -= len; |
| 136 | ptr += len; |
| 137 | len = brotli_version(ptr, left); |
| 138 | left -= len; |
| 139 | ptr += len; |
| 140 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 141 | #ifdef USE_ARES |
| 142 | /* this function is only present in c-ares, not in the original ares */ |
| 143 | len = snprintf(ptr, left, " c-ares/%s", ares_version(NULL)); |
| 144 | left -= len; |
| 145 | ptr += len; |
| 146 | #endif |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 147 | #ifdef USE_LIBIDN2 |
| 148 | if(idn2_check_version(IDN2_VERSION)) { |
| 149 | len = snprintf(ptr, left, " libidn2/%s", idn2_check_version(NULL)); |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 150 | left -= len; |
| 151 | ptr += len; |
| 152 | } |
| 153 | #endif |
Alex Deymo | 8f1a214 | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 154 | #ifdef USE_LIBPSL |
| 155 | len = snprintf(ptr, left, " libpsl/%s", psl_get_version()); |
| 156 | left -= len; |
| 157 | ptr += len; |
| 158 | #endif |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 159 | #ifdef USE_WIN32_IDN |
| 160 | len = snprintf(ptr, left, " WinIDN"); |
| 161 | left -= len; |
| 162 | ptr += len; |
| 163 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 164 | #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS) |
| 165 | #ifdef _LIBICONV_VERSION |
| 166 | len = snprintf(ptr, left, " iconv/%d.%d", |
| 167 | _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 255); |
| 168 | #else |
| 169 | /* version unknown */ |
| 170 | len = snprintf(ptr, left, " iconv"); |
| 171 | #endif /* _LIBICONV_VERSION */ |
| 172 | left -= len; |
| 173 | ptr += len; |
| 174 | #endif |
| 175 | #ifdef USE_LIBSSH2 |
| 176 | len = snprintf(ptr, left, " libssh2/%s", CURL_LIBSSH2_VERSION); |
| 177 | left -= len; |
| 178 | ptr += len; |
| 179 | #endif |
Elliott Hughes | 0128fe4 | 2018-02-27 14:57:55 -0800 | [diff] [blame] | 180 | #ifdef USE_LIBSSH |
| 181 | len = snprintf(ptr, left, " libssh/%s", CURL_LIBSSH_VERSION); |
| 182 | left -= len; |
| 183 | ptr += len; |
| 184 | #endif |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 185 | #ifdef USE_NGHTTP2 |
| 186 | len = Curl_http2_ver(ptr, left); |
| 187 | left -= len; |
| 188 | ptr += len; |
| 189 | #endif |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 190 | #ifdef USE_LIBRTMP |
| 191 | { |
| 192 | char suff[2]; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 193 | if(RTMP_LIB_VERSION & 0xff) { |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 194 | suff[0] = (RTMP_LIB_VERSION & 0xff) + 'a' - 1; |
| 195 | suff[1] = '\0'; |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 196 | } |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 197 | else |
| 198 | suff[0] = '\0'; |
| 199 | |
| 200 | snprintf(ptr, left, " librtmp/%d.%d%s", |
| 201 | RTMP_LIB_VERSION >> 16, (RTMP_LIB_VERSION >> 8) & 0xff, |
| 202 | suff); |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 203 | /* |
| 204 | If another lib version is added below this one, this code would |
| 205 | also have to do: |
| 206 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 207 | len = what snprintf() returned |
| 208 | |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 209 | left -= len; |
| 210 | ptr += len; |
| 211 | */ |
| 212 | } |
| 213 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 214 | |
Alex Deymo | 8f1a214 | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 215 | initialized = true; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 216 | return version; |
| 217 | } |
| 218 | |
| 219 | /* data for curl_version_info |
| 220 | |
| 221 | Keep the list sorted alphabetically. It is also written so that each |
| 222 | protocol line has its own #if line to make things easier on the eye. |
| 223 | */ |
| 224 | |
| 225 | static const char * const protocols[] = { |
| 226 | #ifndef CURL_DISABLE_DICT |
| 227 | "dict", |
| 228 | #endif |
| 229 | #ifndef CURL_DISABLE_FILE |
| 230 | "file", |
| 231 | #endif |
| 232 | #ifndef CURL_DISABLE_FTP |
| 233 | "ftp", |
| 234 | #endif |
| 235 | #if defined(USE_SSL) && !defined(CURL_DISABLE_FTP) |
| 236 | "ftps", |
| 237 | #endif |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 238 | #ifndef CURL_DISABLE_GOPHER |
| 239 | "gopher", |
| 240 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 241 | #ifndef CURL_DISABLE_HTTP |
| 242 | "http", |
| 243 | #endif |
| 244 | #if defined(USE_SSL) && !defined(CURL_DISABLE_HTTP) |
| 245 | "https", |
| 246 | #endif |
| 247 | #ifndef CURL_DISABLE_IMAP |
| 248 | "imap", |
| 249 | #endif |
| 250 | #if defined(USE_SSL) && !defined(CURL_DISABLE_IMAP) |
| 251 | "imaps", |
| 252 | #endif |
| 253 | #ifndef CURL_DISABLE_LDAP |
| 254 | "ldap", |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 255 | #if !defined(CURL_DISABLE_LDAPS) && \ |
| 256 | ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \ |
| 257 | (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL))) |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 258 | "ldaps", |
| 259 | #endif |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 260 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 261 | #ifndef CURL_DISABLE_POP3 |
| 262 | "pop3", |
| 263 | #endif |
| 264 | #if defined(USE_SSL) && !defined(CURL_DISABLE_POP3) |
| 265 | "pop3s", |
| 266 | #endif |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 267 | #ifdef USE_LIBRTMP |
| 268 | "rtmp", |
| 269 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 270 | #ifndef CURL_DISABLE_RTSP |
| 271 | "rtsp", |
| 272 | #endif |
Elliott Hughes | 0128fe4 | 2018-02-27 14:57:55 -0800 | [diff] [blame] | 273 | #if defined(USE_LIBSSH) || defined(USE_LIBSSH2) |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 274 | "scp", |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 275 | "sftp", |
| 276 | #endif |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 277 | #if !defined(CURL_DISABLE_SMB) && defined(USE_NTLM) && \ |
| 278 | (CURL_SIZEOF_CURL_OFF_T > 4) && \ |
| 279 | (!defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO)) |
| 280 | "smb", |
| 281 | # ifdef USE_SSL |
| 282 | "smbs", |
| 283 | # endif |
| 284 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 285 | #ifndef CURL_DISABLE_SMTP |
| 286 | "smtp", |
| 287 | #endif |
| 288 | #if defined(USE_SSL) && !defined(CURL_DISABLE_SMTP) |
| 289 | "smtps", |
| 290 | #endif |
| 291 | #ifndef CURL_DISABLE_TELNET |
| 292 | "telnet", |
| 293 | #endif |
| 294 | #ifndef CURL_DISABLE_TFTP |
| 295 | "tftp", |
| 296 | #endif |
| 297 | |
| 298 | NULL |
| 299 | }; |
| 300 | |
| 301 | static curl_version_info_data version_info = { |
| 302 | CURLVERSION_NOW, |
| 303 | LIBCURL_VERSION, |
| 304 | LIBCURL_VERSION_NUM, |
| 305 | OS, /* as found by configure or set by hand at build-time */ |
| 306 | 0 /* features is 0 by default */ |
| 307 | #ifdef ENABLE_IPV6 |
| 308 | | CURL_VERSION_IPV6 |
| 309 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 310 | #ifdef USE_SSL |
| 311 | | CURL_VERSION_SSL |
| 312 | #endif |
| 313 | #ifdef USE_NTLM |
| 314 | | CURL_VERSION_NTLM |
| 315 | #endif |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 316 | #if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \ |
| 317 | defined(NTLM_WB_ENABLED) |
| 318 | | CURL_VERSION_NTLM_WB |
| 319 | #endif |
| 320 | #ifdef USE_SPNEGO |
| 321 | | CURL_VERSION_SPNEGO |
| 322 | #endif |
| 323 | #ifdef USE_KERBEROS5 |
| 324 | | CURL_VERSION_KERBEROS5 |
| 325 | #endif |
| 326 | #ifdef HAVE_GSSAPI |
| 327 | | CURL_VERSION_GSSAPI |
| 328 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 329 | #ifdef USE_WINDOWS_SSPI |
| 330 | | CURL_VERSION_SSPI |
| 331 | #endif |
| 332 | #ifdef HAVE_LIBZ |
| 333 | | CURL_VERSION_LIBZ |
| 334 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 335 | #ifdef DEBUGBUILD |
| 336 | | CURL_VERSION_DEBUG |
| 337 | #endif |
| 338 | #ifdef CURLDEBUG |
| 339 | | CURL_VERSION_CURLDEBUG |
| 340 | #endif |
| 341 | #ifdef CURLRES_ASYNCH |
| 342 | | CURL_VERSION_ASYNCHDNS |
| 343 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 344 | #if (CURL_SIZEOF_CURL_OFF_T > 4) && \ |
| 345 | ( (SIZEOF_OFF_T > 4) || defined(USE_WIN32_LARGE_FILES) ) |
| 346 | | CURL_VERSION_LARGEFILE |
| 347 | #endif |
| 348 | #if defined(CURL_DOES_CONVERSIONS) |
| 349 | | CURL_VERSION_CONV |
| 350 | #endif |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 351 | #if defined(USE_TLS_SRP) |
| 352 | | CURL_VERSION_TLSAUTH_SRP |
| 353 | #endif |
| 354 | #if defined(USE_NGHTTP2) |
| 355 | | CURL_VERSION_HTTP2 |
| 356 | #endif |
| 357 | #if defined(USE_UNIX_SOCKETS) |
| 358 | | CURL_VERSION_UNIX_SOCKETS |
| 359 | #endif |
Alex Deymo | 8f1a214 | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 360 | #if defined(USE_LIBPSL) |
| 361 | | CURL_VERSION_PSL |
| 362 | #endif |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 363 | #if defined(CURL_WITH_MULTI_SSL) |
| 364 | | CURL_VERSION_MULTI_SSL |
| 365 | #endif |
| 366 | #if defined(HAVE_BROTLI) |
| 367 | | CURL_VERSION_BROTLI |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 368 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 369 | , |
| 370 | NULL, /* ssl_version */ |
| 371 | 0, /* ssl_version_num, this is kept at zero */ |
| 372 | NULL, /* zlib_version */ |
| 373 | protocols, |
| 374 | NULL, /* c-ares version */ |
| 375 | 0, /* c-ares version numerical */ |
| 376 | NULL, /* libidn version */ |
| 377 | 0, /* iconv version */ |
| 378 | NULL, /* ssh lib version */ |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 379 | 0, /* brotli_ver_num */ |
| 380 | NULL, /* brotli version */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 381 | }; |
| 382 | |
| 383 | curl_version_info_data *curl_version_info(CURLversion stamp) |
| 384 | { |
Alex Deymo | 8f1a214 | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 385 | static bool initialized; |
Elliott Hughes | 0128fe4 | 2018-02-27 14:57:55 -0800 | [diff] [blame] | 386 | #if defined(USE_LIBSSH) || defined(USE_LIBSSH2) |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 387 | static char ssh_buffer[80]; |
| 388 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 389 | #ifdef USE_SSL |
| 390 | static char ssl_buffer[80]; |
Alex Deymo | 8f1a214 | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 391 | #endif |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 392 | #ifdef HAVE_BROTLI |
| 393 | static char brotli_buffer[80]; |
| 394 | #endif |
Alex Deymo | 8f1a214 | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 395 | |
| 396 | if(initialized) |
| 397 | return &version_info; |
| 398 | |
| 399 | #ifdef USE_SSL |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 400 | Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer)); |
| 401 | version_info.ssl_version = ssl_buffer; |
Elliott Hughes | 1ef06ba | 2018-05-30 15:43:58 -0700 | [diff] [blame] | 402 | if(Curl_ssl->supports & SSLSUPP_HTTPS_PROXY) |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 403 | version_info.features |= CURL_VERSION_HTTPS_PROXY; |
| 404 | else |
| 405 | version_info.features &= ~CURL_VERSION_HTTPS_PROXY; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 406 | #endif |
| 407 | |
| 408 | #ifdef HAVE_LIBZ |
| 409 | version_info.libz_version = zlibVersion(); |
| 410 | /* libz left NULL if non-existing */ |
| 411 | #endif |
| 412 | #ifdef USE_ARES |
| 413 | { |
| 414 | int aresnum; |
| 415 | version_info.ares = ares_version(&aresnum); |
| 416 | version_info.ares_num = aresnum; |
| 417 | } |
| 418 | #endif |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 419 | #ifdef USE_LIBIDN2 |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 420 | /* This returns a version string if we use the given version or later, |
| 421 | otherwise it returns NULL */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 422 | version_info.libidn = idn2_check_version(IDN2_VERSION); |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 423 | if(version_info.libidn) |
| 424 | version_info.features |= CURL_VERSION_IDN; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 425 | #elif defined(USE_WIN32_IDN) |
| 426 | version_info.features |= CURL_VERSION_IDN; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 427 | #endif |
| 428 | |
| 429 | #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS) |
| 430 | #ifdef _LIBICONV_VERSION |
| 431 | version_info.iconv_ver_num = _LIBICONV_VERSION; |
| 432 | #else |
| 433 | /* version unknown */ |
| 434 | version_info.iconv_ver_num = -1; |
| 435 | #endif /* _LIBICONV_VERSION */ |
| 436 | #endif |
| 437 | |
Elliott Hughes | 0128fe4 | 2018-02-27 14:57:55 -0800 | [diff] [blame] | 438 | #if defined(USE_LIBSSH2) |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 439 | snprintf(ssh_buffer, sizeof(ssh_buffer), "libssh2/%s", LIBSSH2_VERSION); |
| 440 | version_info.libssh_version = ssh_buffer; |
Elliott Hughes | 0128fe4 | 2018-02-27 14:57:55 -0800 | [diff] [blame] | 441 | #elif defined(USE_LIBSSH) |
| 442 | snprintf(ssh_buffer, sizeof(ssh_buffer), "libssh/%s", CURL_LIBSSH_VERSION); |
| 443 | version_info.libssh_version = ssh_buffer; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 444 | #endif |
| 445 | |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 446 | #ifdef HAVE_BROTLI |
| 447 | version_info.brotli_ver_num = BrotliDecoderVersion(); |
| 448 | brotli_version(brotli_buffer, sizeof brotli_buffer); |
| 449 | version_info.brotli_version = brotli_buffer; |
| 450 | #endif |
| 451 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 452 | (void)stamp; /* avoid compiler warnings, we don't use this */ |
| 453 | |
Alex Deymo | 8f1a214 | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 454 | initialized = true; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 455 | return &version_info; |
| 456 | } |