• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef GZIP_WRAPPER_H
2 #define GZIP_WRAPPER_H
3 /*
4  * Squashfs
5  *
6  * Copyright (c) 2014
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  * gzip_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_le16(unsigned short);
37 extern unsigned int inswap_le32(unsigned int);
38 
39 #define SQUASHFS_INSWAP_COMP_OPTS(s) { \
40 	(s)->compression_level = inswap_le32((s)->compression_level); \
41 	(s)->window_size = inswap_le16((s)->window_size); \
42 	(s)->strategy = inswap_le16((s)->strategy); \
43 }
44 #else
45 #define SQUASHFS_INSWAP_COMP_OPTS(s)
46 #endif
47 
48 /* Default compression */
49 #define GZIP_DEFAULT_COMPRESSION_LEVEL 9
50 #define GZIP_DEFAULT_WINDOW_SIZE 15
51 
52 struct gzip_comp_opts {
53 	int compression_level;
54 	short window_size;
55 	short strategy;
56 };
57 
58 struct strategy {
59 	char *name;
60 	int strategy;
61 	int selected;
62 };
63 
64 struct gzip_strategy {
65 	int strategy;
66 	int length;
67 	void *buffer;
68 };
69 
70 struct gzip_stream {
71 	z_stream stream;
72 	int strategies;
73 	struct gzip_strategy strategy[0];
74 };
75 #endif
76