aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolden Rohrer <hr@hrhr.dev>2020-06-14 20:53:17 -0400
committerHolden Rohrer <hr@hrhr.dev>2020-06-14 20:53:54 -0400
commit3ef0e73864d21e2cb96c1c03b09324a665de070e (patch)
treebc3db42a292e6735e5519176ce5fecab16c89b82
parentfd74d59f307bfb50c58e710b96f8b576467cf5de (diff)
moved print statement to main.c
-rw-r--r--main.c27
-rw-r--r--nodelink.c26
-rw-r--r--nodelink.h2
3 files changed, 27 insertions, 28 deletions
diff --git a/main.c b/main.c
index 6c3a617..1a797aa 100644
--- a/main.c
+++ b/main.c
@@ -1,6 +1,33 @@
#include <stdio.h>
+#include <string.h>
#include "read.h"
+#include "nodelink.h"
+
+static void printlink(char* name, link* conn) {
+ if (conn->desc[0])
+ printf("%s: %s", name, conn->desc);
+ else
+ printf("%s\n", name);
+}
+
+static void printeach(strbstnode* loc, char reprint) {
+ if (loc == NULL) return;
+ // loc->ind is the name of the connection and loc->data the link
+ if (!reprint) printf(" "); // indent on subnode
+ printlink(loc->ind, loc->data); // prints it
+ // and subnodes if iterating over root tree (except root link)
+ if (reprint && strcmp(loc->ind,"")) {
+ // prints the link's target's link tree
+ printeach( ( (link*)loc->data)->to->links->head, 0);
+ }
+ printeach(loc->left, reprint);
+ printeach(loc->right, reprint); // recursion
+}
+
+void printnode(node* root) {
+ printeach(root->links->head, 1);
+}
int main() {
node* root = readfile("template");
diff --git a/nodelink.c b/nodelink.c
index aaf8c18..d66bed4 100644
--- a/nodelink.c
+++ b/nodelink.c
@@ -1,6 +1,5 @@
#include <stdlib.h>
#include <stdio.h>
-#include <string.h>
#include "nodelink.h"
#include "strbst.h"
@@ -23,28 +22,3 @@ link* newlink(node* to) {
new->to = to;
return new;
}
-
-static void printlink(char* name, link* conn) {
- if (conn->desc[0])
- printf("%s: %s", name, conn->desc);
- else
- printf("%s\n", name);
-}
-
-static void printeach(strbstnode* loc, char reprint) {
- if (loc == NULL) return;
- // loc->ind is the name of the connection and loc->data the link
- if (!reprint) printf(" "); // indent on subnode
- printlink(loc->ind, loc->data); // prints it
- // and subnodes if iterating over root tree (except root link)
- if (reprint && strcmp(loc->ind,"")) {
- // prints the link's target's link tree
- printeach( ( (link*)loc->data)->to->links->head, 0);
- }
- printeach(loc->left, reprint);
- printeach(loc->right, reprint); // recursion
-}
-
-void printnode(node* root) {
- printeach(root->links->head, 1);
-}
diff --git a/nodelink.h b/nodelink.h
index a1d5eed..44598a5 100644
--- a/nodelink.h
+++ b/nodelink.h
@@ -15,6 +15,4 @@ typedef struct link {
node* newnode(void);
link* newlink(node* to);
-void printnode(node* root);
-
#endif