/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_envnew.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/12/05 14:54:55 by tmaze #+# #+# */ /* Updated: 2019/12/05 17:12:59 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" t_env *ft_envnew(char *env) { t_env *ret; int i; i = 0; ret = NULL; while (env[i] && env[i] != '=') i++; if (env[i] == '=' && (ret = (t_env*)ft_memalloc(sizeof(t_env))) != NULL) if ((ret->val = ft_strsub(env, i + 1, ft_strlen(env) - i - 1)) == NULL || (ret->key = ft_strsub(env, 0, i)) == NULL) ft_envdelelem(&ret); return (ret); }