MiniDevil As beautiful as a shell
env.h
Go to the documentation of this file.
1 /* ************************************************************************** */
2 /* */
3 /* ::: :::::::: */
4 /* env.h :+: :+: :+: */
5 /* +:+ +:+ +:+ */
6 /* By: baelgadi <baelgadi@student.42.fr> +#+ +:+ +#+ */
7 /* +#+#+#+#+#+ +#+ */
8 /* Created: 2025/12/02 22:44:42 by zotaj-di #+# #+# */
9 /* Updated: 2026/03/11 02:51:55 by baelgadi ### ########.fr */
10 /* */
11 /* ************************************************************************** */
12 
13 #ifndef ENV_H
14 # define ENV_H
15 
16 # include "structs.h"
17 
18 /* ────────────── env_init.c ──────────────── */
19 
20 t_env *init_env(char **envp);
21 
22 t_env *create_env_node(char *env_string);
23 
24 void add_env_node(t_env **head, t_env *new_node);
25 
26 /* ────────────── env_operations.c ──────────────── */
27 
28 char *get_env_value(t_env *env_list, char *key);
29 
30 int set_env_value(t_env **env_list, char *key, char *value);
31 
32 /* ────────────── env_utils.c ──────────────── */
33 
34 void handle_shlvl(t_env **env_list);
35 
36 void ensure_pwd(t_env **env_list);
37 
38 void free_env_list(t_env **env_list);
39 
40 int env_list_size(t_env *env_list);
41 
42 /* ────────────── env_conversion.c ──────────────── */
43 
44 char **env_to_array(t_env *env);
45 
46 #endif
char ** env_to_array(t_env *env)
Convert the env linked list to a NULL terminated string array.
int env_list_size(t_env *env_list)
Count the number of nodes in the environment list.
Definition: env_utils.c:91
t_env * create_env_node(char *env_string)
Create a single environment node from a KEY=value string.
Definition: env_init.c:91
void ensure_pwd(t_env **env_list)
Ensure PWD exists in the environment.
Definition: env_utils.c:51
void add_env_node(t_env **head, t_env *new_node)
Add a node to the end of the environment linked list.
Definition: env_init.c:121
int set_env_value(t_env **env_list, char *key, char *value)
Set or create an environment variable.
char * get_env_value(t_env *env_list, char *key)
Look up an environment variable's value by its key.
void handle_shlvl(t_env **env_list)
Increment the SHLVL environment variable.
Definition: env_utils.c:24
void free_env_list(t_env **env_list)
Free all nodes in the env linked list.
Definition: env_utils.c:69
t_env * init_env(char **envp)
Initialize the environment linked list from main()'s envp.
Definition: env_init.c:27
Central type definitions for mandatory part.
Environment variable (doubly linked list)
Definition: structs.h:87