From 99315a26dd11b6bc1dd29c1137c46307d1580d2d Mon Sep 17 00:00:00 2001 From: jbleyel Date: Sun, 22 Sep 2024 16:22:36 +0200 Subject: [PATCH] [eServiceReference] * toLCNReferenceString add trailing flag --- lib/dvb/db.cpp | 2 +- lib/service/iservice.h | 2 +- lib/service/service.cpp | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/dvb/db.cpp b/lib/dvb/db.cpp index 1c7c20073fd..980fc5f017c 100644 --- a/lib/dvb/db.cpp +++ b/lib/dvb/db.cpp @@ -2628,7 +2628,7 @@ PyObject *eDVBDB::getAllServicesRaw(int type) PyTuple_SET_ITEM(tuple, 4, PyUnicode_FromString(!service->m_service_display_name.empty() ? service->m_service_display_name.c_str() : service->m_service_name.c_str())); int flags = (service->m_flags & (eDVBService::dxIntNewServiceName | eDVBService::dxIntNewProvider)) >> 14; PyTuple_SET_ITEM(tuple, 5, PyLong_FromLongLong(flags)); - PyDict_SetItemString(serviceList, sit->first.toLCNReferenceString().c_str(), tuple); + PyDict_SetItemString(serviceList, sit->first.toLCNReferenceString(false).c_str(), tuple); Py_DECREF(tuple); } break; diff --git a/lib/service/iservice.h b/lib/service/iservice.h index 16f59f75171..349885144bd 100644 --- a/lib/service/iservice.h +++ b/lib/service/iservice.h @@ -177,7 +177,7 @@ class eServiceReference std::string toString() const; std::string toCompareString() const; std::string toReferenceString() const; - std::string toLCNReferenceString() const; + std::string toLCNReferenceString(bool trailing=true) const; #ifndef SWIG operator bool() const { diff --git a/lib/service/service.cpp b/lib/service/service.cpp index 57e92cb4b68..b64c0e28f59 100644 --- a/lib/service/service.cpp +++ b/lib/service/service.cpp @@ -138,16 +138,16 @@ std::string eServiceReference::toReferenceString() const return ret; } -std::string eServiceReference::toLCNReferenceString() const -{ - std::string ret; - ret.reserve((4 * sizeof(data)/sizeof(*data)) + 8); /* Estimate required space */ - - for (unsigned int i=1; i<5; ++i) - { - ret += getNum(data[i], 0x10); - ret += ':'; - } +std::string eServiceReference::toLCNReferenceString(bool trailing) const +{ + std::string ret; + ret.reserve(24); /* Estimate required space */ + char buf[24]; + if(trailing) + snprintf(buf, 24, "%X:%X:%X:%X:", data[1], data[2], data[3], data[4]); + else + snprintf(buf, 24, "%X:%X:%X:%X", data[1], data[2], data[3], data[4]); + ret.assign(buf); return ret; }