diff --git a/src/lib/base/Unicode.cpp b/src/lib/base/Unicode.cpp index ec200dc17..7b88f7840 100644 --- a/src/lib/base/Unicode.cpp +++ b/src/lib/base/Unicode.cpp @@ -25,11 +25,11 @@ // local utility functions // -inline static UInt16 decode16(const UInt8 *n, bool byteSwapped) +inline static UInt16 decode16(const uint8_t *n, bool byteSwapped) { union x16 { - UInt8 n8[2]; + uint8_t n8[2]; UInt16 n16; } c; if (byteSwapped) { @@ -42,11 +42,11 @@ inline static UInt16 decode16(const UInt8 *n, bool byteSwapped) return c.n16; } -inline static UInt32 decode32(const UInt8 *n, bool byteSwapped) +inline static UInt32 decode32(const uint8_t *n, bool byteSwapped) { union x32 { - UInt8 n8[4]; + uint8_t n8[4]; UInt32 n32; } c; if (byteSwapped) { @@ -87,7 +87,7 @@ UInt32 Unicode::s_replacement = 0x0000fffd; bool Unicode::isUTF8(const std::string &src) { // convert and test each character - const UInt8 *data = reinterpret_cast(src.c_str()); + const uint8_t *data = reinterpret_cast(src.c_str()); for (UInt32 n = (UInt32)src.size(); n > 0;) { if (fromUTF8(data, n) == s_invalid) { return false; @@ -107,7 +107,7 @@ std::string Unicode::UTF8ToUCS2(const std::string &src, bool *errors) dst.reserve(2 * n); // convert each character - const UInt8 *data = reinterpret_cast(src.c_str()); + const uint8_t *data = reinterpret_cast(src.c_str()); while (n > 0) { UInt32 c = fromUTF8(data, n); if (c == s_invalid) { @@ -134,7 +134,7 @@ std::string Unicode::UTF8ToUCS4(const std::string &src, bool *errors) dst.reserve(4 * n); // convert each character - const UInt8 *data = reinterpret_cast(src.c_str()); + const uint8_t *data = reinterpret_cast(src.c_str()); while (n > 0) { UInt32 c = fromUTF8(data, n); if (c == s_invalid) { @@ -157,7 +157,7 @@ std::string Unicode::UTF8ToUTF16(const std::string &src, bool *errors) dst.reserve(2 * n); // convert each character - const UInt8 *data = reinterpret_cast(src.c_str()); + const uint8_t *data = reinterpret_cast(src.c_str()); while (n > 0) { UInt32 c = fromUTF8(data, n); if (c == s_invalid) { @@ -192,7 +192,7 @@ std::string Unicode::UTF8ToUTF32(const std::string &src, bool *errors) dst.reserve(4 * n); // convert each character - const UInt8 *data = reinterpret_cast(src.c_str()); + const uint8_t *data = reinterpret_cast(src.c_str()); while (n > 0) { UInt32 c = fromUTF8(data, n); if (c == s_invalid) { @@ -236,7 +236,7 @@ std::string Unicode::UCS2ToUTF8(const std::string &src, bool *errors) // convert UInt32 n = (UInt32)src.size() >> 1; - return doUCS2ToUTF8(reinterpret_cast(src.data()), n, errors); + return doUCS2ToUTF8(reinterpret_cast(src.data()), n, errors); } std::string Unicode::UCS4ToUTF8(const std::string &src, bool *errors) @@ -246,7 +246,7 @@ std::string Unicode::UCS4ToUTF8(const std::string &src, bool *errors) // convert UInt32 n = (UInt32)src.size() >> 2; - return doUCS4ToUTF8(reinterpret_cast(src.data()), n, errors); + return doUCS4ToUTF8(reinterpret_cast(src.data()), n, errors); } std::string Unicode::UTF16ToUTF8(const std::string &src, bool *errors) @@ -256,7 +256,7 @@ std::string Unicode::UTF16ToUTF8(const std::string &src, bool *errors) // convert UInt32 n = (UInt32)src.size() >> 1; - return doUTF16ToUTF8(reinterpret_cast(src.data()), n, errors); + return doUTF16ToUTF8(reinterpret_cast(src.data()), n, errors); } std::string Unicode::UTF32ToUTF8(const std::string &src, bool *errors) @@ -266,7 +266,7 @@ std::string Unicode::UTF32ToUTF8(const std::string &src, bool *errors) // convert UInt32 n = (UInt32)src.size() >> 2; - return doUTF32ToUTF8(reinterpret_cast(src.data()), n, errors); + return doUTF32ToUTF8(reinterpret_cast(src.data()), n, errors); } std::string Unicode::textToUTF8(const std::string &src, bool *errors, IArchString::EWideCharEncoding encoding) @@ -335,16 +335,16 @@ Unicode::wideCharToUTF8(const wchar_t *src, UInt32 size, bool *errors, IArchStri // the String's nul character). switch (encoding) { case IArchString::kUCS2: - return doUCS2ToUTF8(reinterpret_cast(src), size, errors); + return doUCS2ToUTF8(reinterpret_cast(src), size, errors); case IArchString::kUCS4: - return doUCS4ToUTF8(reinterpret_cast(src), size, errors); + return doUCS4ToUTF8(reinterpret_cast(src), size, errors); case IArchString::kUTF16: - return doUTF16ToUTF8(reinterpret_cast(src), size, errors); + return doUTF16ToUTF8(reinterpret_cast(src), size, errors); case IArchString::kUTF32: - return doUTF32ToUTF8(reinterpret_cast(src), size, errors); + return doUTF32ToUTF8(reinterpret_cast(src), size, errors); default: assert(0 && "unknown wide character encoding"); @@ -352,7 +352,7 @@ Unicode::wideCharToUTF8(const wchar_t *src, UInt32 size, bool *errors, IArchStri } } -std::string Unicode::doUCS2ToUTF8(const UInt8 *data, UInt32 n, bool *errors) +std::string Unicode::doUCS2ToUTF8(const uint8_t *data, UInt32 n, bool *errors) { // make some space std::string dst; @@ -388,7 +388,7 @@ std::string Unicode::doUCS2ToUTF8(const UInt8 *data, UInt32 n, bool *errors) return dst; } -std::string Unicode::doUCS4ToUTF8(const UInt8 *data, UInt32 n, bool *errors) +std::string Unicode::doUCS4ToUTF8(const uint8_t *data, UInt32 n, bool *errors) { // make some space std::string dst; @@ -424,7 +424,7 @@ std::string Unicode::doUCS4ToUTF8(const UInt8 *data, UInt32 n, bool *errors) return dst; } -std::string Unicode::doUTF16ToUTF8(const UInt8 *data, UInt32 n, bool *errors) +std::string Unicode::doUTF16ToUTF8(const uint8_t *data, UInt32 n, bool *errors) { // make some space std::string dst; @@ -483,7 +483,7 @@ std::string Unicode::doUTF16ToUTF8(const UInt8 *data, UInt32 n, bool *errors) return dst; } -std::string Unicode::doUTF32ToUTF8(const UInt8 *data, UInt32 n, bool *errors) +std::string Unicode::doUTF32ToUTF8(const uint8_t *data, UInt32 n, bool *errors) { // make some space std::string dst; @@ -523,7 +523,7 @@ std::string Unicode::doUTF32ToUTF8(const UInt8 *data, UInt32 n, bool *errors) return dst; } -UInt32 Unicode::fromUTF8(const UInt8 *&data, UInt32 &n) +UInt32 Unicode::fromUTF8(const uint8_t *&data, UInt32 &n) { assert(data != NULL); assert(n != 0); @@ -675,7 +675,7 @@ UInt32 Unicode::fromUTF8(const UInt8 *&data, UInt32 &n) void Unicode::toUTF8(std::string &dst, UInt32 c, bool *errors) { - UInt8 data[6]; + uint8_t data[6]; // handle characters outside the valid range if ((c >= 0x0000d800 && c <= 0x0000dfff) || c >= 0x80000000) { @@ -685,37 +685,37 @@ void Unicode::toUTF8(std::string &dst, UInt32 c, bool *errors) // convert to UTF-8 if (c < 0x00000080) { - data[0] = static_cast(c); + data[0] = static_cast(c); dst.append(reinterpret_cast(data), 1); } else if (c < 0x00000800) { - data[0] = static_cast(((c >> 6) & 0x0000001f) + 0xc0); - data[1] = static_cast((c & 0x0000003f) + 0x80); + data[0] = static_cast(((c >> 6) & 0x0000001f) + 0xc0); + data[1] = static_cast((c & 0x0000003f) + 0x80); dst.append(reinterpret_cast(data), 2); } else if (c < 0x00010000) { - data[0] = static_cast(((c >> 12) & 0x0000000f) + 0xe0); - data[1] = static_cast(((c >> 6) & 0x0000003f) + 0x80); - data[2] = static_cast((c & 0x0000003f) + 0x80); + data[0] = static_cast(((c >> 12) & 0x0000000f) + 0xe0); + data[1] = static_cast(((c >> 6) & 0x0000003f) + 0x80); + data[2] = static_cast((c & 0x0000003f) + 0x80); dst.append(reinterpret_cast(data), 3); } else if (c < 0x00200000) { - data[0] = static_cast(((c >> 18) & 0x00000007) + 0xf0); - data[1] = static_cast(((c >> 12) & 0x0000003f) + 0x80); - data[2] = static_cast(((c >> 6) & 0x0000003f) + 0x80); - data[3] = static_cast((c & 0x0000003f) + 0x80); + data[0] = static_cast(((c >> 18) & 0x00000007) + 0xf0); + data[1] = static_cast(((c >> 12) & 0x0000003f) + 0x80); + data[2] = static_cast(((c >> 6) & 0x0000003f) + 0x80); + data[3] = static_cast((c & 0x0000003f) + 0x80); dst.append(reinterpret_cast(data), 4); } else if (c < 0x04000000) { - data[0] = static_cast(((c >> 24) & 0x00000003) + 0xf8); - data[1] = static_cast(((c >> 18) & 0x0000003f) + 0x80); - data[2] = static_cast(((c >> 12) & 0x0000003f) + 0x80); - data[3] = static_cast(((c >> 6) & 0x0000003f) + 0x80); - data[4] = static_cast((c & 0x0000003f) + 0x80); + data[0] = static_cast(((c >> 24) & 0x00000003) + 0xf8); + data[1] = static_cast(((c >> 18) & 0x0000003f) + 0x80); + data[2] = static_cast(((c >> 12) & 0x0000003f) + 0x80); + data[3] = static_cast(((c >> 6) & 0x0000003f) + 0x80); + data[4] = static_cast((c & 0x0000003f) + 0x80); dst.append(reinterpret_cast(data), 5); } else if (c < 0x80000000) { - data[0] = static_cast(((c >> 30) & 0x00000001) + 0xfc); - data[1] = static_cast(((c >> 24) & 0x0000003f) + 0x80); - data[2] = static_cast(((c >> 18) & 0x0000003f) + 0x80); - data[3] = static_cast(((c >> 12) & 0x0000003f) + 0x80); - data[4] = static_cast(((c >> 6) & 0x0000003f) + 0x80); - data[5] = static_cast((c & 0x0000003f) + 0x80); + data[0] = static_cast(((c >> 30) & 0x00000001) + 0xfc); + data[1] = static_cast(((c >> 24) & 0x0000003f) + 0x80); + data[2] = static_cast(((c >> 18) & 0x0000003f) + 0x80); + data[3] = static_cast(((c >> 12) & 0x0000003f) + 0x80); + data[4] = static_cast(((c >> 6) & 0x0000003f) + 0x80); + data[5] = static_cast((c & 0x0000003f) + 0x80); dst.append(reinterpret_cast(data), 6); } else { assert(0 && "character out of range"); diff --git a/src/lib/base/Unicode.h b/src/lib/base/Unicode.h index 28ab2729c..84fa10661 100644 --- a/src/lib/base/Unicode.h +++ b/src/lib/base/Unicode.h @@ -135,13 +135,13 @@ private: ); // internal conversion to UTF8 - static std::string doUCS2ToUTF8(const UInt8 *src, UInt32 n, bool *errors); - static std::string doUCS4ToUTF8(const UInt8 *src, UInt32 n, bool *errors); - static std::string doUTF16ToUTF8(const UInt8 *src, UInt32 n, bool *errors); - static std::string doUTF32ToUTF8(const UInt8 *src, UInt32 n, bool *errors); + static std::string doUCS2ToUTF8(const uint8_t *src, UInt32 n, bool *errors); + static std::string doUCS4ToUTF8(const uint8_t *src, UInt32 n, bool *errors); + static std::string doUTF16ToUTF8(const uint8_t *src, UInt32 n, bool *errors); + static std::string doUTF32ToUTF8(const uint8_t *src, UInt32 n, bool *errors); // convert characters to/from UTF8 - static UInt32 fromUTF8(const UInt8 *&src, UInt32 &size); + static UInt32 fromUTF8(const uint8_t *&src, UInt32 &size); static void toUTF8(std::string &dst, UInt32 c, bool *errors); private: diff --git a/src/lib/client/ServerProxy.cpp b/src/lib/client/ServerProxy.cpp index 1bbeb9f15..9c9fbaac3 100644 --- a/src/lib/client/ServerProxy.cpp +++ b/src/lib/client/ServerProxy.cpp @@ -110,7 +110,7 @@ void ServerProxy::setKeepAliveRate(double rate) void ServerProxy::handleData(const Event &, void *) { // handle messages until there are no more. first read message code. - UInt8 code[4]; + uint8_t code[4]; UInt32 n = m_stream->read(code, 4); while (n != 0) { // verify we got an entire code @@ -152,7 +152,7 @@ void ServerProxy::handleData(const Event &, void *) flushCompressedMouse(); } -ServerProxy::EResult ServerProxy::parseHandshakeMessage(const UInt8 *code) +ServerProxy::EResult ServerProxy::parseHandshakeMessage(const uint8_t *code) { if (memcmp(code, kMsgQInfo, 4) == 0) { queryInfo(); @@ -225,7 +225,7 @@ ServerProxy::EResult ServerProxy::parseHandshakeMessage(const UInt8 *code) return kOkay; } -ServerProxy::EResult ServerProxy::parseMessage(const UInt8 *code) +ServerProxy::EResult ServerProxy::parseMessage(const uint8_t *code) { if (memcmp(code, kMsgDMouseMove, 4) == 0) { mouseMove(); @@ -857,7 +857,7 @@ void ServerProxy::handleClipboardSendingEvent(const Event &event, void *) ClipboardChunk::send(m_stream, event.getDataObject()); } -void ServerProxy::fileChunkSending(UInt8 mark, char *data, size_t dataSize) +void ServerProxy::fileChunkSending(uint8_t mark, char *data, size_t dataSize) { FileChunk::send(m_stream, mark, data, dataSize); } diff --git a/src/lib/client/ServerProxy.h b/src/lib/client/ServerProxy.h index 1275cbb95..c69be0c06 100644 --- a/src/lib/client/ServerProxy.h +++ b/src/lib/client/ServerProxy.h @@ -63,7 +63,7 @@ public: //@} // sending file chunk to server - void fileChunkSending(UInt8 mark, char *data, size_t dataSize); + void fileChunkSending(uint8_t mark, char *data, size_t dataSize); // sending dragging information to server void sendDragInfo(UInt32 fileCount, const char *info, size_t size); @@ -82,8 +82,8 @@ protected: kUnknown, kDisconnect }; - EResult parseHandshakeMessage(const UInt8 *code); - EResult parseMessage(const UInt8 *code); + EResult parseHandshakeMessage(const uint8_t *code); + EResult parseMessage(const uint8_t *code); private: // if compressing mouse motion then send the last motion now @@ -129,7 +129,7 @@ private: void checkMissedLanguages() const; private: - typedef EResult (ServerProxy::*MessageParser)(const UInt8 *); + typedef EResult (ServerProxy::*MessageParser)(const uint8_t *); Client *m_client; deskflow::IStream *m_stream; diff --git a/src/lib/common/basic_types.h b/src/lib/common/basic_types.h index 665fcc5bd..2087befa7 100644 --- a/src/lib/common/basic_types.h +++ b/src/lib/common/basic_types.h @@ -86,7 +86,6 @@ #else using SInt16 = signed TYPE_OF_SIZE_2; using SInt32 = signed TYPE_OF_SIZE_4; -using UInt8 = unsigned TYPE_OF_SIZE_1; using UInt16 = unsigned TYPE_OF_SIZE_2; using UInt32 = unsigned TYPE_OF_SIZE_4; #endif diff --git a/src/lib/common/common.h b/src/lib/common/common.h index fe98313d6..a2e5fc512 100644 --- a/src/lib/common/common.h +++ b/src/lib/common/common.h @@ -32,6 +32,7 @@ // make assert available since we use it a lot #include +#include #include #include diff --git a/src/lib/common/ipc.h b/src/lib/common/ipc.h index cd4279586..d5a857cf1 100644 --- a/src/lib/common/ipc.h +++ b/src/lib/common/ipc.h @@ -19,7 +19,7 @@ #include "basic_types.h" -enum class IpcMessageType : UInt8 +enum class IpcMessageType : uint8_t { Hello, HelloBack, diff --git a/src/lib/deskflow/ClipboardChunk.cpp b/src/lib/deskflow/ClipboardChunk.cpp index b12732ae8..919305f18 100644 --- a/src/lib/deskflow/ClipboardChunk.cpp +++ b/src/lib/deskflow/ClipboardChunk.cpp @@ -76,7 +76,7 @@ ClipboardChunk *ClipboardChunk::end(ClipboardID id, UInt32 sequence) int ClipboardChunk::assemble(deskflow::IStream *stream, std::string &dataCached, ClipboardID &id, UInt32 &sequence) { - UInt8 mark; + uint8_t mark; std::string data; if (!ProtocolUtil::readf(stream, kMsgDClipboard + 4, &id, &sequence, &mark, &data)) { @@ -116,7 +116,7 @@ void ClipboardChunk::send(deskflow::IStream *stream, void *data) ClipboardID id = chunk[0]; UInt32 sequence; std::memcpy(&sequence, &chunk[1], 4); - UInt8 mark = chunk[5]; + uint8_t mark = chunk[5]; std::string dataChunk(&chunk[6], clipboardData->m_dataSize); switch (mark) { diff --git a/src/lib/deskflow/FileChunk.cpp b/src/lib/deskflow/FileChunk.cpp index df8f11cca..72c03ff6f 100644 --- a/src/lib/deskflow/FileChunk.cpp +++ b/src/lib/deskflow/FileChunk.cpp @@ -43,7 +43,7 @@ FileChunk *FileChunk::start(const std::string &size) return start; } -FileChunk *FileChunk::data(UInt8 *data, size_t dataSize) +FileChunk *FileChunk::data(uint8_t *data, size_t dataSize) { FileChunk *chunk = new FileChunk(dataSize + FILE_CHUNK_META_SIZE); char *chunkData = chunk->m_chunk; @@ -67,7 +67,7 @@ FileChunk *FileChunk::end() int FileChunk::assemble(deskflow::IStream *stream, std::string &dataReceived, size_t &expectedSize) { // parse - UInt8 mark = 0; + uint8_t mark = 0; std::string content; static size_t receivedDataSize; static double elapsedTime; @@ -129,7 +129,7 @@ int FileChunk::assemble(deskflow::IStream *stream, std::string &dataReceived, si return kError; } -void FileChunk::send(deskflow::IStream *stream, UInt8 mark, char *data, size_t dataSize) +void FileChunk::send(deskflow::IStream *stream, uint8_t mark, char *data, size_t dataSize) { std::string chunk(data, dataSize); diff --git a/src/lib/deskflow/FileChunk.h b/src/lib/deskflow/FileChunk.h index e5029d57f..d3613090a 100644 --- a/src/lib/deskflow/FileChunk.h +++ b/src/lib/deskflow/FileChunk.h @@ -34,8 +34,8 @@ public: FileChunk(size_t size); static FileChunk *start(const std::string &size); - static FileChunk *data(UInt8 *data, size_t dataSize); + static FileChunk *data(uint8_t *data, size_t dataSize); static FileChunk *end(); static int assemble(deskflow::IStream *stream, std::string &dataCached, size_t &expectedSize); - static void send(deskflow::IStream *stream, UInt8 mark, char *data, size_t dataSize); + static void send(deskflow::IStream *stream, uint8_t mark, char *data, size_t dataSize); }; diff --git a/src/lib/deskflow/IClipboard.cpp b/src/lib/deskflow/IClipboard.cpp index e3d443588..22da1c716 100644 --- a/src/lib/deskflow/IClipboard.cpp +++ b/src/lib/deskflow/IClipboard.cpp @@ -150,8 +150,8 @@ UInt32 IClipboard::readUInt32(const char *buf) void IClipboard::writeUInt32(std::string *buf, UInt32 v) { - *buf += static_cast((v >> 24) & 0xff); - *buf += static_cast((v >> 16) & 0xff); - *buf += static_cast((v >> 8) & 0xff); - *buf += static_cast(v & 0xff); + *buf += static_cast((v >> 24) & 0xff); + *buf += static_cast((v >> 16) & 0xff); + *buf += static_cast((v >> 8) & 0xff); + *buf += static_cast(v & 0xff); } diff --git a/src/lib/deskflow/PacketStreamFilter.cpp b/src/lib/deskflow/PacketStreamFilter.cpp index d4d819b8e..93efc72ae 100644 --- a/src/lib/deskflow/PacketStreamFilter.cpp +++ b/src/lib/deskflow/PacketStreamFilter.cpp @@ -90,11 +90,11 @@ UInt32 PacketStreamFilter::read(void *buffer, UInt32 n) void PacketStreamFilter::write(const void *buffer, UInt32 count) { // write the length of the payload - UInt8 length[4]; - length[0] = (UInt8)((count >> 24) & 0xff); - length[1] = (UInt8)((count >> 16) & 0xff); - length[2] = (UInt8)((count >> 8) & 0xff); - length[3] = (UInt8)(count & 0xff); + uint8_t length[4]; + length[0] = (uint8_t)((count >> 24) & 0xff); + length[1] = (uint8_t)((count >> 16) & 0xff); + length[2] = (uint8_t)((count >> 8) & 0xff); + length[3] = (uint8_t)(count & 0xff); getStream()->write(length, sizeof(length)); // write the payload @@ -131,7 +131,7 @@ bool PacketStreamFilter::readPacketSize() // note -- m_mutex must be locked on entry if (m_size == 0 && m_buffer.getSize() >= 4) { - UInt8 buffer[4]; + uint8_t buffer[4]; memcpy(buffer, m_buffer.peek(sizeof(buffer)), sizeof(buffer)); m_buffer.pop(sizeof(buffer)); m_size = ((UInt32)buffer[0] << 24) | ((UInt32)buffer[1] << 16) | ((UInt32)buffer[2] << 8) | (UInt32)buffer[3]; diff --git a/src/lib/deskflow/ProtocolUtil.cpp b/src/lib/deskflow/ProtocolUtil.cpp index 6996c003a..54da4f194 100644 --- a/src/lib/deskflow/ProtocolUtil.cpp +++ b/src/lib/deskflow/ProtocolUtil.cpp @@ -34,21 +34,21 @@ namespace { -void writeInt(UInt32 Value, UInt32 Length, std::vector &Buffer) +void writeInt(UInt32 Value, UInt32 Length, std::vector &Buffer) { switch (Length) { case 1: - Buffer.push_back(static_cast(Value & 0xffU)); + Buffer.push_back(static_cast(Value & 0xffU)); break; case 4: - Buffer.push_back(static_cast((Value >> 24U) & 0xffU)); - Buffer.push_back(static_cast((Value >> 16U) & 0xffU)); - Buffer.push_back(static_cast((Value >> 8U) & 0xffU)); - Buffer.push_back(static_cast(Value & 0xffU)); + Buffer.push_back(static_cast((Value >> 24U) & 0xffU)); + Buffer.push_back(static_cast((Value >> 16U) & 0xffU)); + Buffer.push_back(static_cast((Value >> 8U) & 0xffU)); + Buffer.push_back(static_cast(Value & 0xffU)); break; case 2: - Buffer.push_back(static_cast((Value >> 8U) & 0xffU)); - Buffer.push_back(static_cast(Value & 0xffU)); + Buffer.push_back(static_cast((Value >> 8U) & 0xffU)); + Buffer.push_back(static_cast(Value & 0xffU)); break; default: assert(0 && "invalid integer format length"); @@ -56,7 +56,7 @@ void writeInt(UInt32 Value, UInt32 Length, std::vector &Buffer) } } -template void writeVectorInt(const std::vector *VectorData, std::vector &Buffer) +template void writeVectorInt(const std::vector *VectorData, std::vector &Buffer) { if (VectorData) { const std::vector &Vector = *VectorData; @@ -67,7 +67,7 @@ template void writeVectorInt(const std::vector *VectorData, std: } } -void writeString(const std::string *StringData, std::vector &Buffer) +void writeString(const std::string *StringData, std::vector &Buffer) { const UInt32 len = (StringData != NULL) ? (UInt32)StringData->size() : 0; writeInt(len, sizeof(len), Buffer); @@ -126,7 +126,7 @@ void ProtocolUtil::vwritef(deskflow::IStream *stream, const char *fmt, UInt32 si } // fill buffer - std::vector Buffer; + std::vector Buffer; writef(Buffer, fmt, args); try { @@ -156,7 +156,7 @@ void ProtocolUtil::vreadf(deskflow::IStream *stream, const char *fmt, va_list ar switch (len) { case 1: // 1 byte integer - *static_cast(destination) = read1ByteInt(stream); + *static_cast(destination) = read1ByteInt(stream); break; case 2: // 2 byte integer @@ -180,7 +180,7 @@ void ProtocolUtil::vreadf(deskflow::IStream *stream, const char *fmt, va_list ar switch (len) { case 1: // 1 byte integer - readVector1ByteInt(stream, *static_cast *>(destination)); + readVector1ByteInt(stream, *static_cast *>(destination)); break; case 2: // 2 byte integer @@ -256,7 +256,7 @@ UInt32 ProtocolUtil::getLength(const char *fmt, va_list args) assert(len == 1 || len == 2 || len == 4); switch (len) { case 1: - len = (UInt32)(va_arg(args, std::vector *))->size() + 4; + len = (UInt32)(va_arg(args, std::vector *))->size() + 4; break; case 2: @@ -300,7 +300,7 @@ UInt32 ProtocolUtil::getLength(const char *fmt, va_list args) return n; } -void ProtocolUtil::writef(std::vector &buffer, const char *fmt, va_list args) +void ProtocolUtil::writef(std::vector &buffer, const char *fmt, va_list args) { while (*fmt) { if (*fmt == '%') { @@ -318,7 +318,7 @@ void ProtocolUtil::writef(std::vector &buffer, const char *fmt, va_list a switch (len) { case 1: { // 1 byte integers - const std::vector *list = va_arg(args, const std::vector *); + const std::vector *list = va_arg(args, const std::vector *); writeVectorInt(list, buffer); break; } @@ -354,7 +354,7 @@ void ProtocolUtil::writef(std::vector &buffer, const char *fmt, va_list a case 'S': { assert(len == 0); const UInt32 len = va_arg(args, UInt32); - const UInt8 *src = va_arg(args, UInt8 *); + const uint8_t *src = va_arg(args, uint8_t *); writeInt(len, sizeof(len), buffer); std::copy(src, src + len, std::back_inserter(buffer)); break; @@ -429,7 +429,7 @@ void ProtocolUtil::read(deskflow::IStream *stream, void *vbuffer, UInt32 count) assert(stream != NULL); assert(vbuffer != NULL); - UInt8 *buffer = static_cast(vbuffer); + uint8_t *buffer = static_cast(vbuffer); while (count > 0) { // read more UInt32 n = stream->read(buffer, count); @@ -446,13 +446,13 @@ void ProtocolUtil::read(deskflow::IStream *stream, void *vbuffer, UInt32 count) } } -UInt8 ProtocolUtil::read1ByteInt(deskflow::IStream *stream) +uint8_t ProtocolUtil::read1ByteInt(deskflow::IStream *stream) { const UInt32 BufferSize = 1; - std::array buffer = {}; + std::array buffer = {}; read(stream, buffer.data(), BufferSize); - UInt8 Result = buffer[0]; + uint8_t Result = buffer[0]; LOG((CLOG_DEBUG2 "readf: read 1 byte integer: %d (0x%x)", Result, Result)); return Result; @@ -461,7 +461,7 @@ UInt8 ProtocolUtil::read1ByteInt(deskflow::IStream *stream) UInt16 ProtocolUtil::read2BytesInt(deskflow::IStream *stream) { const UInt32 BufferSize = 2; - std::array buffer = {}; + std::array buffer = {}; read(stream, buffer.data(), BufferSize); UInt16 Result = static_cast((static_cast(buffer[0]) << 8) | static_cast(buffer[1])); @@ -473,7 +473,7 @@ UInt16 ProtocolUtil::read2BytesInt(deskflow::IStream *stream) UInt32 ProtocolUtil::read4BytesInt(deskflow::IStream *stream) { const int BufferSize = 4; - std::array buffer = {}; + std::array buffer = {}; read(stream, buffer.data(), BufferSize); UInt32 Result = (static_cast(buffer[0]) << 24) | (static_cast(buffer[1]) << 16) | @@ -484,7 +484,7 @@ UInt32 ProtocolUtil::read4BytesInt(deskflow::IStream *stream) return Result; } -void ProtocolUtil::readVector1ByteInt(deskflow::IStream *stream, std::vector &destination) +void ProtocolUtil::readVector1ByteInt(deskflow::IStream *stream, std::vector &destination) { UInt32 size = readVectorSize(stream); for (UInt32 i = 0; i < size; ++i) { @@ -523,7 +523,7 @@ UInt32 ProtocolUtil::readVectorSize(deskflow::IStream *stream) void ProtocolUtil::readBytes(deskflow::IStream *stream, UInt32 len, std::string *destination) { // read the string length - UInt8 buffer[128]; + uint8_t buffer[128]; // when string length is 0, this implies that the size of the string is // variable and will be embedded in the stream. @@ -535,10 +535,10 @@ void ProtocolUtil::readBytes(deskflow::IStream *stream, UInt32 len, std::string const bool useFixed = (len <= sizeof(buffer)); // allocate a buffer to read the data - UInt8 *sBuffer = buffer; + uint8_t *sBuffer = buffer; if (!useFixed) { try { - sBuffer = new UInt8[len]; + sBuffer = new uint8_t[len]; } catch (std::bad_alloc &exception) { // Added try catch due to GHSA-chfm-333q-gfpp LOG((CLOG_ERR "bad alloc, unable to allocate memory %d bytes", len)); diff --git a/src/lib/deskflow/ProtocolUtil.h b/src/lib/deskflow/ProtocolUtil.h index 4ad75a578..22197ce94 100644 --- a/src/lib/deskflow/ProtocolUtil.h +++ b/src/lib/deskflow/ProtocolUtil.h @@ -48,11 +48,11 @@ public: - \%1i -- converts integer argument to 1 byte integer - \%2i -- converts integer argument to 2 byte integer in NBO - \%4i -- converts integer argument to 4 byte integer in NBO - - \%1I -- converts std::vector* to 1 byte integers + - \%1I -- converts std::vector* to 1 byte integers - \%2I -- converts std::vector* to 2 byte integers in NBO - \%4I -- converts std::vector* to 4 byte integers in NBO - \%s -- converts std::string* to stream of bytes - - \%S -- converts integer N and const UInt8* to stream of N bytes + - \%S -- converts integer N and const uint8_t* to stream of N bytes */ static void writef(deskflow::IStream *, const char *fmt, ...); @@ -67,7 +67,7 @@ public: - \%1i -- reads a 1 byte integer; argument is a SInt32* or UInt32* - \%2i -- reads an NBO 2 byte integer; arg is SInt32* or UInt32* - \%4i -- reads an NBO 4 byte integer; arg is SInt32* or UInt32* - - \%1I -- reads 1 byte integers; arg is std::vector* + - \%1I -- reads 1 byte integers; arg is std::vector* - \%2I -- reads NBO 2 byte integers; arg is std::vector* - \%4I -- reads NBO 4 byte integers; arg is std::vector* - \%s -- reads bytes; argument must be a std::string*, \b not a char* @@ -79,21 +79,21 @@ private: static void vreadf(deskflow::IStream *, const char *fmt, va_list); static UInt32 getLength(const char *fmt, va_list); - static void writef(std::vector &, const char *fmt, va_list); + static void writef(std::vector &, const char *fmt, va_list); static UInt32 eatLength(const char **fmt); static void read(deskflow::IStream *, void *, UInt32); /** * @brief Handles 1,2, or 4 byte Integers */ - static UInt8 read1ByteInt(deskflow::IStream *stream); + static uint8_t read1ByteInt(deskflow::IStream *stream); static UInt16 read2BytesInt(deskflow::IStream *stream); static UInt32 read4BytesInt(deskflow::IStream *stream); /** * @brief Handles a Vector of integers */ - static void readVector1ByteInt(deskflow::IStream *, std::vector &); + static void readVector1ByteInt(deskflow::IStream *, std::vector &); static void readVector2BytesInt(deskflow::IStream *, std::vector &); static void readVector4BytesInt(deskflow::IStream *, std::vector &); static UInt32 readVectorSize(deskflow::IStream *stream); diff --git a/src/lib/deskflow/StreamChunker.cpp b/src/lib/deskflow/StreamChunker.cpp index 4c5491428..a9c818302 100644 --- a/src/lib/deskflow/StreamChunker.cpp +++ b/src/lib/deskflow/StreamChunker.cpp @@ -81,7 +81,7 @@ void StreamChunker::sendFile(char *filename, IEventQueue *events, void *eventTar char *chunkData = new char[chunkSize]; file.read(chunkData, chunkSize); - UInt8 *data = reinterpret_cast(chunkData); + uint8_t *data = reinterpret_cast(chunkData); FileChunk *fileChunk = FileChunk::data(data, chunkSize); delete[] chunkData; diff --git a/src/lib/deskflow/clipboard_types.h b/src/lib/deskflow/clipboard_types.h index 6925ad499..c3dad4e4c 100644 --- a/src/lib/deskflow/clipboard_types.h +++ b/src/lib/deskflow/clipboard_types.h @@ -24,7 +24,7 @@ /*! Type to hold a clipboard identifier. */ -using ClipboardID = UInt8; +using ClipboardID = uint8_t; //! @name Clipboard identifiers //@{ diff --git a/src/lib/deskflow/mouse_types.h b/src/lib/deskflow/mouse_types.h index bbfd5661e..d85d93658 100644 --- a/src/lib/deskflow/mouse_types.h +++ b/src/lib/deskflow/mouse_types.h @@ -24,7 +24,7 @@ /*! Type to hold a mouse button identifier. */ -using ButtonID = UInt8; +using ButtonID = uint8_t; //! @name Mouse button identifiers //@{ @@ -39,4 +39,4 @@ static const ButtonID kMacButtonRight = 2; static const ButtonID kMacButtonMiddle = 3; //@} -static const UInt8 NumButtonIDs = 5; +static const uint8_t NumButtonIDs = 5; diff --git a/src/lib/deskflow/protocol_types.h b/src/lib/deskflow/protocol_types.h index e6ed7af00..40d1f2cdd 100644 --- a/src/lib/deskflow/protocol_types.h +++ b/src/lib/deskflow/protocol_types.h @@ -57,9 +57,9 @@ static const double kHeartBeatsUntilDeath = 3.0; // Messages of very large size indicate a likely protocol error. We don't parse such messages and // drop connection instead. Note that e.g. the clipboard messages are already limited to 32kB. -static constexpr std::uint32_t PROTOCOL_MAX_MESSAGE_LENGTH = 4 * 1024 * 1024; -static constexpr std::uint32_t PROTOCOL_MAX_LIST_LENGTH = 1024 * 1024; -static constexpr std::uint32_t PROTOCOL_MAX_STRING_LENGTH = 1024 * 1024; +static constexpr uint32_t PROTOCOL_MAX_MESSAGE_LENGTH = 4 * 1024 * 1024; +static constexpr uint32_t PROTOCOL_MAX_LIST_LENGTH = 1024 * 1024; +static constexpr uint32_t PROTOCOL_MAX_STRING_LENGTH = 1024 * 1024; // direction constants enum EDirection diff --git a/src/lib/io/StreamBuffer.cpp b/src/lib/io/StreamBuffer.cpp index 96dc1257e..ae2c5c61e 100644 --- a/src/lib/io/StreamBuffer.cpp +++ b/src/lib/io/StreamBuffer.cpp @@ -100,7 +100,7 @@ void StreamBuffer::write(const void *vdata, UInt32 n) m_size += n; // cast data to bytes - const UInt8 *data = static_cast(vdata); + const uint8_t *data = static_cast(vdata); // point to last chunk if it has space, otherwise append an empty chunk ChunkList::iterator scan = m_chunks.end(); diff --git a/src/lib/io/StreamBuffer.h b/src/lib/io/StreamBuffer.h index 96ebe08f0..d62ccff81 100644 --- a/src/lib/io/StreamBuffer.h +++ b/src/lib/io/StreamBuffer.h @@ -71,7 +71,7 @@ public: private: static const UInt32 kChunkSize; - using Chunk = std::vector; + using Chunk = std::vector; using ChunkList = std::list; ChunkList m_chunks; diff --git a/src/lib/ipc/IpcClientProxy.cpp b/src/lib/ipc/IpcClientProxy.cpp index 7060f097e..1b00f903e 100644 --- a/src/lib/ipc/IpcClientProxy.cpp +++ b/src/lib/ipc/IpcClientProxy.cpp @@ -89,7 +89,7 @@ void IpcClientProxy::handleData(const Event &, void *) LOG((CLOG_DEBUG "start ipc handle data")); - UInt8 code[4]; + uint8_t code[4]; UInt32 n = m_stream.read(code, 4); while (n != 0) { @@ -151,7 +151,7 @@ void IpcClientProxy::send(const IpcMessage &message) IpcHelloMessage *IpcClientProxy::parseHello() { - UInt8 type; + uint8_t type; ProtocolUtil::readf(&m_stream, kIpcMsgHello + 4, &type); m_clientType = static_cast(type); @@ -163,7 +163,7 @@ IpcHelloMessage *IpcClientProxy::parseHello() IpcCommandMessage *IpcClientProxy::parseCommand() { std::string command; - UInt8 elevate; + uint8_t elevate; ProtocolUtil::readf(&m_stream, kIpcMsgCommand + 4, &command, &elevate); // must be deleted by event handler. diff --git a/src/lib/ipc/IpcServerProxy.cpp b/src/lib/ipc/IpcServerProxy.cpp index eaa8edf77..bddb7d466 100644 --- a/src/lib/ipc/IpcServerProxy.cpp +++ b/src/lib/ipc/IpcServerProxy.cpp @@ -46,7 +46,7 @@ void IpcServerProxy::handleData(const Event &, void *) { LOG((CLOG_DEBUG "start ipc handle data")); - UInt8 code[4]; + uint8_t code[4]; UInt32 n = m_stream.read(code, 4); while (n != 0) { diff --git a/src/lib/net/InverseSockets/AutoArchSocket.cpp b/src/lib/net/InverseSockets/AutoArchSocket.cpp index 0ded92291..89b4966e4 100644 --- a/src/lib/net/InverseSockets/AutoArchSocket.cpp +++ b/src/lib/net/InverseSockets/AutoArchSocket.cpp @@ -144,7 +144,7 @@ bool AutoArchSocket::connectSocket(const NetworkAddress &addr) return result; } -size_t AutoArchSocket::readSocket(UInt8 *buffer, size_t size) +size_t AutoArchSocket::readSocket(uint8_t *buffer, size_t size) { size_t result = 0; @@ -155,7 +155,7 @@ size_t AutoArchSocket::readSocket(UInt8 *buffer, size_t size) return result; } -size_t AutoArchSocket::writeSocket(const UInt8 *buffer, size_t size) +size_t AutoArchSocket::writeSocket(const uint8_t *buffer, size_t size) { size_t result = 0; diff --git a/src/lib/net/InverseSockets/AutoArchSocket.h b/src/lib/net/InverseSockets/AutoArchSocket.h index ba2483c28..64aac68b6 100644 --- a/src/lib/net/InverseSockets/AutoArchSocket.h +++ b/src/lib/net/InverseSockets/AutoArchSocket.h @@ -40,8 +40,8 @@ public: void closeSocketForRead(); void closeSocketForWrite(); - size_t readSocket(UInt8 *buffer, size_t size); - size_t writeSocket(const UInt8 *buffer, size_t size); + size_t readSocket(uint8_t *buffer, size_t size); + size_t writeSocket(const uint8_t *buffer, size_t size); void throwErrorOnSocket(); bool isValid() const; diff --git a/src/lib/net/InverseSockets/InverseClientSocket.cpp b/src/lib/net/InverseSockets/InverseClientSocket.cpp index 64795d3fa..2bb7f3c97 100644 --- a/src/lib/net/InverseSockets/InverseClientSocket.cpp +++ b/src/lib/net/InverseSockets/InverseClientSocket.cpp @@ -212,7 +212,7 @@ void InverseClientSocket::connect(const NetworkAddress &addr) InverseClientSocket::EJobResult InverseClientSocket::doRead() { - UInt8 buffer[4096] = {0}; + uint8_t buffer[4096] = {0}; size_t bytesRead = m_socket.readSocket(buffer, sizeof(buffer)); if (bytesRead > 0) { @@ -248,7 +248,7 @@ InverseClientSocket::EJobResult InverseClientSocket::doRead() InverseClientSocket::EJobResult InverseClientSocket::doWrite() { UInt32 bufferSize = m_outputBuffer.getSize(); - auto buffer = static_cast(m_outputBuffer.peek(bufferSize)); + auto buffer = static_cast(m_outputBuffer.peek(bufferSize)); const auto bytesWrote = static_cast(m_socket.writeSocket(buffer, bufferSize)); if (bytesWrote > 0) { diff --git a/src/lib/net/InverseSockets/SecureClientSocket.cpp b/src/lib/net/InverseSockets/SecureClientSocket.cpp index adbf3edaa..9ac36d3e7 100644 --- a/src/lib/net/InverseSockets/SecureClientSocket.cpp +++ b/src/lib/net/InverseSockets/SecureClientSocket.cpp @@ -84,7 +84,7 @@ void SecureClientSocket::secureAccept() InverseClientSocket::EJobResult SecureClientSocket::doRead() { - UInt8 buffer[4096] = {0}; + uint8_t buffer[4096] = {0}; int bytesRead = 0; int status = 0; diff --git a/src/lib/net/SecureSocket.cpp b/src/lib/net/SecureSocket.cpp index 44cb14776..f60aabb58 100644 --- a/src/lib/net/SecureSocket.cpp +++ b/src/lib/net/SecureSocket.cpp @@ -127,7 +127,7 @@ void SecureSocket::secureAccept() TCPSocket::EJobResult SecureSocket::doRead() { - static UInt8 buffer[4096]; + static uint8_t buffer[4096]; memset(buffer, 0, sizeof(buffer)); int bytesRead = 0; int status = 0; diff --git a/src/lib/net/TCPSocket.cpp b/src/lib/net/TCPSocket.cpp index 714c346ad..70382a3d8 100644 --- a/src/lib/net/TCPSocket.cpp +++ b/src/lib/net/TCPSocket.cpp @@ -313,7 +313,7 @@ void TCPSocket::init() TCPSocket::EJobResult TCPSocket::doRead() { - UInt8 buffer[4096]; + uint8_t buffer[4096]; memset(buffer, 0, sizeof(buffer)); size_t bytesRead = 0; diff --git a/src/lib/platform/IOSXKeyResource.cpp b/src/lib/platform/IOSXKeyResource.cpp index af6f70282..6c037b1e9 100644 --- a/src/lib/platform/IOSXKeyResource.cpp +++ b/src/lib/platform/IOSXKeyResource.cpp @@ -19,7 +19,7 @@ #include -KeyID IOSXKeyResource::getKeyID(UInt8 c) +KeyID IOSXKeyResource::getKeyID(uint8_t c) { if (c == 0) { return kKeyNone; diff --git a/src/lib/platform/IOSXKeyResource.h b/src/lib/platform/IOSXKeyResource.h index 366800571..c8bdb3315 100644 --- a/src/lib/platform/IOSXKeyResource.h +++ b/src/lib/platform/IOSXKeyResource.h @@ -30,7 +30,7 @@ public: virtual KeyID getKey(UInt32 table, UInt32 button) const = 0; // Convert a character in the current script to the equivalent KeyID - static KeyID getKeyID(UInt8); + static KeyID getKeyID(uint8_t); // Convert a unicode character to the equivalent KeyID. static KeyID unicharToKeyID(UniChar); diff --git a/src/lib/platform/MSWindowsDesks.cpp b/src/lib/platform/MSWindowsDesks.cpp index ea356dd49..f8aedf5d8 100644 --- a/src/lib/platform/MSWindowsDesks.cpp +++ b/src/lib/platform/MSWindowsDesks.cpp @@ -346,8 +346,8 @@ MSWindowsDesks::createBlankCursor() const // create a transparent cursor int cw = GetSystemMetrics(SM_CXCURSOR); int ch = GetSystemMetrics(SM_CYCURSOR); - UInt8 *cursorAND = new UInt8[ch * ((cw + 31) >> 2)]; - UInt8 *cursorXOR = new UInt8[ch * ((cw + 31) >> 2)]; + uint8_t *cursorAND = new uint8_t[ch * ((cw + 31) >> 2)]; + uint8_t *cursorXOR = new uint8_t[ch * ((cw + 31) >> 2)]; memset(cursorAND, 0xff, ch * ((cw + 31) >> 2)); memset(cursorXOR, 0x00, ch * ((cw + 31) >> 2)); HCURSOR c = CreateCursor(MSWindowsScreen::getWindowInstance(), 0, 0, cw, ch, cursorAND, cursorXOR); diff --git a/src/lib/platform/MSWindowsScreen.cpp b/src/lib/platform/MSWindowsScreen.cpp index fa8564249..f6dcb3e60 100644 --- a/src/lib/platform/MSWindowsScreen.cpp +++ b/src/lib/platform/MSWindowsScreen.cpp @@ -825,8 +825,8 @@ MSWindowsScreen::createBlankCursor() const int cw = GetSystemMetrics(SM_CXCURSOR); int ch = GetSystemMetrics(SM_CYCURSOR); - UInt8 *cursorAND = new UInt8[ch * ((cw + 31) >> 2)]; - UInt8 *cursorXOR = new UInt8[ch * ((cw + 31) >> 2)]; + uint8_t *cursorAND = new uint8_t[ch * ((cw + 31) >> 2)]; + uint8_t *cursorXOR = new uint8_t[ch * ((cw + 31) >> 2)]; memset(cursorAND, 0xff, ch * ((cw + 31) >> 2)); memset(cursorXOR, 0x00, ch * ((cw + 31) >> 2)); HCURSOR c = CreateCursor(s_windowInstance, 0, 0, cw, ch, cursorAND, cursorXOR); diff --git a/src/lib/platform/OSXClipboard.cpp b/src/lib/platform/OSXClipboard.cpp index d6b7fc3ae..a07d2f4b8 100644 --- a/src/lib/platform/OSXClipboard.cpp +++ b/src/lib/platform/OSXClipboard.cpp @@ -109,7 +109,7 @@ void OSXClipboard::add(EFormat format, const std::string &data) if (converter->getFormat() == format) { std::string osXData = converter->fromIClipboard(data); CFStringRef flavorType = converter->getOSXFormat(); - CFDataRef dataRef = CFDataCreate(kCFAllocatorDefault, (UInt8 *)osXData.data(), osXData.size()); + CFDataRef dataRef = CFDataCreate(kCFAllocatorDefault, (uint8_t *)osXData.data(), osXData.size()); PasteboardItemID itemID = 0; if (dataRef) { diff --git a/src/lib/platform/OSXClipboardBMPConverter.cpp b/src/lib/platform/OSXClipboardBMPConverter.cpp index b2088f797..4c8d55730 100644 --- a/src/lib/platform/OSXClipboardBMPConverter.cpp +++ b/src/lib/platform/OSXClipboardBMPConverter.cpp @@ -31,31 +31,31 @@ public: }; // BMP is little-endian -static inline UInt32 fromLEU32(const UInt8 *data) +static inline UInt32 fromLEU32(const uint8_t *data) { return static_cast(data[0]) | (static_cast(data[1]) << 8) | (static_cast(data[2]) << 16) | (static_cast(data[3]) << 24); } -static void toLE(UInt8 *&dst, char src) +static void toLE(uint8_t *&dst, char src) { - dst[0] = static_cast(src); + dst[0] = static_cast(src); dst += 1; } -static void toLE(UInt8 *&dst, UInt16 src) +static void toLE(uint8_t *&dst, UInt16 src) { - dst[0] = static_cast(src & 0xffu); - dst[1] = static_cast((src >> 8) & 0xffu); + dst[0] = static_cast(src & 0xffu); + dst[1] = static_cast((src >> 8) & 0xffu); dst += 2; } -static void toLE(UInt8 *&dst, UInt32 src) +static void toLE(uint8_t *&dst, UInt32 src) { - dst[0] = static_cast(src & 0xffu); - dst[1] = static_cast((src >> 8) & 0xffu); - dst[2] = static_cast((src >> 16) & 0xffu); - dst[3] = static_cast((src >> 24) & 0xffu); + dst[0] = static_cast(src & 0xffu); + dst[1] = static_cast((src >> 8) & 0xffu); + dst[2] = static_cast((src >> 16) & 0xffu); + dst[3] = static_cast((src >> 24) & 0xffu); dst += 4; } @@ -84,8 +84,8 @@ std::string OSXClipboardBMPConverter::fromIClipboard(const std::string &bmp) con { LOG((CLOG_DEBUG1 "getting data from clipboard")); // create BMP image - UInt8 header[14]; - UInt8 *dst = header; + uint8_t header[14]; + uint8_t *dst = header; toLE(dst, 'B'); toLE(dst, 'M'); toLE(dst, static_cast(14 + bmp.size())); @@ -103,7 +103,7 @@ std::string OSXClipboardBMPConverter::toIClipboard(const std::string &bmp) const } // check BMP file header - const UInt8 *rawBMPHeader = reinterpret_cast(bmp.data()); + const uint8_t *rawBMPHeader = reinterpret_cast(bmp.data()); if (rawBMPHeader[0] != 'B' || rawBMPHeader[1] != 'M') { return std::string(); } diff --git a/src/lib/platform/OSXClipboardHTMLConverter.cpp b/src/lib/platform/OSXClipboardHTMLConverter.cpp index d7052658a..0168d289b 100644 --- a/src/lib/platform/OSXClipboardHTMLConverter.cpp +++ b/src/lib/platform/OSXClipboardHTMLConverter.cpp @@ -62,7 +62,7 @@ std::string OSXClipboardHTMLConverter::convertString( return std::string(); } - CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, (UInt8 *)buffer, buffSize, NULL); + CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, (uint8_t *)buffer, buffSize, NULL); std::string result(buffer, buffSize); diff --git a/src/lib/platform/OSXClipboardTextConverter.cpp b/src/lib/platform/OSXClipboardTextConverter.cpp index 9dcfc0480..6366d1f8b 100644 --- a/src/lib/platform/OSXClipboardTextConverter.cpp +++ b/src/lib/platform/OSXClipboardTextConverter.cpp @@ -61,7 +61,7 @@ std::string OSXClipboardTextConverter::convertString( return std::string(); } - CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, (UInt8 *)buffer, buffSize, NULL); + CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, (uint8_t *)buffer, buffSize, NULL); std::string result(buffer, buffSize); diff --git a/src/lib/platform/OSXKeyState.cpp b/src/lib/platform/OSXKeyState.cpp index 8e50492ef..3f814ca0a 100644 --- a/src/lib/platform/OSXKeyState.cpp +++ b/src/lib/platform/OSXKeyState.cpp @@ -177,9 +177,9 @@ io_connect_t getEventDriver() return sEventDrvrRef; } -bool isModifier(UInt8 virtualKey) +bool isModifier(uint8_t virtualKey) { - static std::set modifiers{s_shiftVK, s_superVK, s_altVK, s_controlVK, s_capsLockVK}; + static std::set modifiers{s_shiftVK, s_superVK, s_altVK, s_controlVK, s_capsLockVK}; return (modifiers.find(virtualKey) != modifiers.end()); } @@ -459,7 +459,7 @@ void OSXKeyState::pollPressedKeys(KeyButtonSet &pressedKeys) const { ::KeyMap km; GetKeys(km); - const UInt8 *m = reinterpret_cast(km); + const uint8_t *m = reinterpret_cast(km); for (UInt32 i = 0; i < 16; ++i) { for (UInt32 j = 0; j < 8; ++j) { if ((m[i] & (1u << j)) != 0) { @@ -573,7 +573,7 @@ void OSXKeyState::setKeyboardModifiers(CGKeyCode virtualKey, bool keyDown) } } -kern_return_t OSXKeyState::postHIDVirtualKey(UInt8 virtualKey, bool postDown) +kern_return_t OSXKeyState::postHIDVirtualKey(uint8_t virtualKey, bool postDown) { NXEventData event; bzero(&event, sizeof(NXEventData)); @@ -732,11 +732,11 @@ bool OSXKeyState::getKeyMap(deskflow::KeyMap &keyMap, SInt32 group, const IOSXKe // collect the tables that map to the same KeyID. we know it // can't be any earlier tables because of the check above. - std::set tables; - tables.insert(static_cast(j)); + std::set tables; + tables.insert(static_cast(j)); for (UInt32 k = j + 1; k < r.getNumTables(); ++k) { if (buttonKeys[k].first == id) { - tables.insert(static_cast(k)); + tables.insert(static_cast(k)); } } diff --git a/src/lib/platform/OSXKeyState.h b/src/lib/platform/OSXKeyState.h index bd79042a6..fc401229a 100644 --- a/src/lib/platform/OSXKeyState.h +++ b/src/lib/platform/OSXKeyState.h @@ -140,7 +140,7 @@ private: // Post a key event to HID manager. It posts an event to HID client, a // much lower level than window manager which's the target from carbon // CGEventPost - kern_return_t postHIDVirtualKey(UInt8 virtualKeyCode, bool postDown); + kern_return_t postHIDVirtualKey(uint8_t virtualKeyCode, bool postDown); // Get keyboard event flags accorfing to keyboard modifiers CGEventFlags getKeyboardEventFlags() const; diff --git a/src/lib/platform/OSXUchrKeyResource.cpp b/src/lib/platform/OSXUchrKeyResource.cpp index 247e84d70..56680ae19 100644 --- a/src/lib/platform/OSXUchrKeyResource.cpp +++ b/src/lib/platform/OSXUchrKeyResource.cpp @@ -55,7 +55,7 @@ OSXUchrKeyResource::OSXUchrKeyResource(const void *resource, UInt32 keyboardType } // get tables for keyboard type - const UInt8 *const base = reinterpret_cast(m_resource); + const uint8_t *const base = reinterpret_cast(m_resource); m_m = reinterpret_cast(base + th->keyModifiersToTableNumOffset); m_cti = reinterpret_cast(base + th->keyToCharTableIndexOffset); m_sdi = reinterpret_cast(base + th->keySequenceDataIndexOffset); @@ -118,7 +118,7 @@ KeyID OSXUchrKeyResource::getKey(UInt32 table, UInt32 button) const assert(table < getNumTables()); assert(button < getNumButtons()); - const UInt8 *const base = reinterpret_cast(m_resource); + const uint8_t *const base = reinterpret_cast(m_resource); const UCKeyOutput *cPtr = reinterpret_cast(base + m_cti->keyToCharTableOffsets[table]); const UCKeyOutput c = cPtr[button]; @@ -190,7 +190,7 @@ bool OSXUchrKeyResource::getDeadKey(KeySequence &keys, UInt16 index) const bool OSXUchrKeyResource::getKeyRecord(KeySequence &keys, UInt16 index, UInt16 &state) const { - const UInt8 *const base = reinterpret_cast(m_resource); + const uint8_t *const base = reinterpret_cast(m_resource); const UCKeyStateRecord *sr = reinterpret_cast(base + m_sri->keyStateRecordOffsets[index]); const UCKeyStateEntryTerminal *kset = reinterpret_cast(sr->stateEntryData); diff --git a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp index f5a7506ab..181f9d66b 100644 --- a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp +++ b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp @@ -37,37 +37,37 @@ public: // BMP is little-endian -static void toLE(UInt8 *&dst, UInt16 src) +static void toLE(uint8_t *&dst, UInt16 src) { - dst[0] = static_cast(src & 0xffu); - dst[1] = static_cast((src >> 8) & 0xffu); + dst[0] = static_cast(src & 0xffu); + dst[1] = static_cast((src >> 8) & 0xffu); dst += 2; } -static void toLE(UInt8 *&dst, SInt32 src) +static void toLE(uint8_t *&dst, SInt32 src) { - dst[0] = static_cast(src & 0xffu); - dst[1] = static_cast((src >> 8) & 0xffu); - dst[2] = static_cast((src >> 16) & 0xffu); - dst[3] = static_cast((src >> 24) & 0xffu); + dst[0] = static_cast(src & 0xffu); + dst[1] = static_cast((src >> 8) & 0xffu); + dst[2] = static_cast((src >> 16) & 0xffu); + dst[3] = static_cast((src >> 24) & 0xffu); dst += 4; } -static void toLE(UInt8 *&dst, UInt32 src) +static void toLE(uint8_t *&dst, UInt32 src) { - dst[0] = static_cast(src & 0xffu); - dst[1] = static_cast((src >> 8) & 0xffu); - dst[2] = static_cast((src >> 16) & 0xffu); - dst[3] = static_cast((src >> 24) & 0xffu); + dst[0] = static_cast(src & 0xffu); + dst[1] = static_cast((src >> 8) & 0xffu); + dst[2] = static_cast((src >> 16) & 0xffu); + dst[3] = static_cast((src >> 24) & 0xffu); dst += 4; } -static inline UInt16 fromLEU16(const UInt8 *data) +static inline UInt16 fromLEU16(const uint8_t *data) { return static_cast(data[0]) | (static_cast(data[1]) << 8); } -static inline SInt32 fromLES32(const UInt8 *data) +static inline SInt32 fromLES32(const uint8_t *data) { return static_cast( static_cast(data[0]) | (static_cast(data[1]) << 8) | (static_cast(data[2]) << 16) | @@ -75,7 +75,7 @@ static inline SInt32 fromLES32(const UInt8 *data) ); } -static inline UInt32 fromLEU32(const UInt8 *data) +static inline UInt32 fromLEU32(const uint8_t *data) { return static_cast(data[0]) | (static_cast(data[1]) << 8) | (static_cast(data[2]) << 16) | (static_cast(data[3]) << 24); @@ -109,7 +109,7 @@ std::string XWindowsClipboardAnyBitmapConverter::fromIClipboard(const std::strin { // fill BMP info header with native-endian data CBMPInfoHeader infoHeader; - const UInt8 *rawBMPInfoHeader = reinterpret_cast(bmp.data()); + const uint8_t *rawBMPInfoHeader = reinterpret_cast(bmp.data()); infoHeader.biSize = fromLEU32(rawBMPInfoHeader + 0); infoHeader.biWidth = fromLES32(rawBMPInfoHeader + 4); infoHeader.biHeight = fromLES32(rawBMPInfoHeader + 8); @@ -129,7 +129,7 @@ std::string XWindowsClipboardAnyBitmapConverter::fromIClipboard(const std::strin } // convert to image format - const UInt8 *rawBMPPixels = rawBMPInfoHeader + 40; + const uint8_t *rawBMPPixels = rawBMPInfoHeader + 40; if (infoHeader.biBitCount == 24) { return doBGRFromIClipboard(rawBMPPixels, infoHeader.biWidth, infoHeader.biHeight); } else { @@ -147,8 +147,8 @@ std::string XWindowsClipboardAnyBitmapConverter::toIClipboard(const std::string } // fill BMP info header with little-endian data - UInt8 infoHeader[40]; - UInt8 *dst = infoHeader; + uint8_t infoHeader[40]; + uint8_t *dst = infoHeader; toLE(dst, static_cast(40)); toLE(dst, static_cast(w)); toLE(dst, static_cast(h)); diff --git a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h index d912254d2..79320e18a 100644 --- a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h +++ b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h @@ -39,13 +39,13 @@ protected: /*! Convert raw BGR pixel data to another image format. */ - virtual std::string doBGRFromIClipboard(const UInt8 *bgrData, UInt32 w, UInt32 h) const = 0; + virtual std::string doBGRFromIClipboard(const uint8_t *bgrData, UInt32 w, UInt32 h) const = 0; //! Convert from IClipboard format /*! Convert raw BGRA pixel data to another image format. */ - virtual std::string doBGRAFromIClipboard(const UInt8 *bgrData, UInt32 w, UInt32 h) const = 0; + virtual std::string doBGRAFromIClipboard(const uint8_t *bgrData, UInt32 w, UInt32 h) const = 0; //! Convert to IClipboard format /*! diff --git a/src/lib/platform/XWindowsClipboardBMPConverter.cpp b/src/lib/platform/XWindowsClipboardBMPConverter.cpp index 4abc4673b..278bfd927 100644 --- a/src/lib/platform/XWindowsClipboardBMPConverter.cpp +++ b/src/lib/platform/XWindowsClipboardBMPConverter.cpp @@ -30,31 +30,31 @@ public: }; // BMP is little-endian -static inline UInt32 fromLEU32(const UInt8 *data) +static inline UInt32 fromLEU32(const uint8_t *data) { return static_cast(data[0]) | (static_cast(data[1]) << 8) | (static_cast(data[2]) << 16) | (static_cast(data[3]) << 24); } -static void toLE(UInt8 *&dst, char src) +static void toLE(uint8_t *&dst, char src) { - dst[0] = static_cast(src); + dst[0] = static_cast(src); dst += 1; } -static void toLE(UInt8 *&dst, UInt16 src) +static void toLE(uint8_t *&dst, UInt16 src) { - dst[0] = static_cast(src & 0xffu); - dst[1] = static_cast((src >> 8) & 0xffu); + dst[0] = static_cast(src & 0xffu); + dst[1] = static_cast((src >> 8) & 0xffu); dst += 2; } -static void toLE(UInt8 *&dst, UInt32 src) +static void toLE(uint8_t *&dst, UInt32 src) { - dst[0] = static_cast(src & 0xffu); - dst[1] = static_cast((src >> 8) & 0xffu); - dst[2] = static_cast((src >> 16) & 0xffu); - dst[3] = static_cast((src >> 24) & 0xffu); + dst[0] = static_cast(src & 0xffu); + dst[1] = static_cast((src >> 8) & 0xffu); + dst[2] = static_cast((src >> 16) & 0xffu); + dst[3] = static_cast((src >> 24) & 0xffu); dst += 4; } @@ -91,8 +91,8 @@ int XWindowsClipboardBMPConverter::getDataSize() const std::string XWindowsClipboardBMPConverter::fromIClipboard(const std::string &bmp) const { // create BMP image - UInt8 header[14]; - UInt8 *dst = header; + uint8_t header[14]; + uint8_t *dst = header; toLE(dst, 'B'); toLE(dst, 'M'); toLE(dst, static_cast(14 + bmp.size())); @@ -110,7 +110,7 @@ std::string XWindowsClipboardBMPConverter::toIClipboard(const std::string &bmp) } // check BMP file header - const UInt8 *rawBMPHeader = reinterpret_cast(bmp.data()); + const uint8_t *rawBMPHeader = reinterpret_cast(bmp.data()); if (rawBMPHeader[0] != 'B' || rawBMPHeader[1] != 'M') { return std::string(); } diff --git a/src/lib/server/BaseClientProxy.h b/src/lib/server/BaseClientProxy.h index 173ac09fa..b89322325 100644 --- a/src/lib/server/BaseClientProxy.h +++ b/src/lib/server/BaseClientProxy.h @@ -88,7 +88,7 @@ public: virtual void resetOptions() = 0; virtual void setOptions(const OptionsList &options) = 0; virtual void sendDragInfo(UInt32 fileCount, const char *info, size_t size) = 0; - virtual void fileChunkSending(UInt8 mark, char *data, size_t dataSize) = 0; + virtual void fileChunkSending(uint8_t mark, char *data, size_t dataSize) = 0; virtual std::string getSecureInputApp() const = 0; virtual void secureInputNotification(const std::string &app) const = 0; virtual std::string getName() const; diff --git a/src/lib/server/ClientProxy.h b/src/lib/server/ClientProxy.h index bcc8706e2..313f3acd2 100644 --- a/src/lib/server/ClientProxy.h +++ b/src/lib/server/ClientProxy.h @@ -86,7 +86,7 @@ public: void resetOptions() override = 0; void setOptions(const OptionsList &options) override = 0; void sendDragInfo(UInt32 fileCount, const char *info, size_t size) override = 0; - void fileChunkSending(UInt8 mark, char *data, size_t dataSize) override = 0; + void fileChunkSending(uint8_t mark, char *data, size_t dataSize) override = 0; void secureInputNotification(const std::string &app) const override = 0; private: diff --git a/src/lib/server/ClientProxy1_0.cpp b/src/lib/server/ClientProxy1_0.cpp index dc7dc8408..7e6841afd 100644 --- a/src/lib/server/ClientProxy1_0.cpp +++ b/src/lib/server/ClientProxy1_0.cpp @@ -129,7 +129,7 @@ void ClientProxy1_0::setHeartbeatRate(double, double alarm) void ClientProxy1_0::handleData(const Event &, void *) { // handle messages until there are no more. first read message code. - UInt8 code[4]; + uint8_t code[4]; UInt32 n = getStream()->read(code, 4); while (n != 0) { // verify we got an entire code @@ -166,7 +166,7 @@ void ClientProxy1_0::handleData(const Event &, void *) resetHeartbeatTimer(); } -bool ClientProxy1_0::parseHandshakeMessage(const UInt8 *code) +bool ClientProxy1_0::parseHandshakeMessage(const uint8_t *code) { if (memcmp(code, kMsgCNoop, 4) == 0) { // discard no-ops @@ -184,7 +184,7 @@ bool ClientProxy1_0::parseHandshakeMessage(const UInt8 *code) return false; } -bool ClientProxy1_0::parseMessage(const UInt8 *code) +bool ClientProxy1_0::parseMessage(const uint8_t *code) { if (memcmp(code, kMsgDInfo, 4) == 0) { if (recvInfo()) { @@ -332,7 +332,7 @@ void ClientProxy1_0::sendDragInfo(UInt32 fileCount, const char *info, size_t siz LOG((CLOG_DEBUG "draggingInfoSending not supported")); } -void ClientProxy1_0::fileChunkSending(UInt8 mark, char *data, size_t dataSize) +void ClientProxy1_0::fileChunkSending(uint8_t mark, char *data, size_t dataSize) { // ignore -- not supported in protocol 1.0 LOG((CLOG_DEBUG "fileChunkSending not supported")); diff --git a/src/lib/server/ClientProxy1_0.h b/src/lib/server/ClientProxy1_0.h index f86e11837..7de891f8c 100644 --- a/src/lib/server/ClientProxy1_0.h +++ b/src/lib/server/ClientProxy1_0.h @@ -61,13 +61,13 @@ public: void resetOptions() override; void setOptions(const OptionsList &options) override; void sendDragInfo(UInt32 fileCount, const char *info, size_t size) override; - void fileChunkSending(UInt8 mark, char *data, size_t dataSize) override; + void fileChunkSending(uint8_t mark, char *data, size_t dataSize) override; std::string getSecureInputApp() const override; void secureInputNotification(const std::string &app) const override; protected: - virtual bool parseHandshakeMessage(const UInt8 *code); - virtual bool parseMessage(const UInt8 *code); + virtual bool parseHandshakeMessage(const uint8_t *code); + virtual bool parseMessage(const uint8_t *code); virtual void resetHeartbeatRate(); virtual void setHeartbeatRate(double rate, double alarm); @@ -103,7 +103,7 @@ protected: ClientClipboard m_clipboard[kClipboardEnd]; private: - typedef bool (ClientProxy1_0::*MessageParser)(const UInt8 *); + typedef bool (ClientProxy1_0::*MessageParser)(const uint8_t *); ClientInfo m_info; double m_heartbeatAlarm; diff --git a/src/lib/server/ClientProxy1_3.cpp b/src/lib/server/ClientProxy1_3.cpp index e8da23bcb..816d3ab36 100644 --- a/src/lib/server/ClientProxy1_3.cpp +++ b/src/lib/server/ClientProxy1_3.cpp @@ -51,7 +51,7 @@ void ClientProxy1_3::mouseWheel(SInt32 xDelta, SInt32 yDelta) ProtocolUtil::writef(getStream(), kMsgDMouseWheel, xDelta, yDelta); } -bool ClientProxy1_3::parseMessage(const UInt8 *code) +bool ClientProxy1_3::parseMessage(const uint8_t *code) { // process message if (memcmp(code, kMsgCKeepAlive, 4) == 0) { diff --git a/src/lib/server/ClientProxy1_3.h b/src/lib/server/ClientProxy1_3.h index cefb1e461..bff39d2b7 100644 --- a/src/lib/server/ClientProxy1_3.h +++ b/src/lib/server/ClientProxy1_3.h @@ -39,7 +39,7 @@ public: protected: // ClientProxy overrides - virtual bool parseMessage(const UInt8 *code); + virtual bool parseMessage(const uint8_t *code); virtual void resetHeartbeatRate(); virtual void setHeartbeatRate(double rate, double alarm); virtual void resetHeartbeatTimer(); diff --git a/src/lib/server/ClientProxy1_5.cpp b/src/lib/server/ClientProxy1_5.cpp index 9bf067982..a7634678b 100644 --- a/src/lib/server/ClientProxy1_5.cpp +++ b/src/lib/server/ClientProxy1_5.cpp @@ -54,12 +54,12 @@ void ClientProxy1_5::sendDragInfo(UInt32 fileCount, const char *info, size_t siz ProtocolUtil::writef(getStream(), kMsgDDragInfo, fileCount, &data); } -void ClientProxy1_5::fileChunkSending(UInt8 mark, char *data, size_t dataSize) +void ClientProxy1_5::fileChunkSending(uint8_t mark, char *data, size_t dataSize) { FileChunk::send(getStream(), mark, data, dataSize); } -bool ClientProxy1_5::parseMessage(const UInt8 *code) +bool ClientProxy1_5::parseMessage(const uint8_t *code) { if (memcmp(code, kMsgDFileTransfer, 4) == 0) { fileChunkReceived(); diff --git a/src/lib/server/ClientProxy1_5.h b/src/lib/server/ClientProxy1_5.h index d7bfd19ff..569c7b8d3 100644 --- a/src/lib/server/ClientProxy1_5.h +++ b/src/lib/server/ClientProxy1_5.h @@ -37,8 +37,8 @@ public: ClientProxy1_5 &operator=(ClientProxy1_5 &&) = delete; virtual void sendDragInfo(UInt32 fileCount, const char *info, size_t size); - virtual void fileChunkSending(UInt8 mark, char *data, size_t dataSize); - virtual bool parseMessage(const UInt8 *code); + virtual void fileChunkSending(uint8_t mark, char *data, size_t dataSize); + virtual bool parseMessage(const uint8_t *code); void fileChunkReceived(); void dragInfoReceived(); diff --git a/src/lib/server/PrimaryClient.cpp b/src/lib/server/PrimaryClient.cpp index 4e3727329..1bc90756d 100644 --- a/src/lib/server/PrimaryClient.cpp +++ b/src/lib/server/PrimaryClient.cpp @@ -223,7 +223,7 @@ void PrimaryClient::sendDragInfo(UInt32 fileCount, const char *info, size_t size // ignore } -void PrimaryClient::fileChunkSending(UInt8 mark, char *data, size_t dataSize) +void PrimaryClient::fileChunkSending(uint8_t mark, char *data, size_t dataSize) { // ignore } diff --git a/src/lib/server/PrimaryClient.h b/src/lib/server/PrimaryClient.h index 10b2406ea..6c4c99ec4 100644 --- a/src/lib/server/PrimaryClient.h +++ b/src/lib/server/PrimaryClient.h @@ -144,7 +144,7 @@ public: void resetOptions() override; void setOptions(const OptionsList &options) override; void sendDragInfo(UInt32 fileCount, const char *info, size_t size) override; - void fileChunkSending(UInt8 mark, char *data, size_t dataSize) override; + void fileChunkSending(uint8_t mark, char *data, size_t dataSize) override; std::string getSecureInputApp() const override; void secureInputNotification(const std::string &app) const override; diff --git a/src/test/integtests/net/NetworkTests.cpp b/src/test/integtests/net/NetworkTests.cpp index a53444ca2..00d0a2e38 100644 --- a/src/test/integtests/net/NetworkTests.cpp +++ b/src/test/integtests/net/NetworkTests.cpp @@ -61,7 +61,7 @@ const size_t kMockFileSize = 1024 * 1024 * 10; // 10MB void getScreenShape(SInt32 &x, SInt32 &y, SInt32 &w, SInt32 &h); void getCursorPos(SInt32 &x, SInt32 &y); -UInt8 *newMockData(size_t size); +uint8_t *newMockData(size_t size); void createFile(fstream &file, const char *filename, size_t size); class NetworkTests : public ::testing::Test { @@ -96,7 +96,7 @@ public: public: TestEventQueue m_events; - UInt8 *m_mockData; + uint8_t *m_mockData; size_t m_mockDataSize; fstream m_mockFile; size_t m_mockFileSize; @@ -473,15 +473,15 @@ void NetworkTests::sendMockData(void *eventTarget) { m_events.forFile().fileChunkSending(), eventTarget, transferFinished)); } -UInt8 *newMockData(size_t size) { - UInt8 *buffer = new UInt8[size]; +uint8_t *newMockData(size_t size) { + uint8_t *buffer = new uint8_t[size]; - UInt8 *data = buffer; - const UInt8 head[] = "mock head... "; + uint8_t *data = buffer; + const uint8_t head[] = "mock head... "; size_t headSize = sizeof(head) - 1; - const UInt8 tail[] = "... mock tail"; + const uint8_t tail[] = "... mock tail"; size_t tailSize = sizeof(tail) - 1; - const UInt8 deskflowRocks[] = "deskflow\0 rocks! "; + const uint8_t deskflowRocks[] = "deskflow\0 rocks! "; size_t deskflowRocksSize = sizeof(deskflowRocks) - 1; memcpy(data, head, headSize); @@ -504,7 +504,7 @@ UInt8 *newMockData(size_t size) { } void createFile(fstream &file, const char *filename, size_t size) { - UInt8 *buffer = newMockData(size); + uint8_t *buffer = newMockData(size); file.open(filename, ios::out | ios::binary); if (!file.is_open()) { diff --git a/src/test/unittests/deskflow/ProtocolUtilTests.cpp b/src/test/unittests/deskflow/ProtocolUtilTests.cpp index 21ead8bac..e826f527a 100644 --- a/src/test/unittests/deskflow/ProtocolUtilTests.cpp +++ b/src/test/unittests/deskflow/ProtocolUtilTests.cpp @@ -38,7 +38,7 @@ ACTION_P2(SetValueToVoidPointerArg0, value, size) MATCHER_P(EqVoidPointeeInt8, expected, "") { - const UInt8 Actual8 = (*static_cast(arg)); + const uint8_t Actual8 = (*static_cast(arg)); return (expected == Actual8); } @@ -57,7 +57,7 @@ MATCHER_P(EqVoidPointeeInt32, expected, "") MATCHER_P(EqVoidVectorInt1byte, expected, "") { bool Result = true; - const UInt8 *Actual = (static_cast(arg)) + 4; + const uint8_t *Actual = (static_cast(arg)) + 4; const size_t Size = *(Actual - 1); if (Size == expected.size()) { @@ -117,7 +117,7 @@ MATCHER_P(EqVoidVectorInt4bytes, expected, "") MATCHER_P(EqVectorSymbols, expected, "") { bool Result = true; - const UInt8 *Actual = (static_cast(arg)); + const uint8_t *Actual = (static_cast(arg)); for (size_t i = 0; i < expected.size(); ++i) { if (expected[i] != (Actual[i])) { @@ -138,7 +138,7 @@ class ProtocolUtilTests : public ::testing::Test { public: MockStream stream; - UInt8 ActualInt8 = 0; + uint8_t ActualInt8 = 0; UInt16 ActualInt16 = 0; UInt32 ActualInt32 = 0; std::string ActualString; @@ -187,9 +187,9 @@ TEST_F(ProtocolUtilTests, readf_params_validation) { } TEST_F(ProtocolUtilTests, readf_string) { - const UInt8 Length = 200; + const uint8_t Length = 200; const std::string Expected(Length, 'x'); - std::array StringSize{{0, 0, 0, Length}}; + std::array StringSize{{0, 0, 0, Length}}; EXPECT_CALL(stream, read(_, _)) .WillOnce( @@ -207,12 +207,12 @@ class ReadfIntTestFixture : public ::testing::TestWithParam> { public: MockStream stream; - UInt8 StreamData1Byte = 10; - std::array StreamData2Bytes{{0, 10}}; - std::array StreamData4Bytes{{0, 0, 0, 10}}; + uint8_t StreamData1Byte = 10; + std::array StreamData2Bytes{{0, 10}}; + std::array StreamData4Bytes{{0, 0, 0, 10}}; - UInt8 *getStreamData(int size) { - UInt8 *StreamData = nullptr; + uint8_t *getStreamData(int size) { + uint8_t *StreamData = nullptr; switch (size) { case 2: StreamData = StreamData2Bytes.data(); @@ -233,7 +233,7 @@ TEST_P(ReadfIntTestFixture, readf_int) { const int Expected = 10; const char *Format = std::get<0>(GetParam()); int StreamDataSize = std::get<1>(GetParam()); - UInt8 *StreamData = getStreamData(StreamDataSize); + uint8_t *StreamData = getStreamData(StreamDataSize); ON_CALL(stream, read(_, _)) .WillByDefault( @@ -252,18 +252,18 @@ INSTANTIATE_TEST_SUITE_P(ReadfIntTests, ReadfIntTestFixture, class ReadfIntVectorTestFixture : public ReadfIntTestFixture {}; TEST_P(ReadfIntVectorTestFixture, readf_int_vector) { - std::vector Actual1Byte = {}; + std::vector Actual1Byte = {}; std::vector Actual2Bytes = {}; std::vector Actual4Bytes = {}; - const std::vector Expected1Byte = {10, 10}; + const std::vector Expected1Byte = {10, 10}; const std::vector Expected2Bytes = {10, 10}; const std::vector Expected4Bytes = {10, 10}; - std::array StreamVectorSize{{0, 0, 0, 2}}; + std::array StreamVectorSize{{0, 0, 0, 2}}; const char *Format = std::get<0>(GetParam()); int StreamDataSize = std::get<1>(GetParam()); - UInt8 *StreamData = getStreamData(StreamDataSize); + uint8_t *StreamData = getStreamData(StreamDataSize); MockStream stream; EXPECT_CALL(stream, read(_, _)) @@ -297,7 +297,7 @@ INSTANTIATE_TEST_SUITE_P(ReadfIntVectorTests, ReadfIntVectorTestFixture, class ReadfIntAndStringTest : public ReadfIntTestFixture { public: - UInt8 ActualInt8 = 0; + uint8_t ActualInt8 = 0; UInt16 ActualInt16 = 0; UInt32 ActualInt32 = 32; std::string ActualString; @@ -305,13 +305,13 @@ public: TEST_P(ReadfIntAndStringTest, readf_int_and_string) { const int ExpectedInt = 10; - const UInt8 StringLength = 200; + const uint8_t StringLength = 200; const std::string ExpectedString(StringLength, 'x'); - std::array StringSize{{0, 0, 0, StringLength}}; + std::array StringSize{{0, 0, 0, StringLength}}; const char *Format = std::get<0>(GetParam()); int StreamDataSize = std::get<1>(GetParam()); - UInt8 *StreamData = getStreamData(StreamDataSize); + uint8_t *StreamData = getStreamData(StreamDataSize); EXPECT_CALL(stream, read(_, _)) .WillOnce(DoAll(SetValueToVoidPointerArg0(StreamData, StreamDataSize), @@ -349,11 +349,11 @@ INSTANTIATE_TEST_SUITE_P(IntAndStringTest, ReadfIntAndStringTest, std::make_tuple("%4i%s", 4))); TEST_F(ProtocolUtilTests, readf_string_and_int4bytes) { - const UInt8 ExpectedInt = 10; - std::array StreamIntData{{0, 0, 0, ExpectedInt}}; + const uint8_t ExpectedInt = 10; + std::array StreamIntData{{0, 0, 0, ExpectedInt}}; const std::string ExpectedStr(32768, 'x'); - std::array Size{{0, 0, 128, 0}}; + std::array Size{{0, 0, 128, 0}}; EXPECT_CALL(stream, read(_, _)) .WillOnce(DoAll(SetValueToVoidPointerArg0(Size.data(), Size.size()), @@ -374,11 +374,11 @@ TEST_F(ProtocolUtilTests, readf_string_and_int4bytes) { TEST_F(ProtocolUtilTests, readf_string_and_vector_int4bytes) { std::vector Actual = {}; const std::vector Expected4Bytes = {10, 10}; - std::array StreamVectorSize{{0, 0, 0, 2}}; - std::array StreamData4Bytes{{0, 0, 0, 10}}; + std::array StreamVectorSize{{0, 0, 0, 2}}; + std::array StreamData4Bytes{{0, 0, 0, 10}}; const std::string ExpString(32768, 'x'); - std::array SizeString{{0, 0, 128, 0}}; + std::array SizeString{{0, 0, 128, 0}}; EXPECT_CALL(stream, read(_, _)) .WillOnce( @@ -402,11 +402,11 @@ TEST_F(ProtocolUtilTests, readf_string_and_vector_int4bytes) { TEST_F(ProtocolUtilTests, readf_vector_int4bytes_and_string) { std::vector Actual4Bytes = {}; const std::vector Expected4Bytes = {10, 10}; - std::array StreamVectorSize{{0, 0, 0, 2}}; - std::array StreamData4Bytes{{0, 0, 0, 10}}; + std::array StreamVectorSize{{0, 0, 0, 2}}; + std::array StreamData4Bytes{{0, 0, 0, 10}}; const std::string ExpectedString(32768, 'x'); - std::array StringSize{{0, 0, 128, 0}}; + std::array StringSize{{0, 0, 128, 0}}; EXPECT_CALL(stream, read(_, _)) .WillOnce(DoAll(SetValueToVoidPointerArg0(StreamVectorSize.data(), @@ -435,7 +435,7 @@ class WriteIntTest : public ::testing::TestWithParam> { public: MockStream stream; - UInt8 Expected1Byte = 5; + uint8_t Expected1Byte = 5; UInt16 Expected2Bytes = 10; UInt32 Expected4Bytes = 15; }; @@ -470,7 +470,7 @@ class WriteIntVectorTest : public ::testing::TestWithParam> { public: MockStream stream; - const std::vector Expected1Byte = {10, 20, 30}; + const std::vector Expected1Byte = {10, 20, 30}; const std::vector Expected2Byte = {40, 50, 60}; const std::vector Expected4Byte = {70, 80, 90}; }; @@ -507,7 +507,7 @@ INSTANTIATE_TEST_SUITE_P(WriteIntVectorTest, WriteIntVectorTest, TEST_F(ProtocolUtilTests, write_string_test) { const std::string Expected = "Expected"; - const std::vector ExpectedVector = {'E', 'x', 'p', 'e', + const std::vector ExpectedVector = {'E', 'x', 'p', 'e', 'c', 't', 'e', 'd'}; EXPECT_CALL(stream, write(EqVoidVectorInt1byte(ExpectedVector), Expected.size() + sizeof(UInt32))); @@ -516,14 +516,14 @@ TEST_F(ProtocolUtilTests, write_string_test) { TEST_F(ProtocolUtilTests, write_raw_bytes_test) { const UInt32 Size = 5; - const std::array Expected{{10, 20, 30, 40, 50}}; + const std::array Expected{{10, 20, 30, 40, 50}}; EXPECT_CALL(stream, write(EqVoidVectorInt1byte(Expected), Expected.size() + sizeof(UInt32))); ProtocolUtil::writef(&stream, "%S", Size, &Expected); } TEST_F(ProtocolUtilTests, write_symbols_from_format_test) { - const std::vector Expected = {'%', '1', '2', '3', '4', '5'}; + const std::vector Expected = {'%', '1', '2', '3', '4', '5'}; EXPECT_CALL(stream, write(EqVectorSymbols(Expected), Expected.size())); ProtocolUtil::writef(&stream, "%%12345"); }