|
diff --git a/shared.c b/shared.c index f063894..6c1a762 100644 --- a/ shared.c+++ b/ shared.c |
|
@@ -1,24 +1,25 @@ |
1 | /* shared.c: global vars + some callback functions |
1 | /* shared.c: global vars + some callback functions |
2 | * |
2 | * |
3 | * Copyright (C) 2006 Lars Hjemli |
3 | * Copyright (C) 2006 Lars Hjemli |
4 | * |
4 | * |
5 | * Licensed under GNU General Public License v2 |
5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) |
6 | * (see COPYING for full license text) |
7 | */ |
7 | */ |
8 | |
8 | |
9 | #include "cgit.h" |
9 | #include "cgit.h" |
10 | |
10 | |
11 | struct repolist cgit_repolist; |
11 | struct repolist cgit_repolist; |
12 | struct repoinfo *cgit_repo; |
12 | struct repoinfo *cgit_repo; |
| |
13 | struct cgit_context ctx; |
13 | int cgit_cmd; |
14 | int cgit_cmd; |
14 | |
15 | |
15 | const char *cgit_version = CGIT_VERSION; |
16 | const char *cgit_version = CGIT_VERSION; |
16 | |
17 | |
17 | char *cgit_root_title = "Git repository browser"; |
18 | char *cgit_root_title = "Git repository browser"; |
18 | char *cgit_css = "/cgit.css"; |
19 | char *cgit_css = "/cgit.css"; |
19 | char *cgit_logo = "/git-logo.png"; |
20 | char *cgit_logo = "/git-logo.png"; |
20 | char *cgit_index_header = NULL; |
21 | char *cgit_index_header = NULL; |
21 | char *cgit_index_info = NULL; |
22 | char *cgit_index_info = NULL; |
22 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; |
23 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; |
23 | char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; |
24 | char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; |
24 | char *cgit_agefile = "info/web/last-modified"; |
25 | char *cgit_agefile = "info/web/last-modified"; |
@@ -40,42 +41,26 @@ int cgit_cache_repo_ttl = 5; |
40 | int cgit_cache_dynamic_ttl = 5; |
41 | int cgit_cache_dynamic_ttl = 5; |
41 | int cgit_cache_static_ttl = -1; |
42 | int cgit_cache_static_ttl = -1; |
42 | int cgit_cache_max_create_time = 5; |
43 | int cgit_cache_max_create_time = 5; |
43 | int cgit_summary_log = 0; |
44 | int cgit_summary_log = 0; |
44 | int cgit_summary_tags = 0; |
45 | int cgit_summary_tags = 0; |
45 | int cgit_summary_branches = 0; |
46 | int cgit_summary_branches = 0; |
46 | int cgit_renamelimit = -1; |
47 | int cgit_renamelimit = -1; |
47 | |
48 | |
48 | int cgit_max_msg_len = 60; |
49 | int cgit_max_msg_len = 60; |
49 | int cgit_max_repodesc_len = 60; |
50 | int cgit_max_repodesc_len = 60; |
50 | int cgit_max_commit_count = 50; |
51 | int cgit_max_commit_count = 50; |
51 | |
52 | |
52 | int cgit_query_has_symref = 0; |
| |
53 | int cgit_query_has_sha1 = 0; |
| |
54 | |
| |
55 | char *cgit_querystring = NULL; |
| |
56 | char *cgit_query_repo = NULL; |
| |
57 | char *cgit_query_page = NULL; |
| |
58 | char *cgit_query_head = NULL; |
| |
59 | char *cgit_query_search = NULL; |
| |
60 | char *cgit_query_grep = NULL; |
| |
61 | char *cgit_query_sha1 = NULL; |
| |
62 | char *cgit_query_sha2 = NULL; |
| |
63 | char *cgit_query_path = NULL; |
| |
64 | char *cgit_query_name = NULL; |
| |
65 | int cgit_query_ofs = 0; |
| |
66 | |
| |
67 | int htmlfd = 0; |
53 | int htmlfd = 0; |
68 | |
54 | |
69 | |
| |
70 | int cgit_get_cmd_index(const char *cmd) |
55 | int cgit_get_cmd_index(const char *cmd) |
71 | { |
56 | { |
72 | static char *cmds[] = {"log", "commit", "diff", "tree", "blob", |
57 | static char *cmds[] = {"log", "commit", "diff", "tree", "blob", |
73 | "snapshot", "tag", "refs", "patch", NULL}; |
58 | "snapshot", "tag", "refs", "patch", NULL}; |
74 | int i; |
59 | int i; |
75 | |
60 | |
76 | for(i = 0; cmds[i]; i++) |
61 | for(i = 0; cmds[i]; i++) |
77 | if (!strcmp(cmd, cmds[i])) |
62 | if (!strcmp(cmd, cmds[i])) |
78 | return i + 1; |
63 | return i + 1; |
79 | return 0; |
64 | return 0; |
80 | } |
65 | } |
81 | |
66 | |
@@ -230,50 +215,50 @@ void cgit_global_config_cb(const char *name, const char *value) |
230 | else if (cgit_repo && !strcmp(name, "repo.readme") && value != NULL) { |
215 | else if (cgit_repo && !strcmp(name, "repo.readme") && value != NULL) { |
231 | if (*value == '/') |
216 | if (*value == '/') |
232 | cgit_repo->readme = xstrdup(value); |
217 | cgit_repo->readme = xstrdup(value); |
233 | else |
218 | else |
234 | cgit_repo->readme = xstrdup(fmt("%s/%s", cgit_repo->path, value)); |
219 | cgit_repo->readme = xstrdup(fmt("%s/%s", cgit_repo->path, value)); |
235 | } else if (!strcmp(name, "include")) |
220 | } else if (!strcmp(name, "include")) |
236 | cgit_read_config(value, cgit_global_config_cb); |
221 | cgit_read_config(value, cgit_global_config_cb); |
237 | } |
222 | } |
238 | |
223 | |
239 | void cgit_querystring_cb(const char *name, const char *value) |
224 | void cgit_querystring_cb(const char *name, const char *value) |
240 | { |
225 | { |
241 | if (!strcmp(name,"r")) { |
226 | if (!strcmp(name,"r")) { |
242 | cgit_query_repo = xstrdup(value); |
227 | ctx.qry.repo = xstrdup(value); |
243 | cgit_repo = cgit_get_repoinfo(value); |
228 | cgit_repo = cgit_get_repoinfo(value); |
244 | } else if (!strcmp(name, "p")) { |
229 | } else if (!strcmp(name, "p")) { |
245 | cgit_query_page = xstrdup(value); |
230 | ctx.qry.page = xstrdup(value); |
246 | cgit_cmd = cgit_get_cmd_index(value); |
231 | cgit_cmd = cgit_get_cmd_index(value); |
247 | } else if (!strcmp(name, "url")) { |
232 | } else if (!strcmp(name, "url")) { |
248 | cgit_parse_url(value); |
233 | cgit_parse_url(value); |
249 | } else if (!strcmp(name, "qt")) { |
234 | } else if (!strcmp(name, "qt")) { |
250 | cgit_query_grep = xstrdup(value); |
235 | ctx.qry.grep = xstrdup(value); |
251 | } else if (!strcmp(name, "q")) { |
236 | } else if (!strcmp(name, "q")) { |
252 | cgit_query_search = xstrdup(value); |
237 | ctx.qry.search = xstrdup(value); |
253 | } else if (!strcmp(name, "h")) { |
238 | } else if (!strcmp(name, "h")) { |
254 | cgit_query_head = xstrdup(value); |
239 | ctx.qry.head = xstrdup(value); |
255 | cgit_query_has_symref = 1; |
240 | ctx.qry.has_symref = 1; |
256 | } else if (!strcmp(name, "id")) { |
241 | } else if (!strcmp(name, "id")) { |
257 | cgit_query_sha1 = xstrdup(value); |
242 | ctx.qry.sha1 = xstrdup(value); |
258 | cgit_query_has_sha1 = 1; |
243 | ctx.qry.has_sha1 = 1; |
259 | } else if (!strcmp(name, "id2")) { |
244 | } else if (!strcmp(name, "id2")) { |
260 | cgit_query_sha2 = xstrdup(value); |
245 | ctx.qry.sha2 = xstrdup(value); |
261 | cgit_query_has_sha1 = 1; |
246 | ctx.qry.has_sha1 = 1; |
262 | } else if (!strcmp(name, "ofs")) { |
247 | } else if (!strcmp(name, "ofs")) { |
263 | cgit_query_ofs = atoi(value); |
248 | ctx.qry.ofs = atoi(value); |
264 | } else if (!strcmp(name, "path")) { |
249 | } else if (!strcmp(name, "path")) { |
265 | cgit_query_path = trim_end(value, '/'); |
250 | ctx.qry.path = trim_end(value, '/'); |
266 | } else if (!strcmp(name, "name")) { |
251 | } else if (!strcmp(name, "name")) { |
267 | cgit_query_name = xstrdup(value); |
252 | ctx.qry.name = xstrdup(value); |
268 | } |
253 | } |
269 | } |
254 | } |
270 | |
255 | |
271 | void *cgit_free_commitinfo(struct commitinfo *info) |
256 | void *cgit_free_commitinfo(struct commitinfo *info) |
272 | { |
257 | { |
273 | free(info->author); |
258 | free(info->author); |
274 | free(info->author_email); |
259 | free(info->author_email); |
275 | free(info->committer); |
260 | free(info->committer); |
276 | free(info->committer_email); |
261 | free(info->committer_email); |
277 | free(info->subject); |
262 | free(info->subject); |
278 | free(info->msg); |
263 | free(info->msg); |
279 | free(info->msg_encoding); |
264 | free(info->msg_encoding); |
|