masqmail
diff 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 |
line diff
1.1 --- a/src/masqmail.c Mon Nov 01 13:30:02 2010 -0300 1.2 +++ b/src/masqmail.c Mon Nov 01 14:53:26 2010 -0300 1.3 @@ -304,8 +304,6 @@ 1.4 gint queue_interval = 0; 1.5 gboolean opt_t = FALSE; 1.6 gboolean opt_i = FALSE; 1.7 - gboolean opt_odb = FALSE; 1.8 - gboolean opt_oem = FALSE; 1.9 gboolean exit_failure = FALSE; 1.10 1.11 gchar *M_cmd = NULL; 1.12 @@ -432,26 +430,24 @@ 1.13 /* ignore -m (me too) switch (see man page) */ 1.14 break; 1.15 case 'o': 1.16 - switch (argv[arg][pos++]) { 1.17 - case 'e': 1.18 - if (argv[arg][pos++] == 'm') /* -oem */ 1.19 - if (!opt_i) 1.20 - exit_failure = TRUE; 1.21 - opt_oem = TRUE; 1.22 - break; 1.23 - case 'd': 1.24 - if (argv[arg][pos] == 'b') /* -odb */ 1.25 - opt_odb = TRUE; 1.26 - else if (argv[arg][pos] == 'q') /* -odq */ 1.27 - do_queue = TRUE; 1.28 - break; 1.29 - case 'i': 1.30 - opt_i = TRUE; 1.31 + char* oarg = argv[arg][pos+1]; 1.32 + if (strcmp(oarg, "oem") == 0) { 1.33 + if (!opt_i) { 1.34 + /* FIXME: this check needs to be done after 1.35 + option processing as -oi may come later */ 1.36 + exit_failure = TRUE; 1.37 + } 1.38 + } else if (strcmp(oarg, "odb") == 0) { 1.39 + /* ignore ``deliver in background'' switch */ 1.40 + } else if (strcmp(oarg, "odq") == 0) { 1.41 + do_queue = TRUE; 1.42 + } else if (strcmp(oarg, "oi") == 0) { 1.43 exit_failure = FALSE; /* may override -oem */ 1.44 - break; 1.45 - case 'm': 1.46 - /* ignore -m (me too) switch (see man page) */ 1.47 - break; 1.48 + } else if (strcmp(oarg, "om") == 0) { 1.49 + /* ignore ``me too'' switch */ 1.50 + } else { 1.51 + fprintf(stderr, "ignoring unrecognized option %s\n", 1.52 + argv[arg]); 1.53 } 1.54 break; 1.55 1.56 @@ -475,7 +471,7 @@ 1.57 } 1.58 break; 1.59 case 't': 1.60 - if (argv[arg][pos] == 0) { 1.61 + if (argv[arg][pos] == '\0') { 1.62 opt_t = TRUE; 1.63 } else { 1.64 fprintf(stderr, "unrecognized option '%s'\n", argv[arg]); 1.65 @@ -670,10 +666,11 @@ 1.66 message *msg = msg_spool_read(argv[arg], FALSE); 1.67 #ifdef ENABLE_IDENT 1.68 if (((msg->received_host == NULL) && (msg->received_prot == PROT_LOCAL)) 1.69 - || is_in_netlist(msg->received_host, conf.ident_trusted_nets)) { 1.70 + || is_in_netlist(msg->received_host, conf.ident_trusted_nets)) 1.71 #else 1.72 - if ((msg->received_host == NULL) && (msg->received_prot == PROT_LOCAL)) { 1.73 + if ((msg->received_host == NULL) && (msg->received_prot == PROT_LOCAL)) 1.74 #endif 1.75 + { 1.76 if (msg->ident) { 1.77 if (strcmp(pw->pw_name, msg->ident) == 0) { 1.78 if (queue_delete(argv[arg]))