[✨] feat: parsing working
This commit is contained in:
Binary file not shown.
BIN
obj/src/main.o
BIN
obj/src/main.o
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -6,7 +6,7 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/03/21 10:03:04 by adjoly #+# #+# */
|
/* 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;
|
t_pcmd *tmp;
|
||||||
char **option_tmp;
|
char **option_tmp;
|
||||||
|
|
||||||
cmd = parse_cmd(ac, av);
|
cmd = parse_cmd(ac, av + 2);
|
||||||
tmp = cmd;
|
tmp = cmd;
|
||||||
while (tmp && (*tmp).cmd)
|
while (tmp && (*tmp).cmd)
|
||||||
{
|
{
|
||||||
|
@ -6,13 +6,28 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/03/22 21:13:26 by adjoly #+# #+# */
|
/* 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 "parsing.h"
|
||||||
#include "libft.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)
|
t_pcmd split_cmd(char *cmd_av)
|
||||||
{
|
{
|
||||||
char **split;
|
char **split;
|
||||||
@ -21,8 +36,7 @@ t_pcmd split_cmd(char *cmd_av)
|
|||||||
|
|
||||||
split = ft_split(cmd_av, 32);
|
split = ft_split(cmd_av, 32);
|
||||||
tmp_split = split;
|
tmp_split = split;
|
||||||
cmd.cmd = *tmp_split;
|
cmd.cmd = ft_strdup(*tmp_split);
|
||||||
tmp_split++;
|
|
||||||
cmd.option = tmp_split;
|
cmd.option = tmp_split;
|
||||||
return (cmd);
|
return (cmd);
|
||||||
}
|
}
|
||||||
@ -34,9 +48,9 @@ t_pcmd *parse_cmd(int ac, char **av)
|
|||||||
t_pcmd *cmd_tmp;
|
t_pcmd *cmd_tmp;
|
||||||
|
|
||||||
(void)ac;
|
(void)ac;
|
||||||
cmd_arr = ft_calloc(10000, 1);
|
cmd_arr = ft_calloc(ac, sizeof(t_pcmd) + 1);
|
||||||
cmd_tmp = cmd_arr;
|
cmd_tmp = cmd_arr;
|
||||||
tmp = av + 2;
|
tmp = av;
|
||||||
while (*tmp)
|
while (*tmp)
|
||||||
{
|
{
|
||||||
*cmd_tmp = split_cmd(*tmp);
|
*cmd_tmp = split_cmd(*tmp);
|
||||||
|
Reference in New Issue
Block a user