paul@181 | 1 | /* |
paul@181 | 2 | * Copyright 1987 by MIT Student Information Processing Board |
paul@181 | 3 | * |
paul@181 | 4 | * Permission to use, copy, modify, and distribute this software and |
paul@181 | 5 | * its documentation for any purpose is hereby granted, provided that |
paul@181 | 6 | * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in |
paul@181 | 7 | * advertising or publicity pertaining to distribution of the software |
paul@181 | 8 | * without specific, written prior permission. M.I.T. and the |
paul@181 | 9 | * M.I.T. S.I.P.B. make no representations about the suitability of |
paul@181 | 10 | * this software for any purpose. It is provided "as is" without |
paul@181 | 11 | * express or implied warranty. |
paul@181 | 12 | */ |
paul@181 | 13 | |
paul@181 | 14 | #include "config.h" |
paul@181 | 15 | #include "com_err.h" |
paul@181 | 16 | #include "error_table.h" |
paul@181 | 17 | #include "internal.h" |
paul@181 | 18 | |
paul@181 | 19 | static const char char_set[] = |
paul@181 | 20 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; |
paul@181 | 21 | |
paul@181 | 22 | static char buf[6]; |
paul@181 | 23 | |
paul@181 | 24 | const char * error_table_name(errcode_t num) |
paul@181 | 25 | { |
paul@181 | 26 | int ch; |
paul@181 | 27 | int i; |
paul@181 | 28 | char *p; |
paul@181 | 29 | |
paul@181 | 30 | /* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */ |
paul@181 | 31 | p = buf; |
paul@181 | 32 | num >>= ERRCODE_RANGE; |
paul@181 | 33 | /* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */ |
paul@181 | 34 | num &= 077777777L; |
paul@181 | 35 | /* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */ |
paul@181 | 36 | for (i = 4; i >= 0; i--) { |
paul@181 | 37 | ch = (int)((num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1)); |
paul@181 | 38 | if (ch != 0) |
paul@181 | 39 | *p++ = char_set[ch-1]; |
paul@181 | 40 | } |
paul@181 | 41 | *p = '\0'; |
paul@181 | 42 | return(buf); |
paul@181 | 43 | } |