converted CARD{8,16,32} to uint{8,16,32}_t and included support for stdint.h

pull/1/head
dscho 22 years ago
parent f86f9cec24
commit 5030d53ff0

@ -3,7 +3,7 @@ DIST_SUBDIRS=examples contrib
bin_SCRIPTS = libvncserver-config bin_SCRIPTS = libvncserver-config
include_HEADERS=include/rfb.h include/rfbconfig.h include/rfbproto.h \ include_HEADERS=include/rfb.h include/rfbconfig.h include/rfbint.h include/rfbproto.h \
include/keysym.h include/keysym.h
noinst_HEADERS=sraRegion.h d3des.h zrleDecode.h zrleEncode.h \ noinst_HEADERS=sraRegion.h d3des.h zrleDecode.h zrleEncode.h \

@ -1,7 +1,6 @@
immediate: immediate:
---------- ----------
autoconf also CARD8,CARD16,...
x11vnc: clipboard, cursor x11vnc: clipboard, cursor
extra_bytes in rfbDrawCharWithClip. extra_bytes in rfbDrawCharWithClip.
tested mouse buttons make copy rect, but text is not marked as mod. tested mouse buttons make copy rect, but text is not marked as mod.
@ -25,6 +24,7 @@ CORBA
done: done:
----- -----
.autoconf also CARD8,CARD16,...
.autoconf .autoconf
.internal HTTP tunnelling feature (needs a special GET target and a few .internal HTTP tunnelling feature (needs a special GET target and a few
. changes to java applet). . changes to java applet).

