diff options
Diffstat (limited to 'include/bb_archive.h')
-rw-r--r-- | include/bb_archive.h | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/include/bb_archive.h b/include/bb_archive.h index b82cfd83c..a6b166fe3 100644 --- a/include/bb_archive.h +++ b/include/bb_archive.h | |||
@@ -203,43 +203,57 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len) FAST_FUNC; | |||
203 | void dealloc_bunzip(bunzip_data *bd) FAST_FUNC; | 203 | void dealloc_bunzip(bunzip_data *bd) FAST_FUNC; |
204 | 204 | ||
205 | /* Meaning and direction (input/output) of the fields are transformer-specific */ | 205 | /* Meaning and direction (input/output) of the fields are transformer-specific */ |
206 | typedef struct transformer_aux_data_t { | 206 | typedef struct transformer_state_t { |
207 | smallint check_signature; /* most often referenced member */ | 207 | smallint check_signature; /* most often referenced member */ |
208 | |||
209 | IF_DESKTOP(long long) int FAST_FUNC (*xformer)(struct transformer_state_t *xstate); | ||
210 | USE_FOR_NOMMU(const char *xformer_prog;) | ||
211 | |||
212 | /* Source */ | ||
213 | int src_fd; | ||
214 | /* Output */ | ||
215 | int dst_fd; | ||
216 | size_t mem_output_size_max; /* if non-zero, decompress to RAM instead of fd */ | ||
217 | size_t mem_output_size; | ||
218 | char *mem_output_buf; | ||
219 | |||
208 | off_t bytes_out; | 220 | off_t bytes_out; |
209 | off_t bytes_in; /* used in unzip code only: needs to know packed size */ | 221 | off_t bytes_in; /* used in unzip code only: needs to know packed size */ |
210 | uint32_t crc32; | 222 | uint32_t crc32; |
211 | time_t mtime; /* gunzip code may set this on exit */ | 223 | time_t mtime; /* gunzip code may set this on exit */ |
212 | } transformer_aux_data_t; | 224 | } transformer_state_t; |
213 | 225 | ||
214 | void init_transformer_aux_data(transformer_aux_data_t *aux) FAST_FUNC; | 226 | void init_transformer_state(transformer_state_t *xstate) FAST_FUNC; |
215 | int FAST_FUNC check_signature16(transformer_aux_data_t *aux, int src_fd, unsigned magic16) FAST_FUNC; | 227 | ssize_t transformer_write(transformer_state_t *xstate, const void *buf, size_t bufsize) FAST_FUNC; |
228 | ssize_t xtransformer_write(transformer_state_t *xstate, const void *buf, size_t bufsize) FAST_FUNC; | ||
229 | int check_signature16(transformer_state_t *xstate, unsigned magic16) FAST_FUNC; | ||
216 | 230 | ||
217 | IF_DESKTOP(long long) int inflate_unzip(transformer_aux_data_t *aux, int src_fd, int dst_fd) FAST_FUNC; | 231 | IF_DESKTOP(long long) int inflate_unzip(transformer_state_t *xstate) FAST_FUNC; |
218 | IF_DESKTOP(long long) int unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd) FAST_FUNC; | 232 | IF_DESKTOP(long long) int unpack_Z_stream(transformer_state_t *xstate) FAST_FUNC; |
219 | IF_DESKTOP(long long) int unpack_gz_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd) FAST_FUNC; | 233 | IF_DESKTOP(long long) int unpack_gz_stream(transformer_state_t *xstate) FAST_FUNC; |
220 | IF_DESKTOP(long long) int unpack_bz2_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd) FAST_FUNC; | 234 | IF_DESKTOP(long long) int unpack_bz2_stream(transformer_state_t *xstate) FAST_FUNC; |
221 | IF_DESKTOP(long long) int unpack_lzma_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd) FAST_FUNC; | 235 | IF_DESKTOP(long long) int unpack_lzma_stream(transformer_state_t *xstate) FAST_FUNC; |
222 | IF_DESKTOP(long long) int unpack_xz_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd) FAST_FUNC; | 236 | IF_DESKTOP(long long) int unpack_xz_stream(transformer_state_t *xstate) FAST_FUNC; |
223 | 237 | ||
224 | char* append_ext(char *filename, const char *expected_ext) FAST_FUNC; | 238 | char* append_ext(char *filename, const char *expected_ext) FAST_FUNC; |
225 | int bbunpack(char **argv, | 239 | int bbunpack(char **argv, |
226 | IF_DESKTOP(long long) int FAST_FUNC (*unpacker)(transformer_aux_data_t *aux), | 240 | IF_DESKTOP(long long) int FAST_FUNC (*unpacker)(transformer_state_t *xstate), |
227 | char* FAST_FUNC (*make_new_name)(char *filename, const char *expected_ext), | 241 | char* FAST_FUNC (*make_new_name)(char *filename, const char *expected_ext), |
228 | const char *expected_ext | 242 | const char *expected_ext |
229 | ) FAST_FUNC; | 243 | ) FAST_FUNC; |
230 | 244 | ||
231 | void check_errors_in_children(int signo); | 245 | void check_errors_in_children(int signo); |
232 | #if BB_MMU | 246 | #if BB_MMU |
233 | void open_transformer(int fd, | 247 | void fork_transformer(int fd, |
234 | int check_signature, | 248 | int check_signature, |
235 | IF_DESKTOP(long long) int FAST_FUNC (*transformer)(transformer_aux_data_t *aux, int src_fd, int dst_fd) | 249 | IF_DESKTOP(long long) int FAST_FUNC (*transformer)(transformer_state_t *xstate) |
236 | ) FAST_FUNC; | 250 | ) FAST_FUNC; |
237 | #define open_transformer_with_sig(fd, transformer, transform_prog) open_transformer((fd), 1, (transformer)) | 251 | #define fork_transformer_with_sig(fd, transformer, transform_prog) fork_transformer((fd), 1, (transformer)) |
238 | #define open_transformer_with_no_sig(fd, transformer) open_transformer((fd), 0, (transformer)) | 252 | #define fork_transformer_with_no_sig(fd, transformer) fork_transformer((fd), 0, (transformer)) |
239 | #else | 253 | #else |
240 | void open_transformer(int fd, const char *transform_prog) FAST_FUNC; | 254 | void fork_transformer(int fd, const char *transform_prog) FAST_FUNC; |
241 | #define open_transformer_with_sig(fd, transformer, transform_prog) open_transformer((fd), (transform_prog)) | 255 | #define fork_transformer_with_sig(fd, transformer, transform_prog) fork_transformer((fd), (transform_prog)) |
242 | /* open_transformer_with_no_sig() does not exist on NOMMU */ | 256 | /* fork_transformer_with_no_sig() does not exist on NOMMU */ |
243 | #endif | 257 | #endif |
244 | 258 | ||
245 | 259 | ||