Merge pull request #750 from FreeRDP/channels

WinPR + Channels + CMake
This commit is contained in:
Marc-André Moreau 2012-10-02 10:32:33 -07:00
commit cebb3b6267
149 changed files with 3445 additions and 2153 deletions

9
.gitignore vendored
View File

@ -6,9 +6,11 @@ install_manifest.txt
CTestTestfile.cmake
freerdp.pc
Makefile
Testing
cmake_install.cmake
CPackConfig.cmake
CPackSourceConfig.cmake
DartConfiguration.tcl
# Eclipse
*.project
@ -25,9 +27,12 @@ client/X11/xfreerdp.1
# Windows
*.vcxproj
*.vcxproj.*
*.vcproj
*.vcproj.*
*.sdf
*.sln
*.suo
*.ncb
*.opensdf
ipch
Debug
@ -41,9 +46,9 @@ RelWithDebInfo
cunit/test_freerdp
client/X11/xfreerdp
client/Mac/xcode
client/test/freerdp-test
client/Sample/sfreerdp
client/DirectFB/dfreerdp
server/test/tfreerdp-server
server/Sample/sfreerdp-server
server/X11/xfreerdp-server
xcode

View File

@ -49,6 +49,9 @@ include(GetGitRevisionDescription)
git_describe(GIT_REVISION --match "[0-9]*" --abbrev=4 --tags --always)
message(STATUS "Git Revision ${GIT_REVISION}")
# Turn on solution folders (2.8.4+)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Default to release build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
@ -59,6 +62,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)
@ -185,6 +192,14 @@ add_definitions("-DHAVE_CONFIG_H")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/freerdp/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/include/freerdp/config.h)
# Unit Tests
INCLUDE(CTest)
if(BUILD_TESTING)
enable_testing()
endif()
# WinPR
set(WINPR_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/winpr/include")
include_directories(${WINPR_INCLUDE_DIR})
@ -201,9 +216,9 @@ endif()
#find_optional_package(IPP)
# Build CUnit
find_optional_package(CUnit)
if(WITH_CUNIT)
enable_testing()
add_subdirectory(cunit)
endif()

View File

@ -33,4 +33,3 @@ endforeach(FILEPATH)
if(WITH_SERVER_CHANNELS)
add_subdirectory(server)
endif()

View File

@ -24,6 +24,5 @@ set(${MODULE_PREFIX}_SRCS
if(WITH_MONOLITHIC_BUILD)
set(${MODULE_PREFIX}_LIBS freerdp PARENT_SCOPE)
else()
set(${MODULE_PREFIX}_LIBS freerdp-utils PARENT_SCOPE)
set(${MODULE_PREFIX}_LIBS freerdp-utils freerdp-channels PARENT_SCOPE)
endif()

View File

@ -40,9 +40,9 @@ endif()
install(TARGETS rdpdr DESTINATION ${FREERDP_PLUGIN_PATH})
add_subdirectory(disk)
add_subdirectory(printer)
if(NOT WIN32)
add_subdirectory(disk)
add_subdirectory(printer)
add_subdirectory(parallel)
add_subdirectory(serial)
endif()

View File

@ -24,6 +24,13 @@ set(${MODULE_PREFIX}_SRCS
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

@ -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*/

View 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.
@ -118,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)
@ -174,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
@ -182,10 +186,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 +429,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 +456,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 +470,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 +502,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;
}

View 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.
@ -24,17 +25,33 @@
#include <sys/types.h>
#include <sys/stat.h>
#ifndef _WIN32
#ifdef _WIN32
#include <direct.h>
#include <io.h>
#include "dirent.h"
#include "statvfs.h"
#else
#include <dirent.h>
#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

View File

@ -263,7 +263,7 @@ static void disk_process_irp_read(DISK_DEVICE* disk, IRP* irp)
if (Length > 0)
{
stream_check_size(irp->output, Length);
stream_check_size(irp->output, (int)Length);
stream_write(irp->output, buffer, Length);
}
@ -647,15 +647,25 @@ static void disk_free(DEVICE* device)
xfree(disk);
}
int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
char* name;
char* path;
int i, length;
DISK_DEVICE* disk;
name = (char*) pEntryPoints->plugin_data->data[1];
path = (char*) pEntryPoints->plugin_data->data[2];
void disk_register_disk_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, char *name, char *path)
{
DISK_DEVICE* disk;
int i, length ;
#ifdef WIN32
/*
* We cannot enter paths like c:\ because : is an arg separator
* thus, paths are entered as c+\ and the + is substituted here
*/
if ( path[1] == '+' )
{
if ( (path[0]>='a' && path[0]<='z') || (path[0]>='A' && path[0]<='Z') )
{
path[1] = ':';
}
}
#endif
if (name[0] && path[0])
{
@ -683,8 +693,65 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) disk);
ResumeThread(disk->thread);
ResumeThread(disk->thread);
}
return 0;
}
#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;
#ifdef WIN32
char devlist[512], buf[512];
char *dev;
int len ;
#endif
name = (char*) pEntryPoints->plugin_data->data[1];
path = (char*) pEntryPoints->plugin_data->data[2];
#ifndef WIN32
disk_register_disk_path(pEntryPoints, name, path);
#else
/* Special case: path[0] == '*' -> export all drives */
/* Special case: path[0] == '%' -> user home dir */
if( path[0] == '%' )
{
_snprintf(buf, sizeof(buf), "%s\\", getenv("USERPROFILE"));
disk_register_disk_path(pEntryPoints, name, xstrdup(buf));
}
else if( path[0] == '*' )
{
int i;
/* Enumerate all devices: */
GetLogicalDriveStringsA(sizeof(devlist) - 1, devlist);
for (dev = devlist, i = 0; *dev; dev += 4, i++)
{
if (*dev > 'B')
{
/* Suppress disk drives A and B to avoid pesty messages */
_snprintf(buf, sizeof(buf) - 4, "%s", name);
len = strlen(buf);
buf[len] = '_';
buf[len + 1] = dev[0];
buf[len + 2] = 0;
buf[len + 3] = 0;
disk_register_disk_path(pEntryPoints, xstrdup(buf), xstrdup(dev));
}
}
}
else
{
disk_register_disk_path(pEntryPoints, name, path);
}
#endif
return 0;
}

View File

@ -0,0 +1,57 @@
/**
* 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 <string.h>
#include <malloc.h>
#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;
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);
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;
}

View File

@ -0,0 +1,50 @@
/**
* FreeRDP: A Remote Desktop Protocol client.
* statvfs emulation for 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.
*/
#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;
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
#endif /* RDPDR_DISK_STATVFS_H */

View File

@ -31,6 +31,13 @@ if(WITH_CUPS)
add_definitions(-DWITH_CUPS)
endif()
if(WIN32)
set(PRINTER_SRCS
${PRINTER_SRCS}
printer_win.c
printer_win.h)
endif()
include_directories(..)
add_library(printer ${PRINTER_SRCS})

View File

@ -40,6 +40,10 @@
#include "printer_main.h"
#ifdef WIN32
#include "printer_win.h"
#endif
typedef struct _PRINTER_DEVICE PRINTER_DEVICE;
struct _PRINTER_DEVICE
{
@ -294,7 +298,11 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri
freerdp_thread_start(printer_dev->thread, printer_thread_func, printer_dev);
}
#ifdef WITH_STATIC_PLUGINS
int printer_entry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
#else
int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
#endif
{
rdpPrinterDriver* driver = NULL;
rdpPrinter** printers;
@ -305,6 +313,9 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
#ifdef WITH_CUPS
driver = printer_cups_get_driver();
#endif
#ifdef WIN32
driver = printer_win_get_driver();
#endif
if (driver == NULL)
{

View File

@ -0,0 +1,283 @@
/**
* FreeRDP: A Remote Desktop Protocol client.
* Print Virtual Channel - WIN driver
*
* 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 <windows.h>
#include <winspool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "config.h"
#include <freerdp/utils/memory.h>
#include <freerdp/utils/svc_plugin.h>
#include "rdpdr_types.h"
#include "printer_main.h"
#include "printer_win.h"
typedef struct rdp_win_printer_driver rdpWinPrinterDriver;
typedef struct rdp_win_printer rdpWinPrinter;
typedef struct rdp_win_print_job rdpWinPrintJob;
struct rdp_win_printer_driver
{
rdpPrinterDriver driver;
int id_sequence;
};
struct rdp_win_printer
{
rdpPrinter printer;
HANDLE hPrinter;
rdpWinPrintJob* printjob;
};
struct rdp_win_print_job
{
rdpPrintJob printjob;
DOC_INFO_1 di;
DWORD handle;
void* printjob_object;
int printjob_id;
};
static void printer_win_get_printjob_name(char* buf, int size)
{
time_t tt;
struct tm* t;
DEBUG_WINPR("");
tt = time(NULL);
t = localtime(&tt);
snprintf(buf, size - 1, "FreeRDP Print Job %d%02d%02d%02d%02d%02d",
t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
t->tm_hour, t->tm_min, t->tm_sec);
DEBUG_WINPR("buf: %s", buf);
}
static void printer_win_write_printjob(rdpPrintJob* printjob, uint8* data, int size)
{
rdpWinPrintJob* win_printjob = (rdpWinPrintJob*)printjob;
LPVOID pBuf = data;
DWORD cbBuf = size;
DWORD pcWritten;
if( ! WritePrinter( ((rdpWinPrinter*)printjob->printer)->hPrinter, pBuf, cbBuf, &pcWritten ) )
DEBUG_WINPR("WritePrinter failed");
;
}
static void printer_win_close_printjob(rdpPrintJob* printjob)
{
rdpWinPrintJob* win_printjob = (rdpWinPrintJob*)printjob;
DEBUG_WINPR("");
if ( ! EndPagePrinter( ((rdpWinPrinter*)printjob->printer)->hPrinter ) )
DEBUG_WINPR("EndPagePrinter failed");;
if ( ! ClosePrinter( ((rdpWinPrinter*)printjob->printer)->hPrinter ) )
DEBUG_WINPR("ClosePrinter failed");;
((rdpWinPrinter*)printjob->printer)->printjob = NULL;
xfree(win_printjob) ;
}
static rdpPrintJob* printer_win_create_printjob(rdpPrinter* printer, uint32 id)
{
rdpWinPrinter* win_printer = (rdpWinPrinter*)printer;
rdpWinPrintJob* win_printjob;
DEBUG_WINPR("");
if (win_printer->printjob != NULL)
return NULL;
win_printjob = xnew(rdpWinPrintJob);
win_printjob->printjob.id = id;
win_printjob->printjob.printer = printer;
win_printjob->di.pDocName = L"FREERDPjob";
win_printjob->di.pDatatype= NULL;
win_printjob->di.pOutputFile = NULL;
win_printjob->handle = StartDocPrinter(win_printer->hPrinter, 1, (LPBYTE)&(win_printjob->di) );
if(! win_printjob->handle) DEBUG_WINPR("StartDocPrinter failed");
if ( ! StartPagePrinter(win_printer->hPrinter) )
DEBUG_WINPR("ClosePrinter failed");
win_printjob->printjob.Write = printer_win_write_printjob;
win_printjob->printjob.Close = printer_win_close_printjob;
win_printer->printjob = win_printjob;
return (rdpPrintJob*)win_printjob;
}
static rdpPrintJob* printer_win_find_printjob(rdpPrinter* printer, uint32 id)
{
rdpWinPrinter* win_printer = (rdpWinPrinter*)printer;
DEBUG_WINPR("");
if (win_printer->printjob == NULL)
return NULL;
if (win_printer->printjob->printjob.id != id)
return NULL;
return (rdpPrintJob*)win_printer->printjob;
}
static void printer_win_free_printer(rdpPrinter* printer)
{
rdpWinPrinter* win_printer = (rdpWinPrinter*)printer;
DEBUG_WINPR("");
if (win_printer->printjob)
win_printer->printjob->printjob.Close((rdpPrintJob*)win_printer->printjob);
xfree(printer->name);
xfree(printer);
}
static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver, const char* name, const wchar_t* drivername, boolean is_default)
{
rdpWinPrinter* win_printer;
wchar_t wname[256];
DWORD needed;
PRINTER_INFO_2 *prninfo=NULL;
size_t charsConverted;
DEBUG_WINPR("");
win_printer = xnew(rdpWinPrinter);
win_printer->printer.id = win_driver->id_sequence++;
win_printer->printer.name = xstrdup(name);
win_printer->printer.is_default = is_default;
win_printer->printer.CreatePrintJob = printer_win_create_printjob;
win_printer->printer.FindPrintJob = printer_win_find_printjob;
win_printer->printer.Free = printer_win_free_printer;
swprintf(wname, 256, L"%hs", name);
OpenPrinter(wname, &(win_printer->hPrinter), NULL);
DEBUG_WINPR("handle: 0x%08X", win_printer->hPrinter);
GetPrinter(win_printer->hPrinter, 2, (LPBYTE) prninfo, 0, &needed);
prninfo = (PRINTER_INFO_2*) GlobalAlloc(GPTR,needed);
GetPrinter(win_printer->hPrinter, 2, (LPBYTE) prninfo, needed, &needed);
win_printer->printer.driver = xmalloc(1000);
wcstombs_s(&charsConverted, win_printer->printer.driver, 1000, prninfo->pDriverName, _TRUNCATE);
return (rdpPrinter*)win_printer;
}
static rdpPrinter** printer_win_enum_printers(rdpPrinterDriver* driver)
{
rdpPrinter** printers;
int num_printers;
int i;
char pname[1000];
size_t charsConverted;
PRINTER_INFO_2 *prninfo=NULL;
DWORD needed, returned;
DEBUG_WINPR("");
//find required size for the buffer
EnumPrinters(PRINTER_ENUM_LOCAL|PRINTER_ENUM_CONNECTIONS, NULL, 2, NULL, 0, &needed, &returned);
//allocate array of PRINTER_INFO structures
prninfo = (PRINTER_INFO_2*) GlobalAlloc(GPTR,needed);
//call again
if ( !EnumPrinters(PRINTER_ENUM_LOCAL|PRINTER_ENUM_CONNECTIONS, NULL, 2, (LPBYTE) prninfo, needed, &needed, &returned) ) {
DEBUG_WINPR("EnumPrinters failed");
} ; /* eRROR... */
DEBUG_WINPR("printers found: %d", returned);
printers = (rdpPrinter**)xzalloc(sizeof(rdpPrinter*) * (returned + 1));
num_printers = 0;
for (i = 0; i < (int)returned; i++)
{
wcstombs_s(&charsConverted, pname, 1000, prninfo[i].pPrinterName, _TRUNCATE);
printers[num_printers++] = printer_win_new_printer((rdpWinPrinterDriver*)driver,
pname, prninfo[i].pDriverName, 0);
}
GlobalFree(prninfo);
return printers;
}
static rdpPrinter* printer_win_get_printer(rdpPrinterDriver* driver, const char* name)
{
rdpWinPrinterDriver* win_driver = (rdpWinPrinterDriver*)driver;
rdpPrinter *myPrinter = NULL;
DEBUG_WINPR("printer %s", name);
myPrinter = printer_win_new_printer(win_driver, name, L"", win_driver->id_sequence == 1 ? true : false);
return myPrinter;
}
static rdpWinPrinterDriver* win_driver = NULL;
rdpPrinterDriver* printer_win_get_driver(void)
{
DEBUG_WINPR("");
if (win_driver == NULL)
{
win_driver = xnew(rdpWinPrinterDriver);
win_driver->driver.EnumPrinters = printer_win_enum_printers;
win_driver->driver.GetPrinter = printer_win_get_printer;
win_driver->id_sequence = 1;
//#ifdef _win_API_1_4
// DEBUG_SVC("using win API 1.4");
//#else
// DEBUG_SVC("using win API 1.2");
//#endif
}
return (rdpPrinterDriver*)win_driver;
}

View File

@ -1,8 +1,8 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Basic Encoding Rules (BER) Unit Tests
* FreeRDP: A Remote Desktop Protocol client.
* Print Virtual Channel - win driver
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* 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.
@ -17,12 +17,21 @@
* limitations under the License.
*/
#include "test_freerdp.h"
#ifndef __PRINTER_WIN_H
#define __PRINTER_WIN_H
int init_ber_suite(void);
int clean_ber_suite(void);
int add_ber_suite(void);
void test_ber_write_length(void);
void test_ber_write_universal_tag(void);
void test_ber_write_application_tag(void);
rdpPrinterDriver* printer_win_get_driver(void);
#ifdef WITH_DEBUG_WINPR
#define DEBUG_WINPR(fmt, ...) DEBUG_CLASS(WINPR, fmt, ## __VA_ARGS__)
#else
#define DEBUG_WINPR(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__)
#endif
#endif
#ifdef WIN32
#define snprintf _snprintf
#endif

View File

@ -28,12 +28,14 @@
#include <string.h>
#include <unistd.h>
#include <strings.h>
#include <semaphore.h>
#include <pthread.h>
#include <semaphore.h>
#define BOOL PCSC_BOOL
#include <PCSC/pcsclite.h>
#include <PCSC/reader.h>
#include <PCSC/winscard.h>
#undef BOOL
#include <freerdp/freerdp.h>
#include <freerdp/utils/hexdump.h>
@ -1368,10 +1370,15 @@ boolean scard_async_op(IRP* irp)
void scard_device_control(SCARD_DEVICE* scard, IRP* irp)
{
uint32 output_len, input_len, ioctl_code;
uint32 stream_len, result;
uint32 pos, pad_len;
uint32 irp_result_pos, output_len_pos, result_pos;
uint32 pos;
uint32 result;
uint32 result_pos;
uint32 output_len;
uint32 input_len;
uint32 ioctl_code;
uint32 stream_len;
uint32 irp_result_pos;
uint32 output_len_pos;
const uint32 header_lengths = 16; /* MS-RPCE, Sections 2.2.6.1
* and 2.2.6.2.
*/

View File

@ -15,20 +15,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
foreach(MODULE_NAME ${CHANNEL_BUILTIN_SERVER_MODULES})
string(TOUPPER "CHANNEL_${MODULE_NAME}" MODULE_PREFIX)
message(STATUS "Adding built-in channel server module: ${MODULE_NAME}")
set(MODULE_NAME "freerdp-server-channels")
set(MODULE_PREFIX "FREERDP_SERVER_CHANNELS")
foreach(SRC ${${MODULE_PREFIX}_SERVER_SRCS})
set(CHANNEL_SERVER_SRCS ${CHANNEL_SERVER_SRCS} "../${MODULE_NAME}/server/${SRC}")
foreach(_MODULE_NAME ${CHANNEL_BUILTIN_SERVER_MODULES})
string(TOUPPER "CHANNEL_${_MODULE_NAME}" _MODULE_PREFIX)
message(STATUS "Adding built-in channel server module: ${_MODULE_NAME}")
foreach(SRC ${${_MODULE_PREFIX}_SERVER_SRCS})
set(CHANNEL_SERVER_SRCS ${CHANNEL_SERVER_SRCS} "../${_MODULE_NAME}/server/${SRC}")
endforeach()
set(CHANNEL_SERVER_LIBS ${CHANNEL_SERVER_LIBS} ${${MODULE_PREFIX}_SERVER_LIBS})
set(CHANNEL_SERVER_LIBS ${CHANNEL_SERVER_LIBS} ${${_MODULE_PREFIX}_SERVER_LIBS})
endforeach()
add_library(freerdp-server ${CHANNEL_SERVER_SRCS})
add_library(${MODULE_NAME} ${CHANNEL_SERVER_SRCS})
set_target_properties(freerdp-server PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
target_link_libraries(freerdp-server ${CHANNEL_SERVER_LIBS})
install(TARGETS freerdp-server DESTINATION ${CMAKE_INSTALL_LIBDIR})
target_link_libraries(${MODULE_NAME} ${CHANNEL_SERVER_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP Client User Interfaces
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# 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.
@ -20,8 +18,8 @@
# User Interfaces
if(NOT WIN32)
# Build Test Client
add_subdirectory(test)
# Build Sample Client
add_subdirectory(Sample)
# Build X11 Client
find_suggested_package(X11)

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP DirectFB Client
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# 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.
@ -17,9 +15,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "dfreerdp")
set(MODULE_PREFIX "FREERDP_CLIENT_DIRECTFB")
include_directories(${DIRECTFB_INCLUDE_DIRS})
set(FREERDP_CLIENT_DIRECTFB_SRCS
set(${MODULE_PREFIX}_SRCS
df_event.c
df_event.h
df_graphics.c
@ -27,14 +28,14 @@ set(FREERDP_CLIENT_DIRECTFB_SRCS
dfreerdp.c
dfreerdp.h)
add_executable(dfreerdp ${FREERDP_CLIENT_DIRECTFB_SRCS})
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
set(FREERDP_CLIENT_DIRECTFB_LIBS ${DIRECTFB_LIBRARIES})
set(${MODULE_PREFIX}_LIBS ${DIRECTFB_LIBRARIES})
if(WITH_MONOLITHIC_BUILD)
set(FREERDP_CLIENT_DIRECTFB_LIBS ${FREERDP_CLIENT_DIRECTFB_LIBS} freerdp)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp)
else()
set(FREERDP_CLIENT_DIRECTFB_LIBS ${FREERDP_CLIENT_DIRECTFB_LIBS}
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS}
freerdp-core
freerdp-gdi
freerdp-locale
@ -42,5 +43,7 @@ else()
freerdp-utils)
endif()
target_link_libraries(dfreerdp ${FREERDP_CLIENT_DIRECTFB_LIBS})
install(TARGETS dfreerdp DESTINATION ${CMAKE_INSTALL_BINDIR})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/DirectFB")

View File

@ -143,3 +143,5 @@ target_link_libraries(MacFreeRDP
freerdp-codec
freerdp-rail
)
set_property(TARGET MacFreeRDP PROPERTY FOLDER "Client/Mac")

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP Test UI cmake build script
# FreeRDP Sample UI cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# 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.
@ -17,21 +15,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(FREERDP_CLIENT_TEST_SRCS
set(MODULE_NAME "sfreerdp")
set(MODULE_PREFIX "FREERDP_CLIENT_SAMPLE")
set(${MODULE_PREFIX}_SRCS
freerdp.c)
add_executable(freerdp-test ${FREERDP_CLIENT_TEST_SRCS})
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
set(FREERDP_CLIENT_TEST_LIBS ${FREERDP_CLIENT_TEST_LIBS} ${CMAKE_DL_LIBS})
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${CMAKE_DL_LIBS})
if(WITH_MONOLITHIC_BUILD)
set(FREERDP_CLIENT_TEST_LIBS ${FREERDP_CLIENT_TEST_LIBS} freerdp)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp)
else()
set(FREERDP_CLIENT_TEST_LIBS ${FREERDP_CLIENT_TEST_LIBS}
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS}
freerdp-core
freerdp-gdi
freerdp-utils
freerdp-channels)
endif()
target_link_libraries(freerdp-test ${FREERDP_CLIENT_TEST_LIBS})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Sample")

View File

@ -1,48 +1,58 @@
# 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)
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})
# 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(MODULE_NAME "wfreerdp")
set(MODULE_PREFIX "FREERDP_CLIENT_WINDOWS")
set(${MODULE_PREFIX}_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(${MODULE_NAME} WIN32 ${${MODULE_PREFIX}_SRCS})
if(WITH_MONOLITHIC_BUILD)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp)
if(WITH_RDPDR)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} rdpdr disk printer)
endif()
else()
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS}
freerdp-core
freerdp-gdi
freerdp-codec
freerdp-channels
freerdp-utils)
endif()
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Windows")

View File

@ -56,6 +56,8 @@ LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
case WM_SYSKEYUP:
wfi = (wfInfo*) GetWindowLongPtr(g_focus_hWnd, GWLP_USERDATA);
p = (PKBDLLHOOKSTRUCT) lParam;
if (!wfi || !p)
return 1;
input = wfi->instance->input;
rdp_scancode = MAKE_RDP_SCANCODE((uint8) p->scanCode, p->flags & LLKHF_EXTENDED);

View 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"
@ -537,6 +539,10 @@ int wfreerdp_run(freerdp* instance)
printf("Failed to check FreeRDP file descriptor\n");
break;
}
if (freerdp_shall_disconnect(instance))
{
break;
}
if (wf_check_fds(instance) != TRUE)
{
printf("Failed to check wfreerdp file descriptor\n");
@ -631,6 +637,13 @@ static DWORD WINAPI kbd_thread_func(LPVOID lpParam)
return (DWORD) NULL;
}
#ifdef WITH_RDPDR
DEFINE_SVC_PLUGIN_ENTRY(rdpdr) ;
DEFINE_DEV_PLUGIN_ENTRY(disk) ;
DEFINE_DEV_PLUGIN_ENTRY(printer) ;
#endif
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
freerdp* instance;
@ -688,7 +701,13 @@ 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) ;
REGISTER_DEV_PLUGIN_ENTRY(printer) ;
#endif
if (!CreateThread(NULL, 0, kbd_thread_func, NULL, 0, NULL))
printf("error creating keyboard handler thread");
//while (1)

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP X11 Client
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# 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.
@ -17,10 +15,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "xfreerdp")
set(MODULE_PREFIX "FREERDP_CLIENT_WINDOWS")
include(FindXmlto)
include_directories(${X11_INCLUDE_DIRS})
set(FREERDP_CLIENT_X11_SRCS
set(${MODULE_PREFIX}_SRCS
xf_gdi.c
xf_gdi.h
xf_rail.c
@ -42,9 +43,9 @@ set(FREERDP_CLIENT_X11_SRCS
xfreerdp.c
xfreerdp.h)
add_executable(xfreerdp ${FREERDP_CLIENT_X11_SRCS})
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
set(FREERDP_CLIENT_X11_LIBS
set(${MODULE_PREFIX}_LIBS
${X11_LIBRARIES}
${CMAKE_DL_LIBS})
@ -67,7 +68,7 @@ find_suggested_package(Xinerama)
if(WITH_XINERAMA)
add_definitions(-DWITH_XINERAMA -DWITH_XEXT)
include_directories(${XINERAMA_INCLUDE_DIRS})
set(FREERDP_CLIENT_X11_LIBS ${FREERDP_CLIENT_X11_LIBS} ${XINERAMA_LIBRARIES})
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XINERAMA_LIBRARIES})
endif()
find_suggested_package(Xext)
@ -81,22 +82,22 @@ find_suggested_package(Xcursor)
if(WITH_XCURSOR)
add_definitions(-DWITH_XCURSOR)
include_directories(${XCURSOR_INCLUDE_DIRS})
set(FREERDP_CLIENT_X11_LIBS ${FREERDP_CLIENT_X11_LIBS} ${XCURSOR_LIBRARIES})
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XCURSOR_LIBRARIES})
endif()
find_suggested_package(Xv)
if(WITH_XV)
add_definitions(-DWITH_XV)
include_directories(${XV_INCLUDE_DIRS})
set(FREERDP_CLIENT_X11_LIBS ${FREERDP_CLIENT_X11_LIBS} ${XV_LIBRARIES})
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XV_LIBRARIES})
endif()
include_directories(${CMAKE_SOURCE_DIR}/resources)
if(WITH_MONOLITHIC_BUILD)
set(FREERDP_CLIENT_X11_LIBS ${FREERDP_CLIENT_X11_LIBS} freerdp)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp)
else()
set(FREERDP_CLIENT_X11_LIBS ${FREERDP_CLIENT_X11_LIBS}
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS}
freerdp-core
freerdp-gdi
freerdp-locale
@ -105,5 +106,7 @@ else()
freerdp-utils)
endif()
target_link_libraries(xfreerdp ${FREERDP_CLIENT_X11_LIBS})
install(TARGETS xfreerdp DESTINATION ${CMAKE_INSTALL_BINDIR})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/X11")

View File

@ -15,6 +15,8 @@ if(MSVC)
option(WITH_WIN8 "Use Windows 8 libraries" OFF)
endif()
option(BUILD_TESTING "Build unit tests" OFF)
if(${CMAKE_VERSION} VERSION_GREATER 2.8.8)
option(WITH_MONOLITHIC_BUILD "Use monolithic build" OFF)
endif()

View File

