1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2011, 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 ***************************************************************************/
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);
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, " IDN-Windows-native");
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);
127 if(RTMP_LIB_VERSION & 0xff) {
128 suff[0] = (RTMP_LIB_VERSION & 0xff) + 'a' - 1;
134 len = snprintf(ptr, left, " librtmp/%d.%d%s",
135 RTMP_LIB_VERSION >> 16, (RTMP_LIB_VERSION >> 8) & 0xff, suff);
137 If another lib version is added below this one, this code would
149 /* data for curl_version_info
151 Keep the list sorted alphabetically. It is also written so that each
152 protocol line has its own #if line to make things easier on the eye.
155 static const char * const protocols[] = {
156 #ifndef CURL_DISABLE_DICT
159 #ifndef CURL_DISABLE_FILE
162 #ifndef CURL_DISABLE_FTP
165 #if defined(USE_SSL) && !defined(CURL_DISABLE_FTP)
168 #ifndef CURL_DISABLE_GOPHER
171 #ifndef CURL_DISABLE_HTTP
174 #if defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)
177 #ifndef CURL_DISABLE_IMAP
180 #if defined(USE_SSL) && !defined(CURL_DISABLE_IMAP)
183 #ifndef CURL_DISABLE_LDAP
185 #if !defined(CURL_DISABLE_LDAPS) && \
186 ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \
187 (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL)))
191 #ifndef CURL_DISABLE_POP3
194 #if defined(USE_SSL) && !defined(CURL_DISABLE_POP3)
200 #ifndef CURL_DISABLE_RTSP
209 #ifndef CURL_DISABLE_SMTP
212 #if defined(USE_SSL) && !defined(CURL_DISABLE_SMTP)
215 #ifndef CURL_DISABLE_TELNET
218 #ifndef CURL_DISABLE_TFTP
225 static curl_version_info_data version_info = {
229 OS, /* as found by configure or set by hand at build-time */
230 0 /* features is 0 by default */
235 | CURL_VERSION_KERBEROS4
243 #if defined(USE_NTLM) && defined(NTLM_WB_ENABLED)
244 | CURL_VERSION_NTLM_WB
246 #ifdef USE_WINDOWS_SSPI
252 #ifdef USE_HTTP_NEGOTIATE
253 | CURL_VERSION_GSSNEGOTIATE
259 | CURL_VERSION_CURLDEBUG
261 #ifdef CURLRES_ASYNCH
262 | CURL_VERSION_ASYNCHDNS
265 | CURL_VERSION_SPNEGO
267 #if (CURL_SIZEOF_CURL_OFF_T > 4) && \
268 ( (SIZEOF_OFF_T > 4) || defined(USE_WIN32_LARGE_FILES) )
269 | CURL_VERSION_LARGEFILE
271 #if defined(CURL_DOES_CONVERSIONS)
274 #if defined(USE_TLS_SRP)
275 | CURL_VERSION_TLSAUTH_SRP
278 NULL, /* ssl_version */
279 0, /* ssl_version_num, this is kept at zero */
280 NULL, /* zlib_version */
282 NULL, /* c-ares version */
283 0, /* c-ares version numerical */
284 NULL, /* libidn version */
285 0, /* iconv version */
286 NULL, /* ssh lib version */
289 curl_version_info_data *curl_version_info(CURLversion stamp)
292 static char ssh_buffer[80];
296 static char ssl_buffer[80];
297 Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer));
298 version_info.ssl_version = ssl_buffer;
302 version_info.libz_version = zlibVersion();
303 /* libz left NULL if non-existing */
308 version_info.ares = ares_version(&aresnum);
309 version_info.ares_num = aresnum;
313 /* This returns a version string if we use the given version or later,
314 otherwise it returns NULL */
315 version_info.libidn = stringprep_check_version(LIBIDN_REQUIRED_VERSION);
316 if(version_info.libidn)
317 version_info.features |= CURL_VERSION_IDN;
318 #elif defined(USE_WIN32_IDN)
319 version_info.features |= CURL_VERSION_IDN;
322 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
323 #ifdef _LIBICONV_VERSION
324 version_info.iconv_ver_num = _LIBICONV_VERSION;
326 /* version unknown */
327 version_info.iconv_ver_num = -1;
328 #endif /* _LIBICONV_VERSION */
332 snprintf(ssh_buffer, sizeof(ssh_buffer), "libssh2/%s", LIBSSH2_VERSION);
333 version_info.libssh_version = ssh_buffer;
336 (void)stamp; /* avoid compiler warnings, we don't use this */
338 return &version_info;