From 4abab5ad6c8465a7528ccdd5f49367da05f78bbd Mon Sep 17 00:00:00 2001 From: Vladimir Azarov Date: Tue, 1 Oct 2024 15:47:05 +0200 Subject: Initial version --- src/misc/a64l.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/misc/a64l.c (limited to 'src/misc/a64l.c') diff --git a/src/misc/a64l.c b/src/misc/a64l.c new file mode 100644 index 0000000..6055771 --- /dev/null +++ b/src/misc/a64l.c @@ -0,0 +1,29 @@ +#include +#include +#include + +static const char digits[] = + "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + +long a64l(const char *s) +{ + int e; + uint32_t x = 0; + for (e=0; e<36 && *s; e+=6, s++) { + const char *d = strchr(digits, *s); + if (!d) break; + x |= (uint32_t)(d-digits)<>=6) + *p = digits[x&63]; + *p = 0; + return s; +} -- cgit v1.2.3