Remove RCS keywords, since they no longer work after git migration.
[mmh] / uip / inc.c
index aee194a..f23a565 100644 (file)
--- a/uip/inc.c
+++ b/uip/inc.c
@@ -2,8 +2,6 @@
 /*
  * inc.c -- incorporate messages from a maildrop into a folder
  *
- * $Id$
- *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
  * complete copyright information.
@@ -223,8 +221,8 @@ static FILE *in;
  */
 char *map_name(char *);
 
+static void inc_done(int) NORETURN;
 #ifdef POP
-int done(int);
 static int pop_action(char *);
 static int pop_pack(char *);
 static int map_count(void);
@@ -236,18 +234,18 @@ main (int argc, char **argv)
 {
     int chgflag = 1, trnflag = 1;
     int noisy = 1, width = 0;
-    int rpop, i, hghnum, msgnum;
+    int rpop, i, hghnum = 0, msgnum = 0;
     int kpop = 0, sasl = 0;
-    char *cp, *maildir, *folder = NULL;
+    char *cp, *maildir = NULL, *folder = NULL;
     char *format = NULL, *form = NULL;
     char *host = NULL, *user = NULL, *proxy = NULL;
     char *audfile = NULL, *from = NULL, *saslmech = NULL;
     char buf[BUFSIZ], **argp, *nfs, **arguments;
-    struct msgs *mp;
+    struct msgs *mp = NULL;
     struct stat st, s1;
     FILE *aud = NULL;
-    char       b[MAXPATHLEN + 1];
-    char       *maildir_copy;          /* copy of mail directory because the static gets overwritten */
+    char b[MAXPATHLEN + 1];
+    char *maildir_copy = NULL; /* copy of mail directory because the static gets overwritten */
 
 #ifdef POP
     int nmsgs, nbytes, p = 0;
@@ -263,6 +261,8 @@ main (int argc, char **argv)
     struct hes_postoffice *po;
 #endif
 
+    done=inc_done;
+
 /* absolutely the first thing we do is save our privileges,
  * and drop them if we can.
  */
@@ -457,7 +457,7 @@ main (int argc, char **argv)
            if (folder)
                adios (NULL, "only one folder at a time!");
            else
-               folder = path (cp + 1, *cp == '+' ? TFOLDER : TSUBCWF);
+               folder = pluspath (cp);
        } else {
            adios (NULL, "usage: %s [+folder] [switches]", invo_name);
        }
@@ -543,7 +543,7 @@ main (int argc, char **argv)
            adios (NULL, "no mail to incorporate");
 
        if ((cp = strdup(newmail)) == (char *)0)
-           adios (maildir, "error allocating memory to copy newmail");
+           adios (NULL, "error allocating memory to copy newmail");
 
        newmail = cp;
     }
@@ -563,10 +563,15 @@ main (int argc, char **argv)
     if ((maildir_copy = strdup(maildir)) == (char *)0)
         adios (maildir, "error allocating memory to copy maildir");
 
-    if (noisy)
-        create_folder(maildir, 0, done);
-    else
-        done (1);
+    if (!folder_exists(maildir)) {
+        /* If the folder doesn't exist, and we're given the -silent flag,
+         * just fail.
+         */
+        if (noisy)
+            create_folder(maildir, 0, done);
+        else
+            done (1);
+    }
 
     if (chdir (maildir) == NOTOK)
        adios (maildir, "unable to change directory to");
@@ -945,7 +950,8 @@ go_to_it:
     seq_setunseen (mp, 0);     /* set the Unseen-Sequence */
     seq_save (mp);             /* synchronize sequences   */
     context_save ();           /* save the context file   */
-    return done (0);
+    done (0);
+    return 1;
 }
 
 
@@ -982,8 +988,8 @@ cpymsg (FILE *in, FILE *out)
 #endif /* if 0 */
 
 
-int
-done (int status)
+static void
+inc_done (int status)
 {
 #ifdef POP
     if (packfile && pd != NOTOK)
@@ -996,7 +1002,6 @@ done (int status)
         DROPGROUPPRIVS();
     }
     exit (status);
-    return 1;  /* dead code to satisfy the compiler */
 }
 
 #ifdef POP