projects
/
oweals
/
musl.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
implement a64l and l64a (legacy xsi stuff)
[oweals/musl.git]
/
src
/
misc
/
a64l.c
1
#include <stdlib.h>
2
#include <string.h>
3
#include <stdint.h>
4
5
static const char digits[] =
6
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
7
8
long a64l(const char *s)
9
{
10
int e;
11
uint32_t x = 0;
12
for (e=0; e<36 && *s; e+=6, s++)
13
x |= (strchr(digits, *s)-digits)<<e;
14
return x;
15
}
16
17
char *l64a(long x0)
18
{
19
static char s[7];
20
char *p;
21
uint32_t x = x0;
22
for (p=s; x; p++, x>>=6)
23
*p = digits[x&63];
24
*p = 0;
25
return s;
26
}