get_header_tar_gz.c 756 B

12345678910111213141516171819202122232425262728293031
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  4. */
  5. #include <stdlib.h>
  6. #include "libbb.h"
  7. #include "unarchive.h"
  8. char get_header_tar_gz(archive_handle_t *archive_handle)
  9. {
  10. unsigned char magic[2];
  11. /* Can't lseek over pipes */
  12. archive_handle->seek = seek_by_read;
  13. xread(archive_handle->src_fd, &magic, 2);
  14. if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
  15. bb_error_msg_and_die("invalid gzip magic");
  16. }
  17. check_header_gzip(archive_handle->src_fd);
  18. archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip);
  19. archive_handle->offset = 0;
  20. while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
  21. /* Can only do one file at a time */
  22. return EXIT_FAILURE;
  23. }