summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard Basch <probe@mit.edu>1997-02-15 21:25:33 +0000
committerRichard Basch <probe@mit.edu>1997-02-15 21:25:33 +0000
commite68a1b78c1e7f3aabf13efed131eab9d90fb65b1 (patch)
tree90f39c60935805783fc7f8c838625c86a99598db /src
parentd2a9147da28671f50c3cfc5e90f80a51e3e853db (diff)
downloadkrb5-e68a1b78c1e7f3aabf13efed131eab9d90fb65b1.tar.gz
krb5-e68a1b78c1e7f3aabf13efed131eab9d90fb65b1.tar.xz
krb5-e68a1b78c1e7f3aabf13efed131eab9d90fb65b1.zip
Removed V2 experimental API previously checked-in.
Added new routines: add_error_table & remove_error_table for registering error tables. Except on Unix, the _et_list variable and com_err_hook routines/variables are now private to the comerr library. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9866 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src')
-rw-r--r--src/util/et/ChangeLog8
-rw-r--r--src/util/et/Makefile.in28
-rw-r--r--src/util/et/com_err.c158
-rw-r--r--src/util/et/com_err.h68
-rw-r--r--src/util/et/error_message.c141
-rw-r--r--src/util/et/error_table.h15
-rw-r--r--src/util/et/et_c.awk34
-rw-r--r--src/util/et/et_h.awk1
-rw-r--r--src/util/et/init_et.c2
9 files changed, 200 insertions, 255 deletions
diff --git a/src/util/et/ChangeLog b/src/util/et/ChangeLog
index e536e6a58e..a10c3d2db7 100644
--- a/src/util/et/ChangeLog
+++ b/src/util/et/ChangeLog
@@ -1,3 +1,11 @@
+Fri Feb 14 13:55:45 1997 Richard Basch <basch@lehman.com>
+
+ * com_err.c com_err.h error_message.c error_table.h et_c.awk et_h.awk:
+ Removed experimental V2 API
+ Added table register/deregister functions
+ Only make the com_err_hook vars/funcs available on Unix
+ Only expose _et_list on Unix
+
Tue Feb 11 13:31:49 1997 Richard Basch <basch@lehman.com>
* com_err.c: If the application is a console application, simply
diff --git a/src/util/et/Makefile.in b/src/util/et/Makefile.in
index 74c5605e53..51c0601233 100644
--- a/src/util/et/Makefile.in
+++ b/src/util/et/Makefile.in
@@ -2,10 +2,10 @@ RELDIR=../util/et
CFLAGS = $(CCOPTS) $(DEFS) $(LOCALINCLUDE)
SED = sed
-##DOSBUILDTOP = ..\..
-##DOSLIBNAME=comerr.lib
-##DOSXTRA=
-##DOSOBJFILE=comerr.lst
+##DOS##BUILDTOP = ..\..
+##DOS##LIBNAME=comerr.lib
+##DOS##XTRA=
+##DOS##OBJFILE=comerr.lst
STLIBOBJS=error_message.o et_name.o init_et.o com_err.o
STOBJLISTS=OBJS.ST
@@ -63,40 +63,21 @@ all-windows:: $(OBJFILE)
##WIN16## $(CP) nul: $(OBJFILE)
##WIN32## $(LIBECHO) *.obj > $(OBJFILE)
-#
-# what to build...
-#
-#
-# rules
-#
error_table.c: et_lex.lex.c
-
error_table.c: $(srcdir)/error_table.y
error_table.o: error_table.c et_lex.lex.c
$(CC) $(CFLAGS) -c error_table.c
et_lex.lex.o: et_lex.lex.c
- $(CC) $(CFLAGS) -c et_lex.lex.c
-
test1.o: test1.c
- $(CC) $(CFLAGS) -c test1.c
-
test2.o: test2.c
- $(CC) $(CFLAGS) -c test2.c
-
test_et.o: test1.h test2.h
test_et: test_et.o test1.o test2.o $(LIBOBJS)
$(CC) -o test_et test_et.o test1.o test2.o $(LIBOBJS)
-# solaris make loses on com_err.c but not on init_et.c, but this helps
-com_err.o: com_err.c
-#
-# real entries...
-#
-
all-unix:: compile_et includes
# The real compile_et just isn't portable. (But then again, anything using
@@ -115,7 +96,6 @@ compile_et: $(srcdir)/compile_et.sh $(srcdir)/config_script
et_c.awk: $(srcdir)/et_c.awk
$(CP) $(srcdir)/et_c.awk et_c.awk
-
et_h.awk: $(srcdir)/et_h.awk
$(CP) $(srcdir)/et_h.awk et_h.awk
diff --git a/src/util/et/com_err.c b/src/util/et/com_err.c
index 0687827fac..a8f92fbc0e 100644
--- a/src/util/et/com_err.c
+++ b/src/util/et/com_err.c
@@ -30,60 +30,22 @@
static void MacMessageBox(errbuf);
#endif
-#if !(defined(_MSDOS) || defined(_WIN32) || defined(_MACINTOSH))
+static et_old_error_hook_func com_err_hook = 0;
static void default_com_err_proc
-ET_P((et_ctx ectx, void FAR *priv,
- const char FAR *whoami, errcode_t code,
+ET_P((const char FAR *whoami, errcode_t code,
const char FAR *fmt, va_list ap));
-/* The version for Unix */
-static void default_com_err_proc(ectx, priv, whoami, code, fmt, ap)
- et_ctx ectx;
- void FAR *priv;
+static void default_com_err_proc(whoami, code, fmt, ap)
const char FAR *whoami;
errcode_t code;
const char FAR *fmt;
va_list ap;
{
- if (whoami) {
- fputs(whoami, stderr);
- fputs(": ", stderr);
- }
- if (code) {
- fputs(error_message(code), stderr);
- fputs(" ", stderr);
- }
- if (fmt) {
- vfprintf(stderr, fmt, ap);
- }
- /* should do this only on a tty in raw mode */
- putc('\r', stderr);
- putc('\n', stderr);
- fflush(stderr);
-}
-
-#else
-
-/*
- * For Macintosh and Windows
- */
-void KRB5_CALLCONV default_com_err_proc
-ET_P((et_ctx ectx, void FAR *priv,
- const char FAR *whoami, errcode_t code,
- const char FAR *fmt, va_list ap));
+#if defined(_MSDOS) || defined(_WIN32) || defined(_MACINTOSH)
-void KRB5_CALLCONV default_com_err_proc(ectx, priv, whoami, code, fmt, ap)
- et_ctx ectx;
- void FAR *priv;
- const char FAR *whoami;
- errcode_t code;
- const char FAR *fmt;
- va_list ap;
-{
- static char errbuf[1024]; /* For those w/o stdio */
+ char errbuf[1024] = "";
- *errbuf = '\0';
if (whoami) {
strcat (errbuf, whoami);
strcat (errbuf, ": ");
@@ -92,13 +54,12 @@ void KRB5_CALLCONV default_com_err_proc(ectx, priv, whoami, code, fmt, ap)
strcat (errbuf, error_message(code));
strcat (errbuf, " ");
}
- if (fmt) {
+ if (fmt)
vsprintf (errbuf + strlen (errbuf), fmt, ap);
- }
+
#ifdef _MACINTOSH
MacMessageBox(errbuf);
#else
- /* For Windows */
#ifdef _WIN32
if (_isatty(_fileno(stderr))) {
fputs(errbuf, stderr);
@@ -108,72 +69,42 @@ void KRB5_CALLCONV default_com_err_proc(ectx, priv, whoami, code, fmt, ap)
} else
#endif /* _WIN32 */
MessageBox ((HWND)NULL, errbuf, "Kerberos", MB_ICONEXCLAMATION);
-#endif
-}
-#endif
+#endif /* _MACINTOSH */
-et_old_error_hook_func com_err_hook = 0;
-
-void et_com_err_va(ectx, whoami, code, fmt, ap)
- et_ctx ectx;
- const char FAR *whoami;
- errcode_t code;
- const char FAR *fmt;
- va_list ap;
-{
- if (ectx) {
- if (ectx->hook_func == 0)
- ectx->hook_func = default_com_err_proc;
- (*ectx->hook_func)(ectx, ectx->hook_func_data, whoami,
- code, fmt, ap);
- } else {
- if (!com_err_hook)
- default_com_err_proc(0, 0, whoami,
- code, fmt, ap);
- else
- (*com_err_hook)(whoami, code, fmt, ap);
+#else /* !_MSDOS && !_WIN32 && !_MACINTOSH */
+
+ if (whoami) {
+ fputs(whoami, stderr);
+ fputs(": ", stderr);
+ }
+ if (code) {
+ fputs(error_message(code), stderr);
+ fputs(" ", stderr);
+ }
+ if (fmt) {
+ vfprintf(stderr, fmt, ap);
}
+ /* should do this only on a tty in raw mode */
+ putc('\r', stderr);
+ putc('\n', stderr);
+ fflush(stderr);
+
+#endif
}
-#ifndef ET_VARARGS
-KRB5_DLLIMP void KRB5_CALLCONV_C et_com_err(et_ctx ectx,
- const char FAR *whoami,
- errcode_t code,
- const char FAR *fmt, ...)
-#else
-KRB5_DLLIMP void KRB5_CALLCONV_C et_com_err(ectx, whoami,
- code, fmt, va_alist)
- et_ctx ectx;
+KRB5_DLLIMP void KRB5_CALLCONV com_err_va(whoami, code, fmt, ap)
const char FAR *whoami;
errcode_t code;
const char FAR *fmt;
- va_dcl
-#endif
-{
va_list ap;
-
-#ifdef ET_VARARGS
- va_start(ap);
-#else
- va_start(ap, fmt);
-#endif
- et_com_err_va(ectx, whoami, code, fmt, ap);
- va_end(ap);
-}
-
-
-/*
- * The following are the old-style com_err interfaces....
- */
-KRB5_DLLIMP void KRB5_CALLCONV com_err_va(whoami, code, fmt, args)
- const char FAR * whoami;
- errcode_t code;
- const char FAR * fmt;
- va_list args;
{
- et_com_err_va(0, whoami, code, fmt, args);
+ if (!com_err_hook)
+ default_com_err_proc(whoami, code, fmt, ap);
+ else
+ (*com_err_hook)(whoami, code, fmt, ap);
}
+
#ifndef ET_VARARGS
KRB5_DLLIMP void KRB5_CALLCONV_C com_err(const char FAR *whoami,
errcode_t code,
@@ -197,7 +128,8 @@ KRB5_DLLIMP void KRB5_CALLCONV_C com_err(whoami, code, fmt, va_alist)
va_end(ap);
}
-KRB5_DLLIMP et_old_error_hook_func KRB5_CALLCONV set_com_err_hook (new_proc)
+#ifdef unix
+et_old_error_hook_func set_com_err_hook (new_proc)
et_old_error_hook_func new_proc;
{
et_old_error_hook_func x = com_err_hook;
@@ -206,32 +138,14 @@ KRB5_DLLIMP et_old_error_hook_func KRB5_CALLCONV set_com_err_hook (new_proc)
return x;
}
-KRB5_DLLIMP et_old_error_hook_func KRB5_CALLCONV reset_com_err_hook ()
+et_old_error_hook_func reset_com_err_hook ()
{
et_old_error_hook_func x = com_err_hook;
com_err_hook = 0;
return x;
}
-
-KRB5_DLLIMP errcode_t KRB5_CALLCONV et_set_hook(ectx, new, old)
- et_ctx ectx;
- struct et_hook FAR *new;
- struct et_hook FAR *old;
-{
- if (old) {
- old->func = ectx->hook_func;
- old->data = ectx->hook_func_data;
- }
- if (new) {
- ectx->hook_func = new->func;
- ectx->hook_func_data = new->data;
- } else {
- ectx->hook_func = 0;
- ectx->hook_func_data = 0;
- }
- return 0;
-}
+#endif
#ifdef _MACINTOSH
static void MacMessageBox(errbuf)
diff --git a/src/util/et/com_err.h b/src/util/et/com_err.h
index 7a5c9d991a..6258ad0272 100644
--- a/src/util/et/com_err.h
+++ b/src/util/et/com_err.h
@@ -55,63 +55,39 @@
#endif
typedef long errcode_t;
-
typedef void (*et_old_error_hook_func) ET_P((const char FAR *, errcode_t,
const char FAR *, va_list ap));
+struct error_table {
+ char const FAR * const FAR * msgs;
+ unsigned long base;
+ unsigned int n_msgs;
+};
+
KRB5_DLLIMP extern void KRB5_CALLCONV_C com_err
ET_STDARG_P((const char FAR *, errcode_t, const char FAR *, ...));
-
-KRB5_DLLIMP extern const char FAR * KRB5_CALLCONV error_message
- ET_P((errcode_t));
-
-KRB5_DLLIMP extern et_old_error_hook_func KRB5_EXPORTVAR com_err_hook;
-KRB5_DLLIMP extern et_old_error_hook_func KRB5_CALLCONV set_com_err_hook
- ET_P((et_old_error_hook_func));
-KRB5_DLLIMP extern et_old_error_hook_func KRB5_CALLCONV reset_com_err_hook
- ET_P((void));
KRB5_DLLIMP extern void KRB5_CALLCONV com_err_va
ET_P((const char FAR *whoami, errcode_t code, const char FAR *fmt,
va_list ap));
+KRB5_DLLIMP extern const char FAR * KRB5_CALLCONV error_message
+ ET_P((errcode_t));
+KRB5_DLLIMP extern errcode_t KRB5_CALLCONV add_error_table
+ ET_P((const struct error_table FAR *));
+KRB5_DLLIMP extern errcode_t KRB5_CALLCONV remove_error_table
+ ET_P((const struct error_table FAR *));
+#ifdef unix
/*
- * The experimental com_err API...
+ * The display routine should be application specific. A global hook,
+ * may cause inappropriate display procedures to be called between
+ * applications under non-Unix environments.
*/
-typedef struct et_context FAR *et_ctx;
-typedef void (KRB5_CALLCONV *et_error_hook_func)
- ET_P((et_ctx, void FAR *, const char FAR *, errcode_t,
- const char FAR *, va_list ap));
-
-struct error_table {
- char const FAR * const FAR * msgs;
- long base;
- int n_msgs;
-};
-
-struct et_hook {
- et_error_hook_func func;
- void FAR *data;
-};
-
-KRB5_DLLIMP extern errcode_t KRB5_CALLCONV et_init ET_P((et_ctx FAR *));
-KRB5_DLLIMP extern void KRB5_CALLCONV et_shutdown ET_P((et_ctx));
-
-KRB5_DLLIMP extern errcode_t KRB5_CALLCONV et_add_error_table
- ET_P((et_ctx, struct error_table FAR *));
-
-KRB5_DLLIMP extern const char FAR * KRB5_CALLCONV et_error_message
- ET_P((et_ctx, errcode_t));
-
-KRB5_DLLIMP extern void KRB5_CALLCONV_C et_com_err
- ET_STDARG_P((et_ctx, const char FAR *, errcode_t,
- const char FAR *, ...));
-
-KRB5_DLLIMP extern void KRB5_CALLCONV_C et_com_err_va
- ET_STDARG_P((et_ctx, const char FAR *, errcode_t,
- const char FAR *, va_list ap));
+extern et_old_error_hook_func com_err_hook;
+extern et_old_error_hook_func set_com_err_hook
+ ET_P((et_old_error_hook_func));
+extern et_old_error_hook_func reset_com_err_hook
+ ET_P((void));
+#endif
-KRB5_DLLIMP errcode_t KRB5_CALLCONV et_set_hook
- ET_P((et_ctx, struct et_hook FAR *, struct et_hook FAR *));
-
#define __COM_ERR_H
#endif /* ! defined(__COM_ERR_H) */
diff --git a/src/util/et/error_message.c b/src/util/et/error_message.c
index 30424a8b6c..8adc30fa33 100644
--- a/src/util/et/error_message.c
+++ b/src/util/et/error_message.c
@@ -39,41 +39,31 @@ extern const int sys_nerr;
static char buffer[ET_EBUFSIZ];
-KRB5_DLLIMP struct et_list KRB5_EXPORTVAR * _et_list = (struct et_list *) NULL;
+#ifndef unix
+static struct et_list * _et_list = (struct et_list *) NULL;
+#else
+/* Old interface compatibility */
+struct et_list * _et_list = (struct et_list *) NULL;
+#endif
-KRB5_DLLIMP const char FAR * KRB5_CALLCONV et_error_message(ectx, code)
- et_ctx ectx;
+KRB5_DLLIMP const char FAR * KRB5_CALLCONV error_message(code)
long code;
{
- int offset;
- long l_offset;
+ unsigned long offset;
+ unsigned long l_offset;
struct et_list *et;
long table_num;
int started = 0;
+ unsigned int divisor = 100;
char *cp;
-#if defined(_MSDOS) || defined(_WIN32)
- /*
- * Winsock defines errors in the range 10000-10100. These are
- * equivalent to 10000 plus the Berkeley error numbers.
- *
- * (Does windows strerror() work right here?)
- *
- * XXX NO. We need to do our own table lookup for Winsock error
- * messages!!! --- TYT
- *
- */
- if (code >= 10000 && code <= 10100) /* Is it Winsock error? */
- code -= 10000; /* Turn into Berkeley errno */
-#endif
-
- l_offset = code & ((1<<ERRCODE_RANGE)-1);
- offset = (int) l_offset;
- table_num = code - l_offset;
+ l_offset = (unsigned long)code & ((1<<ERRCODE_RANGE)-1);
+ offset = l_offset;
+ table_num = (unsigned long)code - l_offset;
if (!table_num) {
if (code == 0)
goto oops;
-
+
#ifdef HAVE_STRERROR
cp = strerror(offset);
if (cp)
@@ -90,10 +80,10 @@ KRB5_DLLIMP const char FAR * KRB5_CALLCONV et_error_message(ectx, code)
#endif /* HAVE_SYS_ERRLIST */
#endif /* HAVE_STRERROR */
}
- et = ectx ? ectx->tables : _et_list;
+
+ et = _et_list;
while (et) {
- /* This is to work around a bug in the compiler on the Alpha
- comparing longs */
+ /* Work-around for a DEC/Alpha compiler bug comparing longs */
if (((int) (et->table->base - table_num)) == 0) {
/* This is the right table */
if (et->table->n_msgs <= offset)
@@ -102,8 +92,45 @@ KRB5_DLLIMP const char FAR * KRB5_CALLCONV et_error_message(ectx, code)
}
et = et->next;
}
+
+#if defined(_MSDOS) || defined(_WIN32)
+ {
+ LPVOID msgbuf;
+
+ if (! FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL /* lpSource */,
+ (DWORD) code,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &msgbuf,
+ (DWORD) 0 /*sizeof(buffer)*/,
+ NULL /* va_list */ )) {
+ /*
+ * WinSock errors exist in the 10000 and 11000 ranges
+ * but might not appear if WinSock is not initialized
+ */
+ if (code < 12000) {
+ table_num = 0;
+ offset = code;
+ divisor = 10000;
+ }
+
+ goto oops;
+ } else {
+ strncpy(buffer, msgbuf, sizeof(buffer));
+ buffer[sizeof(buffer)-1] = '\0';
+ cp = buffer + strlen(buffer) - 1;
+ if (*cp == '\n') *cp-- = '\0';
+ if (*cp == '\r') *cp-- = '\0';
+ if (*cp == '.') *cp-- = '\0';
+
+ LocalFree(msgbuf);
+ return buffer;
+ }
+ }
+#endif
+
oops:
- cp = ectx ? ectx->error_buf : buffer;
+ cp = buffer;
strcpy(cp, "Unknown code ");
cp += sizeof("Unknown code ") - 1;
if (table_num) {
@@ -112,23 +139,61 @@ oops:
cp++;
*cp++ = ' ';
}
- if (offset >= 100) {
- *cp++ = '0' + offset / 100;
- offset %= 100;
+ while (divisor > 1) {
+ fprintf(stderr, "divisor %d, offset %d\n", divisor, offset);
+ if (started || offset >= divisor) {
+ *cp++ = '0' + offset / divisor;
+ offset %= divisor;
started++;
+ }
+ divisor /= 10;
}
- if (started || offset >= 10) {
- *cp++ = '0' + offset / 10;
- offset %= 10;
- }
+ fprintf(stderr, "divisor %d, offset %d\n", divisor, offset);
*cp++ = '0' + offset;
*cp = '\0';
return(buffer);
}
-KRB5_DLLIMP const char FAR * KRB5_CALLCONV error_message(code)
- errcode_t code;
+KRB5_DLLIMP errcode_t KRB5_CALLCONV
+add_error_table(et)
+ const struct error_table FAR * et;
{
- return et_error_message(0, code);
+ struct et_list *el = _et_list;
+
+ while (el) {
+ if (el->table->base == et->base)
+ return EEXIST;
+ el = el->next;
+ }
+
+ if (! (el = (struct et_list *)malloc(sizeof(struct et_list))))
+ return ENOMEM;
+
+ el->table = et;
+ el->next = _et_list;
+ _et_list = el;
+
+ return 0;
}
+KRB5_DLLIMP errcode_t KRB5_CALLCONV
+remove_error_table(et)
+ const struct error_table FAR * et;
+{
+ struct et_list *el = _et_list;
+ struct et_list *el2 = 0;
+
+ while (el) {
+ if (el->table->base == et->base) {
+ if (el2) /* Not the beginning of the list */
+ el2->next = el->next;
+ else
+ _et_list = el->next;
+ (void) free(el);
+ return 0;
+ }
+ el2 = el;
+ el = el->next;
+ }
+ return ENOENT;
+}
diff --git a/src/util/et/error_table.h b/src/util/et/error_table.h
index 179fe57271..5c2c600870 100644
--- a/src/util/et/error_table.h
+++ b/src/util/et/error_table.h
@@ -9,21 +9,16 @@
#include <errno.h>
-#define ET_EBUFSIZ 32
-
-struct et_context {
- struct et_list FAR *tables;
- et_error_hook_func hook_func;
- void FAR *hook_func_data;
- char error_buf[ET_EBUFSIZ];
-};
+#define ET_EBUFSIZ 64
struct et_list {
- struct et_list FAR *next;
+ struct et_list *next;
const struct error_table FAR *table;
};
-extern KRB5_DLLIMP struct et_list KRB5_EXPORTVAR * _et_list;
+#ifdef unix
+extern struct et_list * _et_list;
+#endif
#define ERRCODE_RANGE 8 /* # of bits to shift table number */
#define BITS_PER_CHAR 6 /* # bits to shift per character in name */
diff --git a/src/util/et/et_c.awk b/src/util/et/et_c.awk
index 3d54727362..8e6a1d419b 100644
--- a/src/util/et/et_c.awk
+++ b/src/util/et/et_c.awk
@@ -124,9 +124,9 @@ c2n["_"]=63
print "" > outfile
print "#if defined(__STDC__) || defined(_MSDOS) || defined(_WIN32)" > outfile
- print "#define NOARGS void" > outfile
+ print "#define P(x) x" > outfile
print "#else" > outfile
- print "#define NOARGS" > outfile
+ print "#define P(x) ()" > outfile
print "#define const" > outfile
print "#endif" > outfile
print "" > outfile
@@ -198,11 +198,6 @@ END {
print " long base;" > outfile
print " int n_msgs;" > outfile
print "};" > outfile
- print "struct et_list {" > outfile
- print " struct et_list FAR *next;" > outfile
- print " const struct error_table FAR *table;" > outfile
- print "};" > outfile
- print "extern KRB5_DLLIMP struct et_list KRB5_EXPORTVAR *_et_list;" > outfile
print "" > outfile
if (tab_base_high == 0) {
print "const struct error_table et_" table_name "_error_table = { text, " \
@@ -214,13 +209,24 @@ END {
tab_base_low, table_item_count) > outfile
}
print "" > outfile
- print "static struct et_list link = { 0, 0 };" > outfile
+ print "typedef long errcode_t;" > outfile
+ print "" > outfile
+ print "extern KRB5_DLLIMP errcode_t KRB5_CALLCONV" > outfile
+ print " add_error_table P((const struct error_table FAR *));" > outfile
+ print "extern KRB5_DLLIMP errcode_t KRB5_CALLCONV" > outfile
+ print " remove_error_table P((const struct error_table FAR *));" > outfile
+ print "" > outfile
+ print "static int init = 0;" > outfile
+ print "" > outfile
+ print "void initialize_" table_name "_error_table P((void)) {" > outfile
+ print " if (init) return;" > outfile
+ print " init++;" > outfile
+ print " add_error_table(&et_" table_name "_error_table);" > outfile
+ print "}" > outfile
print "" > outfile
- print "void initialize_" table_name "_error_table (NOARGS) {" > outfile
- print " if (!link.table) {" > outfile
- print " link.next = _et_list;" > outfile
- print " link.table = &et_" table_name "_error_table ;" > outfile
- print " _et_list = &link;" > outfile
- print " }" > outfile
+ print "void cleanup_" table_name "_error_table P((void)) {" > outfile
+ print " if (!init) return;" > outfile
+ print " init--;" > outfile
+ print " remove_error_table(&et_" table_name "_error_table);" > outfile
print "}" > outfile
}
diff --git a/src/util/et/et_h.awk b/src/util/et/et_h.awk
index 5851dd87a3..075ebc39a4 100644
--- a/src/util/et/et_h.awk
+++ b/src/util/et/et_h.awk
@@ -134,6 +134,7 @@ c2n["_"]=63
END {
print "extern void initialize_" table_name "_error_table ();" > outfile
+ print "extern void cleanup_" table_name "_error_table ();" > outfile
if (tab_base_high == 0) {
print "#define ERROR_TABLE_BASE_" table_name " (" \
sprintf("%d", tab_base_sign*tab_base_low) \
diff --git a/src/util/et/init_et.c b/src/util/et/init_et.c
index 0e5d89a548..d40ed62487 100644
--- a/src/util/et/init_et.c
+++ b/src/util/et/init_et.c
@@ -54,7 +54,6 @@ int init_error_table(msgs, base, count)
_et_list = &new_et->etl;
return 0;
}
-#endif
KRB5_DLLIMP extern errcode_t KRB5_CALLCONV et_init(ectx)
et_ctx FAR *ectx;
@@ -103,3 +102,4 @@ KRB5_DLLIMP extern errcode_t KRB5_CALLCONV et_add_error_table(ectx, tbl)
return 0;
}
+#endif