|
diff --git a/shared.c b/shared.c index 539d533..67eb67b 100644 --- a/ shared.c+++ b/ shared.c |
|
@@ -35,28 +35,16 @@ void cgit_prepare_context(struct cgit_context *ctx) |
35 | ctx->cfg.robots = "index, nofollow"; |
35 | ctx->cfg.robots = "index, nofollow"; |
36 | ctx->cfg.root_title = "Git repository browser"; |
36 | ctx->cfg.root_title = "Git repository browser"; |
37 | ctx->cfg.script_name = CGIT_SCRIPT_NAME; |
37 | ctx->cfg.script_name = CGIT_SCRIPT_NAME; |
38 | ctx->page.mimetype = "text/html"; |
38 | ctx->page.mimetype = "text/html"; |
39 | ctx->page.charset = PAGE_ENCODING; |
39 | ctx->page.charset = PAGE_ENCODING; |
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) |
58 | die("%s: %s", msg, strerror(errno)); |
46 | die("%s: %s", msg, strerror(errno)); |
59 | return result; |
47 | return result; |
60 | } |
48 | } |
61 | |
49 | |
62 | int chk_positive(int result, char *msg) |
50 | int chk_positive(int result, char *msg) |
@@ -211,17 +199,16 @@ void cgit_global_config_cb(const char *name, const char *value) |
211 | |
199 | |
212 | void cgit_querystring_cb(const char *name, const char *value) |
200 | void cgit_querystring_cb(const char *name, const char *value) |
213 | { |
201 | { |
214 | if (!strcmp(name,"r")) { |
202 | if (!strcmp(name,"r")) { |
215 | ctx.qry.repo = xstrdup(value); |
203 | ctx.qry.repo = xstrdup(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")) { |
223 | ctx.qry.grep = xstrdup(value); |
210 | ctx.qry.grep = xstrdup(value); |
224 | } else if (!strcmp(name, "q")) { |
211 | } else if (!strcmp(name, "q")) { |
225 | ctx.qry.search = xstrdup(value); |
212 | ctx.qry.search = xstrdup(value); |
226 | } else if (!strcmp(name, "h")) { |
213 | } else if (!strcmp(name, "h")) { |
227 | ctx.qry.head = xstrdup(value); |
214 | ctx.qry.head = xstrdup(value); |
|