CSE 325   Computer Project #4  Solved

35.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

5/5 - (1 vote)

Assignment Overview

 

For this assignment, you are to design and implement a C/C++ program that will serve as an interpreter for shell scripts, as defined below.  You will design and implement additional functionality in subsequent projects.

 

It is worth 40 points (4% of course grade) and must be completed no later than 11:59 PM on Thursday, 2/6.

 

Assignment Deliverables

 

The deliverables for this assignment are the following files:

 

proj04.makefile – the makefile which produces proj04 proj04.student.c – the source code file for your solution

 

Be sure to use the specified file names and to submit your files for grading via the CSE Handin system before the project deadline.

 

Assignment Specifications

 

  1. The purpose of the program is to interpret the contents of a text file as a series of directives (defined below). The user will supply zero or more command line arguments to control execution of the program.

 

  1. The program will process the command line arguments from left to right.

 

  1. If an argument begins with the character ‘-‘, it will be processed as an option which controls the behavior of the program. Valid options are “-v” and “-s” (defined below).

 

  1. If an argument does not begin with the character ‘-‘, it will be processed as a file name. The user will supply zero or more file names, where each input file contains zero or more lines of text.

 

  1. For each input file, the program will repeatedly read a line of text and process it. An input line is defined as a sequence of zero or more tokens (character strings), separated by one or more delimiters (blanks and tabs), ending with a newline character.  There will be no more than 128 characters in a line.

 

If the first token is the name of a built-in directive (listed below), then the program will take the appropriate action.  Otherwise, the program will assume that it is an error.

 

  1. The program will recognize the following built-in directives:

 

exit terminate processing the input file
date display current date and time
env display environment variables
path display current search path
cwd display absolute pathname of current working directory

 

Built-in directives will be completely processed by the program (the program will not create a child process to perform the processing).

 

  1. The “exit” directive will terminate processing of the current input file. End-of-file on the current input file will be processed as an implicit “exit” directive.

 

  1. The “date” directive will display the current date and time in a human-readable format.

 

  1. The “env” directive will display the user’s environment variables in a format similar to “setenv” in the C shell.

 

  1. The “path” directive will display the current search path in a readable format.

 

  1. The “cwd” directive will display the absolute pathname of the current working directory.

 

  1. The valid command line options are “-v” (verbose) and “-s” (silent). An option applies to file names which appear after the option on the command line.

 

  1. When the “-v” option is in effect (which is the default), the program will display the sequence number of the current line of text from the input file (starting at 1 for each input file) and the current line of text. The sequence number will be enclosed in the characters ‘<‘ and ‘>’.  For example:

 

      <1> cwd

 

  1. When the “-s” option is in effect, the program will not display the sequence number or the current line of text.

 

  1. The program will include appropriate logic to handle exceptional cases and errors.

 

Assignment Notes

 

  1. As stated above, your source code file will be named “proj04.student.c”; that source code file may contain C or C++ statements.

 

  1. You must use “g++” to translate your source code file in the CSE Linux environment.

 

  1. As stated above, the command-line arguments will be processed from left to right. For example, consider the following command line:

 

proj04 testA -s testB testC –v testD testE –s testF

 

The “-v” option will be in effect for files “testA”, “testD” and “testE”; the “-s” option will be in effect for files “testB”, “testC” and “testF”.

 

  1. Information about system calls and library functions which might be useful for this project may be viewed using the “man” utility. For example:

 

man 2 time man 3 ctime man 3 getcwd man 3 string

 

  1. As noted above, you will extend your program in subsequent projects, so you would be wise to properly structure and comment your source code.

 

  • project04-fbzps5.zip