From 79a88784e0819c1bbe9de8d39a0e05997c8211f6 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Thu, 15 Mar 2018 01:18:12 +0100 Subject: [PATCH] filter: Use lsu_merge_config_file_options(). Straight forward conversion. We now set the loglevel only once, after the config file options have been merged. --- configure.ac | 1 + filter.c | 47 ++++++----------------------------------------- 2 files changed, 7 insertions(+), 41 deletions(-) diff --git a/configure.ac b/configure.ac index 3fa68535..94b3abb4 100644 --- a/configure.ac +++ b/configure.ac @@ -596,6 +596,7 @@ filter_errlist_objs=" amp_filter fecdec_filter fec + lsu version prebuffer_filter time diff --git a/filter.c b/filter.c index dfdadab2..d4a24239 100644 --- a/filter.c +++ b/filter.c @@ -9,6 +9,7 @@ #include "filter_cmd.lsg.h" #include "para.h" #include "list.h" +#include "lsu.h" #include "sched.h" #include "buffer_tree.h" #include "filter.h" @@ -71,50 +72,15 @@ static void handle_help_flag(void) static int parse_config(void) { - char *home, *cf; /* config file */ - struct stat statbuf; int ret; version_handle_flag("filter", OPT_GIVEN(VERSION)); handle_help_flag(); - home = para_homedir(); - cf = make_message("%s/.paraslash/filter.conf", home); - free(home); - if (!stat(cf, &statbuf)) { - void *map; - size_t sz; - int cf_argc; - char **cf_argv, *errctx; - struct lls_parse_result *cf_lpr, *merged_lpr; - - ret = mmap_full_file(cf, O_RDONLY, &map, &sz, NULL); - if (ret != -E_EMPTY) { - if (ret < 0) - return ret; - ret = lls(lls_convert_config(map, sz, NULL, &cf_argv, - &errctx)); - para_munmap(map, sz); - if (ret < 0) { - PARA_ERROR_LOG("syntax error in %s\n", cf); - return ret; - } - cf_argc = ret; - ret = lls(lls_parse(cf_argc, cf_argv, CMD_PTR, &cf_lpr, - &errctx)); - lls_free_argv(cf_argv); - if (ret < 0) { - PARA_ERROR_LOG("parse error in %s\n", cf); - return ret; - } - ret = lls(lls_merge(lpr, cf_lpr, CMD_PTR, &merged_lpr, &errctx)); - lls_free_parse_result(cf_lpr, CMD_PTR); - if (ret < 0) - return ret; - lls_free_parse_result(lpr, CMD_PTR); - lpr = merged_lpr; - loglevel = OPT_UINT32_VAL(LOGLEVEL); - } - } + ret = lsu_merge_config_file_options(NULL, "filter.conf", + &lpr, CMD_PTR, filter_suite, 0 /* default flags */); + if (ret < 0) + return ret; + loglevel = OPT_UINT32_VAL(LOGLEVEL); if (!OPT_GIVEN(FILTER)) { print_filter_list(); exit(EXIT_SUCCESS); @@ -147,7 +113,6 @@ int main(int argc, char *argv[]) ret = lls(lls_parse(argc, argv, CMD_PTR, &lpr, &errctx)); if (ret < 0) goto out; - loglevel = OPT_UINT32_VAL(LOGLEVEL); ret = parse_config(); if (ret < 0) goto free_lpr; -- 2.39.5