From 154bd3dfe8b4a989a5324cffca011d4fe8c57e6b Mon Sep 17 00:00:00 2001 From: Justin Reichardt Date: Thu, 9 Dec 2021 15:02:58 -0600 Subject: [PATCH] Parses config file Parses the config file using cfgparseline --- src/rhosts.go | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/src/rhosts.go b/src/rhosts.go index a41ff6c..811dcd9 100644 --- a/src/rhosts.go +++ b/src/rhosts.go @@ -62,7 +62,8 @@ func main() { cfgfb := bufio.NewScanner(cfgf) cfgfb.Split(bufio.ScanLines) for res := cfgfb.Scan();res;res = cfgfb.Scan() { - fmt.Println(cfgfb.Text()) + state, body := cfgparseline(cfgfb.Text()) + log.Print(state, body) } err = cfgfb.Err() if err != nil { @@ -70,6 +71,50 @@ func main() { } } -func cfgparse(buf string) string{ - return "" +func cfgparseline(buf string) (uint8, string){ + // State options + // 0 - Init + // 1 - Error + // 2 - Comment + // 3 - Site + // 4 - Download + var state uint8= 0 + body :=buf[:] + for i:=0; i