author | Michael Krelin <hacker@klever.net> | 2007-07-02 00:29:12 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-07-03 19:28:13 (UTC) |
commit | 51f6547879e2516b9850b0b3c51df044c16a8a52 (patch) (unidiff) | |
tree | f73a2db285a41c1c8d6ece33ec7519728a392d84 | |
parent | 16a3d2779ccd56bf7954d98da547247d8796544b (diff) | |
download | cgit-51f6547879e2516b9850b0b3c51df044c16a8a52.zip cgit-51f6547879e2516b9850b0b3c51df044c16a8a52.tar.gz cgit-51f6547879e2516b9850b0b3c51df044c16a8a52.tar.bz2 |
make config adjustable via env variable CGIT_CONFIG
Signed-off-by: Michael Krelin <hacker@klever.net>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -193,57 +193,59 @@ static void cgit_parse_args(int argc, const char **argv) | |||
193 | if (!strncmp(argv[i], "--cache=", 8)) { | 193 | if (!strncmp(argv[i], "--cache=", 8)) { |
194 | cgit_cache_root = xstrdup(argv[i]+8); | 194 | cgit_cache_root = xstrdup(argv[i]+8); |
195 | } | 195 | } |
196 | if (!strcmp(argv[i], "--nocache")) { | 196 | if (!strcmp(argv[i], "--nocache")) { |
197 | cgit_nocache = 1; | 197 | cgit_nocache = 1; |
198 | } | 198 | } |
199 | if (!strncmp(argv[i], "--query=", 8)) { | 199 | if (!strncmp(argv[i], "--query=", 8)) { |
200 | cgit_querystring = xstrdup(argv[i]+8); | 200 | cgit_querystring = xstrdup(argv[i]+8); |
201 | } | 201 | } |
202 | if (!strncmp(argv[i], "--repo=", 7)) { | 202 | if (!strncmp(argv[i], "--repo=", 7)) { |
203 | cgit_query_repo = xstrdup(argv[i]+7); | 203 | cgit_query_repo = xstrdup(argv[i]+7); |
204 | } | 204 | } |
205 | if (!strncmp(argv[i], "--page=", 7)) { | 205 | if (!strncmp(argv[i], "--page=", 7)) { |
206 | cgit_query_page = xstrdup(argv[i]+7); | 206 | cgit_query_page = xstrdup(argv[i]+7); |
207 | } | 207 | } |
208 | if (!strncmp(argv[i], "--head=", 7)) { | 208 | if (!strncmp(argv[i], "--head=", 7)) { |
209 | cgit_query_head = xstrdup(argv[i]+7); | 209 | cgit_query_head = xstrdup(argv[i]+7); |
210 | cgit_query_has_symref = 1; | 210 | cgit_query_has_symref = 1; |
211 | } | 211 | } |
212 | if (!strncmp(argv[i], "--sha1=", 7)) { | 212 | if (!strncmp(argv[i], "--sha1=", 7)) { |
213 | cgit_query_sha1 = xstrdup(argv[i]+7); | 213 | cgit_query_sha1 = xstrdup(argv[i]+7); |
214 | cgit_query_has_sha1 = 1; | 214 | cgit_query_has_sha1 = 1; |
215 | } | 215 | } |
216 | if (!strncmp(argv[i], "--ofs=", 6)) { | 216 | if (!strncmp(argv[i], "--ofs=", 6)) { |
217 | cgit_query_ofs = atoi(argv[i]+6); | 217 | cgit_query_ofs = atoi(argv[i]+6); |
218 | } | 218 | } |
219 | } | 219 | } |
220 | } | 220 | } |
221 | 221 | ||
222 | int main(int argc, const char **argv) | 222 | int main(int argc, const char **argv) |
223 | { | 223 | { |
224 | struct cacheitem item; | 224 | struct cacheitem item; |
225 | const char *cgit_config_env = getenv("CGIT_CONFIG"); | ||
225 | 226 | ||
226 | htmlfd = STDOUT_FILENO; | 227 | htmlfd = STDOUT_FILENO; |
227 | item.st.st_mtime = time(NULL); | 228 | item.st.st_mtime = time(NULL); |
228 | cgit_repolist.length = 0; | 229 | cgit_repolist.length = 0; |
229 | cgit_repolist.count = 0; | 230 | cgit_repolist.count = 0; |
230 | cgit_repolist.repos = NULL; | 231 | cgit_repolist.repos = NULL; |
231 | 232 | ||
232 | cgit_read_config(CGIT_CONFIG, cgit_global_config_cb); | 233 | cgit_read_config(cgit_config_env ? cgit_config_env : CGIT_CONFIG, |
234 | cgit_global_config_cb); | ||
233 | cgit_repo = NULL; | 235 | cgit_repo = NULL; |
234 | if (getenv("SCRIPT_NAME")) | 236 | if (getenv("SCRIPT_NAME")) |
235 | cgit_script_name = xstrdup(getenv("SCRIPT_NAME")); | 237 | cgit_script_name = xstrdup(getenv("SCRIPT_NAME")); |
236 | if (getenv("QUERY_STRING")) | 238 | if (getenv("QUERY_STRING")) |
237 | cgit_querystring = xstrdup(getenv("QUERY_STRING")); | 239 | cgit_querystring = xstrdup(getenv("QUERY_STRING")); |
238 | cgit_parse_args(argc, argv); | 240 | cgit_parse_args(argc, argv); |
239 | cgit_parse_query(cgit_querystring, cgit_querystring_cb); | 241 | cgit_parse_query(cgit_querystring, cgit_querystring_cb); |
240 | if (!cgit_prepare_cache(&item)) | 242 | if (!cgit_prepare_cache(&item)) |
241 | return 0; | 243 | return 0; |
242 | if (cgit_nocache) { | 244 | if (cgit_nocache) { |
243 | cgit_fill_cache(&item, 0); | 245 | cgit_fill_cache(&item, 0); |
244 | } else { | 246 | } else { |
245 | cgit_check_cache(&item); | 247 | cgit_check_cache(&item); |
246 | cgit_print_cache(&item); | 248 | cgit_print_cache(&item); |
247 | } | 249 | } |
248 | return 0; | 250 | return 0; |
249 | } | 251 | } |