Question: Project: Node Manager - C Program Shell Implementation Overview: - Create a C program that acts as a basic shell named Node Manager. - Reinforces
Project: Node Manager C Program Shell Implementation
Overview:
Create a C program that acts as a basic shell named Node Manager.
Reinforces linked lists, string handling, bitwise operations, and managing multiple source files.
Files and Directory Structure:
phandout Directory contains:
srcnodemngrc: The source file you need to modify.
inclistnodeh: Contains the ListNode structure.
incexech: Contains function prototypes.
objexeco: Object file for linking during compilation.
inputs and outputs: Test case directories used with the testing script.
Makefile: Used for compiling the project.
driverpy: Python script to test the shell.
Text files joestartxtkakyointxtavdoltxt: Provided for testing with List Nodes.
Shell Requirements:
Command Prompt and Input Loop:
Shell prompt: $
Print prompt using fflushstdout;
Continuously loop until EOF is detected.
Command Parsing and Execution:
Parse input commands using whitespace as the delimiter.
Commands can have multiple arguments, with input size limited to characters
Builtin Commands:
quit: Exits the shell, deallocates resources, no arguments.
cd dir: Changes current directory using chdir Prints errors for invalid directory or incorrect arguments.
history: Displaysmanages history of the last commands
history c: Clears command history.
history index: Reexecutes a command from history by index.
new CMD args: Creates a new List Node with a command and arguments.
A List Node includes: command, arguments, and other details.
list: Displays information about all current List Nodes.
open idfilename: Opens a file and assigns its contents to the List Node by ID
Handles errors for invalid IDs, missing files, and incorrect arguments.
execute id: Executes the command stored in a List Node by calling runcommand
Extracts exit status and reports errors if unsuccessful.
Commands are limited to arguments
Key Implementation Requirements:
No Global Variables: Only local variables are allowed.
Memory Management: Proper deallocation of resources must pass Valgrind with no memory leaks
Command History: Manages up to commands replacing the oldest entry when full.
ListNode Structure from listnodeh:
c
typedef struct ListNode
char command; Command associated with the node
char arguments; Array of argument strings command is arguments
struct ListNode next; Pointer to the next List Node
int id; ID of the List Node starts from
int argumentslength; Number of arguments excluding ending NULL pointer
char filecontents; Contents of any file opened for this node
ListNode;
Testing and Submission Instructions:
Testing:
Use the provided Makefile to compile the project.
Run driverpy to test with provided test cases.
Example output from driverpy awards scores based on functionality and memory safety.
Driver Script driverpy Scoring:
Scores range from to :
: Compilation failure or incorrect output with memory leaks.
: Correct output but with memory leaks.
: Correct output and no memory leaks.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
