-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_getenv.c
More file actions
37 lines (34 loc) · 1.32 KB
/
ft_getenv.c
File metadata and controls
37 lines (34 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_getenv.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sid-bell <sid-bell@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/09/04 00:33:37 by sid-bell #+# #+# */
/* Updated: 2019/02/24 00:41:16 by sid-bell ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
char **ft_get_env(t_list *list)
{
char **env_str;
t_env *env;
char *entry;
int index;
env = NULL;
if (!(env_str = (char **)malloc(sizeof(char *) * ft_lstcount(list) + 1)))
return (NULL);
index = 0;
while (list)
{
env = (t_env *)list->content;
entry = ft_strjoin(env->key, "=");
env_str[index] = ft_strjoin(entry, env->value);
free(entry);
list = list->next;
index++;
}
env_str[index] = NULL;
return (env_str);
}