@ -27,21 +27,40 @@
# limitations under the License.
#=============================================================================
find_path(CUNIT_INCLUDE_DIR NAMES CUnit.h
PATH_SUFFIXES CUnit
DOC "The CUnit include directory"
if(WIN32)
set(_CUNIT_ROOT_HINTS
$ENV{CUNIT_ROOT_DIR}
${CUNIT_ROOT_DIR})
set(_CUNIT_ROOT_PATHS
"$ENV{PROGRAMFILES}/CUnit"
"$ENV{SYSTEMDRIVE}/CUnit")
set(_CUNIT_ROOT_HINTS_AND_PATHS
HINTS ${_CUNIT_ROOT_HINTS}
PATHS ${_CUNIT_ROOT_PATHS})
endif(WIN32)
find_path(CUNIT_INCLUDE_DIR
NAMES CUnit.h
HINTS ${_CUNIT_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES CUnit include
DOC "The CUnit include directory"
)
find_library(CUNIT_LIBRARY NAMES cunit
DOC "The CUnit library"
find_library(CUNIT_LIBRARY
NAMES cunit
HINTS ${_CUNIT_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES lib
DOC "The CUnit library"
)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CUnit DEFAULT_MSG CUNIT_LIBRARY CUNIT_INCLUDE_DIR)
if(CUNIT_FOUND)
set( CUNIT_LIBRARIES ${CUNIT_LIBRARY} )
set( CUNIT_INCLUDE_DIRS ${CUNIT_INCLUDE_DIR} )
set(CUNIT_LIBRARIES ${CUNIT_LIBRARY})
set(CUNIT_INCLUDE_DIRS ${CUNIT_INCLUDE_DIR})
endif()
mark_as_advanced(CUNIT_INCLUDE_DIR CUNIT_LIBRARY)

View File

@ -27,6 +27,7 @@
#cmakedefine HAVE_TM_GMTOFF
/* Options */
#cmakedefine WITH_PROFILER
#cmakedefine WITH_SSE2
@ -35,6 +36,11 @@
#cmakedefine WITH_JPEG
#cmakedefine WITH_WIN8
/* Plugins */
#cmakedefine WITH_STATIC_PLUGINS
#cmakedefine WITH_RDPDR
/* Debug */
#cmakedefine WITH_DEBUG_CERTIFICATE
#cmakedefine WITH_DEBUG_CHANNELS

View File

@ -26,10 +26,6 @@ include_directories(../libfreerdp/cache)
include_directories(../libfreerdp/codec)
add_executable(test_freerdp
test_per.c
test_per.h
test_ber.c
test_ber.h
test_gcc.c
test_gcc.h
test_mcs.c
@ -40,8 +36,6 @@ add_executable(test_freerdp
test_bitmap.h
test_gdi.c
test_gdi.h
test_list.c
test_list.h
test_orders.c
test_orders.h
test_pcap.c
@ -50,12 +44,6 @@ add_executable(test_freerdp
test_ntlm.h
test_license.c
test_license.h
test_stream.c
test_stream.h
test_utils.c
test_utils.h
test_channels.c
test_channels.h
test_cliprdr.c
test_cliprdr.h
test_drdynvc.c
@ -86,4 +74,5 @@ target_link_libraries(test_freerdp freerdp-crypto)
target_link_libraries(test_freerdp winpr-sspi)
add_test(CUnitTests ${EXECUTABLE_OUTPUT_PATH}/test_freerdp)
add_test(CUnitTests ${CMAKE_SOURCE_DIR}/cunit/test_freerdp)

View File

@ -1,96 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Basic Encoding Rules (BER) Unit Tests
*
* Copyright 2011 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.
*/
#include <freerdp/freerdp.h>
#include <freerdp/utils/hexdump.h>
#include <freerdp/utils/stream.h>
#include "test_ber.h"
#include <freerdp/crypto/ber.h>
int init_ber_suite(void)
{
return 0;
}
int clean_ber_suite(void)
{
return 0;
}
int add_ber_suite(void)
{
add_test_suite(ber);
add_test_function(ber_write_length);
add_test_function(ber_write_universal_tag);
add_test_function(ber_write_application_tag);
return 0;
}
uint8 ber_length_expected_1[1] = "\x40"; /* 64 */
uint8 ber_length_expected_2[3] = "\x82\x01\x94"; /* 404 */
void test_ber_write_length(void)
{
STREAM *s1, *s2;
s1 = stream_new(sizeof(ber_length_expected_1));
s2 = stream_new(sizeof(ber_length_expected_2));
ber_write_length(s1, 64);
ASSERT_STREAM(s1, (uint8*) ber_length_expected_1, sizeof(ber_length_expected_1));
ber_write_length(s2, 404);
ASSERT_STREAM(s2, (uint8*) ber_length_expected_2, sizeof(ber_length_expected_2));
stream_free(s1);
stream_free(s2);
}
/* BOOLEAN, length 1, without value */
uint8 ber_universal_tag_expected[1] = "\x01";
void test_ber_write_universal_tag(void)
{
STREAM* s;
s = stream_new(sizeof(ber_universal_tag_expected));
ber_write_universal_tag(s, 1, false);
ASSERT_STREAM(s, (uint8*) ber_universal_tag_expected, sizeof(ber_universal_tag_expected));
stream_free(s);
}
/* T.125 MCS Application 101 (Connect-Initial), length 404 */
uint8 ber_application_tag_expected[5] = "\x7F\x65\x82\x01\x94";
void test_ber_write_application_tag(void)
{
STREAM* s;
s = stream_new(sizeof(ber_application_tag_expected));
ber_write_application_tag(s, 101, 404);
ASSERT_STREAM(s, (uint8*) ber_application_tag_expected, sizeof(ber_application_tag_expected));
stream_free(s);
}

View File

@ -1,91 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Channel Manager Unit Tests
*
* Copyright 2011 Vic Lee
*
* 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 <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <freerdp/freerdp.h>
#include <freerdp/constants.h>
#include <freerdp/channels/channels.h>
#include <freerdp/utils/event.h>
#include "test_channels.h"
int init_channels_suite(void)
{
freerdp_channels_global_init();
return 0;
}
int clean_channels_suite(void)
{
freerdp_channels_global_uninit();
return 0;
}
int add_channels_suite(void)
{
add_test_suite(channels);
add_test_function(channels);
return 0;
}
static int test_rdp_channel_data(freerdp* instance, int chan_id, uint8* data, int data_size)
{
printf("chan_id %d data_size %d\n", chan_id, data_size);
return 0;
}
void test_channels(void)
{
rdpChannels* chan_man;
rdpSettings settings = { 0 };
freerdp instance = { 0 };
RDP_EVENT* event;
settings.hostname = "testhost";
instance.settings = &settings;
instance.SendChannelData = test_rdp_channel_data;
chan_man = freerdp_channels_new();
freerdp_channels_load_plugin(chan_man, &settings, "../channels/rdpdbg/rdpdbg.so", NULL);
freerdp_channels_pre_connect(chan_man, &instance);
freerdp_channels_post_connect(chan_man, &instance);
freerdp_channels_data(&instance, 0, "testdata", 8, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 8);
freerdp_channels_data(&instance, 0, "testdata1", 9, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 9);
freerdp_channels_data(&instance, 0, "testdata11", 10, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 10);
freerdp_channels_data(&instance, 0, "testdata111", 11, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 11);
event = freerdp_event_new(RDP_EVENT_CLASS_DEBUG, 0, NULL, NULL);
freerdp_channels_send_event(chan_man, event);
while ((event = freerdp_channels_pop_event(chan_man)) == NULL)
{
freerdp_channels_check_fds(chan_man, &instance);
}
printf("responded event_type %d\n", event->event_type);
freerdp_event_free(event);
freerdp_channels_close(chan_man, &instance);
freerdp_channels_free(chan_man);
}

View File

@ -1,26 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Channel Manager Unit Tests
*
* Copyright 2011 Vic Lee
*
* 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 "test_freerdp.h"
int init_channels_suite(void);
int clean_channels_suite(void);
int add_channels_suite(void);
void test_channels(void);

View File

@ -19,21 +19,14 @@
#include <CUnit/Basic.h>
#include "test_per.h"
#include "test_ber.h"
#include "test_gcc.h"
#include "test_mcs.h"
#include "test_color.h"
#include "test_bitmap.h"
#include "test_gdi.h"
#include "test_list.h"
#include "test_sspi.h"
#include "test_stream.h"
#include "test_utils.h"
#include "test_orders.h"
#include "test_ntlm.h"
#include "test_license.h"
#include "test_channels.h"
#include "test_cliprdr.h"
#include "test_drdynvc.h"
#include "test_rfx.h"
@ -122,29 +115,22 @@ typedef struct _test_suite test_suite;
const static test_suite suites[] =
{
{ "ber", add_ber_suite },
{ "bitmap", add_bitmap_suite },
{ "channels", add_channels_suite },
{ "cliprdr", add_cliprdr_suite },
//{ "cliprdr", add_cliprdr_suite },
{ "color", add_color_suite },
{ "drdynvc", add_drdynvc_suite },
{ "gcc", add_gcc_suite },
//{ "drdynvc", add_drdynvc_suite },
//{ "gcc", add_gcc_suite },
{ "gdi", add_gdi_suite },
{ "license", add_license_suite },
{ "list", add_list_suite },
{ "mcs", add_mcs_suite },
//{ "mcs", add_mcs_suite },
{ "mppc", add_mppc_suite },
{ "mppc_enc", add_mppc_enc_suite },
{ "ntlm", add_ntlm_suite },
{ "orders", add_orders_suite },
//{ "orders", add_orders_suite },
{ "pcap", add_pcap_suite },
{ "per", add_per_suite },
{ "rail", add_rail_suite },
//{ "rail", add_rail_suite },
{ "rfx", add_rfx_suite },
{ "nsc", add_nsc_suite },
{ "sspi", add_sspi_suite },
{ "stream", add_stream_suite },
{ "utils", add_utils_suite }
{ "nsc", add_nsc_suite }
};
#define N_SUITES (sizeof suites / sizeof suites[0])

View File

@ -426,8 +426,8 @@ void test_license_generate_keys(void)
memcpy(license->server_random, test_server_random, sizeof(test_server_random));
memcpy(license->premaster_secret, premaster_secret, sizeof(premaster_secret));
memcpy(license->certificate->cert_info.exponent, test_exponent, sizeof(test_exponent));
memcpy(license->certificate->cert_info.modulus.data, test_modulus, sizeof(test_modulus));
license->certificate->cert_info.modulus.length = sizeof(test_modulus);
memcpy(license->certificate->cert_info.Modulus, test_modulus, sizeof(test_modulus));
license->certificate->cert_info.ModulusLength = sizeof(test_modulus);
license_generate_keys(license);
license_encrypt_premaster_secret(license);
@ -460,8 +460,8 @@ void test_license_encrypt_premaster_secret(void)
s = &_s;
memcpy(license->premaster_secret, premaster_secret, sizeof(premaster_secret));
memcpy(license->certificate->cert_info.exponent, test_exponent, sizeof(test_exponent));
memcpy(license->certificate->cert_info.modulus.data, test_modulus, sizeof(test_modulus));
license->certificate->cert_info.modulus.length = sizeof(test_modulus);
memcpy(license->certificate->cert_info.Modulus, test_modulus, sizeof(test_modulus));
license->certificate->cert_info.ModulusLength = sizeof(test_modulus);
s->data = license->encrypted_premaster_secret->data;
s->p = s->data + sizeof(test_encrypted_premaster_secret);

View File

@ -1,94 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* List Unit Tests
*
* Copyright 2011 Vic Lee
*
* 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 <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <freerdp/freerdp.h>
#include <freerdp/utils/list.h>
#include "test_list.h"
int init_list_suite(void)
{
return 0;
}
int clean_list_suite(void)
{
return 0;
}
int add_list_suite(void)
{
add_test_suite(list);
add_test_function(list);
return 0;
}
struct _my_list_item
{
uint32 a;
uint32 b;
};
typedef struct _my_list_item my_list_item;
void test_list(void)
{
LIST* list;
LIST_ITEM* list_item;
my_list_item* item;
my_list_item* item1;
my_list_item* item2;
int i;
list = list_new();
for (i = 0; i < 10; i++)
{
item = xnew(my_list_item);
item->a = i;
item->b = i * i;
list_enqueue(list, item);
}
for (i = 0, list_item = list->head; list_item; i++, list_item = list_item->next)
{
CU_ASSERT(((my_list_item*)list_item->data)->a == i);
CU_ASSERT(((my_list_item*)list_item->data)->b == i * i);
/*printf("%d %d\n", item->a, item->b);*/
}
item1 = xnew(my_list_item);
list_add(list, item1);
item2 = xnew(my_list_item);
list_add(list, item2);
CU_ASSERT(list_remove(list, item1) == item1);
xfree(item1);
CU_ASSERT(list_remove(list, item2) == item2);
CU_ASSERT(list_remove(list, item2) == NULL);
xfree(item2);
while ((item = list_dequeue(list)) != NULL)
xfree(item);
list_free(list);
}

View File

@ -1,26 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* List Unit Tests
*
* Copyright 2011 Vic Lee
*
* 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 "test_freerdp.h"
int init_list_suite(void);
int clean_list_suite(void);
int add_list_suite(void);
void test_list(void);

View File

@ -1,64 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Packed Encoding Rules (PER) Unit Tests
*
* Copyright 2011 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.
*/
#include <freerdp/freerdp.h>
#include <freerdp/utils/hexdump.h>
#include <freerdp/utils/stream.h>
#include "test_per.h"
#include <freerdp/crypto/per.h>
int init_per_suite(void)
{
return 0;
}
int clean_per_suite(void)
{
return 0;
}
int add_per_suite(void)
{
add_test_suite(per);
add_test_function(per_write_length);
add_test_function(per_write_object_identifier);
return 0;
}
uint8 per_length_expected[2] = "\x81\x2A";
void test_per_write_length(void)
{
STREAM* s = stream_new(2);
per_write_length(s, 298);
ASSERT_STREAM(s, (uint8*) per_length_expected, sizeof(per_length_expected));
}
uint8 per_oid[6] = { 0, 0, 20, 124, 0, 1 };
uint8 per_oid_expected[6] = "\x05\x00\x14\x7C\x00\x01";
void test_per_write_object_identifier(void)
{
STREAM* s = stream_new(6);
per_write_object_identifier(s, per_oid);
ASSERT_STREAM(s, (uint8*) per_oid_expected, sizeof(per_oid_expected));
}

View File

@ -1,27 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Packed Encoding Rules (PER) Unit Tests
*
* Copyright 2011 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.
*/
#include "test_freerdp.h"
int init_per_suite(void);
int clean_per_suite(void);
int add_per_suite(void);
void test_per_write_length(void);
void test_per_write_object_identifier(void);

View File

@ -1,225 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* Security Support Provider Interface (SSPI) Tests
*
* 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.
*/
#include <winpr/sspi.h>
#include <freerdp/freerdp.h>
#include <freerdp/utils/stream.h>
#include <freerdp/utils/memory.h>
#include <freerdp/utils/hexdump.h>
#include "test_sspi.h"
#define NTLM_PACKAGE_NAME "NTLM"
int init_sspi_suite(void)
{
sspi_GlobalInit();
return 0;
}
int clean_sspi_suite(void)
{
sspi_GlobalFinish();
return 0;
}
int add_sspi_suite(void)
{
add_test_suite(sspi);
add_test_function(EnumerateSecurityPackages);
add_test_function(QuerySecurityPackageInfo);
add_test_function(AcquireCredentialsHandle);
add_test_function(InitializeSecurityContext);
return 0;
}
void test_EnumerateSecurityPackages(void)
{
ULONG cPackages;
SECURITY_STATUS status;
SecPkgInfo* pPackageInfo;
status = EnumerateSecurityPackages(&cPackages, &pPackageInfo);
if (status == SEC_E_OK)
{
int index;
printf("\nEnumerateSecurityPackages (%d):\n", (unsigned int)cPackages);
for (index = 0; index < cPackages; index++)
{
printf("\"%s\", \"%s\"\n",
pPackageInfo[index].Name, pPackageInfo[index].Comment);
}
}
FreeContextBuffer(pPackageInfo);
}
void test_QuerySecurityPackageInfo(void)
{
SECURITY_STATUS status;
SecPkgInfo* pPackageInfo;
status = QuerySecurityPackageInfo("NTLM", &pPackageInfo);
if (status == SEC_E_OK)
{
printf("\nQuerySecurityPackageInfo:\n");
printf("\"%s\", \"%s\"\n", pPackageInfo->Name, pPackageInfo->Comment);
}
}
const char* test_User = "User";
const char* test_Domain = "Domain";
const char* test_Password = "Password";
void test_AcquireCredentialsHandle(void)
{
SECURITY_STATUS status;
CredHandle credentials;
TimeStamp expiration;
SEC_WINNT_AUTH_IDENTITY identity;
SecurityFunctionTable* table;
SecPkgCredentials_Names credential_names;
table = InitSecurityInterface();
identity.User = (uint16*) xstrdup(test_User);
identity.UserLength = sizeof(test_User);
identity.Domain = (uint16*) xstrdup(test_Domain);
identity.DomainLength = sizeof(test_Domain);
identity.Password = (uint16*) xstrdup(test_Password);
identity.PasswordLength = sizeof(test_Password);
identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
status = table->AcquireCredentialsHandle(NULL, NTLM_PACKAGE_NAME,
SECPKG_CRED_OUTBOUND, NULL, &identity, NULL, NULL, &credentials, &expiration);
if (status == SEC_E_OK)
{
status = table->QueryCredentialsAttributes(&credentials, SECPKG_CRED_ATTR_NAMES, &credential_names);
if (status == SEC_E_OK)
{
printf("\nQueryCredentialsAttributes: %s\n", credential_names.sUserName);
}
}
}
void test_InitializeSecurityContext(void)
{
uint32 cbMaxLen;
uint32 fContextReq;
void* output_buffer;
CtxtHandle context;
ULONG pfContextAttr;
SECURITY_STATUS status;
CredHandle credentials;
TimeStamp expiration;
SecPkgInfo* pPackageInfo;
SEC_WINNT_AUTH_IDENTITY identity;
SecurityFunctionTable* table;
SecBuffer* p_SecBuffer;
SecBuffer output_SecBuffer;
SecBufferDesc output_SecBuffer_desc;
table = InitSecurityInterface();
status = QuerySecurityPackageInfo(NTLM_PACKAGE_NAME, &pPackageInfo);
if (status != SEC_E_OK)
{
printf("QuerySecurityPackageInfo status: 0x%08X\n", status);
return;
}
cbMaxLen = pPackageInfo->cbMaxToken;
identity.User = (uint16*) xstrdup(test_User);
identity.UserLength = sizeof(test_User);
identity.Domain = (uint16*) xstrdup(test_Domain);
identity.DomainLength = sizeof(test_Domain);
identity.Password = (uint16*) xstrdup(test_Password);
identity.PasswordLength = sizeof(test_Password);
identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
status = table->AcquireCredentialsHandle(NULL, NTLM_PACKAGE_NAME,
SECPKG_CRED_OUTBOUND, NULL, &identity, NULL, NULL, &credentials, &expiration);
if (status != SEC_E_OK)
{
printf("AcquireCredentialsHandle status: 0x%08X\n", status);
return;
}
fContextReq = ISC_REQ_REPLAY_DETECT | ISC_REQ_SEQUENCE_DETECT | ISC_REQ_CONFIDENTIALITY | ISC_REQ_DELEGATE;
output_buffer = xmalloc(cbMaxLen);
output_SecBuffer_desc.ulVersion = 0;
output_SecBuffer_desc.cBuffers = 1;
output_SecBuffer_desc.pBuffers = &output_SecBuffer;
output_SecBuffer.cbBuffer = cbMaxLen;
output_SecBuffer.BufferType = SECBUFFER_TOKEN;
output_SecBuffer.pvBuffer = output_buffer;
status = table->InitializeSecurityContext(&credentials, NULL, NULL, fContextReq, 0, 0, NULL, 0,
&context, &output_SecBuffer_desc, &pfContextAttr, &expiration);
if (status != SEC_I_CONTINUE_NEEDED)
{
printf("InitializeSecurityContext status: 0x%08X\n", status);
return;
}
printf("cBuffers: %ld ulVersion: %ld\n", output_SecBuffer_desc.cBuffers, output_SecBuffer_desc.ulVersion);
p_SecBuffer = &output_SecBuffer_desc.pBuffers[0];
printf("BufferType: 0x%04lX cbBuffer:%ld\n", p_SecBuffer->BufferType, p_SecBuffer->cbBuffer);
freerdp_hexdump((uint8*) p_SecBuffer->pvBuffer, p_SecBuffer->cbBuffer);
table->FreeCredentialsHandle(&credentials);
FreeContextBuffer(pPackageInfo);
}

View File

@ -1,29 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* Security Support Provider Interface (SSPI) Tests
*
* 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.
*/
#include "test_freerdp.h"
int init_sspi_suite(void);
int clean_sspi_suite(void);
int add_sspi_suite(void);
void test_EnumerateSecurityPackages(void);
void test_QuerySecurityPackageInfo(void);
void test_AcquireCredentialsHandle(void);
void test_InitializeSecurityContext(void);

View File

@ -1,76 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Stream Unit Tests
*
* Copyright 2011 Vic Lee
*
* 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 <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <freerdp/freerdp.h>
#include <freerdp/utils/hexdump.h>
#include <freerdp/utils/stream.h>
#include "test_stream.h"
int init_stream_suite(void)
{
return 0;
}
int clean_stream_suite(void)
{
return 0;
}
int add_stream_suite(void)
{
add_test_suite(stream);
add_test_function(stream);
return 0;
}
void test_stream(void)
{
STREAM * stream;
int pos;
uint32 n;
uint64 n64;
stream = stream_new(1);
pos = stream_get_pos(stream);
stream_write_uint8(stream, 0xFE);
stream_check_size(stream, 14);
stream_write_uint16(stream, 0x0102);
stream_write_uint32(stream, 0x03040506);
stream_write_uint64(stream, 0x0708091011121314LL);
/* freerdp_hexdump(stream->buffer, 15); */
stream_set_pos(stream, pos);
stream_seek(stream, 3);
stream_read_uint32(stream, n);
stream_read_uint64(stream, n64);
CU_ASSERT(n == 0x03040506);
CU_ASSERT(n64 == 0x0708091011121314LL);
stream_free(stream);
}

View File

@ -1,26 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Stream Unit Tests
*
* Copyright 2011 Vic Lee
*
* 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 "test_freerdp.h"
int init_stream_suite(void);
int clean_stream_suite(void);
int add_stream_suite(void);
void test_stream(void);

View File

@ -1,650 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Utils Unit Tests
*
* Copyright 2011 Vic Lee, 2011 Shea Levy
*
* 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.
*/
#define _XOPEN_SOURCE 700
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/select.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <termios.h>
#include <unistd.h>
#include <freerdp/freerdp.h>
#include <freerdp/utils/load_plugin.h>
#include <freerdp/utils/wait_obj.h>
#include <freerdp/utils/args.h>
#include <freerdp/utils/passphrase.h>
#include <freerdp/utils/signal.h>
#include <freerdp/utils/memory.h>
#include "test_utils.h"
int init_utils_suite(void)
{
return 0;
}
int clean_utils_suite(void)
{
return 0;
}
int add_utils_suite(void)
{
add_test_suite(utils);
add_test_function(load_plugin);
add_test_function(wait_obj);
add_test_function(args);
add_test_function(passphrase_read);
add_test_function(handle_signals);
return 0;
}
void test_load_plugin(void)
{
void* entry;
#ifdef _WIN32
/* untested */
entry = freerdp_load_plugin("..\\channels\\cliprdr\\cliprdr", "VirtualChannelEntry");
#else
entry = freerdp_load_plugin("../channels/cliprdr/cliprdr.so", "VirtualChannelEntry");
#endif
CU_ASSERT(entry != NULL);
}
void test_wait_obj(void)
{
struct wait_obj* wo;
int set;
wo = wait_obj_new();
set = wait_obj_is_set(wo);
CU_ASSERT(set == 0);
wait_obj_set(wo);
set = wait_obj_is_set(wo);
CU_ASSERT(set == 1);
wait_obj_clear(wo);
set = wait_obj_is_set(wo);
CU_ASSERT(set == 0);
wait_obj_select(&wo, 1, 1000);
wait_obj_free(wo);
}
static int process_plugin_args(rdpSettings* settings, const char* name,
RDP_PLUGIN_DATA* plugin_data, void* user_data)
{
/*printf("load plugin: %s\n", name);*/
return 1;
}
static int process_ui_args(rdpSettings* settings, const char* opt,
const char* val, void* user_data)
{
/*printf("ui arg: %s %s\n", opt, val);*/
return 1;
}
void test_args(void)
{
char* argv_c[] =
{
"freerdp", "-a", "8", "-u", "testuser", "-d", "testdomain", "-g", "640x480", "address1:3389",
"freerdp", "-a", "16", "-u", "testuser", "-d", "testdomain", "-g", "1280x960", "address2:3390"
};
char** argv = argv_c;
int argc = ARRAY_SIZE(argv_c);
int i;
int c;
rdpSettings* settings;
i = 0;
while (argc > 0)
{
settings = settings_new(NULL);
i++;
c = freerdp_parse_args(settings, argc, argv, process_plugin_args, NULL, process_ui_args, NULL);
CU_ASSERT(c > 0);
if (c == 0)
{
settings_free(settings);
break;
}
CU_ASSERT(settings->color_depth == i * 8);
CU_ASSERT(settings->width == i * 640);
CU_ASSERT(settings->height == i * 480);
CU_ASSERT(settings->port == i + 3388);
settings_free(settings);
argc -= c;
argv += c;
}
CU_ASSERT(i == 2);
}
void passphrase_read_prompts_to_tty()
{
static const int read_nbyte = 11;
int masterfd;
char* slavedevice = NULL;
char read_buf[read_nbyte];
fd_set fd_set_write;
masterfd = posix_openpt(O_RDWR|O_NOCTTY);
if (masterfd == -1
|| grantpt (masterfd) == -1
|| unlockpt (masterfd) == -1
|| (slavedevice = ptsname (masterfd)) == NULL)
CU_FAIL_FATAL("Could not create pty");
switch (fork())
{
case -1:
CU_FAIL_FATAL("Could not fork");
case 0:
{
static const int password_size = 512;
char buffer[password_size];
int slavefd;
if (setsid() == (pid_t) -1)
CU_FAIL_FATAL("Could not create new session");
if ((slavefd = open(slavedevice, O_RDWR)) == 0)
CU_FAIL_FATAL("Could not open slave end of pty");
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
close(masterfd);
freerdp_passphrase_read("Password: ", buffer, password_size, 0);
close(slavefd);
exit(EXIT_SUCCESS);
}
}
read_buf[read_nbyte - 1] = '\0';
FD_ZERO(&fd_set_write);
FD_SET(masterfd, &fd_set_write);
if (select(masterfd + 1, NULL, &fd_set_write, NULL, NULL) == -1)
CU_FAIL_FATAL("Master end of pty not writeable");
if (read(masterfd, read_buf, read_nbyte) == (ssize_t) -1)
CU_FAIL_FATAL("Nothing written to slave end of pty");
CU_ASSERT_STRING_EQUAL(read_buf, "Password: ");
write(masterfd, "\n", (size_t) 2);
close(masterfd);
return;
}
void passphrase_read_reads_from_tty()
{
static const int read_nbyte = 11;
int masterfd;
int pipe_ends[2];
char* slavedevice = NULL;
char read_buf[read_nbyte];
fd_set fd_set_write;
masterfd = posix_openpt(O_RDWR|O_NOCTTY);
if (masterfd == -1
|| grantpt (masterfd) == -1
|| unlockpt (masterfd) == -1
|| (slavedevice = ptsname (masterfd)) == NULL)
CU_FAIL_FATAL("Could not create pty");
if (pipe(pipe_ends) != 0)
CU_FAIL_FATAL("Could not create pipe");
switch (fork())
{
case -1:
CU_FAIL_FATAL("Could not fork");
case 0:
{
static const int password_size = 512;
char buffer[password_size];
int slavefd;
if (setsid() == (pid_t) -1)
CU_FAIL_FATAL("Could not create new session");
if ((slavefd = open(slavedevice, O_RDWR)) == 0)
CU_FAIL_FATAL("Could not open slave end of pty");
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
close(masterfd);
close(pipe_ends[0]);
freerdp_passphrase_read("Password: ", buffer, password_size, 0);
write(pipe_ends[1], buffer, password_size);
close(slavefd);
close(pipe_ends[1]);
exit(EXIT_SUCCESS);
}
}
close(pipe_ends[1]);
read_buf[read_nbyte - 1] = '\0';
FD_ZERO(&fd_set_write);
FD_SET(masterfd, &fd_set_write);
if (select(masterfd + 1, NULL, &fd_set_write, NULL, NULL) == -1)
CU_FAIL_FATAL("Master end of pty not writeable");
if (read(masterfd, read_buf, read_nbyte) == (ssize_t) -1)
CU_FAIL_FATAL("Nothing written to slave end of pty");
write(masterfd, "passw0rd\n", sizeof "passw0rd\n");
if (read(pipe_ends[0], read_buf, read_nbyte) == (ssize_t) -1)
CU_FAIL_FATAL("Nothing written to pipe");
CU_ASSERT_STRING_EQUAL(read_buf, "passw0rd");
close(masterfd);
close(pipe_ends[0]);
return;
}
void passphrase_read_turns_off_echo_during_read()
{
static const int read_nbyte = 11;
int masterfd, slavefd;
char* slavedevice = NULL;
char read_buf[read_nbyte];
fd_set fd_set_write;
struct termios term_flags;
masterfd = posix_openpt(O_RDWR|O_NOCTTY);
if (masterfd == -1
|| grantpt (masterfd) == -1
|| unlockpt (masterfd) == -1
|| (slavedevice = ptsname (masterfd)) == NULL)
CU_FAIL_FATAL("Could not create pty");
slavefd = open(slavedevice, O_RDWR|O_NOCTTY);
if (slavefd == -1)
CU_FAIL_FATAL("Could not open slave end of pty");
if (tcgetattr(slavefd, &term_flags) != 0)
CU_FAIL_FATAL("Could not get slave pty attributes");
if (!(term_flags.c_lflag & ECHO))
{
term_flags.c_lflag |= ECHO;
if (tcsetattr(slavefd, TCSANOW, &term_flags) != 0)
CU_FAIL_FATAL("Could not turn ECHO on on slave pty");
}
switch (fork())
{
case -1:
CU_FAIL_FATAL("Could not fork");
case 0:
{
static const int password_size = 512;
int child_slavefd;
char buffer[password_size];
if (setsid() == (pid_t) -1)
CU_FAIL_FATAL("Could not create new session");
if ((child_slavefd = open(slavedevice, O_RDWR)) == 0)
CU_FAIL_FATAL("Could not open slave end of pty");
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
close(masterfd);
close(slavefd);
freerdp_passphrase_read("Password: ", buffer, password_size, 0);
close(child_slavefd);
exit(EXIT_SUCCESS);
}
}
read_buf[read_nbyte - 1] = '\0';
FD_ZERO(&fd_set_write);
FD_SET(masterfd, &fd_set_write);
if (select(masterfd + 1, NULL, &fd_set_write, NULL, NULL) == -1)
CU_FAIL_FATAL("Master end of pty not writeable");
if (read(masterfd, read_buf, read_nbyte) == (ssize_t) -1)
CU_FAIL_FATAL("Nothing written to slave end of pty");
if (tcgetattr(slavefd, &term_flags) != 0)
CU_FAIL_FATAL("Could not get slave pty attributes");
CU_ASSERT(!(term_flags.c_lflag & ECHO))
write(masterfd, "\n", (size_t) 2);
close(masterfd);
close(slavefd);
return;
}
void passphrase_read_resets_terminal_after_read()
{
static const int read_nbyte = 11;
int masterfd, slavefd, status;
char* slavedevice = NULL;
char read_buf[read_nbyte];
fd_set fd_set_write;
struct termios term_flags;
pid_t child;
masterfd = posix_openpt(O_RDWR|O_NOCTTY);
if (masterfd == -1
|| grantpt (masterfd) == -1
|| unlockpt (masterfd) == -1
|| (slavedevice = ptsname (masterfd)) == NULL)
CU_FAIL_FATAL("Could not create pty");
slavefd = open(slavedevice, O_RDWR|O_NOCTTY);
if (slavefd == -1)
CU_FAIL_FATAL("Could not open slave end of pty");
if (tcgetattr(slavefd, &term_flags) != 0)
CU_FAIL_FATAL("Could not get slave pty attributes");
if (!(term_flags.c_lflag & ECHO))
{
term_flags.c_lflag |= ECHO;
if (tcsetattr(slavefd, TCSANOW, &term_flags) != 0)
CU_FAIL_FATAL("Could not turn ECHO on on slave pty");
}
switch (child = fork())
{
case -1:
CU_FAIL_FATAL("Could not fork");
case 0:
{
static const int password_size = 512;
int child_slavefd;
char buffer[password_size];
if (setsid() == (pid_t) -1)
CU_FAIL_FATAL("Could not create new session");
if ((child_slavefd = open(slavedevice, O_RDWR)) == 0)
CU_FAIL_FATAL("Could not open slave end of pty");
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
close(masterfd);
close(slavefd);
freerdp_passphrase_read("Password: ", buffer, password_size, 0);
close(child_slavefd);
exit(EXIT_SUCCESS);
}
}
read_buf[read_nbyte - 1] = '\0';
FD_ZERO(&fd_set_write);
FD_SET(masterfd, &fd_set_write);
if (select(masterfd + 1, NULL, &fd_set_write, NULL, NULL) == -1)
CU_FAIL_FATAL("Master end of pty not writeable");
if (read(masterfd, read_buf, read_nbyte) == (ssize_t) -1)
CU_FAIL_FATAL("Nothing written to slave end of pty");
write(masterfd, "\n", (size_t) 2);
waitpid(child, &status, WUNTRACED);
if (tcgetattr(slavefd, &term_flags) != 0)
CU_FAIL_FATAL("Could not get slave pty attributes");
CU_ASSERT(term_flags.c_lflag & ECHO)
close(masterfd);
close(slavefd);
return;
}
void passphrase_read_turns_on_newline_echo_during_read()
{
static const int read_nbyte = 11;
int masterfd, slavefd;
char* slavedevice = NULL;
char read_buf[read_nbyte];
fd_set fd_set_write;
struct termios term_flags;
masterfd = posix_openpt(O_RDWR|O_NOCTTY);
if (masterfd == -1
|| grantpt (masterfd) == -1
|| unlockpt (masterfd) == -1
|| (slavedevice = ptsname (masterfd)) == NULL)
CU_FAIL_FATAL("Could not create pty");
slavefd = open(slavedevice, O_RDWR|O_NOCTTY);
if (slavefd == -1)
CU_FAIL_FATAL("Could not open slave end of pty");
if (tcgetattr(slavefd, &term_flags) != 0)
CU_FAIL_FATAL("Could not get slave pty attributes");
if (term_flags.c_lflag & ECHONL)
{
term_flags.c_lflag &= ~ECHONL;
if (tcsetattr(slavefd, TCSANOW, &term_flags) != 0)
CU_FAIL_FATAL("Could not turn ECHO on on slave pty");
}
switch (fork())
{
case -1:
CU_FAIL_FATAL("Could not fork");
case 0:
{
static const int password_size = 512;
int child_slavefd;
char buffer[password_size];
if (setsid() == (pid_t) -1)
CU_FAIL_FATAL("Could not create new session");
if ((child_slavefd = open(slavedevice, O_RDWR)) == 0)
CU_FAIL_FATAL("Could not open slave end of pty");
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
close(masterfd);
close(slavefd);
freerdp_passphrase_read("Password: ", buffer, password_size, 0);
close(child_slavefd);
exit(EXIT_SUCCESS);
}
}
read_buf[read_nbyte - 1] = '\0';
FD_ZERO(&fd_set_write);
FD_SET(masterfd, &fd_set_write);
if (select(masterfd + 1, NULL, &fd_set_write, NULL, NULL) == -1)
CU_FAIL_FATAL("Master end of pty not writeable");
if (read(masterfd, read_buf, read_nbyte) == (ssize_t) -1)
CU_FAIL_FATAL("Nothing written to slave end of pty");
if (tcgetattr(slavefd, &term_flags) != 0)
CU_FAIL_FATAL("Could not get slave pty attributes");
CU_ASSERT(term_flags.c_lflag & ECHONL)
write(masterfd, "\n", (size_t) 2);
close(masterfd);
close(slavefd);
return;
}
void passphrase_read_prompts_to_stderr_when_no_tty()
{
static const int read_nbyte = 11;
int stdin_pipe[2], stderr_pipe[2];
char read_buf[read_nbyte];
struct sigaction ignore, orig;
ignore.sa_handler = SIG_IGN;
sigemptyset(&ignore.sa_mask);
if (pipe(stdin_pipe) != 0 || pipe(stderr_pipe) != 0)
CU_FAIL_FATAL("Could not create pipe");
switch (fork())
{
case -1:
CU_FAIL_FATAL("Could not fork");
case 0:
{
static const int password_size = 512;
char buffer[password_size];
close(stderr_pipe[0]);
close(stdin_pipe[1]);
if (setsid() == (pid_t) -1)
CU_FAIL_FATAL("Could not create new session");
dup2(stdin_pipe[0], STDIN_FILENO);
dup2(stderr_pipe[1], STDERR_FILENO);
freerdp_passphrase_read("Password: ", buffer, password_size, 0);
exit(EXIT_SUCCESS);
}
}
close(stderr_pipe[1]);
close(stdin_pipe[0]);
read_buf[read_nbyte - 1] = '\0';
if (read(stderr_pipe[0], read_buf, read_nbyte) == (ssize_t) -1)
CU_FAIL_FATAL("Nothing written to pipe");
CU_ASSERT_STRING_EQUAL(read_buf, "Password: ");
sigaction(SIGPIPE, &ignore, &orig);
write(stdin_pipe[1], "\n", (size_t) 2);
sigaction(SIGPIPE, &orig, NULL);
close(stderr_pipe[0]);
close(stdin_pipe[1]);
return;
}
void passphrase_read_reads_from_stdin_when_no_tty()
{
static const int read_nbyte = 11;
int stdin_pipe[2], stderr_pipe[2], result_pipe[2];
char read_buf[read_nbyte];
struct sigaction ignore, orig;
ignore.sa_handler = SIG_IGN;
sigemptyset(&ignore.sa_mask);
if (pipe(stdin_pipe) != 0
|| pipe(stderr_pipe) != 0
|| pipe(result_pipe) !=0)
CU_FAIL_FATAL("Could not create pipe");
switch (fork())
{
case -1:
CU_FAIL_FATAL("Could not fork");
case 0:
{
static const int password_size = 512;
char buffer[password_size];
close(stderr_pipe[0]);
close(result_pipe[0]);
close(stdin_pipe[1]);
if (setsid() == (pid_t) -1)
CU_FAIL_FATAL("Could not create new session");
dup2(stdin_pipe[0], STDIN_FILENO);
dup2(stderr_pipe[1], STDERR_FILENO);
freerdp_passphrase_read("Password: ", buffer, password_size, 0);
write(result_pipe[1], buffer, strlen(buffer) + (size_t) 1);
exit(EXIT_SUCCESS);
}
}
close(stderr_pipe[1]);
close(result_pipe[1]);
close(stdin_pipe[0]);
read_buf[read_nbyte - 1] = '\0';
if (read(stderr_pipe[0], read_buf, read_nbyte) == (ssize_t) -1)
CU_FAIL_FATAL("Nothing written to pipe");
sigaction(SIGPIPE, &ignore, &orig);
write(stdin_pipe[1], "passw0rd\n", sizeof "passw0rd\n");
sigaction(SIGPIPE, &orig, NULL);
if (read(result_pipe[0], read_buf, read_nbyte) == (ssize_t) -1)
CU_FAIL_FATAL("Nothing written to pipe");
CU_ASSERT_STRING_EQUAL(read_buf, "passw0rd");
close(stderr_pipe[0]);
close(stdin_pipe[1]);
return;
}
void test_passphrase_read(void)
{
passphrase_read_prompts_to_tty();
passphrase_read_reads_from_tty();
passphrase_read_turns_off_echo_during_read();
passphrase_read_resets_terminal_after_read();
passphrase_read_turns_on_newline_echo_during_read();
passphrase_read_prompts_to_stderr_when_no_tty();
passphrase_read_reads_from_stdin_when_no_tty();
}
void handle_signals_resets_terminal(void)
{
int status, masterfd;
char* slavedevice = NULL;
struct termios test_flags;
pid_t child_pid;
masterfd = posix_openpt(O_RDWR|O_NOCTTY);
if (masterfd == -1
|| grantpt (masterfd) == -1
|| unlockpt (masterfd) == -1
|| (slavedevice = ptsname (masterfd)) == NULL)
CU_FAIL_FATAL("Could not create pty");
terminal_fildes = open(slavedevice, O_RDWR|O_NOCTTY);
tcgetattr(terminal_fildes, &orig_flags);
new_flags = orig_flags;
new_flags.c_lflag &= ~ECHO;
tcsetattr(terminal_fildes, TCSANOW, &new_flags);
terminal_needs_reset = 1;
if((child_pid = fork()) == 0)
{
freerdp_handle_signals();
raise(SIGINT);
}
while(wait(&status) != -1);
tcgetattr(terminal_fildes, &test_flags);
CU_ASSERT_EQUAL(orig_flags.c_lflag, test_flags.c_lflag);
close(masterfd);
close(terminal_fildes);
}
void test_handle_signals(void)
{
handle_signals_resets_terminal();
}

View File

@ -1,30 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Utils Unit Tests
*
* Copyright 2011 Vic Lee
*
* 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 "test_freerdp.h"
int init_utils_suite(void);
int clean_utils_suite(void);
int add_utils_suite(void);
void test_load_plugin(void);
void test_wait_obj(void);
void test_args(void);
void test_passphrase_read(void);
void test_handle_signals(void);

View 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

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# libfreerdp-cache cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# 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.
@ -17,7 +15,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(FREERDP_CACHE_SRCS
set(MODULE_NAME "freerdp-cache")
set(MODULE_PREFIX "FREERDP_CACHE")
set(${MODULE_PREFIX}_SRCS
brush.c
pointer.c
bitmap.c
@ -28,22 +29,22 @@ set(FREERDP_CACHE_SRCS
cache.c)
if(WITH_MONOLITHIC_BUILD)
add_library(freerdp-cache OBJECT ${FREERDP_CACHE_SRCS})
add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS})
else()
add_library(freerdp-cache ${FREERDP_CACHE_SRCS})
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
endif()
set_target_properties(freerdp-cache PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
set(FREERDP_CACHE_LIBS)
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
if(WITH_MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${FREERDP_CACHE_LIBS} PARENT_SCOPE)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
set(FREERDP_CACHE_LIBS ${FREERDP_CACHE_LIBS}
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS}
freerdp-core
freerdp-utils)
target_link_libraries(freerdp-cache ${FREERDP_CACHE_LIBS})
install(TARGETS freerdp-cache DESTINATION ${CMAKE_INSTALL_LIBDIR})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP")

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# libfreerdp-channels cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# 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.
@ -17,32 +15,35 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(FREERDP_CHANNELS_SRCS
set(MODULE_NAME "freerdp-channels")
set(MODULE_PREFIX "FREERDP_CHANNELS")
set(${MODULE_PREFIX}_SRCS
libchannels.c
libchannels.h
wtsvc.c
wtsvc.h)
if(WITH_MONOLITHIC_BUILD)
add_library(freerdp-channels OBJECT ${FREERDP_CHANNELS_SRCS})
add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS})
else()
add_library(freerdp-channels ${FREERDP_CHANNELS_SRCS})
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
endif()
set_target_properties(freerdp-channels PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
set(FREERDP_CHANNELS_LIBS)
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
if(WITH_MONOLITHIC_BUILD)
set(FREERDP_CHANNELS_LIBS ${FREERDP_CHANNELS_LIBS} winpr)
set(FREERDP_LIBS ${FREERDP_LIBS} ${FREERDP_CHANNELS_LIBS} PARENT_SCOPE)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
set(FREERDP_CHANNELS_LIBS ${FREERDP_CHANNELS_LIBS}
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS}
freerdp-utils)
set(FREERDP_CHANNELS_LIBS ${FREERDP_CHANNELS_LIBS}
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS}
winpr-synch)
target_link_libraries(freerdp-channels ${FREERDP_CHANNELS_LIBS})
install(TARGETS freerdp-channels DESTINATION ${CMAKE_INSTALL_LIBDIR})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP")

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# libfreerdp-codec cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# 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.
@ -17,7 +15,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(FREERDP_CODEC_SRCS
set(MODULE_NAME "freerdp-codec")
set(MODULE_PREFIX "FREERDP_CODEC")
set(${MODULE_PREFIX}_SRCS
bitmap.c
color.c
rfx_bitstream.h
@ -46,18 +47,18 @@ set(FREERDP_CODEC_SRCS
mppc_enc.c
jpeg.c)
set(FREERDP_CODEC_SSE2_SRCS
set(${MODULE_PREFIX}_SSE2_SRCS
rfx_sse2.c
rfx_sse2.h
nsc_sse2.c
nsc_sse2.h)
set(FREERDP_CODEC_NEON_SRCS
set(${MODULE_PREFIX}_NEON_SRCS
rfx_neon.c
rfx_neon.h)
if(WITH_SSE2)
set(FREERDP_CODEC_SRCS ${FREERDP_CODEC_SRCS} ${FREERDP_CODEC_SSE2_SRCS})
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_SSE2_SRCS})
if(CMAKE_COMPILER_IS_GNUCC)
set_property(SOURCE rfx_sse2.c nsc_sse2.c PROPERTY COMPILE_FLAGS "-msse2")
@ -69,7 +70,7 @@ if(WITH_SSE2)
endif()
if(WITH_NEON)
set(FREERDP_CODEC_SRCS ${FREERDP_CODEC_SRCS} ${FREERDP_CODEC_NEON_SRCS})
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_NEON_SRCS})
set_property(SOURCE rfx_neon.c PROPERTY COMPILE_FLAGS "-mfpu=neon -mfloat-abi=softfp")
endif()
@ -78,22 +79,24 @@ if(WITH_JPEG)
endif()
if(WITH_MONOLITHIC_BUILD)
add_library(freerdp-codec OBJECT ${FREERDP_CODEC_SRCS})
add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS})
else()
add_library(freerdp-codec ${FREERDP_CODEC_SRCS})
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
endif()
set_target_properties(freerdp-codec PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
set(FREERDP_CODEC_LIBS
set(${MODULE_PREFIX}_LIBS
${FREERDP_JPEG_LIBS})
if(WITH_MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${FREERDP_CODEC_LIBS} PARENT_SCOPE)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
set(FREERDP_CODEC_LIBS ${FREERDP_CODEC_LIBS}
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS}
freerdp-utils)
target_link_libraries(freerdp-codec ${FREERDP_CODEC_LIBS})
install(TARGETS freerdp-codec DESTINATION ${CMAKE_INSTALL_LIBDIR})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP")

View File

@ -25,7 +25,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <freerdp/codec/nsc.h>
#include <freerdp/utils/memory.h>

View File

@ -24,7 +24,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <freerdp/codec/nsc.h>
#include <freerdp/utils/memory.h>

View File

@ -24,7 +24,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <freerdp/codec/rfx.h>
#include <freerdp/utils/memory.h>

View File

@ -1,8 +1,6 @@
# FreeRDP: A Remote Desktop Protocol Client
# libfreerdp-core cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
@ -17,12 +15,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "freerdp-core")
set(MODULE_PREFIX "FREERDP_CORE")
add_definitions(-DEXT_PATH="${FREERDP_EXTENSION_PATH}")
include_directories(${OPENSSL_INCLUDE_DIR})
include_directories(${ZLIB_INCLUDE_DIRS})
set(FREERDP_CORE_SRCS
set(${MODULE_PREFIX}_SRCS
activation.c
activation.h
extension.c
@ -92,42 +93,44 @@ set(FREERDP_CORE_SRCS
peer.h)
if(WITH_MONOLITHIC_BUILD)
add_library(freerdp-core OBJECT ${FREERDP_CORE_SRCS})
add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS})
else()
add_library(freerdp-core ${FREERDP_CORE_SRCS})
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
endif()
set_target_properties(freerdp-core PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
if(WITH_MONOLITHIC_BUILD)
set(FREERDP_CORE_LIBS winpr)
set(${MODULE_PREFIX}_LIBS winpr)
else()
set(FREERDP_CORE_LIBS
set(${MODULE_PREFIX}_LIBS
winpr-utils
winpr-sspi)
if(NOT WIN32)
set(FREERDP_CORE_LIBS ${FREERDP_CORE_LIBS} winpr-registry)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-registry)
endif()
endif()
if(WIN32)
set(FREERDP_CORE_LIBS ${FREERDP_CORE_LIBS} ws2_32)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ws2_32)
else()
set(FREERDP_CORE_LIBS ${FREERDP_CORE_LIBS} ${ZLIB_LIBRARIES})
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${ZLIB_LIBRARIES})
endif()
set(FREERDP_CORE_LIBS ${FREERDP_CORE_LIBS} ${OPENSSL_LIBRARIES})
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${OPENSSL_LIBRARIES})
if(WITH_MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${FREERDP_CORE_LIBS} PARENT_SCOPE)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
set(FREERDP_CORE_LIBS ${FREERDP_CORE_LIBS}
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS}
freerdp-utils
freerdp-codec
freerdp-crypto
freerdp-locale)
target_link_libraries(freerdp-core ${FREERDP_CORE_LIBS})
install(TARGETS freerdp-core DESTINATION ${CMAKE_INSTALL_LIBDIR})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP")

