ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/madProps/frameCount.c
Revision: 39
Committed: Fri Jul 19 01:37:38 2002 UTC (21 years, 11 months ago) by mmeineke
Content type: text/plain
File size: 1212 byte(s)
Log Message:
This commit was generated by cvs2svn to compensate for changes in r38, which
included commits to RCS files with non-trunk default branches.

File Contents

# Content
1 #include <stdlib.h>
2 #include <stdio.h>
3
4 #include "frameCount.h"
5
6
7 int frameCount( char* in_name ){
8
9 FILE *in_file;
10 int nFrames = 0;
11 int i, j, k;
12 int lineNum = 0;
13 char readBuffer[2000];
14
15 in_file = fopen( in_name, "r" );
16 if( in_file == NULL ){
17 printf( "Error opening \"%s\"\n", in_name );
18 exit(8);
19 }
20
21 fgets( readBuffer, sizeof( readBuffer ), in_file );
22 lineNum++;
23 if( feof( in_file ) ){
24 printf( "File ended unexpectedly at line %d\n", lineNum );
25 exit(8);
26 }
27
28 while( !feof( in_file ) ){
29
30 i = atoi(readBuffer);
31
32 fgets( readBuffer, sizeof( readBuffer ), in_file );
33 lineNum++;
34 if( feof( in_file ) ){
35 printf( "File ended unexpectedly at line %d, in frame%d\n",
36 lineNum, nFrames+1 );
37 exit(8);
38 }
39
40
41 for(j=0; j<i; j++){
42
43 fgets( readBuffer, sizeof( readBuffer ), in_file );
44 lineNum++;
45 if( feof( in_file ) ){
46 printf( "File ended unexpectedly at line %d,"
47 " with atom %d, in frame %d\n", lineNum, j, nFrames+1 );
48 exit(8);
49 }
50
51 }
52
53 nFrames++;
54
55 fgets( readBuffer, sizeof( readBuffer ), in_file );
56 lineNum++;
57 }
58
59 fclose( in_file );
60
61 return nFrames;
62 }