Wez Furlong's curl_version_info() function added, still needs some
[platform/upstream/curl.git] / lib / version.c
1 /***************************************************************************
2  *                                  _   _ ____  _     
3  *  Project                     ___| | | |  _ \| |    
4  *                             / __| | | | |_) | |    
5  *                            | (__| |_| |  _ <| |___ 
6  *                             \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) 1998 - 2002, 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$
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 char *curl_version(void)
33 {
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
41 #if (SSLEAY_VERSION_NUMBER >= 0x905000)
42   {
43     char sub[2];
44     unsigned long ssleay_value;
45     sub[1]='\0';
46     ssleay_value=SSLeay();
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]=((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 #if (SSLEAY_VERSION_NUMBER >= 0x900000)
68   sprintf(ptr, " OpenSSL/%lx.%lx.%lx",
69           (SSLEAY_VERSION_NUMBER>>28)&0xff,
70           (SSLEAY_VERSION_NUMBER>>20)&0xff,
71           (SSLEAY_VERSION_NUMBER>>12)&0xf);
72 #else
73   {
74     char sub[2];
75     sub[1]='\0';
76     if(SSLEAY_VERSION_NUMBER&0x0f) {
77       sub[0]=(SSLEAY_VERSION_NUMBER&0x0f) + 'a' -1;
78     }
79     else
80       sub[0]='\0';
81
82     sprintf(ptr, " SSL/%x.%x.%x%s",
83             (SSLEAY_VERSION_NUMBER>>12)&0xff,
84             (SSLEAY_VERSION_NUMBER>>8)&0xf,
85             (SSLEAY_VERSION_NUMBER>>4)&0xf, sub);
86   }
87 #endif
88 #endif
89   ptr=strchr(ptr, '\0');
90 #endif
91
92 #ifdef KRB4
93   sprintf(ptr, " krb4");
94   ptr += strlen(ptr);
95 #endif
96 #ifdef ENABLE_IPV6
97   sprintf(ptr, " ipv6");
98   ptr += strlen(ptr);
99 #endif
100 #ifdef HAVE_LIBZ
101   sprintf(ptr, " zlib/%s", zlibVersion());
102   ptr += strlen(ptr);
103 #endif
104
105   return version;
106 }
107
108 /* data for curl_version_info */
109
110 static const curl_runtime_protocol_info protocols[] = {
111 #ifndef CURL_DISABLE_FTP
112   { "ftp" },
113 #endif
114 #ifndef CURL_DISABLE_GOPHER
115   { "gopher" },
116 #endif
117 #ifndef CURL_DISABLE_TELNET
118   { "telnet" },
119 #endif
120 #ifndef CURL_DISABLE_DICT
121   { "dict" },
122 #endif
123 #ifndef CURL_DISABLE_LDAP
124   { "ldap" },
125 #endif
126 #ifndef CURL_DISABLE_HTTP
127   { "http" },
128 #endif
129 #ifndef CURL_DISABLE_FILE
130   { "file" },
131 #endif
132
133 #ifdef USE_SSLEAY
134 #ifndef CURL_DISABLE_HTTP
135   { "https" },
136 #endif
137 #ifndef CURL_DISABLE_FTP
138   { "ftps" },
139 #endif
140 #endif
141   { NULL }
142 };
143
144 static const curl_version_info_data version_info = {
145   LIBCURL_VERSION,
146   LIBCURL_VERSION_NUM,
147   &protocols
148 };
149
150 const curl_version_info_data *curl_version_info(void)
151 {
152   return &version_info;
153 }
154
155 /*
156  * local variables:
157  * eval: (load-file "../curl-mode.el")
158  * end:
159  * vim600: fdm=marker
160  * vim: et sw=2 ts=2 sts=2 tw=78
161  */