a64l.c revision 1.3
1/*
2 * Written by J.T. Conklin <jtc@netbsd.org>.
3 * Public domain.
4 */
5
6#if defined(LIBC_SCCS) && !defined(lint)
7static char *rcsid = "$NetBSD: a64l.c,v 1.3 1995/05/11 23:03:44 jtc Exp $";
8#endif
9
10long
11a64l(s)
12	const char *s;
13{
14	long value, digit, shift;
15	int i;
16
17	value = 0;
18	shift = 0;
19	for (i = 0; *s && i < 6; i++, s++) {
20		if (*s <= '/')
21			digit = *s - '.';
22		else if (*s <= '9')
23			digit = *s - '0' + 2;
24		else if (*s <= 'Z')
25			digit = *s - 'A' + 12;
26		else
27			digit = *s - 'a' + 38;
28
29		value |= digit << shift;
30		shift += 6;
31	}
32
33	return (long) value;
34}
35