#include "stdio.h" #include "stdlib.h" #include "flatfile.h" #include "astring.h" /* --------------------------------------------------------------------------- fwopen - opens the header file and data file - READ WRITE --------------------------------------------------------------------------- */ int fwopen(char *filename) { int lu, error, i; FILE *data, *head; char lfn[100], line[80]; init_ff_system(); error = 0; strcpy(lfn, filename); lu = openhead_rw(filename); if (ff_pointer_h[lu] != NULL) { head = ff_pointer_h[lu]; error = opendata_rw(filename, lu); data = ff_pointer[lu]; if (!data) { error = 1; printf("Error in opening the data file.\n"); } } else { printf("Error in opening the header file.\n"); } if (!error) { for (i=0;i<3;i++) fgets(line,sizeof(line),head); ff_c_tot[lu]=atoi(strmid(line,40,strlen(line)-41)); fgets(line,sizeof(line),head); ff_ncol[lu]=atoi(strmid(line,40,strlen(line)-41)); fgets(line,sizeof(line),head); ff_rows[lu]=(long) atol(strmid(line,40,strlen(line)-41)); for (i=0;i<4+ff_ncol[lu]+4;i++) fgets(line,sizeof(line),head); ff_stime[lu] = c_s_to_r(strmid(line,14,22)); fgets(line,sizeof(line),head); ff_etime[lu] = c_s_to_r(strmid(line,14,22)); rewind(head); } return lu; }