diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/ast.h | 16 | ||||
| -rw-r--r-- | include/debug_tools.h | 9 | ||||
| -rw-r--r-- | include/env.h | 30 | ||||
| -rw-r--r-- | include/minishell.h | 40 | ||||
| -rw-r--r-- | include/token.h | 7 |
5 files changed, 78 insertions, 24 deletions
diff --git a/include/ast.h b/include/ast.h index cd2f9c9..0dede50 100644 --- a/include/ast.h +++ b/include/ast.h @@ -3,15 +3,17 @@ /* ::: :::::::: */ /* ast.h :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */ +/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/27 11:48:27 by dkaiser #+# #+# */ -/* Updated: 2024/08/11 12:20:56 by dkaiser ### ########.fr */ +/* Updated: 2025/01/18 19:28:51 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ -#include "debug_tools.h" -#include "stdlib.h" +#ifndef AST_H +# define AST_H +# include "debug_tools.h" +# include "stdlib.h" enum e_node_type { @@ -44,6 +46,7 @@ typedef struct s_cmd { char **args; struct s_redirection redirs[2]; + t_list *create_files; } t_cmd; union u_node_content @@ -61,7 +64,10 @@ typedef struct s_node t_node *new_node(int type); t_node *new_pipe_node(t_node *left, t_node *right); -t_node *new_cmd_node(char **args, t_redirection redirs[2]); +t_node *new_cmd_node(char **args, t_redirection redirs[2], + t_list *create_files); t_node *new_string_node(char *string); void free_node(t_node *node); + +#endif
\ No newline at end of file diff --git a/include/debug_tools.h b/include/debug_tools.h index 4a7ff10..a014ff1 100644 --- a/include/debug_tools.h +++ b/include/debug_tools.h @@ -3,17 +3,17 @@ /* ::: :::::::: */ /* debug_tools.h :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */ +/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/24 18:34:37 by dkaiser #+# #+# */ -/* Updated: 2024/06/28 15:05:12 by dkaiser ### ########.fr */ +/* Updated: 2025/01/20 17:56:01 by dkaiser ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef DEBUG_TOOLS_H # define DEBUG_TOOLS_H - # include "libft.h" +# include <stdarg.h> # ifndef DEBUG # define DEBUG 0 @@ -22,4 +22,7 @@ void dbg(char *str); void panic(char *msg); + +void dbg2(const char *format, ...); + #endif diff --git a/include/env.h b/include/env.h index a35bec3..bfb28c7 100644 --- a/include/env.h +++ b/include/env.h @@ -6,11 +6,14 @@ /* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/08 16:53:39 by dkaiser #+# #+# */ -/* Updated: 2024/10/25 19:53:38 by chuhlig ### ########.fr */ +/* Updated: 2025/01/20 16:48:57 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ -#include "libft.h" +#ifndef ENV_H +# define ENV_H +# include "libft.h" +# include <stdio.h> typedef struct s_env { @@ -19,7 +22,22 @@ typedef struct s_env struct s_env *next; } t_env; -void getenvlst(t_env **env, char **en); -void free_envlst(t_env **env); -char *env_get(t_env *env, char *name); -char **env_to_strlst(t_env *env);
\ No newline at end of file +void free_env_node(t_env *node); +void getenvlst(t_env **env, char **en); +void free_envlst(t_env **env); +char *env_get(t_env *env, char *name); +char **env_to_strlst(t_env *env); +void update_oldpwd(t_env **env); +void update_pwd(t_env **env); +int unset(char **av, t_env **env); +int export(char **av, t_env **env, int f); +int echo(char **av); +int pwd(t_env *env); +int cd(t_env **env, char **args); +int ft_env(t_env *env); +int builtin_exit(char **args, t_env **env); +t_env *env_new(char *name); +t_env *check_existing(t_env *env, char *av); +int check_flag(int f); + +#endif diff --git a/include/minishell.h b/include/minishell.h index b2a3845..356df7a 100644 --- a/include/minishell.h +++ b/include/minishell.h @@ -6,7 +6,7 @@ /* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/22 17:14:49 by dkaiser #+# #+# */ -/* Updated: 2024/10/25 16:10:21 by chuhlig ### ########.fr */ +/* Updated: 2025/01/20 19:12:03 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,19 +25,45 @@ # include <stdlib.h> # include <termios.h> # include <unistd.h> +# include <fcntl.h> int init(void); int init_signal_handling(void); -void repl(const char *prompt, t_env **env); +void repl(const char *prompt, t_env **env, int *promptflag); -t_list *parse(t_token *tokens); -t_node *parse_cmd(t_token *tokens); -t_redirection *collect_redirs(t_token **tokens); +t_list *parse(t_token *tokens, t_env **env); +t_node *parse_cmd(t_token *tokens, t_env **env); +t_redirection *collect_redirs(t_token **tokens, t_env *env, t_list **cf); void print_ast(t_node *ast); int eval(t_node *node, t_env **env); -char *get_cmd_path(char *cmd, t_env *env); -int execute_cmd(t_cmd *cmd, t_env *env); +char *get_cmd_path(char *cmd, t_env *env, int *return_code); +int execute_cmd(t_cmd *cmd, t_env **env); +char *format_string(char *str, t_env *env, int is_literal); +void set_return_code(int return_code, t_env **env); +int handle_redirections(t_redirection *redirs); +void *error(int err_code, char *err_text, int exit_code, + int *ret_code); +void command_not_found_error(char *cmd); +char *read_heredoc(char *delimiter); +int handle_input_redirection(t_redirection *redir); +int handle_output_redirection(t_redirection *redir); +int handle_redirections(t_redirection *redirs); +int handle_pipe_parent(int p[2], t_node *node, t_env **env); +int handle_pipe_child(int p[2], t_node *node, t_env **env, + int in_fd); +int open_file(char *path, int flags, int mode); +int eval_rec(t_node *node, t_env **env, int in_fd); +int create_files(t_list *files); +void q4fc(t_list **queue, t_redirection *redir); +void i_love_the_norme(t_token **cur, t_token **tokens); + +typedef struct s_minidata +{ + t_env *env; + t_list **create_files; +} t_minidata; + #endif diff --git a/include/token.h b/include/token.h index 7e2038a..2e8da35 100644 --- a/include/token.h +++ b/include/token.h @@ -6,7 +6,7 @@ /* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/27 13:27:18 by dkaiser #+# #+# */ -/* Updated: 2024/08/29 15:26:23 by dkaiser ### ########.fr */ +/* Updated: 2025/01/20 19:10:30 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,10 +43,11 @@ t_token *new_str_token(char *str, t_token *previous, t_token *next); t_token *new_redir_token(int type, t_token *previous, t_token *next); - +void free_tokens(t_token *tokens); void free_token(t_token *token); - +void free_token_and_connect(t_token *token); void tokenizer(char *s, t_token **token_list, char quote_check); +void print_token(t_token *token); #endif |
