[PATCH 3/4] filter: wire up lua_filter to enable function
Jason A. Donenfeld
Jason at zx2c4.com
Sat Oct 14 16:17:49 CEST 2017
Signed-off-by: Jason A. Donenfeld <Jason at zx2c4.com>
---
filter.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/filter.c b/filter.c
index 4deb4de..7b5bef5 100644
--- a/filter.c
+++ b/filter.c
@@ -353,6 +353,15 @@ static int close_lua_filter(struct cgit_filter *base)
return ret;
}
+static int enable_lua_filter(struct cgit_filter *base, bool on)
+{
+ if (on)
+ hook_write(base, write_lua_filter);
+ else
+ unhook_write();
+ return 0;
+}
+
static void fprintf_lua_filter(struct cgit_filter *base, FILE *f, const char *prefix)
{
struct lua_filter *filter = (struct lua_filter *)base;
@@ -368,6 +377,7 @@ static struct cgit_filter *new_lua_filter(const char *cmd, int argument_count)
memset(filter, 0, sizeof(*filter));
filter->base.open = open_lua_filter;
filter->base.close = close_lua_filter;
+ filter->base.enable = enable_lua_filter;
filter->base.fprintf = fprintf_lua_filter;
filter->base.cleanup = cleanup_lua_filter;
filter->base.argument_count = argument_count;
--
2.14.2
More information about the CGit
mailing list