View File

@ -228,8 +228,12 @@ boolean rdp_read_header(rdpRdp* rdp, STREAM* s, uint16* length, uint16* channel_
enum DomainMCSPDU MCSPDU;
MCSPDU = (rdp->settings->server_mode) ? DomainMCSPDU_SendDataRequest : DomainMCSPDU_SendDataIndication;
if (!mcs_read_domain_mcspdu_header(s, &MCSPDU, length))
return false ;
{
if (MCSPDU != DomainMCSPDU_DisconnectProviderUltimatum)
return false;
}
if (*length - 8 > stream_get_left(s))
return false;

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# libfreerdp-crypto cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# 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.
@ -17,7 +15,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(FREERDP_CRYPTO_SRCS
set(MODULE_NAME "freerdp-crypto")
set(MODULE_PREFIX "FREERDP_CRYPTO")
set(${MODULE_PREFIX}_SRCS
er.c
der.c
ber.c
@ -28,39 +29,42 @@ set(FREERDP_CRYPTO_SRCS
tls.c)
if(WITH_MONOLITHIC_BUILD)
add_library(freerdp-crypto OBJECT ${FREERDP_CRYPTO_SRCS})
add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS})
else()
add_library(freerdp-crypto ${FREERDP_CRYPTO_SRCS})
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
endif()
include_directories(${OPENSSL_INCLUDE_DIR})
include_directories(${ZLIB_INCLUDE_DIRS})
set_target_properties(freerdp-crypto PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
set(FREERDP_CRYPTO_LIBS
set(${MODULE_PREFIX}_LIBS
${OPENSSL_LIBRARIES})
if(WITH_MONOLITHIC_BUILD)
set(FREERDP_CRYPTO_LIBS ${FREERDP_CRYPTO_LIBS} winpr)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr)
else()
set(FREERDP_CRYPTO_LIBS ${FREERDP_CRYPTO_LIBS} winpr-sspi)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-sspi)
if(NOT WIN32)
set(FREERDP_CRYPTO_LIBS ${FREERDP_CRYPTO_LIBS} winpr-library)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-library)
endif()
endif()
if(WIN32)
set(FREERDP_CRYPTO_LIBS ${FREERDP_CRYPTO_LIBS} ws2_32)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ws2_32)
else()
set(FREERDP_CRYPTO_LIBS ${FREERDP_CRYPTO_LIBS} ${ZLIB_LIBRARIES})
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${ZLIB_LIBRARIES})
endif()
if(WITH_MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${FREERDP_CRYPTO_LIBS} PARENT_SCOPE)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
set(FREERDP_CRYPTO_LIBS ${FREERDP_CRYPTO_LIBS} freerdp-utils)
target_link_libraries(freerdp-crypto ${FREERDP_CRYPTO_LIBS})
install(TARGETS freerdp-crypto DESTINATION ${CMAKE_INSTALL_LIBDIR})
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-utils)
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP")

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# libfreerdp-gdi cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# 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.
@ -17,9 +15,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "freerdp-gdi")
set(MODULE_PREFIX "FREERDP_GDI")
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set(FREERDP_GDI_SRCS
set(${MODULE_PREFIX}_SRCS
8bpp.c
16bpp.c
32bpp.c
@ -39,24 +40,23 @@ set(FREERDP_GDI_SRCS
gdi.h)
if(WITH_MONOLITHIC_BUILD)
add_library(freerdp-gdi OBJECT ${FREERDP_GDI_SRCS})
add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS})
else()
add_library(freerdp-gdi ${FREERDP_GDI_SRCS})
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
endif()
set_target_properties(freerdp-gdi PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
set(FREERDP_GDI_LIBS)
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
if(WITH_MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${FREERDP_GDI_LIBS} PARENT_SCOPE)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
set(FREERDP_GDI_LIBS ${FREERDP_GDI_LIBS}
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS}
freerdp-core
freerdp-cache
freerdp-codec)
target_link_libraries(freerdp-gdi ${FREERDP_GDI_LIBS})
install(TARGETS freerdp-gdi DESTINATION ${CMAKE_INSTALL_LIBDIR})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP")

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# libfreerdp-locale cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# 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.
@ -17,7 +15,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(FREERDP_LOCALE_SRCS
set(MODULE_NAME "freerdp-locale")
set(MODULE_PREFIX "FREERDP_LOCALE")
set(${MODULE_PREFIX}_SRCS
virtual_key_codes.c
keyboard_layout.c
keyboard.c
@ -25,21 +26,21 @@ set(FREERDP_LOCALE_SRCS
timezone.c
liblocale.h)
set(FREERDP_LOCALE_X11_SRCS
set(${MODULE_PREFIX}_X11_SRCS
xkb_layout_ids.c
xkb_layout_ids.h)
set(FREERDP_LOCALE_X11_KEYMAP_SRCS
set(${MODULE_PREFIX}_X11_KEYMAP_SRCS
keyboard_keymap.c
keyboard_keymap.h
keyboard_x11.c
keyboard_x11.h)
set(FREERDP_LOCALE_XKBFILE_SRCS
set(${MODULE_PREFIX}_XKBFILE_SRCS
keyboard_xkbfile.c
keyboard_xkbfile.h)
set(FREERDP_LOCALE_SUN_SRCS
set(${MODULE_PREFIX}_SUN_SRCS
keyboard_sun.c
keyboard_sun.h)
@ -47,44 +48,45 @@ if(CMAKE_SYSTEM_NAME MATCHES Solaris)
set(WITH_SUN true)
endif()
set(FREERDP_LOCALE_LIBS)
if(NOT WIN32)
find_suggested_package(X11)
if(WITH_X11)
add_definitions(-DWITH_X11)
include_directories(${X11_INCLUDE_DIRS})
set(FREERDP_LOCALE_SRCS ${FREERDP_LOCALE_SRCS} ${FREERDP_LOCALE_X11_SRCS})
set(FREERDP_LOCALE_LIBS ${FREERDP_LOCALE_LIBS} ${X11_LIBRARIES})
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_X11_SRCS})
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${X11_LIBRARIES})
if(WITH_SUN)
add_definitions(-DWITH_SUN)
set(FREERDP_LOCALE_SRCS ${FREERDP_LOCALE_SRCS} ${FREERDP_LOCALE_SUN_SRCS})
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_SUN_SRCS})
elseif(NOT APPLE)
find_suggested_package(XKBFile)
endif()
if(WITH_XKBFILE)
add_definitions(-DWITH_XKBFILE)
include_directories(${XKBFILE_INCLUDE_DIRS})
set(FREERDP_LOCALE_SRCS ${FREERDP_LOCALE_SRCS} ${FREERDP_LOCALE_XKBFILE_SRCS})
set(FREERDP_LOCALE_LIBS ${FREERDP_LOCALE_LIBS} ${XKBFILE_LIBRARIES})
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_XKBFILE_SRCS})
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XKBFILE_LIBRARIES})
else()
set(FREERDP_LOCALE_SRCS ${FREERDP_LOCALE_SRCS} ${FREERDP_LOCALE_X11_KEYMAP_SRCS})
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_X11_KEYMAP_SRCS})
endif()
endif()
endif()
if(WITH_MONOLITHIC_BUILD)
add_library(freerdp-locale OBJECT ${FREERDP_LOCALE_SRCS})
add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS})
else()
add_library(freerdp-locale ${FREERDP_LOCALE_SRCS})
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
endif()
set_target_properties(freerdp-locale PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
if(WITH_MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${FREERDP_LOCALE_LIBS} PARENT_SCOPE)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
set(FREERDP_LOCALE_LIBS ${FREERDP_LOCALE_LIBS} freerdp-utils)
target_link_libraries(freerdp-locale ${FREERDP_LOCALE_LIBS})
install(TARGETS freerdp-locale DESTINATION ${CMAKE_INSTALL_LIBDIR})
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-utils)
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP")

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# libfreerdp-rail cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# 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.
@ -17,7 +15,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(FREERDP_RAIL_SRCS
set(MODULE_NAME "freerdp-rail")
set(MODULE_PREFIX "FREERDP_RAIL")
set(${MODULE_PREFIX}_SRCS
window_list.c
window.c
icon.c
@ -25,19 +26,20 @@ set(FREERDP_RAIL_SRCS
librail.h)
if(WITH_MONOLITHIC_BUILD)
add_library(freerdp-rail OBJECT ${FREERDP_RAIL_SRCS})
add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS})
else()
add_library(freerdp-rail ${FREERDP_RAIL_SRCS})
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
endif()
set_target_properties(freerdp-rail PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
set(FREERDP_RAIL_LIBS)
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
if(WITH_MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${FREERDP_RAIL_LIBS} PARENT_SCOPE)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
set(FREERDP_RAIL_LIBS ${FREERDP_RAIL_LIBS} freerdp-utils)
target_link_libraries(freerdp-rail ${FREERDP_RAIL_LIBS})
install(TARGETS freerdp-rail DESTINATION ${CMAKE_INSTALL_LIBDIR})
set(FREERDP_RAIL_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-utils)
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP")

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# libfreerdp-utils cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# 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.
@ -17,10 +15,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "freerdp-utils")
set(MODULE_PREFIX "FREERDP_UTILS")
set(CMAKE_THREAD_PREFER_PTHREAD)
find_required_package(Threads)
set(FREERDP_UTILS_SRCS
set(${MODULE_PREFIX}_SRCS
args.c
dsp.c
event.c
@ -48,33 +49,37 @@ set(FREERDP_UTILS_SRCS
wait_obj.c)
if(WITH_MONOLITHIC_BUILD)
add_library(freerdp-utils OBJECT ${FREERDP_UTILS_SRCS})
add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS})
else()
add_library(freerdp-utils ${FREERDP_UTILS_SRCS})
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
endif()
set_target_properties(freerdp-utils PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
set(FREERDP_UTILS_LIBS
set(${MODULE_PREFIX}_LIBS
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_DL_LIBS})
if(WIN32)
set(FREERDP_UTILS_LIBS ${FREERDP_UTILS_LIBS} ws2_32)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ws2_32)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES SunOS)
set(FREERDP_UTILS_LIBS ${FREERDP_UTILS_LIBS} rt)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} rt)
endif()
if(WITH_MONOLITHIC_BUILD)
set(FREERDP_UTILS_LIBS ${FREERDP_UTILS_LIBS} winpr)
set(FREERDP_LIBS ${FREERDP_LIBS} ${FREERDP_UTILS_LIBS} PARENT_SCOPE)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
if(NOT WIN32)
set(FREERDP_UTILS_LIBS ${FREERDP_UTILS_LIBS} winpr-crt)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-crt)
endif()
set(FREERDP_UTILS_LIBS ${FREERDP_UTILS_LIBS} winpr-synch)
target_link_libraries(freerdp-utils ${FREERDP_UTILS_LIBS})
install(TARGETS freerdp-utils DESTINATION ${CMAKE_INSTALL_LIBDIR})
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-synch)
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP")

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP Servers
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# 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.
@ -22,7 +20,7 @@
if(NOT WIN32)
# Build Test Server
add_subdirectory(test)
add_subdirectory(Sample)
# Build X11 Server
find_suggested_package(X11)

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP Test Server cmake build script
# FreeRDP Sample Server cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# 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.
@ -17,18 +15,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.
add_executable(tfreerdp-server
set(MODULE_NAME "sfreerdp-server")
set(MODULE_PREFIX "FREERDP_SERVER_SAMPLE")
set(${MODULE_PREFIX}_SRCS
tfreerdp.c)
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
if(WITH_MONOLITHIC_BUILD)
target_link_libraries(tfreerdp-server
target_link_libraries(${MODULE_NAME}
freerdp
freerdp-server-channels)
freerdp-server)
else()
target_link_libraries(tfreerdp-server
target_link_libraries(${MODULE_NAME}
freerdp-core
freerdp-utils
freerdp-codec
freerdp-channels
freerdp-server-channels)
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/Sample")

View File

@ -15,9 +15,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "wfreerdp-server")
set(MODULE_PREFIX "FREERDP_SERVER_WINDOWS")
include_directories(.)
set(WFREERDP_SERVER_SRCS
set(${MODULE_PREFIX}_SRCS
wf_update.c
wf_update.h
wf_dxgi.c
@ -37,37 +40,39 @@ set(WFREERDP_SERVER_SRCS
wf_info.h)
if(WITH_SERVER_INTERFACE)
add_library(wfreerdp-server ${WFREERDP_SERVER_SRCS})
set_target_properties(wfreerdp-server PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
else()
set(WFREERDP_SERVER_SRCS ${WFREERDP_SERVER_SRCS} cli/wfreerdp.c cli/wfreerdp.h)
add_executable(wfreerdp-server ${WFREERDP_SERVER_SRCS})
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} cli/wfreerdp.c cli/wfreerdp.h)
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
endif()
if(WITH_WIN8)
set(WFREERDP_SERVER_LIBS d3d11 dxgi dxguid)
set(${MODULE_PREFIX}_LIBS d3d11 dxgi dxguid)
endif()
if(WITH_MONOLITHIC_BUILD)
set(WFREERDP_SERVER_LIBS ${WFREERDP_SERVER_LIBS} freerdp)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp)
else()
set(WFREERDP_SERVER_LIBS ${WFREERDP_SERVER_LIBS}
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS}
freerdp-core
freerdp-utils
freerdp-codec
freerdp-channels)
endif()
target_link_libraries(wfreerdp-server ${WFREERDP_SERVER_LIBS})
target_link_libraries(wfreerdp-server ${${MODULE_PREFIX}_LIBS})
if(WITH_SERVER_INTERFACE)
install(TARGETS wfreerdp-server DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
else()
install(TARGETS wfreerdp-server DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
if(WITH_SERVER_INTERFACE)
add_subdirectory(cli)
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/Windows")

View File

@ -15,20 +15,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "wfreerdp-server")
set(MODULE_PREFIX "FREERDP_SERVER_WINDOWS_CLI")
include_directories(..)
set(WFREERDP_SERVER_CLI_SRCS
set(${MODULE_PREFIX}_SRCS
wfreerdp.c
wfreerdp.h)
add_executable(wfreerdp-server-cli ${WFREERDP_SERVER_CLI_SRCS})
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
set_target_properties(wfreerdp-server-cli PROPERTIES OUTPUT_NAME "wfreerdp-server")
set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "wfreerdp-server")
set(WFREERDP_SERVER_CLI_LIBS wfreerdp-server)
set(${MODULE_PREFIX}_LIBS wfreerdp-server)
target_link_libraries(wfreerdp-server-cli ${WFREERDP_SERVER_CLI_LIBS})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS wfreerdp-server-cli DESTINATION ${CMAKE_INSTALL_BINDIR})
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/Windows")

