-/*
- * flist.c -- list nmh folders containing messages
+/* flist.c -- list nmh folders containing messages
* -- in a given sequence
*
* originally by
#include <h/mh.h>
#include <h/utils.h>
+#include "h/done.h"
+#include "sbr/m_maildir.h"
/*
* We allocate space to record the names of folders
/* 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 */
typedef int (*qsort_comp) (const void *, const void *);
/*
- * prototypes
+ * static prototypes
*/
-int CompareFolders(struct Folder *, struct Folder *);
-void GetFolderOrder(void);
-void ScanFolders(void);
-int AddFolder(char *, int);
-void BuildFolderList(char *, int);
-void BuildFolderListRecurse(char *, struct stat *, int);
-void PrintFolders(void);
-void AllocFolders(struct Folder **, int *, int);
-int AssignPriority(char *);
+static int CompareFolders(struct Folder *, struct Folder *);
+static void GetFolderOrder(void);
+static void ScanFolders(void);
+static int AddFolder(char *, int);
+static void BuildFolderList(char *, int);
+static void BuildFolderListRecurse(char *, struct stat *, int);
+static void PrintFolders(void);
+static void AllocFolders(struct Folder **, int *, int);
+static int AssignPriority(char *);
static void do_readonly_folders(void);
* If program was invoked with name ending
* in `s', then add switch `-all'.
*/
- all = HasSuffixC(argv[0], 's');
+ all = has_suffix_c(argv[0], 's');
arguments = getarguments (invo_name, argc, argv, 1);
argp = arguments;
/* 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);
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 {
*/
if (numfolders >= maxfolders) {
maxfolders += MAXFOLDERS;
- foldersToDo = (char **) mh_xrealloc (foldersToDo,
+ foldersToDo = mh_xrealloc (foldersToDo,
(size_t) (maxfolders * sizeof(*foldersToDo)));
}
if (*cp == '+' || *cp == '@') {
* how to sort folders for output.
*/
-void
+static void
GetFolderOrder(void)
{
char *p, *s;
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
* Scan all the necessary folders
*/
-void
+static void
ScanFolders(void)
{
int i;
* the top of our search tree.
*/
-void
+static void
BuildFolderList(char *dirName, int searchdepth)
{
struct stat st;
* Recursive building of folder list
*/
-void
+static void
BuildFolderListRecurse(char *dirName, struct stat *s, int searchdepth)
{
char *base, name[PATH_MAX];
/* 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);
* messages and the number of messages in each sequence.
*/
-int
+static int
AddFolder(char *name, int force)
{
unsigned int i;
* Print the folder/sequence information
*/
-void
+static void
PrintFolders(void)
{
char tmpname[BUFSIZ];
if (!Total) {
for (i = 0; i < nFolders; i++)
- printf("%s\n", folders[i].name);
+ puts(folders[i].name);
return;
}
* Put them in priority order.
*/
-int
+static int
CompareFolders(struct Folder *f1, struct Folder *f2)
{
if (!alphaOrder && f1->priority != f2->priority)
* Make sure we have at least n folders allocated.
*/
-void
+static void
AllocFolders(struct Folder **f, int *nfa, int n)
{
if (n <= *nfa)
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)));
}
}
* Return the priority for a name. The highest comes from an exact match.
* After that, the longest match (then first) assigns the priority.
*/
-int
+static int
AssignPriority(char *name)
{
int i, ol, nl;