/* Copyright (C) 2008 Emmanuel Varoquaux
This file is part of XOS.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
#ifndef ERROR_H
#define ERROR_H
#include
#include
extern void (*error_func)(int, int, const char *, ...) __attribute__ ((format (printf, 3, 4)));
#define fail() exit(EXIT_FAILURE)
#define fatal_sys_error(errnum, ...) (error_func(EXIT_FAILURE, (errnum), __VA_ARGS__), fail())
#define fatal_error(...) (error_func(EXIT_FAILURE, 0, __VA_ARGS__), fail())
#define nonfatal_sys_error(errnum, ...) error_func(0, (errnum), __VA_ARGS__)
#define nonfatal_error(...) error_func(0, 0, __VA_ARGS__)
#define file_error(filename, msg) fatal_error("%s: %s", (filename), (msg))
#define file_error_errno(filename, msg) fatal_sys_error(errno, "%s: %s", (filename), (msg));
#endif