X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/0509728c8a506f287fa3483d8e8ffaf8fb66d41d..04ee0c3f6ad7e4177cc43a0c57f046013a4fbac9:/uip/dist.c diff --git a/uip/dist.c b/uip/dist.c index 19158bad..294e4f24 100644 --- a/uip/dist.c +++ b/uip/dist.c @@ -5,10 +5,16 @@ * complete copyright information. */ -#include -#include -#include "../sbr/m_maildir.h" +#include "h/mh.h" +#include "sbr/path.h" +#include "sbr/print_version.h" +#include "sbr/print_help.h" +#include "sbr/error.h" +#include "h/utils.h" +#include "sbr/m_maildir.h" #include +#include "h/done.h" +#include "forwsbr.h" #define DIST_SWITCHES \ X("annotate", 0, ANNOSW) \ @@ -70,10 +76,14 @@ static struct swit aqrl[] = { int main (int argc, char **argv) { - int anot = 0, inplace = 1, nedit = 0; - int nwhat = 0, i, in, isdf = 0, out; + bool anot = false; + bool inplace = true; + bool nedit = false; + bool nwhat = false; + int i, in, isdf = 0, out; int outputlinelen = OUTPUTLINELEN; - int dat[5], atfile = 0; + int dat[5]; + bool atfile = false; char *cp, *cwd, *maildir, *msgnam, *dfolder = NULL; char *dmsg = NULL, *ed = NULL, *file = NULL, *folder = NULL; char *form = NULL, *msg = NULL, buf[BUFSIZ], drft[BUFSIZ]; @@ -82,7 +92,7 @@ main (int argc, char **argv) struct msgs *mp = NULL; struct stat st; - if (nmh_init(argv[0], 1)) { return 1; } + if (nmh_init(argv[0], true, true)) { return 1; } arguments = getarguments (invo_name, argc, argv, 1); argp = arguments; @@ -94,7 +104,7 @@ main (int argc, char **argv) ambigsw (cp, switches); done (1); case UNKWNSW: - adios (NULL, "-%s unknown", cp); + die("-%s unknown", cp); case HELPSW: snprintf (buf, sizeof(buf), "%s [+folder] [msg] [switches]", @@ -106,62 +116,62 @@ main (int argc, char **argv) done (0); case ANNOSW: - anot++; + anot = true; continue; case NANNOSW: - anot = 0; + anot = false; continue; case EDITRSW: if (!(ed = *argp++) || *ed == '-') - adios (NULL, "missing argument to %s", argp[-2]); - nedit = 0; + die("missing argument to %s", argp[-2]); + nedit = false; continue; case NEDITSW: - nedit++; + nedit = true; continue; case WHATSW: if (!(whatnowproc = *argp++) || *whatnowproc == '-') - adios (NULL, "missing argument to %s", argp[-2]); - nwhat = 0; + die("missing argument to %s", argp[-2]); + nwhat = false; continue; case NWHATSW: - nwhat++; + nwhat = true; continue; case FILESW: if (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: if (!(form = *argp++) || *form == '-') - adios (NULL, "missing argument to %s", argp[-2]); + die("missing argument to %s", argp[-2]); continue; case INPLSW: - inplace++; + inplace = true; continue; case NINPLSW: - inplace = 0; + inplace = false; continue; case DFOLDSW: if (dfolder) - adios (NULL, "only one draft folder at a time!"); + die("only one draft folder at a time!"); if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + die("missing argument to %s", argp[-2]); dfolder = path (*cp == '+' || *cp == '@' ? cp + 1 : cp, *cp != '@' ? TFOLDER : TSUBCWF); continue; case DMSGSW: if (dmsg) - adios (NULL, "only one draft message at a time!"); + die("only one draft message at a time!"); if (!(dmsg = *argp++) || *dmsg == '-') - adios (NULL, "missing argument to %s", argp[-2]); + die("missing argument to %s", argp[-2]); continue; case NDFLDSW: dfolder = NULL; @@ -170,50 +180,48 @@ main (int argc, char **argv) case FROMSW: if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + die("missing argument to %s", argp[-2]); from = addlist(from, cp); continue; case TOSW: if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + die("missing argument to %s", argp[-2]); to = addlist(to, cp); continue; case CCSW: if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + die("missing argument to %s", argp[-2]); cc = addlist(cc, cp); continue; case FCCSW: if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + die("missing argument to %s", argp[-2]); fcc = addlist(fcc, cp); continue; case WIDTHSW: if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + die("missing argument to %s", argp[-2]); if ((outputlinelen = atoi(cp)) < 10) - adios (NULL, "impossible width %d", outputlinelen); + die("impossible width %d", outputlinelen); continue; case ATFILESW: - atfile++; + atfile = true; continue; case NOATFILESW: - atfile = 0; + atfile = false; continue; } } if (*cp == '+' || *cp == '@') { if (folder) - adios (NULL, "only one folder at a time!"); - else - folder = pluspath (cp); + die("only one folder at a time!"); + folder = pluspath (cp); } else { if (msg) - adios (NULL, "only one message at a time!"); - else - msg = cp; + die("only one message at a time!"); + msg = cp; } } @@ -222,7 +230,7 @@ main (int argc, char **argv) if (!context_find ("path")) free (path ("./", TFOLDER)); if (file && (msg || folder)) - adios (NULL, "can't mix files and folders/msgs"); + die("can't mix files and folders/msgs"); try_it_again: strncpy (drft, m_draft (dfolder, dmsg, NOUSE, &isdf), sizeof(drft)); @@ -260,7 +268,7 @@ try_it_again: /* * Dist a file */ - anot = 0; /* don't want to annotate a file */ + anot = false; /* don't want to annotate a file */ } else { /* * Dist a message @@ -276,11 +284,11 @@ try_it_again: /* 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 the message range/sequence/name and set SELECTED */ if (!m_convert (mp, msg)) @@ -288,7 +296,7 @@ try_it_again: seq_setprev (mp); /* set the previous-sequence */ if (mp->numsel > 1) - adios (NULL, "only one message at a time!"); + die("only one message at a time!"); } msgnam = file ? file : mh_xstrdup(m_name (mp->lowsel));