+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
typedef long errcode_t;
+struct error_table {
+ char const * const * msgs;
+ unsigned long base;
+ unsigned int n_msgs;
+};
+
#ifdef __STDC__
#include <stdarg.h>
*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);
+}
#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;
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
}
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
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]+,/ {
}
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 " (" \