From 9a05d8f47b5fa5595dc2b3d65344f0ce77106f4b Mon Sep 17 00:00:00 2001 From: Andrew Aladjev Date: Fri, 30 Aug 2019 22:18:19 +0300 Subject: [PATCH] renamed flush compressor to finish (more traditional) --- CMakeLists.txt | 2 +- README.md | 2 +- man/generic/CMakeLists.txt | 2 +- man/generic/lzws_compress.3.txt | 2 +- man/generic/lzws_compressor_free_state.3.txt | 2 +- man/generic/lzws_compressor_get_initial_state.3.txt | 2 +- man/generic/lzws_compressor_write_magic_header.3.txt | 2 +- ...compressor.3.txt => lzws_finish_compressor.3.txt} | 12 +++++++----- src/compressor/main.c | 5 ++++- src/compressor/main.h | 5 ++++- src/examples/generic/main.c | 4 ++-- src/file.c | 2 +- src/string.c | 2 +- 13 files changed, 26 insertions(+), 18 deletions(-) rename man/generic/{lzws_flush_compressor.3.txt => lzws_finish_compressor.3.txt} (81%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c63129e2..45f6b343 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) message (FATAL_ERROR "In-source builds are not allowed") endif () -set (LZWS_VERSION "1.1.1") +set (LZWS_VERSION "1.2.0") if (NOT DEFINED CMAKE_INSTALL_LIBDIR) set (CMAKE_INSTALL_LIBDIR "lib" CACHE PATH "output directory for libraries") diff --git a/README.md b/README.md index df817489..fa0b1464 100644 --- a/README.md +++ b/README.md @@ -206,7 +206,7 @@ Generic API: - [lzws_decompressor_free_state.3](man/generic/lzws_decompressor_free_state.3.txt) - [lzws_decompressor_get_initial_state.3](man/generic/lzws_decompressor_get_initial_state.3.txt) - [lzws_decompressor_read_magic_header.3](man/generic/lzws_decompressor_read_magic_header.3.txt) -- [lzws_flush_compressor.3](man/generic/lzws_flush_compressor.3.txt) +- [lzws_finish_compressor.3](man/generic/lzws_finish_compressor.3.txt) - [lzws_resize_buffer.3](man/generic/lzws_resize_buffer.3.txt) ## Documentation diff --git a/man/generic/CMakeLists.txt b/man/generic/CMakeLists.txt index a25d90fd..d81473b6 100644 --- a/man/generic/CMakeLists.txt +++ b/man/generic/CMakeLists.txt @@ -8,5 +8,5 @@ add_man_target ("lzws_decompress.3" "man3") add_man_target ("lzws_decompressor_free_state.3" "man3") add_man_target ("lzws_decompressor_get_initial_state.3" "man3") add_man_target ("lzws_decompressor_read_magic_header.3" "man3") -add_man_target ("lzws_flush_compressor.3" "man3") +add_man_target ("lzws_finish_compressor.3" "man3") add_man_target ("lzws_resize_buffer.3" "man3") diff --git a/man/generic/lzws_compress.3.txt b/man/generic/lzws_compress.3.txt index d9725400..e0d0cc59 100644 --- a/man/generic/lzws_compress.3.txt +++ b/man/generic/lzws_compress.3.txt @@ -80,4 +80,4 @@ SEE ALSO *lzws_compressor_write_magic_header*(3) *lzws_compressor_get_initial_state*(3) *lzws_compressor_free_state*(3) -*lzws_flush_compressor*(3) +*lzws_finish_compressor*(3) diff --git a/man/generic/lzws_compressor_free_state.3.txt b/man/generic/lzws_compressor_free_state.3.txt index 4bbff8bd..f6dfd9c3 100644 --- a/man/generic/lzws_compressor_free_state.3.txt +++ b/man/generic/lzws_compressor_free_state.3.txt @@ -32,4 +32,4 @@ SEE ALSO *lzws_compressor_write_magic_header*(3) *lzws_compressor_get_initial_state*(3) *lzws_compress*(3) -*lzws_flush_compressor*(3) +*lzws_finish_compressor*(3) diff --git a/man/generic/lzws_compressor_get_initial_state.3.txt b/man/generic/lzws_compressor_get_initial_state.3.txt index e9f064c1..37efdb3b 100644 --- a/man/generic/lzws_compressor_get_initial_state.3.txt +++ b/man/generic/lzws_compressor_get_initial_state.3.txt @@ -76,4 +76,4 @@ SEE ALSO *lzws_compressor_write_magic_header*(3) *lzws_compressor_free_state*(3) *lzws_compress*(3) -*lzws_flush_compressor*(3) +*lzws_finish_compressor*(3) diff --git a/man/generic/lzws_compressor_write_magic_header.3.txt b/man/generic/lzws_compressor_write_magic_header.3.txt index f021e73e..28e1cba1 100644 --- a/man/generic/lzws_compressor_write_magic_header.3.txt +++ b/man/generic/lzws_compressor_write_magic_header.3.txt @@ -69,4 +69,4 @@ SEE ALSO *lzws_compressor_get_initial_state*(3) *lzws_compressor_free_state*(3) *lzws_compress*(3) -*lzws_flush_compressor*(3) +*lzws_finish_compressor*(3) diff --git a/man/generic/lzws_flush_compressor.3.txt b/man/generic/lzws_finish_compressor.3.txt similarity index 81% rename from man/generic/lzws_flush_compressor.3.txt rename to man/generic/lzws_finish_compressor.3.txt index 2a528915..d424df29 100644 --- a/man/generic/lzws_flush_compressor.3.txt +++ b/man/generic/lzws_finish_compressor.3.txt @@ -4,7 +4,9 @@ LZWS(3) NAME ---- -lzws_flush_compressor - Flush compressor. +lzws_finish_compressor - Finish compressor. +You can't use *lzws_compress* after this call. +Use it only after stream was finished. SYNOPSIS @@ -12,7 +14,7 @@ SYNOPSIS *#include * ---- -lzws_result_t lzws_flush_compressor( +lzws_result_t lzws_finish_compressor( lzws_compressor_state_t* state_ptr, uint8_t** destination_ptr, size_t* destination_length_ptr); ---- @@ -39,7 +41,7 @@ See header file *lzws/compressor/common.h* for more details about other results. DESCRIPTION ----------- -Compressor requires flush after *lzws_compress*. +Compressor requires finish after *lzws_compress*. This function writes compressed tail to destination. It is possible that it won't be enough destination. @@ -51,11 +53,11 @@ It also decreases *destination_length_ptr*. PSEUDO EXAMPLE -------------- -You want to flush compressor after several portions of data. +You want to finish compressor after several portions of data. ---- while (true) { - lzws_result_t result = lzws_flush_compressor( + lzws_result_t result = lzws_finish_compressor( state_ptr, &destination, &destination_length); diff --git a/src/compressor/main.c b/src/compressor/main.c index eb57d024..4458bac2 100644 --- a/src/compressor/main.c +++ b/src/compressor/main.c @@ -83,7 +83,7 @@ lzws_result_t lzws_compress(lzws_compressor_state_t* state_ptr, uint8_t** source } } -lzws_result_t lzws_flush_compressor(lzws_compressor_state_t* state_ptr, uint8_t** destination_ptr, size_t* destination_length_ptr) +lzws_result_t lzws_finish_compressor(lzws_compressor_state_t* state_ptr, uint8_t** destination_ptr, size_t* destination_length_ptr) { switch (state_ptr->status) { case LZWS_COMPRESSOR_WRITE_HEADER: @@ -134,3 +134,6 @@ lzws_result_t lzws_flush_compressor(lzws_compressor_state_t* state_ptr, uint8_t* return LZWS_COMPRESSOR_UNKNOWN_STATUS; } } + +lzws_result_t lzws_flush_compressor(lzws_compressor_state_t* state_ptr, uint8_t** destination_ptr, size_t* destination_length_ptr) + __attribute__((weak, alias("lzws_finish_compressor"))); diff --git a/src/compressor/main.h b/src/compressor/main.h index 8ad83ab0..d39832cd 100644 --- a/src/compressor/main.h +++ b/src/compressor/main.h @@ -10,6 +10,9 @@ lzws_result_t lzws_compress(lzws_compressor_state_t* state_ptr, uint8_t** source_ptr, size_t* source_length_ptr, uint8_t** destination_ptr, size_t* destination_length_ptr); // Use this function when you have no more source (received EOF for example). -lzws_result_t lzws_flush_compressor(lzws_compressor_state_t* state_ptr, uint8_t** destination_ptr, size_t* destination_length_ptr); +lzws_result_t lzws_finish_compressor(lzws_compressor_state_t* state_ptr, uint8_t** destination_ptr, size_t* destination_length_ptr); + +lzws_result_t lzws_flush_compressor(lzws_compressor_state_t* state_ptr, uint8_t** destination_ptr, size_t* destination_length_ptr) + __attribute__((deprecated)); #endif // LZWS_COMPRESSOR_MAIN_H diff --git a/src/examples/generic/main.c b/src/examples/generic/main.c index f0ee0498..fb9e6286 100644 --- a/src/examples/generic/main.c +++ b/src/examples/generic/main.c @@ -71,9 +71,9 @@ int main() return 4; } - result = lzws_flush_compressor(compressor_state_ptr, &remaining_compressor_buffer, &remaining_compressor_buffer_length); + result = lzws_finish_compressor(compressor_state_ptr, &remaining_compressor_buffer, &remaining_compressor_buffer_length); if (result != 0) { - LZWS_LOG_ERROR("flush compressor failed"); + LZWS_LOG_ERROR("finish compressor failed"); lzws_compressor_free_state(compressor_state_ptr); free(compressor_buffer); diff --git a/src/file.c b/src/file.c index 0e98273b..0f7835a0 100644 --- a/src/file.c +++ b/src/file.c @@ -206,7 +206,7 @@ static inline lzws_result_t compress_data( } COMPRESS_WITH_READ_WRITE_BUFFERS(&lzws_compress, state_ptr, &source, &source_length, &destination, &destination_length); - COMPRESS_WITH_READ_WRITE_BUFFERS(&lzws_flush_compressor, state_ptr, &destination, &destination_length); + COMPRESS_WITH_READ_WRITE_BUFFERS(&lzws_finish_compressor, state_ptr, &destination, &destination_length); return write_remaining_destination_buffer(destination_file, destination_buffer, destination_buffer_length, destination_length, quiet); } diff --git a/src/string.c b/src/string.c index d3cb13f1..97124e21 100644 --- a/src/string.c +++ b/src/string.c @@ -110,7 +110,7 @@ static inline lzws_result_t compress_data( } COMPRESS_WITH_WRITE_BUFFER(&lzws_compress, state_ptr, &source, &source_length, &destination_buffer, &destination_buffer_length); - COMPRESS_WITH_WRITE_BUFFER(&lzws_flush_compressor, state_ptr, &destination_buffer, &destination_buffer_length); + COMPRESS_WITH_WRITE_BUFFER(&lzws_finish_compressor, state_ptr, &destination_buffer, &destination_buffer_length); FLUSH_DESTINATION_BUFFER();