1 /* $NetBSD: assertions.c,v 1.1.1.4 2009/04/12 16:35:45 christos Exp $ */
4 * Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 1997, 1999, 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 #include <sys/cdefs.h>
21 #if !defined(LINT) && !defined(CODECENTER) && !defined(lint)
23 static const char rcsid
[] = "Id: assertions.c,v 1.5 2008/11/14 02:36:51 marka Exp";
25 __RCSID("$NetBSD: assertions.c,v 1.5 2008/06/21 20:41:48 christos Exp $");
29 #include "port_before.h"
36 #include <isc/assertions.h>
38 #include "port_after.h"
44 static void default_assertion_failed(const char *, int, assertion_type
,
51 assertion_failure_callback __assertion_failed
= default_assertion_failed
;
54 set_assertion_failure_callback(assertion_failure_callback f
) {
56 __assertion_failed
= default_assertion_failed
;
58 __assertion_failed
= f
;
62 assertion_type_to_text(assertion_type type
) {
75 case assert_invariant
:
90 default_assertion_failed(const char *file
, int line
, assertion_type type
,
91 const char *cond
, int print_errno
)
93 fprintf(stderr
, "%s:%d: %s(%s)%s%s failed.\n",
94 file
, line
, assertion_type_to_text(type
), cond
,
95 (print_errno
) ? ": " : "",
96 (print_errno
) ? strerror(errno
) : "");