X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/dbdbd49d59ae5c14e66b1c148a63b8abc9d076ab..4829d096feb337a55e2b866adb19acab9617b071:/uip/show.c diff --git a/uip/show.c b/uip/show.c index 25ede029..7aedb5f6 100644 --- a/uip/show.c +++ b/uip/show.c @@ -5,10 +5,37 @@ * complete copyright information. */ -#include -#include +#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/done.h" -#include +#include "h/utils.h" #include "sbr/m_maildir.h" #define SHOW_SWITCHES \ @@ -66,12 +93,14 @@ static int is_nontext(char *); int main (int argc, char **argv) { - int draftsw = 0, headersw = 1; - int nshow = 0, checkmime = 1, mime = 0; + bool draftsw = false; + bool headersw = true; + bool nshow = false; + 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 }; @@ -93,10 +122,10 @@ main (int argc, char **argv) done (1); case HEADSW: - headersw = 1; + headersw = true; goto non_mhl_switches; case NHEADSW: - headersw = 0; + headersw = false; /* FALLTHRU */ case CONCATSW: case NCONCATSW: @@ -124,7 +153,7 @@ non_mhl_switches: case DRFTSW: if (file) die("only one file at a time!"); - draftsw++; + draftsw = true; if (mode == SHOW) continue; usage: @@ -166,22 +195,22 @@ usage: case SHOWSW: if (!(showproc = *argp++) || *showproc == '-') die("missing argument to %s", argp[-2]); - nshow = 0; + nshow = false; continue; case NSHOWSW: - nshow++; + nshow = true; continue; case SHOWMIMESW: if (!(showmimeproc = *argp++) || *showmimeproc == '-') die("missing argument to %s", argp[-2]); - nshow = 0; + nshow = false; continue; case CHECKMIMESW: - checkmime++; + checkmime = true; continue; case NOCHECKMIMESW: - checkmime = 0; + checkmime = false; continue; } } @@ -206,7 +235,7 @@ usage: app_msgarg(&vec, mh_xstrdup(m_draft(folder, NULL, 1, &isdf))); else app_msgarg(&vec, file); - headersw = 0; + headersw = false; goto go_to_it; } @@ -226,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 */ @@ -279,13 +282,13 @@ go_to_it: ; /* loop through selected messages and check for MIME */ for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) if (is_selected (mp, msgnum) && is_nontext (m_name (msgnum))) { - mime = 1; + mime = true; break; } } else { /* check the file or draft for MIME */ if (is_nontext (vec.msgs[vec.size - 1])) - mime = 1; + mime = true; } }