#define INC_FILE 0
#define INC_POP 1
-static int inc_type;
static struct Maildir_entry {
char *filename;
time_t mtime;
int
main (int argc, char **argv)
{
+ static int inc_type;
bool chgflag;
int trnflag = 1;
bool noisy;
/* guarantee dropping group privileges; we might not have done so earlier */
DROPGROUPPRIVS();
- /*
- * Where are we getting the new mail?
- */
- if (from)
- inc_type = INC_FILE;
- else if (host)
- inc_type = INC_POP;
- else
- inc_type = INC_FILE;
+ /* Source of mail; -from overrides any -host. */
+ inc_type = host && !from ? INC_POP : INC_FILE;
- /*
- * Are we getting the mail from
- * a POP server?
- */
if (inc_type == INC_POP) {
+ /* Mail from a POP server. */
int tlsflag = 0;
if (auth_svc == NULL) {
pop_quit();
adios (NULL, "no mail to incorporate");
}
- }
-
- /*
- * We will get the mail from a file
- * (typically the standard maildrop)
- */
- if (inc_type == INC_FILE) {
+ } else if (inc_type == INC_FILE) {
+ /* Mail from a spool file, or Maildir. */
if (from)
newmail = from;
else if ((newmail = getenv ("MAILDROP")) && *newmail)
adios (NULL, "unable to read folder %s", folder);
if (inc_type == INC_FILE && Maildir == NULL) {
+ /* Mail from a spool file. */
+
if (access (newmail, W_OK) != NOTOK) {
locked++;
if (trnflag) {
* Get the mail from a POP server
*/
if (inc_type == INC_POP) {
+ /* Mail from a POP server. */
int i;
hghnum = msgnum = mp->hghmsg;
if (pop_quit () == NOTOK)
adios (NULL, "%s", response);
- }
- /*
- * Get the mail from file (usually mail spool)
- */
- if (inc_type == INC_FILE && Maildir == NULL) {
+ } else if (inc_type == INC_FILE && Maildir == NULL) {
+ /* Mail from a spool file. */
+
scan_detect_mbox_style (in); /* the MAGIC invocation... */
hghnum = msgnum = mp->hghmsg;
for (;;) {
*/
break;
}
- } else if (inc_type == INC_FILE) { /* Maildir inbox to process */
+
+ } else {
+ /* Mail from Maildir. */
char *sp;
FILE *sf;
int i;
if (noisy)
fflush (stdout);
- /*
- * truncate file we are incorporating from
- */
if (inc_type == INC_FILE && Maildir == NULL) {
+ /* Mail from a spool file; truncate it. */
+
if (trnflag) {
if (stat (newmail, &st) != NOTOK && s1.st_mtime != st.st_mtime)
inform("new messages have arrived!\007");
seq_save(mp2); /* Save the sequence file */
folder_free(mp2);
}
-skip:
- /*
- * unlock the mail spool
- */
+skip:
if (inc_type == INC_FILE && Maildir == NULL) {
+ /* Mail from a spool file; unlock it. */
+
if (locked) {
GETGROUPPRIVS(); /* Be sure we can unlock mail file */
(void) lkfclosespool (in, newmail); in = NULL;