set(MODULE_PREFIX "CHANNEL_DEVICE_DISK")
set(${MODULE_PREFIX}_SRCS
- statvfs.c
disk_file.c
disk_file.h
disk_main.c)
+
+if(WIN32)
+ set(${MODULE_PREFIX}_SRCS
+ statvfs.c
+ statvfs.h
+ dirent.h)
+endif()
include_directories(..)
boolean ret = true;
dir = opendir(path);
+
if (dir == NULL)
return false;
pdirent = readdir(dir);
+
while (pdirent)
{
if (strcmp(pdirent->d_name, ".") == 0 || strcmp(pdirent->d_name, "..") == 0)
xfree(file->fullpath);
file->fullpath = fullpath;
file->filename = strrchr(file->fullpath, '/');
+
if (file->filename == NULL)
file->filename = file->fullpath;
else
#include <sys/types.h>
#include <sys/stat.h>
-#include "dirent.h"
#ifdef _WIN32
#include <direct.h>
#include <io.h>
+#include "dirent.h"
#include "statvfs.h"
#else
+#include <dirent.h>
#include <sys/statvfs.h>
#endif
* limitations under the License.
*/
-#include "statvfs.h"
-#include <windows.h>
#include <string.h>
#include <malloc.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
+#include <winpr/crt.h>
+#include <winpr/windows.h>
+
+#include "statvfs.h"
+
int statvfs(const char *path, struct statvfs *buf)
- {
+{
+ BOOL res;
+ int len;
+ LPWSTR unicodestr;
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!
+ len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
+ unicodestr = (LPWSTR) malloc(len);
MultiByteToWideChar(CP_ACP, 0, path, -1, unicodestr, len);
- res = GetDiskFreeSpace(unicodestr,
- &lpSectorsPerCluster,
- &lpBytesPerSector,
- &lpNumberOfFreeClusters,
- &lpTotalNumberOfClusters);
+ 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 */
+ 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
+}
/**
* FreeRDP: A Remote Desktop Protocol client.
- * statvfs emulation für windows
+ * statvfs emulation for windows
*
* Copyright 2012 Gerald Richter
*
* limitations under the License.
*/
+#ifndef RDPDR_DISK_STATVFS_H
+#define RDPDR_DISK_STATVFS_H
+
#ifdef __cplusplus
extern "C" {
#endif
-
+
typedef unsigned long long fsblkcnt_t;
typedef unsigned long long fsfilcnt_t;
unsigned long f_namemax; /* maximum filename length */
};
-
int statvfs(const char *path, struct statvfs *buf);
+
#ifdef __cplusplus
}
#endif
-
\ No newline at end of file
+
+#endif /* RDPDR_DISK_STATVFS_H */
/* Extensions */
ALIGN64 int num_extensions;
ALIGN64 struct rdp_ext_set extensions[16];
-
- /* Proxy */
- ALIGN64 char * proxy_host;
- ALIGN64 int proxy_port;
-
};
typedef struct rdp_settings rdpSettings;
}
else
{
- if(transport->settings->proxy_host)
- {
- status = tcp_connect(transport->tcp, transport->settings->proxy_host, transport->settings->proxy_port);
- if(status)
- {
- char buf[8192];
- int bytes_read;
- int n = snprintf(buf,sizeof(buf), "CONNECT %s:%d HTTP/1.0\r\n\r\n", hostname, port);
- tcp_write(transport->tcp, buf, n);
-
- bytes_read = tcp_read(transport->tcp, buf, sizeof(buf));
- if(bytes_read > 12)
- {
- if( (strncmp(buf,"HTTP/1.0 200", 12) == 0) ||
- (strncmp(buf,"HTTP/1.1 200", 12) == 0) )
- {
- printf("Connected via proxy\n");
- while (bytes_read > 0)
- {
- if (bytes_read > 4 && strncmp(buf + bytes_read - 4, "\r\n\r\n", 4) == 0)
- break ;
- bytes_read = tcp_read(transport->tcp, buf, sizeof(buf) - 1) ;
- }
- }
- else
- {
- printf("Proxy connection failed: %s\n", buf);
- return false;
- }
- }
- else
- {
- return false;
- }
- }
- }
- else
- {
- status = tcp_connect(transport->tcp, hostname, port);
- }
+ status = tcp_connect(transport->tcp, hostname, port);
}
return status;
#include <freerdp/utils/stream.h>
#include <freerdp/utils/wait_obj.h>
-#ifdef _WIN32
-#ifndef snprintf
-#define snprintf _snprintf
-#endif
-#endif
-
typedef boolean (*TransportRecv) (rdpTransport* transport, STREAM* stream, void* extra);
struct rdp_transport
{
int t;
char* p;
- char* cp;
int i, j;
int index = 1;
int num_extensions = 0;
" --no-salted-checksum: disable salted checksums with Standard RDP encryption\n"
" --pcid: preconnection id\n"
" --pcb: preconnection blob\n"
- " --proxy: <host>:<port> connect via http proxy\n"
" --version: print version information\n"
"\n", argv[0]);
return FREERDP_ARGS_PARSE_HELP; /* TODO: What is the correct return? */
printf("This is FreeRDP version %s (git %s)\n", FREERDP_VERSION_FULL, GIT_REVISION);
return FREERDP_ARGS_PARSE_VERSION;
}
- else if (strcmp("--proxy", argv[index]) == 0)
- {
- index++;
- if (index == argc)
- {
- printf("missing proxy\n");
- return FREERDP_ARGS_PARSE_FAILURE;
- }
- // split in proxy and port
- settings->proxy_host = xstrdup(argv[index]);
- cp = strrchr(settings->proxy_host, ':');
- if( ! cp )
- {
- printf("illegal proxy spec\n");
- return FREERDP_ARGS_PARSE_FAILURE;
- }
- *cp = 0;
- settings->proxy_port = atoi(cp+1);
- }
else if (argv[index][0] != '-')
{
freerdp_parse_hostname(settings, argv[index]);