diff options
author | cbdev <cb@cbcdn.com> | 2023-06-18 21:10:03 +0200 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2023-06-18 21:10:03 +0200 |
commit | de9c58c92c29f9498c9e91a1a1b918261135d31b (patch) | |
tree | e47cf69ee00d0e2d89e6e7810eed7049c67707ad /reader.c | |
parent | 2ebd9db684112ca14d3edfb1c591ac3f90d91e3b (diff) | |
download | nfcommander-de9c58c92c29f9498c9e91a1a1b918261135d31b.tar.gz nfcommander-de9c58c92c29f9498c9e91a1a1b918261135d31b.tar.bz2 nfcommander-de9c58c92c29f9498c9e91a1a1b918261135d31b.zip |
Basic reader interface
Diffstat (limited to 'reader.c')
-rw-r--r-- | reader.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -2,11 +2,13 @@ #include <limits.h> #include <dlfcn.h> +#include "nfcommander.h" #include "reader.h" #include "config.h" #define MAX_PLUGIN_PATH NAME_MAX void* reader_module = NULL; +reader_plugin_handle reader_backend_handle = NULL; int reader_init(){ char plugin[MAX_PLUGIN_PATH] = ""; @@ -25,18 +27,26 @@ int reader_init(){ return -1; } + reader_backend_handle = dlsym(reader_module, "handle"); + + //call initializer + reader_plugin_init init = dlsym(reader_module, "init"); + if(!reader_backend_handle || !init || init()){ + printf("Failed to initialize the reader\n"); + return 1; + } + return 0; } int reader_handle(int fd){ - //TODO - printf("Handling data on reader fd\n"); - return 0; + return reader_backend_handle(fd); } void reader_free(){ if(reader_module){ dlclose(reader_module); + reader_backend_handle = NULL; reader_module = NULL; } } |