Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/archival/bbunzip.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/archival/bbunzip.c
r2725 r3232 6 6 */ 7 7 #include "libbb.h" 8 #include " archive.h"8 #include "bb_archive.h" 9 9 10 10 enum { … … 34 34 35 35 int FAST_FUNC bbunpack(char **argv, 36 IF_DESKTOP(long long) int FAST_FUNC (*unpacker)( unpack_info_t *info),36 IF_DESKTOP(long long) int FAST_FUNC (*unpacker)(transformer_aux_data_t *aux), 37 37 char* FAST_FUNC (*make_new_name)(char *filename, const char *expected_ext), 38 38 const char *expected_ext … … 43 43 char *filename, *new_name; 44 44 smallint exitcode = 0; 45 unpack_info_t info;45 transformer_aux_data_t aux; 46 46 47 47 do { … … 99 99 } 100 100 101 /* memset(&info, 0, sizeof(info)); */102 info.mtime = 0; /* so far it has one member only */103 status = unpacker(& info);101 init_transformer_aux_data(&aux); 102 aux.check_signature = 1; 103 status = unpacker(&aux); 104 104 if (status < 0) 105 105 exitcode = 1; 106 xclose(STDOUT_FILENO); /* with error check! */ 106 107 if (!(option_mask32 & OPT_STDOUT)) 108 xclose(STDOUT_FILENO); /* with error check! */ 107 109 108 110 if (filename) { … … 110 112 if (status >= 0) { 111 113 /* TODO: restore other things? */ 112 if ( info.mtime) {114 if (aux.mtime != 0) { 113 115 struct timeval times[2]; 114 116 115 times[1].tv_sec = times[0].tv_sec = info.mtime;117 times[1].tv_sec = times[0].tv_sec = aux.mtime; 116 118 times[1].tv_usec = times[0].tv_usec = 0; 117 119 /* Note: we closed it first. … … 143 145 } 144 146 } while (*argv && *++argv); 147 148 if (option_mask32 & OPT_STDOUT) 149 xclose(STDOUT_FILENO); /* with error check! */ 145 150 146 151 return exitcode; … … 168 173 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 169 174 */ 175 176 //usage:#define uncompress_trivial_usage 177 //usage: "[-cf] [FILE]..." 178 //usage:#define uncompress_full_usage "\n\n" 179 //usage: "Decompress .Z file[s]\n" 180 //usage: "\n -c Write to stdout" 181 //usage: "\n -f Overwrite" 182 170 183 #if ENABLE_UNCOMPRESS 171 184 static 172 IF_DESKTOP(long long) int FAST_FUNC unpack_uncompress(unpack_info_t *info UNUSED_PARAM) 173 { 174 IF_DESKTOP(long long) int status = -1; 175 176 if ((xread_char(STDIN_FILENO) != 0x1f) || (xread_char(STDIN_FILENO) != 0x9d)) { 177 bb_error_msg("invalid magic"); 178 } else { 179 status = unpack_Z_stream(STDIN_FILENO, STDOUT_FILENO); 180 } 181 return status; 185 IF_DESKTOP(long long) int FAST_FUNC unpack_uncompress(transformer_aux_data_t *aux) 186 { 187 return unpack_Z_stream(aux, STDIN_FILENO, STDOUT_FILENO); 182 188 } 183 189 int uncompress_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; … … 219 225 * See the file algorithm.doc for the compression algorithms and file formats. 220 226 */ 227 228 //usage:#define gunzip_trivial_usage 229 //usage: "[-cft] [FILE]..." 230 //usage:#define gunzip_full_usage "\n\n" 231 //usage: "Decompress FILEs (or stdin)\n" 232 //usage: "\n -c Write to stdout" 233 //usage: "\n -f Force" 234 //usage: "\n -t Test file integrity" 235 //usage: 236 //usage:#define gunzip_example_usage 237 //usage: "$ ls -la /tmp/BusyBox*\n" 238 //usage: "-rw-rw-r-- 1 andersen andersen 557009 Apr 11 10:55 /tmp/BusyBox-0.43.tar.gz\n" 239 //usage: "$ gunzip /tmp/BusyBox-0.43.tar.gz\n" 240 //usage: "$ ls -la /tmp/BusyBox*\n" 241 //usage: "-rw-rw-r-- 1 andersen andersen 1761280 Apr 14 17:47 /tmp/BusyBox-0.43.tar\n" 242 //usage: 243 //usage:#define zcat_trivial_usage 244 //usage: "FILE" 245 //usage:#define zcat_full_usage "\n\n" 246 //usage: "Decompress to stdout" 247 221 248 #if ENABLE_GUNZIP 222 249 static … … 246 273 } 247 274 static 248 IF_DESKTOP(long long) int FAST_FUNC unpack_gunzip(unpack_info_t *info) 249 { 250 IF_DESKTOP(long long) int status = -1; 251 252 /* do the decompression, and cleanup */ 253 if (xread_char(STDIN_FILENO) == 0x1f) { 254 unsigned char magic2; 255 256 magic2 = xread_char(STDIN_FILENO); 257 if (ENABLE_FEATURE_SEAMLESS_Z && magic2 == 0x9d) { 258 status = unpack_Z_stream(STDIN_FILENO, STDOUT_FILENO); 259 } else if (magic2 == 0x8b) { 260 status = unpack_gz_stream_with_info(STDIN_FILENO, STDOUT_FILENO, info); 261 } else { 262 goto bad_magic; 263 } 264 if (status < 0) { 265 bb_error_msg("error inflating"); 266 } 267 } else { 268 bad_magic: 269 bb_error_msg("invalid magic"); 270 /* status is still == -1 */ 271 } 272 return status; 275 IF_DESKTOP(long long) int FAST_FUNC unpack_gunzip(transformer_aux_data_t *aux) 276 { 277 return unpack_gz_stream(aux, STDIN_FILENO, STDOUT_FILENO); 273 278 } 274 279 /* … … 309 314 //usage:#define bunzip2_full_usage "\n\n" 310 315 //usage: "Decompress FILEs (or stdin)\n" 311 //usage: "\nOptions:"312 316 //usage: "\n -c Write to stdout" 313 317 //usage: "\n -f Force" … … 316 320 //usage:#define bzcat_full_usage "\n\n" 317 321 //usage: "Decompress to stdout" 318 //applet:IF_BUNZIP2(APPLET(bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP))319 //applet:IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP, bzcat))322 //applet:IF_BUNZIP2(APPLET(bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP)) 323 //applet:IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP, bzcat)) 320 324 #if ENABLE_BUNZIP2 321 325 static 322 IF_DESKTOP(long long) int FAST_FUNC unpack_bunzip2( unpack_info_t *info UNUSED_PARAM)323 { 324 return unpack_bz2_stream _prime(STDIN_FILENO, STDOUT_FILENO);326 IF_DESKTOP(long long) int FAST_FUNC unpack_bunzip2(transformer_aux_data_t *aux) 327 { 328 return unpack_bz2_stream(aux, STDIN_FILENO, STDOUT_FILENO); 325 329 } 326 330 int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; … … 345 349 * Licensed under GPLv2, see file LICENSE in this source tree. 346 350 */ 351 352 //usage:#define unlzma_trivial_usage 353 //usage: "[-cf] [FILE]..." 354 //usage:#define unlzma_full_usage "\n\n" 355 //usage: "Decompress FILE (or stdin)\n" 356 //usage: "\n -c Write to stdout" 357 //usage: "\n -f Force" 358 //usage: 359 //usage:#define lzma_trivial_usage 360 //usage: "-d [-cf] [FILE]..." 361 //usage:#define lzma_full_usage "\n\n" 362 //usage: "Decompress FILE (or stdin)\n" 363 //usage: "\n -d Decompress" 364 //usage: "\n -c Write to stdout" 365 //usage: "\n -f Force" 366 //usage: 367 //usage:#define lzcat_trivial_usage 368 //usage: "FILE" 369 //usage:#define lzcat_full_usage "\n\n" 370 //usage: "Decompress to stdout" 371 //usage: 372 //usage:#define unxz_trivial_usage 373 //usage: "[-cf] [FILE]..." 374 //usage:#define unxz_full_usage "\n\n" 375 //usage: "Decompress FILE (or stdin)\n" 376 //usage: "\n -c Write to stdout" 377 //usage: "\n -f Force" 378 //usage: 379 //usage:#define xz_trivial_usage 380 //usage: "-d [-cf] [FILE]..." 381 //usage:#define xz_full_usage "\n\n" 382 //usage: "Decompress FILE (or stdin)\n" 383 //usage: "\n -d Decompress" 384 //usage: "\n -c Write to stdout" 385 //usage: "\n -f Force" 386 //usage: 387 //usage:#define xzcat_trivial_usage 388 //usage: "FILE" 389 //usage:#define xzcat_full_usage "\n\n" 390 //usage: "Decompress to stdout" 391 347 392 #if ENABLE_UNLZMA 348 393 static 349 IF_DESKTOP(long long) int FAST_FUNC unpack_unlzma( unpack_info_t *info UNUSED_PARAM)350 { 351 return unpack_lzma_stream( STDIN_FILENO, STDOUT_FILENO);394 IF_DESKTOP(long long) int FAST_FUNC unpack_unlzma(transformer_aux_data_t *aux) 395 { 396 return unpack_lzma_stream(aux, STDIN_FILENO, STDOUT_FILENO); 352 397 } 353 398 int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; … … 372 417 #if ENABLE_UNXZ 373 418 static 374 IF_DESKTOP(long long) int FAST_FUNC unpack_unxz(unpack_info_t *info UNUSED_PARAM) 375 { 376 struct { 377 uint32_t v1; 378 uint16_t v2; 379 } magic; 380 xread(STDIN_FILENO, &magic, 6); 381 if (magic.v1 != XZ_MAGIC1a || magic.v2 != XZ_MAGIC2a) { 382 bb_error_msg("invalid magic"); 383 return -1; 384 } 385 return unpack_xz_stream(STDIN_FILENO, STDOUT_FILENO); 419 IF_DESKTOP(long long) int FAST_FUNC unpack_unxz(transformer_aux_data_t *aux) 420 { 421 return unpack_xz_stream(aux, STDIN_FILENO, STDOUT_FILENO); 386 422 } 387 423 int unxz_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Note:
See TracChangeset
for help on using the changeset viewer.