LALApps 10.1.0.1-eeff03c
errutil.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Jolien Creighton
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20#include "config.h"
21
22#include <stdio.h>
23#include <stdarg.h>
24#include <stdlib.h>
25
26#include <lal/LALStdlib.h>
27
28#include <LALAppsVCSInfo.h>
29#include "errutil.h"
30
31/* global flag to abort on error (rather than just exit) */
33
34extern int vrbflg;
35
36/* print an error message and either exit or abort */
37int error( const char *fmt, ... )
38{
39 va_list ap;
40 va_start( ap, fmt );
41 vfprintf( stderr, fmt, ap );
42 va_end( ap );
43 if ( abrtflg )
44 exit( 1 );
45 else
46 abort();
47 return 1;
48}
49
50/* print an verbose message if verbose messaging is turned on */
51int verbose( const char *fmt, ... )
52{
53 if ( vrbflg )
54 {
55 va_list ap;
56 va_start( ap, fmt );
57 vfprintf( stderr, fmt, ap );
58 va_end( ap );
59 }
60 return 0;
61}
62
63#if 0
64/* XLAL error handler to abort on error */
65void XLALAbortErrorHandler( const char *func, const char *file, int line,
66 int errnum )
67{
68 XLALPerror( func, file, line, errnum );
69 abort();
70}
71
72/* XLAL error handler to exit on error */
73void XLALExitErrorHandler( const char *func, const char *file, int line,
74 int errnum )
75{
76 XLALPerror( func, file, line, errnum );
77 exit(1);
78}
79#endif
80
81/* set handlers to abort on error */
83{
86 abrtflg = 1;
87 return;
88}
89
90/* set handlers to exit on error */
92{
95 abrtflg = 0;
96 return;
97}
int LAL_ERR_ABRT(LALStatus *stat, const char *func, const char *file, const int line, volatile const char *id)
lal_errhandler_t lal_errhandler
int LAL_ERR_EXIT(LALStatus *stat, const char *func, const char *file, const int line, volatile const char *id)
int abrtflg
Definition: errutil.c:32
int verbose(const char *fmt,...)
Definition: errutil.c:51
int error(const char *fmt,...)
Definition: errutil.c:37
void set_exit_on_error(void)
Definition: errutil.c:91
void set_abrt_on_error(void)
Definition: errutil.c:82
int vrbflg
defined in lal/lib/std/LALError.c
void XLALAbortErrorHandler(const char *func, const char *file, int line, int errnum)
XLALErrorHandlerType * XLALSetErrorHandler(XLALErrorHandlerType *newHandler)
void XLALExitErrorHandler(const char *func, const char *file, int line, int errnum)
void XLALPerror(const char *func, const char *file, int line, int errnum)
fmt