|
|
@@ -13,9 +13,7 @@
|
|
|
#include <vector>
|
|
|
|
|
|
#include "publicFunExport.h"
|
|
|
-
|
|
|
-//Stand2S
|
|
|
-static const char* adapterList[] = { "PinPad", "CardIssuer", "IDCertificate","ContactlessCard","HSPScanner", "FingerPrint", "WatchDog", "Gpio", "Ups" };
|
|
|
+#include "DeviceAdaptChecker.h"
|
|
|
|
|
|
void CDeviceControlServerSession::Handle_USB(SpReqAnsContext<DeviceControlService_USB_Req, DeviceControlService_USB_Ans>::Pointer ctx)
|
|
|
{
|
|
|
@@ -172,14 +170,12 @@ void CDeviceControlEntity::TestConnectivity(SpReqAnsContext<DeviceControlService
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
static CSimpleStringA GetRegexPatternString(const DeviceControlService_GetVendorFileList_Req& req)
|
|
|
{
|
|
|
const char* prefix = "^lib";
|
|
|
const char* suffix = "\\.so$";
|
|
|
CSimpleStringA strRegexPattern(prefix);
|
|
|
- if (req.root) {
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
//^lib(Gpio|PinPad)\.[a-zA-Z]*\.[0-9]*\.[0-9]*\.so$
|
|
|
if (req.adapter.IsNullOrEmpty() || req.adapter.Compare("*") == 0) {
|
|
|
@@ -233,46 +229,72 @@ void CDeviceControlEntity::GetVendorFileList(SpReqAnsContext<DeviceControlServic
|
|
|
CSimpleStringA tmpMsg(true);
|
|
|
|
|
|
CSimpleStringA strDepDirPath;
|
|
|
- std::vector<std::string> adapterFiles;
|
|
|
-
|
|
|
result = GetFunction()->GetPath("Dep", strDepDirPath);
|
|
|
|
|
|
- array_header_t* subs = fileutil_get_sub_files_a(strDepDirPath);
|
|
|
- if (subs) {
|
|
|
- regex_t reg;
|
|
|
- CSimpleStringA pattern = GetRegexPatternString(ctx->Req);
|
|
|
- int ret = regcomp(®, pattern, REG_EXTENDED | REG_NOSUB);
|
|
|
- if (ret) {
|
|
|
- char ebuff[256];
|
|
|
- regerror(ret, ®, ebuff, 256);
|
|
|
- Dbg("regex failed: %s", ebuff);
|
|
|
- tmpResult = Error_Unexpect;
|
|
|
- tmpMsg = CSimpleStringA::Format("ÄÚ²¿´íÎó£ºREGEX %s", ebuff);
|
|
|
- } else {
|
|
|
- Dbg("pattern: %s", pattern.GetData());
|
|
|
- for (int i = 0; i < subs->nelts; ++i) {
|
|
|
- char* filenamePath = ARRAY_IDX(subs, i, char*);
|
|
|
- char* filename = &filenamePath[strDepDirPath.GetLength() + 1];
|
|
|
- ret = regexec(®, filename, 0, NULL, 0);
|
|
|
- if (0 == ret) {
|
|
|
- Dbg("filename %s matched!", filename);
|
|
|
- adapterFiles.push_back(std::string(filename));
|
|
|
+ if (ctx->Req.root) {
|
|
|
+ CAdapterLoadChecker* checker = new CAdapterLoadChecker();
|
|
|
+ checker->Init(this);
|
|
|
+ ctx->Ans.filenames = checker->GetConfigedAdapterFileName();
|
|
|
+ ctx->Ans.status.Init(ctx->Ans.filenames.GetCount());
|
|
|
+ CSimpleStringA strDepDirPath2 = strDepDirPath + SPLIT_SLASH_STR;
|
|
|
+ for (int i = 0; i < ctx->Ans.filenames.GetCount(); ++i) {
|
|
|
+ CSimpleStringA fullPath = strDepDirPath2 + ctx->Ans.filenames[i];
|
|
|
+ ctx->Ans.status[i] = 0x2;
|
|
|
+ if (ExistsFileA(fullPath)) {
|
|
|
+ ctx->Ans.status[i] |= 0x1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ delete checker;
|
|
|
+ } else {
|
|
|
+ std::vector<std::string> adapterFiles;
|
|
|
+ array_header_t* subs = fileutil_get_sub_files_a(strDepDirPath);
|
|
|
+ if (subs) {
|
|
|
+ regex_t reg;
|
|
|
+ CSimpleStringA pattern = GetRegexPatternString(ctx->Req);
|
|
|
+ int ret = regcomp(®, pattern, REG_EXTENDED | REG_NOSUB);
|
|
|
+ if (ret) {
|
|
|
+ char ebuff[256];
|
|
|
+ regerror(ret, ®, ebuff, 256);
|
|
|
+ Dbg("regex failed: %s", ebuff);
|
|
|
+ tmpResult = Error_Unexpect;
|
|
|
+ tmpMsg = CSimpleStringA::Format("ÄÚ²¿´íÎó£ºREGEX %s", ebuff);
|
|
|
+ } else {
|
|
|
+ Dbg("pattern: %s", pattern.GetData());
|
|
|
+ for (int i = 0; i < subs->nelts; ++i) {
|
|
|
+ char* filenamePath = ARRAY_IDX(subs, i, char*);
|
|
|
+ char* filename = &filenamePath[strDepDirPath.GetLength() + 1];
|
|
|
+ ret = regexec(®, filename, 0, NULL, 0);
|
|
|
+ if (0 == ret) {
|
|
|
+ Dbg("filename %s matched!", filename);
|
|
|
+ adapterFiles.push_back(std::string(filename));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const int curSize = adapterFiles.size();
|
|
|
+ ctx->Ans.filenames.Init(curSize);
|
|
|
+ ctx->Ans.status.Init(curSize);
|
|
|
+ for (int i = 0; i < curSize; ++i) ctx->Ans.status[i] = 0;
|
|
|
+
|
|
|
+ if (curSize > 0) {
|
|
|
+ CAdapterLoadChecker* checker = new CAdapterLoadChecker();
|
|
|
+ checker->Init(this);
|
|
|
+ int cnt = 0;
|
|
|
+ for (auto iter = adapterFiles.cbegin(); iter != adapterFiles.cend(); ++iter, ++cnt) {
|
|
|
+ ctx->Ans.filenames[cnt] = iter->c_str();
|
|
|
+ ctx->Ans.status[cnt] = 0x1;
|
|
|
+ if (checker->IsThisFileConfigure(iter->c_str())) {
|
|
|
+ ctx->Ans.status[cnt] |= 0x2;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ delete checker;
|
|
|
}
|
|
|
+
|
|
|
+ toolkit_array_free2(subs);
|
|
|
}
|
|
|
- toolkit_array_free2(subs);
|
|
|
}
|
|
|
-
|
|
|
- ctx->Ans.filenames.Init(adapterFiles.size());
|
|
|
- ctx->Ans.status.Init(adapterFiles.size());
|
|
|
- int cnt = 0;
|
|
|
- for (auto iter = adapterFiles.cbegin(); iter != adapterFiles.cend(); ++iter, ++cnt) {
|
|
|
- ctx->Ans.filenames[cnt] = iter->c_str();
|
|
|
- ctx->Ans.status[cnt] &= (0x1);
|
|
|
- }
|
|
|
- if (!ctx->Req.root) {
|
|
|
|
|
|
- }
|
|
|
|
|
|
ctx->Ans.result = tmpResult;
|
|
|
ctx->Ans.msg = tmpMsg;
|