X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=filter.c;h=1bb20b31fb8b7ed421edf357d8b86195f89e96e3;hb=6f58bbe94b49c0fb473bffebde598a3d26b051f3;hp=79ae4dcbd22ef01e9ae44cdb90d02c9d6c5c570e;hpb=40cbbb95e256e63e1e6958e9034311d4904604af;p=paraslash.git diff --git a/filter.c b/filter.c index 79ae4dcb..1bb20b31 100644 --- a/filter.c +++ b/filter.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2006 Andre Noll + * Copyright (C) 2005-2007 Andre Noll * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,8 +30,6 @@ INIT_FILTER_ERRLISTS; -#define INBUF_SIZE 32 * 1024 - static struct stdin_task stdin_task_struct; static struct stdin_task *sit = &stdin_task_struct; static struct filter_chain filter_chain_struct; @@ -39,7 +37,7 @@ static struct filter_chain *fc = &filter_chain_struct; static struct stdout_task stdout_task_struct; static struct stdout_task *sot = &stdout_task_struct; -struct gengetopt_args_info conf; +static struct filter_args_info conf; __printf_2_3 void para_log(int ll, const char* fmt,...) { @@ -53,9 +51,9 @@ __printf_2_3 void para_log(int ll, const char* fmt,...) va_end(argp); } -void filter_event_handler(struct task *t) +static void filter_event_handler(struct task *t) { - PARA_ERROR_LOG("%s\n", PARA_STRERROR(-t->ret)); + PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-t->ret)); unregister_task(t); } @@ -71,7 +69,6 @@ static void open_filters(void) } } - static int init_filter_chain(void) { int i, filter_num; @@ -81,7 +78,13 @@ static int init_filter_chain(void) fc->inbuf = sit->buf; fc->in_loaded = &sit->loaded; - fc->reader_eof = &sit->eof; + fc->input_eof = &sit->eof; + fc->eof = 0; + fc->output_eof = &sot->eof; + fc->task.private_data = fc; + fc->task.pre_select = filter_pre_select; + fc->task.event_handler = filter_event_handler; + sprintf(fc->task.status, "filter chain"); for (i = 0; i < conf.filter_given; i++) { char *fa = conf.filter_arg[i]; @@ -99,10 +102,6 @@ static int init_filter_chain(void) } if (list_empty(&fc->filters)) return -E_NO_FILTERS; - fc->task.private_data = fc; - fc->task.pre_select = filter_pre_select; - fc->task.event_handler = filter_event_handler; - sprintf(fc->task.status, "filter chain"); open_filters(); return 1; } @@ -113,7 +112,7 @@ static int parse_config(int argc, char *argv[]) struct stat statbuf; int i; - if (cmdline_parser(argc, argv, &conf)) + if (filter_cmdline_parser(argc, argv, &conf)) return -E_FILTER_SYNTAX; if (!cf) { char *home = para_homedir(); @@ -121,7 +120,7 @@ static int parse_config(int argc, char *argv[]) free(home); } if (!stat(cf, &statbuf)) { - if (cmdline_parser_configfile(cf, &conf, 0, 0, 0)) + if (filter_cmdline_parser_configfile(cf, &conf, 0, 0, 0)) return -E_FILTER_SYNTAX; } if (!conf.list_filters_given) @@ -140,7 +139,6 @@ int main(int argc, char *argv[]) int ret; struct sched s; - init_sched(); stdin_set_defaults(sit); sit->buf = para_malloc(sit->bufsize), @@ -155,7 +153,7 @@ int main(int argc, char *argv[]) stdout_set_defaults(sot); sot->buf = fc->outbuf; sot->loaded = fc->out_loaded; - sot->eof = &fc->eof; + sot->input_eof = &fc->eof; register_task(&sot->task); register_task(&fc->task); @@ -165,8 +163,8 @@ int main(int argc, char *argv[]) ret = sched(&s); out: free(sit->buf); + close_filters(fc); if (ret < 0) PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret)); - close_filters(fc); return ret < 0? EXIT_FAILURE : EXIT_SUCCESS; }