@ -0,0 +1,653 @@
AH_TEMPLATE(socklen_t, [The type for socklen])
AC_DEFUN([AC_TYPE_SOCKLEN_T],
[AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t,
[
AC_TRY_COMPILE(
[#include <sys/types.h>
#include <sys/socket.h>],
[socklen_t len = 42; return 0;],
ac_cv_type_socklen_t=yes,
ac_cv_type_socklen_t=no)
])
if test $ac_cv_type_socklen_t != yes; then
AC_DEFINE(socklen_t, int)
fi
])
dnl Available from the GNU Autoconf Macro Archive at:
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_compile_check_sizeof.html
dnl
AC_DEFUN([AC_COMPILE_CHECK_SIZEOF],
[changequote(<<, >>)dnl
dnl The name to #define.
define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
dnl The cache variable name.
define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
changequote([, ])dnl
AC_MSG_CHECKING(size of $1)
AC_CACHE_VAL(AC_CV_NAME,
[for ac_size in 4 8 1 2 16 $2 ; do # List sizes in rough order of prevalence.
AC_TRY_COMPILE([#include "confdefs.h"
#include <sys/types.h>
$2
], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
if test x$AC_CV_NAME != x ; then break; fi
done
])
if test x$AC_CV_NAME = x ; then
AC_MSG_ERROR([cannot determine a size for $1])
fi
AC_MSG_RESULT($AC_CV_NAME)
AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
undefine([AC_TYPE_NAME])dnl
undefine([AC_CV_NAME])dnl
])
dnl Available from the GNU Autoconf Macro Archive at:
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_create_stdint_h.html
dnl
AC_DEFUN([AC_CREATE_STDINT_H],
[# ------ AC CREATE STDINT H -------------------------------------
AC_MSG_CHECKING([for stdint-types....])
ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)`
if test "$ac_stdint_h" = "stdint.h" ; then
AC_MSG_RESULT("(are you sure you want them in ./stdint.h?)")
elif test "$ac_stdint_h" = "inttypes.h" ; then
AC_MSG_RESULT("(are you sure you want them in ./inttypes.h?)")
else
AC_MSG_RESULT("(putting them into $ac_stdint_h)")
fi
inttype_headers=`echo inttypes.h sys/inttypes.h sys/inttypes.h $2 \
| sed -e 's/,/ /g'`
ac_cv_header_stdint_x="no-file"
ac_cv_header_stdint_o="no-file"
ac_cv_header_stdint_u="no-file"
for i in stdint.h $inttype_headers ; do
unset ac_cv_type_uintptr_t
unset ac_cv_type_uint64_t
_AC_CHECK_TYPE_NEW(uintptr_t,[ac_cv_header_stdint_x=$i],dnl
continue,[#include <$i>])
AC_CHECK_TYPE(uint64_t,[and64="(uint64_t too)"],[and64=""],[#include<$i>])
AC_MSG_RESULT(... seen our uintptr_t in $i $and64)
break;
done
if test "$ac_cv_header_stdint_x" = "no-file" ; then
for i in stdint.h $inttype_headers ; do
unset ac_cv_type_uint32_t
unset ac_cv_type_uint64_t
AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],dnl
continue,[#include <$i>])
AC_CHECK_TYPE(uint64_t,[and64="(uint64_t too)"],[and64=""],[#include<$i>])
AC_MSG_RESULT(... seen our uint32_t in $i $and64)
break;
done
if test "$ac_cv_header_stdint_o" = "no-file" ; then
for i in sys/types.h $inttype_headers ; do
unset ac_cv_type_u_int32_t
unset ac_cv_type_u_int64_t
AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],dnl
continue,[#include <$i>])
AC_CHECK_TYPE(uint64_t,[and64="(u_int64_t too)"],[and64=""],[#include<$i>])
AC_MSG_RESULT(... seen our u_int32_t in $i $and64)
break;
done
fi
fi
# ----------------- DONE inttypes.h checks MAYBE C basic types --------
if test "$ac_cv_header_stdint_x" = "no-file" ; then
AC_COMPILE_CHECK_SIZEOF(char)
AC_COMPILE_CHECK_SIZEOF(short)
AC_COMPILE_CHECK_SIZEOF(int)
AC_COMPILE_CHECK_SIZEOF(long)
AC_COMPILE_CHECK_SIZEOF(void*)
ac_cv_header_stdint_test="yes"
else
ac_cv_header_stdint_test="no"
fi
# ----------------- DONE inttypes.h checks START header -------------
_ac_stdint_h=AS_TR_CPP(_$ac_stdint_h)
AC_MSG_RESULT(creating $ac_stdint_h : $_ac_stdint_h)
echo "#ifndef" $_ac_stdint_h >$ac_stdint_h
echo "#define" $_ac_stdint_h "1" >>$ac_stdint_h
echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint_h
echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint_h
if test "$GCC" = "yes" ; then
echo "/* generated using a gnu compiler version" `$CC --version` "*/" \
>>$ac_stdint_h
else
echo "/* generated using $CC */" >>$ac_stdint_h
fi
echo "" >>$ac_stdint_h
if test "$ac_cv_header_stdint_x" != "no-file" ; then
ac_cv_header_stdint="$ac_cv_header_stdint_x"
elif test "$ac_cv_header_stdint_o" != "no-file" ; then
ac_cv_header_stdint="$ac_cv_header_stdint_o"
elif test "$ac_cv_header_stdint_u" != "no-file" ; then
ac_cv_header_stdint="$ac_cv_header_stdint_u"
else
ac_cv_header_stdint="stddef.h"
fi
# ----------------- See if int_least and int_fast types are present
unset ac_cv_type_int_least32_t
unset ac_cv_type_int_fast32_t
AC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>])
AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>])
if test "$ac_cv_header_stdint" != "stddef.h" ; then
if test "$ac_cv_header_stdint" != "stdint.h" ; then
AC_MSG_RESULT(..adding include stddef.h)
echo "#include <stddef.h>" >>$ac_stdint_h
fi ; fi
AC_MSG_RESULT(..adding include $ac_cv_header_stdint)
echo "#include <$ac_cv_header_stdint>" >>$ac_stdint_h
echo "" >>$ac_stdint_h
# ----------------- DONE header START basic int types -------------
if test "$ac_cv_header_stdint_x" = "no-file" ; then
AC_MSG_RESULT(... need to look at C basic types)
dnl ac_cv_header_stdint_test="yes" # moved up before creating the file
else
AC_MSG_RESULT(... seen good stdint.h inttypes)
dnl ac_cv_header_stdint_test="no" # moved up before creating the file
fi
if test "$ac_cv_header_stdint_u" != "no-file" ; then
AC_MSG_RESULT(... seen bsd/sysv typedefs)
cat >>$ac_stdint_h <<EOF
/* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */
typedef u_int8_t uint8_t;
typedef u_int16_t uint16_t;
typedef u_int32_t uint32_t;
EOF
cat >>$ac_stdint_h <<EOF
/* glibc compatibility */
#ifndef __int8_t_defined
#define __int8_t_defined
#endif
EOF
fi
ac_cv_sizeof_x="$ac_cv_sizeof_char:$ac_cv_sizeof_short"
ac_cv_sizeof_X="$ac_cv_sizeof_x:$ac_cv_sizeof_int"
ac_cv_sizeof_X="$ac_cv_sizeof_X:$ac_cv_sizeof_voidp:$ac_cv_sizeof_long"
if test "$ac_cv_header_stdint" = "stddef.h" ; then
# we must guess all the basic types. Apart from byte-adressable system,
# there a few 32-bit-only dsp-systems. nibble-addressable systems are way off.
cat >>$ac_stdint_h <<EOF
/* ------------ BITSPECIFIC INTTYPES SECTION --------------- */
EOF
t="typedefs for a"
case "$ac_cv_sizeof_X" in
1:2:2:2:4) AC_MSG_RESULT(..adding $t normal 16-bit system)
cat >>$ac_stdint_h <<EOF
/* a normal 16-bit system */
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned long uint32_t;
#ifndef __int8_t_defined
#define __int8_t_defined
typedef char int8_t;
typedef short int16_t;
typedef long int32_t;
#endif
EOF
;;
1:2:2:4:4) AC_MSG_RESULT(..adding $t 32-bit system derived from a 16-bit)
cat >>$ac_stdint_h <<EOF
/* a 32-bit system derived from a 16-bit */
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#ifndef __int8_t_defined
#define __int8_t_defined
typedef char int8_t;
typedef short int16_t;
typedef int int32_t;
#endif
EOF
;;
1:2:4:4:4) AC_MSG_RESULT(..adding $t normal 32-bit system)
cat >>$ac_stdint_h <<EOF
/* a normal 32-bit system */
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#ifndef __int8_t_defined
#define __int8_t_defined
typedef char int8_t;
typedef short int16_t;
typedef int int32_t;
#endif
EOF
;;
1:2:4:4:8) AC_MSG_RESULT(..adding $t 32-bit system prepared for 64-bit)
cat >>$ac_stdint_h <<EOF
/* a 32-bit system prepared for 64-bit */
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#ifndef __int8_t_defined
#define __int8_t_defined
typedef char int8_t;
typedef short int16_t;
typedef int int32_t;
#endif
EOF
;;
1:2:4:8:8) AC_MSG_RESULT(..adding $t normal 64-bit system)
cat >>$ac_stdint_h <<EOF
/* a normal 64-bit system */
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#ifndef __int8_t_defined
#define __int8_t_defined
typedef char int8_t;
typedef short int16_t;
typedef int int32_t;
#endif
EOF
;;
1:2:4:8:4) AC_MSG_RESULT(..adding $t 64-bit system derived from a 32-bit)
cat >>$ac_stdint_h <<EOF
/* a 64-bit system derived from a 32-bit system */
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#ifndef __int8_t_defined
#define __int8_t_defined
typedef char int8_t;
typedef short int16_t;
typedef int int32_t;
#endif
EOF
;;
*)
AC_MSG_ERROR([ $ac_cv_sizeof_X dnl
what is that a system? contact the author, quick! http://ac-archive.sf.net])
exit 1
;;
esac
fi
# ------------- DONE basic int types START int64_t types ------------
if test "$ac_cv_type_uint64_t" = "yes"
then AC_MSG_RESULT(... seen good uint64_t)
cat >>$ac_stdint_h <<EOF
/* system headers have good uint64_t */
#ifndef _HAVE_UINT64_T
#define _HAVE_UINT64_T
#endif
EOF
elif test "$ac_cv_type_u_int64_t" = "yes"
then AC_MSG_RESULT(..adding typedef u_int64_t uint64_t)
cat >>$ac_stdint_h <<EOF
/* system headers have an u_int64_t */
#ifndef _HAVE_UINT64_T
#define _HAVE_UINT64_T
typedef u_int64_t uint64_t;
#endif
EOF
else AC_MSG_RESULT(..adding generic uint64_t runtime checks)
cat >>$ac_stdint_h <<EOF
/* -------------------- 64 BIT GENERIC SECTION -------------------- */
/* here are some common heuristics using compiler runtime specifics */
#if defined __STDC_VERSION__ && defined __STDC_VERSION__ > 199901L
#ifndef _HAVE_UINT64_T
#define _HAVE_UINT64_T
typedef long long int64_t;
typedef unsigned long long uint64_t;
#endif
#elif !defined __STRICT_ANSI__
#if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__
#ifndef _HAVE_UINT64_T
#define _HAVE_UINT64_T
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#endif
#elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__
dnl /* note: all ELF-systems seem to have loff-support which needs 64-bit */
#if !defined _NO_LONGLONG
#ifndef _HAVE_UINT64_T
#define _HAVE_UINT64_T
typedef long long int64_t;
typedef unsigned long long uint64_t;
#endif
#endif
#elif defined __alpha || (defined __mips && defined _ABIN32)
#if !defined _NO_LONGLONG
#ifndef _HAVE_UINT64_T
#define _HAVE_UINT64_T
typedef long int64_t;
typedef unsigned long uint64_t;
#endif
#endif
/* compiler/cpu type ... or just ISO C99 */
#endif
#endif
EOF
# plus a default 64-bit for systems that are likely to be 64-bit ready
case "$ac_cv_sizeof_x:$ac_cv_sizeof_voidp:$ac_cv_sizeof_long" in
1:2:8:8) AC_MSG_RESULT(..adding uint64_t default, normal 64-bit system)
cat >>$ac_stdint_h <<EOF
/* DEFAULT: */
/* seen normal 64-bit system, CC has sizeof(long and void*) == 8 bytes */
#ifndef _HAVE_UINT64_T
#define _HAVE_UINT64_T
typedef long int64_t;
typedef unsigned long uint64_t;
#endif
EOF
;;
1:2:4:8) AC_MSG_RESULT(..adding uint64_t default, typedef to long)
cat >>$ac_stdint_h <<EOF
/* DEFAULT: */
/* seen 32-bit system prepared for 64-bit, CC has sizeof(long) == 8 bytes */
#ifndef _HAVE_UINT64_T
#define _HAVE_UINT64_T
typedef long int64_t;
typedef unsigned long uint64_t;
#endif
EOF
;;
1:2:8:4) AC_MSG_RESULT(..adding uint64_t default, typedef long long)
cat >>$ac_stdint_h <<EOF
/* DEFAULT: */
/* seen 64-bit derived from a 32-bit, CC has sizeof(long) == 4 bytes */
#ifndef _HAVE_UINT64_T
#define _HAVE_UINT64_T
typedef long long int64_t;
typedef unsigned long long uint64_t;
#endif
EOF
;;
*)
cat >>$ac_stdint_h <<EOF
/* NOTE: */
/* the configure-checks for the basic types did not make us believe */
/* that we could add a fallback to a 'long long' typedef to int64_t */
EOF
esac
fi
# ------------- DONE int64_t types START intptr types ------------
if test "$ac_cv_header_stdint_x" = "no-file" ; then
cat >>$ac_stdint_h <<EOF
/* -------------------------- INPTR SECTION --------------------------- */
EOF
case "$ac_cv_sizeof_x:$ac_cv_sizeof_voidp" in
1:2:2)
a="int16_t" ; cat >>$ac_stdint_h <<EOF
/* we tested sizeof(void*) to be of 2 chars, hence we declare it 16-bit */
typedef uint16_t uintptr_t;
typedef int16_t intptr_t;
EOF
;;
1:2:4)
a="int32_t" ; cat >>$ac_stdint_h <<EOF
/* we tested sizeof(void*) to be of 4 chars, hence we declare it 32-bit */
typedef uint32_t uintptr_t;
typedef int32_t intptr_t;
EOF
;;
1:2:8)
a="int64_t" ; cat >>$ac_stdint_h <<EOF
/* we tested sizeof(void*) to be of 8 chars, hence we declare it 64-bit */
typedef uint64_t uintptr_t;
typedef int64_t intptr_t;
EOF
;;
*)
a="long" ; cat >>$ac_stdint_h <<EOF
/* we tested sizeof(void*) but got no guess, hence we declare it as if long */
typedef unsigned long uintptr_t;
typedef long intptr_t;
EOF
;;
esac
AC_MSG_RESULT(..adding typedef $a intptr_t)
fi
# ------------- DONE intptr types START int_least types ------------
if test "$ac_cv_type_int_least32_t" = "no"; then
AC_MSG_RESULT(..adding generic int_least-types)
cat >>$ac_stdint_h <<EOF
/* --------------GENERIC INT_LEAST ------------------ */
typedef int8_t int_least8_t;
typedef int16_t int_least16_t;
typedef int32_t int_least32_t;
#ifdef _HAVE_INT64_T
typedef int64_t int_least64_t;
#endif
typedef uint8_t uint_least8_t;
typedef uint16_t uint_least16_t;
typedef uint32_t uint_least32_t;
#ifdef _HAVE_INT64_T
typedef uint64_t uint_least64_t;
#endif
EOF
fi
# ------------- DONE intptr types START int_least types ------------
if test "$ac_cv_type_int_fast32_t" = "no"; then
AC_MSG_RESULT(..adding generic int_fast-types)
cat >>$ac_stdint_h <<EOF
/* --------------GENERIC INT_FAST ------------------ */
typedef int8_t int_fast8_t;
typedef int32_t int_fast16_t;
typedef int32_t int_fast32_t;
#ifdef _HAVE_INT64_T
typedef int64_t int_fast64_t;
#endif
typedef uint8_t uint_fast8_t;
typedef uint32_t uint_fast16_t;
typedef uint32_t uint_fast32_t;
#ifdef _HAVE_INT64_T
typedef uint64_t uint_fast64_t;
#endif
EOF
fi
if test "$ac_cv_header_stdint_x" = "no-file" ; then
cat >>$ac_stdint_h <<EOF
#ifdef _HAVE_INT64_T
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
#else
typedef long int intmax_t;
typedef unsigned long uintmax_t;
#endif
EOF
fi
AC_MSG_RESULT(... DONE $ac_stdint_h)
cat >>$ac_stdint_h <<EOF
/* once */
#endif
#endif
EOF
])
dnl quote from SunOS-5.8 sys/inttypes.h:
dnl Use at your own risk. As of February 1996, the committee is squarely
dnl behind the fixed sized types; the "least" and "fast" types are still being
dnl discussed. The probability that the "fast" types may be removed before
dnl the standard is finalized is high enough that they are not currently
dnl implemented.
# AM_INIT_AUTOMAKE(PACKAGE,VERSION, [NO-DEFINE])
# ----------------------------------------------
AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_REQUIRE([AC_PROG_INSTALL])dnl
# test to see if srcdir already configured
if test "`CDPATH=:; cd $srcdir && pwd`" != "`pwd`" &&
test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run \"make distclean\" there first])
fi
# Define the identity of the package.
PACKAGE=$1
AC_SUBST(PACKAGE)dnl
VERSION=$2
AC_SUBST(VERSION)dnl
ifelse([$3],,
[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])
# Autoconf 2.50 wants to disallow AM_ names. We explicitly allow
# the ones we care about.
ifdef([m4_pattern_allow],
[m4_pattern_allow([^AM_[A-Z]+FLAGS])])dnl
# Autoconf 2.50 always computes EXEEXT. However we need to be
# compatible with 2.13, for now. So we always define EXEEXT, but we
# don't compute it.
AC_SUBST(EXEEXT)
# Similar for OBJEXT -- only we only use OBJEXT if the user actually
# requests that it be used. This is a bit dumb.
: ${OBJEXT=o}
AC_SUBST(OBJEXT)
# Some tools Automake needs.
AC_REQUIRE([AM_SANITY_CHECK])dnl
AC_REQUIRE([AC_ARG_PROGRAM])dnl
AM_MISSING_PROG(ACLOCAL, aclocal)
AM_MISSING_PROG(AUTOCONF, autoconf)
AM_MISSING_PROG(AUTOMAKE, automake)
AM_MISSING_PROG(AUTOHEADER, autoheader)
AM_MISSING_PROG(MAKEINFO, makeinfo)
AM_MISSING_PROG(AMTAR, tar)
AM_PROG_INSTALL_SH
AM_PROG_INSTALL_STRIP
# We need awk for the "check" target. The system "awk" is bad on
# some platforms.
AC_REQUIRE([AC_PROG_AWK])dnl
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AM_DEP_TRACK])dnl
AC_REQUIRE([AM_SET_DEPDIR])dnl
AC_PROVIDE_IFELSE([AC_PROG_][CC],
[_AM_DEPENDENCIES(CC)],
[define([AC_PROG_][CC],
defn([AC_PROG_][CC])[_AM_DEPENDENCIES(CC)])])dnl
AC_PROVIDE_IFELSE([AC_PROG_][CXX],
[_AM_DEPENDENCIES(CXX)],
[define([AC_PROG_][CXX],
defn([AC_PROG_][CXX])[_AM_DEPENDENCIES(CXX)])])dnl
])
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
# -------------------------------------
# Define a conditional.
#
# FIXME: Once using 2.50, use this:
# m4_match([$1], [^TRUE\|FALSE$], [AC_FATAL([$0: invalid condition: $1])])dnl
AC_DEFUN([AM_CONDITIONAL],
[ifelse([$1], [TRUE],
[errprint(__file__:__line__: [$0: invalid condition: $1
])dnl
m4exit(1)])dnl
ifelse([$1], [FALSE],
[errprint(__file__:__line__: [$0: invalid condition: $1
])dnl
m4exit(1)])dnl
AC_SUBST([$1_TRUE])
AC_SUBST([$1_FALSE])
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi])
# Like AC_CONFIG_HEADER, but automatically create stamp file.
# serial 3
# When config.status generates a header, we must update the stamp-h file.
# This file resides in the same directory as the config header
# that is generated. We must strip everything past the first ":",
# and everything past the last "/".
AC_PREREQ([2.12])
AC_DEFUN([AM_CONFIG_HEADER],
[ifdef([AC_FOREACH],dnl
[dnl init our file count if it isn't already
m4_ifndef([_AM_Config_Header_Index], m4_define([_AM_Config_Header_Index], [0]))
dnl prepare to store our destination file list for use in config.status
AC_FOREACH([_AM_File], [$1],
[m4_pushdef([_AM_Dest], m4_patsubst(_AM_File, [:.*]))
m4_define([_AM_Config_Header_Index], m4_incr(_AM_Config_Header_Index))
dnl and add it to the list of files AC keeps track of, along
dnl with our hook
AC_CONFIG_HEADERS(_AM_File,
dnl COMMANDS, [, INIT-CMDS]
[# update the timestamp
echo timestamp >"AS_ESCAPE(_AM_DIRNAME(]_AM_Dest[))/stamp-h]_AM_Config_Header_Index["
][$2]m4_ifval([$3], [, [$3]]))dnl AC_CONFIG_HEADERS
m4_popdef([_AM_Dest])])],dnl
[AC_CONFIG_HEADER([$1])
AC_OUTPUT_COMMANDS(
ifelse(patsubst([$1], [[^ ]], []),
[],
[test -z "$CONFIG_HEADERS" || echo timestamp >dnl
patsubst([$1], [^\([^:]*/\)?.*], [\1])stamp-h]),dnl
[am_indx=1
for am_file in $1; do
case " \$CONFIG_HEADERS " in
*" \$am_file "*)
am_dir=\`echo \$am_file |sed 's%:.*%%;s%[^/]*\$%%'\`
if test -n "\$am_dir"; then
am_tmpdir=\`echo \$am_dir |sed 's%^\(/*\).*\$%\1%'\`
for am_subdir in \`echo \$am_dir |sed 's%/% %'\`; do
am_tmpdir=\$am_tmpdir\$am_subdir/
if test ! -d \$am_tmpdir; then
mkdir \$am_tmpdir
fi
done
fi
echo timestamp > "\$am_dir"stamp-h\$am_indx
;;
esac
am_indx=\`expr \$am_indx + 1\`
done])
])]) # AM_CONFIG_HEADER

@ -26,8 +26,6 @@
* USA. * USA.
*/ */
#include <stdio.h>
#include <stdlib.h>
#include "rfb.h" #include "rfb.h"
/* /*
@ -46,12 +44,12 @@ rfbAuthNewClient(cl)
cl->state = RFB_AUTHENTICATION; cl->state = RFB_AUTHENTICATION;
if (cl->screen->rfbAuthPasswdData && !cl->reverseConnection) { if (cl->screen->rfbAuthPasswdData && !cl->reverseConnection) {
*(CARD32 *)buf = Swap32IfLE(rfbVncAuth); *(uint32_t *)buf = Swap32IfLE(rfbVncAuth);
vncRandomBytes(cl->authChallenge); vncRandomBytes(cl->authChallenge);
memcpy(&buf[4], (char *)cl->authChallenge, CHALLENGESIZE); memcpy(&buf[4], (char *)cl->authChallenge, CHALLENGESIZE);
len = 4 + CHALLENGESIZE; len = 4 + CHALLENGESIZE;
} else { } else {
*(CARD32 *)buf = Swap32IfLE(rfbNoAuth); *(uint32_t *)buf = Swap32IfLE(rfbNoAuth);
len = 4; len = 4;
cl->state = RFB_INITIALISATION; cl->state = RFB_INITIALISATION;
} }
@ -74,8 +72,8 @@ rfbAuthProcessClientMessage(cl)
rfbClientPtr cl; rfbClientPtr cl;
{ {
int n; int n;
CARD8 response[CHALLENGESIZE]; uint8_t response[CHALLENGESIZE];
CARD32 authResult; uint32_t authResult;
if ((n = ReadExact(cl, (char *)response, CHALLENGESIZE)) <= 0) { if ((n = ReadExact(cl, (char *)response, CHALLENGESIZE)) <= 0) {
if (n != 0) if (n != 0)

@ -71,6 +71,8 @@ AC_C_INLINE
AC_C_BIGENDIAN AC_C_BIGENDIAN
AC_TYPE_SIZE_T AC_TYPE_SIZE_T
AC_HEADER_TIME AC_HEADER_TIME
AC_TYPE_SOCKLEN_T
AC_CREATE_STDINT_H(include/rfbint.h)
# Checks for library functions. # Checks for library functions.
AC_FUNC_MALLOC AC_FUNC_MALLOC

@ -461,7 +461,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
screen->paddedWidthInBytes = fb->bytes_per_line; screen->paddedWidthInBytes = fb->bytes_per_line;
screen->rfbServerFormat.bitsPerPixel = fb->bits_per_pixel; screen->rfbServerFormat.bitsPerPixel = fb->bits_per_pixel;
screen->rfbServerFormat.depth = fb->depth; screen->rfbServerFormat.depth = fb->depth;
screen->rfbServerFormat.trueColour = (CARD8) TRUE; screen->rfbServerFormat.trueColour = (uint8_t) TRUE;
if ( screen->rfbServerFormat.bitsPerPixel == 8 ) { if ( screen->rfbServerFormat.bitsPerPixel == 8 ) {
/* 8 bpp */ /* 8 bpp */

@ -27,8 +27,6 @@
* USA. * USA.
*/ */
#include <stdio.h>
#include <stdlib.h>
#include "rfb.h" #include "rfb.h"
/* /*
@ -45,10 +43,10 @@ static int rreAfterBufSize = 0;
static char *rreAfterBuf = NULL; static char *rreAfterBuf = NULL;
static int rreAfterBufLen; static int rreAfterBufLen;
static int subrectEncode8(CARD8 *data, int w, int h); static int subrectEncode8(uint8_t *data, int w, int h);
static int subrectEncode16(CARD16 *data, int w, int h); static int subrectEncode16(uint16_t *data, int w, int h);
static int subrectEncode32(CARD32 *data, int w, int h); static int subrectEncode32(uint32_t *data, int w, int h);
static CARD32 getBgColour(char *data, int size, int bpp); static uint32_t getBgColour(char *data, int size, int bpp);
static Bool rfbSendSmallRectEncodingCoRRE(rfbClientPtr cl, int x, int y, static Bool rfbSendSmallRectEncodingCoRRE(rfbClientPtr cl, int x, int y,
int w, int h); int w, int h);
@ -123,13 +121,13 @@ rfbSendSmallRectEncodingCoRRE(cl, x, y, w, h)
switch (cl->format.bitsPerPixel) { switch (cl->format.bitsPerPixel) {
case 8: case 8:
nSubrects = subrectEncode8((CARD8 *)rreBeforeBuf, w, h); nSubrects = subrectEncode8((uint8_t *)rreBeforeBuf, w, h);
break; break;
case 16: case 16:
nSubrects = subrectEncode16((CARD16 *)rreBeforeBuf, w, h); nSubrects = subrectEncode16((uint16_t *)rreBeforeBuf, w, h);
break; break;
case 32: case 32:
nSubrects = subrectEncode32((CARD32 *)rreBeforeBuf, w, h); nSubrects = subrectEncode32((uint32_t *)rreBeforeBuf, w, h);
break; break;
default: default:
rfbLog("getBgColour: bpp %d?\n",cl->format.bitsPerPixel); rfbLog("getBgColour: bpp %d?\n",cl->format.bitsPerPixel);
@ -209,25 +207,25 @@ rfbSendSmallRectEncodingCoRRE(cl, x, y, w, h)
#define DEFINE_SUBRECT_ENCODE(bpp) \ #define DEFINE_SUBRECT_ENCODE(bpp) \
static int \ static int \
subrectEncode##bpp(data,w,h) \ subrectEncode##bpp(data,w,h) \
CARD##bpp *data; \ uint##bpp##_t *data; \
int w; \ int w; \
int h; \ int h; \
{ \ { \
CARD##bpp cl; \ uint##bpp##_t cl; \
rfbCoRRERectangle subrect; \ rfbCoRRERectangle subrect; \
int x,y; \ int x,y; \
int i,j; \ int i,j; \
int hx=0,hy,vx=0,vy; \ int hx=0,hy,vx=0,vy; \
int hyflag; \ int hyflag; \
CARD##bpp *seg; \ uint##bpp##_t *seg; \
CARD##bpp *line; \ uint##bpp##_t *line; \
int hw,hh,vw,vh; \ int hw,hh,vw,vh; \
int thex,they,thew,theh; \ int thex,they,thew,theh; \
int numsubs = 0; \ int numsubs = 0; \
int newLen; \ int newLen; \
CARD##bpp bg = (CARD##bpp)getBgColour((char*)data,w*h,bpp); \ uint##bpp##_t bg = (uint##bpp##_t)getBgColour((char*)data,w*h,bpp); \
\ \
*((CARD##bpp*)rreAfterBuf) = bg; \ *((uint##bpp##_t*)rreAfterBuf) = bg; \
\ \
rreAfterBufLen = (bpp/8); \ rreAfterBufLen = (bpp/8); \
\ \
@ -279,7 +277,7 @@ subrectEncode##bpp(data,w,h) \
return -1; \ return -1; \
\ \
numsubs += 1; \ numsubs += 1; \
*((CARD##bpp*)(rreAfterBuf + rreAfterBufLen)) = cl; \ *((uint##bpp##_t*)(rreAfterBuf + rreAfterBufLen)) = cl; \
rreAfterBufLen += (bpp/8); \ rreAfterBufLen += (bpp/8); \
memcpy(&rreAfterBuf[rreAfterBufLen],&subrect,sz_rfbCoRRERectangle); \ memcpy(&rreAfterBuf[rreAfterBufLen],&subrect,sz_rfbCoRRERectangle); \
rreAfterBufLen += sz_rfbCoRRERectangle; \ rreAfterBufLen += sz_rfbCoRRERectangle; \
@ -307,7 +305,7 @@ DEFINE_SUBRECT_ENCODE(32)
/* /*
* getBgColour() gets the most prevalent colour in a byte array. * getBgColour() gets the most prevalent colour in a byte array.
*/ */
static CARD32 static uint32_t
getBgColour(data,size,bpp) getBgColour(data,size,bpp)
char *data; char *data;
int size; int size;
@ -320,13 +318,13 @@ getBgColour(data,size,bpp)
int i,j,k; int i,j,k;
int maxcount = 0; int maxcount = 0;
CARD8 maxclr = 0; uint8_t maxclr = 0;
if (bpp != 8) { if (bpp != 8) {
if (bpp == 16) { if (bpp == 16) {
return ((CARD16 *)data)[0]; return ((uint16_t *)data)[0];
} else if (bpp == 32) { } else if (bpp == 32) {
return ((CARD32 *)data)[0]; return ((uint32_t *)data)[0];
} else { } else {
rfbLog("getBgColour: bpp %d?\n",bpp); rfbLog("getBgColour: bpp %d?\n",bpp);
exit(1); exit(1);
@ -338,7 +336,7 @@ getBgColour(data,size,bpp)
} }
for (j=0; j<size; j++) { for (j=0; j<size; j++) {
k = (int)(((CARD8 *)data)[j]); k = (int)(((uint8_t *)data)[j]);
if (k >= NUMCLRS) { if (k >= NUMCLRS) {
rfbLog("getBgColour: unusual colour = %d\n", k); rfbLog("getBgColour: unusual colour = %d\n", k);
exit(1); exit(1);
@ -346,7 +344,7 @@ getBgColour(data,size,bpp)
counts[k] += 1; counts[k] += 1;
if (counts[k] > maxcount) { if (counts[k] > maxcount) {
maxcount = counts[k]; maxcount = counts[k];
maxclr = ((CARD8 *)data)[j]; maxclr = ((uint8_t *)data)[j];
} }
} }

@ -40,8 +40,8 @@ rfbSendCursorShape(cl)
int saved_ublen; int saved_ublen;
int bitmapRowBytes, maskBytes, dataBytes; int bitmapRowBytes, maskBytes, dataBytes;
int i, j; int i, j;
CARD8 *bitmapData; uint8_t *bitmapData;
CARD8 bitmapByte; uint8_t bitmapByte;
pCursor = cl->screen->getCursorPtr(cl); pCursor = cl->screen->getCursorPtr(cl);
/*if(!pCursor) return TRUE;*/ /*if(!pCursor) return TRUE;*/
@ -131,7 +131,7 @@ rfbSendCursorShape(cl)
memcpy(&cl->updateBuf[cl->ublen], (char *)&colors, sz_rfbXCursorColors); memcpy(&cl->updateBuf[cl->ublen], (char *)&colors, sz_rfbXCursorColors);
cl->ublen += sz_rfbXCursorColors; cl->ublen += sz_rfbXCursorColors;
bitmapData = (CARD8 *)pCursor->source; bitmapData = (uint8_t *)pCursor->source;
for (i = 0; i < pCursor->height; i++) { for (i = 0; i < pCursor->height; i++) {
for (j = 0; j < bitmapRowBytes; j++) { for (j = 0; j < bitmapRowBytes; j++) {
@ -154,7 +154,7 @@ rfbSendCursorShape(cl)
/* Prepare transparency mask. */ /* Prepare transparency mask. */
bitmapData = (CARD8 *)pCursor->mask; bitmapData = (uint8_t *)pCursor->mask;
for (i = 0; i < pCursor->height; i++) { for (i = 0; i < pCursor->height; i++) {
for (j = 0; j < bitmapRowBytes; j++) { for (j = 0; j < bitmapRowBytes; j++) {
@ -322,7 +322,7 @@ void MakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor)
rfbPixelFormat* format=&rfbScreen->rfbServerFormat; rfbPixelFormat* format=&rfbScreen->rfbServerFormat;
int i,j,w=(cursor->width+7)/8,bpp=format->bitsPerPixel/8, int i,j,w=(cursor->width+7)/8,bpp=format->bitsPerPixel/8,
width=cursor->width*bpp; width=cursor->width*bpp;
CARD32 background; uint32_t background;
char *back=(char*)&background; char *back=(char*)&background;
unsigned char bit; unsigned char bit;
@ -344,7 +344,7 @@ void MakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor)
{ {
rfbPixelFormat* format=&rfbScreen->rfbServerFormat; rfbPixelFormat* format=&rfbScreen->rfbServerFormat;
int i,j,w=(cursor->width+7)/8,bpp=format->bitsPerPixel/8; int i,j,w=(cursor->width+7)/8,bpp=format->bitsPerPixel/8;
CARD32 background,foreground; uint32_t background,foreground;
char *back=(char*)&background,*fore=(char*)&foreground; char *back=(char*)&background,*fore=(char*)&foreground;
unsigned char *cp; unsigned char *cp;
unsigned char bit; unsigned char bit;

@ -23,7 +23,6 @@
* USA. * USA.
*/ */
#include <stdio.h>
#include "rfb.h" #include "rfb.h"

@ -25,7 +25,6 @@
* USA. * USA.
*/ */
#include <stdio.h>
#include "rfb.h" #include "rfb.h"
static Bool sendHextiles8(rfbClientPtr cl, int x, int y, int w, int h); static Bool sendHextiles8(rfbClientPtr cl, int x, int y, int w, int h);
@ -90,10 +89,10 @@ rfbSendRectEncodingHextile(cl, x, y, w, h)
#define DEFINE_SEND_HEXTILES(bpp) \ #define DEFINE_SEND_HEXTILES(bpp) \
\ \
\ \
static Bool subrectEncode##bpp(rfbClientPtr cli, CARD##bpp *data, int w, int h, \ static Bool subrectEncode##bpp(rfbClientPtr cli, uint##bpp##_t *data, int w, int h, \
CARD##bpp bg, CARD##bpp fg, Bool mono); \ uint##bpp##_t bg, uint##bpp##_t fg, Bool mono); \
static void testColours##bpp(CARD##bpp *data, int size, Bool *mono, \ static void testColours##bpp(uint##bpp##_t *data, int size, Bool *mono, \
Bool *solid, CARD##bpp *bg, CARD##bpp *fg); \ Bool *solid, uint##bpp##_t *bg, uint##bpp##_t *fg); \
\ \
\ \
/* \ /* \
@ -108,11 +107,11 @@ sendHextiles##bpp(cl, rx, ry, rw, rh)
int x, y, w, h; \ int x, y, w, h; \
int startUblen; \ int startUblen; \
char *fbptr; \ char *fbptr; \
CARD##bpp bg = 0, fg = 0, newBg, newFg; \ uint##bpp##_t bg = 0, fg = 0, newBg, newFg; \
Bool mono, solid; \ Bool mono, solid; \
Bool validBg = FALSE; \ Bool validBg = FALSE; \
Bool validFg = FALSE; \ Bool validFg = FALSE; \
CARD##bpp clientPixelData[16*16*(bpp/8)]; \ uint##bpp##_t clientPixelData[16*16*(bpp/8)]; \
\ \
for (y = ry; y < ry+rh; y += 16) { \ for (y = ry; y < ry+rh; y += 16) { \
for (x = rx; x < rx+rw; x += 16) { \ for (x = rx; x < rx+rw; x += 16) { \
@ -194,16 +193,16 @@ sendHextiles##bpp(cl, rx, ry, rw, rh)
\ \
\ \
static Bool \ static Bool \
subrectEncode##bpp(rfbClientPtr cl, CARD##bpp *data, int w, int h, \ subrectEncode##bpp(rfbClientPtr cl, uint##bpp##_t *data, int w, int h, \
CARD##bpp bg, CARD##bpp fg, Bool mono) \ uint##bpp##_t bg, uint##bpp##_t fg, Bool mono) \
{ \ { \
CARD##bpp cl2; \ uint##bpp##_t cl2; \
int x,y; \ int x,y; \
int i,j; \ int i,j; \
int hx=0,hy,vx=0,vy; \ int hx=0,hy,vx=0,vy; \
int hyflag; \ int hyflag; \
CARD##bpp *seg; \ uint##bpp##_t *seg; \
CARD##bpp *line; \ uint##bpp##_t *line; \
int hw,hh,vw,vh; \ int hw,hh,vw,vh; \
int thex,they,thew,theh; \ int thex,they,thew,theh; \
int numsubs = 0; \ int numsubs = 0; \
@ -297,14 +296,14 @@ subrectEncode##bpp(rfbClientPtr cl, CARD##bpp *data, int w, int h,
\ \
static void \ static void \
testColours##bpp(data,size,mono,solid,bg,fg) \ testColours##bpp(data,size,mono,solid,bg,fg) \
CARD##bpp *data; \ uint##bpp##_t *data; \
int size; \ int size; \
Bool *mono; \ Bool *mono; \
Bool *solid; \ Bool *solid; \
CARD##bpp *bg; \ uint##bpp##_t *bg; \
CARD##bpp *fg; \ uint##bpp##_t *fg; \
{ \ { \
CARD##bpp colour1 = 0, colour2 = 0; \ uint##bpp##_t colour1 = 0, colour2 = 0; \
int n1 = 0, n2 = 0; \ int n1 = 0, n2 = 0; \
*mono = TRUE; \ *mono = TRUE; \
*solid = TRUE; \ *solid = TRUE; \

@ -22,32 +22,43 @@
* USA. * USA.
*/ */
#include <stdio.h> #include "rfb.h"
#include <ctype.h> #include <ctype.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include <errno.h>
#ifdef WIN32 #ifdef WIN32
#include <winsock.h> #include <winsock.h>
#define close closesocket #define close closesocket
#else #else
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h> #include <sys/time.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <netdb.h> #include <netdb.h>
#include <pwd.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <unistd.h>
#endif #endif
#include <fcntl.h> #include <pwd.h>
#include <errno.h> #endif
#ifdef USE_LIBWRAP #ifdef USE_LIBWRAP
#include <tcpd.h> #include <tcpd.h>
#endif #endif
#include "rfb.h"
#define NOT_FOUND_STR "HTTP/1.0 404 Not found\r\n\r\n" \ #define NOT_FOUND_STR "HTTP/1.0 404 Not found\r\n\r\n" \
"<HEAD><TITLE>File Not Found</TITLE></HEAD>\n" \ "<HEAD><TITLE>File Not Found</TITLE></HEAD>\n" \
"<BODY><H1>File Not Found</H1></BODY>\n" "<BODY><H1>File Not Found</H1></BODY>\n"

@ -1,4 +1,5 @@
rfbconfig.h rfbconfig.h
rfbconfig.h.in rfbconfig.h.in
stamp-h1 stamp-h*
rfbint.h

@ -36,52 +36,47 @@ extern "C"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "rfbconfig.h" #include "rfbconfig.h"
#include "rfbint.h"
#include "keysym.h" #include "keysym.h"
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
#include <zlib.h> #include <zlib.h>
#endif #endif
/* TODO: this stuff has to go into autoconf */
typedef unsigned char CARD8;
typedef unsigned short CARD16;
typedef unsigned int CARD32;
typedef CARD32 Pixel;
/* typedef CARD32 KeySym; */
typedef unsigned long KeySym;
#define SIGNED signed
typedef signed char Bool;
#undef FALSE
#define FALSE 0
#undef TRUE
#define TRUE -1
#include "rfbproto.h" #include "rfbproto.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
#endif
#if defined(WIN32) #if defined(WIN32)
#define WORDS_BIGENDIAN #define WORDS_BIGENDIAN
#undef Bool #undef Bool
#define Bool int #define Bool int
#endif
#ifdef __sgi__
typedef int socklen_t;
#endif
#ifdef WIN32
#include <sys/timeb.h> #include <sys/timeb.h>
#include <winsock.h> #include <winsock.h>
#undef SOCKET #undef SOCKET
#define SOCKET int #define SOCKET int
#else #else
#define max(a,b) (((a)>(b))?(a):(b)) #define max(a,b) (((a)>(b))?(a):(b))
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h> #include <sys/time.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#endif
#define SOCKET int #define SOCKET int
#ifndef Bool
typedef int8_t Bool;
#undef FALSE
#define FALSE 0
#undef TRUE
#define TRUE -1
#endif #endif
#endif
typedef uint32_t KeySym;
typedef uint32_t Pixel;
#ifndef INADDR_NONE #ifndef INADDR_NONE
#define INADDR_NONE ((in_addr_t) 0xffffffff) #define INADDR_NONE ((in_addr_t) 0xffffffff)
@ -171,11 +166,11 @@ typedef enum rfbNewClientAction (*NewClientHookPtr)(struct _rfbClientRec* cl);
typedef void (*DisplayHookPtr)(struct _rfbClientRec* cl); typedef void (*DisplayHookPtr)(struct _rfbClientRec* cl);
typedef struct { typedef struct {
CARD32 count; uint32_t count;
Bool is16; /* is the data format short? */ Bool is16; /* is the data format short? */
union { union {
CARD8* bytes; uint8_t* bytes;
CARD16* shorts; uint16_t* shorts;
} data; /* there have to be count*3 entries */ } data; /* there have to be count*3 entries */
} rfbColourMap; } rfbColourMap;
@ -390,7 +385,7 @@ typedef struct _rfbClientRec {
int correMaxWidth, correMaxHeight; int correMaxWidth, correMaxHeight;
/* The following member is only used during VNC authentication */ /* The following member is only used during VNC authentication */
CARD8 authChallenge[CHALLENGESIZE]; uint8_t authChallenge[CHALLENGESIZE];
/* The following members represent the update needed to get the client's /* The following members represent the update needed to get the client's
framebuffer from its present state to the current state of our framebuffer from its present state to the current state of our
@ -473,7 +468,7 @@ typedef struct _rfbClientRec {
struct z_stream_s compStream; struct z_stream_s compStream;
Bool compStreamInited; Bool compStreamInited;
CARD32 zlibCompressLevel; uint32_t zlibCompressLevel;
#ifdef HAVE_LIBJPEG #ifdef HAVE_LIBJPEG
/* tight encoding -- preserve zlib streams' state for each client */ /* tight encoding -- preserve zlib streams' state for each client */

@ -60,10 +60,10 @@
*/ */
typedef struct { typedef struct {
CARD16 x; uint16_t x;
CARD16 y; uint16_t y;
CARD16 w; uint16_t w;
CARD16 h; uint16_t h;
} rfbRectangle; } rfbRectangle;
#define sz_rfbRectangle 8 #define sz_rfbRectangle 8
@ -75,32 +75,32 @@ typedef struct {
typedef struct { typedef struct {
CARD8 bitsPerPixel; /* 8,16,32 only */ uint8_t bitsPerPixel; /* 8,16,32 only */
CARD8 depth; /* 8 to 32 */ uint8_t depth; /* 8 to 32 */
CARD8 bigEndian; /* True if multi-byte pixels are interpreted uint8_t bigEndian; /* True if multi-byte pixels are interpreted
as big endian, or if single-bit-per-pixel as big endian, or if single-bit-per-pixel
has most significant bit of the byte has most significant bit of the byte
corresponding to first (leftmost) pixel. Of corresponding to first (leftmost) pixel. Of
course this is meaningless for 8 bits/pix */ course this is meaningless for 8 bits/pix */
CARD8 trueColour; /* If false then we need a "colour map" to uint8_t trueColour; /* If false then we need a "colour map" to
convert pixels to RGB. If true, xxxMax and convert pixels to RGB. If true, xxxMax and
xxxShift specify bits used for red, green xxxShift specify bits used for red, green
and blue */ and blue */
/* the following fields are only meaningful if trueColour is true */ /* the following fields are only meaningful if trueColour is true */
CARD16 redMax; /* maximum red value (= 2^n - 1 where n is the uint16_t redMax; /* maximum red value (= 2^n - 1 where n is the
number of bits used for red). Note this number of bits used for red). Note this
value is always in big endian order. */ value is always in big endian order. */
CARD16 greenMax; /* similar for green */ uint16_t greenMax; /* similar for green */
CARD16 blueMax; /* and blue */ uint16_t blueMax; /* and blue */
CARD8 redShift; /* number of shifts needed to get the red uint8_t redShift; /* number of shifts needed to get the red
value in a pixel to the least significant value in a pixel to the least significant
bit. To find the red value from a given bit. To find the red value from a given
pixel, do the following: pixel, do the following:
@ -112,12 +112,12 @@ typedef struct {
4) You now have the red value between 0 and 4) You now have the red value between 0 and
redMax. */ redMax. */
CARD8 greenShift; /* similar for green */ uint8_t greenShift; /* similar for green */
CARD8 blueShift; /* and blue */ uint8_t blueShift; /* and blue */
CARD8 pad1; uint8_t pad1;
CARD16 pad2; uint16_t pad2;
} rfbPixelFormat; } rfbPixelFormat;
@ -216,7 +216,7 @@ typedef char rfbProtocolVersionMsg[13]; /* allow extra byte for null */
*/ */
typedef struct { typedef struct {
CARD8 shared; uint8_t shared;
} rfbClientInitMsg; } rfbClientInitMsg;
#define sz_rfbClientInitMsg 1 #define sz_rfbClientInitMsg 1
@ -231,10 +231,10 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD16 framebufferWidth; uint16_t framebufferWidth;
CARD16 framebufferHeight; uint16_t framebufferHeight;
rfbPixelFormat format; /* the server's preferred pixel format */ rfbPixelFormat format; /* the server's preferred pixel format */
CARD32 nameLength; uint32_t nameLength;
/* followed by char name[nameLength] */ /* followed by char name[nameLength] */
} rfbServerInitMsg; } rfbServerInitMsg;
@ -363,9 +363,9 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbFramebufferUpdate */ uint8_t type; /* always rfbFramebufferUpdate */
CARD8 pad; uint8_t pad;
CARD16 nRects; uint16_t nRects;
/* followed by nRects rectangles */ /* followed by nRects rectangles */
} rfbFramebufferUpdateMsg; } rfbFramebufferUpdateMsg;
@ -381,7 +381,7 @@ typedef struct {
typedef struct { typedef struct {
rfbRectangle r; rfbRectangle r;
CARD32 encoding; /* one of the encoding types rfbEncoding... */ uint32_t encoding; /* one of the encoding types rfbEncoding... */
} rfbFramebufferUpdateRectHeader; } rfbFramebufferUpdateRectHeader;
#define sz_rfbFramebufferUpdateRectHeader (sz_rfbRectangle + 4) #define sz_rfbFramebufferUpdateRectHeader (sz_rfbRectangle + 4)
@ -399,8 +399,8 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD16 srcX; uint16_t srcX;
CARD16 srcY; uint16_t srcY;
} rfbCopyRect; } rfbCopyRect;
#define sz_rfbCopyRect 4 #define sz_rfbCopyRect 4
@ -414,7 +414,7 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD32 nSubrects; uint32_t nSubrects;
} rfbRREHeader; } rfbRREHeader;
#define sz_rfbRREHeader 4 #define sz_rfbRREHeader 4
@ -429,10 +429,10 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 x; uint8_t x;
CARD8 y; uint8_t y;
CARD8 w; uint8_t w;
CARD8 h; uint8_t h;
} rfbCoRRERectangle; } rfbCoRRERectangle;
#define sz_rfbCoRRERectangle 4 #define sz_rfbCoRRERectangle 4
@ -498,7 +498,7 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD32 nBytes; uint32_t nBytes;
} rfbZlibHeader; } rfbZlibHeader;
#define sz_rfbZlibHeader 4 #define sz_rfbZlibHeader 4
@ -661,12 +661,12 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 foreRed; uint8_t foreRed;
CARD8 foreGreen; uint8_t foreGreen;
CARD8 foreBlue; uint8_t foreBlue;
CARD8 backRed; uint8_t backRed;
CARD8 backGreen; uint8_t backGreen;
CARD8 backBlue; uint8_t backBlue;
} rfbXCursorColors; } rfbXCursorColors;
#define sz_rfbXCursorColors 6 #define sz_rfbXCursorColors 6
@ -692,7 +692,7 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD32 length; uint32_t length;
} rfbZRLEHeader; } rfbZRLEHeader;
#define sz_rfbZRLEHeader 4 #define sz_rfbZRLEHeader 4
@ -711,12 +711,12 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbSetColourMapEntries */ uint8_t type; /* always rfbSetColourMapEntries */
CARD8 pad; uint8_t pad;
CARD16 firstColour; uint16_t firstColour;
CARD16 nColours; uint16_t nColours;
/* Followed by nColours * 3 * CARD16 /* Followed by nColours * 3 * uint16_t
r1, g1, b1, r2, g2, b2, r3, g3, b3, ..., rn, bn, gn */ r1, g1, b1, r2, g2, b2, r3, g3, b3, ..., rn, bn, gn */
} rfbSetColourMapEntriesMsg; } rfbSetColourMapEntriesMsg;
@ -730,7 +730,7 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbBell */ uint8_t type; /* always rfbBell */
} rfbBellMsg; } rfbBellMsg;
#define sz_rfbBellMsg 1 #define sz_rfbBellMsg 1
@ -742,10 +742,10 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbServerCutText */ uint8_t type; /* always rfbServerCutText */
CARD8 pad1; uint8_t pad1;
CARD16 pad2; uint16_t pad2;
CARD32 length; uint32_t length;
/* followed by char text[length] */ /* followed by char text[length] */
} rfbServerCutTextMsg; } rfbServerCutTextMsg;
@ -762,7 +762,7 @@ typedef rfbServerCutTextMsg rfbBackChannelMsg;
*/ */
typedef union { typedef union {
CARD8 type; uint8_t type;
rfbFramebufferUpdateMsg fu; rfbFramebufferUpdateMsg fu;
rfbSetColourMapEntriesMsg scme; rfbSetColourMapEntriesMsg scme;
rfbBellMsg b; rfbBellMsg b;
@ -784,9 +784,9 @@ typedef union {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbSetPixelFormat */ uint8_t type; /* always rfbSetPixelFormat */
CARD8 pad1; uint8_t pad1;
CARD16 pad2; uint16_t pad2;
rfbPixelFormat format; rfbPixelFormat format;
} rfbSetPixelFormatMsg; } rfbSetPixelFormatMsg;
@ -801,12 +801,12 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbFixColourMapEntries */ uint8_t type; /* always rfbFixColourMapEntries */
CARD8 pad; uint8_t pad;
CARD16 firstColour; uint16_t firstColour;
CARD16 nColours; uint16_t nColours;
/* Followed by nColours * 3 * CARD16 /* Followed by nColours * 3 * uint16_t
r1, g1, b1, r2, g2, b2, r3, g3, b3, ..., rn, bn, gn */ r1, g1, b1, r2, g2, b2, r3, g3, b3, ..., rn, bn, gn */
} rfbFixColourMapEntriesMsg; } rfbFixColourMapEntriesMsg;
@ -821,10 +821,10 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbSetEncodings */ uint8_t type; /* always rfbSetEncodings */
CARD8 pad; uint8_t pad;
CARD16 nEncodings; uint16_t nEncodings;
/* followed by nEncodings * CARD32 encoding types */ /* followed by nEncodings * uint32_t encoding types */
} rfbSetEncodingsMsg; } rfbSetEncodingsMsg;
#define sz_rfbSetEncodingsMsg 4 #define sz_rfbSetEncodingsMsg 4
@ -837,12 +837,12 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbFramebufferUpdateRequest */ uint8_t type; /* always rfbFramebufferUpdateRequest */
CARD8 incremental; uint8_t incremental;
CARD16 x; uint16_t x;
CARD16 y; uint16_t y;
CARD16 w; uint16_t w;
CARD16 h; uint16_t h;
} rfbFramebufferUpdateRequestMsg; } rfbFramebufferUpdateRequestMsg;
#define sz_rfbFramebufferUpdateRequestMsg 10 #define sz_rfbFramebufferUpdateRequestMsg 10
@ -880,10 +880,10 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbKeyEvent */ uint8_t type; /* always rfbKeyEvent */
CARD8 down; /* true if down (press), false if up */ uint8_t down; /* true if down (press), false if up */
CARD16 pad; uint16_t pad;
CARD32 key; /* key is specified as an X keysym */ uint32_t key; /* key is specified as an X keysym */
} rfbKeyEventMsg; } rfbKeyEventMsg;
#define sz_rfbKeyEventMsg 8 #define sz_rfbKeyEventMsg 8
@ -894,10 +894,10 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbPointerEvent */ uint8_t type; /* always rfbPointerEvent */
CARD8 buttonMask; /* bits 0-7 are buttons 1-8, 0=up, 1=down */ uint8_t buttonMask; /* bits 0-7 are buttons 1-8, 0=up, 1=down */
CARD16 x; uint16_t x;
CARD16 y; uint16_t y;
} rfbPointerEventMsg; } rfbPointerEventMsg;
#define rfbButton1Mask 1 #define rfbButton1Mask 1
@ -913,10 +913,10 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbClientCutText */ uint8_t type; /* always rfbClientCutText */
CARD8 pad1; uint8_t pad1;
CARD16 pad2; uint16_t pad2;
CARD32 length; uint32_t length;
/* followed by char text[length] */ /* followed by char text[length] */
} rfbClientCutTextMsg; } rfbClientCutTextMsg;
@ -929,7 +929,7 @@ typedef struct {
*/ */
typedef union { typedef union {
CARD8 type; uint8_t type;
rfbSetPixelFormatMsg spf; rfbSetPixelFormatMsg spf;
rfbFixColourMapEntriesMsg fcme; rfbFixColourMapEntriesMsg fcme;
rfbSetEncodingsMsg se; rfbSetEncodingsMsg se;

@ -10,8 +10,6 @@
* see GPL (latest version) for full details * see GPL (latest version) for full details
*/ */
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <errno.h> #include <errno.h>
@ -20,12 +18,16 @@
#define true -1 #define true -1
#endif #endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
#endif
#ifndef WIN32 #ifndef WIN32
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <signal.h> #include <signal.h>
#include <time.h> #include <time.h>
@ -734,7 +736,7 @@ void rfbInitServer(rfbScreenInfoPtr rfbScreen)
httpInitSockets(rfbScreen); httpInitSockets(rfbScreen);
} }
#ifdef WIN32 #ifndef HAVE_GETTIMEOFDAY
#include <fcntl.h> #include <fcntl.h>
#include <conio.h> #include <conio.h>
#include <sys/timeb.h> #include <sys/timeb.h>

@ -24,23 +24,30 @@
* USA. * USA.
*/ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include "rfb.h" #include "rfb.h"
#include "sraRegion.h" #include "sraRegion.h"
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef WIN32 #ifdef WIN32
#define write(sock,buf,len) send(sock,buf,len,0) #define write(sock,buf,len) send(sock,buf,len,0)
#else #else
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif
#include <pwd.h> #include <pwd.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <fcntl.h> #endif
#include <sys/types.h>
#ifdef CORBA #ifdef CORBA
#include <vncserverctrl.h> #include <vncserverctrl.h>
@ -538,8 +545,8 @@ rfbClientConnFailed(cl, reason)
int len = strlen(reason); int len = strlen(reason);
buf = (char *)malloc(8 + len); buf = (char *)malloc(8 + len);
((CARD32 *)buf)[0] = Swap32IfLE(rfbConnFailed); ((uint32_t *)buf)[0] = Swap32IfLE(rfbConnFailed);
((CARD32 *)buf)[1] = Swap32IfLE(len); ((uint32_t *)buf)[1] = Swap32IfLE(len);
memcpy(buf + 8, reason, len); memcpy(buf + 8, reason, len);
if (WriteExact(cl, buf, 8 + len) < 0) if (WriteExact(cl, buf, 8 + len) < 0)
@ -692,7 +699,7 @@ rfbProcessClientNormalMessage(cl)
case rfbSetEncodings: case rfbSetEncodings:
{ {
int i; int i;
CARD32 enc; uint32_t enc;
if ((n = ReadExact(cl, ((char *)&msg) + 1, if ((n = ReadExact(cl, ((char *)&msg) + 1,
sz_rfbSetEncodingsMsg - 1)) <= 0) { sz_rfbSetEncodingsMsg - 1)) <= 0) {
@ -828,15 +835,15 @@ rfbProcessClientNormalMessage(cl)
#endif #endif
default: default:
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
if ( enc >= (CARD32)rfbEncodingCompressLevel0 && if ( enc >= (uint32_t)rfbEncodingCompressLevel0 &&
enc <= (CARD32)rfbEncodingCompressLevel9 ) { enc <= (uint32_t)rfbEncodingCompressLevel9 ) {
cl->zlibCompressLevel = enc & 0x0F; cl->zlibCompressLevel = enc & 0x0F;
#ifdef HAVE_LIBJPEG #ifdef HAVE_LIBJPEG
cl->tightCompressLevel = enc & 0x0F; cl->tightCompressLevel = enc & 0x0F;
rfbLog("Using compression level %d for client %s\n", rfbLog("Using compression level %d for client %s\n",
cl->tightCompressLevel, cl->host); cl->tightCompressLevel, cl->host);
} else if ( enc >= (CARD32)rfbEncodingQualityLevel0 && } else if ( enc >= (uint32_t)rfbEncodingQualityLevel0 &&
enc <= (CARD32)rfbEncodingQualityLevel9 ) { enc <= (uint32_t)rfbEncodingQualityLevel9 ) {
cl->tightQualityLevel = enc & 0x0F; cl->tightQualityLevel = enc & 0x0F;
rfbLog("Using image quality level %d for client %s\n", rfbLog("Using image quality level %d for client %s\n",
cl->tightQualityLevel, cl->host); cl->tightQualityLevel, cl->host);
@ -1178,7 +1185,7 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion)
fu->type = rfbFramebufferUpdate; fu->type = rfbFramebufferUpdate;
if (nUpdateRegionRects != 0xFFFF) { if (nUpdateRegionRects != 0xFFFF) {
fu->nRects = Swap16IfLE((CARD16)(sraRgnCountRects(updateCopyRegion) + fu->nRects = Swap16IfLE((uint16_t)(sraRgnCountRects(updateCopyRegion) +
nUpdateRegionRects + nUpdateRegionRects +
!!sendCursorShape + !!sendCursorPos)); !!sendCursorShape + !!sendCursorPos));
} else { } else {
@ -1516,7 +1523,7 @@ rfbSendSetColourMapEntries(cl, firstColour, nColours)
{ {
char buf[sz_rfbSetColourMapEntriesMsg + 256 * 3 * 2]; char buf[sz_rfbSetColourMapEntriesMsg + 256 * 3 * 2];
rfbSetColourMapEntriesMsg *scme = (rfbSetColourMapEntriesMsg *)buf; rfbSetColourMapEntriesMsg *scme = (rfbSetColourMapEntriesMsg *)buf;
CARD16 *rgb = (CARD16 *)(&buf[sz_rfbSetColourMapEntriesMsg]); uint16_t *rgb = (uint16_t *)(&buf[sz_rfbSetColourMapEntriesMsg]);
rfbColourMap* cm = &cl->screen->colourMap; rfbColourMap* cm = &cl->screen->colourMap;
int i, len; int i, len;

41
rre.c

@ -26,7 +26,6 @@
* USA. * USA.
*/ */
#include <stdio.h>
#include "rfb.h" #include "rfb.h"
/* /*
@ -43,10 +42,10 @@ static int rreAfterBufSize = 0;
static char *rreAfterBuf = NULL; static char *rreAfterBuf = NULL;
static int rreAfterBufLen; static int rreAfterBufLen;
static int subrectEncode8(CARD8 *data, int w, int h); static int subrectEncode8(uint8_t *data, int w, int h);
static int subrectEncode16(CARD16 *data, int w, int h); static int subrectEncode16(uint16_t *data, int w, int h);
static int subrectEncode32(CARD32 *data, int w, int h); static int subrectEncode32(uint32_t *data, int w, int h);
static CARD32 getBgColour(char *data, int size, int bpp); static uint32_t getBgColour(char *data, int size, int bpp);
/* /*
@ -91,13 +90,13 @@ rfbSendRectEncodingRRE(cl, x, y, w, h)
switch (cl->format.bitsPerPixel) { switch (cl->format.bitsPerPixel) {
case 8: case 8:
nSubrects = subrectEncode8((CARD8 *)rreBeforeBuf, w, h); nSubrects = subrectEncode8((uint8_t *)rreBeforeBuf, w, h);
break; break;
case 16: case 16:
nSubrects = subrectEncode16((CARD16 *)rreBeforeBuf, w, h); nSubrects = subrectEncode16((uint16_t *)rreBeforeBuf, w, h);
break; break;
case 32: case 32:
nSubrects = subrectEncode32((CARD32 *)rreBeforeBuf, w, h); nSubrects = subrectEncode32((uint32_t *)rreBeforeBuf, w, h);
break; break;
default: default:
rfbLog("getBgColour: bpp %d?\n",cl->format.bitsPerPixel); rfbLog("getBgColour: bpp %d?\n",cl->format.bitsPerPixel);
@ -177,25 +176,25 @@ rfbSendRectEncodingRRE(cl, x, y, w, h)
#define DEFINE_SUBRECT_ENCODE(bpp) \ #define DEFINE_SUBRECT_ENCODE(bpp) \
static int \ static int \
subrectEncode##bpp(data,w,h) \ subrectEncode##bpp(data,w,h) \
CARD##bpp *data; \ uint##bpp##_t *data; \
int w; \ int w; \
int h; \ int h; \
{ \ { \
CARD##bpp cl; \ uint##bpp##_t cl; \
rfbRectangle subrect; \ rfbRectangle subrect; \
int x,y; \ int x,y; \
int i,j; \ int i,j; \
int hx=0,hy,vx=0,vy; \ int hx=0,hy,vx=0,vy; \
int hyflag; \ int hyflag; \
CARD##bpp *seg; \ uint##bpp##_t *seg; \
CARD##bpp *line; \ uint##bpp##_t *line; \
int hw,hh,vw,vh; \ int hw,hh,vw,vh; \
int thex,they,thew,theh; \ int thex,they,thew,theh; \
int numsubs = 0; \ int numsubs = 0; \
int newLen; \ int newLen; \
CARD##bpp bg = (CARD##bpp)getBgColour((char*)data,w*h,bpp); \ uint##bpp##_t bg = (uint##bpp##_t)getBgColour((char*)data,w*h,bpp); \
\ \
*((CARD##bpp*)rreAfterBuf) = bg; \ *((uint##bpp##_t*)rreAfterBuf) = bg; \
\ \
rreAfterBufLen = (bpp/8); \ rreAfterBufLen = (bpp/8); \
\ \
@ -247,7 +246,7 @@ subrectEncode##bpp(data,w,h) \
return -1; \ return -1; \
\ \
numsubs += 1; \ numsubs += 1; \
*((CARD##bpp*)(rreAfterBuf + rreAfterBufLen)) = cl; \ *((uint##bpp##_t*)(rreAfterBuf + rreAfterBufLen)) = cl; \
rreAfterBufLen += (bpp/8); \ rreAfterBufLen += (bpp/8); \
memcpy(&rreAfterBuf[rreAfterBufLen],&subrect,sz_rfbRectangle); \ memcpy(&rreAfterBuf[rreAfterBufLen],&subrect,sz_rfbRectangle); \
rreAfterBufLen += sz_rfbRectangle; \ rreAfterBufLen += sz_rfbRectangle; \
@ -275,7 +274,7 @@ DEFINE_SUBRECT_ENCODE(32)
/* /*
* getBgColour() gets the most prevalent colour in a byte array. * getBgColour() gets the most prevalent colour in a byte array.
*/ */
static CARD32 static uint32_t
getBgColour(data,size,bpp) getBgColour(data,size,bpp)
char *data; char *data;
int size; int size;
@ -288,13 +287,13 @@ getBgColour(data,size,bpp)
int i,j,k; int i,j,k;
int maxcount = 0; int maxcount = 0;
CARD8 maxclr = 0; uint8_t maxclr = 0;
if (bpp != 8) { if (bpp != 8) {
if (bpp == 16) { if (bpp == 16) {
return ((CARD16 *)data)[0]; return ((uint16_t *)data)[0];
} else if (bpp == 32) { } else if (bpp == 32) {
return ((CARD32 *)data)[0]; return ((uint32_t *)data)[0];
} else { } else {
rfbLog("getBgColour: bpp %d?\n",bpp); rfbLog("getBgColour: bpp %d?\n",bpp);
exit(1); exit(1);
@ -306,7 +305,7 @@ getBgColour(data,size,bpp)
} }
for (j=0; j<size; j++) { for (j=0; j<size; j++) {
k = (int)(((CARD8 *)data)[j]); k = (int)(((uint8_t *)data)[j]);
if (k >= NUMCLRS) { if (k >= NUMCLRS) {
rfbLog("getBgColour: unusual colour = %d\n", k); rfbLog("getBgColour: unusual colour = %d\n", k);
exit(1); exit(1);
@ -314,7 +313,7 @@ getBgColour(data,size,bpp)
counts[k] += 1; counts[k] += 1;
if (counts[k] > maxcount) { if (counts[k] > maxcount) {
maxcount = counts[k]; maxcount = counts[k];
maxclr = ((CARD8 *)data)[j]; maxclr = ((uint8_t *)data)[j];
} }
} }

@ -39,8 +39,12 @@
* USA. * USA.
*/ */
#include <stdio.h> #include "rfb.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
#endif
#ifdef WIN32 #ifdef WIN32
#pragma warning (disable: 4018 4761) #pragma warning (disable: 4018 4761)
#define close closesocket #define close closesocket
@ -49,14 +53,23 @@
#define ETIMEDOUT WSAETIMEDOUT #define ETIMEDOUT WSAETIMEDOUT
#define write(sock,buf,len) send(sock,buf,len,0) #define write(sock,buf,len) send(sock,buf,len,0)
#else #else
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h> #include <sys/time.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <netdb.h> #include <netdb.h>
#include <unistd.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#endif
#if defined(__linux__) && defined(NEED_TIMEVAL) #if defined(__linux__) && defined(NEED_TIMEVAL)
struct timeval struct timeval
{ {
@ -64,7 +77,11 @@ struct timeval
} }
; ;
#endif #endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h> #include <fcntl.h>
#endif
#include <errno.h> #include <errno.h>
#ifdef USE_LIBWRAP #ifdef USE_LIBWRAP
@ -74,8 +91,6 @@ int allow_severity=LOG_INFO;
int deny_severity=LOG_WARNING; int deny_severity=LOG_WARNING;
#endif #endif
#include "rfb.h"
/*#ifndef WIN32 /*#ifndef WIN32
int max(int i,int j) { return(i<j?j:i); } int max(int i,int j) { return(i<j?j:i); }
#endif #endif

@ -8,9 +8,6 @@
#include "rfb.h" #include "rfb.h"
#include "sraRegion.h" #include "sraRegion.h"
#include <stdlib.h>
#include <stdio.h>
/* -=- Internal Span structure */ /* -=- Internal Span structure */
struct sraRegion; struct sraRegion;

@ -24,8 +24,6 @@
* USA. * USA.
*/ */
#include <stdio.h>
#include <stdlib.h>
#include "rfb.h" #include "rfb.h"
static const char* encNames[] = { static const char* encNames[] = {

@ -24,22 +24,22 @@
*/ */
static void static void
rfbInitOneRGBTable24 (CARD8 *table, int inMax, int outMax, int outShift,int swap); rfbInitOneRGBTable24 (uint8_t *table, int inMax, int outMax, int outShift,int swap);
static void static void
rfbInitColourMapSingleTable24(char **table, rfbPixelFormat *in, rfbInitColourMapSingleTable24(char **table, rfbPixelFormat *in,
rfbPixelFormat *out,rfbColourMap* colourMap) rfbPixelFormat *out,rfbColourMap* colourMap)
{ {
CARD32 i, r, g, b, outValue; uint32_t i, r, g, b, outValue;
CARD8 *t; uint8_t *t;
CARD8 c; uint8_t c;
unsigned int nEntries = 1 << in->bitsPerPixel; unsigned int nEntries = 1 << in->bitsPerPixel;
int shift = colourMap->is16?16:8; int shift = colourMap->is16?16:8;
if (*table) free(*table); if (*table) free(*table);
*table = (char *)malloc(nEntries * 3 + 1); *table = (char *)malloc(nEntries * 3 + 1);
t = (CARD8 *)*table; t = (uint8_t *)*table;
for (i = 0; i < nEntries; i++) { for (i = 0; i < nEntries; i++) {
r = g = b = 0; r = g = b = 0;
@ -57,7 +57,7 @@ rfbInitColourMapSingleTable24(char **table, rfbPixelFormat *in,
outValue = ((((r * (1 + out->redMax)) >> shift) << out->redShift) | outValue = ((((r * (1 + out->redMax)) >> shift) << out->redShift) |
(((g * (1 + out->greenMax)) >> shift) << out->greenShift) | (((g * (1 + out->greenMax)) >> shift) << out->greenShift) |
(((b * (1 + out->blueMax)) >> shift) << out->blueShift)); (((b * (1 + out->blueMax)) >> shift) << out->blueShift));
*(CARD32*)&t[3*i] = outValue; *(uint32_t*)&t[3*i] = outValue;
if(!rfbEndianTest) if(!rfbEndianTest)
memmove(t+3*i,t+3*i+1,3); memmove(t+3*i,t+3*i+1,3);
if (out->bigEndian != in->bigEndian) { if (out->bigEndian != in->bigEndian) {
@ -77,13 +77,13 @@ rfbInitTrueColourSingleTable24 (char **table, rfbPixelFormat *in,
{ {
int i,outValue; int i,outValue;
int inRed, inGreen, inBlue, outRed, outGreen, outBlue; int inRed, inGreen, inBlue, outRed, outGreen, outBlue;
CARD8 *t; uint8_t *t;
CARD8 c; uint8_t c;
int nEntries = 1 << in->bitsPerPixel; int nEntries = 1 << in->bitsPerPixel;
if (*table) free(*table); if (*table) free(*table);
*table = (char *)malloc(nEntries * 3 + 1); *table = (char *)malloc(nEntries * 3 + 1);
t = (CARD8 *)*table; t = (uint8_t *)*table;
for (i = 0; i < nEntries; i++) { for (i = 0; i < nEntries; i++) {
inRed = (i >> in->redShift) & in->redMax; inRed = (i >> in->redShift) & in->redMax;
@ -97,7 +97,7 @@ rfbInitTrueColourSingleTable24 (char **table, rfbPixelFormat *in,
outValue = ((outRed << out->redShift) | outValue = ((outRed << out->redShift) |
(outGreen << out->greenShift) | (outGreen << out->greenShift) |
(outBlue << out->blueShift)); (outBlue << out->blueShift));
*(CARD32*)&t[3*i] = outValue; *(uint32_t*)&t[3*i] = outValue;
if(!rfbEndianTest) if(!rfbEndianTest)
memmove(t+3*i,t+3*i+1,3); memmove(t+3*i,t+3*i+1,3);
if (out->bigEndian != in->bigEndian) { if (out->bigEndian != in->bigEndian) {
@ -116,14 +116,14 @@ static void
rfbInitTrueColourRGBTables24 (char **table, rfbPixelFormat *in, rfbInitTrueColourRGBTables24 (char **table, rfbPixelFormat *in,
rfbPixelFormat *out) rfbPixelFormat *out)
{ {
CARD8 *redTable; uint8_t *redTable;
CARD8 *greenTable; uint8_t *greenTable;
CARD8 *blueTable; uint8_t *blueTable;
if (*table) free(*table); if (*table) free(*table);
*table = (char *)malloc((in->redMax + in->greenMax + in->blueMax + 3) *table = (char *)malloc((in->redMax + in->greenMax + in->blueMax + 3)
* 3 + 1); * 3 + 1);
redTable = (CARD8 *)*table; redTable = (uint8_t *)*table;
greenTable = redTable + 3*(in->redMax + 1); greenTable = redTable + 3*(in->redMax + 1);
blueTable = greenTable + 3*(in->greenMax + 1); blueTable = greenTable + 3*(in->greenMax + 1);
@ -136,17 +136,17 @@ rfbInitTrueColourRGBTables24 (char **table, rfbPixelFormat *in,
} }
static void static void
rfbInitOneRGBTable24 (CARD8 *table, int inMax, int outMax, int outShift, rfbInitOneRGBTable24 (uint8_t *table, int inMax, int outMax, int outShift,
int swap) int swap)
{ {
int i; int i;
int nEntries = inMax + 1; int nEntries = inMax + 1;
CARD32 outValue; uint32_t outValue;
CARD8 c; uint8_t c;
for (i = 0; i < nEntries; i++) { for (i = 0; i < nEntries; i++) {
outValue = ((i * outMax + inMax / 2) / inMax) << outShift; outValue = ((i * outMax + inMax / 2) / inMax) << outShift;
*(CARD32 *)&table[3*i] = outValue; *(uint32_t *)&table[3*i] = outValue;
if(!rfbEndianTest) if(!rfbEndianTest)
memmove(table+3*i,table+3*i+1,3); memmove(table+3*i,table+3*i+1,3);
if (swap) { if (swap) {

@ -37,7 +37,7 @@
#error "It is included as part of translate.c" #error "It is included as part of translate.c"
#endif #endif
#define OUT_T CONCAT2E(CARD,OUT) #define OUT_T CONCAT3E(uint,OUT,_t)
#define SwapOUT(x) CONCAT2E(Swap,OUT(x)) #define SwapOUT(x) CONCAT2E(Swap,OUT(x))
#define rfbInitColourMapSingleTableOUT \ #define rfbInitColourMapSingleTableOUT \
CONCAT2E(rfbInitColourMapSingleTable,OUT) CONCAT2E(rfbInitColourMapSingleTable,OUT)
@ -46,9 +46,9 @@ static void
rfbInitColourMapSingleTableOUT(char **table, rfbPixelFormat *in, rfbInitColourMapSingleTableOUT(char **table, rfbPixelFormat *in,
rfbPixelFormat *out,rfbColourMap* colourMap) rfbPixelFormat *out,rfbColourMap* colourMap)
{ {
CARD32 i, r, g, b; uint32_t i, r, g, b;
OUT_T *t; OUT_T *t;
CARD32 nEntries = 1 << in->bitsPerPixel; uint32_t nEntries = 1 << in->bitsPerPixel;
int shift = colourMap->is16?16:8; int shift = colourMap->is16?16:8;
if (*table) free(*table); if (*table) free(*table);

@ -39,7 +39,7 @@
#error "It is included as part of translate.c" #error "It is included as part of translate.c"
#endif #endif
#define OUT_T CONCAT2E(CARD,OUT) #define OUT_T CONCAT3E(uint,OUT,_t)
#define SwapOUT(x) CONCAT2E(Swap,OUT(x)) #define SwapOUT(x) CONCAT2E(Swap,OUT(x))
#define rfbInitTrueColourSingleTableOUT \ #define rfbInitTrueColourSingleTableOUT \
CONCAT2E(rfbInitTrueColourSingleTable,OUT) CONCAT2E(rfbInitTrueColourSingleTable,OUT)

@ -53,19 +53,19 @@ rfbTranslateWithSingleTable24to24 (char *table, rfbPixelFormat *in,
int bytesBetweenInputLines, int bytesBetweenInputLines,
int width, int height) int width, int height)
{ {
CARD8 *ip = (CARD8 *)iptr; uint8_t *ip = (uint8_t *)iptr;
CARD8 *op = (CARD8 *)optr; uint8_t *op = (uint8_t *)optr;
int ipextra = bytesBetweenInputLines - width * 3; int ipextra = bytesBetweenInputLines - width * 3;
CARD8 *opLineEnd; uint8_t *opLineEnd;
CARD8 *t = (CARD8 *)table; uint8_t *t = (uint8_t *)table;
int shift = rfbEndianTest?0:8; int shift = rfbEndianTest?0:8;
CARD8 c; uint8_t c;
while (height > 0) { while (height > 0) {
opLineEnd = op + width*3; opLineEnd = op + width*3;
while (op < opLineEnd) { while (op < opLineEnd) {
*(CARD32*)op = t[((*(CARD32 *)ip)>>shift)&0x00ffffff]; *(uint32_t*)op = t[((*(uint32_t *)ip)>>shift)&0x00ffffff];
if(!rfbEndianTest) if(!rfbEndianTest)
memmove(op,op+1,3); memmove(op,op+1,3);
if (out->bigEndian != in->bigEndian) { if (out->bigEndian != in->bigEndian) {
@ -92,21 +92,21 @@ rfbTranslateWithRGBTables24to24 (char *table, rfbPixelFormat *in,
int bytesBetweenInputLines, int bytesBetweenInputLines,
int width, int height) int width, int height)
{ {
CARD8 *ip = (CARD8 *)iptr; uint8_t *ip = (uint8_t *)iptr;
CARD8 *op = (CARD8 *)optr; uint8_t *op = (uint8_t *)optr;
int ipextra = bytesBetweenInputLines - width*3; int ipextra = bytesBetweenInputLines - width*3;
CARD8 *opLineEnd; uint8_t *opLineEnd;
CARD8 *redTable = (CARD8 *)table; uint8_t *redTable = (uint8_t *)table;
CARD8 *greenTable = redTable + 3*(in->redMax + 1); uint8_t *greenTable = redTable + 3*(in->redMax + 1);
CARD8 *blueTable = greenTable + 3*(in->greenMax + 1); uint8_t *blueTable = greenTable + 3*(in->greenMax + 1);
CARD32 outValue,inValue; uint32_t outValue,inValue;
int shift = rfbEndianTest?0:8; int shift = rfbEndianTest?0:8;
while (height > 0) { while (height > 0) {
opLineEnd = op+3*width; opLineEnd = op+3*width;
while (op < opLineEnd) { while (op < opLineEnd) {
inValue = ((*(CARD32 *)ip)>>shift)&0x00ffffff; inValue = ((*(uint32_t *)ip)>>shift)&0x00ffffff;
outValue = (redTable[(inValue >> in->redShift) & in->redMax] | outValue = (redTable[(inValue >> in->redShift) & in->redMax] |
greenTable[(inValue >> in->greenShift) & in->greenMax] | greenTable[(inValue >> in->greenShift) & in->greenMax] |
blueTable[(inValue >> in->blueShift) & in->blueMax]); blueTable[(inValue >> in->blueShift) & in->blueMax]);
@ -121,8 +121,8 @@ rfbTranslateWithRGBTables24to24 (char *table, rfbPixelFormat *in,
#else #else
#define IN_T CONCAT2E(CARD,BPP) #define IN_T CONCAT3E(uint,BPP,_t)
#define OUT_T CONCAT2E(CARD,BPP) #define OUT_T CONCAT3E(uint,BPP,_t)
#define rfbTranslateWithSingleTable24toOUT \ #define rfbTranslateWithSingleTable24toOUT \
CONCAT4E(rfbTranslateWithSingleTable,24,to,BPP) CONCAT4E(rfbTranslateWithSingleTable,24,to,BPP)
#define rfbTranslateWithSingleTableINto24 \ #define rfbTranslateWithSingleTableINto24 \
@ -144,7 +144,7 @@ rfbTranslateWithSingleTable24toOUT (char *table, rfbPixelFormat *in,
int bytesBetweenInputLines, int bytesBetweenInputLines,
int width, int height) int width, int height)
{ {
CARD8 *ip = (CARD8 *)iptr; uint8_t *ip = (uint8_t *)iptr;
OUT_T *op = (OUT_T *)optr; OUT_T *op = (OUT_T *)optr;
int ipextra = bytesBetweenInputLines - width*3; int ipextra = bytesBetweenInputLines - width*3;
OUT_T *opLineEnd; OUT_T *opLineEnd;
@ -155,7 +155,7 @@ rfbTranslateWithSingleTable24toOUT (char *table, rfbPixelFormat *in,
opLineEnd = op + width; opLineEnd = op + width;
while (op < opLineEnd) { while (op < opLineEnd) {
*(op++) = t[((*(CARD32 *)ip)>>shift)&0x00ffffff]; *(op++) = t[((*(uint32_t *)ip)>>shift)&0x00ffffff];
ip+=3; ip+=3;
} }
@ -177,21 +177,21 @@ rfbTranslateWithRGBTables24toOUT (char *table, rfbPixelFormat *in,
int bytesBetweenInputLines, int bytesBetweenInputLines,
int width, int height) int width, int height)
{ {
CARD8 *ip = (CARD8 *)iptr; uint8_t *ip = (uint8_t *)iptr;
OUT_T *op = (OUT_T *)optr; OUT_T *op = (OUT_T *)optr;
int ipextra = bytesBetweenInputLines - width*3; int ipextra = bytesBetweenInputLines - width*3;
OUT_T *opLineEnd; OUT_T *opLineEnd;
OUT_T *redTable = (OUT_T *)table; OUT_T *redTable = (OUT_T *)table;
OUT_T *greenTable = redTable + in->redMax + 1; OUT_T *greenTable = redTable + in->redMax + 1;
OUT_T *blueTable = greenTable + in->greenMax + 1; OUT_T *blueTable = greenTable + in->greenMax + 1;
CARD32 inValue; uint32_t inValue;
int shift = rfbEndianTest?0:8; int shift = rfbEndianTest?0:8;
while (height > 0) { while (height > 0) {
opLineEnd = &op[width]; opLineEnd = &op[width];
while (op < opLineEnd) { while (op < opLineEnd) {
inValue = ((*(CARD32 *)ip)>>shift)&0x00ffffff; inValue = ((*(uint32_t *)ip)>>shift)&0x00ffffff;
*(op++) = (redTable[(inValue >> in->redShift) & in->redMax] | *(op++) = (redTable[(inValue >> in->redShift) & in->redMax] |
greenTable[(inValue >> in->greenShift) & in->greenMax] | greenTable[(inValue >> in->greenShift) & in->greenMax] |
blueTable[(inValue >> in->blueShift) & in->blueMax]); blueTable[(inValue >> in->blueShift) & in->blueMax]);
@ -215,10 +215,10 @@ rfbTranslateWithSingleTableINto24 (char *table, rfbPixelFormat *in,
int width, int height) int width, int height)
{ {
IN_T *ip = (IN_T *)iptr; IN_T *ip = (IN_T *)iptr;
CARD8 *op = (CARD8 *)optr; uint8_t *op = (uint8_t *)optr;
int ipextra = bytesBetweenInputLines / sizeof(IN_T) - width; int ipextra = bytesBetweenInputLines / sizeof(IN_T) - width;
CARD8 *opLineEnd; uint8_t *opLineEnd;
CARD8 *t = (CARD8 *)table; uint8_t *t = (uint8_t *)table;
while (height > 0) { while (height > 0) {
opLineEnd = op + width * 3; opLineEnd = op + width * 3;
@ -247,13 +247,13 @@ rfbTranslateWithRGBTablesINto24 (char *table, rfbPixelFormat *in,
int width, int height) int width, int height)
{ {
IN_T *ip = (IN_T *)iptr; IN_T *ip = (IN_T *)iptr;
CARD8 *op = (CARD8 *)optr; uint8_t *op = (uint8_t *)optr;
int ipextra = bytesBetweenInputLines / sizeof(IN_T) - width; int ipextra = bytesBetweenInputLines / sizeof(IN_T) - width;
CARD8 *opLineEnd; uint8_t *opLineEnd;
CARD8 *redTable = (CARD8 *)table; uint8_t *redTable = (uint8_t *)table;
CARD8 *greenTable = redTable + 3*(in->redMax + 1); uint8_t *greenTable = redTable + 3*(in->redMax + 1);
CARD8 *blueTable = greenTable + 3*(in->greenMax + 1); uint8_t *blueTable = greenTable + 3*(in->greenMax + 1);
CARD32 outValue; uint32_t outValue;
while (height > 0) { while (height > 0) {
opLineEnd = op+3*width; opLineEnd = op+3*width;

@ -39,8 +39,8 @@
#error "It is included as part of translate.c" #error "It is included as part of translate.c"
#endif #endif
#define IN_T CONCAT2E(CARD,IN) #define IN_T CONCAT3E(uint,IN,_t)
#define OUT_T CONCAT2E(CARD,OUT) #define OUT_T CONCAT3E(uint,OUT,_t)
#define rfbTranslateWithSingleTableINtoOUT \ #define rfbTranslateWithSingleTableINtoOUT \
CONCAT4E(rfbTranslateWithSingleTable,IN,to,OUT) CONCAT4E(rfbTranslateWithSingleTable,IN,to,OUT)
#define rfbTranslateWithRGBTablesINtoOUT \ #define rfbTranslateWithRGBTablesINtoOUT \

@ -87,7 +87,7 @@ static int qualityLevel;
typedef struct COLOR_LIST_s { typedef struct COLOR_LIST_s {
struct COLOR_LIST_s *next; struct COLOR_LIST_s *next;
int idx; int idx;
CARD32 rgb; uint32_t rgb;
} COLOR_LIST; } COLOR_LIST;
typedef struct PALETTE_ENTRY_s { typedef struct PALETTE_ENTRY_s {
@ -102,7 +102,7 @@ typedef struct PALETTE_s {
} PALETTE; } PALETTE;
static int paletteNumColors, paletteMaxColors; static int paletteNumColors, paletteMaxColors;
static CARD32 monoBackground, monoForeground; static uint32_t monoBackground, monoForeground;
static PALETTE palette; static PALETTE palette;
/* Pointers to dynamically-allocated buffers. */ /* Pointers to dynamically-allocated buffers. */
@ -119,18 +119,18 @@ static int *prevRowBuf = NULL;
/* Prototypes for static functions. */ /* Prototypes for static functions. */
static void FindBestSolidArea (rfbClientPtr cl, int x, int y, int w, int h, static void FindBestSolidArea (rfbClientPtr cl, int x, int y, int w, int h,
CARD32 colorValue, int *w_ptr, int *h_ptr); uint32_t colorValue, int *w_ptr, int *h_ptr);
static void ExtendSolidArea (rfbClientPtr cl, int x, int y, int w, int h, static void ExtendSolidArea (rfbClientPtr cl, int x, int y, int w, int h,
CARD32 colorValue, uint32_t colorValue,
int *x_ptr, int *y_ptr, int *w_ptr, int *h_ptr); int *x_ptr, int *y_ptr, int *w_ptr, int *h_ptr);
static Bool CheckSolidTile (rfbClientPtr cl, int x, int y, int w, int h, static Bool CheckSolidTile (rfbClientPtr cl, int x, int y, int w, int h,
CARD32 *colorPtr, Bool needSameColor); uint32_t *colorPtr, Bool needSameColor);
static Bool CheckSolidTile8 (rfbClientPtr cl, int x, int y, int w, int h, static Bool CheckSolidTile8 (rfbClientPtr cl, int x, int y, int w, int h,
CARD32 *colorPtr, Bool needSameColor); uint32_t *colorPtr, Bool needSameColor);
static Bool CheckSolidTile16 (rfbClientPtr cl, int x, int y, int w, int h, static Bool CheckSolidTile16 (rfbClientPtr cl, int x, int y, int w, int h,
CARD32 *colorPtr, Bool needSameColor); uint32_t *colorPtr, Bool needSameColor);
static Bool CheckSolidTile32 (rfbClientPtr cl, int x, int y, int w, int h, static Bool CheckSolidTile32 (rfbClientPtr cl, int x, int y, int w, int h,
CARD32 *colorPtr, Bool needSameColor); uint32_t *colorPtr, Bool needSameColor);
static Bool SendRectSimple (rfbClientPtr cl, int x, int y, int w, int h); static Bool SendRectSimple (rfbClientPtr cl, int x, int y, int w, int h);
static Bool SendSubrect (rfbClientPtr cl, int x, int y, int w, int h); static Bool SendSubrect (rfbClientPtr cl, int x, int y, int w, int h);
@ -151,20 +151,20 @@ static void FillPalette16(int count);
static void FillPalette32(int count); static void FillPalette32(int count);
static void PaletteReset(void); static void PaletteReset(void);
static int PaletteInsert(CARD32 rgb, int numPixels, int bpp); static int PaletteInsert(uint32_t rgb, int numPixels, int bpp);
static void Pack24(rfbClientPtr cl, char *buf, rfbPixelFormat *fmt, int count); static void Pack24(rfbClientPtr cl, char *buf, rfbPixelFormat *fmt, int count);
static void EncodeIndexedRect16(CARD8 *buf, int count); static void EncodeIndexedRect16(uint8_t *buf, int count);
static void EncodeIndexedRect32(CARD8 *buf, int count); static void EncodeIndexedRect32(uint8_t *buf, int count);
static void EncodeMonoRect8(CARD8 *buf, int w, int h); static void EncodeMonoRect8(uint8_t *buf, int w, int h);
static void EncodeMonoRect16(CARD8 *buf, int w, int h); static void EncodeMonoRect16(uint8_t *buf, int w, int h);
static void EncodeMonoRect32(CARD8 *buf, int w, int h); static void EncodeMonoRect32(uint8_t *buf, int w, int h);
static void FilterGradient24(rfbClientPtr cl, char *buf, rfbPixelFormat *fmt, int w, int h); static void FilterGradient24(rfbClientPtr cl, char *buf, rfbPixelFormat *fmt, int w, int h);
static void FilterGradient16(rfbClientPtr cl, CARD16 *buf, rfbPixelFormat *fmt, int w, int h); static void FilterGradient16(rfbClientPtr cl, uint16_t *buf, rfbPixelFormat *fmt, int w, int h);
static void FilterGradient32(rfbClientPtr cl, CARD32 *buf, rfbPixelFormat *fmt, int w, int h); static void FilterGradient32(rfbClientPtr cl, uint32_t *buf, rfbPixelFormat *fmt, int w, int h);
static int DetectSmoothImage(rfbClientPtr cl, rfbPixelFormat *fmt, int w, int h); static int DetectSmoothImage(rfbClientPtr cl, rfbPixelFormat *fmt, int w, int h);
static unsigned long DetectSmoothImage24(rfbClientPtr cl, rfbPixelFormat *fmt, int w, int h); static unsigned long DetectSmoothImage24(rfbClientPtr cl, rfbPixelFormat *fmt, int w, int h);
@ -173,10 +173,10 @@ static unsigned long DetectSmoothImage32(rfbClientPtr cl, rfbPixelFormat *fmt, i
static Bool SendJpegRect(rfbClientPtr cl, int x, int y, int w, int h, static Bool SendJpegRect(rfbClientPtr cl, int x, int y, int w, int h,
int quality); int quality);
static void PrepareRowForJpeg(rfbClientPtr cl, CARD8 *dst, int x, int y, int count); static void PrepareRowForJpeg(rfbClientPtr cl, uint8_t *dst, int x, int y, int count);
static void PrepareRowForJpeg24(rfbClientPtr cl, CARD8 *dst, int x, int y, int count); static void PrepareRowForJpeg24(rfbClientPtr cl, uint8_t *dst, int x, int y, int count);
static void PrepareRowForJpeg16(rfbClientPtr cl, CARD8 *dst, int x, int y, int count); static void PrepareRowForJpeg16(rfbClientPtr cl, uint8_t *dst, int x, int y, int count);
static void PrepareRowForJpeg32(rfbClientPtr cl, CARD8 *dst, int x, int y, int count); static void PrepareRowForJpeg32(rfbClientPtr cl, uint8_t *dst, int x, int y, int count);
static void JpegInitDestination(j_compress_ptr cinfo); static void JpegInitDestination(j_compress_ptr cinfo);
static boolean JpegEmptyOutputBuffer(j_compress_ptr cinfo); static boolean JpegEmptyOutputBuffer(j_compress_ptr cinfo);
@ -220,7 +220,7 @@ rfbSendRectEncodingTight(cl, x, y, w, h)
int x, y, w, h; int x, y, w, h;
{ {
int nMaxRows; int nMaxRows;
CARD32 colorValue; uint32_t colorValue;
int dx, dy, dw, dh; int dx, dy, dw, dh;
int x_best, y_best, w_best, h_best; int x_best, y_best, w_best, h_best;
char *fbptr; char *fbptr;
@ -356,7 +356,7 @@ static void
FindBestSolidArea(cl, x, y, w, h, colorValue, w_ptr, h_ptr) FindBestSolidArea(cl, x, y, w, h, colorValue, w_ptr, h_ptr)
rfbClientPtr cl; rfbClientPtr cl;
int x, y, w, h; int x, y, w, h;
CARD32 colorValue; uint32_t colorValue;
int *w_ptr, *h_ptr; int *w_ptr, *h_ptr;
{ {
int dx, dy, dw, dh; int dx, dy, dw, dh;
@ -398,7 +398,7 @@ static void
ExtendSolidArea(cl, x, y, w, h, colorValue, x_ptr, y_ptr, w_ptr, h_ptr) ExtendSolidArea(cl, x, y, w, h, colorValue, x_ptr, y_ptr, w_ptr, h_ptr)
rfbClientPtr cl; rfbClientPtr cl;
int x, y, w, h; int x, y, w, h;
CARD32 colorValue; uint32_t colorValue;
int *x_ptr, *y_ptr, *w_ptr, *h_ptr; int *x_ptr, *y_ptr, *w_ptr, *h_ptr;
{ {
int cx, cy; int cx, cy;
@ -432,7 +432,7 @@ ExtendSolidArea(cl, x, y, w, h, colorValue, x_ptr, y_ptr, w_ptr, h_ptr)
*w_ptr += cx - (*x_ptr + *w_ptr); *w_ptr += cx - (*x_ptr + *w_ptr);
} }
static Bool CheckSolidTile(rfbClientPtr cl, int x, int y, int w, int h, CARD32* colorPtr, Bool needSameColor) static Bool CheckSolidTile(rfbClientPtr cl, int x, int y, int w, int h, uint32_t* colorPtr, Bool needSameColor)
{ {
switch(cl->screen->rfbServerFormat.bitsPerPixel) { switch(cl->screen->rfbServerFormat.bitsPerPixel) {
case 32: case 32:
@ -447,17 +447,17 @@ static Bool CheckSolidTile(rfbClientPtr cl, int x, int y, int w, int h, CARD32*
#define DEFINE_CHECK_SOLID_FUNCTION(bpp) \ #define DEFINE_CHECK_SOLID_FUNCTION(bpp) \
\ \
static Bool \ static Bool \
CheckSolidTile##bpp(rfbClientPtr cl, int x, int y, int w, int h, CARD32* colorPtr, Bool needSameColor) \ CheckSolidTile##bpp(rfbClientPtr cl, int x, int y, int w, int h, uint32_t* colorPtr, Bool needSameColor) \
{ \ { \
CARD##bpp *fbptr; \ uint##bpp##_t *fbptr; \
CARD##bpp colorValue; \ uint##bpp##_t colorValue; \
int dx, dy; \ int dx, dy; \
\ \
fbptr = (CARD##bpp *) \ fbptr = (uint##bpp##_t *) \
&cl->screen->frameBuffer[y * cl->screen->paddedWidthInBytes + x * (bpp/8)]; \ &cl->screen->frameBuffer[y * cl->screen->paddedWidthInBytes + x * (bpp/8)]; \
\ \
colorValue = *fbptr; \ colorValue = *fbptr; \
if (needSameColor && (CARD32)colorValue != *colorPtr) \ if (needSameColor && (uint32_t)colorValue != *colorPtr) \
return FALSE; \ return FALSE; \
\ \
for (dy = 0; dy < h; dy++) { \ for (dy = 0; dy < h; dy++) { \
@ -465,10 +465,10 @@ CheckSolidTile##bpp(rfbClientPtr cl, int x, int y, int w, int h, CARD32* colorPt
if (colorValue != fbptr[dx]) \ if (colorValue != fbptr[dx]) \
return FALSE; \ return FALSE; \
} \ } \
fbptr = (CARD##bpp *)((CARD8 *)fbptr + cl->screen->paddedWidthInBytes); \ fbptr = (uint##bpp##_t *)((uint8_t *)fbptr + cl->screen->paddedWidthInBytes); \
} \ } \
\ \
*colorPtr = (CARD32)colorValue; \ *colorPtr = (uint32_t)colorValue; \
return TRUE; \ return TRUE; \
} }
@ -691,10 +691,10 @@ SendMonoRect(cl, w, h)
switch (cl->format.bitsPerPixel) { switch (cl->format.bitsPerPixel) {
case 32: case 32:
EncodeMonoRect32((CARD8 *)tightBeforeBuf, w, h); EncodeMonoRect32((uint8_t *)tightBeforeBuf, w, h);
((CARD32 *)tightAfterBuf)[0] = monoBackground; ((uint32_t *)tightAfterBuf)[0] = monoBackground;
((CARD32 *)tightAfterBuf)[1] = monoForeground; ((uint32_t *)tightAfterBuf)[1] = monoForeground;
if (usePixelFormat24) { if (usePixelFormat24) {
Pack24(cl, tightAfterBuf, &cl->format, 2); Pack24(cl, tightAfterBuf, &cl->format, 2);
paletteLen = 6; paletteLen = 6;
@ -707,10 +707,10 @@ SendMonoRect(cl, w, h)
break; break;
case 16: case 16:
EncodeMonoRect16((CARD8 *)tightBeforeBuf, w, h); EncodeMonoRect16((uint8_t *)tightBeforeBuf, w, h);
((CARD16 *)tightAfterBuf)[0] = (CARD16)monoBackground; ((uint16_t *)tightAfterBuf)[0] = (uint16_t)monoBackground;
((CARD16 *)tightAfterBuf)[1] = (CARD16)monoForeground; ((uint16_t *)tightAfterBuf)[1] = (uint16_t)monoForeground;
memcpy(&cl->updateBuf[cl->ublen], tightAfterBuf, 4); memcpy(&cl->updateBuf[cl->ublen], tightAfterBuf, 4);
cl->ublen += 4; cl->ublen += 4;
@ -718,7 +718,7 @@ SendMonoRect(cl, w, h)
break; break;
default: default:
EncodeMonoRect8((CARD8 *)tightBeforeBuf, w, h); EncodeMonoRect8((uint8_t *)tightBeforeBuf, w, h);
cl->updateBuf[cl->ublen++] = (char)monoBackground; cl->updateBuf[cl->ublen++] = (char)monoBackground;
cl->updateBuf[cl->ublen++] = (char)monoForeground; cl->updateBuf[cl->ublen++] = (char)monoForeground;
@ -754,10 +754,10 @@ SendIndexedRect(cl, w, h)
switch (cl->format.bitsPerPixel) { switch (cl->format.bitsPerPixel) {
case 32: case 32:
EncodeIndexedRect32((CARD8 *)tightBeforeBuf, w * h); EncodeIndexedRect32((uint8_t *)tightBeforeBuf, w * h);
for (i = 0; i < paletteNumColors; i++) { for (i = 0; i < paletteNumColors; i++) {
((CARD32 *)tightAfterBuf)[i] = ((uint32_t *)tightAfterBuf)[i] =
palette.entry[i].listNode->rgb; palette.entry[i].listNode->rgb;
} }
if (usePixelFormat24) { if (usePixelFormat24) {
@ -772,11 +772,11 @@ SendIndexedRect(cl, w, h)
break; break;
case 16: case 16:
EncodeIndexedRect16((CARD8 *)tightBeforeBuf, w * h); EncodeIndexedRect16((uint8_t *)tightBeforeBuf, w * h);
for (i = 0; i < paletteNumColors; i++) { for (i = 0; i < paletteNumColors; i++) {
((CARD16 *)tightAfterBuf)[i] = ((uint16_t *)tightAfterBuf)[i] =
(CARD16)palette.entry[i].listNode->rgb; (uint16_t)palette.entry[i].listNode->rgb;
} }
memcpy(&cl->updateBuf[cl->ublen], tightAfterBuf, paletteNumColors * 2); memcpy(&cl->updateBuf[cl->ublen], tightAfterBuf, paletteNumColors * 2);
@ -847,10 +847,10 @@ SendGradientRect(cl, w, h)
FilterGradient24(cl, tightBeforeBuf, &cl->format, w, h); FilterGradient24(cl, tightBeforeBuf, &cl->format, w, h);
len = 3; len = 3;
} else if (cl->format.bitsPerPixel == 32) { } else if (cl->format.bitsPerPixel == 32) {
FilterGradient32(cl, (CARD32 *)tightBeforeBuf, &cl->format, w, h); FilterGradient32(cl, (uint32_t *)tightBeforeBuf, &cl->format, w, h);
len = 4; len = 4;
} else { } else {
FilterGradient16(cl, (CARD16 *)tightBeforeBuf, &cl->format, w, h); FilterGradient16(cl, (uint16_t *)tightBeforeBuf, &cl->format, w, h);
len = 2; len = 2;
} }
@ -958,8 +958,8 @@ static void
FillPalette8(count) FillPalette8(count)
int count; int count;
{ {
CARD8 *data = (CARD8 *)tightBeforeBuf; uint8_t *data = (uint8_t *)tightBeforeBuf;
CARD8 c0, c1; uint8_t c0, c1;
int i, n0, n1; int i, n0, n1;
paletteNumColors = 0; paletteNumColors = 0;
@ -987,11 +987,11 @@ FillPalette8(count)
} }
if (i == count) { if (i == count) {
if (n0 > n1) { if (n0 > n1) {
monoBackground = (CARD32)c0; monoBackground = (uint32_t)c0;
monoForeground = (CARD32)c1; monoForeground = (uint32_t)c1;
} else { } else {
monoBackground = (CARD32)c1; monoBackground = (uint32_t)c1;
monoForeground = (CARD32)c0; monoForeground = (uint32_t)c0;
} }
paletteNumColors = 2; /* Two colors */ paletteNumColors = 2; /* Two colors */
} }
@ -1003,8 +1003,8 @@ static void \
FillPalette##bpp(count) \ FillPalette##bpp(count) \
int count; \ int count; \
{ \ { \
CARD##bpp *data = (CARD##bpp *)tightBeforeBuf; \ uint##bpp##_t *data = (uint##bpp##_t *)tightBeforeBuf; \
CARD##bpp c0, c1, ci; \ uint##bpp##_t c0, c1, ci; \
int i, n0, n1, ni; \ int i, n0, n1, ni; \
\ \
c0 = data[0]; \ c0 = data[0]; \
@ -1033,32 +1033,32 @@ FillPalette##bpp(count) \
} \ } \
if (i >= count) { \ if (i >= count) { \
if (n0 > n1) { \ if (n0 > n1) { \
monoBackground = (CARD32)c0; \ monoBackground = (uint32_t)c0; \
monoForeground = (CARD32)c1; \ monoForeground = (uint32_t)c1; \
} else { \ } else { \
monoBackground = (CARD32)c1; \ monoBackground = (uint32_t)c1; \
monoForeground = (CARD32)c0; \ monoForeground = (uint32_t)c0; \
} \ } \
paletteNumColors = 2; /* Two colors */ \ paletteNumColors = 2; /* Two colors */ \
return; \ return; \
} \ } \
\ \
PaletteReset(); \ PaletteReset(); \
PaletteInsert (c0, (CARD32)n0, bpp); \ PaletteInsert (c0, (uint32_t)n0, bpp); \
PaletteInsert (c1, (CARD32)n1, bpp); \ PaletteInsert (c1, (uint32_t)n1, bpp); \
\ \
ni = 1; \ ni = 1; \
for (i++; i < count; i++) { \ for (i++; i < count; i++) { \
if (data[i] == ci) { \ if (data[i] == ci) { \
ni++; \ ni++; \
} else { \ } else { \
if (!PaletteInsert (ci, (CARD32)ni, bpp)) \ if (!PaletteInsert (ci, (uint32_t)ni, bpp)) \
return; \ return; \
ci = data[i]; \ ci = data[i]; \
ni = 1; \ ni = 1; \
} \ } \
} \ } \
PaletteInsert (ci, (CARD32)ni, bpp); \ PaletteInsert (ci, (uint32_t)ni, bpp); \
} }
DEFINE_FILL_PALETTE_FUNCTION(16) DEFINE_FILL_PALETTE_FUNCTION(16)
@ -1081,7 +1081,7 @@ PaletteReset(void)
static int static int
PaletteInsert(rgb, numPixels, bpp) PaletteInsert(rgb, numPixels, bpp)
CARD32 rgb; uint32_t rgb;
int numPixels; int numPixels;
int bpp; int bpp;
{ {
@ -1158,11 +1158,11 @@ static void Pack24(cl, buf, fmt, count)
rfbPixelFormat *fmt; rfbPixelFormat *fmt;
int count; int count;
{ {
CARD32 *buf32; uint32_t *buf32;
CARD32 pix; uint32_t pix;
int r_shift, g_shift, b_shift; int r_shift, g_shift, b_shift;
buf32 = (CARD32 *)buf; buf32 = (uint32_t *)buf;
if (!cl->screen->rfbServerFormat.bigEndian == !fmt->bigEndian) { if (!cl->screen->rfbServerFormat.bigEndian == !fmt->bigEndian) {
r_shift = fmt->redShift; r_shift = fmt->redShift;
@ -1191,15 +1191,15 @@ static void Pack24(cl, buf, fmt, count)
\ \
static void \ static void \
EncodeIndexedRect##bpp(buf, count) \ EncodeIndexedRect##bpp(buf, count) \
CARD8 *buf; \ uint8_t *buf; \
int count; \ int count; \
{ \ { \
COLOR_LIST *pnode; \ COLOR_LIST *pnode; \
CARD##bpp *src; \ uint##bpp##_t *src; \
CARD##bpp rgb; \ uint##bpp##_t rgb; \
int rep = 0; \ int rep = 0; \
\ \
src = (CARD##bpp *) buf; \ src = (uint##bpp##_t *) buf; \
\ \
while (count--) { \ while (count--) { \
rgb = *src++; \ rgb = *src++; \
@ -1208,10 +1208,10 @@ EncodeIndexedRect##bpp(buf, count) \
} \ } \
pnode = palette.hash[HASH_FUNC##bpp(rgb)]; \ pnode = palette.hash[HASH_FUNC##bpp(rgb)]; \
while (pnode != NULL) { \ while (pnode != NULL) { \
if ((CARD##bpp)pnode->rgb == rgb) { \ if ((uint##bpp##_t)pnode->rgb == rgb) { \
*buf++ = (CARD8)pnode->idx; \ *buf++ = (uint8_t)pnode->idx; \
while (rep) { \ while (rep) { \
*buf++ = (CARD8)pnode->idx; \ *buf++ = (uint8_t)pnode->idx; \
rep--; \ rep--; \
} \ } \
break; \ break; \
@ -1228,17 +1228,17 @@ DEFINE_IDX_ENCODE_FUNCTION(32)
\ \
static void \ static void \
EncodeMonoRect##bpp(buf, w, h) \ EncodeMonoRect##bpp(buf, w, h) \
CARD8 *buf; \ uint8_t *buf; \
int w, h; \ int w, h; \
{ \ { \
CARD##bpp *ptr; \ uint##bpp##_t *ptr; \
CARD##bpp bg; \ uint##bpp##_t bg; \
unsigned int value, mask; \ unsigned int value, mask; \
int aligned_width; \ int aligned_width; \
int x, y, bg_bits; \ int x, y, bg_bits; \
\ \
ptr = (CARD##bpp *) buf; \ ptr = (uint##bpp##_t *) buf; \
bg = (CARD##bpp) monoBackground; \ bg = (uint##bpp##_t) monoBackground; \
aligned_width = w - w % 8; \ aligned_width = w - w % 8; \
\ \
for (y = 0; y < h; y++) { \ for (y = 0; y < h; y++) { \
@ -1259,7 +1259,7 @@ EncodeMonoRect##bpp(buf, w, h) \
value |= mask; \ value |= mask; \
} \ } \
} \ } \
*buf++ = (CARD8)value; \ *buf++ = (uint8_t)value; \
} \ } \
\ \
mask = 0x80; \ mask = 0x80; \
@ -1273,7 +1273,7 @@ EncodeMonoRect##bpp(buf, w, h) \
} \ } \
mask >>= 1; \ mask >>= 1; \
} \ } \
*buf++ = (CARD8)value; \ *buf++ = (uint8_t)value; \
} \ } \
} }
@ -1295,15 +1295,15 @@ FilterGradient24(cl, buf, fmt, w, h)
rfbPixelFormat *fmt; rfbPixelFormat *fmt;
int w, h; int w, h;
{ {
CARD32 *buf32; uint32_t *buf32;
CARD32 pix32; uint32_t pix32;
int *prevRowPtr; int *prevRowPtr;
int shiftBits[3]; int shiftBits[3];
int pixHere[3], pixUpper[3], pixLeft[3], pixUpperLeft[3]; int pixHere[3], pixUpper[3], pixLeft[3], pixUpperLeft[3];
int prediction; int prediction;
int x, y, c; int x, y, c;
buf32 = (CARD32 *)buf; buf32 = (uint32_t *)buf;
memset (prevRowBuf, 0, w * 3 * sizeof(int)); memset (prevRowBuf, 0, w * 3 * sizeof(int));
if (!cl->screen->rfbServerFormat.bigEndian == !fmt->bigEndian) { if (!cl->screen->rfbServerFormat.bigEndian == !fmt->bigEndian) {
@ -1353,11 +1353,11 @@ FilterGradient24(cl, buf, fmt, w, h)
static void \ static void \
FilterGradient##bpp(cl, buf, fmt, w, h) \ FilterGradient##bpp(cl, buf, fmt, w, h) \
rfbClientPtr cl; \ rfbClientPtr cl; \
CARD##bpp *buf; \ uint##bpp##_t *buf; \
rfbPixelFormat *fmt; \ rfbPixelFormat *fmt; \
int w, h; \ int w, h; \
{ \ { \
CARD##bpp pix, diff; \ uint##bpp##_t pix, diff; \
Bool endianMismatch; \ Bool endianMismatch; \
int *prevRowPtr; \ int *prevRowPtr; \
int maxColor[3], shiftBits[3]; \ int maxColor[3], shiftBits[3]; \
@ -1539,7 +1539,7 @@ DetectSmoothImage##bpp (cl, fmt, w, h)
int w, h; \ int w, h; \
{ \ { \
Bool endianMismatch; \ Bool endianMismatch; \
CARD##bpp pix; \ uint##bpp##_t pix; \
int maxColor[3], shiftBits[3]; \ int maxColor[3], shiftBits[3]; \
int x, y, d, dx, c; \ int x, y, d, dx, c; \
int diffStat[256]; \ int diffStat[256]; \
@ -1561,7 +1561,7 @@ DetectSmoothImage##bpp (cl, fmt, w, h)
y = 0, x = 0; \ y = 0, x = 0; \
while (y < h && x < w) { \ while (y < h && x < w) { \
for (d = 0; d < h - y && d < w - x - DETECT_SUBROW_WIDTH; d++) { \ for (d = 0; d < h - y && d < w - x - DETECT_SUBROW_WIDTH; d++) { \
pix = ((CARD##bpp *)tightBeforeBuf)[(y+d)*w+x+d]; \ pix = ((uint##bpp##_t *)tightBeforeBuf)[(y+d)*w+x+d]; \
if (endianMismatch) { \ if (endianMismatch) { \
pix = Swap##bpp(pix); \ pix = Swap##bpp(pix); \
} \ } \
@ -1569,7 +1569,7 @@ DetectSmoothImage##bpp (cl, fmt, w, h)
left[c] = (int)(pix >> shiftBits[c] & maxColor[c]); \ left[c] = (int)(pix >> shiftBits[c] & maxColor[c]); \
} \ } \
for (dx = 1; dx <= DETECT_SUBROW_WIDTH; dx++) { \ for (dx = 1; dx <= DETECT_SUBROW_WIDTH; dx++) { \
pix = ((CARD##bpp *)tightBeforeBuf)[(y+d)*w+x+d+dx]; \ pix = ((uint##bpp##_t *)tightBeforeBuf)[(y+d)*w+x+d+dx]; \
if (endianMismatch) { \ if (endianMismatch) { \
pix = Swap##bpp(pix); \ pix = Swap##bpp(pix); \
} \ } \
@ -1631,14 +1631,14 @@ SendJpegRect(cl, x, y, w, h, quality)
{ {
struct jpeg_compress_struct cinfo; struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr; struct jpeg_error_mgr jerr;
CARD8 *srcBuf; uint8_t *srcBuf;
JSAMPROW rowPointer[1]; JSAMPROW rowPointer[1];
int dy; int dy;
if (cl->screen->rfbServerFormat.bitsPerPixel == 8) if (cl->screen->rfbServerFormat.bitsPerPixel == 8)
return SendFullColorRect(cl, w, h); return SendFullColorRect(cl, w, h);
srcBuf = (CARD8 *)malloc(w * 3); srcBuf = (uint8_t *)malloc(w * 3);
if (srcBuf == NULL) { if (srcBuf == NULL) {
return SendFullColorRect(cl, w, h); return SendFullColorRect(cl, w, h);
} }
@ -1689,7 +1689,7 @@ SendJpegRect(cl, x, y, w, h, quality)
static void static void
PrepareRowForJpeg(cl, dst, x, y, count) PrepareRowForJpeg(cl, dst, x, y, count)
rfbClientPtr cl; rfbClientPtr cl;
CARD8 *dst; uint8_t *dst;
int x, y, count; int x, y, count;
{ {
if (cl->screen->rfbServerFormat.bitsPerPixel == 32) { if (cl->screen->rfbServerFormat.bitsPerPixel == 32) {
@ -1709,20 +1709,20 @@ PrepareRowForJpeg(cl, dst, x, y, count)
static void static void
PrepareRowForJpeg24(cl, dst, x, y, count) PrepareRowForJpeg24(cl, dst, x, y, count)
rfbClientPtr cl; rfbClientPtr cl;
CARD8 *dst; uint8_t *dst;
int x, y, count; int x, y, count;
{ {
CARD32 *fbptr; uint32_t *fbptr;
CARD32 pix; uint32_t pix;
fbptr = (CARD32 *) fbptr = (uint32_t *)
&cl->screen->frameBuffer[y * cl->screen->paddedWidthInBytes + x * 4]; &cl->screen->frameBuffer[y * cl->screen->paddedWidthInBytes + x * 4];
while (count--) { while (count--) {
pix = *fbptr++; pix = *fbptr++;
*dst++ = (CARD8)(pix >> cl->screen->rfbServerFormat.redShift); *dst++ = (uint8_t)(pix >> cl->screen->rfbServerFormat.redShift);
*dst++ = (CARD8)(pix >> cl->screen->rfbServerFormat.greenShift); *dst++ = (uint8_t)(pix >> cl->screen->rfbServerFormat.greenShift);
*dst++ = (CARD8)(pix >> cl->screen->rfbServerFormat.blueShift); *dst++ = (uint8_t)(pix >> cl->screen->rfbServerFormat.blueShift);
} }
} }
@ -1731,14 +1731,14 @@ PrepareRowForJpeg24(cl, dst, x, y, count)
static void \ static void \
PrepareRowForJpeg##bpp(cl, dst, x, y, count) \ PrepareRowForJpeg##bpp(cl, dst, x, y, count) \
rfbClientPtr cl; \ rfbClientPtr cl; \
CARD8 *dst; \ uint8_t *dst; \
int x, y, count; \ int x, y, count; \
{ \ { \
CARD##bpp *fbptr; \ uint##bpp##_t *fbptr; \
CARD##bpp pix; \ uint##bpp##_t pix; \
int inRed, inGreen, inBlue; \ int inRed, inGreen, inBlue; \
\ \
fbptr = (CARD##bpp *) \ fbptr = (uint##bpp##_t *) \
&cl->screen->frameBuffer[y * cl->screen->paddedWidthInBytes + \ &cl->screen->frameBuffer[y * cl->screen->paddedWidthInBytes + \
x * (bpp / 8)]; \ x * (bpp / 8)]; \
\ \
@ -1752,11 +1752,11 @@ PrepareRowForJpeg##bpp(cl, dst, x, y, count)
inBlue = (int) \ inBlue = (int) \
(pix >> cl->screen->rfbServerFormat.blueShift & cl->screen->rfbServerFormat.blueMax); \ (pix >> cl->screen->rfbServerFormat.blueShift & cl->screen->rfbServerFormat.blueMax); \
\ \
*dst++ = (CARD8)((inRed * 255 + cl->screen->rfbServerFormat.redMax / 2) / \ *dst++ = (uint8_t)((inRed * 255 + cl->screen->rfbServerFormat.redMax / 2) / \
cl->screen->rfbServerFormat.redMax); \ cl->screen->rfbServerFormat.redMax); \
*dst++ = (CARD8)((inGreen * 255 + cl->screen->rfbServerFormat.greenMax / 2) / \ *dst++ = (uint8_t)((inGreen * 255 + cl->screen->rfbServerFormat.greenMax / 2) / \
cl->screen->rfbServerFormat.greenMax); \ cl->screen->rfbServerFormat.greenMax); \
*dst++ = (CARD8)((inBlue * 255 + cl->screen->rfbServerFormat.blueMax / 2) / \ *dst++ = (uint8_t)((inBlue * 255 + cl->screen->rfbServerFormat.blueMax / 2) / \
cl->screen->rfbServerFormat.blueMax); \ cl->screen->rfbServerFormat.blueMax); \
} \ } \
} }

@ -23,8 +23,6 @@
* USA. * USA.
*/ */
#include <stdio.h>
#include <stdlib.h>
#include "rfb.h" #include "rfb.h"
#include "sraRegion.h" #include "sraRegion.h"
@ -60,6 +58,8 @@ static const rfbPixelFormat BGR233Format = {
#define CONCAT2(a,b) a##b #define CONCAT2(a,b) a##b
#define CONCAT2E(a,b) CONCAT2(a,b) #define CONCAT2E(a,b) CONCAT2(a,b)
#define CONCAT3(a,b,c) a##b##c
#define CONCAT3E(a,b,c) CONCAT3(a,b,c)
#define CONCAT4(a,b,c,d) a##b##c##d #define CONCAT4(a,b,c,d) a##b##c##d
#define CONCAT4E(a,b,c,d) CONCAT4(a,b,c,d) #define CONCAT4E(a,b,c,d) CONCAT4(a,b,c,d)
@ -364,7 +364,7 @@ rfbSetClientColourMapBGR233(cl)
{ {
char buf[sz_rfbSetColourMapEntriesMsg + 256 * 3 * 2]; char buf[sz_rfbSetColourMapEntriesMsg + 256 * 3 * 2];
rfbSetColourMapEntriesMsg *scme = (rfbSetColourMapEntriesMsg *)buf; rfbSetColourMapEntriesMsg *scme = (rfbSetColourMapEntriesMsg *)buf;
CARD16 *rgb = (CARD16 *)(&buf[sz_rfbSetColourMapEntriesMsg]); uint16_t *rgb = (uint16_t *)(&buf[sz_rfbSetColourMapEntriesMsg]);
int i, len; int i, len;
int r, g, b; int r, g, b;

@ -21,21 +21,27 @@
* vncauth.c - Functions for VNC password management and authentication. * vncauth.c - Functions for VNC password management and authentication.
*/ */
#include <stdio.h> #include "rfb.h"
#include <stdlib.h> #include "d3des.h"
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h> #include <sys/stat.h>
#endif
#include <time.h> #include <time.h>
#ifdef WIN32 #ifdef WIN32
#define srandom srand #define srandom srand
#define random rand #define random rand
#else #else
#include <sys/time.h> #include <sys/time.h>
#endif #endif
#include "rfb.h"
#include "d3des.h"
/* /*

@ -30,7 +30,6 @@
* or send email to feedback@developvnc.org. * or send email to feedback@developvnc.org.
*/ */
#include <stdio.h>
#include "rfb.h" #include "rfb.h"
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ

@ -23,7 +23,6 @@
// Routines to implement Zlib Run-length Encoding (ZRLE). // Routines to implement Zlib Run-length Encoding (ZRLE).
// //
#include <stdio.h>
extern "C" { extern "C" {
#include "rfb.h" #include "rfb.h"
} }
@ -158,7 +157,7 @@ Bool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h)
bytesToCopy = mos.length() - i; bytesToCopy = mos.length() - i;
} }
memcpy(cl->updateBuf+cl->ublen, (CARD8*)mos.data() + i, bytesToCopy); memcpy(cl->updateBuf+cl->ublen, (uint8_t*)mos.data() + i, bytesToCopy);
cl->ublen += bytesToCopy; cl->ublen += bytesToCopy;
i += bytesToCopy; i += bytesToCopy;

Loading…
Cancel
Save