summaryrefslogtreecommitdiffabout
path: root/cgit.c
Unidiff
Diffstat (limited to 'cgit.c') (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/cgit.c b/cgit.c
index 2036ceb..ac882c3 100644
--- a/cgit.c
+++ b/cgit.c
@@ -335,52 +335,52 @@ static void cgit_parse_args(int argc, const char **argv)
335 } 335 }
336 } 336 }
337} 337}
338 338
339static int calc_ttl() 339static int calc_ttl()
340{ 340{
341 if (!ctx.repo) 341 if (!ctx.repo)
342 return ctx.cfg.cache_root_ttl; 342 return ctx.cfg.cache_root_ttl;
343 343
344 if (!ctx.qry.page) 344 if (!ctx.qry.page)
345 return ctx.cfg.cache_repo_ttl; 345 return ctx.cfg.cache_repo_ttl;
346 346
347 if (ctx.qry.has_symref) 347 if (ctx.qry.has_symref)
348 return ctx.cfg.cache_dynamic_ttl; 348 return ctx.cfg.cache_dynamic_ttl;
349 349
350 if (ctx.qry.has_sha1) 350 if (ctx.qry.has_sha1)
351 return ctx.cfg.cache_static_ttl; 351 return ctx.cfg.cache_static_ttl;
352 352
353 return ctx.cfg.cache_repo_ttl; 353 return ctx.cfg.cache_repo_ttl;
354} 354}
355 355
356int main(int argc, const char **argv) 356int main(int argc, const char **argv)
357{ 357{
358 const char *cgit_config_env = getenv("CGIT_CONFIG"); 358 const char *cgit_config_env = getenv("CGIT_CONFIG");
359 int err, ttl; 359 int err, ttl;
360 360
361 prepare_context(&ctx); 361 prepare_context(&ctx);
362 cgit_repolist.length = 0; 362 cgit_repolist.length = 0;
363 cgit_repolist.count = 0; 363 cgit_repolist.count = 0;
364 cgit_repolist.repos = NULL; 364 cgit_repolist.repos = NULL;
365 365
366 parse_configfile(cgit_config_env ? cgit_config_env : CGIT_CONFIG, 366 parse_configfile(cgit_config_env ? cgit_config_env : CGIT_CONFIG,
367 config_cb); 367 config_cb);
368 ctx.repo = NULL; 368 ctx.repo = NULL;
369 if (getenv("SCRIPT_NAME")) 369 if (getenv("SCRIPT_NAME"))
370 ctx.cfg.script_name = xstrdup(getenv("SCRIPT_NAME")); 370 ctx.cfg.script_name = xstrdup(getenv("SCRIPT_NAME"));
371 if (getenv("QUERY_STRING")) 371 if (getenv("QUERY_STRING"))
372 ctx.qry.raw = xstrdup(getenv("QUERY_STRING")); 372 ctx.qry.raw = xstrdup(getenv("QUERY_STRING"));
373 cgit_parse_args(argc, argv); 373 cgit_parse_args(argc, argv);
374 http_parse_querystring(ctx.qry.raw, querystring_cb); 374 http_parse_querystring(ctx.qry.raw, querystring_cb);
375 375
376 ttl = calc_ttl(); 376 ttl = calc_ttl();
377 ctx.page.expires += ttl*60; 377 ctx.page.expires += ttl*60;
378 if (ctx.cfg.nocache) 378 if (ctx.cfg.nocache)
379 ctx.cfg.cache_size = 0; 379 ctx.cfg.cache_size = 0;
380 err = cache_process(ctx.cfg.cache_size, ctx.cfg.cache_root, 380 err = cache_process(ctx.cfg.cache_size, ctx.cfg.cache_root,
381 ctx.qry.raw, ttl, process_request, &ctx); 381 ctx.qry.raw, ttl, process_request, &ctx);
382 if (err) 382 if (err)
383 cache_log("[cgit] error %d - %s\n", 383 cgit_print_error(fmt("Error processing page: %s (%d)",
384 err, strerror(err)); 384 strerror(err), err));
385 return err; 385 return err;
386} 386}