void ToString(CString& sRes, CConfig& conf) { CConfig::EntryMapIterator it = conf.BeginEntries(); while (it != conf.EndEntries()) { const CString& sKey = it->first; const VCString& vsEntries = it->second; VCString::const_iterator i = vsEntries.begin(); if (i == vsEntries.end()) sRes += sKey + " <- Error, empty list!\n"; else while (i != vsEntries.end()) { sRes += sKey + "=" + *i + "\n"; ++i; } ++it; } CConfig::SubConfigMapIterator it2 = conf.BeginSubConfigs(); while (it2 != conf.EndSubConfigs()) { std::map<CString, CConfigEntry>::const_iterator it3 = it2->second.begin(); while (it3 != it2->second.end()) { sRes += "->" + it2->first + "/" + it3->first + "\n"; ToString(sRes, *it3->second.m_pSubConfig); sRes += "<-\n"; ++it3; } ++it2; } }
int LoadConf (const char *p_pszConfDir) { int iRetVal = 0; std::string strConfDir; std::string strConfFile; do { strConfDir = p_pszConfDir; if ('/' != strConfDir[strConfDir.length() - 1]) { strConfDir += '/'; } strConfFile = strConfDir + "coam.conf"; iRetVal = g_coConf.LoadConf (strConfFile.c_str()); if (iRetVal) { iRetVal = -1; break; } std::vector<std::string> vectValList; std::vector<std::string>::iterator iterValList; CConfig *pcoTmp; g_coConf.GetParamValue ("location", vectValList); for (iterValList = vectValList.begin(); iterValList != vectValList.end(); ++iterValList) { strConfFile = strConfDir + *iterValList; pcoTmp = new CConfig; iRetVal = pcoTmp->LoadConf (strConfFile.c_str()); if (iRetVal) { iRetVal = -1; break; } g_mapLocationConf.insert (std::make_pair (std::string(*iterValList), pcoTmp)); } if (iRetVal) { break; } } while (0); return iRetVal; }
bool CConfigPra::LoadCfgFile(const char* a_szCfgFile) { if (a_szCfgFile != NULL) { m_strCfgFile = a_szCfgFile; } else { m_strCfgFile = getenv("HOME"); m_strCfgFile += "/ATOM/CFG/ATOM.cfg"; } CConfig clsCF; if (clsCF.Initialize((char*)m_strCfgFile.c_str()) < 0) { return false; } const char* szV = NULL; szV = clsCF.GetGlobalConfigValue("LOG_PATH"); if (szV) m_strLogPath = szV; //szV = clsCF.GetGlobalConfigValue("DB_HOST"); if (szV) m_strDbIp = szV; //szV = clsCF.GetGlobalConfigValue("DB_PORT"); if (szV) m_nDbPort = atoi(szV); //szV = clsCF.GetGlobalConfigValue("DB_USER"); if (szV) m_strDbUser = szV; //szV = clsCF.GetGlobalConfigValue("DB_PASS"); if (szV) m_strDbPasswd = szV; //szV = clsCF.GetGlobalConfigValue("DB_DATABASE"); if (szV) m_strDbName = szV; //szV = clsCF.GetConfigValue("PRA", "VNF_WAITTIME"); if (szV) m_nVnfWaitTime = atoi(szV); return true; }
EXPORT_C gint32 CConfigIterator::Current(CDbEntity ** ppEntity) { if (ppEntity == NULL) return ERROR(ESide_Client, EModule_Db, ECode_Invalid_Param); *ppEntity = NULL; if (m_dbQuery->eof()) return ERROR(ESide_Client, EModule_Db, ECode_Not_Exist); /* fill config table fields */ *ppEntity = new CConfig(m_pEntityDb); if (NULL == *ppEntity) { return ERROR(ESide_Client, EModule_Db, ECode_No_Memory); } CConfig * pConfig = (CConfig*)(*ppEntity); for (int i=0; i<ConfigField_EndFlag; i++) { GString * fieldValue = g_string_new(m_dbQuery->fieldValue(i)); pConfig->SetFieldValue(i, fieldValue); g_string_free(fieldValue, TRUE); } return 0; }
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE , LPWSTR , int ) { CConfig* config = CConfig::get_instance(); if (!config->load()) return 0; using namespace DuiLib; CPaintManagerUI::SetInstance(hInstance); CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + L"\\skin"); HRESULT Hr = ::CoInitialize(nullptr); if (FAILED(Hr)) return 0; CMainWnd *wnd = new CMainWnd(L"MainWnd.xml"); wnd->Create(nullptr, L"player", UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE); wnd->ShowModal(); delete wnd; ::CoUninitialize(); delete config; _CrtDumpMemoryLeaks(); return 0; }
bool Test() { CFile &File = WriteFile(); // Verify that Parse() rewinds the file File.Seek(12); CConfig conf; CString sError; bool res = conf.Parse(File, sError); if (!res) { std::cout << "Error'd out! (" + sError + ")\n"; return false; } if (!sError.empty()) { std::cout << "Non-empty error string!\n"; return false; } CString sOutput; ToString(sOutput, conf); if (sOutput != m_sOutput) { std::cout << "Wrong output\n Expected: " << m_sOutput << "\n Got: " << sOutput << std::endl; return false; } return true; }
void CClient::Run() { Init(); if(!m_sockMain.Socket()) return; if(!m_sockMain.Bind() ) return; if(!m_sockOT.Socket()) return; if(!m_sockOT.Bind() ) return; CConfig* pConfig = CConfig::GetInstance(); if( !m_sockMain.Connect( pConfig->GetAddrPID(ID_SERVER), pConfig->GetPortPID(ID_SERVER) ) ) return; if( !m_sockOT.Connect( pConfig->GetAddrPID(ID_SERVER), pConfig->GetPortPID(ID_SERVER) ) ) return; m_pThreadOT = new COTThread(); m_pRecvThread = new CRecvThread(); m_pThreadOT->Start(); m_pRecvThread->Start(); RunMainThread(); m_pThreadOT->Wait(); m_pRecvThread->Wait(); delete m_pThreadOT; delete m_pRecvThread; Cleanup(); }
void CSemanticJudge::loadAnalysis() { int nValue; string strValue; CConfig *config; config = new CConfig(); if(config->loadConfig(getConfigFile())) { strValue = config->getValue("ANALYSIS", "total"); convertFromString(nValue, strValue); _log("[CSemanticJudge] CSemanticJudge get analysis total: %d", nValue); for(int i = 1; i <= nValue; ++i) { strValue = config->getValue("ANALYSIS", ConvertToString(i)); _log("[CSemanticJudge] CSemanticJudge Get conf: %s conf file: %s", ConvertToString(i).c_str(), strValue.c_str()); if(!strValue.empty()) mapAnalysis[i] = new CAnalysisHandler(strValue.c_str(), this); } } else { _log("[CSemanticJudge] CSemanticJudge Load Configure Fail, File: %s", getConfigFile().c_str()); } delete config; mapSemanticService[0] = new CStory(); for(unsigned int i = 0; i < mapSemanticService.size(); ++i) mapSemanticService[i]->init(); }
int _tmain(int argc, _TCHAR* argv[]) { CConfig pConfig; pConfig.SetEntryAddr( "12345" ); return 0; }
void action_toggle_install() { consoleClear(); CConfig::Mode nextMode = CConfig::Mode::INSTALL_CIA; switch (config.GetMode()) { case CConfig::Mode::DOWNLOAD_CIA: nextMode = CConfig::Mode::INSTALL_CIA; break; case CConfig::Mode::INSTALL_CIA: nextMode = CConfig::Mode::INSTALL_TICKET; break; case CConfig::Mode::INSTALL_TICKET: nextMode = CConfig::Mode::DOWNLOAD_CIA; break; } if (nextMode == CConfig::Mode::INSTALL_TICKET || nextMode == CConfig::Mode::INSTALL_CIA) { if (!bSvcHaxAvailable) { nextMode = CConfig::Mode::DOWNLOAD_CIA; printf(CONSOLE_RED "Kernel access not available.\nCan't enable Install modes.\nYou can only make a CIA.\n" CONSOLE_RESET); wait_key_specific("\nPress A to continue.", KEY_A); } } config.SetMode(nextMode); }
void BuildCmdLine() { const CPath *appPath = config.GetAppPath(); const CString *args = config.GetAppArgs(); cmdLine = static_cast<CString>(*appPath); cmdLine.AppendChar(L' '); cmdLine.Append(*args); }
CConfig* CLibrary::AddConfiguration(char* szConfig) { CConfig* pcConfig; pcConfig = mcConfigs.InsertAfterTail(); pcConfig->Init(szConfig); return pcConfig; }
void TEST_ERROR(const CString& sConfig, const CString& sExpectError) { CFile &File = WriteFile(sConfig); CConfig conf; CString sError; EXPECT_FALSE(conf.Parse(File, sError)); EXPECT_EQ(sExpectError, sError); }
void CManager::init_process() { CConfig config; std::vector<int> vSWPort; std::vector<int> vQWPort; std::vector<int> vSRPort; std::vector<int> vQRPort; std::cout << "********** Process Initialization **********" << std::endl; config.read_process(m_vpart, m_filepath); //lecture des process a créer config.read_communication(m_vpart, m_compath); std::cout << "There are :" << m_vpart.size() << " partitions " << std::endl; std::cout << " ***** Partitions parameters *****" << std::endl; for (unsigned int i = 0; i < m_vpart.size(); i++) { //on vide la mémoire des vectors vSWPort.clear(); std::vector<int>(vSWPort).swap(vSWPort); vQWPort.clear(); std::vector<int>(vQWPort).swap(vQWPort); vSRPort.clear(); std::vector<int>(vSRPort).swap(vSRPort); vQRPort.clear(); std::vector<int>(vQRPort).swap(vQRPort); std::cout << "name Process : " << (m_vpart[i]).nameProcess() << std::endl; std::cout << "path Process : " << (m_vpart[i]).pathProcess() << std::endl; std::cout << "time processing : " << (m_vpart[i]).time() << std::endl; vSWPort = (m_vpart[i]).get_wSport(); for (unsigned int j = 0; j < vSWPort.size(); j++) { std::cout << " can write in sampling port number :" << vSWPort[j] << std::endl; } vQWPort = (m_vpart[i]).get_wQport(); for (unsigned int j = 0; j < vQWPort.size(); j++) { std::cout << " can read in queuing port :" << vQWPort[j] << std::endl; } vSRPort = (m_vpart[i]).get_rSport(); for (unsigned int j = 0; j < vSRPort.size(); j++) { std::cout << " sampling associated partion :" << vSRPort[j] << std::endl; } vQRPort = (m_vpart[i]).get_rQport(); for (unsigned int j = 0; j < vQRPort.size(); j++) { std::cout << " queuing associated partion :" << vQRPort[j] << std::endl; } std::cout << "********** End of process initialization **********" << std::endl; } }
void CConfig::remove(const QString &name, const QString &path) { #ifdef DEBUG qDebug("static CConfig::remove('%s', '%s')", debug_string(name), debug_string(path)); #endif CConfig *c = new CConfig(name, path); c->remove(); delete c; }
void loadConfig() { // Load config, and force mode to DOWNLOAD_CIA if svcHax not available, then resave config.LoadConfig("/CIAngel/config.json"); if (!bSvcHaxAvailable) { config.SetMode(CConfig::Mode::DOWNLOAD_CIA); } config.SaveConfig(); }
//////////////////////////////////////////////////////////////////////////// // XBMC has loaded us into memory, we should set our core values // here and load any settings we may have from our config file // extern "C" void Create(LPDIRECT3DDEVICE8 pd3dDevice, int width, int height, const char* szScreenSaverName) { strcpy(gScrName,szScreenSaverName); gConfig.SetDefaults(); gConfig.LoadSettings(); gRender.m_D3dDevice = pd3dDevice; gRender.m_Width = width; gRender.m_Height= height; }
CRef<CSimpleRebalanceStrategy> CreateSimpleRebalanceStrategy(CConfig& config, const string& driver_name) { return CRef<CSimpleRebalanceStrategy>(new CSimpleRebalanceStrategy( config.GetInt(driver_name, "rebalance_requests", CConfig::eErr_NoThrow, REBALANCE_REQUESTS_DEFAULT), s_SecondsToMilliseconds(config.GetString(driver_name, "rebalance_time", CConfig::eErr_NoThrow, NCBI_AS_STRING(REBALANCE_TIME_DEFAULT)), SECONDS_DOUBLE_TO_MS_UL(REBALANCE_TIME_DEFAULT)))); }
VOID CSciEdit::_InternalInitialize() { _SendSciMessage(SCI_SETCODEPAGE,SC_CP_UTF8); CConfig config; int tabWidth = 4; if (config.Get(_T("SciEdit/Language/Editor/TabWidth"))) { config.GetNode().GetAttribute(_T("tabWidth"),tabWidth); } _SendSciMessage(SCI_SETTABWIDTH,tabWidth); }
int main(int argc, char **argv) { ros::init(argc, argv, "roscir_wheel_test"); CConfig* config = CConfig::getInstance(); string ip = config->getParamValue("wheel.device.server.ip"); ROS_INFO("wheel.server.ip : %s", ip.c_str()); string path = ros::package::getPath("roscir"); ROS_INFO("path: %s", path.c_str()); ROS_INFO("examples"); return -1; }
NM::CDiction::CDiction() { CConfig* pconfig = NM::CConfig::getInstance(); pconfig->getconfigInfo("textquery","distdir",m_distdir);//yuliao dir pconfig->getconfigInfo("textquery","datadir",m_datadir);//fenci dir pconfig->getconfigInfo("textquery","stopdir",m_stopdir);//tingliuci dir pconfig->getconfigInfo("textquery","wordfreqpath",m_wordfreqpath); if(!NLPIR_Init(m_datadir.c_str(),UTF8_CODE)) { std::cout<<"NLPLR Init Fail!"<<std::endl; exit(1); } }
bool Filter(const char *p_pszFilterName, std::string &p_strLocation, std::string &p_strValue) { bool bRetVal = false; int iFnRes; std::map<std::string,CConfig*>::iterator iterLocation; std::vector<std::string> vectValList; std::vector<std::string>::iterator iterValList; CConfig *pcoLocConf; int iValueLen = p_strValue.length(); do { // ищем конфигурацию локации iterLocation = g_mapLocationConf.find (p_strLocation); if (iterLocation == g_mapLocationConf.end()) { UTL_LOG_E(g_coLog, "Location '%s' configuration not found", p_strLocation.c_str()); bRetVal = true; break; } pcoLocConf = iterLocation->second; if (NULL == pcoLocConf) { UTL_LOG_E(g_coLog, "Location '%s' configuration not exists", p_strLocation.c_str()); bRetVal = true; break; } /* выбираем фильтры для локации */ if (0 != pcoLocConf->GetParamValue (p_pszFilterName, vectValList)) { bRetVal = true; break; } // обходим все правила изменения имен сервисов for (iterValList = vectValList.begin(); iterValList != vectValList.end(); ++iterValList) { // если длина значения больше или равна длине значения фильтра if (static_cast<size_t>(iValueLen) >= iterValList->length()) { // сравниваем префикс с началом имени сервиса iFnRes = p_strValue.compare( 0, iterValList->length(), *iterValList ); // если перфикс и начало имени сервиса совпадают if (0 == iFnRes) { bRetVal = true; UTL_LOG_N( g_coLog, "value %s matched to filter %s", p_strValue.c_str(), iterValList->c_str() ); break; } else { UTL_LOG_N( g_coLog, "value %s NOT matched to filter %s(length: %u)", p_strValue.c_str(), iterValList->c_str(), iterValList->length() ); } } } } while (0); return bRetVal; }
void TEST_SUCCESS(const CString& sConfig, const CString& sExpectedOutput) { CFile &File = WriteFile(sConfig); // Verify that Parse() rewinds the file File.Seek(12); CConfig conf; CString sError; EXPECT_TRUE(conf.Parse(File, sError)) << sError; EXPECT_TRUE(sError.empty()) << "Non-empty error string!"; CString sOutput; ToString(sOutput, conf); EXPECT_EQ(sExpectedOutput, sOutput); }
int IniHandler(void* param, const char* section, const char* name, const char* value) { CConfig* config = (CConfig*)param; std::string val = std::string(value); // strip quotes if they exist to allow passwords to begin with a whitespace if(val.length() >= 2 && val[0] == '\"' && val[val.length()-1] == '\"') { val.erase(0, 1); val.erase(val.length() - 1); } config->Set(name, val); return 1; }
bool CEditorWorld::init() { CWorld::init(); // Get zone list from file CConfig cf; cf.load(CEditorApp::instance()->getSetting("/config/world/ZonesDir") + "zones.ini"); m_zoneList = cf.getMultiSetting("Zone"); if( !m_zoneList.empty() ) m_zone->load(m_zoneList[0]); return true; };
int GetAuthorization(const char *login, const char *password) { // printf("incoming login [%s], password [%s]\n", login, password); const char *auth_names[4]; int adm_level=0; auth_names[0]="view"; auth_names[1]="paycheck"; auth_names[2]="control"; auth_names[3]="admin"; sem_wait(&users_lock); for (int i=0; i<4; i++) { const char *tmp=NULL; if ((tmp=users.GetValue(login,auth_names[i]))!=NULL) { char md5_inc[1024]; if (CreateMD5HexSign(password, md5_inc, 1023)==0) { if (strcmp(tmp, md5_inc)==0) adm_level=i+1; } } } sem_post(&users_lock); // printf("returning %i\n", adm_level); return adm_level; }
// Initialize the window and tray icon BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { // prepare for XP style controls InitCommonControls(); // store instance handle and create dialog hInst = hInstance; hDlg = CreateDialog( hInstance, MAKEINTRESOURCE(IDD_DLG_DIALOG), NULL, (DLGPROC)DlgProc); if (!hDlg) { return FALSE; } IntializeNotificationData(); const CPath * imagePath = config.GetOffIconPath(); UINT flags = LR_LOADFROMFILE; HICON icon = (HICON)LoadImage( NULL, *imagePath, IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), flags); niData.hIcon = icon; Shell_NotifyIcon(NIM_ADD, &niData); DestroyIcon(icon); niData.hIcon = NULL; StartProcess(); return TRUE; }
void ProcessGameQueue() { // Create the tickets folder if we're in ticket mode char empty_titleVersion[2] = {0x00, 0x00}; std::vector<game_item>::iterator game = game_queue.begin(); while(aptMainLoop() && game != game_queue.end()) { std::string selected_titleid = (*game).titleid; std::string selected_enckey = (*game).titlekey; std::string selected_name = (*game).name; std::string selected_region = (*game).region; if (config.GetMode() == CConfig::Mode::INSTALL_TICKET) { CreateTicket(selected_titleid, selected_enckey, empty_titleVersion, "/CIAngel/tmp/ticket"); InstallTicket("/CIAngel/tmp/ticket", selected_titleid); } else { Result res = DownloadTitle(selected_titleid, selected_enckey, selected_name, selected_region); if (R_FAILED(res)) { printf("Error processing queue. Returning to menu\n"); break; } } game = game_queue.erase(game); } wait_key_specific("Press A to continue.\n", KEY_A); }
// Search config in the hash table, if it is not there, this config will be // inserted. If inserted, *pCacheConfig will point to the location. // return value // 0 -- not found or can not be pruned // 1 -- find a config that can be pruned in the cache int TryFind(CConfig **arr, CConfig *pConfig, CConfig **pCacheConfig) { *pCacheConfig = NULL; //return 0; int index = pConfig->CalHashValue(); CConfig *p = arr[index]; if (!p) // the config is not found and insert this pConfig to it { #ifdef USE_OWN_CACHE if (usedconfiglength>=MAXUSEDCONFIGSIZE) return 0; CConfig* pNewConfig = newCacheConfig(pConfig->len); if (!pNewConfig) return 0; // cache has been used up, just return; #else if (usedconfiglength>=MAXUSEDCONFIGSIZE) return 0; CConfig* pNewConfig = new CConfig(pConfig->len); assert(pNewConfig); #endif usedconfiglength++; pNewConfig->Copy(pConfig); arr[index] = pNewConfig; *pCacheConfig = pNewConfig; return 0; } if (p->ConfigCmp(pConfig)) return 0; // now the configs are the same if (p->depth <= pConfig->depth) { // if a config hits the hash table with length no less than that in the // table, it cannot be on the path of any optimal solutions not found // yet. Remember if an optimal solution is found, all configs along // the solution path stored in the hash table are released in // Solution_Found() in solver.cpp return 1; } else { p->depth = pConfig->depth; *pCacheConfig = p; return 0; } }
CConfig CIRCNetwork::ToConfig() { CConfig config; if (!m_sNick.empty()) { config.AddKeyValuePair("Nick", m_sNick); } if (!m_sAltNick.empty()) { config.AddKeyValuePair("AltNick", m_sAltNick); } if (!m_sIdent.empty()) { config.AddKeyValuePair("Ident", m_sIdent); } if (!m_sRealName.empty()) { config.AddKeyValuePair("RealName", m_sRealName); } config.AddKeyValuePair("IRCConnectEnabled", CString(GetIRCConnectEnabled())); // Modules CModules& Mods = GetModules(); if (!Mods.empty()) { for (unsigned int a = 0; a < Mods.size(); a++) { CString sArgs = Mods[a]->GetArgs(); if (!sArgs.empty()) { sArgs = " " + sArgs; } config.AddKeyValuePair("LoadModule", Mods[a]->GetModName() + sArgs); } } // Servers for (unsigned int b = 0; b < m_vServers.size(); b++) { config.AddKeyValuePair("Server", m_vServers[b]->GetString()); } // Chans for (unsigned int c = 0; c < m_vChans.size(); c++) { CChan* pChan = m_vChans[c]; if (pChan->InConfig()) { config.AddSubConfig("Chan", pChan->GetName(), pChan->ToConfig()); } } return config; }