/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* minishell.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mea +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/05/02 13:50:44 by narnaud #+# #+# */ /* Updated: 2022/05/06 13:30:59 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef MINISHELL_H # define MINISHELL_H # define ENVP_LIMIT 1024 # define PIPE_MAX_SIZE 8192 # define PATHS_MAX_SIZE 126 # define PROMPT_PREFIX 0 # define DEBUG 0 # include "libft/libft.h" # include # include # include # include # include # include # include # include # include # include # include # include typedef struct s_command { char **argv; int fd[2]; char *heredoc; struct s_command *next; struct s_command *prev; } t_command; typedef struct s_datas { char **envp; int exit_code; } t_datas; // ----------------------------------Errors.c int file_error(char *cmd, char *file, char *msg); // ----------------------------------Utils.c int is_empty(char *line); void halt(int ret_code); void sigs_handler(int sig_num); void nothing(int sig_num); void handle_status(t_datas *datas, int status); // ----------------------------------Builtins.c int close_minishell(int exit_code); int ft_echo(t_command *cmd); int ft_pwd(t_command *cmd); int ft_cd(t_command *cmd); // ----------------------------------Env.c int is_valid_identifier(char *ident); int ft_unset(t_datas *datas, t_command *cmd); int ft_env(t_datas *datas, t_command *cmd); int ft_export(t_datas *datas, t_command *cmd); // ----------------------------------Caller.c void exe(t_datas *datas, t_command *cmd); int builtin_call(t_datas *datas, t_command *cmd); int is_builtin(char *cmd); pid_t caller(t_datas *datas, t_command *cmd); int piper(t_datas *datas, t_command *cmd); // ----------------------------------Parser.c typedef enum e_type { WORD, PIPE, OUT, ADD, IN, HD, } t_type; typedef struct s_token { char *value; t_type type; struct s_token *next; } t_token; char *expend_str(t_datas *datas, char *line); size_t count_arguments(t_token *tok); void update_redir(t_datas *datas, t_command *cmd, t_token *tok); t_command *parser(t_datas *datas, t_token *tok, t_command *prev); // ----------------------------------Lexer.c typedef enum e_state { OLD_ST, ROOT_ST, S_QUOTE_ST, D_QUOTE_ST, } t_state; typedef struct s_lex { t_state state; t_type type; t_type next_type; t_token *tokens; int n_elem; } t_lexer; int create_token(t_lexer *lex, char str[]); int check_register(t_lexer *lex, char **line, char *tmp); int replace_var(t_datas *datas, char **line, char *tmp, int tmp_i); int check_state(t_lexer *lex, char **line); t_token *lexer(t_datas *datas, char *line); #endif