diff --git a/Makefile b/Makefile index 61635b9..3798aa8 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ srcs = \ src/parser/wordsplit/tokenizing_6_10.c \ src/parser/wordsplit/wordsplit.c \ src/parser/wordsplit/wordsplit_utils.c \ - src/postprocess/redirections/redirections.c \ + src/postprocess/redirections/redirection_parsing.c \ objs = $(srcs:.c=.o) export objs diff --git a/src/parser/simple_cmd/simple_cmd.h b/src/parser/simple_cmd/simple_cmd.h index cee6bd1..f3f01b5 100644 --- a/src/parser/simple_cmd/simple_cmd.h +++ b/src/parser/simple_cmd/simple_cmd.h @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/21 12:24:57 by khais #+# #+# */ -/* Updated: 2025/03/07 12:29:16 by khais ### ########.fr */ +/* Updated: 2025/03/07 13:12:12 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,12 +14,11 @@ # define SIMPLE_CMD_H # include "../wordlist/wordlist.h" -# include "../../postprocess/redirections/redirections.h" typedef struct s_simple_cmd { - t_wordlist *words; - t_redir_list *redirections; + t_wordlist *words; + struct s_redirection_list *redirections; } t_simple_cmd; t_simple_cmd *simple_cmd_from_wordlist(t_wordlist *words); diff --git a/src/postprocess/redirections/redirections.h b/src/postprocess/redirections/redirection.h similarity index 58% rename from src/postprocess/redirections/redirections.h rename to src/postprocess/redirections/redirection.h index 7ba777b..8a9bfa6 100644 --- a/src/postprocess/redirections/redirections.h +++ b/src/postprocess/redirections/redirection.h @@ -1,36 +1,20 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* redirections.h :+: :+: :+: */ +/* redirection.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2025/03/07 11:59:31 by khais #+# #+# */ -/* Updated: 2025/03/07 14:23:48 by khais ### ########.fr */ +/* Created: 2025/03/07 14:26:06 by khais #+# #+# */ +/* Updated: 2025/03/07 14:44:12 by khais ### ########.fr */ /* */ /* ************************************************************************** */ -#ifndef REDIRECTIONS_H -# define REDIRECTIONS_H +#ifndef REDIRECTION_H +# define REDIRECTION_H # include "../../parser/worddesc/worddesc.h" - -/* -** Type of redirection. -*/ -typedef enum e_redirection_type -{ - // Invalid - REDIR_INVALID, - // < - REDIR_INPUT, - // > - REDIR_OUTPUT, - // << - REDIR_HERE_DOC, - // >> - REDIR_APPEND, -} t_redir_type; +# include "redirection_type.h" typedef struct s_redirection { @@ -41,14 +25,4 @@ typedef struct s_redirection t_worddesc *marker; } t_redirection; -typedef struct s_redirection_list -{ - t_redirection *redirection; - struct s_redirection_list *next; -} t_redir_list; - -struct s_simple_cmd; - -struct s_simple_cmd *parse_redirections(struct s_simple_cmd *cmd); - -#endif // REDIRECTIONS_H +#endif // REDIRECTION_BASICS_H diff --git a/src/postprocess/redirections/redirection_list.h b/src/postprocess/redirections/redirection_list.h new file mode 100644 index 0000000..d15709a --- /dev/null +++ b/src/postprocess/redirections/redirection_list.h @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* redirection_list.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: khais +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/03/07 14:29:32 by khais #+# #+# */ +/* Updated: 2025/03/07 14:43:50 by khais ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef REDIRECTION_LIST_H +# define REDIRECTION_LIST_H + +# include "redirection.h" + +typedef struct s_redirection_list +{ + t_redirection *redirection; + struct s_redirection_list *next; +} t_redir_list; + +#endif // REDIRECTION_LIST_H diff --git a/src/postprocess/redirections/redirections.c b/src/postprocess/redirections/redirection_parsing.c similarity index 89% rename from src/postprocess/redirections/redirections.c rename to src/postprocess/redirections/redirection_parsing.c index 8538db0..1b29e26 100644 --- a/src/postprocess/redirections/redirections.c +++ b/src/postprocess/redirections/redirection_parsing.c @@ -6,12 +6,11 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/07 12:30:04 by khais #+# #+# */ -/* Updated: 2025/03/07 12:32:02 by khais ### ########.fr */ +/* Updated: 2025/03/07 14:43:06 by khais ### ########.fr */ /* */ /* ************************************************************************** */ -#include "redirections.h" -#include +#include "redirection_parsing.h" struct s_simple_cmd *parse_redirections(struct s_simple_cmd *cmd) { diff --git a/src/postprocess/redirections/redirection_parsing.h b/src/postprocess/redirections/redirection_parsing.h new file mode 100644 index 0000000..75bcc66 --- /dev/null +++ b/src/postprocess/redirections/redirection_parsing.h @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* redirection_parsing.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: khais +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/03/07 11:59:31 by khais #+# #+# */ +/* Updated: 2025/03/07 14:38:30 by khais ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef REDIRECTION_PARSING_H +# define REDIRECTION_PARSING_H + +# include "../../parser/simple_cmd/simple_cmd.h" + +t_simple_cmd *parse_redirections(t_simple_cmd *cmd); + +#endif // REDIRECTIONS_H diff --git a/src/postprocess/redirections/redirection_type.h b/src/postprocess/redirections/redirection_type.h new file mode 100644 index 0000000..19897b2 --- /dev/null +++ b/src/postprocess/redirections/redirection_type.h @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* redirection_type.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: khais +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/03/07 14:37:12 by khais #+# #+# */ +/* Updated: 2025/03/07 14:44:31 by khais ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef REDIRECTION_TYPE_H +# define REDIRECTION_TYPE_H + +/* +** Type of redirection. +*/ +typedef enum e_redirection_type +{ + // Invalid + REDIR_INVALID, + // < + REDIR_INPUT, + // > + REDIR_OUTPUT, + // << + REDIR_HERE_DOC, + // >> + REDIR_APPEND, +} t_redir_type; + +#endif // REDIRECTION_TYPE_H diff --git a/tests/test_redirection_parsing.c b/tests/test_redirection_parsing.c index ea76762..689ff2f 100644 --- a/tests/test_redirection_parsing.c +++ b/tests/test_redirection_parsing.c @@ -6,14 +6,14 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/07 11:55:37 by khais #+# #+# */ -/* Updated: 2025/03/07 12:00:13 by khais ### ########.fr */ +/* Updated: 2025/03/07 14:43:15 by khais ### ########.fr */ /* */ /* ************************************************************************** */ #include #include "../src/parser/simple_cmd/simple_cmd.h" #include "../src/parser/wordsplit/wordsplit.h" -#include "../src/postprocess/redirections/redirections.h" +#include "../src/postprocess/redirections/redirection_parsing.h" static t_simple_cmd *parse_simple_cmd(char *input) {