2011-02-14 20:36:03 +01:00
|
|
|
/*
|
|
|
|
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
|
|
|
* Public domain.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#if defined(LIBC_SCCS) && !defined(lint)
|
2012-11-15 12:06:41 +01:00
|
|
|
__RCSID("$NetBSD: a64l.c,v 1.10 2012/06/08 11:15:26 abs Exp $");
|
2011-02-14 20:36:03 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "namespace.h"
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#ifdef __weak_alias
|
|
|
|
__weak_alias(a64l,_a64l)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
long
|
2012-11-15 12:06:41 +01:00
|
|
|
a64l(const char *s)
|
2011-02-14 20:36:03 +01:00
|
|
|
{
|
|
|
|
long value, digit, shift;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
_DIAGASSERT(s != NULL);
|
|
|
|
|
|
|
|
value = 0;
|
|
|
|
shift = 0;
|
|
|
|
for (i = 0; *s && i < 6; i++, s++) {
|
|
|
|
if (*s <= '/')
|
|
|
|
digit = *s - '.';
|
|
|
|
else if (*s <= '9')
|
|
|
|
digit = *s - '0' + 2;
|
|
|
|
else if (*s <= 'Z')
|
|
|
|
digit = *s - 'A' + 12;
|
|
|
|
else
|
|
|
|
digit = *s - 'a' + 38;
|
|
|
|
|
|
|
|
value |= digit << shift;
|
|
|
|
shift += 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (long) value;
|
|
|
|
}
|