1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2007, 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 * $Id: version.c,v 1.1.1.1 2008-09-23 16:32:05 hoffman Exp $
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)
53 char *curl_version(void)
55 static char version
[200];
58 size_t left
= sizeof(version
);
59 strcpy(ptr
, LIBCURL_NAME
"/" LIBCURL_VERSION
);
65 len
= Curl_ssl_version(ptr
+ 1, left
- 1);
75 len
= snprintf(ptr
, left
, " zlib/%s", zlibVersion());
80 /* this function is only present in c-ares, not in the original ares */
81 len
= snprintf(ptr
, left
, " c-ares/%s", ares_version(NULL
));
86 if(stringprep_check_version(LIBIDN_REQUIRED_VERSION
)) {
87 len
= snprintf(ptr
, left
, " libidn/%s", stringprep_check_version(NULL
));
92 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
93 #ifdef _LIBICONV_VERSION
94 len
= snprintf(ptr
, left
, " iconv/%d.%d",
95 _LIBICONV_VERSION
>> 8, _LIBICONV_VERSION
& 255);
98 len
= snprintf(ptr
, left
, " iconv");
99 #endif /* _LIBICONV_VERSION */
104 len
= snprintf(ptr
, left
, " libssh2/%s", LIBSSH2_VERSION
);
112 /* data for curl_version_info */
114 static const char * const protocols
[] = {
115 #ifndef CURL_DISABLE_TFTP
118 #ifndef CURL_DISABLE_FTP
121 #ifndef CURL_DISABLE_TELNET
124 #ifndef CURL_DISABLE_DICT
127 #ifndef CURL_DISABLE_LDAP
133 #ifndef CURL_DISABLE_HTTP
136 #ifndef CURL_DISABLE_FILE
141 #ifndef CURL_DISABLE_HTTP
144 #ifndef CURL_DISABLE_FTP
157 static curl_version_info_data version_info
= {
161 OS
, /* as found by configure or set by hand at build-time */
162 0 /* features is 0 by default */
167 | CURL_VERSION_KERBEROS4
175 #ifdef USE_WINDOWS_SSPI
182 | CURL_VERSION_GSSNEGOTIATE
188 | CURL_VERSION_ASYNCHDNS
191 | CURL_VERSION_SPNEGO
193 #if (CURL_SIZEOF_CURL_OFF_T > 4) && \
194 ( (SIZEOF_OFF_T > 4) || defined(USE_WIN32_LARGE_FILES) )
195 | CURL_VERSION_LARGEFILE
197 #if defined(CURL_DOES_CONVERSIONS)
201 NULL
, /* ssl_version */
202 0, /* ssl_version_num, this is kept at zero */
203 NULL
, /* zlib_version */
205 NULL
, /* c-ares version */
206 0, /* c-ares version numerical */
207 NULL
, /* libidn version */
208 0, /* iconv version */
209 NULL
, /* ssh lib version */
212 curl_version_info_data
*curl_version_info(CURLversion stamp
)
215 static char ssh_buffer
[80];
219 static char ssl_buffer
[80];
220 Curl_ssl_version(ssl_buffer
, sizeof(ssl_buffer
));
221 version_info
.ssl_version
= ssl_buffer
;
225 version_info
.libz_version
= zlibVersion();
226 /* libz left NULL if non-existing */
231 version_info
.ares
= ares_version(&aresnum
);
232 version_info
.ares_num
= aresnum
;
236 /* This returns a version string if we use the given version or later,
237 otherwise it returns NULL */
238 version_info
.libidn
= stringprep_check_version(LIBIDN_REQUIRED_VERSION
);
239 if(version_info
.libidn
)
240 version_info
.features
|= CURL_VERSION_IDN
;
243 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
244 #ifdef _LIBICONV_VERSION
245 version_info
.iconv_ver_num
= _LIBICONV_VERSION
;
247 /* version unknown */
248 version_info
.iconv_ver_num
= -1;
249 #endif /* _LIBICONV_VERSION */
253 snprintf(ssh_buffer
, sizeof(ssh_buffer
), "libssh2/%s", LIBSSH2_VERSION
);
254 version_info
.libssh_version
= ssh_buffer
;
257 (void)stamp
; /* avoid compiler warnings, we don't use this */
259 return &version_info
;