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.7 2004/10/13 14:45:30 andy Exp $
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];
105
/* to prevent compier warnings, we only declare len if we have code
107
#if defined(USE_SSLEAY) || defined(HAVE_LIBZ) || defined(USE_ARES) || \
111
size_t left = sizeof(version);
112
strcpy(ptr, LIBCURL_NAME "/" LIBCURL_VERSION );
113
ptr=strchr(ptr, '\0');
120
len = getssl_version(ptr, left, &num);
127
len = snprintf(ptr, left, " zlib/%s", zlibVersion());
132
/* this function is only present in c-ares, not in the original ares */
133
len = snprintf(ptr, left, " c-ares/%s", ares_version(NULL));
138
if(stringprep_check_version(LIBIDN_REQUIRED_VERSION)) {
139
len = snprintf(ptr, left, " libidn/%s", stringprep_check_version(NULL));
148
/* data for curl_version_info */
150
static const char *protocols[] = {
151
#ifndef CURL_DISABLE_FTP
154
#ifndef CURL_DISABLE_GOPHER
157
#ifndef CURL_DISABLE_TELNET
160
#ifndef CURL_DISABLE_DICT
163
#ifndef CURL_DISABLE_LDAP
166
#ifndef CURL_DISABLE_HTTP
169
#ifndef CURL_DISABLE_FILE
174
#ifndef CURL_DISABLE_HTTP
177
#ifndef CURL_DISABLE_FTP
184
static curl_version_info_data version_info = {
188
OS, /* as found by configure or set by hand at build-time */
189
0 /* features is 0 by default */
194
| CURL_VERSION_KERBEROS4
198
| CURL_VERSION_NTLM /* since this requires OpenSSL */
204
| CURL_VERSION_GSSNEGOTIATE
210
| CURL_VERSION_ASYNCHDNS
213
| CURL_VERSION_SPNEGO
215
#if defined(ENABLE_64BIT) && (SIZEOF_CURL_OFF_T > 4)
216
| CURL_VERSION_LARGEFILE
219
NULL, /* ssl_version */
220
0, /* ssl_version_num */
221
NULL, /* zlib_version */
223
NULL, /* c-ares version */
224
0, /* c-ares version numerical */
225
NULL, /* libidn version */
228
curl_version_info_data *curl_version_info(CURLversion stamp)
231
static char ssl_buffer[80];
233
getssl_version(ssl_buffer, sizeof(ssl_buffer), &num);
235
version_info.ssl_version = ssl_buffer;
236
version_info.ssl_version_num = num;
237
/* SSL stuff is left zero if undefined */
241
version_info.libz_version = zlibVersion();
242
/* libz left NULL if non-existing */
247
version_info.ares = ares_version(&aresnum);
248
version_info.ares_num = aresnum;
252
/* This returns a version string if we use the given version or later,
253
otherwise it returns NULL */
254
version_info.libidn = stringprep_check_version(LIBIDN_REQUIRED_VERSION);
255
if(version_info.libidn)
256
version_info.features |= CURL_VERSION_IDN;
258
(void)stamp; /* avoid compiler warnings, we don't use this */
260
return &version_info;