* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * 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
#include <stringprep.h>
#endif
+#ifdef USE_LIBPSL
+#include <libpsl.h>
+#endif
+
#if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
#include <iconv.h>
#endif
#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;
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;
}
#endif
+ initialized = true;
return version;
}
#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 */
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
(void)stamp; /* avoid compiler warnings, we don't use this */
+ initialized = true;
return &version_info;
}