Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE DO THESE 2 STEPS . Please also do NOT copy and paste other answers online. 1.) Write two programs (Interface & db) in C

PLEASE DO THESE 2 STEPS . Please also do NOT copy and paste other answers online.

1.) Write two programs (Interface & db) in C language PROVIDING the FULL CODE.

2.) Output that demonstrates that the code performs correctly. Create a data set of at least 12 elements and show that your results are correct. Note that the evaluation of the code may be performed with a larger data file. Also, consider abnormal cases as well.

image text in transcribed

image text in transcribed

image text in transcribed

Purpose: The objective of this project is to gain experience with UNIX (Linux) system calls and additional C language features. 2. Overview: You are to write two programs, interface and db. After initialization, interface will use the fork system call and an exec system call to start the execution of db. Interface will accept commands from the console and send them to db for execution. After executing the command, db will send the output to interface for display on the console. 3. Pipes: interface will need to create the pipes to be used for communication between itself and db prior to doing the fork. Use two pipes, one for sending commands to db and one for sending the response to interface. 4. Interface: In addition to tasks described elsewhere, interface must pass the pipe file descriptor values to db. Use the arguments on the exec command for this purpose. interface should also detect the final exit status of db and display an appropriate message. 5. DB : When db initializes, it must do two things before entering its loop accepting commands. First, it must initialize an array of structures (records) using the data in a local file called accountData. This file must contain data for at least twelve records. Second, it should display the contents of the array so it is easy to verify that the initialization occurred correctly. The records will keep track of a set of bank accounts. Each structure in the array is to consist of the following fields: id: this is the identifier of the account. It is to be a long integer. checkNumber: the check (or transaction) number (int). amount: The amount withdrawn from the account (float). date: The date of the transaction (char). You are to create and use a typedef for the record structure. 6. accountData: each line of this ASCII file is to contain the data for one record of the array of structures. Each line is expected to be in the form: id checkNumber date amount where a single space is used as a delimiter. 7. Makefile: Write a makefile to control the compilation of your programs. 8. Commands: Four commands must be processed: account, This is to compute the total value of all transactions identified by the label >. date, This is to compute the total value of all transactions that occurred on the given date. exit After processing this command, db should terminate in a normal manner. After detecting the termination of db, interface should print relevant information and exit normally. 9. System calls: You should view this exercise as an opportunity to try out various system calls. Detailed documentation of the system calls can be found in the associated man pages. At a minimum, you are expected to use the following system calls: fork, some type of exec call (such as execl), pipe, read, write, exit, waitpid, close. In addition your code is to check the response from the system calls for errors, display an appropriate error message and take appropriate action. In many cases that action may be just to call exit with a unique number selected. 10. Readability: Your program must be written using good C programming conventions: Variable names and function names should be descriptive of what they represent. Use indentation to show the structure of the program. Typically this means using indentation with for, while, do-while, if, and switch statements as well as indenting the body of functions. Indentation should show the nesting level of the statements involved. Include some in-line documentation to give a high level view of what the program and groups of statements is/are doing. Sample output: Some of the library string functions may be useful: strchr, stremp, strnemp, strncpy. PLEASE DO THESE STEPS 1.) Write two programs in C language PROVIDING the FULL CODE. - Interface Db 2.) Output that demonstrates that the code performs correctly. Create a data set of at least 12 elements and show that your results are correct. Note that the evaluation of the code may be performed with a larger data file. Also, consider abnormal cases as well

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 15th International Conference Dasfaa 2010 International Workshops Gdm Benchmarx Mcis Snsmw Diew Udm Tsukuba Japan April 2010 Revised Selected Papers Lncs 6193

Authors: Masatoshi Yoshikawa ,Xiaofeng Meng ,Takayuki Yumoto ,Qiang Ma ,Lifeng Sun ,Chiemi Watanabe

2010th Edition

3642145884, 978-3642145889

More Books

Students also viewed these Databases questions