void ConfigExperimentFromFile(char iniFile[255]) { FILE *chk; if (fopen_s(&chk,iniFile,"r")!=0) {printf("Error: Could not find ini file.\a\n"); exit(1);} char s[255]; // configure physical properties { GetPrivateProfileString("physical","little_g","9.8",s,255,iniFile); gDefaultGravity=NxVec3(0,-atof(s),0); bGravity=true; GetPrivateProfileString("physical","big_G","1",s,255,iniFile); gUniversalBigG=atof(s); } // configure special materials { GetPrivateProfileString("material","cell_restitution","0.5",s,255,iniFile); gCellMatParam[0]=atof(s); GetPrivateProfileString("material","cell_friction","0.5",s,255,iniFile); gCellMatParam[1]=atof(s); GetPrivateProfileString("material","lander_upside_restitution","0.5",s,255,iniFile); gLanderUpMatParam[0]=atof(s); GetPrivateProfileString("material","lander_upside_friction","0.5",s,255,iniFile); gLanderUpMatParam[1]=atof(s); GetPrivateProfileString("material","lander_downside_restitution","0.5",s,255,iniFile); gLanderDownMatParam[0]=atof(s); GetPrivateProfileString("material","lander_downside_friction","0.5",s,255,iniFile); gLanderDownMatParam[1]=atof(s); } // read experiment-specific parameters { GetPrivateProfileString("experiment","experiment_type","NULL",s,255,iniFile); if (strcmp(s,"lander")==0) gExperimentType=LANDER; else if (strcmp(s,"lay_substrate")==0) gExperimentType=LAY_SUBSTRATE; else gExperimentType=BAD_EXPERIMENT_TYPE; GetPrivateProfileString("experiment","rubble_type","",s,255,iniFile); if (strcmp(s,"boxes")==0) gRubbleType=BOXES; else if (strcmp(s,"spheres")==0) gRubbleType=SPHERES; else if (strcmp(s,"icosahedra")==0) gRubbleType=ICOSAHEDRA; else if (strcmp(s,"tetrahedra")==0) gRubbleType=TETRAHEDRA; else if (strcmp(s,"mixed")==0) gRubbleType=MIXED; else if (strcmp(s,"convex")==0) gRubbleType=CONVEX_POLYHEDRA; else if (strcmp(s,"d12")==0) gRubbleType=D12; else if (strcmp(s,"capsules")==0) gRubbleType=CAPSULES; else if (strcmp(s,"mixed")==0) gRubbleType=MIXED; else gRubbleType=BAD_RUBBLE_TYPE; // Lander parameters GetPrivateProfileString("experiment","lander_type","",s,255,iniFile); if (strcmp(s,"capsule")==0) gLanderType=CAPSULE_LANDER; else if (strcmp(s,"sphere")==0) gLanderType=SPHERE_LANDER; else if (strcmp(s,"shaped_charge")==0) gLanderType=SHAPED_CHARGE; else if (strcmp(s,"roly_poly")==0) gLanderType=ROLY_POLY; else if (strcmp(s,"cubesat")==0) gLanderType=CUBESAT; else gLanderType=BAD_LANDER_TYPE; GetPrivateProfileString("experiment","lander_size.w","0",s,255,iniFile); gLanderSize.x=atof(s); GetPrivateProfileString("experiment","lander_size.h","0",s,255,iniFile); gLanderSize.y=atof(s); GetPrivateProfileString("experiment","lander_size.d","0",s,255,iniFile); gLanderSize.z=atof(s); if (gLanderType==ROLY_POLY) { GetPrivateProfileString("experiment","roly_poly_radius","0",s,255,iniFile); gLanderSize.x=atof(s); GetPrivateProfileString("experiment","roly_poly_offset","0",s,255,iniFile); gLanderSize.y=atof(s); GetPrivateProfileString("experiment","roly_poly_hemisphere_ratio","1",s,255,iniFile); gLanderSize.z=atof(s); GetPrivateProfileString("experiment","roly_poly_weight_ratio","0",s,255,iniFile); gRPWeight=atof(s); } GetPrivateProfileString("experiment","lander_mass","0",s,255,iniFile); gLanderMass=atof(s); GetPrivateProfileString("experiment","lander_mass_ratio","1",s,255,iniFile); gLanderMassRatio=atof(s); GetPrivateProfileString("experiment","landing_roughness","0",s,255,iniFile); gLandingRoughness=atof(s); GetPrivateProfileString("experiment","vibrator_amplitude","0",s,255,iniFile); gVibrateAmp=atof(s); GetPrivateProfileString("experiment","vibrator_frequency","0",s,255,iniFile); gVibrateFreq=atof(s); // rubble parameters RUBBLE_SIZE=GetPrivateProfileInt("experiment","rubble_size",0,iniFile); GetPrivateProfileString("experiment","grain_size","0",s,255,iniFile); gRainSize=atof(s); GetPrivateProfileString("experiment","gsd.amin","0.1",s,255,iniFile); gsd[0]=atof(s); GetPrivateProfileString("experiment","gsd.amax","1.0",s,255,iniFile); gsd[1]=atof(s); GetPrivateProfileString("experiment","gsd.alpha","4.0",s,255,iniFile); gsd[2]=atof(s); GetPrivateProfileString("experiment","gravitator_threshold_mass","0",s,255,iniFile); gRavitatorThresholdMass=atof(s); GetPrivateProfileString("experiment","cell_size","1",s,255,iniFile); gCellSize=atof(s); GetPrivateProfileString("experiment","grain_density","1000",s,255,iniFile); gDefaultDensity=atof(s); gDefaultNumVerts=GetPrivateProfileInt("experiment","num_verts",12,iniFile); GetPrivateProfileString("experiment","vertex_spacing","10",s,255,iniFile); gDefaultGam=atof(s); GetPrivateProfileString("experiment","uniform_rubble","false",s,255,iniFile); if (strcmp(s,"true")==0) isUniformRubble=true; else isUniformRubble=false; GetPrivateProfileString("experiment","control_mode","manual",s,255,iniFile); if (strcmp(s,"manual")==0) isManualControl=true; else isManualControl=false; } }
//005535a0 -> 100% int CMasterLevelSystem::MasterLevelUp(LPOBJ lpObj, __int64 iAddExp, bool bEventMapReward, int iMonsterType) //OK { if( !this->IsMasterLevelUser(lpObj) ) { return false; } int m_maxMasterLevel = GetPrivateProfileInt("Common", "MaxMasterLevel", 200, gDirPath.GetNewPath("MasterSystem.cfg")); int numCoded = 201; if (m_maxMasterLevel >= numCoded || m_maxMasterLevel <= 0){ int m_maxMasterLevel = 200; } // ---- if (lpObj->m_nMasterLevel >= m_maxMasterLevel) { GCServerMsgStringSend(lMsg.Get(1136), lpObj->m_Index, 1); return false; } // ---- if( bEventMapReward ) //-> New { iAddExp = iAddExp; //??? } else { #ifdef GENS if( gGensSystem.IsMapBattleZone(lpObj->MapNumber) ) //-> Original g_GensSystem maybe { iAddExp = iAddExp * (this->m_fAddExpRate + g_MLBattleZoneAddExp); } else { iAddExp = iAddExp * this->m_fAddExpRate; } #else iAddExp = iAddExp * this->m_fAddExpRate; #endif } // ---- if( lpObj->m_MPSkillOpt.MpsPlusExp > 0 ) { iAddExp += iAddExp * lpObj->m_MPSkillOpt.MpsPlusExp / 100; } // ---- if( iAddExp > 0 ) { gObjSetExpPetItem(lpObj->m_Index, iAddExp); // ---- LogAddTD("ML Experience : Map[%d]-(%d,%d) [%s][%s](%d) %I64d %I64d MonsterIndex : %d", //-> Updated lpObj->MapNumber, lpObj->X, lpObj->Y, lpObj->AccountID,lpObj->Name, lpObj->m_nMasterLevel, lpObj->m_i64MasterLevelExp, iAddExp, iMonsterType); // ---- if( iAddExp + lpObj->m_i64MasterLevelExp >= lpObj->m_i64NextMasterLevelExp ) { iAddExp = 0; // ----- int m_masterPointsPerLvl = GetPrivateProfileInt("Common", "MasterPointsPerLvl", 100, gDirPath.GetNewPath("MasterSystem.cfg")); int numCodeds = 101; if (m_maxMasterLevel >= numCodeds) { int m_masterPointsPerLvl = 1; } // ----- lpObj->m_i64MasterLevelExp = lpObj->m_i64NextMasterLevelExp; lpObj->m_nMasterLevel++; lpObj->m_iMasterLevelPoint += m_masterPointsPerLvl; //-> In future can use it for change ml point per level) // ----- gObjCalCharacter(lpObj->m_Index); // ----- lpObj->MaxLife += DCInfo.DefClass[ lpObj->Class ].LevelLife; lpObj->MaxMana += DCInfo.DefClass[ lpObj->Class ].LevelMana; lpObj->Life = lpObj->AddLife + lpObj->MaxLife; lpObj->Mana = lpObj->AddMana + lpObj->MaxMana; // ----- gObjCalcShieldPoint(lpObj); lpObj->iShield = lpObj->iAddShield + lpObj->iMaxShield; // ----- this->gObjNextMLExpCal(lpObj); // ---- gObjCalcMaxLifePower(lpObj->m_Index); gObjSetBP(lpObj->m_Index); GJSetCharacterInfo(lpObj, lpObj->m_Index, 0, 0); this->GCMasterLevelUpInfo(lpObj); GCReFillSend(lpObj->m_Index, lpObj->Life, 0xFF, 0, lpObj->iShield); GCManaSend(lpObj->m_Index, lpObj->Mana, 0xFF, 0, lpObj->BP); //-> Original name ->_BP } else { lpObj->m_i64MasterLevelExp += iAddExp; } // ---- GCSendExp_INT64(lpObj->m_Index, 65535, iAddExp, 0, 0); } // ---- return true; }
void cLuckyPenny::Read(char * FilePath) { this->Enabled = GetPrivateProfileInt("Common", "SCFLuckyPennyEnabled",0, FilePath); LogAddTD("[SCFLuckyPenny] - %s file is Loaded",FilePath); }
inline bool GetPrivateProfileBool( LPCTSTR lpAppName,LPCTSTR lpKeyName,bool nDefault, LPCTSTR lpFileName) { return GetPrivateProfileInt( lpAppName,lpKeyName,nDefault,lpFileName) == 0 ? false : true; }
int CIniFile::ReadInteger (LPCSTR lpszSection, LPCSTR lpszKey, int iDefault) { // read integer value from ini-file return GetPrivateProfileInt (lpszSection, lpszKey, iDefault, m_szFileName); }
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { MSG uMsg; memset(&uMsg,0,sizeof(uMsg)); winClass.lpszClassName = "MY_WINDOWS_CLASS"; winClass.cbSize = sizeof(WNDCLASSEX); winClass.style = CS_HREDRAW | CS_VREDRAW; winClass.lpfnWndProc = WndProc; winClass.hInstance = hInstance; winClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); winClass.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); winClass.hCursor = LoadCursor(NULL, IDC_ARROW); winClass.lpszMenuName = MAKEINTRESOURCE(IDC_CV); winClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winClass.cbClsExtra = 0; winClass.cbWndExtra = 0; if( !RegisterClassEx(&winClass) ) return E_FAIL; GetINIPath(); OpenConsoleWindow = GetPrivateProfileBool("Display", "OpenConsoleWindow", true, IniName); if (OpenConsoleWindow) OpenConsole(); pcejin.aspectRatio = GetPrivateProfileBool("Video", "aspectratio", false, IniName); pcejin.windowSize = GetPrivateProfileInt("Video", "pcejin.windowSize", 1, IniName); WndX = GetPrivateProfileInt("Main", "WndX", 0, IniName); WndY = GetPrivateProfileInt("Main", "WndY", 0, IniName); g_hWnd = CreateWindowEx( NULL, "MY_WINDOWS_CLASS", pcejin.versionName.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, WndX, WndY, 348, 224, NULL, NULL, hInstance, NULL ); if( g_hWnd == NULL ) return E_FAIL; ScaleScreen((float)pcejin.windowSize); soundInit(); LoadIniSettings(); InitSpeedThrottle(); DirectDrawInit(); InitCustomControls(); InitCustomKeys(&CustomKeys); LoadHotkeyConfig(); LoadInputConfig(); DragAcceptFiles(g_hWnd, true); extern void Agg_init(); Agg_init(); if (osd) {delete osd; osd =NULL; } osd = new OSDCLASS(-1); di_init(); DWORD wmTimerRes; TIMECAPS tc; if (timeGetDevCaps(&tc, sizeof(TIMECAPS))== TIMERR_NOERROR) { wmTimerRes = std::min(std::max(tc.wPeriodMin, (UINT)1), tc.wPeriodMax); timeBeginPeriod (wmTimerRes); } else { wmTimerRes = 5; timeBeginPeriod (wmTimerRes); } if (KeyInDelayMSec == 0) { DWORD dwKeyboardDelay; SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &dwKeyboardDelay, 0); KeyInDelayMSec = 250 * (dwKeyboardDelay + 1); } if (KeyInRepeatMSec == 0) { DWORD dwKeyboardSpeed; SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &dwKeyboardSpeed, 0); KeyInRepeatMSec = (int)(1000.0/(((30.0-2.5)/31.0)*dwKeyboardSpeed+2.5)); } if (KeyInRepeatMSec < (int)wmTimerRes) KeyInRepeatMSec = (int)wmTimerRes; if (KeyInDelayMSec < KeyInRepeatMSec) KeyInDelayMSec = KeyInRepeatMSec; hKeyInputTimer = timeSetEvent (KeyInRepeatMSec, 0, KeyInputTimer, 0, TIME_PERIODIC); ShowWindow( g_hWnd, nCmdShow ); UpdateWindow( g_hWnd ); initialize(); if (lpCmdLine[0])ParseCmdLine(lpCmdLine, g_hWnd); while( uMsg.message != WM_QUIT ) { if( PeekMessage( &uMsg, NULL, 0, 0, PM_REMOVE ) ) { TranslateMessage( &uMsg ); DispatchMessage( &uMsg ); } else { emulate(); render(); } if(!pcejin.started) Sleep(1); } // shutDown(); timeEndPeriod (wmTimerRes); CloseAllToolWindows(); UnregisterClass( "MY_WINDOWS_CLASS", winClass.hInstance ); return uMsg.wParam; }
int CBaseIni::ReadInt( LPCTSTR lpszAppName, LPCTSTR lpszKeyName, int nDefault/*, LPCTSTR lpszFileName = NULL*/ ) { return GetPrivateProfileInt( lpszAppName, lpszKeyName, nDefault, m_strFileName.c_str() ); }
bool MainWnd::FileRun() { // save battery file before we change the filename... if(rom != NULL || gbRom != NULL) { if(theApp.autoSaveLoadCheatList) winSaveCheatListDefault(); writeBatteryFile(); cheatSearchCleanup(&cheatSearchData); theApp.emulator.emuCleanUp(); remoteCleanUp(); emulating = false; #ifdef APU_LOGGER_H end_apu_log(); #endif } char tempName[2048]; char file[2048]; CString oldFile = theApp.filename; utilStripDoubleExtension(theApp.szFile, tempName); _fullpath(file, tempName, 2048); theApp.filename = file; int index = theApp.filename.ReverseFind('.'); if(index != -1) theApp.filename = theApp.filename.Left(index); if( theApp.filename != oldFile ) { // clear cheat list when another game is loaded cheatsDeleteAll( false ); gbCheatRemoveAll(); } CString patchName; patchName.Format("%s.ips", theApp.filename); if( !fileExists( patchName ) ) { patchName.Format("%s.ups", theApp.filename); if( !fileExists( patchName ) ) { patchName.Format("%s.ppf", theApp.filename); if( !fileExists( patchName ) ) { // don't use any patches patchName.Empty(); } } } if(!theApp.dir.GetLength()) { int index = theApp.filename.ReverseFind('\\'); if(index != -1) { theApp.dir = theApp.filename.Left(index-1); } } IMAGE_TYPE type = utilFindType(theApp.szFile); if(type == IMAGE_UNKNOWN) { systemMessage(IDS_UNSUPPORTED_FILE_TYPE, "Unsupported file type: %s", theApp.szFile); return false; } systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; theApp.cartridgeType = type; if(type == IMAGE_GB) { if(!gbLoadRom(theApp.szFile)) return false; gbGetHardwareType(); // used for the handling of the gb Boot Rom if (gbHardware & 5) { skipBios = theApp.skipBiosFile; gbCPUInit(theApp.biosFileNameGB, theApp.useBiosFileGB); } gbReset(); theApp.emulator = GBSystem; gbBorderOn = theApp.winGbBorderOn; theApp.romSize = gbRomSize; if(theApp.autoPatch && !patchName.IsEmpty()) { int size = gbRomSize; applyPatch(patchName, &gbRom, &size); if(size != gbRomSize) { extern bool gbUpdateSizes(); gbUpdateSizes(); gbReset(); theApp.romSize = size; } } } else { int size = CPULoadRom(theApp.szFile); if(!size) return false; theApp.romSize = size; flashSetSize(theApp.winFlashSize); rtcEnable(theApp.winRtcEnable); cpuSaveType = theApp.winSaveType; GetModuleFileName(NULL, tempName, 2048); char *p = strrchr(tempName, '\\'); if(p) *p = 0; char buffer[5]; strncpy(buffer, (const char *)&rom[0xac], 4); buffer[4] = 0; strcat(tempName, "\\vba-over.ini"); UINT i = GetPrivateProfileInt(buffer, "rtcEnabled", -1, tempName); if(i != (UINT)-1) rtcEnable(i == 0 ? false : true); i = GetPrivateProfileInt(buffer, "flashSize", -1, tempName); if(i != (UINT)-1 && (i == 0x10000 || i == 0x20000)) flashSetSize((int)i); i = GetPrivateProfileInt(buffer, "saveType", -1, tempName); if(i != (UINT)-1 && (i <= 5)) cpuSaveType = (int)i; i = GetPrivateProfileInt(buffer, "mirroringEnabled", -1, tempName); if(i != (UINT)-1) doMirroring (i == 0 ? false : true); theApp.emulator = GBASystem; /* disabled due to problems if(theApp.removeIntros && rom != NULL) { *((u32 *)rom)= 0xea00002e; } */ if(theApp.autoPatch && !patchName.IsEmpty()) { int size = 0x2000000; applyPatch(patchName, &rom, &size); if(size != 0x2000000) { CPUReset(); } } } if(theApp.soundInitialized) { if(theApp.cartridgeType == 1) gbSoundReset(); else soundReset(); } else { soundInit(); theApp.soundInitialized = true; } #ifdef APU_LOGGER_H begin_apu_log("apu_log.txt"); #endif if(type == IMAGE_GBA) { skipBios = theApp.skipBiosFile; CPUInit(theApp.biosFileNameGBA.GetString(), theApp.useBiosFileGBA); CPUReset(); } readBatteryFile(); if(theApp.autoSaveLoadCheatList) winLoadCheatListDefault(); theApp.addRecentFile(theApp.szFile); theApp.updateWindowSize(theApp.videoOption); theApp.updateFrameSkip(); emulating = true; if(theApp.autoLoadMostRecent) OnFileLoadgameMostrecent(); theApp.frameskipadjust = 0; theApp.renderedFrames = 0; theApp.autoFrameSkipLastTime = systemGetClock(); theApp.rewindCount = 0; theApp.rewindCounter = 0; theApp.rewindSaveNeeded = false; toolsClearLog(); return true; }
void ImperialEvent::ImperialLoadConfig() { char FileName[] = "..//OptionsData//Events//ImperialEvent.ini"; ImperialConfig.MinimumLevel = GetPrivateProfileInt("ImperialGuardianFort", "ImperialEventReqLevel", 15, FileName); ImperialConfig.CheckInvite = GetPrivateProfileInt("ImperialGuardianFort", "ImperialEventCheckPaper", 1, FileName); }
int CConfigManager::GetFontSize() { return GetPrivateProfileInt(m_section.c_str(), FONT_SIZE, 20, m_configFileName.c_str()); }
BOOL CUserLoginDlg::OnInitDialog() { CDialogEx::OnInitDialog(); HICON m_hIcon; m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);//修改对话框的图标 SetIcon(m_hIcon,TRUE); // TODO: 在此添加额外的初始化 ModifyStyleEx(0,WS_EX_APPWINDOW); GetClientRect(&m_rect); SetBackgroundColor(RGB(247,252,255)); //初始化全局变量g_CurrentDir(当前目录绝对路径) GetCurrentDirectory(MAX_PATH,g_CurrentDir.GetBuffer(MAX_PATH)); g_CurrentDir.ReleaseBuffer(); //提取之前保存的用户信息,如果有的话,利用sqlite数据库 sqlite3* UserInfodb = NULL; //打开数据库,不存在则创建 if(sqlite3_open("User\\UserInfo.db3", &UserInfodb) != 0) { MessageBox(L"打开用户信息列表失败",L"初始化",MB_ICONERROR); return FALSE; } //创建用户信息表格,已存在则创建失败,错误信息保存在szErrmsg中 char *sqlcmd = "CREATE TABLE UserInfo(\ UserName string PRIMARY KEY,\ PassWord string )"; char *szErrmsg = NULL; sqlite3_exec(UserInfodb,sqlcmd,0,0,&szErrmsg); //查询用户数据 char *zsql = "SELECT * FROM UserInfo"; char **szResult = NULL; int nRow = 0; int nColumn = 0; sqlite3_get_table(UserInfodb,zsql,&szResult,&nRow,&nColumn,&szErrmsg); char username[MAX_USERNAMELEN] = {0}; char passwordEncodeHex[500] = {0}; char *passwordEncode = NULL; memset(username,0,MAX_USERNAMELEN); memset(passwordEncodeHex,0,500); int l = strlen(szResult[3]); if(nRow) { memcpy(username,szResult[2],strlen(szResult[2])); memcpy(passwordEncodeHex,szResult[3],strlen(szResult[3])); } m_UserIniFilePath = g_CurrentDir; m_UserIniFilePath+=L"\\config\\config.ini"; m_UserName = Char2CString(username); m_CheckPW=GetPrivateProfileInt(L"UserSetting",L"SavePassword",0,m_UserIniFilePath); if(strlen(passwordEncodeHex)) { //如果密码不为空,则解密 char *userKey = "1234567887654321"; // 原始密钥128位,16字节 CString sDataLen; GetPrivateProfileString(L"UserSetting",L"PasswordEnCodeLen",L"",sDataLen.GetBuffer(10),10,m_UserIniFilePath); int datalen = _wtoi(sDataLen); char keyDecode[256]; //解密密钥 char *PassWordDecoded = NULL; //char *dataSrc = NULL; //补齐的数据 //将转为16进制串的密码转为初始状态 int L=strlen(passwordEncodeHex); passwordEncode = (char*)malloc(sizeof(char)*(L)); memset(passwordEncode,0,L); int x; for(int i=0;i<L/2;i++) { sscanf(passwordEncodeHex+i*2,"%02X",&x); passwordEncode[i]=(char)x;//(x&0xFFu); } unsigned char in[16]; unsigned char out[16]; PassWordDecoded = (char*)malloc(sizeof(char)*datalen); if(!PassWordDecoded) { return -1; } memset(PassWordDecoded,0,datalen); //设置解密密钥 if(0!=AES_set_decrypt_key((const unsigned char *)userKey,128,(AES_KEY *)keyDecode)) { return -1; } //循环加密,以16字节为单位 int count = datalen/16; //解密 for(int i = 0;i<count;++i) { memset(in, 0, 16); memset(out, 0, 16); memcpy(in,passwordEncode+i*16,16); AES_ecb_encrypt(in,out,(AES_KEY *)keyDecode,AES_DECRYPT); memcpy(PassWordDecoded+i*16,out,16); } //初始化密码 m_PassWord = Char2CString(PassWordDecoded); //释放资源 free(passwordEncode); passwordEncode = NULL; free(PassWordDecoded); PassWordDecoded = NULL; } //关闭数据库 sqlite3_close(UserInfodb); UserInfodb = NULL; UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE }
int CConfigManager::GetScreenDepth() { return GetPrivateProfileInt(m_section.c_str(), SCREEN_DEPTH, 32, m_configFileName.c_str()); }
int CConfigManager::GetWindowHeight() { return GetPrivateProfileInt(m_section.c_str(), SCREEN_HEIGHT, 480, m_configFileName.c_str()); }
int CConfigManager::GetWindowWidth() { return GetPrivateProfileInt(m_section.c_str(), SCREEN_WIDTH, 640, m_configFileName.c_str()); }
bool CRtkService::_init() { char serverName[rtkm_node_key_length + 1]; m_bPending = __true; PrimaryCheckInterval = GetPrivateProfileInt( "PMC", "PrimaryCheckInterval", 500, get_config_file() ); if(PrimaryCheckInterval < 50 || PrimaryCheckInterval > 5000){ utils_error( "Warning : PrimaryCheckInterval=%d is invalid, reset to 500.\n", PrimaryCheckInterval ); PrimaryCheckInterval = 500; } MaxPrimaryWatchDogCounter = GetPrivateProfileInt( "PMC", "PrimaryWatchDogCounter", 8, get_config_file() ); if(MaxPrimaryWatchDogCounter < 3 || MaxPrimaryWatchDogCounter > 50){ utils_error( "Warning : PrimaryWatchDogCounter=%d is invalid, reset to 20.\n", PrimaryWatchDogCounter ); MaxPrimaryWatchDogCounter = 8; } PrimaryWatchDogCounter = MaxPrimaryWatchDogCounter; m_bPending = __false; init_powermgr(); #ifdef _WIN32 init_spac();//初始化得到security descriptor、mutex对象句柄数组mutics[]和event对象句柄数组events[] #endif init_server_shell();//创建g_shell init_config();//空函数。。。 GetPrivateProfileString( "PMC", "ServerName", "", serverName, sizeof(serverName), get_config_file() ); //若pmc.ini中没有给出节点名,取本机名为节点名 if(!serverName[0]){ DWORD len; len = sizeof(serverName); GetComputerName(serverName, &len); } //初始化网络,即设定一些值,创建链表g_buses,<bus_id, CRtkVBus*>,并开启5个VBUS线程 if(!init_network(RTK_INIT_AS_SERVER, serverName)){ return false; } //给g_buses中的4个元素的CRtkVBus的成员赋值 connect_vbus( BUSID_RTDB, VBUS_CONNECT_AS_SERVER, on_rtdb, rtdb_filter ); connect_vbus( BUSID_SYSTEM, VBUS_CONNECT_AS_SERVER, on_system, server_filter ); connect_vbus( BUSID_OPERATION, VBUS_CONNECT_AS_SERVER, on_operation, server_filter ); connect_vbus( BUSID_CONFIG, VBUS_CONNECT_AS_SERVER, on_config, server_filter ); utils_trace("Networking Subsystem initialized.\n"); register_power_callback(power_state_changed, 0);//创建一个CALLBACK_ITEM,用形参给其成员赋值,并链接上RTK_LIST_ENTRY // checking primary site if(!setup_running_state()){ return false; } setup_rtdb();//在pmc.ini中寻找组名,加载组名对应的*.csv文件中的标签到内存,并开启一个线程。 utils_trace("Realtime Database Subsystem initialized.\n"); init_ioss(); utils_trace("IO Susbsystem initialized.\n"); utils_trace("%s started...\n", versionString.c_str()); if(get_power_state() == PWR_RUNNING){ online_broadcast();//发送一个报警数据包,RTK_ALARM_PACKET型 } return true; }
UINT ConfigManager::ReadInt(char *key, int def) { return GetPrivateProfileInt(APPNAME, key, def, mIniFile); }
// // Load driver data from an external file into the drivers table // BOOL FAR TMSRPT29(TMSRPTPassedDataDef *pPassedData) { BOOL bOK; BOOL bFileOpen[NUMINPUTFILES]; BOOL bFound; FILE *fp[NUMINPUTFILES]; char blanks[80]; char dummy[256]; char inputString[256]; char inputFiles[NUMINPUTFILES][16]; char nodeNumbers[256]; char *ptr; char routeNumber[ROUTES_NAME_LENGTH + 1]; char routeName[ROUTES_NAME_LENGTH + 1]; char serviceName[SERVICES_NAME_LENGTH + 1]; long directionIndex; long firstTime; long nodeSequence; long PATTERNSrecordID; long ROUTESrecordID; long SERVICESrecordID; long tempLong; long oldCount; long newCount; int nI; int nJ; int rcode2; bOK = TRUE; memset(blanks, ' ', 80); for(nI = 0; nI < NUMINPUTFILES; nI++) { bFileOpen[nI] = FALSE; } // // Give the warning // LoadString(hInst, ERROR_278, tempString, TEMPSTRING_LENGTH); if(MessageBox(NULL, tempString, TMS, MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2) == IDNO) { bOK = FALSE; goto done; } // // Get the list of divisions we're going to load // // Number of divisions // numDivisions = GetPrivateProfileInt("TMSRPT29", "numDivisions", 0, TMSINIFile); if(numDivisions == 0) { LoadString(hInst, ERROR_273, tempString, TEMPSTRING_LENGTH); MessageBox(NULL, tempString, TMS, MB_OK); bOK = FALSE; goto done; } // // Did we exceed the max? // if(numDivisions > MAXDIVISIONS) { LoadString(hInst, ERROR_274, tempString, TEMPSTRING_LENGTH); MessageBox(NULL, tempString, TMS, MB_OK); bOK = FALSE; goto done; } // // Loop through the divisions? // for(nI = 0; nI < numDivisions; nI++) { sprintf(tempString, "DivisionNumber%02d", nI); divisionList[nI] = GetPrivateProfileInt("TMSRPT29", tempString, NO_RECORD, TMSINIFile); if(divisionList[nI] == NO_RECORD) { LoadString(hInst, ERROR_275, szFormatString, sizeof(szFormatString)); sprintf(szarString, szFormatString, tempString); MessageBox(NULL, szarString, TMS, MB_OK); bOK = FALSE; goto done; } sprintf(tempString, "DivisionName%02d", nI); GetPrivateProfileString("TMSRPT29", tempString, "", szarString, sizeof(szarString), TMSINIFile); // // Set up the Divisions Table // rcode2 = btrieve(B_GETLAST, TMS_DIVISIONS, &DIVISIONS, &DIVISIONSKey0, 0); DIVISIONS.recordID = AssignRecID(rcode2, DIVISIONS.recordID); DIVISIONS.COMMENTSrecordID = NO_RECORD; DIVISIONS.number = divisionList[nI]; strncpy(DIVISIONS.name, szarString, DIVISIONS_NAME_LENGTH); pad(DIVISIONS.name, DIVISIONS_NAME_LENGTH); memset(DIVISIONS.reserved, 0x00, DIVISIONS_RESERVED_LENGTH); DIVISIONS.flags = 0; rcode2 = btrieve(B_INSERT, TMS_DIVISIONS, &DIVISIONS, &DIVISIONSKey0, 0); // // Add the division information as a comment // recordLength[TMS_COMMENTS] = COMMENTS_TOTAL_LENGTH; rcode2 = btrieve(B_GETLAST, TMS_COMMENTS, pCommentText, &COMMENTSKey0, 0); COMMENTS.recordID = AssignRecID(rcode2, COMMENTS.recordID); strncpy(COMMENTS.code, szarString, COMMENTS_CODE_LENGTH); pad(COMMENTS.code, COMMENTS_CODE_LENGTH); memset(COMMENTS.reserved, 0x00, COMMENTS_RESERVED_LENGTH); COMMENTS.flags = 0; memcpy(pCommentText, &COMMENTS, COMMENTS_FIXED_LENGTH); strcpy(&pCommentText[COMMENTS_FIXED_LENGTH], szarString); btrieve(B_INSERT, TMS_COMMENTS, pCommentText, &COMMENTSKey0, 0); recordLength[TMS_COMMENTS] = COMMENTS_FIXED_LENGTH; } // // Establish the file names // strcpy(inputFiles[TMSRPT29_ROUTES], "ROUTES.TXT"); strcpy(inputFiles[TMSRPT29_NODES], "NODES.TXT"); strcpy(inputFiles[TMSRPT29_HEADWAYS], "HEADWAYS.TXT"); // // Set up the status bar // pPassedData->nReportNumber = 28; pPassedData->numDataFiles = 1; for(nI = 0; nI < m_LastReport; nI++) { if(TMSRPT[nI].originalReportNumber == pPassedData->nReportNumber) { StatusBarStart(hWndMain, TMSRPT[nI].szReportName); break; } } // // Verify that all the files are present // for(nI = 0; nI < NUMINPUTFILES; nI++) { fp[nI] = fopen(inputFiles[nI], "r"); if(fp[nI] == NULL) { LoadString(hInst, ERROR_204, szFormatString, sizeof(szFormatString)); sprintf(tempString, szFormatString, inputFiles[nI]); MessageBox(NULL, tempString, TMS, MB_OK); bOK = FALSE; goto done; } bFileOpen[nI] = TRUE; } // // Routes // // Cols Data // ~~~~ ~~~~ // 1-4 (Alphanumeric) Route number // 5 "," // 6-37 Route name // 38 "," // 39 Service day (1) // 40 "," // 41 Service day (2) // 42 "," // 43 Service day (3) // 44 "," // 45-52 Outbound direction name // 53 "," // 54-61 Inbound direction name // 62 "," // 63-66 Internal route number / numeric equivalent (for block numbers) // StatusBarText("Loading Route Data"); while(fgets(inputString, sizeof(inputString), fp[TMSRPT29_ROUTES])) { if(StatusBarAbort()) { bOK = FALSE; goto done; } memset(&ROUTES, 0x00, sizeof(ROUTESDef)); // // ROUTES.recordID // strncpy(tempString, &inputString[62], 4); tempString[4] = '\0'; ROUTES.recordID = atol(tempString); // // ROUTES.COMMENTSrecordID // ROUTES.COMMENTSrecordID = NO_RECORD; // // ROUTES.DIRECTIONSrecordID[] // for(nI = 0; nI < 2; nI++) { if(nI == 0) strncpy(tempString, &inputString[44], 8); else strncpy(tempString, &inputString[53], 8); tempString[8]= '\0'; pad(tempString, DIRECTIONS_LONGNAME_LENGTH); // // If it's blank, it means the route is unidirectional // if(strncmp(tempString, blanks, DIRECTIONS_LONGNAME_LENGTH) == 0) { ROUTES.DIRECTIONSrecordID[nI] = NO_RECORD; } // // See if the direction exists already // else { strncpy(DIRECTIONSKey1.longName, tempString, DIRECTIONS_LONGNAME_LENGTH); rcode2 = btrieve(B_GETEQUAL, TMS_DIRECTIONS, &DIRECTIONS, &DIRECTIONSKey1, 1); if(rcode2 == 0) { ROUTES.DIRECTIONSrecordID[nI] = DIRECTIONS.recordID; } // // No - create a DIRECTIONS record and insert it. // // tempString still contains the long direction name // else { // // DIRECTIONS.RecordID // rcode2 = btrieve(B_GETLAST, TMS_DIRECTIONS, &DIRECTIONS, &DIRECTIONSKey0, 0); DIRECTIONS.recordID = AssignRecID(rcode2, DIRECTIONS.recordID); // // DIRECTIONS.COMMENTSrecordID // DIRECTIONS.COMMENTSrecordID = NO_RECORD; // // DIRECTIONS.abbrName // DIRECTIONS.abbrName[0] = tempString[0]; DIRECTIONS.abbrName[1] = (tempString[1] == '-' ? 'B' : tempString[1]); pad(DIRECTIONS.abbrName, DIRECTIONS_ABBRNAME_LENGTH); // // DIRECTIONS.longName // strncpy(DIRECTIONS.longName, tempString, DIRECTIONS_LONGNAME_LENGTH); // // DIRECTIONS.reserved // memset(&DIRECTIONS.reserved, 0x00, DIRECTIONS_RESERVED_LENGTH); // // DIRECTIONS.flags // DIRECTIONS.flags = 0; // // DIRECTIONS Insert // rcode2 = btrieve(B_INSERT, TMS_DIRECTIONS, &DIRECTIONS, &DIRECTIONSKey0, 0); if(rcode2 != 0) { LoadString(hInst, ERROR_205, szFormatString, sizeof(szFormatString)); sprintf(tempString, szFormatString, rcode2); MessageBox(NULL, tempString, TMS, MB_OK); bOK = FALSE; goto done; } ROUTES.DIRECTIONSrecordID[nI] = DIRECTIONS.recordID; } } } // // ROUTES.number // strncpy(tempString, &inputString[0], 4); tempString[4] = '\0'; strcpy(ROUTES.number, tempString); pad(ROUTES.number, ROUTES_NUMBER_LENGTH); // // ROUTES.name // strncpy(tempString, &inputString[5], 32); tempString[32] = '\0'; strcpy(ROUTES.name, tempString); pad(ROUTES.name, ROUTES_NAME_LENGTH); // // ROUTES bays // ROUTES.OBBayNODESrecordID = NO_RECORD; ROUTES.IBBayNODESrecordID = NO_RECORD; // // ROUTES Insert // rcode2 = btrieve(B_INSERT, TMS_ROUTES, &ROUTES, &ROUTESKey0, 0); if(rcode2 != 0) { LoadString(hInst, ERROR_206, szFormatString, sizeof(szFormatString)); sprintf(tempString, szFormatString, rcode2); MessageBox(NULL, tempString, TMS, MB_OK); bOK = FALSE; goto done; } } // // Nodes // // Cols Data // ~~~~ ~~~~ // 1-3 Blank // 4-7 Node number / name // 8 "," // 9-12 On street // 13 "," // 14-17 At street // 18 "," // 19-22 Address prefix (1) // 23 "," // 24-27 Address prefix (2) // 28 "," // 29- Address / Intersection // StatusBarText("Loading Node Data"); while(fgets(inputString, sizeof(inputString), fp[TMSRPT29_NODES])) { if(StatusBarAbort()) { bOK = FALSE; goto done; } memset(&NODES, 0x00, sizeof(NODESDef)); // // NODES.recordID // rcode2 = btrieve(B_GETLAST, TMS_NODES, &NODES, &NODESKey0, 0); NODES.recordID = AssignRecID(rcode2, NODES.recordID); // // NODES.COMMENTSrecordID // NODES.COMMENTSrecordID = NO_RECORD; // // NODES.JURISDICTIONSrecordID // NODES.JURISDICTIONSrecordID = NO_RECORD; // // NODES.abbrName // strncpy(NODES.abbrName, &inputString[3], 4); // // NODES.longName // strncpy(NODES.longName, &inputString[8], 4); strncpy(&NODES.longName[4], &inputString[13], 4); // // NODES.intersection // strcpy(tempString, ""); // // There are extra information fields in the input stream. // If they're not blank, prefix the intersection field with them // if(strncmp(&inputString[18], blanks, 4) != 0) { strncpy(szarString, &inputString[18], 4); szarString[4] = '\0'; strcat(tempString, szarString); strcat(tempString, " "); } if(strncmp(&inputString[23], blanks, 4) != 0) { strncpy(szarString, &inputString[23], 4); szarString[4] = '\0'; strcat(tempString, szarString); strcat(tempString, " "); } // // Now the rest of the intersection // // There's crap at the end of the record, so get rid of it // strcat(tempString, &inputString[28]); for(nI = strlen(tempString) - 1; nI > 0; nI--) { if(tempString[nI] == 10) // ^J ?? { tempString[nI] = ' '; break; } } strcpy(NODES.intersection, tempString); pad(NODES.intersection, NODES_INTERSECTION_LENGTH); // // NODES.reliefLabels // strncpy(NODES.reliefLabels, blanks, NODES_RELIEFLABELS_LENGTH); // // NODES.longitude and NODES.latitude // tempLong = 0L; memcpy(&NODES.longitude, &tempLong, sizeof(long)); memcpy(&NODES.latitude, &tempLong, sizeof(long)); // // NODES.number // strncpy(tempString, &inputString[3], 4); NODES.number = atol(tempString); // // NODES.reserved // memset(&NODES.reserved, 0x00, NODES_RESERVED_LENGTH); // // NODES.flags // NODES.flags = 0; // // NODES Insert // rcode2 = btrieve(B_INSERT, TMS_NODES, &NODES, &NODESKey0, 0); if(rcode2 != 0) { LoadString(hInst, ERROR_230, szFormatString, sizeof(szFormatString)); sprintf(tempString, szFormatString, rcode2); MessageBox(NULL, tempString, TMS, MB_OK); bOK = FALSE; goto done; } } // // Headways // // Header Record // // Cols Data // ~~~~ ~~~~ // 1 Blank // 2-6 "ROUTE" // 7 Blank // 8-11 (Alphanumeric) Route number // 12 Blank // 13-20 Direction name // 21-23 " : " // 24-80 Route name // // Nodes on the Route Record // // Cols Data // ~~~~ ~~~~ // 1-7 ",,,,,,," // 8-11 Node number // 12 "," // 13-16 Node number // 17 "," // // ...continues in i4,1x format until "\0" // // Trip records // // Cols Data // ~~~~ ~~~~ // 1-2 Service number (1=Wk, 2=Sa, 3=Su) // 3 "," // 4-5 Division number // 6 "," // 7-10 (Alphanumeric) Route number // 11 "," // 12-19 Direction name // 20 "," // 21-25 Block number (rrrnn, where "rrr" is the internal route #) // 26 "," // 27-30 Trip start (in minutes after midnight) // 31 "," // 32-35 Trip end (in minutes after midnight) // 36 "," // 37-40 (Military) Time at timepoint // 41-42 " ," // // ...repeats Number of Nodes on the Routes Record times. // // If there's no time at a timepoint, the field contains " - " // StatusBarText("Loading Headway Data"); ptr = fgets(inputString, sizeof(inputString), fp[TMSRPT29_HEADWAYS]); while(ptr) { if(StatusBarAbort()) { bOK = FALSE; goto done; } // // Figure out the type of record we've just read // // Header record // if(strncmp(inputString, " ROUTE", 6) == 0) { // // Header: Determine the route // strncpy(tempString, &inputString[7], 4); tempString[4] = '\0'; strcpy(ROUTESKey1.number, tempString); pad(ROUTESKey1.number, ROUTES_NUMBER_LENGTH); rcode2 = btrieve(B_GETEQUAL, TMS_ROUTES, &ROUTES, &ROUTESKey1, 1); if(rcode2 != 0) { LoadString(hInst, ERROR_231, szFormatString, sizeof(szFormatString)); sprintf(szarString, szFormatString, tempString); MessageBox(NULL, szarString, TMS, MB_OK); bOK = FALSE; goto done; } ROUTESrecordID = ROUTES.recordID; strncpy(routeNumber, ROUTES.number, ROUTES_NUMBER_LENGTH); trim(routeNumber, ROUTES_NUMBER_LENGTH); // // Header: Determine the direction // strncpy(tempString, &inputString[12], 8); tempString[8] = '\0'; pad(tempString, DIRECTIONS_LONGNAME_LENGTH); strncpy(DIRECTIONSKey1.longName, tempString, DIRECTIONS_LONGNAME_LENGTH); rcode2 = btrieve(B_GETEQUAL, TMS_DIRECTIONS, &DIRECTIONS, &DIRECTIONSKey1, 1); if(rcode2 != 0) { LoadString(hInst, ERROR_232, szFormatString, sizeof(szFormatString)); trim(tempString, DIRECTIONS_LONGNAME_LENGTH); sprintf(szarString, szFormatString, tempString, routeNumber); MessageBox(NULL, szarString, TMS, MB_OK); bOK = FALSE; goto done; } if(DIRECTIONS.recordID == ROUTES.DIRECTIONSrecordID[0]) directionIndex = 0; else if(DIRECTIONS.recordID == ROUTES.DIRECTIONSrecordID[1]) directionIndex = 1; else { LoadString(hInst, ERROR_233, szFormatString, sizeof(szFormatString)); trim(tempString, DIRECTIONS_LONGNAME_LENGTH); sprintf(szarString, szFormatString, tempString, routeNumber); MessageBox(NULL, szarString, TMS, MB_OK); bOK = FALSE; goto done; } // // Get the next record // ptr = fgets(inputString, sizeof(inputString), fp[TMSRPT29_HEADWAYS]); } // // Nodes on the route record. The record terminates with \j\0 // else if(strncmp(inputString, ",,,,,,,", 7) == 0) { // // Save the current input string. We actually have to read the next record // (which is the first trip record) in order to determine what service // we're on. // strcpy(nodeNumbers, &inputString[7]); ptr = fgets(inputString, sizeof(inputString), fp[TMSRPT29_HEADWAYS]); if(!ptr) { LoadString(hInst, ERROR_243, szFormatString, sizeof(szFormatString)); sprintf(szarString, szFormatString, routeNumber); MessageBox(NULL, szarString, TMS, MB_OK); bOK = FALSE; goto done; } // // Determine the service // strncpy(tempString, inputString, 2); tempString[2] = '\0'; SERVICESKey1.number = atol(tempString); rcode2 = btrieve(B_GETEQUAL, TMS_SERVICES, &SERVICES, &SERVICESKey1, 1); if(rcode2 != 0) { LoadString(hInst, ERROR_260, szFormatString, sizeof(szFormatString)); sprintf(szarString, szFormatString, routeNumber); MessageBox(NULL, szarString, TMS, MB_OK); bOK = FALSE; goto done; } SERVICESrecordID = SERVICES.recordID; // // Loop through the node numbers so we can build a BASE pattern // nJ = 0; rcode2 = btrieve(B_GETLAST, TMS_PATTERNS, &PATTERNS, &PATTERNSKey0, 0); PATTERNSrecordID = AssignRecID(rcode2, PATTERNS.recordID); nodeSequence = 10000; numBasePatternNodes = 0; while(nodeNumbers[nJ] != 10) { memset(&PATTERNS, 0x00, sizeof(PATTERNSDef)); // // PATTERNS.recordID // PATTERNS.recordID = PATTERNSrecordID++; // // PATTERNS.COMMENTSrecordID // PATTERNS.COMMENTSrecordID = NO_RECORD; // // PATTERNS.ROUTESrecordID // PATTERNS.ROUTESrecordID = ROUTESrecordID; // // PATTERNS.SERVICESrecordID // PATTERNS.SERVICESrecordID = SERVICESrecordID; // // PATTERNS.directionIndex // PATTERNS.directionIndex = directionIndex; // // PATTERNS.PATTERNNAMESrecordID // PATTERNS.PATTERNNAMESrecordID = basePatternRecordID; // // PATTERNS.NODESrecordID // strncpy(tempString, &nodeNumbers[nJ], 4); tempString[4] = '\0'; strncpy(NODESKey2.abbrName, tempString, 4); rcode2 = btrieve(B_GETEQUAL, TMS_NODES, &NODES, &NODESKey2, 2); if(rcode2 != 0) { LoadString(hInst, ERROR_269, szFormatString, sizeof(szFormatString)); sprintf(szarString, szFormatString, tempString, routeNumber); MessageBox(NULL, szarString, TMS, MB_OK); bOK = FALSE; goto done; } PATTERNS.NODESrecordID = NODES.recordID; // // PATTERNS.nodeSequence // PATTERNS.nodeSequence = nodeSequence; nodeSequence += 10000; // // PATTERNS.reserved // memset(&PATTERNS.fromText, 0x00, PATTERNS_FROMTEXT_LENGTH); memset(&PATTERNS.toText, 0x00, PATTERNS_TOTEXT_LENGTH); memset(&PATTERNS.reserved, 0x00, PATTERNS_RESERVED_LENGTH); // // PATTERNS.flags // // Force the first timepoint to be the MLP // PATTERNS.flags = (nJ == 0 ? PATTERNS_FLAG_MLP : 0); // // PATTERNS: Insert // rcode2 = btrieve(B_INSERT, TMS_PATTERNS, &PATTERNS, &PATTERNSKey0, 0); if(rcode2 != 0) { LoadString(hInst, ERROR_271, szFormatString, sizeof(szFormatString)); sprintf(tempString, szFormatString, rcode2); MessageBox(NULL, tempString, TMS, MB_OK); bOK = FALSE; goto done; } // // Save the base pattern internally // basePatternNodes[numBasePatternNodes] = PATTERNS.NODESrecordID; numBasePatternNodes++; // // Get the next timepoint // nJ += 5; } // // Zero out numPatterns for the benefit of the headway records to follow // numPatterns = 0; } // // Trip records. The first trip record was fetched above. // else { // // Only load trips belonging to the required divisions // if(ATCDivision(&inputString[3])) { // // Do we need to add a comment to the route? // ROUTESKey0.recordID = ROUTESrecordID; rcode2 = btrieve(B_GETEQUAL, TMS_ROUTES, &ROUTES, &ROUTESKey0, 0); if(rcode2 == 0 && ROUTES.COMMENTSrecordID == NO_RECORD) { DIVISIONSKey1.number = atol(&inputString[3]); rcode2 = btrieve(B_GETEQUAL, TMS_DIVISIONS, &DIVISIONS, &DIVISIONSKey1, 1); if(rcode2 == 0) { strncpy(COMMENTSKey1.code, DIVISIONS.name, COMMENTS_CODE_LENGTH); pad(COMMENTSKey1.code, COMMENTS_CODE_LENGTH); recordLength[TMS_COMMENTS] = COMMENTS_TOTAL_LENGTH; rcode2 = btrieve(B_GETEQUAL, TMS_COMMENTS, pCommentText, &COMMENTSKey1, 1); memcpy(&COMMENTS, pCommentText, COMMENTS_FIXED_LENGTH); recordLength[TMS_COMMENTS] = COMMENTS_FIXED_LENGTH; if(rcode2 == 0) { ROUTES.COMMENTSrecordID = COMMENTS.recordID; rcode2 = btrieve(B_UPDATE, TMS_ROUTES, &ROUTES, &ROUTESKey0, 0); } } } // // Get the first time // strncpy(tempString, &inputString[26], 4); tempString[4] = '\0'; firstTime = atol(tempString) * 60; // // TRIPS.recordID // rcode2 = btrieve(B_GETLAST, TMS_TRIPS, &TRIPS, &TRIPSKey0, 0); TRIPS.recordID = AssignRecID(rcode2, TRIPS.recordID); // // TRIPS.COMMENTSrecordID // TRIPS.COMMENTSrecordID = NO_RECORD; // // TRIPS.ROUTESrecordID // TRIPS.ROUTESrecordID = ROUTESrecordID; // // TRIPS.SERVICESrecordID // TRIPS.SERVICESrecordID = SERVICESrecordID; // // TRIPS.BUSTYPESrecordID // TRIPS.BUSTYPESrecordID = NO_RECORD; // // TRIPS.PATTERNNAMESrecordID // TRIPS.PATTERNNAMESrecordID = DeterminePattern(ROUTESrecordID, SERVICESrecordID, directionIndex, inputString); if(TRIPS.PATTERNNAMESrecordID == NO_RECORD) { bOK = FALSE; goto done; } // // TRIPS.timeAtMLP and tripSequence // TRIPS.timeAtMLP = firstTime; TRIPS.tripSequence = firstTime; // // TRIPS.SIGNCODESrecordID // TRIPS.SIGNCODESrecordID = NO_RECORD; // // TRIPS.directionIndex // TRIPS.directionIndex = directionIndex; // // TRIPS.tripNumber // TRIPS.tripNumber = NO_RECORD; // // TRIPS.shift.* // TRIPS.shift.negativeMax = NO_TIME; TRIPS.shift.positiveMax = NO_TIME; TRIPS.shift.actual = NO_TIME; // // TRIPS.standard.* // // TRIPS.standard.blockNumber // // Figure out where it's blocked. This is a verification process. We // know the recordID of the route 'cause it was set up above as the // "Internal Route Number". Never hurts to check, though. // strncpy(tempString, &inputString[20], 3); tempString[3] = '\0'; ROUTESKey0.recordID = atol(tempString); rcode2 = btrieve(B_GETEQUAL, TMS_ROUTES, &ROUTES, &ROUTESKey0, 0); if(rcode2 != 0) { LoadString(hInst, ERROR_270, szFormatString, sizeof(szFormatString)); sprintf(szarString, szFormatString, rcode2); MessageBox(NULL, szarString, TMS, MB_OK); bOK = FALSE; goto done; } strncpy(tempString, &inputString[20], 5); tempString[5] = '\0'; TRIPS.standard.blockNumber = atol(tempString); // // TRIPS.standard.BLOCKNAMESrecordID // TRIPS.standard.BLOCKNAMESrecordID = NO_RECORD; // // TRIPS.standard.POGNODESrecordID and PIGNODESrecordID // TRIPS.standard.POGNODESrecordID = NO_RECORD; TRIPS.standard.PIGNODESrecordID = NO_RECORD; // // TRIPS.standard.RGRPROUTESrecordID // TRIPS.standard.RGRPROUTESrecordID = ROUTES.recordID; // // TRIPS.standard.SGRPSERVICES // TRIPS.standard.SGRPSERVICESrecordID = SERVICESrecordID; // // TRIPS.standard.assignedToNODESrecordID // TRIPS.standard.assignedToNODESrecordID = NO_RECORD; // // TRIPS.standard.blockSequence // TRIPS.standard.blockSequence = firstTime; // // TRIPS.standard.layoverMin and layoverMax // TRIPS.standard.layoverMin = NO_TIME; TRIPS.standard.layoverMax = NO_TIME; // // TRIPS.dropback.* // TRIPS.dropback.blockNumber = 0; TRIPS.dropback.BLOCKNAMESrecordID = NO_RECORD; TRIPS.dropback.POGNODESrecordID = NO_RECORD; TRIPS.dropback.PIGNODESrecordID = NO_RECORD; TRIPS.dropback.RGRPROUTESrecordID = NO_RECORD; TRIPS.dropback.SGRPSERVICESrecordID = NO_RECORD; TRIPS.dropback.assignedToNODESrecordID = NO_RECORD; TRIPS.dropback.blockSequence = NO_TIME; TRIPS.dropback.layoverMin = NO_TIME; TRIPS.dropback.layoverMax = NO_TIME; // // TRIPS.customerCOMMENTSrecordID // TRIPS.customerCOMMENTSrecordID = NO_RECORD; // // TRIPS.reserved // memset(&TRIPS.reserved, 0x00, TRIPS_RESERVED_LENGTH); // // TRIPS.flags // TRIPS.flags = 0; // // TRIPS: Insert // rcode2 = btrieve(B_INSERT, TMS_TRIPS, &TRIPS, &TRIPSKey0, 0); if(rcode2 != 0) { LoadString(hInst, ERROR_272, szFormatString, sizeof(szFormatString)); sprintf(tempString, szFormatString, routeNumber); MessageBox(NULL, tempString, TMS, MB_OK); bOK = FALSE; goto done; } // // Create the connections // if(!CreateConnections(ROUTESrecordID, SERVICESrecordID, inputString)) { bOK = FALSE; goto done; } } // // Get the next record // ptr = fgets(inputString, sizeof(inputString), fp[TMSRPT29_HEADWAYS]); } } // // Eliminate the patterns from any route that doesn't have trips on it // // Cycle through all the services // rcode2 = btrieve(B_GETFIRST, TMS_SERVICES, &SERVICES, &SERVICESKey1, 1); while(rcode2 == 0) { if(StatusBarAbort()) return(FALSE); strncpy(serviceName, SERVICES.name, SERVICES_NAME_LENGTH); trim(serviceName, SERVICES_NAME_LENGTH); // // Cycle through all the routes // rcode2 = btrieve(B_GETFIRST, TMS_ROUTES, &ROUTES, &ROUTESKey1, 1); while(rcode2 == 0) { if(StatusBarAbort()) return(FALSE); strncpy(routeNumber, ROUTES.number, ROUTES_NUMBER_LENGTH); trim(routeNumber, ROUTES_NUMBER_LENGTH); strncpy(routeName, ROUTES.name, ROUTES_NAME_LENGTH); trim(routeName, ROUTES_NAME_LENGTH); sprintf(tempString, "Eliminating Unused Patterns - %s\n%s - %s", serviceName, routeNumber, routeName); StatusBarText(tempString); // // Loop through the (possibly) two directions // for(nI = 0; nI < 2; nI++) { if(ROUTES.DIRECTIONSrecordID[nI] == NO_RECORD) continue; TRIPSKey1.ROUTESrecordID = ROUTES.recordID; TRIPSKey1.SERVICESrecordID = SERVICES.recordID; TRIPSKey1.directionIndex = nI; TRIPSKey1.tripSequence = NO_TIME; // // See if there are any trips on the rte/ser/dir // rcode2 = btrieve(B_GETGREATEROREQUAL, TMS_TRIPS, &TRIPS, &TRIPSKey1, 1); if(rcode2 == 0 && TRIPS.ROUTESrecordID == ROUTES.recordID && TRIPS.SERVICESrecordID == SERVICES.recordID && TRIPS.directionIndex == nI) { continue; // Yes } // // No. Delete any pattern data on this rte/ser/dir // PATTERNSKey2.ROUTESrecordID = ROUTES.recordID; PATTERNSKey2.SERVICESrecordID = SERVICES.recordID; PATTERNSKey2.directionIndex = nI; PATTERNSKey2.PATTERNNAMESrecordID = NO_RECORD; PATTERNSKey2.nodeSequence = NO_RECORD; rcode2 = btrieve(B_GETGREATER, TMS_PATTERNS, &PATTERNS, &PATTERNSKey2, 2); while(rcode2 == 0 && PATTERNS.ROUTESrecordID == ROUTES.recordID && PATTERNS.SERVICESrecordID == SERVICES.recordID && PATTERNS.directionIndex == nI) { btrieve(B_DELETE, TMS_PATTERNS, &PATTERNS, &PATTERNSKey2, 2); rcode2 = btrieve(B_GETNEXT, TMS_PATTERNS, &PATTERNS, &PATTERNSKey2,2 ); } } // nI rcode2 = btrieve(B_GETNEXT, TMS_ROUTES, &ROUTES, &ROUTESKey1, 1); } rcode2 = btrieve(B_GETNEXT, TMS_SERVICES, &SERVICES, &SERVICESKey1, 1); } // // Now eliminate any unused nodes // rcode2 = btrieve(B_GETFIRST, TMS_NODES, &NODES, &NODESKey0, 0); while(rcode2 == 0) { PATTERNSKey1.NODESrecordID = NODES.recordID; rcode2 = btrieve(B_GETEQUAL, TMS_PATTERNS, &PATTERNS, &PATTERNSKey1, 1); if(rcode2 != 0) { btrieve(B_DELETE, TMS_NODES, &NODES, &NODESKey0, 0); } rcode2 = btrieve(B_GETNEXT, TMS_NODES, &NODES, &NODESKey0, 0); } // // Now eliminate any unused routes // // // Cycle through all the routes // rcode2 = btrieve(B_GETFIRST, TMS_ROUTES, &ROUTES, &ROUTESKey1, 1); while(rcode2 == 0) { if(StatusBarAbort()) return(FALSE); strncpy(routeNumber, ROUTES.number, ROUTES_NUMBER_LENGTH); trim(routeNumber, ROUTES_NUMBER_LENGTH); strncpy(routeName, ROUTES.name, ROUTES_NAME_LENGTH); trim(routeName, ROUTES_NAME_LENGTH); // // Cycle through all the services // bFound = FALSE; rcode2 = btrieve(B_GETFIRST, TMS_SERVICES, &SERVICES, &SERVICESKey1, 1); while(rcode2 == 0) { if(StatusBarAbort()) return(FALSE); strncpy(serviceName, SERVICES.name, SERVICES_NAME_LENGTH); trim(serviceName, SERVICES_NAME_LENGTH); sprintf(tempString, "Eliminating Unused Routes - %s\n%s - %s", serviceName, routeNumber, routeName); StatusBarText(tempString); // // Loop through the (possibly) two directions // for(nI = 0; nI < 2; nI++) { if(ROUTES.DIRECTIONSrecordID[nI] == NO_RECORD) continue; TRIPSKey1.ROUTESrecordID = ROUTES.recordID; TRIPSKey1.SERVICESrecordID = SERVICES.recordID; TRIPSKey1.directionIndex = nI; TRIPSKey1.tripSequence = NO_TIME; // // See if there are any trips on the rte/ser/dir // rcode2 = btrieve(B_GETGREATEROREQUAL, TMS_TRIPS, &TRIPS, &TRIPSKey1, 1); if(rcode2 == 0 && TRIPS.ROUTESrecordID == ROUTES.recordID && TRIPS.SERVICESrecordID == SERVICES.recordID && TRIPS.directionIndex == nI) { bFound = TRUE; break; } } // // If there was, break // if(bFound) break; // // See if there are any blocks on this rte/ser // TRIPSKey2.assignedToNODESrecordID = NO_RECORD; TRIPSKey2.RGRPROUTESrecordID = ROUTES.recordID; TRIPSKey2.SGRPSERVICESrecordID = SERVICES.recordID; TRIPSKey2.blockNumber = 0; TRIPSKey2.blockSequence = NO_TIME; rcode2 = btrieve(B_GETGREATER, TMS_TRIPS, &TRIPS, &TRIPSKey2, 2); if(rcode2 == 0 && TRIPS.standard.assignedToNODESrecordID == NO_RECORD && TRIPS.standard.RGRPROUTESrecordID == ROUTES.recordID && TRIPS.standard.SGRPSERVICESrecordID == SERVICES.recordID) { bFound = TRUE; break; } // // Get the next service // rcode2 = btrieve(B_GETNEXT, TMS_SERVICES, &SERVICES, &SERVICESKey1, 1); } // // If no reference was found, delete the route // if(!bFound) btrieve(B_DELETE, TMS_ROUTES, &ROUTES, &ROUTESKey1, 1); // // Get the next route // rcode2 = btrieve(B_GETNEXT, TMS_ROUTES, &ROUTES, &ROUTESKey1, 1); } // // Condense the connections table // rcode2 = btrieve(B_STAT, TMS_CONNECTIONS, &BSTAT, dummy, 0); oldCount = BSTAT.numRecords; if(!CondenseConnections()) { bOK = FALSE; goto done; } rcode2 = btrieve(B_STAT, TMS_CONNECTIONS, &BSTAT, dummy, 0); newCount = BSTAT.numRecords; sprintf(tempString, "Connections reduced from %ld to %ld", oldCount, newCount); MessageBox(NULL, tempString, TMS, MB_OK); // // All done // done: for(nI = 0; nI < NUMINPUTFILES; nI++) { if(bFileOpen[nI]) { fclose(fp[nI]); } } StatusBarEnd(); if(bOK) { MessageBox(NULL, "Done!", TMS, MB_OK); } return(TRUE); }
int IniReader::ReadInteger(char* szSection, char* szKey, int iDefaultValue) { int iResult = GetPrivateProfileInt(szSection, szKey, iDefaultValue, m_szFileName); return iResult; }
BOOL CSyoboiCalUtil::SendReserve(vector<RESERVE_DATA*>* reserveList, vector<TUNER_RESERVE_INFO>* tunerList) { if( reserveList == NULL || tunerList == NULL ){ return FALSE; } if( reserveList->size() == 0 ){ return FALSE; } wstring iniAppPath = L""; GetModuleIniPath(iniAppPath); if( GetPrivateProfileInt(L"SYOBOI", L"use", 0, iniAppPath.c_str()) == 0 ){ return FALSE; } _OutputDebugString(L"★SyoboiCalUtil:SendReserve"); wstring textPath; GetModuleFolderPath(textPath); textPath += L"\\SyoboiCh.txt"; CParseServiceChgText srvChg; srvChg.ParseText(textPath.c_str()); SAFE_DELETE(this->proxyInfo); WCHAR buff[512] = L""; int length = 0; BOOL useProxy = (BOOL)GetPrivateProfileInt(L"SYOBOI", L"useProxy", 0, iniAppPath.c_str()); if( useProxy == TRUE ){ this->proxyInfo = new USE_PROXY_INFO; GetPrivateProfileString(L"SYOBOI", L"ProxyServer", L"", buff, 512, iniAppPath.c_str()); this->proxyInfo->serverName = new WCHAR[wcslen(buff)+1]; wcscpy_s(this->proxyInfo->serverName, wcslen(buff)+1, buff); ZeroMemory(buff, (sizeof(WCHAR)*512)); GetPrivateProfileString(L"SYOBOI", L"ProxyID", L"", buff, 512, iniAppPath.c_str()); length = (int)wcslen(buff); if( length > 0 ){ this->proxyInfo->userName = new WCHAR[length+1]; wcscpy_s(this->proxyInfo->userName, length+1, buff); }else{ this->proxyInfo->userName = NULL; } ZeroMemory(buff, (sizeof(WCHAR)*512)); GetPrivateProfileString(L"SYOBOI", L"ProxyPWD", L"", buff, 512, iniAppPath.c_str()); length = (int)wcslen(buff); if( length > 0 ){ this->proxyInfo->password = new WCHAR[length+1]; wcscpy_s(this->proxyInfo->password, length+1, buff); }else{ this->proxyInfo->password = NULL; } } ZeroMemory(buff, (sizeof(WCHAR)*512)); GetPrivateProfileString(L"SYOBOI", L"userID", L"", buff, 512, iniAppPath.c_str()); this->id=buff; ZeroMemory(buff, (sizeof(WCHAR)*512)); GetPrivateProfileString(L"SYOBOI", L"PWD", L"", buff, 512, iniAppPath.c_str()); this->pass=buff; int slot = GetPrivateProfileInt(L"SYOBOI", L"slot", 0, iniAppPath.c_str()); ZeroMemory(buff, (sizeof(WCHAR)*512)); GetPrivateProfileString(L"SYOBOI", L"devcolors", L"", buff, 512, iniAppPath.c_str()); wstring devcolors=buff; ZeroMemory(buff, (sizeof(WCHAR)*512)); GetPrivateProfileString(L"SYOBOI", L"epgurl", L"", buff, 512, iniAppPath.c_str()); wstring epgurl=buff; if( this->id.size() == 0 ){ _OutputDebugString(L"★SyoboiCalUtil:NoUserID"); return FALSE; } //Authorization wstring auth = L""; auth = this->id; auth += L":"; auth += this->pass; string authA; WtoA(auth, authA); DWORD destSize = 0; Base64Enc(authA.c_str(), (DWORD)authA.size(), NULL, &destSize); WCHAR* base64 = new WCHAR[destSize]; ZeroMemory(base64, destSize*sizeof(WCHAR)); Base64Enc(authA.c_str(), (DWORD)authA.size(), base64, &destSize); wstring authHead = L""; Format(authHead, L"Authorization: Basic %s\r\nContent-type: application/x-www-form-urlencoded\r\n", base64); //data wstring dataParam; wstring param; map<DWORD, wstring> tunerMap; for( size_t i=0; i<tunerList->size(); i++ ){ for( size_t j=0; j<(*tunerList)[i].reserveList.size(); j++ ){ tunerMap.insert(pair<DWORD, wstring>((*tunerList)[i].reserveList[j], (*tunerList)[i].tunerName)); } } map<DWORD, wstring>::iterator itrTuner; DWORD dataCount = 0; for(size_t i=0; i<reserveList->size(); i++ ){ if( dataCount>=200 ){ break; } RESERVE_DATA* info = (*reserveList)[i]; if( info->recSetting.recMode == RECMODE_NO || info->recSetting.recMode == RECMODE_VIEW ){ continue; } wstring device=L""; itrTuner = tunerMap.find(info->reserveID); if( itrTuner != tunerMap.end() ){ device = itrTuner->second; } wstring stationName = info->stationName; srvChg.ChgText(stationName); __int64 startTime = GetTimeStamp(info->startTime); Format(param, L"%I64d\t%I64d\t%s\t%s\t%s\t\t0\t%d\n", startTime, startTime+info->durationSecond, device.c_str(), info->title.c_str(), stationName.c_str(), info->reserveID ); dataParam+=param; } if(dataParam.size() == 0 ){ _OutputDebugString(L"★SyoboiCalUtil:NoReserve"); return FALSE; } string utf8; UrlEncodeUTF8(dataParam.c_str(), (DWORD)dataParam.size(), utf8); string data; Format(data, "slot=%d&data=%s",slot, utf8.c_str()); if( devcolors.size() > 0){ utf8 = ""; UrlEncodeUTF8(devcolors.c_str(), (DWORD)devcolors.size(), utf8); data += "&devcolors="; data += utf8; } if( epgurl.size() > 0){ utf8 = ""; UrlEncodeUTF8(epgurl.c_str(), (DWORD)epgurl.size(), utf8); data += "&epgurl="; data += utf8; } UPLOAD_DATA_LIST upList; upList.listCount = 1; upList.list = new UPLOAD_DATA[1]; upList.list->filePathFlag = 0; upList.list->buffSize = (DWORD)data.size(); upList.list->buff = new BYTE[data.size()+1]; ZeroMemory(upList.list->buff, data.size()+1); memcpy(upList.list->buff, data.c_str(), data.size()); wstring url; Format(url,L"%s",SYOBOI_UP_URL); CWinHTTPUtil http; DWORD result = NO_ERR; result = http.OpenSession(L"EpgTimerSrv", FALSE, useProxy, this->proxyInfo); if( result != NO_ERR ){ return FALSE; } result = http.SendRequest(url.c_str(), NW_VERB_POST, authHead.c_str(), NULL, &upList); DWORD dlSize = 0; http.GetDLBuff(NULL, &dlSize); if( dlSize > 0 ){ BYTE* dlBuff = new BYTE[dlSize+1]; ZeroMemory(dlBuff, dlSize+1); http.GetDLBuff(dlBuff, &dlSize); string response = (char*)dlBuff; SAFE_DELETE_ARRAY(dlBuff); } http.CloseRequest(); _OutputDebugString(L"★SyoboiCalUtil:SendRequest res:%d", result); if( result != NO_ERR ){ return FALSE; } return TRUE; }
int CZQIniFile::ReadInteger(char* szSection, char* szKey, int iDefaultValue) { int iResult = GetPrivateProfileInt((LPCSTR)szSection, (LPCSTR)szKey, iDefaultValue, (LPCSTR)m_szFileName); return iResult; }
int Ini::ReadInt(const char* key, int defaultValue, const char* section) const { return GetPrivateProfileInt(GetSection(section), key, defaultValue, _fname.c_str()); }
UINT WINAPI myGetProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, INT nDefault) { return GetPrivateProfileInt(lpAppName, lpKeyName, nDefault, pszFilename); }
extern int IniFileRead(TCHAR *ass_type, ass_setting_t *as) { int ret = -1; // Allocate string buffers. TCHAR *ini_file = new TCHAR[FILE_PATH_MAX]; TCHAR *tmp_buff = new TCHAR[INI_STRING_MAX]; WCHAR *utf8_str = new WCHAR[INI_STRING_MAX]; if (!ini_file || !tmp_buff || !utf8_str) goto EXIT; // Initliaze string buffers. memset(ini_file, 0, sizeof(TCHAR) * FILE_PATH_MAX); memset(tmp_buff, 0, sizeof(TCHAR) * INI_STRING_MAX); memset(utf8_str, 0, sizeof(WCHAR) * INI_STRING_MAX); // Get the file path of ini file. if (GetPrivateProfilePath(ini_file)) goto EXIT; // Open ini file. FILE *fp = NULL; if (_tfopen_s(&fp, ini_file, _T("r")) || !fp) { if (_tfopen_s(&fp, ini_file, _T("wb")) || !fp) goto EXIT; fprintf(fp, "%s", DEFAULT_INI); } fclose(fp); // Caption offset of SWF-Mode as->SWF0offset=GetPrivateProfileInt(_T("SWFModeOffset"), _T("SWF0offset"), 0, ini_file); as->SWF5offset=GetPrivateProfileInt(_T("SWFModeOffset"), _T("SWF5offset"), 0, ini_file); as->SWF7offset=GetPrivateProfileInt(_T("SWFModeOffset"), _T("SWF7offset"), 0, ini_file); as->SWF9offset=GetPrivateProfileInt(_T("SWFModeOffset"), _T("SWF9offset"), 0, ini_file); as->SWF11offset=GetPrivateProfileInt(_T("SWFModeOffset"), _T("SWF11offset"), 0, ini_file); // ass header infomation #define GET_INI_STRING(sec, key, def, tmp, str, len, ini, get) \ do { \ GetPrivateProfileString(sec, key, def, tmp, len, ini); \ MultiByteToWideChar(932, 0, tmp, -1, str, len); \ WideCharToMultiByte(CP_UTF8, 0, str, -1, get, len, NULL, NULL); \ } while (0) #define GET_INI_VALUE(sec, key, def, ini, get) \ do { \ get = GetPrivateProfileInt(sec, key, def, ini); \ } while (0) GET_INI_STRING(ass_type, _T("Comment1"), NULL, tmp_buff, utf8_str, INI_STRING_MAX, ini_file, as->Comment1); GET_INI_STRING(ass_type, _T("Comment2"), NULL, tmp_buff, utf8_str, INI_STRING_MAX, ini_file, as->Comment2); GET_INI_STRING(ass_type, _T("Comment3"), NULL, tmp_buff, utf8_str, INI_STRING_MAX, ini_file, as->Comment3); GET_INI_VALUE(ass_type, _T("PlayResX"), 1920, ini_file, as->PlayResX); GET_INI_VALUE(ass_type, _T("PlayResY"), 1080, ini_file, as->PlayResY); GET_INI_STRING(ass_type, _T("DefaultFontname"), _T("MS UI Gothic"), tmp_buff, utf8_str, INI_STRING_MAX, ini_file, as->DefaultFontname); GET_INI_VALUE(ass_type, _T("DefaultFontsize"), 90, ini_file, as->DefaultFontsize); GET_INI_STRING(ass_type, _T("DefaultStyle"), _T("&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,15,0,1,2,2,1,10,10,10,0") , tmp_buff, utf8_str, INI_STRING_MAX, ini_file, as->DefaultStyle); GET_INI_STRING(ass_type, _T("BoxFontname"), _T("MS UI Gothic"), tmp_buff, utf8_str, INI_STRING_MAX, ini_file, as->BoxFontname); GET_INI_VALUE(ass_type, _T("BoxFontsize"), 90, ini_file, as->BoxFontsize); GET_INI_STRING(ass_type, _T("BoxStyle"), _T("&HFFFFFFFF,&H000000FF,&H00FFFFFF,&H00FFFFFF,0,0,0,0,100,100,0,0,1,2,2,2,10,10,10,0") , tmp_buff, utf8_str, INI_STRING_MAX, ini_file, as->BoxStyle); GET_INI_STRING(ass_type, _T("RubiFontname"), _T("MS UI Gothic"), tmp_buff, utf8_str, INI_STRING_MAX, ini_file, as->RubiFontname); GET_INI_VALUE(ass_type, _T("RubiFontsize"), 50, ini_file, as->RubiFontsize); GET_INI_STRING(ass_type, _T("RubiStyle"), _T("&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,1,10,10,10,0") , tmp_buff, utf8_str, INI_STRING_MAX, ini_file, as->RubiStyle); #undef GET_INI_STRING #undef GET_INI_VALUE ret = 0; EXIT: SAFE_DELETE_ARRAY(ini_file); SAFE_DELETE_ARRAY(tmp_buff); SAFE_DELETE_ARRAY(utf8_str); return ret; }
BOOL CParseChText4::SaveChText(LPCWSTR filePath) { wstring loadFilePath = L""; wstring loadTunerName = L""; if( filePath == NULL ){ loadFilePath = this->filePath; loadTunerName = this->tunerName; }else{ loadFilePath = filePath; wregex re(L".+\\\\(.+)\\(.+\\)\\.ChSet4\\.txt$"); wstring text(filePath); wsmatch m; if( regex_search(text, m, re) ){ loadTunerName = m[1]; loadTunerName += L".dll"; } } if( loadFilePath.size() == 0 ){ return FALSE; } if( loadTunerName.size() == 0 ){ return FALSE; } multimap<LONGLONG, CH_DATA4> sortList; multimap<LONGLONG, CH_DATA4>::iterator itr; for( itr = this->chList.begin(); itr != this->chList.end(); itr++ ){ LONGLONG Key = ((LONGLONG)itr->second.space)<<32 | ((LONGLONG)itr->second.ch)<<16 | (LONGLONG)itr->second.serviceID; sortList.insert(pair<LONGLONG, CH_DATA4>(Key, itr->second)); } // ファイル出力 HANDLE hFile = _CreateFile2( loadFilePath.c_str(), GENERIC_WRITE, FILE_SHARE_READ, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); if( hFile == INVALID_HANDLE_VALUE ){ return FALSE; } for( itr = sortList.begin(); itr != sortList.end(); itr++ ){ string chName=""; WtoA(itr->second.chName, chName); string serviceName=""; WtoA(itr->second.serviceName, serviceName); string networkName=""; WtoA(itr->second.networkName, networkName); string strBuff; Format(strBuff, "%s\t%s\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\r\n", chName.c_str(), serviceName.c_str(), networkName.c_str(), itr->second.space, itr->second.ch, itr->second.originalNetworkID, itr->second.transportStreamID, itr->second.serviceID, itr->second.serviceType, itr->second.partialFlag, itr->second.useViewFlag, itr->second.remoconID ); DWORD dwWrite = 0; WriteFile(hFile, strBuff.c_str(), (DWORD)strBuff.length(), &dwWrite, NULL); } CloseHandle(hFile); wstring appIniPath = L""; GetModuleIniPath(appIniPath); wstring ipString; DWORD ip; DWORD port; ip = GetPrivateProfileInt(L"SET_UDP", L"IP0", 2130706433, appIniPath.c_str()); Format(ipString, L"%d.%d.%d.%d", (ip&0xFF000000)>>24, (ip&0x00FF0000)>>16, (ip&0x0000FF00)>>8, (ip&0x000000FF) ); port = GetPrivateProfileInt( L"SET_UDP", L"Port0", 3456, appIniPath.c_str() ); // MediaPortal TV Serverのデータベースへ登録 if (this->dbCtrl.Connect(&this->mysql, MYSQL_HOST, MYSQL_USER, MYSQL_PASSWD, MYSQL_DB) != 0) { return FALSE; } this->results = NULL; CString sql = L""; wstring wsql = L""; int chkNum = 0; this->dbCtrl.Begin(&this->mysql); map<CString, int> lockTable; lockTable[L"channelgroup"] = 2; lockTable[L"tuningdetail"] = 2; lockTable[L"groupmap" ] = 2; lockTable[L"channel" ] = 2; lockTable[L"channelmap" ] = 2; if (this->dbCtrl.LockTable(&this->mysql, lockTable) != 0) goto ESC; // channelgroupの登録が何個あるか調べる sql = L"SELECT idGroup FROM channelgroup WHERE idGroup < 2;"; if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; this->dbCtrl.StoreResult(&this->mysql, &this->results); chkNum = this->dbCtrl.NumRows(&this->results); this->dbCtrl.FreeResult(&this->results); int maxNum; sql = L"SELECT MAX(idGroup) FROM channelgroup;"; if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; this->dbCtrl.StoreResult(&this->mysql, &this->results); this->record = this->dbCtrl.FetchRow(&this->results); maxNum = atoi(this->record[0]); this->dbCtrl.FreeResult(&this->results); switch(chkNum){ case 0: // 登録が0個ならidGroupの0(地上波・BS)と1(CS)を登録する // idGroupに0はオートナンバーのためINSERTの段階では登録できないのでINSERTしてから変更する sql.Format(_T("INSERT INTO channelgroup VALUES(%d,'地上波・BS',0);"), maxNum + 1); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; sql.Format(_T("UPDATE channelgroup SET idGroup = 0 WHERE idGroup = %d;"), maxNum + 1); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; sql = L"INSERT INTO channelgroup VALUES(1,'CS',1);"; if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; break; case 1: // 登録が1個ならidGroupの1を末番に変更して、idGroupの0(地上波・BS)と1(CS)を登録する // 1個ということはMediaPortal_Bonより前にMediaPortal TV Serverのチャンネル設定で初期値が入った。 sql.Format(_T("UPDATE channelgroup SET idGroup = %d WHERE idGroup = 1;"), maxNum + 1); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; sql.Format(_T("UPDATE groupmap SET idGroup = %d WHERE idGroup = 1;"), maxNum + 1); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; sql = L"SELECT MAX(idGroup) FROM channelgroup;"; if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; this->dbCtrl.StoreResult(&this->mysql, &this->results); this->record = this->dbCtrl.FetchRow(&this->results); maxNum = atoi(this->record[0]); this->dbCtrl.FreeResult(&this->results); sql.Format(_T("INSERT INTO channelgroup VALUES(%d,'地上波・BS',0);"), maxNum + 1); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; sql.Format(_T("UPDATE channelgroup SET idGroup = 0 WHERE idGroup = %d;"), maxNum + 1); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; sql = L"INSERT INTO channelgroup VALUES(1,'CS',1);"; if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; break; } // 同じチューナーの既存の登録に対してチューナー名を変更する。 sql.Format(_T("UPDATE tuningdetail SET provider = '@_%s' WHERE provider = '%s';"), loadTunerName.c_str(), loadTunerName.c_str()); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; //sql.Format(_T("iterator = '%d' '%d';"), sortList.begin(), sortList.end()); //AfxMessageBox(sql, NULL, MB_OK); int tmpCh; // 登録用チャンネル for( itr = sortList.begin(); itr != sortList.end(); itr++ ){ if(itr->second.useViewFlag){ wsql = L""; wsql += L"SELECT idChannel FROM tuningdetail WHERE "; wsql += L"provider = '@_%s' AND "; wsql += L"channelNumber = %d AND "; wsql += L"networkId = %d AND "; wsql += L"transportId = %d AND "; wsql += L"serviceId = %d;"; sql.Format(wsql.c_str(), loadTunerName.c_str(), itr->second.ch, itr->second.originalNetworkID, itr->second.transportStreamID, itr->second.serviceID ); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; this->dbCtrl.StoreResult(&this->mysql, &this->results); //AfxMessageBox(loadTunerName.c_str(), NULL, MB_OK); if(this->dbCtrl.NumRows(&this->results)){ // 既存のチャンネルは退避する this->record = this->dbCtrl.FetchRow(&this->results); tmpCh = atoi(this->record[0]); this->dbCtrl.FreeResult(&this->results); wsql = L""; wsql += L"UPDATE tuningdetail SET provider = '%s' WHERE "; wsql += L"provider = '@_%s' AND "; wsql += L"channelNumber = %d AND "; wsql += L"networkId = %d AND "; wsql += L"transportId = %d AND "; wsql += L"serviceId = %d;"; sql.Format(wsql.c_str(), loadTunerName.c_str(), loadTunerName.c_str(), itr->second.ch, itr->second.originalNetworkID, itr->second.transportStreamID, itr->second.serviceID ); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; // 既存のチャンネル登録があってもgroupmap.idGroupが適切な値(0:地上波・BS, 1:CS)になっているかを調べる。 sql.Format(_T("SELECT idMap FROM groupmap WHERE idChannel = %d AND idGroup = %d;"), tmpCh, itr->second.space); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; this->dbCtrl.StoreResult(&this->mysql, &this->results); if(!this->dbCtrl.NumRows(&this->results)){ this->dbCtrl.FreeResult(&this->results); sql = L"SELECT SortOrder FROM groupmap;"; if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; this->dbCtrl.StoreResult(&this->mysql, &this->results); maxNum = this->dbCtrl.NumRows(&this->results); // groupmap.idGroupに適切な値(0:地上波・BS, 1:CS)の登録を行う。 sql.Format(_T("INSERT INTO groupmap VALUES(0, %d, %d, %d);"), itr->second.space, tmpCh, maxNum); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; } this->dbCtrl.FreeResult(&this->results); // チャンネル概要があるか sql.Format(_T("SELECT displayName FROM channel WHERE idChannel = %d;"), tmpCh); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; this->dbCtrl.StoreResult(&this->mysql, &this->results); if(!this->dbCtrl.NumRows(&this->results)){ // チャンネルの登録を行う。 sql.Format(_T("INSERT INTO channel VALUES(%d,0,1,0,'2000-01-01 00:00:00',0,'2000-01-01 00:00:00',%d,1,'','%s',0,%d);"), tmpCh, (tmpCh + itr->second.space * 1000), itr->second.serviceName.c_str(), itr->second.ch ); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; } this->dbCtrl.FreeResult(&this->results); // チャンネルマップがあるか sql.Format(_T("SELECT idChannelMap FROM channelmap WHERE idChannel = %d AND idCard = 1;"), tmpCh); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; this->dbCtrl.StoreResult(&this->mysql, &this->results); if(!this->dbCtrl.NumRows(&this->results)){ // チャンネルマップの登録を行う。 sql.Format(_T("INSERT INTO channelmap VALUES(0,%d,1,0);"), tmpCh); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; } this->dbCtrl.FreeResult(&this->results); } else { // チャンネルを新規登録 this->dbCtrl.FreeResult(&this->results); // BONドライバーが違っても同じチャンネルがあるかどうか wsql = L""; wsql += L"SELECT idChannel FROM tuningdetail WHERE "; wsql += L"provider <> '@_%s' AND "; wsql += L"channelNumber = %d AND "; wsql += L"networkId = %d AND "; wsql += L"transportId = %d AND "; wsql += L"serviceId = %d;"; sql.Format(wsql.c_str(), loadTunerName.c_str(), itr->second.ch, itr->second.originalNetworkID, itr->second.transportStreamID, itr->second.serviceID ); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; this->dbCtrl.StoreResult(&this->mysql, &this->results); // 同じチャンネルがある場合はそのチャンネルを使う // ない場合はチャンネル概要の次番号を得る。 if(!this->dbCtrl.NumRows(&this->results)){ sql = L"SELECT MAX(idChannel) FROM channel;"; if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; this->dbCtrl.StoreResult(&this->mysql, &this->results); } this->record = this->dbCtrl.FetchRow(&this->results); //if(CA2T(this->record[0], CP_UTF8) == L"") maxNum = 0; if(this->record[0] == 0x00000000) maxNum = 0; else maxNum = atoi(this->record[0]); tmpCh = maxNum + 1; this->dbCtrl.FreeResult(&this->results); // チャンネル概要があるか sql.Format(_T("SELECT displayName FROM channel WHERE idChannel = %d;"), tmpCh); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; this->dbCtrl.StoreResult(&this->mysql, &this->results); if(!this->dbCtrl.NumRows(&this->results)){ // チャンネルの登録を行う。 sql.Format(_T("INSERT INTO channel VALUES(%d,0,1,0,'2000-01-01 00:00:00',0,'2000-01-01 00:00:00',%d,1,'','%s',0,%d);"), tmpCh, (tmpCh + itr->second.space * 1000), itr->second.serviceName.c_str(), itr->second.ch ); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; } this->dbCtrl.FreeResult(&this->results); // チャンネル詳細の次番号を得る。 int maxTuNum; sql = L"SELECT MAX(idTuning) FROM tuningdetail;"; if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; this->dbCtrl.StoreResult(&this->mysql, &this->results); this->record = this->dbCtrl.FetchRow(&this->results); if(this->record[0] == 0x00000000) maxTuNum = 0; else maxTuNum = atoi(this->record[0]); this->dbCtrl.FreeResult(&this->results); // チャンネル詳細登録 sql.Format(L"INSERT INTO tuningdetail VALUES(%d,%d,'%s','%s',7,%d,0,31,0,1,%d,%d,%d,496,0,0,0,0,1,0,8,-1,-1,0,0,0,-1,-1,-1,-1,'udp://%s:%d',0,0,0);", maxTuNum + 1, tmpCh, itr->second.serviceName.c_str(), loadTunerName.c_str(), itr->second.ch, itr->second.originalNetworkID, itr->second.transportStreamID, itr->second.serviceID, ipString.c_str(), port ); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; //AfxMessageBox(sql, NULL, MB_OK); // グループがあるか sql.Format(_T("SELECT idChannel FROM groupmap WHERE idGroup = %d AND idChannel = %d;"), itr->second.space, tmpCh); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; this->dbCtrl.StoreResult(&this->mysql, &this->results); if(!this->dbCtrl.NumRows(&this->results)){ this->dbCtrl.FreeResult(&this->results); sql = L"SELECT SortOrder FROM groupmap;"; if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; this->dbCtrl.StoreResult(&this->mysql, &this->results); maxNum = this->dbCtrl.NumRows(&this->results); // グループの登録を行う。 sql.Format(_T("INSERT INTO groupmap VALUES(0, %d, %d, %d);"), itr->second.space, tmpCh, maxNum); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; } this->dbCtrl.FreeResult(&this->results); // チャンネルマップがあるか sql.Format(_T("SELECT idChannelMap FROM channelmap WHERE idChannel = %d AND idCard = 2;"), tmpCh); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; this->dbCtrl.StoreResult(&this->mysql, &this->results); if(!this->dbCtrl.NumRows(&this->results)){ // チャンネルマップの登録を行う。 sql.Format(_T("INSERT INTO channelmap VALUES(0,%d,2,0);"), tmpCh); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; } this->dbCtrl.FreeResult(&this->results); } } } // 残ったチャンネルを削除する sql.Format(_T("DELETE FROM tuningdetail WHERE provider = '@_%s';"), loadTunerName.c_str()); if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; // ついでにチューナーのないチャンネルを削除する sql = L"DELETE channel FROM channel LEFT JOIN tuningdetail ON channel.idChannel = tuningdetail.idChannel WHERE tuningdetail.idChannel IS NULL;"; if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; // ついでにチャンネルのないグループを削除する。 sql = L"DELETE groupmap FROM groupmap LEFT JOIN channel ON groupmap.idChannel = channel.idChannel WHERE channel.idChannel IS NULL;"; if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; // ついでにチャンネルのないチャンネルマップも削除する sql = L"DELETE channelmap FROM channelmap LEFT JOIN channel ON channelmap.idChannel = channel.idChannel WHERE channel.idChannel IS NULL;"; if (this->dbCtrl.Query(&this->mysql, sql) != 0) goto ESC; this->dbCtrl.Commit(&this->mysql); this->dbCtrl.UnlockTable(&this->mysql); this->dbCtrl.Close(&this->mysql); return TRUE; ESC: wstring err = L""; Format(err, L"ERROR SQL:%s", sql); AfxMessageBox(err.c_str(), NULL, MB_OK); this->dbCtrl.Rollback(&this->mysql); this->dbCtrl.UnlockTable(&this->mysql); this->dbCtrl.Close(&this->mysql); return FALSE; }
void load_setup (void) { static char *buffer; char *profile; char *inifile; int i; #ifdef USE_NETCODE extern char *ftpfs_proxy_host; #endif buffer = concat_dir_and_file (home_dir, PROFILE_NAME); inifile = concat_dir_and_file (mc_home, "mc.ini"); if (exist_file (buffer)){ profile = buffer; } else if (exist_file (inifile)){ profile = strdup (inifile); free (buffer); } else { profile = buffer; } free (inifile); profile_name = profile; /* Load integer boolean options */ for (i = 0; options [i].opt_name; i++) *options [i].opt_addr = get_int (profile, options [i].opt_name, *options [i].opt_addr); load_layout (profile); load_panelize (); startup_left_mode = load_mode ("New Left Panel"); startup_right_mode = load_mode ("New Right Panel"); /* At least one of the panels is a listing panel */ if (startup_left_mode != view_listing && startup_right_mode!=view_listing) startup_left_mode = view_listing; if (!other_dir){ buffer = (char*) malloc (MC_MAXPATHLEN); load_string ("Dirs", "other_dir", ".", buffer, MC_MAXPATHLEN); if (vfs_file_is_local (buffer)) other_dir = buffer; else free (buffer); } #ifdef USE_NETCODE ftpfs_proxy_host = do_load_string ("Misc", "ftp_proxy_host", "gate"); #endif boot_current_is_left = GetPrivateProfileInt ("Dirs", "current_is_left", 1, profile); load_string ("Misc", "find_ignore_dirs", "", setup_color_string, sizeof (setup_color_string)); if (setup_color_string [0]) find_ignore_dirs = copy_strings (":", setup_color_string, ":", 0); /* The default color and the terminal dependent color */ load_string ("Colors", "base_color", "", setup_color_string, sizeof (setup_color_string)); load_string ("Colors", getenv ("TERM"), "", term_color_string, sizeof (term_color_string)); load_string ("Colors", "color_terminals", "", color_terminal_string, sizeof (color_terminal_string)); /* Load the directory history */ /* directory_history_load (); */ /* Remove the temporal entries */ profile_clean_section ("Temporal:New Left Panel", profile_name); profile_clean_section ("Temporal:New Right Panel", profile_name); #ifdef USE_VFS #ifdef USE_NETCODE ftpfs_init_passwd (); #endif #endif }
int IniHandler::ReadInt(char* p_section, char* p_key, int p_defaultValue) { return GetPrivateProfileInt(p_section, p_key, p_defaultValue, fileName); }
int GSdxApp::GetConfig(const char* entry, int value) { return GetPrivateProfileInt(m_section.c_str(), entry, value, m_ini.c_str()); }
int ReadCfgInt (char *Section,char *Key,int DefaultValue) { return GetPrivateProfileInt( Section, Key, DefaultValue, CfgFilePath()); }
/** * GetVersionDependentKADFileName. Gets the version dependent compiler KAD. * It uses the command line, if there is a target file it's firmware version * is read and then using the <target type>_Addon.kad the final name of the kad is * searched. If no target or no speciffic kad is specified in <target type>_Addon.kad * the default kad <<target type>_4cvm.kad is assumed. * @param pdm IN diag message sink * @param pOpt IN the command line arguments * @param kadFile OUT receives the kad file name and full path * @param ulTrgVer OUT receive firmware version * @return void */ static void GetVersionDependentKADFileName( CGT_CDiagMsg* pdm, const CMDL_OPT_TYP* pOpt, FC_CString& kadFile, unsigned long& ulTrgVer ) { FC_CString addonKad(MAX_PATH); FC_CString prjPath(MAX_PATH); FC_CString binPath(MAX_PATH); IXMLDOMNode* pNode; IXMLDOMNodeList*pNList; long len; FC_CString jot; long i; ulTrgVer = 0; kadFile.clear(); binPath.load(g_szModuleName).stripFilePart(); prjPath.load(pOpt->sz4CP).stripFilePart(); //if there is a target file or check file given in the command line get the target version if(!pOpt->szCheckFile.isEmpty()) { //TODO: Workaround: passing an optional target version number via the command line //is not possible because we may have very old backends, we pass this info //inside a file with fixed name, old backend simple don't read it. //If we make a new major version all backends should add this to there cmd line //and then we don't need this tmp file any more... FC_CString sCheckInfo(MAX_PATH); sCheckInfo.load(prjPath)<<_T("\\gen\\checkinf.tmp"); ulTrgVer = GetPrivateProfileInt(_T("target"), _T("version"), 0, sCheckInfo); } else if(pOpt->targets.getUsed()>0) { ulTrgVer = GetTargetVersion(pdm, prjPath, pOpt->targets.get(0)); //Note: if more than one target is specified CGlobCtx::loadTargets() will //later treat this as an "error not supported multiple targets". //This solution here is only possible if at max one target at a time is built! } if(ulTrgVer>0) { //Addon KAD = "<installdir>\bin\<trgtyp>_Addon.kad" addonKad<<binPath<<'\\'<<pOpt->szCurTrgTyp<<_T("_Addon.kad"); if(FC_Exist(addonKad)) { //open xml file: pNode = CGT_XMLLoadFile(pdm, NULL, addonKad, NULL); if(pNode) { // read targets pNList = NULL; len = 0; pNode->selectNodes(L"FIRMWARE", &pNList); FC_RELEASE_PTR(pNode); pNList->get_length(&len); for(i=0;i<len;i++) { pNList->get_item(i, &pNode); if(CGT_XMLGetStrAttrTrim(pdm, pNode, L"VERSION", &jot, false, false)) { if(strtoul(jot, NULL, 10)==ulTrgVer) { CGT_XMLGetStrAttrTrim(pdm, pNode, L"COMPILERKAD", &kadFile, false, true); FC_RELEASE_PTR(pNode); break; } } FC_RELEASE_PTR(pNode); } } }//<targettyp>_addon.kad does not exist, this is for backward compatibillity (4cec!) }//else: maybe check file or build lib, we have no version info!! use default KAD if(kadFile.isEmpty()) {//Not found in AddonKAD with version: //default compiler kad = "<installdir>\bin\<trgtyp>_4cvm.kad" kadFile<<binPath<<'\\'<<pOpt->szCurTrgTyp<<_T("_4cvm.kad"); } else {//Found in AddonKAD with version: //make an absolute path: kadFile.prepend(binPath, "\\"); } }
int LoadNewPluginsModule(void) { TCHAR exe[MAX_PATH]; TCHAR* slice; pluginEntry* p; pluginEntry* clist = NULL; int useWhiteList, i; bool msgModule = false; // make full path to the plugin GetModuleFileName(NULL, exe, SIZEOF(exe)); slice = _tcsrchr(exe, '\\'); if (slice) *slice = 0; // remember some useful options askAboutIgnoredPlugins=(UINT) GetPrivateProfileInt( _T("PluginLoader"), _T("AskAboutIgnoredPlugins"), 0, mirandabootini); // if Crash Dumper is present, load it to provide Crash Reports if (pluginList_crshdmp != NULL && isPluginOnWhiteList(pluginList_crshdmp->pluginname)) { if ( pluginList_crshdmp->bpi.Load(&pluginCoreLink) == 0 ) pluginList_crshdmp->pclass |= PCLASS_LOADED | PCLASS_LAST; else Plugin_Uninit( pluginList_crshdmp ); } // if freeimage is present, load it to provide the basic core functions if ( pluginList_freeimg != NULL ) { BASIC_PLUGIN_INFO bpi; mir_sntprintf(slice, &exe[SIZEOF(exe)] - slice, _T("\\Plugins\\%s"), pluginList_freeimg->pluginname); if ( checkAPI(exe, &bpi, mirandaVersion, CHECKAPI_NONE, NULL) ) { pluginList_freeimg->bpi = bpi; pluginList_freeimg->pclass |= PCLASS_OK | PCLASS_BASICAPI; if ( bpi.Load(&pluginCoreLink) == 0 ) pluginList_freeimg->pclass |= PCLASS_LOADED; else Plugin_Uninit( pluginList_freeimg ); } } // first load the clist cos alot of plugins need that to be present at Load() for ( useWhiteList = 1; useWhiteList >= 0 && clist == NULL; useWhiteList-- ) clist=getCListModule(exe, slice, useWhiteList); /* the loop above will try and get one clist DLL to work, if all fail then just bail now */ if ( clist == NULL ) { // result = 0, no clist_* can be found if ( pluginListUI ) MessageBox(NULL, TranslateT("Unable to start any of the installed contact list plugins, I even ignored your preferences for which contact list couldn't load any."), _T("Miranda IM"), MB_OK | MB_ICONINFORMATION); else MessageBox(NULL, TranslateT("Can't find a contact list plugin! you need clist_classic or any other clist plugin.") , _T("Miranda IM"), MB_OK | MB_ICONINFORMATION); return 1; } /* enable and disable as needed */ p = pluginListUI; while ( p != NULL ) { SetPluginOnWhiteList(p->pluginname, clist != p ? 0 : 1 ); p = p->nextclass; } /* now loop thru and load all the other plugins, do this in one pass */ for ( i=0; i < pluginList.getCount(); i++ ) { p = pluginList[i]; CharLower(p->pluginname); if (!(p->pclass & (PCLASS_LOADED | PCLASS_DB | PCLASS_CLIST))) { if (isPluginOnWhiteList(p->pluginname)) { BASIC_PLUGIN_INFO bpi; mir_sntprintf(slice, &exe[SIZEOF(exe)] - slice, _T("\\Plugins\\%s"), p->pluginname); if ( checkAPI(exe, &bpi, mirandaVersion, CHECKAPI_NONE, NULL) ) { int rm = bpi.pluginInfo->replacesDefaultModule; p->bpi = bpi; p->pclass |= PCLASS_OK | PCLASS_BASICAPI; if ( pluginDefModList[rm] == NULL ) { pluginListAddr.insert( p ); if ( bpi.Load(&pluginCoreLink) == 0 ) { p->pclass |= PCLASS_LOADED; msgModule |= (bpi.pluginInfo->replacesDefaultModule == DEFMOD_SRMESSAGE); } else { Plugin_Uninit( p ); i--; } if ( rm ) pluginDefModList[rm]=p; } //if else { SetPluginOnWhiteList( p->pluginname, 0 ); Plugin_Uninit( p ); i--; } } else p->pclass |= PCLASS_FAILED; } else { Plugin_Uninit( p ); i--; } } else if ( p->bpi.hInst != NULL ) { pluginListAddr.insert( p ); p->pclass |= PCLASS_LOADED; } } if (!msgModule) MessageBox(NULL, TranslateT("No messaging plugins loaded. Please install/enable one of the messaging plugins, for instance, \"srmm.dll\""), _T("Miranda IM"), MB_OK | MB_ICONINFORMATION); HookEvent(ME_OPT_INITIALISE, PluginOptionsInit); return 0; }