From 3fc228fb4c1a39aceaee3d7013365042a6077bd0 Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Fri, 26 Mar 1999 18:24:03 +0000 Subject: This commit was manufactured by cvs2git to create branch 'OPENBSD_2_5'. --- src/lib/libc/stdlib/a64l.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/lib/libc/stdlib/a64l.c (limited to 'src/lib/libc/stdlib/a64l.c') diff --git a/src/lib/libc/stdlib/a64l.c b/src/lib/libc/stdlib/a64l.c new file mode 100644 index 0000000000..a68f0a6dcd --- /dev/null +++ b/src/lib/libc/stdlib/a64l.c @@ -0,0 +1,46 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char *rcsid = "$OpenBSD: a64l.c,v 1.3 1997/08/17 22:58:34 millert Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +long +a64l(s) + const char *s; +{ + long value, digit, shift; + int i; + + if (s == NULL) { + errno = EINVAL; + return(-1L); + } + + value = 0; + shift = 0; + for (i = 0; *s && i < 6; i++, s++) { + if (*s >= '.' && *s <= '/') + digit = *s - '.'; + else if (*s >= '0' && *s <= '9') + digit = *s - '0' + 2; + else if (*s >= 'A' && *s <= 'Z') + digit = *s - 'A' + 12; + else if (*s >= 'a' && *s <= 'z') + digit = *s - 'a' + 38; + else { + errno = EINVAL; + return(-1L); + } + + value |= digit << shift; + shift += 6; + } + + return(value); +} -- cgit v1.2.3-55-g6feb