Minor Update:
- Complete LogCore functions - Implement ShowOutput() in Port and Socket functions
This commit is contained in:
38
LogCore.cpp
38
LogCore.cpp
@@ -17,16 +17,17 @@
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void ShowOutput( const char * Name, const char * Buffer, const int Len, const long Duration )
|
||||
bool ShowOutput( const char * Heading, const short Show, const char * Buffer, int Len )
|
||||
{
|
||||
// Show Duration delay
|
||||
if (Duration) {
|
||||
printf( "Delay: %ld", Duration );
|
||||
}
|
||||
// Validate values
|
||||
if (!Buffer)
|
||||
return false;
|
||||
if (Len == -1)
|
||||
Len = strlen( Buffer );
|
||||
|
||||
// Show Hex output
|
||||
if (ShowOutBytes) {
|
||||
printf( "%s in (hex): ", Name );
|
||||
if (Show & OUT_HEX) {
|
||||
printf( "%s [%d]: ", Heading, Len );
|
||||
for (int i=0; i<Len; i++) {
|
||||
printf( "%02X ", Buffer[i] );
|
||||
}
|
||||
@@ -34,12 +35,29 @@ void ShowOutput( const char * Name, const char * Buffer, const int Len, const lo
|
||||
}
|
||||
|
||||
// Show normal output
|
||||
if (ShowOutHex) {
|
||||
printf( "%s in [%d]: %s", Name, Len, Buffer );
|
||||
if (Buffer[Len-1] != '\n') {
|
||||
if (Show & OUT_NORMAL) {
|
||||
printf( "%s [%d]: ", Heading, Len );
|
||||
if (Show & OUT_ASIS) {
|
||||
printf( "%s", Buffer );
|
||||
}
|
||||
else {
|
||||
for (int i=0; i<Len; i++) {
|
||||
if ((Buffer[i] < 32) || (Buffer[i] > 126)) {
|
||||
if ((Show & OUT_CRLF) && ((Buffer[i] == '\r') || (Buffer[i] == '\n')))
|
||||
printf( "%c", Buffer[i] );
|
||||
else
|
||||
printf( "." );
|
||||
}
|
||||
else {
|
||||
printf( "%c", Buffer[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(Show & (OUT_ASIS | OUT_CRLF)) || (Buffer[Len-1] != '\n')) {
|
||||
printf( "\n" );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user