diff options
| author | Lars Hjemli | 2011-05-23 23:28:38 +0200 |
|---|---|---|
| committer | Lars Hjemli | 2011-05-23 23:28:38 +0200 |
| commit | ab350a77b1d3b0e251cc28329f2e16f0566e521e (patch) | |
| tree | 1af2b0760858fcd87ce1e628465f9b60af7815e3 /cgit.c | |
| parent | 652a5a18db3b0409fedfaf8c5720446d87628ba0 (diff) | |
| parent | c2b58ed8539fcfa4f05cc9da316bbc782f4b8f10 (diff) | |
| download | cgit-ab350a77b1d3b0e251cc28329f2e16f0566e521e.tar.gz cgit-ab350a77b1d3b0e251cc28329f2e16f0566e521e.tar.bz2 cgit-ab350a77b1d3b0e251cc28329f2e16f0566e521e.zip | |
Merge branch 'fh/filter-api'
Conflicts:
cgit.c
Diffstat (limited to 'cgit.c')
| -rw-r--r-- | cgit.c | 27 |
1 files changed, 20 insertions, 7 deletions
| @@ -26,14 +26,27 @@ void add_mimetype(const char *name, const char *value) | |||
| 26 | item->util = xstrdup(value); | 26 | item->util = xstrdup(value); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | struct cgit_filter *new_filter(const char *cmd, int extra_args) | 29 | struct cgit_filter *new_filter(const char *cmd, filter_type filtertype) |
| 30 | { | 30 | { |
| 31 | struct cgit_filter *f; | 31 | struct cgit_filter *f; |
| 32 | int args_size = 0; | 32 | int args_size = 0; |
| 33 | int extra_args; | ||
| 33 | 34 | ||
| 34 | if (!cmd || !cmd[0]) | 35 | if (!cmd || !cmd[0]) |
| 35 | return NULL; | 36 | return NULL; |
| 36 | 37 | ||
| 38 | switch (filtertype) { | ||
| 39 | case SOURCE: | ||
| 40 | extra_args = 1; | ||
| 41 | break; | ||
| 42 | |||
| 43 | case ABOUT: | ||
| 44 | case COMMIT: | ||
| 45 | default: | ||
| 46 | extra_args = 0; | ||
| 47 | break; | ||
| 48 | } | ||
| 49 | |||
| 37 | f = xmalloc(sizeof(struct cgit_filter)); | 50 | f = xmalloc(sizeof(struct cgit_filter)); |
| 38 | f->cmd = xstrdup(cmd); | 51 | f->cmd = xstrdup(cmd); |
| 39 | args_size = (2 + extra_args) * sizeof(char *); | 52 | args_size = (2 + extra_args) * sizeof(char *); |
| @@ -83,11 +96,11 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value) | |||
| 83 | repo->logo_link = xstrdup(value); | 96 | repo->logo_link = xstrdup(value); |
| 84 | else if (ctx.cfg.enable_filter_overrides) { | 97 | else if (ctx.cfg.enable_filter_overrides) { |
| 85 | if (!strcmp(name, "about-filter")) | 98 | if (!strcmp(name, "about-filter")) |
| 86 | repo->about_filter = new_filter(value, 0); | 99 | repo->about_filter = new_filter(value, ABOUT); |
| 87 | else if (!strcmp(name, "commit-filter")) | 100 | else if (!strcmp(name, "commit-filter")) |
| 88 | repo->commit_filter = new_filter(value, 0); | 101 | repo->commit_filter = new_filter(value, COMMIT); |
| 89 | else if (!strcmp(name, "source-filter")) | 102 | else if (!strcmp(name, "source-filter")) |
| 90 | repo->source_filter = new_filter(value, 1); | 103 | repo->source_filter = new_filter(value, SOURCE); |
| 91 | } | 104 | } |
| 92 | } | 105 | } |
| 93 | 106 | ||
| @@ -180,9 +193,9 @@ void config_cb(const char *name, const char *value) | |||
| 180 | else if (!strcmp(name, "cache-dynamic-ttl")) | 193 | else if (!strcmp(name, "cache-dynamic-ttl")) |
| 181 | ctx.cfg.cache_dynamic_ttl = atoi(value); | 194 | ctx.cfg.cache_dynamic_ttl = atoi(value); |
| 182 | else if (!strcmp(name, "about-filter")) | 195 | else if (!strcmp(name, "about-filter")) |
| 183 | ctx.cfg.about_filter = new_filter(value, 0); | 196 | ctx.cfg.about_filter = new_filter(value, ABOUT); |
| 184 | else if (!strcmp(name, "commit-filter")) | 197 | else if (!strcmp(name, "commit-filter")) |
| 185 | ctx.cfg.commit_filter = new_filter(value, 0); | 198 | ctx.cfg.commit_filter = new_filter(value, COMMIT); |
| 186 | else if (!strcmp(name, "embedded")) | 199 | else if (!strcmp(name, "embedded")) |
| 187 | ctx.cfg.embedded = atoi(value); | 200 | ctx.cfg.embedded = atoi(value); |
| 188 | else if (!strcmp(name, "max-atom-items")) | 201 | else if (!strcmp(name, "max-atom-items")) |
| @@ -212,7 +225,7 @@ void config_cb(const char *name, const char *value) | |||
| 212 | else if (!strcmp(name, "section-from-path")) | 225 | else if (!strcmp(name, "section-from-path")) |
| 213 | ctx.cfg.section_from_path = atoi(value); | 226 | ctx.cfg.section_from_path = atoi(value); |
| 214 | else if (!strcmp(name, "source-filter")) | 227 | else if (!strcmp(name, "source-filter")) |
| 215 | ctx.cfg.source_filter = new_filter(value, 1); | 228 | ctx.cfg.source_filter = new_filter(value, SOURCE); |
| 216 | else if (!strcmp(name, "summary-log")) | 229 | else if (!strcmp(name, "summary-log")) |
| 217 | ctx.cfg.summary_log = atoi(value); | 230 | ctx.cfg.summary_log = atoi(value); |
| 218 | else if (!strcmp(name, "summary-branches")) | 231 | else if (!strcmp(name, "summary-branches")) |
