summaryrefslogtreecommitdiffstats
path: root/eBones/compile_et/et_name.c
blob: 98ccb08ecad967569da9131188d454ce50054779 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Copyright 1987 by MIT Student Information Processing Board
 * For copyright info, see Copyright.SIPB.
 *
 *	$Id: et_name.c,v 1.2 1994/07/19 19:21:27 g89r4222 Exp $
 */

#include "error_table.h"

static char copyright[] = "Copyright 1987 by MIT Student Information Processing Board";

char *malloc();

char *
error_table_name(num)
	int num;
{
	register int ch;
	register int i;
	register char *buf, *p;

	/* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */
	buf = malloc(5);
	p = buf;
	num >>= ERRCODE_RANGE;
	/* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */
	num &= 077777777;
	/* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */
	for (i = 0; i < 5; i++) {
		ch = (num >> 24-6*i) & 077;
		if (ch == 0)
			continue;
		else if (ch < 27)
			*p++ = ch - 1 + 'A';
		else if (ch < 53)
			*p++ = ch - 27 + 'a';
		else if (ch < 63)
			*p++ = ch - 53 + '0';
		else		/* ch == 63 */
			*p++ = '_';
	}
	return(buf);
}

OpenPOWER on IntegriCloud