- static const char *delim = " \t,:/|;";
- int f, tl, rv = 0;
- /* favor legacy setting */
- if(atoi(str)) return 1;
- for(;;) {
- str += strspn(str,delim);
- tl = strcspn(str,delim);
- if(!tl)
- break;
- for(f=0;f<(sizeof(snapshot_archives)/sizeof(*snapshot_archives));++f) {
- const struct snapshot_archive_t* sat = &snapshot_archives[f];
- if(! ( strncmp(sat->suffix,str,tl) && strncmp(sat->suffix+1,str,tl-1) ) ) {
- rv |= sat->bit;
- break;
- }
+ ctx.page.mimetype = "text/html";
+ cgit_print_http_headers(&ctx);
+ cgit_print_docstart(&ctx);
+ cgit_print_pageheader(&ctx);
+ cgit_print_error(msg);
+ cgit_print_docend();
+}
+
+void cgit_print_snapshot(const char *head, const char *hex,
+ const char *filename, int snapshots, int dwim)
+{
+ const struct cgit_snapshot_format* f;
+ char *prefix = NULL;
+
+ if (!filename) {
+ show_error("No snapshot name specified");
+ return;
+ }
+
+ f = get_format(filename);
+ if (!f) {
+ show_error(xstrdup(fmt("Unsupported snapshot format: %s",
+ filename)));
+ return;
+ }
+
+ if (!hex && dwim) {
+ hex = get_ref_from_filename(ctx.repo->url, filename, f);
+ if (hex == NULL) {
+ html_status(404, "Not found", 0);
+ return;