comparison src/masqmail.c @ 248:018cfd163f5c

refactored processing of -oXXX options plus two minor things
author markus schnalke <meillo@marmaro.de>
date Mon, 01 Nov 2010 14:53:26 -0300
parents 3c40f86d50e4
children f9da5a7caeda
comparison
equal deleted inserted replaced
247:3c40f86d50e4 248:018cfd163f5c
302 mta_mode mta_mode = MODE_ACCEPT; 302 mta_mode mta_mode = MODE_ACCEPT;
303 303
304 gint queue_interval = 0; 304 gint queue_interval = 0;
305 gboolean opt_t = FALSE; 305 gboolean opt_t = FALSE;
306 gboolean opt_i = FALSE; 306 gboolean opt_i = FALSE;
307 gboolean opt_odb = FALSE;
308 gboolean opt_oem = FALSE;
309 gboolean exit_failure = FALSE; 307 gboolean exit_failure = FALSE;
310 308
311 gchar *M_cmd = NULL; 309 gchar *M_cmd = NULL;
312 310
313 gint exit_code = EXIT_SUCCESS; 311 gint exit_code = EXIT_SUCCESS;
430 break; 428 break;
431 case 'm': 429 case 'm':
432 /* ignore -m (me too) switch (see man page) */ 430 /* ignore -m (me too) switch (see man page) */
433 break; 431 break;
434 case 'o': 432 case 'o':
435 switch (argv[arg][pos++]) { 433 char* oarg = argv[arg][pos+1];
436 case 'e': 434 if (strcmp(oarg, "oem") == 0) {
437 if (argv[arg][pos++] == 'm') /* -oem */ 435 if (!opt_i) {
438 if (!opt_i) 436 /* FIXME: this check needs to be done after
439 exit_failure = TRUE; 437 option processing as -oi may come later */
440 opt_oem = TRUE; 438 exit_failure = TRUE;
441 break; 439 }
442 case 'd': 440 } else if (strcmp(oarg, "odb") == 0) {
443 if (argv[arg][pos] == 'b') /* -odb */ 441 /* ignore ``deliver in background'' switch */
444 opt_odb = TRUE; 442 } else if (strcmp(oarg, "odq") == 0) {
445 else if (argv[arg][pos] == 'q') /* -odq */ 443 do_queue = TRUE;
446 do_queue = TRUE; 444 } else if (strcmp(oarg, "oi") == 0) {
447 break;
448 case 'i':
449 opt_i = TRUE;
450 exit_failure = FALSE; /* may override -oem */ 445 exit_failure = FALSE; /* may override -oem */
451 break; 446 } else if (strcmp(oarg, "om") == 0) {
452 case 'm': 447 /* ignore ``me too'' switch */
453 /* ignore -m (me too) switch (see man page) */ 448 } else {
454 break; 449 fprintf(stderr, "ignoring unrecognized option %s\n",
450 argv[arg]);
455 } 451 }
456 break; 452 break;
457 453
458 case 'q': 454 case 'q':
459 { 455 {
473 queue_interval = time_interval(optarg, &pos); 469 queue_interval = time_interval(optarg, &pos);
474 } 470 }
475 } 471 }
476 break; 472 break;
477 case 't': 473 case 't':
478 if (argv[arg][pos] == 0) { 474 if (argv[arg][pos] == '\0') {
479 opt_t = TRUE; 475 opt_t = TRUE;
480 } else { 476 } else {
481 fprintf(stderr, "unrecognized option '%s'\n", argv[arg]); 477 fprintf(stderr, "unrecognized option '%s'\n", argv[arg]);
482 exit(EXIT_FAILURE); 478 exit(EXIT_FAILURE);
483 } 479 }
668 if (pw) { 664 if (pw) {
669 for (; arg < argc; arg++) { 665 for (; arg < argc; arg++) {
670 message *msg = msg_spool_read(argv[arg], FALSE); 666 message *msg = msg_spool_read(argv[arg], FALSE);
671 #ifdef ENABLE_IDENT 667 #ifdef ENABLE_IDENT
672 if (((msg->received_host == NULL) && (msg->received_prot == PROT_LOCAL)) 668 if (((msg->received_host == NULL) && (msg->received_prot == PROT_LOCAL))
673 || is_in_netlist(msg->received_host, conf.ident_trusted_nets)) { 669 || is_in_netlist(msg->received_host, conf.ident_trusted_nets))
674 #else 670 #else
675 if ((msg->received_host == NULL) && (msg->received_prot == PROT_LOCAL)) { 671 if ((msg->received_host == NULL) && (msg->received_prot == PROT_LOCAL))
676 #endif 672 #endif
673 {
677 if (msg->ident) { 674 if (msg->ident) {
678 if (strcmp(pw->pw_name, msg->ident) == 0) { 675 if (strcmp(pw->pw_name, msg->ident) == 0) {
679 if (queue_delete(argv[arg])) 676 if (queue_delete(argv[arg]))
680 ok = TRUE; 677 ok = TRUE;
681 } else { 678 } else {