Make the rdpdr disk plugin working on windows.
authorrichterger <richter@ecos.de>
Tue, 2 Oct 2012 06:58:54 +0000 (08:58 +0200)
committerrichterger <richter@ecos.de>
Tue, 2 Oct 2012 06:58:54 +0000 (08:58 +0200)
Currently not working are rename and setting of read only attribute and file times.

In addition it also adds the ability to staticly link plugins into the binary, so you get one big exe and need no dlls. I have only tested this on windows (only disk plugin so far).

I use the following options for cmake for static binary:

cmake -DWITH_MONOLITHIC_BUILD=ON -DMSVC_RUNTIME=static -DBUILD_SHARED_LIBS=OFF -DWITH_RDPDR=ON -DOPENSSL_INCLUDE_DIR=\opensslpath\inc32 -DOPENSSL_LIBRARIES="\opensslpath\out32.dbg\ssleay32.lib;d:\path\out32.dbg\libeay32.lib" -G "Visual Studio 9 2008" .

Important notice: Openssl need to be compiled with the same static runtime. Currently missing is a switch to link different openssl libraries for debug and release builds.

13 files changed:
CMakeLists.txt
channels/rdpdr/client/CMakeLists.txt
channels/rdpdr/client/disk/CMakeLists.txt
channels/rdpdr/client/disk/dirent.h [new file with mode: 0644]
channels/rdpdr/client/disk/disk_file.c
channels/rdpdr/client/disk/disk_file.h
channels/rdpdr/client/disk/disk_main.c
channels/rdpdr/client/disk/statvfs.c [new file with mode: 0644]
channels/rdpdr/client/disk/statvfs.h [new file with mode: 0644]
client/Windows/CMakeLists.txt
client/Windows/wfreerdp.c
config.h.in
include/freerdp/utils/svc_plugin.h

index 446e685..2fe8a10 100644 (file)
@@ -59,6 +59,10 @@ if(NOT DEFINED BUILD_SHARED_LIBS)
        set(BUILD_SHARED_LIBS ON)
 endif()
 
+if(NOT BUILD_SHARED_LIBS AND WITH_MONOLITHIC_BUILD)
+       set(WITH_STATIC_PLUGINS ON)
+endif()
+
 # Configure MSVC Runtime
 if(MSVC)
        include(MSVCRuntime)
@@ -73,6 +77,7 @@ if(MSVC)
        configure_msvc_runtime()
 endif()
 
+
 # Compiler-specific flags
 if(CMAKE_COMPILER_IS_GNUCC)
        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
index 55b0e09..8547706 100644 (file)
@@ -40,8 +40,8 @@ endif()
 
 install(TARGETS rdpdr DESTINATION ${FREERDP_PLUGIN_PATH})
 
+add_subdirectory(disk)
 if(NOT WIN32)
-       add_subdirectory(disk)
        add_subdirectory(printer)
        add_subdirectory(parallel)
        add_subdirectory(serial)
index d6d7935..b1e5787 100644 (file)
@@ -21,6 +21,7 @@ set(MODULE_NAME "disk")
 set(MODULE_PREFIX "CHANNEL_DEVICE_DISK")
 
 set(${MODULE_PREFIX}_SRCS
+       statvfs.c
        disk_file.c
        disk_file.h
        disk_main.c)
