Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libtksh/tcl/panic.c
1810 views
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.15 96/09/12 14:55:25
15
*/
16
17
#define panic panicDummy
18
19
#include <ast.h>
20
#include <stdio.h>
21
#if 0
22
#ifdef NO_STDLIB_H
23
# include "../compat/stdlib.h"
24
#else
25
# include <stdlib.h>
26
#endif
27
#endif
28
29
#include "tcl.h"
30
31
#undef panic
32
33
#if _BLD_tcl && defined(__EXPORT__)
34
#define extern __EXPORT__
35
#endif
36
37
EXTERN void panic _ANSI_ARGS_((char *format, char *arg1,
38
char *arg2, char *arg3, char *arg4, char *arg5,
39
char *arg6, char *arg7, char *arg8));
40
41
#undef extern
42
43
/*
44
* The panicProc variable contains a pointer to an application
45
* specific panic procedure.
46
*/
47
48
void (*panicProc) _ANSI_ARGS_(TCL_VARARGS(char *,format)) = NULL;
49
50
/*
51
*----------------------------------------------------------------------
52
*
53
* Tcl_SetPanicProc --
54
*
55
* Replace the default panic behavior with the specified functiion.
56
*
57
* Results:
58
* None.
59
*
60
* Side effects:
61
* Sets the panicProc variable.
62
*
63
*----------------------------------------------------------------------
64
*/
65
66
void
67
Tcl_SetPanicProc(proc)
68
void (*proc) _ANSI_ARGS_(TCL_VARARGS(char *,format));
69
{
70
panicProc = proc;
71
}
72
73
/*
74
*----------------------------------------------------------------------
75
*
76
* panic --
77
*
78
* Print an error message and kill the process.
79
*
80
* Results:
81
* None.
82
*
83
* Side effects:
84
* The process dies, entering the debugger if possible.
85
*
86
*----------------------------------------------------------------------
87
*/
88
89
/* VARARGS ARGSUSED */
90
void
91
panic(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
92
char *format; /* Format string, suitable for passing to
93
* fprintf. */
94
char *arg1, *arg2, *arg3; /* Additional arguments (variable in number)
95
* to pass to fprintf. */
96
char *arg4, *arg5, *arg6, *arg7, *arg8;
97
{
98
if (panicProc != NULL) {
99
(void) (*panicProc)(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
100
} else {
101
(void) fprintf(stderr, format, arg1, arg2, arg3, arg4, arg5, arg6,
102
arg7, arg8);
103
(void) fprintf(stderr, "\n");
104
(void) fflush(stderr);
105
abort();
106
}
107
}
108
109