1 /* $NCDId: @(#)ErrHndlr.c,v 1.3 1996/02/09 21:15:53 greg Exp $ */
2 /* $XConsortium: XErrHndlr.c,v 11.16 91/11/09 15:39:57 keith Exp $ */
3 /* Copyright Massachusetts Institute of Technology 1986 */
4
5 /*
6 * Permission to use, copy, modify, distribute, and sell this software and
7 * its documentation for any purpose is hereby granted without fee, provided
8 * that the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of M.I.T. not be used in advertising or
11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. M.I.T. makes no representations about the
13 * suitability of this software for any purpose. It is provided "as is"
14 * without express or implied warranty.
15 */
16
17 #include "Alibint.h"
18
19 /*
20 * AuSetErrorHandler - This procedure sets the NAS non-fatal error handler
21 * (aud->funcs.error_handler) to be the specified routine. If NULL is passed
22 * in the original error handler is restored.
23 */
24
25 AuErrorHandler
AuSetErrorHandler(AuServer * aud,AuErrorHandler handler)26 AuSetErrorHandler(AuServer *aud, AuErrorHandler handler)
27 {
28 AuErrorHandler oldhandler = aud->funcs.error_handler;
29
30 if (!oldhandler)
31 oldhandler = _AuDefaultError;
32
33 aud->funcs.error_handler = handler ? handler : _AuDefaultError;
34 return oldhandler;
35 }
36
37 /*
38 * AuSetIOErrorHandler - This procedure sets the NAS fatal I/O error handler
39 * (aud->funcs.ioerror_handler) to be the specified routine. If NULL is
40 * passed in the original error handler is restored.
41 */
42
43 extern int _AuIOError();
44 AuIOErrorHandler
AuSetIOErrorHandler(AuServer * aud,AuIOErrorHandler handler)45 AuSetIOErrorHandler(AuServer *aud, AuIOErrorHandler handler)
46 {
47 AuIOErrorHandler oldhandler = aud->funcs.ioerror_handler;
48
49 if (!oldhandler)
50 oldhandler = (AuIOErrorHandler) _AuDefaultIOError;
51
52 aud->funcs.ioerror_handler = ((handler) ?
53 (AuIOErrorHandler) handler :
54 (AuIOErrorHandler) _AuDefaultIOError);
55
56 return oldhandler;
57 }
58