Import Upstream version 1.8.5
[hcoop/debian/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
10 #include <roken.h>
11
12 #include <afs/opr.h>
13
14 #include "error_table.h"
15 #include "mit-sipb-cr.h"
16 #include "internal.h"
17
18 static const char char_set[] =
19 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
20
21 static char buf[6];
22
23 const char *
24 afs_error_table_name(int num)
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 */
34 num &= 077777777;
35 /* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */
36 for (i = 4; i >= 0; i--) {
37 ch = (num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1);
38 if (ch != 0)
39 *p++ = char_set[ch - 1];
40 }
41 *p = '\0';
42 return (lcstring(buf, buf, sizeof(buf)));
43 }