libacfutils
A general purpose library of utility functions designed to make it easier to develop addons for the X-Plane flight simulator.
Loading...
Searching...
No Matches
Functions
compress.h File Reference
#include "types.h"
Include dependency graph for compress.h:

Go to the source code of this file.

Functions

bool_t zlib_test (const void *in_buf, size_t len)
 
void * zlib_compress (void *in_buf, size_t len, size_t *out_len)
 
void * zlib_decompress (void *in_buf, size_t len, size_t *out_len_p)
 
bool_t test_7z (const void *in_buf, size_t len)
 
void * decompress_7z (const char *filename, size_t *out_len)
 
void * decompress_zip (void *in_buf, size_t len, size_t *out_len)
 

Detailed Description

This file contains various compression/decompression utility functions.

Definition in file compress.h.

Function Documentation

◆ decompress_7z()

void * decompress_7z ( const char *  filename,
size_t *  out_len 
)

Decompresses the first file contained in a 7-zip archive and returns its contents.

Parameters
filenameThe full path to the file holding the 7-zip archive.
out_lenReturn argument, which will be filled with the amount of bytes contained in the returned decompressed buffer.
Returns
A buffer containing the decompressed file data, or NULL if decompression failed.
Free the returned data using lacf_free().

Definition at line 61 of file compress_7z.c.

◆ decompress_zip()

void * decompress_zip ( void *  in_buf,
size_t  len,
size_t *  out_len 
)

Definition at line 49 of file compress_zip.c.

◆ test_7z()

bool_t test_7z ( const void *  in_buf,
size_t  len 
)

Performs a light-weight & quick test to see if some data might constitute a 7-zip archive.

Parameters
in_bufInput buffer to test.
lenNumber of bytes in in_buf.
Returns
B_TRUE if the data MAY be a 7-zip archive, B_FALSE if definitely not.

Definition at line 41 of file compress_7z.c.

◆ zlib_compress()

void * zlib_compress ( void *  in_buf,
size_t  len,
size_t *  out_len 
)

Compresses a chunk of data using the zlib algorithm and returns it. The compression ratio applied is the default zlib value (equivalent to "gzip -6").

Parameters
in_bufInput data buffer to be compressed.
lenNumber of bytes in ‘in_buf’.
out_lenOutput variable which will be filled the number of bytes contained in the compressed output.
Returns
Returns a pointer to the output buffer containing the zlib-compressed data. Returns NULL on an internal compressor error.
Use lacf_free() to free the returned buffer.

Definition at line 65 of file compress_zlib.c.

◆ zlib_decompress()

void * zlib_decompress ( void *  in_buf,
size_t  len,
size_t *  out_len_p 
)

Decompresses a chunk of data previously compressed using the zlib algorithm. Same arguments as zlib_compress().

Returns
The decompressed data, or NULL on error, or if the input data doesn't look like valid zlib compressed data.
Use lacf_free() to free the returned buffer.

Definition at line 128 of file compress_zlib.c.

◆ zlib_test()

bool_t zlib_test ( const void *  in_buf,
size_t  len 
)

Performs a light-weight & quick test to see if some data might constitute zlib-compressed data. Please note that zlib data is NOT the same as a Gzip (.gz) file. A .gz file contains additional metadata that these functions do not understand.

Parameters
in_bufInput buffer to check.
lenInput buffer length in bytes.
Returns
B_TRUE if the data MAY contain zlib data, B_FALSE if definitely not.

Definition at line 40 of file compress_zlib.c.