2 * Copyright 1987, 1988 by MIT Student Information Processing Board.
4 * For copyright info, see mit-sipb-copyright.h.
9 #include "mit-sipb-copyright.h"
11 #if defined(HAVE_STDARG_H) || defined(_WINDOWS)
18 #include "error_table.h"
23 * Protect us from header version (externally visible) of com_err, so
24 * we can survive in a <varargs.h> environment. I think.
26 #define com_err com_err_external
31 /* We have problems with varargs definitions if we include com_err.h */
34 * XXX for now, we define error_message by hand. Ultimately, we
35 * should fix up com_err.h so that it's safe to #include here
38 #if defined(__STDC__) || defined(_WINDOWS)
39 extern char const * INTERFACE error_message (long);
41 extern char * INTERFACE error_message ();
45 #if defined(__STDC__) || defined(_WINDOWS)
46 default_com_err_proc (const char *whoami, long code, const char *fmt, va_list args)
48 default_com_err_proc (whoami, code, fmt, args)
55 static char errbuf[1024]; /* For those w/o stdio */
59 strcat (errbuf, whoami);
60 strcat (errbuf, ": ");
63 strcat (errbuf, error_message(code));
67 vsprintf (errbuf + strlen (errbuf), fmt, args);
70 MessageBox (NULL, errbuf, "Kerboros", MB_ICONEXCLAMATION);
72 fputs (errbuf, stderr);
73 /* should do this only on a tty in raw mode */
80 #if defined(__STDC__) || defined(_WINDOWS)
81 typedef void (*errf) (const char *, long, const char *, va_list);
83 typedef void (*errf) ();
86 errf com_err_hook = default_com_err_proc;
88 void com_err_va (whoami, code, fmt, args)
94 (*com_err_hook) (whoami, code, fmt, args);
98 void INTERFACE_C com_err (const char *whoami,
100 const char *fmt, ...)
103 void INTERFACE_C com_err (va_alist)
106 const char *whoami, *fmt;
112 com_err_hook = default_com_err_proc;
115 whoami = va_arg (pvar, const char *);
116 code = va_arg (pvar, long);
117 fmt = va_arg (pvar, const char *);
121 com_err_va (whoami, code, fmt, pvar);
125 errf set_com_err_hook (new_proc)
128 errf x = com_err_hook;
131 com_err_hook = new_proc;
133 com_err_hook = default_com_err_proc;
138 errf reset_com_err_hook () {
139 errf x = com_err_hook;
140 com_err_hook = default_com_err_proc;