aboutsummaryrefslogtreecommitdiff
path: root/src/util/et/et_name.c
blob: 267f20b28b32165b1dc6c548513e58905f3dd911 (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
45
46
47
48
49
50
51
52
53
54
/*
 * Copyright 1997 by Massachusetts Institute of Technology
 * 
 * Copyright 1987 by MIT Student Information Processing Board
 *
 * Permission to use, copy, modify, and distribute this software
 * and its documentation for any purpose and without fee is
 * hereby granted, provided that the above copyright notice
 * appear in all copies and that both that copyright notice and
 * this permission notice appear in supporting documentation,
 * and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
 * used in advertising or publicity pertaining to distribution
 * of the software without specific, written prior permission.
 * Furthermore if you modify this software you must label
 * your software as modified software and not distribute it in such a
 * fashion that it might be confused with the original M.I.T. software.
 * M.I.T. and the M.I.T. S.I.P.B. make no representations about
 * the suitability of this software for any purpose.  It is
 * provided "as is" without express or implied warranty.
 */

#include "com_err.h"
#include "error_table.h"

static const char char_set[] =
	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";

const char * error_table_name_r(num, out)
	unsigned long num;
	char FAR *out;
{
	long ch;
	int i;
	char *p;

	p = out;
	num >>= ERRCODE_RANGE;

	for (i = 3; i >= 0; i--) {
		ch = (num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1);
		if (ch != 0)
			*p++ = char_set[ch-1];
	}
	*p = '\0';
	return(out);
}

const char FAR * error_table_name(num)
	unsigned long num;
{
	static char buf[6];

	return error_table_name_r(num, buf);
}