From 8747cd034a460597a78c4ac616c13e3c981ff1d3 Mon Sep 17 00:00:00 2001 From: Konstantin Serebryany Date: Tue, 3 Jun 2014 16:39:08 +0530 Subject: Remove redundant nested function b64_from_24bit Move multiple definitions of the nested function b64_from_24bit into a single function __b64_from_24bit. --- crypt/crypt_util.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'crypt/crypt_util.c') diff --git a/crypt/crypt_util.c b/crypt/crypt_util.c index 287593142b..9381d67194 100644 --- a/crypt/crypt_util.c +++ b/crypt/crypt_util.c @@ -253,6 +253,10 @@ static ufc_long eperm32tab[4][256][2]; */ static ufc_long efp[16][64][2]; +/* Table with characters for base64 transformation. */ +static const char b64t[64] = +"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + /* * For use by the old, non-reentrant routines * (crypt/encrypt/setkey) @@ -956,3 +960,17 @@ setkey(__key) { __setkey_r(__key, &_ufc_foobar); } + +void +__b64_from_24bit (char **cp, int *buflen, + unsigned int b2, unsigned int b1, unsigned int b0, + int n) +{ + unsigned int w = (b2 << 16) | (b1 << 8) | b0; + while (n-- > 0 && (*buflen) > 0) + { + *(*cp)++ = b64t[w & 0x3f]; + --(*buflen); + w >>= 6; + } +} -- cgit v1.2.3