# HG changeset patch # User markus schnalke # Date 1288634006 10800 # Node ID 018cfd163f5cad3c9411b3accdaa3c0a234dcd00 # Parent 3c40f86d50e4daf5ea719fa841353d23124c91fc refactored processing of -oXXX options plus two minor things diff -r 3c40f86d50e4 -r 018cfd163f5c src/masqmail.c --- a/src/masqmail.c Mon Nov 01 13:30:02 2010 -0300 +++ b/src/masqmail.c Mon Nov 01 14:53:26 2010 -0300 @@ -304,8 +304,6 @@ gint queue_interval = 0; gboolean opt_t = FALSE; gboolean opt_i = FALSE; - gboolean opt_odb = FALSE; - gboolean opt_oem = FALSE; gboolean exit_failure = FALSE; gchar *M_cmd = NULL; @@ -432,26 +430,24 @@ /* ignore -m (me too) switch (see man page) */ break; case 'o': - switch (argv[arg][pos++]) { - case 'e': - if (argv[arg][pos++] == 'm') /* -oem */ - if (!opt_i) - exit_failure = TRUE; - opt_oem = TRUE; - break; - case 'd': - if (argv[arg][pos] == 'b') /* -odb */ - opt_odb = TRUE; - else if (argv[arg][pos] == 'q') /* -odq */ - do_queue = TRUE; - break; - case 'i': - opt_i = TRUE; + char* oarg = argv[arg][pos+1]; + if (strcmp(oarg, "oem") == 0) { + if (!opt_i) { + /* FIXME: this check needs to be done after + option processing as -oi may come later */ + exit_failure = TRUE; + } + } else if (strcmp(oarg, "odb") == 0) { + /* ignore ``deliver in background'' switch */ + } else if (strcmp(oarg, "odq") == 0) { + do_queue = TRUE; + } else if (strcmp(oarg, "oi") == 0) { exit_failure = FALSE; /* may override -oem */ - break; - case 'm': - /* ignore -m (me too) switch (see man page) */ - break; + } else if (strcmp(oarg, "om") == 0) { + /* ignore ``me too'' switch */ + } else { + fprintf(stderr, "ignoring unrecognized option %s\n", + argv[arg]); } break; @@ -475,7 +471,7 @@ } break; case 't': - if (argv[arg][pos] == 0) { + if (argv[arg][pos] == '\0') { opt_t = TRUE; } else { fprintf(stderr, "unrecognized option '%s'\n", argv[arg]); @@ -670,10 +666,11 @@ message *msg = msg_spool_read(argv[arg], FALSE); #ifdef ENABLE_IDENT if (((msg->received_host == NULL) && (msg->received_prot == PROT_LOCAL)) - || is_in_netlist(msg->received_host, conf.ident_trusted_nets)) { + || is_in_netlist(msg->received_host, conf.ident_trusted_nets)) #else - if ((msg->received_host == NULL) && (msg->received_prot == PROT_LOCAL)) { + if ((msg->received_host == NULL) && (msg->received_prot == PROT_LOCAL)) #endif + { if (msg->ident) { if (strcmp(pw->pw_name, msg->ident) == 0) { if (queue_delete(argv[arg]))