Question: Question: need the pseudo code turned into a workable program as specified in the following pseudo code. Given Code: #include #include #include #include #include #include

Question: need the pseudo code turned into a workable program as specified in the following pseudo code.

Question: need the pseudo code turned into a workable program as specified

Given Code:

#include #include #include #include #include #include #include #include

#define MAXLINE 80 #define MAXARGS 20 #define MAX_PATH_LENGTH 50 #define TRUE 1

/* function prototypes */ int parseline(char *cmdline, char **argv);

/* ----------------------------------------------------------------- */ /* The main program starts here */ /* ----------------------------------------------------------------- */ int main(void) { char cmdline[MAXLINE]; char *argv[MAXARGS]; int argc; int status; pid_t pid;

/* Loop forever to wait and process commands */ while (TRUE) { /* Print your shell name: csc60mshell (m for mini shell) */ printf("cscc60mshell> ");

/* Read the command line */ fgets(cmdline, MAXLINE, stdin);

/* Call parseline to build argc/argv */ //code here

/* If user hits enter key without a command, continue to loop * again at the beginning */ /* Hint: if argc is zero, no command declared */ /* Hint: look up for the keyword "continue" in C */ //code here /* Handle build-in command: exit, pwd, or cd */ /* Put the rest of your code here */ //code here

} /* end of the while */ } /* end of main */ /* ----------------------------------------------------------------- */ /* parseline */ /* ----------------------------------------------------------------- */ /* parse input line into argc/argv format */

int parseline(char *cmdline, char **argv) { int count = 0; char *separator = " \t"; /* Includes space, Enter, Tab */ /* strtok searches for the characters listed in separator */ argv[count] = strtok(cmdline, separator); while ((argv[count] != NULL) && (count+1 Pseudo Code (Highlight indicates provided code.) int main (void) while (TRUE) int childPid; char *cmd Line; print the prompt(); i.ee. csc60mshell Use printf*/ fgets(cmdline, MAXLINE, stdin); You have to write the call. The function itself is provided: function parseline Call the function parseline, sending in cmdline & argv, getting back argc code to print out the argc and the agrv list to make sure it all came in. Required. Print a line. Ex: "Argc %i" loop starting at zero, thru less than agrc, increment by one. print each argv[loop counter] Start processing the built-in commands if argc compare equal to zero) a command was not entered, might have been just Enter or a space&Enter continue to end of while(TRUE)-loop next deal with the built-in commands Use strcmp to do the test after each command, do a continue to end of while(TRUE)-loop if ("exit") issue an exit call else if ("pwd") declare a char variable array of size MAX PATH LENGTH to hold the path do a getcwd print the path else if ("cd") declare a char variable dir as a pointer (with an if the argc is 1 use the getenv call with "HOME" and return the value from the call to variable dir else variable dir gets assigned the value of argv[1] execute a call to chdir(dir) with error checking. Message error changing directory end of the while loop end of main

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!