Added a redirect checker and started ioredirect function
This commit is contained in:
parent
c21e2fb7f6
commit
adc4064f08
47
src/Pish.c
47
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,17 +55,28 @@ 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();
|
||||
|
Loading…
Reference in New Issue
Block a user