|
diff --git a/cgit.c b/cgit.c index bd37788..a17f40d 100644 --- a/ cgit.c+++ b/ cgit.c |
|
@@ -164,96 +164,98 @@ void config_cb(const char *name, const char *value) |
164 | else if (!strcmp(name, "max-message-length")) |
164 | else if (!strcmp(name, "max-message-length")) |
165 | ctx.cfg.max_msg_len = atoi(value); |
165 | ctx.cfg.max_msg_len = atoi(value); |
166 | else if (!strcmp(name, "max-repodesc-length")) |
166 | else if (!strcmp(name, "max-repodesc-length")) |
167 | ctx.cfg.max_repodesc_len = atoi(value); |
167 | ctx.cfg.max_repodesc_len = atoi(value); |
168 | else if (!strcmp(name, "max-repo-count")) |
168 | else if (!strcmp(name, "max-repo-count")) |
169 | ctx.cfg.max_repo_count = atoi(value); |
169 | ctx.cfg.max_repo_count = atoi(value); |
170 | else if (!strcmp(name, "max-commit-count")) |
170 | else if (!strcmp(name, "max-commit-count")) |
171 | ctx.cfg.max_commit_count = atoi(value); |
171 | ctx.cfg.max_commit_count = atoi(value); |
172 | else if (!strcmp(name, "scan-path")) |
172 | else if (!strcmp(name, "scan-path")) |
173 | if (!ctx.cfg.nocache && ctx.cfg.cache_size) |
173 | if (!ctx.cfg.nocache && ctx.cfg.cache_size) |
174 | process_cached_repolist(value); |
174 | process_cached_repolist(value); |
175 | else |
175 | else |
176 | scan_tree(value, repo_config); |
176 | scan_tree(value, repo_config); |
177 | else if (!strcmp(name, "source-filter")) |
177 | else if (!strcmp(name, "source-filter")) |
178 | ctx.cfg.source_filter = new_filter(value, 1); |
178 | ctx.cfg.source_filter = new_filter(value, 1); |
179 | else if (!strcmp(name, "summary-log")) |
179 | else if (!strcmp(name, "summary-log")) |
180 | ctx.cfg.summary_log = atoi(value); |
180 | ctx.cfg.summary_log = atoi(value); |
181 | else if (!strcmp(name, "summary-branches")) |
181 | else if (!strcmp(name, "summary-branches")) |
182 | ctx.cfg.summary_branches = atoi(value); |
182 | ctx.cfg.summary_branches = atoi(value); |
183 | else if (!strcmp(name, "summary-tags")) |
183 | else if (!strcmp(name, "summary-tags")) |
184 | ctx.cfg.summary_tags = atoi(value); |
184 | ctx.cfg.summary_tags = atoi(value); |
185 | else if (!strcmp(name, "agefile")) |
185 | else if (!strcmp(name, "agefile")) |
186 | ctx.cfg.agefile = xstrdup(value); |
186 | ctx.cfg.agefile = xstrdup(value); |
187 | else if (!strcmp(name, "renamelimit")) |
187 | else if (!strcmp(name, "renamelimit")) |
188 | ctx.cfg.renamelimit = atoi(value); |
188 | ctx.cfg.renamelimit = atoi(value); |
189 | else if (!strcmp(name, "robots")) |
189 | else if (!strcmp(name, "robots")) |
190 | ctx.cfg.robots = xstrdup(value); |
190 | ctx.cfg.robots = xstrdup(value); |
191 | else if (!strcmp(name, "clone-prefix")) |
191 | else if (!strcmp(name, "clone-prefix")) |
192 | ctx.cfg.clone_prefix = xstrdup(value); |
192 | ctx.cfg.clone_prefix = xstrdup(value); |
193 | else if (!strcmp(name, "local-time")) |
193 | else if (!strcmp(name, "local-time")) |
194 | ctx.cfg.local_time = atoi(value); |
194 | ctx.cfg.local_time = atoi(value); |
195 | else if (!prefixcmp(name, "mimetype.")) |
195 | else if (!prefixcmp(name, "mimetype.")) |
196 | add_mimetype(name + 9, value); |
196 | add_mimetype(name + 9, value); |
197 | else if (!strcmp(name, "include")) |
197 | else if (!strcmp(name, "include")) |
198 | parse_configfile(value, config_cb); |
198 | parse_configfile(value, config_cb); |
199 | } |
199 | } |
200 | |
200 | |
201 | static void querystring_cb(const char *name, const char *value) |
201 | static void querystring_cb(const char *name, const char *value) |
202 | { |
202 | { |
203 | if (!value) |
203 | if (!value) |
204 | value = ""; |
204 | value = ""; |
205 | |
205 | |
206 | if (!strcmp(name,"r")) { |
206 | if (!strcmp(name,"r")) { |
207 | ctx.qry.repo = xstrdup(value); |
207 | ctx.qry.repo = xstrdup(value); |
208 | ctx.repo = cgit_get_repoinfo(value); |
208 | ctx.repo = cgit_get_repoinfo(value); |
209 | } else if (!strcmp(name, "p")) { |
209 | } else if (!strcmp(name, "p")) { |
210 | ctx.qry.page = xstrdup(value); |
210 | ctx.qry.page = xstrdup(value); |
211 | } else if (!strcmp(name, "url")) { |
211 | } else if (!strcmp(name, "url")) { |
| |
212 | if (*value == '/') |
| |
213 | value++; |
212 | ctx.qry.url = xstrdup(value); |
214 | ctx.qry.url = xstrdup(value); |
213 | cgit_parse_url(value); |
215 | cgit_parse_url(value); |
214 | } else if (!strcmp(name, "qt")) { |
216 | } else if (!strcmp(name, "qt")) { |
215 | ctx.qry.grep = xstrdup(value); |
217 | ctx.qry.grep = xstrdup(value); |
216 | } else if (!strcmp(name, "q")) { |
218 | } else if (!strcmp(name, "q")) { |
217 | ctx.qry.search = xstrdup(value); |
219 | ctx.qry.search = xstrdup(value); |
218 | } else if (!strcmp(name, "h")) { |
220 | } else if (!strcmp(name, "h")) { |
219 | ctx.qry.head = xstrdup(value); |
221 | ctx.qry.head = xstrdup(value); |
220 | ctx.qry.has_symref = 1; |
222 | ctx.qry.has_symref = 1; |
221 | } else if (!strcmp(name, "id")) { |
223 | } else if (!strcmp(name, "id")) { |
222 | ctx.qry.sha1 = xstrdup(value); |
224 | ctx.qry.sha1 = xstrdup(value); |
223 | ctx.qry.has_sha1 = 1; |
225 | ctx.qry.has_sha1 = 1; |
224 | } else if (!strcmp(name, "id2")) { |
226 | } else if (!strcmp(name, "id2")) { |
225 | ctx.qry.sha2 = xstrdup(value); |
227 | ctx.qry.sha2 = xstrdup(value); |
226 | ctx.qry.has_sha1 = 1; |
228 | ctx.qry.has_sha1 = 1; |
227 | } else if (!strcmp(name, "ofs")) { |
229 | } else if (!strcmp(name, "ofs")) { |
228 | ctx.qry.ofs = atoi(value); |
230 | ctx.qry.ofs = atoi(value); |
229 | } else if (!strcmp(name, "path")) { |
231 | } else if (!strcmp(name, "path")) { |
230 | ctx.qry.path = trim_end(value, '/'); |
232 | ctx.qry.path = trim_end(value, '/'); |
231 | } else if (!strcmp(name, "name")) { |
233 | } else if (!strcmp(name, "name")) { |
232 | ctx.qry.name = xstrdup(value); |
234 | ctx.qry.name = xstrdup(value); |
233 | } else if (!strcmp(name, "mimetype")) { |
235 | } else if (!strcmp(name, "mimetype")) { |
234 | ctx.qry.mimetype = xstrdup(value); |
236 | ctx.qry.mimetype = xstrdup(value); |
235 | } else if (!strcmp(name, "s")){ |
237 | } else if (!strcmp(name, "s")){ |
236 | ctx.qry.sort = xstrdup(value); |
238 | ctx.qry.sort = xstrdup(value); |
237 | } else if (!strcmp(name, "showmsg")) { |
239 | } else if (!strcmp(name, "showmsg")) { |
238 | ctx.qry.showmsg = atoi(value); |
240 | ctx.qry.showmsg = atoi(value); |
239 | } else if (!strcmp(name, "period")) { |
241 | } else if (!strcmp(name, "period")) { |
240 | ctx.qry.period = xstrdup(value); |
242 | ctx.qry.period = xstrdup(value); |
241 | } |
243 | } |
242 | } |
244 | } |
243 | |
245 | |
244 | char *xstrdupn(const char *str) |
246 | char *xstrdupn(const char *str) |
245 | { |
247 | { |
246 | return (str ? xstrdup(str) : NULL); |
248 | return (str ? xstrdup(str) : NULL); |
247 | } |
249 | } |
248 | |
250 | |
249 | static void prepare_context(struct cgit_context *ctx) |
251 | static void prepare_context(struct cgit_context *ctx) |
250 | { |
252 | { |
251 | memset(ctx, 0, sizeof(ctx)); |
253 | memset(ctx, 0, sizeof(ctx)); |
252 | ctx->cfg.agefile = "info/web/last-modified"; |
254 | ctx->cfg.agefile = "info/web/last-modified"; |
253 | ctx->cfg.nocache = 0; |
255 | ctx->cfg.nocache = 0; |
254 | ctx->cfg.cache_size = 0; |
256 | ctx->cfg.cache_size = 0; |
255 | ctx->cfg.cache_dynamic_ttl = 5; |
257 | ctx->cfg.cache_dynamic_ttl = 5; |
256 | ctx->cfg.cache_max_create_time = 5; |
258 | ctx->cfg.cache_max_create_time = 5; |
257 | ctx->cfg.cache_repo_ttl = 5; |
259 | ctx->cfg.cache_repo_ttl = 5; |
258 | ctx->cfg.cache_root = CGIT_CACHE_ROOT; |
260 | ctx->cfg.cache_root = CGIT_CACHE_ROOT; |
259 | ctx->cfg.cache_root_ttl = 5; |
261 | ctx->cfg.cache_root_ttl = 5; |
|