engine handles are replaced with context handles.
Change-Id: I8a088ecf1427b69d9f6cee3f5c88a79c6cd49648
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
});
}
-int CsLoader::getEngineInfo(csre_cs_engine_h &e)
+int CsLoader::getEngineApiVersion(csre_cs_context_h c, std::string &value)
{
- return this->m_pc.fpGetEngineInfo(&e);
-}
-
-int CsLoader::destroyEngine(csre_cs_engine_h e)
-{
- return this->m_pc.fpDestroyEngine(e);
-}
-
-int CsLoader::getEngineApiVersion(csre_cs_engine_h e, std::string &value)
-{
- if (e == nullptr)
+ if (c == nullptr)
throw std::invalid_argument("cs loader get error string");
return getValueCstr(value, [&](const char **cvalue) {
- return this->m_pc.fpGetEngineApiVersion(e, cvalue);
+ return this->m_pc.fpGetEngineApiVersion(c, cvalue);
});
}
-int CsLoader::getEngineVendor(csre_cs_engine_h e, std::string &value)
+int CsLoader::getEngineVendor(csre_cs_context_h c, std::string &value)
{
- if (e == nullptr)
+ if (c == nullptr)
throw std::invalid_argument("cs loader get engine vendor");
return getValueCstr(value, [&](const char **cvalue) {
- return this->m_pc.fpGetEngineVendor(e, cvalue);
+ return this->m_pc.fpGetEngineVendor(c, cvalue);
});
}
-int CsLoader::getEngineName(csre_cs_engine_h e, std::string &value)
+int CsLoader::getEngineName(csre_cs_context_h c, std::string &value)
{
- if (e == nullptr)
+ if (c == nullptr)
throw std::invalid_argument("cs loader get engine name");
return getValueCstr(value, [&](const char **cvalue) {
- return this->m_pc.fpGetEngineName(e, cvalue);
+ return this->m_pc.fpGetEngineName(c, cvalue);
});
}
-int CsLoader::getEngineVersion(csre_cs_engine_h e, std::string &value)
+int CsLoader::getEngineVersion(csre_cs_context_h c, std::string &value)
{
- if (e == nullptr)
+ if (c == nullptr)
throw std::invalid_argument("cs loader get engine version");
return getValueCstr(value, [&](const char **cvalue) {
- return this->m_pc.fpGetEngineVersion(e, cvalue);
+ return this->m_pc.fpGetEngineVersion(c, cvalue);
});
}
-int CsLoader::getEngineDataVersion(csre_cs_engine_h e, std::string &value)
+int CsLoader::getEngineDataVersion(csre_cs_context_h c, std::string &value)
{
- if (e == nullptr)
+ if (c == nullptr)
throw std::invalid_argument("cs loader get engine version");
return getValueCstr(value, [&](const char **cvalue) {
- return this->m_pc.fpGetEngineDataVersion(e, cvalue);
+ return this->m_pc.fpGetEngineDataVersion(c, cvalue);
});
}
-int CsLoader::getEngineLatestUpdateTime(csre_cs_engine_h e, time_t *ptime)
+int CsLoader::getEngineLatestUpdateTime(csre_cs_context_h c, time_t *ptime)
{
- if (e == nullptr || ptime == nullptr)
+ if (c == nullptr || ptime == nullptr)
throw std::invalid_argument("cs loader get latest update time");
- return this->m_pc.fpGetEngineLatestUpdateTime(e, ptime);
+ return this->m_pc.fpGetEngineLatestUpdateTime(c, ptime);
}
-int CsLoader::getEngineActivated(csre_cs_engine_h e,
+int CsLoader::getEngineActivated(csre_cs_context_h c,
csre_cs_activated_e *pactivated)
{
- if (e == nullptr || pactivated == nullptr)
+ if (c == nullptr || pactivated == nullptr)
throw std::invalid_argument("cs loader get engine activated");
- return this->m_pc.fpGetEngineActivated(e, pactivated);
+ return this->m_pc.fpGetEngineActivated(c, pactivated);
}
-int CsLoader::getEngineVendorLogo(csre_cs_engine_h e,
+int CsLoader::getEngineVendorLogo(csre_cs_context_h c,
std::vector<unsigned char> &value)
{
- if (e == nullptr)
+ if (c == nullptr)
throw std::invalid_argument("cs loader get engine vendor logo");
unsigned char *cvalue = nullptr;
unsigned int size = 0;
- auto retval = this->m_pc.fpGetEngineVendorLogo(e, &cvalue, &size);
+ auto retval = this->m_pc.fpGetEngineVendorLogo(c, &cvalue, &size);
if (retval == CSRE_ERROR_NONE && cvalue != nullptr && size != 0)
value.assign(cvalue, cvalue + size);
"csre_cs_detected_get_detailed_url"));
this->m_pc.fpGetErrorString = reinterpret_cast <FpGetErrorString>(dlsym(handle,
"csre_cs_get_error_string"));
- this->m_pc.fpGetEngineInfo = reinterpret_cast<FpGetEngineInfo>(dlsym(handle,
- "csre_cs_engine_get_info"));
- this->m_pc.fpDestroyEngine = reinterpret_cast<FpDestroyEngine>(dlsym(handle,
- "csre_cs_engine_destroy"));
this->m_pc.fpGetEngineApiVersion = reinterpret_cast<FpGetEngineApiVersion>(dlsym(
handle, "csre_cs_engine_get_api_version"));
this->m_pc.fpGetEngineVendor = reinterpret_cast<FpGetEngineVendor>(dlsym(handle,
this->m_pc.fpGetMalwareName == nullptr ||
this->m_pc.fpGetDetailedUrl == nullptr ||
this->m_pc.fpGetErrorString == nullptr ||
- this->m_pc.fpGetEngineInfo == nullptr ||
this->m_pc.fpGetEngineApiVersion == nullptr ||
this->m_pc.fpGetEngineVendor == nullptr ||
this->m_pc.fpGetEngineName == nullptr ||
return this->m_context;
}
-
-CsEngineInfo::CsEngineInfo(const std::shared_ptr<CsLoader> &loader) :
- m_loader(loader), m_info(nullptr)
-{
- if (!this->m_loader)
- ThrowExc(EngineNotExist, "null loader means engine not exist!");
-
- toException(this->m_loader->getEngineInfo(this->m_info));
-}
-
-CsEngineInfo::~CsEngineInfo()
-{
- toException(this->m_loader->destroyEngine(this->m_info));
-}
-
-csre_cs_engine_h &CsEngineInfo::get(void)
-{
- return this->m_info;
-}
-
}
int getErrorString(int, std::string &);
- int getEngineInfo(csre_cs_engine_h &);
- int destroyEngine(csre_cs_engine_h);
- int getEngineApiVersion(csre_cs_engine_h, std::string &);
- int getEngineVendor(csre_cs_engine_h, std::string &);
- int getEngineName(csre_cs_engine_h, std::string &);
- int getEngineVersion(csre_cs_engine_h, std::string &);
- int getEngineDataVersion(csre_cs_engine_h, std::string &);
- int getEngineLatestUpdateTime(csre_cs_engine_h, time_t *);
- int getEngineActivated(csre_cs_engine_h, csre_cs_activated_e *);
- int getEngineVendorLogo(csre_cs_engine_h, std::vector<unsigned char> &);
+ int getEngineApiVersion(csre_cs_context_h, std::string &);
+ int getEngineVendor(csre_cs_context_h, std::string &);
+ int getEngineName(csre_cs_context_h, std::string &);
+ int getEngineVersion(csre_cs_context_h, std::string &);
+ int getEngineDataVersion(csre_cs_context_h, std::string &);
+ int getEngineLatestUpdateTime(csre_cs_context_h, time_t *);
+ int getEngineActivated(csre_cs_context_h, csre_cs_activated_e *);
+ int getEngineVendorLogo(csre_cs_context_h, std::vector<unsigned char> &);
private:
using FpGlobalInit = int(*)(const char *, const char *);
using FpGetMalwareName = int(*)(csre_cs_detected_h, const char **);
using FpGetDetailedUrl = int(*)(csre_cs_detected_h, const char **);
using FpGetErrorString = int(*)(int, const char **);
- using FpGetEngineInfo = int(*)(csre_cs_engine_h *);
- using FpDestroyEngine = int(*)(csre_cs_engine_h);
- using FpGetEngineApiVersion = int(*)(csre_cs_engine_h, const char **);
- using FpGetEngineVendor = int(*)(csre_cs_engine_h, const char **);
- using FpGetEngineName = int(*)(csre_cs_engine_h, const char **);
- using FpGetEngineVersion = int(*)(csre_cs_engine_h, const char **);
- using FpGetEngineDataVersion = int(*)(csre_cs_engine_h, const char **);
- using FpGetEngineLatestUpdateTime = int(*)(csre_cs_engine_h, time_t *);
- using FpGetEngineActivated = int(*)(csre_cs_engine_h, csre_cs_activated_e *);
- using FpGetEngineVendorLogo = int(*)(csre_cs_engine_h, unsigned char **,
+ using FpGetEngineApiVersion = int(*)(csre_cs_context_h, const char **);
+ using FpGetEngineVendor = int(*)(csre_cs_context_h, const char **);
+ using FpGetEngineName = int(*)(csre_cs_context_h, const char **);
+ using FpGetEngineVersion = int(*)(csre_cs_context_h, const char **);
+ using FpGetEngineDataVersion = int(*)(csre_cs_context_h, const char **);
+ using FpGetEngineLatestUpdateTime = int(*)(csre_cs_context_h, time_t *);
+ using FpGetEngineActivated = int(*)(csre_cs_context_h, csre_cs_activated_e *);
+ using FpGetEngineVendorLogo = int(*)(csre_cs_context_h, unsigned char **,
unsigned int *);
struct PluginContext {
FpGetMalwareName fpGetMalwareName;
FpGetDetailedUrl fpGetDetailedUrl;
FpGetErrorString fpGetErrorString;
- FpGetEngineInfo fpGetEngineInfo;
- FpDestroyEngine fpDestroyEngine;
FpGetEngineApiVersion fpGetEngineApiVersion;
FpGetEngineVendor fpGetEngineVendor;
FpGetEngineName fpGetEngineName;
csre_cs_context_h m_context;
};
-class CsEngineInfo {
-public:
- CsEngineInfo(const std::shared_ptr<CsLoader> &);
- ~CsEngineInfo();
- csre_cs_engine_h &get(void);
-
-private:
- std::shared_ptr<CsLoader> m_loader;
- csre_cs_engine_h m_info;
-};
-
}
ThrowExc(DbFailed, "Failed to init db");
if (this->m_loader) {
- CsEngineInfo csEngineInfo(this->m_loader);
- toException(this->m_loader->getEngineDataVersion(csEngineInfo.get(),
+ CsEngineContext csEngineContext(this->m_loader);
+ toException(this->m_loader->getEngineDataVersion(csEngineContext.get(),
this->m_dataVersion));
}
}
EXCEPTION_GUARD_START
if (context.engineId == CSR_ENGINE_CS) {
- CsEngineInfo engineInfo(this->m_cs);
- auto &c = engineInfo.get();
+ CsEngineContext engineContext(this->m_cs);
+ auto &c = engineContext.get();
std::string value;
toException(this->m_cs->getEngineName(c, value));
return BinaryQueue::Serialize(CSR_ERROR_NONE, value).pop();
} else {
- WpEngineInfo engineInfo(this->m_wp);
- auto &c = engineInfo.get();
+ WpEngineContext engineContext(this->m_wp);
+ auto &c = engineContext.get();
std::string value;
toException(this->m_wp->getEngineName(c, value));
EXCEPTION_GUARD_START
if (context.engineId == CSR_ENGINE_CS) {
- CsEngineInfo engineInfo(this->m_cs);
- auto &c = engineInfo.get();
+ CsEngineContext engineContext(this->m_cs);
+ auto &c = engineContext.get();
std::string value;
toException(this->m_cs->getEngineVendor(c, value));
return BinaryQueue::Serialize(CSR_ERROR_NONE, value).pop();
} else {
- WpEngineInfo engineInfo(this->m_wp);
- auto &c = engineInfo.get();
+ WpEngineContext engineContext(this->m_wp);
+ auto &c = engineContext.get();
std::string value;
toException(this->m_wp->getEngineVendor(c, value));
EXCEPTION_GUARD_START
if (context.engineId == CSR_ENGINE_CS) {
- CsEngineInfo engineInfo(this->m_cs);
- auto &c = engineInfo.get();
+ CsEngineContext engineContext(this->m_cs);
+ auto &c = engineContext.get();
std::string value;
toException(this->m_cs->getEngineVersion(c, value));
return BinaryQueue::Serialize(CSR_ERROR_NONE, value).pop();
} else {
- WpEngineInfo engineInfo(this->m_wp);
- auto &c = engineInfo.get();
+ WpEngineContext engineContext(this->m_wp);
+ auto &c = engineContext.get();
std::string value;
toException(this->m_wp->getEngineVersion(c, value));
EXCEPTION_GUARD_START
if (context.engineId == CSR_ENGINE_CS) {
- CsEngineInfo engineInfo(this->m_cs);
- auto &c = engineInfo.get();
+ CsEngineContext engineContext(this->m_cs);
+ auto &c = engineContext.get();
std::string value;
toException(this->m_cs->getEngineDataVersion(c, value));
return BinaryQueue::Serialize(CSR_ERROR_NONE, value).pop();
} else {
- WpEngineInfo engineInfo(this->m_wp);
- auto &c = engineInfo.get();
+ WpEngineContext engineContext(this->m_wp);
+ auto &c = engineContext.get();
std::string value;
toException(this->m_wp->getEngineDataVersion(c, value));
EXCEPTION_GUARD_START
if (context.engineId == CSR_ENGINE_CS) {
- CsEngineInfo engineInfo(this->m_cs);
- auto &c = engineInfo.get();
+ CsEngineContext engineContext(this->m_cs);
+ auto &c = engineContext.get();
time_t value;
toException(this->m_cs->getEngineLatestUpdateTime(c, &value));
return BinaryQueue::Serialize(CSR_ERROR_NONE, ts64).pop();
} else {
- WpEngineInfo engineInfo(this->m_wp);
- auto &c = engineInfo.get();
+ WpEngineContext engineContext(this->m_wp);
+ auto &c = engineContext.get();
time_t value;
toException(this->m_wp->getEngineLatestUpdateTime(c, &value));
csr_activated_e activated = CSR_NOT_ACTIVATED;
if (context.engineId == CSR_ENGINE_CS) {
- CsEngineInfo engineInfo(this->m_cs);
- auto &c = engineInfo.get();
+ CsEngineContext engineContext(this->m_cs);
+ auto &c = engineContext.get();
csre_cs_activated_e value;
toException(this->m_cs->getEngineActivated(c, &value));
ThrowExc(EngineError, "Invalid returned activated val: " <<
static_cast<int>(value));
} else {
- WpEngineInfo engineInfo(this->m_wp);
- auto &c = engineInfo.get();
+ WpEngineContext engineContext(this->m_wp);
+ auto &c = engineContext.get();
csre_wp_activated_e value;
toException(this->m_wp->getEngineActivated(c, &value));
});
}
-
-int WpLoader::getEngineInfo(csre_wp_engine_h &e)
-{
- return this->m_pc.fpGetEngineInfo(&e);
-}
-
-int WpLoader::destroyEngine(csre_wp_engine_h e)
-{
- return this->m_pc.fpDestroyEngine(e);
-}
-
-int WpLoader::getEngineApiVersion(csre_wp_engine_h e, std::string &value)
+int WpLoader::getEngineApiVersion(csre_wp_context_h c, std::string &value)
{
- if (e == nullptr)
+ if (c == nullptr)
throw std::invalid_argument("wp loader get error string");
return getValueCstr(value, [&](const char **cvalue) {
- return this->m_pc.fpGetEngineApiVersion(e, cvalue);
+ return this->m_pc.fpGetEngineApiVersion(c, cvalue);
});
}
-int WpLoader::getEngineVendor(csre_wp_engine_h e, std::string &value)
+int WpLoader::getEngineVendor(csre_wp_context_h c, std::string &value)
{
- if (e == nullptr)
+ if (c == nullptr)
throw std::invalid_argument("wp loader get engine vendor");
return getValueCstr(value, [&](const char **cvalue) {
- return this->m_pc.fpGetEngineVendor(e, cvalue);
+ return this->m_pc.fpGetEngineVendor(c, cvalue);
});
}
-int WpLoader::getEngineName(csre_wp_engine_h e, std::string &value)
+int WpLoader::getEngineName(csre_wp_context_h c, std::string &value)
{
- if (e == nullptr)
+ if (c == nullptr)
throw std::invalid_argument("wp loader get engine name");
return getValueCstr(value, [&](const char **cvalue) {
- return this->m_pc.fpGetEngineName(e, cvalue);
+ return this->m_pc.fpGetEngineName(c, cvalue);
});
}
-int WpLoader::getEngineVersion(csre_wp_engine_h e, std::string &value)
+int WpLoader::getEngineVersion(csre_wp_context_h c, std::string &value)
{
- if (e == nullptr)
+ if (c == nullptr)
throw std::invalid_argument("wp loader get engine version");
return getValueCstr(value, [&](const char **cvalue) {
- return this->m_pc.fpGetEngineVersion(e, cvalue);
+ return this->m_pc.fpGetEngineVersion(c, cvalue);
});
}
-int WpLoader::getEngineDataVersion(csre_wp_engine_h e, std::string &value)
+int WpLoader::getEngineDataVersion(csre_wp_context_h c, std::string &value)
{
- if (e == nullptr)
+ if (c == nullptr)
throw std::invalid_argument("wp loader get engine version");
return getValueCstr(value, [&](const char **cvalue) {
- return this->m_pc.fpGetEngineDataVersion(e, cvalue);
+ return this->m_pc.fpGetEngineDataVersion(c, cvalue);
});
}
-int WpLoader::getEngineLatestUpdateTime(csre_wp_engine_h e, time_t *ptime)
+int WpLoader::getEngineLatestUpdateTime(csre_wp_context_h c, time_t *ptime)
{
- if (e == nullptr || ptime == nullptr)
+ if (c == nullptr || ptime == nullptr)
throw std::invalid_argument("wp loader get latest update time");
- return this->m_pc.fpGetEngineLatestUpdateTime(e, ptime);
+ return this->m_pc.fpGetEngineLatestUpdateTime(c, ptime);
}
-int WpLoader::getEngineActivated(csre_wp_engine_h e,
+int WpLoader::getEngineActivated(csre_wp_context_h c,
csre_wp_activated_e *pactivated)
{
- if (e == nullptr || pactivated == nullptr)
+ if (c == nullptr || pactivated == nullptr)
throw std::invalid_argument("wp loader get engine activated");
- return this->m_pc.fpGetEngineActivated(e, pactivated);
+ return this->m_pc.fpGetEngineActivated(c, pactivated);
}
-int WpLoader::getEngineVendorLogo(csre_wp_engine_h e,
+int WpLoader::getEngineVendorLogo(csre_wp_context_h c,
std::vector<unsigned char> &value)
{
- if (e == nullptr)
+ if (c == nullptr)
throw std::invalid_argument("wp loader get engine vendor logo");
unsigned char *cvalue = nullptr;
unsigned int size = 0;
- auto retval = this->m_pc.fpGetEngineVendorLogo(e, &cvalue, &size);
+ auto retval = this->m_pc.fpGetEngineVendorLogo(c, &cvalue, &size);
if (retval == CSRE_ERROR_NONE && cvalue != nullptr && size != 0)
value.assign(cvalue, cvalue + size);
"csre_wp_result_get_detailed_url"));
this->m_pc.fpGetErrorString = reinterpret_cast <FpGetErrorString>(dlsym(handle,
"csre_wp_get_error_string"));
- this->m_pc.fpGetEngineInfo = reinterpret_cast<FpGetEngineInfo>(dlsym(handle,
- "csre_wp_engine_get_info"));
- this->m_pc.fpDestroyEngine = reinterpret_cast<FpDestroyEngine>(dlsym(handle,
- "csre_wp_engine_destroy"));
this->m_pc.fpGetEngineApiVersion = reinterpret_cast<FpGetEngineApiVersion>(dlsym(
handle, "csre_wp_engine_get_api_version"));
this->m_pc.fpGetEngineVendor = reinterpret_cast<FpGetEngineVendor>(dlsym(handle,
this->m_pc.fpCheckUrl == nullptr || this->m_pc.fpGetRiskLevel == nullptr ||
this->m_pc.fpGetDetailedUrl == nullptr ||
this->m_pc.fpGetErrorString == nullptr ||
- this->m_pc.fpGetEngineInfo == nullptr ||
- this->m_pc.fpDestroyEngine == nullptr ||
this->m_pc.fpGetEngineApiVersion == nullptr ||
this->m_pc.fpGetEngineVendor == nullptr ||
this->m_pc.fpGetEngineName == nullptr ||
return this->m_context;
}
-
-WpEngineInfo::WpEngineInfo(const std::shared_ptr<WpLoader> &loader) :
- m_loader(loader), m_info(nullptr)
-{
- if (!this->m_loader)
- ThrowExc(EngineNotExist, "null loader means engine not exist!");
-
- toException(this->m_loader->getEngineInfo(this->m_info));
-}
-
-WpEngineInfo::~WpEngineInfo()
-{
- toException(this->m_loader->destroyEngine(this->m_info));
-}
-
-csre_wp_engine_h &WpEngineInfo::get(void)
-{
- return this->m_info;
-}
-
}
int getRiskLevel(csre_wp_check_result_h, csre_wp_risk_level_e *);
int getDetailedUrl(csre_wp_check_result_h, std::string &);
int getErrorString(int, std::string &);
- int getEngineInfo(csre_wp_engine_h &);
- int destroyEngine(csre_wp_engine_h);
- int getEngineApiVersion(csre_wp_engine_h, std::string &);
- int getEngineVendor(csre_wp_engine_h, std::string &);
- int getEngineName(csre_wp_engine_h, std::string &);
- int getEngineVersion(csre_wp_engine_h, std::string &);
- int getEngineDataVersion(csre_wp_engine_h, std::string &);
- int getEngineLatestUpdateTime(csre_wp_engine_h, time_t *);
- int getEngineActivated(csre_wp_engine_h, csre_wp_activated_e *);
- int getEngineVendorLogo(csre_wp_engine_h, std::vector<unsigned char> &);
+ int getEngineApiVersion(csre_wp_context_h, std::string &);
+ int getEngineVendor(csre_wp_context_h, std::string &);
+ int getEngineName(csre_wp_context_h, std::string &);
+ int getEngineVersion(csre_wp_context_h, std::string &);
+ int getEngineDataVersion(csre_wp_context_h, std::string &);
+ int getEngineLatestUpdateTime(csre_wp_context_h, time_t *);
+ int getEngineActivated(csre_wp_context_h, csre_wp_activated_e *);
+ int getEngineVendorLogo(csre_wp_context_h, std::vector<unsigned char> &);
private:
using FpGlobalInit = int(*)(const char *, const char *);
using FpGetRiskLevel = int(*)(csre_wp_check_result_h, csre_wp_risk_level_e *);
using FPGetDetailedUrl = int(*)(csre_wp_check_result_h, const char **);
using FpGetErrorString = int(*)(int, const char **);
- using FpGetEngineInfo = int(*)(csre_wp_engine_h *);
- using FpDestroyEngine = int(*)(csre_wp_engine_h);
- using FpGetEngineApiVersion = int(*)(csre_wp_engine_h, const char **);
- using FpGetEngineVendor = int(*)(csre_wp_engine_h, const char **);
- using FpGetEngineName = int(*)(csre_wp_engine_h, const char **);
- using FpGetEngineVersion = int(*)(csre_wp_engine_h, const char **);
- using FpGetEngineDataVersion = int(*)(csre_wp_engine_h, const char **);
- using FpGetEngineLatestUpdateTime = int(*)(csre_wp_engine_h, time_t *);
- using FpGetEngineActivated = int(*)(csre_wp_engine_h, csre_wp_activated_e *);
- using FpGetEngineVendorLogo = int(*)(csre_wp_engine_h, unsigned char **,
+ using FpGetEngineApiVersion = int(*)(csre_wp_context_h, const char **);
+ using FpGetEngineVendor = int(*)(csre_wp_context_h, const char **);
+ using FpGetEngineName = int(*)(csre_wp_context_h, const char **);
+ using FpGetEngineVersion = int(*)(csre_wp_context_h, const char **);
+ using FpGetEngineDataVersion = int(*)(csre_wp_context_h, const char **);
+ using FpGetEngineLatestUpdateTime = int(*)(csre_wp_context_h, time_t *);
+ using FpGetEngineActivated = int(*)(csre_wp_context_h, csre_wp_activated_e *);
+ using FpGetEngineVendorLogo = int(*)(csre_wp_context_h, unsigned char **,
unsigned int *);
struct PluginContext {
FpGetRiskLevel fpGetRiskLevel;
FPGetDetailedUrl fpGetDetailedUrl;
FpGetErrorString fpGetErrorString;
- FpGetEngineInfo fpGetEngineInfo;
- FpDestroyEngine fpDestroyEngine;
FpGetEngineApiVersion fpGetEngineApiVersion;
FpGetEngineVendor fpGetEngineVendor;
FpGetEngineName fpGetEngineName;
csre_wp_context_h m_context;
};
-class WpEngineInfo {
-public:
- WpEngineInfo(const std::shared_ptr<WpLoader> &);
- ~WpEngineInfo();
- csre_wp_engine_h &get(void);
-
-private:
- std::shared_ptr<WpLoader> m_loader;
- csre_wp_engine_h m_info;
-};
-
}
ThrowExc(DbFailed, "DB init failed.");
if (this->m_loader) {
- WpEngineInfo wpEngineInfo(this->m_loader);
- toException(this->m_loader->getEngineDataVersion(wpEngineInfo.get(),
+ WpEngineContext wpEngineContext(this->m_loader);
+ toException(this->m_loader->getEngineDataVersion(wpEngineContext.get(),
this->m_dataVersion));
}
}
extern "C" {
#endif
-typedef struct __csre_cs_engine_h *csre_cs_engine_h;
-
/**
* @brief State of engine activation
*/
} csre_cs_activated_e;
/**
- * @brief Gets the handle of a selected engine information.
- *
- * @param[in] id Engine identifier to get handle.
- * @param[out] pengine A pointer of the engine information handle.
- *
- * @return #CSRE_ERROR_NONE on success, otherwise a negative error value
- *
- * @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid handle
- * @retval #CSRE_ERROR_INVALID_PARAMETER pengine is invalid
- * @retval #CSRE_ERROR_ENGINE_NOT_SELECTED No engine selected
- * @retval #CSRE_ERROR_ENGINE_NOT_ACTIVATED Engine is not activated
- * @retval #CSRE_ERROR_ENGINE_INTERNAL Engine Internal error
- * @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
- */
-int csre_cs_engine_get_info(csre_cs_engine_h *engine);
-
-/**
- * @brief Releases all system resources associated with a engine information handle.
- *
- * @param[in] engine The engine information handle.
- *
- * @return #CSRE_ERROR_NONE on success, otherwise a negative error value
- *
- * @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid handle
- * @retval #CSRE_ERROR_SOCKET Socket error between client and server
- * @retval #CSRE_ERROR_SERVER Server has been failed for some reason
- * @retval #CSRE_ERROR_ENGINE_INTERNAL Engine Internal error
- * @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
- */
-int csre_cs_engine_destroy(csre_cs_engine_h engine);
-
-/**
* @brief returns the engine API version.
*
- * @param[in] engine The engine information handle.
+ * @param[in] context CSR CS context handle.
* @param[out] version A pointer of the API version string. A caller should not free it.
*
* @return #CSRE_ERROR_NONE on success, otherwise a negative error value
*
* @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid engine information handle
+ * @retval #CSRE_ERROR_INVALID_HANDLE Invalid context handle
* @retval #CSRE_ERROR_INVALID_PARAMETER api_ver is invalid
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
* @retval -0x0100~-0xFF00 Engine defined error
- *
- * @see csre_cs_get_engine_info()
*/
-int csre_cs_engine_get_api_version(csre_cs_engine_h engine,
- const char **version);
+int csre_cs_engine_get_api_version(csre_cs_context_h context, const char **version);
/**
- * @brief Extracts an vendor name from the engine information handle.
+ * @brief Extracts an vendor name from CSR CS context handle.
*
- * @param[in] engine The engine information handle.
+ * @param[in] context CSR CS context handle.
* @param[out] vendor A pointer of the engine's vendor name. A caller should not free it.
*
* @return #CSRE_ERROR_NONE on success, otherwise a negative error value
*
* @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid engine information handle
- * @retval #CSRE_ERROR_INVALID_PARAMETER engine_vendor is invalid
+ * @retval #CSRE_ERROR_INVALID_HANDLE Invalid context handle
+ * @retval #CSRE_ERROR_INVALID_PARAMETER @a vendor is invalid
* @retval #CSRE_ERROR_ENGINE_INTERNAL Engine Internal error
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
- *
- * @see csre_cs_get_engine_info()
*/
-int csre_cs_engine_get_vendor(csre_cs_engine_h engine, const char **vendor);
+int csre_cs_engine_get_vendor(csre_cs_context_h context, const char **vendor);
/**
- * @brief Extracts an engine name from the engine information handle.
+ * @brief Extracts an engine name from CSR CS context handle.
*
- * @param[in] engine The engine information handle.
+ * @param[in] context CSR CS context handle.
* @param[out] name A pointer of the engine's name. A caller should not free it.
*
* @return #CSRE_ERROR_NONE on success, otherwise a negative error value
*
* @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid engine information handle
- * @retval #CSRE_ERROR_INVALID_PARAMETER engine_name is invalid
+ * @retval #CSRE_ERROR_INVALID_HANDLE Invalid context handle
+ * @retval #CSRE_ERROR_INVALID_PARAMETER @a name is invalid
* @retval #CSRE_ERROR_ENGINE_INTERNAL Engine Internal error
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
- *
- * @see csre_cs_get_engine_info()
*/
-int csre_cs_engine_get_name(csre_cs_engine_h engine, const char **name);
+int csre_cs_engine_get_name(csre_cs_context_h context, const char **name);
/**
- * @brief Extracts an engine version from the engine information handle.
+ * @brief Extracts an engine version from CSR CS context handle.
*
- * @param[in] engine An engine information handle.
+ * @param[in] context CSR CS context handle.
* @param[out] version A pointer of the engine's version. A caller should not free it.
*
* @return #CSRE_ERROR_NONE on success, otherwise a negative error value
*
* @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid engine information handle
- * @retval #CSRE_ERROR_INVALID_PARAMETER engine_version is invalid
+ * @retval #CSRE_ERROR_INVALID_HANDLE Invalid context handle
+ * @retval #CSRE_ERROR_INVALID_PARAMETER @a version is invalid
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
* @retval #CSRE_ERROR_ENGINE_INTERNAL Engine Internal error
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
- *
- * @see csre_cs_get_engine_info()
*/
-int csre_cs_engine_get_version(csre_cs_engine_h engine, const char **version);
+int csre_cs_engine_get_version(csre_cs_context_h context, const char **version);
/**
- * @brief Extracts an engine's data version from the engine information handle.
+ * @brief Extracts an engine's data version from CSR CS context handle.
*
- * @param[in] engine The engine information handle.
+ * @param[in] context CSR CS context handle.
* @param[out] version A pointer of the data version. It can be null. A caller should not free it.
*
* @return #CSRE_ERROR_NONE on success, otherwise a negative error value
*
* @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid engine information handle
- * @retval #CSRE_ERROR_INVALID_PARAMETER engine_version is invalid
+ * @retval #CSRE_ERROR_INVALID_HANDLE Invalid context handle
+ * @retval #CSRE_ERROR_INVALID_PARAMETER @a version is invalid
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
* @retval #CSRE_ERROR_ENGINE_INTERNAL Engine Internal error
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
- *
- * @see csre_cs_get_engine_info()
*/
-int csre_cs_engine_get_data_version(csre_cs_engine_h engine,
- const char **version);
+int csre_cs_engine_get_data_version(csre_cs_context_h context, const char **version);
/**
- * @brief Extracts the latest update time of an engine from the engine information handle.
+ * @brief Extracts the latest update time of an engine from CSR CS context handle.
*
- * @param[in] engine The engine information handle.
+ * @param[in] context CSR CS context handle.
* @param[out] time A pointer of lasted update time.
*
* @return #CSRE_ERROR_NONE on success, otherwise a negative error value
*
* @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid engine information handle
+ * @retval #CSRE_ERROR_INVALID_HANDLE Invalid context handle
* @retval #CSRE_ERROR_INVALID_PARAMETER time is invalid
- * @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
* @retval #CSRE_ERROR_ENGINE_INTERNAL Engine Internal error
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
- *
- * @see csre_cs_get_engine_info()
*/
-int csre_cs_engine_get_latest_update_time(csre_cs_engine_h engine,
- time_t *time);
+int csre_cs_engine_get_latest_update_time(csre_cs_context_h context, time_t *time);
/**
- * @brief Extracts the state of engine activation from the engine information handle.
+ * @brief Extracts the state of engine activation from CSR CS context handle.
*
- * @param[in] engine The engine information handle.
+ * @param[in] context CSR CS context handle.
* @param[out] pactivated A pointer of the engine state.
*
* @return #CSRE_ERROR_NONE on success, otherwise a negative error value
*
* @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid engine information handle
- * @retval #CSRE_ERROR_INVALID_PARAMETER pactivated is invalid
+ * @retval #CSRE_ERROR_INVALID_HANDLE Invalid context handle
+ * @retval #CSRE_ERROR_INVALID_PARAMETER @a pactivated is invalid
* @retval #CSRE_ERROR_ENGINE_INTERNAL Engine Internal error
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
- *
- * @see csre_cs_get_engine_info()
*/
-int csre_cs_engine_get_activated(csre_cs_engine_h engine,
+int csre_cs_engine_get_activated(csre_cs_context_h context,
csre_cs_activated_e *pactivated);
/**
- * @brief Extracts an vendor logo image from the engine information handle.
+ * @brief Extracts an vendor logo image from CSR CS context handle.
*
* @details If log image is provided, the vendor logo is shown in a popup. The format
* of the logo image should be jpeg, gif, bmp or png.
*
- * @param[in] engine The engine information handle.
+ * @param[in] context CSR CS context handle.
* @param[out] vendor_logo_image A pointer of the vendor logo image. A caller should not
* free it.
* @param[out] image_size Size of log image.
* @return #CSRE_ERROR_NONE on success, otherwise a negative error value
*
* @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid engine information handle
- * @retval #CSRE_ERROR_INVALID_PARAMETER vendor_logo_imgage or image_size is invalid
+ * @retval #CSRE_ERROR_INVALID_HANDLE Invalid context handle
+ * @retval #CSRE_ERROR_INVALID_PARAMETER @a vendor_logo_imgage or @a image_size is invalid
* @retval #CSRE_ERROR_NO_DATA No vendor logo image
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
* @retval -0x0100~-0xFF00 Engine defined error
- *
- * @see csre_cs_get_engine_info()
*/
-int csre_cs_engine_get_vendor_logo(csre_cs_engine_h engine,
- unsigned char **vendor_logo_image, unsigned int *image_size);
+int csre_cs_engine_get_vendor_logo(csre_cs_context_h context,
+ unsigned char **vendor_logo_image,
+ unsigned int *image_size);
#ifdef __cplusplus
}
extern "C" {
#endif
-typedef struct csre_wp_engine_s *csre_wp_engine_h;
-
/**
* @brief State of engine activation
*/
} csre_wp_activated_e;
/**
- * @brief Gets the handle of a selected engine information.
- *
- * @param[in] id Engine identifier to get handle.
- * @param[out] pengine A pointer of the engine information handle.
- *
- * @return #CSRE_ERROR_NONE on success, otherwise a negative error value
- *
- * @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid handle
- * @retval #CSRE_ERROR_INVALID_PARAMETER pengine is invalid
- * @retval #CSRE_ERROR_ENGINE_NOT_SELECTED No engine selected
- * @retval #CSRE_ERROR_ENGINE_NOT_ACTIVATED Engine is not activated
- * @retval #CSRE_ERROR_ENGINE_INTERNAL Engine Internal error
- * @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
- */
-int csre_wp_engine_get_info(csre_wp_engine_h *engine);
-
-/**
- * @brief Releases all system resources associated with a engine information handle.
- *
- * @param[in] engine The engine information handle.
- *
- * @return #CSRE_ERROR_NONE on success, otherwise a negative error value
- *
- * @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid handle
- * @retval #CSRE_ERROR_SOCKET Socket error between client and server
- * @retval #CSRE_ERROR_SERVER Server has been failed for some reason
- * @retval #CSRE_ERROR_ENGINE_INTERNAL Engine Internal error
- * @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
- */
-int csre_wp_engine_destroy(csre_wp_engine_h engine);
-
-/**
* @brief returns the engine API version.
*
- * @param[in] engine The engine information handle.
+ * @param[in] context CSR WP context handle.
* @param[out] version A pointer of the API version string. A caller should not free it.
*
* @return #CSRE_ERROR_NONE on success, otherwise a negative error value
*
* @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid engine information handle
+ * @retval #CSRE_ERROR_INVALID_HANDLE Invalid context handle
* @retval #CSRE_ERROR_INVALID_PARAMETER api_ver is invalid
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
* @retval -0x0100~-0xFF00 Engine defined error
- *
- * @see csre_wp_engine_get_info()
*/
-int csre_wp_engine_get_api_version(csre_wp_engine_h engine,
- const char **version);
+int csre_wp_engine_get_api_version(csre_wp_context_h context, const char **version);
/**
- * @brief Extracts an vendor name from the engine information handle.
+ * @brief Extracts an vendor name from the CSR WP context handle.
*
- * @param[in] engine The engine information handle.
- * @param[out] vendor A pointer of the engine's vendor name. A caller should not free it.
+ * @param[in] context CSR WP context handle.
+ * @param[out] vendor A pointer of the engine's vendor name. A caller should not free it.
*
* @return #CSRE_ERROR_NONE on success, otherwise a negative error value
*
* @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid engine information handle
+ * @retval #CSRE_ERROR_INVALID_HANDLE Invalid context handle
* @retval #CSRE_ERROR_INVALID_PARAMETER engine_vendor is invalid
* @retval #CSRE_ERROR_ENGINE_INTERNAL Engine Internal error
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
- *
- * @see csre_wp_engine_get_info()
*/
-int csre_wp_engine_get_vendor(csre_wp_engine_h engine, const char **vendor);
+int csre_wp_engine_get_vendor(csre_wp_context_h context, const char **vendor);
/**
- * @brief Extracts an engine name from the engine information handle.
+ * @brief Extracts an engine name from the CSR WP context handle.
*
- * @param[in] engine The engine information handle.
- * @param[out] name A pointer of the engine's name. A caller should not free it.
+ * @param[in] context CSR WP context handle.
+ * @param[out] name A pointer of the engine's name. A caller should not free it.
*
* @return #CSRE_ERROR_NONE on success, otherwise a negative error value
*
* @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid engine information handle
+ * @retval #CSRE_ERROR_INVALID_HANDLE Invalid context handle
* @retval #CSRE_ERROR_INVALID_PARAMETER engine_name is invalid
* @retval #CSRE_ERROR_ENGINE_INTERNAL Engine Internal error
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
- *
- * @see csre_wp_engine_get_info()
*/
-int csre_wp_engine_get_name(csre_wp_engine_h engine, const char **name);
+int csre_wp_engine_get_name(csre_wp_context_h context, const char **name);
/**
- * @brief Extracts an engine version from the engine information handle.
+ * @brief Extracts an engine version from the CSR WP context handle.
*
- * @param[in] engine An engine information handle.
+ * @param[in] context CSR WP context handle.
* @param[out] version A pointer of the engine's version. A caller should not free it.
*
* @return #CSRE_ERROR_NONE on success, otherwise a negative error value
*
* @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid engine information handle
+ * @retval #CSRE_ERROR_INVALID_HANDLE Invalid context handle
* @retval #CSRE_ERROR_INVALID_PARAMETER engine_version is invalid
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
* @retval #CSRE_ERROR_ENGINE_INTERNAL Engine Internal error
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
- *
- * @see csre_wp_engine_get_info()
*/
-int csre_wp_engine_get_version(csre_wp_engine_h engine, const char **version);
+int csre_wp_engine_get_version(csre_wp_context_h context, const char **version);
/**
- * @brief Extracts an engine's data version from the engine information handle.
+ * @brief Extracts an engine's data version from the CSR WP context handle.
*
- * @param[in] engine The engine information handle.
+ * @param[in] context CSR WP context handle.
* @param[out] version A pointer of the data version. It can be null. A caller should not free it.
*
* @return #CSRE_ERROR_NONE on success, otherwise a negative error value
*
* @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid engine information handle
+ * @retval #CSRE_ERROR_INVALID_HANDLE Invalid context handle
* @retval #CSRE_ERROR_INVALID_PARAMETER engine_version is invalid
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
* @retval #CSRE_ERROR_ENGINE_INTERNAL Engine Internal error
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
- *
- * @see csre_wp_engine_get_info()
*/
-int csre_wp_engine_get_data_version(csre_wp_engine_h engine,
- const char **version);
+int csre_wp_engine_get_data_version(csre_wp_context_h context, const char **version);
/**
- * @brief Extracts the latest update time of an engine from the engine information handle.
+ * @brief Extracts the latest update time of an engine from the CSR WP context handle.
*
- * @param[in] engine The engine information handle.
+ * @param[in] context CSR WP context handle.
* @param[out] time A pointer of lasted update time.
*
* @return #CSRE_ERROR_NONE on success, otherwise a negative error value
*
* @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid engine information handle
+ * @retval #CSRE_ERROR_INVALID_HANDLE Invalid context handle
* @retval #CSRE_ERROR_INVALID_PARAMETER time is invalid
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
* @retval #CSRE_ERROR_ENGINE_INTERNAL Engine Internal error
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
- *
- * @see csre_wp_get_engine_info()
*/
-int csre_wp_engine_get_latest_update_time(csre_wp_engine_h engine,
- time_t *time);
+int csre_wp_engine_get_latest_update_time(csre_wp_context_h context, time_t *time);
/**
- * @brief Extracts the state of engine activation from the engine information handle.
+ * @brief Extracts the state of engine activation from the CSR WP context handle.
*
- * @param[in] engine The engine information handle.
+ * @param[in] context CSR WP context handle.
* @param[out] pactivated A pointer of the engine state.
*
* @return #CSRE_ERROR_NONE on success, otherwise a negative error value
*
* @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid engine information handle
+ * @retval #CSRE_ERROR_INVALID_HANDLE Invalid context handle
* @retval #CSRE_ERROR_INVALID_PARAMETER pactivated is invalid
* @retval #CSRE_ERROR_ENGINE_INTERNAL Engine Internal error
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
- *
- * @see csre_wp_engine_get_info()
*/
-int csre_wp_engine_get_activated(csre_wp_engine_h engine,
+int csre_wp_engine_get_activated(csre_wp_context_h context,
csre_wp_activated_e *pactivated);
/**
- * @brief Extracts an vendor logo image from the engine information handle.
+ * @brief Extracts an vendor logo image from the CSR WP context handle.
*
* @details If log image is provided, the vendor logo is shown in a popup. The format
* of the logo image should be jpeg, gif, bmp or png.
*
- * @param[in] engine The engine information handle.
+ * @param[in] context CSR WP context handle.
* @param[out] vendor_logo_image A pointer of the vendor logo image. A caller should not
* free it.
* @param[out] image_size Size of log image.
* @return #CSRE_ERROR_NONE on success, otherwise a negative error value
*
* @retval #CSRE_ERROR_NONE Successful
- * @retval #CSRE_ERROR_INVALID_HANDLE Invalid engine information handle
+ * @retval #CSRE_ERROR_INVALID_HANDLE Invalid context handle
* @retval #CSRE_ERROR_INVALID_PARAMETER vendor_logo_imgage or image_size is invalid
* @retval #CSRE_ERROR_NO_DATA No vendor logo image
* @retval #CSRE_ERROR_UNKNOWN Error with unknown reason
*
* @see csre_wp_engine_get_info()
*/
-int csre_wp_engine_get_vendor_logo(csre_wp_engine_h engine,
- unsigned char **vendor_logo_image, unsigned int *image_size);
+int csre_wp_engine_get_vendor_logo(csre_wp_context_h context,
+ unsigned char **vendor_logo_image,
+ unsigned int *image_size);
#ifdef __cplusplus
}
time_t timestamp;
};
-struct csret_cs_context_s {
- int scan_on_data;
- std::list<csret_cs_detected_s> detected_list;
-};
-
struct csret_cs_engine_s {
std::string vendorName;
std::string engineName;
time_t latestUpdate;
};
+struct csret_cs_context_s {
+ int scan_on_data;
+ std::list<csret_cs_detected_s> detected_list;
+ csret_cs_engine_s *engine;
+};
+
enum csret_cs_internal_error_e {
CSRET_CS_ERROR_NO_SIGNATURE_FILE = -0x0101,
CSRET_CS_ERROR_SIGNATURE_FILE_FORMAT = -0x0102,
return tv.tv_sec;
}
-csret_cs_engine_s *csret_cs_init_engine()
+int csret_cs_init_engine(csret_cs_engine_s **pengine)
{
+ if (pengine == nullptr)
+ return CSRE_ERROR_INVALID_PARAMETER;
+
auto ptr = new csret_cs_engine_s;
ptr->vendorName = VENDOR_NAME;
ptr->engineVersion = ENGINE_VERSION;
ptr->dataVersion = ENGINE_VERSION;
- int ret = csret_cs_read_binary(g_resdir + "/" PRIVATE_LOGO_FILE,
- ptr->logoImage);
+ int ret = csret_cs_read_binary(g_resdir + "/" PRIVATE_LOGO_FILE, ptr->logoImage);
if (ret != CSRE_ERROR_NONE) {
delete ptr;
- return nullptr;
+ return ret;
}
struct stat attrib;
ptr->latestUpdate = attrib.st_mtime;
- return ptr;
+ *pengine = ptr;
+
+ return CSRE_ERROR_NONE;
}
int csret_cs_compare_data(const RawBuffer &data, const std::string &needle)
// Main function related
//==============================================================================
API
-int csre_cs_global_initialize(const char *ro_res_dir,
- const char *rw_working_dir)
+int csre_cs_global_initialize(const char *ro_res_dir, const char *rw_working_dir)
{
if (ro_res_dir == nullptr || rw_working_dir == nullptr)
return CSRE_ERROR_INVALID_PARAMETER;
if (g_virus_sig.empty())
return CSRE_ERROR_INVALID_HANDLE; // not yet initialized
- auto context = new csret_cs_context_s;
+ csret_cs_engine_s *engine = nullptr;
+ auto ret = csret_cs_init_engine(&engine);
+ if (ret != CSRE_ERROR_NONE)
+ return ret;
+
+ auto context = new (std::nothrow) csret_cs_context_s;
+ if (context == nullptr)
+ return CSRE_ERROR_OUT_OF_MEMORY;
+
+ context->engine = engine;
*phandle = reinterpret_cast<csre_cs_context_h>(context);
if (context == nullptr)
return CSRE_ERROR_INVALID_HANDLE;
+ if (context->engine != nullptr)
+ delete context->engine;
+
delete context;
return CSRE_ERROR_NONE;
// Engine information related
//==============================================================================
API
-int csre_cs_engine_get_info(csre_cs_engine_h *pengine)
-{
- if (pengine == nullptr)
- return CSRE_ERROR_INVALID_PARAMETER;
-
- auto ptr = csret_cs_init_engine();
- *pengine = reinterpret_cast<csre_cs_engine_h>(ptr);
-
- return CSRE_ERROR_NONE;
-}
-
-API
-int csre_cs_engine_destroy(csre_cs_engine_h engine)
+int csre_cs_engine_get_vendor(csre_cs_context_h context, const char **vendor)
{
- if (engine == nullptr)
- return CSRE_ERROR_INVALID_PARAMETER;
-
- delete reinterpret_cast<csret_cs_engine_s *>(engine);
-
- return CSRE_ERROR_NONE;
-}
-
-API
-int csre_cs_engine_get_vendor(csre_cs_engine_h engine, const char **vendor)
-{
- auto eng = reinterpret_cast<csret_cs_engine_s *>(engine);
-
- if (eng == nullptr)
+ if (context == nullptr)
return CSRE_ERROR_INVALID_HANDLE;
if (vendor == nullptr)
return CSRE_ERROR_INVALID_PARAMETER;
+ auto eng = reinterpret_cast<csret_cs_context_s *>(context)->engine;
+
*vendor = eng->vendorName.c_str();
return CSRE_ERROR_NONE;
}
API
-int csre_cs_engine_get_name(csre_cs_engine_h engine, const char **name)
+int csre_cs_engine_get_name(csre_cs_context_h context, const char **name)
{
- auto eng = reinterpret_cast<csret_cs_engine_s *>(engine);
-
- if (eng == nullptr)
+ if (context == nullptr)
return CSRE_ERROR_INVALID_HANDLE;
if (name == nullptr)
return CSRE_ERROR_INVALID_PARAMETER;
+ auto eng = reinterpret_cast<csret_cs_context_s *>(context)->engine;
+
*name = eng->engineName.c_str();
return CSRE_ERROR_NONE;
}
API
-int csre_cs_engine_get_vendor_logo(csre_cs_engine_h engine,
+int csre_cs_engine_get_vendor_logo(csre_cs_context_h context,
unsigned char **logo_image,
unsigned int *image_size)
{
- auto eng = reinterpret_cast<csret_cs_engine_s *>(engine);
-
- if (eng == nullptr)
+ if (context == nullptr)
return CSRE_ERROR_INVALID_HANDLE;
if (logo_image == nullptr || image_size == nullptr)
return CSRE_ERROR_INVALID_PARAMETER;
+ auto eng = reinterpret_cast<csret_cs_context_s *>(context)->engine;
+
auto s = eng->logoImage.size();
if (s > UINT_MAX - 1)
}
API
-int csre_cs_engine_get_version(csre_cs_engine_h engine, const char **version)
+int csre_cs_engine_get_version(csre_cs_context_h context, const char **version)
{
- auto eng = reinterpret_cast<csret_cs_engine_s *>(engine);
-
- if (eng == nullptr)
+ if (context == nullptr)
return CSRE_ERROR_INVALID_HANDLE;
if (version == nullptr)
return CSRE_ERROR_INVALID_PARAMETER;
+ auto eng = reinterpret_cast<csret_cs_context_s *>(context)->engine;
+
*version = eng->engineVersion.c_str();
return CSRE_ERROR_NONE;
}
API
-int csre_cs_engine_get_data_version(csre_cs_engine_h engine,
- const char **version)
+int csre_cs_engine_get_data_version(csre_cs_context_h context, const char **version)
{
- auto eng = reinterpret_cast<csret_cs_engine_s *>(engine);
-
- if (eng == nullptr)
+ if (context == nullptr)
return CSRE_ERROR_INVALID_HANDLE;
if (version == nullptr)
return CSRE_ERROR_INVALID_PARAMETER;
+ auto eng = reinterpret_cast<csret_cs_context_s *>(context)->engine;
+
*version = eng->dataVersion.c_str();
return CSRE_ERROR_NONE;
}
API
-int csre_cs_engine_get_latest_update_time(csre_cs_engine_h engine, time_t *time)
+int csre_cs_engine_get_latest_update_time(csre_cs_context_h context, time_t *time)
{
- auto eng = reinterpret_cast<csret_cs_engine_s *>(engine);
-
- if (eng == nullptr)
+ if (context == nullptr)
return CSRE_ERROR_INVALID_HANDLE;
if (time == nullptr)
return CSRE_ERROR_INVALID_PARAMETER;
+ auto eng = reinterpret_cast<csret_cs_context_s *>(context)->engine;
+
*time = eng->latestUpdate;
return CSRE_ERROR_NONE;
}
API
-int csre_cs_engine_get_activated(csre_cs_engine_h engine,
+int csre_cs_engine_get_activated(csre_cs_context_h context,
csre_cs_activated_e *pactivated)
{
- auto eng = reinterpret_cast<csret_cs_engine_s *>(engine);
-
- if (eng == nullptr)
- return CSRE_ERROR_INVALID_HANDLE;
+ (void) context;
if (pactivated == nullptr)
return CSRE_ERROR_INVALID_PARAMETER;
}
API
-int csre_cs_engine_get_api_version(csre_cs_engine_h engine,
- const char **version)
+int csre_cs_engine_get_api_version(csre_cs_context_h context, const char **version)
{
- auto eng = reinterpret_cast<csret_cs_engine_s *>(engine);
-
- if (eng == nullptr)
+ if (context == nullptr)
return CSRE_ERROR_INVALID_HANDLE;
if (version == nullptr)
return CSRE_ERROR_INVALID_PARAMETER;
+ auto eng = reinterpret_cast<csret_cs_context_s *>(context)->engine;
+
*version = eng->apiVersion.c_str();
return CSRE_ERROR_NONE;
csret_wp_risky_url_s() : risk_level(CSRE_WP_RISK_UNVERIFIED) {}
};
-struct csret_wp_context_s {
- std::list<csret_wp_risky_url_s> detected_list;
-};
-
struct csret_wp_engine_s {
std::string vendorName;
std::string engineName;
time_t latestUpdate;
};
+struct csret_wp_context_s {
+ std::list<csret_wp_risky_url_s> detected_list;
+ csret_wp_engine_s *engine;
+};
+
enum csret_wp_internal_error_e {
CSRET_WP_ERROR_NO_RISKY_URL_FILE = -0x0101,
CSRET_WP_ERROR_SIGNATURE_FILE_FORMAT = -0x0102,
return CSRE_ERROR_NONE;
}
-csret_wp_engine_s *csret_wp_init_engine()
+int csret_wp_init_engine(csret_wp_engine_s **pengine)
{
+ if (pengine == nullptr)
+ return CSRE_ERROR_INVALID_PARAMETER;
+
auto ptr = new csret_wp_engine_s;
ptr->vendorName = VENDOR_NAME;
if (ret != CSRE_ERROR_NONE) {
delete ptr;
- return nullptr;
+ return ret;
}
struct stat attrib;
ptr->latestUpdate = attrib.st_mtime;
- return ptr;
+ *pengine = ptr;
+
+ return CSRE_ERROR_NONE;
}
if (g_risky_urls.empty())
return CSRE_ERROR_INVALID_HANDLE; // not yet initialized
- auto context = new csret_wp_context_s;
+ csret_wp_engine_s *engine = nullptr;
+ auto ret = csret_wp_init_engine(&engine);
+ if (ret != CSRE_ERROR_NONE)
+ return ret;
+
+ auto context = new (std::nothrow) csret_wp_context_s;
+ if (context == nullptr)
+ return CSRE_ERROR_OUT_OF_MEMORY;
+
+ context->engine = engine;
*phandle = reinterpret_cast<csre_wp_context_h>(context);
if (context == nullptr)
return CSRE_ERROR_INVALID_HANDLE;
+ if (context->engine != nullptr)
+ delete context->engine;
+
delete context;
return CSRE_ERROR_NONE;
// Engine information related
//==============================================================================
API
-int csre_wp_engine_get_info(csre_wp_engine_h *pengine)
+int csre_wp_engine_get_vendor(csre_wp_context_h context, const char **vendor)
{
- if (pengine == nullptr)
- return CSRE_ERROR_INVALID_PARAMETER;
-
- auto ptr = csret_wp_init_engine();
- *pengine = reinterpret_cast<csre_wp_engine_h>(ptr);
-
- return CSRE_ERROR_NONE;
-}
-
-API
-int csre_wp_engine_destroy(csre_wp_engine_h engine)
-{
- if (engine == nullptr)
- return CSRE_ERROR_INVALID_PARAMETER;
-
- delete reinterpret_cast<csret_wp_engine_s *>(engine);
-
- return CSRE_ERROR_NONE;
-}
-
-API
-int csre_wp_engine_get_vendor(csre_wp_engine_h engine, const char **vendor)
-{
- auto eng = reinterpret_cast<csret_wp_engine_s *>(engine);
-
- if (eng == nullptr)
+ if (context == nullptr)
return CSRE_ERROR_INVALID_HANDLE;
if (vendor == nullptr)
return CSRE_ERROR_INVALID_PARAMETER;
+ auto eng = reinterpret_cast<csret_wp_context_s *>(context)->engine;
+
*vendor = eng->vendorName.c_str();
return CSRE_ERROR_NONE;
}
API
-int csre_wp_engine_get_name(csre_wp_engine_h engine, const char **name)
+int csre_wp_engine_get_name(csre_wp_context_h context, const char **name)
{
- auto eng = reinterpret_cast<csret_wp_engine_s *>(engine);
-
- if (eng == nullptr)
+ if (context == nullptr)
return CSRE_ERROR_INVALID_HANDLE;
if (name == nullptr)
return CSRE_ERROR_INVALID_PARAMETER;
+ auto eng = reinterpret_cast<csret_wp_context_s *>(context)->engine;
+
*name = eng->engineName.c_str();
return CSRE_ERROR_NONE;
}
API
-int csre_wp_engine_get_vendor_logo(csre_wp_engine_h engine,
+int csre_wp_engine_get_vendor_logo(csre_wp_context_h context,
unsigned char **vendor_logo_image,
unsigned int *image_size)
{
- auto eng = reinterpret_cast<csret_wp_engine_s *>(engine);
-
- if (eng == nullptr)
+ if (context == nullptr)
return CSRE_ERROR_INVALID_HANDLE;
if (vendor_logo_image == nullptr || image_size == nullptr)
return CSRE_ERROR_INVALID_PARAMETER;
+ auto eng = reinterpret_cast<csret_wp_context_s *>(context)->engine;
+
auto s = eng->logoImage.size();
if (s > UINT_MAX - 1)
}
API
-int csre_wp_engine_get_version(csre_wp_engine_h engine, const char **version)
+int csre_wp_engine_get_version(csre_wp_context_h context, const char **version)
{
- auto eng = reinterpret_cast<csret_wp_engine_s *>(engine);
-
- if (eng == nullptr)
+ if (context == nullptr)
return CSRE_ERROR_INVALID_HANDLE;
if (version == nullptr)
return CSRE_ERROR_INVALID_PARAMETER;
+ auto eng = reinterpret_cast<csret_wp_context_s *>(context)->engine;
+
*version = eng->engineVersion.c_str();
return CSRE_ERROR_NONE;
}
API
-int csre_wp_engine_get_data_version(csre_wp_engine_h engine,
- const char **version)
+int csre_wp_engine_get_data_version(csre_wp_context_h context, const char **version)
{
- auto eng = reinterpret_cast<csret_wp_engine_s *>(engine);
-
- if (eng == nullptr)
+ if (context == nullptr)
return CSRE_ERROR_INVALID_HANDLE;
if (version == nullptr)
return CSRE_ERROR_INVALID_PARAMETER;
+ auto eng = reinterpret_cast<csret_wp_context_s *>(context)->engine;
+
*version = eng->dataVersion.c_str();
return CSRE_ERROR_NONE;
API
-int csre_wp_engine_get_latest_update_time(csre_wp_engine_h engine, time_t *time)
+int csre_wp_engine_get_latest_update_time(csre_wp_context_h context, time_t *time)
{
- auto eng = reinterpret_cast<csret_wp_engine_s *>(engine);
-
- if (eng == nullptr)
+ if (context == nullptr)
return CSRE_ERROR_INVALID_HANDLE;
if (time == nullptr)
return CSRE_ERROR_INVALID_PARAMETER;
+ auto eng = reinterpret_cast<csret_wp_context_s *>(context)->engine;
+
*time = eng->latestUpdate;
return CSRE_ERROR_NONE;
}
API
-int csre_wp_engine_get_activated(csre_wp_engine_h engine,
+int csre_wp_engine_get_activated(csre_wp_context_h context,
csre_wp_activated_e *pactivated)
{
- auto eng = reinterpret_cast<csret_wp_engine_s *>(engine);
-
- if (eng == nullptr)
- return CSRE_ERROR_INVALID_HANDLE;
+ (void) context;
if (pactivated == nullptr)
return CSRE_ERROR_INVALID_PARAMETER;
}
API
-int csre_wp_engine_get_api_version(csre_wp_engine_h engine,
- const char **version)
+int csre_wp_engine_get_api_version(csre_wp_context_h context, const char **version)
{
- auto eng = reinterpret_cast<csret_wp_engine_s *>(engine);
-
- if (eng == nullptr)
+ if (context == nullptr)
return CSRE_ERROR_INVALID_HANDLE;
if (version == nullptr)
return CSRE_ERROR_INVALID_PARAMETER;
+ auto eng = reinterpret_cast<csret_wp_context_s *>(context)->engine;
+
*version = eng->apiVersion.c_str();
return CSRE_ERROR_NONE;
BOOST_AUTO_TEST_SUITE(API_ENGINE_CONTENT_SCREENING_ENGINE_INFO)
-BOOST_AUTO_TEST_CASE(get_engine_info)
-{
- EXCEPTION_GUARD_START
-
- auto c = Test::Context<csre_cs_engine_h>();
- (void) c;
-
- EXCEPTION_GUARD_END
-}
-
BOOST_AUTO_TEST_CASE(get_vendor)
{
EXCEPTION_GUARD_START
- auto c = Test::Context<csre_cs_engine_h>();
+ auto c = Test::Context<csre_cs_context_h>();
auto handle = c.get();
const char *vendor = nullptr;
{
EXCEPTION_GUARD_START
- auto c = Test::Context<csre_cs_engine_h>();
+ auto c = Test::Context<csre_cs_context_h>();
auto handle = c.get();
unsigned char *vendor_logo_image = nullptr;
{
EXCEPTION_GUARD_START
- auto c = Test::Context<csre_cs_engine_h>();
+ auto c = Test::Context<csre_cs_context_h>();
auto handle = c.get();
const char *version = nullptr;
{
EXCEPTION_GUARD_START
- auto c = Test::Context<csre_cs_engine_h>();
+ auto c = Test::Context<csre_cs_context_h>();
auto handle = c.get();
const char *version = nullptr;
{
EXCEPTION_GUARD_START
- auto c = Test::Context<csre_cs_engine_h>();
+ auto c = Test::Context<csre_cs_context_h>();
auto handle = c.get();
time_t time = 0;
{
EXCEPTION_GUARD_START
- auto c = Test::Context<csre_cs_engine_h>();
+ auto c = Test::Context<csre_cs_context_h>();
auto handle = c.get();
csre_cs_activated_e activated;
{
EXCEPTION_GUARD_START
- auto c = Test::Context<csre_cs_engine_h>();
+ auto c = Test::Context<csre_cs_context_h>();
auto handle = c.get();
const char *version = nullptr;
BOOST_AUTO_TEST_SUITE(API_ENGINE_WEB_PROTECTION_ENGINE_INFO)
-BOOST_AUTO_TEST_CASE(get_engine_info)
-{
- EXCEPTION_GUARD_START
-
- auto c = Test::Context<csre_wp_engine_h>();
- (void) c;
-
- EXCEPTION_GUARD_END
-}
-
BOOST_AUTO_TEST_CASE(get_vendor)
{
EXCEPTION_GUARD_START
- auto c = Test::Context<csre_wp_engine_h>();
+ auto c = Test::Context<csre_wp_context_h>();
auto handle = c.get();
const char *vendor = nullptr;
{
EXCEPTION_GUARD_START
- auto c = Test::Context<csre_wp_engine_h>();
+ auto c = Test::Context<csre_wp_context_h>();
auto handle = c.get();
unsigned char *vendor_logo_image = nullptr;
{
EXCEPTION_GUARD_START
- auto c = Test::Context<csre_wp_engine_h>();
+ auto c = Test::Context<csre_wp_context_h>();
auto handle = c.get();
const char *version = nullptr;
{
EXCEPTION_GUARD_START
- auto c = Test::Context<csre_wp_engine_h>();
+ auto c = Test::Context<csre_wp_context_h>();
auto handle = c.get();
const char *version = nullptr;
{
EXCEPTION_GUARD_START
- auto c = Test::Context<csre_wp_engine_h>();
+ auto c = Test::Context<csre_wp_context_h>();
auto handle = c.get();
time_t time = 0;
{
EXCEPTION_GUARD_START
- auto c = Test::Context<csre_wp_engine_h>();
+ auto c = Test::Context<csre_wp_context_h>();
auto handle = c.get();
csre_wp_activated_e activated;
{
EXCEPTION_GUARD_START
- auto c = Test::Context<csre_wp_engine_h>();
+ auto c = Test::Context<csre_wp_context_h>();
auto handle = c.get();
const char *version = nullptr;
EXCEPTION_GUARD_END
}
-template <typename T>
struct Handle {
- Handle()
- {
- BOOST_REQUIRE_MESSAGE(0, "Not specialized for handle template");
- }
-
- ~Handle()
- {
- BOOST_REQUIRE_MESSAGE(0, "Not specialized for handle template");
- }
-
- Csr::CsLoader loader;
- T context;
-};
-
-template <>
-struct Handle<csre_cs_context_h> {
Handle() :
loader(ENGINE_DIR "/libcsr-cs-engine.so",
ENGINE_DIR,
csre_cs_context_h context;
};
-template <>
-struct Handle<csre_cs_engine_h> {
- Handle() :
- loader(ENGINE_DIR "/libcsr-cs-engine.so",
- ENGINE_DIR,
- ENGINE_RW_WORKING_DIR)
- {
- ASSERT_IF(loader.getEngineInfo(context), CSRE_ERROR_NONE);
- }
-
- ~Handle()
- {
- ASSERT_IF(loader.destroyEngine(context), CSRE_ERROR_NONE);
- }
-
- Csr::CsLoader loader;
- csre_cs_engine_h context;
-};
-
} // namespace anonymous
BOOST_AUTO_TEST_SUITE(CS_LOADER)
{
EXCEPTION_GUARD_START
- Handle<csre_cs_context_h> h;
+ Handle h;
(void) h;
EXCEPTION_GUARD_END
{
EXCEPTION_GUARD_START
- Handle<csre_cs_context_h> h;
+ Handle h;
const char *cdata =
"abcd1234dfdfdf334dfdi8ffndsfdfdsfdasfagdfvdfdfafadfasdfsdfe";
{
EXCEPTION_GUARD_START
- Handle<csre_cs_context_h> h;
+ Handle h;
const char *cdata =
"aabbccX5O!P%@AP[4\\PZX54(P^)7CC)7}$"
{
EXCEPTION_GUARD_START
- Handle<csre_cs_context_h> h;
+ Handle h;
const char *cdata = "aabbccRISKY_MALWARE112233";
{
EXCEPTION_GUARD_START
- Handle<csre_cs_context_h> h;
+ Handle h;
csre_cs_detected_h detected;
ASSERT_IF(h.loader.scanFile(h.context, TEST_FILE_NORMAL, &detected),
{
EXCEPTION_GUARD_START
- Handle<csre_cs_context_h> h;
+ Handle h;
csre_cs_detected_h detected;
ASSERT_IF(h.loader.scanFile(h.context, TEST_FILE_MALWARE, &detected),
{
EXCEPTION_GUARD_START
- Handle<csre_cs_context_h> h;
+ Handle h;
csre_cs_detected_h detected;
ASSERT_IF(h.loader.scanFile(h.context, TEST_FILE_RISKY, &detected),
{
EXCEPTION_GUARD_START
- Handle<csre_cs_context_h> h;
+ Handle h;
csre_cs_detected_h detected;
ASSERT_IF(h.loader.scanAppOnCloud(h.context, TEST_APP_ROOT, &detected),
{
EXCEPTION_GUARD_START
- Handle<csre_cs_context_h> h;
+ Handle h;
std::string str;
EXCEPTION_GUARD_END
}
-BOOST_AUTO_TEST_CASE(get_engine_info)
-{
- EXCEPTION_GUARD_START
-
- Handle<csre_cs_engine_h> h;
- (void) h;
-
- EXCEPTION_GUARD_END
-}
-
BOOST_AUTO_TEST_CASE(get_vendor)
{
EXCEPTION_GUARD_START
- Handle<csre_cs_engine_h> h;
+ Handle h;
std::string str;
ASSERT_IF(h.loader.getEngineVendor(h.context, str), CSRE_ERROR_NONE);
{
EXCEPTION_GUARD_START
- Handle<csre_cs_engine_h> h;
+ Handle h;
std::vector<unsigned char> logo;
ASSERT_IF(h.loader.getEngineVendorLogo(h.context, logo), CSRE_ERROR_NONE);
{
EXCEPTION_GUARD_START
- Handle<csre_cs_engine_h> h;
+ Handle h;
std::string str;
ASSERT_IF(h.loader.getEngineVersion(h.context, str), CSRE_ERROR_NONE);
{
EXCEPTION_GUARD_START
- Handle<csre_cs_engine_h> h;
+ Handle h;
std::string str;
ASSERT_IF(h.loader.getEngineDataVersion(h.context, str), CSRE_ERROR_NONE);
{
EXCEPTION_GUARD_START
- Handle<csre_cs_engine_h> h;
+ Handle h;
time_t time = 0;
ASSERT_IF(h.loader.getEngineLatestUpdateTime(h.context, &time),
{
EXCEPTION_GUARD_START
- Handle<csre_cs_engine_h> h;
+ Handle h;
csre_cs_activated_e activated;
ASSERT_IF(h.loader.getEngineActivated(h.context, &activated), CSRE_ERROR_NONE);
{
EXCEPTION_GUARD_START
- Handle<csre_cs_engine_h> h;
+ Handle h;
std::string str;
ASSERT_IF(h.loader.getEngineApiVersion(h.context, str), CSRE_ERROR_NONE);
EXCEPTION_GUARD_END
}
-template <typename T>
struct Handle {
- Handle()
- {
- BOOST_REQUIRE_MESSAGE(0, "Not specialized for handle template");
- }
-
- ~Handle()
- {
- BOOST_REQUIRE_MESSAGE(0, "Not specialized for handle template");
- }
-
- Csr::WpLoader loader;
- T context;
-};
-
-template <>
-struct Handle<csre_wp_context_h> {
Handle() :
loader(ENGINE_DIR "/libcsr-wp-engine.so",
ENGINE_DIR,
csre_wp_context_h context;
};
-template <>
-struct Handle<csre_wp_engine_h> {
- Handle() :
- loader(ENGINE_DIR "/libcsr-wp-engine.so",
- ENGINE_DIR,
- ENGINE_RW_WORKING_DIR)
- {
- ASSERT_IF(loader.getEngineInfo(context), CSRE_ERROR_NONE);
- }
-
- ~Handle()
- {
- ASSERT_IF(loader.destroyEngine(context), CSRE_ERROR_NONE);
- }
-
- Csr::WpLoader loader;
- csre_wp_engine_h context;
-};
-
} // namespace anonymous
{
EXCEPTION_GUARD_START
- Handle<csre_wp_context_h> h;
+ Handle h;
(void) h;
EXCEPTION_GUARD_END
{
EXCEPTION_GUARD_START
- Handle<csre_wp_context_h> h;
+ Handle h;
for (const auto &expected : ExpectedResult) {
csre_wp_check_result_h result;
{
EXCEPTION_GUARD_START
- Handle<csre_wp_engine_h> h;
+ Handle h;
std::string str;
EXCEPTION_GUARD_END
}
-
-BOOST_AUTO_TEST_CASE(get_engine_info)
-{
- EXCEPTION_GUARD_START
-
- Handle<csre_wp_engine_h> h;
- (void) h;
-
- EXCEPTION_GUARD_END
-}
-
BOOST_AUTO_TEST_CASE(get_vendor)
{
EXCEPTION_GUARD_START
- Handle<csre_wp_engine_h> h;
+ Handle h;
std::string str;
ASSERT_IF(h.loader.getEngineVendor(h.context, str), CSRE_ERROR_NONE);
{
EXCEPTION_GUARD_START
- Handle<csre_wp_engine_h> h;
+ Handle h;
std::vector<unsigned char> logo;
ASSERT_IF(h.loader.getEngineVendorLogo(h.context, logo), CSRE_ERROR_NONE);
{
EXCEPTION_GUARD_START
- Handle<csre_wp_engine_h> h;
+ Handle h;
std::string str;
ASSERT_IF(h.loader.getEngineVersion(h.context, str), CSRE_ERROR_NONE);
{
EXCEPTION_GUARD_START
- Handle<csre_wp_engine_h> h;
+ Handle h;
std::string str;
ASSERT_IF(h.loader.getEngineDataVersion(h.context, str), CSRE_ERROR_NONE);
{
EXCEPTION_GUARD_START
- Handle<csre_wp_engine_h> h;
+ Handle h;
time_t time = 0;
ASSERT_IF(h.loader.getEngineLatestUpdateTime(h.context, &time),
{
EXCEPTION_GUARD_START
- Handle<csre_wp_engine_h> h;
+ Handle h;
csre_wp_activated_e activated;
ASSERT_IF(h.loader.getEngineActivated(h.context, &activated), CSRE_ERROR_NONE);
{
EXCEPTION_GUARD_START
- Handle<csre_wp_engine_h> h;
+ Handle h;
std::string str;
ASSERT_IF(h.loader.getEngineApiVersion(h.context, str), CSRE_ERROR_NONE);
#include <csre-content-screening.h>
#include <csre-web-protection.h>
-#include <csre-content-screening-engine-info.h>
-#include <csre-web-protection-engine-info.h>
-
#ifndef __FILENAME__
#define __FILENAME__ (::strrchr(__FILE__, '/') ? ::strrchr(__FILE__, '/') + 1 : __FILE__)
#endif
csre_wp_context_h m_context;
};
-template <>
-class Context<csre_cs_engine_h> {
-public:
- Context() : m_context(nullptr)
- {
- ASSERT_IF(csre_cs_engine_get_info(&m_context), CSRE_ERROR_NONE);
- BOOST_REQUIRE(m_context != nullptr);
- }
-
- virtual ~Context()
- {
- ASSERT_IF(csre_cs_engine_destroy(m_context), CSRE_ERROR_NONE);
- }
-
- csre_cs_engine_h get(void) const
- {
- return m_context;
- }
-
-private:
- csre_cs_engine_h m_context;
-};
-
-template <>
-class Context<csre_wp_engine_h> {
-public:
- Context() : m_context(nullptr)
- {
- ASSERT_IF(csre_wp_engine_get_info(&m_context), CSRE_ERROR_NONE);
- BOOST_REQUIRE(m_context != nullptr);
- }
-
- virtual ~Context()
- {
- ASSERT_IF(csre_wp_engine_destroy(m_context), CSRE_ERROR_NONE);
- }
-
- csre_wp_engine_h get(void) const
- {
- return m_context;
- }
-
-private:
- csre_wp_engine_h m_context;
-};
-
} // namespace Test