diff --git a/lib/com_err/com_err.c b/lib/com_err/com_err.c index 9a4cebae5..725f54457 100644 --- a/lib/com_err/com_err.c +++ b/lib/com_err/com_err.c @@ -45,13 +45,13 @@ RCSID("$Id$"); #include #include "com_err.h" -static struct error_table *et_list; +struct et_list *_et_list; const char * error_message (long code) { static char msg[128]; - const char *p = com_right(et_list, code); + const char *p = com_right(_et_list, code); if(p){ strncpy(msg, p, sizeof(msg)); msg[sizeof(msg)-1] = '\0'; @@ -64,7 +64,7 @@ error_message (long code) int init_error_table(const char **msgs, long base, int count) { - initialize_error_table_r(&et_list, msgs, count, base); + initialize_error_table_r(&_et_list, msgs, count, base); return 0; } diff --git a/lib/com_err/com_right.h b/lib/com_err/com_right.h index 8412f72cc..ba1c88868 100644 --- a/lib/com_err/com_right.h +++ b/lib/com_err/com_right.h @@ -45,11 +45,15 @@ struct error_table { char const * const * msgs; long base; int n_msgs; - struct error_table *next; }; +struct et_list { + struct et_list *next; + struct error_table *table; +}; +extern struct et_list *_et_list; -const char *com_right(struct error_table *list, long code); -void initialize_error_table_r(struct error_table**, const char**, int, long); -void free_error_table(struct error_table*); +const char *com_right(struct et_list *list, long code); +void initialize_error_table_r(struct et_list **, const char **, int, long); +void free_error_table(struct et_list *); #endif /* __COM_RIGHT_H__ */ diff --git a/lib/com_err/compile_et.c b/lib/com_err/compile_et.c index f82b5625f..f6a9afb12 100644 --- a/lib/com_err/compile_et.c +++ b/lib/com_err/compile_et.c @@ -100,7 +100,7 @@ generate_c(void) fprintf(c_file, "};\n"); fprintf(c_file, "\n"); fprintf(c_file, - "void initialize_%s_error_table_r(struct error_table **list)\n", + "void initialize_%s_error_table_r(struct et_list **list)\n", name); fprintf(c_file, "{\n"); fprintf(c_file, @@ -146,7 +146,7 @@ generate_h(void) fprintf(h_file, "#include \n"); fprintf(h_file, "\n"); fprintf(h_file, - "void initialize_%s_error_table_r(struct error_table**);\n", + "void initialize_%s_error_table_r(struct et_list **);\n", name); fprintf(h_file, "\n"); fprintf(h_file, "void initialize_%s_error_table(void);\n", name); diff --git a/lib/com_err/error.c b/lib/com_err/error.c index 337a3b87b..c616d1253 100644 --- a/lib/com_err/error.c +++ b/lib/com_err/error.c @@ -46,42 +46,50 @@ RCSID("$Id$"); #include const char * -com_right(struct error_table *list, long code) +com_right(struct et_list *list, long code) { - struct error_table *p; - for(p = list; p; p = p->next){ - if(code >= p->base && code < p->base + p->n_msgs) - return p->msgs[code - p->base]; + struct et_list *p; + for (p = list; p; p = p->next) { + if (code >= p->table->base && code < p->table->base + p->table->n_msgs) + return p->table->msgs[code - p->table->base]; } return NULL; } +struct foobar { + struct et_list etl; + struct error_table et; +}; + void -initialize_error_table_r(struct error_table **list, +initialize_error_table_r(struct et_list **list, const char **messages, int num_errors, long base) { - struct error_table *et; - for(et = *list; et; et = et->next) - if(et->msgs == messages) + struct et_list *et; + struct foobar *f; + for (et = *list; et; et = et->next) + if (et->table->msgs == messages) return; - et = malloc(sizeof(*et)); - if (et == NULL) + f = malloc(sizeof(*f)); + if (f == NULL) return; - et->msgs = messages; - et->n_msgs = num_errors; - et->base = base; + et = &f->etl; + et->table = &f->et; + et->table->msgs = messages; + et->table->n_msgs = num_errors; + et->table->base = base; et->next = *list; *list = et; } void -free_error_table(struct error_table *et) +free_error_table(struct et_list *et) { while(et){ - struct error_table *p = et; + struct et_list *p = et; et = et->next; free(p); }