Unverified Commit 7897834c authored by Mihai Moldovan's avatar Mihai Moldovan

Merge branch 'sunweaver-pr/nxcomp-autoreconf' into 3.6.x

parents 9193d11e 4afc641f
......@@ -54,14 +54,7 @@ all:
test:
echo "No testing for NX (redistributed)"
build-lite:
cd nxcomp && autoconf && (${CONFIGURE}) && ${MAKE}
cd nxproxy && autoreconf -vfsi && (${CONFIGURE}) && ${MAKE}
build-full:
# in the full case, we rely on "magic" in the nx-X11 imake-based makefiles...
cd nxcomp && autoconf && (${CONFIGURE}) && ${MAKE}
build-env:
# prepare nx-X11/config/cf/nxversion.def
sed \
-e 's/###NX_VERSION_MAJOR###/$(NX_VERSION_MAJOR)/' \
......@@ -74,6 +67,13 @@ build-full:
# prepare Makefiles and the nx-X11 symlinking magic
cd nx-X11 && make BuildEnv FONT_DEFINES=$(FONT_DEFINES)
build-lite:
cd nxcomp && autoreconf -vfsi && (${CONFIGURE}) && ${MAKE}
cd nxproxy && autoreconf -vfsi && (${CONFIGURE}) && ${MAKE}
build-full: build-env
# in the full case, we rely on "magic" in the nx-X11 imake-based makefiles...
cd nxcomp && autoreconf -vfsi && (${CONFIGURE}) && ${MAKE}
# build libNX_X11 and libNX_Xext prior to building
# nxcomp{ext,shad}.
cd nx-X11/lib && make
......
usr/lib/*/libXcomp.so
usr/lib/*/libXcomp.a
usr/include/*/nx/NX.h
usr/include/*/nx/NXalert.h
usr/include/*/nx/NXpack.h
......
......@@ -17,14 +17,10 @@ override_dh_auto_clean:
rm -Rf nx-X11/.build-exports
dh_auto_clean
override_dh_clean:
rm -f nx*/configure
dh_clean
override_dh_install:
# remove static libs
rm debian/tmp/usr/lib/$(DEB_BUILD_MULTIARCH)/libXcomp.a
rm debian/tmp/usr/lib/$(DEB_BUILD_MULTIARCH)/libXcomp.la
rm debian/tmp/usr/lib/$(DEB_BUILD_MULTIARCH)/libXcompshad.la
# remove extras, GL, and other unneeded headers
......
......@@ -303,12 +303,3 @@ rm -f conftest*])
FreeBSD=
test "$nxconf_cv_freebsd" = yes && FreeBSD=yes
]) # NX_BUILD_ON_FreeBSD
AC_DEFUN([NX_HAS_INADDRT],
[AC_CACHE_CHECK(for in_addr_t, nx_cv_inaddrt,
[AC_TRY_COMPILE([#include <netinet/in.h>],[in_addr_t t; t = 1; return t;],
nx_cv_inaddrt=yes, nx_cv_inaddrt=no)
rm -f conftest*])
INADDRT=
test "$nx_cv_inaddrt" = yes && INADDRT=yes
]) # NX_HAS_INADDRT
......@@ -36,9 +36,9 @@ BuildIncludes($(HEADERS),IncSubdir,..)
#if NXLibraries
#ifdef SunArchitecture
NX_INCLUDES = -I../../../nxcomp -I/usr/sfw/include
NX_INCLUDES = -I../../../nxcomp/include -I/usr/sfw/include
#else
NX_INCLUDES = -I../../../nxcomp
NX_INCLUDES = -I../../../nxcomp/include
#endif
NX_DEFINES = -DNX_TRANS_SOCKET \
......@@ -81,7 +81,7 @@ NX_XCOMPLIBNAME = libXcomp.so
NX_XCOMPEXTLIBNAME = libXcompext.so
#endif
NX_XCOMPLIBDIR = $(XTOP)/../nxcomp
NX_XCOMPLIBDIR = $(XTOP)/../nxcomp/src/.libs
NX_XCOMPLIBLINK = Xcomp
NX_XCOMPLIBTARGET = $(NX_XCOMPLIBDIR)/$(NX_XCOMPLIBNAME)
NX_REQUIREDLIBS = -L$(NX_XCOMPLIBDIR) -l$(NX_XCOMPLIBLINK)
......
......@@ -213,12 +213,12 @@ NXAGENTDDXDIR = hw
NXAGENTDIRS = $(STDDIRS) $(FBDIR) $(MIDAMAGEDIR) $(NXAGENTDDXDIR) $(DEPDIRS)
NX_XCOMP_HEADERS = \
../../../nxcomp/MD5.h \
../../../nxcomp/NXalert.h \
../../../nxcomp/NX.h \
../../../nxcomp/NXpack.h \
../../../nxcomp/NXproto.h \
../../../nxcomp/NXvars.h \
../../../nxcomp/include/MD5.h \
../../../nxcomp/include/NXalert.h \
../../../nxcomp/include/NX.h \
../../../nxcomp/include/NXpack.h \
../../../nxcomp/include/NXproto.h \
../../../nxcomp/include/NXvars.h \
$(NULL)
NX_XCOMPSHAD_HEADERS = \
......@@ -315,7 +315,7 @@ $(NXAGENTOBJS) $(NXAGENTLIBS) $(NXAGENTSYSLIBS):: $(NXAGENTDIRS)
#if defined(SunArchitecture)
NXAGENTNXLIBS = -L/usr/sfw/lib \
-L../../../nxcomp \
-L../../../nxcomp/src/.libs \
-L../../../nxcompshad/src/.libs \
-lrt \
-lXcomp \
......@@ -330,7 +330,7 @@ NXAGENTNXLIBS = -L/usr/sfw/lib \
-lXext \
$(NULL)
#elif defined(cygwinArchitecture)
NXAGENTNXLIBS = -L../../../nxcomp \
NXAGENTNXLIBS = -L../../../nxcomp/src/.libs \
-L../../../nxcompshad/src/.libs \
-lXcomp \
-lXcompshad \
......@@ -343,7 +343,7 @@ NXAGENTNXLIBS = -L../../../nxcomp \
-lXext \
$(NULL)
#elif defined(OpenBSDArchitecture)
NXAGENTNXLIBS = -L../../../nxcomp \
NXAGENTNXLIBS = -L../../../nxcomp/src/.libs \
-L../../../nx-X11/exports/lib \
-L../../../nxcompshad/src/.libs \
-lkvm \
......@@ -359,7 +359,7 @@ NXAGENTNXLIBS = -L../../../nxcomp \
-lXext \
$(NULL)
#else
NXAGENTNXLIBS = -L../../../nxcomp \
NXAGENTNXLIBS = -L../../../nxcomp/src/.libs \
-L../../../nxcompshad/src/.libs \
-lXcomp \
-lXcompshad \
......
nxcomp.pc
Makefile
Makefile.in
aclocal.m4
compile
config.guess
config.sub
depcomp
install-sh
ltmain.sh
missing
config.h
config.h.in
libtool
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
nxcomp.pc
src/.deps/
src/Makefile
src/Makefile.in
stamp-h1
SUBDIRS = src
pkgconfig_DATA = nxcomp.pc
MAINTAINERCLEANFILES = \
$(srcdir)/autom4te.cache/* \
$(srcdir)/build-aux/* \
$(srcdir)/Makefile.in \
$(srcdir)/src/Makefile.in \
$(srcdir)/aclocal.m4 \
$(srcdir)/config.h.in \
$(srcdir)/config.h.in~ \
$(srcdir)/configure \
$(srcdir)/m4/libtool.m4 \
$(srcdir)/m4/lt~obsolete.m4 \
$(srcdir)/m4/ltoptions.m4 \
$(srcdir)/m4/ltsugar.m4 \
$(srcdir)/m4/ltversion.m4 \
$(NULL)
DISTCLEANFILES=$(MAINTAINERCLEANFILES)
#/**************************************************************************/
#/* */
#/* Copyright (c) 2001, 2011 NoMachine (http://www.nomachine.com) */
#/* Copyright (c) 2008-2014 Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> */
#/* Copyright (c) 2014-2016 Ulrich Sibiller <uli42@gmx.de> */
#/* Copyright (c) 2014-2016 Mihai Moldovan <ionic@ionic.de> */
#/* Copyright (c) 2011-2016 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>*/
#/* Copyright (c) 2015-2016 Qindel Group (http://www.qindel.com) */
#/* */
#/* NXCOMP, NX protocol compression and NX extensions to this software */
#/* are copyright of the aforementioned persons and companies. */
#/* */
#/* Redistribution and use of the present software is allowed according */
#/* to terms specified in the file LICENSE.nxcomp which comes in the */
#/* source distribution. */
#/* */
#/* All rights reserved. */
#/* */
#/* NOTE: This software has received contributions from various other */
#/* contributors, only the core maintainers and supporters are listed as */
#/* copyright holders. Please contact us, if you feel you should be listed */
#/* as copyright holder, as well. */
#/* */
#/**************************************************************************/
#
# Get these values from the configure script. The
# version printed by the program should be derived
# from the CHANGELOG. For example we may use the
# following command:
#
# head -n 3 CHANGELOG | grep 'nxcomp-' | cut -d '-' -f 2-3
#
VERSION=@VERSION@
LIBVERSION=@LIBVERSION@
#
# We would really like to enable all warnings, -Wredundant-decls,
# though, gives a warning caused by pthread.h and unistd.h and
# GCC 3.4 was changed in a way that it now complains about some
# of the -W directives we used before (-Wmissing-declarations,
# -Wnested-externs, -Wstrict-prototypes and -Wmissing-prototypes).
#
CXX = @CXX@
CXXFLAGS = @CXXFLAGS@ @X_CFLAGS@ @DEFS@ \
-Wall -Wpointer-arith
CXXINCLUDES =
CXXDEFINES =
CPPFLAGS = @CPPFLAGS@
#
# C programs have their own CFLAGS.
#
CC = @CC@
CCFLAGS = @CFLAGS@ @X_CFLAGS@ @DEFS@ \
-Wall -Wpointer-arith
CCINCLUDES =
CCDEFINES =
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
#
# Other autoconfigured settings, not used at the moment.
#
srcdir = @srcdir@
prefix = @prefix@
datarootdir = @datarootdir@
datadir = @datadir@
exec_prefix = @exec_prefix@
bindir = @bindir@
man1dir = @mandir@/man1
VPATH = @srcdir@
libdir = @libdir@
includedir = @includedir@
pkgconfigdir = @pkgconfigdir@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_LINK = cp -av
DESTDIR =
RM_FILE = rm -f
#
# This should be autodetected.
#
MAKEDEPEND = @MAKEDEPEND@
DEPENDINCLUDES = -I/usr/include/c++ -I/usr/include/g++ -I/usr/include/g++-3
.SUFFIXES: .cpp.c
.cpp.o:
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CXXINCLUDES) $(CXXDEFINES) $<
.c.o:
$(CC) -c $(CPPFLAGS) $(CCFLAGS) $(CCINCLUDES) $(CCDEFINES) $<
LIBRARY = Xcomp
LIBNAME = lib$(LIBRARY)
ifeq ($(shell uname),Darwin)
LIBFULL = lib$(LIBRARY).$(VERSION).dylib
LIBLOAD = lib$(LIBRARY).$(LIBVERSION).dylib
LIBSHARED = lib$(LIBRARY).dylib
COMP_VER = $(shell echo '$(VERSION)' | cut -d '.' -f 1-3)
LIBFLAGS = -install_name $(libdir)/$(LIBLOAD) -compatibility_version $(LIBVERSION) -current_version $(COMP_VER)
else
LIBFULL = lib$(LIBRARY).so.$(VERSION)
LIBLOAD = lib$(LIBRARY).so.$(LIBVERSION)
LIBSHARED = lib$(LIBRARY).so
LIBFLAGS =
endif
LIBARCHIVE = lib$(LIBRARY).a
LIBCYGSHARED = cyg$(LIBRARY).dll
LIBCYGARCHIVE = lib$(LIBRARY).dll.a
all: depend @ALL@
MSRC =
CSRC = MD5.c \
Pack.c \
Vars.c \
Version.c
CXXSRC = Loop.cpp \
Children.cpp \
Control.cpp \
Misc.cpp \
Socket.cpp \
Fork.cpp \
Pipe.cpp \
List.cpp \
Keeper.cpp \
Timestamp.cpp \
Transport.cpp \
Statistics.cpp \
Auth.cpp \
Agent.cpp \
Proxy.cpp \
Channel.cpp \
Message.cpp \
Split.cpp \
ClientProxy.cpp \
ServerProxy.cpp \
OpcodeStore.cpp \
ClientStore.cpp \
ServerStore.cpp \
ChannelCache.cpp \
ClientCache.cpp \
ServerCache.cpp \
ClientChannel.cpp \
ServerChannel.cpp \
GenericChannel.cpp \
ChannelEndPoint.cpp \
ReadBuffer.cpp \
ProxyReadBuffer.cpp \
ClientReadBuffer.cpp \
ServerReadBuffer.cpp \
GenericReadBuffer.cpp \
EncodeBuffer.cpp \
DecodeBuffer.cpp \
WriteBuffer.cpp \
SequenceQueue.cpp \
IntCache.cpp \
CharCache.cpp \
XidCache.cpp \
ActionCache.cpp \
BlockCache.cpp \
BlockCacheSet.cpp \
StaticCompressor.cpp \
Unpack.cpp \
Alpha.cpp \
Colormap.cpp \
Jpeg.cpp \
Pgn.cpp \
Bitmap.cpp \
Rgb.cpp \
Rle.cpp \
Z.cpp \
ChangeProperty.cpp \
SendEvent.cpp \
ChangeGC.cpp \
CreateGC.cpp \
CreatePixmap.cpp \
SetClipRectangles.cpp \
CopyArea.cpp \
PolyLine.cpp \
PolySegment.cpp \
PolyFillRectangle.cpp \
PutImage.cpp \
TranslateCoords.cpp \
GetImage.cpp \
ClearArea.cpp \
ConfigureWindow.cpp \
PolyText8.cpp \
PolyText16.cpp \
ImageText8.cpp \
ImageText16.cpp \
PolyPoint.cpp \
PolyFillArc.cpp \
PolyArc.cpp \
FillPoly.cpp \
InternAtom.cpp \
GetProperty.cpp \
SetUnpackGeometry.cpp \
SetUnpackColormap.cpp \
SetUnpackAlpha.cpp \
PutPackedImage.cpp \
ShapeExtension.cpp \
RenderExtension.cpp \
GenericRequest.cpp \
QueryFontReply.cpp \
ListFontsReply.cpp \
GetImageReply.cpp \
GetPropertyReply.cpp \
GenericReply.cpp \
RenderGenericRequest.cpp \
RenderCreatePicture.cpp \
RenderChangePicture.cpp \
RenderFreePicture.cpp \
RenderPictureClip.cpp \
RenderPictureTransform.cpp \
RenderPictureFilter.cpp \
RenderCreateGlyphSet.cpp \
RenderFreeGlyphSet.cpp \
RenderAddGlyphs.cpp \
RenderComposite.cpp \
RenderCompositeGlyphs.cpp \
RenderFillRectangles.cpp \
RenderTrapezoids.cpp \
RenderTriangles.cpp
MOBJ = $(MSRC:.c=.o)
COBJ = $(CSRC:.c=.o)
CXXOBJ = $(CXXSRC:.cpp=.o)
$(LIBFULL): $(CXXOBJ) $(COBJ)
$(CXX) -o $@ $(LDFLAGS) $(LIBFLAGS) $(CXXOBJ) $(COBJ) $(LIBS)
$(LIBLOAD): $(LIBFULL)
rm -f $(LIBLOAD)
ln -s $(LIBFULL) $(LIBLOAD)
$(LIBSHARED): $(LIBFULL)
rm -f $(LIBSHARED)
ln -s $(LIBFULL) $(LIBSHARED)
$(LIBARCHIVE): $(CXXOBJ) $(COBJ)
rm -f $(LIBARCHIVE)
ar clq $(LIBARCHIVE) $(CXXOBJ) $(COBJ)
ranlib $(LIBARCHIVE)
$(LIBCYGSHARED): $(LIBARCHIVE)
$(CC) -shared -o $(LIBCYGSHARED) \
-Wl,--out-implib=$(LIBCYGARCHIVE) \
-Wl,--export-all-symbols \
-Wl,--enable-auto-import \
-Wl,--whole-archive $(LIBARCHIVE) \
-Wl,--no-whole-archive $(LIBS) \
$(LDFLAGS)
$(LIBCYGARCHIVE): $(LIBCYGSHARED)
depends: depend.status
depend: depend.status
depend.status:
if [ -n "$(MAKEDEPEND)" ] && [ -x "$(MAKEDEPEND)" ] ; then \
$(MAKEDEPEND) $(CXXINCLUDES) $(CCINCLUDES) \
$(DEPENDINCLUDES) -f Makefile $(MSRC) $(CSRC) \
$(CXXSRC) 2>/dev/null; \
fi
touch depend.status
install: install.bin install.lib install.man
install.bin:
install.lib: all
./mkinstalldirs $(DESTDIR)${libdir}
./mkinstalldirs $(DESTDIR)${includedir}/nx
./mkinstalldirs $(DESTDIR)${pkgconfigdir}
$(INSTALL_DATA) $(LIBFULL) $(DESTDIR)${libdir}
$(INSTALL_LINK) $(LIBLOAD) $(DESTDIR)${libdir}
$(INSTALL_LINK) $(LIBSHARED) $(DESTDIR)${libdir}
$(INSTALL_DATA) $(LIBARCHIVE) $(DESTDIR)${libdir}
$(INSTALL_DATA) MD5.h $(DESTDIR)${includedir}/nx
$(INSTALL_DATA) NX.h $(DESTDIR)${includedir}/nx
$(INSTALL_DATA) NXalert.h $(DESTDIR)${includedir}/nx
$(INSTALL_DATA) NXpack.h $(DESTDIR)${includedir}/nx
$(INSTALL_DATA) NXproto.h $(DESTDIR)${includedir}/nx
$(INSTALL_DATA) NXvars.h $(DESTDIR)${includedir}/nx
$(INSTALL_DATA) nxcomp.pc $(DESTDIR)${pkgconfigdir}
echo "Running ldconfig tool, this may take a while..." && ldconfig || true
install.man:
uninstall: uninstall.bin uninstall.lib uninstall.man
uninstall.bin:
uninstall.lib:
$(RM_FILE) $(DESTDIR)${libdir}/$(LIBFULL)
$(RM_FILE) $(DESTDIR)${libdir}/$(LIBLOAD)
$(RM_FILE) $(DESTDIR)${libdir}/$(LIBSHARED)
$(RM_FILE) $(DESTDIR)${libdir}/$(LIBARCHIVE)
$(RM_FILE) $(DESTDIR)${includedir}/nx/NXalert.h
$(RM_FILE) $(DESTDIR)${includedir}/nx/NX.h
$(RM_FILE) $(DESTDIR)${includedir}/nx/NXpack.h
$(RM_FILE) $(DESTDIR)${includedir}/nx/NXproto.h
$(RM_FILE) $(DESTDIR)${includedir}/nx/NXvars.h
$(RM_FILE) $(DESTDIR)${includedir}/nx/MD5.h
$(RM_FILE) $(DESTDIR)${pkgconfigdir}/nxcomp.pc
echo "Running ldconfig tool, this may take a while..." && ldconfig || true
uninstall.man:
clean:
-rm -f *~ *.o *.bak *.orig *.rej st?????? core core.* *.out.* *.pc \
@ALL@
distclean: clean
-rm -rf autom4te.cache config.status config.log \
config.cache depend.status Makefile tags configure
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2011 NoMachine (http://www.nomachine.com) */
/* Copyright (c) 2008-2014 Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> */
/* Copyright (c) 2014-2016 Ulrich Sibiller <uli42@gmx.de> */
/* Copyright (c) 2014-2016 Mihai Moldovan <ionic@ionic.de> */
/* Copyright (c) 2011-2016 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>*/
/* Copyright (c) 2015-2016 Qindel Group (http://www.qindel.com) */
/* */
/* NXCOMP, NX protocol compression and NX extensions to this software */
/* are copyright of the aforementioned persons and companies. */
/* */
/* Redistribution and use of the present software is allowed according */
/* to terms specified in the file LICENSE.nxcomp which comes in the */
/* source distribution. */
/* */
/* All rights reserved. */
/* */
/* NOTE: This software has received contributions from various other */
/* contributors, only the core maintainers and supporters are listed as */
/* copyright holders. Please contact us, if you feel you should be listed */
/* as copyright holder, as well. */
/* */
/**************************************************************************/
#include "ShapeExtension.h"
#include "ClientCache.h"
#include "EncodeBuffer.h"
#include "DecodeBuffer.h"
#include "WriteBuffer.h"
//
// Set the verbosity level.
//
#define PANIC
#define WARNING
#undef TEST
#undef DEBUG
#undef DUMP
//
// Constructors and destructors.
//
ShapeExtensionStore::ShapeExtensionStore(StaticCompressor *compressor)
: MessageStore(compressor)
{
enableCache = SHAPEEXTENSION_ENABLE_CACHE;
enableData = SHAPEEXTENSION_ENABLE_DATA;
enableSplit = SHAPEEXTENSION_ENABLE_SPLIT;
// Since ProtoStep7 (#issue 108)
enableCompress = SHAPEEXTENSION_ENABLE_COMPRESS_IF_PROTO_STEP_7;
dataLimit = SHAPEEXTENSION_DATA_LIMIT;
dataOffset = SHAPEEXTENSION_DATA_OFFSET;
cacheSlots = SHAPEEXTENSION_CACHE_SLOTS;
cacheThreshold = SHAPEEXTENSION_CACHE_THRESHOLD;
cacheLowerThreshold = SHAPEEXTENSION_CACHE_LOWER_THRESHOLD;
opcode_ = X_NXInternalShapeExtension;
messages_ -> resize(cacheSlots);
for (T_messages::iterator i = messages_ -> begin();
i < messages_ -> end(); i++)
{
*i = NULL;
}
temporary_ = NULL;
}
ShapeExtensionStore::~ShapeExtensionStore()
{
for (T_messages::iterator i = messages_ -> begin();
i < messages_ -> end(); i++)
{
destroy(*i);
}
destroy(temporary_);
}
//
// Here are the methods to handle messages' content.
//
int ShapeExtensionStore::encodeIdentity(EncodeBuffer &encodeBuffer, const unsigned char *buffer,
const unsigned int size, int bigEndian,
ChannelCache *channelCache) const
{
//
// Handle this extension in a way similar to shape.
//
ClientCache *clientCache = (ClientCache *) channelCache;
#ifdef DEBUG
*logofs << name() << ": Encoding full message identity.\n" << logofs_flush;
#endif
//
// We handle all possible requests of this extension
// using the same opcode. We give to message a data
// offset of 4 (or 16 if proto is >= 3) and handle
// the first 16 bytes through an array of caches.
//
encodeBuffer.encodeValue(size >> 2, 16, 10);
encodeBuffer.encodeCachedValue(*(buffer + 1), 8,
clientCache -> shapeOpcodeCache);
for (unsigned int i = 0; i < 8 && (i * 2 + 4) < size; i++)
{
encodeBuffer.encodeCachedValue(GetUINT(buffer + (i * 2) + 4, bigEndian), 16,
*clientCache -> shapeDataCache[i]);
}
#ifdef DEBUG
*logofs << name() << ": Encoded full message identity.\n" << logofs_flush;
#endif
return 1;
}
int ShapeExtensionStore::decodeIdentity(DecodeBuffer &decodeBuffer, unsigned char *&buffer,
unsigned int &size, int bigEndian, WriteBuffer *writeBuffer,
ChannelCache *channelCache) const
{
ClientCache *clientCache = (ClientCache *) channelCache;
#ifdef DEBUG
*logofs << name() << ": Decoding full message identity.\n" << logofs_flush;
#endif
decodeBuffer.decodeValue(size, 16, 10);
size <<= 2;
buffer = writeBuffer -> addMessage(size);
decodeBuffer.decodeCachedValue(*(buffer + 1), 8,
clientCache -> shapeOpcodeCache);
unsigned int value;
for (unsigned int i = 0; i < 8 && (i * 2 + 4) < size; i++)
{
decodeBuffer.decodeCachedValue(value, 16,
*clientCache -> shapeDataCache[i]);
PutUINT(value, buffer + 4 + (i * 2), bigEndian);
}
#ifdef DEBUG
*logofs << name() << ": Decoded full message identity.\n" << logofs_flush;
#endif
return 1;
}
int ShapeExtensionStore::parseIdentity(Message *message, const unsigned char *buffer,
unsigned int size, int bigEndian) const
{
ShapeExtensionMessage *shapeExtension = (ShapeExtensionMessage *) message;
shapeExtension -> opcode = *(buffer + 1);
for (unsigned int i = 0; i < 8; i++)
{
if ((i * 2 + 4) < size)
{
shapeExtension -> data[i] = GetUINT(buffer + i * 2 + 4, bigEndian);
#ifdef DEBUG
*logofs << name() << ": Parsed data[" << i << "].\n"
<< logofs_flush;
#endif
}
else
{
shapeExtension -> data[i] = 0;
}
}
#ifdef DEBUG
*logofs << name() << ": Parsed identity for message at "
<< this << ".\n" << logofs_flush;
#endif
return 1;
}
int ShapeExtensionStore::unparseIdentity(const Message *message, unsigned char *buffer,
unsigned int size, int bigEndian) const
{
ShapeExtensionMessage *shapeExtension = (ShapeExtensionMessage *) message;
*(buffer + 1) = shapeExtension -> opcode;
for (unsigned int i = 0; i < 8 && (i * 2 + 4) < size; i++)
{
PutUINT(shapeExtension -> data[i], buffer + i * 2 + 4, bigEndian);
}
#ifdef DEBUG
*logofs << name() << ": Unparsed identity for message at "
<< this << ".\n" << logofs_flush;
#endif
return 1;
}
void ShapeExtensionStore::dumpIdentity(const Message *message) const
{
#ifdef DUMP
ShapeExtensionMessage *shapeExtension = (ShapeExtensionMessage *) message;
*logofs << name() << ": Identity opcode " << (unsigned) shapeExtension -> opcode;
for (int i = 0; i < 8; i++)
{
*logofs << ", data[" << i << "] " << shapeExtension -> data[i];
}
*logofs << ", size " << shapeExtension -> size_ << ".\n" << logofs_flush;
#endif
}
void ShapeExtensionStore::identityChecksum(const Message *message, const unsigned char *buffer,
unsigned int size, int bigEndian) const
{
//
// Include minor opcode in the checksum. As data
// offset can be beyond the real end of message,
// we need to include size or we will match any
// message of size less or equal to data offset.
//
md5_append(md5_state_, buffer + 1, 3);
}
void ShapeExtensionStore::updateIdentity(EncodeBuffer &encodeBuffer, const Message *message,
const Message *cachedMessage,
ChannelCache *channelCache) const
{
//
// Encode the variant part.
//
ShapeExtensionMessage *shapeExtension = (ShapeExtensionMessage *) message;
ShapeExtensionMessage *cachedShapeExtension = (ShapeExtensionMessage *) cachedMessage;
ClientCache *clientCache = (ClientCache *) channelCache;
for (int i = 0; i < 8 && (i * 2 + 4) < shapeExtension -> size_; i++)
{
#ifdef TEST
*logofs << name() << ": Encoding value " << shapeExtension -> data[i]
<< " as data[" << i << "] field.\n" << logofs_flush;
#endif
encodeBuffer.encodeCachedValue((unsigned int) shapeExtension -> data[i], 16,
*clientCache -> shapeDataCache[i]);
cachedShapeExtension -> data[i] = shapeExtension -> data[i];
}
}
void ShapeExtensionStore::updateIdentity(DecodeBuffer &decodeBuffer, const Message *message,
ChannelCache *channelCache) const
{
ShapeExtensionMessage *shapeExtension = (ShapeExtensionMessage *) message;
ClientCache *clientCache = (ClientCache *) channelCache;
unsigned int value;
for (int i = 0; i < 8 && (i * 2 + 4) < shapeExtension -> size_; i++)
{
decodeBuffer.decodeCachedValue(value, 16,
*clientCache -> shapeDataCache[i]);
shapeExtension -> data[i] = (unsigned short) value;
#ifdef TEST
*logofs << name() << ": Decoded value " << shapeExtension -> data[i]
<< " as data[" << i << "] field.\n" << logofs_flush;
#endif
}
}
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2011 NoMachine (http://www.nomachine.com) */
/* Copyright (c) 2008-2014 Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> */
/* Copyright (c) 2014-2016 Ulrich Sibiller <uli42@gmx.de> */
/* Copyright (c) 2014-2016 Mihai Moldovan <ionic@ionic.de> */
/* Copyright (c) 2011-2016 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>*/
/* Copyright (c) 2015-2016 Qindel Group (http://www.qindel.com) */
/* */
/* NXCOMP, NX protocol compression and NX extensions to this software */
/* are copyright of the aforementioned persons and companies. */
/* */
/* Redistribution and use of the present software is allowed according */
/* to terms specified in the file LICENSE.nxcomp which comes in the */
/* source distribution. */
/* */
/* All rights reserved. */
/* */
/* NOTE: This software has received contributions from various other */
/* contributors, only the core maintainers and supporters are listed as */
/* copyright holders. Please contact us, if you feel you should be listed */
/* as copyright holder, as well. */
/* */
/**************************************************************************/
#ifndef Timestamp_H
#define Timestamp_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include "Misc.h"
//
// Log level.
//
#define PANIC
#define WARNING
#undef TEST
#undef DEBUG
//
// If not defined, always query the system time.
//
#undef CACHE_TIMESTAMP
//
// Log a warning if the time difference since
// the last update exceeds the given number
// of milliseconds.
//
#define DRIFT_TIMESTAMP 1
//
// Type used for timeout manipulation.
//
typedef struct timeval T_timestamp;
//
// Last timestamp taken from the system. If the
// timestamp is cached, we need to explicitly
// get a new timestamp after any operation that
// may have required a relevant amount of time.
//
extern T_timestamp timestamp;
//
// Get a timestamp instance with values set
// at the given amount of milliseconds.
//
inline T_timestamp getTimestamp(long ms)
{
struct timeval ts;
ts.tv_sec = ms / 1000;
ts.tv_usec = (ms % 1000) * 1000;
return ts;
}
//
// Return the difference in milliseconds
// between the two timestamps.
//
inline long diffTimestamp(const T_timestamp &ts1, const T_timestamp &ts2)
{
//
// Add 500 microseconds to round up
// to the nearest millisecond.
//
return ((ts2.tv_sec * 1000 + (ts2.tv_usec + 500) / 1000) -
(ts1.tv_sec * 1000 + (ts1.tv_usec + 500) / 1000));
}
//
// The same in microseconds. It doesn't
// round the value.
//
inline long diffUsTimestamp(const T_timestamp &ts1, const T_timestamp &ts2)
{
return ((ts2.tv_sec * 1000000 + ts2.tv_usec) -
(ts1.tv_sec * 1000000 + ts1.tv_usec));
}
//
// Return the last timestamp taken from the
// system. It doesn't update the timestamp.
//
inline T_timestamp getTimestamp()
{
#ifdef CACHE_TIMESTAMP
#ifdef TEST
T_timestamp ts;
gettimeofday(&ts, NULL);
long diffTs = diffTimestamp(timestamp, ts);
if (diffTs > DRIFT_TIMESTAMP)
{
*logofs << "Timestamp: WARNING! Time difference since the "
<< "current timestamp is " << diffTs << " Ms.\n"
<< logofs_flush;
}
#endif
return timestamp;
#else
gettimeofday(&timestamp, NULL);
return timestamp;
#endif
}
inline T_timestamp &setTimestamp(T_timestamp &ts, long ms)
{
ts.tv_sec = ms / 1000;
ts.tv_usec = (ms % 1000) * 1000;
return ts;
}
//
// Return the smaller between two timestamps.
//
inline T_timestamp &setMinTimestamp(T_timestamp &ts, long ms)
{
if ((ts.tv_sec * 1000 + ts.tv_usec / 1000) > ms)
{
ts.tv_sec = ms / 1000;
ts.tv_usec = (ms % 1000) * 1000;
}
return ts;
}
inline T_timestamp &setMinTimestamp(T_timestamp &ts1, T_timestamp &ts2)
{
if ((ts1.tv_sec * 1000000 + ts1.tv_usec) >
(ts2.tv_sec * 1000000 + ts2.tv_usec))
{
ts1.tv_sec = ts2.tv_sec;
ts1.tv_usec = ts2.tv_usec;
}
return ts1;
}
//
// Convert a timestamp in the total number
// of milliseconds.
//
inline long getMsTimestamp(const T_timestamp &ts)
{
return ts.tv_sec * 1000 + ts.tv_usec / 1000;
}
//
// A 0 value on both seconds and microseconds
// fields means that timestamp is invalid or
// not set.
//
inline T_timestamp nullTimestamp()
{
struct timeval ts;
ts.tv_sec = 0;
ts.tv_usec = 0;
return ts;
}
inline bool isTimestamp(const T_timestamp &ts)
{
if (ts.tv_sec == 0 && ts.tv_usec == 0)
{
return 0;
}
return 1;
}
inline void subMsTimestamp(T_timestamp &ts, long ms)
{
ts.tv_sec -= ms / 1000;
ts.tv_usec -= (ms % 1000) * 1000;
}
inline void addMsTimestamp(T_timestamp &ts, long ms)
{
ts.tv_sec += ms / 1000;
ts.tv_usec += (ms % 1000) * 1000;
}
//
// Check the difference between timestamps.
// Return 0 if the system time went backward
// compared to the second timestamp, or the
// difference between the timestamps exceeds
// the given number of milliseconds.
//
inline int checkDiffTimestamp(const T_timestamp &ts1, const T_timestamp &ts2,
long ms = 30000)
{
long diffTs = diffTimestamp(ts1, ts2);
if (diffTs < 0 || diffTs > ms)
{
return 0;
}
return 1;
}
//
// Return a string representing the timestamp.
//
char *strTimestamp(const T_timestamp &ts);
char *strMsTimestamp(const T_timestamp &ts);
inline char *strTimestamp()
{
return strTimestamp(getTimestamp());
}
inline char *strMsTimestamp()
{
return strMsTimestamp(getTimestamp());
}
//
// Update the current timestamp.
//
inline T_timestamp getNewTimestamp()
{
#ifdef TEST
T_timestamp ts;
gettimeofday(&ts, NULL);
*logofs << "Timestamp: Updating the current timestamp at "
<< strMsTimestamp(ts) << ".\n" << logofs_flush;
long diffTs = diffTimestamp(timestamp, ts);
if (diffTs > DRIFT_TIMESTAMP)
{
*logofs << "Timestamp: WARNING! Time difference since the "
<< "old timestamp is " << diffTs << " Ms.\n"
<< logofs_flush;
}
#endif
gettimeofday(&timestamp, NULL);
return timestamp;
}
#endif /* Timestamp_H */
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2011 NoMachine (http://www.nomachine.com) */
/* Copyright (c) 2008-2014 Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> */
/* Copyright (c) 2014-2016 Ulrich Sibiller <uli42@gmx.de> */
/* Copyright (c) 2014-2016 Mihai Moldovan <ionic@ionic.de> */
/* Copyright (c) 2011-2016 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>*/
/* Copyright (c) 2015-2016 Qindel Group (http://www.qindel.com) */
/* */
/* NXCOMP, NX protocol compression and NX extensions to this software */
/* are copyright of the aforementioned persons and companies. */
/* */
/* Redistribution and use of the present software is allowed according */
/* to terms specified in the file LICENSE.nxcomp which comes in the */
/* source distribution. */
/* */
/* All rights reserved. */
/* */
/* NOTE: This software has received contributions from various other */
/* contributors, only the core maintainers and supporters are listed as */
/* copyright holders. Please contact us, if you feel you should be listed */
/* as copyright holder, as well. */
/* */
/**************************************************************************/
#include "TranslateCoords.h"
#include "ClientCache.h"
#include "EncodeBuffer.h"
#include "DecodeBuffer.h"
//
// Set the verbosity level.
//
#define PANIC
#define WARNING
#undef TEST
#undef DEBUG
#undef DUMP
//
// Here are the methods to handle messages' content.
//
int TranslateCoordsStore::parseIdentity(Message *message, const unsigned char *buffer,
unsigned int size, int bigEndian) const
{
TranslateCoordsMessage *translateCoords = (TranslateCoordsMessage *) message;
//
// Here is the fingerprint.
//
translateCoords -> src_window = GetULONG(buffer + 4, bigEndian);
translateCoords -> dst_window = GetULONG(buffer + 8, bigEndian);
translateCoords -> src_x = GetUINT(buffer + 12, bigEndian);
translateCoords -> src_y = GetUINT(buffer + 14, bigEndian);
#ifdef DEBUG
*logofs << name() << ": Parsed Identity for message at " << this << ".\n" << logofs_flush;
#endif
return 1;
}
int TranslateCoordsStore::unparseIdentity(const Message *message, unsigned char *buffer,
unsigned int size, int bigEndian) const
{
TranslateCoordsMessage *translateCoords = (TranslateCoordsMessage *) message;
//
// Fill all the message's fields.
//
PutULONG(translateCoords -> src_window, buffer + 4, bigEndian);
PutULONG(translateCoords -> dst_window, buffer + 8, bigEndian);
PutUINT(translateCoords -> src_x, buffer + 12, bigEndian);
PutUINT(translateCoords -> src_y, buffer + 14, bigEndian);
#ifdef DEBUG
*logofs << name() << ": Unparsed identity for message at " << this << ".\n" << logofs_flush;
#endif
return 1;
}
void TranslateCoordsStore::dumpIdentity(const Message *message) const
{
#ifdef DUMP
TranslateCoordsMessage *translateCoords = (TranslateCoordsMessage *) message;
*logofs << name() << ": Identity src_window " << translateCoords -> src_window << ", dst_window "
<< translateCoords -> dst_window << ", src_x " << translateCoords -> src_x << ", src_y "
<< translateCoords -> src_y << ", size " << translateCoords -> size_ << ".\n" << logofs_flush;
#endif
}
void TranslateCoordsStore::identityChecksum(const Message *message, const unsigned char *buffer,
unsigned int size, int bigEndian) const
{
md5_append(md5_state_, buffer + 4, 4);
md5_append(md5_state_, buffer + 8, 4);
md5_append(md5_state_, buffer + 12, 2);
md5_append(md5_state_, buffer + 14, 2);
}
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2011 NoMachine (http://www.nomachine.com) */
/* Copyright (c) 2008-2014 Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> */
/* Copyright (c) 2014-2016 Ulrich Sibiller <uli42@gmx.de> */
/* Copyright (c) 2014-2016 Mihai Moldovan <ionic@ionic.de> */
/* Copyright (c) 2011-2016 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>*/
/* Copyright (c) 2015-2016 Qindel Group (http://www.qindel.com) */
/* */
/* NXCOMP, NX protocol compression and NX extensions to this software */
/* are copyright of the aforementioned persons and companies. */
/* */
/* Redistribution and use of the present software is allowed according */
/* to terms specified in the file LICENSE.nxcomp which comes in the */
/* source distribution. */
/* */
/* All rights reserved. */
/* */
/* NOTE: This software has received contributions from various other */
/* contributors, only the core maintainers and supporters are listed as */
/* copyright holders. Please contact us, if you feel you should be listed */
/* as copyright holder, as well. */
/* */
/**************************************************************************/
#ifndef TranslateCoords_H
#define TranslateCoords_H
#include "Message.h"
//
// Set the verbosity level.
//
#define PANIC
#define WARNING
#undef TEST
#undef DEBUG
#undef DUMP
//
// Set default values.
//
#define TRANSLATECOORDS_ENABLE_CACHE 1
#define TRANSLATECOORDS_ENABLE_DATA 0
#define TRANSLATECOORDS_ENABLE_SPLIT 0
#define TRANSLATECOORDS_ENABLE_COMPRESS 0
#define TRANSLATECOORDS_DATA_LIMIT 0
#define TRANSLATECOORDS_DATA_OFFSET 16
#define TRANSLATECOORDS_CACHE_SLOTS 3000
#define TRANSLATECOORDS_CACHE_THRESHOLD 3
#define TRANSLATECOORDS_CACHE_LOWER_THRESHOLD 1
//
// The message class.
//
class TranslateCoordsMessage : public Message
{
friend class TranslateCoordsStore;
public:
TranslateCoordsMessage()
{
}
~TranslateCoordsMessage()
{
}
//
// Put here the fields which constitute
// the 'identity' part of the message.
//
private:
unsigned int src_window;
unsigned int dst_window;
unsigned int src_x;
unsigned int src_y;
unsigned char r_same_screen;
unsigned int r_child_window;
unsigned int r_dst_x;
unsigned int r_dst_y;
};
class TranslateCoordsStore : public MessageStore
{
//
// Constructors and destructors.
//
public:
TranslateCoordsStore() : MessageStore()
{
enableCache = TRANSLATECOORDS_ENABLE_CACHE;
enableData = TRANSLATECOORDS_ENABLE_DATA;
enableSplit = TRANSLATECOORDS_ENABLE_SPLIT;
enableCompress = TRANSLATECOORDS_ENABLE_COMPRESS;
dataLimit = TRANSLATECOORDS_DATA_LIMIT;
dataOffset = TRANSLATECOORDS_DATA_OFFSET;
cacheSlots = TRANSLATECOORDS_CACHE_SLOTS;
cacheThreshold = TRANSLATECOORDS_CACHE_THRESHOLD;
cacheLowerThreshold = TRANSLATECOORDS_CACHE_LOWER_THRESHOLD;
messages_ -> resize(cacheSlots);
for (T_messages::iterator i = messages_ -> begin();
i < messages_ -> end(); i++)
{
*i = NULL;
}
temporary_ = NULL;
}
virtual ~TranslateCoordsStore()
{
for (T_messages::iterator i = messages_ -> begin();
i < messages_ -> end(); i++)
{
destroy(*i);
}
destroy(temporary_);
}
virtual const char *name() const
{
return "TranslateCoords";
}
virtual unsigned char opcode() const
{
return X_TranslateCoords;
}
virtual unsigned int storage() const
{
return sizeof(TranslateCoordsMessage);
}
//
// Message handling methods.
//
public:
virtual Message *create() const
{
return new TranslateCoordsMessage();
}
virtual Message *create(const Message &message) const
{
return new TranslateCoordsMessage((const TranslateCoordsMessage &) message);
}
virtual void destroy(Message *message) const
{
delete (TranslateCoordsMessage *) message;
}
virtual int parseIdentity(Message *message, const unsigned char *buffer,
unsigned int size, int bigEndian) const;
virtual int unparseIdentity(const Message *message, unsigned char *buffer,
unsigned int size, int bigEndian) const;
virtual void identityChecksum(const Message *message, const unsigned char *buffer,
unsigned int size, int bigEndian) const;
virtual void dumpIdentity(const Message *message) const;
};
#endif /* TranslateCoords_H */
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2011 NoMachine (http://www.nomachine.com) */
/* Copyright (c) 2008-2014 Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> */
/* Copyright (c) 2014-2016 Ulrich Sibiller <uli42@gmx.de> */
/* Copyright (c) 2014-2016 Mihai Moldovan <ionic@ionic.de> */
/* Copyright (c) 2011-2016 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>*/
/* Copyright (c) 2015-2016 Qindel Group (http://www.qindel.com) */
/* */
/* NXCOMP, NX protocol compression and NX extensions to this software */
/* are copyright of the aforementioned persons and companies. */
/* */
/* Redistribution and use of the present software is allowed according */
/* to terms specified in the file LICENSE.nxcomp which comes in the */
/* source distribution. */
/* */
/* All rights reserved. */
/* */
/* NOTE: This software has received contributions from various other */
/* contributors, only the core maintainers and supporters are listed as */
/* copyright holders. Please contact us, if you feel you should be listed */
/* as copyright holder, as well. */
/* */
/**************************************************************************/
#ifndef Types_H
#define Types_H
using namespace std;
#include <vector>
#include <list>
#include <map>
#include <set>
#include "MD5.h"
//
// This is MD5 length.
//
#define MD5_LENGTH 16
//
// Types of repositories. Replace the original
// clear() methods from STL in order to actually
// free the unused memory.
//
class Message;
class T_data : public vector < unsigned char >
{
public:
unsigned char *begin()
{
return &*(vector < unsigned char >::begin());
}
const unsigned char *begin() const
{
return &*(vector < unsigned char >::begin());
}
// Avoid overriding clear() when using libc++. Fiddling with STL internals
// doesn't really seem like a good idea to me anyway.
#ifndef _LIBCPP_VECTOR
void clear()
{
#if defined(__STL_USE_STD_ALLOCATORS) || defined(__GLIBCPP_INTERNAL_VECTOR_H)
#if defined(__GLIBCPP_INTERNAL_VECTOR_H)
_Destroy(_M_start, _M_finish);
#else /* #if defined(__GLIBCPP_INTERNAL_VECTOR_H) */
destroy(_M_start, _M_finish);
#endif /* #if defined(__GLIBCPP_INTERNAL_VECTOR_H) */
_M_deallocate(_M_start, _M_end_of_storage - _M_start);
_M_start = _M_finish = _M_end_of_storage = 0;
#else /* #if defined(__STL_USE_STD_ALLOCATORS) || defined(__GLIBCPP_INTERNAL_VECTOR_H) */
#if defined(_GLIBCXX_VECTOR)
_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish);
_M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage - this->_M_impl._M_start);
this->_M_impl._M_start = this->_M_impl._M_finish = this->_M_impl._M_end_of_storage = 0;
#else /* #if defined(_GLIBCXX_VECTOR) */
destroy(start, finish);
deallocate();
start = finish = end_of_storage = 0;
#endif /* #if defined(_GLIBCXX_VECTOR) */
#endif /* #if defined(__STL_USE_STD_ALLOCATORS) || defined(__GLIBCPP_INTERNAL_VECTOR_H) */
}
#endif /* #ifdef _LIBCPP_VECTOR */
};
class T_messages : public vector < Message * >
{
public:
// Avoid overriding clear() when using libc++. Fiddling with STL internals
// doesn't really seem like a good idea to me anyway.
#ifndef _LIBCPP_VECTOR
void clear()
{
#if defined(__STL_USE_STD_ALLOCATORS) || defined(__GLIBCPP_INTERNAL_VECTOR_H)
#if defined(__GLIBCPP_INTERNAL_VECTOR_H)
_Destroy(_M_start, _M_finish);
#else /* #if defined(__GLIBCPP_INTERNAL_VECTOR_H) */
destroy(_M_start, _M_finish);
#endif /* #if defined(__GLIBCPP_INTERNAL_VECTOR_H) */
_M_deallocate(_M_start, _M_end_of_storage - _M_start);
_M_start = _M_finish = _M_end_of_storage = 0;
#else /* #if defined(__STL_USE_STD_ALLOCATORS) || defined(__GLIBCPP_INTERNAL_VECTOR_H) */
#if defined(_GLIBCXX_VECTOR)
_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish);
_M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage - this->_M_impl._M_start);
this->_M_impl._M_start = this->_M_impl._M_finish = this->_M_impl._M_end_of_storage = 0;
#else /* #if defined(_GLIBCXX_VECTOR) */
destroy(start, finish);
deallocate();
start = finish = end_of_storage = 0;
#endif /* #if defined(_GLIBCXX_VECTOR) */
#endif /* #if defined(__STL_USE_STD_ALLOCATORS) || defined(__GLIBCPP_INTERNAL_VECTOR_H) */
}
#endif /* #ifndef _LIBCPP_VECTOR */
};
typedef md5_byte_t * T_checksum;
struct T_less
{
bool operator()(T_checksum a, T_checksum b) const
{
return (memcmp(a, b, MD5_LENGTH) < 0);
}
};
typedef map < T_checksum, int, T_less > T_checksums;
class Split;
typedef list < Split * > T_splits;
class File;
struct T_older
{
bool operator()(File *a, File *b) const;
};
typedef set < File *, T_older > T_files;
typedef list < int > T_list;
//
// Used to accommodate data to be read and
// written to a socket.
//
typedef struct
{
T_data data_;
int length_;
int start_;
}
T_buffer;
//
// The message store operation that was
// executed for the message. The channels
// use these values to determine how to
// handle the message after it has been
// received at the decoding side.
//
// Since ProtoStep8 (#issue 108)
enum T_store_action
{
is_hit,
is_added,
is_discarded,
is_removed
};
// Since ProtoStep8 (#issue 108)
#define IS_HIT is_hit
#define IS_ADDED is_added
enum T_checksum_action
{
use_checksum,
discard_checksum
};
enum T_data_action
{
use_data,
discard_data
};
//
// Message is going to be weighted for
// deletion at insert or cleanup time?
//
enum T_rating
{
rating_for_insert,
rating_for_clean
};
//
// How to handle the writes to the X
// and proxy connections.
//
enum T_write
{
write_immediate,
write_delayed
};
enum T_flush
{
flush_if_needed,
flush_if_any
};
//
// This is the value to indicate an
// invalid position in the message
// store.
//
static const int nothing = -1;
#endif /* Types_H */
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2011 NoMachine (http://www.nomachine.com) */
/* Copyright (c) 2008-2014 Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> */
/* Copyright (c) 2014-2016 Ulrich Sibiller <uli42@gmx.de> */
/* Copyright (c) 2014-2016 Mihai Moldovan <ionic@ionic.de> */
/* Copyright (c) 2011-2016 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>*/
/* Copyright (c) 2015-2016 Qindel Group (http://www.qindel.com) */
/* */
/* NXCOMP, NX protocol compression and NX extensions to this software */
/* are copyright of the aforementioned persons and companies. */
/* */
/* Redistribution and use of the present software is allowed according */
/* to terms specified in the file LICENSE.nxcomp which comes in the */
/* source distribution. */
/* */
/* All rights reserved. */
/* */
/* NOTE: This software has received contributions from various other */
/* contributors, only the core maintainers and supporters are listed as */
/* copyright holders. Please contact us, if you feel you should be listed */
/* as copyright holder, as well. */
/* */
/**************************************************************************/
#ifndef Unpack_H
#define Unpack_H
#include "NXpack.h"
#include "Z.h"
#define LSBFirst 0
#define MSBFirst 1
#define SPLIT_PATTERN 0x88
typedef ColorMask T_colormask;
//
// Pixel geometry of channel's display.
//
typedef struct
{
unsigned int depth1_bpp;
unsigned int depth4_bpp;
unsigned int depth8_bpp;
unsigned int depth16_bpp;
unsigned int depth24_bpp;
unsigned int depth32_bpp;
unsigned int red_mask;
unsigned int green_mask;
unsigned int blue_mask;
unsigned int image_byte_order;
unsigned int bitmap_bit_order;
unsigned int scanline_unit;
unsigned int scanline_pad;
} T_geometry;
//
// Colormap is used to remap colors
// from source to destination depth.
//
typedef struct
{
unsigned int entries;
unsigned int *data;
} T_colormap;
//
// Alpha channel data is added to 32
// bits images at the time they are
// unpacked.
//
typedef struct
{
unsigned int entries;
unsigned char *data;
} T_alpha;
//
// The ZLIB stream structure used for
// the decompression.
//
extern z_stream unpackStream;
//
// Initialize the ZLIB stream used for
// decompression.
//
void UnpackInit();
//
// Free the ZLIB stream.
//
void UnpackDestroy();
//
// Get the destination bits per pixel
// based on the drawable depth.
//
int UnpackBitsPerPixel(T_geometry *geometry, unsigned int depth);
//
// Unpack the source data into the X
// bitmap.
//
int Unpack8(T_geometry *geometry, const T_colormask *colormask, int src_depth, int src_width,
int src_height, unsigned char *src_data, int src_size, int dst_depth,
int dst_width, int dst_height, unsigned char *dst_data, int dst_size);
int Unpack16(T_geometry *geometry, const T_colormask *colormask, int src_depth, int src_width,
int src_height, unsigned char *src_data, int src_size, int dst_depth,
int dst_width, int dst_height, unsigned char *dst_data, int dst_size);
int Unpack24(T_geometry *geometry, const T_colormask *colormask, int src_depth, int src_width,
int src_height, unsigned char *src_data, int src_size, int dst_depth,
int dst_width, int dst_height, unsigned char *dst_data, int dst_size);
int Unpack8(T_geometry *geometry, T_colormap *colormap, int src_depth, int src_width,
int src_height, unsigned char *src_data, int src_size, int dst_depth,
int dst_width, int dst_height, unsigned char *dst_data, int dst_size);
int Unpack15(T_geometry *geometry, int src_depth, int src_width,
int src_height, unsigned char *src_data, int src_size, int dst_depth,
int dst_width, int dst_height, unsigned char *dst_data, int dst_size);
int Unpack16(T_geometry *geometry, int src_depth, int src_width,
int src_height, unsigned char *src_data, int src_size, int dst_depth,
int dst_width, int dst_height, unsigned char *dst_data, int dst_size);
int Unpack24(T_geometry *geometry, int src_depth, int src_width,
int src_height, unsigned char *src_data, int src_size, int dst_depth,
int dst_width, int dst_height, unsigned char *dst_data, int dst_size);
#endif /* Unpack_H */
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2011 NoMachine (http://www.nomachine.com) */
/* Copyright (c) 2008-2014 Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> */
/* Copyright (c) 2014-2016 Ulrich Sibiller <uli42@gmx.de> */
/* Copyright (c) 2014-2016 Mihai Moldovan <ionic@ionic.de> */
/* Copyright (c) 2011-2016 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>*/
/* Copyright (c) 2015-2016 Qindel Group (http://www.qindel.com) */
/* */
/* NXCOMP, NX protocol compression and NX extensions to this software */
/* are copyright of the aforementioned persons and companies. */
/* */
/* Redistribution and use of the present software is allowed according */
/* to terms specified in the file LICENSE.nxcomp which comes in the */
/* source distribution. */
/* */
/* All rights reserved. */
/* */
/* NOTE: This software has received contributions from various other */
/* contributors, only the core maintainers and supporters are listed as */
/* copyright holders. Please contact us, if you feel you should be listed */
/* as copyright holder, as well. */
/* */
/**************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include "NXvars.h"
/*
* Allocate here instances of variables and
* pointers declared in NXvars.h.
*/
int _NXHandleDisplayError = 0;
NXDisplayErrorPredicate _NXDisplayErrorFunction = NULL;
int _NXUnsetLibraryPath = 0;
NXLostSequenceHandler _NXLostSequenceFunction = NULL;
NXDisplayBlockHandler _NXDisplayBlockFunction = NULL;
NXDisplayWriteHandler _NXDisplayWriteFunction = NULL;
NXDisplayFlushHandler _NXDisplayFlushFunction = NULL;
NXDisplayStatisticsHandler _NXDisplayStatisticsFunction = NULL;
#ifdef __cplusplus
}
#endif
/**************************************************************************/
/* */
/* Copyright (c) 2015 Qindel Formacion y Servicios SL. */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License Version 2, as */
/* published by the Free Software Foundation. */
/* */
/* This program is distributed in the hope that it will be useful, but */
/* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA- */
/* BILITY 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 program; if not, you can request a copy from Qindel */
/* or write to the Free Software Foundation, Inc., 51 Franklin Street, */
/* Fifth Floor, Boston, MA 02110-1301 USA. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "NX.h"
static int _NXVersionMajor = -1;
static int _NXVersionMinor = -1;
static int _NXVersionPatch = -1;
static int _NXVersionMaintenancePatch = -1;
const char* NXVersion() {
const char *version = VERSION;
return version;
}
void _parseNXVersion() {
char version[32];
int i;
strcpy(version, VERSION);
char *value;
/* Reset values to 0 if undefined */
_NXVersionMajor = _NXVersionMinor = _NXVersionPatch = _NXVersionMaintenancePatch = 0;
#define NXVERSIONSEPARATOR "."
value = strtok(version, NXVERSIONSEPARATOR);
for (i = 0; value != NULL && i < 4; i++)
{
switch (i)
{
case 0:
_NXVersionMajor = atoi(value);
break;
case 1:
_NXVersionMinor = atoi(value);
break;
case 2:
_NXVersionPatch = atoi(value);
break;
case 3:
_NXVersionMaintenancePatch = atoi(value);
break;
}
value = strtok(NULL, NXVERSIONSEPARATOR);
}
}
int NXMajorVersion() {
if (_NXVersionMajor == -1)
_parseNXVersion();
return _NXVersionMajor;
}
int NXMinorVersion() {
if (_NXVersionMinor == -1)
_parseNXVersion();
return _NXVersionMinor;
}
int NXPatchVersion() {
if (_NXVersionPatch == -1)
_parseNXVersion();
return _NXVersionPatch;
}
int NXMaintenancePatchVersion() {
if (_NXVersionMaintenancePatch == -1)
_parseNXVersion();
return _NXVersionMaintenancePatch;
}
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2011 NoMachine (http://www.nomachine.com) */
/* Copyright (c) 2008-2014 Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> */
/* Copyright (c) 2014-2016 Ulrich Sibiller <uli42@gmx.de> */
/* Copyright (c) 2014-2016 Mihai Moldovan <ionic@ionic.de> */
/* Copyright (c) 2011-2016 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>*/
/* Copyright (c) 2015-2016 Qindel Group (http://www.qindel.com) */
/* */
/* NXCOMP, NX protocol compression and NX extensions to this software */
/* are copyright of the aforementioned persons and companies. */
/* */
/* Redistribution and use of the present software is allowed according */
/* to terms specified in the file LICENSE.nxcomp which comes in the */
/* source distribution. */
/* */
/* All rights reserved. */
/* */
/* NOTE: This software has received contributions from various other */
/* contributors, only the core maintainers and supporters are listed as */
/* copyright holders. Please contact us, if you feel you should be listed */
/* as copyright holder, as well. */
/* */
/**************************************************************************/
#ifndef WriteBuffer_H
#define WriteBuffer_H
#include "Misc.h"
#define PANIC
#define WARNING
#undef TEST
#undef DEBUG
#define WRITE_BUFFER_DEFAULT_SIZE 16384
//
// Adjust for the biggest reply that we could receive.
// This is likely to be a reply to a X_ListFonts where
// user has a large amount of installed fonts.
//
#define WRITE_BUFFER_OVERFLOW_SIZE 4194304
class WriteBuffer
{
public:
WriteBuffer();
~WriteBuffer();
void setSize(unsigned int initialSize, unsigned int thresholdSize,
unsigned int maximumSize);
unsigned char *addMessage(unsigned int numBytes);
unsigned char *removeMessage(unsigned int numBytes);
unsigned char *addScratchMessage(unsigned int numBytes);
//
// This form allows user to provide its own
// buffer as write buffer's scratch area.
//
unsigned char *addScratchMessage(unsigned char *newBuffer, unsigned int numBytes);
void removeScratchMessage();
void partialReset();
void fullReset();
unsigned char *getData() const
{
return buffer_;
}
unsigned int getLength() const
{
return length_;
}
unsigned int getAvailable() const
{
return (size_ - length_);
}
unsigned char *getScratchData() const
{
return scratchBuffer_;
}
unsigned int getScratchLength() const
{
return scratchLength_;
}
unsigned int getTotalLength() const
{
return (length_ + scratchLength_);
}
void registerPointer(unsigned char **pointer)
{
index_ = pointer;
}
void unregisterPointer()
{
index_ = 0;
}
private:
unsigned int size_;
unsigned int length_;
unsigned char *buffer_;
unsigned char **index_;
unsigned int scratchLength_;
unsigned char *scratchBuffer_;
int scratchOwner_;
unsigned int initialSize_;
unsigned int thresholdSize_;
unsigned int maximumSize_;
};
#endif /* WriteBuffer_H */
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2011 NoMachine (http://www.nomachine.com) */
/* Copyright (c) 2008-2014 Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> */
/* Copyright (c) 2014-2016 Ulrich Sibiller <uli42@gmx.de> */
/* Copyright (c) 2014-2016 Mihai Moldovan <ionic@ionic.de> */
/* Copyright (c) 2011-2016 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>*/
/* Copyright (c) 2015-2016 Qindel Group (http://www.qindel.com) */
/* */
/* NXCOMP, NX protocol compression and NX extensions to this software */
/* are copyright of the aforementioned persons and companies. */
/* */
/* Redistribution and use of the present software is allowed according */
/* to terms specified in the file LICENSE.nxcomp which comes in the */
/* source distribution. */
/* */
/* All rights reserved. */
/* */
/* NOTE: This software has received contributions from various other */
/* contributors, only the core maintainers and supporters are listed as */
/* copyright holders. Please contact us, if you feel you should be listed */
/* as copyright holder, as well. */
/* */
/**************************************************************************/
#include "Control.h"
#include "XidCache.h"
XidCache::XidCache()
{
for (int i = 0; i < 256; i++)
{
base_[i] = new IntCache(8);
}
slot_ = 0;
last_ = 0;
}
XidCache::~XidCache()
{
for (int i = 0; i < 256; i++)
{
delete base_[i];
}
}
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2011 NoMachine (http://www.nomachine.com) */
/* Copyright (c) 2008-2014 Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> */
/* Copyright (c) 2014-2016 Ulrich Sibiller <uli42@gmx.de> */
/* Copyright (c) 2014-2016 Mihai Moldovan <ionic@ionic.de> */
/* Copyright (c) 2011-2016 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>*/
/* Copyright (c) 2015-2016 Qindel Group (http://www.qindel.com) */
/* */
/* NXCOMP, NX protocol compression and NX extensions to this software */
/* are copyright of the aforementioned persons and companies. */
/* */
/* Redistribution and use of the present software is allowed according */
/* to terms specified in the file LICENSE.nxcomp which comes in the */
/* source distribution. */
/* */
/* All rights reserved. */
/* */
/* NOTE: This software has received contributions from various other */
/* contributors, only the core maintainers and supporters are listed as */
/* copyright holders. Please contact us, if you feel you should be listed */
/* as copyright holder, as well. */
/* */
/**************************************************************************/
#ifndef XidCache_H
#define XidCache_H
#include "IntCache.h"
class XidCache
{
friend class EncodeBuffer;
friend class DecodeBuffer;
public:
XidCache();
~XidCache();
private:
IntCache *base_[256];
unsigned int slot_;
unsigned int last_;
};
#endif /* XidCache_H */
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2011 NoMachine (http://www.nomachine.com) */
/* Copyright (c) 2008-2014 Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> */
/* Copyright (c) 2014-2016 Ulrich Sibiller <uli42@gmx.de> */
/* Copyright (c) 2014-2016 Mihai Moldovan <ionic@ionic.de> */
/* Copyright (c) 2011-2016 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>*/
/* Copyright (c) 2015-2016 Qindel Group (http://www.qindel.com) */
/* */
/* NXCOMP, NX protocol compression and NX extensions to this software */
/* are copyright of the aforementioned persons and companies. */
/* */
/* Redistribution and use of the present software is allowed according */
/* to terms specified in the file LICENSE.nxcomp which comes in the */
/* source distribution. */
/* */
/* All rights reserved. */
/* */
/* NOTE: This software has received contributions from various other */
/* contributors, only the core maintainers and supporters are listed as */
/* copyright holders. Please contact us, if you feel you should be listed */
/* as copyright holder, as well. */
/* */
/**************************************************************************/
#include "Z.h"
#include "Misc.h"
int ZCompress(z_stream *stream, unsigned char *dest, unsigned int *destLen,
const unsigned char *source, unsigned int sourceLen)
{
//
// Deal with the possible overflow.
//
if (stream -> total_out & 0x80000000)
{
#ifdef TEST
*logofs << "ZCompress: Reset stream counters with "
<< "total in " << stream -> total_in
<< " and total out " << stream -> total_out
<< ".\n" << logofs_flush;
#endif
stream -> total_in = 0;
stream -> total_out = 0;
}
unsigned int saveOut = stream -> total_out;
stream -> next_in = (Bytef *) source;
stream -> avail_in = sourceLen;
//
// Check if the source is bigger than
// 64K on 16-bit machine.
//
#ifdef MAXSEG_64K
if ((uLong) stream -> avail_in != sourceLen) return Z_BUF_ERROR;
#endif
stream -> next_out = dest;
stream -> avail_out = *destLen;
#ifdef MAXSEG_64K
if ((uLong) stream -> avail_out != *destLen) return Z_BUF_ERROR;
#endif
int result = deflate(stream, Z_FINISH);
if (result != Z_STREAM_END)
{
deflateReset(stream);
return (result == Z_OK ? Z_BUF_ERROR : result);
}
*destLen = stream -> total_out - saveOut;
result = deflateReset(stream);
return result;
}
int ZDecompress(z_stream *stream, unsigned char *dest, unsigned int *destLen,
const unsigned char *source, unsigned int sourceLen)
{
stream -> next_in = (Bytef *) source;
stream -> avail_in = sourceLen;
//
// Deal with the possible overflow.
//
if (stream -> total_out & 0x80000000)
{
#ifdef TEST
*logofs << "ZDecompress: Reset stream counters with "
<< "total in " << stream -> total_in
<< " and total out " << stream -> total_out
<< ".\n" << logofs_flush;
#endif
stream -> total_in = 0;
stream -> total_out = 0;
}
unsigned int saveOut = stream -> total_out;
if (stream -> avail_in != sourceLen)
{
return Z_BUF_ERROR;
}
stream -> next_out = dest;
stream -> avail_out = *destLen;
if (stream -> avail_out != *destLen)
{
return Z_BUF_ERROR;
}
int result = inflate(stream, Z_FINISH);
if (result != Z_STREAM_END)
{
inflateReset(stream);
return (result == Z_OK ? Z_BUF_ERROR : result);
}
*destLen = stream -> total_out - saveOut;
result = inflateReset(stream);
return result;
}
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2011 NoMachine (http://www.nomachine.com) */
/* Copyright (c) 2008-2014 Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> */
/* Copyright (c) 2014-2016 Ulrich Sibiller <uli42@gmx.de> */
/* Copyright (c) 2014-2016 Mihai Moldovan <ionic@ionic.de> */
/* Copyright (c) 2011-2016 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>*/
/* Copyright (c) 2015-2016 Qindel Group (http://www.qindel.com) */
/* */
/* NXCOMP, NX protocol compression and NX extensions to this software */
/* are copyright of the aforementioned persons and companies. */
/* */
/* Redistribution and use of the present software is allowed according */
/* to terms specified in the file LICENSE.nxcomp which comes in the */
/* source distribution. */
/* */
/* All rights reserved. */
/* */
/* NOTE: This software has received contributions from various other */
/* contributors, only the core maintainers and supporters are listed as */
/* copyright holders. Please contact us, if you feel you should be listed */
/* as copyright holder, as well. */
/* */
/**************************************************************************/
#ifndef Z_H
#define Z_H
#include <zlib.h>
int ZCompress(z_stream *stream, unsigned char *dest, unsigned int *destLen,
const unsigned char *source, unsigned int sourceLen);
int ZDecompress(z_stream *stream, unsigned char *dest, unsigned int *destLen,
const unsigned char *source, unsigned int sourceLen);
#endif /* Z_H */
# ***************************************************************************
# *** configure.ac for nxcomp ***
# ***************************************************************************
m4_define([nxcomp_version], m4_esyscmd([tr -d '\n' < VERSION]))
# Initialize Autoconf
AC_PREREQ(2.60)
AC_INIT([libXcomp], [nxcomp_version], [https://github.com/ArcticaProject/nx-libs/issues])
AC_CONFIG_AUX_DIR([build-aux])
AC_PROG_CXX
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign no-dist-gzip dist-xz])
# Initialize libtool
AC_PROG_LIBTOOL
COMP_VERSION=nxcomp_version
AC_SUBST([COMP_VERSION])
LT_COMP_VERSION=[`echo $COMP_VERSION | sed -r -e 's/^([0-9]+\.[0-9]+\.[0-9]+).*$/\1/' -e 's/\./:/g'`]
AC_SUBST([LT_COMP_VERSION])
PKG_CHECK_MODULES(JPEG, libjpeg)
PKG_CHECK_MODULES(PNG, libpng)
PKG_CHECK_MODULES(Z, zlib)
# Upstream's pkg.m4 (since 0.27) offers this now, but define our own
# compatible version in case the local version of pkgconfig isn't new enough.
# https://bugs.freedesktop.org/show_bug.cgi?id=48743
m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR],
[AC_ARG_WITH([pkgconfigdir],
[AS_HELP_STRING([--with-pkgconfigdir],
[install directory for nxcompshad.pc pkg-config file])],
[],[with_pkgconfigdir='$(libdir)/pkgconfig'])
AC_SUBST([pkgconfigdir], [${with_pkgconfigdir}])])
AC_LANG([C++])
NX_COMPILER_BRAND
NX_COMPILER_FLAGS
NX_BUILD_ON_CYGWIN32
NX_BUILD_ON_AMD64
NX_BUILD_ON_DARWIN
NX_BUILD_ON_SUN
NX_BUILD_ON_FreeBSD
# Build PIC libraries.
if test "$CYGWIN32" != yes -a "$DARWIN" != yes; then
CXXFLAGS="$CXXFLAGS -fPIC"
CFLAGS="$CFLAGS -fPIC"
fi
# On FreeBSD search libraries and includes under /usr/local.
if test "$FreeBSD" = yes; then
LIBS="$LIBS -L/usr/local/lib"
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
fi
# If in_addr_t is not defined use unsigned int.
AC_CHECK_TYPES([in_addr_t], [], [], [[#include <netinet/in.h>]])
AC_ARG_ENABLE(info,
[AS_HELP_STRING([--enable-debug], [enable to get info session log output (disabled by default)])],
[if test x$enableval = xyes; then
AC_DEFINE(INFO, 1, [Define this to get info session log output.])
info_messages=yes
fi])
AC_ARG_ENABLE(valgrind,
[AS_HELP_STRING([--enable-valgrind], [enable for extra valgrind hacks (disabled by default)])],
[if test x$enableval = xyes; then
AC_DEFINE(VALGRIND, 1, [Define this for extra valgrind hacks.])
valgrind_hacks=yes
fi])
AC_CONFIG_FILES([
Makefile
src/Makefile
nxcomp.pc
])
AC_OUTPUT
#! /bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
#
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0
../../m4/nx-macros.m4
\ No newline at end of file
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Last modified: 1995-03-05
# Public domain
errstatus=0
for file in ${1+"$@"} ; do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
pathcomp=
for d in ${1+"$@"} ; do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp" 1>&2
mkdir "$pathcomp" > /dev/null 2>&1 || lasterr=$?
fi
if test ! -d "$pathcomp"; then
errstatus=$lasterr
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
......@@ -5,7 +5,7 @@ includedir=@includedir@
Name: nxcomp
Description: NX Compression Library
Version: @VERSION@
Version: @COMP_VERSION@
#libjepg does not provide a pkgconfig-file, zlib does not provide it for older versions
#Requires: libjpeg zlib
Requires: libpng
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "Control.h"
#include "ActionCache.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "Misc.h"
#include "Agent.h"
#include "Proxy.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "Misc.h"
#include "Unpack.h"
#include "Alpha.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "Auth.h"
#include "Misc.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "Misc.h"
#include "Bitmap.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include "BlockCache.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "Misc.h"
#include "BlockCacheSet.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "ChangeGC.h"
#include "ClientCache.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "ChangeProperty.h"
#include "ClientCache.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "Channel.h"
#include "List.h"
......
......@@ -519,7 +519,7 @@ class Channel
// Set up the split stores.
//
void handleSplitStoreError(int resource);
void handleSplitStoreError(int resource) __attribute__((noreturn));
void handleSplitStoreAlloc(List *list, int resource);
void handleSplitStoreRemove(List *list, int resource);
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "ChannelCache.h"
const unsigned int CONFIGUREWINDOW_FIELD_WIDTH[7] =
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "CharCache.h"
int CharCache::lookup(unsigned char value, unsigned int &index)
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
......@@ -60,7 +64,7 @@
extern Keeper *keeper;
extern int (*handler)(int);
extern int (*signalHandler)(int);
extern int useUnixSocket;
......@@ -788,7 +792,7 @@ int NXTransKeeper(int caches, int images, const char *root)
keeper = new Keeper(caches, images, root, 100, parent);
handler = NXTransKeeperHandler;
signalHandler = NXTransKeeperHandler;
if (keeper == NULL)
{
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "ClearArea.h"
#include "ClientCache.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "ClientCache.h"
ClientCache::ClientCache() :
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include <X11/X.h>
......@@ -693,10 +697,10 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m
*(clientCache_ -> convertSelectionAtomCache[i]), 9);
nextSrc += 4;
}
unsigned int timestamp = GetULONG(nextSrc, bigEndian_);
encodeBuffer.encodeValue(timestamp -
unsigned int _timestamp = GetULONG(nextSrc, bigEndian_);
encodeBuffer.encodeValue(_timestamp -
clientCache_ -> convertSelectionLastTimestamp, 32, 4);
clientCache_ -> convertSelectionLastTimestamp = timestamp;
clientCache_ -> convertSelectionLastTimestamp = _timestamp;
}
break;
case X_CopyArea:
......@@ -1368,10 +1372,10 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m
encodeBuffer.encodeCachedValue(GetULONG(inputMessage + 16,
bigEndian_), 29, clientCache_ -> cursorCache, 9);
unsigned int timestamp = GetULONG(inputMessage + 20, bigEndian_);
encodeBuffer.encodeValue(timestamp -
unsigned int _timestamp = GetULONG(inputMessage + 20, bigEndian_);
encodeBuffer.encodeValue(_timestamp -
clientCache_ -> grabKeyboardLastTimestamp, 32, 4);
clientCache_ -> grabKeyboardLastTimestamp = timestamp;
clientCache_ -> grabKeyboardLastTimestamp = _timestamp;
sequenceQueue_.push(clientSequence_, inputOpcode);
......@@ -1383,10 +1387,10 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m
encodeBuffer.encodeBoolValue((unsigned int) inputMessage[1]);
encodeBuffer.encodeXidValue(GetULONG(inputMessage + 4, bigEndian_),
clientCache_ -> windowCache);
unsigned int timestamp = GetULONG(inputMessage + 8, bigEndian_);
encodeBuffer.encodeValue(timestamp -
unsigned int _timestamp = GetULONG(inputMessage + 8, bigEndian_);
encodeBuffer.encodeValue(_timestamp -
clientCache_ -> grabKeyboardLastTimestamp, 32, 4);
clientCache_ -> grabKeyboardLastTimestamp = timestamp;
clientCache_ -> grabKeyboardLastTimestamp = _timestamp;
encodeBuffer.encodeBoolValue((unsigned int) inputMessage[12]);
encodeBuffer.encodeBoolValue((unsigned int) inputMessage[13]);
......@@ -3603,10 +3607,10 @@ int ClientChannel::handleWrite(const unsigned char *message, unsigned int length
unsigned char *nextDest = outputMessage + 32;
for (; numExtensions; numExtensions--)
{
unsigned int length;
decodeBuffer.decodeValue(length, 8);
*nextDest++ = (unsigned char) length;
for (; length; length--)
unsigned int _length;
decodeBuffer.decodeValue(_length, 8);
*nextDest++ = (unsigned char) _length;
for (; _length; _length--)
{
decodeBuffer.decodeValue(value, 8);
*nextDest++ = value;
......@@ -3651,13 +3655,13 @@ int ClientChannel::handleWrite(const unsigned char *message, unsigned int length
unsigned char* nextDest = outputMessage + 32;
for (; numFonts; numFonts--)
{
unsigned int length;
decodeBuffer.decodeValue(length, 8);
*nextDest++ = (unsigned char)length;
unsigned int _length;
decodeBuffer.decodeValue(_length, 8);
*nextDest++ = (unsigned char)_length;
// Since ProtoStep7 (#issue 108)
decodeBuffer.decodeTextData(nextDest, length);
nextDest += length;
decodeBuffer.decodeTextData(nextDest, _length);
nextDest += _length;
}
handleSave(messageStore, outputMessage, outputLength);
......@@ -3900,10 +3904,10 @@ int ClientChannel::handleWrite(const unsigned char *message, unsigned int length
{
unsigned int index;
decodeBuffer.decodeValue(index, 4);
unsigned int length;
unsigned int _length;
const unsigned char *data;
ServerCache::queryFontFontCache.get(index, length, data);
memcpy(nextDest, data, length);
ServerCache::queryFontFontCache.get(index, _length, data);
memcpy(nextDest, data, _length);
end = 1;
}
......@@ -3911,7 +3915,7 @@ int ClientChannel::handleWrite(const unsigned char *message, unsigned int length
if (end == 0)
{
unsigned char *saveDest = nextDest;
unsigned int length = numProperties * 8 + numCharInfos * 12;
unsigned int _length = numProperties * 8 + numCharInfos * 12;
for (; numProperties; numProperties--)
{
decodeBuffer.decodeValue(value, 32, 9);
......@@ -3926,7 +3930,7 @@ int ClientChannel::handleWrite(const unsigned char *message, unsigned int length
nextDest += 12;
}
ServerCache::queryFontFontCache.set(length, saveDest);
ServerCache::queryFontFontCache.set(_length, saveDest);
}
handleSave(messageStore, outputMessage, outputLength);
......@@ -7841,12 +7845,12 @@ void ClientChannel::handleDecodeCharInfo(DecodeBuffer &decodeBuffer, unsigned ch
for (unsigned int i = 1; i < 5; i++)
{
unsigned int value;
unsigned int _value;
decodeBuffer.decodeCachedValue(value, 16,
decodeBuffer.decodeCachedValue(_value, 16,
*serverCache_ -> queryFontCharInfoCache[i], 6);
PutUINT(value, nextDest, bigEndian_);
PutUINT(_value, nextDest, bigEndian_);
nextDest += 2;
}
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "Socket.h"
#include "Agent.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "ClientReadBuffer.h"
#include "ClientChannel.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "ClientStore.h"
//
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "Misc.h"
#include "Unpack.h"
#include "Colormap.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "ConfigureWindow.h"
#include "ClientCache.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "NX.h"
#include "NXpack.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "CopyArea.h"
#include "ClientCache.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "CreateGC.h"
#include "ClientCache.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "CreatePixmap.h"
#include "ClientCache.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "Misc.h"
#include "Control.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "Misc.h"
#include "Control.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "FillPoly.h"
#include "ClientCache.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <unistd.h>
#include "Fork.h"
......
......@@ -23,6 +23,10 @@
/* */
/**************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
#include <sys/socket.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment