From 5dd0e8870842e86c2b94ff9ddcb5119007b773ad Mon Sep 17 00:00:00 2001 From: Charl Wentzel Date: Sun, 25 Nov 2018 10:19:52 +0200 Subject: [PATCH] Minor Update: - WatchdogCore: - Renamed FunctionType TYPE_WATCHDOG -> TYPE_WATCHDOGPING - ApplicationCore: - Prevent overwriting existing Function Type --- ApplicationCore.cpp | 13 +++++++++---- WatchdogCore.h | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ApplicationCore.cpp b/ApplicationCore.cpp index 85ac748..02dc1c4 100644 --- a/ApplicationCore.cpp +++ b/ApplicationCore.cpp @@ -51,9 +51,9 @@ CApplication::CApplication( EDebugLevel pLogLevel ) // Add Core Function Types //AddFunctionType( TYPE_FUNCTION, NewFunctionCore ); // <-- Can't add virtual function - AddFunctionType( TYPE_SELECTABLE, NewSelectableCore ); - AddFunctionType( TYPE_WATCHDOG, NewWatchdogCore ); - AddFunctionType( TYPE_FILE, NewFileCore ); + AddFunctionType( TYPE_SELECTABLE, NewSelectableCore ); + AddFunctionType( TYPE_WATCHDOGPING, NewWatchdogCore ); + AddFunctionType( TYPE_FILE, NewFileCore ); //AddFunctionType( TYPE_DEVICE, NewDeviceCore ); // <-- Can't add virtual function } //--------------------------------------------------------------------------- @@ -381,8 +381,13 @@ bool CApplication::AddFunctionType( const char * Type, FFuncConstructor Construc // Get end of list FunctionType = &FirstFunctionType; - while (*FunctionType) + while (*FunctionType && strcasecmp(Type, (*FunctionType)->Name)) FunctionType = &((*FunctionType)->Next); + if (*FunctionType) { + if (Log) Log->Message( dlLow, dlLow, "%s: Cannot add FunctionType '%s' - Already exists", + ProcessName, Type ); + return NULL; + } // Add new Type *FunctionType = (TFunctionType*)calloc( sizeof(TFunctionType), 1 ); diff --git a/WatchdogCore.h b/WatchdogCore.h index 1ac7767..d168c64 100644 --- a/WatchdogCore.h +++ b/WatchdogCore.h @@ -18,7 +18,7 @@ //--------------------------------------------------------------------------- // Function Constructor -#define TYPE_WATCHDOG "Watchdog" +#define TYPE_WATCHDOGPING "WatchdogPing" CFunctionCore * NewWatchdogCore( const char * Name ); //--------------------------------------------------------------------------- @@ -38,7 +38,7 @@ private: public: // Life Cycle - CWatchdogCore( const char * pName, const char * pType = TYPE_WATCHDOG ); + CWatchdogCore( const char * pName, const char * pType = TYPE_WATCHDOGPING ); virtual ~CWatchdogCore(); // Manually set Configuration