1 #ifndef LZO_WRAPPER_H
2 #define LZO_WRAPPER_H
3 /*
4  * Squashfs
5  *
6  * Copyright (c) 2013
7  * Phillip Lougher <phillip@squashfs.org.uk>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2,
12  * or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * lzo_wrapper.h
24  *
25  */
26 
27 #ifndef linux
28 #define __BYTE_ORDER BYTE_ORDER
29 #define __BIG_ENDIAN BIG_ENDIAN
30 #define __LITTLE_ENDIAN LITTLE_ENDIAN
31 #else
32 #include <endian.h>
33 #endif
34 
35 #if __BYTE_ORDER == __BIG_ENDIAN
36 extern unsigned int inswap_le32(unsigned int);
37 
38 #define SQUASHFS_INSWAP_COMP_OPTS(s) { \
39 	(s)->algorithm = inswap_le32((s)->algorithm); \
40 	(s)->compression_level = inswap_le32((s)->compression_level); \
41 }
42 #else
43 #define SQUASHFS_INSWAP_COMP_OPTS(s)
44 #endif
45 
46 /* Define the compression flags recognised. */
47 #define SQUASHFS_LZO1X_1	0
48 #define SQUASHFS_LZO1X_1_11	1
49 #define SQUASHFS_LZO1X_1_12	2
50 #define SQUASHFS_LZO1X_1_15	3
51 #define SQUASHFS_LZO1X_999	4
52 
53 /* Default compression level used by SQUASHFS_LZO1X_999 */
54 #define SQUASHFS_LZO1X_999_COMP_DEFAULT	8
55 
56 struct lzo_comp_opts {
57 	int algorithm;
58 	int compression_level;
59 };
60 
61 struct lzo_algorithm {
62 	char *name;
63 	int size;
64 	int (*compress) (const lzo_bytep, lzo_uint, lzo_bytep, lzo_uintp,
65 		lzo_voidp);
66 };
67 
68 struct lzo_stream {
69 	void *workspace;
70 	void *buffer;
71 };
72 
73 #define LZO_MAX_EXPANSION(size)	(size + (size / 16) + 64 + 3)
74 
75 int lzo1x_999_wrapper(const lzo_bytep, lzo_uint, lzo_bytep, lzo_uintp,
76 		lzo_voidp);
77 
78 #endif
79