summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/b_export.c1
-rw-r--r--src/b_export_next.c31
-rw-r--r--src/b_export_next.h7
3 files changed, 36 insertions, 3 deletions
diff --git a/src/b_export.c b/src/b_export.c
index fc1657e..7aeed93 100644
--- a/src/b_export.c
+++ b/src/b_export.c
@@ -89,7 +89,6 @@ uint8_t
const uint64_t argc = u_builtins_get_argc((const char**)args);
char **ptr;
char *varval;
- /* char *varname; */
char fmt[255];
t_bool next;
uint8_t r;
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);
}
diff --git a/src/b_export_next.h b/src/b_export_next.h
index 8df8746..c9d53ea 100644
--- a/src/b_export_next.h
+++ b/src/b_export_next.h
@@ -15,6 +15,13 @@
#include "s_struct.h"
+enum
+{
+ FT_VAR_NAME,
+ FT_VAR_VAL,
+ FT_VAR_NULL
+};
+
void b_export_with_equals(const char arg[], t_msh *msh);
#endif