aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2023-12-15 20:20:20 +0100
committerJoe <rbo@gmx.us>2023-12-15 20:20:20 +0100
commit8945d49e7ae4b96b2919fd074c03623a7c65b8f8 (patch)
treea538134f49219d34aee0b762e8d7b40a42598e20
parentnew stuff (diff)
downloadhardflip-8945d49e7ae4b96b2919fd074c03623a7c65b8f8.tar.gz
hardflip-8945d49e7ae4b96b2919fd074c03623a7c65b8f8.tar.bz2
hardflip-8945d49e7ae4b96b2919fd074c03623a7c65b8f8.tar.xz
hardflip-8945d49e7ae4b96b2919fd074c03623a7c65b8f8.tar.zst
hardflip-8945d49e7ae4b96b2919fd074c03623a7c65b8f8.zip
good parsing
Diffstat (limited to '')
-rw-r--r--c_init.go15
-rw-r--r--c_josh.go9
-rw-r--r--c_lhosts.go2
-rw-r--r--c_parse.go2
4 files changed, 18 insertions, 10 deletions
diff --git a/c_init.go b/c_init.go
index c3710c6..d5af2e8 100644
--- a/c_init.go
+++ b/c_init.go
@@ -84,21 +84,24 @@ func c_get_data_dir() string {
// this function recurses into the specified root directory in order to load
// every yaml file into memory
-func c_recurse_data_dir(dir string, root string) {
+func c_recurse_data_dir(dir string, root string, lhost *HostList) {
files, err := ioutil.ReadDir(root + dir)
if err != nil {
c_die("could not read data directory", err)
}
for _, file := range files {
if file.IsDir() == true {
- c_recurse_data_dir(dir + file.Name() + "/", root)
+ c_recurse_data_dir(dir + file.Name() + "/", root, lhost)
} else if filepath.Ext(file.Name()) == ".yml" {
- fmt.Println(root + dir + file.Name())
- c_read_yaml_file(root + dir + file.Name())
+ fmt.Println(dir + file.Name())
+ host := c_read_yaml_file(root + dir + file.Name())
+ lhost.add_back(host)
}
}
}
-func c_load_data_dir(dir string) {
- c_recurse_data_dir("", dir + "/")
+func c_load_data_dir(dir string) *HostList {
+ lhost := HostList{}
+ c_recurse_data_dir("", dir + "/", &lhost)
+ return &lhost
}
diff --git a/c_josh.go b/c_josh.go
index 05e1f79..0f999d2 100644
--- a/c_josh.go
+++ b/c_josh.go
@@ -47,9 +47,16 @@
package main
+import "fmt"
+
func main() {
var data_dir string
data_dir = c_get_data_dir()
- c_load_data_dir(data_dir)
+ lhost := c_load_data_dir(data_dir)
+ curr := lhost.head
+ for curr != nil {
+ fmt.Println(*curr)
+ curr = curr.next
+ }
}
diff --git a/c_lhosts.go b/c_lhosts.go
index d2cb992..aa32681 100644
--- a/c_lhosts.go
+++ b/c_lhosts.go
@@ -39,7 +39,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* josh: src/c_lhosts.go
- * Fri, 15 Dec 2023 10:01:11 +0100
+ * Fri, 15 Dec 2023 11:43:34 +0100
* Joe
*
* the hosts linked list
diff --git a/c_parse.go b/c_parse.go
index eef9ee1..dcaa6a8 100644
--- a/c_parse.go
+++ b/c_parse.go
@@ -48,7 +48,6 @@
package main
import (
- "fmt"
"io/ioutil"
"gopkg.in/yaml.v3"
)
@@ -69,6 +68,5 @@ func c_read_yaml_file(file string) *HostNode {
if host.Port == 0 {
host.Port = 22
}
- fmt.Println(host)
return &host
}