diff options
Diffstat (limited to 'src/b_export_next.c')
-rw-r--r-- | src/b_export_next.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/b_export_next.c b/src/b_export_next.c index 2641f65..f0bb804 100644 --- a/src/b_export_next.c +++ b/src/b_export_next.c @@ -11,13 +11,40 @@ /* ************************************************************************** */ #include <libft.h> +#include <stdlib.h> +#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) { - (void)arg; - (void)msh; + char **var; + + var = b_get_var(arg, msh); + ft_delwords(var); } |