pull-prototypes-to-head-20020821
[openafs.git] / src / comerr / et_name.c
1 /*
2  * Copyright 1987 by MIT Student Information Processing Board
3  *
4  * For copyright info, see mit-sipb-cr.h.
5  */
6
7 #include <afsconfig.h>
8 #include <afs/param.h>
9 #include <afs/afsutil.h>
10
11 RCSID("$Header$");
12
13 #include "error_table.h"
14 #include "mit-sipb-cr.h"
15 #include "internal.h"
16
17 #ifndef lint
18 static const char copyright[] =
19     "Copyright 1987,1988 by Student Information Processing Board, Massachusetts Institute of Technology";
20 #endif
21
22 static const char char_set[] =
23         "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
24
25 static char buf[6];
26
27 const char *error_table_name(afs_int32 num)
28 {
29     int ch;
30     int i;
31     char *p;
32
33     /* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */
34     p = buf;
35     num >>= ERRCODE_RANGE;
36     /* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */
37     num &= 077777777;
38     /* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */
39     for (i = 4; i >= 0; i--) {
40         ch = (num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1);
41         if (ch != 0)
42             *p++ = char_set[ch-1];
43     }
44     *p = '\0';
45     return(lcstring (buf, buf, sizeof(buf)));
46 }