Archived
1
0

[] feat: parsing working

This commit is contained in:
2024-04-02 11:42:01 +02:00
parent 9c1f172983
commit 7d09b4cb31
7 changed files with 21 additions and 7 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
pipex

Binary file not shown.

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/21 10:03:04 by adjoly #+# #+# */
/* Updated: 2024/03/30 13:22:17 by adjoly ### ########.fr */
/* Updated: 2024/04/02 11:08:15 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,7 +19,7 @@ int main(int ac, char **av)
t_pcmd *tmp;
char **option_tmp;
cmd = parse_cmd(ac, av);
cmd = parse_cmd(ac, av + 2);
tmp = cmd;
while (tmp && (*tmp).cmd)
{

@ -6,13 +6,28 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/22 21:13:26 by adjoly #+# #+# */
/* Updated: 2024/03/30 12:01:17 by adjoly ### ########.fr */
/* Updated: 2024/04/02 11:08:57 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "parsing.h"
#include "libft.h"
size_t ft_arrlen(char **arr)
{
size_t len;
char **tmp;
tmp = arr;
len = 0;
while (*tmp)
{
len += ft_strlen(*tmp);
tmp++;
}
return (len);
}
t_pcmd split_cmd(char *cmd_av)
{
char **split;
@ -21,8 +36,7 @@ t_pcmd split_cmd(char *cmd_av)
split = ft_split(cmd_av, 32);
tmp_split = split;
cmd.cmd = *tmp_split;
tmp_split++;
cmd.cmd = ft_strdup(*tmp_split);
cmd.option = tmp_split;
return (cmd);
}
@ -34,9 +48,9 @@ t_pcmd *parse_cmd(int ac, char **av)
t_pcmd *cmd_tmp;
(void)ac;
cmd_arr = ft_calloc(10000, 1);
cmd_arr = ft_calloc(ac, sizeof(t_pcmd) + 1);
cmd_tmp = cmd_arr;
tmp = av + 2;
tmp = av;
while (*tmp)
{
*cmd_tmp = split_cmd(*tmp);