Google

TOP --> libjdl

class CJdlMime

Apply MIME-64 encoding to a string based on the RFC 1521 standards document.

This class can be used encode a string of characters in MIME format. It handles binary as well as ASCII strings.

Encoding

The basic idea behind encoding is that the user hands the object a pointer to an input string that is composed of plaintext characters and a pointer to an output string that is at least 33% larger than the input string. The object then encodes the input string to the output string. An example is shown below.

 CJdlMime mime;
 uchar *plain = "1234567890 ABCDEFG";
 uchar enc[64];
 mime.Encode(enc,plain);
 cout << enc << endl;
 

Decoding

The basic idea behind decoding is that the user hands the object a pointer to an input string that is composed of encoded characters and a pointer to an output string that is at least 25% smaller than the input string. The object then decodes the input string to the output string. An example is shown below.

 CJdlMime mime;
 uchar* plain = "1234567890 ABCDEFG";
 uchar enc[64]; // These are both much larger than the text to encode.
 uchar dec[64];
 mime.Encode(enc,sizeof(enc),plain,::strlen(plain));
 mime.Decode(dec,sizeof(dec),enc,::strlen(enc));
 cout << dec << endl;
 

Author:
Joe Linoff

Version:
$Id: jdlmime.h,v 1.4 1999/06/12 18:26:00 jdl Exp $

Source:
../../libjdl/src/jdlmime.h:64

Constructors Index

CJdlMime
[public] Constructor.
~CJdlMime
[public] Destructor.


Methods Index

Decode
[public] Decode a sequence of characters. This routine will termine the output string with a NULL. Make sure that you account for this during binary conversions.
DecodeFile
[public] Decode an ASCII file.
Encode
[public] Encode a sequence of characters. This routine will termine the output string with NULL. Make sure that you account for this during binary conversions.
EncodeFile
[public] Encode an ASCII file.
Reset
[public] Reset the internal encode and decode maps.


Constructors

CJdlMime

public CJdlMime ( ) ;

Constructor.

CJdlMime

public ~ CJdlMime ( ) ;

Destructor.


Methods

Encode

public uint Encode ( uchar * out ,
                     uint outlen ,
                     const uchar * in ,
                     uint len ) ;

Encode a sequence of characters. This routine will termine the output string with NULL. Make sure that you account for this during binary conversions.

It is safe to cast char* arguments as unsigned char* in this method.

Parameters:
out The encoded output string. It must be 33% larger than the input string.
outlen The length of the output buffer.
in The input buffer.
inlen The length of the input buffer.

Return:
The number of bytes encoded or zero if the output buffer was too small.

EncodeFile

public void EncodeFile ( const char * out ,
                         const char * in ) ;

Encode an ASCII file.

Parameters:
out The output file name.
in The input file name.

Decode

public uint Decode ( uchar * out ,
                     uint outlen ,
                     const uchar * in ,
                     uint len ) ;

Decode a sequence of characters. This routine will termine the output string with a NULL. Make sure that you account for this during binary conversions.

Parameters:
out The decoded output string.
outlen The length of the output buffer.
in The input buffer.
inlen The length of the input buffer.

Return:
The number of bytes decoded or zero if the output buffer was too small.

DecodeFile

public void DecodeFile ( const char * out ,
                         const char * in ) ;

Decode an ASCII file.

Parameters:
out The output file name.
in The input file name.

Reset

public void Reset ( uchar * enc ,
                    uchar * dec ) ;

Reset the internal encode and decode maps.

Parameters:
enc The new encode map. Must be at least 128 chars.
dec The new decode map. Must be at least 128 chars.

This documentation was generated automatically by the ccdoc tool (version 0.7a).
Click here to submit a bug report or feature request.

Click here to return to the top of the page.