diff --git a/compress/compressor.c b/compress/compressor.c index 5b483f0..ad0ca7f 100644 --- a/compress/compressor.c +++ b/compress/compressor.c @@ -8,7 +8,7 @@ #include enum b_status b_compressor_create( - const struct b_compression_function *func, enum b_compressor_mode mode, + const struct b_compression_function *func, enum b_compression_mode mode, struct b_ringbuffer *inbuf, struct b_ringbuffer *outbuf, struct b_compressor **out) { @@ -59,7 +59,7 @@ enum b_status b_compressor_destroy(struct b_compressor *compressor) enum b_status b_compressor_compress(struct b_compressor *compressor) { - if (compressor->c_mode != B_COMPRESSOR_MODE_COMPRESS) { + if (compressor->c_mode != B_COMPRESSION_MODE_COMPRESS) { return B_ERR_BAD_STATE; } @@ -96,7 +96,7 @@ enum b_status b_compressor_compress_end(struct b_compressor *compressor) enum b_status b_compressor_decompress(struct b_compressor *compressor) { - if (compressor->c_mode != B_COMPRESSOR_MODE_DECOMPRESS) { + if (compressor->c_mode != B_COMPRESSION_MODE_DECOMPRESS) { return B_ERR_BAD_STATE; } diff --git a/compress/compressor.h b/compress/compressor.h index ce47de4..168391f 100644 --- a/compress/compressor.h +++ b/compress/compressor.h @@ -2,8 +2,8 @@ #define _COMPRESSOR_H_ #include +#include -struct b_compression_function; struct b_ringbuffer; enum compressor_flags { @@ -12,7 +12,7 @@ enum compressor_flags { struct b_compressor { enum compressor_flags c_flags; - enum b_compressor_mode c_mode; + enum b_compression_mode c_mode; const struct b_compression_function *c_func; struct b_ringbuffer *c_in, *c_out; }; diff --git a/compress/function.c b/compress/function.c index 5a2cd82..44e1a12 100644 --- a/compress/function.c +++ b/compress/function.c @@ -26,7 +26,7 @@ const struct b_compression_function *b_compression_function_get_by_id( } enum b_status b_compression_function_get_buffer_size( - const struct b_compression_function *func, enum b_compressor_mode mode, + const struct b_compression_function *func, enum b_compression_mode mode, size_t *inbuf_size, size_t *outbuf_size) { if (!func->f_buffer_size) { diff --git a/compress/function.h b/compress/function.h index 7a1133e..f65adef 100644 --- a/compress/function.h +++ b/compress/function.h @@ -11,7 +11,7 @@ struct b_compression_function { const char *f_name; size_t f_ctx_size; - enum b_status (*f_buffer_size)(enum b_compressor_mode, size_t *, size_t *); + enum b_status (*f_buffer_size)(enum b_compression_mode, size_t *, size_t *); enum b_status (*f_init)(struct b_compressor *); enum b_status (*f_fini)(struct b_compressor *); diff --git a/compress/function/zstd.c b/compress/function/zstd.c index e369fe5..d5ba8cc 100644 --- a/compress/function/zstd.c +++ b/compress/function/zstd.c @@ -12,14 +12,14 @@ struct zstd_ctx { }; static enum b_status buffer_size( - enum b_compressor_mode mode, size_t *inbuf_size, size_t *outbuf_size) + enum b_compression_mode mode, size_t *inbuf_size, size_t *outbuf_size) { switch (mode) { - case B_COMPRESSOR_MODE_COMPRESS: + case B_COMPRESSION_MODE_COMPRESS: *inbuf_size = ZSTD_CStreamInSize(); *outbuf_size = ZSTD_CStreamOutSize(); break; - case B_COMPRESSOR_MODE_DECOMPRESS: + case B_COMPRESSION_MODE_DECOMPRESS: *inbuf_size = ZSTD_DStreamInSize(); *outbuf_size = ZSTD_DStreamOutSize(); break; @@ -34,13 +34,13 @@ static enum b_status init(struct b_compressor *compressor) { struct zstd_ctx *ctx = b_compressor_get_function_ctx(compressor); switch (compressor->c_mode) { - case B_COMPRESSOR_MODE_COMPRESS: + case B_COMPRESSION_MODE_COMPRESS: ctx->zstd_c = ZSTD_createCCtx(); if (!ctx->zstd_c) { return B_ERR_NO_MEMORY; } break; - case B_COMPRESSOR_MODE_DECOMPRESS: + case B_COMPRESSION_MODE_DECOMPRESS: ctx->zstd_d = ZSTD_createDCtx(); if (!ctx->zstd_d) { return B_ERR_NO_MEMORY; @@ -57,10 +57,10 @@ static enum b_status fini(struct b_compressor *compressor) { struct zstd_ctx *ctx = b_compressor_get_function_ctx(compressor); switch (compressor->c_mode) { - case B_COMPRESSOR_MODE_COMPRESS: + case B_COMPRESSION_MODE_COMPRESS: ZSTD_freeCCtx(ctx->zstd_c); break; - case B_COMPRESSOR_MODE_DECOMPRESS: + case B_COMPRESSION_MODE_DECOMPRESS: ZSTD_freeDCtx(ctx->zstd_d); break; default: @@ -74,10 +74,10 @@ static enum b_status reset(struct b_compressor *compressor) { struct zstd_ctx *ctx = b_compressor_get_function_ctx(compressor); switch (compressor->c_mode) { - case B_COMPRESSOR_MODE_COMPRESS: + case B_COMPRESSION_MODE_COMPRESS: ZSTD_CCtx_reset(ctx->zstd_c, ZSTD_reset_session_only); break; - case B_COMPRESSOR_MODE_DECOMPRESS: + case B_COMPRESSION_MODE_DECOMPRESS: ZSTD_DCtx_reset(ctx->zstd_d, ZSTD_reset_session_only); break; default: diff --git a/compress/include/blue/compress/compressor.h b/compress/include/blue/compress/compressor.h index 3f732ad..4832d53 100644 --- a/compress/include/blue/compress/compressor.h +++ b/compress/include/blue/compress/compressor.h @@ -8,15 +8,12 @@ struct b_ringbuffer; struct b_compression_function; +enum b_compression_mode; + typedef struct b_compressor b_compressor; -typedef enum b_compressor_mode { - B_COMPRESSOR_MODE_COMPRESS, - B_COMPRESSOR_MODE_DECOMPRESS, -} b_compressor_mode; - BLUE_API b_status b_compressor_create( - const struct b_compression_function *func, b_compressor_mode mode, + 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); diff --git a/compress/include/blue/compress/function.h b/compress/include/blue/compress/function.h index b4d248d..b4bc68c 100644 --- a/compress/include/blue/compress/function.h +++ b/compress/include/blue/compress/function.h @@ -13,10 +13,15 @@ typedef enum b_compression_function_id { 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_compressor_mode mode, + const b_compression_function *func, enum b_compression_mode mode, size_t *inbuf_size, size_t *outbuf_size); #endif