Return TypeFunction nameArguments
hzEcodeBase64Decode(hzChain&,const char*,)

Declared in file: hzCodec.h
Defined in file : hzCodec.cpp

Function Logic:

0:START 1:hzChain::Clear strlen nBytes 2:nBytes%4 3:Return hzerr(E_FORMAT,Supplied string is not an exact multiple of 4 bytes in length) 4:*i; 5:a items b items c items d items 6:a==101||b==101||c==101||d==101 7:Return E_FORMAT 8:val 9:a<100 10:val 11:b<100 12:val 13:c<100 14:val 15:d<100 16:val 17:a b c hzChain::AddByte 18:b 19:hzChain::AddByte 20:c 21:hzChain::AddByte 22:*i==(char)10 23:items 24:*i==(char)13 25:items 26:Return E_OK

Function body:

hzEcode Base64Decode (hzChain& Decoded, const char* s)
{
   _hzfunc("Base64Decode(cstr)") ;
   const char* i ;
   int32_t     nBytes ;
   int32_t     val ;
   int32_t     a ;
   int32_t     b ;
   int32_t     c ;
   int32_t     d ;
   Decoded.Clear() ;
   nBytes = strlen(s) ;
   if (nBytes % 4)
       return hzerr(E_FORMAT, "Supplied string is not an exact multiple of 4 bytes in length") ;
   for (i = s ; *i ;)
   {
       a = _get6bit(*i) ; i++ ;
       b = _get6bit(*i) ; i++ ;
       c = _get6bit(*i) ; i++ ;
       d = _get6bit(*i) ; i++ ;
       if (a == 101||b== 101||c== 101||d== 101)
           return E_FORMAT ;
       val = 0;
       if (a < 100)val += (a << 18);
       if (b < 100)val += (b << 12);
       if (c < 100)val += (c << 6);
       if (d < 100)val += d ;
       a = (val & 0xff0000)>>16;
       b = (val & 0xff00)>>8;
       c = val & 0xff;
       Decoded.AddByte(a) ;
       if (b)
           Decoded.AddByte(b) ;
       if (c)
           Decoded.AddByte(c) ;
       if (*i == CHAR_NL)  i++ ;
       if (*i == CHAR_CR)  i++ ;
   }
   return E_OK ;
}