static void SortItems (void) { int i; int filtered = 0; Debug ("AppSort (begin)"); // Apply filters apps2Disp = 0; for (i = 0; i < appsCnt; i++) { apps[i].filtered = IsFiltered (i); if (apps[i].filtered && (!apps[i].hidden || showHidden)) apps2Disp++; if (apps[i].filtered) filtered++; } bsort (apps, appsCnt, sizeof(s_app), bsort_filtered); bsort (apps, filtered, sizeof(s_app), bsort_hidden); bsort (apps, apps2Disp, sizeof(s_app), bsort_name); bsort (apps, apps2Disp, sizeof(s_app), bsort_priority); pageMax = (apps2Disp - 1) / gui.spotsXpage; FeedCoverCache (); Debug ("AppSort (end)"); }
BOOL CAdultFilter::IsChatFiltered(LPCTSTR pszText) const { if ( Settings.Community.ChatCensor && pszText ) return IsFiltered( pszText ); return FALSE; }
//+--------------------------------------------------------------------------- // // Member: CDispRoot::PreDraw // // Synopsis: Before drawing starts, PreDraw processes the redraw region, // subtracting areas that are blocked by opaque or buffered items. // PreDraw is finished when the redraw region becomes empty // (i.e., an opaque item completely obscures all content below it) // // Arguments: pContext draw context // // Returns: TRUE if first opaque node to draw has been found // // Notes: // //---------------------------------------------------------------------------- BOOL CDispRoot::PreDraw(CDispDrawContext* pContext) { // Interesting nodes are visible, in-view, opaque Assert(AllSet(CDispFlags::s_preDrawSelector)); Assert(!IsSet(CDispFlags::s_generalFlagsNotSetInDraw)); Assert(!IsSet(CDispFlags::s_interiorFlagsNotSetInDraw)); // we don't expect filter on the root node Assert(!IsFiltered()); // root must have only one or zero children CDispNode* pChild = _pFirstChildNode; Assert(_pFirstChildNode==_pLastChildNode && _cChildren<=1); if(pChild != NULL) { // only children which meet our selection criteria if(pChild->AllSet(CDispFlags::s_preDrawSelector)) { // if we found the first child to draw, stop further PreDraw calcs if(PreDrawChild(pChild, pContext, *pContext)) { return TRUE; } } } // root is always opaque pContext->_pFirstDrawNode = this; Verify(!pContext->PushRedrawRegion(*(pContext->GetRedrawRegion()),this)); return TRUE; }
BOOL CAdultFilter::IsSearchFiltered(LPCTSTR pszText) const { if ( Settings.Search.AdultFilter && pszText ) return IsFiltered( pszText ); return FALSE; }
BOOL CAdultFilter::IsHitAdult(LPCTSTR pszText) const { if ( pszText ) return IsFiltered( pszText ); return FALSE; }
/* ================ idServerScan::InfoResponse ================ */ int idServerScan::InfoResponse( networkServer_t &server ) { if ( scan_state == IDLE ) { return false; } idStr serv = Sys_NetAdrToString( server.adr ); if ( server.challenge != challenge ) { common->DPrintf( "idServerScan::InfoResponse - ignoring response from %s, wrong challenge %d.", serv.c_str(), server.challenge ); return false; } if ( scan_state == NET_SCAN ) { const idKeyValue *info = net_info.FindKey( serv.c_str() ); if ( !info ) { common->DPrintf( "idServerScan::InfoResponse NET_SCAN: reply from unknown %s\n", serv.c_str() ); return false; } int id = atoi( info->GetValue() ); net_info.Delete( serv.c_str() ); inServer_t iserv = net_servers[ id ]; server.ping = Sys_Milliseconds() - iserv.time; server.id = iserv.id; } else { server.ping = Sys_Milliseconds() - lan_pingtime; server.id = 0; // check for duplicate servers for ( int i = 0; i < Num() ; i++ ) { if ( memcmp( &(*this)[ i ].adr, &server.adr, sizeof(netadr_t) ) == 0 ) { common->DPrintf( "idServerScan::InfoResponse LAN_SCAN: duplicate server %s\n", serv.c_str() ); return true; } } } const char *si_map = server.serverInfo.GetString( "si_map" ); const idDecl *mapDecl = declManager->FindType( DECL_MAPDEF, si_map, false ); const idDeclEntityDef *mapDef = static_cast< const idDeclEntityDef * >( mapDecl ); if ( mapDef ) { const char *mapName = common->GetLanguageDict()->GetString( mapDef->dict.GetString( "name", si_map ) ); server.serverInfo.Set( "si_mapName", mapName ); } else { server.serverInfo.Set( "si_mapName", si_map ); } int index = Append( server ); // for now, don't maintain sorting when adding new info response servers m_sortedServers.Append( Num()-1 ); if ( listGUI->IsConfigured( ) && !IsFiltered( server ) ) { GUIAdd( Num()-1, server ); } if ( listGUI->GetSelection( NULL, 0 ) == ( Num()-1 ) ) { GUIUpdateSelected(); } return index; }
llvm::Value *RowBatch::GetPhysicalPosition(CodeGen &codegen, const Row &row) const { llvm::Value *batch_pos = row.GetBatchPosition(); if (IsFiltered()) { return selection_vector_.GetValue(codegen, batch_pos); } else { return codegen->CreateAdd(tid_start_, batch_pos); } }
llvm::Value *RowBatch::GetNumValidRows(CodeGen &codegen) { if (IsFiltered()) { // The batch is filtered. Then the number of valid rows is equivalent to the // current size of the selection vector. return selection_vector_.GetNumElements(); } else { // The batch isn't filtered by the selection vector. Then the number of // valid rows is equivalent to the total number of rows return GetNumTotalRows(codegen); } }
BOOL CAdultFilter::IsChildPornography(LPCTSTR pszText) const { if ( ! pszText ) return FALSE; for ( LPCTSTR pszWord = m_pszChildWords ; *pszWord ; ) { if ( _tcsistr( pszText, pszWord ) != NULL ) return ( IsFiltered( pszText ) ); pszWord += _tcslen( pszWord ) + 1; } return FALSE; }
/* ================ idServerScan::ApplyFilter ================ */ void idServerScan::ApplyFilter() { int i; networkServer_t serv; idStr s; listGUI->SetStateChanges( false ); listGUI->Clear(); for( i = m_sortAscending ? 0 : m_sortedServers.Num() - 1; m_sortAscending ? i < m_sortedServers.Num() : i >= 0; m_sortAscending ? i++ : i-- ) { serv = ( *this )[m_sortedServers[i]]; if( !IsFiltered( serv ) ) { GUIAdd( m_sortedServers[i], serv ); } } GUIUpdateSelected(); listGUI->SetStateChanges( true ); }
void LogBase::WriteVA(ELogMessageType type, ELogMessageLevel nLevel, LPCTSTR pszModule, LPCTSTR pszMessage, va_list args) throw() { if (IsFiltered(type, nLevel)) // не обрабатываем сообщение, если оно не попадает в лог return; // 75% времени тратится на new и delete, поэтому первую попытку попробуем сделать без него. StackResizableBuf<TCHAR, 16*1024> buf; int pos; for (;;) { pos = _vsntprintf_s(buf.data, buf.size, buf.size - 1, pszMessage, args); if (pos != -1) break; // BUG 16456 FIX, см. в конец WriteVAW почему //if (buf.size >= 1024 * 256) if (buf.size >= 1024 * 1024 * 10) //Increased limit for DumpServer { pos = (int)buf.size - 1; break; } buf.Resize(buf.size * 2); } if (pos >= 0) { buf.data[pos] = 0; SYSTEMTIME st; GetLocalTime(&st); TCHAR bufdate[128], buftime[128], bufthread[128]; _stprintf_s(bufdate, _T("%i-%02i-%02i"), st.wYear, st.wMonth, st.wDay); _stprintf_s(buftime, _T("%02i:%02i:%02i.%03d"), st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); _stprintf_s(bufthread, _T("%4x"), GetCurrentThreadId()); m_pMedia->Write(type, nLevel, bufdate, buftime, bufthread, GetThreadName() , pszModule ? pszModule : m_szModule.c_str(), buf.data); } }
TBool CHuiFxEffect::IsAppliedToBackground() { if (iRoot && iRoot->LayerCount()) { if (iRoot->Layer(0).Type() == ELayerTypeGroup) { // If first layer after root is group, then effect is not applied to background (?) return EFalse; } else { if (IsFiltered()) { return ETrue; } else { // Not filter effect -> cannot be applied to background. return EFalse; } } } return EFalse; }
/* ======================== idZipBuilder::CleanSourceFolder this folder is assumed to be a path under FSPATH_BASE ======================== */ void idZipBuilder::CleanSourceFolder() { #if 0 //#ifdef ID_PC_WIN idStrList deletedFiles; // make sure this is a valid path, we don't want to go nuking // some user path or something else unintentionally idStr ospath = sourceFolderName; ospath.SlashesToBackSlashes(); ospath.ToLower(); char relPath[MAX_OSPATH]; fileSystem->OSPathToRelativePath( ospath, relPath, MAX_OSPATH ); // get the game's base path idStr basePath = fileSystem->GetBasePathStr( FSPATH_BASE ); basePath.AppendPath( BASE_GAMEDIR ); basePath.AppendPath( "maps" ); basePath.SlashesToBackSlashes(); basePath.ToLower(); // path must be off of our base path, ospath can't have .map on the end, and // do some additional sanity checks if( ( ospath.Find( basePath ) == 0 ) && ( ospath.Right( 4 ) != ".map" ) && ( ospath != "c:\\" ) && ( ospath.Length() > basePath.Length() ) ) { // get the files in the current directory idFileList* files = fileSystem->ListFilesTree( relPath, "*.*" ); if( files->GetNumFiles() && zip_verbosity.GetBool() ) { idLib::Printf( "Deleting files in '%s'...\n", relPath ); } for( int i = 0; i < files->GetNumFiles(); i++ ) { if( IsFiltered( files->GetFile( i ) ) ) { continue; } // nuke 'em if( zip_verbosity.GetBool() ) { idLib::Printf( "\t...%s\n", files->GetFile( i ) ); } fileSystem->RemoveFile( files->GetFile( i ) ); char ospath2[MAX_OSPATH]; fileSystem->RelativePathToOSPath( files->GetFile( i ), ospath2, MAX_OSPATH ); deletedFiles.Append( ospath2 ); } fileSystem->FreeFileList( files ); fileSystem->RemoveDir( relPath ); } else { idLib::Printf( "Warning: idZipBuilder::CleanSourceFolder - Non-standard path: '%s'!\n", ospath.c_str() ); return; } // figure out which deleted files need to be removed from source control, and then remove those files idStrList filesToRemoveFromSourceControl; for( int i = 0; i < deletedFiles.Num(); i++ ) { scFileStatus_t fileStatus = idLib::sourceControl->GetFileStatus( deletedFiles[ i ] ); if( SCF_IS_IN_SOURCE_CONTROL( fileStatus ) ) { filesToRemoveFromSourceControl.Append( deletedFiles[ i ] ); } } if( filesToRemoveFromSourceControl.Num() > 0 ) { idLib::sourceControl->Delete( filesToRemoveFromSourceControl ); } #endif }
/* ======================== idZipBuilder::CreateZipFile ======================== */ bool idZipBuilder::CreateZipFile( bool appendFiles ) { #if 0 //#ifdef ID_PC if( zipFileName.IsEmpty() || sourceFolderName.IsEmpty() ) { idLib::Warning( "[%s] - invalid parameters!", __FUNCTION__ ); return false; } // need to clear the filesystem's zip cache before we can open and write //fileSystem->ClearZipCache(); idLib::Printf( "Building zip file: '%s'\n", zipFileName.c_str() ); sourceFolderName.StripTrailing( "\\" ); sourceFolderName.StripTrailing( "/" ); #if 0 // attempt to check the file out if( !Sys_IsFileWritable( zipFileName ) ) { if( ( idLib::sourceControl == NULL ) || !idLib::sourceControl->CheckOut( zipFileName ) ) { idLib::Warning( "READONLY zip file couldn't be checked out: %s", zipFileName.c_str() ); } else { idLib::Printf( "Checked out: %s\n", zipFileName.c_str() ); } } #endif // if not appending, set the file size to zero to "create it from scratch" if( !appendFiles ) { idLib::PrintfIf( zip_verbosity.GetBool(), "Overwriting zip file: '%s'\n", zipFileName.c_str() ); idFile* zipFile = fileSystem->OpenExplicitFileWrite( zipFileName ); if( zipFile != NULL ) { delete zipFile; zipFile = NULL; } } else { idLib::PrintfIf( zip_verbosity.GetBool(), "Appending to zip file: '%s'\n", zipFileName.c_str() ); } // enumerate the files to zip up in the source folder idStrStatic< MAX_OSPATH > relPath; relPath = fileSystem->OSPathToRelativePath( sourceFolderName ); idFileList* files = fileSystem->ListFilesTree( relPath, "*.*" ); // check to make sure that at least one file will be added to the package int atLeastOneFilteredFile = false; for( int i = 0; i < files->GetNumFiles(); i++ ) { idStr filename = files->GetFile( i ); if( !IsFiltered( filename ) ) { atLeastOneFilteredFile = true; break; } } if( !atLeastOneFilteredFile ) { // although we didn't actually update/create a zip file, it's because no files would be added anyway, which would result in a corrupted zip idLib::Printf( "Skipping zip creation/modification, no additional changes need to be made...\n" ); return true; } // open the zip file zipFile zf = zipOpen( zipFileName, appendFiles ? APPEND_STATUS_ADDINZIP : 0 ); if( zf == NULL ) { idLib::Warning( "[%s] - error opening file '%s'!", __FUNCTION__, zipFileName.c_str() ); return false; } // add the files to the zip file for( int i = 0; i < files->GetNumFiles(); i++ ) { // add each file to the zip file zip_fileinfo zi; memset( &zi, 0, sizeof( zip_fileinfo ) ); idStr filename = files->GetFile( i ); if( IsFiltered( filename ) ) { idLib::PrintfIf( zip_verbosity.GetBool(), "...Skipping: '%s'\n", filename.c_str() ); continue; } idStr filenameInZip = filename; filenameInZip.Strip( relPath ); filenameInZip.StripLeading( "/" ); idStrStatic< MAX_OSPATH > ospath; ospath = fileSystem->RelativePathToOSPath( filename ); GetFileTime( ospath, &zi.dosDate ); idLib::PrintfIf( zip_verbosity.GetBool(), "...Adding: '%s' ", filenameInZip.c_str() ); int compressionMethod = Z_DEFLATED; if( IsUncompressed( filenameInZip ) ) { compressionMethod = 0; } int errcode = zipOpenNewFileInZip3( zf, filenameInZip, &zi, NULL, 0, NULL, 0, NULL /* comment*/, compressionMethod, DEFAULT_COMPRESSION_LEVEL, 0, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, NULL /*password*/, 0 /*fileCRC*/ ); if( errcode != ZIP_OK ) { idLib::Warning( "Error opening file in zipfile!" ); continue; } else { // open the source file idFile_Permanent src( filename, ospath, FS_READ ); if( !src.IsOpen() ) { idLib::Warning( "Error opening source file!" ); continue; } // copy the file data into the zip file idTempArray<byte> buffer( DEFAULT_WRITEBUFFERSIZE ); size_t total = 0; while( size_t bytesRead = src.Read( buffer.Ptr(), buffer.Size() ) ) { if( bytesRead > 0 ) { errcode = zipWriteInFileInZip( zf, buffer.Ptr(), ( unsigned int )bytesRead ); if( errcode != ZIP_OK ) { idLib::Warning( "Error writing to zipfile (%i bytes)!", bytesRead ); continue; } } total += bytesRead; } assert( total == ( size_t )src.Length() ); } errcode = zipCloseFileInZip( zf ); if( errcode != ZIP_OK ) { idLib::Warning( "Error zipping source file!" ); continue; } idLib::PrintfIf( zip_verbosity.GetBool(), "\n" ); } // free the file list if( files != NULL ) { fileSystem->FreeFileList( files ); } // close the zip file int closeError = zipClose( zf, NULL ); if( closeError != ZIP_OK ) { idLib::Warning( "[%s] - error closing file '%s'!", __FUNCTION__, zipFileName.c_str() ); return false; } idLib::Printf( "Done.\n" ); return true; #else return false; #endif }
void DatabaseGroupWidget::SetFilter(const QString& Filter) { this->Filter = Filter; this->setVisible(!IsFiltered()); }
/*********************************************************************************** ** WriteL ** ** ***********************************************************************************/ void SearchTemplate::WriteL(const OpStringC8& currsection, PrefsFile* searchengines, BOOL& result) { // Only ever write out user search.ini information (i.e not from the package) // (or from package, but changed by user) if (IsFromPackage()) { result = FALSE; return; } // If the search has been deleted and it was not from the package search.ini, don't write it to custom search.ini if (!IsFromPackageOrModified() && IsFiltered()) { result = FALSE; return; } result = TRUE; //searchengines->WriteIntL(currsection, "ID", m_id); searchengines->WriteStringL(currsection, "UNIQUEID", m_guid); searchengines->WriteStringL(currsection, "Name", m_stringname); searchengines->WriteIntL(currsection, "Verbtext", m_format_id); searchengines->WriteStringL(currsection, "URL", m_url); // Write tracking codes only if URL still contains '{TrackingCode}' template. // Refer to the SearchTemplate::SetURL() which replaces SearchTemplate::m_url with an updated URL. if (m_url.FindI(UNI_L("{TrackingCode}")) != KNotFound) { searchengines->WriteStringL(currsection, "Default Tracking Code", m_default_tracking_code); searchengines->WriteStringL(currsection, "SpeedDial Tracking Code", m_speeddial_tracking_code); } else { // searchengines should be cleared before this function is called (SearchEngineManager does that) OP_ASSERT(!searchengines->IsKey(currsection, "Default Tracking Code")); OP_ASSERT(!searchengines->IsKey(currsection, "SpeedDial Tracking Code")); } // ** Suggest Protocol - The protocol used for search suggestions, if available. // ** Suggest URL - The url used for search suggestions. if(m_suggest_protocol != SearchTemplate::SUGGEST_NONE && m_suggest_url.HasContent()) { const uni_char *suggest_type = NULL; switch(m_suggest_protocol) { case SearchTemplate::SUGGEST_JSON: suggest_type = UNI_L("JSON"); break; } searchengines->WriteStringL(currsection, "Suggest Protocol", suggest_type); searchengines->WriteStringL(currsection, "Suggest URL", m_suggest_url); } // We do not write an ICON entry searchengines->WriteStringL(currsection, "Query", m_query); searchengines->WriteStringL(currsection, "Key", m_key); searchengines->WriteIntL(currsection, "Is post", m_is_post ? 1 : 0); searchengines->WriteIntL(currsection, "UseTLD", m_use_tld ? 1 : 0); searchengines->WriteIntL(currsection, "Has endseparator", m_seperator_after); searchengines->WriteStringL(currsection, "Encoding", m_encoding); searchengines->WriteIntL(currsection, "Search Type", m_type); searchengines->WriteIntL(currsection, "Position", m_pbar_pos); searchengines->WriteIntL(currsection, "Nameid", m_name); searchengines->WriteIntL(currsection, "Deleted", IsFiltered() ? 1 : 0); }
void LogBase::WriteVAW(ELogMessageType type, ELogMessageLevel nLevel, LPCWSTR pszModule, LPCWSTR pszMessage, va_list args) throw() { #if defined(_UNICODE) || defined(UNICODE) WriteVA(type, nLevel, pszModule, pszMessage, args); #else if (IsFiltered(type, nLevel)) // не обрабатываем сообщение, если оно не попадает в лог return; // 75% времени тратится на new и delete, поэтому первую попытку попробуем сделать без него. StackResizableBuf<WCHAR, 1024> buf; int pos; for (;;) { pos = _vsnwprintf(buf.data, buf.size - 1, pszMessage, args); if (pos != -1) break; // BUG 16456 FIX, см. в конец WriteVAW почему if (buf.size >= 1024 * 256) { pos = buf.size - 1; break; } buf.Resize(buf.size * 2); } if (pos >= 0) { buf.data[pos] = 0; LPTSTR pszStr = static_cast<LPTSTR>(_alloca(buf.size)); if (0 == WideCharToMultiByte(CP_ACP, 0/*WC_DEFAULTCHAR*/, buf.data, pos + 1, pszStr, buf.size, NULL, NULL)) { _RPT1(_CRT_ERROR, "Can't convert Unicode string (error #0x%08X)", GetLastError()); return; } LPCTSTR pszMod; if (pszModule == NULL) pszMod = m_szModule.c_str(); else { size_t nModuleLen = wcslen(pszModule) + 1; LPTSTR pszModBuf = static_cast<LPTSTR>(_alloca(nModuleLen)); if (0 == WideCharToMultiByte(CP_ACP, 0/*WC_DEFAULTCHAR*/, pszModule, nModuleLen, pszModBuf, nModuleLen, NULL, NULL)) { _RPT1(_CRT_ERROR, "Can't convert Unicode string (error #0x%08X)", GetLastError()); return; } pszMod = pszModBuf; } SYSTEMTIME st; GetLocalTime(&st); TCHAR bufdate[128], buftime[128], bufthread[128]; _stprintf(bufdate, _T("%i-%02i-%02i"), st.wYear, st.wMonth, st.wDay); _stprintf(buftime, _T("%02i:%02i:%02i.%03d"), st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); _stprintf(bufthread, _T("%03x"), GetCurrentThreadId()); m_pMedia->Write(type, nLevel, bufdate, buftime, bufthread, GetThreadName(), pszMod, pszStr); } #endif /* BUG 16456 FIX _vsnwprintf спотыкается на строках с символом 0xFFFF, возвращает -1 при любой длине буфера. Соответсвтвенно буфер увеличивается (Resize) пока не хватит памяти, а потом вызывается _vsnwprintf на NULL. Решение: Т.к. _vsnwprintf, даже если нехватает буфера, начало заполняет, то просто ограничим буфер 256кб (а 0 на конце и так ставим на всякий случай) #include <stdarg.h> #include <stdio.h> void WriteVAW(wchar_t* pszMessage, va_list args) { wchar_t buf[1000]; int n = _vsnwprintf(buf, 1000, pszMessage, args); printf("Return %i\nBuf is: \"%ls\"", n, buf); // n будет -1, хотя буфера хватает !!! } void WriteW(wchar_t* pszMessage, ...) { va_list ap; va_start(ap, pszMessage); WriteVAW(pszMessage, ap); va_end(ap); } void main() { WriteW(L"%ls!", L"123\xffff"); } */ }
bool CMOOSPlayBackV2::Iterate(MOOSMSG_LIST &Output) { if(IsEOF()) return false; double dfStopTime = m_dfLastMessageTime+m_dfTickTime; bool bDone = false; while(!bDone && !IsEOF() ) { CMOOSMsg NewMsg; double dfTNext = m_ALog.GetEntryTime(m_nCurrentLine); //are we in a mode in which we are slaved to a client //via its publishing of MOOS_CHOKE? m_dfClientLagTime = MOOSTime() - m_dfLastClientProcessedTime; if (m_dfLastClientProcessedTime != -1 && m_dfClientLagTime > MAX_CHOKE_TIME) { m_bWaitingForClientCatchup = true; bDone = true; dfStopTime = dfTNext; continue; } else { //normal sequential processing under our own steam m_bWaitingForClientCatchup = false; if(dfTNext<=dfStopTime) { if(MessageFromLine(m_ALog.GetLine(m_nCurrentLine),NewMsg)) { if(!IsFiltered(NewMsg.GetSource())) { Output.push_front(NewMsg); } } // arh moved this out of the loop above, because a failed // call to MessageFromLine would make uPlayback hang in // an infinite loop m_nCurrentLine++; } else { bDone = true; } } } //post a playback time if(!Output.empty()) { CMOOSMsg timeMsg( MOOS_NOTIFY, "PLAYBACK_DB_TIME", dfStopTime ); timeMsg.m_sSrc = "uPlayback"; Output.push_front( timeMsg ); } m_dfLastMessageTime = dfStopTime; return true; }
bool CIPFilter::IsFiltered(uint32 ip) /*const*/ { return IsFiltered(ip, thePrefs.GetIPFilterLevel()); }
bool DatabaseGroupWidget::GetSelected() { if(IsFiltered()) return false; return this->IsSelected; }