71 #define BinaryCloseFile BINARYCLOSEFILE 72 #define BinaryOpenFile BINARYOPENFILE 73 #define BinaryReadFile BINARYREADFILE 74 #define BinarySetFile BINARYSETFILE 75 #define BinarySkipFile BINARYSKIPFILE 76 #define BinaryWriteFile BINARYWRITEFILE 77 #define IsBinaryFileOpen ISBINARYFILEOPEN 78 #define IsEndBinaryFile ISENDBINARYFILE 81 #define BinaryCloseFile binaryclosefile_ 82 #define BinaryOpenFile binaryopenfile_ 83 #define BinaryReadFile binaryreadfile_ 84 #define BinarySetFile binarysetfile_ 85 #define BinarySkipFile binaryskipfile_ 86 #define BinaryWriteFile binarywritefile_ 87 #define IsBinaryFileOpen isbinaryfileopen_ 88 #define IsEndBinaryFile isendbinaryfile_ 91 #define BinaryCloseFile binaryclosefile 92 #define BinaryOpenFile binaryopenfile 93 #define BinaryReadFile binaryreadfile 94 #define BinarySetFile binarysetfile 95 #define BinarySkipFile binaryskipfile 96 #define BinaryWriteFile binarywritefile 97 #define IsBinaryFileOpen isbinaryfileopen 98 #define IsEndBinaryFile isendbinaryfile 101 #define BinaryCloseFile binaryclosefile 102 #define BinaryOpenFile binaryopenfile 103 #define BinaryReadFile binaryreadfile_ 104 #define BinarySetFile binarysetfile 105 #define BinarySkipFile binaryskipfile 106 #define BinaryWriteFile binarywritefile_ 107 #define IsBinaryFileOpen isbinaryfileopen 108 #define IsEndBinaryFile isendbinaryfile_ 113 #define INTEGERTYPE 1 114 #define SHORTINTTYPE 2 115 #define LONGINTTYPE 3 118 #define QUADRUPLETYPE 6 120 #define LOGICALTYPE 8 121 #define COMPLEXTYPE 9 122 #define DOUBLECOMPLEXTYPE 10 123 #define QUADRUPLECOMPLEXTYPE 11 127 #define MAXBINFILES 99 147 int *number_of_items,
157 int *number_of_bytes,
162 int *number_of_items,
182 {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
183 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
184 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
185 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
186 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
187 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
188 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
189 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
190 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
191 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
192 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
217 strcpy(error_string,
">>ERROR: error closing binary file");
224 strcpy(error_string,
">>ERROR: file ID is out of range");
244 strcpy(error_string,
">>ERROR: binary file is already open");
248 if(
binaryfiles[*fileid-1] = fopen(filename,access_code))
255 strcpy(error_string,
">>ERROR: binary file could not be opened");
262 strcpy(error_string,
">>ERROR: file ID is out of range");
268 int *number_of_items,
285 int i,item_size,j,number_of_bytes,start_byte,temp;
294 strcpy(error_string,
">>ERROR: binary file is not open");
301 item_size=
sizeof(int);
306 item_size=
sizeof(float);
311 item_size=
sizeof(double);
316 item_size=
sizeof(char);
326 item_size=
sizeof(
short int);
331 strcpy(error_string,
">>ERROR: Invalid item type");
337 number_of_bytes=*number_of_items * item_size;
338 for(i = 0; i < number_of_bytes ; i++)
340 temp = getc(binaryfile);
341 data[i] = (char)temp;
345 data[number_of_bytes]=
'\0';
351 for(i = 0; i < *number_of_items; i++)
353 start_byte=i*item_size;
354 for(j = 0; j < item_size; j++)
356 temp = getc(binaryfile);
357 data[start_byte+item_size-j-1] = (char)temp;
362 *err=ferror(binaryfile);
365 strcpy(error_string,
">>ERROR: error reading binary file");
372 strcpy(error_string,
">>ERROR: file ID is out of range");
396 strcpy(error_string,
">>ERROR: binary file is not open");
404 *err=fseek(binaryfile,(
long)0,SEEK_SET);
407 strcpy(error_string,
">>ERROR: Could not set to beginning of file");
412 *err=fseek(binaryfile,(
long)0,SEEK_CUR);
415 strcpy(error_string,
">>ERROR: Could not set to current file position");
420 *err=fseek(binaryfile,(
long)0,SEEK_END);
423 strcpy(error_string,
">>ERROR: Could not set to end of file position");
429 strcpy(error_string,
">>ERROR: Invalid set_code");
437 strcpy(error_string,
">>ERROR: file ID is out of range");
442 int *number_of_bytes,
461 strcpy(error_string,
">>ERROR: binary file is not open");
465 for(i = 0; i < *number_of_bytes ; i++)
467 temp = getc(binaryfile);
470 *err=ferror(binaryfile);
473 strcpy(error_string,
">>ERROR: error skipping binary file");
480 strcpy(error_string,
">>ERROR: file ID is out of range");
486 int *number_of_items,
503 int i,item_size,j,number_of_bytes,start_byte;
512 strcpy(error_string,
">>ERROR: binary file is not open");
519 item_size=
sizeof(int);
524 item_size=
sizeof(float);
529 item_size=
sizeof(double);
534 item_size=
sizeof(char);
544 item_size=
sizeof(
short int);
549 strcpy(error_string,
">>ERROR: Invalid item type");
555 number_of_bytes=*number_of_items * item_size;
556 for(i = 0; i < number_of_bytes ; i++)
558 putc(data[i],binaryfile);
564 for(i = 0; i < *number_of_items; i++)
566 start_byte=i*item_size;
567 for(j = 0; j < item_size; j++)
569 putc(data[start_byte+item_size-j-1],binaryfile);
574 *err=ferror(binaryfile);
577 strcpy(error_string,
">>ERROR: error writing binary file");
584 strcpy(error_string,
">>ERROR: file ID is out of range");
617 strcpy(error_string,
">>ERROR: file ID is out of range");
651 strcpy(error_string,
">>ERROR: file ID is out of range");
void IsEndBinaryFile(int *fileid, int *returncode, int *err, char *error_string)
void IsBinaryFileOpen(int *fileid, int *returncode, int *err, char *error_string)
FILE * binaryfiles[MAXBINFILES]
void BinaryOpenFile(int *fileid, char *filename, char *access_code, int *err, char *error_string)
void BinarySkipFile(int *fileid, int *number_of_bytes, int *err, char *error_string)
void BinaryReadFile(int *fileid, int *endian, int *number_of_items, int *item_type, char *data, int *err, char *error_string)
void BinarySetFile(int *fileid, int *set_code, int *err, char *error_string)
void BinaryCloseFile(int *fileid, int *err, char *error_string)
void BinaryWriteFile(int *fileid, int *endian, int *number_of_items, int *item_type, char *data, int *err, char *error_string)