Merge branch 'master' into InterAfrica

This commit is contained in:
Charl Wentzel
2019-12-06 04:05:29 +02:00
10 changed files with 181 additions and 47 deletions

View File

@@ -404,6 +404,24 @@ CFunctionCore * CApplication::GetFunction( const char * Name )
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
CDataMember * CApplication::GetAddress( const char * SearchAddress )
{
CDataMember * AddressDef = NULL;
char NamePath[100];
char * Address;
// Address renamed?
sprintf( NamePath, "Application/Addresses/Rename/%s", SearchAddress );
if (!(Address = (char*)Config->GetChStr( NamePath, NULL, false ))) {
Address = (char*)SearchAddress;
}
// Get address def
AddressDef = AddressList->GetChild( Address );
return AddressDef;
}
//---------------------------------------------------------------------------
bool CApplication::Run( bool TerminateOnError ) bool CApplication::Run( bool TerminateOnError )
{ {
bool CleanTerminate = true; bool CleanTerminate = true;

View File

@@ -102,6 +102,8 @@ public:
CFunctionCore * AddFunction( const char * Type, const char * Name ); CFunctionCore * AddFunction( const char * Type, const char * Name );
CFunctionCore * GetFunction( const char * Name ); CFunctionCore * GetFunction( const char * Name );
CDataMember * GetAddress( const char * SearchAddress );
// Run Application // Run Application
bool Run( bool TerminateOnError ); bool Run( bool TerminateOnError );
}; };

View File

