vncsnapshot-1.2a/0040755005671200567000000000000010120152273013447 5ustar grantharmonyvncsnapshot-1.2a/BUILD.unix0100644005671200567000000000434610117721111015216 0ustar grantharmonyBUILDING vncsnapshot (1.0 release) for Unix and Linux ====================================================== This distibution requires two third-party libraries for successfull compilation. They are NOT included in this archive. These are are zlib and JPEG libraries freely available in the source form from following locations: JPEG library: Home page: http://www.ijg.org/ Tar/GZ: http://www.ijg.org/files/jpegsrc.v6b.tar.gz Zip: ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/jpegsr6.zip zlib library: Home page http://www.gzip.org/zlib/ Tar/GZ: http://www.gzip.org/zlib/zlib-1.1.4.tar.gz Tar/BZ2: http://www.gzip.org/zlib/zlib-1.1.4.tar.bz2 Zip: http://www.gzip.org/zlib/zlib114.zip You *must* use zlib 1.1.4 or later. Earlier versions have a significant security hole; see the zlib home page for details. If your system already has these packages installed, simply edit the Makefile to use the correct include and library paths. The defaults in the Makefile are suitable for most systems with the libraries in the standard locations (/usr or /usr/local). If you do not have them, please download the packages and compile. They can be installed anywhere (root permission is not required), as long as you edit the Makefile appropriately. The Makefile does not include an 'install' target; to install, simply copy 'vncsnapshot' to the desired location (such as /usr/local/bin). Other Makefile configuration items: EXTRALIBS needs to be set to any extra libraries you need. On Solaris, this will be '-lsocket -lnsl'. EXTRAINCLUDES needs to be set to any extra include options you need. Most systems should not require anything extra here. CC is set 'gcc'. On non-Linux systems, such as Solaris, you may want to set this to something else such as 'cc' or 'acc'. Likewise, CXX is set 'g++'. Again, you may want to set this to something else such as 'CC'. CDEBUGFLAGS is set to '-O2'. This is appropriate for gcc; other compilers may want '-O'; or, you may wish to set this to '-g' for debugging. You can also look at make_release_bin; this script is used by the maintainer to build vncsnapshot on various flavours of Unix and Linux. < $Id: BUILD.unix,v 1.4 2004/09/09 00:22:33 grmcdorman Exp $ > vncsnapshot-1.2a/BUGS0100644005671200567000000000150210120152273014125 0ustar grantharmonyKnown bugs in vncsnapshot: * The cursor may or may not appear in the snapshot. It is known to not appear in snapshots of Windows Tight VNC servers when connecting normally, and to appear when connecting via the server's 'Add New Client' option (i.e. -listen option for vncsnapshot). In addition, moving the cursor while vncsnapshot is connecting may result in the cursor being included in the snapshot. The -cursor and -nocursor attempt to control this, but are only workable for recent TightVNC servers. * When getting multiple snapshots (i.e. using -count with a value greater than 1) the second and subsequent images are messed up with some VNC servers. This has been observed with the KDE server ("KDE Desktop Sharing"), and with Ultra VNC. < $Id: BUGS,v 1.5 2004/09/09 22:10:03 grmcdorman Exp $ > vncsnapshot-1.2a/BUILD0100644005671200567000000000023407431317710014237 0ustar grantharmonyOn Windows systems, please read BUILD.win32. On Unix and Linux systems, please read BUILD.unix. < $Id: BUILD,v 1.2 2002/02/09 22:16:40 grmcdorman Exp $ > vncsnapshot-1.2a/RELEASE-NOTES.txt0100644005671200567000000000155310117721111016156 0ustar grantharmonyRelease Notes for VNC Snapshot 1.2 ========================================= New in this release is the ability to get multiple snapshots, using the -count and -fps options. This release also includes a version of vncpasswd usable on Windows. vncpasswd is also built on Unix/Linux systems to allow you to use it without a full VNC installation. Bug fixes include: * Under some circumstances, a blank screen would be captured even if -ignoreblank was specified. * Makefiles have been edited to work better on some non-Linux systems. * Compilation errors on Mac OS X (Darwin) have been fixed A new build script, make_release_bin, for Linux/Unix systems is also provided; it is intended for use by the maintainer to create compiled versions of the programs on multiple platforms with minimum pain. < $Id: RELEASE-NOTES.txt,v 1.4 2004/09/09 00:22:33 grmcdorman Exp $ > vncsnapshot-1.2a/BUILD.win320100644005671200567000000000271410117721111015172 0ustar grantharmonyBUILDING vncsnapshot (1.0 release) for Windows ============================================== This distibution requires two third-party libraries for successfull compilation. They are NOT included in this archive. These are are zlib and JPEG libraries freely available in the source form from following locations: JPEG library: Home page: http://www.ijg.org/ Tar/GZ: http://www.ijg.org/files/jpegsrc.v6b.tar.gz Zip: ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/jpegsr6.zip zlib library: Version 1.2.1 or later. 1.1.4 is no longer supported Home page http://www.gzip.org/zlib/ See the home page for download locations. As of this writing, there are two primary mirrors (France and US); formats include tar.gz, tar.bz2, and zip. The workspaces assume the 1.2.1 Zlib source. However, if you wish to use the 1.1.4 source, you may do so by removing the source file list for the Zlib project and replacing it with the 1.1.4 source file list. Please download these libraries prior to compilation. After you have downloaded and unpacked libraries, place their source files to the locations listed below, NOT overriding existing files: zlib library: zlib/ JPEG library: libjpeg You can then build using Microsoft's Visual Studio. Output is placed in Debug or Release, depending on the type of build you've done. Borland C++ builds are not supported at the moment. < $Id: BUILD.win32,v 1.4 2004/09/09 00:22:33 grmcdorman Exp $ > vncsnapshot-1.2a/CHANGE-LOG.txt0100644005671200567000000000360610120152231015550 0ustar grantharmony1.2a * Fixed bug where the snapshot, by default, would start 60 pixels down from the top of the screen * Fixed up Windows zlib.dsp (1.2 release was still 1.1.x zlib.dsp, despite change log and README entries) * Minor enhancments to developer make_release_bin and run-sf-compiles scripts * Fix to manual page formatting * Missing change log entry for 1.2 added (-count/-fps options not mentioned, but are in README) 1.2 * Upgraded Windows build to Zlib 1.2.1 * Added vncpasswd to the build * Fixed bug where snapshot thought it had got a non-blank screen when in fact it hadn't (bug resulted in blank screen captures) * Fixed to compile on Mac OS X * Added -count and -fps options for multiple screen shots (does not work with all servers) 1.1 * Included UltraVNC RFB definitions in header files. UltraVNC encodings and scalings are not supported yet, however. * Merged Tight VNC 1.2.8 and RealVNC 3.3.7 sources * Merged Tight VNC 1.2.7 sources * When saving a sub-area of the server's screen, only that part is fetched (formerly the entire screen was fetched) * New '-ignoreblank' and '-allowblank' to work around RealVNC servers that send an initial blank screen. * Now supports '-cursor' and '-nocursor' options; unfortunately these only work for recent TightVNC servers * Merged RealVNC 3.3.6 sources * Now supports both TightVNC 'tight' and 'zlib' encodings and RealVNC 'zrle' encoding. * Dropped beta status as I got no bug reports (in fact, no reports at all) * -tunnel and -via options now supported for all platforms (not tested on Windows) * Fix: coordinates of -0 (0 pixels from right/bottom edge) now work * Win32 Release build works 1.0 Beta 2 * Added manual page * Updated zlib dependancy to version without security vunerability * Updated web page to include author's e-mail * Updated BUILD.unix and BUILD.win32 to point to official JPEG and zlib sites vncsnapshot-1.2a/MANIFEST0100644005671200567000000000213010117721111014570 0ustar grantharmonyFiles included in this archive: BUGS BUILD BUILD.unix BUILD.win32 CHANGE-LOG.txt MANIFEST Makefile README RELEASE-NOTES.txt RELEASE-NOTES-1.1.txt argsresources.c buffer.c cursor.c d3des.c d3des.h getpass.c listen.c make_release_bin rfb.h rfbproto.c rfbproto.h sockets.cxx stdhdrs.h tunnel.c version.h vncauth.c vncauth.h vncpasswd.c vncpasswd.dsp vncsnapshot.c vncsnapshot.dsp vncsnapshot.dsw vncsnapshot.h vncsnapshot.man1 web-page.html zrle.cxx libjpeg/Makefile.bcc32 libjpeg/jconfig.h libjpeg/jmorecfg.h libjpeg/libjpeg.dsp protocols/corre.c protocols/hextile.c protocols/rre.c protocols/tight.c protocols/zlib.c 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/Makefile 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/rdr.dsp rdr/types.h rfb/zrleDecode.h rfb/zrleEncode.h zlib/Makefile.bcc32 zlib/zlib.dsp < $Id: MANIFEST,v 1.6 2004/09/09 00:22:33 grmcdorman Exp $ > vncsnapshot-1.2a/Makefile0100644005671200567000000000522010117721111015102 0ustar grantharmony# Makefile for vncsnapshot, Unix/Linux platforms. # # $Id: Makefile,v 1.6 2004/09/09 00:22:33 grmcdorman Exp $ # # INSTALLER: Adjust these lines to point to your installation's location of # Zlib and JPEG lib. ZLIB_INCLUDE = -I/usr/local/include ZLIB_LIB = -L/usr/local/lib -lz JPEG_INCLUDE = -I/usr/local/include JPEG_LIB = -L/usr/local/lib -ljpeg # Other libraries: # SOLARIS: # EXTRALIBS = -lsocket -lnsl # EXTRAINCLUDES = # Linux: EXTRALIBS = EXTRAINCLUDES = # Compilation Flags. Season to taste. CC = gcc CDEBUGFLAGS = -O2 -Wall CXX=g++ # You shouldn't need to change anything below. INCLUDES = -I. $(ZLIB_INCLUDE) $(JPEG_INCLUDE) $(EXTRAINCLUDES) CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) CXXFLAGS = $(CFLAGS) # Solaris 8 uses CCC and CCFLAGS CCC=$(CXX) CCFLAGS = $(CFLAGS) .SUFFIXES: .cxx # SRCS = \ argsresources.c \ buffer.c \ cursor.c \ listen.c \ rfbproto.c \ sockets.cxx \ tunnel.c \ vncsnapshot.c \ d3des.c vncauth.c \ zrle.cxx \ PASSWD_SRCS = vncpasswd.c vncauth.c d3des.c OBJS1 = $(SRCS:.c=.o) OBJS = $(OBJS1:.cxx=.o) PASSWD_OBJS1 = $(PASSWD_SRCS:.c=.o) PASSWD_OBJS = $(PASSWD_OBJS1:.cxx=.o) SUBDIRS=rdr.dir all: $(SUBDIRS:.dir=.all) vncsnapshot vncpasswd vncsnapshot: $(OBJS) # ${CXX} ${CXXFLAGS} ${LDFLAGS} -o $@ $(OBJS) rdr/librdr.a $(ZLIB_LIB) $(JPEG_LIB) $(EXTRALIBS) $(LINK.cc) $(CDEBUGFLAGS) -o $@ $(OBJS) rdr/librdr.a $(ZLIB_LIB) $(JPEG_LIB) $(EXTRALIBS) vncpasswd: $(PASSWD_OBJS) # ${CXX} ${CXXFLAGS} ${LDFLAGS} -o $@ $(PASSWD_OBJS) $(LINK.c) $(CDEBUGFLAGS) -o $@ $(PASSWD_OBJS) clean: $(SUBDIRS:.dir=.clean) $(FINAL_SUBDIRS:.dir=.clean) -rm -f $(OBJS) $(PASSWD_OBJS) vncpasswd vncsnapshot core reallyclean: clean $(SUBDIRS:.dir=.reallyclean) $(FINAL_SUBDIRS:.dir=.reallyclean) -rm -f *~ rdr.all: cd rdr;make all rdr.clean: cd rdr;make clean rdr.reallyclean: cd rdr;make reallyclean vncpasswd.all: cd vncpasswd;make all vncpasswd.clean: cd vncpasswd;make clean vncpasswd.reallyclean: cd vncpasswd;make reallyclean .cxx.o: $(COMPILE.cc) -o $@ $< # dependancies argsresources.o: argsresources.c vncsnapshot.h rfb.h rfbproto.h buffer.o: buffer.c vncsnapshot.h rfb.h rfbproto.h cursor.o: cursor.c vncsnapshot.h rfb.h rfbproto.h listen.o: listen.c vncsnapshot.h rfb.h rfbproto.h rfbproto.o: rfbproto.c vncsnapshot.h rfb.h rfbproto.h vncauth.h \ protocols/rre.c protocols/corre.c \ protocols/hextile.c protocols/zlib.c protocols/tight.c sockets.o: sockets.cxx vncsnapshot.h rfb.h rfbproto.h tunnel.o: tunnel.c vncsnapshot.h rfb.h rfbproto.h vncsnapshot.o: vncsnapshot.c vncsnapshot.h rfb.h rfbproto.h vncauth.o: vncauth.c stdhdrs.h rfb.h rfbproto.h vncauth.h d3des.h zrle.o: zrle.cxx vncsnapshot.h vncpasswd.o: vncpasswd.c vncauth.h vncsnapshot-1.2a/README0100644005671200567000000000176610117721111014335 0ustar grantharmony vncsnapshot 1.2: VNC snapshot utility based on VNC ================================================================ TightVNC is Copyright (C) 2001 Const Kaplinsky. All Rights Reserved. VNC is Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. This software is distributed under the GNU General Public Licence as published by the Free Software Foundation. Adapted from the TightVNC viewer by Grant McDorman, February 2002. Features -------- Always connects to server in 'shared' mode. Saves image to JPEG file. The JPEG quality can be specified, with a default of 100%. The remote cursor is NOT included - unfortunately, the server doesn't provide a way of including the cursor in the snapshot. Standard VNC/TightVNC options (encoding, etc.) are available. On Windows, -listen, -tunnel and -via options are not available. On Windows systems, please read BUILD.win32. On Unix and Linux systems, please read BUILD.unix. < $Id: README,v 1.4 2004/09/09 00:22:33 grmcdorman Exp $ > vncsnapshot-1.2a/rfbproto.c0100644005671200567000000005723310117721111015456 0ustar grantharmony/* * Copyright (C) 2002 RealVNC Ltd. * 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. */ /* * rfbproto.c - functions to deal with client side of RFB protocol. */ static const char *ID = "$Id: rfbproto.c,v 1.6 2004/09/09 00:22:33 grmcdorman Exp $"; #ifdef WIN32 #include "vncauth.h" #define strcasecmp(a,b) stricmp(a,b) #define strncasecmp(a,b,n) strnicmp(a, b, n) #else #include #include #endif #include #include "vncsnapshot.h" #include "vncauth.h" #define INT16 jpegINT16 #include #include #undef INT16 /* do not need non-32 bit versions of these */ static Bool HandleRRE32(int rx, int ry, int rw, int rh); static Bool HandleCoRRE32(int rx, int ry, int rw, int rh); static Bool HandleHextile32(int rx, int ry, int rw, int rh); static Bool HandleZlib32(int rx, int ry, int rw, int rh); static Bool HandleTight32(int rx, int ry, int rw, int rh); static long ReadCompactLen (void); /* JPEG */ 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, CARD8 *compressedData, int compressedLen); char *desktopName; rfbPixelFormat myFormat; Bool pendingFormatChange = False; /* * 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)))) int currentEncoding = rfbEncodingZRLE; Bool pendingEncodingChange = False; int supportedEncodings[] = { rfbEncodingZRLE, rfbEncodingHextile, rfbEncodingCoRRE, rfbEncodingRRE, rfbEncodingRaw, rfbEncodingTight }; #define NUM_SUPPORTED_ENCODINGS (sizeof(supportedEncodings)/sizeof(int)) rfbServerInitMsg si; char *serverCutText = NULL; Bool newServerCutText = False; int endianTest = 1; /* 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 */ /* also hextile assumes it is big enough to hold 16 * 16 * 32 bits */ #define BUFFER_SIZE (640*480) static char buffer[BUFFER_SIZE]; /* 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. */ static int raw_buffer_size = -1; static char *raw_buffer; static z_stream decompStream; static Bool decompStreamInited = False; /* * Variables for the ``tight'' encoding implementation. */ /* Separate buffer for compressed data. */ #define ZLIB_BUFFER_SIZE 512 static char zlib_buffer[ZLIB_BUFFER_SIZE]; /* Four independent compression streams for zlib library. */ static z_stream zlibStream[4]; static Bool zlibStreamActive[4] = { False, False, False, False }; /* Filter stuff. Should be initialized by filter initialization code. */ static Bool cutZeros; static int rectWidth, rectColors; static char tightPalette[256*4]; static CARD8 tightPrevRow[2048*3*sizeof(CARD16)]; /* JPEG decoder state. */ static Bool jpegError; /* * InitialiseRFBConnection. */ Bool InitialiseRFBConnection() { rfbProtocolVersionMsg pv; int major,minor; CARD32 authScheme, reasonLen, authResult; char *reason; CARD8 challenge[CHALLENGESIZE]; char *passwd; int i; rfbClientInitMsg ci; if (!ReadFromRFBServer(pv, sz_rfbProtocolVersionMsg)) return False; pv[sz_rfbProtocolVersionMsg] = 0; if (sscanf(pv,rfbProtocolVersionFormat,&major,&minor) != 2) { fprintf(stderr,"Not a valid VNC server\n"); return False; } if (!appData.quiet) { fprintf(stderr,"VNC server supports protocol version %d.%d (viewer %d.%d)\n", major, minor, rfbProtocolMajorVersion, rfbProtocolMinorVersion); } major = rfbProtocolMajorVersion; minor = rfbProtocolMinorVersion; sprintf(pv,rfbProtocolVersionFormat,major,minor); if (!WriteToRFBServer(pv, sz_rfbProtocolVersionMsg)) return False; if (!ReadFromRFBServer((char *)&authScheme, 4)) return False; authScheme = Swap32IfLE(authScheme); switch (authScheme) { case rfbConnFailed: if (!ReadFromRFBServer((char *)&reasonLen, 4)) return False; reasonLen = Swap32IfLE(reasonLen); reason = malloc(reasonLen); if (!ReadFromRFBServer(reason, reasonLen)) return False; fprintf(stderr,"VNC connection failed: %.*s\n",(int)reasonLen, reason); return False; case rfbNoAuth: if (!appData.quiet) { fprintf(stderr,"No authentication needed\n"); } break; case rfbVncAuth: if (!ReadFromRFBServer((char *)challenge, CHALLENGESIZE)) return False; if (appData.passwordFile) { passwd = vncDecryptPasswdFromFile(appData.passwordFile); if (!passwd) { fprintf(stderr,"Cannot read valid password from file \"%s\"\n", appData.passwordFile); return False; } } else { passwd = getpass("Password: "); } if ((!passwd) || (strlen(passwd) == 0)) { fprintf(stderr,"Reading password failed\n"); return False; } if (strlen(passwd) > 8) { passwd[8] = '\0'; } vncEncryptBytes(challenge, passwd); /* Lose the password from memory */ for (i = strlen(passwd); i >= 0; i--) { passwd[i] = '\0'; } if (!WriteToRFBServer((char *)challenge, CHALLENGESIZE)) return False; if (!ReadFromRFBServer((char *)&authResult, 4)) return False; authResult = Swap32IfLE(authResult); switch (authResult) { case rfbVncAuthOK: if (!appData.quiet) { fprintf(stderr,"VNC authentication succeeded\n"); } break; case rfbVncAuthFailed: fprintf(stderr,"VNC authentication failed\n"); return False; case rfbVncAuthTooMany: fprintf(stderr,"VNC authentication failed - too many tries\n"); return False; default: fprintf(stderr,"Unknown VNC authentication result: %d\n", (int)authResult); return False; } break; default: fprintf(stderr,"Unknown authentication scheme from VNC server: %d\n", (int)authScheme); return False; } ci.shared = 1; if (!WriteToRFBServer((char *)&ci, sz_rfbClientInitMsg)) return False; if (!ReadFromRFBServer((char *)&si, sz_rfbServerInitMsg)) return False; si.framebufferWidth = Swap16IfLE(si.framebufferWidth); si.framebufferHeight = Swap16IfLE(si.framebufferHeight); si.format.redMax = Swap16IfLE(si.format.redMax); si.format.greenMax = Swap16IfLE(si.format.greenMax); si.format.blueMax = Swap16IfLE(si.format.blueMax); si.nameLength = Swap32IfLE(si.nameLength); desktopName = malloc(si.nameLength + 1); if (!desktopName) { fprintf(stderr, "Error allocating memory for desktop name, %lu bytes\n", (unsigned long)si.nameLength); return False; } if (!ReadFromRFBServer(desktopName, si.nameLength)) return False; desktopName[si.nameLength] = 0; if (!appData.quiet) { fprintf(stderr,"Desktop name \"%s\"\n",desktopName); fprintf(stderr,"Connected to VNC server, using protocol version %d.%d\n", rfbProtocolMajorVersion, rfbProtocolMinorVersion); fprintf(stderr,"VNC server default format:\n"); PrintPixelFormat(&si.format); } return True; } Bool SendFramebufferUpdateRequest(int x, int y, int w, int h, Bool incremental) { rfbFramebufferUpdateRequestMsg fur; fur.type = rfbFramebufferUpdateRequest; fur.incremental = incremental ? 1 : 0; fur.x = Swap16IfLE(x); fur.y = Swap16IfLE(y); fur.w = Swap16IfLE(w); fur.h = Swap16IfLE(h); if (!WriteToRFBServer((char *)&fur, sz_rfbFramebufferUpdateRequestMsg)) return False; return True; } Bool SendSetPixelFormat() { rfbSetPixelFormatMsg spf; spf.type = rfbSetPixelFormat; spf.format = myFormat; spf.format.redMax = Swap16IfLE(spf.format.redMax); spf.format.greenMax = Swap16IfLE(spf.format.greenMax); spf.format.blueMax = Swap16IfLE(spf.format.blueMax); PrintPixelFormat(&myFormat); return WriteToRFBServer((char *)&spf, sz_rfbSetPixelFormatMsg); } Bool SendSetEncodings() { char buf[sz_rfbSetEncodingsMsg + MAX_ENCODINGS * 4]; rfbSetEncodingsMsg *se = (rfbSetEncodingsMsg *)buf; CARD32 *encs = (CARD32 *)(&buf[sz_rfbSetEncodingsMsg]); int len = 0; int i; Bool requestCompressLevel = False; Bool requestQualityLevel = False; Bool requestLastRectEncoding = False; se->type = rfbSetEncodings; se->nEncodings = 0; if (appData.encodingsString) { char *encStr = appData.encodingsString; int encStrLen; do { char *nextEncStr = strchr(encStr, ' '); if (nextEncStr) { encStrLen = nextEncStr - encStr; nextEncStr++; } else { encStrLen = strlen(encStr); } if (strncasecmp(encStr,"raw",encStrLen) == 0) { encs[se->nEncodings++] = Swap32IfLE(rfbEncodingRaw); } else if (strncasecmp(encStr,"copyrect",encStrLen) == 0) { encs[se->nEncodings++] = Swap32IfLE(rfbEncodingCopyRect); } else if (strncasecmp(encStr,"tight",encStrLen) == 0) { encs[se->nEncodings++] = Swap32IfLE(rfbEncodingTight); requestLastRectEncoding = True; if (appData.compressLevel >= 0 && appData.compressLevel <= 9) requestCompressLevel = True; if (appData.enableJPEG) requestQualityLevel = True; } else if (strncasecmp(encStr,"hextile",encStrLen) == 0) { encs[se->nEncodings++] = Swap32IfLE(rfbEncodingHextile); } else if (strncasecmp(encStr,"zlib",encStrLen) == 0) { encs[se->nEncodings++] = Swap32IfLE(rfbEncodingZlib); if (appData.compressLevel >= 0 && appData.compressLevel <= 9) requestCompressLevel = True; } else if (strncasecmp(encStr,"corre",encStrLen) == 0) { encs[se->nEncodings++] = Swap32IfLE(rfbEncodingCoRRE); } else if (strncasecmp(encStr,"rre",encStrLen) == 0) { encs[se->nEncodings++] = Swap32IfLE(rfbEncodingRRE); } else if (strncasecmp(encStr,"zrle",encStrLen) == 0) { encs[se->nEncodings++] = Swap32IfLE(rfbEncodingZRLE); } else { fprintf(stderr,"Unknown encoding '%.*s'\n",encStrLen,encStr); } encStr = nextEncStr; } while (encStr && se->nEncodings < MAX_ENCODINGS); if (se->nEncodings < MAX_ENCODINGS && requestCompressLevel) { encs[se->nEncodings++] = Swap32IfLE(appData.compressLevel + rfbEncodingCompressLevel0); } if (se->nEncodings < MAX_ENCODINGS && requestQualityLevel) { if (appData.qualityLevel < 0 || appData.qualityLevel > 9) appData.qualityLevel = 5; encs[se->nEncodings++] = Swap32IfLE(appData.qualityLevel + rfbEncodingQualityLevel0); } if (se->nEncodings < MAX_ENCODINGS) encs[se->nEncodings++] = Swap32IfLE(rfbEncodingXCursor); if (se->nEncodings < MAX_ENCODINGS) encs[se->nEncodings++] = Swap32IfLE(rfbEncodingRichCursor); if (se->nEncodings < MAX_ENCODINGS) encs[se->nEncodings++] = Swap32IfLE(rfbEncodingPointerPos); if (se->nEncodings < MAX_ENCODINGS && requestLastRectEncoding) { encs[se->nEncodings++] = Swap32IfLE(rfbEncodingLastRect); } } else { if (sameMachine) { if (!tunnelSpecified) { if (!appData.quiet) { fprintf(stderr,"Same machine: preferring raw encoding\n"); } currentEncoding = rfbEncodingRaw; } else { if (!appData.quiet) { fprintf(stderr,"Tunneling active: preferring tight encoding\n"); } currentEncoding = rfbEncodingTight; } } encs[se->nEncodings++] = Swap32IfLE(rfbEncodingLastRect); encs[se->nEncodings++] = Swap32IfLE(rfbEncodingCopyRect); encs[se->nEncodings++] = Swap32IfLE(currentEncoding); for (i = 0; i < NUM_SUPPORTED_ENCODINGS; i++) { if (supportedEncodings[i] != currentEncoding) encs[se->nEncodings++] = Swap32IfLE(supportedEncodings[i]); } if (appData.compressLevel >= 0 && appData.compressLevel <= 9) { encs[se->nEncodings++] = Swap32IfLE(appData.compressLevel + rfbEncodingCompressLevel0); } else if (!tunnelSpecified) { /* If -tunnel option was provided, we assume that server machine is not in the local network so we use default compression level for tight encoding instead of fast compression. Thus we are requesting level 1 compression only if tunneling is not used. */ encs[se->nEncodings++] = Swap32IfLE(rfbEncodingCompressLevel1); } if (appData.enableJPEG) { if (appData.qualityLevel < 0 || appData.qualityLevel > 9) appData.qualityLevel = 5; encs[se->nEncodings++] = Swap32IfLE(appData.qualityLevel + rfbEncodingQualityLevel0); } if (se->nEncodings < MAX_ENCODINGS) encs[se->nEncodings++] = Swap32IfLE(rfbEncodingXCursor); if (se->nEncodings < MAX_ENCODINGS) encs[se->nEncodings++] = Swap32IfLE(rfbEncodingRichCursor); if (se->nEncodings < MAX_ENCODINGS) encs[se->nEncodings++] = Swap32IfLE(rfbEncodingPointerPos); } len = sz_rfbSetEncodingsMsg + se->nEncodings * 4; se->nEncodings = Swap16IfLE(se->nEncodings); return WriteToRFBServer(buf, len); } /* * SendIncrementalFramebufferUpdateRequest. */ Bool SendIncrementalFramebufferUpdateRequest() { return SendFramebufferUpdateRequest(0, 0, si.framebufferWidth, si.framebufferHeight, True); } Bool RequestNewUpdate() { if (!SendFramebufferUpdateRequest(appData.rectX, appData.rectY, appData.rectWidth, appData.rectHeight, True)) { return False; } return True; } /* * HandleRFBServerMessage. */ Bool HandleRFBServerMessage() { rfbServerToClientMsg msg; if (!ReadFromRFBServer((char *)&msg, 1)) return False; switch (msg.type) { case rfbSetColourMapEntries: { fprintf(stderr, "Received unsupported rfbSetColourMapEntries\n"); return False; /* unsupported */ } case rfbFramebufferUpdate: { rfbFramebufferUpdateRectHeader rect; int linesToRead; int bytesPerLine; int i; if (!ReadFromRFBServer(((char *)&msg.fu) + 1, sz_rfbFramebufferUpdateMsg - 1)) return False; msg.fu.nRects = Swap16IfLE(msg.fu.nRects); for (i = 0; i < msg.fu.nRects; i++) { if (!ReadFromRFBServer((char *)&rect, sz_rfbFramebufferUpdateRectHeader)) return False; rect.r.x = Swap16IfLE(rect.r.x); rect.r.y = Swap16IfLE(rect.r.y); rect.r.w = Swap16IfLE(rect.r.w); rect.r.h = Swap16IfLE(rect.r.h); rect.encoding = Swap32IfLE(rect.encoding); if (rect.encoding == rfbEncodingXCursor) { if (!HandleCursorShape(rect.r.x, rect.r.y, rect.r.w, rect.r.h, rfbEncodingXCursor)) { return False; } continue; } if (rect.encoding == rfbEncodingRichCursor) { if (!HandleCursorShape(rect.r.x, rect.r.y, rect.r.w, rect.r.h, rfbEncodingRichCursor)) { return False; } continue; } if (rect.encoding == rfbEncodingPointerPos) { if (!HandleCursorPos(rect.r.x, rect.r.y)) { return False; } appData.gotCursorPos = 1; continue; } if ((rect.r.x + rect.r.w > si.framebufferWidth) || (rect.r.y + rect.r.h > si.framebufferHeight)) { fprintf(stderr,"Rect too large: %dx%d at (%d, %d)\n", rect.r.w, rect.r.h, rect.r.x, rect.r.y); return False; } if ((rect.r.h * rect.r.w) == 0) { fprintf(stderr,"Zero size rect - ignoring\n"); continue; } /* If RichCursor encoding is used, we should prevent collisions between framebuffer updates and cursor drawing operations. */ SoftCursorLockArea(rect.r.x, rect.r.y, rect.r.w, rect.r.h); switch (rect.encoding) { case rfbEncodingRaw: bytesPerLine = rect.r.w * myFormat.bitsPerPixel / 8; linesToRead = BUFFER_SIZE / bytesPerLine; while (rect.r.h > 0) { if (linesToRead > rect.r.h) linesToRead = rect.r.h; if (!ReadFromRFBServer(buffer,bytesPerLine * linesToRead)) return False; CopyDataToScreen(buffer, rect.r.x, rect.r.y, rect.r.w, linesToRead); rect.r.h -= linesToRead; rect.r.y += linesToRead; } break; case rfbEncodingCopyRect: { rfbCopyRect cr; char *buffer; if (!ReadFromRFBServer((char *)&cr, sz_rfbCopyRect)) return False; if (!BufferWritten()) { /* Ignore attempts to do copy-rect when we have nothing to * copy from. */ break; } cr.srcX = Swap16IfLE(cr.srcX); cr.srcY = Swap16IfLE(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. */ SoftCursorLockArea(cr.srcX, cr.srcY, rect.r.w, rect.r.h); buffer = CopyScreenToData(cr.srcX, cr.srcY, rect.r.w, rect.r.h); CopyDataToScreen(buffer, rect.r.x, rect.r.y, rect.r.w, rect.r.h); free(buffer); break; } case rfbEncodingRRE: { if (!HandleRRE32(rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return False; break; } case rfbEncodingCoRRE: { if (!HandleCoRRE32(rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return False; break; } case rfbEncodingHextile: { if (!HandleHextile32(rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return False; break; } case rfbEncodingZlib: { if (!HandleZlib32(rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return False; break; } case rfbEncodingTight: { if (!HandleTight32(rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return False; break; } case rfbEncodingZRLE: if (!zrleDecode(rect.r.x,rect.r.y,rect.r.w,rect.r.h)) return False; break; default: fprintf(stderr,"Unknown rect encoding %d\n", (int)rect.encoding); return False; } /* Now we may discard "soft cursor locks". */ SoftCursorUnlockScreen(); /* Done. Save the screen image. */ } /* RealVNC sometimes returns an initial black screen. */ if (BufferIsBlank() && appData.ignoreBlank) { if (!appData.quiet && appData.ignoreBlank != 1) { /* user did not specify either -quiet or -ignoreblank */ fprintf(stderr, "Warning: discarding received blank screen (use -allowblank to accept,\n or -ignoreblank to suppress this message)\n"); appData.ignoreBlank = 1; } RequestNewUpdate(); } else { return False; } break; } case rfbBell: /* ignore */ break; case rfbServerCutText: { if (!ReadFromRFBServer(((char *)&msg) + 1, sz_rfbServerCutTextMsg - 1)) return False; msg.sct.length = Swap32IfLE(msg.sct.length); if (serverCutText) free(serverCutText); serverCutText = malloc(msg.sct.length+1); if (!ReadFromRFBServer(serverCutText, msg.sct.length)) return False; serverCutText[msg.sct.length] = 0; newServerCutText = True; break; } default: fprintf(stderr,"Unknown message type %d from VNC server\n",msg.type); return False; } return True; } #define GET_PIXEL8(pix, ptr) ((pix) = *(ptr)++) #define GET_PIXEL16(pix, ptr) (((CARD8*)&(pix))[0] = *(ptr)++, \ ((CARD8*)&(pix))[1] = *(ptr)++) #ifdef __APPLE__ /* Apple compilation appears to be broken.*/ static inline void GET_PIXEL32(void *pix, CARD8 *ptr) { ((CARD8*)&(pix))[0] = *(ptr)++; ((CARD8*)&(pix))[1] = *(ptr)++; ((CARD8*)&(pix))[2] = *(ptr)++; ((CARD8*)&(pix))[3] = *(ptr)++; } #endif #define GET_PIXEL32(pix, ptr) (((CARD8*)&(pix))[0] = *(ptr)++, \ ((CARD8*)&(pix))[1] = *(ptr)++, \ ((CARD8*)&(pix))[2] = *(ptr)++, \ ((CARD8*)&(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 BPP 32 #include "protocols/rre.c" #include "protocols/corre.c" #include "protocols/hextile.c" #include "protocols/zlib.c" #include "protocols/tight.c" #undef BPP /* * PrintPixelFormat. */ void PrintPixelFormat(format) rfbPixelFormat *format; { if (format->bitsPerPixel == 1) { fprintf(stderr," Single bit per pixel.\n"); fprintf(stderr, " %s significant bit in each byte is leftmost on the screen.\n", (format->bigEndian ? "Most" : "Least")); } else { fprintf(stderr," %d bits per pixel.\n",format->bitsPerPixel); if (format->bitsPerPixel != 8) { fprintf(stderr," %s significant byte first in each pixel.\n", (format->bigEndian ? "Most" : "Least")); } if (format->trueColour) { fprintf(stderr," True colour: max red %d green %d blue %d", format->redMax, format->greenMax, format->blueMax); fprintf(stderr,", shift red %d green %d blue %d\n", format->redShift, format->greenShift, format->blueShift); } else { fprintf(stderr," Colour map (not true colour).\n"); } } } static long ReadCompactLen (void) { long len; CARD8 b; if (!ReadFromRFBServer((char *)&b, 1)) return -1; len = (int)b & 0x7F; if (b & 0x80) { if (!ReadFromRFBServer((char *)&b, 1)) return -1; len |= ((int)b & 0x7F) << 7; if (b & 0x80) { if (!ReadFromRFBServer((char *)&b, 1)) return -1; len |= ((int)b & 0xFF) << 14; } } return len; } /* * JPEG source manager functions for JPEG decompression in Tight decoder. */ static struct jpeg_source_mgr jpegSrcManager; static JOCTET *jpegBufferPtr; static size_t jpegBufferLen; static void JpegInitSource(j_decompress_ptr cinfo) { jpegError = False; } static boolean JpegFillInputBuffer(j_decompress_ptr cinfo) { jpegError = True; jpegSrcManager.bytes_in_buffer = jpegBufferLen; jpegSrcManager.next_input_byte = (JOCTET *)jpegBufferPtr; return TRUE; } static void JpegSkipInputData(j_decompress_ptr cinfo, long num_bytes) { if (num_bytes < 0 || (unsigned int) num_bytes > jpegSrcManager.bytes_in_buffer) { jpegError = True; jpegSrcManager.bytes_in_buffer = jpegBufferLen; jpegSrcManager.next_input_byte = (JOCTET *)jpegBufferPtr; } else { jpegSrcManager.next_input_byte += (size_t) num_bytes; jpegSrcManager.bytes_in_buffer -= (size_t) num_bytes; } } static void JpegTermSource(j_decompress_ptr cinfo) { /* No work necessary here. */ } static void JpegSetSrcManager(j_decompress_ptr cinfo, CARD8 *compressedData, int compressedLen) { jpegBufferPtr = (JOCTET *)compressedData; jpegBufferLen = (size_t)compressedLen; jpegSrcManager.init_source = JpegInitSource; jpegSrcManager.fill_input_buffer = JpegFillInputBuffer; jpegSrcManager.skip_input_data = JpegSkipInputData; jpegSrcManager.resync_to_restart = jpeg_resync_to_restart; jpegSrcManager.term_source = JpegTermSource; jpegSrcManager.next_input_byte = jpegBufferPtr; jpegSrcManager.bytes_in_buffer = jpegBufferLen; cinfo->src = &jpegSrcManager; } vncsnapshot-1.2a/rfb.h0100644005671200567000000000437307431306772014415 0ustar grantharmony// Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. // // This file is part of the VNC system. // // The VNC system 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. // // TightVNC distribution homepage on the Web: http://www.tightvnc.com/ // // If the source code for the VNC system is not available from the place // whence you received this file, check http://www.uk.research.att.com/vnc or contact // the authors on vnc@uk.research.att.com for information on obtaining it. // rfb.h // This includes the rfb spec header, the port numbers, // the CARD type definitions and various useful macros. // #ifndef RFB_H__ #define RFB_H__ // Define the CARD* types as used in X11/Xmd.h typedef unsigned long CARD32; typedef unsigned short CARD16; typedef short INT16; typedef unsigned char CARD8; // Define the port number offsets #define FLASH_PORT_OFFSET 5400 #define INCOMING_PORT_OFFSET 5500 #define HTTP_PORT_OFFSET 5800 // we don't use this in Venice #define RFB_PORT_OFFSET 5900 #define PORT_TO_DISPLAY(p) ( (p) - RFB_PORT_OFFSET ) #define DISPLAY_TO_PORT(d) ( (d) + RFB_PORT_OFFSET ) // include the protocol spec #include "rfbproto.h" // define some quick endian conversions // change this if necessary #define LITTLE_ENDIAN_HOST #ifdef LITTLE_ENDIAN_HOST #define Swap16IfLE(s) \ ((CARD16) ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff))) #define Swap32IfLE(l) \ ((CARD32) ((((l) & 0xff000000) >> 24) | \ (((l) & 0x00ff0000) >> 8) | \ (((l) & 0x0000ff00) << 8) | \ (((l) & 0x000000ff) << 24))) #else #define Swap16IfLE(s) (s) #define Swap32IfLE(l) (l) #endif #endif // RFB_H__ vncsnapshot-1.2a/RELEASE-NOTES-1.1.txt0100644005671200567000000000332210117721111016447 0ustar grantharmonyRelease Notes for VNC Snapshot 1.1 ========================================= This is the second release of VNC snapshot. It has been tested on Windows, Linux and Solaris Sparc systems. This version merges the TightVNC 1.2.8 and RealVNC 3.3.7 code, including the ZRLE encoding. Semantics of the -rect option has changed. Formerly, when giving negative x and y (e.g. -rect 400x300-400-300) the x and y coordinates were of the top left corner of the rectangle. This meant that you usually had to add in the size of the rectangle. Now, the negative value refers to the right or bottom edge. Thus, in 1.0b1 the option: -rect 400x300-400-300 is now -rect 400x300-0-0 which is more readable (and sensible). This also now corresponds to the way Unix X11 -geometry specifications work. Two new pairs of options are available. The first is -cursor and -nocursor, which cause the remote cursor to be included, or excluded, from the snapshot. They will work with TightVNC servers only, unfortunately. The second is -allowblank and -ignoreblank, which cause blank (all black) screens to be saved, or ignored. -ignoreblank is the default and is appropriate for recent RealVNC servers on Windows systems, which send an all-blank screen at first before sending the actual image. Performance improvements have also been made when fetching a sub-rectangle of the screen; previously the entire screen would be retreived from the remote server, and the sub-rectangle extracted from that. Now, only the area to be saved is retrieved. This should reduce the amount of data sent across the network. Note: -listen, -tunnel, and -via are implemented but untested for Windows systems. < $Id: RELEASE-NOTES-1.1.txt,v 1.1 2004/09/09 00:22:33 grmcdorman Exp $ > vncsnapshot-1.2a/argsresources.c0100644005671200567000000002424310120126175016506 0ustar grantharmony/* * 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. */ /* * argsresources.c - deal with command-line args and resources. */ static const char *ID = "$Id: argsresources.c,v 1.7 2004/09/09 19:18:21 grmcdorman Exp $"; #include "vncsnapshot.h" #include "version.h" static int setNumber(int *argc, char ***argv, void *arg, int value); static int setString(int *argc, char ***argv, void *arg, int value); static int setFlag(int *argc, char ***argv, void *arg, int value); static char * rect = NULL; typedef struct { const char *optionstring; int (*set)(int *argc, char ***argv, void *arg, int value); void *arg; int value; const char *optiondesc; } Options; /* Options - excluding -listen, -tunnel, and -via */ Options cmdLineOptions[] = { {"-allowblank", setFlag, &appData.ignoreBlank, 0, ": allow blank images"}, {"-compresslevel", setNumber, &appData.compressLevel, 0, " (0..9: 0-fast, 9-best)"}, {"-cursor", setFlag, &appData.useRemoteCursor, 1, ": include remote cursor"}, {"-debug", setFlag, &appData.debug, 0, ": enable debug printout"}, {"-encodings", setString, &appData.encodingsString, 0, " (e.g. \"tight copyrect\")"}, {"-ignoreblank", setFlag, &appData.ignoreBlank, 1, ": ignore blank images"}, {"-jpeg", setFlag, &appData.enableJPEG, 1, ": use JPEG transmission encoding"}, {"-nocursor", setFlag, &appData.useRemoteCursor, 0, ": do not include remote cursor"}, {"-nojpeg", setFlag, &appData.enableJPEG, 0, ": do not use JPEG transmission encoding"}, {"-passwd", setString, &appData.passwordFile, 0, " : read password from file"}, {"-quality", setNumber, &appData.saveQuality, 0, " : output file quality level, percent (0..100)"}, {"-quiet", setFlag, &appData.quiet, 1, ": do not output messages"}, {"-rect", setString, &rect, 0, " wxh+x+y: define rectangle to capture (default entire screen)"}, {"-verbose", setFlag, &appData.quiet, 0, ": output messages"}, {"-vncQuality", setNumber, &appData.qualityLevel, 0, " : transmission quality level (0..9: 0-low, 9-high)"}, {"-fps", setNumber, &appData.fps, 0, " : Wait seconds between snapshots, default 60"}, {"-count", setNumber, &appData.count, 0, " : Capture images, default 1"}, {NULL, NULL, NULL, 0} }; /* * vncServerHost and vncServerPort are set either from the command line or * from a dialog box. */ char vncServerHost[256]; int vncServerPort = 0; char *vncServerName; /* * appData is our application-specific data which can be set by the user with * application resource specs. The AppData structure is defined in the header * file. */ AppData appData = { NULL, /* encodingsString */ NULL, /* passwordFile */ 0, /* debug */ 4, /* compressLevel */ 9, /* qualityLevel */ -1, /* useRemoteCursor */ -1, /* ignoreBlank */ -1, /* enableJPEG */ 100, /* saveQuality */ NULL, /* outputFilename */ 0, /* quiet */ 0, 0, /* rectXNegative, rectYNegative */ 0, 0, /* rect width, height */ 0, 0, /* rect x, y */ 0, /* gotCursorPos (-cursor, -nocursor worked) */ 60, /* fps */ 1, /* count */ }; /* * removeArgs() is used to remove some of command line arguments. */ void removeArgs(int *argc, char** argv, int idx, int nargs) { int i; if ((idx+nargs) > *argc) return; for (i = idx+nargs; i < *argc; i++) { argv[i-nargs] = argv[i]; } *argc -= nargs; } /* * usage() prints out the usage message. */ void usage(void) { int i; fprintf(stderr, "TightVNC snapshot version " VNC_SNAPSHOT_VERSION " (based on TightVNC 1.2.8 and RealVNC 3.3.7)\n" "\n" "Usage: %s [] []: filename\n" " %s [] -listen [] filename\n" " %s [] -tunnel : filename\n" " %s [] -via []: filename\n" "\n" " are:" "\n", programName, programName, programName, programName); for (i = 0; cmdLineOptions[i].optionstring; i++) { fprintf(stderr, " %s", cmdLineOptions[i].optionstring); if (cmdLineOptions[i].optiondesc) { fprintf(stderr, "%s", cmdLineOptions[i].optiondesc); } if (cmdLineOptions[i].set == setFlag && *(Bool *)cmdLineOptions[i].arg) { fprintf(stderr, " (default)"); } else if (cmdLineOptions[i].set == setNumber) { fprintf(stderr, " (default %d)", *(int *)cmdLineOptions[i].arg); } else if (cmdLineOptions[i].set == setString) { char *str = *(char **)cmdLineOptions[i].arg; if (str != NULL && !*str) { fprintf(stderr, " (default %s)", str); } } fprintf(stderr, "\n"); } exit(1); } /* * GetArgsAndResources() deals with resources and any command-line arguments * not already processed by XtVaAppInitialize(). It sets vncServerHost and * vncServerPort and all the fields in appData. */ void GetArgsAndResources(int argc, char **argv) { int i; int argsleft; char **arg; int processed; char *vncServerName, *colonPos; int len, portOffset; argsleft = argc; arg = argv+1; /* Must have at least one argument */ if (argc < 2) { usage(); } do { processed = 0; for (i = 0; cmdLineOptions[i].optionstring != NULL; i++) { if (strcmp(cmdLineOptions[i].optionstring, arg[0]) == 0) { processed = cmdLineOptions[i].set(&argsleft, &arg, cmdLineOptions[i].arg, cmdLineOptions[i].value); argsleft--; arg++; } } } while (processed); /* Parse rectangle provided. */ if (rect != NULL) { /* We could use sscanf, but the return value is not consistent * across all platforms. */ long w, h; long x, y; char *end = NULL; w = strtol(rect, &end, 10); if (end == NULL || end == rect || *end != 'x') { fprintf(stderr, "%s: invalid rectangle specification %s\n", programName, rect); usage(); } end++; h = strtol(end, &end, 10); if (end == NULL || end == rect || (*end != '+' && *end != '-')) { fprintf(stderr, "%s: invalid rectangle specification %s\n", programName, rect); usage(); } /* determine sign */ appData.rectXNegative = *end == '-'; end++; x = strtol(end, &end, 10); if (end == NULL || end == rect || (*end != '+' && *end != '-')) { fprintf(stderr, "%s: invalid rectangle specification %s\n", programName, rect); usage(); } /* determine sign */ appData.rectYNegative = *end == '-'; end++; y = strtol(end, &end, 10); if (end == NULL || end == rect || *end != '\0') { fprintf(stderr, "%s: invalid rectangle specification %s\n", programName, rect); usage(); } appData.rectWidth = w; appData.rectHeight = h; appData.rectX = x; appData.rectY = y; } argc = argsleft; argv = arg; /* Check any remaining command-line arguments. If -listen was specified there should be none. Otherwise the only argument should be the VNC server name. If not given then pop up a dialog box and wait for the server name to be entered. */ if (listenSpecified) { if (argc != 2) { fprintf(stderr,"\n%s -listen: invalid command line argument: %s\n", programName, argv[0]); usage(); } appData.outputFilename = argv[0]; return; } if (argc != 3) { usage(); return; /* keep gcc -Wall happy */ } else { vncServerName = argv[0]; appData.outputFilename = argv[1]; if (vncServerName[0] == '-') usage(); } if (strlen(vncServerName) > 255) { fprintf(stderr,"VNC server name too long\n"); exit(1); } colonPos = strchr(vncServerName, ':'); if (colonPos == NULL) { /* No colon -- use default port number */ strcpy(vncServerHost, vncServerName); vncServerPort = SERVER_PORT_OFFSET; } else { memcpy(vncServerHost, vncServerName, colonPos - vncServerName); vncServerHost[colonPos - vncServerName] = '\0'; len = strlen(colonPos + 1); portOffset = SERVER_PORT_OFFSET; if (colonPos[1] == ':') { /* Two colons -- interpret as a port number */ colonPos++; len--; portOffset = 0; } if (!len || strspn(colonPos + 1, "0123456789") != len) { usage(); } vncServerPort = atoi(colonPos + 1) + portOffset; } } static int setNumber(int *argc, char ***argv, void *arg, int value) { long number; char *end; int ok; ok = 0; if (*argc > 2) { (*argc) --; (*argv)++; end = NULL; number = strtol((*argv)[0], &end, 0); if (end != NULL && *end == '\0') { *((int *) arg) = number; ok = 1; } } return ok; } static int setString(int *argc, char ***argv, void *arg, int value) { int ok; ok = 0; if (*argc > 2) { (*argc) --; (*argv)++; *((char **) arg) = (*argv)[0]; ok = 1; } return ok; } static int setFlag(int *argc, char ***argv, void *arg, int value) { *((Bool *)arg) = value; return 1; } vncsnapshot-1.2a/buffer.c0100644005671200567000000002567110117721111015073 0ustar grantharmony/* * 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. */ /* * buffer.c - functions to deal with the raw image buffer. */ static const char *ID = "$Id: buffer.c,v 1.6 2004/09/09 00:22:33 grmcdorman Exp $"; #include "vncsnapshot.h" /* jpeglib.h may redefine INT16 */ #define INT16 jpegINT16 #include #include #undef INT16 static void BufferPixelToRGB(unsigned long pixel, int *r, int *g, int *b); static char * rawBuffer = NULL; static char bufferBlank = 1; static char bufferWritten = 0; #define RAW_BYTES_PER_PIXEL 3 /* size of pixel in raw buffer */ #define MY_BYTES_PER_PIXEL 4 /* size of pixel in VNC buffer */ #define MY_BITS_PER_PIXEL (MY_BYTES_PER_PIXEL*8) int AllocateBuffer() { unsigned long bytes; static const short testEndian = 1; int bigEndian; /* Determine 'endian' nature of this machine */ /* On big-endian machines, the address of a short (16 bit) is the * most significant byte (and is therefore 0). On little-endian, * it is the address of the least significant byte - and is therefore * 1. * * Intel 8x86 (including Pentium) are big-endian. Motorola, PDP-11, * and Sparc are little-endian. */ bigEndian = 0 == *(char *)&testEndian; //bigEndian = 0; /* Format is RGBA. Due to the way we store the pixels, * the 'bigEndian' is the *opposite* of the hardware value. */ myFormat.bitsPerPixel = MY_BITS_PER_PIXEL; myFormat.depth = 24; myFormat.trueColour = 1; myFormat.bigEndian = bigEndian; if (bigEndian) { myFormat.redShift = 24; myFormat.greenShift = 16; myFormat.blueShift = 8; } else { myFormat.redShift = 0; myFormat.greenShift = 8; myFormat.blueShift = 16; } myFormat.redMax = 0xFF; myFormat.greenMax = 0xFF; myFormat.blueMax = 0xFF; bytes = si.framebufferWidth * si.framebufferHeight * myFormat.depth / 8; rawBuffer = malloc(bytes); /* allocate initialized to 0 */ if (rawBuffer == NULL) { fprintf(stderr, "Failed to allocate memory frame buffer, %lu bytes\n", bytes); return 0; } memset(rawBuffer, 0xBA, bytes); return 1; } void CopyDataToScreen(char *buffer, int x, int y, int w, int h) { int start; int stride; int row, col; stride = si.framebufferWidth * RAW_BYTES_PER_PIXEL - w * RAW_BYTES_PER_PIXEL; start = (x + y * si.framebufferWidth) * RAW_BYTES_PER_PIXEL; bufferWritten = 1; for (row = 0; row < h; row++) { for (col = 0; col < w; col++) { bufferBlank &= buffer[0] == 0 && buffer[1] == 0 && buffer[2] == 0; rawBuffer[start++] = *buffer++; rawBuffer[start++] = *buffer++; rawBuffer[start++] = *buffer++; buffer++; /* ignore 4th byte */ } start += stride; } } char * CopyScreenToData(int x, int y, int w, int h) { int start; int stride; int row, col; char *buffer; char *cp; stride = si.framebufferWidth * RAW_BYTES_PER_PIXEL - w * RAW_BYTES_PER_PIXEL; start = (x + y * si.framebufferWidth) * RAW_BYTES_PER_PIXEL; /* Allocate a buffer at the VNC size, not the raw size */ buffer = malloc(h * w * MY_BYTES_PER_PIXEL); cp = buffer; for (row = 0; row < h; row++) { for (col = 0; col < w; col++) { *cp++ = rawBuffer[start++]; *cp++ = rawBuffer[start++]; *cp++ = rawBuffer[start++]; *cp++ = 0; } start += stride; } return buffer; } void FillBufferRectangle(int x, int y, int w, int h, unsigned long pixel) { int r, g, b; int start; int stride; int row, col; BufferPixelToRGB(pixel, &r, &g, &b); bufferBlank &= r == 0 && g == 0 && b == 0; bufferWritten = 1; stride = si.framebufferWidth * RAW_BYTES_PER_PIXEL - w * RAW_BYTES_PER_PIXEL; start = (x + y * si.framebufferWidth) * RAW_BYTES_PER_PIXEL; for (row = 0; row < h; row++) { for (col = 0; col < w; col++) { rawBuffer[start++] = r; rawBuffer[start++] = g; rawBuffer[start++] = b; } start += stride; } } int BufferIsBlank() { return bufferBlank; } int BufferWritten() { return bufferWritten; } /* * Borrowed with very minor modifications from JPEG6 sample code. Error handling * remains as default (i.e. exit on errors). */ void write_JPEG_file (char * filename, int quality, int width, int height) { /* This struct contains the JPEG compression parameters and pointers to * working space (which is allocated as needed by the JPEG library). * It is possible to have several such structures, representing multiple * compression/decompression processes, in existence at once. We refer * to any one struct (and its associated working data) as a "JPEG object". */ struct jpeg_compress_struct cinfo; /* This struct represents a JPEG error handler. It is declared separately * because applications often want to supply a specialized error handler * (see the second half of this file for an example). But here we just * take the easy way out and use the standard error handler, which will * print a message on stderr and call exit() if compression fails. * Note that this struct must live as long as the main JPEG parameter * struct, to avoid dangling-pointer problems. */ struct jpeg_error_mgr jerr; /* More stuff */ FILE * outfile; /* target file */ JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ int row_stride; /* physical row width in image buffer */ /* Step 1: allocate and initialize JPEG compression object */ /* We have to set up the error handler first, in case the initialization * step fails. (Unlikely, but it could happen if you are out of memory.) * This routine fills in the contents of struct jerr, and returns jerr's * address which we place into the link field in cinfo. */ cinfo.err = jpeg_std_error(&jerr); /* Now we can initialize the JPEG compression object. */ jpeg_create_compress(&cinfo); /* Step 2: specify data destination (eg, a file) */ /* Note: steps 2 and 3 can be done in either order. */ /* Here we use the library-supplied code to send compressed data to a * stdio stream. You can also write your own code to do something else. * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that * requires it in order to write binary files. */ if (strcmp(filename, "-") == 0) { outfile = stdout; } else { if ((outfile = fopen(filename, "wb")) == NULL) { fprintf(stderr, "can't open %s\n", filename); exit(1); } } jpeg_stdio_dest(&cinfo, outfile); /* Step 3: set parameters for compression */ /* First we supply a description of the input image. * Four fields of the cinfo struct must be filled in: */ cinfo.image_width = width; /* image width and height, in pixels */ cinfo.image_height = height; cinfo.input_components = RAW_BYTES_PER_PIXEL; /* # of color components per pixel */ cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ /* Now use the library's routine to set default compression parameters. * (You must set at least cinfo.in_color_space before calling this, * since the defaults depend on the source color space.) */ jpeg_set_defaults(&cinfo); /* Now you can set any non-default parameters you wish to. * Here we just illustrate the use of quality (quantization table) scaling: */ jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */); /* VNCSNAPSHOT: Set file colourspace to RGB. * If it is not set to RGB, colour distortions occur. */ jpeg_set_colorspace(&cinfo, JCS_RGB); /* Step 4: Start compressor */ /* TRUE ensures that we will write a complete interchange-JPEG file. * Pass TRUE unless you are very sure of what you're doing. */ jpeg_start_compress(&cinfo, TRUE); /* Step 5: while (scan lines remain to be written) */ /* jpeg_write_scanlines(...); */ /* Here we use the library's state variable cinfo.next_scanline as the * loop counter, so that we don't have to keep track ourselves. * To keep things simple, we pass one scanline per call; you can pass * more if you wish, though. */ row_stride = width * 3; /* JSAMPLEs per row in image_buffer */ while (cinfo.next_scanline < cinfo.image_height) { /* jpeg_write_scanlines expects an array of pointers to scanlines. * Here the array is only one element long, but you could pass * more than one scanline at a time if that's more convenient. */ row_pointer[0] = & rawBuffer[cinfo.next_scanline * row_stride]; (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); } /* Step 6: Finish compression */ jpeg_finish_compress(&cinfo); /* After finish_compress, we can close the output file. */ if (strcmp(filename, "-") != 0) { fclose(outfile); } /* Step 7: release JPEG compression object */ /* This is an important step since it will release a good deal of memory. */ jpeg_destroy_compress(&cinfo); /* And we're done! */ } static void BufferPixelToRGB(unsigned long pixel, int *r, int *g, int *b) { *r = (pixel >> myFormat.redShift) & myFormat.redMax; *b = (pixel >> myFormat.blueShift) & myFormat.blueMax; *g = (pixel >> myFormat.greenShift) & myFormat.greenMax; } void ShrinkBuffer(long x, long y, long req_width, long req_height) { int start; int stride; int row, col; char *cp; /* * Don't bother if x and y are zero and the width is the same. */ if (x == 0 && y == 0 && req_width == si.framebufferWidth) { return; } /* * Rather than creating a copy, we just move in-place. Since we are * doing this from the start of the image, there is no problem * with overlapping moves. */ stride = si.framebufferWidth * RAW_BYTES_PER_PIXEL - req_width * RAW_BYTES_PER_PIXEL; start = (x + y * si.framebufferWidth) * RAW_BYTES_PER_PIXEL; cp = rawBuffer; for (row = 0; row < req_height; row++) { for (col = 0; col < req_width; col++) { *cp++ = rawBuffer[start++]; *cp++ = rawBuffer[start++]; *cp++ = rawBuffer[start++]; } start += stride; } } vncsnapshot-1.2a/cursor.c0100644005671200567000000002524410117721111015133 0ustar grantharmony/* * 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). */ static const char *ID = "$Id: cursor.c,v 1.5 2004/09/09 00:22:33 grmcdorman Exp $"; #include #define OPER_SAVE 0 #define OPER_RESTORE 1 #define RGB24_TO_PIXEL(bpp,r,g,b) \ ((((CARD##bpp)(r) & 0xFF) * myFormat.redMax + 127) / 255 \ << myFormat.redShift | \ (((CARD##bpp)(g) & 0xFF) * myFormat.greenMax + 127) / 255 \ << myFormat.greenShift | \ (((CARD##bpp)(b) & 0xFF) * myFormat.blueMax + 127) / 255 \ << myFormat.blueShift) static Bool prevSoftCursorSet = False; /*static Pixmap rcSavedArea;*/ static char *rcSavedArea; static CARD8 *rcSource, *rcMask; static int rcHotX, rcHotY, rcWidth, rcHeight; static int rcCursorX = 0, rcCursorY = 0; static int rcLockX, rcLockY, rcLockWidth, rcLockHeight; static Bool rcCursorHidden, rcLockSet; static Bool SoftCursorInLockedArea(void); static void SoftCursorCopyArea(int oper); static void SoftCursorDraw(void); static void FreeSoftCursor(void); /********************************************************************* * HandleCursorShape(). Support for XCursor and RichCursor shape * updates. We emulate cursor operating on the frame buffer (that is * why we call it "software cursor"). ********************************************************************/ Bool HandleCursorShape(int xhot, int yhot, int width, int height, CARD32 enc) { int bytesPerPixel; size_t bytesPerRow, bytesMaskData; /* Drawable dr;*/ rfbXCursorColors rgb; CARD32 colors[2]; char *buf; CARD8 *ptr; int x, y, b; bytesPerPixel = myFormat.bitsPerPixel / 8; bytesPerRow = (width + 7) / 8; bytesMaskData = bytesPerRow * height; /* dr = DefaultRootWindow(dpy);*/ FreeSoftCursor(); if (width * height == 0) return True; /* Allocate memory for pixel data and temporary mask data. */ rcSource = malloc(width * height * bytesPerPixel); if (rcSource == NULL) return False; buf = malloc(bytesMaskData); if (buf == NULL) { free(rcSource); 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((char *)&rgb, sz_rfbXCursorColors)) { free(rcSource); 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(buf, bytesMaskData)) { free(rcSource); free(buf); return False; } /* Convert 1bpp data to byte-wide color indices. */ ptr = 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++) rcSource[x] = (CARD8)colors[rcSource[x]]; break; case 2: for (x = 0; x < width * height; x++) ((CARD16 *)rcSource)[x] = (CARD16)colors[rcSource[x * 2]]; break; case 4: for (x = 0; x < width * height; x++) ((CARD32 *)rcSource)[x] = colors[rcSource[x * 4]]; break; } } else { /* enc == rfbEncodingRichCursor */ if (!ReadFromRFBServer((char *)rcSource, width * height * bytesPerPixel)) { free(rcSource); free(buf); return False; } } /* Read and decode mask data. */ if (!ReadFromRFBServer(buf, bytesMaskData)) { free(rcSource); free(buf); return False; } rcMask = malloc(width * height); if (rcMask == NULL) { free(rcSource); free(buf); return False; } ptr = 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; } } free(buf); /* Set remaining data associated with cursor. */ /* dr = DefaultRootWindow(dpy); rcSavedArea = XCreatePixmap(dpy, dr, width, height, visdepth);*/ rcHotX = xhot; rcHotY = yhot; rcWidth = width; rcHeight = height; /* Do not draw. Only draw when we have the position. */ SoftCursorCopyArea(OPER_SAVE); /*SoftCursorDraw();*/ rcCursorHidden = False; rcLockSet = False; prevSoftCursorSet = True; return True; } /********************************************************************* * HandleCursorPos(). Support for the PointerPos pseudo-encoding used * to transmit changes in pointer position from server to clients. * PointerPos encoding is used together with cursor shape updates. ********************************************************************/ Bool HandleCursorPos(int x, int y) { if (x >= si.framebufferWidth) x = si.framebufferWidth - 1; if (y >= si.framebufferHeight) y = si.framebufferHeight - 1; SoftCursorMove(x, y); return True; } /********************************************************************* * SoftCursorLockArea(). This function should be used to prevent * collisions between simultaneous framebuffer update operations and * cursor drawing operations caused by movements of pointing device. * The parameters denote a rectangle where mouse cursor should not be * drawn. Every next call to this function expands locked area so * previous locks remain active. ********************************************************************/ void SoftCursorLockArea(int x, int y, int w, int h) { int newX, newY; if (!BufferWritten()) { return; /* no cursor to hide */ } if (!prevSoftCursorSet) return; if (!rcLockSet) { rcLockX = x; rcLockY = y; rcLockWidth = w; rcLockHeight = h; rcLockSet = True; } else { newX = (x < rcLockX) ? x : rcLockX; newY = (y < rcLockY) ? y : rcLockY; rcLockWidth = (x + w > rcLockX + rcLockWidth) ? (x + w - newX) : (rcLockX + rcLockWidth - newX); rcLockHeight = (y + h > rcLockY + rcLockHeight) ? (y + h - newY) : (rcLockY + rcLockHeight - newY); rcLockX = newX; rcLockY = newY; } if (!rcCursorHidden && SoftCursorInLockedArea()) { SoftCursorCopyArea(OPER_RESTORE); rcCursorHidden = True; } } /********************************************************************* * SoftCursorUnlockScreen(). This function discards all locks * performed since previous SoftCursorUnlockScreen() call. ********************************************************************/ void SoftCursorUnlockScreen(void) { if (!prevSoftCursorSet) return; if (rcCursorHidden) { SoftCursorCopyArea(OPER_SAVE); if (appData.useRemoteCursor == 1) { SoftCursorDraw(); } rcCursorHidden = False; } rcLockSet = False; } /********************************************************************* * SoftCursorMove(). Moves soft cursor into a particular location. * This function respects locking of screen areas so when the cursor * is moved into the locked area, it becomes invisible until * SoftCursorUnlock() functions is called. ********************************************************************/ void SoftCursorMove(int x, int y) { if (prevSoftCursorSet && !rcCursorHidden) { SoftCursorCopyArea(OPER_RESTORE); rcCursorHidden = True; } rcCursorX = x; rcCursorY = y; if (prevSoftCursorSet && !(rcLockSet && SoftCursorInLockedArea())) { SoftCursorCopyArea(OPER_SAVE); if (appData.useRemoteCursor == 1) { SoftCursorDraw(); } rcCursorHidden = False; } } /********************************************************************* * Internal (static) low-level functions. ********************************************************************/ static Bool SoftCursorInLockedArea(void) { return (rcLockX < rcCursorX - rcHotX + rcWidth && rcLockY < rcCursorY - rcHotY + rcHeight && rcLockX + rcLockWidth > rcCursorX - rcHotX && rcLockY + rcLockHeight > rcCursorY - rcHotY); } static void SoftCursorCopyArea(int oper) { int x, y, w, h; x = rcCursorX - rcHotX; y = rcCursorY - rcHotY; if (x >= si.framebufferWidth || y >= si.framebufferHeight) return; w = rcWidth; h = rcHeight; if (x < 0) { w += x; x = 0; } else if (x + w > si.framebufferWidth) { w = si.framebufferWidth - x; } if (y < 0) { h += y; y = 0; } else if (y + h > si.framebufferHeight) { h = si.framebufferHeight - y; } if (oper == OPER_SAVE) { /* Save screen area in memory. */ if (rcSavedArea != NULL) { free(rcSavedArea); rcSavedArea = NULL; } rcSavedArea = CopyScreenToData(x, y, w, h); } else { /* Restore screen area. */ CopyDataToScreen(rcSavedArea, x, y, w, h); } } static void SoftCursorDraw(void) { int x, y, x0, y0; int offset, bytesPerPixel; char *pos; bytesPerPixel = myFormat.bitsPerPixel / 8; /* FIXME: Speed optimization is possible. */ for (y = 0; y < rcHeight; y++) { y0 = rcCursorY - rcHotY + y; if (y0 >= 0 && y0 < si.framebufferHeight) { for (x = 0; x < rcWidth; x++) { x0 = rcCursorX - rcHotX + x; if (x0 >= 0 && x0 < si.framebufferWidth) { offset = y * rcWidth + x; if (rcMask[offset]) { pos = (char *)&rcSource[offset * bytesPerPixel]; CopyDataToScreen(pos, x0, y0, 1, 1); } } } } } } static void FreeSoftCursor(void) { if (prevSoftCursorSet) { SoftCursorCopyArea(OPER_RESTORE); if (rcSavedArea != NULL) { free(rcSavedArea); rcSavedArea = NULL; } free(rcSource); free(rcMask); prevSoftCursorSet = False; } } vncsnapshot-1.2a/d3des.c0100644005671200567000000004401507640172377014642 0ustar grantharmony/* * This is D3DES (V5.09) by Richard Outerbridge with the double and * triple-length support removed for use in VNC. Also the bytebit[] array * has been reversed so that the most significant bit in each byte of the * key is ignored, not the least significant. * * 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 (V5.09) - * * A portable, public domain, version of the Data Encryption Standard. * * Written with Symantec's THINK (Lightspeed) C by Richard Outerbridge. * Thanks to: Dan Hoey for his excellent Initial and Inverse permutation * code; Jim Gillogly & Phil Karn for the DES key schedule code; Dennis * Ferguson, Eric Young and Dana How for comparing notes; and Ray Lau, * for humouring me on. * * Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge. * (GEnie : OUTER; CIS : [71755,204]) Graven Imagery, 1992. */ #include "d3des.h" static void scrunch(unsigned char *, unsigned long *); static void unscrun(unsigned long *, unsigned char *); static void desfunc(unsigned long *, unsigned long *); static void cookey(unsigned long *); static unsigned long KnL[32] = { 0L }; /*static unsigned long KnR[32] = { 0L };*/ /*static unsigned long Kn3[32] = { 0L };*/ /*static unsigned char Df_Key[24] = { 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10, 0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67 };*/ static unsigned short bytebit[8] = { 01, 02, 04, 010, 020, 040, 0100, 0200 }; static unsigned long bigbyte[24] = { 0x800000L, 0x400000L, 0x200000L, 0x100000L, 0x80000L, 0x40000L, 0x20000L, 0x10000L, 0x8000L, 0x4000L, 0x2000L, 0x1000L, 0x800L, 0x400L, 0x200L, 0x100L, 0x80L, 0x40L, 0x20L, 0x10L, 0x8L, 0x4L, 0x2L, 0x1L }; /* Use the key schedule specified in the Standard (ANSI X3.92-1981). */ static unsigned char pc1[56] = { 56, 48, 40, 32, 24, 16, 8, 0, 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 60, 52, 44, 36, 28, 20, 12, 4, 27, 19, 11, 3 }; static unsigned char totrot[16] = { 1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28 }; static unsigned char pc2[48] = { 13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9, 22, 18, 11, 3, 25, 7, 15, 6, 26, 19, 12, 1, 40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47, 43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31 }; void deskey(key, edf) /* Thanks to James Gillogly & Phil Karn! */ unsigned char *key; int edf; { register int i, j, l, m, n; unsigned char pc1m[56], pcr[56]; unsigned long kn[32]; for ( j = 0; j < 56; j++ ) { l = pc1[j]; m = l & 07; pc1m[j] = (key[l >> 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(raw1) 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); } usekey(dough); return; } void cpkey(into) register unsigned long *into; { register unsigned long *from, *endp; from = KnL, endp = &KnL[32]; while( from < endp ) *into++ = *from++; return; } void usekey(from) register unsigned long *from; { register unsigned long *to, *endp; to = KnL, endp = &KnL[32]; while( to < endp ) *to++ = *from++; return; } void des(inblock, outblock) unsigned char *inblock, *outblock; { unsigned long work[2]; scrunch(inblock, work); desfunc(work, KnL); unscrun(work, outblock); return; } static void scrunch(outof, into) 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(outof, into) 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(block, keys) register unsigned long *block, *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 **********************************************************************/ vncsnapshot-1.2a/d3des.h0100644005671200567000000000324607640172377014650 0ustar grantharmony/* * 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 deskey(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 usekey(unsigned long *); /* cookedkey[32] * Loads the internal key register with the data in cookedkey. */ extern void cpkey(unsigned long *); /* cookedkey[32] * Copies the contents of the internal key register into the storage * located at &cookedkey[0]. */ extern void des(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 ********************************************************************/ vncsnapshot-1.2a/getpass.c0100644005671200567000000000274507431321124015272 0ustar grantharmony/* * 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. */ /* * passwd.c - get password from console, Win32 */ static const char *ID = "$Id: getpass.c,v 1.3 2002/02/09 22:27:32 grmcdorman Exp $"; #include static char buffer[512]; char *getpass(const char * prompt) { int ch; int index = 0; _cputs(prompt); ch = _getch(); while (ch != -1 && ch != '\r') { if (ch == 0xE0) { _getch(); } else { if (index < 511) { buffer[index++] = ch; } } ch = _getch(); } buffer[index] = '\0'; return buffer; } vncsnapshot-1.2a/listen.c0100644005671200567000000000660307640172377015137 0ustar grantharmony/* * 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 */ static const char *ID = "$Id: listen.c,v 1.5 2003/03/26 00:31:59 grmcdorman Exp $"; #ifndef WIN32 #include #include #include #include #include #include typedef int SOCKET; #else #include #define close(x) closesocket(x) #endif #include "vncsnapshot.h" #define FLASHWIDTH 50 /* pixels */ #define FLASHDELAY 1 /* seconds */ Bool listenSpecified = False; int listenPort = 0, flashPort = 0; /* * listenForIncomingConnections() - listen for incoming connections from * servers, and fork a new process to deal with each connection. We must do * all this before invoking any Xt functions - this is because Xt doesn't * cope with forking very well. */ void listenForIncomingConnections(int *argc, char **argv, int listenArgIndex) { SOCKET listenSocket, flashSocket, sock; fd_set fds; char flashUser[256]; int n; listenSpecified = True; if (listenArgIndex+1 < *argc && argv[listenArgIndex+1][0] >= '0' && argv[listenArgIndex+1][0] <= '9') { listenPort = LISTEN_PORT_OFFSET + atoi(argv[listenArgIndex+1]); flashPort = FLASH_PORT_OFFSET + atoi(argv[listenArgIndex+1]); removeArgs(argc, argv, listenArgIndex, 2); } else { fprintf(stderr,"%s: Please specify which display to listen on with -listen \n", programName); exit(1); } listenSocket = ListenAtTcpPort(listenPort); flashSocket = ListenAtTcpPort(flashPort); if ((listenSocket < 0) || (flashSocket < 0)) exit(1); fprintf(stderr,"%s -listen: Listening on port %d (flash port %d)\n", programName,listenPort,flashPort); fprintf(stderr,"%s -listen: Command line errors are not reported until " "a connection comes in.\n", programName); while (True) { #ifndef WIN32 /* reap any zombies */ int status, pid; while ((pid= wait3(&status, WNOHANG, (struct rusage *)0))>0); #endif FD_ZERO(&fds); FD_SET(flashSocket, &fds); FD_SET(listenSocket, &fds); select(FD_SETSIZE, &fds, NULL, NULL, NULL); if (FD_ISSET(flashSocket, &fds)) { sock = AcceptTcpConnection(flashSocket); if (sock < 0) exit(1); n = recv(sock, flashUser, 255, 0); if (n > 0) { flashUser[n] = 0; } close(sock); } if (FD_ISSET(listenSocket, &fds)) { rfbsock = AcceptTcpConnection(listenSocket); if (rfbsock < 0) exit(1); /* Unlike a standard VNC client, we don't continue to listen. */ /* Return to caller. */ close(listenSocket); close(flashSocket); return; } } } vncsnapshot-1.2a/make_release_bin0100755005671200567000000000622110120127433016640 0ustar grantharmony#!/bin/sh # This shell script is set up to build on SourceForge compile farm hosts, # plus a few others. Output is placed in 'bin', with ldd output in 'ldd-info'. # # It expects jpeg-6b and zlib-1.2.2 to be unpacked in the current directory. # They will be used on systems where they are missing. # # Systems it is known to work on include: # Debian Alpha # Debian x86 # FreeBSD x86 # Gentoo x686 (Pentium 4) # Mac OS X (Darwin) PowerPC # NetBSD x86 # OpenBSD x86 # Red Hat Linux x86 # SuSE x86_64 (64 bit) # SunOS Solaris Sparc (sun4u) # SunOS Solaris x86 # RELEASE=$1 OS="`uname -s`" CC=gcc CDEBUGFLAGS="-O2 -Wall" CXX=g++ MAKE=make # need to set this before comiling JPEG if [ "$OS" = "SunOS" ];then PATH=/opt/SUNWspro/bin:$PATH:/usr/ccs/bin export PATH CC=cc EXTRALIBS="-lsocket -lnsl" CXX=CC CDEBUGFLAGS=-O export CC CXX fi # make sure we're clean cd vncsnapshot-$RELEASE make clean cd .. cd jpeg-6b make clean cd ../zlib-1.2.1 make clean cd .. # dummy macros COMPILE_cc=0 LINK_c=0 LINK_cc=0 vCOMPILE_cc="VNC_DUMMY_VAR=" vLINK_c="VNC_DUMMY_VAR=" vLINK_cc="VNC_DUMMY_VAR=" # defaults ZLIB_INCLUDE= # for systems that have libjpeg.so but no header file JPEG_INCLUDE=-I../jpeg-6b [ -f /usr/include/jpeglib.h ] && JPEG_INCLUDE= ZLIB_LIB="-lz" # Detech JPEG library if [ -f /usr/lib/libjpeg.so ];then JPEG_LIB="-ljpeg" elif [ -f /usr/lib/libjpeg.so.62 ];then JPEG_LIB="/usr/lib/libjpeg.so.62" else JPEG_INCLUDE=-I../jpeg-6b JPEG_LIB="-L../jpeg-6b -ljpeg" cd jpeg-6b;./configure&&make clean&&make;cd .. fi # OS specifics if [ "$OS" = "SunOS" ];then PATH=/opt/SUNWspro/bin:$PATH:/usr/ccs/bin export PATH CC=cc EXTRALIBS="-lsocket -lnsl" CXX=CC CDEBUGFLAGS=-O ZLIB_INCLUDE=-I../zlib-1.2.1 ZLIB_LIB="-L../zlib-1.2.1 -lz" cd zlib-1.2.1;CC=cc ./configure&&make clean&&make;cd .. elif [ "$OS" = "OpenBSD" ];then ZLIB_INCLUDE=-I../zlib-1.2.1 ZLIB_LIB="-L../zlib-1.2.1 -lz" # OpenBSD has a libz but no header files cd zlib-1.2.1;./configure &&make clean;cd .. elif [ "$OS" = "Darwin" ];then CC=cc CDEBUGFLAGS="-O2 -Wall" CXX=c++ elif [ "$OS" = "FreeBSD" ];then # missing some macros COMPILE_cc='$(CXX) -c $(CXXFLAGS)' LINK_c='$(CXX) $(CXXFLAGS)' LINK_cc='$(CXX) $(CXXFLAGS)' vCOMPILE_cc="COMPILE.cc=" vLINK_c="LINK.c=" vLINK_cc="LINK.cc=" fi cd vncsnapshot-$RELEASE if $MAKE CPLUSPLUS="$CXX" CC="$CC" EXTRALIBS="$EXTRALIBS" CDEBUGFLAGS="$CDEBUGFLAGS" CXX="$CXX" ZLIB_INCLUDE="$ZLIB_INCLUDE" ZLIB_LIB="$ZLIB_LIB" JPEG_INCLUDE="$JPEG_INCLUDE" JPEG_LIB="$JPEG_LIB" $vCOMPILE_cc"$COMPILE_cc" $vLINK_c"$LINK_c" $vLINK_cc"$LINK_cc";then HOST=`uname -srm | sed -e 's/ /-/g'` if expr "$HOST" : "Linux"; then # prepend with info from /proc/version HOST="`sed -e 's=.*(.*(\([^)]*\)).*=\1=' -e 's= =-=g' -e 's=/=-=g' /proc/version`-$HOST" fi [ ! -d ../bin ] && mkdir ../bin [ ! -d ../ldd-info ] && mkdir ../ldd-info ldd vncsnapshot >../ldd-info/vncsnapshot-${HOST}.ldd ldd vncpasswd >../ldd-info/vncpasswd-${HOST}.ldd mv vncsnapshot ../bin/vncsnapshot-${HOST} mv vncpasswd ../bin/vncpasswd-${HOST} make clean cd .. cd jpeg-6b make clean cd ../zlib-1.2.1 make clean fi vncsnapshot-1.2a/rfbproto.h0100644005671200567000000012735407640446507015511 0ustar grantharmony/* * Copyright (C) 2002 Ultr@VNC Team Members. All Rights Reserved. * Copyright (C) 2002 RealVNC Ltd. 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. */ /***************************************************************************** * * 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 { CARD16 x; CARD16 y; CARD16 w; CARD16 h; } rfbRectangle; #define sz_rfbRectangle 8 /*----------------------------------------------------------------------------- * Structure used to specify pixel format. */ typedef struct { CARD8 bitsPerPixel; /* 8,16,32 only */ CARD8 depth; /* 8 to 32 */ CARD8 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 */ CARD8 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 */ CARD16 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. */ CARD16 greenMax; /* similar for green */ CARD16 blueMax; /* and blue */ CARD8 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. */ CARD8 greenShift; /* similar for green */ CARD8 blueShift; /* and blue */ CARD8 pad1; CARD16 pad2; } rfbPixelFormat; #define sz_rfbPixelFormat 16 /***************************************************************************** * * 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 3 /* Other protocol numbers: * 4 UltraVNC * 6 UltraVNC */ typedef char rfbProtocolVersionMsg[13]; /* allow extra byte for null */ #define sz_rfbProtocolVersionMsg 12 /*----------------------------------------------------------------------------- * 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 /* * 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 { CARD8 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 { CARD16 framebufferWidth; CARD16 framebufferHeight; rfbPixelFormat format; /* the server's preferred pixel format */ CARD32 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 /* UltraVNC/PalmVNC messages */ #define rfbResizeFrameBuffer 4 /* Modif sf@2002 */ #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 /* UltraVNC/PalmVNC messages */ #define rfbFileTransfer 7 /* Modif sf@2002 - actually bidirectionnal */ #define rfbSetScale 8 /* Modif sf@2002 */ #define rfbSetServerInput 9 /* Modif rdv@2002 */ #define rfbSetSW 10 /* Modif rdv@2002 */ #define rfbTextChat 11 /* Modif sf@2002 - TextChat - Bidirectionnal */ #define rfbPalmVNCSetScaleFactor 0xF /* PalmVNC 1.4 & 2.0 SetScale Factor message */ #define rfbEnableExtensionRequest 10 #define rfbExtensionData 11 /***************************************************************************** * * Encoding types * *****************************************************************************/ #define rfbEncodingRaw 0 #define rfbEncodingCopyRect 1 #define rfbEncodingRRE 2 #define rfbEncodingCoRRE 4 #define rfbEncodingHextile 5 #define rfbEncodingZlib 6 #define rfbEncodingTight 7 #define rfbEncodingZlibHex 8 #define rfbEncodingZRLE 16 /* * Special encoding numbers: * 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. */ /* UltraVNC */ /* 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 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 /* UltraVNC */ #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 /***************************************************************************** * * 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 { CARD8 type; /* always rfbFramebufferUpdate */ CARD8 pad; CARD16 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; CARD32 encoding; /* one of the encoding types rfbEncoding... */ } rfbFramebufferUpdateRectHeader; #define sz_rfbFramebufferUpdateRectHeader (sz_rfbRectangle + 4) /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Raw Encoding. Pixels are sent in top-to-bottom scanline order, * left-to-right within a scanline with no padding in between. */ /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CopyRect Encoding. The pixels are specified simply by the x and y position * of the source rectangle. */ typedef struct { CARD16 srcX; CARD16 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 { CARD32 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 { CARD8 x; CARD8 y; CARD8 w; CARD8 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. */ typedef struct { CARD32 nBytes; } rfbZlibHeader; #define sz_rfbZlibHeader 4 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * ZRLE - encoding combining Zlib compression, tiling, palettisation and * run-length encoding. */ typedef struct { CARD32 length; } rfbZRLEHeader; #define sz_rfbZRLEHeader 4 #define rfbZRLETileWidth 64 #define rfbZRLETileHeight 64 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Tight Encoding. * *-- 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", * if 0xxx, then the compression type is "basic", * values greater than 1001 are not valid. * * If the compression type is "basic", 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" 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", the following data stream looks like * this: * * 1..3 bytes: data size (N) in compact representation; * N bytes: JPEG 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" or "jpeg". * *-- 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 rfbTightMaxSubencoding 0x09 /* Filters to improve compression efficiency */ #define rfbTightFilterCopy 0x00 #define rfbTightFilterPalette 0x01 #define rfbTightFilterGradient 0x02 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * 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) /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * 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 { CARD8 foreRed; CARD8 foreGreen; CARD8 foreBlue; CARD8 backRed; CARD8 backGreen; CARD8 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). */ /*----------------------------------------------------------------------------- * 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 { CARD8 type; /* always rfbSetColourMapEntries */ CARD8 pad; CARD16 firstColour; CARD16 nColours; /* Followed by nColours * 3 * CARD16 r1, g1, b1, r2, g2, b2, r3, g3, b3, ..., rn, bn, gn */ } rfbSetColourMapEntriesMsg; #define sz_rfbSetColourMapEntriesMsg 6 /***************************************************************************** * * Bi-directional message types * *****************************************************************************/ /*----------------------------------------------------------------------------- * EnableExtension - tell client/server that a particular extension is available, * or reconfigure an extension. If the new_msg field is non-zero then the sender * is indicating that the specified protocol uses the given message number. * The recipient may then send rfbExtensionData messages on the given message * number, provided the extension configuration data is recognised. * * The length field in the ExtensionData message may be invalid, if the zeroeth * bit of "flags" was not set in the corresponding EnableExtensionRequest. * If the length field is invalid then obviously the message can't be dealt * with by dumb proxies - avoid this where possible. * * The first bit of the flags field indicates that the extension is a new, named * encoding. This form is used by servers to tell clients the names of the * encodings they support. Typically, a receiving client will then dispatch * an "enable encoding" message for the specified encoding number, if supported. */ typedef struct { CARD8 type; /* always rfbEnableExtensionRequest */ CARD8 new_msg; CARD8 flags; CARD8 pad1; CARD32 length; /* Followed by bytes of data */ } rfbEnableExtensionRequestMsg; #define sz_rfbEnableExtensionRequestMsg 8 typedef struct { CARD8 type; /* always >= rfbExtensionData */ CARD8 pad1; CARD16 pad2; CARD32 length; /* Must be correct if used */ /* Followed by bytes of data */ } rfbExtensionDataMsg; #define sz_rfbExtensionDataMsg 8 /*----------------------------------------------------------------------------- * Bell - ring a bell on the client if it has one. */ typedef struct { CARD8 type; /* always rfbBell */ } rfbBellMsg; #define sz_rfbBellMsg 1 /*----------------------------------------------------------------------------- * ServerCutText - the server has new text in its cut buffer. */ typedef struct { CARD8 type; /* always rfbServerCutText */ CARD8 pad1; CARD16 pad2; CARD32 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 { CARD8 type; /* always rfbFileTransfer */ CARD8 contentType; /* See defines below */ CARD16 contentParam;/* Other possible content classification (Dir or File name, etc..) */ CARD32 size; /* FileSize or packet index or error or other */ CARD32 length; /* followed by data char text[length] */ } rfbFileTransferMsg; #define sz_rfbFileTransferMsg 12 /* 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 tranfer of a given file */ #define rfbFileHeader 4 /* First packet of a file transfer, containing file's features */ #define rfbFilePacket 5 /* One slice 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 */ /* rfbDirContentRequest client Request - content params */ #define rfbRDirContent 1 /* Request a Server Directory contents */ #define rfbRDrivesList 2 /* Request the server's drives list */ /* 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 */ /* 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 */ /* 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 4096 /* Size of a File Transfer packet (before compression) */ /*----------------------------------------------------------------------------- * Modif sf@2002 * TextChatMsg - Utilized to order the TextChat mode on server or client * Bidirectional message */ typedef struct _rfbTextChatMsg { CARD8 type; /* always rfbTextChat */ CARD8 pad1; /* Could be used later as an additionnal param */ CARD16 pad2; /* Could be used later as text offset, for instance */ CARD32 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 /*----------------------------------------------------------------------------- * Modif sf@2002 * ResizeFrameBuffer - The Client must change the size of its framebuffer */ typedef struct _rfbResizeFrameBufferMsg { CARD8 type; /* always rfbResizeFrameBuffer */ CARD8 pad1; CARD16 framebufferWidth; /* FrameBuffer width */ CARD16 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 { CARD8 type; /* always rfbReSizeFrameBuffer */ CARD8 pad1; CARD16 desktop_w; /* Desktop width */ CARD16 desktop_h; /* Desktop height */ CARD16 buffer_w; /* FrameBuffer width */ CARD16 buffer_h; /* Framebuffer height */ CARD16 pad2; } rfbPalmVNCReSizeFrameBufferMsg; #define sz_rfbPalmVNCReSizeFrameBufferMsg (12) /*----------------------------------------------------------------------------- * Union of all server->client messages. */ typedef union { CARD8 type; rfbFramebufferUpdateMsg fu; rfbSetColourMapEntriesMsg scme; rfbBellMsg b; rfbServerCutTextMsg sct; rfbEnableExtensionRequestMsg eer; rfbExtensionDataMsg ed; rfbResizeFrameBufferMsg rsfb; rfbPalmVNCReSizeFrameBufferMsg prsfb; rfbFileTransferMsg ft; rfbTextChatMsg tc; } rfbServerToClientMsg; /***************************************************************************** * * Message definitions (client -> server) * *****************************************************************************/ /*----------------------------------------------------------------------------- * SetPixelFormat - tell the RFB server the format in which the client wants * pixels sent. */ typedef struct { CARD8 type; /* always rfbSetPixelFormat */ CARD8 pad1; CARD16 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 { CARD8 type; /* always rfbFixColourMapEntries */ CARD8 pad; CARD16 firstColour; CARD16 nColours; /* Followed by nColours * 3 * CARD16 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 { CARD8 type; /* always rfbSetEncodings */ CARD8 pad; CARD16 nEncodings; /* followed by nEncodings * CARD32 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 { CARD8 type; /* always rfbFramebufferUpdateRequest */ CARD8 incremental; CARD16 x; CARD16 y; CARD16 w; CARD16 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 { CARD8 type; /* always rfbKeyEvent */ CARD8 down; /* true if down (press), false if up */ CARD16 pad; CARD32 key; /* key is specified as an X keysym */ } rfbKeyEventMsg; #define sz_rfbKeyEventMsg 8 /*----------------------------------------------------------------------------- * PointerEvent - mouse/pen move and/or button press. */ typedef struct { CARD8 type; /* always rfbPointerEvent */ CARD8 buttonMask; /* bits 0-7 are buttons 1-8, 0=up, 1=down */ CARD16 x; CARD16 y; } rfbPointerEventMsg; #define rfbButton1Mask 1 #define rfbButton2Mask 2 #define rfbButton3Mask 4 #define rfbButton4Mask 8 #define rfbButton5Mask 16 #define rfbWheelUpMask rfbButton4Mask #define rfbWheelDownMask rfbButton5Mask #define sz_rfbPointerEventMsg 6 /*----------------------------------------------------------------------------- * ClientCutText - the client has new text in its cut buffer. */ typedef struct { CARD8 type; /* always rfbClientCutText */ CARD8 pad1; CARD16 pad2; CARD32 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 { CARD8 type; /* always rfbSetScale */ CARD8 scale; /* Scale value 1server messages. */ typedef union { CARD8 type; rfbSetPixelFormatMsg spf; rfbFixColourMapEntriesMsg fcme; rfbSetEncodingsMsg se; rfbFramebufferUpdateRequestMsg fur; rfbKeyEventMsg ke; rfbPointerEventMsg pe; rfbClientCutTextMsg cct; rfbEnableExtensionRequestMsg eer; rfbExtensionDataMsg ed; rfbSetScaleMsg ssc; rfbPalmVNCSetScaleFactorMsg pssf; rfbSetServerInputMsg sim; rfbFileTransferMsg ft; rfbSetSWMsg sw; rfbTextChatMsg tc; } rfbClientToServerMsg; vncsnapshot-1.2a/vncpasswd.c0100644005671200567000000000647410117721111015632 0ustar grantharmony/* * 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. */ /* * vncpasswd: A standalone program which gets and verifies a password, * encrypts it, and stores it to a file. Always ignore anything * after 8 characters, since this is what Solaris getpass() does * anyway. */ #include #include #include #ifndef WIN32 #include #else #include #endif #include "vncauth.h" #define MINPASSWD 6 #ifdef WIN32 static char *vnc_getpass(const char *prompt); #else /* *nix systems can use the system getpass() function. */ #define vnc_getpass(prompt) getpass(prompt) #endif static void usage(char *argv[]) { #ifdef WIN32 fprintf(stderr,"Usage: %s file\n",argv[0]); #else fprintf(stderr,"Usage: %s [file]\n",argv[0]); #endif exit(1); } int main(int argc, char *argv[]) { char *passwd; char *passwd1; char passwdFile[256]; int i; #ifndef WIN32 /* Home directory only applies on *nix systems */ if (argc == 1) { if (getenv("HOME") == NULL) { fprintf(stderr,"Error: no HOME environment variable\n"); exit(1); } sprintf(passwdFile,"%s/.vnc/passwd",getenv("HOME")); } else #endif if (argc == 2) { strcpy(passwdFile,argv[1]); } else { usage(argv); } while (1) { passwd = vnc_getpass("Password: "); if (!passwd) { fprintf(stderr,"Can't get password: not a tty?\n"); exit(1); } if (strlen(passwd) < MINPASSWD) { fprintf(stderr,"Password too short\n"); exit(1); } if (strlen(passwd) > MAXPWLEN) { fprintf(stderr, "Warning: password truncated to 8 characters\n"); passwd[MAXPWLEN] = '\0'; } passwd1 = strdup(passwd); passwd = vnc_getpass("Verify: "); if (strlen(passwd) > MAXPWLEN) { passwd[MAXPWLEN] = '\0'; } if (strcmp(passwd1, passwd) == 0) { if (vncEncryptAndStorePasswd(passwd, passwdFile) != 0) { fprintf(stderr,"Cannot write password file %s\n",passwdFile); exit(1); } for (i = 0; i < strlen(passwd); i++) passwd[i] = passwd1[i] = '\0'; return 0; } fprintf(stderr,"They don't match. Try again.\n\n"); } } #ifdef WIN32 char * vnc_getpass(const char *prompt) { register char *p; register c; static char pbuf[50+1]; fprintf(stderr, "%s", prompt); (void) fflush(stderr); for (p=pbuf; (c = _getch())!=13 && c!=EOF;) { if (p < &pbuf[sizeof(pbuf)-1]) *p++ = c; } *p = '\0'; fprintf(stderr, "\n"); (void) fflush(stderr); return(pbuf); } #endif vncsnapshot-1.2a/stdhdrs.h0100644005671200567000000000264507431306773015320 0ustar grantharmony// Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. // // This file is part of the VNC system. // // The VNC system 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. // // TightVNC distribution homepage on the Web: http://www.tightvnc.com/ // // If the source code for the VNC system is not available from the place // whence you received this file, check http://www.uk.research.att.com/vnc or contact // the authors on vnc@uk.research.att.com for information on obtaining it. #define VC_EXTRALEAN #ifdef WIN32 #include #include #include #include #include #include #endif #include #include #include #include #include #include "rfb.h" vncsnapshot-1.2a/run-sf-compiles0100755005671200567000000000202110120127331016405 0ustar grantharmony#!/bin/sh RELEASE=1.2a # x86-openbsd1 OpenBSD 3.4 # x86-solaris1 Solaris 9 # x86-linux1 Linux 2.4 (Debian 2.2) # x86-linux2 Linux 2.4 (Redhat 9.0) # x86-freebsd1 FreeBSD (4.8) # x86-netbsd1 NetBSD (1.6.1) # amd64-linux1 Linux 2.4 (SuSE 8 ES on AMD64 Opteron) # alpha-linux1 Linux 2.2 (Debian 3.0) # ppc-osx1 MacOS X 10.1 SERVER Edition # ppc-osx2 MacOS X 10.2 SERVER Edition # sparc-solaris1 [R220] Sun Solaris (9) #1 # sparc-solaris2 [R220] Sun Solaris (9) #2 HOSTS='x86-openbsd1 x86-solaris1 x86-linux1 x86-linux2 x86-freebsd1 x86-netbsd1 amd64-linux1 alpha-linux1 ppc-osx1 ppc-osx2 sparc-solaris1' scp vncsnapshot-${RELEASE}-src.tar.bz2 cv-shell.sf.net: cmd="tar xjf vncsnapshot-${RELEASE}-src.tar.bz2;" cmd="${cmd}cp vncsnapshot-${RELEASE}/make_release_bin .;" for h in $HOSTS;do cmd="${cmd}echo Compiling for $h;ssh $h ./make_release_bin ${RELEASE};echo;echo;echo;" done cmd="${cmd}tar cjf binaries-${RELEASE}.tar.bz2 bin ldd-info" ssh cf-shell.sf.net "$cmd" scp cf-shell.sf.net:binaries-${RELEASE}.tar.bz2 . vncsnapshot-1.2a/sockets.cxx0100644005671200567000000002052210117721111015643 0ustar grantharmony/* * 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. */ /* * sockets.cxx - functions to deal with sockets. */ static const char *ID = "$Id: sockets.cxx,v 1.3 2004/09/09 00:22:33 grmcdorman Exp $"; #ifdef WIN32 #include #define close(x) closesocket(x) typedef int socklen_t; #else #include #include #include #include #include #include #include #include #endif #ifdef __APPLE__ typedef int socklen_t; #endif extern "C" { #include "vncsnapshot.h" } #include #include #include extern "C" { void PrintInHex(char *buf, int len); } int rfbsock; rdr::FdInStream* fis; rdr::FdOutStream* fos; Bool sameMachine = False; /*static Bool rfbsockReady = False;*/ /* * InitializeSockets is called on startup. It will do any required one-time setup * for the network. * * On *nix systems, it does nothing. * * On Windows, it initializes Windows Sockets. */ extern "C" Bool InitializeSockets(void) { #ifdef WIN32 WORD wVersionRequested; WSADATA wsaData; int err; wVersionRequested = MAKEWORD( 2, 2 ); err = WSAStartup( wVersionRequested, &wsaData ); if ( err != 0 ) { fprintf(stderr, "Cannot initialize Windows Sockets\n"); return False; } /* Confirm that the WinSock DLL supports 2.2.*/ /* Note that if the DLL supports versions greater */ /* than 2.2 in addition to 2.2, it will still return */ /* 2.2 in wVersion since that is the version we */ /* requested. */ if ( LOBYTE( wsaData.wVersion ) != 2 || HIBYTE( wsaData.wVersion ) != 2 ) { fprintf(stderr, "Cannot get proper version of Windows Sockets\n"); WSACleanup( ); return False; } /* The WinSock DLL is acceptable. Proceed. */ #endif return True; } /* * ConnectToRFBServer. */ Bool ConnectToRFBServer(const char *hostname, int port) { int sock = ConnectToTcpAddr(hostname, port); if (sock < 0) { fprintf(stderr,"Unable to connect to VNC server\n"); return False; } return SetRFBSock(sock); } Bool SetRFBSock(int sock) { try { rfbsock = sock; fis = new rdr::FdInStream(rfbsock); fos = new rdr::FdOutStream(rfbsock); struct sockaddr_in peeraddr, myaddr; socklen_t addrlen = sizeof(struct sockaddr_in); getpeername(sock, (struct sockaddr *)&peeraddr, &addrlen); getsockname(sock, (struct sockaddr *)&myaddr, &addrlen); sameMachine = (peeraddr.sin_addr.s_addr == myaddr.sin_addr.s_addr); return True; } catch (rdr::Exception& e) { fprintf(stderr,"initialiseInStream: %s\n",e.str()); } return False; } Bool ReadFromRFBServer(char *out, unsigned int n) { try { fis->readBytes(out, n); return True; } catch (rdr::Exception& e) { fprintf(stderr,"ReadFromRFBServer: %s\n",e.str()); } return False; } /* * Write an exact number of bytes, and don't return until you've sent them. */ Bool WriteToRFBServer(char *buf, int n) { try { fos->writeBytes(buf, n); fos->flush(); return True; } catch (rdr::Exception& e) { fprintf(stderr,"WriteExact: %s\n",e.str()); } return False; } /* * ConnectToTcpAddr connects to the given host and port. */ int ConnectToTcpAddr(const char* hostname, int port) { int sock; struct sockaddr_in addr; int one = 1; unsigned int host; if (!StringToIPAddr(hostname, &host)) { fprintf(stderr,"Couldn't convert '%s' to host address\n", hostname); return -1; } memset(&addr, 0, sizeof(addr)); 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) { fprintf(stderr,programName); perror(": ConnectToTcpAddr: socket"); return -1; } if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { fprintf(stderr,programName); perror(": ConnectToTcpAddr: connect"); close(sock); return -1; } if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(one)) < 0) { fprintf(stderr,programName); perror(": ConnectToTcpAddr: setsockopt"); close(sock); return -1; } return sock; } /* * 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 = INADDR_ANY; sock = socket(AF_INET, SOCK_STREAM, 0); if (sock < 0) { fprintf(stderr,programName); perror(": FindFreeTcpPort: socket"); 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) { int sock; struct sockaddr_in addr; int one = 1; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(port); addr.sin_addr.s_addr = INADDR_ANY; sock = socket(AF_INET, SOCK_STREAM, 0); if (sock < 0) { fprintf(stderr,programName); perror(": ListenAtTcpPort: socket"); return -1; } if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char *)&one, sizeof(one)) < 0) { fprintf(stderr,programName); perror(": ListenAtTcpPort: setsockopt"); close(sock); return -1; } if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { fprintf(stderr,programName); perror(": ListenAtTcpPort: bind"); close(sock); return -1; } if (listen(sock, 5) < 0) { fprintf(stderr,programName); perror(": ListenAtTcpPort: listen"); 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) { fprintf(stderr,programName); perror(": AcceptTcpConnection: accept"); return -1; } if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(one)) < 0) { fprintf(stderr,programName); perror(": AcceptTcpConnection: setsockopt"); close(sock); return -1; } return sock; } /* * StringToIPAddr - convert a host string to an IP address. */ Bool StringToIPAddr(const char *str, unsigned int *addr) { struct hostent *hp; if (strcmp(str,"") == 0) { *addr = 0; /* local */ return True; } *addr = inet_addr(str); if (*addr != (unsigned int)-1) return True; hp = gethostbyname(str); if (hp) { *addr = *(unsigned int *)hp->h_addr; return True; } return False; } /* * 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; fprintf(stderr,"ReadExact: "); for (i = 0; i < len; i++) { if ((i % 16 == 0) && (i != 0)) { fprintf(stderr," "); } c = buf[i]; str[i % 16] = (((c > 31) && (c < 127)) ? c : '.'); fprintf(stderr,"%02x ",(unsigned char)c); if ((i % 4) == 3) fprintf(stderr," "); if ((i % 16) == 15) { fprintf(stderr,"%s\n",str); } } if ((i % 16) != 0) { for (j = i % 16; j < 16; j++) { fprintf(stderr," "); if ((j % 4) == 3) fprintf(stderr," "); } str[i % 16] = 0; fprintf(stderr,"%s\n",str); } fflush(stderr); } vncsnapshot-1.2a/tunnel.c0100644005671200567000000001551607640172400015134 0ustar grantharmony/* * Copyright (C) 2000 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. */ /* * tunnel.c - tunneling support (e.g. for using standalone SSH installation) */ static const char *ID = "$Id: tunnel.c,v 1.5 2003/03/26 00:32:00 grmcdorman Exp $"; #ifndef WIN32 #include #endif #include #include #include "vncsnapshot.h" #ifdef WIN32 #define stat _stat #ifndef S_ISREG #define S_ISREG(x) (x & _S_IFREG) #endif #endif /* If S_ISLNK is not defined, assume links don't exist */ #ifndef S_ISLNK #define S_ISLNK(x) (0) #endif /* True if there was -tunnel or -via option in the command line. */ Bool tunnelSpecified = False; /* True if it was -tunnel, not -via option. */ static Bool tunnelOption = False; /* "Hostname:display" pair in the command line will be substituted by this fake argument when tunneling is used. */ static char lastArgv[32]; static void processTunnelArgs(char **remoteHost, int *remotePort, int localPort, int *pargc, char **argv, int tunnelArgIndex); static void processViaArgs(char **gatewayHost, char **remoteHost, int *remotePort, int localPort, int *pargc, char **argv, int tunnelArgIndex); static char *getCmdPattern(void); static Bool fillCmdPattern(char *result, char *pattern, char *gatewayHost, char *remoteHost, char *remotePort, char *localPort); static Bool runCommand(char *cmd); Bool createTunnel(int *pargc, char **argv, int tunnelArgIndex) { char *pattern; char cmd[1024]; int localPort, remotePort; char localPortStr[8]; char remotePortStr[8]; char *gatewayHost = ""; char *remoteHost = "localhost"; tunnelSpecified = True; if (strcmp(argv[tunnelArgIndex], "-tunnel") == 0) tunnelOption = True; pattern = getCmdPattern(); if (!pattern) return False; localPort = FindFreeTcpPort(); if (localPort == 0) return False; if (tunnelOption) { processTunnelArgs(&remoteHost, &remotePort, localPort, pargc, argv, tunnelArgIndex); } else { processViaArgs(&gatewayHost, &remoteHost, &remotePort, localPort, pargc, argv, tunnelArgIndex); } sprintf(localPortStr, "%d", localPort); sprintf(remotePortStr, "%d", remotePort); if (!fillCmdPattern(cmd, pattern, gatewayHost, remoteHost, remotePortStr, localPortStr)) return False; if (!runCommand(cmd)) return False; return True; } static void processTunnelArgs(char **remoteHost, int *remotePort, int localPort, int *pargc, char **argv, int tunnelArgIndex) { char *pdisplay; if (tunnelArgIndex >= *pargc - 1) usage(); pdisplay = strchr(argv[*pargc - 1], ':'); if (pdisplay == NULL || pdisplay == argv[*pargc - 1]) usage(); *pdisplay++ = '\0'; if (strspn(pdisplay, "-0123456789") != strlen(pdisplay)) usage(); *remotePort = atoi(pdisplay); if (*remotePort < 100) *remotePort += SERVER_PORT_OFFSET; sprintf(lastArgv, "localhost:%d", localPort); *remoteHost = argv[*pargc - 1]; argv[*pargc - 1] = lastArgv; removeArgs(pargc, argv, tunnelArgIndex, 1); } static void processViaArgs(char **gatewayHost, char **remoteHost, int *remotePort, int localPort, int *pargc, char **argv, int tunnelArgIndex) { char *colonPos; int len, portOffset; if (tunnelArgIndex >= *pargc - 2) usage(); colonPos = strchr(argv[*pargc - 1], ':'); if (colonPos == NULL) { /* No colon -- use default port number */ *remotePort = SERVER_PORT_OFFSET; } else { *colonPos++ = '\0'; len = strlen(colonPos); portOffset = SERVER_PORT_OFFSET; if (colonPos[0] == ':') { /* Two colons -- interpret as a port number */ colonPos++; len--; portOffset = 0; } if (!len || strspn(colonPos, "-0123456789") != len) { usage(); } *remotePort = atoi(colonPos) + portOffset; } sprintf(lastArgv, "localhost::%d", localPort); *gatewayHost = argv[tunnelArgIndex + 1]; if (argv[*pargc - 1][0] != '\0') *remoteHost = argv[*pargc - 1]; argv[*pargc - 1] = lastArgv; removeArgs(pargc, argv, tunnelArgIndex, 2); } static char * getCmdPattern(void) { struct stat st; char *pattern; pattern = getenv((tunnelOption) ? "VNC_TUNNEL_CMD" : "VNC_VIA_CMD"); if (pattern == NULL) { if ( stat(DEFAULT_SSH_CMD, &st) != 0 || !(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) ) { fprintf(stderr, "%s: Cannot establish SSH tunnel: missing %s binary.\n", programName, DEFAULT_SSH_CMD); return NULL; } pattern = (tunnelOption) ? DEFAULT_TUNNEL_CMD : DEFAULT_VIA_CMD; } return pattern; } /* Note: in fillCmdPattern() result points to a 1024-byte buffer */ static Bool fillCmdPattern(char *result, char *pattern, char *gatewayHost, char *remoteHost, char *remotePort, char *localPort) { int i, j; Bool H_found = False, G_found = False, R_found = False, L_found = False; for (i=0, j=0; pattern[i] && j<1023; i++, j++) { if (pattern[i] == '%') { switch (pattern[++i]) { case 'H': strncpy(&result[j], remoteHost, 1024 - j); j += strlen(remoteHost) - 1; H_found = True; continue; case 'G': strncpy(&result[j], gatewayHost, 1024 - j); j += strlen(gatewayHost) - 1; G_found = True; continue; case 'R': strncpy(&result[j], remotePort, 1024 - j); j += strlen(remotePort) - 1; R_found = True; continue; case 'L': strncpy(&result[j], localPort, 1024 - j); j += strlen(localPort) - 1; L_found = True; continue; case '\0': i--; continue; } } result[j] = pattern[i]; } if (pattern[i]) { fprintf(stderr, "%s: Tunneling command is too long.\n", programName); return False; } if (!H_found || !R_found || !L_found) { fprintf(stderr, "%s: %%H, %%R or %%L absent in tunneling command.\n", programName); return False; } if (!tunnelOption && !G_found) { fprintf(stderr, "%s: %%G pattern absent in tunneling command.\n", programName); return False; } result[j] = '\0'; return True; } static Bool runCommand(char *cmd) { if (system(cmd) != 0) { fprintf(stderr, "%s: Tunneling command failed: %s.\n", programName, cmd); return False; } return True; } vncsnapshot-1.2a/version.h0100644005671200567000000000004410120127016015275 0ustar grantharmony#define VNC_SNAPSHOT_VERSION "1.2a" vncsnapshot-1.2a/vncauth.c0100644005671200567000000001127710117721111015267 0ustar grantharmony// Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. // // This file is part of the VNC system. // // The VNC system 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. // // TightVNC distribution homepage on the Web: http://www.tightvnc.com/ // // If the source code for the VNC system is not available from the place whence // you received this file, check http://www.uk.research.att.com/vnc or contact // the authors on vnc@uk.research.att.com for information on obtaining it. /* * vncauth.c - Functions for VNC password management and authentication. */ static const char *ID = "$Id: vncauth.c,v 1.5 2004/09/09 00:22:33 grmcdorman Exp $"; #ifndef WIN32 #include #include #include #include #include #endif #include "stdhdrs.h" #include "vncauth.h" #include "d3des.h" #include /* * 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. */ 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 vncEncryptAndStorePasswd(char *passwd, char *fname) { FILE *fp; int i; unsigned char encryptedPasswd[8]; if ((fp = fopen(fname,"wb")) == NULL) return 1; #ifndef WIN32 chmod(fname, 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 */ deskey(fixedkey, EN0); des(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 * vncDecryptPasswdFromFile(char *fname) { FILE *fp; int i, ch; unsigned char *passwd = (unsigned char *)malloc(9); if ((fp = fopen(fname,"r")) == NULL) return NULL; for (i = 0; i < 8; i++) { ch = getc(fp); if (ch == EOF) { fclose(fp); return NULL; } passwd[i] = ch; } fclose(fp); deskey(fixedkey, DE1); des(passwd, passwd); passwd[8] = 0; return (char *)passwd; } /* * Encrypt CHALLENGESIZE bytes in memory using a password. */ void vncEncryptBytes(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; } } deskey(key, EN0); for (i = 0; i < CHALLENGESIZE; i += 8) { des(bytes+i, bytes+i); } } /* * Encrypt a password into the specified space. * encryptedPasswd will be 8 bytes long - sufficient space * should be allocated. */ void vncEncryptPasswd( unsigned char *encryptedPasswd, char *passwd ) { unsigned int i; /* pad password with nulls */ for (i = 0; i < MAXPWLEN; 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 */ deskey(fixedkey, EN0); des(encryptedPasswd, encryptedPasswd); } /* * Decrypt a password. 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 * vncDecryptPasswd(const unsigned char *encryptedPasswd) { unsigned int i; unsigned char *passwd = (unsigned char *)malloc(MAXPWLEN+1); memcpy(passwd, encryptedPasswd, MAXPWLEN); for (i = 0; i < MAXPWLEN; i++) { passwd[i] = encryptedPasswd[i]; } deskey(fixedkey, DE1); des(passwd, passwd); passwd[MAXPWLEN] = 0; return (char *)passwd; } vncsnapshot-1.2a/vncauth.h0100644005671200567000000000312410117721111015264 0ustar grantharmony// Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. // // This file is part of the VNC system. // // The VNC system 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. // // TightVNC distribution homepage on the Web: http://www.tightvnc.com/ // // If the source code for the VNC system is not available from the place // whence you received this file, check http://www.uk.research.att.com/vnc or contact // the authors on vnc@uk.research.att.com for information on obtaining it. /* * vncauth.h - describes the functions provided by the vncauth library. */ #define MAXPWLEN 8 #define CHALLENGESIZE 16 extern int vncEncryptAndStorePasswd(char *passwd, char *fname); extern char *vncDecryptPasswdFromFile(char *fname); extern void vncEncryptBytes(unsigned char *bytes, char *passwd); extern void vncEncryptPasswd(unsigned char *encryptedPasswd, char *passwd); extern char *vncDecryptPasswd(const unsigned char *encryptedPasswd); vncsnapshot-1.2a/vncsnapshot.dsp0100644005671200567000000001256207574257252016556 0ustar grantharmony# Microsoft Developer Studio Project File - Name="vncsnapshot" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=vncsnapshot - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "vncsnapshot.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "vncsnapshot.mak" CFG="vncsnapshot - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "vncsnapshot - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "vncsnapshot - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "vncsnapshot - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /I "libjpeg" /I "." /I ".\libjpeg" /I ".\zlib" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x1009 /d "NDEBUG" # ADD RSC /l 0x1009 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib zlib.lib libjpeg.lib rdr.lib /nologo /subsystem:console /machine:I386 /libpath:".\libjpeg\Release" /libpath:".\zlib\Release" /libpath:".\rdr\Release" !ELSEIF "$(CFG)" == "vncsnapshot - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I ".\libjpeg" /I ".\zlib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c # ADD BASE RSC /l 0x1009 /d "_DEBUG" # ADD RSC /l 0x1009 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib zlib.lib libjpeg.lib rdr.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:".\libjpeg\Debug" /libpath:".\zlib\Debug" /libpath:".\rdr\Debug" !ENDIF # Begin Target # Name "vncsnapshot - Win32 Release" # Name "vncsnapshot - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\argsresources.c # End Source File # Begin Source File SOURCE=.\buffer.c # End Source File # Begin Source File SOURCE=.\cursor.c # End Source File # Begin Source File SOURCE=.\d3des.c # End Source File # Begin Source File SOURCE=.\getpass.c # End Source File # Begin Source File SOURCE=.\listen.c # End Source File # Begin Source File SOURCE=.\rfbproto.c # End Source File # Begin Source File SOURCE=.\sockets.cxx # End Source File # Begin Source File SOURCE=.\tunnel.c # End Source File # Begin Source File SOURCE=.\vncauth.c # End Source File # Begin Source File SOURCE=.\vncsnapshot.c # End Source File # Begin Source File SOURCE=.\zrle.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\d3des.h # End Source File # Begin Source File SOURCE=.\rfb.h # End Source File # Begin Source File SOURCE=.\rfbproto.h # End Source File # Begin Source File SOURCE=.\stdhdrs.h # End Source File # Begin Source File SOURCE=.\vncauth.h # End Source File # Begin Source File SOURCE=.\vncsnapshot.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project vncsnapshot-1.2a/vncpasswd.dsp0100644005671200567000000001072210117721111016165 0ustar grantharmony# Microsoft Developer Studio Project File - Name="vncpasswd" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=vncpasswd - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "vncpasswd.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "vncpasswd.mak" CFG="vncpasswd - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "vncpasswd - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "vncpasswd - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "vncpasswd - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "vncpasswd - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "vncpasswd - Win32 Release" # Name "vncpasswd - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\d3des.c # End Source File # Begin Source File SOURCE=.\vncauth.c # End Source File # Begin Source File SOURCE=.\vncpasswd.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\d3des.h # End Source File # Begin Source File SOURCE=.\vncauth.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project vncsnapshot-1.2a/vncsnapshot.c0100644005671200567000000002146110117721111016161 0ustar grantharmony/* * 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. */ /* * vncsnapshot.c - the VNC snapshot. */ static const char *ID = "$Id: vncsnapshot.c,v 1.7 2004/09/09 00:22:33 grmcdorman Exp $"; #include #include #include "vncsnapshot.h" char *programName; #ifdef WIN32 /* On Win32, sleep() doesn't exist, but Sleep() does, and * takes an argument of milliseconds. */ #include /* for Sleep() */ static void sleep(int seconds) { Sleep(seconds * 1000); } #endif int main(int argc, char **argv) { int i = 0; int count = 1; /* for multiple snapshots,snapshot number */ char *filename; /* output filename; for multiple snapshots, constructed */ char *cp; /* work variable */ char *suffix = NULL; /* suffix to follow snapshot number, including . */ char *append = NULL; /* point in *filename to put count and suffix */ time_t last_time = 0; /* value of time() at last snapshot */ programName = argv[0]; if (!InitializeSockets()) { return 1; } /* The -listen option is used to make us a daemon process which listens for incoming connections from servers, rather than actively connecting to a given server. The -tunnel and -via options are useful to create connections tunneled via SSH port forwarding. We must test for the -listen option before invoking any Xt functions - this is because we use forking, and Xt doesn't seem to cope with forking very well. For -listen option, when a successful incoming connection has been accepted, listenForIncomingConnections() returns, setting the listenSpecified flag. */ for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-listen") == 0) { listenForIncomingConnections(&argc, argv, i); break; } if (strcmp(argv[i], "-tunnel") == 0 || strcmp(argv[i], "-via") == 0) { if (!createTunnel(&argc, argv, i)) exit(1); break; } } /* Interpret resource specs and process any remaining command-line arguments (i.e. the VNC server name). If the server name isn't specified on the command line, getArgsAndResources() will complain and exit. */ GetArgsAndResources(argc, argv); /* Unless we accepted an incoming connection, make a TCP connection to the given VNC server */ if (!listenSpecified) { if (!ConnectToRFBServer(vncServerHost, vncServerPort)) exit(1); } /* Initialise the VNC connection, including reading the password */ if (!InitialiseRFBConnection()) exit(1); if (!AllocateBuffer()) exit(1); /* Tell the VNC server which pixel format and encodings we want to use */ SendSetPixelFormat(); SendSetEncodings(); /* Set up for mutiple images, if required */ if (appData.count > 1) { last_time = time(NULL); count = 0; /* Maximum length of a 32-bit integer is 10 digits plus sign */ filename = (char *) malloc(strlen(appData.outputFilename) + 11 + 1); /* Determine where to insert number. If the supplied filename * ends in .jpg, or .jpeg (case insensitive), then it goes * before that. If not, it goes at the end, with .jpg appended. */ cp = strrchr(appData.outputFilename, '.'); if (cp != NULL) { char *jpg = "jpg"; char *jpeg = "jpeg"; int is_jpg = 1; i = 0; while (cp[i+1]) { if (tolower(cp[i+1]) != jpg[i]) { is_jpg = 0; break; } i++; } if (!is_jpg) { i = 0; while (cp[i+1]) { if (tolower(cp[i+1]) != jpeg[i]) { cp = NULL; break; } i++; } } } if (cp != NULL) { strncpy(filename, appData.outputFilename, cp - appData.outputFilename); append = filename + (cp - appData.outputFilename); suffix = cp; } else { strcpy(filename, appData.outputFilename); suffix = ".jpg"; append = filename + strlen(filename); } } else { /* Not doing repetitive snapshots. */ filename = appData.outputFilename; } /* Grab image; delay and repeat if requested */ do { if(appData.count > 1) { sprintf(append, "%05d%s", count, suffix); count++; } /* Now enter the main loop, processing VNC messages. */ /* * Negative X/Y implies from opposite edge. */ if (appData.rectX < 0) { appData.rectX = si.framebufferWidth + appData.rectX; } else if (appData.rectXNegative) { appData.rectX = si.framebufferWidth - appData.rectX - appData.rectWidth; } if (appData.rectY < 0) { appData.rectY = si.framebufferHeight + appData.rectY; } else if (appData.rectYNegative) { appData.rectY = si.framebufferHeight - appData.rectY - appData.rectHeight; } if (appData.rectX >= si.framebufferWidth || appData.rectX < 0) { fprintf(stderr, "%s: Requested rectangle x <%ld> is outside screen width <%d>, using 0\n", programName, appData.rectX, si.framebufferWidth); appData.rectX = 0; } if (appData.rectY >= si.framebufferHeight || appData.rectY < 0) { fprintf(stderr, "%s: Requested rectangle y <%ld> is outside screen height <%d>, using 0\n", programName, appData.rectY, si.framebufferHeight); appData.rectY = 0; } /* * Width/height of 0 means to edge. */ if (appData.rectWidth == 0) { appData.rectWidth = si.framebufferWidth - appData.rectX; } if (appData.rectHeight == 0) { appData.rectHeight = si.framebufferHeight - appData.rectY; } if (appData.rectWidth <= 0 || appData.rectWidth > si.framebufferWidth - appData.rectX) { fprintf(stderr, "%s: Requested rectangle width <%ld> plus offset <%ld> is wider than screen width <%d>, using %ld\n", programName, appData.rectWidth, appData.rectX, si.framebufferWidth, si.framebufferWidth - appData.rectX); appData.rectWidth = si.framebufferWidth - appData.rectX; } if (appData.rectHeight <= 0 || appData.rectHeight > si.framebufferHeight - appData.rectY) { fprintf(stderr, "%s: Requested rectangle height <%ld> plus offset <%ld> is wider than screen height <%d>, using %ld\n", programName, appData.rectHeight, appData.rectY, si.framebufferHeight, si.framebufferHeight - appData.rectY); appData.rectHeight = si.framebufferHeight - appData.rectY; } if (!SendFramebufferUpdateRequest(appData.rectX, appData.rectY, appData.rectWidth, appData.rectHeight, False)) { exit(1); } while (1) { if (!HandleRFBServerMessage()) break; } /* shrink buffer to requested rectangle */ ShrinkBuffer(appData.rectX, appData.rectY, appData.rectWidth, appData.rectHeight); write_JPEG_file(filename, appData.saveQuality, appData.rectWidth, appData.rectHeight); if (!appData.quiet) { fprintf(stderr, "Image saved from %s %dx%d screen to ", vncServerName ? vncServerName : "(local host)", si.framebufferWidth, si.framebufferHeight); if (strcmp(filename, "-") == 0) { fprintf(stderr, "- (stdout)"); } else { fprintf(stderr, "%s", filename); } fprintf(stderr, " using %ldx%ld+%ld+%ld rectangle\n", appData.rectWidth, appData.rectHeight, appData.rectX, appData.rectY); if (appData.useRemoteCursor != -1 && !appData.gotCursorPos) { if (appData.useRemoteCursor) { fprintf(stderr, "Warning: -cursor not supported by server, cursor may not be included in image.\n"); } else { fprintf(stderr, "Warning: -nocursor not supported by server, cursor may be included in image.\n"); } } } if (count < appData.count) { /* Sleep until next snapshot time rolls around. Note * that the period to wait will include the time taken * to grab the snapshot. */ time_t now = time(NULL); if (now < last_time + appData.fps) { sleep(last_time + appData.fps - now); } last_time = now; /* Request update - incremental is fine here. */ SendIncrementalFramebufferUpdateRequest(); } } while (count < appData.count); return 0; } vncsnapshot-1.2a/libjpeg/0040755005671200567000000000000010120076456015073 5ustar grantharmonyvncsnapshot-1.2a/libjpeg/Makefile.bcc320100644005671200567000000000366107431306773017442 0ustar grantharmony# Makefile for Independent JPEG Group's software # This makefile is for command-line Borland C++ 5.5 compiler (Win32). # It builds the IJG library as a statically linkable library (.LIB). CC=bcc32 LIB=tlib CFLAGS= -v- -O2 -3 -tWM -q -w-8004 -w-8057 LIBFLAGS= /C # Put here the object file name for the correct system-dependent memory # manager file. For NT we suggest jmemnobs.obj, which expects the OS to # provide adequate virtual memory. SYSDEPMEM=jmemnobs.obj # End of configurable options. OBJS=jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) \ jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj \ jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ jquant1.obj jquant2.obj jdmerge.obj pOBJS=+jcomapi.obj +jutils.obj +jerror.obj +jmemmgr.obj +$(SYSDEPMEM) \ +jcapimin.obj +jcapistd.obj +jctrans.obj +jcparam.obj +jdatadst.obj \ +jcinit.obj +jcmaster.obj +jcmarker.obj +jcmainct.obj +jcprepct.obj \ +jccoefct.obj +jccolor.obj +jcsample.obj +jchuff.obj +jcphuff.obj \ +jcdctmgr.obj +jfdctfst.obj +jfdctflt.obj +jfdctint.obj \ +jdapimin.obj +jdapistd.obj +jdtrans.obj +jdatasrc.obj \ +jdmaster.obj +jdinput.obj +jdmarker.obj +jdhuff.obj +jdphuff.obj \ +jdmainct.obj +jdcoefct.obj +jdpostct.obj +jddctmgr.obj +jidctfst.obj \ +jidctflt.obj +jidctint.obj +jidctred.obj +jdsample.obj +jdcolor.obj \ +jquant1.obj +jquant2.obj +jdmerge.obj .autodepend .c.obj: $(CC) -c $(CFLAGS) $< libjpeg.lib: $(OBJS) @if exist $@ del $@ $(LIB) $@ $(LIBFLAGS) $(pOBJS) @if exist libjpeg.bak del libjpeg.bak clean: del *.obj *.lib vncsnapshot-1.2a/libjpeg/jconfig.h0100644005671200567000000000246507431306773016700 0ustar grantharmony/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ /* see jconfig.doc for explanations */ #define HAVE_PROTOTYPES #define HAVE_UNSIGNED_CHAR #define HAVE_UNSIGNED_SHORT /* #define void char */ /* #define const */ #undef CHAR_IS_UNSIGNED #define HAVE_STDDEF_H #define HAVE_STDLIB_H #undef NEED_BSD_STRINGS #undef NEED_SYS_TYPES_H #undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */ #undef NEED_SHORT_EXTERNAL_NAMES #undef INCOMPLETE_TYPES_BROKEN /* Define "boolean" as unsigned char, not int, per Windows custom */ #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ typedef unsigned char boolean; #endif #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ #ifdef JPEG_INTERNALS #undef RIGHT_SHIFT_IS_UNSIGNED #endif /* JPEG_INTERNALS */ #ifdef JPEG_CJPEG_DJPEG #define BMP_SUPPORTED /* BMP image file format */ #define GIF_SUPPORTED /* GIF image file format */ #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ #undef RLE_SUPPORTED /* Utah RLE image file format */ #define TARGA_SUPPORTED /* Targa image file format */ #define TWO_FILE_COMMANDLINE /* optional */ #define USE_SETMODE /* Microsoft has setmode() */ #undef NEED_SIGNAL_CATCHER #undef DONT_USE_B_MODE #undef PROGRESS_REPORT /* optional */ #endif /* JPEG_CJPEG_DJPEG */ vncsnapshot-1.2a/libjpeg/jmorecfg.h0100644005671200567000000003027507431306773017055 0ustar grantharmony/* * jmorecfg.h * * Copyright (C) 1991-1997, Thomas G. Lane. * This file is part of the Independent JPEG Group's software. * For conditions of distribution and use, see the accompanying README file. * * This file contains additional configuration options that customize the * JPEG software for special applications or support machine-dependent * optimizations. Most users will not need to touch this file. */ /* * Define BITS_IN_JSAMPLE as either * 8 for 8-bit sample values (the usual setting) * 12 for 12-bit sample values * Only 8 and 12 are legal data precisions for lossy JPEG according to the * JPEG standard, and the IJG code does not support anything else! * We do not support run-time selection of data precision, sorry. */ #define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ /* * Maximum number of components (color channels) allowed in JPEG image. * To meet the letter of the JPEG spec, set this to 255. However, darn * few applications need more than 4 channels (maybe 5 for CMYK + alpha * mask). We recommend 10 as a reasonable compromise; use 4 if you are * really short on memory. (Each allowed component costs a hundred or so * bytes of storage, whether actually used in an image or not.) */ #define MAX_COMPONENTS 10 /* maximum number of image components */ /* * Basic data types. * You may need to change these if you have a machine with unusual data * type sizes; for example, "char" not 8 bits, "short" not 16 bits, * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, * but it had better be at least 16. */ /* Representation of a single sample (pixel element value). * We frequently allocate large arrays of these, so it's important to keep * them small. But if you have memory to burn and access to char or short * arrays is very slow on your hardware, you might want to change these. */ #if BITS_IN_JSAMPLE == 8 /* JSAMPLE should be the smallest type that will hold the values 0..255. * You can use a signed char by having GETJSAMPLE mask it with 0xFF. */ #ifdef HAVE_UNSIGNED_CHAR typedef unsigned char JSAMPLE; #define GETJSAMPLE(value) ((int) (value)) #else /* not HAVE_UNSIGNED_CHAR */ typedef char JSAMPLE; #ifdef CHAR_IS_UNSIGNED #define GETJSAMPLE(value) ((int) (value)) #else #define GETJSAMPLE(value) ((int) (value) & 0xFF) #endif /* CHAR_IS_UNSIGNED */ #endif /* HAVE_UNSIGNED_CHAR */ #define MAXJSAMPLE 255 #define CENTERJSAMPLE 128 #endif /* BITS_IN_JSAMPLE == 8 */ #if BITS_IN_JSAMPLE == 12 /* JSAMPLE should be the smallest type that will hold the values 0..4095. * On nearly all machines "short" will do nicely. */ typedef short JSAMPLE; #define GETJSAMPLE(value) ((int) (value)) #define MAXJSAMPLE 4095 #define CENTERJSAMPLE 2048 #endif /* BITS_IN_JSAMPLE == 12 */ /* Representation of a DCT frequency coefficient. * This should be a signed value of at least 16 bits; "short" is usually OK. * Again, we allocate large arrays of these, but you can change to int * if you have memory to burn and "short" is really slow. */ typedef short JCOEF; /* Compressed datastreams are represented as arrays of JOCTET. * These must be EXACTLY 8 bits wide, at least once they are written to * external storage. Note that when using the stdio data source/destination * managers, this is also the data type passed to fread/fwrite. */ #ifdef HAVE_UNSIGNED_CHAR typedef unsigned char JOCTET; #define GETJOCTET(value) (value) #else /* not HAVE_UNSIGNED_CHAR */ typedef char JOCTET; #ifdef CHAR_IS_UNSIGNED #define GETJOCTET(value) (value) #else #define GETJOCTET(value) ((value) & 0xFF) #endif /* CHAR_IS_UNSIGNED */ #endif /* HAVE_UNSIGNED_CHAR */ /* These typedefs are used for various table entries and so forth. * They must be at least as wide as specified; but making them too big * won't cost a huge amount of memory, so we don't provide special * extraction code like we did for JSAMPLE. (In other words, these * typedefs live at a different point on the speed/space tradeoff curve.) */ /* UINT8 must hold at least the values 0..255. */ #ifdef HAVE_UNSIGNED_CHAR typedef unsigned char UINT8; #else /* not HAVE_UNSIGNED_CHAR */ #ifdef CHAR_IS_UNSIGNED typedef char UINT8; #else /* not CHAR_IS_UNSIGNED */ typedef short UINT8; #endif /* CHAR_IS_UNSIGNED */ #endif /* HAVE_UNSIGNED_CHAR */ /* UINT16 must hold at least the values 0..65535. */ #ifdef HAVE_UNSIGNED_SHORT typedef unsigned short UINT16; #else /* not HAVE_UNSIGNED_SHORT */ typedef unsigned int UINT16; #endif /* HAVE_UNSIGNED_SHORT */ /* INT16 must hold at least the values -32768..32767. */ #ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ typedef short INT16; #endif /* INT32 must hold at least signed 32-bit values. */ #ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ typedef long INT32; #endif /* Datatype used for image dimensions. The JPEG standard only supports * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore * "unsigned int" is sufficient on all machines. However, if you need to * handle larger images and you don't mind deviating from the spec, you * can change this datatype. */ typedef unsigned int JDIMENSION; #define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ /* These macros are used in all function definitions and extern declarations. * You could modify them if you need to change function linkage conventions; * in particular, you'll need to do that to make the library a Windows DLL. * Another application is to make all functions global for use with debuggers * or code profilers that require it. */ /* a function called through method pointers: */ #define METHODDEF(type) static type /* a function used only in its module: */ #define LOCAL(type) static type /* a function referenced thru EXTERNs: */ #define GLOBAL(type) type /* a reference to a GLOBAL function: */ #define EXTERN(type) extern type /* This macro is used to declare a "method", that is, a function pointer. * We want to supply prototype parameters if the compiler can cope. * Note that the arglist parameter must be parenthesized! * Again, you can customize this if you need special linkage keywords. */ #ifdef HAVE_PROTOTYPES #define JMETHOD(type,methodname,arglist) type (*methodname) arglist #else #define JMETHOD(type,methodname,arglist) type (*methodname) () #endif /* Here is the pseudo-keyword for declaring pointers that must be "far" * on 80x86 machines. Most of the specialized coding for 80x86 is handled * by just saying "FAR *" where such a pointer is needed. In a few places * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. */ #ifndef FAR #ifdef NEED_FAR_POINTERS #define FAR far #else #define FAR #endif #endif /* * On a few systems, type boolean and/or its values FALSE, TRUE may appear * in standard header files. Or you may have conflicts with application- * specific header files that you want to include together with these files. * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. */ #ifndef HAVE_BOOLEAN typedef int boolean; #endif #ifndef FALSE /* in case these macros already exist */ #define FALSE 0 /* values of boolean */ #endif #ifndef TRUE #define TRUE 1 #endif /* * The remaining options affect code selection within the JPEG library, * but they don't need to be visible to most applications using the library. * To minimize application namespace pollution, the symbols won't be * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. */ #ifdef JPEG_INTERNALS #define JPEG_INTERNAL_OPTIONS #endif #ifdef JPEG_INTERNAL_OPTIONS /* * These defines indicate whether to include various optional functions. * Undefining some of these symbols will produce a smaller but less capable * library. Note that you can leave certain source files out of the * compilation/linking process if you've #undef'd the corresponding symbols. * (You may HAVE to do that if your compiler doesn't like null source files.) */ /* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */ /* Capability options common to encoder and decoder: */ #define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ #define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ #define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ /* Encoder capability options: */ #undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ #define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ #define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ #define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ /* Note: if you selected 12-bit data precision, it is dangerous to turn off * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit * precision, so jchuff.c normally uses entropy optimization to compute * usable tables for higher precision. If you don't want to do optimization, * you'll have to supply different default Huffman tables. * The exact same statements apply for progressive JPEG: the default tables * don't work for progressive mode. (This may get fixed, however.) */ #define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ /* Decoder capability options: */ #undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ #define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ #define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ #define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ #define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ #undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ #define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ #define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ #define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ /* more capability options later, no doubt */ /* * Ordering of RGB data in scanlines passed to or from the application. * If your application wants to deal with data in the order B,G,R, just * change these macros. You can also deal with formats such as R,G,B,X * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing * the offsets will also change the order in which colormap data is organized. * RESTRICTIONS: * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not * useful if you are using JPEG color spaces other than YCbCr or grayscale. * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE * is not 3 (they don't understand about dummy color components!). So you * can't use color quantization if you change that value. */ #define RGB_RED 0 /* Offset of Red in an RGB scanline element */ #define RGB_GREEN 1 /* Offset of Green */ #define RGB_BLUE 2 /* Offset of Blue */ #define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ /* Definitions for speed-related optimizations. */ /* If your compiler supports inline functions, define INLINE * as the inline keyword; otherwise define it as empty. */ #ifndef INLINE #ifdef __GNUC__ /* for instance, GNU C knows about inline */ #define INLINE __inline__ #endif #ifndef INLINE #define INLINE /* default is to define it as empty */ #endif #endif /* On some machines (notably 68000 series) "int" is 32 bits, but multiplying * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER * as short on such a machine. MULTIPLIER must be at least 16 bits wide. */ #ifndef MULTIPLIER #define MULTIPLIER int /* type for fastest integer multiply */ #endif /* FAST_FLOAT should be either float or double, whichever is done faster * by your compiler. (Note that this type is only used in the floating point * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) * Typically, float is faster in ANSI C compilers, while double is faster in * pre-ANSI compilers (because they insist on converting to double anyway). * The code below therefore chooses float if we have ANSI-style prototypes. */ #ifndef FAST_FLOAT #ifdef HAVE_PROTOTYPES #define FAST_FLOAT float #else #define FAST_FLOAT double #endif #endif #endif /* JPEG_INTERNAL_OPTIONS */ vncsnapshot-1.2a/libjpeg/libjpeg.dsp0100644005671200567000000001411007574257252017227 0ustar grantharmony# Microsoft Developer Studio Project File - Name="libjpeg" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Static Library" 0x0104 CFG=libjpeg - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "libjpeg.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "libjpeg.mak" CFG="libjpeg - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "libjpeg - Win32 Release" (based on "Win32 (x86) Static Library") !MESSAGE "libjpeg - Win32 Debug" (based on "Win32 (x86) Static Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "libjpeg - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD BASE RSC /l 0x419 /d "NDEBUG" # ADD RSC /l 0x419 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo !ELSEIF "$(CFG)" == "libjpeg - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD BASE RSC /l 0x419 /d "_DEBUG" # ADD RSC /l 0x419 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo !ENDIF # Begin Target # Name "libjpeg - Win32 Release" # Name "libjpeg - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=jcapimin.c # End Source File # Begin Source File SOURCE=jcapistd.c # End Source File # Begin Source File SOURCE=jccoefct.c # End Source File # Begin Source File SOURCE=jccolor.c # End Source File # Begin Source File SOURCE=jcdctmgr.c # End Source File # Begin Source File SOURCE=jchuff.c # End Source File # Begin Source File SOURCE=jcinit.c # End Source File # Begin Source File SOURCE=jcmainct.c # End Source File # Begin Source File SOURCE=jcmarker.c # End Source File # Begin Source File SOURCE=jcmaster.c # End Source File # Begin Source File SOURCE=jcomapi.c # End Source File # Begin Source File SOURCE=jcparam.c # End Source File # Begin Source File SOURCE=jcphuff.c # End Source File # Begin Source File SOURCE=jcprepct.c # End Source File # Begin Source File SOURCE=jcsample.c # End Source File # Begin Source File SOURCE=jctrans.c # End Source File # Begin Source File SOURCE=jdapimin.c # End Source File # Begin Source File SOURCE=jdapistd.c # End Source File # Begin Source File SOURCE=jdatadst.c # End Source File # Begin Source File SOURCE=jdatasrc.c # End Source File # Begin Source File SOURCE=jdcoefct.c # End Source File # Begin Source File SOURCE=jdcolor.c # End Source File # Begin Source File SOURCE=jddctmgr.c # End Source File # Begin Source File SOURCE=jdhuff.c # End Source File # Begin Source File SOURCE=jdinput.c # End Source File # Begin Source File SOURCE=jdmainct.c # End Source File # Begin Source File SOURCE=jdmarker.c # End Source File # Begin Source File SOURCE=jdmaster.c # End Source File # Begin Source File SOURCE=jdmerge.c # End Source File # Begin Source File SOURCE=jdphuff.c # End Source File # Begin Source File SOURCE=jdpostct.c # End Source File # Begin Source File SOURCE=jdsample.c # End Source File # Begin Source File SOURCE=jdtrans.c # End Source File # Begin Source File SOURCE=jerror.c # End Source File # Begin Source File SOURCE=jfdctflt.c # End Source File # Begin Source File SOURCE=jfdctfst.c # End Source File # Begin Source File SOURCE=jfdctint.c # End Source File # Begin Source File SOURCE=jidctflt.c # End Source File # Begin Source File SOURCE=jidctfst.c # End Source File # Begin Source File SOURCE=jidctint.c # End Source File # Begin Source File SOURCE=jidctred.c # End Source File # Begin Source File SOURCE=jmemmgr.c # End Source File # Begin Source File SOURCE=jmemnobs.c # End Source File # Begin Source File SOURCE=jquant1.c # End Source File # Begin Source File SOURCE=jquant2.c # End Source File # Begin Source File SOURCE=jutils.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=jchuff.h # End Source File # Begin Source File SOURCE=jconfig.h # End Source File # Begin Source File SOURCE=jdct.h # End Source File # Begin Source File SOURCE=jdhuff.h # End Source File # Begin Source File SOURCE=jerror.h # End Source File # Begin Source File SOURCE=jinclude.h # End Source File # Begin Source File SOURCE=jmemsys.h # End Source File # Begin Source File SOURCE=jmorecfg.h # End Source File # Begin Source File SOURCE=jpegint.h # End Source File # Begin Source File SOURCE=jpeglib.h # End Source File # Begin Source File SOURCE=jversion.h # End Source File # End Group # End Target # End Project vncsnapshot-1.2a/rdr/0040755005671200567000000000000010120076464014245 5ustar grantharmonyvncsnapshot-1.2a/rdr/FdOutStream.cxx0100644005671200567000000000457007574257252017210 0ustar grantharmony// // 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. #include #include #include #include #ifdef _WIN32 #include #define write(s,b,l) send(s,(const char*)b,l,0) #undef errno #define errno WSAGetLastError() #else #include #include #endif #include #include using namespace rdr; enum { DEFAULT_BUF_SIZE = 16384, MIN_BULK_SIZE = 1024 }; FdOutStream::FdOutStream(int fd_, int bufSize_) : fd(fd_), bufSize(bufSize_ ? bufSize_ : DEFAULT_BUF_SIZE), offset(0) { ptr = start = new U8[bufSize]; end = start + bufSize; } FdOutStream::~FdOutStream() { try { flush(); } catch (Exception&) { } delete [] start; } void FdOutStream::writeBytes(const void* data, int length) { if (length < MIN_BULK_SIZE) { OutStream::writeBytes(data, length); return; } const U8* dataPtr = (const U8*)data; flush(); while (length > 0) { int n = write(fd, dataPtr, length); if (n < 0) throw SystemException("write",errno); length -= n; dataPtr += n; offset += n; } } int FdOutStream::length() { return offset + ptr - start; } void FdOutStream::flush() { U8* sentUpTo = start; while (sentUpTo < ptr) { int n = write(fd, (const void*) sentUpTo, ptr - sentUpTo); if (n < 0) throw SystemException("write",errno); sentUpTo += n; offset += n; } ptr = start; } int FdOutStream::overrun(int itemSize, int nItems) { if (itemSize > bufSize) throw Exception("FdOutStream overrun: max itemSize exceeded"); flush(); if (itemSize * nItems > end - ptr) nItems = (end - ptr) / itemSize; return nItems; } vncsnapshot-1.2a/rdr/Exception.h0100644005671200567000000000415507574257252016375 0ustar grantharmony// // 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 __RDR_EXCEPTION_H__ #define __RDR_EXCEPTION_H__ #include #include namespace rdr { struct Exception { enum { len = 256 }; char str_[len]; Exception(const char* s=0, const char* e="rdr::Exception") { str_[0] = 0; strncat(str_, e, len-1); if (s) { strncat(str_, ": ", len-1-strlen(str_)); strncat(str_, s, len-1-strlen(str_)); } } virtual const char* str() const { return str_; } }; struct SystemException : public Exception { int err; SystemException(const char* s, int err_) : err(err_) { str_[0] = 0; strncat(str_, "rdr::SystemException: ", len-1); strncat(str_, s, len-1-strlen(str_)); strncat(str_, ": ", len-1-strlen(str_)); strncat(str_, strerror(err), len-1-strlen(str_)); strncat(str_, " (", len-1-strlen(str_)); char buf[20]; sprintf(buf,"%d",err); strncat(str_, buf, len-1-strlen(str_)); strncat(str_, ")", len-1-strlen(str_)); } }; struct TimedOut : public Exception { TimedOut(const char* s=0) : Exception(s,"rdr::TimedOut") {} }; struct EndOfStream : public Exception { EndOfStream(const char* s=0) : Exception(s,"rdr::EndOfStream") {} }; struct FrameException : public Exception { FrameException(const char* s=0) : Exception(s,"rdr::FrameException") {} }; } #endif vncsnapshot-1.2a/rdr/FdInStream.cxx0100644005671200567000000001400707574257252017003 0ustar grantharmony// // 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. #include #include #include #include #ifdef _WIN32 #include #include #define read(s,b,l) recv(s,(char*)b,l,0) #undef errno #define errno WSAGetLastError() #else #include #include #endif // XXX should use autoconf HAVE_SYS_SELECT_H #ifdef _AIX #include #endif #include #include using namespace rdr; enum { DEFAULT_BUF_SIZE = 8192, MIN_BULK_SIZE = 1024 }; FdInStream::FdInStream(int fd_, int timeout_, int bufSize_) : fd(fd_), timeout(timeout_), blockCallback(0), blockCallbackArg(0), timing(false), timeWaitedIn100us(5), timedKbits(0), bufSize(bufSize_ ? bufSize_ : DEFAULT_BUF_SIZE), offset(0) { ptr = end = start = new U8[bufSize]; } FdInStream::FdInStream(int fd_, void (*blockCallback_)(void*), void* blockCallbackArg_, int bufSize_) : fd(fd_), timeout(0), blockCallback(blockCallback_), blockCallbackArg(blockCallbackArg_), timing(false), timeWaitedIn100us(5), timedKbits(0), bufSize(bufSize_ ? bufSize_ : DEFAULT_BUF_SIZE), offset(0) { ptr = end = start = new U8[bufSize]; } FdInStream::~FdInStream() { delete [] start; } int FdInStream::pos() { return offset + ptr - start; } void FdInStream::readBytes(void* data, int length) { if (length < MIN_BULK_SIZE) { InStream::readBytes(data, length); return; } U8* dataPtr = (U8*)data; int n = end - ptr; if (n > length) n = length; memcpy(dataPtr, ptr, n); dataPtr += n; length -= n; ptr += n; while (length > 0) { n = readWithTimeoutOrCallback(dataPtr, length); dataPtr += n; length -= n; offset += n; } } int FdInStream::overrun(int itemSize, int nItems) { if (itemSize > bufSize) throw Exception("FdInStream overrun: max itemSize exceeded"); if (end - ptr != 0) memmove(start, ptr, end - ptr); offset += ptr - start; end -= ptr - start; ptr = start; while (end < start + itemSize) { int n = readWithTimeoutOrCallback((U8*)end, start + bufSize - end); end += n; } if (itemSize * nItems > end - ptr) nItems = (end - ptr) / itemSize; return nItems; } int FdInStream::checkReadable(int fd, int timeout) { while (true) { fd_set rfds; struct timeval tv; tv.tv_sec = timeout / 1000; tv.tv_usec = (timeout % 1000) * 1000; FD_ZERO(&rfds); FD_SET(fd, &rfds); int n = select(fd+1, &rfds, 0, 0, &tv); if (n != -1 || errno != EINTR) return n; fprintf(stderr,"select returned EINTR\n"); } } #ifdef _WIN32 static void gettimeofday(struct timeval* tv, void*) { LARGE_INTEGER counts, countsPerSec; static double usecPerCount = 0.0; if (QueryPerformanceCounter(&counts)) { if (usecPerCount == 0.0) { QueryPerformanceFrequency(&countsPerSec); usecPerCount = 1000000.0 / countsPerSec.QuadPart; } LONGLONG usecs = (LONGLONG)(counts.QuadPart * usecPerCount); tv->tv_usec = (long)(usecs % 1000000); tv->tv_sec = (long)(usecs / 1000000); } else { struct timeb tb; ftime(&tb); tv->tv_sec = tb.time; tv->tv_usec = tb.millitm * 1000; } } #endif int FdInStream::readWithTimeoutOrCallback(void* buf, int len) { struct timeval before, after; if (timing) gettimeofday(&before, 0); int n = checkReadable(fd, timeout); if (n < 0) throw SystemException("select",errno); if (n == 0) { if (timeout) throw TimedOut(); if (blockCallback) (*blockCallback)(blockCallbackArg); } while (true) { n = ::read(fd, buf, len); if (n != -1 || errno != EINTR) break; fprintf(stderr,"read returned EINTR\n"); } if (n < 0) throw SystemException("read",errno); if (n == 0) throw EndOfStream(); if (timing) { gettimeofday(&after, 0); // fprintf(stderr,"%d.%06d\n",(after.tv_sec - before.tv_sec), // (after.tv_usec - before.tv_usec)); int newTimeWaited = ((after.tv_sec - before.tv_sec) * 10000 + (after.tv_usec - before.tv_usec) / 100); int newKbits = n * 8 / 1000; // if (newTimeWaited == 0) { // fprintf(stderr,"new kbps infinite t %d k %d\n", // newTimeWaited, newKbits); // } else { // fprintf(stderr,"new kbps %d t %d k %d\n", // newKbits * 10000 / newTimeWaited, newTimeWaited, newKbits); // } // limit rate to between 10kbit/s and 40Mbit/s if (newTimeWaited > newKbits*1000) newTimeWaited = newKbits*1000; if (newTimeWaited < newKbits/4) newTimeWaited = newKbits/4; timeWaitedIn100us += newTimeWaited; timedKbits += newKbits; } return n; } void FdInStream::startTiming() { timing = true; // Carry over up to 1s worth of previous rate for smoothing. if (timeWaitedIn100us > 10000) { timedKbits = timedKbits * 10000 / timeWaitedIn100us; timeWaitedIn100us = 10000; } } void FdInStream::stopTiming() { timing = false; if (timeWaitedIn100us < timedKbits/2) timeWaitedIn100us = timedKbits/2; // upper limit 20Mbit/s } unsigned int FdInStream::kbitsPerSecond() { // The following calculation will overflow 32-bit arithmetic if we have // received more than about 50Mbytes (400Mbits) since we started timing, so // it should be OK for a single RFB update. return timedKbits * 10000 / timeWaitedIn100us; } vncsnapshot-1.2a/rdr/FdInStream.h0100644005671200567000000000352007574257252016426 0ustar grantharmony// // 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. // // FdInStream streams from a file descriptor. // #ifndef __RDR_FDINSTREAM_H__ #define __RDR_FDINSTREAM_H__ #include namespace rdr { class FdInStream : public InStream { public: FdInStream(int fd, int timeout=0, int bufSize=0); FdInStream(int fd, void (*blockCallback)(void*), void* blockCallbackArg=0, int bufSize=0); virtual ~FdInStream(); int getFd() { return fd; } int pos(); void readBytes(void* data, int length); int bytesInBuf() { return end - ptr; } void startTiming(); void stopTiming(); unsigned int kbitsPerSecond(); unsigned int timeWaited() { return timeWaitedIn100us; } protected: int overrun(int itemSize, int nItems); private: int checkReadable(int fd, int timeout); int readWithTimeoutOrCallback(void* buf, int len); int fd; int timeout; void (*blockCallback)(void*); void* blockCallbackArg; bool timing; unsigned int timeWaitedIn100us; unsigned int timedKbits; int bufSize; int offset; U8* start; }; } // end of namespace rdr #endif vncsnapshot-1.2a/rdr/FixedMemOutStream.h0100644005671200567000000000260407574257252017776 0ustar grantharmony// // 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. // // A FixedMemOutStream writes to a buffer of a fixed length. // #ifndef __RDR_FIXEDMEMOUTSTREAM_H__ #define __RDR_FIXEDMEMOUTSTREAM_H__ #include #include namespace rdr { class FixedMemOutStream : public OutStream { public: FixedMemOutStream(void* buf, int len) { ptr = start = (U8*)buf; end = start + len; } int length() { return ptr - start; } void reposition(int pos) { ptr = start + pos; } const void* data() { return (const void*)start; } private: int overrun(int itemSize, int nItems) { throw EndOfStream(); } U8* start; }; } #endif vncsnapshot-1.2a/rdr/FdOutStream.h0100644005671200567000000000243207574257252016630 0ustar grantharmony// // 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. // // FdOutStream streams to a file descriptor. // #ifndef __RDR_FDOUTSTREAM_H__ #define __RDR_FDOUTSTREAM_H__ #include namespace rdr { class FdOutStream : public OutStream { public: FdOutStream(int fd, int bufSize=0); virtual ~FdOutStream(); int getFd() { return fd; } void flush(); int length(); void writeBytes(const void* data, int length); private: int overrun(int itemSize, int nItems); int fd; int bufSize; int offset; U8* start; }; } #endif vncsnapshot-1.2a/rdr/InStream.cxx0100644005671200567000000000214107574257252016525 0ustar grantharmony// // 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. #include #include using namespace rdr; U32 InStream::maxStringLength = 65535; char* InStream::readString() { U32 len = readU32(); if (len > maxStringLength) throw Exception("InStream max string length exceeded"); char* str = new char[len+1]; readBytes(str, len); str[len] = 0; return str; } vncsnapshot-1.2a/rdr/InStream.h0100644005671200567000000001110407574257252016151 0ustar grantharmony// // 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. // // rdr::InStream marshalls data from a buffer stored in RDR (RFB Data // Representation). // #ifndef __RDR_INSTREAM_H__ #define __RDR_INSTREAM_H__ #include #include // for memcpy namespace rdr { class InStream { public: virtual ~InStream() {} // check() ensures there is buffer data for at least one item of size // itemSize bytes. Returns the number of items in the buffer (up to a // maximum of nItems). inline int check(int itemSize, int nItems=1) { if (ptr + itemSize * nItems > end) { if (ptr + itemSize > end) return overrun(itemSize, nItems); nItems = (end - ptr) / itemSize; } return nItems; } // readU/SN() methods read unsigned and signed N-bit integers. inline U8 readU8() { check(1); return *ptr++; } inline U16 readU16() { check(2); int b0 = *ptr++; int b1 = *ptr++; return b0 << 8 | b1; } inline U32 readU32() { check(4); int b0 = *ptr++; int b1 = *ptr++; int b2 = *ptr++; int b3 = *ptr++; return b0 << 24 | b1 << 16 | b2 << 8 | b3; } inline S8 readS8() { return (S8) readU8(); } inline S16 readS16() { return (S16)readU16(); } inline S32 readS32() { return (S32)readU32(); } // readString() reads a string - a U32 length followed by the data. // Returns a null-terminated string - the caller should delete[] it // afterwards. char* readString(); // maxStringLength protects against allocating a huge buffer. Set it // higher if you need longer strings. static U32 maxStringLength; inline void skip(int bytes) { while (bytes > 0) { int n = check(1, bytes); ptr += n; bytes -= n; } } // readBytes() reads an exact number of bytes. virtual void readBytes(void* data, int length) { U8* dataPtr = (U8*)data; U8* dataEnd = dataPtr + length; while (dataPtr < dataEnd) { int n = check(1, dataEnd - dataPtr); memcpy(dataPtr, ptr, n); ptr += n; dataPtr += n; } } // readOpaqueN() reads a quantity without byte-swapping. inline U8 readOpaque8() { return readU8(); } inline U16 readOpaque16() { check(2); U16 r; ((U8*)&r)[0] = *ptr++; ((U8*)&r)[1] = *ptr++; return r; } inline U32 readOpaque32() { check(4); U32 r; ((U8*)&r)[0] = *ptr++; ((U8*)&r)[1] = *ptr++; ((U8*)&r)[2] = *ptr++; ((U8*)&r)[3] = *ptr++; return r; } inline U32 readOpaque24A() { check(3); U32 r=0; ((U8*)&r)[0] = *ptr++; ((U8*)&r)[1] = *ptr++; ((U8*)&r)[2] = *ptr++; return r; } inline U32 readOpaque24B() { check(3); U32 r=0; ((U8*)&r)[1] = *ptr++; ((U8*)&r)[2] = *ptr++; ((U8*)&r)[3] = *ptr++; return r; } // pos() returns the position in the stream. virtual int pos() = 0; // getptr(), getend() and setptr() are "dirty" methods which allow you to // manipulate the buffer directly. This is useful for a stream which is a // wrapper around an underlying stream. inline const U8* getptr() const { return ptr; } inline const U8* getend() const { return end; } inline void setptr(const U8* p) { ptr = p; } private: // overrun() is implemented by a derived class to cope with buffer overrun. // It ensures there are at least itemSize bytes of buffer data. Returns // the number of items in the buffer (up to a maximum of nItems). itemSize // is supposed to be "small" (a few bytes). virtual int overrun(int itemSize, int nItems) = 0; protected: InStream() {} const U8* ptr; const U8* end; }; } #endif vncsnapshot-1.2a/rdr/Makefile0100644005671200567000000000153010117721114015674 0ustar grantharmony# Makefile for vncsnapshot, Unix/Linux platforms. # # $Id: Makefile,v 1.2 2004/09/09 00:22:36 grmcdorman Exp $ # You shouldn't need to change anything below. INCLUDES = -I. -I.. $(ZLIB_INCLUDE) $(JPEG_INCLUDE) $(EXTRAINCLUDES) CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) CXXFLAGS = $(CFLAGS) # Solaris 8 uses CCFLAGS instead of CXXFLAGS CCFLAGS = $(CXXFLAGS) .SUFFIXES: .cxx SRCS = \ FdInStream.cxx InStream.cxx ZlibInStream.cxx \ FdOutStream.cxx NullOutStream.cxx ZlibOutStream.cxx \ OBJS1 = $(SRCS:.c=.o) OBJS = $(OBJS1:.cxx=.o) SUBDIRS= TARGET=librdr.a all: $(SUBDIRS:.dir=.all) $(TARGET) $(TARGET): $(OBJS) $(AR) cr $(TARGET) $(OBJS) ranlib $(TARGET) clean: $(SUBDIRS:.dir=.clean) -rm -f $(OBJS) $(TARGET) core reallyclean: clean $(SUBDIRS:.=.reallyclean) -rm -f *~ .cxx.o: $(COMPILE.cc) -o $@ $< #.o.cxx: echo $@ $< # dependancies vncsnapshot-1.2a/rdr/MemInStream.h0100644005671200567000000000240107574257252016610 0ustar grantharmony// // 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 __RDR_MEMINSTREAM_H__ #define __RDR_MEMINSTREAM_H__ #include #include namespace rdr { class MemInStream : public InStream { public: MemInStream(const void* data, int len) { ptr = start = (const U8*)data; end = start + len; } int pos() { return ptr - start; } void reposition(int pos) { ptr = start + pos; } private: int overrun(int itemSize, int nItems) { throw EndOfStream(); } const U8* start; }; } #endif vncsnapshot-1.2a/rdr/MemOutStream.h0100644005671200567000000000401707574257252017016 0ustar grantharmony// // 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. // // A MemOutStream grows as needed when data is written to it. // #ifndef __RDR_MEMOUTSTREAM_H__ #define __RDR_MEMOUTSTREAM_H__ #include namespace rdr { class MemOutStream : public OutStream { public: MemOutStream(int len=1024) { start = ptr = new U8[len]; end = start + len; } virtual ~MemOutStream() { delete [] start; } void writeBytes(const void* data, int length) { check(length); memcpy(ptr, data, length); ptr += length; } int length() { return ptr - start; } void clear() { ptr = start; }; void reposition(int pos) { ptr = start + pos; } // data() returns a pointer to the buffer. const void* data() { return (const void*)start; } private: // overrun() either doubles the buffer or adds enough space for nItems of // size itemSize bytes. int overrun(int itemSize, int nItems) { int len = ptr - start + itemSize * nItems; if (len < (end - start) * 2) len = (end - start) * 2; U8* newStart = new U8[len]; memcpy(newStart, start, ptr - start); ptr = newStart + (ptr - start); delete [] start; start = newStart; end = newStart + len; return nItems; } U8* start; }; } #endif vncsnapshot-1.2a/rdr/NullOutStream.cxx0100644005671200567000000000273707574257252017574 0ustar grantharmony// // 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. #include #include using namespace rdr; static const int bufferSize = 1024; NullOutStream::NullOutStream() : offset(0) { start = ptr = new U8[bufferSize]; end = start + bufferSize; } NullOutStream::~NullOutStream() { delete [] start; } int NullOutStream::length() { return offset + ptr - start; } void NullOutStream::writeBytes(const void* data, int length) { offset += length; } int NullOutStream::overrun(int itemSize, int nItems) { if (itemSize > bufferSize) throw Exception("NullOutStream overrun: max itemSize exceeded"); offset += ptr - start; ptr = start; if (itemSize * nItems > end - ptr) nItems = (end - ptr) / itemSize; return nItems; } vncsnapshot-1.2a/rdr/NullOutStream.h0100644005671200567000000000221207574257252017205 0ustar grantharmony// // 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 __RDR_NULLOUTSTREAM_H__ #define __RDR_NULLOUTSTREAM_H__ #include namespace rdr { class NullOutStream : public OutStream { public: NullOutStream(); virtual ~NullOutStream(); int length(); void writeBytes(const void* data, int length); private: int overrun(int itemSize, int nItems); int offset; U8* start; }; } #endif vncsnapshot-1.2a/rdr/OutStream.h0100644005671200567000000001125407574257252016360 0ustar grantharmony// // 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. // // rdr::OutStream marshalls data into a buffer stored in RDR (RFB Data // Representation). // #ifndef __RDR_OUTSTREAM_H__ #define __RDR_OUTSTREAM_H__ #include #include // for memcpy namespace rdr { class OutStream { protected: OutStream() {} public: virtual ~OutStream() {} // check() ensures there is buffer space for at least one item of size // itemSize bytes. Returns the number of items which fit (up to a maximum // of nItems). inline int check(int itemSize, int nItems=1) { if (ptr + itemSize * nItems > end) { if (ptr + itemSize > end) return overrun(itemSize, nItems); nItems = (end - ptr) / itemSize; } return nItems; } // writeU/SN() methods write unsigned and signed N-bit integers. inline void writeU8( U8 u) { check(1); *ptr++ = u; } inline void writeU16(U16 u) { check(2); *ptr++ = u >> 8; *ptr++ = (U8)u; } inline void writeU32(U32 u) { check(4); *ptr++ = u >> 24; *ptr++ = u >> 16; *ptr++ = u >> 8; *ptr++ = u; } inline void writeS8( S8 s) { writeU8((U8)s); } inline void writeS16(S16 s) { writeU16((U16)s); } inline void writeS32(S32 s) { writeU32((U32)s); } // writeString() writes a string - a U32 length followed by the data. The // given string should be null-terminated (but the terminating null is not // written to the stream). inline void writeString(const char* str) { U32 len = strlen(str); writeU32(len); writeBytes(str, len); } inline void pad(int bytes) { while (bytes-- > 0) writeU8(0); } inline void skip(int bytes) { while (bytes > 0) { int n = check(1, bytes); ptr += n; bytes -= n; } } // writeBytes() writes an exact number of bytes. virtual void writeBytes(const void* data, int length) { const U8* dataPtr = (const U8*)data; const U8* dataEnd = dataPtr + length; while (dataPtr < dataEnd) { int n = check(1, dataEnd - dataPtr); memcpy(ptr, dataPtr, n); ptr += n; dataPtr += n; } } // writeOpaqueN() writes a quantity without byte-swapping. inline void writeOpaque8( U8 u) { writeU8(u); } inline void writeOpaque16(U16 u) { check(2); *ptr++ = ((U8*)&u)[0]; *ptr++ = ((U8*)&u)[1]; } inline void writeOpaque32(U32 u) { check(4); *ptr++ = ((U8*)&u)[0]; *ptr++ = ((U8*)&u)[1]; *ptr++ = ((U8*)&u)[2]; *ptr++ = ((U8*)&u)[3]; } inline void writeOpaque24A(U32 u) { check(3); *ptr++ = ((U8*)&u)[0]; *ptr++ = ((U8*)&u)[1]; *ptr++ = ((U8*)&u)[2]; } inline void writeOpaque24B(U32 u) { check(3); *ptr++ = ((U8*)&u)[1]; *ptr++ = ((U8*)&u)[2]; *ptr++ = ((U8*)&u)[3]; } // length() returns the length of the stream. virtual int length() = 0; // flush() requests that the stream be flushed. virtual void flush() {} // getptr(), getend() and setptr() are "dirty" methods which allow you to // manipulate the buffer directly. This is useful for a stream which is a // wrapper around an underlying stream. inline U8* getptr() { return ptr; } inline U8* getend() { return end; } inline void setptr(U8* p) { ptr = p; } private: // overrun() is implemented by a derived class to cope with buffer overrun. // It ensures there are at least itemSize bytes of buffer space. Returns // the number of items which fit (up to a maximum of nItems). itemSize is // supposed to be "small" (a few bytes). virtual int overrun(int itemSize, int nItems) = 0; protected: U8* ptr; U8* end; }; } #endif vncsnapshot-1.2a/rdr/ZlibInStream.cxx0100644005671200567000000000564107574257252017356 0ustar grantharmony// // 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. #include #include #include using namespace rdr; enum { DEFAULT_BUF_SIZE = 16384 }; ZlibInStream::ZlibInStream(int bufSize_) : underlying(0), bufSize(bufSize_ ? bufSize_ : DEFAULT_BUF_SIZE), offset(0), bytesIn(0) { zs = new z_stream; zs->zalloc = Z_NULL; zs->zfree = Z_NULL; zs->opaque = Z_NULL; zs->next_in = Z_NULL; zs->avail_in = 0; if (inflateInit(zs) != Z_OK) { delete zs; throw Exception("ZlibInStream: inflateInit failed"); } ptr = end = start = new U8[bufSize]; } ZlibInStream::~ZlibInStream() { delete [] start; inflateEnd(zs); delete zs; } void ZlibInStream::setUnderlying(InStream* is, int bytesIn_) { underlying = is; bytesIn = bytesIn_; ptr = end = start; } int ZlibInStream::pos() { return offset + ptr - start; } void ZlibInStream::reset() { ptr = end = start; if (!underlying) return; while (bytesIn > 0) { decompress(); end = start; // throw away any data } underlying = 0; } int ZlibInStream::overrun(int itemSize, int nItems) { if (itemSize > bufSize) throw Exception("ZlibInStream overrun: max itemSize exceeded"); if (!underlying) throw Exception("ZlibInStream overrun: no underlying stream"); if (end - ptr != 0) memmove(start, ptr, end - ptr); offset += ptr - start; end -= ptr - start; ptr = start; while (end - ptr < itemSize) { decompress(); } if (itemSize * nItems > end - ptr) nItems = (end - ptr) / itemSize; return nItems; } // decompress() calls the decompressor once. Note that this won't necessarily // generate any output data - it may just consume some input data. void ZlibInStream::decompress() { zs->next_out = (U8*)end; zs->avail_out = start + bufSize - end; underlying->check(1); zs->next_in = (U8*)underlying->getptr(); zs->avail_in = underlying->getend() - underlying->getptr(); if ((int)zs->avail_in > bytesIn) zs->avail_in = bytesIn; int rc = inflate(zs, Z_SYNC_FLUSH); if (rc != Z_OK) { throw Exception("ZlibInStream: inflate failed"); } bytesIn -= zs->next_in - underlying->getptr(); end = zs->next_out; underlying->setptr(zs->next_in); } vncsnapshot-1.2a/rdr/ZlibInStream.h0100644005671200567000000000265207574257252017002 0ustar grantharmony// // 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. // // ZlibInStream streams from a compressed data stream ("underlying"), // decompressing with zlib on the fly. // #ifndef __RDR_ZLIBINSTREAM_H__ #define __RDR_ZLIBINSTREAM_H__ #include struct z_stream_s; namespace rdr { class ZlibInStream : public InStream { public: ZlibInStream(int bufSize=0); virtual ~ZlibInStream(); void setUnderlying(InStream* is, int bytesIn); void reset(); int pos(); private: int overrun(int itemSize, int nItems); void decompress(); InStream* underlying; int bufSize; int offset; z_stream_s* zs; int bytesIn; U8* start; }; } // end of namespace rdr #endif vncsnapshot-1.2a/rdr/ZlibOutStream.cxx0100644005671200567000000000737307574257252017563 0ustar grantharmony// // 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. #include #include #include using namespace rdr; enum { DEFAULT_BUF_SIZE = 16384 }; ZlibOutStream::ZlibOutStream(OutStream* os, int bufSize_) : underlying(os), bufSize(bufSize_ ? bufSize_ : DEFAULT_BUF_SIZE), offset(0) { zs = new z_stream; zs->zalloc = Z_NULL; zs->zfree = Z_NULL; zs->opaque = Z_NULL; if (deflateInit(zs, Z_DEFAULT_COMPRESSION) != Z_OK) { delete zs; throw Exception("ZlibOutStream: deflateInit failed"); } ptr = start = new U8[bufSize]; end = start + bufSize; } ZlibOutStream::~ZlibOutStream() { try { flush(); } catch (Exception&) { } delete [] start; deflateEnd(zs); delete zs; } void ZlibOutStream::setUnderlying(OutStream* os) { underlying = os; } int ZlibOutStream::length() { return offset + ptr - start; } void ZlibOutStream::flush() { zs->next_in = start; zs->avail_in = ptr - start; // fprintf(stderr,"zos flush: avail_in %d\n",zs->avail_in); while (zs->avail_in != 0) { do { underlying->check(1); zs->next_out = underlying->getptr(); zs->avail_out = underlying->getend() - underlying->getptr(); // fprintf(stderr,"zos flush: calling deflate, avail_in %d, avail_out %d\n", // zs->avail_in,zs->avail_out); int rc = deflate(zs, Z_SYNC_FLUSH); if (rc != Z_OK) throw Exception("ZlibOutStream: deflate failed"); // fprintf(stderr,"zos flush: after deflate: %d bytes\n", // zs->next_out-underlying->getptr()); underlying->setptr(zs->next_out); } while (zs->avail_out == 0); } offset += ptr - start; ptr = start; } int ZlibOutStream::overrun(int itemSize, int nItems) { // fprintf(stderr,"ZlibOutStream overrun\n"); if (itemSize > bufSize) throw Exception("ZlibOutStream overrun: max itemSize exceeded"); while (end - ptr < itemSize) { zs->next_in = start; zs->avail_in = ptr - start; do { underlying->check(1); zs->next_out = underlying->getptr(); zs->avail_out = underlying->getend() - underlying->getptr(); // fprintf(stderr,"zos overrun: calling deflate, avail_in %d, avail_out %d\n", // zs->avail_in,zs->avail_out); int rc = deflate(zs, 0); if (rc != Z_OK) throw Exception("ZlibOutStream: deflate failed"); // fprintf(stderr,"zos overrun: after deflate: %d bytes\n", // zs->next_out-underlying->getptr()); underlying->setptr(zs->next_out); } while (zs->avail_out == 0); // output buffer not full if (zs->avail_in == 0) { offset += ptr - start; ptr = start; } else { // but didn't consume all the data? try shifting what's left to the // start of the buffer. fprintf(stderr,"z out buf not full, but in data not consumed\n"); memmove(start, zs->next_in, ptr - zs->next_in); offset += zs->next_in - start; ptr -= zs->next_in - start; } } if (itemSize * nItems > end - ptr) nItems = (end - ptr) / itemSize; return nItems; } vncsnapshot-1.2a/rdr/ZlibOutStream.h0100644005671200567000000000261507574257252017202 0ustar grantharmony// // 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. // // ZlibOutStream streams to a compressed data stream (underlying), compressing // with zlib on the fly. // #ifndef __RDR_ZLIBOUTSTREAM_H__ #define __RDR_ZLIBOUTSTREAM_H__ #include struct z_stream_s; namespace rdr { class ZlibOutStream : public OutStream { public: ZlibOutStream(OutStream* os=0, int bufSize=0); virtual ~ZlibOutStream(); void setUnderlying(OutStream* os); void flush(); int length(); private: int overrun(int itemSize, int nItems); OutStream* underlying; int bufSize; int offset; z_stream_s* zs; U8* start; }; } // end of namespace rdr #endif vncsnapshot-1.2a/rdr/rdr.dsp0100644005671200567000000001534707574257252015572 0ustar grantharmony# Microsoft Developer Studio Project File - Name="rdr" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Static Library" 0x0104 CFG=rdr - Win32 Release CORBA DEBUG !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "rdr.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "rdr.mak" CFG="rdr - Win32 Release CORBA DEBUG" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "rdr - Win32 Release" (based on "Win32 (x86) Static Library") !MESSAGE "rdr - Win32 Debug" (based on "Win32 (x86) Static Library") !MESSAGE "rdr - Win32 Release CORBA DEBUG" (based on "Win32 (x86) Static Library") !MESSAGE "rdr - Win32 Release CORBA" (based on "Win32 (x86) Static Library") !MESSAGE "rdr - Win32 Profile" (based on "Win32 (x86) Static Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "rdr - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo !ELSEIF "$(CFG)" == "rdr - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo !ELSEIF "$(CFG)" == "rdr - Win32 Release CORBA DEBUG" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "rdr___Win32_Release_CORBA_DEBUG" # PROP BASE Intermediate_Dir "rdr___Win32_Release_CORBA_DEBUG" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "..\Release_CORBA_DEBUG" # PROP Intermediate_Dir "..\Release_CORBA_DEBUG" # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo !ELSEIF "$(CFG)" == "rdr - Win32 Release CORBA" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "rdr___Win32_Release_CORBA" # PROP BASE Intermediate_Dir "rdr___Win32_Release_CORBA" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Release_CORBA" # PROP Intermediate_Dir "..\Release_CORBA" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo !ELSEIF "$(CFG)" == "rdr - Win32 Profile" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "rdr___Win32_Profile" # PROP BASE Intermediate_Dir "rdr___Win32_Profile" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "..\Profile" # PROP Intermediate_Dir "..\Profile" # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD CPP /nologo /MTd /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo !ENDIF # Begin Target # Name "rdr - Win32 Release" # Name "rdr - Win32 Debug" # Name "rdr - Win32 Release CORBA DEBUG" # Name "rdr - Win32 Release CORBA" # Name "rdr - Win32 Profile" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\FdInStream.cxx # ADD CPP /I ".." /I "../zlib" # End Source File # Begin Source File SOURCE=.\FdOutStream.cxx # ADD CPP /I ".." /I "../zlib" # End Source File # Begin Source File SOURCE=.\InStream.cxx # ADD CPP /I ".." /I "../zlib" # End Source File # Begin Source File SOURCE=.\NullOutStream.cxx # ADD CPP /I ".." /I "../zlib" # End Source File # Begin Source File SOURCE=.\ZlibInStream.cxx # ADD CPP /I ".." /I "../zlib" # End Source File # Begin Source File SOURCE=.\ZlibOutStream.cxx # ADD CPP /I ".." /I "../zlib" # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\Exception.h # End Source File # Begin Source File SOURCE=.\FdInStream.h # End Source File # Begin Source File SOURCE=.\FdOutStream.h # End Source File # Begin Source File SOURCE=.\FixedMemOutStream.h # End Source File # Begin Source File SOURCE=.\InStream.h # End Source File # Begin Source File SOURCE=.\MemInStream.h # End Source File # Begin Source File SOURCE=.\MemOutStream.h # End Source File # Begin Source File SOURCE=.\NullOutStream.h # End Source File # Begin Source File SOURCE=.\OutStream.h # End Source File # Begin Source File SOURCE=.\types.h # End Source File # Begin Source File SOURCE=.\ZlibInStream.h # End Source File # Begin Source File SOURCE=.\ZlibOutStream.h # End Source File # End Group # End Target # End Project vncsnapshot-1.2a/rdr/types.h0100644005671200567000000000202307574257252015573 0ustar grantharmony// // 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 __RDR_TYPES_H__ #define __RDR_TYPES_H__ namespace rdr { typedef unsigned char U8; typedef unsigned short U16; typedef unsigned int U32; typedef signed char S8; typedef signed short S16; typedef signed int S32; } // end of namespace rdr #endif vncsnapshot-1.2a/vncsnapshot.dsw0100644005671200567000000000304710117721111016534 0ustar grantharmonyMicrosoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "libjpeg"=".\libjpeg\libjpeg.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "rdr"=".\rdr\rdr.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "vncpasswd"=".\vncpasswd.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "vncsnapshot"=".\vncsnapshot.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ Begin Project Dependency Project_Dep_Name zlib End Project Dependency Begin Project Dependency Project_Dep_Name libjpeg End Project Dependency Begin Project Dependency Project_Dep_Name rdr End Project Dependency }}} ############################################################################### Project: "zlib"=".\zlib\zlib.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### vncsnapshot-1.2a/vncsnapshot.h0100644005671200567000000001310110117721111016156 0ustar grantharmony/* * 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. */ /* * vncviewer.h */ #include #include #include #ifndef WIN32 #include #include #endif #include "rfb.h" extern int endianTest; #ifdef Swap16IfLE #undef Swap16IfLE #endif #ifdef Swap32IfLE #undef Swap32IfLE #endif #define Swap16IfLE(s) \ (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s)) #define Swap32IfLE(l) \ (*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \ (((l) & 0x00ff0000) >> 8) | \ (((l) & 0x0000ff00) << 8) | \ (((l) & 0x000000ff) << 24)) : (l)) #define MAX_ENCODINGS 20 #define FLASH_PORT_OFFSET 5400 #define LISTEN_PORT_OFFSET 5500 #define TUNNEL_PORT_OFFSET 5500 #define SERVER_PORT_OFFSET 5900 #ifdef WIN32 /* This is for the NetworkSimplicty installation of SSH */ #define DEFAULT_SSH_CMD "C:\\Program Files\\NetworkSimplicity\\ssh.exe" #else #define DEFAULT_SSH_CMD "/usr/bin/ssh" #endif #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") typedef char Bool; #ifndef True #define True 1 #endif #ifndef False #define False 0 #endif /* argsresources.c */ typedef struct { char *encodingsString; char *passwordFile; Bool debug; int compressLevel; int qualityLevel; Bool useRemoteCursor; Bool ignoreBlank; /* ignore blank screens */ Bool enableJPEG; int saveQuality; char *outputFilename; int quiet; char rectXNegative; /* if non-zero, X or Y relative to opposite edge */ char rectYNegative; long rectWidth; long rectHeight; long rectX; long rectY; char gotCursorPos; int fps; int count; /* number of snapshots to grab */ } AppData; extern AppData appData; extern char *fallback_resources[]; extern char vncServerHost[]; extern char *vncServerName; extern int vncServerPort; extern Bool listenSpecified; extern int listenPort, flashPort; extern void removeArgs(int *argc, char** argv, int idx, int nargs); extern void usage(void); extern void GetArgsAndResources(int argc, char **argv); /* buffer.c */ extern int AllocateBuffer(); extern void CopyDataToScreen(char *buffer, int x, int y, int w, int h); extern char *CopyScreenToData(int x, int y, int w, int h); extern void FillBufferRectangle(int x, int y, int w, int h, unsigned long pixel); extern void ShrinkBuffer(long x, long y, long req_width, long req_height); extern void write_JPEG_file (char * filename, int quality, int width, int height); extern int BufferIsBlank(); extern int BufferWritten(); /* colour.c */ extern unsigned long BGR233ToPixel[]; /* cursor.c */ extern Bool HandleCursorShape(int xhot, int yhot, int width, int height, CARD32 enc); extern Bool HandleCursorPos(int x, int y); extern void SoftCursorLockArea(int x, int y, int w, int h); extern void SoftCursorUnlockScreen(void); extern void SoftCursorMove(int x, int y); /* listen.c */ extern void listenForIncomingConnections(); /* rfbproto.c */ extern Bool canUseCoRRE; extern Bool canUseHextile; extern char *desktopName; extern rfbPixelFormat myFormat; extern rfbServerInitMsg si; extern char *serverCutText; extern Bool newServerCutText; extern Bool ConnectToRFBServer(const char *hostname, int port); extern Bool InitialiseRFBConnection(); extern Bool SendSetPixelFormat(); extern Bool SendSetEncodings(); extern Bool SendIncrementalFramebufferUpdateRequest(); extern Bool SendFramebufferUpdateRequest(int x, int y, int w, int h, Bool incremental); extern Bool SendPointerEvent(int x, int y, int buttonMask); extern Bool SendKeyEvent(CARD32 key, Bool down); extern Bool SendClientCutText(char *str, int len); extern Bool HandleRFBServerMessage(); extern void PrintPixelFormat(rfbPixelFormat *format); /* sockets.cxx */ extern Bool sameMachine; extern int rfbsock; extern Bool InitializeSockets(void); extern Bool ConnectToRFBServer(const char *hostname, int port); extern Bool SetRFBSock(int sock); extern void StartTiming(); extern void StopTiming(); extern int KbitsPerSecond(); extern int TimeWaitedIn100us(); extern Bool ReadFromRFBServer(char *out, unsigned int n); extern Bool WriteToRFBServer(char *buf, int n); extern int ConnectToTcpAddr(const char* hostname, int port); extern int FindFreeTcpPort(); extern int ListenAtTcpPort(int port); extern int AcceptTcpConnection(int listenSock); extern Bool StringToIPAddr(const char *str, unsigned int *addr); /* tunnel.c */ extern Bool tunnelSpecified; extern Bool createTunnel(int *argc, char **argv, int tunnelArgIndex); /* vncviewer.c */ extern char *programName; /* zrle.cxx */ extern Bool zrleDecode(int x, int y, int w, int h); /* getpass.c (win32) */ #ifdef WIN32 extern char *getpass(const char * prompt); #endif vncsnapshot-1.2a/vncsnapshot.man10100644005671200567000000001243410120152273016574 0ustar grantharmony.TH "vncsnapshot" "1" "1.0beta2" "Grant McDorman" "VNC" .\" $Id: vncsnapshot.man1,v 1.5 2004/09/09 22:10:03 grmcdorman Exp $ .SH "NAME" .LP vncsnapshot \- grab snapshots from VNC servers .SH "SYNTAX" .LP vncsnapshot [\fIoptions\fP] \fIhost\fP:\fIdisplay\fP \fIJPEG\-file\fP .br vncsnapshot [\fIoptions\fP] \-listen \fIlocal\-display\fP \fIJPEG\-file\fP .br vncsnapshot [\fIoptions\fP] \-tunnel \fIhost\fP:\fIdisplay\fP \fIJPEG\-file\fP .br vncsnapshot [\fIoptions\fP] \-via \fIgateway\fP \fIhost\fP:\fIdisplay\fP \fIJPEG\-file\fP .SH "DESCRIPTION" .LP VNC Snapshot is a command\-line program for VNC. It will save a JPEG image of the VNC server's screen. .LP This manual page documents version 1.2a of vncsnapshot. .SH "OPTIONS" .LP .TP \fB\-allowblank\fR Allow blank (all black) images as snapshots. See \fB-ignoreblank\fP. \fB\-compresslevel\fR \fIlevel\fP Compress network messages to level, if the server supports it. level is between 0 and 9, with 0 being no compression and 9 the maximum. The default is 4. .TP \fB\-cursor\fR Include the cursor in snapshots. Only effective if the remote server is a TightVNC version; otherwise ignored. .TP \fB\-encodings\fR \fIlist\fP Use the given encodings. The default is .br \ "copyrect tight hextile zlib corre rre" .br or .br \ "raw copyrect tight hextile zlib corre rre" .br when VNC snapshot and the server are on the same machine. .TP \fB\-ignoreblank\fR Ignore blank (all black) screens; do not save the screen until a screen that is not all black is received. This is useful with some servers that send an initial all-black screen before sending the actual screen. This is the default. .TP \fB\-jpeg\fR Request the remote server to use JPEG-style encoding when sending the image, if possible. Currently only supported by TightVNC (and servers derived from it). This is the default. .TP \fB\-nocursor\fR Do not include the cursor in snapshots. Only effective if the remote server is a TightVNC version; otherwise ignored. This is the default. .TP \fB\-nojpeg\fR Request the remote server to \fBnot\fP use JPEG-style encoding when sending the image, if possible. Currently only supported by TightVNC (and servers derived from it). .TP \fB\-listen\fR \fIlocal-display\fP Do not connect to a server; wait for the server to connect to the specified local "display". Cannot be used with \fB\-tunnel\fP or \fB\-via\fP options. .TP \fB\-passwd\fR \fIfilename\fP Read encrypted password from \fIfilename\fP instead of from the console. The \fIfilename\fP can be made with the vncpasswd utility included with the vncsnapshot release. .TP \fB\-quality \fIquality\fP Use the specified JPEG image quality (0-100) for the output file. The default is 100. .TP \fB\-quiet Do not print any messages. Opposite of \fB-verbose\fP. .TP \fB\-rect \fIw\fPx\fIh\fP+\fIx\fP+\fIy\fP Save a sub-rectangle of the screen, width \fIw\fP height \fIh\fP offset from the left by \fIx\fP and the top by \fIy\fP. A negative number for \fIx\fP or \fIy\fP makes it an offset from the opposite edge. A zero value for the width or height makes the snapshot extend to the right or bottom of the screen, respectively. The default is the entire screen. .TP \fB\-tunnel\fR Connect to the remote server via an SSH tunnel. Cannot be used with \fB\-listen\fP or \fB\-via\fP options. .TP \fB\-via\fR \fIgateway\fP Connect to the remote server via an SSH tunnel on the host \fIgateway\fP. Cannot be used with \fB\-listen\fP or \fB\-tunnel\fP options. .TP \fB\-verbose Print messages; default. .TP \fB\-vncQuality \fIquality\fP Use the specified image quality level (0-9) for tight encoding. The default is 9. Only effective if the remote server is a TightVNC version; otherwise ignored. .TP \fB\-count \fInumber\fP Take \fInumber\fP snapshots; default 1. If greater than 1, vncsnapshot will insert a five-digit sequence number just before the output file's extension; i.e. if you specify \fBout.jpeg\fP as the output file, it will create \fBout00001.jpeg\fP, \fBout00002.jpeg\fP, and so forth .TP \fB\-fps \fIrate\fP When taking multiple snapshots, take them every \fIrate\fP seconds; default 60. .SH "EXAMPLES" .TP vncsnapshot anhk-morpork:1 unseen.jpg Get a snapshot of screen 1 from the server \fBahnk-morpork\fP and save it in \fBunseen.jpg\fP. The entire screen is saved; the default transport is used. .TP vncsnapshot \-listen 0 portrait.jpeg Wait for a server to connect to this host (using "screen" 0), and then save the full screen image in \fBportrait.jpeg\fP. .TP vncsnapshot \-passwd ~/.vnc/passwd \-rect 640x0+120+30 :1 subarea.jpeg Using \fB~/.vnc/passwd\fP to get the server's password, connect to screen 1 on the local machine and save a rectangle 640 pixels high and extending to the right edge, offset 120 pixels from the left and 30 pixels down. .TP vncsnapshot \-rect 0x0\-800\-600 :1 pict.jpeg Get a snapshot that is 800 pixels from the right edge and 600 pixels from the bottom of the screen. It will extend to the screen edges, making it 800x600. Alternatively, the rectangle could be given as \fB-rect 800x600-0-0\fP, which specifies the same region. .SH "AUTHOR" .LP Grant McDorman .br Based on TightVNC and RealVNC . .SH "DISTRIBUTION" Source for vncsnapshot can be found at . .SH "SEE ALSO" .LP vncviewer(1), Xvnc(1), vncpasswd(1), vncconnect(1) vncsnapshot-1.2a/web-page.html0100644005671200567000000002162410120152273016026 0ustar grantharmony VNC Snapshot