View File

@ -21,6 +21,8 @@
#include "config.h"
#endif
#include <stdio.h>
#include <winpr/windows.h>
#include <freerdp/freerdp.h>

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP X11 Server cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# 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.
@ -17,15 +15,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "xfreerdp-server")
set(MODULE_PREFIX "FREERDP_SERVER_X11")
include_directories(${X11_INCLUDE_DIRS})
add_executable(xfreerdp-server
set(${MODULE_PREFIX}_SRCS
xf_peer.c
xf_event.c
xf_input.c
xf_encode.c
xfreerdp.c)
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
find_suggested_package(XShm)
if(WITH_XSHM)
add_definitions(-DWITH_XSHM)
@ -36,42 +39,45 @@ find_suggested_package(Xext)
if(WITH_XEXT)
add_definitions(-DWITH_XEXT)
include_directories(${XEXT_INCLUDE_DIRS})
target_link_libraries(xfreerdp-server ${XEXT_LIBRARIES})
target_link_libraries(${MODULE_NAME} ${XEXT_LIBRARIES})
endif()
find_suggested_package(Xdamage)
if(WITH_XDAMAGE)
add_definitions(-DWITH_XDAMAGE)
include_directories(${XDAMAGE_INCLUDE_DIRS})
target_link_libraries(xfreerdp-server ${XDAMAGE_LIBRARIES})
target_link_libraries(${MODULE_NAME} ${XDAMAGE_LIBRARIES})
endif()
find_suggested_package(Xfixes)
if(WITH_XFIXES)
add_definitions(-DWITH_XFIXES)
include_directories(${XFIXES_INCLUDE_DIRS})
target_link_libraries(xfreerdp-server ${XFIXES_LIBRARIES})
target_link_libraries(${MODULE_NAME} ${XFIXES_LIBRARIES})
endif()
find_suggested_package(XTest)
if(WITH_XTEST)
add_definitions(-DWITH_XTEST)
include_directories(${XTEST_INCLUDE_DIRS})
target_link_libraries(xfreerdp-server ${XTEST_LIBRARIES})
target_link_libraries(${MODULE_NAME} ${XTEST_LIBRARIES})
endif()
if(WITH_MONOLITHIC_BUILD)
target_link_libraries(xfreerdp-server freerdp)
target_link_libraries(xfreerdp-server winpr)
target_link_libraries(${MODULE_NAME} freerdp)
target_link_libraries(${MODULE_NAME} winpr)
else()
target_link_libraries(xfreerdp-server
target_link_libraries(${MODULE_NAME}
freerdp-core
freerdp-codec
freerdp-utils
freerdp-gdi
freerdp-crypto
freerdp-locale)
target_link_libraries(xfreerdp-server winpr-sspi)
target_link_libraries(${MODULE_NAME} winpr-sspi)
endif()
target_link_libraries(xfreerdp-server ${X11_LIBRARIES})
target_link_libraries(${MODULE_NAME} ${X11_LIBRARIES})
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/X11")

View File

@ -25,6 +25,9 @@
#ifndef _WIN32
#define S_OK ((HRESULT) 0L)
#define S_FALSE ((HRESULT) 1L)
/* System Error Codes (0-499) */
#define ERROR_SUCCESS 0x00000000

View File

@ -27,6 +27,82 @@
#ifndef _WIN32
#define FILE_READ_DATA 0x0001
#define FILE_LIST_DIRECTORY 0x0001
#define FILE_WRITE_DATA 0x0002
#define FILE_ADD_FILE 0x0002
#define FILE_APPEND_DATA 0x0004
#define FILE_ADD_SUBDIRECTORY 0x0004
#define FILE_CREATE_PIPE_INSTANCE 0x0004
#define FILE_READ_EA 0x0008
#define FILE_WRITE_EA 0x0010
#define FILE_EXECUTE 0x0020
#define FILE_TRAVERSE 0x0020
#define FILE_DELETE_CHILD 0x0040
#define FILE_READ_ATTRIBUTES 0x0080
#define FILE_WRITE_ATTRIBUTES 0x0100
#define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF)
#define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE)
#define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE)
#define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE)
#define FILE_SHARE_READ 0x00000001
#define FILE_SHARE_WRITE 0x00000002
#define FILE_SHARE_DELETE 0x00000004
#define FILE_ATTRIBUTE_READONLY 0x00000001
#define FILE_ATTRIBUTE_HIDDEN 0x00000002
#define FILE_ATTRIBUTE_SYSTEM 0x00000004
#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
#define FILE_ATTRIBUTE_ARCHIVE 0x00000020
#define FILE_ATTRIBUTE_DEVICE 0x00000040
#define FILE_ATTRIBUTE_NORMAL 0x00000080
#define FILE_ATTRIBUTE_TEMPORARY 0x00000100
#define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
#define FILE_ATTRIBUTE_COMPRESSED 0x00000800
#define FILE_ATTRIBUTE_OFFLINE 0x00001000
#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
#define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
#define FILE_ATTRIBUTE_VIRTUAL 0x00010000
#define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
#define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
#define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
#define FILE_NOTIFY_CHANGE_SIZE 0x00000008
#define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
#define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
#define FILE_NOTIFY_CHANGE_CREATION 0x00000040
#define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
#define FILE_ACTION_ADDED 0x00000001
#define FILE_ACTION_REMOVED 0x00000002
#define FILE_ACTION_MODIFIED 0x00000003
#define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
#define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
#define FILE_CASE_SENSITIVE_SEARCH 0x00000001
#define FILE_CASE_PRESERVED_NAMES 0x00000002
#define FILE_UNICODE_ON_DISK 0x00000004
#define FILE_PERSISTENT_ACLS 0x00000008
#define FILE_FILE_COMPRESSION 0x00000010
#define FILE_VOLUME_QUOTAS 0x00000020
#define FILE_SUPPORTS_SPARSE_FILES 0x00000040
#define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
#define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
#define FILE_VOLUME_IS_COMPRESSED 0x00008000
#define FILE_SUPPORTS_OBJECT_IDS 0x00010000
#define FILE_SUPPORTS_ENCRYPTION 0x00020000
#define FILE_NAMED_STREAMS 0x00040000
#define FILE_READ_ONLY_VOLUME 0x00080000
#define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000
#define FILE_SUPPORTS_TRANSACTIONS 0x00200000
#define FILE_SUPPORTS_HARD_LINKS 0x00400000
#define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
#define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000
#define FILE_SUPPORTS_USN_JOURNAL 0x02000000
#define FILE_FLAG_WRITE_THROUGH 0x80000000
#define FILE_FLAG_OVERLAPPED 0x40000000
#define FILE_FLAG_NO_BUFFERING 0x20000000
@ -39,6 +115,12 @@
#define FILE_FLAG_OPEN_NO_RECALL 0x00100000
#define FILE_FLAG_FIRST_PIPE_INSTANCE 0x00080000
#define CREATE_NEW 1
#define CREATE_ALWAYS 2
#define OPEN_EXISTING 3
#define OPEN_ALWAYS 4
#define TRUNCATE_EXISTING 5
typedef union _FILE_SEGMENT_ELEMENT
{
PVOID64 Buffer;
@ -47,6 +129,16 @@ typedef union _FILE_SEGMENT_ELEMENT
typedef VOID (*LPOVERLAPPED_COMPLETION_ROUTINE)(DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped);
WINPR_API HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
WINPR_API HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
WINPR_API BOOL DeleteFileA(LPCSTR lpFileName);
WINPR_API BOOL DeleteFileW(LPCWSTR lpFileName);
WINPR_API BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped);
@ -87,6 +179,14 @@ WINPR_API BOOL UnlockFile(HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffse
WINPR_API BOOL UnlockFileEx(HANDLE hFile, DWORD dwReserved, DWORD nNumberOfBytesToUnlockLow,
DWORD nNumberOfBytesToUnlockHigh, LPOVERLAPPED lpOverlapped);
#ifdef UNICODE
#define CreateFile CreateFileW
#define DeleteFile DeleteFileW
#else
#define CreateFile CreateFileA
#define DeleteFile DeleteFileA
#endif
#endif
#endif /* WINPR_FILE_H */

View File

@ -57,7 +57,7 @@ typedef struct LIST_ENTRY64
} LIST_ENTRY64;
typedef LIST_ENTRY64 *PLIST_ENTRY64;
#ifdef _AMD64_
#ifdef _WIN64
typedef struct _SLIST_ENTRY *PSLIST_ENTRY;
typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY
@ -65,24 +65,46 @@ typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY
PSLIST_ENTRY Next;
} SLIST_ENTRY;
#else /* _AMD64_ */
#else /* _WIN64 */
#define SLIST_ENTRY SINGLE_LIST_ENTRY
#define _SLIST_ENTRY _SINGLE_LIST_ENTRY
#define PSLIST_ENTRY PSINGLE_LIST_ENTRY
#endif /* _AMD64_ */
#endif /* _WIN64 */
#if defined(_AMD64_)
#ifdef _WIN64
typedef struct DECLSPEC_ALIGN(16) _SLIST_HEADER
typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER
{
ULONGLONG Alignment;
ULONGLONG Region;
} SLIST_HEADER;
typedef struct _SLIST_HEADER *PSLIST_HEADER;
struct
{
ULONGLONG Alignment;
ULONGLONG Region;
} DUMMYSTRUCTNAME;
#else /* _AMD64_ */
struct
{
ULONGLONG Depth:16;
ULONGLONG Sequence:9;
ULONGLONG NextEntry:39;
ULONGLONG HeaderType:1;
ULONGLONG Init:1;
ULONGLONG Reserved:59;
ULONGLONG Region:3;
} Header8;
struct
{
ULONGLONG Depth:16;
ULONGLONG Sequence:48;
ULONGLONG HeaderType:1;
ULONGLONG Reserved:3;
ULONGLONG NextEntry:60;
} HeaderX64;
} SLIST_HEADER, *PSLIST_HEADER;
#else /* _WIN64 */
typedef union _SLIST_HEADER
{
@ -96,13 +118,13 @@ typedef union _SLIST_HEADER
} DUMMYSTRUCTNAME;
} SLIST_HEADER, *PSLIST_HEADER;
#endif /* _AMD64_ */
#endif /* _WIN64 */
WINPR_API VOID InitializeSListHead(PSLIST_HEADER ListHead);
WINPR_API PSLIST_ENTRY InterlockedPopEntrySList(PSLIST_HEADER ListHead);
WINPR_API PSLIST_ENTRY InterlockedPushEntrySList(PSLIST_HEADER ListHead, PSLIST_ENTRY ListEntry);
WINPR_API PSLIST_ENTRY InterlockedPushListSListEx(PSLIST_HEADER ListHead, PSLIST_ENTRY List, PSLIST_ENTRY ListEnd, ULONG Count);
WINPR_API PSLIST_ENTRY InterlockedPopEntrySList(PSLIST_HEADER ListHead);
WINPR_API PSLIST_ENTRY InterlockedFlushSList(PSLIST_HEADER ListHead);
WINPR_API USHORT QueryDepthSList(PSLIST_HEADER ListHead);
@ -113,8 +135,8 @@ WINPR_API LONG InterlockedDecrement(LONG volatile *Addend);
WINPR_API LONG InterlockedExchange(LONG volatile *Target, LONG Value);
WINPR_API LONG InterlockedExchangeAdd(LONG volatile *Addend, LONG Value);
WINPR_API LONG InterlockedCompareExchange(LONG volatile *Destination,LONG ExChange, LONG Comperand);
WINPR_API LONG64 InterlockedCompareExchange64(LONG64 volatile *Destination, LONG64 ExChange, LONG64 Comperand);
WINPR_API LONG InterlockedCompareExchange(LONG volatile *Destination,LONG Exchange, LONG Comperand);
WINPR_API LONGLONG InterlockedCompareExchange64(LONGLONG volatile *Destination, LONGLONG Exchange, LONGLONG Comperand);
#endif /* _WIN32 */

