|
|
@@ -6,6 +6,7 @@
|
|
|
#include <stdio.h>
|
|
|
#include <stdlib.h>
|
|
|
#include "fileutil.h"
|
|
|
+#include "iniutil.h"
|
|
|
#include "CommEntityUtil.hpp"
|
|
|
#include "CommEntityRestful.hpp"
|
|
|
#include "SpUtility.h"
|
|
|
@@ -1167,3 +1168,55 @@ void CAccessAuthFSM::GetNetMsg(SpReqAnsContext<AccessAuthService_GetNetMsg_Req,
|
|
|
|
|
|
ctx->Answer(Error_Succeed);
|
|
|
}
|
|
|
+
|
|
|
+CSimpleStringA CAccessAuthFSM::GetOsVersion()
|
|
|
+{
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+ CSimpleStringA runInfoPath;
|
|
|
+ ErrorCodeEnum eErr = GetEntityBase()->GetFunction()->GetPath("runinfo", runInfoPath);
|
|
|
+ if (eErr != Error_Succeed) {
|
|
|
+ DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("GetPath runinfo error=%s.", SpStrError(eErr));
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ runInfoPath += "\\runcfg\\osverion";
|
|
|
+ ifstream is;
|
|
|
+ is.open(runInfoPath.GetData(), ios::binary);
|
|
|
+ if (!is.is_open())
|
|
|
+ {
|
|
|
+ DWORD dwErr = GetLastError();
|
|
|
+ DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("open runcfg\\osverion file failed. [%d]", dwErr);
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ string line;
|
|
|
+ while (!is.eof()) {
|
|
|
+ getline(is, line);
|
|
|
+ int start = line.find("版本");
|
|
|
+ if (start != string::npos)
|
|
|
+ //return CSimpleStringA(line.substr(start + 5, line.length() - start - 7).c_str());
|
|
|
+ return CSimpleStringA(line.c_str());
|
|
|
+ else
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+#else
|
|
|
+ std::map<std::string, std::string> osInfo;
|
|
|
+ const char filePath[] = "/etc/os-version";
|
|
|
+ char tmp[33];
|
|
|
+ memset(tmp, 0, 33);
|
|
|
+ inifile_read_str_s("Version", "SystemName", "unknown", tmp, 32, filePath);
|
|
|
+ osInfo["SystemName"] = tmp;
|
|
|
+ memset(tmp, 0, 33);
|
|
|
+ inifile_read_str_s("Version", "ProductType", "unknown", tmp, 32, filePath);
|
|
|
+ osInfo["ProductType"] = tmp;
|
|
|
+ memset(tmp, 0, 33);
|
|
|
+ inifile_read_str_s("Version", "MajorVersion", "unknown", tmp, 32, filePath);
|
|
|
+ osInfo["MajorVersion"] = tmp;
|
|
|
+ memset(tmp, 0, 33);
|
|
|
+ inifile_read_str_s("Version", "MinorVersion", "unknown", tmp, 32, filePath);
|
|
|
+ osInfo["MinorVersion"] = tmp;
|
|
|
+ memset(tmp, 0, 33);
|
|
|
+ inifile_read_str_s("Version", "OsBuild", "unknown", tmp, 32, filePath);
|
|
|
+ osInfo["OsBuild"] = tmp;
|
|
|
+ return generateJsonStr(osInfo).second.c_str();
|
|
|
+#endif
|
|
|
+}
|