/* Stub to call the fd from body object. */ static int nntp_body_get_transport2 (mu_stream_t stream, mu_transport_t *pin, mu_transport_t *pout) { mu_body_t body = mu_stream_get_owner (stream); mu_message_t msg = mu_body_get_owner (body); msg_nntp_t msg_nntp = mu_message_get_owner (msg); return nntp_get_transport2 (msg_nntp, pin, pout); }
static int mbox_get_body_transport (mu_stream_t is, mu_transport_t *pin, mu_transport_t *pout) { mu_body_t body = mu_stream_get_owner (is); mu_message_t msg = mu_body_get_owner (body); mbox_message_t mum = mu_message_get_owner (msg); return mbox_get_transport2 (mum, pin, pout); }
static int mbox_body_read (mu_stream_t is, char *buffer, size_t buflen, mu_off_t off, size_t *pnread) { mu_body_t body = mu_stream_get_owner (is); mu_message_t msg = mu_body_get_owner (body); mbox_message_t mum = mu_message_get_owner (msg); return mbox_readstream (mum, buffer, buflen, off, pnread, 0, mum->body, mum->body_end); }
static int pop_body_lines (mu_body_t body, size_t *plines) { mu_message_t msg = mu_body_get_owner (body); struct _pop3_message *mpm = mu_message_get_owner (msg); int status = pop_scan_message (mpm); if (status) return status; *plines = mpm->body_lines; return 0; }
static int pop_body_size (mu_body_t body, size_t *psize) { mu_message_t msg = mu_body_get_owner (body); struct _pop3_message *mpm = mu_message_get_owner (msg); int status = pop_scan_message (mpm); if (status) return status; *psize = mpm->body_end - mpm->body_start; return 0; }
static int mbox_body_lines (mu_body_t body, size_t *plines) { mu_message_t msg = mu_body_get_owner (body); mbox_message_t mum = mu_message_get_owner (msg); if (mum == NULL) return EINVAL; if (plines) *plines = mum->body_lines; return 0; }
static int mbox_body_size (mu_body_t body, size_t *psize) { mu_message_t msg = mu_body_get_owner (body); mbox_message_t mum = mu_message_get_owner (msg); if (mum == NULL) return EINVAL; if (psize) *psize = mum->body_end - mum->body; return 0; }
int pop_body_get_stream (mu_body_t body, mu_stream_t *pstr) { mu_message_t msg = mu_body_get_owner (body); struct _pop3_message *mpm = mu_message_get_owner (msg); struct _pop3_mailbox *mpd = mpm->mpd; int status = pop_scan_message (mpm); if (status) return status; return mu_streamref_create_abridged (pstr, mpd->cache, mpm->offset + mpm->body_start, mpm->offset + mpm->body_end - 1); }
/* Message read overload */ static int nntp_body_read (mu_stream_t stream, char *buffer, size_t buflen, mu_off_t offset, size_t *plen) { mu_body_t body = mu_stream_get_owner (stream); mu_message_t msg = mu_body_get_owner (body); msg_nntp_t msg_nntp = mu_message_get_owner (msg); m_nntp_t m_nntp = msg_nntp->m_nntp; f_nntp_t f_nntp = m_nntp->f_nntp; int status; size_t len = 0; /* Start over. */ if (plen == NULL) plen = &len; /* Select first. */ status = nntp_mailbox_messages_count (m_nntp->mailbox, NULL); if (status != 0) return status; if (msg_nntp->bstream == NULL) { status = mu_nntp_body (f_nntp->nntp, msg_nntp->msgno, NULL, &msg_nntp->mid, &msg_nntp->bstream); if (status != 0) return status; } status = mu_stream_read (msg_nntp->bstream, buffer, buflen, offset, plen); if (status == 0) { /* Destroy the stream. */ if (*plen == 0) { mu_stream_destroy (&msg_nntp->bstream, NULL); } } return status; }