1*a466cc55SCy Schubert /* 2*a466cc55SCy Schubert * Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC") 3*a466cc55SCy Schubert * Copyright (C) 1998-2001 Internet Software Consortium. 4*a466cc55SCy Schubert * 5*a466cc55SCy Schubert * Permission to use, copy, modify, and/or distribute this software for any 6*a466cc55SCy Schubert * purpose with or without fee is hereby granted, provided that the above 7*a466cc55SCy Schubert * copyright notice and this permission notice appear in all copies. 8*a466cc55SCy Schubert * 9*a466cc55SCy Schubert * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 10*a466cc55SCy Schubert * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11*a466cc55SCy Schubert * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 12*a466cc55SCy Schubert * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13*a466cc55SCy Schubert * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 14*a466cc55SCy Schubert * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15*a466cc55SCy Schubert * PERFORMANCE OF THIS SOFTWARE. 16*a466cc55SCy Schubert */ 17*a466cc55SCy Schubert 18*a466cc55SCy Schubert /* $Id: error.h,v 1.22 2009/09/29 23:48:04 tbox Exp $ */ 19*a466cc55SCy Schubert 20*a466cc55SCy Schubert #ifndef ISC_ERROR_H 21*a466cc55SCy Schubert #define ISC_ERROR_H 1 22*a466cc55SCy Schubert 23*a466cc55SCy Schubert /*! \file isc/error.h */ 24*a466cc55SCy Schubert 25*a466cc55SCy Schubert #include <stdarg.h> 26*a466cc55SCy Schubert 27*a466cc55SCy Schubert #include <isc/formatcheck.h> 28*a466cc55SCy Schubert #include <isc/lang.h> 29*a466cc55SCy Schubert #include <isc/platform.h> 30*a466cc55SCy Schubert 31*a466cc55SCy Schubert ISC_LANG_BEGINDECLS 32*a466cc55SCy Schubert 33*a466cc55SCy Schubert typedef void (*isc_errorcallback_t)(const char *, int, const char *, va_list); 34*a466cc55SCy Schubert 35*a466cc55SCy Schubert /*% set unexpected error */ 36*a466cc55SCy Schubert void 37*a466cc55SCy Schubert isc_error_setunexpected(isc_errorcallback_t); 38*a466cc55SCy Schubert 39*a466cc55SCy Schubert /*% set fatal error */ 40*a466cc55SCy Schubert void 41*a466cc55SCy Schubert isc_error_setfatal(isc_errorcallback_t); 42*a466cc55SCy Schubert 43*a466cc55SCy Schubert /*% unexpected error */ 44*a466cc55SCy Schubert void 45*a466cc55SCy Schubert isc_error_unexpected(const char *, int, const char *, ...) 46*a466cc55SCy Schubert ISC_FORMAT_PRINTF(3, 4); 47*a466cc55SCy Schubert 48*a466cc55SCy Schubert /*% fatal error */ 49*a466cc55SCy Schubert ISC_PLATFORM_NORETURN_PRE void 50*a466cc55SCy Schubert isc_error_fatal(const char *, int, const char *, ...) 51*a466cc55SCy Schubert ISC_FORMAT_PRINTF(3, 4) ISC_PLATFORM_NORETURN_POST; 52*a466cc55SCy Schubert 53*a466cc55SCy Schubert /*% runtimecheck error */ 54*a466cc55SCy Schubert void 55*a466cc55SCy Schubert isc_error_runtimecheck(const char *, int, const char *); 56*a466cc55SCy Schubert 57*a466cc55SCy Schubert #define ISC_ERROR_RUNTIMECHECK(cond) \ 58*a466cc55SCy Schubert ((void) ((cond) || \ 59*a466cc55SCy Schubert ((isc_error_runtimecheck)(__FILE__, __LINE__, #cond), 0))) 60*a466cc55SCy Schubert 61*a466cc55SCy Schubert ISC_LANG_ENDDECLS 62*a466cc55SCy Schubert 63*a466cc55SCy Schubert #endif /* ISC_ERROR_H */ 64