~ubuntu-branches/ubuntu/dapper/curl/dapper-security

« back to all changes in this revision

Viewing changes to lib/version.c

  • Committer: Bazaar Package Importer
  • Author(s): Domenico Andreoli
  • Date: 2004-06-04 19:09:25 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040604190925-wy048bp31320r2z6
Tags: 7.12.0.is.7.11.2-1
* Reverted to version 7.11.2 (closes: #252348).
* Disabled support for libidn (closes: #252367). This is to leave
  curl in unstable as much similar as possible to the one in testing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
 
1
/***************************************************************************
2
2
 *                                  _   _ ____  _     
3
3
 *  Project                     ___| | | |  _ \| |    
4
4
 *                             / __| | | | |_) | |    
5
5
 *                            | (__| |_| |  _ <| |___ 
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * Copyright (C) 2002, Daniel Stenberg, <daniel@haxx.se>, et al.
9
 
 *
10
 
 * In order to be useful for every potential user, curl and libcurl are
11
 
 * dual-licensed under the MPL and the MIT/X-derivate licenses.
12
 
 *
 
8
 * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
 
9
 *
 
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.
 
13
 * 
13
14
 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
14
15
 * copies of the Software, and permit persons to whom the Software is
15
 
 * furnished to do so, under the terms of the MPL or the MIT/X-derivate
16
 
 * licenses. You may pick one of these licenses.
 
16
 * furnished to do so, under the terms of the COPYING file.
17
17
 *
18
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
 * KIND, either express or implied.
20
20
 *
21
 
 * $Id: version.c,v 1.15 2002/01/16 17:45:08 bagder Exp $
22
 
 *****************************************************************************/
 
21
 * $Id: version.c,v 1.35 2004/03/08 07:46:26 bagder Exp $
 
22
 ***************************************************************************/
23
23
 
24
24
#include "setup.h"
25
25
 
29
29
#include <curl/curl.h>
30
30
#include "urldata.h"
31
31
 
32
 
char *curl_version(void)
 
32
#ifdef USE_ARES
 
33
#include <ares_version.h>
 
34
#endif
 
35
 
 
36
#ifdef USE_SSLEAY
 
37
static void getssl_version(char *ptr, long *num)
33
38
{
34
 
  static char version[200];
35
 
  char *ptr;
36
 
  strcpy(version, LIBCURL_NAME " " LIBCURL_VERSION );
37
 
  ptr=strchr(version, '\0');
38
 
 
39
 
#ifdef USE_SSLEAY
40
39
 
41
40
#if (SSLEAY_VERSION_NUMBER >= 0x905000)
42
41
  {
44
43
    unsigned long ssleay_value;
45
44
    sub[1]='\0';
46
45
    ssleay_value=SSLeay();
 
46
    *num = ssleay_value;
47
47
    if(ssleay_value < 0x906000) {
48
48
      ssleay_value=SSLEAY_VERSION_NUMBER;
49
49
      sub[0]='\0';
50
50
    }
51
51
    else {
52
52
      if(ssleay_value&0xff0) {
53
 
        sub[0]=((ssleay_value>>4)&0xff) + 'a' -1;
 
53
        sub[0]=(char)((ssleay_value>>4)&0xff) + 'a' -1;
54
54
      }
55
55
      else
56
56
        sub[0]='\0';
57
57
    }
58
58
 
59
 
    sprintf(ptr, " (OpenSSL %lx.%lx.%lx%s)",
 
59
    sprintf(ptr, " OpenSSL/%lx.%lx.%lx%s",
60
60
            (ssleay_value>>28)&0xf,
61
61
            (ssleay_value>>20)&0xff,
62
62
            (ssleay_value>>12)&0xff,
64
64
  }
65
65
 
66
66
#else
 
67
  *num = SSLEAY_VERSION_NUMBER;
67
68
#if (SSLEAY_VERSION_NUMBER >= 0x900000)
68
 
  sprintf(ptr, " (SSL %lx.%lx.%lx)",
 
69
  sprintf(ptr, " OpenSSL/%lx.%lx.%lx",
69
70
          (SSLEAY_VERSION_NUMBER>>28)&0xff,
70
71
          (SSLEAY_VERSION_NUMBER>>20)&0xff,
71
72
          (SSLEAY_VERSION_NUMBER>>12)&0xf);
79
80
    else
80
81
      sub[0]='\0';
81
82
 
82
 
    sprintf(ptr, " (SSL %x.%x.%x%s)",
 
83
    sprintf(ptr, " SSL/%x.%x.%x%s",
83
84
            (SSLEAY_VERSION_NUMBER>>12)&0xff,
84
85
            (SSLEAY_VERSION_NUMBER>>8)&0xf,
85
86
            (SSLEAY_VERSION_NUMBER>>4)&0xf, sub);
86
87
  }
87
88
#endif
88
89
#endif
89
 
  ptr=strchr(ptr, '\0');
90
 
#endif
91
 
 
92
 
#if defined(KRB4) || defined(ENABLE_IPV6)
93
 
  strcat(ptr, " (");
94
 
  ptr+=2;
95
 
#ifdef KRB4
96
 
  sprintf(ptr, "krb4 ");
 
90
}
 
91
 
 
92
#endif
 
93
 
 
94
char *curl_version(void)
 
95
{
 
96
  static char version[200];
 
97
  char *ptr;
 
98
  strcpy(version, LIBCURL_NAME "/" LIBCURL_VERSION );
 
99
  ptr=strchr(version, '\0');
 
100
 
 
101
#ifdef USE_SSLEAY
 
102
  {
 
103
    long num;
 
104
    getssl_version(ptr, &num);
 
105
    ptr=strchr(version, '\0');
 
106
  }
 
107
#endif
 
108
 
 
109
#ifdef HAVE_KRB4
 
110
  sprintf(ptr, " krb4");
97
111
  ptr += strlen(ptr);
98
112
#endif
99
113
#ifdef ENABLE_IPV6
100
 
  sprintf(ptr, "ipv6 ");
101
 
  ptr += strlen(ptr);
102
 
#endif
103
 
  sprintf(ptr, "enabled)");
104
 
  ptr += strlen(ptr);
105
 
#endif
106
 
 
107
 
#ifdef USE_ZLIB
108
 
  sprintf(ptr, " (zlib %s)", zlibVersion());
 
114
  sprintf(ptr, " ipv6");
 
115
  ptr += strlen(ptr);
 
116
#endif
 
117
#ifdef HAVE_LIBZ
 
118
  sprintf(ptr, " zlib/%s", zlibVersion());
 
119
  ptr += strlen(ptr);
 
120
#endif
 
121
#ifdef HAVE_GSSAPI
 
122
  sprintf(ptr, " GSS");
 
123
  ptr += strlen(ptr);
 
124
#endif
 
125
#ifdef USE_ARES
 
126
  /* this function is only present in c-ares, not in the original ares */
 
127
  sprintf(ptr, " c-ares/%s", ares_version(NULL));
109
128
  ptr += strlen(ptr);
110
129
#endif
111
130
 
112
131
  return version;
113
132
}
114
133
 
115
 
/*
116
 
 * local variables:
117
 
 * eval: (load-file "../curl-mode.el")
118
 
 * end:
119
 
 * vim600: fdm=marker
120
 
 * vim: et sw=2 ts=2 sts=2 tw=78
121
 
 */
 
134
/* data for curl_version_info */
 
135
 
 
136
static const char *protocols[] = {
 
137
#ifndef CURL_DISABLE_FTP
 
138
  "ftp",
 
139
#endif
 
140
#ifndef CURL_DISABLE_GOPHER
 
141
  "gopher",
 
142
#endif
 
143
#ifndef CURL_DISABLE_TELNET
 
144
  "telnet",
 
145
#endif
 
146
#ifndef CURL_DISABLE_DICT
 
147
  "dict",
 
148
#endif
 
149
#ifndef CURL_DISABLE_LDAP
 
150
  "ldap",
 
151
#endif
 
152
#ifndef CURL_DISABLE_HTTP
 
153
  "http",
 
154
#endif
 
155
#ifndef CURL_DISABLE_FILE
 
156
  "file",
 
157
#endif
 
158
 
 
159
#ifdef USE_SSLEAY
 
160
#ifndef CURL_DISABLE_HTTP
 
161
  "https",
 
162
#endif
 
163
#ifndef CURL_DISABLE_FTP
 
164
  "ftps",
 
165
#endif
 
166
#endif
 
167
  NULL
 
168
};
 
169
 
 
170
static curl_version_info_data version_info = {
 
171
  CURLVERSION_SECOND,
 
172
  LIBCURL_VERSION,
 
173
  LIBCURL_VERSION_NUM,
 
174
  OS, /* as found by configure or set by hand at build-time */
 
175
  0 /* features is 0 by default */
 
176
#ifdef ENABLE_IPV6
 
177
  | CURL_VERSION_IPV6
 
178
#endif
 
179
#ifdef HAVE_KRB4
 
180
  | CURL_VERSION_KERBEROS4
 
181
#endif
 
182
#ifdef USE_SSLEAY
 
183
  | CURL_VERSION_SSL
 
184
  | CURL_VERSION_NTLM /* since this requires OpenSSL */
 
185
#endif
 
186
#ifdef HAVE_LIBZ
 
187
  | CURL_VERSION_LIBZ
 
188
#endif
 
189
#ifdef HAVE_GSSAPI
 
190
  | CURL_VERSION_GSSNEGOTIATE
 
191
#endif
 
192
#ifdef CURLDEBUG
 
193
  | CURL_VERSION_DEBUG
 
194
#endif
 
195
#ifdef USE_ARES
 
196
  | CURL_VERSION_ASYNCHDNS
 
197
#endif
 
198
#ifdef HAVE_SPNEGO
 
199
  | CURL_VERSION_SPNEGO
 
200
#endif
 
201
#if defined(ENABLE_64BIT) && (SIZEOF_CURL_OFF_T > 4)
 
202
  | CURL_VERSION_LARGEFILE
 
203
#endif
 
204
  ,
 
205
  NULL, /* ssl_version */
 
206
  0,    /* ssl_version_num */
 
207
  NULL, /* zlib_version */
 
208
  protocols,
 
209
  NULL, /* c-ares version */
 
210
  0,    /* c-ares version numerical */
 
211
};
 
212
 
 
213
curl_version_info_data *curl_version_info(CURLversion stamp)
 
214
{
 
215
#ifdef USE_SSLEAY
 
216
  static char ssl_buffer[80];
 
217
  long num;
 
218
  getssl_version(ssl_buffer, &num);
 
219
 
 
220
  version_info.ssl_version = ssl_buffer;
 
221
  version_info.ssl_version_num = num;
 
222
  /* SSL stuff is left zero if undefined */
 
223
#endif
 
224
 
 
225
#ifdef HAVE_LIBZ
 
226
  version_info.libz_version = zlibVersion();
 
227
  /* libz left NULL if non-existing */
 
228
#endif
 
229
#ifdef USE_ARES
 
230
  {
 
231
    int aresnum;
 
232
    version_info.ares = ares_version(&aresnum);
 
233
    version_info.ares_num = aresnum;
 
234
  }
 
235
#endif
 
236
  (void)stamp; /* avoid compiler warnings, we don't use this */
 
237
 
 
238
  return &version_info;
 
239
}