Commit e2c3255c authored by gkiagia's avatar gkiagia

Import a fork of libvncserver 0.9.7.

This is currently required to be able to split off the event processing code
in small functions so that it is possible to integrate libvncserver's event
loop code with Qt's event loop properly. This is also what vino does; the whole
event loop integration idea was taken from there.

git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/KDE/kdenetwork/krfb/libvncserver@1195283 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
parent 0ad7b0d2
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
typedef struct {
char* filename; /* this file is the pipe (set by user) */
char is_server; /* this is set by open_control_file */
int fd; /* this is set by open_control_file */
} single_instance_struct;
/* returns fd, is_server is set to -1 if server, 0 if client */
int open_control_file(single_instance_struct* str)
{
struct stat buf;
if(stat(str->filename,&buf)) {
mkfifo(str->filename,128|256);
str->is_server=-1;
str->fd=open(str->filename,O_NONBLOCK|O_RDONLY);
} else {
str->fd=open(str->filename,O_NONBLOCK|O_WRONLY);
if(errno==ENXIO) {
str->is_server=-1;
str->fd=open(str->filename,O_NONBLOCK|O_RDONLY);
} else
str->is_server=0;
}
return(str->fd);
}
void delete_control_file(single_instance_struct* str)
{
remove(str->filename);
}
void close_control_file(single_instance_struct* str)
{
close(str->fd);
}
typedef void (*event_dispatcher)(char* message);
int get_next_message(char* buffer,int len,single_instance_struct* str,int usecs)
{
struct timeval tv;
fd_set fdset;
int num_fds;
FD_ZERO(&fdset);
FD_SET(str->fd,&fdset);
tv.tv_sec=0;
tv.tv_usec=usecs;
num_fds=select(str->fd+1,&fdset,NULL,NULL,&tv);
if(num_fds) {
int reallen;
reallen=read(str->fd,buffer,len);
if(reallen==0) {
close(str->fd);
str->fd=open(str->filename,O_NONBLOCK|O_RDONLY);
num_fds--;
}
buffer[reallen]=0;
#ifdef DEBUG_1INSTANCE
if(reallen!=0) fprintf(stderr,"message received: %s.\n",buffer);
#endif
}
return(num_fds);
}
int dispatch_event(single_instance_struct* str,event_dispatcher dispatcher,int usecs)
{
char buffer[1024];
int num_fds;
if((num_fds=get_next_message(buffer,1024,str,usecs)) && buffer[0])
dispatcher(buffer);
return(num_fds);
}
int loop_if_server(single_instance_struct* str,event_dispatcher dispatcher)
{
open_control_file(str);
if(str->is_server) {
while(1)
dispatch_event(str,dispatcher,50);
}
return(str->fd);
}
void send_message(single_instance_struct* str,char* message)
{
#ifdef DEBUG_1INSTANCE
int i=
#endif
write(str->fd,message,strlen(message));
#ifdef DEBUG_1INSTANCE
fprintf(stderr,"send: %s => %d(%d)\n",message,i,strlen(message));
#endif
}
#ifdef DEBUG_MAIN
#include <stdio.h>
#include <stdlib.h>
single_instance_struct str1 = { "/tmp/1instance" };
void my_dispatcher(char* message)
{
#ifdef DEBUG_1INSTANCE
fprintf(stderr,"Message arrived: %s.\n",message);
#endif
if(!strcmp(message,"quit")) {
delete_control_file(str1);
exit(0);
}
}
int main(int argc,char** argv)
{
int i;
loop_if_server(str1,my_dispatcher);
for(i=1;i<argc;i++)
send_event(str1,argv[i]);
return(0);
}
#endif
memory leaks squashed (localtime pseudo leak is still there :-)
small improvements for OSXvnc (still not working correctly)
synced with TightVNC 1.2.3
solaris compile cleanups
many x11vnc improvements
added backchannel, an encoding which needs special clients to pass
arbitrary data to the client
changes from Tim Jansen regarding multi threading and client blocking
as well as C++ compliancy
x11vnc can be controlled by starting again with special options if compiling
with LOCAL_CONTROL defined
0.3
added x11vnc, a x0rfbserver clone
regard deferUpdateTime in processEvents, if usec<0
initialize deferUpdateTime (memory "leak"!)
changed command line handling (arguments are parsed and then removed)
added very simple example: zippy
added rfbDrawLine, rfbDrawPixel
0.2
inserted a deferUpdate mechanism (X11 independent).
removed deletion of requestedRegion
added rfbLoadConsoleFont
fixed font colour handling.
added rfbSelectBox
added rfbDrawCharWithClip to allow for clipping and a background colour.
fixed font colours
added rfbFillRect
added IO function to check password.
rfbNewClient now sets the socket in the fd_set (for the select() call)
when compiling the library with HAVE_PTHREADS and an application
which includes "rfb.h" without, the structures got mixed up.
So, the pthreads section is now always at the end, and also
you get a linker error for rfbInitServer when using two different
pthread setups.
fixed two deadlocks: when setting a cursor and when using CopyRect
fixed CopyRect when copying modified regions (they lost the modified
property)
WIN32 target compiles and works for example :-)
fixed CopyRect (was using the wrong order of rectangles...)
should also work with pthreads, because copyrects are
always sent immediately (so that two consecutive copy rects
cannot conflict).
changed rfbUndrawCursor(rfbClientPtr) to (rfbScreenInfoPtr), because
this makes more sense!
flag backgroundLoop in rfbScreenInfo (if having pthreads)
CopyRect & CopyRegion were implemented.
if you use a rfbDoCopyR* function, it copies the data in the
framebuffer. If you prefer to do that yourself, use rfbScheduleCopyR*
instead; this doesn't modify the frameBuffer.
added flag to optionally not send XCursor updates, but only RichCursor,
or if that is not possible, fall back to server side cursor.
This is useful if your cursor has many nice colours.
fixed java viewer on server side:
SendCursorUpdate would send data even before the client pixel format
was set, but the java applet doesn't like the server's format.
fixed two pthread issues:
rfbSendFramebuffer was sent by a ProcessClientMessage function
(unprotected by updateMutex).
cursor coordinates were set without protection by cursorMutex
source is now equivalent to TridiaVNC 1.2.1
pthreads now work (use iterators!)
cursors are supported (rfbSetCursor automatically undraws cursor)
support for 3 bytes/pixel (slow!)
server side colourmap support
fixed rfbCloseClient not to close the connection (pthreads!)
this is done lazily (and with proper signalling).
cleaned up mac.c (from original OSXvnc); now compiles (untested!)
compiles cleanly on Linux, IRIX, BSD, Apple (Darwin)
fixed prototypes
0.1
rewrote API to use pseudo-methods instead of required functions.
lots of clean up.
Example can show symbols now.
All encodings
HTTP
project(libvncserver)
find_package(ZLIB)
macro_log_feature(ZLIB_FOUND "ZLib" "The Zlib compression library" "http://www.zlib.net" FALSE "" "Used by the vncserver library.")
find_package(JPEG)
macro_log_feature(JPEG_FOUND "LibJPEG" "The JPEG library" "" FALSE "" "Used by the vncserver library")
include(CheckIncludeFiles)
include(CheckFunctionExists)
include(CheckCXXSourceCompiles)
include(TestBigEndian)
macro_bool_to_01(ZLIB_FOUND LIBVNCSERVER_HAVE_LIBZ)
macro_bool_to_01(JPEG_FOUND LIBVNCSERVER_HAVE_LIBJPEG)
check_include_files(fcntl.h LIBVNCSERVER_HAVE_FCNTL_H)
check_include_files(unistd.h LIBVNCSERVER_HAVE_UNISTD_H)
check_include_files(sys/socket.h LIBVNCSERVER_HAVE_SYS_SOCKET_H)
check_include_files(sys/types.h LIBVNCSERVER_HAVE_SYS_TYPES_H)
check_include_files(sys/stat.h LIBVNCSERVER_HAVE_SYS_STAT_H)
check_include_files(sys/time.h LIBVNCSERVER_HAVE_SYS_TIME_H)
check_include_files(netinet/in.h LIBVNCSERVER_HAVE_NETINET_IN_H)
check_include_files(stdint.h LIBVNCSERVER_HAVE_STDINT_H)
check_include_files(ifaddrs.h LIBVNCSERVER_HAVE_IFADDRS_H)
check_function_exists(gettimeofday LIBVNCSERVER_HAVE_GETTIMEOFDAY)
test_big_endian(LIBVNCSERVER_WORDS_BIGENDIAN)
set(LIBVNCSERVER_PACKAGE_STRING "Krfb ${KDE_VERSION} - LibVNCServer 0.9.7")
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/libvncserver-config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/libvncserver-config.h
)
set(LIBVNCSERVER_SRCS
main.c
rfbserver.c
rfbregion.c
auth.c
sockets.c
stats.c
corre.c
hextile.c
rre.c
translate.c
cutpaste.c
httpd.c
cursor.c
font.c
draw.c
selbox.c
d3des.c
vncauth.c
cargs.c
minilzo.c
ultra.c
scale.c
)
if (ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
set(LIBVNCSERVER_SRCS ${LIBVNCSERVER_SRCS} zlib.c zrle.c zrleoutstream.c zrlepalettehelper.c zywrletemplate.c)
if (JPEG_FOUND)
include_directories(${JPEG_INCLUDE_DIR})
set(LIBVNCSERVER_SRCS ${LIBVNCSERVER_SRCS} tight.c)
endif()
endif()
add_library(vncserver STATIC ${LIBVNCSERVER_SRCS})
if (ZLIB_FOUND)
target_link_libraries(vncserver ${ZLIB_LIBRARIES})
if (JPEG_FOUND)
target_link_libraries(vncserver ${JPEG_LIBRARIES})
endif()
endif()
This diff is collapsed.
This diff is collapsed.
immediate:
----------
x11vnc: clipboard, cursor, updates interruptible by input (doesn't work yet)
extra_bytes in rfbDrawCharWithClip.
tested mouse buttons make copy rect, but text is not marked as mod.
cursor drawing: set optional grain to mark bigger rectangles as drawn (else
you end up with thousands of one-pixel-rectangles to encode).
selectbox: scroll bars
documentation
hint that to mark very tiny regions as
modified is possibly inefficient for the encodings.
(a trail of points could better be a small rectangle).
later:
------
authentification schemes (secure vnc)
IO function ptr exists; now explain how to tunnel and implement a
client address restriction scheme.
autoconf? at least Sun Solaris and Windows compilation
(maybe Michael makes a small autconf)
using Hermes library for fast colour translations.
CORBA
internal HTTP tunnelling feature (needs a special GET target and a few
changes to java applet).
done:
-----
.x11vnc: sometimes XTest fails (but doesn't with x0rfbserver)
.DeferUpdateTime (timing problems!)
.empty cursor sending doesn't work.
.udp (need an rfbClientPtr udpClient in rfbScreen)
input only; nearly untested (don't have the clients).
.font handling: bpp>1
.test copyRect and pthreads.
.optionally dont draw rich cursors as xcursors
.cursor smears on IRIX with pthreads, then has bus error. has to be a mutex
problem in cursor routines.
.fix bug in http (java) client with big endian server: byte swapping is broken
(was a cursorshape which was sent too soon; java vncviewer assumes
a rich cursor shape to be always 1 byte per pixel, however, framebuffer
updates before setting the pixel format can be server format)
.rfbConnect, ConnectToTcpAddr
.update to newest TridiaVNC version (1.2.1).
.adapt rdp2vnc (rdesktop)
.pthreads concept: How to iterate over rfbClientPtr's? So that it can be
either called from rfbProcessEvents (which locks the list mutex)
or from the main thread (where the background loop sometimes
locks the list mutex).
- cursor drawing!
- cursor setting!
- rfbMarkRectAsModified
(did that by adding a refcount to clients secured by refCountMutex;
it also was necessary to check for cl->sock<0 in SendUpdateBuf)
.translate.c: warning about non 8-bit colourmaps
16-bit colourmaps are 192k -> no use without fast net.
.rfbCloseClient
.set colourmap
.support 3 bytes per pixel
.cursors
.cutpaste
.httpd
.other encodings
.test drawing of cursors when not using xcursor or rich cursor encoding
fix bug with odd width (depends on client depth: width has to be multiple of server.bytesPerPixel/client.bytesPerPixel). only raw!! -> bug of vncviewer!
.use sraRegion from Wez instead of miregion, because it is much smaller
. - connection gone and then reconnect is a problem
the reason: there are in fact three threads accessing
the clientPtr: input, output and the application thread.
if you kill the viewer or do rfbCloseClient, all of those
three have to be warned that this is happening.
-> rfbClientConnectionGone can only be called by the outer loop
(with background loop, it is input, else it is processEvents).
. fixed pthreads issues:
cursor deadlock,
CopyRect deadlock.
. when copying a region with modified parts, they were not marked
as modified
This diff is collapsed.
#!/usr/bin/perl
@encodings=();
for($i=0;$i<256*5;$i++) {
$encodings[$i]="0";
}
$out="";
$counter=0;
$fontname="default";
$i=0;
$searchfor="";
$nullx="0x";
while(<>) {
if(/^FONT (.*)$/) {
$fontname=$1;
$fontname=~y/\"//d;
} elsif(/^ENCODING (.*)$/) {
$glyphindex=$1;
$searchfor="BBX";
$dwidth=0;
} elsif(/^DWIDTH (.*) (.*)/) {
$dwidth=$1;
} elsif(/^BBX (.*) (.*) (.*) (.*)$/) {
($width,$height,$x,$y)=($1,$2,$3,$4);
@encodings[$glyphindex*5..($glyphindex*5+4)]=($counter,$width,$height,$x,$y);
if($dwidth != 0) {
$encodings[$glyphindex*5+1]=$dwidth;
} else {
$dwidth=$width;
}
$searchfor="BITMAP";
} elsif(/^BITMAP/) {
$i=1;
} elsif($i>0) {
if($i>$height) {
$i=0;
$out.=" /* $glyphindex */\n";
} else {
if(int(($dwidth+7)/8) > int(($width+7)/8)) {
$_ .= "00"x(int(($dwidth+7)/8)-int(($width+7)/8));
}
$_=substr($_,0,(int(($dwidth+7)/8)*2));
$counter+=(int(($dwidth+7)/8));
s/(..)/$nullx$1,/g;
$out.=$_;
$i++;
}
}
}
print "unsigned char " . $fontname . "FontData[$counter]={\n" . $out;
print "};\nint " . $fontname . "FontMetaData[256*5]={\n";
for($i=0;$i<256*5;$i++) {
print $encodings[$i] . ",";
}
print "};\nrfbFontData " . $fontname . "Font={" .
$fontname . "FontData, " . $fontname . "FontMetaData};\n";
/*
* This parses the command line arguments. It was separated from main.c by
* This parses the command line arguments. It was seperated from main.c by
* Justin Dearing <jdeari01@longisland.poly.edu>.
*/
/*
* LibVNCServer (C) 2001 Johannes E. Schindelin <Johannes.Schindelin@gmx.de>
* Original OSXvnc (C) 2001 Dan McGuirk <mcguirk@incompleteness.net>.
* Original Xvnc (C) 1999 AT&T Laboratories Cambridge.
* Original Xvnc (C) 1999 AT&T Laboratories Cambridge.
* All Rights Reserved.
*
* see GPL (latest version) for full details
*/
#include "rfb.h"
#include <rfb/rfb.h>
extern int rfbStringToAddr(char *str, in_addr_t *iface);
void
rfbUsage(void)
{
rfbProtocolExtension* extension;
fprintf(stderr, "-rfbport port TCP port for RFB protocol\n");
fprintf(stderr, "-rfbwait time max time in ms to wait for RFB client\n");
fprintf(stderr, "-rfbauth passwd-file use authentication on RFB protocol\n"
" (use 'storepasswd' to create a password file)\n");
fprintf(stderr, "-rfbversion 3.x Set the version of the RFB we choose to advertise\n");
fprintf(stderr, "-permitfiletransfer permit file transfer support\n");
fprintf(stderr, "-passwd plain-password use authentication \n"
" (use plain-password as password, USE AT YOUR RISK)\n");
fprintf(stderr, "-deferupdate time time in ms to defer updates "
"(default 40)\n");
fprintf(stderr, "-deferptrupdate time time in ms to defer pointer updates"
" (default none)\n");
fprintf(stderr, "-desktop name VNC desktop name (default \"LibVNCServer\")\n");
fprintf(stderr, "-alwaysshared always treat new clients as shared\n");
fprintf(stderr, "-nevershared never treat new clients as shared\n");
......@@ -32,7 +40,17 @@ rfbUsage(void)
"new non-shared\n"
" connection comes in (refuse new connection "
"instead)\n");
exit(1);
fprintf(stderr, "-httpdir dir-path enable http server using dir-path home\n");
fprintf(stderr, "-httpport portnum use portnum for http connection\n");
fprintf(stderr, "-enablehttpproxy enable http proxy support\n");
fprintf(stderr, "-progressive height enable progressive updating for slow links\n");
fprintf(stderr, "-listen ipaddr listen for connections only on network interface with\n");
fprintf(stderr, " addr ipaddr. '-listen localhost' and hostname work too.\n");
for(extension=rfbGetExtensionIterator();extension;extension=extension->next)
if(extension->usage)
extension->usage();
rfbReleaseExtensionIterator();
}
/* purges COUNT arguments from ARGV at POSITION and decrements ARGC.
......@@ -43,77 +61,139 @@ void rfbPurgeArguments(int* argc,int* position,int count,char *argv[])
if(amount)
memmove(argv+(*position),argv+(*position)+count,sizeof(char*)*amount);
(*argc)-=count;
(*position)--;
}
void
rfbBool
rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[])
{
int i,i1;
if(!argc) return;
for (i = i1 = 1; i < *argc; i++) {
if(!argc) return TRUE;
for (i = i1 = 1; i < *argc;) {
if (strcmp(argv[i], "-help") == 0) {
rfbUsage();
exit(1);
return FALSE;
} else if (strcmp(argv[i], "-rfbport") == 0) { /* -rfbport port */
if (i + 1 >= *argc) rfbUsage();
rfbScreen->rfbPort = atoi(argv[++i]);
if (i + 1 >= *argc) {
rfbUsage();
return FALSE;
}
rfbScreen->port = atoi(argv[++i]);
} else if (strcmp(argv[i], "-rfbwait") == 0) { /* -rfbwait ms */
if (i + 1 >= *argc) rfbUsage();
rfbScreen->rfbMaxClientWait = atoi(argv[++i]);
if (i + 1 >= *argc) {
rfbUsage();
return FALSE;
}
rfbScreen->maxClientWait = atoi(argv[++i]);
} else if (strcmp(argv[i], "-rfbauth") == 0) { /* -rfbauth passwd-file */
if (i + 1 >= *argc) rfbUsage();
rfbScreen->rfbAuthPasswdData = argv[++i];
if (i + 1 >= *argc) {
rfbUsage();
return FALSE;
}
rfbScreen->authPasswdData = argv[++i];
} else if (strcmp(argv[i], "-permitfiletransfer") == 0) { /* -permitfiletransfer */
rfbScreen->permitFileTransfer = TRUE;
} else if (strcmp(argv[i], "-rfbversion") == 0) { /* -rfbversion 3.6 */
if (i + 1 >= *argc) {
rfbUsage();
return FALSE;
}
sscanf(argv[++i],"%d.%d", &rfbScreen->protocolMajorVersion, &rfbScreen->protocolMinorVersion);
} else if (strcmp(argv[i], "-passwd") == 0) { /* -passwd password */
char **passwds = malloc(sizeof(char**)*2);
if (i + 1 >= *argc) rfbUsage();
if (i + 1 >= *argc) {
rfbUsage();
return FALSE;
}
passwds[0] = argv[++i];
passwds[1] = 0;
rfbScreen->rfbAuthPasswdData = (void*)passwds;
passwds[1] = NULL;
rfbScreen->authPasswdData = (void*)passwds;
rfbScreen->passwordCheck = rfbCheckPasswordByList;
} else if (strcmp(argv[i], "-deferupdate") == 0) { /* -desktop desktop-name */
if (i + 1 >= *argc) rfbUsage();
rfbScreen->rfbDeferUpdateTime = atoi(argv[++i]);
} else if (strcmp(argv[i], "-deferupdate") == 0) { /* -deferupdate milliseconds */
if (i + 1 >= *argc) {
rfbUsage();
return FALSE;
}
rfbScreen->deferUpdateTime = atoi(argv[++i]);
} else if (strcmp(argv[i], "-deferptrupdate") == 0) { /* -deferptrupdate milliseconds */
if (i + 1 >= *argc) {
rfbUsage();
return FALSE;
}
rfbScreen->deferPtrUpdateTime = atoi(argv[++i]);
} else if (strcmp(argv[i], "-desktop") == 0) { /* -desktop desktop-name */
if (i + 1 >= *argc) rfbUsage();
if (i + 1 >= *argc) {
rfbUsage();
return FALSE;
}
rfbScreen->desktopName = argv[++i];
} else if (strcmp(argv[i], "-alwaysshared") == 0) {
rfbScreen->rfbAlwaysShared = TRUE;
rfbScreen->alwaysShared = TRUE;
} else if (strcmp(argv[i], "-nevershared") == 0) {
rfbScreen->rfbNeverShared = TRUE;
rfbScreen->neverShared = TRUE;
} else if (strcmp(argv[i], "-dontdisconnect") == 0) {
rfbScreen->rfbDontDisconnect = TRUE;
} else if (strcmp(argv[i], "-width") == 0) {
rfbScreen->width = atoi(argv[++i]);
} else if (strcmp(argv[i], "-height") == 0) {
rfbScreen->height = atoi(argv[++i]);
rfbScreen->dontDisconnect = TRUE;
} else if (strcmp(argv[i], "-httpdir") == 0) { /* -httpdir directory-path */
if (i + 1 >= *argc) {
rfbUsage();
return FALSE;
}
rfbScreen->httpDir = argv[++i];
} else if (strcmp(argv[i], "-httpport") == 0) { /* -httpport portnum */
if (i + 1 >= *argc) {
rfbUsage();
return FALSE;
}
rfbScreen->httpPort = atoi(argv[++i]);
} else if (strcmp(argv[i], "-enablehttpproxy") == 0) {
rfbScreen->httpEnableProxyConnect = TRUE;
} else if (strcmp(argv[i], "-progressive") == 0) { /* -httpport portnum */
if (i + 1 >= *argc) {
rfbUsage();
return FALSE;
}
rfbScreen->progressiveSliceHeight = atoi(argv[++i]);
} else if (strcmp(argv[i], "-listen") == 0) { /* -listen ipaddr */
if (i + 1 >= *argc) {
rfbUsage();
return FALSE;
}
if (! rfbStringToAddr(argv[++i], &(rfbScreen->listenInterface))) {
return FALSE;
}
} else {
/* we just remove the processed arguments from the list */
if(i != i1)
rfbPurgeArguments(argc,&i,i1-i,argv);
i1++;
i++;
}
}
*argc -= i-i1;
}
rfbProtocolExtension* extension;
int handled=0;
void rfbSizeUsage()
{
fprintf(stderr, "-width sets the width of the framebuffer\n");
fprintf(stderr, "-height sets the height of the framebuffer\n");
exit(1);
for(extension=rfbGetExtensionIterator();handled==0 && extension;
extension=extension->next)
if(extension->processArgument)
handled = extension->processArgument(*argc - i, argv + i);
rfbReleaseExtensionIterator();
if(handled==0) {
i++;
i1=i;
continue;
}
i+=handled-1;
}
/* we just remove the processed arguments from the list */
rfbPurgeArguments(argc,&i1,i-i1+1,argv);
i=i1;
}
return TRUE;
}
void
rfbBool
rfbProcessSizeArguments(int* width,int* height,int* bpp,int* argc, char *argv[])
{
int i,i1;
if(!argc) return;
for (i = i1 = 1; i < *argc-1; i++) {
if(!argc) return TRUE;
for (i = i1 = 1; i < *argc-1;) {
if (strcmp(argv[i], "-bpp") == 0) {
*bpp = atoi(argv[++i]);
} else if (strcmp(argv[i], "-width") == 0) {
......@@ -121,15 +201,13 @@ rfbProcessSizeArguments(int* width,int* height,int* bpp,int* argc, char *argv[])
} else if (strcmp(argv[i], "-height") == 0) {
*height = atoi(argv[++i]);
} else {
/* we just remove the processed arguments from the list */
if(i != i1) {
memmove(argv+i1,argv+i,sizeof(char*)*(*argc-i));
*argc -= i-i1;
}
i1++;
i = i1-1;
}
i++;
i1=i;
continue;
}
rfbPurgeArguments(argc,&i1,i-i1,argv);
i=i1;
}
*argc -= i-i1;
return TRUE;
}
This diff is collapsed.
This diff is collapsed.
......@@ -19,12 +19,11 @@
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#include <stdio.h>
#include "rfb.h"
#include <rfb/rfb.h>
/*
......
......@@ -71,9 +71,8 @@ static unsigned char pc2[48] = {
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;
void rfbDesKey(unsigned char *key,
int edf)
{
register int i, j, l, m, n;
unsigned char pc1m[56], pcr[56];
......@@ -108,8 +107,7 @@ int edf;
return;
}
static void cookey(raw1)
register unsigned long *raw1;
static void cookey(register unsigned long *raw1)
{
register unsigned long *cook, *raw0;
unsigned long dough[32];
......@@ -127,12 +125,11 @@ register unsigned long *raw1;
*cook |= (*raw1 & 0x0003f000L) >> 4;
*cook++ |= (*raw1 & 0x0000003fL);
}
usekey(dough);
rfbUseKey(dough);
return;
}
void cpkey(into)
register unsigned long *into;
void rfbCPKey(register unsigned long *into)
{
register unsigned long *from, *endp;
......@@ -141,8 +138,7 @@ register unsigned long *into;
return;
}
void usekey(from)
register unsigned long *from;
void rfbUseKey(register unsigned long *from)
{
register unsigned long *to, *endp;
......@@ -151,8 +147,8 @@ register unsigned long *from;
return;
}
void des(inblock, outblock)
unsigned char *inblock, *outblock;
void rfbDes(unsigned char *inblock,
unsigned char *outblock)
{
unsigned long work[2];
......@@ -162,9 +158,8 @@ unsigned char *inblock, *outblock;
return;
}
static void scrunch(outof, into)
register unsigned char *outof;
register unsigned long *into;
static void scrunch(register unsigned char *outof,
register unsigned long *into)
{
*into = (*outof++ & 0xffL) << 24;
*into |= (*outof++ & 0xffL) << 16;
......@@ -177,9 +172,8 @@ register unsigned long *into;
return;
}
static void unscrun(outof, into)
register unsigned long *outof;
register unsigned char *into;
static void unscrun(register unsigned long *outof,
register unsigned char *into)
{
*into++ = (unsigned char)((*outof >> 24) & 0xffL);
*into++ = (unsigned char)((*outof >> 16) & 0xffL);
......@@ -336,8 +330,8 @@ static unsigned long SP8[64] = {
0x10041040L, 0x00041000L, 0x00041000L, 0x00001040L,
0x00001040L, 0x00040040L, 0x10000000L, 0x10041000L };
static void desfunc(block, keys)
register unsigned long *block, *keys;
static void desfunc(register unsigned long *block,
register unsigned long *keys)
{
register unsigned long fval, work, right, leftt;
register int round;
......
......@@ -14,9 +14,6 @@
*/
/* d3des.h -
*
*
* A portable, public domain, version of the Data Encryption Standard.
*
* Headers and defines for d3des.c
* Graven Imagery, 1992.
......@@ -28,25 +25,25 @@
#define EN0 0 /* MODE == encrypt */
#define DE1 1 /* MODE == decrypt */
extern void deskey(unsigned char *, int);
extern void rfbDesKey(unsigned char *, int);
/* hexkey[8] MODE
* Sets the internal key register according to the hexadecimal
* key contained in the 8 bytes of hexkey, according to the DES,
* for encryption or decryption according to MODE.
*/
extern void usekey(unsigned long *);
extern void rfbUseKey(unsigned long *);
/* cookedkey[32]
* Loads the internal key register with the data in cookedkey.
*/
extern void cpkey(unsigned long *);
extern void rfbCPKey(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 *);
extern void rfbDes(unsigned char *, unsigned char *);
/* from[8] to[8]
* Encrypts/Decrypts (according to the key currently loaded in the
* internal key register) one block of eight bytes at address 'from'
......
#include "rfb.h"
#include <rfb/rfb.h>
void rfbFillRect(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,Pixel col)
void rfbFillRect(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,rfbPixel col)
{
int rowstride = s->paddedWidthInBytes, bpp = s->bitsPerPixel>>3;
int i,j;
......@@ -17,7 +17,7 @@ void rfbFillRect(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,Pixel col)
#define SETPIXEL(x,y) \
memcpy(s->frameBuffer+(y)*rowstride+(x)*bpp,colour,bpp)
void rfbDrawPixel(rfbScreenInfoPtr s,int x,int y,Pixel col)
void rfbDrawPixel(rfbScreenInfoPtr s,int x,int y,rfbPixel col)
{
int rowstride = s->paddedWidthInBytes, bpp = s->bitsPerPixel>>3;
char* colour=(char*)&col;
......@@ -28,7 +28,7 @@ void rfbDrawPixel(rfbScreenInfoPtr s,int x,int y,Pixel col)
rfbMarkRectAsModified(s,x,y,x+1,y+1);
}
void rfbDrawLine(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,Pixel col)
void rfbDrawLine(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,rfbPixel col)
{
int rowstride = s->paddedWidthInBytes, bpp = s->bitsPerPixel>>3;
int i;
......
/*
*
* This is an example of how to use libvncserver.
*
* libvncserver example
* Copyright (C) 2001 Johannes E. Schindelin <Johannes.Schindelin@gmx.de>
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#ifdef WIN32
#define sleep Sleep
#else
#include <unistd.h>
#endif
#ifdef __IRIX__
#include <netdb.h>
#endif
#include "rfb.h"
#include "keysym.h"
const int maxx=640, maxy=480, bpp=4;
/* TODO: odd maxx doesn't work (vncviewer bug) */
/* This initializes a nice (?) background */
void initBuffer(unsigned char* buffer)
{
int i,j;
for(j=0;j<maxy;++j) {
for(i=0;i<maxx;++i) {
buffer[(j*maxx+i)*bpp+0]=(i+j)*128/(maxx+maxy); /* red */
buffer[(j*maxx+i)*bpp+1]=i*128/maxx; /* green */
buffer[(j*maxx+i)*bpp+2]=j*256/maxy; /* blue */
}
buffer[j*maxx*bpp+0]=0xff;
buffer[j*maxx*bpp+1]=0xff;
buffer[j*maxx*bpp+2]=0xff;
buffer[j*maxx*bpp+3]=0xff;
}
}
/* Here we create a structure so that every client has it's own pointer */
typedef struct ClientData {
Bool oldButton;
int oldx,oldy;
} ClientData;
void clientgone(rfbClientPtr cl)
{
free(cl->clientData);
}
enum rfbNewClientAction newclient(rfbClientPtr cl)
{
cl->clientData = (void*)calloc(sizeof(ClientData),1);
cl->clientGoneHook = clientgone;
return RFB_CLIENT_ACCEPT;
}
/* aux function to draw a line */
void drawline(unsigned char* buffer,int rowstride,int bpp,int x1,int y1,int x2,int y2)
{
int i,j;
i=x1-x2; j=y1-y2;
if(i==0 && j==0) {
for(i=0;i<bpp;i++)
buffer[y1*rowstride+x1*bpp+i]=0xff;
return;
}
if(i<0) i=-i;
if(j<0) j=-j;
if(i<j) {
if(y1>y2) { i=y2; y2=y1; y1=i; i=x2; x2=x1; x1=i; }
if(y2==y1) { if(y2>0) y1--; else y2++; }
for(j=y1;j<=y2;j++)
for(i=0;i<bpp;i++)
buffer[j*rowstride+(x1+(j-y1)*(x2-x1)/(y2-y1))*bpp+i]=0xff;
} else {
if(x1>x2) { i=y2; y2=y1; y1=i; i=x2; x2=x1; x1=i; }
for(i=x1;i<=x2;i++)
for(j=0;j<bpp;j++)
buffer[(y1+(i-x1)*(y2-y1)/(x2-x1))*rowstride+i*bpp+j]=0xff;
}
}
/* Here the pointer events are handled */
void doptr(int buttonMask,int x,int y,rfbClientPtr cl)
{
ClientData* cd=cl->clientData;
if(cl->screen->cursorIsDrawn)
rfbUndrawCursor(cl->screen);
if(x>=0 && y>=0 && x<maxx && y<maxy) {
if(buttonMask) {
int i,j,x1,x2,y1,y2;
if(cd->oldButton==buttonMask) { /* draw a line */
drawline(cl->screen->frameBuffer,cl->screen->paddedWidthInBytes,bpp,
x,y,cd->oldx,cd->oldy);
rfbMarkRectAsModified(cl->screen,x,y,cd->oldx,cd->oldy);
} else { /* draw a point (diameter depends on button) */
int w=cl->screen->paddedWidthInBytes;
x1=x-buttonMask; if(x1<0) x1=0;
x2=x+buttonMask; if(x2>maxx) x2=maxx;
y1=y-buttonMask; if(y1<0) y1=0;
y2=y+buttonMask; if(y2>maxy) y2=maxy;
for(i=x1*bpp;i<x2*bpp;i++)
for(j=y1;j<y2;j++)
cl->screen->frameBuffer[j*w+i]=(char)0xff;
rfbMarkRectAsModified(cl->screen,x1,y1,x2-1,y2-1);
}
/* we could get a selection like that:
rfbGotXCutText(cl->screen,"Hallo",5);
*/
} else
cd->oldButton=0;
cd->oldx=x; cd->oldy=y; cd->oldButton=buttonMask;
}
defaultPtrAddEvent(buttonMask,x,y,cl);
}
/* aux function to draw a character to x, y */
#include "radon.h"
/* Here the key events are handled */
void dokey(Bool down,KeySym key,rfbClientPtr cl)
{
if(down) {
if(key==XK_Escape)
rfbCloseClient(cl);
else if(key==XK_Page_Up) {
if(cl->screen->cursorIsDrawn)
rfbUndrawCursor(cl->screen);
initBuffer(cl->screen->frameBuffer);
rfbMarkRectAsModified(cl->screen,0,0,maxx,maxy);
} else if(key>=' ' && key<0x100) {
ClientData* cd=cl->clientData;
int x1=cd->oldx,y1=cd->oldy,x2,y2;
if(cl->screen->cursorIsDrawn)
rfbUndrawCursor(cl->screen);
cd->oldx+=rfbDrawChar(cl->screen,&radonFont,cd->oldx,cd->oldy,(char)key,0x00ffffff);
rfbFontBBox(&radonFont,(char)key,&x1,&y1,&x2,&y2);
rfbMarkRectAsModified(cl->screen,x1,y1,x2-1,y2-1);
}
}
}
/* Example for an XCursor (foreground/background only) */
int exampleXCursorWidth=9,exampleXCursorHeight=7;
char exampleXCursor[]=
" "
" xx xx "
" xx xx "
" xxx "
" xx xx "
" xx xx "
" ";
/* Example for a rich cursor (full-colour) */
void MakeRichCursor(rfbScreenInfoPtr rfbScreen)
{
int i,j,w=32,h=32;
rfbCursorPtr c = rfbScreen->cursor;
char bitmap[]=
" "
" xxxxxx "
" xxxxxxxxxxxxxxxxx "
" xxxxxxxxxxxxxxxxxxxxxx "
" xxxxx xxxxxxxx xxxxxxxx "
" xxxxxxxxxxxxxxxxxxxxxxxxxxx "
" xxxxxxxxxxxxxxxxxxxxxxxxxxxxx "
" xxxxx xxxxxxxxxxx xxxxxxx "
" xxxx xxxxxxxxx xxxxxx "
" xxxxx xxxxxxxxxxx xxxxxxx "
" xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx "
" xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx "
" xxxxxxxxxxxx xxxxxxxxxxxxxxx "
" xxxxxxxxxxxxxxxxxxxxxxxxxxxx "
" xxxxxxxxxxxxxxxxxxxxxxxxxxxx "
" xxxxxxxxxxx xxxxxxxxxxxxxx "
" xxxxxxxxxx xxxxxxxxxxxx "
" xxxxxxxxx xxxxxxxxx "
" xxxxxxxxxx xxxxxxxxx "
" xxxxxxxxxxxxxxxxxxx "
" xxxxxxxxxxxxxxxxxxx "
" xxxxxxxxxxxxxxxxxxx "
" xxxxxxxxxxxxxxxxx "
" xxxxxxxxxxxxxxx "
" xxxx xxxxxxxxxxxxx "
" xx x xxxxxxxxxxx "
" xxx xxxxxxxxxxx "
" xxxx xxxxxxxxxxx "
" xxxxxx xxxxxxxxxxxx "
" xxxxxxxxxxxxxxxxxxxxxx "
" xxxxxxxxxxxxxxxx "
" ";
c=rfbScreen->cursor = rfbMakeXCursor(w,h,bitmap,bitmap);
c->xhot = 16; c->yhot = 24;
c->richSource = malloc(w*h*bpp);
for(j=0;j<h;j++) {
for(i=0;i<w;i++) {
c->richSource[j*w*bpp+i*bpp+0]=i*0xff/w;
c->richSource[j*w*bpp+i*bpp+1]=(i+j)*0xff/(w+h);
c->richSource[j*w*bpp+i*bpp+2]=j*0xff/h;
c->richSource[j*w*bpp+i*bpp+3]=0;
}
}
}
/* Initialization */
int main(int argc,char** argv)
{
rfbScreenInfoPtr rfbScreen =
rfbGetScreen(&argc,argv,maxx,maxy,8,3,bpp);
rfbScreen->desktopName = "LibVNCServer Example";
rfbScreen->frameBuffer = (char*)malloc(maxx*maxy*bpp);
rfbScreen->rfbAlwaysShared = TRUE;
rfbScreen->ptrAddEvent = doptr;
rfbScreen->kbdAddEvent = dokey;
rfbScreen->newClientHook = newclient;
rfbScreen->httpDir = "./classes";
initBuffer(rfbScreen->frameBuffer);
rfbDrawString(rfbScreen,&radonFont,20,100,"Hello, World!",0xffffff);
/* This call creates a mask and then a cursor: */
/* rfbScreen->defaultCursor =
rfbMakeXCursor(exampleCursorWidth,exampleCursorHeight,exampleCursor,0);
*/
MakeRichCursor(rfbScreen);
/* initialize the server */
rfbInitServer(rfbScreen);
#ifndef BACKGROUND_LOOP_TEST
/* this is the blocking event loop, i.e. it never returns */
/* 40000 are the microseconds, i.e. 0.04 seconds */
rfbRunEventLoop(rfbScreen,40000,FALSE);
#elif !defined(HAVE_PTHREADS)
#error "I need pthreads for that."
#endif
/* this is the non-blocking event loop; a background thread is started */
rfbRunEventLoop(rfbScreen,-1,TRUE);
/* now we could do some cool things like rendering */
while(1) sleep(5); /* render(); */
return(0);
}
#include "rfb.h"
#include <rfb/rfb.h>
int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
int x,int y,unsigned char c,Pixel col)
int x,int y,unsigned char c,rfbPixel col)
{
int i,j,width,height;
unsigned char* data=font->data+font->metaData[c*5];
unsigned char d=*data;
int rowstride=rfbScreen->paddedWidthInBytes;
int bpp=rfbScreen->rfbServerFormat.bitsPerPixel/8;
int bpp=rfbScreen->serverFormat.bitsPerPixel/8;
char *colour=(char*)&col;
if(!rfbEndianTest)
......@@ -34,7 +34,7 @@ int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
}
void rfbDrawString(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
int x,int y,const char* string,Pixel colour)
int x,int y,const char* string,rfbPixel colour)
{
while(*string) {
x+=rfbDrawChar(rfbScreen,font,x,y,*string,colour);
......@@ -43,16 +43,17 @@ void rfbDrawString(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
}
/* TODO: these two functions need to be more efficient */
/* if col==bcol, assume transparent background */
int rfbDrawCharWithClip(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
int x,int y,unsigned char c,
int x1,int y1,int x2,int y2,
Pixel col,Pixel bcol)
rfbPixel col,rfbPixel bcol)
{
int i,j,width,height;
unsigned char* data=font->data+font->metaData[c*5];
unsigned char d;
int rowstride=rfbScreen->paddedWidthInBytes;
int bpp=rfbScreen->rfbServerFormat.bitsPerPixel/8,extra_bytes=0;
int bpp=rfbScreen->serverFormat.bitsPerPixel/8,extra_bytes=0;
char* colour=(char*)&col;
char* bcolour=(char*)&bcol;
......@@ -102,7 +103,7 @@ int rfbDrawCharWithClip(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
void rfbDrawStringWithClip(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
int x,int y,const char* string,
int x1,int y1,int x2,int y2,
Pixel colour,Pixel backColour)
rfbPixel colour,rfbPixel backColour)
{
while(*string) {
x+=rfbDrawCharWithClip(rfbScreen,font,x,y,*string,x1,y1,x2,y2,
......@@ -130,8 +131,8 @@ void rfbFontBBox(rfbFontDataPtr font,unsigned char c,int* x1,int* y1,int* x2,int
{
*x1+=font->metaData[c*5+3];
*y1+=-font->metaData[c*5+4]-font->metaData[c*5+2]+1;
*x2=*x1+font->metaData[c*5+1];
*y2=*y1+font->metaData[c*5+2];
*x2=*x1+font->metaData[c*5+1]+1;
*y2=*y1+font->metaData[c*5+2]+1;
}
#ifndef INT_MAX
......@@ -144,7 +145,7 @@ void rfbWholeFontBBox(rfbFontDataPtr font,
int i;
int* m=font->metaData;
(*x1)=(*y1)=INT_MAX; (*x2)=(*y2)=-INT_MAX+1;
(*x1)=(*y1)=INT_MAX; (*x2)=(*y2)=1-(INT_MAX);
for(i=0;i<256;i++) {
if(m[i*5+1]-m[i*5+3]>(*x2))
(*x2)=m[i*5+1]-m[i*5+3];
......@@ -155,6 +156,8 @@ void rfbWholeFontBBox(rfbFontDataPtr font,
if(-m[i*5+4]>(*y2))
(*y2)=-m[i*5+4];
}
(*x2)++;
(*y2)++;
}
rfbFontDataPtr rfbLoadConsoleFont(char *filename)
......@@ -163,14 +166,14 @@ rfbFontDataPtr rfbLoadConsoleFont(char *filename)
rfbFontDataPtr p;
int i;
if(!f) return(0);
if(!f) return NULL;
p=(rfbFontDataPtr)malloc(sizeof(rfbFontData));
p->data=(unsigned char*)malloc(4096);
if(1!=fread(p->data,4096,1,f)) {
free(p->data);
free(p);
return(0);
return NULL;
}
fclose(f);
p->metaData=(int*)malloc(256*5*sizeof(int));
......
#include "rfb.h"
#define FONTDIR "/usr/lib/kbd/consolefonts/"
#define DEFAULTFONT FONTDIR "default8x16"
char *fontlist[50]={
"8x16alt", "b.fnt", "c.fnt", "default8x16", "m.fnt", "ml.fnt", "mod_d.fnt",
"mod_s.fnt", "mr.fnt", "mu.fnt", "r.fnt", "rl.fnt", "ro.fnt", "s.fnt",
"sc.fnt", "scrawl_s.fnt", "scrawl_w.fnt", "sd.fnt", "t.fnt",
0
};
rfbScreenInfoPtr rfbScreen = 0;
rfbFontDataPtr curFont = 0;
void showFont(int index)
{
char buffer[1024];
if(!rfbScreen) return;
if(curFont)
rfbFreeFont(curFont);
strcpy(buffer,FONTDIR);
strcat(buffer,fontlist[index]);
curFont = rfbLoadConsoleFont(buffer);
rfbFillRect(rfbScreen,210,30-20,210+10*16,30-20+256*20/16,0xb77797);
if(curFont) {
int i,j;
for(j=0;j<256;j+=16)
for(i=0;i<16;i++)
rfbDrawCharWithClip(rfbScreen,curFont,210+10*i,30+j*20/16,j+i,
0,0,640,480,0xffffff,0x000000);
}
}
int main(int argc,char** argv)
{
rfbFontDataPtr font;
rfbScreenInfoPtr s=rfbGetScreen(&argc,argv,640,480,8,3,3);
int i,j;
s->frameBuffer=(char*)malloc(640*480*3);
rfbInitServer(s);
for(j=0;j<480;j++)
for(i=0;i<640;i++) {
s->frameBuffer[(j*640+i)*3+0]=j*256/480;
s->frameBuffer[(j*640+i)*3+1]=i*256/640;
s->frameBuffer[(j*640+i)*3+2]=(i+j)*256/(480+640);
}
rfbScreen = s;
font=rfbLoadConsoleFont(DEFAULTFONT);
if(!font) {
fprintf(stderr,"Couldn't find %s\n",DEFAULTFONT);
exit(1);
}
for(j=0;j<0;j++)
rfbProcessEvents(s,900000);
i = rfbSelectBox(s,font,fontlist,10,20,200,300,0xffdfdf,0x602040,2,showFont);
fprintf(stderr,"Selection: %d: %s\n",i,(i>=0)?fontlist[i]:"canceled");
rfbFreeFont(font);
return(0);
}
This diff is collapsed.
This diff is collapsed.
#cmakedefine LIBVNCSERVER_HAVE_LIBZ
#cmakedefine LIBVNCSERVER_HAVE_LIBJPEG
#define LIBVNCSERVER_PACKAGE_STRING "@LIBVNCSERVER_PACKAGE_STRING@"
#cmakedefine LIBVNCSERVER_HAVE_FCNTL_H
#cmakedefine LIBVNCSERVER_HAVE_IFADDRS_H
#cmakedefine LIBVNCSERVER_HAVE_NETINET_IN_H
#cmakedefine LIBVNCSERVER_HAVE_STDINT_H
#cmakedefine LIBVNCSERVER_HAVE_SYS_SOCKET_H
#cmakedefine LIBVNCSERVER_HAVE_SYS_TIME_H
#cmakedefine LIBVNCSERVER_HAVE_SYS_TYPES_H
#cmakedefine LIBVNCSERVER_HAVE_SYS_STAT_H
#cmakedefine LIBVNCSERVER_HAVE_UNISTD_H
#cmakedefine LIBVNCSERVER_WORDS_BIGENDIAN
#cmakedefine LIBVNCSERVER_HAVE_GETTIMEOFDAY
#define LIBVNCSERVER_ALLOW24BPP
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* minilzo.h -- mini subset of the LZO real-time data compression library
This file is part of the LZO real-time data compression library.
Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
The LZO library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
The LZO library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the LZO library; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/opensource/lzo/
*/
/*
* NOTE:
* the full LZO package can be found at
* http://www.oberhumer.com/opensource/lzo/
*/
#ifndef __MINILZO_H
#define __MINILZO_H
#define MINILZO_VERSION 0x1080
#ifdef __LZOCONF_H
# error "you cannot use both LZO and miniLZO"
#endif
#undef LZO_HAVE_CONFIG_H
#include "lzoconf.h"
#if !defined(LZO_VERSION) || (LZO_VERSION != MINILZO_VERSION)
# error "version mismatch in header files"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/***********************************************************************
//
************************************************************************/
/* Memory required for the wrkmem parameter.
* When the required size is 0, you can also pass a NULL pointer.
*/
#define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS
#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t))
#define LZO1X_MEM_DECOMPRESS (0)
/* compression */
LZO_EXTERN(int)
lzo1x_1_compress ( const lzo_byte *src, lzo_uint src_len,
lzo_byte *dst, lzo_uintp dst_len,
lzo_voidp wrkmem );
/* decompression */
LZO_EXTERN(int)
lzo1x_decompress ( const lzo_byte *src, lzo_uint src_len,
lzo_byte *dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ );
/* safe decompression with overrun testing */
LZO_EXTERN(int)
lzo1x_decompress_safe ( const lzo_byte *src, lzo_uint src_len,
lzo_byte *dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ );
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* already included */
#include <stdio.h>
#include "rfb.h"
#include "keysym.h"
void HandleKey(Bool down,KeySym key,rfbClientPtr cl)
{
if(down && (key==XK_Escape || key=='q' || key=='Q'))
rfbCloseClient(cl);
}
int main(int argc,char** argv)
{
FILE* in=stdin;
int i,j,k,width,height,paddedWidth;
unsigned char buffer[1024];
rfbScreenInfoPtr rfbScreen;
if(argc>1) {
in=fopen(argv[1],"rb");
if(!in) {
printf("Couldn't find file %s.\n",argv[1]);
exit(1);
}
}
fgets(buffer,1024,in);
if(strncmp(buffer,"P6",2)) {
printf("Not a ppm.\n");
exit(2);
}
/* skip comments */
do {
fgets(buffer,1024,in);
} while(buffer[0]=='#');
/* get width & height */
sscanf(buffer,"%d %d",&width,&height);
fprintf(stderr,"Got width %d and height %d.\n",width,height);
fgets(buffer,1024,in);
/* vncviewers have problems with widths which are no multiple of 4. */
paddedWidth = width;
if(width&3)
paddedWidth+=4-(width&3);
/* initialize data for vnc server */
rfbScreen = rfbGetScreen(&argc,argv,paddedWidth,height,8,3,4);
if(argc>1)
rfbScreen->desktopName = argv[1];
else
rfbScreen->desktopName = "Picture";
rfbScreen->rfbAlwaysShared = TRUE;
rfbScreen->kbdAddEvent = HandleKey;
/* enable http */
rfbScreen->httpDir = "./classes";
/* allocate picture and read it */
rfbScreen->frameBuffer = (char*)malloc(paddedWidth*4*height);
fread(rfbScreen->frameBuffer,width*3,height,in);
fclose(in);
/* correct the format to 4 bytes instead of 3 (and pad to paddedWidth) */
for(j=height-1;j>=0;j--) {
for(i=width-1;i>=0;i--)
for(k=2;k>=0;k--)
rfbScreen->frameBuffer[(j*paddedWidth+i)*4+k]=
rfbScreen->frameBuffer[(j*width+i)*3+k];
for(i=width*4;i<paddedWidth*4;i++)
rfbScreen->frameBuffer[j*paddedWidth*4+i]=0;
}
/* initialize server */
rfbInitServer(rfbScreen);
/* run event loop */
rfbRunEventLoop(rfbScreen,40000,FALSE);
return(0);
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
unsigned char default8x16FontData[4096+1]={
static unsigned char default8x16FontData[4096+1]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xbd,0x99,0x81,0x81,0x7e,0x00,0x00,0x00,0x00,
0x00,0x00,0x7e,0xff,0xdb,0xff,0xff,0xc3,0xe7,0xff,0xff,0x7e,0x00,0x00,0x00,0x00,
......@@ -256,6 +256,6 @@ unsigned char default8x16FontData[4096+1]={
0x00,0x00,0x00,0x00,0x7c,0x7c,0x7c,0x7c,0x7c,0x7c,0x7c,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
int default8x16FontMetaData[256*5+1]={
static int default8x16FontMetaData[256*5+1]={
0,8,16,0,0,16,8,16,0,0,32,8,16,0,0,48,8,16,0,0,64,8,16,0,0,80,8,16,0,0,96,8,16,0,0,112,8,16,0,0,128,8,16,0,0,144,8,16,0,0,160,8,16,0,0,176,8,16,0,0,192,8,16,0,0,208,8,16,0,0,224,8,16,0,0,240,8,16,0,0,256,8,16,0,0,272,8,16,0,0,288,8,16,0,0,304,8,16,0,0,320,8,16,0,0,336,8,16,0,0,352,8,16,0,0,368,8,16,0,0,384,8,16,0,0,400,8,16,0,0,416,8,16,0,0,432,8,16,0,0,448,8,16,0,0,464,8,16,0,0,480,8,16,0,0,496,8,16,0,0,512,8,16,0,0,528,8,16,0,0,544,8,16,0,0,560,8,16,0,0,576,8,16,0,0,592,8,16,0,0,608,8,16,0,0,624,8,16,0,0,640,8,16,0,0,656,8,16,0,0,672,8,16,0,0,688,8,16,0,0,704,8,16,0,0,720,8,16,0,0,736,8,16,0,0,752,8,16,0,0,768,8,16,0,0,784,8,16,0,0,800,8,16,0,0,816,8,16,0,0,832,8,16,0,0,848,8,16,0,0,864,8,16,0,0,880,8,16,0,0,896,8,16,0,0,912,8,16,0,0,928,8,16,0,0,944,8,16,0,0,960,8,16,0,0,976,8,16,0,0,992,8,16,0,0,1008,8,16,0,0,1024,8,16,0,0,1040,8,16,0,0,1056,8,16,0,0,1072,8,16,0,0,1088,8,16,0,0,1104,8,16,0,0,1120,8,16,0,0,1136,8,16,0,0,1152,8,16,0,0,1168,8,16,0,0,1184,8,16,0,0,1200,8,16,0,0,1216,8,16,0,0,1232,8,16,0,0,1248,8,16,0,0,1264,8,16,0,0,1280,8,16,0,0,1296,8,16,0,0,1312,8,16,0,0,1328,8,16,0,0,1344,8,16,0,0,1360,8,16,0,0,1376,8,16,0,0,1392,8,16,0,0,1408,8,16,0,0,1424,8,16,0,0,1440,8,16,0,0,1456,8,16,0,0,1472,8,16,0,0,1488,8,16,0,0,1504,8,16,0,0,1520,8,16,0,0,1536,8,16,0,0,1552,8,16,0,0,1568,8,16,0,0,1584,8,16,0,0,1600,8,16,0,0,1616,8,16,0,0,1632,8,16,0,0,1648,8,16,0,0,1664,8,16,0,0,1680,8,16,0,0,1696,8,16,0,0,1712,8,16,0,0,1728,8,16,0,0,1744,8,16,0,0,1760,8,16,0,0,1776,8,16,0,0,1792,8,16,0,0,1808,8,16,0,0,1824,8,16,0,0,1840,8,16,0,0,1856,8,16,0,0,1872,8,16,0,0,1888,8,16,0,0,1904,8,16,0,0,1920,8,16,0,0,1936,8,16,0,0,1952,8,16,0,0,1968,8,16,0,0,1984,8,16,0,0,2000,8,16,0,0,2016,8,16,0,0,2032,8,16,0,0,2048,8,16,0,0,2064,8,16,0,0,2080,8,16,0,0,2096,8,16,0,0,2112,8,16,0,0,2128,8,16,0,0,2144,8,16,0,0,2160,8,16,0,0,2176,8,16,0,0,2192,8,16,0,0,2208,8,16,0,0,2224,8,16,0,0,2240,8,16,0,0,2256,8,16,0,0,2272,8,16,0,0,2288,8,16,0,0,2304,8,16,0,0,2320,8,16,0,0,2336,8,16,0,0,2352,8,16,0,0,2368,8,16,0,0,2384,8,16,0,0,2400,8,16,0,0,2416,8,16,0,0,2432,8,16,0,0,2448,8,16,0,0,2464,8,16,0,0,2480,8,16,0,0,2496,8,16,0,0,2512,8,16,0,0,2528,8,16,0,0,2544,8,16,0,0,2560,8,16,0,0,2576,8,16,0,0,2592,8,16,0,0,2608,8,16,0,0,2624,8,16,0,0,2640,8,16,0,0,2656,8,16,0,0,2672,8,16,0,0,2688,8,16,0,0,2704,8,16,0,0,2720,8,16,0,0,2736,8,16,0,0,2752,8,16,0,0,2768,8,16,0,0,2784,8,16,0,0,2800,8,16,0,0,2816,8,16,0,0,2832,8,16,0,0,2848,8,16,0,0,2864,8,16,0,0,2880,8,16,0,0,2896,8,16,0,0,2912,8,16,0,0,2928,8,16,0,0,2944,8,16,0,0,2960,8,16,0,0,2976,8,16,0,0,2992,8,16,0,0,3008,8,16,0,0,3024,8,16,0,0,3040,8,16,0,0,3056,8,16,0,0,3072,8,16,0,0,3088,8,16,0,0,3104,8,16,0,0,3120,8,16,0,0,3136,8,16,0,0,3152,8,16,0,0,3168,8,16,0,0,3184,8,16,0,0,3200,8,16,0,0,3216,8,16,0,0,3232,8,16,0,0,3248,8,16,0,0,3264,8,16,0,0,3280,8,16,0,0,3296,8,16,0,0,3312,8,16,0,0,3328,8,16,0,0,3344,8,16,0,0,3360,8,16,0,0,3376,8,16,0,0,3392,8,16,0,0,3408,8,16,0,0,3424,8,16,0,0,3440,8,16,0,0,3456,8,16,0,0,3472,8,16,0,0,3488,8,16,0,0,3504,8,16,0,0,3520,8,16,0,0,3536,8,16,0,0,3552,8,16,0,0,3568,8,16,0,0,3584,8,16,0,0,3600,8,16,0,0,3616,8,16,0,0,3632,8,16,0,0,3648,8,16,0,0,3664,8,16,0,0,3680,8,16,0,0,3696,8,16,0,0,3712,8,16,0,0,3728,8,16,0,0,3744,8,16,0,0,3760,8,16,0,0,3776,8,16,0,0,3792,8,16,0,0,3808,8,16,0,0,3824,8,16,0,0,3840,8,16,0,0,3856,8,16,0,0,3872,8,16,0,0,3888,8,16,0,0,3904,8,16,0,0,3920,8,16,0,0,3936,8,16,0,0,3952,8,16,0,0,3968,8,16,0,0,3984,8,16,0,0,4000,8,16,0,0,4016,8,16,0,0,4032,8,16,0,0,4048,8,16,0,0,4064,8,16,0,0,4080,8,16,0,0,};
rfbFontData default8x16Font = { default8x16FontData, default8x16FontMetaData };
static rfbFontData default8x16Font = { default8x16FontData, default8x16FontMetaData };
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment