1993-10-22 20:26:43 +03:00
|
|
|
/*
|
1995-05-12 03:03:44 +04:00
|
|
|
* Written by J.T. Conklin <jtc@netbsd.org>.
|
|
|
|
* Public domain.
|
1993-10-22 20:26:43 +03:00
|
|
|
*/
|
|
|
|
|
1997-07-14 00:16:31 +04:00
|
|
|
#include <sys/cdefs.h>
|
1993-10-22 20:26:43 +03:00
|
|
|
#if defined(LIBC_SCCS) && !defined(lint)
|
2000-01-23 01:19:07 +03:00
|
|
|
__RCSID("$NetBSD: a64l.c,v 1.8 2000/01/22 22:19:19 mycroft Exp $");
|
1993-10-22 20:26:43 +03:00
|
|
|
#endif
|
|
|
|
|
1997-07-21 18:06:24 +04:00
|
|
|
#include "namespace.h"
|
1999-09-16 15:44:54 +04:00
|
|
|
|
|
|
|
#include <assert.h>
|
1997-07-14 00:16:31 +04:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
1997-07-21 18:06:24 +04:00
|
|
|
#ifdef __weak_alias
|
2000-01-23 01:19:07 +03:00
|
|
|
__weak_alias(a64l,_a64l)
|
1997-07-21 18:06:24 +04:00
|
|
|
#endif
|
|
|
|
|
1993-10-22 20:26:43 +03:00
|
|
|
long
|
|
|
|
a64l(s)
|
|
|
|
const char *s;
|
|
|
|
{
|
|
|
|
long value, digit, shift;
|
|
|
|
int i;
|
|
|
|
|
1999-09-16 15:44:54 +04:00
|
|
|
_DIAGASSERT(s != NULL);
|
|
|
|
|
1993-10-22 20:26:43 +03:00
|
|
|
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;
|
|
|
|
}
|