Przeglądaj źródła

Print linked 3rd party libraries with version in `aria2c -v` output

Tatsuhiro Tsujikawa 12 lat temu
rodzic
commit
b35fbd3172
3 zmienionych plików z 87 dodań i 0 usunięć
  1. 81 0
      src/FeatureConfig.cc
  2. 4 0
      src/FeatureConfig.h
  3. 2 0
      src/version_usage.cc

+ 81 - 0
src/FeatureConfig.cc

@@ -34,6 +34,34 @@
 /* copyright --> */
 #include "FeatureConfig.h"
 
+#ifdef HAVE_ZLIB
+# include <zlib.h>
+#endif // HAVE_ZLIB
+#ifdef HAVE_LIBXML2
+# include <libxml/xmlversion.h>
+#endif // HAVE_LIBXML2
+#ifdef HAVE_LIBEXPAT
+# include <expat.h>
+#endif // HAVE_LIBEXPAT
+#ifdef HAVE_SQLITE3
+# include <sqlite3.h>
+#endif // HAVE_SQLITE3
+#ifdef HAVE_LIBGNUTLS
+# include <gnutls/gnutls.h>
+#endif // HAVE_LIBGNUTLS
+#ifdef HAVE_OPENSSL
+# include <openssl/opensslv.h>
+#endif // HAVE_OPENSSL
+#ifdef HAVE_LIBGMP
+# include <gmp.h>
+#endif // HAVE_LIBGMP
+#ifdef HAVE_LIBGCRYPT
+# include <gcrypt.h>
+#endif // HAVE_LIBGCRYPT
+#ifdef HAVE_LIBCARES
+# include <ares.h>
+#endif // HAVE_LIBCARES
+
 #include "util.h"
 
 namespace aria2 {
@@ -141,4 +169,57 @@ const char* strSupportedFeature(int feature)
   }
 }
 
+std::string usedLibs()
+{
+  std::string res;
+#ifdef HAVE_ZLIB
+  res += "zlib/"ZLIB_VERSION" ";
+#endif // HAVE_ZLIB
+#ifdef HAVE_LIBXML2
+  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);
+#endif // HAVE_LIBEXPAT
+#ifdef HAVE_SQLITE3
+  res += "sqlite3/"SQLITE_VERSION" ";
+#endif // HAVE_SQLITE3
+#ifdef HAVE_APPLETLS
+  res += "appleTLS ";
+#endif // HAVE_APPLETLS
+#ifdef HAVE_LIBGNUTLS
+  res += "GnuTLS/"GNUTLS_VERSION" ";
+#endif // HAVE_LIBGNUTLS
+#ifdef HAVE_OPENSSL
+  res += fmt("OpenSSL/%d.%d.%d",
+             OPENSSL_VERSION_NUMBER >> 28,
+             (OPENSSL_VERSION_NUMBER >> 20) & 0xff,
+             (OPENSSL_VERSION_NUMBER >> 12) & 0xff);
+  if((OPENSSL_VERSION_NUMBER >> 4) & 0xff) {
+    res += 'a' + ((OPENSSL_VERSION_NUMBER >> 4) & 0xff) - 1;
+  }
+  res += " ";
+#endif // HAVE_OPENSSL
+#ifdef HAVE_LIBNETTLE
+  // No library version in header files.
+  res += "nettle ";
+#endif // HAVE_LIBNETTLE
+#ifdef HAVE_LIBGMP
+  res += fmt("GMP/%d.%d.%d ",
+             __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR,
+             __GNU_MP_VERSION_PATCHLEVEL);
+#endif // HAVE_LIBGMP
+#ifdef HAVE_LIBGCRYPT
+  res += "libgcrypt/"GCRYPT_VERSION" ";
+#endif // HAVE_LIBGCRYPT
+#ifdef HAVE_LIBCARES
+  res += "c-ares/"ARES_VERSION_STR" ";
+#endif // HAVE_LIBCARES
+  if(!res.empty()) {
+    res.erase(res.length()-1);
+  }
+  return res;
+}
+
 } // namespace aria2

+ 4 - 0
src/FeatureConfig.h

@@ -63,6 +63,10 @@ std::string featureSummary();
 // available in the build. If it is not available, returns NULL.
 const char* strSupportedFeature(int feature);
 
+// Returns summary string of 3rd party libraries directly used by
+// aria2.
+std::string usedLibs();
+
 } // namespace aria2
 
 #endif // D_FEATURE_CONFIG_H

+ 2 - 0
src/version_usage.cc

@@ -75,6 +75,8 @@ void showVersion() {
             << _("Hash Algorithms") << ": "
             << MessageDigest::getSupportedHashTypeString() << "\n"
 #endif // ENABLE_MESSAGE_DIGEST
+            << _("Libraries") << ": "
+            << usedLibs() << "\n"
             << "\n"
             << fmt(_("Report bugs to %s"), PACKAGE_BUGREPORT) << "\n"
             << _("Visit") << " " << PACKAGE_URL << std::endl;