summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c89
1 files changed, 48 insertions, 41 deletions
diff --git a/cgit.c b/cgit.c
index 7264b8e..90ae124 100644
--- a/cgit.c
+++ b/cgit.c
@@ -21,51 +21,97 @@ void add_mimetype(const char *name, const char *value)
{
struct string_list_item *item;
item = string_list_insert(xstrdup(name), &ctx.cfg.mimetypes);
item->util = xstrdup(value);
}
struct cgit_filter *new_filter(const char *cmd, int extra_args)
{
struct cgit_filter *f;
if (!cmd || !cmd[0])
return NULL;
f = xmalloc(sizeof(struct cgit_filter));
f->cmd = xstrdup(cmd);
f->argv = xmalloc((2 + extra_args) * sizeof(char *));
f->argv[0] = f->cmd;
f->argv[1] = NULL;
return f;
}
static void process_cached_repolist(const char *path);
+void repo_config(struct cgit_repo *repo, const char *name, const char *value)
+{
+ if (!strcmp(name, "name"))
+ repo->name = xstrdup(value);
+ else if (!strcmp(name, "clone-url"))
+ repo->clone_url = xstrdup(value);
+ else if (!strcmp(name, "desc"))
+ repo->desc = xstrdup(value);
+ else if (!strcmp(name, "owner"))
+ repo->owner = xstrdup(value);
+ else if (!strcmp(name, "defbranch"))
+ repo->defbranch = xstrdup(value);
+ else if (!strcmp(name, "snapshots"))
+ repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value);
+ else if (!strcmp(name, "enable-log-filecount"))
+ repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value);
+ else if (!strcmp(name, "enable-log-linecount"))
+ repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value);
+ else if (!strcmp(name, "max-stats"))
+ repo->max_stats = cgit_find_stats_period(value, NULL);
+ else if (!strcmp(name, "module-link"))
+ repo->module_link= xstrdup(value);
+ else if (!strcmp(name, "section"))
+ repo->section = xstrdup(value);
+ else if (!strcmp(name, "about-filter"))
+ repo->about_filter = new_filter(value, 0);
+ else if (!strcmp(name, "commit-filter"))
+ repo->commit_filter = new_filter(value, 0);
+ else if (!strcmp(name, "source-filter"))
+ repo->source_filter = new_filter(value, 1);
+ else if (!strcmp(name, "readme") && value != NULL) {
+ if (*value == '/')
+ ctx.repo->readme = xstrdup(value);
+ else
+ ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value));
+ }
+}
+
void config_cb(const char *name, const char *value)
{
- if (!strcmp(name, "root-title"))
+ if (!strcmp(name, "section") || !strcmp(name, "repo.group"))
+ ctx.cfg.section = xstrdup(value);
+ else if (!strcmp(name, "repo.url"))
+ ctx.repo = cgit_add_repo(value);
+ else if (ctx.repo && !strcmp(name, "repo.path"))
+ ctx.repo->path = trim_end(value, '/');
+ else if (ctx.repo && !prefixcmp(name, "repo."))
+ repo_config(ctx.repo, name + 5, value);
+ else if (!strcmp(name, "root-title"))
ctx.cfg.root_title = xstrdup(value);
else if (!strcmp(name, "root-desc"))
ctx.cfg.root_desc = xstrdup(value);
else if (!strcmp(name, "root-readme"))
ctx.cfg.root_readme = xstrdup(value);
else if (!strcmp(name, "css"))
ctx.cfg.css = xstrdup(value);
else if (!strcmp(name, "favicon"))
ctx.cfg.favicon = xstrdup(value);
else if (!strcmp(name, "footer"))
ctx.cfg.footer = xstrdup(value);
else if (!strcmp(name, "head-include"))
ctx.cfg.head_include = xstrdup(value);
else if (!strcmp(name, "header"))
ctx.cfg.header = xstrdup(value);
else if (!strcmp(name, "logo"))
ctx.cfg.logo = xstrdup(value);
else if (!strcmp(name, "index-header"))
ctx.cfg.index_header = xstrdup(value);
else if (!strcmp(name, "index-info"))
ctx.cfg.index_info = xstrdup(value);
else if (!strcmp(name, "logo-link"))
ctx.cfg.logo_link = xstrdup(value);
else if (!strcmp(name, "module-link"))
@@ -122,88 +168,49 @@ void config_cb(const char *name, const char *value)
if (!ctx.cfg.nocache && ctx.cfg.cache_size)
process_cached_repolist(value);
else
scan_tree(value);
else if (!strcmp(name, "source-filter"))
ctx.cfg.source_filter = new_filter(value, 1);
else if (!strcmp(name, "summary-log"))
ctx.cfg.summary_log = atoi(value);
else if (!strcmp(name, "summary-branches"))
ctx.cfg.summary_branches = atoi(value);
else if (!strcmp(name, "summary-tags"))
ctx.cfg.summary_tags = atoi(value);
else if (!strcmp(name, "agefile"))
ctx.cfg.agefile = xstrdup(value);
else if (!strcmp(name, "renamelimit"))
ctx.cfg.renamelimit = atoi(value);
else if (!strcmp(name, "robots"))
ctx.cfg.robots = xstrdup(value);
else if (!strcmp(name, "clone-prefix"))
ctx.cfg.clone_prefix = xstrdup(value);
else if (!strcmp(name, "local-time"))
ctx.cfg.local_time = atoi(value);
else if (!prefixcmp(name, "mimetype."))
add_mimetype(name + 9, value);
- else if (!strcmp(name, "section") || !strcmp(name, "repo.group"))
- ctx.cfg.section = xstrdup(value);
- else if (!strcmp(name, "repo.url"))
- ctx.repo = cgit_add_repo(value);
- else if (!strcmp(name, "repo.name"))
- ctx.repo->name = xstrdup(value);
- else if (ctx.repo && !strcmp(name, "repo.path"))
- ctx.repo->path = trim_end(value, '/');
- else if (ctx.repo && !strcmp(name, "repo.clone-url"))
- ctx.repo->clone_url = xstrdup(value);
- else if (ctx.repo && !strcmp(name, "repo.desc"))
- ctx.repo->desc = xstrdup(value);
- else if (ctx.repo && !strcmp(name, "repo.owner"))
- ctx.repo->owner = xstrdup(value);
- else if (ctx.repo && !strcmp(name, "repo.defbranch"))
- ctx.repo->defbranch = xstrdup(value);
- else if (ctx.repo && !strcmp(name, "repo.snapshots"))
- ctx.repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */
- else if (ctx.repo && !strcmp(name, "repo.enable-log-filecount"))
- ctx.repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value);
- else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount"))
- ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value);
- else if (ctx.repo && !strcmp(name, "repo.max-stats"))
- ctx.repo->max_stats = cgit_find_stats_period(value, NULL);
- else if (ctx.repo && !strcmp(name, "repo.module-link"))
- ctx.repo->module_link= xstrdup(value);
- else if (ctx.repo && !strcmp(name, "repo.section"))
- ctx.repo->section = xstrdup(value);
- else if (ctx.repo && !strcmp(name, "repo.about-filter"))
- ctx.repo->about_filter = new_filter(value, 0);
- else if (ctx.repo && !strcmp(name, "repo.commit-filter"))
- ctx.repo->commit_filter = new_filter(value, 0);
- else if (ctx.repo && !strcmp(name, "repo.source-filter"))
- ctx.repo->source_filter = new_filter(value, 1);
- else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) {
- if (*value == '/')
- ctx.repo->readme = xstrdup(value);
- else
- ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value));
- } else if (!strcmp(name, "include"))
+ else if (!strcmp(name, "include"))
parse_configfile(value, config_cb);
}
static void querystring_cb(const char *name, const char *value)
{
if (!value)
value = "";
if (!strcmp(name,"r")) {
ctx.qry.repo = xstrdup(value);
ctx.repo = cgit_get_repoinfo(value);
} else if (!strcmp(name, "p")) {
ctx.qry.page = xstrdup(value);
} else if (!strcmp(name, "url")) {
ctx.qry.url = xstrdup(value);
cgit_parse_url(value);
} else if (!strcmp(name, "qt")) {
ctx.qry.grep = xstrdup(value);
} else if (!strcmp(name, "q")) {
ctx.qry.search = xstrdup(value);
} else if (!strcmp(name, "h")) {
ctx.qry.head = xstrdup(value);
ctx.qry.has_symref = 1;
} else if (!strcmp(name, "id")) {