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