Commit 67f86a80 67f86a800e84d6c38fd86d324dabd09b9e5b6aac by Sergey Poznyakoff

Fixed _get_fd methods.

1 parent 2f48aee1
......@@ -35,7 +35,7 @@
#define BODY_MODIFIED 0x10000
static int _body_flush __P ((stream_t));
static int _body_get_fd __P ((stream_t, int *));
static int _body_get_fd __P ((stream_t, int *, int *));
static int _body_read __P ((stream_t, char *, size_t, off_t, size_t *));
static int _body_readline __P ((stream_t, char *, size_t, off_t, size_t *));
static int _body_truncate __P ((stream_t, off_t));
......@@ -241,10 +241,15 @@ body_set_size (body_t body, int (*_size)(body_t, size_t*) , void *owner)
/* Stub function for the body stream. */
static int
_body_get_fd (stream_t stream, int *fd)
_body_get_fd (stream_t stream, int *fd, int *fd2)
{
body_t body = stream_get_owner (stream);
return stream_get_fd (body->fstream, fd);
if (fd2)
return ENOSYS;
else
{
body_t body = stream_get_owner (stream);
return stream_get_fd (body->fstream, fd);
}
}
static int
......
......@@ -314,10 +314,14 @@ _file_flush (stream_t stream)
}
static int
_file_get_fd (stream_t stream, int *pfd)
_file_get_fd (stream_t stream, int *pfd, int *pfd2)
{
struct _file_stream *fs = stream_get_owner (stream);
int status = 0;
if (pfd2)
return ENOSYS;
if (pfd)
{
if (fs->file)
......
......@@ -111,10 +111,15 @@ filter_flush (stream_t stream)
}
static int
filter_get_fd (stream_t stream, int *pfd)
filter_get_fd (stream_t stream, int *pfd, int *pfd2)
{
filter_t filter = stream_get_owner (stream);
return stream_get_fd (filter->stream, pfd);
if (pfd2)
return ENOSYS;
else
{
filter_t filter = stream_get_owner (stream);
return stream_get_fd (filter->stream, pfd);
}
}
static int
......
......@@ -77,7 +77,7 @@ static int mbox_append_message0 __P ((mailbox_t, message_t, off_t *,
static int mbox_message_uid __P ((message_t, size_t *));
static int mbox_header_fill __P ((header_t, char *, size_t, off_t,
size_t *));
static int mbox_get_body_fd __P ((stream_t, int *));
static int mbox_get_body_fd __P ((stream_t, int *, int *));
static int mbox_get_fd __P ((mbox_message_t, int *));
static int mbox_get_attr_flags __P ((attribute_t, int *));
static int mbox_set_attr_flags __P ((attribute_t, int));
......@@ -828,12 +828,17 @@ mbox_message_uid (message_t msg, size_t *puid)
}
static int
mbox_get_body_fd (stream_t is, int *pfd)
mbox_get_body_fd (stream_t is, int *pfd, int *pfd2)
{
body_t body = stream_get_owner (is);
message_t msg = body_get_owner (body);
mbox_message_t mum = message_get_owner (msg);
return mbox_get_fd (mum, pfd);
if (pfd2)
return ENOSYS;
else
{
body_t body = stream_get_owner (is);
message_t msg = body_get_owner (body);
mbox_message_t mum = message_get_owner (msg);
return mbox_get_fd (mum, pfd);
}
}
static int
......
......@@ -56,7 +56,7 @@ static int message_read __P ((stream_t is, char *buf, size_t buflen,
off_t off, size_t *pnread ));
static int message_write __P ((stream_t os, const char *buf, size_t buflen,
off_t off, size_t *pnwrite));
static int message_get_fd __P ((stream_t stream, int *pfd));
static int message_get_fd __P ((stream_t stream, int *pfd, int *pfd2));
static int message_sender __P ((envelope_t envelope, char *buf, size_t len,
size_t *pnwrite));
static int message_date __P ((envelope_t envelope, char *buf, size_t len,
......@@ -882,7 +882,7 @@ message_write (stream_t os, const char *buf, size_t buflen,
/* Implements the stream_get_fd () on the message stream. */
static int
message_get_fd (stream_t stream, int *pfd)
message_get_fd (stream_t stream, int *pfd, int *pfd2)
{
message_t msg = stream_get_owner (stream);
body_t body;
......@@ -890,6 +890,8 @@ message_get_fd (stream_t stream, int *pfd)
if (msg == NULL)
return EINVAL;
if (pfd2)
return ENOSYS;
/* Probably being lazy, then create a body for the stream. */
if (msg->body == NULL)
......
......@@ -432,13 +432,17 @@ _mimepart_body_read (stream_t stream, char *buf, size_t buflen, off_t off,
}
static int
_mimepart_body_fd (stream_t stream, int *fd)
_mimepart_body_fd (stream_t stream, int *fd, int *fd2)
{
body_t body = stream_get_owner (stream);
message_t msg = body_get_owner (body);
struct _mime_part *mime_part = message_get_owner (msg);
return stream_get_fd (mime_part->mime->stream, fd);
if (fd2)
return ENOSYS;
else
{
body_t body = stream_get_owner (stream);
message_t msg = body_get_owner (body);
struct _mime_part *mime_part = message_get_owner (msg);
return stream_get_fd (mime_part->mime->stream, fd);
}
}
static int
......@@ -657,17 +661,22 @@ _mime_body_read (stream_t stream, char *buf, size_t buflen, off_t off,
}
static int
_mime_body_fd (stream_t stream, int *fd)
_mime_body_fd (stream_t stream, int *fd, int *fd2)
{
body_t body = stream_get_owner (stream);
message_t msg = body_get_owner (body);
mime_t mime = message_get_owner (msg);
stream_t msg_stream = NULL;
if (fd2)
return ENOSYS;
else
{
body_t body = stream_get_owner (stream);
message_t msg = body_get_owner (body);
mime_t mime = message_get_owner (msg);
stream_t msg_stream = NULL;
if (mime->nmtp_parts == 0 || mime->cur_offset == 0)
return EINVAL;
message_get_stream (mime->mtp_parts[mime->cur_part]->msg, &msg_stream);
return stream_get_fd (msg_stream, fd);
if (mime->nmtp_parts == 0 || mime->cur_offset == 0)
return EINVAL;
message_get_stream (mime->mtp_parts[mime->cur_part]->msg, &msg_stream);
return stream_get_fd (msg_stream, fd);
}
}
static int
......
......@@ -150,13 +150,15 @@ _tcp_open (stream_t stream)
static int
_tcp_get_fd (stream_t stream, int *fd)
_tcp_get_fd (stream_t stream, int *fd, int *fd2)
{
struct _tcp_instance *tcp = stream_get_owner (stream);
if (fd == NULL || tcp->fd == -1)
return EINVAL;
if (fd2)
return ENOSYS;
*fd = tcp->fd;
return 0;
}
......