X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/0509728c8a506f287fa3483d8e8ffaf8fb66d41d..0b7286788a95dd854d1826b8493eda431d8e8aac:/uip/flist.c diff --git a/uip/flist.c b/uip/flist.c index 65ddf458..28592791 100644 --- a/uip/flist.c +++ b/uip/flist.c @@ -13,9 +13,22 @@ * any specification. */ -#include -#include -#include "../sbr/m_maildir.h" +#include "h/mh.h" +#include "sbr/folder_read.h" +#include "sbr/folder_free.h" +#include "sbr/context_save.h" +#include "sbr/context_replace.h" +#include "sbr/context_find.h" +#include "sbr/brkstring.h" +#include "sbr/ambigsw.h" +#include "sbr/path.h" +#include "sbr/print_version.h" +#include "sbr/print_help.h" +#include "sbr/seq_getnum.h" +#include "sbr/error.h" +#include "h/utils.h" +#include "h/done.h" +#include "sbr/m_maildir.h" /* * We allocate space to record the names of folders @@ -73,11 +86,11 @@ static int maxfolders; /* info on sequences to search for */ static svector_t sequencesToDo; -static int all = FALSE; /* scan all folders in top level? */ -static int alphaOrder = FALSE; /* want alphabetical order only */ -static int recurse = FALSE; /* show nested folders? */ -static int showzero = TRUE; /* show folders even if no messages in seq? */ -static int Total = TRUE; /* display info on number of messages in * +static bool all; /* scan all folders in top level? */ +static bool alphaOrder; /* want alphabetical order only */ +static bool recurse; /* show nested folders? */ +static bool showzero = true; /* show folders even if no messages in seq? */ +static bool Total = true; /* display info on number of messages in * sequence found, and total num messages */ static char curfolder[BUFSIZ]; /* name of the current folder */ @@ -112,7 +125,7 @@ main(int argc, char **argv) char **arguments; char buf[BUFSIZ]; - if (nmh_init(argv[0], 1)) { return 1; } + if (nmh_init(argv[0], true, true)) { return 1; } /* * If program was invoked with name ending @@ -126,7 +139,7 @@ main(int argc, char **argv) /* allocate the initial space to record the folder names */ numfolders = 0; maxfolders = MAXFOLDERS; - foldersToDo = (char **) mh_xmalloc ((size_t) (maxfolders * sizeof(*foldersToDo))); + foldersToDo = mh_xmalloc ((size_t) (maxfolders * sizeof(*foldersToDo))); /* no sequences yet */ sequencesToDo = svector_create (0); @@ -139,7 +152,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 [+folder1 [+folder2 ...]][switches]", @@ -152,47 +165,47 @@ main(int argc, char **argv) case SEQSW: if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + die("missing argument to %s", argp[-2]); svector_push_back (sequencesToDo, cp); break; case ALLSW: - all = TRUE; + all = true; break; case NOALLSW: - all = FALSE; + all = false; break; case SHOWZERO: - showzero = TRUE; + showzero = true; break; case NOSHOWZERO: - showzero = FALSE; + showzero = false; break; case ALPHASW: - alphaOrder = TRUE; + alphaOrder = true; break; case NOALPHASW: - alphaOrder = FALSE; + alphaOrder = false; break; case NOFASTSW: case TOTALSW: - Total = TRUE; + Total = true; break; case FASTSW: case NOTOTALSW: - Total = FALSE; + Total = false; break; case RECURSE: - recurse = TRUE; + recurse = true; break; case NORECURSE: - recurse = FALSE; + recurse = false; break; } } else { @@ -202,7 +215,7 @@ main(int argc, char **argv) */ if (numfolders >= maxfolders) { maxfolders += MAXFOLDERS; - foldersToDo = (char **) mh_xrealloc (foldersToDo, + foldersToDo = mh_xrealloc (foldersToDo, (size_t) (maxfolders * sizeof(*foldersToDo))); } if (*cp == '+' || *cp == '@') { @@ -236,7 +249,7 @@ main(int argc, char **argv) for (; ap && *ap; ap++) svector_push_back (sequencesToDo, *ap); } else { - adios (NULL, "no sequence specified or %s profile entry found", usequence); + die("no sequence specified or %s profile entry found", usequence); } } @@ -274,7 +287,7 @@ GetFolderOrder(void) AllocFolders(&orders, &nOrdersAlloced, nOrders + 1); o = &orders[nOrders++]; o->priority = priority++; - o->name = (char *) mh_xmalloc(p - s + 1); + o->name = mh_xmalloc(p - s + 1); strncpy(o->name, s, p - s); o->name[p - s] = 0; } else @@ -410,7 +423,7 @@ BuildFolderListRecurse(char *dirName, struct stat *s, int searchdepth) /* Check to see if the name of the file is a number * if it is, we assume it's a mail file and skip it */ - for (n = dp->d_name; *n && isdigit((unsigned char) *n); n++); + for (n = dp->d_name; isdigit((unsigned char)*n); n++); if (!*n) continue; strncpy (name, base, sizeof(name) - 2); @@ -442,7 +455,8 @@ static int AddFolder(char *name, int force) { unsigned int i; - int msgnum, nonzero; + int msgnum; + bool nonzero; ivector_t seqnum = ivector_create (0), nSeq = ivector_create (0); struct Folder *f; struct msgs *mp; @@ -477,10 +491,10 @@ AddFolder(char *name, int force) } /* Check if any of the sequence checks were nonzero */ - nonzero = 0; + nonzero = false; for (i = 0; i < svector_size (sequencesToDo); i++) { if (ivector_at (nSeq, i) > 0) { - nonzero = 1; + nonzero = true; break; } } @@ -520,7 +534,8 @@ static void PrintFolders(void) { char tmpname[BUFSIZ]; - unsigned int i, j, len, has_private = 0; + unsigned int i, j, len; + bool has_private = false; unsigned int maxfolderlen = 0, maxseqlen = 0; int maxnum = 0, maxseq = 0; @@ -560,7 +575,7 @@ PrintFolders(void) /* check if this sequence is private in any of the folders */ if (ivector_at (folders[i].private, j)) - has_private = 1; + has_private = true; } } @@ -614,10 +629,10 @@ AllocFolders(struct Folder **f, int *nfa, int n) return; if (*f == NULL) { *nfa = 10; - *f = (struct Folder *) mh_xmalloc (*nfa * (sizeof(struct Folder))); + *f = mh_xmalloc (*nfa * (sizeof(struct Folder))); } else { *nfa *= 2; - *f = (struct Folder *) mh_xrealloc (*f, *nfa * (sizeof(struct Folder))); + *f = mh_xrealloc (*f, *nfa * (sizeof(struct Folder))); } }