6 * Copyright 1987 by the Student Information Processing Board
7 * of the Massachusetts Institute of Technology
9 * Permission to use, copy, modify, and distribute this software and
10 * its documentation for any purpose is hereby granted, provided that
11 * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in
12 * advertising or publicity pertaining to distribution of the software
13 * without specific, written prior permission. M.I.T. and the
14 * M.I.T. S.I.P.B. make no representations about the suitability of
15 * this software for any purpose. It is provided "as is" without
16 * express or implied warranty.
24 #include "error_table.h"
27 static char buffer[25];
29 struct et_list * _et_list = (struct et_list *) NULL;
32 const char * error_message (errcode_t code)
40 offset = (int) (code & ((1<<ERRCODE_RANGE)-1));
41 table_num = code - offset;
43 #ifdef HAS_SYS_ERRLIST
44 if (offset < sys_nerr)
45 return(sys_errlist[offset]);
49 cp = strerror(offset);
56 for (et = _et_list; et; et = et->next) {
57 if (et->table->base == table_num) {
58 /* This is the right table */
59 if (et->table->n_msgs <= offset)
61 return(et->table->msgs[offset]);
65 strcpy (buffer, "Unknown code ");
67 strcat (buffer, error_table_name (table_num));
70 for (cp = buffer; *cp; cp++)
73 *cp++ = '0' + offset / 100;
77 if (started || offset >= 10) {
78 *cp++ = '0' + offset / 10;
87 * New interface provided by krb5's com_err library
89 errcode_t add_error_table(const struct error_table * et)
91 struct et_list *el = _et_list;
94 if (el->table->base == et->base)
99 if (!(el = (struct et_list *) malloc(sizeof(struct et_list))))
110 * New interface provided by krb5's com_err library
112 errcode_t remove_error_table(const struct error_table * et)
114 struct et_list *el = _et_list;
115 struct et_list *el2 = 0;
118 if (el->table->base == et->base) {
119 if (el2) /* Not the beginning of the list */
120 el2->next = el->next;
133 * Variant of the interface provided by Heimdal's com_err library
136 add_to_error_table(struct et_list *new_table)
138 add_error_table(new_table->table);