34 if (!envp || !envp[0])
69 key_len = equal_pos - env_string;
70 node->
key = ft_substr(env_string, 0, key_len);
73 node->
value = ft_strdup(equal_pos + 1);
96 node = ft_calloc(
sizeof(
t_env), 1);
99 equal_pos = ft_strchr(env_string,
'=');
133 while (current->
next)
134 current = current->
next;
135 current->
next = new_node;
136 new_node->
prev = current;
Environment variable management prototypes.
t_env * create_env_node(char *env_string)
Create a single environment node from a KEY=value string.
void add_env_node(t_env **head, t_env *new_node)
Add a node to the end of the environment linked list.
static int set_env_key_value(t_env *node, char *env_string, char *equal_pos)
Parse KEY=value and fill a pre allocated t_env node.
t_env * init_env(char **envp)
Initialize the environment linked list from main()'s envp.
void ensure_pwd(t_env **env_list)
Ensure PWD exists in the environment.
void handle_shlvl(t_env **env_list)
Increment the SHLVL environment variable.
void free_env_list(t_env **env_list)
Free all nodes in the env linked list.
Environment variable (doubly linked list)
char * value
Value (NULL if export only)
struct s_env * prev
Previous node.
struct s_env * next
Next node.