test: compress: update simple1 compression api usage
This commit is contained in:
@@ -41,7 +41,7 @@ int refill_input_buffer(FILE *fp, b_ringbuffer *dest)
|
|||||||
int flush_output_buffer(FILE *fp, b_ringbuffer *src)
|
int flush_output_buffer(FILE *fp, b_ringbuffer *src)
|
||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
void *buf;
|
const void *buf;
|
||||||
size_t capacity;
|
size_t capacity;
|
||||||
b_status status
|
b_status status
|
||||||
= b_ringbuffer_open_read_buffer(src, &buf, &capacity);
|
= b_ringbuffer_open_read_buffer(src, &buf, &capacity);
|
||||||
@@ -79,11 +79,11 @@ int main(int argc, const char **argv)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
b_compressor_mode mode;
|
b_compression_mode mode;
|
||||||
if (!strcmp(argv[1], "C")) {
|
if (!strcmp(argv[1], "C")) {
|
||||||
mode = B_COMPRESSOR_MODE_COMPRESS;
|
mode = B_COMPRESSION_MODE_COMPRESS;
|
||||||
} else if (!strcmp(argv[1], "D")) {
|
} else if (!strcmp(argv[1], "D")) {
|
||||||
mode = B_COMPRESSOR_MODE_DECOMPRESS;
|
mode = B_COMPRESSION_MODE_DECOMPRESS;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "invalid mode %s\n", argv[1]);
|
fprintf(stderr, "invalid mode %s\n", argv[1]);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -135,14 +135,7 @@ int main(int argc, const char **argv)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (mode) {
|
status = b_compressor_step(compressor);
|
||||||
case B_COMPRESSOR_MODE_COMPRESS:
|
|
||||||
status = b_compressor_compress(compressor);
|
|
||||||
break;
|
|
||||||
case B_COMPRESSOR_MODE_DECOMPRESS:
|
|
||||||
status = b_compressor_decompress(compressor);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status == B_ERR_NO_DATA) {
|
if (status == B_ERR_NO_DATA) {
|
||||||
break;
|
break;
|
||||||
@@ -164,9 +157,9 @@ int main(int argc, const char **argv)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == B_COMPRESSOR_MODE_COMPRESS) {
|
if (mode == B_COMPRESSION_MODE_COMPRESS) {
|
||||||
while (!b_compressor_eof(compressor)) {
|
while (!b_compressor_eof(compressor)) {
|
||||||
status = b_compressor_compress_end(compressor);
|
status = b_compressor_end(compressor);
|
||||||
if (!B_OK(status)) {
|
if (!B_OK(status)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"compression finalisation error\n");
|
"compression finalisation error\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user