View File

@ -23,6 +23,8 @@
#include <winpr/winpr.h>
#include <winpr/wtypes.h>
#ifndef _WIN32
typedef HANDLE DLL_DIRECTORY_COOKIE;
#define LOAD_LIBRARY_SEARCH_APPLICATION_DIR 0x00000200
@ -34,8 +36,6 @@ WINPR_API DLL_DIRECTORY_COOKIE AddDllDirectory(PCWSTR NewDirectory);
WINPR_API BOOL RemoveDllDirectory(DLL_DIRECTORY_COOKIE Cookie);
WINPR_API BOOL SetDefaultDllDirectories(DWORD DirectoryFlags);
#ifndef _WIN32
WINPR_API HMODULE LoadLibraryA(LPCSTR lpLibFileName);
WINPR_API HMODULE LoadLibraryW(LPCWSTR lpLibFileName);

View File

@ -21,8 +21,30 @@
#define WINPR_PATH_H
#include <winpr/winpr.h>
#include <winpr/tchar.h>
#include <winpr/error.h>
#include <winpr/wtypes.h>
//#define HAVE_PATHCCH_H 1
#ifdef HAVE_PATHCCH_H
#include <Pathcch.h>
#else
#define PATHCCH_ALLOW_LONG_PATHS 0x00000001 /* Allow building of \\?\ paths if longer than MAX_PATH */
#define VOLUME_PREFIX _T("\\\\?\\Volume")
#define VOLUME_PREFIX_LEN ((sizeof(VOLUME_PREFIX) / sizeof(TCHAR)) - 1)
/*
* Maximum number of characters we support using the "\\?\" syntax
* (0x7FFF + 1 for NULL terminator)
*/
#define PATHCCH_MAX_CCH 0x8000
WINPR_API HRESULT PathCchAddBackslashA(PSTR pszPath, size_t cchPath);
WINPR_API HRESULT PathCchAddBackslashW(PWSTR pszPath, size_t cchPath);
@ -137,4 +159,6 @@ WINPR_API HRESULT PathCchRemoveFileSpecW(PWSTR pszPath, size_t cchPath);
#define PathCchRemoveFileSpec PathCchRemoveFileSpecA
#endif
#endif
#endif /* WINPR_PATH_H */

