This patch provides a simple API to nrv2b and lzma. Necessary for

integrating compression algorithms into lar.

lar -x (extract) will be done using the decompression routines in lib/ to
ease debugging (just in case - they _should_ be functionally equivalent to
the decompression routines in the compression utilities)

Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@356 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
Stefan Reinauer 2007-06-16 14:37:02 +00:00
commit 8da7c69e28
2 changed files with 25 additions and 0 deletions

View file

@ -234,6 +234,7 @@ const std::vector<unsigned char> LZMADeCompress
return result;
}
#ifndef COMPACT
int main(int argc, char *argv[])
{
char *s;
@ -277,4 +278,16 @@ int main(int argc, char *argv[])
fclose(outfile);
return EXIT_SUCCESS;
}
#else
extern "C" {
void do_lzma_compress(char* in, unsigned long in_len, char* out, unsigned long* out_len) {
std::vector<unsigned char> result;
result = LZMACompress(std::vector<unsigned char>(in,in+in_len));
*out_len = result.size();
std::memcpy(out, &result[0], *out_len);
}
}
#endif

View file

@ -65,11 +65,13 @@ FILE *infile, *outfile;
#define BITSIZE 32
#endif
#ifndef COMPACT
static __inline__ void Error(char *message)
{
Fprintf((stderr, "\n%s\n", message));
exit(EXIT_FAILURE);
}
#endif
/* These will be a complete waste of time on a lo-endian */
/* system, but it only gets done once so WTF. */
@ -1213,6 +1215,7 @@ int ucl_nrv2b_99_compress(
}
#ifndef COMPACT
void Encode(void) /* compression */
{
uint8_t *in, *out;
@ -1291,9 +1294,18 @@ void Encode(void) /* compression */
#endif
}
#endif
#endif
#ifdef COMPACT
void do_nrv2b_compress(char* in, unsigned long in_len, char* out, unsigned long* out_len) {
*out_len = in_len + (in_len/8) + 256;
out = malloc(*out_len);
ucl_nrv2b_99_compress(in, in_len, out, out_len, 0 );
}
#endif
#ifdef DECODE
#define GETBIT_8(bb, src, ilen) \