|
diff --git a/cgit.c b/cgit.c index 1f46e0d..763242a 100644 --- a/ cgit.c+++ b/ cgit.c |
|
@@ -1,36 +1,37 @@ |
1 | /* cgit.c: cgi for the git scm |
1 | /* cgit.c: cgi for the git scm |
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 | #include "cache.h" |
10 | #include "cache.h" |
11 | #include "cmd.h" |
11 | #include "cmd.h" |
12 | #include "configfile.h" |
12 | #include "configfile.h" |
| |
13 | #include "html.h" |
13 | #include "ui-shared.h" |
14 | #include "ui-shared.h" |
14 | |
15 | |
15 | const char *cgit_version = CGIT_VERSION; |
16 | const char *cgit_version = CGIT_VERSION; |
16 | |
17 | |
17 | void config_cb(const char *name, const char *value) |
18 | void config_cb(const char *name, const char *value) |
18 | { |
19 | { |
19 | if (!strcmp(name, "root-title")) |
20 | if (!strcmp(name, "root-title")) |
20 | ctx.cfg.root_title = xstrdup(value); |
21 | ctx.cfg.root_title = xstrdup(value); |
21 | else if (!strcmp(name, "css")) |
22 | else if (!strcmp(name, "css")) |
22 | ctx.cfg.css = xstrdup(value); |
23 | ctx.cfg.css = xstrdup(value); |
23 | else if (!strcmp(name, "logo")) |
24 | else if (!strcmp(name, "logo")) |
24 | ctx.cfg.logo = xstrdup(value); |
25 | ctx.cfg.logo = xstrdup(value); |
25 | else if (!strcmp(name, "index-header")) |
26 | else if (!strcmp(name, "index-header")) |
26 | ctx.cfg.index_header = xstrdup(value); |
27 | ctx.cfg.index_header = xstrdup(value); |
27 | else if (!strcmp(name, "index-info")) |
28 | else if (!strcmp(name, "index-info")) |
28 | ctx.cfg.index_info = xstrdup(value); |
29 | ctx.cfg.index_info = xstrdup(value); |
29 | else if (!strcmp(name, "logo-link")) |
30 | else if (!strcmp(name, "logo-link")) |
30 | ctx.cfg.logo_link = xstrdup(value); |
31 | ctx.cfg.logo_link = xstrdup(value); |
31 | else if (!strcmp(name, "module-link")) |
32 | else if (!strcmp(name, "module-link")) |
32 | ctx.cfg.module_link = xstrdup(value); |
33 | ctx.cfg.module_link = xstrdup(value); |
33 | else if (!strcmp(name, "virtual-root")) { |
34 | else if (!strcmp(name, "virtual-root")) { |
34 | ctx.cfg.virtual_root = trim_end(value, '/'); |
35 | ctx.cfg.virtual_root = trim_end(value, '/'); |
35 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) |
36 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) |
36 | ctx.cfg.virtual_root = ""; |
37 | ctx.cfg.virtual_root = ""; |
@@ -423,35 +424,35 @@ static void cgit_parse_args(int argc, const char **argv) |
423 | if (!strncmp(argv[i], "--ofs=", 6)) { |
424 | if (!strncmp(argv[i], "--ofs=", 6)) { |
424 | ctx.qry.ofs = atoi(argv[i]+6); |
425 | ctx.qry.ofs = atoi(argv[i]+6); |
425 | } |
426 | } |
426 | } |
427 | } |
427 | } |
428 | } |
428 | |
429 | |
429 | int main(int argc, const char **argv) |
430 | int main(int argc, const char **argv) |
430 | { |
431 | { |
431 | struct cacheitem item; |
432 | struct cacheitem item; |
432 | const char *cgit_config_env = getenv("CGIT_CONFIG"); |
433 | const char *cgit_config_env = getenv("CGIT_CONFIG"); |
433 | |
434 | |
434 | prepare_context(&ctx); |
435 | prepare_context(&ctx); |
435 | item.st.st_mtime = time(NULL); |
436 | item.st.st_mtime = time(NULL); |
436 | cgit_repolist.length = 0; |
437 | cgit_repolist.length = 0; |
437 | cgit_repolist.count = 0; |
438 | cgit_repolist.count = 0; |
438 | cgit_repolist.repos = NULL; |
439 | cgit_repolist.repos = NULL; |
439 | |
440 | |
440 | parse_configfile(cgit_config_env ? cgit_config_env : CGIT_CONFIG, |
441 | parse_configfile(cgit_config_env ? cgit_config_env : CGIT_CONFIG, |
441 | config_cb); |
442 | config_cb); |
442 | if (getenv("SCRIPT_NAME")) |
443 | if (getenv("SCRIPT_NAME")) |
443 | ctx.cfg.script_name = xstrdup(getenv("SCRIPT_NAME")); |
444 | ctx.cfg.script_name = xstrdup(getenv("SCRIPT_NAME")); |
444 | if (getenv("QUERY_STRING")) |
445 | if (getenv("QUERY_STRING")) |
445 | ctx.qry.raw = xstrdup(getenv("QUERY_STRING")); |
446 | ctx.qry.raw = xstrdup(getenv("QUERY_STRING")); |
446 | cgit_parse_args(argc, argv); |
447 | cgit_parse_args(argc, argv); |
447 | cgit_parse_query(ctx.qry.raw, querystring_cb); |
448 | http_parse_querystring(ctx.qry.raw, querystring_cb); |
448 | if (!cgit_prepare_cache(&item)) |
449 | if (!cgit_prepare_cache(&item)) |
449 | return 0; |
450 | return 0; |
450 | if (ctx.cfg.nocache) { |
451 | if (ctx.cfg.nocache) { |
451 | cgit_fill_cache(&item, 0); |
452 | cgit_fill_cache(&item, 0); |
452 | } else { |
453 | } else { |
453 | cgit_check_cache(&item); |
454 | cgit_check_cache(&item); |
454 | cgit_print_cache(&item); |
455 | cgit_print_cache(&item); |
455 | } |
456 | } |
456 | return 0; |
457 | return 0; |
457 | } |
458 | } |
|