blob: a855574622063ef6a457572753fda9b5aa5639fb (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
/*
 * The dispatch table that maps the page name in a request to the function
 * rendering it. Each entry also records what the request needs resolved
 * first, so the caller can look up the repository or the path within the tree
 * and reject a bad request once, rather than every page repeating the check.
 */

#ifndef CGIT_CMD_H
#define CGIT_CMD_H

typedef void (*cgit_cmd_fn)(void);

struct cgit_cmd {
	const char *name;
	cgit_cmd_fn fn;
	unsigned int want_repo:1, want_vpath:1, is_clone:1;
	// Set on the pages that render the same bytes for the same id for
	// ever. A log or refs page named with an id still lists branches and
	// tags, which move.
	unsigned int is_static:1;
};

/*
 * The entry for the page named, or NULL when no page goes by that name.
 */
extern const struct cgit_cmd *cgit_find_cmd(const char *name);

/*
 * The entry naming ctx.qry.page, after filling in the default page for the
 * request, or NULL when no page goes by that name.
 */
extern const struct cgit_cmd *cgit_get_cmd(void);

#endif // CGIT_CMD_H