lzo: update to 2.09
[tomato/tomato-dir865l.git] / release / src / router / lzo / src / lzo1a_99.c
blob75579d4f48eb46d1cd574788777376f5722f2add
1 /* lzo1a_99.c -- implementation of the LZO1A-99 algorithm
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/
30 #define COMPRESS_ID 99
32 #define DDBITS 3
33 #define CLEVEL 9
36 /***********************************************************************
38 ************************************************************************/
40 #define LZO_NEED_DICT_H 1
41 #include "config1a.h"
44 /***********************************************************************
45 // compression internal entry point.
46 ************************************************************************/
48 static int
49 _lzo1a_do_compress ( const lzo_bytep in, lzo_uint in_len,
50 lzo_bytep out, lzo_uintp out_len,
51 lzo_voidp wrkmem,
52 lzo_compress_t func )
54 int r;
56 /* don't try to compress a block that's too short */
57 if (in_len == 0)
59 *out_len = 0;
60 r = LZO_E_OK;
62 else if (in_len <= MIN_LOOKAHEAD + 1)
64 #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
65 *out_len = 0;
66 r = LZO_E_NOT_COMPRESSIBLE;
67 #else
68 *out_len = pd(STORE_RUN(out,in,in_len), out);
69 r = (*out_len > in_len) ? LZO_E_OK : LZO_E_ERROR;
70 #endif
72 else
73 r = func(in,in_len,out,out_len,wrkmem);
75 return r;
79 /***********************************************************************
81 ************************************************************************/
83 #if !defined(COMPRESS_ID)
84 #define COMPRESS_ID _LZO_ECONCAT2(DD_BITS,CLEVEL)
85 #endif
88 #define LZO_CODE_MATCH_INCLUDE_FILE "lzo1a_cm.ch"
89 #include "lzo1b_c.ch"
92 /***********************************************************************
94 ************************************************************************/
96 #define LZO_COMPRESS \
97 LZO_PP_ECONCAT3(lzo1a_,COMPRESS_ID,_compress)
99 #define LZO_COMPRESS_FUNC \
100 LZO_PP_ECONCAT3(_lzo1a_,COMPRESS_ID,_compress_func)
103 /***********************************************************************
105 ************************************************************************/
107 LZO_PUBLIC(int)
108 LZO_COMPRESS ( const lzo_bytep in, lzo_uint in_len,
109 lzo_bytep out, lzo_uintp out_len,
110 lzo_voidp wrkmem )
112 return _lzo1a_do_compress(in,in_len,out,out_len,wrkmem,do_compress);
116 /* vim:set ts=4 sw=4 et: */