#include "stdio.h" #include "stdlib.h" #include "string.h" #include "astring.h" #include "flatfile.h" /* --------------------------------------------------------------------------- ffcreate - opens the header file which was just created, and creates a data file to write and read from. --------------------------------------------------------------------------- */ int ffcreate(char *filename) { int lu, error, i, stime[6] = {2100,1,1,0,0,0}; 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]; ff_pointer[lu] = fopen(strcat(lfn,".dat"),"w+b"); data = ff_pointer[lu]; if (!data) { error = 1; printf("Error in creating 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) atof(strmid(line,40,strlen(line)-41)); ff_stime[lu] = c_i_to_r(stime); ff_etime[lu] = 0.0; } return lu; }