Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <linux/limits.h>
- #include <errno.h>
- #include <unistd.h>
- #include "LineParser.h"
- void execute(cmdLine *pCmdLine);
- int main(int argc,char **argv){
- char buff_path[PATH_MAX];
- int q_flag = 1;
- getcwd(buff_path,sizeof(buff_path));
- /*puts inside buff_path the pathname of the current working directory of the
- calling process*/
- fprintf(stdout,"%s \n",buff_path);
- char commands[2048];
- while(q_flag){
- fgets(commands,2048,stdin);
- struct cmdLine* cmdLine_1;
- cmdLine_1 =parseCmdLines(commands);
- if(strcmp(cmdLine_1->arguments[0],"quit")==0){
- q_flag=0;
- }
- if(q_flag){
- execute(cmdLine_1);
- }
- /*eather may we need to free mem*/
- freeCmdLines(cmdLine_1);
- }
- return(0);
- }
- void execute(cmdLine *pCmdLine){
- int answer = execvp(pCmdLine->arguments[0],pCmdLine->arguments);
- if(answer==-1){
- perror("execvp");
- /* fprintf(stdout,"error in execvp");*/
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement