From adc4064f08319ce7158f73e9c33932e3347b55c8 Mon Sep 17 00:00:00 2001
From: Samantha Boyer <sboyer@vm-10.cs.siue.edu>
Date: Sun, 23 Oct 2022 20:57:30 -0500
Subject: [PATCH] Added a redirect checker and started ioredirect function

---
 src/Pish.c | 49 +++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 43 insertions(+), 6 deletions(-)

diff --git a/src/Pish.c b/src/Pish.c
index e2cb4d1..45a0104 100644
--- a/src/Pish.c
+++ b/src/Pish.c
@@ -6,6 +6,32 @@
 #include "Integrated.h"
 #include "Pish.h"
 
+//checks if there is a special symbol for redirection
+int redirectCheck(char* command)
+{
+    int check;
+    if(strchr(str, '|') != NULL){
+        check = 1;
+    }
+    else if (strpbrk(str, ">>") != NULL){
+        check = 2;
+    }
+    else if (strchr(str, '>') != NULL){
+        check = 3;
+    }
+    else if (strchr(str, '<') != NULL){
+        check = 4;
+    }
+    else{
+        check = 0; 
+}
+//i/o Redirection (void my need to be changed)
+void ioRedirect(int sym, char* command)
+{
+  // |1, >>2, >3, <4
+  
+}
+         
 // Prints a prompt and then reads a command from the terminal
 char* getInput(void)
 {
@@ -29,18 +55,29 @@ void Pish(void)
 {
     char* command;
     int retval;
+    int redirect;
+    
     while (1)
     {
         command = getInput();
 	//Parse command
-	char* token = strtok(command, " ");
-	while(token != NULL)
+	// Need to check for |,<,>,>>
+	//redirect = redirectCheck(command);
+	if (redirect > 0)
         {
-	  //This only holds 1 command at a time then it overrides
-	  //Will need modified
-	  token = strtok(NULL, " ");
+          //ioRedirect(redirect, command);
 	}
-	
+	else
+	{
+	  char* token = strtok(command, " ");
+	  while(token != NULL)
+          {
+	    //This only holds 1 command at a time then it overrides
+	    //Will need modified
+	    token = strtok(NULL, " ");
+	  }
+	{
+	  
 	IntegratedCheck(command);
         retval = fork();
         // Child