mirror of
https://github.com/KeyZox71/ft_minipowershell.git
synced 2025-03-15 03:16:51 +01:00
「🔨」 fix(env): fixed the env init
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/29 13:20:22 by mmoussou #+# #+# */
|
||||
/* Updated: 2024/07/06 18:24:48 by mmoussou ### ########.fr */
|
||||
/* Updated: 2024/07/09 14:40:00 by mmoussou ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -28,7 +28,7 @@ typedef struct s_env
|
||||
*
|
||||
* @return (int) 0 if everything goes well, 1 on error
|
||||
*/
|
||||
int env_init(char **env_d, t_env *env);
|
||||
t_env *env_init(char **env_d);
|
||||
|
||||
/**
|
||||
* @brief get value of an env
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/26 08:42:36 by mmoussou #+# #+# */
|
||||
/* Updated: 2024/07/06 18:27:41 by mmoussou ### ########.fr */
|
||||
/* Updated: 2024/07/06 19:08:43 by mmoussou ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
27
src/env/env_setters.c
vendored
27
src/env/env_setters.c
vendored
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/22 14:42:52 by mmoussou #+# #+# */
|
||||
/* Updated: 2024/06/24 12:53:38 by mmoussou ### ########.fr */
|
||||
/* Updated: 2024/07/09 14:34:39 by mmoussou ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -53,32 +53,25 @@ t_env *env_create_el(char *env_line)
|
||||
return (new);
|
||||
}
|
||||
|
||||
int env_init(char **env_d, t_env *env)
|
||||
t_env *env_init(char **env_d)
|
||||
{
|
||||
t_env *env;
|
||||
t_env *new;
|
||||
int i;
|
||||
char bool_first_el;
|
||||
|
||||
i = -1;
|
||||
bool_first_el = true;
|
||||
env = NULL;
|
||||
while (env_d[++i])
|
||||
{
|
||||
if (bool_first_el)
|
||||
if (env_create_first_el(env_d[i], env))
|
||||
return (1);
|
||||
if (!bool_first_el)
|
||||
new = env_create_el(env_d[i]);
|
||||
if (!new)
|
||||
{
|
||||
new = env_create_el(env_d[i]);
|
||||
if (!new)
|
||||
{
|
||||
ft_envclear(&env, free);
|
||||
return (1);
|
||||
}
|
||||
ft_envadd_back(&env, new);
|
||||
ft_envclear(&env, free);
|
||||
return (NULL);
|
||||
}
|
||||
bool_first_el = false;
|
||||
ft_envadd_back(&env, new);
|
||||
}
|
||||
return (0);
|
||||
return (env);
|
||||
}
|
||||
|
||||
char **env_get(t_env *env)
|
||||
|
15
src/main.c
15
src/main.c
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/24 11:18:04 by adjoly #+# #+# */
|
||||
/* Updated: 2024/07/07 14:50:45 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/09 14:40:50 by mmoussou ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -34,7 +34,7 @@ bool run_checks(char *rl)
|
||||
return (false);
|
||||
}
|
||||
|
||||
int main(int ac, char **av, char **env)
|
||||
/*int main(int ac, char **av, char **env)
|
||||
{
|
||||
char *rl;
|
||||
char *prompt;
|
||||
@ -68,4 +68,15 @@ int main(int ac, char **av, char **env)
|
||||
free(rl);
|
||||
}
|
||||
return (0);
|
||||
}*/
|
||||
|
||||
int main(int ac, char **av, char **e)
|
||||
{
|
||||
t_env *env;
|
||||
|
||||
(void) ac;
|
||||
(void) av;
|
||||
env = env_init(e);
|
||||
ft_envprint(env);
|
||||
ft_envclear(&env, free);
|
||||
}
|
||||
|
Reference in New Issue
Block a user