]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-snapshot.c
Remove obsolete cacheitem parameter to ui-functions
[ps-cgit] / ui-snapshot.c
index bd34a28a41713cccffff7a52742e4a61038e0544..c7414691290eef3dc335c237810d07e3524f5907 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include "cgit.h"
  */
 
 #include "cgit.h"
+#include "html.h"
 
 static int write_compressed_tar_archive(struct archiver_args *args,const char *filter)
 {
 
 static int write_compressed_tar_archive(struct archiver_args *args,const char *filter)
 {
@@ -68,8 +69,7 @@ static const struct snapshot_archive_t {
 
 #define snapshot_archives_len (sizeof(snapshot_archives) / sizeof(*snapshot_archives))
 
 
 #define snapshot_archives_len (sizeof(snapshot_archives) / sizeof(*snapshot_archives))
 
-void cgit_print_snapshot(struct cacheitem *item, const char *head,
-                        const char *hex, const char *prefix,
+void cgit_print_snapshot(const char *head, const char *hex, const char *prefix,
                         const char *filename, int snapshots)
 {
        const struct snapshot_archive_t* sat;
                         const char *filename, int snapshots)
 {
        const struct snapshot_archive_t* sat;
@@ -99,7 +99,10 @@ void cgit_print_snapshot(struct cacheitem *item, const char *head,
                memset(&args,0,sizeof(args));
                args.base = fmt("%s/", prefix);
                args.tree = commit->tree;
                memset(&args,0,sizeof(args));
                args.base = fmt("%s/", prefix);
                args.tree = commit->tree;
-               cgit_print_snapshot_start(sat->mimetype, filename, item);
+               args.time = commit->date;
+               ctx.page.mimetype = xstrdup(sat->mimetype);
+               ctx.page.filename = xstrdup(filename);
+               cgit_print_http_headers(&ctx);
                (*sat->write_func)(&args);
                return;
        }
                (*sat->write_func)(&args);
                return;
        }
@@ -129,7 +132,7 @@ int cgit_parse_snapshots_mask(const char *str)
 {
        const struct snapshot_archive_t* sat;
        static const char *delim = " \t,:/|;";
 {
        const struct snapshot_archive_t* sat;
        static const char *delim = " \t,:/|;";
-       int f, tl, rv = 0;
+       int f, tl, sl, rv = 0;
 
        /* favor legacy setting */
        if(atoi(str))
 
        /* favor legacy setting */
        if(atoi(str))
@@ -141,8 +144,9 @@ int cgit_parse_snapshots_mask(const char *str)
                        break;
                for(f=0; f<snapshot_archives_len; f++) {
                        sat = &snapshot_archives[f];
                        break;
                for(f=0; f<snapshot_archives_len; f++) {
                        sat = &snapshot_archives[f];
-                       if(!(strncmp(sat->suffix, str, tl) &&
-                            strncmp(sat->suffix+1, str, tl-1))) {
+                       sl = strlen(sat->suffix);
+                       if((tl == sl && !strncmp(sat->suffix, str, tl)) ||
+                          (tl == sl-1 && !strncmp(sat->suffix+1, str, tl-1))) {
                                rv |= sat->bit;
                                break;
                        }
                                rv |= sat->bit;
                                break;
                        }