WIN32 compatibility, removed kbdptr.c

pull/1/head
dscho 23 years ago
parent 018e90db59
commit 446f334cc1

@ -291,6 +291,80 @@ There is the possibility to set a password, which is also negotiated by the
RFB protocol, but IT IS NOT SECURE. Anybody sniffing your net can get the RFB protocol, but IT IS NOT SECURE. Anybody sniffing your net can get the
password. You really should tunnel through SSH. password. You really should tunnel through SSH.
Windows or: why do you do that to me?
--------------------------------------------
If you love products from Redmod, you better skip this paragraph.
I am always amazed how people react whenever Microsoft(tm) puts in some
features into their products which were around for a long time. Especially
reporters seem to not know dick about what they are reporting about! But
what is everytime annoying again, is that they don't do it right. Every
concept has it's new name (remember what enumerators used to be until
Mickeysoft(tm) claimed that enumerators are what we thought were iterators.
Yeah right, enumerators are also containers. They are not separate. Muddy.)
There are three packages you want to get hold of: zlib, jpeg and pthreads.
The latter is not strictly necessary, but when you put something like this
into your source:
#define MUTEX(s)
struct {
int something;
MUTEX(latex);
}
Microsoft's C++ compiler doesn't do it. It complains that this is an error.
You can find the packages at
http://www.gimp.org/win32/extralibs-dev-20001007.zip
Thanks go to all the GIMP team!
Why I don't feel bad about GPL
------------------------------
At the beginning of this projects I would have liked to make it a BSD
license. However, it is based on plenty of GPL'ed code, so it has to be
a GPL. I hear BeeGee complaining: "but that's invasive, every derivative
work, even just linking, makes my software GPL!"
Yeah. That's right. It is because there are nasty jarheads out there who
would take anybody's work and claim it their own, selling it for much too
much money, stealing freedom and innovation from others, saying they were
the maintainers of innovation, lying, making money with that.
The people at AT&T worked really well to produce something as clean and lean
as VNC. The managers decided that for their fame, they would release the
program for free. But not only that! They realized that by releasing also
the code for free, VNC would become an evolving little child, conquering
new worlds, making it's parents very proud. As well they can be! To protect
this innovation, they decided to make it GPL, not BSD. The principal
difference is: You can make closed source programs deriving from BSD, not
from GPL. You have to give proper credit with both.
Now, why not BSD? Well, imagine your child being some famous actor. Along
comes a manager who exploits your child exclusively, that is: nobody else
can profit from the child, it itself included. Got it?
What reason do you have now to use this library commercially?
Several: You don't have to give away your product. Then you have effectively
circumvented the GPL, because you have the benefits of other's work and you
don't give back anything and you will be in hell for that. In fact, this
library, as my other projects, is a payback for all the free software I can
use (and sometimes, make better). For example, just now, I am using XEmacs
on top X11, all running under Linux.
Better: Use a concept like MySQL. This is free software, however, they make
money with it. If you want something implemented, you have the choice:
Ask them to do it (and pay a fair price), or do it yourself, normally giving
back your enhancements to the free world of computing.
Learn from it: If you like the style this is written, learn how to imitate
it. If you don't like the style, learn how to avoid those things you don't
like. I learnt so much, just from looking at code like Linux, XEmacs,
LilyPond, STL, etc.
License License
------- -------

@ -181,14 +181,14 @@ static void unscrun(outof, into)
register unsigned long *outof; register unsigned long *outof;
register unsigned char *into; register unsigned char *into;
{ {
*into++ = (*outof >> 24) & 0xffL; *into++ = (unsigned char)((*outof >> 24) & 0xffL);
*into++ = (*outof >> 16) & 0xffL; *into++ = (unsigned char)((*outof >> 16) & 0xffL);
*into++ = (*outof >> 8) & 0xffL; *into++ = (unsigned char)((*outof >> 8) & 0xffL);
*into++ = *outof++ & 0xffL; *into++ = (unsigned char)( *outof++ & 0xffL);
*into++ = (*outof >> 24) & 0xffL; *into++ = (unsigned char)((*outof >> 24) & 0xffL);
*into++ = (*outof >> 16) & 0xffL; *into++ = (unsigned char)((*outof >> 16) & 0xffL);
*into++ = (*outof >> 8) & 0xffL; *into++ = (unsigned char)((*outof >> 8) & 0xffL);
*into = *outof & 0xffL; *into = (unsigned char)( *outof & 0xffL);
return; return;
} }

