a64l.c revision 1.4
11.1Sjtc/*
21.3Sjtc * Written by J.T. Conklin <jtc@netbsd.org>.
31.3Sjtc * Public domain.
41.1Sjtc */
51.1Sjtc
61.4Schristos#include <sys/cdefs.h>
71.1Sjtc#if defined(LIBC_SCCS) && !defined(lint)
81.4Schristos__RCSID("$NetBSD: a64l.c,v 1.4 1997/07/13 20:16:33 christos Exp $");
91.1Sjtc#endif
101.4Schristos
111.4Schristos#include <stdlib.h>
121.1Sjtc
131.1Sjtclong
141.1Sjtca64l(s)
151.1Sjtc	const char *s;
161.1Sjtc{
171.1Sjtc	long value, digit, shift;
181.1Sjtc	int i;
191.1Sjtc
201.1Sjtc	value = 0;
211.1Sjtc	shift = 0;
221.1Sjtc	for (i = 0; *s && i < 6; i++, s++) {
231.1Sjtc		if (*s <= '/')
241.1Sjtc			digit = *s - '.';
251.1Sjtc		else if (*s <= '9')
261.1Sjtc			digit = *s - '0' + 2;
271.1Sjtc		else if (*s <= 'Z')
281.1Sjtc			digit = *s - 'A' + 12;
291.1Sjtc		else
301.1Sjtc			digit = *s - 'a' + 38;
311.1Sjtc
321.1Sjtc		value |= digit << shift;
331.1Sjtc		shift += 6;
341.1Sjtc	}
351.1Sjtc
361.1Sjtc	return (long) value;
371.1Sjtc}
38