-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
81 lines (68 loc) · 1.67 KB
/
main.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
#include<stdio.h>
#include"rfi.h"
/* SERVER SIDE */
void printMessage(void *data, char *message, char *message2)
{
printf("%s%s\n", message, message2);
}
void printRange(void *data, int start, int end, int step)
{
printf("%d -> %d : %d\n", start, end, step);
}
void touch(void *data)
{
printf("Touched!\n");
}
int getIncrement(void *data, int num)
{
return num + 1;
}
/* LOCAL_HEADER(Local); */
LOCAL(Local,
SHARED_FUNC(void, printMessage, char*, char*),
SHARED_FUNC(void, printRange, int, int, int),
SHARED_FUNC(void, touch),
SHARED_FUNC(int, getIncrement, int)
);
char *server_received(void *p, char *buffer, size_t size, size_t *result_size)
{
return Local_called(NULL, buffer, size, result_size);
}
/* CLIENT SIDE */
char *request_to_server(void *p, char *buffer, size_t size, size_t *result_size)
{
return server_received(NULL, buffer, size, result_size);
}
#if 0
REMOTE_HEADER(
Remote,
REMOTE_FUNC(void, printMessage, char*, char*),
REMOTE_FUNC(void, printRange, int, int, int),
REMOTE_FUNC(void, touch)
);
REMOTE_OBJECT(
Remote,
REMOTE_FUNC(void, printMessage, char*, char*),
REMOTE_FUNC(void, printRange, int, int, int),
REMOTE_FUNC(void, touch),
REMOTE_FUNC(int, getIncrement)
);
#else
REMOTE(
Remote,
REMOTE_FUNC(void, printMessage, char*, char*),
REMOTE_FUNC(void, printRange, int, int, int),
REMOTE_FUNC(void, touch),
REMOTE_FUNC(int, getIncrement, int)
);
#endif
int main(int argc, char **argv)
{
Remote *remote = Remote_new(request_to_server, NULL);
remote->touch(remote);
remote->printRange(remote, 59, 30, 32);
remote->printMessage(remote, "Hello ", "World!");
printf("Increment %d\n", remote->getIncrement(remote, 10));
Remote_free(remote);
return 0;
}