diff --git a/channels/rdpdr/client/disk/dirent.h b/channels/rdpdr/client/disk/dirent.h
new file mode 100644 (file)
index 0000000..fa5a294
--- /dev/null
@@ -0,0 +1,374 @@
+/*****************************************************************************
+ * dirent.h - dirent API for Microsoft Visual Studio
+ *
+ * Copyright (C) 2006 Toni Ronkko
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * ``Software''), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Mar 15, 2011, Toni Ronkko
+ * Defined FILE_ATTRIBUTE_DEVICE for MSVC 6.0.
+ *
+ * Aug 11, 2010, Toni Ronkko
+ * Added d_type and d_namlen fields to dirent structure.  The former is
+ * especially useful for determining whether directory entry represents a
+ * file or a directory.  For more information, see
+ * http://www.delorie.com/gnu/docs/glibc/libc_270.html
+ *
+ * Aug 11, 2010, Toni Ronkko
+ * Improved conformance to the standards.  For example, errno is now set
+ * properly on failure and assert() is never used.  Thanks to Peter Brockam
+ * for suggestions.
+ *
+ * Aug 11, 2010, Toni Ronkko
+ * Fixed a bug in rewinddir(): when using relative directory names, change
+ * of working directory no longer causes rewinddir() to fail.
+ *
+ * Dec 15, 2009, John Cunningham
+ * Added rewinddir member function
+ *
+ * Jan 18, 2008, Toni Ronkko
+ * Using FindFirstFileA and WIN32_FIND_DATAA to avoid converting string
+ * between multi-byte and unicode representations.  This makes the
+ * code simpler and also allows the code to be compiled under MingW.  Thanks
+ * to Azriel Fasten for the suggestion.
+ *
+ * Mar 4, 2007, Toni Ronkko
+ * Bug fix: due to the strncpy_s() function this file only compiled in
+ * Visual Studio 2005.  Using the new string functions only when the
+ * compiler version allows.
+ *
+ * Nov  2, 2006, Toni Ronkko
+ * Major update: removed support for Watcom C, MS-DOS and Turbo C to
+ * simplify the file, updated the code to compile cleanly on Visual
+ * Studio 2005 with both unicode and multi-byte character strings,
+ * removed rewinddir() as it had a bug.
+ *
+ * Aug 20, 2006, Toni Ronkko
+ * Removed all remarks about MSVC 1.0, which is antiqued now.  Simplified
+ * comments by removing SGML tags.
+ *
+ * May 14 2002, Toni Ronkko
+ * Embedded the function definitions directly to the header so that no
+ * source modules need to be included in the Visual Studio project.  Removed
+ * all the dependencies to other projects so that this very header can be
+ * used independently.
+ *
+ * May 28 1998, Toni Ronkko
+ * First version.
+ *****************************************************************************/
+#ifndef DIRENT_H
+#define DIRENT_H
+
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+/* Entries missing from MSVC 6.0 */
+#if !defined(FILE_ATTRIBUTE_DEVICE)
+# define FILE_ATTRIBUTE_DEVICE 0x40
+#endif
+
+/* File type and permission flags for stat() */
+#if defined(_MSC_VER)  &&  !defined(S_IREAD)
+# define S_IFMT   _S_IFMT                      /* file type mask */
+# define S_IFDIR  _S_IFDIR                     /* directory */
+# define S_IFCHR  _S_IFCHR                     /* character device */
+# define S_IFFIFO _S_IFFIFO                    /* pipe */
+# define S_IFREG  _S_IFREG                     /* regular file */
+# define S_IREAD  _S_IREAD                     /* read permission */
+# define S_IWRITE _S_IWRITE                    /* write permission */
+# define S_IEXEC  _S_IEXEC                     /* execute permission */
+#endif
+#define S_IFBLK   0                            /* block device */
+#define S_IFLNK   0                            /* link */
+#define S_IFSOCK  0                            /* socket */
+
+#if defined(_MSC_VER)
+# define S_IRUSR  S_IREAD                      /* read, user */
+# define S_IWUSR  S_IWRITE                     /* write, user */
+# define S_IXUSR  0                            /* execute, user */
+# define S_IRGRP  0                            /* read, group */
+# define S_IWGRP  0                            /* write, group */
+# define S_IXGRP  0                            /* execute, group */
+# define S_IROTH  0                            /* read, others */
+# define S_IWOTH  0                            /* write, others */
+# define S_IXOTH  0                            /* execute, others */
+#endif
+
+/* Indicates that d_type field is available in dirent structure */
+#define _DIRENT_HAVE_D_TYPE
+
+/* File type flags for d_type */
+#define DT_UNKNOWN  0
+#define DT_REG      S_IFREG
+#define DT_DIR      S_IFDIR
+#define DT_FIFO     S_IFFIFO
+#define DT_SOCK     S_IFSOCK
+#define DT_CHR      S_IFCHR
+#define DT_BLK      S_IFBLK
+
+/* Macros for converting between st_mode and d_type */
+#define IFTODT(mode) ((mode) & S_IFMT)
+#define DTTOIF(type) (type)
+
+/*
+ * File type macros.  Note that block devices, sockets and links cannot be
+ * distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are
+ * only defined for compatibility.  These macros should always return false
+ * on Windows.
+ */
+#define        S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFFIFO)
+#define        S_ISDIR(mode)  (((mode) & S_IFMT) == S_IFDIR)
+#define        S_ISREG(mode)  (((mode) & S_IFMT) == S_IFREG)
+#define        S_ISLNK(mode)  (((mode) & S_IFMT) == S_IFLNK)
+#define        S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
+#define        S_ISCHR(mode)  (((mode) & S_IFMT) == S_IFCHR)
+#define        S_ISBLK(mode)  (((mode) & S_IFMT) == S_IFBLK)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef struct dirent
+{
+   char d_name[MAX_PATH + 1];                  /* File name */
+   size_t d_namlen;                            /* Length of name without \0 */
+   int d_type;                                 /* File type */
+} dirent;
+
+
+typedef struct DIR
+{
+   dirent           curentry;                  /* Current directory entry */
+   WIN32_FIND_DATAA find_data;                 /* Private file data */
+   int              cached;                    /* True if data is valid */
+   HANDLE           search_handle;             /* Win32 search handle */
+   char             patt[MAX_PATH + 3];        /* Initial directory name */
+} DIR;
+
+
+/* Forward declarations */
+static DIR *opendir(const char *dirname);
+static struct dirent *readdir(DIR *dirp);
+static int closedir(DIR *dirp);
+static void rewinddir(DIR* dirp);
+
+
+/* Use the new safe string functions introduced in Visual Studio 2005 */
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+# define DIRENT_STRNCPY(dest,src,size) strncpy_s((dest),(size),(src),_TRUNCATE)
+#else
+# define DIRENT_STRNCPY(dest,src,size) strncpy((dest),(src),(size))
+#endif
+
+/* Set errno variable */
+#if defined(_MSC_VER)
+#define DIRENT_SET_ERRNO(x) _set_errno (x)
+#else
+#define DIRENT_SET_ERRNO(x) (errno = (x))
+#endif
+
+
+/*****************************************************************************
+ * Open directory stream DIRNAME for read and return a pointer to the
+ * internal working area that is used to retrieve individual directory
+ * entries.
+ */
+static DIR *opendir(const char *dirname)
+{
+   DIR *dirp;
+
+   /* ensure that the resulting search pattern will be a valid file name */
+   if (dirname == NULL) {
+      DIRENT_SET_ERRNO (ENOENT);
+      return NULL;
+   }
+   if (strlen (dirname) + 3 >= MAX_PATH) {
+      DIRENT_SET_ERRNO (ENAMETOOLONG);
+      return NULL;
+   }
+
+   /* construct new DIR structure */
+   dirp = (DIR*) malloc (sizeof (struct DIR));
+   if (dirp != NULL) {
+      int error;
+
+      /*
+       * Convert relative directory name to an absolute one.  This
+       * allows rewinddir() to function correctly when the current working
+       * directory is changed between opendir() and rewinddir().
+       */
+      if (GetFullPathNameA (dirname, MAX_PATH, dirp->patt, NULL)) {
+         char *p;
+
+         /* append the search pattern "\\*\0" to the directory name */
+         p = strchr (dirp->patt, '\0');
+         if (dirp->patt < p  &&  *(p-1) != '\\'  &&  *(p-1) != ':') {
+           *p++ = '\\';
+         }
+         *p++ = '*';
+         *p = '\0';
+
+         /* open directory stream and retrieve the first entry */
+         dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->find_data);
+         if (dirp->search_handle != INVALID_HANDLE_VALUE) {
+            /* a directory entry is now waiting in memory */
+            dirp->cached = 1;
+            error = 0;
+         } else {
+            /* search pattern is not a directory name? */
+            DIRENT_SET_ERRNO (ENOENT);
+            error = 1;
+         }
+      } else {
+         /* buffer too small */
+         DIRENT_SET_ERRNO (ENOMEM);
+         error = 1;
+      }
+
+      if (error) {
+         free (dirp);
+         dirp = NULL;
+      }
+   }
+
+   return dirp;
+}
+
+
+/*****************************************************************************
+ * Read a directory entry, and return a pointer to a dirent structure
+ * containing the name of the entry in d_name field.  Individual directory
+ * entries returned by this very function include regular files,
+ * sub-directories, pseudo-directories "." and "..", but also volume labels,
+ * hidden files and system files may be returned.
+ */
+static struct dirent *readdir(DIR *dirp)
+{
+   DWORD attr;
+   if (dirp == NULL) {
+      /* directory stream did not open */
+      DIRENT_SET_ERRNO (EBADF);
+      return NULL;
+   }
+
+   /* get next directory entry */
+   if (dirp->cached != 0) {
+      /* a valid directory entry already in memory */
+      dirp->cached = 0;
+   } else {
+      /* get the next directory entry from stream */
+      if (dirp->search_handle == INVALID_HANDLE_VALUE) {
+         return NULL;
+      }
+      if (FindNextFileA (dirp->search_handle, &dirp->find_data) == FALSE) {
+         /* the very last entry has been processed or an error occured */
+         FindClose (dirp->search_handle);
+         dirp->search_handle = INVALID_HANDLE_VALUE;
+         return NULL;
+      }
+   }
+
+   /* copy as a multibyte character string */
+   DIRENT_STRNCPY ( dirp->curentry.d_name,
+             dirp->find_data.cFileName,
+             sizeof(dirp->curentry.d_name) );
+   dirp->curentry.d_name[MAX_PATH] = '\0';
+
+   /* compute the length of name */
+   dirp->curentry.d_namlen = strlen (dirp->curentry.d_name);
+
+   /* determine file type */
+   attr = dirp->find_data.dwFileAttributes;
+   if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
+      dirp->curentry.d_type = DT_CHR;
+   } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
+      dirp->curentry.d_type = DT_DIR;
+   } else {
+      dirp->curentry.d_type = DT_REG;
+   }
+   return &dirp->curentry;
+}
+
+
+/*****************************************************************************
+ * Close directory stream opened by opendir() function.  Close of the
+ * directory stream invalidates the DIR structure as well as any previously
+ * read directory entry.
+ */
+static int closedir(DIR *dirp)
+{
+   if (dirp == NULL) {
+      /* invalid directory stream */
+      DIRENT_SET_ERRNO (EBADF);
+      return -1;
+   }
+
+   /* release search handle */
+   if (dirp->search_handle != INVALID_HANDLE_VALUE) {
+      FindClose (dirp->search_handle);
+      dirp->search_handle = INVALID_HANDLE_VALUE;
+   }
+
+   /* release directory structure */
+   free (dirp);
+   return 0;
+}
+
+
+/*****************************************************************************
+ * Resets the position of the directory stream to which dirp refers to the
+ * beginning of the directory.  It also causes the directory stream to refer
+ * to the current state of the corresponding directory, as a call to opendir()
+ * would have done.  If dirp does not refer to a directory stream, the effect
+ * is undefined.
+ */
+static void rewinddir(DIR* dirp)
+{
+   if (dirp != NULL) {
+      /* release search handle */
+      if (dirp->search_handle != INVALID_HANDLE_VALUE) {
+         FindClose (dirp->search_handle);
+      }
+
+      /* open new search handle and retrieve the first entry */
+      dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->find_data);
+      if (dirp->search_handle != INVALID_HANDLE_VALUE) {
+         /* a directory entry is now waiting in memory */
+         dirp->cached = 1;
+      } else {
+         /* failed to re-open directory: no directory entry in memory */
+         dirp->cached = 0;
+      }
+   }
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /*DIRENT_H*/
index a8a02a8..5efead5 100644 (file)
@@ -4,6 +4,7 @@
  *
  * Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
  * Copyright 2010-2011 Vic Lee
