ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/frameCount/src/frameCount.c
(Generate patch)

Comparing trunk/frameCount/src/frameCount.c (file contents):
Revision 36 by mmeineke, Fri Jul 19 00:48:45 2002 UTC vs.
Revision 37 by mmeineke, Fri Jul 19 00:57:32 2002 UTC

# Line 5 | Line 5 | int frameCount( char* in_name ){
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 <        FILE *in_file;
33 <        int nFrames = 0;
34 <        int i, j, k;
35 <        int lineNum = 0;
36 <        char readBuffer[2000];
37 <        
38 <        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 <        if( feof( in_file ) ){
22 <                printf( "File ended unexpectedly at line %d\n", lineNum );
23 <                exit(8);
24 <        }
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 <        fgets( readBuffer, sizeof( readBuffer ), in_file );
41 <        lineNum++;
42 <
43 <        while( !feof( in_file ) ){
44 <                        
45 <                i = atoi(readBuffer);
46 <
47 <                if( feof( in_file ) ){
48 <                        printf( "File ended unexpectedly at line %d, in frame%d\n", lineNum, nFrames+1 );
49 <                        exit(8);
50 <                }
51 <                fgets( readBuffer, sizeof( readBuffer ), in_file );
52 <                lineNum++;
53 <
54 <                for(j=0; j<i; j++){
55 <                        
56 <                        if( feof( in_file ) ){
57 <                                printf( "File ended unexpectedly at line %d, with atom %d, in frame %d\n",
58 <                                                lineNum, j, nFrames+1 );
59 <                                exit(8);
60 <                        }
61 <                        fgets( readBuffer, sizeof( readBuffer ), in_file );
48 <                        lineNum++;
49 <                }
50 <
51 <                nFrames++;
52 <                
53 <                fgets( readBuffer, sizeof( readBuffer ), in_file );
54 <                lineNum++;
55 <        }
56 <
57 <        fclose( in_file );
58 <        
59 <        return nFrames;
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   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines