示例#1
0
int main(int argc, char *argv[])
{
	DebugInit();
	
	ProcessEnvVars();

	ProcessCommandLine(argc, argv);
	
	DebugShutdown();
	
	return 0;
}
示例#2
0
int main( int argc, char *argv[])
{
char *p;
char *Switch, *Value;
char InputFileName[200];
int i;
XTL_FileStatus XTLFileStat;

/* initialize trace to off */
TraceInit(  );
SetTraceOutput( stdout );  /* defaults to stderr if not set, we want stdout */
TraceOn( FALSE );

DL_CL_ProcessArgs( argc, argv );
p = DL_CL_GetProgName( );

printf( "%s", p );
for( i = 0; Copyright[i] != NULL; ++i )
	puts( Copyright[i] );
	
if ( getcwd(CurrentDirectory, sizeof(CurrentDirectory) - 1) == NULL )
{
	CurrentDirectory[0] = 0;
	puts( "Failed to get current working directory" );
}


if (  DL_CL_GetArgCount() != 1 )
{
	for( i = 0; Instructions[i] != NULL; ++i )
		puts( Instructions[i] );
	
	ErrorExit( "\n" );
}
	
strcpy( InputFileName, DL_CL_GetArg( 0 ) );


for ( i = 0; DL_CL_GetSwitch( i, &Switch, &Value ); i++ )
{
	ProcessCommandLineSwitch( Switch, Value );
}

	/* Process and envirnmant variables */	
	ProcessEnvVars();


/* initialize the XronosIO library */
XronosIOInit();
XTL_SubVars_Init();

	/* init stuff from Conf file */
	puts( "Processing Conf file" );
	printf( "Conf File: %s\n", ConfFileName );
	if ( DL_ReadIniFile(ConfFileName) != 0 )
		ErrorExit( "Failed to read conf file" );

	p = DL_GetIniValue( "XF_MaxQuestions", NULL );
	if ( p != NULL )
	{
		SetMaxQuestions( atoi(p) );
	}
	
	QuestionsOnly = DL_GetIniBOOLValue( "XF_QuestionsOnly", QuestionsOnly );
	
	TagsRequired = DL_GetIniBOOLValue( "XF_TagsRequired", TagsRequired );
	
	SB_Texttt_removal = DL_GetIniBOOLValue( "SageBug_Texttt_removal", SB_Texttt_removal );

	InitUserDefinedSubstitution( );
	
	p = DL_GetIniStringValue( "XF_OutputFileHeader", NULL );
	if ( p != NULL )
	{
	strcpy( FileForOutputHeader, p );
	}
	
	p = DL_GetIniStringValue( "XF_OutputFileFooter", NULL );
	if ( p != NULL )
	{
	strcpy( FileForOutputFooter, p );
	}
	
	p = DL_GetIniStringValue( "XF_InputFileHeader", NULL );
	if ( p != NULL )
	{
	if ( XronosIO_SetHeaderFile( p ) != 0 )
		ErrorExit( "failed to set XF_InputFileHeader value" );
	printf( "Set Input HeaderFile: %s\n", p );
	}
	
	p = DL_GetIniStringValue( "XF_InputFileFooter", NULL );
	if ( p != NULL )
	{
	if ( XronosIO_SetFooterFile( p ) != 0 )
		ErrorExit( "failed to set XF_InputFileFooter value" );
	printf( "Set Input FooterFile: %s\n", p );
	}
	
	DL_DiscardIniFile();
	puts( "Done Processing Conf file" );
	/* end ini stuff */

strcpy( OutputFileName, InputFileName );

/* Load file into memory */
printf( "*** Reading input file: %s\n", InputFileName );
ReadInputFile( InputFileName );

/* kill dups */
puts( "*** Killing Dups" );
KillDups( );

/* deal with braces */
RecycleBuffers( );  /* recycle the previous pass output to the new pass input */
puts( "*** Braces processing" );
Braces( );

/* deal with question limit on file size */
RecycleBuffers( );  /* recycle the previous pass output to the new pass input */
puts( "*** Question Limit processing" );
QuestionLimit( );

if ( SB_Texttt_removal )
{
	/* deal with \text{\texttt{}} sage bug */
	RecycleBuffers( );  /* recycle the previous pass output to the new pass input */
	puts( "*** Texttt Removal processing" );
	TextttRemoval( );
}

/* deal with substitution processing - should be JUST before WriteOutputFile() */
RecycleBuffers( );  /* recycle the previous pass output to the new pass input */
puts( "*** Internal variable substitution processing" );
HandleSubstitution( );

/* write output file */
RecycleBuffers( );  /* recycle the previous pass output to the new pass input */
printf( "*** Writing Output file; %s\n", OutputFileName );
WriteOutputFile( OutputFileName );

puts( "*** Program Complete\n" );
return 0;
}