@ -21,11 +21,16 @@
* USA. * USA.
*/ */
#ifdef WIN32
#define sleep Sleep
#else
#include <unistd.h> #include <unistd.h>
#endif
#ifdef __IRIX__ #ifdef __IRIX__
#include <netdb.h> #include <netdb.h>
#endif #endif
#define XK_MISCELLANY
#include "rfb.h" #include "rfb.h"
#include "keysym.h" #include "keysym.h"
@ -121,7 +126,7 @@ void doptr(int buttonMask,int x,int y,rfbClientPtr cl)
for(i=x1*bpp;i<x2*bpp;i++) for(i=x1*bpp;i<x2*bpp;i++)
for(j=y1;j<y2;j++) for(j=y1;j<y2;j++)
cl->screen->frameBuffer[j*w+i]=0xff; cl->screen->frameBuffer[j*w+i]=(char)0xff;
rfbMarkRectAsModified(cl->screen,x1,y1,x2-1,y2-1); rfbMarkRectAsModified(cl->screen,x1,y1,x2-1,y2-1);
} }
@ -157,8 +162,8 @@ void dokey(Bool down,KeySym key,rfbClientPtr cl)
int x1=cd->oldx,y1=cd->oldy,x2,y2; int x1=cd->oldx,y1=cd->oldy,x2,y2;
if(cl->screen->cursorIsDrawn) if(cl->screen->cursorIsDrawn)
rfbUndrawCursor(cl->screen); rfbUndrawCursor(cl->screen);
cd->oldx+=rfbDrawChar(cl->screen,&radonFont,cd->oldx,cd->oldy,key,0xffffff); cd->oldx+=rfbDrawChar(cl->screen,&radonFont,cd->oldx,cd->oldy,(char)key,0x00ffffff);
rfbFontBBox(&radonFont,key,&x1,&y1,&x2,&y2); rfbFontBBox(&radonFont,(char)key,&x1,&y1,&x2,&y2);
rfbMarkRectAsModified(cl->screen,x1,y1,x2-1,y2-1); rfbMarkRectAsModified(cl->screen,x1,y1,x2-1,y2-1);
} }
} }

@ -0,0 +1,80 @@
# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=example - Win32 Debug
!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "example - 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)" == "example - 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 0x407 /d "NDEBUG"
# ADD RSC /l 0x407 /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)" == "example - 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 /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x407 /d "_DEBUG"
# ADD RSC /l 0x407 /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 wsock32.lib libvncserver.lib libjpeg.a libz.a /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "example - Win32 Release"
# Name "example - Win32 Debug"
# Begin Group "Sources"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\example.c
# End Source File
# End Group
# End Target
# End Project

