X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=filter.c;h=07b78aed59e5d2a04c400003d2136cd2e956a1c4;hp=8ebceb44fd574f9a06c91d9a4c23d897827fc9a0;hb=9c00a79ed817c854ed10ee6bd1b908df8dc13a2f;hpb=72293235b8a21ea3cc4633005775e8ecf7d9308c diff --git a/filter.c b/filter.c index 8ebceb44..07b78aed 100644 --- a/filter.c +++ b/filter.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2009 Andre Noll + * Copyright (C) 2005-2013 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -7,7 +7,6 @@ /** \file filter.c The stand-alone filter program. */ #include -#include #include "para.h" #include "filter.cmdline.h" @@ -20,6 +19,7 @@ #include "stdin.h" #include "stdout.h" #include "error.h" +#include "version.h" /** The list of all status items used by para_{server,audiod,gui}. */ const char *status_item_list[] = {STATUS_ITEM_ARRAY}; @@ -87,6 +87,8 @@ static int parse_config(int argc, char *argv[]) if (filter_cmdline_parser_config_file(cf, &conf, ¶ms)) return -E_FILTER_SYNTAX; } + if (!conf.filter_given) + return -E_NO_FILTERS; return 1; } @@ -114,9 +116,10 @@ int main(int argc, char *argv[]) ret = parse_config(argc, argv); if (ret < 0) goto out; - sit->btrn = btr_new_node("stdin", NULL, NULL, NULL); + sit->btrn = btr_new_node(&(struct btr_node_description) + EMBRACE(.name = "stdin")); stdin_set_defaults(sit); - register_task(&sit->task); + register_task(&s, &sit->task); fns = para_malloc(conf.filter_given * sizeof(*fns)); for (i = 0, parent = sit->btrn; i < conf.filter_given; i++) { @@ -133,16 +136,25 @@ int main(int argc, char *argv[]) f = filters + fn->filter_num; sprintf(fn->task.status, "%s", f->name); PARA_DEBUG_LOG("filter #%d: %s\n", i, f->name); - fn->btrn = btr_new_node(f->name, parent, f->execute, fn); + fn->btrn = btr_new_node(&(struct btr_node_description) + EMBRACE(.name = f->name, .parent = parent, + .handler = f->execute, .context = fn)); fn->task.pre_select = f->pre_select; - fn->task.post_select = f->post_select; + if (f->new_post_select) { + fn->task.new_post_select = f->new_post_select; + fn->task.post_select = NULL; + } else { + fn->task.new_post_select = NULL; + fn->task.post_select = f->post_select; + } f->open(fn); - register_task(&fn->task); + register_task(&s, &fn->task); parent = fn->btrn; } - sot->btrn = btr_new_node("stdout", parent, NULL, NULL); + sot->btrn = btr_new_node(&(struct btr_node_description) + EMBRACE(.name = "stdout", .parent = parent)); stdout_set_defaults(sot); - register_task(&sot->task); + register_task(&s, &sot->task); s.default_timeout.tv_sec = 1; s.default_timeout.tv_usec = 0; @@ -153,14 +165,16 @@ out_cleanup: struct filter_node *fn = fns[i]; f = filters + fn->filter_num; - f->close(fn); - btr_free_node(fn->btrn); - free(fn->conf); + if (f->close) + f->close(fn); + btr_remove_node(&fn->btrn); + if (f->free_config) + f->free_config(fn->conf); free(fn); } free(fns); - btr_free_node(sit->btrn); - btr_free_node(sot->btrn); + btr_remove_node(&sit->btrn); + btr_remove_node(&sot->btrn); out: if (ret < 0) PARA_EMERG_LOG("%s\n", para_strerror(-ret));