From 21afc7dc291f1cb11feec7a9766bf3542545f581 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sun, 3 Sep 2006 15:49:40 +0000 Subject: uuencode: common implementation for wget and uuencode (closing bug 694) --- networking/wget.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'networking/wget.c') diff --git a/networking/wget.c b/networking/wget.c index 755515262..c3b9fc039 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -98,29 +98,11 @@ static char *safe_fgets(char *s, int size, FILE *stream) #ifdef CONFIG_FEATURE_WGET_AUTHENTICATION /* - * Base64-encode character string - * oops... isn't something similar in uuencode.c? - * XXX: It would be better to use already existing code + * Base64-encode character string and return the string. */ static char *base64enc(unsigned char *p, char *buf, int len) { - char al[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" - "0123456789+/"; - char *s = buf; - - while(*p) { - if (s >= buf+len-4) - bb_error_msg_and_die("buffer overflow"); - *(s++) = al[(*p >> 2) & 0x3F]; - *(s++) = al[((*p << 4) & 0x30) | ((*(p+1) >> 4) & 0x0F)]; - *s = *(s+1) = '='; - *(s+2) = 0; - if (! *(++p)) break; - *(s++) = al[((*p << 2) & 0x3C) | ((*(p+1) >> 6) & 0x03)]; - if (! *(++p)) break; - *(s++) = al[*(p++) & 0x3F]; - } - + bb_uuencode(p, buf, len, bb_uuenc_tbl_base64); return buf; } #endif -- cgit v1.2.3