diff --git a/.gitignore b/.gitignore index 21444d459..8bb66ef8b 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 446e685a7..e5eaa9a8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/channels/CMakeLists.txt b/channels/CMakeLists.txt index 9c456090e..09cba743f 100644 --- a/channels/CMakeLists.txt +++ b/channels/CMakeLists.txt @@ -33,4 +33,3 @@ endforeach(FILEPATH) if(WITH_SERVER_CHANNELS) add_subdirectory(server) endif() - diff --git a/channels/audin/server/CMakeLists.txt b/channels/audin/server/CMakeLists.txt index 3280cfd05..d728b7009 100644 --- a/channels/audin/server/CMakeLists.txt +++ b/channels/audin/server/CMakeLists.txt @@ -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() - diff --git a/channels/rdpdr/client/CMakeLists.txt b/channels/rdpdr/client/CMakeLists.txt index 55b0e09ba..a3fa82e1c 100644 --- a/channels/rdpdr/client/CMakeLists.txt +++ b/channels/rdpdr/client/CMakeLists.txt @@ -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() diff --git a/channels/rdpdr/client/disk/CMakeLists.txt b/channels/rdpdr/client/disk/CMakeLists.txt index d6d7935f3..e19638503 100644 --- a/channels/rdpdr/client/disk/CMakeLists.txt +++ b/channels/rdpdr/client/disk/CMakeLists.txt @@ -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(..) diff --git a/channels/rdpdr/client/disk/dirent.h b/channels/rdpdr/client/disk/dirent.h new file mode 100644 index 000000000..fa5a294d5 --- /dev/null +++ b/channels/rdpdr/client/disk/dirent.h @@ -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 +#include +#include +#include +#include +#include + +/* 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*/ diff --git a/channels/rdpdr/client/disk/disk_file.c b/channels/rdpdr/client/disk/disk_file.c index a8a02a8ad..0bf28af66 100644 --- a/channels/rdpdr/client/disk/disk_file.c +++ b/channels/rdpdr/client/disk/disk_file.c @@ -4,6 +4,7 @@ * * Copyright 2010-2011 Marc-Andre Moreau * 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; } diff --git a/channels/rdpdr/client/disk/disk_file.h b/channels/rdpdr/client/disk/disk_file.h index 2d85bf80e..ba55f3c7c 100644 --- a/channels/rdpdr/client/disk/disk_file.h +++ b/channels/rdpdr/client/disk/disk_file.h @@ -4,6 +4,7 @@ * * Copyright 2010-2011 Marc-Andre Moreau * 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 #include -#ifndef _WIN32 +#ifdef _WIN32 +#include +#include +#include "dirent.h" +#include "statvfs.h" +#else #include #include #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 diff --git a/channels/rdpdr/client/disk/disk_main.c b/channels/rdpdr/client/disk/disk_main.c index a6203ecce..f5fc3e508 100644 --- a/channels/rdpdr/client/disk/disk_main.c +++ b/channels/rdpdr/client/disk/disk_main.c @@ -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; + } diff --git a/channels/rdpdr/client/disk/statvfs.c b/channels/rdpdr/client/disk/statvfs.c new file mode 100644 index 000000000..6ab29c4ea --- /dev/null +++ b/channels/rdpdr/client/disk/statvfs.c @@ -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 +#include + +#include +#include + +#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; +} diff --git a/channels/rdpdr/client/disk/statvfs.h b/channels/rdpdr/client/disk/statvfs.h new file mode 100644 index 000000000..a38dc71dc --- /dev/null +++ b/channels/rdpdr/client/disk/statvfs.h @@ -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 */ diff --git a/channels/rdpdr/client/printer/CMakeLists.txt b/channels/rdpdr/client/printer/CMakeLists.txt index ea4e19fa4..91dd64863 100644 --- a/channels/rdpdr/client/printer/CMakeLists.txt +++ b/channels/rdpdr/client/printer/CMakeLists.txt @@ -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}) diff --git a/channels/rdpdr/client/printer/printer_main.c b/channels/rdpdr/client/printer/printer_main.c index a4db9377b..2716472cf 100644 --- a/channels/rdpdr/client/printer/printer_main.c +++ b/channels/rdpdr/client/printer/printer_main.c @@ -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) { diff --git a/channels/rdpdr/client/printer/printer_win.c b/channels/rdpdr/client/printer/printer_win.c new file mode 100644 index 000000000..6b00704b4 --- /dev/null +++ b/channels/rdpdr/client/printer/printer_win.c @@ -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 +#include +#include +#include +#include +#include + +#include "config.h" +#include +#include + +#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; +} + diff --git a/cunit/test_ber.h b/channels/rdpdr/client/printer/printer_win.h similarity index 56% rename from cunit/test_ber.h rename to channels/rdpdr/client/printer/printer_win.h index 0cc922885..5b694ac40 100644 --- a/cunit/test_ber.h +++ b/channels/rdpdr/client/printer/printer_win.h @@ -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 + * 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 + diff --git a/channels/rdpdr/client/smartcard/scard_operations.c b/channels/rdpdr/client/smartcard/scard_operations.c index 52d98c098..88bdc6358 100644 --- a/channels/rdpdr/client/smartcard/scard_operations.c +++ b/channels/rdpdr/client/smartcard/scard_operations.c @@ -28,12 +28,14 @@ #include #include #include -#include #include +#include +#define BOOL PCSC_BOOL #include #include #include +#undef BOOL #include #include @@ -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. */ diff --git a/channels/server/CMakeLists.txt b/channels/server/CMakeLists.txt index d36053b2a..b8de4ee2d 100644 --- a/channels/server/CMakeLists.txt +++ b/channels/server/CMakeLists.txt @@ -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}) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index cb1d48e13..98afbbe4c 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -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 -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # 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) diff --git a/client/DirectFB/CMakeLists.txt b/client/DirectFB/CMakeLists.txt index a9c076d2f..287176422 100644 --- a/client/DirectFB/CMakeLists.txt +++ b/client/DirectFB/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # FreeRDP DirectFB Client # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # 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") diff --git a/client/Mac/CMakeLists.txt b/client/Mac/CMakeLists.txt index 98a9abaa9..c14c063d4 100644 --- a/client/Mac/CMakeLists.txt +++ b/client/Mac/CMakeLists.txt @@ -143,3 +143,5 @@ target_link_libraries(MacFreeRDP freerdp-codec freerdp-rail ) + +set_property(TARGET MacFreeRDP PROPERTY FOLDER "Client/Mac") diff --git a/client/test/CMakeLists.txt b/client/Sample/CMakeLists.txt similarity index 55% rename from client/test/CMakeLists.txt rename to client/Sample/CMakeLists.txt index 2ef51bef2..bebd12694 100644 --- a/client/test/CMakeLists.txt +++ b/client/Sample/CMakeLists.txt @@ -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 -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # 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") diff --git a/client/test/freerdp.c b/client/Sample/freerdp.c similarity index 100% rename from client/test/freerdp.c rename to client/Sample/freerdp.c diff --git a/client/Windows/CMakeLists.txt b/client/Windows/CMakeLists.txt index 4b05882d5..8f3a921e5 100644 --- a/client/Windows/CMakeLists.txt +++ b/client/Windows/CMakeLists.txt @@ -1,48 +1,58 @@ -# FreeRDP: A Remote Desktop Protocol Client -# FreeRDP Windows cmake build script -# -# Copyright 2012 Marc-Andre Moreau -# -# 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 +# +# 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") + diff --git a/client/Windows/wf_event.c b/client/Windows/wf_event.c index 1ee93165b..48450a806 100644 --- a/client/Windows/wf_event.c +++ b/client/Windows/wf_event.c @@ -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); diff --git a/client/Windows/wfreerdp.c b/client/Windows/wfreerdp.c index 17fc9a9ed..60aae23c2 100644 --- a/client/Windows/wfreerdp.c +++ b/client/Windows/wfreerdp.c @@ -41,6 +41,8 @@ #include #include #include +#include +#include #include #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) diff --git a/client/X11/CMakeLists.txt b/client/X11/CMakeLists.txt index 5ecd0fbaf..980579067 100644 --- a/client/X11/CMakeLists.txt +++ b/client/X11/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # FreeRDP X11 Client # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # 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") diff --git a/cmake/ConfigOptions.cmake b/cmake/ConfigOptions.cmake index 76fa33a3b..908caddfd 100644 --- a/cmake/ConfigOptions.cmake +++ b/cmake/ConfigOptions.cmake @@ -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() diff --git a/cmake/FindCUnit.cmake b/cmake/FindCUnit.cmake index 3e6b17518..9abfd121e 100644 --- a/cmake/FindCUnit.cmake +++ b/cmake/FindCUnit.cmake @@ -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) diff --git a/config.h.in b/config.h.in index 74df3e656..d9c4d367a 100644 --- a/config.h.in +++ b/config.h.in @@ -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 diff --git a/cunit/CMakeLists.txt b/cunit/CMakeLists.txt index 18f7c1216..b03f55240 100644 --- a/cunit/CMakeLists.txt +++ b/cunit/CMakeLists.txt @@ -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) + diff --git a/cunit/test_ber.c b/cunit/test_ber.c deleted file mode 100644 index cb555f0e3..000000000 --- a/cunit/test_ber.c +++ /dev/null @@ -1,96 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Basic Encoding Rules (BER) Unit Tests - * - * Copyright 2011 Marc-Andre Moreau - * - * 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 -#include -#include - -#include "test_ber.h" -#include - -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); -} diff --git a/cunit/test_channels.c b/cunit/test_channels.c deleted file mode 100644 index 6ef97cda2..000000000 --- a/cunit/test_channels.c +++ /dev/null @@ -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 -#include -#include -#include -#include -#include -#include - -#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); -} diff --git a/cunit/test_channels.h b/cunit/test_channels.h deleted file mode 100644 index 678a5c08d..000000000 --- a/cunit/test_channels.h +++ /dev/null @@ -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); diff --git a/cunit/test_freerdp.c b/cunit/test_freerdp.c index a7223de83..dc178de85 100644 --- a/cunit/test_freerdp.c +++ b/cunit/test_freerdp.c @@ -19,21 +19,14 @@ #include -#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]) diff --git a/cunit/test_license.c b/cunit/test_license.c index 49e7e0457..997ad6c63 100644 --- a/cunit/test_license.c +++ b/cunit/test_license.c @@ -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); diff --git a/cunit/test_list.c b/cunit/test_list.c deleted file mode 100644 index c5ef963f9..000000000 --- a/cunit/test_list.c +++ /dev/null @@ -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 -#include -#include -#include -#include - -#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); -} diff --git a/cunit/test_list.h b/cunit/test_list.h deleted file mode 100644 index 01afbb02d..000000000 --- a/cunit/test_list.h +++ /dev/null @@ -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); diff --git a/cunit/test_per.c b/cunit/test_per.c deleted file mode 100644 index 3d872849f..000000000 --- a/cunit/test_per.c +++ /dev/null @@ -1,64 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Packed Encoding Rules (PER) Unit Tests - * - * Copyright 2011 Marc-Andre Moreau - * - * 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 -#include -#include - -#include "test_per.h" -#include - -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)); -} diff --git a/cunit/test_per.h b/cunit/test_per.h deleted file mode 100644 index 30f8d6fe6..000000000 --- a/cunit/test_per.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Packed Encoding Rules (PER) Unit Tests - * - * Copyright 2011 Marc-Andre Moreau - * - * 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); diff --git a/cunit/test_sspi.c b/cunit/test_sspi.c deleted file mode 100644 index 213a8d98d..000000000 --- a/cunit/test_sspi.c +++ /dev/null @@ -1,225 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * Security Support Provider Interface (SSPI) Tests - * - * Copyright 2012 Marc-Andre Moreau - * - * 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 -#include - -#include -#include -#include - -#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); -} - - - - - - - - - - - - - - - - - diff --git a/cunit/test_sspi.h b/cunit/test_sspi.h deleted file mode 100644 index 81def91dc..000000000 --- a/cunit/test_sspi.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * Security Support Provider Interface (SSPI) Tests - * - * Copyright 2012 Marc-Andre Moreau - * - * 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); diff --git a/cunit/test_stream.c b/cunit/test_stream.c deleted file mode 100644 index ae1a9e256..000000000 --- a/cunit/test_stream.c +++ /dev/null @@ -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 -#include -#include -#include -#include -#include - -#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); -} diff --git a/cunit/test_stream.h b/cunit/test_stream.h deleted file mode 100644 index 32080edb5..000000000 --- a/cunit/test_stream.h +++ /dev/null @@ -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); diff --git a/cunit/test_utils.c b/cunit/test_utils.c deleted file mode 100644 index 673da5163..000000000 --- a/cunit/test_utils.c +++ /dev/null @@ -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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#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(); -} diff --git a/cunit/test_utils.h b/cunit/test_utils.h deleted file mode 100644 index 6f7567603..000000000 --- a/cunit/test_utils.h +++ /dev/null @@ -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); diff --git a/include/freerdp/utils/svc_plugin.h b/include/freerdp/utils/svc_plugin.h index 4f593d15e..7c2a06131 100644 --- a/include/freerdp/utils/svc_plugin.h +++ b/include/freerdp/utils/svc_plugin.h @@ -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 diff --git a/libfreerdp/cache/CMakeLists.txt b/libfreerdp/cache/CMakeLists.txt index 940f9e409..0cc624659 100644 --- a/libfreerdp/cache/CMakeLists.txt +++ b/libfreerdp/cache/CMakeLists.txt @@ -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 -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # 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") diff --git a/libfreerdp/channels/CMakeLists.txt b/libfreerdp/channels/CMakeLists.txt index 30f61f338..63fa9fdcc 100644 --- a/libfreerdp/channels/CMakeLists.txt +++ b/libfreerdp/channels/CMakeLists.txt @@ -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 -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # 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") diff --git a/libfreerdp/codec/CMakeLists.txt b/libfreerdp/codec/CMakeLists.txt index 6a03e002e..a404535d6 100644 --- a/libfreerdp/codec/CMakeLists.txt +++ b/libfreerdp/codec/CMakeLists.txt @@ -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 -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # 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") diff --git a/libfreerdp/codec/nsc.c b/libfreerdp/codec/nsc.c index ac74dcc0c..4ce27529d 100644 --- a/libfreerdp/codec/nsc.c +++ b/libfreerdp/codec/nsc.c @@ -25,7 +25,9 @@ #include #include #include +#ifdef HAVE_STDINT_H #include +#endif #include #include diff --git a/libfreerdp/codec/nsc_encode.c b/libfreerdp/codec/nsc_encode.c index 7feb4879a..50a9c5bce 100644 --- a/libfreerdp/codec/nsc_encode.c +++ b/libfreerdp/codec/nsc_encode.c @@ -24,7 +24,9 @@ #include #include #include +#ifdef HAVE_STDINT_H #include +#endif #include #include diff --git a/libfreerdp/codec/rfx.c b/libfreerdp/codec/rfx.c index 1e7478356..b3ed3ca99 100644 --- a/libfreerdp/codec/rfx.c +++ b/libfreerdp/codec/rfx.c @@ -24,7 +24,9 @@ #include #include #include +#ifdef HAVE_STDINT_H #include +#endif #include #include diff --git a/libfreerdp/core/CMakeLists.txt b/libfreerdp/core/CMakeLists.txt index 9f4a09423..14467460a 100644 --- a/libfreerdp/core/CMakeLists.txt +++ b/libfreerdp/core/CMakeLists.txt @@ -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 # Copyright 2012 Marc-Andre Moreau # # 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") diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index ad5c99f22..3623c2b67 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -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; diff --git a/libfreerdp/crypto/CMakeLists.txt b/libfreerdp/crypto/CMakeLists.txt index 554f7336e..33f984a63 100644 --- a/libfreerdp/crypto/CMakeLists.txt +++ b/libfreerdp/crypto/CMakeLists.txt @@ -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 -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # 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") diff --git a/libfreerdp/gdi/CMakeLists.txt b/libfreerdp/gdi/CMakeLists.txt index 2513b0673..106fc0f16 100644 --- a/libfreerdp/gdi/CMakeLists.txt +++ b/libfreerdp/gdi/CMakeLists.txt @@ -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 -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # 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") diff --git a/libfreerdp/locale/CMakeLists.txt b/libfreerdp/locale/CMakeLists.txt index 8e9c27035..52e03500e 100644 --- a/libfreerdp/locale/CMakeLists.txt +++ b/libfreerdp/locale/CMakeLists.txt @@ -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 -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # 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") diff --git a/libfreerdp/rail/CMakeLists.txt b/libfreerdp/rail/CMakeLists.txt index 728441ae3..8f256ed37 100644 --- a/libfreerdp/rail/CMakeLists.txt +++ b/libfreerdp/rail/CMakeLists.txt @@ -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 -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # 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") diff --git a/libfreerdp/utils/CMakeLists.txt b/libfreerdp/utils/CMakeLists.txt index 0d3c83b5c..41b2c639e 100644 --- a/libfreerdp/utils/CMakeLists.txt +++ b/libfreerdp/utils/CMakeLists.txt @@ -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 -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # 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") diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 6ac9ede9d..e7b64a890 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # FreeRDP Servers # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # 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) diff --git a/server/test/CMakeLists.txt b/server/Sample/CMakeLists.txt similarity index 63% rename from server/test/CMakeLists.txt rename to server/Sample/CMakeLists.txt index fbf0d72ce..a7219c248 100644 --- a/server/test/CMakeLists.txt +++ b/server/Sample/CMakeLists.txt @@ -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 -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # 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") diff --git a/server/test/rfx_test.pcap b/server/Sample/rfx_test.pcap similarity index 100% rename from server/test/rfx_test.pcap rename to server/Sample/rfx_test.pcap diff --git a/server/test/server.crt b/server/Sample/server.crt similarity index 100% rename from server/test/server.crt rename to server/Sample/server.crt diff --git a/server/test/server.key b/server/Sample/server.key similarity index 100% rename from server/test/server.key rename to server/Sample/server.key diff --git a/server/test/test_icon.ppm b/server/Sample/test_icon.ppm similarity index 100% rename from server/test/test_icon.ppm rename to server/Sample/test_icon.ppm diff --git a/server/test/tfreerdp.c b/server/Sample/tfreerdp.c similarity index 100% rename from server/test/tfreerdp.c rename to server/Sample/tfreerdp.c diff --git a/server/Windows/CMakeLists.txt b/server/Windows/CMakeLists.txt index 59570b44d..b0d680db4 100644 --- a/server/Windows/CMakeLists.txt +++ b/server/Windows/CMakeLists.txt @@ -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") diff --git a/server/Windows/cli/CMakeLists.txt b/server/Windows/cli/CMakeLists.txt index bbd5f1a40..f7d2ade5a 100644 --- a/server/Windows/cli/CMakeLists.txt +++ b/server/Windows/cli/CMakeLists.txt @@ -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") diff --git a/server/Windows/wf_update.c b/server/Windows/wf_update.c index 98bde03a4..70d5a81ca 100644 --- a/server/Windows/wf_update.c +++ b/server/Windows/wf_update.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include + #include #include diff --git a/server/X11/CMakeLists.txt b/server/X11/CMakeLists.txt index be56d64bc..a2fe3f03e 100644 --- a/server/X11/CMakeLists.txt +++ b/server/X11/CMakeLists.txt @@ -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 -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # 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") diff --git a/winpr/include/winpr/error.h b/winpr/include/winpr/error.h index 21f5f05c6..58ffc31d8 100644 --- a/winpr/include/winpr/error.h +++ b/winpr/include/winpr/error.h @@ -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 diff --git a/winpr/include/winpr/file.h b/winpr/include/winpr/file.h index 0b06c8acf..88ee610dd 100644 --- a/winpr/include/winpr/file.h +++ b/winpr/include/winpr/file.h @@ -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 */ diff --git a/winpr/include/winpr/interlocked.h b/winpr/include/winpr/interlocked.h index a3563a75e..d651c629e 100644 --- a/winpr/include/winpr/interlocked.h +++ b/winpr/include/winpr/interlocked.h @@ -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 */ diff --git a/winpr/include/winpr/library.h b/winpr/include/winpr/library.h index 203bcd755..b38cf2a6e 100644 --- a/winpr/include/winpr/library.h +++ b/winpr/include/winpr/library.h @@ -23,6 +23,8 @@ #include #include +#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); diff --git a/winpr/include/winpr/path.h b/winpr/include/winpr/path.h index edcb90314..d823e15be 100644 --- a/winpr/include/winpr/path.h +++ b/winpr/include/winpr/path.h @@ -21,8 +21,30 @@ #define WINPR_PATH_H #include +#include +#include #include +//#define HAVE_PATHCCH_H 1 + +#ifdef HAVE_PATHCCH_H + +#include + +#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 */ diff --git a/winpr/include/winpr/spec.h b/winpr/include/winpr/spec.h index 9a64f9c82..25355e5bc 100644 --- a/winpr/include/winpr/spec.h +++ b/winpr/include/winpr/spec.h @@ -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 */ diff --git a/winpr/include/winpr/tchar.h b/winpr/include/winpr/tchar.h index 9b3cedc62..5d43a0c74 100644 --- a/winpr/include/winpr/tchar.h +++ b/winpr/include/winpr/tchar.h @@ -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; diff --git a/winpr/libwinpr/asn1/CMakeLists.txt b/winpr/libwinpr/asn1/CMakeLists.txt index 7a528f689..5cbef153a 100644 --- a/winpr/libwinpr/asn1/CMakeLists.txt +++ b/winpr/libwinpr/asn1/CMakeLists.txt @@ -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") diff --git a/winpr/libwinpr/bcrypt/CMakeLists.txt b/winpr/libwinpr/bcrypt/CMakeLists.txt index 9aa7646e3..fc58b0b78 100644 --- a/winpr/libwinpr/bcrypt/CMakeLists.txt +++ b/winpr/libwinpr/bcrypt/CMakeLists.txt @@ -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") diff --git a/winpr/libwinpr/crt/CMakeLists.txt b/winpr/libwinpr/crt/CMakeLists.txt index c494a874b..20074470b 100644 --- a/winpr/libwinpr/crt/CMakeLists.txt +++ b/winpr/libwinpr/crt/CMakeLists.txt @@ -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() diff --git a/winpr/libwinpr/crt/alignment.c b/winpr/libwinpr/crt/alignment.c index c947e0496..084eef03f 100644 --- a/winpr/libwinpr/crt/alignment.c +++ b/winpr/libwinpr/crt/alignment.c @@ -27,14 +27,31 @@ #ifndef _WIN32 +#include +#include + 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 diff --git a/winpr/libwinpr/crt/test/.gitignore b/winpr/libwinpr/crt/test/.gitignore new file mode 100644 index 000000000..7180deec5 --- /dev/null +++ b/winpr/libwinpr/crt/test/.gitignore @@ -0,0 +1,3 @@ +TestCrt +TestCrt.c + diff --git a/winpr/libwinpr/crt/test/CMakeLists.txt b/winpr/libwinpr/crt/test/CMakeLists.txt new file mode 100644 index 000000000..b66524907 --- /dev/null +++ b/winpr/libwinpr/crt/test/CMakeLists.txt @@ -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") + diff --git a/winpr/libwinpr/crt/test/TestAlignment.c b/winpr/libwinpr/crt/test/TestAlignment.c new file mode 100644 index 000000000..bd911db0f --- /dev/null +++ b/winpr/libwinpr/crt/test/TestAlignment.c @@ -0,0 +1,83 @@ + +#include +#include +#include +#include + +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; +} + diff --git a/winpr/libwinpr/dsparse/CMakeLists.txt b/winpr/libwinpr/dsparse/CMakeLists.txt index aa459f240..eb59108cb 100644 --- a/winpr/libwinpr/dsparse/CMakeLists.txt +++ b/winpr/libwinpr/dsparse/CMakeLists.txt @@ -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") diff --git a/winpr/libwinpr/environment/CMakeLists.txt b/winpr/libwinpr/environment/CMakeLists.txt index 80c150445..207632a69 100644 --- a/winpr/libwinpr/environment/CMakeLists.txt +++ b/winpr/libwinpr/environment/CMakeLists.txt @@ -35,3 +35,4 @@ else() install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/error/CMakeLists.txt b/winpr/libwinpr/error/CMakeLists.txt index 08740f0a0..65790882b 100644 --- a/winpr/libwinpr/error/CMakeLists.txt +++ b/winpr/libwinpr/error/CMakeLists.txt @@ -35,3 +35,4 @@ else() install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/file/CMakeLists.txt b/winpr/libwinpr/file/CMakeLists.txt index af233a751..82baa624a 100644 --- a/winpr/libwinpr/file/CMakeLists.txt +++ b/winpr/libwinpr/file/CMakeLists.txt @@ -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") diff --git a/winpr/libwinpr/file/file.c b/winpr/libwinpr/file/file.c index 04a519e01..9ae9c831b 100644 --- a/winpr/libwinpr/file/file.c +++ b/winpr/libwinpr/file/file.c @@ -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) { diff --git a/winpr/libwinpr/handle/CMakeLists.txt b/winpr/libwinpr/handle/CMakeLists.txt index 34f9fe703..69acd270f 100644 --- a/winpr/libwinpr/handle/CMakeLists.txt +++ b/winpr/libwinpr/handle/CMakeLists.txt @@ -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") diff --git a/winpr/libwinpr/heap/CMakeLists.txt b/winpr/libwinpr/heap/CMakeLists.txt index 25ff8f483..a1790a12e 100644 --- a/winpr/libwinpr/heap/CMakeLists.txt +++ b/winpr/libwinpr/heap/CMakeLists.txt @@ -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") diff --git a/winpr/libwinpr/heap/heap.c b/winpr/libwinpr/heap/heap.c index 5de8cba21..a53b2eff0 100644 --- a/winpr/libwinpr/heap/heap.c +++ b/winpr/libwinpr/heap/heap.c @@ -23,6 +23,8 @@ #include +#include + /* Memory Allocation: http://msdn.microsoft.com/en-us/library/hk1k7x6x.aspx */ /* Memory Management Functions: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366781/ */ diff --git a/winpr/libwinpr/interlocked/CMakeLists.txt b/winpr/libwinpr/interlocked/CMakeLists.txt index 5128cd122..7aea061f1 100644 --- a/winpr/libwinpr/interlocked/CMakeLists.txt +++ b/winpr/libwinpr/interlocked/CMakeLists.txt @@ -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() diff --git a/winpr/libwinpr/interlocked/interlocked.c b/winpr/libwinpr/interlocked/interlocked.c index fdbdea5ad..0be301529 100644 --- a/winpr/libwinpr/interlocked/interlocked.c +++ b/winpr/libwinpr/interlocked/interlocked.c @@ -42,34 +42,163 @@ #ifndef _WIN32 +#include +#include + 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 diff --git a/winpr/libwinpr/interlocked/test/.gitignore b/winpr/libwinpr/interlocked/test/.gitignore new file mode 100644 index 000000000..1d4702c9b --- /dev/null +++ b/winpr/libwinpr/interlocked/test/.gitignore @@ -0,0 +1,3 @@ +TestInterlocked +TestInterlocked.c + diff --git a/winpr/libwinpr/interlocked/test/CMakeLists.txt b/winpr/libwinpr/interlocked/test/CMakeLists.txt new file mode 100644 index 000000000..c04306ba1 --- /dev/null +++ b/winpr/libwinpr/interlocked/test/CMakeLists.txt @@ -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") diff --git a/winpr/libwinpr/interlocked/test/TestInterlockedAccess.c b/winpr/libwinpr/interlocked/test/TestInterlockedAccess.c new file mode 100644 index 000000000..38c557fa0 --- /dev/null +++ b/winpr/libwinpr/interlocked/test/TestInterlockedAccess.c @@ -0,0 +1,164 @@ + +#include +#include +#include +#include +#include + +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; +} diff --git a/winpr/libwinpr/interlocked/test/TestInterlockedSList.c b/winpr/libwinpr/interlocked/test/TestInterlockedSList.c new file mode 100644 index 000000000..b3eb357ec --- /dev/null +++ b/winpr/libwinpr/interlocked/test/TestInterlockedSList.c @@ -0,0 +1,85 @@ + +#include +#include +#include +#include +#include + +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; +} diff --git a/winpr/libwinpr/io/CMakeLists.txt b/winpr/libwinpr/io/CMakeLists.txt index 63e9a8428..d2632ae74 100644 --- a/winpr/libwinpr/io/CMakeLists.txt +++ b/winpr/libwinpr/io/CMakeLists.txt @@ -35,3 +35,4 @@ else() install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/library/CMakeLists.txt b/winpr/libwinpr/library/CMakeLists.txt index b47022219..e8004c957 100644 --- a/winpr/libwinpr/library/CMakeLists.txt +++ b/winpr/libwinpr/library/CMakeLists.txt @@ -15,19 +15,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_LIBRARY_SRCS +set(MODULE_NAME "winpr-library") +set(MODULE_PREFIX "WINPR_LIBRARY") + +set(${MODULE_PREFIX}_SRCS library.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-library OBJECT ${WINPR_LIBRARY_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-library ${WINPR_LIBRARY_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-library 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-library DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/library/library.c b/winpr/libwinpr/library/library.c index b5e38601f..8707dc80b 100644 --- a/winpr/libwinpr/library/library.c +++ b/winpr/libwinpr/library/library.c @@ -58,6 +58,12 @@ * SizeofResource */ +#ifndef _WIN32 + +#include +#include +#include + DLL_DIRECTORY_COOKIE AddDllDirectory(PCWSTR NewDirectory) { return NULL; @@ -73,12 +79,6 @@ BOOL SetDefaultDllDirectories(DWORD DirectoryFlags) return TRUE; } -#ifndef _WIN32 - -#include -#include -#include - HMODULE LoadLibraryA(LPCSTR lpLibFileName) { HMODULE library; diff --git a/winpr/libwinpr/path/CMakeLists.txt b/winpr/libwinpr/path/CMakeLists.txt index 559edc930..00080ee0a 100644 --- a/winpr/libwinpr/path/CMakeLists.txt +++ b/winpr/libwinpr/path/CMakeLists.txt @@ -32,6 +32,12 @@ set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SO if(WITH_MONOLITHIC_BUILD) else() + target_link_libraries(${MODULE_NAME} winpr-heap) install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") + +if(BUILD_TESTING) + add_subdirectory(test) +endif() diff --git a/winpr/libwinpr/path/path.c b/winpr/libwinpr/path/path.c index bc54e3494..ce0a80aaa 100644 --- a/winpr/libwinpr/path/path.c +++ b/winpr/libwinpr/path/path.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include + #include HRESULT PathCchAddBackslashA(PSTR pszPath, size_t cchPath) diff --git a/winpr/libwinpr/path/test/.gitignore b/winpr/libwinpr/path/test/.gitignore new file mode 100644 index 000000000..7c43324cd --- /dev/null +++ b/winpr/libwinpr/path/test/.gitignore @@ -0,0 +1,3 @@ +TestPath +TestPath.c + diff --git a/winpr/libwinpr/path/test/CMakeLists.txt b/winpr/libwinpr/path/test/CMakeLists.txt new file mode 100644 index 000000000..b8eb05fd0 --- /dev/null +++ b/winpr/libwinpr/path/test/CMakeLists.txt @@ -0,0 +1,48 @@ + +set(MODULE_NAME "TestPath") +set(MODULE_PREFIX "TEST_PATH") + +set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c) + +set(${MODULE_PREFIX}_TESTS + TestPathCchAddBackslash.c + TestPathCchRemoveBackslash.c + TestPathCchAddBackslashEx.c + TestPathCchRemoveBackslashEx.c + TestPathCchAddExtension.c + TestPathCchAppend.c + TestPathCchAppendEx.c + TestPathCchCanonicalize.c + TestPathCchCanonicalizeEx.c + TestPathAllocCanonicalize.c + TestPathCchCombine.c + TestPathCchCombineEx.c + TestPathAllocCombine.c + TestPathCchFindExtension.c + TestPathCchRenameExtension.c + TestPathCchRemoveExtension.c + TestPathCchIsRoot.c + TestPathIsUNCEx.c + TestPathCchSkipRoot.c + TestPathCchStripToRoot.c + TestPathCchStripPrefix.c + TestPathCchRemoveFileSpec.c) + +create_test_sourcelist(${MODULE_PREFIX}_SRCS + ${${MODULE_PREFIX}_DRIVER} + ${${MODULE_PREFIX}_TESTS}) + +add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) + +if(WIN32) + target_link_libraries(${MODULE_NAME} Pathcch) +else() + target_link_libraries(${MODULE_NAME} winpr-path) +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") diff --git a/winpr/libwinpr/path/test/TestPathAllocCanonicalize.c b/winpr/libwinpr/path/test/TestPathAllocCanonicalize.c new file mode 100644 index 000000000..81f601432 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathAllocCanonicalize.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathAllocCanonicalize(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathAllocCombine.c b/winpr/libwinpr/path/test/TestPathAllocCombine.c new file mode 100644 index 000000000..a2fd2b069 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathAllocCombine.c @@ -0,0 +1,94 @@ + +#include +#include +#include +#include +#include + +static const TCHAR testBasePathBackslash[] = _T("C:\\Program Files\\"); +static const TCHAR testBasePathNoBackslash[] = _T("C:\\Program Files"); +static const TCHAR testMorePathBackslash[] = _T("\\Microsoft Visual Studio 11.0"); +static const TCHAR testMorePathNoBackslash[] = _T("Microsoft Visual Studio 11.0"); +static const TCHAR testPathOut[] = _T("C:\\Program Files\\Microsoft Visual Studio 11.0"); +static const TCHAR testPathOutMorePathBackslash[] = _T("C:\\Microsoft Visual Studio 11.0"); + +int TestPathAllocCombine(int argc, char* argv[]) +{ + HRESULT status; + LPTSTR PathOut; + + /* Base Path: Backslash, More Path: No Backslash */ + + status = PathAllocCombine(testBasePathBackslash, testMorePathNoBackslash, 0, &PathOut); + + if (status != S_OK) + { + _tprintf(_T("PathAllocCombine status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(PathOut, testPathOut) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), PathOut, testPathOut); + return -1; + } + + HeapFree(GetProcessHeap(), 0, PathOut); + + /* Base Path: Backslash, More Path: Backslash */ + + status = PathAllocCombine(testBasePathBackslash, testMorePathBackslash, 0, &PathOut); + + if (status != S_OK) + { + _tprintf(_T("PathAllocCombine status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(PathOut, testPathOutMorePathBackslash) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), PathOut, testPathOutMorePathBackslash); + return -1; + } + + HeapFree(GetProcessHeap(), 0, PathOut); + + /* Base Path: No Backslash, More Path: Backslash */ + + status = PathAllocCombine(testBasePathNoBackslash, testMorePathBackslash, 0, &PathOut); + + if (status != S_OK) + { + _tprintf(_T("PathAllocCombine status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(PathOut, testPathOutMorePathBackslash) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), PathOut, testPathOutMorePathBackslash); + return -1; + } + + HeapFree(GetProcessHeap(), 0, PathOut); + + /* Base Path: No Backslash, More Path: No Backslash */ + + status = PathAllocCombine(testBasePathNoBackslash, testMorePathNoBackslash, 0, &PathOut); + + if (status != S_OK) + { + _tprintf(_T("PathAllocCombine status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(PathOut, testPathOut) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), PathOut, testPathOut); + return -1; + } + + HeapFree(GetProcessHeap(), 0, PathOut); + + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchAddBackslash.c b/winpr/libwinpr/path/test/TestPathCchAddBackslash.c new file mode 100644 index 000000000..a4e4a6df8 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchAddBackslash.c @@ -0,0 +1,54 @@ + +#include +#include +#include +#include +#include + +static const TCHAR testPathBackslash[] = _T("C:\\Program Files\\"); +static const TCHAR testPathNoBackslash[] = _T("C:\\Program Files"); + +int TestPathCchAddBackslash(int argc, char* argv[]) +{ + HRESULT status; + TCHAR Path[PATHCCH_MAX_CCH]; + + _tcscpy(Path, testPathNoBackslash); + + /* Add a backslash to a path without a trailing backslash, expect S_OK */ + + status = PathCchAddBackslash(Path, PATHCCH_MAX_CCH); + + if (status != S_OK) + { + _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), (int) status); + return -1; + } + + if (_tcscmp(Path, testPathBackslash) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathBackslash); + return -1; + } + + /* Add a backslash to a path with a trailing backslash, expect S_FALSE */ + + _tcscpy(Path, testPathBackslash); + + status = PathCchAddBackslash(Path, PATHCCH_MAX_CCH); + + if (status != S_FALSE) + { + _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), (int) status); + return -1; + } + + if (_tcscmp(Path, testPathBackslash) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathBackslash); + return -1; + } + + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchAddBackslashEx.c b/winpr/libwinpr/path/test/TestPathCchAddBackslashEx.c new file mode 100644 index 000000000..9fe39be84 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchAddBackslashEx.c @@ -0,0 +1,56 @@ + +#include +#include +#include +#include +#include + +static const TCHAR testPathBackslash[] = _T("C:\\Program Files\\"); +static const TCHAR testPathNoBackslash[] = _T("C:\\Program Files"); + +int TestPathCchAddBackslashEx(int argc, char* argv[]) +{ + HRESULT status; + LPTSTR pszEnd; + size_t cchRemaining; + TCHAR Path[PATHCCH_MAX_CCH]; + + _tcscpy(Path, testPathNoBackslash); + + /* Add a backslash to a path without a trailing backslash, expect S_OK */ + + status = PathCchAddBackslashEx(Path, sizeof(Path) / sizeof(TCHAR), &pszEnd, &cchRemaining); + + if (status != S_OK) + { + _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathBackslash) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathBackslash); + return -1; + } + + /* Add a backslash to a path with a trailing backslash, expect S_FALSE */ + + _tcscpy(Path, testPathBackslash); + + status = PathCchAddBackslashEx(Path, sizeof(Path) / sizeof(TCHAR), &pszEnd, &cchRemaining); + + if (status != S_FALSE) + { + _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathBackslash) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathBackslash); + return -1; + } + + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchAddExtension.c b/winpr/libwinpr/path/test/TestPathCchAddExtension.c new file mode 100644 index 000000000..ef766cffa --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchAddExtension.c @@ -0,0 +1,92 @@ + +#include +#include +#include +#include +#include + +static const TCHAR testExtDot[] = _T(".exe"); +static const TCHAR testExtNoDot[] = _T("exe"); +static const TCHAR testPathNoExtension[] = _T("C:\\Windows\\System32\\cmd"); +static const TCHAR testPathExtension[] = _T("C:\\Windows\\System32\\cmd.exe"); + +int TestPathCchAddExtension(int argc, char* argv[]) +{ + HRESULT status; + TCHAR Path[PATHCCH_MAX_CCH]; + + /* Path: no extension, Extension: dot */ + + _tcscpy(Path, testPathNoExtension); + + status = PathCchAddExtension(Path, PATHCCH_MAX_CCH, testExtDot); + + if (status != S_OK) + { + _tprintf(_T("PathCchAddExtension status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathExtension) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathExtension); + return -1; + } + + /* Path: no extension, Extension: no dot */ + + _tcscpy(Path, testPathNoExtension); + + status = PathCchAddExtension(Path, PATHCCH_MAX_CCH, testExtNoDot); + + if (status != S_OK) + { + _tprintf(_T("PathCchAddExtension status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathExtension) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathExtension); + return -1; + } + + /* Path: extension, Extension: dot */ + + _tcscpy(Path, testPathExtension); + + status = PathCchAddExtension(Path, PATHCCH_MAX_CCH, testExtDot); + + if (status != S_FALSE) + { + _tprintf(_T("PathCchAddExtension status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathExtension) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathExtension); + return -1; + } + + /* Path: extension, Extension: no dot */ + + _tcscpy(Path, testPathExtension); + + status = PathCchAddExtension(Path, PATHCCH_MAX_CCH, testExtDot); + + if (status != S_FALSE) + { + _tprintf(_T("PathCchAddExtension status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathExtension) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathExtension); + return -1; + } + + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchAppend.c b/winpr/libwinpr/path/test/TestPathCchAppend.c new file mode 100644 index 000000000..76053c38a --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchAppend.c @@ -0,0 +1,93 @@ + +#include +#include +#include +#include +#include + +static const TCHAR testBasePathBackslash[] = _T("C:\\Program Files\\"); +static const TCHAR testBasePathNoBackslash[] = _T("C:\\Program Files"); +static const TCHAR testMorePathBackslash[] = _T("\\Microsoft Visual Studio 11.0"); +static const TCHAR testMorePathNoBackslash[] = _T("Microsoft Visual Studio 11.0"); +static const TCHAR testPathOut[] = _T("C:\\Program Files\\Microsoft Visual Studio 11.0"); + +int TestPathCchAppend(int argc, char* argv[]) +{ + HRESULT status; + TCHAR Path[PATHCCH_MAX_CCH]; + + /* Base Path: Backslash, More Path: No Backslash */ + + _tcscpy(Path, testBasePathBackslash); + + status = PathCchAppend(Path, PATHCCH_MAX_CCH, testMorePathNoBackslash); + + if (status != S_OK) + { + _tprintf(_T("PathCchAppend status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathOut) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathOut); + return -1; + } + + /* Base Path: Backslash, More Path: Backslash */ + + _tcscpy(Path, testBasePathBackslash); + + status = PathCchAppend(Path, PATHCCH_MAX_CCH, testMorePathBackslash); + + if (status != S_OK) + { + _tprintf(_T("PathCchAppend status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathOut) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathOut); + return -1; + } + + /* Base Path: No Backslash, More Path: Backslash */ + + _tcscpy(Path, testBasePathNoBackslash); + + status = PathCchAppend(Path, PATHCCH_MAX_CCH, testMorePathBackslash); + + if (status != S_OK) + { + _tprintf(_T("PathCchAppend status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathOut) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathOut); + return -1; + } + + /* Base Path: No Backslash, More Path: No Backslash */ + + _tcscpy(Path, testBasePathNoBackslash); + + status = PathCchAppend(Path, PATHCCH_MAX_CCH, testMorePathNoBackslash); + + if (status != S_OK) + { + _tprintf(_T("PathCchAppend status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathOut) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathOut); + return -1; + } + + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchAppendEx.c b/winpr/libwinpr/path/test/TestPathCchAppendEx.c new file mode 100644 index 000000000..6f040fad1 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchAppendEx.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchAppendEx(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchCanonicalize.c b/winpr/libwinpr/path/test/TestPathCchCanonicalize.c new file mode 100644 index 000000000..7c5b868dd --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchCanonicalize.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchCanonicalize(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchCanonicalizeEx.c b/winpr/libwinpr/path/test/TestPathCchCanonicalizeEx.c new file mode 100644 index 000000000..13c4d373e --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchCanonicalizeEx.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchCanonicalizeEx(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchCombine.c b/winpr/libwinpr/path/test/TestPathCchCombine.c new file mode 100644 index 000000000..bfe1e86c6 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchCombine.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchCombine(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchCombineEx.c b/winpr/libwinpr/path/test/TestPathCchCombineEx.c new file mode 100644 index 000000000..5c3d0b8be --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchCombineEx.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchCombineEx(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchFindExtension.c b/winpr/libwinpr/path/test/TestPathCchFindExtension.c new file mode 100644 index 000000000..35ce6b576 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchFindExtension.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchFindExtension(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchIsRoot.c b/winpr/libwinpr/path/test/TestPathCchIsRoot.c new file mode 100644 index 000000000..a4e48daf9 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchIsRoot.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchIsRoot(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchRemoveBackslash.c b/winpr/libwinpr/path/test/TestPathCchRemoveBackslash.c new file mode 100644 index 000000000..a7c00ecfd --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchRemoveBackslash.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchRemoveBackslash(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchRemoveBackslashEx.c b/winpr/libwinpr/path/test/TestPathCchRemoveBackslashEx.c new file mode 100644 index 000000000..903341a46 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchRemoveBackslashEx.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchRemoveBackslashEx(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchRemoveExtension.c b/winpr/libwinpr/path/test/TestPathCchRemoveExtension.c new file mode 100644 index 000000000..f52ea8fc3 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchRemoveExtension.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchRemoveExtension(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchRemoveFileSpec.c b/winpr/libwinpr/path/test/TestPathCchRemoveFileSpec.c new file mode 100644 index 000000000..192894e0c --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchRemoveFileSpec.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchRemoveFileSpec(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchRenameExtension.c b/winpr/libwinpr/path/test/TestPathCchRenameExtension.c new file mode 100644 index 000000000..a1816cbcd --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchRenameExtension.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchRenameExtension(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchSkipRoot.c b/winpr/libwinpr/path/test/TestPathCchSkipRoot.c new file mode 100644 index 000000000..4e83ef541 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchSkipRoot.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchSkipRoot(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchStripPrefix.c b/winpr/libwinpr/path/test/TestPathCchStripPrefix.c new file mode 100644 index 000000000..7163c1346 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchStripPrefix.c @@ -0,0 +1,61 @@ + +#include +#include +#include +#include +#include + +/** + * Naming Files, Paths, and Namespaces: + * http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247/ + */ + +static const TCHAR testPathPrefixFileNamespace[] = _T("\\\\?\\C:\\Program Files\\"); +static const TCHAR testPathNoPrefixFileNamespace[] = _T("C:\\Program Files\\"); + +static const TCHAR testPathPrefixDeviceNamespace[] = _T("\\\\?\\GLOBALROOT"); + +int TestPathCchStripPrefix(int argc, char* argv[]) +{ + HRESULT status; + TCHAR Path[PATHCCH_MAX_CCH]; + + /* Path with prefix (File Namespace) */ + + _tcscpy(Path, testPathPrefixFileNamespace); + + status = PathCchStripPrefix(Path, sizeof(testPathPrefixFileNamespace) / sizeof(TCHAR)); + + if (status != S_OK) + { + _tprintf(_T("PathCchStripPrefix status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathNoPrefixFileNamespace) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathNoPrefixFileNamespace); + return -1; + } + + /* Path with prefix (Device Namespace) */ + + _tcscpy(Path, testPathPrefixDeviceNamespace); + + status = PathCchStripPrefix(Path, sizeof(testPathPrefixDeviceNamespace) / sizeof(TCHAR)); + + if (status != S_FALSE) + { + _tprintf(_T("PathCchStripPrefix status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathPrefixDeviceNamespace) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathPrefixDeviceNamespace); + return -1; + } + + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchStripToRoot.c b/winpr/libwinpr/path/test/TestPathCchStripToRoot.c new file mode 100644 index 000000000..cc6e13cd9 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchStripToRoot.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchStripToRoot(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathIsUNCEx.c b/winpr/libwinpr/path/test/TestPathIsUNCEx.c new file mode 100644 index 000000000..3cea93432 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathIsUNCEx.c @@ -0,0 +1,50 @@ + +#include +#include +#include +#include +#include + +static const TCHAR testServer[] = _T("server\\share\\path\\file"); +static const TCHAR testPathUNC[] = _T("\\\\server\\share\\path\\file"); +static const TCHAR testPathNotUNC[] = _T("C:\\share\\path\\file"); + +int TestPathIsUNCEx(int argc, char* argv[]) +{ + BOOL status; + LPTSTR Server; + TCHAR Path[PATHCCH_MAX_CCH]; + + /* Path is UNC */ + + _tcscpy(Path, testPathUNC); + + status = PathIsUNCEx(Path, &Server); + + if (!status) + { + _tprintf(_T("PathIsUNCEx status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Server, testServer) != 0) + { + _tprintf(_T("Server Name Mismatch: Actual: %s, Expected: %s\n"), Server, testServer); + return -1; + } + + /* Path is not UNC */ + + _tcscpy(Path, testPathNotUNC); + + status = PathIsUNCEx(Path, &Server); + + if (status) + { + _tprintf(_T("PathIsUNCEx status: 0x%08X\n"), status); + return -1; + } + + return 0; +} + diff --git a/winpr/libwinpr/registry/CMakeLists.txt b/winpr/libwinpr/registry/CMakeLists.txt index 53910a99c..b76c1014f 100644 --- a/winpr/libwinpr/registry/CMakeLists.txt +++ b/winpr/libwinpr/registry/CMakeLists.txt @@ -15,22 +15,27 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_REGISTRY_SRCS +set(MODULE_NAME "winpr-registry") +set(MODULE_PREFIX "WINPR_REGISTRY") + +set(${MODULE_PREFIX}_SRCS registry_reg.c registry_reg.h registry.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-registry OBJECT ${WINPR_REGISTRY_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-registry ${WINPR_REGISTRY_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-registry 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() - target_link_libraries(winpr-registry winpr-utils) - install(TARGETS winpr-registry DESTINATION ${CMAKE_INSTALL_LIBDIR}) + target_link_libraries(${MODULE_NAME} winpr-utils) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/rpc/CMakeLists.txt b/winpr/libwinpr/rpc/CMakeLists.txt index a825b3270..ec3c3bb39 100644 --- a/winpr/libwinpr/rpc/CMakeLists.txt +++ b/winpr/libwinpr/rpc/CMakeLists.txt @@ -15,43 +15,57 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_RPC_SRCS +set(MODULE_NAME "winpr-rpc") +set(MODULE_PREFIX "WINPR_RPC") + +set(${MODULE_PREFIX}_SRCS rpc.c ndr.c - ndr_array.c ndr_array.h - ndr_context.c ndr_context.h - ndr_correlation.c ndr_correlation.h - ndr_pointer.c ndr_pointer.h - ndr_private.c ndr_private.h - ndr_simple.c ndr_simple.h - ndr_string.c ndr_string.h - ndr_structure.c ndr_structure.h - ndr_union.c ndr_union.h + ndr_array.c + ndr_array.h + ndr_context.c + ndr_context.h + ndr_correlation.c + ndr_correlation.h + ndr_pointer.c + ndr_pointer.h + ndr_private.c + ndr_private.h + ndr_simple.c + ndr_simple.h + ndr_string.c + ndr_string.h + ndr_structure.c + ndr_structure.h + ndr_union.c + ndr_union.h midl.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-rpc OBJECT ${WINPR_RPC_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-rpc ${WINPR_RPC_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() include_directories(${OPENSSL_INCLUDE_DIR}) include_directories(${ZLIB_INCLUDE_DIRS}) -set_target_properties(winpr-rpc 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_RPC_LIBS +set(${MODULE_PREFIX}_LIBS ${OPENSSL_LIBRARIES}) if(WIN32) - set(WINPR_RPC_LIBS ${WINPR_RPC_LIBS} ws2_32) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ws2_32) else() - set(WINPR_RPC_LIBS ${WINPR_RPC_LIBS} ${ZLIB_LIBRARIES}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${ZLIB_LIBRARIES}) endif() if(WITH_MONOLITHIC_BUILD) - set(WINPR_LIBS ${WINPR_LIBS} ${WINPR_RPC_LIBS} PARENT_SCOPE) + set(WINPR_LIBS ${WINPR_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() - target_link_libraries(winpr-rpc ${WINPR_RPC_LIBS}) - install(TARGETS winpr-rpc 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") diff --git a/winpr/libwinpr/sspi/CMakeLists.txt b/winpr/libwinpr/sspi/CMakeLists.txt index 2af96c6cb..197aa4639 100644 --- a/winpr/libwinpr/sspi/CMakeLists.txt +++ b/winpr/libwinpr/sspi/CMakeLists.txt @@ -15,7 +15,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_SSPI_NTLM_SRCS +set(MODULE_NAME "winpr-sspi") +set(MODULE_PREFIX "WINPR_SSPI") + +set(${MODULE_PREFIX}_NTLM_SRCS NTLM/ntlm_av_pairs.c NTLM/ntlm_av_pairs.h NTLM/ntlm_compute.c @@ -25,68 +28,74 @@ set(WINPR_SSPI_NTLM_SRCS NTLM/ntlm.c NTLM/ntlm.h) -set(WINPR_SSPI_NEGOTIATE_SRCS +set(${MODULE_PREFIX}_NEGOTIATE_SRCS Negotiate/negotiate.c Negotiate/negotiate.h) -set(WINPR_SSPI_SCHANNEL_SRCS +set(${MODULE_PREFIX}_SCHANNEL_SRCS Schannel/schannel.c Schannel/schannel.h) -set(WINPR_SSPI_CREDSSP_SRCS +set(${MODULE_PREFIX}_CREDSSP_SRCS CredSSP/credssp.c) -set(WINPR_SSPI_SRCS - ${WINPR_SSPI_CREDSSP_SRCS} +set(${MODULE_PREFIX}_SRCS + ${${MODULE_PREFIX}_CREDSSP_SRCS} sspi.c sspi.h) if(NOT WITH_NATIVE_SSPI) - set(WINPR_SSPI_SRCS - ${WINPR_SSPI_NTLM_SRCS} - ${WINPR_SSPI_KERBEROS_SRCS} - ${WINPR_SSPI_NEGOTIATE_SRCS} - ${WINPR_SSPI_SCHANNEL_SRCS} - ${WINPR_SSPI_SRCS}) + set(${MODULE_PREFIX}_SRCS + ${${MODULE_PREFIX}_NTLM_SRCS} + ${${MODULE_PREFIX}_KERBEROS_SRCS} + ${${MODULE_PREFIX}_NEGOTIATE_SRCS} + ${${MODULE_PREFIX}_SCHANNEL_SRCS} + ${${MODULE_PREFIX}_SRCS}) endif() if(WITH_MONOLITHIC_BUILD) - add_library(winpr-sspi OBJECT ${WINPR_SSPI_SRCS}) + add_library(${MODULE_NAME} OBJECT ${WINPR_SSPI_SRCS}) else() - add_library(winpr-sspi ${WINPR_SSPI_SRCS}) + add_library(${MODULE_NAME} ${WINPR_SSPI_SRCS}) endif() include_directories(${ZLIB_INCLUDE_DIRS}) include_directories(${OPENSSL_INCLUDE_DIR}) -set_target_properties(winpr-sspi 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_SSPI_LIBS +set(${MODULE_PREFIX}_LIBS ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES}) if(WIN32) - set(WINPR_SSPI_LIBS ${WINPR_SSPI_LIBS} ws2_32) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ws2_32) else() - set(WINPR_SSPI_LIBS ${WINPR_SSPI_LIBS} ${ZLIB_LIBRARIES}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${ZLIB_LIBRARIES}) endif() if(WITH_MONOLITHIC_BUILD) - set(WINPR_SSPI_LIBS ${WINPR_SSPI_LIBS} winpr) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) else() if (NOT WIN32) - set(WINPR_SSPI_LIBS ${WINPR_SSPI_LIBS} + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-crt winpr-sysinfo winpr-registry) endif() - set(WINPR_SSPI_LIBS ${WINPR_SSPI_LIBS} winpr-utils) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-utils) endif() if(WITH_MONOLITHIC_BUILD) - set(WINPR_LIBS ${WINPR_LIBS} ${WINPR_SSPI_LIBS} PARENT_SCOPE) + set(WINPR_LIBS ${WINPR_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() - target_link_libraries(winpr-sspi ${WINPR_SSPI_LIBS}) - install(TARGETS winpr-sspi 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") + +if(BUILD_TESTING) + add_subdirectory(test) endif() diff --git a/winpr/libwinpr/sspi/test/.gitignore b/winpr/libwinpr/sspi/test/.gitignore new file mode 100644 index 000000000..ad5671c60 --- /dev/null +++ b/winpr/libwinpr/sspi/test/.gitignore @@ -0,0 +1,3 @@ +TestSspi +TestSspi.c + diff --git a/winpr/libwinpr/sspi/test/CMakeLists.txt b/winpr/libwinpr/sspi/test/CMakeLists.txt new file mode 100644 index 000000000..0c774a0e5 --- /dev/null +++ b/winpr/libwinpr/sspi/test/CMakeLists.txt @@ -0,0 +1,30 @@ + +set(MODULE_NAME "TestSspi") +set(MODULE_PREFIX "TEST_SSPI") + +set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c) + +set(${MODULE_PREFIX}_TESTS + TestQuerySecurityPackageInfo.c + TestEnumerateSecurityPackages.c + TestInitializeSecurityContext.c + TestAcquireCredentialsHandle.c) + +create_test_sourcelist(${MODULE_PREFIX}_SRCS + ${${MODULE_PREFIX}_DRIVER} + ${${MODULE_PREFIX}_TESTS}) + +add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) + +if(WIN32) + target_link_libraries(${MODULE_NAME} secur32) +endif() + +target_link_libraries(${MODULE_NAME} winpr-sspi) + +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") diff --git a/winpr/libwinpr/sspi/test/TestAcquireCredentialsHandle.c b/winpr/libwinpr/sspi/test/TestAcquireCredentialsHandle.c new file mode 100644 index 000000000..e9d60ea3f --- /dev/null +++ b/winpr/libwinpr/sspi/test/TestAcquireCredentialsHandle.c @@ -0,0 +1,53 @@ + +#include +#include +#include +#include + +static const char* test_User = "User"; +static const char* test_Domain = "Domain"; +static const char* test_Password = "Password"; + +int TestAcquireCredentialsHandle(int argc, char* argv[]) +{ + SECURITY_STATUS status; + CredHandle credentials; + TimeStamp expiration; + SEC_WINNT_AUTH_IDENTITY identity; + SecurityFunctionTable* table; + SecPkgCredentials_Names credential_names; + + sspi_GlobalInit(); + + table = InitSecurityInterface(); + + identity.User = (UINT16*) _strdup(test_User); + identity.UserLength = sizeof(test_User); + identity.Domain = (UINT16*) _strdup(test_Domain); + identity.DomainLength = sizeof(test_Domain); + identity.Password = (UINT16*) _strdup(test_Password); + identity.PasswordLength = sizeof(test_Password); + identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI; + + status = table->AcquireCredentialsHandle(NULL, NTLMSP_NAME, + SECPKG_CRED_OUTBOUND, NULL, &identity, NULL, NULL, &credentials, &expiration); + + if (status != SEC_E_OK) + { + sspi_GlobalFinish(); + return -1; + } + + status = table->QueryCredentialsAttributes(&credentials, SECPKG_CRED_ATTR_NAMES, &credential_names); + + if (status != SEC_E_OK) + { + sspi_GlobalFinish(); + return -1; + } + + sspi_GlobalFinish(); + + return 0; +} + diff --git a/winpr/libwinpr/sspi/test/TestEnumerateSecurityPackages.c b/winpr/libwinpr/sspi/test/TestEnumerateSecurityPackages.c new file mode 100644 index 000000000..cab3884c6 --- /dev/null +++ b/winpr/libwinpr/sspi/test/TestEnumerateSecurityPackages.c @@ -0,0 +1,36 @@ + +#include +#include +#include +#include + +int TestEnumerateSecurityPackages(int argc, char* argv[]) +{ + int index; + ULONG cPackages; + SECURITY_STATUS status; + SecPkgInfo* pPackageInfo; + + sspi_GlobalInit(); + + status = EnumerateSecurityPackages(&cPackages, &pPackageInfo); + + if (status != SEC_E_OK) + { + sspi_GlobalFinish(); + return -1; + } + + 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); + sspi_GlobalFinish(); + + return 0; +} + diff --git a/winpr/libwinpr/sspi/test/TestInitializeSecurityContext.c b/winpr/libwinpr/sspi/test/TestInitializeSecurityContext.c new file mode 100644 index 000000000..d434234bf --- /dev/null +++ b/winpr/libwinpr/sspi/test/TestInitializeSecurityContext.c @@ -0,0 +1,96 @@ + +#include +#include +#include +#include + +static const char* test_User = "User"; +static const char* test_Domain = "Domain"; +static const char* test_Password = "Password"; + +int TestInitializeSecurityContext(int argc, char* argv[]) +{ + UINT32 cbMaxLen; + UINT32 fContextReq; + void* output_buffer; + CtxtHandle context; + ULONG pfContextAttr; + SECURITY_STATUS status; + CredHandle credentials; + TimeStamp expiration; + PSecPkgInfo pPackageInfo; + SEC_WINNT_AUTH_IDENTITY identity; + SecurityFunctionTable* table; + PSecBuffer p_SecBuffer; + SecBuffer output_SecBuffer; + SecBufferDesc output_SecBuffer_desc; + + sspi_GlobalInit(); + + table = InitSecurityInterface(); + + status = QuerySecurityPackageInfo(NTLMSP_NAME, &pPackageInfo); + + if (status != SEC_E_OK) + { + printf("QuerySecurityPackageInfo status: 0x%08X\n", status); + return -1; + } + + cbMaxLen = pPackageInfo->cbMaxToken; + + identity.User = (UINT16*) _strdup(test_User); + identity.UserLength = sizeof(test_User); + identity.Domain = (UINT16*) _strdup(test_Domain); + identity.DomainLength = sizeof(test_Domain); + identity.Password = (UINT16*) _strdup(test_Password); + identity.PasswordLength = sizeof(test_Password); + identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI; + + status = table->AcquireCredentialsHandle(NULL, NTLMSP_NAME, + SECPKG_CRED_OUTBOUND, NULL, &identity, NULL, NULL, &credentials, &expiration); + + if (status != SEC_E_OK) + { + printf("AcquireCredentialsHandle status: 0x%08X\n", status); + sspi_GlobalFinish(); + return -1; + } + + fContextReq = ISC_REQ_REPLAY_DETECT | ISC_REQ_SEQUENCE_DETECT | ISC_REQ_CONFIDENTIALITY | ISC_REQ_DELEGATE; + + output_buffer = malloc(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); + sspi_GlobalFinish(); + return -1; + } + + 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); + + table->FreeCredentialsHandle(&credentials); + + FreeContextBuffer(pPackageInfo); + + sspi_GlobalFinish(); + + return 0; +} + diff --git a/winpr/libwinpr/sspi/test/TestQuerySecurityPackageInfo.c b/winpr/libwinpr/sspi/test/TestQuerySecurityPackageInfo.c new file mode 100644 index 000000000..5f970fd86 --- /dev/null +++ b/winpr/libwinpr/sspi/test/TestQuerySecurityPackageInfo.c @@ -0,0 +1,28 @@ + +#include +#include +#include + +int TestQuerySecurityPackageInfo(int argc, char* argv[]) +{ + SECURITY_STATUS status; + SecPkgInfo* pPackageInfo; + + sspi_GlobalInit(); + + status = QuerySecurityPackageInfo(NTLMSP_NAME, &pPackageInfo); + + if (status != SEC_E_OK) + { + sspi_GlobalFinish(); + return -1; + } + + printf("\nQuerySecurityPackageInfo:\n"); + printf("\"%s\", \"%s\"\n", pPackageInfo->Name, pPackageInfo->Comment); + + sspi_GlobalFinish(); + + return 0; +} + diff --git a/winpr/libwinpr/sspicli/CMakeLists.txt b/winpr/libwinpr/sspicli/CMakeLists.txt index 106d01158..9374da3fb 100644 --- a/winpr/libwinpr/sspicli/CMakeLists.txt +++ b/winpr/libwinpr/sspicli/CMakeLists.txt @@ -15,19 +15,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_SSPICLI_SRCS +set(MODULE_NAME "winpr-sspicli") +set(MODULE_PREFIX "WINPR_SSPICLI") + +set(${MODULE_PREFIX}_SRCS sspicli.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-sspicli OBJECT ${WINPR_SSPICLI_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-sspicli ${WINPR_SSPICLI_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-sspicli 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-sspicli DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/synch/CMakeLists.txt b/winpr/libwinpr/synch/CMakeLists.txt index e74a67911..5db40b18e 100644 --- a/winpr/libwinpr/synch/CMakeLists.txt +++ b/winpr/libwinpr/synch/CMakeLists.txt @@ -15,10 +15,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +set(MODULE_NAME "winpr-synch") +set(MODULE_PREFIX "WINPR_SYNCH") + set(CMAKE_THREAD_PREFER_PTHREAD) find_required_package(Threads) -set(WINPR_SYNCH_SRCS +set(${MODULE_PREFIX}_SRCS address.c barrier.c condition.c @@ -35,14 +38,14 @@ set(WINPR_SYNCH_SRCS wait.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-synch OBJECT ${WINPR_SYNCH_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-synch ${WINPR_SYNCH_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-synch 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_SYNCH_LIBS +set(${MODULE_PREFIX}_LIBS ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) @@ -51,13 +54,14 @@ if(${CMAKE_SYSTEM_NAME} MATCHES SunOS) endif() if(WITH_MONOLITHIC_BUILD) - set(WINPR_LIBS ${WINPR_LIBS} ${WINPR_SYNCH_LIBS} PARENT_SCOPE) + set(WINPR_LIBS ${WINPR_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() if(NOT WIN32) - set(WINPR_SYNCH_LIBS ${WINPR_SYNCH_LIBS} winpr-handle) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-handle) endif() - target_link_libraries(winpr-synch ${WINPR_SYNCH_LIBS}) - install(TARGETS winpr-synch 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") diff --git a/winpr/libwinpr/sysinfo/CMakeLists.txt b/winpr/libwinpr/sysinfo/CMakeLists.txt index e5e41d8cd..f05d6c553 100644 --- a/winpr/libwinpr/sysinfo/CMakeLists.txt +++ b/winpr/libwinpr/sysinfo/CMakeLists.txt @@ -15,19 +15,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_SYSINFO_SRCS +set(MODULE_NAME "winpr-sysinfo") +set(MODULE_PREFIX "WINPR_SYSINFO") + +set(${MODULE_PREFIX}_SRCS sysinfo.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-sysinfo OBJECT ${WINPR_SYSINFO_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-sysinfo ${WINPR_SYSINFO_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-sysinfo 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-sysinfo DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/thread/CMakeLists.txt b/winpr/libwinpr/thread/CMakeLists.txt index 343c3b16c..d53f523ea 100644 --- a/winpr/libwinpr/thread/CMakeLists.txt +++ b/winpr/libwinpr/thread/CMakeLists.txt @@ -15,39 +15,43 @@ # See the License for the specific language governing permissions and # limitations under the License. +set(MODULE_NAME "winpr-thread") +set(MODULE_PREFIX "WINPR_THREAD") + set(CMAKE_THREAD_PREFER_PTHREAD) find_required_package(Threads) -set(WINPR_THREAD_SRCS +set(${MODULE_PREFIX}_SRCS process.c processor.c thread.c tls.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-thread OBJECT ${WINPR_THREAD_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-thread ${WINPR_THREAD_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-thread 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_SYNCH_LIBS +set(${MODULE_PREFIX}_LIBS ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) if(${CMAKE_SYSTEM_NAME} MATCHES SunOS) - set(WINPR_SYNCH_LIBS ${WINPR_SYNCH_LIBS} rt) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} rt) endif() if(WITH_MONOLITHIC_BUILD) - set(WINPR_LIBS ${WINPR_LIBS} ${WINPR_SYNCH_LIBS} PARENT_SCOPE) + set(WINPR_LIBS ${WINPR_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() if(NOT WIN32) - set(WINPR_SYNCH_LIBS ${WINPR_SYNCH_LIBS} winpr-handle) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-handle) endif() - target_link_libraries(winpr-thread ${WINPR_SYNCH_LIBS}) - install(TARGETS winpr-thread 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") diff --git a/winpr/libwinpr/timezone/CMakeLists.txt b/winpr/libwinpr/timezone/CMakeLists.txt index e780f26aa..afbbd50d7 100644 --- a/winpr/libwinpr/timezone/CMakeLists.txt +++ b/winpr/libwinpr/timezone/CMakeLists.txt @@ -15,19 +15,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_TIMEZONE_SRCS +set(MODULE_NAME "winpr-timezone") +set(MODULE_PREFIX "WINPR_TIMEZONE") + +set(${MODULE_PREFIX}_SRCS timezone.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-timezone OBJECT ${WINPR_TIMEZONE_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-timezone ${WINPR_TIMEZONE_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-timezone 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-timezone DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/utils/CMakeLists.txt b/winpr/libwinpr/utils/CMakeLists.txt index 9edc35dc3..eb327c5e5 100644 --- a/winpr/libwinpr/utils/CMakeLists.txt +++ b/winpr/libwinpr/utils/CMakeLists.txt @@ -15,7 +15,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_UTILS_SRCS +set(MODULE_NAME "winpr-utils") +set(MODULE_PREFIX "WINPR_UTILS") + +set(${MODULE_PREFIX}_SRCS ntlm.c print.c sam.c @@ -25,24 +28,26 @@ include_directories(${ZLIB_INCLUDE_DIRS}) include_directories(${OPENSSL_INCLUDE_DIR}) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-utils OBJECT ${WINPR_UTILS_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-utils ${WINPR_UTILS_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-utils 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_UTILS_LIBS +set(${MODULE_PREFIX}_LIBS ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES}) if(WITH_MONOLITHIC_BUILD) - set(WINPR_LIBS ${WINPR_LIBS} ${WINPR_UTILS_LIBS} PARENT_SCOPE) + set(WINPR_LIBS ${WINPR_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() if (NOT WIN32) - set(WINPR_UTILS_LIBS ${WINPR_UTILS_LIBS} winpr-crt) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-crt) endif() - target_link_libraries(winpr-utils ${WINPR_UTILS_LIBS}) - install(TARGETS winpr-utils 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") diff --git a/winpr/libwinpr/winhttp/CMakeLists.txt b/winpr/libwinpr/winhttp/CMakeLists.txt index 1fa4dd60c..ccdf271f5 100644 --- a/winpr/libwinpr/winhttp/CMakeLists.txt +++ b/winpr/libwinpr/winhttp/CMakeLists.txt @@ -15,19 +15,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_WINHTTP_SRCS +set(MODULE_NAME "winpr-winhttp") +set(MODULE_PREFIX "WINPR_WINHTTP") + +set(${MODULE_PREFIX}_SRCS winhttp.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-winhttp OBJECT ${WINPR_WINHTTP_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-winhttp ${WINPR_WINHTTP_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-winhttp 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-winhttp DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/winsock/CMakeLists.txt b/winpr/libwinpr/winsock/CMakeLists.txt index a120c77b7..abdab2387 100644 --- a/winpr/libwinpr/winsock/CMakeLists.txt +++ b/winpr/libwinpr/winsock/CMakeLists.txt @@ -15,24 +15,29 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_WINSOCK_SRCS +set(MODULE_NAME "winpr-winsock") +set(MODULE_PREFIX "WINPR_WINSOCK") + +set(${MODULE_PREFIX}_SRCS winsock.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-winsock OBJECT ${WINPR_WINSOCK_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-winsock ${WINPR_WINSOCK_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-winsock 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(WIN32) - set(WINPR_WINSOCK_LIBS ${WINPR_WINSOCK_LIBS} ws2_32) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ws2_32) endif() if(WITH_MONOLITHIC_BUILD) - set(WINPR_LIBS ${WINPR_LIBS} ${WINPR_WINSOCK_LIBS} PARENT_SCOPE) + set(WINPR_LIBS ${WINPR_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() - target_link_libraries(winpr-winsock ${WINPR_WINSOCK_LIBS}) - install(TARGETS winpr-winsock 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") diff --git a/winpr/tools/CMakeLists.txt b/winpr/tools/CMakeLists.txt index d04fbc019..86376a2df 100644 --- a/winpr/tools/CMakeLists.txt +++ b/winpr/tools/CMakeLists.txt @@ -1,9 +1,7 @@ # WinPR: Windows Portable Runtime # winpr cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,6 +15,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_subdirectory(reg) add_subdirectory(hash) diff --git a/winpr/tools/hash/CMakeLists.txt b/winpr/tools/hash/CMakeLists.txt index 0aff945d3..1e671ab0e 100644 --- a/winpr/tools/hash/CMakeLists.txt +++ b/winpr/tools/hash/CMakeLists.txt @@ -15,12 +15,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_executable(winpr-hash +set(MODULE_NAME "winpr-hash") +set(MODULE_PREFIX "WINPR_TOOLS_HASH") + +set(${MODULE_PREFIX}_SRCS hash.c) +add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) + if(WITH_MONOLITHIC_BUILD) - target_link_libraries(winpr-hash winpr) + target_link_libraries(${MODULE_NAME} winpr) else() - target_link_libraries(winpr-hash winpr-utils) + target_link_libraries(${MODULE_NAME} winpr-utils) endif() +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Tools") diff --git a/winpr/tools/reg/CMakeLists.txt b/winpr/tools/reg/CMakeLists.txt deleted file mode 100644 index 1392862bc..000000000 --- a/winpr/tools/reg/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# WinPR: Windows Portable Runtime -# winpr-reg cmake build script -# -# Copyright 2012 Marc-Andre Moreau -# -# 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. - -add_executable(winpr-reg - reg.c) - -if(WITH_MONOLITHIC_BUILD) - target_link_libraries(winpr-reg winpr) -else() - target_link_libraries(winpr-reg winpr-utils) - - if(NOT WIN32) - target_link_libraries(winpr-reg winpr-registry) - endif() -endif() diff --git a/winpr/tools/reg/reg.c b/winpr/tools/reg/reg.c deleted file mode 100644 index 5333a7a9f..000000000 --- a/winpr/tools/reg/reg.c +++ /dev/null @@ -1,86 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Registry API Tool - * - * Copyright 2012 Marc-Andre Moreau - * - * 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 -#include -#include - -#include -#include - -#include -#include - -int main(int argc, char* argv[]) -{ - HKEY hKey; - LONG status; - DWORD dwType; - DWORD dwSize; - DWORD dwValue; - DWORD RemoteFX; - char* ComputerName; - - status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\FreeRDP"), 0, KEY_READ, &hKey); - - if (status != ERROR_SUCCESS) - { - _tprintf(_T("RegOpenKeyEx error: 0x%08lX\n"), status); - return 0; - } - - dwValue = 0; - status = RegQueryValueEx(hKey, _T("RemoteFX"), NULL, &dwType, (BYTE*) &dwValue, &dwSize); - - if (status != ERROR_SUCCESS) - { - _tprintf(_T("RegQueryValueEx error: 0x%08lX\n"), status); - return 0; - } - - RemoteFX = dwValue; - - status = RegQueryValueEx(hKey, _T("ComputerName"), NULL, &dwType, NULL, &dwSize); - - if (status != ERROR_SUCCESS) - { - _tprintf(_T("RegQueryValueEx error: 0x%08lX\n"), status); - return 0; - } - - ComputerName = (char*) malloc(dwSize + 1); - - status = RegQueryValueEx(hKey, _T("ComputerName"), NULL, &dwType, (BYTE*) ComputerName, &dwSize); - - if (status != ERROR_SUCCESS) - { - _tprintf(_T("RegQueryValueEx error: 0x%08lX\n"), status); - return 0; - } - - printf("RemoteFX: %08lX\n", RemoteFX); - printf("ComputerName: %s\n", ComputerName); - - RegCloseKey(hKey); - - free(ComputerName); - - return 0; -} -