1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2006, 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.
22 ***************************************************************************/
29 #include <curl/curl.h>
33 #define _MPRINTF_REPLACE /* use the internal *printf() functions */
34 #include <curl/mprintf.h>
37 #include <ares_version.h>
41 #include <stringprep.h>
44 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
48 char *curl_version(void)
50 static char version[200];
53 size_t left = sizeof(version);
54 strcpy(ptr, LIBCURL_NAME "/" LIBCURL_VERSION );
55 ptr=strchr(ptr, '\0');
58 len = Curl_ssl_version(ptr, left);
63 len = snprintf(ptr, left, " zlib/%s", zlibVersion());
68 /* this function is only present in c-ares, not in the original ares */
69 len = snprintf(ptr, left, " c-ares/%s", ares_version(NULL));
74 if(stringprep_check_version(LIBIDN_REQUIRED_VERSION)) {
75 len = snprintf(ptr, left, " libidn/%s", stringprep_check_version(NULL));
80 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
81 len = snprintf(ptr, left, " iconv/%d.%d",
82 _libiconv_version >> 8, _libiconv_version & 255);
90 /* data for curl_version_info */
92 static const char * const protocols[] = {
93 #ifndef CURL_DISABLE_TFTP
96 #ifndef CURL_DISABLE_FTP
99 #ifndef CURL_DISABLE_TELNET
102 #ifndef CURL_DISABLE_DICT
105 #ifndef CURL_DISABLE_LDAP
108 #ifndef CURL_DISABLE_HTTP
111 #ifndef CURL_DISABLE_FILE
116 #ifndef CURL_DISABLE_HTTP
119 #ifndef CURL_DISABLE_FTP
126 static curl_version_info_data version_info = {
130 OS, /* as found by configure or set by hand at build-time */
131 0 /* features is 0 by default */
136 | CURL_VERSION_KERBEROS4
144 #ifdef USE_WINDOWS_SSPI
151 | CURL_VERSION_GSSNEGOTIATE
157 | CURL_VERSION_ASYNCHDNS
160 | CURL_VERSION_SPNEGO
162 #if defined(ENABLE_64BIT) && (SIZEOF_CURL_OFF_T > 4)
163 | CURL_VERSION_LARGEFILE
165 #if defined(CURL_DOES_CONVERSIONS)
169 NULL, /* ssl_version */
170 0, /* ssl_version_num, this is kept at zero */
171 NULL, /* zlib_version */
173 NULL, /* c-ares version */
174 0, /* c-ares version numerical */
175 NULL, /* libidn version */
176 0, /* iconv version */
179 curl_version_info_data *curl_version_info(CURLversion stamp)
182 static char ssl_buffer[80];
183 Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer));
184 version_info.ssl_version = ssl_buffer;
188 version_info.libz_version = zlibVersion();
189 /* libz left NULL if non-existing */
194 version_info.ares = ares_version(&aresnum);
195 version_info.ares_num = aresnum;
199 /* This returns a version string if we use the given version or later,
200 otherwise it returns NULL */
201 version_info.libidn = stringprep_check_version(LIBIDN_REQUIRED_VERSION);
202 if(version_info.libidn)
203 version_info.features |= CURL_VERSION_IDN;
206 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
207 version_info.iconv_ver_num = _libiconv_version;
210 (void)stamp; /* avoid compiler warnings, we don't use this */
212 return &version_info;