summaryrefslogtreecommitdiffabout
path: root/shared.c
Unidiff
Diffstat (limited to 'shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--shared.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/shared.c b/shared.c
index 84aa281..bf0581f 100644
--- a/shared.c
+++ b/shared.c
@@ -17,24 +17,26 @@ const char *cgit_version = CGIT_VERSION;
17char *cgit_root_title = "Git repository browser"; 17char *cgit_root_title = "Git repository browser";
18char *cgit_css = "/cgit.css"; 18char *cgit_css = "/cgit.css";
19char *cgit_logo = "/git-logo.png"; 19char *cgit_logo = "/git-logo.png";
20char *cgit_index_header = NULL; 20char *cgit_index_header = NULL;
21char *cgit_index_info = NULL; 21char *cgit_index_info = NULL;
22char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; 22char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/";
23char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; 23char *cgit_module_link = "./?repo=%s&page=commit&id=%s";
24char *cgit_agefile = "info/web/last-modified"; 24char *cgit_agefile = "info/web/last-modified";
25char *cgit_virtual_root = NULL; 25char *cgit_virtual_root = NULL;
26char *cgit_script_name = CGIT_SCRIPT_NAME; 26char *cgit_script_name = CGIT_SCRIPT_NAME;
27char *cgit_cache_root = CGIT_CACHE_ROOT; 27char *cgit_cache_root = CGIT_CACHE_ROOT;
28char *cgit_repo_group = NULL; 28char *cgit_repo_group = NULL;
29char *cgit_robots = "index, nofollow";
30char *cgit_clone_prefix = NULL;
29 31
30int cgit_nocache = 0; 32int cgit_nocache = 0;
31int cgit_snapshots = 0; 33int cgit_snapshots = 0;
32int cgit_enable_index_links = 0; 34int cgit_enable_index_links = 0;
33int cgit_enable_log_filecount = 0; 35int cgit_enable_log_filecount = 0;
34int cgit_enable_log_linecount = 0; 36int cgit_enable_log_linecount = 0;
35int cgit_max_lock_attempts = 5; 37int cgit_max_lock_attempts = 5;
36int cgit_cache_root_ttl = 5; 38int cgit_cache_root_ttl = 5;
37int cgit_cache_repo_ttl = 5; 39int cgit_cache_repo_ttl = 5;
38int cgit_cache_dynamic_ttl = 5; 40int cgit_cache_dynamic_ttl = 5;
39int cgit_cache_static_ttl = -1; 41int cgit_cache_static_ttl = -1;
40int cgit_cache_max_create_time = 5; 42int cgit_cache_max_create_time = 5;
@@ -59,25 +61,25 @@ char *cgit_query_grep = NULL;
59char *cgit_query_sha1 = NULL; 61char *cgit_query_sha1 = NULL;
60char *cgit_query_sha2 = NULL; 62char *cgit_query_sha2 = NULL;
61char *cgit_query_path = NULL; 63char *cgit_query_path = NULL;
62char *cgit_query_name = NULL; 64char *cgit_query_name = NULL;
63int cgit_query_ofs = 0; 65int cgit_query_ofs = 0;
64 66
65int htmlfd = 0; 67int htmlfd = 0;
66 68
67 69
68int cgit_get_cmd_index(const char *cmd) 70int cgit_get_cmd_index(const char *cmd)
69{ 71{
70 static char *cmds[] = {"log", "commit", "diff", "tree", "blob", 72 static char *cmds[] = {"log", "commit", "diff", "tree", "blob",
71 "snapshot", "tag", "refs", NULL}; 73 "snapshot", "tag", "refs", "patch", NULL};
72 int i; 74 int i;
73 75
74 for(i = 0; cmds[i]; i++) 76 for(i = 0; cmds[i]; i++)
75 if (!strcmp(cmd, cmds[i])) 77 if (!strcmp(cmd, cmds[i]))
76 return i + 1; 78 return i + 1;
77 return 0; 79 return 0;
78} 80}
79 81
80int chk_zero(int result, char *msg) 82int chk_zero(int result, char *msg)
81{ 83{
82 if (result != 0) 84 if (result != 0)
83 die("%s: %s", msg, strerror(errno)); 85 die("%s: %s", msg, strerror(errno));
@@ -188,32 +190,38 @@ void cgit_global_config_cb(const char *name, const char *value)
188 else if (!strcmp(name, "max-commit-count")) 190 else if (!strcmp(name, "max-commit-count"))
189 cgit_max_commit_count = atoi(value); 191 cgit_max_commit_count = atoi(value);
190 else if (!strcmp(name, "summary-log")) 192 else if (!strcmp(name, "summary-log"))
191 cgit_summary_log = atoi(value); 193 cgit_summary_log = atoi(value);
192 else if (!strcmp(name, "summary-branches")) 194 else if (!strcmp(name, "summary-branches"))
193 cgit_summary_branches = atoi(value); 195 cgit_summary_branches = atoi(value);
194 else if (!strcmp(name, "summary-tags")) 196 else if (!strcmp(name, "summary-tags"))
195 cgit_summary_tags = atoi(value); 197 cgit_summary_tags = atoi(value);
196 else if (!strcmp(name, "agefile")) 198 else if (!strcmp(name, "agefile"))
197 cgit_agefile = xstrdup(value); 199 cgit_agefile = xstrdup(value);
198 else if (!strcmp(name, "renamelimit")) 200 else if (!strcmp(name, "renamelimit"))
199 cgit_renamelimit = atoi(value); 201 cgit_renamelimit = atoi(value);
202 else if (!strcmp(name, "robots"))
203 cgit_robots = xstrdup(value);
204 else if (!strcmp(name, "clone-prefix"))
205 cgit_clone_prefix = xstrdup(value);
200 else if (!strcmp(name, "repo.group")) 206 else if (!strcmp(name, "repo.group"))
201 cgit_repo_group = xstrdup(value); 207 cgit_repo_group = xstrdup(value);
202 else if (!strcmp(name, "repo.url")) 208 else if (!strcmp(name, "repo.url"))
203 cgit_repo = add_repo(value); 209 cgit_repo = add_repo(value);
204 else if (!strcmp(name, "repo.name")) 210 else if (!strcmp(name, "repo.name"))
205 cgit_repo->name = xstrdup(value); 211 cgit_repo->name = xstrdup(value);
206 else if (cgit_repo && !strcmp(name, "repo.path")) 212 else if (cgit_repo && !strcmp(name, "repo.path"))
207 cgit_repo->path = trim_end(value, '/'); 213 cgit_repo->path = trim_end(value, '/');
214 else if (cgit_repo && !strcmp(name, "repo.clone-url"))
215 cgit_repo->clone_url = xstrdup(value);
208 else if (cgit_repo && !strcmp(name, "repo.desc")) 216 else if (cgit_repo && !strcmp(name, "repo.desc"))
209 cgit_repo->desc = xstrdup(value); 217 cgit_repo->desc = xstrdup(value);
210 else if (cgit_repo && !strcmp(name, "repo.owner")) 218 else if (cgit_repo && !strcmp(name, "repo.owner"))
211 cgit_repo->owner = xstrdup(value); 219 cgit_repo->owner = xstrdup(value);
212 else if (cgit_repo && !strcmp(name, "repo.defbranch")) 220 else if (cgit_repo && !strcmp(name, "repo.defbranch"))
213 cgit_repo->defbranch = xstrdup(value); 221 cgit_repo->defbranch = xstrdup(value);
214 else if (cgit_repo && !strcmp(name, "repo.snapshots")) 222 else if (cgit_repo && !strcmp(name, "repo.snapshots"))
215 cgit_repo->snapshots = cgit_snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ 223 cgit_repo->snapshots = cgit_snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */
216 else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) 224 else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount"))
217 cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value); 225 cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value);
218 else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) 226 else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount"))
219 cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value); 227 cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value);
@@ -258,24 +266,26 @@ void cgit_querystring_cb(const char *name, const char *value)
258 } else if (!strcmp(name, "name")) { 266 } else if (!strcmp(name, "name")) {
259 cgit_query_name = xstrdup(value); 267 cgit_query_name = xstrdup(value);
260 } 268 }
261} 269}
262 270
263void *cgit_free_commitinfo(struct commitinfo *info) 271void *cgit_free_commitinfo(struct commitinfo *info)
264{ 272{
265 free(info->author); 273 free(info->author);
266 free(info->author_email); 274 free(info->author_email);
267 free(info->committer); 275 free(info->committer);
268 free(info->committer_email); 276 free(info->committer_email);
269 free(info->subject); 277 free(info->subject);
278 free(info->msg);
279 free(info->msg_encoding);
270 free(info); 280 free(info);
271 return NULL; 281 return NULL;
272} 282}
273 283
274int hextoint(char c) 284int hextoint(char c)
275{ 285{
276 if (c >= 'a' && c <= 'f') 286 if (c >= 'a' && c <= 'f')
277 return 10 + c - 'a'; 287 return 10 + c - 'a';
278 else if (c >= 'A' && c <= 'F') 288 else if (c >= 'A' && c <= 'F')
279 return 10 + c - 'A'; 289 return 10 + c - 'A';
280 else if (c >= '0' && c <= '9') 290 else if (c >= '0' && c <= '9')
281 return c - '0'; 291 return c - '0';