Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use C sudba.h makefile sudba.c sudba.interface.c Reading Commands In this assignment, you are to implement and test function char sudbe read line(int file). The necessary

use C
image text in transcribed
sudba.h
image text in transcribed
makefile
image text in transcribed
sudba.c
image text in transcribed
sudba.interface.c
image text in transcribed
Reading Commands In this assignment, you are to implement and test function char sudbe read line(int file). The necessary constants are defined in the file sudah (provided). You must read the descriptions of the POSIX functions read(), malloc()free). (openlog(), closclog), sysloy'), and strerror_r before starting coding Your program must compile without any warnings Function char "sudbe_read_lincint file) shall read up to SUDBA_MAX_INPUT characters from the previously opened file file. The function shall allocate enough but not more than necessary) memory to store the input as a NULL-terminated character string It then shall copy the input into the newly allocated buffer, and return the pointer to the buffer. The function shall log the obtained string to the previously opened system log file at priority LOG_INFO before returning it. If any I/O or memory operation fails, the function shall report an error message with strerror () to the previously opened system log file at priority LOG ERR. and return NULL. If the input is longer than SUDBA_MAX_INPUT. the function shall, in addition, read and discard any excessive input. The functions must be implemented in the file sudbe_interface.c (provided). The files must include sudah Write the main function that shall: 1. Open a connection to the system logger with openlog(). Use the facility LOG_LOCALI, options LOG_CONS / LOG_PID / LOG_NDELAY, and the prefix "Sudha" (less the quotes). 2. In a while loop controlled by the global variable int donc (a) Read a string from the command line (file 0) with sudbe_read_line). (b) Free the memory allocated by sudbe_read_line). The value of the global variable shall not change in this exercise, you will have to terminate the program manually. 3. Close the connection to the system logger. The main function shall successfully terminate by returning EXIT_SUCCESS. The main function shall be implemented in the file sudbac (provided). The file must include The project mastuve a makefile (provided) with all the necessary dependencies. I will build your project by running make without any parameters. If I ran make again without modifying any of the submitted files, the project should not be rebuilt. #ifndef SUDBA_H #define SUDBA H 4 #define SUDBA_MAX_INPUT 1024 char *sudba_read_line(int file); #endif TARGET - sudba INCLUDE - include/ OBJS = sudba o sudba_interface.o 5 CFLAGS - - I$(INCLUDE) -Wall -pedantic - Wextra -Wcast-align - Wcast-qual \ - Wdisabled-optimization -Wformat-2 - Winit-self - Wmissing-include-dirs - Wredundant-decls - Wshadow ! -Wstrict-overflow-5 -Wundef -Werror -Wno-unused -8 - Wno-unused-result -03 -Wlogical-op - Wno-strict-overflow all: $(TARGET) 13 sudba: $(OBJS) # Uncomment the end of the next line for memory debugging $(CC) $(OBJS) -0 $(TARGET) #-lefence 16 sudba.o: sudba.c $(INCLUDE)/sudba.h sudba_interface.o: sudba_interface.c $(INCLUDE)/sudba.h 19 20 # Rer # Remove everything that can be rebuilt clean: rm -f $(OBJS) $(TARGET) sudba.tgz #include #include "sudba.h" N W 4 // SUDBa main loop 6 int main(int argc, char *argv[]). 8 9 return EXIT_SUCCESS; } 1 2 #include #include "sudba.h" 4 // Client-side SUDBa interface U 6: char *sudba_read_line(int file) N 8 return NULL; // Must be changed 91 Reading Commands In this assignment, you are to implement and test function char sudbe read line(int file). The necessary constants are defined in the file sudah (provided). You must read the descriptions of the POSIX functions read(), malloc()free). (openlog(), closclog), sysloy'), and strerror_r before starting coding Your program must compile without any warnings Function char "sudbe_read_lincint file) shall read up to SUDBA_MAX_INPUT characters from the previously opened file file. The function shall allocate enough but not more than necessary) memory to store the input as a NULL-terminated character string It then shall copy the input into the newly allocated buffer, and return the pointer to the buffer. The function shall log the obtained string to the previously opened system log file at priority LOG_INFO before returning it. If any I/O or memory operation fails, the function shall report an error message with strerror () to the previously opened system log file at priority LOG ERR. and return NULL. If the input is longer than SUDBA_MAX_INPUT. the function shall, in addition, read and discard any excessive input. The functions must be implemented in the file sudbe_interface.c (provided). The files must include sudah Write the main function that shall: 1. Open a connection to the system logger with openlog(). Use the facility LOG_LOCALI, options LOG_CONS / LOG_PID / LOG_NDELAY, and the prefix "Sudha" (less the quotes). 2. In a while loop controlled by the global variable int donc (a) Read a string from the command line (file 0) with sudbe_read_line). (b) Free the memory allocated by sudbe_read_line). The value of the global variable shall not change in this exercise, you will have to terminate the program manually. 3. Close the connection to the system logger. The main function shall successfully terminate by returning EXIT_SUCCESS. The main function shall be implemented in the file sudbac (provided). The file must include The project mastuve a makefile (provided) with all the necessary dependencies. I will build your project by running make without any parameters. If I ran make again without modifying any of the submitted files, the project should not be rebuilt. #ifndef SUDBA_H #define SUDBA H 4 #define SUDBA_MAX_INPUT 1024 char *sudba_read_line(int file); #endif TARGET - sudba INCLUDE - include/ OBJS = sudba o sudba_interface.o 5 CFLAGS - - I$(INCLUDE) -Wall -pedantic - Wextra -Wcast-align - Wcast-qual \ - Wdisabled-optimization -Wformat-2 - Winit-self - Wmissing-include-dirs - Wredundant-decls - Wshadow ! -Wstrict-overflow-5 -Wundef -Werror -Wno-unused -8 - Wno-unused-result -03 -Wlogical-op - Wno-strict-overflow all: $(TARGET) 13 sudba: $(OBJS) # Uncomment the end of the next line for memory debugging $(CC) $(OBJS) -0 $(TARGET) #-lefence 16 sudba.o: sudba.c $(INCLUDE)/sudba.h sudba_interface.o: sudba_interface.c $(INCLUDE)/sudba.h 19 20 # Rer # Remove everything that can be rebuilt clean: rm -f $(OBJS) $(TARGET) sudba.tgz #include #include "sudba.h" N W 4 // SUDBa main loop 6 int main(int argc, char *argv[]). 8 9 return EXIT_SUCCESS; } 1 2 #include #include "sudba.h" 4 // Client-side SUDBa interface U 6: char *sudba_read_line(int file) N 8 return NULL; // Must be changed 91

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

Step: 3

blur-text-image

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

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions

Question

Identify three types of physicians and their roles in health care.

Answered: 1 week ago

Question

Compare the types of managed care organizations (MCOs).

Answered: 1 week ago