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.
21 * $Id: version.c,v 1.2 2007-03-15 19:22:13 andy 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
);
60 ptr
=strchr(ptr
, '\0');
63 len
= Curl_ssl_version(ptr
, left
);
68 len
= snprintf(ptr
, left
, " zlib/%s", zlibVersion());
73 /* this function is only present in c-ares, not in the original ares */
74 len
= snprintf(ptr
, left
, " c-ares/%s", ares_version(NULL
));
79 if(stringprep_check_version(LIBIDN_REQUIRED_VERSION
)) {
80 len
= snprintf(ptr
, left
, " libidn/%s", stringprep_check_version(NULL
));
85 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
86 #ifdef _LIBICONV_VERSION
87 len
= snprintf(ptr
, left
, " iconv/%d.%d",
88 _LIBICONV_VERSION
>> 8, _LIBICONV_VERSION
& 255);
91 len
= snprintf(ptr
, left
, " iconv");
92 #endif /* _LIBICONV_VERSION */
97 len
= snprintf(ptr
, left
, " libssh2/%s", LIBSSH2_VERSION
);
105 /* data for curl_version_info */
107 static const char * const protocols
[] = {
108 #ifndef CURL_DISABLE_TFTP
111 #ifndef CURL_DISABLE_FTP
114 #ifndef CURL_DISABLE_TELNET
117 #ifndef CURL_DISABLE_DICT
120 #ifndef CURL_DISABLE_LDAP
123 #ifndef CURL_DISABLE_HTTP
126 #ifndef CURL_DISABLE_FILE
131 #ifndef CURL_DISABLE_HTTP
134 #ifndef CURL_DISABLE_FTP
147 static curl_version_info_data version_info
= {
151 OS
, /* as found by configure or set by hand at build-time */
152 0 /* features is 0 by default */
157 | CURL_VERSION_KERBEROS4
165 #ifdef USE_WINDOWS_SSPI
172 | CURL_VERSION_GSSNEGOTIATE
178 | CURL_VERSION_ASYNCHDNS
181 | CURL_VERSION_SPNEGO
183 #if defined(ENABLE_64BIT) && (SIZEOF_CURL_OFF_T > 4)
184 | CURL_VERSION_LARGEFILE
186 #if defined(CURL_DOES_CONVERSIONS)
190 NULL
, /* ssl_version */
191 0, /* ssl_version_num, this is kept at zero */
192 NULL
, /* zlib_version */
194 NULL
, /* c-ares version */
195 0, /* c-ares version numerical */
196 NULL
, /* libidn version */
197 0, /* iconv version */
198 NULL
, /* ssh lib version */
201 curl_version_info_data
*curl_version_info(CURLversion stamp
)
204 static char ssh_buffer
[80];
208 static char ssl_buffer
[80];
209 Curl_ssl_version(ssl_buffer
, sizeof(ssl_buffer
));
210 version_info
.ssl_version
= ssl_buffer
;
214 version_info
.libz_version
= zlibVersion();
215 /* libz left NULL if non-existing */
220 version_info
.ares
= ares_version(&aresnum
);
221 version_info
.ares_num
= aresnum
;
225 /* This returns a version string if we use the given version or later,
226 otherwise it returns NULL */
227 version_info
.libidn
= stringprep_check_version(LIBIDN_REQUIRED_VERSION
);
228 if(version_info
.libidn
)
229 version_info
.features
|= CURL_VERSION_IDN
;
232 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
233 #ifdef _LIBICONV_VERSION
234 version_info
.iconv_ver_num
= _LIBICONV_VERSION
;
236 /* version unknown */
237 version_info
.iconv_ver_num
= -1;
238 #endif /* _LIBICONV_VERSION */
242 snprintf(ssh_buffer
, sizeof(ssh_buffer
), "libssh2/%s", LIBSSH2_VERSION
);
243 version_info
.libssh_version
= ssh_buffer
;
246 (void)stamp
; /* avoid compiler warnings, we don't use this */
248 return &version_info
;