Merge remote-tracking branch 'upstream/master' into rail

This commit is contained in:
roman-b 2011-09-02 01:24:45 +03:00
commit 9b7eb7934f
39 changed files with 964 additions and 275 deletions

View File

@ -63,12 +63,12 @@ if(CMAKE_COMPILER_IS_GNUCC)
endif()
if(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gz")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gd /MT")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /O2 /Ob2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_X86_")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFREERDP_EXPORTS")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWIN32_LEAN_AND_MEAN")
endif()
# Include files
@ -79,13 +79,13 @@ check_include_files(fcntl.h HAVE_FCNTL_H)
check_include_files(unistd.h HAVE_UNISTD_H)
# Libraries that we have a hard dependency on
find_package(OpenSSL REQUIRED)
find_required_package(OpenSSL)
if(NOT WIN32)
find_package(ZLIB REQUIRED)
find_optional_package(ALSA)
find_required_package(ZLIB)
find_suggested_package(ALSA)
find_optional_package(PulseAudio)
find_optional_package(Cups)
find_suggested_package(Cups)
endif()
# Endian
@ -111,7 +111,7 @@ if(APPLE)
endif()
# Build CUnit
find_package(CUnit)
find_optional_package(CUnit)
if(CUNIT_FOUND)
add_subdirectory(cunit)
enable_testing()

View File

@ -341,7 +341,7 @@ void rail_recv_handshake_order(rdpRailOrder* rail_order, STREAM* s)
rail_order->sysparam.keyboardPref = False;
rail_order->sysparam.params |= SPI_MASK_SET_DRAG_FULL_WINDOWS;
rail_order->sysparam.dragFullWindows = True;
rail_order->sysparam.dragFullWindows = False;
rail_order->sysparam.params |= SPI_MASK_SET_KEYBOARD_CUES;
rail_order->sysparam.keyboardCues = False;

View File

@ -20,19 +20,21 @@
# User Interfaces
if(NOT WIN32)
# Build Test Client
add_subdirectory(test)
# Build X11 Client
find_package(X11)
find_suggested_package(X11)
if(X11_FOUND)
add_subdirectory(X11)
endif()
# Build DirectFB Client
find_package(DirectFB)
find_optional_package(DirectFB)
if(DIRECTFB_FOUND)
add_subdirectory(DirectFB)
endif()
else()
# Build Windows Client
add_subdirectory(Windows)
endif()

View File

@ -0,0 +1,27 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP Windows cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
#
# 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(wfreerdp
wfreerdp.c
wfreerdp.h)
target_link_libraries(wfreerdp freerdp-core)
target_link_libraries(wfreerdp freerdp-gdi)
target_link_libraries(wfreerdp freerdp-utils)
target_link_libraries(wfreerdp freerdp-chanman)

375
client/Windows/wfreerdp.c Normal file
View File

