From 632efb25c07c1b014a4e8cfbbea759f517c2aaf6 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Sun, 12 Jan 2014 17:13:51 +0000 Subject: filter: add fprintf_filter function This stops the code in cgit.c::print_repo needing to inspect the cgit_filter structure, meaning that we can abstract out different filter types that will have different fields that need to be printed. Signed-off-by: John Keeping --- cgit.c | 6 +++--- cgit.h | 1 + filter.c | 5 +++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cgit.c b/cgit.c index 0be41b8..29b658e 100644 --- a/cgit.c +++ b/cgit.c @@ -706,11 +706,11 @@ static void print_repo(FILE *f, struct cgit_repo *repo) fprintf(f, "repo.enable-log-linecount=%d\n", repo->enable_log_linecount); if (repo->about_filter && repo->about_filter != ctx.cfg.about_filter) - fprintf(f, "repo.about-filter=%s\n", repo->about_filter->cmd); + cgit_fprintf_filter(repo->about_filter, f, "repo.about-filter="); if (repo->commit_filter && repo->commit_filter != ctx.cfg.commit_filter) - fprintf(f, "repo.commit-filter=%s\n", repo->commit_filter->cmd); + cgit_fprintf_filter(repo->commit_filter, f, "repo.commit-filter="); if (repo->source_filter && repo->source_filter != ctx.cfg.source_filter) - fprintf(f, "repo.source-filter=%s\n", repo->source_filter->cmd); + cgit_fprintf_filter(repo->source_filter, f, "repo.source-filter="); if (repo->snapshots != ctx.cfg.snapshots) { char *tmp = build_snapshot_setting(repo->snapshots); fprintf(f, "repo.snapshots=%s\n", tmp ? tmp : ""); diff --git a/cgit.h b/cgit.h index e6e7715..9b4be26 100644 --- a/cgit.h +++ b/cgit.h @@ -345,6 +345,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 void cgit_fprintf_filter(struct cgit_filter *filter, FILE *f, const char *prefix); extern struct cgit_filter *cgit_new_filter(const char *cmd, filter_type filtertype); extern void cgit_prepare_repo_env(struct cgit_repo * repo); diff --git a/filter.c b/filter.c index d8c0116..80cf689 100644 --- a/filter.c +++ b/filter.c @@ -63,6 +63,11 @@ done: } +void cgit_fprintf_filter(struct cgit_filter *filter, FILE *f, const char *prefix) +{ + fprintf(f, "%s%s\n", prefix, filter->cmd); +} + struct cgit_filter *cgit_new_filter(const char *cmd, filter_type filtertype) { struct cgit_filter *f; -- cgit 1.4.1 68ec043199098326d5bb327f10617&showmsg=1&follow=1'>Expand)Author 2019-11-10Separate tags from all targetJune McEnroe 2019-11-10Filter invite-notifyJune McEnroe 2019-11-10Add capsicum note to READMEJune McEnroe 2019-11-10Filter extended-joinJune McEnroe 2019-11-10Expand client configuration documentation and list capabilitiesJune McEnroe 2019-11-10Request all supported caps from serverJune McEnroe 2019-11-10Filter ACCOUNT, AWAY, CHGHOST for incapable clientsJune McEnroe 2019-11-10Rename listen to localJune McEnroe 2019-11-09Remove extended-join and invite-notifyJune McEnroe 2019-11-09Maintain stateCaps and offer them to clientsJune McEnroe 2019-11-09Parse capabilitiesJune McEnroe 2019-11-09Avoid the reserved _A names with BIT macroJune McEnroe 2019-11-09Define macro for bit flag enumsJune McEnroe 2019-11-08Check that password is hashedJune McEnroe 2019-11-08Avoid calling getopt_long again after it returns -1June McEnroe 2019-11-08Only change AWAY status for registered clientsJune McEnroe 2019-11-07Just write the example normallyJune McEnroe 2019-11-07Include path in readlinkat errorJune McEnroe 2019-11-07Call clientConsume before clientRecvJune McEnroe 2019-11-06Use -l:filename in Linux.mkJune McEnroe 2019-11-06Fix compat.h for #defined strlcpyJune McEnroe 2019-11-06Allow unsetting LIBRESSL_PREFIXJune McEnroe 2019-11-06Document calico service configurationJune McEnroe 2019-11-06Document SASL EXTERNAL configuration in more detailJune McEnroe 2019-11-06Document pounce service configurationJune McEnroe 2019-11-06Mention Darwin and GNU/Linux in READMEJune McEnroe 2019-11-06Assume LibreSSL from brew on DarwinJune McEnroe 2019-11-06Remove -DNO_EXPLICIT_BZERO from Darwin.mkJune McEnroe 2019-11-06Don't install rc scripts or dirs on LinuxJune McEnroe