Skip to content

Commit

Permalink
Added date to all MDF file object items
Browse files Browse the repository at this point in the history
  • Loading branch information
grodansparadis committed Nov 2, 2023
1 parent 7e50a2a commit 2e0decb
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 64 deletions.
4 changes: 2 additions & 2 deletions src/common/sockettcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@ typedef int socklen_t;
// strlcpy
//

static void strlcpy( register char *dst, register const char *src, size_t n )
static void _strlcpy( register char *dst, register const char *src, size_t n )
{
for (; *src != '\0' && n > 1; n--) {
*dst++ = *src++;
Expand All @@ -1490,7 +1490,7 @@ static char *stcp_strndup( const char *ptr, size_t len )
char *p;

if ( ( p = (char *)malloc( len + 1 ) ) != NULL ) {
strlcpy( p, ptr, len + 1 );
_strlcpy( p, ptr, len + 1 );
}

return p;
Expand Down
2 changes: 2 additions & 0 deletions src/vscp/common/canal_xmlconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#if !defined(CANALCONFIG_H__INCLUDED_)
#define CANALCONFIG_H__INCLUDED_

#include <inttypes.h>

#include <string>
#include <list>
#include <vector>
Expand Down
66 changes: 66 additions & 0 deletions src/vscp/common/mdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,7 @@ CMDF_Picture::clearStorage(void)
m_strName.clear();
m_strURL.clear();
m_strFormat.clear();
m_strDate.clear();
m_mapDescription.clear();
m_mapInfoURL.clear();
}
Expand Down Expand Up @@ -1049,6 +1050,7 @@ CMDF_Video::clearStorage(void)
m_strName.clear();
m_strURL.clear();
m_strFormat.clear();
m_strDate.clear();
m_mapDescription.clear();
m_mapInfoURL.clear();
}
Expand Down Expand Up @@ -1157,6 +1159,7 @@ CMDF_Manual::clearStorage(void)
m_strName.clear();
m_strURL.clear();
m_strFormat.clear();
m_strDate.clear();
m_mapDescription.clear();
m_mapInfoURL.clear();
}
Expand Down Expand Up @@ -1186,6 +1189,7 @@ CMDF_Setup::clearStorage(void)
m_strName.clear();
m_strURL.clear();
m_strFormat.clear();
m_strDate.clear();
m_mapDescription.clear();
m_mapInfoURL.clear();
}
Expand Down Expand Up @@ -1785,6 +1789,11 @@ __startSetupMDFParser(void *data, const char *name, const char **attr)
gpPictureStruct->m_strFormat = attribute;
}
}
else if (0 == strcasecmp(attr[i], "date")) {
// Date for picture
spdlog::trace("Parse-XML: handleMDFParserData: Module picture date: {0}", attribute);
gpPictureStruct->m_strDate = attribute;
}
}
}
// * * * NOTE! * * *
Expand Down Expand Up @@ -1900,6 +1909,11 @@ __startSetupMDFParser(void *data, const char *name, const char **attr)
spdlog::trace("Parse-XML: handleMDFParserData: Module manual format: {0}", attribute);
gpManualStruct->m_strFormat = attribute;
}
else if (0 == strcasecmp(attr[i], "date")) {
// Date for manula
spdlog::trace("Parse-XML: handleMDFParserData: Module manialö date: {0}", attribute);
gpManualStruct->m_strDate = attribute;
}
}
}
else if (currentToken == "boot") {
Expand Down Expand Up @@ -1978,6 +1992,11 @@ __startSetupMDFParser(void *data, const char *name, const char **attr)
gpPictureStruct->m_strFormat = attribute;
}
}
else if (0 == strcasecmp(attr[i], "date")) {
// Date for picture
spdlog::trace("Parse-XML: handleMDFParserData: Module picture date: {0}", attribute);
gpPictureStruct->m_strDate = attribute;
}
}
}
// [3] Video (standard format)
Expand Down Expand Up @@ -2011,6 +2030,11 @@ __startSetupMDFParser(void *data, const char *name, const char **attr)
gpVideoStruct->m_strFormat = attribute;
}
}
else if (0 == strcasecmp(attr[i], "date")) {
// Date for video
spdlog::trace("Parse-XML: handleMDFParserData: Module video date: {0}", attribute);
gpVideoStruct->m_strDate = attribute;
}
}
}
// [3] Firmware (standard format)
Expand Down Expand Up @@ -2200,6 +2224,11 @@ __startSetupMDFParser(void *data, const char *name, const char **attr)
spdlog::trace("Parse-XML: handleMDFParserData: Module manual format: {0}", attribute);
gpManualStruct->m_strFormat = attribute;
}
else if (0 == strcasecmp(attr[i], "date")) {
// Date for manual
spdlog::trace("Parse-XML: handleMDFParserData: Module manual date: {0}", attribute);
gpManualStruct->m_strDate = attribute;
}
}
}
// [3] Picture (standard format)
Expand Down Expand Up @@ -2233,6 +2262,11 @@ __startSetupMDFParser(void *data, const char *name, const char **attr)
gpSetupStruct->m_strFormat = attribute;
}
}
else if (0 == strcasecmp(attr[i], "date")) {
// Date for setup
spdlog::trace("Parse-XML: handleMDFParserData: Module setup date: {0}", attribute);
gpSetupStruct->m_strDate = attribute;
}
}
}
// Boot (standard format)
Expand Down Expand Up @@ -6938,6 +6972,14 @@ CMDF::parseMDF_JSON(const std::string &path)
spdlog::warn("Parse-JSON: No picture format.");
}

