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