mirror of https://github.com/tp4a/teleport
fix ini parser not work when new line flag '\r\n' and '\n' in the same file.
parent
2fac0b76a5
commit
4d5007e413
|
@ -267,32 +267,66 @@ bool ExIniFile::LoadFromMemory(const ex_wstr& strData, bool bClearOld)
|
|||
ex_wstr strValue(L"");
|
||||
|
||||
ex_wstr strLine(L"");
|
||||
ex_wstr::size_type pos = ex_wstr::npos;
|
||||
ex_wstr::size_type posCR = ex_wstr::npos;
|
||||
ex_wstr::size_type posLF = ex_wstr::npos;
|
||||
for (;;)
|
||||
{
|
||||
pos = strAll.find(L"\r\n");
|
||||
if (ex_wstr::npos == pos)
|
||||
{
|
||||
pos = strAll.find(L'\n');
|
||||
if (ex_wstr::npos == pos)
|
||||
{
|
||||
if (strAll.empty())
|
||||
break;
|
||||
posCR = ex_wstr::npos;
|
||||
posLF = ex_wstr::npos;
|
||||
posCR = strAll.find(L"\r");
|
||||
posLF = strAll.find(L"\n");
|
||||
int tttt = 0;
|
||||
|
||||
strLine = strAll;
|
||||
strAll.clear();
|
||||
if(posCR == ex_wstr::npos && posLF == ex_wstr::npos) {
|
||||
if (strAll.empty())
|
||||
break;
|
||||
strLine = strAll;
|
||||
strAll.clear();
|
||||
} else if(posCR != ex_wstr::npos && posLF != ex_wstr::npos) {
|
||||
if(posLF != posCR + 1) {
|
||||
if(posLF < posCR) {
|
||||
strLine.assign(strAll, 0, posLF);
|
||||
strAll.erase(0, posLF + 1);
|
||||
} else {
|
||||
strLine.assign(strAll, 0, posCR);
|
||||
strAll.erase(0, posCR + 1);
|
||||
}
|
||||
} else {
|
||||
strLine.assign(strAll, 0, posCR);
|
||||
strAll.erase(0, posCR + 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
strLine.assign(strAll, 0, pos);
|
||||
strAll.erase(0, pos + 1);
|
||||
} else {
|
||||
if(posCR != ex_wstr::npos) {
|
||||
strLine.assign(strAll, 0, posCR);
|
||||
strAll.erase(0, posCR + 1);
|
||||
} else {
|
||||
strLine.assign(strAll, 0, posLF);
|
||||
strAll.erase(0, posLF + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strLine.assign(strAll, 0, pos);
|
||||
strAll.erase(0, pos + 2);
|
||||
}
|
||||
|
||||
// if (ex_wstr::npos == pos)
|
||||
// {
|
||||
// pos = strAll.find(L'\n');
|
||||
// if (ex_wstr::npos == pos)
|
||||
// {
|
||||
// if (strAll.empty())
|
||||
// break;
|
||||
//
|
||||
// strLine = strAll;
|
||||
// strAll.clear();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// strLine.assign(strAll, 0, pos);
|
||||
// strAll.erase(0, pos + 1);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// strLine.assign(strAll, 0, pos);
|
||||
// strAll.erase(0, pos + 2);
|
||||
// }
|
||||
|
||||
if (ex_only_white_space(strLine))
|
||||
continue;
|
||||
|
|
|
@ -69,6 +69,9 @@ bool ExThreadBase::stop(void)
|
|||
|
||||
EXLOGV("[thread] wait thread [%s] end.\n", m_thread_name.c_str());
|
||||
|
||||
if(m_handle == 0)
|
||||
return true;
|
||||
|
||||
#ifdef EX_OS_WIN32
|
||||
if (WaitForSingleObject(m_handle, INFINITE) != WAIT_OBJECT_0)
|
||||
{
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
<file url="file://$PROJECT_DIR$/../common/libex/src/ex_ini.cpp" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/../common/libex/src/ex_log.cpp" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/../common/libex/src/ex_util.cpp" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/../common/pyshell/src/pys_api.cpp" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/../common/pyshell/src/pys_core.cpp" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/../common/teleport/teleport_const.h" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_core/common/base_env.h" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_core/common/base_record.cpp" charset="GBK" />
|
||||
|
@ -26,8 +28,6 @@
|
|||
<file url="file://$PROJECT_DIR$/tp_core/core/ts_session.h" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_core/core/ts_web_rpc.cpp" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_core/core/ts_web_rpc.h" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_core/protocol/rdp/rdp_recorder.h" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_core/protocol/rdp/rdp_session.h" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_core/protocol/ssh/ssh_proxy.cpp" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_core/protocol/ssh/ssh_proxy.h" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_core/protocol/ssh/ssh_recorder.cpp" charset="GBK" />
|
||||
|
|
|
@ -76,8 +76,10 @@ bool TsEnv::init(bool load_config)
|
|||
{
|
||||
m_replay_path = replay_path;
|
||||
}
|
||||
ex_mkdirs(m_replay_path);
|
||||
|
||||
ex_wstr log_file;
|
||||
|
||||
ex_wstr log_file;
|
||||
if (!ps->GetStr(L"log-file", log_file))
|
||||
{
|
||||
EXLOG_FILE(L"tpcore.log", log_path.c_str());
|
||||
|
@ -99,15 +101,15 @@ bool TsEnv::init(bool load_config)
|
|||
}
|
||||
|
||||
int log_level = EX_LOG_LEVEL_INFO;
|
||||
if (ps->GetInt(L"log-level", log_level))
|
||||
{
|
||||
EXLOG_LEVEL(log_level);
|
||||
}
|
||||
ps->GetInt(L"log-level", log_level, EX_LOG_LEVEL_INFO);
|
||||
EXLOG_LEVEL(log_level);
|
||||
|
||||
int debug_mode = 0;
|
||||
ps->GetInt(L"debug-mode", debug_mode, 0);
|
||||
if (debug_mode == 1)
|
||||
if (debug_mode == 1) {
|
||||
EXLOG_LEVEL(EX_LOG_LEVEL_DEBUG);
|
||||
EXLOG_DEBUG(true);
|
||||
}
|
||||
|
||||
ex_wstr tmp;
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ TsHttpRpc::~TsHttpRpc()
|
|||
|
||||
void TsHttpRpc::_thread_loop(void)
|
||||
{
|
||||
EXLOGV("[core] TeleportServer-RPC ready on %s:%d\n", m_host_ip.c_str(), m_host_port);
|
||||
EXLOGI("[core] TeleportServer-RPC ready on %s:%d\n", m_host_ip.c_str(), m_host_port);
|
||||
|
||||
while (!m_stop_flag)
|
||||
{
|
||||
|
|
|
@ -80,7 +80,7 @@ void SshProxy::timer() {
|
|||
|
||||
void SshProxy::_thread_loop()
|
||||
{
|
||||
EXLOGV("[ssh] TeleportServer-SSH ready on %s:%d\n", m_host_ip.c_str(), m_host_port);
|
||||
EXLOGI("[ssh] TeleportServer-SSH ready on %s:%d\n", m_host_ip.c_str(), m_host_port);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
|
|
@ -100,17 +100,15 @@ bool TsEnv::init(bool load_config)
|
|||
int log_level = EX_LOG_LEVEL_INFO;
|
||||
if (ps->GetInt(L"log-level", log_level))
|
||||
{
|
||||
// EXLOGV("[tpweb] log-level: %d\n", log_level);
|
||||
EXLOG_LEVEL(log_level);
|
||||
}
|
||||
|
||||
int debug_mode = 0;
|
||||
if (ps->GetInt(L"debug-mode", debug_mode))
|
||||
{
|
||||
// EXLOGV("[tpweb] debug-mode: %d\n", debug_mode);
|
||||
// EXLOG_LEVEL(log_level);
|
||||
if (1 == debug_mode) {
|
||||
EXLOG_LEVEL(EX_LOG_LEVEL_DEBUG);
|
||||
EXLOG_LEVEL(EX_LOG_LEVEL_DEBUG);
|
||||
EXLOG_DEBUG(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue