summaryrefslogtreecommitdiffstats
path: root/libvncclient
diff options
context:
space:
mode:
authordscho <dscho>2003-07-28 12:01:07 +0000
committerdscho <dscho>2003-07-28 12:01:07 +0000
commit13b358fed1b89a7a7f8c47bc175dcb3ccae1e39b (patch)
tree8ca17b27e8b953403b93625381aa162d734c4287 /libvncclient
parenteef408c1d84c7aaceb9732dd9a7e216886d2c2f8 (diff)
downloadlibvncserver-13b358fed1b89a7a7f8c47bc175dcb3ccae1e39b.zip
libvncserver-13b358fed1b89a7a7f8c47bc175dcb3ccae1e39b.tar.gz
fixed maxRectsPerUpdate with Tight encoding bug; some autoconfing; stderr should not be used in a library (use rfbLog instead)
Diffstat (limited to 'libvncclient')
-rw-r--r--libvncclient/Makefile368
-rw-r--r--libvncclient/Makefile.am18
-rw-r--r--libvncclient/Makefile.in365
-rw-r--r--libvncclient/client_test.c98
-rw-r--r--libvncclient/corre.c2
-rw-r--r--libvncclient/listen.c4
-rw-r--r--libvncclient/rfbproto.c253
-rw-r--r--libvncclient/rre.c10
-rw-r--r--libvncclient/sockets.c26
-rw-r--r--libvncclient/tight.c28
-rw-r--r--libvncclient/vncviewer.c141
-rw-r--r--libvncclient/zlib.c12
12 files changed, 1036 insertions, 289 deletions
diff --git a/libvncclient/Makefile b/libvncclient/Makefile
index 026b5b2..475dd25 100644
--- a/libvncclient/Makefile
+++ b/libvncclient/Makefile
@@ -1,17 +1,365 @@
-CFLAGS=-g -I.. -I. -Wall
-LDLIBS=-lz -ljpeg
+# Makefile.in generated by automake 1.6.3 from Makefile.am.
+# libvncclient/Makefile. Generated from Makefile.in by configure.
-OBJS=cursor.o listen.o rfbproto.o sockets.o vncviewer.o ../libvncserver.a
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
-all: libvncclient.a
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
-rfbproto.o: rfbproto.c corre.c hextile.c rre.c tight.c zlib.c
-$(OBJS): ../rfb/rfbclient.h
+SHELL = /bin/sh
+
+srcdir = .
+top_srcdir = ..
+
+prefix = /usr/local
+exec_prefix = ${prefix}
+
+bindir = ${exec_prefix}/bin
+sbindir = ${exec_prefix}/sbin
+libexecdir = ${exec_prefix}/libexec
+datadir = ${prefix}/share
+sysconfdir = ${prefix}/etc
+sharedstatedir = ${prefix}/com
+localstatedir = ${prefix}/var
+libdir = ${exec_prefix}/lib
+infodir = ${prefix}/info
+mandir = ${prefix}/man
+includedir = ${prefix}/include
+oldincludedir = /usr/include
+pkgdatadir = $(datadir)/LibVNCServer
+pkglibdir = $(libdir)/LibVNCServer
+pkgincludedir = $(includedir)/LibVNCServer
+top_builddir = ..
+
+ACLOCAL = ${SHELL} /my/libvncserver/missing --run aclocal-1.6
+AUTOCONF = ${SHELL} /my/libvncserver/missing --run autoconf
+AUTOMAKE = ${SHELL} /my/libvncserver/missing --run automake-1.6
+AUTOHEADER = ${SHELL} /my/libvncserver/missing --run autoheader
+
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = /usr/bin/install -c
+INSTALL_PROGRAM = ${INSTALL}
+INSTALL_DATA = ${INSTALL} -m 644
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_SCRIPT = ${INSTALL}
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = s,x,x,
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+
+EXEEXT =
+OBJEXT = o
+PATH_SEPARATOR = :
+AMTAR = ${SHELL} /my/libvncserver/missing --run tar
+AWK = gawk
+CC = gcc
+CCLD = g++
+CXX = g++
+DEPDIR = .deps
+INSTALL_STRIP_PROGRAM = ${SHELL} $(install_sh) -c -s
+PACKAGE = LibVNCServer
+RANLIB = ranlib
+RPMSOURCEDIR = /usr/src/packages/SOURCES/
+STRIP =
+VERSION = 0.6pre
+X_CFLAGS = -I/usr/X11R6/include
+X_EXTRA_LIBS =
+X_LIBS = -L/usr/X11R6/lib -lXtst -lXext -lX11
+X_PRE_LIBS = -lSM -lICE
+am__include = include
+am__quote =
+install_sh = /my/libvncserver/install-sh
+CFLAGS = -g -I.. -I. -Wall
+
+libvncclient_a_SOURCES = cursor.c listen.c rfbproto.c sockets.c vncviewer.c
+
+EXTRA_DIST = corre.c hextile.c rre.c tight.c zlib.c
+
+lib_LIBRARIES = libvncclient.a
+
+client_test_SOURCES = client_test.c
+
+noinst_PROGRAMS = client_test
+
+#client_test_LDADD=libvncclient.a ../libvncserver.a
+client_test_LDADD = libvncclient.a
+subdir = libvncclient
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/rfb/rfbconfig.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(lib_LIBRARIES)
+
+libvncclient_a_AR = $(AR) cru
+libvncclient_a_LIBADD =
+am_libvncclient_a_OBJECTS = cursor.$(OBJEXT) listen.$(OBJEXT) \
+ rfbproto.$(OBJEXT) sockets.$(OBJEXT) vncviewer.$(OBJEXT)
+libvncclient_a_OBJECTS = $(am_libvncclient_a_OBJECTS)
+noinst_PROGRAMS = client_test$(EXEEXT)
+PROGRAMS = $(noinst_PROGRAMS)
+
+am_client_test_OBJECTS = client_test.$(OBJEXT)
+client_test_OBJECTS = $(am_client_test_OBJECTS)
+client_test_DEPENDENCIES = libvncclient.a
+client_test_LDFLAGS =
+
+DEFS = -DHAVE_CONFIG_H
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/rfb
+CPPFLAGS =
+LDFLAGS =
+LIBS = -lnsl -lz -lpthread -ljpeg
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+DEP_FILES = ./$(DEPDIR)/client_test.Po ./$(DEPDIR)/cursor.Po \
+ ./$(DEPDIR)/listen.Po ./$(DEPDIR)/rfbproto.Po \
+ ./$(DEPDIR)/sockets.Po ./$(DEPDIR)/vncviewer.Po
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(libvncclient_a_SOURCES) $(client_test_SOURCES)
+DIST_COMMON = Makefile.am Makefile.in
+SOURCES = $(libvncclient_a_SOURCES) $(client_test_SOURCES)
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .o .obj
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4)
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu libvncclient/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
+
+AR = ar
+libLIBRARIES_INSTALL = $(INSTALL_DATA)
+install-libLIBRARIES: $(lib_LIBRARIES)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(libdir)
+ @list='$(lib_LIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ f="`echo $$p | sed -e 's|^.*/||'`"; \
+ echo " $(libLIBRARIES_INSTALL) $$p $(DESTDIR)$(libdir)/$$f"; \
+ $(libLIBRARIES_INSTALL) $$p $(DESTDIR)$(libdir)/$$f; \
+ else :; fi; \
+ done
+ @$(POST_INSTALL)
+ @list='$(lib_LIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ p="`echo $$p | sed -e 's|^.*/||'`"; \
+ echo " $(RANLIB) $(DESTDIR)$(libdir)/$$p"; \
+ $(RANLIB) $(DESTDIR)$(libdir)/$$p; \
+ else :; fi; \
+ done
+
+uninstall-libLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(lib_LIBRARIES)'; for p in $$list; do \
+ p="`echo $$p | sed -e 's|^.*/||'`"; \
+ echo " rm -f $(DESTDIR)$(libdir)/$$p"; \
+ rm -f $(DESTDIR)$(libdir)/$$p; \
+ done
+
+clean-libLIBRARIES:
+ -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES)
+libvncclient.a: $(libvncclient_a_OBJECTS) $(libvncclient_a_DEPENDENCIES)
+ -rm -f libvncclient.a
+ $(libvncclient_a_AR) libvncclient.a $(libvncclient_a_OBJECTS) $(libvncclient_a_LIBADD)
+ $(RANLIB) libvncclient.a
+
+clean-noinstPROGRAMS:
+ -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
+client_test$(EXEEXT): $(client_test_OBJECTS) $(client_test_DEPENDENCIES)
+ @rm -f client_test$(EXEEXT)
+ $(LINK) $(client_test_LDFLAGS) $(client_test_OBJECTS) $(client_test_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT) core *.core
+
+distclean-compile:
+ -rm -f *.tab.c
+
+include ./$(DEPDIR)/client_test.Po
+include ./$(DEPDIR)/cursor.Po
+include ./$(DEPDIR)/listen.Po
+include ./$(DEPDIR)/rfbproto.Po
+include ./$(DEPDIR)/sockets.Po
+include ./$(DEPDIR)/vncviewer.Po
+
+distclean-depend:
+ -rm -rf ./$(DEPDIR)
+
+.c.o:
+ source='$<' object='$@' libtool=no \
+ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' \
+ $(CCDEPMODE) $(depcomp) \
+ $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
+
+.c.obj:
+ source='$<' object='$@' libtool=no \
+ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' \
+ $(CCDEPMODE) $(depcomp) \
+ $(COMPILE) -c `cygpath -w $<`
+CCDEPMODE = depmode=gcc3
+uninstall-info-am:
+
+ETAGS = etags
+ETAGSFLAGS =
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
-libvncclient.a: $(OBJS)
- $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)$$tags$$unique" \
+ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique
-clean:
- rm *.o *.a
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+
+top_distdir = ..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
+
+distdir: $(DISTFILES)
+ @list='$(DISTFILES)'; for file in $$list; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkinstalldirs) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
+ if test -d $$d/$$file; then \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+
+installdirs:
+ $(mkinstalldirs) $(DESTDIR)$(libdir)
+
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libLIBRARIES clean-noinstPROGRAMS \
+ mostlyclean-am
+
+distclean: distclean-am
+
+distclean-am: clean-am distclean-compile distclean-depend \
+ distclean-generic distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am: install-libLIBRARIES
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+uninstall-am: uninstall-info-am uninstall-libLIBRARIES
+
+.PHONY: GTAGS all all-am check check-am clean clean-generic \
+ clean-libLIBRARIES clean-noinstPROGRAMS distclean \
+ distclean-compile distclean-depend distclean-generic \
+ distclean-tags distdir dvi dvi-am info info-am install \
+ install-am install-data install-data-am install-exec \
+ install-exec-am install-info install-info-am \
+ install-libLIBRARIES install-man install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic tags uninstall uninstall-am \
+ uninstall-info-am uninstall-libLIBRARIES
+
+
+rfbproto.o: rfbproto.c corre.c hextile.c rre.c tight.c zlib.c
+$(libvncclient_a_OBJECTS): ../rfb/rfbclient.h
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/libvncclient/Makefile.am b/libvncclient/Makefile.am
new file mode 100644
index 0000000..78b5620
--- /dev/null
+++ b/libvncclient/Makefile.am
@@ -0,0 +1,18 @@
+CFLAGS=-g -I.. -I. -Wall
+
+libvncclient_a_SOURCES=cursor.c listen.c rfbproto.c sockets.c vncviewer.c
+
+rfbproto.o: rfbproto.c corre.c hextile.c rre.c tight.c zlib.c
+
+EXTRA_DIST=corre.c hextile.c rre.c tight.c zlib.c
+
+$(libvncclient_a_OBJECTS): ../rfb/rfbclient.h
+
+lib_LIBRARIES=libvncclient.a
+
+client_test_SOURCES=client_test.c
+
+noinst_PROGRAMS=client_test
+
+#client_test_LDADD=libvncclient.a ../libvncserver.a
+client_test_LDADD=libvncclient.a
diff --git a/libvncclient/Makefile.in b/libvncclient/Makefile.in
new file mode 100644
index 0000000..6f563e7
--- /dev/null
+++ b/libvncclient/Makefile.in
@@ -0,0 +1,365 @@
+# Makefile.in generated by automake 1.6.3 from Makefile.am.
+# @configure_input@
+
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = @program_transform_name@
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+
+EXEEXT = @EXEEXT@
+OBJEXT = @OBJEXT@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+AMTAR = @AMTAR@
+AWK = @AWK@
+CC = @CC@
+CCLD = @CCLD@
+CXX = @CXX@
+DEPDIR = @DEPDIR@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+PACKAGE = @PACKAGE@
+RANLIB = @RANLIB@
+RPMSOURCEDIR = @RPMSOURCEDIR@
+STRIP = @STRIP@
+VERSION = @VERSION@
+X_CFLAGS = @X_CFLAGS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_LIBS = @X_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+am__include = @am__include@
+am__quote = @am__quote@
+install_sh = @install_sh@
+CFLAGS = -g -I.. -I. -Wall
+
+libvncclient_a_SOURCES = cursor.c listen.c rfbproto.c sockets.c vncviewer.c
+
+EXTRA_DIST = corre.c hextile.c rre.c tight.c zlib.c
+
+lib_LIBRARIES = libvncclient.a
+
+client_test_SOURCES = client_test.c
+
+noinst_PROGRAMS = client_test
+
+#client_test_LDADD=libvncclient.a ../libvncserver.a
+client_test_LDADD = libvncclient.a
+subdir = libvncclient
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/rfb/rfbconfig.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(lib_LIBRARIES)
+
+libvncclient_a_AR = $(AR) cru
+libvncclient_a_LIBADD =
+am_libvncclient_a_OBJECTS = cursor.$(OBJEXT) listen.$(OBJEXT) \
+ rfbproto.$(OBJEXT) sockets.$(OBJEXT) vncviewer.$(OBJEXT)
+libvncclient_a_OBJECTS = $(am_libvncclient_a_OBJECTS)
+noinst_PROGRAMS = client_test$(EXEEXT)
+PROGRAMS = $(noinst_PROGRAMS)
+
+am_client_test_OBJECTS = client_test.$(OBJEXT)
+client_test_OBJECTS = $(am_client_test_OBJECTS)
+client_test_DEPENDENCIES = libvncclient.a
+client_test_LDFLAGS =
+
+DEFS = @DEFS@
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/rfb
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/client_test.Po ./$(DEPDIR)/cursor.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/listen.Po ./$(DEPDIR)/rfbproto.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/sockets.Po ./$(DEPDIR)/vncviewer.Po
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(libvncclient_a_SOURCES) $(client_test_SOURCES)
+DIST_COMMON = Makefile.am Makefile.in
+SOURCES = $(libvncclient_a_SOURCES) $(client_test_SOURCES)
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .o .obj
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4)
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu libvncclient/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
+
+AR = ar
+libLIBRARIES_INSTALL = $(INSTALL_DATA)
+install-libLIBRARIES: $(lib_LIBRARIES)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(libdir)
+ @list='$(lib_LIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ f="`echo $$p | sed -e 's|^.*/||'`"; \
+ echo " $(libLIBRARIES_INSTALL) $$p $(DESTDIR)$(libdir)/$$f"; \
+ $(libLIBRARIES_INSTALL) $$p $(DESTDIR)$(libdir)/$$f; \
+ else :; fi; \
+ done
+ @$(POST_INSTALL)
+ @list='$(lib_LIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ p="`echo $$p | sed -e 's|^.*/||'`"; \
+ echo " $(RANLIB) $(DESTDIR)$(libdir)/$$p"; \
+ $(RANLIB) $(DESTDIR)$(libdir)/$$p; \
+ else :; fi; \
+ done
+
+uninstall-libLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(lib_LIBRARIES)'; for p in $$list; do \
+ p="`echo $$p | sed -e 's|^.*/||'`"; \
+ echo " rm -f $(DESTDIR)$(libdir)/$$p"; \
+ rm -f $(DESTDIR)$(libdir)/$$p; \
+ done
+
+clean-libLIBRARIES:
+ -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES)
+libvncclient.a: $(libvncclient_a_OBJECTS) $(libvncclient_a_DEPENDENCIES)
+ -rm -f libvncclient.a
+ $(libvncclient_a_AR) libvncclient.a $(libvncclient_a_OBJECTS) $(libvncclient_a_LIBADD)
+ $(RANLIB) libvncclient.a
+
+clean-noinstPROGRAMS:
+ -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
+client_test$(EXEEXT): $(client_test_OBJECTS) $(client_test_DEPENDENCIES)
+ @rm -f client_test$(EXEEXT)
+ $(LINK) $(client_test_LDFLAGS) $(client_test_OBJECTS) $(client_test_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT) core *.core
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/client_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cursor.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/listen.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rfbproto.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sockets.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vncviewer.Po@am__quote@
+
+distclean-depend:
+ -rm -rf ./$(DEPDIR)
+
+.c.o:
+@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
+
+.c.obj:
+@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ $(COMPILE) -c `cygpath -w $<`
+CCDEPMODE = @CCDEPMODE@
+uninstall-info-am:
+
+ETAGS = etags
+ETAGSFLAGS =
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)$$tags$$unique" \
+ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+
+top_distdir = ..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
+
+distdir: $(DISTFILES)
+ @list='$(DISTFILES)'; for file in $$list; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkinstalldirs) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
+ if test -d $$d/$$file; then \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+
+installdirs:
+ $(mkinstalldirs) $(DESTDIR)$(libdir)
+
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libLIBRARIES clean-noinstPROGRAMS \
+ mostlyclean-am
+
+distclean: distclean-am
+
+distclean-am: clean-am distclean-compile distclean-depend \
+ distclean-generic distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am: install-libLIBRARIES
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+uninstall-am: uninstall-info-am uninstall-libLIBRARIES
+
+.PHONY: GTAGS all all-am check check-am clean clean-generic \
+ clean-libLIBRARIES clean-noinstPROGRAMS distclean \
+ distclean-compile distclean-depend distclean-generic \
+ distclean-tags distdir dvi dvi-am info info-am install \
+ install-am install-data install-data-am install-exec \
+ install-exec-am install-info install-info-am \
+ install-libLIBRARIES install-man install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic tags uninstall uninstall-am \
+ uninstall-info-am uninstall-libLIBRARIES
+
+
+rfbproto.o: rfbproto.c corre.c hextile.c rre.c tight.c zlib.c
+
+$(libvncclient_a_OBJECTS): ../rfb/rfbclient.h
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/libvncclient/client_test.c b/libvncclient/client_test.c
new file mode 100644
index 0000000..94f6f58
--- /dev/null
+++ b/libvncclient/client_test.c
@@ -0,0 +1,98 @@
+/* A simple example of an RFB client */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <rfb/rfbclient.h>
+
+void PrintRect(rfbClient* client, int x, int y, int w, int h) {
+ rfbClientLog("Received an update for %d,%d,%d,%d.\n",x,y,w,h);
+}
+
+void SaveFramebufferAsPGM(rfbClient* client, int x, int y, int w, int h) {
+ static time_t t=0,t1;
+ FILE* f;
+ int i,j;
+ int bpp=client->format.bitsPerPixel/8;
+ int row_stride=client->width*bpp;
+
+ /* save one picture only if the last is older than 2 seconds */
+ t1=time(0);
+ if(t1-t>2)
+ t=t1;
+ else
+ return;
+
+ /* assert bpp=4 */
+ if(bpp!=4) {
+ rfbClientLog("bpp = %d (!=4)\n",bpp);
+ return;
+ }
+
+ f=fopen("/tmp/framebuffer.ppm","wb");
+
+ fprintf(f,"P6\n# %s\n%d %d\n255\n",client->desktopName,client->width,client->height);
+ for(j=0;j<client->height*row_stride;j+=row_stride)
+ for(i=0;i<client->width*bpp;i+=bpp) {
+ if(client->format.bigEndian) {
+ fputc(client->frameBuffer[j+i+bpp-1],f);
+ fputc(client->frameBuffer[j+i+bpp-2],f);
+ fputc(client->frameBuffer[j+i+bpp-3],f);
+ } else {
+ fputc(client->frameBuffer[j+i+bpp+0],f);
+ fputc(client->frameBuffer[j+i+bpp+1],f);
+ fputc(client->frameBuffer[j+i+bpp+2],f);
+ }
+ }
+ fclose(f);
+}
+
+int
+main(int argc, char **argv)
+{
+ int i;
+ rfbClient* client = rfbGetClient(&argc,argv,8,3,4);
+ const char* vncServerHost="";
+ int vncServerPort=5900;
+
+ client->GotFrameBufferUpdate = PrintRect;
+ client->GotFrameBufferUpdate = SaveFramebufferAsPGM;
+
+ /* The -listen option is used to make us a daemon process which listens for
+ incoming connections from servers, rather than actively connecting to a
+ given server. The -tunnel and -via options are useful to create
+ connections tunneled via SSH port forwarding. We must test for the
+ -listen option before invoking any Xt functions - this is because we use
+ forking, and Xt doesn't seem to cope with forking very well. For -listen
+ option, when a successful incoming connection has been accepted,
+ listenForIncomingConnections() returns, setting the listenSpecified
+ flag. */
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-listen") == 0) {
+ listenForIncomingConnections(client);
+ break;
+ } else {
+ char* colon=strchr(argv[i],':');
+
+ vncServerHost=argv[i];
+ if(colon) {
+ *colon=0;
+ vncServerPort=atoi(colon+1);
+ } else
+ vncServerPort=0;
+ vncServerPort+=5900;
+ }
+ }
+
+ client->appData.encodingsString="tight";
+ rfbInitClient(client,vncServerHost,vncServerPort);
+
+ while (1) {
+ if (!HandleRFBServerMessage(client))
+ break;
+ }
+
+ return 0;
+}
+
diff --git a/libvncclient/corre.c b/libvncclient/corre.c
index d6d3d0d..d7f2fe6 100644
--- a/libvncclient/corre.c
+++ b/libvncclient/corre.c
@@ -41,7 +41,7 @@ HandleCoRREBPP (rfbClient* client, int rx, int ry, int rw, int rh)
if (!ReadFromRFBServer(client, (char *)&hdr, sz_rfbRREHeader))
return FALSE;
- hdr.nSubrects = Swap32IfLE(hdr.nSubrects);
+ hdr.nSubrects = rfbClientSwap32IfLE(hdr.nSubrects);
if (!ReadFromRFBServer(client, (char *)&pix, sizeof(pix)))
return FALSE;
diff --git a/libvncclient/listen.c b/libvncclient/listen.c
index c11aef7..2461dcf 100644
--- a/libvncclient/listen.c
+++ b/libvncclient/listen.c
@@ -45,9 +45,9 @@ listenForIncomingConnections(rfbClient* client)
if ((listenSocket < 0)) exit(1);
- fprintf(stderr,"%s -listen: Listening on port %d\n",
+ rfbClientLog("%s -listen: Listening on port %d\n",
client->programName,client->listenPort);
- fprintf(stderr,"%s -listen: Command line errors are not reported until "
+ rfbClientLog("%s -listen: Command line errors are not reported until "
"a connection comes in.\n", client->programName);
while (TRUE) {
diff --git a/libvncclient/rfbproto.c b/libvncclient/rfbproto.c
index e654fcc..389aa05 100644
--- a/libvncclient/rfbproto.c
+++ b/libvncclient/rfbproto.c
@@ -33,6 +33,36 @@
#ifdef HAVE_LIBJPEG
#include <jpeglib.h>
#endif
+#include <stdarg.h>
+#include <time.h>
+
+/*
+ * rfbClientLog prints a time-stamped message to the log file (stderr).
+ */
+
+Bool rfbEnableClientLogging=TRUE;
+
+void
+rfbClientLog(const char *format, ...)
+{
+ va_list args;
+ char buf[256];
+ time_t log_clock;
+
+ if(!rfbEnableClientLogging)
+ return;
+
+ va_start(args, format);
+
+ time(&log_clock);
+ strftime(buf, 255, "%d/%m/%Y %X ", localtime(&log_clock));
+ fprintf(stderr,buf);
+
+ vfprintf(stderr, format, args);
+ fflush(stderr);
+
+ va_end(args);
+}
void FillRectangle(rfbClient* client, int x, int y, int w, int h, uint32_t colour) {
int i,j;
@@ -47,7 +77,7 @@ void FillRectangle(rfbClient* client, int x, int y, int w, int h, uint32_t colou
case 16: FILL_RECT(16); break;
case 32: FILL_RECT(32); break;
default:
- fprintf(stderr,"Unsupported bitsPerPixel: %d\n",client->format.bitsPerPixel);
+ rfbClientLog("Unsupported bitsPerPixel: %d\n",client->format.bitsPerPixel);
}
}
@@ -68,7 +98,7 @@ void CopyRectangle(rfbClient* client, uint8_t* buffer, int x, int y, int w, int
case 16: COPY_RECT(16); break;
case 32: COPY_RECT(32); break;
default:
- fprintf(stderr,"Unsupported bitsPerPixel: %d\n",client->format.bitsPerPixel);
+ rfbClientLog("Unsupported bitsPerPixel: %d\n",client->format.bitsPerPixel);
}
}
@@ -90,7 +120,7 @@ void CopyRectangleFromRectangle(rfbClient* client, int src_x, int src_y, int w,
case 16: COPY_RECT_FROM_RECT(16); break;
case 32: COPY_RECT_FROM_RECT(32); break;
default:
- fprintf(stderr,"Unsupported bitsPerPixel: %d\n",client->format.bitsPerPixel);
+ rfbClientLog("Unsupported bitsPerPixel: %d\n",client->format.bitsPerPixel);
}
}
@@ -137,7 +167,9 @@ static Bool decompStreamInited = FALSE;
*/
/* Separate buffer for compressed data. */
-#define ZLIB_BUFFER_SIZE 512
+// TODO:
+// #define ZLIB_BUFFER_SIZE 512
+#define ZLIB_BUFFER_SIZE 30000
static char zlib_buffer[ZLIB_BUFFER_SIZE];
/* Four independent compression streams for zlib library. */
@@ -166,14 +198,14 @@ ConnectToRFBServer(rfbClient* client,const char *hostname, int port)
unsigned int host;
if (!StringToIPAddr(hostname, &host)) {
- fprintf(stderr,"Couldn't convert '%s' to host address\n", hostname);
+ rfbClientLog("Couldn't convert '%s' to host address\n", hostname);
return FALSE;
}
- client->sock = ConnectToTcpAddr(host, port);
+ client->sock = ConnectClientToTcpAddr(host, port);
if (client->sock < 0) {
- fprintf(stderr,"Unable to connect to VNC server\n");
+ rfbClientLog("Unable to connect to VNC server\n");
return FALSE;
}
@@ -211,11 +243,11 @@ InitialiseRFBConnection(rfbClient* client)
pv[sz_rfbProtocolVersionMsg] = 0;
if (sscanf(pv,rfbProtocolVersionFormat,&major,&minor) != 2) {
- fprintf(stderr,"Not a valid VNC server\n");
+ rfbClientLog("Not a valid VNC server\n");
return FALSE;
}
- fprintf(stderr,"VNC server supports protocol version %d.%d (viewer %d.%d)\n",
+ rfbClientLog("VNC server supports protocol version %d.%d (viewer %d.%d)\n",
major, minor, rfbProtocolMajorVersion, rfbProtocolMinorVersion);
major = rfbProtocolMajorVersion;
@@ -223,27 +255,27 @@ InitialiseRFBConnection(rfbClient* client)
sprintf(pv,rfbProtocolVersionFormat,major,minor);
- if (!WriteExact(client, pv, sz_rfbProtocolVersionMsg)) return FALSE;
+ if (!WriteToRFBServer(client, pv, sz_rfbProtocolVersionMsg)) return FALSE;
if (!ReadFromRFBServer(client, (char *)&authScheme, 4)) return FALSE;
- authScheme = Swap32IfLE(authScheme);
+ authScheme = rfbClientSwap32IfLE(authScheme);
switch (authScheme) {
case rfbConnFailed:
if (!ReadFromRFBServer(client, (char *)&reasonLen, 4)) return FALSE;
- reasonLen = Swap32IfLE(reasonLen);
+ reasonLen = rfbClientSwap32IfLE(reasonLen);
reason = malloc(reasonLen);
if (!ReadFromRFBServer(client, reason, reasonLen)) return FALSE;
- fprintf(stderr,"VNC connection failed: %.*s\n",(int)reasonLen, reason);
+ rfbClientLog("VNC connection failed: %.*s\n",(int)reasonLen, reason);
return FALSE;
case rfbNoAuth:
- fprintf(stderr,"No authentication needed\n");
+ rfbClientLog("No authentication needed\n");
break;
case rfbVncAuth:
@@ -253,7 +285,7 @@ InitialiseRFBConnection(rfbClient* client)
passwd = client->GetPassword(client);
if ((!passwd) || (strlen(passwd) == 0)) {
- fprintf(stderr,"Reading password failed\n");
+ rfbClientLog("Reading password failed\n");
return FALSE;
}
if (strlen(passwd) > 8) {
@@ -267,51 +299,51 @@ InitialiseRFBConnection(rfbClient* client)
passwd[i] = '\0';
}
- if (!WriteExact(client, (char *)challenge, CHALLENGESIZE)) return FALSE;
+ if (!WriteToRFBServer(client, (char *)challenge, CHALLENGESIZE)) return FALSE;
if (!ReadFromRFBServer(client, (char *)&authResult, 4)) return FALSE;
- authResult = Swap32IfLE(authResult);
+ authResult = rfbClientSwap32IfLE(authResult);
switch (authResult) {
case rfbVncAuthOK:
- fprintf(stderr,"VNC authentication succeeded\n");
+ rfbClientLog("VNC authentication succeeded\n");
break;
case rfbVncAuthFailed:
- fprintf(stderr,"VNC authentication failed\n");
+ rfbClientLog("VNC authentication failed\n");
return FALSE;
case rfbVncAuthTooMany:
- fprintf(stderr,"VNC authentication failed - too many tries\n");
+ rfbClientLog("VNC authentication failed - too many tries\n");
return FALSE;
default:
- fprintf(stderr,"Unknown VNC authentication result: %d\n",
+ rfbClientLog("Unknown VNC authentication result: %d\n",
(int)authResult);
return FALSE;
}
break;
default:
- fprintf(stderr,"Unknown authentication scheme from VNC server: %d\n",
+ rfbClientLog("Unknown authentication scheme from VNC server: %d\n",
(int)authScheme);
return FALSE;
}
ci.shared = (client->appData.shareDesktop ? 1 : 0);
- if (!WriteExact(client, (char *)&ci, sz_rfbClientInitMsg)) return FALSE;
+ if (!WriteToRFBServer(client, (char *)&ci, sz_rfbClientInitMsg)) return FALSE;
if (!ReadFromRFBServer(client, (char *)&client->si, sz_rfbServerInitMsg)) return FALSE;
- client->si.framebufferWidth = Swap16IfLE(client->si.framebufferWidth);
- client->si.framebufferHeight = Swap16IfLE(client->si.framebufferHeight);
- client->si.format.redMax = Swap16IfLE(client->si.format.redMax);
- client->si.format.greenMax = Swap16IfLE(client->si.format.greenMax);
- client->si.format.blueMax = Swap16IfLE(client->si.format.blueMax);
- client->si.nameLength = Swap32IfLE(client->si.nameLength);
+ client->si.framebufferWidth = rfbClientSwap16IfLE(client->si.framebufferWidth);
+ client->si.framebufferHeight = rfbClientSwap16IfLE(client->si.framebufferHeight);
+ client->si.format.redMax = rfbClientSwap16IfLE(client->si.format.redMax);
+ client->si.format.greenMax = rfbClientSwap16IfLE(client->si.format.greenMax);
+ client->si.format.blueMax = rfbClientSwap16IfLE(client->si.format.blueMax);
+ client->si.nameLength = rfbClientSwap32IfLE(client->si.nameLength);
client->desktopName = malloc(client->si.nameLength + 1);
if (!client->desktopName) {
- fprintf(stderr, "Error allocating memory for desktop name, %lu bytes\n",
+ rfbClientLog("Error allocating memory for desktop name, %lu bytes\n",
(unsigned long)client->si.nameLength);
return FALSE;
}
@@ -320,12 +352,12 @@ InitialiseRFBConnection(rfbClient* client)
client->desktopName[client->si.nameLength] = 0;
- fprintf(stderr,"Desktop name \"%s\"\n",client->desktopName);
+ rfbClientLog("Desktop name \"%s\"\n",client->desktopName);
- fprintf(stderr,"Connected to VNC server, using protocol version %d.%d\n",
+ rfbClientLog("Connected to VNC server, using protocol version %d.%d\n",
rfbProtocolMajorVersion, rfbProtocolMinorVersion);
- fprintf(stderr,"VNC server default format:\n");
+ rfbClientLog("VNC server default format:\n");
PrintPixelFormat(&client->si.format);
return TRUE;
@@ -350,11 +382,11 @@ SetFormatAndEncodings(rfbClient* client)
spf.type = rfbSetPixelFormat;
spf.format = client->format;
- spf.format.redMax = Swap16IfLE(spf.format.redMax);
- spf.format.greenMax = Swap16IfLE(spf.format.greenMax);
- spf.format.blueMax = Swap16IfLE(spf.format.blueMax);
+ spf.format.redMax = rfbClientSwap16IfLE(spf.format.redMax);
+ spf.format.greenMax = rfbClientSwap16IfLE(spf.format.greenMax);
+ spf.format.blueMax = rfbClientSwap16IfLE(spf.format.blueMax);
- if (!WriteExact(client, (char *)&spf, sz_rfbSetPixelFormatMsg))
+ if (!WriteToRFBServer(client, (char *)&spf, sz_rfbSetPixelFormatMsg))
return FALSE;
se->type = rfbSetEncodings;
@@ -373,56 +405,56 @@ SetFormatAndEncodings(rfbClient* client)
}
if (strncasecmp(encStr,"raw",encStrLen) == 0) {
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingRaw);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRaw);
} else if (strncasecmp(encStr,"copyrect",encStrLen) == 0) {
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingCopyRect);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCopyRect);
} else if (strncasecmp(encStr,"tight",encStrLen) == 0) {
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingTight);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingTight);
requestLastRectEncoding = TRUE;
if (client->appData.compressLevel >= 0 && client->appData.compressLevel <= 9)
requestCompressLevel = TRUE;
if (client->appData.enableJPEG)
requestQualityLevel = TRUE;
} else if (strncasecmp(encStr,"hextile",encStrLen) == 0) {
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingHextile);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingHextile);
} else if (strncasecmp(encStr,"zlib",encStrLen) == 0) {
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingZlib);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZlib);
if (client->appData.compressLevel >= 0 && client->appData.compressLevel <= 9)
requestCompressLevel = TRUE;
} else if (strncasecmp(encStr,"corre",encStrLen) == 0) {
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingCoRRE);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCoRRE);
} else if (strncasecmp(encStr,"rre",encStrLen) == 0) {
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingRRE);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRRE);
} else {
- fprintf(stderr,"Unknown encoding '%.*s'\n",encStrLen,encStr);
+ rfbClientLog("Unknown encoding '%.*s'\n",encStrLen,encStr);
}
encStr = nextEncStr;
} while (encStr && se->nEncodings < MAX_ENCODINGS);
if (se->nEncodings < MAX_ENCODINGS && requestCompressLevel) {
- encs[se->nEncodings++] = Swap32IfLE(client->appData.compressLevel +
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(client->appData.compressLevel +
rfbEncodingCompressLevel0);
}
if (se->nEncodings < MAX_ENCODINGS && requestQualityLevel) {
if (client->appData.qualityLevel < 0 || client->appData.qualityLevel > 9)
client->appData.qualityLevel = 5;
- encs[se->nEncodings++] = Swap32IfLE(client->appData.qualityLevel +
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(client->appData.qualityLevel +
rfbEncodingQualityLevel0);
}
if (client->appData.useRemoteCursor) {
if (se->nEncodings < MAX_ENCODINGS)
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingXCursor);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingXCursor);
if (se->nEncodings < MAX_ENCODINGS)
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingRichCursor);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRichCursor);
if (se->nEncodings < MAX_ENCODINGS)
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingPointerPos);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingPointerPos);
}
if (se->nEncodings < MAX_ENCODINGS && requestLastRectEncoding) {
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingLastRect);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingLastRect);
}
}
else {
@@ -430,55 +462,54 @@ SetFormatAndEncodings(rfbClient* client)
/* TODO:
if (!tunnelSpecified) {
*/
- fprintf(stderr,"Same machine: preferring raw encoding\n");
- /* TODO: */
- //encs[se->nEncodings++] = Swap32IfLE(rfbEncodingRaw);
+ rfbClientLog("Same machine: preferring raw encoding\n");
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRaw);
/*
} else {
- fprintf(stderr,"Tunneling active: preferring tight encoding\n");
+ rfbClientLog("Tunneling active: preferring tight encoding\n");
}
*/
}
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingCopyRect);
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingTight);
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingHextile);
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingZlib);
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingCoRRE);
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingRRE);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCopyRect);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingTight);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingHextile);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZlib);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCoRRE);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRRE);
if (client->appData.compressLevel >= 0 && client->appData.compressLevel <= 9) {
- encs[se->nEncodings++] = Swap32IfLE(client->appData.compressLevel +
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(client->appData.compressLevel +
rfbEncodingCompressLevel0);
} else /* if (!tunnelSpecified) */ {
/* If -tunnel option was provided, we assume that server machine is
not in the local network so we use default compression level for
tight encoding instead of fast compression. Thus we are
requesting level 1 compression only if tunneling is not used. */
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingCompressLevel1);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCompressLevel1);
}
if (client->appData.enableJPEG) {
if (client->appData.qualityLevel < 0 || client->appData.qualityLevel > 9)
client->appData.qualityLevel = 5;
- encs[se->nEncodings++] = Swap32IfLE(client->appData.qualityLevel +
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(client->appData.qualityLevel +
rfbEncodingQualityLevel0);
}
if (client->appData.useRemoteCursor) {
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingXCursor);
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingRichCursor);
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingPointerPos);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingXCursor);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRichCursor);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingPointerPos);
}
- encs[se->nEncodings++] = Swap32IfLE(rfbEncodingLastRect);
+ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingLastRect);
}
len = sz_rfbSetEncodingsMsg + se->nEncodings * 4;
- se->nEncodings = Swap16IfLE(se->nEncodings);
+ se->nEncodings = rfbClientSwap16IfLE(se->nEncodings);
- if (!WriteExact(client, buf, len)) return FALSE;
+ if (!WriteToRFBServer(client, buf, len)) return FALSE;
return TRUE;
}
@@ -507,12 +538,12 @@ SendFramebufferUpdateRequest(rfbClient* client, int x, int y, int w, int h, Bool
fur.type = rfbFramebufferUpdateRequest;
fur.incremental = incremental ? 1 : 0;
- fur.x = Swap16IfLE(x);
- fur.y = Swap16IfLE(y);
- fur.w = Swap16IfLE(w);
- fur.h = Swap16IfLE(h);
+ fur.x = rfbClientSwap16IfLE(x);
+ fur.y = rfbClientSwap16IfLE(y);
+ fur.w = rfbClientSwap16IfLE(w);
+ fur.h = rfbClientSwap16IfLE(h);
- if (!WriteExact(client, (char *)&fur, sz_rfbFramebufferUpdateRequestMsg))
+ if (!WriteToRFBServer(client, (char *)&fur, sz_rfbFramebufferUpdateRequestMsg))
return FALSE;
return TRUE;
@@ -533,9 +564,9 @@ SendPointerEvent(rfbClient* client,int x, int y, int buttonMask)
if (x < 0) x = 0;
if (y < 0) y = 0;
- pe.x = Swap16IfLE(x);
- pe.y = Swap16IfLE(y);
- return WriteExact(client, (char *)&pe, sz_rfbPointerEventMsg);
+ pe.x = rfbClientSwap16IfLE(x);
+ pe.y = rfbClientSwap16IfLE(y);
+ return WriteToRFBServer(client, (char *)&pe, sz_rfbPointerEventMsg);
}
@@ -550,8 +581,8 @@ SendKeyEvent(rfbClient* client, uint32_t key, Bool down)
ke.type = rfbKeyEvent;
ke.down = down ? 1 : 0;
- ke.key = Swap32IfLE(key);
- return WriteExact(client, (char *)&ke, sz_rfbKeyEventMsg);
+ ke.key = rfbClientSwap32IfLE(key);
+ return WriteToRFBServer(client, (char *)&ke, sz_rfbKeyEventMsg);
}
@@ -569,9 +600,9 @@ SendClientCutText(rfbClient* client, char *str, int len)
client->serverCutText = NULL;
cct.type = rfbClientCutText;
- cct.length = Swap32IfLE(len);
- return (WriteExact(client, (char *)&cct, sz_rfbClientCutTextMsg) &&
- WriteExact(client, str, len));
+ cct.length = rfbClientSwap32IfLE(len);
+ return (WriteToRFBServer(client, (char *)&cct, sz_rfbClientCutTextMsg) &&
+ WriteToRFBServer(client, str, len));
}
@@ -601,16 +632,16 @@ HandleRFBServerMessage(rfbClient* client)
sz_rfbSetColourMapEntriesMsg - 1))
return FALSE;
- msg.scme.firstColour = Swap16IfLE(msg.scme.firstColour);
- msg.scme.nColours = Swap16IfLE(msg.scme.nColours);
+ msg.scme.firstColour = rfbClientSwap16IfLE(msg.scme.firstColour);
+ msg.scme.nColours = rfbClientSwap16IfLE(msg.scme.nColours);
for (i = 0; i < msg.scme.nColours; i++) {
if (!ReadFromRFBServer(client, (char *)rgb, 6))
return FALSE;
xc.pixel = msg.scme.firstColour + i;
- xc.red = Swap16IfLE(rgb[0]);
- xc.green = Swap16IfLE(rgb[1]);
- xc.blue = Swap16IfLE(rgb[2]);
+ xc.red = rfbClientSwap16IfLE(rgb[0]);
+ xc.green = rfbClientSwap16IfLE(rgb[1]);
+ xc.blue = rfbClientSwap16IfLE(rgb[2]);
xc.flags = DoRed|DoGreen|DoBlue;
XStoreColor(dpy, cmap, &xc);
}
@@ -630,20 +661,20 @@ HandleRFBServerMessage(rfbClient* client)
sz_rfbFramebufferUpdateMsg - 1))
return FALSE;
- msg.fu.nRects = Swap16IfLE(msg.fu.nRects);
+ msg.fu.nRects = rfbClientSwap16IfLE(msg.fu.nRects);
for (i = 0; i < msg.fu.nRects; i++) {
if (!ReadFromRFBServer(client, (char *)&rect, sz_rfbFramebufferUpdateRectHeader))
return FALSE;
- rect.encoding = Swap32IfLE(rect.encoding);
+ rect.encoding = rfbClientSwap32IfLE(rect.encoding);
if (rect.encoding == rfbEncodingLastRect)
break;
- rect.r.x = Swap16IfLE(rect.r.x);
- rect.r.y = Swap16IfLE(rect.r.y);
- rect.r.w = Swap16IfLE(rect.r.w);
- rect.r.h = Swap16IfLE(rect.r.h);
+ rect.r.x = rfbClientSwap16IfLE(rect.r.x);
+ rect.r.y = rfbClientSwap16IfLE(rect.r.y);
+ rect.r.w = rfbClientSwap16IfLE(rect.r.w);
+ rect.r.h = rfbClientSwap16IfLE(rect.r.h);
if (rect.encoding == rfbEncodingXCursor ||
rect.encoding == rfbEncodingRichCursor) {
@@ -665,13 +696,13 @@ HandleRFBServerMessage(rfbClient* client)
if ((rect.r.x + rect.r.w > client->si.framebufferWidth) ||
(rect.r.y + rect.r.h > client->si.framebufferHeight))
{
- fprintf(stderr,"Rect too large: %dx%d at (%d, %d)\n",
+ rfbClientLog("Rect too large: %dx%d at (%d, %d)\n",
rect.r.w, rect.r.h, rect.r.x, rect.r.y);
return FALSE;
}
if (rect.r.h * rect.r.w == 0) {
- fprintf(stderr,"Zero size rect - ignoring\n");
+ rfbClientLog("Zero size rect - ignoring\n");
continue;
}
@@ -709,8 +740,8 @@ HandleRFBServerMessage(rfbClient* client)
if (!ReadFromRFBServer(client, (char *)&cr, sz_rfbCopyRect))
return FALSE;
- cr.srcX = Swap16IfLE(cr.srcX);
- cr.srcY = Swap16IfLE(cr.srcY);
+ cr.srcX = rfbClientSwap16IfLE(cr.srcX);
+ cr.srcY = rfbClientSwap16IfLE(cr.srcY);
/* If RichCursor encoding is used, we should extend our
"cursor lock area" (previously set to destination
@@ -821,7 +852,7 @@ HandleRFBServerMessage(rfbClient* client)
}
default:
- fprintf(stderr,"Unknown rect encoding %d\n",
+ rfbClientLog("Unknown rect encoding %d\n",
(int)rect.encoding);
return FALSE;
}
@@ -829,7 +860,7 @@ HandleRFBServerMessage(rfbClient* client)
/* Now we may discard "soft cursor locks". */
client->SoftCursorUnlockScreen(client);
- client->FramebufferUpdateReceived(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h);
+ client->GotFrameBufferUpdate(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h);
}
#ifdef MITSHM
@@ -861,7 +892,7 @@ HandleRFBServerMessage(rfbClient* client)
sz_rfbServerCutTextMsg - 1))
return FALSE;
- msg.sct.length = Swap32IfLE(msg.sct.length);
+ msg.sct.length = rfbClientSwap32IfLE(msg.sct.length);
if (client->serverCutText)
free(client->serverCutText);
@@ -879,7 +910,7 @@ HandleRFBServerMessage(rfbClient* client)
}
default:
- fprintf(stderr,"Unknown message type %d from VNC server\n",msg.type);
+ rfbClientLog("Unknown message type %d from VNC server\n",msg.type);
return FALSE;
}
@@ -937,23 +968,23 @@ PrintPixelFormat(format)
rfbPixelFormat *format;
{
if (format->bitsPerPixel == 1) {
- fprintf(stderr," Single bit per pixel.\n");
- fprintf(stderr,
+ rfbClientLog(" Single bit per pixel.\n");
+ rfbClientLog(
" %s significant bit in each byte is leftmost on the screen.\n",
(format->bigEndian ? "Most" : "Least"));
} else {
- fprintf(stderr," %d bits per pixel.\n",format->bitsPerPixel);
+ rfbClientLog(" %d bits per pixel.\n",format->bitsPerPixel);
if (format->bitsPerPixel != 8) {
- fprintf(stderr," %s significant byte first in each pixel.\n",
+ rfbClientLog(" %s significant byte first in each pixel.\n",
(format->bigEndian ? "Most" : "Least"));
}
if (format->trueColour) {
- fprintf(stderr," TRUE colour: max red %d green %d blue %d",
+ rfbClientLog(" TRUE colour: max red %d green %d blue %d",
format->redMax, format->greenMax, format->blueMax);
- fprintf(stderr,", shift red %d green %d blue %d\n",
+ rfbClientLog(", shift red %d green %d blue %d\n",
format->redShift, format->greenShift, format->blueShift);
} else {
- fprintf(stderr," Colour map (not true colour).\n");
+ rfbClientLog(" Colour map (not true colour).\n");
}
}
}
@@ -1047,6 +1078,10 @@ JpegSetSrcManager(j_decompress_ptr cinfo, uint8_t *compressedData,
#define vncEncryptAndStorePasswd rfbEncryptAndStorePasswdUnused
#define vncDecryptPasswdFromFile rfbDecryptPasswdFromFileUnused
#define vncRandomBytes rfbRandomBytesUnused
+#define des rfbDES
+#define deskey rfbDESKey
+#define usekey rfbUseKey
+#define cpkey rfbCPKey
#include "../vncauth.c"
#include "../d3des.c"
diff --git a/libvncclient/rre.c b/libvncclient/rre.c
index fba3767..a0b75e6 100644
--- a/libvncclient/rre.c
+++ b/libvncclient/rre.c
@@ -40,7 +40,7 @@ HandleRREBPP (rfbClient* client, int rx, int ry, int rw, int rh)
if (!ReadFromRFBServer(client, (char *)&hdr, sz_rfbRREHeader))
return FALSE;
- hdr.nSubrects = Swap32IfLE(hdr.nSubrects);
+ hdr.nSubrects = rfbClientSwap32IfLE(hdr.nSubrects);
if (!ReadFromRFBServer(client, (char *)&pix, sizeof(pix)))
return FALSE;
@@ -54,10 +54,10 @@ HandleRREBPP (rfbClient* client, int rx, int ry, int rw, int rh)
if (!ReadFromRFBServer(client, (char *)&subrect, sz_rfbRectangle))
return FALSE;
- subrect.x = Swap16IfLE(subrect.x);
- subrect.y = Swap16IfLE(subrect.y);
- subrect.w = Swap16IfLE(subrect.w);
- subrect.h = Swap16IfLE(subrect.h);
+ subrect.x = rfbClientSwap16IfLE(subrect.x);
+ subrect.y = rfbClientSwap16IfLE(subrect.y);
+ subrect.w = rfbClientSwap16IfLE(subrect.w);
+ subrect.h = rfbClientSwap16IfLE(subrect.h);
FillRectangle(client, rx+subrect.x, ry+subrect.y, subrect.w, subrect.h, pix);
}
diff --git a/libvncclient/sockets.c b/libvncclient/sockets.c
index 5e6cd69..d631b02 100644
--- a/libvncclient/sockets.c
+++ b/libvncclient/sockets.c
@@ -90,7 +90,7 @@ ReadFromRFBServer(rfbClient* client, char *out, unsigned int n)
}
} else {
if (errorMessageOnReadFailure) {
- fprintf(stderr,"VNC server closed connection\n");
+ rfbClientLog("VNC server closed connection\n");
}
return FALSE;
}
@@ -120,7 +120,7 @@ ReadFromRFBServer(rfbClient* client, char *out, unsigned int n)
}
} else {
if (errorMessageOnReadFailure) {
- fprintf(stderr,"VNC server closed connection\n");
+ rfbClientLog("VNC server closed connection\n");
}
return FALSE;
}
@@ -139,7 +139,7 @@ ReadFromRFBServer(rfbClient* client, char *out, unsigned int n)
*/
Bool
-WriteExact(rfbClient* client, char *buf, int n)
+WriteToRFBServer(rfbClient* client, char *buf, int n)
{
fd_set fds;
int i = 0;
@@ -163,7 +163,7 @@ WriteExact(rfbClient* client, char *buf, int n)
return FALSE;
}
} else {
- fprintf(stderr,"write failed\n");
+ rfbClientLog("write failed\n");
return FALSE;
}
}
@@ -178,7 +178,7 @@ WriteExact(rfbClient* client, char *buf, int n)
*/
int
-ConnectToTcpAddr(unsigned int host, int port)
+ConnectClientToTcpAddr(unsigned int host, int port)
{
int sock;
struct sockaddr_in addr;
@@ -392,32 +392,32 @@ PrintInHex(char *buf, int len)
str[16] = 0;
- fprintf(stderr,"ReadExact: ");
+ rfbClientLog("ReadExact: ");
for (i = 0; i < len; i++)
{
if ((i % 16 == 0) && (i != 0)) {
- fprintf(stderr," ");
+ rfbClientLog(" ");
}
c = buf[i];
str[i % 16] = (((c > 31) && (c < 127)) ? c : '.');
- fprintf(stderr,"%02x ",(unsigned char)c);
+ rfbClientLog("%02x ",(unsigned char)c);
if ((i % 4) == 3)
- fprintf(stderr," ");
+ rfbClientLog(" ");
if ((i % 16) == 15)
{
- fprintf(stderr,"%s\n",str);
+ rfbClientLog("%s\n",str);
}
}
if ((i % 16) != 0)
{
for (j = i % 16; j < 16; j++)
{
- fprintf(stderr," ");
- if ((j % 4) == 3) fprintf(stderr," ");
+ rfbClientLog(" ");
+ if ((j % 4) == 3) rfbClientLog(" ");
}
str[i % 16] = 0;
- fprintf(stderr,"%s\n",str);
+ rfbClientLog("%s\n",str);
}
fflush(stderr);
diff --git a/libvncclient/tight.c b/libvncclient/tight.c
index c858392..1fadd4c 100644
--- a/libvncclient/tight.c
+++ b/libvncclient/tight.c
@@ -105,7 +105,7 @@ HandleTightBPP (rfbClient* client, int rx, int ry, int rw, int rh)
if ((comp_ctl & 1) && zlibStreamActive[stream_id]) {
if (inflateEnd (&zlibStream[stream_id]) != Z_OK &&
zlibStream[stream_id].msg != NULL)
- fprintf(stderr, "inflateEnd: %s\n", zlibStream[stream_id].msg);
+ rfbClientLog("inflateEnd: %s\n", zlibStream[stream_id].msg);
zlibStreamActive[stream_id] = FALSE;
}
comp_ctl >>= 1;
@@ -135,7 +135,7 @@ HandleTightBPP (rfbClient* client, int rx, int ry, int rw, int rh)
#if BPP == 8
if (comp_ctl == rfbTightJpeg) {
- fprintf(stderr, "Tight encoding: JPEG is not supported in 8 bpp mode.\n");
+ rfbClientLog("Tight encoding: JPEG is not supported in 8 bpp mode.\n");
return FALSE;
}
#else
@@ -146,7 +146,7 @@ HandleTightBPP (rfbClient* client, int rx, int ry, int rw, int rh)
/* Quit on unsupported subencoding value. */
if (comp_ctl > rfbTightMaxSubencoding) {
- fprintf(stderr, "Tight encoding: bad subencoding value received.\n");
+ rfbClientLog("Tight encoding: bad subencoding value received.\n");
return FALSE;
}
@@ -174,7 +174,7 @@ HandleTightBPP (rfbClient* client, int rx, int ry, int rw, int rh)
bitsPixel = InitFilterGradientBPP(client, rw, rh);
break;
default:
- fprintf(stderr, "Tight encoding: unknown filter code received.\n");
+ rfbClientLog("Tight encoding: unknown filter code received.\n");
return FALSE;
}
} else {
@@ -182,7 +182,7 @@ HandleTightBPP (rfbClient* client, int rx, int ry, int rw, int rh)
bitsPixel = InitFilterCopyBPP(client, rw, rh);
}
if (bitsPixel == 0) {
- fprintf(stderr, "Tight encoding: error receiving palette.\n");
+ rfbClientLog("Tight encoding: error receiving palette.\n");
return FALSE;
}
@@ -203,7 +203,7 @@ HandleTightBPP (rfbClient* client, int rx, int ry, int rw, int rh)
/* Read the length (1..3 bytes) of compressed data following. */
compressedLen = (int)ReadCompactLen(client);
if (compressedLen <= 0) {
- fprintf(stderr, "Incorrect data received from the server.\n");
+ rfbClientLog("Incorrect data received from the server.\n");
return FALSE;
}
@@ -217,7 +217,7 @@ HandleTightBPP (rfbClient* client, int rx, int ry, int rw, int rh)
err = inflateInit(zs);
if (err != Z_OK) {
if (zs->msg != NULL)
- fprintf(stderr, "InflateInit error: %s.\n", zs->msg);
+ rfbClientLog("InflateInit error: %s.\n", zs->msg);
return FALSE;
}
zlibStreamActive[stream_id] = TRUE;
@@ -229,7 +229,7 @@ HandleTightBPP (rfbClient* client, int rx, int ry, int rw, int rh)
buffer2 = &client->buffer[bufferSize];
if (rowSize > bufferSize) {
/* Should be impossible when BUFFER_SIZE >= 16384 */
- fprintf(stderr, "Internal error: incorrect buffer size.\n");
+ rfbClientLog("Internal error: incorrect buffer size.\n");
return FALSE;
}
@@ -259,9 +259,9 @@ HandleTightBPP (rfbClient* client, int rx, int ry, int rw, int rh)
break;
if (err != Z_OK && err != Z_STREAM_END) {
if (zs->msg != NULL) {
- fprintf(stderr, "Inflate error: %s.\n", zs->msg);
+ rfbClientLog("Inflate error: %s.\n", zs->msg);
} else {
- fprintf(stderr, "Inflate error: %d.\n", err);
+ rfbClientLog("Inflate error: %d.\n", err);
}
return FALSE;
}
@@ -282,7 +282,7 @@ HandleTightBPP (rfbClient* client, int rx, int ry, int rw, int rh)
}
if (rowsProcessed != rh) {
- fprintf(stderr, "Incorrect number of scan lines after decompression.\n");
+ rfbClientLog("Incorrect number of scan lines after decompression.\n");
return FALSE;
}
@@ -545,13 +545,13 @@ DecompressJpegRectBPP(rfbClient* client, int x, int y, int w, int h)
compressedLen = (int)ReadCompactLen(client);
if (compressedLen <= 0) {
- fprintf(stderr, "Incorrect data received from the server.\n");
+ rfbClientLog("Incorrect data received from the server.\n");
return FALSE;
}
compressedData = malloc(compressedLen);
if (compressedData == NULL) {
- fprintf(stderr, "Memory allocation error.\n");
+ rfbClientLog("Memory allocation error.\n");
return FALSE;
}
@@ -571,7 +571,7 @@ DecompressJpegRectBPP(rfbClient* client, int x, int y, int w, int h)
jpeg_start_decompress(&cinfo);
if (cinfo.output_width != w || cinfo.output_height != h ||
cinfo.output_components != 3) {
- fprintf(stderr, "Tight Encoding: Wrong JPEG data received.\n");
+ rfbClientLog("Tight Encoding: Wrong JPEG data received.\n");
jpeg_destroy_decompress(&cinfo);
free(compressedData);
return FALSE;
diff --git a/libvncclient/vncviewer.c b/libvncclient/vncviewer.c
index 3c9c13c..c5f7c69 100644
--- a/libvncclient/vncviewer.c
+++ b/libvncclient/vncviewer.c
@@ -86,7 +86,7 @@ rfbClient* rfbGetClient(int* argc,char** argv,
client->HandleCursorPos = DummyPoint;
client->SoftCursorLockArea = DummyRect;
client->SoftCursorUnlockScreen = Dummy;
- client->FramebufferUpdateReceived = DummyRect;
+ client->GotFrameBufferUpdate = DummyRect;
client->GetPassword = NoPassword;
client->MallocFrameBuffer = MallocFrameBuffer;
client->Bell = Dummy;
@@ -94,147 +94,30 @@ rfbClient* rfbGetClient(int* argc,char** argv,
return client;
}
-void PrintRect(rfbClient* client, int x, int y, int w, int h) {
- fprintf(stderr,"Received an update for %d,%d,%d,%d.\n",x,y,w,h);
-}
-
-void SaveFramebufferAsPGM(rfbClient* client, int x, int y, int w, int h) {
- static time_t t=0,t1;
- FILE* f;
- int i,j;
- int bpp=client->format.bitsPerPixel/8;
- int row_stride=client->width*bpp;
-
- /* save one picture only if the last is older than 2 seconds */
- t1=time(0);
- if(t1-t>2)
- t=t1;
- else
- return;
-
- /* assert bpp=4 */
- if(bpp!=4) {
- fprintf(stderr,"bpp = %d (!=4)\n",bpp);
- return;
- }
-
- f=fopen("/tmp/framebuffer.ppm","wb");
-
- fprintf(f,"P6\n# %s\n%d %d\n255\n",client->desktopName,client->width,client->height);
- for(j=0;j<client->height*row_stride;j+=row_stride)
- for(i=0;i<client->width*bpp;i+=bpp) {
- if(client->format.bigEndian) {
- fputc(client->frameBuffer[j+i+bpp-1],f);
- fputc(client->frameBuffer[j+i+bpp-2],f);
- fputc(client->frameBuffer[j+i+bpp-3],f);
- } else {
- fputc(client->frameBuffer[j+i+bpp+0],f);
- fputc(client->frameBuffer[j+i+bpp+1],f);
- fputc(client->frameBuffer[j+i+bpp+2],f);
- }
- }
- fclose(f);
-}
-
-void
-vncEncryptBytes(unsigned char *bytes, char *passwd);
-
-int
-main(int argc, char **argv)
+Bool rfbInitClient(rfbClient* client,const char* vncServerHost,int vncServerPort)
{
- int i;
- rfbClient* client = rfbGetClient(&argc,argv,8,3,4);
- const char* vncServerHost="";
- int vncServerPort=5900;
-
- char buf1[]="pass",buf2[]="pass";
- vncEncryptBytes(buf1,buf2);
-
- client->FramebufferUpdateReceived = PrintRect;
- client->FramebufferUpdateReceived = SaveFramebufferAsPGM;
-
- /* The -listen option is used to make us a daemon process which listens for
- incoming connections from servers, rather than actively connecting to a
- given server. The -tunnel and -via options are useful to create
- connections tunneled via SSH port forwarding. We must test for the
- -listen option before invoking any Xt functions - this is because we use
- forking, and Xt doesn't seem to cope with forking very well. For -listen
- option, when a successful incoming connection has been accepted,
- listenForIncomingConnections() returns, setting the listenSpecified
- flag. */
-
- for (i = 1; i < argc; i++) {
- if (strcmp(argv[i], "-listen") == 0) {
- listenForIncomingConnections(client);
- break;
- } else {
- char* colon=strchr(argv[i],':');
-
- vncServerHost=argv[i];
- if(colon) {
- *colon=0;
- vncServerPort=atoi(colon+1);
- } else
- vncServerPort=0;
- vncServerPort+=5900;
- }
-
- /* TODO:
- if (strcmp(argv[i], "-tunnel") == 0 || strcmp(argv[i], "-via") == 0) {
- if (!createTunnel(&argc, argv, i))
- exit(1);
- break;
- }
- */
- }
-
- /* Call the main Xt initialisation function. It parses command-line options,
- generating appropriate resource specs, and makes a connection to the X
- display. */
-
- /* TODO: cmdline args
- toplevel = XtVaAppInitialize(&appContext, "Vncviewer",
- cmdLineOptions, numCmdLineOptions,
- &argc, argv, fallback_resources,
- XtNborderWidth, 0, NULL);
-
- dpy = XtDisplay(toplevel);
- */
-
- /* Interpret resource specs and process any remaining command-line arguments
- (i.e. the VNC server name). If the server name isn't specified on the
- command line, getArgsAndResources() will pop up a dialog box and wait
- for one to be entered. */
-
- /*
- GetArgsAndResources(argc, argv);
- */
-
/* Unless we accepted an incoming connection, make a TCP connection to the
given VNC server */
if (!client->listenSpecified) {
- if (!ConnectToRFBServer(client,vncServerHost, vncServerPort)) exit(1);
+ if (!ConnectToRFBServer(client,vncServerHost, vncServerPort))
+ return FALSE;
}
/* Initialise the VNC connection, including reading the password */
- if (!InitialiseRFBConnection(client)) exit(1);
+ if (!InitialiseRFBConnection(client))
+ return FALSE;
- SetFormatAndEncodings(client);
+ if (!SetFormatAndEncodings(client))
+ return FALSE;
client->width=client->si.framebufferWidth;
client->height=client->si.framebufferHeight;
client->MallocFrameBuffer(client);
- SendFramebufferUpdateRequest(client,0,0,client->width,client->height,FALSE);
+ if (!SendFramebufferUpdateRequest(client,
+ 0,0,client->width,client->height,FALSE))
+ return FALSE;
- /* Now enter the main loop, processing VNC messages. X events will
- automatically be processed whenever the VNC connection is idle. */
-
- while (1) {
- if (!HandleRFBServerMessage(client))
- break;
- }
-
- return 0;
+ return TRUE;
}
diff --git a/libvncclient/zlib.c b/libvncclient/zlib.c
index 1fa67b5..25d6422 100644
--- a/libvncclient/zlib.c
+++ b/libvncclient/zlib.c
@@ -60,7 +60,7 @@ HandleZlibBPP (rfbClient* client, int rx, int ry, int rw, int rh)
if (!ReadFromRFBServer(client, (char *)&hdr, sz_rfbZlibHeader))
return FALSE;
- remaining = Swap32IfLE(hdr.nBytes);
+ remaining = rfbClientSwap32IfLE(hdr.nBytes);
/* Need to initialize the decompressor state. */
decompStream.next_in = ( Bytef * )client->buffer;
@@ -75,7 +75,7 @@ HandleZlibBPP (rfbClient* client, int rx, int ry, int rw, int rh)
inflateResult = inflateInit( &decompStream );
if ( inflateResult != Z_OK ) {
- fprintf(stderr,
+ rfbClientLog(
"inflateInit returned error: %d, msg: %s\n",
inflateResult,
decompStream.msg);
@@ -113,11 +113,11 @@ HandleZlibBPP (rfbClient* client, int rx, int ry, int rw, int rh)
/* We never supply a dictionary for compression. */
if ( inflateResult == Z_NEED_DICT ) {
- fprintf(stderr,"zlib inflate needs a dictionary!\n");
+ rfbClientLog("zlib inflate needs a dictionary!\n");
return FALSE;
}
if ( inflateResult < 0 ) {
- fprintf(stderr,
+ rfbClientLog(
"zlib inflate returned error: %d, msg: %s\n",
inflateResult,
decompStream.msg);
@@ -129,7 +129,7 @@ HandleZlibBPP (rfbClient* client, int rx, int ry, int rw, int rh)
*/
if (( decompStream.avail_in > 0 ) &&
( decompStream.avail_out <= 0 )) {
- fprintf(stderr,"zlib inflate ran out of space!\n");
+ rfbClientLog("zlib inflate ran out of space!\n");
return FALSE;
}
@@ -144,7 +144,7 @@ HandleZlibBPP (rfbClient* client, int rx, int ry, int rw, int rh)
}
else {
- fprintf(stderr,
+ rfbClientLog(
"zlib inflate returned error: %d, msg: %s\n",
inflateResult,
decompStream.msg);
OpenPOWER on IntegriCloud