@ -0,0 +1,375 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Windows Client
*
* Copyright 2009-2011 Jay Sorg
* Copyright 2010-2011 Vic Lee
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <freerdp/freerdp.h>
#include <freerdp/utils/args.h>
#include <freerdp/utils/event.h>
#include <freerdp/chanman/chanman.h>
#include "wfreerdp.h"
struct _thread_data
{
freerdp* instance;
};
typedef struct _thread_data thread_data;
HANDLE g_done_event;
HINSTANCE g_hInstance;
HCURSOR g_default_cursor;
volatile int g_thread_count = 0;
LPCTSTR g_wnd_class_name = L"wfreerdp";
int wf_create_console(void)
{
if (!AllocConsole())
return 1;
freopen("CONOUT$", "w", stdout);
printf("Debug console created.\n");
return 0;
}
boolean wf_pre_connect(freerdp* instance)
{
wfInfo* wfi;
rdpSettings* settings;
wfi = (wfInfo*) xzalloc(sizeof(wfInfo));
SET_WFI(instance, wfi);
settings = instance->settings;
settings->order_support[NEG_DSTBLT_INDEX] = True;
settings->order_support[NEG_PATBLT_INDEX] = True;
settings->order_support[NEG_SCRBLT_INDEX] = True;
settings->order_support[NEG_OPAQUE_RECT_INDEX] = True;
settings->order_support[NEG_DRAWNINEGRID_INDEX] = False;
settings->order_support[NEG_MULTIDSTBLT_INDEX] = False;
settings->order_support[NEG_MULTIPATBLT_INDEX] = False;
settings->order_support[NEG_MULTISCRBLT_INDEX] = False;
settings->order_support[NEG_MULTIOPAQUERECT_INDEX] = True;
settings->order_support[NEG_MULTI_DRAWNINEGRID_INDEX] = False;
settings->order_support[NEG_LINETO_INDEX] = True;
settings->order_support[NEG_POLYLINE_INDEX] = True;
settings->order_support[NEG_MEMBLT_INDEX] = True;
settings->order_support[NEG_MEM3BLT_INDEX] = False;
settings->order_support[NEG_SAVEBITMAP_INDEX] = True;
settings->order_support[NEG_GLYPH_INDEX_INDEX] = True;
settings->order_support[NEG_FAST_INDEX_INDEX] = True;
settings->order_support[NEG_FAST_GLYPH_INDEX] = True;
settings->order_support[NEG_POLYGON_SC_INDEX] = False;
settings->order_support[NEG_POLYGON_CB_INDEX] = False;
settings->order_support[NEG_ELLIPSE_SC_INDEX] = False;
settings->order_support[NEG_ELLIPSE_CB_INDEX] = False;
settings->kbd_layout = (int) GetKeyboardLayout(0) & 0x0000FFFF;
printf("keyboard_layout: 0x%X\n", settings->kbd_layout);
freerdp_chanman_pre_connect(GET_CHANMAN(instance), instance);
return True;
}
boolean wf_post_connect(freerdp* instance)
{
GDI* gdi;
wfInfo* wfi;
wfi = GET_WFI(instance);
SET_WFI(instance->update, wfi);
gdi_init(instance, CLRCONV_ALPHA | CLRBUF_32BPP);
gdi = GET_GDI(instance->update);
freerdp_chanman_post_connect(GET_CHANMAN(instance), instance);
return True;
}
int wf_receive_channel_data(freerdp* instance, int channelId, uint8* data, int size, int flags, int total_size)
{
return freerdp_chanman_data(instance, channelId, data, size, flags, total_size);
}
void wf_process_channel_event(rdpChanMan* chanman, freerdp* instance)
{
wfInfo* wfi;
RDP_EVENT* event;
wfi = GET_WFI(instance);
event = freerdp_chanman_pop_event(chanman);
if (event)
freerdp_event_free(event);
}
boolean wf_get_fds(freerdp* instance, void** rfds, int* rcount, void** wfds, int* wcount)
{
wfInfo* wfi = GET_WFI(instance);
return True;
}
boolean wf_check_fds(freerdp* instance)
{
wfInfo* wfi = GET_WFI(instance);
return True;
}
int wfreerdp_run(freerdp* instance)
{
MSG msg;
int index;
int gmcode;
int alldone;
int rcount;
int wcount;
void* rfds[32];
void* wfds[32];
int fds_count;
HANDLE fds[64];
rdpChanMan* chanman;
chanman = GET_CHANMAN(instance);
/* program main loop */
while (1)
{
rcount = 0;
wcount = 0;
if (instance->GetFileDescriptor(instance, rfds, &rcount, wfds, &wcount) != True)
{
printf("Failed to get FreeRDP file descriptor\n");
break;
}
if (freerdp_chanman_get_fds(chanman, instance, rfds, &rcount, wfds, &wcount) != True)
{
printf("Failed to get channel manager file descriptor\n");
break;
}
if (wf_get_fds(instance, rfds, &rcount, wfds, &wcount) != True)
{
printf("Failed to get wfreerdp file descriptor\n");
break;
}
fds_count = 0;
/* setup read fds */
for (index = 0; index < rcount; index++)
{
fds[fds_count++] = rfds[index];
}
/* setup write fds */
for (index = 0; index < wcount; index++)
{
fds[fds_count++] = wfds[index];
}
/* exit if nothing to do */
if (fds_count == 0)
{
printf("wfreerdp_run: fds_count is zero\n");
break;
}
/* do the wait */
if (MsgWaitForMultipleObjects(fds_count, fds, FALSE, INFINITE, QS_ALLINPUT) == WAIT_FAILED)
{
printf("wfreerdp_run: WaitForMultipleObjects failed\n");
break;
}
if (instance->CheckFileDescriptor(instance) != True)
{
printf("Failed to check FreeRDP file descriptor\n");
break;
}
if (wf_check_fds(instance) != True)
{
printf("Failed to check wfreerdp file descriptor\n");
break;
}
if (freerdp_chanman_check_fds(chanman, instance) != True)
{
printf("Failed to check channel manager file descriptor\n");
break;
}
wf_process_channel_event(chanman, instance);
alldone = FALSE;
while (PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE))
{
gmcode = GetMessage(&msg, 0, 0, 0);
if (gmcode == 0 || gmcode == -1)
{
alldone = TRUE;
break;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if (alldone)
{
break;
}
}
/* cleanup */
freerdp_chanman_free(chanman);
freerdp_free(instance);
return 0;
}
static DWORD WINAPI thread_func(LPVOID lpParam)
{
wfInfo* wfi;
freerdp* instance;
thread_data* data;
data = (thread_data*) lpParam;
instance = data->instance;
wfi = (wfInfo*) xzalloc(sizeof(wfInfo));
wfi->clrconv = (HCLRCONV) xzalloc(sizeof(CLRCONV));
wfi->clrconv->alpha = 1;
wfi->clrconv->palette = NULL;
SET_WFI(instance, wfi);
wfreerdp_run(instance);
g_thread_count--;
if (g_thread_count < 1)
SetEvent(g_done_event);
return (DWORD) NULL;
}
static DWORD WINAPI kbd_thread_func(LPVOID lpParam)
{
#if 0
MSG msg;
BOOL bRet;
HHOOK hook_handle;
hook_handle = SetWindowsHookEx(WH_KEYBOARD_LL, wf_ll_kbd_proc, g_hInstance, 0);
if (hook_handle)
{
while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
{
if (bRet == -1)
{
printf("keyboard thread error getting message\n");
break;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
UnhookWindowsHookEx(hook_handle);
}
else
printf("failed to install keyboard hook\n");
#endif
return (DWORD) NULL;
}
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
freerdp* instance;
thread_data* data;
WSADATA wsa_data;
WNDCLASSEX wnd_cls;
rdpChanMan* chanman;
if (WSAStartup(0x101, &wsa_data) != 0)
return 1;
g_done_event = CreateEvent(0, 1, 0, 0);
#if defined(WITH_DEBUG) || defined(_DEBUG)
wf_create_console();
#endif
g_default_cursor = LoadCursor(NULL, IDC_ARROW);
wnd_cls.cbSize = sizeof(WNDCLASSEX);
wnd_cls.style = CS_HREDRAW | CS_VREDRAW;
//wnd_cls.lpfnWndProc = wf_event_proc;
wnd_cls.cbClsExtra = 0;
wnd_cls.cbWndExtra = 0;
wnd_cls.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wnd_cls.hCursor = g_default_cursor;
wnd_cls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wnd_cls.lpszMenuName = NULL;
wnd_cls.lpszClassName = g_wnd_class_name;
wnd_cls.hInstance = hInstance;
wnd_cls.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
RegisterClassEx(&wnd_cls);
g_hInstance = hInstance;
instance = freerdp_new();
instance->PreConnect = wf_pre_connect;
instance->PostConnect = wf_post_connect;
instance->ReceiveChannelData = wf_receive_channel_data;
chanman = freerdp_chanman_new();
SET_CHANMAN(instance, chanman);
if (!CreateThread(NULL, 0, kbd_thread_func, NULL, 0, NULL))
printf("error creating keyboard handler thread");
while (1)
{
data = (thread_data*) xzalloc(sizeof(thread_data));
data->instance = instance;
freerdp_parse_args(instance->settings, __argc, __argv, NULL, NULL, NULL, NULL);
if (CreateThread(NULL, 0, thread_func, data, 0, NULL) != 0)
{
g_thread_count++;
}
}
if (g_thread_count > 0)
WaitForSingleObject(g_done_event, INFINITE);
else
MessageBox(GetConsoleWindow(),
L"Failed to start wfreerdp.\n\nPlease check the debug output.",
L"FreeRDP Error", MB_ICONSTOP);
WSACleanup();
return 0;
}

68
client/Windows/wfreerdp.h Normal file
View File

@ -0,0 +1,68 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Windows Client
*
* Copyright 2009-2011 Jay Sorg
* Copyright 2010-2011 Vic Lee
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __WFREERDP_H
#define __WFREERDP_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <winsock2.h>
#include <windows.h>
#include <freerdp/freerdp.h>
#include <freerdp/gdi/gdi.h>
#include <freerdp/gdi/color.h>
#include <freerdp/utils/debug.h>
#include <freerdp/chanman/chanman.h>
#define SET_WFI(_instance, _wfi) (_instance)->param1 = _wfi
#define GET_WFI(_instance) ((wfInfo*) ((_instance)->param1))
#define SET_CHANMAN(_instance, _chanman) (_instance)->param2 = _chanman
#define GET_CHANMAN(_instance) ((rdpChanMan*) ((_instance)->param2))
struct wf_bitmap
{
HDC hdc;
HBITMAP bitmap;
HBITMAP org_bitmap;
};
struct wf_info
{
int fs_toggle;
int fullscreen;
int percentscreen;
char window_title[64];
HWND hwnd;
struct wf_bitmap* primary;
struct wf_bitmap* drawing;
HCLRCONV clrconv;
HCURSOR cursor;
HBRUSH brush;
HBRUSH org_brush;
};
typedef struct wf_info wfInfo;
#endif

View File

@ -29,6 +29,8 @@ add_executable(xfreerdp
xf_event.h
xf_keyboard.c
xf_keyboard.h
xf_monitor.c
xf_monitor.h
xf_window.c
xf_window.h
xfreerdp.c
@ -49,21 +51,21 @@ if(WITH_MANPAGES)
endif(XMLTO_FOUND)
endif(WITH_MANPAGES)
find_package(Xinerama)
find_suggested_package(Xinerama)
if(XINERAMA_FOUND)
add_definitions(-DWITH_XINERAMA -DWITH_XEXT)
include_directories(${XINERAMA_INCLUDE_DIRS})
target_link_libraries(xfreerdp ${XINERAMA_LIBRARIES})
endif()
find_package(Xext)
find_suggested_package(Xext)
if(XEXT_FOUND)
add_definitions(-DWITH_XEXT)
include_directories(${XEXT_INCLUDE_DIRS})
target_link_libraries(xfreerdp ${XEXT_LIBRARIES})
endif()
find_package(Xcursor)
find_suggested_package(Xcursor)
if(Xcursor_FOUND)
add_definitions(-DWITH_XCURSOR)
include_directories(${Xcursor_INCLUDE_DIRS})

106
client/X11/xf_monitor.c Normal file
View File

@ -0,0 +1,106 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* X11 Monitor Handling
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#ifdef WITH_XINERAMA
#include <X11/extensions/Xinerama.h>
#endif
#include "xf_monitor.h"
/* See MSDN Section on Multiple Display Monitors: http://msdn.microsoft.com/en-us/library/dd145071 */
boolean xf_detect_monitors(xfInfo* xfi, rdpSettings* settings)
{
int i;
VIRTUAL_SCREEN* vscreen;
#ifdef WITH_XINERAMA
int ignored, ignored2;
XineramaScreenInfo* screen_info = NULL;
#endif
vscreen = &xfi->vscreen;
xf_GetWorkArea(xfi);
if (settings->workarea)
{
settings->width = xfi->workArea.width;
settings->height = xfi->workArea.height;
}
if (settings->fullscreen != True && settings->workarea != True)
return True;
#ifdef WITH_XINERAMA
if (XineramaQueryExtension(xfi->display, &ignored, &ignored2))
{
if (XineramaIsActive(xfi->display))
{
screen_info = XineramaQueryScreens(xfi->display, &vscreen->nmonitors);
if (vscreen->nmonitors > 16)
vscreen->nmonitors = 0;
vscreen->monitors = xzalloc(sizeof(MONITOR_INFO) * vscreen->nmonitors);
if (vscreen->nmonitors)
{
for (i = 0; i < vscreen->nmonitors; i++)
{
vscreen->monitors[i].area.left = screen_info[i].x_org;
vscreen->monitors[i].area.top = screen_info[i].y_org;
vscreen->monitors[i].area.right = screen_info[i].x_org + screen_info[i].width - 1;
vscreen->monitors[i].area.bottom = screen_info[i].y_org + screen_info[i].height - 1;
if ((screen_info[i].x_org == 0) && (screen_info[i].y_org == 0))
vscreen->monitors[i].primary = True;
}
}
XFree(screen_info);
}
}
#endif
settings->num_monitors = vscreen->nmonitors;
settings->width = 0;
settings->height = 0;
for (i = 0; i < vscreen->nmonitors; i++)
{
settings->monitors[i].x = vscreen->monitors[i].area.left;
settings->monitors[i].y = vscreen->monitors[i].area.top;
settings->monitors[i].width = vscreen->monitors[i].area.right - vscreen->monitors[i].area.left + 1;
settings->monitors[i].height = vscreen->monitors[i].area.bottom - vscreen->monitors[i].area.top + 1;
settings->monitors[i].is_primary = vscreen->monitors[i].primary;
settings->width += settings->monitors[i].width;
settings->height = settings->monitors[i].height;
}
return True;
}

47
client/X11/xf_monitor.h Normal file
View File

@ -0,0 +1,47 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* X11 Monitor Handling
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __XF_MONITOR_H
#define __XF_MONITOR_H
#include <freerdp/freerdp.h>
#include <freerdp/rail/rail.h>
struct _MONITOR_INFO
{
RECTANGLE_16 area;
RECTANGLE_16 workarea;
boolean primary;
};
typedef struct _MONITOR_INFO MONITOR_INFO;
struct _VIRTUAL_SCREEN
{
int nmonitors;
RECTANGLE_16 area;
RECTANGLE_16 workarea;
MONITOR_INFO* monitors;
};
typedef struct _VIRTUAL_SCREEN VIRTUAL_SCREEN;
#include "xfreerdp.h"
boolean xf_detect_monitors(xfInfo* xfi, rdpSettings* settings);
#endif /* __XF_MONITOR_H */

View File

@ -187,14 +187,14 @@ void xf_rail_DestroyWindow(rdpRail* rail, rdpWindow* window)
void xf_rail_register_callbacks(xfInfo* xfi, rdpRail* rail)
{
rail->extra = (void*) xfi;
rail->CreateWindow = xf_rail_CreateWindow;
rail->MoveWindow = xf_rail_MoveWindow;
rail->ShowWindow = xf_rail_ShowWindow;
rail->SetWindowText = xf_rail_SetWindowText;
rail->SetWindowIcon = xf_rail_SetWindowIcon;
rail->SetWindowRects = xf_rail_SetWindowRects;
rail->SetWindowVisibilityRects = xf_rail_SetWindowVisibilityRects;
rail->DestroyWindow = xf_rail_DestroyWindow;
rail->rail_CreateWindow = xf_rail_CreateWindow;
rail->rail_MoveWindow = xf_rail_MoveWindow;
rail->rail_ShowWindow = xf_rail_ShowWindow;
rail->rail_SetWindowText = xf_rail_SetWindowText;
rail->rail_SetWindowIcon = xf_rail_SetWindowIcon;
rail->rail_SetWindowRects = xf_rail_SetWindowRects;
rail->rail_SetWindowVisibilityRects = xf_rail_SetWindowVisibilityRects;
rail->rail_DestroyWindow = xf_rail_DestroyWindow;
}
static void xf_on_free_rail_client_event(RDP_EVENT* event)
@ -276,11 +276,6 @@ void xf_process_rail_get_sysparams_event(xfInfo* xfi, rdpChanMan* chanman, RDP_E
sysparam->workArea.right = xfi->workArea.x + xfi->workArea.width;
sysparam->workArea.bottom = xfi->workArea.y + xfi->workArea.height;
sysparam->displayChange.left = xfi->workArea.x;
sysparam->displayChange.top = xfi->workArea.y;
sysparam->displayChange.right = xfi->workArea.x + xfi->workArea.width;
sysparam->displayChange.bottom = xfi->workArea.y + xfi->workArea.height;
sysparam->taskbarPos.left = 0;
sysparam->taskbarPos.top = 0;
sysparam->taskbarPos.right = 0;

View File

@ -41,6 +41,7 @@
#include "xf_gdi.h"
#include "xf_rail.h"
#include "xf_event.h"
#include "xf_monitor.h"
#include "xf_keyboard.h"
#include "xfreerdp.h"
@ -235,11 +236,6 @@ boolean xf_pre_connect(freerdp* instance)
xfInfo* xfi;
rdpSettings* settings;
#ifdef WITH_XINERAMA
int n, ignored, ignored2;
XineramaScreenInfo* screen_info = NULL;
#endif
xfi = (xfInfo*) xzalloc(sizeof(xfInfo));
SET_XFI(instance, xfi);
@ -318,61 +314,7 @@ boolean xf_pre_connect(freerdp* instance)
xfi->remote_app = settings->remote_app;
xfi->fullscreen = settings->fullscreen;
xf_GetWorkArea(xfi);
if (settings->workarea)
{
settings->width = xfi->workArea.width;
settings->height = xfi->workArea.height;
}
if (settings->fullscreen != True && settings->workarea != True)
return True;
#ifdef WITH_XINERAMA
if (XineramaQueryExtension(xfi->display, &ignored, &ignored2))
{
if (XineramaIsActive(xfi->display))
{
screen_info = XineramaQueryScreens(xfi->display, &settings->num_monitors);
if (settings->num_monitors > 16)
settings->num_monitors = 0;
settings->width = 0;
settings->height = 0;
if (settings->num_monitors)
{
for (n = 0; n < settings->num_monitors; n++)
{
if (settings->workarea)
{
settings->monitors[n].x = screen_info[n].x_org;
settings->monitors[n].y = screen_info[n].y_org;
settings->monitors[n].width = screen_info[n].width;
settings->monitors[n].height = xfi->workArea.height;
settings->width += settings->monitors[n].width;
settings->height = settings->monitors[n].height;
}
else
{
settings->monitors[n].x = screen_info[n].x_org;
settings->monitors[n].y = screen_info[n].y_org;
settings->monitors[n].width = screen_info[n].width;
settings->monitors[n].height = screen_info[n].height;
settings->width += settings->monitors[n].width;
settings->height = settings->monitors[n].height;
}
settings->monitors[n].is_primary = screen_info[n].x_org == 0 && screen_info[n].y_org == 0;
}
}
XFree(screen_info);
}
}
#endif
xf_detect_monitors(xfi, settings);
return True;
}

View File

@ -31,6 +31,7 @@
typedef struct xf_info xfInfo;
#include "xf_window.h"
#include "xf_monitor.h"
#define SET_XFI(_instance, _xfi) (_instance)->param1 = _xfi
#define GET_XFI(_instance) ((xfInfo*) ((_instance)->param1))
@ -87,6 +88,7 @@ struct xf_info
XModifierKeymap* modifier_map;
XSetWindowAttributes attribs;
boolean complex_regions;
VIRTUAL_SCREEN vscreen;
Atom _NET_WM_ICON;
Atom _MOTIF_WM_HINTS;

View File

@ -1,7 +1,10 @@
# - FindOptionalPackage
# Enable or disable optional packages. Also force optional packages.
#
# This module defines the following variables:
# This module defines the following macros:
# find_required_package : find a required package, can not be disabled
# find_suggested_package : find a suggested package - required but can be disabled
# find_optional_package : find an optional package - required only if enabled
#
#=============================================================================
@ -20,15 +23,29 @@
# limitations under the License.
#=============================================================================
macro(find_required_package _normal_package)
find_package(${_normal_package} REQUIRED)
endmacro(find_required_package)
macro(find_suggested_package _normal_package)
string(TOUPPER ${_normal_package} _upper_package)
option(WITH_${_upper_package} "Add dependency to ${_normal_package} - recommended" ON)
if(NOT WITHOUT_${_upper_package})
message(STATUS "Finding suggested package ${_normal_package}.")
message(STATUS " Disable this using \"-DWITH_${_upper_package}=OFF\".")
find_package(${_normal_package} REQUIRED)
endif(NOT WITHOUT_${_upper_package})
endmacro(find_suggested_package)
macro(find_optional_package _normal_package)
STRING(TOUPPER ${_normal_package} _upper_package)
OPTION(WITH_${_upper_package} "Force dependencies to ${_normal_package}" OFF)
OPTION(WITHOUT_${_upper_package} "Never depend on ${_normal_package}" OFF)
string(TOUPPER ${_normal_package} _upper_package)
option(WITH_${_upper_package} "Add dependency to ${_normal_package}" OFF)
if(WITH_${_upper_package})
find_package(${_normal_package} REQUIRED)
elseif(NOT WITHOUT_${_upper_package})
find_package(${_normal_package})
else(WITH_${_upper_package})
message(STATUS "Skipping optional package ${_normal_package}.")
message(STATUS " Enable this using \"-DWITH_${_upper_package}=ON\".")
endif(WITH_${_upper_package})
endmacro(find_optional_package)

View File

@ -45,11 +45,17 @@
#endif
#ifdef _WIN32
#define FREERDP_CC __stdcall
#define FREERDP_CC __cdecl
#else
#define FREERDP_CC
#endif
#ifdef _WIN32
#define INLINE __inline
#else
#define INLINE inline
#endif
#define IFCALL(_cb, ...) do { if (_cb != NULL) { _cb( __VA_ARGS__ ); } } while (0)
#endif

View File

@ -25,6 +25,7 @@
*/
enum RDP_CODEC_ID
{
CODEC_ID_NONE = 0x00,
CODEC_ID_NSCODEC = 0x01,
CODEC_ID_REMOTEFX = 0x02
};

View File

@ -242,12 +242,13 @@ struct _GDI
HGDI_DC hdc;
HCLRCONV clrconv;
GDI_IMAGE *primary;
GDI_IMAGE *drawing;
GDI_IMAGE* primary;
GDI_IMAGE* drawing;
uint8* primary_buffer;
GDI_COLOR textColor;
void * rfx_context;
GDI_IMAGE *tile;
void* rfx_context;
GDI_IMAGE* tile;
GDI_IMAGE* image;
rdpCache* cache;
};

View File

@ -50,14 +50,14 @@ struct rdp_rail
rdpIconCache* cache;
rdpWindowList* list;
rdpSettings* settings;
railCreateWindow CreateWindow;
railDestroyWindow DestroyWindow;
railMoveWindow MoveWindow;
railShowWindow ShowWindow;
railSetWindowText SetWindowText;
railSetWindowIcon SetWindowIcon;
railSetWindowRects SetWindowRects;
railSetWindowVisibilityRects SetWindowVisibilityRects;
railCreateWindow rail_CreateWindow;
railDestroyWindow rail_DestroyWindow;
railMoveWindow rail_MoveWindow;
railShowWindow rail_ShowWindow;
railSetWindowText rail_SetWindowText;
railSetWindowIcon rail_SetWindowIcon;
railSetWindowRects rail_SetWindowRects;
railSetWindowVisibilityRects rail_SetWindowVisibilityRects;
};
FREERDP_API void rail_register_update_callbacks(rdpRail* rail, rdpUpdate* update);

View File

@ -25,6 +25,10 @@
#include <freerdp/utils/pcap.h>
#include <freerdp/utils/stream.h>
#ifdef _WIN32
#include <windows.h>
#endif
/* Common */
struct _BOUNDS

View File

@ -27,16 +27,17 @@ struct rdp_certstore
struct rdp_certdata* certdata;
};
void certstore_create(rdpCertstore* certstore);
void certstore_open(rdpCertstore* certstore);
void certstore_load(rdpCertstore* certstore);
void certstore_close(rdpCertstore* certstore);
char* get_local_certloc();
rdpCertdata* certdata_new(char* host_name,char* fingerprint);
void certdata_free(rdpCertdata* certdata);
void certstore_init(rdpCertstore* certstore);
rdpCertstore* certstore_new(rdpCertdata* certdata);
void certstore_free(rdpCertstore* certstore);
int match_certdata(rdpCertstore* certstore);
void print_certdata(rdpCertstore* certstore);
FREERDP_API void certstore_create(rdpCertstore* certstore);
FREERDP_API void certstore_open(rdpCertstore* certstore);
FREERDP_API void certstore_load(rdpCertstore* certstore);
FREERDP_API void certstore_close(rdpCertstore* certstore);
FREERDP_API char* get_local_certloc();
FREERDP_API rdpCertdata* certdata_new(char* host_name, char* fingerprint);
FREERDP_API void certdata_free(rdpCertdata* certdata);
FREERDP_API void certstore_init(rdpCertstore* certstore);
FREERDP_API rdpCertstore* certstore_new(rdpCertdata* certdata);
FREERDP_API void certstore_free(rdpCertstore* certstore);
FREERDP_API int match_certdata(rdpCertstore* certstore);
FREERDP_API void print_certdata(rdpCertstore* certstore);
#endif /* __CERTSTORE_UTILS_H */

