-import Data.List (intercalate, intersperse)
+import Data.List ((\\), intercalate, intersperse)
import System.Exit (ExitCode(..), exitWith)
import System.IO (stderr, hPutStrLn)
import Cidr (Cidr(..),
cidr_from_string,
- combine_all)
+ combine_all,
+ max_octet1,
+ max_octet2,
+ max_octet3,
+ max_octet4,
+ min_octet1,
+ min_octet2,
+ min_octet3,
+ min_octet4 )
import CommandLine (help_set,
help_text,
parse_errors,
parse_mode)
-import IPv4Address
import Octet
-- Some exit codes, used in the ExitFailure constructor.
range2 = numeric_range min2 max2
range3 = numeric_range min3 max3
range4 = numeric_range min4 max4
- min1 = octet_to_int (min_octet1 (ipv4address cidr) (maskbits cidr))
- min2 = octet_to_int (min_octet2 (ipv4address cidr) (maskbits cidr))
- min3 = octet_to_int (min_octet3 (ipv4address cidr) (maskbits cidr))
- min4 = octet_to_int (min_octet4 (ipv4address cidr) (maskbits cidr))
- max1 = octet_to_int (max_octet1 (ipv4address cidr) (maskbits cidr))
- max2 = octet_to_int (max_octet2 (ipv4address cidr) (maskbits cidr))
- max3 = octet_to_int (max_octet3 (ipv4address cidr) (maskbits cidr))
- max4 = octet_to_int (max_octet4 (ipv4address cidr) (maskbits cidr))
+ min1 = octet_to_int (min_octet1 cidr)
+ min2 = octet_to_int (min_octet2 cidr)
+ min3 = octet_to_int (min_octet3 cidr)
+ min4 = octet_to_int (min_octet4 cidr)
+ max1 = octet_to_int (max_octet1 cidr)
+ max2 = octet_to_int (max_octet2 cidr)
+ max3 = octet_to_int (max_octet3 cidr)
+ max4 = octet_to_int (max_octet4 cidr)
Reduce -> do
mapM (putStrLn . show) (combine_all cidrs)
return ()
+ Dupe -> do
+ mapM (putStrLn . show) dupes
+ return ()
+ where
+ dupes = cidrs \\ (combine_all cidrs)
+ Diff -> do
+ mapM putStrLn deletions
+ mapM putStrLn additions
+ return ()
+ where
+ dupes = cidrs \\ (combine_all cidrs)
+ deletions = map (\s -> "-" ++ (show s)) dupes
+ newcidrs = (combine_all cidrs) \\ cidrs
+ additions = map (\s -> "+" ++ (show s)) newcidrs