diff options
| author | Dominik Kaiser | 2024-10-17 16:06:53 +0200 |
|---|---|---|
| committer | Dominik Kaiser | 2024-10-17 16:06:53 +0200 |
| commit | e7faa6525a007e463c06a20e438a2253287011f1 (patch) | |
| tree | e187b2fd0bebf7d0b10a6d5cc74d1edc9b9f3a73 /src/env.c | |
| parent | 08f6e0bf8c5d3ebc7fb9b61f9913369cfdbebae2 (diff) | |
| download | minishell-e7faa6525a007e463c06a20e438a2253287011f1.tar.gz minishell-e7faa6525a007e463c06a20e438a2253287011f1.zip | |
yes
Diffstat (limited to 'src/env.c')
| -rw-r--r-- | src/env.c | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -6,11 +6,13 @@ /* 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/10/17 15:58:28 by dkaiser ### ########.fr */ /* */ /* ************************************************************************** */ #include "env.h" +#include "get_next_line.h" +#include "libft.h" void getenvlst(t_env **env, char **en) { @@ -22,7 +24,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 +49,15 @@ void free_envlst(t_env **env) free(cur); cur = new; } -}
\ No newline at end of file +} + +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); +} |
