version.c
Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                  _   _ ____  _
00003  *  Project                     ___| | | |  _ \| |
00004  *                             / __| | | | |_) | |
00005  *                            | (__| |_| |  _ <| |___
00006  *                             \___|\___/|_| \_\_____|
00007  *
00008  * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
00009  *
00010  * This software is licensed as described in the file COPYING, which
00011  * you should have received as part of this distribution. The terms
00012  * are also available at https://curl.haxx.se/docs/copyright.html.
00013  *
00014  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00015  * copies of the Software, and permit persons to whom the Software is
00016  * furnished to do so, under the terms of the COPYING file.
00017  *
00018  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00019  * KIND, either express or implied.
00020  *
00021  ***************************************************************************/
00022 
00023 #include "curl_setup.h"
00024 
00025 #include <curl/curl.h>
00026 #include "urldata.h"
00027 #include "vtls/vtls.h"
00028 #include "http2.h"
00029 #include "curl_printf.h"
00030 
00031 #ifdef USE_ARES
00032 #  if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
00033      (defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__))
00034 #    define CARES_STATICLIB
00035 #  endif
00036 #  include <ares.h>
00037 #endif
00038 
00039 #ifdef USE_LIBIDN2
00040 #include <idn2.h>
00041 #endif
00042 
00043 #ifdef USE_LIBPSL
00044 #include <libpsl.h>
00045 #endif
00046 
00047 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
00048 #include <iconv.h>
00049 #endif
00050 
00051 #ifdef USE_LIBRTMP
00052 #include <librtmp/rtmp.h>
00053 #endif
00054 
00055 #ifdef USE_LIBSSH2
00056 #include <libssh2.h>
00057 #endif
00058 
00059 #ifdef HAVE_LIBSSH2_VERSION
00060 /* get it run-time if possible */
00061 #define CURL_LIBSSH2_VERSION libssh2_version(0)
00062 #else
00063 /* use build-time if run-time not possible */
00064 #define CURL_LIBSSH2_VERSION LIBSSH2_VERSION
00065 #endif
00066 
00067 void Curl_version_init(void);
00068 
00069 /* For thread safety purposes this function is called by global_init so that
00070    the static data in both version functions is initialized. */
00071 void Curl_version_init(void)
00072 {
00073   curl_version();
00074   curl_version_info(CURLVERSION_NOW);
00075 }
00076 
00077 char *curl_version(void)
00078 {
00079   static bool initialized;
00080   static char version[200];
00081   char *ptr = version;
00082   size_t len;
00083   size_t left = sizeof(version);
00084 
00085   if(initialized)
00086     return version;
00087 
00088   strcpy(ptr, LIBCURL_NAME "/" LIBCURL_VERSION);
00089   len = strlen(ptr);
00090   left -= len;
00091   ptr += len;
00092 
00093   if(left > 1) {
00094     len = Curl_ssl_version(ptr + 1, left - 1);
00095 
00096     if(len > 0) {
00097       *ptr = ' ';
00098       left -= ++len;
00099       ptr += len;
00100     }
00101   }
00102 
00103 #ifdef HAVE_LIBZ
00104   len = snprintf(ptr, left, " zlib/%s", zlibVersion());
00105   left -= len;
00106   ptr += len;
00107 #endif
00108 #ifdef USE_ARES
00109   /* this function is only present in c-ares, not in the original ares */
00110   len = snprintf(ptr, left, " c-ares/%s", ares_version(NULL));
00111   left -= len;
00112   ptr += len;
00113 #endif
00114 #ifdef USE_LIBIDN2
00115   if(idn2_check_version(IDN2_VERSION)) {
00116     len = snprintf(ptr, left, " libidn2/%s", idn2_check_version(NULL));
00117     left -= len;
00118     ptr += len;
00119   }
00120 #endif
00121 #ifdef USE_LIBPSL
00122   len = snprintf(ptr, left, " libpsl/%s", psl_get_version());
00123   left -= len;
00124   ptr += len;
00125 #endif
00126 #ifdef USE_WIN32_IDN
00127   len = snprintf(ptr, left, " WinIDN");
00128   left -= len;
00129   ptr += len;
00130 #endif
00131 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
00132 #ifdef _LIBICONV_VERSION
00133   len = snprintf(ptr, left, " iconv/%d.%d",
00134                  _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 255);
00135 #else
00136   /* version unknown */
00137   len = snprintf(ptr, left, " iconv");
00138 #endif /* _LIBICONV_VERSION */
00139   left -= len;
00140   ptr += len;
00141 #endif
00142 #ifdef USE_LIBSSH2
00143   len = snprintf(ptr, left, " libssh2/%s", CURL_LIBSSH2_VERSION);
00144   left -= len;
00145   ptr += len;
00146 #endif
00147 #ifdef USE_NGHTTP2
00148   len = Curl_http2_ver(ptr, left);
00149   left -= len;
00150   ptr += len;
00151 #endif
00152 #ifdef USE_LIBRTMP
00153   {
00154     char suff[2];
00155     if(RTMP_LIB_VERSION & 0xff) {
00156       suff[0] = (RTMP_LIB_VERSION & 0xff) + 'a' - 1;
00157       suff[1] = '\0';
00158     }
00159     else
00160       suff[0] = '\0';
00161 
00162     snprintf(ptr, left, " librtmp/%d.%d%s",
00163              RTMP_LIB_VERSION >> 16, (RTMP_LIB_VERSION >> 8) & 0xff,
00164              suff);
00165 /*
00166   If another lib version is added below this one, this code would
00167   also have to do:
00168 
00169     len = what snprintf() returned
00170 
00171     left -= len;
00172     ptr += len;
00173 */
00174   }
00175 #endif
00176 
00177   initialized = true;
00178   return version;
00179 }
00180 
00181 /* data for curl_version_info
00182 
00183    Keep the list sorted alphabetically. It is also written so that each
00184    protocol line has its own #if line to make things easier on the eye.
00185  */
00186 
00187 static const char * const protocols[] = {
00188 #ifndef CURL_DISABLE_DICT
00189   "dict",
00190 #endif
00191 #ifndef CURL_DISABLE_FILE
00192   "file",
00193 #endif
00194 #ifndef CURL_DISABLE_FTP
00195   "ftp",
00196 #endif
00197 #if defined(USE_SSL) && !defined(CURL_DISABLE_FTP)
00198   "ftps",
00199 #endif
00200 #ifndef CURL_DISABLE_GOPHER
00201   "gopher",
00202 #endif
00203 #ifndef CURL_DISABLE_HTTP
00204   "http",
00205 #endif
00206 #if defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)
00207   "https",
00208 #endif
00209 #ifndef CURL_DISABLE_IMAP
00210   "imap",
00211 #endif
00212 #if defined(USE_SSL) && !defined(CURL_DISABLE_IMAP)
00213   "imaps",
00214 #endif
00215 #ifndef CURL_DISABLE_LDAP
00216   "ldap",
00217 #if !defined(CURL_DISABLE_LDAPS) && \
00218     ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \
00219      (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL)))
00220   "ldaps",
00221 #endif
00222 #endif
00223 #ifndef CURL_DISABLE_POP3
00224   "pop3",
00225 #endif
00226 #if defined(USE_SSL) && !defined(CURL_DISABLE_POP3)
00227   "pop3s",
00228 #endif
00229 #ifdef USE_LIBRTMP
00230   "rtmp",
00231 #endif
00232 #ifndef CURL_DISABLE_RTSP
00233   "rtsp",
00234 #endif
00235 #ifdef USE_LIBSSH2
00236   "scp",
00237 #endif
00238 #ifdef USE_LIBSSH2
00239   "sftp",
00240 #endif
00241 #if !defined(CURL_DISABLE_SMB) && defined(USE_NTLM) && \
00242    (CURL_SIZEOF_CURL_OFF_T > 4) && \
00243    (!defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO))
00244   "smb",
00245 #  ifdef USE_SSL
00246   "smbs",
00247 #  endif
00248 #endif
00249 #ifndef CURL_DISABLE_SMTP
00250   "smtp",
00251 #endif
00252 #if defined(USE_SSL) && !defined(CURL_DISABLE_SMTP)
00253   "smtps",
00254 #endif
00255 #ifndef CURL_DISABLE_TELNET
00256   "telnet",
00257 #endif
00258 #ifndef CURL_DISABLE_TFTP
00259   "tftp",
00260 #endif
00261 
00262   NULL
00263 };
00264 
00265 static curl_version_info_data version_info = {
00266   CURLVERSION_NOW,
00267   LIBCURL_VERSION,
00268   LIBCURL_VERSION_NUM,
00269   OS, /* as found by configure or set by hand at build-time */
00270   0 /* features is 0 by default */
00271 #ifdef ENABLE_IPV6
00272   | CURL_VERSION_IPV6
00273 #endif
00274 #ifdef USE_SSL
00275   | CURL_VERSION_SSL
00276 #endif
00277 #ifdef USE_NTLM
00278   | CURL_VERSION_NTLM
00279 #endif
00280 #if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \
00281   defined(NTLM_WB_ENABLED)
00282   | CURL_VERSION_NTLM_WB
00283 #endif
00284 #ifdef USE_SPNEGO
00285   | CURL_VERSION_SPNEGO
00286 #endif
00287 #ifdef USE_KERBEROS5
00288   | CURL_VERSION_KERBEROS5
00289 #endif
00290 #ifdef HAVE_GSSAPI
00291   | CURL_VERSION_GSSAPI
00292 #endif
00293 #ifdef USE_WINDOWS_SSPI
00294   | CURL_VERSION_SSPI
00295 #endif
00296 #ifdef HAVE_LIBZ
00297   | CURL_VERSION_LIBZ
00298 #endif
00299 #ifdef DEBUGBUILD
00300   | CURL_VERSION_DEBUG
00301 #endif
00302 #ifdef CURLDEBUG
00303   | CURL_VERSION_CURLDEBUG
00304 #endif
00305 #ifdef CURLRES_ASYNCH
00306   | CURL_VERSION_ASYNCHDNS
00307 #endif
00308 #if (CURL_SIZEOF_CURL_OFF_T > 4) && \
00309     ( (SIZEOF_OFF_T > 4) || defined(USE_WIN32_LARGE_FILES) )
00310   | CURL_VERSION_LARGEFILE
00311 #endif
00312 #if defined(CURL_DOES_CONVERSIONS)
00313   | CURL_VERSION_CONV
00314 #endif
00315 #if defined(USE_TLS_SRP)
00316   | CURL_VERSION_TLSAUTH_SRP
00317 #endif
00318 #if defined(USE_NGHTTP2)
00319   | CURL_VERSION_HTTP2
00320 #endif
00321 #if defined(USE_UNIX_SOCKETS)
00322   | CURL_VERSION_UNIX_SOCKETS
00323 #endif
00324 #if defined(USE_LIBPSL)
00325   | CURL_VERSION_PSL
00326 #endif
00327 #if defined(HTTPS_PROXY_SUPPORT)
00328   | CURL_VERSION_HTTPS_PROXY
00329 #endif
00330   ,
00331   NULL, /* ssl_version */
00332   0,    /* ssl_version_num, this is kept at zero */
00333   NULL, /* zlib_version */
00334   protocols,
00335   NULL, /* c-ares version */
00336   0,    /* c-ares version numerical */
00337   NULL, /* libidn version */
00338   0,    /* iconv version */
00339   NULL, /* ssh lib version */
00340 };
00341 
00342 curl_version_info_data *curl_version_info(CURLversion stamp)
00343 {
00344   static bool initialized;
00345 #ifdef USE_LIBSSH2
00346   static char ssh_buffer[80];
00347 #endif
00348 #ifdef USE_SSL
00349   static char ssl_buffer[80];
00350 #endif
00351 
00352   if(initialized)
00353     return &version_info;
00354 
00355 #ifdef USE_SSL
00356   Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer));
00357   version_info.ssl_version = ssl_buffer;
00358 #endif
00359 
00360 #ifdef HAVE_LIBZ
00361   version_info.libz_version = zlibVersion();
00362   /* libz left NULL if non-existing */
00363 #endif
00364 #ifdef USE_ARES
00365   {
00366     int aresnum;
00367     version_info.ares = ares_version(&aresnum);
00368     version_info.ares_num = aresnum;
00369   }
00370 #endif
00371 #ifdef USE_LIBIDN2
00372   /* This returns a version string if we use the given version or later,
00373      otherwise it returns NULL */
00374   version_info.libidn = idn2_check_version(IDN2_VERSION);
00375   if(version_info.libidn)
00376     version_info.features |= CURL_VERSION_IDN;
00377 #elif defined(USE_WIN32_IDN)
00378   version_info.features |= CURL_VERSION_IDN;
00379 #endif
00380 
00381 #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
00382 #ifdef _LIBICONV_VERSION
00383   version_info.iconv_ver_num = _LIBICONV_VERSION;
00384 #else
00385   /* version unknown */
00386   version_info.iconv_ver_num = -1;
00387 #endif /* _LIBICONV_VERSION */
00388 #endif
00389 
00390 #ifdef USE_LIBSSH2
00391   snprintf(ssh_buffer, sizeof(ssh_buffer), "libssh2/%s", LIBSSH2_VERSION);
00392   version_info.libssh_version = ssh_buffer;
00393 #endif
00394 
00395   (void)stamp; /* avoid compiler warnings, we don't use this */
00396 
00397   initialized = true;
00398   return &version_info;
00399 }


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:07