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.5 1997/07/21 14:08:48 jtc Exp $"); 9 #endif 10 11 #include "namespace.h" 12 #include <stdlib.h> 13 14 #ifdef __weak_alias 15 __weak_alias(a64l,_a64l); 16 #endif 17 18 long 19 a64l(s) 20 const char *s; 21 { 22 long value, digit, shift; 23 int i; 24 25 value = 0; 26 shift = 0; 27 for (i = 0; *s && i < 6; i++, s++) { 28 if (*s <= '/') 29 digit = *s - '.'; 30 else if (*s <= '9') 31 digit = *s - '0' + 2; 32 else if (*s <= 'Z') 33 digit = *s - 'A' + 12; 34 else 35 digit = *s - 'a' + 38; 36 37 value |= digit << shift; 38 shift += 6; 39 } 40 41 return (long) value; 42 } 43