Blame include/error_context.h

Packit 1437d9
/*
Packit 1437d9
  Copyright (C) 2009  Andreas Gruenbacher <agruen@suse.de>
Packit 1437d9
Packit 1437d9
  This program is free software: you can redistribute it and/or modify it
Packit 1437d9
  under the terms of the GNU Lesser General Public License as published by
Packit 1437d9
  the Free Software Foundation, either version 2.1 of the License, or
Packit 1437d9
  (at your option) any later version.
Packit 1437d9
Packit 1437d9
  This program is distributed in the hope that it will be useful,
Packit 1437d9
  but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 1437d9
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 1437d9
  GNU Lesser General Public License for more details.
Packit 1437d9
Packit 1437d9
  You should have received a copy of the GNU Lesser General Public License
Packit 1437d9
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit 1437d9
 */
Packit 1437d9
Packit 1437d9
#ifndef __ERROR_CONTEXT_T
Packit 1437d9
#define __ERROR_CONTEXT_T
Packit 1437d9
Packit 1437d9
#ifdef __cplusplus
Packit 1437d9
extern "C" {
Packit 1437d9
#endif
Packit 1437d9
Packit 1437d9
struct error_context {
Packit 1437d9
	/* Process an error message */
Packit 1437d9
	void (*error) (struct error_context *, const char *, ...);
Packit 1437d9
Packit 1437d9
	/* Quote a file name for including in an error message */
Packit 1437d9
	const char *(*quote) (struct error_context *, const char *);
Packit 1437d9
Packit 1437d9
	/* Free a quoted name */
Packit 1437d9
	void (*quote_free) (struct error_context *, const char *);
Packit 1437d9
};
Packit 1437d9
Packit 1437d9
#ifdef ERROR_CONTEXT_MACROS
Packit 1437d9
# define error(ctx, args...) do { \
Packit 1437d9
	if ((ctx) && (ctx)->error) \
Packit 1437d9
		(ctx)->error((ctx), args); \
Packit 1437d9
	} while(0)
Packit 1437d9
# define quote(ctx, name) \
Packit 1437d9
	( ((ctx) && (ctx)->quote) ? (ctx)->quote((ctx), (name)) : (name) )
Packit 1437d9
# define quote_free(ctx, name) do { \
Packit 1437d9
	if ((ctx) && (ctx)->quote_free) \
Packit 1437d9
		(ctx)->quote_free((ctx), (name)); \
Packit 1437d9
	} while(0)
Packit 1437d9
#endif
Packit 1437d9
Packit 1437d9
#ifdef __cplusplus
Packit 1437d9
}
Packit 1437d9
#endif
Packit 1437d9
Packit 1437d9
#endif  /* __ERROR_CONTEXT_T */