1
0
mirror of https://github.com/KeyZox71/ft_minipowershell.git synced 2025-05-13 16:08:45 +02:00

」 feat: Parsing working but not handling error

This commit is contained in:
2024-05-31 19:26:09 +02:00
parent 6bbdef9d7c
commit 5a71c50897
7 changed files with 57 additions and 32 deletions

View File

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_cmd_list.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/31 12:47:13 by adjoly #+# #+# */
/* Updated: 2024/05/31 13:29:46 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include "parsing.h"
t_list *get_cmd_list(t_list *list)
{
t_list *tmp;
t_list *cmd_list;
tmp = list;
cmd_list = NULL;
while (tmp)
{
ft_lstadd_back(&cmd_list, ft_lstnew(get_redir_fd(tmp->content)));
tmp = tmp->next;
}
return (cmd_list);
}

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/30 10:48:41 by adjoly #+# #+# */
/* Updated: 2024/05/30 17:47:43 by adjoly ### ########.fr */
/* Updated: 2024/05/31 19:16:41 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -46,11 +46,10 @@ t_cmd *get_redir_fd(void *content)
in.sign = INFILE;
in.file_name = tmp_redir->file_name;
}
else
{
out.sign = tmp_redir->sign;
out.file_name = tmp_redir->file_name;
}
else if (tmp_redir->sign == OUTFILE)
cmd->outfile = open(tmp_redir->file_name, O_CREAT | O_TRUNC | O_WRONLY, 0644);
else if (tmp_redir->sign == OUT_APPEND)
cmd->outfile = open(tmp_redir->file_name, O_CREAT | O_APPEND | O_WRONLY, 0644);
tmp = tmp->next;
}
if (in.sign == OUTFILE)
@ -62,9 +61,6 @@ t_cmd *get_redir_fd(void *content)
}
if (out.sign == INFILE)
cmd->outfile = STDOUT_FILENO;
else if (out.sign == OUTFILE)
cmd->outfile = open(out.file_name, O_CREAT | O_TRUNC | O_WRONLY);
else if (out.sign == OUT_APPEND)
cmd->outfile = open(out.file_name, O_CREAT | O_APPEND | O_WRONLY);
cmd = split_cmd(token->argv, cmd);
return (cmd);
}

View File

@ -6,23 +6,24 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/04 15:00:32 by adjoly #+# #+# */
/* Updated: 2024/05/30 16:31:04 by adjoly ### ########.fr */
/* Updated: 2024/05/31 12:57:18 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "parsing.h"
#include "libft.h"
/*t_cmd *split_cmd(char *cmd_av)
t_cmd *split_cmd(char *cmd_av, t_cmd *cmd)
{
char *tmp;
char **split;
char **tmp_split;
t_cmd *cmd;
split = ft_split(cmd_av, 32);
tmp_split = split;
cmd = ft_calloc(sizeof(t_cmd), 1);
cmd->cmd = ft_strdup(*tmp_split);
cmd->argv = tmp_split;
tmp = cmd_av;
split = ft_split(cmd_av, ' ');
cmd->cmd = ft_strdup(*split);
ft_free("a", &split);
while (*tmp && *tmp == ' ')
tmp++;
cmd->argv = ft_strdup(tmp);
return (cmd);
}*/
}