From 00aba96743c1b76eb9c242368f582c65ecdbe47c Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 19 Mar 2003 19:46:02 -0500 Subject: [PATCH] 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. --- lib/et/ChangeLog | 13 ++++++++++++ lib/et/com_err.h | 6 ++++++ lib/et/error_message.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ lib/et/error_table.h | 5 ----- lib/et/et_c.awk | 6 +++--- lib/et/et_h.awk | 3 +++ 6 files changed, 82 insertions(+), 8 deletions(-) diff --git a/lib/et/ChangeLog b/lib/et/ChangeLog index 2f697e4..4df0b49 100644 --- a/lib/et/ChangeLog +++ b/lib/et/ChangeLog @@ -1,3 +1,16 @@ +2003-03-19 Theodore Ts'o + + * 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 * Release of E2fsprogs 1.32 diff --git a/lib/et/com_err.h b/lib/et/com_err.h index f28dce8..5c3fd94 100644 --- a/lib/et/com_err.h +++ b/lib/et/com_err.h @@ -12,6 +12,12 @@ typedef long errcode_t; +struct error_table { + char const * const * msgs; + unsigned long base; + unsigned int n_msgs; +}; + #ifdef __STDC__ #include diff --git a/lib/et/error_message.c b/lib/et/error_message.c index 6a836e8..3668c45 100644 --- a/lib/et/error_message.c +++ b/lib/et/error_message.c @@ -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); +} diff --git a/lib/et/error_table.h b/lib/et/error_table.h index d9a7b4b..36348e9 100644 --- a/lib/et/error_table.h +++ b/lib/et/error_table.h @@ -18,11 +18,6 @@ #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; diff --git a/lib/et/et_c.awk b/lib/et/et_c.awk index 5f95b55..66923e4 100644 --- a/lib/et/et_c.awk +++ b/lib/et/et_c.awk @@ -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 diff --git a/lib/et/et_h.awk b/lib/et/et_h.awk index 8b83a21..e8da3ac 100644 --- a/lib/et/et_h.awk +++ b/lib/et/et_h.awk @@ -119,6 +119,8 @@ c2n["_"]=63 print " * This file is automatically generated; please do not edit it." > outfile print " */" > outfile print "" > outfile + print "#include " > 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 " (" \ -- 1.8.3.1