blob: 5472e0f7762e60dd3ddd46c3913428bb2cdd118f (
plain)
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
|
#include <stdio.h>
#include <limits.h>
#include <dlfcn.h>
#include "reader.h"
#include "config.h"
#define MAX_PLUGIN_PATH NAME_MAX
void* reader_module = NULL;
int reader_init(){
char plugin[MAX_PLUGIN_PATH] = "";
char* reader = config_get("nfc", "reader");
if(!reader){
printf("No reader plugin configured\n");
return -1;
}
snprintf(plugin, sizeof(plugin), "./reader_%s.so", reader);
reader_module = dlopen(plugin, RTLD_NOW);
if(!reader_module){
printf("Failed to load reader plugin %s: %s\n", plugin, dlerror());
return -1;
}
return 0;
}
int reader_handle(int fd){
//TODO
printf("Handling data on reader fd\n");
return 0;
}
void reader_free(){
if(reader_module){
dlclose(reader_module);
reader_module = NULL;
}
}
|