CharBuffer search fixed & Log/Util buffer changed:

- Char/ShiftBuffer: Fixed multi-char string search
- UtilCore: Always pass output buffer & remove own buffer for conversions
- UtilCore: Remove optional parameters to force passing of buffer
- LogCore: Add TempBuffer for output conversion (using UtilCore)
- ApplicationCore: Allow setting size of TempBuffer via config
- Optimize use of {}
This commit is contained in:
2021-10-14 09:19:55 -05:00
parent 474289beab
commit 9830f687ad
7 changed files with 196 additions and 260 deletions

View File

@@ -32,7 +32,7 @@ CApplication::CApplication( EDebugLevel pLogLevel )
AddressFile = NULL;
// Create output logger
Log = new CLogCore( stdout );
Log = new CLogCore( stdout, 5000 );
LogLevel = pLogLevel;
LogOutput = loNormal;
@@ -193,9 +193,10 @@ bool CApplication::SaveConfig()
}
//---------------------------------------------------------------------------
bool CApplication::SetLogParam( EDebugLevel pDebugLevel, int pOutputDisplay )
bool CApplication::SetLogParam( int pLogBufferSize, EDebugLevel pDebugLevel, int pOutputDisplay )
{
// Output
LogBufSize = pLogBufferSize;
LogLevel = pDebugLevel;
LogOutput = pOutputDisplay;
@@ -208,6 +209,7 @@ bool CApplication::InitApplication()
CDataMember * CoreConfig;
CDataMember * LogConfig;
CDataMember * SelectConfig;
int pLogSize;
EDebugLevel pLogLevel;
int pLogOutput;
@@ -216,14 +218,14 @@ bool CApplication::InitApplication()
// Configure Logging/Debugging
LogConfig = CoreConfig->GetChild( "Log", true );
pLogSize = Log->ReadLogBufSize( LogConfig );
pLogLevel = Log->ReadLogLevel( LogConfig );
pLogOutput = Log->ReadLogOutput( LogConfig );
SetLogParam( pLogLevel, pLogOutput );
SetLogParam( pLogSize, pLogLevel, pLogOutput );
// Configure Selector
if ((SelectConfig = CoreConfig->GetChild( "Selector" ))) {
if ((SelectConfig = CoreConfig->GetChild( "Selector" )))
Selector = new CSelect( (int)SelectConfig->GetChInt( "Wait", 5, true ), LogLevel );
}
// Show status
if (Log) Log->Message( LogLevel, dlLow, "%s: Application Core configured.", ProcessName );
@@ -276,8 +278,7 @@ bool CApplication::InitFunctions()
// Process each Function
FunctionConfig = FunctionList->GetFirstChild();
while (FunctionConfig)
{
while (FunctionConfig) {
// Get function parameters
Type = (char*)FunctionConfig->GetChStr( "Type", "Custom", true );
@@ -325,8 +326,7 @@ bool CApplication::InitFunctionLinks()
// Process each Channel
FunctionItem = FirstFunction;
while (FunctionItem)
{
while (FunctionItem) {
// Build links for function
if ((LinkConfig = LinkList->GetChild( FunctionItem->Function->GetName() )))
FunctionItem->Function->InitChannelLinks( LinkConfig );
@@ -412,9 +412,8 @@ CDataMember * CApplication::GetAddress( const char * SearchAddress )
// Address renamed?
sprintf( NamePath, "Application/Addresses/Rename/%s", SearchAddress );
if (!(Address = (char*)Config->GetChStr( NamePath, NULL, false ))) {
if (!(Address = (char*)Config->GetChStr( NamePath, NULL, false )))
Address = (char*)SearchAddress;
}
// Get address def
AddressDef = AddressList->GetChild( Address );
@@ -429,13 +428,11 @@ bool CApplication::Run( bool TerminateOnError )
TFunctionItem * FunctionItem;
// Check for FD Events/States
if (Selector) {
if (Selector)
Selector->Test();
}
// Process Functions
for (FunctionItem = FirstFunction; FunctionItem; FunctionItem = FunctionItem->Next )
{
for (FunctionItem = FirstFunction; FunctionItem; FunctionItem = FunctionItem->Next ) {
ProcessTerminate = !FunctionItem->Function->Process();
if (TerminateOnError) {
if (ProcessTerminate) // Raise terminate flag for other processes