1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
|
#ifndef production
static char rcsId[]="$Header: /usr/local/rcs/Newt/XmHTML/RCS/error.c,v 1.9 1998/04/27 06:59:08 newt Exp newt $";
#endif
/*****
* error.c : XmHTML warning/error functions
*
* This file Version $Revision: 1.9 $
*
* Creation date: Wed Jan 29 19:30:25 GMT+0100 1997
* Last modification: $Date: 1998/04/27 06:59:08 $
* By: $Author: newt $
* Current State: $State: Exp $
*
* Author: newt
*
* Copyright (C) 1994-1997 by Ripley Software Development
* All Rights Reserved
*
* This file is part of the XmHTML Widget Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****/
/*****
* ChangeLog
* $Log: error.c,v $
* Revision 1.9 1998/04/27 06:59:08 newt
* tka stuff
*
* Revision 1.8 1998/04/04 06:28:05 newt
* XmHTML Beta 1.1.3
*
* Revision 1.7 1997/08/31 17:33:22 newt
* log edit
*
* Revision 1.6 1997/08/30 00:48:26 newt
* Modified all protos: there are now two different versions of each function:
* one for debugging and one for production builds.
*
* Revision 1.5 1997/08/01 12:59:10 newt
* Added _XmHTMLBadParent
*
* Revision 1.4 1997/04/29 14:25:39 newt
* Moved dependency on a XmHTML widget out.
*
* Revision 1.3 1997/03/20 08:08:33 newt
* LynxOS changes
*
* Revision 1.2 1997/03/02 23:16:45 newt
* moved all html widget declarations between #ifdef DEBUG/#endif pairs
*
* Revision 1.1 1997/02/11 01:59:21 newt
* Initial Revision
*
*****/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#ifdef __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include <stdio.h> /* must follow stdarg or varargs on LynxOS */
#include "toolkit.h"
#include XmHTMLPrivateHeader
/*** External Function Prototype Declarations ***/
/*** Public Variable Declarations ***/
/*** Private Datatype Declarations ****/
/*** Private Function Prototype Declarations ****/
/*** Private Variable Declarations ***/
#ifdef DEBUG
static char buf[640];
static char loc[128];
#else
static char buf[512];
#endif
/* default string that gets appended when a fatal error occurs */
static String authors = " Please contact the XmHTML author at "
"ripley@xs4all.nl.";
static String err_fmt = "\n Name: %s\n Class: %s\n ";
/* undefine these to prevent compiler errors */
#undef _XmHTMLWarning
#undef _XmHTMLError
/*****
* Name: __XmHTMLWarning
* Return Type: void
* Description: displays a warning message to stderr
* In:
* w: widget;
* module: source file name;
* line: line number information;
* routine: routine name;
* fmt: message to display;
* ...: extra args to fmt;
* Returns:
* nothing
* Note:
* the module, line and routine args are only used when DEBUG was defined
* during compilation.
*****/
void
#ifdef __STDC__
__XmHTMLWarning(Widget w,
# ifdef DEBUG
String module, int line, String routine,
# endif
String fmt, ...)
{
va_list arg_list;
va_start(arg_list, fmt);
#else /* ! __STDC__ */
# ifdef DEBUG
__XmHTMLWarning(w, module, line, routine, fmt, va_alist)
Widget w;
String module;
int line;
String routine;
# else /* !DEBUG */
__XmHTMLWarning(w, fmt, va_alist)
Widget w;
# endif /* DEBUG */
String fmt;
va_dcl
{
va_list arg_list;
va_start(arg_list);
#endif /* __STDC__ */
#ifdef DEBUG
if(w && debug_disable_warnings)
return;
sprintf(loc, "\n (%s, %s, line %i)\n", module, routine, line);
#endif
if(w)
{
sprintf(buf, err_fmt, TkaWidgetName(w), TkaWidgetClassName(w));
vsprintf(buf+strlen(buf), fmt, arg_list);
va_end(arg_list);
#ifdef DEBUG
strcat(buf, loc);
#else
strcat(buf, "\n");
#endif
XtAppWarning(XtWidgetToApplicationContext(w), buf);
}
else
{
vsprintf(buf, fmt, arg_list);
va_end(arg_list);
#ifdef DEBUG
strcat(buf, loc);
#else
strcat(buf, "\n");
#endif
XtWarning(buf);
}
_XmHTMLDebugMirrorToFile((buf));
}
/*****
* Name: __XmHTMLError
* Return Type: void
* Description: displays an error message on stderr and exits.
* In:
* w: widget;
* module: source file name;
* line: line information;
* routine: routine name;
* fmt: message to display;
* ...: args to message;
* Returns:
* nothing.
* Note:
* the module, line and routine args are only used when DEBUG was defined
* during compilation.
*****/
void
#ifdef __STDC__
__XmHTMLError(Widget w,
#ifdef DEBUG
String module, int line, String routine,
#endif
String fmt, ...)
{
va_list arg_list;
va_start(arg_list, fmt);
#else /* ! __STDC__ */
# ifdef DEBUG
__XmHTMLError(w, module, line, routine, fmt, va_alist)
Widget w;
String module;
int line;
String routine;
# else /* !DEBUG */
__XmHTMLError(w, fmt, va_alist)
Widget w;
# endif /* DEBUG */
String fmt;
va_dcl
{
va_list arg_list;
va_start(arg_list);
#endif /* __STDC__ */
#ifdef DEBUG
if(w && debug_disable_warnings)
return;
sprintf(loc, "\n (%s, %s, line %i)\n", module, routine, line);
#endif
if(w)
{
sprintf(buf, err_fmt, TkaWidgetName(w), TkaWidgetClassName(w));
vsprintf(buf+strlen(buf), fmt, arg_list);
va_end(arg_list);
#ifdef DEBUG
strcat(buf, loc);
#else
strcat(buf, "\n");
#endif
strcat(buf, authors);
XtAppError(XtWidgetToApplicationContext(w), buf);
}
else
{
vsprintf(buf, fmt, arg_list);
va_end(arg_list);
#ifdef DEBUG
strcat(buf, loc);
#else
strcat(buf, "\n");
#endif
strcat(buf, authors);
XtError(buf);
}
_XmHTMLDebugMirrorToFile((buf));
exit(EXIT_FAILURE);
}
/*****
* Name: _XmHTMLAllocError
* Return Type: void
* Description: displays an error message on stderr and exits.
* In:
* w: widget
* module: source file name
* routine: routine name
* func: function used for allocation
* size: size for which allocation was attempted.
* Returns:
* nothing.
*****/
void
_XmHTMLAllocError(Widget w, char *module, char *routine, char *func, int size)
{
if(w)
{
sprintf(buf, "\n Name: %s\n Class: %s\n "
"cannot continue: %s failed for %i bytes.\n (%s, %s)\n",
TkaWidgetName(w), TkaWidgetClassName(w), func,
size, module, routine);
XtAppError(XtWidgetToApplicationContext(w), buf);
}
else
{
sprintf(buf, "cannot continue: %s failed for %i bytes.\n"
" (%s, %s)\n", func, size, module, routine);
XtError(buf);
}
_XmHTMLDebugMirrorToFile((buf));
exit(EXIT_FAILURE);
}
/*****
* Name: __XmHTMLBadParent
* Return Type: void
* Description: default warning message for a call to a public routine and
* the widget argument is either NULL or not of class XmHTML.
* In:
* w: offending Widget id;
* src_file: source file where function is found;
* func: function in which error occured.
* Returns:
* nothing.
*****/
void
#ifdef DEBUG
__XmHTMLBadParent(Widget w, String src_file, int line, String func)
#else
__XmHTMLBadParent(Widget w, String func)
#endif
{
#ifdef DEBUG
__XmHTMLWarning(w, src_file, line, func, XMHTML_MSG_34,
#else
__XmHTMLWarning(w, XMHTML_MSG_34,
#endif
(w ? "Invalid parent" : "NULL parent"), func);
}
|