doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
version.c
Go to the documentation of this file.
1 /***************************************************************************
2  * _ _ ____ _
3  * Project ___| | | | _ \| |
4  * / __| | | | |_) | |
5  * | (__| |_| | _ <| |___
6  * \___|\___/|_| \_\_____|
7  *
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  *
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.
17  *
18  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19  * KIND, either express or implied.
20  *
21  * $Id: version.c,v 1.35 2004/03/08 07:46:26 bagder Exp $
22  ***************************************************************************/
23 
24 #include "setup.h"
25 
26 #include <string.h>
27 #include <stdio.h>
28 
29 #include <curl/curl.h>
30 #include "urldata.h"
31 
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)
38 {
39 
40 #if (SSLEAY_VERSION_NUMBER >= 0x905000)
41  {
42  char sub[2];
43  unsigned long ssleay_value;
44  sub[1]='\0';
45  ssleay_value=SSLeay();
46  *num = ssleay_value;
47  if(ssleay_value < 0x906000) {
48  ssleay_value=SSLEAY_VERSION_NUMBER;
49  sub[0]='\0';
50  }
51  else {
52  if(ssleay_value&0xff0) {
53  sub[0]=(char)((ssleay_value>>4)&0xff) + 'a' -1;
54  }
55  else
56  sub[0]='\0';
57  }
58 
59  sprintf(ptr, " OpenSSL/%lx.%lx.%lx%s",
60  (ssleay_value>>28)&0xf,
61  (ssleay_value>>20)&0xff,
62  (ssleay_value>>12)&0xff,
63  sub);
64  }
65 
66 #else
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);
73 #else
74  {
75  char sub[2];
76  sub[1]='\0';
77  if(SSLEAY_VERSION_NUMBER&0x0f) {
78  sub[0]=(SSLEAY_VERSION_NUMBER&0x0f) + 'a' -1;
79  }
80  else
81  sub[0]='\0';
82 
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);
87  }
88 #endif
89 #endif
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");
111  ptr += strlen(ptr);
112 #endif
113 #ifdef ENABLE_IPV6
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));
128  ptr += strlen(ptr);
129 #endif
130 
131  return version;
132 }
133 
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 = {
174  OS, /* as found by configure or set by hand at build-time */
175  0 /* features is 0 by default */
176 #ifdef ENABLE_IPV6
178 #endif
179 #ifdef HAVE_KRB4
181 #endif
182 #ifdef USE_SSLEAY
184  | CURL_VERSION_NTLM /* since this requires OpenSSL */
185 #endif
186 #ifdef HAVE_LIBZ
188 #endif
189 #ifdef HAVE_GSSAPI
191 #endif
192 #ifdef CURLDEBUG
194 #endif
195 #ifdef USE_ARES
197 #endif
198 #ifdef HAVE_SPNEGO
200 #endif
201 #if defined(ENABLE_64BIT) && (SIZEOF_CURL_OFF_T > 4)
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 
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 }
#define OS
#define CURL_VERSION_SSL
Definition: curl.h:1254
#define CURL_VERSION_LIBZ
Definition: curl.h:1255
#define LIBCURL_NAME
Definition: urldata.h:911
GLuint GLuint num
Definition: glext.h:5390
CURLversion
Definition: curl.h:1222
#define CURL_VERSION_NTLM
Definition: curl.h:1256
const char * ares
Definition: curl.h:1248
struct version_s version
curl_version_info_data * curl_version_info(CURLversion stamp)
Definition: version.c:213
#define CURL_VERSION_DEBUG
Definition: curl.h:1258
const char * libz_version
Definition: curl.h:1243
#define NULL
Definition: Lib.h:88
#define LIBCURL_VERSION
Definition: curl.h:32
#define LIBCURL_VERSION_NUM
Definition: curl.h:48
#define CURL_VERSION_IPV6
Definition: curl.h:1252
char * curl_version(void)
Definition: version.c:94
#define CURL_VERSION_GSSNEGOTIATE
Definition: curl.h:1257
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
#define CURL_VERSION_ASYNCHDNS
Definition: curl.h:1259
#define CURL_VERSION_LARGEFILE
Definition: curl.h:1261
int sprintf(idStr &string, const char *fmt,...)
Definition: Str.cpp:1528
#define CURL_VERSION_KERBEROS4
Definition: curl.h:1253
#define CURL_VERSION_SPNEGO
Definition: curl.h:1260