aboutsummaryrefslogtreecommitdiffstats
path: root/common/rdr
diff options
context:
space:
mode:
Diffstat (limited to 'common/rdr')
-rw-r--r--common/rdr/AESInStream.cxx19
-rw-r--r--common/rdr/AESInStream.h4
-rw-r--r--common/rdr/AESOutStream.cxx7
-rw-r--r--common/rdr/AESOutStream.h8
-rw-r--r--common/rdr/BufferedInStream.cxx8
-rw-r--r--common/rdr/BufferedInStream.h2
-rw-r--r--common/rdr/BufferedOutStream.cxx8
-rw-r--r--common/rdr/BufferedOutStream.h4
-rw-r--r--common/rdr/FdInStream.cxx2
-rw-r--r--common/rdr/FileInStream.cxx2
-rw-r--r--common/rdr/HexInStream.cxx4
-rw-r--r--common/rdr/HexOutStream.cxx2
-rw-r--r--common/rdr/InStream.h52
-rw-r--r--common/rdr/MemInStream.h8
-rw-r--r--common/rdr/MemOutStream.h6
-rw-r--r--common/rdr/OutStream.h46
-rw-r--r--common/rdr/RandomStream.cxx6
-rw-r--r--common/rdr/TLSInStream.cxx4
-rw-r--r--common/rdr/TLSInStream.h2
-rw-r--r--common/rdr/TLSOutStream.cxx2
-rw-r--r--common/rdr/TLSOutStream.h2
-rw-r--r--common/rdr/ZlibInStream.cxx4
-rw-r--r--common/rdr/types.h42
23 files changed, 127 insertions, 117 deletions
diff --git a/common/rdr/AESInStream.cxx b/common/rdr/AESInStream.cxx
index e6737e64..de91a3df 100644
--- a/common/rdr/AESInStream.cxx
+++ b/common/rdr/AESInStream.cxx
@@ -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 \ No newline at end of file
+#endif
diff --git a/common/rdr/AESInStream.h b/common/rdr/AESInStream.h
index 3483bd3a..6069bb71 100644
--- a/common/rdr/AESInStream.h
+++ b/common/rdr/AESInStream.h
@@ -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];
};
}
diff --git a/common/rdr/AESOutStream.cxx b/common/rdr/AESOutStream.cxx
index 1559b78a..fcb3e37a 100644
--- a/common/rdr/AESOutStream.cxx
+++ b/common/rdr/AESOutStream.cxx
@@ -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;
diff --git a/common/rdr/AESOutStream.h b/common/rdr/AESOutStream.h
index e5d6aa7a..f9e4f4da 100644
--- a/common/rdr/AESOutStream.h
+++ b/common/rdr/AESOutStream.h
@@ -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];
};
};
diff --git a/common/rdr/BufferedInStream.cxx b/common/rdr/BufferedInStream.cxx
index 9972e13e..5978a8c9 100644
--- a/common/rdr/BufferedInStream.cxx
+++ b/common/rdr/BufferedInStream.cxx
@@ -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;
}
diff --git a/common/rdr/BufferedInStream.h b/common/rdr/BufferedInStream.h
index 05f7231e..89b25ffb 100644
--- a/common/rdr/BufferedInStream.h
+++ b/common/rdr/BufferedInStream.h
@@ -50,7 +50,7 @@ namespace rdr {
private:
size_t bufSize;
size_t offset;
- U8* start;
+ uint8_t* start;
struct timeval lastSizeCheck;
size_t peakUsage;
diff --git a/common/rdr/BufferedOutStream.cxx b/common/rdr/BufferedOutStream.cxx
index ff7b6b51..640f6007 100644
--- a/common/rdr/BufferedOutStream.cxx
+++ b/common/rdr/BufferedOutStream.cxx
@@ -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;
diff --git a/common/rdr/BufferedOutStream.h b/common/rdr/BufferedOutStream.h
index 94707118..22693257 100644
--- a/common/rdr/BufferedOutStream.h
+++ b/common/rdr/BufferedOutStream.h
@@ -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);
diff --git a/common/rdr/FdInStream.cxx b/common/rdr/FdInStream.cxx
index e0174a8f..13d3a5a8 100644
--- a/common/rdr/FdInStream.cxx
+++ b/common/rdr/FdInStream.cxx
@@ -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;
diff --git a/common/rdr/FileInStream.cxx b/common/rdr/FileInStream.cxx
index 43f9ea4c..6de1a5b2 100644
--- a/common/rdr/FileInStream.cxx
+++ b/common/rdr/FileInStream.cxx
@@ -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);
diff --git a/common/rdr/HexInStream.cxx b/common/rdr/HexInStream.cxx
index 3eac9d2e..8a88d337 100644
--- a/common/rdr/HexInStream.cxx
+++ b/common/rdr/HexInStream.cxx
@@ -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);
diff --git a/common/rdr/HexOutStream.cxx b/common/rdr/HexOutStream.cxx
index 4bcd8ba4..0cbc312f 100644
--- a/common/rdr/HexOutStream.cxx
+++ b/common/rdr/HexOutStream.cxx
@@ -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++) {
diff --git a/common/rdr/InStream.h b/common/rdr/InStream.h
index 26817fb8..c6c83456 100644
--- a/common/rdr/InStream.h
+++ b/common/rdr/InStream.h
@@ -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;
};
}
diff --git a/common/rdr/MemInStream.h b/common/rdr/MemInStream.h
index b54334ca..08f48392 100644
--- a/common/rdr/MemInStream.h
+++ b/common/rdr/MemInStream.h
@@ -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;
};
diff --git a/common/rdr/MemOutStream.h b/common/rdr/MemOutStream.h
index f8b4d93c..33920a4d 100644
--- a/common/rdr/MemOutStream.h
+++ b/common/rdr/MemOutStream.h
@@ -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;
};
}
diff --git a/common/rdr/OutStream.h b/common/rdr/OutStream.h
index df1d8962..70216a2d 100644
--- a/common/rdr/OutStream.h
+++ b/common/rdr/OutStream.h
@@ -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;
};
diff --git a/common/rdr/RandomStream.cxx b/common/rdr/RandomStream.cxx
index c9be704c..79a1a0f7 100644
--- a/common/rdr/RandomStream.cxx
+++ b/common/rdr/RandomStream.cxx
@@ -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;
diff --git a/common/rdr/TLSInStream.cxx b/common/rdr/TLSInStream.cxx
index aa552e86..f62d6d87 100644
--- a/common/rdr/TLSInStream.cxx
+++ b/common/rdr/TLSInStream.cxx
@@ -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;
diff --git a/common/rdr/TLSInStream.h b/common/rdr/TLSInStream.h
index 397a7b3d..5b1b716f 100644
--- a/common/rdr/TLSInStream.h
+++ b/common/rdr/TLSInStream.h
@@ -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;
diff --git a/common/rdr/TLSOutStream.cxx b/common/rdr/TLSOutStream.cxx
index cdfe9b12..0a88d18a 100644
--- a/common/rdr/TLSOutStream.cxx
+++ b/common/rdr/TLSOutStream.cxx
@@ -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;
diff --git a/common/rdr/TLSOutStream.h b/common/rdr/TLSOutStream.h
index 276e5c78..2d365f36 100644
--- a/common/rdr/TLSOutStream.h
+++ b/common/rdr/TLSOutStream.h
@@ -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;
diff --git a/common/rdr/ZlibInStream.cxx b/common/rdr/ZlibInStream.cxx
index 03df10cc..6441f0a1 100644
--- a/common/rdr/ZlibInStream.cxx
+++ b/common/rdr/ZlibInStream.cxx
@@ -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);
diff --git a/common/rdr/types.h b/common/rdr/types.h
index 05d27773..1a53edf7 100644
--- a/common/rdr/types.h
+++ b/common/rdr/types.h
@@ -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