From e3cffcaf6fceddb593d0d7dda6e907a3eed2af48 Mon Sep 17 00:00:00 2001 From: LongHairedHacker Date: Tue, 22 Sep 2015 00:31:51 +0200 Subject: [PATCH] Added more functions to manage twinkl messages to the shared library --- Makefile | 6 +++--- message_wrapper.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 message_wrapper.c diff --git a/Makefile b/Makefile index eb19ed8..9ff8493 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ CFLAGS = -fPIC -Wall -O2 -I include -I twinkl/include LDFLAGS = -all : start $(OBJDIR)/twinkl-client +all : start $(OBJDIR)/twinkl-client $(OBJDIR)/twinklclient.so @echo ":: Done !" start : @@ -22,10 +22,10 @@ $(OBJDIR)/%.o : %.c Makefile $(HEADERS) mkdir -p $$(dirname $@) $(CC) $(CFLAGS) -c $< -o $@ -$(OBJDIR)/twinklsocket.so : $(OBJDIR)/twinklsocket.o +$(OBJDIR)/twinklclient.so : $(OBJDIR)/twinklsocket.o $(OBJDIR)/message_wrapper.o $(CC) $+ -shared $(LDFLAGS) -o $@ -$(OBJDIR)/twinkl-client : $(OBJDIR)/main.o $(OBJDIR)/twinklsocket.so +$(OBJDIR)/twinkl-client : $(OBJDIR)/main.o $(OBJDIR)/twinklsocket.o $(CC) $+ $(LDFLAGS) -o $@ clean : diff --git a/message_wrapper.c b/message_wrapper.c new file mode 100644 index 0000000..6ecb341 --- /dev/null +++ b/message_wrapper.c @@ -0,0 +1,32 @@ +#include "message.h" + +#include + +// Wrapper for the inline functions in message.h +// Also enforces a consistent naming scheme for symbols in twinklclient.so + +struct twinkl_message* twinklmsg_create() { + struct twinkl_message* msg = malloc(sizeof(struct twinkl_message)); + twinkl_init_message(msg); + return msg; +} + +void twinklmsg_reset(struct twinkl_message *msg) { + twinkl_init_message(msg); +} + +void twinklmsg_set_value(struct twinkl_message *msg, uint16_t chan, uint8_t value) { + twinkl_set_value(msg, chan, value); +} + +void twinklmsg_unset_value(struct twinkl_message *msg, uint16_t chan) { + twinkl_unset_value(msg, chan); +} + +void twinklmsg_set_priority(struct twinkl_message *msg, uint8_t priority) { + twinkl_set_priority(msg, priority); +} + +void twinklmsg_destroy(struct twinkl_message* msg) { + free(msg); +}