mirror of
https://github.com/KeyZox71/ft_minipowershell.git
synced 2025-03-15 11:26:51 +01:00
「🔨」 fix: Merge resolved
This commit is contained in:
@ -6,13 +6,15 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/04/25 12:20:26 by adjoly #+# #+# */
|
/* Created: 2024/04/25 12:20:26 by adjoly #+# #+# */
|
||||||
/* Updated: 2024/05/04 13:54:02 by adjoly ### ########.fr */
|
/* Updated: 2024/05/07 14:07:10 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef PARSING_H
|
#ifndef PARSING_H
|
||||||
# define PARSING_H
|
# define PARSING_H
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
typedef struct s_cmd
|
typedef struct s_cmd
|
||||||
{
|
{
|
||||||
char *cmd;
|
char *cmd;
|
||||||
@ -24,6 +26,7 @@ typedef struct s_parsing
|
|||||||
|
|
||||||
} t_parsing;
|
} t_parsing;
|
||||||
|
|
||||||
t_cmd split_cmd(char *cmd_av);
|
t_cmd *split_cmd(char *cmd_av);
|
||||||
|
t_list *split_pipe(char *readline);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
3
src/env/env_cmd.c
vendored
3
src/env/env_cmd.c
vendored
@ -7,6 +7,7 @@
|
|||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/06 19:09:50 by mmoussou #+# #+# */
|
/* Created: 2024/05/06 19:09:50 by mmoussou #+# #+# */
|
||||||
/* Updated: 2024/05/09 15:54:22 by adjoly ### ########.fr */
|
/* Updated: 2024/05/09 15:54:22 by adjoly ### ########.fr */
|
||||||
|
/* Updated: 2024/05/07 13:58:48 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ char **env_get(t_env *env)
|
|||||||
|
|
||||||
int env_create_first_el(char *env_line, t_env *env)
|
int env_create_first_el(char *env_line, t_env *env)
|
||||||
{
|
{
|
||||||
// t_env *new;
|
t_env *new;
|
||||||
char *name;
|
char *name;
|
||||||
char *content;
|
char *content;
|
||||||
|
|
||||||
|
166
src/env/env_cmd.c.orig
vendored
Normal file
166
src/env/env_cmd.c.orig
vendored
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* env_cmd.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/05/06 19:09:50 by mmoussou #+# #+# */
|
||||||
|
<<<<<<< HEAD
|
||||||
|
/* Updated: 2024/05/09 15:54:22 by adjoly ### ########.fr */
|
||||||
|
=======
|
||||||
|
/* Updated: 2024/05/07 13:58:48 by adjoly ### ########.fr */
|
||||||
|
>>>>>>> 3c66d20 (「✨」 feat: split pile started)
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "minishell.h"
|
||||||
|
|
||||||
|
char **env_get(t_env *env)
|
||||||
|
{
|
||||||
|
char **exec_env;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
exec_env = malloc(sizeof(char *) * (ft_envsize(env) + 1));
|
||||||
|
if (!exec_env)
|
||||||
|
return (exec_env);
|
||||||
|
exec_env[ft_envsize(env)] = NULL;
|
||||||
|
i = 0;
|
||||||
|
while (env)
|
||||||
|
{
|
||||||
|
exec_env[i] = malloc(ft_strlen(env->name)
|
||||||
|
+ ft_strlen(env->content) + 2);
|
||||||
|
if (!exec_env[i])
|
||||||
|
{
|
||||||
|
ft_free("a", exec_env);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
ft_strlcpy(exec_env[i], env->name, ft_strlen(env->name) + 1);
|
||||||
|
exec_env[i][ft_strlen(env->name)] = '=';
|
||||||
|
ft_strlcpy(exec_env[i] + ft_strlen(env->name) + 1,
|
||||||
|
env->content, ft_strlen(env->content) + 1);
|
||||||
|
env = env->next;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (exec_env);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_create_first_el(char *env_line, t_env *env)
|
||||||
|
{
|
||||||
|
// t_env *new;
|
||||||
|
char *name;
|
||||||
|
char *content;
|
||||||
|
|
||||||
|
content = ft_strdup(ft_strchr(env_line, '=') + 1);
|
||||||
|
if (!content)
|
||||||
|
return (-1);
|
||||||
|
ft_strchr(env_line, '=')[0] = 0;
|
||||||
|
name = ft_strdup(env_line);
|
||||||
|
if (!name)
|
||||||
|
return (-1);
|
||||||
|
env->name = name;
|
||||||
|
env->content = content;
|
||||||
|
env->next = NULL;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
t_env *env_create_el(char *env_line)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
char *name;
|
||||||
|
char *content;
|
||||||
|
|
||||||
|
content = ft_strdup(ft_strchr(env_line, '=') + 1);
|
||||||
|
if (!content)
|
||||||
|
return (NULL);
|
||||||
|
ft_strchr(env_line, '=')[0] = 0;
|
||||||
|
name = ft_strdup(env_line);
|
||||||
|
if (!name)
|
||||||
|
return (NULL);
|
||||||
|
new = ft_envnew(name, content);
|
||||||
|
return (new);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_init(char **env_d, t_env *env)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
int i;
|
||||||
|
char bool_first_el;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
bool_first_el = true;
|
||||||
|
while (env_d[i])
|
||||||
|
{
|
||||||
|
if (bool_first_el)
|
||||||
|
i = env_create_first_el(env_d[i], env);
|
||||||
|
if (bool_first_el && i < 0)
|
||||||
|
return (1);
|
||||||
|
if (bool_first_el)
|
||||||
|
bool_first_el = false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new = env_create_el(env_d[i]);
|
||||||
|
if (!new)
|
||||||
|
{
|
||||||
|
ft_envclear(&env, free);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
ft_envadd_back(&env, new);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_append(char *name, char *content, t_env *env)
|
||||||
|
{
|
||||||
|
char *new_content;
|
||||||
|
|
||||||
|
while (env && ft_strcmp(env->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env)
|
||||||
|
return (-1);
|
||||||
|
new_content = ft_calloc(1, ft_strlen(env->content) + ft_strlen(content));
|
||||||
|
ft_strlcpy(new_content, env->content, ft_strlen(env->content) + 1);
|
||||||
|
ft_strlcpy(new_content + ft_strlen(env->content),
|
||||||
|
content, ft_strlen(content) + 1);
|
||||||
|
free(env->content);
|
||||||
|
env->content = new_content;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_edit(char *name, char *content, t_env *env)
|
||||||
|
{
|
||||||
|
while (env && ft_strcmp(env->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env)
|
||||||
|
return (-1);
|
||||||
|
free(env->content);
|
||||||
|
env->content = content;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_delete(char *name, t_env *env)
|
||||||
|
{
|
||||||
|
// char *new_content;
|
||||||
|
t_env *tmp;
|
||||||
|
|
||||||
|
while (env && env->next && ft_strcmp(env->next->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env || !env->next)
|
||||||
|
return (-1);
|
||||||
|
ft_free("cc", &env->next->name, &env->next->content);
|
||||||
|
tmp = env->next;
|
||||||
|
env->next = env->next->next;
|
||||||
|
free(tmp);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void env_print(t_env *env)
|
||||||
|
{
|
||||||
|
while (env)
|
||||||
|
{
|
||||||
|
printf("%s:%s\n", env->name, env->content);
|
||||||
|
env = env->next;
|
||||||
|
}
|
||||||
|
}
|
166
src/env/env_cmd_BACKUP_1565069.c
vendored
Normal file
166
src/env/env_cmd_BACKUP_1565069.c
vendored
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* env_cmd.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/05/06 19:09:50 by mmoussou #+# #+# */
|
||||||
|
<<<<<<< HEAD
|
||||||
|
/* Updated: 2024/05/09 15:54:22 by adjoly ### ########.fr */
|
||||||
|
=======
|
||||||
|
/* Updated: 2024/05/07 13:58:48 by adjoly ### ########.fr */
|
||||||
|
>>>>>>> 3c66d20 (「✨」 feat: split pile started)
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "minishell.h"
|
||||||
|
|
||||||
|
char **env_get(t_env *env)
|
||||||
|
{
|
||||||
|
char **exec_env;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
exec_env = malloc(sizeof(char *) * (ft_envsize(env) + 1));
|
||||||
|
if (!exec_env)
|
||||||
|
return (exec_env);
|
||||||
|
exec_env[ft_envsize(env)] = NULL;
|
||||||
|
i = 0;
|
||||||
|
while (env)
|
||||||
|
{
|
||||||
|
exec_env[i] = malloc(ft_strlen(env->name)
|
||||||
|
+ ft_strlen(env->content) + 2);
|
||||||
|
if (!exec_env[i])
|
||||||
|
{
|
||||||
|
ft_free("a", exec_env);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
ft_strlcpy(exec_env[i], env->name, ft_strlen(env->name) + 1);
|
||||||
|
exec_env[i][ft_strlen(env->name)] = '=';
|
||||||
|
ft_strlcpy(exec_env[i] + ft_strlen(env->name) + 1,
|
||||||
|
env->content, ft_strlen(env->content) + 1);
|
||||||
|
env = env->next;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (exec_env);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_create_first_el(char *env_line, t_env *env)
|
||||||
|
{
|
||||||
|
// t_env *new;
|
||||||
|
char *name;
|
||||||
|
char *content;
|
||||||
|
|
||||||
|
content = ft_strdup(ft_strchr(env_line, '=') + 1);
|
||||||
|
if (!content)
|
||||||
|
return (-1);
|
||||||
|
ft_strchr(env_line, '=')[0] = 0;
|
||||||
|
name = ft_strdup(env_line);
|
||||||
|
if (!name)
|
||||||
|
return (-1);
|
||||||
|
env->name = name;
|
||||||
|
env->content = content;
|
||||||
|
env->next = NULL;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
t_env *env_create_el(char *env_line)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
char *name;
|
||||||
|
char *content;
|
||||||
|
|
||||||
|
content = ft_strdup(ft_strchr(env_line, '=') + 1);
|
||||||
|
if (!content)
|
||||||
|
return (NULL);
|
||||||
|
ft_strchr(env_line, '=')[0] = 0;
|
||||||
|
name = ft_strdup(env_line);
|
||||||
|
if (!name)
|
||||||
|
return (NULL);
|
||||||
|
new = ft_envnew(name, content);
|
||||||
|
return (new);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_init(char **env_d, t_env *env)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
int i;
|
||||||
|
char bool_first_el;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
bool_first_el = true;
|
||||||
|
while (env_d[i])
|
||||||
|
{
|
||||||
|
if (bool_first_el)
|
||||||
|
i = env_create_first_el(env_d[i], env);
|
||||||
|
if (bool_first_el && i < 0)
|
||||||
|
return (1);
|
||||||
|
if (bool_first_el)
|
||||||
|
bool_first_el = false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new = env_create_el(env_d[i]);
|
||||||
|
if (!new)
|
||||||
|
{
|
||||||
|
ft_envclear(&env, free);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
ft_envadd_back(&env, new);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_append(char *name, char *content, t_env *env)
|
||||||
|
{
|
||||||
|
char *new_content;
|
||||||
|
|
||||||
|
while (env && ft_strcmp(env->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env)
|
||||||
|
return (-1);
|
||||||
|
new_content = ft_calloc(1, ft_strlen(env->content) + ft_strlen(content));
|
||||||
|
ft_strlcpy(new_content, env->content, ft_strlen(env->content) + 1);
|
||||||
|
ft_strlcpy(new_content + ft_strlen(env->content),
|
||||||
|
content, ft_strlen(content) + 1);
|
||||||
|
free(env->content);
|
||||||
|
env->content = new_content;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_edit(char *name, char *content, t_env *env)
|
||||||
|
{
|
||||||
|
while (env && ft_strcmp(env->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env)
|
||||||
|
return (-1);
|
||||||
|
free(env->content);
|
||||||
|
env->content = content;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_delete(char *name, t_env *env)
|
||||||
|
{
|
||||||
|
// char *new_content;
|
||||||
|
t_env *tmp;
|
||||||
|
|
||||||
|
while (env && env->next && ft_strcmp(env->next->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env || !env->next)
|
||||||
|
return (-1);
|
||||||
|
ft_free("cc", &env->next->name, &env->next->content);
|
||||||
|
tmp = env->next;
|
||||||
|
env->next = env->next->next;
|
||||||
|
free(tmp);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void env_print(t_env *env)
|
||||||
|
{
|
||||||
|
while (env)
|
||||||
|
{
|
||||||
|
printf("%s:%s\n", env->name, env->content);
|
||||||
|
env = env->next;
|
||||||
|
}
|
||||||
|
}
|
166
src/env/env_cmd_BACKUP_1565172.c
vendored
Normal file
166
src/env/env_cmd_BACKUP_1565172.c
vendored
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* env_cmd.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/05/06 19:09:50 by mmoussou #+# #+# */
|
||||||
|
<<<<<<< HEAD
|
||||||
|
/* Updated: 2024/05/09 15:54:22 by adjoly ### ########.fr */
|
||||||
|
=======
|
||||||
|
/* Updated: 2024/05/07 13:58:48 by adjoly ### ########.fr */
|
||||||
|
>>>>>>> 3c66d20 (「✨」 feat: split pile started)
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "minishell.h"
|
||||||
|
|
||||||
|
char **env_get(t_env *env)
|
||||||
|
{
|
||||||
|
char **exec_env;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
exec_env = malloc(sizeof(char *) * (ft_envsize(env) + 1));
|
||||||
|
if (!exec_env)
|
||||||
|
return (exec_env);
|
||||||
|
exec_env[ft_envsize(env)] = NULL;
|
||||||
|
i = 0;
|
||||||
|
while (env)
|
||||||
|
{
|
||||||
|
exec_env[i] = malloc(ft_strlen(env->name)
|
||||||
|
+ ft_strlen(env->content) + 2);
|
||||||
|
if (!exec_env[i])
|
||||||
|
{
|
||||||
|
ft_free("a", exec_env);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
ft_strlcpy(exec_env[i], env->name, ft_strlen(env->name) + 1);
|
||||||
|
exec_env[i][ft_strlen(env->name)] = '=';
|
||||||
|
ft_strlcpy(exec_env[i] + ft_strlen(env->name) + 1,
|
||||||
|
env->content, ft_strlen(env->content) + 1);
|
||||||
|
env = env->next;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (exec_env);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_create_first_el(char *env_line, t_env *env)
|
||||||
|
{
|
||||||
|
// t_env *new;
|
||||||
|
char *name;
|
||||||
|
char *content;
|
||||||
|
|
||||||
|
content = ft_strdup(ft_strchr(env_line, '=') + 1);
|
||||||
|
if (!content)
|
||||||
|
return (-1);
|
||||||
|
ft_strchr(env_line, '=')[0] = 0;
|
||||||
|
name = ft_strdup(env_line);
|
||||||
|
if (!name)
|
||||||
|
return (-1);
|
||||||
|
env->name = name;
|
||||||
|
env->content = content;
|
||||||
|
env->next = NULL;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
t_env *env_create_el(char *env_line)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
char *name;
|
||||||
|
char *content;
|
||||||
|
|
||||||
|
content = ft_strdup(ft_strchr(env_line, '=') + 1);
|
||||||
|
if (!content)
|
||||||
|
return (NULL);
|
||||||
|
ft_strchr(env_line, '=')[0] = 0;
|
||||||
|
name = ft_strdup(env_line);
|
||||||
|
if (!name)
|
||||||
|
return (NULL);
|
||||||
|
new = ft_envnew(name, content);
|
||||||
|
return (new);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_init(char **env_d, t_env *env)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
int i;
|
||||||
|
char bool_first_el;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
bool_first_el = true;
|
||||||
|
while (env_d[i])
|
||||||
|
{
|
||||||
|
if (bool_first_el)
|
||||||
|
i = env_create_first_el(env_d[i], env);
|
||||||
|
if (bool_first_el && i < 0)
|
||||||
|
return (1);
|
||||||
|
if (bool_first_el)
|
||||||
|
bool_first_el = false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new = env_create_el(env_d[i]);
|
||||||
|
if (!new)
|
||||||
|
{
|
||||||
|
ft_envclear(&env, free);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
ft_envadd_back(&env, new);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_append(char *name, char *content, t_env *env)
|
||||||
|
{
|
||||||
|
char *new_content;
|
||||||
|
|
||||||
|
while (env && ft_strcmp(env->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env)
|
||||||
|
return (-1);
|
||||||
|
new_content = ft_calloc(1, ft_strlen(env->content) + ft_strlen(content));
|
||||||
|
ft_strlcpy(new_content, env->content, ft_strlen(env->content) + 1);
|
||||||
|
ft_strlcpy(new_content + ft_strlen(env->content),
|
||||||
|
content, ft_strlen(content) + 1);
|
||||||
|
free(env->content);
|
||||||
|
env->content = new_content;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_edit(char *name, char *content, t_env *env)
|
||||||
|
{
|
||||||
|
while (env && ft_strcmp(env->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env)
|
||||||
|
return (-1);
|
||||||
|
free(env->content);
|
||||||
|
env->content = content;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_delete(char *name, t_env *env)
|
||||||
|
{
|
||||||
|
// char *new_content;
|
||||||
|
t_env *tmp;
|
||||||
|
|
||||||
|
while (env && env->next && ft_strcmp(env->next->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env || !env->next)
|
||||||
|
return (-1);
|
||||||
|
ft_free("cc", &env->next->name, &env->next->content);
|
||||||
|
tmp = env->next;
|
||||||
|
env->next = env->next->next;
|
||||||
|
free(tmp);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void env_print(t_env *env)
|
||||||
|
{
|
||||||
|
while (env)
|
||||||
|
{
|
||||||
|
printf("%s:%s\n", env->name, env->content);
|
||||||
|
env = env->next;
|
||||||
|
}
|
||||||
|
}
|
162
src/env/env_cmd_BASE_1565069.c
vendored
Normal file
162
src/env/env_cmd_BASE_1565069.c
vendored
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* env_cmd.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/05/06 19:09:50 by mmoussou #+# #+# */
|
||||||
|
/* Updated: 2024/05/06 20:27:45 by mmoussou ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "minishell.h"
|
||||||
|
|
||||||
|
char **env_get(t_env *env)
|
||||||
|
{
|
||||||
|
char **exec_env;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
exec_env = malloc(sizeof(char *) * (ft_envsize(env) + 1));
|
||||||
|
if (!exec_env)
|
||||||
|
return (exec_env);
|
||||||
|
exec_env[ft_envsize(env)] = NULL;
|
||||||
|
i = 0;
|
||||||
|
while (env)
|
||||||
|
{
|
||||||
|
exec_env[i] = malloc(ft_strlen(env->name)
|
||||||
|
+ ft_strlen(env->content) + 2);
|
||||||
|
if (!exec_env[i])
|
||||||
|
{
|
||||||
|
ft_free("a", exec_env);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
ft_strlcpy(exec_env[i], env->name, ft_strlen(env->name) + 1);
|
||||||
|
exec_env[i][ft_strlen(env->name)] = '=';
|
||||||
|
ft_strlcpy(exec_env[i] + ft_strlen(env->name) + 1,
|
||||||
|
env->content, ft_strlen(env->content) + 1);
|
||||||
|
env = env->next;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (exec_env);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_create_first_el(char *env_line, t_env *env)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
char *name;
|
||||||
|
char *content;
|
||||||
|
|
||||||
|
content = ft_strdup(ft_strchr(env_line, '=') + 1);
|
||||||
|
if (!content)
|
||||||
|
return (-1);
|
||||||
|
ft_strchr(env_line, '=')[0] = 0;
|
||||||
|
name = ft_strdup(env_line);
|
||||||
|
if (!name)
|
||||||
|
return (-1);
|
||||||
|
env->name = name;
|
||||||
|
env->content = content;
|
||||||
|
env->next = NULL;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
t_env *env_create_el(char *env_line)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
char *name;
|
||||||
|
char *content;
|
||||||
|
|
||||||
|
content = ft_strdup(ft_strchr(env_line, '=') + 1);
|
||||||
|
if (!content)
|
||||||
|
return (NULL);
|
||||||
|
ft_strchr(env_line, '=')[0] = 0;
|
||||||
|
name = ft_strdup(env_line);
|
||||||
|
if (!name)
|
||||||
|
return (NULL);
|
||||||
|
new = ft_envnew(name, content);
|
||||||
|
return (new);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_init(char **env_d, t_env *env)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
int i;
|
||||||
|
char bool_first_el;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
bool_first_el = true;
|
||||||
|
while (env_d[i])
|
||||||
|
{
|
||||||
|
if (bool_first_el)
|
||||||
|
i = env_create_first_el(env_d[i], env);
|
||||||
|
if (bool_first_el && i < 0)
|
||||||
|
return (1);
|
||||||
|
if (bool_first_el)
|
||||||
|
bool_first_el = false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new = env_create_el(env_d[i]);
|
||||||
|
if (!new)
|
||||||
|
{
|
||||||
|
ft_envclear(&env, free);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
ft_envadd_back(&env, new);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_append(char *name, char *content, t_env *env)
|
||||||
|
{
|
||||||
|
char *new_content;
|
||||||
|
|
||||||
|
while (env && ft_strcmp(env->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env)
|
||||||
|
return (-1);
|
||||||
|
new_content = ft_calloc(1, ft_strlen(env->content) + ft_strlen(content));
|
||||||
|
ft_strlcpy(new_content, env->content, ft_strlen(env->content) + 1);
|
||||||
|
ft_strlcpy(new_content + ft_strlen(env->content),
|
||||||
|
content, ft_strlen(content) + 1);
|
||||||
|
free(env->content);
|
||||||
|
env->content = new_content;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_edit(char *name, char *content, t_env *env)
|
||||||
|
{
|
||||||
|
while (env && ft_strcmp(env->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env)
|
||||||
|
return (-1);
|
||||||
|
free(env->content);
|
||||||
|
env->content = content;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_delete(char *name, t_env *env)
|
||||||
|
{
|
||||||
|
char *new_content;
|
||||||
|
t_env *tmp;
|
||||||
|
|
||||||
|
while (env && env->next && ft_strcmp(env->next->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env || !env->next)
|
||||||
|
return (-1);
|
||||||
|
ft_free("cc", &env->next->name, &env->next->content);
|
||||||
|
tmp = env->next;
|
||||||
|
env->next = env->next->next;
|
||||||
|
free(tmp);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void env_print(t_env *env)
|
||||||
|
{
|
||||||
|
while (env)
|
||||||
|
{
|
||||||
|
printf("%s:%s\n", env->name, env->content);
|
||||||
|
env = env->next;
|
||||||
|
}
|
||||||
|
}
|
162
src/env/env_cmd_BASE_1565172.c
vendored
Normal file
162
src/env/env_cmd_BASE_1565172.c
vendored
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* env_cmd.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/05/06 19:09:50 by mmoussou #+# #+# */
|
||||||
|
/* Updated: 2024/05/06 20:27:45 by mmoussou ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "minishell.h"
|
||||||
|
|
||||||
|
char **env_get(t_env *env)
|
||||||
|
{
|
||||||
|
char **exec_env;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
exec_env = malloc(sizeof(char *) * (ft_envsize(env) + 1));
|
||||||
|
if (!exec_env)
|
||||||
|
return (exec_env);
|
||||||
|
exec_env[ft_envsize(env)] = NULL;
|
||||||
|
i = 0;
|
||||||
|
while (env)
|
||||||
|
{
|
||||||
|
exec_env[i] = malloc(ft_strlen(env->name)
|
||||||
|
+ ft_strlen(env->content) + 2);
|
||||||
|
if (!exec_env[i])
|
||||||
|
{
|
||||||
|
ft_free("a", exec_env);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
ft_strlcpy(exec_env[i], env->name, ft_strlen(env->name) + 1);
|
||||||
|
exec_env[i][ft_strlen(env->name)] = '=';
|
||||||
|
ft_strlcpy(exec_env[i] + ft_strlen(env->name) + 1,
|
||||||
|
env->content, ft_strlen(env->content) + 1);
|
||||||
|
env = env->next;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (exec_env);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_create_first_el(char *env_line, t_env *env)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
char *name;
|
||||||
|
char *content;
|
||||||
|
|
||||||
|
content = ft_strdup(ft_strchr(env_line, '=') + 1);
|
||||||
|
if (!content)
|
||||||
|
return (-1);
|
||||||
|
ft_strchr(env_line, '=')[0] = 0;
|
||||||
|
name = ft_strdup(env_line);
|
||||||
|
if (!name)
|
||||||
|
return (-1);
|
||||||
|
env->name = name;
|
||||||
|
env->content = content;
|
||||||
|
env->next = NULL;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
t_env *env_create_el(char *env_line)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
char *name;
|
||||||
|
char *content;
|
||||||
|
|
||||||
|
content = ft_strdup(ft_strchr(env_line, '=') + 1);
|
||||||
|
if (!content)
|
||||||
|
return (NULL);
|
||||||
|
ft_strchr(env_line, '=')[0] = 0;
|
||||||
|
name = ft_strdup(env_line);
|
||||||
|
if (!name)
|
||||||
|
return (NULL);
|
||||||
|
new = ft_envnew(name, content);
|
||||||
|
return (new);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_init(char **env_d, t_env *env)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
int i;
|
||||||
|
char bool_first_el;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
bool_first_el = true;
|
||||||
|
while (env_d[i])
|
||||||
|
{
|
||||||
|
if (bool_first_el)
|
||||||
|
i = env_create_first_el(env_d[i], env);
|
||||||
|
if (bool_first_el && i < 0)
|
||||||
|
return (1);
|
||||||
|
if (bool_first_el)
|
||||||
|
bool_first_el = false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new = env_create_el(env_d[i]);
|
||||||
|
if (!new)
|
||||||
|
{
|
||||||
|
ft_envclear(&env, free);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
ft_envadd_back(&env, new);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_append(char *name, char *content, t_env *env)
|
||||||
|
{
|
||||||
|
char *new_content;
|
||||||
|
|
||||||
|
while (env && ft_strcmp(env->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env)
|
||||||
|
return (-1);
|
||||||
|
new_content = ft_calloc(1, ft_strlen(env->content) + ft_strlen(content));
|
||||||
|
ft_strlcpy(new_content, env->content, ft_strlen(env->content) + 1);
|
||||||
|
ft_strlcpy(new_content + ft_strlen(env->content),
|
||||||
|
content, ft_strlen(content) + 1);
|
||||||
|
free(env->content);
|
||||||
|
env->content = new_content;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_edit(char *name, char *content, t_env *env)
|
||||||
|
{
|
||||||
|
while (env && ft_strcmp(env->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env)
|
||||||
|
return (-1);
|
||||||
|
free(env->content);
|
||||||
|
env->content = content;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_delete(char *name, t_env *env)
|
||||||
|
{
|
||||||
|
char *new_content;
|
||||||
|
t_env *tmp;
|
||||||
|
|
||||||
|
while (env && env->next && ft_strcmp(env->next->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env || !env->next)
|
||||||
|
return (-1);
|
||||||
|
ft_free("cc", &env->next->name, &env->next->content);
|
||||||
|
tmp = env->next;
|
||||||
|
env->next = env->next->next;
|
||||||
|
free(tmp);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void env_print(t_env *env)
|
||||||
|
{
|
||||||
|
while (env)
|
||||||
|
{
|
||||||
|
printf("%s:%s\n", env->name, env->content);
|
||||||
|
env = env->next;
|
||||||
|
}
|
||||||
|
}
|
162
src/env/env_cmd_LOCAL_1565069.c
vendored
Normal file
162
src/env/env_cmd_LOCAL_1565069.c
vendored
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* env_cmd.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/05/06 19:09:50 by mmoussou #+# #+# */
|
||||||
|
/* Updated: 2024/05/09 15:54:22 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "minishell.h"
|
||||||
|
|
||||||
|
char **env_get(t_env *env)
|
||||||
|
{
|
||||||
|
char **exec_env;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
exec_env = malloc(sizeof(char *) * (ft_envsize(env) + 1));
|
||||||
|
if (!exec_env)
|
||||||
|
return (exec_env);
|
||||||
|
exec_env[ft_envsize(env)] = NULL;
|
||||||
|
i = 0;
|
||||||
|
while (env)
|
||||||
|
{
|
||||||
|
exec_env[i] = malloc(ft_strlen(env->name)
|
||||||
|
+ ft_strlen(env->content) + 2);
|
||||||
|
if (!exec_env[i])
|
||||||
|
{
|
||||||
|
ft_free("a", exec_env);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
ft_strlcpy(exec_env[i], env->name, ft_strlen(env->name) + 1);
|
||||||
|
exec_env[i][ft_strlen(env->name)] = '=';
|
||||||
|
ft_strlcpy(exec_env[i] + ft_strlen(env->name) + 1,
|
||||||
|
env->content, ft_strlen(env->content) + 1);
|
||||||
|
env = env->next;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (exec_env);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_create_first_el(char *env_line, t_env *env)
|
||||||
|
{
|
||||||
|
// t_env *new;
|
||||||
|
char *name;
|
||||||
|
char *content;
|
||||||
|
|
||||||
|
content = ft_strdup(ft_strchr(env_line, '=') + 1);
|
||||||
|
if (!content)
|
||||||
|
return (-1);
|
||||||
|
ft_strchr(env_line, '=')[0] = 0;
|
||||||
|
name = ft_strdup(env_line);
|
||||||
|
if (!name)
|
||||||
|
return (-1);
|
||||||
|
env->name = name;
|
||||||
|
env->content = content;
|
||||||
|
env->next = NULL;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
t_env *env_create_el(char *env_line)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
char *name;
|
||||||
|
char *content;
|
||||||
|
|
||||||
|
content = ft_strdup(ft_strchr(env_line, '=') + 1);
|
||||||
|
if (!content)
|
||||||
|
return (NULL);
|
||||||
|
ft_strchr(env_line, '=')[0] = 0;
|
||||||
|
name = ft_strdup(env_line);
|
||||||
|
if (!name)
|
||||||
|
return (NULL);
|
||||||
|
new = ft_envnew(name, content);
|
||||||
|
return (new);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_init(char **env_d, t_env *env)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
int i;
|
||||||
|
char bool_first_el;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
bool_first_el = true;
|
||||||
|
while (env_d[i])
|
||||||
|
{
|
||||||
|
if (bool_first_el)
|
||||||
|
i = env_create_first_el(env_d[i], env);
|
||||||
|
if (bool_first_el && i < 0)
|
||||||
|
return (1);
|
||||||
|
if (bool_first_el)
|
||||||
|
bool_first_el = false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new = env_create_el(env_d[i]);
|
||||||
|
if (!new)
|
||||||
|
{
|
||||||
|
ft_envclear(&env, free);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
ft_envadd_back(&env, new);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_append(char *name, char *content, t_env *env)
|
||||||
|
{
|
||||||
|
char *new_content;
|
||||||
|
|
||||||
|
while (env && ft_strcmp(env->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env)
|
||||||
|
return (-1);
|
||||||
|
new_content = ft_calloc(1, ft_strlen(env->content) + ft_strlen(content));
|
||||||
|
ft_strlcpy(new_content, env->content, ft_strlen(env->content) + 1);
|
||||||
|
ft_strlcpy(new_content + ft_strlen(env->content),
|
||||||
|
content, ft_strlen(content) + 1);
|
||||||
|
free(env->content);
|
||||||
|
env->content = new_content;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_edit(char *name, char *content, t_env *env)
|
||||||
|
{
|
||||||
|
while (env && ft_strcmp(env->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env)
|
||||||
|
return (-1);
|
||||||
|
free(env->content);
|
||||||
|
env->content = content;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_delete(char *name, t_env *env)
|
||||||
|
{
|
||||||
|
// char *new_content;
|
||||||
|
t_env *tmp;
|
||||||
|
|
||||||
|
while (env && env->next && ft_strcmp(env->next->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env || !env->next)
|
||||||
|
return (-1);
|
||||||
|
ft_free("cc", &env->next->name, &env->next->content);
|
||||||
|
tmp = env->next;
|
||||||
|
env->next = env->next->next;
|
||||||
|
free(tmp);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void env_print(t_env *env)
|
||||||
|
{
|
||||||
|
while (env)
|
||||||
|
{
|
||||||
|
printf("%s:%s\n", env->name, env->content);
|
||||||
|
env = env->next;
|
||||||
|
}
|
||||||
|
}
|
162
src/env/env_cmd_LOCAL_1565172.c
vendored
Normal file
162
src/env/env_cmd_LOCAL_1565172.c
vendored
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* env_cmd.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/05/06 19:09:50 by mmoussou #+# #+# */
|
||||||
|
/* Updated: 2024/05/09 15:54:22 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "minishell.h"
|
||||||
|
|
||||||
|
char **env_get(t_env *env)
|
||||||
|
{
|
||||||
|
char **exec_env;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
exec_env = malloc(sizeof(char *) * (ft_envsize(env) + 1));
|
||||||
|
if (!exec_env)
|
||||||
|
return (exec_env);
|
||||||
|
exec_env[ft_envsize(env)] = NULL;
|
||||||
|
i = 0;
|
||||||
|
while (env)
|
||||||
|
{
|
||||||
|
exec_env[i] = malloc(ft_strlen(env->name)
|
||||||
|
+ ft_strlen(env->content) + 2);
|
||||||
|
if (!exec_env[i])
|
||||||
|
{
|
||||||
|
ft_free("a", exec_env);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
ft_strlcpy(exec_env[i], env->name, ft_strlen(env->name) + 1);
|
||||||
|
exec_env[i][ft_strlen(env->name)] = '=';
|
||||||
|
ft_strlcpy(exec_env[i] + ft_strlen(env->name) + 1,
|
||||||
|
env->content, ft_strlen(env->content) + 1);
|
||||||
|
env = env->next;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (exec_env);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_create_first_el(char *env_line, t_env *env)
|
||||||
|
{
|
||||||
|
// t_env *new;
|
||||||
|
char *name;
|
||||||
|
char *content;
|
||||||
|
|
||||||
|
content = ft_strdup(ft_strchr(env_line, '=') + 1);
|
||||||
|
if (!content)
|
||||||
|
return (-1);
|
||||||
|
ft_strchr(env_line, '=')[0] = 0;
|
||||||
|
name = ft_strdup(env_line);
|
||||||
|
if (!name)
|
||||||
|
return (-1);
|
||||||
|
env->name = name;
|
||||||
|
env->content = content;
|
||||||
|
env->next = NULL;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
t_env *env_create_el(char *env_line)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
char *name;
|
||||||
|
char *content;
|
||||||
|
|
||||||
|
content = ft_strdup(ft_strchr(env_line, '=') + 1);
|
||||||
|
if (!content)
|
||||||
|
return (NULL);
|
||||||
|
ft_strchr(env_line, '=')[0] = 0;
|
||||||
|
name = ft_strdup(env_line);
|
||||||
|
if (!name)
|
||||||
|
return (NULL);
|
||||||
|
new = ft_envnew(name, content);
|
||||||
|
return (new);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_init(char **env_d, t_env *env)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
int i;
|
||||||
|
char bool_first_el;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
bool_first_el = true;
|
||||||
|
while (env_d[i])
|
||||||
|
{
|
||||||
|
if (bool_first_el)
|
||||||
|
i = env_create_first_el(env_d[i], env);
|
||||||
|
if (bool_first_el && i < 0)
|
||||||
|
return (1);
|
||||||
|
if (bool_first_el)
|
||||||
|
bool_first_el = false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new = env_create_el(env_d[i]);
|
||||||
|
if (!new)
|
||||||
|
{
|
||||||
|
ft_envclear(&env, free);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
ft_envadd_back(&env, new);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_append(char *name, char *content, t_env *env)
|
||||||
|
{
|
||||||
|
char *new_content;
|
||||||
|
|
||||||
|
while (env && ft_strcmp(env->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env)
|
||||||
|
return (-1);
|
||||||
|
new_content = ft_calloc(1, ft_strlen(env->content) + ft_strlen(content));
|
||||||
|
ft_strlcpy(new_content, env->content, ft_strlen(env->content) + 1);
|
||||||
|
ft_strlcpy(new_content + ft_strlen(env->content),
|
||||||
|
content, ft_strlen(content) + 1);
|
||||||
|
free(env->content);
|
||||||
|
env->content = new_content;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_edit(char *name, char *content, t_env *env)
|
||||||
|
{
|
||||||
|
while (env && ft_strcmp(env->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env)
|
||||||
|
return (-1);
|
||||||
|
free(env->content);
|
||||||
|
env->content = content;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_delete(char *name, t_env *env)
|
||||||
|
{
|
||||||
|
// char *new_content;
|
||||||
|
t_env *tmp;
|
||||||
|
|
||||||
|
while (env && env->next && ft_strcmp(env->next->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env || !env->next)
|
||||||
|
return (-1);
|
||||||
|
ft_free("cc", &env->next->name, &env->next->content);
|
||||||
|
tmp = env->next;
|
||||||
|
env->next = env->next->next;
|
||||||
|
free(tmp);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void env_print(t_env *env)
|
||||||
|
{
|
||||||
|
while (env)
|
||||||
|
{
|
||||||
|
printf("%s:%s\n", env->name, env->content);
|
||||||
|
env = env->next;
|
||||||
|
}
|
||||||
|
}
|
162
src/env/env_cmd_REMOTE_1565069.c
vendored
Normal file
162
src/env/env_cmd_REMOTE_1565069.c
vendored
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* env_cmd.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/05/06 19:09:50 by mmoussou #+# #+# */
|
||||||
|
/* Updated: 2024/05/07 13:58:48 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "minishell.h"
|
||||||
|
|
||||||
|
char **env_get(t_env *env)
|
||||||
|
{
|
||||||
|
char **exec_env;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
exec_env = malloc(sizeof(char *) * (ft_envsize(env) + 1));
|
||||||
|
if (!exec_env)
|
||||||
|
return (exec_env);
|
||||||
|
exec_env[ft_envsize(env)] = NULL;
|
||||||
|
i = 0;
|
||||||
|
while (env)
|
||||||
|
{
|
||||||
|
exec_env[i] = malloc(ft_strlen(env->name)
|
||||||
|
+ ft_strlen(env->content) + 2);
|
||||||
|
if (!exec_env[i])
|
||||||
|
{
|
||||||
|
ft_free("a", exec_env);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
ft_strlcpy(exec_env[i], env->name, ft_strlen(env->name) + 1);
|
||||||
|
exec_env[i][ft_strlen(env->name)] = '=';
|
||||||
|
ft_strlcpy(exec_env[i] + ft_strlen(env->name) + 1,
|
||||||
|
env->content, ft_strlen(env->content) + 1);
|
||||||
|
env = env->next;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (exec_env);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_create_first_el(char *env_line, t_env *env)
|
||||||
|
{
|
||||||
|
// t_env *new;
|
||||||
|
char *name;
|
||||||
|
char *content;
|
||||||
|
|
||||||
|
content = ft_strdup(ft_strchr(env_line, '=') + 1);
|
||||||
|
if (!content)
|
||||||
|
return (-1);
|
||||||
|
ft_strchr(env_line, '=')[0] = 0;
|
||||||
|
name = ft_strdup(env_line);
|
||||||
|
if (!name)
|
||||||
|
return (-1);
|
||||||
|
env->name = name;
|
||||||
|
env->content = content;
|
||||||
|
env->next = NULL;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
t_env *env_create_el(char *env_line)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
char *name;
|
||||||
|
char *content;
|
||||||
|
|
||||||
|
content = ft_strdup(ft_strchr(env_line, '=') + 1);
|
||||||
|
if (!content)
|
||||||
|
return (NULL);
|
||||||
|
ft_strchr(env_line, '=')[0] = 0;
|
||||||
|
name = ft_strdup(env_line);
|
||||||
|
if (!name)
|
||||||
|
return (NULL);
|
||||||
|
new = ft_envnew(name, content);
|
||||||
|
return (new);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_init(char **env_d, t_env *env)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
int i;
|
||||||
|
char bool_first_el;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
bool_first_el = true;
|
||||||
|
while (env_d[i])
|
||||||
|
{
|
||||||
|
if (bool_first_el)
|
||||||
|
i = env_create_first_el(env_d[i], env);
|
||||||
|
if (bool_first_el && i < 0)
|
||||||
|
return (1);
|
||||||
|
if (bool_first_el)
|
||||||
|
bool_first_el = false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new = env_create_el(env_d[i]);
|
||||||
|
if (!new)
|
||||||
|
{
|
||||||
|
ft_envclear(&env, free);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
ft_envadd_back(&env, new);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_append(char *name, char *content, t_env *env)
|
||||||
|
{
|
||||||
|
char *new_content;
|
||||||
|
|
||||||
|
while (env && ft_strcmp(env->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env)
|
||||||
|
return (-1);
|
||||||
|
new_content = ft_calloc(1, ft_strlen(env->content) + ft_strlen(content));
|
||||||
|
ft_strlcpy(new_content, env->content, ft_strlen(env->content) + 1);
|
||||||
|
ft_strlcpy(new_content + ft_strlen(env->content),
|
||||||
|
content, ft_strlen(content) + 1);
|
||||||
|
free(env->content);
|
||||||
|
env->content = new_content;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_edit(char *name, char *content, t_env *env)
|
||||||
|
{
|
||||||
|
while (env && ft_strcmp(env->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env)
|
||||||
|
return (-1);
|
||||||
|
free(env->content);
|
||||||
|
env->content = content;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_delete(char *name, t_env *env)
|
||||||
|
{
|
||||||
|
// char *new_content;
|
||||||
|
t_env *tmp;
|
||||||
|
|
||||||
|
while (env && env->next && ft_strcmp(env->next->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env || !env->next)
|
||||||
|
return (-1);
|
||||||
|
ft_free("cc", &env->next->name, &env->next->content);
|
||||||
|
tmp = env->next;
|
||||||
|
env->next = env->next->next;
|
||||||
|
free(tmp);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void env_print(t_env *env)
|
||||||
|
{
|
||||||
|
while (env)
|
||||||
|
{
|
||||||
|
printf("%s:%s\n", env->name, env->content);
|
||||||
|
env = env->next;
|
||||||
|
}
|
||||||
|
}
|
162
src/env/env_cmd_REMOTE_1565172.c
vendored
Normal file
162
src/env/env_cmd_REMOTE_1565172.c
vendored
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* env_cmd.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/05/06 19:09:50 by mmoussou #+# #+# */
|
||||||
|
/* Updated: 2024/05/07 13:58:48 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "minishell.h"
|
||||||
|
|
||||||
|
char **env_get(t_env *env)
|
||||||
|
{
|
||||||
|
char **exec_env;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
exec_env = malloc(sizeof(char *) * (ft_envsize(env) + 1));
|
||||||
|
if (!exec_env)
|
||||||
|
return (exec_env);
|
||||||
|
exec_env[ft_envsize(env)] = NULL;
|
||||||
|
i = 0;
|
||||||
|
while (env)
|
||||||
|
{
|
||||||
|
exec_env[i] = malloc(ft_strlen(env->name)
|
||||||
|
+ ft_strlen(env->content) + 2);
|
||||||
|
if (!exec_env[i])
|
||||||
|
{
|
||||||
|
ft_free("a", exec_env);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
ft_strlcpy(exec_env[i], env->name, ft_strlen(env->name) + 1);
|
||||||
|
exec_env[i][ft_strlen(env->name)] = '=';
|
||||||
|
ft_strlcpy(exec_env[i] + ft_strlen(env->name) + 1,
|
||||||
|
env->content, ft_strlen(env->content) + 1);
|
||||||
|
env = env->next;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (exec_env);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_create_first_el(char *env_line, t_env *env)
|
||||||
|
{
|
||||||
|
// t_env *new;
|
||||||
|
char *name;
|
||||||
|
char *content;
|
||||||
|
|
||||||
|
content = ft_strdup(ft_strchr(env_line, '=') + 1);
|
||||||
|
if (!content)
|
||||||
|
return (-1);
|
||||||
|
ft_strchr(env_line, '=')[0] = 0;
|
||||||
|
name = ft_strdup(env_line);
|
||||||
|
if (!name)
|
||||||
|
return (-1);
|
||||||
|
env->name = name;
|
||||||
|
env->content = content;
|
||||||
|
env->next = NULL;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
t_env *env_create_el(char *env_line)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
char *name;
|
||||||
|
char *content;
|
||||||
|
|
||||||
|
content = ft_strdup(ft_strchr(env_line, '=') + 1);
|
||||||
|
if (!content)
|
||||||
|
return (NULL);
|
||||||
|
ft_strchr(env_line, '=')[0] = 0;
|
||||||
|
name = ft_strdup(env_line);
|
||||||
|
if (!name)
|
||||||
|
return (NULL);
|
||||||
|
new = ft_envnew(name, content);
|
||||||
|
return (new);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_init(char **env_d, t_env *env)
|
||||||
|
{
|
||||||
|
t_env *new;
|
||||||
|
int i;
|
||||||
|
char bool_first_el;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
bool_first_el = true;
|
||||||
|
while (env_d[i])
|
||||||
|
{
|
||||||
|
if (bool_first_el)
|
||||||
|
i = env_create_first_el(env_d[i], env);
|
||||||
|
if (bool_first_el && i < 0)
|
||||||
|
return (1);
|
||||||
|
if (bool_first_el)
|
||||||
|
bool_first_el = false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new = env_create_el(env_d[i]);
|
||||||
|
if (!new)
|
||||||
|
{
|
||||||
|
ft_envclear(&env, free);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
ft_envadd_back(&env, new);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_append(char *name, char *content, t_env *env)
|
||||||
|
{
|
||||||
|
char *new_content;
|
||||||
|
|
||||||
|
while (env && ft_strcmp(env->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env)
|
||||||
|
return (-1);
|
||||||
|
new_content = ft_calloc(1, ft_strlen(env->content) + ft_strlen(content));
|
||||||
|
ft_strlcpy(new_content, env->content, ft_strlen(env->content) + 1);
|
||||||
|
ft_strlcpy(new_content + ft_strlen(env->content),
|
||||||
|
content, ft_strlen(content) + 1);
|
||||||
|
free(env->content);
|
||||||
|
env->content = new_content;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_edit(char *name, char *content, t_env *env)
|
||||||
|
{
|
||||||
|
while (env && ft_strcmp(env->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env)
|
||||||
|
return (-1);
|
||||||
|
free(env->content);
|
||||||
|
env->content = content;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int env_delete(char *name, t_env *env)
|
||||||
|
{
|
||||||
|
// char *new_content;
|
||||||
|
t_env *tmp;
|
||||||
|
|
||||||
|
while (env && env->next && ft_strcmp(env->next->name, name))
|
||||||
|
env = env->next;
|
||||||
|
if (!env || !env->next)
|
||||||
|
return (-1);
|
||||||
|
ft_free("cc", &env->next->name, &env->next->content);
|
||||||
|
tmp = env->next;
|
||||||
|
env->next = env->next->next;
|
||||||
|
free(tmp);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void env_print(t_env *env)
|
||||||
|
{
|
||||||
|
while (env)
|
||||||
|
{
|
||||||
|
printf("%s:%s\n", env->name, env->content);
|
||||||
|
env = env->next;
|
||||||
|
}
|
||||||
|
}
|
28
src/main.c
28
src/main.c
@ -6,7 +6,7 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/04/24 11:18:04 by adjoly #+# #+# */
|
/* Created: 2024/04/24 11:18:04 by adjoly #+# #+# */
|
||||||
/* Updated: 2024/05/04 15:33:54 by adjoly ### ########.fr */
|
/* Updated: 2024/05/07 14:11:35 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -15,7 +15,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include "libft.h"
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
#include "parsing.h"
|
||||||
|
|
||||||
void print_cmd(t_cmd cmd)
|
void print_cmd(t_cmd cmd)
|
||||||
{
|
{
|
||||||
@ -27,12 +29,29 @@ void print_cmd(t_cmd cmd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_pipe(t_list *pipe)
|
||||||
|
{
|
||||||
|
t_list *tmp;
|
||||||
|
|
||||||
|
tmp = pipe;
|
||||||
|
if (!pipe->next)
|
||||||
|
{
|
||||||
|
print_cmd(*(t_cmd*)tmp->content);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
while (tmp)
|
||||||
|
{
|
||||||
|
print_cmd(*(t_cmd*)tmp->content);
|
||||||
|
tmp = tmp->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int ac, char **av, char **env)
|
int main(int ac, char **av, char **env)
|
||||||
{
|
{
|
||||||
char *test;
|
char *test;
|
||||||
char **lll;
|
char **lll;
|
||||||
char *prompt;
|
char *prompt;
|
||||||
t_cmd *cmd;
|
t_list *cmd;
|
||||||
|
|
||||||
(void)ac;
|
(void)ac;
|
||||||
(void)av;
|
(void)av;
|
||||||
@ -48,9 +67,8 @@ int main(int ac, char **av, char **env)
|
|||||||
continue;
|
continue;
|
||||||
if (is_str(test, "exit"))
|
if (is_str(test, "exit"))
|
||||||
break;
|
break;
|
||||||
cmd = ft_calloc(sizeof(t_cmd), 1);
|
cmd = split_pipe(test);
|
||||||
*cmd = split_cmd(test);
|
//print_pipe(cmd);
|
||||||
print_cmd(*cmd);
|
|
||||||
ft_free("a", &lll);
|
ft_free("a", &lll);
|
||||||
}
|
}
|
||||||
ft_free("a", &lll);
|
ft_free("a", &lll);
|
||||||
|
0
src/parsing/get_infile.c
Normal file
0
src/parsing/get_infile.c
Normal file
0
src/parsing/get_outfile.c
Normal file
0
src/parsing/get_outfile.c
Normal file
@ -6,22 +6,23 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/04 15:00:32 by adjoly #+# #+# */
|
/* Created: 2024/05/04 15:00:32 by adjoly #+# #+# */
|
||||||
/* Updated: 2024/05/04 15:20:29 by adjoly ### ########.fr */
|
/* Updated: 2024/05/07 13:56:57 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "parsing.h"
|
#include "parsing.h"
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
t_cmd split_cmd(char *cmd_av)
|
t_cmd *split_cmd(char *cmd_av)
|
||||||
{
|
{
|
||||||
char **split;
|
char **split;
|
||||||
char **tmp_split;
|
char **tmp_split;
|
||||||
t_cmd cmd;
|
t_cmd *cmd;
|
||||||
|
|
||||||
split = ft_split(cmd_av, 32);
|
split = ft_split(cmd_av, 32);
|
||||||
tmp_split = split;
|
tmp_split = split;
|
||||||
cmd.cmd = ft_strdup(*tmp_split);
|
cmd = ft_calloc(sizeof(t_cmd), 1);
|
||||||
cmd.argv = tmp_split;
|
cmd->cmd = ft_strdup(*tmp_split);
|
||||||
|
cmd->argv = tmp_split;
|
||||||
return (cmd);
|
return (cmd);
|
||||||
}
|
}
|
||||||
|
31
src/parsing/split_pipe.c
Normal file
31
src/parsing/split_pipe.c
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* split_pipe.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/05/07 13:26:40 by adjoly #+# #+# */
|
||||||
|
/* Updated: 2024/05/08 14:38:33 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
#include "parsing.h"
|
||||||
|
|
||||||
|
t_list *split_pipe(char *readline)
|
||||||
|
{
|
||||||
|
//char *tmp;
|
||||||
|
char *av;
|
||||||
|
//char *cmd_start;
|
||||||
|
t_list *list;
|
||||||
|
|
||||||
|
list = NULL;
|
||||||
|
if (!list)
|
||||||
|
{
|
||||||
|
av = ft_calloc(sizeof(readline), sizeof(char));
|
||||||
|
ft_strlcpy(av, readline, ft_strlen(readline));
|
||||||
|
ft_lstadd_back(&list, ft_lstnew((void*)split_cmd(av)));
|
||||||
|
}
|
||||||
|
return (list);
|
||||||
|
}
|
Reference in New Issue
Block a user