haha
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/go-ini/ini"
|
||||
)
|
||||
|
||||
type server_t struct {
|
||||
NAME string
|
||||
ADDR string
|
||||
PORT int
|
||||
MOUNT string
|
||||
USR string
|
||||
PWD string
|
||||
STYPE int
|
||||
}
|
||||
|
||||
type ice_t struct {
|
||||
NAME string
|
||||
DESC string
|
||||
GENRE string
|
||||
URL string
|
||||
IRC string
|
||||
AIM string
|
||||
PUB string
|
||||
}
|
||||
|
||||
type Track_t struct {
|
||||
ID uint32
|
||||
AID uint32
|
||||
NAME string
|
||||
MAKER string
|
||||
ALBUM string
|
||||
PATH string
|
||||
}
|
||||
|
||||
type Album_t struct {
|
||||
ID uint32
|
||||
NAME string
|
||||
MAKER string
|
||||
PATH string
|
||||
COVER string
|
||||
TRACKS map[uint32]Track_t
|
||||
}
|
||||
|
||||
type archive_t struct {
|
||||
PATH string
|
||||
ALBUMS map[uint32]Album_t
|
||||
}
|
||||
|
||||
type config_t struct {
|
||||
Track Track_t
|
||||
Server server_t
|
||||
Ice ice_t
|
||||
Archive archive_t
|
||||
}
|
||||
|
||||
var Xcfg config_t
|
||||
|
||||
func Loadconfig(filename string) error {
|
||||
|
||||
ini, err := ini.Load(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Xcfg.Server.NAME = ini.Section("server").Key("name").Value()
|
||||
Xcfg.Server.ADDR = ini.Section("server").Key("addr").Value()
|
||||
Xcfg.Server.PORT, _ = ini.Section("server").Key("port").Int()
|
||||
Xcfg.Server.MOUNT = ini.Section("server").Key("mount").Value()
|
||||
Xcfg.Server.USR = ini.Section("server").Key("usr").Value()
|
||||
Xcfg.Server.PWD = ini.Section("server").Key("pwd").Value()
|
||||
|
||||
Xcfg.Ice.NAME = ini.Section("ice").Key("name").Value()
|
||||
Xcfg.Ice.DESC = ini.Section("ice").Key("desc").Value()
|
||||
Xcfg.Ice.GENRE = ini.Section("ice").Key("genre").Value()
|
||||
Xcfg.Ice.URL = ini.Section("ice").Key("url").Value()
|
||||
Xcfg.Ice.IRC = ini.Section("ice").Key("irc").Value()
|
||||
Xcfg.Ice.AIM = ini.Section("ice").Key("aim").Value()
|
||||
Xcfg.Ice.PUB = ini.Section("ice").Key("pub").Value()
|
||||
|
||||
Xcfg.Archive.PATH = ini.Section("archive").Key("path").Value()
|
||||
|
||||
|
||||
Xcfg.Archive.ALBUMS = make(map[uint32]Album_t)
|
||||
|
||||
return nil
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user