aboutsummaryrefslogtreecommitdiffstats
path: root/cgit.c
diff options
context:
space:
mode:
authorJason A. Donenfeld2014-01-10 05:19:05 +0100
committerJason A. Donenfeld2014-01-10 17:45:43 +0100
commit3eae406934b98ce78eff3a92cb410475d71095a3 (patch)
tree8545d754ee0b4d970a3299479087847bc4c33b5e /cgit.c
parentb67ea0c0222d5b7eb4f65413047138e72055d8c5 (diff)
downloadcgit-3eae406934b98ce78eff3a92cb410475d71095a3.tar.gz
cgit-3eae406934b98ce78eff3a92cb410475d71095a3.tar.bz2
cgit-3eae406934b98ce78eff3a92cb410475d71095a3.zip
filter: split filter functions into their own file
A first step for more interesting things. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'cgit.c')
-rw-r--r--cgit.c42
1 files changed, 6 insertions, 36 deletions
diff --git a/cgit.c b/cgit.c
index d74b0f3..0be41b8 100644
--- a/cgit.c
+++ b/cgit.c
@@ -27,36 +27,6 @@ static void add_mimetype(const char *name, const char *value)
27 item->util = xstrdup(value); 27 item->util = xstrdup(value);
28} 28}
29 29
30static struct cgit_filter *new_filter(const char *cmd, filter_type filtertype)
31{
32 struct cgit_filter *f;
33 int args_size = 0;
34 int extra_args;
35
36 if (!cmd || !cmd[0])
37 return NULL;
38
39 switch (filtertype) {
40 case SOURCE:
41 case ABOUT:
42 extra_args = 1;
43 break;
44
45 case COMMIT:
46 default:
47 extra_args = 0;
48 break;
49 }
50
51 f = xmalloc(sizeof(struct cgit_filter));
52 f->cmd = xstrdup(cmd);
53 args_size = (2 + extra_args) * sizeof(char *);
54 f->argv = xmalloc(args_size);
55 memset(f->argv, 0, args_size);
56 f->argv[0] = f->cmd;
57 return f;
58}
59
60static void process_cached_repolist(const char *path); 30static void process_cached_repolist(const char *path);
61 31
62static void repo_config(struct cgit_repo *repo, const char *name, const char *value) 32static void repo_config(struct cgit_repo *repo, const char *name, const char *value)
@@ -114,11 +84,11 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va
114 repo->logo_link = xstrdup(value); 84 repo->logo_link = xstrdup(value);
115 else if (ctx.cfg.enable_filter_overrides) { 85 else if (ctx.cfg.enable_filter_overrides) {
116 if (!strcmp(name, "about-filter")) 86 if (!strcmp(name, "about-filter"))
117 repo->about_filter = new_filter(value, ABOUT); 87 repo->about_filter = cgit_new_filter(value, ABOUT);
118 else if (!strcmp(name, "commit-filter")) 88 else if (!strcmp(name, "commit-filter"))
119 repo->commit_filter = new_filter(value, COMMIT); 89 repo->commit_filter = cgit_new_filter(value, COMMIT);
120 else if (!strcmp(name, "source-filter")) 90 else if (!strcmp(name, "source-filter"))
121 repo->source_filter = new_filter(value, SOURCE); 91 repo->source_filter = cgit_new_filter(value, SOURCE);
122 } 92 }
123} 93}
124 94
@@ -215,9 +185,9 @@ static void config_cb(const char *name, const char *value)
215 else if (!strcmp(name, "case-sensitive-sort")) 185 else if (!strcmp(name, "case-sensitive-sort"))
216 ctx.cfg.case_sensitive_sort = atoi(value); 186 ctx.cfg.case_sensitive_sort = atoi(value);
217 else if (!strcmp(name, "about-filter")) 187 else if (!strcmp(name, "about-filter"))
218 ctx.cfg.about_filter = new_filter(value, ABOUT); 188 ctx.cfg.about_filter = cgit_new_filter(value, ABOUT);
219 else if (!strcmp(name, "commit-filter")) 189 else if (!strcmp(name, "commit-filter"))
220 ctx.cfg.commit_filter = new_filter(value, COMMIT); 190 ctx.cfg.commit_filter = cgit_new_filter(value, COMMIT);
221 else if (!strcmp(name, "embedded")) 191 else if (!strcmp(name, "embedded"))
222 ctx.cfg.embedded = atoi(value); 192 ctx.cfg.embedded = atoi(value);
223 else if (!strcmp(name, "max-atom-items")) 193 else if (!strcmp(name, "max-atom-items"))
@@ -251,7 +221,7 @@ static void config_cb(const char *name, const char *value)
251 else if (!strcmp(name, "section-sort")) 221 else if (!strcmp(name, "section-sort"))
252 ctx.cfg.section_sort = atoi(value); 222 ctx.cfg.section_sort = atoi(value);
253 else if (!strcmp(name, "source-filter")) 223 else if (!strcmp(name, "source-filter"))
254 ctx.cfg.source_filter = new_filter(value, SOURCE); 224 ctx.cfg.source_filter = cgit_new_filter(value, SOURCE);
255 else if (!strcmp(name, "summary-log")) 225 else if (!strcmp(name, "summary-log"))
256 ctx.cfg.summary_log = atoi(value); 226 ctx.cfg.summary_log = atoi(value);
257 else if (!strcmp(name, "summary-branches")) 227 else if (!strcmp(name, "summary-branches"))