Moved config parsing to a seperate function
This will allow for easier looping later on when this can be run as a daemonstable
parent
154bd3dfe8
commit
ad1410410b
|
|
@ -53,24 +53,28 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse Config
|
// Parse Config
|
||||||
|
cfgparse(cfgloc)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func cfgparse (cfgloc string){
|
||||||
log.Print("Opening: ", cfgloc)
|
log.Print("Opening: ", cfgloc)
|
||||||
cfgf, err := os.Open(cfgloc)
|
file, err := os.Open(cfgloc)
|
||||||
defer cfgf.Close()
|
defer file.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
cfgfb := bufio.NewScanner(cfgf)
|
filebuf := bufio.NewScanner(file)
|
||||||
cfgfb.Split(bufio.ScanLines)
|
filebuf.Split(bufio.ScanLines)
|
||||||
for res := cfgfb.Scan();res;res = cfgfb.Scan() {
|
for res := filebuf.Scan();res;res = filebuf.Scan() {
|
||||||
state, body := cfgparseline(cfgfb.Text())
|
state, body := cfgparseline(filebuf.Text())
|
||||||
log.Print(state, body)
|
log.Print(state, body)
|
||||||
}
|
}
|
||||||
err = cfgfb.Err()
|
err = filebuf.Err()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func cfgparseline(buf string) (uint8, string){
|
func cfgparseline(buf string) (uint8, string){
|
||||||
// State options
|
// State options
|
||||||
// 0 - Init
|
// 0 - Init
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue