1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2010, 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 ***************************************************************************/
28 #include <curl/curl.h>
32 #define _MPRINTF_REPLACE /* use the internal *printf() functions */
33 #include <curl/mprintf.h>
36 #include <ares_version.h>
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);
69 strcpy(ptr, LIBCURL_NAME "/" LIBCURL_VERSION );
75 len = Curl_ssl_version(ptr + 1, left - 1);
85 len = snprintf(ptr, left, " zlib/%s", zlibVersion());
90 /* this function is only present in c-ares, not in the original ares */
91 len = snprintf(ptr, left, " c-ares/%s", ares_version(NULL));
96 if(stringprep_check_version(LIBIDN_REQUIRED_VERSION)) {
97 len = snprintf(ptr, left, " libidn/%s", stringprep_check_version(NULL));
102 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
103 #ifdef _LIBICONV_VERSION
104 len = snprintf(ptr, left, " iconv/%d.%d",
105 _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 255);
107 /* version unknown */
108 len = snprintf(ptr, left, " iconv");
109 #endif /* _LIBICONV_VERSION */
114 len = snprintf(ptr, left, " libssh2/%s", CURL_LIBSSH2_VERSION);
121 if (RTMP_LIB_VERSION & 0xff) {
122 suff[0] = (RTMP_LIB_VERSION & 0xff) + 'a' - 1;
127 len = snprintf(ptr, left, " librtmp/%d.%d%s",
128 RTMP_LIB_VERSION >> 16, (RTMP_LIB_VERSION >> 8) & 0xff, suff);
130 If another lib version is added below this one, this code would
142 /* data for curl_version_info
144 Keep the list sorted alphabetically. It is also written so that each
145 protocol line has its own #if line to make things easier on the eye.
148 static const char * const protocols[] = {
149 #ifndef CURL_DISABLE_DICT
152 #ifndef CURL_DISABLE_FILE
155 #ifndef CURL_DISABLE_FTP
158 #if defined(USE_SSL) && !defined(CURL_DISABLE_FTP)
161 #ifndef CURL_DISABLE_GOPHER
164 #ifndef CURL_DISABLE_HTTP
167 #if defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)
170 #ifndef CURL_DISABLE_IMAP
173 #if defined(USE_SSL) && !defined(CURL_DISABLE_IMAP)
176 #ifndef CURL_DISABLE_LDAP
178 #if (defined(USE_OPENLDAP) && defined(USE_SSL)) || \
179 (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL))
183 #ifndef CURL_DISABLE_POP3
186 #if defined(USE_SSL) && !defined(CURL_DISABLE_POP3)
192 #ifndef CURL_DISABLE_RTSP
201 #ifndef CURL_DISABLE_SMTP
204 #if defined(USE_SSL) && !defined(CURL_DISABLE_SMTP)
207 #ifndef CURL_DISABLE_TELNET
210 #ifndef CURL_DISABLE_TFTP
217 static curl_version_info_data version_info = {
221 OS, /* as found by configure or set by hand at build-time */
222 0 /* features is 0 by default */
227 | CURL_VERSION_KERBEROS4
235 #ifdef USE_WINDOWS_SSPI
242 | CURL_VERSION_GSSNEGOTIATE
248 | CURL_VERSION_CURLDEBUG
250 #ifdef CURLRES_ASYNCH
251 | CURL_VERSION_ASYNCHDNS
254 | CURL_VERSION_SPNEGO
256 #if (CURL_SIZEOF_CURL_OFF_T > 4) && \
257 ( (SIZEOF_OFF_T > 4) || defined(USE_WIN32_LARGE_FILES) )
258 | CURL_VERSION_LARGEFILE
260 #if defined(CURL_DOES_CONVERSIONS)
264 NULL, /* ssl_version */
265 0, /* ssl_version_num, this is kept at zero */
266 NULL, /* zlib_version */
268 NULL, /* c-ares version */
269 0, /* c-ares version numerical */
270 NULL, /* libidn version */
271 0, /* iconv version */
272 NULL, /* ssh lib version */
275 curl_version_info_data *curl_version_info(CURLversion stamp)
278 static char ssh_buffer[80];
282 static char ssl_buffer[80];
283 Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer));
284 version_info.ssl_version = ssl_buffer;
288 version_info.libz_version = zlibVersion();
289 /* libz left NULL if non-existing */
294 version_info.ares = ares_version(&aresnum);
295 version_info.ares_num = aresnum;
299 /* This returns a version string if we use the given version or later,
300 otherwise it returns NULL */
301 version_info.libidn = stringprep_check_version(LIBIDN_REQUIRED_VERSION);
302 if(version_info.libidn)
303 version_info.features |= CURL_VERSION_IDN;
306 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
307 #ifdef _LIBICONV_VERSION
308 version_info.iconv_ver_num = _LIBICONV_VERSION;
310 /* version unknown */
311 version_info.iconv_ver_num = -1;
312 #endif /* _LIBICONV_VERSION */
316 snprintf(ssh_buffer, sizeof(ssh_buffer), "libssh2/%s", LIBSSH2_VERSION);
317 version_info.libssh_version = ssh_buffer;
320 (void)stamp; /* avoid compiler warnings, we don't use this */
322 return &version_info;