Author: stepan Date: 2007-06-16 16:37:02 +0200 (Sat, 16 Jun 2007) New Revision: 356
Modified: LinuxBIOSv3/util/lzma/minilzma.cc LinuxBIOSv3/util/nrv2b/nrv2b.c Log: 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
Modified: LinuxBIOSv3/util/lzma/minilzma.cc =================================================================== --- LinuxBIOSv3/util/lzma/minilzma.cc 2007-06-16 14:34:17 UTC (rev 355) +++ LinuxBIOSv3/util/lzma/minilzma.cc 2007-06-16 14:37:02 UTC (rev 356) @@ -234,6 +234,7 @@ return result; }
+#ifndef COMPACT int main(int argc, char *argv[]) { char *s; @@ -277,4 +278,16 @@ 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 +
Modified: LinuxBIOSv3/util/nrv2b/nrv2b.c =================================================================== --- LinuxBIOSv3/util/nrv2b/nrv2b.c 2007-06-16 14:34:17 UTC (rev 355) +++ LinuxBIOSv3/util/nrv2b/nrv2b.c 2007-06-16 14:37:02 UTC (rev 356) @@ -65,11 +65,13 @@ #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 @@ }
+#ifndef COMPACT void Encode(void) /* compression */ { uint8_t *in, *out; @@ -1291,9 +1294,18 @@ #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) \