On Tue, Oct 18, 2011 at 8:57 AM, Leonid Lisovskiy <[email protected]> wrote: > On Tue, Oct 18, 2011 at 2:32 AM, Denys Vlasenko > <[email protected]> wrote: >> On Saturday 01 October 2011 18:02, Leonid Lisovskiy wrote: >>> This patch adds into libbb decode_base64() function to decode base64 >>> string. Needs for DHCPv6 authorization keys decode. >> >> Cut-and-paste programming - you just copied read_base64() >> and tweaked the part where it gets next byte. > > I know :( > >> Busybox is about minimizing size, therefore code duplication >> isn't a good idea. > > I'm absolutely agree, but another way to share code, requires two > callback functions returning next char/putting next char. Is it > acceptable? Can you advice more pretty & compact solution?
After you created decode_base64 which operates on string, rewrite read_base64 to use it (say, by loop "read up to N*4 bytes, decode them, repeat if no decode error, no EOF and no end char encountered"). This may need some tweaks: decode_base64 should be taught how to decode partial (incomplete) base64 string. -- vda _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
