[PATCH 1/4] filter: add generic scafolding for temporarily disabling filter

Jason A. Donenfeld Jason at zx2c4.com
Sat Oct 14 16:17:47 CEST 2017


Signed-off-by: Jason A. Donenfeld <Jason at zx2c4.com>
---
 cgit.h   | 2 ++
 filter.c | 9 +++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/cgit.h b/cgit.h
index 005ae63..8da69e7 100644
--- a/cgit.h
+++ b/cgit.h
@@ -61,6 +61,7 @@ typedef enum {
 struct cgit_filter {
 	int (*open)(struct cgit_filter *, va_list ap);
 	int (*close)(struct cgit_filter *);
+	int (*enable)(struct cgit_filter *, bool on);
 	void (*fprintf)(struct cgit_filter *, FILE *, const char *prefix);
 	void (*cleanup)(struct cgit_filter *);
 	int argument_count;
@@ -376,6 +377,7 @@ extern int cgit_parse_snapshots_mask(const char *str);
 
 extern int cgit_open_filter(struct cgit_filter *filter, ...);
 extern int cgit_close_filter(struct cgit_filter *filter);
+extern int cgit_enable_filter(struct cgit_filter *filter, bool on);
 extern void cgit_fprintf_filter(struct cgit_filter *filter, FILE *f, const char *prefix);
 extern void cgit_exec_filter_init(struct cgit_exec_filter *filter, char *cmd, char **argv);
 extern struct cgit_filter *cgit_new_filter(const char *cmd, filter_type filtertype);
diff --git a/filter.c b/filter.c
index 70f5b74..aa0027a 100644
--- a/filter.c
+++ b/filter.c
@@ -383,13 +383,18 @@ int cgit_close_filter(struct cgit_filter *filter)
 	return filter->close(filter);
 }
 
+int cgit_enable_filter(struct cgit_filter *filter, bool on)
+{
+	if (!filter)
+		return 0;
+	return filter->enable(filter, on);
+}
+
 void cgit_fprintf_filter(struct cgit_filter *filter, FILE *f, const char *prefix)
 {
 	filter->fprintf(filter, f, prefix);
 }
 
-
-
 static const struct {
 	const char *prefix;
 	struct cgit_filter *(*ctor)(const char *cmd, int argument_count);
-- 
2.14.2



More information about the CGit mailing list