VNC Snapshot

Hosted by Source Forge SourceForge Logo
Quick Links
Mail author:
VNC Snapshot at Sourceforge VNC Snapshot Home Page
Official VNC Home Page Tight VNC Home Page

Features Command-Line Options
Examples Project Summary

About VNC and VNCSnapshot

VNC [www.realvnc.com] (an abbreviation for Virtual Network Computing) is a great client/server software package allowing remote network access to graphical desktops. With VNC, you may allow yourself to access your machine from everywhere provided that your machine is connected to the Internet. VNC is free (released under the GNU General Public License) and it's available on most platforms. The original VNC distribution can be obtained at the Real VNC site.

VNC Snapshot is a command-line program for VNC. It will save a JPEG image of the VNC server's screen.

Also included with the package is vncpasswd, to allow you to create password files if you do not have a Unix or Linux version of VNC available. Note that while this utility is in the Windows version of VNC Snapshot, it does not create a file usable by the Windows version of the VNC Server.

VNC Snapshot is derived from Tight VNC [www.tightvnc.com] and Real VNC [www.realvnc.com].

Sources and binaries can be download from the VNCSnapshot Source Forge site.

VNC Snapshot Features and Usage

VNC Snapshot includes all standard VNC viewer options, except those that apply to the viewer's window.

