[SCM] GNU Mailutils branch, stream-cleanup, updated. rel-2_1-80-gfd5cc10

"Sergey Poznyakoff" <[email protected]>
Newsgroups gmane.comp.gnu.mailutils.cvs
Message-ID <[email protected]>
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=fd5cc1028e705b1c5fc350361e3a10a0b23f6b23

The branch, stream-cleanup has been updated
       via  fd5cc1028e705b1c5fc350361e3a10a0b23f6b23 (commit)
      from  987ec1d4f1fda22924fc84531e76f02fe6a288b9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit fd5cc1028e705b1c5fc350361e3a10a0b23f6b23
Author: Sergey Poznyakoff <[email protected]>
Date:   Sat May 1 01:39:49 2010 +0300

    Use stringrefs, add some guidelines for further editing.
    
    * comsat/action.c
    * imap4d/fetch.c
    * imap4d/search.c
    * mh/burst.c
    * mh/comp.c
    * mh/forw.c
    * mh/mh_ctx.c
    * mh/mh_format.c
    * mh/mh_list.c
    * mh/mhn.c
    * mh/pick.y
    * pop3d/retr.c
    * pop3d/top.c
    * readmsg/msglist.c
    * readmsg/readmsg.c

-----------------------------------------------------------------------

Summary of changes:
 comsat/action.c   |    3 +-
 imap4d/fetch.c    |   25 ++++++++++-----
 imap4d/search.c   |    3 +-
 mh/burst.c        |   31 ++++++++++--------
 mh/comp.c         |   41 +++++++------------------
 mh/forw.c         |    4 +-
 mh/mh_ctx.c       |    7 ++--
 mh/mh_format.c    |    8 +++--
 mh/mh_list.c      |    6 +--
 mh/mhn.c          |   87 +++++++++++++++++++++++++----------------------------
 mh/pick.y         |    4 +-
 pop3d/retr.c      |    1 +
 pop3d/top.c       |    2 +
 readmsg/msglist.c |    3 +-
 readmsg/readmsg.c |   10 ++++--
 15 files changed, 115 insertions(+), 120 deletions(-)

diff --git a/comsat/action.c b/comsat/action.c
index 638d03f..738521c 100644
--- a/comsat/action.c
+++ b/comsat/action.c
@@ -155,7 +155,7 @@ expand_escape (char **pp, mu_message_t msg, struct obstack *stk)
       if (lncount == 0)
 	lncount = maxlines;
       if (mu_message_get_body (msg, &body) == 0
-	  && mu_body_get_stream (body, &stream) == 0)
+	  && mu_body_get_streamref (body, &stream) == 0)
 	{
 	  size_t nread;
 	  char *buf = malloc (size+1);
@@ -179,6 +179,7 @@ expand_escape (char **pp, mu_message_t msg, struct obstack *stk)
 		}
 	      obstack_grow (stk, buf, size);
 	    }
+	  mu_stream_destroy (&stream);
 	  free (buf);
 	}
       *pp = p;
diff --git a/imap4d/fetch.c b/imap4d/fetch.c
index 18452a2..a36a097 100644
--- a/imap4d/fetch.c
+++ b/imap4d/fetch.c
@@ -885,7 +885,8 @@ _frt_body (struct fetch_function_closure *ffc,
   mu_message_t msg;
   mu_stream_t stream = NULL;
   size_t size = 0, lines = 0;
-
+  int rc;
+  
   set_seen (ffc, frt);
   if (ffc->name)
     util_send ("%s", ffc->name);
@@ -897,10 +898,12 @@ _frt_body (struct fetch_function_closure *ffc,
       util_send (" \"\"");
       return RESP_OK;
     }
-  mu_message_get_stream (msg, &stream);
+  mu_message_get_streamref (msg, &stream);
   mu_message_size (msg, &size);
   mu_message_lines (msg, &lines);
-  return fetch_io (stream, ffc->start, ffc->size, size + lines);
+  rc = fetch_io (stream, ffc->start, ffc->size, size + lines);
+  mu_stream_destroy (&stream);
+  return rc;
 }
 
 static int
