Changeset 812a413 for protocols


Ignore:
Timestamp:
2006-06-23T18:15:28Z (19 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
df1694b
Parents:
00ab350
Message:

Added saner base64 encoding function (actually, moved the one from libyahoo2.c
to core, with some changes), which I need for the XML format password garbling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/yahoo/libyahoo2.c

    r00ab350 r812a413  
    695695}
    696696
    697 static char base64digits[] =    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    698                                 "abcdefghijklmnopqrstuvwxyz"
    699                                 "0123456789._";
     697/* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */
    700698static void to_y64(unsigned char *out, const unsigned char *in, int inlen)
    701 /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */
    702 {
    703         for (; inlen >= 3; inlen -= 3)
    704                 {
    705                         *out++ = base64digits[in[0] >> 2];
    706                         *out++ = base64digits[((in[0]<<4) & 0x30) | (in[1]>>4)];
    707                         *out++ = base64digits[((in[1]<<2) & 0x3c) | (in[2]>>6)];
    708                         *out++ = base64digits[in[2] & 0x3f];
    709                         in += 3;
    710                 }
    711         if (inlen > 0)
    712                 {
    713                         unsigned char fragment;
    714 
    715                         *out++ = base64digits[in[0] >> 2];
    716                         fragment = (in[0] << 4) & 0x30;
    717                         if (inlen > 1)
    718                                 fragment |= in[1] >> 4;
    719                         *out++ = base64digits[fragment];
    720                         *out++ = (inlen < 2) ? '-'
    721                                         : base64digits[(in[1] << 2) & 0x3c];
    722                         *out++ = '-';
    723                 }
    724         *out = '\0';
     699{
     700        return base64_encode_real(in, inlen, out, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
    725701}
    726702
Note: See TracChangeset for help on using the changeset viewer.