summaryrefslogtreecommitdiff
path: root/src/metaentry.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/metaentry.c')
-rw-r--r--src/metaentry.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/metaentry.c b/src/metaentry.c
index 035901c..1eeed5b 100644
--- a/src/metaentry.c
+++ b/src/metaentry.c
@@ -434,9 +434,18 @@ mentries_tofile_v0(const struct metahash *mhash, FILE * to)
/* Stores metaentries to a file */
void
-mentries_tofile(const struct metahash *mhash, const char *path)
+mentries_tofile(const struct metahash *mhash, const char *path, int format)
{
FILE *to;
+ char const * formatstr;
+ void(*tofile)(const struct metahash *, FILE *);
+
+ switch (format) {
+ case 0: formatstr = VERSION_0; tofile = mentries_tofile_v0; break;
+ default:
+ msg(MSG_CRITICAL, "Unknown format %d\n", format);
+ exit(EXIT_FAILURE);
+ }
to = fopen(path, "w");
if (!to) {
@@ -446,9 +455,9 @@ mentries_tofile(const struct metahash *mhash, const char *path)
}
write_binary_string(SIGNATURE, SIGNATURELEN, to);
- write_binary_string(VERSION_0, VERSIONLEN, to);
+ write_binary_string(formatstr, VERSIONLEN, to);
- mentries_tofile_v0(mhash, to);
+ tofile(mhash, to);
fclose(to);
}