/*-------------------------------------------------------------------------*/ /** @file qerror.c @author N. Devillard @date Aug 2001 @version $Revision: 1.5 $ @brief This module is responsible for error message display. It allows to re-direct all messages to a given set of functions for display. */ /*--------------------------------------------------------------------------*/ /* $Id: qerror.c,v 1.5 2002/01/15 10:18:38 ndevilla Exp $ $Author: ndevilla $ $Date: 2002/01/15 10:18:38 $ $Revision: 1.5 $ */ /*--------------------------------------------------------------------------- Includes ---------------------------------------------------------------------------*/ #include #include #include #include #include /*--------------------------------------------------------------------------- Defines ---------------------------------------------------------------------------*/ /* Max number of error handling functions registered */ #define QFITS_ERR_MAXERRDISP 8 /* Max size of an error message */ #define QFITS_ERR_MSGSIZE 1024 /*--------------------------------------------------------------------------- Private stuff ---------------------------------------------------------------------------*/ /* Type of a display function only defined for legibility here */ typedef void (*qfits_err_dispfunc)(char *) ; /* Default display function prints out msg to stderr */ static void qfits_err_display_stderr(char * s) { fprintf(stderr, "qfits: %s\n", s); } /* Static control structure, completely private */ static struct { qfits_err_dispfunc disp[QFITS_ERR_MAXERRDISP] ; int n ; int active ; } qfits_err_control = {{qfits_err_display_stderr}, 1, 1} ; /*--------------------------------------------------------------------------- Function codes ---------------------------------------------------------------------------*/ /* * Private: this is the main function used for message display. * It calls registered display functions one after another. */ static void qfits_err_main_display(char * msg) { int i ; /* Check if there is a message in input */ if (msg==NULL) return ; /* Loop on all registered functions and call them */ for (i=0 ; i