blob: c594168e1a76d5f94e8a373607d3a8765fd60b88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 * The snapshot page, which serves a commit as a downloadable archive. It owns
 * the table of formats cgit knows how to write, so the config reader and the
 * link builders both reach through here to ask which formats a repository
 * offers. Each format has a bit in the per-repository snapshots mask, taken
 * from its position in that table.
 */

#ifndef CGIT_UI_SNAPSHOT_H
#define CGIT_UI_SNAPSHOT_H

#include "cgit.h"

typedef int (*write_archive_fn_t)(const char *hex, const char *prefix);

struct cgit_snapshot_format {
	const char *suffix;
	const char *mimetype;
	write_archive_fn_t write_func;
};

// Terminated by an entry with a NULL suffix.
extern const struct cgit_snapshot_format cgit_snapshot_formats[];

extern unsigned cgit_snapshot_format_bit(const struct cgit_snapshot_format *f);

/*
 * Turn a cgitrc snapshots value into a mask over cgit_snapshot_formats. A
 * plain nonzero number is the legacy boolean form and enables plain tar
 * alone, the word all enables every format, and otherwise the value is a
 * space separated list of suffixes.
 */
extern int cgit_parse_snapshots_mask(const char *str);

// The detached signature stored for this format under refs/notes, if any.
extern const struct object_id *cgit_snapshot_get_sig(
	const char *ref, const struct cgit_snapshot_format *f);

extern void cgit_print_snapshot(const char *head, const char *hex, const char *filename, int dwim);

#endif // CGIT_UI_SNAPSHOT_H