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

Functions for initializing the shell's main data structure. More...

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

Functions

t_environ_listempty_environ (t_environ_list *environ)
 Initializes environment variables for an empty environment.
 
t_environ_listinit_environ (char **envp)
 Initializes the environment variables linked list.
 
t_shellinit_shell (char **envp)
 Initializes the main data structure (shell environment).
 
void lvl_up (t_shell *shell)
 Increases the shell level (SHLVL) environment variable.
 

Detailed Description

Functions for initializing the shell's main data structure.

Function Documentation

◆ empty_environ()

t_environ_list * empty_environ ( t_environ_list environ)

Initializes environment variables for an empty environment.

Initializes environment variables for an empty environment, such as adding the "PWD" and "SHLVL" variables to the provided environment variables linked list.

Parameters
[in]environA pointer to the environment variables linked list.
Returns
A pointer to the updated environment variables linked list, or Null in case of failure to obtain CWD.

◆ init_environ()

t_environ_list * init_environ ( char **  envp)

Initializes the environment variables linked list.

Initializes a linked list to store environment variables based on the provided 2D array of environment variables.

Parameters
[in]envpA 2D array of environment variables.
Returns
A pointer to the initialized environment variables linked list, or NULL in case of memory allocation failure.

◆ init_shell()

t_shell * init_shell ( char **  envp)

Initializes the main data structure (shell environment).

Starts the process of initializing the shell's main data structure, which includes components such as the environment variables in a linked list and other relevant information.

Parameters
[in]envpA 2D char array of environment variables.
Returns
A pointer to the initialized main data structure (shell environment).

◆ lvl_up()

void lvl_up ( t_shell shell)

Increases the shell level (SHLVL) environment variable.

Increments the value of the shell level (SHLVL) environment variable. If the variable doesn't exist, it is added with a value of 1.

Parameters
[in,out]shellA pointer to the shell data structure.