4 # ferm, a firewall setup program that makes firewall rules easy!
6 # Copyright (C) 2001-2014 Max Kellermann
8 # Comments, questions, greetings and additions to this program
9 # may be sent to <ferm@foo-projects.org>
12 # This script is sorts the tables and chains in the ferm output so the
13 # unit test suite can use "diff" to verify it. It's a kludge that is
14 # necessary because ferm outputs these in random order (because Perl
26 if (/^(\w+)tables -t (\w+) -([NAP]) (\S+)/ or
27 /^(\w+)tables -t (\w+) -([FX])()$/) {
28 my $key = $3 eq 'P' ?
"$1 $2 $4" : "$1 $2 $4";
29 $key .= ' z' if $4 eq '';
30 my $array = $rules{$key} ||= [];
32 } elsif (/^\*(\S+)/) {
35 my $array = $rules{$key} ||= [];
38 my $key = $table . 'z';
39 my $array = $rules{$key} ||= [];
41 } elsif (/^(:)(\S+)/ or /^-(A) (\S+)/) {
42 my $key = $table . $1 . $2;
43 my $array = $rules{$key} ||= [];
50 foreach my $key (sort keys %rules) {
51 foreach my $line (@
{$rules{$key}}) {