home *** CD-ROM | disk | FTP | other *** search
/ Internet Publisher's Toolbox 2.0 / Internet Publisher's Toolbox.iso / internet / ntserver / wtsource / panic.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-16  |  2.4 KB  |  119 lines

  1. /* WIDE AREA INFORMATION SERVER SOFTWARE:
  2.    No guarantees or restrictions.  See the readme file for the full standard
  3.    disclaimer.
  4.  
  5.    Morris@think.com
  6. */
  7.  
  8. /* Copyright (c) CNIDR (see ../COPYRIGHT) */
  9.  
  10.  
  11. /* Change log:
  12.  * $Log: panic.c,v $
  13.  * Revision 1.1  1993/02/16  15:05:35  freewais
  14.  * Initial revision
  15.  *
  16.  * Revision 1.10  92/03/07  19:42:30  jonathan
  17.  * ANSIfied arguments.
  18.  * 
  19.  * Revision 1.9  92/02/20  13:58:10  jonathan
  20.  * Removed redundant include of varargs.h.  Removed fprintf for BSD, since
  21.  * we've not got a vprintf.
  22.  * 
  23.  * Revision 1.8  92/02/12  13:38:05  jonathan
  24.  * Added "$Log" so RCS will put the log message in the header
  25.  * 
  26. */
  27.  
  28. /* panic is an error system interface.  On the Mac, it will pop
  29.  * up a little window to explain the problem.
  30.  * On a unix box, it will print out the error and call perror()
  31.  */
  32.  
  33. #include "panic.h"
  34. #include "futil.h"
  35.  
  36. #include <ctype.h>
  37.  
  38. #ifndef EXIT_FAILURE  /* should be in stdlib */
  39. #define EXIT_FAILURE (-1)
  40. #endif /* ndef EXIT_FAILURE */
  41.  
  42. /*----------------------------------------------------------------------*/
  43.  
  44. static void exitAction _AP((long error));
  45.  
  46. static void
  47. exitAction(error)
  48. long error;
  49. {
  50.   long i;
  51. #ifdef THINK_C
  52.   Debugger();
  53. #else
  54.   for (i = 0; i < 100000; i++)
  55.     ;
  56. #endif
  57. #if 0
  58.     abort();
  59. #else
  60.   exit(-1);
  61. #endif
  62. }
  63.  
  64. /*----------------------------------------------------------------------*/
  65.  
  66. #define PANIC_HEADER "Fatal Error:  "
  67. #define BELL "\007"
  68.  
  69. #ifdef THINK_C /* pop up a dialog box */
  70. #include "CDynamicError.h"
  71. #endif
  72.  
  73. extern char* log_file_name;
  74. extern FILE* logfile;
  75.  
  76. void
  77. #ifdef ANSI_LIKE
  78.   panic(char* format, ...)
  79. #else
  80. panic(va_alist)
  81. va_dcl
  82. #endif
  83.   {
  84.     va_list ap;            /* the variable arguments */
  85. #ifndef ANSI_LIKE
  86.   char *format;
  87.  
  88.   va_start(ap);
  89.   format = va_arg(ap, char *);
  90. #else
  91.   va_start(ap, format);
  92. #endif
  93.  
  94. #ifdef THINK_C            /* pop up a dialog box */
  95.  
  96.   char buffer[1000];        /* hope this is enough space! */
  97.   long i;
  98.   strncpy(buffer,PANIC_HEADER,1000);
  99.   SysBeep(5);
  100.   vsprintf(buffer + strlen(PANIC_HEADER),format,ap);
  101.   for (i = 0L; buffer[i] != '\0'; i++)
  102.     { if (buffer[i] == '\n' || buffer[i] == '\r')
  103.     buffer[i] = ' ';
  104.       }
  105.   gError->PostAlertMessage(buffer);
  106.  
  107. #else
  108.   
  109.   vwaislog(1, -1, format, ap);
  110.   va_end(ap);
  111.  
  112. #endif
  113.  
  114.   exitAction(0);
  115. }
  116.   
  117.  
  118. /*----------------------------------------------------------------------*/
  119.