Files
spark/src/lib/md/vendor/OnixsUtils.cpp
T
John Colvin dfc5fcc16a fix build (client): Change 'WIN32' macros to '_WIN32'
Not sure exactly how this broke, but the WIN32 macro is no longer defined.
2022-11-20 14:22:42 -05:00

74 lines
2.4 KiB
C++

#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[] = {
"<license version=\"1.0\">",
" <type>production</type>",
" <customer>",
" <name>Blue Trading Systems OF 9420-2</name>",
" </customer>",
" <period>",
" <since>2020-05-01</since>",
" <till>2021-05-12</till>",
" </period>",
" <products>",
" <product id=\"4\" name=\"CME Market Data Handler for C++\" />",
" <product id=\"7\" name=\"ICE iMpact Multicast Price Feed Handler for "
"C++\" />",
" <product id=\"67\" name=\"Eurex Market and Reference Data Interfaces "
"(EMDI, RDI) Handler for C++\" />",
" </products>",
" <checksum>1C9210495AA3C9C884B7A37A4C7AD8F9</checksum>",
"</license>"};
OnixsTemplLicense onixs_create_temporary_license() {
const auto &options = config::get<OnixsOptions>();
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