Changeset View
Changeset View
Standalone View
Standalone View
src/clientversion.cpp
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | #define BUILD_DESC \ | ||||
BUILD_DESC_FROM_UNKNOWN(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, \ | BUILD_DESC_FROM_UNKNOWN(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, \ | ||||
CLIENT_VERSION_REVISION) | CLIENT_VERSION_REVISION) | ||||
#endif | #endif | ||||
#endif | #endif | ||||
const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX); | const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX); | ||||
static std::string FormatVersion(int nVersion) { | static std::string FormatVersion(int nVersion) { | ||||
if (nVersion % 100 == 0) | if (nVersion % 100 == 0) { | ||||
return strprintf("%d.%d.%d", nVersion / 1000000, | return strprintf("%d.%d.%d", nVersion / 1000000, | ||||
(nVersion / 10000) % 100, (nVersion / 100) % 100); | (nVersion / 10000) % 100, (nVersion / 100) % 100); | ||||
else | } else { | ||||
return strprintf("%d.%d.%d.%d", nVersion / 1000000, | return strprintf("%d.%d.%d.%d", nVersion / 1000000, | ||||
(nVersion / 10000) % 100, (nVersion / 100) % 100, | (nVersion / 10000) % 100, (nVersion / 100) % 100, | ||||
nVersion % 100); | nVersion % 100); | ||||
} | } | ||||
} | |||||
std::string FormatFullVersion() { | std::string FormatFullVersion() { | ||||
return CLIENT_BUILD; | return CLIENT_BUILD; | ||||
} | } | ||||
/** | /** | ||||
* Format the subversion field according to BIP 14 spec | * Format the subversion field according to BIP 14 spec | ||||
* (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) | * (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) | ||||
*/ | */ | ||||
std::string FormatSubVersion(const std::string &name, int nClientVersion, | std::string FormatSubVersion(const std::string &name, int nClientVersion, | ||||
const std::vector<std::string> &comments) { | const std::vector<std::string> &comments) { | ||||
std::ostringstream ss; | std::ostringstream ss; | ||||
ss << "/"; | ss << "/"; | ||||
ss << name << ":" << FormatVersion(nClientVersion); | ss << name << ":" << FormatVersion(nClientVersion); | ||||
if (!comments.empty()) { | if (!comments.empty()) { | ||||
std::vector<std::string>::const_iterator it(comments.begin()); | std::vector<std::string>::const_iterator it(comments.begin()); | ||||
ss << "(" << *it; | ss << "(" << *it; | ||||
for (++it; it != comments.end(); ++it) | for (++it; it != comments.end(); ++it) { | ||||
ss << "; " << *it; | ss << "; " << *it; | ||||
} | |||||
ss << ")"; | ss << ")"; | ||||
} | } | ||||
ss << "/"; | ss << "/"; | ||||
return ss.str(); | return ss.str(); | ||||
} | } |