]> diplodocus.org Git - nmh/blobdiff - uip/show.c
expect this commit to be force-replaced periodically
[nmh] / uip / show.c
index c6429acc6b77dc2824213f681c74ab61186813d5..7aedb5f6ed4779344330fb809107f13952a084fe 100644 (file)
@@ -5,11 +5,37 @@
  * complete copyright information.
  */
 
-#include <h/mh.h>
+#include "h/mh.h"
+#include "h/managed_folders.h"
+#include "h/folder.h"
+#include "mhlsbr.h"
+#include "sbr/m_name.h"
+#include "sbr/m_getfld.h"
+#include "sbr/getarguments.h"
+#include "sbr/seq_setunseen.h"
+#include "sbr/seq_setprev.h"
+#include "sbr/seq_setcur.h"
+#include "sbr/seq_save.h"
+#include "sbr/smatch.h"
+#include "sbr/r1bindex.h"
+#include "sbr/uprf.h"
+#include "sbr/check_charset.h"
+#include "sbr/m_draft.h"
+#include "sbr/m_convert.h"
+#include "sbr/getfolder.h"
+#include "sbr/folder_read.h"
+#include "sbr/context_save.h"
+#include "sbr/context_replace.h"
+#include "sbr/context_find.h"
+#include "sbr/ambigsw.h"
+#include "sbr/path.h"
+#include "sbr/print_version.h"
+#include "sbr/print_help.h"
+#include "sbr/arglist.h"
 #include "sbr/error.h"
-#include <h/mime.h>
+#include "h/mime.h"
 #include "h/done.h"
-#include <h/utils.h>
+#include "h/utils.h"
 #include "sbr/m_maildir.h"
 
 #define SHOW_SWITCHES \
@@ -73,9 +99,8 @@ main (int argc, char **argv)
     bool checkmime = true;
     bool mime = false;
     int isdf = 0, mode = SHOW, msgnum;
-    char *cp, *maildir, *file = NULL, *folder = NULL, *proc, *program;
+    char *cp, *file = NULL, *folder = NULL, *proc, *program;
     char buf[BUFSIZ], **argp, **arguments;
-    struct msgs *mp = NULL;
     struct msgs_array msgs = { 0, 0, NULL };
     struct msgs_array vec = { 0, 0, NULL }, non_mhl_vec = { 0, 0, NULL };
 
@@ -230,42 +255,16 @@ usage:
 
     if (!folder)
        folder = getfolder (1);
-    maildir = m_maildir (folder);
+    mh_managed_folders *mmfs;
+    if (!mh_managed_folders_open(&mmfs))
+        die("%s", mh_managed_folders_get_err_string(mmfs));
+    mh_folder *mhf;
+    if (!mh_folder_open(&mhf, folder, mmfs))
+        die("%s", mh_folder_get_err_string(mhf));
+    const struct msgs *const mp = mh_folder_select_and_chdir_and_mark_seen(&vec, mhf, msgs);
+    if (mp == NULL)
+        die("%s", mh_folder_get_err_string(mhf));
 
-    if (chdir (maildir) == NOTOK)
-       adios (maildir, "unable to change directory to");
-
-    /* read folder and create message structure */
-    if (!(mp = folder_read (folder, 1)))
-       die("unable to read folder %s", folder);
-
-    /* check for empty folder */
-    if (mp->nummsg == 0)
-       die("no messages in %s", folder);
-
-    /* parse all the message ranges/sequences and set SELECTED */
-    for (msgnum = 0; msgnum < msgs.size; msgnum++)
-       if (!m_convert (mp, msgs.msgs[msgnum]))
-           done (1);
-
-    /*
-     * Set the SELECT_UNSEEN bit for all the SELECTED messages,
-     * since we will use that as a tag to know which messages
-     * to remove from the "unseen" sequence.
-     */
-    for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
-       if (is_selected(mp, msgnum))
-           set_unseen (mp, msgnum);
-
-    seq_setprev (mp);          /* set the Previous-Sequence */
-    seq_setunseen (mp, 1);     /* unset the Unseen-Sequence */
-
-    for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
-       if (is_selected(mp, msgnum))
-           app_msgarg(&vec, mh_xstrdup(m_name (msgnum)));
-
-    seq_setcur (mp, mp->hghsel);       /* update current message  */
-    seq_save (mp);                     /* synchronize sequences   */
     context_replace (pfolder, folder); /* update current folder   */
     context_save ();                   /* save the context file   */