VNC Snapshot can only be used from the command line.

It can be invoked in three ways:

vncsnapshot options host:display JPEG-filename

vncsnapshot options -listen local-display JPEG-filename

vncsnapshot options -tunnel host:display JPEG-filename

vncsnapshot options -via gateway host:display JPEG-filename

-listen, -tunnel and -via options have not been tested on Windows systems.

Options
-cursor
-nocursor
Attempt to include, or exclude, the mouse cursor from the snapshot. Currently, this works only when the remote server is TightVNC 1.2.7 or later. Other servers do not respond to these options and may or may not include the cursor in the snapshot.
-passwd filename Read encrypted password from filename instead of from the console. The filename can be made with the vncpasswd utility included in the vncsnapshot distribution.
-encodings list Use the given encodings. The default is
 "copyrect tight hextile zlib corre rre"
or
 "raw copyrect tight hextile zlib corre rre"
when VNC snapshot and the server are on the same machine.
-compresslevel level Compress network messages to level, if the server supports it. level is between 0 and 9, with 0 being no compression and 9 the maximum. The default is 4.
-allowblank
-ignoreblank
Allow, or ignore, blank (all black) screens from the server. The default is to ignore blank screens, and to wait for the first non-blank screen instead. This is useful with some versions of RealVNC, which send an all-black screen initially before sending the actual screen image.
-vncQuality quality Use the specified image quality level (0-9) for tight encoding. The default is 9.
-quality quality Use the specified JPEG image quality (0-100) for the output file. The default is 100.
-quiet Do not print any messages. Opposite of -verbose.
-verbose Print messages; default.
-rect wxh+x+y Save a sub-rectangle of the screen, width w height h offset from the left by x and the top by y.

