comparison 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
comparison
equal deleted inserted replaced
258:05fa719b7002 259:f4117fd5a163
36 36
37 /* mutually exclusive modes. Note that there is no 'queue daemon' mode. 37 /* mutually exclusive modes. Note that there is no 'queue daemon' mode.
38 It, as well as the distinction beween the two (non exclusive) daemon 38 It, as well as the distinction beween the two (non exclusive) daemon
39 (queue and listen) modes, is handled by flags.*/ 39 (queue and listen) modes, is handled by flags.*/
40 typedef enum _mta_mode { 40 typedef enum _mta_mode {
41 MODE_ACCEPT = 0, /* accept message on stdin */ 41 MODE_NONE = 0, /* for being able to check if a mode was defined */
42 MODE_ACCEPT, /* accept message on stdin */
42 MODE_DAEMON, /* run as daemon */ 43 MODE_DAEMON, /* run as daemon */
43 MODE_RUNQUEUE, /* single queue run, online or offline */ 44 MODE_RUNQUEUE, /* single queue run, online or offline */
44 MODE_SMTP, /* accept SMTP on stdin */ 45 MODE_SMTP, /* accept SMTP on stdin */
45 MODE_LIST, /* list queue */ 46 MODE_LIST, /* list queue */
46 MODE_MCMD, /* do queue manipulation */ 47 MODE_MCMD, /* do queue manipulation */
47 MODE_VERSION, /* show version */ 48 MODE_VERSION, /* show version */
48 MODE_BI, /* fake ;-) */ 49 MODE_BI, /* fake ;-) */
49 MODE_NONE /* to prevent default MODE_ACCEPT */
50 } mta_mode; 50 } mta_mode;
51 51
52 char *pidfile = NULL; 52 char *pidfile = NULL;
53 volatile int sigterm_in_progress = 0; 53 volatile int sigterm_in_progress = 0;
54 54
380 { 380 {
381 gchar *progname; 381 gchar *progname;
382 char* opt; 382 char* opt;
383 gint arg; 383 gint arg;
384 384
385 mta_mode mta_mode = MODE_ACCEPT; 385 mta_mode mta_mode = MODE_NONE;
386 gboolean do_listen = FALSE; 386 gboolean do_listen = FALSE;
387 gboolean do_runq = FALSE; 387 gboolean do_runq = FALSE;
388 gboolean do_runq_online = FALSE; 388 gboolean do_runq_online = FALSE;
389 gboolean do_queue = FALSE; 389 gboolean do_queue = FALSE;
390 gint queue_interval = 0; 390 gint queue_interval = 0;
534 fprintf(stderr, "unrecognized option `-%s'\n", opt); 534 fprintf(stderr, "unrecognized option `-%s'\n", opt);
535 exit(EXIT_FAILURE); 535 exit(EXIT_FAILURE);
536 } 536 }
537 } 537 }
538 538
539 if (!mta_mode) {
540 fprintf(stderr, "arg:%d argc:%d\n", arg, argc);
541 mta_mode = (arg<argc || opt_t) ? MODE_ACCEPT : MODE_VERSION;
542 }
543
539 if (mta_mode == MODE_VERSION) { 544 if (mta_mode == MODE_VERSION) {
540 gchar *with_resolver = ""; 545 gchar *with_resolver = "";
541 gchar *with_auth = ""; 546 gchar *with_auth = "";
542 gchar *with_ident = ""; 547 gchar *with_ident = "";
543 548
685 | (opt_i ? ACC_DOT_IGNORE : ACC_NODOT_RELAX); 690 | (opt_i ? ACC_DOT_IGNORE : ACC_NODOT_RELAX);
686 mode_accept(return_path, full_sender_name, accept_flags, &(argv[arg]), argc - arg); 691 mode_accept(return_path, full_sender_name, accept_flags, &(argv[arg]), argc - arg);
687 exit(0); 692 exit(0);
688 } 693 }
689 break; 694 break;
690 case MODE_NONE:
691 break;
692 695
693 default: 696 default:
694 fprintf(stderr, "unknown mode: %d\n", mta_mode); 697 fprintf(stderr, "unknown mode: %d\n", mta_mode);
695 break; 698 break;
696 } 699 }