Commit 3bc07ec6 authored by (no author)'s avatar (no author)

moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu...

moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames kdegraphics kdemultimedia kdenetwork kdesdk kdetoys kdeutils kdevelop kdewebdev kdepim kdebase kdelibs kde-i18n arts into /trunk/KDE/

git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/KDE/kdenetwork/krfb/libvncserver@409203 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
parents
#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
This diff is collapsed.
INCLUDES = $(all_includes)
noinst_LTLIBRARIES = libvncserver.la
libvncserver_la_SOURCES = main.c rfbserver.c sraRegion.c auth.c sockets.c \
stats.c corre.c hextile.c rre.c translate.c cutpaste.c \
zlib.c tight.c httpd.c cursor.c font.c \
draw.c selbox.c d3des.c vncauth.c cargs.c
EXTRA_DIST = CHANGES COPYING README TODO
AM_CPPFLAGS = -DHAVE_PTHREADS -DALLOW24BPP
AM_CFLAGS = -Wno-unused
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
/*
* auth.c - deal with authentication.
*
* This file implements the VNC authentication protocol when setting up an RFB
* connection.
*/
/*
* OSXvnc Copyright (C) 2001 Dan McGuirk <mcguirk@incompleteness.net>.
* Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge.
* All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include "rfb.h"
static int rfbMaxPasswordWait = 120000; /* password timeout (ms) */
/*
* rfbAuthNewClient is called when we reach the point of authenticating
* a new client. If authentication isn't being used then we simply send
* rfbNoAuth. Otherwise we send rfbVncAuth plus the challenge.
*/
void
rfbAuthNewClient(cl)
rfbClientPtr cl;
{
char buf[4 + CHALLENGESIZE];
int len;
cl->state = RFB_AUTHENTICATION;
if (cl->screen->rfbAuthPasswdData && !cl->reverseConnection) {
*(CARD32 *)buf = Swap32IfLE(rfbVncAuth);
vncRandomBytes(cl->authChallenge);
memcpy(&buf[4], (char *)cl->authChallenge, CHALLENGESIZE);
len = 4 + CHALLENGESIZE;
} else {
*(CARD32 *)buf = Swap32IfLE(rfbNoAuth);
len = 4;
cl->state = RFB_INITIALISATION;
}
if (WriteExact(cl, buf, len) < 0) {
rfbLogPerror("rfbAuthNewClient: write");
rfbCloseClient(cl);
return;
}
}
/*
* rfbAuthProcessClientMessage is called when the client sends its
* authentication response.
*/
void
rfbAuthProcessClientMessage(cl)
rfbClientPtr cl;
{
int n;
CARD8 response[CHALLENGESIZE];
CARD32 authResult;
if ((n = ReadExactTimeout(cl, (char *)response, CHALLENGESIZE,
rfbMaxPasswordWait)) <= 0) {
if (n != 0)
rfbLogPerror("rfbAuthProcessClientMessage: read");
rfbCloseClient(cl);
return;
}
if(!cl->screen->passwordCheck(cl,response,CHALLENGESIZE)) {
rfbLog("rfbAuthProcessClientMessage: password check failed\n");
authResult = Swap32IfLE(rfbVncAuthFailed);
if (WriteExact(cl, (char *)&authResult, 4) < 0) {
rfbLogPerror("rfbAuthProcessClientMessage: write");
}
rfbCloseClient(cl);
return;
}
authResult = Swap32IfLE(rfbVncAuthOK);
if (WriteExact(cl, (char *)&authResult, 4) < 0) {
rfbLogPerror("rfbAuthProcessClientMessage: write");
rfbCloseClient(cl);
return;
}
cl->state = RFB_INITIALISATION;
}
#!/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 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.
* All Rights Reserved.
*
* see GPL (latest version) for full details
*/
#include "rfb.h"
void
rfbUsage(void)
{
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, "-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, "-desktop name VNC desktop name (default \"LibVNCServer\")\n");
fprintf(stderr, "-alwaysshared always treat new clients as shared\n");
fprintf(stderr, "-nevershared never treat new clients as shared\n");
fprintf(stderr, "-dontdisconnect don't disconnect existing clients when a "
"new non-shared\n"
" connection comes in (refuse new connection "
"instead)\n");
exit(1);
}
/* purges COUNT arguments from ARGV at POSITION and decrements ARGC.
POSITION points to the first non purged argument afterwards. */
void rfbPurgeArguments(int* argc,int* position,int count,char *argv[])
{
int amount=(*argc)-(*position)-count;
if(amount)
memmove(argv+(*position),argv+(*position)+count,sizeof(char*)*amount);
(*argc)-=count;
(*position)--;
}
void
rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[])
{
int i,i1;
if(!argc) return;
for (i = i1 = 1; i < *argc; i++) {
if (strcmp(argv[i], "-help") == 0) {
rfbUsage();
exit(1);
} else if (strcmp(argv[i], "-rfbport") == 0) { /* -rfbport port */
if (i + 1 >= *argc) rfbUsage();
rfbScreen->rfbPort = atoi(argv[++i]);
} else if (strcmp(argv[i], "-rfbwait") == 0) { /* -rfbwait ms */
if (i + 1 >= *argc) rfbUsage();
rfbScreen->rfbMaxClientWait = atoi(argv[++i]);
} else if (strcmp(argv[i], "-rfbauth") == 0) { /* -rfbauth passwd-file */
if (i + 1 >= *argc) rfbUsage();
rfbScreen->rfbAuthPasswdData = argv[++i];
} else if (strcmp(argv[i], "-passwd") == 0) { /* -passwd password */
char **passwds = malloc(sizeof(char**)*2);
if (i + 1 >= *argc) rfbUsage();
passwds[0] = argv[++i];
passwds[1] = 0;
rfbScreen->rfbAuthPasswdData = (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], "-desktop") == 0) { /* -desktop desktop-name */
if (i + 1 >= *argc) rfbUsage();
rfbScreen->desktopName = argv[++i];
} else if (strcmp(argv[i], "-alwaysshared") == 0) {
rfbScreen->rfbAlwaysShared = TRUE;
} else if (strcmp(argv[i], "-nevershared") == 0) {
rfbScreen->rfbNeverShared = 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]);
} else {
/* we just remove the processed arguments from the list */
if(i != i1)
rfbPurgeArguments(argc,&i,i1-i,argv);
i1++;
i++;
}
}
*argc -= i-i1;
}
void rfbSizeUsage()
{
fprintf(stderr, "-width sets the width of the framebuffer\n");
fprintf(stderr, "-height sets the height of the framebuffer\n");
exit(1);
}
void
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 (strcmp(argv[i], "-bpp") == 0) {
*bpp = atoi(argv[++i]);
} else if (strcmp(argv[i], "-width") == 0) {
*width = atoi(argv[++i]);
} else if (strcmp(argv[i], "-height") == 0) {
*height = atoi(argv[++i]);
} else {
/* 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;
}
}
*argc -= i-i1;
}
This diff is collapsed.
This diff is collapsed.
/*
* cutpaste.c - routines to deal with cut & paste buffers / selection.
*/
/*
* OSXvnc Copyright (C) 2001 Dan McGuirk <mcguirk@incompleteness.net>.
* Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge.
* All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#include <stdio.h>
#include "rfb.h"
/*
* rfbSetXCutText sets the cut buffer to be the given string. We also clear
* the primary selection. Ideally we'd like to set it to the same thing, but I
* can't work out how to do that without some kind of helper X client.
*/
void rfbGotXCutText(rfbScreenInfoPtr rfbScreen, char *str, int len)
{
rfbSendServerCutText(rfbScreen, str, len);
}
This diff is collapsed.
#ifndef D3DES_H
#define D3DES_H
/*
* This is D3DES (V5.09) by Richard Outerbridge with the double and
* triple-length support removed for use in VNC.
*
* These changes are:
* Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/* d3des.h -
*
* Headers and defines for d3des.c
* Graven Imagery, 1992.
*
* Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge
* (GEnie : OUTER; CIS : [71755,204])
*/
#define EN0 0 /* MODE == encrypt */
#define DE1 1 /* MODE == decrypt */
extern void 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
********************************************************************/
#endif
This diff is collapsed.
#include "rfb.h"
void rfbFillRect(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,Pixel col)
{
int rowstride = s->paddedWidthInBytes, bpp = s->bitsPerPixel>>3;
int i,j;
char* colour=(char*)&col;
if(!rfbEndianTest)
colour += 4-bpp;
for(j=y1;j<y2;j++)
for(i=x1;i<x2;i++)
memcpy(s->frameBuffer+j*rowstride+i*bpp,colour,bpp);
rfbMarkRectAsModified(s,x1,y1,x2,y2);
}
#define SETPIXEL(x,y) \
memcpy(s->frameBuffer+(y)*rowstride+(x)*bpp,colour,bpp)
void rfbDrawPixel(rfbScreenInfoPtr s,int x,int y,Pixel col)
{
int rowstride = s->paddedWidthInBytes, bpp = s->bitsPerPixel>>3;
char* colour=(char*)&col;
if(!rfbEndianTest)
colour += 4-bpp;
SETPIXEL(x,y);
rfbMarkRectAsModified(s,x,y,x+1,y+1);
}
void rfbDrawLine(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,Pixel col)
{
int rowstride = s->paddedWidthInBytes, bpp = s->bitsPerPixel>>3;
int i;
char* colour=(char*)&col;
if(!rfbEndianTest)
colour += 4-bpp;
#define SWAPPOINTS { i=x1; x1=x2; x2=i; i=y1; y1=y2; y2=i; }
if(abs(x1-x2)<abs(y1-y2)) {
if(y1>y2)
SWAPPOINTS
for(i=y1;i<=y2;i++)
SETPIXEL(x1+(i-y1)*(x2-x1)/(y2-y1),i);
/* TODO: Maybe make this more intelligently? */
if(x2<x1) { i=x1; x1=x2; x2=i; }
rfbMarkRectAsModified(s,x1,y1,x2+1,y2+1);
} else {
if(x1>x2)
SWAPPOINTS
else if(x1==x2) {
rfbDrawPixel(s,x1,y1,col);
return;
}
for(i=x1;i<=x2;i++)
SETPIXEL(i,y1+(i-x1)*(y2-y1)/(x2-x1));
if(y2<y1) { i=y1; y1=y2; y2=i; }
rfbMarkRectAsModified(s,x1,y1,x2+1,y2+1);
}
}
/*
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* 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"
int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
int x,int y,unsigned char c,Pixel 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;
char *colour=(char*)&col;
if(!rfbEndianTest)
colour += 4-bpp;
width=font->metaData[c*5+1];
height=font->metaData[c*5+2];
x+=font->metaData[c*5+3];
y+=-font->metaData[c*5+4]-height+1;
for(j=0;j<height;j++) {
for(i=0;i<width;i++) {
if((i&7)==0) {
d=*data;
data++;
}
if(d&0x80)
memcpy(rfbScreen->frameBuffer+(y+j)*rowstride+(x+i)*bpp,colour,bpp);
d<<=1;
}
/* if((i&7)!=0) data++; */
}
return(width);
}
void rfbDrawString(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
int x,int y,const char* string,Pixel colour)
{
while(*string) {
x+=rfbDrawChar(rfbScreen,font,x,y,*string,colour);
string++;
}
}
/* TODO: these two functions need to be more efficient */
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)
{
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;
char* colour=(char*)&col;
char* bcolour=(char*)&bcol;
if(!rfbEndianTest) {
colour+=4-bpp;
bcolour+=4-bpp;
}
width=font->metaData[c*5+1];
height=font->metaData[c*5+2];
x+=font->metaData[c*5+3];
y+=-font->metaData[c*5+4]-height+1;
/* after clipping, x2 will be count of bytes between rows,
* x1 start of i, y1 start of j, width and height will be adjusted. */
if(y1>y) { y1-=y; data+=(width+7)/8; height-=y1; y+=y1; } else y1=0;
if(x1>x) { x1-=x; data+=x1; width-=x1; x+=x1; extra_bytes+=x1/8; } else x1=0;
if(y2<y+height) height-=y+height-y2;
if(x2<x+width) { extra_bytes+=(x1+width)/8-(x+width-x2+7)/8; width-=x+width-x2; }
d=*data;
for(j=y1;j<height;j++) {
if((x1&7)!=0)
d=data[-1]; /* TODO: check if in this case extra_bytes is correct! */
for(i=x1;i<width;i++) {
if((i&7)==0) {
d=*data;
data++;
}
/* if(x+i>=x1 && x+i<x2 && y+j>=y1 && y+j<y2) */ {
if(d&0x80) {
memcpy(rfbScreen->frameBuffer+(y+j)*rowstride+(x+i)*bpp,
colour,bpp);
} else if(bcol!=col) {
memcpy(rfbScreen->frameBuffer+(y+j)*rowstride+(x+i)*bpp,
bcolour,bpp);
}
}
d<<=1;
}
/* if((i&7)==0) data++; */
data += extra_bytes;
}
return(width);
}
void rfbDrawStringWithClip(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
int x,int y,const char* string,
int x1,int y1,int x2,int y2,
Pixel colour,Pixel backColour)
{
while(*string) {
x+=rfbDrawCharWithClip(rfbScreen,font,x,y,*string,x1,y1,x2,y2,
colour,backColour);
string++;
}
}
int rfbWidthOfString(rfbFontDataPtr font,const char* string)
{
int i=0;
while(*string) {
i+=font->metaData[*string*5+1];
string++;
}
return(i);
}
int rfbWidthOfChar(rfbFontDataPtr font,unsigned char c)
{
return(font->metaData[c*5+1]+font->metaData[c*5+3]);
}
void rfbFontBBox(rfbFontDataPtr font,unsigned char c,int* x1,int* y1,int* x2,int* y2)
{
*x1+=font->metaData[c*5+3];
*y1+=-font->metaData[c*5+4]-font->metaData[c*5+2]+1;
*x2=*x1+font->metaData[c*5+1];
*y2=*y1+font->metaData[c*5+2];
}
#ifndef INT_MAX
#define INT_MAX 0x7fffffff
#endif
void rfbWholeFontBBox(rfbFontDataPtr font,
int *x1, int *y1, int *x2, int *y2)
{
int i;
int* m=font->metaData;
(*x1)=(*y1)=INT_MAX; (*x2)=(*y2)=-INT_MAX+1;
for(i=0;i<256;i++) {
if(m[i*5+1]-m[i*5+3]>(*x2))
(*x2)=m[i*5+1]-m[i*5+3];
if(-m[i*5+2]+m[i*5+4]<(*y1))
(*y1)=-m[i*5+2]+m[i*5+4];
if(m[i*5+3]<(*x1))
(*x1)=m[i*5+3];
if(-m[i*5+4]>(*y2))
(*y2)=-m[i*5+4];
}
}
rfbFontDataPtr rfbLoadConsoleFont(char *filename)
{
FILE *f=fopen(filename,"rb");
rfbFontDataPtr p;
int i;
if(!f) return(0);
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);
}
fclose(f);
p->metaData=(int*)malloc(256*5*sizeof(int));
for(i=0;i<256;i++) {
p->metaData[i*5+0]=i*16; /* offset */
p->metaData[i*5+1]=8; /* width */
p->metaData[i*5+2]=16; /* height */
p->metaData[i*5+3]=0; /* xhot */
p->metaData[i*5+4]=0; /* yhot */
}
return(p);
}
void rfbFreeFont(rfbFontDataPtr f)
{
free(f->data);
free(f->metaData);
free(f);
}
#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]:"cancelled");
rfbFreeFont(font);
return(0);
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#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);
}
#ifndef ALLOW24BPP
#error "I need the ALLOW24BPP flag to work"
#endif
#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 j,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 your vncviewer doesn't have problems with a width
which is not a multiple of 4, you can comment this. */
if(width&3)
paddedWidth+=4-(width&3);
/* initialize data for vnc server */
rfbScreen = rfbGetScreen(&argc,argv,paddedWidth,height,8,3,3);
if(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*3*height);
fread(rfbScreen->frameBuffer,width*3,height,in);
fclose(in);
/* pad to paddedWidth */
if(width != paddedWidth) {
int padCount = 3*(paddedWidth - width);
for(j=height-1;j>=0;j--) {
memmove(rfbScreen->frameBuffer+3*paddedWidth*j,
rfbScreen->frameBuffer+3*width*j,
3*width);
memset(rfbScreen->frameBuffer+3*paddedWidth*(j+1)-padCount,
0,padCount);
}
}
/* initialize server */
rfbInitServer(rfbScreen);
/* run event loop */
rfbRunEventLoop(rfbScreen,40000,FALSE);
return(0);
}
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.
/*
* OSXvnc Copyright (C) 2001 Dan McGuirk <mcguirk@incompleteness.net>.
* Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge.
* All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#include <stdio.h>
#include "rfb.h"
void usage(void)
{
printf("\nusage: storepasswd <password> <filename>\n\n");
printf("Stores a password in encrypted format.\n");
printf("The resulting file can be used with the -rfbauth argument to OSXvnc.\n\n");
exit(1);
}
int main(int argc, char *argv[])
{
if (argc != 3)
usage();
if (vncEncryptAndStorePasswd(argv[1], argv[2]) != 0) {
printf("storing password failed.\n");
return 1;
} else {
printf("storing password succeeded.\n");
return 0;
}
}
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