minishell
Minishell Project for École 42
Loading...
Searching...
No Matches
environ_list_utils.c File Reference

Functions for managing the environment linked list and its nodes. More...

#include "minishell.h"
Include dependency graph for environ_list_utils.c:

Functions

t_environ_nodeadd_back_environ_node (t_environ_list *environ, t_environ_node *node)
 Adds an node to the end of an environment variables linked list.
 
t_environ_nodecreate_environ_node (char *var)
 Creates an node for an environment variable linked list.
 
t_environ_nodeget_node (t_environ_list *environ, char *key)
 Find an node by the key from an environment variables linked list.
 

Detailed Description

Functions for managing the environment linked list and its nodes.

Function Documentation

◆ add_back_environ_node()

t_environ_node * add_back_environ_node ( t_environ_list environ,
t_environ_node node 
)

Adds an node to the end of an environment variables linked list.

Adds a given node to the end of an environment variable linked list. The linked list's size is incremented accordingly.

Parameters
[in,out]environA pointer to the environment variables linked list.
[in]nodeA pointer to the node to be added.
Returns
A pointer to the added node, or NULL if input parameters are invalid.

◆ create_environ_node()

t_environ_node * create_environ_node ( char *  var)

Creates an node for an environment variable linked list.

Creates and initializes an node using the provided parameter string. The string is typically in the format "KEY=VALUE", where KEY is the variable name and VALUE is its value ("duhh").

Parameters
[in]varThe string representing the environment variable in the "KEY=VALUE" format.
Returns
A pointer to the created environment variable node, or NULL in case of memory allocation error or invalid input.

◆ get_node()

t_environ_node * get_node ( t_environ_list environ,
char *  key 
)

Find an node by the key from an environment variables linked list.

Searches for an node with a specific key, given as parameter, in the environment variables linked list, given as parameter. Returns the matching node.

Parameters
[in]environA pointer to the environment linked list.
[in]keyThe KEY ov the environment variable to search for.
Returns
A pointer the the found node, or NULL if not found or parameters are invalid.