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.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
29 static int lzma_compress(char *in
, int in_len
, char *out
, int *out_len
)
31 return do_lzma_compress(in
, in_len
, out
, out_len
);
34 static int lzma_decompress(char *in
, int in_len
, char *out
, unused
int out_len
,
37 return do_lzma_uncompress(out
, out_len
, in
, in_len
, actual_size
);
39 static int none_compress(char *in
, int in_len
, char *out
, int *out_len
)
41 memcpy(out
, in
, in_len
);
46 static int none_decompress(char *in
, int in_len
, char *out
, unused
int out_len
,
49 memcpy(out
, in
, in_len
);
50 if (actual_size
!= NULL
)
51 *actual_size
= in_len
;
55 comp_func_ptr
compression_function(enum comp_algo algo
)
57 comp_func_ptr compress
;
59 case CBFS_COMPRESS_NONE
:
60 compress
= none_compress
;
62 case CBFS_COMPRESS_LZMA
:
63 compress
= lzma_compress
;
66 ERROR("Unknown compression algorithm %d!\n", algo
);
72 decomp_func_ptr
decompression_function(enum comp_algo algo
)
74 decomp_func_ptr decompress
;
76 case CBFS_COMPRESS_NONE
:
77 decompress
= none_decompress
;
79 case CBFS_COMPRESS_LZMA
:
80 decompress
= lzma_decompress
;
83 ERROR("Unknown compression algorithm %d!\n", algo
);