aboutsummaryrefslogtreecommitdiff
path: root/src/env.c
diff options
context:
space:
mode:
authorChristopher Uhlig2025-01-13 11:06:54 +0100
committerChristopher Uhlig2025-01-13 11:06:54 +0100
commit78dc50a2bce3c6e31405437189e2990d8fc720ac (patch)
treed61d9f0d279e191c1bfb34929908f412cf58c02d /src/env.c
parentae5512ea0d6d8be833ca3a9b39f93239109f45b4 (diff)
downloadminishell-78dc50a2bce3c6e31405437189e2990d8fc720ac.tar.gz
minishell-78dc50a2bce3c6e31405437189e2990d8fc720ac.zip
here
Diffstat (limited to 'src/env.c')
-rw-r--r--src/env.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/env.c b/src/env.c
index 8105bf4..0213209 100644
--- a/src/env.c
+++ b/src/env.c
@@ -6,11 +6,12 @@
/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/17 14:31:07 by chuhlig #+# #+# */
-/* Updated: 2024/10/17 15:18:44 by chuhlig ### ########.fr */
+/* Updated: 2024/12/17 19:36:14 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
#include "env.h"
+#include <stdlib.h>
void getenvlst(t_env **env, char **en)
{
@@ -22,7 +23,7 @@ void getenvlst(t_env **env, char **en)
while (en[i] != NULL)
{
tmp = ft_strchr(en[i], '=');
- tmp = '\0';
+ *tmp = '\0';
current = *env;
current = malloc(sizeof(t_env));
current->name = ft_strdup(en[i]);
@@ -47,4 +48,15 @@ void free_envlst(t_env **env)
free(cur);
cur = new;
}
+}
+
+char *env_get(t_env *env, char *name)
+{
+ while (env != NULL)
+ {
+ if (!ft_strncmp(env->name, name, ft_strlen(name)))
+ return (env->value);
+ env = env->next;
+ }
+ return (NULL);
} \ No newline at end of file