os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/generic/tclPanic.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/generic/tclPanic.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,137 @@
     1.4 +/* 
     1.5 + * tclPanic.c --
     1.6 + *
     1.7 + *	Source code for the "Tcl_Panic" library procedure for Tcl;
     1.8 + *	individual applications will probably call Tcl_SetPanicProc()
     1.9 + *	to set an application-specific panic procedure.
    1.10 + *
    1.11 + * Copyright (c) 1988-1993 The Regents of the University of California.
    1.12 + * Copyright (c) 1994 Sun Microsystems, Inc.
    1.13 + * Copyright (c) 1998-1999 by Scriptics Corporation.
    1.14 + * Portions Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiaries. All rights reserved.  
    1.15 + *
    1.16 + * See the file "license.terms" for information on usage and redistribution
    1.17 + * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    1.18 + *
    1.19 + * RCS: @(#) $Id: tclPanic.c,v 1.4.12.2 2006/03/09 23:11:23 dgp Exp $
    1.20 + */
    1.21 +
    1.22 +#include "tclInt.h"
    1.23 +#include "tclPort.h"
    1.24 +
    1.25 +/*
    1.26 + * The panicProc variable contains a pointer to an application
    1.27 + * specific panic procedure.
    1.28 + */
    1.29 +
    1.30 +static Tcl_PanicProc *panicProc = NULL;
    1.31 +
    1.32 +/*
    1.33 + * The platformPanicProc variable contains a pointer to a platform
    1.34 + * specific panic procedure, if any.  ( TclpPanic may be NULL via
    1.35 + * a macro. )
    1.36 + */
    1.37 +
    1.38 +static Tcl_PanicProc * CONST platformPanicProc = TclpPanic;
    1.39 +
    1.40 +
    1.41 +/*
    1.42 + *----------------------------------------------------------------------
    1.43 + *
    1.44 + * Tcl_SetPanicProc --
    1.45 + *
    1.46 + *	Replace the default panic behavior with the specified functiion.
    1.47 + *
    1.48 + * Results:
    1.49 + *	None.
    1.50 + *
    1.51 + * Side effects:
    1.52 + *	Sets the panicProc variable.
    1.53 + *
    1.54 + *----------------------------------------------------------------------
    1.55 + */
    1.56 +
    1.57 +EXPORT_C void
    1.58 +Tcl_SetPanicProc(proc)
    1.59 +    Tcl_PanicProc *proc;
    1.60 +{
    1.61 +    panicProc = proc;
    1.62 +}
    1.63 +
    1.64 +/*
    1.65 + *----------------------------------------------------------------------
    1.66 + *
    1.67 + * Tcl_PanicVA --
    1.68 + *
    1.69 + *	Print an error message and kill the process.
    1.70 + *
    1.71 + * Results:
    1.72 + *	None.
    1.73 + *
    1.74 + * Side effects:
    1.75 + *	The process dies, entering the debugger if possible.
    1.76 + *
    1.77 + *----------------------------------------------------------------------
    1.78 + */
    1.79 +
    1.80 +EXPORT_C void
    1.81 +Tcl_PanicVA (format, argList)
    1.82 +    CONST char *format;		/* Format string, suitable for passing to
    1.83 +				 * fprintf. */
    1.84 +    va_list argList;		/* Variable argument list. */
    1.85 +{
    1.86 +    char *arg1, *arg2, *arg3, *arg4;	/* Additional arguments (variable in
    1.87 +					 * number) to pass to fprintf. */
    1.88 +    char *arg5, *arg6, *arg7, *arg8;
    1.89 +
    1.90 +    arg1 = va_arg(argList, char *);
    1.91 +    arg2 = va_arg(argList, char *);
    1.92 +    arg3 = va_arg(argList, char *);
    1.93 +    arg4 = va_arg(argList, char *);
    1.94 +    arg5 = va_arg(argList, char *);
    1.95 +    arg6 = va_arg(argList, char *);
    1.96 +    arg7 = va_arg(argList, char *);
    1.97 +    arg8 = va_arg(argList, char *);
    1.98 +    
    1.99 +    if (panicProc != NULL) {
   1.100 +	(void) (*panicProc)(format, arg1, arg2, arg3, arg4,
   1.101 +		arg5, arg6, arg7, arg8);
   1.102 +    } else if (platformPanicProc != NULL) {
   1.103 +	(void) (*platformPanicProc)(format, arg1, arg2, arg3, arg4,
   1.104 +		arg5, arg6, arg7, arg8);
   1.105 +    } else {
   1.106 +	(void) fprintf(stderr, format, arg1, arg2, arg3, arg4, arg5, arg6,
   1.107 +		arg7, arg8);
   1.108 +	(void) fprintf(stderr, "\n");
   1.109 +	(void) fflush(stderr);
   1.110 +	abort();
   1.111 +    }
   1.112 +}
   1.113 +
   1.114 +/*
   1.115 + *----------------------------------------------------------------------
   1.116 + *
   1.117 + * Tcl_Panic --
   1.118 + *
   1.119 + *	Print an error message and kill the process.
   1.120 + *
   1.121 + * Results:
   1.122 + *	None.
   1.123 + *
   1.124 + * Side effects:
   1.125 + *	The process dies, entering the debugger if possible.
   1.126 + *
   1.127 + *----------------------------------------------------------------------
   1.128 + */
   1.129 +
   1.130 +	/* VARARGS ARGSUSED */
   1.131 +EXPORT_C void
   1.132 +Tcl_Panic TCL_VARARGS_DEF(CONST char *,arg1)
   1.133 +{
   1.134 +    va_list argList;
   1.135 +    CONST char *format;
   1.136 +
   1.137 +    format = TCL_VARARGS_START(CONST char *,arg1,argList);
   1.138 +    Tcl_PanicVA(format, argList);
   1.139 +    va_end (argList);
   1.140 +}