From 0517eb7d604da454213e42d55f477401dc7f7ebf Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 13 Dec 2014 11:58:08 -0600 Subject: Add base64. The tizen guys wanted this. Yeah, I know there's base64 code in uuencode/uudecode, but that this has -i, input lines aren't of fixed length, encode/decode are in same file, there's no prefix/suffix code, it always writes to stdout... Eliminating the code duplication wouldn't be worth the if/else I'd have to add, so I just did a new one. Factored out the base64 table init into lib.c though: that was worth sharing. --- toys/posix/uuencode.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'toys/posix/uuencode.c') diff --git a/toys/posix/uuencode.c b/toys/posix/uuencode.c index 2323c98d..ca3f10d3 100644 --- a/toys/posix/uuencode.c +++ b/toys/posix/uuencode.c @@ -28,16 +28,7 @@ void uuencode_main(void) if (toys.optc > 1) fd = xopen(toys.optargs[0], O_RDONLY); - // base64 table - - p = toybuf; - for (i = 'A'; i != ':'; i++) { - if (i == 'Z'+1) i = 'a'; - if (i == 'z'+1) i = '0'; - *(p++) = i; - } - *(p++) = '+'; - *(p++) = '/'; + base64_init(toybuf); xprintf("begin%s 744 %s\n", m ? "-base64" : "", name); for (;;) { -- cgit v1.2.3