CVS: seamlessrdp/ServerExe main.c,1.2,1.3 vchannel.c,1.1,1.2 vchannel.h,1.1,1.2
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-serv9526
Modified Files:
main.c vchannel.c vchannel.h
Log Message:
Basic infrastructure for retrieving commands in the server.
Index: main.c
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/main.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** main.c 9 Mar 2006 12:00:14 -0000 1.2
--- main.c 9 Mar 2006 13:24:35 -0000 1.3
***************
*** 26,29 ****
--- 26,31 ----
#include <stdio.h>
+ #include "vchannel.h"
+
#include "resource.h"
***************
*** 43,46 ****
--- 45,59 ----
}
+ static void
+ process_cmds(void)
+ {
+ char line[VCHANNEL_MAX_LINE];
+ int size;
+
+ while ((size = vchannel_read(line, sizeof(line))) >= 0) {
+ debug("Got: %s", line);
+ }
+ }
+
int WINAPI
WinMain(HINSTANCE instance, HINSTANCE prev_instance, LPSTR cmdline, int cmdshow)
***************
*** 80,83 ****
--- 93,98 ----
}
+ vchannel_open();
+
set_hooks_fn();
***************
*** 104,108 ****
do
{
! Sleep(1000);
GetExitCodeProcess(proc_info.hProcess, &exitcode);
}
--- 119,124 ----
do
{
! process_cmds();
! Sleep(100);
GetExitCodeProcess(proc_info.hProcess, &exitcode);
}
***************
*** 127,130 ****
--- 143,148 ----
FreeLibrary(hookdll);
+ vchannel_close();
+
return 1;
}
Index: vchannel.c
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/vchannel.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** vchannel.c 9 Mar 2006 12:26:30 -0000 1.1
--- vchannel.c 9 Mar 2006 13:24:35 -0000 1.2
***************
*** 23,26 ****
--- 23,27 ----
#include <stdio.h>
#include <stdarg.h>
+ #include <errno.h>
#include <windows.h>
***************
*** 93,99 ****
int
! vchannel_read(char *buffer, size_t length)
{
! return -1;
}
--- 94,157 ----
int
! vchannel_read(char *line, size_t length)
{
! static BOOL overflow_mode = FALSE;
! static char buffer[VCHANNEL_MAX_LINE];
! static size_t size = 0;
!
! char *newline;
! int line_size;
!
! BOOL result;
! ULONG bytes_read;
!
! result = WTSVirtualChannelRead(g_vchannel, 0, buffer + size,
! sizeof(buffer) - size, &bytes_read);
!
! if (!result) {
! errno = EIO;
! return -1;
! }
!
! if (overflow_mode) {
! newline = strchr(buffer, '\n');
! if (newline && (newline - buffer) < bytes_read) {
! size = bytes_read - (newline - buffer) - 1;
! memmove(buffer, newline + 1, size);
! overflow_mode = FALSE;
! }
! }
! else
! size += bytes_read;
!
! if (overflow_mode) {
! errno = -EAGAIN;
! return -1;
! }
!
! newline = strchr(buffer, '\n');
! if (!newline || (newline - buffer) >= size) {
! if (size == sizeof(buffer)) {
! overflow_mode = TRUE;
! size = 0;
! }
! errno = -EAGAIN;
! return -1;
! }
!
! if ((newline - buffer) >= length) {
! errno = ENOMEM;
! return -1;
! }
!
! *newline = '\0';
!
! strcpy(line, buffer);
! line_size = newline - buffer;
!
! size -= newline - buffer + 1;
! memmove(buffer, newline + 1, size);
!
! return 0;
}
***************
*** 103,107 ****
BOOL result;
va_list argp;
! char buf[1024];
int size;
ULONG bytes_written;
--- 161,165 ----
BOOL result;
va_list argp;
! char buf[VCHANNEL_MAX_LINE];
int size;
ULONG bytes_written;
Index: vchannel.h
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/vchannel.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** vchannel.h 9 Mar 2006 12:26:30 -0000 1.1
--- vchannel.h 9 Mar 2006 13:24:35 -0000 1.2
***************
*** 23,26 ****
--- 23,28 ----
#define __VCHANNEL_H__
+ #define VCHANNEL_MAX_LINE 1024
+
void debug(char *format, ...);
***************
*** 30,34 ****
int vchannel_is_open();
! int vchannel_read(char *buffer, size_t length);
int vchannel_write(char *format, ...);
--- 32,37 ----
int vchannel_is_open();
! /* read may only be used by a single process. write is completely safe */
! int vchannel_read(char *line, size_t length);
int vchannel_write(char *format, ...);
-------------------------------------------------------
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