git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@333 3789f03b-4d11-0410-bbf8-ca57d06f2519tags/v0.0.90
/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or | ||||
*/ | */ | ||||
#include <rdr/Exception.h> | #include <rdr/Exception.h> | ||||
#ifdef _WIN32 | #ifdef _WIN32 | ||||
#define WIN32_LEAN_AND_MEAN | |||||
#include <tchar.h> | |||||
#include <windows.h> | #include <windows.h> | ||||
#include <winsock2.h> | #include <winsock2.h> | ||||
#endif | #endif | ||||
using namespace rdr; | using namespace rdr; | ||||
SystemException::SystemException(const char* s, int err_) | SystemException::SystemException(const char* s, int err_) | ||||
: Exception(s, "rdr::SystemException"), err(err_) | |||||
: Exception(s), err(err_) | |||||
{ | { | ||||
strncat(str_, ": ", len-1-strlen(str_)); | strncat(str_, ": ", len-1-strlen(str_)); | ||||
#ifdef _WIN32 | #ifdef _WIN32 | ||||
str_+strlen(str_), len-strlen(str_), 0, 0); | str_+strlen(str_), len-strlen(str_), 0, 0); | ||||
delete [] tmsg; | delete [] tmsg; | ||||
#else | #else | ||||
char* currStr = str_+strlen(str_); | |||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, | ||||
0, err, 0, str_+strlen(str_), len-1-strlen(str_), 0); | |||||
0, err, 0, currStr, len-1-strlen(str_), 0); | |||||
#endif | #endif | ||||
int l = strlen(str_); | |||||
if ((l >= 2) && (str_[l-2] == '\r') && (str_[l-1] == '\n')) | |||||
str_[l-2] = 0; | |||||
} | } | ||||
#else | #else | ||||
strncat(str_, strerror(err), len-1-strlen(str_)); | strncat(str_, strerror(err), len-1-strlen(str_)); | ||||
#endif | #endif | ||||
strncat(str_, " (", len-1-strlen(str_)); | strncat(str_, " (", len-1-strlen(str_)); | ||||
char buf[20]; | char buf[20]; | ||||
sprintf(buf,"%d",err); | |||||
#ifdef WIN32 | |||||
if (err < 0) | |||||
sprintf(buf, "%x", err); | |||||
else | |||||
#endif | |||||
sprintf(buf,"%d",err); | |||||
strncat(str_, buf, len-1-strlen(str_)); | strncat(str_, buf, len-1-strlen(str_)); | ||||
strncat(str_, ")", len-1-strlen(str_)); | strncat(str_, ")", len-1-strlen(str_)); | ||||
} | } |
/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or | ||||
struct Exception { | struct Exception { | ||||
enum { len = 256 }; | enum { len = 256 }; | ||||
char str_[len]; | char str_[len]; | ||||
char type_[len]; | |||||
Exception(const char* s=0, const char* e="rdr::Exception") { | |||||
Exception(const char* s=0) { | |||||
str_[0] = 0; | str_[0] = 0; | ||||
if (s) | if (s) | ||||
strncat(str_, s, len-1); | strncat(str_, s, len-1); | ||||
else | else | ||||
strcat(str_, "Exception"); | strcat(str_, "Exception"); | ||||
type_[0] = 0; | |||||
strncat(type_, e, len-1); | |||||
} | } | ||||
virtual const char* str() const { return str_; } | virtual const char* str() const { return str_; } | ||||
virtual const char* type() const { return type_; } | |||||
}; | }; | ||||
struct SystemException : public Exception { | struct SystemException : public Exception { | ||||
}; | }; | ||||
struct TimedOut : public Exception { | struct TimedOut : public Exception { | ||||
TimedOut(const char* s="Timed out") : Exception(s,"rdr::TimedOut") {} | |||||
TimedOut(const char* s="Timed out") : Exception(s) {} | |||||
}; | }; | ||||
struct EndOfStream : public Exception { | struct EndOfStream : public Exception { | ||||
EndOfStream(const char* s="End of stream") | |||||
: Exception(s,"rdr::EndOfStream") {} | |||||
EndOfStream(const char* s="End of stream") : Exception(s) {} | |||||
}; | |||||
struct FrameException : public Exception { | |||||
FrameException(const char* s="Frame exception") : Exception(s) {} | |||||
}; | }; | ||||
} | } | ||||
/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or |
/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or |
/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or |
/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or |
/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or |
/* Copyright (C) 2002-2004 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or |
/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or |
/* Copyright (C) 2002-2004 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or |
/* Copyright (C) 2002-2004 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or |
/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or |
/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or |
SRCS = Exception.cxx FdInStream.cxx FdOutStream.cxx InStream.cxx \ | SRCS = Exception.cxx FdInStream.cxx FdOutStream.cxx InStream.cxx \ | ||||
NullOutStream.cxx RandomStream.cxx ZlibInStream.cxx ZlibOutStream.cxx \ | |||||
RandomStream.cxx ZlibInStream.cxx ZlibOutStream.cxx \ | |||||
HexInStream.cxx HexOutStream.cxx | HexInStream.cxx HexOutStream.cxx | ||||
OBJS = $(SRCS:.cxx=.o) | OBJS = $(SRCS:.cxx=.o) |
/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or |
/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or | ||||
int length() { return ptr - start; } | int length() { return ptr - start; } | ||||
void clear() { ptr = start; }; | void clear() { ptr = start; }; | ||||
void clearAndZero() { memset(start, 0, ptr-start); clear(); } | |||||
void reposition(int pos) { ptr = start + pos; } | void reposition(int pos) { ptr = start + pos; } | ||||
// data() returns a pointer to the buffer. | // data() returns a pointer to the buffer. |
/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | |||||
* it under the terms of the GNU General Public License as published by | |||||
* the Free Software Foundation; either version 2 of the License, or | |||||
* (at your option) any later version. | |||||
* | |||||
* This software is distributed in the hope that it will be useful, | |||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
* GNU General Public License for more details. | |||||
* | |||||
* You should have received a copy of the GNU General Public License | |||||
* along with this software; if not, write to the Free Software | |||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |||||
* USA. | |||||
*/ | |||||
#include <rdr/NullOutStream.h> | |||||
#include <rdr/Exception.h> | |||||
using namespace rdr; | |||||
static const int bufferSize = 1024; | |||||
NullOutStream::NullOutStream() | |||||
: offset(0) | |||||
{ | |||||
start = ptr = new U8[bufferSize]; | |||||
end = start + bufferSize; | |||||
} | |||||
NullOutStream::~NullOutStream() | |||||
{ | |||||
delete [] start; | |||||
} | |||||
int NullOutStream::length() | |||||
{ | |||||
return offset + ptr - start; | |||||
} | |||||
void NullOutStream::writeBytes(const void* data, int length) | |||||
{ | |||||
offset += length; | |||||
} | |||||
int NullOutStream::overrun(int itemSize, int nItems) | |||||
{ | |||||
if (itemSize > bufferSize) | |||||
throw Exception("NullOutStream overrun: max itemSize exceeded"); | |||||
offset += ptr - start; | |||||
ptr = start; | |||||
if (itemSize * nItems > end - ptr) | |||||
nItems = (end - ptr) / itemSize; | |||||
return nItems; | |||||
} |
/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | |||||
* it under the terms of the GNU General Public License as published by | |||||
* the Free Software Foundation; either version 2 of the License, or | |||||
* (at your option) any later version. | |||||
* | |||||
* This software is distributed in the hope that it will be useful, | |||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
* GNU General Public License for more details. | |||||
* | |||||
* You should have received a copy of the GNU General Public License | |||||
* along with this software; if not, write to the Free Software | |||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |||||
* USA. | |||||
*/ | |||||
#ifndef __RDR_NULLOUTSTREAM_H__ | |||||
#define __RDR_NULLOUTSTREAM_H__ | |||||
#include <rdr/OutStream.h> | |||||
namespace rdr { | |||||
class NullOutStream : public OutStream { | |||||
public: | |||||
NullOutStream(); | |||||
virtual ~NullOutStream(); | |||||
int length(); | |||||
void writeBytes(const void* data, int length); | |||||
private: | |||||
int overrun(int itemSize, int nItems); | |||||
int offset; | |||||
U8* start; | |||||
}; | |||||
} | |||||
#endif |
/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or | ||||
#include <errno.h> | #include <errno.h> | ||||
#else | #else | ||||
#define getpid() GetCurrentProcessId() | #define getpid() GetCurrentProcessId() | ||||
#ifndef RFB_HAVE_WINCRYPT | |||||
#pragma message(" NOTE: Not building WinCrypt-based RandomStream") | |||||
#endif | |||||
#endif | #endif | ||||
using namespace rdr; | using namespace rdr; | ||||
{ | { | ||||
ptr = end = start = new U8[DEFAULT_BUF_LEN]; | ptr = end = start = new U8[DEFAULT_BUF_LEN]; | ||||
#ifdef WIN32 | |||||
#ifdef RFB_HAVE_WINCRYPT | |||||
provider = 0; | provider = 0; | ||||
if (!CryptAcquireContext(&provider, 0, 0, PROV_RSA_FULL, 0)) { | if (!CryptAcquireContext(&provider, 0, 0, PROV_RSA_FULL, 0)) { | ||||
if (GetLastError() == NTE_BAD_KEYSET) { | if (GetLastError() == NTE_BAD_KEYSET) { | ||||
} | } | ||||
if (!provider) { | if (!provider) { | ||||
#else | #else | ||||
#ifndef WIN32 | |||||
fp = fopen("/dev/urandom", "r"); | fp = fopen("/dev/urandom", "r"); | ||||
if (!fp) | if (!fp) | ||||
fp = fopen("/dev/random", "r"); | fp = fopen("/dev/random", "r"); | ||||
if (!fp) { | if (!fp) { | ||||
#else | |||||
{ | |||||
#endif | |||||
#endif | #endif | ||||
fprintf(stderr,"RandomStream: warning: no OS supplied random source - using rand()\n"); | fprintf(stderr,"RandomStream: warning: no OS supplied random source - using rand()\n"); | ||||
seed += (unsigned int) time(0) + getpid() + getpid() * 987654 + rand(); | seed += (unsigned int) time(0) + getpid() + getpid() * 987654 + rand(); | ||||
RandomStream::~RandomStream() { | RandomStream::~RandomStream() { | ||||
delete [] start; | delete [] start; | ||||
#ifdef WIN32 | |||||
if (provider) { | |||||
#ifdef RFB_HAVE_WINCRYPT | |||||
if (provider) | |||||
CryptReleaseContext(provider, 0); | CryptReleaseContext(provider, 0); | ||||
} | |||||
#else | |||||
#endif | |||||
#ifndef WIN32 | |||||
if (fp) fclose(fp); | if (fp) fclose(fp); | ||||
#endif | #endif | ||||
} | } | ||||
int length = start + DEFAULT_BUF_LEN - end; | int length = start + DEFAULT_BUF_LEN - end; | ||||
#ifdef WIN32 | |||||
#ifdef RFB_HAVE_WINCRYPT | |||||
if (provider) { | if (provider) { | ||||
if (!CryptGenRandom(provider, length, (U8*)end)) | if (!CryptGenRandom(provider, length, (U8*)end)) | ||||
throw rdr::SystemException("unable to CryptGenRandom", GetLastError()); | throw rdr::SystemException("unable to CryptGenRandom", GetLastError()); | ||||
end += length; | end += length; | ||||
} else { | |||||
#else | #else | ||||
#ifndef WIN32 | |||||
if (fp) { | if (fp) { | ||||
int n = fread((U8*)end, length, 1, fp); | int n = fread((U8*)end, length, 1, fp); | ||||
if (n != 1) | if (n != 1) | ||||
throw rdr::SystemException("reading /dev/urandom or /dev/random failed", | throw rdr::SystemException("reading /dev/urandom or /dev/random failed", | ||||
errno); | errno); | ||||
end += length; | end += length; | ||||
#endif | |||||
} else { | } else { | ||||
#else | |||||
{ | |||||
#endif | |||||
#endif | |||||
for (int i=0; i<length; i++) | for (int i=0; i<length; i++) | ||||
*(U8*)end++ = (int) (256.0*rand()/(RAND_MAX+1.0)); | *(U8*)end++ = (int) (256.0*rand()/(RAND_MAX+1.0)); | ||||
} | } |
/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or | ||||
#include <rdr/InStream.h> | #include <rdr/InStream.h> | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
#ifndef _WIN32_WINNT | |||||
#define _WIN32_WINNT 0x0400 | |||||
#endif | |||||
#define WIN32_LEAN_AND_MEAN | |||||
#include <windows.h> | #include <windows.h> | ||||
#include <wincrypt.h> | #include <wincrypt.h> | ||||
#ifdef WINCRYPT32API | |||||
#define RFB_HAVE_WINCRYPT | |||||
#endif | |||||
#endif | #endif | ||||
namespace rdr { | namespace rdr { | ||||
int offset; | int offset; | ||||
static unsigned int seed; | static unsigned int seed; | ||||
#ifdef WIN32 | |||||
#ifdef RFB_HAVE_WINCRYPT | |||||
HCRYPTPROV provider; | HCRYPTPROV provider; | ||||
#else | |||||
#endif | |||||
#ifndef WIN32 | |||||
FILE* fp; | FILE* fp; | ||||
#endif | #endif | ||||
/* Copyright (C) 2002-2004 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or |
/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or |
/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or |
/* Copyright (C) 2002-2004 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or |
/* Copyright (C) 2002-2004 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or |
/* Copyright (C) 2002-2004 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or | ||||
U16* buf; | U16* buf; | ||||
}; | }; | ||||
class U32Array { | |||||
public: | |||||
U32Array() : buf(0) {} | |||||
U32Array(U32* a) : buf(a) {} // note: assumes ownership | |||||
U32Array(int len) : buf(new U32[len]) {} | |||||
~U32Array() { delete [] buf; } | |||||
U32* takeBuf() { U32* tmp = buf; buf = 0; return tmp; } | |||||
U32* buf; | |||||
}; | |||||
} // end of namespace rdr | } // end of namespace rdr | ||||
#endif | #endif |
/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. | |||||
* | |||||
* This is free software; you can redistribute it and/or modify | * This is free software; you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or | ||||
#include <rdr/Exception.h> | #include <rdr/Exception.h> | ||||
namespace rfb { | namespace rfb { | ||||
struct Exception : public rdr::Exception { | |||||
Exception(const char* s=0, const char* e="rfb::Exception") | |||||
: rdr::Exception(s,e) {} | |||||
}; | |||||
typedef rdr::Exception Exception; | |||||
struct AuthFailureException : public Exception { | struct AuthFailureException : public Exception { | ||||
AuthFailureException(const char* s="Authentication failure") | AuthFailureException(const char* s="Authentication failure") | ||||
: Exception(s,"rfb::AuthFailureException") {} | |||||
: Exception(s) {} | |||||
}; | |||||
struct AuthCancelledException : public rfb::Exception { | |||||
AuthCancelledException(const char* s="Authentication cancelled") | |||||
: Exception(s) {} | |||||
}; | }; | ||||
struct ConnFailedException : public Exception { | struct ConnFailedException : public Exception { | ||||
ConnFailedException(const char* s="Connection failed") | |||||
: Exception(s,"rfb::ConnFailedException") {} | |||||
ConnFailedException(const char* s="Connection failed") : Exception(s) {} | |||||
}; | }; | ||||
} | } | ||||
#endif | #endif |