/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* b_export_next.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 "b_export_next.h" #include "f_fail.h" #include "s_struct.h" static char **b_get_var(const char arg[], t_msh *msh) { size_t len; char **var; if ((var = (char**)malloc(3 * sizeof(char*))) == NULL) f_fail_alloc_and_destroy(msh); len = 0; while (arg[len] != '=' && arg[len] != '\0') len++; len += 1; if ((var[FT_VAR_NAME] = (char*)malloc((len) * sizeof(char))) == NULL) f_fail_alloc_and_destroy(msh); ft_strlcpy(var[FT_VAR_NAME], arg, len); if ((var[FT_VAR_VAL] = ft_strdup(arg + len)) == NULL) f_fail_alloc_and_destroy(msh); var[FT_VAR_NULL] = NULL; return (var); } void b_export_with_equals(const char arg[], t_msh *msh) { char **var; var = b_get_var(arg, msh); ft_delwords(var); }