masqmail

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
parents 05fa719b7002
children bd3109ec0f0a
files man/masqmail.8 src/masqmail.c
diffstat 2 files changed, 14 insertions(+), 5 deletions(-) [+]
line diff
     1.1 --- a/man/masqmail.8	Wed Dec 01 18:27:46 2010 -0300
     1.2 +++ b/man/masqmail.8	Thu Dec 02 16:22:55 2010 -0300
     1.3 @@ -33,6 +33,12 @@
     1.4  but not all are implemented.
     1.5  The \fB\-qo\fP option is additional, and unique to masqmail.
     1.6  
     1.7 +When no mode had been specified by either a command line option
     1.8 +(e.g. \fB\-bd\fP, \fB\-bs\fP) or by calling masqmail under a special name
     1.9 +(e.g. ``mailq''), then the default mode is used.
    1.10 +This is accepting messages on stdin if any address arguments are given,
    1.11 +and only printing its version (\fB\-bV\fP) otherwise.
    1.12 +
    1.13  .TP
    1.14  \fB\-\-\fR
    1.15  
     2.1 --- a/src/masqmail.c	Wed Dec 01 18:27:46 2010 -0300
     2.2 +++ b/src/masqmail.c	Thu Dec 02 16:22:55 2010 -0300
     2.3 @@ -38,7 +38,8 @@
     2.4     It, as well as the distinction beween the two (non exclusive) daemon
     2.5     (queue and listen) modes, is handled by flags.*/
     2.6  typedef enum _mta_mode {
     2.7 -	MODE_ACCEPT = 0,  /* accept message on stdin */
     2.8 +	MODE_NONE = 0,  /* for being able to check if a mode was defined */
     2.9 +	MODE_ACCEPT,  /* accept message on stdin */
    2.10  	MODE_DAEMON,  /* run as daemon */
    2.11  	MODE_RUNQUEUE,  /* single queue run, online or offline */
    2.12  	MODE_SMTP,  /* accept SMTP on stdin */
    2.13 @@ -46,7 +47,6 @@
    2.14  	MODE_MCMD,  /* do queue manipulation */
    2.15  	MODE_VERSION,  /* show version */
    2.16  	MODE_BI,  /* fake ;-) */
    2.17 -	MODE_NONE  /* to prevent default MODE_ACCEPT */
    2.18  } mta_mode;
    2.19  
    2.20  char *pidfile = NULL;
    2.21 @@ -382,7 +382,7 @@
    2.22  	char* opt;
    2.23  	gint arg;
    2.24  
    2.25 -	mta_mode mta_mode = MODE_ACCEPT;
    2.26 +	mta_mode mta_mode = MODE_NONE;
    2.27  	gboolean do_listen = FALSE;
    2.28  	gboolean do_runq = FALSE;
    2.29  	gboolean do_runq_online = FALSE;
    2.30 @@ -536,6 +536,11 @@
    2.31  		}
    2.32  	}
    2.33  
    2.34 +	if (!mta_mode) {
    2.35 +		fprintf(stderr, "arg:%d argc:%d\n", arg, argc);
    2.36 +		mta_mode = (arg<argc || opt_t) ? MODE_ACCEPT : MODE_VERSION;
    2.37 +	}
    2.38 +
    2.39  	if (mta_mode == MODE_VERSION) {
    2.40  		gchar *with_resolver = "";
    2.41  		gchar *with_auth = "";
    2.42 @@ -687,8 +692,6 @@
    2.43  			exit(0);
    2.44  		}
    2.45  		break;
    2.46 -	case MODE_NONE:
    2.47 -		break;
    2.48  
    2.49  	default:
    2.50  		fprintf(stderr, "unknown mode: %d\n", mta_mode);