util: expose urlsafe_base64char()
This commit is contained in:
@@ -526,6 +526,16 @@ char base64char(int x) {
|
||||
return table[x & 63];
|
||||
}
|
||||
|
||||
/* This is almost base64char(), but not entirely, as it uses the "url and filename safe" alphabet,
|
||||
* since we don't want "/" appear in interface names (since interfaces appear in sysfs as filenames).
|
||||
* See section #5 of RFC 4648. */
|
||||
char urlsafe_base64char(int x) {
|
||||
static const char table[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789-_";
|
||||
return table[x & 63];
|
||||
}
|
||||
|
||||
int unbase64char(char c) {
|
||||
unsigned offset;
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ char base32hexchar(int x) _const_;
|
||||
int unbase32hexchar(char c) _const_;
|
||||
|
||||
char base64char(int x) _const_;
|
||||
char urlsafe_base64char(int x) _const_;
|
||||
int unbase64char(char c) _const_;
|
||||
|
||||
char *base32hexmem(const void *p, size_t l, bool padding);
|
||||
|
||||
Reference in New Issue
Block a user