mirror of
https://github.com/emmanuel-marty/lzsa.git
synced 2025-02-10 10:31:26 +00:00
Avoid forward declarations
This commit is contained in:
parent
3eaf926c1a
commit
bea90736d5
@ -39,9 +39,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Forward declaration */
|
|
||||||
typedef enum _lzsa_status_t lzsa_status_t;
|
|
||||||
|
|
||||||
/*-------------- File API -------------- */
|
/*-------------- File API -------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
18
src/lib.h
18
src/lib.h
@ -48,24 +48,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** High level status for compression and decompression */
|
|
||||||
typedef enum _lzsa_status_t {
|
|
||||||
LZSA_OK = 0, /**< Success */
|
|
||||||
LZSA_ERROR_SRC, /**< Error reading input */
|
|
||||||
LZSA_ERROR_DST, /**< Error reading output */
|
|
||||||
LZSA_ERROR_DICTIONARY, /**< Error reading dictionary */
|
|
||||||
LZSA_ERROR_MEMORY, /**< Out of memory */
|
|
||||||
|
|
||||||
/* Compression-specific status codes */
|
|
||||||
LZSA_ERROR_COMPRESSION, /**< Internal compression error */
|
|
||||||
LZSA_ERROR_RAW_TOOLARGE, /**< Input is too large to be compressed to a raw block */
|
|
||||||
LZSA_ERROR_RAW_UNCOMPRESSED, /**< Input is incompressible and raw blocks don't support uncompressed data */
|
|
||||||
|
|
||||||
/* Decompression-specific status codes */
|
|
||||||
LZSA_ERROR_FORMAT, /**< Invalid input format or magic number when decompressing */
|
|
||||||
LZSA_ERROR_DECOMPRESSION /**< Internal decompression error */
|
|
||||||
} lzsa_status_t;
|
|
||||||
|
|
||||||
/* Compression flags */
|
/* Compression flags */
|
||||||
#define LZSA_FLAG_FAVOR_RATIO (1<<0) /**< 1 to compress with the best ratio, 0 to trade some compression ratio for extra decompression speed */
|
#define LZSA_FLAG_FAVOR_RATIO (1<<0) /**< 1 to compress with the best ratio, 0 to trade some compression ratio for extra decompression speed */
|
||||||
#define LZSA_FLAG_RAW_BLOCK (1<<1) /**< 1 to emit raw block */
|
#define LZSA_FLAG_RAW_BLOCK (1<<1) /**< 1 to emit raw block */
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "matchfinder.h"
|
#include "matchfinder.h"
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "lib.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hash index into TAG_BITS
|
* Hash index into TAG_BITS
|
||||||
|
@ -33,14 +33,12 @@
|
|||||||
#ifndef _MATCHFINDER_H
|
#ifndef _MATCHFINDER_H
|
||||||
#define _MATCHFINDER_H
|
#define _MATCHFINDER_H
|
||||||
|
|
||||||
|
#include "shrink_context.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Forward declarations */
|
|
||||||
typedef struct _lzsa_match lzsa_match;
|
|
||||||
typedef struct _lzsa_compressor lzsa_compressor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse input data, build suffix array and overlaid data structures to speed up match finding
|
* Parse input data, build suffix array and overlaid data structures to speed up match finding
|
||||||
*
|
*
|
||||||
|
@ -33,8 +33,11 @@
|
|||||||
#ifndef _SHRINK_BLOCK_V1_H
|
#ifndef _SHRINK_BLOCK_V1_H
|
||||||
#define _SHRINK_BLOCK_V1_H
|
#define _SHRINK_BLOCK_V1_H
|
||||||
|
|
||||||
/* Forward declarations */
|
#include "shrink_context.h"
|
||||||
typedef struct _lzsa_compressor lzsa_compressor;
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select the most optimal matches, reduce the token count if possible, and then emit a block of compressed LZSA1 data
|
* Select the most optimal matches, reduce the token count if possible, and then emit a block of compressed LZSA1 data
|
||||||
@ -50,4 +53,8 @@ typedef struct _lzsa_compressor lzsa_compressor;
|
|||||||
*/
|
*/
|
||||||
int lzsa_optimize_and_write_block_v1(lzsa_compressor *pCompressor, const unsigned char *pInWindow, const int nPreviousBlockSize, const int nInDataSize, unsigned char *pOutData, const int nMaxOutDataSize);
|
int lzsa_optimize_and_write_block_v1(lzsa_compressor *pCompressor, const unsigned char *pInWindow, const int nPreviousBlockSize, const int nInDataSize, unsigned char *pOutData, const int nMaxOutDataSize);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _SHRINK_BLOCK_V1_H */
|
#endif /* _SHRINK_BLOCK_V1_H */
|
||||||
|
@ -33,8 +33,11 @@
|
|||||||
#ifndef _SHRINK_BLOCK_V2_H
|
#ifndef _SHRINK_BLOCK_V2_H
|
||||||
#define _SHRINK_BLOCK_V2_H
|
#define _SHRINK_BLOCK_V2_H
|
||||||
|
|
||||||
/* Forward declarations */
|
#include "shrink_context.h"
|
||||||
typedef struct _lzsa_compressor lzsa_compressor;
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select the most optimal matches, reduce the token count if possible, and then emit a block of compressed LZSA2 data
|
* Select the most optimal matches, reduce the token count if possible, and then emit a block of compressed LZSA2 data
|
||||||
@ -50,4 +53,8 @@ typedef struct _lzsa_compressor lzsa_compressor;
|
|||||||
*/
|
*/
|
||||||
int lzsa_optimize_and_write_block_v2(lzsa_compressor *pCompressor, const unsigned char *pInWindow, const int nPreviousBlockSize, const int nInDataSize, unsigned char *pOutData, const int nMaxOutDataSize);
|
int lzsa_optimize_and_write_block_v2(lzsa_compressor *pCompressor, const unsigned char *pInWindow, const int nPreviousBlockSize, const int nInDataSize, unsigned char *pOutData, const int nMaxOutDataSize);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _SHRINK_BLOCK_V2_H */
|
#endif /* _SHRINK_BLOCK_V2_H */
|
||||||
|
@ -33,16 +33,13 @@
|
|||||||
#ifndef _SHRINK_STREAMING_H
|
#ifndef _SHRINK_STREAMING_H
|
||||||
#define _SHRINK_STREAMING_H
|
#define _SHRINK_STREAMING_H
|
||||||
|
|
||||||
|
#include "shrink_context.h"
|
||||||
#include "stream.h"
|
#include "stream.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Forward declaration */
|
|
||||||
typedef enum _lzsa_status_t lzsa_status_t;
|
|
||||||
typedef struct _lzsa_stats lzsa_stats;
|
|
||||||
|
|
||||||
/*-------------- File API -------------- */
|
/*-------------- File API -------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
*
|
*
|
||||||
* @param stream stream
|
* @param stream stream
|
||||||
*/
|
*/
|
||||||
static void lzsa_filestream_close(lzsa_stream_t *stream) {
|
static void lzsa_filestream_close(struct _lzsa_stream_t *stream) {
|
||||||
if (stream->obj) {
|
if (stream->obj) {
|
||||||
fclose((FILE*)stream->obj);
|
fclose((FILE*)stream->obj);
|
||||||
stream->obj = NULL;
|
stream->obj = NULL;
|
||||||
@ -64,7 +64,7 @@ static void lzsa_filestream_close(lzsa_stream_t *stream) {
|
|||||||
*
|
*
|
||||||
* @return number of bytes read
|
* @return number of bytes read
|
||||||
*/
|
*/
|
||||||
static size_t lzsa_filestream_read(lzsa_stream_t *stream, void *ptr, size_t size) {
|
static size_t lzsa_filestream_read(struct _lzsa_stream_t *stream, void *ptr, size_t size) {
|
||||||
return fread(ptr, 1, size, (FILE*)stream->obj);
|
return fread(ptr, 1, size, (FILE*)stream->obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ static size_t lzsa_filestream_read(lzsa_stream_t *stream, void *ptr, size_t size
|
|||||||
*
|
*
|
||||||
* @return number of bytes written
|
* @return number of bytes written
|
||||||
*/
|
*/
|
||||||
static size_t lzsa_filestream_write(lzsa_stream_t *stream, void *ptr, size_t size) {
|
static size_t lzsa_filestream_write(struct _lzsa_stream_t *stream, void *ptr, size_t size) {
|
||||||
return fwrite(ptr, 1, size, (FILE*)stream->obj);
|
return fwrite(ptr, 1, size, (FILE*)stream->obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ static size_t lzsa_filestream_write(lzsa_stream_t *stream, void *ptr, size_t siz
|
|||||||
*
|
*
|
||||||
* @return nonzero if the end of the data has been reached, 0 if there is more data
|
* @return nonzero if the end of the data has been reached, 0 if there is more data
|
||||||
*/
|
*/
|
||||||
static int lzsa_filestream_eof(lzsa_stream_t *stream) {
|
static int lzsa_filestream_eof(struct _lzsa_stream_t *stream) {
|
||||||
return feof((FILE*)stream->obj);
|
return feof((FILE*)stream->obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
27
src/stream.h
27
src/stream.h
@ -37,8 +37,23 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Forward declaration */
|
/** High level status for compression and decompression */
|
||||||
typedef struct _lzsa_stream_t lzsa_stream_t;
|
typedef enum _lzsa_status_t {
|
||||||
|
LZSA_OK = 0, /**< Success */
|
||||||
|
LZSA_ERROR_SRC, /**< Error reading input */
|
||||||
|
LZSA_ERROR_DST, /**< Error reading output */
|
||||||
|
LZSA_ERROR_DICTIONARY, /**< Error reading dictionary */
|
||||||
|
LZSA_ERROR_MEMORY, /**< Out of memory */
|
||||||
|
|
||||||
|
/* Compression-specific status codes */
|
||||||
|
LZSA_ERROR_COMPRESSION, /**< Internal compression error */
|
||||||
|
LZSA_ERROR_RAW_TOOLARGE, /**< Input is too large to be compressed to a raw block */
|
||||||
|
LZSA_ERROR_RAW_UNCOMPRESSED, /**< Input is incompressible and raw blocks don't support uncompressed data */
|
||||||
|
|
||||||
|
/* Decompression-specific status codes */
|
||||||
|
LZSA_ERROR_FORMAT, /**< Invalid input format or magic number when decompressing */
|
||||||
|
LZSA_ERROR_DECOMPRESSION /**< Internal decompression error */
|
||||||
|
} lzsa_status_t;
|
||||||
|
|
||||||
/* I/O stream */
|
/* I/O stream */
|
||||||
typedef struct _lzsa_stream_t {
|
typedef struct _lzsa_stream_t {
|
||||||
@ -54,7 +69,7 @@ typedef struct _lzsa_stream_t {
|
|||||||
*
|
*
|
||||||
* @return number of bytes read
|
* @return number of bytes read
|
||||||
*/
|
*/
|
||||||
size_t(*read)(lzsa_stream_t *stream, void *ptr, size_t size);
|
size_t(*read)(struct _lzsa_stream_t *stream, void *ptr, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write to stream
|
* Write to stream
|
||||||
@ -65,7 +80,7 @@ typedef struct _lzsa_stream_t {
|
|||||||
*
|
*
|
||||||
* @return number of bytes written
|
* @return number of bytes written
|
||||||
*/
|
*/
|
||||||
size_t(*write)(lzsa_stream_t *stream, void *ptr, size_t size);
|
size_t(*write)(struct _lzsa_stream_t *stream, void *ptr, size_t size);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,14 +90,14 @@ typedef struct _lzsa_stream_t {
|
|||||||
*
|
*
|
||||||
* @return nonzero if the end of the data has been reached, 0 if there is more data
|
* @return nonzero if the end of the data has been reached, 0 if there is more data
|
||||||
*/
|
*/
|
||||||
int(*eof)(lzsa_stream_t *stream);
|
int(*eof)(struct _lzsa_stream_t *stream);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close stream
|
* Close stream
|
||||||
*
|
*
|
||||||
* @param stream stream
|
* @param stream stream
|
||||||
*/
|
*/
|
||||||
void(*close)(lzsa_stream_t *stream);
|
void(*close)(struct _lzsa_stream_t *stream);
|
||||||
} lzsa_stream_t;
|
} lzsa_stream_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user