-
Notifications
You must be signed in to change notification settings - Fork 0
/
env_queue.c
43 lines (39 loc) · 1.53 KB
/
env_queue.c
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
38
39
40
41
42
43
/* ************************************************************************** *//* */
/* ::: :::::::: */
/* env_queue.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: almelo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/04 14:20:09 by almelo #+# #+# */
/* Updated: 2023/03/04 14:21:02 by almelo ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
t_env *new_env(void *key, void *value)
{
t_env *node;
node = malloc(sizeof(t_env));
node->key = key;
node->value = value;
node->next = NULL;
return (node);
}
void queue_env(t_envl *env_lst, t_env *new)
{
if (env_lst->head == NULL)
{
env_lst->head = new;
env_lst->tail = new;
}
else
{
env_lst->tail->next = new;
env_lst->tail = new;
}
//to do: create a get_env function
if (ft_strcmp(new->key, "PATH") == 0)
env_lst->path = new;
else if (ft_strcmp(new->key, "HOME") == 0)
env_lst->home = new;
env_lst->length++;
}