|
diff --git a/cgit.c b/cgit.c index b3dd119..3943a0f 100644 --- a/ cgit.c+++ b/ cgit.c |
|
@@ -1,108 +1,110 @@ |
1 | /* cgit.c: cgi for the git scm |
1 | /* cgit.c: cgi for the git scm |
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 | #include "cmd.h" |
10 | #include "cmd.h" |
11 | #include "ui-shared.h" |
11 | #include "ui-shared.h" |
12 | |
12 | |
| |
13 | const char *cgit_version = CGIT_VERSION; |
| |
14 | |
13 | void config_cb(const char *name, const char *value) |
15 | void config_cb(const char *name, const char *value) |
14 | { |
16 | { |
15 | if (!strcmp(name, "root-title")) |
17 | if (!strcmp(name, "root-title")) |
16 | ctx.cfg.root_title = xstrdup(value); |
18 | ctx.cfg.root_title = xstrdup(value); |
17 | else if (!strcmp(name, "css")) |
19 | else if (!strcmp(name, "css")) |
18 | ctx.cfg.css = xstrdup(value); |
20 | ctx.cfg.css = xstrdup(value); |
19 | else if (!strcmp(name, "logo")) |
21 | else if (!strcmp(name, "logo")) |
20 | ctx.cfg.logo = xstrdup(value); |
22 | ctx.cfg.logo = xstrdup(value); |
21 | else if (!strcmp(name, "index-header")) |
23 | else if (!strcmp(name, "index-header")) |
22 | ctx.cfg.index_header = xstrdup(value); |
24 | ctx.cfg.index_header = xstrdup(value); |
23 | else if (!strcmp(name, "index-info")) |
25 | else if (!strcmp(name, "index-info")) |
24 | ctx.cfg.index_info = xstrdup(value); |
26 | ctx.cfg.index_info = xstrdup(value); |
25 | else if (!strcmp(name, "logo-link")) |
27 | else if (!strcmp(name, "logo-link")) |
26 | ctx.cfg.logo_link = xstrdup(value); |
28 | ctx.cfg.logo_link = xstrdup(value); |
27 | else if (!strcmp(name, "module-link")) |
29 | else if (!strcmp(name, "module-link")) |
28 | ctx.cfg.module_link = xstrdup(value); |
30 | ctx.cfg.module_link = xstrdup(value); |
29 | else if (!strcmp(name, "virtual-root")) { |
31 | else if (!strcmp(name, "virtual-root")) { |
30 | ctx.cfg.virtual_root = trim_end(value, '/'); |
32 | ctx.cfg.virtual_root = trim_end(value, '/'); |
31 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) |
33 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) |
32 | ctx.cfg.virtual_root = ""; |
34 | ctx.cfg.virtual_root = ""; |
33 | } else if (!strcmp(name, "nocache")) |
35 | } else if (!strcmp(name, "nocache")) |
34 | ctx.cfg.nocache = atoi(value); |
36 | ctx.cfg.nocache = atoi(value); |
35 | else if (!strcmp(name, "snapshots")) |
37 | else if (!strcmp(name, "snapshots")) |
36 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); |
38 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); |
37 | else if (!strcmp(name, "enable-index-links")) |
39 | else if (!strcmp(name, "enable-index-links")) |
38 | ctx.cfg.enable_index_links = atoi(value); |
40 | ctx.cfg.enable_index_links = atoi(value); |
39 | else if (!strcmp(name, "enable-log-filecount")) |
41 | else if (!strcmp(name, "enable-log-filecount")) |
40 | ctx.cfg.enable_log_filecount = atoi(value); |
42 | ctx.cfg.enable_log_filecount = atoi(value); |
41 | else if (!strcmp(name, "enable-log-linecount")) |
43 | else if (!strcmp(name, "enable-log-linecount")) |
42 | ctx.cfg.enable_log_linecount = atoi(value); |
44 | ctx.cfg.enable_log_linecount = atoi(value); |
43 | else if (!strcmp(name, "cache-root")) |
45 | else if (!strcmp(name, "cache-root")) |
44 | ctx.cfg.cache_root = xstrdup(value); |
46 | ctx.cfg.cache_root = xstrdup(value); |
45 | else if (!strcmp(name, "cache-root-ttl")) |
47 | else if (!strcmp(name, "cache-root-ttl")) |
46 | ctx.cfg.cache_root_ttl = atoi(value); |
48 | ctx.cfg.cache_root_ttl = atoi(value); |
47 | else if (!strcmp(name, "cache-repo-ttl")) |
49 | else if (!strcmp(name, "cache-repo-ttl")) |
48 | ctx.cfg.cache_repo_ttl = atoi(value); |
50 | ctx.cfg.cache_repo_ttl = atoi(value); |
49 | else if (!strcmp(name, "cache-static-ttl")) |
51 | else if (!strcmp(name, "cache-static-ttl")) |
50 | ctx.cfg.cache_static_ttl = atoi(value); |
52 | ctx.cfg.cache_static_ttl = atoi(value); |
51 | else if (!strcmp(name, "cache-dynamic-ttl")) |
53 | else if (!strcmp(name, "cache-dynamic-ttl")) |
52 | ctx.cfg.cache_dynamic_ttl = atoi(value); |
54 | ctx.cfg.cache_dynamic_ttl = atoi(value); |
53 | else if (!strcmp(name, "max-message-length")) |
55 | else if (!strcmp(name, "max-message-length")) |
54 | ctx.cfg.max_msg_len = atoi(value); |
56 | ctx.cfg.max_msg_len = atoi(value); |
55 | else if (!strcmp(name, "max-repodesc-length")) |
57 | else if (!strcmp(name, "max-repodesc-length")) |
56 | ctx.cfg.max_repodesc_len = atoi(value); |
58 | ctx.cfg.max_repodesc_len = atoi(value); |
57 | else if (!strcmp(name, "max-commit-count")) |
59 | else if (!strcmp(name, "max-commit-count")) |
58 | ctx.cfg.max_commit_count = atoi(value); |
60 | ctx.cfg.max_commit_count = atoi(value); |
59 | else if (!strcmp(name, "summary-log")) |
61 | else if (!strcmp(name, "summary-log")) |
60 | ctx.cfg.summary_log = atoi(value); |
62 | ctx.cfg.summary_log = atoi(value); |
61 | else if (!strcmp(name, "summary-branches")) |
63 | else if (!strcmp(name, "summary-branches")) |
62 | ctx.cfg.summary_branches = atoi(value); |
64 | ctx.cfg.summary_branches = atoi(value); |
63 | else if (!strcmp(name, "summary-tags")) |
65 | else if (!strcmp(name, "summary-tags")) |
64 | ctx.cfg.summary_tags = atoi(value); |
66 | ctx.cfg.summary_tags = atoi(value); |
65 | else if (!strcmp(name, "agefile")) |
67 | else if (!strcmp(name, "agefile")) |
66 | ctx.cfg.agefile = xstrdup(value); |
68 | ctx.cfg.agefile = xstrdup(value); |
67 | else if (!strcmp(name, "renamelimit")) |
69 | else if (!strcmp(name, "renamelimit")) |
68 | ctx.cfg.renamelimit = atoi(value); |
70 | ctx.cfg.renamelimit = atoi(value); |
69 | else if (!strcmp(name, "robots")) |
71 | else if (!strcmp(name, "robots")) |
70 | ctx.cfg.robots = xstrdup(value); |
72 | ctx.cfg.robots = xstrdup(value); |
71 | else if (!strcmp(name, "clone-prefix")) |
73 | else if (!strcmp(name, "clone-prefix")) |
72 | ctx.cfg.clone_prefix = xstrdup(value); |
74 | ctx.cfg.clone_prefix = xstrdup(value); |
73 | else if (!strcmp(name, "repo.group")) |
75 | else if (!strcmp(name, "repo.group")) |
74 | ctx.cfg.repo_group = xstrdup(value); |
76 | ctx.cfg.repo_group = xstrdup(value); |
75 | else if (!strcmp(name, "repo.url")) |
77 | else if (!strcmp(name, "repo.url")) |
76 | ctx.repo = cgit_add_repo(value); |
78 | ctx.repo = cgit_add_repo(value); |
77 | else if (!strcmp(name, "repo.name")) |
79 | else if (!strcmp(name, "repo.name")) |
78 | ctx.repo->name = xstrdup(value); |
80 | ctx.repo->name = xstrdup(value); |
79 | else if (ctx.repo && !strcmp(name, "repo.path")) |
81 | else if (ctx.repo && !strcmp(name, "repo.path")) |
80 | ctx.repo->path = trim_end(value, '/'); |
82 | ctx.repo->path = trim_end(value, '/'); |
81 | else if (ctx.repo && !strcmp(name, "repo.clone-url")) |
83 | else if (ctx.repo && !strcmp(name, "repo.clone-url")) |
82 | ctx.repo->clone_url = xstrdup(value); |
84 | ctx.repo->clone_url = xstrdup(value); |
83 | else if (ctx.repo && !strcmp(name, "repo.desc")) |
85 | else if (ctx.repo && !strcmp(name, "repo.desc")) |
84 | ctx.repo->desc = xstrdup(value); |
86 | ctx.repo->desc = xstrdup(value); |
85 | else if (ctx.repo && !strcmp(name, "repo.owner")) |
87 | else if (ctx.repo && !strcmp(name, "repo.owner")) |
86 | ctx.repo->owner = xstrdup(value); |
88 | ctx.repo->owner = xstrdup(value); |
87 | else if (ctx.repo && !strcmp(name, "repo.defbranch")) |
89 | else if (ctx.repo && !strcmp(name, "repo.defbranch")) |
88 | ctx.repo->defbranch = xstrdup(value); |
90 | ctx.repo->defbranch = xstrdup(value); |
89 | else if (ctx.repo && !strcmp(name, "repo.snapshots")) |
91 | else if (ctx.repo && !strcmp(name, "repo.snapshots")) |
90 | ctx.repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ |
92 | ctx.repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ |
91 | else if (ctx.repo && !strcmp(name, "repo.enable-log-filecount")) |
93 | else if (ctx.repo && !strcmp(name, "repo.enable-log-filecount")) |
92 | ctx.repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); |
94 | ctx.repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); |
93 | else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount")) |
95 | else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount")) |
94 | ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); |
96 | ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); |
95 | else if (ctx.repo && !strcmp(name, "repo.module-link")) |
97 | else if (ctx.repo && !strcmp(name, "repo.module-link")) |
96 | ctx.repo->module_link= xstrdup(value); |
98 | ctx.repo->module_link= xstrdup(value); |
97 | else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) { |
99 | else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) { |
98 | if (*value == '/') |
100 | if (*value == '/') |
99 | ctx.repo->readme = xstrdup(value); |
101 | ctx.repo->readme = xstrdup(value); |
100 | else |
102 | else |
101 | ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value)); |
103 | ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value)); |
102 | } else if (!strcmp(name, "include")) |
104 | } else if (!strcmp(name, "include")) |
103 | cgit_read_config(value, config_cb); |
105 | cgit_read_config(value, config_cb); |
104 | } |
106 | } |
105 | |
107 | |
106 | static void querystring_cb(const char *name, const char *value) |
108 | static void querystring_cb(const char *name, const char *value) |
107 | { |
109 | { |
108 | if (!strcmp(name,"r")) { |
110 | if (!strcmp(name,"r")) { |
|