summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-05-01 17:43:48 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2010-05-01 17:43:48 +0300
commit55187d77a5aece6b16c1a6091f9704bd159fda73 (patch)
tree1a9be45b29269dd8c194488042243bb8bbb8a221
parente745b7a0a24f3f29f1737d9bb52a0c2683384ffb (diff)
downloadmailutils-55187d77a5aece6b16c1a6091f9704bd159fda73.tar.gz
mailutils-55187d77a5aece6b16c1a6091f9704bd159fda73.tar.bz2
Bugfixes
* mailbox/message.c (_check_stream_state): Bugfix. (_message_stream_seek): Bugfix. (_message_stream_read): Always try to fill out the buffer. (_message_stream_create): Set MU_STREAM_SEEK flag bit.
-rw-r--r--mailbox/message.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/mailbox/message.c b/mailbox/message.c
index d23677cf3..9bffd1c59 100644
--- a/mailbox/message.c
+++ b/mailbox/message.c
@@ -104,7 +104,7 @@ _check_stream_state (struct _mu_message_stream *str)
rc = mu_body_get_streamref (str->msg->body, &str->transport);
if (rc == 0)
{
- str->state = _mss_header;
+ str->state = _mss_body;
rc = mu_stream_seek (str->transport, 0, MU_SEEK_SET, NULL);
}
}
@@ -194,13 +194,12 @@ _message_stream_seek (struct _mu_stream *str, mu_off_t off, int whence,
return rc;
/* fall through */
case _mss_header:
- if (off > hsize)
- {
- mu_stream_destroy (&sp->transport);
- rc = _check_stream_state (sp);
- if (rc)
- return rc;
- }
+ if (off < hsize)
+ break;
+ mu_stream_destroy (&sp->transport);
+ rc = _check_stream_state (sp);
+ if (rc)
+ return rc;
/* fall through */
case _mss_body:
off -= hsize;
@@ -224,15 +223,24 @@ _message_stream_read (struct _mu_stream *str, char *buf, size_t bufsize,
size_t *pnread)
{
struct _mu_message_stream *sp = (struct _mu_message_stream *)str;
- int rc = _check_stream_state (sp);
- if (rc)
- return rc;
- if (sp->state == _mss_eof)
+ size_t nread = 0;
+ int rc;
+
+ while (bufsize)
{
- *pnread = 0;
- return 0;
+ size_t n;
+ rc = _check_stream_state (sp);
+ if (rc)
+ break;
+ if (sp->state == _mss_eof)
+ break;
+ rc = mu_stream_read (sp->transport, buf, bufsize, &n);
+ nread += n;
+ buf += n;
+ bufsize -= n;
}
- return mu_stream_read (sp->transport, buf, bufsize, pnread);
+ *pnread = nread;
+ return rc;
}
#if 0
@@ -252,7 +260,8 @@ _message_stream_create (mu_stream_t *pmsg, mu_message_t msg, int flags)
{
struct _mu_message_stream *sp;
- sp = (struct _mu_message_stream *) _mu_stream_create (sizeof (*sp), flags);
+ sp = (struct _mu_message_stream *) _mu_stream_create (sizeof (*sp),
+ flags | MU_STREAM_SEEK);
if (!sp)
return ENOMEM;

Return to:

Send suggestions and report system problems to the System administrator.