1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 1999-2021 Free Software Foundation, Inc.
3
4 GNU Mailutils is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 GNU Mailutils is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
16
17 /* This file implements an MH draftfile stream: a read-only stream used
18 to transparently pass MH draftfiles to mailers. The only difference
19 between the usual RFC822 and MH draft is that the latter allows to use
20 a string of dashes to separate the headers from the body. */
21
22 #include <mh.h>
23 #include <mailutils/stream.h>
24
25 mu_message_t
mh_stream_to_message(mu_stream_t instream)26 mh_stream_to_message (mu_stream_t instream)
27 {
28 int rc;
29 mu_message_t msg;
30
31 rc = mu_stream_to_message (instream, &msg);
32 mu_stream_unref (instream);
33 if (rc)
34 {
35 mu_error (_("cannot open draft message stream: %s"),
36 mu_strerror (rc));
37 return NULL;
38 }
39 return msg;
40 }
41