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 "Integrated.h"
|
||||||
#include "Pish.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
|
// Prints a prompt and then reads a command from the terminal
|
||||||
char* getInput(void)
|
char* getInput(void)
|
||||||
{
|
{
|
||||||
@ -29,17 +55,28 @@ void Pish(void)
|
|||||||
{
|
{
|
||||||
char* command;
|
char* command;
|
||||||
int retval;
|
int retval;
|
||||||
|
int redirect;
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
command = getInput();
|
command = getInput();
|
||||||
//Parse command
|
//Parse command
|
||||||
char* token = strtok(command, " ");
|
// Need to check for |,<,>,>>
|
||||||
while(token != NULL)
|
//redirect = redirectCheck(command);
|
||||||
|
if (redirect > 0)
|
||||||
{
|
{
|
||||||
//This only holds 1 command at a time then it overrides
|
//ioRedirect(redirect, command);
|
||||||
//Will need modified
|
|
||||||
token = strtok(NULL, " ");
|
|
||||||
}
|
}
|
||||||
|
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);
|
IntegratedCheck(command);
|
||||||
retval = fork();
|
retval = fork();
|
||||||
|
Loading…
Reference in New Issue
Block a user