#include #include #include "read.h" #include "nodelink.h" #include "strbst.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 } static void printnode(node* root) { printeach(root->links->head, 1); } static void listeach(strbstnode* loc) { if (loc == NULL) return; listeach(loc->left); listeach(loc->right); printf("Got %s\n",loc->ind); } int main() { node* root = readfile("template"); listeach(root->links->head); printnode(root); return 0; }