Skip to content

Commit 8a059fc

Browse files
committed
modify:detach version list from main configure
1 parent e5cc100 commit 8a059fc

File tree

6 files changed

+94
-2
lines changed

6 files changed

+94
-2
lines changed

XEngine_Source/XEngine_ModuleConfigure/ModuleConfig_Define.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,23 @@ extern "C" XLONG ModuleConfigure_GetLastError(int* pInt_ErrorCode = NULL);
134134
意思:是否成功
135135
备注:
136136
*********************************************************************/
137-
extern "C" bool ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XENGINE_SERVICECONFIG* pSt_ServerConfig);
137+
extern "C" bool ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XENGINE_SERVICECONFIG* pSt_ServerConfig);
138+
/********************************************************************
139+
函数名称:ModuleConfigure_Json_Versions
140+
函数功能:读取版本列表配置
141+
参数.一:lpszConfigFile
142+
In/Out:In
143+
类型:常量字符指针
144+
可空:N
145+
意思:输入要读取的配置文件
146+
参数.二:pSt_ServerConfig
147+
In/Out:Out
148+
类型:数据结构指针
149+
可空:N
150+
意思:输出服务配置信息
151+
返回值
152+
类型:逻辑型
153+
意思:是否成功
154+
备注:
155+
*********************************************************************/
156+
extern "C" bool ModuleConfigure_Json_Versions(LPCXSTR lpszConfigFile, XENGINE_SERVICECONFIG* pSt_ServerConfig);

XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,67 @@ bool CModuleConfigure_Json::ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XE
182182
pSt_ServerConfig->st_XReport.bEnable = st_JsonReport["bEnable"].asBool();
183183
_tcsxcpy(pSt_ServerConfig->st_XReport.tszServiceName, st_JsonReport["tszServiceName"].asCString());
184184
_tcsxcpy(pSt_ServerConfig->st_XReport.tszAPIUrl, st_JsonReport["tszAPIUrl"].asCString());
185+
return true;
186+
}
187+
/********************************************************************
188+
函数名称:ModuleConfigure_Json_Versions
189+
函数功能:读取版本列表配置
190+
参数.一:lpszConfigFile
191+
In/Out:In
192+
类型:常量字符指针
193+
可空:N
194+
意思:输入要读取的配置文件
195+
参数.二:pSt_ServerConfig
196+
In/Out:Out
197+
类型:数据结构指针
198+
可空:N
199+
意思:输出服务配置信息
200+
返回值
201+
类型:逻辑型
202+
意思:是否成功
203+
备注:
204+
*********************************************************************/
205+
bool CModuleConfigure_Json::ModuleConfigure_Json_Versions(LPCXSTR lpszConfigFile, XENGINE_SERVICECONFIG* pSt_ServerConfig)
206+
{
207+
Config_IsErrorOccur = false;
208+
209+
if ((NULL == lpszConfigFile) || (NULL == pSt_ServerConfig))
210+
{
211+
Config_IsErrorOccur = true;
212+
Config_dwErrorCode = ERROR_MODULE_CONFIGURE_JSON_PARAMENT;
213+
return false;
214+
}
215+
Json::Value st_JsonRoot;
216+
JSONCPP_STRING st_JsonError;
217+
Json::CharReaderBuilder st_JsonBuilder;
218+
//读取配置文件所有内容到缓冲区
219+
FILE* pSt_File = _xtfopen(lpszConfigFile, _X("rb"));
220+
if (NULL == pSt_File)
221+
{
222+
Config_IsErrorOccur = true;
223+
Config_dwErrorCode = ERROR_MODULE_CONFIGURE_JSON_OPENFILE;
224+
return false;
225+
}
226+
size_t nCount = 0;
227+
XCHAR tszMsgBuffer[4096];
228+
while (1)
229+
{
230+
size_t nRet = fread(tszMsgBuffer + nCount, 1, 2048, pSt_File);
231+
if (nRet <= 0)
232+
{
233+
break;
234+
}
235+
nCount += nRet;
236+
}
237+
fclose(pSt_File);
238+
//开始解析配置文件
239+
std::unique_ptr<Json::CharReader> const pSt_JsonReader(st_JsonBuilder.newCharReader());
240+
if (!pSt_JsonReader->parse(tszMsgBuffer, tszMsgBuffer + nCount, &st_JsonRoot, &st_JsonError))
241+
{
242+
Config_IsErrorOccur = true;
243+
Config_dwErrorCode = ERROR_MODULE_CONFIGURE_JSON_PARSE;
244+
return false;
245+
}
185246
//版本列表
186247
if (st_JsonRoot["XVer"].empty())
187248
{

XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class CModuleConfigure_Json
1818
~CModuleConfigure_Json();
1919
public:
2020
bool ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XENGINE_SERVICECONFIG* pSt_ServerConfig);
21+
bool ModuleConfigure_Json_Versions(LPCXSTR lpszConfigFile, XENGINE_SERVICECONFIG* pSt_ServerConfig);
2122
protected:
2223
private:
2324
};

XEngine_Source/XEngine_ModuleConfigure/XEngine_ModuleConfigure.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ LIBRARY
33
EXPORTS
44
ModuleConfigure_GetLastError
55

6-
ModuleConfigure_Json_File
6+
ModuleConfigure_Json_File
7+
ModuleConfigure_Json_Versions

XEngine_Source/XEngine_ModuleConfigure/pch.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ extern "C" XLONG ModuleConfigure_GetLastError(int* pInt_ErrorCode)
3232
extern "C" bool ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XENGINE_SERVICECONFIG * pSt_ServerConfig)
3333
{
3434
return m_ConfigJson.ModuleConfigure_Json_File(lpszConfigFile, pSt_ServerConfig);
35+
}
36+
extern "C" bool ModuleConfigure_Json_Versions(LPCXSTR lpszConfigFile, XENGINE_SERVICECONFIG * pSt_ServerConfig)
37+
{
38+
return m_ConfigJson.ModuleConfigure_Json_Versions(lpszConfigFile, pSt_ServerConfig);
3539
}

XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_Configure.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@
1313
bool XEngine_Configure_Parament(int argc, char** argv)
1414
{
1515
LPCXSTR lpszServiceCfg = _X("./XEngine_Config/XEngine_Config.json");
16+
LPCXSTR lpszServiceVersion = _X("./XEngine_Config/XEngine_Version.json");
1617

1718
if (!ModuleConfigure_Json_File(lpszServiceCfg, &st_ServiceConfig))
1819
{
1920
printf("解析配置文件失败,ModuleConfigure_Json_File:%lX", ModuleConfigure_GetLastError());
2021
return false;
2122
}
23+
if (!ModuleConfigure_Json_Versions(lpszServiceVersion, &st_ServiceConfig))
24+
{
25+
printf("解析配置文件失败,ModuleConfigure_Json_Versions:%lX", ModuleConfigure_GetLastError());
26+
return false;
27+
}
2228
st_ServiceConfig.bDebug = true;
2329

2430
for (int i = 0; i < argc; i++)

0 commit comments

Comments
 (0)