diff options
Diffstat (limited to 'src/env.c')
| -rw-r--r-- | src/env.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -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 |
