diff options
author | John Keeping | 2014-01-12 17:13:52 +0000 |
---|---|---|
committer | Jason A. Donenfeld | 2014-01-14 02:00:07 +0100 |
commit | 7bd90b8048fd6937766dff7474947dd80205ea7e (patch) | |
tree | 63f9ba4eac9892a843338400042194b3bf115216 /cgit.h | |
parent | 632efb25c07c1b014a4e8cfbbea759f517c2aaf6 (diff) | |
download | cgit-7bd90b8048fd6937766dff7474947dd80205ea7e.tar.gz cgit-7bd90b8048fd6937766dff7474947dd80205ea7e.tar.bz2 cgit-7bd90b8048fd6937766dff7474947dd80205ea7e.zip |
filter: add interface layer
Change the existing cgit_{open,close,fprintf}_filter functions to
delegate to filter-specific implementations accessed via function
pointers on the cgit_filter object.
We treat the "exec" filter type slightly specially here by putting its
structure definition in the header file and providing an "init" function
to set up the function pointers. This is required so that the
ui-snapshot.c code that applies a compression filter can continue to use
the filter interface to do so.
Signed-off-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to 'cgit.h')
-rw-r--r-- | cgit.h | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -57,6 +57,13 @@ typedef enum { | |||
57 | } filter_type; | 57 | } filter_type; |
58 | 58 | ||
59 | struct cgit_filter { | 59 | struct cgit_filter { |
60 | int (*open)(struct cgit_filter *, va_list ap); | ||
61 | int (*close)(struct cgit_filter *); | ||
62 | void (*fprintf)(struct cgit_filter *, FILE *, const char *prefix); | ||
63 | }; | ||
64 | |||
65 | struct cgit_exec_filter { | ||
66 | struct cgit_filter base; | ||
60 | char *cmd; | 67 | char *cmd; |
61 | char **argv; | 68 | char **argv; |
62 | int extra_args; | 69 | int extra_args; |
@@ -346,6 +353,7 @@ extern int cgit_parse_snapshots_mask(const char *str); | |||
346 | extern int cgit_open_filter(struct cgit_filter *filter, ...); | 353 | extern int cgit_open_filter(struct cgit_filter *filter, ...); |
347 | extern int cgit_close_filter(struct cgit_filter *filter); | 354 | extern int cgit_close_filter(struct cgit_filter *filter); |
348 | extern void cgit_fprintf_filter(struct cgit_filter *filter, FILE *f, const char *prefix); | 355 | extern void cgit_fprintf_filter(struct cgit_filter *filter, FILE *f, const char *prefix); |
356 | extern void cgit_exec_filter_init(struct cgit_exec_filter *filter, char *cmd, char **argv); | ||
349 | extern struct cgit_filter *cgit_new_filter(const char *cmd, filter_type filtertype); | 357 | extern struct cgit_filter *cgit_new_filter(const char *cmd, filter_type filtertype); |
350 | 358 | ||
351 | extern void cgit_prepare_repo_env(struct cgit_repo * repo); | 359 | extern void cgit_prepare_repo_env(struct cgit_repo * repo); |