file norming
This commit is contained in:
40
srcs/def_env.c
Normal file
40
srcs/def_env.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* def_env.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2020/02/01 15:53:22 by tmaze #+# #+# */
|
||||
/* Updated: 2020/02/01 15:53:34 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
t_env *def_env(void)
|
||||
{
|
||||
t_env *ret;
|
||||
t_env *n;
|
||||
char p[PATH_MAX];
|
||||
|
||||
n = ft_memalloc(sizeof(t_env));
|
||||
if (n != NULL && ((n->key = ft_strnew(3)) == NULL || !getcwd(p, PATH_MAX)))
|
||||
ft_envdelelem(&n);
|
||||
if (n != NULL)
|
||||
ft_strcpy(n->key, "PWD");
|
||||
if (n != NULL && (n->val = ft_strdup(p)) == NULL)
|
||||
ft_envdelelem(&n);
|
||||
if (n != NULL)
|
||||
ft_envaddend(&ret, n);
|
||||
n = ft_memalloc(sizeof(t_env));
|
||||
if (n != NULL && (n->key = ft_strnew(5)) == NULL)
|
||||
ft_envdelelem(&n);
|
||||
if (n != NULL)
|
||||
ft_strcpy(n->key, "SHLVL");
|
||||
if (n != NULL && (n->val = ft_strdup("1")) == NULL)
|
||||
ft_envdelelem(&n);
|
||||
if (n != NULL)
|
||||
ft_envaddend(&ret, n);
|
||||
return (ret);
|
||||
}
|
Reference in New Issue
Block a user