@@ -911,7 +914,8 @@ _frt_body_text (struct fetch_function_closure *ffc,
   mu_body_t body = NULL;
   mu_stream_t stream = NULL;
   size_t size = 0, lines = 0;
-
+  int rc;
+  
   set_seen (ffc, frt);
   if (ffc->name)
     util_send ("%s",  ffc->name);
@@ -927,8 +931,10 @@ _frt_body_text (struct fetch_function_closure *ffc,
   mu_message_get_body (msg, &body);
   mu_body_size (body, &size);
   mu_body_lines (body, &lines);
-  mu_body_get_stream (body, &stream);
-  return fetch_io (stream, ffc->start, ffc->size, size + lines);
+  mu_body_get_streamref (body, &stream);
+  rc = fetch_io (stream, ffc->start, ffc->size, size + lines);
+  mu_stream_destroy (&stream);
+  return rc;
 }
 
 static int
@@ -953,6 +959,7 @@ _frt_header0 (struct fetch_function_closure *ffc,
   mu_header_t header = NULL;
   mu_stream_t stream = NULL;
   size_t size = 0, lines = 0;
+  int rc;
   
   set_seen (ffc, frt);
   if (ffc->name)
@@ -969,8 +976,10 @@ _frt_header0 (struct fetch_function_closure *ffc,
   mu_message_get_header (msg, &header);
   mu_header_size (header, &size);
   mu_header_lines (header, &lines);
-  mu_header_get_stream (header, &stream);
-  return fetch_io (stream, ffc->start, ffc->size, size + lines);
+  mu_header_get_streamref (header, &stream);
+  rc = fetch_io (stream, ffc->start, ffc->size, size + lines);
+  mu_stream_destroy (&stream);
+  return rc;
 }
 
 static int
diff --git a/imap4d/search.c b/imap4d/search.c
index bdfca9e..33d2aa2 100644
--- a/imap4d/search.c
+++ b/imap4d/search.c
@@ -842,7 +842,7 @@ _scan_body (struct parsebuf *pb, char *text)
   mu_message_get_body (pb->msg, &body);
   mu_body_size (body, &size);
   mu_body_lines (body, &lines);
-  mu_body_get_stream (body, &stream);
+  mu_body_get_streamref (body, &stream);
   rc = 0;
   while (rc == 0
 	 && mu_stream_read (stream, buffer, sizeof(buffer)-1, &n) == 0
@@ -851,6 +851,7 @@ _scan_body (struct parsebuf *pb, char *text)
       buffer[n] = 0;
       rc = util_strcasestr (buffer, text) != NULL;
     }
+  mu_stream_destroy (&stream);
   return rc;
 }
 
diff --git a/mh/burst.c b/mh/burst.c
index 0dcb080..0647baa 100644
--- a/mh/burst.c
+++ b/mh/burst.c
@@ -286,8 +286,7 @@ burst_digest (mu_message_t msg)
       exit (1);
     }
 
-  mu_message_get_stream (msg, &is);
-  mu_stream_seek (is, 0, MU_SEEK_SET, NULL);
+  mu_message_get_streamref (msg, &is);
   while (mu_stream_read (is, buf, bufsize, &n) == 0
 	 && n > 0)
     {
@@ -339,7 +338,8 @@ burst_digest (mu_message_t msg)
 
       flush_stream (&os, buf + start, i - start);
     }
-
+  mu_stream_destroy (&is);
+  
   free (buf);
   if (os)
     {
@@ -390,8 +390,10 @@ burst_or_copy (mu_message_t msg, int recursive, int copy)
 	      mu_body_t body;
 	      
 	      mu_message_get_body (msg, &body);
-	      mu_body_get_stream (body, &str);
-
+	      mu_body_get_streamref (body, &str);
+	      /* FIXME: Check if str is actually destroyed.
+		 See mailbox/message_stream.c
+	      */
 	      msg = mh_stream_to_message (str);
 	    }
 	  free (value);
@@ -487,8 +489,6 @@ msg_copy (size_t num, const char *file)
   mu_attribute_t attr = NULL;
   mu_stream_t istream, ostream;
   int rc;
-  size_t n;
-  char buf[512];
   
   if ((rc = mu_file_stream_create (&ostream,
 				   file,
@@ -501,13 +501,16 @@ msg_copy (size_t num, const char *file)
     }
 
   mu_mailbox_get_message (tmpbox, num, &msg);
-  mu_message_get_stream (msg, &istream);
-  mu_stream_seek (istream, 0, MU_SEEK_SET, NULL);
-  while (rc == 0
-	 && mu_stream_read (istream, buf, sizeof buf, &n) == 0
-	 && n > 0)
-    /* FIXME: Implement RFC 934 FSA? */
-    rc = mu_stream_write (ostream, buf, n, NULL);
+  mu_message_get_streamref (msg, &istream);
+  /* FIXME: Implement RFC 934 FSA? */
+  rc = mu_stream_copy (ostream, istream, 0);
+  if (rc)
+    {
+      mu_error (_("copy stream error: %s"), mu_strerror (rc));
+      exit (1);
+    }
+  
+  mu_stream_destroy (&istream);
   
   mu_stream_close (ostream);
   mu_stream_destroy (&ostream);
diff --git a/mh/comp.c b/mh/comp.c
index c01dfd6..3ac0a41 100644
--- a/mh/comp.c
+++ b/mh/comp.c
@@ -160,49 +160,30 @@ copy_message (mu_mailbox_t mbox, size_t n, const char *file)
   mu_stream_t in;
   mu_stream_t out;
   int rc;
-  size_t size;
-  char *buffer;
-  size_t bufsize, rdsize;
   
   mu_mailbox_get_message (mbox, n, &msg);
-  mu_message_size (msg, &size);
-
-  for (bufsize = size; bufsize > 0 && (buffer = malloc (bufsize)) == 0;
-       bufsize /= 2)
-    ;
-
-  if (!bufsize)
-    mh_err_memory (1);
-
-  mu_message_get_stream (msg, &in);
+  mu_message_get_streamref (msg, &in);
   
   if ((rc = mu_file_stream_create (&out,
-				file, MU_STREAM_RDWR|MU_STREAM_CREAT)) != 0
+				   file, MU_STREAM_RDWR|MU_STREAM_CREAT)) != 0
       || (rc = mu_stream_open (out)))
     {
       mu_error (_("cannot open output file \"%s\": %s"),
 		file, mu_strerror (rc));
-      free (buffer);
-      return 1;
-    }
-
-  mu_stream_seek (in, 0, MU_SEEK_SET, NULL);
-  while (size > 0
-	 && (rc = mu_stream_read (in, buffer, bufsize, &rdsize)) == 0
-	 && rdsize > 0)
-    {
-      if ((rc = mu_stream_write (out, buffer, rdsize, NULL)) != 0)
-	{
-	  mu_error (_("error writing to \"%s\": %s"),
-		    file, mu_strerror (rc));
-	  break;
-	}
-      size -= rdsize;
+      mu_stream_destroy (&in);
+      return rc;
     }
 
+  rc = mu_stream_copy (out, in, 0);
+  mu_stream_destroy (&in);
   mu_stream_close (out);
   mu_stream_destroy (&out);
   
+  if (rc)
+    {
+      mu_error (_("error copying to \"%s\": %s"),
+		file, mu_strerror (rc));
+    }
   return rc;
 }
 
diff --git a/mh/forw.c b/mh/forw.c
index 390af21..8ec9fee 100644
--- a/mh/forw.c
+++ b/mh/forw.c
@@ -246,10 +246,9 @@ msg_copy (mu_message_t msg, mu_stream_t ostream)
   char buf[512];
   enum rfc934_state state = S1;
   
-  rc = mu_message_get_stream (msg, &istream);
+  rc = mu_message_get_streamref (msg, &istream);
   if (rc)
     return rc;
-  mu_stream_seek (istream, 0, SEEK_SET, NULL);
   while (rc == 0
 	 && mu_stream_read (istream, buf, sizeof buf, &n) == 0
 	 && n > 0)
@@ -283,6 +282,7 @@ msg_copy (mu_message_t msg, mu_stream_t ostream)
       if (i > start)
 	rc = mu_stream_write (ostream, buf + start, i  - start, NULL);
     }
+  mu_stream_destroy (&istream);
   return rc;
 }
 
diff --git a/mh/mh_ctx.c b/mh/mh_ctx.c
index 995bfa6..0b4795d 100644
--- a/mh/mh_ctx.c
+++ b/mh/mh_ctx.c
@@ -145,17 +145,16 @@ mh_context_write (mh_context_t *ctx)
 		ctx->name, strerror (errno));
       return MU_ERR_FAILURE;
     }
-  
-  mu_header_get_stream (ctx->header, &stream);
 
-  mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
+  /* FIXME: Use mu_stream+copy */
+  mu_header_get_streamref (ctx->header, &stream);
   while (mu_stream_read (stream, buffer, sizeof buffer - 1, &n) == 0
 	 && n != 0)
     {
       buffer[n] = '\0';
       fprintf (fp, "%s", buffer);
     }
-
+  mu_stream_destroy (&stream);
   fclose (fp);
   return 0;
 }
diff --git a/mh/mh_format.c b/mh/mh_format.c
index 95d677b..7d548c0 100644
--- a/mh/mh_format.c
+++ b/mh/mh_format.c
@@ -609,8 +609,10 @@ mh_format (mh_format_t *fmt, mu_message_t msg, size_t msgno,
 	    strobj_free (&mach.arg_str);
 	    mu_message_get_body (mach.message, &body);
 	    mu_body_size (body, &size);
-	    mu_body_get_stream (body, &stream);
-	    if (size == 0 || !stream)
+	    if (size == 0)
+	      break;
+	    mu_body_get_streamref (body, &stream);
+	    if (!stream)
 	      break;
 	    if (size > rest)
 	      size = rest;
@@ -619,7 +621,6 @@ mh_format (mh_format_t *fmt, mu_message_t msg, size_t msgno,
 	    mach.arg_str.size = size;
 	    
 	    str_off = 0;
-	    mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
 	    while (!mu_stream_read (stream, mach.arg_str.ptr + str_off,
 				    mach.arg_str.size - str_off, &nread)
 		   && nread != 0
@@ -629,6 +630,7 @@ mh_format (mh_format_t *fmt, mu_message_t msg, size_t msgno,
 		if (nread)
 		  str_off += nread;
 	      }
+	    mu_stream_destroy (&stream);
 	    mach.arg_str.ptr[str_off] = 0;
 	  }
 	  break;
diff --git a/mh/mh_list.c b/mh/mh_list.c
index 94743b9..026308e 100644
--- a/mh/mh_list.c
+++ b/mh/mh_list.c
@@ -687,7 +687,7 @@ eval_body (struct eval_env *env)
   env->prefix = env->svar[S_COMPONENT];
 
   mu_message_get_body (env->msg, &body);
-  mu_body_get_stream (body, &input);
+  mu_body_get_streamref (body, &input);
 
   if (env->bvar[B_DECODE])
     {
@@ -707,15 +707,13 @@ eval_body (struct eval_env *env)
 	}
     }
   
-  mu_stream_seek (input, 0, SEEK_SET, NULL);
   while (mu_stream_readline (input, buf, sizeof buf, &n) == 0
 	 && n > 0)
     {
       buf[n] = 0;
       print (env, buf, 0);
     }
-  if (dstr)
-    mu_stream_destroy (&dstr);
+  mu_stream_destroy (&input);
   return 0;
 }
 
diff --git a/mh/mhn.c b/mh/mhn.c
index 6204050..0824134 100644
--- a/mh/mhn.c
+++ b/mh/mhn.c
@@ -961,6 +961,7 @@ _free_env (char **env)
   free (env);
 }
 
+/* FIXME: Use mimehdr.c functions instead */
 int
 get_extbody_params (mu_message_t msg, char **content, char **descr)
 {
@@ -971,8 +972,7 @@ get_extbody_params (mu_message_t msg, char **content, char **descr)
   size_t n;
 	
   mu_message_get_body (msg, &body);
-  mu_body_get_stream (body, &stream);
-  mu_stream_seek (stream, 0, SEEK_SET, NULL);
+  mu_body_get_streamref (body, &stream);
 
   while (rc == 0
 	 && mu_stream_readline (stream, buf, sizeof buf, &n) == 0
@@ -1005,6 +1005,7 @@ get_extbody_params (mu_message_t msg, char **content, char **descr)
 	  *content = strdup (p);
 	}
     }
+  mu_stream_destroy (&stream);
   return 0;
 }
 
@@ -1112,7 +1113,7 @@ mhn_message_size (mu_message_t msg, size_t *psize)
     {
       mu_stream_t dstr = NULL, bstr = NULL;
 
-      if (mu_body_get_stream (body, &bstr) == 0)
+      if (mu_body_get_streamref (body, &bstr) == 0)
 	{
 	  mu_header_t hdr;
 	  char *encoding;
@@ -1131,7 +1132,6 @@ mhn_message_size (mu_message_t msg, size_t *psize)
 	      char buf[512];
 	      size_t n;
 
-	      mu_stream_seek (dstr, 0, MU_SEEK_SET, NULL);
 	      while (mu_stream_read (dstr, buf, sizeof buf, &n) == 0
 		     && n > 0)
 		size += n;
@@ -1140,6 +1140,7 @@ mhn_message_size (mu_message_t msg, size_t *psize)
 	      *psize = size;
 	      return 0;
 	    }
+	  mu_stream_destroy (&bstr);
 	}
     }
 
@@ -1245,20 +1246,6 @@ mhn_list ()
 
 static mu_list_t mhl_format;
 
-void
-cat_message (mu_stream_t out, mu_stream_t in)
-{
-  int rc = 0;
-  char buf[512];
-  size_t n;
-
-  mu_stream_seek (in, 0, SEEK_SET, NULL);
-  while (rc == 0
-	 && mu_stream_read (in, buf, sizeof buf, &n) == 0
-	 && n > 0)
-    rc = mu_stream_write (out, buf, n, NULL);
-}
-
 int
 show_internal (mu_message_t msg, msg_part_t part, char *encoding, mu_stream_t out)
 {
@@ -1273,15 +1260,14 @@ show_internal (mu_message_t msg, msg_part_t part, char *encoding, mu_stream_t ou
 		mu_strerror (rc));
       return 0;
     }
-  mu_body_get_stream (body, &bstr);
+  mu_body_get_streamref (body, &bstr);
   rc = mu_filter_create (&dstr, bstr, encoding,
 		         MU_FILTER_DECODE, MU_STREAM_READ | MU_STREAM_NO_CLOSE);
   if (rc == 0)
     bstr = dstr;
-  cat_message (out, bstr);
-  if (dstr)
-    mu_stream_destroy (&dstr);
-  return 0;
+  rc = mu_stream_copy (out, bstr, 0);
+  mu_stream_destroy (&bstr);
+  return rc;
 }
   
 int
@@ -1964,14 +1950,15 @@ copy_header_to_stream (mu_message_t msg, mu_stream_t stream)
   size_t bufsize = 0, n = 0;
   
   mu_message_get_header (msg, &hdr);
-  mu_header_get_stream (hdr, &in);
-  mu_stream_seek (in, 0, SEEK_SET, NULL);
+  mu_header_get_streamref (hdr, &in);
+  /* FIXME: Use mu_stream_copy */
   while (mu_stream_getline (in, &buf, &bufsize, &n) == 0 && n > 0)
     {
       if (n == 1 && buf[0] == '\n')
 	break;
       mu_stream_write (stream, buf, n, NULL);
     }
+  mu_stream_destroy (&in);
   free (buf);
 }
 
@@ -2009,29 +1996,29 @@ finish_text_msg (struct compose_env *env, mu_message_t *msg, int ascii)
       
       mu_message_create (&newmsg, NULL);
       mu_message_get_header (newmsg, &hdr);
-      mu_header_get_stream (hdr, &output);
       copy_header (*msg, hdr);
       mu_header_set_value (hdr, MU_HEADER_CONTENT_TRANSFER_ENCODING,
 			   "quoted-printable", 0);
       
       mu_message_get_body (newmsg, &body);
-      mu_body_get_stream (body, &output);
-      mu_stream_seek (output, 0, SEEK_SET, NULL);
+      mu_body_get_streamref (body, &output);
 
       mu_message_get_body (*msg, &body);
-      mu_body_get_stream (body, &input);
+      mu_body_get_streamref (body, &input);
       rc = mu_filter_create (&fstr, input, "quoted-printable",
 			     MU_FILTER_ENCODE, 
 			     MU_STREAM_READ | MU_STREAM_NO_CLOSE);
       if (rc == 0)
 	{
-	  cat_message (output, fstr);
+	  mu_stream_copy (output, fstr, 0);
 	  mu_stream_destroy (&fstr);
 	  mu_message_unref (*msg);
 	  *msg = newmsg;
 	}
       else
 	mu_message_destroy (&newmsg, NULL);
+      mu_stream_destroy (&input);
+      mu_stream_destroy (&output);
     }
   finish_msg (env, msg);
 }
@@ -2075,18 +2062,19 @@ edit_extern (char *cmd, struct compose_env *env, mu_message_t *msg, int level)
     return 1;
 
   mu_message_get_body (*msg, &body);
-  mu_body_get_stream (body, &out);
-  mu_stream_seek (out, 0, SEEK_SET, NULL);
+  mu_body_get_streamref (body, &out);
 
   if (!id)
     id = mh_create_message_id (env->subpart);
   mu_header_set_value (hdr2, MU_HEADER_CONTENT_ID, id, 1);
   free (id);
 
-  mu_header_get_stream (hdr2, &in);
-  mu_stream_seek (in, 0, SEEK_SET, NULL);
-  cat_message (out, in);
+  mu_header_get_streamref (hdr2, &in);
+  mu_stream_copy (out, in, 0);
+  mu_stream_destroy (&in);
   mu_stream_close (out);
+  mu_stream_destroy (&out);
+  
   mu_header_destroy (&hdr2);
 
   finish_msg (env, msg);
@@ -2311,11 +2299,11 @@ edit_mime (char *cmd, struct compose_env *env, mu_message_t *msg, int level)
     }
   
   mu_message_get_body (*msg, &body);
-  mu_body_get_stream (body, &out);
-  cat_message (out, fstr);
+  mu_body_get_streamref (body, &out);
+  mu_stream_copy (out, fstr, 0);
 
   mu_stream_close (out);
-  
+  mu_stream_destroy (&out);
   mu_stream_destroy (&fstr);
   finish_msg (env, msg);
   return rc;
@@ -2338,7 +2326,7 @@ mhn_edit (struct compose_env *env, int level)
   char *buf = NULL;
   size_t bufsize = 0, n;
   mu_body_t body;
-  mu_stream_t output;
+  mu_stream_t output = NULL;
   mu_message_t msg = NULL;
   size_t line_count = 0;
   int ascii_buf;
@@ -2350,12 +2338,15 @@ mhn_edit (struct compose_env *env, int level)
       if (!msg)
 	{
 	  mu_header_t hdr;
+
+	  /* Destroy old stream */
+	  mu_stream_destroy (&output);
+	  
 	  /* Create new message */
 	  mu_message_create (&msg, NULL);
 	  mu_message_get_header (msg, &hdr);
 	  mu_message_get_body (msg, &body);
-	  mu_body_get_stream (body, &output);
-	  mu_stream_seek (output, 0, SEEK_SET, NULL);
+	  mu_body_get_streamref (body, &output);
 	  line_count = 0;
 	  ascii_buf = 1; /* Suppose it is ascii */
 	  env->subpart++;
@@ -2390,6 +2381,8 @@ mhn_edit (struct compose_env *env, int level)
 	      free (b2);
 
 	      mu_stream_close (output);
+	      mu_stream_destroy (&output);
+	      
 	      if (line_count)
 		/* Close and append the previous part */
 		finish_text_msg (env, &msg, ascii_buf);
@@ -2472,6 +2465,7 @@ mhn_edit (struct compose_env *env, int level)
       else
 	mu_message_unref (msg);
     }
+  mu_stream_destroy (&output);
   
   return status;
 }
@@ -2620,14 +2614,14 @@ mhn_compose ()
   mu_mime_create (&mime, NULL, 0);
 
   mu_message_get_body (message, &body);
-  mu_body_get_stream (body, &stream);
-  mu_stream_seek (stream, 0, SEEK_SET, NULL);
+  mu_body_get_streamref (body, &stream);
 
   env.mime = mime;
   env.input = stream;
   env.subpart = 0;
   env.line = 0;
   rc = mhn_edit (&env, 0);
+  mu_stream_destroy (&stream);
   if (rc)
     return rc;
 
@@ -2670,10 +2664,11 @@ mhn_compose ()
 
   mhn_header (message, msg);
   copy_header_to_stream (message, stream);
-  mu_message_get_stream (msg, &in);
-  cat_message (stream, in);
+  mu_message_get_streamref (msg, &in);
+  mu_stream_copy (stream, in, 0);
+  mu_stream_destroy (&in);
   mu_stream_destroy (&stream);
-
+  
   /* Preserve the backup copy and replace the draft */
   unlink (backup);
   rename (input_file, backup);
diff --git a/mh/pick.y b/mh/pick.y
index 152b7a5..64248ec 100644
--- a/mh/pick.y
+++ b/mh/pick.y
@@ -324,8 +324,7 @@ match_message (mu_message_t msg, regex_t *regex)
   char buf[128];
   size_t n;
   
-  mu_message_get_stream (msg, &str);
-  mu_stream_seek (str, 0, SEEK_SET, NULL);
+  mu_message_get_streamref (msg, &str);
   while (mu_stream_readline (str, buf, sizeof buf, &n) == 0
 	 && n > 0)
     {
@@ -333,6 +332,7 @@ match_message (mu_message_t msg, regex_t *regex)
       if (regexec (regex, buf, 0, NULL, 0) == 0)
 	return 1;
     }
+  mu_stream_destroy (&str);
   return 0;
 }
 
diff --git a/pop3d/retr.c b/pop3d/retr.c
index 137d53d..8d3030d 100644
--- a/pop3d/retr.c
+++ b/pop3d/retr.c
@@ -44,6 +44,7 @@ pop3d_retr (char *arg)
   if (pop3d_is_deleted (attr))
     return ERR_MESG_DELE;
 
+  /* FIXME: Use crlf filter + mu_stream_copy instead of the loop below */
   mu_message_get_stream (msg, &stream);
   pop3d_outf ("+OK\r\n");
 
diff --git a/pop3d/top.c b/pop3d/top.c
index d9d8614..0506a64 100644
--- a/pop3d/top.c
+++ b/pop3d/top.c
@@ -59,6 +59,7 @@ pop3d_top (char *arg)
 
   /* Header.  */
   mu_message_get_header (msg, &hdr);
+  /* FIXME: Use crlf filter + mu_stream_copy instead of the below loop */
   mu_header_get_stream (hdr, &stream);
   n = 0;
   while (mu_stream_readline (stream, buf, sizeof(buf), &n) == 0
@@ -80,6 +81,7 @@ pop3d_top (char *arg)
       int prev_nl = 1;
 
       mu_message_get_body (msg, &body);
+      /* FIXME: Use the crlf filter + mu_stream_copy */
       mu_body_get_stream (body, &stream);
       n = 0;
       while (mu_stream_readline (stream, buf, sizeof(buf), &n) == 0
diff --git a/readmsg/msglist.c b/readmsg/msglist.c
index 481993b..fb4ff99 100644
--- a/readmsg/msglist.c
+++ b/readmsg/msglist.c
@@ -124,8 +124,7 @@ msglist (mu_mailbox_t mbox, int show_all, int argc, char **argv,
 	      mu_stream_t stream = NULL;
 
 	      mu_mailbox_get_message (mbox, j, &msg);
-	      mu_message_get_stream (msg, &stream);
-	      mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
+	      mu_message_get_streamref (msg, &stream);
 	      while (mu_stream_readline (stream, buf, sizeof buf, &len) == 0
 		     && len > 0)
 		{
diff --git a/readmsg/readmsg.c b/readmsg/readmsg.c
index 0f2a0ed..0ea377e 100644
--- a/readmsg/readmsg.c
+++ b/readmsg/readmsg.c
@@ -211,14 +211,15 @@ print_header (mu_message_t message, int unix_header, int weedc, char **weedv)
       size_t len = 0;
       char buf[128];
 
-      mu_header_get_stream (header, &stream);
-      mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
+      /* FIXME: Use mu_stream_copy */
+      mu_header_get_streamref (header, &stream);
       while (mu_stream_read (stream, buf, sizeof (buf) - 1, &len) == 0
 	     && len != 0)
 	{
 	  buf[len] = '\0';
 	  printf ("%s", buf);
 	}
+      mu_stream_destroy (&stream);
     }
   else
     {
@@ -264,7 +265,9 @@ print_body (mu_message_t message)
   mu_stream_t stream = NULL;
   size_t len = 0;
   mu_message_get_body (message, &body);
-  mu_body_get_stream (body, &stream);
+
+  /* FIXME: Use mu_stream_copy */
+  mu_body_get_streamref (body, &stream);
 
   while (mu_stream_read (stream, buf, sizeof (buf) - 1, &len) == 0
 	 && len != 0)
@@ -272,6 +275,7 @@ print_body (mu_message_t message)
       buf[len] = '\0';
       printf ("%s", buf);
     }
+  mu_stream_destroy (&stream);
 }
 
 int


hooks/post-receive
-- 
GNU Mailutils
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.