[dovecot-cvs] dovecot/src/lib-mail istream-header-filter.c, 1.2,
1.3 istream-header-filter.h, 1.1, 1.2
cras at dovecot.org
cras at dovecot.org
Sun Jul 18 05:25:09 EEST 2004
- Previous message: [dovecot-cvs] dovecot/src/lib-imap imap-bodystructure.c,1.47,1.48
- Next message: [dovecot-cvs] dovecot/src/lib-index Makefile.am, 1.19,
1.20 mail-cache-compress.c, 1.11, 1.12 mail-cache-decisions.c,
1.4, 1.5 mail-cache-fields.c, NONE, 1.1 mail-cache-lookup.c,
1.13, 1.14 mail-cache-private.h, 1.9,
1.10 mail-cache-transaction.c, 1.14, 1.15 mail-cache.c, 1.40,
1.41 mail-cache.h, 1.18, 1.19
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/lib-mail
In directory talvi:/tmp/cvs-serv3398/lib-mail
Modified Files:
istream-header-filter.c istream-header-filter.h
Log Message:
Header caching redesigned. New design allows caching decisions per field, so
they can be divided to temporary/permanent. Cached headers are now always
returned in original order, old code didn't guarantee it. Some other caching
changes. (still missing code to store changes in caching decisions)
Index: istream-header-filter.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/istream-header-filter.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- istream-header-filter.c 7 Jul 2004 13:36:29 -0000 1.2
+++ istream-header-filter.c 18 Jul 2004 02:25:07 -0000 1.3
@@ -112,14 +112,16 @@
}
}
-static void read_and_hide_headers(struct istream *input,
- const char *const *headers,
- size_t headers_count, buffer_t *dest,
- struct message_size *hdr_size)
+static void
+read_and_hide_headers(struct istream *input, int filter,
+ const char *const *headers, size_t headers_count,
+ buffer_t *dest, struct message_size *hdr_size,
+ header_filter_callback *callback, void *context)
{
struct message_header_parser_ctx *hdr_ctx;
struct message_header_line *hdr;
uoff_t virtual_size = 0;
+ int matched;
hdr_ctx = message_parse_header_init(input, hdr_size, FALSE);
while ((hdr = message_parse_header_next(hdr_ctx)) != NULL) {
@@ -131,8 +133,12 @@
break;
}
- if (bsearch(hdr->name, headers, headers_count,
- sizeof(*headers), bsearch_strcasecmp) != NULL) {
+ matched = bsearch(hdr->name, headers, headers_count,
+ sizeof(*headers), bsearch_strcasecmp) != NULL;
+ if (callback != NULL)
+ callback(hdr, matched, context);
+
+ if (matched == filter) {
/* ignore */
} else if (dest != NULL) {
if (!hdr->continued) {
@@ -157,8 +163,9 @@
}
struct istream *
-i_stream_create_header_filter(pool_t pool, struct istream *input,
- const char *const *headers, size_t headers_count)
+i_stream_create_header_filter(pool_t pool, struct istream *input, int filter,
+ const char *const *headers, size_t headers_count,
+ header_filter_callback *callback, void *context)
{
struct header_filter_istream *mstream;
@@ -168,8 +175,11 @@
mstream->headers = buffer_create_dynamic(default_pool,
8192, (size_t)-1);
- read_and_hide_headers(input, headers, headers_count, mstream->headers,
- &mstream->header_size);
+ read_and_hide_headers(input, filter, headers, headers_count,
+ mstream->headers, &mstream->header_size,
+ callback, context);
+ if (callback != NULL)
+ callback(NULL, FALSE, context);
mstream->istream.buffer = buffer_get_data(mstream->headers, NULL);
mstream->istream.pos = mstream->header_size.virtual_size;
Index: istream-header-filter.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/istream-header-filter.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- istream-header-filter.h 20 Jun 2004 06:20:32 -0000 1.1
+++ istream-header-filter.h 18 Jul 2004 02:25:07 -0000 1.2
@@ -1,9 +1,14 @@
#ifndef __ISTREAM_HEADER_FILTER_H
#define __ISTREAM_HEADER_FILTER_H
-/* NOTE: NULL-terminated headers list must be sorted. */
+typedef void header_filter_callback(struct message_header_line *hdr,
+ int matched, void *context);
+
+/* NOTE: headers list must be sorted. If filter is TRUE, given headers are
+ removed from output, otherwise only given headers are included in output. */
struct istream *
-i_stream_create_header_filter(pool_t pool, struct istream *input,
- const char *const *headers, size_t headers_count);
+i_stream_create_header_filter(pool_t pool, struct istream *input, int filter,
+ const char *const *headers, size_t headers_count,
+ header_filter_callback *callback, void *context);
#endif
- Previous message: [dovecot-cvs] dovecot/src/lib-imap imap-bodystructure.c,1.47,1.48
- Next message: [dovecot-cvs] dovecot/src/lib-index Makefile.am, 1.19,
1.20 mail-cache-compress.c, 1.11, 1.12 mail-cache-decisions.c,
1.4, 1.5 mail-cache-fields.c, NONE, 1.1 mail-cache-lookup.c,
1.13, 1.14 mail-cache-private.h, 1.9,
1.10 mail-cache-transaction.c, 1.14, 1.15 mail-cache.c, 1.40,
1.41 mail-cache.h, 1.18, 1.19
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list