#ifndef SHELL_H
#define SHELL_H
#include <stdbool.h>
#include "ast.h"

void initialize(void);

struct tree_node;
void run_command(struct tree_node* n);

int parse_tree(node_t *node, bool c_fork, bool c_wait);
int fork_func(int (*f)(node_t *), node_t *arg_node, bool c_wait);
int fork_extr(int (*f)(node_t *, bool, bool),
              node_t *arg_node,
              bool c_fork,
              bool c_wait);
int cmd_exit(node_t *node);
int cmd_exec(node_t *node);
int cmd_set(node_t *node);
int parse_command(node_t *node, bool c_fork, bool c_wait);
int parse_sequence(node_t *node, bool c_fork, bool c_wait);
int child_pipe(node_t *node, int p_pos, int *fd, int fd_in);
int parse_pipe(node_t *node, bool c_wait);
int child_red(node_t *node, int fd_o, int fd_n);
int get_flags(node_t *node);
int get_o_fd(node_t *node);
int parse_red(node_t *node);
int parse_det(node_t *node);
int parse_sub(node_t *node);
int parse_tree(node_t *node, bool c_fork, bool c_wait);

#endif
