X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/2b83f27e1980a6c5de752bd55c0ff76f53ec15f6..394a751fd883d2bbfc769fed7e254e008a2ef45e:/uip/rmf.c diff --git a/uip/rmf.c b/uip/rmf.c index 406d9a61..37e7162f 100644 --- a/uip/rmf.c +++ b/uip/rmf.c @@ -5,9 +5,27 @@ * complete copyright information. */ -#include +#include "h/mh.h" +#include "sbr/getarguments.h" +#include "sbr/read_yes_or_no_if_tty.h" +#include "sbr/concat.h" +#include "sbr/smatch.h" +#include "sbr/remdir.h" +#include "sbr/ssequal.h" +#include "sbr/m_atoi.h" +#include "sbr/getfolder.h" +#include "sbr/ext_hook.h" +#include "sbr/context_save.h" +#include "sbr/context_replace.h" +#include "sbr/context_del.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/error.h" #include "h/done.h" -#include +#include "h/utils.h" #include "sbr/m_maildir.h" #include "sbr/m_mktemp.h" @@ -35,12 +53,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; @@ -52,7 +71,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]", @@ -73,10 +92,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); } } @@ -84,11 +103,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) @@ -127,7 +146,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]; @@ -154,8 +174,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. @@ -183,12 +203,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; } } @@ -203,7 +223,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);