masqmail

diff src/masqmail.c @ 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
line diff
     1.1 --- a/src/masqmail.c	Wed Dec 01 18:27:46 2010 -0300
     1.2 +++ b/src/masqmail.c	Thu Dec 02 16:22:55 2010 -0300
     1.3 @@ -38,7 +38,8 @@
     1.4     It, as well as the distinction beween the two (non exclusive) daemon
     1.5     (queue and listen) modes, is handled by flags.*/
     1.6  typedef enum _mta_mode {
     1.7 -	MODE_ACCEPT = 0,  /* accept message on stdin */
     1.8 +	MODE_NONE = 0,  /* for being able to check if a mode was defined */
     1.9 +	MODE_ACCEPT,  /* accept message on stdin */
    1.10  	MODE_DAEMON,  /* run as daemon */
    1.11  	MODE_RUNQUEUE,  /* single queue run, online or offline */
    1.12  	MODE_SMTP,  /* accept SMTP on stdin */
    1.13 @@ -46,7 +47,6 @@
    1.14  	MODE_MCMD,  /* do queue manipulation */
    1.15  	MODE_VERSION,  /* show version */
    1.16  	MODE_BI,  /* fake ;-) */
    1.17 -	MODE_NONE  /* to prevent default MODE_ACCEPT */
    1.18  } mta_mode;
    1.19  
    1.20  char *pidfile = NULL;
    1.21 @@ -382,7 +382,7 @@
    1.22  	char* opt;
    1.23  	gint arg;
    1.24  
    1.25 -	mta_mode mta_mode = MODE_ACCEPT;
    1.26 +	mta_mode mta_mode = MODE_NONE;
    1.27  	gboolean do_listen = FALSE;
    1.28  	gboolean do_runq = FALSE;
    1.29  	gboolean do_runq_online = FALSE;
    1.30 @@ -536,6 +536,11 @@
    1.31  		}
    1.32  	}
    1.33  
    1.34 +	if (!mta_mode) {
    1.35 +		fprintf(stderr, "arg:%d argc:%d\n", arg, argc);
    1.36 +		mta_mode = (arg<argc || opt_t) ? MODE_ACCEPT : MODE_VERSION;
    1.37 +	}
    1.38 +
    1.39  	if (mta_mode == MODE_VERSION) {
    1.40  		gchar *with_resolver = "";
    1.41  		gchar *with_auth = "";
    1.42 @@ -687,8 +692,6 @@
    1.43  			exit(0);
    1.44  		}
    1.45  		break;
    1.46 -	case MODE_NONE:
    1.47 -		break;
    1.48  
    1.49  	default:
    1.50  		fprintf(stderr, "unknown mode: %d\n", mta_mode);