static SquashStatus squash_bz2_process_stream (SquashStream* stream, SquashOperation operation) { switch (operation) { case SQUASH_OPERATION_PROCESS: return squash_bz2_process_stream_ex (stream, BZ_RUN); case SQUASH_OPERATION_FLUSH: return squash_bz2_process_stream_ex (stream, BZ_FLUSH); case SQUASH_OPERATION_FINISH: return squash_bz2_finish_stream (stream); } assert (0); }
static SquashStatus squash_bz2_process_stream (SquashStream* stream, SquashOperation operation) { switch (operation) { case SQUASH_OPERATION_PROCESS: return squash_bz2_process_stream_ex (stream, BZ_RUN); case SQUASH_OPERATION_FLUSH: return squash_bz2_process_stream_ex (stream, BZ_FLUSH); case SQUASH_OPERATION_FINISH: return squash_bz2_finish_stream (stream); case SQUASH_OPERATION_TERMINATE: squash_assert_unreachable (); break; } squash_assert_unreachable(); }
static SquashStatus squash_bz2_finish_stream (SquashStream* stream) { bz_stream* bz2_stream; int bz2_res; SquashStatus res; if (stream->stream_type != SQUASH_STREAM_COMPRESS) { return squash_bz2_process_stream_ex (stream, BZ_RUN); } assert (stream != NULL); if (stream->avail_out == 0) return SQUASH_BUFFER_FULL; bz2_stream = &(((SquashBZ2Stream*) stream)->stream); SQUASH_BZ2_STREAM_COPY_TO_BZ_STREAM(stream, bz2_stream); bz2_res = BZ2_bzCompress (bz2_stream, BZ_FINISH); switch (bz2_res) { case BZ_FINISH_OK: res = SQUASH_PROCESSING; break; case BZ_STREAM_END: res = SQUASH_OK; break; default: res = squash_bz2_status_to_squash_status (bz2_res); break; } SQUASH_BZ2_STREAM_COPY_FROM_BZ_STREAM(stream, bz2_stream); return res; }