main.cpp
1.56 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
60
61
62
63
64
65
66
//*****************************************************************
/*
VLibras: Automatic pasteboardContents translator from Portuguese to LIBRAS
Copyright (c) 2015 Gustavo Sobral, Erickson Silva, Leonardo Araújo
VLibras-Core group at LAViD, Federal University of Paraiba
*/
//*****************************************************************
/**
* \file main.cpp
* \author Leonardo Araújo
* \date Outubro 2015
*/
#include <stdlib.h>
#include <dlfcn.h>
#include <iostream>
#include <fstream>
#include <string>
int main()
{
void *vlibras_lib_handler;
const char *dlsym_error_ptr;
vlibras_lib_handler = dlopen("plugin/libCorePlugin.so", RTLD_LAZY);
if (!vlibras_lib_handler)
{
fprintf(stderr, "%s\n", dlerror());
exit(1);
}
typedef void (*coreplugin_t)();
dlerror();
coreplugin_t core_init_f = (coreplugin_t) dlsym(vlibras_lib_handler, "coreInitialize");
dlsym_error_ptr = dlerror();
if (dlsym_error_ptr)
{
printf("Cannot load symbol 'coreInitialize': %s\n", dlsym_error_ptr);
dlclose(vlibras_lib_handler);
return 1;
}
/* Test coreInitialize function */
core_init_f();
coreplugin_t core_update_f = (coreplugin_t) dlsym(vlibras_lib_handler, "coreUpdateCheck");
dlsym_error_ptr = dlerror();
if (dlsym_error_ptr)
{
printf("Cannot load symbol 'coreUpdateCheck': %s\n", dlsym_error_ptr);
dlclose(vlibras_lib_handler);
return 1;
}
/* Test coreUpdateCheck function */
core_update_f();
/* Close load library */
dlclose(vlibras_lib_handler);
return 0;
}