compress: compressor: convert b_compressor to a b_object interface
This commit is contained in:
@@ -1,29 +1,67 @@
|
||||
#ifndef BLUELIB_COMPRESS_COMPRESSOR_H_
|
||||
#define BLUELIB_COMPRESS_COMPRESSOR_H_
|
||||
#ifndef BLUE_COMPRESS_COMPRESSOR_H_
|
||||
#define BLUE_COMPRESS_COMPRESSOR_H_
|
||||
|
||||
#include <blue/core/macros.h>
|
||||
#include <blue/core/misc.h>
|
||||
#include <blue/core/ringbuffer.h>
|
||||
#include <blue/core/status.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
struct b_ringbuffer;
|
||||
struct b_compression_function;
|
||||
B_DECLS_BEGIN;
|
||||
|
||||
enum b_compression_mode;
|
||||
typedef enum b_compressor_mode {
|
||||
B_COMPRESSOR_MODE_NONE = 0,
|
||||
B_COMPRESSOR_MODE_COMPRESS,
|
||||
B_COMPRESSOR_MODE_DECOMPRESS,
|
||||
} b_compressor_mode;
|
||||
|
||||
typedef struct b_compressor b_compressor;
|
||||
typedef enum b_compressor_flags {
|
||||
B_COMPRESSOR_EOF = 0x01u,
|
||||
} b_compressor_flags;
|
||||
|
||||
#define B_TYPE_COMPRESSOR (b_compressor_get_type())
|
||||
|
||||
B_DECLARE_TYPE(b_compressor);
|
||||
|
||||
B_TYPE_CLASS_DECLARATION_BEGIN(b_compressor)
|
||||
b_status (*c_buffer_size)(b_compressor_mode, size_t *, size_t *);
|
||||
b_status (*c_set_mode)(b_compressor *, b_compressor_mode);
|
||||
b_status (*c_compress)(b_compressor *);
|
||||
b_status (*c_compress_end)(b_compressor *);
|
||||
b_status (*c_decompress)(b_compressor *);
|
||||
b_status (*c_reset)(b_compressor *);
|
||||
B_TYPE_CLASS_DECLARATION_END(b_compressor)
|
||||
|
||||
typedef struct b_compressor_data {
|
||||
b_compressor_flags c_flags;
|
||||
b_compressor_mode c_mode;
|
||||
b_ringbuffer *c_in, *c_out;
|
||||
} b_compressor_data;
|
||||
|
||||
BLUE_API b_type b_compressor_get_type(void);
|
||||
|
||||
#if 0
|
||||
BLUE_API b_status b_compressor_create(
|
||||
const struct b_compression_function *func, enum b_compression_mode mode,
|
||||
struct b_ringbuffer *inbuf, struct b_ringbuffer *outbuf,
|
||||
b_compressor **out);
|
||||
BLUE_API b_status b_compressor_destroy(b_compressor *compressor);
|
||||
#endif
|
||||
|
||||
BLUE_API b_status b_compressor_get_buffer_size(
|
||||
const b_compressor *compressor, size_t *inbuf_size, size_t *outbuf_size);
|
||||
b_type type, b_compressor_mode mode, size_t *inbuf_size,
|
||||
size_t *outbuf_size);
|
||||
|
||||
BLUE_API b_status b_compressor_get_mode(
|
||||
const b_compressor *compressor, b_compressor_mode *out);
|
||||
BLUE_API b_status b_compressor_set_mode(
|
||||
b_compressor *compressor, b_compressor_mode mode);
|
||||
BLUE_API b_status b_compressor_set_buffer(
|
||||
b_compressor *compressor, b_ringbuffer *inbuf, b_ringbuffer *outbuf);
|
||||
BLUE_API b_status b_compressor_step(b_compressor *compressor);
|
||||
BLUE_API b_status b_compressor_end(b_compressor *compressor);
|
||||
BLUE_API b_status b_compressor_reset(b_compressor *compressor);
|
||||
BLUE_API bool b_compressor_eof(const b_compressor *compressor);
|
||||
|
||||
B_DECLS_END;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
#ifndef BLUELIB_COMPRESS_FUNCTION_H_
|
||||
#define BLUELIB_COMPRESS_FUNCTION_H_
|
||||
|
||||
#include <blue/core/misc.h>
|
||||
#include <blue/core/status.h>
|
||||
|
||||
enum b_compressor_mode;
|
||||
|
||||
typedef struct b_compression_function b_compression_function;
|
||||
|
||||
typedef enum b_compression_function_id {
|
||||
B_COMPRESSOR_FUNCTION_NONE = 0,
|
||||
B_COMPRESSOR_FUNCTION_ZSTD,
|
||||
} b_compression_function_id;
|
||||
|
||||
typedef enum b_compression_mode {
|
||||
B_COMPRESSION_MODE_COMPRESS,
|
||||
B_COMPRESSION_MODE_DECOMPRESS,
|
||||
} b_compression_mode;
|
||||
|
||||
BLUE_API const b_compression_function *b_compression_function_get_by_id(
|
||||
b_compression_function_id id);
|
||||
BLUE_API b_status b_compression_function_get_buffer_size(
|
||||
const b_compression_function *func, enum b_compression_mode mode,
|
||||
size_t *inbuf_size, size_t *outbuf_size);
|
||||
|
||||
#endif
|
||||
28
compress/include/blue/compress/zstd.h
Normal file
28
compress/include/blue/compress/zstd.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef BLUE_COMPRESS_ZSTD_H_
|
||||
#define BLUE_COMPRESS_ZSTD_H_
|
||||
|
||||
#include <blue/compress/compressor.h>
|
||||
#include <blue/core/macros.h>
|
||||
#include <blue/core/misc.h>
|
||||
#include <blue/core/status.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
B_DECLS_BEGIN;
|
||||
|
||||
#define B_TYPE_ZSTD_COMPRESSOR (b_zstd_compressor_get_type())
|
||||
|
||||
B_DECLARE_TYPE(b_zstd_compressor);
|
||||
|
||||
B_TYPE_CLASS_DECLARATION_BEGIN(b_zstd_compressor)
|
||||
B_TYPE_CLASS_DECLARATION_END(b_compressor)
|
||||
|
||||
BLUE_API b_type b_zstd_compressor_get_type(void);
|
||||
|
||||
BLUE_API b_status b_zstd_compressor_get_buffer_size(
|
||||
b_compressor_mode mode, size_t *inbuf_size, size_t *outbuf_size);
|
||||
|
||||
B_TYPE_DEFAULT_CONSTRUCTOR(b_zstd_compressor, B_TYPE_ZSTD_COMPRESSOR);
|
||||
|
||||
B_DECLS_END;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user