]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
com_err.h, error_table.h: Move definition of the error_table
authorTheodore Ts'o <tytso@mit.edu>
Thu, 20 Mar 2003 00:46:02 +0000 (19:46 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 20 Mar 2003 00:46:02 +0000 (19:46 -0500)
structure from the internal error_table.h to com_err.h,
since it now needs to be public.

et_c.awk, et_h.awk: Import changes from krb5's et library so
that the error_table structure is defined and available
publically.

error_message.c: Import krb5 and heimdall com_err extensions to
the et library.

lib/et/ChangeLog
lib/et/com_err.h
lib/et/error_message.c
lib/et/error_table.h
lib/et/et_c.awk
lib/et/et_h.awk

index 2f697e41345c4404bb3c645669a35024204bde3f..4df0b491aa500377d19e155a9022cb224ab3046c 100644 (file)
@@ -1,3 +1,16 @@
+2003-03-19  Theodore Ts'o  <tytso@mit.edu>
+
+       * com_err.h, error_table.h: Move definition of the error_table
+               structure from the internal error_table.h to com_err.h,
+               since it now needs to be public.
+
+       * et_c.awk, et_h.awk: Import changes from krb5's et library so
+               that the error_table structure is defined and available
+               publically.
+
+       * error_message.c: Import krb5 and heimdall com_err extensions to
+               the et library.
+
 2002-11-09  Theodore Ts'o  <tytso@mit.edu>
 
        * Release of E2fsprogs 1.32
index f28dce88a6c1d473406fea2052a002bf23616bca..5c3fd94f1e8a5c61b404273587f05723f42528ef 100644 (file)
 
 typedef long errcode_t;
 
+struct error_table {
+       char const * const * msgs;
+       unsigned long base;
+       unsigned int n_msgs;
+};
+
 #ifdef __STDC__
 #include <stdarg.h>
 
index 6a836e8e042b81aa6bcb82a4272fe4c03ecc78bb..3668c451f67578c8cee026e6942cbf53ff6a7736 100644 (file)
@@ -86,3 +86,60 @@ oops:
     *cp = '\0';
     return(buffer);
 }
+
+/*
+ * New interface provided by krb5's com_err library
+ */
+errcode_t add_error_table(et)
+       const struct error_table * et;
+{
+       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;
+}
+
+/*
+ * New interface provided by krb5's com_err library
+ */
+errcode_t remove_error_table(et)
+       const struct error_table * 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;
+}
+
+/*
+ * Variant of the interface provided by Heimdal's com_err library
+ */
+void
+add_to_error_table(struct et_list *new_table)
+{
+       add_error_table(new_table->table);
+}
index d9a7b4b2809b6a97cf0220652ad083b7d3f535d0..36348e920410cf6af88630497cf9c6a8ea4234fa 100644 (file)
 #define const
 #endif
 
-struct error_table {
-    char const * const * msgs;
-    long base;
-    int n_msgs;
-};
 struct et_list {
     struct et_list *next;
     const struct error_table *table;
index 5f95b55bf4882c666cddf93aedcc7f5e38c781ba..66923e47be99a3da140c74244ddc58d0ca6b8f7d 100644 (file)
@@ -162,11 +162,11 @@ END {
        print "extern struct et_list *_et_list;" > outfile
        print "" > outfile
        if (tab_base_high == 0) {
-           print "static const struct error_table et = { text, " \
+               print "const struct error_table et_" table_name "_error_table = { text, " \
                sprintf("%dL, %d };", tab_base_sign*tab_base_low, \
                table_item_count) > outfile
        } else {
-           print "static const struct error_table et = { text, " \
+               print "const struct error_table et_" table_name "_error_table = { text, " \
                sprintf("%d%06dL, %d };", tab_base_sign*tab_base_high, \
                tab_base_low, table_item_count) > outfile
        }
@@ -178,7 +178,7 @@ END {
        print "void initialize_" table_name "_error_table(void) {" > outfile
        print "    if (!link.table) {" > outfile
        print "        link.next = _et_list;" > outfile
-       print "        link.table = &et;" > outfile
+       print "        link.table = &et_" table_name "_error_table;" > outfile
        print "        _et_list = &link;" > outfile
        print "    }" > outfile
        print "}" > outfile
index 8b83a21d7013cd5df7005fbe83a11fc836c59243..e8da3accaab6b09e7be86e1ed1ad52fe8d2253ab 100644 (file)
@@ -119,6 +119,8 @@ c2n["_"]=63
        print " * This file is automatically generated; please do not edit it." > outfile
        print " */" > outfile
        print "" > outfile
+       print "#include <com_err.h>" > outfile
+       print "" > outfile
 }
 
 /^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,/ {
@@ -142,6 +144,7 @@ c2n["_"]=63
 }
 
 END {
+       print "extern const struct error_table et_" table_name "_error_table;" > outfile
        print "extern void initialize_" table_name "_error_table(void);" > outfile
        if (tab_base_high == 0) {
                print "#define ERROR_TABLE_BASE_" table_name " (" \