@ -23,16 +23,21 @@
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#ifdef WIN32
#include <winsock.h>
#define close closesocket
#else
#include <sys/time.h> #include <sys/time.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <netdb.h> #include <netdb.h>
#include <fcntl.h>
#include <errno.h>
#include <pwd.h> #include <pwd.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <unistd.h> #include <unistd.h>
#endif
#include <fcntl.h>
#include <errno.h>
#include "rfb.h" #include "rfb.h"
@ -120,6 +125,9 @@ httpCheckFds(rfbScreenInfoPtr rfbScreen)
return; return;
} }
if (nfds < 0) { if (nfds < 0) {
#ifdef WIN32
errno = WSAGetLastError();
#endif
rfbLogPerror("httpCheckFds: select"); rfbLogPerror("httpCheckFds: select");
return; return;
} }
@ -170,12 +178,14 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
int addrlen = sizeof(addr); int addrlen = sizeof(addr);
char fullFname[256]; char fullFname[256];
char *fname; char *fname;
int maxFnameLen; unsigned int maxFnameLen;
int fd; FILE* fd;
Bool gotGet = FALSE; Bool gotGet = FALSE;
Bool performSubstitutions = FALSE; Bool performSubstitutions = FALSE;
char str[256]; char str[256];
#ifndef WIN32
struct passwd *user = getpwuid(getuid());; struct passwd *user = getpwuid(getuid());;
#endif
cl.sock=rfbScreen->httpSock; cl.sock=rfbScreen->httpSock;
@ -263,7 +273,7 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
/* Open the file */ /* Open the file */
if ((fd = open(fullFname, O_RDONLY)) < 0) { if ((fd = fopen(fullFname, O_RDONLY)) < 0) {
rfbLogPerror("httpProcessInput: open"); rfbLogPerror("httpProcessInput: open");
WriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR)); WriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR));
httpCloseSock(rfbScreen); httpCloseSock(rfbScreen);
@ -273,10 +283,10 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
WriteExact(&cl, OK_STR, strlen(OK_STR)); WriteExact(&cl, OK_STR, strlen(OK_STR));
while (1) { while (1) {
int n = read(fd, buf, BUF_SIZE-1); int n = fread(buf, BUF_SIZE-1, 1, fd);
if (n < 0) { if (n < 0) {
rfbLogPerror("httpProcessInput: read"); rfbLogPerror("httpProcessInput: read");
close(fd); fclose(fd);
httpCloseSock(rfbScreen); httpCloseSock(rfbScreen);
return; return;
} }
@ -335,20 +345,19 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
WriteExact(&cl, str, strlen(str)); WriteExact(&cl, str, strlen(str));
} else if (compareAndSkip(&ptr, "$USER")) { } else if (compareAndSkip(&ptr, "$USER")) {
#ifndef WIN32
if (user) { if (user) {
WriteExact(&cl, user->pw_name, WriteExact(&cl, user->pw_name,
strlen(user->pw_name)); strlen(user->pw_name));
} else { } else
#endif
WriteExact(&cl, "?", 1); WriteExact(&cl, "?", 1);
}
} else { } else {
if (!compareAndSkip(&ptr, "$$")) if (!compareAndSkip(&ptr, "$$"))
ptr++; ptr++;
if (WriteExact(&cl, "$", 1) < 0) { if (WriteExact(&cl, "$", 1) < 0) {
close(fd); fclose(fd);
httpCloseSock(rfbScreen); httpCloseSock(rfbScreen);
return; return;
} }
@ -366,7 +375,7 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
} }
} }
close(fd); fclose(fd);
httpCloseSock(rfbScreen); httpCloseSock(rfbScreen);
} }

