--- branches/mmeineke/frameCount/src/frameCount.c 2002/07/19 00:01:59 34 +++ trunk/frameCount/src/frameCount.c 2002/08/16 16:45:29 84 @@ -1,65 +1,75 @@ #include #include +#include -int main(int argc, char *argv[] ){ +#include "frameCount.h" - FILE *in_file; - int nFrames = 0; - int i, j, k; - int lineNum = 0; - char readBuffer[1000]; - - if( argc != 2 ){ - printf( "I need a dump file to read.\n" ); - exit(8); - } - - in_file = fopen( argv[1], "r" ); - if( in_file == NULL ){ - printf( "Error opening \"%s\"\n", argv[1] ); - exit(8); - } - - if( feof( in_file ) ){ - printf( "File ended unexpectedly at line %d\n", lineNum ); - exit(8); - } +int frameCount( char* in_name, int outTime ){ + + FILE *in_file; + int nFrames = 0; + double time; + int i, j, k; + int lineNum = 0; + char readBuffer[2000]; + char* foo; + - fgets( readBuffer, sizeof( readBuffer ), in_file ); - lineNum++; + in_file = fopen( in_name, "r" ); + if( in_file == NULL ){ + printf( "Error opening \"%s\"\n", in_name ); + exit(8); + } + + fgets( readBuffer, sizeof( readBuffer ), in_file ); + lineNum++; + if( feof( in_file ) ){ + printf( "File ended unexpectedly at line %d\n", lineNum ); + exit(8); + } + + if(outTime) printf("# frame Num\tTime\n" ); - while( !feof( in_file ) ){ - - i = atoi(readBuffer); + while( !feof( in_file ) ){ + + i = atoi(readBuffer); - if( feof( in_file ) ){ - printf( "File ended unexpectedly at line %d, in frame%d\n", lineNum, nFrames+1 ); - exit(8); - } - fgets( readBuffer, sizeof( readBuffer ), in_file ); - lineNum++; + fgets( readBuffer, sizeof( readBuffer ), in_file ); + lineNum++; + if( feof( in_file ) ){ + printf( "File ended unexpectedly at line %d, in frame%d\n", + lineNum, nFrames+1 ); + exit(8); + } - for(j=0; j