1 /****************************************************************************
2 * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
31 * and: Eric S. Raymond <esr@snark.thyrsus.com> *
32 * and: Thomas E. Dickey 1996-on *
33 ****************************************************************************/
36 * comp_error.c -- Error message routines
40 #include <curses.priv.h>
44 MODULE_ID("$Id: comp_error.c,v 1.31 2007/04/21 23:38:32 tom Exp $")
46 NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings = FALSE;
47 NCURSES_EXPORT_VAR(int) _nc_curr_line = 0; /* current line # in input */
48 NCURSES_EXPORT_VAR(int) _nc_curr_col = 0; /* current column # in input */
50 #define SourceName _nc_globals.comp_sourcename
51 #define TermType _nc_globals.comp_termtype
53 NCURSES_EXPORT(const char *)
60 _nc_set_source(const char *const name)
66 _nc_set_type(const char *const name)
69 TermType = typeMalloc(char, MAX_NAME_SIZE + 1);
73 strncat(TermType, name, MAX_NAME_SIZE);
78 _nc_get_type(char *name)
81 if (name == 0 && TermType != 0) {
82 FreeAndNull(TermType);
87 strcpy(name, TermType != 0 ? TermType : "");
90 static NCURSES_INLINE void
91 where_is_problem(void)
93 fprintf(stderr, "\"%s\"", SourceName ? SourceName : "?");
94 if (_nc_curr_line >= 0)
95 fprintf(stderr, ", line %d", _nc_curr_line);
96 if (_nc_curr_col >= 0)
97 fprintf(stderr, ", col %d", _nc_curr_col);
98 if (TermType != 0 && TermType[0] != '\0')
99 fprintf(stderr, ", terminal '%s'", TermType);
105 _nc_warning(const char *const fmt,...)
109 if (_nc_suppress_warnings)
114 vfprintf(stderr, fmt, argp);
115 fprintf(stderr, "\n");
120 _nc_err_abort(const char *const fmt,...)
126 vfprintf(stderr, fmt, argp);
127 fprintf(stderr, "\n");
133 _nc_syserr_abort(const char *const fmt,...)
139 vfprintf(stderr, fmt, argp);
140 fprintf(stderr, "\n");
143 /* If we're debugging, try to show where the problem occurred - this
146 #if defined(TRACE) || !defined(NDEBUG)
149 /* Dumping core in production code is not a good idea.