diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-20 16:48:19 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-20 16:48:19 +0200 |
commit | 86382acdb6cc8a94f98f4d8fe8d60f24b13fdebe (patch) | |
tree | e9c89ec16372d95bf10e96e6707d2258b0ea1b68 /src | |
parent | Update (diff) | |
download | 42-minishell-86382acdb6cc8a94f98f4d8fe8d60f24b13fdebe.tar.gz 42-minishell-86382acdb6cc8a94f98f4d8fe8d60f24b13fdebe.tar.bz2 42-minishell-86382acdb6cc8a94f98f4d8fe8d60f24b13fdebe.tar.xz 42-minishell-86382acdb6cc8a94f98f4d8fe8d60f24b13fdebe.tar.zst 42-minishell-86382acdb6cc8a94f98f4d8fe8d60f24b13fdebe.zip |
Good
Diffstat (limited to '')
-rw-r--r-- | src/ft_d_define.h | 18 | ||||
-rw-r--r-- | src/ft_m_prompt.c | 21 | ||||
-rw-r--r-- | src/ft_m_prompt.h | 19 | ||||
-rw-r--r-- | src/ft_s_init.c | 12 | ||||
-rw-r--r-- | src/ft_s_init.h | 2 | ||||
-rw-r--r-- | src/ft_s_struct.h | 1 | ||||
-rw-r--r-- | src/minishell.c | 14 |
7 files changed, 79 insertions, 8 deletions
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 <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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 <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include <libft.h> +#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 <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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 <ft_s_init.h> +#include <libft.h> +#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 <ft_s_struct.h> #include <stdlib.h> +#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 <libft.h> #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 */ |