Commit c948b18a c948b18a102b660bab5a74f4615ea6c7a496419d by Alain Magloire

message add the header count part of the bytes being written.

1 parent 543739df
......@@ -108,7 +108,8 @@ attribute_set_recent (attribute_t attr)
return EINVAL;
if (attr == NULL)
{
attr->flag = 0;
attr->flag &= ~MU_ATTRIBUTE_READ;
attr->flag &= ~MU_ATTRIBUTE_SEEN;
return 0;
}
return EACCES;
......@@ -167,7 +168,10 @@ attribute_is_recent (attribute_t attr)
{
if (attr == NULL)
return 0;
return attr->flag == 0;
/* something is recent when it is not read and not seen. */
return (attr->flag == 0
|| ! ((attr->flag & MU_ATTRIBUTE_SEEN)
&& (attr->flag & MU_ATTRIBUTE_READ));
}
int
......@@ -229,7 +233,7 @@ attribute_unset_recent (attribute_t attr)
{
if (attr == NULL)
return 0;
attr->flag |= MU_ATTRIBUTE_SEEN;
attr-> |= MU_ATTRIBUTE_SEEN;
return 0;
}
......
......@@ -37,13 +37,13 @@ struct _attribute
size_t flag;
};
#define MU_ATTRIBUTE_SEEN ((int)1)
#define MU_ATTRIBUTE_ANSWERED (MU_ATTRIBUTE_SEEN << 1)
#define MU_ATTRIBUTE_FLAGGED (MU_ATTRIBUTE_ANSWERED << 1)
#define MU_ATTRIBUTE_DELETED (MU_ATTRIBUTE_FLAGGED << 1)
#define MU_ATTRIBUTE_DRAFT (MU_ATTRIBUTE_DELETED << 1)
#define MU_ATTRIBUTE_RECENT (MU_ATTRIBUTE_DRAFT << 1)
#define MU_ATTRIBUTE_READ (MU_ATTRIBUTE_RECENT << 1)
#define MU_ATTRIBUTE_ANSWERED 0x01
#define MU_ATTRIBUTE_FLAGGED 0x02
#define MU_ATTRIBUTE_DELETED 0x04
#define MU_ATTRIBUTE_DRAFT 0x08
#define MU_ATTRIBUTE_SEEN 0x10
#define MU_ATTRIBUTE_READ 0x20
#define MU_ATTRIBUTE_RECENT 0x00
#ifdef __cplusplus
}
......
......@@ -559,7 +559,8 @@ message_write (stream_t os, const char *buf, size_t buflen,
off_t off, size_t *pnwrite)
{
message_t msg;
int status;
int status = 0;
size_t bufsize = 0;
if (os == NULL || (msg = os->owner) == NULL)
return EINVAL;
......@@ -629,11 +630,13 @@ message_write (stream_t os, const char *buf, size_t buflen,
msg->hdr_buf = thdr;
memcpy (msg->hdr_buf + msg->hdr_buflen, buf, buflen);
msg->hdr_buflen += buflen;
buflen = 0;
}
else if (buflen > 0) /* in the body */
{
stream_t bs;
body_t body;
size_t written = 0;
if ((status = message_get_body (msg, &body)) != 0 ||
(status = body_get_stream (msg->body, &bs)) != 0)
{
......@@ -646,9 +649,12 @@ message_write (stream_t os, const char *buf, size_t buflen,
off = 0;
else
off -= msg->hdr_buflen;
return stream_write (bs, buf, buflen, off, pnwrite);
status = stream_write (bs, buf, buflen, off, &written);
buflen -= written;
}
return 0;
if (pnwrite)
*pnwrite = busize - buflen;
return status;
}
static int
......