Obey to the new coding style
[infodrom/newmail] / folder.c
index 26232f0..1c63872 100644 (file)
--- a/folder.c
+++ b/folder.c
@@ -27,6 +27,7 @@
 #include <errno.h>
 #include <paths.h>
 #include "mbox.h"
+#include "optdefs.h"
 
 #define FOLDERS_DELTA  5
 
@@ -58,15 +59,15 @@ void add_folder(char *path)
   }
 
   if ((thisfolder = (struct folder *)malloc(sizeof(struct folder))) == NULL) {
-    perror("malloc");
-    exit(1);
+    perror ("malloc");
+    exit (1);
   }
 
   if ((cp = index(path, '=')) != NULL) {
     *cp++ = '\0';
     if ((thisfolder->prefix = (char *)strdup(cp)) == NULL) {
-      perror("strdup");
-      exit(1);
+      perror ("strdup");
+      exit (1);
     }
     strcpy(thisfolder->prefix, cp);
   } else {
@@ -75,13 +76,13 @@ void add_folder(char *path)
       if ((cp = rindex(path, '/')) != NULL) {
        cp++;
        if ((thisfolder->prefix = (char *)strdup(cp)) == NULL) {
-         perror("strdup");
-         exit(1);
+         perror ("strdup");
+         exit (1);
        }
       } else {
        if ((thisfolder->prefix = (char *)strdup(path)) == NULL) {
-         perror("strdup");
-         exit(1);
+         perror ("strdup");
+         exit (1);
        }
       }
     } else
@@ -89,8 +90,8 @@ void add_folder(char *path)
   }
 
   if ((thisfolder->path = (char *)strdup(path)) == NULL) {
-    perror("strdup");
-    exit(1);
+    perror ("strdup");
+    exit (1);
   }
 
   sh = stat(path, &st);
@@ -118,13 +119,13 @@ void add_default_folder()
   if ((env = getenv("MAIL")) == NULL) {
     uid = getuid();
     if ((pw = getpwuid(uid)) == NULL) {
-      perror("getpwuid");
-      exit(1);
+      perror ("getpwuid");
+      exit (1);
     }
 
-    snprintf(path, sizeof(path), "%s/%s", _PATH_MAILDIR, pw->pw_name);
+    snprintf (path, sizeof(path), "%s/%s", _PATH_MAILDIR, pw->pw_name);
   } else {
-    snprintf(path, sizeof(path), env);
+    snprintf (path, sizeof(path), env);
   }
 
   add_folder(path);
@@ -143,27 +144,31 @@ void fix_prefix()
   if ((cp = rindex(folders[0]->path, '/')) != NULL) {
     cp++;
     if ((folders[0]->prefix = (char *)strdup(cp)) == NULL) {
-      perror("strdup");
-      exit(1);
+      perror ("strdup");
+      exit (1);
     }
   } else {
     if ((folders[0]->prefix = (char *)strdup(folders[0]->path)) == NULL) {
-      perror("strdup");
-      exit(1);
+      perror ("strdup");
+      exit (1);
     }
   }
 }
 
-void watch_folders(int opt_bell)
+void watch_folders(int opt_flags)
 {
   unsigned int i;
   int newmail = 0;
 
   for (i=0; i < numfolders; i++)
-    newmail |= watch_mbox(folders[i]->path, folders[i]->prefix, &folders[i]->size);
+    newmail |= watch_mbox(folders[i]->path, folders[i]->prefix, &folders[i]->size, opt_flags);
 
-  if (newmail && opt_bell) {
-    putchar('\007');
-    fflush(stdout);
+  if (newmail) {
+    if (!(opt_flags & OPT_WINDOW)) {
+      if (opt_flags & OPT_BELL)
+       putchar ('\007');
+      putchar ('\n');
+    }
+    fflush (stdout);
   }
 }