+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
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
SRCS=$(CFILES)
+all:: all-$(WHAT)
+
+all-windows: com_err.obj error_message.obj et_name.obj
+
#
# what to build...
#
# 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. :-( )
# $(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
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::
$(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)
$(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 \
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
*/
#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>
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__
}
#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;
#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 ()) ();
*/
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include "error_table.h"
#include "mit-sipb-copyright.h"
#include "internal.h"
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;
*/
#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;
#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
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;