archive: centralize archive entry writing
[git/raj.git] / archive.h
blob4e44549fdd702ceca430aeb319cc5d5f1afc7ac9
1 #ifndef ARCHIVE_H
2 #define ARCHIVE_H
4 #define MAX_EXTRA_ARGS 32
5 #define MAX_ARGS (MAX_EXTRA_ARGS + 32)
7 struct archiver_args {
8 const char *base;
9 size_t baselen;
10 struct tree *tree;
11 const unsigned char *commit_sha1;
12 const struct commit *commit;
13 time_t time;
14 const char **pathspec;
15 unsigned int verbose : 1;
16 void *extra;
19 typedef int (*write_archive_fn_t)(struct archiver_args *);
21 typedef void *(*parse_extra_args_fn_t)(int argc, const char **argv);
23 typedef int (*write_archive_entry_fn_t)(struct archiver_args *args, const unsigned char *sha1, const char *path, size_t pathlen, unsigned int mode, void *buffer, unsigned long size);
25 struct archiver {
26 const char *name;
27 write_archive_fn_t write_archive;
28 parse_extra_args_fn_t parse_extra;
31 extern int parse_archive_args(int argc, const char **argv, const struct archiver **ar, struct archiver_args *args);
33 extern void parse_treeish_arg(const char **treeish,
34 struct archiver_args *ar_args,
35 const char *prefix);
37 extern void parse_pathspec_arg(const char **pathspec,
38 struct archiver_args *args);
40 * Archive-format specific backends.
42 extern int write_tar_archive(struct archiver_args *);
43 extern int write_zip_archive(struct archiver_args *);
44 extern void *parse_extra_zip_args(int argc, const char **argv);
46 extern void *sha1_file_to_archive(const char *path, const unsigned char *sha1, unsigned int mode, enum object_type *type, unsigned long *size, const struct commit *commit);
47 extern int is_archive_path_ignored(const char *path);
49 extern int write_archive_entries(struct archiver_args *args, write_archive_entry_fn_t write_entry);
51 #endif /* ARCHIVE_H */