Question: #ifndef CRYPT _ H #define CRYPT _ H #define MAX _ BUFF 1 0 2 4 #define STDIN 0 #define STDOUT 1 #define STDERR 2

#ifndef CRYPT_H
#define CRYPT_H
#define MAX_BUFF 1024
#define STDIN 0
#define STDOUT 1
#define STDERR 2
void client(int readfd /*read head of channel */, int writefd /*write head of channel */);
void server(int readfd /*read head of channel */, int writefd /*write head of channel */);
double calculate(char *buf);
#endif
#include
#include
#include
#include
#include
#include
#include
int main(int argc, char **argv){
/*************************************************************
write code for the main process that will establish
the communication channel between cleint and server using
pipes
*************************************************************/
pid_t pid;
// TODO:
int fd[2];
int pipe(int pipefd[2]);
if(pipe(fd)=0){
printf("Hello"
);
exit(-1);
}
pid = fork();
if(pid <0){
perror("Fork failed
");
return 1;
}
if(pid ==0){
// TODO:
//call to server here: server(int readfd, int writefd);
exit(0);
}
// TODO:
//call to client here client(int readfd, int writefd);
return 0;
}
#include
#include
#include
#include
#include
#include
#include
void client(int readfd, int writefd){
/*************************************************************
write client code to be used by the parent process
*************************************************************/
char buf[MAX_BUFF];
size_t len;
// implement client functionality
}
#include
#include
#include
#include
#include
#include
#include
void server(int readfd, int writefd){
/*************************************************************
write server code to be used by the child process
*************************************************************/
char buf[MAX_BUFF];
size_t len;
/* Implement server functionlity here
use calculate function to evaluate expression
signature: calculate(char *buf)
*/
}
#include
#include
#include
#include
#include
#include
#include
double calculate(char *buf){
/*************************************************************
Implement the expression evaluation functionality which
will be invoked by the server whenever required.
*************************************************************/
double operands[20];
char op[20];
int oprnInd =0;
double result =0.0;
// implement expression evaluation functionality here
return(result);
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!