diff options
Diffstat (limited to 'src/lib/libc/stdlib/a64l.c')
| -rw-r--r-- | src/lib/libc/stdlib/a64l.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/lib/libc/stdlib/a64l.c b/src/lib/libc/stdlib/a64l.c new file mode 100644 index 0000000000..03fc77e034 --- /dev/null +++ b/src/lib/libc/stdlib/a64l.c | |||
| @@ -0,0 +1,34 @@ | |||
| 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 = "$NetBSD: a64l.c,v 1.3 1995/05/11 23:04:47 jtc Exp $"; | ||
| 8 | #endif | ||
| 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 | } | ||
