📄 r2util.c
字号:
/* 2.2 31 Jan 98 W. Hall Modified to reflect changes made */
/* to the command line parameters. */
/* 25 Nov 98 D. Fralish Use R2_VERS as per Tisk 33 */
/*--------------------------------------------------------------------*/
extern void Usage()
{
printf( "\nR2Analyz Version %s\n", R2_VERS );
printf( "Copyright (c) 1993 University of West Florida\n\n" );
printf( "Usage : r2analyz [ ? | -h | -q | -v | -s ] \n");
printf(" -r {filename} -p {directory}\n\n" );
printf(" (ALL SWITCHES ARE CASE IN-SENSITIVE)\n\n");
printf( "where : ?, -h | -H = This usage help.\n" );
printf( " -q | -Q = No terminal output, not even errors!\n" );
printf( " -v | -V = Very verbose mode!\n" );
printf( " -s | -S = Output is the sets each branch is in\n");
printf( " -r|-R {filename} = Full path filename of the analysis input file.\n");
printf( " This is a required entry.\n");
printf( " -p|-P {directory} = Full path directory for the analysis .out file.\n");
printf( " This is a required entry.\n");
printf( "Default : Annotated listing output with\n");
printf( " some progress information and error messages.\n\n" );
exit( EXIT_SUCCESS );
} /* Usage() */
/*--------------------------------------------------------------------*/
/* FUNCTION NullStruct */
/*--------------------------------------------------------------------*/
/* PURPOSE Clears the command line argument structure */
/* */
/* HISTORY: */
/* VER DATE AUTHOR DESCRIPTION */
/* 10 May 93 E. Martinez Created function. */
/*--------------------------------------------------------------------*/
extern void NullStruct(
clinput *CLInput /* Cmd line arguments */
)
{
CLInput->annotout = "a";
CLInput->analfile = "a";
CLInput->talk = "a";
CLInput->outmode = "a";
CLInput->usage = "a";
} /* NullStruct() */
/*--------------------------------------------------------------------*/
/* FUNCTION EvalValueType */
/*--------------------------------------------------------------------*/
/* PURPOSE Evaluates the first character in each line of the */
/* test file. Returns the source filename, filename */
/* length, switch value and source file line number. */
/* Trace file error checking is performed as each */
/* item is read. The program aborts when an error is*/
/* found. */
/* */
/* HISTORY: */
/* VER DATE AUTHOR DESCRIPTION */
/* 1.00 15 Mar 97 L. Landry Created function. */
/* 2.2 31 Jan 98 W. Hall Added a typecast to cval to clean */
/* up a compiler warning issue. */
/* 2.3 9 Mar 99 D. Fralish Add new value 'E' as per Tisk 38 */
/*--------------------------------------------------------------------*/
int EvalValueType(FILE *testFile, char *R2srcFile, int *lnum,
char *cval, long *sval,char name[MAXLINE],
int *lenName, int linenum)
{
int CommentVal=0;
char icval;
icval=*cval;
switch(icval)
{
case '#': getComment(name, testFile, linenum, R2srcFile);
CommentVal=1;
break;
case 'S': getSwitchValue(testFile, sval, linenum, R2srcFile);
case 'E':
case 'F':
case 'T': {
getLine(testFile, lnum, linenum, R2srcFile);
getName(name,lenName,linenum,testFile,R2srcFile);
}
break;
default : if (*cval=='\n')
{
printf("\nThere is a blank line at line");
printf(" %d in file %s\n",linenum,R2srcFile);
AbortMsg("Trace file Error");
}
else
{
printf("\nThere is an invalid or missing format");
printf(" symbol %c at line %d in file",*cval,linenum);
printf(" %s\n",R2srcFile);
AbortMsg("Trace file Error");
}
}
return(CommentVal);
} /* EvalValueType */
/*--------------------------------------------------------------------*/
/* FUNCTION getSwitchVAlue */
/*--------------------------------------------------------------------*/
/* PURPOSE Gets the switch value for case from the */
/* test file. Returns the switch value. */
/* */
/* HISTORY: */
/* VER DATE AUTHOR DESCRIPTION */
/* 1.00 15 Mar 97 L. Landry Created function. */
/* 2.2 31 Jan 98 T. Hall eliminated test of *sval == 0, */
/* making a 0 for a variable in a */
/* switch statement valid. */
/* changed 2 format descriptors to */
/* clean up compiler warning issues */
/*--------------------------------------------------------------------*/
RESULT getSwitchValue(FILE *testFile, long *sval,
int linenum, char * R2srcFile)
{
if(NULL==fscanf(testFile,"%ld",sval))
{
printf("\nThere is an invalid or missing switch value\n");
printf("at line %d in file %s\n",linenum,R2srcFile);
AbortMsg("Trace File error");
}
if (gTALK==2) printf(" %ld",*sval);
return(SUCCEED);
} /* getSwitchValue */
/*--------------------------------------------------------------------*/
/* FUNCTION getLine */
/*--------------------------------------------------------------------*/
/* PURPOSE Gets the source file line number from the */
/* test file. Returns the line number. */
/* */
/* HISTORY: */
/* VER DATE AUTHOR DESCRIPTION */
/* 1.00 15 Mar 97 L. Landry Created function. */
/*--------------------------------------------------------------------*/
RESULT getLine(FILE *testFile, int *lnum, int linenum, char * R2srcFile)
{
if(NULL==fscanf(testFile,"%d",lnum) || 0 == *lnum)
{
printf("\nThere is an invalid or missing line number or switch\n");
printf("value at line %d in file %s.\n",linenum,R2srcFile);
AbortMsg("Trace file error");
}
if (gTALK==2) printf(" %d",*lnum);
return(SUCCEED);
} /* getLine */
/*--------------------------------------------------------------------*/
/* FUNCTION getName */
/*--------------------------------------------------------------------*/
/* PURPOSE Gets the source file name and length from the */
/* test file. Returns the file name and length. */
/* */
/* HISTORY: */
/* VER DATE AUTHOR DESCRIPTION */
/* 1.00 15 Mar 97 L. Landry Created function. */
/*--------------------------------------------------------------------*/
RESULT getName(char name[MAXLINE], int *lenName, int linenum,
FILE *testFile, char * R2srcFile)
{
if(NULL == fscanf(testFile,"%d",lenName) || 0 > *lenName)
{
/* checks for an integer > 0 in the input */
printf("\nThe filename length, line number or switch value\n");
printf("at line %d in file %s.\n",linenum,R2srcFile);
AbortMsg("Trace File error");
}
fgetc(testFile); /* Remove the space between the lenght and filename */
fgets(name,MAXLINE,testFile);
if( strlen(name) != *lenName + 1)
{
/* check that the filemane and length match */
printf("\nThe filename at line %d in file ",linenum);
printf("%s is too long\n",R2srcFile);
printf("or the trace file line format is corrupted.\n");
printf("Trace file also may have missing or extra values.\n");
AbortMsg("Trace File error");
}
if (gTALK==2) printf(" %d %s",*lenName,name);
return(SUCCEED);
} /* getName */
/*--------------------------------------------------------------------*/
/* FUNCTION getComment */
/*--------------------------------------------------------------------*/
/* PURPOSE Gets the comment line from the test file. */
/* The comment is printed if gTALK=2. */
/* */
/* HISTORY: */
/* VER DATE AUTHOR DESCRIPTION */
/* 1.00 15 Mar 97 L. Landry Created function. */
/*--------------------------------------------------------------------*/
RESULT getComment(char name[MAXLINE], FILE *testFile,
int linenum, char * R2srcFile)
{
fgets(name,MAXLINE,testFile);
if ('\n' == *name)
{
printf("\nComment line %d was a NULL in %s\n",linenum, R2srcFile);
AbortMsg("Trace File error");
}
else
if (gTALK == 2)
printf("%s",name);
return(SUCCEED);
} /* getComment */
/*--------------------------------------------------------------------*/
/* FUNCTION getRecordType */
/*--------------------------------------------------------------------*/
/* PURPOSE Gets the first character on the line from the */
/* test file. Returns the file character or EOF. */
/* */
/* HISTORY: */
/* VER DATE AUTHOR DESCRIPTION */
/* 1.00 15 Mar 97 L. Landry Created function. */
/*--------------------------------------------------------------------*/
int getRecordType(FILE *testFile, char * cval)
{
char read = fgetc(testFile);
if (read == EOF)
return(-1);
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -