dprint (1, (debugfile, "mh_sync_message: %s: %s (errno %d).\n", newpath, strerror (errno), errno)); return (-1);
snprintf (oldpath, _POSIX_PATH_MAX, "%s/%s", ctx->path, h->path); strfcpy  (partpath, h->path, _POSIX_PATH_MAX);  if (ctx->magic == M_MAILDIR) rc = maildir_commit_message (ctx, dest, h); else rc = mh_commit_message (ctx, dest, h); if (rc == 0) unlink (oldpath);    if (ctx->magic == M_MH && rc == 0) { snprintf (newpath, _POSIX_PATH_MAX, "%s/%s", ctx->path, h->path); if (safe_rename (newpath, oldpath) == 0) { FREE (&h->path); h->path = safe_strdup (partpath); } }
static int mh_sync_message (CONTEXT *ctx, int msgno){  HEADER *h = ctx->hdrs[msgno];  FILE *f;  FILE *d;  int rc = -1;  char oldpath[_POSIX_PATH_MAX];  char newpath[_POSIX_PATH_MAX];    snprintf (oldpath, sizeof (oldpath), "%s/%s", ctx->path, h->path);    mutt_mktemp (newpath);  if ((f = safe_fopen (newpath, "w")) == NULL)  {    dprint (1, (debugfile, "mh_sync_message: %s: %s (errno %d).\n",		newpath, strerror (errno), errno));    return (-1);  }  rc = mutt_copy_message (f, ctx, h, M_CM_UPDATE, CH_UPDATE | CH_UPDATE_LEN);  if (rc == 0)  {    /* replace the original version of the message with the new one */    if ((f = freopen (newpath, "r", f)) != NULL)    {      unlink (newpath);      unlink (oldpath);      if ((d = mx_open_file_lock (oldpath, "w")) != NULL)      {	mutt_copy_stream (f, d);	mx_unlock_file (oldpath, fileno (d));	fclose (d);      }      else      {	/* mutt_copy_message() will have changed	 * some of the internal state of the message,	 * but we can't commit it here.	 * 	 * Reparse later.	 *	 */	mutt_free_body (&h->content->parts);	fclose (f);	return (-1);      }      fclose (f);    }    else    {      mutt_perror (newpath);      return (-1);    }    /*     * if the status of this message changed, the offsets for the body parts     * will be wrong, so free up the memory.  This is ok since it will get     * parsed again the next time the user tries to view it.     */    mutt_free_body (&h->content->parts);  }  else  {    fclose (f);    unlink (newpath);  }  return (rc);}