/*************************************************************** errchk These functions are to simplify the handling of common fatal errors. The 'exit' function is used, so we are relying on the system to close files, etc. Header: ioserv.h Library: ioserv_x.h */ #include "common.h" /* exit() */ #include "ioserv.h" /* report_msg() */ FILE *check_fopen(char *fn, char *mode) { FILE *fp; char buff[255]; if ( (fp = fopen(fn, mode)) == NULL) { sprintf(buff, "\n%%%% ERROR: File %s could not be opened.\n\n", fn); report_msg(buff); exit(-1); } return(fp); } void check_error(int test, char *message ) { char buff[255]; if (test) { sprintf(buff, "\n%%%% ERROR: %d, %s\n", test, message); report_msg(buff); exit(-1); } return; }