home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / lib / H / utils / exc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  2.7 KB  |  139 lines

  1. /*
  2.  * exc.h --
  3.  *    POSTGRES exception handling definitions.
  4.  */
  5.  
  6. #ifndef    ExcIncluded        /* Include this file only once */
  7. #define ExcIncluded    1
  8.  
  9. /*
  10.  * Identification:
  11.  */
  12. #define EXC_H    "$Header: /private/postgres/src/lib/H/utils/RCS/exc.h,v 1.8 1991/11/11 19:32:17 mer Exp $"
  13.  
  14. #include <setjmp.h>
  15.  
  16. #include "tmp/c.h"
  17.  
  18. /*
  19.  * EnableExceptionHandling --
  20.  *    Enables/disables the exception handling system.
  21.  *
  22.  * Note:
  23.  *    This must be called before any exceptions occur.  I.e., call this first!
  24.  *    This routine will not return if an error is detected.
  25.  *    This does not follow the usual Enable... protocol.
  26.  *    This should be merged more closely with the error logging and tracing
  27.  *    packages.
  28.  *
  29.  * Exceptions:
  30.  *    none
  31.  */
  32. extern
  33. void
  34. EnableExceptionHandling ARGS((
  35.     bool    on
  36. ));
  37.  
  38. /* START HERE */
  39.  
  40. /*
  41.  * ExcMessage and Exception are now defined in c.h
  42.  */
  43. #if    0
  44. typedef char*        ExcMessage;
  45.  
  46. typedef struct Exception {
  47.     ExcMessage    message;
  48. } Exception;
  49. #endif    /* 0 */
  50.  
  51. typedef jmp_buf        ExcContext;
  52. typedef Exception*    ExcId;
  53. typedef long        ExcDetail;
  54. typedef char*        ExcData;
  55.  
  56. typedef struct ExcFrame {
  57.     struct ExcFrame    *link;
  58.     ExcContext    context;
  59.     ExcId        id;
  60.     ExcDetail    detail;
  61.     ExcData        data;
  62.     ExcMessage    message;
  63. } ExcFrame;
  64.  
  65. extern    ExcFrame*    ExcCurFrameP;
  66.  
  67. #define    ExcBegin()                            \
  68.     {                                \
  69.         ExcFrame    exception;                \
  70.                                     \
  71.         exception.link = ExcCurFrameP;                 \
  72.         if (setjmp(exception.context) == 0) {            \
  73.             ExcCurFrameP = &exception;            \
  74.             {
  75. #define    ExcExcept()                            \
  76.             }                        \
  77.             ExcCurFrameP = exception.link;            \
  78.         } else {                        \
  79.             {
  80. #define    ExcEnd()                            \
  81.             }                        \
  82.         }                            \
  83.     }
  84.  
  85. #define raise(exception)    raise2((exception), 0)
  86. #define raise2(x, detail)    raise3((x), (detail), 0)
  87. #define raise3(x, t, data)    raise4((x), (t), (data), 0)
  88.  
  89. #define raise4(x, t, d, message) \
  90.     ExcRaise(&(x), (ExcDetail)(t), (ExcData)(d), (ExcMessage)(message))
  91.  
  92. #define    reraise() \
  93.     raise4(*exception.id,exception.detail,exception.data,exception.message)
  94.  
  95. typedef    void    ExcProc(/* Exception*, ExcDetail, ExcData, ExcMessage */);
  96.  
  97. void ExcRaise ARGS((
  98.     Exception *excP,
  99.     ExcDetail detail,
  100.     ExcData data,
  101.     ExcMessage message
  102. ));
  103.  
  104. ExcProc *ExcGetUnCaught ARGS((void ));
  105. ExcProc *ExcSetUnCaught ARGS((ExcProc *newP ));
  106.  
  107. void ExcUnCaught ARGS((
  108.     Exception *excP,
  109.     ExcDetail detail,
  110.     ExcData data,
  111.     ExcMessage message
  112. ));
  113.  
  114. void ExcPrint ARGS((
  115.     Exception *excP,
  116.     ExcDetail detail,
  117.     ExcData data,
  118.     ExcMessage message
  119. ));
  120. extern    char*    ProgramName;
  121.  
  122. /*
  123.  * ExcAbort --
  124.  *    Handler for uncaught exception.
  125.  *
  126.  * Note:
  127.  *    Define this yourself if you don't want the default action (dump core).
  128.  */
  129. extern
  130. void
  131. ExcAbort ARGS((
  132.     Exception    *excP,
  133.     ExcDetail    detail,
  134.     ExcData        data,
  135.     ExcMessage    message
  136. ));
  137.  
  138. #endif    /* !defined(ExcIncluded) */
  139.