41 static const char sixtet_to_base64[] =
42 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
59 if (size == 0 || i == 3) {
62 for (j = 0; j*6 < i*8; ++
j) {
63 *to++ = sixtet_to_base64[ out[
j] ];
66 for (j = i; j < 3; ++
j) {
99 static char base64_to_sixtet[256];
100 static int tab_init = 0;
104 memset( base64_to_sixtet, 0, 256 );
105 for (i = 0; (j = sixtet_to_base64[
i]) !=
'\0'; ++
i) {
106 base64_to_sixtet[
j] =
i;
115 while (*from !=
'\0' && *from !=
'=' ) {
116 if (*from ==
' ' || *from ==
'\n') {
120 in[
i] = base64_to_sixtet[* (
unsigned char *) from];
123 if (*from ==
'\0' || *from ==
'=' || i == 4) {
125 for (j = 0; j*8 < i*6; ++
j) {
155 dest = (
const char *)buf;
167 dest->
Write( buf, out );
173 void idBase64_TestBase64() {
177 src =
"Encode me in base64";
185 src_dict.
SetBool(
"bool",
true);
186 src_dict.
Set(
"value",
"foo");
189 dest.
Encode( (
const byte *)src_fmem.GetDataPtr(), src_fmem.Length() );
194 dest.
Decode( &dest_fmem );
195 dest_fmem.MakeReadOnly();
220 base64_src = (
char *)buffer;
221 base64_src.
Decode( &mem_src );
222 mem_src.MakeReadOnly();
virtual idFile * OpenFileRead(const char *relativePath, bool allowCopyFiles=true, const char *gamedir=NULL)=0
int Decode(byte *to) const
void WriteToFileHandle(idFile *f) const
void Set(const char *key, const char *value)
virtual void FreeFile(void *buffer)=0
void SetFloat(const char *key, float val)
void ReadFromFileHandle(idFile *f)
static class idFileSystem * fileSystem
GLubyte GLubyte GLubyte GLubyte w
void SetBool(const char *key, bool val)
virtual void Printf(const char *fmt,...) id_attribute((format(printf
const char * c_str() const
void EnsureAlloced(int size)
int IntForSixtets(byte *in)
virtual int Write(const void *buffer, int len)
int DecodeLength(void) const
void Encode(const byte *from, int size)
const char * c_str(void) const
void SixtetsForInt(byte *out, int src)
virtual void CloseFile(idFile *f)=0
static class idCommon * common