/* --------------------------------------------------------------------- */ /* BEGIN COPYRIGHT AND LICENSE NOTICE */ /* --------------------------------------------------------------------- */ /* ** Copyright (c) 2008, 2009 by Richard Harter. ** ** Permission is hereby granted, free of charge, to any person ** obtaining a copy of this software and associated documentation ** files , to deal in the Software without ** restriction, including without limitation the rights to use, ** copy, modify, merge, publish, distribute, sublicense, and/or ** sell copies of the Software, and to permit persons to whom the ** Software is furnished to do so, subject to the following ** conditions: ** ** The above copyright notice and this permission notice shall be ** included in copies of this software and in copies of substantial ** portions, whether or not the software has been modified. ** ** Derivative works shall include a notice that the software is a ** modified version of the copyrighted software. ** ** There is no guarantee that this software is useful for anything ** or that it is any way correct or of value. The author disclaims ** any responsibility for the consequences of using this software. ** */ /* --------------------------------------------------------------------- */ /* END COPYRIGHT AND LICENSE NOTICE */ /* --------------------------------------------------------------------- */ #include #include #include #include #include "errmgr.h" #include "getspace.h" #include "lineloc.h" #include "trace.h" static FILE * errfile; static FILE * logfile; static FILE * infofile; void errmgr_set_errfile(FILE * fptr) { errfile = fptr? fptr : stderr; } void errmgr_set_logfile(FILE * fptr) { logfile = fptr? fptr : stderr; } void errmgr_set_infofile(FILE * fptr) { infofile = fptr? fptr : stderr; } FILE * errmgr_get_errfile(void) { errfile = errfile?errfile:stderr; return errfile; } FILE * errmgr_get_logfile(void) { logfile = logfile? logfile: stderr; return logfile; } FILE * errmgr_get_infofile(void) { infofile = infofile? infofile: stderr; return infofile; } void errexit(char * loc, char *fmt,...) { va_list args; fprintf(errfile,"Error exit at %s\n",loc);fflush(errfile); va_start(args,fmt); vfprintf(errfile,fmt,args); fprintf(errfile,"\n"); fflush(errfile); va_end(args); trace_dump(errfile); printspace(errfile,LINELOC); exit(EXIT_FAILURE); }