[✨] feat: parsing working but free does not
This commit is contained in:
BIN
.cache/clangd/index/ft_freetab.c.634110A41B036729.idx
Normal file
BIN
.cache/clangd/index/ft_freetab.c.634110A41B036729.idx
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.cache/clangd/index/parsing.c.B79530D8B421E683.idx
Normal file
BIN
.cache/clangd/index/parsing.c.B79530D8B421E683.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/parsing.h.E14E231C05813896.idx
Normal file
BIN
.cache/clangd/index/parsing.h.E14E231C05813896.idx
Normal file
Binary file not shown.
@ -14,8 +14,46 @@
|
||||
"src/main.c",
|
||||
"-c",
|
||||
"-o",
|
||||
"obj/main.o"
|
||||
"obj/src/main.o"
|
||||
],
|
||||
"file": "src/main.c"
|
||||
},
|
||||
{
|
||||
"directory": "/nfs/homes/adjoly/Documents/pipex",
|
||||
"arguments": [
|
||||
"cc",
|
||||
"-I",
|
||||
"include/",
|
||||
"-I",
|
||||
"libft/",
|
||||
"-Werror",
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-g",
|
||||
"src/parsing/parsing.c",
|
||||
"-c",
|
||||
"-o",
|
||||
"obj/src/parsing/parsing.o"
|
||||
],
|
||||
"file": "src/parsing/parsing.c"
|
||||
},
|
||||
{
|
||||
"directory": "/nfs/homes/adjoly/Documents/pipex",
|
||||
"arguments": [
|
||||
"cc",
|
||||
"-I",
|
||||
"include/",
|
||||
"-I",
|
||||
"libft/",
|
||||
"-Werror",
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-g",
|
||||
"src/utils/ft_freetab.c",
|
||||
"-c",
|
||||
"-o",
|
||||
"obj/src/utils/ft_freetab.o"
|
||||
],
|
||||
"file": "src/utils/ft_freetab.c"
|
||||
}
|
||||
]
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/28 16:54:40 by adjoly #+# #+# */
|
||||
/* Updated: 2024/03/28 22:37:29 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/03/29 10:41:40 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -20,5 +20,7 @@ typedef struct s_pcmd
|
||||
} t_pcmd;
|
||||
|
||||
void ft_freearr(char **arr);
|
||||
t_pcmd split_cmd(char *cmd_av);
|
||||
t_pcmd *parse_cmd(int ac, char **av);
|
||||
|
||||
#endif
|
BIN
obj/src/main.o
BIN
obj/src/main.o
Binary file not shown.
BIN
obj/src/parsing/parsing.o
Normal file
BIN
obj/src/parsing/parsing.o
Normal file
Binary file not shown.
BIN
obj/src/utils/ft_freetab.o
Normal file
BIN
obj/src/utils/ft_freetab.o
Normal file
Binary file not shown.
32
src/main.c
32
src/main.c
@ -6,14 +6,40 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/21 10:03:04 by adjoly #+# #+# */
|
||||
/* Updated: 2024/03/28 23:04:32 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/03/30 13:22:17 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
#include "parsing.h"
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
ft_putstr_fd(*av, 1);
|
||||
return (ac);
|
||||
t_pcmd *cmd;
|
||||
t_pcmd *tmp;
|
||||
char **option_tmp;
|
||||
|
||||
cmd = parse_cmd(ac, av);
|
||||
tmp = cmd;
|
||||
while (tmp && (*tmp).cmd)
|
||||
{
|
||||
ft_printf("cmd : %s\n", (*tmp).cmd);
|
||||
option_tmp = (*tmp).option;
|
||||
while (*option_tmp)
|
||||
{
|
||||
ft_printf("%s\n", *option_tmp);
|
||||
option_tmp++;
|
||||
}
|
||||
tmp++;
|
||||
}
|
||||
tmp = cmd;
|
||||
while (tmp && (*tmp).cmd)
|
||||
{
|
||||
if (tmp->option)
|
||||
ft_freearr(tmp->option);
|
||||
free(tmp->cmd);
|
||||
tmp++;
|
||||
}
|
||||
free(cmd);
|
||||
return (EXIT_SUCCESS);
|
||||
}
|
||||
|
@ -6,29 +6,42 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/22 21:13:26 by adjoly #+# #+# */
|
||||
/* Updated: 2024/03/28 22:37:50 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/03/30 12:01:17 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#include "parsing.h"
|
||||
#include "libft.h"
|
||||
|
||||
t_pcmd split_cmd(char *cmd)
|
||||
t_pcmd split_cmd(char *cmd_av)
|
||||
{
|
||||
char **split;
|
||||
char **tmp_split;
|
||||
t_pcmd cmd;
|
||||
|
||||
split = ft_split(cmd, 32);
|
||||
split = ft_split(cmd_av, 32);
|
||||
tmp_split = split;
|
||||
cmd.cmd = *tmp_split;
|
||||
tmp_split++;
|
||||
cmd.option = tmp_split;
|
||||
return (cmd);
|
||||
}
|
||||
|
||||
t_pcmd *parse_cmd(int ac, char **av)
|
||||
{
|
||||
char **tmp;
|
||||
t_pcmd *cmd_arr;
|
||||
t_pcmd *cmd_tmp;
|
||||
|
||||
tmp = av + 1;
|
||||
(void)ac;
|
||||
cmd_arr = ft_calloc(10000, 1);
|
||||
cmd_tmp = cmd_arr;
|
||||
tmp = av + 2;
|
||||
while (*tmp)
|
||||
{
|
||||
*cmd_tmp = split_cmd(*tmp);
|
||||
cmd_tmp++;
|
||||
tmp++;
|
||||
}
|
||||
return (cmd_arr);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/28 22:34:09 by adjoly #+# #+# */
|
||||
/* Updated: 2024/03/28 22:36:50 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/03/30 11:58:39 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -17,9 +17,10 @@ void ft_freearr(char **arr)
|
||||
char **tmp;
|
||||
|
||||
tmp = arr;
|
||||
while(*tmp)
|
||||
while(tmp && *tmp)
|
||||
{
|
||||
free(*tmp);
|
||||
tmp++;
|
||||
}
|
||||
free(arr);
|
||||
}
|
||||
|
Reference in New Issue
Block a user