diff options
author | Lars Hjemli <hjemli@gmail.com> | 2008-03-24 09:09:39 (JST) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-03-24 09:43:48 (JST) |
commit | e0e4478e7b4812f822d60a13a33525f8e529e1e8 (patch) | |
tree | 577c3927deb9b122f940b69ca7db66afe2422814 /shared.c | |
parent | b608e88adb6f77328288afb6dd0eddf674fc9b5b (diff) | |
download | cgit-e0e4478e7b4812f822d60a13a33525f8e529e1e8.zip cgit-e0e4478e7b4812f822d60a13a33525f8e529e1e8.tar.gz |
Add command dispatcher
This simplifies the code in cgit.c and makes it easier to extend cgit with
new pages/commands.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'shared.c')
-rw-r--r-- | shared.c | 13 |
1 files changed, 0 insertions, 13 deletions
@@ -40,18 +40,6 @@ void cgit_prepare_context(struct cgit_context *ctx) | |||
40 | ctx->page.filename = NULL; | 40 | ctx->page.filename = NULL; |
41 | } | 41 | } |
42 | 42 | ||
43 | int cgit_get_cmd_index(const char *cmd) | ||
44 | { | ||
45 | static char *cmds[] = {"log", "commit", "diff", "tree", "blob", | ||
46 | "snapshot", "tag", "refs", "patch", NULL}; | ||
47 | int i; | ||
48 | |||
49 | for(i = 0; cmds[i]; i++) | ||
50 | if (!strcmp(cmd, cmds[i])) | ||
51 | return i + 1; | ||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | int chk_zero(int result, char *msg) | 43 | int chk_zero(int result, char *msg) |
56 | { | 44 | { |
57 | if (result != 0) | 45 | if (result != 0) |
@@ -216,7 +204,6 @@ void cgit_querystring_cb(const char *name, const char *value) | |||
216 | ctx.repo = cgit_get_repoinfo(value); | 204 | ctx.repo = cgit_get_repoinfo(value); |
217 | } else if (!strcmp(name, "p")) { | 205 | } else if (!strcmp(name, "p")) { |
218 | ctx.qry.page = xstrdup(value); | 206 | ctx.qry.page = xstrdup(value); |
219 | cgit_cmd = cgit_get_cmd_index(value); | ||
220 | } else if (!strcmp(name, "url")) { | 207 | } else if (!strcmp(name, "url")) { |
221 | cgit_parse_url(value); | 208 | cgit_parse_url(value); |
222 | } else if (!strcmp(name, "qt")) { | 209 | } else if (!strcmp(name, "qt")) { |