lzo: update to 2.09
[tomato.git] / release / src / router / lzo / src / lzo1b_xx.c
blob56f300662aebd0f99a48e40ea04eb419669ce085
1 /* lzo1b_xx.c -- LZO1B compression public entry point
3 This file is part of the LZO real-time data compression library.
5 Copyright (C) 1996-2015 Markus Franz Xaver Johannes Oberhumer
6 All Rights Reserved.
8 The LZO library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of
11 the License, or (at your option) any later version.
13 The LZO library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with the LZO library; see the file COPYING.
20 If not, write to the Free Software Foundation, Inc.,
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 Markus F.X.J. Oberhumer
24 <markus@oberhumer.com>
25 http://www.oberhumer.com/opensource/lzo/
29 #include "config1b.h"
32 /***********************************************************************
34 ************************************************************************/
36 static const lzo_compress_t * const c_funcs [9] =
38 &_lzo1b_1_compress_func,
39 &_lzo1b_2_compress_func,
40 &_lzo1b_3_compress_func,
41 &_lzo1b_4_compress_func,
42 &_lzo1b_5_compress_func,
43 &_lzo1b_6_compress_func,
44 &_lzo1b_7_compress_func,
45 &_lzo1b_8_compress_func,
46 &_lzo1b_9_compress_func
50 static lzo_compress_t lzo1b_get_compress_func(int clevel)
52 const lzo_compress_t *f;
54 if (clevel < LZO1B_BEST_SPEED || clevel > LZO1B_BEST_COMPRESSION)
56 if (clevel == LZO1B_DEFAULT_COMPRESSION)
57 clevel = LZO1B_BEST_SPEED;
58 else
59 return (lzo_compress_t) 0;
61 f = c_funcs[clevel-1];
62 assert(f && *f);
63 return *f;
67 LZO_PUBLIC(int)
68 lzo1b_compress ( const lzo_bytep src, lzo_uint src_len,
69 lzo_bytep dst, lzo_uintp dst_len,
70 lzo_voidp wrkmem,
71 int clevel )
73 lzo_compress_t f;
75 f = lzo1b_get_compress_func(clevel);
76 if (!f)
77 return LZO_E_ERROR;
78 return _lzo1b_do_compress(src,src_len,dst,dst_len,wrkmem,f);
82 /* vim:set ts=4 sw=4 et: */