- int chgflag = 1, trnflag = 1;
- int noisy = 1, width = 0, locked = 0;
- int rpop, i, hghnum, msgnum;
- char *cp, *maildir, *folder = NULL;
- char *format = NULL, *form = NULL;
- char *newmail, *host = NULL, *user = NULL;
- char *audfile = NULL, *from = NULL;
- char buf[BUFSIZ], **argp, *nfs, **arguments;
- struct msgs *mp;
- struct stat st, s1;
- FILE *in, *aud = NULL;
-
-#ifdef POP
- int nmsgs, nbytes, p = 0;
- char *pass = NULL;
-#endif
-
-#ifdef MHE
- FILE *mhe = NULL;
-#endif
-
-#ifdef HESIOD
- struct hes_postoffice *po;
- char *tmphost;
-#endif
-
-#ifdef LOCALE
- setlocale(LC_ALL, "");
-#endif
- invo_name = r1bindex (argv[0], '/');
-
- /* read user profile/context */
- context_read();
-
- mts_init (invo_name);
- arguments = getarguments (invo_name, argc, argv, 1);
- argp = arguments;
-
-#ifdef POP
-# ifdef HESIOD
- /*
- * Scheme is:
- * use MAILHOST environment variable if present,
- * else try Hesiod.
- * If that fails, use the default (if any)
- * provided by mts.conf in mts_init()
- */
- if ((tmphost = getenv("MAILHOST")) != NULL)
- pophost = tmphost;
- else if ((po = hes_getmailhost(getusername())) != NULL &&
- strcmp(po->po_type, "POP") == 0)
- pophost = po->po_host;
-# endif /* HESIOD */
- /*
- * If there is a valid "pophost" entry in mts.conf,
- * then use it as the default host.
- */
- if (pophost && *pophost)
- host = pophost;
-
- if ((cp = getenv ("MHPOPDEBUG")) && *cp)
- snoop++;
-#endif /* POP */
-
-#ifdef KPOP
- rpop = 1;
-#else
- rpop = 0;
-#endif
-
- while ((cp = *argp++)) {
- if (*cp == '-') {
- switch (smatch (++cp, switches)) {
- case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
- case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
-
- case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [switches]", invo_name);
- print_help (buf, switches, 1);
- done (1);
- case VERSIONSW:
- print_version(invo_name);
- done (1);
-
- case AUDSW:
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- audfile = getcpy (m_maildir (cp));
- continue;
- case NAUDSW:
- audfile = NULL;
- continue;
-
- case CHGSW:
- chgflag++;
- continue;
- case NCHGSW:
- chgflag = 0;
- continue;
-
- /*
- * The flag `trnflag' has the value:
- *
- * 2 if -truncate is given
- * 1 by default (truncating is default)
- * 0 if -notruncate is given
- */
- case TRNCSW:
- trnflag = 2;
- continue;
- case NTRNCSW:
- trnflag = 0;
- continue;
-
- case FILESW:
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- from = path (cp, TFILE);
+ int chgflag = 1, trnflag = 1;
+ int noisy = 1, width = 0;
+ int hghnum = 0, msgnum = 0;
+ int incerr = 0; /*
+ ** <0 if inc hits an error which means it should
+ ** not truncate mailspool
+ */
+ char *cp, *maildir = NULL, *folder = NULL;
+ char *form = NULL;
+ char *audfile = NULL, *from = NULL;
+ char buf[BUFSIZ], **argp, *fmtstr, **arguments;
+ struct msgs *mp = NULL;
+ struct stat st, s1;
+ FILE *aud = NULL;
+ char b[MAXPATHLEN + 1];
+ /* copy of mail directory because the static gets overwritten */
+ char *maildir_copy = NULL;
+
+ if (atexit(inc_done) != 0) {
+ adios(EX_OSERR, NULL, "atexit failed");
+ }