void GLFragmentDecompilerThread::AddCode(const std::string& code) { main.append(m_code_level, '\t') += Format(code) + "\n"; }
// Read the string table bool LoadTableMain(wchar_t *filename) { BUF *b; UINT64 t1, t2; UCHAR hash[MD5_SIZE]; // Validate arguments if (filename == NULL) { return false; } if (MayaquaIsMinimalMode()) { return true; } if (UniStrCmpi(old_table_name, filename) == 0) { // Already loaded return true; } t1 = Tick64(); // Open the file b = ReadDumpW(filename); if (b == NULL) { char tmp[MAX_SIZE]; StrCpy(tmp, sizeof(tmp), "Error: Can't read string tables (file not found).\r\nPlease check hamcore.se2.\r\n\r\n(First, reboot the computer. If this problem occurs again, please reinstall VPN software files.)"); Alert(tmp, NULL); exit(-1); return false; } Hash(hash, b->Buf, b->Size, false); if (LoadUnicodeCache(filename, b->Size, hash) == false) { if (LoadTableFromBuf(b) == false) { FreeBuf(b); return false; } SaveUnicodeCache(filename, b->Size, hash); //Debug("Unicode Source: strtable.stb\n"); } else { //Debug("Unicode Source: unicode_cache\n"); } FreeBuf(b); SetLocale(_UU("DEFAULE_LOCALE")); UniStrCpy(old_table_name, sizeof(old_table_name), filename); t2 = Tick64(); if (StrCmpi(_SS("STRTABLE_ID"), STRTABLE_ID) != 0) { char tmp[MAX_SIZE]; Format(tmp, sizeof(tmp), "Error: Can't read string tables (invalid version: '%s'!='%s').\r\nPlease check hamcore.se2.\r\n\r\n(First, reboot the computer. If this problem occurs again, please reinstall VPN software files.)", _SS("STRTABLE_ID"), STRTABLE_ID); Alert(tmp, NULL); exit(-1); return false; } //Debug("Unicode File Read Cost: %u (%u Lines)\n", (UINT)(t2 - t1), LIST_NUM(TableList)); return true; }
void __fastcall TProgressPanel::UpdateProgress(bool Regular) { float interval = 0.0; if (Regular) { DWORD ticks = GetTickCount(); if (ticks > this->FLastTicks) { interval = ((float)(ticks - this->FLastTicks))/1000.0; this->FCurElapsed += interval; this->FOvrElapsed += interval; } this->FLastTicks = ticks; } UnicodeString oper = this->FOperation; float cur, ovr; long double cur_completed, ovr_completed; if (this->FTotalWork > 0.00) { cur = this->FCompleteRatio; cur_completed = this->FCurrentWork*(long double)cur; ovr_completed = this->FCommittedWork + cur_completed; if (this->FTotalWork > 0.0) { ovr = ovr_completed/this->FTotalWork; } else { ovr = 0.0; } } else { cur = 0.00; ovr = 0.00; cur_completed = 0.0; ovr_completed = 0.0; } UnicodeString cur_bytes, ovr_bytes, cur_eta, ovr_eta; if (this->FCurrentBytes > 0) { cur_bytes = Format(TXT_COMPLETED, ARRAYOFCONST((this->FCompletedText, FormatDataSize(this->FCompletedBytes), FormatDataSize(this->FCurrentBytes)))); } if (this->FTotalBytes > 0) { ovr_bytes = Format(TXT_COMPLETED, ARRAYOFCONST((this->FCompletedText, FormatDataSize(this->FCommittedBytes + this->FCompletedBytes), FormatDataSize(this->FTotalBytes)))); } if (!this->FSubOperation.IsEmpty()) { if (cur_bytes.IsEmpty()) cur_bytes = this->FSubOperation + L"..."; else cur_bytes += L" - " + this->FSubOperation; } if (Regular && (this->FEnableSpeed || this->FEnableETA!=ETA_NONE)) { if (interval > 0.0) { if (this->FEnableSpeed && this->FLastBytes >= 0) { float speed = ((float)(this->FCompletedBytes - this->FLastBytes))/interval; if (this->AveragerSpeed) { this->AveragerSpeed->Add(speed); speed = this->AveragerSpeed->GetAverage(); } if (speed > 0) { ovr_bytes += L" at " + FormatDataSize(speed, true); } } if (this->FEnableETA!=ETA_NONE && this->FLastWork >= 0) { float speed = ((float)(ovr_completed - this->FLastWork))/interval; if (this->AveragerETA) { this->AveragerETA->Add(speed); speed = this->AveragerETA->GetAverage(); } if (speed > 0.0) { long secs_current = Round((this->FCurrentWork - cur_completed)/speed); long secs_overall = Round((this->FTotalWork - ovr_completed)/speed); if (this->FEnableETA&ETA_CURRENT && secs_current > 0 && secs_current < MAX_ETA) { cur_eta = L"Time Left: " + FormatDuration(secs_current); } if (this->FEnableETA&ETA_OVERALL && secs_overall > 0 && secs_overall < MAX_ETA) { ovr_eta = L"Time Left: " + FormatDuration(secs_overall); } } } } if (this->EnableETA!=ETA_NONE) this->FLastWork = ovr_completed; if (this->EnableSpeed) this->FLastBytes = this->FCompletedBytes; } //Assign UI values this->lblOperation->Caption = ReplaceStr(oper, L"&", L"&&"); this->pbCurrent->Position = cur * (float)PROGRESSBAR_GRADATION; this->lblCurPercent->Caption = IntToStr(Round(cur*100)) + L"%"; this->pbOverall->Position = ovr * (float)PROGRESSBAR_GRADATION; this->lblOvrPercent->Caption = IntToStr(Round(ovr*100)) + L"%"; this->lblCurCompleted->Caption = cur_bytes; this->lblOvrCompleted->Caption = ovr_bytes; if (Regular) { this->lblOvrTimeleft->Caption = ovr_eta; this->lblCurTimeleft->Caption = cur_eta; } this->lblCurElapsed->Caption = L"Elapsed: " + FormatDuration(this->FCurElapsed); this->lblOvrElapsed->Caption = L"Elapsed: " + FormatDuration(this->FOvrElapsed); this->Update(); }
void TextureConverterCell::SetTexture(const FilePath &texturePath) { textureFormat->SetText(L""); textureSize->SetText(L""); textureName->SetText(StringToWString(texturePath.GetFilename())); Texture *texture = Texture::CreateFromFile(texturePath); Sprite *s = Sprite::CreateFromTexture(texture, 0, 0, (float32)texture->width, (float32)texture->height); preview->SetSprite(s, 0); if(texturePath.IsEqualToExtension(".png")) { String pngFormat = Texture::GetPixelFormatString(texture->format); FilePath pvrPath = FilePath::CreateWithNewExtension(texturePath, ".pvr"); Texture *pvrTex = Texture::CreateFromFile(pvrPath); if(pvrTex) { PixelFormat format = LibPVRHelper::GetPixelFormat(pvrPath); uint32 pvrDataSize = LibPVRHelper::GetDataSize(pvrPath); String pvrFormat = Texture::GetPixelFormatString(format); textureFormat->SetText(StringToWString(pngFormat + "/" + pvrFormat)); textureSize->SetText(SizeInBytesToWideString(pvrDataSize)); SafeRelease(pvrTex); } else { textureFormat->SetText(StringToWString(pngFormat)); } } else if(texturePath.IsEqualToExtension(".pvr")) { PixelFormat format = LibPVRHelper::GetPixelFormat(texturePath); uint32 pvrDataSize = LibPVRHelper::GetDataSize(texturePath); String pvrFormat = Texture::GetPixelFormatString(format); textureSize->SetText(SizeInBytesToWideString(pvrDataSize)); FilePath pngPath = FilePath::CreateWithNewExtension(texturePath, ".png"); Texture *pngTex = Texture::CreateFromFile(pngPath); if(pngTex) { String pngFormat = Texture::GetPixelFormatString(pngTex->format); textureFormat->SetText(StringToWString(pngFormat + "/" + pvrFormat)); SafeRelease(pngTex); } else { textureFormat->SetText(StringToWString(pvrFormat)); } } textureDimensions->SetText(Format(L"%d x %d", texture->width, texture->height)); SafeRelease(texture); SafeRelease(s); }
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; }
String Parser::clear(String arg) { return Format("Clear(%s)",OPENARRAY(TVarRec,(arg))); }
String Parser::smaller(String arg1,String arg2) { return Format("Smaller(%s,%s)",OPENARRAY(TVarRec,(arg1,arg2))); }
// Parse the URL bool ParseUrl(URL_DATA *data, char *str, bool is_post, char *referrer) { char tmp[MAX_SIZE * 3]; char server_port[MAX_HOST_NAME_LEN + 16]; char *s = NULL; char *host; UINT port; UINT i; // Validate arguments if (data == NULL || str == NULL) { return false; } Zero(data, sizeof(URL_DATA)); if (is_post) { StrCpy(data->Method, sizeof(data->Method), WPC_HTTP_POST_NAME); } else { StrCpy(data->Method, sizeof(data->Method), WPC_HTTP_GET_NAME); } if (referrer != NULL) { StrCpy(data->Referer, sizeof(data->Referer), referrer); } StrCpy(tmp, sizeof(tmp), str); Trim(tmp); // Determine the protocol if (StartWith(tmp, "http://")) { data->Secure = false; s = &tmp[7]; } else if (StartWith(tmp, "https://")) { data->Secure = true; s = &tmp[8]; } else { if (SearchStrEx(tmp, "://", 0, false) != INFINITE) { return false; } data->Secure = false; s = &tmp[0]; } // Get the "server name:port number" StrCpy(server_port, sizeof(server_port), s); i = SearchStrEx(server_port, "/", 0, false); if (i != INFINITE) { server_port[i] = 0; s += StrLen(server_port); StrCpy(data->Target, sizeof(data->Target), s); } else { StrCpy(data->Target, sizeof(data->Target), "/"); } if (ParseHostPort(server_port, &host, &port, data->Secure ? 443 : 80) == false) { return false; } StrCpy(data->HostName, sizeof(data->HostName), host); data->Port = port; Free(host); if ((data->Secure && data->Port == 443) || (data->Secure == false && data->Port == 80)) { StrCpy(data->HeaderHostName, sizeof(data->HeaderHostName), data->HostName); } else { Format(data->HeaderHostName, sizeof(data->HeaderHostName), "%s:%u", data->HostName, data->Port); } return true; }
BUF *HttpRequestEx3(URL_DATA *data, INTERNET_SETTING *setting, UINT timeout_connect, UINT timeout_comm, UINT *error_code, bool check_ssl_trust, char *post_data, WPC_RECV_CALLBACK *recv_callback, void *recv_callback_param, void *sha1_cert_hash, UINT num_hashes, bool *cancel, UINT max_recv_size, char *header_name, char *header_value) { WPC_CONNECT con; SOCK *s; HTTP_HEADER *h; bool use_http_proxy = false; char target[MAX_SIZE * 4]; char *send_str; BUF *send_buf; BUF *recv_buf; UINT http_error_code; char len_str[100]; UINT content_len; void *socket_buffer; UINT socket_buffer_size = WPC_RECV_BUF_SIZE; UINT num_continue = 0; INTERNET_SETTING wt_setting; // Validate arguments if (data == NULL) { return NULL; } if (setting == NULL) { Zero(&wt_setting, sizeof(wt_setting)); setting = &wt_setting; } if (error_code == NULL) { static UINT ret = 0; error_code = &ret; } if (timeout_comm == 0) { timeout_comm = WPC_TIMEOUT; } if (sha1_cert_hash == NULL) { num_hashes = 0; } if (num_hashes == 0) { sha1_cert_hash = NULL; } // Connection Zero(&con, sizeof(con)); StrCpy(con.HostName, sizeof(con.HostName), data->HostName); con.Port = data->Port; con.ProxyType = setting->ProxyType; StrCpy(con.ProxyHostName, sizeof(con.ProxyHostName), setting->ProxyHostName); con.ProxyPort = setting->ProxyPort; StrCpy(con.ProxyUsername, sizeof(con.ProxyUsername), setting->ProxyUsername); StrCpy(con.ProxyPassword, sizeof(con.ProxyPassword), setting->ProxyPassword); if (setting->ProxyType != PROXY_HTTP || data->Secure) { use_http_proxy = false; StrCpy(target, sizeof(target), data->Target); } else { use_http_proxy = true; CreateUrl(target, sizeof(target), data); } if (use_http_proxy == false) { // If the connection is not via HTTP Proxy, or is a SSL connection even via HTTP Proxy s = WpcSockConnectEx(&con, error_code, timeout_connect, cancel); } else { // If the connection is not SSL via HTTP Proxy s = TcpConnectEx3(con.ProxyHostName, con.ProxyPort, timeout_connect, cancel, NULL, true, NULL, false, false, NULL); if (s == NULL) { *error_code = ERR_PROXY_CONNECT_FAILED; } } if (s == NULL) { return NULL; } if (data->Secure) { // Start the SSL communication if (StartSSLEx(s, NULL, NULL, true, 0, (IsEmptyStr(data->SniString) ? NULL : data->SniString)) == false) { // SSL connection failed *error_code = ERR_PROTOCOL_ERROR; Disconnect(s); ReleaseSock(s); return NULL; } if (sha1_cert_hash != NULL && num_hashes >= 1) { UCHAR hash[SHA1_SIZE]; UINT i; bool ok = false; Zero(hash, sizeof(hash)); GetXDigest(s->RemoteX, hash, true); for (i = 0;i < num_hashes;i++) { UCHAR *a = (UCHAR *)sha1_cert_hash; a += (SHA1_SIZE * i); if (Cmp(hash, a, SHA1_SIZE) == 0) { ok = true; break; } } if (ok == false) { // Destination certificate hash mismatch *error_code = ERR_CERT_NOT_TRUSTED; Disconnect(s); ReleaseSock(s); return NULL; } } } // Timeout setting SetTimeout(s, timeout_comm); // Generate a request h = NewHttpHeader(data->Method, target, use_http_proxy ? "HTTP/1.0" : "HTTP/1.1"); AddHttpValue(h, NewHttpValue("Keep-Alive", HTTP_KEEP_ALIVE)); AddHttpValue(h, NewHttpValue("Connection", "Keep-Alive")); AddHttpValue(h, NewHttpValue("Accept-Language", "ja")); AddHttpValue(h, NewHttpValue("User-Agent", WPC_USER_AGENT)); AddHttpValue(h, NewHttpValue("Pragma", "no-cache")); AddHttpValue(h, NewHttpValue("Cache-Control", "no-cache")); AddHttpValue(h, NewHttpValue("Host", data->HeaderHostName)); if (IsEmptyStr(header_name) == false && IsEmptyStr(header_value) == false) { AddHttpValue(h, NewHttpValue(header_name, header_value)); } if (IsEmptyStr(data->Referer) == false) { AddHttpValue(h, NewHttpValue("Referer", data->Referer)); } if (StrCmpi(data->Method, WPC_HTTP_POST_NAME) == 0) { ToStr(len_str, StrLen(post_data)); AddHttpValue(h, NewHttpValue("Content-Type", "application/x-www-form-urlencoded")); AddHttpValue(h, NewHttpValue("Content-Length", len_str)); } if (IsEmptyStr(data->AdditionalHeaderName) == false && IsEmptyStr(data->AdditionalHeaderValue) == false) { AddHttpValue(h, NewHttpValue(data->AdditionalHeaderName, data->AdditionalHeaderValue)); } if (use_http_proxy) { AddHttpValue(h, NewHttpValue("Proxy-Connection", "Keep-Alive")); if (IsEmptyStr(setting->ProxyUsername) == false || IsEmptyStr(setting->ProxyPassword) == false) { char auth_tmp_str[MAX_SIZE], auth_b64_str[MAX_SIZE * 2]; char basic_str[MAX_SIZE * 2]; // Generate the authentication string Format(auth_tmp_str, sizeof(auth_tmp_str), "%s:%s", setting->ProxyUsername, setting->ProxyPassword); // Base64 encode Zero(auth_b64_str, sizeof(auth_b64_str)); Encode64(auth_b64_str, auth_tmp_str); Format(basic_str, sizeof(basic_str), "Basic %s", auth_b64_str); AddHttpValue(h, NewHttpValue("Proxy-Authorization", basic_str)); } } send_str = HttpHeaderToStr(h); FreeHttpHeader(h); send_buf = NewBuf(); WriteBuf(send_buf, send_str, StrLen(send_str)); Free(send_str); // Append to the sending data in the case of POST if (StrCmpi(data->Method, WPC_HTTP_POST_NAME) == 0) { WriteBuf(send_buf, post_data, StrLen(post_data)); } // Send if (SendAll(s, send_buf->Buf, send_buf->Size, s->SecureMode) == false) { Disconnect(s); ReleaseSock(s); FreeBuf(send_buf); *error_code = ERR_DISCONNECTED; return NULL; } FreeBuf(send_buf); CONT: // Receive h = RecvHttpHeader(s); if (h == NULL) { Disconnect(s); ReleaseSock(s); *error_code = ERR_DISCONNECTED; return NULL; } http_error_code = 0; if (StrLen(h->Method) == 8) { if (Cmp(h->Method, "HTTP/1.", 7) == 0) { http_error_code = ToInt(h->Target); } } *error_code = ERR_NO_ERROR; switch (http_error_code) { case 401: case 407: // Proxy authentication error *error_code = ERR_PROXY_AUTH_FAILED; break; case 404: // 404 File Not Found *error_code = ERR_OBJECT_NOT_FOUND; break; case 100: // Continue num_continue++; if (num_continue >= 10) { goto DEF; } FreeHttpHeader(h); goto CONT; case 200: // Success break; default: // Protocol error DEF: *error_code = ERR_PROTOCOL_ERROR; break; } if (*error_code != ERR_NO_ERROR) { // An error has occured Disconnect(s); ReleaseSock(s); FreeHttpHeader(h); return NULL; } // Get the length of the content content_len = GetContentLength(h); if (max_recv_size != 0) { content_len = MIN(content_len, max_recv_size); } FreeHttpHeader(h); socket_buffer = Malloc(socket_buffer_size); // Receive the content recv_buf = NewBuf(); while (true) { UINT recvsize = MIN(socket_buffer_size, content_len - recv_buf->Size); UINT size; if (recv_callback != NULL) { if (recv_callback(recv_callback_param, content_len, recv_buf->Size, recv_buf) == false) { // Cancel the reception *error_code = ERR_USER_CANCEL; goto RECV_CANCEL; } } if (recvsize == 0) { break; } size = Recv(s, socket_buffer, recvsize, s->SecureMode); if (size == 0) { // Disconnected *error_code = ERR_DISCONNECTED; RECV_CANCEL: FreeBuf(recv_buf); Free(socket_buffer); Disconnect(s); ReleaseSock(s); return NULL; } WriteBuf(recv_buf, socket_buffer, size); } SeekBuf(recv_buf, 0, 0); Free(socket_buffer); Disconnect(s); ReleaseSock(s); // Transmission return recv_buf; }
void MeshInstancePropertyControl::ReadFrom(Entity * sceneNode) { NodesPropertyControl::ReadFrom(sceneNode); MeshInstanceNode *mesh = dynamic_cast<MeshInstanceNode *> (sceneNode); DVASSERT(mesh); propertyList->AddSection("property.meshinstance.meshinstance", GetHeaderState("property.meshinstance.meshinstance", true)); //BBOX AABBox3 bbox = mesh->GetBoundingBox(); AABBox3 transformedBox; bbox.GetTransformedBox(mesh->GetWorldTransform(), transformedBox); propertyList->AddStringProperty("property.meshinstance.bboxmin", PropertyList::PROPERTY_IS_READ_ONLY); propertyList->AddStringProperty("property.meshinstance.bboxmax", PropertyList::PROPERTY_IS_READ_ONLY); propertyList->SetStringPropertyValue("property.meshinstance.bboxmin", Format("%0.2f, %0.2f, %0.2f", transformedBox.min.x, transformedBox.min.y, transformedBox.min.z)); propertyList->SetStringPropertyValue("property.meshinstance.bboxmax", Format("%0.2f, %0.2f, %0.2f", transformedBox.max.x, transformedBox.max.y, transformedBox.max.z)); materials.clear(); materialNames.clear(); if(workingScene) { workingScene->GetDataNodes(materials); } int32 matCount = (int32)materials.size(); for(int32 i = 0; i < matCount; ++i) { Material *mat = materials[i]; materialNames.push_back(mat->GetName()); } Vector<PolygonGroupWithMaterial*> polygroups = mesh->GetPolygonGroups(); for(int32 i = 0; i < (int32)polygroups.size(); ++i) { PolygonGroup *pg = polygroups[i]->GetPolygonGroup(); String fieldName = Format("PolygonGroup #%d", i); propertyList->AddSection(fieldName, GetHeaderState(fieldName, true)); int32 vertexFormat = pg->GetFormat(); String keyPrefix = Format("#%d", i); propertyList->AddBoolProperty(keyPrefix + ". fmt.NORMAL", PropertyList::PROPERTY_IS_EDITABLE); propertyList->SetBoolPropertyValue(keyPrefix + ". fmt.NORMAL", 0 != (vertexFormat & EVF_NORMAL)); propertyList->AddBoolProperty(keyPrefix + ". fmt.COLOR", PropertyList::PROPERTY_IS_EDITABLE); propertyList->SetBoolPropertyValue(keyPrefix + ". fmt.COLOR", 0 != (vertexFormat & EVF_COLOR)); propertyList->AddBoolProperty(keyPrefix + ". fmt.TEXCOORD0", PropertyList::PROPERTY_IS_EDITABLE); propertyList->SetBoolPropertyValue(keyPrefix + ". fmt.TEXCOORD0", 0 != (vertexFormat & EVF_TEXCOORD0)); propertyList->AddBoolProperty(keyPrefix + ". fmt.TEXCOORD1", PropertyList::PROPERTY_IS_EDITABLE); propertyList->SetBoolPropertyValue(keyPrefix + ". fmt.TEXCOORD1", 0 != (vertexFormat & EVF_TEXCOORD1)); propertyList->AddBoolProperty(keyPrefix + ". fmt.TEXCOORD2", PropertyList::PROPERTY_IS_EDITABLE); propertyList->SetBoolPropertyValue(keyPrefix + ". fmt.TEXCOORD2", 0 != (vertexFormat & EVF_TEXCOORD2)); propertyList->AddBoolProperty(keyPrefix + ". fmt.TEXCOORD3", PropertyList::PROPERTY_IS_EDITABLE); propertyList->SetBoolPropertyValue(keyPrefix + ". fmt.TEXCOORD3", 0 != (vertexFormat & EVF_TEXCOORD3)); propertyList->AddBoolProperty(keyPrefix + ". fmt.TANGENT", PropertyList::PROPERTY_IS_EDITABLE); propertyList->SetBoolPropertyValue(keyPrefix + ". fmt.TANGENT", 0 != (vertexFormat & EVF_TANGENT)); propertyList->AddBoolProperty(keyPrefix + ". fmt.BINORMAL", PropertyList::PROPERTY_IS_EDITABLE); propertyList->SetBoolPropertyValue(keyPrefix + ". fmt.BINORMAL", 0 != (vertexFormat & EVF_BINORMAL)); propertyList->AddBoolProperty(keyPrefix + ". fmt.JOINTWEIGHT", PropertyList::PROPERTY_IS_EDITABLE); propertyList->SetBoolPropertyValue(keyPrefix + ". fmt.JOINTWEIGHT", 0 != (vertexFormat & EVF_JOINTWEIGHT)); propertyList->AddIntProperty(keyPrefix + ".lightmap.size"); propertyList->SetIntPropertyValue(keyPrefix + ".lightmap.size", currentSceneNode->GetCustomProperties()->GetInt32(keyPrefix + ".lightmap.size", 128)); if(matCount && !createNodeProperties) { String comboName = keyPrefix + ". Material"; propertyList->AddComboProperty(comboName, materialNames); if(polygroups[i]->GetMaterial()) { String meshMatName = polygroups[i]->GetMaterial()->GetName(); for(int32 iMat = 0; iMat < (int32)materials.size(); ++iMat) { if(meshMatName == materialNames[iMat]) { propertyList->SetComboPropertyIndex(comboName, iMat); break; } } } else { propertyList->SetComboPropertyIndex(comboName, 0); } propertyList->AddMessageProperty("property.meshinstance.editmaterial", Message(this, &MeshInstancePropertyControl::OnGo2Materials, polygroups[i]->GetMaterial())); } propertyList->AddMessageProperty("property.meshinstance.showtriangles", Message(this, &MeshInstancePropertyControl::OnShowTexture, pg)); } propertyList->AddSection("property.meshinstance.dynamicshadow", GetHeaderState("property.meshinstance.dynamicshadow", true)); propertyList->AddBoolProperty("property.meshinstance.dynamicshadow.enable"); propertyList->SetBoolPropertyValue("property.meshinstance.dynamicshadow.enable", currentSceneNode->GetCustomProperties()->GetBool("property.meshinstance.dynamicshadow.enable", false)); propertyList->AddMessageProperty("property.meshinstance.dynamicshadow.converttovolume", Message(this, &MeshInstancePropertyControl::OnConvertToShadowVolume)); }
void AutotestingSystem::SaveScreenShotNameToDB() { Logger::Debug("AutotestingSystem::SaveScreenShotNameToDB %s", screenShotName.c_str()); AutotestingDB::Instance()->Log("INFO", Format("screenshot: %s", screenShotName.c_str())); }
unsigned int __stdcall CreateBrokerThreadEntry(void *data) { TRY_CATCH CoInitialize(0); SBrokerThreadEntryData* inData = reinterpret_cast<SBrokerThreadEntryData*>(data); SStartBroker *startBroker = reinterpret_cast<SStartBroker*>(inData->buf); if (NULL == startBroker->buf || 0 == startBroker->bufSize) throw MCException("NULL == startBroker->buf || 0 == startBroker->bufSize"); CComPtr<IDispatch> broker; HRESULT hr; if((hr=broker.CoCreateInstance(L"Broker.CoBroker",NULL,CLSCTX_LOCAL_SERVER))!=S_OK) throw CExceptionBase(__LINE__,_T(__FILE__),_T(__DATE__),tstring(_T("CoBroker creation failed")),hr); CScopedTracker<HGLOBAL> globalMem; globalMem.reset(GlobalAlloc(GMEM_MOVEABLE, startBroker->bufSize), GlobalFree); if (NULL == globalMem) throw MCException_Win("Failed to GlobalAlloc"); CComPtr<IStream> stream; hr = CreateStreamOnHGlobal(globalMem, FALSE, &stream); if (S_OK != hr) throw MCException_Win(Format(_T("Failed to GlobalAlloc; result = %X"),hr)); ULARGE_INTEGER size; size.QuadPart = startBroker->bufSize; hr = stream->SetSize(size); if (S_OK != hr) throw MCException_Win(Format(_T("Failed to stream->SetSize; result = %X"),hr)); hr = CoMarshalInterface(stream, IID_IDispatch, broker, MSHCTX_LOCAL, NULL, MSHLFLAGS_NORMAL); if (S_OK != hr) throw MCException_Win(Format(_T("Failed to CoMarshalInterface; result = %X"),hr)); ULARGE_INTEGER uLi; LARGE_INTEGER li; li.QuadPart = 0; /// Writing stream to client process memory stream->Seek(li, STREAM_SEEK_SET, NULL); boost::scoped_array<char> localBuf; ULONG readCount; localBuf.reset(new char[startBroker->bufSize]); hr = stream->Read(localBuf.get(), startBroker->bufSize, &readCount); if (S_OK != hr) throw MCException_Win(Format(_T("stream->Read; result = %X"),hr)); /// Writing stream date into client process memory ULONG writtenCount; if (FALSE == WriteProcessMemory(inData->clientProcess, startBroker->buf, localBuf.get(), readCount, &writtenCount)) throw MCException_Win("Failed to WriteProcessMemory "); CoUninitialize(); Log.Add(_MESSAGE_,_T("Broker created and marshaled to BrokerProxy process")); return TRUE; CATCH_LOG() CoUninitialize(); return FALSE; }
CATCH_LOG() } /// Preparing to set vncHooks m_vncHooks.reset(NULL, CloseHandle); LoadVNCHooks(); CATCH_THROW() } void CRCHostProxy::LoadVNCHooks() { TRY_CATCH if (NULL != m_vncHooks.get()) return; //Already loaded tstring fileName = Format(_T("%s\\vnchooks.dll"),GetModulePath(NULL).c_str()); m_vncHooks.reset(LoadLibrary(fileName.c_str()),FreeLibrary); if (NULL != m_vncHooks) { m_unSetHooks = (UnSetHooksFn) GetProcAddress( m_vncHooks, _T("UnSetHooks")); m_setMouseFilterHook = (SetMouseFilterHookFn) GetProcAddress( m_vncHooks, _T("SetMouseFilterHook")); m_setKeyboardFilterHook = (SetKeyboardFilterHookFn) GetProcAddress( m_vncHooks, _T("SetKeyboardFilterHook")); m_setHooks = (SetHooksFn) GetProcAddress( m_vncHooks, _T("SetHooks")); } else throw MCException_Win(Format(_T("Failed to load %s"),fileName.c_str())); Log.Add(_MESSAGE_,_T("VNCHooks loaded")); CATCH_LOG() } CRCHostProxy::~CRCHostProxy() {
void operator()(const Args&... args) const { writeln(Format(args...)); }
void Parser::CheckKey(int c) { if(!Key(c)) ThrowError(Format("Missing %c", c)); }
BOOL CParseRecInfoText::ParseRecInfoText(LPCWSTR filePath) { if( filePath == NULL ){ return FALSE; } multimap<wstring, REC_FILE_INFO*>::iterator itr; for( itr = this->recInfoMap.begin(); itr != this->recInfoMap.end(); itr++ ){ SAFE_DELETE(itr->second) } this->recInfoMap.clear(); this->recIDMap.clear(); this->nextID = 1; this->loadFilePath = filePath; HANDLE hFile = _CreateFile2( filePath, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if( hFile == INVALID_HANDLE_VALUE ){ return FALSE; } DWORD dwFileSize = GetFileSize( hFile, NULL ); if( dwFileSize == 0 ){ CloseHandle(hFile); return TRUE; } char* pszBuff = new char[dwFileSize+1]; if( pszBuff == NULL ){ CloseHandle(hFile); return FALSE; } ZeroMemory(pszBuff,dwFileSize+1); DWORD dwRead=0; ReadFile( hFile, pszBuff, dwFileSize, &dwRead, NULL ); string strRead = pszBuff; CloseHandle(hFile); SAFE_DELETE_ARRAY(pszBuff); string parseLine=""; size_t iIndex = 0; size_t iFind = 0; while( iFind != string::npos ){ iFind = strRead.find("\r\n", iIndex); if( iFind == (int)string::npos ){ parseLine = strRead.substr(iIndex); //strRead.clear(); }else{ parseLine = strRead.substr(iIndex,iFind-iIndex); //strRead.erase( 0, iIndex+2 ); iIndex = iFind + 2; } //先頭;はコメント行 if( parseLine.find(";") != 0 ){ //空行? if( parseLine.find("\t") != string::npos ){ REC_FILE_INFO* item = new REC_FILE_INFO; BOOL bRet = Parse1Line(parseLine, item); if( bRet == FALSE ){ SAFE_DELETE(item) }else{ wstring strKey; Format(strKey, L"%04d%02d%02d%02d%02d%02d%04X%04X", item->startTime.wYear, item->startTime.wMonth, item->startTime.wDay, item->startTime.wHour, item->startTime.wMinute, item->startTime.wSecond, item->originalNetworkID, item->transportStreamID); item->id = GetNextReserveID(); this->recInfoMap.insert( pair<wstring, REC_FILE_INFO*>(strKey,item) ); this->recIDMap.insert( pair<DWORD, REC_FILE_INFO*>(item->id,item) ); } } } }
void VertexProgramDecompiler::AddCode(const std::string& code) { m_body.push_back(Format(code) + ";"); m_cur_instr->body.push_back(Format(code)); }
protected func Construction() { var graphic = Random(5); if(graphic) SetGraphics(Format("%d",graphic)); }
String Parser::on(String arg1,String arg2) { return Format("On(%s,%s)",OPENARRAY(TVarRec,(arg1,arg2))); }
void FragmentProgramDecompiler::AddCode(const std::string& code) { main.append(m_code_level, '\t') += Format(code) + "\n"; }
String Parser::move(String element,String pile1,String pile2) { return Format("Move(%s,%s,%s)",OPENARRAY(TVarRec,(element,pile1,pile2))); }
// 抓拍数据 void CALLBACK VehicleDataCallbackFuc(void *pUserData, VehicleData *pData) { TForm1 *pThis = (TForm1 *)pUserData; if(pThis->tvConnectDev->Selected == NULL) return; String strIP; bool bFlag = false; PDevInfo pDev = NULL; TTreeNodes *nodes = pThis->tvConnectDev->Items; if(nodes != NULL) { for(int i = 0; i < nodes->Count; i++) { if(TreeView_GetCheckState(pThis->tvConnectDev->Handle,nodes->Item[i]->ItemId)) { String strViewIP = nodes->Item[i]->Text; // 只显示指定抓拍的设备数据 strIP.sprintf("%s", pData->ucDeviceIP); if(strIP == strViewIP) { bFlag = true; break; } } } } if(!bFlag) return; int nColor = pData->PlateColor; TDateTime dataTime = Now(); SYSTEMTIME tm; GetSystemTime(&tm); String strPlate = (char *)pData->ucPlate; String strPath; String strBigFile, strCifFile, strPlateFile, strPlateNoFile; int iFileHandle = 0; // 大图 if(pData->pucBigImage != NULL && pData->uiBigImageLen > 0) { strPath = pThis->strImagePath + strIP + "\\大图\\" + FormatDateTime("yyyymmdd", dataTime) + "\\"; pThis->CreateDirectoryRecurrent(strPath); strBigFile = Format("%s%s%03d(%s).jpg", ARRAYOFCONST((strPath, dataTime.FormatString("hhmmss"), tm.wMilliseconds, strPlate))); iFileHandle = FileCreate(strBigFile); if(iFileHandle != 0) { FileWrite(iFileHandle, pData->pucBigImage, pData->uiBigImageLen); FileClose(iFileHandle); if(FileExists(strBigFile)) { pThis->imgBigImg->Picture->LoadFromFile(strBigFile); } } } // CIF图 if(pData->pucCIFImage != NULL && pData->uiCIFImageLen > 0) { strPath = pThis->strImagePath + strIP + "\\CIF图\\" + dataTime.FormatString("yyyymmdd") + "\\"; pThis->CreateDirectoryRecurrent(strPath); strCifFile = Format("%s%s%03d(%s).jpg", ARRAYOFCONST((strPath, dataTime.FormatString("hhmmss"), tm.wMilliseconds, strPlate))); iFileHandle = FileCreate(strCifFile); if(iFileHandle != 0) { FileWrite(iFileHandle, pData->pucCIFImage, pData->uiCIFImageLen); FileClose(iFileHandle); if(FileExists(strCifFile)) { pThis->imgCIFImg->Picture->LoadFromFile(strCifFile); } } } // 车牌图 if(pData->pucPlateImage != NULL && pData->uiPlateImageLen > 0) { strPath = pThis->strImagePath + strIP + "\\车牌图\\" + dataTime.FormatString("yyyymmdd") + "\\"; pThis->CreateDirectoryRecurrent(strPath); strPlateFile = Format("%s%s%03d(%s).jpg", ARRAYOFCONST((strPath, dataTime.FormatString("hhmmss"), tm.wMilliseconds, strPlate))); iFileHandle = FileCreate(strPlateFile); if(iFileHandle != 0) { FileWrite(iFileHandle, pData->pucPlateImage, pData->uiPlateImageLen); FileClose(iFileHandle); } if(FileExists(strPlateFile)) { pThis->imgPlateImg->Picture->LoadFromFile(strPlateFile); } } // 车牌号码 pThis->ShowPlate(strPlate, nColor); }
//================================================================================================= bool RunInstallScripts() { Info("Reading install scripts."); WIN32_FIND_DATA data; HANDLE find = FindFirstFile(Format("%s/install/*.txt", g_system_dir.c_str()), &data); if(find == INVALID_HANDLE_VALUE) return true; vector<InstallScript> scripts; Tokenizer t; t.AddKeyword("install", 0); t.AddKeyword("version", 1); t.AddKeyword("remove", 2); do { int major, minor, patch; // read file to find version info try { if(t.FromFile(Format("%s/install/%s", g_system_dir.c_str(), data.cFileName))) { t.Next(); if(t.MustGetKeywordId() == 2) { // old install script if(sscanf_s(data.cFileName, "%d.%d.%d.txt", &major, &minor, &patch) != 3) { if(sscanf_s(data.cFileName, "%d.%d.txt", &major, &minor) == 2) patch = 0; else { // unknown version major = 0; minor = 0; patch = 0; } } } else { t.AssertKeyword(0); t.Next(); if(t.MustGetInt() != 1) t.Throw(Format("Unknown install script version '%d'.", t.MustGetInt())); t.Next(); t.AssertKeyword(1); t.Next(); major = t.MustGetInt(); t.Next(); minor = t.MustGetInt(); t.Next(); patch = t.MustGetInt(); } InstallScript& s = Add1(scripts); s.filename = data.cFileName; s.version = (((major & 0xFF) << 16) | ((minor & 0xFF) << 8) | (patch & 0xFF)); } } catch(const Tokenizer::Exception& e) { Warn("Unknown install script '%s': %s", data.cFileName, e.ToString()); } } while(FindNextFile(find, &data)); FindClose(find); if(scripts.empty()) return true; std::sort(scripts.begin(), scripts.end()); GetModuleFileName(nullptr, BUF, 256); char buf[512], buf2[512]; char* filename; GetFullPathName(BUF, 512, buf, &filename); *filename = 0; DWORD len = strlen(buf); LocalString s, s2; for(vector<InstallScript>::iterator it = scripts.begin(), end = scripts.end(); it != end; ++it) { cstring path = Format("%s/install/%s", g_system_dir.c_str(), it->filename.c_str()); try { if(!t.FromFile(path)) { Error("Failed to load install script '%s'.", it->filename.c_str()); continue; } Info("Using install script %s.", it->filename.c_str()); t.Next(); t.AssertKeyword(); if(t.MustGetKeywordId() == 0) { // skip install 1, version X Y Z W t.Next(); t.AssertInt(); t.Next(); t.AssertKeyword(1); t.Next(); t.AssertInt(); t.Next(); t.AssertInt(); t.Next(); t.AssertInt(); t.Next(); t.AssertInt(); t.Next(); } while(true) { if(t.IsEof()) break; t.AssertKeyword(2); t.Next(); s2 = t.MustGetString(); if(GetFullPathName(s2->c_str(), 512, buf2, nullptr) == 0 || strncmp(buf, buf2, len) != 0) { Error("Invalid file path '%s'.", s2->c_str()); return false; } DeleteFile(buf2); t.Next(); } DeleteFile(path); } catch(cstring err) { Error("Failed to parse install script '%s': %s", path, err); } } return true; }
void ConvertInx::Convert( s_Inx* InxFile ) { FILE* oldInx = nullptr; FILE* bakInx = nullptr; FILE* newInx = nullptr; INT oldAddress = 0; INT newAddress = 0; fopen_s( &oldInx, InxFile->FullPath, "rb" ); fopen_s( &bakInx, Format( "%s.bak", GetName( InxFile->FullPath ) ), "wb+" ); if( !oldInx ) { fclose( bakInx ); fprintf( lpDbg, "[ ERROR ] : %s\n", InxFile->FullPath ); return; }; char oldData[ OLD_INX_SIZE ] = { 0 }; char newData[ NEW_INX_SIZE ] = { 0 }; fread_s( &oldData, OLD_INX_SIZE, OLD_INX_SIZE, sizeof( char ), oldInx ); fclose( oldInx ); DeleteFileA( InxFile->FullPath ); fwrite( oldData, OLD_INX_SIZE, sizeof( char ), bakInx ); fclose( bakInx ); fopen_s( &newInx, InxFile->FullPath, "wb+" ); while( oldAddress < OLD_INX_SIZE ) { switch( newAddress ) { case 0x63C: oldAddress = 0x844; break; case 0x6A8: oldAddress = 0x8E4; break; case 0x720: oldAddress = 0x990; break; case 0x798: oldAddress = 0xA3C; break; case 0x814: oldAddress = 0xAEC; break; case 0x88C: oldAddress = 0xB98; break; case 0x904: oldAddress = 0xC44; break; case 0x97C: oldAddress = 0xCF0; break; case 0x9F4: oldAddress = 0xD9C; break; case 0xA6C: oldAddress = 0xE48; break; case 0xAE4: oldAddress = 0xB18; break; case 0xB5C: oldAddress = 0xBC4; break; case 0xBD4: oldAddress = 0xC70; break; case 0xF18C: oldAddress = 0x1598C; break; case 0x10068: oldAddress = 0x16E80; break; }; newData[ newAddress ] = oldData[ oldAddress ]; oldAddress++; newAddress++; }; fwrite( newData, NEW_INX_SIZE, sizeof( char ), newInx ); fclose( newInx ); fprintf( lpDbg, "Convertido: %s\n", InxFile->FullPath ); };
static void _SlxConvertProfileRegKey(const wchar_t* pszRegKey, CProfileSection* pSection) { // Open sub key CSmartHandle<HKEY> Key; if (RegOpenKeyEx(HKEY_CURRENT_USER, pszRegKey, 0, KEY_READ, &Key)==ERROR_SUCCESS) { // Enumerate all values DWORD dwIndex=0; TCHAR szName[MAX_PATH]; DWORD cbName=MAX_PATH; DWORD dwType; while (RegEnumValue(Key, dwIndex++, szName, &cbName, NULL, &dwType, NULL, NULL)==ERROR_SUCCESS) { switch (dwType) { case REG_SZ: { CUniString str; if (RegGetString(Key, NULL, szName, str)==ERROR_SUCCESS) { pSection->SetValue(szName, str); } break; } case REG_DWORD: { DWORD dw; if (RegGetDWORD(Key, NULL, szName, &dw)==ERROR_SUCCESS) { pSection->SetIntValue(szName, dw); } break; } case REG_BINARY: { CAutoPtr<IStream, SRefCounted> spStreamSrc; if (SUCCEEDED(OpenRegistryStream(Key, NULL, szName, &spStreamSrc))) { CAutoPtr<IStream, SRefCounted> spStreamDest; if (SUCCEEDED(CreateProfileStream(pSection->CreateEntry(szName), NULL, &spStreamDest))) { CopyStream(spStreamDest, spStreamSrc); } } break; } } // Reset size cbName=MAX_PATH; } Key.Release(); } // Copy sub sections CUniStringVector vecSubSections; RegEnumAllKeys(HKEY_CURRENT_USER, pszRegKey, vecSubSections); for (int i=0; i<vecSubSections.GetSize(); i++) { _SlxConvertProfileRegKey(Format(L"%s\\%s", pszRegKey, vecSubSections[i]), pSection->CreateSection(vecSubSections[i])); } }
String TimeStamp() { Time time = GetSysTime(); return Format(Date(GetSysTime())) + (Format(" %02d:%02d:%02d", time.hour, time.minute, time.second)); }
int main() { char str[10]; char strname[10]; char c; printf("FormatDisk?<y/n>"); scanf("%c",&c); fflush(stdin); if(c=='y') { if(!Format()) { return -1; } printf("Finished!\n"); } if(!Install()) { return -1; } printf("login now\n"); login(); showhelp(); printf("%s>",cmdhead); while(1) { scanf("%s",&str); if(strcmp(str,"shutdown")==0) { fclose(fd); return 0 ; } else if(strcmp(str,"dir")==0) { showdir(); } else if(strcmp(str,"bit")==0) { showbitmap(); } else if(strcmp(str,"help")==0) { showhelp(); } else if(strcmp(str,"logout")==0) { logout(); } else if(Iscmd(str)) { scanf("%s",&strname); cmd_Up(str,strname); } else { printf("Error!!\n"); } printf("%s>",cmdhead); } return 0; }
void Parser::ThrowError(const String& e) { throw Error(Format("(%d) : %s", GetLine(lex.Pos()), ~e)); }
// ----------------------------------------------------------------------- HRESULT STDMETHODCALLTYPE MFilterSAX2ContentHandler::endElement ( const wchar_t * pwchNamespaceUri, int cchNamespaceUri, const wchar_t * pwchLocalName, int cchLocalName, const wchar_t * pwchQName, int cchQName) { TCHAR szCurElement[MAX_PATH + 1] = {0}; _tcsncpy_s(szCurElement, MAX_PATH + 1, pwchQName, cchQName); if (m_bValidation && _tcscmp(szCurElement, _T("filters")) == 0) { // Check that the XML file version is present and that // a. it is less than or equal to the Filter schema version // b. it is less than or equal to the version supported by this PWS if (m_iXMLVersion < 0) { LoadAString(m_strXMLErrors, IDSC_MISSING_XML_VER); return E_FAIL; } if (m_iXMLVersion > m_iSchemaVersion) { Format(m_strXMLErrors, IDSC_INVALID_XML_VER1, m_iXMLVersion, m_iSchemaVersion); return E_FAIL; } if (m_iXMLVersion > PWS_XML_FILTER_VERSION) { Format(m_strXMLErrors, IDSC_INVALID_XML_VER2, m_iXMLVersion, PWS_XML_FILTER_VERSION); return E_FAIL; } } if (m_bValidation) { return S_OK; } if (_tcscmp(szCurElement, _T("filter")) == 0) { INT_PTR rc = IDYES; st_Filterkey fk; fk.fpool = m_FPool; fk.cs_filtername = cur_filter->fname; if (m_MapFilters->find(fk) != m_MapFilters->end()) { stringT question; Format(question, IDSC_FILTEREXISTS, cur_filter->fname.c_str()); if (m_pAsker == NULL || !(*m_pAsker)(question)) { m_MapFilters->erase(fk); } } if (rc == IDYES) { m_MapFilters->insert(PWSFilters::Pair(fk, *cur_filter)); } delete cur_filter; return S_OK; } else if (_tcscmp(szCurElement, _T("filter_entry")) == 0) { if (cur_filterentry->mtype == PWSMatch::MT_DATE && cur_filterentry->rule != PWSMatch::MR_PRESENT && cur_filterentry->rule != PWSMatch::MR_NOTPRESENT && cur_filterentry->fdate1 == (time_t)0 && cur_filterentry->fdate2 == (time_t)0) cur_filterentry->fdatetype = 1; // Relative Date if (m_type == DFTYPE_MAIN) { cur_filter->num_Mactive++; cur_filter->vMfldata.push_back(*cur_filterentry); } else if (m_type == DFTYPE_PWHISTORY) { cur_filter->num_Hactive++; cur_filter->vHfldata.push_back(*cur_filterentry); } else if (m_type == DFTYPE_PWPOLICY) { cur_filter->num_Pactive++; cur_filter->vPfldata.push_back(*cur_filterentry); } delete cur_filterentry; } else if (_tcscmp(szCurElement, _T("grouptitle")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_STRING; cur_filterentry->ftype = FT_GROUPTITLE; } else if (_tcscmp(szCurElement, _T("group")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_STRING; cur_filterentry->ftype = FT_GROUP; } else if (_tcscmp(szCurElement, _T("title")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_STRING; cur_filterentry->ftype = FT_TITLE; } else if (_tcscmp(szCurElement, _T("user")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_STRING; cur_filterentry->ftype = FT_USER; } else if (_tcscmp(szCurElement, _T("password")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_PASSWORD; cur_filterentry->ftype = FT_PASSWORD; } else if (_tcscmp(szCurElement, _T("notes")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_STRING; cur_filterentry->ftype = FT_NOTES; } else if (_tcscmp(szCurElement, _T("url")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_STRING; cur_filterentry->ftype = FT_URL; } else if (_tcscmp(szCurElement, _T("autotype")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_STRING; cur_filterentry->ftype = FT_AUTOTYPE; } else if (_tcscmp(szCurElement, _T("runcommand")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_STRING; cur_filterentry->ftype = FT_RUNCMD; } else if (_tcscmp(szCurElement, _T("DCA")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_DCA; cur_filterentry->ftype = FT_DCA; } else if (_tcscmp(szCurElement, _T("ShiftDCA")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_SHIFTDCA; cur_filterentry->ftype = FT_SHIFTDCA; } else if (_tcscmp(szCurElement, _T("email")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_STRING; cur_filterentry->ftype = FT_EMAIL; } else if (_tcscmp(szCurElement, _T("protected")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_BOOL; cur_filterentry->ftype = FT_PROTECTED; } else if (_tcscmp(szCurElement, _T("kbshortcut")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_BOOL; cur_filterentry->ftype = FT_KBSHORTCUT; } else if (_tcscmp(szCurElement, _T("symbols")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_STRING; cur_filterentry->ftype = FT_SYMBOLS; cur_filterentry->fstring = PWSUtil::DeDupString(cur_filterentry->fstring); } else if (_tcscmp(szCurElement, _T("policy_name")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_STRING; cur_filterentry->ftype = FT_POLICYNAME; } else if (_tcscmp(szCurElement, _T("create_time")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_DATE; cur_filterentry->ftype = FT_CTIME; } else if (_tcscmp(szCurElement, _T("password_modified_time")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_DATE; cur_filterentry->ftype = FT_PMTIME; } else if (_tcscmp(szCurElement, _T("last_access_time")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_DATE; cur_filterentry->ftype = FT_ATIME; } else if (_tcscmp(szCurElement, _T("expiry_time")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_DATE; cur_filterentry->ftype = FT_XTIME; } else if (_tcscmp(szCurElement, _T("record_modified_time")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_DATE; cur_filterentry->ftype = FT_RMTIME; } else if (_tcscmp(szCurElement, _T("password_expiry_interval")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_INTEGER; cur_filterentry->ftype = FT_XTIME_INT; } else if (_tcscmp(szCurElement, _T("password_length")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_INTEGER; cur_filterentry->ftype = FT_PASSWORDLEN; } else if (_tcscmp(szCurElement, _T("entrytype")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_ENTRYTYPE; cur_filterentry->ftype = FT_ENTRYTYPE; } else if (_tcscmp(szCurElement, _T("entrystatus")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_ENTRYSTATUS; cur_filterentry->ftype = FT_ENTRYSTATUS; } else if (_tcscmp(szCurElement, _T("entrysize")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_ENTRYSIZE; cur_filterentry->ftype = FT_ENTRYSIZE; } else if (_tcscmp(szCurElement, _T("unknownfields")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->ftype = FT_UNKNOWNFIELDS; } else if (_tcscmp(szCurElement, _T("password_history")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_PWHIST; cur_filterentry->ftype = FT_PWHIST; } else if (_tcscmp(szCurElement, _T("history_present")) == 0) { m_type = DFTYPE_PWHISTORY; cur_filterentry->mtype = PWSMatch::MT_BOOL; cur_filterentry->ftype = HT_PRESENT; } else if (_tcscmp(szCurElement, _T("history_active")) == 0) { m_type = DFTYPE_PWHISTORY; cur_filterentry->mtype = PWSMatch::MT_BOOL; cur_filterentry->ftype = HT_ACTIVE; } else if (_tcscmp(szCurElement, _T("history_number")) == 0) { m_type = DFTYPE_PWHISTORY; cur_filterentry->mtype = PWSMatch::MT_INTEGER; cur_filterentry->ftype = HT_NUM; } else if (_tcscmp(szCurElement, _T("history_maximum")) == 0) { m_type = DFTYPE_PWHISTORY; cur_filterentry->mtype = PWSMatch::MT_INTEGER; cur_filterentry->ftype = HT_MAX; } else if (_tcscmp(szCurElement, _T("history_changedate")) == 0) { m_type = DFTYPE_PWHISTORY; cur_filterentry->mtype = PWSMatch::MT_DATE; cur_filterentry->ftype = HT_CHANGEDATE; } else if (_tcscmp(szCurElement, _T("history_passwords")) == 0) { m_type = DFTYPE_PWHISTORY; cur_filterentry->mtype = PWSMatch::MT_PASSWORD; cur_filterentry->ftype = HT_PASSWORDS; } else if (_tcscmp(szCurElement, _T("password_policy")) == 0) { m_type = DFTYPE_MAIN; cur_filterentry->mtype = PWSMatch::MT_POLICY; cur_filterentry->ftype = FT_POLICY; } else if (_tcscmp(szCurElement, _T("policy_present")) == 0) { m_type = DFTYPE_PWPOLICY; cur_filterentry->mtype = PWSMatch::MT_BOOL; cur_filterentry->ftype = PT_PRESENT; } else if (_tcscmp(szCurElement, _T("policy_length")) == 0) { m_type = DFTYPE_PWPOLICY; cur_filterentry->mtype = PWSMatch::MT_INTEGER; cur_filterentry->ftype = PT_LENGTH; } else if (_tcscmp(szCurElement, _T("policy_number_lowercase")) == 0) { m_type = DFTYPE_PWPOLICY; cur_filterentry->mtype = PWSMatch::MT_INTEGER; cur_filterentry->ftype = PT_LOWERCASE; } else if (_tcscmp(szCurElement, _T("policy_number_uppercase")) == 0) { m_type = DFTYPE_PWPOLICY; cur_filterentry->mtype = PWSMatch::MT_INTEGER; cur_filterentry->ftype = PT_UPPERCASE; } else if (_tcscmp(szCurElement, _T("policy_number_digits")) == 0) { m_type = DFTYPE_PWPOLICY; cur_filterentry->mtype = PWSMatch::MT_INTEGER; cur_filterentry->ftype = PT_DIGITS; } else if (_tcscmp(szCurElement, _T("policy_number_symbols")) == 0) { m_type = DFTYPE_PWPOLICY; cur_filterentry->mtype = PWSMatch::MT_INTEGER; cur_filterentry->ftype = PT_SYMBOLS; } else if (_tcscmp(szCurElement, _T("policy_easyvision")) == 0) { m_type = DFTYPE_PWPOLICY; cur_filterentry->mtype = PWSMatch::MT_BOOL; cur_filterentry->ftype = PT_EASYVISION; } else if (_tcscmp(szCurElement, _T("policy_pronounceable")) == 0) { m_type = DFTYPE_PWPOLICY; cur_filterentry->mtype = PWSMatch::MT_BOOL; cur_filterentry->ftype = PT_PRONOUNCEABLE; } else if (_tcscmp(szCurElement, _T("policy_hexadecimal")) == 0) { m_type = DFTYPE_PWPOLICY; cur_filterentry->mtype = PWSMatch::MT_BOOL; cur_filterentry->ftype = PT_HEXADECIMAL; } else if (_tcscmp(szCurElement, _T("rule")) == 0) { ToUpper(m_sxElemContent); cur_filterentry->rule = PWSMatch::GetRule(m_sxElemContent); } else if (_tcscmp(szCurElement, _T("logic")) == 0) { if (m_sxElemContent == _T("or")) cur_filterentry->ltype = LC_OR; else cur_filterentry->ltype = LC_AND; } else if (_tcscmp(szCurElement, _T("string")) == 0) { cur_filterentry->fstring = m_sxElemContent; } else if (_tcscmp(szCurElement, _T("case")) == 0) { cur_filterentry->fcase = _ttoi(m_sxElemContent.c_str()) != 0; } else if (_tcscmp(szCurElement, _T("warn")) == 0) { cur_filterentry->fnum1 = _ttoi(m_sxElemContent.c_str()); } else if (_tcscmp(szCurElement, _T("num1")) == 0) { cur_filterentry->fnum1 = _ttoi(m_sxElemContent.c_str()); } else if (_tcscmp(szCurElement, _T("num2")) == 0) { cur_filterentry->fnum2 = _ttoi(m_sxElemContent.c_str()); } else if (_tcscmp(szCurElement, _T("unit")) == 0) { cur_filterentry->funit = _ttoi(m_sxElemContent.c_str()); } else if (_tcscmp(szCurElement, _T("date1")) == 0) { time_t t(0); if (VerifyXMLDateString(m_sxElemContent.c_str(), t) && (t != (time_t)-1)) cur_filterentry->fdate1 = t; else cur_filterentry->fdate1 = (time_t)0; } else if (_tcscmp(szCurElement, _T("date2")) == 0) { time_t t(0); if (VerifyXMLDateString(m_sxElemContent.c_str(), t) && (t != (time_t)-1)) cur_filterentry->fdate2 = t; else cur_filterentry->fdate1 = (time_t)0; } else if (_tcscmp(szCurElement, _T("dca")) == 0) { cur_filterentry->fdca = (short)_ttoi(m_sxElemContent.c_str()); } else if (_tcscmp(szCurElement, _T("shiftdca")) == 0) { cur_filterentry->fdca = (short)_ttoi(m_sxElemContent.c_str()); } else if (_tcscmp(szCurElement, _T("type")) == 0) { if (m_sxElemContent == _T("normal")) cur_filterentry->etype = CItemData::ET_NORMAL; else if (m_sxElemContent == _T("alias")) cur_filterentry->etype = CItemData::ET_ALIAS; else if (m_sxElemContent == _T("shortcut")) cur_filterentry->etype = CItemData::ET_SHORTCUT; else if (m_sxElemContent == _T("aliasbase")) cur_filterentry->etype = CItemData::ET_ALIASBASE; else if (m_sxElemContent == _T("shortcutbase")) cur_filterentry->etype = CItemData::ET_SHORTCUTBASE; else cur_filterentry->etype = CItemData::ET_INVALID; } else if (_tcscmp(szCurElement, _T("status")) == 0) { if (m_sxElemContent == _T("clean")) cur_filterentry->estatus = CItemData::ES_CLEAN; else if (m_sxElemContent == _T("added")) cur_filterentry->estatus = CItemData::ES_ADDED; else if (m_sxElemContent == _T("modified")) cur_filterentry->estatus = CItemData::ES_MODIFIED; else cur_filterentry->estatus = CItemData::ES_INVALID; } else if (!(_tcscmp(szCurElement, _T("test")) == 0 || _tcscmp(szCurElement, _T("filters")) == 0)) ASSERT(0); return S_OK; }
std::string Mine::GetWeaponWinString(const char *TeamName, uint items_count ) const { return Format(ngettext("%s team has won %u mine!", "%s team has won %u mines!", items_count), TeamName, items_count); }