unarchive.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* vi: set sw=4 ts=4: */
  2. #ifndef __UNARCHIVE_H__
  3. #define __UNARCHIVE_H__
  4. #define ARCHIVE_PRESERVE_DATE 1
  5. #define ARCHIVE_CREATE_LEADING_DIRS 2
  6. #define ARCHIVE_EXTRACT_UNCONDITIONAL 4
  7. #define ARCHIVE_EXTRACT_QUIET 8
  8. #define ARCHIVE_EXTRACT_NEWER 16
  9. #define ARCHIVE_NOPRESERVE_OWN 32
  10. #define ARCHIVE_NOPRESERVE_PERM 64
  11. #include "libbb.h"
  12. typedef struct file_headers_s {
  13. char *name;
  14. char *link_name;
  15. off_t size;
  16. uid_t uid;
  17. gid_t gid;
  18. mode_t mode;
  19. time_t mtime;
  20. dev_t device;
  21. } file_header_t;
  22. typedef struct archive_handle_s {
  23. /* define if the header and data component should processed */
  24. char (*filter)(struct archive_handle_s *);
  25. llist_t *accept;
  26. /* List of files that have been rejected */
  27. llist_t *reject;
  28. /* List of files that have successfully been worked on */
  29. llist_t *passed;
  30. /* Contains the processed header entry */
  31. file_header_t *file_header;
  32. /* process the header component, e.g. tar -t */
  33. void (*action_header)(const file_header_t *);
  34. /* process the data component, e.g. extract to filesystem */
  35. void (*action_data)(struct archive_handle_s *);
  36. /* How to process any sub archive, e.g. get_header_tar_gz */
  37. char (*action_data_subarchive)(struct archive_handle_s *);
  38. /* Contains the handle to a sub archive */
  39. struct archive_handle_s *sub_archive;
  40. /* The raw stream as read from disk or stdin */
  41. int src_fd;
  42. /* Count the number of bytes processed */
  43. off_t offset;
  44. /* Function that skips data: read_by_char or read_by_skip */
  45. void (*seek)(const struct archive_handle_s *archive_handle, const unsigned int amount);
  46. /* Temporary storage */
  47. char *buffer;
  48. /* Flags and misc. stuff */
  49. unsigned char flags;
  50. } archive_handle_t;
  51. extern archive_handle_t *init_handle(void);
  52. extern char filter_accept_all(archive_handle_t *archive_handle);
  53. extern char filter_accept_list(archive_handle_t *archive_handle);
  54. extern char filter_accept_list_reassign(archive_handle_t *archive_handle);
  55. extern char filter_accept_reject_list(archive_handle_t *archive_handle);
  56. extern void unpack_ar_archive(archive_handle_t *ar_archive);
  57. extern void data_skip(archive_handle_t *archive_handle);
  58. extern void data_extract_all(archive_handle_t *archive_handle);
  59. extern void data_extract_to_stdout(archive_handle_t *archive_handle);
  60. extern void data_extract_to_buffer(archive_handle_t *archive_handle);
  61. extern void header_skip(const file_header_t *file_header);
  62. extern void header_list(const file_header_t *file_header);
  63. extern void header_verbose_list(const file_header_t *file_header);
  64. extern void check_header_gzip(int src_fd);
  65. extern char get_header_ar(archive_handle_t *archive_handle);
  66. extern char get_header_cpio(archive_handle_t *archive_handle);
  67. extern char get_header_tar(archive_handle_t *archive_handle);
  68. extern char get_header_tar_bz2(archive_handle_t *archive_handle);
  69. extern char get_header_tar_lzma(archive_handle_t *archive_handle);
  70. extern char get_header_tar_gz(archive_handle_t *archive_handle);
  71. extern void seek_by_jump(const archive_handle_t *archive_handle, const unsigned int amount);
  72. extern void seek_by_read(const archive_handle_t *archive_handle, const unsigned int amount);
  73. extern ssize_t archive_xread_all_eof(archive_handle_t *archive_handle, unsigned char *buf, size_t count);
  74. extern void data_align(archive_handle_t *archive_handle, const unsigned short boundary);
  75. extern const llist_t *find_list_entry(const llist_t *list, const char *filename);
  76. extern const llist_t *find_list_entry2(const llist_t *list, const char *filename);
  77. extern USE_DESKTOP(long long) int uncompressStream(int src_fd, int dst_fd);
  78. extern void inflate_init(unsigned int bufsize);
  79. extern void inflate_cleanup(void);
  80. extern USE_DESKTOP(long long) int inflate_unzip(int in, int out);
  81. extern USE_DESKTOP(long long) int inflate_gunzip(int in, int out);
  82. extern USE_DESKTOP(long long) int unlzma(int src_fd, int dst_fd);
  83. extern int open_transformer(int src_fd,
  84. USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd));
  85. #endif