90 lines
1.9 KiB
Go
90 lines
1.9 KiB
Go
package config
|
|
|
|
import (
|
|
"github.com/go-ini/ini"
|
|
)
|
|
|
|
type ice_server_t struct {
|
|
NAME string
|
|
ADDR string
|
|
PORT int
|
|
MOUNT string
|
|
USR string
|
|
PWD string
|
|
STYPE int
|
|
}
|
|
|
|
type ice_stream_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
|
|
IceServer ice_server_t
|
|
IceStream ice_stream_t
|
|
Archive archive_t
|
|
WWWport string
|
|
}
|
|
|
|
var Xcfg config_t
|
|
|
|
func Loadconfig(filename string) error {
|
|
|
|
ini, err := ini.Load(filename)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
Xcfg.IceServer.NAME = ini.Section("ice-server").Key("name").Value()
|
|
Xcfg.IceServer.ADDR = ini.Section("ice-server").Key("addr").Value()
|
|
Xcfg.IceServer.PORT, _ = ini.Section("ice-server").Key("port").Int()
|
|
Xcfg.IceServer.MOUNT = ini.Section("ice-server").Key("mount").Value()
|
|
Xcfg.IceServer.USR = ini.Section("ice-server").Key("usr").Value()
|
|
Xcfg.IceServer.PWD = ini.Section("ice-server").Key("pwd").Value()
|
|
|
|
Xcfg.IceStream.NAME = ini.Section("ice-stream").Key("name").Value()
|
|
Xcfg.IceStream.DESC = ini.Section("ice-stream").Key("desc").Value()
|
|
Xcfg.IceStream.GENRE = ini.Section("ice-stream").Key("genre").Value()
|
|
Xcfg.IceStream.URL = ini.Section("ice-stream").Key("url").Value()
|
|
Xcfg.IceStream.IRC = ini.Section("ice-stream").Key("irc").Value()
|
|
Xcfg.IceStream.AIM = ini.Section("ice-stream").Key("aim").Value()
|
|
Xcfg.IceStream.PUB = ini.Section("ice-stream").Key("pub").Value()
|
|
|
|
Xcfg.Archive.PATH = ini.Section("archive").Key("path").Value()
|
|
|
|
Xcfg.WWWport = ini.Section("www-server").Key("port").Value()
|
|
|
|
Xcfg.Archive.ALBUMS = make(map[uint32]Album_t)
|
|
|
|
return nil
|
|
|
|
} |