changeset 259:f4117fd5a163

made default mode sensible Until now in case no mode was specified, a message would have been read from stdin but then it would fail because no recipients had been given on the cmd line. (This had been useful only if -t was given.) Now in case of no mode being specified neither address arguments or -t is given then the version message is printed, otherwise mode accept is entered (as until yet).
author markus schnalke <meillo@marmaro.de>
date Thu, 02 Dec 2010 16:22:55 -0300 (2010-12-02)
parents 05fa719b7002
children bd3109ec0f0a
files man/masqmail.8 src/masqmail.c
diffstat 2 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/man/masqmail.8	Wed Dec 01 18:27:46 2010 -0300
+++ b/man/masqmail.8	Thu Dec 02 16:22:55 2010 -0300
@@ -33,6 +33,12 @@
 but not all are implemented.
 The \fB\-qo\fP option is additional, and unique to masqmail.
 
+When no mode had been specified by either a command line option
+(e.g. \fB\-bd\fP, \fB\-bs\fP) or by calling masqmail under a special name
+(e.g. ``mailq''), then the default mode is used.
+This is accepting messages on stdin if any address arguments are given,
+and only printing its version (\fB\-bV\fP) otherwise.
+
 .TP
 \fB\-\-\fR
 
--- a/src/masqmail.c	Wed Dec 01 18:27:46 2010 -0300
+++ b/src/masqmail.c	Thu Dec 02 16:22:55 2010 -0300
@@ -38,7 +38,8 @@
    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_ACCEPT = 0,  /* accept message on stdin */
+	MODE_NONE = 0,  /* for being able to check if a mode was defined */
+	MODE_ACCEPT,  /* accept message on stdin */
 	MODE_DAEMON,  /* run as daemon */
 	MODE_RUNQUEUE,  /* single queue run, online or offline */
 	MODE_SMTP,  /* accept SMTP on stdin */
@@ -46,7 +47,6 @@
 	MODE_MCMD,  /* do queue manipulation */
 	MODE_VERSION,  /* show version */
 	MODE_BI,  /* fake ;-) */
-	MODE_NONE  /* to prevent default MODE_ACCEPT */
 } mta_mode;
 
 char *pidfile = NULL;
@@ -382,7 +382,7 @@
 	char* opt;
 	gint arg;
 
-	mta_mode mta_mode = MODE_ACCEPT;
+	mta_mode mta_mode = MODE_NONE;
 	gboolean do_listen = FALSE;
 	gboolean do_runq = FALSE;
 	gboolean do_runq_online = FALSE;
@@ -536,6 +536,11 @@
 		}
 	}
 
+	if (!mta_mode) {
+		fprintf(stderr, "arg:%d argc:%d\n", arg, argc);
+		mta_mode = (arg<argc || opt_t) ? MODE_ACCEPT : MODE_VERSION;
+	}
+
 	if (mta_mode == MODE_VERSION) {
 		gchar *with_resolver = "";
 		gchar *with_auth = "";
@@ -687,8 +692,6 @@
 			exit(0);
 		}
 		break;
-	case MODE_NONE:
-		break;
 
 	default:
 		fprintf(stderr, "unknown mode: %d\n", mta_mode);