sl@0: /* sl@0: * tclPanic.c -- sl@0: * sl@0: * Source code for the "Tcl_Panic" library procedure for Tcl; sl@0: * individual applications will probably call Tcl_SetPanicProc() sl@0: * to set an application-specific panic procedure. sl@0: * sl@0: * Copyright (c) 1988-1993 The Regents of the University of California. sl@0: * Copyright (c) 1994 Sun Microsystems, Inc. sl@0: * Copyright (c) 1998-1999 by Scriptics Corporation. sl@0: * Portions Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiaries. All rights reserved. sl@0: * sl@0: * See the file "license.terms" for information on usage and redistribution sl@0: * of this file, and for a DISCLAIMER OF ALL WARRANTIES. sl@0: * sl@0: * RCS: @(#) $Id: tclPanic.c,v 1.4.12.2 2006/03/09 23:11:23 dgp Exp $ sl@0: */ sl@0: sl@0: #include "tclInt.h" sl@0: #include "tclPort.h" sl@0: sl@0: /* sl@0: * The panicProc variable contains a pointer to an application sl@0: * specific panic procedure. sl@0: */ sl@0: sl@0: static Tcl_PanicProc *panicProc = NULL; sl@0: sl@0: /* sl@0: * The platformPanicProc variable contains a pointer to a platform sl@0: * specific panic procedure, if any. ( TclpPanic may be NULL via sl@0: * a macro. ) sl@0: */ sl@0: sl@0: static Tcl_PanicProc * CONST platformPanicProc = TclpPanic; sl@0: sl@0: sl@0: /* sl@0: *---------------------------------------------------------------------- sl@0: * sl@0: * Tcl_SetPanicProc -- sl@0: * sl@0: * Replace the default panic behavior with the specified functiion. sl@0: * sl@0: * Results: sl@0: * None. sl@0: * sl@0: * Side effects: sl@0: * Sets the panicProc variable. sl@0: * sl@0: *---------------------------------------------------------------------- sl@0: */ sl@0: sl@0: EXPORT_C void sl@0: Tcl_SetPanicProc(proc) sl@0: Tcl_PanicProc *proc; sl@0: { sl@0: panicProc = proc; sl@0: } sl@0: sl@0: /* sl@0: *---------------------------------------------------------------------- sl@0: * sl@0: * Tcl_PanicVA -- sl@0: * sl@0: * Print an error message and kill the process. sl@0: * sl@0: * Results: sl@0: * None. sl@0: * sl@0: * Side effects: sl@0: * The process dies, entering the debugger if possible. sl@0: * sl@0: *---------------------------------------------------------------------- sl@0: */ sl@0: sl@0: EXPORT_C void sl@0: Tcl_PanicVA (format, argList) sl@0: CONST char *format; /* Format string, suitable for passing to sl@0: * fprintf. */ sl@0: va_list argList; /* Variable argument list. */ sl@0: { sl@0: char *arg1, *arg2, *arg3, *arg4; /* Additional arguments (variable in sl@0: * number) to pass to fprintf. */ sl@0: char *arg5, *arg6, *arg7, *arg8; sl@0: sl@0: arg1 = va_arg(argList, char *); sl@0: arg2 = va_arg(argList, char *); sl@0: arg3 = va_arg(argList, char *); sl@0: arg4 = va_arg(argList, char *); sl@0: arg5 = va_arg(argList, char *); sl@0: arg6 = va_arg(argList, char *); sl@0: arg7 = va_arg(argList, char *); sl@0: arg8 = va_arg(argList, char *); sl@0: sl@0: if (panicProc != NULL) { sl@0: (void) (*panicProc)(format, arg1, arg2, arg3, arg4, sl@0: arg5, arg6, arg7, arg8); sl@0: } else if (platformPanicProc != NULL) { sl@0: (void) (*platformPanicProc)(format, arg1, arg2, arg3, arg4, sl@0: arg5, arg6, arg7, arg8); sl@0: } else { sl@0: (void) fprintf(stderr, format, arg1, arg2, arg3, arg4, arg5, arg6, sl@0: arg7, arg8); sl@0: (void) fprintf(stderr, "\n"); sl@0: (void) fflush(stderr); sl@0: abort(); sl@0: } sl@0: } sl@0: sl@0: /* sl@0: *---------------------------------------------------------------------- sl@0: * sl@0: * Tcl_Panic -- sl@0: * sl@0: * Print an error message and kill the process. sl@0: * sl@0: * Results: sl@0: * None. sl@0: * sl@0: * Side effects: sl@0: * The process dies, entering the debugger if possible. sl@0: * sl@0: *---------------------------------------------------------------------- sl@0: */ sl@0: sl@0: /* VARARGS ARGSUSED */ sl@0: EXPORT_C void sl@0: Tcl_Panic TCL_VARARGS_DEF(CONST char *,arg1) sl@0: { sl@0: va_list argList; sl@0: CONST char *format; sl@0: sl@0: format = TCL_VARARGS_START(CONST char *,arg1,argList); sl@0: Tcl_PanicVA(format, argList); sl@0: va_end (argList); sl@0: }