mirror of
https://github.com/KeyZox71/ft_minipowershell.git
synced 2025-03-15 11:26:51 +01:00
「✨」 feat(env_get_value): added a func to get value of a variable with the env struct
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/04/29 13:20:22 by mmoussou #+# #+# */
|
/* Created: 2024/04/29 13:20:22 by mmoussou #+# #+# */
|
||||||
/* Updated: 2024/05/21 00:20:49 by mmoussou ### ########.fr */
|
/* Updated: 2024/05/27 13:13:11 by mmoussou ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -50,6 +50,16 @@ int env_init(char **env_d, t_env *env);
|
|||||||
*/
|
*/
|
||||||
void env_print(t_env *env);
|
void env_print(t_env *env);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief get an array from the env struct
|
* @brief get an array from the env struct
|
||||||
*
|
*
|
||||||
|
11
src/env/env_cmd.c
vendored
11
src/env/env_cmd.c
vendored
@ -6,7 +6,7 @@
|
|||||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/22 14:50:01 by mmoussou #+# #+# */
|
/* Created: 2024/05/22 14:50:01 by mmoussou #+# #+# */
|
||||||
/* Updated: 2024/05/22 14:50:03 by mmoussou ### ########.fr */
|
/* Updated: 2024/05/27 13:11:07 by mmoussou ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -65,6 +65,15 @@ int env_delete(char *name, t_env *env)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *env_get_value(char *name, t_env *env)
|
||||||
|
{
|
||||||
|
while (env && ft_strcmp(env->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (env)
|
||||||
|
return (env->content);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void env_print(t_env *env)
|
void env_print(t_env *env)
|
||||||
{
|
{
|
||||||
while (env)
|
while (env)
|
||||||
|
Reference in New Issue
Block a user