summaryrefslogtreecommitdiffabout
path: root/shared.c
Unidiff
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
@@ -1,23 +1,25 @@
1/* shared.c: global vars + some callback functions 1/* shared.c: global vars + some callback functions
2 * 2 *
3 * Copyright (C) 2006 Lars Hjemli 3 * Copyright (C) 2006 Lars Hjemli
4 * 4 *
5 * Licensed under GNU General Public License v2 5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text) 6 * (see COPYING for full license text)
7 */ 7 */
8 8
9#include "cgit.h" 9#include "cgit.h"
10 10
11char *cgit_root = "/usr/src/git"; 11struct repolist cgit_repolist;
12struct repoinfo *cgit_repo;
13
12char *cgit_root_title = "Git repository browser"; 14char *cgit_root_title = "Git repository browser";
13char *cgit_css = "/cgit.css"; 15char *cgit_css = "/cgit.css";
14char *cgit_logo = "/git-logo.png"; 16char *cgit_logo = "/git-logo.png";
15char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; 17char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/";
16char *cgit_virtual_root = NULL; 18char *cgit_virtual_root = NULL;
17 19
18char *cgit_cache_root = "/var/cache/cgit"; 20char *cgit_cache_root = "/var/cache/cgit";
19 21
20int cgit_nocache = 0; 22int cgit_nocache = 0;
21int cgit_max_lock_attempts = 5; 23int cgit_max_lock_attempts = 5;
22int cgit_cache_root_ttl = 5; 24int cgit_cache_root_ttl = 5;
23int cgit_cache_repo_ttl = 5; 25int cgit_cache_repo_ttl = 5;
@@ -37,52 +39,83 @@ int cgit_query_has_sha1 = 0;
37char *cgit_querystring = NULL; 39char *cgit_querystring = NULL;
38char *cgit_query_repo = NULL; 40char *cgit_query_repo = NULL;
39char *cgit_query_page = NULL; 41char *cgit_query_page = NULL;
40char *cgit_query_head = NULL; 42char *cgit_query_head = NULL;
41char *cgit_query_search = NULL; 43char *cgit_query_search = NULL;
42char *cgit_query_sha1 = NULL; 44char *cgit_query_sha1 = NULL;
43char *cgit_query_sha2 = NULL; 45char *cgit_query_sha2 = NULL;
44char *cgit_query_path = NULL; 46char *cgit_query_path = NULL;
45int cgit_query_ofs = 0; 47int cgit_query_ofs = 0;
46 48
47int htmlfd = 0; 49int htmlfd = 0;
48 50
51struct repoinfo *add_repo(const char *url)
52{
53 struct repoinfo *ret;
54
55 if (++cgit_repolist.count > cgit_repolist.length) {
56 if (cgit_repolist.length == 0)
57 cgit_repolist.length = 8;
58 else
59 cgit_repolist.length *= 2;
60 cgit_repolist.repos = xrealloc(cgit_repolist.repos,
61 cgit_repolist.length *
62 sizeof(struct repoinfo));
63 }
64
65 ret = &cgit_repolist.repos[cgit_repolist.count-1];
66 ret->url = xstrdup(url);
67 ret->name = ret->url;
68 ret->path = NULL;
69 ret->desc = NULL;
70 ret->owner = NULL;
71 return ret;
72}
73
49void cgit_global_config_cb(const char *name, const char *value) 74void cgit_global_config_cb(const char *name, const char *value)
50{ 75{
51 if (!strcmp(name, "root")) 76 if (!strcmp(name, "root-title"))
52 cgit_root = xstrdup(value);
53 else if (!strcmp(name, "root-title"))
54 cgit_root_title = xstrdup(value); 77 cgit_root_title = xstrdup(value);
55 else if (!strcmp(name, "css")) 78 else if (!strcmp(name, "css"))
56 cgit_css = xstrdup(value); 79 cgit_css = xstrdup(value);
57 else if (!strcmp(name, "logo")) 80 else if (!strcmp(name, "logo"))
58 cgit_logo = xstrdup(value); 81 cgit_logo = xstrdup(value);
59 else if (!strcmp(name, "logo-link")) 82 else if (!strcmp(name, "logo-link"))
60 cgit_logo_link = xstrdup(value); 83 cgit_logo_link = xstrdup(value);
61 else if (!strcmp(name, "virtual-root")) 84 else if (!strcmp(name, "virtual-root"))
62 cgit_virtual_root = xstrdup(value); 85 cgit_virtual_root = xstrdup(value);
63 else if (!strcmp(name, "nocache")) 86 else if (!strcmp(name, "nocache"))
64 cgit_nocache = atoi(value); 87 cgit_nocache = atoi(value);
65 else if (!strcmp(name, "cache-root")) 88 else if (!strcmp(name, "cache-root"))
66 cgit_cache_root = xstrdup(value); 89 cgit_cache_root = xstrdup(value);
67 else if (!strcmp(name, "cache-root-ttl")) 90 else if (!strcmp(name, "cache-root-ttl"))
68 cgit_cache_root_ttl = atoi(value); 91 cgit_cache_root_ttl = atoi(value);
69 else if (!strcmp(name, "cache-repo-ttl")) 92 else if (!strcmp(name, "cache-repo-ttl"))
70 cgit_cache_repo_ttl = atoi(value); 93 cgit_cache_repo_ttl = atoi(value);
71 else if (!strcmp(name, "cache-static-ttl")) 94 else if (!strcmp(name, "cache-static-ttl"))
72 cgit_cache_static_ttl = atoi(value); 95 cgit_cache_static_ttl = atoi(value);
73 else if (!strcmp(name, "cache-dynamic-ttl")) 96 else if (!strcmp(name, "cache-dynamic-ttl"))
74 cgit_cache_dynamic_ttl = atoi(value); 97 cgit_cache_dynamic_ttl = atoi(value);
75 else if (!strcmp(name, "max-message-length")) 98 else if (!strcmp(name, "max-message-length"))
76 cgit_max_msg_len = atoi(value); 99 cgit_max_msg_len = atoi(value);
100 else if (!strcmp(name, "repo.url"))
101 cgit_repo = add_repo(value);
102 else if (!strcmp(name, "repo.name"))
103 cgit_repo->name = xstrdup(value);
104 else if (cgit_repo && !strcmp(name, "repo.path"))
105 cgit_repo->path = xstrdup(value);
106 else if (cgit_repo && !strcmp(name, "repo.desc"))
107 cgit_repo->desc = xstrdup(value);
108 else if (cgit_repo && !strcmp(name, "repo.owner"))
109 cgit_repo->owner = xstrdup(value);
77} 110}
78 111
79void cgit_repo_config_cb(const char *name, const char *value) 112void cgit_repo_config_cb(const char *name, const char *value)
80{ 113{
81 if (!strcmp(name, "name")) 114 if (!strcmp(name, "name"))
82 cgit_repo_name = xstrdup(value); 115 cgit_repo_name = xstrdup(value);
83 else if (!strcmp(name, "desc")) 116 else if (!strcmp(name, "desc"))
84 cgit_repo_desc = xstrdup(value); 117 cgit_repo_desc = xstrdup(value);
85 else if (!strcmp(name, "owner")) 118 else if (!strcmp(name, "owner"))
86 cgit_repo_owner = xstrdup(value); 119 cgit_repo_owner = xstrdup(value);
87} 120}
88 121