+ * Copyright 2012      Gerald Richter
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -182,10 +183,12 @@ static void disk_file_set_fullpath(DISK_FILE* file, char* fullpath)
 
 static boolean disk_file_init(DISK_FILE* file, uint32 DesiredAccess, uint32 CreateDisposition, uint32 CreateOptions)
 {
-       const static int mode = S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH;
        struct STAT st;
        boolean exists;
-#ifndef WIN32
+#ifdef WIN32
+        const static int mode = _S_IREAD | _S_IWRITE ;
+#else
+        const static int mode = S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH;
        boolean largeFile = false;
 #endif
        int oflag = 0;
@@ -423,7 +426,8 @@ boolean disk_file_query_information(DISK_FILE* file, uint32 FsInformationClass,
 boolean disk_file_set_information(DISK_FILE* file, uint32 FsInformationClass, uint32 Length, STREAM* input)
 {
        char* s;
-       mode_t m;
+
+        mode_t m;
        uint64 size;
        char* fullpath;
        struct STAT st;
@@ -449,7 +453,9 @@ boolean disk_file_set_information(DISK_FILE* file, uint32 FsInformationClass, ui
                        tv[0].tv_usec = 0;
                        tv[1].tv_sec = (LastWriteTime > 0 ? FILE_TIME_RDP_TO_SYSTEM(LastWriteTime) : st.st_mtime);
                        tv[1].tv_usec = 0;
-                       futimes(file->fd, tv);
+#ifndef WIN32
+/* TODO on win32 */                        
+                        futimes(file->fd, tv);
 
                        if (FileAttributes > 0)
                        {
@@ -461,7 +467,8 @@ boolean disk_file_set_information(DISK_FILE* file, uint32 FsInformationClass, ui
                                if (m != st.st_mode)
                                        fchmod(file->fd, st.st_mode);
                        }
-                       break;
+#endif
+                        break;
 
                case FileEndOfFileInformation:
                        /* http://msdn.microsoft.com/en-us/library/cc232067.aspx */
@@ -492,14 +499,15 @@ boolean disk_file_set_information(DISK_FILE* file, uint32 FsInformationClass, ui
                        fullpath = disk_file_combine_fullpath(file->basepath, s);
                        xfree(s);
 
-                       if (rename(file->fullpath, fullpath) == 0)
+                       /* TODO rename does not work on win32 */
+                        if (rename(file->fullpath, fullpath) == 0)
                        {
                                DEBUG_SVC("renamed %s to %s", file->fullpath, fullpath);
                                disk_file_set_fullpath(file, fullpath);
                        }
                        else
                        {
-                               DEBUG_WARN("rename %s to %s failed", file->fullpath, fullpath);
+                               DEBUG_WARN("rename %s to %s failed, errno = %d", file->fullpath, fullpath, errno);
                                free(fullpath);
                                return false;
                        }
index 2d85bf8..35db89a 100644 (file)
@@ -4,6 +4,7 @@
  *
  * Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
  * Copyright 2010-2011 Vic Lee
+ * Copyright 2012      Gerald Richter
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#ifndef _WIN32
-#include <dirent.h>
+#include "dirent.h"
+#ifdef _WIN32
+#include <direct.h>
+#include <io.h>
+#include "statvfs.h"
+#else
 #include <sys/statvfs.h>
 #endif
 
 #ifdef _WIN32
 #define STAT stat
-#define OPEN open
-#define LSEEK lseek
+#define OPEN _open
+#define close _close
+#define read  _read
+#define write _write
+#define LSEEK _lseek
 #define FSTAT fstat
 #define STATVFS statvfs
+#define mkdir(a,b) _mkdir(a)
+#define rmdir _rmdir
+#define unlink(a) _unlink(a)
+#define ftruncate(a,b) _chsize(a,b)
+
+typedef uint32 ssize_t ;
+typedef uint32 mode_t ;
+
 #elif defined(__APPLE__) || defined(__FreeBSD__)
 #define STAT stat
 #define OPEN open
index a6203ec..504df2a 100644 (file)
@@ -647,7 +647,11 @@ static void disk_free(DEVICE* device)
        xfree(disk);
 }
 
+#ifdef WITH_STATIC_PLUGINS
+int disk_entry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
+#else
 int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
+#endif
 {
        char* name;
        char* path;
diff --git a/channels/rdpdr/client/disk/statvfs.c b/channels/rdpdr/client/disk/statvfs.c
new file mode 100644 (file)
index 0000000..063b0e9
--- /dev/null
@@ -0,0 +1,67 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol client.
+ * statvfs emulation für windows
+ *
+ * Copyright 2012 Gerald Richter
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "statvfs.h"
+#include <windows.h>
+#include <string.h>
+#include <malloc.h>
+
+#ifdef __cplusplus
+extern "C" { 
+#endif 
+int statvfs(const char *path, struct statvfs *buf)
+    {
+       DWORD lpSectorsPerCluster;
+       DWORD lpBytesPerSector;
+       DWORD lpNumberOfFreeClusters;
+       DWORD lpTotalNumberOfClusters;
+       
+       BOOL res;
+
+       int len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
+       LPWSTR unicodestr = (LPWSTR)malloc(len); // free() nicht vergessen!
+       MultiByteToWideChar(CP_ACP, 0, path, -1, unicodestr, len);
+
+       res = GetDiskFreeSpace(unicodestr,
+               &lpSectorsPerCluster,
+               &lpBytesPerSector,
+               &lpNumberOfFreeClusters,
+               &lpTotalNumberOfClusters);
+
+       
+    buf->f_bsize = lpBytesPerSector;                                   /* file system block size */
+    buf->f_frsize=0;                                                                           /* fragment size */
+    buf->f_blocks=lpTotalNumberOfClusters;                     /* size of fs in f_frsize units */
+    buf->f_bfree=lpNumberOfFreeClusters;                       /* # free blocks */
+    buf->f_bavail=lpNumberOfFreeClusters;                      /* # free blocks for unprivileged users */
+    buf->f_files=0;                                                                    /* # inodes */
+    buf->f_ffree=0;                                                                            /* # free inodes */
+    buf->f_favail=0;                                                                           /* # free inodes for unprivileged users */
+    buf->f_fsid=lpNumberOfFreeClusters & 0xffff;       /* file system ID */
+    buf->f_flag=0;                                                                             /* mount flags */
+    buf->f_namemax=250;                                                                /* maximum filename length */
+       
+       return res;
+    }
+    
+#ifdef __cplusplus
+} 
+#endif 
\ No newline at end of file
diff --git a/channels/rdpdr/client/disk/statvfs.h b/channels/rdpdr/client/disk/statvfs.h
new file mode 100644 (file)
index 0000000..fd6fb2c
--- /dev/null
@@ -0,0 +1,46 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol client.
+ * statvfs emulation für windows
+ *
+ * Copyright 2012 Gerald Richter
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef __cplusplus
+extern "C" { 
+#endif 
+typedef unsigned long long fsblkcnt_t;
+typedef unsigned long long fsfilcnt_t;
+
+struct statvfs {
+    unsigned long  f_bsize;    /* file system block size */
+    unsigned long  f_frsize;   /* fragment size */
+    fsblkcnt_t     f_blocks;   /* size of fs in f_frsize units */
+    fsblkcnt_t     f_bfree;    /* # free blocks */
+    fsblkcnt_t     f_bavail;   /* # free blocks for unprivileged users */
+    fsfilcnt_t     f_files;    /* # inodes */
+    fsfilcnt_t     f_ffree;    /* # free inodes */
+    fsfilcnt_t     f_favail;   /* # free inodes for unprivileged users */
+    unsigned long  f_fsid;     /* file system ID */
+    unsigned long  f_flag;     /* mount flags */
+    unsigned long  f_namemax;  /* maximum filename length */
+};
+
+
+int statvfs(const char *path, struct statvfs *buf);
+#ifdef __cplusplus
+}
+#endif 
\ No newline at end of file
index 4b05882..527ab1b 100644 (file)
@@ -1,48 +1,51 @@
-# FreeRDP: A Remote Desktop Protocol Client\r
-# FreeRDP Windows cmake build script\r
-#\r
-# Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>\r
-#\r
-# Licensed under the Apache License, Version 2.0 (the "License");\r
-# you may not use this file except in compliance with the License.\r
-# You may obtain a copy of the License at\r
-#\r
-#     http://www.apache.org/licenses/LICENSE-2.0\r
-#\r
-# Unless required by applicable law or agreed to in writing, software\r
-# distributed under the License is distributed on an "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-# See the License for the specific language governing permissions and\r
-# limitations under the License.\r
-\r
-set(FREERDP_CLIENT_WINDOWS_SRCS\r
-       wf_gdi.c\r
-       wf_gdi.h\r
-       wf_event.c\r
-       wf_event.h\r
-       wf_graphics.c\r
-       wf_graphics.h\r
-       wf_cliprdr.c\r
-       wf_cliprdr.h\r
-       wf_window.c\r
-       wf_window.h\r
-       wf_rail.c\r
-       wf_rail.h\r
-       wfreerdp.c\r
-       wfreerdp.h)\r
-\r
-add_executable(wfreerdp WIN32 ${FREERDP_CLIENT_WINDOWS_SRCS})\r
-\r
-if(WITH_MONOLITHIC_BUILD)\r
-       set(FREERDP_CLIENT_WINDOWS_LIBS ${FREERDP_CLIENT_WINDOWS_LIBS} freerdp)\r
-else()\r
-       set(FREERDP_CLIENT_WINDOWS_LIBS ${FREERDP_CLIENT_WINDOWS_LIBS}\r
-               freerdp-core\r
-               freerdp-gdi\r
-               freerdp-codec\r
-               freerdp-channels\r
-               freerdp-utils)\r
-endif()\r
-\r
-target_link_libraries(wfreerdp ${FREERDP_CLIENT_WINDOWS_LIBS})\r
-install(TARGETS wfreerdp DESTINATION ${CMAKE_INSTALL_BINDIR})\r
+# FreeRDP: A Remote Desktop Protocol Client
+# FreeRDP Windows cmake build script
+#
+# Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set(FREERDP_CLIENT_WINDOWS_SRCS
+       wf_gdi.c
+       wf_gdi.h
+       wf_event.c
+       wf_event.h
+       wf_graphics.c
+       wf_graphics.h
+       wf_cliprdr.c
+       wf_cliprdr.h
+       wf_window.c
+       wf_window.h
+       wf_rail.c
+       wf_rail.h
+       wfreerdp.c
+       wfreerdp.h)
+
+add_executable(wfreerdp WIN32 ${FREERDP_CLIENT_WINDOWS_SRCS})
+
+if(WITH_MONOLITHIC_BUILD)
+       set(FREERDP_CLIENT_WINDOWS_LIBS ${FREERDP_CLIENT_WINDOWS_LIBS} freerdp)
+    if(WITH_RDPDR)
+        set(FREERDP_CLIENT_WINDOWS_LIBS ${FREERDP_CLIENT_WINDOWS_LIBS} rdpdr disk)
+    endif()
+else()
+       set(FREERDP_CLIENT_WINDOWS_LIBS ${FREERDP_CLIENT_WINDOWS_LIBS}
+               freerdp-core
+               freerdp-gdi
+               freerdp-codec
+               freerdp-channels
+               freerdp-utils)
+endif()
+
+target_link_libraries(wfreerdp ${FREERDP_CLIENT_WINDOWS_LIBS})
+install(TARGETS wfreerdp DESTINATION ${CMAKE_INSTALL_BINDIR})
index 17fc9a9..f44572c 100644 (file)
@@ -41,6 +41,8 @@
 #include <freerdp/utils/args.h>
 #include <freerdp/utils/event.h>
 #include <freerdp/utils/memory.h>
+#include <freerdp/utils/load_plugin.h>
+#include <freerdp/utils/svc_plugin.h>
 #include <freerdp/channels/channels.h>
 
 #include "wf_gdi.h"
@@ -631,6 +633,12 @@ static DWORD WINAPI kbd_thread_func(LPVOID lpParam)
        return (DWORD) NULL;
 }
 
+#ifdef WITH_RDPDR
+DEFINE_SVC_PLUGIN_ENTRY(rdpdr) ;
+DEFINE_DEV_PLUGIN_ENTRY(disk) ;
+#endif
+
+
 INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
 {
        freerdp* instance;
@@ -688,7 +696,12 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
        instance->context->argc = __argc;
        instance->context->argv = __argv;
 
-       if (!CreateThread(NULL, 0, kbd_thread_func, NULL, 0, NULL))
+#ifdef WITH_RDPDR
+        REGISTER_SVC_PLUGIN_ENTRY(rdpdr) ;
+        REGISTER_DEV_PLUGIN_ENTRY(disk) ;
+#endif
+
+        if (!CreateThread(NULL, 0, kbd_thread_func, NULL, 0, NULL))
                printf("error creating keyboard handler thread");
 
        //while (1)
index 74df3e6..d9c4d36 100644 (file)
@@ -27,6 +27,7 @@
 
 #cmakedefine HAVE_TM_GMTOFF
 
+
 /* Options */
 #cmakedefine WITH_PROFILER
 #cmakedefine WITH_SSE2
 #cmakedefine WITH_JPEG
 #cmakedefine WITH_WIN8
 
+/* Plugins */
+#cmakedefine WITH_STATIC_PLUGINS
+#cmakedefine WITH_RDPDR
+
+
 /* Debug */
 #cmakedefine WITH_DEBUG_CERTIFICATE
 #cmakedefine WITH_DEBUG_CHANNELS
index 4f593d1..7c2a061 100644 (file)
@@ -62,7 +62,13 @@ FREERDP_API int svc_plugin_send_event(rdpSvcPlugin* plugin, RDP_EVENT* event);
 
 #ifdef WITH_STATIC_PLUGINS
 #define DEFINE_SVC_PLUGIN_ENTRY(_prefix) int _prefix##_entry(PCHANNEL_ENTRY_POINTS pEntryPoints)
+#define DEFINE_DEV_PLUGIN_ENTRY(_prefix) int _prefix##_entry(PCHANNEL_ENTRY_POINTS pEntryPoints)
+#define REGISTER_SVC_PLUGIN_ENTRY(_prefix)  freerdp_register_static_plugin(#_prefix, "VirtualChannelEntry", _prefix##_entry) 
+#define REGISTER_DEV_PLUGIN_ENTRY(_prefix)  freerdp_register_static_plugin(#_prefix, "DeviceServiceEntry", _prefix##_entry) 
 #else
+#define REGISTER_DEV_PLUGIN_ENTRY(_prefix)
+#define REGISTER_SVC_PLUGIN_ENTRY(_prefix)
+#define DEFINE_DEV_PLUGIN_ENTRY(_prefix)
 #define DEFINE_SVC_PLUGIN_ENTRY(_prefix) int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
 #endif