2024-04-29 13:55:21 +02:00
|
|
|
/* ************************************************************************** */
|
|
|
|
/* */
|
|
|
|
/* ::: :::::::: */
|
|
|
|
/* execution.h :+: :+: :+: */
|
|
|
|
/* +:+ +:+ +:+ */
|
|
|
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
|
|
|
/* +#+#+#+#+#+ +#+ */
|
|
|
|
/* Created: 2024/04/29 13:20:22 by mmoussou #+# #+# */
|
2024-05-27 13:13:46 +02:00
|
|
|
/* Updated: 2024/05/27 13:13:11 by mmoussou ### ########.fr */
|
2024-04-29 13:55:21 +02:00
|
|
|
/* */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
#ifndef EXECUTION_H
|
|
|
|
# define EXECUTION_H
|
|
|
|
|
2024-05-19 05:49:22 +02:00
|
|
|
int get_path(char *path);
|
|
|
|
|
2024-04-29 13:55:21 +02:00
|
|
|
typedef struct s_env
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
char *content;
|
|
|
|
struct s_env *next;
|
|
|
|
} t_env;
|
|
|
|
|
2024-05-21 00:21:51 +02:00
|
|
|
/**
|
|
|
|
* @brief spawn a heredoc
|
|
|
|
*
|
|
|
|
* @param delimiter a string representing the delimiter of the heredoc
|
|
|
|
*
|
|
|
|
* @return (int) fd of a file containing the user's input, or -1 on error
|
|
|
|
*/
|
2024-05-20 11:22:25 +02:00
|
|
|
int ft_heredoc(char *delimiter);
|
|
|
|
|
2024-05-21 00:21:51 +02:00
|
|
|
/**
|
|
|
|
* @brief function to fill an env struct from an array
|
|
|
|
*
|
|
|
|
* @param env_d env values as an array
|
|
|
|
* @param env pointer to the env struct we will fill
|
|
|
|
*
|
|
|
|
* @return (int) 0 if everything goes well, 1 on error
|
|
|
|
*/
|
2024-05-06 20:52:14 +02:00
|
|
|
int env_init(char **env_d, t_env *env);
|
2024-05-21 00:21:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief DEBUG FUNC : print the actual state of the env struct
|
|
|
|
*
|
|
|
|
* @param env the env struct that will be printed
|
|
|
|
*
|
|
|
|
* @return (void)
|
|
|
|
*/
|
2024-05-06 20:52:14 +02:00
|
|
|
void env_print(t_env *env);
|
2024-05-21 00:21:51 +02:00
|
|
|
|
2024-05-27 13:13:46 +02:00
|
|
|
/**
|
|
|
|
* @brief get value of an env
|
|
|
|
*
|
|
|
|
* @param name name of the variable you want
|
|
|
|
* @param env the env struct
|
|
|
|
*
|
|
|
|
* @return (char *) content of the variable, NULL if doesn't exist
|
|
|
|
*/
|
|
|
|
char *env_get_value(char *name, t_env *env)
|
|
|
|
|
2024-05-21 00:21:51 +02:00
|
|
|
/**
|
|
|
|
* @brief get an array from the env struct
|
|
|
|
*
|
|
|
|
* @param env the env struct you want to convert
|
|
|
|
*
|
|
|
|
* @return (char **) the array, or NULL on error
|
|
|
|
*/
|
2024-05-06 20:52:14 +02:00
|
|
|
char **env_get(t_env *env);
|
2024-05-21 00:21:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief append content at the end of an env variable
|
|
|
|
*
|
|
|
|
* @param name name of the variable that will be changed
|
|
|
|
* @param content content that will be append
|
|
|
|
* @param env the env struct that will be affected
|
|
|
|
*
|
|
|
|
* @return (int) 0 if everything goes well, -1 on error
|
|
|
|
*/
|
2024-05-06 20:52:14 +02:00
|
|
|
int env_append(char *name, char *content, t_env *env);
|
2024-05-21 00:21:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief replace the content of an env variable
|
|
|
|
*
|
|
|
|
* @param name name of the variable that will be changed
|
|
|
|
* @param content content that you want to add
|
|
|
|
* @param env the env struct that will be affected
|
|
|
|
*
|
|
|
|
* @return (int) 0 if everything goes well, -1 on error
|
|
|
|
*/
|
2024-05-06 20:52:14 +02:00
|
|
|
int env_edit(char *name, char *content, t_env *env);
|
2024-05-21 00:21:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief delete an entry in the env struct
|
|
|
|
*
|
|
|
|
* @param name name of the variable that will be deleted
|
|
|
|
* @param env the env struct that will be affected
|
|
|
|
*
|
|
|
|
* @return (int) 0 if everything goes well, -1 on error
|
|
|
|
*/
|
2024-05-06 20:52:14 +02:00
|
|
|
int env_delete(char *name, t_env *env);
|
|
|
|
|
2024-05-21 00:21:51 +02:00
|
|
|
// theses are literally the linked-list functions but for env
|
2024-05-06 20:52:14 +02:00
|
|
|
void ft_envadd_back(t_env **env, t_env *new);
|
|
|
|
void ft_envadd_front(t_env **lst, t_env *new);
|
|
|
|
void ft_envclear(t_env **lst, void (*del)(void *));
|
|
|
|
void ft_envdelone(t_env *lst, void (*del)(void *));
|
|
|
|
t_env *ft_envlast(t_env *env);
|
|
|
|
t_env *ft_envnew(char *name, char *content);
|
|
|
|
uint ft_envsize(t_env *lst);
|
|
|
|
|
2024-04-29 13:55:21 +02:00
|
|
|
#endif
|