2 * compression handling for cbfstool
4 * Copyright (C) 2009 coresystems GmbH
5 * written by Patrick Georgi <patrick.georgi@coresystems.de>
8 * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net>, released
9 * under identical license terms
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; version 2 of the License.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
25 static int lzma_compress(char *in
, int in_len
, char *out
, int *out_len
)
27 return do_lzma_compress(in
, in_len
, out
, out_len
);
30 static int lzma_decompress(char *in
, int in_len
, char *out
, unused
int out_len
,
33 return do_lzma_uncompress(out
, out_len
, in
, in_len
, actual_size
);
35 static int none_compress(char *in
, int in_len
, char *out
, int *out_len
)
37 memcpy(out
, in
, in_len
);
42 static int none_decompress(char *in
, int in_len
, char *out
, unused
int out_len
,
45 memcpy(out
, in
, in_len
);
46 if (actual_size
!= NULL
)
47 *actual_size
= in_len
;
51 comp_func_ptr
compression_function(enum comp_algo algo
)
53 comp_func_ptr compress
;
55 case CBFS_COMPRESS_NONE
:
56 compress
= none_compress
;
58 case CBFS_COMPRESS_LZMA
:
59 compress
= lzma_compress
;
62 ERROR("Unknown compression algorithm %d!\n", algo
);
68 decomp_func_ptr
decompression_function(enum comp_algo algo
)
70 decomp_func_ptr decompress
;
72 case CBFS_COMPRESS_NONE
:
73 decompress
= none_decompress
;
75 case CBFS_COMPRESS_LZMA
:
76 decompress
= lzma_decompress
;
79 ERROR("Unknown compression algorithm %d!\n", algo
);