int print_node_pipe(NodeType *cmd, NodeType *pipe) { if (print_node_rec(cmd) < 0) return -1; if (pipe != NULL) { printf(" | "); if (print_node_rec(pipe) < 0) return -1; } return 0; }
int print_node_redir(NodeType *cmd, NodeType *file) { if (print_node_rec(cmd) < 0) { return -1; } printf(" > "); if (print_node_rec(file) < 0) { return -1; } return 0; }
//just a pretty way to print the nodes that is semi-readable and easy to code void print_node_rec(bst_n *node) { if(node == NULL) { printf("Empty Leaf\n"); return; } printf("%d\n", node->data); printf("%d ->\n", node->data); print_node_rec(node->right); printf("<- %d\n", node->data); print_node_rec(node->left); }
//cause I like recursive functions void print_tree(bst_t *tree) { if(tree == NULL || tree->head == NULL) { printf("Empty tree\n"); } else { print_node_rec(tree->head); } }
int print_node_cmd(char *cmd, NodeType *params) { printf("%s ", cmd); if (print_node_rec(params) < 0) { return -1; } return 0; }
int print_node(NodeType *pn) { int ret = print_node_rec(pn); printf("\n"); return ret; }
int print_node_pair(NodeType *car, NodeType *cdr) { if (print_node_rec(car) < 0) return -1; if (print_node_rec(cdr) < 0) return -1; return 0; }