blob: f47878b5f287828cd2b911dbfb6d3c17636ae0ca (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
/*
 * 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;
};

/*
 * 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