ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/ihost/libukcprog/panic.c
Revision: 1.1
Committed: Fri Mar 8 14:37:29 2002 UTC (22 years, 8 months ago) by tdb
Content type: text/plain
Branch: MAIN
CVS Tags: IHOST_1_5_3, IHOST_1_5_2, IHOST_1_5_1, IHOST_1_5, IHOST_1_0_RC1
Log Message:
I'm not usually up for putting third party sources in here, but in this
case I'll make an exception. This is ukcprog, a set of useful C functions
which the ihost plugins Pete's writing uses. It's got a pretty free license
too. I've munged the Makefile around, as all it needs to do now is make the
library, not install anything. The idea is to statically compile the other
programs against this library, making the final binary independent of this
code etc.

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 }