0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-10 22:18:54 +02:00

ircd::info: Do autogeneration of missing version string in ctor.

This commit is contained in:
Jason Volk 2019-06-02 14:21:40 -07:00
parent f2e84a6b0e
commit 364e98d564
3 changed files with 27 additions and 25 deletions

View file

@ -98,22 +98,13 @@ ircd::db::version_api
"RocksDB", info::versions::API, 0,
{
ROCKSDB_MAJOR, ROCKSDB_MINOR, ROCKSDB_PATCH,
},
// version string generator
[](auto &version, const auto &buf)
{
::snprintf(data(buf), size(buf), "%ld.%ld.%ld",
version[0],
version[1],
version[2]);
}
};
decltype(ircd::db::version_abi)
ircd::db::version_abi
{
"RocksDB", info::versions::ABI, 0, {0}, "<unknown>" //TODO: get this
"RocksDB", info::versions::ABI //TODO: get this
};
//

View file

@ -169,12 +169,15 @@ ircd::info::versions::versions(const string_view &name,
const long &monotonic,
const std::array<long, 3> &semantic,
const string_view &string)
:name{name}
,type{type}
,monotonic{monotonic}
,semantic{semantic}
:versions
{
name, type, monotonic, semantic, [&string]
(auto &that, const mutable_buffer &buf)
{
strlcpy(buf, string);
}
}
{
strlcpy(this->string, string);
}
/// Construction of versions members with closure for custom string generation.
@ -190,6 +193,23 @@ ircd::info::versions::versions(const string_view &name,
,semantic{semantic}
{
closure(*this, this->string);
// User provided a string already; nothing else to do
if(strnlen(this->string, sizeof(this->string)) != 0)
return;
// Generate a string from the semantic version number or if all zeroes
// from the monotonic version number instead.
if(monotonic && !semantic[0] && !semantic[1] && !semantic[2])
::snprintf(this->string, sizeof(this->string), "%ld",
monotonic);
else if(!monotonic)
::snprintf(this->string, sizeof(this->string), "%ld.%ld.%ld",
semantic[0],
semantic[1],
semantic[2]);
else
::snprintf(this->string, sizeof(this->string), "<unknown>");
}
//

View file

@ -32,22 +32,13 @@ ircd::boost_version_api
BOOST_VERSION / 100000,
BOOST_VERSION / 100 % 1000,
BOOST_VERSION % 100,
},
// Version string generator since boost doesn't provide any strings.
[](auto &version, const auto &buf)
{
::snprintf(data(buf), size(buf), "%ld.%ld.%ld",
version[0],
version[1],
version[2]);
}
};
decltype(ircd::boost_version_abi)
ircd::boost_version_abi
{
"boost", info::versions::ABI, 0, {0}, "<unknown>" //TODO: get this
"boost", info::versions::ABI //TODO: get this
};
//