diff --git a/src/Integrated.c b/src/Integrated.c index d578754..339c314 100755 --- a/src/Integrated.c +++ b/src/Integrated.c @@ -89,3 +89,65 @@ void ReadPishrc(CommandStruct* command, char* inputString) } assert(close(fd) >= 0); } +// i/o redirection +void ioRedirection(char* inputString, CommandStruct* command) +{ + int newfd; + // check command standard output +if (strchr(inputString, '>' )!= NULL) + { + + newfd = open((command, O_CREAT |O_TRUNC | O_WRONLY, 0644)) <0) { + //failed + perror(command); + exit(1); + } + + // copies the new file descriptor + dup2(newfd,1); + }//this is supposed to close if statement?? + +// check command standard input + if(strchr(inputString, '<') != NULL) + { + newfd = open((command, O_CREAT |O_TRUNC | O_WRONLY, 0644)) <0) { + //failed + perror(command); + exit(1); + } + dup2(newfd,0); + } + +//check pipe + if(strchr(command, '|') != NULL) + { + + } +//check append + if (strpbrk(command, ">>") != NULL) + newfd = open((command, O_CREAT |O_TRUNC | O_WRONLY, 0644)) <0) { + //failed + perror(command); + exit(1); + } + dup2(newfd,0); + } + +//check pipe + if(strchr(command, '|') != NULL) + { + + } +//check append + if (strpbrk(command, ">>") != NULL) + { + + } +} +//Environment varibles +void varibles(char str, int count) +{ + char var[1000]; + var[count]= str; + +}