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.
23 #include "error_table.h"
27 default_com_err_proc (const char *whoami, errcode_t code, const
28 char *fmt, va_list args)
29 COM_ERR_ATTR((format(printf, 3, 0)));
32 default_com_err_proc (const char *whoami, errcode_t code, const
33 char *fmt, va_list args)
35 int do_cr = 1, fd = fileno(stderr);
38 fputs(whoami, stderr);
42 fputs(error_message(code), stderr);
46 vfprintf (stderr, fmt, args);
54 if ((tcgetattr(fd, &t)) == 0 &&
55 (t.c_oflag & OPOST) && (t.c_oflag & ONLCR))
65 typedef void (*errf) (const char *, errcode_t, const char *, va_list)
66 COM_ERR_ATTR((format(printf, 3, 0)));
68 errf com_err_hook = default_com_err_proc;
70 void com_err_va (const char *whoami, errcode_t code, const char *fmt,
73 (*com_err_hook) (whoami, code, fmt, args);
76 void com_err (const char *whoami,
83 com_err_hook = default_com_err_proc;
85 com_err_va (whoami, code, fmt, pvar);
89 errf set_com_err_hook(errf new_proc)
91 errf x = com_err_hook;
94 com_err_hook = new_proc;
96 com_err_hook = default_com_err_proc;
101 errf reset_com_err_hook(void) {
102 errf x = com_err_hook;
103 com_err_hook = default_com_err_proc;