Anoncoin  0.9.4
P2P Digital Currency
clientversion.cpp
Go to the documentation of this file.
1 // Copyright (c) 2012-2014 The Bitcoin developers
2 // Copyright (c) 2013-2014 The Anoncoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #include "clientversion.h"
7 
8 #include "tinyformat.h"
9 
10 #include <string>
11 
17 const std::string CLIENT_NAME("Anonymous");
18 
22 #define CLIENT_VERSION_SUFFIX ""
23 
24 
41 #ifdef HAVE_BUILD_INFO
43 #include "build.h"
44 #endif
45 
47 #ifdef GIT_ARCHIVE
48 #define GIT_COMMIT_ID "$Format:%h$"
49 #define GIT_COMMIT_DATE "$Format:%cD$"
50 #endif
51 
52 #define BUILD_DESC_WITH_SUFFIX(maj, min, rev, build, suffix) \
53  "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-" DO_STRINGIZE(suffix)
54 
55 #define BUILD_DESC_FROM_COMMIT(maj, min, rev, build, commit) \
56  "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-g" commit
57 
58 #define BUILD_DESC_FROM_UNKNOWN(maj, min, rev, build) \
59  "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-unk"
60 
61 #ifndef BUILD_DESC
62 #ifdef BUILD_SUFFIX
63 #define BUILD_DESC BUILD_DESC_WITH_SUFFIX(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, BUILD_SUFFIX)
64 #elif defined(GIT_COMMIT_ID)
65 #define BUILD_DESC BUILD_DESC_FROM_COMMIT(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, GIT_COMMIT_ID)
66 #else
67 #define BUILD_DESC BUILD_DESC_FROM_UNKNOWN(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD)
68 #endif
69 #endif
70 
71 #ifndef BUILD_DATE
72 #ifdef GIT_COMMIT_DATE
73 #define BUILD_DATE GIT_COMMIT_DATE
74 #else
75 #define BUILD_DATE __DATE__ ", " __TIME__
76 #endif
77 #endif
78 
80 const std::string CLIENT_DATE(BUILD_DATE);
81 
82 static std::string FormatVersion(int nVersion)
83 {
84  if (nVersion % 100 == 0)
85  return strprintf("%d.%d.%d", nVersion / 1000000, (nVersion / 10000) % 100, (nVersion / 100) % 100);
86  else
87  return strprintf("%d.%d.%d.%d", nVersion / 1000000, (nVersion / 10000) % 100, (nVersion / 100) % 100, nVersion % 100);
88 }
89 
90 std::string FormatFullVersion()
91 {
92  return CLIENT_BUILD;
93 }
94 
98 std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments)
99 {
100  std::ostringstream ss;
101  ss << "/";
102  ss << name << ":" << FormatVersion(nClientVersion);
103  if (!comments.empty())
104  {
105  std::vector<std::string>::const_iterator it(comments.begin());
106  ss << "(" << *it;
107  for(++it; it != comments.end(); ++it)
108  ss << "; " << *it;
109  ss << ")";
110  }
111  ss << "/";
112  return ss.str();
113 }
const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX)
#define strprintf
Definition: tinyformat.h:1011
const std::string CLIENT_NAME("Anonymous")
Name of client reported in the 'version' message.
#define CLIENT_VERSION_SUFFIX
Client version number.
#define BUILD_DATE
std::string FormatFullVersion()
#define BUILD_DESC
const std::string CLIENT_DATE(BUILD_DATE)
std::string FormatSubVersion(const std::string &name, int nClientVersion, const std::vector< std::string > &comments)
Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip...