1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2004, 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>
32 #define _MPRINTF_REPLACE /* use the internal *printf() functions */
33 #include <curl/mprintf.h>
36 #include <ares_version.h>
40 #include <stringprep.h>
44 static int getssl_version(char *ptr, size_t left, long *num)
47 #if (SSLEAY_VERSION_NUMBER >= 0x905000)
50 unsigned long ssleay_value;
52 ssleay_value=SSLeay();
53 *num = (long)ssleay_value;
54 if(ssleay_value < 0x906000) {
55 ssleay_value=SSLEAY_VERSION_NUMBER;
59 if(ssleay_value&0xff0) {
60 sub[0]=(char)((ssleay_value>>4)&0xff) + 'a' -1;
66 return snprintf(ptr, left, " OpenSSL/%lx.%lx.%lx%s",
67 (ssleay_value>>28)&0xf,
68 (ssleay_value>>20)&0xff,
69 (ssleay_value>>12)&0xff,
74 *num = SSLEAY_VERSION_NUMBER;
75 #if (SSLEAY_VERSION_NUMBER >= 0x900000)
76 return snprintf(ptr, left, " OpenSSL/%lx.%lx.%lx",
77 (SSLEAY_VERSION_NUMBER>>28)&0xff,
78 (SSLEAY_VERSION_NUMBER>>20)&0xff,
79 (SSLEAY_VERSION_NUMBER>>12)&0xf);
84 if(SSLEAY_VERSION_NUMBER&0x0f) {
85 sub[0]=(SSLEAY_VERSION_NUMBER&0x0f) + 'a' -1;
90 return snprintf(ptr, left, " SSL/%x.%x.%x%s",
91 (SSLEAY_VERSION_NUMBER>>12)&0xff,
92 (SSLEAY_VERSION_NUMBER>>8)&0xf,
93 (SSLEAY_VERSION_NUMBER>>4)&0xf, sub);
101 char *curl_version(void)
103 static char version[200];
106 size_t left = sizeof(version);
107 strcpy(ptr, LIBCURL_NAME "/" LIBCURL_VERSION );
108 ptr=strchr(ptr, '\0');
114 len = getssl_version(ptr, left, &num);
121 len = snprintf(ptr, left, " zlib/%s", zlibVersion());
126 /* this function is only present in c-ares, not in the original ares */
127 len = snprintf(ptr, left, " c-ares/%s", ares_version(NULL));
132 if(stringprep_check_version(LIBIDN_REQUIRED_VERSION)) {
133 len = snprintf(ptr, left, " libidn/%s", stringprep_check_version(NULL));
142 /* data for curl_version_info */
144 static const char *protocols[] = {
145 #ifndef CURL_DISABLE_FTP
148 #ifndef CURL_DISABLE_GOPHER
151 #ifndef CURL_DISABLE_TELNET
154 #ifndef CURL_DISABLE_DICT
157 #ifndef CURL_DISABLE_LDAP
160 #ifndef CURL_DISABLE_HTTP
163 #ifndef CURL_DISABLE_FILE
168 #ifndef CURL_DISABLE_HTTP
171 #ifndef CURL_DISABLE_FTP
178 static curl_version_info_data version_info = {
182 OS, /* as found by configure or set by hand at build-time */
183 0 /* features is 0 by default */
188 | CURL_VERSION_KERBEROS4
192 | CURL_VERSION_NTLM /* since this requires OpenSSL */
198 | CURL_VERSION_GSSNEGOTIATE
204 | CURL_VERSION_ASYNCHDNS
207 | CURL_VERSION_SPNEGO
209 #if defined(ENABLE_64BIT) && (SIZEOF_CURL_OFF_T > 4)
210 | CURL_VERSION_LARGEFILE
213 NULL, /* ssl_version */
214 0, /* ssl_version_num */
215 NULL, /* zlib_version */
217 NULL, /* c-ares version */
218 0, /* c-ares version numerical */
219 NULL, /* libidn version */
222 curl_version_info_data *curl_version_info(CURLversion stamp)
225 static char ssl_buffer[80];
227 getssl_version(ssl_buffer, sizeof(ssl_buffer), &num);
229 version_info.ssl_version = ssl_buffer;
230 version_info.ssl_version_num = num;
231 /* SSL stuff is left zero if undefined */
235 version_info.libz_version = zlibVersion();
236 /* libz left NULL if non-existing */
241 version_info.ares = ares_version(&aresnum);
242 version_info.ares_num = aresnum;
246 /* This returns a version string if we use the given version or later,
247 otherwise it returns NULL */
248 version_info.libidn = stringprep_check_version(LIBIDN_REQUIRED_VERSION);
249 if(version_info.libidn)
250 version_info.features |= CURL_VERSION_IDN;
252 (void)stamp; /* avoid compiler warnings, we don't use this */
254 return &version_info;