author | unc0rr |
Sat, 05 Mar 2011 22:23:14 +0300 | |
changeset 4987 | cf9470964dba |
parent 4982 | 3572eaf14340 |
child 4988 | bd540ba66599 |
permissions | -rw-r--r-- |
4975
31da8979e5b1
Use Data.TConfig to read and store server config in hedgewars.ini (a little bit of hate to the author for not exporting Conf type)
unc0rr
parents:
4974
diff
changeset
|
1 |
{-# LANGUAGE RankNTypes #-} |
4974
078cd026a7b1
Add stubs for server config reading and writing routines
unc0rr
parents:
diff
changeset
|
2 |
module ConfigFile where |
078cd026a7b1
Add stubs for server config reading and writing routines
unc0rr
parents:
diff
changeset
|
3 |
|
4975
31da8979e5b1
Use Data.TConfig to read and store server config in hedgewars.ini (a little bit of hate to the author for not exporting Conf type)
unc0rr
parents:
4974
diff
changeset
|
4 |
import Data.Maybe |
4974
078cd026a7b1
Add stubs for server config reading and writing routines
unc0rr
parents:
diff
changeset
|
5 |
import Data.TConfig |
4975
31da8979e5b1
Use Data.TConfig to read and store server config in hedgewars.ini (a little bit of hate to the author for not exporting Conf type)
unc0rr
parents:
4974
diff
changeset
|
6 |
import qualified Data.ByteString.Char8 as B |
4974
078cd026a7b1
Add stubs for server config reading and writing routines
unc0rr
parents:
diff
changeset
|
7 |
------------------- |
078cd026a7b1
Add stubs for server config reading and writing routines
unc0rr
parents:
diff
changeset
|
8 |
import CoreTypes |
078cd026a7b1
Add stubs for server config reading and writing routines
unc0rr
parents:
diff
changeset
|
9 |
|
4975
31da8979e5b1
Use Data.TConfig to read and store server config in hedgewars.ini (a little bit of hate to the author for not exporting Conf type)
unc0rr
parents:
4974
diff
changeset
|
10 |
readServerConfig serverInfo' = do |
31da8979e5b1
Use Data.TConfig to read and store server config in hedgewars.ini (a little bit of hate to the author for not exporting Conf type)
unc0rr
parents:
4974
diff
changeset
|
11 |
cfg <- readConfig "hedgewars-server.ini" |
31da8979e5b1
Use Data.TConfig to read and store server config in hedgewars.ini (a little bit of hate to the author for not exporting Conf type)
unc0rr
parents:
4974
diff
changeset
|
12 |
let si = serverInfo'{ |
31da8979e5b1
Use Data.TConfig to read and store server config in hedgewars.ini (a little bit of hate to the author for not exporting Conf type)
unc0rr
parents:
4974
diff
changeset
|
13 |
dbHost = value "dbHost" cfg |
4982
3572eaf14340
Add dbName parameter to .ini file, fix some warnings
unc0rr
parents:
4975
diff
changeset
|
14 |
, dbName = value "dbName" cfg |
4975
31da8979e5b1
Use Data.TConfig to read and store server config in hedgewars.ini (a little bit of hate to the author for not exporting Conf type)
unc0rr
parents:
4974
diff
changeset
|
15 |
, dbLogin = value "dbLogin" cfg |
31da8979e5b1
Use Data.TConfig to read and store server config in hedgewars.ini (a little bit of hate to the author for not exporting Conf type)
unc0rr
parents:
4974
diff
changeset
|
16 |
, dbPassword = value "dbPassword" cfg |
31da8979e5b1
Use Data.TConfig to read and store server config in hedgewars.ini (a little bit of hate to the author for not exporting Conf type)
unc0rr
parents:
4974
diff
changeset
|
17 |
, serverConfig = Just cfg |
31da8979e5b1
Use Data.TConfig to read and store server config in hedgewars.ini (a little bit of hate to the author for not exporting Conf type)
unc0rr
parents:
4974
diff
changeset
|
18 |
} |
31da8979e5b1
Use Data.TConfig to read and store server config in hedgewars.ini (a little bit of hate to the author for not exporting Conf type)
unc0rr
parents:
4974
diff
changeset
|
19 |
return si |
31da8979e5b1
Use Data.TConfig to read and store server config in hedgewars.ini (a little bit of hate to the author for not exporting Conf type)
unc0rr
parents:
4974
diff
changeset
|
20 |
where |
31da8979e5b1
Use Data.TConfig to read and store server config in hedgewars.ini (a little bit of hate to the author for not exporting Conf type)
unc0rr
parents:
4974
diff
changeset
|
21 |
value n c = B.pack . fromJust $ getValue n c |
4974
078cd026a7b1
Add stubs for server config reading and writing routines
unc0rr
parents:
diff
changeset
|
22 |
|
4975
31da8979e5b1
Use Data.TConfig to read and store server config in hedgewars.ini (a little bit of hate to the author for not exporting Conf type)
unc0rr
parents:
4974
diff
changeset
|
23 |
writeServerConfig :: ServerInfo c -> IO () |
4974
078cd026a7b1
Add stubs for server config reading and writing routines
unc0rr
parents:
diff
changeset
|
24 |
writeServerConfig = undefined |