[PATCH 1/4] dhcp6c: decode_base64()

Denys Vlasenko vda.linux at googlemail.com
Tue Oct 18 10:19:43 UTC 2011


On Tue, Oct 18, 2011 at 8:57 AM, Leonid Lisovskiy <lly.dev at gmail.com> wrote:
> On Tue, Oct 18, 2011 at 2:32 AM, Denys Vlasenko
> <vda.linux at googlemail.com> 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


More information about the busybox mailing list