aboutsummaryrefslogtreecommitdiffstats
path: root/shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'shared.c')
-rw-r--r--shared.c61
1 files changed, 30 insertions, 31 deletions
diff --git a/shared.c b/shared.c
index 8dd2b00..808e674 100644
--- a/shared.c
+++ b/shared.c
@@ -8,8 +8,7 @@
8 8
9#include "cgit.h" 9#include "cgit.h"
10 10
11struct repolist cgit_repolist; 11struct cgit_repolist cgit_repolist;
12struct repoinfo *cgit_repo;
13struct cgit_context ctx; 12struct cgit_context ctx;
14int cgit_cmd; 13int cgit_cmd;
15 14
@@ -73,9 +72,9 @@ int chk_non_negative(int result, char *msg)
73 return result; 72 return result;
74} 73}
75 74
76struct repoinfo *add_repo(const char *url) 75struct cgit_repo *add_repo(const char *url)
77{ 76{
78 struct repoinfo *ret; 77 struct cgit_repo *ret;
79 78
80 if (++cgit_repolist.count > cgit_repolist.length) { 79 if (++cgit_repolist.count > cgit_repolist.length) {
81 if (cgit_repolist.length == 0) 80 if (cgit_repolist.length == 0)
@@ -84,7 +83,7 @@ struct repoinfo *add_repo(const char *url)
84 cgit_repolist.length *= 2; 83 cgit_repolist.length *= 2;
85 cgit_repolist.repos = xrealloc(cgit_repolist.repos, 84 cgit_repolist.repos = xrealloc(cgit_repolist.repos,
86 cgit_repolist.length * 85 cgit_repolist.length *
87 sizeof(struct repoinfo)); 86 sizeof(struct cgit_repo));
88 } 87 }
89 88
90 ret = &cgit_repolist.repos[cgit_repolist.count-1]; 89 ret = &cgit_repolist.repos[cgit_repolist.count-1];
@@ -103,10 +102,10 @@ struct repoinfo *add_repo(const char *url)
103 return ret; 102 return ret;
104} 103}
105 104
106struct repoinfo *cgit_get_repoinfo(const char *url) 105struct cgit_repo *cgit_get_repoinfo(const char *url)
107{ 106{
108 int i; 107 int i;
109 struct repoinfo *repo; 108 struct cgit_repo *repo;
110 109
111 for (i=0; i<cgit_repolist.count; i++) { 110 for (i=0; i<cgit_repolist.count; i++) {
112 repo = &cgit_repolist.repos[i]; 111 repo = &cgit_repolist.repos[i];
@@ -179,32 +178,32 @@ void cgit_global_config_cb(const char *name, const char *value)
179 else if (!strcmp(name, "repo.group")) 178 else if (!strcmp(name, "repo.group"))
180 ctx.cfg.repo_group = xstrdup(value); 179 ctx.cfg.repo_group = xstrdup(value);
181 else if (!strcmp(name, "repo.url")) 180 else if (!strcmp(name, "repo.url"))
182 cgit_repo = add_repo(value); 181 ctx.repo = add_repo(value);
183 else if (!strcmp(name, "repo.name")) 182 else if (!strcmp(name, "repo.name"))
184 cgit_repo->name = xstrdup(value); 183 ctx.repo->name = xstrdup(value);
185 else if (cgit_repo && !strcmp(name, "repo.path")) 184 else if (ctx.repo && !strcmp(name, "repo.path"))
186 cgit_repo->path = trim_end(value, '/'); 185 ctx.repo->path = trim_end(value, '/');
187 else if (cgit_repo && !strcmp(name, "repo.clone-url")) 186 else if (ctx.repo && !strcmp(name, "repo.clone-url"))
188 cgit_repo->clone_url = xstrdup(value); 187 ctx.repo->clone_url = xstrdup(value);
189 else if (cgit_repo && !strcmp(name, "repo.desc")) 188 else if (ctx.repo && !strcmp(name, "repo.desc"))
190 cgit_repo->desc = xstrdup(value); 189 ctx.repo->desc = xstrdup(value);
191 else if (cgit_repo && !strcmp(name, "repo.owner")) 190 else if (ctx.repo && !strcmp(name, "repo.owner"))
192 cgit_repo->owner = xstrdup(value); 191 ctx.repo->owner = xstrdup(value);
193 else if (cgit_repo && !strcmp(name, "repo.defbranch")) 192 else if (ctx.repo && !strcmp(name, "repo.defbranch"))
194 cgit_repo->defbranch = xstrdup(value); 193 ctx.repo->defbranch = xstrdup(value);
195 else if (cgit_repo && !strcmp(name, "repo.snapshots")) 194 else if (ctx.repo && !strcmp(name, "repo.snapshots"))
196 cgit_repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ 195 ctx.repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */
197 else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) 196 else if (ctx.repo && !strcmp(name, "repo.enable-log-filecount"))
198 cgit_repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); 197 ctx.repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value);
199 else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) 198 else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount"))
200 cgit_repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); 199 ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value);
201 else if (cgit_repo && !strcmp(name, "repo.module-link")) 200 else if (ctx.repo && !strcmp(name, "repo.module-link"))
202 cgit_repo->module_link= xstrdup(value); 201 ctx.repo->module_link= xstrdup(value);
203 else if (cgit_repo && !strcmp(name, "repo.readme") && value != NULL) { 202 else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) {
204 if (*value == '/') 203 if (*value == '/')
205 cgit_repo->readme = xstrdup(value); 204 ctx.repo->readme = xstrdup(value);
206 else 205 else
207 cgit_repo->readme = xstrdup(fmt("%s/%s", cgit_repo->path, value)); 206 ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value));
208 } else if (!strcmp(name, "include")) 207 } else if (!strcmp(name, "include"))
209 cgit_read_config(value, cgit_global_config_cb); 208 cgit_read_config(value, cgit_global_config_cb);
210} 209}
@@ -213,7 +212,7 @@ void cgit_querystring_cb(const char *name, const char *value)
213{ 212{
214 if (!strcmp(name,"r")) { 213 if (!strcmp(name,"r")) {
215 ctx.qry.repo = xstrdup(value); 214 ctx.qry.repo = xstrdup(value);
216 cgit_repo = cgit_get_repoinfo(value); 215 ctx.repo = cgit_get_repoinfo(value);
217 } else if (!strcmp(name, "p")) { 216 } else if (!strcmp(name, "p")) {
218 ctx.qry.page = xstrdup(value); 217 ctx.qry.page = xstrdup(value);
219 cgit_cmd = cgit_get_cmd_index(value); 218 cgit_cmd = cgit_get_cmd_index(value);