[dovecot-cvs] dovecot/src/lib-mail message-parser.c,1.47,1.48
message-part-serialize.c,1.18,1.19 message-part-serialize.h,1.8,1.9
cras at procontrol.fi
cras at procontrol.fi
Wed Sep 3 02:33:36 EEST 2003
- Previous message: [dovecot-cvs] dovecot/src/lib-index/mbox istream-mbox.c,NONE,1.1
Makefile.am,1.6,1.7 mbox-append.c,1.43,1.44 mbox-index.c,1.79,1.80
mbox-index.h,1.31,1.32 mbox-open.c,1.21,1.22
mbox-rewrite.c,1.60,1.61 mbox-sync-full.c,1.15,1.16
mbox-sync.c,1.34,1.35
- Next message: [dovecot-cvs]
dovecot/src/lib-storage/index/mbox mbox-expunge.c,1.29,1.30
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/lib-mail
In directory danu:/tmp/cvs-serv25812/lib-mail
Modified Files:
message-parser.c message-part-serialize.c
message-part-serialize.h
Log Message:
mbox reading is kind of working again. Just don't try rewriting or expunging
:) Changing headers are also hidden from clients so mbox messages are finally
seen immutable as required by IMAP.
Index: message-parser.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-parser.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- message-parser.c 21 Aug 2003 00:04:11 -0000 1.47
+++ message-parser.c 2 Sep 2003 22:33:33 -0000 1.48
@@ -637,8 +637,10 @@
hdr_ctx = message_parse_header_init(input, hdr_size);
while ((hdr = message_parse_header_next(hdr_ctx)) != NULL)
callback(part, hdr, context);
- callback(part, NULL, context);
message_parse_header_deinit(hdr_ctx);
+
+ /* call after the final skipping */
+ callback(part, NULL, context);
}
struct message_header_parser_ctx *
@@ -722,6 +724,24 @@
if (ret == -1) {
/* error / EOF with no bytes */
return NULL;
+ }
+
+ if (msg[0] == '\n' ||
+ (msg[0] == '\r' && size > 1 && msg[1] == '\n')) {
+ /* end of headers - this mostly happens just
+ with mbox where headers are read separately
+ from body */
+ size = 0;
+ if (ctx->hdr_size != NULL)
+ ctx->hdr_size->lines++;
+ if (msg[0] == '\r')
+ ctx->skip = 2;
+ else {
+ ctx->skip = 1;
+ if (ctx->hdr_size != NULL)
+ ctx->hdr_size->virtual_size++;
+ }
+ break;
}
/* a) line is larger than input buffer
Index: message-part-serialize.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-part-serialize.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- message-part-serialize.c 21 Aug 2003 01:59:50 -0000 1.18
+++ message-part-serialize.c 2 Sep 2003 22:33:33 -0000 1.19
@@ -264,87 +264,6 @@
return part;
}
-static size_t get_serialized_size(unsigned int flags)
-{
- size_t size = sizeof(unsigned int) + sizeof(uoff_t) * 5;
-
- if ((flags & (MESSAGE_PART_FLAG_TEXT |
- MESSAGE_PART_FLAG_MESSAGE_RFC822)) != 0)
- size += sizeof(unsigned int);
- if ((flags & (MESSAGE_PART_FLAG_MULTIPART |
- MESSAGE_PART_FLAG_MESSAGE_RFC822)) != 0)
- size += sizeof(unsigned int);
- return size;
-}
-
-int message_part_serialize_update_header(void *data, size_t size,
- struct message_size *hdr_size,
- const char **error)
-{
- unsigned char *buf = data;
- size_t offset, part_size;
- uoff_t uofft_size, old_size;
- off_t pos_diff;
- unsigned int flags;
-
- i_assert(hdr_size->physical_size <= OFF_T_MAX);
-
- if (size < MINIMUM_SERIALIZED_SIZE) {
- *error = "Not enough data";
- return FALSE;
- }
-
- memcpy(&flags, buf, sizeof(flags));
- memcpy(&uofft_size, buf + sizeof(unsigned int), sizeof(uoff_t));
-
- if (uofft_size > OFF_T_MAX) {
- *error = "Invalid physical_size";
- return FALSE;
- }
- pos_diff = (off_t)hdr_size->physical_size - (off_t)uofft_size;
- old_size = uofft_size;
-
- memcpy(buf + sizeof(unsigned int),
- &hdr_size->physical_size, sizeof(uoff_t));
- memcpy(buf + sizeof(unsigned int) + sizeof(uoff_t),
- &hdr_size->virtual_size, sizeof(uoff_t));
-
- if (pos_diff != 0) {
- /* have to update all positions, but skip the root */
- offset = get_serialized_size(flags) - sizeof(uoff_t);
-
- while (offset + sizeof(unsigned int) < size) {
- memcpy(buf + offset, &flags, sizeof(flags));
-
- part_size = get_serialized_size(flags);
- if (offset + part_size > size) {
- *error = "Not enough data";
- return FALSE;
- }
- memcpy(&uofft_size, buf + offset + sizeof(flags),
- sizeof(uoff_t));
-
- if (uofft_size < old_size || uofft_size >= OFF_T_MAX) {
- /* invalid offset, might cause overflow */
- *error = "Invalid offset";
- return FALSE;
- }
- uofft_size += pos_diff;
-
- memcpy(buf + offset + sizeof(flags), &uofft_size,
- sizeof(uoff_t));
- offset += part_size;
- }
-
- if (offset != size) {
- *error = "Invalid size";
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
int message_part_deserialize_size(const void *data, size_t size,
struct message_size *hdr_size,
struct message_size *body_size)
Index: message-part-serialize.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-part-serialize.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- message-part-serialize.h 11 Jan 2003 23:13:36 -0000 1.8
+++ message-part-serialize.h 2 Sep 2003 22:33:33 -0000 1.9
@@ -12,11 +12,6 @@
struct message_part *message_part_deserialize(pool_t pool, const void *data,
size_t size, const char **error);
-/* Update header size in serialized struct message_part. */
-int message_part_serialize_update_header(void *data, size_t size,
- struct message_size *hdr_size,
- const char **error);
-
/* Get message size from serialized struct message_part data. */
int message_part_deserialize_size(const void *data, size_t size,
struct message_size *hdr_size,
- Previous message: [dovecot-cvs] dovecot/src/lib-index/mbox istream-mbox.c,NONE,1.1
Makefile.am,1.6,1.7 mbox-append.c,1.43,1.44 mbox-index.c,1.79,1.80
mbox-index.h,1.31,1.32 mbox-open.c,1.21,1.22
mbox-rewrite.c,1.60,1.61 mbox-sync-full.c,1.15,1.16
mbox-sync.c,1.34,1.35
- Next message: [dovecot-cvs]
dovecot/src/lib-storage/index/mbox mbox-expunge.c,1.29,1.30
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list