summaryrefslogtreecommitdiffstats
path: root/net/Socket.cpp
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2017-11-29 03:23:45 +0000
committerMichael Meeks <michael.meeks@collabora.com>2017-11-29 03:33:16 +0000
commit0778b726978fffd83f6cc1e75e4f3291ef2b69a4 (patch)
tree8c0ae2d033140f5ecbf8bd98423acbbb787c5ff8 /net/Socket.cpp
parentRLE compress sharing bitmap for display. (diff)
downloadonline-0778b726978fffd83f6cc1e75e4f3291ef2b69a4.tar.gz
online-0778b726978fffd83f6cc1e75e4f3291ef2b69a4.zip
Dump hex contents of un-shared memory.
Change-Id: I47dfa8a0b48d0ba34b7462301b83e2721617814d
Diffstat (limited to 'net/Socket.cpp')
-rw-r--r--net/Socket.cpp44
1 files changed, 3 insertions, 41 deletions
diff --git a/net/Socket.cpp b/net/Socket.cpp
index 13424cd33c..475649ac29 100644
--- a/net/Socket.cpp
+++ b/net/Socket.cpp
@@ -137,50 +137,12 @@ void SocketDisposition::execute()
_socketMove = nullptr;
}
-namespace {
-
-void dump_hex (std::ostream &os, const char *legend, const char *prefix, std::vector<char> buffer)
-{
- unsigned int i, j;
- char scratch[64];
-
- os << legend;
- for (j = 0; j < buffer.size() + 15; j += 16)
- {
- sprintf (scratch, "%s0x%.4x ", prefix, j);
- os << scratch;
- for (i = 0; i < 16; i++)
- {
- if ((j + i) < buffer.size())
- sprintf (scratch, "%.2x ", (unsigned char)buffer[j+i]);
- else
- sprintf (scratch, " ");
- os << scratch;
- if (i == 8)
- os << " ";
- }
- os << " | ";
-
- for (i = 0; i < 16; i++)
- {
- if ((j + i) < buffer.size() && ::isprint(buffer[j+i]))
- sprintf (scratch, "%c", buffer[j+i]);
- else
- sprintf (scratch, ".");
- os << scratch;
- }
- os << "\n";
- }
-}
-
-} // namespace
-
void WebSocketHandler::dumpState(std::ostream& os)
{
os << (_shuttingDown ? "shutd " : "alive ")
<< std::setw(5) << 1.0*_pingTimeUs/1000 << "ms ";
if (_wsPayload.size() > 0)
- dump_hex(os, "\t\tws queued payload:\n", "\t\t", _wsPayload);
+ Util::dumpHex(os, "\t\tws queued payload:\n", "\t\t", _wsPayload);
os << "\n";
}
@@ -193,9 +155,9 @@ void StreamSocket::dumpState(std::ostream& os)
<< " r: " << _bytesRecvd << "\t w: " << _bytesSent << "\t";
_socketHandler->dumpState(os);
if (_inBuffer.size() > 0)
- dump_hex(os, "\t\tinBuffer:\n", "\t\t", _inBuffer);
+ Util::dumpHex(os, "\t\tinBuffer:\n", "\t\t", _inBuffer);
if (_outBuffer.size() > 0)
- dump_hex(os, "\t\toutBuffer:\n", "\t\t", _inBuffer);
+ Util::dumpHex(os, "\t\toutBuffer:\n", "\t\t", _inBuffer);
}
void StreamSocket::send(Poco::Net::HTTPResponse& response)