X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FMain.hs;h=eeee9f6b6fe07f4ae40b580e093c818042b253c9;hb=75038b45b9c379d8313511e58c3c0fe680810883;hp=2fdcfd0459c1b2c88ecd2980e6de90a4a709cd95;hpb=78e436a8b3548f41f6c9bfd1db1b318a010f1472;p=hath.git diff --git a/src/Main.hs b/src/Main.hs index 2fdcfd0..eeee9f6 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -1,9 +1,18 @@ -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) + cidr_from_string, + combine_all, + max_octet1, + max_octet2, + max_octet3, + max_octet4, + min_octet1, + min_octet2, + min_octet3, + min_octet4 ) import CommandLine (help_set, help_text, @@ -12,7 +21,6 @@ import CommandLine (help_set, parse_errors, parse_mode) -import IPv4Address import Octet -- Some exit codes, used in the ExitFailure constructor. @@ -53,14 +61,14 @@ cidr_to_regex cidr = 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) @@ -122,4 +130,10 @@ main = do let regexes = map cidr_to_regex cidrs putStrLn $ alternate regexes Reduce -> do - putStr input + mapM (putStrLn . show) (combine_all cidrs) + return () + Dupe -> do + mapM (putStrLn . show) dupes + return () + where + dupes = cidrs \\ (combine_all cidrs)