]> gitweb @ CieloNegro.org - blackboard-dns.git/commitdiff
Main.hs --> ServerMain.hs
authorPHO <pho@cielonegro.org>
Tue, 2 Jun 2009 03:29:21 +0000 (12:29 +0900)
committerPHO <pho@cielonegro.org>
Tue, 2 Jun 2009 03:29:21 +0000 (12:29 +0900)
GNUmakefile
Main.hs [deleted file]
ServerMain.hs [new file with mode: 0644]
blackboard-dns.buildinfo.in
blackboard-dns.cabal

index d6d702a4a461937c3e30162ec195aadffb76d886..2bb908fb3253dea6cae7c46043e6993d350d349d 100644 (file)
@@ -1,4 +1,4 @@
-RUN_COMMAND = ./dist/build/blackboard-dns/blackboard-dns
+RUN_COMMAND = ./dist/build/bbdns-server/bbdns-server
 
 include cabal-package.mk
 
diff --git a/Main.hs b/Main.hs
deleted file mode 100644 (file)
index 163d01e..0000000
--- a/Main.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-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
diff --git a/ServerMain.hs b/ServerMain.hs
new file mode 100644 (file)
index 0000000..833256f
--- /dev/null
@@ -0,0 +1,84 @@
+{-# 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
index a817b1c2e510dc3fb4d319679f3435957622187b..fed0e64980188cfd17b59e0898ecac203944fbc8 100644 (file)
@@ -1,4 +1,4 @@
 -- -*- haskell-cabal -*-
-Executable: blackboard-dns
+Executable: bbdns-server
 GHC-Options:
     -DLOCALSTATEDIR="@DDNS_LOCALSTATEDIR@"
index 5a68ea1ff0a757469e1a806bbaa341a5b588b53b..b66aa2209d62983638ac6046035af95ce76a23d5 100644 (file)
@@ -16,9 +16,10 @@ Extra-Source-Files:
     data/GNUmakefile
     data/GenDBModules.hs
 
-Executable blackboard-dns
+Executable bbdns-server
     Build-Depends:
-        HDBC, HDBC-sqlite3, base, haskelldb, haskelldb-hdbc-sqlite3
+        HDBC, HDBC-sqlite3, base, haskelldb, haskelldb-hdbc-sqlite3,
+        parseargs
 
     Other-Modules:
         DDNS.DB
@@ -27,7 +28,7 @@ Executable blackboard-dns
         DDNS.DBInfo
 
     Main-Is:
-        Main.hs
+        ServerMain.hs
 
     GHC-Options:
         -Wall