1 /*-------------------------------------------------------------------------
2 * Copyright (C) 2000 Caldera Systems, Inc
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * Neither the name of Caldera Systems nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * `AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE CALDERA
24 * SYSTEMS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *-------------------------------------------------------------------------*/
32
33 /** Implementation of general debugging code.
34 *
35 * @file slp_debug.c
36 * @author John Calcote (jcalcote@novell.com)
37 * @attention Please submit patches to http://www.openslp.org
38 * @ingroup CommonCodeDebugAssert
39 */
40
41 #include "slp_types.h"
42 #include "slp_debug.h"
43
44 /** Displays a message when SLP_ASSERT macro expression fails
45 *
46 * Only called by the SLP_ASSERT macro, and then only if the assertion
47 * fails.
48 *
49 * @param[in] assertion - A text string indicating the failed expression.
50 * @param[in] file - The file name in which the assertion failed.
51 * @param[in] line - The line number on which the assertion failed.
52 *
53 * @return Zero.
54 */
SLPAssertionFailed(const char * assertion,const char * file,int line)55 int SLPAssertionFailed(const char * assertion, const char * file, int line)
56 {
57 #ifdef _WIN32
58 char errmsg[2048];
59 _snprintf(errmsg, sizeof(errmsg),
60 "Debug assertion \"%s\" failed.\n\tLine %d of file %s.\n",
61 assertion, line, file);
62 FatalAppExit(0, errmsg);
63 #else
64 fprintf(stderr, "Debug assertion \"%s\" failed."
65 "\n\tLine %d of file %s.\n", assertion, line, file);
66 /* exit(-1); */
67 #endif
68 return 0;
69 }
70
71 /*=========================================================================*/
72