"Robert P. J. Day" | 63fc1a9 | 2006-07-02 19:47:05 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Glenn L McGrath | 7ca04f3 | 2002-09-25 02:47:48 +0000 | [diff] [blame] | 2 | /* |
"Robert P. J. Day" | 801ab14 | 2006-07-12 07:56:04 +0000 | [diff] [blame] | 3 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
Glenn L McGrath | 7ca04f3 | 2002-09-25 02:47:48 +0000 | [diff] [blame] | 4 | */ |
5 | |||||
Glenn L McGrath | 7ca04f3 | 2002-09-25 02:47:48 +0000 | [diff] [blame] | 6 | #include <stdlib.h> |
Glenn L McGrath | a0d395e | 2002-11-19 08:22:03 +0000 | [diff] [blame] | 7 | |
Glenn L McGrath | 7ca04f3 | 2002-09-25 02:47:48 +0000 | [diff] [blame] | 8 | #include "libbb.h" |
9 | #include "unarchive.h" | ||||
10 | |||||
Rob Landley | dfba741 | 2006-03-06 20:47:33 +0000 | [diff] [blame] | 11 | char get_header_tar_gz(archive_handle_t *archive_handle) |
Glenn L McGrath | 7ca04f3 | 2002-09-25 02:47:48 +0000 | [diff] [blame] | 12 | { |
Glenn L McGrath | 2e41d0c | 2002-09-27 06:46:02 +0000 | [diff] [blame] | 13 | unsigned char magic[2]; |
Glenn L McGrath | e356883 | 2002-11-13 00:24:20 +0000 | [diff] [blame] | 14 | |
Denis Vlasenko | e1a0d48 | 2006-10-20 13:28:22 +0000 | [diff] [blame] | 15 | /* Can't lseek over pipes */ |
Denis Vlasenko | 1385899 | 2006-10-08 12:49:22 +0000 | [diff] [blame] | 16 | archive_handle->seek = seek_by_read; |
Glenn L McGrath | 5699b85 | 2003-11-15 23:19:05 +0000 | [diff] [blame] | 17 | |
Rob Landley | 5343747 | 2006-07-16 08:14:35 +0000 | [diff] [blame] | 18 | xread(archive_handle->src_fd, &magic, 2); |
Glenn L McGrath | 2e41d0c | 2002-09-27 06:46:02 +0000 | [diff] [blame] | 19 | if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { |
Denis Vlasenko | 97a8dd3 | 2006-10-01 15:55:11 +0000 | [diff] [blame] | 20 | bb_error_msg_and_die("invalid gzip magic"); |
Glenn L McGrath | 2e41d0c | 2002-09-27 06:46:02 +0000 | [diff] [blame] | 21 | } |
Glenn L McGrath | 7ca04f3 | 2002-09-25 02:47:48 +0000 | [diff] [blame] | 22 | |
Denis Vlasenko | ab9eef2 | 2007-03-07 22:02:23 +0000 | [diff] [blame^] | 23 | check_header_gzip_or_die(archive_handle->src_fd); |
Glenn L McGrath | 7ca04f3 | 2002-09-25 02:47:48 +0000 | [diff] [blame] | 24 | |
Glenn L McGrath | 5699b85 | 2003-11-15 23:19:05 +0000 | [diff] [blame] | 25 | archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip); |
Glenn L McGrath | 2e41d0c | 2002-09-27 06:46:02 +0000 | [diff] [blame] | 26 | archive_handle->offset = 0; |
Denis Vlasenko | 1385899 | 2006-10-08 12:49:22 +0000 | [diff] [blame] | 27 | while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/; |
Glenn L McGrath | 7ca04f3 | 2002-09-25 02:47:48 +0000 | [diff] [blame] | 28 | |
Glenn L McGrath | 5699b85 | 2003-11-15 23:19:05 +0000 | [diff] [blame] | 29 | /* Can only do one file at a time */ |
Denis Vlasenko | 1385899 | 2006-10-08 12:49:22 +0000 | [diff] [blame] | 30 | return EXIT_FAILURE; |
Glenn L McGrath | 7ca04f3 | 2002-09-25 02:47:48 +0000 | [diff] [blame] | 31 | } |