@@ -207,7 +207,7 @@ char const * GetTimeStr( const char * TimeSeparator )
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
char const * GetDateTimeStr( const char * DateSeparator, const char * TimeSeparator ) char const * GetDateTimeStr( const char * DateSeparator, const char * TimeSeparator, const char * Separator )
{ {
unsigned char Day; unsigned char Day;
unsigned char Month; unsigned char Month;
@@ -221,8 +221,9 @@ char const * GetDateTimeStr( const char * DateSeparator, const char * TimeSepar
GetTime( Hours, Minutes, Seconds ); GetTime( Hours, Minutes, Seconds );
// Build String // Build String
sprintf( ReturnStr, "%04d%s%02d%s%02d %02d%s%02d%s%02d", sprintf( ReturnStr, "%04d%s%02d%s%02d%s%02d%s%02d%s%02d",
Year, ((DateSeparator)? DateSeparator : ""), Month, ((DateSeparator)? DateSeparator : ""), Day, Year, ((DateSeparator)? DateSeparator : ""), Month, ((DateSeparator)? DateSeparator : ""), Day,
Separator,
Hours, ((TimeSeparator)? TimeSeparator : ""), Minutes, ((TimeSeparator)? TimeSeparator : ""), Seconds ); Hours, ((TimeSeparator)? TimeSeparator : ""), Minutes, ((TimeSeparator)? TimeSeparator : ""), Seconds );
return (ReturnStr); return (ReturnStr);
@@ -417,11 +418,12 @@ char const * BuildTimeStr( unsigned char Hours, unsigned char Minutes, unsigned
char const * BuildDateTimeStr( unsigned char Day, unsigned char Month, unsigned Year, char const * BuildDateTimeStr( unsigned char Day, unsigned char Month, unsigned Year,
unsigned char Hours, unsigned char Minutes, unsigned char Seconds, unsigned char Hours, unsigned char Minutes, unsigned char Seconds,
const char * DateSeparator, const char * TimeSeparator ) const char * DateSeparator, const char * TimeSeparator, const char * Separator )
{ {
// Build String // Build String
sprintf( ReturnStr, "%04d%s%02d%s%02d %02d%s%02d%s%02d", sprintf( ReturnStr, "%04d%s%02d%s%02d%s%02d%s%02d%s%02d",
Year, ((DateSeparator)? DateSeparator : ""), Month, ((DateSeparator)? DateSeparator : ""), Day, Year, ((DateSeparator)? DateSeparator : ""), Month, ((DateSeparator)? DateSeparator : ""), Day,
Separator,
Hours, ((TimeSeparator)? TimeSeparator : ""), Minutes, ((TimeSeparator)? TimeSeparator : ""), Seconds ); Hours, ((TimeSeparator)? TimeSeparator : ""), Minutes, ((TimeSeparator)? TimeSeparator : ""), Seconds );
return (ReturnStr); return (ReturnStr);
@@ -457,7 +459,8 @@ char const * BuildTimeStr( const time_t EpochTime, bool LocalTime, const char *
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
char const * BuildDateTimeStr( const time_t EpochTime, bool LocalTime, const char * DateSeparator, const char * TimeSeparator ) char const * BuildDateTimeStr( const time_t EpochTime, bool LocalTime,
const char * DateSeparator, const char * TimeSeparator, const char * Separator )
{ {
unsigned char Day; unsigned char Day;
unsigned char Month; unsigned char Month;

View File

@@ -29,7 +29,7 @@ bool SetDateTime( unsigned char Day, unsigned char Month, unsigned Year,
char const * GetDateStr( const char * DateSeparator = "/" ); char const * GetDateStr( const char * DateSeparator = "/" );
char const * GetTimeStr( const char * TimeSeparator = ":" ); char const * GetTimeStr( const char * TimeSeparator = ":" );
char const * GetDateTimeStr( const char * DateSeparator = "/", const char * TimeSeparator = ":" ); char const * GetDateTimeStr( const char * DateSeparator = "/", const char * TimeSeparator = ":", const char * Separator = " " );
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@@ -50,11 +50,12 @@ char const * BuildDateStr( unsigned char Day, unsigned char Month, unsigned Yea
char const * BuildTimeStr( unsigned char Hours, unsigned char Minutes, unsigned char Seconds, const char * TimeSeparator = ":" ); char const * BuildTimeStr( unsigned char Hours, unsigned char Minutes, unsigned char Seconds, const char * TimeSeparator = ":" );
char const * BuildDateTimeStr( unsigned char Day, unsigned char Month, unsigned Year, char const * BuildDateTimeStr( unsigned char Day, unsigned char Month, unsigned Year,
unsigned char Hours, unsigned char Minutes, unsigned char Seconds, unsigned char Hours, unsigned char Minutes, unsigned char Seconds,
const char * DateSeparator = "/", const char * TimeSeparator = ":" ); const char * DateSeparator = "/", const char * TimeSeparator = ":", const char * Separator = " " );
char const * BuildDateStr( const time_t EpochTime, bool LocalTime, const char * DateSeparator = "/" ); char const * BuildDateStr( const time_t EpochTime, bool LocalTime, const char * DateSeparator = "/" );
char const * BuildTimeStr( const time_t EpochTime, bool LocalTime, const char * TimeSeparator = ":" ); char const * BuildTimeStr( const time_t EpochTime, bool LocalTime, const char * TimeSeparator = ":" );
char const * BuildDateTimeStr( const time_t EpochTime, bool LocalTime, const char * DateSeparator = "/", const char * TimeSeparator = ":" ); char const * BuildDateTimeStr( const time_t EpochTime, bool LocalTime,
const char * DateSeparator = "/", const char * TimeSeparator = ":", const char * Separator = " " );
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@@ -352,13 +352,12 @@ bool CJSONparse::ReadFromBuffer( const char * BasePath )
// Parse Root Object // Parse Root Object
SkipWhiteSpace(); SkipWhiteSpace();
if (!ParseObject( BaseMember ) && !Error && !ParseArray( BaseMember )) { if (!ParseObject( BaseMember ) && !Error && !ParseArray( BaseMember ) && !Error) {
if (!Error) {
Error = true; Error = true;
CharNo += BufPos-Mark; CharNo += BufPos-Mark;
sprintf( ErrorText, "First entry in file must be an Object or Array on line %d:%d", LineNo, CharNo ); sprintf( ErrorText, "First entry in file must be an Object or Array on line %d:%d", LineNo, CharNo );
} }
FreeBuffer(); if (Error) {
return false; return false;
} }
@@ -368,7 +367,6 @@ bool CJSONparse::ReadFromBuffer( const char * BasePath )
Error = true; Error = true;
CharNo += BufPos-Mark; CharNo += BufPos-Mark;
sprintf( ErrorText, "No content expected after Root object on line %d:%d", LineNo, CharNo ); sprintf( ErrorText, "No content expected after Root object on line %d:%d", LineNo, CharNo );
FreeBuffer();
return false; return false;
} }

View File

@@ -63,19 +63,10 @@ CSelectableBare::~CSelectableBare()
CDataMember * CSelectableBare::GetHandleAddress( THandle * Handle, const char * HandleRef ) CDataMember * CSelectableBare::GetHandleAddress( THandle * Handle, const char * HandleRef )
{ {
CDataMember * AddressDef = NULL; CDataMember * AddressDef = NULL;
char NamePath[100];
char * Address;
// Handle renamed? if ((AddressDef = Application->GetAddress( HandleRef ))) {
sprintf( NamePath, "Application/Addresses/Rename/%s", HandleRef );
if (!(Address = (char*)Application->Config->GetChStr( NamePath, NULL, false ))) {
Address = (char*)HandleRef;
}
// Get address def
if ((AddressDef = Application->AddressList->GetChild( Address ))) {
if (Log) Log->Message( LogLevel, dlMedium, "%s/%s: Handle '%s' - Use address '%s' ('%s')", if (Log) Log->Message( LogLevel, dlMedium, "%s/%s: Handle '%s' - Use address '%s' ('%s')",
ProcessName, Name, Handle->Name, Address, HandleRef ); ProcessName, Name, Handle->Name, AddressDef->GetName(), HandleRef );
} }
return AddressDef; return AddressDef;
} }

View File

@@ -25,6 +25,7 @@
// redA Libraries // redA Libraries
#include "ApplicationCore.h" #include "ApplicationCore.h"
#include "SelectableCore.h" #include "SelectableCore.h"
#include "UtilCore.h"
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@@ -40,7 +41,7 @@ CFunctionCore * NewSelectableCore( const char * Name ) {
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Resolve action handlder // Resolve action handler
void ResolveHandler( int Signal, siginfo_t * SignalInfo, void * Context ) void ResolveHandler( int Signal, siginfo_t * SignalInfo, void * Context )
{ {
TResolveReq * ResolveReq; TResolveReq * ResolveReq;
@@ -106,7 +107,7 @@ bool CSelectableCore::Init( CDataMember * FunctionConfig )
CDataMember * SerialConfig; CDataMember * SerialConfig;
THandle * Handle; THandle * Handle;
char * Type; char * Type;
char * Name; char * PortName;
char * Address; char * Address;
char * Port; char * Port;
char * ParityText; char * ParityText;
@@ -132,7 +133,7 @@ bool CSelectableCore::Init( CDataMember * FunctionConfig )
Type = (char*)HandleConfig->GetChStr( "Type", "TCPclient", true ); Type = (char*)HandleConfig->GetChStr( "Type", "TCPclient", true );
if (!strcasecmp( Type, "Serial" )) if (!strcasecmp( Type, "Serial" ))
{ {
if ((Name = (char*)HandleConfig->GetChStr( "Port/Name", NULL )) && (AddressDef = Application->AddressList->GetChild( Name ))) { if ((PortName = (char*)HandleConfig->GetChStr( "Port/Name", NULL )) && (AddressDef = Application->AddressList->GetChild( PortName ))) {
Address = (char*)AddressDef->GetChStr( "Address", NULL, true ); // Get address list value Address = (char*)AddressDef->GetChStr( "Address", NULL, true ); // Get address list value
} else { } else {
Address = (char*)HandleConfig->GetChStr( "Port/Address", NULL, true ); // Get default value Address = (char*)HandleConfig->GetChStr( "Port/Address", NULL, true ); // Get default value
@@ -176,7 +177,7 @@ bool CSelectableCore::Init( CDataMember * FunctionConfig )
} }
else if (!strcasecmp( Type, "LinePrinter" )) else if (!strcasecmp( Type, "LinePrinter" ))
{ {
if ((Name = (char*)HandleConfig->GetChStr( "Port/Name", NULL )) && (AddressDef = GetHandleAddress( Handle, Name ))) { if ((PortName = (char*)HandleConfig->GetChStr( "Port/Name", NULL )) && (AddressDef = GetHandleAddress( Handle, PortName ))) {
Address = (char*)AddressDef->GetChStr( "Address", NULL, true ); // Get address list value Address = (char*)AddressDef->GetChStr( "Address", NULL, true ); // Get address list value
} else { } else {
Address = (char*)HandleConfig->GetChStr( "Port/Address", NULL, true ); // Get default value Address = (char*)HandleConfig->GetChStr( "Port/Address", NULL, true ); // Get default value
@@ -186,7 +187,7 @@ bool CSelectableCore::Init( CDataMember * FunctionConfig )
} }
else if (!strcasecmp( Type, "UNIXserver" )) else if (!strcasecmp( Type, "UNIXserver" ))
{ {
if ((Name = (char*)HandleConfig->GetChStr( "Socket/Name", NULL )) && (AddressDef = GetHandleAddress( Handle, Name ))) { if ((PortName = (char*)HandleConfig->GetChStr( "Socket/Name", NULL )) && (AddressDef = GetHandleAddress( Handle, PortName ))) {
Address = (char*)AddressDef->GetChStr( "Address", NULL, true ); // Get address list value Address = (char*)AddressDef->GetChStr( "Address", NULL, true ); // Get address list value
} else { } else {
Address = (char*)HandleConfig->GetChStr( "Socket/Address", NULL, true ); // Get default Address value Address = (char*)HandleConfig->GetChStr( "Socket/Address", NULL, true ); // Get default Address value
@@ -197,7 +198,7 @@ bool CSelectableCore::Init( CDataMember * FunctionConfig )
} }
else if (!strcasecmp( Type, "UNIXclient" )) else if (!strcasecmp( Type, "UNIXclient" ))
{ {
if ((Name = (char*)HandleConfig->GetChStr( "Socket/Name", NULL )) && (AddressDef = GetHandleAddress( Handle, Name ))) { if ((PortName = (char*)HandleConfig->GetChStr( "Socket/Name", NULL )) && (AddressDef = GetHandleAddress( Handle, PortName ))) {
Address = (char*)AddressDef->GetChStr( "Address", NULL, true ); // Get address list value Address = (char*)AddressDef->GetChStr( "Address", NULL, true ); // Get address list value
} else { } else {
Address = (char*)HandleConfig->GetChStr( "Socket/Address", NULL, true ); // Get default Address value Address = (char*)HandleConfig->GetChStr( "Socket/Address", NULL, true ); // Get default Address value
@@ -207,7 +208,7 @@ bool CSelectableCore::Init( CDataMember * FunctionConfig )
} }
else if (!strcasecmp( Type, "UDPserver" )) else if (!strcasecmp( Type, "UDPserver" ))
{ {
if ((Name = (char*)HandleConfig->GetChStr( "Socket/Name", NULL )) && (AddressDef = GetHandleAddress( Handle, Name ))) { if ((PortName = (char*)HandleConfig->GetChStr( "Socket/Name", NULL )) && (AddressDef = GetHandleAddress( Handle, PortName ))) {
Address = (char*)AddressDef->GetChStr( "Address", NULL, true ); // Get address list value Address = (char*)AddressDef->GetChStr( "Address", NULL, true ); // Get address list value
Port = (char*)AddressDef->GetChStr( "Port", "0", true ); // Get AddressList Port value Port = (char*)AddressDef->GetChStr( "Port", "0", true ); // Get AddressList Port value
} else { } else {
@@ -219,7 +220,7 @@ bool CSelectableCore::Init( CDataMember * FunctionConfig )
} }
else if (!strcasecmp( Type, "UDPclient" )) else if (!strcasecmp( Type, "UDPclient" ))
{ {
if ((Name = (char*)HandleConfig->GetChStr( "Socket/Name", NULL )) && (AddressDef = GetHandleAddress( Handle, Name ))) { if ((PortName = (char*)HandleConfig->GetChStr( "Socket/Name", NULL )) && (AddressDef = GetHandleAddress( Handle, PortName ))) {
Address = (char*)AddressDef->GetChStr( "Address", NULL, true ); // Get address list value Address = (char*)AddressDef->GetChStr( "Address", NULL, true ); // Get address list value
Port = (char*)AddressDef->GetChStr( "Port", "0", true ); // Get AddressList Port value Port = (char*)AddressDef->GetChStr( "Port", "0", true ); // Get AddressList Port value
} else { } else {
@@ -231,7 +232,7 @@ bool CSelectableCore::Init( CDataMember * FunctionConfig )
} }
else if (!strcasecmp( Type, "TCPserver" )) else if (!strcasecmp( Type, "TCPserver" ))
{ {
if ((Name = (char*)HandleConfig->GetChStr( "Socket/Name", NULL )) && (AddressDef = GetHandleAddress( Handle, Name ))) { if ((PortName = (char*)HandleConfig->GetChStr( "Socket/Name", NULL )) && (AddressDef = GetHandleAddress( Handle, PortName ))) {
Address = (char*)AddressDef->GetChStr( "Address", NULL, true ); // Get address list value Address = (char*)AddressDef->GetChStr( "Address", NULL, true ); // Get address list value
Port = (char*)AddressDef->GetChStr( "Port", "0", true ); // Get AddressList Port value Port = (char*)AddressDef->GetChStr( "Port", "0", true ); // Get AddressList Port value
} else { } else {
@@ -244,7 +245,7 @@ bool CSelectableCore::Init( CDataMember * FunctionConfig )
} }
else if (!strcasecmp( Type, "TCPclient" )) else if (!strcasecmp( Type, "TCPclient" ))
{ {
if ((Name = (char*)HandleConfig->GetChStr( "Socket/Name", NULL )) && (AddressDef = GetHandleAddress( Handle, Name ))) { if ((PortName = (char*)HandleConfig->GetChStr( "Socket/Name", NULL )) && (AddressDef = GetHandleAddress( Handle, PortName ))) {
Address = (char*)AddressDef->GetChStr( "Address", NULL, true ); // Get address list value Address = (char*)AddressDef->GetChStr( "Address", NULL, true ); // Get address list value
Port = (char*)AddressDef->GetChStr( "Port", "0", true ); // Get AddressList Port value Port = (char*)AddressDef->GetChStr( "Port", "0", true ); // Get AddressList Port value
} else { } else {

View File

@@ -223,13 +223,6 @@ protected:
// Buffer operations // Buffer operations
virtual bool ProcessInputBuffer( THandle * Handle, bool Force ); virtual bool ProcessInputBuffer( THandle * Handle, bool Force );
// Convert string to lower case
inline char * strlcase( char * Str ) {
for (char * Ch = Str; *Ch; Ch++ )
*Ch = tolower(*Ch);
return Str;
}
public: public:
// Life Cycle // Life Cycle
CSelectableBare( const char * Name, const char * Type = TYPE_SELECTABLE ); CSelectableBare( const char * Name, const char * Type = TYPE_SELECTABLE );

View File

@@ -119,6 +119,40 @@ char * BytesToBinStr( const char * Bytes, const int Len, const char * Separator,
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
char * IntToBinStr( const int Bytes, const int Len, const char * Separator, char * OutBuf )
{
char * TempBuf;
char * BufPos;
bool First = true;
char SepLen = (Separator)? strlen(Separator) : 0;
u_int8_t Byte;
// Select/create output buffer
if (!OutBuf) {
TempBuf = ReturnStr;
}
else {
// if (!*OutBuf)
// *OutBuf = (char*)malloc( Len*(8+SepLen)+1 );
// TempBuf = *OutBuf;
TempBuf = OutBuf;
}
BufPos = TempBuf;
// Print each byte as 8-bit binary
for (int i=Len-1; i>=0; i--) {
Byte = (Bytes >> (i*8)) & 0xFF;
sprintf( BufPos, "%s%c%c%c%c%c%c%c%c", ((First || !Separator)? "" : Separator),
(Byte & 0x80)?'1':'0', (Byte & 0x40)?'1':'0', (Byte & 0x20)?'1':'0', (Byte & 0x10)?'1':'0',
(Byte & 0x08)?'1':'0', (Byte & 0x04)?'1':'0', (Byte & 0x02)?'1':'0', (Byte & 0x01)?'1':'0' );
BufPos += (First)? 8 : 8+SepLen;
First = false;
}
*BufPos = 0;
return TempBuf;
}
//---------------------------------------------------------------------------
char * HexStrToBytes( const char * Str, const int Len, const char * Separator, char * OutBuf ) char * HexStrToBytes( const char * Str, const int Len, const char * Separator, char * OutBuf )
{ {
char * TempBuf; char * TempBuf;
@@ -179,3 +213,79 @@ char * StrSearch( const char * Haystack, const char * Needle, const int Haystac
return NULL; return NULL;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool UrlEncode( const char * Input, char * Output, char ** EndPos )
{
int c;
char h[] = "0123456789abcdef";
char * Ipos = (char*)Input;
char * Opos = Output;
if (!Ipos || !Opos) {
if (*EndPos) *EndPos = NULL;
return false;
}
while ((c = *Ipos)) {
if ((('a' <= c) && (c <= 'z')) ||
(('A' <= c) && (c <= 'Z')) ||
(('0' <= c) && (c <= '9')) ||
(c == '-') || (c == '_') || (c == '.')) {
*Opos = *Ipos;
Opos++;
}
else if (c == ' ') {
*Opos = '+';
Opos++;
}
else {
Opos[0] = '%';
Opos[1] = h[c >> 4];
Opos[2] = h[c & 0x0f];
Opos += 3;
}
Ipos++;
}
*Opos = 0;
if (EndPos) *EndPos = Opos;
return true;
}
//---------------------------------------------------------------------------
bool UrlDecode( const char * Input, char * Output, char ** EndPos )
{
char c, c1, c2;
char * Ipos = (char*)Input;
char * Opos = Output;
if (!Ipos || !Opos) {
if (EndPos) *EndPos = Output;
return false;
}
while ((c = *Ipos)) {
if (c == '%') {
if (!(c1 = tolower(Ipos[1])) ||
!(c2 = tolower(Ipos[2])) ||
!isxdigit(c1) || !isxdigit(c2))
return false;
c1 = (c1 <= '9')? (c1 - '0') : (c1 - 'a' + 10);
c2 = (c2 <= '9')? (c2 - '0') : (c2 - 'a' + 10);
*Opos = 16*c1 + c2;
Ipos += 3;
}
else if (c == '+') {
*Opos = ' ';
Ipos++;
}
else {
*Opos = c;
Ipos++;
}
Opos++;
}
*Opos = 0;
if (EndPos) *EndPos = Opos;
return true;
}
//---------------------------------------------------------------------------

View File

@@ -9,7 +9,7 @@
#define REDACORE_UTILCORE_H_ #define REDACORE_UTILCORE_H_
// Standard C/C++ Libraries // Standard C/C++ Libraries
/* none */ #include <ctype.h>
// redA Libraries // redA Libraries
/* none */ /* none */
@@ -21,6 +21,8 @@ char * BytesToSafeStr( const char * Bytes, const int Len, const bool NoCrLf = fa
char * BytesToHexStr( const char * Bytes, const int Len, const char * Separator = " ", char * OutBuf = NULL ); char * BytesToHexStr( const char * Bytes, const int Len, const char * Separator = " ", char * OutBuf = NULL );
char * BytesToBinStr( const char * Bytes, const int Len, const char * Separator = " ", char * OutBuf = NULL ); char * BytesToBinStr( const char * Bytes, const int Len, const char * Separator = " ", char * OutBuf = NULL );
char * IntToBinStr( const int Bytes, const int Len, const char * Separator = " ", char * OutBuf = NULL );
// Convert string to raw bytes // Convert string to raw bytes
inline u_int8_t HexToInt( char Digit ) { inline u_int8_t HexToInt( char Digit ) {
if ((Digit >= '0') && (Digit <= '9')) return (Digit - '0'); if ((Digit >= '0') && (Digit <= '9')) return (Digit - '0');
@@ -31,9 +33,24 @@ inline u_int8_t HexToInt( char Digit ) {
char * HexStrToBytes( const char * Str, const int Len, const char * Separator = NULL, char * OutBuf = NULL ); char * HexStrToBytes( const char * Str, const int Len, const char * Separator = NULL, char * OutBuf = NULL );
char * BinStrToBytes( const char * Str, const int Len, const char * Separator = NULL, char * OutBuf = NULL ); char * BinStrToBytes( const char * Str, const int Len, const char * Separator = NULL, char * OutBuf = NULL );
//---------------------------------------------------------------------------
// Search string data // Search string data
char * StrSearch( const char * Haystack, const char * Needle, const int hLen = 0, const int nLen = 0 ); char * StrSearch( const char * Haystack, const char * Needle, const int hLen = 0, const int nLen = 0 );
// Convert string to lower case
inline char * strlcase( char * Str ) {
for (char * Ch = Str; *Ch; Ch++ )
*Ch = tolower(*Ch);
return Str;
}
//---------------------------------------------------------------------------
// URL encoding & decoding
bool UrlEncode( const char * Input, char * Output, char ** EndPos = NULL );
bool UrlDecode( const char * Input, char * Output, char ** EndPos = NULL );
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#endif /* REDACORE_UTILCORE_H_ */ #endif /* REDACORE_UTILCORE_H_ */