Commit a98c19c9 a98c19c971e38b9da7ace05254a543f309bf1586 by Alain Magloire

Changes propose by Dave Inglis.

1 parent d72ba1c6
2001-05-30 Dave Inglis
* mailbox/filter_trans.c (base64_decode): The variable should
be unsigned char not signed char. By default gcc treats a
declaration of "char*" like "signed char*", CC Watcom did not.
(base64_encode): Likewised.
* mailbox/mime.c: Read 'itl the end of the stream.
2001-05-29 Sergey Poznyakoff
* imap4d/uid.c, imap4d/search.c: support for UID SEARCH command;
* imap4d/util.c: forgotten fix to util_msgset().
......@@ -26,9 +34,10 @@
expunge will know it was modified.
* imap4d/search.c: implemented. Charsets other than US-ASCII are
not supported, though.
not supported, though.
2001-05-27 Sam Roberts
* mailbox/address.c: removed unfolding of lines at a NL before parsing.
* mailbox/parse822.c: consider LF and CRLF equivalent for purposes
of unfolding lines.
......
......@@ -269,7 +269,7 @@ base64_decode (const char *iptr, size_t isize, char *optr, size_t osize,
{
int i = 0, tmp = 0, pad = 0;
size_t consumed = 0;
char data[4];
unsigned char data[4];
(void) line_len;
*nbytes = 0;
......@@ -316,7 +316,8 @@ base64_encode (const char *iptr, size_t isize, char *optr, size_t osize,
int pad = 0;
const char *b64 =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const unsigned char* ptr = iptr;
*nbytes = 0;
if (isize <= 3)
pad = 1;
......@@ -330,12 +331,10 @@ base64_encode (const char *iptr, size_t isize, char *optr, size_t osize,
if ((*nbytes + 4) > osize)
return consumed;
}
*optr++ = b64[iptr[0] >> 2];
*optr++ = b64[((iptr[0] << 4) + (--isize ? (iptr[1] >> 4): 0)) & 0x3f];
*optr++ = isize ?
b64[((iptr[1] << 2) + (--isize ? (iptr[2] >> 6) : 0 )) & 0x3f]
: '=';
*optr++ = isize ? b64[iptr[2] & 0x3f] : '=';
*optr++ = b64[ptr[0] >> 2];
*optr++ = b64[((ptr[0] << 4) + (--isize ? (ptr[1] >> 4): 0)) & 0x3f];
*optr++ = isize ? b64[((iptr[1] << 2) + (--isize ? (ptr[2] >> 6) : 0 )) & 0x3f] : '=';
*optr++ = isize ? b64[ptr[2] & 0x3f] : '=';
iptr += 3;
consumed += 3;
(*nbytes) += 4;
......
......@@ -348,7 +348,7 @@ _mimepart_body_read(stream_t stream, char *buf, size_t buflen, off_t off, size_t
read_len = (int)mime_part->len - (int)off;
if ( read_len <= 0 ) {
if ( !stream_is_seekable (mime_part->mime->stream) ) {
while( ( ret = stream_read(mime_part->mime->stream, buf, buflen, mime_part->offset + off, nbytes) ) == 0 && *nbytes > 0 )
while( ( ret = stream_read(mime_part->mime->stream, buf, buflen, mime_part->offset + off, nbytes) ) == 0 && *nbytes )
off += *nbytes;
*nbytes = 0;
}
......@@ -447,7 +447,7 @@ _mime_body_read(stream_t stream, char *buf, size_t buflen, off_t off, size_t *nb
body_t body = stream_get_owner(stream);
message_t msg = body_get_owner(body);
mime_t mime = message_get_owner(msg);
int ret = 0, len;
int ret = 0;
size_t part_nbytes = 0;
stream_t msg_stream = NULL;
......@@ -469,8 +469,8 @@ _mime_body_read(stream_t stream, char *buf, size_t buflen, off_t off, size_t *nb
if ( ( ret = _mime_set_content_type(mime) ) == 0 ) {
do {
len = 0;
if ( mime->nmtp_parts > 1 ) {
int len;
if ( mime->flags & MIME_INSERT_BOUNDARY ) {
if ( ( mime->flags & MIME_ADDING_BOUNDARY ) == 0 ) {
mime->boundary_len = strlen(mime->boundary);
......@@ -508,14 +508,16 @@ _mime_body_read(stream_t stream, char *buf, size_t buflen, off_t off, size_t *nb
body_get_stream(part_body, &msg_stream);
}
ret = stream_read(msg_stream, buf, buflen, mime->part_offset, &part_nbytes );
len += part_nbytes;
mime->part_offset += part_nbytes;
if ( nbytes )
*nbytes += len;
mime->cur_offset += len;
if ( part_nbytes ) {
mime->part_offset += part_nbytes;
mime->cur_offset += part_nbytes;
if ( nbytes )
*nbytes += part_nbytes;
}
if ( ret == 0 && part_nbytes == 0 ) {
mime->flags |= MIME_INSERT_BOUNDARY;
mime->cur_part++;
ADD_CHAR(buf, '\n', mime->cur_offset, buflen, *nbytes);
}
} while( ret == 0 && part_nbytes == 0 && mime->cur_part <= mime->nmtp_parts );
}
......