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