From 170b8628fabff2d81606cac052a35f8cf91cc7b2 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 27 Nov 2020 20:44:55 +0100 Subject: libbb: smaller and faster decode_base64() function old new delta decode_base64 195 180 -15 Signed-off-by: Denys Vlasenko --- networking/httpd.c | 37 ------------------------------------- 1 file changed, 37 deletions(-) (limited to 'networking/httpd.c') diff --git a/networking/httpd.c b/networking/httpd.c index 961f8cab4..4ffd89c48 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -1017,46 +1017,9 @@ static char *encodeString(const char *string) */ static void decodeBase64(char *Data) { -# if ENABLE_BASE64 || ENABLE_UUDECODE - /* Call decode_base64() from uuencode.c */ char *eptr = Data; decode_base64(&eptr, Data); *eptr = '\0'; -# else - const unsigned char *in = (const unsigned char *)Data; - /* The decoded size will be at most 3/4 the size of the encoded */ - unsigned ch = 0; - int i = 0; - - while (*in) { - int t = *in++; - - if (t >= '0' && t <= '9') - t = t - '0' + 52; - else if (t >= 'A' && t <= 'Z') - t = t - 'A'; - else if (t >= 'a' && t <= 'z') - t = t - 'a' + 26; - else if (t == '+') - t = 62; - else if (t == '/') - t = 63; - else if (t == '=') - t = 0; - else - continue; - - ch = (ch << 6) | t; - i++; - if (i == 4) { - *Data++ = (char) (ch >> 16); - *Data++ = (char) (ch >> 8); - *Data++ = (char) ch; - i = 0; - } - } - *Data = '\0'; -# endif } #endif -- cgit v1.2.3