CVS: seamlessrdp/ServerExe vchannel.c,NONE,1.1 vchannel.h,NONE,1.1 Makefile,1.5,1.6 clipper.vcproj,1.9,1.10
Pierre Ossman <[email protected]>
| Newsgroups | gmane.network.rdesktop.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/rdesktop/seamlessrdp/ServerExe In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3038 Modified Files: Makefile clipper.vcproj Added Files: vchannel.c vchannel.h Log Message: Put virtual channel handling into a separate file since both the DLL and the main program will use it. --- NEW FILE: vchannel.c --- /* -*- c-basic-offset: 8 -*- rdesktop: A Remote Desktop Protocol client. Seamless windows - Virtual channel handling Copyright (C) Pierre Ossman <[email protected]> 2006 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <assert.h> #include <stdio.h> #include <stdarg.h> #include <windows.h> #include <wtsapi32.h> #include <cchannel.h> #include "vchannel.h" #define CHANNELNAME "seamrdp" static HANDLE g_mutex = NULL; static HANDLE g_vchannel = NULL; void debug(char *format, ...) { va_list argp; char buf[256]; sprintf(buf, "DEBUG1,"); va_start(argp, format); _vsnprintf(buf + sizeof("DEBUG1,") - 1, sizeof(buf) - sizeof("DEBUG1,") + 1, format, argp); va_end(argp); vchannel_write(buf); } int vchannel_open() { g_vchannel = WTSVirtualChannelOpen(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, CHANNELNAME); if (g_vchannel == NULL) return -1; g_mutex = CreateMutex(NULL, FALSE, "Local\\SeamlessChannel"); if (!g_mutex) { WTSVirtualChannelClose(g_vchannel); g_vchannel = NULL; return -1; } return 0; } void vchannel_close() { if (g_mutex) CloseHandle(g_mutex); if (g_vchannel) WTSVirtualChannelClose(g_vchannel); g_mutex = NULL; g_vchannel = NULL; } int vchannel_is_open() { if (g_vchannel == NULL) return 0; else return 1; } int vchannel_read(char *buffer, size_t length) { return -1; } int vchannel_write(char *format, ...) { BOOL result; va_list argp; char buf[1024]; int size; ULONG bytes_written; assert(vchannel_is_open()); va_start(argp, format); size = _vsnprintf(buf, sizeof(buf), format, argp); va_end(argp); assert(size < sizeof(buf)); WaitForSingleObject(g_mutex, INFINITE); result = WTSVirtualChannelWrite(g_vchannel, buf, (ULONG) strlen(buf), &bytes_written); result = WTSVirtualChannelWrite(g_vchannel, "\n", (ULONG) 1, &bytes_written); ReleaseMutex(g_mutex); if (!result) return -1; return bytes_written; } --- NEW FILE: vchannel.h --- /* -*- c-basic-offset: 8 -*- rdesktop: A Remote Desktop Protocol client. Seamless windows - Virtual channel handling Copyright (C) Pierre Ossman <[email protected]> 2006 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __VCHANNEL_H__ #define __VCHANNEL_H__ void debug(char *format, ...); int vchannel_open(); void vchannel_close(); int vchannel_is_open(); int vchannel_read(char *buffer, size_t length); int vchannel_write(char *format, ...); #endif Index: Makefile =================================================================== RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/Makefile,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile 9 Mar 2006 12:06:17 -0000 1.5 --- Makefile 9 Mar 2006 12:26:30 -0000 1.6 *************** *** 11,18 **** default: seamlessrdpshell.exe HookDll/hookdll.dll ! seamlessrdpshell.exe: main.c ! $(CC) $(CFLAGS) -mwindows -o $@ $^ ! HookDll/hookdll.dll: HookDll/hookdll.c $(CC) $(CFLAGS) -shared -o $@ $^ -lwtsapi32 --- 11,21 ---- default: seamlessrdpshell.exe HookDll/hookdll.dll ! seamlessrdpshell.exe: main.c vchannel.o ! $(CC) $(CFLAGS) -mwindows -o $@ $^ -lwtsapi32 ! vchannel.o: vchannel.c vchannel.h ! $(CC) $(CFLAGS) -c -o $@ vchannel.c ! ! HookDll/hookdll.dll: HookDll/hookdll.c vchannel.o $(CC) $(CFLAGS) -shared -o $@ $^ -lwtsapi32 Index: clipper.vcproj =================================================================== RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/clipper.vcproj,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** clipper.vcproj 9 Mar 2006 09:46:30 -0000 1.9 --- clipper.vcproj 9 Mar 2006 12:26:30 -0000 1.10 *************** *** 102,106 **** Name="VCLinkerTool" AdditionalOptions="/MACHINE:I386" ! AdditionalDependencies="" OutputFile=".\Release/seamlessrdpshell.exe" LinkIncremental="2" --- 102,106 ---- Name="VCLinkerTool" AdditionalOptions="/MACHINE:I386" ! AdditionalDependencies="wtsapi32.lib" OutputFile=".\Release/seamlessrdpshell.exe" LinkIncremental="2" *************** *** 153,156 **** --- 153,162 ---- RelativePath=".\resource.h"> </File> + <File + RelativePath=".\vchannel.c"> + </File> + <File + RelativePath=".\vchannel.h"> + </File> </Files> <Globals> ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642