lzfu.c File Reference

Compressed RTF related functions. More...

#include "libmapi/libmapi.h"
#include "libmapi/libmapi_private.h"
#include <ctype.h>

Macros

#define LE16_CPU(x)
 
#define LE32_CPU(x)
 
#define LZFU_COMPRESSED   0x75465a4c
 
#define LZFU_DICTLENGTH   0x1000
 
#define LZFU_HEADERLENGTH   0x10
 
#define LZFU_INITDICT
 
#define LZFU_INITLENGTH   207
 
#define LZFU_UNCOMPRESSED   0x414c454d
 
#define MIN(a, b)   ((a) < (b) ? (a) : (b))
 

Typedefs

typedef struct _decompression_state decompression_state
 
typedef struct _dictionaryref dictionaryref
 
typedef struct _lzfuheader lzfuheader
 
typedef struct _output_state output_state
 

Functions

uint32_t calculateCRC (uint8_t *input, uint32_t offset, uint32_t length)
 
_PUBLIC_ enum MAPISTATUS compress_rtf (TALLOC_CTX *mem_ctx, const char *rtf, const size_t rtf_size, uint8_t **rtfcomp, size_t *rtfcomp_size)
 
_PUBLIC_ enum MAPISTATUS uncompress_rtf (TALLOC_CTX *mem_ctx, uint8_t *rtfcomp, uint32_t in_size, DATA_BLOB *rtf)
 
_PUBLIC_ enum MAPISTATUS WrapCompressedRTFStream (mapi_object_t *obj_stream, DATA_BLOB *rtf)
 

Detailed Description

Compressed RTF related functions.

Macro Definition Documentation

#define LE16_CPU (   x)
Value:
x = ((((x) & 0xff00) >> 8) | \
(((x) & 0x00ff) << 8));
#define LE32_CPU (   x)
Value:
x = ((((x) & 0xff000000) >> 24) | \
(((x) & 0x00ff0000) >> 8 ) | \
(((x) & 0x0000ff00) << 8 ) | \
(((x) & 0x000000ff) << 24));
#define LZFU_COMPRESSED   0x75465a4c

Referenced by compress_rtf().

#define LZFU_DICTLENGTH   0x1000

Referenced by compress_rtf().

#define LZFU_HEADERLENGTH   0x10
#define LZFU_INITDICT
Value:
"{\\rtf1\\ansi\\mac\\deff0\\deftab720{\\fonttbl;}" \
"{\\f0\\fnil \\froman \\fswiss \\fmodern \\fscrip" \
"t \\fdecor MS Sans SerifSymbolArialTimes Ne" \
"w RomanCourier{\\colortbl\\red0\\green0\\blue0" \
"\r\n\\par \\pard\\plain\\f0\\fs20\\b\\i\\u\\tab" \
"\\tx"

Referenced by compress_rtf().

#define LZFU_INITLENGTH   207

Referenced by compress_rtf().

#define LZFU_UNCOMPRESSED   0x414c454d

Referenced by uncompress_rtf().

#define MIN (   a,
 
)    ((a) < (b) ? (a) : (b))

Typedef Documentation

typedef struct _decompression_state decompression_state
typedef struct _dictionaryref dictionaryref
typedef struct _lzfuheader lzfuheader
typedef struct _output_state output_state

Function Documentation

uint32_t calculateCRC ( uint8_t *  input,
uint32_t  offset,
uint32_t  length 
)

Referenced by compress_rtf().

_PUBLIC_ enum MAPISTATUS compress_rtf ( TALLOC_CTX *  mem_ctx,
const char *  rtf,
const size_t  rtf_size,
uint8_t **  rtfcomp,
size_t *  rtfcomp_size 
)
_PUBLIC_ enum MAPISTATUS uncompress_rtf ( TALLOC_CTX *  mem_ctx,
uint8_t *  rtfcomp,
uint32_t  in_size,
DATA_BLOB *  rtf 
)
_PUBLIC_ enum MAPISTATUS WrapCompressedRTFStream ( mapi_object_t obj_stream,
DATA_BLOB *  rtf 
)

creates a DATA_BLOB in uncompressed Rich Text Format (RTF) from the compressed format used in the PR_RTF_COMPRESSED property opened in the stream.

Parameters
obj_streamstream object with RTF stream content
rtfthe output blob with uncompressed content
Returns
MAPI_E_SUCCESS on success, otherwise MAPI error. Possible MAPI error codes are:
  • MAPI_E_NOT_INITIALIZED: MAPI subsystem has not been initialized
  • MAPI_E_INVALID_PARAMETER: obj_stream is not a valid pointer
  • MAPI_E_CORRUPT_DATA: a problem was encountered while decompressing the RTF compressed data
  • MAPI_E_CALL_FAILED: A network problem was encountered during the transaction
Note
Developers may also call GetLastError() to retrieve the last MAPI error code.
rtf->data needs to be freed with MAPIFreeBuffer
See Also
OpenStream

References GetLastError(), mapi_session::mapi_ctx, mapi_object_get_session(), mapi_context::mem_ctx, OPENCHANGE_RETVAL_IF, ReadStream(), and uncompress_rtf().


Creative Commons License
Creative Commons Attribution icon Creative Commons Share Alike icon
This content is licensed under the Creative Commons
Attribution ShareAlike License v. 3.0:
http://creativecommons.org/licenses/by-sa/3.0/