Avoid having our own custom stuff and instead use the modern, standard types, for familiarity.pull/1587/head
@@ -27,7 +27,8 @@ | |||
#ifdef HAVE_NETTLE | |||
using namespace rdr; | |||
AESInStream::AESInStream(InStream* _in, const U8* key, int _keySize) | |||
AESInStream::AESInStream(InStream* _in, const uint8_t* key, | |||
int _keySize) | |||
: keySize(_keySize), in(_in), counter() | |||
{ | |||
if (keySize == 128) | |||
@@ -44,26 +45,26 @@ bool AESInStream::fillBuffer() | |||
{ | |||
if (!in->hasData(2)) | |||
return false; | |||
const U8* ptr = in->getptr(2); | |||
const uint8_t* ptr = in->getptr(2); | |||
size_t length = ((int)ptr[0] << 8) | (int)ptr[1]; | |||
if (!in->hasData(2 + length + 16)) | |||
return false; | |||
ensureSpace(length); | |||
ptr = in->getptr(2 + length + 16); | |||
const U8* ad = ptr; | |||
const U8* data = ptr + 2; | |||
const U8* mac = ptr + 2 + length; | |||
U8 macComputed[16]; | |||
const uint8_t* ad = ptr; | |||
const uint8_t* data = ptr + 2; | |||
const uint8_t* mac = ptr + 2 + length; | |||
uint8_t macComputed[16]; | |||
if (keySize == 128) { | |||
EAX_SET_NONCE(&eaxCtx128, aes128_encrypt, 16, counter); | |||
EAX_UPDATE(&eaxCtx128, aes128_encrypt, 2, ad); | |||
EAX_DECRYPT(&eaxCtx128, aes128_encrypt, length, (rdr::U8*)end, data); | |||
EAX_DECRYPT(&eaxCtx128, aes128_encrypt, length, (uint8_t*)end, data); | |||
EAX_DIGEST(&eaxCtx128, aes128_encrypt, 16, macComputed); | |||
} else { | |||
EAX_SET_NONCE(&eaxCtx256, aes256_encrypt, 16, counter); | |||
EAX_UPDATE(&eaxCtx256, aes256_encrypt, 2, ad); | |||
EAX_DECRYPT(&eaxCtx256, aes256_encrypt, length, (rdr::U8*)end, data); | |||
EAX_DECRYPT(&eaxCtx256, aes256_encrypt, length, (uint8_t*)end, data); | |||
EAX_DIGEST(&eaxCtx256, aes256_encrypt, 16, macComputed); | |||
} | |||
if (memcmp(mac, macComputed, 16) != 0) | |||
@@ -82,4 +83,4 @@ bool AESInStream::fillBuffer() | |||
return true; | |||
} | |||
#endif | |||
#endif |
@@ -29,7 +29,7 @@ namespace rdr { | |||
class AESInStream : public BufferedInStream { | |||
public: | |||
AESInStream(InStream* in, const U8* key, int keySize); | |||
AESInStream(InStream* in, const uint8_t* key, int keySize); | |||
virtual ~AESInStream(); | |||
private: | |||
@@ -41,7 +41,7 @@ namespace rdr { | |||
struct EAX_CTX(aes128_ctx) eaxCtx128; | |||
struct EAX_CTX(aes256_ctx) eaxCtx256; | |||
}; | |||
U8 counter[16]; | |||
uint8_t counter[16]; | |||
}; | |||
} | |||
@@ -29,10 +29,11 @@ using namespace rdr; | |||
const int MaxMessageSize = 8192; | |||
AESOutStream::AESOutStream(OutStream* _out, const U8* key, int _keySize) | |||
AESOutStream::AESOutStream(OutStream* _out, const uint8_t* key, | |||
int _keySize) | |||
: keySize(_keySize), out(_out), counter() | |||
{ | |||
msg = new U8[MaxMessageSize + 16 + 2]; | |||
msg = new uint8_t[MaxMessageSize + 16 + 2]; | |||
if (keySize == 128) | |||
EAX_SET_KEY(&eaxCtx128, aes128_set_encrypt_key, aes128_encrypt, key); | |||
else if (keySize == 256) | |||
@@ -71,7 +72,7 @@ bool AESOutStream::flushBuffer() | |||
} | |||
void AESOutStream::writeMessage(const U8* data, size_t length) | |||
void AESOutStream::writeMessage(const uint8_t* data, size_t length) | |||
{ | |||
msg[0] = (length & 0xff00) >> 8; | |||
msg[1] = length & 0xff; |
@@ -28,7 +28,7 @@ namespace rdr { | |||
class AESOutStream : public BufferedOutStream { | |||
public: | |||
AESOutStream(OutStream* out, const U8* key, int keySize); | |||
AESOutStream(OutStream* out, const uint8_t* key, int keySize); | |||
virtual ~AESOutStream(); | |||
virtual void flush(); | |||
@@ -36,16 +36,16 @@ namespace rdr { | |||
private: | |||
virtual bool flushBuffer(); | |||
void writeMessage(const U8* data, size_t length); | |||
void writeMessage(const uint8_t* data, size_t length); | |||
int keySize; | |||
OutStream* out; | |||
U8* msg; | |||
uint8_t* msg; | |||
union { | |||
struct EAX_CTX(aes128_ctx) eaxCtx128; | |||
struct EAX_CTX(aes256_ctx) eaxCtx256; | |||
}; | |||
U8 counter[16]; | |||
uint8_t counter[16]; | |||
}; | |||
}; | |||
@@ -34,7 +34,7 @@ static const size_t MAX_BUF_SIZE = 32 * 1024 * 1024; | |||
BufferedInStream::BufferedInStream() | |||
: bufSize(DEFAULT_BUF_SIZE), offset(0) | |||
{ | |||
ptr = end = start = new U8[bufSize]; | |||
ptr = end = start = new uint8_t[bufSize]; | |||
gettimeofday(&lastSizeCheck, NULL); | |||
peakUsage = 0; | |||
} | |||
@@ -60,7 +60,7 @@ void BufferedInStream::ensureSpace(size_t needed) | |||
if (needed > bufSize) { | |||
size_t newSize; | |||
U8* newBuffer; | |||
uint8_t* newBuffer; | |||
if (needed > MAX_BUF_SIZE) | |||
throw Exception("BufferedInStream overrun: requested size of " | |||
@@ -71,7 +71,7 @@ void BufferedInStream::ensureSpace(size_t needed) | |||
while (newSize < needed) | |||
newSize *= 2; | |||
newBuffer = new U8[newSize]; | |||
newBuffer = new uint8_t[newSize]; | |||
memcpy(newBuffer, ptr, end - ptr); | |||
delete [] start; | |||
bufSize = newSize; | |||
@@ -101,7 +101,7 @@ void BufferedInStream::ensureSpace(size_t needed) | |||
// We know the buffer is empty, so just reset everything | |||
delete [] start; | |||
ptr = end = start = new U8[newSize]; | |||
ptr = end = start = new uint8_t[newSize]; | |||
bufSize = newSize; | |||
} | |||
@@ -50,7 +50,7 @@ namespace rdr { | |||
private: | |||
size_t bufSize; | |||
size_t offset; | |||
U8* start; | |||
uint8_t* start; | |||
struct timeval lastSizeCheck; | |||
size_t peakUsage; |
@@ -34,7 +34,7 @@ static const size_t MAX_BUF_SIZE = 32 * 1024 * 1024; | |||
BufferedOutStream::BufferedOutStream(bool emulateCork) | |||
: bufSize(DEFAULT_BUF_SIZE), offset(0), emulateCork(emulateCork) | |||
{ | |||
ptr = start = sentUpTo = new U8[bufSize]; | |||
ptr = start = sentUpTo = new uint8_t[bufSize]; | |||
end = start + bufSize; | |||
gettimeofday(&lastSizeCheck, NULL); | |||
peakUsage = 0; | |||
@@ -88,7 +88,7 @@ void BufferedOutStream::flush() | |||
// We know the buffer is empty, so just reset everything | |||
delete [] start; | |||
ptr = start = sentUpTo = new U8[newSize]; | |||
ptr = start = sentUpTo = new uint8_t[newSize]; | |||
end = start + newSize; | |||
bufSize = newSize; | |||
} | |||
@@ -107,7 +107,7 @@ void BufferedOutStream::overrun(size_t needed) | |||
{ | |||
bool oldCorked; | |||
size_t totalNeeded, newSize; | |||
U8* newBuffer; | |||
uint8_t* newBuffer; | |||
// First try to get rid of the data we have | |||
// (use corked to make things a bit more efficient since we're not | |||
@@ -147,7 +147,7 @@ void BufferedOutStream::overrun(size_t needed) | |||
while (newSize < totalNeeded) | |||
newSize *= 2; | |||
newBuffer = new U8[newSize]; | |||
newBuffer = new uint8_t[newSize]; | |||
memcpy(newBuffer, sentUpTo, ptr - sentUpTo); | |||
delete [] start; | |||
bufSize = newSize; |
@@ -54,7 +54,7 @@ namespace rdr { | |||
private: | |||
size_t bufSize; | |||
size_t offset; | |||
U8* start; | |||
uint8_t* start; | |||
struct timeval lastSizeCheck; | |||
size_t peakUsage; | |||
@@ -62,7 +62,7 @@ namespace rdr { | |||
bool emulateCork; | |||
protected: | |||
U8* sentUpTo; | |||
uint8_t* sentUpTo; | |||
protected: | |||
BufferedOutStream(bool emulateCork=true); |
@@ -59,7 +59,7 @@ FdInStream::~FdInStream() | |||
bool FdInStream::fillBuffer() | |||
{ | |||
size_t n = readFd((U8*)end, availSpace()); | |||
size_t n = readFd((uint8_t*)end, availSpace()); | |||
if (n == 0) | |||
return false; | |||
end += n; |
@@ -45,7 +45,7 @@ FileInStream::~FileInStream(void) { | |||
bool FileInStream::fillBuffer() | |||
{ | |||
size_t n = fread((U8 *)end, 1, availSpace(), file); | |||
size_t n = fread((uint8_t*)end, 1, availSpace(), file); | |||
if (n == 0) { | |||
if (ferror(file)) | |||
throw SystemException("fread", errno); |
@@ -81,9 +81,9 @@ bool HexInStream::fillBuffer() { | |||
return false; | |||
size_t length = min(in_stream.avail()/2, availSpace()); | |||
const U8* iptr = in_stream.getptr(length*2); | |||
const uint8_t* iptr = in_stream.getptr(length*2); | |||
U8* optr = (U8*) end; | |||
uint8_t* optr = (uint8_t*) end; | |||
for (size_t i=0; i<length; i++) { | |||
int v = 0; | |||
readHexAndShift(iptr[i*2], &v); |
@@ -62,7 +62,7 @@ char* HexOutStream::binToHexStr(const char* data, size_t length) { | |||
bool HexOutStream::flushBuffer() | |||
{ | |||
while (sentUpTo != ptr) { | |||
U8* optr = out_stream.getptr(2); | |||
uint8_t* optr = out_stream.getptr(2); | |||
size_t length = min(ptr-sentUpTo, out_stream.avail()/2); | |||
for (size_t i=0; i<length; i++) { |
@@ -25,10 +25,11 @@ | |||
#ifndef __RDR_INSTREAM_H__ | |||
#define __RDR_INSTREAM_H__ | |||
#include <rdr/types.h> | |||
#include <rdr/Exception.h> | |||
#include <stdint.h> | |||
#include <string.h> // for memcpy | |||
#include <rdr/Exception.h> | |||
// Check that callers are using InStream properly, | |||
// useful when writing new protocol handling | |||
#ifdef _DEBUG | |||
@@ -122,16 +123,18 @@ namespace rdr { | |||
// readU/SN() methods read unsigned and signed N-bit integers. | |||
inline U8 readU8() { check(1); return *ptr++; } | |||
inline U16 readU16() { check(2); int b0 = *ptr++; int b1 = *ptr++; | |||
return b0 << 8 | b1; } | |||
inline U32 readU32() { check(4); int b0 = *ptr++; int b1 = *ptr++; | |||
int b2 = *ptr++; int b3 = *ptr++; | |||
return b0 << 24 | b1 << 16 | b2 << 8 | b3; } | |||
inline uint8_t readU8() { check(1); return *ptr++; } | |||
inline uint16_t readU16() { check(2); | |||
int b0 = *ptr++; int b1 = *ptr++; | |||
return b0 << 8 | b1; } | |||
inline uint32_t readU32() { check(4); | |||
int b0 = *ptr++; int b1 = *ptr++; | |||
int b2 = *ptr++; int b3 = *ptr++; | |||
return b0 << 24 | b1 << 16 | b2 << 8 | b3; } | |||
inline S8 readS8() { return (S8) readU8(); } | |||
inline S16 readS16() { return (S16)readU16(); } | |||
inline S32 readS32() { return (S32)readU32(); } | |||
inline int8_t readS8() { return (int8_t) readU8(); } | |||
inline int16_t readS16() { return (int16_t)readU16(); } | |||
inline int32_t readS32() { return (int32_t)readU32(); } | |||
// skip() ignores a number of bytes on the stream | |||
@@ -150,12 +153,17 @@ namespace rdr { | |||
// readOpaqueN() reads a quantity without byte-swapping. | |||
inline U8 readOpaque8() { return readU8(); } | |||
inline U16 readOpaque16() { check(2); U16 r; ((U8*)&r)[0] = *ptr++; | |||
((U8*)&r)[1] = *ptr++; return r; } | |||
inline U32 readOpaque32() { check(4); U32 r; ((U8*)&r)[0] = *ptr++; | |||
((U8*)&r)[1] = *ptr++; ((U8*)&r)[2] = *ptr++; | |||
((U8*)&r)[3] = *ptr++; return r; } | |||
inline uint8_t readOpaque8() { return readU8(); } | |||
inline uint16_t readOpaque16() { check(2); uint16_t r; | |||
((uint8_t*)&r)[0] = *ptr++; | |||
((uint8_t*)&r)[1] = *ptr++; | |||
return r; } | |||
inline uint32_t readOpaque32() { check(4); uint32_t r; | |||
((uint8_t*)&r)[0] = *ptr++; | |||
((uint8_t*)&r)[1] = *ptr++; | |||
((uint8_t*)&r)[2] = *ptr++; | |||
((uint8_t*)&r)[3] = *ptr++; | |||
return r; } | |||
// pos() returns the position in the stream. | |||
@@ -165,15 +173,15 @@ namespace rdr { | |||
// to the buffer. This is useful for a stream which is a wrapper around an | |||
// some other stream API. | |||
inline const U8* getptr(size_t length) { check(length); | |||
return ptr; } | |||
inline const uint8_t* getptr(size_t length) { check(length); | |||
return ptr; } | |||
inline void setptr(size_t length) { if (length > avail()) | |||
throw Exception("Input stream overflow"); | |||
skip(length); } | |||
private: | |||
const U8* restorePoint; | |||
const uint8_t* restorePoint; | |||
#ifdef RFB_INSTREAM_CHECK | |||
size_t checkedBytes; | |||
#endif | |||
@@ -201,8 +209,8 @@ namespace rdr { | |||
,checkedBytes(0) | |||
#endif | |||
{} | |||
const U8* ptr; | |||
const U8* end; | |||
const uint8_t* ptr; | |||
const uint8_t* end; | |||
}; | |||
} |
@@ -19,8 +19,8 @@ | |||
// | |||
// rdr::MemInStream is an InStream which streams from a given memory buffer. | |||
// If the deleteWhenDone parameter is true then the buffer will be delete[]d in | |||
// the destructor. Note that it is delete[]d as a U8* - strictly speaking this | |||
// means it ought to be new[]ed as a U8* as well, but on most platforms this | |||
// the destructor. Note that it is delete[]d as a uint8_t* - strictly speaking this | |||
// means it ought to be new[]ed as a uint8_t* as well, but on most platforms this | |||
// doesn't matter. | |||
// | |||
@@ -37,7 +37,7 @@ namespace rdr { | |||
public: | |||
MemInStream(const void* data, size_t len, bool deleteWhenDone_=false) | |||
: start((const U8*)data), deleteWhenDone(deleteWhenDone_) | |||
: start((const uint8_t*)data), deleteWhenDone(deleteWhenDone_) | |||
{ | |||
ptr = start; | |||
end = start + len; | |||
@@ -60,7 +60,7 @@ namespace rdr { | |||
private: | |||
bool overrun(size_t /*needed*/) { throw EndOfStream(); } | |||
const U8* start; | |||
const uint8_t* start; | |||
bool deleteWhenDone; | |||
}; | |||
@@ -33,7 +33,7 @@ namespace rdr { | |||
public: | |||
MemOutStream(int len=1024) { | |||
start = ptr = new U8[len]; | |||
start = ptr = new uint8_t[len]; | |||
end = start + len; | |||
} | |||
@@ -63,7 +63,7 @@ namespace rdr { | |||
if (len < (size_t)(end - start)) | |||
throw Exception("Overflow in MemOutStream::overrun()"); | |||
U8* newStart = new U8[len]; | |||
uint8_t* newStart = new uint8_t[len]; | |||
memcpy(newStart, start, ptr - start); | |||
ptr = newStart + (ptr - start); | |||
delete [] start; | |||
@@ -71,7 +71,7 @@ namespace rdr { | |||
end = newStart + len; | |||
} | |||
U8* start; | |||
uint8_t* start; | |||
}; | |||
} |
@@ -24,10 +24,11 @@ | |||
#ifndef __RDR_OUTSTREAM_H__ | |||
#define __RDR_OUTSTREAM_H__ | |||
#include <rdr/types.h> | |||
#include <stdint.h> | |||
#include <string.h> // for memcpy | |||
#include <rdr/Exception.h> | |||
#include <rdr/InStream.h> | |||
#include <string.h> // for memcpy | |||
namespace rdr { | |||
@@ -51,14 +52,17 @@ namespace rdr { | |||
// writeU/SN() methods write unsigned and signed N-bit integers. | |||
inline void writeU8( U8 u) { check(1); *ptr++ = u; } | |||
inline void writeU16(U16 u) { check(2); *ptr++ = u >> 8; *ptr++ = (U8)u; } | |||
inline void writeU32(U32 u) { check(4); *ptr++ = u >> 24; *ptr++ = u >> 16; | |||
*ptr++ = u >> 8; *ptr++ = u; } | |||
inline void writeU8( uint8_t u) { check(1); *ptr++ = u; } | |||
inline void writeU16(uint16_t u) { check(2); *ptr++ = u >> 8; | |||
*ptr++ = (uint8_t)u; } | |||
inline void writeU32(uint32_t u) { check(4); *ptr++ = u >> 24; | |||
*ptr++ = u >> 16; | |||
*ptr++ = u >> 8; | |||
*ptr++ = u; } | |||
inline void writeS8( S8 s) { writeU8((U8)s); } | |||
inline void writeS16(S16 s) { writeU16((U16)s); } | |||
inline void writeS32(S32 s) { writeU32((U32)s); } | |||
inline void writeS8( int8_t s) { writeU8((uint8_t)s); } | |||
inline void writeS16(int16_t s) { writeU16((uint16_t)s); } | |||
inline void writeS32(int32_t s) { writeU32((uint32_t)s); } | |||
inline void pad(size_t bytes) { | |||
while (bytes-- > 0) writeU8(0); | |||
@@ -74,7 +78,7 @@ namespace rdr { | |||
n = avail(); | |||
memcpy(ptr, data, n); | |||
ptr += n; | |||
data = (U8*)data + n; | |||
data = (uint8_t*)data + n; | |||
length -= n; | |||
} | |||
} | |||
@@ -95,13 +99,15 @@ namespace rdr { | |||
// writeOpaqueN() writes a quantity without byte-swapping. | |||
inline void writeOpaque8( U8 u) { writeU8(u); } | |||
inline void writeOpaque16(U16 u) { check(2); *ptr++ = ((U8*)&u)[0]; | |||
*ptr++ = ((U8*)&u)[1]; } | |||
inline void writeOpaque32(U32 u) { check(4); *ptr++ = ((U8*)&u)[0]; | |||
*ptr++ = ((U8*)&u)[1]; | |||
*ptr++ = ((U8*)&u)[2]; | |||
*ptr++ = ((U8*)&u)[3]; } | |||
inline void writeOpaque8( uint8_t u) { writeU8(u); } | |||
inline void writeOpaque16(uint16_t u) { check(2); | |||
*ptr++ = ((uint8_t*)&u)[0]; | |||
*ptr++ = ((uint8_t*)&u)[1]; } | |||
inline void writeOpaque32(uint32_t u) { check(4); | |||
*ptr++ = ((uint8_t*)&u)[0]; | |||
*ptr++ = ((uint8_t*)&u)[1]; | |||
*ptr++ = ((uint8_t*)&u)[2]; | |||
*ptr++ = ((uint8_t*)&u)[3]; } | |||
// length() returns the length of the stream. | |||
@@ -121,7 +127,7 @@ namespace rdr { | |||
// larger than the bytes actually written as doing so can result in | |||
// security issues. Use pad() in such cases instead. | |||
inline U8* getptr(size_t length) { check(length); return ptr; } | |||
inline uint8_t* getptr(size_t length) { check(length); return ptr; } | |||
inline void setptr(size_t length) { if (length > avail()) | |||
throw Exception("Output stream overflow"); | |||
ptr += length; } | |||
@@ -141,8 +147,8 @@ namespace rdr { | |||
protected: | |||
U8* ptr; | |||
U8* end; | |||
uint8_t* ptr; | |||
uint8_t* end; | |||
bool corked; | |||
}; |
@@ -86,14 +86,14 @@ RandomStream::~RandomStream() { | |||
bool RandomStream::fillBuffer() { | |||
#ifdef RFB_HAVE_WINCRYPT | |||
if (provider) { | |||
if (!CryptGenRandom(provider, availSpace(), (U8*)end)) | |||
if (!CryptGenRandom(provider, availSpace(), (uint8_t*)end)) | |||
throw rdr::SystemException("unable to CryptGenRandom", GetLastError()); | |||
end += availSpace(); | |||
} else { | |||
#else | |||
#ifndef WIN32 | |||
if (fp) { | |||
size_t n = fread((U8*)end, 1, availSpace(), fp); | |||
size_t n = fread((uint8_t*)end, 1, availSpace(), fp); | |||
if (n <= 0) | |||
throw rdr::SystemException("reading /dev/urandom or /dev/random failed", | |||
errno); | |||
@@ -104,7 +104,7 @@ bool RandomStream::fillBuffer() { | |||
#endif | |||
#endif | |||
for (size_t i=availSpace(); i>0; i--) | |||
*(U8*)end++ = (int) (256.0*rand()/(RAND_MAX+1.0)); | |||
*(uint8_t*)end++ = (int) (256.0*rand()/(RAND_MAX+1.0)); | |||
} | |||
return true; |
@@ -90,7 +90,7 @@ TLSInStream::~TLSInStream() | |||
bool TLSInStream::fillBuffer() | |||
{ | |||
size_t n = readTLS((U8*) end, availSpace()); | |||
size_t n = readTLS((uint8_t*) end, availSpace()); | |||
if (n == 0) | |||
return false; | |||
end += n; | |||
@@ -98,7 +98,7 @@ bool TLSInStream::fillBuffer() | |||
return true; | |||
} | |||
size_t TLSInStream::readTLS(U8* buf, size_t len) | |||
size_t TLSInStream::readTLS(uint8_t* buf, size_t len) | |||
{ | |||
int n; | |||
@@ -34,7 +34,7 @@ namespace rdr { | |||
private: | |||
virtual bool fillBuffer(); | |||
size_t readTLS(U8* buf, size_t len); | |||
size_t readTLS(uint8_t* buf, size_t len); | |||
static ssize_t pull(gnutls_transport_ptr_t str, void* data, size_t size); | |||
gnutls_session_t session; |
@@ -106,7 +106,7 @@ bool TLSOutStream::flushBuffer() | |||
return true; | |||
} | |||
size_t TLSOutStream::writeTLS(const U8* data, size_t length) | |||
size_t TLSOutStream::writeTLS(const uint8_t* data, size_t length) | |||
{ | |||
int n; | |||
@@ -36,7 +36,7 @@ namespace rdr { | |||
private: | |||
virtual bool flushBuffer(); | |||
size_t writeTLS(const U8* data, size_t length); | |||
size_t writeTLS(const uint8_t* data, size_t length); | |||
static ssize_t push(gnutls_transport_ptr_t str, const void* data, size_t size); | |||
gnutls_session_t session; |
@@ -94,7 +94,7 @@ bool ZlibInStream::fillBuffer() | |||
if (!underlying) | |||
throw Exception("ZlibInStream overrun: no underlying stream"); | |||
zs->next_out = (U8*)end; | |||
zs->next_out = (uint8_t*)end; | |||
zs->avail_out = availSpace(); | |||
if (!underlying->hasData(1)) | |||
@@ -102,7 +102,7 @@ bool ZlibInStream::fillBuffer() | |||
size_t length = underlying->avail(); | |||
if (length > bytesIn) | |||
length = bytesIn; | |||
zs->next_in = (U8*)underlying->getptr(length); | |||
zs->next_in = (uint8_t*)underlying->getptr(length); | |||
zs->avail_in = length; | |||
int rc = inflate(zs, Z_SYNC_FLUSH); |
@@ -19,57 +19,51 @@ | |||
#ifndef __RDR_TYPES_H__ | |||
#define __RDR_TYPES_H__ | |||
namespace rdr { | |||
#include <stdint.h> | |||
typedef unsigned char U8; | |||
typedef unsigned short U16; | |||
typedef unsigned int U32; | |||
typedef unsigned long long U64; | |||
typedef signed char S8; | |||
typedef signed short S16; | |||
typedef signed int S32; | |||
namespace rdr { | |||
class U8Array { | |||
public: | |||
U8Array() : buf(0) {} | |||
U8Array(U8* a) : buf(a) {} // note: assumes ownership | |||
U8Array(int len) : buf(new U8[len]) {} | |||
U8Array(uint8_t* a) : buf(a) {} // note: assumes ownership | |||
U8Array(int len) : buf(new uint8_t[len]) {} | |||
~U8Array() { delete [] buf; } | |||
// Get the buffer pointer & clear it (i.e. caller takes ownership) | |||
U8* takeBuf() { U8* tmp = buf; buf = 0; return tmp; } | |||
uint8_t* takeBuf() { uint8_t* tmp = buf; buf = 0; return tmp; } | |||
U8* buf; | |||
uint8_t* buf; | |||
}; | |||
class U16Array { | |||
public: | |||
U16Array() : buf(0) {} | |||
U16Array(U16* a) : buf(a) {} // note: assumes ownership | |||
U16Array(int len) : buf(new U16[len]) {} | |||
U16Array(uint16_t* a) : buf(a) {} // note: assumes ownership | |||
U16Array(int len) : buf(new uint16_t[len]) {} | |||
~U16Array() { delete [] buf; } | |||
U16* takeBuf() { U16* tmp = buf; buf = 0; return tmp; } | |||
U16* buf; | |||
uint16_t* takeBuf() { uint16_t* tmp = buf; buf = 0; return tmp; } | |||
uint16_t* buf; | |||
}; | |||
class U32Array { | |||
public: | |||
U32Array() : buf(0) {} | |||
U32Array(U32* a) : buf(a) {} // note: assumes ownership | |||
U32Array(int len) : buf(new U32[len]) {} | |||
U32Array(uint32_t* a) : buf(a) {} // note: assumes ownership | |||
U32Array(int len) : buf(new uint32_t[len]) {} | |||
~U32Array() { delete [] buf; } | |||
U32* takeBuf() { U32* tmp = buf; buf = 0; return tmp; } | |||
U32* buf; | |||
uint32_t* takeBuf() { uint32_t* tmp = buf; buf = 0; return tmp; } | |||
uint32_t* buf; | |||
}; | |||
class S32Array { | |||
public: | |||
S32Array() : buf(0) {} | |||
S32Array(S32* a) : buf(a) {} // note: assumes ownership | |||
S32Array(int len) : buf(new S32[len]) {} | |||
S32Array(int32_t* a) : buf(a) {} // note: assumes ownership | |||
S32Array(int len) : buf(new int32_t[len]) {} | |||
~S32Array() { delete [] buf; } | |||
S32* takeBuf() { S32* tmp = buf; buf = 0; return tmp; } | |||
S32* buf; | |||
int32_t* takeBuf() { int32_t* tmp = buf; buf = 0; return tmp; } | |||
int32_t* buf; | |||
}; | |||
} // end of namespace rdr |
@@ -93,10 +93,10 @@ void CConnection::setFramebuffer(ModifiablePixelBuffer* fb) | |||
if ((framebuffer != NULL) && (fb != NULL)) { | |||
Rect rect; | |||
const rdr::U8* data; | |||
const uint8_t* data; | |||
int stride; | |||
const rdr::U8 black[4] = { 0, 0, 0, 0 }; | |||
const uint8_t black[4] = { 0, 0, 0, 0 }; | |||
// Copy still valid area | |||
@@ -210,7 +210,7 @@ bool CConnection::processSecurityTypesMsg() | |||
int secType = secTypeInvalid; | |||
std::list<rdr::U8> secTypes; | |||
std::list<uint8_t> secTypes; | |||
secTypes = security.GetEnabledSecTypes(); | |||
if (server.isVersion(3,3)) { | |||
@@ -225,7 +225,7 @@ bool CConnection::processSecurityTypesMsg() | |||
state_ = RFBSTATE_SECURITY_REASON; | |||
return true; | |||
} else if (secType == secTypeNone || secType == secTypeVncAuth) { | |||
std::list<rdr::U8>::iterator i; | |||
std::list<uint8_t>::iterator i; | |||
for (i = secTypes.begin(); i != secTypes.end(); i++) | |||
if (*i == secType) { | |||
secType = *i; | |||
@@ -259,10 +259,10 @@ bool CConnection::processSecurityTypesMsg() | |||
return true; | |||
} | |||
std::list<rdr::U8>::iterator j; | |||
std::list<uint8_t>::iterator j; | |||
for (int i = 0; i < nServerSecTypes; i++) { | |||
rdr::U8 serverSecType = is->readU8(); | |||
uint8_t serverSecType = is->readU8(); | |||
vlog.debug("Server offers security type %s(%d)", | |||
secTypeName(serverSecType), serverSecType); | |||
@@ -355,7 +355,7 @@ bool CConnection::processSecurityReasonMsg() | |||
is->setRestorePoint(); | |||
rdr::U32 len = is->readU32(); | |||
uint32_t len = is->readU32(); | |||
if (!is->hasDataOrRestore(len)) | |||
return false; | |||
is->clearRestorePoint(); | |||
@@ -553,10 +553,10 @@ void CConnection::serverCutText(const char* str) | |||
handleClipboardAnnounce(true); | |||
} | |||
void CConnection::handleClipboardCaps(rdr::U32 flags, | |||
const rdr::U32* lengths) | |||
void CConnection::handleClipboardCaps(uint32_t flags, | |||
const uint32_t* lengths) | |||
{ | |||
rdr::U32 sizes[] = { 0 }; | |||
uint32_t sizes[] = { 0 }; | |||
CMsgHandler::handleClipboardCaps(flags, lengths); | |||
@@ -568,7 +568,7 @@ void CConnection::handleClipboardCaps(rdr::U32 flags, | |||
sizes); | |||
} | |||
void CConnection::handleClipboardRequest(rdr::U32 flags) | |||
void CConnection::handleClipboardRequest(uint32_t flags) | |||
{ | |||
if (!(flags & rfb::clipboardUTF8)) { | |||
vlog.debug("Ignoring clipboard request for unsupported formats 0x%x", flags); | |||
@@ -587,7 +587,7 @@ void CConnection::handleClipboardPeek() | |||
writer()->writeClipboardNotify(hasLocalClipboard ? rfb::clipboardUTF8 : 0); | |||
} | |||
void CConnection::handleClipboardNotify(rdr::U32 flags) | |||
void CConnection::handleClipboardNotify(uint32_t flags) | |||
{ | |||
strFree(serverClipboard); | |||
serverClipboard = NULL; | |||
@@ -600,9 +600,9 @@ void CConnection::handleClipboardNotify(rdr::U32 flags) | |||
} | |||
} | |||
void CConnection::handleClipboardProvide(rdr::U32 flags, | |||
void CConnection::handleClipboardProvide(uint32_t flags, | |||
const size_t* lengths, | |||
const rdr::U8* const* data) | |||
const uint8_t* const* data) | |||
{ | |||
if (!(flags & rfb::clipboardUTF8)) { | |||
vlog.debug("Ignoring clipboard provide with unsupported formats 0x%x", flags); | |||
@@ -683,7 +683,7 @@ void CConnection::sendClipboardData(const char* data) | |||
if (server.clipboardFlags() & rfb::clipboardProvide) { | |||
CharArray filtered(convertCRLF(data)); | |||
size_t sizes[1] = { strlen(filtered.buf) + 1 }; | |||
const rdr::U8* data[1] = { (const rdr::U8*)filtered.buf }; | |||
const uint8_t* data[1] = { (const uint8_t*)filtered.buf }; | |||
if (unsolicitedClipboardAttempt) { | |||
unsolicitedClipboardAttempt = false; | |||
@@ -754,7 +754,7 @@ void CConnection::setPF(const PixelFormat& pf) | |||
formatChange = true; | |||
} | |||
void CConnection::fence(rdr::U32 flags, unsigned len, const char data[]) | |||
void CConnection::fence(uint32_t flags, unsigned len, const char data[]) | |||
{ | |||
CMsgHandler::fence(flags, len, data); | |||
@@ -819,7 +819,7 @@ void CConnection::requestNewUpdate() | |||
void CConnection::updateEncodings() | |||
{ | |||
std::list<rdr::U32> encodings; | |||
std::list<uint32_t> encodings; | |||
if (supportsLocalCursor) { | |||
encodings.push_back(pseudoEncodingCursorWithAlpha); |
@@ -116,14 +116,14 @@ namespace rfb { | |||
virtual void serverCutText(const char* str); | |||
virtual void handleClipboardCaps(rdr::U32 flags, | |||
const rdr::U32* lengths); | |||
virtual void handleClipboardRequest(rdr::U32 flags); | |||
virtual void handleClipboardCaps(uint32_t flags, | |||
const uint32_t* lengths); | |||
virtual void handleClipboardRequest(uint32_t flags); | |||
virtual void handleClipboardPeek(); | |||
virtual void handleClipboardNotify(rdr::U32 flags); | |||
virtual void handleClipboardProvide(rdr::U32 flags, | |||
virtual void handleClipboardNotify(uint32_t flags); | |||
virtual void handleClipboardProvide(uint32_t flags, | |||
const size_t* lengths, | |||
const rdr::U8* const* data); | |||
const uint8_t* const* data); | |||
// Methods to be overridden in a derived class | |||
@@ -248,7 +248,7 @@ namespace rfb { | |||
// responds to requests, stating no support for synchronisation. | |||
// When overriding, call CMsgHandler::fence() directly in order to | |||
// state correct support for fence flags. | |||
virtual void fence(rdr::U32 flags, unsigned len, const char data[]); | |||
virtual void fence(uint32_t flags, unsigned len, const char data[]); | |||
private: | |||
bool processVersionMsg(); |
@@ -68,7 +68,7 @@ void CMsgHandler::setName(const char* name) | |||
server.setName(name); | |||
} | |||
void CMsgHandler::fence(rdr::U32 /*flags*/, unsigned /*len*/, | |||
void CMsgHandler::fence(uint32_t /*flags*/, unsigned /*len*/, | |||
const char /*data*/ []) | |||
{ | |||
server.supportsFence = true; | |||
@@ -106,7 +106,7 @@ void CMsgHandler::setLEDState(unsigned int state) | |||
server.setLEDState(state); | |||
} | |||
void CMsgHandler::handleClipboardCaps(rdr::U32 flags, const rdr::U32* lengths) | |||
void CMsgHandler::handleClipboardCaps(uint32_t flags, const uint32_t* lengths) | |||
{ | |||
int i; | |||
@@ -151,7 +151,7 @@ void CMsgHandler::handleClipboardCaps(rdr::U32 flags, const rdr::U32* lengths) | |||
server.setClipboardCaps(flags, lengths); | |||
} | |||
void CMsgHandler::handleClipboardRequest(rdr::U32 /*flags*/) | |||
void CMsgHandler::handleClipboardRequest(uint32_t /*flags*/) | |||
{ | |||
} | |||
@@ -159,12 +159,12 @@ void CMsgHandler::handleClipboardPeek() | |||
{ | |||
} | |||
void CMsgHandler::handleClipboardNotify(rdr::U32 /*flags*/) | |||
void CMsgHandler::handleClipboardNotify(uint32_t /*flags*/) | |||
{ | |||
} | |||
void CMsgHandler::handleClipboardProvide(rdr::U32 /*flags*/, | |||
void CMsgHandler::handleClipboardProvide(uint32_t /*flags*/, | |||
const size_t* /*lengths*/, | |||
const rdr::U8* const* /*data*/) | |||
const uint8_t* const* /*data*/) | |||
{ | |||
} |
@@ -24,7 +24,8 @@ | |||
#ifndef __RFB_CMSGHANDLER_H__ | |||
#define __RFB_CMSGHANDLER_H__ | |||
#include <rdr/types.h> | |||
#include <stdint.h> | |||
#include <rfb/Pixel.h> | |||
#include <rfb/ServerParams.h> | |||
#include <rfb/Rect.h> | |||
@@ -51,11 +52,11 @@ namespace rfb { | |||
int w, int h, | |||
const ScreenSet& layout); | |||
virtual void setCursor(int width, int height, const Point& hotspot, | |||
const rdr::U8* data) = 0; | |||
const uint8_t* data) = 0; | |||
virtual void setCursorPos(const Point& pos) = 0; | |||
virtual void setPixelFormat(const PixelFormat& pf); | |||
virtual void setName(const char* name); | |||
virtual void fence(rdr::U32 flags, unsigned len, const char data[]); | |||
virtual void fence(uint32_t flags, unsigned len, const char data[]); | |||
virtual void endOfContinuousUpdates(); | |||
virtual void supportsQEMUKeyEvent(); | |||
virtual void serverInit(int width, int height, | |||
@@ -70,20 +71,20 @@ namespace rfb { | |||
virtual bool dataRect(const Rect& r, int encoding) = 0; | |||
virtual void setColourMapEntries(int firstColour, int nColours, | |||
rdr::U16* rgbs) = 0; | |||
uint16_t* rgbs) = 0; | |||
virtual void bell() = 0; | |||
virtual void serverCutText(const char* str) = 0; | |||
virtual void setLEDState(unsigned int state); | |||
virtual void handleClipboardCaps(rdr::U32 flags, | |||
const rdr::U32* lengths); | |||
virtual void handleClipboardRequest(rdr::U32 flags); | |||
virtual void handleClipboardCaps(uint32_t flags, | |||
const uint32_t* lengths); | |||
virtual void handleClipboardRequest(uint32_t flags); | |||
virtual void handleClipboardPeek(); | |||
virtual void handleClipboardNotify(rdr::U32 flags); | |||
virtual void handleClipboardProvide(rdr::U32 flags, | |||
virtual void handleClipboardNotify(uint32_t flags); | |||
virtual void handleClipboardProvide(uint32_t flags, | |||
const size_t* lengths, | |||
const rdr::U8* const* data); | |||
const uint8_t* const* data); | |||
ServerParams server; | |||
}; |
@@ -26,6 +26,7 @@ | |||
#include <rdr/InStream.h> | |||
#include <rdr/ZlibInStream.h> | |||
#include <rdr/types.h> | |||
#include <rfb/msgTypes.h> | |||
#include <rfb/clipboardTypes.h> | |||
@@ -54,7 +55,7 @@ CMsgReader::~CMsgReader() | |||
bool CMsgReader::readServerInit() | |||
{ | |||
int width, height; | |||
rdr::U32 len; | |||
uint32_t len; | |||
if (!is->hasData(2 + 2 + 16 + 4)) | |||
return false; | |||
@@ -250,10 +251,10 @@ bool CMsgReader::readServerCutText() | |||
is->setRestorePoint(); | |||
is->skip(3); | |||
rdr::U32 len = is->readU32(); | |||
uint32_t len = is->readU32(); | |||
if (len & 0x80000000) { | |||
rdr::S32 slen = len; | |||
int32_t slen = len; | |||
slen = -slen; | |||
if (readExtendedClipboard(slen)) { | |||
is->clearRestorePoint(); | |||
@@ -281,10 +282,10 @@ bool CMsgReader::readServerCutText() | |||
return true; | |||
} | |||
bool CMsgReader::readExtendedClipboard(rdr::S32 len) | |||
bool CMsgReader::readExtendedClipboard(int32_t len) | |||
{ | |||
rdr::U32 flags; | |||
rdr::U32 action; | |||
uint32_t flags; | |||
uint32_t action; | |||
if (!is->hasData(len)) | |||
return false; | |||
@@ -303,7 +304,7 @@ bool CMsgReader::readExtendedClipboard(rdr::S32 len) | |||
if (action & clipboardCaps) { | |||
int i; | |||
size_t num; | |||
rdr::U32 lengths[16]; | |||
uint32_t lengths[16]; | |||
num = 0; | |||
for (i = 0;i < 16;i++) { | |||
@@ -311,7 +312,7 @@ bool CMsgReader::readExtendedClipboard(rdr::S32 len) | |||
num++; | |||
} | |||
if (len < (rdr::S32)(4 + 4*num)) | |||
if (len < (int32_t)(4 + 4*num)) | |||
throw Exception("Invalid extended clipboard message"); | |||
num = 0; | |||
@@ -327,7 +328,7 @@ bool CMsgReader::readExtendedClipboard(rdr::S32 len) | |||
int i; | |||
size_t num; | |||
size_t lengths[16]; | |||
rdr::U8* buffers[16]; | |||
uint8_t* buffers[16]; | |||
zis.setUnderlying(is, len - 4); | |||
@@ -368,7 +369,7 @@ bool CMsgReader::readExtendedClipboard(rdr::S32 len) | |||
if (!zis.hasData(lengths[num])) | |||
throw Exception("Extended clipboard decode error"); | |||
buffers[num] = new rdr::U8[lengths[num]]; | |||
buffers[num] = new uint8_t[lengths[num]]; | |||
zis.readBytes(buffers[num], lengths[num]); | |||
num++; | |||
} | |||
@@ -405,8 +406,8 @@ bool CMsgReader::readExtendedClipboard(rdr::S32 len) | |||
bool CMsgReader::readFence() | |||
{ | |||
rdr::U32 flags; | |||
rdr::U8 len; | |||
uint32_t flags; | |||
uint8_t len; | |||
char data[64]; | |||
if (!is->hasData(3 + 4 + 1)) | |||
@@ -479,15 +480,15 @@ bool CMsgReader::readSetXCursor(int width, int height, const Point& hotspot) | |||
rdr::U8Array rgba(width*height*4); | |||
if (width * height > 0) { | |||
rdr::U8 pr, pg, pb; | |||
rdr::U8 sr, sg, sb; | |||
uint8_t pr, pg, pb; | |||
uint8_t sr, sg, sb; | |||
int data_len = ((width+7)/8) * height; | |||
int mask_len = ((width+7)/8) * height; | |||
rdr::U8Array data(data_len); | |||
rdr::U8Array mask(mask_len); | |||
int x, y; | |||
rdr::U8* out; | |||
uint8_t* out; | |||
if (!is->hasData(3 + 3 + data_len + mask_len)) | |||
return false; | |||
@@ -547,8 +548,8 @@ bool CMsgReader::readSetCursor(int width, int height, const Point& hotspot) | |||
int x, y; | |||
rdr::U8Array rgba(width*height*4); | |||
rdr::U8* in; | |||
rdr::U8* out; | |||
uint8_t* in; | |||
uint8_t* out; | |||
if (!is->hasData(data_len + mask_len)) | |||
return false; | |||
@@ -592,7 +593,7 @@ bool CMsgReader::readSetCursorWithAlpha(int width, int height, const Point& hots | |||
bool ret; | |||
rdr::U8* buf; | |||
uint8_t* buf; | |||
int stride; | |||
// We can't use restore points as the decoder likely wants to as well, so | |||
@@ -621,7 +622,7 @@ bool CMsgReader::readSetCursorWithAlpha(int width, int height, const Point& hots | |||
assert(stride == width); | |||
for (int i = 0;i < pb.area();i++) { | |||
rdr::U8 alpha; | |||
uint8_t alpha; | |||
alpha = buf[3]; | |||
if (alpha == 0) | |||
@@ -647,7 +648,7 @@ bool CMsgReader::readSetVMwareCursor(int width, int height, const Point& hotspot | |||
if (width > maxCursorSize || height > maxCursorSize) | |||
throw Exception("Too big cursor"); | |||
rdr::U8 type; | |||
uint8_t type; | |||
if (!is->hasData(1 + 1)) | |||
return false; | |||
@@ -664,9 +665,9 @@ bool CMsgReader::readSetVMwareCursor(int width, int height, const Point& hotspot | |||
rdr::U8Array data(width*height*4); | |||
rdr::U8* andIn; | |||
rdr::U8* xorIn; | |||
rdr::U8* out; | |||
uint8_t* andIn; | |||
uint8_t* xorIn; | |||
uint8_t* out; | |||
int Bpp; | |||
if (!is->hasDataOrRestore(len + len)) | |||
@@ -690,7 +691,7 @@ bool CMsgReader::readSetVMwareCursor(int width, int height, const Point& hotspot | |||
xorIn += Bpp; | |||
if (andPixel == 0) { | |||
rdr::U8 r, g, b; | |||
uint8_t r, g, b; | |||
// Opaque pixel | |||
@@ -747,7 +748,7 @@ bool CMsgReader::readSetVMwareCursor(int width, int height, const Point& hotspot | |||
bool CMsgReader::readSetDesktopName(int x, int y, int w, int h) | |||
{ | |||
rdr::U32 len; | |||
uint32_t len; | |||
if (!is->hasData(4)) | |||
return false; | |||
@@ -776,7 +777,7 @@ bool CMsgReader::readSetDesktopName(int x, int y, int w, int h) | |||
bool CMsgReader::readExtendedDesktopSize(int x, int y, int w, int h) | |||
{ | |||
unsigned int screens, i; | |||
rdr::U32 id, flags; | |||
uint32_t id, flags; | |||
int sx, sy, sw, sh; | |||
ScreenSet layout; | |||
@@ -810,7 +811,7 @@ bool CMsgReader::readExtendedDesktopSize(int x, int y, int w, int h) | |||
bool CMsgReader::readLEDState() | |||
{ | |||
rdr::U8 state; | |||
uint8_t state; | |||
if (!is->hasData(1)) | |||
return false; | |||
@@ -824,7 +825,7 @@ bool CMsgReader::readLEDState() | |||
bool CMsgReader::readVMwareLEDState() | |||
{ | |||
rdr::U32 state; | |||
uint32_t state; | |||
if (!is->hasData(4)) | |||
return false; |
@@ -24,7 +24,7 @@ | |||
#ifndef __RFB_CMSGREADER_H__ | |||
#define __RFB_CMSGREADER_H__ | |||
#include <rdr/types.h> | |||
#include <stdint.h> | |||
#include <rfb/Rect.h> | |||
#include <rfb/encodings.h> | |||
@@ -53,7 +53,7 @@ namespace rfb { | |||
bool readSetColourMapEntries(); | |||
bool readBell(); | |||
bool readServerCutText(); | |||
bool readExtendedClipboard(rdr::S32 len); | |||
bool readExtendedClipboard(int32_t len); | |||
bool readFence(); | |||
bool readEndOfContinuousUpdates(); | |||
@@ -83,7 +83,7 @@ namespace rfb { | |||
stateEnum state; | |||
rdr::U8 currentMsgType; | |||
uint8_t currentMsgType; | |||
int nUpdateRectsLeft; | |||
Rect dataRect; | |||
int rectEncoding; |
@@ -62,9 +62,9 @@ void CMsgWriter::writeSetPixelFormat(const PixelFormat& pf) | |||
endMsg(); | |||
} | |||
void CMsgWriter::writeSetEncodings(const std::list<rdr::U32> encodings) | |||
void CMsgWriter::writeSetEncodings(const std::list<uint32_t> encodings) | |||
{ | |||
std::list<rdr::U32>::const_iterator iter; | |||
std::list<uint32_t>::const_iterator iter; | |||
startMsg(msgTypeSetEncodings); | |||
os->pad(1); | |||
os->writeU16(encodings.size()); | |||
@@ -130,7 +130,7 @@ void CMsgWriter::writeEnableContinuousUpdates(bool enable, | |||
endMsg(); | |||
} | |||
void CMsgWriter::writeFence(rdr::U32 flags, unsigned len, const char data[]) | |||
void CMsgWriter::writeFence(uint32_t flags, unsigned len, const char data[]) | |||
{ | |||
if (!server->supportsFence) | |||
throw Exception("Server does not support fences"); | |||
@@ -150,7 +150,7 @@ void CMsgWriter::writeFence(rdr::U32 flags, unsigned len, const char data[]) | |||
endMsg(); | |||
} | |||
void CMsgWriter::writeKeyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down) | |||
void CMsgWriter::writeKeyEvent(uint32_t keysym, uint32_t keycode, bool down) | |||
{ | |||
if (!server->supportsQEMUKeyEvent || !keycode) { | |||
/* This event isn't meaningful without a valid keysym */ | |||
@@ -204,8 +204,8 @@ void CMsgWriter::writeClientCutText(const char* str) | |||
endMsg(); | |||
} | |||
void CMsgWriter::writeClipboardCaps(rdr::U32 caps, | |||
const rdr::U32* lengths) | |||
void CMsgWriter::writeClipboardCaps(uint32_t caps, | |||
const uint32_t* lengths) | |||
{ | |||
size_t i, count; | |||
@@ -233,7 +233,7 @@ void CMsgWriter::writeClipboardCaps(rdr::U32 caps, | |||
endMsg(); | |||
} | |||
void CMsgWriter::writeClipboardRequest(rdr::U32 flags) | |||
void CMsgWriter::writeClipboardRequest(uint32_t flags) | |||
{ | |||
if (!(server->clipboardFlags() & clipboardRequest)) | |||
throw Exception("Server does not support clipboard \"request\" action"); | |||
@@ -245,7 +245,7 @@ void CMsgWriter::writeClipboardRequest(rdr::U32 flags) | |||
endMsg(); | |||
} | |||
void CMsgWriter::writeClipboardPeek(rdr::U32 flags) | |||
void CMsgWriter::writeClipboardPeek(uint32_t flags) | |||
{ | |||
if (!(server->clipboardFlags() & clipboardPeek)) | |||
throw Exception("Server does not support clipboard \"peek\" action"); | |||
@@ -257,7 +257,7 @@ void CMsgWriter::writeClipboardPeek(rdr::U32 flags) | |||
endMsg(); | |||
} | |||
void CMsgWriter::writeClipboardNotify(rdr::U32 flags) | |||
void CMsgWriter::writeClipboardNotify(uint32_t flags) | |||
{ | |||
if (!(server->clipboardFlags() & clipboardNotify)) | |||
throw Exception("Server does not support clipboard \"notify\" action"); | |||
@@ -269,9 +269,9 @@ void CMsgWriter::writeClipboardNotify(rdr::U32 flags) | |||
endMsg(); | |||
} | |||
void CMsgWriter::writeClipboardProvide(rdr::U32 flags, | |||
void CMsgWriter::writeClipboardProvide(uint32_t flags, | |||
const size_t* lengths, | |||
const rdr::U8* const* data) | |||
const uint8_t* const* data) | |||
{ | |||
rdr::MemOutStream mos; | |||
rdr::ZlibOutStream zos; |
@@ -25,7 +25,7 @@ | |||
#include <list> | |||
#include <rdr/types.h> | |||
#include <stdint.h> | |||
namespace rdr { class OutStream; } | |||
@@ -45,25 +45,25 @@ namespace rfb { | |||
void writeClientInit(bool shared); | |||
void writeSetPixelFormat(const PixelFormat& pf); | |||
void writeSetEncodings(const std::list<rdr::U32> encodings); | |||
void writeSetEncodings(const std::list<uint32_t> encodings); | |||
void writeSetDesktopSize(int width, int height, const ScreenSet& layout); | |||
void writeFramebufferUpdateRequest(const Rect& r,bool incremental); | |||
void writeEnableContinuousUpdates(bool enable, int x, int y, int w, int h); | |||
void writeFence(rdr::U32 flags, unsigned len, const char data[]); | |||
void writeFence(uint32_t flags, unsigned len, const char data[]); | |||
void writeKeyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down); | |||
void writeKeyEvent(uint32_t keysym, uint32_t keycode, bool down); | |||
void writePointerEvent(const Point& pos, int buttonMask); | |||
void writeClientCutText(const char* str); | |||
void writeClipboardCaps(rdr::U32 caps, const rdr::U32* lengths); | |||
void writeClipboardRequest(rdr::U32 flags); | |||
void writeClipboardPeek(rdr::U32 flags); | |||
void writeClipboardNotify(rdr::U32 flags); | |||
void writeClipboardProvide(rdr::U32 flags, const size_t* lengths, | |||
const rdr::U8* const* data); | |||
void writeClipboardCaps(uint32_t caps, const uint32_t* lengths); | |||
void writeClipboardRequest(uint32_t flags); | |||
void writeClipboardPeek(uint32_t flags); | |||
void writeClipboardNotify(uint32_t flags); | |||
void writeClipboardProvide(uint32_t flags, const size_t* lengths, | |||
const uint8_t* const* data); | |||
protected: | |||
void startMsg(int type); |
@@ -39,6 +39,7 @@ | |||
#include <rdr/InStream.h> | |||
#include <rdr/OutStream.h> | |||
#include <rdr/RandomStream.h> | |||
#include <rdr/types.h> | |||
#include <rfb/Exception.h> | |||
#include <os/os.h> | |||
@@ -83,7 +84,7 @@ bool CSecurityDH::readKey() | |||
if (!is->hasData(4)) | |||
return false; | |||
is->setRestorePoint(); | |||
rdr::U16 gen = is->readU16(); | |||
uint16_t gen = is->readU16(); | |||
keyLength = is->readU16(); | |||
if (keyLength < MinKeyLength) | |||
throw AuthFailureException("DH key is too short"); | |||
@@ -121,7 +122,7 @@ void CSecurityDH::writeCredentials() | |||
rdr::U8Array BBytes(keyLength); | |||
nettle_mpz_get_str_256(keyLength, sharedSecret.buf, k); | |||
nettle_mpz_get_str_256(keyLength, BBytes.buf, B); | |||
rdr::U8 key[16]; | |||
uint8_t key[16]; | |||
struct md5_ctx md5Ctx; | |||
md5_init(&md5Ctx); | |||
md5_update(&md5Ctx, keyLength, sharedSecret.buf); | |||
@@ -141,7 +142,7 @@ void CSecurityDH::writeCredentials() | |||
if (len >= 64) | |||
throw AuthFailureException("password is too long"); | |||
memcpy(buf + 64, password.buf, len + 1); | |||
aes128_encrypt(&aesCtx, 128, (rdr::U8 *)buf, (rdr::U8 *)buf); | |||
aes128_encrypt(&aesCtx, 128, (uint8_t *)buf, (uint8_t *)buf); | |||
rdr::OutStream* os = cc->getOutStream(); | |||
os->writeBytes(buf, 128); |
@@ -39,6 +39,7 @@ | |||
#include <rdr/InStream.h> | |||
#include <rdr/OutStream.h> | |||
#include <rdr/RandomStream.h> | |||
#include <rdr/types.h> | |||
#include <rfb/Exception.h> | |||
#include <os/os.h> | |||
@@ -79,9 +80,9 @@ bool CSecurityMSLogonII::readKey() | |||
rdr::InStream* is = cc->getInStream(); | |||
if (!is->hasData(24)) | |||
return false; | |||
rdr::U8 gBytes[8]; | |||
rdr::U8 pBytes[8]; | |||
rdr::U8 ABytes[8]; | |||
uint8_t gBytes[8]; | |||
uint8_t pBytes[8]; | |||
uint8_t ABytes[8]; | |||
is->readBytes(gBytes, 8); | |||
is->readBytes(pBytes, 8); | |||
is->readBytes(ABytes, 8); | |||
@@ -106,15 +107,15 @@ void CSecurityMSLogonII::writeCredentials() | |||
mpz_powm(k, A, b, p); | |||
mpz_powm(B, g, b, p); | |||
rdr::U8 key[8]; | |||
rdr::U8 reversedKey[8]; | |||
rdr::U8 BBytes[8]; | |||
rdr::U8 user[256]; | |||
rdr::U8 pass[64]; | |||
uint8_t key[8]; | |||
uint8_t reversedKey[8]; | |||
uint8_t BBytes[8]; | |||
uint8_t user[256]; | |||
uint8_t pass[64]; | |||
nettle_mpz_get_str_256(8, key, k); | |||
nettle_mpz_get_str_256(8, BBytes, B); | |||
for (int i = 0; i < 8; ++i) { | |||
rdr::U8 x = 0; | |||
uint8_t x = 0; | |||
for (int j = 0; j < 8; ++j) { | |||
x |= ((key[i] >> j) & 1) << (7 - j); | |||
} |
@@ -55,7 +55,7 @@ const int MaxKeyLength = 8192; | |||
using namespace rfb; | |||
CSecurityRSAAES::CSecurityRSAAES(CConnection* cc, rdr::U32 _secType, | |||
CSecurityRSAAES::CSecurityRSAAES(CConnection* cc, uint32_t _secType, | |||
int _keySize, bool _isAllEncrypted) | |||
: CSecurity(cc), state(ReadPublicKey), | |||
keySize(_keySize), isAllEncrypted(_isAllEncrypted), secType(_secType), | |||
@@ -155,8 +155,8 @@ void CSecurityRSAAES::writePublicKey() | |||
if (!rsa_generate_keypair(&clientPublicKey, &clientKey, | |||
&rs, random_func, NULL, NULL, clientKeyLength, 0)) | |||
throw AuthFailureException("failed to generate key"); | |||
clientKeyN = new rdr::U8[rsaKeySize]; | |||
clientKeyE = new rdr::U8[rsaKeySize]; | |||
clientKeyN = new uint8_t[rsaKeySize]; | |||
clientKeyE = new uint8_t[rsaKeySize]; | |||
nettle_mpz_get_str_256(rsaKeySize, clientKeyN, clientPublicKey.n); | |||
nettle_mpz_get_str_256(rsaKeySize, clientKeyE, clientPublicKey.e); | |||
os->writeU32(clientKeyLength); | |||
@@ -180,8 +180,8 @@ bool CSecurityRSAAES::readPublicKey() | |||
if (!is->hasDataOrRestore(size * 2)) | |||
return false; | |||
is->clearRestorePoint(); | |||
serverKeyE = new rdr::U8[size]; | |||
serverKeyN = new rdr::U8[size]; | |||
serverKeyE = new uint8_t[size]; | |||
serverKeyN = new uint8_t[size]; | |||
is->readBytes(serverKeyN, size); | |||
is->readBytes(serverKeyE, size); | |||
rsa_public_key_init(&serverKey); | |||
@@ -194,13 +194,13 @@ bool CSecurityRSAAES::readPublicKey() | |||
void CSecurityRSAAES::verifyServer() | |||
{ | |||
rdr::U8 lenServerKey[4] = { | |||
(rdr::U8)((serverKeyLength & 0xff000000) >> 24), | |||
(rdr::U8)((serverKeyLength & 0xff0000) >> 16), | |||
(rdr::U8)((serverKeyLength & 0xff00) >> 8), | |||
(rdr::U8)(serverKeyLength & 0xff) | |||
uint8_t lenServerKey[4] = { | |||
(uint8_t)((serverKeyLength & 0xff000000) >> 24), | |||
(uint8_t)((serverKeyLength & 0xff0000) >> 16), | |||
(uint8_t)((serverKeyLength & 0xff00) >> 8), | |||
(uint8_t)(serverKeyLength & 0xff) | |||
}; | |||
rdr::U8 f[8]; | |||
uint8_t f[8]; | |||
struct sha1_ctx ctx; | |||
sha1_init(&ctx); | |||
sha1_update(&ctx, 4, lenServerKey); | |||
@@ -238,7 +238,7 @@ void CSecurityRSAAES::writeRandom() | |||
mpz_clear(x); | |||
throw AuthFailureException("failed to encrypt random"); | |||
} | |||
rdr::U8* buffer = new rdr::U8[serverKey.size]; | |||
uint8_t* buffer = new uint8_t[serverKey.size]; | |||
nettle_mpz_get_str_256(serverKey.size, buffer, x); | |||
mpz_clear(x); | |||
os->writeU16(serverKey.size); | |||
@@ -259,7 +259,7 @@ bool CSecurityRSAAES::readRandom() | |||
if (!is->hasDataOrRestore(size)) | |||
return false; | |||
is->clearRestorePoint(); | |||
rdr::U8* buffer = new rdr::U8[size]; | |||
uint8_t* buffer = new uint8_t[size]; | |||
is->readBytes(buffer, size); | |||
size_t randomSize = keySize / 8; | |||
mpz_t x; | |||
@@ -278,7 +278,7 @@ void CSecurityRSAAES::setCipher() | |||
{ | |||
rawis = cc->getInStream(); | |||
rawos = cc->getOutStream(); | |||
rdr::U8 key[32]; | |||
uint8_t key[32]; | |||
if (keySize == 128) { | |||
struct sha1_ctx ctx; | |||
sha1_init(&ctx); | |||
@@ -310,20 +310,20 @@ void CSecurityRSAAES::setCipher() | |||
void CSecurityRSAAES::writeHash() | |||
{ | |||
rdr::U8 hash[32]; | |||
uint8_t hash[32]; | |||
size_t len = serverKeyLength; | |||
rdr::U8 lenServerKey[4] = { | |||
(rdr::U8)((len & 0xff000000) >> 24), | |||
(rdr::U8)((len & 0xff0000) >> 16), | |||
(rdr::U8)((len & 0xff00) >> 8), | |||
(rdr::U8)(len & 0xff) | |||
uint8_t lenServerKey[4] = { | |||
(uint8_t)((len & 0xff000000) >> 24), | |||
(uint8_t)((len & 0xff0000) >> 16), | |||
(uint8_t)((len & 0xff00) >> 8), | |||
(uint8_t)(len & 0xff) | |||
}; | |||
len = clientKeyLength; | |||
rdr::U8 lenClientKey[4] = { | |||
(rdr::U8)((len & 0xff000000) >> 24), | |||
(rdr::U8)((len & 0xff0000) >> 16), | |||
(rdr::U8)((len & 0xff00) >> 8), | |||
(rdr::U8)(len & 0xff) | |||
uint8_t lenClientKey[4] = { | |||
(uint8_t)((len & 0xff000000) >> 24), | |||
(uint8_t)((len & 0xff0000) >> 16), | |||
(uint8_t)((len & 0xff00) >> 8), | |||
(uint8_t)(len & 0xff) | |||
}; | |||
int hashSize; | |||
if (keySize == 128) { | |||
@@ -355,25 +355,25 @@ void CSecurityRSAAES::writeHash() | |||
bool CSecurityRSAAES::readHash() | |||
{ | |||
rdr::U8 hash[32]; | |||
rdr::U8 realHash[32]; | |||
uint8_t hash[32]; | |||
uint8_t realHash[32]; | |||
int hashSize = keySize == 128 ? 20 : 32; | |||
if (!rais->hasData(hashSize)) | |||
return false; | |||
rais->readBytes(hash, hashSize); | |||
size_t len = serverKeyLength; | |||
rdr::U8 lenServerKey[4] = { | |||
(rdr::U8)((len & 0xff000000) >> 24), | |||
(rdr::U8)((len & 0xff0000) >> 16), | |||
(rdr::U8)((len & 0xff00) >> 8), | |||
(rdr::U8)(len & 0xff) | |||
uint8_t lenServerKey[4] = { | |||
(uint8_t)((len & 0xff000000) >> 24), | |||
(uint8_t)((len & 0xff0000) >> 16), | |||
(uint8_t)((len & 0xff00) >> 8), | |||
(uint8_t)(len & 0xff) | |||
}; | |||
len = clientKeyLength; | |||
rdr::U8 lenClientKey[4] = { | |||
(rdr::U8)((len & 0xff000000) >> 24), | |||
(rdr::U8)((len & 0xff0000) >> 16), | |||
(rdr::U8)((len & 0xff00) >> 8), | |||
(rdr::U8)(len & 0xff) | |||
uint8_t lenClientKey[4] = { | |||
(uint8_t)((len & 0xff000000) >> 24), | |||
(uint8_t)((len & 0xff0000) >> 16), | |||
(uint8_t)((len & 0xff00) >> 8), | |||
(uint8_t)(len & 0xff) | |||
}; | |||
if (keySize == 128) { | |||
struct sha1_ctx ctx; | |||
@@ -458,4 +458,4 @@ void CSecurityRSAAES::writeCredentials() | |||
if (len) | |||
raos->writeBytes(password.buf, len); | |||
raos->flush(); | |||
} | |||
} |
@@ -36,7 +36,7 @@ namespace rfb { | |||
class UserMsgBox; | |||
class CSecurityRSAAES : public CSecurity { | |||
public: | |||
CSecurityRSAAES(CConnection* cc, rdr::U32 secType, | |||
CSecurityRSAAES(CConnection* cc, uint32_t secType, | |||
int keySize, bool isAllEncrypted); | |||
virtual ~CSecurityRSAAES(); | |||
virtual bool processMsg(); | |||
@@ -62,19 +62,19 @@ namespace rfb { | |||
int state; | |||
int keySize; | |||
bool isAllEncrypted; | |||
rdr::U32 secType; | |||
rdr::U8 subtype; | |||
uint32_t secType; | |||
uint8_t subtype; | |||
struct rsa_private_key clientKey; | |||
struct rsa_public_key clientPublicKey; | |||
struct rsa_public_key serverKey; | |||
rdr::U32 serverKeyLength; | |||
rdr::U8* serverKeyN; | |||
rdr::U8* serverKeyE; | |||
rdr::U32 clientKeyLength; | |||
rdr::U8* clientKeyN; | |||
rdr::U8* clientKeyE; | |||
rdr::U8 serverRandom[32]; | |||
rdr::U8 clientRandom[32]; | |||
uint32_t serverKeyLength; | |||
uint8_t* serverKeyN; | |||
uint8_t* serverKeyE; | |||
uint32_t clientKeyLength; | |||
uint8_t* clientKeyN; | |||
uint8_t* clientKeyE; | |||
uint8_t serverRandom[32]; | |||
uint8_t clientRandom[32]; | |||
rdr::InStream* rais; | |||
rdr::OutStream* raos; |
@@ -86,7 +86,8 @@ bool CSecurityVeNCrypt::processMsg() | |||
} | |||
/* major version in upper 8 bits and minor version in lower 8 bits */ | |||
U16 Version = (((U16) majorVersion) << 8) | ((U16) minorVersion); | |||
uint16_t Version = (((uint16_t) majorVersion) << 8) | | |||
((uint16_t) minorVersion); | |||
if (!haveSentVersion) { | |||
/* Currently we don't support former VeNCrypt 0.1 */ | |||
@@ -131,7 +132,7 @@ bool CSecurityVeNCrypt::processMsg() | |||
if (!nAvailableTypes) | |||
throw AuthFailureException("The server reported no VeNCrypt sub-types"); | |||
availableTypes = new rdr::U32[nAvailableTypes]; | |||
availableTypes = new uint32_t[nAvailableTypes]; | |||
haveNumberOfTypes = true; | |||
} | |||
@@ -154,9 +155,9 @@ bool CSecurityVeNCrypt::processMsg() | |||
/* make a choice and send it to the server, meanwhile set up the stack */ | |||
if (!haveChosenType) { | |||
chosenType = secTypeInvalid; | |||
U8 i; | |||
list<U32>::iterator j; | |||
list<U32> secTypes; | |||
uint8_t i; | |||
list<uint32_t>::iterator j; | |||
list<uint32_t> secTypes; | |||
secTypes = security->GetEnabledExtSecTypes(); | |||
@@ -25,9 +25,10 @@ | |||
#ifndef __CSECURITYVENCRYPT_H__ | |||
#define __CSECURITYVENCRYPT_H__ | |||
#include <stdint.h> | |||
#include <rfb/CSecurity.h> | |||
#include <rfb/SecurityClient.h> | |||
#include <rdr/types.h> | |||
namespace rfb { | |||
@@ -50,10 +51,10 @@ namespace rfb { | |||
bool haveListOfTypes; | |||
bool haveNumberOfTypes; | |||
bool haveChosenType; | |||
rdr::U8 majorVersion, minorVersion; | |||
rdr::U32 chosenType; | |||
rdr::U8 nAvailableTypes; | |||
rdr::U32 *availableTypes; | |||
uint8_t majorVersion, minorVersion; | |||
uint32_t chosenType; | |||
uint8_t nAvailableTypes; | |||
uint32_t *availableTypes; | |||
}; | |||
} | |||
#endif |
@@ -53,13 +53,13 @@ bool CSecurityVncAuth::processMsg() | |||
return false; | |||
// Read the challenge & obtain the user's password | |||
rdr::U8 challenge[vncAuthChallengeSize]; | |||
uint8_t challenge[vncAuthChallengeSize]; | |||
is->readBytes(challenge, vncAuthChallengeSize); | |||
PlainPasswd passwd; | |||
(CSecurity::upg)->getUserPasswd(cc->isSecure(), 0, &passwd.buf); | |||
// Calculate the correct response | |||
rdr::U8 key[8]; | |||
uint8_t key[8]; | |||
int pwdLen = strlen(passwd.buf); | |||
for (int i=0; i<8; i++) | |||
key[i] = i<pwdLen ? passwd.buf[i] : 0; |
@@ -95,12 +95,12 @@ void ClientParams::setCursorPos(const Point& pos) | |||
cursorPos_ = pos; | |||
} | |||
bool ClientParams::supportsEncoding(rdr::S32 encoding) const | |||
bool ClientParams::supportsEncoding(int32_t encoding) const | |||
{ | |||
return encodings_.count(encoding) != 0; | |||
} | |||
void ClientParams::setEncodings(int nEncodings, const rdr::S32* encodings) | |||
void ClientParams::setEncodings(int nEncodings, const int32_t* encodings) | |||
{ | |||
compressLevel = -1; | |||
qualityLevel = -1; | |||
@@ -153,7 +153,7 @@ void ClientParams::setLEDState(unsigned int state) | |||
ledState_ = state; | |||
} | |||
rdr::U32 ClientParams::clipboardSize(unsigned int format) const | |||
uint32_t ClientParams::clipboardSize(unsigned int format) const | |||
{ | |||
int i; | |||
@@ -165,7 +165,7 @@ rdr::U32 ClientParams::clipboardSize(unsigned int format) const | |||
throw Exception("Invalid clipboard format 0x%x", format); | |||
} | |||
void ClientParams::setClipboardCaps(rdr::U32 flags, const rdr::U32* lengths) | |||
void ClientParams::setClipboardCaps(uint32_t flags, const uint32_t* lengths) | |||
{ | |||
int i, num; | |||
@@ -25,7 +25,8 @@ | |||
#include <set> | |||
#include <rdr/types.h> | |||
#include <stdint.h> | |||
#include <rfb/Cursor.h> | |||
#include <rfb/PixelFormat.h> | |||
#include <rfb/ScreenSet.h> | |||
@@ -80,16 +81,16 @@ namespace rfb { | |||
const Point& cursorPos() const { return cursorPos_; } | |||
void setCursorPos(const Point& pos); | |||
bool supportsEncoding(rdr::S32 encoding) const; | |||
bool supportsEncoding(int32_t encoding) const; | |||
void setEncodings(int nEncodings, const rdr::S32* encodings); | |||
void setEncodings(int nEncodings, const int32_t* encodings); | |||
unsigned int ledState() { return ledState_; } | |||
void setLEDState(unsigned int state); | |||
rdr::U32 clipboardFlags() const { return clipFlags; } | |||
rdr::U32 clipboardSize(unsigned int format) const; | |||
void setClipboardCaps(rdr::U32 flags, const rdr::U32* lengths); | |||
uint32_t clipboardFlags() const { return clipFlags; } | |||
uint32_t clipboardSize(unsigned int format) const; | |||
void setClipboardCaps(uint32_t flags, const uint32_t* lengths); | |||
// Wrappers to check for functionality rather than specific | |||
// encodings | |||
@@ -115,10 +116,10 @@ namespace rfb { | |||
char* name_; | |||
Cursor* cursor_; | |||
Point cursorPos_; | |||
std::set<rdr::S32> encodings_; | |||
std::set<int32_t> encodings_; | |||
unsigned int ledState_; | |||
rdr::U32 clipFlags; | |||
rdr::U32 clipSizes[16]; | |||
uint32_t clipFlags; | |||
uint32_t clipSizes[16]; | |||
}; | |||
} | |||
#endif |
@@ -23,7 +23,7 @@ | |||
#include <stdio.h> | |||
#include <string.h> | |||
#include <vector> | |||
#include <rdr/types.h> | |||
#include <rfb/Exception.h> | |||
#include <rfb/LogWriter.h> | |||
#include <rfb/ComparingUpdateTracker.h> | |||
@@ -62,7 +62,7 @@ bool ComparingUpdateTracker::compare() | |||
for (int y=0; y<fb->height(); y+=BLOCK_SIZE) { | |||
Rect pos(0, y, fb->width(), __rfbmin(fb->height(), y+BLOCK_SIZE)); | |||
int srcStride; | |||
const rdr::U8* srcData = fb->getBuffer(pos, &srcStride); | |||
const uint8_t* srcData = fb->getBuffer(pos, &srcStride); | |||
oldFb.imageRect(pos, srcData, srcStride); | |||
} | |||
@@ -122,7 +122,7 @@ void ComparingUpdateTracker::compareRect(const Rect& r, Region* newChanged) | |||
int bytesPerPixel = fb->getPF().bpp/8; | |||
int oldStride; | |||
rdr::U8* oldData = oldFb.getBufferRW(r, &oldStride); | |||
uint8_t* oldData = oldFb.getBufferRW(r, &oldStride); | |||
int oldStrideBytes = oldStride * bytesPerPixel; | |||
// Used to efficiently crop the left and right of the change rectangle | |||
@@ -134,16 +134,16 @@ void ComparingUpdateTracker::compareRect(const Rect& r, Region* newChanged) | |||
// Get a strip of the source buffer | |||
Rect pos(r.tl.x, blockTop, r.br.x, __rfbmin(r.br.y, blockTop+BLOCK_SIZE)); | |||
int fbStride; | |||
const rdr::U8* newBlockPtr = fb->getBuffer(pos, &fbStride); | |||
const uint8_t* newBlockPtr = fb->getBuffer(pos, &fbStride); | |||
int newStrideBytes = fbStride * bytesPerPixel; | |||
rdr::U8* oldBlockPtr = oldData; | |||
uint8_t* oldBlockPtr = oldData; | |||
int blockBottom = __rfbmin(blockTop+BLOCK_SIZE, r.br.y); | |||
for (int blockLeft = r.tl.x; blockLeft < r.br.x; blockLeft += BLOCK_SIZE) | |||
{ | |||
const rdr::U8* newPtr = newBlockPtr; | |||
rdr::U8* oldPtr = oldBlockPtr; | |||
const uint8_t* newPtr = newBlockPtr; | |||
uint8_t* oldPtr = oldBlockPtr; | |||
int blockRight = __rfbmin(blockLeft+BLOCK_SIZE, r.br.x); | |||
int blockWidthInBytes = (blockRight-blockLeft) * bytesPerPixel; | |||
@@ -160,8 +160,8 @@ void ComparingUpdateTracker::compareRect(const Rect& r, Region* newChanged) | |||
// For every unchanged row at the bottom of the block, decrement change height | |||
{ | |||
const rdr::U8* newRowPtr = newPtr + ((changeHeight - 1) * newStrideBytes); | |||
const rdr::U8* oldRowPtr = oldPtr + ((changeHeight - 1) * oldStrideBytes); | |||
const uint8_t* newRowPtr = newPtr + ((changeHeight - 1) * newStrideBytes); | |||
const uint8_t* oldRowPtr = oldPtr + ((changeHeight - 1) * oldStrideBytes); | |||
while (changeHeight > 1 && memcmp(oldRowPtr, newRowPtr, blockWidthInBytes) == 0) | |||
{ | |||
newRowPtr -= newStrideBytes; | |||
@@ -173,12 +173,12 @@ void ComparingUpdateTracker::compareRect(const Rect& r, Region* newChanged) | |||
// For every unchanged column at the left of the block, increment change left | |||
{ | |||
const rdr::U8* newColumnPtr = newPtr; | |||
const rdr::U8* oldColumnPtr = oldPtr; | |||
const uint8_t* newColumnPtr = newPtr; | |||
const uint8_t* oldColumnPtr = oldPtr; | |||
while (changeLeft + minCompareWidthInPixels < changeRight) | |||
{ | |||
const rdr::U8* newRowPtr = newColumnPtr; | |||
const rdr::U8* oldRowPtr = oldColumnPtr; | |||
const uint8_t* newRowPtr = newColumnPtr; | |||
const uint8_t* oldRowPtr = oldColumnPtr; | |||
for (int row = 0; row < changeHeight; row++) | |||
{ | |||
if (memcmp(oldRowPtr, newRowPtr, minCompareWidthInBytes) != 0) | |||
@@ -198,15 +198,15 @@ void ComparingUpdateTracker::compareRect(const Rect& r, Region* newChanged) | |||
// For every unchanged column at the right of the block, decrement change right | |||
{ | |||
const rdr::U8* newColumnPtr = newPtr + blockWidthInBytes; | |||
const rdr::U8* oldColumnPtr = oldPtr + blockWidthInBytes; | |||
const uint8_t* newColumnPtr = newPtr + blockWidthInBytes; | |||
const uint8_t* oldColumnPtr = oldPtr + blockWidthInBytes; | |||
while (changeLeft + minCompareWidthInPixels < changeRight) | |||
{ | |||
newColumnPtr -= minCompareWidthInBytes; | |||
oldColumnPtr -= minCompareWidthInBytes; | |||
const rdr::U8* newRowPtr = newColumnPtr; | |||
const rdr::U8* oldRowPtr = oldColumnPtr; | |||
const uint8_t* newRowPtr = newColumnPtr; | |||
const uint8_t* oldRowPtr = oldColumnPtr; | |||
for (int row = 0; row < changeHeight; row++) | |||
{ | |||
if (memcmp(oldRowPtr, newRowPtr, minCompareWidthInBytes) != 0) |
@@ -23,6 +23,7 @@ | |||
#include <assert.h> | |||
#include <string.h> | |||
#include <rdr/types.h> | |||
#include <rfb/Cursor.h> | |||
#include <rfb/LogWriter.h> | |||
#include <rfb/Exception.h> | |||
@@ -32,10 +33,10 @@ using namespace rfb; | |||
static LogWriter vlog("Cursor"); | |||
Cursor::Cursor(int width, int height, const Point& hotspot, | |||
const rdr::U8* data) : | |||
const uint8_t* data) : | |||
width_(width), height_(height), hotspot_(hotspot) | |||
{ | |||
this->data = new rdr::U8[width_*height_*4]; | |||
this->data = new uint8_t[width_*height_*4]; | |||
memcpy(this->data, data, width_*height_*4); | |||
} | |||
@@ -43,7 +44,7 @@ Cursor::Cursor(const Cursor& other) : | |||
width_(other.width_), height_(other.height_), | |||
hotspot_(other.hotspot_) | |||
{ | |||
data = new rdr::U8[width_*height_*4]; | |||
data = new uint8_t[width_*height_*4]; | |||
memcpy(data, other.data, width_*height_*4); | |||
} | |||
@@ -81,7 +82,7 @@ static unsigned short srgb_to_lin(unsigned char srgb) | |||
} | |||
// Floyd-Steinberg dithering | |||
static void dither(int width, int height, rdr::S32* data) | |||
static void dither(int width, int height, int32_t* data) | |||
{ | |||
for (int y = 0; y < height; y++) { | |||
for (int x_ = 0; x_ < width; x_++) { | |||
@@ -124,21 +125,21 @@ static void dither(int width, int height, rdr::S32* data) | |||
} | |||
} | |||
rdr::U8* Cursor::getBitmap() const | |||
uint8_t* Cursor::getBitmap() const | |||
{ | |||
// First step is converting to luminance | |||
rdr::S32Array luminance(width()*height()); | |||
rdr::S32 *lum_ptr = luminance.buf; | |||
const rdr::U8 *data_ptr = data; | |||
int32_t *lum_ptr = luminance.buf; | |||
const uint8_t *data_ptr = data; | |||
for (int y = 0; y < height(); y++) { | |||
for (int x = 0; x < width(); x++) { | |||
rdr::S32 lum; | |||
int32_t lum; | |||
// Use BT.709 coefficients for grayscale | |||
lum = 0; | |||
lum += (rdr::U32)srgb_to_lin(data_ptr[0]) * 6947; // 0.2126 | |||
lum += (rdr::U32)srgb_to_lin(data_ptr[1]) * 23436; // 0.7152 | |||
lum += (rdr::U32)srgb_to_lin(data_ptr[2]) * 2366; // 0.0722 | |||
lum += (uint32_t)srgb_to_lin(data_ptr[0]) * 6947; // 0.2126 | |||
lum += (uint32_t)srgb_to_lin(data_ptr[1]) * 23436; // 0.7152 | |||
lum += (uint32_t)srgb_to_lin(data_ptr[2]) * 2366; // 0.0722 | |||
lum /= 32768; | |||
*lum_ptr++ = lum; | |||
@@ -169,15 +170,15 @@ rdr::U8* Cursor::getBitmap() const | |||
return source.takeBuf(); | |||
} | |||
rdr::U8* Cursor::getMask() const | |||
uint8_t* Cursor::getMask() const | |||
{ | |||
// First step is converting to integer array | |||
rdr::S32Array alpha(width()*height()); | |||
rdr::S32 *alpha_ptr = alpha.buf; | |||
const rdr::U8 *data_ptr = data; | |||
int32_t *alpha_ptr = alpha.buf; | |||
const uint8_t *data_ptr = data; | |||
for (int y = 0; y < height(); y++) { | |||
for (int x = 0; x < width(); x++) { | |||
*alpha_ptr++ = (rdr::U32)data_ptr[3] * 65535 / 255; | |||
*alpha_ptr++ = (uint32_t)data_ptr[3] * 65535 / 255; | |||
data_ptr += 4; | |||
} | |||
} | |||
@@ -217,7 +218,7 @@ void Cursor::crop() | |||
busy = busy.intersect(Rect(hotspot_.x, hotspot_.y, | |||
hotspot_.x+1, hotspot_.y+1)); | |||
int x, y; | |||
rdr::U8 *data_ptr = data; | |||
uint8_t *data_ptr = data; | |||
for (y = 0; y < height(); y++) { | |||
for (x = 0; x < width(); x++) { | |||
if (data_ptr[3] > 0) { | |||
@@ -234,7 +235,7 @@ void Cursor::crop() | |||
// Copy the pixel data | |||
int newDataLen = busy.area() * 4; | |||
rdr::U8* newData = new rdr::U8[newDataLen]; | |||
uint8_t* newData = new uint8_t[newDataLen]; | |||
data_ptr = newData; | |||
for (y = busy.tl.y; y < busy.br.y; y++) { | |||
memcpy(data_ptr, data + y*width()*4 + busy.tl.x*4, busy.width()*4); | |||
@@ -253,7 +254,7 @@ RenderedCursor::RenderedCursor() | |||
{ | |||
} | |||
const rdr::U8* RenderedCursor::getBuffer(const Rect& _r, int* stride) const | |||
const uint8_t* RenderedCursor::getBuffer(const Rect& _r, int* stride) const | |||
{ | |||
Rect r; | |||
@@ -270,7 +271,7 @@ void RenderedCursor::update(PixelBuffer* framebuffer, | |||
Point rawOffset, diff; | |||
Rect clippedRect; | |||
const rdr::U8* data; | |||
const uint8_t* data; | |||
int stride; | |||
assert(framebuffer); | |||
@@ -300,8 +301,8 @@ void RenderedCursor::update(PixelBuffer* framebuffer, | |||
for (int y = 0;y < buffer.height();y++) { | |||
for (int x = 0;x < buffer.width();x++) { | |||
size_t idx; | |||
rdr::U8 bg[4], fg[4]; | |||
rdr::U8 rgb[3]; | |||
uint8_t bg[4], fg[4]; | |||
uint8_t rgb[3]; | |||
idx = (y+diff.y)*cursor->width() + (x+diff.x); | |||
memcpy(fg, cursor->getBuffer() + idx*4, 4); |
@@ -30,19 +30,19 @@ namespace rfb { | |||
class Cursor { | |||
public: | |||
Cursor(int width, int height, const Point& hotspot, const rdr::U8* data); | |||
Cursor(int width, int height, const Point& hotspot, const uint8_t* data); | |||
Cursor(const Cursor& other); | |||
~Cursor(); | |||
int width() const { return width_; }; | |||
int height() const { return height_; }; | |||
const Point& hotspot() const { return hotspot_; }; | |||
const rdr::U8* getBuffer() const { return data; }; | |||
const uint8_t* getBuffer() const { return data; }; | |||
// getBitmap() returns a monochrome version of the cursor | |||
rdr::U8* getBitmap() const; | |||
uint8_t* getBitmap() const; | |||
// getMask() returns a simple mask version of the alpha channel | |||
rdr::U8* getMask() const; | |||
uint8_t* getMask() const; | |||
// crop() crops the cursor down to the smallest possible size, based on the | |||
// mask. | |||
@@ -51,7 +51,7 @@ namespace rfb { | |||
protected: | |||
int width_, height_; | |||
Point hotspot_; | |||
rdr::U8* data; | |||
uint8_t* data; | |||
}; | |||
class RenderedCursor : public PixelBuffer { | |||
@@ -60,7 +60,7 @@ namespace rfb { | |||
Rect getEffectiveRect() const { return buffer.getRect(offset); } | |||
virtual const rdr::U8* getBuffer(const Rect& r, int* stride) const; | |||
virtual const uint8_t* getBuffer(const Rect& r, int* stride) const; | |||
void update(PixelBuffer* framebuffer, Cursor* cursor, const Point& pos); | |||
@@ -377,7 +377,7 @@ void EncodeManager::prepareEncoders(bool allowLossy) | |||
bool allowJPEG; | |||
rdr::S32 preferred; | |||
int32_t preferred; | |||
std::vector<int>::iterator iter; | |||
@@ -678,8 +678,8 @@ void EncodeManager::findSolidRect(const Rect& rect, Region *changed, | |||
for (dx = rect.tl.x; dx < rect.br.x; dx += SolidSearchBlock) { | |||
// We define it like this to guarantee alignment | |||
rdr::U32 _buffer; | |||
rdr::U8* colourValue = (rdr::U8*)&_buffer; | |||
uint32_t _buffer; | |||
uint8_t* colourValue = (uint8_t*)&_buffer; | |||
dw = SolidSearchBlock; | |||
if (dx + dw > rect.br.x) | |||
@@ -718,8 +718,8 @@ void EncodeManager::findSolidRect(const Rect& rect, Region *changed, | |||
encoder->writeSolidRect(erp.width(), erp.height(), | |||
pb->getPF(), colourValue); | |||
} else { | |||
rdr::U32 _buffer2; | |||
rdr::U8* converted = (rdr::U8*)&_buffer2; | |||
uint32_t _buffer2; | |||
uint8_t* converted = (uint8_t*)&_buffer2; | |||
conn->client.pf().bufferFromBuffer(converted, pb->getPF(), | |||
colourValue, 1); | |||
@@ -886,21 +886,21 @@ void EncodeManager::writeSubRect(const Rect& rect, const PixelBuffer *pb) | |||
endRect(); | |||
} | |||
bool EncodeManager::checkSolidTile(const Rect& r, const rdr::U8* colourValue, | |||
bool EncodeManager::checkSolidTile(const Rect& r, const uint8_t* colourValue, | |||
const PixelBuffer *pb) | |||
{ | |||
switch (pb->getPF().bpp) { | |||
case 32: | |||
return checkSolidTile(r, *(const rdr::U32*)colourValue, pb); | |||
return checkSolidTile(r, *(const uint32_t*)colourValue, pb); | |||
case 16: | |||
return checkSolidTile(r, *(const rdr::U16*)colourValue, pb); | |||
return checkSolidTile(r, *(const uint16_t*)colourValue, pb); | |||
default: | |||
return checkSolidTile(r, *(const rdr::U8*)colourValue, pb); | |||
return checkSolidTile(r, *(const uint8_t*)colourValue, pb); | |||
} | |||
} | |||
void EncodeManager::extendSolidAreaByBlock(const Rect& r, | |||
const rdr::U8* colourValue, | |||
const uint8_t* colourValue, | |||
const PixelBuffer *pb, Rect* er) | |||
{ | |||
int dx, dy, dw, dh; | |||
@@ -956,7 +956,7 @@ void EncodeManager::extendSolidAreaByBlock(const Rect& r, | |||
} | |||
void EncodeManager::extendSolidAreaByPixel(const Rect& r, const Rect& sr, | |||
const rdr::U8* colourValue, | |||
const uint8_t* colourValue, | |||
const PixelBuffer *pb, Rect* er) | |||
{ | |||
int cx, cy; | |||
@@ -999,7 +999,7 @@ PixelBuffer* EncodeManager::preparePixelBuffer(const Rect& rect, | |||
const PixelBuffer *pb, | |||
bool convert) | |||
{ | |||
const rdr::U8* buffer; | |||
const uint8_t* buffer; | |||
int stride; | |||
// Do wo need to convert the data? | |||
@@ -1029,7 +1029,7 @@ PixelBuffer* EncodeManager::preparePixelBuffer(const Rect& rect, | |||
bool EncodeManager::analyseRect(const PixelBuffer *pb, | |||
struct RectInfo *info, int maxColours) | |||
{ | |||
const rdr::U8* buffer; | |||
const uint8_t* buffer; | |||
int stride; | |||
buffer = pb->getBuffer(pb->getRect(), &stride); | |||
@@ -1037,30 +1037,30 @@ bool EncodeManager::analyseRect(const PixelBuffer *pb, | |||
switch (pb->getPF().bpp) { | |||
case 32: | |||
return analyseRect(pb->width(), pb->height(), | |||
(const rdr::U32*)buffer, stride, | |||
(const uint32_t*)buffer, stride, | |||
info, maxColours); | |||
case 16: | |||
return analyseRect(pb->width(), pb->height(), | |||
(const rdr::U16*)buffer, stride, | |||
(const uint16_t*)buffer, stride, | |||
info, maxColours); | |||
default: | |||
return analyseRect(pb->width(), pb->height(), | |||
(const rdr::U8*)buffer, stride, | |||
(const uint8_t*)buffer, stride, | |||
info, maxColours); | |||
} | |||
} | |||
void EncodeManager::OffsetPixelBuffer::update(const PixelFormat& pf, | |||
int width, int height, | |||
const rdr::U8* data_, | |||
const uint8_t* data_, | |||
int stride_) | |||
{ | |||
format = pf; | |||
// Forced cast. We never write anything though, so it should be safe. | |||
setBuffer(width, height, (rdr::U8*)data_, stride_); | |||
setBuffer(width, height, (uint8_t*)data_, stride_); | |||
} | |||
rdr::U8* EncodeManager::OffsetPixelBuffer::getBufferRW(const Rect& /*r*/, int* /*stride*/) | |||
uint8_t* EncodeManager::OffsetPixelBuffer::getBufferRW(const Rect& /*r*/, int* /*stride*/) | |||
{ | |||
throw rfb::Exception("Invalid write attempt to OffsetPixelBuffer"); | |||
} |
@@ -22,7 +22,8 @@ | |||
#include <vector> | |||
#include <rdr/types.h> | |||
#include <stdint.h> | |||
#include <rfb/PixelBuffer.h> | |||
#include <rfb/Region.h> | |||
#include <rfb/Timer.h> | |||
@@ -82,12 +83,12 @@ namespace rfb { | |||
void writeSubRect(const Rect& rect, const PixelBuffer *pb); | |||
bool checkSolidTile(const Rect& r, const rdr::U8* colourValue, | |||
bool checkSolidTile(const Rect& r, const uint8_t* colourValue, | |||
const PixelBuffer *pb); | |||
void extendSolidAreaByBlock(const Rect& r, const rdr::U8* colourValue, | |||
void extendSolidAreaByBlock(const Rect& r, const uint8_t* colourValue, | |||
const PixelBuffer *pb, Rect* er); | |||
void extendSolidAreaByPixel(const Rect& r, const Rect& sr, | |||
const rdr::U8* colourValue, | |||
const uint8_t* colourValue, | |||
const PixelBuffer *pb, Rect* er); | |||
PixelBuffer* preparePixelBuffer(const Rect& rect, | |||
@@ -138,10 +139,10 @@ namespace rfb { | |||
virtual ~OffsetPixelBuffer() {} | |||
void update(const PixelFormat& pf, int width, int height, | |||
const rdr::U8* data_, int stride); | |||
const uint8_t* data_, int stride); | |||
private: | |||
virtual rdr::U8* getBufferRW(const Rect& r, int* stride); | |||
virtual uint8_t* getBufferRW(const Rect& r, int* stride); | |||
}; | |||
OffsetPixelBuffer offsetPixelBuffer; |
@@ -41,12 +41,12 @@ Encoder::~Encoder() | |||
} | |||
void Encoder::writeSolidRect(int width, int height, | |||
const PixelFormat& pf, const rdr::U8* colour) | |||
const PixelFormat& pf, const uint8_t* colour) | |||
{ | |||
ManagedPixelBuffer buffer(pf, width, height); | |||
Palette palette; | |||
rdr::U32 palcol; | |||
uint32_t palcol; | |||
buffer.fillRect(buffer.getRect(), colour); | |||
@@ -59,27 +59,27 @@ void Encoder::writeSolidRect(int width, int height, | |||
void Encoder::writeSolidRect(const PixelBuffer* pb, const Palette& palette) | |||
{ | |||
rdr::U32 col32; | |||
rdr::U16 col16; | |||
rdr::U8 col8; | |||
uint32_t col32; | |||
uint16_t col16; | |||
uint8_t col8; | |||
rdr::U8* buffer; | |||
uint8_t* buffer; | |||
assert(palette.size() == 1); | |||
// The Palette relies on implicit up and down conversion | |||
switch (pb->getPF().bpp) { | |||
case 32: | |||
col32 = (rdr::U32)palette.getColour(0); | |||
buffer = (rdr::U8*)&col32; | |||
col32 = (uint32_t)palette.getColour(0); | |||
buffer = (uint8_t*)&col32; | |||
break; | |||
case 16: | |||
col16 = (rdr::U16)palette.getColour(0); | |||
buffer = (rdr::U8*)&col16; | |||
col16 = (uint16_t)palette.getColour(0); | |||
buffer = (uint8_t*)&col16; | |||
break; | |||
default: | |||
col8 = (rdr::U8)palette.getColour(0); | |||
buffer = (rdr::U8*)&col8; | |||
col8 = (uint8_t)palette.getColour(0); | |||
buffer = (uint8_t*)&col8; | |||
break; | |||
} | |||
@@ -20,7 +20,8 @@ | |||
#ifndef __RFB_ENCODER_H__ | |||
#define __RFB_ENCODER_H__ | |||
#include <rdr/types.h> | |||
#include <stdint.h> | |||
#include <rfb/Rect.h> | |||
namespace rfb { | |||
@@ -83,7 +84,7 @@ namespace rfb { | |||
// efficient short cut. | |||
virtual void writeSolidRect(int width, int height, | |||
const PixelFormat& pf, | |||
const rdr::U8* colour)=0; | |||
const uint8_t* colour)=0; | |||
protected: | |||
// Helper method for redirecting a single colour palette to the |
@@ -70,7 +70,7 @@ bool H264Decoder::readRect(const Rect& /*r*/, | |||
const ServerParams& /*server*/, | |||
rdr::OutStream* os) | |||
{ | |||
rdr::U32 len; | |||
uint32_t len; | |||
if (!is->hasData(8)) | |||
return false; | |||
@@ -79,7 +79,7 @@ bool H264Decoder::readRect(const Rect& /*r*/, | |||
len = is->readU32(); | |||
os->writeU32(len); | |||
rdr::U32 flags = is->readU32(); | |||
uint32_t flags = is->readU32(); | |||
os->writeU32(flags); | |||
@@ -99,8 +99,8 @@ void H264Decoder::decodeRect(const Rect& r, const void* buffer, | |||
ModifiablePixelBuffer* pb) | |||
{ | |||
rdr::MemInStream is(buffer, buflen); | |||
rdr::U32 len = is.readU32(); | |||
rdr::U32 flags = is.readU32(); | |||
uint32_t len = is.readU32(); | |||
uint32_t flags = is.readU32(); | |||
H264DecoderContext* ctx = NULL; | |||
if (flags & resetAllContexts) |
@@ -21,8 +21,9 @@ | |||
#ifndef __RFB_H264DECODERCONTEXT_H__ | |||
#define __RFB_H264DECODERCONTEXT_H__ | |||
#include <stdint.h> | |||
#include <os/Mutex.h> | |||
#include <rdr/types.h> | |||
#include <rfb/Rect.h> | |||
#include <rfb/Decoder.h> | |||
@@ -33,8 +34,8 @@ namespace rfb { | |||
virtual ~H264DecoderContext() = 0; | |||
virtual void decode(const rdr::U8* /*h264_buffer*/, | |||
rdr::U32 /*len*/, | |||
virtual void decode(const uint8_t* /*h264_buffer*/, | |||
uint32_t /*len*/, | |||
ModifiablePixelBuffer* /*pb*/) {} | |||
void reset(); | |||
@@ -110,13 +110,13 @@ void H264LibavDecoderContext::freeCodec() { | |||
// We need to reallocate buffer because AVPacket uses non-const pointer. | |||
// We don't want to const_cast our buffer somewhere. So we would rather to maintain context's own buffer | |||
// Also avcodec requires a right padded buffer | |||
rdr::U8* H264LibavDecoderContext::makeH264WorkBuffer(const rdr::U8* buffer, rdr::U32 len) | |||
uint8_t* H264LibavDecoderContext::makeH264WorkBuffer(const uint8_t* buffer, uint32_t len) | |||
{ | |||
rdr::U32 reserve_len = len + len % AV_INPUT_BUFFER_PADDING_SIZE; | |||
uint32_t reserve_len = len + len % AV_INPUT_BUFFER_PADDING_SIZE; | |||
if (!h264WorkBuffer || reserve_len > h264WorkBufferLength) | |||
{ | |||
h264WorkBuffer = (rdr::U8*)realloc(h264WorkBuffer, reserve_len); | |||
h264WorkBuffer = (uint8_t*)realloc(h264WorkBuffer, reserve_len); | |||
if (h264WorkBuffer == NULL) { | |||
throw Exception("H264LibavDecoderContext: Unable to allocate memory"); | |||
} | |||
@@ -128,13 +128,13 @@ rdr::U8* H264LibavDecoderContext::makeH264WorkBuffer(const rdr::U8* buffer, rdr: | |||
return h264WorkBuffer; | |||
} | |||
void H264LibavDecoderContext::decode(const rdr::U8* h264_in_buffer, | |||
rdr::U32 len, | |||
void H264LibavDecoderContext::decode(const uint8_t* h264_in_buffer, | |||
uint32_t len, | |||
ModifiablePixelBuffer* pb) { | |||
os::AutoMutex lock(&mutex); | |||
if (!initialized) | |||
return; | |||
rdr::U8* h264_work_buffer = makeH264WorkBuffer(h264_in_buffer, len); | |||
uint8_t* h264_work_buffer = makeH264WorkBuffer(h264_in_buffer, len); | |||
#ifdef FFMPEG_INIT_PACKET_DEPRECATED | |||
AVPacket *packet = av_packet_alloc(); | |||
@@ -154,7 +154,7 @@ void H264LibavDecoderContext::decode(const rdr::U8* h264_in_buffer, | |||
break; | |||
} | |||
// We need to slap on tv to make it work here (don't ask me why) | |||
if (!packet->size && len == static_cast<rdr::U32>(ret)) | |||
if (!packet->size && len == static_cast<uint32_t>(ret)) | |||
ret = av_parser_parse2(parser, avctx, &packet->data, &packet->size, h264_work_buffer, len, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0); | |||
if (ret < 0) | |||
{ |
@@ -34,7 +34,7 @@ namespace rfb { | |||
H264LibavDecoderContext(const Rect &r) : H264DecoderContext(r) {} | |||
~H264LibavDecoderContext() { freeCodec(); } | |||
virtual void decode(const rdr::U8* h264_buffer, rdr::U32 len, | |||
virtual void decode(const uint8_t* h264_buffer, uint32_t len, | |||
ModifiablePixelBuffer* pb); | |||
protected: | |||
@@ -42,15 +42,15 @@ namespace rfb { | |||
virtual void freeCodec(); | |||
private: | |||
rdr::U8* makeH264WorkBuffer(const rdr::U8* buffer, rdr::U32 len); | |||
uint8_t* makeH264WorkBuffer(const uint8_t* buffer, uint32_t len); | |||
AVCodecContext *avctx; | |||
AVCodecParserContext *parser; | |||
AVFrame* frame; | |||
SwsContext* sws; | |||
uint8_t* swsBuffer; | |||
rdr::U8* h264WorkBuffer; | |||
rdr::U32 h264WorkBufferLength; | |||
uint8_t* h264WorkBuffer; | |||
uint32_t h264WorkBufferLength; | |||
}; | |||
} | |||
@@ -154,8 +154,8 @@ void H264WinDecoderContext::freeCodec() { | |||
initialized = false; | |||
} | |||
void H264WinDecoderContext::decode(const rdr::U8* h264_buffer, | |||
rdr::U32 len, | |||
void H264WinDecoderContext::decode(const uint8_t* h264_buffer, | |||
uint32_t len, | |||
ModifiablePixelBuffer* pb) { | |||
os::AutoMutex lock(&mutex); | |||
if (!initialized) | |||
@@ -351,7 +351,7 @@ void H264WinDecoderContext::decode(const rdr::U8* h264_buffer, | |||
} | |||
// "7.3.2.1.1 Sequence parameter set data syntax" on page 66 of https://www.itu.int/rec/T-REC-H.264-202108-I/en | |||
void H264WinDecoderContext::ParseSPS(const rdr::U8* buffer, int length) | |||
void H264WinDecoderContext::ParseSPS(const uint8_t* buffer, int length) | |||
{ | |||
#define EXPECT(cond) if (!(cond)) return; | |||
@@ -404,14 +404,14 @@ void H264WinDecoderContext::ParseSPS(const rdr::U8* buffer, int length) | |||
// NAL unit type | |||
EXPECT(length > 1); | |||
rdr::U8 type = buffer[0]; | |||
uint8_t type = buffer[0]; | |||
EXPECT((type & 0x80) == 0); // forbidden zero bit | |||
EXPECT((type & 0x1f) == 7); // SPS NAL unit type | |||
buffer++; | |||
length--; | |||
int available = 0; | |||
rdr::U8 byte = 0; | |||
uint8_t byte = 0; | |||
unsigned profile_idc; | |||
unsigned seq_parameter_set_id; |
@@ -33,7 +33,7 @@ namespace rfb { | |||
H264WinDecoderContext(const Rect &r) : H264DecoderContext(r) {}; | |||
~H264WinDecoderContext() { freeCodec(); } | |||
virtual void decode(const rdr::U8* h264_buffer, rdr::U32 len, | |||
virtual void decode(const uint8_t* h264_buffer, uint32_t len, | |||
ModifiablePixelBuffer* pb); | |||
protected: | |||
@@ -42,12 +42,12 @@ namespace rfb { | |||
private: | |||
LONG stride; | |||
rdr::U32 full_width = 0; | |||
rdr::U32 full_height = 0; | |||
rdr::U32 crop_width = 0; | |||
rdr::U32 crop_height = 0; | |||
rdr::U32 offset_x = 0; | |||
rdr::U32 offset_y = 0; | |||
uint32_t full_width = 0; | |||
uint32_t full_height = 0; | |||
uint32_t crop_width = 0; | |||
uint32_t crop_height = 0; | |||
uint32_t offset_x = 0; | |||
uint32_t offset_y = 0; | |||
IMFTransform *decoder = NULL; | |||
IMFTransform *converter = NULL; | |||
IMFSample *input_sample = NULL; | |||
@@ -57,7 +57,7 @@ namespace rfb { | |||
IMFMediaBuffer *decoded_buffer = NULL; | |||
IMFMediaBuffer *converted_buffer = NULL; | |||
void ParseSPS(const rdr::U8* buffer, int length); | |||
void ParseSPS(const uint8_t* buffer, int length); | |||
}; | |||
} | |||
@@ -56,7 +56,7 @@ bool HextileDecoder::readRect(const Rect& r, rdr::InStream* is, | |||
t.br.y = __rfbmin(r.br.y, t.tl.y + 16); | |||
for (t.tl.x = r.tl.x; t.tl.x < r.br.x; t.tl.x += 16) { | |||
rdr::U8 tileType; | |||
uint8_t tileType; | |||
t.br.x = __rfbmin(r.br.x, t.tl.x + 16); | |||
@@ -87,7 +87,7 @@ bool HextileDecoder::readRect(const Rect& r, rdr::InStream* is, | |||
} | |||
if (tileType & hextileAnySubrects) { | |||
rdr::U8 nSubrects; | |||
uint8_t nSubrects; | |||
if (!is->hasDataOrRestore(1)) | |||
return false; | |||
@@ -120,9 +120,9 @@ void HextileDecoder::decodeRect(const Rect& r, const void* buffer, | |||
rdr::MemInStream is(buffer, buflen); | |||
const PixelFormat& pf = server.pf(); | |||
switch (pf.bpp) { | |||
case 8: hextileDecode<rdr::U8 >(r, &is, pf, pb); break; | |||
case 16: hextileDecode<rdr::U16>(r, &is, pf, pb); break; | |||
case 32: hextileDecode<rdr::U32>(r, &is, pf, pb); break; | |||
case 8: hextileDecode<uint8_t >(r, &is, pf, pb); break; | |||
case 16: hextileDecode<uint16_t>(r, &is, pf, pb); break; | |||
case 32: hextileDecode<uint32_t>(r, &is, pf, pb); break; | |||
} | |||
} | |||
@@ -59,23 +59,23 @@ void HextileEncoder::writeRect(const PixelBuffer* pb, | |||
switch (pb->getPF().bpp) { | |||
case 8: | |||
if (improvedHextile) { | |||
hextileEncodeBetter<rdr::U8>(os, pb); | |||
hextileEncodeBetter<uint8_t>(os, pb); | |||
} else { | |||
hextileEncode<rdr::U8>(os, pb); | |||
hextileEncode<uint8_t>(os, pb); | |||
} | |||
break; | |||
case 16: | |||
if (improvedHextile) { | |||
hextileEncodeBetter<rdr::U16>(os, pb); | |||
hextileEncodeBetter<uint16_t>(os, pb); | |||
} else { | |||
hextileEncode<rdr::U16>(os, pb); | |||
hextileEncode<uint16_t>(os, pb); | |||
} | |||
break; | |||
case 32: | |||
if (improvedHextile) { | |||
hextileEncodeBetter<rdr::U32>(os, pb); | |||
hextileEncodeBetter<uint32_t>(os, pb); | |||
} else { | |||
hextileEncode<rdr::U32>(os, pb); | |||
hextileEncode<uint32_t>(os, pb); | |||
} | |||
break; | |||
} | |||
@@ -83,7 +83,7 @@ void HextileEncoder::writeRect(const PixelBuffer* pb, | |||
void HextileEncoder::writeSolidRect(int width, int height, | |||
const PixelFormat& pf, | |||
const rdr::U8* colour) | |||
const uint8_t* colour) | |||
{ | |||
rdr::OutStream* os; | |||
int tiles; | |||
@@ -120,7 +120,7 @@ void HextileEncoder::hextileEncode(rdr::OutStream* os, | |||
T oldBg = 0, oldFg = 0; | |||
bool oldBgValid = false; | |||
bool oldFgValid = false; | |||
rdr::U8 encoded[256*sizeof(T)]; | |||
uint8_t encoded[256*sizeof(T)]; | |||
for (t.tl.y = 0; t.tl.y < pb->height(); t.tl.y += 16) { | |||
@@ -177,10 +177,10 @@ void HextileEncoder::hextileEncode(rdr::OutStream* os, | |||
template<class T> | |||
int HextileEncoder::hextileEncodeTile(T* data, int w, int h, | |||
int tileType, rdr::U8* encoded, | |||
int tileType, uint8_t* encoded, | |||
T bg) | |||
{ | |||
rdr::U8* nSubrectsPtr = encoded; | |||
uint8_t* nSubrectsPtr = encoded; | |||
*nSubrectsPtr = 0; | |||
encoded++; | |||
@@ -220,13 +220,13 @@ int HextileEncoder::hextileEncodeTile(T* data, int w, int h, | |||
if (sizeof(T) == 1) { | |||
*encoded++ = *data; | |||
} else if (sizeof(T) == 2) { | |||
*encoded++ = ((rdr::U8*)data)[0]; | |||
*encoded++ = ((rdr::U8*)data)[1]; | |||
*encoded++ = ((uint8_t*)data)[0]; | |||
*encoded++ = ((uint8_t*)data)[1]; | |||
} else if (sizeof(T) == 4) { | |||
*encoded++ = ((rdr::U8*)data)[0]; | |||
*encoded++ = ((rdr::U8*)data)[1]; | |||
*encoded++ = ((rdr::U8*)data)[2]; | |||
*encoded++ = ((rdr::U8*)data)[3]; | |||
*encoded++ = ((uint8_t*)data)[0]; | |||
*encoded++ = ((uint8_t*)data)[1]; | |||
*encoded++ = ((uint8_t*)data)[2]; | |||
*encoded++ = ((uint8_t*)data)[3]; | |||
} | |||
} | |||
@@ -334,7 +334,7 @@ class HextileTile { | |||
// big enough to store at least the number of bytes returned by the | |||
// getSize() method. | |||
// | |||
void encode(rdr::U8* dst) const; | |||
void encode(uint8_t* dst) const; | |||
protected: | |||
@@ -353,7 +353,7 @@ class HextileTile { | |||
T m_foreground; | |||
int m_numSubrects; | |||
rdr::U8 m_coords[256 * 2]; | |||
uint8_t m_coords[256 * 2]; | |||
T m_colors[256]; | |||
private: | |||
@@ -403,7 +403,7 @@ void HextileTile<T>::analyze() | |||
int y = (ptr - m_tile) / m_width; | |||
T *colorsPtr = m_colors; | |||
rdr::U8 *coordsPtr = m_coords; | |||
uint8_t *coordsPtr = m_coords; | |||
m_pal.clear(); | |||
m_numSubrects = 0; | |||
@@ -411,7 +411,7 @@ void HextileTile<T>::analyze() | |||
if (y > 0) { | |||
*colorsPtr++ = color; | |||
*coordsPtr++ = 0; | |||
*coordsPtr++ = (rdr::U8)(((m_width - 1) << 4) | ((y - 1) & 0x0F)); | |||
*coordsPtr++ = (uint8_t)(((m_width - 1) << 4) | ((y - 1) & 0x0F)); | |||
m_pal.insert(color, 1); | |||
m_numSubrects++; | |||
} | |||
@@ -445,8 +445,8 @@ void HextileTile<T>::analyze() | |||
// Save properties of this subrect | |||
*colorsPtr++ = color; | |||
*coordsPtr++ = (rdr::U8)((x << 4) | (y & 0x0F)); | |||
*coordsPtr++ = (rdr::U8)(((sw - 1) << 4) | ((sh - 1) & 0x0F)); | |||
*coordsPtr++ = (uint8_t)((x << 4) | (y & 0x0F)); | |||
*coordsPtr++ = (uint8_t)(((sw - 1) << 4) | ((sh - 1) & 0x0F)); | |||
if (!m_pal.insert(color, 1) || | |||
((size_t)m_pal.size() > (48 + 2 * sizeof(T)*8))) { | |||
@@ -489,12 +489,12 @@ void HextileTile<T>::analyze() | |||
} | |||
template<class T> | |||
void HextileTile<T>::encode(rdr::U8 *dst) const | |||
void HextileTile<T>::encode(uint8_t *dst) const | |||
{ | |||
assert(m_numSubrects && (m_flags & hextileAnySubrects)); | |||
// Zero subrects counter | |||
rdr::U8 *numSubrectsPtr = dst; | |||
uint8_t *numSubrectsPtr = dst; | |||
*dst++ = 0; | |||
for (int i = 0; i < m_numSubrects; i++) { | |||
@@ -505,13 +505,13 @@ void HextileTile<T>::encode(rdr::U8 *dst) const | |||
if (sizeof(T) == 1) { | |||
*dst++ = m_colors[i]; | |||
} else if (sizeof(T) == 2) { | |||
*dst++ = ((rdr::U8*)&m_colors[i])[0]; | |||
*dst++ = ((rdr::U8*)&m_colors[i])[1]; | |||
*dst++ = ((uint8_t*)&m_colors[i])[0]; | |||
*dst++ = ((uint8_t*)&m_colors[i])[1]; | |||
} else if (sizeof(T) == 4) { | |||
*dst++ = ((rdr::U8*)&m_colors[i])[0]; | |||
*dst++ = ((rdr::U8*)&m_colors[i])[1]; | |||
*dst++ = ((rdr::U8*)&m_colors[i])[2]; | |||
*dst++ = ((rdr::U8*)&m_colors[i])[3]; | |||
*dst++ = ((uint8_t*)&m_colors[i])[0]; | |||
*dst++ = ((uint8_t*)&m_colors[i])[1]; | |||
*dst++ = ((uint8_t*)&m_colors[i])[2]; | |||
*dst++ = ((uint8_t*)&m_colors[i])[3]; | |||
} | |||
} | |||
*dst++ = m_coords[i * 2]; | |||
@@ -536,7 +536,7 @@ void HextileEncoder::hextileEncodeBetter(rdr::OutStream* os, | |||
T oldBg = 0, oldFg = 0; | |||
bool oldBgValid = false; | |||
bool oldFgValid = false; | |||
rdr::U8 encoded[256*sizeof(T)]; | |||
uint8_t encoded[256*sizeof(T)]; | |||
HextileTile<T> tile; | |||
@@ -31,7 +31,7 @@ namespace rfb { | |||
virtual void writeRect(const PixelBuffer* pb, const Palette& palette); | |||
virtual void writeSolidRect(int width, int height, | |||
const PixelFormat& pf, | |||
const rdr::U8* colour); | |||
const uint8_t* colour); | |||
private: | |||
template<class T> | |||
inline void writePixel(rdr::OutStream* os, T pixel); | |||
@@ -40,7 +40,7 @@ namespace rfb { | |||
void hextileEncode(rdr::OutStream* os, const PixelBuffer* pb); | |||
template<class T> | |||
int hextileEncodeTile(T* data, int w, int h, int tileType, | |||
rdr::U8* encoded, T bg); | |||
uint8_t* encoded, T bg); | |||
template<class T> | |||
int testTileType(T* data, int w, int h, T* bg, T* fg); | |||
@@ -23,7 +23,8 @@ | |||
#ifndef __RFB_INPUTHANDLER_H__ | |||
#define __RFB_INPUTHANDLER_H__ | |||
#include <rdr/types.h> | |||
#include <stdint.h> | |||
#include <rfb/Rect.h> | |||
#include <rfb/util.h> | |||
@@ -32,7 +33,7 @@ namespace rfb { | |||
class InputHandler { | |||
public: | |||
virtual ~InputHandler() {} | |||
virtual void keyEvent(rdr::U32 /*keysym*/, rdr::U32 /*keycode*/, | |||
virtual void keyEvent(uint32_t /*keysym*/, uint32_t /*keycode*/, | |||
bool /*down*/) { } | |||
virtual void pointerEvent(const Point& /*pos*/, | |||
int /*buttonMask*/) { } |
@@ -155,14 +155,14 @@ JpegCompressor::~JpegCompressor(void) | |||
delete cinfo; | |||
} | |||
void JpegCompressor::compress(const rdr::U8 *buf, volatile int stride, | |||
void JpegCompressor::compress(const uint8_t *buf, volatile int stride, | |||
const Rect& r, const PixelFormat& pf, | |||
int quality, int subsamp) | |||
{ | |||
int w = r.width(); | |||
int h = r.height(); | |||
int pixelsize; | |||
rdr::U8 * volatile srcBuf = NULL; | |||
uint8_t * volatile srcBuf = NULL; | |||
volatile bool srcBufIsTemp = false; | |||
JSAMPROW * volatile rowPointer = NULL; | |||
@@ -192,7 +192,7 @@ void JpegCompressor::compress(const rdr::U8 *buf, volatile int stride, | |||
cinfo->in_color_space = JCS_EXT_XBGR; | |||
if (cinfo->in_color_space != JCS_RGB) { | |||
srcBuf = (rdr::U8 *)buf; | |||
srcBuf = (uint8_t *)buf; | |||
pixelsize = 4; | |||
} | |||
#endif | |||
@@ -201,9 +201,9 @@ void JpegCompressor::compress(const rdr::U8 *buf, volatile int stride, | |||
stride = w; | |||
if (cinfo->in_color_space == JCS_RGB) { | |||
srcBuf = new rdr::U8[w * h * pixelsize]; | |||
srcBuf = new uint8_t[w * h * pixelsize]; | |||
srcBufIsTemp = true; | |||
pf.rgbFromBuffer(srcBuf, (const rdr::U8 *)buf, w, stride, h); | |||
pf.rgbFromBuffer(srcBuf, (const uint8_t *)buf, w, stride, h); | |||
stride = w; | |||
} | |||
@@ -43,7 +43,7 @@ namespace rfb { | |||
JpegCompressor(int bufferLen = 128*1024); | |||
virtual ~JpegCompressor(); | |||
void compress(const rdr::U8 *, int, const Rect&, const PixelFormat&, int, int); | |||
void compress(const uint8_t *, int, const Rect&, const PixelFormat&, int, int); | |||
void writeBytes(const void*, int); | |||
@@ -150,8 +150,8 @@ JpegDecompressor::~JpegDecompressor(void) | |||
delete dinfo; | |||
} | |||
void JpegDecompressor::decompress(const rdr::U8 *jpegBuf, | |||
int jpegBufLen, rdr::U8 *buf, | |||
void JpegDecompressor::decompress(const uint8_t *jpegBuf, | |||
int jpegBufLen, uint8_t *buf, | |||
volatile int stride, | |||
const Rect& r, const PixelFormat& pf) | |||
{ | |||
@@ -159,7 +159,7 @@ void JpegDecompressor::decompress(const rdr::U8 *jpegBuf, | |||
int h = r.height(); | |||
int pixelsize; | |||
int dstBufStride; | |||
rdr::U8 * volatile dstBuf = NULL; | |||
uint8_t * volatile dstBuf = NULL; | |||
volatile bool dstBufIsTemp = false; | |||
JSAMPROW * volatile rowPointer = NULL; | |||
@@ -194,13 +194,13 @@ void JpegDecompressor::decompress(const rdr::U8 *jpegBuf, | |||
dinfo->out_color_space = JCS_EXT_XBGR; | |||
if (dinfo->out_color_space != JCS_RGB) { | |||
dstBuf = (rdr::U8 *)buf; | |||
dstBuf = (uint8_t *)buf; | |||
pixelsize = 4; | |||
} | |||
#endif | |||
if (dinfo->out_color_space == JCS_RGB) { | |||
dstBuf = new rdr::U8[w * h * pixelsize]; | |||
dstBuf = new uint8_t[w * h * pixelsize]; | |||
dstBufIsTemp = true; | |||
dstBufStride = w; | |||
} | |||
@@ -226,7 +226,7 @@ void JpegDecompressor::decompress(const rdr::U8 *jpegBuf, | |||
} | |||
if (dinfo->out_color_space == JCS_RGB) | |||
pf.bufferFromRGB((rdr::U8*)buf, dstBuf, w, stride, h); | |||
pf.bufferFromRGB((uint8_t*)buf, dstBuf, w, stride, h); | |||
jpeg_finish_decompress(dinfo); | |||
@@ -43,7 +43,7 @@ namespace rfb { | |||
JpegDecompressor(void); | |||
virtual ~JpegDecompressor(); | |||
void decompress(const rdr::U8 *, int, rdr::U8 *, int, const Rect&, | |||
void decompress(const uint8_t *, int, uint8_t *, int, const Rect&, | |||
const PixelFormat&); | |||
private: |
@@ -72,10 +72,10 @@ void KeyRemapper::setMapping(const char* m) { | |||
} | |||
} | |||
rdr::U32 KeyRemapper::remapKey(rdr::U32 key) const { | |||
uint32_t KeyRemapper::remapKey(uint32_t key) const { | |||
os::AutoMutex a(mutex); | |||
std::map<rdr::U32,rdr::U32>::const_iterator i = mapping.find(key); | |||
std::map<uint32_t,uint32_t>::const_iterator i = mapping.find(key); | |||
if (i != mapping.end()) | |||
return i->second; | |||
return key; |
@@ -20,7 +20,8 @@ | |||
#define __RFB_KEYREMAPPER_H__ | |||
#include <map> | |||
#include <rdr/types.h> | |||
#include <stdint.h> | |||
namespace os { class Mutex; } | |||
@@ -31,10 +32,10 @@ namespace rfb { | |||
KeyRemapper(const char* m=""); | |||
~KeyRemapper(); | |||
void setMapping(const char* m); | |||
rdr::U32 remapKey(rdr::U32 key) const; | |||
uint32_t remapKey(uint32_t key) const; | |||
static KeyRemapper defInstance; | |||
private: | |||
std::map<rdr::U32,rdr::U32> mapping; | |||
std::map<uint32_t,uint32_t> mapping; | |||
os::Mutex* mutex; | |||
}; | |||
@@ -22,8 +22,7 @@ | |||
#include <assert.h> | |||
#include <string.h> | |||
#include <rdr/types.h> | |||
#include <stdint.h> | |||
namespace rfb { | |||
class Palette { | |||
@@ -35,13 +34,13 @@ namespace rfb { | |||
void clear() { numColours = 0; memset(hash, 0, sizeof(hash)); } | |||
inline bool insert(rdr::U32 colour, int numPixels); | |||
inline unsigned char lookup(rdr::U32 colour) const; | |||
inline rdr::U32 getColour(unsigned char index) const; | |||
inline bool insert(uint32_t colour, int numPixels); | |||
inline unsigned char lookup(uint32_t colour) const; | |||
inline uint32_t getColour(unsigned char index) const; | |||
inline int getCount(unsigned char index) const; | |||
protected: | |||
inline unsigned char genHash(rdr::U32 colour) const; | |||
inline unsigned char genHash(uint32_t colour) const; | |||
protected: | |||
int numColours; | |||
@@ -49,7 +48,7 @@ namespace rfb { | |||
struct PaletteListNode { | |||
PaletteListNode *next; | |||
unsigned char idx; | |||
rdr::U32 colour; | |||
uint32_t colour; | |||
}; | |||
struct PaletteEntry { | |||
@@ -67,7 +66,7 @@ namespace rfb { | |||
}; | |||
} | |||
inline bool rfb::Palette::insert(rdr::U32 colour, int numPixels) | |||
inline bool rfb::Palette::insert(uint32_t colour, int numPixels) | |||
{ | |||
PaletteListNode* pnode; | |||
PaletteListNode* prev_pnode; | |||
@@ -145,7 +144,7 @@ inline bool rfb::Palette::insert(rdr::U32 colour, int numPixels) | |||
return true; | |||
} | |||
inline unsigned char rfb::Palette::lookup(rdr::U32 colour) const | |||
inline unsigned char rfb::Palette::lookup(uint32_t colour) const | |||
{ | |||
unsigned char hash_key; | |||
PaletteListNode* pnode; | |||
@@ -165,7 +164,7 @@ inline unsigned char rfb::Palette::lookup(rdr::U32 colour) const | |||
return 0; | |||
} | |||
inline rdr::U32 rfb::Palette::getColour(unsigned char index) const | |||
inline uint32_t rfb::Palette::getColour(unsigned char index) const | |||
{ | |||
return entry[index].listNode->colour; | |||
} | |||
@@ -175,7 +174,7 @@ inline int rfb::Palette::getCount(unsigned char index) const | |||
return entry[index].numPixels; | |||
} | |||
inline unsigned char rfb::Palette::genHash(rdr::U32 colour) const | |||
inline unsigned char rfb::Palette::genHash(uint32_t colour) const | |||
{ | |||
unsigned char hash_key; | |||
@@ -25,10 +25,11 @@ | |||
#endif | |||
#include <string.h> | |||
#include <stdint.h> | |||
extern "C" { | |||
#include <rfb/d3des.h> | |||
} | |||
#include <rdr/types.h> | |||
#include <rdr/Exception.h> | |||
#include <rfb/Password.h> | |||
@@ -49,7 +50,7 @@ PlainPasswd::PlainPasswd(const ObfuscatedPasswd& obfPwd) : CharArray(9) { | |||
if (obfPwd.length < 8) | |||
throw rdr::Exception("bad obfuscated password length"); | |||
deskey(d3desObfuscationKey, DE1); | |||
des((rdr::U8*)obfPwd.buf, (rdr::U8*)buf); | |||
des((uint8_t*)obfPwd.buf, (uint8_t*)buf); | |||
buf[8] = 0; | |||
} | |||
@@ -75,7 +76,7 @@ ObfuscatedPasswd::ObfuscatedPasswd(const PlainPasswd& plainPwd) : CharArray(8), | |||
for (i=0; i<8; i++) | |||
buf[i] = i<l ? plainPwd.buf[i] : 0; | |||
deskey(d3desObfuscationKey, EN0); | |||
des((rdr::U8*)buf, (rdr::U8*)buf); | |||
des((uint8_t*)buf, (uint8_t*)buf); | |||
} | |||
ObfuscatedPasswd::~ObfuscatedPasswd() { |
@@ -18,9 +18,9 @@ | |||
#ifndef __RFB_PIXEL_H__ | |||
#define __RFB_PIXEL_H__ | |||
#include <rdr/types.h> | |||
#include <stdint.h> | |||
namespace rfb { | |||
typedef rdr::U32 Pixel; // must be big enough to hold any pixel value | |||
typedef uint32_t Pixel; // must be big enough to hold any pixel value | |||
} | |||
#endif |
@@ -63,10 +63,10 @@ void | |||
PixelBuffer::getImage(void* imageBuf, const Rect& r, int outStride) const | |||
{ | |||
int inStride; | |||
const U8* data; | |||
const uint8_t* data; | |||
int bytesPerPixel, inBytesPerRow, outBytesPerRow, bytesPerMemCpy; | |||
U8* imageBufPos; | |||
const U8* end; | |||
uint8_t* imageBufPos; | |||
const uint8_t* end; | |||
if (!r.enclosed_by(getRect())) | |||
throw rfb::Exception("Source rect %dx%d at %d,%d exceeds framebuffer %dx%d", | |||
@@ -83,7 +83,7 @@ PixelBuffer::getImage(void* imageBuf, const Rect& r, int outStride) const | |||
outBytesPerRow = outStride * bytesPerPixel; | |||
bytesPerMemCpy = r.width() * bytesPerPixel; | |||
imageBufPos = (U8*)imageBuf; | |||
imageBufPos = (uint8_t*)imageBuf; | |||
end = data + (inBytesPerRow * r.height()); | |||
while (data < end) { | |||
@@ -96,7 +96,7 @@ PixelBuffer::getImage(void* imageBuf, const Rect& r, int outStride) const | |||
void PixelBuffer::getImage(const PixelFormat& pf, void* imageBuf, | |||
const Rect& r, int stride) const | |||
{ | |||
const rdr::U8* srcBuffer; | |||
const uint8_t* srcBuffer; | |||
int srcStride; | |||
if (format.equal(pf)) { | |||
@@ -114,8 +114,8 @@ void PixelBuffer::getImage(const PixelFormat& pf, void* imageBuf, | |||
srcBuffer = getBuffer(r, &srcStride); | |||
pf.bufferFromBuffer((U8*)imageBuf, format, srcBuffer, r.width(), r.height(), | |||
stride, srcStride); | |||
pf.bufferFromBuffer((uint8_t*)imageBuf, format, srcBuffer, | |||
r.width(), r.height(), stride, srcStride); | |||
} | |||
void PixelBuffer::setSize(int width, int height) | |||
@@ -148,7 +148,7 @@ ModifiablePixelBuffer::~ModifiablePixelBuffer() | |||
void ModifiablePixelBuffer::fillRect(const Rect& r, const void* pix) | |||
{ | |||
int stride; | |||
U8 *buf; | |||
uint8_t *buf; | |||
int w, h, b; | |||
if (!r.enclosed_by(getRect())) | |||
@@ -166,11 +166,11 @@ void ModifiablePixelBuffer::fillRect(const Rect& r, const void* pix) | |||
if (b == 1) { | |||
while (h--) { | |||
memset(buf, *(const U8*)pix, w); | |||
memset(buf, *(const uint8_t*)pix, w); | |||
buf += stride * b; | |||
} | |||
} else { | |||
U8 *start; | |||
uint8_t *start; | |||
int w1; | |||
start = buf; | |||
@@ -195,11 +195,11 @@ void ModifiablePixelBuffer::fillRect(const Rect& r, const void* pix) | |||
void ModifiablePixelBuffer::imageRect(const Rect& r, | |||
const void* pixels, int srcStride) | |||
{ | |||
U8* dest; | |||
uint8_t* dest; | |||
int destStride; | |||
int bytesPerPixel, bytesPerDestRow, bytesPerSrcRow, bytesPerFill; | |||
const U8* src; | |||
U8* end; | |||
const uint8_t* src; | |||
uint8_t* end; | |||
if (!r.enclosed_by(getRect())) | |||
throw rfb::Exception("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d", | |||
@@ -217,7 +217,7 @@ void ModifiablePixelBuffer::imageRect(const Rect& r, | |||
bytesPerSrcRow = bytesPerPixel * srcStride; | |||
bytesPerFill = bytesPerPixel * r.width(); | |||
src = (const U8*)pixels; | |||
src = (const uint8_t*)pixels; | |||
end = dest + (bytesPerDestRow * r.height()); | |||
while (dest < end) { | |||
@@ -234,8 +234,8 @@ void ModifiablePixelBuffer::copyRect(const Rect &rect, | |||
{ | |||
int srcStride, dstStride; | |||
int bytesPerPixel; | |||
const U8* srcData; | |||
U8* dstData; | |||
const uint8_t* srcData; | |||
uint8_t* dstData; | |||
Rect drect, srect; | |||
@@ -290,15 +290,15 @@ void ModifiablePixelBuffer::copyRect(const Rect &rect, | |||
void ModifiablePixelBuffer::fillRect(const PixelFormat& pf, const Rect &dest, | |||
const void* pix) | |||
{ | |||
rdr::U8 buf[4]; | |||
format.bufferFromBuffer(buf, pf, (const rdr::U8*)pix, 1); | |||
uint8_t buf[4]; | |||
format.bufferFromBuffer(buf, pf, (const uint8_t*)pix, 1); | |||
fillRect(dest, buf); | |||
} | |||
void ModifiablePixelBuffer::imageRect(const PixelFormat& pf, const Rect &dest, | |||
const void* pixels, int stride) | |||
{ | |||
rdr::U8* dstBuffer; | |||
uint8_t* dstBuffer; | |||
int dstStride; | |||
if (!dest.enclosed_by(getRect())) | |||
@@ -310,7 +310,7 @@ void ModifiablePixelBuffer::imageRect(const PixelFormat& pf, const Rect &dest, | |||
stride = dest.width(); | |||
dstBuffer = getBufferRW(dest, &dstStride); | |||
format.bufferFromBuffer(dstBuffer, pf, (const rdr::U8*)pixels, | |||
format.bufferFromBuffer(dstBuffer, pf, (const uint8_t*)pixels, | |||
dest.width(), dest.height(), | |||
dstStride, stride); | |||
commitBufferRW(dest); | |||
@@ -319,7 +319,7 @@ void ModifiablePixelBuffer::imageRect(const PixelFormat& pf, const Rect &dest, | |||
// -=- Simple pixel buffer with a continuous block of memory | |||
FullFramePixelBuffer::FullFramePixelBuffer(const PixelFormat& pf, int w, int h, | |||
rdr::U8* data_, int stride_) | |||
uint8_t* data_, int stride_) | |||
: ModifiablePixelBuffer(pf, w, h), data(data_), stride(stride_) | |||
{ | |||
} | |||
@@ -328,7 +328,7 @@ FullFramePixelBuffer::FullFramePixelBuffer() : data(0) {} | |||
FullFramePixelBuffer::~FullFramePixelBuffer() {} | |||
rdr::U8* FullFramePixelBuffer::getBufferRW(const Rect& r, int* stride_) | |||
uint8_t* FullFramePixelBuffer::getBufferRW(const Rect& r, int* stride_) | |||
{ | |||
if (!r.enclosed_by(getRect())) | |||
throw rfb::Exception("Pixel buffer request %dx%d at %d,%d exceeds framebuffer %dx%d", | |||
@@ -343,7 +343,7 @@ void FullFramePixelBuffer::commitBufferRW(const Rect& /*r*/) | |||
{ | |||
} | |||
const rdr::U8* FullFramePixelBuffer::getBuffer(const Rect& r, int* stride_) const | |||
const uint8_t* FullFramePixelBuffer::getBuffer(const Rect& r, int* stride_) const | |||
{ | |||
if (!r.enclosed_by(getRect())) | |||
throw rfb::Exception("Pixel buffer request %dx%d at %d,%d exceeds framebuffer %dx%d", | |||
@@ -355,7 +355,7 @@ const rdr::U8* FullFramePixelBuffer::getBuffer(const Rect& r, int* stride_) cons | |||
} | |||
void FullFramePixelBuffer::setBuffer(int width, int height, | |||
rdr::U8* data_, int stride_) | |||
uint8_t* data_, int stride_) | |||
{ | |||
if ((width < 0) || (width > maxPixelBufferWidth)) | |||
throw rfb::Exception("Invalid PixelBuffer width of %d pixels requested", width); | |||
@@ -415,7 +415,7 @@ void ManagedPixelBuffer::setSize(int w, int h) | |||
datasize = 0; | |||
} | |||
if (new_datasize) { | |||
data_ = new U8[new_datasize]; | |||
data_ = new uint8_t[new_datasize]; | |||
datasize = new_datasize; | |||
} | |||
} |
@@ -66,7 +66,7 @@ namespace rfb { | |||
// Get a pointer into the buffer | |||
// The pointer is to the top-left pixel of the specified Rect. | |||
// The buffer stride (in pixels) is returned. | |||
virtual const rdr::U8* getBuffer(const Rect& r, int* stride) const = 0; | |||
virtual const uint8_t* getBuffer(const Rect& r, int* stride) const = 0; | |||
// Get pixel data for a given part of the buffer | |||
// Data is copied into the supplied buffer, with the specified | |||
@@ -112,7 +112,7 @@ namespace rfb { | |||
// Get a writeable pointer into the buffer | |||
// Like getBuffer(), the pointer is to the top-left pixel of the | |||
// specified Rect and the stride in pixels is returned. | |||
virtual rdr::U8* getBufferRW(const Rect& r, int* stride) = 0; | |||
virtual uint8_t* getBufferRW(const Rect& r, int* stride) = 0; | |||
// Commit the modified contents | |||
// Ensures that the changes to the specified Rect is properly | |||
// stored away and any temporary buffers are freed. The Rect given | |||
@@ -149,23 +149,23 @@ namespace rfb { | |||
class FullFramePixelBuffer : public ModifiablePixelBuffer { | |||
public: | |||
FullFramePixelBuffer(const PixelFormat& pf, int width, int height, | |||
rdr::U8* data_, int stride); | |||
uint8_t* data_, int stride); | |||
virtual ~FullFramePixelBuffer(); | |||
public: | |||
virtual const rdr::U8* getBuffer(const Rect& r, int* stride) const; | |||
virtual rdr::U8* getBufferRW(const Rect& r, int* stride); | |||
virtual const uint8_t* getBuffer(const Rect& r, int* stride) const; | |||
virtual uint8_t* getBufferRW(const Rect& r, int* stride); | |||
virtual void commitBufferRW(const Rect& r); | |||
protected: | |||
FullFramePixelBuffer(); | |||
virtual void setBuffer(int width, int height, rdr::U8* data, int stride); | |||
virtual void setBuffer(int width, int height, uint8_t* data, int stride); | |||
private: | |||
virtual void setSize(int w, int h); | |||
private: | |||
rdr::U8* data; | |||
uint8_t* data; | |||
int stride; | |||
}; | |||
@@ -183,7 +183,7 @@ namespace rfb { | |||
virtual void setSize(int w, int h); | |||
private: | |||
rdr::U8* data_; // Mirrors FullFramePixelBuffer::data | |||
uint8_t* data_; // Mirrors FullFramePixelBuffer::data | |||
unsigned long datasize; | |||
}; | |||
@@ -38,8 +38,8 @@ | |||
using namespace rfb; | |||
rdr::U8 PixelFormat::upconvTable[256*8]; | |||
rdr::U8 PixelFormat::downconvTable[256*8]; | |||
uint8_t PixelFormat::upconvTable[256*8]; | |||
uint8_t PixelFormat::downconvTable[256*8]; | |||
class PixelFormat::Init { | |||
public: | |||
@@ -59,8 +59,8 @@ PixelFormat::Init::Init() | |||
for (bits = 1;bits <= 8;bits++) { | |||
int i, maxVal; | |||
rdr::U8 *subUpTable; | |||
rdr::U8 *subDownTable; | |||
uint8_t *subUpTable; | |||
uint8_t *subDownTable; | |||
maxVal = (1 << bits) - 1; | |||
subUpTable = &upconvTable[(bits-1)*256]; | |||
@@ -234,17 +234,17 @@ bool PixelFormat::isLittleEndian(void) const | |||
} | |||
void PixelFormat::bufferFromRGB(rdr::U8 *dst, const rdr::U8* src, int pixels) const | |||
void PixelFormat::bufferFromRGB(uint8_t *dst, const uint8_t* src, int pixels) const | |||
{ | |||
bufferFromRGB(dst, src, pixels, pixels, 1); | |||
} | |||
void PixelFormat::bufferFromRGB(rdr::U8 *dst, const rdr::U8* src, | |||
void PixelFormat::bufferFromRGB(uint8_t *dst, const uint8_t* src, | |||
int w, int stride, int h) const | |||
{ | |||
if (is888()) { | |||
// Optimised common case | |||
rdr::U8 *r, *g, *b, *x; | |||
uint8_t *r, *g, *b, *x; | |||
if (bigEndian) { | |||
r = dst + (24 - redShift)/8; | |||
@@ -283,7 +283,7 @@ void PixelFormat::bufferFromRGB(rdr::U8 *dst, const rdr::U8* src, | |||
int w_ = w; | |||
while (w_--) { | |||
Pixel p; | |||
rdr::U8 r, g, b; | |||
uint8_t r, g, b; | |||
r = *(src++); | |||
g = *(src++); | |||
@@ -300,18 +300,18 @@ void PixelFormat::bufferFromRGB(rdr::U8 *dst, const rdr::U8* src, | |||
} | |||
void PixelFormat::rgbFromBuffer(rdr::U8* dst, const rdr::U8* src, int pixels) const | |||
void PixelFormat::rgbFromBuffer(uint8_t* dst, const uint8_t* src, int pixels) const | |||
{ | |||
rgbFromBuffer(dst, src, pixels, pixels, 1); | |||
} | |||
void PixelFormat::rgbFromBuffer(rdr::U8* dst, const rdr::U8* src, | |||
void PixelFormat::rgbFromBuffer(uint8_t* dst, const uint8_t* src, | |||
int w, int stride, int h) const | |||
{ | |||
if (is888()) { | |||
// Optimised common case | |||
const rdr::U8 *r, *g, *b; | |||
const uint8_t *r, *g, *b; | |||
if (bigEndian) { | |||
r = src + (24 - redShift)/8; | |||
@@ -345,7 +345,7 @@ void PixelFormat::rgbFromBuffer(rdr::U8* dst, const rdr::U8* src, | |||
int w_ = w; | |||
while (w_--) { | |||
Pixel p; | |||
rdr::U8 r, g, b; | |||
uint8_t r, g, b; | |||
p = pixelFromBuffer(src); | |||
@@ -364,22 +364,22 @@ void PixelFormat::rgbFromBuffer(rdr::U8* dst, const rdr::U8* src, | |||
Pixel PixelFormat::pixelFromPixel(const PixelFormat &srcPF, Pixel src) const | |||
{ | |||
rdr::U16 r, g, b; | |||
uint16_t r, g, b; | |||
srcPF.rgbFromPixel(src, &r, &g, &b); | |||
return pixelFromRGB(r, g, b); | |||
} | |||
void PixelFormat::bufferFromBuffer(rdr::U8* dst, const PixelFormat &srcPF, | |||
const rdr::U8* src, int pixels) const | |||
void PixelFormat::bufferFromBuffer(uint8_t* dst, const PixelFormat &srcPF, | |||
const uint8_t* src, int pixels) const | |||
{ | |||
bufferFromBuffer(dst, srcPF, src, pixels, 1, pixels, pixels); | |||
} | |||
#define IS_ALIGNED(v, a) (((intptr_t)v & (a-1)) == 0) | |||
void PixelFormat::bufferFromBuffer(rdr::U8* dst, const PixelFormat &srcPF, | |||
const rdr::U8* src, int w, int h, | |||
void PixelFormat::bufferFromBuffer(uint8_t* dst, const PixelFormat &srcPF, | |||
const uint8_t* src, int w, int h, | |||
int dstStride, int srcStride) const | |||
{ | |||
if (equal(srcPF)) { | |||
@@ -391,7 +391,7 @@ void PixelFormat::bufferFromBuffer(rdr::U8* dst, const PixelFormat &srcPF, | |||
} | |||
} else if (is888() && srcPF.is888()) { | |||
// Optimised common case A: byte shuffling (e.g. endian conversion) | |||
rdr::U8 *d[4], *s[4]; | |||
uint8_t *d[4], *s[4]; | |||
int dstPad, srcPad; | |||
if (bigEndian) { | |||
@@ -442,15 +442,15 @@ void PixelFormat::bufferFromBuffer(rdr::U8* dst, const PixelFormat &srcPF, | |||
// Optimised common case B: 888 source | |||
switch (bpp) { | |||
case 8: | |||
directBufferFromBufferFrom888((rdr::U8*)dst, srcPF, src, | |||
directBufferFromBufferFrom888((uint8_t*)dst, srcPF, src, | |||
w, h, dstStride, srcStride); | |||
break; | |||
case 16: | |||
directBufferFromBufferFrom888((rdr::U16*)dst, srcPF, src, | |||
directBufferFromBufferFrom888((uint16_t*)dst, srcPF, src, | |||
w, h, dstStride, srcStride); | |||
break; | |||
case 32: | |||
directBufferFromBufferFrom888((rdr::U32*)dst, srcPF, src, | |||
directBufferFromBufferFrom888((uint32_t*)dst, srcPF, src, | |||
w, h, dstStride, srcStride); | |||
break; | |||
} | |||
@@ -458,15 +458,15 @@ void PixelFormat::bufferFromBuffer(rdr::U8* dst, const PixelFormat &srcPF, | |||
// Optimised common case C: 888 destination | |||
switch (srcPF.bpp) { | |||
case 8: | |||
directBufferFromBufferTo888(dst, srcPF, (rdr::U8*)src, | |||
directBufferFromBufferTo888(dst, srcPF, (uint8_t*)src, | |||
w, h, dstStride, srcStride); | |||
break; | |||
case 16: | |||
directBufferFromBufferTo888(dst, srcPF, (rdr::U16*)src, | |||
directBufferFromBufferTo888(dst, srcPF, (uint16_t*)src, | |||
w, h, dstStride, srcStride); | |||
break; | |||
case 32: | |||
directBufferFromBufferTo888(dst, srcPF, (rdr::U32*)src, | |||
directBufferFromBufferTo888(dst, srcPF, (uint32_t*)src, | |||
w, h, dstStride, srcStride); | |||
break; | |||
} | |||
@@ -478,7 +478,7 @@ void PixelFormat::bufferFromBuffer(rdr::U8* dst, const PixelFormat &srcPF, | |||
int w_ = w; | |||
while (w_--) { | |||
Pixel p; | |||
rdr::U8 r, g, b; | |||
uint8_t r, g, b; | |||
p = srcPF.pixelFromBuffer(src); | |||
srcPF.rgbFromPixel(p, &r, &g, &b); | |||
@@ -579,8 +579,8 @@ bool PixelFormat::parse(const char* str) | |||
depth = bits1 + bits2 + bits3; | |||
bpp = depth <= 8 ? 8 : ((depth <= 16) ? 16 : 32); | |||
trueColour = true; | |||
rdr::U32 endianTest = 1; | |||
bigEndian = (*(rdr::U8*)&endianTest == 0); | |||
uint32_t endianTest = 1; | |||
bigEndian = (*(uint8_t*)&endianTest == 0); | |||
greenShift = bits3; | |||
greenMax = (1 << bits2) - 1; | |||
@@ -607,7 +607,7 @@ bool PixelFormat::parse(const char* str) | |||
} | |||
static int bits(rdr::U16 value) | |||
static int bits(uint16_t value) | |||
{ | |||
int bits; | |||
@@ -58,29 +58,29 @@ namespace rfb { | |||
bool isBigEndian(void) const; | |||
bool isLittleEndian(void) const; | |||
inline Pixel pixelFromBuffer(const rdr::U8* buffer) const; | |||
inline void bufferFromPixel(rdr::U8* buffer, Pixel pixel) const; | |||
inline Pixel pixelFromBuffer(const uint8_t* buffer) const; | |||
inline void bufferFromPixel(uint8_t* buffer, Pixel pixel) const; | |||
inline Pixel pixelFromRGB(rdr::U16 red, rdr::U16 green, rdr::U16 blue) const; | |||
inline Pixel pixelFromRGB(rdr::U8 red, rdr::U8 green, rdr::U8 blue) const; | |||
inline Pixel pixelFromRGB(uint16_t red, uint16_t green, uint16_t blue) const; | |||
inline Pixel pixelFromRGB(uint8_t red, uint8_t green, uint8_t blue) const; | |||
void bufferFromRGB(rdr::U8 *dst, const rdr::U8* src, int pixels) const; | |||
void bufferFromRGB(rdr::U8 *dst, const rdr::U8* src, | |||
void bufferFromRGB(uint8_t *dst, const uint8_t* src, int pixels) const; | |||
void bufferFromRGB(uint8_t *dst, const uint8_t* src, | |||
int w, int stride, int h) const; | |||
inline void rgbFromPixel(Pixel pix, rdr::U16 *r, rdr::U16 *g, rdr::U16 *b) const; | |||
inline void rgbFromPixel(Pixel pix, rdr::U8 *r, rdr::U8 *g, rdr::U8 *b) const; | |||
inline void rgbFromPixel(Pixel pix, uint16_t *r, uint16_t *g, uint16_t *b) const; | |||
inline void rgbFromPixel(Pixel pix, uint8_t *r, uint8_t *g, uint8_t *b) const; | |||
void rgbFromBuffer(rdr::U8* dst, const rdr::U8* src, int pixels) const; | |||
void rgbFromBuffer(rdr::U8* dst, const rdr::U8* src, | |||
void rgbFromBuffer(uint8_t* dst, const uint8_t* src, int pixels) const; | |||
void rgbFromBuffer(uint8_t* dst, const uint8_t* src, | |||
int w, int stride, int h) const; | |||
Pixel pixelFromPixel(const PixelFormat &srcPF, Pixel src) const; | |||
void bufferFromBuffer(rdr::U8* dst, const PixelFormat &srcPF, | |||
const rdr::U8* src, int pixels) const; | |||
void bufferFromBuffer(rdr::U8* dst, const PixelFormat &srcPF, | |||
const rdr::U8* src, int w, int h, | |||
void bufferFromBuffer(uint8_t* dst, const PixelFormat &srcPF, | |||
const uint8_t* src, int pixels) const; | |||
void bufferFromBuffer(uint8_t* dst, const PixelFormat &srcPF, | |||
const uint8_t* src, int w, int h, | |||
int dstStride, int srcStride) const; | |||
void print(char* str, int len) const; | |||
@@ -94,10 +94,10 @@ namespace rfb { | |||
// Templated, optimised methods | |||
template<class T> | |||
void directBufferFromBufferFrom888(T* dst, const PixelFormat &srcPF, | |||
const rdr::U8* src, int w, int h, | |||
const uint8_t* src, int w, int h, | |||
int dstStride, int srcStride) const; | |||
template<class T> | |||
void directBufferFromBufferTo888(rdr::U8* dst, const PixelFormat &srcPF, | |||
void directBufferFromBufferTo888(uint8_t* dst, const PixelFormat &srcPF, | |||
const T* src, int w, int h, | |||
int dstStride, int srcStride) const; | |||
@@ -124,18 +124,18 @@ namespace rfb { | |||
int maxBits, minBits; | |||
bool endianMismatch; | |||
static rdr::U8 upconvTable[256*8]; | |||
static rdr::U8 downconvTable[256*8]; | |||
static uint8_t upconvTable[256*8]; | |||
static uint8_t downconvTable[256*8]; | |||
class Init; | |||
friend class Init; | |||
static Init _init; | |||
/* Only for testing this class */ | |||
friend void makePixel(const rfb::PixelFormat &, rdr::U8 *); | |||
friend void makePixel(const rfb::PixelFormat &, uint8_t *); | |||
friend bool verifyPixel(const rfb::PixelFormat &, | |||
const rfb::PixelFormat &, | |||
const rdr::U8 *); | |||
const uint8_t *); | |||
}; | |||
} | |||
@@ -19,7 +19,7 @@ | |||
namespace rfb { | |||
inline Pixel PixelFormat::pixelFromBuffer(const rdr::U8* buffer) const | |||
inline Pixel PixelFormat::pixelFromBuffer(const uint8_t* buffer) const | |||
{ | |||
Pixel p; | |||
@@ -52,7 +52,7 @@ inline Pixel PixelFormat::pixelFromBuffer(const rdr::U8* buffer) const | |||
} | |||
inline void PixelFormat::bufferFromPixel(rdr::U8* buffer, Pixel p) const | |||
inline void PixelFormat::bufferFromPixel(uint8_t* buffer, Pixel p) const | |||
{ | |||
if (bigEndian) { | |||
switch (bpp) { | |||
@@ -79,7 +79,7 @@ inline void PixelFormat::bufferFromPixel(rdr::U8* buffer, Pixel p) const | |||
} | |||
inline Pixel PixelFormat::pixelFromRGB(rdr::U16 red, rdr::U16 green, rdr::U16 blue) const | |||
inline Pixel PixelFormat::pixelFromRGB(uint16_t red, uint16_t green, uint16_t blue) const | |||
{ | |||
Pixel p; | |||
@@ -91,7 +91,7 @@ inline Pixel PixelFormat::pixelFromRGB(rdr::U16 red, rdr::U16 green, rdr::U16 bl | |||
} | |||
inline Pixel PixelFormat::pixelFromRGB(rdr::U8 red, rdr::U8 green, rdr::U8 blue) const | |||
inline Pixel PixelFormat::pixelFromRGB(uint8_t red, uint8_t green, uint8_t blue) const | |||
{ | |||
Pixel p; | |||
@@ -103,9 +103,9 @@ inline Pixel PixelFormat::pixelFromRGB(rdr::U8 red, rdr::U8 green, rdr::U8 blue) | |||
} | |||
inline void PixelFormat::rgbFromPixel(Pixel p, rdr::U16 *r, rdr::U16 *g, rdr::U16 *b) const | |||
inline void PixelFormat::rgbFromPixel(Pixel p, uint16_t *r, uint16_t *g, uint16_t *b) const | |||
{ | |||
rdr::U8 _r, _g, _b; | |||
uint8_t _r, _g, _b; | |||
_r = p >> redShift; | |||
_g = p >> greenShift; | |||
@@ -121,9 +121,9 @@ inline void PixelFormat::rgbFromPixel(Pixel p, rdr::U16 *r, rdr::U16 *g, rdr::U1 | |||
} | |||
inline void PixelFormat::rgbFromPixel(Pixel p, rdr::U8 *r, rdr::U8 *g, rdr::U8 *b) const | |||
inline void PixelFormat::rgbFromPixel(Pixel p, uint8_t *r, uint8_t *g, uint8_t *b) const | |||
{ | |||
rdr::U8 _r, _g, _b; | |||
uint8_t _r, _g, _b; | |||
_r = p >> redShift; | |||
_g = p >> greenShift; |
@@ -43,7 +43,7 @@ RREDecoder::~RREDecoder() | |||
bool RREDecoder::readRect(const Rect& /*r*/, rdr::InStream* is, | |||
const ServerParams& server, rdr::OutStream* os) | |||
{ | |||
rdr::U32 numRects; | |||
uint32_t numRects; | |||
size_t len; | |||
if (!is->hasData(4)) | |||
@@ -73,9 +73,9 @@ void RREDecoder::decodeRect(const Rect& r, const void* buffer, | |||
rdr::MemInStream is(buffer, buflen); | |||
const PixelFormat& pf = server.pf(); | |||
switch (pf.bpp) { | |||
case 8: rreDecode<rdr::U8 >(r, &is, pf, pb); break; | |||
case 16: rreDecode<rdr::U16>(r, &is, pf, pb); break; | |||
case 32: rreDecode<rdr::U32>(r, &is, pf, pb); break; | |||
case 8: rreDecode<uint8_t >(r, &is, pf, pb); break; | |||
case 16: rreDecode<uint16_t>(r, &is, pf, pb); break; | |||
case 32: rreDecode<uint32_t>(r, &is, pf, pb); break; | |||
} | |||
} | |||
@@ -47,9 +47,9 @@ bool RREEncoder::isSupported() | |||
void RREEncoder::writeRect(const PixelBuffer* pb, const Palette& palette) | |||
{ | |||
rdr::U8* imageBuf; | |||
uint8_t* imageBuf; | |||
int stride; | |||
rdr::U32 bg; | |||
uint32_t bg; | |||
int w = pb->width(); | |||
int h = pb->height(); | |||
@@ -79,13 +79,13 @@ void RREEncoder::writeRect(const PixelBuffer* pb, const Palette& palette) | |||
int nSubrects = -1; | |||
switch (pb->getPF().bpp) { | |||
case 8: | |||
nSubrects = rreEncode<rdr::U8>((rdr::U8*)imageBuf, w, h, &mos, bg); | |||
nSubrects = rreEncode<uint8_t>((uint8_t*)imageBuf, w, h, &mos, bg); | |||
break; | |||
case 16: | |||
nSubrects = rreEncode<rdr::U16>((rdr::U16*)imageBuf, w, h, &mos, bg); | |||
nSubrects = rreEncode<uint16_t>((uint16_t*)imageBuf, w, h, &mos, bg); | |||
break; | |||
case 32: | |||
nSubrects = rreEncode<rdr::U32>((rdr::U32*)imageBuf, w, h, &mos, bg); | |||
nSubrects = rreEncode<uint32_t>((uint32_t*)imageBuf, w, h, &mos, bg); | |||
break; | |||
} | |||
@@ -99,7 +99,7 @@ void RREEncoder::writeRect(const PixelBuffer* pb, const Palette& palette) | |||
void RREEncoder::writeSolidRect(int /*width*/, int /*height*/, | |||
const PixelFormat& pf, | |||
const rdr::U8* colour) | |||
const uint8_t* colour) | |||
{ | |||
rdr::OutStream* os; | |||
@@ -33,7 +33,7 @@ namespace rfb { | |||
virtual void writeRect(const PixelBuffer* pb, const Palette& palette); | |||
virtual void writeSolidRect(int width, int height, | |||
const PixelFormat& pf, | |||
const rdr::U8* colour); | |||
const uint8_t* colour); | |||
private: | |||
template<class T> | |||
inline void writePixel(rdr::OutStream* os, T pixel); |
@@ -47,7 +47,7 @@ bool RawEncoder::isSupported() | |||
void RawEncoder::writeRect(const PixelBuffer* pb, | |||
const Palette& /*palette*/) | |||
{ | |||
const rdr::U8* buffer; | |||
const uint8_t* buffer; | |||
int stride; | |||
rdr::OutStream* os; | |||
@@ -68,7 +68,7 @@ void RawEncoder::writeRect(const PixelBuffer* pb, | |||
void RawEncoder::writeSolidRect(int width, int height, | |||
const PixelFormat& pf, | |||
const rdr::U8* colour) | |||
const uint8_t* colour) | |||
{ | |||
rdr::OutStream* os; | |||
int pixels, pixel_size; |
@@ -31,7 +31,7 @@ namespace rfb { | |||
virtual void writeRect(const PixelBuffer* pb, const Palette& palette); | |||
virtual void writeSolidRect(int width, int height, | |||
const PixelFormat& pf, | |||
const rdr::U8* colour); | |||
const uint8_t* colour); | |||
}; | |||
} | |||
#endif |
@@ -161,8 +161,8 @@ bool SConnection::processVersionMsg() | |||
versionReceived(); | |||
std::list<rdr::U8> secTypes; | |||
std::list<rdr::U8>::iterator i; | |||
std::list<uint8_t> secTypes; | |||
std::list<uint8_t>::iterator i; | |||
secTypes = security.GetEnabledSecTypes(); | |||
if (client.isVersion(3,3)) { | |||
@@ -216,8 +216,8 @@ bool SConnection::processSecurityTypeMsg() | |||
void SConnection::processSecurityType(int secType) | |||
{ | |||
// Verify that the requested security type should be offered | |||
std::list<rdr::U8> secTypes; | |||
std::list<rdr::U8>::iterator i; | |||
std::list<uint8_t> secTypes; | |||
std::list<uint8_t>::iterator i; | |||
secTypes = security.GetEnabledSecTypes(); | |||
for (i=secTypes.begin(); i!=secTypes.end(); i++) | |||
@@ -352,7 +352,7 @@ bool SConnection::accessCheck(AccessRights ar) const | |||
return (accessRights & ar) == ar; | |||
} | |||
void SConnection::setEncodings(int nEncodings, const rdr::S32* encodings) | |||
void SConnection::setEncodings(int nEncodings, const int32_t* encodings) | |||
{ | |||
int i; | |||
@@ -367,7 +367,7 @@ void SConnection::setEncodings(int nEncodings, const rdr::S32* encodings) | |||
SMsgHandler::setEncodings(nEncodings, encodings); | |||
if (client.supportsEncoding(pseudoEncodingExtendedClipboard)) { | |||
rdr::U32 sizes[] = { 0 }; | |||
uint32_t sizes[] = { 0 }; | |||
writer()->writeClipboardCaps(rfb::clipboardUTF8 | | |||
rfb::clipboardRequest | | |||
rfb::clipboardPeek | | |||
@@ -389,7 +389,7 @@ void SConnection::clientCutText(const char* str) | |||
handleClipboardAnnounce(true); | |||
} | |||
void SConnection::handleClipboardRequest(rdr::U32 flags) | |||
void SConnection::handleClipboardRequest(uint32_t flags) | |||
{ | |||
if (!(flags & rfb::clipboardUTF8)) { | |||
vlog.debug("Ignoring clipboard request for unsupported formats 0x%x", flags); | |||
@@ -408,7 +408,7 @@ void SConnection::handleClipboardPeek() | |||
writer()->writeClipboardNotify(hasLocalClipboard ? rfb::clipboardUTF8 : 0); | |||
} | |||
void SConnection::handleClipboardNotify(rdr::U32 flags) | |||
void SConnection::handleClipboardNotify(uint32_t flags) | |||
{ | |||
strFree(clientClipboard); | |||
clientClipboard = NULL; | |||
@@ -421,9 +421,9 @@ void SConnection::handleClipboardNotify(rdr::U32 flags) | |||
} | |||
} | |||
void SConnection::handleClipboardProvide(rdr::U32 flags, | |||
void SConnection::handleClipboardProvide(uint32_t flags, | |||
const size_t* lengths, | |||
const rdr::U8* const* data) | |||
const uint8_t* const* data) | |||
{ | |||
if (!(flags & rfb::clipboardUTF8)) { | |||
vlog.debug("Ignoring clipboard provide with unsupported formats 0x%x", flags); | |||
@@ -523,7 +523,7 @@ void SConnection::framebufferUpdateRequest(const Rect& /*r*/, | |||
} | |||
} | |||
void SConnection::fence(rdr::U32 flags, unsigned len, const char data[]) | |||
void SConnection::fence(uint32_t flags, unsigned len, const char data[]) | |||
{ | |||
if (!(flags & fenceFlagRequest)) | |||
return; | |||
@@ -596,7 +596,7 @@ void SConnection::sendClipboardData(const char* data) | |||
(client.clipboardFlags() & rfb::clipboardProvide)) { | |||
CharArray filtered(convertCRLF(data)); | |||
size_t sizes[1] = { strlen(filtered.buf) + 1 }; | |||
const rdr::U8* data[1] = { (const rdr::U8*)filtered.buf }; | |||
const uint8_t* data[1] = { (const uint8_t*)filtered.buf }; | |||
if (unsolicitedClipboardAttempt) { | |||
unsolicitedClipboardAttempt = false; | |||
@@ -631,7 +631,7 @@ void SConnection::cleanup() | |||
void SConnection::writeFakeColourMap(void) | |||
{ | |||
int i; | |||
rdr::U16 red[256], green[256], blue[256]; | |||
uint16_t red[256], green[256], blue[256]; | |||
for (i = 0;i < 256;i++) | |||
client.pf().rgbFromPixel(i, &red[i], &green[i], &blue[i]); |
@@ -80,16 +80,16 @@ namespace rfb { | |||
// Overridden from SMsgHandler | |||
virtual void setEncodings(int nEncodings, const rdr::S32* encodings); | |||
virtual void setEncodings(int nEncodings, const int32_t* encodings); | |||
virtual void clientCutText(const char* str); | |||
virtual void handleClipboardRequest(rdr::U32 flags); | |||
virtual void handleClipboardRequest(uint32_t flags); | |||
virtual void handleClipboardPeek(); | |||
virtual void handleClipboardNotify(rdr::U32 flags); | |||
virtual void handleClipboardProvide(rdr::U32 flags, | |||
virtual void handleClipboardNotify(uint32_t flags); | |||
virtual void handleClipboardProvide(uint32_t flags, | |||
const size_t* lengths, | |||
const rdr::U8* const* data); | |||
const uint8_t* const* data); | |||
virtual void supportsQEMUKeyEvent(); | |||
@@ -130,7 +130,7 @@ namespace rfb { | |||
// it responds directly to requests (stating it doesn't support any | |||
// synchronisation) and drops responses. Override to implement more proper | |||
// support. | |||
virtual void fence(rdr::U32 flags, unsigned len, const char data[]); | |||
virtual void fence(uint32_t flags, unsigned len, const char data[]); | |||
// enableContinuousUpdates() is called when the client wants to enable | |||
// or disable continuous updates, or change the active area. | |||
@@ -177,7 +177,7 @@ namespace rfb { | |||
// of a SConnection to the server. How the access rights are treated | |||
// is up to the derived class. | |||
typedef rdr::U16 AccessRights; | |||
typedef uint16_t AccessRights; | |||
static const AccessRights AccessView; // View display contents | |||
static const AccessRights AccessKeyEvents; // Send key events | |||
static const AccessRights AccessPtrEvents; // Send pointer events | |||
@@ -216,7 +216,7 @@ namespace rfb { | |||
stateEnum state() { return state_; } | |||
rdr::S32 getPreferredEncoding() { return preferredEncoding; } | |||
int32_t getPreferredEncoding() { return preferredEncoding; } | |||
protected: | |||
// throwConnFailedException() prints a message to the log, sends a conn | |||
@@ -260,7 +260,7 @@ namespace rfb { | |||
CharArray authFailureMsg; | |||
stateEnum state_; | |||
rdr::S32 preferredEncoding; | |||
int32_t preferredEncoding; | |||
AccessRights accessRights; | |||
char* clientClipboard; |
@@ -125,13 +125,13 @@ namespace rfb { | |||
public: | |||
SStaticDesktop(const Point& size) : server(0), buffer(0) { | |||
PixelFormat pf; | |||
const rdr::U8 black[4] = { 0, 0, 0, 0 }; | |||
const uint8_t black[4] = { 0, 0, 0, 0 }; | |||
buffer = new ManagedPixelBuffer(pf, size.x, size.y); | |||
if (buffer) | |||
buffer->fillRect(buffer->getRect(), black); | |||
} | |||
SStaticDesktop(const Point& size, const PixelFormat& pf) : buffer(0) { | |||
const rdr::U8 black[4] = { 0, 0, 0, 0 }; | |||
const uint8_t black[4] = { 0, 0, 0, 0 }; | |||
buffer = new ManagedPixelBuffer(pf, size.x, size.y); | |||
if (buffer) | |||
buffer->fillRect(buffer->getRect(), black); |
@@ -49,7 +49,7 @@ void SMsgHandler::setPixelFormat(const PixelFormat& pf) | |||
client.setPF(pf); | |||
} | |||
void SMsgHandler::setEncodings(int nEncodings, const rdr::S32* encodings) | |||
void SMsgHandler::setEncodings(int nEncodings, const int32_t* encodings) | |||
{ | |||
bool firstFence, firstContinuousUpdates, firstLEDState, | |||
firstQEMUKeyEvent; | |||
@@ -73,7 +73,7 @@ void SMsgHandler::setEncodings(int nEncodings, const rdr::S32* encodings) | |||
supportsQEMUKeyEvent(); | |||
} | |||
void SMsgHandler::handleClipboardCaps(rdr::U32 flags, const rdr::U32* lengths) | |||
void SMsgHandler::handleClipboardCaps(uint32_t flags, const uint32_t* lengths) | |||
{ | |||
int i; | |||
@@ -118,7 +118,7 @@ void SMsgHandler::handleClipboardCaps(rdr::U32 flags, const rdr::U32* lengths) | |||
client.setClipboardCaps(flags, lengths); | |||
} | |||
void SMsgHandler::handleClipboardRequest(rdr::U32 /*flags*/) | |||
void SMsgHandler::handleClipboardRequest(uint32_t /*flags*/) | |||
{ | |||
} | |||
@@ -126,13 +126,13 @@ void SMsgHandler::handleClipboardPeek() | |||
{ | |||
} | |||
void SMsgHandler::handleClipboardNotify(rdr::U32 /*flags*/) | |||
void SMsgHandler::handleClipboardNotify(uint32_t /*flags*/) | |||
{ | |||
} | |||
void SMsgHandler::handleClipboardProvide(rdr::U32 /*flags*/, | |||
void SMsgHandler::handleClipboardProvide(uint32_t /*flags*/, | |||
const size_t* /*lengths*/, | |||
const rdr::U8* const* /*data*/) | |||
const uint8_t* const* /*data*/) | |||
{ | |||
} | |||
@@ -23,7 +23,8 @@ | |||
#ifndef __RFB_SMSGHANDLER_H__ | |||
#define __RFB_SMSGHANDLER_H__ | |||
#include <rdr/types.h> | |||
#include <stdint.h> | |||
#include <rfb/PixelFormat.h> | |||
#include <rfb/ClientParams.h> | |||
#include <rfb/InputHandler.h> | |||
@@ -46,22 +47,22 @@ namespace rfb { | |||
virtual void clientInit(bool shared); | |||
virtual void setPixelFormat(const PixelFormat& pf); | |||
virtual void setEncodings(int nEncodings, const rdr::S32* encodings); | |||
virtual void setEncodings(int nEncodings, const int32_t* encodings); | |||
virtual void framebufferUpdateRequest(const Rect& r, bool incremental) = 0; | |||
virtual void setDesktopSize(int fb_width, int fb_height, | |||
const ScreenSet& layout) = 0; | |||
virtual void fence(rdr::U32 flags, unsigned len, const char data[]) = 0; | |||
virtual void fence(uint32_t flags, unsigned len, const char data[]) = 0; | |||
virtual void enableContinuousUpdates(bool enable, | |||
int x, int y, int w, int h) = 0; | |||
virtual void handleClipboardCaps(rdr::U32 flags, | |||
const rdr::U32* lengths); | |||
virtual void handleClipboardRequest(rdr::U32 flags); | |||
virtual void handleClipboardCaps(uint32_t flags, | |||
const uint32_t* lengths); | |||
virtual void handleClipboardRequest(uint32_t flags); | |||
virtual void handleClipboardPeek(); | |||
virtual void handleClipboardNotify(rdr::U32 flags); | |||
virtual void handleClipboardProvide(rdr::U32 flags, | |||
virtual void handleClipboardNotify(uint32_t flags); | |||
virtual void handleClipboardProvide(uint32_t flags, | |||
const size_t* lengths, | |||
const rdr::U8* const* data); | |||
const uint8_t* const* data); | |||
// InputHandler interface | |||
// The InputHandler methods will be called for the corresponding messages. |
@@ -25,6 +25,7 @@ | |||
#include <rdr/InStream.h> | |||
#include <rdr/ZlibInStream.h> | |||
#include <rdr/types.h> | |||
#include <rfb/msgTypes.h> | |||
#include <rfb/qemuTypes.h> | |||
@@ -153,7 +154,7 @@ bool SMsgReader::readSetDesktopSize() | |||
{ | |||
int width, height; | |||
int screens, i; | |||
rdr::U32 id, flags; | |||
uint32_t id, flags; | |||
int sx, sy, sw, sh; | |||
ScreenSet layout; | |||
@@ -225,8 +226,8 @@ bool SMsgReader::readEnableContinuousUpdates() | |||
bool SMsgReader::readFence() | |||
{ | |||
rdr::U32 flags; | |||
rdr::U8 len; | |||
uint32_t flags; | |||
uint8_t len; | |||
char data[64]; | |||
if (!is->hasData(3 + 4 + 1)) | |||
@@ -263,7 +264,7 @@ bool SMsgReader::readKeyEvent() | |||
return false; | |||
bool down = is->readU8(); | |||
is->skip(2); | |||
rdr::U32 key = is->readU32(); | |||
uint32_t key = is->readU32(); | |||
handler->keyEvent(key, 0, down); | |||
return true; | |||
} | |||
@@ -288,10 +289,10 @@ bool SMsgReader::readClientCutText() | |||
is->setRestorePoint(); | |||
is->skip(3); | |||
rdr::U32 len = is->readU32(); | |||
uint32_t len = is->readU32(); | |||
if (len & 0x80000000) { | |||
rdr::S32 slen = len; | |||
int32_t slen = len; | |||
slen = -slen; | |||
if (readExtendedClipboard(slen)) { | |||
is->clearRestorePoint(); | |||
@@ -320,10 +321,10 @@ bool SMsgReader::readClientCutText() | |||
return true; | |||
} | |||
bool SMsgReader::readExtendedClipboard(rdr::S32 len) | |||
bool SMsgReader::readExtendedClipboard(int32_t len) | |||
{ | |||
rdr::U32 flags; | |||
rdr::U32 action; | |||
uint32_t flags; | |||
uint32_t action; | |||
if (!is->hasData(len)) | |||
return false; | |||
@@ -342,7 +343,7 @@ bool SMsgReader::readExtendedClipboard(rdr::S32 len) | |||
if (action & clipboardCaps) { | |||
int i; | |||
size_t num; | |||
rdr::U32 lengths[16]; | |||
uint32_t lengths[16]; | |||
num = 0; | |||
for (i = 0;i < 16;i++) { | |||
@@ -350,7 +351,7 @@ bool SMsgReader::readExtendedClipboard(rdr::S32 len) | |||
num++; | |||
} | |||
if (len < (rdr::S32)(4 + 4*num)) | |||
if (len < (int32_t)(4 + 4*num)) | |||
throw Exception("Invalid extended clipboard message"); | |||
num = 0; | |||
@@ -366,7 +367,7 @@ bool SMsgReader::readExtendedClipboard(rdr::S32 len) | |||
int i; | |||
size_t num; | |||
size_t lengths[16]; | |||
rdr::U8* buffers[16]; | |||
uint8_t* buffers[16]; | |||
zis.setUnderlying(is, len - 4); | |||
@@ -407,7 +408,7 @@ bool SMsgReader::readExtendedClipboard(rdr::S32 len) | |||
if (!zis.hasData(lengths[num])) | |||
throw Exception("Extended clipboard decode error"); | |||
buffers[num] = new rdr::U8[lengths[num]]; | |||
buffers[num] = new uint8_t[lengths[num]]; | |||
zis.readBytes(buffers[num], lengths[num]); | |||
num++; | |||
} | |||
@@ -476,8 +477,8 @@ bool SMsgReader::readQEMUKeyEvent() | |||
if (!is->hasData(2 + 4 + 4)) | |||
return false; | |||
bool down = is->readU16(); | |||
rdr::U32 keysym = is->readU32(); | |||
rdr::U32 keycode = is->readU32(); | |||
uint32_t keysym = is->readU32(); | |||
uint32_t keycode = is->readU32(); | |||
if (!keycode) { | |||
vlog.error("Key event without keycode - ignoring"); | |||
return true; |
@@ -54,7 +54,7 @@ namespace rfb { | |||
bool readKeyEvent(); | |||
bool readPointerEvent(); | |||
bool readClientCutText(); | |||
bool readExtendedClipboard(rdr::S32 len); | |||
bool readExtendedClipboard(int32_t len); | |||
bool readQEMUMessage(); | |||
bool readQEMUKeyEvent(); | |||
@@ -70,7 +70,7 @@ namespace rfb { | |||
stateEnum state; | |||
rdr::U8 currentMsgType; | |||
uint8_t currentMsgType; | |||
}; | |||
} | |||
#endif |
@@ -27,6 +27,7 @@ | |||
#include <rdr/OutStream.h> | |||
#include <rdr/MemOutStream.h> | |||
#include <rdr/ZlibOutStream.h> | |||
#include <rdr/types.h> | |||
#include <rfb/msgTypes.h> | |||
#include <rfb/fenceTypes.h> | |||
@@ -56,7 +57,7 @@ SMsgWriter::~SMsgWriter() | |||
{ | |||
} | |||
void SMsgWriter::writeServerInit(rdr::U16 width, rdr::U16 height, | |||
void SMsgWriter::writeServerInit(uint16_t width, uint16_t height, | |||
const PixelFormat& pf, const char* name) | |||
{ | |||
os->writeU16(width); | |||
@@ -68,9 +69,9 @@ void SMsgWriter::writeServerInit(rdr::U16 width, rdr::U16 height, | |||
} | |||
void SMsgWriter::writeSetColourMapEntries(int firstColour, int nColours, | |||
const rdr::U16 red[], | |||
const rdr::U16 green[], | |||
const rdr::U16 blue[]) | |||
const uint16_t red[], | |||
const uint16_t green[], | |||
const uint16_t blue[]) | |||
{ | |||
startMsg(msgTypeSetColourMapEntries); | |||
os->pad(1); | |||
@@ -105,8 +106,8 @@ void SMsgWriter::writeServerCutText(const char* str) | |||
endMsg(); | |||
} | |||
void SMsgWriter::writeClipboardCaps(rdr::U32 caps, | |||
const rdr::U32* lengths) | |||
void SMsgWriter::writeClipboardCaps(uint32_t caps, | |||
const uint32_t* lengths) | |||
{ | |||
size_t i, count; | |||
@@ -134,7 +135,7 @@ void SMsgWriter::writeClipboardCaps(rdr::U32 caps, | |||
endMsg(); | |||
} | |||
void SMsgWriter::writeClipboardRequest(rdr::U32 flags) | |||
void SMsgWriter::writeClipboardRequest(uint32_t flags) | |||
{ | |||
if (!client->supportsEncoding(pseudoEncodingExtendedClipboard)) | |||
throw Exception("Client does not support extended clipboard"); | |||
@@ -148,7 +149,7 @@ void SMsgWriter::writeClipboardRequest(rdr::U32 flags) | |||
endMsg(); | |||
} | |||
void SMsgWriter::writeClipboardPeek(rdr::U32 flags) | |||
void SMsgWriter::writeClipboardPeek(uint32_t flags) | |||
{ | |||
if (!client->supportsEncoding(pseudoEncodingExtendedClipboard)) | |||
throw Exception("Client does not support extended clipboard"); | |||
@@ -162,7 +163,7 @@ void SMsgWriter::writeClipboardPeek(rdr::U32 flags) | |||
endMsg(); | |||
} | |||
void SMsgWriter::writeClipboardNotify(rdr::U32 flags) | |||
void SMsgWriter::writeClipboardNotify(uint32_t flags) | |||
{ | |||
if (!client->supportsEncoding(pseudoEncodingExtendedClipboard)) | |||
throw Exception("Client does not support extended clipboard"); | |||
@@ -176,9 +177,9 @@ void SMsgWriter::writeClipboardNotify(rdr::U32 flags) | |||
endMsg(); | |||
} | |||
void SMsgWriter::writeClipboardProvide(rdr::U32 flags, | |||
void SMsgWriter::writeClipboardProvide(uint32_t flags, | |||
const size_t* lengths, | |||
const rdr::U8* const* data) | |||
const uint8_t* const* data) | |||
{ | |||
rdr::MemOutStream mos; | |||
rdr::ZlibOutStream zos; | |||
@@ -211,7 +212,7 @@ void SMsgWriter::writeClipboardProvide(rdr::U32 flags, | |||
endMsg(); | |||
} | |||
void SMsgWriter::writeFence(rdr::U32 flags, unsigned len, const char data[]) | |||
void SMsgWriter::writeFence(uint32_t flags, unsigned len, const char data[]) | |||
{ | |||
if (!client->supportsEncoding(pseudoEncodingFence)) | |||
throw Exception("Client does not support fences"); | |||
@@ -242,7 +243,7 @@ void SMsgWriter::writeEndOfContinuousUpdates() | |||
endMsg(); | |||
} | |||
void SMsgWriter::writeDesktopSize(rdr::U16 reason, rdr::U16 result) | |||
void SMsgWriter::writeDesktopSize(uint16_t reason, uint16_t result) | |||
{ | |||
ExtendedDesktopSizeMsg msg; | |||
@@ -445,8 +446,8 @@ void SMsgWriter::writePseudoRects() | |||
rdr::U8Array data(cursor.width()*cursor.height() * (client->pf().bpp/8)); | |||
rdr::U8Array mask(cursor.getMask()); | |||
const rdr::U8* in; | |||
rdr::U8* out; | |||
const uint8_t* in; | |||
uint8_t* out; | |||
in = cursor.getBuffer(); | |||
out = data.buf; | |||
@@ -538,8 +539,8 @@ void SMsgWriter::writeSetDesktopSizeRect(int width, int height) | |||
os->writeU32(pseudoEncodingDesktopSize); | |||
} | |||
void SMsgWriter::writeExtendedDesktopSizeRect(rdr::U16 reason, | |||
rdr::U16 result, | |||
void SMsgWriter::writeExtendedDesktopSizeRect(uint16_t reason, | |||
uint16_t result, | |||
int fb_width, | |||
int fb_height, | |||
const ScreenSet& layout) | |||
@@ -632,7 +633,7 @@ void SMsgWriter::writeSetXCursorRect(int width, int height, | |||
void SMsgWriter::writeSetCursorWithAlphaRect(int width, int height, | |||
int hotspotX, int hotspotY, | |||
const rdr::U8* data) | |||
const uint8_t* data) | |||
{ | |||
if (!client->supportsEncoding(pseudoEncodingCursorWithAlpha)) | |||
throw Exception("Client does not support local cursors"); | |||
@@ -660,7 +661,7 @@ void SMsgWriter::writeSetCursorWithAlphaRect(int width, int height, | |||
void SMsgWriter::writeSetVMwareCursorRect(int width, int height, | |||
int hotspotX, int hotspotY, | |||
const rdr::U8* data) | |||
const uint8_t* data) | |||
{ | |||
if (!client->supportsEncoding(pseudoEncodingVMwareCursor)) | |||
throw Exception("Client does not support local cursors"); | |||
@@ -694,7 +695,7 @@ void SMsgWriter::writeSetVMwareCursorPositionRect(int hotspotX, int hotspotY) | |||
os->writeU32(pseudoEncodingVMwareCursorPosition); | |||
} | |||
void SMsgWriter::writeLEDStateRect(rdr::U8 state) | |||
void SMsgWriter::writeLEDStateRect(uint8_t state) | |||
{ | |||
if (!client->supportsEncoding(pseudoEncodingLEDState) && | |||
!client->supportsEncoding(pseudoEncodingVMwareLEDState)) |
@@ -23,7 +23,8 @@ | |||
#ifndef __RFB_SMSGWRITER_H__ | |||
#define __RFB_SMSGWRITER_H__ | |||
#include <rdr/types.h> | |||
#include <stdint.h> | |||
#include <rfb/encodings.h> | |||
#include <rfb/ScreenSet.h> | |||
@@ -42,7 +43,7 @@ namespace rfb { | |||
// writeServerInit() must only be called at the appropriate time in the | |||
// protocol initialisation. | |||
void writeServerInit(rdr::U16 width, rdr::U16 height, | |||
void writeServerInit(uint16_t width, uint16_t height, | |||
const PixelFormat& pf, const char* name); | |||
// Methods to write normal protocol messages | |||
@@ -50,24 +51,24 @@ namespace rfb { | |||
// writeSetColourMapEntries() writes a setColourMapEntries message, using | |||
// the given colour entries. | |||
void writeSetColourMapEntries(int firstColour, int nColours, | |||
const rdr::U16 red[], | |||
const rdr::U16 green[], | |||
const rdr::U16 blue[]); | |||
const uint16_t red[], | |||
const uint16_t green[], | |||
const uint16_t blue[]); | |||
// writeBell() does the obvious thing. | |||
void writeBell(); | |||
void writeServerCutText(const char* str); | |||
void writeClipboardCaps(rdr::U32 caps, const rdr::U32* lengths); | |||
void writeClipboardRequest(rdr::U32 flags); | |||
void writeClipboardPeek(rdr::U32 flags); | |||
void writeClipboardNotify(rdr::U32 flags); | |||
void writeClipboardProvide(rdr::U32 flags, const size_t* lengths, | |||
const rdr::U8* const* data); | |||
void writeClipboardCaps(uint32_t caps, const uint32_t* lengths); | |||
void writeClipboardRequest(uint32_t flags); | |||
void writeClipboardPeek(uint32_t flags); | |||
void writeClipboardNotify(uint32_t flags); | |||
void writeClipboardProvide(uint32_t flags, const size_t* lengths, | |||
const uint8_t* const* data); | |||
// writeFence() sends a new fence request or response to the client. | |||
void writeFence(rdr::U32 flags, unsigned len, const char data[]); | |||
void writeFence(uint32_t flags, unsigned len, const char data[]); | |||
// writeEndOfContinuousUpdates() indicates that we have left continuous | |||
// updates mode. | |||
@@ -75,7 +76,7 @@ namespace rfb { | |||
// writeDesktopSize() won't actually write immediately, but will | |||
// write the relevant pseudo-rectangle as part of the next update. | |||
void writeDesktopSize(rdr::U16 reason, rdr::U16 result=0); | |||
void writeDesktopSize(uint16_t reason, uint16_t result=0); | |||
void writeSetDesktopName(); | |||
@@ -128,7 +129,7 @@ namespace rfb { | |||
void writeNoDataRects(); | |||
void writeSetDesktopSizeRect(int width, int height); | |||
void writeExtendedDesktopSizeRect(rdr::U16 reason, rdr::U16 result, | |||
void writeExtendedDesktopSizeRect(uint16_t reason, uint16_t result, | |||
int fb_width, int fb_height, | |||
const ScreenSet& layout); | |||
void writeSetDesktopNameRect(const char *name); | |||
@@ -140,12 +141,12 @@ namespace rfb { | |||
const void* data, const void* mask); | |||
void writeSetCursorWithAlphaRect(int width, int height, | |||
int hotspotX, int hotspotY, | |||
const rdr::U8* data); | |||
const uint8_t* data); | |||
void writeSetVMwareCursorRect(int width, int height, | |||
int hotspotX, int hotspotY, | |||
const rdr::U8* data); | |||
const uint8_t* data); | |||
void writeSetVMwareCursorPositionRect(int hotspotX, int hotspotY); | |||
void writeLEDStateRect(rdr::U8 state); | |||
void writeLEDStateRect(uint8_t state); | |||
void writeQEMUKeyEventRect(); | |||
ClientParams* client; | |||
@@ -161,7 +162,7 @@ namespace rfb { | |||
bool needQEMUKeyEvent; | |||
typedef struct { | |||
rdr::U16 reason, result; | |||
uint16_t reason, result; | |||
} ExtendedDesktopSizeMsg; | |||
std::list<ExtendedDesktopSizeMsg> extendedDesktopSizeMsgs; |
@@ -43,7 +43,6 @@ | |||
#ifndef __RFB_SSECURITY_H__ | |||
#define __RFB_SSECURITY_H__ | |||
#include <rdr/types.h> | |||
#include <rfb/SConnection.h> | |||
#include <rfb/util.h> | |||
#include <list> |
@@ -39,6 +39,7 @@ | |||
#include <rfb/Exception.h> | |||
#include <rdr/AESInStream.h> | |||
#include <rdr/AESOutStream.h> | |||
#include <rdr/types.h> | |||
#if !defined(WIN32) && !defined(__APPLE__) | |||
#include <rfb/UnixPasswordValidator.h> | |||
#endif | |||
@@ -68,7 +69,7 @@ BoolParameter SSecurityRSAAES::requireUsername | |||
("RequireUsername", "Require username for the RSA-AES security types", | |||
false, ConfServer); | |||
SSecurityRSAAES::SSecurityRSAAES(SConnection* sc, rdr::U32 _secType, | |||
SSecurityRSAAES::SSecurityRSAAES(SConnection* sc, uint32_t _secType, | |||
int _keySize, bool _isAllEncrypted) | |||
: SSecurity(sc), state(SendPublicKey), | |||
keySize(_keySize), isAllEncrypted(_isAllEncrypted), secType(_secType), | |||
@@ -107,7 +108,7 @@ void SSecurityRSAAES::cleanup() | |||
delete raos; | |||
} | |||
static inline ssize_t findSubstr(rdr::U8* data, size_t size, const char *pattern) | |||
static inline ssize_t findSubstr(uint8_t* data, size_t size, const char *pattern) | |||
{ | |||
size_t patternLength = strlen(pattern); | |||
for (size_t i = 0; i + patternLength < size; ++i) { | |||
@@ -121,8 +122,8 @@ next: | |||
return -1; | |||
} | |||
static bool loadPEM(rdr::U8* data, size_t size, const char *begin, | |||
const char *end, rdr::U8** der, size_t *derSize) | |||
static bool loadPEM(uint8_t* data, size_t size, const char *begin, | |||
const char *end, uint8_t** der, size_t *derSize) | |||
{ | |||
ssize_t pos1 = findSubstr(data, size, begin); | |||
if (pos1 == -1) | |||
@@ -134,7 +135,7 @@ static bool loadPEM(rdr::U8* data, size_t size, const char *begin, | |||
char *derBase64 = (char *)data + pos1; | |||
if (!base64Size) | |||
return false; | |||
*der = new rdr::U8[BASE64_DECODE_LENGTH(base64Size)]; | |||
*der = new uint8_t[BASE64_DECODE_LENGTH(base64Size)]; | |||
struct base64_decode_ctx ctx; | |||
base64_decode_init(&ctx); | |||
if (!base64_decode_update(&ctx, derSize, *der, base64Size, derBase64)) | |||
@@ -180,7 +181,7 @@ void SSecurityRSAAES::loadPrivateKey() | |||
throw ConnFailedException("failed to import key"); | |||
} | |||
void SSecurityRSAAES::loadPKCS1Key(const rdr::U8* data, size_t size) | |||
void SSecurityRSAAES::loadPKCS1Key(const uint8_t* data, size_t size) | |||
{ | |||
struct rsa_public_key pub; | |||
rsa_private_key_init(&serverKey); | |||
@@ -191,14 +192,14 @@ void SSecurityRSAAES::loadPKCS1Key(const rdr::U8* data, size_t size) | |||
throw ConnFailedException("failed to import key"); | |||
} | |||
serverKeyLength = serverKey.size * 8; | |||
serverKeyN = new rdr::U8[serverKey.size]; | |||
serverKeyE = new rdr::U8[serverKey.size]; | |||
serverKeyN = new uint8_t[serverKey.size]; | |||
serverKeyE = new uint8_t[serverKey.size]; | |||
nettle_mpz_get_str_256(serverKey.size, serverKeyN, pub.n); | |||
nettle_mpz_get_str_256(serverKey.size, serverKeyE, pub.e); | |||
rsa_public_key_clear(&pub); | |||
} | |||
void SSecurityRSAAES::loadPKCS8Key(const rdr::U8* data, size_t size) | |||
void SSecurityRSAAES::loadPKCS8Key(const uint8_t* data, size_t size) | |||
{ | |||
struct asn1_der_iterator i, j; | |||
uint32_t version; | |||
@@ -296,8 +297,8 @@ bool SSecurityRSAAES::readPublicKey() | |||
if (!is->hasDataOrRestore(size * 2)) | |||
return false; | |||
is->clearRestorePoint(); | |||
clientKeyE = new rdr::U8[size]; | |||
clientKeyN = new rdr::U8[size]; | |||
clientKeyE = new uint8_t[size]; | |||
clientKeyN = new uint8_t[size]; | |||
is->readBytes(clientKeyN, size); | |||
is->readBytes(clientKeyE, size); | |||
rsa_public_key_init(&clientKey); | |||
@@ -336,7 +337,7 @@ void SSecurityRSAAES::writeRandom() | |||
mpz_clear(x); | |||
throw ConnFailedException("failed to encrypt random"); | |||
} | |||
rdr::U8* buffer = new rdr::U8[clientKey.size]; | |||
uint8_t* buffer = new uint8_t[clientKey.size]; | |||
nettle_mpz_get_str_256(clientKey.size, buffer, x); | |||
mpz_clear(x); | |||
os->writeU16(clientKey.size); | |||
@@ -357,7 +358,7 @@ bool SSecurityRSAAES::readRandom() | |||
if (!is->hasDataOrRestore(size)) | |||
return false; | |||
is->clearRestorePoint(); | |||
rdr::U8* buffer = new rdr::U8[size]; | |||
uint8_t* buffer = new uint8_t[size]; | |||
is->readBytes(buffer, size); | |||
size_t randomSize = keySize / 8; | |||
mpz_t x; | |||
@@ -376,7 +377,7 @@ void SSecurityRSAAES::setCipher() | |||
{ | |||
rawis = sc->getInStream(); | |||
rawos = sc->getOutStream(); | |||
rdr::U8 key[32]; | |||
uint8_t key[32]; | |||
if (keySize == 128) { | |||
struct sha1_ctx ctx; | |||
sha1_init(&ctx); | |||
@@ -408,20 +409,20 @@ void SSecurityRSAAES::setCipher() | |||
void SSecurityRSAAES::writeHash() | |||
{ | |||
rdr::U8 hash[32]; | |||
uint8_t hash[32]; | |||
size_t len = serverKeyLength; | |||
rdr::U8 lenServerKey[4] = { | |||
(rdr::U8)((len & 0xff000000) >> 24), | |||
(rdr::U8)((len & 0xff0000) >> 16), | |||
(rdr::U8)((len & 0xff00) >> 8), | |||
(rdr::U8)(len & 0xff) | |||
uint8_t lenServerKey[4] = { | |||
(uint8_t)((len & 0xff000000) >> 24), | |||
(uint8_t)((len & 0xff0000) >> 16), | |||
(uint8_t)((len & 0xff00) >> 8), | |||
(uint8_t)(len & 0xff) | |||
}; | |||
len = clientKeyLength; | |||
rdr::U8 lenClientKey[4] = { | |||
(rdr::U8)((len & 0xff000000) >> 24), | |||
(rdr::U8)((len & 0xff0000) >> 16), | |||
(rdr::U8)((len & 0xff00) >> 8), | |||
(rdr::U8)(len & 0xff) | |||
uint8_t lenClientKey[4] = { | |||
(uint8_t)((len & 0xff000000) >> 24), | |||
(uint8_t)((len & 0xff0000) >> 16), | |||
(uint8_t)((len & 0xff00) >> 8), | |||
(uint8_t)(len & 0xff) | |||
}; | |||
int hashSize; | |||
if (keySize == 128) { | |||
@@ -453,25 +454,25 @@ void SSecurityRSAAES::writeHash() | |||
bool SSecurityRSAAES::readHash() | |||
{ | |||
rdr::U8 hash[32]; | |||
rdr::U8 realHash[32]; | |||
uint8_t hash[32]; | |||
uint8_t realHash[32]; | |||
int hashSize = keySize == 128 ? 20 : 32; | |||
if (!rais->hasData(hashSize)) | |||
return false; | |||
rais->readBytes(hash, hashSize); | |||
size_t len = serverKeyLength; | |||
rdr::U8 lenServerKey[4] = { | |||
(rdr::U8)((len & 0xff000000) >> 24), | |||
(rdr::U8)((len & 0xff0000) >> 16), | |||
(rdr::U8)((len & 0xff00) >> 8), | |||
(rdr::U8)(len & 0xff) | |||
uint8_t lenServerKey[4] = { | |||
(uint8_t)((len & 0xff000000) >> 24), | |||
(uint8_t)((len & 0xff0000) >> 16), | |||
(uint8_t)((len & 0xff00) >> 8), | |||
(uint8_t)(len & 0xff) | |||
}; | |||
len = clientKeyLength; | |||
rdr::U8 lenClientKey[4] = { | |||
(rdr::U8)((len & 0xff000000) >> 24), | |||
(rdr::U8)((len & 0xff0000) >> 16), | |||
(rdr::U8)((len & 0xff00) >> 8), | |||
(rdr::U8)(len & 0xff) | |||
uint8_t lenClientKey[4] = { | |||
(uint8_t)((len & 0xff000000) >> 24), | |||
(uint8_t)((len & 0xff0000) >> 16), | |||
(uint8_t)((len & 0xff00) >> 8), | |||
(uint8_t)(len & 0xff) | |||
}; | |||
if (keySize == 128) { | |||
struct sha1_ctx ctx; | |||
@@ -531,7 +532,7 @@ bool SSecurityRSAAES::readCredentials() | |||
rais->setRestorePoint(); | |||
if (!rais->hasData(1)) | |||
return false; | |||
rdr::U8 lenUsername = rais->readU8(); | |||
uint8_t lenUsername = rais->readU8(); | |||
if (!rais->hasDataOrRestore(lenUsername + 1)) | |||
return false; | |||
if (!username.buf) { | |||
@@ -541,7 +542,7 @@ bool SSecurityRSAAES::readCredentials() | |||
} else { | |||
rais->skip(lenUsername); | |||
} | |||
rdr::U8 lenPassword = rais->readU8(); | |||
uint8_t lenPassword = rais->readU8(); | |||
if (!rais->hasDataOrRestore(lenPassword)) | |||
return false; | |||
password.replaceBuf(new char[lenPassword + 1]); |
@@ -33,7 +33,7 @@ namespace rfb { | |||
class SSecurityRSAAES : public SSecurity { | |||
public: | |||
SSecurityRSAAES(SConnection* sc, rdr::U32 secType, | |||
SSecurityRSAAES(SConnection* sc, uint32_t secType, | |||
int keySize, bool isAllEncrypted); | |||
virtual ~SSecurityRSAAES(); | |||
virtual bool processMsg(); | |||
@@ -50,8 +50,8 @@ namespace rfb { | |||
private: | |||
void cleanup(); | |||
void loadPrivateKey(); | |||
void loadPKCS1Key(const rdr::U8* data, size_t size); | |||
void loadPKCS8Key(const rdr::U8* data, size_t size); | |||
void loadPKCS1Key(const uint8_t* data, size_t size); | |||
void loadPKCS8Key(const uint8_t* data, size_t size); | |||
void writePublicKey(); | |||
bool readPublicKey(); | |||
void writeRandom(); | |||
@@ -68,17 +68,17 @@ namespace rfb { | |||
int state; | |||
int keySize; | |||
bool isAllEncrypted; | |||
rdr::U32 secType; | |||
uint32_t secType; | |||
struct rsa_private_key serverKey; | |||
struct rsa_public_key clientKey; | |||
rdr::U32 serverKeyLength; | |||
rdr::U8* serverKeyN; | |||
rdr::U8* serverKeyE; | |||
rdr::U32 clientKeyLength; | |||
rdr::U8* clientKeyN; | |||
rdr::U8* clientKeyE; | |||
rdr::U8 serverRandom[32]; | |||
rdr::U8 clientRandom[32]; | |||
uint32_t serverKeyLength; | |||
uint8_t* serverKeyN; | |||
uint8_t* serverKeyE; | |||
uint32_t clientKeyLength; | |||
uint8_t* clientKeyN; | |||
uint8_t* clientKeyE; | |||
uint8_t serverRandom[32]; | |||
uint8_t clientRandom[32]; | |||
CharArray username; | |||
CharArray password; |
@@ -64,7 +64,7 @@ bool SSecurityVeNCrypt::processMsg() | |||
{ | |||
rdr::InStream* is = sc->getInStream(); | |||
rdr::OutStream* os = sc->getOutStream(); | |||
rdr::U8 i; | |||
uint8_t i; | |||
/* VeNCrypt initialization */ | |||
@@ -93,7 +93,7 @@ bool SSecurityVeNCrypt::processMsg() | |||
haveRecvdMinorVersion = true; | |||
/* WORD value with major version in upper 8 bits and minor version in lower 8 bits */ | |||
U16 Version = (((U16)majorVersion) << 8) | ((U16)minorVersion); | |||
uint16_t Version = (((uint16_t)majorVersion) << 8) | ((uint16_t)minorVersion); | |||
switch (Version) { | |||
case 0x0000: /* 0.0 - The client cannot support us! */ | |||
@@ -115,16 +115,16 @@ bool SSecurityVeNCrypt::processMsg() | |||
} | |||
/* | |||
* send number of supported VeNCrypt authentication types (U8) followed | |||
* by authentication types (U32s) | |||
* send number of supported VeNCrypt authentication types (uint8_t) | |||
* followed by authentication types (uint32_t:s) | |||
*/ | |||
if (!haveSentTypes) { | |||
list<U32> listSubTypes; | |||
list<uint32_t> listSubTypes; | |||
listSubTypes = security->GetEnabledExtSecTypes(); | |||
numTypes = listSubTypes.size(); | |||
subTypes = new U32[numTypes]; | |||
subTypes = new uint32_t[numTypes]; | |||
for (i = 0; i < numTypes; i++) { | |||
subTypes[i] = listSubTypes.front(); |
@@ -44,8 +44,8 @@ namespace rfb { | |||
SecurityServer *security; | |||
bool haveSentVersion, haveRecvdMajorVersion, haveRecvdMinorVersion; | |||
bool haveSentTypes, haveChosenType; | |||
rdr::U8 majorVersion, minorVersion, numTypes; | |||
rdr::U32 *subTypes, chosenType; | |||
uint8_t majorVersion, minorVersion, numTypes; | |||
uint32_t *subTypes, chosenType; | |||
}; | |||
} | |||
#endif |
@@ -60,10 +60,10 @@ SSecurityVncAuth::SSecurityVncAuth(SConnection* sc) | |||
bool SSecurityVncAuth::verifyResponse(const PlainPasswd &password) | |||
{ | |||
rdr::U8 expectedResponse[vncAuthChallengeSize]; | |||
uint8_t expectedResponse[vncAuthChallengeSize]; | |||
// Calculate the expected response | |||
rdr::U8 key[8]; | |||
uint8_t key[8]; | |||
int pwdLen = strlen(password.buf); | |||
for (int i=0; i<8; i++) | |||
key[i] = i<pwdLen ? password.buf[i] : 0; |
@@ -24,11 +24,12 @@ | |||
#ifndef __RFB_SSECURITYVNCAUTH_H__ | |||
#define __RFB_SSECURITYVNCAUTH_H__ | |||
#include <stdint.h> | |||
#include <rfb/Configuration.h> | |||
#include <rfb/Password.h> | |||
#include <rfb/SSecurity.h> | |||
#include <rfb/Security.h> | |||
#include <rdr/types.h> | |||
namespace rfb { | |||
@@ -61,8 +62,8 @@ namespace rfb { | |||
private: | |||
bool verifyResponse(const PlainPasswd &password); | |||
enum {vncAuthChallengeSize = 16}; | |||
rdr::U8 challenge[vncAuthChallengeSize]; | |||
rdr::U8 response[vncAuthChallengeSize]; | |||
uint8_t challenge[vncAuthChallengeSize]; | |||
uint8_t response[vncAuthChallengeSize]; | |||
bool sentChallenge; | |||
VncAuthPasswdGetter* pg; | |||
SConnection::AccessRights accessRights; |
@@ -23,8 +23,8 @@ | |||
#include <stdio.h> | |||
#include <string.h> | |||
#include <stdint.h> | |||
#include <rdr/types.h> | |||
#include <rfb/Rect.h> | |||
#include <list> | |||
#include <set> | |||
@@ -38,7 +38,7 @@ namespace rfb { | |||
struct Screen { | |||
Screen(void) : id(0), flags(0) {}; | |||
Screen(rdr::U32 id_, int x_, int y_, int w_, int h_, rdr::U32 flags_) : | |||
Screen(uint32_t id_, int x_, int y_, int w_, int h_, uint32_t flags_) : | |||
id(id_), dimensions(x_, y_, x_+w_, y_+h_), flags(flags_) {}; | |||
inline bool operator==(const Screen& r) const { | |||
@@ -51,9 +51,9 @@ namespace rfb { | |||
return true; | |||
} | |||
rdr::U32 id; | |||
uint32_t id; | |||
Rect dimensions; | |||
rdr::U32 flags; | |||
uint32_t flags; | |||
}; | |||
// rfb::ScreenSet | |||
@@ -75,7 +75,7 @@ namespace rfb { | |||
inline int num_screens(void) const { return screens.size(); }; | |||
inline void add_screen(const Screen screen) { screens.push_back(screen); }; | |||
inline void remove_screen(rdr::U32 id) { | |||
inline void remove_screen(uint32_t id) { | |||
std::list<Screen>::iterator iter, nextiter; | |||
for (iter = screens.begin();iter != screens.end();iter = nextiter) { | |||
nextiter = iter; nextiter++; | |||
@@ -86,7 +86,7 @@ namespace rfb { | |||
inline bool validate(int fb_width, int fb_height) const { | |||
std::list<Screen>::const_iterator iter; | |||
std::set<rdr::U32> seen_ids; | |||
std::set<uint32_t> seen_ids; | |||
Rect fb_rect; | |||
if (screens.empty()) |
@@ -69,10 +69,10 @@ Security::Security(StringParameter &secTypes) | |||
delete [] secTypesStr; | |||
} | |||
const std::list<rdr::U8> Security::GetEnabledSecTypes(void) | |||
const std::list<uint8_t> Security::GetEnabledSecTypes(void) | |||
{ | |||
list<rdr::U8> result; | |||
list<U32>::iterator i; | |||
list<uint8_t> result; | |||
list<uint32_t>::iterator i; | |||
/* Partial workaround for Vino's stupid behaviour. It doesn't allow | |||
* the basic authentication types as part of the VeNCrypt handshake, | |||
@@ -93,10 +93,10 @@ const std::list<rdr::U8> Security::GetEnabledSecTypes(void) | |||
return result; | |||
} | |||
const std::list<rdr::U32> Security::GetEnabledExtSecTypes(void) | |||
const std::list<uint32_t> Security::GetEnabledExtSecTypes(void) | |||
{ | |||
list<rdr::U32> result; | |||
list<U32>::iterator i; | |||
list<uint32_t> result; | |||
list<uint32_t>::iterator i; | |||
for (i = enabledSecTypes.begin(); i != enabledSecTypes.end(); i++) | |||
if (*i != secTypeVeNCrypt) /* Do not include VeNCrypt type to avoid loops */ | |||
@@ -105,9 +105,9 @@ const std::list<rdr::U32> Security::GetEnabledExtSecTypes(void) | |||
return result; | |||
} | |||
void Security::EnableSecType(U32 secType) | |||
void Security::EnableSecType(uint32_t secType) | |||
{ | |||
list<U32>::iterator i; | |||
list<uint32_t>::iterator i; | |||
for (i = enabledSecTypes.begin(); i != enabledSecTypes.end(); i++) | |||
if (*i == secType) | |||
@@ -116,9 +116,9 @@ void Security::EnableSecType(U32 secType) | |||
enabledSecTypes.push_back(secType); | |||
} | |||
bool Security::IsSupported(U32 secType) | |||
bool Security::IsSupported(uint32_t secType) | |||
{ | |||
list<U32>::iterator i; | |||
list<uint32_t>::iterator i; | |||
for (i = enabledSecTypes.begin(); i != enabledSecTypes.end(); i++) | |||
if (*i == secType) | |||
@@ -131,7 +131,7 @@ bool Security::IsSupported(U32 secType) | |||
char *Security::ToString(void) | |||
{ | |||
list<U32>::iterator i; | |||
list<uint32_t>::iterator i; | |||
static char out[128]; /* Should be enough */ | |||
bool firstpass = true; | |||
const char *name; | |||
@@ -153,7 +153,7 @@ char *Security::ToString(void) | |||
return out; | |||
} | |||
rdr::U32 rfb::secTypeNum(const char* name) | |||
uint32_t rfb::secTypeNum(const char* name) | |||
{ | |||
if (strcasecmp(name, "None") == 0) return secTypeNone; | |||
if (strcasecmp(name, "VncAuth") == 0) return secTypeVncAuth; | |||
@@ -180,7 +180,7 @@ rdr::U32 rfb::secTypeNum(const char* name) | |||
return secTypeInvalid; | |||
} | |||
const char* rfb::secTypeName(rdr::U32 num) | |||
const char* rfb::secTypeName(uint32_t num) | |||
{ | |||
switch (num) { | |||
case secTypeNone: return "None"; | |||
@@ -208,13 +208,13 @@ const char* rfb::secTypeName(rdr::U32 num) | |||
} | |||
} | |||
std::list<rdr::U32> rfb::parseSecTypes(const char* types_) | |||
std::list<uint32_t> rfb::parseSecTypes(const char* types_) | |||
{ | |||
std::list<rdr::U32> result; | |||
std::list<uint32_t> result; | |||
CharArray types(strDup(types_)), type; | |||
while (types.buf) { | |||
strSplit(types.buf, ',', &type.buf, &types.buf); | |||
rdr::U32 typeNum = secTypeNum(type.buf); | |||
uint32_t typeNum = secTypeNum(type.buf); | |||
if (typeNum != secTypeInvalid) | |||
result.push_back(typeNum); | |||
} |
@@ -22,33 +22,34 @@ | |||
#ifndef __RFB_SECTYPES_H__ | |||
#define __RFB_SECTYPES_H__ | |||
#include <rdr/types.h> | |||
#include <stdint.h> | |||
#include <rfb/Configuration.h> | |||
#include <list> | |||
namespace rfb { | |||
const rdr::U8 secTypeInvalid = 0; | |||
const rdr::U8 secTypeNone = 1; | |||
const rdr::U8 secTypeVncAuth = 2; | |||
const uint8_t secTypeInvalid = 0; | |||
const uint8_t secTypeNone = 1; | |||
const uint8_t secTypeVncAuth = 2; | |||
const rdr::U8 secTypeRA2 = 5; | |||
const rdr::U8 secTypeRA2ne = 6; | |||
const uint8_t secTypeRA2 = 5; | |||
const uint8_t secTypeRA2ne = 6; | |||
const rdr::U8 secTypeSSPI = 7; | |||
const rdr::U8 secTypeSSPIne = 8; | |||
const uint8_t secTypeSSPI = 7; | |||
const uint8_t secTypeSSPIne = 8; | |||
const rdr::U8 secTypeTight = 16; | |||
const rdr::U8 secTypeUltra = 17; | |||
const rdr::U8 secTypeTLS = 18; | |||
const rdr::U8 secTypeVeNCrypt = 19; | |||
const uint8_t secTypeTight = 16; | |||
const uint8_t secTypeUltra = 17; | |||
const uint8_t secTypeTLS = 18; | |||
const uint8_t secTypeVeNCrypt = 19; | |||
const rdr::U8 secTypeDH = 30; | |||
const uint8_t secTypeDH = 30; | |||
const rdr::U8 secTypeMSLogonII = 113; | |||
const uint8_t secTypeMSLogonII = 113; | |||
const rdr::U8 secTypeRA256 = 129; | |||
const rdr::U8 secTypeRAne256 = 130; | |||
const uint8_t secTypeRA256 = 129; | |||
const uint8_t secTypeRAne256 = 130; | |||
/* VeNCrypt subtypes */ | |||
const int secTypePlain = 256; | |||
@@ -65,9 +66,9 @@ namespace rfb { | |||
// result types | |||
const rdr::U32 secResultOK = 0; | |||
const rdr::U32 secResultFailed = 1; | |||
const rdr::U32 secResultTooMany = 2; // deprecated | |||
const uint32_t secResultOK = 0; | |||
const uint32_t secResultFailed = 1; | |||
const uint32_t secResultTooMany = 2; // deprecated | |||
class Security { | |||
public: | |||
@@ -87,18 +88,18 @@ namespace rfb { | |||
*/ | |||
/* Enable/Disable certain security type */ | |||
void EnableSecType(rdr::U32 secType); | |||
void DisableSecType(rdr::U32 secType) { enabledSecTypes.remove(secType); } | |||
void EnableSecType(uint32_t secType); | |||
void DisableSecType(uint32_t secType) { enabledSecTypes.remove(secType); } | |||
void SetSecTypes(std::list<rdr::U32> &secTypes) { enabledSecTypes = secTypes; } | |||
void SetSecTypes(std::list<uint32_t> &secTypes) { enabledSecTypes = secTypes; } | |||
/* Check if certain type is supported */ | |||
bool IsSupported(rdr::U32 secType); | |||
bool IsSupported(uint32_t secType); | |||
/* Get list of enabled security types without VeNCrypt subtypes */ | |||
const std::list<rdr::U8> GetEnabledSecTypes(void); | |||
const std::list<uint8_t> GetEnabledSecTypes(void); | |||
/* Get list of enabled VeNCrypt subtypes */ | |||
const std::list<rdr::U32> GetEnabledExtSecTypes(void); | |||
const std::list<uint32_t> GetEnabledExtSecTypes(void); | |||
/* Output char* is stored in static array */ | |||
char *ToString(void); | |||
@@ -108,12 +109,12 @@ namespace rfb { | |||
#endif | |||
private: | |||
std::list<rdr::U32> enabledSecTypes; | |||
std::list<uint32_t> enabledSecTypes; | |||
}; | |||
const char* secTypeName(rdr::U32 num); | |||
rdr::U32 secTypeNum(const char* name); | |||
std::list<rdr::U32> parseSecTypes(const char* types); | |||
const char* secTypeName(uint32_t num); | |||
uint32_t secTypeNum(const char* name); | |||
std::list<uint32_t> parseSecTypes(const char* types); | |||
} | |||
#endif |
@@ -65,7 +65,7 @@ StringParameter SecurityClient::secTypes | |||
"VncAuth,None", | |||
ConfViewer); | |||
CSecurity* SecurityClient::GetCSecurity(CConnection* cc, U32 secType) | |||
CSecurity* SecurityClient::GetCSecurity(CConnection* cc, uint32_t secType) | |||
{ | |||
assert (CSecurity::upg != NULL); /* (upg == NULL) means bug in the viewer */ | |||
#if defined(HAVE_GNUTLS) || defined(HAVE_NETTLE) |
@@ -33,7 +33,7 @@ namespace rfb { | |||
SecurityClient(void) : Security(secTypes) {} | |||
/* Create client side CSecurity class instance */ | |||
CSecurity* GetCSecurity(CConnection* cc, rdr::U32 secType); | |||
CSecurity* GetCSecurity(CConnection* cc, uint32_t secType); | |||
static StringParameter secTypes; | |||
}; |
@@ -54,7 +54,7 @@ StringParameter SecurityServer::secTypes | |||
"VncAuth", | |||
ConfServer); | |||
SSecurity* SecurityServer::GetSSecurity(SConnection* sc, U32 secType) | |||
SSecurity* SecurityServer::GetSSecurity(SConnection* sc, uint32_t secType) | |||
{ | |||
if (!IsSupported(secType)) | |||
goto bail; |
@@ -33,7 +33,7 @@ namespace rfb { | |||
SecurityServer(void) : Security(secTypes) {} | |||
/* Create server side SSecurity class instance */ | |||
SSecurity* GetSSecurity(SConnection* sc, rdr::U32 secType); | |||
SSecurity* GetSSecurity(SConnection* sc, uint32_t secType); | |||
static StringParameter secTypes; | |||
}; |