/*************************************************************************** Desc: This routine displays an error message to the screen. *****************************************************************************/ void ViewShowError( const char * pszMessage) { FLMUINT uiChar; FLMUINT uiNumCols; FLMUINT uiNumRows; f_conGetScreenSize( &uiNumCols, &uiNumRows); f_conSetBackFore( FLM_BLACK, FLM_WHITE); f_conClearScreen( 0, uiNumRows - 2); f_conSetBackFore( FLM_RED, FLM_WHITE); f_conStrOutXY( pszMessage, 0, uiNumRows - 2); f_conStrOutXY( "Press ENTER to continue: ", 0, uiNumRows - 1); for (;;) { uiChar = f_conGetKey(); if (uiChar == FKB_ENTER || uiChar == FKB_ESCAPE) { break; } } f_conSetBackFore( FLM_BLACK, FLM_WHITE); f_conClearScreen( 0, uiNumRows - 2); ViewEscPrompt(); }
/******************************************************************** Desc: ? *********************************************************************/ FSTATIC void bldShowError( const char * Message) { if( !gv_bBatchMode) { f_conSetBackFore( FLM_BLACK, FLM_LIGHTGRAY); f_conClearScreen( 0, 22); f_conSetBackFore( FLM_RED, FLM_WHITE); f_conStrOutXY( Message, 0, 22); f_conStrOutXY( "Press any character to continue, ESCAPE to quit: ", 0, 23); for (;;) { if (gv_bShutdown) { break; } else if (f_conHaveKey()) { if (f_conGetKey() == FKB_ESCAPE) { gv_bShutdown = TRUE; } break; } f_yieldCPU(); } f_conSetBackFore( FLM_BLACK, FLM_LIGHTGRAY); f_conClearScreen( 0, 22); } }
/******************************************************************** Desc: ? *********************************************************************/ FSTATIC RCODE bldGetUserInput( void ) { FLMUINT uiChar; f_conStrOutXY( "Q,ESC=Quit, Other=Continue: ", 0, 23); for (;;) { if( gv_bShutdown) { uiChar = FKB_ESCAPE; break; } else if( f_conHaveKey()) { uiChar = f_conGetKey(); if( uiChar) { break; } } f_yieldCPU(); } f_conSetBackFore( FLM_BLACK, FLM_LIGHTGRAY); f_conClearScreen( 0, 22); switch( uiChar) { case 'q': case 'Q': case FKB_ESCAPE: return( RC_SET( FERR_FAILURE)); default: break; } return( FERR_OK); }
/**************************************************************************** Desc: ****************************************************************************/ int main( int argc, char ** argv) { RCODE rc = FERR_OK; IFlmTest * pTest = NULL; unsigned int i = 1; ArgList * pArgs = NULL; TEST_INFO testInfo; if( RC_BAD( rc = FlmStartup())) { goto Exit; } if( (pArgs = f_new ArgList) == NULL) { rc = RC_SET( FERR_MEM); goto Exit; } #ifdef FLM_NLM f_conInit( 0, 0, "FLAIM Unit Test"); #endif if( argc > 1) { if( (f_strcmp( argv[1], "--help") == 0) || (f_strcmp( argv[1], "-h") == 0)) { printHelp(); goto Exit; } } pArgs->expandArgs( argv, argc); while( i < pArgs->getNumEntries()) { if( (*pArgs)[i][0] != '-') { goto Exit; } if( ((*pArgs)[i][1] == 'l') || ((*pArgs)[i][1] == 'L')) { testInfo.bLog = true; f_strcpy( testInfo.pszLogfile, &((*pArgs)[i][2])); } else if( ((*pArgs)[i][1] == 'd') || ((*pArgs)[i][1] == 'D')) { testInfo.bDisplay = true; } else if( ((*pArgs)[i][1] == 'c') || ((*pArgs)[i][1] == 'C')) { f_strcpy( testInfo.pszConfig, &((*pArgs)[i][2])); } else if( ((*pArgs)[i][1] == 'b') || ((*pArgs)[i][1] == 'B')) { f_strcpy( testInfo.pszBuild, &((*pArgs)[i][2])); } else if( ((*pArgs)[i][1] == 'u') || ((*pArgs)[i][1] == 'U')) { f_strcpy( testInfo.pszUser, &((*pArgs)[i][2])); } else { f_conPrintf( "\nInvalid parameter"); printHelp(); goto Exit; } i++; } f_conPrintf( "Running %s\n", argv[0]); if( RC_BAD( rc = getTest( &pTest))) { f_conPrintf( "ERROR: Unable to create test instance\n"); goto Exit; } if( pTest->init( testInfo.bLog, testInfo.pszLogfile, testInfo.bDisplay, testInfo.pszConfig, testInfo.pszEnvironment, testInfo.pszBuild, testInfo.pszUser) != 0) { f_conPrintf( "\nTest initialization failed"); goto Exit; } if( RC_BAD( rc = pTest->execute())) { goto Exit; } Exit: if( pTest) { pTest->Release(); } if( pArgs) { pArgs->Release(); } #ifdef FLM_NLM f_conPrintf( "\nPress any key to exit ... "); f_conGetKey(); #endif #ifdef FLM_NLM f_conExit(); #endif FlmShutdown(); return( (int)rc); }
int main( #endif int iArgC, char ** ppszArgV) { int iRetCode = 0; F_Pool LogPool; gv_bBatchMode = FALSE; gv_bRunning = TRUE; if( RC_BAD( FlmStartup())) { iRetCode = -1; goto Exit; } f_conInit( 0xFFFF, 0xFFFF, "FLAIM Database Rebuild"); if( RC_BAD( FlmGetFileSystem( &gv_pFileSystem))) { f_conStrOut( "\nCould not allocate a file system object.\n"); goto Exit; } LogPool.poolInit( 1024); if( RC_BAD( LogPool.poolAlloc( MAX_LOG_BUFF, (void **)&gv_pucLogBuffer))) { goto Exit; } if( bldGetParams( iArgC, (const char **)ppszArgV)) { if (!bldDoRebuild()) { iRetCode = 1; } } Exit: if (gv_bPauseBeforeExiting && !gv_bShutdown) { f_conStrOut( "\nPress any character to exit REBUILD: "); for (;;) { if (gv_bShutdown) { break; } if (f_conHaveKey()) { f_conGetKey(); break; } f_yieldCPU(); } } if (gv_pFileSystem) { gv_pFileSystem->Release(); gv_pFileSystem = NULL; } f_conExit(); FlmShutdown(); gv_bRunning = FALSE; return( iRetCode); }
/******************************************************************** Desc: ? *********************************************************************/ FSTATIC RCODE bldProgFunc( eStatusType eStatus, void * Parm1, void * Parm2, void * pvAppData ) { RCODE rc = FERR_OK; F_UNREFERENCED_PARM( Parm2); F_UNREFERENCED_PARM( pvAppData); if( eStatus == FLM_DB_COPY_STATUS) { DB_COPY_INFO * pCopyInfo = (DB_COPY_INFO *)Parm1; char ucDoing [200]; if( gv_ui64DatabaseSize != pCopyInfo->ui64BytesToCopy) { gv_ui64DatabaseSize = pCopyInfo->ui64BytesToCopy; bldOutNumValue( DB_SIZE_ROW, (FLMUINT)gv_ui64DatabaseSize); } gv_ui64BytesDone = pCopyInfo->ui64BytesCopied; bldOutNumValue( BYTES_DONE_ROW, (FLMUINT)gv_ui64BytesDone); gv_iLastDoing = -1; if (pCopyInfo->bNewSrcFile) { f_sprintf( (char *)ucDoing, "Saving File %-15s", (char *)pCopyInfo->szSrcFileName); ucDoing [25] = 0; bldOutValue( DOING_ROW, ucDoing); } } else if( eStatus == FLM_REBUILD_STATUS) { REBUILD_INFO * Progress = (REBUILD_INFO *)Parm1; /* First update the display */ if( gv_iLastDoing != Progress->iDoingFlag) { gv_ui64DatabaseSize = Progress->ui64DatabaseSize; bldOutNumValue( DB_SIZE_ROW, (FLMUINT)gv_ui64DatabaseSize); gv_iLastDoing = Progress->iDoingFlag; if( gv_iLastDoing == REBUILD_GET_BLK_SIZ) { bldOutValue( DOING_ROW, "Determining Block Size "); } else if( gv_iLastDoing == REBUILD_RECOVER_DICT) { bldOutValue( DOING_ROW, "Recovering Dictionaries "); } else { bldOutValue( DOING_ROW, "Recovering Data "); } } if( gv_iLastDoing == REBUILD_GET_BLK_SIZ) { if( gv_ui64DatabaseSize != Progress->ui64DatabaseSize) { gv_ui64DatabaseSize = Progress->ui64DatabaseSize; bldOutNumValue( DB_SIZE_ROW, (FLMUINT)gv_ui64DatabaseSize); } gv_ui64BytesDone = Progress->ui64BytesExamined; bldOutNumValue( BYTES_DONE_ROW, (FLMUINT)gv_ui64BytesDone); } else { if( gv_ui64DatabaseSize != Progress->ui64DatabaseSize) { gv_ui64DatabaseSize = Progress->ui64DatabaseSize; bldOutNumValue( DB_SIZE_ROW, (FLMUINT)gv_ui64DatabaseSize); } gv_ui64BytesDone = Progress->ui64BytesExamined; bldOutNumValue( BYTES_DONE_ROW, (FLMUINT)gv_ui64BytesDone); if( gv_uiTotalRecs != Progress->uiTotRecs) { gv_uiTotalRecs = Progress->uiTotRecs; bldOutNumValue( TOTAL_REC_ROW, gv_uiTotalRecs); } if( gv_iLastDoing == REBUILD_RECOVER_DICT) { if( gv_uiDictRecsRecovered != Progress->uiRecsRecov) { gv_uiDictRecsRecovered = Progress->uiRecsRecov; bldOutNumValue( DICT_RECOV_ROW, gv_uiDictRecsRecovered); } } else { if( gv_uiRecsRecovered != Progress->uiRecsRecov) { gv_uiRecsRecovered = Progress->uiRecsRecov; bldOutNumValue( RECOV_ROW, gv_uiRecsRecovered); } } } } else if( eStatus == FLM_PROBLEM_STATUS) { CORRUPT_INFO * pCorruptInfo = (CORRUPT_INFO *)Parm1; bldLogCorruptError( pCorruptInfo); goto Exit; } else if( eStatus == FLM_CHECK_RECORD_STATUS) { CHK_RECORD * pChkRec = (CHK_RECORD *)Parm1; if (pChkRec->pDictRecSet) { pChkRec->pDictRecSet->clear(); } } if ((f_conHaveKey()) && (f_conGetKey() == FKB_ESCAPE)) { f_conSetBackFore( FLM_BLACK, FLM_LIGHTGRAY); f_conClearScreen( 0, 22); f_conSetBackFore (FLM_RED, FLM_WHITE); f_conStrOutXY( "ESCAPE key pressed", 0, 22); rc = bldGetUserInput(); goto Exit; } f_yieldCPU(); Exit: return( rc); }