-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.c
91 lines (77 loc) · 1.85 KB
/
server.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <rpc/rpc.h>
#include "calculator.h"
#include <math.h>
/*Version 1: Un-rounded result*/
//addition
float * add_1_svc(numbers *argp, struct svc_req *rqstp)
{
static float result;
printf("add(%f, %f) is called\n", argp->a, argp->b);
result = argp->a+argp->b;
return &result;
}
//subtraction
float * sub_1_svc(numbers *argp, struct svc_req *rqstp)
{
static float result;
printf("sub(%f, %f) is called\n", argp->a, argp->b);
result = argp->a-argp->b;
return &result;
}
//multiplication
float * mul_1_svc(numbers *argp, struct svc_req *rqstp)
{
static float result;
printf("mul(%f, %f) is called\n", argp->a, argp->b);
result = argp->a*argp->b;
return &result;
}
//division
float * div_1_svc(numbers *argp, struct svc_req *rqstp)
{
static float result;
printf("div(%f, %f) is called\n", argp->a, argp->b);
result = argp->a/argp->b;
return &result;
}
/*Version 2: The rounded result*/
//addition
float * add_2_svc(numbers1 *argp, struct svc_req *rqstp)
{
static float result;
result = result + 0.5;
result = (int)result;
printf("add(%f, %f) is called\n", argp->aa, argp->bb);
result = argp->aa+argp->bb;
return &result;
}
//subtraction
float * sub_2_svc(numbers1 *argp, struct svc_req *rqstp)
{
static float result;
result = result + 0.5;
result = (int)result;
printf("sub(%f, %f) is called\n", argp->aa, argp->bb);
result = argp->aa-argp->bb;
return &result;
}
//multiplication
float * mul_2_svc(numbers1 *argp, struct svc_req *rqstp)
{
static float result;
result = result + 0.5;
result = (int)result;
printf("mul(%f, %f) is called\n", argp->aa, argp->bb);
result = argp->aa*argp->bb;
return &result;
}
//division
float * div_2_svc(numbers1 *argp, struct svc_req *rqstp)
{
static float result;
result = result + 0.5;
result = (int)result;
printf("div(%f, %f) is called\n", argp->aa, argp->bb);
result = argp->aa/argp->bb;
return &result;
}