Reformated comments and long lines
[mmh] / uip / flist.c
index 51eff1e..17916fb 100644 (file)
@@ -1,18 +1,18 @@
 /*
- * flist.c -- list nmh folders containing messages
- *         -- in a given sequence
- *
- * originally by
- * David Nichols, Xerox-PARC, November, 1992
- *
- * Copyright (c) 1994 Xerox Corporation.
- * Use and copying of this software and preparation of derivative works based
- * upon this software are permitted. Any distribution of this software or
- * derivative works must comply with all applicable United States export
- * control laws. This software is made available AS IS, and Xerox Corporation
- * makes no warranty about the software, its performance or its conformity to
- * any specification.
- */
+** flist.c -- list nmh folders containing messages
+**         -- in a given sequence
+**
+** originally by
+** David Nichols, Xerox-PARC, November, 1992
+**
+** Copyright (c) 1994 Xerox Corporation.
+** Use and copying of this software and preparation of derivative works based
+** upon this software are permitted. Any distribution of this software or
+** derivative works must comply with all applicable United States export
+** control laws. This software is made available AS IS, and Xerox Corporation
+** makes no warranty about the software, its performance or its conformity to
+** any specification.
+*/
 
 #include <h/mh.h>
 #include <h/utils.h>
@@ -21,9 +21,9 @@
 #define TRUE    1
 
 /*
- * We allocate space to record the names of folders
- * (foldersToDo array), this number of elements at a time.
- */
+** We allocate space to record the names of folders
+** (foldersToDo array), this number of elements at a time.
+*/
 #define MAXFOLDERS  100
 
 
@@ -97,14 +97,14 @@ static char curfolder[BUFSIZ];  /* name of the current folder */
 static char *nmhdir;  /* base nmh mail directory */
 
 /*
- * Type for a compare function for qsort.  This keeps
- * the compiler happy.
- */
+** Type for a compare function for qsort.  This keeps
+** the compiler happy.
+*/
 typedef int (*qsort_comp) (const void *, const void *);
 
 /*
- * prototypes
- */
+** prototypes
+*/
 int CompareFolders(struct Folder *, struct Folder *);
 void GetFolderOrder(void);
 void ScanFolders(void);
@@ -134,9 +134,9 @@ main(int argc, char **argv)
        context_read();
 
        /*
-        * If program was invoked with name ending
-        * in `s', then add switch `-all'.
-        */
+       ** If program was invoked with name ending
+       ** in `s', then add switch `-all'.
+       */
        if (argv[0][strlen (argv[0]) - 1] == 's')
                all = TRUE;
 
@@ -220,9 +220,9 @@ main(int argc, char **argv)
                        }
                } else {
                        /*
-                        * Check if we need to allocate more space
-                        * for folder names.
-                        */
+                       ** Check if we need to allocate more space
+                       ** for folder names.
+                       */
                        if (numfolders >= maxfolders) {
                                maxfolders += MAXFOLDERS;
                                foldersToDo = (char **) mh_xrealloc (foldersToDo,
@@ -246,12 +246,12 @@ main(int argc, char **argv)
        nmhdir = m_maildir ("");
 
        /*
-        * If we didn't specify any sequences, we search
-        * for the "Unseen-Sequence" profile entry and use
-        * all the sequences defined there.  We check to
-        * make sure that the Unseen-Sequence entry doesn't
-        * contain more than NUMATTRS sequences.
-        */
+       ** If we didn't specify any sequences, we search
+       ** for the "Unseen-Sequence" profile entry and use
+       ** all the sequences defined there.  We check to
+       ** make sure that the Unseen-Sequence entry doesn't
+       ** contain more than NUMATTRS sequences.
+       */
        if (numsequences == 0) {
                if ((cp = context_find(usequence)) && *cp) {
                        char **ap, *dp;
@@ -279,9 +279,9 @@ main(int argc, char **argv)
 }
 
 /*
- * Read the Flist-Order profile entry to determine
- * how to sort folders for output.
- */
+** Read the Flist-Order profile entry to determine
+** how to sort folders for output.
+*/
 
 void
 GetFolderOrder(void)
@@ -312,8 +312,8 @@ GetFolderOrder(void)
 }
 
 /*
- * Scan all the necessary folders
- */
+** Scan all the necessary folders
+*/
 
 void
 ScanFolders(void)
@@ -333,36 +333,36 @@ ScanFolders(void)
                context_save ();  /* save the context file */
 
                /*
-                * Scan each given folder.  If -all is given,
-                * then also scan the 1st level subfolders under
-                * each given folder.
-                */
+               ** Scan each given folder.  If -all is given,
+               ** then also scan the 1st level subfolders under
+               ** each given folder.
+               */
                for (i = 0; i < numfolders; ++i)
                        BuildFolderList(foldersToDo[i], all ? 1 : 0);
        } else {
                if (all) {
                        /*
-                        * Do the readonly folders
-                        */
+                       ** Do the readonly folders
+                       */
                        do_readonly_folders();
 
                        /*
-                        * Now scan the entire nmh directory for folders
-                        */
+                       ** Now scan the entire nmh directory for folders
+                       */
                        BuildFolderList(".", 0);
                } else {
                        /*
-                        * Else scan current folder
-                        */
+                       ** Else scan current folder
+                       */
                        BuildFolderList(curfolder, 0);
                }
        }
 }
 
 /*
- * Initial building of folder list for
- * the top of our search tree.
- */
+** Initial building of folder list for
+** the top of our search tree.
+*/
 
 void
 BuildFolderList(char *dirName, int searchdepth)
@@ -374,26 +374,26 @@ BuildFolderList(char *dirName, int searchdepth)
                return;
 
        /*
-        * If base directory, don't add it to the
-        * folder list. We just recurse into it.
-        */
+       ** If base directory, don't add it to the
+       ** folder list. We just recurse into it.
+       */
        if (!strcmp (dirName, ".")) {
                BuildFolderListRecurse (".", &st, 0);
                return;
        }
 
        /*
-        * Add this folder to the list.
-        * If recursing and directory has subfolders,
-        * then build folder list for subfolders.
-        */
+       ** Add this folder to the list.
+       ** If recursing and directory has subfolders,
+       ** then build folder list for subfolders.
+       */
        if (AddFolder(dirName, showzero) && (recurse || searchdepth) && st.st_nlink > 2)
                BuildFolderListRecurse(dirName, &st, searchdepth - 1);
 }
 
 /*
- * Recursive building of folder list
- */
+** Recursive building of folder list
+*/
 
 void
 BuildFolderListRecurse(char *dirName, struct stat *s, int searchdepth)