A negative number for x or y makes it an offset from the opposite edge.

A zero value for the width or height makes the snapshot extend to the right or bottom of the screen, respectively.

The default is the entire screen.

-count number Take number snapshots; default 1. If greater than 1, vncsnapshot will insert a five-digit sequence number just before the output file's extension; i.e. if you specify out.jpeg as the output file, it will create out00001.jpeg, out00002.jpeg, and so forth.
-fps rate When taking multiple snapshots, take them every rate seconds; default 60.

Example Command Lines

vncsnapshot anhk-morpork:1 unseen.jpg
Get a snapshot of screen 1 from the server ahnk-morpork and save it in unseen.jpg. The entire screen is saved; the default transport is used.
vncsnapshot -listen 0 portrait.jpeg
Wait for a server to connect to this host (using "screen" 0), and then save the full screen image in portrait.jpeg.
vncsnapshot -passwd ~/.vnc/passwd -rect 640x0+120+30 :1 subarea.jpeg
Using ~/.vnc/passwd to get the server's password, connect to screen 1 on the local machine and save a rectangle 640 pixels high and extending to the right edge offset 120 pixels from the left and 30 pixels down.
vncsnapshot -rect 0x0-800-600 :1 pict.jpeg
Get a snapshot that is 800 pixels from the right edge and 600 pixels from the bottom of the screen. It will extend to the screen edges, making it 800x600. Alternatively, the rectangle could be given as -rect 800x600-0-0, which specifies the same region.