View File

@ -27,6 +27,10 @@
#endif
#endif /* _AMD64_ */
#ifdef _AMD64_
#define _WIN64
#endif
#ifndef DECLSPEC_ALIGN
#if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
#define DECLSPEC_ALIGN(x) __declspec(align(x))
@ -37,11 +41,13 @@
#endif
#endif /* DECLSPEC_ALIGN */
#ifdef _AMD64_
#ifdef _WIN64
#define MEMORY_ALLOCATION_ALIGNMENT 16
#else
#define MEMORY_ALLOCATION_ALIGNMENT 8
#endif
#define DUMMYSTRUCTNAME s
#endif /* WINPR_SPEC_H */

View File

@ -34,11 +34,13 @@ typedef WCHAR TCHAR;
#define _tprintf wprintf
#define _tcsdup _wcsdup
#define _tcscmp wcscmp
#define _tcscpy wcscpy
#else
typedef CHAR TCHAR;
#define _tprintf printf
#define _tcsdup _strdup
#define _tcscmp strcmp
#define _tcscpy strcpy
#endif
typedef TCHAR *LPTSTR, *LPTCH;

View File

@ -15,19 +15,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(WINPR_ASN1_SRCS
set(MODULE_NAME "winpr-asn1")
set(MODULE_PREFIX "WINPR_ASN1")
set(${MODULE_PREFIX}_SRCS
asn1.c)
if(WITH_MONOLITHIC_BUILD)
add_library(winpr-asn1 OBJECT ${WINPR_ASN1_SRCS})
add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS})
else()
add_library(winpr-asn1 ${WINPR_ASN1_SRCS})
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
endif()
set_target_properties(winpr-asn1 PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib")
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib")
if(WITH_MONOLITHIC_BUILD)
else()
install(TARGETS winpr-asn1 DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR")

View File

@ -15,32 +15,37 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(WINPR_BCRYPT_SRCS
set(MODULE_NAME "winpr-bcrypt")
set(MODULE_PREFIX "WINPR_BCRYPT")
set(${MODULE_PREFIX}_SRCS
bcrypt.c)
if(WITH_MONOLITHIC_BUILD)
add_library(winpr-bcrypt OBJECT ${WINPR_BCRYPT_SRCS})
add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS})
else()
add_library(winpr-bcrypt ${WINPR_BCRYPT_SRCS})
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
endif()
include_directories(${OPENSSL_INCLUDE_DIR})
include_directories(${ZLIB_INCLUDE_DIRS})
set_target_properties(winpr-bcrypt PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib")
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib")
set(WINPR_BCRYPT_LIBS
set(${MODULE_PREFIX}_LIBS
${ZLIB_LIBRARIES})
if(WITH_MONOLITHIC_BUILD)
set(WINPR_LIBS ${WINPR_LIBS} ${WINPR_BCRYPT_LIBS} PARENT_SCOPE)
set(WINPR_LIBS ${WINPR_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
if(NOT WIN32)
set(WINPR_BCRYPT_LIBS ${WINPR_BCRYPT_LIBS} winpr-crt)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-crt)
endif()
set(WINPR_BCRYPT_LIBS ${WINPR_BCRYPT_LIBS} winpr-utils)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-utils)
target_link_libraries(winpr-bcrypt ${WINPR_BCRYPT_LIBS})
install(TARGETS winpr-bcrypt DESTINATION ${CMAKE_INSTALL_LIBDIR})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR")

View File

@ -15,21 +15,30 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(WINPR_CRT_SRCS
set(MODULE_NAME "winpr-crt")
set(MODULE_PREFIX "WINPR_CRT")
set(${MODULE_PREFIX}_SRCS
alignment.c
memory.c
string.c)
if(WITH_MONOLITHIC_BUILD)
add_library(winpr-crt OBJECT ${WINPR_CRT_SRCS})
add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS})
else()
add_library(winpr-crt ${WINPR_CRT_SRCS})
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
endif()
set_target_properties(winpr-crt PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib")
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib")
if(WITH_MONOLITHIC_BUILD)
else()
install(TARGETS winpr-crt DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR")
if(BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@ -27,14 +27,31 @@
#ifndef _WIN32
#include <stdlib.h>
#include <malloc.h>
void* _aligned_malloc(size_t size, size_t alignment)
{
return NULL;
void* memptr;
/* alignment must be a power of 2 */
if (alignment % 2 == 1)
return NULL;
if (posix_memalign(&memptr, alignment, size) != 0)
return NULL;
return memptr;
}
void* _aligned_realloc(void* memblock, size_t size, size_t alignment)
{
return NULL;
void* memptr = NULL;
memptr = realloc(memblock, size);
return memptr;
}
void* _aligned_recalloc(void* memblock, size_t num, size_t size, size_t alignment)
@ -44,7 +61,27 @@ void* _aligned_recalloc(void* memblock, size_t num, size_t size, size_t alignmen
void* _aligned_offset_malloc(size_t size, size_t alignment, size_t offset)
{
return NULL;
void* memptr;
/* alignment must be a power of 2 */
if (alignment % 2 == 1)
return NULL;
/* offset must be less than size */
if (offset >= size)
return NULL;
/* minimum alignment is pointer size */
if (alignment < sizeof(void*))
alignment = sizeof(void*);
if (posix_memalign(&memptr, alignment, size) != 0)
return NULL;
return memptr;
}
void* _aligned_offset_realloc(void* memblock, size_t size, size_t alignment, size_t offset)
@ -64,7 +101,7 @@ size_t _aligned_msize(void* memblock, size_t alignment, size_t offset)
void _aligned_free(void* memblock)
{
free(memblock);
}
#endif

3
winpr/libwinpr/crt/test/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
TestCrt
TestCrt.c

View File

@ -0,0 +1,26 @@
set(MODULE_NAME "TestCrt")
set(MODULE_PREFIX "TEST_CRT")
set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c)
set(${MODULE_PREFIX}_TESTS
TestAlignment.c)
create_test_sourcelist(${MODULE_PREFIX}_SRCS
${${MODULE_PREFIX}_DRIVER}
${${MODULE_PREFIX}_TESTS})
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
if(NOT WIN32)
target_link_libraries(${MODULE_NAME} winpr-crt)
endif()
foreach(test ${${MODULE_PREFIX}_TESTS})
get_filename_component(TestName ${test} NAME_WE)
add_test(${TestName} ${EXECUTABLE_OUTPUT_PATH}/${MODULE_NAME} ${TestName})
endforeach()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Test")

View File

@ -0,0 +1,83 @@
#include <stdio.h>
#include <malloc.h>
#include <winpr/crt.h>
#include <winpr/windows.h>
int TestAlignment(int argc, char* argv[])
{
void* ptr;
size_t alignment;
size_t offset;
/* Alignment should be 2^N where N is a positive integer */
alignment = 16;
offset = 5;
/* _aligned_malloc */
ptr = _aligned_malloc(100, alignment);
if (ptr == NULL)
{
printf("Error allocating aligned memory.\n");
return -1;
}
if (((size_t) ptr % alignment) != 0)
{
printf("This pointer, %d, is not aligned on %d\n", ptr, alignment);
return -1;
}
/* _aligned_realloc */
ptr = _aligned_realloc(ptr, 200, alignment);
if (((size_t) ptr % alignment) != 0)
{
printf("This pointer, %d, is not aligned on %d\n", ptr, alignment);
return -1;
}
_aligned_free(ptr);
/* _aligned_offset_malloc */
ptr = _aligned_offset_malloc(200, alignment, offset);
if (ptr == NULL)
{
printf("Error reallocating aligned offset memory.");
return -1;
}
if (((((size_t) ptr) + offset) % alignment) != 0)
{
printf("This pointer, %d, does not satisfy offset %d and alignment %d\n", ptr, offset, alignment);
return -1;
}
/* _aligned_offset_realloc */
ptr = _aligned_offset_realloc(ptr, 200, alignment, offset);
if (ptr == NULL)
{
printf("Error reallocating aligned offset memory.");
return -1;
}
if (((((size_t) ptr) + offset) % alignment) != 0)
{
printf("This pointer, %d, does not satisfy offset %d and alignment %d\n", ptr, offset, alignment);
return -1;
}
/* _aligned_free works for both _aligned_malloc and _aligned_offset_malloc. free() should not be used. */
_aligned_free(ptr);
return 0;
}

View File

@ -15,19 +15,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(WINPR_DSPARSE_SRCS
set(MODULE_NAME "winpr-dsparse")
set(MODULE_PREFIX "WINPR_DSPARSE")
set(${MODULE_PREFIX}_SRCS
dsparse.c)
if(WITH_MONOLITHIC_BUILD)
add_library(winpr-dsparse OBJECT ${WINPR_DSPARSE_SRCS})
add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS})
else()
add_library(winpr-dsparse ${WINPR_DSPARSE_SRCS})
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
endif()
set_target_properties(winpr-dsparse PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib")
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib")
if(WITH_MONOLITHIC_BUILD)
else()
install(TARGETS winpr-dsparse DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR")

View File

@ -35,3 +35,4 @@ else()
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR")

View File

@ -35,3 +35,4 @@ else()
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR")

View File

@ -32,6 +32,12 @@ set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SO
if(WITH_MONOLITHIC_BUILD)
else()
if(NOT WIN32)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-handle)
endif()
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR")

View File

@ -26,17 +26,20 @@
/**
* api-ms-win-core-file-l1-2-0.dll:
*
* CompareFileTime
* CreateDirectoryA
* CreateDirectoryW
* CreateFile2
* CreateFileA
* CreateFileW
* DefineDosDeviceW
* CreateFile2
* DeleteFileA
* DeleteFileW
* CreateDirectoryA
* CreateDirectoryW
* RemoveDirectoryA
* RemoveDirectoryW
* CompareFileTime
* DefineDosDeviceW
* DeleteVolumeMountPointW
* FileTimeToLocalFileTime
* LocalFileTimeToFileTime
* FindClose
* FindCloseChangeNotification
* FindFirstChangeNotificationA
@ -82,10 +85,7 @@
* GetVolumeNameForVolumeMountPointW
* GetVolumePathNamesForVolumeNameW
* GetVolumePathNameW
* LocalFileTimeToFileTime
* QueryDosDeviceW
* RemoveDirectoryA
* RemoveDirectoryW
* SetFileAttributesA
* SetFileAttributesW
* SetFileTime
@ -109,6 +109,28 @@
#ifndef _WIN32
HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{
return NULL;
}
HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{
return NULL;
}
BOOL DeleteFileA(LPCSTR lpFileName)
{
return TRUE;
}
BOOL DeleteFileW(LPCWSTR lpFileName)
{
return TRUE;
}
BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)
{

View File

@ -15,20 +15,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(WINPR_HANDLE_SRCS
set(MODULE_NAME "winpr-handle")
set(MODULE_PREFIX "WINPR_HANDLE")
set(${MODULE_PREFIX}_SRCS
handle.c
table.c)
if(WITH_MONOLITHIC_BUILD)
add_library(winpr-handle OBJECT ${WINPR_HANDLE_SRCS})
add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS})
else()
add_library(winpr-handle ${WINPR_HANDLE_SRCS})
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
endif()
set_target_properties(winpr-handle PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib")
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib")
if(WITH_MONOLITHIC_BUILD)
else()
install(TARGETS winpr-handle DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR")

View File

@ -15,19 +15,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(WINPR_HEAP_SRCS
set(MODULE_NAME "winpr-heap")
set(MODULE_PREFIX "WINPR_HEAP")
set(${MODULE_PREFIX}_SRCS
heap.c)
if(WITH_MONOLITHIC_BUILD)
add_library(winpr-heap OBJECT ${WINPR_HEAP_SRCS})
add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS})
else()
add_library(winpr-heap ${WINPR_HEAP_SRCS})
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
endif()
set_target_properties(winpr-heap PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib")
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib")
if(WITH_MONOLITHIC_BUILD)
else()
install(TARGETS winpr-heap DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR")

View File

@ -23,6 +23,8 @@
#include <winpr/crt.h>
#include <winpr/heap.h>
/* Memory Allocation: http://msdn.microsoft.com/en-us/library/hk1k7x6x.aspx */
/* Memory Management Functions: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366781/ */

View File

@ -15,20 +15,29 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(WINPR_INTERLOCKED_SRCS
set(MODULE_NAME "winpr-interlocked")
set(MODULE_PREFIX "WINPR_INTERLOCKED")
set(${MODULE_PREFIX}_SRCS
interlocked.c)
if(WITH_MONOLITHIC_BUILD)
add_library(winpr-interlocked OBJECT ${WINPR_INTERLOCKED_SRCS})
add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS})
else()
add_library(winpr-interlocked ${WINPR_INTERLOCKED_SRCS})
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
endif()
set_target_properties(winpr-interlocked PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib")
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib")
if(WITH_MONOLITHIC_BUILD)
else()
install(TARGETS winpr-interlocked DESTINATION ${CMAKE_INSTALL_LIBDIR})
target_link_libraries(${MODULE_NAME} winpr-crt)
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR")
if(BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@ -42,34 +42,163 @@
#ifndef _WIN32
#include <stdio.h>
#include <stdlib.h>
VOID InitializeSListHead(PSLIST_HEADER ListHead)
{
}
PSLIST_ENTRY InterlockedPopEntrySList(PSLIST_HEADER ListHead)
{
return NULL;
#ifdef _WIN64
ListHead->s.Alignment = 0;
ListHead->s.Region = 0;
ListHead->Header8.Init = 1;
#else
ListHead->Alignment = 0;
#endif
}
PSLIST_ENTRY InterlockedPushEntrySList(PSLIST_HEADER ListHead, PSLIST_ENTRY ListEntry)
{
return NULL;
SLIST_HEADER old;
SLIST_HEADER new;
#ifdef _WIN64
new.HeaderX64.NextEntry = (((ULONG_PTR) ListEntry) >> 4);
while (1)
{
old = *ListHead;
ListEntry->Next = (PSLIST_ENTRY) (((ULONG_PTR) old.HeaderX64.NextEntry) << 4);
new.HeaderX64.Depth = old.HeaderX64.Depth + 1;
new.HeaderX64.Sequence = old.HeaderX64.Sequence + 1;
if (InterlockedCompareExchange64((LONGLONG*) ListHead, new.s.Alignment, old.s.Alignment))
{
InterlockedCompareExchange64(&((LONGLONG*) ListHead)[1], new.s.Region, old.s.Region);
break;
}
}
return (PSLIST_ENTRY) ((ULONG_PTR) old.HeaderX64.NextEntry << 4);
#else
new.s.Next.Next = entry;
do
{
old = *ListHead;
ListEntry->Next = old.s.Next.Next;
new.s.Depth = old.s.Depth + 1;
new.s.Sequence = old.s.Sequence + 1;
}
while(InterlockedCompareExchange64(&ListHead->Alignment, new.Alignment, old.Alignment) != old.Alignment);
return old.s.Next.Next;
#endif
}
PSLIST_ENTRY InterlockedPushListSListEx(PSLIST_HEADER ListHead, PSLIST_ENTRY List, PSLIST_ENTRY ListEnd, ULONG Count)
{
#ifdef _WIN64
#else
#endif
return NULL;
}
PSLIST_ENTRY InterlockedPopEntrySList(PSLIST_HEADER ListHead)
{
SLIST_HEADER old;
SLIST_HEADER new;
PSLIST_ENTRY entry;
#ifdef _WIN64
while (1)
{
old = *ListHead;
entry = (PSLIST_ENTRY) (((ULONG_PTR) old.HeaderX64.NextEntry) << 4);
if (!entry)
return NULL;
new.HeaderX64.NextEntry = ((ULONG_PTR) entry->Next) >> 4;
new.HeaderX64.Depth = old.HeaderX64.Depth - 1;
new.HeaderX64.Sequence = old.HeaderX64.Sequence - 1;
if (InterlockedCompareExchange64((LONGLONG*) ListHead, new.s.Alignment, old.s.Alignment))
{
InterlockedCompareExchange64(&((LONGLONG*) ListHead)[1], new.s.Region, old.s.Region);
break;
}
}
#else
do
{
old = *ListHead;
entry = old.s.Next.Next;
if (!entry)
return NULL;
new.s.Next.Next = entry->Next;
new.s.Depth = old.s.Depth - 1;
new.s.Sequence = old.s.Sequence + 1;
}
while(InterlockedCompareExchange64(&ListHead->Alignment, new.Alignment, old.Alignment) != old.Alignment);
#endif
return entry;
}
PSLIST_ENTRY InterlockedFlushSList(PSLIST_HEADER ListHead)
{
return NULL;
SLIST_HEADER old;
SLIST_HEADER new;
if (!QueryDepthSList(ListHead))
return NULL;
#ifdef _WIN64
new.s.Alignment = 0;
new.s.Region = 0;
new.HeaderX64.HeaderType = 1;
while (1)
{
old = *ListHead;
new.HeaderX64.Sequence = old.HeaderX64.Sequence + 1;
if (InterlockedCompareExchange64((LONGLONG*) ListHead, new.s.Alignment, old.s.Alignment))
{
InterlockedCompareExchange64(&((LONGLONG*) ListHead)[1], new.s.Region, old.s.Region);
break;
}
}
return (PSLIST_ENTRY) (((ULONG_PTR) old.HeaderX64.NextEntry) << 4);
#else
new.Alignment = 0;
do
{
old = *ListHead;
new.s.Sequence = old.s.Sequence + 1;
}
while(InterlockedCompareExchange64(&ListHead->Alignment, new.Alignment, old.Alignment) != old.Alignment);
return old.s.Next.Next;
#endif
}
USHORT QueryDepthSList(PSLIST_HEADER ListHead)
{
return 0;
#ifdef _WIN64
return ListHead->HeaderX64.Depth;
#else
return ListHead->s.Depth;
#endif
}
LONG InterlockedIncrement(LONG volatile *Addend)
@ -102,25 +231,25 @@ LONG InterlockedExchange(LONG volatile *Target, LONG Value)
LONG InterlockedExchangeAdd(LONG volatile *Addend, LONG Value)
{
#ifdef __GNUC__
return __sync_add_and_fetch(Addend, Value);
return __sync_fetch_and_add(Addend, Value);
#else
return 0;
#endif
}
LONG InterlockedCompareExchange(LONG volatile *Destination, LONG ExChange, LONG Comperand)
LONG InterlockedCompareExchange(LONG volatile *Destination, LONG Exchange, LONG Comperand)
{
#ifdef __GNUC__
return __sync_val_compare_and_swap(Destination, Comperand, ExChange);
return __sync_val_compare_and_swap(Destination, Comperand, Exchange);
#else
return 0;
#endif
}
LONG64 InterlockedCompareExchange64(LONG64 volatile *Destination, LONG64 ExChange, LONG64 Comperand)
LONGLONG InterlockedCompareExchange64(LONGLONG volatile *Destination, LONGLONG Exchange, LONGLONG Comperand)
{
#ifdef __GNUC__
return __sync_val_compare_and_swap(Destination, Comperand, ExChange);
return __sync_val_compare_and_swap(Destination, Comperand, Exchange);
#else
return 0;
#endif

View File

@ -0,0 +1,3 @@
TestInterlocked
TestInterlocked.c

View File

@ -0,0 +1,26 @@
set(MODULE_NAME "TestInterlocked")
set(MODULE_PREFIX "TEST_INTERLOCKED")
set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c)
set(${MODULE_PREFIX}_TESTS
TestInterlockedAccess.c
TestInterlockedSList.c)
create_test_sourcelist(${MODULE_PREFIX}_SRCS
${${MODULE_PREFIX}_DRIVER}
${${MODULE_PREFIX}_TESTS})
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
if(NOT WIN32)
target_link_libraries(${MODULE_NAME} winpr-interlocked)
endif()
foreach(test ${${MODULE_PREFIX}_TESTS})
get_filename_component(TestName ${test} NAME_WE)
add_test(${TestName} ${EXECUTABLE_OUTPUT_PATH}/${MODULE_NAME} ${TestName})
endforeach()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Test")

View File

@ -0,0 +1,164 @@
#include <stdio.h>
#include <malloc.h>
#include <winpr/crt.h>
#include <winpr/windows.h>
#include <winpr/interlocked.h>
int TestInterlockedAccess(int argc, char* argv[])
{
int index;
LONG* Addend;
LONG* Target;
LONG oldValue;
LONG* Destination;
LONGLONG oldValue64;
LONGLONG* Destination64;
/* InterlockedIncrement */
Addend = _aligned_malloc(sizeof(LONG), sizeof(LONG));
*Addend = 0;
for (index = 0; index < 10; index ++)
InterlockedIncrement(Addend);
if (*Addend != 10)
{
printf("InterlockedIncrement failure: Actual: %d, Expected: %d\n", (int) *Addend, 10);
return -1;
}
/* InterlockedDecrement */
for (index = 0; index < 10; index ++)
InterlockedDecrement(Addend);
if (*Addend != 0)
{
printf("InterlockedDecrement failure: Actual: %d, Expected: %d\n", (int) *Addend, 0);
return -1;
}
/* InterlockedExchange */
Target = _aligned_malloc(sizeof(LONG), sizeof(LONG));
*Target = 0xAA;
oldValue = InterlockedExchange(Target, 0xFF);
if (oldValue != 0xAA)
{
printf("InterlockedExchange failure: Actual: 0x%08X, Expected: 0x%08X\n", (int) oldValue, 0xAA);
return -1;
}
if (*Target != 0xFF)
{
printf("InterlockedExchange failure: Actual: 0x%08X, Expected: 0x%08X\n", (int) *Target, 0xFF);
return -1;
}
/* InterlockedExchangeAdd */
*Addend = 25;
oldValue = InterlockedExchangeAdd(Addend, 100);
if (oldValue != 25)
{
printf("InterlockedExchangeAdd failure: Actual: %d, Expected: %d\n", (int) oldValue, 25);
return -1;
}
if (*Addend != 125)
{
printf("InterlockedExchangeAdd failure: Actual: %d, Expected: %d\n", (int) *Addend, 125);
return -1;
}
/* InterlockedCompareExchange (*Destination == Comparand) */
Destination = _aligned_malloc(sizeof(LONG), sizeof(LONG));
*Destination = 0xAABBCCDD;
oldValue = InterlockedCompareExchange(Destination, 0xCCDDEEFF, 0xAABBCCDD);
if (oldValue != 0xAABBCCDD)
{
printf("InterlockedCompareExchange failure: Actual: 0x%08X, Expected: 0x%08X\n", (int) oldValue, 0xAABBCCDD);
return -1;
}
if (*Destination != 0xCCDDEEFF)
{
printf("InterlockedCompareExchange failure: Actual: 0x%08X, Expected: 0x%08X\n", (int) *Destination, 0xCCDDEEFF);
return -1;
}
/* InterlockedCompareExchange (*Destination != Comparand) */
*Destination = 0xAABBCCDD;
oldValue = InterlockedCompareExchange(Destination, 0xCCDDEEFF, 0x66778899);
if (oldValue != 0xAABBCCDD)
{
printf("InterlockedCompareExchange failure: Actual: 0x%08X, Expected: 0x%08X\n", (int) oldValue, 0xAABBCCDD);
return -1;
}
if (*Destination != 0xAABBCCDD)
{
printf("InterlockedCompareExchange failure: Actual: 0x%08X, Expected: 0x%08X\n", (int) *Destination, 0xAABBCCDD);
return -1;
}
/* InterlockedCompareExchange64 (*Destination == Comparand) */
Destination64 = _aligned_malloc(sizeof(LONGLONG), sizeof(LONGLONG));
*Destination64 = 0x66778899AABBCCDD;
oldValue64 = InterlockedCompareExchange64(Destination64, 0x8899AABBCCDDEEFF, 0x66778899AABBCCDD);
if (oldValue64 != 0x66778899AABBCCDD)
{
printf("InterlockedCompareExchange failure: Actual: %lld, Expected: %lld\n", oldValue64, (LONGLONG) 0x66778899AABBCCDD);
return -1;
}
if (*Destination64 != 0x8899AABBCCDDEEFF)
{
printf("InterlockedCompareExchange failure: Actual: %lld, Expected: %lld\n", *Destination64, (LONGLONG) 0x8899AABBCCDDEEFF);
return -1;
}
/* InterlockedCompareExchange64 (*Destination != Comparand) */
*Destination64 = 0x66778899AABBCCDD;
oldValue64 = InterlockedCompareExchange64(Destination64, 0x8899AABBCCDDEEFF, 12345);
if (oldValue64 != 0x66778899AABBCCDD)
{
printf("InterlockedCompareExchange failure: Actual: %lld, Expected: %lld\n", oldValue64, (LONGLONG) 0x66778899AABBCCDD);
return -1;
}
if (*Destination64 != 0x66778899AABBCCDD)
{
printf("InterlockedCompareExchange failure: Actual: %lld, Expected: %lld\n", *Destination64, (LONGLONG) 0x66778899AABBCCDD);
return -1;
}
_aligned_free(Addend);
_aligned_free(Target);
_aligned_free(Destination);
_aligned_free(Destination64);
return 0;
}

View File

@ -0,0 +1,85 @@
#include <stdio.h>
#include <malloc.h>
#include <winpr/crt.h>
#include <winpr/windows.h>
#include <winpr/interlocked.h>
typedef struct _PROGRAM_ITEM
{
SLIST_ENTRY ItemEntry;
ULONG Signature;
} PROGRAM_ITEM, *PPROGRAM_ITEM;
int TestInterlockedSList(int argc, char* argv[])
{
ULONG Count;
PSLIST_ENTRY pFirstEntry;
PSLIST_ENTRY pListEntry;
PSLIST_HEADER pListHead;
PPROGRAM_ITEM pProgramItem;
/* Initialize the list header to a MEMORY_ALLOCATION_ALIGNMENT boundary. */
pListHead = (PSLIST_HEADER) _aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT);
if (!pListHead)
{
printf("Memory allocation failed.\n");
return -1;
}
InitializeSListHead(pListHead);
/* Insert 10 items into the list. */
for (Count = 1; Count <= 10; Count += 1)
{
pProgramItem = (PPROGRAM_ITEM) _aligned_malloc(sizeof(PROGRAM_ITEM), MEMORY_ALLOCATION_ALIGNMENT);
if (!pProgramItem)
{
printf("Memory allocation failed.\n");
return -1;
}
pProgramItem->Signature = Count;
pFirstEntry = InterlockedPushEntrySList(pListHead, &(pProgramItem->ItemEntry));
}
/* Remove 10 items from the list and display the signature. */
for (Count = 10; Count >= 1; Count -= 1)
{
pListEntry = InterlockedPopEntrySList(pListHead);
if (!pListEntry)
{
printf("List is empty.\n");
return -1;
}
pProgramItem = (PPROGRAM_ITEM) pListEntry;
printf("Signature is %d\n", (int) pProgramItem->Signature);
/*
* This example assumes that the SLIST_ENTRY structure is the
* first member of the structure. If your structure does not
* follow this convention, you must compute the starting address
* of the structure before calling the free function.
*/
_aligned_free(pListEntry);
}
/* Flush the list and verify that the items are gone. */
pListEntry = InterlockedFlushSList(pListHead);
pFirstEntry = InterlockedPopEntrySList(pListHead);
if (pFirstEntry)
{
printf("Error: List is not empty.\n");
return -1;
}
_aligned_free(pListHead);
return 0;
}

View File

@ -35,3 +35,4 @@ else()
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR")

Some files were not shown because too many files have changed in this diff Show More