-- ExitSuccess).
--
module ExitCodes (
+ exit_host_blacklisted,
exit_no_hosts,
exit_no_lists,
exit_unparseable_host,
exit_unparseable_list )
where
+-- | The most common error: some host exceeded the blacklist
+-- threshold.
+exit_host_blacklisted :: Int
+exit_host_blacklisted = 1
+
+
-- | No hosts were given on the command-line or in a config file.
--
exit_no_hosts :: Int
-exit_no_hosts = 1
+exit_no_hosts = 2
-- | No lists were given on the command-line or in a config file.
--
exit_no_lists :: Int
-exit_no_lists = 2
+exit_no_lists = 3
-- | The user gave us an RBL we couldn't parse.
--
exit_unparseable_list :: Int
-exit_unparseable_list = 3
+exit_unparseable_list = 4
-- | The user gave us a host we couldn't parse.
--
exit_unparseable_host :: Int
-exit_unparseable_host = 4
+exit_unparseable_host = 5
+{-# LANGUAGE DoAndIfThenElse #-}
+
module Main ( main )
where
import Data.Monoid ( (<>) )
import Text.Parsec ( ParseError, parse )
import System.Console.CmdArgs ( def )
-import System.Exit ( exitWith, ExitCode (ExitFailure) )
+import System.Exit ( exitSuccess, exitWith, ExitCode (ExitFailure) )
import System.IO ( hPutStrLn, stderr )
import CommandLine ( get_args )
import Configuration ( Configuration(..), merge_optional )
import ExitCodes (
+ exit_host_blacklisted,
exit_no_hosts,
exit_no_lists,
exit_unparseable_host,
Right hs -> do
listings <- concatMapM (lookup_rbl ls) hs
mapM_ (putStrLn . listing_message) listings
+ if null listings
+ then exitSuccess
+ else exitWith (ExitFailure exit_host_blacklisted)