void DeepScanner::processFile(FIFile* pFile) { Error error; class SkipFile {}; try { Path path = pFile->getAbsolutePath(error, m_db.m_root); if (error) throw SkipFile(); m_fProgress = Real64(m_iCurItem) / Real64(m_db.m_pFIFiles.size()); progressReport(path); FileInputStream fis(error, path); if (error) throw SkipFile(); FIIndex* pIndex = vivFileIndex(error, fis); if (error) throw SkipFile(); pFile->setFIIndex(pIndex); pIndex->addFIFile(pFile); } catch (SkipFile&) { UTF16 sErrorMessage = (error ? UTF16(error) : L"Unknown Error"); skipWarning(pFile->getPath(), error); } }
int RarParse(stream_t *s, int *count, rar_file_t ***file) { *count = 0; *file = NULL; /* Skip marker */ if (IgnoreBlock(s, RAR_BLOCK_MARKER)) return VLC_EGENERIC; /* Skip archive */ if (IgnoreBlock(s, RAR_BLOCK_ARCHIVE)) return VLC_EGENERIC; /* */ for (;;) { rar_block_t bk; int ret; if (PeekBlock(s, &bk)) break; switch(bk.type) { case RAR_BLOCK_END: ret = SkipEnd(s, &bk); break; case RAR_BLOCK_FILE: ret = SkipFile(s, count, file, &bk); break; default: ret = SkipBlock(s, &bk); break; } if (ret) break; } return VLC_SUCCESS; }
int RarParse(stream_t *s, int *count, rar_file_t ***file) { *count = 0; *file = NULL; const rar_pattern_t *pattern = FindVolumePattern(s->psz_path); int volume_offset = 0; char *volume_mrl; if (asprintf(&volume_mrl, "%s://%s", s->psz_access, s->psz_path) < 0) return VLC_EGENERIC; stream_t *vol = s; for (;;) { /* Skip marker & archive */ if (IgnoreBlock(vol, RAR_BLOCK_MARKER) || IgnoreBlock(vol, RAR_BLOCK_ARCHIVE)) { if (vol != s) stream_Delete(vol); free(volume_mrl); return VLC_EGENERIC; } /* */ bool has_next = false; for (;;) { rar_block_t bk; int ret; if (PeekBlock(vol, &bk)) break; switch(bk.type) { case RAR_BLOCK_END: ret = SkipEnd(vol, &bk); has_next = ret && (bk.flags & RAR_BLOCK_END_HAS_NEXT); break; case RAR_BLOCK_FILE: ret = SkipFile(vol, count, file, &bk, volume_mrl); break; default: ret = SkipBlock(vol, &bk); break; } if (ret) break; } if (vol != s) stream_Delete(vol); if (!has_next || !pattern || (*count > 0 && !(*file)[*count -1]->is_complete)) { free(volume_mrl); return VLC_SUCCESS; } /* Open next volume */ const int volume_index = pattern->start + volume_offset++; if (volume_index > pattern->stop) { free(volume_mrl); return VLC_SUCCESS; } char *volume_base; if (asprintf(&volume_base, "%s://%.*s", s->psz_access, (int)(strlen(s->psz_path) - strlen(pattern->match)), s->psz_path) < 0) { free(volume_mrl); return VLC_SUCCESS; } free(volume_mrl); if (asprintf(&volume_mrl, pattern->format, volume_base, volume_index) < 0) volume_mrl = NULL; free(volume_base); if (!volume_mrl) return VLC_SUCCESS; vol = stream_UrlNew(s, volume_mrl); if (!vol) { free(volume_mrl); return VLC_SUCCESS; } } }
void CCodeProcessor::ProcessModule( bool forcequiet, int depth, int& maxdepth, int& numheaders, int& skippedfiles, const char *srcroot, const char *baseroot, const char *root, const char *module ) { char filename[ 256 ]; if ( depth > maxdepth ) { maxdepth = depth; } int filelength; char *buffer = NULL; // Always skip these particular modules/headers if ( SkipFile( module ) ) { CODE_MODULE module; module.skipped = true; m_Modules.Insert( filename, module ); skippedfiles++; return; } if ( !LoadFile( &buffer, filename, module, forcequiet, depth, filelength, numheaders, skippedfiles, srcroot, root, baseroot ) ) { CODE_MODULE module; module.skipped = true; m_Modules.Insert( filename, module ); skippedfiles++; return; } assert( buffer ); m_nBytesProcessed += filelength; CODE_MODULE m; m.skipped = false; m_Modules.Insert( filename, m ); if ( !forcequiet ) { strcpy( m_szCurrentCPP, filename ); } AddHeader( depth, filename, m_szCurrentCPP ); bool onclient = !strnicmp( m_szBaseEntityClass, "C_", 2 ) ? true : false; // Parse tokens looking for #include directives or class starts char *current = buffer; current = CC_ParseToken( current ); while ( 1 ) { // No more tokens if ( !current ) break; if ( !stricmp( com_token, "#include" ) ) { current = CC_ParseToken( current ); if ( strlen( com_token ) > 0 && com_token[ 0 ] != '<' ) { //vprint( "#include %s\n", com_token ); m_nHeadersProcessed++; numheaders++; ProcessModule( true, depth + 1, maxdepth, numheaders, skippedfiles, srcroot, baseroot, root, com_token ); } } else if ( !stricmp( com_token, "class" ) || !stricmp( com_token, "struct" ) ) { current = CC_ParseToken( current ); if ( strlen( com_token ) > 0 ) { //vprint( depth, "class %s\n", com_token ); CClass *cl = AddClass( com_token ); // Now see if there's a base class current = CC_ParseToken( current ); if ( !stricmp( com_token, ":" ) ) { // Parse out public and then classname an current = CC_ParseToken( current ); if ( !stricmp( com_token, "public" ) ) { current = CC_ParseToken( current ); if ( strlen( com_token ) > 0 ) { cl->SetBaseClass( com_token ); do { current = CC_ParseToken( current ); } while ( strlen( com_token ) && stricmp( com_token, "{" ) ); if ( !stricmp( com_token, "{" ) ) { current = cl->ParseClassDeclaration( current ); } } } } else if ( !stricmp( com_token, "{" ) ) { current = cl->ParseClassDeclaration( current ); } } } else if ( !strnicmp( com_token, "PREDICTABLE_CLASS", strlen( "PREDICTABLE_CLASS" ) ) ) { char prefix[ 32 ]; prefix[ 0 ] = 0; int type = 0; int bases = 1; int usebase = 0; if ( !stricmp( com_token, "PREDICTABLE_CLASS_ALIASED" ) ) { type = 2; bases = 2; if ( onclient ) { strcpy( prefix, "C_" ); } else { strcpy( prefix, "C" ); usebase = 1; } } else if ( !stricmp( com_token, "PREDICTABLE_CLASS_SHARED" ) ) { type = 1; bases = 1; } else if ( !stricmp( com_token, "PREDICTABLE_CLASS" ) ) { type = 0; bases = 1; if ( onclient ) { strcpy( prefix, "C_" ); } else { strcpy( prefix, "C" ); } } else if ( !stricmp( com_token, "PREDICTABLE_CLASS_ALIASED_PREFIXED" ) ) { // Nothing } else { vprint( 0, "PREDICTABLE_CLASS of unknown type!!! %s\n", com_token ); } // parse the ( current = CC_ParseToken( current ); if ( !strcmp( com_token, "(" ) ) { // Now the classname current = CC_ParseToken( current ); if ( strlen( com_token ) > 0 ) { //vprint( depth, "class %s\n", com_token ); CClass *cl = AddClass( com_token ); // Now see if there's a base class current = CC_ParseToken( current ); if ( !stricmp( com_token, "," ) ) { // Parse out public and then classname an current = CC_ParseToken( current ); if ( strlen( com_token ) > 0 ) { char basename[ 256 ]; sprintf( basename, "%s%s", prefix, com_token ); bool valid = true; if ( bases == 2 ) { valid = false; current = CC_ParseToken( current ); if ( !stricmp( com_token, "," ) ) { current = CC_ParseToken( current ); if ( strlen( com_token ) > 0 ) { valid = true; if ( usebase == 1 ) { sprintf( basename, "%s%s", prefix, com_token ); } } } } if ( valid ) { cl->SetBaseClass( basename ); strcpy( cl->m_szTypedefBaseClass, basename ); } do { current = CC_ParseToken( current ); } while ( strlen( com_token ) && stricmp( com_token, ")" ) ); if ( !stricmp( com_token, ")" ) ) { current = cl->ParseClassDeclaration( current ); } } } else if ( !stricmp( com_token, ")" ) ) { current = cl->ParseClassDeclaration( current ); } } } } else if ( !strcmp( com_token, "TYPEDESCRIPTION" ) || !strcmp( com_token, "typedescription_t" ) ) { current = ParseTypeDescription( current, false ); } else if ( !strcmp( com_token, "BEGIN_DATADESC" ) || !strcmp( com_token, "BEGIN_DATADESC_NO_BASE" ) || !strcmp( com_token, "BEGIN_SIMPLE_DATADESC" ) ) { current = ParseTypeDescription( current, true ); } else if ( !strcmp( com_token, "BEGIN_PREDICTION_DATA" ) || !strcmp( com_token, "BEGIN_EMBEDDED_PREDDESC" ) ) { current = ParsePredictionTypeDescription( current ); } else if ( !strcmp( com_token, "BEGIN_RECV_TABLE" ) || !strcmp( com_token, "BEGIN_RECV_TABLE_NOBASE" ) || !strcmp( com_token, "IMPLEMENT_CLIENTCLASS_DT" ) || !strcmp( com_token, "IMPLEMENT_CLIENTCLASS_DT_NOBASE" ) ) { current = ParseReceiveTable( current ); } else if ( !strcmp( com_token, "IMPLEMENT_PREDICTABLE_NODATA" ) ) { current = CC_ParseToken( current ); if ( !strcmp( com_token, "(" ) ) { current = CC_ParseToken( current ); CClass *cl = FindClass( com_token ); if ( cl ) { if ( cl->m_bHasPredictionData ) { if ( !forcequiet ) { vprint( 0, "Class %s declared predictable and implemented with IMPLEMENT_PREDICTABLE_NODATA in typedescription\n", cl->m_szName ); } cl->m_bHasPredictionData = false; } } current = CC_ParseToken( current ); } } current = CC_ParseToken( current ); } COM_FreeFile( (unsigned char *)buffer ); if ( !forcequiet && !GetQuiet() ) { vprint( 0, " %s: headers (%i game / %i total)", (char *)&filename[ m_nOffset ], numheaders - skippedfiles, numheaders ); if ( maxdepth > 1 ) { vprint( 0, ", depth %i", maxdepth ); } vprint( 0, "\n" ); } m_nLinesOfCode += linesprocessed; linesprocessed = 0; }
static void DoPass1( mod_entry *next, file_list *list ) /*****************************************************/ /* do pass 1 on the object file */ { member_list *member; char *membname; unsigned long loc; unsigned long size; unsigned reclength; bool lastmod; bool ignoreobj; loc = 0; lastmod = FALSE; if( CacheOpen( list ) ) { reclength = CheckLibraryType( list, &loc, FALSE ); for( ;; ) { /* there may be more than 1 object module in a file */ member = NULL; ignoreobj = FALSE; if( EndOfLib( list, loc ) ) break; membname = IdentifyObject( list, &loc, &size ); if( list->status & STAT_IS_LIB ) { if( (list->status & STAT_HAS_MEMBER) && list->u.member != NULL ) { member = FindMember( list, membname ); if( member == NULL ) { ignoreobj = TRUE; } else if( list->u.member == NULL ) { lastmod = TRUE; } } } if( ignoreobj ) { _LnkFree( membname ); if( size != 0 ) { loc += size; } else { SkipFile( list, &loc ); } } else { if( next == NULL ) { next = NewModEntry(); } next->n.next_mod = NULL; next->f.source = list; next->modtime = next->f.source->file->modtime; next->modinfo |= ObjFormat & FMT_OBJ_FMT_MASK; if( member != NULL ) { next->modinfo |= member->flags; _LnkFree( member ); } if( !(list->status & STAT_HAS_MEMBER) ) { next->modinfo |= list->status & DBI_MASK; if( list->status & STAT_LAST_SEG ) { next->modinfo |= MOD_LAST_SEG; } } AddToModList( next ); next->location = loc; if( membname == NULL ) { membname = ChkStrDup( list->file->name ); } next->name = membname; loc = ObjPass1(); if( list->status & STAT_TRACE_SYMS ) { TraceSymList( CurrMod->publist ); } next = NULL; } ObjFormat = 0; if( list->status & STAT_IS_LIB ) { // skip padding. loc += CalcAlign( loc, reclength ); } else if( !IS_FMT_OMF( CurrMod->modinfo ) ) { break; // can only concat omf. } if( lastmod || CacheEnd( list, loc ) ) { break; } } if( list->u.member != NULL ) { LnkMsg( ERR+MSG_CANT_FIND_MEMBER, "12", list->file->name, list->u.member->name ); } CacheClose( list, 1 ); } CheckStop(); }
int RarParse(struct stream *s, int *count, rar_file_t ***file) { *count = 0; *file = NULL; const rar_pattern_t *pattern = FindVolumePattern(s->url); int volume_offset = 0; char *volume_mrl; if (asprintf(&volume_mrl, "%s", s->url) < 0) return -1; struct stream *vol = s; for (;;) { /* Skip marker & archive */ if (IgnoreBlock(vol, RAR_BLOCK_MARKER) || IgnoreBlock(vol, RAR_BLOCK_ARCHIVE)) { if (vol != s) free_stream(vol); free(volume_mrl); return -1; } /* */ int has_next = -1; for (;;) { rar_block_t bk; int ret; if (PeekBlock(vol, &bk)) break; switch(bk.type) { case RAR_BLOCK_END: ret = SkipEnd(vol, &bk); has_next = ret && (bk.flags & RAR_BLOCK_END_HAS_NEXT); break; case RAR_BLOCK_FILE: ret = SkipFile(vol, count, file, &bk, volume_mrl); break; default: ret = SkipBlock(vol, &bk); break; } if (ret) break; } if (has_next < 0 && *count > 0 && !(*file)[*count -1]->is_complete) has_next = 1; if (vol != s) free_stream(vol); if (!has_next || !pattern) goto done; /* Open next volume */ const int volume_index = pattern->start + volume_offset++; if (volume_index > pattern->stop) goto done; char *volume_base; if (asprintf(&volume_base, "%.*s", (int)(strlen(s->url) - strlen(pattern->match)), s->url) < 0) { goto done; } free(volume_mrl); if (pattern->start) { if (asprintf(&volume_mrl, pattern->format, volume_base, volume_index) < 0) volume_mrl = NULL; } else { if (asprintf(&volume_mrl, pattern->format, volume_base, 'r' + volume_index / 100, volume_index % 100) < 0) volume_mrl = NULL; } free(volume_base); if (!volume_mrl) goto done; vol = stream_create(volume_mrl, STREAM_READ | STREAM_NO_FILTERS, s->cancel, s->global); if (!vol) goto done; } done: free(volume_mrl); if (*count == 0) { talloc_free(*file); return -1; } return 0; }
int RarParse(stream_t *s, int *count, rar_file_t ***file, unsigned int *pi_nbvols, bool b_extonly) { *count = 0; *file = NULL; *pi_nbvols = 1; if( s->psz_url == NULL ) return VLC_EGENERIC; const rar_pattern_t *pattern = FindVolumePattern(s->psz_url, b_extonly); int volume_offset = 0; char *volume_mrl = strdup(s->psz_url); if (volume_mrl == NULL) return VLC_ENOMEM; stream_t *vol = s; for (;;) { /* Skip marker & archive */ if (IgnoreBlock(vol, RAR_BLOCK_MARKER) || IgnoreBlock(vol, RAR_BLOCK_ARCHIVE)) { if (vol != s) stream_Delete(vol); free(volume_mrl); return VLC_EGENERIC; } /* */ int has_next = -1; for (;;) { rar_block_t bk; int ret; if (PeekBlock(vol, &bk)) break; switch(bk.type) { case RAR_BLOCK_END: ret = SkipEnd(vol, &bk); has_next = ret && (bk.flags & RAR_BLOCK_END_HAS_NEXT); break; case RAR_BLOCK_FILE: ret = SkipFile(vol, count, file, &bk, volume_mrl); break; default: ret = SkipBlock(vol, &bk); break; } if (ret) break; } if (has_next < 0 && *count > 0 && !(*file)[*count -1]->is_complete) has_next = 1; if (vol != s) stream_Delete(vol); free(volume_mrl); if (!has_next || !pattern) return VLC_SUCCESS; /* Open next volume */ const int volume_index = pattern->start + volume_offset++; if (volume_index > pattern->stop) return VLC_SUCCESS; char *volume_base = strndup(s->psz_url, strlen(s->psz_url) - strlen(pattern->match)); if (volume_base == NULL) return VLC_SUCCESS; if (pattern->start) { if (asprintf(&volume_mrl, pattern->format, volume_base, volume_index) < 0) volume_mrl = NULL; } else { if (asprintf(&volume_mrl, pattern->format, volume_base, 'r' + volume_index / 100, volume_index % 100) < 0) volume_mrl = NULL; } free(volume_base); if (!volume_mrl) return VLC_SUCCESS; const int s_flags = s->i_flags; s->i_flags |= OBJECT_FLAGS_NOINTERACT; vol = stream_UrlNew(s, volume_mrl); s->i_flags = s_flags; if (!vol) { free(volume_mrl); return VLC_SUCCESS; } (*pi_nbvols)++; } }