Question: I have to write an interface in c. The executable of your program must be named naiveinterface. Your makefile must ensure this. The naiveinterface program
I have to write an interface in c.
The executable of your program must be named naiveinterface. Your makefile must ensure this. The naiveinterface program must support the following usage: naiveinterface [scriptfile]. When no arguments are given, naiveinterface should enter a loop in which it accepts one command at a time as keyboard input (e.g., using scanf). The user types a command, and then presses return on the keyboard to execute it (i.e., the command will end with a newline character). Your program must block until the command completes and, if the return code is abnormal, print out a message to that effect. Alternatively, your program should open the given file (if one is provided) and interpret the contents as a sequence of commands to execute. You may assume that each line of the script file corresponds to one command. Your user interface should accept and support the following commands:
quit: When this command is encountered, naiveinterface should stop processing commands, prompt the user for confirmation (i.e., Are you sure you want to exit? All files will be lost! Y/N), accept the user input, delete all data structures and intermediate files (if any) created, and exit.
Output redirection: Your naiveinterface program should allow output to be redirected to a file (e.g., executing the command srchindx -o ALT indx.txt flightdata > foo.txt should execute srchindx in the flightdata directory and print its output in file foo.txt).
create: This command is used for creating new files, directories, and links. This is a separate program that can be executed by naiveinterface, or can be executed from a terminal by running its executable file. The create program should support the following usage:
create -f filepath creates an empty, ordinary file whose name is given in the specified path. The path can be an absolute pathname, a relative pathname, or just a bare filename, in which case the file should be created in the current directory. The new file should have permission 0640 specified in octal. 1
create -d dirpath creates a new directory whose name is given in the specified path. The new file should have permission 0750 specified in octal.
create -h oldname linkname creates a hard link. oldname is the path or name of an existing file, and linkname is the path or name of the hard link to be created.
create -s oldname linkname creates a symbolic (i.e., soft) link. oldname is the path or name of an existing file, and linkname is the path or name of the symbolic link to be created.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
