home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / extensions / lib / PEX / include / err.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-15  |  2.9 KB  |  95 lines

  1. /* $XConsortium: err.h,v 5.1 91/02/16 09:49:04 rws Exp $ */
  2.  
  3. /***********************************************************
  4. Copyright 1989, 1990, 1991 by Sun Microsystems, Inc. and the X Consortium.
  5.  
  6.                         All Rights Reserved
  7.  
  8. Permission to use, copy, modify, and distribute this software and its 
  9. documentation for any purpose and without fee is hereby granted, 
  10. provided that the above copyright notice appear in all copies and that
  11. both that copyright notice and this permission notice appear in 
  12. supporting documentation, and that the names of Sun Microsystems,
  13. the X Consortium, and MIT not be used in advertising or publicity 
  14. pertaining to distribution of the software without specific, written 
  15. prior permission.  
  16.  
  17. SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
  18. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT 
  19. SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
  20. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  22. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  23. SOFTWARE.
  24. ******************************************************************/
  25.  
  26. #ifndef PHG_ERR_H_INCLUDED
  27. #define PHG_ERR_H_INCLUDED
  28.  
  29. #define ERR_SET_CUR_FUNC( erh, funcnum) \
  30.     ((erh)->cur_func_num = (funcnum))
  31.  
  32. #define ERR_BUF( erh, errnum) \
  33.     if ( (erh)->mode == PERR_ON) (*(erh)->buf_func)((erh), (errnum))
  34.  
  35. #define ERR_FLUSH( erh) \
  36.     if ( (erh)->flush_func) (*(erh)->flush_func)( erh)
  37.  
  38. /* ERR_HANDLE calls the global error handler function */
  39. #define ERR_HANDLE( errnum, funcnum, erf) \
  40.     (*phg_errhandle)((errnum), (funcnum), (erf))
  41.  
  42. /*** ERR_REPORT called by binding only ***/
  43. #define ERR_REPORT( erh, errnum) \
  44.     if ( (erh)->mode == PERR_ON && (erh)->report_func) \
  45.     (*(erh)->report_func)((erh), (errnum))
  46.  
  47. /*** ERR_DESTROY called by error code only ***/
  48. #define ERR_DESTROY( erh) \
  49.     if ( (erh)->destroy_func) (*(erh)->destroy_func)(erh)
  50.  
  51. typedef struct {
  52.     Pint    errnum;
  53.     Pint    funcnum;
  54. } Err_msg;
  55.  
  56. typedef struct {
  57.     char    *fname;    /* error file name */
  58. } Err_local_data;
  59.  
  60. typedef struct {
  61.     int        sfd;    /* socket fd for errors from server */
  62.     char    *fname;    /* error file name */
  63. } Err_client_data;
  64.  
  65. typedef struct {
  66.     int        sfd;        /* fd to write to client */
  67. } Err_remote_data;
  68.  
  69. typedef struct {
  70.     Perr_mode    mode;
  71.     Perr_mode    err_state;    /* NOT maintained in server */
  72.     int        cur_func_num;
  73.     int        errno;
  74.     void    (*buf_func)();
  75.     void    (*flush_func)();
  76.     void    (*report_func)();
  77.     void    (*destroy_func)();
  78.     union {
  79.     Err_local_data        local;
  80.     Err_client_data        client;
  81.     Err_remote_data        remote;
  82.     }        data;
  83. } Err_struct;
  84.  
  85. typedef Err_struct    *Err_handle;
  86.  
  87. extern Err_handle    phg_err_init_local();
  88. extern Err_handle    phg_err_init_client();
  89. extern Err_handle    phg_err_init_remote();
  90.  
  91. /* declare the global error handler function pointer. */
  92. extern void        (*phg_errhandle)();
  93.  
  94. #endif
  95.