#ifndef _WIN32
#include "OnixsUtils.h"
#include "lib/config/config.h"
#include "lib/config/protos/market_data.pb.h"
#include "lib/logging/logging.h"
namespace bts {
namespace md {
// The onixs checksum includes the line endings as \r\n
// to avoid the possibility of git mangling the line endings we store
// an array of lines instead of a single string and restore the lines
// when we write it out in MDP3main.cpp
const char *onixs_license[] = {
"",
" production",
" ",
" Blue Trading Systems OF 9420-2",
" ",
" ",
" 2020-05-01",
" 2021-05-12",
" ",
" ",
" ",
" ",
" ",
" ",
" 1C9210495AA3C9C884B7A37A4C7AD8F9",
""};
OnixsTemplLicense onixs_create_temporary_license() {
const auto &options = config::get();
OnixsTemplLicense linfo;
linfo.path = options.onixs_license();
if (linfo.path == "{default}") {
linfo.path = boost::filesystem::path{os::bts_data_path()} / "licenses";
auto ident = boost::filesystem::unique_path("%%%%-%%%%-%%%%-%%%%.lic");
linfo.license = {linfo.path / ident};
}
if (linfo.license) {
boost::system::error_code ignore;
boost::filesystem::create_directories(linfo.path, ignore);
auto temp = linfo.license.value();
std::ofstream out(temp.c_str(), std::ios::out | std::ios::binary);
if (out.good()) {
for (const char *line : onixs_license) {
if (line != onixs_license[0])
out << "\r\n";
out << line;
}
} else {
LOG(md, Warn,
"Licensing error. Failed to write to '{}'. Please ensure it is "
"writeable.",
linfo.path);
}
}
return linfo;
}
void onixs_destroy_temporary_license(const OnixsTemplLicense &lic) {
if (lic.license) {
boost::system::error_code ignore;
boost::filesystem::remove(lic.license.value(), ignore);
}
}
} // namespace md
} // namespace bts
#endif