From 204dfb8cc71bc188529d598ba5036a257252e9c5 Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Sat, 15 Aug 2015 10:46:46 +0200 Subject: [PATCH] add udata to monitor hook --- Makefile | 2 +- misc.c | 11 ++++++++++- misc.h | 2 +- ot-recorder.c | 2 +- udata.h | 5 +++++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f9b53e0..153166d 100644 --- a/Makefile +++ b/Makefile @@ -15,4 +15,4 @@ base64.o: base64.h base64.c ghash.o: ghash.h ghash.c config.h udata.h safewrite.o: safewrite.h safewrite.c jget.o: jget.c jget.h json.h -misc.o: misc.c misc.h +misc.o: misc.c misc.h udata.h diff --git a/misc.c b/misc.c index 8e7d5a9..ddfe51a 100644 --- a/misc.c +++ b/misc.c @@ -2,6 +2,7 @@ #include #include "utstring.h" #include "ctype.h" +#include "udata.h" #include "misc.h" char *bindump(char *buf, long buflen) @@ -28,6 +29,14 @@ char *bindump(char *buf, long buflen) * a monitoring hoook. */ -void monitorhook(time_t now, char *topic) +void monitorhook(struct udata *userdata, time_t now, char *topic) { + struct udata *ud = (struct udata *)userdata; + +#ifdef HAVE_REDIS + if (ud->useredis) { + } +#endif + if (ud->usefiles) { + } } diff --git a/misc.h b/misc.h index 5f0bfaf..b0b6ade 100644 --- a/misc.h +++ b/misc.h @@ -3,6 +3,6 @@ #include char *bindump(char *buf, long buflen); -void monitorhook(time_t now, char *topic); +void monitorhook(struct udata *ud, time_t now, char *topic); #endif diff --git a/ot-recorder.c b/ot-recorder.c index adca226..4c018a4 100644 --- a/ot-recorder.c +++ b/ot-recorder.c @@ -388,7 +388,7 @@ void on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_m time(&now); - monitorhook(now, m->topic); + monitorhook(ud, now, m->topic); /* FIXME: handle null leading topic `/` */ utstring_printf(basetopic, "%s/%s/%s", topics[0], topics[1], topics[2]); diff --git a/udata.h b/udata.h index 7f139e1..55df7a2 100644 --- a/udata.h +++ b/udata.h @@ -1,3 +1,6 @@ +#ifndef UDATA_H_INCLUDED +# define UDATA_H_INCLUDED + #include "config.h" #include "utarray.h" #ifdef HAVE_REDIS @@ -16,3 +19,5 @@ struct udata { int skipdemo; /* True if _demo users are to be skipped */ int useredis; /* True if we should do Redis (if we have it) */ }; + +#endif