aboutsummaryrefslogtreecommitdiff
diff refs
from: back
to: back
| flip
diff options
context:
space:
mode:
-rw-r--r--cgit.c2
-rw-r--r--cgit.h4
-rw-r--r--shared.c2
-rw-r--r--ui-shared.c2
-rw-r--r--ui-snapshot.c17
5 files changed, 10 insertions, 17 deletions
diff --git a/cgit.c b/cgit.c
index ca0a89c..d2f7b9c 100644
--- a/cgit.c
+++ b/cgit.c
@@ -765,7 +765,7 @@ static char *build_snapshot_setting(int bitmap)
struct strbuf result = STRBUF_INIT;
for (f = cgit_snapshot_formats; f->suffix; f++) {
- if (cgit_snapshot_format_bit(f) & bitmap) {
+ if (f->bit & bitmap) {
if (result.len)
strbuf_addch(&result, ' ');
strbuf_addstr(&result, f->suffix);
diff --git a/cgit.h b/cgit.h
index 0798dc5..a686390 100644
--- a/cgit.h
+++ b/cgit.h
@@ -46,8 +46,6 @@
*/
#define PAGE_ENCODING "UTF-8"
-#define BIT(x) (1U << (x))
-
typedef void (*configfn)(const char *name, const char *value);
typedef void (*filepair_fn)(struct diff_filepair *pair);
typedef void (*linediff_fn)(char *line, int len);
@@ -316,6 +314,7 @@ struct cgit_snapshot_format {
const char *suffix;
const char *mimetype;
write_archive_fn_t write_func;
+ int bit;
};
extern const char *cgit_version;
@@ -377,7 +376,6 @@ extern const char *cgit_repobasename(const char *reponame);
extern int cgit_parse_snapshots_mask(const char *str);
extern const struct object_id *cgit_snapshot_get_sig(const char *ref,
const struct cgit_snapshot_format *f);
-extern const unsigned cgit_snapshot_format_bit(const struct cgit_snapshot_format *f);
extern int cgit_open_filter(struct cgit_filter *filter, ...);
extern int cgit_close_filter(struct cgit_filter *filter);
diff --git a/shared.c b/shared.c
index d59ae7e..0a11e68 100644
--- a/shared.c
+++ b/shared.c
@@ -400,7 +400,7 @@ int cgit_parse_snapshots_mask(const char *str)
for (f = cgit_snapshot_formats; f->suffix; f++) {
if (!strcmp(item->string, f->suffix) ||
!strcmp(item->string, f->suffix + 1)) {
- rv |= cgit_snapshot_format_bit(f);
+ rv |= f->bit;
break;
}
}
diff --git a/ui-shared.c b/ui-shared.c
index e8c0723..8a786e0 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -1127,7 +1127,7 @@ void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref,
prefixlen = filename.len;
for (f = cgit_snapshot_formats; f->suffix; f++) {
- if (!(repo->snapshots & cgit_snapshot_format_bit(f)))
+ if (!(repo->snapshots & f->bit))
continue;
strbuf_setlen(&filename, prefixlen);
strbuf_addstr(&filename, f->suffix);
diff --git a/ui-snapshot.c b/ui-snapshot.c
index 83ce6e8..c7611e8 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[] = {
- { ".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 },
+ { ".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 },
{ NULL }
};
@@ -130,11 +130,6 @@ 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)
@@ -268,7 +263,7 @@ void cgit_print_snapshot(const char *head, const char *hex,
}
f = get_format(filename);
- if (!f || !(ctx.repo->snapshots & cgit_snapshot_format_bit(f))) {
+ if (!f || !(ctx.repo->snapshots & f->bit)) {
cgit_print_error_page(400, "Bad request",
"Unsupported snapshot format: %s", filename);
return;