From a615b966525be7f609eebe19a508c77d51726b05 Mon Sep 17 00:00:00 2001 From: Bart De Schuymer Date: Sun, 3 Nov 2002 14:54:09 +0000 Subject: allow ! - option, equivalent with - ! option --- ebtables.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'ebtables.c') diff --git a/ebtables.c b/ebtables.c index c057f09..c6d3100 100644 --- a/ebtables.c +++ b/ebtables.c @@ -1436,13 +1436,17 @@ static void check_for_references(int chain_nr) } } +static int invert = 0; int check_inverse(const char option[]) { if (strcmp(option, "!") == 0) { + if (invert == 1) + print_error("double use of '!' not allowed"); optind++; + invert = 1; return 1; } - return 0; + return invert; } void check_option(unsigned int *flags, unsigned int mask) @@ -1499,6 +1503,8 @@ int main(int argc, char *argv[]) struct ebt_u_entries *entries; const char *modprobe = NULL; + opterr = 0; + // initialize the table name, OPT_ flags, selected hook and command strcpy(replace.name, "filter"); replace.flags = 0; @@ -1993,7 +1999,14 @@ int main(int argc, char *argv[]) replace.filename = (char *)malloc(strlen(optarg) + 1); strcpy(replace.filename, optarg); break; - + case 1 : + if (!strcmp(optarg, "!")) + check_inverse(optarg); + else + print_error("Bad argument : %s", optarg); + // check_inverse() did optind++ + optind--; + continue; default: // is it a target option? t = (struct ebt_u_target *)new_entry->t; @@ -2028,6 +2041,7 @@ check_extension: replace.command != 'D') print_error("Extensions only for -A, -I and -D"); } + invert = 0; } if ( !table && !(table = find_table(replace.name)) ) -- cgit v1.2.3