summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordscho <dscho>2001-10-06 17:45:42 +0000
committerdscho <dscho>2001-10-06 17:45:42 +0000
commit446f334cc1ee67b280e218ae58fef34d5b063cea (patch)
treef238279505d71a241b20154a43aee10b7acde3fa
parent018e90db5918a75ceaf3835be084e2387f31a47e (diff)
downloadlibtdevnc-446f334cc1ee67b280e218ae58fef34d5b063cea.tar.gz
libtdevnc-446f334cc1ee67b280e218ae58fef34d5b063cea.zip
WIN32 compatibility, removed kbdptr.c
-rw-r--r--README74
-rw-r--r--d3des.c16
-rw-r--r--example.c13
-rw-r--r--example.dsp80
-rw-r--r--httpd.c35
-rw-r--r--kbdptr.c31
-rw-r--r--libvncserver.dsp188
-rw-r--r--libvncserver.dsw59
-rw-r--r--main.c39
-rw-r--r--rfb.h65
-rw-r--r--rfbserver.c12
-rw-r--r--sockets.c40
-rw-r--r--tableinitcmtemplate.c2
-rw-r--r--tight.c11
-rw-r--r--translate.c3
-rw-r--r--vncauth.c13
16 files changed, 585 insertions, 96 deletions
diff --git a/README b/README
index 654a97a..158be5b 100644
--- a/README
+++ b/README
@@ -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
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
-------
diff --git a/d3des.c b/d3des.c
index 60e6473..4994afb 100644
--- a/d3des.c
+++ b/d3des.c
@@ -181,14 +181,14 @@ static void unscrun(outof, into)
register unsigned long *outof;
register unsigned char *into;
{
- *into++ = (*outof >> 24) & 0xffL;
- *into++ = (*outof >> 16) & 0xffL;
- *into++ = (*outof >> 8) & 0xffL;
- *into++ = *outof++ & 0xffL;
- *into++ = (*outof >> 24) & 0xffL;
- *into++ = (*outof >> 16) & 0xffL;
- *into++ = (*outof >> 8) & 0xffL;
- *into = *outof & 0xffL;
+ *into++ = (unsigned char)((*outof >> 24) & 0xffL);
+ *into++ = (unsigned char)((*outof >> 16) & 0xffL);
+ *into++ = (unsigned char)((*outof >> 8) & 0xffL);
+ *into++ = (unsigned char)( *outof++ & 0xffL);
+ *into++ = (unsigned char)((*outof >> 24) & 0xffL);
+ *into++ = (unsigned char)((*outof >> 16) & 0xffL);
+ *into++ = (unsigned char)((*outof >> 8) & 0xffL);
+ *into = (unsigned char)( *outof & 0xffL);
return;
}
diff --git a/example.c b/example.c
index 1348c49..9ed6846 100644
--- a/example.c
+++ b/example.c
@@ -21,11 +21,16 @@
* USA.
*/
+#ifdef WIN32
+#define sleep Sleep
+#else
#include <unistd.h>
+#endif
+
#ifdef __IRIX__
#include <netdb.h>
#endif
-#define XK_MISCELLANY
+
#include "rfb.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(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);
}
@@ -157,8 +162,8 @@ void dokey(Bool down,KeySym key,rfbClientPtr cl)
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,key,0xffffff);
- rfbFontBBox(&radonFont,key,&x1,&y1,&x2,&y2);
+ 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);
}
}
diff --git a/example.dsp b/example.dsp
new file mode 100644
index 0000000..ebabc4a
--- /dev/null
+++ b/example.dsp
@@ -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
diff --git a/httpd.c b/httpd.c
index a80c44d..7d92812 100644
--- a/httpd.c
+++ b/httpd.c
@@ -23,16 +23,21 @@
#include <stdio.h>
#include <sys/types.h>
+#ifdef WIN32
+#include <winsock.h>
+#define close closesocket
+#else
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netdb.h>
-#include <fcntl.h>
-#include <errno.h>
#include <pwd.h>
#include <arpa/inet.h>
#include <unistd.h>
+#endif
+#include <fcntl.h>
+#include <errno.h>
#include "rfb.h"
@@ -120,6 +125,9 @@ httpCheckFds(rfbScreenInfoPtr rfbScreen)
return;
}
if (nfds < 0) {
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
rfbLogPerror("httpCheckFds: select");
return;
}
@@ -170,12 +178,14 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
int addrlen = sizeof(addr);
char fullFname[256];
char *fname;
- int maxFnameLen;
- int fd;
+ unsigned int maxFnameLen;
+ FILE* fd;
Bool gotGet = FALSE;
Bool performSubstitutions = FALSE;
char str[256];
+#ifndef WIN32
struct passwd *user = getpwuid(getuid());;
+#endif
cl.sock=rfbScreen->httpSock;
@@ -263,7 +273,7 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
/* Open the file */
- if ((fd = open(fullFname, O_RDONLY)) < 0) {
+ if ((fd = fopen(fullFname, O_RDONLY)) < 0) {
rfbLogPerror("httpProcessInput: open");
WriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR));
httpCloseSock(rfbScreen);
@@ -273,10 +283,10 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
WriteExact(&cl, OK_STR, strlen(OK_STR));
while (1) {
- int n = read(fd, buf, BUF_SIZE-1);
+ int n = fread(buf, BUF_SIZE-1, 1, fd);
if (n < 0) {
rfbLogPerror("httpProcessInput: read");
- close(fd);
+ fclose(fd);
httpCloseSock(rfbScreen);
return;
}
@@ -335,20 +345,19 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
WriteExact(&cl, str, strlen(str));
} else if (compareAndSkip(&ptr, "$USER")) {
-
+#ifndef WIN32
if (user) {
WriteExact(&cl, user->pw_name,
strlen(user->pw_name));
- } else {
+ } else
+#endif
WriteExact(&cl, "?", 1);
- }
-
} else {
if (!compareAndSkip(&ptr, "$$"))
ptr++;
if (WriteExact(&cl, "$", 1) < 0) {
- close(fd);
+ fclose(fd);
httpCloseSock(rfbScreen);
return;
}
@@ -366,7 +375,7 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
}
}
- close(fd);
+ fclose(fd);
httpCloseSock(rfbScreen);
}
diff --git a/kbdptr.c b/kbdptr.c
deleted file mode 100644
index 8c2d678..0000000
--- a/kbdptr.c
+++ /dev/null
@@ -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"
-
diff --git a/libvncserver.dsp b/libvncserver.dsp
new file mode 100644
index 0000000..1ff5d1e
--- /dev/null
+++ b/libvncserver.dsp
@@ -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
diff --git a/libvncserver.dsw b/libvncserver.dsw
new file mode 100644
index 0000000..93b60c1
--- /dev/null
+++ b/libvncserver.dsw
@@ -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>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/main.c b/main.c
index 305645e..2c682af 100644
--- a/main.c
+++ b/main.c
@@ -21,9 +21,11 @@
#endif
#include <sys/types.h>
+#ifndef WIN32
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
+#endif
#include <signal.h>
#include <time.h>
@@ -354,11 +356,22 @@ void defaultSetXCutText(char* text, int len, rfbClientPtr cl)
/* 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 =
{
- width: 8, height: 7, xhot: 3, yhot: 3,
source: "\000\102\044\030\044\102\000",
mask: "\347\347\176\074\176\347\347",
+ width: 8, height: 7, xhot: 3, yhot: 3,
/*
width: 8, height: 7, xhot: 0, yhot: 0,
source: "\000\074\176\146\176\074\000",
@@ -368,6 +381,7 @@ static rfbCursor myCursor =
backRed: 0xffff, backGreen: 0xffff, backBlue: 0xffff,
richSource: 0
};
+#endif
rfbCursorPtr defaultGetCursorPtr(rfbClientPtr cl)
{
@@ -422,7 +436,15 @@ rfbScreenInfoPtr rfbGetScreen(int argc,char** argv,
rfbScreen->width = width;
rfbScreen->height = height;
rfbScreen->bitsPerPixel = rfbScreen->depth = 8*bytesPerPixel;
+#ifdef WIN32
+ {
+ DWORD dummy=255;
+ GetComputerName(rfbScreen->rfbThisHost,&dummy);
+ }
+#else
gethostname(rfbScreen->rfbThisHost, 255);
+#endif
+
rfbScreen->paddedWidthInBytes = width*bytesPerPixel;
/* format */
@@ -498,6 +520,10 @@ void rfbScreenCleanup(rfbScreenInfoPtr rfbScreen)
void rfbInitServer(rfbScreenInfoPtr rfbScreen)
{
+#ifdef WIN32
+ WSADATA trash;
+ int i=WSAStartup(MAKEWORD(2,2),&trash);
+#endif
rfbInitSockets(rfbScreen);
httpInitSockets(rfbScreen);
}
@@ -506,7 +532,7 @@ void
rfbProcessEvents(rfbScreenInfoPtr rfbScreen,long usec)
{
rfbClientIteratorPtr i;
- rfbClientPtr cl;
+ rfbClientPtr cl,clPrev;
rfbCheckFds(rfbScreen,usec);
httpCheckFds(rfbScreen);
@@ -515,11 +541,14 @@ rfbProcessEvents(rfbScreenInfoPtr rfbScreen,long usec)
#endif
i = rfbGetClientIterator(rfbScreen);
- while((cl=rfbClientIteratorNext(i))) {
+ cl=rfbClientIteratorNext(i);
+ while(cl) {
if(cl->sock>=0 && FB_UPDATE_PENDING(cl))
rfbSendFramebufferUpdate(cl,cl->modifiedRegion);
- if(cl->sock==-1)
- rfbClientConnectionGone(cl);
+ clPrev=cl;
+ cl=rfbClientIteratorNext(i);
+ if(clPrev->sock==-1)
+ rfbClientConnectionGone(clPrev);
}
rfbReleaseClientIterator(i);
}
diff --git a/rfb.h b/rfb.h
index c0ca7a9..26dde36 100644
--- a/rfb.h
+++ b/rfb.h
@@ -46,22 +46,18 @@ typedef CARD32 KeySym;
#define xrealloc realloc
#define xfree free
-int max(int,int);
-
#include <zlib.h>
-#include <rfbproto.h>
+#include "rfbproto.h"
#ifdef __linux__
#include <endian.h>
-#else
-#if defined(__APPLE__) || defined(__FreeBSD__)
+#elif defined(__APPLE__) || defined(__FreeBSD__)
#include <sys/types.h>
#include <machine/endian.h>
#define _BYTE_ORDER BYTE_ORDER
#define _LITTLE_ENDIAN LITTLE_ENDIAN
-#else
-#ifdef sparc
+#elif sparc
#define _LITTLE_ENDIAN 1234
#define _BYTE_ORDER _LITTLE_ENDIAN
#undef Bool
@@ -69,11 +65,14 @@ int max(int,int);
#include <sys/types.h>
/* typedef unsigned int pthread_t; */
/* 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
#include <sys/endian.h>
#endif
-#endif
-#endif
#ifndef _BYTE_ORDER
#define _BYTE_ORDER __BYTE_ORDER
@@ -83,11 +82,20 @@ int max(int,int);
#define _LITTLE_ENDIAN __LITTLE_ENDIAN
#endif
+#ifdef WIN32
+#include <winsock.h>
+//#define sockaddr_in sockaddr*
+#undef SOCKET
+#define SOCKET int
+#else
+int max(int,int);
#include <netinet/in.h>
+#define SOCKET int
+#endif
#ifdef HAVE_PTHREADS
#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 UNLOCK(mutex) fprintf(stderr,"%s:%d UNLOCK(%s,0x%x)\n",__FILE__,__LINE__,#mutex,&(mutex))
#define MUTEX(mutex) int mutex
@@ -141,7 +149,7 @@ typedef Bool (*SetTranslateFunctionProcPtr)(struct rfbClientRec* cl);
typedef void (*NewClientHookPtr)(struct rfbClientRec* cl);
typedef struct {
- int count;
+ CARD32 count;
Bool is16; /* is the data format short? */
union {
CARD8* bytes;
@@ -149,6 +157,23 @@ typedef struct {
} data; /* there have to be count*3 entries */
} 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
* don't allow the X server to have multiple screens.
@@ -221,12 +246,12 @@ typedef struct
char rfbThisHost[255];
int rfbPort;
Bool socketInitDone;
- int inetdSock;
+ SOCKET inetdSock;
int maxSock;
int maxFd;
- int rfbListenSock;
+ SOCKET rfbListenSock;
int udpPort;
- int udpSock;
+ SOCKET udpSock;
struct rfbClientRec* udpClient;
Bool udpSockConnected;
struct sockaddr_in udpRemoteAddr;
@@ -237,8 +262,8 @@ typedef struct
Bool httpInitDone;
int httpPort;
char* httpDir;
- int httpListenSock;
- int httpSock;
+ SOCKET httpListenSock;
+ SOCKET httpSock;
FILE* httpFP;
char* rfbAuthPasswdFile;
@@ -255,8 +280,10 @@ typedef struct
Bool dontConvertRichCursorToXCursor;
struct rfbCursor* cursor;
MUTEX(cursorMutex);
-
- IF_PTHREADS(Bool backgroundLoop);
+
+#ifdef HAVE_PTHREADS
+ Bool backgroundLoop;
+#endif
/* the following members have to be supplied by the serving process */
char* frameBuffer;
@@ -319,7 +346,7 @@ typedef struct rfbClientRec {
void* clientData;
ClientGoneHookPtr clientGoneHook;
- int sock;
+ SOCKET sock;
char *host;
/* Possible client states: */
enum {
diff --git a/rfbserver.c b/rfbserver.c
index 2460130..6c20323 100644
--- a/rfbserver.c
+++ b/rfbserver.c
@@ -27,12 +27,16 @@
#include <stdlib.h>
#include "rfb.h"
#include "sraRegion.h"
+#ifdef WIN32
+#define write(sock,buf,len) send(sock,buf,len,0)
+#else
#include <unistd.h>
#include <pwd.h>
-#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#endif
+#include <sys/types.h>
#ifdef CORBA
#include <vncserverctrl.h>
@@ -984,8 +988,8 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion)
fu->type = rfbFramebufferUpdate;
if (nUpdateRegionRects != 0xFFFF) {
- fu->nRects = Swap16IfLE(sraRgnCountRects(updateCopyRegion)
- + nUpdateRegionRects + !!sendCursorShape);
+ fu->nRects = Swap16IfLE((CARD16)(sraRgnCountRects(updateCopyRegion)
+ + nUpdateRegionRects + !!sendCursorShape));
} else {
fu->nRects = 0xFFFF;
}
@@ -1277,7 +1281,7 @@ rfbSendSetColourMapEntries(cl, firstColour, nColours)
len = sz_rfbSetColourMapEntriesMsg;
for (i = 0; i < nColours; i++) {
- if(i<cm->count) {
+ if(i<(int)cm->count) {
if(cm->is16) {
rgb[i*3] = Swap16IfLE(cm->data.shorts[i*3]);
rgb[i*3+1] = Swap16IfLE(cm->data.shorts[i*3+1]);
diff --git a/sockets.c b/sockets.c
index 3882147..83b747e 100644
--- a/sockets.c
+++ b/sockets.c
@@ -41,7 +41,22 @@
#include <stdio.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/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)
struct timeval
{
@@ -49,18 +64,14 @@ struct timeval
}
;
#endif
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <netdb.h>
#include <fcntl.h>
#include <errno.h>
-#include <unistd.h>
-#include <arpa/inet.h>
#include "rfb.h"
+#ifndef WIN32
int max(int i,int j) { return(i<j?j:i); }
+#endif
int rfbMaxClientWait = 20000; /* time (ms) after which we decide client has
gone away - needed to stop us hanging */
@@ -81,10 +92,12 @@ rfbInitSockets(rfbScreenInfoPtr rfbScreen)
if (rfbScreen->inetdSock != -1) {
const int one = 1;
+#ifndef WIN32
if (fcntl(rfbScreen->inetdSock, F_SETFL, O_NONBLOCK) < 0) {
rfbLogPerror("fcntl");
exit(1);
}
+#endif
if (setsockopt(rfbScreen->inetdSock, IPPROTO_TCP, TCP_NODELAY,
(char *)&one, sizeof(one)) < 0) {
@@ -117,7 +130,7 @@ rfbInitSockets(rfbScreenInfoPtr rfbScreen)
exit(1);
}
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;
}
if (nfds < 0) {
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
rfbLogPerror("rfbCheckFds: select");
return;
}
@@ -168,11 +184,13 @@ rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec)
return;
}
+#ifndef WIN32
if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) {
rfbLogPerror("rfbCheckFds: fcntl");
close(sock);
return;
}
+#endif
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
(char *)&one, sizeof(one)) < 0) {
@@ -282,11 +300,13 @@ rfbConnect(rfbScreen, host, port)
return -1;
}
+#ifndef WIN32
if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) {
rfbLogPerror("fcntl failed");
close(sock);
return -1;
}
+#endif
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
(char *)&one, sizeof(one)) < 0) {
@@ -332,6 +352,9 @@ ReadExact(cl, buf, len)
return 0;
} else {
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
if (errno != EWOULDBLOCK && errno != EAGAIN) {
return n;
}
@@ -389,6 +412,9 @@ WriteExact(cl, buf, len)
exit(1);
} else {
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
if (errno != EWOULDBLOCK && errno != EAGAIN) {
UNLOCK(cl->outputMutex);
return n;
diff --git a/tableinitcmtemplate.c b/tableinitcmtemplate.c
index b8144ea..2d10ea5 100644
--- a/tableinitcmtemplate.c
+++ b/tableinitcmtemplate.c
@@ -48,7 +48,7 @@ rfbInitColourMapSingleTableOUT(char **table, rfbPixelFormat *in,
{
CARD32 i, r, g, b;
OUT_T *t;
- int nEntries = 1 << in->bitsPerPixel;
+ CARD32 nEntries = 1 << in->bitsPerPixel;
int shift = colourMap->is16?16:8;
if (*table) free(*table);
diff --git a/tight.c b/tight.c
index db0d382..0893fc2 100644
--- a/tight.c
+++ b/tight.c
@@ -24,8 +24,15 @@
* USA.
*/
-#include <stdio.h>
+//#include <stdio.h>
#include "rfb.h"
+
+#ifdef WIN32
+#define XMD_H
+#undef FAR
+#define NEEDFAR_POINTERS
+#endif
+
#include <jpeglib.h>
@@ -1433,7 +1440,7 @@ DetectSmoothImage (cl, fmt, w, h)
rfbPixelFormat *fmt;
int w, h;
{
- unsigned long avgError;
+ long avgError;
if ( cl->screen->rfbServerFormat.bitsPerPixel == 8 || fmt->bitsPerPixel == 8 ||
w < DETECT_MIN_WIDTH || h < DETECT_MIN_HEIGHT ) {
diff --git a/translate.c b/translate.c
index 5efc52c..8d78b99 100644
--- a/translate.c
+++ b/translate.c
@@ -63,6 +63,9 @@ static const rfbPixelFormat BGR233Format = {
#define CONCAT4(a,b,c,d) a##b##c##d
#define CONCAT4E(a,b,c,d) CONCAT4(a,b,c,d)
+#undef OUT
+#undef IN
+
#define OUT 8
#include "tableinitcmtemplate.c"
#include "tableinittctemplate.c"
diff --git a/vncauth.c b/vncauth.c
index 75f1cc3..1014291 100644
--- a/vncauth.c
+++ b/vncauth.c
@@ -26,7 +26,13 @@
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef WIN32
+#include <time.h>
+#define srandom srand
+#define random rand
+#else
#include <sys/time.h>
+#endif
#include "rfb.h"
#include "d3des.h"
@@ -49,12 +55,15 @@ int
vncEncryptAndStorePasswd(char *passwd, char *fname)
{
FILE *fp;
- int i;
+ unsigned int i;
unsigned char encryptedPasswd[8];
if ((fp = fopen(fname,"w")) == NULL) return 1;
+ /* windows security sux */
+#ifndef WIN32
chmod(fname, S_IRUSR|S_IWUSR);
+#endif
/* pad password with nulls */
@@ -142,7 +151,7 @@ void
vncEncryptBytes(unsigned char *bytes, char *passwd)
{
unsigned char key[8];
- int i;
+ unsigned int i;
/* key is simply password padded with nulls */