diff options
-rw-r--r-- | Makefile | 10 | ||||
-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 |
8 files changed, 85 insertions, 12 deletions
@@ -15,6 +15,7 @@ LFT_SRCS_DIR = ${LFT_DIR}src/ #--------------------------------- FILES --------------------------------------# #==============================================================================# SRCS_NAME = minishell.c +SRCS_NAME += ft_m_prompt.c SRCS_NAME += ft_s_init.c SRCS_NAME += ft_s_destroy.c #------------------------------------------------------------------------------# @@ -22,6 +23,7 @@ SRCS = $(addprefix ${SRCS_DIR}, ${SRCS_NAME}) #------------------------------------------------------------------------------# INCS_NAME = ft_s_struct.h INCS_NAME += ft_d_enum.h +INCS_NAME += ft_d_define.h INCS_NAME += $(patsubst %.c,%.h,${SRCS_NAME}) #------------------------------------------------------------------------------# INCS = $(addprefix ${SRCS_DIR}, ${INCS_NAME}) @@ -59,7 +61,7 @@ LFTRULE = all #------------------------------------------------------------------------------# ${OBJS_DIR}%.o: ${SRCS_DIR}%.c ${INCS} @${MKDIR} ${OBJS_DIR} - ${CC} -c ${CFLAGS} ${CDEFS} -I${SRCS_DIR} -I${LFT_INCS_DIR} -o $@ $< + ${CC} -c ${CFLAGS} ${CDEFS} -I${LFT_INCS_DIR} -o $@ $< #------------------------------------------------------------------------------# $(NAME): ${OBJS} ${LFT_SRCS} ${LFT_INCS_DIR}libft.h @$(MAKE) --no-print-directory -C ${LFT_DIR} ${LFTRULE} @@ -80,10 +82,10 @@ clean: @$(MAKE) --no-print-directory -C ${LFT_DIR} clean ${RM} ${OBJS_DIR} #------------------------------------------------------------------------------# -fclean: clean +fclean: clean @$(MAKE) --no-print-directory -C ${LFT_DIR} fclean - ${RM} ${NAME} ${NAME}.dSYM/ ${HISTFILE} + ${RM} ${NAME} ${NAME}.core ${NAME}.dSYM/ ${HISTFILE} #------------------------------------------------------------------------------# -re: fclean all +re: fclean all #------------------------------------------------------------------------------# .PHONY: all clean clean fclean re debug asan 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 */ |