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