00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "setup.h"
00025
00026 #include <string.h>
00027 #include <stdio.h>
00028
00029 #include <curl/curl.h>
00030 #include "urldata.h"
00031 #include "sslgen.h"
00032
00033 #define _MPRINTF_REPLACE
00034 #include <curl/mprintf.h>
00035
00036 #ifdef USE_ARES
00037 #include <ares_version.h>
00038 #endif
00039
00040 #ifdef USE_LIBIDN
00041 #include <stringprep.h>
00042 #endif
00043
00044 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
00045 #include <iconv.h>
00046 #endif
00047
00048 #ifdef USE_LIBSSH2
00049 #include <libssh2.h>
00050 #endif
00051
00052
00053 char *curl_version(void)
00054 {
00055 static char version[200];
00056 char *ptr=version;
00057 size_t len;
00058 size_t left = sizeof(version);
00059 strcpy(ptr, LIBCURL_NAME "/" LIBCURL_VERSION );
00060 ptr=strchr(ptr, '\0');
00061 left -= strlen(ptr);
00062
00063 len = Curl_ssl_version(ptr, left);
00064 left -= len;
00065 ptr += len;
00066
00067 #ifdef HAVE_LIBZ
00068 len = snprintf(ptr, left, " zlib/%s", zlibVersion());
00069 left -= len;
00070 ptr += len;
00071 #endif
00072 #ifdef USE_ARES
00073
00074 len = snprintf(ptr, left, " c-ares/%s", ares_version(NULL));
00075 left -= len;
00076 ptr += len;
00077 #endif
00078 #ifdef USE_LIBIDN
00079 if(stringprep_check_version(LIBIDN_REQUIRED_VERSION)) {
00080 len = snprintf(ptr, left, " libidn/%s", stringprep_check_version(NULL));
00081 left -= len;
00082 ptr += len;
00083 }
00084 #endif
00085 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
00086 #ifdef _LIBICONV_VERSION
00087 len = snprintf(ptr, left, " iconv/%d.%d",
00088 _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 255);
00089 #else
00090
00091 len = snprintf(ptr, left, " iconv");
00092 #endif
00093 left -= len;
00094 ptr += len;
00095 #endif
00096 #ifdef USE_LIBSSH2
00097 len = snprintf(ptr, left, " libssh2/%s", LIBSSH2_VERSION);
00098 left -= len;
00099 ptr += len;
00100 #endif
00101
00102 return version;
00103 }
00104
00105
00106
00107 static const char * const protocols[] = {
00108 #ifndef CURL_DISABLE_TFTP
00109 "tftp",
00110 #endif
00111 #ifndef CURL_DISABLE_FTP
00112 "ftp",
00113 #endif
00114 #ifndef CURL_DISABLE_TELNET
00115 "telnet",
00116 #endif
00117 #ifndef CURL_DISABLE_DICT
00118 "dict",
00119 #endif
00120 #ifndef CURL_DISABLE_LDAP
00121 "ldap",
00122 #endif
00123 #ifndef CURL_DISABLE_HTTP
00124 "http",
00125 #endif
00126 #ifndef CURL_DISABLE_FILE
00127 "file",
00128 #endif
00129
00130 #ifdef USE_SSL
00131 #ifndef CURL_DISABLE_HTTP
00132 "https",
00133 #endif
00134 #ifndef CURL_DISABLE_FTP
00135 "ftps",
00136 #endif
00137 #endif
00138
00139 #ifdef USE_LIBSSH2
00140 "scp",
00141 "sftp",
00142 #endif
00143
00144 NULL
00145 };
00146
00147 static curl_version_info_data version_info = {
00148 CURLVERSION_NOW,
00149 LIBCURL_VERSION,
00150 LIBCURL_VERSION_NUM,
00151 OS,
00152 0
00153 #ifdef ENABLE_IPV6
00154 | CURL_VERSION_IPV6
00155 #endif
00156 #ifdef HAVE_KRB4
00157 | CURL_VERSION_KERBEROS4
00158 #endif
00159 #ifdef USE_SSL
00160 | CURL_VERSION_SSL
00161 #endif
00162 #ifdef USE_NTLM
00163 | CURL_VERSION_NTLM
00164 #endif
00165 #ifdef USE_WINDOWS_SSPI
00166 | CURL_VERSION_SSPI
00167 #endif
00168 #ifdef HAVE_LIBZ
00169 | CURL_VERSION_LIBZ
00170 #endif
00171 #ifdef HAVE_GSSAPI
00172 | CURL_VERSION_GSSNEGOTIATE
00173 #endif
00174 #ifdef CURLDEBUG
00175 | CURL_VERSION_DEBUG
00176 #endif
00177 #ifdef USE_ARES
00178 | CURL_VERSION_ASYNCHDNS
00179 #endif
00180 #ifdef HAVE_SPNEGO
00181 | CURL_VERSION_SPNEGO
00182 #endif
00183 #if defined(ENABLE_64BIT) && (SIZEOF_CURL_OFF_T > 4)
00184 | CURL_VERSION_LARGEFILE
00185 #endif
00186 #if defined(CURL_DOES_CONVERSIONS)
00187 | CURL_VERSION_CONV
00188 #endif
00189 ,
00190 NULL,
00191 0,
00192 NULL,
00193 protocols,
00194 NULL,
00195 0,
00196 NULL,
00197 0,
00198 NULL,
00199 };
00200
00201 curl_version_info_data *curl_version_info(CURLversion stamp)
00202 {
00203 #ifdef USE_LIBSSH2
00204 static char ssh_buffer[80];
00205 #endif
00206
00207 #ifdef USE_SSL
00208 static char ssl_buffer[80];
00209 Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer));
00210 version_info.ssl_version = ssl_buffer;
00211 #endif
00212
00213 #ifdef HAVE_LIBZ
00214 version_info.libz_version = zlibVersion();
00215
00216 #endif
00217 #ifdef USE_ARES
00218 {
00219 int aresnum;
00220 version_info.ares = ares_version(&aresnum);
00221 version_info.ares_num = aresnum;
00222 }
00223 #endif
00224 #ifdef USE_LIBIDN
00225
00226
00227 version_info.libidn = stringprep_check_version(LIBIDN_REQUIRED_VERSION);
00228 if(version_info.libidn)
00229 version_info.features |= CURL_VERSION_IDN;
00230 #endif
00231
00232 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
00233 #ifdef _LIBICONV_VERSION
00234 version_info.iconv_ver_num = _LIBICONV_VERSION;
00235 #else
00236
00237 version_info.iconv_ver_num = -1;
00238 #endif
00239 #endif
00240
00241 #ifdef USE_LIBSSH2
00242 snprintf(ssh_buffer, sizeof(ssh_buffer), "libssh2/%s", LIBSSH2_VERSION);
00243 version_info.libssh_version = ssh_buffer;
00244 #endif
00245
00246 (void)stamp;
00247
00248 return &version_info;
00249 }