summaryrefslogtreecommitdiffstats
path: root/src/util/et
diff options
context:
space:
mode:
authorKeith Vetter <keithv@fusion.com>1995-03-17 00:30:47 +0000
committerKeith Vetter <keithv@fusion.com>1995-03-17 00:30:47 +0000
commit762daf3bb80d67302642ce6c8406fcc62f75fab6 (patch)
tree56c8f538f096ea6a2bde88f0b10b80361aeda2c8 /src/util/et
parentbea9cfe5ab7e4dd4560474ef70818bce5f276ac8 (diff)
downloadkrb5-762daf3bb80d67302642ce6c8406fcc62f75fab6.tar.gz
krb5-762daf3bb80d67302642ce6c8406fcc62f75fab6.tar.xz
krb5-762daf3bb80d67302642ce6c8406fcc62f75fab6.zip
Ported the error table stuff to the PC
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5135 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util/et')
-rw-r--r--src/util/et/ChangeLog13
-rw-r--r--src/util/et/Makefile.in31
-rw-r--r--src/util/et/com_err.c28
-rw-r--r--src/util/et/com_err.h8
-rw-r--r--src/util/et/error_message.c16
-rw-r--r--src/util/et/error_table.h25
-rw-r--r--src/util/et/et_name.c6
7 files changed, 91 insertions, 36 deletions
diff --git a/src/util/et/ChangeLog b/src/util/et/ChangeLog
index cfd8d58975..7b487c4f27 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 <tytso@dcl>
* 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 99ff5902c8..57247c8a3d 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 8860446f17..01c7cc5f15 100644
--- a/src/util/et/com_err.c
+++ b/src/util/et/com_err.c
@@ -5,9 +5,10 @@
*/
#include <stdio.h>
+#include <string.h>
#include "mit-sipb-copyright.h"
-#ifdef STDARG_PROTOTYPES
+#if defined(__STDC__) || defined(STDARG_PROTOTYPES)
#include <stdarg.h>
#else
#include <varargs.h>
@@ -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 98a540084b..f61822aed7 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 507e0f1730..990d292380 100644
--- a/src/util/et/error_message.c
+++ b/src/util/et/error_message.c
@@ -8,6 +8,8 @@
*/
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#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<<ERRCODE_RANGE)-1);
- table_num = code - offset;
+ l_offset = code & ((1<<ERRCODE_RANGE)-1);
+ offset = (int) l_offset;
+ table_num = code - l_offset;
if (!table_num) {
- if (offset < sys_nerr)
+ if (offset < sys_nerr)
return(sys_errlist[offset]);
else
goto oops;
diff --git a/src/util/et/error_table.h b/src/util/et/error_table.h
index 571ffba5e7..f1d493fdae 100644
--- a/src/util/et/error_table.h
+++ b/src/util/et/error_table.h
@@ -6,7 +6,25 @@
*/
#ifndef _ET_H
+
+/* This directory doesn't really know about the krb5 world. The following
+ windows defines are usually hidden in k5-config.h. For now I'll just
+ place here what is needed from that file. Later we may decide to do
+ it differently.
+*/
+#ifdef _WINDOWS
+#define INTERFACE __far __export __pascal
+#define INTERFACE_C __far __export __cdecl
+#define sys_nerr _sys_nerr
+#define sys_errlist _sys_errlist
+int __far __pascal MessageBox (void __far *, const char __far*, const char __far*, unsigned int);
+#define MB_ICONEXCLAMATION 0x0030
+#else
+#define INTERFACE
+#define INTERFACE_C
extern int errno;
+#endif
+
struct error_table {
char const * const * msgs;
long base;
@@ -21,6 +39,11 @@ extern struct et_list * _et_list;
#define ERRCODE_RANGE 8 /* # of bits to shift table number */
#define BITS_PER_CHAR 6 /* # bits to shift per character in name */
-extern const char *error_table_name();
+#if defined(__STDC__) || defined(KRB5_PROVIDE_PROTOTYPES)
+extern const char *error_table_name (long);
+#else
+extern const char *error_table_name ();
+#endif
+
#define _ET_H
#endif
diff --git a/src/util/et/et_name.c b/src/util/et/et_name.c
index 044302b8dd..a462676435 100644
--- a/src/util/et/et_name.c
+++ b/src/util/et/et_name.c
@@ -18,10 +18,10 @@ static const char char_set[] =
static char buf[6];
-const char * error_table_name(num)
- int num;
+const char * error_table_name (num)
+ long num;
{
- int ch;
+ long ch;
int i;
char *p;