freerdp: fix build on Linux

This commit is contained in:
Marc-André Moreau
2012-10-02 10:57:39 -04:00
parent 84b21a61c4
commit 412f5dc452
9 changed files with 45 additions and 112 deletions

View File

@@ -21,10 +21,16 @@ 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)
if(WIN32)
set(${MODULE_PREFIX}_SRCS
statvfs.c
statvfs.h
dirent.h)
endif()
include_directories(..)

View File

@@ -119,10 +119,12 @@ static boolean disk_file_remove_dir(const char* path)
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)
@@ -175,6 +177,7 @@ static void disk_file_set_fullpath(DISK_FILE* file, char* fullpath)
xfree(file->fullpath);
file->fullpath = fullpath;
file->filename = strrchr(file->fullpath, '/');
if (file->filename == NULL)
file->filename = file->fullpath;
else

View File

@@ -25,12 +25,13 @@
#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

View File

@@ -17,51 +17,41 @@
* 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
}

View File

@@ -1,6 +1,6 @@
/**
* FreeRDP: A Remote Desktop Protocol client.
* statvfs emulation für windows
* statvfs emulation for windows
*
* Copyright 2012 Gerald Richter
*
@@ -17,10 +17,13 @@
* 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;
@@ -38,9 +41,10 @@ struct statvfs {
unsigned long f_namemax; /* maximum filename length */
};
int statvfs(const char *path, struct statvfs *buf);
#ifdef __cplusplus
}
#endif
#endif /* RDPDR_DISK_STATVFS_H */

View File

@@ -477,11 +477,6 @@ struct rdp_settings
/* 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;

View File

@@ -204,46 +204,7 @@ boolean transport_connect(rdpTransport* transport, const char* hostname, uint16
}
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;

View File

@@ -43,12 +43,6 @@ typedef struct rdp_transport rdpTransport;
#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

View File

@@ -91,7 +91,6 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
{
int t;
char* p;
char* cp;
int i, j;
int index = 1;
int num_extensions = 0;
@@ -164,7 +163,6 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
" --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? */
@@ -818,25 +816,6 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
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]);