diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-07-27 18:55:07 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-07-27 18:55:07 +0200 |
commit | 487a66394061f2d14a2fa421302966b5442d643f (patch) | |
tree | 34237d4e9cb85f94bcefd46f399d2224dff3f6b3 /src/ft_s_init.c | |
parent | Correct shell prompt (diff) | |
download | 42-minishell-487a66394061f2d14a2fa421302966b5442d643f.tar.gz 42-minishell-487a66394061f2d14a2fa421302966b5442d643f.tar.bz2 42-minishell-487a66394061f2d14a2fa421302966b5442d643f.tar.xz 42-minishell-487a66394061f2d14a2fa421302966b5442d643f.tar.zst 42-minishell-487a66394061f2d14a2fa421302966b5442d643f.zip |
I couldn't see shit
Diffstat (limited to 'src/ft_s_init.c')
-rw-r--r-- | src/ft_s_init.c | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/src/ft_s_init.c b/src/ft_s_init.c deleted file mode 100644 index 88a3817..0000000 --- a/src/ft_s_init.c +++ /dev/null @@ -1,85 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_s_init.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 <stdint.h> -#include <stdlib.h> -#include <unistd.h> - -#include "ft_d_define.h" -#include "ft_m_funptr.h" -#include "ft_s_init.h" - -static char - **ft_dupenv_del(char **nenvp, - uint64_t i) -{ - while (i > 0) - { - ft_memdel((void*)&nenvp[i]); - i--; - } - ft_memdel((void*)&nenvp); - return (NULL); -} - -static char - **ft_dupenv(char *const envp[]) -{ - uint64_t i; - char **nenvp; - - i = 0; - while (envp[i]) - { - i++; - } - if (!(nenvp = (char**)malloc((i + 1) * sizeof(char*)))) - { - return (NULL); - } - i = 0; - while (envp[i]) - { - if (!(nenvp[i] = ft_strdup(envp[i]))) - return (ft_dupenv_del(nenvp, i)); - i++; - } - nenvp[i] = NULL; - return (nenvp); -} - -t_msh - *ft_init_msh(char *const argv[], - char *const envp[]) -{ - t_msh *msh; - - if (!(msh = (t_msh*)malloc(sizeof(t_msh)))) - return (NULL); - if (!(msh->ps_one = ft_strdup(FT_PS_ONE))) - return (NULL); - if (!(msh->shname = ft_strdup(argv[0]))) - return (NULL); - /* TODO: shname: care about "./", try with symlinks */ - msh->cwd = NULL; - msh->cwd = getcwd(NULL, 0); - /* TODO: handle getcwd failed */ - msh->envp = NULL; - if (!(msh->envp = ft_dupenv(envp))) - return (NULL); - msh->ret = 0; - ft_init_buptr(msh); - msh->curr = NULL; - msh->vars = NULL; - return (msh); -} |