diff options
Diffstat (limited to 'src/FeatureConfig.cc')
| -rw-r--r-- | src/FeatureConfig.cc | 135 |
1 files changed, 68 insertions, 67 deletions
diff --git a/src/FeatureConfig.cc b/src/FeatureConfig.cc index 1b5b183a..3cebd846 100644 --- a/src/FeatureConfig.cc +++ b/src/FeatureConfig.cc @@ -38,37 +38,37 @@ #include <cstring> #ifdef HAVE_ZLIB -# include <zlib.h> +#include <zlib.h> #endif // HAVE_ZLIB #ifdef HAVE_LIBXML2 -# include <libxml/xmlversion.h> +#include <libxml/xmlversion.h> #endif // HAVE_LIBXML2 #ifdef HAVE_LIBEXPAT -# include <expat.h> +#include <expat.h> #endif // HAVE_LIBEXPAT #ifdef HAVE_SQLITE3 -# include <sqlite3.h> +#include <sqlite3.h> #endif // HAVE_SQLITE3 #ifdef HAVE_LIBGNUTLS -# include <gnutls/gnutls.h> +#include <gnutls/gnutls.h> #endif // HAVE_LIBGNUTLS #ifdef HAVE_OPENSSL -# include <openssl/opensslv.h> +#include <openssl/opensslv.h> #endif // HAVE_OPENSSL #ifdef HAVE_LIBGMP -# include <gmp.h> +#include <gmp.h> #endif // HAVE_LIBGMP #ifdef HAVE_LIBGCRYPT -# include <gcrypt.h> +#include <gcrypt.h> #endif // HAVE_LIBGCRYPT #ifdef HAVE_LIBCARES -# include <ares.h> +#include <ares.h> #endif // HAVE_LIBCARES #ifdef HAVE_SYS_UTSNAME_H -# include <sys/utsname.h> +#include <sys/utsname.h> #endif // HAVE_SYS_UTSNAME_H #ifdef HAVE_LIBSSH2 -# include <libssh2.h> +#include <libssh2.h> #endif // HAVE_LIBSSH2 #include "util.h" @@ -76,15 +76,19 @@ namespace aria2 { uint16_t getDefaultPort(const std::string& protocol) { - if(protocol == "http") { + if (protocol == "http") { return 80; - } else if(protocol == "https") { + } + else if (protocol == "https") { return 443; - } else if(protocol == "ftp") { + } + else if (protocol == "ftp") { return 21; - } else if(protocol == "sftp") { + } + else if (protocol == "sftp") { return 22; - } else { + } + else { return 0; } } @@ -93,12 +97,13 @@ std::string featureSummary() { std::string s; int first; - for(first = 0; first < MAX_FEATURE && !strSupportedFeature(first); ++first); - if(first < MAX_FEATURE) { + for (first = 0; first < MAX_FEATURE && !strSupportedFeature(first); ++first) + ; + if (first < MAX_FEATURE) { s += strSupportedFeature(first); - for(int i = first+1; i < MAX_FEATURE; ++i) { + for (int i = first + 1; i < MAX_FEATURE; ++i) { const char* name = strSupportedFeature(i); - if(name) { + if (name) { s += ", "; s += name; } @@ -109,71 +114,71 @@ std::string featureSummary() const char* strSupportedFeature(int feature) { - switch(feature) { - case(FEATURE_ASYNC_DNS): + switch (feature) { + case (FEATURE_ASYNC_DNS): #ifdef ENABLE_ASYNC_DNS return "Async DNS"; -#else // !ENABLE_ASYNC_DNS +#else // !ENABLE_ASYNC_DNS return nullptr; #endif // !ENABLE_ASYNC_DNS break; - case(FEATURE_BITTORRENT): + case (FEATURE_BITTORRENT): #ifdef ENABLE_BITTORRENT return "BitTorrent"; -#else // !ENABLE_BITTORRENT +#else // !ENABLE_BITTORRENT return nullptr; #endif // !ENABLE_BITTORRENT break; - case(FEATURE_FF3_COOKIE): + case (FEATURE_FF3_COOKIE): #ifdef HAVE_SQLITE3 return "Firefox3 Cookie"; -#else // !HAVE_SQLITE3 +#else // !HAVE_SQLITE3 return nullptr; #endif // !HAVE_SQLITE3 break; - case(FEATURE_GZIP): + case (FEATURE_GZIP): #ifdef HAVE_ZLIB return "GZip"; -#else // !HAVE_ZLIB +#else // !HAVE_ZLIB return nullptr; #endif // !HAVE_ZLIB break; - case(FEATURE_HTTPS): + case (FEATURE_HTTPS): #ifdef ENABLE_SSL return "HTTPS"; -#else // !ENABLE_SSL +#else // !ENABLE_SSL return nullptr; #endif // !ENABLE_SSL break; - case(FEATURE_MESSAGE_DIGEST): + case (FEATURE_MESSAGE_DIGEST): return "Message Digest"; break; - case(FEATURE_METALINK): + case (FEATURE_METALINK): #ifdef ENABLE_METALINK return "Metalink"; -#else // !ENABLE_METALINK +#else // !ENABLE_METALINK return nullptr; #endif // !ENABLE_METALINK break; - case(FEATURE_XML_RPC): + case (FEATURE_XML_RPC): #ifdef ENABLE_XML_RPC return "XML-RPC"; -#else // !ENABLE_XML_RPC +#else // !ENABLE_XML_RPC return nullptr; #endif // !ENABLE_XML_RPC break; - case(FEATURE_SFTP): + case (FEATURE_SFTP): #ifdef HAVE_LIBSSH2 return "SFTP"; -#else // !HAVE_LIBSSH2 +#else // !HAVE_LIBSSH2 return nullptr; #endif // !HAVE_LIBSSH2 break; @@ -193,8 +198,8 @@ std::string usedLibs() res += "libxml2/" LIBXML_DOTTED_VERSION " "; #endif // HAVE_LIBXML2 #ifdef HAVE_LIBEXPAT - res += fmt("expat/%d.%d.%d ", - XML_MAJOR_VERSION, XML_MINOR_VERSION, XML_MICRO_VERSION); + res += fmt("expat/%d.%d.%d ", XML_MAJOR_VERSION, XML_MINOR_VERSION, + XML_MICRO_VERSION); #endif // HAVE_LIBEXPAT #ifdef HAVE_SQLITE3 res += "sqlite3/" SQLITE_VERSION " "; @@ -209,11 +214,10 @@ std::string usedLibs() res += "GnuTLS/" GNUTLS_VERSION " "; #endif // HAVE_LIBGNUTLS #ifdef HAVE_OPENSSL - res += fmt("OpenSSL/%ld.%ld.%ld", - OPENSSL_VERSION_NUMBER >> 28, + res += fmt("OpenSSL/%ld.%ld.%ld", OPENSSL_VERSION_NUMBER >> 28, (OPENSSL_VERSION_NUMBER >> 20) & 0xff, (OPENSSL_VERSION_NUMBER >> 12) & 0xff); - if((OPENSSL_VERSION_NUMBER >> 4) & 0xff) { + if ((OPENSSL_VERSION_NUMBER >> 4) & 0xff) { res += 'a' + ((OPENSSL_VERSION_NUMBER >> 4) & 0xff) - 1; } res += " "; @@ -223,8 +227,7 @@ std::string usedLibs() res += "nettle "; #endif // HAVE_LIBNETTLE #ifdef HAVE_LIBGMP - res += fmt("GMP/%d.%d.%d ", - __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, + res += fmt("GMP/%d.%d.%d ", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL); #endif // HAVE_LIBGMP #ifdef HAVE_LIBGCRYPT @@ -238,8 +241,8 @@ std::string usedLibs() res += "libssh2/" LIBSSH2_VERSION " "; #endif // HAVE_LIBSSH2 - if(!res.empty()) { - res.erase(res.length()-1); + if (!res.empty()) { + res.erase(res.length() - 1); } return res; } @@ -251,7 +254,7 @@ std::string usedCompilerAndPlatform() #ifdef __apple_build_version__ rv << "Apple LLVM "; -#else // !__apple_build_version__ +#else // !__apple_build_version__ rv << "clang "; #endif // !__apple_build_version__ rv << __clang_version__; @@ -260,7 +263,7 @@ std::string usedCompilerAndPlatform() rv << "Intel ICC " << __VERSION__; -#elif defined( __MINGW64_VERSION_STR) +#elif defined(__MINGW64_VERSION_STR) rv << "mingw-w64 " << __MINGW64_VERSION_STR; #ifdef __MINGW64_VERSION_STATE @@ -289,7 +292,7 @@ std::string usedCompilerAndPlatform() #endif // !defined(__GNUG__) rv << "\n built by " << BUILD; - if(strcmp(BUILD, TARGET)) { + if (strcmp(BUILD, TARGET)) { rv << "\n targetting " << TARGET; } rv << "\n on " << __DATE__ << " " << __TIME__; @@ -302,20 +305,18 @@ std::string getOperatingSystemInfo() #ifdef _WIN32 std::stringstream rv; rv << "Windows "; - OSVERSIONINFOEX ovi = { - sizeof(OSVERSIONINFOEX) - }; - if(!GetVersionEx((LPOSVERSIONINFO)&ovi)) { + OSVERSIONINFOEX ovi = {sizeof(OSVERSIONINFOEX)}; + if (!GetVersionEx((LPOSVERSIONINFO)&ovi)) { rv << "Unknown"; return rv.str(); } - if(ovi.dwMajorVersion < 6) { + if (ovi.dwMajorVersion < 6) { rv << "Legacy, probably XP"; return rv.str(); } - switch(ovi.dwMinorVersion) { + switch (ovi.dwMinorVersion) { case 0: - if(ovi.wProductType == VER_NT_WORKSTATION) { + if (ovi.wProductType == VER_NT_WORKSTATION) { rv << "Vista"; } else { @@ -324,7 +325,7 @@ std::string getOperatingSystemInfo() break; case 1: - if(ovi.wProductType == VER_NT_WORKSTATION) { + if (ovi.wProductType == VER_NT_WORKSTATION) { rv << "7"; } else { @@ -336,15 +337,15 @@ std::string getOperatingSystemInfo() // Windows above 6.2 does not actually say so. :p rv << ovi.dwMajorVersion; - if(ovi.dwMinorVersion) { + if (ovi.dwMinorVersion) { rv << "." << ovi.dwMinorVersion; } - if(ovi.wProductType != VER_NT_WORKSTATION) { + if (ovi.wProductType != VER_NT_WORKSTATION) { rv << " Server"; } break; } - if(ovi.szCSDVersion[0]) { + if (ovi.szCSDVersion[0]) { rv << " (" << ovi.szCSDVersion << ")"; } #ifdef _WIN64 @@ -355,13 +356,13 @@ std::string getOperatingSystemInfo() #else //! _WIN32 #ifdef HAVE_SYS_UTSNAME_H struct utsname name; - if(!uname(&name)) { - if(!strstr(name.version, name.sysname) || - !strstr(name.version, name.release) || - !strstr(name.version, name.machine)) { + if (!uname(&name)) { + if (!strstr(name.version, name.sysname) || + !strstr(name.version, name.release) || + !strstr(name.version, name.machine)) { std::stringstream ss; - ss << name.sysname << " " << name.release << " " << name.version << - " " << name.machine; + ss << name.sysname << " " << name.release << " " << name.version << " " + << name.machine; return ss.str(); } return name.version; |
