1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2014, 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"
30 #define _MPRINTF_REPLACE /* use the internal *printf() functions */
31 #include <curl/mprintf.h>
34 # if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
35 (defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__))
36 # define CARES_STATICLIB
42 #include <stringprep.h>
45 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
50 #include <librtmp/rtmp.h>
57 #ifdef HAVE_LIBSSH2_VERSION
58 /* get it run-time if possible */
59 #define CURL_LIBSSH2_VERSION libssh2_version(0)
61 /* use build-time if run-time not possible */
62 #define CURL_LIBSSH2_VERSION LIBSSH2_VERSION
65 char *curl_version(void)
67 static char version[200];
70 size_t left = sizeof(version);
72 strcpy(ptr, LIBCURL_NAME "/" LIBCURL_VERSION);
78 len = Curl_ssl_version(ptr + 1, left - 1);
88 len = snprintf(ptr, left, " zlib/%s", zlibVersion());
93 /* this function is only present in c-ares, not in the original ares */
94 len = snprintf(ptr, left, " c-ares/%s", ares_version(NULL));
99 if(stringprep_check_version(LIBIDN_REQUIRED_VERSION)) {
100 len = snprintf(ptr, left, " libidn/%s", stringprep_check_version(NULL));
106 len = snprintf(ptr, left, " WinIDN");
110 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
111 #ifdef _LIBICONV_VERSION
112 len = snprintf(ptr, left, " iconv/%d.%d",
113 _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 255);
115 /* version unknown */
116 len = snprintf(ptr, left, " iconv");
117 #endif /* _LIBICONV_VERSION */
122 len = snprintf(ptr, left, " libssh2/%s", CURL_LIBSSH2_VERSION);
127 len = Curl_http2_ver(ptr, left);
134 if(RTMP_LIB_VERSION & 0xff) {
135 suff[0] = (RTMP_LIB_VERSION & 0xff) + 'a' - 1;
141 snprintf(ptr, left, " librtmp/%d.%d%s",
142 RTMP_LIB_VERSION >> 16, (RTMP_LIB_VERSION >> 8) & 0xff,
145 If another lib version is added below this one, this code would
148 len = what snprintf() returned
159 /* data for curl_version_info
161 Keep the list sorted alphabetically. It is also written so that each
162 protocol line has its own #if line to make things easier on the eye.
165 static const char * const protocols[] = {
166 #ifndef CURL_DISABLE_DICT
169 #ifndef CURL_DISABLE_FILE
172 #ifndef CURL_DISABLE_FTP
175 #if defined(USE_SSL) && !defined(CURL_DISABLE_FTP)
178 #ifndef CURL_DISABLE_GOPHER
181 #ifndef CURL_DISABLE_HTTP
184 #if defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)
187 #ifndef CURL_DISABLE_IMAP
190 #if defined(USE_SSL) && !defined(CURL_DISABLE_IMAP)
193 #ifndef CURL_DISABLE_LDAP
195 #if !defined(CURL_DISABLE_LDAPS) && \
196 ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \
197 (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL)))
201 #ifndef CURL_DISABLE_POP3
204 #if defined(USE_SSL) && !defined(CURL_DISABLE_POP3)
210 #ifndef CURL_DISABLE_RTSP
219 #if !defined(CURL_DISABLE_SMB) && defined(USE_NTLM) && \
220 (CURL_SIZEOF_CURL_OFF_T > 4) && \
221 (!defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO))
227 #ifndef CURL_DISABLE_SMTP
230 #if defined(USE_SSL) && !defined(CURL_DISABLE_SMTP)
233 #ifndef CURL_DISABLE_TELNET
236 #ifndef CURL_DISABLE_TFTP
243 static curl_version_info_data version_info = {
247 OS, /* as found by configure or set by hand at build-time */
248 0 /* features is 0 by default */
258 #if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \
259 defined(NTLM_WB_ENABLED)
260 | CURL_VERSION_NTLM_WB
263 | CURL_VERSION_SPNEGO
266 | CURL_VERSION_KERBEROS5
269 | CURL_VERSION_GSSAPI
271 #ifdef USE_WINDOWS_SSPI
281 | CURL_VERSION_CURLDEBUG
283 #ifdef CURLRES_ASYNCH
284 | CURL_VERSION_ASYNCHDNS
286 #if (CURL_SIZEOF_CURL_OFF_T > 4) && \
287 ( (SIZEOF_OFF_T > 4) || defined(USE_WIN32_LARGE_FILES) )
288 | CURL_VERSION_LARGEFILE
290 #if defined(CURL_DOES_CONVERSIONS)
293 #if defined(USE_TLS_SRP)
294 | CURL_VERSION_TLSAUTH_SRP
296 #if defined(USE_NGHTTP2)
299 #if defined(USE_UNIX_SOCKETS)
300 | CURL_VERSION_UNIX_SOCKETS
303 NULL, /* ssl_version */
304 0, /* ssl_version_num, this is kept at zero */
305 NULL, /* zlib_version */
307 NULL, /* c-ares version */
308 0, /* c-ares version numerical */
309 NULL, /* libidn version */
310 0, /* iconv version */
311 NULL, /* ssh lib version */
314 curl_version_info_data *curl_version_info(CURLversion stamp)
317 static char ssh_buffer[80];
321 static char ssl_buffer[80];
322 Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer));
323 version_info.ssl_version = ssl_buffer;
327 version_info.libz_version = zlibVersion();
328 /* libz left NULL if non-existing */
333 version_info.ares = ares_version(&aresnum);
334 version_info.ares_num = aresnum;
338 /* This returns a version string if we use the given version or later,
339 otherwise it returns NULL */
340 version_info.libidn = stringprep_check_version(LIBIDN_REQUIRED_VERSION);
341 if(version_info.libidn)
342 version_info.features |= CURL_VERSION_IDN;
343 #elif defined(USE_WIN32_IDN)
344 version_info.features |= CURL_VERSION_IDN;
347 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
348 #ifdef _LIBICONV_VERSION
349 version_info.iconv_ver_num = _LIBICONV_VERSION;
351 /* version unknown */
352 version_info.iconv_ver_num = -1;
353 #endif /* _LIBICONV_VERSION */
357 snprintf(ssh_buffer, sizeof(ssh_buffer), "libssh2/%s", LIBSSH2_VERSION);
358 version_info.libssh_version = ssh_buffer;
361 (void)stamp; /* avoid compiler warnings, we don't use this */
363 return &version_info;