+++ /dev/null
-module Main where
-
-import DDNS.DBInfo
-import qualified Database.HDBC as RAW
-import qualified Database.HDBC.Sqlite3 as RAW
-import Database.HaskellDB.DBSpec
-import Database.HaskellDB.HDBC.SQLite3
-
-
-main :: IO ()
-main = do sqliteConnect "ddns.db" $ \ db ->
- dbSpecToDatabase db dbinfo
-
- rawCon <- RAW.connectSqlite3 "ddns.db"
- mapM_ (\ sql -> RAW.run rawCon sql []) indexDeclarations
- RAW.commit rawCon
- RAW.disconnect rawCon
--- /dev/null
+{-# LANGUAGE CPP #-}
+module Main where
+
+import Control.Monad
+{-
+import DDNS.DBInfo
+import qualified Database.HDBC as RAW
+import qualified Database.HDBC.Sqlite3 as RAW
+import Database.HaskellDB.DBSpec
+import Database.HaskellDB.HDBC.SQLite3
+-}
+import System.Console.ParseArgs
+
+data Options
+ = Help
+ | LSDir
+ | DNSPort
+ | HTTPSPort
+ | AllowTransfer
+ | Command
+ deriving (Show, Eq, Ord)
+
+arginfo :: [Arg Options]
+arginfo = [ Arg {
+ argIndex = Help
+ , argAbbr = Just 'h'
+ , argName = Just "help"
+ , argData = Nothing
+ , argDesc = "print this help."
+ }
+ , Arg {
+ argIndex = LSDir
+ , argAbbr = Just 'd'
+ , argName = Just "localstatedir"
+ -- LOCALSTATEDIR will be replaced by CPP
+ , argData = argDataDefaulted "DIR" ArgtypeString LOCALSTATEDIR
+ , argDesc = "specify the local state directory (def: " ++ LOCALSTATEDIR ++ ")."
+ }
+ , Arg {
+ argIndex = DNSPort
+ , argAbbr = Just 'p'
+ , argName = Just "dns-port"
+ , argData = argDataDefaulted "PORT" ArgtypeString "53"
+ , argDesc = "port to listen for DNS packets (default: 53)."
+ }
+ , Arg {
+ argIndex = HTTPSPort
+ , argAbbr = Just 'P'
+ , argName = Just "https-port"
+ , argData = argDataDefaulted "PORT" ArgtypeString "443"
+ , argDesc = "port to listen for HTTPS connections (def: 443)."
+ }
+ , Arg {
+ argIndex = AllowTransfer
+ , argAbbr = Just 'a'
+ , argName = Just "allow-transfer"
+ , argData = Nothing
+ , argDesc = "accept AXFR requests."
+ }
+ , Arg {
+ argIndex = Command
+ , argAbbr = Nothing
+ , argName = Nothing
+ , argData = argDataDefaulted "COMMAND" ArgtypeString "daemon"
+ , argDesc = "command to the server (default: \"daemon\")."
+ }
+ ]
+
+main :: IO ()
+main = do m <- parseArgsIO ArgsComplete arginfo
+ when (gotArg m Help)
+ $ usageError m "" `seq` return ()
+
+ usageError m "" `seq` return ()
+
+{-
+main = do sqliteConnect "ddns.db" $ \ db ->
+ dbSpecToDatabase db dbinfo
+
+ rawCon <- RAW.connectSqlite3 "ddns.db"
+ mapM_ (\ sql -> RAW.run rawCon sql []) indexDeclarations
+ RAW.commit rawCon
+ RAW.disconnect rawCon
+-}
\ No newline at end of file