Removed V2 experimental API previously checked-in.
authorRichard Basch <probe@mit.edu>
Sat, 15 Feb 1997 21:25:33 +0000 (21:25 +0000)
committerRichard Basch <probe@mit.edu>
Sat, 15 Feb 1997 21:25:33 +0000 (21:25 +0000)
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

src/util/et/ChangeLog
src/util/et/Makefile.in
src/util/et/com_err.c
src/util/et/com_err.h
src/util/et/error_message.c
src/util/et/error_table.h
src/util/et/et_c.awk
src/util/et/et_h.awk
src/util/et/init_et.c

index e536e6a58e9f060bb5d5f81878b19e6718a4af31..a10c3d2db7863cd44a2bcf99bfe584e81e037e9c 100644 (file)
@@ -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
index 74c5605e53303f60cc8707b61792d31d4090b5f3..51c0601233825f62c9739e8926700d5062b8f825 100644 (file)
@@ -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
 
index 0687827fac586663136ee3e4b28a35c084038f29..a8f92fbc0ecb45496fd86a66e7a9cf724e46572f 100644 (file)
 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)
index 7a5c9d991ab0084681d2dc7d43b3e214a8479422..6258ad0272fba52515bab3d5b473733049fa507b 100644 (file)
 #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) */
index 30424a8b6cf07cf5cdfe768d808260f92af5f41b..8adc30fa33a1fd3bbce1affcdcb5ac3ab38d5414 100644 (file)
@@ -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;
+}
index 179fe5727169b953c68b493664ed95cbeb9835cb..5c2c6008702fc7e05ca7e5d0002a527f10f92b7b 100644 (file)
@@ -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 */
index 3d5472736289057314f57c98b3f5060ac498f744..8e6a1d419b8eec7fcf329ba4fc83aaf9128d3e22 100644 (file)
@@ -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
 }
index 5851dd87a37a38dbe5f2f72b8b0fff481f07db17..075ebc39a4839d2ad228f6b8778a19dd3d04ae09 100644 (file)
@@ -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) \
index 0e5d89a548190dd62524a190ea93fe7df31adaee..d40ed62487dca85efb6754b92fa81a899e767baa 100644 (file)
@@ -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