bool c_server::LoadConfig() { CMarkupSTL config; if (!config.Load(TS_CONFIG)) return false; //根节点 config.FindElem(); if (config.FindChildElem("server", true)) { config.IntoElem(); if (config.FindChildElem("port", true)) c_config::get_instance()->m_port = atoi(config.GetChildData().c_str()); if (config.FindChildElem("threads", true)) m_threads = atoi(config.GetChildData().c_str()); if (config.FindChildElem("delay", true)) m_delay = atoi(config.GetChildData().c_str()); config.OutOfElem(); } wisdom_IOStream os = new c_ostream_array; loadStorage(os); return true; }
void CXmlConfig::GetServerInfo(std::string &ip, short &port) { CMarkupSTL MarkupXml; MarkupXml.Load(configfile.c_str()); bool bRet = MarkupXml.FindChildElem("port"); assert(bRet); MarkupXml.IntoElem(); port = atoi(MarkupXml.GetData().c_str()); }
bool c_server::LoadConfig() { CMarkupSTL config; if (!config.Load(TS_CONFIG)) return false; //¸ù½Úµã config.FindElem(); if (config.FindChildElem("server", true)) { config.IntoElem(); if (config.FindChildElem("ip", true)) m_ip = config.GetChildData(); if (config.FindChildElem("port", true)) c_config::get_instance()->m_port = atoi(config.GetChildData().c_str()); if (config.FindChildElem("threads", true)) m_threads = atoi(config.GetChildData().c_str()); if (config.FindChildElem("leavedb", true)) m_leavedb = config.GetChildData(); if (config.FindChildElem("cache", true)) m_cache_size = atoi(config.GetChildData().c_str()); if (config.FindChildElem("list_max_count", true)) m_list_max_count = atoi(config.GetChildData().c_str()); if (config.FindChildElem("mlist_max_count", true)) m_mlist_max_count = atoi(config.GetChildData().c_str()); if (config.FindChildElem("seq_valid_time", true)) m_seq_valid_time = atoi(config.GetChildData().c_str()); if (config.FindChildElem("write_buffer_size", true)) m_write_buffer_size = atoi(config.GetChildData().c_str()); if (config.FindChildElem("object_effective", true)) m_object_effective = atoi(config.GetChildData().c_str()); if (config.FindChildElem("seq_clear_time", true)) m_seq_clear_time = atoi(config.GetChildData().c_str()); config.OutOfElem(); } return true; }
void c_server::loadStorage(wisdom_IOStream& os) { CMarkupSTL config; if (!config.Load(TS_CONFIG)) return; c_wlock lock(&m_lock); m_storage.clear(); //根节点 config.FindElem(); while (config.FindChildElem("storage")) { config.IntoElem(); wisdom_storage og = new _storage; og->cb = new _storage_cb; string interval; if (config.FindChildElem("interval", true)) interval = config.GetChildData().c_str(); sscanf(interval.c_str(), "%x#%x", &og->ibegin, &og->iend); if (config.FindChildElem("constr", true)) og->cb->m_constr = config.GetChildData().c_str(); LOG4_INFO("storage begin:" << og->ibegin << "|end:" << og->iend << "|constr:" << og->cb->constr()); os->push(__tos("storage begin:" << og->ibegin << "|end:" << og->iend << "|constr:" << og->cb->constr())); config.OutOfElem(); m_storage.insert(make_pair(c_interval(og->ibegin, og->iend), og)); } return; }
bool CFileOperate::_Load() { UPLOAD_LOG_TYPE upload_load_type = _GetUpLoadLogType(); if (upload_load_type == NAME_SERVER_LOG) { char szPath[255]; sprintf(szPath,"../share_config/share_log_config.xml"); CMarkupSTL oxml; if (!oxml.Load(szPath) ){ USER_LOG_ERROR("cannot load "<<szPath); assert(false); return false; } if (!oxml.FindElem("root") ){ USER_LOG_ERROR("can not find root node "<<szPath); assert(false); return false; } if (!oxml.IntoElem()){ USER_LOG_ERROR("can not into root node "<<szPath); assert(false); return false; } if (!oxml.FindElem("logtype") ){ USER_LOG_ERROR("can not find logtype node "<<szPath); assert(false); return false; } if (!oxml.IntoElem()){ USER_LOG_ERROR("can not into logtype node "<<szPath); assert(false); return false; } log_directory_map log_directory_map_tmp; while (oxml.FindElem("type")) { LogStruct log_struct_tmp; log_struct_tmp.folder_name = oxml.GetAttrib("name"); log_struct_tmp.log_file_head = oxml.GetAttrib("log_file_head"); log_struct_tmp.log_file_trail = oxml.GetAttrib("log_file_trail"); if (!log_struct_tmp.folder_name.empty()) { std::map<std::string,std::string> remote_local_directory; std::string remote_direcotry = "ftp://"; remote_direcotry += CCurlFtpMgr::Instance().GetFtpHost(); remote_direcotry += ":"; remote_direcotry += CCurlFtpMgr::Instance().GetFtpPort(); remote_direcotry += "/"; remote_direcotry += "name_server/"; remote_direcotry += log_struct_tmp.folder_name; remote_direcotry += "/"; std::string local_directory = "..\\"; local_directory += log_struct_tmp.folder_name; local_directory += "\\"; remote_local_directory.insert(std::pair<std::string,std::string>(remote_direcotry,local_directory)); log_directory_map_tmp.insert(std::pair<LogStruct,std::map<std::string,std::string>>(log_struct_tmp,remote_local_directory)); } } m_log_directory.insert(std::pair<UPLOAD_LOG_TYPE,log_directory_map>(upload_load_type,log_directory_map_tmp)); oxml.OutOfElem(); oxml.OutOfElem(); } else if (upload_load_type == LG_SERVER_LOG) { std::string lg_id = ""; { char szPath[255]; sprintf(szPath,"../config/lg_config.xml"); CMarkupSTL oxml; if (!oxml.Load(szPath) ){ USER_LOG_ERROR("cannot load "<<szPath); assert(false); return false; } if (!oxml.FindElem("root") ){ USER_LOG_ERROR("can not find root node "<<szPath); assert(false); return false; } if (!oxml.IntoElem()){ USER_LOG_ERROR("can not into root node "<<szPath); assert(false); return false; } if (!oxml.FindElem("loginserver") ){ USER_LOG_ERROR("can not find loginserver node "<<szPath); assert(false); return false; } if (!oxml.IntoElem()){ USER_LOG_ERROR("can not into loginserver node "<<szPath); assert(false); return false; } if (!oxml.FindElem("id") ){ USER_LOG_ERROR("can not find id node "<<szPath); assert(false); return false; } lg_id = oxml.GetAttrib("value"); } { char szPath[255]; sprintf(szPath,"../share_config/share_log_config.xml"); CMarkupSTL oxml; if (!oxml.Load(szPath) ){ USER_LOG_ERROR("cannot load "<<szPath); assert(false); return false; } if (!oxml.FindElem("root") ){ USER_LOG_ERROR("can not find root node "<<szPath); assert(false); return false; } if (!oxml.IntoElem()){ USER_LOG_ERROR("can not into root node "<<szPath); assert(false); return false; } if (!oxml.FindElem("logtype") ){ USER_LOG_ERROR("can not find logtype node "<<szPath); assert(false); return false; } if (!oxml.IntoElem()){ USER_LOG_ERROR("can not into logtype node "<<szPath); assert(false); return false; } log_directory_map log_directory_map_tmp; while (oxml.FindElem("type")) { LogStruct log_struct_tmp; log_struct_tmp.folder_name = oxml.GetAttrib("name"); log_struct_tmp.log_file_head = oxml.GetAttrib("log_file_head"); log_struct_tmp.log_file_trail = oxml.GetAttrib("log_file_trail"); if (!log_struct_tmp.folder_name.empty()) { std::map<std::string,std::string> remote_local_directory; std::string remote_direcotry = "ftp://"; remote_direcotry += CCurlFtpMgr::Instance().GetFtpHost(); remote_direcotry += ":"; remote_direcotry += CCurlFtpMgr::Instance().GetFtpPort(); remote_direcotry += "/"; remote_direcotry += "area_"; remote_direcotry += lg_id.substr(0,1); remote_direcotry += "/"; remote_direcotry += "lg_"; remote_direcotry += lg_id; remote_direcotry += "/"; remote_direcotry += log_struct_tmp.folder_name; remote_direcotry += "/"; std::string local_directory = "..\\"; local_directory += log_struct_tmp.folder_name; local_directory += "\\"; remote_local_directory.insert(std::pair<std::string,std::string>(remote_direcotry,local_directory)); log_directory_map_tmp.insert(std::pair<LogStruct,std::map<std::string,std::string>>(log_struct_tmp,remote_local_directory)); } } m_log_directory.insert(std::pair<UPLOAD_LOG_TYPE,log_directory_map>(upload_load_type,log_directory_map_tmp)); oxml.OutOfElem(); oxml.OutOfElem(); } } else if (upload_load_type == GS_SERVER_LOG) { std::string gs_id = ""; { char szPath[255]; sprintf(szPath,"../config/gs_config.xml"); CMarkupSTL oxml; if (!oxml.Load(szPath) ){ USER_LOG_ERROR("cannot load "<<szPath); assert(false); return false; } if (!oxml.FindElem("root") ){ USER_LOG_ERROR("can not find root node "<<szPath); assert(false); return false; } if (!oxml.IntoElem()){ USER_LOG_ERROR("can not into root node "<<szPath); assert(false); return false; } if (!oxml.FindElem("gameserver") ){ USER_LOG_ERROR("can not find gameserver node "<<szPath); assert(false); return false; } if (!oxml.IntoElem()){ USER_LOG_ERROR("can not into gameserver node "<<szPath); assert(false); return false; } if (!oxml.FindElem("id") ){ USER_LOG_ERROR("can not find id node "<<szPath); assert(false); return false; } gs_id = oxml.GetAttrib("value"); } { char szPath[255]; sprintf(szPath,"../share_config/share_log_config.xml"); CMarkupSTL oxml; if (!oxml.Load(szPath) ){ USER_LOG_ERROR("cannot load "<<szPath); assert(false); return false; } if (!oxml.FindElem("root") ){ USER_LOG_ERROR("can not find root node "<<szPath); assert(false); return false; } if (!oxml.IntoElem()){ USER_LOG_ERROR("can not into root node "<<szPath); assert(false); return false; } if (!oxml.FindElem("logtype") ){ USER_LOG_ERROR("can not find logtype node "<<szPath); assert(false); return false; } if (!oxml.IntoElem()){ USER_LOG_ERROR("can not into logtype node "<<szPath); assert(false); return false; } log_directory_map log_directory_map_tmp; while (oxml.FindElem("type")) { LogStruct log_struct_tmp; log_struct_tmp.folder_name = oxml.GetAttrib("name"); log_struct_tmp.log_file_head = oxml.GetAttrib("log_file_head"); log_struct_tmp.log_file_trail = oxml.GetAttrib("log_file_trail"); if (!log_struct_tmp.folder_name.empty()) { std::map<std::string,std::string> remote_local_directory; std::string remote_direcotry = "ftp://"; remote_direcotry += CCurlFtpMgr::Instance().GetFtpHost(); remote_direcotry += ":"; remote_direcotry += CCurlFtpMgr::Instance().GetFtpPort(); remote_direcotry += "/"; remote_direcotry += "area_"; remote_direcotry += gs_id.substr(0,1); remote_direcotry += "/"; remote_direcotry += "gs_"; remote_direcotry += gs_id; remote_direcotry += "/"; remote_direcotry += log_struct_tmp.folder_name; remote_direcotry += "/"; std::string local_directory = "..\\"; local_directory += log_struct_tmp.folder_name; local_directory += "\\"; remote_local_directory.insert(std::pair<std::string,std::string>(remote_direcotry,local_directory)); log_directory_map_tmp.insert(std::pair<LogStruct,std::map<std::string,std::string>>(log_struct_tmp,remote_local_directory)); } } m_log_directory.insert(std::pair<UPLOAD_LOG_TYPE,log_directory_map>(upload_load_type,log_directory_map_tmp)); oxml.OutOfElem(); oxml.OutOfElem(); } } return true; }