summaryrefslogtreecommitdiffabout
path: root/shared.c
Unidiff
Diffstat (limited to 'shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--shared.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/shared.c b/shared.c
index 45fde7f..65af11a 100644
--- a/shared.c
+++ b/shared.c
@@ -1,47 +1,48 @@
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
11struct repolist cgit_repolist; 11struct repolist cgit_repolist;
12struct repoinfo *cgit_repo; 12struct repoinfo *cgit_repo;
13int cgit_cmd; 13int cgit_cmd;
14 14
15char *cgit_root_title = "Git repository browser"; 15char *cgit_root_title = "Git repository browser";
16char *cgit_css = "/cgit.css"; 16char *cgit_css = "/cgit.css";
17char *cgit_logo = "/git-logo.png"; 17char *cgit_logo = "/git-logo.png";
18char *cgit_index_header = NULL; 18char *cgit_index_header = NULL;
19char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; 19char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/";
20char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; 20char *cgit_module_link = "./?repo=%s&page=commit&id=%s";
21char *cgit_virtual_root = NULL; 21char *cgit_virtual_root = NULL;
22char *cgit_script_name = CGIT_SCRIPT_NAME; 22char *cgit_script_name = CGIT_SCRIPT_NAME;
23char *cgit_cache_root = "/var/cache/cgit"; 23char *cgit_cache_root = "/var/cache/cgit";
24char *cgit_repo_group = NULL;
24 25
25int cgit_nocache = 0; 26int cgit_nocache = 0;
26int cgit_snapshots = 0; 27int cgit_snapshots = 0;
27int cgit_enable_log_filecount = 0; 28int cgit_enable_log_filecount = 0;
28int cgit_enable_log_linecount = 0; 29int cgit_enable_log_linecount = 0;
29int cgit_max_lock_attempts = 5; 30int cgit_max_lock_attempts = 5;
30int cgit_cache_root_ttl = 5; 31int cgit_cache_root_ttl = 5;
31int cgit_cache_repo_ttl = 5; 32int cgit_cache_repo_ttl = 5;
32int cgit_cache_dynamic_ttl = 5; 33int cgit_cache_dynamic_ttl = 5;
33int cgit_cache_static_ttl = -1; 34int cgit_cache_static_ttl = -1;
34int cgit_cache_max_create_time = 5; 35int cgit_cache_max_create_time = 5;
35 36
36int cgit_max_msg_len = 60; 37int cgit_max_msg_len = 60;
37int cgit_max_repodesc_len = 60; 38int cgit_max_repodesc_len = 60;
38int cgit_max_commit_count = 50; 39int cgit_max_commit_count = 50;
39 40
40int cgit_query_has_symref = 0; 41int cgit_query_has_symref = 0;
41int cgit_query_has_sha1 = 0; 42int cgit_query_has_sha1 = 0;
42 43
43char *cgit_querystring = NULL; 44char *cgit_querystring = NULL;
44char *cgit_query_repo = NULL; 45char *cgit_query_repo = NULL;
45char *cgit_query_page = NULL; 46char *cgit_query_page = NULL;
46char *cgit_query_head = NULL; 47char *cgit_query_head = NULL;
47char *cgit_query_search = NULL; 48char *cgit_query_search = NULL;
@@ -78,48 +79,49 @@ int chk_positive(int result, char *msg)
78 die("%s: %s", msg, strerror(errno)); 79 die("%s: %s", msg, strerror(errno));
79 return result; 80 return result;
80} 81}
81 82
82struct repoinfo *add_repo(const char *url) 83struct repoinfo *add_repo(const char *url)
83{ 84{
84 struct repoinfo *ret; 85 struct repoinfo *ret;
85 86
86 if (++cgit_repolist.count > cgit_repolist.length) { 87 if (++cgit_repolist.count > cgit_repolist.length) {
87 if (cgit_repolist.length == 0) 88 if (cgit_repolist.length == 0)
88 cgit_repolist.length = 8; 89 cgit_repolist.length = 8;
89 else 90 else
90 cgit_repolist.length *= 2; 91 cgit_repolist.length *= 2;
91 cgit_repolist.repos = xrealloc(cgit_repolist.repos, 92 cgit_repolist.repos = xrealloc(cgit_repolist.repos,
92 cgit_repolist.length * 93 cgit_repolist.length *
93 sizeof(struct repoinfo)); 94 sizeof(struct repoinfo));
94 } 95 }
95 96
96 ret = &cgit_repolist.repos[cgit_repolist.count-1]; 97 ret = &cgit_repolist.repos[cgit_repolist.count-1];
97 ret->url = xstrdup(url); 98 ret->url = xstrdup(url);
98 ret->name = ret->url; 99 ret->name = ret->url;
99 ret->path = NULL; 100 ret->path = NULL;
100 ret->desc = NULL; 101 ret->desc = NULL;
101 ret->owner = NULL; 102 ret->owner = NULL;
103 ret->group = cgit_repo_group;
102 ret->defbranch = "master"; 104 ret->defbranch = "master";
103 ret->snapshots = cgit_snapshots; 105 ret->snapshots = cgit_snapshots;
104 ret->enable_log_filecount = cgit_enable_log_filecount; 106 ret->enable_log_filecount = cgit_enable_log_filecount;
105 ret->enable_log_linecount = cgit_enable_log_linecount; 107 ret->enable_log_linecount = cgit_enable_log_linecount;
106 ret->module_link = cgit_module_link; 108 ret->module_link = cgit_module_link;
107 return ret; 109 return ret;
108} 110}
109 111
110struct repoinfo *cgit_get_repoinfo(const char *url) 112struct repoinfo *cgit_get_repoinfo(const char *url)
111{ 113{
112 int i; 114 int i;
113 struct repoinfo *repo; 115 struct repoinfo *repo;
114 116
115 for (i=0; i<cgit_repolist.count; i++) { 117 for (i=0; i<cgit_repolist.count; i++) {
116 repo = &cgit_repolist.repos[i]; 118 repo = &cgit_repolist.repos[i];
117 if (!strcmp(repo->url, url)) 119 if (!strcmp(repo->url, url))
118 return repo; 120 return repo;
119 } 121 }
120 return NULL; 122 return NULL;
121} 123}
122 124
123void cgit_global_config_cb(const char *name, const char *value) 125void cgit_global_config_cb(const char *name, const char *value)
124{ 126{
125 if (!strcmp(name, "root-title")) 127 if (!strcmp(name, "root-title"))
@@ -139,48 +141,50 @@ void cgit_global_config_cb(const char *name, const char *value)
139 else if (!strcmp(name, "nocache")) 141 else if (!strcmp(name, "nocache"))
140 cgit_nocache = atoi(value); 142 cgit_nocache = atoi(value);
141 else if (!strcmp(name, "snapshots")) 143 else if (!strcmp(name, "snapshots"))
142 cgit_snapshots = atoi(value); 144 cgit_snapshots = atoi(value);
143 else if (!strcmp(name, "enable-log-filecount")) 145 else if (!strcmp(name, "enable-log-filecount"))
144 cgit_enable_log_filecount = atoi(value); 146 cgit_enable_log_filecount = atoi(value);
145 else if (!strcmp(name, "enable-log-linecount")) 147 else if (!strcmp(name, "enable-log-linecount"))
146 cgit_enable_log_linecount = atoi(value); 148 cgit_enable_log_linecount = atoi(value);
147 else if (!strcmp(name, "cache-root")) 149 else if (!strcmp(name, "cache-root"))
148 cgit_cache_root = xstrdup(value); 150 cgit_cache_root = xstrdup(value);
149 else if (!strcmp(name, "cache-root-ttl")) 151 else if (!strcmp(name, "cache-root-ttl"))
150 cgit_cache_root_ttl = atoi(value); 152 cgit_cache_root_ttl = atoi(value);
151 else if (!strcmp(name, "cache-repo-ttl")) 153 else if (!strcmp(name, "cache-repo-ttl"))
152 cgit_cache_repo_ttl = atoi(value); 154 cgit_cache_repo_ttl = atoi(value);
153 else if (!strcmp(name, "cache-static-ttl")) 155 else if (!strcmp(name, "cache-static-ttl"))
154 cgit_cache_static_ttl = atoi(value); 156 cgit_cache_static_ttl = atoi(value);
155 else if (!strcmp(name, "cache-dynamic-ttl")) 157 else if (!strcmp(name, "cache-dynamic-ttl"))
156 cgit_cache_dynamic_ttl = atoi(value); 158 cgit_cache_dynamic_ttl = atoi(value);
157 else if (!strcmp(name, "max-message-length")) 159 else if (!strcmp(name, "max-message-length"))
158 cgit_max_msg_len = atoi(value); 160 cgit_max_msg_len = atoi(value);
159 else if (!strcmp(name, "max-repodesc-length")) 161 else if (!strcmp(name, "max-repodesc-length"))
160 cgit_max_repodesc_len = atoi(value); 162 cgit_max_repodesc_len = atoi(value);
161 else if (!strcmp(name, "max-commit-count")) 163 else if (!strcmp(name, "max-commit-count"))
162 cgit_max_commit_count = atoi(value); 164 cgit_max_commit_count = atoi(value);
165 else if (!strcmp(name, "repo.group"))
166 cgit_repo_group = xstrdup(value);
163 else if (!strcmp(name, "repo.url")) 167 else if (!strcmp(name, "repo.url"))
164 cgit_repo = add_repo(value); 168 cgit_repo = add_repo(value);
165 else if (!strcmp(name, "repo.name")) 169 else if (!strcmp(name, "repo.name"))
166 cgit_repo->name = xstrdup(value); 170 cgit_repo->name = xstrdup(value);
167 else if (cgit_repo && !strcmp(name, "repo.path")) 171 else if (cgit_repo && !strcmp(name, "repo.path"))
168 cgit_repo->path = xstrdup(value); 172 cgit_repo->path = xstrdup(value);
169 else if (cgit_repo && !strcmp(name, "repo.desc")) 173 else if (cgit_repo && !strcmp(name, "repo.desc"))
170 cgit_repo->desc = xstrdup(value); 174 cgit_repo->desc = xstrdup(value);
171 else if (cgit_repo && !strcmp(name, "repo.owner")) 175 else if (cgit_repo && !strcmp(name, "repo.owner"))
172 cgit_repo->owner = xstrdup(value); 176 cgit_repo->owner = xstrdup(value);
173 else if (cgit_repo && !strcmp(name, "repo.defbranch")) 177 else if (cgit_repo && !strcmp(name, "repo.defbranch"))
174 cgit_repo->defbranch = xstrdup(value); 178 cgit_repo->defbranch = xstrdup(value);
175 else if (cgit_repo && !strcmp(name, "repo.snapshots")) 179 else if (cgit_repo && !strcmp(name, "repo.snapshots"))
176 cgit_repo->snapshots = cgit_snapshots * atoi(value); 180 cgit_repo->snapshots = cgit_snapshots * atoi(value);
177 else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) 181 else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount"))
178 cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value); 182 cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value);
179 else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) 183 else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount"))
180 cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value); 184 cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value);
181 else if (cgit_repo && !strcmp(name, "repo.module-link")) 185 else if (cgit_repo && !strcmp(name, "repo.module-link"))
182 cgit_repo->module_link= xstrdup(value); 186 cgit_repo->module_link= xstrdup(value);
183 else if (!strcmp(name, "include")) 187 else if (!strcmp(name, "include"))
184 cgit_read_config(value, cgit_global_config_cb); 188 cgit_read_config(value, cgit_global_config_cb);
185} 189}
186 190