The filter can submitted as a character string in ECL or as a compiled
function in a C library archieve.
The Echo CVS repository contains samples for both cases.
int
xxx_filter(void* input, void* output, void* data) {
Filters can be divided into two classes. One class of filters take in
the incoming event
and decides whether it should be published on the derived channel. The
other class of filters act as a tranformer, which means it takes in the
incoming event but publish it in a different event format. The two kind
of filters are submitted through different APIs.
For ECL filter, there are three predefined parameters: input, output,
and data. "input" represents the incoming event, "output" represents
the outgoing event, and "data" acts like a static variable which will
still persist after each filter
invocation. The format of the "input" parameter is specified when the *to-be-derived* channel is created,
and the format of "output" and "data" is specified when the *derived* channel is created.
For example,
/* when channel is created */
chan = EChannel_typed_create(cc,
INPUT_FIELD, INPUT_FIELD_FORMAT_LIST);
TO_BE_DERIVED_CHAN_ID =
ECglobal_id(chan);
/* when channel is derived */
derived_chan = EChannel_typed_derive_data(cc,
TO_BE_DERIVED_CHAN_ID,
FILTER_NAME,
OUTPUT_FIELD,
OUTPUT_FIELD_FORMAT_LIST,
DATA_SPEC);
For filter as a function in C library, the parameters are determined by
their order of the declaration.
Usually, we use the filter declaration in C like this.
int
XXX_FILTER(void* input, void* output, void* data);
So, the "input/output/data" parameter will be the 1st, 2nd and the
3rd parameter, and the function declaration maintains this consistency.
For source code access, I remembered the test/ directory in the ECho
CVS
repository contains some samples for the filter use. Also the filters
for smartP can be obtained from the pipegl/pipgl_filters.[ch]
from the smartP's CVS repository.