static int lha_lh_new_init(void *data, LHADecoderCallback callback, void *callback_data) { LHANewDecoder *decoder = data; // Initialize input stream reader. bit_stream_reader_init(&decoder->bit_stream_reader, callback, callback_data); // Initialize data structures. init_ring_buffer(decoder); // First read starts the first block. decoder->block_remaining = 0; // Initialize tree tables to a known state. init_tree(decoder->code_tree, NUM_CODES * 2); init_tree(decoder->offset_tree, MAX_TEMP_CODES * 2); return 1; }
static int lha_pm2_decoder_init(void *data, LHADecoderCallback callback, void *callback_data) { LHAPM2Decoder *decoder = data; bit_stream_reader_init(&decoder->bit_stream_reader, callback, callback_data); // Tree has not been built yet. It needs to be built on // the first call to read(). decoder->tree_state = PM2_REBUILD_UNBUILT; decoder->tree_rebuild_remaining = 0; // Initialize ring buffer contents. memset(&decoder->ringbuf, ' ', RING_BUFFER_SIZE); decoder->ringbuf_pos = 0; // Init history lookup list. init_history(decoder); // Initialize the lookup trees to a known state. init_tree(decoder->code_tree, CODE_TREE_ELEMENTS); init_tree(decoder->offset_tree, OFFSET_TREE_ELEMENTS); return 1; }
static int lha_lzs_init(void *data, LHADecoderCallback callback, void *callback_data) { LHALZSDecoder *decoder = data; memset(decoder->ringbuf, ' ', RING_BUFFER_SIZE); decoder->ringbuf_pos = RING_BUFFER_SIZE - START_OFFSET; bit_stream_reader_init(&decoder->bit_stream_reader, callback, callback_data); return 1; }
static int lha_pm1_init(void *data, LHADecoderCallback callback, void *callback_data) { LHAPM1Decoder *decoder = data; memset(decoder, 0, sizeof(LHAPM1Decoder)); bit_stream_reader_init(&decoder->bit_stream_reader, callback, callback_data); decoder->output_stream_pos = 0; decoder->byte_decode_tree = NULL; decoder->ringbuf_pos = 0; init_history_list(&decoder->history_list); return 1; }
static int lha_lh1_init(void *data, LHADecoderCallback callback, void *callback_data) { LHALH1Decoder *decoder = data; // Initialize input stream reader. bit_stream_reader_init(&decoder->bit_stream_reader, callback, callback_data); // Initialize data structures. init_groups(decoder); init_tree(decoder); init_offset_table(decoder); init_ring_buffer(decoder); return 1; }