#include "filter_cmd.lsg.h"
#include "para.h"
#include "list.h"
+#include "lsu.h"
#include "sched.h"
#include "buffer_tree.h"
#include "filter.h"
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);
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;