| | |
| | | #include <algorithm> |
| | | #include <map> |
| | | #include <iostream> |
| | | #include <sstream> |
| | | |
| | | #include "EventRegistry.h" |
| | | #define LIC_ID_NOT_DEFINED "UNDEF" |
| | |
| | | return out; |
| | | } |
| | | |
| | | string EventRegistry::to_string() const { |
| | | std::stringstream ss; |
| | | ss << this; |
| | | return ss.str(); |
| | | } |
| | | |
| | | void EventRegistry::append(const EventRegistry &eventRegistry) { |
| | | logs.insert(logs.end(), eventRegistry.logs.begin(), eventRegistry.logs.end()); |
| | | } |
| | |
| | | void addEvent(LCC_EVENT_TYPE event, const std::string &licenseLocationId); |
| | | void addEvent(LCC_EVENT_TYPE event, const char *licenseLocationId = nullptr, const char *info = nullptr); |
| | | void exportLastEvents(AuditEvent *auditEvents, int nlogs); |
| | | std::string to_string() const; |
| | | }; |
| | | } // namespace license |
| | | #endif /* EVENTREGISTRY_H_ */ |
| | |
| | | } catch (const std::exception& ex) { |
| | | LOG_ERROR("Error calculating hw_identifier: %s", ex.what()); |
| | | #ifndef NDEBUG |
| | | cout << "Error occurred: " << ex.what() << std::endl; |
| | | cerr << "Error occurred in identify_pc: " << ex.what() << std::endl; |
| | | #endif |
| | | } |
| | | } else { |
| | |
| | | } |
| | | } |
| | | #ifndef NDEBUG |
| | | cout << er << endl; |
| | | const string evlog = er.to_string(); |
| | | LOG_DEBUG("License status %s", evlog.c_str()); |
| | | #endif |
| | | |
| | | if (license_out != nullptr) { |
| | |
| | | |
| | | const auto expiry = fullLicInfo.m_limits.find(PARAM_EXPIRY_DATE); |
| | | if (expiry != fullLicInfo.m_limits.end()) { |
| | | strncpy(info.expiry_date, expiry->second.c_str(), sizeof(info.expiry_date)); |
| | | mstrlcpy(info.expiry_date, expiry->second.c_str(), sizeof(info.expiry_date)); |
| | | info.has_expiry = true; |
| | | const double secs = difftime(seconds_from_epoch(expiry->second), time(nullptr)); |
| | | info.days_left = max((int)round(secs / (60 * 60 * 24)), 0); |
| | |
| | | |
| | | const auto proprietary_data = fullLicInfo.m_limits.find(PARAM_EXTRA_DATA); |
| | | if (proprietary_data != fullLicInfo.m_limits.end()) { |
| | | strncpy(info.proprietary_data, proprietary_data->second.c_str(), LCC_API_PROPRIETARY_DATA_SIZE); |
| | | mstrlcpy(info.proprietary_data, proprietary_data->second.c_str(), sizeof(info.proprietary_data)); |
| | | } |
| | | return info; |
| | | } |
| | |
| | | #include <iphlpapi.h> |
| | | #include <stdio.h> |
| | | |
| | | #include "../../base/string_utils.h" |
| | | #include "../../base/logger.h" |
| | | #include "../os.h" |
| | | using namespace std; |
| | |
| | | DWORD fileMaxLen; |
| | | size_t ndrives = 0, drives_scanned = 0; |
| | | DWORD fileFlags; |
| | | char volName[MAX_PATH], fileSysName[MAX_PATH]; |
| | | char volName[MAX_PATH]; |
| | | DWORD volSerial = 0; |
| | | const DWORD dwSize = MAX_PATH; |
| | | char szLogicalDrives[MAX_PATH] = {0}; |
| | |
| | | // get the next drive |
| | | UINT driveType = GetDriveType(szSingleDrive); |
| | | if (driveType == DRIVE_FIXED) { |
| | | char fileSysName[MAX_PATH]; |
| | | BOOL success = GetVolumeInformation(szSingleDrive, volName, MAX_PATH, &volSerial, &fileMaxLen, |
| | | &fileFlags, fileSysName, MAX_PATH); |
| | | if (success) { |
| | |
| | | DiskInfo diskInfo = {}; |
| | | diskInfo.id = (int)ndrives; |
| | | diskInfo.label_initialized = true; |
| | | strncpy(diskInfo.device, volName, min(std::size_t{MAX_PATH}, sizeof(volName)) - 1); |
| | | strncpy(diskInfo.label, fileSysName, |
| | | min(sizeof(diskInfos[ndrives].label), sizeof(fileSysName)) - 1); |
| | | mstrlcpy(diskInfo.device, volName, min(std::size_t{MAX_PATH}, sizeof(volName))); |
| | | mstrlcpy(diskInfo.label, fileSysName, min(sizeof(diskInfos[ndrives].label), sizeof(fileSysName))); |
| | | memcpy(diskInfo.disk_sn, &volSerial, sizeof(DWORD)); |
| | | diskInfo.sn_initialized = true; |
| | | diskInfo.preferred = (szSingleDrive[0] == 'C'); |