# HG changeset patch
# User markus schnalke <meillo@marmaro.de>
# Date 1291668110 10800
# Node ID c35c59a36a2a5395909ae9b5f804984e8d7631d3
# Parent  5f559921391a6a145c7560e05e13b0c496abf210
added -bm for mode accept (the other MTAs have it too)
usually one does not need it as it's the default

diff -r 5f559921391a -r c35c59a36a2a src/masqmail.c
--- a/src/masqmail.c	Mon Dec 06 17:34:15 2010 -0300
+++ b/src/masqmail.c	Mon Dec 06 17:41:50 2010 -0300
@@ -38,8 +38,7 @@
    It, as well as the distinction beween the two (non exclusive) daemon
    (queue and listen) modes, is handled by flags.*/
 typedef enum _mta_mode {
-	MODE_NONE = 0,  /* for being able to check if a mode was defined */
-	MODE_ACCEPT,  /* accept message on stdin */
+	MODE_ACCEPT = 0,  /* accept message on stdin (fallback mode) */
 	MODE_DAEMON,  /* run as daemon */
 	MODE_RUNQUEUE,  /* single queue run, online or offline */
 	MODE_SMTP,  /* accept SMTP on stdin */
@@ -422,7 +421,7 @@
 	char* opt;
 	gint arg;
 
-	mta_mode mta_mode = MODE_NONE;
+	mta_mode mta_mode = MODE_ACCEPT;
 	gboolean do_listen = FALSE;
 	gboolean do_runq = FALSE;
 	gboolean do_runq_online = FALSE;
@@ -470,6 +469,9 @@
 			arg++;
 			break;
 
+		} else if (strcmp(opt, "bm") == 0) {
+			mta_mode = MODE_ACCEPT;
+
 		} else if (strcmp(opt, "bd") == 0) {
 			do_listen = TRUE;
 			mta_mode = MODE_DAEMON;
@@ -546,6 +548,7 @@
 			/* ignore all other -oXXX options */
 
 		} else if (strncmp(opt, "qo", 2) == 0) {
+			/* must be before the `q' check */
 			mta_mode = MODE_RUNQUEUE;
 			do_runq = FALSE;
 			do_runq_online = TRUE;
@@ -577,8 +580,14 @@
 		}
 	}
 
-	if (!mta_mode) {
-		mta_mode = (arg<argc || opt_t) ? MODE_ACCEPT : MODE_VERSION;
+	if (mta_mode==MODE_ACCEPT && arg==argc && !opt_t) {
+		/*
+		In this case no rcpts can be found, thus no mail
+		can be sent, thus masqmail will always fail. We
+		rather do something better instead. This covers
+		also the case of calling masqmail without args.
+		*/
+		mta_mode =  MODE_VERSION;
 	}
 
 	if (mta_mode == MODE_VERSION) {