[dovecot-cvs] dovecot/src/lib-mail message-parser.c,1.42,1.43
message-size.c,1.13,1.14 message-size.h,1.11,1.12
cras at procontrol.fi
cras at procontrol.fi
Thu Jun 5 03:00:46 EEST 2003
Update of /home/cvs/dovecot/src/lib-mail
In directory danu:/tmp/cvs-serv22729/lib-mail
Modified Files:
message-parser.c message-size.c message-size.h
Log Message:
Removed useless parameters from message_get_body_size(). Also did some small
optimizations to it.
Index: message-parser.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-parser.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- message-parser.c 4 Jun 2003 15:57:58 -0000 1.42
+++ message-parser.c 4 Jun 2003 23:00:44 -0000 1.43
@@ -486,8 +486,7 @@
struct message_size body_size;
if (boundaries == NULL) {
- message_get_body_size(input, &body_size,
- (uoff_t)-1, NULL, has_nuls);
+ message_get_body_size(input, &body_size, has_nuls);
message_size_add(msg_size, &body_size);
boundary = NULL;
} else {
Index: message-size.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-size.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- message-size.c 4 Jun 2003 15:57:58 -0000 1.13
+++ message-size.c 4 Jun 2003 23:00:44 -0000 1.14
@@ -62,63 +62,53 @@
}
void message_get_body_size(struct istream *input, struct message_size *body,
- uoff_t max_virtual_size, int *last_cr, int *has_nuls)
+ int *has_nuls)
{
const unsigned char *msg;
- size_t i, size, startpos, missing_cr_count;
- int cr;
+ size_t i, size, missing_cr_count;
+ int last_cr;
memset(body, 0, sizeof(struct message_size));
if (has_nuls != NULL)
*has_nuls = FALSE;
- cr = 0;
- missing_cr_count = 0; startpos = 0;
- while (max_virtual_size != 0 &&
- i_stream_read_data(input, &msg, &size, startpos) > 0) {
- cr = 0;
- for (i = startpos; i < size && max_virtual_size > 0; i++) {
- max_virtual_size--;
+ missing_cr_count = 0; last_cr = FALSE;
+ if (i_stream_read_data(input, &msg, &size, 0) <= 0)
+ return;
- if (msg[i] == '\0') {
- if (has_nuls != NULL)
- *has_nuls = TRUE;
- } else if (msg[i] == '\n') {
- if (i == 0 || msg[i-1] != '\r') {
- /* missing CR */
- missing_cr_count++;
+ if (msg[0] == '\n')
+ missing_cr_count++;
- if (max_virtual_size == 0) {
- cr = 2;
- break;
- }
+ do {
+ for (i = 1; i < size; i++) {
+ if (msg[i] > '\n')
+ continue;
- max_virtual_size--;
+ if (msg[i] == '\n') {
+ if (msg[i-1] != '\r') {
+ /* missing CR */
+ missing_cr_count++;
}
/* increase after making sure we didn't break
at virtual \r */
body->lines++;
+ } else if (msg[i] == '\0') {
+ if (has_nuls != NULL)
+ *has_nuls = TRUE;
}
}
- if (cr == 0 && i > 0 && msg[i-1] == '\r')
- cr = 1;
-
/* leave the last character, it may be \r */
i_stream_skip(input, i - 1);
- startpos = 1;
-
body->physical_size += i - 1;
- }
- i_stream_skip(input, startpos);
- body->physical_size += startpos;
+ } while (i_stream_read_data(input, &msg, &size, 1) > 0);
+
+ i_stream_skip(input, 1);
+ body->physical_size++;
body->virtual_size = body->physical_size + missing_cr_count;
i_assert(body->virtual_size >= body->physical_size);
-
- if (last_cr != NULL)
- *last_cr = cr;
}
void message_size_add(struct message_size *dest,
Index: message-size.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-size.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- message-size.h 4 Jun 2003 15:57:58 -0000 1.11
+++ message-size.h 4 Jun 2003 23:00:44 -0000 1.12
@@ -11,11 +11,8 @@
character in body. */
void message_get_header_size(struct istream *input, struct message_size *hdr,
int *has_nuls);
-/* Calculate size of message body. Read only max_virtual_size virtual bytes,
- if you want it unlimited, use (uoff_t)-1. If last_cr is not NULL, it's set
- to 1 if last character is CR, 2 if it's virtual CR. */
+/* Calculate size of message body. */
void message_get_body_size(struct istream *input, struct message_size *body,
- uoff_t max_virtual_size, int *last_cr,
int *has_nuls);
/* Sum contents of src into dest. */
More information about the dovecot-cvs
mailing list