MCS  0.3.3-alpha7
mcs::B64_Codec Class Reference

A Base 64 encoder/decoder. More...

#include <mcs.hh>

Public Member Functions

 B64_Codec ()
 Constructor. More...
 
char * buffer ()
 
unsigned int bufUsed ()
 
unsigned int decode (char *buf_in, int Length, char *par_buf_out=NULL)
 Decode a block of data. More...
 
unsigned int encode (char *buf_in, int Length, char *par_buf_out=NULL, unsigned int linesize=72)
 Encode a block of data. More...
 
 ~B64_Codec ()
 Destructor. More...
 

Private Member Functions

void decodeblock (unsigned char in[4], unsigned char out[3])
 Decode a block of 4'Base64' bytes into 3 binary bytes. More...
 
void encodeblock (unsigned char in[3], unsigned char out[4], int len)
 Encode a block of 3 binary bytes into 4 'Base64' bytes. More...
 
bool eob ()
 Tell if we are at the end of input buffer. More...
 
void freeBuffer ()
 Free internal buffer. More...
 
unsigned char readData ()
 Read one byte from input buffer. More...
 
void requireSpace (unsigned int Length)
 Allocate "Length" bytes in internal buffer. More...
 
void writeData (unsigned char d)
 Write one byte to output buffer. More...
 

Private Attributes

unsigned int blocksout
 Blocks of base64 data already written. More...
 
char * buf_out
 Pointer to output buffer. More...
 
char * bufAllocated
 Pointer to allocated internal buffer. More...
 
unsigned int bufsize
 Size of allocated buffer. More...
 
unsigned int bufused
 Size of data in output buffer. More...
 
char * EOIB
 Pointer to the end of input buffer. More...
 
unsigned int linesize
 Required linesize (when encoding). More...
 
char * pin
 Cursor for input buffer. More...
 
char * pout
 Cursor for output buffer. More...
 
unsigned char precData [4]
 
int precDataCount
 

Static Private Attributes

static const char * cb64 ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
 
static const char * cd64 ="|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq"
 

Detailed Description

A Base 64 encoder/decoder.

For an example on how to use this class see the b64codec.cc file.

Definition at line 7975 of file mcs.hh.

Constructor & Destructor Documentation

◆ B64_Codec()

mcs::B64_Codec::B64_Codec ( )

Constructor.

Definition at line 454 of file Utils.cc.

◆ ~B64_Codec()

mcs::B64_Codec::~B64_Codec ( )

Destructor.

Definition at line 461 of file Utils.cc.

Member Function Documentation

◆ decode()

unsigned int mcs::B64_Codec::decode ( char *  buf_in,
int  Length,
char *  par_buf_out = NULL 
)

Decode a block of data.

If par_buf_out is NULL an internal buffer will be automatically allocated for decoded data. This buffer can be reached through the buffer() method.

If buffers pointed by buf_in and par_buf_out overlaps the result are unpredictable.

Definition at line 609 of file Utils.cc.

◆ decodeblock()

void mcs::B64_Codec::decodeblock ( unsigned char  in[4],
unsigned char  out[3] 
)
private

Decode a block of 4'Base64' bytes into 3 binary bytes.

Definition at line 680 of file Utils.cc.

◆ encode()

unsigned int mcs::B64_Codec::encode ( char *  buf_in,
int  Length,
char *  par_buf_out = NULL,
unsigned int  linesize = 72 
)

Encode a block of data.

If par_buf_out is NULL an internal buffer will be automatically allocated for encoded data. This buffer can be reached through the buffer() method.

If buffers pointed by buf_in and par_buf_out overlaps the result are unpredictable.

Definition at line 523 of file Utils.cc.

◆ encodeblock()

void mcs::B64_Codec::encodeblock ( unsigned char  in[3],
unsigned char  out[4],
int  len 
)
private

Encode a block of 3 binary bytes into 4 'Base64' bytes.

Definition at line 672 of file Utils.cc.

◆ eob()

bool mcs::B64_Codec::eob ( )
private

Tell if we are at the end of input buffer.

Definition at line 491 of file Utils.cc.

◆ freeBuffer()

void mcs::B64_Codec::freeBuffer ( )
private

Free internal buffer.

Definition at line 481 of file Utils.cc.

◆ readData()

unsigned char mcs::B64_Codec::readData ( )
private

Read one byte from input buffer.

Definition at line 499 of file Utils.cc.

◆ requireSpace()

void mcs::B64_Codec::requireSpace ( unsigned int  Length)
private

Allocate "Length" bytes in internal buffer.

Definition at line 467 of file Utils.cc.

◆ writeData()

void mcs::B64_Codec::writeData ( unsigned char  d)
private

Write one byte to output buffer.

Definition at line 513 of file Utils.cc.

Member Data Documentation

◆ blocksout

unsigned int mcs::B64_Codec::blocksout
private

Blocks of base64 data already written.

Definition at line 8018 of file mcs.hh.

◆ buf_out

char* mcs::B64_Codec::buf_out
private

Pointer to output buffer.

Definition at line 8000 of file mcs.hh.

◆ bufAllocated

char* mcs::B64_Codec::bufAllocated
private

Pointer to allocated internal buffer.

Definition at line 7988 of file mcs.hh.

◆ bufsize

unsigned int mcs::B64_Codec::bufsize
private

Size of allocated buffer.

Definition at line 7991 of file mcs.hh.

◆ bufused

unsigned int mcs::B64_Codec::bufused
private

Size of data in output buffer.

Definition at line 8003 of file mcs.hh.

◆ EOIB

char* mcs::B64_Codec::EOIB
private

Pointer to the end of input buffer.

Definition at line 8012 of file mcs.hh.

◆ linesize

unsigned int mcs::B64_Codec::linesize
private

Required linesize (when encoding).

Definition at line 8015 of file mcs.hh.

◆ pin

char* mcs::B64_Codec::pin
private

Cursor for input buffer.

Definition at line 8006 of file mcs.hh.

◆ pout

char* mcs::B64_Codec::pout
private

Cursor for output buffer.

Definition at line 8009 of file mcs.hh.


The documentation for this class was generated from the following files:

mcslogo

MCS (My Customizable Server) ver. 0.3.3-alpha7
Documentation generated on Mon May 28 07:39:41 UTC 2018