4 * Copyright (C) 2004, 2005, 2007, 2008 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 1997-2001 Internet Software Consortium.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
20 /* Id: assertions.c,v 1.23 2008/10/15 23:47:31 tbox Exp */
29 #include <isc/assertions.h>
37 default_callback(const char *, int, isc_assertiontype_t
, const char *);
43 LIBISC_EXTERNAL_DATA isc_assertioncallback_t isc_assertion_failed
=
48 isc_assertion_setcallback(isc_assertioncallback_t cb
) {
50 isc_assertion_failed
= default_callback
;
52 isc_assertion_failed
= cb
;
57 isc_assertion_typetotext(isc_assertiontype_t type
) {
61 * These strings have purposefully not been internationalized
62 * because they are considered to essentially be keywords of
63 * the ISC development environment.
66 case isc_assertiontype_require
:
69 case isc_assertiontype_ensure
:
72 case isc_assertiontype_insist
:
75 case isc_assertiontype_invariant
:
89 default_callback(const char *file
, int line
, isc_assertiontype_t type
,
92 fprintf(stderr
, "%s:%d: %s(%s) %s.\n",
93 file
, line
, isc_assertion_typetotext(type
), cond
,
94 isc_msgcat_get(isc_msgcat
, ISC_MSGSET_GENERAL
,
95 ISC_MSG_FAILED
, "failed"));