gameServer/ConfigFile.hs
changeset 4975 31da8979e5b1
parent 4974 078cd026a7b1
child 4982 3572eaf14340
--- a/gameServer/ConfigFile.hs	Mon Feb 28 22:28:43 2011 +0300
+++ b/gameServer/ConfigFile.hs	Thu Mar 03 22:15:13 2011 +0300
@@ -1,11 +1,23 @@
+{-# LANGUAGE RankNTypes #-}
 module ConfigFile where
 
+import Data.Maybe
 import Data.TConfig
+import qualified Data.ByteString.Char8 as B
 -------------------
 import CoreTypes
 
-readServerConfig :: ServerInfo -> IO ServerInfo
-readServerConfig = undefined
+readServerConfig serverInfo' = do
+    cfg <- readConfig "hedgewars-server.ini"
+    let si = serverInfo'{
+        dbHost = value "dbHost" cfg
+        , dbLogin = value "dbLogin" cfg
+        , dbPassword = value "dbPassword" cfg
+        , serverConfig = Just cfg
+    }
+    return si
+    where
+        value n c = B.pack . fromJust $ getValue n c
 
-writeServerConfig :: ServerInfo -> IO
+writeServerConfig :: ServerInfo c -> IO ()
 writeServerConfig = undefined