/*1* panic.c --2*3* Source code for the "panic" library procedure for Tcl;4* individual applications will probably override this with5* an application-specific panic procedure.6*7* Copyright (c) 1988-1993 The Regents of the University of California.8* Copyright (c) 1994 Sun Microsystems, Inc.9*10* See the file "license.terms" for information on usage and redistribution11* of this file, and for a DISCLAIMER OF ALL WARRANTIES.12*13* SCCS: @(#) panic.c 1.15 96/09/12 14:55:2514*/1516#define panic panicDummy1718#include <ast.h>19#include <stdio.h>20#if 021#ifdef NO_STDLIB_H22# include "../compat/stdlib.h"23#else24# include <stdlib.h>25#endif26#endif2728#include "tcl.h"2930#undef panic3132#if _BLD_tcl && defined(__EXPORT__)33#define extern __EXPORT__34#endif3536EXTERN void panic _ANSI_ARGS_((char *format, char *arg1,37char *arg2, char *arg3, char *arg4, char *arg5,38char *arg6, char *arg7, char *arg8));3940#undef extern4142/*43* The panicProc variable contains a pointer to an application44* specific panic procedure.45*/4647void (*panicProc) _ANSI_ARGS_(TCL_VARARGS(char *,format)) = NULL;4849/*50*----------------------------------------------------------------------51*52* Tcl_SetPanicProc --53*54* Replace the default panic behavior with the specified functiion.55*56* Results:57* None.58*59* Side effects:60* Sets the panicProc variable.61*62*----------------------------------------------------------------------63*/6465void66Tcl_SetPanicProc(proc)67void (*proc) _ANSI_ARGS_(TCL_VARARGS(char *,format));68{69panicProc = proc;70}7172/*73*----------------------------------------------------------------------74*75* panic --76*77* Print an error message and kill the process.78*79* Results:80* None.81*82* Side effects:83* The process dies, entering the debugger if possible.84*85*----------------------------------------------------------------------86*/8788/* VARARGS ARGSUSED */89void90panic(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)91char *format; /* Format string, suitable for passing to92* fprintf. */93char *arg1, *arg2, *arg3; /* Additional arguments (variable in number)94* to pass to fprintf. */95char *arg4, *arg5, *arg6, *arg7, *arg8;96{97if (panicProc != NULL) {98(void) (*panicProc)(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);99} else {100(void) fprintf(stderr, format, arg1, arg2, arg3, arg4, arg5, arg6,101arg7, arg8);102(void) fprintf(stderr, "\n");103(void) fflush(stderr);104abort();105}106}107108109