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