- list_for_each_entry(fn, &fc->filters, node) {
- fn->filter->open(fn);
- PARA_INFO_LOG("opened %s filter\n", fn->filter->name);
- fc->outbuf = fn->buf;
- fc->out_loaded = &fn->loaded;
- }
-}
-
-static int init_filter_chain(void)
-{
- int i, filter_num;
- struct filter_node *fn;
-
- INIT_LIST_HEAD(&fc->filters);
-
- fc->inbuf = sit->buf;
- fc->in_loaded = &sit->loaded;
- 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];
- fn = para_calloc(sizeof(struct filter_node));
- filter_num = check_filter_arg(fa, &fn->conf);
- if (filter_num < 0) {
- free(fn);
- return filter_num;
- }
- fn->fc = fc;
- INIT_LIST_HEAD(&fn->callbacks);
- fn->filter = &filters[filter_num];
- PARA_DEBUG_LOG("adding %s to filter chain\n", fn->filter->name);
- list_add_tail(&fn->node, &fc->filters);
- }
- if (list_empty(&fc->filters))
- return -E_NO_FILTERS;
- open_filters();
- return 1;