From bcb11b6257c1f5502a7404764eb209953d9b6b29 Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Tue, 13 Jan 2015 21:24:31 +0200 Subject: [PATCH] Added a compile-time option to split any mixed model server into several single ones. --- Makefile | 10 ++++++++++ discover.c | 18 ++++++++++++++++++ server.c | 8 +++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index dbc9403..085eea4 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,10 @@ #SATIP_XCI = 1 +# Split any mixed model server into several single ones + +#SATIP_USE_SINGLE_MODEL_SERVERS_ONLY = 1 + # Strip debug symbols? Set eg. to /bin/true if not STRIP = strip @@ -91,6 +95,12 @@ DEFINES += -DXCI endif endif +ifdef SATIP_USE_SINGLE_MODEL_SERVERS_ONLY +ifeq ($(SATIP_USE_SINGLE_MODEL_SERVERS_ONLY),1) +DEFINES += -DUSE_SINGLE_MODEL_SERVERS_ONLY +endif +endif + ifneq ($(strip $(GITTAG)),) DEFINES += -DGITVERSION='"-GIT-$(GITTAG)"' endif diff --git a/discover.c b/discover.c index 1870400..2a53ffd 100644 --- a/discover.c +++ b/discover.c @@ -233,6 +233,23 @@ void cSatipDiscover::AddServer(const char *addrP, const char *modelP, const char { debug1("%s (%s, %s, %s)", __PRETTY_FUNCTION__, addrP, modelP, descP); cMutexLock MutexLock(&mutexM); +#ifdef USE_SINGLE_MODEL_SERVERS_ONLY + int n = 0; + char *s, *p = (char *)modelP; + char *r = strtok_r(p, ",", &s); + while (r) { + r = skipspace(r); + cString desc = cString::sprintf("%s #%d", descP, n++); + cSatipServer *tmp = new cSatipServer(addrP, r, desc); + if (!serversM.Update(tmp)) { + info("Adding server '%s|%s|%s'", tmp->Address(), tmp->Model(), tmp->Description()); + serversM.Add(tmp); + } + else + DELETENULL(tmp); + r = strtok_r(NULL, ",\n", &s); + } +#else cSatipServer *tmp = new cSatipServer(addrP, modelP, descP); // Validate against existing servers if (!serversM.Update(tmp)) { @@ -241,6 +258,7 @@ void cSatipDiscover::AddServer(const char *addrP, const char *modelP, const char } else DELETENULL(tmp); +#endif } int cSatipDiscover::GetServerCount(void) diff --git a/server.c b/server.c index 3401852..7810127 100644 --- a/server.c +++ b/server.c @@ -99,7 +99,13 @@ cSatipServer::~cSatipServer() int cSatipServer::Compare(const cListObject &listObjectP) const { const cSatipServer *s = (const cSatipServer *)&listObjectP; - return strcasecmp(*addressM, *s->addressM); + int result = strcasecmp(*addressM, *s->addressM); + if (!result) { + result = strcasecmp(*modelM, *s->modelM); + if (!result) + result = strcasecmp(*descriptionM, *s->descriptionM); + } + return result; } void cSatipServer::Use(bool onOffP)