refactor: replace UInt8 with uint8_t

This commit is contained in:
sithlord48
2025-01-10 19:09:43 -05:00
committed by Nick Bolton
parent 8ea20cf6da
commit ba11eba91e
54 changed files with 262 additions and 262 deletions

View File

@ -25,11 +25,11 @@
// local utility functions // local utility functions
// //
inline static UInt16 decode16(const UInt8 *n, bool byteSwapped) inline static UInt16 decode16(const uint8_t *n, bool byteSwapped)
{ {
union x16 union x16
{ {
UInt8 n8[2]; uint8_t n8[2];
UInt16 n16; UInt16 n16;
} c; } c;
if (byteSwapped) { if (byteSwapped) {
@ -42,11 +42,11 @@ inline static UInt16 decode16(const UInt8 *n, bool byteSwapped)
return c.n16; return c.n16;
} }
inline static UInt32 decode32(const UInt8 *n, bool byteSwapped) inline static UInt32 decode32(const uint8_t *n, bool byteSwapped)
{ {
union x32 union x32
{ {
UInt8 n8[4]; uint8_t n8[4];
UInt32 n32; UInt32 n32;
} c; } c;
if (byteSwapped) { if (byteSwapped) {
@ -87,7 +87,7 @@ UInt32 Unicode::s_replacement = 0x0000fffd;
bool Unicode::isUTF8(const std::string &src) bool Unicode::isUTF8(const std::string &src)
{ {
// convert and test each character // convert and test each character
const UInt8 *data = reinterpret_cast<const UInt8 *>(src.c_str()); const uint8_t *data = reinterpret_cast<const uint8_t *>(src.c_str());
for (UInt32 n = (UInt32)src.size(); n > 0;) { for (UInt32 n = (UInt32)src.size(); n > 0;) {
if (fromUTF8(data, n) == s_invalid) { if (fromUTF8(data, n) == s_invalid) {
return false; return false;
@ -107,7 +107,7 @@ std::string Unicode::UTF8ToUCS2(const std::string &src, bool *errors)
dst.reserve(2 * n); dst.reserve(2 * n);
// convert each character // convert each character
const UInt8 *data = reinterpret_cast<const UInt8 *>(src.c_str()); const uint8_t *data = reinterpret_cast<const uint8_t *>(src.c_str());
while (n > 0) { while (n > 0) {
UInt32 c = fromUTF8(data, n); UInt32 c = fromUTF8(data, n);
if (c == s_invalid) { if (c == s_invalid) {
@ -134,7 +134,7 @@ std::string Unicode::UTF8ToUCS4(const std::string &src, bool *errors)
dst.reserve(4 * n); dst.reserve(4 * n);
// convert each character // convert each character
const UInt8 *data = reinterpret_cast<const UInt8 *>(src.c_str()); const uint8_t *data = reinterpret_cast<const uint8_t *>(src.c_str());
while (n > 0) { while (n > 0) {
UInt32 c = fromUTF8(data, n); UInt32 c = fromUTF8(data, n);
if (c == s_invalid) { if (c == s_invalid) {
@ -157,7 +157,7 @@ std::string Unicode::UTF8ToUTF16(const std::string &src, bool *errors)
dst.reserve(2 * n); dst.reserve(2 * n);
// convert each character // convert each character
const UInt8 *data = reinterpret_cast<const UInt8 *>(src.c_str()); const uint8_t *data = reinterpret_cast<const uint8_t *>(src.c_str());
while (n > 0) { while (n > 0) {
UInt32 c = fromUTF8(data, n); UInt32 c = fromUTF8(data, n);
if (c == s_invalid) { if (c == s_invalid) {
@ -192,7 +192,7 @@ std::string Unicode::UTF8ToUTF32(const std::string &src, bool *errors)
dst.reserve(4 * n); dst.reserve(4 * n);
// convert each character // convert each character
const UInt8 *data = reinterpret_cast<const UInt8 *>(src.c_str()); const uint8_t *data = reinterpret_cast<const uint8_t *>(src.c_str());
while (n > 0) { while (n > 0) {
UInt32 c = fromUTF8(data, n); UInt32 c = fromUTF8(data, n);
if (c == s_invalid) { if (c == s_invalid) {
@ -236,7 +236,7 @@ std::string Unicode::UCS2ToUTF8(const std::string &src, bool *errors)
// convert // convert
UInt32 n = (UInt32)src.size() >> 1; UInt32 n = (UInt32)src.size() >> 1;
return doUCS2ToUTF8(reinterpret_cast<const UInt8 *>(src.data()), n, errors); return doUCS2ToUTF8(reinterpret_cast<const uint8_t *>(src.data()), n, errors);
} }
std::string Unicode::UCS4ToUTF8(const std::string &src, bool *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 // convert
UInt32 n = (UInt32)src.size() >> 2; UInt32 n = (UInt32)src.size() >> 2;
return doUCS4ToUTF8(reinterpret_cast<const UInt8 *>(src.data()), n, errors); return doUCS4ToUTF8(reinterpret_cast<const uint8_t *>(src.data()), n, errors);
} }
std::string Unicode::UTF16ToUTF8(const std::string &src, bool *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 // convert
UInt32 n = (UInt32)src.size() >> 1; UInt32 n = (UInt32)src.size() >> 1;
return doUTF16ToUTF8(reinterpret_cast<const UInt8 *>(src.data()), n, errors); return doUTF16ToUTF8(reinterpret_cast<const uint8_t *>(src.data()), n, errors);
} }
std::string Unicode::UTF32ToUTF8(const std::string &src, bool *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 // convert
UInt32 n = (UInt32)src.size() >> 2; UInt32 n = (UInt32)src.size() >> 2;
return doUTF32ToUTF8(reinterpret_cast<const UInt8 *>(src.data()), n, errors); return doUTF32ToUTF8(reinterpret_cast<const uint8_t *>(src.data()), n, errors);
} }
std::string Unicode::textToUTF8(const std::string &src, bool *errors, IArchString::EWideCharEncoding encoding) 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). // the String's nul character).
switch (encoding) { switch (encoding) {
case IArchString::kUCS2: case IArchString::kUCS2:
return doUCS2ToUTF8(reinterpret_cast<const UInt8 *>(src), size, errors); return doUCS2ToUTF8(reinterpret_cast<const uint8_t *>(src), size, errors);
case IArchString::kUCS4: case IArchString::kUCS4:
return doUCS4ToUTF8(reinterpret_cast<const UInt8 *>(src), size, errors); return doUCS4ToUTF8(reinterpret_cast<const uint8_t *>(src), size, errors);
case IArchString::kUTF16: case IArchString::kUTF16:
return doUTF16ToUTF8(reinterpret_cast<const UInt8 *>(src), size, errors); return doUTF16ToUTF8(reinterpret_cast<const uint8_t *>(src), size, errors);
case IArchString::kUTF32: case IArchString::kUTF32:
return doUTF32ToUTF8(reinterpret_cast<const UInt8 *>(src), size, errors); return doUTF32ToUTF8(reinterpret_cast<const uint8_t *>(src), size, errors);
default: default:
assert(0 && "unknown wide character encoding"); 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 // make some space
std::string dst; std::string dst;
@ -388,7 +388,7 @@ std::string Unicode::doUCS2ToUTF8(const UInt8 *data, UInt32 n, bool *errors)
return dst; 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 // make some space
std::string dst; std::string dst;
@ -424,7 +424,7 @@ std::string Unicode::doUCS4ToUTF8(const UInt8 *data, UInt32 n, bool *errors)
return dst; 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 // make some space
std::string dst; std::string dst;
@ -483,7 +483,7 @@ std::string Unicode::doUTF16ToUTF8(const UInt8 *data, UInt32 n, bool *errors)
return dst; 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 // make some space
std::string dst; std::string dst;
@ -523,7 +523,7 @@ std::string Unicode::doUTF32ToUTF8(const UInt8 *data, UInt32 n, bool *errors)
return dst; return dst;
} }
UInt32 Unicode::fromUTF8(const UInt8 *&data, UInt32 &n) UInt32 Unicode::fromUTF8(const uint8_t *&data, UInt32 &n)
{ {
assert(data != NULL); assert(data != NULL);
assert(n != 0); 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) void Unicode::toUTF8(std::string &dst, UInt32 c, bool *errors)
{ {
UInt8 data[6]; uint8_t data[6];
// handle characters outside the valid range // handle characters outside the valid range
if ((c >= 0x0000d800 && c <= 0x0000dfff) || c >= 0x80000000) { 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 // convert to UTF-8
if (c < 0x00000080) { if (c < 0x00000080) {
data[0] = static_cast<UInt8>(c); data[0] = static_cast<uint8_t>(c);
dst.append(reinterpret_cast<char *>(data), 1); dst.append(reinterpret_cast<char *>(data), 1);
} else if (c < 0x00000800) { } else if (c < 0x00000800) {
data[0] = static_cast<UInt8>(((c >> 6) & 0x0000001f) + 0xc0); data[0] = static_cast<uint8_t>(((c >> 6) & 0x0000001f) + 0xc0);
data[1] = static_cast<UInt8>((c & 0x0000003f) + 0x80); data[1] = static_cast<uint8_t>((c & 0x0000003f) + 0x80);
dst.append(reinterpret_cast<char *>(data), 2); dst.append(reinterpret_cast<char *>(data), 2);
} else if (c < 0x00010000) { } else if (c < 0x00010000) {
data[0] = static_cast<UInt8>(((c >> 12) & 0x0000000f) + 0xe0); data[0] = static_cast<uint8_t>(((c >> 12) & 0x0000000f) + 0xe0);
data[1] = static_cast<UInt8>(((c >> 6) & 0x0000003f) + 0x80); data[1] = static_cast<uint8_t>(((c >> 6) & 0x0000003f) + 0x80);
data[2] = static_cast<UInt8>((c & 0x0000003f) + 0x80); data[2] = static_cast<uint8_t>((c & 0x0000003f) + 0x80);
dst.append(reinterpret_cast<char *>(data), 3); dst.append(reinterpret_cast<char *>(data), 3);
} else if (c < 0x00200000) { } else if (c < 0x00200000) {
data[0] = static_cast<UInt8>(((c >> 18) & 0x00000007) + 0xf0); data[0] = static_cast<uint8_t>(((c >> 18) & 0x00000007) + 0xf0);
data[1] = static_cast<UInt8>(((c >> 12) & 0x0000003f) + 0x80); data[1] = static_cast<uint8_t>(((c >> 12) & 0x0000003f) + 0x80);
data[2] = static_cast<UInt8>(((c >> 6) & 0x0000003f) + 0x80); data[2] = static_cast<uint8_t>(((c >> 6) & 0x0000003f) + 0x80);
data[3] = static_cast<UInt8>((c & 0x0000003f) + 0x80); data[3] = static_cast<uint8_t>((c & 0x0000003f) + 0x80);
dst.append(reinterpret_cast<char *>(data), 4); dst.append(reinterpret_cast<char *>(data), 4);
} else if (c < 0x04000000) { } else if (c < 0x04000000) {
data[0] = static_cast<UInt8>(((c >> 24) & 0x00000003) + 0xf8); data[0] = static_cast<uint8_t>(((c >> 24) & 0x00000003) + 0xf8);
data[1] = static_cast<UInt8>(((c >> 18) & 0x0000003f) + 0x80); data[1] = static_cast<uint8_t>(((c >> 18) & 0x0000003f) + 0x80);
data[2] = static_cast<UInt8>(((c >> 12) & 0x0000003f) + 0x80); data[2] = static_cast<uint8_t>(((c >> 12) & 0x0000003f) + 0x80);
data[3] = static_cast<UInt8>(((c >> 6) & 0x0000003f) + 0x80); data[3] = static_cast<uint8_t>(((c >> 6) & 0x0000003f) + 0x80);
data[4] = static_cast<UInt8>((c & 0x0000003f) + 0x80); data[4] = static_cast<uint8_t>((c & 0x0000003f) + 0x80);
dst.append(reinterpret_cast<char *>(data), 5); dst.append(reinterpret_cast<char *>(data), 5);
} else if (c < 0x80000000) { } else if (c < 0x80000000) {
data[0] = static_cast<UInt8>(((c >> 30) & 0x00000001) + 0xfc); data[0] = static_cast<uint8_t>(((c >> 30) & 0x00000001) + 0xfc);
data[1] = static_cast<UInt8>(((c >> 24) & 0x0000003f) + 0x80); data[1] = static_cast<uint8_t>(((c >> 24) & 0x0000003f) + 0x80);
data[2] = static_cast<UInt8>(((c >> 18) & 0x0000003f) + 0x80); data[2] = static_cast<uint8_t>(((c >> 18) & 0x0000003f) + 0x80);
data[3] = static_cast<UInt8>(((c >> 12) & 0x0000003f) + 0x80); data[3] = static_cast<uint8_t>(((c >> 12) & 0x0000003f) + 0x80);
data[4] = static_cast<UInt8>(((c >> 6) & 0x0000003f) + 0x80); data[4] = static_cast<uint8_t>(((c >> 6) & 0x0000003f) + 0x80);
data[5] = static_cast<UInt8>((c & 0x0000003f) + 0x80); data[5] = static_cast<uint8_t>((c & 0x0000003f) + 0x80);
dst.append(reinterpret_cast<char *>(data), 6); dst.append(reinterpret_cast<char *>(data), 6);
} else { } else {
assert(0 && "character out of range"); assert(0 && "character out of range");

View File

@ -135,13 +135,13 @@ private:
); );
// internal conversion to UTF8 // internal conversion to UTF8
static std::string doUCS2ToUTF8(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 *src, UInt32 n, bool *errors); static std::string doUCS4ToUTF8(const uint8_t *src, UInt32 n, bool *errors);
static std::string doUTF16ToUTF8(const UInt8 *src, UInt32 n, bool *errors); static std::string doUTF16ToUTF8(const uint8_t *src, UInt32 n, bool *errors);
static std::string doUTF32ToUTF8(const UInt8 *src, UInt32 n, bool *errors); static std::string doUTF32ToUTF8(const uint8_t *src, UInt32 n, bool *errors);
// convert characters to/from UTF8 // 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); static void toUTF8(std::string &dst, UInt32 c, bool *errors);
private: private:

View File

@ -110,7 +110,7 @@ void ServerProxy::setKeepAliveRate(double rate)
void ServerProxy::handleData(const Event &, void *) void ServerProxy::handleData(const Event &, void *)
{ {
// handle messages until there are no more. first read message code. // 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); UInt32 n = m_stream->read(code, 4);
while (n != 0) { while (n != 0) {
// verify we got an entire code // verify we got an entire code
@ -152,7 +152,7 @@ void ServerProxy::handleData(const Event &, void *)
flushCompressedMouse(); flushCompressedMouse();
} }
ServerProxy::EResult ServerProxy::parseHandshakeMessage(const UInt8 *code) ServerProxy::EResult ServerProxy::parseHandshakeMessage(const uint8_t *code)
{ {
if (memcmp(code, kMsgQInfo, 4) == 0) { if (memcmp(code, kMsgQInfo, 4) == 0) {
queryInfo(); queryInfo();
@ -225,7 +225,7 @@ ServerProxy::EResult ServerProxy::parseHandshakeMessage(const UInt8 *code)
return kOkay; return kOkay;
} }
ServerProxy::EResult ServerProxy::parseMessage(const UInt8 *code) ServerProxy::EResult ServerProxy::parseMessage(const uint8_t *code)
{ {
if (memcmp(code, kMsgDMouseMove, 4) == 0) { if (memcmp(code, kMsgDMouseMove, 4) == 0) {
mouseMove(); mouseMove();
@ -857,7 +857,7 @@ void ServerProxy::handleClipboardSendingEvent(const Event &event, void *)
ClipboardChunk::send(m_stream, event.getDataObject()); 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); FileChunk::send(m_stream, mark, data, dataSize);
} }

View File

@ -63,7 +63,7 @@ public:
//@} //@}
// sending file chunk to server // 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 // sending dragging information to server
void sendDragInfo(UInt32 fileCount, const char *info, size_t size); void sendDragInfo(UInt32 fileCount, const char *info, size_t size);
@ -82,8 +82,8 @@ protected:
kUnknown, kUnknown,
kDisconnect kDisconnect
}; };
EResult parseHandshakeMessage(const UInt8 *code); EResult parseHandshakeMessage(const uint8_t *code);
EResult parseMessage(const UInt8 *code); EResult parseMessage(const uint8_t *code);
private: private:
// if compressing mouse motion then send the last motion now // if compressing mouse motion then send the last motion now
@ -129,7 +129,7 @@ private:
void checkMissedLanguages() const; void checkMissedLanguages() const;
private: private:
typedef EResult (ServerProxy::*MessageParser)(const UInt8 *); typedef EResult (ServerProxy::*MessageParser)(const uint8_t *);
Client *m_client; Client *m_client;
deskflow::IStream *m_stream; deskflow::IStream *m_stream;

View File

@ -86,7 +86,6 @@
#else #else
using SInt16 = signed TYPE_OF_SIZE_2; using SInt16 = signed TYPE_OF_SIZE_2;
using SInt32 = signed TYPE_OF_SIZE_4; using SInt32 = signed TYPE_OF_SIZE_4;
using UInt8 = unsigned TYPE_OF_SIZE_1;
using UInt16 = unsigned TYPE_OF_SIZE_2; using UInt16 = unsigned TYPE_OF_SIZE_2;
using UInt32 = unsigned TYPE_OF_SIZE_4; using UInt32 = unsigned TYPE_OF_SIZE_4;
#endif #endif

View File

@ -32,6 +32,7 @@
// make assert available since we use it a lot // make assert available since we use it a lot
#include <assert.h> #include <assert.h>
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@ -19,7 +19,7 @@
#include "basic_types.h" #include "basic_types.h"
enum class IpcMessageType : UInt8 enum class IpcMessageType : uint8_t
{ {
Hello, Hello,
HelloBack, HelloBack,

View File

@ -76,7 +76,7 @@ ClipboardChunk *ClipboardChunk::end(ClipboardID id, UInt32 sequence)
int ClipboardChunk::assemble(deskflow::IStream *stream, std::string &dataCached, 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; std::string data;
if (!ProtocolUtil::readf(stream, kMsgDClipboard + 4, &id, &sequence, &mark, &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]; ClipboardID id = chunk[0];
UInt32 sequence; UInt32 sequence;
std::memcpy(&sequence, &chunk[1], 4); std::memcpy(&sequence, &chunk[1], 4);
UInt8 mark = chunk[5]; uint8_t mark = chunk[5];
std::string dataChunk(&chunk[6], clipboardData->m_dataSize); std::string dataChunk(&chunk[6], clipboardData->m_dataSize);
switch (mark) { switch (mark) {

View File

@ -43,7 +43,7 @@ FileChunk *FileChunk::start(const std::string &size)
return start; 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); FileChunk *chunk = new FileChunk(dataSize + FILE_CHUNK_META_SIZE);
char *chunkData = chunk->m_chunk; char *chunkData = chunk->m_chunk;
@ -67,7 +67,7 @@ FileChunk *FileChunk::end()
int FileChunk::assemble(deskflow::IStream *stream, std::string &dataReceived, size_t &expectedSize) int FileChunk::assemble(deskflow::IStream *stream, std::string &dataReceived, size_t &expectedSize)
{ {
// parse // parse
UInt8 mark = 0; uint8_t mark = 0;
std::string content; std::string content;
static size_t receivedDataSize; static size_t receivedDataSize;
static double elapsedTime; static double elapsedTime;
@ -129,7 +129,7 @@ int FileChunk::assemble(deskflow::IStream *stream, std::string &dataReceived, si
return kError; 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); std::string chunk(data, dataSize);

View File

@ -34,8 +34,8 @@ public:
FileChunk(size_t size); FileChunk(size_t size);
static FileChunk *start(const std::string &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 FileChunk *end();
static int assemble(deskflow::IStream *stream, std::string &dataCached, size_t &expectedSize); 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);
}; };

View File

@ -150,8 +150,8 @@ UInt32 IClipboard::readUInt32(const char *buf)
void IClipboard::writeUInt32(std::string *buf, UInt32 v) void IClipboard::writeUInt32(std::string *buf, UInt32 v)
{ {
*buf += static_cast<UInt8>((v >> 24) & 0xff); *buf += static_cast<uint8_t>((v >> 24) & 0xff);
*buf += static_cast<UInt8>((v >> 16) & 0xff); *buf += static_cast<uint8_t>((v >> 16) & 0xff);
*buf += static_cast<UInt8>((v >> 8) & 0xff); *buf += static_cast<uint8_t>((v >> 8) & 0xff);
*buf += static_cast<UInt8>(v & 0xff); *buf += static_cast<uint8_t>(v & 0xff);
} }

View File

@ -90,11 +90,11 @@ UInt32 PacketStreamFilter::read(void *buffer, UInt32 n)
void PacketStreamFilter::write(const void *buffer, UInt32 count) void PacketStreamFilter::write(const void *buffer, UInt32 count)
{ {
// write the length of the payload // write the length of the payload
UInt8 length[4]; uint8_t length[4];
length[0] = (UInt8)((count >> 24) & 0xff); length[0] = (uint8_t)((count >> 24) & 0xff);
length[1] = (UInt8)((count >> 16) & 0xff); length[1] = (uint8_t)((count >> 16) & 0xff);
length[2] = (UInt8)((count >> 8) & 0xff); length[2] = (uint8_t)((count >> 8) & 0xff);
length[3] = (UInt8)(count & 0xff); length[3] = (uint8_t)(count & 0xff);
getStream()->write(length, sizeof(length)); getStream()->write(length, sizeof(length));
// write the payload // write the payload
@ -131,7 +131,7 @@ bool PacketStreamFilter::readPacketSize()
// note -- m_mutex must be locked on entry // note -- m_mutex must be locked on entry
if (m_size == 0 && m_buffer.getSize() >= 4) { if (m_size == 0 && m_buffer.getSize() >= 4) {
UInt8 buffer[4]; uint8_t buffer[4];
memcpy(buffer, m_buffer.peek(sizeof(buffer)), sizeof(buffer)); memcpy(buffer, m_buffer.peek(sizeof(buffer)), sizeof(buffer));
m_buffer.pop(sizeof(buffer)); m_buffer.pop(sizeof(buffer));
m_size = ((UInt32)buffer[0] << 24) | ((UInt32)buffer[1] << 16) | ((UInt32)buffer[2] << 8) | (UInt32)buffer[3]; m_size = ((UInt32)buffer[0] << 24) | ((UInt32)buffer[1] << 16) | ((UInt32)buffer[2] << 8) | (UInt32)buffer[3];

View File

@ -34,21 +34,21 @@
namespace { namespace {
void writeInt(UInt32 Value, UInt32 Length, std::vector<UInt8> &Buffer) void writeInt(UInt32 Value, UInt32 Length, std::vector<uint8_t> &Buffer)
{ {
switch (Length) { switch (Length) {
case 1: case 1:
Buffer.push_back(static_cast<UInt8>(Value & 0xffU)); Buffer.push_back(static_cast<uint8_t>(Value & 0xffU));
break; break;
case 4: case 4:
Buffer.push_back(static_cast<UInt8>((Value >> 24U) & 0xffU)); Buffer.push_back(static_cast<uint8_t>((Value >> 24U) & 0xffU));
Buffer.push_back(static_cast<UInt8>((Value >> 16U) & 0xffU)); Buffer.push_back(static_cast<uint8_t>((Value >> 16U) & 0xffU));
Buffer.push_back(static_cast<UInt8>((Value >> 8U) & 0xffU)); Buffer.push_back(static_cast<uint8_t>((Value >> 8U) & 0xffU));
Buffer.push_back(static_cast<UInt8>(Value & 0xffU)); Buffer.push_back(static_cast<uint8_t>(Value & 0xffU));
break; break;
case 2: case 2:
Buffer.push_back(static_cast<UInt8>((Value >> 8U) & 0xffU)); Buffer.push_back(static_cast<uint8_t>((Value >> 8U) & 0xffU));
Buffer.push_back(static_cast<UInt8>(Value & 0xffU)); Buffer.push_back(static_cast<uint8_t>(Value & 0xffU));
break; break;
default: default:
assert(0 && "invalid integer format length"); assert(0 && "invalid integer format length");
@ -56,7 +56,7 @@ void writeInt(UInt32 Value, UInt32 Length, std::vector<UInt8> &Buffer)
} }
} }
template <typename T> void writeVectorInt(const std::vector<T> *VectorData, std::vector<UInt8> &Buffer) template <typename T> void writeVectorInt(const std::vector<T> *VectorData, std::vector<uint8_t> &Buffer)
{ {
if (VectorData) { if (VectorData) {
const std::vector<T> &Vector = *VectorData; const std::vector<T> &Vector = *VectorData;
@ -67,7 +67,7 @@ template <typename T> void writeVectorInt(const std::vector<T> *VectorData, std:
} }
} }
void writeString(const std::string *StringData, std::vector<UInt8> &Buffer) void writeString(const std::string *StringData, std::vector<uint8_t> &Buffer)
{ {
const UInt32 len = (StringData != NULL) ? (UInt32)StringData->size() : 0; const UInt32 len = (StringData != NULL) ? (UInt32)StringData->size() : 0;
writeInt(len, sizeof(len), Buffer); writeInt(len, sizeof(len), Buffer);
@ -126,7 +126,7 @@ void ProtocolUtil::vwritef(deskflow::IStream *stream, const char *fmt, UInt32 si
} }
// fill buffer // fill buffer
std::vector<UInt8> Buffer; std::vector<uint8_t> Buffer;
writef(Buffer, fmt, args); writef(Buffer, fmt, args);
try { try {
@ -156,7 +156,7 @@ void ProtocolUtil::vreadf(deskflow::IStream *stream, const char *fmt, va_list ar
switch (len) { switch (len) {
case 1: case 1:
// 1 byte integer // 1 byte integer
*static_cast<UInt8 *>(destination) = read1ByteInt(stream); *static_cast<uint8_t *>(destination) = read1ByteInt(stream);
break; break;
case 2: case 2:
// 2 byte integer // 2 byte integer
@ -180,7 +180,7 @@ void ProtocolUtil::vreadf(deskflow::IStream *stream, const char *fmt, va_list ar
switch (len) { switch (len) {
case 1: case 1:
// 1 byte integer // 1 byte integer
readVector1ByteInt(stream, *static_cast<std::vector<UInt8> *>(destination)); readVector1ByteInt(stream, *static_cast<std::vector<uint8_t> *>(destination));
break; break;
case 2: case 2:
// 2 byte integer // 2 byte integer
@ -256,7 +256,7 @@ UInt32 ProtocolUtil::getLength(const char *fmt, va_list args)
assert(len == 1 || len == 2 || len == 4); assert(len == 1 || len == 2 || len == 4);
switch (len) { switch (len) {
case 1: case 1:
len = (UInt32)(va_arg(args, std::vector<UInt8> *))->size() + 4; len = (UInt32)(va_arg(args, std::vector<uint8_t> *))->size() + 4;
break; break;
case 2: case 2:
@ -300,7 +300,7 @@ UInt32 ProtocolUtil::getLength(const char *fmt, va_list args)
return n; return n;
} }
void ProtocolUtil::writef(std::vector<UInt8> &buffer, const char *fmt, va_list args) void ProtocolUtil::writef(std::vector<uint8_t> &buffer, const char *fmt, va_list args)
{ {
while (*fmt) { while (*fmt) {
if (*fmt == '%') { if (*fmt == '%') {
@ -318,7 +318,7 @@ void ProtocolUtil::writef(std::vector<UInt8> &buffer, const char *fmt, va_list a
switch (len) { switch (len) {
case 1: { case 1: {
// 1 byte integers // 1 byte integers
const std::vector<UInt8> *list = va_arg(args, const std::vector<UInt8> *); const std::vector<uint8_t> *list = va_arg(args, const std::vector<uint8_t> *);
writeVectorInt(list, buffer); writeVectorInt(list, buffer);
break; break;
} }
@ -354,7 +354,7 @@ void ProtocolUtil::writef(std::vector<UInt8> &buffer, const char *fmt, va_list a
case 'S': { case 'S': {
assert(len == 0); assert(len == 0);
const UInt32 len = va_arg(args, UInt32); 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); writeInt(len, sizeof(len), buffer);
std::copy(src, src + len, std::back_inserter(buffer)); std::copy(src, src + len, std::back_inserter(buffer));
break; break;
@ -429,7 +429,7 @@ void ProtocolUtil::read(deskflow::IStream *stream, void *vbuffer, UInt32 count)
assert(stream != NULL); assert(stream != NULL);
assert(vbuffer != NULL); assert(vbuffer != NULL);
UInt8 *buffer = static_cast<UInt8 *>(vbuffer); uint8_t *buffer = static_cast<uint8_t *>(vbuffer);
while (count > 0) { while (count > 0) {
// read more // read more
UInt32 n = stream->read(buffer, count); 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; const UInt32 BufferSize = 1;
std::array<UInt8, 1> buffer = {}; std::array<uint8_t, 1> buffer = {};
read(stream, buffer.data(), BufferSize); 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)); LOG((CLOG_DEBUG2 "readf: read 1 byte integer: %d (0x%x)", Result, Result));
return Result; return Result;
@ -461,7 +461,7 @@ UInt8 ProtocolUtil::read1ByteInt(deskflow::IStream *stream)
UInt16 ProtocolUtil::read2BytesInt(deskflow::IStream *stream) UInt16 ProtocolUtil::read2BytesInt(deskflow::IStream *stream)
{ {
const UInt32 BufferSize = 2; const UInt32 BufferSize = 2;
std::array<UInt8, BufferSize> buffer = {}; std::array<uint8_t, BufferSize> buffer = {};
read(stream, buffer.data(), BufferSize); read(stream, buffer.data(), BufferSize);
UInt16 Result = static_cast<UInt16>((static_cast<UInt16>(buffer[0]) << 8) | static_cast<UInt16>(buffer[1])); UInt16 Result = static_cast<UInt16>((static_cast<UInt16>(buffer[0]) << 8) | static_cast<UInt16>(buffer[1]));
@ -473,7 +473,7 @@ UInt16 ProtocolUtil::read2BytesInt(deskflow::IStream *stream)
UInt32 ProtocolUtil::read4BytesInt(deskflow::IStream *stream) UInt32 ProtocolUtil::read4BytesInt(deskflow::IStream *stream)
{ {
const int BufferSize = 4; const int BufferSize = 4;
std::array<UInt8, BufferSize> buffer = {}; std::array<uint8_t, BufferSize> buffer = {};
read(stream, buffer.data(), BufferSize); read(stream, buffer.data(), BufferSize);
UInt32 Result = (static_cast<UInt32>(buffer[0]) << 24) | (static_cast<UInt32>(buffer[1]) << 16) | UInt32 Result = (static_cast<UInt32>(buffer[0]) << 24) | (static_cast<UInt32>(buffer[1]) << 16) |
@ -484,7 +484,7 @@ UInt32 ProtocolUtil::read4BytesInt(deskflow::IStream *stream)
return Result; return Result;
} }
void ProtocolUtil::readVector1ByteInt(deskflow::IStream *stream, std::vector<UInt8> &destination) void ProtocolUtil::readVector1ByteInt(deskflow::IStream *stream, std::vector<uint8_t> &destination)
{ {
UInt32 size = readVectorSize(stream); UInt32 size = readVectorSize(stream);
for (UInt32 i = 0; i < size; ++i) { 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) void ProtocolUtil::readBytes(deskflow::IStream *stream, UInt32 len, std::string *destination)
{ {
// read the string length // 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 // when string length is 0, this implies that the size of the string is
// variable and will be embedded in the stream. // 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)); const bool useFixed = (len <= sizeof(buffer));
// allocate a buffer to read the data // allocate a buffer to read the data
UInt8 *sBuffer = buffer; uint8_t *sBuffer = buffer;
if (!useFixed) { if (!useFixed) {
try { try {
sBuffer = new UInt8[len]; sBuffer = new uint8_t[len];
} catch (std::bad_alloc &exception) { } catch (std::bad_alloc &exception) {
// Added try catch due to GHSA-chfm-333q-gfpp // Added try catch due to GHSA-chfm-333q-gfpp
LOG((CLOG_ERR "bad alloc, unable to allocate memory %d bytes", len)); LOG((CLOG_ERR "bad alloc, unable to allocate memory %d bytes", len));

View File

@ -48,11 +48,11 @@ public:
- \%1i -- converts integer argument to 1 byte integer - \%1i -- converts integer argument to 1 byte integer
- \%2i -- converts integer argument to 2 byte integer in NBO - \%2i -- converts integer argument to 2 byte integer in NBO
- \%4i -- converts integer argument to 4 byte integer in NBO - \%4i -- converts integer argument to 4 byte integer in NBO
- \%1I -- converts std::vector<UInt8>* to 1 byte integers - \%1I -- converts std::vector<uint8_t>* to 1 byte integers
- \%2I -- converts std::vector<UInt16>* to 2 byte integers in NBO - \%2I -- converts std::vector<UInt16>* to 2 byte integers in NBO
- \%4I -- converts std::vector<UInt32>* to 4 byte integers in NBO - \%4I -- converts std::vector<UInt32>* to 4 byte integers in NBO
- \%s -- converts std::string* to stream of bytes - \%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, ...); 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* - \%1i -- reads a 1 byte integer; argument is a SInt32* or UInt32*
- \%2i -- reads an NBO 2 byte integer; arg is 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* - \%4i -- reads an NBO 4 byte integer; arg is SInt32* or UInt32*
- \%1I -- reads 1 byte integers; arg is std::vector<UInt8>* - \%1I -- reads 1 byte integers; arg is std::vector<uint8_t>*
- \%2I -- reads NBO 2 byte integers; arg is std::vector<UInt16>* - \%2I -- reads NBO 2 byte integers; arg is std::vector<UInt16>*
- \%4I -- reads NBO 4 byte integers; arg is std::vector<UInt32>* - \%4I -- reads NBO 4 byte integers; arg is std::vector<UInt32>*
- \%s -- reads bytes; argument must be a std::string*, \b not a char* - \%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 void vreadf(deskflow::IStream *, const char *fmt, va_list);
static UInt32 getLength(const char *fmt, va_list); static UInt32 getLength(const char *fmt, va_list);
static void writef(std::vector<UInt8> &, const char *fmt, va_list); static void writef(std::vector<uint8_t> &, const char *fmt, va_list);
static UInt32 eatLength(const char **fmt); static UInt32 eatLength(const char **fmt);
static void read(deskflow::IStream *, void *, UInt32); static void read(deskflow::IStream *, void *, UInt32);
/** /**
* @brief Handles 1,2, or 4 byte Integers * @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 UInt16 read2BytesInt(deskflow::IStream *stream);
static UInt32 read4BytesInt(deskflow::IStream *stream); static UInt32 read4BytesInt(deskflow::IStream *stream);
/** /**
* @brief Handles a Vector of integers * @brief Handles a Vector of integers
*/ */
static void readVector1ByteInt(deskflow::IStream *, std::vector<UInt8> &); static void readVector1ByteInt(deskflow::IStream *, std::vector<uint8_t> &);
static void readVector2BytesInt(deskflow::IStream *, std::vector<UInt16> &); static void readVector2BytesInt(deskflow::IStream *, std::vector<UInt16> &);
static void readVector4BytesInt(deskflow::IStream *, std::vector<UInt32> &); static void readVector4BytesInt(deskflow::IStream *, std::vector<UInt32> &);
static UInt32 readVectorSize(deskflow::IStream *stream); static UInt32 readVectorSize(deskflow::IStream *stream);

View File

@ -81,7 +81,7 @@ void StreamChunker::sendFile(char *filename, IEventQueue *events, void *eventTar
char *chunkData = new char[chunkSize]; char *chunkData = new char[chunkSize];
file.read(chunkData, chunkSize); file.read(chunkData, chunkSize);
UInt8 *data = reinterpret_cast<UInt8 *>(chunkData); uint8_t *data = reinterpret_cast<uint8_t *>(chunkData);
FileChunk *fileChunk = FileChunk::data(data, chunkSize); FileChunk *fileChunk = FileChunk::data(data, chunkSize);
delete[] chunkData; delete[] chunkData;

View File

@ -24,7 +24,7 @@
/*! /*!
Type to hold a clipboard identifier. Type to hold a clipboard identifier.
*/ */
using ClipboardID = UInt8; using ClipboardID = uint8_t;
//! @name Clipboard identifiers //! @name Clipboard identifiers
//@{ //@{

View File

@ -24,7 +24,7 @@
/*! /*!
Type to hold a mouse button identifier. Type to hold a mouse button identifier.
*/ */
using ButtonID = UInt8; using ButtonID = uint8_t;
//! @name Mouse button identifiers //! @name Mouse button identifiers
//@{ //@{
@ -39,4 +39,4 @@ static const ButtonID kMacButtonRight = 2;
static const ButtonID kMacButtonMiddle = 3; static const ButtonID kMacButtonMiddle = 3;
//@} //@}
static const UInt8 NumButtonIDs = 5; static const uint8_t NumButtonIDs = 5;

View File

@ -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 // 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. // 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 uint32_t PROTOCOL_MAX_MESSAGE_LENGTH = 4 * 1024 * 1024;
static constexpr std::uint32_t PROTOCOL_MAX_LIST_LENGTH = 1024 * 1024; static constexpr 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_STRING_LENGTH = 1024 * 1024;
// direction constants // direction constants
enum EDirection enum EDirection

View File

@ -100,7 +100,7 @@ void StreamBuffer::write(const void *vdata, UInt32 n)
m_size += n; m_size += n;
// cast data to bytes // cast data to bytes
const UInt8 *data = static_cast<const UInt8 *>(vdata); const uint8_t *data = static_cast<const uint8_t *>(vdata);
// point to last chunk if it has space, otherwise append an empty chunk // point to last chunk if it has space, otherwise append an empty chunk
ChunkList::iterator scan = m_chunks.end(); ChunkList::iterator scan = m_chunks.end();

View File

@ -71,7 +71,7 @@ public:
private: private:
static const UInt32 kChunkSize; static const UInt32 kChunkSize;
using Chunk = std::vector<UInt8>; using Chunk = std::vector<uint8_t>;
using ChunkList = std::list<Chunk>; using ChunkList = std::list<Chunk>;
ChunkList m_chunks; ChunkList m_chunks;

View File

@ -89,7 +89,7 @@ void IpcClientProxy::handleData(const Event &, void *)
LOG((CLOG_DEBUG "start ipc handle data")); LOG((CLOG_DEBUG "start ipc handle data"));
UInt8 code[4]; uint8_t code[4];
UInt32 n = m_stream.read(code, 4); UInt32 n = m_stream.read(code, 4);
while (n != 0) { while (n != 0) {
@ -151,7 +151,7 @@ void IpcClientProxy::send(const IpcMessage &message)
IpcHelloMessage *IpcClientProxy::parseHello() IpcHelloMessage *IpcClientProxy::parseHello()
{ {
UInt8 type; uint8_t type;
ProtocolUtil::readf(&m_stream, kIpcMsgHello + 4, &type); ProtocolUtil::readf(&m_stream, kIpcMsgHello + 4, &type);
m_clientType = static_cast<IpcClientType>(type); m_clientType = static_cast<IpcClientType>(type);
@ -163,7 +163,7 @@ IpcHelloMessage *IpcClientProxy::parseHello()
IpcCommandMessage *IpcClientProxy::parseCommand() IpcCommandMessage *IpcClientProxy::parseCommand()
{ {
std::string command; std::string command;
UInt8 elevate; uint8_t elevate;
ProtocolUtil::readf(&m_stream, kIpcMsgCommand + 4, &command, &elevate); ProtocolUtil::readf(&m_stream, kIpcMsgCommand + 4, &command, &elevate);
// must be deleted by event handler. // must be deleted by event handler.

View File

@ -46,7 +46,7 @@ void IpcServerProxy::handleData(const Event &, void *)
{ {
LOG((CLOG_DEBUG "start ipc handle data")); LOG((CLOG_DEBUG "start ipc handle data"));
UInt8 code[4]; uint8_t code[4];
UInt32 n = m_stream.read(code, 4); UInt32 n = m_stream.read(code, 4);
while (n != 0) { while (n != 0) {

View File

@ -144,7 +144,7 @@ bool AutoArchSocket::connectSocket(const NetworkAddress &addr)
return result; 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; size_t result = 0;
@ -155,7 +155,7 @@ size_t AutoArchSocket::readSocket(UInt8 *buffer, size_t size)
return result; 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; size_t result = 0;

View File

@ -40,8 +40,8 @@ public:
void closeSocketForRead(); void closeSocketForRead();
void closeSocketForWrite(); void closeSocketForWrite();
size_t readSocket(UInt8 *buffer, size_t size); size_t readSocket(uint8_t *buffer, size_t size);
size_t writeSocket(const UInt8 *buffer, size_t size); size_t writeSocket(const uint8_t *buffer, size_t size);
void throwErrorOnSocket(); void throwErrorOnSocket();
bool isValid() const; bool isValid() const;

View File

@ -212,7 +212,7 @@ void InverseClientSocket::connect(const NetworkAddress &addr)
InverseClientSocket::EJobResult InverseClientSocket::doRead() InverseClientSocket::EJobResult InverseClientSocket::doRead()
{ {
UInt8 buffer[4096] = {0}; uint8_t buffer[4096] = {0};
size_t bytesRead = m_socket.readSocket(buffer, sizeof(buffer)); size_t bytesRead = m_socket.readSocket(buffer, sizeof(buffer));
if (bytesRead > 0) { if (bytesRead > 0) {
@ -248,7 +248,7 @@ InverseClientSocket::EJobResult InverseClientSocket::doRead()
InverseClientSocket::EJobResult InverseClientSocket::doWrite() InverseClientSocket::EJobResult InverseClientSocket::doWrite()
{ {
UInt32 bufferSize = m_outputBuffer.getSize(); UInt32 bufferSize = m_outputBuffer.getSize();
auto buffer = static_cast<const UInt8 *>(m_outputBuffer.peek(bufferSize)); auto buffer = static_cast<const uint8_t *>(m_outputBuffer.peek(bufferSize));
const auto bytesWrote = static_cast<UInt32>(m_socket.writeSocket(buffer, bufferSize)); const auto bytesWrote = static_cast<UInt32>(m_socket.writeSocket(buffer, bufferSize));
if (bytesWrote > 0) { if (bytesWrote > 0) {

View File

@ -84,7 +84,7 @@ void SecureClientSocket::secureAccept()
InverseClientSocket::EJobResult SecureClientSocket::doRead() InverseClientSocket::EJobResult SecureClientSocket::doRead()
{ {
UInt8 buffer[4096] = {0}; uint8_t buffer[4096] = {0};
int bytesRead = 0; int bytesRead = 0;
int status = 0; int status = 0;

View File

@ -127,7 +127,7 @@ void SecureSocket::secureAccept()
TCPSocket::EJobResult SecureSocket::doRead() TCPSocket::EJobResult SecureSocket::doRead()
{ {
static UInt8 buffer[4096]; static uint8_t buffer[4096];
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
int bytesRead = 0; int bytesRead = 0;
int status = 0; int status = 0;

View File

@ -313,7 +313,7 @@ void TCPSocket::init()
TCPSocket::EJobResult TCPSocket::doRead() TCPSocket::EJobResult TCPSocket::doRead()
{ {
UInt8 buffer[4096]; uint8_t buffer[4096];
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
size_t bytesRead = 0; size_t bytesRead = 0;

View File

@ -19,7 +19,7 @@
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
KeyID IOSXKeyResource::getKeyID(UInt8 c) KeyID IOSXKeyResource::getKeyID(uint8_t c)
{ {
if (c == 0) { if (c == 0) {
return kKeyNone; return kKeyNone;

View File

@ -30,7 +30,7 @@ public:
virtual KeyID getKey(UInt32 table, UInt32 button) const = 0; virtual KeyID getKey(UInt32 table, UInt32 button) const = 0;
// Convert a character in the current script to the equivalent KeyID // 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. // Convert a unicode character to the equivalent KeyID.
static KeyID unicharToKeyID(UniChar); static KeyID unicharToKeyID(UniChar);

View File

@ -346,8 +346,8 @@ MSWindowsDesks::createBlankCursor() const
// create a transparent cursor // create a transparent cursor
int cw = GetSystemMetrics(SM_CXCURSOR); int cw = GetSystemMetrics(SM_CXCURSOR);
int ch = GetSystemMetrics(SM_CYCURSOR); int ch = GetSystemMetrics(SM_CYCURSOR);
UInt8 *cursorAND = new UInt8[ch * ((cw + 31) >> 2)]; uint8_t *cursorAND = new uint8_t[ch * ((cw + 31) >> 2)];
UInt8 *cursorXOR = new UInt8[ch * ((cw + 31) >> 2)]; uint8_t *cursorXOR = new uint8_t[ch * ((cw + 31) >> 2)];
memset(cursorAND, 0xff, ch * ((cw + 31) >> 2)); memset(cursorAND, 0xff, ch * ((cw + 31) >> 2));
memset(cursorXOR, 0x00, ch * ((cw + 31) >> 2)); memset(cursorXOR, 0x00, ch * ((cw + 31) >> 2));
HCURSOR c = CreateCursor(MSWindowsScreen::getWindowInstance(), 0, 0, cw, ch, cursorAND, cursorXOR); HCURSOR c = CreateCursor(MSWindowsScreen::getWindowInstance(), 0, 0, cw, ch, cursorAND, cursorXOR);

View File

@ -825,8 +825,8 @@ MSWindowsScreen::createBlankCursor() const
int cw = GetSystemMetrics(SM_CXCURSOR); int cw = GetSystemMetrics(SM_CXCURSOR);
int ch = GetSystemMetrics(SM_CYCURSOR); int ch = GetSystemMetrics(SM_CYCURSOR);
UInt8 *cursorAND = new UInt8[ch * ((cw + 31) >> 2)]; uint8_t *cursorAND = new uint8_t[ch * ((cw + 31) >> 2)];
UInt8 *cursorXOR = new UInt8[ch * ((cw + 31) >> 2)]; uint8_t *cursorXOR = new uint8_t[ch * ((cw + 31) >> 2)];
memset(cursorAND, 0xff, ch * ((cw + 31) >> 2)); memset(cursorAND, 0xff, ch * ((cw + 31) >> 2));
memset(cursorXOR, 0x00, ch * ((cw + 31) >> 2)); memset(cursorXOR, 0x00, ch * ((cw + 31) >> 2));
HCURSOR c = CreateCursor(s_windowInstance, 0, 0, cw, ch, cursorAND, cursorXOR); HCURSOR c = CreateCursor(s_windowInstance, 0, 0, cw, ch, cursorAND, cursorXOR);

View File

@ -109,7 +109,7 @@ void OSXClipboard::add(EFormat format, const std::string &data)
if (converter->getFormat() == format) { if (converter->getFormat() == format) {
std::string osXData = converter->fromIClipboard(data); std::string osXData = converter->fromIClipboard(data);
CFStringRef flavorType = converter->getOSXFormat(); 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; PasteboardItemID itemID = 0;
if (dataRef) { if (dataRef) {

View File

@ -31,31 +31,31 @@ public:
}; };
// BMP is little-endian // BMP is little-endian
static inline UInt32 fromLEU32(const UInt8 *data) static inline UInt32 fromLEU32(const uint8_t *data)
{ {
return static_cast<UInt32>(data[0]) | (static_cast<UInt32>(data[1]) << 8) | (static_cast<UInt32>(data[2]) << 16) | return static_cast<UInt32>(data[0]) | (static_cast<UInt32>(data[1]) << 8) | (static_cast<UInt32>(data[2]) << 16) |
(static_cast<UInt32>(data[3]) << 24); (static_cast<UInt32>(data[3]) << 24);
} }
static void toLE(UInt8 *&dst, char src) static void toLE(uint8_t *&dst, char src)
{ {
dst[0] = static_cast<UInt8>(src); dst[0] = static_cast<uint8_t>(src);
dst += 1; dst += 1;
} }
static void toLE(UInt8 *&dst, UInt16 src) static void toLE(uint8_t *&dst, UInt16 src)
{ {
dst[0] = static_cast<UInt8>(src & 0xffu); dst[0] = static_cast<uint8_t>(src & 0xffu);
dst[1] = static_cast<UInt8>((src >> 8) & 0xffu); dst[1] = static_cast<uint8_t>((src >> 8) & 0xffu);
dst += 2; dst += 2;
} }
static void toLE(UInt8 *&dst, UInt32 src) static void toLE(uint8_t *&dst, UInt32 src)
{ {
dst[0] = static_cast<UInt8>(src & 0xffu); dst[0] = static_cast<uint8_t>(src & 0xffu);
dst[1] = static_cast<UInt8>((src >> 8) & 0xffu); dst[1] = static_cast<uint8_t>((src >> 8) & 0xffu);
dst[2] = static_cast<UInt8>((src >> 16) & 0xffu); dst[2] = static_cast<uint8_t>((src >> 16) & 0xffu);
dst[3] = static_cast<UInt8>((src >> 24) & 0xffu); dst[3] = static_cast<uint8_t>((src >> 24) & 0xffu);
dst += 4; dst += 4;
} }
@ -84,8 +84,8 @@ std::string OSXClipboardBMPConverter::fromIClipboard(const std::string &bmp) con
{ {
LOG((CLOG_DEBUG1 "getting data from clipboard")); LOG((CLOG_DEBUG1 "getting data from clipboard"));
// create BMP image // create BMP image
UInt8 header[14]; uint8_t header[14];
UInt8 *dst = header; uint8_t *dst = header;
toLE(dst, 'B'); toLE(dst, 'B');
toLE(dst, 'M'); toLE(dst, 'M');
toLE(dst, static_cast<UInt32>(14 + bmp.size())); toLE(dst, static_cast<UInt32>(14 + bmp.size()));
@ -103,7 +103,7 @@ std::string OSXClipboardBMPConverter::toIClipboard(const std::string &bmp) const
} }
// check BMP file header // check BMP file header
const UInt8 *rawBMPHeader = reinterpret_cast<const UInt8 *>(bmp.data()); const uint8_t *rawBMPHeader = reinterpret_cast<const uint8_t *>(bmp.data());
if (rawBMPHeader[0] != 'B' || rawBMPHeader[1] != 'M') { if (rawBMPHeader[0] != 'B' || rawBMPHeader[1] != 'M') {
return std::string(); return std::string();
} }

View File

@ -62,7 +62,7 @@ std::string OSXClipboardHTMLConverter::convertString(
return std::string(); 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); std::string result(buffer, buffSize);

View File

@ -61,7 +61,7 @@ std::string OSXClipboardTextConverter::convertString(
return std::string(); 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); std::string result(buffer, buffSize);

View File

@ -177,9 +177,9 @@ io_connect_t getEventDriver()
return sEventDrvrRef; return sEventDrvrRef;
} }
bool isModifier(UInt8 virtualKey) bool isModifier(uint8_t virtualKey)
{ {
static std::set<UInt8> modifiers{s_shiftVK, s_superVK, s_altVK, s_controlVK, s_capsLockVK}; static std::set<uint8_t> modifiers{s_shiftVK, s_superVK, s_altVK, s_controlVK, s_capsLockVK};
return (modifiers.find(virtualKey) != modifiers.end()); return (modifiers.find(virtualKey) != modifiers.end());
} }
@ -459,7 +459,7 @@ void OSXKeyState::pollPressedKeys(KeyButtonSet &pressedKeys) const
{ {
::KeyMap km; ::KeyMap km;
GetKeys(km); GetKeys(km);
const UInt8 *m = reinterpret_cast<const UInt8 *>(km); const uint8_t *m = reinterpret_cast<const uint8_t *>(km);
for (UInt32 i = 0; i < 16; ++i) { for (UInt32 i = 0; i < 16; ++i) {
for (UInt32 j = 0; j < 8; ++j) { for (UInt32 j = 0; j < 8; ++j) {
if ((m[i] & (1u << j)) != 0) { 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; NXEventData event;
bzero(&event, sizeof(NXEventData)); 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 // collect the tables that map to the same KeyID. we know it
// can't be any earlier tables because of the check above. // can't be any earlier tables because of the check above.
std::set<UInt8> tables; std::set<uint8_t> tables;
tables.insert(static_cast<UInt8>(j)); tables.insert(static_cast<uint8_t>(j));
for (UInt32 k = j + 1; k < r.getNumTables(); ++k) { for (UInt32 k = j + 1; k < r.getNumTables(); ++k) {
if (buttonKeys[k].first == id) { if (buttonKeys[k].first == id) {
tables.insert(static_cast<UInt8>(k)); tables.insert(static_cast<uint8_t>(k));
} }
} }

View File

@ -140,7 +140,7 @@ private:
// Post a key event to HID manager. It posts an event to HID client, a // 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 // much lower level than window manager which's the target from carbon
// CGEventPost // 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 // Get keyboard event flags accorfing to keyboard modifiers
CGEventFlags getKeyboardEventFlags() const; CGEventFlags getKeyboardEventFlags() const;

View File

@ -55,7 +55,7 @@ OSXUchrKeyResource::OSXUchrKeyResource(const void *resource, UInt32 keyboardType
} }
// get tables for keyboard type // get tables for keyboard type
const UInt8 *const base = reinterpret_cast<const UInt8 *>(m_resource); const uint8_t *const base = reinterpret_cast<const uint8_t *>(m_resource);
m_m = reinterpret_cast<const UCKeyModifiersToTableNum *>(base + th->keyModifiersToTableNumOffset); m_m = reinterpret_cast<const UCKeyModifiersToTableNum *>(base + th->keyModifiersToTableNumOffset);
m_cti = reinterpret_cast<const UCKeyToCharTableIndex *>(base + th->keyToCharTableIndexOffset); m_cti = reinterpret_cast<const UCKeyToCharTableIndex *>(base + th->keyToCharTableIndexOffset);
m_sdi = reinterpret_cast<const UCKeySequenceDataIndex *>(base + th->keySequenceDataIndexOffset); m_sdi = reinterpret_cast<const UCKeySequenceDataIndex *>(base + th->keySequenceDataIndexOffset);
@ -118,7 +118,7 @@ KeyID OSXUchrKeyResource::getKey(UInt32 table, UInt32 button) const
assert(table < getNumTables()); assert(table < getNumTables());
assert(button < getNumButtons()); assert(button < getNumButtons());
const UInt8 *const base = reinterpret_cast<const UInt8 *>(m_resource); const uint8_t *const base = reinterpret_cast<const uint8_t *>(m_resource);
const UCKeyOutput *cPtr = reinterpret_cast<const UCKeyOutput *>(base + m_cti->keyToCharTableOffsets[table]); const UCKeyOutput *cPtr = reinterpret_cast<const UCKeyOutput *>(base + m_cti->keyToCharTableOffsets[table]);
const UCKeyOutput c = cPtr[button]; 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 bool OSXUchrKeyResource::getKeyRecord(KeySequence &keys, UInt16 index, UInt16 &state) const
{ {
const UInt8 *const base = reinterpret_cast<const UInt8 *>(m_resource); const uint8_t *const base = reinterpret_cast<const uint8_t *>(m_resource);
const UCKeyStateRecord *sr = reinterpret_cast<const UCKeyStateRecord *>(base + m_sri->keyStateRecordOffsets[index]); const UCKeyStateRecord *sr = reinterpret_cast<const UCKeyStateRecord *>(base + m_sri->keyStateRecordOffsets[index]);
const UCKeyStateEntryTerminal *kset = reinterpret_cast<const UCKeyStateEntryTerminal *>(sr->stateEntryData); const UCKeyStateEntryTerminal *kset = reinterpret_cast<const UCKeyStateEntryTerminal *>(sr->stateEntryData);

View File

@ -37,37 +37,37 @@ public:
// BMP is little-endian // BMP is little-endian
static void toLE(UInt8 *&dst, UInt16 src) static void toLE(uint8_t *&dst, UInt16 src)
{ {
dst[0] = static_cast<UInt8>(src & 0xffu); dst[0] = static_cast<uint8_t>(src & 0xffu);
dst[1] = static_cast<UInt8>((src >> 8) & 0xffu); dst[1] = static_cast<uint8_t>((src >> 8) & 0xffu);
dst += 2; dst += 2;
} }
static void toLE(UInt8 *&dst, SInt32 src) static void toLE(uint8_t *&dst, SInt32 src)
{ {
dst[0] = static_cast<UInt8>(src & 0xffu); dst[0] = static_cast<uint8_t>(src & 0xffu);
dst[1] = static_cast<UInt8>((src >> 8) & 0xffu); dst[1] = static_cast<uint8_t>((src >> 8) & 0xffu);
dst[2] = static_cast<UInt8>((src >> 16) & 0xffu); dst[2] = static_cast<uint8_t>((src >> 16) & 0xffu);
dst[3] = static_cast<UInt8>((src >> 24) & 0xffu); dst[3] = static_cast<uint8_t>((src >> 24) & 0xffu);
dst += 4; dst += 4;
} }
static void toLE(UInt8 *&dst, UInt32 src) static void toLE(uint8_t *&dst, UInt32 src)
{ {
dst[0] = static_cast<UInt8>(src & 0xffu); dst[0] = static_cast<uint8_t>(src & 0xffu);
dst[1] = static_cast<UInt8>((src >> 8) & 0xffu); dst[1] = static_cast<uint8_t>((src >> 8) & 0xffu);
dst[2] = static_cast<UInt8>((src >> 16) & 0xffu); dst[2] = static_cast<uint8_t>((src >> 16) & 0xffu);
dst[3] = static_cast<UInt8>((src >> 24) & 0xffu); dst[3] = static_cast<uint8_t>((src >> 24) & 0xffu);
dst += 4; dst += 4;
} }
static inline UInt16 fromLEU16(const UInt8 *data) static inline UInt16 fromLEU16(const uint8_t *data)
{ {
return static_cast<UInt16>(data[0]) | (static_cast<UInt16>(data[1]) << 8); return static_cast<UInt16>(data[0]) | (static_cast<UInt16>(data[1]) << 8);
} }
static inline SInt32 fromLES32(const UInt8 *data) static inline SInt32 fromLES32(const uint8_t *data)
{ {
return static_cast<SInt32>( return static_cast<SInt32>(
static_cast<UInt32>(data[0]) | (static_cast<UInt32>(data[1]) << 8) | (static_cast<UInt32>(data[2]) << 16) | static_cast<UInt32>(data[0]) | (static_cast<UInt32>(data[1]) << 8) | (static_cast<UInt32>(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<UInt32>(data[0]) | (static_cast<UInt32>(data[1]) << 8) | (static_cast<UInt32>(data[2]) << 16) | return static_cast<UInt32>(data[0]) | (static_cast<UInt32>(data[1]) << 8) | (static_cast<UInt32>(data[2]) << 16) |
(static_cast<UInt32>(data[3]) << 24); (static_cast<UInt32>(data[3]) << 24);
@ -109,7 +109,7 @@ std::string XWindowsClipboardAnyBitmapConverter::fromIClipboard(const std::strin
{ {
// fill BMP info header with native-endian data // fill BMP info header with native-endian data
CBMPInfoHeader infoHeader; CBMPInfoHeader infoHeader;
const UInt8 *rawBMPInfoHeader = reinterpret_cast<const UInt8 *>(bmp.data()); const uint8_t *rawBMPInfoHeader = reinterpret_cast<const uint8_t *>(bmp.data());
infoHeader.biSize = fromLEU32(rawBMPInfoHeader + 0); infoHeader.biSize = fromLEU32(rawBMPInfoHeader + 0);
infoHeader.biWidth = fromLES32(rawBMPInfoHeader + 4); infoHeader.biWidth = fromLES32(rawBMPInfoHeader + 4);
infoHeader.biHeight = fromLES32(rawBMPInfoHeader + 8); infoHeader.biHeight = fromLES32(rawBMPInfoHeader + 8);
@ -129,7 +129,7 @@ std::string XWindowsClipboardAnyBitmapConverter::fromIClipboard(const std::strin
} }
// convert to image format // convert to image format
const UInt8 *rawBMPPixels = rawBMPInfoHeader + 40; const uint8_t *rawBMPPixels = rawBMPInfoHeader + 40;
if (infoHeader.biBitCount == 24) { if (infoHeader.biBitCount == 24) {
return doBGRFromIClipboard(rawBMPPixels, infoHeader.biWidth, infoHeader.biHeight); return doBGRFromIClipboard(rawBMPPixels, infoHeader.biWidth, infoHeader.biHeight);
} else { } else {
@ -147,8 +147,8 @@ std::string XWindowsClipboardAnyBitmapConverter::toIClipboard(const std::string
} }
// fill BMP info header with little-endian data // fill BMP info header with little-endian data
UInt8 infoHeader[40]; uint8_t infoHeader[40];
UInt8 *dst = infoHeader; uint8_t *dst = infoHeader;
toLE(dst, static_cast<UInt32>(40)); toLE(dst, static_cast<UInt32>(40));
toLE(dst, static_cast<SInt32>(w)); toLE(dst, static_cast<SInt32>(w));
toLE(dst, static_cast<SInt32>(h)); toLE(dst, static_cast<SInt32>(h));

View File

@ -39,13 +39,13 @@ protected:
/*! /*!
Convert raw BGR pixel data to another image format. 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 from IClipboard format
/*! /*!
Convert raw BGRA pixel data to another image 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 //! Convert to IClipboard format
/*! /*!

View File

@ -30,31 +30,31 @@ public:
}; };
// BMP is little-endian // BMP is little-endian
static inline UInt32 fromLEU32(const UInt8 *data) static inline UInt32 fromLEU32(const uint8_t *data)
{ {
return static_cast<UInt32>(data[0]) | (static_cast<UInt32>(data[1]) << 8) | (static_cast<UInt32>(data[2]) << 16) | return static_cast<UInt32>(data[0]) | (static_cast<UInt32>(data[1]) << 8) | (static_cast<UInt32>(data[2]) << 16) |
(static_cast<UInt32>(data[3]) << 24); (static_cast<UInt32>(data[3]) << 24);
} }
static void toLE(UInt8 *&dst, char src) static void toLE(uint8_t *&dst, char src)
{ {
dst[0] = static_cast<UInt8>(src); dst[0] = static_cast<uint8_t>(src);
dst += 1; dst += 1;
} }
static void toLE(UInt8 *&dst, UInt16 src) static void toLE(uint8_t *&dst, UInt16 src)
{ {
dst[0] = static_cast<UInt8>(src & 0xffu); dst[0] = static_cast<uint8_t>(src & 0xffu);
dst[1] = static_cast<UInt8>((src >> 8) & 0xffu); dst[1] = static_cast<uint8_t>((src >> 8) & 0xffu);
dst += 2; dst += 2;
} }
static void toLE(UInt8 *&dst, UInt32 src) static void toLE(uint8_t *&dst, UInt32 src)
{ {
dst[0] = static_cast<UInt8>(src & 0xffu); dst[0] = static_cast<uint8_t>(src & 0xffu);
dst[1] = static_cast<UInt8>((src >> 8) & 0xffu); dst[1] = static_cast<uint8_t>((src >> 8) & 0xffu);
dst[2] = static_cast<UInt8>((src >> 16) & 0xffu); dst[2] = static_cast<uint8_t>((src >> 16) & 0xffu);
dst[3] = static_cast<UInt8>((src >> 24) & 0xffu); dst[3] = static_cast<uint8_t>((src >> 24) & 0xffu);
dst += 4; dst += 4;
} }
@ -91,8 +91,8 @@ int XWindowsClipboardBMPConverter::getDataSize() const
std::string XWindowsClipboardBMPConverter::fromIClipboard(const std::string &bmp) const std::string XWindowsClipboardBMPConverter::fromIClipboard(const std::string &bmp) const
{ {
// create BMP image // create BMP image
UInt8 header[14]; uint8_t header[14];
UInt8 *dst = header; uint8_t *dst = header;
toLE(dst, 'B'); toLE(dst, 'B');
toLE(dst, 'M'); toLE(dst, 'M');
toLE(dst, static_cast<UInt32>(14 + bmp.size())); toLE(dst, static_cast<UInt32>(14 + bmp.size()));
@ -110,7 +110,7 @@ std::string XWindowsClipboardBMPConverter::toIClipboard(const std::string &bmp)
} }
// check BMP file header // check BMP file header
const UInt8 *rawBMPHeader = reinterpret_cast<const UInt8 *>(bmp.data()); const uint8_t *rawBMPHeader = reinterpret_cast<const uint8_t *>(bmp.data());
if (rawBMPHeader[0] != 'B' || rawBMPHeader[1] != 'M') { if (rawBMPHeader[0] != 'B' || rawBMPHeader[1] != 'M') {
return std::string(); return std::string();
} }

View File

@ -88,7 +88,7 @@ public:
virtual void resetOptions() = 0; virtual void resetOptions() = 0;
virtual void setOptions(const OptionsList &options) = 0; virtual void setOptions(const OptionsList &options) = 0;
virtual void sendDragInfo(UInt32 fileCount, const char *info, size_t size) = 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 std::string getSecureInputApp() const = 0;
virtual void secureInputNotification(const std::string &app) const = 0; virtual void secureInputNotification(const std::string &app) const = 0;
virtual std::string getName() const; virtual std::string getName() const;

View File

@ -86,7 +86,7 @@ public:
void resetOptions() override = 0; void resetOptions() override = 0;
void setOptions(const OptionsList &options) override = 0; void setOptions(const OptionsList &options) override = 0;
void sendDragInfo(UInt32 fileCount, const char *info, size_t size) 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; void secureInputNotification(const std::string &app) const override = 0;
private: private:

View File

@ -129,7 +129,7 @@ void ClientProxy1_0::setHeartbeatRate(double, double alarm)
void ClientProxy1_0::handleData(const Event &, void *) void ClientProxy1_0::handleData(const Event &, void *)
{ {
// handle messages until there are no more. first read message code. // handle messages until there are no more. first read message code.
UInt8 code[4]; uint8_t code[4];
UInt32 n = getStream()->read(code, 4); UInt32 n = getStream()->read(code, 4);
while (n != 0) { while (n != 0) {
// verify we got an entire code // verify we got an entire code
@ -166,7 +166,7 @@ void ClientProxy1_0::handleData(const Event &, void *)
resetHeartbeatTimer(); resetHeartbeatTimer();
} }
bool ClientProxy1_0::parseHandshakeMessage(const UInt8 *code) bool ClientProxy1_0::parseHandshakeMessage(const uint8_t *code)
{ {
if (memcmp(code, kMsgCNoop, 4) == 0) { if (memcmp(code, kMsgCNoop, 4) == 0) {
// discard no-ops // discard no-ops
@ -184,7 +184,7 @@ bool ClientProxy1_0::parseHandshakeMessage(const UInt8 *code)
return false; return false;
} }
bool ClientProxy1_0::parseMessage(const UInt8 *code) bool ClientProxy1_0::parseMessage(const uint8_t *code)
{ {
if (memcmp(code, kMsgDInfo, 4) == 0) { if (memcmp(code, kMsgDInfo, 4) == 0) {
if (recvInfo()) { if (recvInfo()) {
@ -332,7 +332,7 @@ void ClientProxy1_0::sendDragInfo(UInt32 fileCount, const char *info, size_t siz
LOG((CLOG_DEBUG "draggingInfoSending not supported")); 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 // ignore -- not supported in protocol 1.0
LOG((CLOG_DEBUG "fileChunkSending not supported")); LOG((CLOG_DEBUG "fileChunkSending not supported"));

View File

@ -61,13 +61,13 @@ public:
void resetOptions() override; void resetOptions() override;
void setOptions(const OptionsList &options) override; void setOptions(const OptionsList &options) override;
void sendDragInfo(UInt32 fileCount, const char *info, size_t size) 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; std::string getSecureInputApp() const override;
void secureInputNotification(const std::string &app) const override; void secureInputNotification(const std::string &app) const override;
protected: protected:
virtual bool parseHandshakeMessage(const UInt8 *code); virtual bool parseHandshakeMessage(const uint8_t *code);
virtual bool parseMessage(const UInt8 *code); virtual bool parseMessage(const uint8_t *code);
virtual void resetHeartbeatRate(); virtual void resetHeartbeatRate();
virtual void setHeartbeatRate(double rate, double alarm); virtual void setHeartbeatRate(double rate, double alarm);
@ -103,7 +103,7 @@ protected:
ClientClipboard m_clipboard[kClipboardEnd]; ClientClipboard m_clipboard[kClipboardEnd];
private: private:
typedef bool (ClientProxy1_0::*MessageParser)(const UInt8 *); typedef bool (ClientProxy1_0::*MessageParser)(const uint8_t *);
ClientInfo m_info; ClientInfo m_info;
double m_heartbeatAlarm; double m_heartbeatAlarm;

View File

@ -51,7 +51,7 @@ void ClientProxy1_3::mouseWheel(SInt32 xDelta, SInt32 yDelta)
ProtocolUtil::writef(getStream(), kMsgDMouseWheel, xDelta, yDelta); ProtocolUtil::writef(getStream(), kMsgDMouseWheel, xDelta, yDelta);
} }
bool ClientProxy1_3::parseMessage(const UInt8 *code) bool ClientProxy1_3::parseMessage(const uint8_t *code)
{ {
// process message // process message
if (memcmp(code, kMsgCKeepAlive, 4) == 0) { if (memcmp(code, kMsgCKeepAlive, 4) == 0) {

View File

@ -39,7 +39,7 @@ public:
protected: protected:
// ClientProxy overrides // ClientProxy overrides
virtual bool parseMessage(const UInt8 *code); virtual bool parseMessage(const uint8_t *code);
virtual void resetHeartbeatRate(); virtual void resetHeartbeatRate();
virtual void setHeartbeatRate(double rate, double alarm); virtual void setHeartbeatRate(double rate, double alarm);
virtual void resetHeartbeatTimer(); virtual void resetHeartbeatTimer();

View File

@ -54,12 +54,12 @@ void ClientProxy1_5::sendDragInfo(UInt32 fileCount, const char *info, size_t siz
ProtocolUtil::writef(getStream(), kMsgDDragInfo, fileCount, &data); 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); 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) { if (memcmp(code, kMsgDFileTransfer, 4) == 0) {
fileChunkReceived(); fileChunkReceived();

View File

@ -37,8 +37,8 @@ public:
ClientProxy1_5 &operator=(ClientProxy1_5 &&) = delete; ClientProxy1_5 &operator=(ClientProxy1_5 &&) = delete;
virtual void sendDragInfo(UInt32 fileCount, const char *info, size_t size); virtual void sendDragInfo(UInt32 fileCount, const char *info, size_t size);
virtual void fileChunkSending(UInt8 mark, char *data, size_t dataSize); virtual void fileChunkSending(uint8_t mark, char *data, size_t dataSize);
virtual bool parseMessage(const UInt8 *code); virtual bool parseMessage(const uint8_t *code);
void fileChunkReceived(); void fileChunkReceived();
void dragInfoReceived(); void dragInfoReceived();

View File

@ -223,7 +223,7 @@ void PrimaryClient::sendDragInfo(UInt32 fileCount, const char *info, size_t size
// ignore // ignore
} }
void PrimaryClient::fileChunkSending(UInt8 mark, char *data, size_t dataSize) void PrimaryClient::fileChunkSending(uint8_t mark, char *data, size_t dataSize)
{ {
// ignore // ignore
} }

View File

@ -144,7 +144,7 @@ public:
void resetOptions() override; void resetOptions() override;
void setOptions(const OptionsList &options) override; void setOptions(const OptionsList &options) override;
void sendDragInfo(UInt32 fileCount, const char *info, size_t size) 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; std::string getSecureInputApp() const override;
void secureInputNotification(const std::string &app) const override; void secureInputNotification(const std::string &app) const override;

View File

@ -61,7 +61,7 @@ const size_t kMockFileSize = 1024 * 1024 * 10; // 10MB
void getScreenShape(SInt32 &x, SInt32 &y, SInt32 &w, SInt32 &h); void getScreenShape(SInt32 &x, SInt32 &y, SInt32 &w, SInt32 &h);
void getCursorPos(SInt32 &x, SInt32 &y); 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); void createFile(fstream &file, const char *filename, size_t size);
class NetworkTests : public ::testing::Test { class NetworkTests : public ::testing::Test {
@ -96,7 +96,7 @@ public:
public: public:
TestEventQueue m_events; TestEventQueue m_events;
UInt8 *m_mockData; uint8_t *m_mockData;
size_t m_mockDataSize; size_t m_mockDataSize;
fstream m_mockFile; fstream m_mockFile;
size_t m_mockFileSize; size_t m_mockFileSize;
@ -473,15 +473,15 @@ void NetworkTests::sendMockData(void *eventTarget) {
m_events.forFile().fileChunkSending(), eventTarget, transferFinished)); m_events.forFile().fileChunkSending(), eventTarget, transferFinished));
} }
UInt8 *newMockData(size_t size) { uint8_t *newMockData(size_t size) {
UInt8 *buffer = new UInt8[size]; uint8_t *buffer = new uint8_t[size];
UInt8 *data = buffer; uint8_t *data = buffer;
const UInt8 head[] = "mock head... "; const uint8_t head[] = "mock head... ";
size_t headSize = sizeof(head) - 1; size_t headSize = sizeof(head) - 1;
const UInt8 tail[] = "... mock tail"; const uint8_t tail[] = "... mock tail";
size_t tailSize = sizeof(tail) - 1; 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; size_t deskflowRocksSize = sizeof(deskflowRocks) - 1;
memcpy(data, head, headSize); memcpy(data, head, headSize);
@ -504,7 +504,7 @@ UInt8 *newMockData(size_t size) {
} }
void createFile(fstream &file, const char *filename, 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); file.open(filename, ios::out | ios::binary);
if (!file.is_open()) { if (!file.is_open()) {

View File

@ -38,7 +38,7 @@ ACTION_P2(SetValueToVoidPointerArg0, value, size)
MATCHER_P(EqVoidPointeeInt8, expected, "") MATCHER_P(EqVoidPointeeInt8, expected, "")
{ {
const UInt8 Actual8 = (*static_cast<const UInt8 *>(arg)); const uint8_t Actual8 = (*static_cast<const uint8_t *>(arg));
return (expected == Actual8); return (expected == Actual8);
} }
@ -57,7 +57,7 @@ MATCHER_P(EqVoidPointeeInt32, expected, "")
MATCHER_P(EqVoidVectorInt1byte, expected, "") MATCHER_P(EqVoidVectorInt1byte, expected, "")
{ {
bool Result = true; bool Result = true;
const UInt8 *Actual = (static_cast<const UInt8 *>(arg)) + 4; const uint8_t *Actual = (static_cast<const uint8_t *>(arg)) + 4;
const size_t Size = *(Actual - 1); const size_t Size = *(Actual - 1);
if (Size == expected.size()) { if (Size == expected.size()) {
@ -117,7 +117,7 @@ MATCHER_P(EqVoidVectorInt4bytes, expected, "")
MATCHER_P(EqVectorSymbols, expected, "") MATCHER_P(EqVectorSymbols, expected, "")
{ {
bool Result = true; bool Result = true;
const UInt8 *Actual = (static_cast<const UInt8 *>(arg)); const uint8_t *Actual = (static_cast<const uint8_t *>(arg));
for (size_t i = 0; i < expected.size(); ++i) { for (size_t i = 0; i < expected.size(); ++i) {
if (expected[i] != (Actual[i])) { if (expected[i] != (Actual[i])) {
@ -138,7 +138,7 @@ class ProtocolUtilTests : public ::testing::Test
{ {
public: public:
MockStream stream; MockStream stream;
UInt8 ActualInt8 = 0; uint8_t ActualInt8 = 0;
UInt16 ActualInt16 = 0; UInt16 ActualInt16 = 0;
UInt32 ActualInt32 = 0; UInt32 ActualInt32 = 0;
std::string ActualString; std::string ActualString;
@ -187,9 +187,9 @@ TEST_F(ProtocolUtilTests, readf_params_validation) {
} }
TEST_F(ProtocolUtilTests, readf_string) { TEST_F(ProtocolUtilTests, readf_string) {
const UInt8 Length = 200; const uint8_t Length = 200;
const std::string Expected(Length, 'x'); const std::string Expected(Length, 'x');
std::array<UInt8, 4> StringSize{{0, 0, 0, Length}}; std::array<uint8_t, 4> StringSize{{0, 0, 0, Length}};
EXPECT_CALL(stream, read(_, _)) EXPECT_CALL(stream, read(_, _))
.WillOnce( .WillOnce(
@ -207,12 +207,12 @@ class ReadfIntTestFixture
: public ::testing::TestWithParam<std::tuple<const char *, int>> { : public ::testing::TestWithParam<std::tuple<const char *, int>> {
public: public:
MockStream stream; MockStream stream;
UInt8 StreamData1Byte = 10; uint8_t StreamData1Byte = 10;
std::array<UInt8, 2> StreamData2Bytes{{0, 10}}; std::array<uint8_t, 2> StreamData2Bytes{{0, 10}};
std::array<UInt8, 4> StreamData4Bytes{{0, 0, 0, 10}}; std::array<uint8_t, 4> StreamData4Bytes{{0, 0, 0, 10}};
UInt8 *getStreamData(int size) { uint8_t *getStreamData(int size) {
UInt8 *StreamData = nullptr; uint8_t *StreamData = nullptr;
switch (size) { switch (size) {
case 2: case 2:
StreamData = StreamData2Bytes.data(); StreamData = StreamData2Bytes.data();
@ -233,7 +233,7 @@ TEST_P(ReadfIntTestFixture, readf_int) {
const int Expected = 10; const int Expected = 10;
const char *Format = std::get<0>(GetParam()); const char *Format = std::get<0>(GetParam());
int StreamDataSize = std::get<1>(GetParam()); int StreamDataSize = std::get<1>(GetParam());
UInt8 *StreamData = getStreamData(StreamDataSize); uint8_t *StreamData = getStreamData(StreamDataSize);
ON_CALL(stream, read(_, _)) ON_CALL(stream, read(_, _))
.WillByDefault( .WillByDefault(
@ -252,18 +252,18 @@ INSTANTIATE_TEST_SUITE_P(ReadfIntTests, ReadfIntTestFixture,
class ReadfIntVectorTestFixture : public ReadfIntTestFixture {}; class ReadfIntVectorTestFixture : public ReadfIntTestFixture {};
TEST_P(ReadfIntVectorTestFixture, readf_int_vector) { TEST_P(ReadfIntVectorTestFixture, readf_int_vector) {
std::vector<UInt8> Actual1Byte = {}; std::vector<uint8_t> Actual1Byte = {};
std::vector<UInt16> Actual2Bytes = {}; std::vector<UInt16> Actual2Bytes = {};
std::vector<UInt32> Actual4Bytes = {}; std::vector<UInt32> Actual4Bytes = {};
const std::vector<UInt8> Expected1Byte = {10, 10}; const std::vector<uint8_t> Expected1Byte = {10, 10};
const std::vector<UInt16> Expected2Bytes = {10, 10}; const std::vector<UInt16> Expected2Bytes = {10, 10};
const std::vector<UInt32> Expected4Bytes = {10, 10}; const std::vector<UInt32> Expected4Bytes = {10, 10};
std::array<UInt8, 4> StreamVectorSize{{0, 0, 0, 2}}; std::array<uint8_t, 4> StreamVectorSize{{0, 0, 0, 2}};
const char *Format = std::get<0>(GetParam()); const char *Format = std::get<0>(GetParam());
int StreamDataSize = std::get<1>(GetParam()); int StreamDataSize = std::get<1>(GetParam());
UInt8 *StreamData = getStreamData(StreamDataSize); uint8_t *StreamData = getStreamData(StreamDataSize);
MockStream stream; MockStream stream;
EXPECT_CALL(stream, read(_, _)) EXPECT_CALL(stream, read(_, _))
@ -297,7 +297,7 @@ INSTANTIATE_TEST_SUITE_P(ReadfIntVectorTests, ReadfIntVectorTestFixture,
class ReadfIntAndStringTest : public ReadfIntTestFixture { class ReadfIntAndStringTest : public ReadfIntTestFixture {
public: public:
UInt8 ActualInt8 = 0; uint8_t ActualInt8 = 0;
UInt16 ActualInt16 = 0; UInt16 ActualInt16 = 0;
UInt32 ActualInt32 = 32; UInt32 ActualInt32 = 32;
std::string ActualString; std::string ActualString;
@ -305,13 +305,13 @@ public:
TEST_P(ReadfIntAndStringTest, readf_int_and_string) { TEST_P(ReadfIntAndStringTest, readf_int_and_string) {
const int ExpectedInt = 10; const int ExpectedInt = 10;
const UInt8 StringLength = 200; const uint8_t StringLength = 200;
const std::string ExpectedString(StringLength, 'x'); const std::string ExpectedString(StringLength, 'x');
std::array<UInt8, 4> StringSize{{0, 0, 0, StringLength}}; std::array<uint8_t, 4> StringSize{{0, 0, 0, StringLength}};
const char *Format = std::get<0>(GetParam()); const char *Format = std::get<0>(GetParam());
int StreamDataSize = std::get<1>(GetParam()); int StreamDataSize = std::get<1>(GetParam());
UInt8 *StreamData = getStreamData(StreamDataSize); uint8_t *StreamData = getStreamData(StreamDataSize);
EXPECT_CALL(stream, read(_, _)) EXPECT_CALL(stream, read(_, _))
.WillOnce(DoAll(SetValueToVoidPointerArg0(StreamData, StreamDataSize), .WillOnce(DoAll(SetValueToVoidPointerArg0(StreamData, StreamDataSize),
@ -349,11 +349,11 @@ INSTANTIATE_TEST_SUITE_P(IntAndStringTest, ReadfIntAndStringTest,
std::make_tuple("%4i%s", 4))); std::make_tuple("%4i%s", 4)));
TEST_F(ProtocolUtilTests, readf_string_and_int4bytes) { TEST_F(ProtocolUtilTests, readf_string_and_int4bytes) {
const UInt8 ExpectedInt = 10; const uint8_t ExpectedInt = 10;
std::array<UInt8, 4> StreamIntData{{0, 0, 0, ExpectedInt}}; std::array<uint8_t, 4> StreamIntData{{0, 0, 0, ExpectedInt}};
const std::string ExpectedStr(32768, 'x'); const std::string ExpectedStr(32768, 'x');
std::array<UInt8, 4> Size{{0, 0, 128, 0}}; std::array<uint8_t, 4> Size{{0, 0, 128, 0}};
EXPECT_CALL(stream, read(_, _)) EXPECT_CALL(stream, read(_, _))
.WillOnce(DoAll(SetValueToVoidPointerArg0(Size.data(), Size.size()), .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) { TEST_F(ProtocolUtilTests, readf_string_and_vector_int4bytes) {
std::vector<UInt32> Actual = {}; std::vector<UInt32> Actual = {};
const std::vector<UInt32> Expected4Bytes = {10, 10}; const std::vector<UInt32> Expected4Bytes = {10, 10};
std::array<UInt8, 4> StreamVectorSize{{0, 0, 0, 2}}; std::array<uint8_t, 4> StreamVectorSize{{0, 0, 0, 2}};
std::array<UInt8, 4> StreamData4Bytes{{0, 0, 0, 10}}; std::array<uint8_t, 4> StreamData4Bytes{{0, 0, 0, 10}};
const std::string ExpString(32768, 'x'); const std::string ExpString(32768, 'x');
std::array<UInt8, 4> SizeString{{0, 0, 128, 0}}; std::array<uint8_t, 4> SizeString{{0, 0, 128, 0}};
EXPECT_CALL(stream, read(_, _)) EXPECT_CALL(stream, read(_, _))
.WillOnce( .WillOnce(
@ -402,11 +402,11 @@ TEST_F(ProtocolUtilTests, readf_string_and_vector_int4bytes) {
TEST_F(ProtocolUtilTests, readf_vector_int4bytes_and_string) { TEST_F(ProtocolUtilTests, readf_vector_int4bytes_and_string) {
std::vector<UInt32> Actual4Bytes = {}; std::vector<UInt32> Actual4Bytes = {};
const std::vector<UInt32> Expected4Bytes = {10, 10}; const std::vector<UInt32> Expected4Bytes = {10, 10};
std::array<UInt8, 4> StreamVectorSize{{0, 0, 0, 2}}; std::array<uint8_t, 4> StreamVectorSize{{0, 0, 0, 2}};
std::array<UInt8, 4> StreamData4Bytes{{0, 0, 0, 10}}; std::array<uint8_t, 4> StreamData4Bytes{{0, 0, 0, 10}};
const std::string ExpectedString(32768, 'x'); const std::string ExpectedString(32768, 'x');
std::array<UInt8, 4> StringSize{{0, 0, 128, 0}}; std::array<uint8_t, 4> StringSize{{0, 0, 128, 0}};
EXPECT_CALL(stream, read(_, _)) EXPECT_CALL(stream, read(_, _))
.WillOnce(DoAll(SetValueToVoidPointerArg0(StreamVectorSize.data(), .WillOnce(DoAll(SetValueToVoidPointerArg0(StreamVectorSize.data(),
@ -435,7 +435,7 @@ class WriteIntTest
: public ::testing::TestWithParam<std::tuple<const char *, int>> { : public ::testing::TestWithParam<std::tuple<const char *, int>> {
public: public:
MockStream stream; MockStream stream;
UInt8 Expected1Byte = 5; uint8_t Expected1Byte = 5;
UInt16 Expected2Bytes = 10; UInt16 Expected2Bytes = 10;
UInt32 Expected4Bytes = 15; UInt32 Expected4Bytes = 15;
}; };
@ -470,7 +470,7 @@ class WriteIntVectorTest
: public ::testing::TestWithParam<std::tuple<const char *, int>> { : public ::testing::TestWithParam<std::tuple<const char *, int>> {
public: public:
MockStream stream; MockStream stream;
const std::vector<UInt8> Expected1Byte = {10, 20, 30}; const std::vector<uint8_t> Expected1Byte = {10, 20, 30};
const std::vector<UInt16> Expected2Byte = {40, 50, 60}; const std::vector<UInt16> Expected2Byte = {40, 50, 60};
const std::vector<UInt32> Expected4Byte = {70, 80, 90}; const std::vector<UInt32> Expected4Byte = {70, 80, 90};
}; };
@ -507,7 +507,7 @@ INSTANTIATE_TEST_SUITE_P(WriteIntVectorTest, WriteIntVectorTest,
TEST_F(ProtocolUtilTests, write_string_test) { TEST_F(ProtocolUtilTests, write_string_test) {
const std::string Expected = "Expected"; const std::string Expected = "Expected";
const std::vector<UInt8> ExpectedVector = {'E', 'x', 'p', 'e', const std::vector<uint8_t> ExpectedVector = {'E', 'x', 'p', 'e',
'c', 't', 'e', 'd'}; 'c', 't', 'e', 'd'};
EXPECT_CALL(stream, write(EqVoidVectorInt1byte(ExpectedVector), EXPECT_CALL(stream, write(EqVoidVectorInt1byte(ExpectedVector),
Expected.size() + sizeof(UInt32))); Expected.size() + sizeof(UInt32)));
@ -516,14 +516,14 @@ TEST_F(ProtocolUtilTests, write_string_test) {
TEST_F(ProtocolUtilTests, write_raw_bytes_test) { TEST_F(ProtocolUtilTests, write_raw_bytes_test) {
const UInt32 Size = 5; const UInt32 Size = 5;
const std::array<UInt8, Size> Expected{{10, 20, 30, 40, 50}}; const std::array<uint8_t, Size> Expected{{10, 20, 30, 40, 50}};
EXPECT_CALL(stream, write(EqVoidVectorInt1byte(Expected), EXPECT_CALL(stream, write(EqVoidVectorInt1byte(Expected),
Expected.size() + sizeof(UInt32))); Expected.size() + sizeof(UInt32)));
ProtocolUtil::writef(&stream, "%S", Size, &Expected); ProtocolUtil::writef(&stream, "%S", Size, &Expected);
} }
TEST_F(ProtocolUtilTests, write_symbols_from_format_test) { TEST_F(ProtocolUtilTests, write_symbols_from_format_test) {
const std::vector<UInt8> Expected = {'%', '1', '2', '3', '4', '5'}; const std::vector<uint8_t> Expected = {'%', '1', '2', '3', '4', '5'};
EXPECT_CALL(stream, write(EqVectorSymbols(Expected), Expected.size())); EXPECT_CALL(stream, write(EqVectorSymbols(Expected), Expected.size()));
ProtocolUtil::writef(&stream, "%%12345"); ProtocolUtil::writef(&stream, "%%12345");
} }