[dovecot-cvs] dovecot/src/lib-mail message-send.c,1.20,1.21
message-send.h,1.11,1.12
cras at procontrol.fi
cras at procontrol.fi
Sat Nov 8 22:47:09 EET 2003
Update of /home/cvs/dovecot/src/lib-mail
In directory danu:/tmp/cvs-serv1373/lib-mail
Modified Files:
message-send.c message-send.h
Log Message:
message_send()'s skip parameter was buggy with messages having CRLF.
Index: message-send.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-send.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- message-send.c 5 Nov 2003 08:42:13 -0000 1.20
+++ message-send.c 8 Nov 2003 20:47:07 -0000 1.21
@@ -9,41 +9,30 @@
off_t message_send(struct ostream *output, struct istream *input,
const struct message_size *msg_size,
- uoff_t virtual_skip, uoff_t max_virtual_size, int *last_cr,
+ int cr_skipped, uoff_t max_virtual_size, int *last_cr,
int fix_nuls)
{
const unsigned char *msg;
- uoff_t old_limit, limit;
size_t i, size;
off_t ret;
- int cr_skipped;
unsigned char add;
if (last_cr != NULL)
*last_cr = -1;
- if (msg_size->physical_size == 0 ||
- virtual_skip >= msg_size->virtual_size)
+ if (msg_size->physical_size == 0)
return 0;
- if (max_virtual_size > msg_size->virtual_size - virtual_skip)
- max_virtual_size = msg_size->virtual_size - virtual_skip;
-
if (msg_size->physical_size == msg_size->virtual_size && !fix_nuls) {
/* no need to kludge with CRs, we can use sendfile() */
- i_stream_skip(input, virtual_skip);
-
- old_limit = input->v_limit;
- limit = input->v_offset + max_virtual_size;
- i_stream_set_read_limit(input, I_MIN(limit, old_limit));
+ input = i_stream_create_limit(default_pool, input,
+ input->v_offset,
+ max_virtual_size);
ret = o_stream_send_istream(output, input);
- i_stream_set_read_limit(input, old_limit);
-
+ i_stream_unref(input);
return ret;
}
- message_skip_virtual(input, virtual_skip, NULL, 0, &cr_skipped);
-
/* go through the message data and insert CRs where needed. */
ret = 0;
while (max_virtual_size > 0 &&
@@ -53,8 +42,8 @@
max_virtual_size--;
if (msg[i] == '\n') {
- if ((i == 0 && !cr_skipped) ||
- (i > 0 && msg[i-1] != '\r')) {
+ if ((i > 0 && msg[i-1] != '\r') ||
+ (i == 0 && !cr_skipped)) {
/* missing CR */
add = '\r';
break;
Index: message-send.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-send.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- message-send.h 4 Jun 2003 15:57:58 -0000 1.11
+++ message-send.h 8 Nov 2003 20:47:07 -0000 1.12
@@ -4,13 +4,12 @@
struct message_size;
/* Send message to client inserting CRs if needed. Only max_virtual_size
- bytes if sent (relative to virtual_skip), if you want it unlimited,
- use (uoff_t)-1. Remember that if input begins with LF, CR is inserted
- before it unless virtual_skip = 1. last_cr is set to 1, 0 or -1 if not
- known. Returns number of bytes sent, or -1 if error. */
+ bytes are sent. If cr_skipped is FALSE and input begins with LF, it's
+ treated as CRLF. last_cr is set to 1, 0 or -1 if not known. Returns number
+ of bytes sent, or -1 if error. */
off_t message_send(struct ostream *output, struct istream *input,
const struct message_size *msg_size,
- uoff_t virtual_skip, uoff_t max_virtual_size, int *last_cr,
+ int cr_skipped, uoff_t max_virtual_size, int *last_cr,
int fix_nuls);
/* Skip number of virtual bytes from putfer. msg_size is updated if it's not
More information about the dovecot-cvs
mailing list