summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-04-22 22:54:14 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-04-22 22:54:14 +0200
commit91b822851212a43feca13a7f540c451074132c3d (patch)
tree22b11850fd656b0fbc08cfde206bd377773e1b67
parentStarting to do redirections (diff)
download42-minishell-91b822851212a43feca13a7f540c451074132c3d.tar.gz
42-minishell-91b822851212a43feca13a7f540c451074132c3d.tar.bz2
42-minishell-91b822851212a43feca13a7f540c451074132c3d.tar.xz
42-minishell-91b822851212a43feca13a7f540c451074132c3d.tar.zst
42-minishell-91b822851212a43feca13a7f540c451074132c3d.zip
Implementing redirections
-rw-r--r--src/ft_m_loop.c5
-rw-r--r--src/ft_p_lcom.c28
-rw-r--r--src/ft_p_lcom.h2
-rw-r--r--src/ft_s_lcom.c3
4 files changed, 35 insertions, 3 deletions
diff --git a/src/ft_m_loop.c b/src/ft_m_loop.c
index a96eea2..08bc0e4 100644
--- a/src/ft_m_loop.c
+++ b/src/ft_m_loop.c
@@ -37,9 +37,10 @@ uint8_t
ft_memdel((void*)&line);
ft_e_lcom(msh);
ft_lcom_clear(&msh->curr);
- /* TODO: GNL leak on "msh ~> exit" */
- /* TODO: redirect vvv redirect */
+ /* TODO: GNL leak on "msh ~> exit" */
+ /* TODO: redirect vvv redirect */
/* "msh ~> echo qwe >/dev/null; echo *.vscode >> .gitignore" */
+ /* TODO: "msh ~> some command \": re GNL into ft_nrealloc */
}
else
{
diff --git a/src/ft_p_lcom.c b/src/ft_p_lcom.c
index 15247a2..ec30f43 100644
--- a/src/ft_p_lcom.c
+++ b/src/ft_p_lcom.c
@@ -15,6 +15,34 @@
#include "ft_s_lcom.h"
#include "ft_s_struct.h"
+void
+ ft_check_redir_file()
+{
+}
+
+void
+ ft_get_redir(const char word[],
+ t_lcom **link)
+{
+ char *ptr;
+
+ ptr = word;
+ while (*ptr)
+ {
+ if (*ptr == '<')
+ {
+ *link->redir = -1;
+ break ;
+ }
+ if (*ptr == '>')
+ {
+ *link->redir = (*(ptr + 1) == '>') ? (2) : (1);
+ break ;
+ }
+ ptr++;
+ }
+}
+
int8_t
ft_p_lcom(const char line[],
const uint64_t count,
diff --git a/src/ft_p_lcom.h b/src/ft_p_lcom.h
index 556045b..4cbce6a 100644
--- a/src/ft_p_lcom.h
+++ b/src/ft_p_lcom.h
@@ -16,6 +16,8 @@
#include <stdint.h>
#include "ft_s_struct.h"
+void ft_get_redir(const char word[],
+ t_lcom **link);
int8_t ft_p_lcom(const char line[],
const uint64_t count,
t_msh *msh);
diff --git a/src/ft_s_lcom.c b/src/ft_s_lcom.c
index 7a72378..6661b1e 100644
--- a/src/ft_s_lcom.c
+++ b/src/ft_s_lcom.c
@@ -105,9 +105,10 @@ t_lcom
link->com = NULL;
link->args = NULL;
link->rdrpath = NULL;
+ /* TODO: redirections here */
+ ft_get_redir(&link);
if (!(words = ft_split(word, ' ')))
return (NULL);
- /* TODO: redirections here */
if (ft_fill_lcom(words, &link) < 0)
{
ft_delwords(words);