-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainClient.c
More file actions
59 lines (50 loc) · 1.16 KB
/
Copy pathMainClient.c
File metadata and controls
59 lines (50 loc) · 1.16 KB
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
/******************************************************
* MainClient.c
* Purpose:
*
* @author
* @version
******************************************************/
#include "lib/inc/PrivateTreatment.h"
#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>
typedef int (*T_func1)(int,char*);
typedef int (*T_func2)(int);
T_func1 func1;
T_func2 func2;
/**
Main function
@param argc, int
@param argv, char**
@return int
*/
int main(int argc, char** argv) {
int res = 0;
void* handle;
char* error;
handle = dlopen("libPrivate.so", RTLD_LAZY);
if (!handle)
{
fprintf(stderr,"%s\n",dlerror());
exit(1);
}
func1 = (T_func1) dlsym(handle,"function1");
if ((error = dlerror()) != NULL)
{
fprintf(stderr,"%s\n",error);
exit(1);
}
res = (int)func1(1,NULL);
printf("\nIn function %s , function1 return %d\n",__FUNCTION__,res);
func2 = (T_func2) dlsym(handle,"function2");
if ((error = dlerror()) != NULL)
{
fprintf(stderr,"%s\n",error);
exit(1);
}
res = (int)func2(1);
printf("\nIn function %s , function2 return %d\n",__FUNCTION__,res);
dlclose(handle);
return(0);
}