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.
21 * $Id: version.c,v 1.35 2004/03/08 07:46:26 bagder Exp $
22 ***************************************************************************/
29 #include <curl/curl.h>
33 #include <ares_version.h>
37 static void getssl_version(char *ptr, long *num)
40 #if (SSLEAY_VERSION_NUMBER >= 0x905000)
43 unsigned long ssleay_value;
45 ssleay_value=SSLeay();
47 if(ssleay_value < 0x906000) {
48 ssleay_value=SSLEAY_VERSION_NUMBER;
52 if(ssleay_value&0xff0) {
53 sub[0]=(char)((ssleay_value>>4)&0xff) + 'a' -1;
59 sprintf(ptr, " OpenSSL/%lx.%lx.%lx%s",
60 (ssleay_value>>28)&0xf,
61 (ssleay_value>>20)&0xff,
62 (ssleay_value>>12)&0xff,
67 *num = SSLEAY_VERSION_NUMBER;
68 #if (SSLEAY_VERSION_NUMBER >= 0x900000)
69 sprintf(ptr, " OpenSSL/%lx.%lx.%lx",
70 (SSLEAY_VERSION_NUMBER>>28)&0xff,
71 (SSLEAY_VERSION_NUMBER>>20)&0xff,
72 (SSLEAY_VERSION_NUMBER>>12)&0xf);
77 if(SSLEAY_VERSION_NUMBER&0x0f) {
78 sub[0]=(SSLEAY_VERSION_NUMBER&0x0f) + 'a' -1;
83 sprintf(ptr, " SSL/%x.%x.%x%s",
84 (SSLEAY_VERSION_NUMBER>>12)&0xff,
85 (SSLEAY_VERSION_NUMBER>>8)&0xf,
86 (SSLEAY_VERSION_NUMBER>>4)&0xf, sub);
94 char *curl_version(void)
96 static char version[200];
98 strcpy(version, LIBCURL_NAME "/" LIBCURL_VERSION );
99 ptr=strchr(version, '\0');
104 getssl_version(ptr, &num);
105 ptr=strchr(version, '\0');
110 sprintf(ptr, " krb4");
114 sprintf(ptr, " ipv6");
118 sprintf(ptr, " zlib/%s", zlibVersion());
122 sprintf(ptr, " GSS");
126 /* this function is only present in c-ares, not in the original ares */
127 sprintf(ptr, " c-ares/%s", ares_version(NULL));
134 /* data for curl_version_info */
136 static const char *protocols[] = {
137 #ifndef CURL_DISABLE_FTP
140 #ifndef CURL_DISABLE_GOPHER
143 #ifndef CURL_DISABLE_TELNET
146 #ifndef CURL_DISABLE_DICT
149 #ifndef CURL_DISABLE_LDAP
152 #ifndef CURL_DISABLE_HTTP
155 #ifndef CURL_DISABLE_FILE
160 #ifndef CURL_DISABLE_HTTP
163 #ifndef CURL_DISABLE_FTP
170 static curl_version_info_data version_info = {
174 OS, /* as found by configure or set by hand at build-time */
175 0 /* features is 0 by default */
180 | CURL_VERSION_KERBEROS4
184 | CURL_VERSION_NTLM /* since this requires OpenSSL */
190 | CURL_VERSION_GSSNEGOTIATE
196 | CURL_VERSION_ASYNCHDNS
199 | CURL_VERSION_SPNEGO
201 #if defined(ENABLE_64BIT) && (SIZEOF_CURL_OFF_T > 4)
202 | CURL_VERSION_LARGEFILE
205 NULL, /* ssl_version */
206 0, /* ssl_version_num */
207 NULL, /* zlib_version */
209 NULL, /* c-ares version */
210 0, /* c-ares version numerical */
213 curl_version_info_data *curl_version_info(CURLversion stamp)
216 static char ssl_buffer[80];
218 getssl_version(ssl_buffer, &num);
220 version_info.ssl_version = ssl_buffer;
221 version_info.ssl_version_num = num;
222 /* SSL stuff is left zero if undefined */
226 version_info.libz_version = zlibVersion();
227 /* libz left NULL if non-existing */
232 version_info.ares = ares_version(&aresnum);
233 version_info.ares_num = aresnum;
236 (void)stamp; /* avoid compiler warnings, we don't use this */
238 return &version_info;