X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/8a5a1a5303ddc67f06350a57a515853724a16e31..ec173fd2c:/uip/show.c?ds=inline diff --git a/uip/show.c b/uip/show.c index 55707da4..699b77b0 100644 --- a/uip/show.c +++ b/uip/show.c @@ -5,10 +5,36 @@ * complete copyright information. */ -#include -#include -#include -#include "../sbr/m_maildir.h" +#include "h/mh.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 "h/utils.h" +#include "sbr/m_maildir.h" #define SHOW_SWITCHES \ X("checkmime", 0, CHECKMIMESW) \ @@ -65,8 +91,11 @@ 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 buf[BUFSIZ], **argp, **arguments; @@ -74,7 +103,7 @@ main (int argc, char **argv) struct msgs_array msgs = { 0, 0, NULL }; struct msgs_array vec = { 0, 0, NULL }, non_mhl_vec = { 0, 0, NULL }; - if (nmh_init(argv[0], 1)) { return 1; } + if (nmh_init(argv[0], true, true)) { return 1; } if (!strcasecmp (invo_name, "next")) { mode = NEXT; @@ -92,10 +121,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: @@ -122,29 +151,28 @@ non_mhl_switches: case DRFTSW: if (file) - adios (NULL, "only one file at a time!"); - draftsw++; + die("only one file at a time!"); + draftsw = true; if (mode == SHOW) continue; usage: - adios (NULL, - "usage: %s [+folder] [switches] [switches for showproc]", + die( "usage: %s [+folder] [switches] [switches for showproc]", invo_name); case FILESW: if (mode != SHOW) goto usage; if (draftsw || file) - adios (NULL, "only one file at a time!"); + die("only one file at a time!"); if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + die("missing argument to %s", argp[-2]); file = path (cp, TFILE); continue; case FORMSW: app_msgarg(&vec, --cp); if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); - app_msgarg(&vec, getcpy (etcpath(cp))); + die("missing argument to %s", argp[-2]); + app_msgarg(&vec, mh_xstrdup(etcpath(cp))); continue; case PROGSW: @@ -159,35 +187,35 @@ usage: case WCACHESW: app_msgarg(&vec, --cp); if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + die("missing argument to %s", argp[-2]); app_msgarg(&vec, cp); continue; case SHOWSW: if (!(showproc = *argp++) || *showproc == '-') - adios (NULL, "missing argument to %s", argp[-2]); - nshow = 0; + die("missing argument to %s", argp[-2]); + nshow = false; continue; case NSHOWSW: - nshow++; + nshow = true; continue; case SHOWMIMESW: if (!(showmimeproc = *argp++) || *showmimeproc == '-') - adios (NULL, "missing argument to %s", argp[-2]); - nshow = 0; + die("missing argument to %s", argp[-2]); + nshow = false; continue; case CHECKMIMESW: - checkmime++; + checkmime = true; continue; case NOCHECKMIMESW: - checkmime = 0; + checkmime = false; continue; } } if (*cp == '+' || *cp == '@') { if (folder) - adios (NULL, "only one folder at a time!"); + die("only one folder at a time!"); folder = pluspath (cp); } else { if (mode != SHOW) @@ -201,12 +229,12 @@ usage: if (draftsw || file) { if (msgs.size) - adios (NULL, "only one file at a time!"); + die("only one file at a time!"); if (draftsw) - app_msgarg(&vec, getcpy (m_draft (folder, NULL, 1, &isdf))); + app_msgarg(&vec, mh_xstrdup(m_draft(folder, NULL, 1, &isdf))); else app_msgarg(&vec, file); - headersw = 0; + headersw = false; goto go_to_it; } @@ -233,11 +261,11 @@ usage: /* read folder and create message structure */ if (!(mp = folder_read (folder, 1))) - adios (NULL, "unable to read folder %s", folder); + die("unable to read folder %s", folder); /* check for empty folder */ if (mp->nummsg == 0) - adios (NULL, "no messages in %s", folder); + die("no messages in %s", folder); /* parse all the message ranges/sequences and set SELECTED */ for (msgnum = 0; msgnum < msgs.size; msgnum++) @@ -279,13 +307,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; } }