summaryrefslogtreecommitdiffabout
path: root/cgit.c
Side-by-side diff
Diffstat (limited to 'cgit.c') (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/cgit.c b/cgit.c
index 8a30c3c..f0907a1 100644
--- a/cgit.c
+++ b/cgit.c
@@ -13,3 +13,3 @@ static int cgit_prepare_cache(struct cacheitem *item)
if (!cgit_repo && ctx.qry.repo) {
- char *title = fmt("%s - %s", cgit_root_title, "Bad request");
+ char *title = fmt("%s - %s", ctx.cfg.root_title, "Bad request");
cgit_print_docstart(title, item);
@@ -22,4 +22,4 @@ static int cgit_prepare_cache(struct cacheitem *item)
if (!cgit_repo) {
- item->name = xstrdup(fmt("%s/index.html", cgit_cache_root));
- item->ttl = cgit_cache_root_ttl;
+ item->name = xstrdup(fmt("%s/index.html", ctx.cfg.cache_root));
+ item->ttl = ctx.cfg.cache_root_ttl;
return 1;
@@ -28,8 +28,8 @@ static int cgit_prepare_cache(struct cacheitem *item)
if (!cgit_cmd) {
- item->name = xstrdup(fmt("%s/%s/index.%s.html", cgit_cache_root,
+ item->name = xstrdup(fmt("%s/%s/index.%s.html", ctx.cfg.cache_root,
cache_safe_filename(cgit_repo->url),
cache_safe_filename(ctx.qry.raw)));
- item->ttl = cgit_cache_repo_ttl;
+ item->ttl = ctx.cfg.cache_repo_ttl;
} else {
- item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root,
+ item->name = xstrdup(fmt("%s/%s/%s/%s.html", ctx.cfg.cache_root,
cache_safe_filename(cgit_repo->url),
@@ -38,7 +38,7 @@ static int cgit_prepare_cache(struct cacheitem *item)
if (ctx.qry.has_symref)
- item->ttl = cgit_cache_dynamic_ttl;
+ item->ttl = ctx.cfg.cache_dynamic_ttl;
else if (ctx.qry.has_sha1)
- item->ttl = cgit_cache_static_ttl;
+ item->ttl = ctx.cfg.cache_static_ttl;
else
- item->ttl = cgit_cache_repo_ttl;
+ item->ttl = ctx.cfg.cache_repo_ttl;
}
@@ -87,3 +87,3 @@ static void cgit_print_repo_page(struct cacheitem *item)
if (chdir(cgit_repo->path)) {
- title = fmt("%s - %s", cgit_root_title, "Bad request");
+ title = fmt("%s - %s", ctx.cfg.root_title, "Bad request");
cgit_print_docstart(title, item);
@@ -155,3 +155,3 @@ static void cgit_print_repo_page(struct cacheitem *item)
cgit_print_log(ctx.qry.sha1, ctx.qry.ofs,
- cgit_max_commit_count, ctx.qry.grep, ctx.qry.search,
+ ctx.cfg.max_commit_count, ctx.qry.grep, ctx.qry.search,
ctx.qry.path, 1);
@@ -214,3 +214,3 @@ static void cgit_check_cache(struct cacheitem *item)
top:
- if (++i > cgit_max_lock_attempts) {
+ if (++i > ctx.cfg.max_lock_attempts) {
die("cgit_refresh_cache: unable to lock %s: %s",
@@ -260,6 +260,6 @@ static void cgit_parse_args(int argc, const char **argv)
if (!strncmp(argv[i], "--cache=", 8)) {
- cgit_cache_root = xstrdup(argv[i]+8);
+ ctx.cfg.cache_root = xstrdup(argv[i]+8);
}
if (!strcmp(argv[i], "--nocache")) {
- cgit_nocache = 1;
+ ctx.cfg.nocache = 1;
}
@@ -293,2 +293,3 @@ int main(int argc, const char **argv)
+ cgit_prepare_context(&ctx);
htmlfd = STDOUT_FILENO;
@@ -303,3 +304,3 @@ int main(int argc, const char **argv)
if (getenv("SCRIPT_NAME"))
- cgit_script_name = xstrdup(getenv("SCRIPT_NAME"));
+ ctx.cfg.script_name = xstrdup(getenv("SCRIPT_NAME"));
if (getenv("QUERY_STRING"))
@@ -310,3 +311,3 @@ int main(int argc, const char **argv)
return 0;
- if (cgit_nocache) {
+ if (ctx.cfg.nocache) {
cgit_fill_cache(&item, 0);