summaryrefslogtreecommitdiffabout
path: root/shared.c
Side-by-side diff
Diffstat (limited to 'shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--shared.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/shared.c b/shared.c
index 8e6df31..6fd70a8 100644
--- a/shared.c
+++ b/shared.c
@@ -10,3 +10,5 @@
-char *cgit_root = "/usr/src/git";
+struct repolist cgit_repolist;
+struct repoinfo *cgit_repo;
+
char *cgit_root_title = "Git repository browser";
@@ -48,7 +50,28 @@ int htmlfd = 0;
+struct repoinfo *add_repo(const char *url)
+{
+ struct repoinfo *ret;
+
+ if (++cgit_repolist.count > cgit_repolist.length) {
+ if (cgit_repolist.length == 0)
+ cgit_repolist.length = 8;
+ else
+ cgit_repolist.length *= 2;
+ cgit_repolist.repos = xrealloc(cgit_repolist.repos,
+ cgit_repolist.length *
+ sizeof(struct repoinfo));
+ }
+
+ ret = &cgit_repolist.repos[cgit_repolist.count-1];
+ ret->url = xstrdup(url);
+ ret->name = ret->url;
+ ret->path = NULL;
+ ret->desc = NULL;
+ ret->owner = NULL;
+ return ret;
+}
+
void cgit_global_config_cb(const char *name, const char *value)
{
- if (!strcmp(name, "root"))
- cgit_root = xstrdup(value);
- else if (!strcmp(name, "root-title"))
+ if (!strcmp(name, "root-title"))
cgit_root_title = xstrdup(value);
@@ -76,2 +99,12 @@ void cgit_global_config_cb(const char *name, const char *value)
cgit_max_msg_len = atoi(value);
+ else if (!strcmp(name, "repo.url"))
+ cgit_repo = add_repo(value);
+ else if (!strcmp(name, "repo.name"))
+ cgit_repo->name = xstrdup(value);
+ else if (cgit_repo && !strcmp(name, "repo.path"))
+ cgit_repo->path = xstrdup(value);
+ else if (cgit_repo && !strcmp(name, "repo.desc"))
+ cgit_repo->desc = xstrdup(value);
+ else if (cgit_repo && !strcmp(name, "repo.owner"))
+ cgit_repo->owner = xstrdup(value);
}