#include <rdr/RandomStream.h>
#include <rdr/Exception.h>
+#include <rfb/LogWriter.h>
#include <time.h>
#include <stdlib.h>
#ifndef WIN32
#endif
#endif
+static rfb::LogWriter vlog("RandomStream");
+
using namespace rdr;
const int DEFAULT_BUF_LEN = 256;
if (!CryptAcquireContext(&provider, 0, 0, PROV_RSA_FULL, 0)) {
if (GetLastError() == (DWORD)NTE_BAD_KEYSET) {
if (!CryptAcquireContext(&provider, 0, 0, PROV_RSA_FULL, CRYPT_NEWKEYSET)) {
- fprintf(stderr, "RandomStream: unable to create keyset\n");
+ vlog.error("unable to create keyset");
provider = 0;
}
} else {
- fprintf(stderr, "RandomStream: unable to acquire context\n");
+ vlog.error("unable to acquire context");
provider = 0;
}
}
{
#endif
#endif
- fprintf(stderr,"RandomStream: warning: no OS supplied random source - using rand()\n");
+ vlog.error("no OS supplied random source - using rand()");
seed += (unsigned int) time(0) + getpid() + getpid() * 987654 + rand();
srand(seed);
}
#include <rdr/ZlibOutStream.h>
#include <rdr/Exception.h>
+#include <rfb/LogWriter.h>
#include <zlib.h>
#undef ZLIBOUT_DEBUG
+static rfb::LogWriter vlog("ZlibOutStream");
+
using namespace rdr;
enum { DEFAULT_BUF_SIZE = 16384 };
zs->avail_in = ptr - start;
#ifdef ZLIBOUT_DEBUG
- fprintf(stderr,"zos flush: avail_in %d\n",zs->avail_in);
+ vlog.debug("flush: avail_in %d",zs->avail_in);
#endif
// Force out everything from the zlib encoder
int ZlibOutStream::overrun(int itemSize, int nItems)
{
#ifdef ZLIBOUT_DEBUG
- fprintf(stderr,"zos overrun\n");
+ vlog.debug("overrun");
#endif
if (itemSize > bufSize)
} else {
// but didn't consume all the data? try shifting what's left to the
// start of the buffer.
- fprintf(stderr,"z out buf not full, but in data not consumed\n");
+ vlog.info("z out buf not full, but in data not consumed");
memmove(start, zs->next_in, ptr - zs->next_in);
offset += zs->next_in - start;
ptr -= zs->next_in - start;
zs->avail_out = underlying->getend() - underlying->getptr();
#ifdef ZLIBOUT_DEBUG
- fprintf(stderr,"zos: calling deflate, avail_in %d, avail_out %d\n",
- zs->avail_in,zs->avail_out);
+ vlog.debug("calling deflate, avail_in %d, avail_out %d",
+ zs->avail_in,zs->avail_out);
#endif
rc = ::deflate(zs, flush);
}
#ifdef ZLIBOUT_DEBUG
- fprintf(stderr,"zos: after deflate: %d bytes\n",
- zs->next_out-underlying->getptr());
+ vlog.debug("after deflate: %d bytes",
+ zs->next_out-underlying->getptr());
#endif
underlying->setptr(zs->next_out);
if (newLevel != compressionLevel) {
#ifdef ZLIBOUT_DEBUG
- fprintf(stderr,"zos change: avail_in %d\n",zs->avail_in);
+ vlog.debug("change: avail_in %d",zs->avail_in);
#endif
// zlib is just horribly stupid. It does an implicit flush on
#include <stdio.h>
#include <rfb/Exception.h>
+#include <rfb/LogWriter.h>
#include <rfb/CMsgHandler.h>
#include <rfb/screenTypes.h>
+static rfb::LogWriter vlog("CMsgHandler");
+
using namespace rfb;
CMsgHandler::CMsgHandler()
#include <rfb/msgTypes.h>
#include <rdr/InStream.h>
#include <rfb/Exception.h>
+#include <rfb/LogWriter.h>
#include <rfb/util.h>
#include <rfb/CMsgHandler.h>
#include <rfb/CMsgReader.h>
+static rfb::LogWriter vlog("CMsgReader");
+
using namespace rfb;
CMsgReader::CMsgReader(CMsgHandler* handler_, rdr::InStream* is_)
readEndOfContinuousUpdates();
break;
default:
- fprintf(stderr, "unknown message type %d\n", type);
+ vlog.error("unknown message type %d", type);
throw Exception("unknown message type");
}
} else {
rdr::U32 len = is->readU32();
if (len > 256*1024) {
is->skip(len);
- fprintf(stderr,"cut text too long (%d bytes) - ignoring\n",len);
+ vlog.error("cut text too long (%d bytes) - ignoring",len);
return;
}
CharArray ca(len+1);
len = is->readU8();
if (len > sizeof(data)) {
- fprintf(stderr, "Ignoring fence with too large payload\n");
+ vlog.error("Ignoring fence with too large payload");
is->skip(len);
return;
}
{
if ((r.br.x > handler->server.width()) ||
(r.br.y > handler->server.height())) {
- fprintf(stderr, "Rect too big: %dx%d at %d,%d exceeds %dx%d\n",
+ vlog.error("Rect too big: %dx%d at %d,%d exceeds %dx%d",
r.width(), r.height(), r.tl.x, r.tl.y,
handler->server.width(), handler->server.height());
throw Exception("Rect too big");
}
if (r.is_empty())
- fprintf(stderr, "Warning: zero size rect\n");
+ vlog.error("zero size rect");
handler->dataRect(r, encoding);
}
char* name = is->readString();
if (x || y || w || h) {
- fprintf(stderr, "Ignoring DesktopName rect with non-zero position/size\n");
+ vlog.error("Ignoring DesktopName rect with non-zero position/size");
} else {
handler->setName(name);
}
: VoidParameter(name_, desc_, co), value(strDup(v)), def_value(v)
{
if (!v) {
- fprintf(stderr,"Default value <null> for %s not allowed\n",name_);
+ vlog.error("Default value <null> for %s not allowed",name_);
throw rfb::Exception("Default value <null> not allowed");
}
}
//
#include <rfb/Region.h>
+#include <rfb/LogWriter.h>
#include <assert.h>
#include <stdio.h>
#include <Xregion/Xregion.h>
}
+static rfb::LogWriter vlog("Region");
+
// A _RectRegion must never be passed as a return parameter to the Xlib region
// operations. This is because for efficiency its "rects" member has not been
// allocated with Xmalloc. It is however safe to pass it as an input
BOX* prevRects = xrgn->rects;
xrgn->rects = (BOX*)Xrealloc((char*)xrgn->rects, nRects * sizeof(BOX));
if (!xrgn->rects) {
- fprintf(stderr,"Xrealloc failed\n");
+ vlog.error("Xrealloc failed");
Xfree(prevRects);
return;
}
void rfb::Region::debug_print(const char* prefix) const
{
- fprintf(stderr,"%s num rects %3ld extents %3d,%3d %3dx%3d\n",
+ vlog.debug("%s num rects %3ld extents %3d,%3d %3dx%3d",
prefix, xrgn->numRects, xrgn->extents.x1, xrgn->extents.y1,
xrgn->extents.x2-xrgn->extents.x1,
xrgn->extents.y2-xrgn->extents.y1);
for (int i = 0; i < xrgn->numRects; i++) {
- fprintf(stderr," rect %3d,%3d %3dx%3d\n",
+ vlog.debug(" rect %3d,%3d %3dx%3d",
xrgn->rects[i].x1, xrgn->rects[i].y1,
xrgn->rects[i].x2-xrgn->rects[i].x1,
xrgn->rects[i].y2-xrgn->rects[i].y1);
readQEMUMessage();
break;
default:
- fprintf(stderr, "unknown message type %d\n", msgType);
+ vlog.error("unknown message type %d", msgType);
throw Exception("unknown message type");
}
}
len = is->readU8();
if (len > sizeof(data)) {
- fprintf(stderr, "Ignoring fence with too large payload\n");
+ vlog.error("Ignoring fence with too large payload");
is->skip(len);
return;
}