1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
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 http://curl.haxx.se/docs/copyright.html.
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.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
23 #include "curl_setup.h"
25 #include <curl/curl.h>
27 #include "vtls/vtls.h"
29 #include "curl_printf.h"
32 # if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
33 (defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__))
34 # define CARES_STATICLIB
40 #include <stringprep.h>
43 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
48 #include <librtmp/rtmp.h>
55 #ifdef HAVE_LIBSSH2_VERSION
56 /* get it run-time if possible */
57 #define CURL_LIBSSH2_VERSION libssh2_version(0)
59 /* use build-time if run-time not possible */
60 #define CURL_LIBSSH2_VERSION LIBSSH2_VERSION
63 char *curl_version(void)
65 static char version[200];
68 size_t left = sizeof(version);
70 strcpy(ptr, LIBCURL_NAME "/" LIBCURL_VERSION);
76 len = Curl_ssl_version(ptr + 1, left - 1);
86 len = snprintf(ptr, left, " zlib/%s", zlibVersion());
91 /* this function is only present in c-ares, not in the original ares */
92 len = snprintf(ptr, left, " c-ares/%s", ares_version(NULL));
97 if(stringprep_check_version(LIBIDN_REQUIRED_VERSION)) {
98 len = snprintf(ptr, left, " libidn/%s", stringprep_check_version(NULL));
104 len = snprintf(ptr, left, " WinIDN");
108 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
109 #ifdef _LIBICONV_VERSION
110 len = snprintf(ptr, left, " iconv/%d.%d",
111 _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 255);
113 /* version unknown */
114 len = snprintf(ptr, left, " iconv");
115 #endif /* _LIBICONV_VERSION */
120 len = snprintf(ptr, left, " libssh2/%s", CURL_LIBSSH2_VERSION);
125 len = Curl_http2_ver(ptr, left);
132 if(RTMP_LIB_VERSION & 0xff) {
133 suff[0] = (RTMP_LIB_VERSION & 0xff) + 'a' - 1;
139 snprintf(ptr, left, " librtmp/%d.%d%s",
140 RTMP_LIB_VERSION >> 16, (RTMP_LIB_VERSION >> 8) & 0xff,
143 If another lib version is added below this one, this code would
146 len = what snprintf() returned
157 /* data for curl_version_info
159 Keep the list sorted alphabetically. It is also written so that each
160 protocol line has its own #if line to make things easier on the eye.
163 static const char * const protocols[] = {
164 #ifndef CURL_DISABLE_DICT
167 #ifndef CURL_DISABLE_FILE
170 #ifndef CURL_DISABLE_FTP
173 #if defined(USE_SSL) && !defined(CURL_DISABLE_FTP)
176 #ifndef CURL_DISABLE_GOPHER
179 #ifndef CURL_DISABLE_HTTP
182 #if defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)
185 #ifndef CURL_DISABLE_IMAP
188 #if defined(USE_SSL) && !defined(CURL_DISABLE_IMAP)
191 #ifndef CURL_DISABLE_LDAP
193 #if !defined(CURL_DISABLE_LDAPS) && \
194 ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \
195 (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL)))
199 #ifndef CURL_DISABLE_POP3
202 #if defined(USE_SSL) && !defined(CURL_DISABLE_POP3)
208 #ifndef CURL_DISABLE_RTSP
217 #if !defined(CURL_DISABLE_SMB) && defined(USE_NTLM) && \
218 (CURL_SIZEOF_CURL_OFF_T > 4) && \
219 (!defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO))
225 #ifndef CURL_DISABLE_SMTP
228 #if defined(USE_SSL) && !defined(CURL_DISABLE_SMTP)
231 #ifndef CURL_DISABLE_TELNET
234 #ifndef CURL_DISABLE_TFTP
241 static curl_version_info_data version_info = {
245 OS, /* as found by configure or set by hand at build-time */
246 0 /* features is 0 by default */
256 #if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \
257 defined(NTLM_WB_ENABLED)
258 | CURL_VERSION_NTLM_WB
261 | CURL_VERSION_SPNEGO
264 | CURL_VERSION_KERBEROS5
267 | CURL_VERSION_GSSAPI
269 #ifdef USE_WINDOWS_SSPI
279 | CURL_VERSION_CURLDEBUG
281 #ifdef CURLRES_ASYNCH
282 | CURL_VERSION_ASYNCHDNS
284 #if (CURL_SIZEOF_CURL_OFF_T > 4) && \
285 ( (SIZEOF_OFF_T > 4) || defined(USE_WIN32_LARGE_FILES) )
286 | CURL_VERSION_LARGEFILE
288 #if defined(CURL_DOES_CONVERSIONS)
291 #if defined(USE_TLS_SRP)
292 | CURL_VERSION_TLSAUTH_SRP
294 #if defined(USE_NGHTTP2)
297 #if defined(USE_UNIX_SOCKETS)
298 | CURL_VERSION_UNIX_SOCKETS
301 NULL, /* ssl_version */
302 0, /* ssl_version_num, this is kept at zero */
303 NULL, /* zlib_version */
305 NULL, /* c-ares version */
306 0, /* c-ares version numerical */
307 NULL, /* libidn version */
308 0, /* iconv version */
309 NULL, /* ssh lib version */
312 curl_version_info_data *curl_version_info(CURLversion stamp)
315 static char ssh_buffer[80];
319 static char ssl_buffer[80];
320 Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer));
321 version_info.ssl_version = ssl_buffer;
325 version_info.libz_version = zlibVersion();
326 /* libz left NULL if non-existing */
331 version_info.ares = ares_version(&aresnum);
332 version_info.ares_num = aresnum;
336 /* This returns a version string if we use the given version or later,
337 otherwise it returns NULL */
338 version_info.libidn = stringprep_check_version(LIBIDN_REQUIRED_VERSION);
339 if(version_info.libidn)
340 version_info.features |= CURL_VERSION_IDN;
341 #elif defined(USE_WIN32_IDN)
342 version_info.features |= CURL_VERSION_IDN;
345 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
346 #ifdef _LIBICONV_VERSION
347 version_info.iconv_ver_num = _LIBICONV_VERSION;
349 /* version unknown */
350 version_info.iconv_ver_num = -1;
351 #endif /* _LIBICONV_VERSION */
355 snprintf(ssh_buffer, sizeof(ssh_buffer), "libssh2/%s", LIBSSH2_VERSION);
356 version_info.libssh_version = ssh_buffer;
359 (void)stamp; /* avoid compiler warnings, we don't use this */
361 return &version_info;