diff options
author | cbdev <cb@cbcdn.com> | 2023-06-14 22:51:13 +0200 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2023-06-14 22:51:13 +0200 |
commit | 9fbad1544764c515cb1f22bc552f33bb41206e92 (patch) | |
tree | 36b66aee2f956197d28621ac96a922ecee1e2f21 /reader.c | |
parent | 1f22af635893d4c3221dffca8f05ea3bb8870028 (diff) | |
download | nfcommander-9fbad1544764c515cb1f22bc552f33bb41206e92.tar.gz nfcommander-9fbad1544764c515cb1f22bc552f33bb41206e92.tar.bz2 nfcommander-9fbad1544764c515cb1f22bc552f33bb41206e92.zip |
Skeleton structure implementation
Diffstat (limited to 'reader.c')
-rw-r--r-- | reader.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/reader.c b/reader.c new file mode 100644 index 0000000..1186800 --- /dev/null +++ b/reader.c @@ -0,0 +1,36 @@ +#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\n", plugin); + return -1; + } + + return 0; +} + +void reader_free(){ + if(reader_module){ + dlclose(reader_module); + reader_module = NULL; + } +} |