Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 1 | #ifndef ARCHIVE_H |
| 2 | #define ARCHIVE_H |
| 3 | |
Nguyễn Thái Ngọc Duy | f3e743a | 2013-07-14 15:35:44 +0700 | [diff] [blame] | 4 | #include "pathspec.h" |
| 5 | |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 6 | struct archiver_args { |
| 7 | const char *base; |
René Scharfe | d53fe81 | 2008-07-15 09:49:38 +0200 | [diff] [blame] | 8 | size_t baselen; |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 9 | struct tree *tree; |
| 10 | const unsigned char *commit_sha1; |
René Scharfe | 8460b2f | 2007-09-03 20:07:01 +0200 | [diff] [blame] | 11 | const struct commit *commit; |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 12 | time_t time; |
Nguyễn Thái Ngọc Duy | f3e743a | 2013-07-14 15:35:44 +0700 | [diff] [blame] | 13 | struct pathspec pathspec; |
Junio C Hamano | e0ffb24 | 2006-09-09 22:42:02 -0700 | [diff] [blame] | 14 | unsigned int verbose : 1; |
Nguyễn Thái Ngọc Duy | ba053ea | 2009-04-18 00:18:05 +0200 | [diff] [blame] | 15 | unsigned int worktree_attributes : 1; |
Nguyễn Thái Ngọc Duy | 9cb513b | 2012-05-03 08:51:03 +0700 | [diff] [blame] | 16 | unsigned int convert : 1; |
René Scharfe | 3a176c6 | 2008-07-18 16:30:32 +0200 | [diff] [blame] | 17 | int compression_level; |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 18 | }; |
| 19 | |
Jeff King | 13e0f88 | 2011-06-21 21:23:33 -0400 | [diff] [blame] | 20 | #define ARCHIVER_WANT_COMPRESSION_LEVELS 1 |
Jeff King | 7b97730 | 2011-06-21 23:17:35 -0400 | [diff] [blame] | 21 | #define ARCHIVER_REMOTE 2 |
Jeff King | 13e0f88 | 2011-06-21 21:23:33 -0400 | [diff] [blame] | 22 | struct archiver { |
| 23 | const char *name; |
Jeff King | 4d7c989 | 2011-06-21 21:24:07 -0400 | [diff] [blame] | 24 | int (*write_archive)(const struct archiver *, struct archiver_args *); |
Jeff King | 13e0f88 | 2011-06-21 21:23:33 -0400 | [diff] [blame] | 25 | unsigned flags; |
Jeff King | 4d7c989 | 2011-06-21 21:24:07 -0400 | [diff] [blame] | 26 | void *data; |
Jeff King | 13e0f88 | 2011-06-21 21:23:33 -0400 | [diff] [blame] | 27 | }; |
| 28 | extern void register_archiver(struct archiver *); |
| 29 | |
| 30 | extern void init_tar_archiver(void); |
| 31 | extern void init_zip_archiver(void); |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 32 | |
Nguyễn Thái Ngọc Duy | 9cb513b | 2012-05-03 08:51:03 +0700 | [diff] [blame] | 33 | typedef int (*write_archive_entry_fn_t)(struct archiver_args *args, |
| 34 | const unsigned char *sha1, |
| 35 | const char *path, size_t pathlen, |
| 36 | unsigned int mode); |
René Scharfe | 562e25a | 2008-07-14 21:22:24 +0200 | [diff] [blame] | 37 | |
René Scharfe | 562e25a | 2008-07-14 21:22:24 +0200 | [diff] [blame] | 38 | extern int write_archive_entries(struct archiver_args *args, write_archive_entry_fn_t write_entry); |
Jeff King | 7b97730 | 2011-06-21 23:17:35 -0400 | [diff] [blame] | 39 | extern int write_archive(int argc, const char **argv, const char *prefix, int setup_prefix, const char *name_hint, int remote); |
Jeff King | 56baa61 | 2011-06-21 21:24:48 -0400 | [diff] [blame] | 40 | |
| 41 | const char *archive_format_from_filename(const char *filename); |
Nguyễn Thái Ngọc Duy | 9cb513b | 2012-05-03 08:51:03 +0700 | [diff] [blame] | 42 | extern void *sha1_file_to_archive(const struct archiver_args *args, |
| 43 | const char *path, const unsigned char *sha1, |
| 44 | unsigned int mode, enum object_type *type, |
| 45 | unsigned long *sizep); |
René Scharfe | 562e25a | 2008-07-14 21:22:24 +0200 | [diff] [blame] | 46 | |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 47 | #endif /* ARCHIVE_H */ |