|
diff --git a/shared.c b/shared.c index cd9d68d..1cd60a2 100644 --- a/ shared.c+++ b/ shared.c |
|
@@ -1,122 +1,122 @@ |
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 | |
11 | struct repolist cgit_repolist; |
11 | struct repolist cgit_repolist; |
12 | struct repoinfo *cgit_repo; |
12 | struct repoinfo *cgit_repo; |
13 | int cgit_cmd; |
13 | int cgit_cmd; |
14 | |
14 | |
15 | const char *cgit_version = CGIT_VERSION; |
15 | const char *cgit_version = CGIT_VERSION; |
16 | |
16 | |
17 | char *cgit_root_title = "Git repository browser"; |
17 | char *cgit_root_title = "Git repository browser"; |
18 | char *cgit_css = "/cgit.css"; |
18 | char *cgit_css = "/cgit.css"; |
19 | char *cgit_logo = "/git-logo.png"; |
19 | char *cgit_logo = "/git-logo.png"; |
20 | char *cgit_index_header = NULL; |
20 | char *cgit_index_header = NULL; |
21 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; |
21 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; |
22 | char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; |
22 | char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; |
23 | char *cgit_agefile = "info/web/last-modified"; |
23 | char *cgit_agefile = "info/web/last-modified"; |
24 | char *cgit_virtual_root = NULL; |
24 | char *cgit_virtual_root = NULL; |
25 | char *cgit_script_name = CGIT_SCRIPT_NAME; |
25 | char *cgit_script_name = CGIT_SCRIPT_NAME; |
26 | char *cgit_cache_root = "/var/cache/cgit"; |
26 | char *cgit_cache_root = CGIT_CACHE_ROOT; |
27 | char *cgit_repo_group = NULL; |
27 | char *cgit_repo_group = NULL; |
28 | |
28 | |
29 | int cgit_nocache = 0; |
29 | int cgit_nocache = 0; |
30 | int cgit_snapshots = 0; |
30 | int cgit_snapshots = 0; |
31 | int cgit_enable_index_links = 0; |
31 | int cgit_enable_index_links = 0; |
32 | int cgit_enable_log_filecount = 0; |
32 | int cgit_enable_log_filecount = 0; |
33 | int cgit_enable_log_linecount = 0; |
33 | int cgit_enable_log_linecount = 0; |
34 | int cgit_max_lock_attempts = 5; |
34 | int cgit_max_lock_attempts = 5; |
35 | int cgit_cache_root_ttl = 5; |
35 | int cgit_cache_root_ttl = 5; |
36 | int cgit_cache_repo_ttl = 5; |
36 | int cgit_cache_repo_ttl = 5; |
37 | int cgit_cache_dynamic_ttl = 5; |
37 | int cgit_cache_dynamic_ttl = 5; |
38 | int cgit_cache_static_ttl = -1; |
38 | int cgit_cache_static_ttl = -1; |
39 | int cgit_cache_max_create_time = 5; |
39 | int cgit_cache_max_create_time = 5; |
40 | int cgit_summary_log = 0; |
40 | int cgit_summary_log = 0; |
41 | |
41 | |
42 | int cgit_max_msg_len = 60; |
42 | int cgit_max_msg_len = 60; |
43 | int cgit_max_repodesc_len = 60; |
43 | int cgit_max_repodesc_len = 60; |
44 | int cgit_max_commit_count = 50; |
44 | int cgit_max_commit_count = 50; |
45 | |
45 | |
46 | int cgit_query_has_symref = 0; |
46 | int cgit_query_has_symref = 0; |
47 | int cgit_query_has_sha1 = 0; |
47 | int cgit_query_has_sha1 = 0; |
48 | |
48 | |
49 | char *cgit_querystring = NULL; |
49 | char *cgit_querystring = NULL; |
50 | char *cgit_query_repo = NULL; |
50 | char *cgit_query_repo = NULL; |
51 | char *cgit_query_page = NULL; |
51 | char *cgit_query_page = NULL; |
52 | char *cgit_query_head = NULL; |
52 | char *cgit_query_head = NULL; |
53 | char *cgit_query_search = NULL; |
53 | char *cgit_query_search = NULL; |
54 | char *cgit_query_sha1 = NULL; |
54 | char *cgit_query_sha1 = NULL; |
55 | char *cgit_query_sha2 = NULL; |
55 | char *cgit_query_sha2 = NULL; |
56 | char *cgit_query_path = NULL; |
56 | char *cgit_query_path = NULL; |
57 | char *cgit_query_name = NULL; |
57 | char *cgit_query_name = NULL; |
58 | int cgit_query_ofs = 0; |
58 | int cgit_query_ofs = 0; |
59 | |
59 | |
60 | int htmlfd = 0; |
60 | int htmlfd = 0; |
61 | |
61 | |
62 | |
62 | |
63 | int cgit_get_cmd_index(const char *cmd) |
63 | int cgit_get_cmd_index(const char *cmd) |
64 | { |
64 | { |
65 | static char *cmds[] = {"log", "commit", "diff", "tree", "blob", |
65 | static char *cmds[] = {"log", "commit", "diff", "tree", "blob", |
66 | "snapshot", "tag", NULL}; |
66 | "snapshot", "tag", NULL}; |
67 | int i; |
67 | int i; |
68 | |
68 | |
69 | for(i = 0; cmds[i]; i++) |
69 | for(i = 0; cmds[i]; i++) |
70 | if (!strcmp(cmd, cmds[i])) |
70 | if (!strcmp(cmd, cmds[i])) |
71 | return i + 1; |
71 | return i + 1; |
72 | return 0; |
72 | return 0; |
73 | } |
73 | } |
74 | |
74 | |
75 | int chk_zero(int result, char *msg) |
75 | int chk_zero(int result, char *msg) |
76 | { |
76 | { |
77 | if (result != 0) |
77 | if (result != 0) |
78 | die("%s: %s", msg, strerror(errno)); |
78 | die("%s: %s", msg, strerror(errno)); |
79 | return result; |
79 | return result; |
80 | } |
80 | } |
81 | |
81 | |
82 | int chk_positive(int result, char *msg) |
82 | int chk_positive(int result, char *msg) |
83 | { |
83 | { |
84 | if (result <= 0) |
84 | if (result <= 0) |
85 | die("%s: %s", msg, strerror(errno)); |
85 | die("%s: %s", msg, strerror(errno)); |
86 | return result; |
86 | return result; |
87 | } |
87 | } |
88 | |
88 | |
89 | int chk_non_negative(int result, char *msg) |
89 | int chk_non_negative(int result, char *msg) |
90 | { |
90 | { |
91 | if (result < 0) |
91 | if (result < 0) |
92 | die("%s: %s",msg, strerror(errno)); |
92 | die("%s: %s",msg, strerror(errno)); |
93 | return result; |
93 | return result; |
94 | } |
94 | } |
95 | |
95 | |
96 | struct repoinfo *add_repo(const char *url) |
96 | struct repoinfo *add_repo(const char *url) |
97 | { |
97 | { |
98 | struct repoinfo *ret; |
98 | struct repoinfo *ret; |
99 | |
99 | |
100 | if (++cgit_repolist.count > cgit_repolist.length) { |
100 | if (++cgit_repolist.count > cgit_repolist.length) { |
101 | if (cgit_repolist.length == 0) |
101 | if (cgit_repolist.length == 0) |
102 | cgit_repolist.length = 8; |
102 | cgit_repolist.length = 8; |
103 | else |
103 | else |
104 | cgit_repolist.length *= 2; |
104 | cgit_repolist.length *= 2; |
105 | cgit_repolist.repos = xrealloc(cgit_repolist.repos, |
105 | cgit_repolist.repos = xrealloc(cgit_repolist.repos, |
106 | cgit_repolist.length * |
106 | cgit_repolist.length * |
107 | sizeof(struct repoinfo)); |
107 | sizeof(struct repoinfo)); |
108 | } |
108 | } |
109 | |
109 | |
110 | ret = &cgit_repolist.repos[cgit_repolist.count-1]; |
110 | ret = &cgit_repolist.repos[cgit_repolist.count-1]; |
111 | ret->url = xstrdup(url); |
111 | ret->url = xstrdup(url); |
112 | ret->name = ret->url; |
112 | ret->name = ret->url; |
113 | ret->path = NULL; |
113 | ret->path = NULL; |
114 | ret->desc = NULL; |
114 | ret->desc = NULL; |
115 | ret->owner = NULL; |
115 | ret->owner = NULL; |
116 | ret->group = cgit_repo_group; |
116 | ret->group = cgit_repo_group; |
117 | ret->defbranch = "master"; |
117 | ret->defbranch = "master"; |
118 | ret->snapshots = cgit_snapshots; |
118 | ret->snapshots = cgit_snapshots; |
119 | ret->enable_log_filecount = cgit_enable_log_filecount; |
119 | ret->enable_log_filecount = cgit_enable_log_filecount; |
120 | ret->enable_log_linecount = cgit_enable_log_linecount; |
120 | ret->enable_log_linecount = cgit_enable_log_linecount; |
121 | ret->module_link = cgit_module_link; |
121 | ret->module_link = cgit_module_link; |
122 | ret->readme = NULL; |
122 | ret->readme = NULL; |
|