diff options
| author | cuhlig | 2024-10-17 15:42:11 +0200 |
|---|---|---|
| committer | GitHub | 2024-10-17 15:42:11 +0200 |
| commit | ae5512ea0d6d8be833ca3a9b39f93239109f45b4 (patch) | |
| tree | 04e1801fd62324dbb2b24f50822c934b3a547d38 /src/env.c | |
| parent | 85d82207526e7220bd14bc96e5f8079ec781fc75 (diff) | |
| download | minishell-ae5512ea0d6d8be833ca3a9b39f93239109f45b4.tar.gz minishell-ae5512ea0d6d8be833ca3a9b39f93239109f45b4.zip | |
Env (#23)
* Add data structure and prototypes for env
* added env linked lis c file
* fixed normitte and fixed return issue
* changed prototypes in header file
---------
Co-authored-by: Dominik Kaiser <dkaiser@2-F-4.42heilbronn.de>
Co-authored-by: Christopher Uhlig <chuhlig@1-C-5.42heilbronn.de>
Diffstat (limited to 'src/env.c')
| -rw-r--r-- | src/env.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/env.c b/src/env.c new file mode 100644 index 0000000..8105bf4 --- /dev/null +++ b/src/env.c @@ -0,0 +1,50 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* env.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* 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 */ +/* */ +/* ************************************************************************** */ + +#include "env.h" + +void getenvlst(t_env **env, char **en) +{ + 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++; + } +} + +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 |
