llbase64.cpp

Go to the documentation of this file.
00001 
00033 #include "linden_common.h"
00034 
00035 #include "llbase64.h"
00036 
00037 #include <string>
00038 
00039 #include "apr-1/apr_base64.h"
00040 
00041 
00042 // static
00043 std::string LLBase64::encode(const U8* input, size_t input_size)
00044 {
00045         std::string output;
00046         if (input
00047                 && input_size > 0)
00048         {
00049                 // Yes, it returns int.
00050                 int b64_buffer_length = apr_base64_encode_len(input_size);
00051                 char* b64_buffer = new char[b64_buffer_length];
00052                 
00053                 // This is faster than apr_base64_encode() if you know
00054                 // you're not on an EBCDIC machine.  Also, the output is
00055                 // null terminated, even though the documentation doesn't
00056                 // specify.  See apr_base64.c for details. JC
00057                 b64_buffer_length = apr_base64_encode_binary(
00058                         b64_buffer,
00059                         input,
00060                         input_size);
00061                 output.assign(b64_buffer);
00062                 delete[] b64_buffer;
00063         }
00064         return output;
00065 }
00066 

Generated on Thu Jul 1 06:08:19 2010 for Second Life Viewer by  doxygen 1.4.7