2 * Copyright 1987, 1988 by MIT Student Information Processing Board.
4 * Permission to use, copy, modify, and distribute this software and
5 * its documentation for any purpose is hereby granted, provided that
6 * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in
7 * advertising or publicity pertaining to distribution of the software
8 * without specific, written prior permission. M.I.T. and the
9 * M.I.T. S.I.P.B. make no representations about the suitability of
10 * this software for any purpose. It is provided "as is" without
11 * express or implied warranty.
16 #include "error_table.h"
19 #if !defined(__STDC__) && !defined(STDARG_PROTOTYPES)
26 default_com_err_proc (const char *whoami, errcode_t code, const
27 char *fmt, va_list args)
29 default_com_err_proc (whoami, code, fmt, args)
37 fputs(whoami, stderr);
41 fputs(error_message(code), stderr);
45 vfprintf (stderr, fmt, args);
47 /* should do this only on a tty in raw mode */
54 typedef void (*errf) (const char *, errcode_t, const char *, va_list);
56 typedef void (*errf) ();
59 errf com_err_hook = default_com_err_proc;
62 void com_err_va (const char *whoami, errcode_t code, const char *fmt,
65 void com_err_va (whoami, code, fmt, args)
72 (*com_err_hook) (whoami, code, fmt, args);
76 void com_err (const char *whoami,
81 void com_err (va_alist)
84 const char *whoami, *fmt;
90 com_err_hook = default_com_err_proc;
93 whoami = va_arg (pvar, const char *);
94 code = va_arg (pvar, errcode_t);
95 fmt = va_arg (pvar, const char *);
99 com_err_va (whoami, code, fmt, pvar);
103 errf set_com_err_hook (new_proc)
106 errf x = com_err_hook;
109 com_err_hook = new_proc;
111 com_err_hook = default_com_err_proc;
116 errf reset_com_err_hook () {
117 errf x = com_err_hook;
118 com_err_hook = default_com_err_proc;