2086
|
1 /*
|
|
2 * Copyright 1987 by MIT Student Information Processing Board
|
|
3 *
|
|
4 * For copyright info, see mit-sipb-copyright.h.
|
|
5 */
|
|
6
|
|
7 #include <sysdep.h>
|
|
8
|
8354
|
9
|
|
10 #define ERRCODE_RANGE 8 /* # of bits to shift table number */
|
|
11 #define BITS_PER_CHAR 6 /* # bits to shift per character in name */
|
|
12
|
|
13
|
2086
|
14 static const char char_set[] =
|
|
15 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
|
|
16
|
|
17 const char * error_table_name_r(num, buf)
|
|
18 int num;
|
|
19 char *buf;
|
|
20 {
|
|
21 int ch;
|
|
22 int i;
|
|
23 char *p;
|
|
24
|
|
25 /* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */
|
|
26 p = buf;
|
|
27 num >>= ERRCODE_RANGE;
|
|
28 /* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */
|
|
29 num &= 077777777;
|
|
30 /* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */
|
|
31 for (i = 4; i >= 0; i--) {
|
|
32 ch = (num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1);
|
|
33 if (ch != 0)
|
|
34 *p++ = char_set[ch-1];
|
|
35 }
|
|
36 *p = '\0';
|
|
37 return(buf);
|
|
38 }
|
|
39
|
|
40 const char * error_table_name(num)
|
|
41 int num;
|
|
42 {
|
|
43 static char buf[6];
|
|
44
|
|
45 return(error_table_name_r(num, buf));
|
|
46 }
|
|
47
|