X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FMain.hs;h=6fa7da9203645e193d177de6a97ffed87a7c7f97;hb=f81e236ab90102d8afd6d6080131b77d59e38348;hp=a3b1bfe4a811faad00f6e8503b58de540bd8703f;hpb=6c671cd410b81257514e1be76ca3f252ea69ccdb;p=hath.git diff --git a/src/Main.hs b/src/Main.hs index a3b1bfe..6fa7da9 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -4,7 +4,15 @@ 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, @@ -13,7 +21,6 @@ import CommandLine (help_set, parse_errors, parse_mode) -import IPv4Address import Octet -- Some exit codes, used in the ExitFailure constructor. @@ -54,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) @@ -123,10 +130,19 @@ main = do let regexes = map cidr_to_regex cidrs putStrLn $ alternate regexes Reduce -> do - mapM (putStrLn . show) (combine_all cidrs) + _ <- mapM (putStrLn . show) (combine_all cidrs) return () Dupe -> do - mapM (putStrLn . show) dupes + _ <- 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