]>
glassweightruler.freedombox.rocks Git - Ventoy.git/blob - SQUASHFS/squashfs-tools-4.4/squashfs-tools/compressor.h
5 * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014
6 * Phillip Lougher <phillip@squashfs.org.uk>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2,
11 * or (at your option) any later version.
13 * This program 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 this program; if not, write to the Free Software
20 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 int (*init
)(void **, int, int);
30 int (*compress
)(void *, void *, void *, int, int, int *);
31 int (*uncompress
)(void *, void *, int, int, int *);
32 int (*options
)(char **, int);
33 int (*options_post
)(int);
34 void *(*dump_options
)(int, int *);
35 int (*extract_options
)(int, void *, int);
36 int (*check_options
)(int, void *, int);
37 void (*display_options
)(void *, int);
41 extern struct compressor
*lookup_compressor(char *);
42 extern struct compressor
*lookup_compressor_id(int);
43 extern void display_compressors(char *, char *);
44 extern void display_compressor_usage(char *);
46 static inline int compressor_init(struct compressor
*comp
, void **stream
,
47 int block_size
, int datablock
)
49 if(comp
->init
== NULL
)
51 return comp
->init(stream
, block_size
, datablock
);
55 static inline int compressor_compress(struct compressor
*comp
, void *strm
,
56 void *dest
, void *src
, int size
, int block_size
, int *error
)
58 return comp
->compress(strm
, dest
, src
, size
, block_size
, error
);
62 static inline int compressor_uncompress(struct compressor
*comp
, void *dest
,
63 void *src
, int size
, int block_size
, int *error
)
65 return comp
->uncompress(dest
, src
, size
, block_size
, error
);
70 * For the following functions please see the lzo, lz4 or xz
71 * compressors for commented examples of how they are used.
73 static inline int compressor_options(struct compressor
*comp
, char *argv
[],
76 if(comp
->options
== NULL
)
79 return comp
->options(argv
, argc
);
83 static inline int compressor_options_post(struct compressor
*comp
, int block_size
)
85 if(comp
->options_post
== NULL
)
87 return comp
->options_post(block_size
);
91 static inline void *compressor_dump_options(struct compressor
*comp
,
92 int block_size
, int *size
)
94 if(comp
->dump_options
== NULL
)
96 return comp
->dump_options(block_size
, size
);
100 static inline int compressor_extract_options(struct compressor
*comp
,
101 int block_size
, void *buffer
, int size
)
103 if(comp
->extract_options
== NULL
)
104 return size
? -1 : 0;
105 return comp
->extract_options(block_size
, buffer
, size
);
109 static inline int compressor_check_options(struct compressor
*comp
,
110 int block_size
, void *buffer
, int size
)
112 if(comp
->check_options
== NULL
)
114 return comp
->check_options(block_size
, buffer
, size
);
118 static inline void compressor_display_options(struct compressor
*comp
,
119 void *buffer
, int size
)
121 if(comp
->display_options
!= NULL
)
122 comp
->display_options(buffer
, size
);