From: Keith Vetter Date: Fri, 17 Mar 1995 00:30:47 +0000 (+0000) Subject: Ported the error table stuff to the PC X-Git-Tag: krb5-1.0-beta5~553 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=762daf3bb80d67302642ce6c8406fcc62f75fab6;p=krb5.git Ported the error table stuff to the PC git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5135 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/util/et/ChangeLog b/src/util/et/ChangeLog index cfd8d5897..7b487c4f2 100644 --- a/src/util/et/ChangeLog +++ b/src/util/et/ChangeLog @@ -1,3 +1,16 @@ +Wed Mar 15 23:02:14 1995 Keith Vetter (keithv@fusion.com) + + * com_err.c: made to work on the PC. Biggest changes was that + the error message now gets built in a buffer and either gets + printed to stderr or for Windows gets displays in a message box. + * err_message.c: fixed up includes and some 32/16 bit ints. + * et_name.c: changed two ints into longs. + * com_err.h: added windows keyword INTERFACE to prototypes. + * error_table.h: Added some windows specific defines since this + source doesn't really know about k5-config.h. Also, added + prototype for error_table_name(). + * Makefile.in: PC rules to make com_err, err_message and et_name. + Tue Feb 28 13:23:58 1995 Theodore Y. Ts'o * error_table.h: Remove #ifdef STDC check to see if we should use diff --git a/src/util/et/Makefile.in b/src/util/et/Makefile.in index 99ff5902c..57247c8a3 100644 --- a/src/util/et/Makefile.in +++ b/src/util/et/Makefile.in @@ -2,9 +2,11 @@ CFLAGS = $(CCOPTS) $(DEFS) $(LOCALINCLUDE) LDFLAGS = -g SED = sed -INSTALLFILE = cp +##DOSBUILDTOP = ..\.. +##DOSLIBNAME=comerr.lib +##DOS!include $(BUILDTOP)\config\windows.in -all:: +INSTALLFILE = cp LINTFLAGS=-uhvb LINTFILES= error_message.c et_name.c init_et.c com_err.c @@ -24,6 +26,10 @@ CFILES= compile_et.c error_table.c error_message.c et_name.c \ SRCS=$(CFILES) +all:: all-$(WHAT) + +all-windows: com_err.obj error_message.obj et_name.obj + # # what to build... # @@ -39,7 +45,7 @@ com_err.o: com_err.c # real entries... # -all:: compile_et includes +all-unix:: compile_et includes # The real compile_et just isn't portable. (But then again, anything using # lex and yacc isn't portable by definition. :-( ) @@ -48,7 +54,7 @@ all:: compile_et includes # $(CC) $(CFLAGS) -o $@ compile_et.o error_table.o $(LEXLIB) $(BSDLIB) # #install:: -# $(INSTALLPROG) compile_et ${DESTDIR}$(PROGDIR)/compile_et +# $(INSTALLPROG) compile_et $(DESTDIR)$(PROGDIR)/compile_et compile_et: $(srcdir)/compile_et.sh $(srcdir)/config_script $(srcdir)/config_script $(srcdir)/compile_et.sh $(AWK) $(SED) > compile_et @@ -59,8 +65,10 @@ et_c.awk: $(srcdir)/et_c.awk et_h.awk: $(srcdir)/et_h.awk $(CP) $(srcdir)/et_h.awk et_h.awk + +clean:: clean-$(WHAT) -clean:: +clean-unix:: $(RM) compile_et compile_et.o error_table.o depend:: @@ -72,20 +80,20 @@ install:: mit-sipb-copyright.h $(INSTALLFILE) $(srcdir)/mit-sipb-copyright.h $(DESTDIR)$(INCLDIR)/mit-sipb-copyright.h install:: com_err.3 - $(INSTALLFILE) $(srcdir)/com_err.3 ${DESTDIR}${MANDIR}/man3/com_err.3 + $(INSTALLFILE) $(srcdir)/com_err.3 $(DESTDIR)$(MANDIR)/man3/com_err.3 install:: compile_et.1 - $(INSTALLFILE) $(srcdir)/compile_et.1 ${DESTDIR}${MANDIR}/man1/compile_et.1 + $(INSTALLFILE) $(srcdir)/compile_et.1 $(DESTDIR)$(MANDIR)/man1/compile_et.1 ## install_library_target(com_err,$(LIBOBJS),$(LINTFILES),) -all:: libcom_err.a +all-unix:: libcom_err.a libcom_err.a: $(LIBOBJS) $(ARCHIVE) $@ $(LIBOBJS) $(RANLIB) $@ -clean:: +clean-unix:: $(RM) libcom_err.a $(RM) $(LIBOBJS) @@ -96,7 +104,7 @@ install:: $(CHMOD) 444 $(DESTDIR)$(LIBDIR)/libcom_err.a ## -clean:: +clean-unix:: rm -f *~ \#* *.bak \ *.otl *.aux *.toc *.PS *.dvi *.x9700 *.ps \ *.cp *.fn *.ky *.log *.pg *.tp *.vr \ @@ -107,7 +115,8 @@ clean:: test1.h test1.c test2.h test2.c test_et \ eddep makedep *.ln - +clean-windows:: + $(RM) comerr.lib comerr.bak com_err.ps : com_err.dvi com_err.dvi: com_err.texinfo diff --git a/src/util/et/com_err.c b/src/util/et/com_err.c index 8860446f1..01c7cc5f1 100644 --- a/src/util/et/com_err.c +++ b/src/util/et/com_err.c @@ -5,9 +5,10 @@ */ #include +#include #include "mit-sipb-copyright.h" -#ifdef STDARG_PROTOTYPES +#if defined(__STDC__) || defined(STDARG_PROTOTYPES) #include #else #include @@ -51,21 +52,26 @@ static void va_list args; #endif { + static char errbuf[1024]; /* For those w/o stdio */ + + *errbuf = '\0'; if (whoami) { - fputs(whoami, stderr); - fputs(": ", stderr); + strcat (errbuf, whoami); + strcat (errbuf, ": "); } if (code) { - fputs(error_message(code), stderr); - fputs(" ", stderr); + strcat (errbuf, error_message(code)); + strcat (errbuf, " "); } if (fmt) { - vfprintf (stderr, fmt, args); + vsprintf (errbuf + strlen (errbuf), fmt, args); } - /* should do this only on a tty in raw mode */ - putc('\r', stderr); - putc('\n', stderr); +#ifdef _WINDOWS + MessageBox (NULL, errbuf, "Kerboros", MB_ICONEXCLAMATION); +#else + fputs (errbuf, stderr); fflush(stderr); +#endif } #ifdef __STDC__ @@ -86,12 +92,12 @@ void com_err_va (whoami, code, fmt, args) } #ifndef VARARGS -void com_err (const char *whoami, +void INTERFACE_C com_err (const char *whoami, long code, const char *fmt, ...) { #else -void com_err (va_alist) +void INTERFACE_C com_err (va_alist) va_dcl { const char *whoami, *fmt; diff --git a/src/util/et/com_err.h b/src/util/et/com_err.h index 98a540084..f61822aed 100644 --- a/src/util/et/com_err.h +++ b/src/util/et/com_err.h @@ -25,16 +25,16 @@ #ifdef __STDC__ /* ANSI C -- use prototypes etc */ -extern void com_err (const char *, long, const char *, ...); -extern char const *error_message (long); +extern void INTERFACE_C com_err (const char *, long, const char *, ...); +extern char const * INTERFACE error_message (long); extern void (*com_err_hook) (const char *, long, const char *, va_list); extern void (*set_com_err_hook (void (*) (const char *, long, const char *, va_list))) (const char *, long, const char *, va_list); extern void (*reset_com_err_hook ()) (const char *, long, const char *, va_list); #else /* no prototypes */ -extern void com_err (); -extern char *error_message (); +extern void INTERFACE_C com_err (); +extern char * INTERFACE error_message (); extern void (*com_err_hook) (); extern void (*set_com_err_hook ()) (); extern void (*reset_com_err_hook ()) (); diff --git a/src/util/et/error_message.c b/src/util/et/error_message.c index 507e0f173..990d29238 100644 --- a/src/util/et/error_message.c +++ b/src/util/et/error_message.c @@ -8,6 +8,8 @@ */ #include +#include +#include #include "error_table.h" #include "mit-sipb-copyright.h" #include "internal.h" @@ -19,19 +21,21 @@ static char buffer[25]; struct et_list * _et_list = (struct et_list *) NULL; -const char * error_message (code) -long code; +const char * INTERFACE error_message (code) +long code; { int offset; + long l_offset; struct et_list *et; - int table_num; + long table_num; int started = 0; char *cp; - offset = code & ((1<