home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / evbl0627.zip / everblue_20010627.zip / x11 / Xlib_ErrHndlr.c < prev    next >
C/C++ Source or Header  |  1999-11-02  |  3KB  |  99 lines

  1. /* $XConsortium: ErrHndlr.c,v 11.21 94/04/17 20:19:15 kaleb Exp $ */
  2. /*
  3.  
  4. Copyright (c) 1986  X Consortium
  5.  
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12.  
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15.  
  16. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
  19. X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  20. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22.  
  23. Except as contained in this notice, the name of the X Consortium shall not be
  24. used in advertising or otherwise to promote the sale, use or other dealings
  25. in this Software without prior written authorization from the X Consortium.
  26.  
  27. */
  28.  
  29. #include "Xlib_private.h"
  30.  
  31. extern int _XDefaultError();
  32. extern int _XDefaultIOError();
  33. /* 
  34.  * XErrorHandler - This procedure sets the X non-fatal error handler
  35.  * (_XErrorFunction) to be the specified routine.  If NULL is passed in
  36.  * the original error handler is restored.
  37.  */
  38.  
  39. #if NeedFunctionPrototypes
  40. XErrorHandler XSetErrorHandler(XErrorHandler handler)
  41. #else
  42. XErrorHandler XSetErrorHandler(handler)
  43.     register XErrorHandler handler;
  44. #endif
  45. {
  46.     DBUG_ENTER("XSetErrorHandler")
  47.     int (*oldhandler)();
  48.  
  49.     _XLockMutex(_Xglobal_lock);
  50.     oldhandler = _XErrorFunction;
  51.  
  52.     if (!oldhandler)
  53.     oldhandler = _XDefaultError;
  54.  
  55.     if (handler != NULL) {
  56.     _XErrorFunction = handler;
  57.     }
  58.     else {
  59.     _XErrorFunction = _XDefaultError;
  60.     }
  61.     _XUnlockMutex(_Xglobal_lock);
  62.  
  63.     DBUG_RETURN((XErrorHandler) oldhandler);
  64. }
  65.  
  66. /* 
  67.  * XIOErrorHandler - This procedure sets the X fatal I/O error handler
  68.  * (_XIOErrorFunction) to be the specified routine.  If NULL is passed in 
  69.  * the original error handler is restored.
  70.  */
  71.  
  72. extern int _XIOError();
  73. #if NeedFunctionPrototypes
  74. XIOErrorHandler XSetIOErrorHandler(XIOErrorHandler handler)
  75. #else
  76. XIOErrorHandler XSetIOErrorHandler(handler)
  77.     register XIOErrorHandler handler;
  78. #endif
  79. {
  80.     DBUG_ENTER("_XIOError")
  81.     int (*oldhandler)();
  82.  
  83.     _XLockMutex(_Xglobal_lock);
  84.     oldhandler = _XIOErrorFunction;
  85.  
  86.     if (!oldhandler)
  87.     oldhandler = _XDefaultIOError;
  88.  
  89.     if (handler != NULL) {
  90.     _XIOErrorFunction = handler;
  91.     }
  92.     else {
  93.     _XIOErrorFunction = _XDefaultIOError;
  94.     }
  95.     _XUnlockMutex(_Xglobal_lock);
  96.  
  97.     DBUG_RETURN((XIOErrorHandler) oldhandler);
  98. }
  99.