1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2012, 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>
29 #define _MPRINTF_REPLACE /* use the internal *printf() functions */
30 #include <curl/mprintf.h>
33 # if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
34 (defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__))
35 # define CARES_STATICLIB
41 #include <stringprep.h>
44 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
49 #include <librtmp/rtmp.h>
56 #ifdef HAVE_LIBSSH2_VERSION
57 /* get it run-time if possible */
58 #define CURL_LIBSSH2_VERSION libssh2_version(0)
60 /* use build-time if run-time not possible */
61 #define CURL_LIBSSH2_VERSION LIBSSH2_VERSION
64 char *curl_version(void)
66 static char version[200];
69 size_t left = sizeof(version);
71 strcpy(ptr, LIBCURL_NAME "/" LIBCURL_VERSION);
77 len = Curl_ssl_version(ptr + 1, left - 1);
87 len = snprintf(ptr, left, " zlib/%s", zlibVersion());
92 /* this function is only present in c-ares, not in the original ares */
93 len = snprintf(ptr, left, " c-ares/%s", ares_version(NULL));
98 if(stringprep_check_version(LIBIDN_REQUIRED_VERSION)) {
99 len = snprintf(ptr, left, " libidn/%s", stringprep_check_version(NULL));
105 len = snprintf(ptr, left, " WinIDN");
109 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
110 #ifdef _LIBICONV_VERSION
111 len = snprintf(ptr, left, " iconv/%d.%d",
112 _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 255);
114 /* version unknown */
115 len = snprintf(ptr, left, " iconv");
116 #endif /* _LIBICONV_VERSION */
121 len = snprintf(ptr, left, " libssh2/%s", CURL_LIBSSH2_VERSION);
128 if(RTMP_LIB_VERSION & 0xff) {
129 suff[0] = (RTMP_LIB_VERSION & 0xff) + 'a' - 1;
135 snprintf(ptr, left, " librtmp/%d.%d%s",
136 RTMP_LIB_VERSION >> 16, (RTMP_LIB_VERSION >> 8) & 0xff,
139 If another lib version is added below this one, this code would
142 len = what snprintf() returned
153 /* data for curl_version_info
155 Keep the list sorted alphabetically. It is also written so that each
156 protocol line has its own #if line to make things easier on the eye.
159 static const char * const protocols[] = {
160 #ifndef CURL_DISABLE_DICT
163 #ifndef CURL_DISABLE_FILE
166 #ifndef CURL_DISABLE_FTP
169 #if defined(USE_SSL) && !defined(CURL_DISABLE_FTP)
172 #ifndef CURL_DISABLE_GOPHER
175 #ifndef CURL_DISABLE_HTTP
178 #if defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)
181 #ifndef CURL_DISABLE_IMAP
184 #if defined(USE_SSL) && !defined(CURL_DISABLE_IMAP)
187 #ifndef CURL_DISABLE_LDAP
189 #if !defined(CURL_DISABLE_LDAPS) && \
190 ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \
191 (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL)))
195 #ifndef CURL_DISABLE_POP3
198 #if defined(USE_SSL) && !defined(CURL_DISABLE_POP3)
204 #ifndef CURL_DISABLE_RTSP
213 #ifndef CURL_DISABLE_SMTP
216 #if defined(USE_SSL) && !defined(CURL_DISABLE_SMTP)
219 #ifndef CURL_DISABLE_TELNET
222 #ifndef CURL_DISABLE_TFTP
229 static curl_version_info_data version_info = {
233 OS, /* as found by configure or set by hand at build-time */
234 0 /* features is 0 by default */
239 | CURL_VERSION_KERBEROS4
247 #if defined(USE_NTLM) && defined(NTLM_WB_ENABLED)
248 | CURL_VERSION_NTLM_WB
250 #ifdef USE_WINDOWS_SSPI
256 #ifdef USE_HTTP_NEGOTIATE
257 | CURL_VERSION_GSSNEGOTIATE
263 | CURL_VERSION_CURLDEBUG
265 #ifdef CURLRES_ASYNCH
266 | CURL_VERSION_ASYNCHDNS
269 | CURL_VERSION_SPNEGO
271 #if (CURL_SIZEOF_CURL_OFF_T > 4) && \
272 ( (SIZEOF_OFF_T > 4) || defined(USE_WIN32_LARGE_FILES) )
273 | CURL_VERSION_LARGEFILE
275 #if defined(CURL_DOES_CONVERSIONS)
278 #if defined(USE_TLS_SRP)
279 | CURL_VERSION_TLSAUTH_SRP
282 NULL, /* ssl_version */
283 0, /* ssl_version_num, this is kept at zero */
284 NULL, /* zlib_version */
286 NULL, /* c-ares version */
287 0, /* c-ares version numerical */
288 NULL, /* libidn version */
289 0, /* iconv version */
290 NULL, /* ssh lib version */
293 curl_version_info_data *curl_version_info(CURLversion stamp)
296 static char ssh_buffer[80];
300 static char ssl_buffer[80];
301 Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer));
302 version_info.ssl_version = ssl_buffer;
306 version_info.libz_version = zlibVersion();
307 /* libz left NULL if non-existing */
312 version_info.ares = ares_version(&aresnum);
313 version_info.ares_num = aresnum;
317 /* This returns a version string if we use the given version or later,
318 otherwise it returns NULL */
319 version_info.libidn = stringprep_check_version(LIBIDN_REQUIRED_VERSION);
320 if(version_info.libidn)
321 version_info.features |= CURL_VERSION_IDN;
322 #elif defined(USE_WIN32_IDN)
323 version_info.features |= CURL_VERSION_IDN;
326 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
327 #ifdef _LIBICONV_VERSION
328 version_info.iconv_ver_num = _LIBICONV_VERSION;
330 /* version unknown */
331 version_info.iconv_ver_num = -1;
332 #endif /* _LIBICONV_VERSION */
336 snprintf(ssh_buffer, sizeof(ssh_buffer), "libssh2/%s", LIBSSH2_VERSION);
337 version_info.libssh_version = ssh_buffer;
340 (void)stamp; /* avoid compiler warnings, we don't use this */
342 return &version_info;