aboutsummaryrefslogtreecommitdiffstats
path: root/shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'shared.c')
-rw-r--r--shared.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/shared.c b/shared.c
index 3778a5b..699c362 100644
--- a/shared.c
+++ b/shared.c
@@ -7,6 +7,8 @@
7 */ 7 */
8 8
9#include "cgit.h" 9#include "cgit.h"
10#include <stdio.h>
11#include <linux/limits.h>
10 12
11struct cgit_repolist cgit_repolist; 13struct cgit_repolist cgit_repolist;
12struct cgit_context ctx; 14struct cgit_context ctx;
@@ -68,6 +70,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
68 ret->about_filter = ctx.cfg.about_filter; 70 ret->about_filter = ctx.cfg.about_filter;
69 ret->commit_filter = ctx.cfg.commit_filter; 71 ret->commit_filter = ctx.cfg.commit_filter;
70 ret->source_filter = ctx.cfg.source_filter; 72 ret->source_filter = ctx.cfg.source_filter;
73 ret->clone_url = ctx.cfg.clone_url;
71 return ret; 74 return ret;
72} 75}
73 76
@@ -367,6 +370,33 @@ int cgit_parse_snapshots_mask(const char *str)
367 return rv; 370 return rv;
368} 371}
369 372
373typedef struct {
374 char * name;
375 char * value;
376} cgit_env_var;
377
378void cgit_prepare_repo_env(struct cgit_repo * repo)
379{
380 cgit_env_var env_vars[] = {
381 { .name = "CGIT_REPO_URL", .value = repo->url },
382 { .name = "CGIT_REPO_NAME", .value = repo->name },
383 { .name = "CGIT_REPO_PATH", .value = repo->path },
384 { .name = "CGIT_REPO_OWNER", .value = repo->owner },
385 { .name = "CGIT_REPO_DEFBRANCH", .value = repo->defbranch },
386 { .name = "CGIT_REPO_SECTION", .value = repo->section },
387 { .name = "CGIT_REPO_CLONE_URL", .value = repo->clone_url }
388 };
389 int env_var_count = ARRAY_SIZE(env_vars);
390 cgit_env_var *p, *q;
391 static char *warn = "cgit warning: failed to set env: %s=%s\n";
392
393 p = env_vars;
394 q = p + env_var_count;
395 for (; p < q; p++)
396 if (setenv(p->name, p->value, 1))
397 fprintf(stderr, warn, p->name, p->value);
398}
399
370int cgit_open_filter(struct cgit_filter *filter) 400int cgit_open_filter(struct cgit_filter *filter)
371{ 401{
372 402