| 1 |
/* err/gsl_message.h |
| 2 |
* |
| 3 |
* Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation; either version 3 of the License, or (at |
| 8 |
* your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, but |
| 11 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program; if not, write to the Free Software |
| 17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#ifndef __GSL_MESSAGE_H__ |
| 21 |
#define __GSL_MESSAGE_H__ |
| 22 |
#include "gsl_types.h" |
| 23 |
|
| 24 |
#undef __BEGIN_DECLS |
| 25 |
#undef __END_DECLS |
| 26 |
#ifdef __cplusplus |
| 27 |
# define __BEGIN_DECLS extern "C" { |
| 28 |
# define __END_DECLS } |
| 29 |
#else |
| 30 |
# define __BEGIN_DECLS /* empty */ |
| 31 |
# define __END_DECLS /* empty */ |
| 32 |
#endif |
| 33 |
|
| 34 |
__BEGIN_DECLS |
| 35 |
|
| 36 |
/* Provide a general messaging service for client use. Messages can |
| 37 |
* be selectively turned off at compile time by defining an |
| 38 |
* appropriate message mask. Client code which uses the GSL_MESSAGE() |
| 39 |
* macro must provide a mask which is or'ed with the GSL_MESSAGE_MASK. |
| 40 |
* |
| 41 |
* The messaging service can be completely turned off |
| 42 |
* by defining GSL_MESSAGING_OFF. */ |
| 43 |
|
| 44 |
void gsl_message(const char * message, const char * file, int line, |
| 45 |
unsigned int mask); |
| 46 |
|
| 47 |
#ifndef GSL_MESSAGE_MASK |
| 48 |
#define GSL_MESSAGE_MASK 0xffffffffu /* default all messages allowed */ |
| 49 |
#endif |
| 50 |
|
| 51 |
GSL_VAR unsigned int gsl_message_mask ; |
| 52 |
|
| 53 |
/* Provide some symolic masks for client ease of use. */ |
| 54 |
|
| 55 |
enum { |
| 56 |
GSL_MESSAGE_MASK_A = 1, |
| 57 |
GSL_MESSAGE_MASK_B = 2, |
| 58 |
GSL_MESSAGE_MASK_C = 4, |
| 59 |
GSL_MESSAGE_MASK_D = 8, |
| 60 |
GSL_MESSAGE_MASK_E = 16, |
| 61 |
GSL_MESSAGE_MASK_F = 32, |
| 62 |
GSL_MESSAGE_MASK_G = 64, |
| 63 |
GSL_MESSAGE_MASK_H = 128 |
| 64 |
} ; |
| 65 |
|
| 66 |
#ifdef GSL_MESSAGING_OFF /* throw away messages */ |
| 67 |
#define GSL_MESSAGE(message, mask) do { } while(0) |
| 68 |
#else /* output all messages */ |
| 69 |
#define GSL_MESSAGE(message, mask) \ |
| 70 |
do { \ |
| 71 |
if (mask & GSL_MESSAGE_MASK) \ |
| 72 |
gsl_message (message, __FILE__, __LINE__, mask) ; \ |
| 73 |
} while (0) |
| 74 |
#endif |
| 75 |
|
| 76 |
__END_DECLS |
| 77 |
|
| 78 |
#endif /* __GSL_MESSAGE_H__ */ |
| 79 |
|
| 80 |
|