Bitcoin ABC 0.30.5
P2P Digital Currency
clientversion.cpp
Go to the documentation of this file.
1// Copyright (c) 2012-2016 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <clientversion.h>
6#include <util/translation.h>
7
8#include <tinyformat.h>
9
10#include <sstream>
11#include <string>
12#include <vector>
13
19const std::string CLIENT_NAME("Bitcoin ABC");
20
21#ifdef HAVE_BUILD_INFO
22#include <obj/build.h>
23// The <obj/build.h>, which is generated by the build environment
24// (share/genbuild.sh), could contain only one line of the following:
25// - "#define BUILD_GIT_TAG ...", if the top commit is tagged
26// - "#define BUILD_GIT_COMMIT ...", if the top commit is not tagged
27// - "// No build information available", if proper git information is not
28// available
29#endif
30
33
34#ifdef BUILD_GIT_TAG
35#define BUILD_DESC BUILD_GIT_TAG
36#define BUILD_SUFFIX ""
37#else
38#define BUILD_DESC \
39 "v" STRINGIZE(CLIENT_VERSION_MAJOR) "." STRINGIZE( \
40 CLIENT_VERSION_MINOR) "." STRINGIZE(CLIENT_VERSION_REVISION)
41#ifdef BUILD_GIT_COMMIT
42#define BUILD_SUFFIX "-" BUILD_GIT_COMMIT
43#elif defined(GIT_COMMIT_ID)
44#define BUILD_SUFFIX "-g" GIT_COMMIT_ID
45#else
46#define BUILD_SUFFIX "-unk"
47#endif
48#endif
49
51
52std::string FormatVersion(int nVersion) {
53 if (nVersion % 100 == 0) {
54 return strprintf("%d.%d.%d", nVersion / 1000000,
55 (nVersion / 10000) % 100, (nVersion / 100) % 100);
56 } else {
57 return strprintf("%d.%d.%d.%d", nVersion / 1000000,
58 (nVersion / 10000) % 100, (nVersion / 100) % 100,
59 nVersion % 100);
60 }
61}
62
63std::string FormatFullVersion() {
64 return CLIENT_BUILD;
65}
66
71std::string FormatUserAgent(const std::string &name, const std::string &version,
72 const std::vector<std::string> &comments) {
73 std::ostringstream ss;
74 ss << "/";
75 ss << name << ":" << version;
76 if (!comments.empty()) {
77 std::vector<std::string>::const_iterator it(comments.begin());
78 ss << "(" << *it;
79 for (++it; it != comments.end(); ++it) {
80 ss << "; " << *it;
81 }
82 ss << ")";
83 }
84 ss << "/";
85 return ss.str();
86}
87
88std::string CopyrightHolders(const std::string &strPrefix) {
89 return strPrefix + strprintf(_(COPYRIGHT_HOLDERS).translated,
90 COPYRIGHT_HOLDERS_SUBSTITUTION);
91}
92
93std::string LicenseInfo() {
94 const std::string URL_SOURCE_CODE =
95 "<https://github.com/Bitcoin-ABC/bitcoin-abc>";
96 const std::string URL_WEBSITE = "<https://www.bitcoinabc.org>";
97
98 return CopyrightHolders(strprintf(_("Copyright (C) %i-%i").translated, 2009,
99 COPYRIGHT_YEAR) +
100 " ") +
101 "\n" + "\n" +
102 strprintf(_("Please contribute if you find %s useful. "
103 "Visit %s for further information about the software.")
104 .translated,
105 PACKAGE_NAME, URL_WEBSITE) +
106 "\n" +
107 strprintf(_("The source code is available from %s.").translated,
108 URL_SOURCE_CODE) +
109 "\n" + "\n" + _("This is experimental software.").translated + "\n" +
110 strprintf(_("Distributed under the MIT software license, see the "
111 "accompanying file %s or %s")
112 .translated,
113 "COPYING", "<https://opensource.org/licenses/MIT>") +
114 "\n" + "\n" +
115 strprintf(_("This product includes software developed by the "
116 "OpenSSL Project for use in the OpenSSL Toolkit %s and "
117 "cryptographic software written by Eric Young and UPnP "
118 "software written by Thomas Bernard.")
119 .translated,
120 "<https://www.openssl.org>") +
121 "\n";
122}
std::string CopyrightHolders(const std::string &strPrefix)
const std::string CLIENT_NAME("Bitcoin ABC")
Name of client reported in the 'version' message.
#define BUILD_SUFFIX
#define BUILD_DESC
git will put "#define GIT_COMMIT_ID ..." on the next line inside archives.
std::string FormatVersion(int nVersion)
std::string FormatFullVersion()
std::string LicenseInfo()
Returns licensing information (for -version)
const std::string CLIENT_BUILD(BUILD_DESC BUILD_SUFFIX)
std::string FormatUserAgent(const std::string &name, const std::string &version, const std::vector< std::string > &comments)
Format the subversion field according to BIP 14 spec.
const char * name
Definition: rest.cpp:47
std::string translated
Definition: translation.h:19
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1202
bilingual_str _(const char *psz)
Translation function.
Definition: translation.h:68