On Tue, 2010-09-21 at 15:07 -0300, Alex Baule wrote:> static void filter_callback(struct message_header_line *hdr,
> bool *matched, void *context ATTR_UNUSED)
..> What i try to understand is how the structs work, it's save the entire
> header or every line from header call the callback function ?
The function is called once for each header field and depending on
*matched value after the call it's either filtered out or not.
> hdr->name_offset is the size of elements in the struct ? (like a array
of
> message_header_line)
I don't really know what name_offset contains in this case, probably
nothing useful, don't use it. hdr->name, hdr->value and
hdr->value_len
are the only things you should need.
> The void *context ATTR_UNUSED i can pass what i want to change ? like a
> pointer to a variable ?
The context pointer contains the same pointer you gave to
i_stream_create_header_filter(). So for example you could do something
like:
char *value = NULL;
i_stream_create_header_filter(..., &value);
static void filter_callback(struct message_header_line *hdr,
bool *matched, void *context)
{
char **value = context;
if (strcmp(hdr, "yourheader") == 0 && *value == NULL)
*value = i_strndup(hdr->value, hdr->value_len);
}