@ -1,31 +0,0 @@
/*
* kbdptr.c - deal with keyboard and pointer device over TCP & UDP.
*
*
*/
/*
* 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 <X11/keysym.h>
#include "rfb.h"

@ -0,0 +1,188 @@
# Microsoft Developer Studio Project File - Name="libvncserver" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** NICHT BEARBEITEN **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=libvncserver - Win32 Debug
!MESSAGE "libvncserver - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "libvncserver - 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)" == "libvncserver - 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 0x407 /d "NDEBUG"
# ADD RSC /l 0x407 /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)" == "libvncserver - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "libvncserver___Win32_Debug"
# PROP BASE Intermediate_Dir "libvncserver___Win32_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "libvncserver___Win32_Debug"
# PROP Intermediate_Dir "libvncserver___Win32_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 0x407 /d "_DEBUG"
# ADD RSC /l 0x407 /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 "libvncserver - Win32 Release"
# Name "libvncserver - Win32 Debug"
# Begin Group "Sources"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Group "auth"
# Begin Source File
SOURCE=.\auth.c
# End Source File
# Begin Source File
SOURCE=.\d3des.c
# End Source File
# Begin Source File
SOURCE=.\storepasswd.c
# End Source File
# Begin Source File
SOURCE=.\vncauth.c
# End Source File
# End Group
# Begin Source File
SOURCE=.\corre.c
# End Source File
# Begin Source File
SOURCE=.\cursor.c
# End Source File
# Begin Source File
SOURCE=.\cutpaste.c
# End Source File
# Begin Source File
SOURCE=.\font.c
# End Source File
# Begin Source File
SOURCE=.\hextile.c
# End Source File
# Begin Source File
SOURCE=.\httpd.c
# End Source File
# Begin Source File
SOURCE=.\main.c
# End Source File
# Begin Source File
SOURCE=.\rfbserver.c
# End Source File
# Begin Source File
SOURCE=.\rre.c
# End Source File
# Begin Source File
SOURCE=.\sockets.c
# End Source File
# Begin Source File
SOURCE=.\sraRegion.c
# End Source File
# Begin Source File
SOURCE=.\stats.c
# End Source File
# Begin Source File
SOURCE=.\tight.c
# End Source File
# Begin Source File
SOURCE=.\translate.c
# End Source File
# Begin Source File
SOURCE=.\zlib.c
# End Source File
# End Group
# Begin Group "Headers"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Group "auth"
# Begin Source File
SOURCE=.\d3des.h
# End Source File
# End Group
# Begin Source File
SOURCE=.\keysym.h
# End Source File
# Begin Source File
SOURCE=.\radon.h
# End Source File
# Begin Source File
SOURCE=.\region.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=.\sraRegion.h
# End Source File
# End Group
# End Target
# End Project

@ -0,0 +1,59 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN!
###############################################################################
Project: "example"=.\example.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name libvncserver
End Project Dependency
}}}
###############################################################################
Project: "libvncserver"=.\libvncserver.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "rdp2vnc"=..\rdp2vnc\rdp2vnc.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name libvncserver
End Project Dependency
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

@ -21,9 +21,11 @@
#endif #endif
#include <sys/types.h> #include <sys/types.h>
#ifndef WIN32
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <unistd.h> #include <unistd.h>
#endif
#include <signal.h> #include <signal.h>
#include <time.h> #include <time.h>
@ -354,11 +356,22 @@ void defaultSetXCutText(char* text, int len, rfbClientPtr cl)
/* TODO: add a nice VNC or RFB cursor */ /* TODO: add a nice VNC or RFB cursor */
#ifdef WIN32
static rfbCursor myCursor =
{
"\000\102\044\030\044\102\000",
"\347\347\176\074\176\347\347",
8, 7, 3, 3,
0, 0, 0,
0xffff, 0xffff, 0xffff,
0
};
#else
static rfbCursor myCursor = static rfbCursor myCursor =
{ {
width: 8, height: 7, xhot: 3, yhot: 3,
source: "\000\102\044\030\044\102\000", source: "\000\102\044\030\044\102\000",
mask: "\347\347\176\074\176\347\347", mask: "\347\347\176\074\176\347\347",
width: 8, height: 7, xhot: 3, yhot: 3,
/* /*
width: 8, height: 7, xhot: 0, yhot: 0, width: 8, height: 7, xhot: 0, yhot: 0,
source: "\000\074\176\146\176\074\000", source: "\000\074\176\146\176\074\000",
@ -368,6 +381,7 @@ static rfbCursor myCursor =
backRed: 0xffff, backGreen: 0xffff, backBlue: 0xffff, backRed: 0xffff, backGreen: 0xffff, backBlue: 0xffff,
richSource: 0 richSource: 0
}; };
#endif
rfbCursorPtr defaultGetCursorPtr(rfbClientPtr cl) rfbCursorPtr defaultGetCursorPtr(rfbClientPtr cl)
{ {
@ -422,7 +436,15 @@ rfbScreenInfoPtr rfbGetScreen(int argc,char** argv,
rfbScreen->width = width; rfbScreen->width = width;
rfbScreen->height = height; rfbScreen->height = height;
rfbScreen->bitsPerPixel = rfbScreen->depth = 8*bytesPerPixel; rfbScreen->bitsPerPixel = rfbScreen->depth = 8*bytesPerPixel;
#ifdef WIN32
{
DWORD dummy=255;
GetComputerName(rfbScreen->rfbThisHost,&dummy);
}
#else
gethostname(rfbScreen->rfbThisHost, 255); gethostname(rfbScreen->rfbThisHost, 255);
#endif
rfbScreen->paddedWidthInBytes = width*bytesPerPixel; rfbScreen->paddedWidthInBytes = width*bytesPerPixel;
/* format */ /* format */
@ -498,6 +520,10 @@ void rfbScreenCleanup(rfbScreenInfoPtr rfbScreen)
void rfbInitServer(rfbScreenInfoPtr rfbScreen) void rfbInitServer(rfbScreenInfoPtr rfbScreen)
{ {
#ifdef WIN32
WSADATA trash;
int i=WSAStartup(MAKEWORD(2,2),&trash);
#endif
rfbInitSockets(rfbScreen); rfbInitSockets(rfbScreen);
httpInitSockets(rfbScreen); httpInitSockets(rfbScreen);
} }
@ -506,7 +532,7 @@ void
rfbProcessEvents(rfbScreenInfoPtr rfbScreen,long usec) rfbProcessEvents(rfbScreenInfoPtr rfbScreen,long usec)
{ {
rfbClientIteratorPtr i; rfbClientIteratorPtr i;
rfbClientPtr cl; rfbClientPtr cl,clPrev;
rfbCheckFds(rfbScreen,usec); rfbCheckFds(rfbScreen,usec);
httpCheckFds(rfbScreen); httpCheckFds(rfbScreen);
@ -515,11 +541,14 @@ rfbProcessEvents(rfbScreenInfoPtr rfbScreen,long usec)
#endif #endif
i = rfbGetClientIterator(rfbScreen); i = rfbGetClientIterator(rfbScreen);
while((cl=rfbClientIteratorNext(i))) { cl=rfbClientIteratorNext(i);
while(cl) {
if(cl->sock>=0 && FB_UPDATE_PENDING(cl)) if(cl->sock>=0 && FB_UPDATE_PENDING(cl))
rfbSendFramebufferUpdate(cl,cl->modifiedRegion); rfbSendFramebufferUpdate(cl,cl->modifiedRegion);
if(cl->sock==-1) clPrev=cl;
rfbClientConnectionGone(cl); cl=rfbClientIteratorNext(i);
if(clPrev->sock==-1)
rfbClientConnectionGone(clPrev);
} }
rfbReleaseClientIterator(i); rfbReleaseClientIterator(i);
} }

63
rfb.h

@ -46,22 +46,18 @@ typedef CARD32 KeySym;
#define xrealloc realloc #define xrealloc realloc
#define xfree free #define xfree free
int max(int,int);
#include <zlib.h> #include <zlib.h>
#include <rfbproto.h> #include "rfbproto.h"
#ifdef __linux__ #ifdef __linux__
#include <endian.h> #include <endian.h>
#else #elif defined(__APPLE__) || defined(__FreeBSD__)
#if defined(__APPLE__) || defined(__FreeBSD__)
#include <sys/types.h> #include <sys/types.h>
#include <machine/endian.h> #include <machine/endian.h>
#define _BYTE_ORDER BYTE_ORDER #define _BYTE_ORDER BYTE_ORDER
#define _LITTLE_ENDIAN LITTLE_ENDIAN #define _LITTLE_ENDIAN LITTLE_ENDIAN
#else #elif sparc
#ifdef sparc
#define _LITTLE_ENDIAN 1234 #define _LITTLE_ENDIAN 1234
#define _BYTE_ORDER _LITTLE_ENDIAN #define _BYTE_ORDER _LITTLE_ENDIAN
#undef Bool #undef Bool
@ -69,11 +65,14 @@ int max(int,int);
#include <sys/types.h> #include <sys/types.h>
/* typedef unsigned int pthread_t; */ /* typedef unsigned int pthread_t; */
/* SUN cc seems to have problems with inclusion of sys/types! */ /* SUN cc seems to have problems with inclusion of sys/types! */
#elif defined(WIN32)
#define _LITTLE_ENDIAN 1234
#define _BYTE_ORDER _LITTLE_ENDIAN
#undef Bool
#define Bool int
#else #else
#include <sys/endian.h> #include <sys/endian.h>
#endif #endif
#endif
#endif
#ifndef _BYTE_ORDER #ifndef _BYTE_ORDER
#define _BYTE_ORDER __BYTE_ORDER #define _BYTE_ORDER __BYTE_ORDER
@ -83,11 +82,20 @@ int max(int,int);
#define _LITTLE_ENDIAN __LITTLE_ENDIAN #define _LITTLE_ENDIAN __LITTLE_ENDIAN
#endif #endif
#ifdef WIN32
#include <winsock.h>
//#define sockaddr_in sockaddr*
#undef SOCKET
#define SOCKET int
#else
int max(int,int);
#include <netinet/in.h> #include <netinet/in.h>
#define SOCKET int
#endif
#ifdef HAVE_PTHREADS #ifdef HAVE_PTHREADS
#include <pthread.h> #include <pthread.h>
#if 0 #if 0 /* debugging */
#define LOCK(mutex) fprintf(stderr,"%s:%d LOCK(%s,0x%x)\n",__FILE__,__LINE__,#mutex,&(mutex)) #define LOCK(mutex) fprintf(stderr,"%s:%d LOCK(%s,0x%x)\n",__FILE__,__LINE__,#mutex,&(mutex))
#define UNLOCK(mutex) fprintf(stderr,"%s:%d UNLOCK(%s,0x%x)\n",__FILE__,__LINE__,#mutex,&(mutex)) #define UNLOCK(mutex) fprintf(stderr,"%s:%d UNLOCK(%s,0x%x)\n",__FILE__,__LINE__,#mutex,&(mutex))
#define MUTEX(mutex) int mutex #define MUTEX(mutex) int mutex
@ -141,7 +149,7 @@ typedef Bool (*SetTranslateFunctionProcPtr)(struct rfbClientRec* cl);
typedef void (*NewClientHookPtr)(struct rfbClientRec* cl); typedef void (*NewClientHookPtr)(struct rfbClientRec* cl);
typedef struct { typedef struct {
int count; CARD32 count;
Bool is16; /* is the data format short? */ Bool is16; /* is the data format short? */
union { union {
CARD8* bytes; CARD8* bytes;
@ -149,6 +157,23 @@ typedef struct {
} data; /* there have to be count*3 entries */ } data; /* there have to be count*3 entries */
} rfbColourMap; } rfbColourMap;
/* this is why windows and it's programs are so huge:
You can't do something like
#define MUTEX(m)
struct {
int i;
MUTEX(m); // this evaluates to ";", and that is not acceptable
// to Visual C++
}
*/
#ifdef WIN32
#undef MUTEX
#define MUTEX(mutex) char dummy##mutex
#undef COND
#define COND(cont) char dummy##cond
#endif
/* /*
* Per-screen (framebuffer) structure. There is only one of these, since we * Per-screen (framebuffer) structure. There is only one of these, since we
* don't allow the X server to have multiple screens. * don't allow the X server to have multiple screens.
@ -221,12 +246,12 @@ typedef struct
char rfbThisHost[255]; char rfbThisHost[255];
int rfbPort; int rfbPort;
Bool socketInitDone; Bool socketInitDone;
int inetdSock; SOCKET inetdSock;
int maxSock; int maxSock;
int maxFd; int maxFd;
int rfbListenSock; SOCKET rfbListenSock;
int udpPort; int udpPort;
int udpSock; SOCKET udpSock;
struct rfbClientRec* udpClient; struct rfbClientRec* udpClient;
Bool udpSockConnected; Bool udpSockConnected;
struct sockaddr_in udpRemoteAddr; struct sockaddr_in udpRemoteAddr;
@ -237,8 +262,8 @@ typedef struct
Bool httpInitDone; Bool httpInitDone;
int httpPort; int httpPort;
char* httpDir; char* httpDir;
int httpListenSock; SOCKET httpListenSock;
int httpSock; SOCKET httpSock;
FILE* httpFP; FILE* httpFP;
char* rfbAuthPasswdFile; char* rfbAuthPasswdFile;
@ -256,7 +281,9 @@ typedef struct
struct rfbCursor* cursor; struct rfbCursor* cursor;
MUTEX(cursorMutex); MUTEX(cursorMutex);
IF_PTHREADS(Bool backgroundLoop); #ifdef HAVE_PTHREADS
Bool backgroundLoop;
#endif
/* the following members have to be supplied by the serving process */ /* the following members have to be supplied by the serving process */
char* frameBuffer; char* frameBuffer;
@ -319,7 +346,7 @@ typedef struct rfbClientRec {
void* clientData; void* clientData;
ClientGoneHookPtr clientGoneHook; ClientGoneHookPtr clientGoneHook;
int sock; SOCKET sock;
char *host; char *host;
/* Possible client states: */ /* Possible client states: */
enum { enum {

@ -27,12 +27,16 @@
#include <stdlib.h> #include <stdlib.h>
#include "rfb.h" #include "rfb.h"
#include "sraRegion.h" #include "sraRegion.h"
#ifdef WIN32
#define write(sock,buf,len) send(sock,buf,len,0)
#else
#include <unistd.h> #include <unistd.h>
#include <pwd.h> #include <pwd.h>
#include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#endif
#include <sys/types.h>
#ifdef CORBA #ifdef CORBA
#include <vncserverctrl.h> #include <vncserverctrl.h>
@ -984,8 +988,8 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion)
fu->type = rfbFramebufferUpdate; fu->type = rfbFramebufferUpdate;
if (nUpdateRegionRects != 0xFFFF) { if (nUpdateRegionRects != 0xFFFF) {
fu->nRects = Swap16IfLE(sraRgnCountRects(updateCopyRegion) fu->nRects = Swap16IfLE((CARD16)(sraRgnCountRects(updateCopyRegion)
+ nUpdateRegionRects + !!sendCursorShape); + nUpdateRegionRects + !!sendCursorShape));
} else { } else {
fu->nRects = 0xFFFF; fu->nRects = 0xFFFF;
} }
@ -1277,7 +1281,7 @@ rfbSendSetColourMapEntries(cl, firstColour, nColours)
len = sz_rfbSetColourMapEntriesMsg; len = sz_rfbSetColourMapEntriesMsg;
for (i = 0; i < nColours; i++) { for (i = 0; i < nColours; i++) {
if(i<cm->count) { if(i<(int)cm->count) {
if(cm->is16) { if(cm->is16) {
rgb[i*3] = Swap16IfLE(cm->data.shorts[i*3]); rgb[i*3] = Swap16IfLE(cm->data.shorts[i*3]);
rgb[i*3+1] = Swap16IfLE(cm->data.shorts[i*3+1]); rgb[i*3+1] = Swap16IfLE(cm->data.shorts[i*3+1]);

@ -41,7 +41,22 @@
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#ifdef WIN32
#pragma warning (disable: 4018 4761)
#define close closesocket
#define read(sock,buf,len) recv(sock,buf,len,0)
#define EWOULDBLOCK WSAEWOULDBLOCK
#define ETIMEDOUT WSAETIMEDOUT
#define write(sock,buf,len) send(sock,buf,len,0)
#else
#include <sys/time.h> #include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netdb.h>
#include <unistd.h>
#include <arpa/inet.h>
#endif
#if defined(__linux__) && defined(NEED_TIMEVAL) #if defined(__linux__) && defined(NEED_TIMEVAL)
struct timeval struct timeval
{ {
@ -49,18 +64,14 @@ struct timeval
} }
; ;
#endif #endif
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netdb.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include <unistd.h>
#include <arpa/inet.h>
#include "rfb.h" #include "rfb.h"
#ifndef WIN32
int max(int i,int j) { return(i<j?j:i); } int max(int i,int j) { return(i<j?j:i); }
#endif
int rfbMaxClientWait = 20000; /* time (ms) after which we decide client has int rfbMaxClientWait = 20000; /* time (ms) after which we decide client has
gone away - needed to stop us hanging */ gone away - needed to stop us hanging */
@ -81,10 +92,12 @@ rfbInitSockets(rfbScreenInfoPtr rfbScreen)
if (rfbScreen->inetdSock != -1) { if (rfbScreen->inetdSock != -1) {
const int one = 1; const int one = 1;
#ifndef WIN32
if (fcntl(rfbScreen->inetdSock, F_SETFL, O_NONBLOCK) < 0) { if (fcntl(rfbScreen->inetdSock, F_SETFL, O_NONBLOCK) < 0) {
rfbLogPerror("fcntl"); rfbLogPerror("fcntl");
exit(1); exit(1);
} }
#endif
if (setsockopt(rfbScreen->inetdSock, IPPROTO_TCP, TCP_NODELAY, if (setsockopt(rfbScreen->inetdSock, IPPROTO_TCP, TCP_NODELAY,
(char *)&one, sizeof(one)) < 0) { (char *)&one, sizeof(one)) < 0) {
@ -117,7 +130,7 @@ rfbInitSockets(rfbScreenInfoPtr rfbScreen)
exit(1); exit(1);
} }
FD_SET(rfbScreen->udpSock, &(rfbScreen->allFds)); FD_SET(rfbScreen->udpSock, &(rfbScreen->allFds));
rfbScreen->maxFd = max(rfbScreen->udpSock,rfbScreen->maxFd); rfbScreen->maxFd = max((int)rfbScreen->udpSock,rfbScreen->maxFd);
} }
} }
@ -156,6 +169,9 @@ rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec)
return; return;
} }
if (nfds < 0) { if (nfds < 0) {
#ifdef WIN32
errno = WSAGetLastError();
#endif
rfbLogPerror("rfbCheckFds: select"); rfbLogPerror("rfbCheckFds: select");
return; return;
} }
@ -168,11 +184,13 @@ rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec)
return; return;
} }
#ifndef WIN32
if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) { if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) {
rfbLogPerror("rfbCheckFds: fcntl"); rfbLogPerror("rfbCheckFds: fcntl");
close(sock); close(sock);
return; return;
} }
#endif
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
(char *)&one, sizeof(one)) < 0) { (char *)&one, sizeof(one)) < 0) {
@ -282,11 +300,13 @@ rfbConnect(rfbScreen, host, port)
return -1; return -1;
} }
#ifndef WIN32
if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) { if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) {
rfbLogPerror("fcntl failed"); rfbLogPerror("fcntl failed");
close(sock); close(sock);
return -1; return -1;
} }
#endif
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
(char *)&one, sizeof(one)) < 0) { (char *)&one, sizeof(one)) < 0) {
@ -332,6 +352,9 @@ ReadExact(cl, buf, len)
return 0; return 0;
} else { } else {
#ifdef WIN32
errno = WSAGetLastError();
#endif
if (errno != EWOULDBLOCK && errno != EAGAIN) { if (errno != EWOULDBLOCK && errno != EAGAIN) {
return n; return n;
} }
@ -389,6 +412,9 @@ WriteExact(cl, buf, len)
exit(1); exit(1);
} else { } else {
#ifdef WIN32
errno = WSAGetLastError();
#endif
if (errno != EWOULDBLOCK && errno != EAGAIN) { if (errno != EWOULDBLOCK && errno != EAGAIN) {
UNLOCK(cl->outputMutex); UNLOCK(cl->outputMutex);
return n; return n;

@ -48,7 +48,7 @@ rfbInitColourMapSingleTableOUT(char **table, rfbPixelFormat *in,
{ {
CARD32 i, r, g, b; CARD32 i, r, g, b;
OUT_T *t; OUT_T *t;
int nEntries = 1 << in->bitsPerPixel; CARD32 nEntries = 1 << in->bitsPerPixel;
int shift = colourMap->is16?16:8; int shift = colourMap->is16?16:8;
if (*table) free(*table); if (*table) free(*table);

@ -24,8 +24,15 @@
* USA. * USA.
*/ */
#include <stdio.h> //#include <stdio.h>
#include "rfb.h" #include "rfb.h"
#ifdef WIN32
#define XMD_H
#undef FAR
#define NEEDFAR_POINTERS
#endif
#include <jpeglib.h> #include <jpeglib.h>
@ -1433,7 +1440,7 @@ DetectSmoothImage (cl, fmt, w, h)
rfbPixelFormat *fmt; rfbPixelFormat *fmt;
int w, h; int w, h;
{ {
unsigned long avgError; long avgError;
if ( cl->screen->rfbServerFormat.bitsPerPixel == 8 || fmt->bitsPerPixel == 8 || if ( cl->screen->rfbServerFormat.bitsPerPixel == 8 || fmt->bitsPerPixel == 8 ||
w < DETECT_MIN_WIDTH || h < DETECT_MIN_HEIGHT ) { w < DETECT_MIN_WIDTH || h < DETECT_MIN_HEIGHT ) {

@ -63,6 +63,9 @@ static const rfbPixelFormat BGR233Format = {
#define CONCAT4(a,b,c,d) a##b##c##d #define CONCAT4(a,b,c,d) a##b##c##d
#define CONCAT4E(a,b,c,d) CONCAT4(a,b,c,d) #define CONCAT4E(a,b,c,d) CONCAT4(a,b,c,d)
#undef OUT
#undef IN
#define OUT 8 #define OUT 8
#include "tableinitcmtemplate.c" #include "tableinitcmtemplate.c"
#include "tableinittctemplate.c" #include "tableinittctemplate.c"

@ -26,7 +26,13 @@
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef WIN32
#include <time.h>
#define srandom srand
#define random rand
#else
#include <sys/time.h> #include <sys/time.h>
#endif
#include "rfb.h" #include "rfb.h"
#include "d3des.h" #include "d3des.h"
@ -49,12 +55,15 @@ int
vncEncryptAndStorePasswd(char *passwd, char *fname) vncEncryptAndStorePasswd(char *passwd, char *fname)
{ {
FILE *fp; FILE *fp;
int i; unsigned int i;
unsigned char encryptedPasswd[8]; unsigned char encryptedPasswd[8];
if ((fp = fopen(fname,"w")) == NULL) return 1; if ((fp = fopen(fname,"w")) == NULL) return 1;
/* windows security sux */
#ifndef WIN32
chmod(fname, S_IRUSR|S_IWUSR); chmod(fname, S_IRUSR|S_IWUSR);
#endif
/* pad password with nulls */ /* pad password with nulls */
@ -142,7 +151,7 @@ void
vncEncryptBytes(unsigned char *bytes, char *passwd) vncEncryptBytes(unsigned char *bytes, char *passwd)
{ {
unsigned char key[8]; unsigned char key[8];
int i; unsigned int i;
/* key is simply password padded with nulls */ /* key is simply password padded with nulls */

Loading…
Cancel
Save