aboutsummaryrefslogtreecommitdiff
path: root/src/env.c
diff options
context:
space:
mode:
authorChristopher Uhlig2024-10-17 14:32:28 +0200
committerChristopher Uhlig2024-10-17 14:32:28 +0200
commita0016dffa6c5412d7c53b3d9040b837299c50159 (patch)
treec568dd4ca6e5eabf6843a832fc667ec50495e22a /src/env.c
parent06f7c2548f68ec2786eec97219b55cd095de450d (diff)
downloadminishell-a0016dffa6c5412d7c53b3d9040b837299c50159.tar.gz
minishell-a0016dffa6c5412d7c53b3d9040b837299c50159.zip
added env linked lis c file
Diffstat (limited to 'src/env.c')
-rw-r--r--src/env.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/env.c b/src/env.c
new file mode 100644
index 0000000..2403329
--- /dev/null
+++ b/src/env.c
@@ -0,0 +1,53 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* env.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2024/10/17 14:31:07 by chuhlig #+# #+# */
+/* Updated: 2024/10/17 14:31:50 by chuhlig ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "env.h"
+
+void getenvlst(t_env **env, char **en)// seperated name and value
+{
+ char *tmp;
+ int i;
+ t_env *current;
+
+ i = 0;
+ while (en[i] != NULL)
+ {
+ tmp = ft_strchr(en[i], '=');
+ tmp = '\0';
+ current = *env;
+ current = malloc(sizeof(t_env));
+ current->name = ft_strdup(en[i]);
+ current->value = ft_strdup(tmp + 1);
+ current->next = *env;
+ *env = current;
+ i++;
+ }
+ return (0);
+}
+
+
+void free_envlst(t_env **env)
+{
+ t_env *cur;
+ t_env *new;
+
+ cur = *env;
+ while (cur)
+ {
+ new = cur->next;
+ free(cur->name);
+ free(cur->value);
+ free(cur);
+ cur = new;
+ }
+
+} \ No newline at end of file