View File

@ -23,6 +23,7 @@
#include <freerdp/api.h>
#include <freerdp/types.h>
FREERDP_API void freerdp_sleep(uint32 seconds);
FREERDP_API void freerdp_usleep(uint32 useconds);
#endif /* __SLEEP_UTILS_H */

View File

@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <freerdp/api.h>
#include <freerdp/utils/stream.h>
#include "orders.h"
@ -73,7 +74,7 @@ uint16 fastpath_read_header(rdpFastPath* fastpath, STREAM* s)
return length;
}
inline void fastpath_read_update_header(STREAM* s, uint8* updateCode, uint8* fragmentation, uint8* compression)
INLINE void fastpath_read_update_header(STREAM* s, uint8* updateCode, uint8* fragmentation, uint8* compression)
{
uint8 updateHeader;
@ -83,7 +84,7 @@ inline void fastpath_read_update_header(STREAM* s, uint8* updateCode, uint8* fra
*compression = (updateHeader >> 6) & 0x03;
}
inline void fastpath_write_update_header(STREAM* s, uint8 updateCode, uint8 fragmentation, uint8 compression)
INLINE void fastpath_write_update_header(STREAM* s, uint8 updateCode, uint8 fragmentation, uint8 compression)
{
uint8 updateHeader = 0;

View File

@ -17,6 +17,8 @@
* limitations under the License.
*/
#include <freerdp/utils/print.h>
#include "gcc.h"
/**

View File

@ -21,6 +21,7 @@
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <freerdp/utils/print.h>
#ifndef _WIN32
#include <netdb.h>
@ -47,6 +48,9 @@ static boolean freerdp_listener_open(freerdp_listener* instance, const char* bin
int option_value;
void* sin_addr;
char buf[50];
#ifdef _WIN32
u_long arg;
#endif
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
@ -78,7 +82,13 @@ static boolean freerdp_listener_open(freerdp_listener* instance, const char* bin
{
perror("setsockopt");
}
#ifndef _WIN32
fcntl(sockfd, F_SETFL, O_NONBLOCK);
#else
arg = 1;
ioctlsocket(sockfd, FIONBIO, &arg);
#endif
status = bind(sockfd, ai->ai_addr, ai->ai_addrlen);
if (status != 0)

View File

@ -251,13 +251,14 @@ rdpTls* tls_new()
int tls_verify_certificate(CryptoCert cert, char* hostname)
{
boolean ret;
rdpCertstore* certstore;
ret = x509_verify_cert(cert);
if (!ret)
{
rdpCertdata* certdata;
certdata = crypto_get_certdata(cert->px509, hostname);
rdpCertstore* certstore = certstore_new(certdata);
certstore = certstore_new(certdata);
if (match_certdata(certstore) == 0)
goto end;
@ -267,17 +268,17 @@ int tls_verify_certificate(CryptoCert cert, char* hostname)
char answer;
crypto_cert_printinfo(cert->px509);
while(1)
while (1)
{
printf("Do you trust the above certificate? (Y/N) ");
answer=fgetc(stdin);
answer = fgetc(stdin);
if(answer=='y' || answer =='Y')
if (answer == 'y' || answer == 'Y')
{
print_certdata(certstore);
break;
}
else if(answer=='n' || answer=='N')
else if (answer == 'n' || answer == 'N')
{
certstore_free(certstore);
return 1;

View File

@ -20,6 +20,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <freerdp/api.h>
#include <freerdp/freerdp.h>
#include <freerdp/gdi/gdi.h>
#include <freerdp/gdi/color.h>
@ -799,96 +800,96 @@ int PatBlt_16bpp(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, i
return 1;
}
inline void SetPixel_BLACK_16bpp(uint16 *pixel, uint16 *pen)
INLINE void SetPixel_BLACK_16bpp(uint16 *pixel, uint16 *pen)
{
/* D = 0 */
*pixel = 0;
}
inline void SetPixel_NOTMERGEPEN_16bpp(uint16 *pixel, uint16 *pen)
INLINE void SetPixel_NOTMERGEPEN_16bpp(uint16 *pixel, uint16 *pen)
{
/* D = ~(D | P) */
*pixel = ~(*pixel | *pen);
}
inline void SetPixel_MASKNOTPEN_16bpp(uint16 *pixel, uint16 *pen)
INLINE void SetPixel_MASKNOTPEN_16bpp(uint16 *pixel, uint16 *pen)
{
/* D = D & ~P */
*pixel &= ~(*pen);
}
inline void SetPixel_NOTCOPYPEN_16bpp(uint16 *pixel, uint16 *pen)
INLINE void SetPixel_NOTCOPYPEN_16bpp(uint16 *pixel, uint16 *pen)
{
/* D = ~P */
*pixel = ~(*pen);
}
inline void SetPixel_MASKPENNOT_16bpp(uint16 *pixel, uint16 *pen)
INLINE void SetPixel_MASKPENNOT_16bpp(uint16 *pixel, uint16 *pen)
{
/* D = P & ~D */
*pixel = *pen & ~*pixel;
}
inline void SetPixel_NOT_16bpp(uint16 *pixel, uint16 *pen)
INLINE void SetPixel_NOT_16bpp(uint16 *pixel, uint16 *pen)
{
/* D = ~D */
*pixel = ~(*pixel);
}
inline void SetPixel_XORPEN_16bpp(uint16 *pixel, uint16 *pen)
INLINE void SetPixel_XORPEN_16bpp(uint16 *pixel, uint16 *pen)
{
/* D = D ^ P */
*pixel = *pixel ^ *pen;
}
inline void SetPixel_NOTMASKPEN_16bpp(uint16 *pixel, uint16 *pen)
INLINE void SetPixel_NOTMASKPEN_16bpp(uint16 *pixel, uint16 *pen)
{
/* D = ~(D & P) */
*pixel = ~(*pixel & *pen);
}
inline void SetPixel_MASKPEN_16bpp(uint16 *pixel, uint16 *pen)
INLINE void SetPixel_MASKPEN_16bpp(uint16 *pixel, uint16 *pen)
{
/* D = D & P */
*pixel &= *pen;
}
inline void SetPixel_NOTXORPEN_16bpp(uint16 *pixel, uint16 *pen)
INLINE void SetPixel_NOTXORPEN_16bpp(uint16 *pixel, uint16 *pen)
{
/* D = ~(D ^ P) */
*pixel = ~(*pixel ^ *pen);
}
inline void SetPixel_NOP_16bpp(uint16 *pixel, uint16 *pen)
INLINE void SetPixel_NOP_16bpp(uint16 *pixel, uint16 *pen)
{
/* D = D */
}
inline void SetPixel_MERGENOTPEN_16bpp(uint16 *pixel, uint16 *pen)
INLINE void SetPixel_MERGENOTPEN_16bpp(uint16 *pixel, uint16 *pen)
{
/* D = D | ~P */
*pixel |= ~(*pen);
}
inline void SetPixel_COPYPEN_16bpp(uint16 *pixel, uint16 *pen)
INLINE void SetPixel_COPYPEN_16bpp(uint16 *pixel, uint16 *pen)
{
/* D = P */
*pixel = *pen;
}
inline void SetPixel_MERGEPENNOT_16bpp(uint16 *pixel, uint16 *pen)
INLINE void SetPixel_MERGEPENNOT_16bpp(uint16 *pixel, uint16 *pen)
{
/* D = P | ~D */
*pixel = *pen | ~(*pixel);
}
inline void SetPixel_MERGEPEN_16bpp(uint16 *pixel, uint16 *pen)
INLINE void SetPixel_MERGEPEN_16bpp(uint16 *pixel, uint16 *pen)
{
/* D = P | D */
*pixel |= *pen;
}
inline void SetPixel_WHITE_16bpp(uint16 *pixel, uint16 *pen)
INLINE void SetPixel_WHITE_16bpp(uint16 *pixel, uint16 *pen)
{
/* D = 1 */
*pixel = 0xFFFF;

View File

@ -20,6 +20,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <freerdp/api.h>
#include <freerdp/freerdp.h>
#include <freerdp/gdi/gdi.h>
#include <freerdp/gdi/color.h>
@ -827,96 +828,96 @@ int PatBlt_32bpp(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, i
return 1;
}
inline void SetPixel_BLACK_32bpp(uint32 *pixel, uint32 *pen)
INLINE void SetPixel_BLACK_32bpp(uint32 *pixel, uint32 *pen)
{
/* D = 0 */
*pixel = 0;
}
inline void SetPixel_NOTMERGEPEN_32bpp(uint32 *pixel, uint32 *pen)
INLINE void SetPixel_NOTMERGEPEN_32bpp(uint32 *pixel, uint32 *pen)
{
/* D = ~(D | P) */
*pixel = ~(*pixel | *pen);
}
inline void SetPixel_MASKNOTPEN_32bpp(uint32 *pixel, uint32 *pen)
INLINE void SetPixel_MASKNOTPEN_32bpp(uint32 *pixel, uint32 *pen)
{
/* D = D & ~P */
*pixel &= ~(*pen);
}
inline void SetPixel_NOTCOPYPEN_32bpp(uint32 *pixel, uint32 *pen)
INLINE void SetPixel_NOTCOPYPEN_32bpp(uint32 *pixel, uint32 *pen)
{
/* D = ~P */
*pixel = ~(*pen);
}
inline void SetPixel_MASKPENNOT_32bpp(uint32 *pixel, uint32 *pen)
INLINE void SetPixel_MASKPENNOT_32bpp(uint32 *pixel, uint32 *pen)
{
/* D = P & ~D */
*pixel = *pen & ~*pixel;
}
inline void SetPixel_NOT_32bpp(uint32 *pixel, uint32 *pen)
INLINE void SetPixel_NOT_32bpp(uint32 *pixel, uint32 *pen)
{
/* D = ~D */
*pixel = ~(*pixel);
}
inline void SetPixel_XORPEN_32bpp(uint32 *pixel, uint32 *pen)
INLINE void SetPixel_XORPEN_32bpp(uint32 *pixel, uint32 *pen)
{
/* D = D ^ P */
*pixel = *pixel ^ *pen;
}
inline void SetPixel_NOTMASKPEN_32bpp(uint32 *pixel, uint32 *pen)
INLINE void SetPixel_NOTMASKPEN_32bpp(uint32 *pixel, uint32 *pen)
{
/* D = ~(D & P) */
*pixel = ~(*pixel & *pen);
}
inline void SetPixel_MASKPEN_32bpp(uint32 *pixel, uint32 *pen)
INLINE void SetPixel_MASKPEN_32bpp(uint32 *pixel, uint32 *pen)
{
/* D = D & P */
*pixel &= *pen;
}
inline void SetPixel_NOTXORPEN_32bpp(uint32 *pixel, uint32 *pen)
INLINE void SetPixel_NOTXORPEN_32bpp(uint32 *pixel, uint32 *pen)
{
/* D = ~(D ^ P) */
*pixel = ~(*pixel ^ *pen);
}
inline void SetPixel_NOP_32bpp(uint32 *pixel, uint32 *pen)
INLINE void SetPixel_NOP_32bpp(uint32 *pixel, uint32 *pen)
{
/* D = D */
}
inline void SetPixel_MERGENOTPEN_32bpp(uint32 *pixel, uint32 *pen)
INLINE void SetPixel_MERGENOTPEN_32bpp(uint32 *pixel, uint32 *pen)
{
/* D = D | ~P */
*pixel |= ~(*pen);
}
inline void SetPixel_COPYPEN_32bpp(uint32 *pixel, uint32 *pen)
INLINE void SetPixel_COPYPEN_32bpp(uint32 *pixel, uint32 *pen)
{
/* D = P */
*pixel = *pen;
}
inline void SetPixel_MERGEPENNOT_32bpp(uint32 *pixel, uint32 *pen)
INLINE void SetPixel_MERGEPENNOT_32bpp(uint32 *pixel, uint32 *pen)
{
/* D = P | ~D */
*pixel = *pen | ~(*pixel);
}
inline void SetPixel_MERGEPEN_32bpp(uint32 *pixel, uint32 *pen)
INLINE void SetPixel_MERGEPEN_32bpp(uint32 *pixel, uint32 *pen)
{
/* D = P | D */
*pixel |= *pen;
}
inline void SetPixel_WHITE_32bpp(uint32 *pixel, uint32 *pen)
INLINE void SetPixel_WHITE_32bpp(uint32 *pixel, uint32 *pen)
{
/* D = 1 */
*pixel = 0xFFFFFF;

View File

@ -20,6 +20,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <freerdp/api.h>
#include <freerdp/freerdp.h>
#include <freerdp/gdi/gdi.h>
#include <freerdp/gdi/color.h>
@ -707,96 +708,96 @@ int PatBlt_8bpp(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, in
return 1;
}
inline void SetPixel_BLACK_8bpp(uint8* pixel, uint8* pen)
INLINE void SetPixel_BLACK_8bpp(uint8* pixel, uint8* pen)
{
/* D = 0 */
*pixel = 0;
}
inline void SetPixel_NOTMERGEPEN_8bpp(uint8* pixel, uint8* pen)
INLINE void SetPixel_NOTMERGEPEN_8bpp(uint8* pixel, uint8* pen)
{
/* D = ~(D | P) */
*pixel = ~(*pixel | *pen);
}
inline void SetPixel_MASKNOTPEN_8bpp(uint8* pixel, uint8* pen)
INLINE void SetPixel_MASKNOTPEN_8bpp(uint8* pixel, uint8* pen)
{
/* D = D & ~P */
*pixel &= ~(*pen);
}
inline void SetPixel_NOTCOPYPEN_8bpp(uint8* pixel, uint8* pen)
INLINE void SetPixel_NOTCOPYPEN_8bpp(uint8* pixel, uint8* pen)
{
/* D = ~P */
*pixel = ~(*pen);
}
inline void SetPixel_MASKPENNOT_8bpp(uint8* pixel, uint8* pen)
INLINE void SetPixel_MASKPENNOT_8bpp(uint8* pixel, uint8* pen)
{
/* D = P & ~D */
*pixel = *pen & ~*pixel;
}
inline void SetPixel_NOT_8bpp(uint8* pixel, uint8* pen)
INLINE void SetPixel_NOT_8bpp(uint8* pixel, uint8* pen)
{
/* D = ~D */
*pixel = ~(*pixel);
}
inline void SetPixel_XORPEN_8bpp(uint8* pixel, uint8* pen)
INLINE void SetPixel_XORPEN_8bpp(uint8* pixel, uint8* pen)
{
/* D = D ^ P */
*pixel = *pixel ^ *pen;
}
inline void SetPixel_NOTMASKPEN_8bpp(uint8* pixel, uint8* pen)
INLINE void SetPixel_NOTMASKPEN_8bpp(uint8* pixel, uint8* pen)
{
/* D = ~(D & P) */
*pixel = ~(*pixel & *pen);
}
inline void SetPixel_MASKPEN_8bpp(uint8* pixel, uint8* pen)
INLINE void SetPixel_MASKPEN_8bpp(uint8* pixel, uint8* pen)
{
/* D = D & P */
*pixel &= *pen;
}
inline void SetPixel_NOTXORPEN_8bpp(uint8* pixel, uint8* pen)
INLINE void SetPixel_NOTXORPEN_8bpp(uint8* pixel, uint8* pen)
{
/* D = ~(D ^ P) */
*pixel = ~(*pixel ^ *pen);
}
inline void SetPixel_NOP_8bpp(uint8* pixel, uint8* pen)
INLINE void SetPixel_NOP_8bpp(uint8* pixel, uint8* pen)
{
/* D = D */
}
inline void SetPixel_MERGENOTPEN_8bpp(uint8* pixel, uint8* pen)
INLINE void SetPixel_MERGENOTPEN_8bpp(uint8* pixel, uint8* pen)
{
/* D = D | ~P */
*pixel |= ~(*pen);
}
inline void SetPixel_COPYPEN_8bpp(uint8* pixel, uint8* pen)
INLINE void SetPixel_COPYPEN_8bpp(uint8* pixel, uint8* pen)
{
/* D = P */
*pixel = *pen;
}
inline void SetPixel_MERGEPENNOT_8bpp(uint8* pixel, uint8* pen)
INLINE void SetPixel_MERGEPENNOT_8bpp(uint8* pixel, uint8* pen)
{
/* D = P | ~D */
*pixel = *pen | ~(*pixel);
}
inline void SetPixel_MERGEPEN_8bpp(uint8* pixel, uint8* pen)
INLINE void SetPixel_MERGEPEN_8bpp(uint8* pixel, uint8* pen)
{
/* D = P | D */
*pixel |= *pen;
}
inline void SetPixel_WHITE_8bpp(uint8* pixel, uint8* pen)
INLINE void SetPixel_WHITE_8bpp(uint8* pixel, uint8* pen)
{
/* D = 1 */
*pixel = 0xFF;

View File

@ -20,6 +20,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <freerdp/api.h>
#include <freerdp/freerdp.h>
#include <freerdp/gdi/gdi.h>
#include <freerdp/gdi/color.h>
@ -48,39 +49,39 @@ pBitBlt BitBlt_[5] =
* @return pixel color
*/
inline GDI_COLOR gdi_GetPixel(HGDI_DC hdc, int nXPos, int nYPos)
INLINE GDI_COLOR gdi_GetPixel(HGDI_DC hdc, int nXPos, int nYPos)
{
HGDI_BITMAP hBmp = (HGDI_BITMAP) hdc->selectedObject;
GDI_COLOR* colorp = (GDI_COLOR*)&(hBmp->data[(nYPos * hBmp->width * hdc->bytesPerPixel) + nXPos * hdc->bytesPerPixel]);
return (GDI_COLOR) *colorp;
}
inline uint8 gdi_GetPixel_8bpp(HGDI_BITMAP hBmp, int X, int Y)
INLINE uint8 gdi_GetPixel_8bpp(HGDI_BITMAP hBmp, int X, int Y)
{
return *((uint8*)&(hBmp->data[(Y * hBmp->width) + X]));
}
inline uint16 gdi_GetPixel_16bpp(HGDI_BITMAP hBmp, int X, int Y)
INLINE uint16 gdi_GetPixel_16bpp(HGDI_BITMAP hBmp, int X, int Y)
{
return *((uint16*)&(hBmp->data[(Y * hBmp->width * 2) + X * 2]));
}
inline uint32 gdi_GetPixel_32bpp(HGDI_BITMAP hBmp, int X, int Y)
INLINE uint32 gdi_GetPixel_32bpp(HGDI_BITMAP hBmp, int X, int Y)
{
return *((uint32*)&(hBmp->data[(Y * hBmp->width * 4) + X * 4]));
}
inline uint8* gdi_GetPointer_8bpp(HGDI_BITMAP hBmp, int X, int Y)
INLINE uint8* gdi_GetPointer_8bpp(HGDI_BITMAP hBmp, int X, int Y)
{
return ((uint8*)&(hBmp->data[(Y * hBmp->width) + X]));
}
inline uint16* gdi_GetPointer_16bpp(HGDI_BITMAP hBmp, int X, int Y)
INLINE uint16* gdi_GetPointer_16bpp(HGDI_BITMAP hBmp, int X, int Y)
{
return ((uint16*)&(hBmp->data[(Y * hBmp->width * 2) + X * 2]));
}
inline uint32* gdi_GetPointer_32bpp(HGDI_BITMAP hBmp, int X, int Y)
INLINE uint32* gdi_GetPointer_32bpp(HGDI_BITMAP hBmp, int X, int Y)
{
return ((uint32*)&(hBmp->data[(Y * hBmp->width * 4) + X * 4]));
}
@ -95,24 +96,24 @@ inline uint32* gdi_GetPointer_32bpp(HGDI_BITMAP hBmp, int X, int Y)
* @return
*/
inline GDI_COLOR gdi_SetPixel(HGDI_DC hdc, int X, int Y, GDI_COLOR crColor)
INLINE GDI_COLOR gdi_SetPixel(HGDI_DC hdc, int X, int Y, GDI_COLOR crColor)
{
HGDI_BITMAP hBmp = (HGDI_BITMAP) hdc->selectedObject;
*((GDI_COLOR*)&(hBmp->data[(Y * hBmp->width * hdc->bytesPerPixel) + X * hdc->bytesPerPixel])) = crColor;
return 0;
}
inline void gdi_SetPixel_8bpp(HGDI_BITMAP hBmp, int X, int Y, uint8 pixel)
INLINE void gdi_SetPixel_8bpp(HGDI_BITMAP hBmp, int X, int Y, uint8 pixel)
{
*((uint8*)&(hBmp->data[(Y * hBmp->width) + X])) = pixel;
}
inline void gdi_SetPixel_16bpp(HGDI_BITMAP hBmp, int X, int Y, uint16 pixel)
INLINE void gdi_SetPixel_16bpp(HGDI_BITMAP hBmp, int X, int Y, uint16 pixel)
{
*((uint16*)&(hBmp->data[(Y * hBmp->width * 2) + X * 2])) = pixel;
}
inline void gdi_SetPixel_32bpp(HGDI_BITMAP hBmp, int X, int Y, uint32 pixel)
INLINE void gdi_SetPixel_32bpp(HGDI_BITMAP hBmp, int X, int Y, uint32 pixel)
{
*((uint32*)&(hBmp->data[(Y * hBmp->width * 4) + X * 4])) = pixel;
}

View File

@ -20,6 +20,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <freerdp/api.h>
#include <freerdp/freerdp.h>
#include <freerdp/constants.h>
#include <freerdp/gdi/color.h>
@ -301,17 +302,17 @@ const uint32 rop3_code_table[] =
/* GDI Helper Functions */
inline uint32 gdi_rop3_code(uint8 code)
INLINE uint32 gdi_rop3_code(uint8 code)
{
return rop3_code_table[code];
}
inline void gdi_copy_mem(uint8 * d, uint8 * s, int n)
INLINE void gdi_copy_mem(uint8 * d, uint8 * s, int n)
{
memmove(d, s, n);
}
inline void gdi_copy_mem_backwards(uint8 * d, uint8 * s, int n)
INLINE void gdi_copy_mem_backwards(uint8 * d, uint8 * s, int n)
{
d = (d + n) - 1;
s = (s + n) - 1;
@ -336,7 +337,7 @@ inline void gdi_copy_mem_backwards(uint8 * d, uint8 * s, int n)
}
}
inline uint8* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, int x, int y)
INLINE uint8* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, int x, int y)
{
uint8 * p;
HGDI_BITMAP hBmp = (HGDI_BITMAP) hdcBmp->selectedObject;
@ -353,7 +354,7 @@ inline uint8* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, int x, int y)
}
}
inline uint8* gdi_get_brush_pointer(HGDI_DC hdcBrush, int x, int y)
INLINE uint8* gdi_get_brush_pointer(HGDI_DC hdcBrush, int x, int y)
{
uint8 * p;
@ -377,7 +378,7 @@ inline uint8* gdi_get_brush_pointer(HGDI_DC hdcBrush, int x, int y)
return p;
}
inline int gdi_is_mono_pixel_set(uint8* data, int x, int y, int width)
INLINE int gdi_is_mono_pixel_set(uint8* data, int x, int y, int width)
{
int byte;
int shift;
@ -755,12 +756,12 @@ void gdi_cache_brush(rdpUpdate* update, CACHE_BRUSH_ORDER* cache_brush)
void gdi_surface_bits(rdpUpdate* update, SURFACE_BITS_COMMAND* surface_bits_command)
{
GDI* gdi = GET_GDI(update);
RFX_CONTEXT* context = (RFX_CONTEXT*)gdi->rfx_context;
RFX_MESSAGE* message;
STREAM* s;
int i, j;
int tx, ty;
STREAM* s;
RFX_MESSAGE* message;
GDI* gdi = GET_GDI(update);
RFX_CONTEXT* context = (RFX_CONTEXT*) gdi->rfx_context;
DEBUG_GDI("destLeft %d destTop %d destRight %d destBottom %d "
"bpp %d codecID %d width %d height %d length %d",
@ -838,6 +839,32 @@ void gdi_surface_bits(rdpUpdate* update, SURFACE_BITS_COMMAND* surface_bits_comm
stream_detach(s);
stream_free(s);
}
else if (surface_bits_command->codecID == CODEC_ID_NONE)
{
gdi->image->bitmap->width = surface_bits_command->width;
gdi->image->bitmap->height = surface_bits_command->height;
gdi->image->bitmap->bitsPerPixel = surface_bits_command->bpp;
gdi->image->bitmap->bytesPerPixel = gdi->image->bitmap->bitsPerPixel / 8;
gdi->image->bitmap->data = (uint8*) xrealloc(gdi->image->bitmap->data,
gdi->image->bitmap->width * gdi->image->bitmap->height * 4);
if (surface_bits_command->bpp != 32)
{
gdi_image_convert(surface_bits_command->bitmapData, gdi->image->bitmap->data,
gdi->image->bitmap->width, gdi->image->bitmap->height,
gdi->image->bitmap->bitsPerPixel, 32, gdi->clrconv);
surface_bits_command->bpp = 32;
surface_bits_command->bitmapData = gdi->image->bitmap->data;
}
gdi_image_invert(surface_bits_command->bitmapData, gdi->image->bitmap->data,
gdi->image->bitmap->width, gdi->image->bitmap->height, 32);
gdi_BitBlt(gdi->primary->hdc, surface_bits_command->destLeft, surface_bits_command->destTop,
surface_bits_command->width, surface_bits_command->height, gdi->image->hdc, 0, 0, GDI_SRCCOPY);
}
else
{
printf("Unsupported codecID %d\n", surface_bits_command->codecID);
@ -897,7 +924,7 @@ void gdi_register_update_callbacks(rdpUpdate* update)
int gdi_init(freerdp* instance, uint32 flags)
{
GDI *gdi = (GDI*) malloc(sizeof(GDI));
GDI* gdi = (GDI*) malloc(sizeof(GDI));
memset(gdi, 0, sizeof(GDI));
SET_GDI(instance->update, gdi);
@ -963,6 +990,7 @@ int gdi_init(freerdp* instance, uint32 flags)
gdi->primary->hdc->hwnd->ninvalid = 0;
gdi->tile = gdi_bitmap_new(gdi, 64, 64, 32, NULL);
gdi->image = gdi_bitmap_new(gdi, 64, 64, 32, NULL);
gdi_register_update_callbacks(instance->update);

View File

@ -23,6 +23,7 @@
#include <string.h>
#include <stdlib.h>
#include <freerdp/api.h>
#include <freerdp/freerdp.h>
#include <freerdp/gdi/gdi.h>
@ -47,13 +48,13 @@ HGDI_PEN gdi_CreatePen(int fnPenStyle, int nWidth, int crColor)
return hPen;
}
inline uint8 gdi_GetPenColor_8bpp(HGDI_PEN pen)
INLINE uint8 gdi_GetPenColor_8bpp(HGDI_PEN pen)
{
/* TODO: implement conversion using palette */
return 0xFF;
}
inline uint16 gdi_GetPenColor_16bpp(HGDI_PEN pen)
INLINE uint16 gdi_GetPenColor_16bpp(HGDI_PEN pen)
{
uint16 p;
int r, g, b;
@ -63,7 +64,7 @@ inline uint16 gdi_GetPenColor_16bpp(HGDI_PEN pen)
return p;
}
inline uint32 gdi_GetPenColor_32bpp(HGDI_PEN pen)
INLINE uint32 gdi_GetPenColor_32bpp(HGDI_PEN pen)
{
return pen->color;
}

View File

@ -21,6 +21,7 @@
#include <string.h>
#include <stdlib.h>
#include <freerdp/api.h>
#include <freerdp/freerdp.h>
#include <freerdp/gdi/gdi.h>
@ -74,7 +75,7 @@ HGDI_RECT gdi_CreateRect(int xLeft, int yTop, int xRight, int yBottom)
* @param rgn destination region
*/
inline void gdi_RectToRgn(HGDI_RECT rect, HGDI_RGN rgn)
INLINE void gdi_RectToRgn(HGDI_RECT rect, HGDI_RGN rgn)
{
rgn->x = rect->left;
rgn->y = rect->top;
@ -91,7 +92,7 @@ inline void gdi_RectToRgn(HGDI_RECT rect, HGDI_RGN rgn)
* @param rgn destination region
*/
inline void gdi_CRectToRgn(int left, int top, int right, int bottom, HGDI_RGN rgn)
INLINE void gdi_CRectToRgn(int left, int top, int right, int bottom, HGDI_RGN rgn)
{
rgn->x = left;
rgn->y = top;
@ -108,7 +109,7 @@ inline void gdi_CRectToRgn(int left, int top, int right, int bottom, HGDI_RGN rg
* @param h height
*/
inline void gdi_RectToCRgn(HGDI_RECT rect, int *x, int *y, int *w, int *h)
INLINE void gdi_RectToCRgn(HGDI_RECT rect, int *x, int *y, int *w, int *h)
{
*x = rect->left;
*y = rect->top;
@ -128,7 +129,7 @@ inline void gdi_RectToCRgn(HGDI_RECT rect, int *x, int *y, int *w, int *h)
* @param h height
*/
inline void gdi_CRectToCRgn(int left, int top, int right, int bottom, int *x, int *y, int *w, int *h)
INLINE void gdi_CRectToCRgn(int left, int top, int right, int bottom, int *x, int *y, int *w, int *h)
{
*x = left;
*y = top;
@ -142,7 +143,7 @@ inline void gdi_CRectToCRgn(int left, int top, int right, int bottom, int *x, in
* @param rect destination rectangle
*/
inline void gdi_RgnToRect(HGDI_RGN rgn, HGDI_RECT rect)
INLINE void gdi_RgnToRect(HGDI_RGN rgn, HGDI_RECT rect)
{
rect->left = rgn->x;
rect->top = rgn->y;
@ -159,7 +160,7 @@ inline void gdi_RgnToRect(HGDI_RGN rgn, HGDI_RECT rect)
* @param rect destination rectangle
*/
inline void gdi_CRgnToRect(int x, int y, int w, int h, HGDI_RECT rect)
INLINE void gdi_CRgnToRect(int x, int y, int w, int h, HGDI_RECT rect)
{
rect->left = x;
rect->top = y;
@ -176,7 +177,7 @@ inline void gdi_CRgnToRect(int x, int y, int w, int h, HGDI_RECT rect)
* @param bottom y2
*/
inline void gdi_RgnToCRect(HGDI_RGN rgn, int *left, int *top, int *right, int *bottom)
INLINE void gdi_RgnToCRect(HGDI_RGN rgn, int *left, int *top, int *right, int *bottom)
{
*left = rgn->x;
*top = rgn->y;
@ -196,7 +197,7 @@ inline void gdi_RgnToCRect(HGDI_RGN rgn, int *left, int *top, int *right, int *b
* @param bottom y2
*/
inline void gdi_CRgnToCRect(int x, int y, int w, int h, int *left, int *top, int *right, int *bottom)
INLINE void gdi_CRgnToCRect(int x, int y, int w, int h, int *left, int *top, int *right, int *bottom)
{
*left = x;
*top = y;
@ -215,7 +216,7 @@ inline void gdi_CRgnToCRect(int x, int y, int w, int h, int *left, int *top, int
* @return 1 if there is an overlap, 0 otherwise
*/
inline int gdi_CopyOverlap(int x, int y, int width, int height, int srcx, int srcy)
INLINE int gdi_CopyOverlap(int x, int y, int width, int height, int srcx, int srcy)
{
GDI_RECT dst;
GDI_RECT src;
@ -238,7 +239,7 @@ inline int gdi_CopyOverlap(int x, int y, int width, int height, int srcx, int sr
* @return 1 if successful, 0 otherwise
*/
inline int gdi_SetRect(HGDI_RECT rc, int xLeft, int yTop, int xRight, int yBottom)
INLINE int gdi_SetRect(HGDI_RECT rc, int xLeft, int yTop, int xRight, int yBottom)
{
rc->left = xLeft;
rc->top = yTop;
@ -257,7 +258,7 @@ inline int gdi_SetRect(HGDI_RECT rc, int xLeft, int yTop, int xRight, int yBotto
* @return
*/
inline int gdi_SetRgn(HGDI_RGN hRgn, int nXLeft, int nYLeft, int nWidth, int nHeight)
INLINE int gdi_SetRgn(HGDI_RGN hRgn, int nXLeft, int nYLeft, int nWidth, int nHeight)
{
hRgn->x = nXLeft;
hRgn->y = nYLeft;
@ -277,7 +278,7 @@ inline int gdi_SetRgn(HGDI_RGN hRgn, int nXLeft, int nYLeft, int nWidth, int nHe
* @return
*/
inline int gdi_SetRectRgn(HGDI_RGN hRgn, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect)
INLINE int gdi_SetRectRgn(HGDI_RGN hRgn, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect)
{
gdi_CRectToRgn(nLeftRect, nTopRect, nRightRect, nBottomRect, hRgn);
hRgn->null = 0;
@ -302,7 +303,7 @@ inline int gdi_SetRectRgn(HGDI_RGN hRgn, int nLeftRect, int nTopRect, int nRight
* @return 1 if both regions are equal, 0 otherwise
*/
inline int gdi_EqualRgn(HGDI_RGN hSrcRgn1, HGDI_RGN hSrcRgn2)
INLINE int gdi_EqualRgn(HGDI_RGN hSrcRgn1, HGDI_RGN hSrcRgn2)
{
if ((hSrcRgn1->x == hSrcRgn2->x) &&
(hSrcRgn1->y == hSrcRgn2->y) &&
@ -322,7 +323,7 @@ inline int gdi_EqualRgn(HGDI_RGN hSrcRgn1, HGDI_RGN hSrcRgn2)
* @return 1 if successful, 0 otherwise
*/
inline int gdi_CopyRect(HGDI_RECT dst, HGDI_RECT src)
INLINE int gdi_CopyRect(HGDI_RECT dst, HGDI_RECT src)
{
dst->left = src->left;
dst->top = src->top;
@ -340,7 +341,7 @@ inline int gdi_CopyRect(HGDI_RECT dst, HGDI_RECT src)
* @return 1 if the point is inside, 0 otherwise
*/
inline int gdi_PtInRect(HGDI_RECT rc, int x, int y)
INLINE int gdi_PtInRect(HGDI_RECT rc, int x, int y)
{
/*
* points on the left and top sides are considered in,
@ -369,7 +370,7 @@ inline int gdi_PtInRect(HGDI_RECT rc, int x, int y)
* @return
*/
inline int gdi_InvalidateRegion(HGDI_DC hdc, int x, int y, int w, int h)
INLINE int gdi_InvalidateRegion(HGDI_DC hdc, int x, int y, int w, int h)
{
GDI_RECT inv;
GDI_RECT rgn;

View File

@ -29,7 +29,7 @@ set(FREERDP_KBD_SRCS
add_library(freerdp-kbd SHARED ${FREERDP_KBD_SRCS})
find_package(XKBFile)
find_suggested_package(XKBFile)
if(XKBFILE_FOUND)
add_definitions(-DWITH_XKBFILE)
include_directories(${XKBFILE_INCLUDE_DIRS})

View File

@ -71,7 +71,7 @@ static void rail_WindowIcon(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo, WIN
else
window->smallIcon = icon;
IFCALL(rail->SetWindowIcon, rail, window, icon);
IFCALL(rail->rail_SetWindowIcon, rail, window, icon);
}
static void rail_WindowCachedIcon(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo, WINDOW_CACHED_ICON_ORDER* window_cached_icon)

View File

@ -281,15 +281,15 @@ void rail_CreateWindow(rdpRail* rail, rdpWindow* window)
memcpy(window->title, "RAIL", sizeof("RAIL"));
}
IFCALL(rail->CreateWindow, rail, window);
IFCALL(rail->rail_CreateWindow, rail, window);
if (window->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS)
{
IFCALL(rail->SetWindowRects, rail, window);
IFCALL(rail->rail_SetWindowRects, rail, window);
}
if (window->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY)
{
IFCALL(rail->SetWindowVisibilityRects, rail, window);
IFCALL(rail->rail_SetWindowVisibilityRects, rail, window);
}
}
@ -307,7 +307,7 @@ void rail_UpdateWindow(rdpRail* rail, rdpWindow* window)
if (window->fieldFlags & WINDOW_ORDER_FIELD_SHOW)
{
IFCALL(rail->ShowWindow, rail, window, window->showState);
IFCALL(rail->rail_ShowWindow, rail, window, window->showState);
}
if (window->fieldFlags & WINDOW_ORDER_FIELD_TITLE)
@ -317,7 +317,7 @@ void rail_UpdateWindow(rdpRail* rail, rdpWindow* window)
window->title = freerdp_uniconv_in(rail->uniconv, window->titleInfo.string, window->titleInfo.length);
IFCALL(rail->SetWindowText, rail, window);
IFCALL(rail->rail_SetWindowText, rail, window);
}
if (window->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET)
@ -343,7 +343,7 @@ void rail_UpdateWindow(rdpRail* rail, rdpWindow* window)
if ((window->fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) ||
(window->fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE))
{
IFCALL(rail->MoveWindow, rail, window);
IFCALL(rail->rail_MoveWindow, rail, window);
}
if (window->fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA)
@ -353,7 +353,7 @@ void rail_UpdateWindow(rdpRail* rail, rdpWindow* window)
if (window->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS)
{
IFCALL(rail->SetWindowRects, rail, window);
IFCALL(rail->rail_SetWindowRects, rail, window);
}
if (window->fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET)
@ -363,13 +363,13 @@ void rail_UpdateWindow(rdpRail* rail, rdpWindow* window)
if (window->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY)
{
IFCALL(rail->SetWindowVisibilityRects, rail, window);
IFCALL(rail->rail_SetWindowVisibilityRects, rail, window);
}
}
void rail_DestroyWindow(rdpRail* rail, rdpWindow* window)
{
IFCALL(rail->DestroyWindow, rail, window);
IFCALL(rail->rail_DestroyWindow, rail, window);
if (window != NULL)
{

View File

@ -18,7 +18,7 @@
# limitations under the License.
set(CMAKE_THREAD_PREFER_PTHREAD)
find_package(Threads REQUIRED)
find_required_package(Threads)
set(FREERDP_UTILS_SRCS
args.c

View File

@ -36,19 +36,20 @@ void certstore_create(rdpCertstore* certstore)
printf("certstore_create: error opening [%s] for writing\n", certstore->file);
return;
}
fflush(certstore->fp);
}
void certstore_load(rdpCertstore* certstore)
{
certstore->fp = fopen((char*)certstore->file, "r+");
certstore->fp = fopen((char*) certstore->file, "r+");
}
void certstore_open(rdpCertstore* certstore)
{
struct stat stat_info;
if (stat((char*)certstore->file, &stat_info) != 0)
if (stat((char*) certstore->file, &stat_info) != 0)
certstore_create(certstore);
else
certstore_load(certstore);
@ -62,14 +63,23 @@ void certstore_close(rdpCertstore* certstore)
char* get_local_certloc()
{
char *home_path;
char *certloc;
char* home_path;
char* certloc;
struct stat stat_info;
home_path=getenv("HOME");
certloc=(char*)xmalloc(strlen(home_path)+strlen("/.")+strlen(cert_dir)+strlen("/")+strlen(cert_loc)+1);
home_path = getenv("HOME");
certloc = (char*) xmalloc(strlen(home_path) + strlen("/.") + strlen(cert_dir) + strlen("/") + strlen(cert_loc) + 1);
sprintf(certloc,"%s/.%s/%s",home_path,cert_dir,cert_loc);
if(stat((char*)certloc, &stat_info) != 0)
if(stat((char*) certloc, &stat_info) != 0)
{
#ifndef _WIN32
mkdir(certloc, S_IRUSR | S_IWUSR | S_IXUSR);
#else
CreateDirectory(certloc, 0);
#endif
}
return certloc;
}
@ -115,14 +125,18 @@ void certstore_init(rdpCertstore* certstore)
rdpCertdata* certdata_new(char* host_name,char* fingerprint)
{
rdpCertdata* certdata=(rdpCertdata*)xzalloc(sizeof(rdpCertdata));
if(certdata !=NULL)
rdpCertdata* certdata;
certdata = (rdpCertdata*) xzalloc(sizeof(rdpCertdata));
if (certdata !=NULL)
{
certdata->hostname=xzalloc(strlen(host_name)+1);
certdata->thumbprint=xzalloc(strlen(fingerprint)+1);
sprintf(certdata->hostname,"%s",host_name);
sprintf(certdata->thumbprint,"%s",fingerprint);
certdata->hostname = xzalloc(strlen(host_name) + 1);
certdata->thumbprint = xzalloc(strlen(fingerprint) + 1);
sprintf(certdata->hostname, "%s", host_name);
sprintf(certdata->thumbprint, "%s", fingerprint);
}
return certdata;
}
@ -138,7 +152,9 @@ void certdata_free(rdpCertdata* certdata)
rdpCertstore* certstore_new(rdpCertdata* certdata)
{
rdpCertstore* certstore = (rdpCertstore*) xzalloc(sizeof(rdpCertstore));
rdpCertstore* certstore;
certstore = (rdpCertstore*) xzalloc(sizeof(rdpCertstore));
if (certstore != NULL)
{
@ -164,48 +180,57 @@ void certstore_free(rdpCertstore* certstore)
int match_certdata(rdpCertstore* certstore)
{
char *host;
char *p;
char *thumb_print;
FILE* fp;
int length;
unsigned char c;
FILE* cfp;
cfp=certstore->fp;
rdpCertdata* cert_data=certstore->certdata;
length=strlen(cert_data->thumbprint);
host=xzalloc(strlen(cert_data->hostname)+1);
for(;;)
char* data;
char* pline;
long int size;
rdpCertdata* cert_data;
fp = certstore->fp;
cert_data = certstore->certdata;
fseek(fp, 0, SEEK_END);
size = ftell(fp);
fseek(fp, 0, SEEK_SET);
data = (char*) xmalloc(size + 1);
length = fread(data, size, 1, fp);
if (size < 1)
return certstore->match;
data[size] = '\n';
pline = strtok(data, "\n");
while (pline != NULL)
{
if((int)fread(host,sizeof(char),strlen(cert_data->hostname),cfp) < strlen(cert_data->hostname))
break;
if((!strcmp(host,cert_data->hostname)) && ((c=fgetc(cfp))==' ' || c=='\t') )
length = strlen(pline);
if (length > 0)
{
ungetc(c,cfp);
while((c=fgetc(cfp))==' ' || c=='\t');
if(c==EOF)
break;
ungetc(c,cfp);
thumb_print=xzalloc(length+1);
p=thumb_print;
while((p-thumb_print) < length && (*p=fgetc(cfp))!=EOF && *p!='\n' && *p==*(cert_data->thumbprint+(p-thumb_print)))
p++;
if(p-thumb_print==length)
certstore->match=0;
else
certstore->match=-1;
break;
}
else
{
while(c!='\n' && c!=EOF)
c=fgetc(cfp);
if(c==EOF)
length = strcspn(pline, " \t");
pline[length] = '\0';
if (strcmp(pline, cert_data->hostname) == 0)
{
pline = &pline[length + 1];
if (strcmp(pline, cert_data->thumbprint) == 0)
certstore->match = 0;
else
certstore->match = -1;
break;
}
}
pline = strtok(NULL, "\n");
}
xfree(host);
xfree(data);
return certstore->match;
}
void print_certdata(rdpCertstore* certstore)
{
fseek(certstore->fp,0,SEEK_END);

View File

@ -28,6 +28,11 @@
#include <windows.h>
#endif
void freerdp_sleep(uint32 seconds)
{
sleep(seconds);
}
void freerdp_usleep(uint32 useconds)
{
#ifndef _WIN32

View File

@ -65,6 +65,6 @@ void stopwatch_get_elapsed_time_in_useconds(STOPWATCH* stopwatch, uint32* sec, u
*sec = ((uint32) stopwatch->elapsed) / CLOCKS_PER_SEC;
uelapsed = stopwatch->elapsed - ((double)(*sec) * CLOCKS_PER_SEC);
*usec = (uelapsed / (CLOCKS_PER_SEC / 1000000));
*usec = (uint32)(uelapsed / (CLOCKS_PER_SEC / 1000000));
}

View File

@ -25,6 +25,7 @@
#include <pthread.h>
#include <signal.h>
#include <freerdp/constants.h>
#include <freerdp/utils/sleep.h>
#include <freerdp/utils/memory.h>
#include <freerdp/utils/thread.h>
#include <freerdp/rfx/rfx.h>
@ -239,6 +240,8 @@ static void test_peer_draw_icon(freerdp_peer* client, int x, int y)
void test_peer_dump_rfx(freerdp_peer* client)
{
STREAM* s;
uint32 seconds;
uint32 useconds;
rdpUpdate* update;
rdpPcap* pcap_rfx;
pcap_record record;
@ -248,6 +251,8 @@ void test_peer_dump_rfx(freerdp_peer* client)
client->update->pcap_rfx = pcap_open(test_pcap_file, False);
pcap_rfx = client->update->pcap_rfx;
seconds = useconds = 0;
while (pcap_has_next_record(pcap_rfx))
{
pcap_get_next_record_header(pcap_rfx, &record);
@ -259,6 +264,15 @@ void test_peer_dump_rfx(freerdp_peer* client)
pcap_get_next_record_content(pcap_rfx, &record);
s->p = s->data + s->size;
seconds = record.header.ts_sec - seconds;
useconds = record.header.ts_usec - useconds;
if (seconds > 0)
freerdp_sleep(seconds);
if (useconds > 0)
freerdp_usleep(useconds);
update->SurfaceCommand(update, s);
}
}