1 /* 2 * Written by J.T. Conklin <jtc@netbsd.org>. 3 * Public domain. 4 */ 5 6 #if defined(LIBC_SCCS) && !defined(lint) 7 static char *rcsid = "$OpenBSD: a64l.c,v 1.2 1996/08/19 08:33:19 tholo Exp $"; 8 #endif /* LIBC_SCCS and not lint */ 9 10 long 11 a64l(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