diff options
author | cbdev <cb@cbcdn.com> | 2023-06-17 23:45:44 +0200 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2023-06-17 23:45:44 +0200 |
commit | 2ebd9db684112ca14d3edfb1c591ac3f90d91e3b (patch) | |
tree | 4822920fe69ab887fbf50f757d9596391a158e85 | |
parent | 209897056d43ea0d682700e1078a8988a9b133f3 (diff) | |
download | nfcommander-2ebd9db684112ca14d3edfb1c591ac3f90d91e3b.tar.gz nfcommander-2ebd9db684112ca14d3edfb1c591ac3f90d91e3b.tar.bz2 nfcommander-2ebd9db684112ca14d3edfb1c591ac3f90d91e3b.zip |
Reverse exports
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | nfcommander.c | 11 | ||||
-rw-r--r-- | reader.c | 2 | ||||
-rw-r--r-- | reader_yhy.c | 11 |
4 files changed, 23 insertions, 4 deletions
@@ -5,7 +5,7 @@ CORE_OBJS = control.o reader.o config.o command.o PLUGINS = reader_yhy.so reader_yhy.so: LDLIBS = -lyhy -reader_yhy.so: LDFLAGS = -L. -Wl,-rpath . +reader_yhy.so: LDFLAGS += -L. -Wl,-rpath . %.so: CFLAGS += -shared -fPIC @@ -13,6 +13,7 @@ reader_yhy.so: LDFLAGS = -L. -Wl,-rpath . $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) $(LDLIBS) nfcommander: LDLIBS = -ldl +nfcommander: LDFLAGS += -Wl,-export-dynamic all: nfcommander $(PLUGINS) diff --git a/nfcommander.c b/nfcommander.c index 3c58d6c..4763b78 100644 --- a/nfcommander.c +++ b/nfcommander.c @@ -73,10 +73,16 @@ int main(int argc, char** argv){ } //start reader api - reader_init(); + if(reader_init()){ + printf("Failed to start reader\n"); + return EXIT_FAILURE; + } //start control api - control_start(); + if(control_start()){ + printf("Failed to start control interface\n"); + return EXIT_FAILURE; + } //handle signals signal(SIGINT, signal_handler); @@ -91,6 +97,7 @@ int main(int argc, char** argv){ for(n = 0; n < event_count; n++){ polldata.u64 = events[n].data.u64; + //TODO error checking switch(polldata.components.system){ case system_control: control_handle(polldata.components.fd); @@ -21,7 +21,7 @@ int reader_init(){ reader_module = dlopen(plugin, RTLD_NOW); if(!reader_module){ - printf("Failed to load reader plugin %s\n", plugin); + printf("Failed to load reader plugin %s: %s\n", plugin, dlerror()); return -1; } diff --git a/reader_yhy.c b/reader_yhy.c index da5be5e..51ac796 100644 --- a/reader_yhy.c +++ b/reader_yhy.c @@ -1,9 +1,20 @@ #include <stdio.h> #include "nfcommander.h" +#include "config.h" static void __attribute__((constructor)) init() { printf("This is the yhy reader plugin\n"); + + size_t poll_timeout = 1000; + if(config_get("nfc", "interval")){ + poll_timeout = strtoul(config_get("nfc", "interval"), NULL, 10); + } + + char* port = config_get("nfc", "device"); + + printf("Opening %s with polltime %d\n", port, poll_timeout); + } static void __attribute__((destructor)) cleanup() { |