home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tkisrc04.zip / tcl / os2 / panic.c < prev    next >
C/C++ Source or Header  |  1998-08-07  |  2KB  |  93 lines

  1. /* 
  2.  * panic.c --
  3.  *
  4.  *    Source code for the "panic" library procedure for Tcl;
  5.  *    individual applications will probably override this with
  6.  *    an application-specific panic procedure.
  7.  *
  8.  * Copyright (c) 1988-1993 The Regents of the University of California.
  9.  * Copyright (c) 1994 Sun Microsystems, Inc.
  10.  *
  11.  * See the file "license.terms" for information on usage and redistribution
  12.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  13.  *
  14.  * SCCS: @(#) panic.c 1.11 96/02/15 11:50:29
  15.  */
  16.  
  17. #include <stdio.h>
  18. #ifdef NO_STDLIB_H
  19. #   include "../compat/stdlib.h"
  20. #else
  21. #   include <stdlib.h>
  22. #endif
  23.  
  24. #include "tcl.h"
  25.  
  26. /*
  27.  * The panicProc variable contains a pointer to an application
  28.  * specific panic procedure.
  29.  */
  30.  
  31. void (*panicProc) _ANSI_ARGS_(TCL_VARARGS(char *,format)) = NULL;
  32.  
  33.  
  34.  
  35. /*
  36.  *----------------------------------------------------------------------
  37.  *
  38.  * Tcl_SetPanicProc --
  39.  *
  40.  *    Replace the default panic behavior with the specified functiion.
  41.  *
  42.  * Results:
  43.  *    None.
  44.  *
  45.  * Side effects:
  46.  *    Sets the panicProc variable.
  47.  *
  48.  *----------------------------------------------------------------------
  49.  */
  50.  
  51. void
  52. Tcl_SetPanicProc(proc)
  53.     void (*proc) _ANSI_ARGS_(TCL_VARARGS(char *,format));
  54. {
  55.     panicProc = proc;
  56. }
  57.  
  58. /*
  59.  *----------------------------------------------------------------------
  60.  *
  61.  * panic --
  62.  *
  63.  *    Print an error message and kill the process.
  64.  *
  65.  * Results:
  66.  *    None.
  67.  *
  68.  * Side effects:
  69.  *    The process dies, entering the debugger if possible.
  70.  *
  71.  *----------------------------------------------------------------------
  72.  */
  73.  
  74.     /* VARARGS ARGSUSED */
  75. void
  76. panic(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
  77.     char *format;        /* Format string, suitable for passing to
  78.                  * fprintf. */
  79.     char *arg1, *arg2, *arg3;    /* Additional arguments (variable in number)
  80.                  * to pass to fprintf. */
  81.     char *arg4, *arg5, *arg6, *arg7, *arg8;
  82. {
  83.     if (panicProc != NULL) {
  84.     (void) (*panicProc)(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
  85.     } else {
  86.     (void) fprintf(stderr, format, arg1, arg2, arg3, arg4, arg5, arg6,
  87.         arg7, arg8);
  88.     (void) fprintf(stderr, "\n");
  89.     (void) fflush(stderr);
  90.     abort();
  91.     }
  92. }
  93.