Project Summary

Current Release:
Version: 1.2a
Release Notes: 1.2 Release Notes
Change Log: 1.2a Change Log
vncsnapshot-1.2a/zrle.cxx0100644005671200567000000000600207574257252015170 0ustar grantharmony// // 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. // // zrle.cxx // // Decode function for Zlib Run-length Encoding (ZRLE). // #include #include #include extern "C" { #include "vncsnapshot.h" } // Instantiate the decoding function for 8, 16 and 32 BPP #define IMAGE_RECT(x,y,w,h,data) \ CopyDataToScreen((char*)data,x,y,w,h); #define FILL_RECT(x,y,w,h,pix) \ FillBufferRectangle(x, y, w, h, pix); #define BPP 8 #include #undef BPP #undef FILL_RECT #define FILL_RECT(x,y,w,h,pix) \ FillBufferRectangle(x, y, w, h, pix); #define BPP 16 #include #undef BPP #define BPP 32 #include #define CPIXEL 24A #include #undef CPIXEL #define CPIXEL 24B #include #undef CPIXEL #undef BPP #define BUFFER_SIZE (rfbZRLETileWidth * rfbZRLETileHeight * 4) static char buffer[BUFFER_SIZE]; rdr::ZlibInStream zis; extern rdr::FdInStream* fis; Bool zrleDecode(int x, int y, int w, int h) { try { switch (myFormat.bitsPerPixel) { case 8: zrleDecode8( x,y,w,h,fis,&zis,(rdr::U8*)buffer); break; case 16: zrleDecode16(x,y,w,h,fis,&zis,(rdr::U16*)buffer); break; case 32: bool fitsInLS3Bytes = ((myFormat.redMax << myFormat.redShift) < (1<<24) && (myFormat.greenMax << myFormat.greenShift) < (1<<24) && (myFormat.blueMax << myFormat.blueShift) < (1<<24)); bool fitsInMS3Bytes = (myFormat.redShift > 7 && myFormat.greenShift > 7 && myFormat.blueShift > 7); if ((fitsInLS3Bytes && !myFormat.bigEndian) || (fitsInMS3Bytes && myFormat.bigEndian)) { zrleDecode24A(x,y,w,h,fis,&zis,(rdr::U32*)buffer); } else if ((fitsInLS3Bytes && myFormat.bigEndian) || (fitsInMS3Bytes && !myFormat.bigEndian)) { zrleDecode24B(x,y,w,h,fis,&zis,(rdr::U32*)buffer); } else { zrleDecode32(x,y,w,h,fis,&zis,(rdr::U32*)buffer); } break; } } catch (rdr::Exception& e) { fprintf(stderr,"ZRLE decoder exception: %s\n",e.str()); return False; } return True; } vncsnapshot-1.2a/protocols/0040755005671200567000000000000010120076460015476 5ustar grantharmonyvncsnapshot-1.2a/protocols/corre.c0100644005671200567000000000367307574257252017005 0ustar grantharmony/* * 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. */ /* * 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 CONCAT2E(CARD,BPP) static Bool HandleCoRREBPP (int rx, int ry, int rw, int rh) { rfbRREHeader hdr; unsigned int i; CARDBPP pix; CARD8 *ptr; int x, y, w, h; if (!ReadFromRFBServer((char *)&hdr, sz_rfbRREHeader)) return False; hdr.nSubrects = Swap32IfLE(hdr.nSubrects); if (!ReadFromRFBServer((char *)&pix, sizeof(pix))) return False; FillBufferRectangle(rx, ry, rw, rh, pix); if (!ReadFromRFBServer(buffer, hdr.nSubrects * (4 + (BPP / 8)))) return False; ptr = (CARD8 *)buffer; for (i = 0; i < hdr.nSubrects; i++) { pix = *(CARDBPP *)ptr; ptr += BPP/8; x = *ptr++; y = *ptr++; w = *ptr++; h = *ptr++; FillBufferRectangle(rx + x, ry + y, w, h, pix); } return True; } vncsnapshot-1.2a/protocols/hextile.c0100644005671200567000000000611007574257252017322 0ustar grantharmony/* * 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. */ /* * 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 CONCAT2E(CARD,BPP) #define GET_PIXEL CONCAT2E(GET_PIXEL,BPP) static Bool HandleHextileBPP (int rx, int ry, int rw, int rh) { CARDBPP bg, fg; int i; CARD8 *ptr; int x, y, w, h; int sx, sy, sw, sh; CARD8 subencoding; CARD8 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((char *)&subencoding, 1)) return False; if (subencoding & rfbHextileRaw) { if (!ReadFromRFBServer(buffer, w * h * (BPP / 8))) return False; CopyDataToScreen(buffer, x, y, w, h); continue; } if (subencoding & rfbHextileBackgroundSpecified) if (!ReadFromRFBServer((char *)&bg, sizeof(bg))) return False; FillBufferRectangle(x, y, w, h, bg); if (subencoding & rfbHextileForegroundSpecified) if (!ReadFromRFBServer((char *)&fg, sizeof(fg))) return False; if (!(subencoding & rfbHextileAnySubrects)) { continue; } if (!ReadFromRFBServer((char *)&nSubrects, 1)) return False; ptr = (CARD8 *)buffer; if (subencoding & rfbHextileSubrectsColoured) { if (!ReadFromRFBServer(buffer, nSubrects * (2 + (BPP / 8)))) return False; for (i = 0; i < nSubrects; i++) { GET_PIXEL(fg, ptr); sx = rfbHextileExtractX(*ptr); sy = rfbHextileExtractY(*ptr); ptr++; sw = rfbHextileExtractW(*ptr); sh = rfbHextileExtractH(*ptr); ptr++; FillBufferRectangle(x+sx, y+sy, sw, sh, fg); } } else { if (!ReadFromRFBServer(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++; FillBufferRectangle(x+sx, y+sy, sw, sh, fg); } } } } return True; } vncsnapshot-1.2a/protocols/rre.c0100644005671200567000000000404707574257252016457 0ustar grantharmony/* * 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. */ /* * 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 CONCAT2E(CARD,BPP) static Bool HandleRREBPP (int rx, int ry, int rw, int rh) { rfbRREHeader hdr; unsigned int i; CARDBPP pix; rfbRectangle subrect; if (!ReadFromRFBServer((char *)&hdr, sz_rfbRREHeader)) return False; hdr.nSubrects = Swap32IfLE(hdr.nSubrects); if (!ReadFromRFBServer((char *)&pix, sizeof(pix))) return False; FillBufferRectangle(rx, ry, rw, rh, pix); for (i = 0; i < hdr.nSubrects; i++) { if (!ReadFromRFBServer((char *)&pix, sizeof(pix))) return False; if (!ReadFromRFBServer((char *)&subrect, sz_rfbRectangle)) return False; subrect.x = Swap16IfLE(subrect.x); subrect.y = Swap16IfLE(subrect.y); subrect.w = Swap16IfLE(subrect.w); subrect.h = Swap16IfLE(subrect.h); FillBufferRectangle(rx + subrect.x, ry + subrect.y, subrect.w, subrect.h, pix); } return True; } vncsnapshot-1.2a/protocols/tight.c0100644005671200567000000003676507431306773017015 0ustar grantharmony/* * 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. */ /* * 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 CONCAT2E(CARD,BPP) #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) & myFormat.redMax) << myFormat.redShift | \ ((CARD##bpp)(g) & myFormat.greenMax) << myFormat.greenShift | \ ((CARD##bpp)(b) & myFormat.blueMax) << myFormat.blueShift) #define RGB24_TO_PIXEL(bpp,r,g,b) \ ((((CARD##bpp)(r) & 0xFF) * myFormat.redMax + 127) / 255 \ << myFormat.redShift | \ (((CARD##bpp)(g) & 0xFF) * myFormat.greenMax + 127) / 255 \ << myFormat.greenShift | \ (((CARD##bpp)(b) & 0xFF) * myFormat.blueMax + 127) / 255 \ << myFormat.blueShift) #define RGB24_TO_PIXEL32(r,g,b) \ (((CARD32)(r) & 0xFF) << myFormat.redShift | \ ((CARD32)(g) & 0xFF) << myFormat.greenShift | \ ((CARD32)(b) & 0xFF) << myFormat.blueShift) #endif /* Type declarations */ typedef void (*filterPtrBPP)(int, CARDBPP *); /* Prototypes */ static int InitFilterCopyBPP (int rw, int rh); static int InitFilterPaletteBPP (int rw, int rh); static int InitFilterGradientBPP (int rw, int rh); static void FilterCopyBPP (int numRows, CARDBPP *destBuffer); static void FilterPaletteBPP (int numRows, CARDBPP *destBuffer); static void FilterGradientBPP (int numRows, CARDBPP *destBuffer); static Bool DecompressJpegRectBPP(int x, int y, int w, int h); /* Definitions */ static Bool HandleTightBPP (int rx, int ry, int rw, int rh) { CARDBPP fill_colour; CARD8 comp_ctl; CARD8 filter_id; filterPtrBPP filterFn; z_streamp zs; char *buffer2; int err, stream_id, compressedLen, bitsPixel; int bufferSize, rowSize, numRows, portionLen, rowsProcessed, extraBytes; if (!ReadFromRFBServer((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) && zlibStreamActive[stream_id]) { if (inflateEnd (&zlibStream[stream_id]) != Z_OK && zlibStream[stream_id].msg != NULL) fprintf(stderr, "inflateEnd: %s\n", zlibStream[stream_id].msg); zlibStreamActive[stream_id] = False; } comp_ctl >>= 1; } /* Handle solid rectangles. */ if (comp_ctl == rfbTightFill) { #if BPP == 32 if (myFormat.depth == 24 && myFormat.redMax == 0xFF && myFormat.greenMax == 0xFF && myFormat.blueMax == 0xFF) { if (!ReadFromRFBServer(buffer, 3)) return False; fill_colour = RGB24_TO_PIXEL32(buffer[0], buffer[1], buffer[2]); } else { if (!ReadFromRFBServer((char*)&fill_colour, sizeof(fill_colour))) return False; } #else if (!ReadFromRFBServer((char*)&fill_colour, sizeof(fill_colour))) return False; #endif FillBufferRectangle(rx, ry, rw, rh, fill_colour); return True; } #if BPP == 8 if (comp_ctl == rfbTightJpeg) { fprintf(stderr, "Tight encoding: JPEG is not supported in 8 bpp mode.\n"); return False; } #else if (comp_ctl == rfbTightJpeg) { return DecompressJpegRectBPP(rx, ry, rw, rh); } #endif /* Quit on unsupported subencoding value. */ if (comp_ctl > rfbTightMaxSubencoding) { fprintf(stderr, "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((char*)&filter_id, 1)) return False; switch (filter_id) { case rfbTightFilterCopy: filterFn = FilterCopyBPP; bitsPixel = InitFilterCopyBPP(rw, rh); break; case rfbTightFilterPalette: filterFn = FilterPaletteBPP; bitsPixel = InitFilterPaletteBPP(rw, rh); break; case rfbTightFilterGradient: filterFn = FilterGradientBPP; bitsPixel = InitFilterGradientBPP(rw, rh); break; default: fprintf(stderr, "Tight encoding: unknown filter code received.\n"); return False; } } else { filterFn = FilterCopyBPP; bitsPixel = InitFilterCopyBPP(rw, rh); } if (bitsPixel == 0) { fprintf(stderr, "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((char*)buffer, rh * rowSize)) return False; buffer2 = &buffer[TIGHT_MIN_TO_COMPRESS * 4]; filterFn(rh, (CARDBPP *)buffer2); CopyDataToScreen(buffer2, rx, ry, rw, rh); return True; } /* Read the length (1..3 bytes) of compressed data following. */ compressedLen = (int)ReadCompactLen(); if (compressedLen <= 0) { fprintf(stderr, "Incorrect data received from the server.\n"); return False; } /* Now let's initialize compression stream if needed. */ stream_id = comp_ctl & 0x03; zs = &zlibStream[stream_id]; if (!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) fprintf(stderr, "InflateInit error: %s.\n", zs->msg); return False; } zlibStreamActive[stream_id] = True; } /* Read, decode and draw actual pixel data in a loop. */ bufferSize = BUFFER_SIZE * bitsPixel / (bitsPixel + BPP) & 0xFFFFFFFC; buffer2 = &buffer[bufferSize]; if (rowSize > bufferSize) { /* Should be impossible when BUFFER_SIZE >= 16384 */ fprintf(stderr, "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((char*)zlib_buffer, portionLen)) return False; compressedLen -= portionLen; zs->next_in = (Bytef *)zlib_buffer; zs->avail_in = portionLen; do { zs->next_out = (Bytef *)&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) { fprintf(stderr, "Inflate error: %s.\n", zs->msg); } else { fprintf(stderr, "Inflate error: %d.\n", err); } return False; } numRows = (bufferSize - zs->avail_out) / rowSize; filterFn(numRows, (CARDBPP *)buffer2); extraBytes = bufferSize - zs->avail_out - numRows * rowSize; if (extraBytes > 0) memcpy(buffer, &buffer[numRows * rowSize], extraBytes); CopyDataToScreen(buffer2, rx, ry + rowsProcessed, rw, numRows); rowsProcessed += numRows; } while (zs->avail_out == 0); } if (rowsProcessed != rh) { fprintf(stderr, "Incorrect number of scan lines after decompression.\n"); return False; } return True; } /*---------------------------------------------------------------------------- * * Filter stuff. * */ /* The following variables are defined in rfbproto.c: static Bool cutZeros; static int rectWidth, rectColors; static CARD8 tightPalette[256*4]; static CARD8 tightPrevRow[2048*3*sizeof(CARD16)]; */ static int InitFilterCopyBPP (int rw, int rh) { rectWidth = rw; #if BPP == 32 if (myFormat.depth == 24 && myFormat.redMax == 0xFF && myFormat.greenMax == 0xFF && myFormat.blueMax == 0xFF) { cutZeros = True; return 24; } else { cutZeros = False; } #endif return BPP; } static void FilterCopyBPP (int numRows, CARDBPP *dst) { #if BPP == 32 int x, y; if (cutZeros) { for (y = 0; y < numRows; y++) { for (x = 0; x < rectWidth; x++) { dst[y*rectWidth+x] = RGB24_TO_PIXEL32(buffer[(y*rectWidth+x)*3], buffer[(y*rectWidth+x)*3+1], buffer[(y*rectWidth+x)*3+2]); } } return; } #endif memcpy (dst, buffer, numRows * rectWidth * (BPP / 8)); } static int InitFilterGradientBPP (int rw, int rh) { int bits; bits = InitFilterCopyBPP(rw, rh); if (cutZeros) memset(tightPrevRow, 0, rw * 3); else memset(tightPrevRow, 0, rw * 3 * sizeof(CARD16)); return bits; } #if BPP == 32 static void FilterGradient24 (int numRows, CARD32 *dst) { int x, y, c; CARD8 thisRow[2048*3]; CARD8 pix[3]; int est[3]; for (y = 0; y < numRows; y++) { /* First pixel in a row */ for (c = 0; c < 3; c++) { pix[c] = tightPrevRow[c] + buffer[y*rectWidth*3+c]; thisRow[c] = pix[c]; } dst[y*rectWidth] = RGB24_TO_PIXEL32(pix[0], pix[1], pix[2]); /* Remaining pixels of a row */ for (x = 1; x < rectWidth; x++) { for (c = 0; c < 3; c++) { est[c] = (int)tightPrevRow[x*3+c] + (int)pix[c] - (int)tightPrevRow[(x-1)*3+c]; if (est[c] > 0xFF) { est[c] = 0xFF; } else if (est[c] < 0x00) { est[c] = 0x00; } pix[c] = (CARD8)est[c] + buffer[(y*rectWidth+x)*3+c]; thisRow[x*3+c] = pix[c]; } dst[y*rectWidth+x] = RGB24_TO_PIXEL32(pix[0], pix[1], pix[2]); } memcpy(tightPrevRow, thisRow, rectWidth * 3); } } #endif static void FilterGradientBPP (int numRows, CARDBPP *dst) { int x, y, c; CARDBPP *src = (CARDBPP *)buffer; CARD16 *thatRow = (CARD16 *)tightPrevRow; CARD16 thisRow[2048*3]; CARD16 pix[3]; CARD16 max[3]; int shift[3]; int est[3]; #if BPP == 32 if (cutZeros) { FilterGradient24(numRows, dst); return; } #endif max[0] = myFormat.redMax; max[1] = myFormat.greenMax; max[2] = myFormat.blueMax; shift[0] = myFormat.redShift; shift[1] = myFormat.greenShift; shift[2] = myFormat.blueShift; for (y = 0; y < numRows; y++) { /* First pixel in a row */ for (c = 0; c < 3; c++) { pix[c] = (CARD16)((src[y*rectWidth] >> shift[c]) + thatRow[c] & max[c]); thisRow[c] = pix[c]; } dst[y*rectWidth] = RGB_TO_PIXEL(BPP, pix[0], pix[1], pix[2]); /* Remaining pixels of a row */ for (x = 1; x < 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] = (CARD16)((src[y*rectWidth+x] >> shift[c]) + est[c] & max[c]); thisRow[x*3+c] = pix[c]; } dst[y*rectWidth+x] = RGB_TO_PIXEL(BPP, pix[0], pix[1], pix[2]); } memcpy(thatRow, thisRow, rectWidth * 3 * sizeof(CARD16)); } } static int InitFilterPaletteBPP (int rw, int rh) { int i; CARD8 numColors; CARDBPP *palette = (CARDBPP *)tightPalette; rectWidth = rw; if (!ReadFromRFBServer((char*)&numColors, 1)) return 0; rectColors = (int)numColors; if (++rectColors < 2) return 0; #if BPP == 32 if (myFormat.depth == 24 && myFormat.redMax == 0xFF && myFormat.greenMax == 0xFF && myFormat.blueMax == 0xFF) { if (!ReadFromRFBServer((char*)&tightPalette, rectColors * 3)) return 0; for (i = rectColors - 1; i >= 0; i--) { palette[i] = RGB24_TO_PIXEL32(tightPalette[i*3], tightPalette[i*3+1], tightPalette[i*3+2]); } return (rectColors == 2) ? 1 : 8; } #endif if (!ReadFromRFBServer((char*)&tightPalette, rectColors * (BPP / 8))) return 0; return (rectColors == 2) ? 1 : 8; } static void FilterPaletteBPP (int numRows, CARDBPP *dst) { int x, y, b, w; CARD8 *src = (CARD8 *)buffer; CARDBPP *palette = (CARDBPP *)tightPalette; if (rectColors == 2) { w = (rectWidth + 7) / 8; for (y = 0; y < numRows; y++) { for (x = 0; x < rectWidth / 8; x++) { for (b = 7; b >= 0; b--) dst[y*rectWidth+x*8+7-b] = palette[src[y*w+x] >> b & 1]; } for (b = 7; b >= 8 - rectWidth % 8; b--) { dst[y*rectWidth+x*8+7-b] = palette[src[y*w+x] >> b & 1]; } } } else { for (y = 0; y < numRows; y++) for (x = 0; x < rectWidth; x++) dst[y*rectWidth+x] = palette[(int)src[y*rectWidth+x]]; } } #if BPP != 8 /*---------------------------------------------------------------------------- * * JPEG decompression. * */ /* The following variables are defined in rfbproto.c: static Bool jpegError; static struct jpeg_source_mgr jpegSrcManager; static JOCTET *jpegBufferPtr; static size_t *jpegBufferLen; */ static Bool DecompressJpegRectBPP(int x, int y, int w, int h) { struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr jerr; int compressedLen; CARD8 *compressedData; CARDBPP *pixelPtr; JSAMPROW rowPointer[1]; int dx, dy; compressedLen = (int)ReadCompactLen(); if (compressedLen <= 0) { fprintf(stderr, "Incorrect data received from the server.\n"); return False; } compressedData = malloc(compressedLen); if (compressedData == NULL) { fprintf(stderr, "Memory allocation error.\n"); return False; } if (!ReadFromRFBServer((char*)compressedData, compressedLen)) { free(compressedData); return False; } cinfo.err = jpeg_std_error(&jerr); 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 != (unsigned int) w || cinfo.output_height != (unsigned int) h || cinfo.output_components != 3) { fprintf(stderr, "Tight Encoding: Wrong JPEG data received.\n"); jpeg_destroy_decompress(&cinfo); free(compressedData); return False; } rowPointer[0] = (JSAMPROW)buffer; dy = 0; while (cinfo.output_scanline < cinfo.output_height) { jpeg_read_scanlines(&cinfo, rowPointer, 1); if (jpegError) { break; } pixelPtr = (CARDBPP *)&buffer[BUFFER_SIZE / 2]; for (dx = 0; dx < w; dx++) { *pixelPtr++ = RGB24_TO_PIXEL(BPP, buffer[dx*3], buffer[dx*3+1], buffer[dx*3+2]); } CopyDataToScreen(&buffer[BUFFER_SIZE / 2], x, y + dy, w, 1); dy++; } if (!jpegError) jpeg_finish_decompress(&cinfo); jpeg_destroy_decompress(&cinfo); free(compressedData); return !jpegError; } #endif vncsnapshot-1.2a/protocols/zlib.c0100644005671200567000000001052507431306773016620 0ustar grantharmony/* * 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. */ /* * 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 CONCAT2E(CARD,BPP) static Bool HandleZlibBPP (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 ( raw_buffer_size < (( rw * rh ) * ( BPP / 8 ))) { if ( raw_buffer != NULL ) { free( raw_buffer ); } raw_buffer_size = (( rw * rh ) * ( BPP / 8 )); raw_buffer = (char*) malloc( raw_buffer_size ); } if (!ReadFromRFBServer((char *)&hdr, sz_rfbZlibHeader)) return False; remaining = Swap32IfLE(hdr.nBytes); /* Need to initialize the decompressor state. */ decompStream.next_in = ( Bytef * )buffer; decompStream.avail_in = 0; decompStream.next_out = ( Bytef * )raw_buffer; decompStream.avail_out = raw_buffer_size; decompStream.data_type = Z_BINARY; /* Initialize the decompression stream structures on the first invocation. */ if ( decompStreamInited == False ) { inflateResult = inflateInit( &decompStream ); if ( inflateResult != Z_OK ) { fprintf(stderr, "inflateInit returned error: %d, msg: %s\n", inflateResult, decompStream.msg); return False; } 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 > BUFFER_SIZE ) { toRead = BUFFER_SIZE; } else { toRead = remaining; } /* Fill the buffer, obtaining data from the server. */ if (!ReadFromRFBServer(buffer,toRead)) return False; decompStream.next_in = ( Bytef * )buffer; decompStream.avail_in = toRead; /* Need to uncompress buffer full. */ inflateResult = inflate( &decompStream, Z_SYNC_FLUSH ); /* We never supply a dictionary for compression. */ if ( inflateResult == Z_NEED_DICT ) { fprintf(stderr,"zlib inflate needs a dictionary!\n"); return False; } if ( inflateResult < 0 ) { fprintf(stderr, "zlib inflate returned error: %d, msg: %s\n", inflateResult, decompStream.msg); return False; } /* Result buffer allocated to be at least large enough. We should * never run out of space! */ if (( decompStream.avail_in > 0 ) && ( decompStream.avail_out <= 0 )) { fprintf(stderr,"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. */ CopyDataToScreen(raw_buffer, rx, ry, rw, rh); } else { fprintf(stderr, "zlib inflate returned error: %d, msg: %s\n", inflateResult, decompStream.msg); return False; } return True; } vncsnapshot-1.2a/rfb/0040755005671200567000000000000010120076465014230 5ustar grantharmonyvncsnapshot-1.2a/rfb/zrleDecode.h0100644005671200567000000001401607574257252016476 0ustar grantharmony// // 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. // // zrleDecode.h - zrle decoding function. // // 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. // FILL_RECT // IMAGE_RECT #include #include #include using namespace rdr; /* __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 #ifdef CPIXEL #define PIXEL_T __RFB_CONCAT2E(rdr::U,BPP) #define READ_PIXEL __RFB_CONCAT2E(readOpaque,CPIXEL) #define ZRLE_DECODE_BPP __RFB_CONCAT2E(zrleDecode,CPIXEL) #else #define PIXEL_T __RFB_CONCAT2E(rdr::U,BPP) #define READ_PIXEL __RFB_CONCAT2E(readOpaque,BPP) #define ZRLE_DECODE_BPP __RFB_CONCAT2E(zrleDecode,BPP) #endif void ZRLE_DECODE_BPP (int x, int y, int w, int h, rdr::InStream* is, rdr::ZlibInStream* zis, PIXEL_T* buf) { int length = is->readU32(); zis->setUnderlying(is, length); for (int ty = y; ty < y+h; ty += rfbZRLETileHeight) { int th = rfbZRLETileHeight; if (th > y+h-ty) th = y+h-ty; for (int tx = x; tx < x+w; tx += rfbZRLETileWidth) { int tw = rfbZRLETileWidth; if (tw > x+w-tx) tw = x+w-tx; int mode = zis->readU8(); bool rle = mode & 128; int palSize = mode & 127; PIXEL_T palette[128]; // fprintf(stderr,"rle %d palSize %d\n",rle,palSize); for (int i = 0; i < palSize; i++) { palette[i] = zis->READ_PIXEL(); } if (palSize == 1) { PIXEL_T pix = palette[0]; FILL_RECT(tx,ty,tw,th,pix); continue; } if (!rle) { if (palSize == 0) { // raw #ifdef CPIXEL for (PIXEL_T* ptr = buf; ptr < buf+tw*th; ptr++) { *ptr = zis->READ_PIXEL(); } #else zis->readBytes(buf, tw * th * (BPP / 8)); #endif } else { // packed pixels int bppp = ((palSize > 16) ? 8 : ((palSize > 4) ? 4 : ((palSize > 2) ? 2 : 1))); PIXEL_T* ptr = buf; for (int i = 0; i < th; i++) { PIXEL_T* eol = ptr + tw; U8 byte = 0; U8 nbits = 0; while (ptr < eol) { if (nbits == 0) { byte = zis->readU8(); nbits = 8; } nbits -= bppp; U8 index = (byte >> nbits) & ((1 << bppp) - 1) & 127; *ptr++ = palette[index]; } } } #ifdef FAVOUR_FILL_RECT //fprintf(stderr,"copying data to screen %dx%d at %d,%d\n",tw,th,tx,ty); IMAGE_RECT(tx,ty,tw,th,buf); #endif } else { if (palSize == 0) { // plain RLE PIXEL_T* ptr = buf; PIXEL_T* end = ptr + th * tw; while (ptr < end) { PIXEL_T pix = zis->READ_PIXEL(); int len = 1; int b; do { b = zis->readU8(); len += b; } while (b == 255); assert(len <= end - ptr); #ifdef FAVOUR_FILL_RECT int i = ptr - buf; ptr += len; int runX = i % tw; int runY = i / tw; if (runX + len > tw) { if (runX != 0) { FILL_RECT(tx+runX, ty+runY, tw-runX, 1, pix); len -= tw-runX; runX = 0; runY++; } if (len > tw) { FILL_RECT(tx, ty+runY, tw, len/tw, pix); runY += len / tw; len = len % tw; } } if (len != 0) { FILL_RECT(tx+runX, ty+runY, len, 1, pix); } #else while (len-- > 0) *ptr++ = pix; #endif } } else { // palette RLE PIXEL_T* ptr = buf; PIXEL_T* end = ptr + th * tw; while (ptr < end) { int index = zis->readU8(); int len = 1; if (index & 128) { int b; do { b = zis->readU8(); len += b; } while (b == 255); assert(len <= end - ptr); } index &= 127; PIXEL_T pix = palette[index]; #ifdef FAVOUR_FILL_RECT int i = ptr - buf; ptr += len; int runX = i % tw; int runY = i / tw; if (runX + len > tw) { if (runX != 0) { FILL_RECT(tx+runX, ty+runY, tw-runX, 1, pix); len -= tw-runX; runX = 0; runY++; } if (len > tw) { FILL_RECT(tx, ty+runY, tw, len/tw, pix); runY += len / tw; len = len % tw; } } if (len != 0) { FILL_RECT(tx+runX, ty+runY, len, 1, pix); } #else while (len-- > 0) *ptr++ = pix; #endif } } } #ifndef FAVOUR_FILL_RECT //fprintf(stderr,"copying data to screen %dx%d at %d,%d\n",tw,th,tx,ty); IMAGE_RECT(tx,ty,tw,th,buf); #endif } } zis->reset(); } #undef ZRLE_DECODE_BPP #undef READ_PIXEL #undef PIXEL_T vncsnapshot-1.2a/rfb/zrleEncode.h0100644005671200567000000001661607574257252016520 0ustar grantharmony// // 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. // // zrleEncode.h - zrle encoding function. // // 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 #include using namespace rdr; /* __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 #ifdef CPIXEL #define PIXEL_T __RFB_CONCAT2E(rdr::U,BPP) #define WRITE_PIXEL __RFB_CONCAT2E(writeOpaque,CPIXEL) #define ZRLE_ENCODE __RFB_CONCAT2E(zrleEncode,CPIXEL) #define ZRLE_ENCODE_TILE __RFB_CONCAT2E(zrleEncodeTile,CPIXEL) #define BPPOUT 24 #else #define PIXEL_T __RFB_CONCAT2E(rdr::U,BPP) #define WRITE_PIXEL __RFB_CONCAT2E(writeOpaque,BPP) #define ZRLE_ENCODE __RFB_CONCAT2E(zrleEncode,BPP) #define ZRLE_ENCODE_TILE __RFB_CONCAT2E(zrleEncodeTile,BPP) #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 }; // The PaletteHelper class helps us build up the palette from pixel data by // storing a reverse index using a simple hash-table class PaletteHelper { public: enum { MAX_SIZE = 127 }; PaletteHelper() { memset(index, 255, sizeof(index)); size = 0; } inline int hash(rdr::U32 pix) { return (pix ^ (pix >> 17)) & 4095; } inline void insert(rdr::U32 pix) { if (size < MAX_SIZE) { int i = hash(pix); while (index[i] != 255 && key[i] != pix) i++; if (index[i] != 255) return; index[i] = size; key[i] = pix; palette[size] = pix; } size++; } inline int lookup(rdr::U32 pix) { assert(size <= MAX_SIZE); int i = hash(pix); while (index[i] != 255 && key[i] != pix) i++; if (index[i] != 255) return index[i]; return -1; } rdr::U32 palette[MAX_SIZE]; rdr::U8 index[4096+MAX_SIZE]; rdr::U32 key[4096+MAX_SIZE]; int size; }; #endif void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, rdr::OutStream* os); void ZRLE_ENCODE (int x, int y, int w, int h, rdr::OutStream* os, rdr::ZlibOutStream* zos, void* buf EXTRA_ARGS ) { zos->setUnderlying(os); for (int ty = y; ty < y+h; ty += rfbZRLETileHeight) { int th = rfbZRLETileHeight; if (th > y+h-ty) th = y+h-ty; for (int 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); ZRLE_ENCODE_TILE((PIXEL_T*)buf, tw, th, zos); } } zos->flush(); } void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, rdr::OutStream* os) { // First find the palette and the number of runs PaletteHelper ph; int runs = 0; int singlePixels = 0; PIXEL_T* ptr = data; PIXEL_T* end = ptr + h * w; *end = ~*(end-1); // one past the end is different so the while loop ends while (ptr < end) { PIXEL_T pix = *ptr; if (*++ptr != pix) { singlePixels++; } else { while (*++ptr == pix) ; runs++; } ph.insert(pix); } //fprintf(stderr,"runs %d, single pixels %d, paletteSize %d\n", // runs, singlePixels, ph.size); // Solid tile is a special case if (ph.size == 1) { os->writeU8(1); os->WRITE_PIXEL(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... bool useRle = false; bool usePalette = false; int estimatedBytes = w * h * (BPPOUT/8); // start assuming raw int 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; os->writeU8((useRle ? 128 : 0) | ph.size); for (int i = 0; i < ph.size; i++) { os->WRITE_PIXEL(ph.palette[i]); } if (useRle) { PIXEL_T* ptr = data; PIXEL_T* end = ptr + w * h; PIXEL_T* runStart; PIXEL_T pix; while (ptr < end) { runStart = ptr; pix = *ptr++; while (*ptr == pix && ptr < end) ptr++; int len = ptr - runStart; if (len <= 2 && usePalette) { int index = ph.lookup(pix); if (len == 2) os->writeU8(index); os->writeU8(index); continue; } if (usePalette) { int index = ph.lookup(pix); os->writeU8(index | 128); } else { os->WRITE_PIXEL(pix); } len -= 1; while (len >= 255) { os->writeU8(255); len -= 255; } os->writeU8(len); } } else { // no RLE if (usePalette) { // packed pixels assert (ph.size < 17); int bppp = bitsPerPackedPixel[ph.size-1]; PIXEL_T* ptr = data; for (int i = 0; i < h; i++) { U8 nbits = 0; U8 byte = 0; PIXEL_T* eol = ptr + w; while (ptr < eol) { PIXEL_T pix = *ptr++; U8 index = ph.lookup(pix); byte = (byte << bppp) | index; nbits += bppp; if (nbits >= 8) { os->writeU8(byte); nbits = 0; } } if (nbits > 0) { byte <<= 8 - nbits; os->writeU8(byte); } } } else { // raw #ifdef CPIXEL for (PIXEL_T* ptr = data; ptr < data+w*h; ptr++) { os->WRITE_PIXEL(*ptr); } #else os->writeBytes(data, w*h*(BPP/8)); #endif } } } #undef PIXEL_T #undef WRITE_PIXEL #undef ZRLE_ENCODE #undef ZRLE_ENCODE_TILE #undef BPPOUT vncsnapshot-1.2a/zlib/0040755005671200567000000000000010120076466014420 5ustar grantharmonyvncsnapshot-1.2a/zlib/Makefile.bcc320100644005671200567000000000120707431306773016760 0ustar grantharmony# ------------- Borland C++ 5.5 (Win32) ------------- CC=bcc32 LIB=tlib CFLAGS= -v- -O2 -3 -tWM -q -w-8004 -w-8057 LIBFLAGS= /C OBJS=adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infblock.obj \ infcodes.obj inflate.obj inftrees.obj infutil.obj inffast.obj \ trees.obj uncompr.obj zutil.obj pOBJS=+adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infblock.obj \ +infcodes.obj+inflate.obj+inftrees.obj+infutil.obj+inffast.obj \ +trees.obj+uncompr.obj+zutil.obj .autodepend .c.obj: $(CC) -c $(CFLAGS) $< zlib.lib: $(OBJS) @if exist $@ del $@ $(LIB) $@ $(LIBFLAGS) $(pOBJS) clean: del *.obj *.lib vncsnapshot-1.2a/zlib/zlib.dsp0100755005671200567000000001016310120134430016053 0ustar grantharmony# Microsoft Developer Studio Project File - Name="zlib" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Static Library" 0x0104 CFG=zlib - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "zlib.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "zlib.mak" CFG="zlib - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "zlib - Win32 Release" (based on "Win32 (x86) Static Library") !MESSAGE "zlib - Win32 Debug" (based on "Win32 (x86) Static Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "zlib - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_WINDOWS" /D "__NT__" /D "_WINSTATIC" /D "__WIN32__" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo !ELSEIF "$(CFG)" == "zlib - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo !ENDIF # Begin Target # Name "zlib - Win32 Release" # Name "zlib - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\adler32.c # End Source File # Begin Source File SOURCE=.\compress.c # End Source File # Begin Source File SOURCE=.\crc32.c # End Source File # Begin Source File SOURCE=.\deflate.c # End Source File # Begin Source File SOURCE=.\gzio.c # End Source File # Begin Source File SOURCE=.\infback.c # End Source File # Begin Source File SOURCE=.\inffast.c # End Source File # Begin Source File SOURCE=.\inflate.c # End Source File # Begin Source File SOURCE=.\inftrees.c # End Source File # Begin Source File SOURCE=.\trees.c # End Source File # Begin Source File SOURCE=.\uncompr.c # End Source File # Begin Source File SOURCE=.\zutil.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\crc32.h # End Source File # Begin Source File SOURCE=.\deflate.h # End Source File # Begin Source File SOURCE=.\inffast.h # End Source File # Begin Source File SOURCE=.\inffixed.h # End Source File # Begin Source File SOURCE=.\inflate.h # End Source File # Begin Source File SOURCE=.\inftrees.h # End Source File # Begin Source File SOURCE=.\trees.h # End Source File # Begin Source File SOURCE=.\zconf.h # End Source File # Begin Source File SOURCE=.\zconf.in.h # End Source File # Begin Source File SOURCE=.\zlib.h # End Source File # Begin Source File SOURCE=.\zutil.h # End Source File # End Group # End Target # End Project