From 86382acdb6cc8a94f98f4d8fe8d60f24b13fdebe Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Mon, 20 Apr 2020 16:48:19 +0200 Subject: Good --- src/ft_d_define.h | 18 ++++++++++++++++++ src/ft_m_prompt.c | 21 +++++++++++++++++++++ src/ft_m_prompt.h | 19 +++++++++++++++++++ src/ft_s_init.c | 12 ++++++++++-- src/ft_s_init.h | 2 +- src/ft_s_struct.h | 1 + src/minishell.c | 14 +++++++++----- 7 files changed, 79 insertions(+), 8 deletions(-) create mode 100644 src/ft_d_define.h create mode 100644 src/ft_m_prompt.c create mode 100644 src/ft_m_prompt.h (limited to 'src') diff --git a/src/ft_d_define.h b/src/ft_d_define.h new file mode 100644 index 0000000..06cc2eb --- /dev/null +++ b/src/ft_d_define.h @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_d_define.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_D_DEFINE_H +#define FT_D_DEFINE_H + +#define FT_PS_ONE "minishell ~> " + +#endif diff --git a/src/ft_m_prompt.c b/src/ft_m_prompt.c new file mode 100644 index 0000000..5d0f80c --- /dev/null +++ b/src/ft_m_prompt.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_m_prompt.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include "ft_m_prompt.h" +#include "ft_s_struct.h" + +void + ft_m_prompt(t_msh *msh) +{ + ft_printf("%s", msh->ps_one); +} diff --git a/src/ft_m_prompt.h b/src/ft_m_prompt.h new file mode 100644 index 0000000..e16b24c --- /dev/null +++ b/src/ft_m_prompt.h @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_m_prompt.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_M_PROMPT_H +#define FT_M_PROMPT_H + +#include "ft_s_struct.h" + +void ft_m_prompt(t_msh *msh); +#endif diff --git a/src/ft_s_init.c b/src/ft_s_init.c index 103725b..0d27aa7 100644 --- a/src/ft_s_init.c +++ b/src/ft_s_init.c @@ -10,10 +10,12 @@ /* */ /* ************************************************************************** */ -#include +#include +#include "ft_d_define.h" +#include "ft_s_init.h" t_msh -*ft_init_msh(void) + *ft_init_msh(void) { t_msh *msh; @@ -21,6 +23,12 @@ t_msh { return (NULL); } + if (!(msh->ps_one = + (char*)malloc((ft_strlen(FT_PS_ONE) + 1) * sizeof(char)))) + { + return (NULL); + } + ft_strlcpy(msh->ps_one, FT_PS_ONE, ft_strlen(FT_PS_ONE)); msh->envp = NULL; msh->lcom = NULL; return (msh); diff --git a/src/ft_s_init.h b/src/ft_s_init.h index a941a80..ea28b24 100644 --- a/src/ft_s_init.h +++ b/src/ft_s_init.h @@ -13,8 +13,8 @@ #ifndef FT_S_INIT_H #define FT_S_INIT_H -#include #include +#include "ft_s_struct.h" t_msh *ft_init_msh(void); diff --git a/src/ft_s_struct.h b/src/ft_s_struct.h index e2150eb..3bfa76b 100644 --- a/src/ft_s_struct.h +++ b/src/ft_s_struct.h @@ -23,6 +23,7 @@ typedef struct s_com typedef struct s_msh { struct s_com *lcom; + char *ps_one; char **envp; } t_msh; diff --git a/src/minishell.c b/src/minishell.c index cc0798f..5d97ed6 100644 --- a/src/minishell.c +++ b/src/minishell.c @@ -13,6 +13,7 @@ #include #include "minishell.h" #include "ft_d_enum.h" +#include "ft_m_prompt.h" #include "ft_s_struct.h" #include "ft_s_init.h" #include "ft_s_destroy.h" @@ -26,16 +27,18 @@ main(int argc, (void)argc; (void)argv; + (void)envp; if (!(msh = ft_init_msh())) { return (FT_RET_ALLOC); } msh->envp = envp; - while (*msh->envp) - { - ft_printf("%s\n", *msh->envp); - msh->envp++; - } + ft_m_prompt(msh); + /* while (*msh->envp) */ + /* { */ + /* ft_printf("%s\n", *msh->envp); */ + /* msh->envp++; */ + /* } */ ft_s_destroy(msh); return (FT_RET_FINE); } @@ -48,6 +51,7 @@ main(int argc, ** b_ -> builtins related ** d_ -> defines related ** e_ -> exec related +** m_ -> core minishell related ** p_ -> parse related ** s_ -> structs related */ -- cgit v1.2.3