int __cdecl main(
	int			iArgC,
	char **		ppszArgV)
#endif   
{
	int			iRetCode = 0;

	gigaInitGlobalVars();

#ifdef FLM_NLM

	// Setup the routines to be called when the NLM exits itself
	
	atexit( gigaCleanup);

#endif

	if( RC_BAD( FlmStartup()))
	{
		iRetCode = 1;
		goto Exit;
	}

	if( RC_BAD( FTXInit( gv_pszTitle, (FLMBYTE)80, (FLMBYTE)50,
					FLM_BLUE, FLM_LIGHTGRAY, NULL, NULL)))
	{
		iRetCode = 1;
		goto Exit;
	}

	FTXSetShutdownFlag( &gv_bShutdown);

	if( RC_BAD( FTXScreenInit( gv_pszTitle, &gv_pScreen)))
	{
		iRetCode = 1;
		goto Exit;
	}

	if( RC_BAD( FTXScreenInitStandardWindows( gv_pScreen, FLM_RED, FLM_WHITE,
		FLM_BLUE, FLM_WHITE, FALSE, TRUE, gv_pszTitle, NULL, &gv_pWindow)))
	{
		iRetCode = 1;
		goto Exit;
	}
	
	FTXWinGetCanvasSize( gv_pWindow, &gv_uiNumCols, &gv_uiNumRows);

	if( RC_BAD( f_mutexCreate( &gv_hWindowMutex)))
	{
		iRetCode = 99;
		goto Exit;
	}

	if( !gigaGetParams( iArgC, (const char **)ppszArgV))
	{
		iRetCode = 2;
		goto Exit;
	}

	f_pathReduce( gv_szDibName, gv_szDirectoryPath, gv_pszFileName);
	if( !gv_szDirectoryPath [0])
	{
		f_strcpy( gv_szDirectoryPath, ".");
	}
	
	if( RC_BAD( gigaLoadDatabase()))
	{
		iRetCode = 7;
		goto Exit;
	}

	if( !gv_bBatchMode)
	{
		gigaOutputErrMsg( "Load complete");
	}

Exit:

	if( gv_hWindowMutex != F_MUTEX_NULL)
	{
		f_mutexDestroy( &gv_hWindowMutex);
	}
	
	FTXExit();
	FlmShutdown();

#ifdef FLM_NLM
	if (!gv_bSynchronized)
	{
		SynchronizeStart();
		gv_bSynchronized = TRUE;
	}
#endif

	gv_bRunning = FALSE;
	return( iRetCode);
}
Beispiel #2
0
/****************************************************************************
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);
}
Beispiel #3
0
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);
}