2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1998-2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: error.c,v 1.16.206.1 2004/03/06 08:14:28 marka Exp $ */
25 #include <isc/error.h>
29 default_unexpected_callback(const char *, int, const char *, va_list)
30 ISC_FORMAT_PRINTF(3, 0);
33 default_fatal_callback(const char *, int, const char *, va_list)
34 ISC_FORMAT_PRINTF(3, 0);
36 static isc_errorcallback_t unexpected_callback = default_unexpected_callback;
37 static isc_errorcallback_t fatal_callback = default_fatal_callback;
40 isc_error_setunexpected(isc_errorcallback_t cb) {
42 unexpected_callback = default_unexpected_callback;
44 unexpected_callback = cb;
48 isc_error_setfatal(isc_errorcallback_t cb) {
50 fatal_callback = default_fatal_callback;
56 isc_error_unexpected(const char *file, int line, const char *format, ...) {
59 va_start(args, format);
60 (unexpected_callback)(file, line, format, args);
65 isc_error_fatal(const char *file, int line, const char *format, ...) {
68 va_start(args, format);
69 (fatal_callback)(file, line, format, args);
75 isc_error_runtimecheck(const char *file, int line, const char *expression) {
76 isc_error_fatal(file, line, "RUNTIME_CHECK(%s) %s", expression,
77 isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
78 ISC_MSG_FAILED, "failed"));
82 default_unexpected_callback(const char *file, int line, const char *format,
85 fprintf(stderr, "%s:%d: ", file, line);
86 vfprintf(stderr, format, args);
87 fprintf(stderr, "\n");
92 default_fatal_callback(const char *file, int line, const char *format,
95 fprintf(stderr, "%s:%d: %s: ", file, line,
96 isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
97 ISC_MSG_FATALERROR, "fatal error"));
98 vfprintf(stderr, format, args);
99 fprintf(stderr, "\n");