about summary refs log tree commit diff
path: root/ui-snapshot.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-snapshot.c')
-rw-r--r--ui-snapshot.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/ui-snapshot.c b/ui-snapshot.c
index c7611e8..83ce6e8 100644
--- a/ui-snapshot.c
+++ b/ui-snapshot.c
@@ -86,11 +86,11 @@ static int write_tar_xz_archive(const char *hex, const char *prefix)
 }
 
 const struct cgit_snapshot_format cgit_snapshot_formats[] = {
-	{ ".zip", "application/x-zip", write_zip_archive, 0x01 },
-	{ ".tar.gz", "application/x-gzip", write_tar_gzip_archive, 0x02 },
-	{ ".tar.bz2", "application/x-bzip2", write_tar_bzip2_archive, 0x04 },
-	{ ".tar", "application/x-tar", write_tar_archive, 0x08 },
-	{ ".tar.xz", "application/x-xz", write_tar_xz_archive, 0x10 },
+	{ ".tar",	"application/x-tar",	write_tar_archive	},
+	{ ".tar.gz",	"application/x-gzip",	write_tar_gzip_archive	},
+	{ ".tar.bz2",	"application/x-bzip2",	write_tar_bzip2_archive	},
+	{ ".tar.xz",	"application/x-xz",	write_tar_xz_archive	},
+	{ ".zip",	"application/x-zip",	write_zip_archive	},
 	{ NULL }
 };
 
@@ -130,6 +130,11 @@ static const struct cgit_snapshot_format *get_format(const char *filename)
 	return NULL;
 }
 
+const unsigned cgit_snapshot_format_bit(const struct cgit_snapshot_format *f)
+{
+	return BIT(f - &cgit_snapshot_formats[0]);
+}
+
 static int make_snapshot(const struct cgit_snapshot_format *format,
 			 const char *hex, const char *prefix,
 			 const char *filename)
@@ -263,7 +268,7 @@ void cgit_print_snapshot(const char *head, const char *hex,
 	}
 
 	f = get_format(filename);
-	if (!f || !(ctx.repo->snapshots & f->bit)) {
+	if (!f || !(ctx.repo->snapshots & cgit_snapshot_format_bit(f))) {
 		cgit_print_error_page(400, "Bad request",
 				"Unsupported snapshot format: %s", filename);
 		return;
;id=f3db938ded8210956d492d7c42df1793893e5cbe&follow=1'>Replace "view" with "window"June McEnroe I think originally I didn't want to use the same word as curses WINDOW but it's really much clearer for the user if they're just called windows. UI code probably needs yet another rewrite though. Still feels messy. 2019-02-21Remove ROT13June McEnroe It's just not convenient when it can only do the whole line... 2019-02-21Clean up man pageJune McEnroe 2019-01-26Draw UI before connectingJune McEnroe Otherwise the "Traveling" message isn't visible while connecting. 2019-01-25Avoid unused variable warnings with getyxJune McEnroe 2019-01-25Add GNU/Linux build instructionsJune McEnroe