ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libukcprog/src/panic.c
Revision: 1.1
Committed: Sat Mar 29 16:30:33 2003 UTC (21 years, 1 month ago) by tdb
Content type: text/plain
Branch: MAIN
CVS Tags: LIBUKCPROG_1_0_2, LIBUKCPROG_1_0_1, LIBUKCPROG_1_0, HEAD
Log Message:
libukcprog is now a seperate package. I doubt this will be much use to
anyone other than us, but I see no reason why we can't package it up
and distribute it. Obviously we can't attach the GPL to this, as we
don't own it.

File Contents

# Content
1 /* panic.c -- Call a user user-defined panic handling routine and abort() */
2
3 /* Copyright 1992 Godfrey Paul, University of Kent at Canterbury.
4 *
5 * You can do what you like with this source code as long as
6 * you don't try to make money out of it and you include an
7 * unaltered copy of this message (including the copyright).
8 */
9
10 char ukcprog_panic_sccsid[] = "$Id: panic.c,v 1.9 1993/05/30 18:15:12 gjap Exp $ UKC";
11
12 #include <stdio.h>
13 #include <stdlib.h>
14
15 #include "ukcprog.h"
16
17
18 static panic_handler_t User_panic_handler = NULL;
19
20
21 /*
22 * install_panic_handler()
23 * Installs a new panic handler, returns the old one.
24 */
25 panic_handler_t
26 install_panic_handler(handler)
27 panic_handler_t handler;
28 {
29 panic_handler_t old;
30
31 old = User_panic_handler;
32 User_panic_handler = handler;
33
34 return old;
35 }
36
37
38 /*
39 * panic()
40 * Called when the world has ended. If a user-defined routine exists,
41 * call it with the given message as an argument. If not, or if it
42 * returns, print a suitable message and abort.
43 */
44 void
45 panic(message)
46 const char *message;
47 {
48 if (User_panic_handler != NULL)
49 (*User_panic_handler)(message);
50
51 fprintf(stderr, "Fatal internal error: %s (aborting) ...\n", message);
52 fflush(stderr);
53 abort();
54 }