summaryrefslogtreecommitdiff
path: root/archive.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2011-06-21 21:23:33 -0400
committerJunio C Hamano <gitster@pobox.com>2011-06-22 11:12:35 -0700
commit13e0f88d4aba326da9217c225d6ab5e642eb611d (patch)
treeaf7e13e62c420620946b152ea383f680d6105a94 /archive.h
parent40e7629194c79e72009b5b8e98cce65921b0faf2 (diff)
downloadgit-13e0f88d4aba326da9217c225d6ab5e642eb611d.tar.gz
archive: refactor list of archive formats
Most of the tar and zip code was nicely split out into two abstracted files which knew only about their specific formats. The entry point to this code was a single "write archive" function. However, as these basic formats grow more complex (e.g., by handling multiple file extensions and format names), a static list of the entry point functions won't be enough. Instead, let's provide a way for the tar and zip code to tell the main archive code what they support by registering archiver names and functions. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'archive.h')
-rw-r--r--archive.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/archive.h b/archive.h
index 038ac353d4..f39cede0c6 100644
--- a/archive.h
+++ b/archive.h
@@ -14,15 +14,18 @@ struct archiver_args {
int compression_level;
};
-typedef int (*write_archive_fn_t)(struct archiver_args *);
+#define ARCHIVER_WANT_COMPRESSION_LEVELS 1
+struct archiver {
+ const char *name;
+ int (*write_archive)(struct archiver_args *);
+ unsigned flags;
+};
+extern void register_archiver(struct archiver *);
-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);
+extern void init_tar_archiver(void);
+extern void init_zip_archiver(void);
-/*
- * Archive-format specific backends.
- */
-extern int write_tar_archive(struct archiver_args *);
-extern int write_zip_archive(struct archiver_args *);
+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);
extern int write_archive_entries(struct archiver_args *args, write_archive_entry_fn_t write_entry);
extern int write_archive(int argc, const char **argv, const char *prefix, int setup_prefix);