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