author | Lars Hjemli <hjemli@gmail.com> | 2009-08-09 11:46:01 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2009-08-09 11:46:01 (UTC) |
commit | db6303b58883c4417f5bcc0c1ee34fed6553dca3 (patch) (unidiff) | |
tree | ef7775ade9eef57c5a878f9588fe545a7da2c952 /cgit.c | |
parent | 17e3ff42646f182911fd0e5d872082977538db9e (diff) | |
parent | 97b3d252629a8a3b9d356c2532dec7611438e4b9 (diff) | |
download | cgit-db6303b58883c4417f5bcc0c1ee34fed6553dca3.zip cgit-db6303b58883c4417f5bcc0c1ee34fed6553dca3.tar.gz cgit-db6303b58883c4417f5bcc0c1ee34fed6553dca3.tar.bz2 |
Merge branch 'lh/plugins'
Conflicts:
cgit.c
cgit.h
-rw-r--r-- | cgit.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -16,24 +16,39 @@ | |||
16 | #include "scan-tree.h" | 16 | #include "scan-tree.h" |
17 | 17 | ||
18 | const char *cgit_version = CGIT_VERSION; | 18 | const char *cgit_version = CGIT_VERSION; |
19 | 19 | ||
20 | void add_mimetype(const char *name, const char *value) | 20 | void add_mimetype(const char *name, const char *value) |
21 | { | 21 | { |
22 | struct string_list_item *item; | 22 | struct string_list_item *item; |
23 | 23 | ||
24 | item = string_list_insert(xstrdup(name), &ctx.cfg.mimetypes); | 24 | item = string_list_insert(xstrdup(name), &ctx.cfg.mimetypes); |
25 | item->util = xstrdup(value); | 25 | item->util = xstrdup(value); |
26 | } | 26 | } |
27 | 27 | ||
28 | struct cgit_filter *new_filter(const char *cmd, int extra_args) | ||
29 | { | ||
30 | struct cgit_filter *f; | ||
31 | |||
32 | if (!cmd || !cmd[0]) | ||
33 | return NULL; | ||
34 | |||
35 | f = xmalloc(sizeof(struct cgit_filter)); | ||
36 | f->cmd = xstrdup(cmd); | ||
37 | f->argv = xmalloc((2 + extra_args) * sizeof(char *)); | ||
38 | f->argv[0] = f->cmd; | ||
39 | f->argv[1] = NULL; | ||
40 | return f; | ||
41 | } | ||
42 | |||
28 | void config_cb(const char *name, const char *value) | 43 | void config_cb(const char *name, const char *value) |
29 | { | 44 | { |
30 | if (!strcmp(name, "root-title")) | 45 | if (!strcmp(name, "root-title")) |
31 | ctx.cfg.root_title = xstrdup(value); | 46 | ctx.cfg.root_title = xstrdup(value); |
32 | else if (!strcmp(name, "root-desc")) | 47 | else if (!strcmp(name, "root-desc")) |
33 | ctx.cfg.root_desc = xstrdup(value); | 48 | ctx.cfg.root_desc = xstrdup(value); |
34 | else if (!strcmp(name, "root-readme")) | 49 | else if (!strcmp(name, "root-readme")) |
35 | ctx.cfg.root_readme = xstrdup(value); | 50 | ctx.cfg.root_readme = xstrdup(value); |
36 | else if (!strcmp(name, "css")) | 51 | else if (!strcmp(name, "css")) |
37 | ctx.cfg.css = xstrdup(value); | 52 | ctx.cfg.css = xstrdup(value); |
38 | else if (!strcmp(name, "favicon")) | 53 | else if (!strcmp(name, "favicon")) |
39 | ctx.cfg.favicon = xstrdup(value); | 54 | ctx.cfg.favicon = xstrdup(value); |
@@ -76,34 +91,38 @@ void config_cb(const char *name, const char *value) | |||
76 | else if (!strcmp(name, "cache-size")) | 91 | else if (!strcmp(name, "cache-size")) |
77 | ctx.cfg.cache_size = atoi(value); | 92 | ctx.cfg.cache_size = atoi(value); |
78 | else if (!strcmp(name, "cache-root")) | 93 | else if (!strcmp(name, "cache-root")) |
79 | ctx.cfg.cache_root = xstrdup(value); | 94 | ctx.cfg.cache_root = xstrdup(value); |
80 | else if (!strcmp(name, "cache-root-ttl")) | 95 | else if (!strcmp(name, "cache-root-ttl")) |
81 | ctx.cfg.cache_root_ttl = atoi(value); | 96 | ctx.cfg.cache_root_ttl = atoi(value); |
82 | else if (!strcmp(name, "cache-repo-ttl")) | 97 | else if (!strcmp(name, "cache-repo-ttl")) |
83 | ctx.cfg.cache_repo_ttl = atoi(value); | 98 | ctx.cfg.cache_repo_ttl = atoi(value); |
84 | else if (!strcmp(name, "cache-static-ttl")) | 99 | else if (!strcmp(name, "cache-static-ttl")) |
85 | ctx.cfg.cache_static_ttl = atoi(value); | 100 | ctx.cfg.cache_static_ttl = atoi(value); |
86 | else if (!strcmp(name, "cache-dynamic-ttl")) | 101 | else if (!strcmp(name, "cache-dynamic-ttl")) |
87 | ctx.cfg.cache_dynamic_ttl = atoi(value); | 102 | ctx.cfg.cache_dynamic_ttl = atoi(value); |
103 | else if (!strcmp(name, "commit-filter")) | ||
104 | ctx.cfg.commit_filter = new_filter(value, 0); | ||
88 | else if (!strcmp(name, "embedded")) | 105 | else if (!strcmp(name, "embedded")) |
89 | ctx.cfg.embedded = atoi(value); | 106 | ctx.cfg.embedded = atoi(value); |
90 | else if (!strcmp(name, "max-message-length")) | 107 | else if (!strcmp(name, "max-message-length")) |
91 | ctx.cfg.max_msg_len = atoi(value); | 108 | ctx.cfg.max_msg_len = atoi(value); |
92 | else if (!strcmp(name, "max-repodesc-length")) | 109 | else if (!strcmp(name, "max-repodesc-length")) |
93 | ctx.cfg.max_repodesc_len = atoi(value); | 110 | ctx.cfg.max_repodesc_len = atoi(value); |
94 | else if (!strcmp(name, "max-repo-count")) | 111 | else if (!strcmp(name, "max-repo-count")) |
95 | ctx.cfg.max_repo_count = atoi(value); | 112 | ctx.cfg.max_repo_count = atoi(value); |
96 | else if (!strcmp(name, "max-commit-count")) | 113 | else if (!strcmp(name, "max-commit-count")) |
97 | ctx.cfg.max_commit_count = atoi(value); | 114 | ctx.cfg.max_commit_count = atoi(value); |
115 | else if (!strcmp(name, "source-filter")) | ||
116 | ctx.cfg.source_filter = new_filter(value, 1); | ||
98 | else if (!strcmp(name, "summary-log")) | 117 | else if (!strcmp(name, "summary-log")) |
99 | ctx.cfg.summary_log = atoi(value); | 118 | ctx.cfg.summary_log = atoi(value); |
100 | else if (!strcmp(name, "summary-branches")) | 119 | else if (!strcmp(name, "summary-branches")) |
101 | ctx.cfg.summary_branches = atoi(value); | 120 | ctx.cfg.summary_branches = atoi(value); |
102 | else if (!strcmp(name, "summary-tags")) | 121 | else if (!strcmp(name, "summary-tags")) |
103 | ctx.cfg.summary_tags = atoi(value); | 122 | ctx.cfg.summary_tags = atoi(value); |
104 | else if (!strcmp(name, "agefile")) | 123 | else if (!strcmp(name, "agefile")) |
105 | ctx.cfg.agefile = xstrdup(value); | 124 | ctx.cfg.agefile = xstrdup(value); |
106 | else if (!strcmp(name, "renamelimit")) | 125 | else if (!strcmp(name, "renamelimit")) |
107 | ctx.cfg.renamelimit = atoi(value); | 126 | ctx.cfg.renamelimit = atoi(value); |
108 | else if (!strcmp(name, "robots")) | 127 | else if (!strcmp(name, "robots")) |
109 | ctx.cfg.robots = xstrdup(value); | 128 | ctx.cfg.robots = xstrdup(value); |
@@ -130,24 +149,28 @@ void config_cb(const char *name, const char *value) | |||
130 | else if (ctx.repo && !strcmp(name, "repo.defbranch")) | 149 | else if (ctx.repo && !strcmp(name, "repo.defbranch")) |
131 | ctx.repo->defbranch = xstrdup(value); | 150 | ctx.repo->defbranch = xstrdup(value); |
132 | else if (ctx.repo && !strcmp(name, "repo.snapshots")) | 151 | else if (ctx.repo && !strcmp(name, "repo.snapshots")) |
133 | ctx.repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ | 152 | ctx.repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ |
134 | else if (ctx.repo && !strcmp(name, "repo.enable-log-filecount")) | 153 | else if (ctx.repo && !strcmp(name, "repo.enable-log-filecount")) |
135 | ctx.repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); | 154 | ctx.repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); |
136 | else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount")) | 155 | else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount")) |
137 | ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); | 156 | ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); |
138 | else if (ctx.repo && !strcmp(name, "repo.max-stats")) | 157 | else if (ctx.repo && !strcmp(name, "repo.max-stats")) |
139 | ctx.repo->max_stats = cgit_find_stats_period(value, NULL); | 158 | ctx.repo->max_stats = cgit_find_stats_period(value, NULL); |
140 | else if (ctx.repo && !strcmp(name, "repo.module-link")) | 159 | else if (ctx.repo && !strcmp(name, "repo.module-link")) |
141 | ctx.repo->module_link= xstrdup(value); | 160 | ctx.repo->module_link= xstrdup(value); |
161 | else if (ctx.repo && !strcmp(name, "repo.commit-filter")) | ||
162 | ctx.repo->commit_filter = new_filter(value, 0); | ||
163 | else if (ctx.repo && !strcmp(name, "repo.source-filter")) | ||
164 | ctx.repo->source_filter = new_filter(value, 1); | ||
142 | else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) { | 165 | else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) { |
143 | if (*value == '/') | 166 | if (*value == '/') |
144 | ctx.repo->readme = xstrdup(value); | 167 | ctx.repo->readme = xstrdup(value); |
145 | else | 168 | else |
146 | ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value)); | 169 | ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value)); |
147 | } else if (!strcmp(name, "include")) | 170 | } else if (!strcmp(name, "include")) |
148 | parse_configfile(value, config_cb); | 171 | parse_configfile(value, config_cb); |
149 | } | 172 | } |
150 | 173 | ||
151 | static void querystring_cb(const char *name, const char *value) | 174 | static void querystring_cb(const char *name, const char *value) |
152 | { | 175 | { |
153 | if (!strcmp(name,"r")) { | 176 | if (!strcmp(name,"r")) { |