if (jpic.contains("date") && jpic["date"].is_string()) {
ppicture->m_strDate = jpic["date"];
spdlog::debug("Parse-JSON: Picture date: {0} ", jpic["date"]);
}
else {
spdlog::warn("Parse-JSON: No picture date");
}

if (getDescriptionList(jpic, ppicture->m_mapDescription) != VSCP_ERROR_SUCCESS) {
spdlog::warn("Parse-JSON: Failed to get picture description.");
}
Expand Down Expand Up @@ -6986,6 +7028,14 @@ CMDF::parseMDF_JSON(const std::string &path)
spdlog::warn("Parse-JSON: No video format.");
}

if (jvideo.contains("date") && jvideo["date"].is_string()) {
pvideo->m_strDate = jvideo["date"];
spdlog::debug("Parse-JSON: Video date: {0} ", jvideo["date"]);
}
else {
spdlog::warn("Parse-JSON: No video date");
}

if (getDescriptionList(jvideo, pvideo->m_mapDescription) != VSCP_ERROR_SUCCESS) {
spdlog::warn("Parse-JSON: Failed to get video description.");
}
Expand Down Expand Up @@ -7351,6 +7401,14 @@ CMDF::parseMDF_JSON(const std::string &path)
spdlog::warn("Parse-JSON: No manual language.");
}

if (jmanual.contains("date") && jmanual["date"].is_string()) {
pmanual->m_strDate = jmanual["date"];
spdlog::debug("Parse-JSON: Manual date: {0} ", jmanual["date"]);
}
else {
spdlog::warn("Parse-JSON: No manual date");
}

if (getDescriptionList(jmanual, pmanual->m_mapDescription) != VSCP_ERROR_SUCCESS) {
spdlog::warn("Parse-JSON: Failed to get event data description.");
}
Expand Down Expand Up @@ -7399,6 +7457,14 @@ CMDF::parseMDF_JSON(const std::string &path)
spdlog::warn("Parse-JSON: No setup format.");
}

if (jsetup.contains("date") && jsetup["date"].is_string()) {
psetup->m_strDate = jsetup["date"];
spdlog::debug("Parse-JSON: Setup date: {0} ", jsetup["date"]);
}
else {
spdlog::warn("Parse-JSON: No setup date");
}

if (getDescriptionList(jsetup, psetup->m_mapDescription) != VSCP_ERROR_SUCCESS) {
spdlog::warn("Parse-JSON: Failed to get setup description.");
}
Expand Down
Loading

0 comments on commit 2e0decb

Please sign in to comment.