예제 #1
0
void OutputObjectDetail( cFCODatabaseFileIter& genreIter, const iFCONameTranslator* pNT, TOSTREAM* pOut )
{
    const cDbDataSourceIter dbIterDetails(&genreIter.GetDb());
 
    OutputIterPeers( dbIterDetails, genreIter.GetGenreHeader().GetPropDisplayer(), pNT, pOut, true);
    (*pOut) << endl;
}
예제 #2
0
// The rules summary is not working due to changes in the databasse infrastructure.  Until 
// we hear different from the product manager, it is out of here.
static void OutputRulesSummary(const cFCODatabaseFileIter& genreIter, const iFCONameTranslator* pNT, TOSTREAM* pOut )
{
    const cHierDatabase& db = genreIter.GetDb();  

    // these should add up to 79
    const int nameWidth = 50;
    const int numObjectsWidth = 10; 

    (*pOut) << g_sz79Dashes << endl;
    (*pOut) << TSS_GetString( cTW, tw::STR_RULE_SUMMARY ) << endl;
    (*pOut) << g_sz79Dashes << endl << endl;

    (*pOut).width(nameWidth);
    (*pOut) << TSS_GetString( cTW, tw::STR_RULE_NAME );
    (*pOut).width(numObjectsWidth);
    (*pOut) << TSS_GetString( cTW, tw::STR_OBJECTS ) << endl;

    (*pOut) << setw( nameWidth ) << _T("---------");
    (*pOut) << setw( numObjectsWidth ) << _T("-------");
    (*pOut) << endl;

    // output spec stats
    cFCOSpecListCanonicalIter specIter( genreIter.GetSpecList() );

    // iterate over all database elements 
    int nTotalObjects = 0;
    for( specIter.SeekBegin(); !specIter.Done(); specIter.Next() )
    {
        (*pOut) << setw( nameWidth ) << specIter.Spec()->GetName();

        // if the name is too long, put it on its own line
        if( specIter.Spec()->GetName().length() >= nameWidth )
        {
            (*pOut) << endl;

            // output space holder
            (*pOut).width(nameWidth);
            (*pOut) << _T("");
        }

        (*pOut).width(numObjectsWidth);
        (*pOut) << _T("TODO");
        //(*pOut) << specIter.GetFCOSet()->Size(); TODO: Do this right
        (*pOut) << endl;
    }
    
    (*pOut) << endl;

    // NOTE 4 Jan 99 mdb -- this used to use dbHeader.GetTotalObjectsScanned() but it was not always consistent with the 
    //      total number of objects in the database. TODO -- if we are really not going to use this number, then we should 
    //      not store it in the database at all.
    //
    (*pOut) << TSS_GetString( cTW, tw::STR_TOTAL_NUM_FILES );
    //(*pOut) << _T(" ") << nTotalObjects << endl;
    (*pOut) << _T("TODO") << endl;
    (*pOut) << endl;
}
예제 #3
0
void OutputObjectSummary( cFCODatabaseFileIter& genreIter, const iFCONameTranslator* pNT, TOSTREAM* pOut, int margin )
{
    const cDbDataSourceIter dbIter( &genreIter.GetDb() );
    ASSERT(dbIter.AtRoot());

    (*pOut) << setw( margin ) << _T("");
    TSTRING strBuf;
    (*pOut) << genreIter.GetGenreHeader().GetPropDisplayer()->GetDetailsHeader( strBuf, margin ).c_str() << endl;

    OutputIterPeers( dbIter, genreIter.GetGenreHeader().GetPropDisplayer(), pNT, pOut, false );
    (*pOut) << endl;
}
예제 #4
0
///////////////////////////////////////////////////////////////////////////////
// Execute
///////////////////////////////////////////////////////////////////////////////
void cDbExplore::Execute( cFCODatabaseFileIter& dbIter )
{
    ASSERT( ! dbIter.Done() );

    cDbDataSourceIter* pIter        = new cDbDataSourceIter( &dbIter.GetDb(), dbIter.GetGenre() );
    const iFCOPropDisplayer* pDisplayer = dbIter.GetGenreHeader().GetPropDisplayer();

    ////////////////////////////
    // the main event loop...
    ////////////////////////////
    while( true )
    {
        TSTRING verb, noun;
        TCOUT << _T(">>");
        TCIN >> verb;
        //
        // ok, now we switch on the command...
        //
        //-----------------------------------------------------------------
        // quit
        //-----------------------------------------------------------------
        if( verb.compare( _T("quit") ) == 0 )
        {
            // the quit command...
            break;
        }
        //-----------------------------------------------------------------
        // print
        //-----------------------------------------------------------------
        if( verb.compare( _T("print") ) == 0 )
        {
            GetNoun(noun);
            if( SeekTo( pIter, noun ) )
            {
                if( pIter->HasFCOData() )
                {
                    iFCO* pFCO = pIter->CreateFCO();
                    PrintFCO( pFCO, pDisplayer );
                    pFCO->Release();
                }
                else
                {
                    TCOUT << _T("Object has no data associated with it.") << std::endl;
                }
            }
            else
            {
                TCOUT << _T("Unable to find object ") << noun << std::endl;
            }
        }
        //-----------------------------------------------------------------
        // pwd
        //-----------------------------------------------------------------
        else if( verb.compare( _T("pwd") ) == 0 )
        {
            TCOUT << iTWFactory::GetInstance()->GetNameTranslator()->ToStringDisplay( pIter->GetParentName() ) << std::endl;
        }
        //-----------------------------------------------------------------
        // ls
        //-----------------------------------------------------------------
        else if( verb.compare( _T("ls") ) == 0 )
        {
            int cnt = 0;
            for( pIter->SeekBegin(); ! pIter->Done(); pIter->Next(), cnt++ )
            {
                TCOUT << _T("[") << cnt ;
                if( pIter->CanDescend() )
                {
                    TCOUT << _T("]*\t") ;
                }
                else
                {
                    TCOUT << _T("]\t") ;
                }
                TCOUT << pIter->GetShortName() << std::endl;
            }
        }
        //-----------------------------------------------------------------
        // cd
        //-----------------------------------------------------------------
        else if( verb.compare( _T("cd") ) == 0 )
        {
            GetNoun(noun);
            std::vector<TSTRING> vDirs;
            SplitString( noun, pIter->GetParentName().GetDelimiter(), vDirs );
            for( std::vector<TSTRING>::iterator i = vDirs.begin(); i != vDirs.end(); i++ )
            {
                
                if( i->compare( _T("..") ) == 0 )
                {
                    if( pIter->AtRoot() )
                    {
                        TCOUT << _T("Can't ascend above root.") << std::endl;
                        break;
                    }
                    else
                    {
                        TCOUT << _T("Ascending...") << std::endl;
                        pIter->Ascend();
                    }
                }
                else
                {
                    if( SeekTo( pIter, *i ) )
                    {
                        if( pIter->CanDescend() )
                        {
                            TCOUT << _T("Descending into ") << *i << std::endl;
                            pIter->Descend();
                        }
                        else
                        {
                            TCOUT << *i << _T(" has no children; can't descend.") << std::endl;
                            break;
                        }
                    }
                    else
                    {
                        TCOUT << _T("Unable to find object ") << *i << std::endl;
                        break;
                    }
                }
            }
        }
        //-----------------------------------------------------------------
        // cg
        //-----------------------------------------------------------------
        else if( verb.compare( _T("cg") ) == 0 )
        {
            GetNoun(noun);

            cGenre::Genre newGenre = cGenreSwitcher::GetInstance()->StringToGenre( noun.c_str() );

            if (newGenre != cGenre::GENRE_INVALID)
            {
                dbIter.SeekToGenre( newGenre );
                if( !dbIter.Done() )
                {
                    TCOUT << _T("Changing to Genre ") << noun << std::endl;
                    //
                    // create a new db iter for the new genre (db iters can only be
                    // assocaited with a single genre :-( )
                    //
                    delete pIter;
                    pIter = new cDbDataSourceIter( &dbIter.GetDb(), newGenre );
                }
                else
                {
                    TCOUT << _T("Unable to find Genre ") << noun << std::endl;
                }
            }
            else
            {
                TCOUT << _T("Invalid Genre ") << noun << std::endl;
            }
        }
        //-----------------------------------------------------------------
        // pwg
        //-----------------------------------------------------------------
        else if( verb.compare( _T("pwg") ) == 0 )
        {
            TCOUT << _T("Current Genre: ") << cGenreSwitcher::GetInstance()->GenreToString( (cGenre::Genre)dbIter.GetGenre(), true ) << std::endl;
        }

        //-----------------------------------------------------------------
        // help
        //-----------------------------------------------------------------
        if( verb.compare( _T("help") ) == 0 )
        {
            TCOUT   << _T("Commands: ")             << std::endl
                    << _T(" cd <dir_name>")         << std::endl
                    << _T(" pwd ")                  << std::endl
                    << _T(" ls ")                   << std::endl
                    << _T(" print <object_name>")   << std::endl
                    << _T(" cg (FS | NTFS | NTREG)")<< std::endl
                    << _T(" pwg")                   << std::endl
                    << _T(" quit")                  << std::endl;
        }

        // make sure the file is still valid...
        //
    /*
#ifdef _BLOCKFILE_DEBUG
        db.AssertAllBlocksValid() ;
#endif
    */
    }

    delete pIter;
    TCOUT << _T("Exiting...") << std::endl;

}
예제 #5
0
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Execute :
//		Drives the DebugDb mode of tripwire, which will only be used for internal use.
//////////////////////////////////////////////////////////////////////////////////////////////////////
void cDbDebug::Execute( cFCODatabaseFileIter& dbIter, const TSTRING& dbFile )
{
	
	cDebug d("cDebugDb::Execute");
	cDbDebug DbDebug;
	//
	//A derived class with extra methods for obtaining blockfile information.
	cDebugHierDb* db;
	//
	// Cast the database object that we have inherited from the "common" command line
	// information to a cDebugHierDb.  This will expose all the information that we 
	// need to debug the database.
	//
	db = static_cast<cDebugHierDb*>(&(dbIter.GetDb()));

	try
	{
		cDebugHierDbIter pIter( db );

		//
		//First, map the state of the underlying quantyum database.  Store this info. in 
		//the hierDbMap.
		//
		DbDebug.MapQuantumDatabase( *db );

		//DbDebug.DisplayDbMap(); //TODO : get rid of these display calls.

		//
		// Uncomment ManipDb() to allow manipulation of the database
		// This may be handy if one does not want to do a full update...
		//DbDebug.ManipDb( dbIter );

		// Next, traverse the hierarchical overlay and "tag" all entries in the map that
		// we see:
		ASSERT( pIter.AtRoot() );
			//
			// check to make sure we are at the root of the hierarchy, if so, map the root
			// before calling the recursive traversal function.
			//
		util_MapHierRoot( DbDebug.GetHierDbMap() );

		DbDebug.TraverseHierarchy( pIter /*, db*/ );

		//DbDebug.DisplayDbMap(); //TODO: get rid of these display calls.
		//
		// Finally, iterate over the map and see if there is any data that the hierarchy
		// does not account for:
		//
		DbDebug.CongruencyTest();
		//
		// Output the results
		//
		DbDebug.OutputResults();

	}//try

	catch( eError& e )
	{
		cErrorReporter::PrintErrorMsg( e );
	}
	
}