2 Copyright (C) 2009 Andreas Gruenbacher <agruen@suse.de>
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation, either version 2.1 of the License, or
7 (at your option) any later version.
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.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef __ERROR_CONTEXT_T
19 #define __ERROR_CONTEXT_T
25 struct error_context {
26 /* Process an error message */
27 void (*error) (struct error_context *, const char *, ...);
29 /* Quote a file name for including in an error message */
30 const char *(*quote) (struct error_context *, const char *);
32 /* Free a quoted name */
33 void (*quote_free) (struct error_context *, const char *);
36 #ifdef ERROR_CONTEXT_MACROS
37 # define error(ctx, args...) do { \
38 if ((ctx) && (ctx)->error) \
39 (ctx)->error((ctx), args); \
41 # define quote(ctx, name) \
42 ( ((ctx) && (ctx)->quote) ? (ctx)->quote((ctx), (name)) : (name) )
43 # define quote_free(ctx, name) do { \
44 if ((ctx) && (ctx)->quote_free) \
45 (ctx)->quote_free((ctx), (name)); \
53 #endif /* __ERROR_CONTEXT_T */