X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/31da9febde0d822d73f99089109bacc1c3e36433..a062e4ec504f324c5d5ea7907fef3a737f4d742a:/uip/rmf.c diff --git a/uip/rmf.c b/uip/rmf.c index a99b53cf..38b07a14 100644 --- a/uip/rmf.c +++ b/uip/rmf.c @@ -6,6 +6,7 @@ */ #include +#include "h/done.h" #include #include "sbr/m_maildir.h" #include "sbr/m_mktemp.h" @@ -34,12 +35,13 @@ static void rma (char *); int main (int argc, char **argv) { - int defolder = 0, interactive = -1; + bool defolder = false; + int interactive = -1; char *cp, *folder = NULL, newfolder[BUFSIZ]; char buf[BUFSIZ], **argp, **arguments; char *fp; - 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; @@ -51,7 +53,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] [switches]", @@ -72,10 +74,10 @@ main (int argc, char **argv) } if (*cp == '+' || *cp == '@') { if (folder) - adios (NULL, "only one folder at a time!"); + die("only one folder at a time!"); folder = pluspath (cp); } else { - adios (NULL, "usage: %s [+folder] [switches]", invo_name); + die("usage: %s [+folder] [switches]", invo_name); } } @@ -83,11 +85,11 @@ main (int argc, char **argv) free (path ("./", TFOLDER)); if (!folder) { folder = getfolder (1); - defolder++; + defolder = true; } fp = m_mailpath(folder); if (!strcmp(fp, pwd())) - adios (NULL, "sorry, you can't remove the current working directory"); + die("sorry, you can't remove the current working directory"); free(fp); if (interactive == -1) @@ -126,7 +128,8 @@ main (int argc, char **argv) static int rmf (char *folder) { - int i, others; + int i; + bool others; char *fp; char *maildir; char cur[BUFSIZ]; @@ -153,8 +156,8 @@ rmf (char *folder) } if ((dd = opendir (".")) == NULL) - adios (NULL, "unable to read folder +%s", folder); - others = 0; + die("unable to read folder +%s", folder); + others = false; /* * Run the external delete hook program. @@ -182,12 +185,12 @@ rmf (char *folder) inform("file \"%s/%s\" not deleted, continuing...", folder, dp->d_name); - others++; + others = true; continue; } if (m_unlink (dp->d_name) == NOTOK) { admonish (dp->d_name, "unable to unlink %s:", folder); - others++; + others = true; } } @@ -202,7 +205,7 @@ rmf (char *folder) if (chdir ("..") < 0) { advise ("..", "chdir"); } - if (others == 0 && remdir (maildir)) + if (!others && remdir (maildir)) return OK; inform("folder +%s not removed", folder);