diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-20 15:34:34 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-20 15:34:34 +0200 |
commit | a4c02cf9a4d13dc81b015a6acc19628e48b7367b (patch) | |
tree | a002631374e42f7c2580560748d1d94774bafa1a /src | |
parent | More info (diff) | |
download | 42-minishell-a4c02cf9a4d13dc81b015a6acc19628e48b7367b.tar.gz 42-minishell-a4c02cf9a4d13dc81b015a6acc19628e48b7367b.tar.bz2 42-minishell-a4c02cf9a4d13dc81b015a6acc19628e48b7367b.tar.xz 42-minishell-a4c02cf9a4d13dc81b015a6acc19628e48b7367b.tar.zst 42-minishell-a4c02cf9a4d13dc81b015a6acc19628e48b7367b.zip |
Update
Diffstat (limited to '')
-rw-r--r-- | src/ft_d_enum.h | 2 | ||||
-rw-r--r-- | src/ft_s_destroy.c | 4 | ||||
-rw-r--r-- | src/ft_s_destroy.h | 2 | ||||
-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 | 14 | ||||
-rw-r--r-- | src/minishell.c | 28 | ||||
-rw-r--r-- | src/minishell.h | 4 |
8 files changed, 39 insertions, 29 deletions
diff --git a/src/ft_d_enum.h b/src/ft_d_enum.h index ef276c8..c34f296 100644 --- a/src/ft_d_enum.h +++ b/src/ft_d_enum.h @@ -24,6 +24,6 @@ enum { FT_RET_FINE, FT_RET_ALLOC -} +}; #endif diff --git a/src/ft_s_destroy.c b/src/ft_s_destroy.c index ffb8381..ef132ce 100644 --- a/src/ft_s_destroy.c +++ b/src/ft_s_destroy.c @@ -14,7 +14,7 @@ #include "ft_s_destroy.h" void -ft_s_destroy(t_data *data) +ft_s_destroy(t_msh *msh) { - ft_memdel((void*)&data); + ft_memdel((void*)&msh); } diff --git a/src/ft_s_destroy.h b/src/ft_s_destroy.h index 0d6d030..68a5c09 100644 --- a/src/ft_s_destroy.h +++ b/src/ft_s_destroy.h @@ -15,6 +15,6 @@ #include "ft_s_struct.h" -void ft_s_destroy(t_data *data); +void ft_s_destroy(t_msh *msh); #endif diff --git a/src/ft_s_init.c b/src/ft_s_init.c index 82293be..103725b 100644 --- a/src/ft_s_init.c +++ b/src/ft_s_init.c @@ -12,14 +12,16 @@ #include <ft_s_init.h> -t_data -*ft_init_data(void) +t_msh +*ft_init_msh(void) { - t_data *data; + t_msh *msh; - if (!(data = (t_data*)malloc(sizeof(t_data)))) + if (!(msh = (t_msh*)malloc(sizeof(t_msh)))) { return (NULL); } - return (data); + msh->envp = NULL; + msh->lcom = NULL; + return (msh); } diff --git a/src/ft_s_init.h b/src/ft_s_init.h index 8297a5e..a941a80 100644 --- a/src/ft_s_init.h +++ b/src/ft_s_init.h @@ -16,6 +16,6 @@ #include <ft_s_struct.h> #include <stdlib.h> -t_data *ft_init_data(void); +t_msh *ft_init_msh(void); #endif diff --git a/src/ft_s_struct.h b/src/ft_s_struct.h index 3d3d8a7..e2150eb 100644 --- a/src/ft_s_struct.h +++ b/src/ft_s_struct.h @@ -13,9 +13,17 @@ #ifndef FT_S_STRUCT_H #define FT_S_STRUCT_H -typedef struct s_data +typedef struct s_com { - char **envp; -} t_data; + char *com; + char **args; + struct s_com *next; +} t_com; + +typedef struct s_msh +{ + struct s_com *lcom; + char **envp; +} t_msh; #endif diff --git a/src/minishell.c b/src/minishell.c index cd08a64..cc0798f 100644 --- a/src/minishell.c +++ b/src/minishell.c @@ -12,29 +12,32 @@ #include <libft.h> #include "minishell.h" +#include "ft_d_enum.h" +#include "ft_s_struct.h" +#include "ft_s_init.h" +#include "ft_s_destroy.h" int main(int argc, const char *argv[], char *envp[]) { - t_data *data; + t_msh *msh; (void)argc; (void)argv; - (void)envp; - if (!(data = ft_init_data())) + if (!(msh = ft_init_msh())) { - return (1); + return (FT_RET_ALLOC); } - data->envp = envp; - while (*data->envp) + msh->envp = envp; + while (*msh->envp) { - ft_printf("%s\n", *data->envp); - data->envp++; + ft_printf("%s\n", *msh->envp); + msh->envp++; } - ft_s_destroy(data); - return (0); + ft_s_destroy(msh); + return (FT_RET_FINE); } /* @@ -42,8 +45,9 @@ main(int argc, ** Files prefixes info ** ------------------- ** ft_ -> 42 -** s_ -> structs related +** b_ -> builtins related ** d_ -> defines related -** p_ -> parse related ** e_ -> exec related +** p_ -> parse related +** s_ -> structs related */ diff --git a/src/minishell.h b/src/minishell.h index 5e50303..a30d8bc 100644 --- a/src/minishell.h +++ b/src/minishell.h @@ -13,8 +13,4 @@ #ifndef MINISHELL_H #define MINISHELL_H -#include "ft_s_struct.h" -#include "ft_s_init.h" -#include "ft_s_destroy.h" - #endif |