base64: Reformat _bin_to_base64()

Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit fe9991b3c6)
This commit is contained in:
Andreas Schneider
2019-10-31 16:22:20 +01:00
parent 31f65d1ffb
commit d5b10f569d

View File

@@ -234,9 +234,11 @@ static int get_equals(char *string) {
}
/* thanks sysk for debugging my mess :) */
static void _bin_to_base64(unsigned char *dest,
const unsigned char source[3],
int len)
{
#define BITS(n) ((1 << (n)) - 1)
static void _bin_to_base64(unsigned char *dest, const unsigned char source[3],
int len) {
switch (len) {
case 1:
dest[0] = alphabet[(source[0] >> 2)];
@@ -257,6 +259,7 @@ static void _bin_to_base64(unsigned char *dest, const unsigned char source[3],
dest[3] = alphabet[source[2] & BITS(6)];
break;
}
#undef BITS
}
/**