Logo Search packages:      
Sourcecode: nbsmtp version File versions  Download package

void to64frombits ( unsigned char *  out,
const unsigned char *  in,
int  inlen 
)

Raw bytes in quasi-big-endian order to base 64 string (NUL-terminated).

Parameters:
[out] out A pointer to a char to hold the converted string
[in] in String to convert
[in] inlen Length of the string to be converted

Definition at line 39 of file base64.c.

Referenced by nbsmtp_auth().

{
      for (; inlen >= 3; inlen -= 3)
      {
            *out++ = base64digits[in[0] >> 2];
            *out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)];
            *out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
            *out++ = base64digits[in[2] & 0x3f];
            in += 3;
      }

      if (inlen > 0)
      {
            unsigned char fragment;

            *out++ = base64digits[in[0] >> 2];
            fragment = (in[0] << 4) & 0x30;

            if (inlen > 1)
                  fragment |= in[1] >> 4;

            *out++ = base64digits[fragment];
            *out++ = (inlen < 2) ? '=' : base64digits[(in[1] << 2) & 0x3c];
            *out++ = '=';
      }
      
      *out = '\0';
}


Generated by  Doxygen 1.6.0   Back to index