|
diff --git a/shared.c b/shared.c index 4ddba61..65af11a 100644 --- a/ shared.c+++ b/ shared.c |
|
@@ -7,16 +7,18 @@ |
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 | |
14 | |
14 | char *cgit_root_title = "Git repository browser"; |
15 | char *cgit_root_title = "Git repository browser"; |
15 | char *cgit_css = "/cgit.css"; |
16 | char *cgit_css = "/cgit.css"; |
16 | char *cgit_logo = "/git-logo.png"; |
17 | char *cgit_logo = "/git-logo.png"; |
| |
18 | char *cgit_index_header = NULL; |
17 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; |
19 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; |
18 | char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; |
20 | char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; |
19 | char *cgit_virtual_root = NULL; |
21 | char *cgit_virtual_root = NULL; |
20 | char *cgit_script_name = CGIT_SCRIPT_NAME; |
22 | char *cgit_script_name = CGIT_SCRIPT_NAME; |
21 | char *cgit_cache_root = "/var/cache/cgit"; |
23 | char *cgit_cache_root = "/var/cache/cgit"; |
22 | char *cgit_repo_group = NULL; |
24 | char *cgit_repo_group = NULL; |
@@ -49,12 +51,24 @@ char *cgit_query_sha2 = NULL; |
49 | char *cgit_query_path = NULL; |
51 | char *cgit_query_path = NULL; |
50 | char *cgit_query_name = NULL; |
52 | char *cgit_query_name = NULL; |
51 | int cgit_query_ofs = 0; |
53 | int cgit_query_ofs = 0; |
52 | |
54 | |
53 | int htmlfd = 0; |
55 | int htmlfd = 0; |
54 | |
56 | |
| |
57 | |
| |
58 | int cgit_get_cmd_index(const char *cmd) |
| |
59 | { |
| |
60 | static char *cmds[] = {"log", "commit", "diff", "tree", "view", "blob", "snapshot", NULL}; |
| |
61 | int i; |
| |
62 | |
| |
63 | for(i = 0; cmds[i]; i++) |
| |
64 | if (!strcmp(cmd, cmds[i])) |
| |
65 | return i + 1; |
| |
66 | return 0; |
| |
67 | } |
| |
68 | |
55 | int chk_zero(int result, char *msg) |
69 | int chk_zero(int result, char *msg) |
56 | { |
70 | { |
57 | if (result != 0) |
71 | if (result != 0) |
58 | die("%s: %s", msg, strerror(errno)); |
72 | die("%s: %s", msg, strerror(errno)); |
59 | return result; |
73 | return result; |
60 | } |
74 | } |
@@ -92,20 +106,35 @@ struct repoinfo *add_repo(const char *url) |
92 | ret->enable_log_filecount = cgit_enable_log_filecount; |
106 | ret->enable_log_filecount = cgit_enable_log_filecount; |
93 | ret->enable_log_linecount = cgit_enable_log_linecount; |
107 | ret->enable_log_linecount = cgit_enable_log_linecount; |
94 | ret->module_link = cgit_module_link; |
108 | ret->module_link = cgit_module_link; |
95 | return ret; |
109 | return ret; |
96 | } |
110 | } |
97 | |
111 | |
| |
112 | struct repoinfo *cgit_get_repoinfo(const char *url) |
| |
113 | { |
| |
114 | int i; |
| |
115 | struct repoinfo *repo; |
| |
116 | |
| |
117 | for (i=0; i<cgit_repolist.count; i++) { |
| |
118 | repo = &cgit_repolist.repos[i]; |
| |
119 | if (!strcmp(repo->url, url)) |
| |
120 | return repo; |
| |
121 | } |
| |
122 | return NULL; |
| |
123 | } |
| |
124 | |
98 | void cgit_global_config_cb(const char *name, const char *value) |
125 | void cgit_global_config_cb(const char *name, const char *value) |
99 | { |
126 | { |
100 | if (!strcmp(name, "root-title")) |
127 | if (!strcmp(name, "root-title")) |
101 | cgit_root_title = xstrdup(value); |
128 | cgit_root_title = xstrdup(value); |
102 | else if (!strcmp(name, "css")) |
129 | else if (!strcmp(name, "css")) |
103 | cgit_css = xstrdup(value); |
130 | cgit_css = xstrdup(value); |
104 | else if (!strcmp(name, "logo")) |
131 | else if (!strcmp(name, "logo")) |
105 | cgit_logo = xstrdup(value); |
132 | cgit_logo = xstrdup(value); |
| |
133 | else if (!strcmp(name, "index-header")) |
| |
134 | cgit_index_header = xstrdup(value); |
106 | else if (!strcmp(name, "logo-link")) |
135 | else if (!strcmp(name, "logo-link")) |
107 | cgit_logo_link = xstrdup(value); |
136 | cgit_logo_link = xstrdup(value); |
108 | else if (!strcmp(name, "module-link")) |
137 | else if (!strcmp(name, "module-link")) |
109 | cgit_module_link = xstrdup(value); |
138 | cgit_module_link = xstrdup(value); |
110 | else if (!strcmp(name, "virtual-root")) |
139 | else if (!strcmp(name, "virtual-root")) |
111 | cgit_virtual_root = xstrdup(value); |
140 | cgit_virtual_root = xstrdup(value); |
@@ -160,14 +189,18 @@ void cgit_global_config_cb(const char *name, const char *value) |
160 | } |
189 | } |
161 | |
190 | |
162 | void cgit_querystring_cb(const char *name, const char *value) |
191 | void cgit_querystring_cb(const char *name, const char *value) |
163 | { |
192 | { |
164 | if (!strcmp(name,"r")) { |
193 | if (!strcmp(name,"r")) { |
165 | cgit_query_repo = xstrdup(value); |
194 | cgit_query_repo = xstrdup(value); |
| |
195 | cgit_repo = cgit_get_repoinfo(value); |
166 | } else if (!strcmp(name, "p")) { |
196 | } else if (!strcmp(name, "p")) { |
167 | cgit_query_page = xstrdup(value); |
197 | cgit_query_page = xstrdup(value); |
| |
198 | cgit_cmd = cgit_get_cmd_index(value); |
| |
199 | } else if (!strcmp(name, "url")) { |
| |
200 | cgit_parse_url(value); |
168 | } else if (!strcmp(name, "q")) { |
201 | } else if (!strcmp(name, "q")) { |
169 | cgit_query_search = xstrdup(value); |
202 | cgit_query_search = xstrdup(value); |
170 | } else if (!strcmp(name, "h")) { |
203 | } else if (!strcmp(name, "h")) { |
171 | cgit_query_head = xstrdup(value); |
204 | cgit_query_head = xstrdup(value); |
172 | cgit_query_has_symref = 1; |
205 | cgit_query_has_symref = 1; |
173 | } else if (!strcmp(name, "id")) { |
206 | } else if (!strcmp(name, "id")) { |
|