diff options
Diffstat (limited to 'lib/version.c')
-rw-r--r-- | lib/version.c | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/lib/version.c b/lib/version.c index 1727c5a..1292445 100644 --- a/lib/version.c +++ b/lib/version.c @@ -5,11 +5,11 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. + * are also available at https://curl.haxx.se/docs/copyright.html. * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is @@ -40,6 +40,10 @@ #include <stringprep.h> #endif +#ifdef USE_LIBPSL +#include <libpsl.h> +#endif + #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS) #include <iconv.h> #endif @@ -60,13 +64,27 @@ #define CURL_LIBSSH2_VERSION LIBSSH2_VERSION #endif +void Curl_version_init(void); + +/* For thread safety purposes this function is called by global_init so that + the static data in both version functions is initialized. */ +void Curl_version_init(void) +{ + curl_version(); + curl_version_info(CURLVERSION_NOW); +} + char *curl_version(void) { + static bool initialized; static char version[200]; char *ptr = version; size_t len; size_t left = sizeof(version); + if(initialized) + return version; + strcpy(ptr, LIBCURL_NAME "/" LIBCURL_VERSION); len = strlen(ptr); left -= len; @@ -100,6 +118,11 @@ char *curl_version(void) ptr += len; } #endif +#ifdef USE_LIBPSL + len = snprintf(ptr, left, " libpsl/%s", psl_get_version()); + left -= len; + ptr += len; +#endif #ifdef USE_WIN32_IDN len = snprintf(ptr, left, " WinIDN"); left -= len; @@ -151,6 +174,7 @@ char *curl_version(void) } #endif + initialized = true; return version; } @@ -297,6 +321,9 @@ static curl_version_info_data version_info = { #if defined(USE_UNIX_SOCKETS) | CURL_VERSION_UNIX_SOCKETS #endif +#if defined(USE_LIBPSL) + | CURL_VERSION_PSL +#endif , NULL, /* ssl_version */ 0, /* ssl_version_num, this is kept at zero */ @@ -311,12 +338,18 @@ static curl_version_info_data version_info = { curl_version_info_data *curl_version_info(CURLversion stamp) { + static bool initialized; #ifdef USE_LIBSSH2 static char ssh_buffer[80]; #endif - #ifdef USE_SSL static char ssl_buffer[80]; +#endif + + if(initialized) + return &version_info; + +#ifdef USE_SSL Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer)); version_info.ssl_version = ssl_buffer; #endif @@ -358,5 +391,6 @@ curl_version_info_data *curl_version_info(CURLversion stamp) (void)stamp; /* avoid compiler warnings, we don't use this */ + initialized = true; return &version_info; } |