- 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;
- }
+ const char *reponame = cgit_repobasename(url);
+ fprintf(stderr, "reponame=%s, filename=%s\n", reponame, filename);
+ if (prefixcmp(filename, reponame))
+ return NULL;
+ filename += strlen(reponame);
+ while (filename && (*filename == '-' || *filename == '_'))
+ filename++;
+ dwim_filename = xstrdup(filename);
+ dwim_filename[strlen(filename) - strlen(fmt->suffix)] = '\0';
+ for_each_tag_ref(ref_cb, NULL);
+ return dwim_refname;
+}
+
+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;
+
+ f = get_format(filename);
+ if (!f) {
+ ctx.page.mimetype = "text/html";
+ cgit_print_http_headers(&ctx);
+ cgit_print_docstart(&ctx);
+ cgit_print_pageheader(&ctx);
+ cgit_print_error(fmt("Unsupported snapshot format: %s", filename));
+ cgit_print_docend();
+ return;
+ }
+
+ if (!hex && dwim) {
+ hex = get_ref_from_filename(ctx.repo->url, filename, f);
+ if (hex != NULL) {
+ prefix = xstrdup(filename);
+ prefix[strlen(filename) - strlen(f->suffix)] = '\0';