return 0;
}
-void extract_lz_file(unsigned char *inbuf, unsigned char *name, unsigned char check_crc)
+unsigned char *extract_lz_file(unsigned char *inbuf, unsigned int *outlen , unsigned char check_crc)
{
- unsigned int len;
unsigned char *outbuf;
struct data_in_s data_in;
struct data_out_s data_out;
if (*((unsigned int*)inbuf) != LZ_MAGIC)
err_exit(__func__);
- len = *((unsigned int*)(inbuf + 4));
- printf(", length: %d", len);
+ *outlen = *((unsigned int*)(inbuf + 4));
+ printf(", length: %d", *outlen);
- if ((outbuf = malloc(len)) == NULL) {
+ if ((outbuf = malloc(*outlen)) == NULL) {
perror("malloc");
exit(1);
}
- bzero(outbuf, len);
+ bzero(outbuf, *outlen);
data_in.start = inbuf + 8;
- data_in.stop = inbuf + len;
+ data_in.stop = inbuf + *outlen;
data_in.byte = 0x00;
data_in.bitpos = 0x80;
data_out.pos = outbuf;
- data_out.end = outbuf + len;
+ data_out.end = outbuf + *outlen;
lz_expand(&data_in, &data_out);
err_exit(__func__);
}
}
- write_file(extracted_file((char*)name), outbuf, len);
-
- free(outbuf);
+
+ return outbuf;
}