size_t lhaDepack(void* buf, size_t len, void* data) { size_t res; if (buf == NULL) { unsigned char* tbuf = (unsigned char*)malloc(len); res = lha_decoder_read((LHADecoder*)data, tbuf, len); free(tbuf); } else { res = lha_decoder_read((LHADecoder*)data, buf, len); } return res; }
size_t lha_reader_read(LHAReader *reader, void *buf, size_t buf_len) { // The first time that we try to read the current file, we // must create the decoder to decompress it. if (reader->decoder == NULL) { if (!open_decoder(reader, NULL, NULL)) { return 0; } } // Read from decoder and return the result. return lha_decoder_read(reader->decoder, buf, buf_len); }