a64l.c revision 1.3
11.1Sjtc/*
21.3Sjtc * Written by J.T. Conklin <jtc@netbsd.org>.
31.3Sjtc * Public domain.
41.1Sjtc */
51.1Sjtc
61.1Sjtc#if defined(LIBC_SCCS) && !defined(lint)
71.3Sjtcstatic char *rcsid = "$NetBSD: a64l.c,v 1.3 1995/05/11 23:03:44 jtc Exp $";
81.1Sjtc#endif
91.1Sjtc
101.1Sjtclong
111.1Sjtca64l(s)
121.1Sjtc	const char *s;
131.1Sjtc{
141.1Sjtc	long value, digit, shift;
151.1Sjtc	int i;
161.1Sjtc
171.1Sjtc	value = 0;
181.1Sjtc	shift = 0;
191.1Sjtc	for (i = 0; *s && i < 6; i++, s++) {
201.1Sjtc		if (*s <= '/')
211.1Sjtc			digit = *s - '.';
221.1Sjtc		else if (*s <= '9')
231.1Sjtc			digit = *s - '0' + 2;
241.1Sjtc		else if (*s <= 'Z')
251.1Sjtc			digit = *s - 'A' + 12;
261.1Sjtc		else
271.1Sjtc			digit = *s - 'a' + 38;
281.1Sjtc
291.1Sjtc		value |= digit << shift;
301.1Sjtc		shift += 6;
311.1Sjtc	}
321.1Sjtc
331.1Sjtc	return (long) value;
341.1Sjtc}
35