From 39d80124439e6c164b5b0a758effe6df5a94b20e Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Mon, 24 Aug 2020 20:57:09 +0200 Subject: sqb in progress --- src/b_builtins.h | 1 + src/b_sqb.c | 33 +++++++++++++++++++++++++++++++++ src/b_sqb.h | 22 ++++++++++++++++++++++ src/m_funptr.c | 17 +++++++++-------- 4 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 src/b_sqb.c create mode 100644 src/b_sqb.h (limited to 'src') diff --git a/src/b_builtins.h b/src/b_builtins.h index f7e7e99..0cb430a 100644 --- a/src/b_builtins.h +++ b/src/b_builtins.h @@ -21,5 +21,6 @@ #include "b_pwd.h" #include "b_type.h" #include "b_unset.h" +#include "b_sqb.h" #endif diff --git a/src/b_sqb.c b/src/b_sqb.c new file mode 100644 index 0000000..312fd90 --- /dev/null +++ b/src/b_sqb.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* b_sqb.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 +#include + +#include "s_struct.h" +#include "u_utils.h" + +uint8_t + b_sqb(char *args[], + t_msh *msh) +{ + const uint64_t argc = u_builtins_get_argc((const char**)args); + + (void)msh; + if (ft_strncmp(args[argc - 1], "]", 2) != 0) + { + ft_dprintf(STDERR_FILENO, "[: missing ]\n"); + return (2); + } + return (0); +} diff --git a/src/b_sqb.h b/src/b_sqb.h new file mode 100644 index 0000000..c0cfcb8 --- /dev/null +++ b/src/b_sqb.h @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* b_sqb.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef B_SQB_H +#define B_SQB_H + +#include + +#include "s_struct.h" + +uint8_t b_sqb(char *args[], t_msh *msh); + +#endif diff --git a/src/m_funptr.c b/src/m_funptr.c index 2fdf4d1..a6b31f2 100644 --- a/src/m_funptr.c +++ b/src/m_funptr.c @@ -22,14 +22,15 @@ void init_buptr(t_msh *msh) { - msh->bu_ptr[0] = b_echo; - msh->bu_ptr[1] = b_cd; - msh->bu_ptr[2] = b_pwd; - msh->bu_ptr[3] = b_export; - msh->bu_ptr[4] = b_unset; - msh->bu_ptr[5] = b_env; - msh->bu_ptr[6] = b_exit; - msh->bu_ptr[7] = b_type; + msh->bu_ptr[FT_ID_ECHO] = b_echo; + msh->bu_ptr[FT_ID_CD] = b_cd; + msh->bu_ptr[FT_ID_PWD] = b_pwd; + msh->bu_ptr[FT_ID_EXPORT] = b_export; + msh->bu_ptr[FT_ID_UNSET] = b_unset; + msh->bu_ptr[FT_ID_ENV] = b_env; + msh->bu_ptr[FT_ID_EXIT] = b_exit; + msh->bu_ptr[FT_ID_TYPE] = b_type; + msh->bu_ptr[FT_ID_SQB] = b_sqb; if (!(msh->bu_ref = ft_split(FT_BUILTINS, '|'))) { f_alloc_and_destroy_msh(msh); -- cgit v1.2.3