@@ -406,21 +406,21 @@ BuildFolderListRecurse(char *dirName, struct stat *s, int searchdepth)
        struct stat st;
 
        /*
-        * Keep track of number of directories we've seen so we can
-        * stop stat'ing entries in this directory once we've seen
-        * them all.  This optimization will fail if you have extra
-        * directories beginning with ".", since we don't bother to
-        * stat them.  But that shouldn't generally be a problem.
-        */
+       ** Keep track of number of directories we've seen so we can
+       ** stop stat'ing entries in this directory once we've seen
+       ** them all.  This optimization will fail if you have extra
+       ** directories beginning with ".", since we don't bother to
+       ** stat them.  But that shouldn't generally be a problem.
+       */
        nlinks = s->st_nlink;
 
        if (!(dir = opendir(dirName)))
                adios(dirName, "can't open directory");
 
        /*
-        * A hack so that we don't see a
-        * leading "./" in folder names.
-        */
+       ** A hack so that we don't see a
+       ** leading "./" in folder names.
+       */
        base = strcmp (dirName, ".") ? dirName : dirName + 1;
 
        while (nlinks && (dp = readdir(dir))) {
@@ -431,8 +431,8 @@ BuildFolderListRecurse(char *dirName, struct stat *s, int searchdepth)
                if (dp->d_name[0] == '.')
                        continue;
                /* 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
-                */
+               ** if it is, we assume it's a mail file and skip it
+               */
                for (n = dp->d_name; *n && isdigit(*n); n++);
                if (!*n)
                        continue;
@@ -442,14 +442,15 @@ BuildFolderListRecurse(char *dirName, struct stat *s, int searchdepth)
                strncat(name, dp->d_name, sizeof(name) - strlen(name) - 1);
                if ((stat(name, &st) != -1) && S_ISDIR(st.st_mode)) {
                        /*
-                        * Check if this was really a symbolic link pointing
-                        * to a directory.  If not, then decrement link count.
-                        */
+                       ** Check if this was really a symbolic link pointing
+                       ** to a directory.  If not, then decrement link count.
+                       */
                        if (lstat (name, &st) == -1)
                                nlinks--;
                        /* Add this folder to the list */
                        if (AddFolder(name, showzero) &&
-                                               (recurse || searchdepth) && st.st_nlink > 2)
+                                       (recurse || searchdepth) &&
+                                       st.st_nlink > 2)
                                BuildFolderListRecurse(name, &st, searchdepth - 1);
                }
        }
@@ -457,9 +458,9 @@ BuildFolderListRecurse(char *dirName, struct stat *s, int searchdepth)
 }
 
 /*
- * Add this folder to our list, counting the total number of
- * messages and the number of messages in each sequence.
- */
+** Add this folder to our list, counting the total number of
+** messages and the number of messages in each sequence.
+*/
 
 int
 AddFolder(char *name, int force)
@@ -527,8 +528,8 @@ AddFolder(char *name, int force)
 }
 
 /*
- * Print the folder/sequence information
- */
+** Print the folder/sequence information
+*/
 
 void
 PrintFolders(void)
@@ -545,8 +546,8 @@ PrintFolders(void)
        }
 
        /*
-        * Find the width we need for various fields
-        */
+       ** Find the width we need for various fields
+       */
        for (i = 0; i < nFolders; ++i) {
                /* find the length of longest folder name */
                len = strlen(folders[i].name);
@@ -604,8 +605,8 @@ PrintFolders(void)
 }
 
 /*
- * Put them in priority order.
- */
+** Put them in priority order.
+*/
 
 int
 CompareFolders(struct Folder *f1, struct Folder *f2)
@@ -617,8 +618,8 @@ CompareFolders(struct Folder *f1, struct Folder *f2)
 }
 
 /*
- * Make sure we have at least n folders allocated.
- */
+** Make sure we have at least n folders allocated.
+*/
 
 void
 AllocFolders(struct Folder **f, int *nfa, int n)
@@ -635,9 +636,9 @@ 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.
- */
+** Return the priority for a name.  The highest comes from an exact match.
+** After that, the longest match (then first) assigns the priority.
+*/
 int
 AssignPriority(char *name)
 {
@@ -668,8 +669,8 @@ AssignPriority(char *name)
 }
 
 /*
- * Do the read only folders
- */
+** Do the read only folders
+*/
 
 static void
 do_readonly_folders (void)