]> diplodocus.org Git - nmh/blobdiff - uip/msgchk.c
lock_file.c: close(2) file descriptor on failure, avoiding leak.
[nmh] / uip / msgchk.c
index eed61cd2d4985ab7b186c2d670995d6adff58742..73ed72845db6d372451bc1bde3a79aa588ffdb87 100644 (file)
@@ -1,6 +1,4 @@
-
-/*
- * msgchk.c -- check for mail
+/* msgchk.c -- check for mail
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
@@ -10,6 +8,7 @@
 #include <h/mh.h>
 #include <h/mts.h>
 #include <h/tws.h>
 #include <h/mh.h>
 #include <h/mts.h>
 #include <h/tws.h>
+#include <h/utils.h>
 #include <pwd.h>
 
 #include <h/popsbr.h>
 #include <pwd.h>
 
 #include <h/popsbr.h>
@@ -80,7 +79,7 @@ DEFINE_SWITCH_ARRAY(MSGCHK, switches);
 /*
  * static prototypes
  */
 /*
  * static prototypes
  */
-static int donote (char *, int);
+static int donote (char *, int) PURE;
 static int checkmail (char *, char *, int, int, int);
 static int remotemail (char *, char *, char *, char *, int, int, int, int,
                       char *, int, const char *);
 static int checkmail (char *, char *, int, int, int);
 static int remotemail (char *, char *, char *, char *, int, int, int, int,
                       char *, int, const char *);
@@ -155,8 +154,7 @@ main (int argc, char **argv)
                        adios (NULL, "missing argument to %s", argp[-2]);
                    if (vecp >= MAXVEC-1)
                        adios (NULL, "you can only check %d users at a time", MAXVEC-1);
                        adios (NULL, "missing argument to %s", argp[-2]);
                    if (vecp >= MAXVEC-1)
                        adios (NULL, "you can only check %d users at a time", MAXVEC-1);
-                   else
-                       user = vec[vecp++] = cp;
+                    user = vec[vecp++] = cp;
                    continue;
 
                case SNOOPSW:
                    continue;
 
                case SNOOPSW:
@@ -209,8 +207,7 @@ main (int argc, char **argv)
        }
        if (vecp >= MAXVEC-1)
            adios (NULL, "you can only check %d users at a time", MAXVEC-1);
        }
        if (vecp >= MAXVEC-1)
            adios (NULL, "you can only check %d users at a time", MAXVEC-1);
-       else
-           vec[vecp++] = cp;
+        vec[vecp++] = cp;
     }
 
     /*
     }
 
     /*
@@ -265,7 +262,7 @@ main (int argc, char **argv)
                if ((pw = getpwnam (vec[vecp])))
                    status += checkmail (pw->pw_name, pw->pw_dir, datesw, notifysw, 0);
                else
                if ((pw = getpwnam (vec[vecp])))
                    status += checkmail (pw->pw_name, pw->pw_dir, datesw, notifysw, 0);
                else
-                   advise (NULL, "no such user as %s", vec[vecp]);
+                   inform("no such user as %s", vec[vecp]);
            }
        }
     }          /* host == NULL */
            }
        }
     }          /* host == NULL */
@@ -389,7 +386,7 @@ remotemail (char *host, char *port, char *user, char *proxy, int notifysw,
                  auth_svc) == NOTOK
            || pop_stat (&nmsgs, &nbytes) == NOTOK     /* check for messages  */
            || pop_quit () == NOTOK) {                 /* quit POP connection */
                  auth_svc) == NOTOK
            || pop_stat (&nmsgs, &nbytes) == NOTOK     /* check for messages  */
            || pop_quit () == NOTOK) {                 /* quit POP connection */
-       advise (NULL, "%s", response);
+       inform("%s", response);
        return 1;
     }
 
        return 1;
     }
 
@@ -401,7 +398,7 @@ remotemail (char *host, char *port, char *user, char *proxy, int notifysw,
                printf ("%s has ", user);
 
            printf ("%d message%s (%d bytes)",
                printf ("%s has ", user);
 
            printf ("%d message%s (%d bytes)",
-                   nmsgs, nmsgs != 1 ? "s" : "", nbytes);
+                   nmsgs, PLURALS(nmsgs), nbytes);
        }
        else
            notifysw = 0;
        }
        else
            notifysw = 0;