X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/c6f2d14d9c38345075629af3487c2de491584ca1..28ec221002d755d33c41fa4b5d9673eee0abef9d:/uip/flist.c diff --git a/uip/flist.c b/uip/flist.c index 4a38938c..02d6f5e7 100644 --- a/uip/flist.c +++ b/uip/flist.c @@ -1,5 +1,4 @@ -/* - * flist.c -- list nmh folders containing messages +/* flist.c -- list nmh folders containing messages * -- in a given sequence * * originally by @@ -17,9 +16,6 @@ #include #include -#define FALSE 0 -#define TRUE 1 - /* * We allocate space to record the names of folders * (foldersToDo array), this number of elements at a time. @@ -93,17 +89,17 @@ static char *nmhdir; /* base nmh mail directory */ 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); @@ -121,8 +117,7 @@ main(int argc, char **argv) * If program was invoked with name ending * in `s', then add switch `-all'. */ - if (argv[0][strlen (argv[0]) - 1] == 's') - all = TRUE; + all = has_suffix_c(argv[0], 's'); arguments = getarguments (invo_name, argc, argv, 1); argp = arguments; @@ -235,7 +230,7 @@ main(int argc, char **argv) if ((cp = context_find(usequence)) && *cp) { char **ap, *dp; - dp = getcpy(cp); + dp = mh_xstrdup(cp); ap = brkstring (dp, " ", "\n"); for (; ap && *ap; ap++) svector_push_back (sequencesToDo, *ap); @@ -258,7 +253,7 @@ main(int argc, char **argv) * how to sort folders for output. */ -void +static void GetFolderOrder(void) { char *p, *s; @@ -290,7 +285,7 @@ GetFolderOrder(void) * Scan all the necessary folders */ -void +static void ScanFolders(void) { int i; @@ -339,7 +334,7 @@ ScanFolders(void) * the top of our search tree. */ -void +static void BuildFolderList(char *dirName, int searchdepth) { struct stat st; @@ -370,7 +365,7 @@ BuildFolderList(char *dirName, int searchdepth) * Recursive building of folder list */ -void +static void BuildFolderListRecurse(char *dirName, struct stat *s, int searchdepth) { char *base, name[PATH_MAX]; @@ -442,7 +437,7 @@ BuildFolderListRecurse(char *dirName, struct stat *s, int searchdepth) * messages and the number of messages in each sequence. */ -int +static int AddFolder(char *name, int force) { unsigned int i; @@ -457,7 +452,7 @@ AddFolder(char *name, int force) /* Oops, error occurred. Record it and continue. */ AllocFolders(&folders, &nFoldersAlloced, nFolders + 1); f = &folders[nFolders++]; - f->name = getcpy(name); + f->name = mh_xstrdup(name); f->error = 1; f->priority = AssignPriority(f->name); return 0; @@ -493,7 +488,7 @@ AddFolder(char *name, int force) /* save general folder information */ AllocFolders(&folders, &nFoldersAlloced, nFolders + 1); f = &folders[nFolders++]; - f->name = getcpy(name); + f->name = mh_xstrdup(name); f->nMsgs = mp->nummsg; f->nSeq = ivector_create (0); f->private = ivector_create (0); @@ -520,7 +515,7 @@ AddFolder(char *name, int force) * Print the folder/sequence information */ -void +static void PrintFolders(void) { char tmpname[BUFSIZ]; @@ -530,7 +525,7 @@ PrintFolders(void) if (!Total) { for (i = 0; i < nFolders; i++) - printf("%s\n", folders[i].name); + puts(folders[i].name); return; } @@ -599,20 +594,19 @@ PrintFolders(void) * Put them in priority order. */ -int +static int CompareFolders(struct Folder *f1, struct Folder *f2) { if (!alphaOrder && f1->priority != f2->priority) return f1->priority - f2->priority; - else - return strcmp(f1->name, f2->name); + return strcmp(f1->name, f2->name); } /* * Make sure we have at least n folders allocated. */ -void +static void AllocFolders(struct Folder **f, int *nfa, int n) { if (n <= *nfa) @@ -630,7 +624,7 @@ AllocFolders(struct Folder **f, int *nfa, int n) * 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;