+ struct string_list_item *item;
+
+ item = string_list_insert(&ctx.cfg.mimetypes, xstrdup(name));
+ item->util = xstrdup(value);
+}
+
+static struct cgit_filter *new_filter(const char *cmd, filter_type filtertype)
+{
+ struct cgit_filter *f;
+ int args_size = 0;
+ int extra_args;
+
+ if (!cmd || !cmd[0])
+ return NULL;
+
+ switch (filtertype) {
+ case SOURCE:
+ extra_args = 1;
+ break;
+
+ case ABOUT:
+ case COMMIT:
+ default:
+ extra_args = 0;
+ break;
+ }
+
+ f = xmalloc(sizeof(struct cgit_filter));
+ f->cmd = xstrdup(cmd);
+ args_size = (2 + extra_args) * sizeof(char *);
+ f->argv = xmalloc(args_size);
+ memset(f->argv, 0, args_size);
+ f->argv[0] = f->cmd;
+ return f;
+}
+
+static void process_cached_repolist(const char *path);
+
+static void repo_config(struct cgit_repo *repo, const char *name, const char *value)
+{
+ struct string_list_item *item;
+
+ 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-commit-graph"))
+ repo->enable_commit_graph = atoi(value);
+ else if (!strcmp(name, "enable-log-filecount"))
+ repo->enable_log_filecount = atoi(value);
+ else if (!strcmp(name, "enable-log-linecount"))
+ repo->enable_log_linecount = atoi(value);
+ else if (!strcmp(name, "enable-remote-branches"))
+ repo->enable_remote_branches = atoi(value);
+ else if (!strcmp(name, "enable-subject-links"))
+ repo->enable_subject_links = atoi(value);
+ else if (!strcmp(name, "commit-sort")) {
+ if (!strcmp(value, "date"))
+ repo->commit_sort = 1;
+ if (!strcmp(value, "topo"))
+ repo->commit_sort = 2;
+ } 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 (!prefixcmp(name, "module-link.")) {
+ item = string_list_append(&repo->submodules, name + 12);
+ item->util = xstrdup(value);
+ } else if (!strcmp(name, "section"))
+ repo->section = xstrdup(value);
+ else if (!strcmp(name, "readme") && value != NULL)
+ repo->readme = xstrdup(value);
+ else if (!strcmp(name, "logo") && value != NULL)
+ repo->logo = xstrdup(value);
+ else if (!strcmp(name, "logo-link") && value != NULL)
+ repo->logo_link = xstrdup(value);
+ else if (ctx.cfg.enable_filter_overrides) {
+ if (!strcmp(name, "about-filter"))
+ repo->about_filter = new_filter(value, ABOUT);
+ else if (!strcmp(name, "commit-filter"))
+ repo->commit_filter = new_filter(value, COMMIT);
+ else if (!strcmp(name, "source-filter"))
+ repo->source_filter = new_filter(value, SOURCE);
+ }
+}
+
+static void config_cb(const char *name, const char *value)
+{
+ 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, "readme"))
+ ctx.cfg.readme = xstrdup(value);
+ else if (!strcmp(name, "root-title"))