diff --git a/cunit/CMakeLists.txt b/cunit/CMakeLists.txt index 88b44d005..f82818026 100644 --- a/cunit/CMakeLists.txt +++ b/cunit/CMakeLists.txt @@ -49,8 +49,6 @@ add_executable(test_freerdp test_stream.h test_utils.c test_utils.h - test_transport.c - test_transport.h test_chanman.c test_chanman.h test_cliprdr.c diff --git a/cunit/test_chanman.c b/cunit/test_chanman.c index 8e7ee3565..cdb13e493 100644 --- a/cunit/test_chanman.c +++ b/cunit/test_chanman.c @@ -51,6 +51,7 @@ int add_chanman_suite(void) 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_chanman(void) diff --git a/cunit/test_cliprdr.c b/cunit/test_cliprdr.c index a8d0a0982..7b0500ab5 100644 --- a/cunit/test_cliprdr.c +++ b/cunit/test_cliprdr.c @@ -90,6 +90,7 @@ static int test_rdp_channel_data(freerdp* instance, int chan_id, uint8* data, in { printf("chan_id %d data_size %d\n", chan_id, data_size); freerdp_hexdump(data, data_size); + return 0; } static int event_processed; diff --git a/cunit/test_drdynvc.c b/cunit/test_drdynvc.c index 3a1af3368..12f7f89f1 100644 --- a/cunit/test_drdynvc.c +++ b/cunit/test_drdynvc.c @@ -62,6 +62,7 @@ static int test_rdp_channel_data(freerdp* instance, int chan_id, uint8* data, in printf("chan_id %d data_size %d\n", chan_id, data_size); freerdp_hexdump(data, data_size); data_received = 1; + return 0; } void test_drdynvc(void) diff --git a/cunit/test_freerdp.c b/cunit/test_freerdp.c index 016977dc2..85db80ffe 100644 --- a/cunit/test_freerdp.c +++ b/cunit/test_freerdp.c @@ -31,7 +31,6 @@ #include "test_utils.h" #include "test_orders.h" #include "test_license.h" -#include "test_transport.h" #include "test_chanman.h" #include "test_cliprdr.h" #include "test_drdynvc.h" @@ -163,10 +162,6 @@ int main(int argc, char* argv[]) { add_utils_suite(); } - else if (strcmp("transport", argv[*pindex]) == 0) - { - add_transport_suite(); - } else if (strcmp("chanman", argv[*pindex]) == 0) { add_chanman_suite(); diff --git a/cunit/test_transport.c b/cunit/test_transport.c deleted file mode 100644 index 102ad87a2..000000000 --- a/cunit/test_transport.c +++ /dev/null @@ -1,103 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Transport 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 "tpkt.h" -#include "transport.h" -#include "test_transport.h" - -static const char test_server[] = "192.168.1.200"; - -static const uint8 test_x224_req[] = -{ - "\x03\x00\x00\x2C\x27\xE0\x00\x00\x00\x00\x00\x43\x6F\x6F\x6B\x69" - "\x65\x3A\x20\x6D\x73\x74\x73\x68\x61\x73\x68\x3D\x65\x6C\x74\x6F" - "\x6e\x73\x0D\x0A\x01\x00\x08\x00\x00\x00\x00\x00" -}; - -int init_transport_suite(void) -{ - return 0; -} - -int clean_transport_suite(void) -{ - return 0; -} - -int add_transport_suite(void) -{ - add_test_suite(transport); - - add_test_function(transport); - - return 0; -} - -#if 0 -static int test_finished = 0; - -static int -packet_received(rdpTransport * transport, STREAM * stream, void * extra) -{ - uint16 length; - length = tpkt_read_header(stream); - CU_ASSERT(length == 19); - freerdp_hexdump(stream->data, length); - test_finished = 1; - return 0; -} -#endif - -void test_transport(void) -{ -#if 0 - rdpTransport * transport; - STREAM * stream; - int r; - - transport = transport_new((rdpSettings*) NULL); - transport->recv_callback = packet_received; - - r = transport_connect(transport, test_server, 3389); - CU_ASSERT(r == True); - - stream = stream_new(sizeof(test_x224_req)); - stream_write(stream, test_x224_req, sizeof(test_x224_req)); - r = transport_send(transport, stream); - CU_ASSERT(r == 0); - - while (!test_finished) - { - transport_check_fds(transport); - sleep(1); - } - - r = transport_disconnect(transport); - CU_ASSERT(r == True); - - transport_free(transport); -#endif -} diff --git a/cunit/test_transport.h b/cunit/test_transport.h deleted file mode 100644 index 5c5488e0c..000000000 --- a/cunit/test_transport.h +++ /dev/null @@ -1,26 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Transport 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_transport_suite(void); -int clean_transport_suite(void); -int add_transport_suite(void); - -void test_transport(void); diff --git a/libfreerdp-core/bitmap.c b/libfreerdp-core/bitmap.c index d22a4fa74..f2cf16934 100644 --- a/libfreerdp-core/bitmap.c +++ b/libfreerdp-core/bitmap.c @@ -26,135 +26,6 @@ http://msdn.microsoft.com/en-us/library/dd240593%28v=prot.10%29.aspx */ -/* - Bitmasks -*/ -static uint8 g_MaskBit0 = 0x01; /* Least significant bit */ -static uint8 g_MaskBit1 = 0x02; -static uint8 g_MaskBit2 = 0x04; -static uint8 g_MaskBit3 = 0x08; -static uint8 g_MaskBit4 = 0x10; -static uint8 g_MaskBit5 = 0x20; -static uint8 g_MaskBit6 = 0x40; -static uint8 g_MaskBit7 = 0x80; /* Most significant bit */ - -static uint8 g_MaskRegularRunLength = 0x1F; -static uint8 g_MaskLiteRunLength = 0x0F; - -static uint8 g_MaskSpecialFgBg1 = 0x03; -static uint8 g_MaskSpecialFgBg2 = 0x05; - -/** - * Reads the supplied order header and extracts the compression - * order code ID. - */ -static uint32 ExtractCodeId(uint8 bOrderHdr) -{ - int code; - - switch (bOrderHdr) - { - case MEGA_MEGA_BG_RUN: - case MEGA_MEGA_FG_RUN: - case MEGA_MEGA_SET_FG_RUN: - case MEGA_MEGA_DITHERED_RUN: - case MEGA_MEGA_COLOR_RUN: - case MEGA_MEGA_FGBG_IMAGE: - case MEGA_MEGA_SET_FGBG_IMAGE: - case MEGA_MEGA_COLOR_IMAGE: - case SPECIAL_FGBG_1: - case SPECIAL_FGBG_2: - case SPECIAL_WHITE: - case SPECIAL_BLACK: - return bOrderHdr; - } - code = bOrderHdr >> 5; - switch (code) - { - case REGULAR_BG_RUN: - case REGULAR_FG_RUN: - case REGULAR_COLOR_RUN: - case REGULAR_FGBG_IMAGE: - case REGULAR_COLOR_IMAGE: - return code; - } - return bOrderHdr >> 4; -} - -/** - * Extract the run length of a compression order. - */ -static uint32 ExtractRunLength(uint32 code, uint8* pbOrderHdr, uint32* advance) -{ - uint32 runLength; - uint32 ladvance; - - ladvance = 1; - runLength = 0; - switch (code) - { - case REGULAR_FGBG_IMAGE: - runLength = (*pbOrderHdr) & g_MaskRegularRunLength; - if (runLength == 0) - { - runLength = (*(pbOrderHdr + 1)) + 1; - ladvance += 1; - } - else - { - runLength = runLength * 8; - } - break; - case LITE_SET_FG_FGBG_IMAGE: - runLength = (*pbOrderHdr) & g_MaskLiteRunLength; - if (runLength == 0) - { - runLength = (*(pbOrderHdr + 1)) + 1; - ladvance += 1; - } - else - { - runLength = runLength * 8; - } - break; - case REGULAR_BG_RUN: - case REGULAR_FG_RUN: - case REGULAR_COLOR_RUN: - case REGULAR_COLOR_IMAGE: - runLength = (*pbOrderHdr) & g_MaskRegularRunLength; - if (runLength == 0) - { - /* An extended (MEGA) run. */ - runLength = (*(pbOrderHdr + 1)) + 32; - ladvance += 1; - } - break; - case LITE_SET_FG_FG_RUN: - case LITE_DITHERED_RUN: - runLength = (*pbOrderHdr) & g_MaskLiteRunLength; - if (runLength == 0) - { - /* An extended (MEGA) run. */ - runLength = (*(pbOrderHdr + 1)) + 16; - ladvance += 1; - } - break; - case MEGA_MEGA_BG_RUN: - case MEGA_MEGA_FG_RUN: - case MEGA_MEGA_SET_FG_RUN: - case MEGA_MEGA_DITHERED_RUN: - case MEGA_MEGA_COLOR_RUN: - case MEGA_MEGA_FGBG_IMAGE: - case MEGA_MEGA_SET_FGBG_IMAGE: - case MEGA_MEGA_COLOR_IMAGE: - runLength = ((uint16) pbOrderHdr[1]) | ((uint16) (pbOrderHdr[2] << 8)); - ladvance += 2; - break; - } - *advance = ladvance; - return runLength; -} - #define UNROLL_COUNT 4 #define UNROLL(_exp) do { _exp _exp _exp _exp } while (0) diff --git a/libfreerdp-core/bitmap_inc.c b/libfreerdp-core/bitmap_inc.c index f1d84bf45..50ab6234c 100644 --- a/libfreerdp-core/bitmap_inc.c +++ b/libfreerdp-core/bitmap_inc.c @@ -19,6 +19,137 @@ /* do not compile the file directly */ +#ifndef __BITMAP_TEMPLATE +#define __BITMAP_TEMPLATE + +static uint8 g_MaskBit0 = 0x01; /* Least significant bit */ +static uint8 g_MaskBit1 = 0x02; +static uint8 g_MaskBit2 = 0x04; +static uint8 g_MaskBit3 = 0x08; +static uint8 g_MaskBit4 = 0x10; +static uint8 g_MaskBit5 = 0x20; +static uint8 g_MaskBit6 = 0x40; +static uint8 g_MaskBit7 = 0x80; /* Most significant bit */ + +static uint8 g_MaskSpecialFgBg1 = 0x03; +static uint8 g_MaskSpecialFgBg2 = 0x05; + +static uint8 g_MaskRegularRunLength = 0x1F; +static uint8 g_MaskLiteRunLength = 0x0F; + +/** + * Reads the supplied order header and extracts the compression + * order code ID. + */ +static uint32 ExtractCodeId(uint8 bOrderHdr) +{ + int code; + + switch (bOrderHdr) + { + case MEGA_MEGA_BG_RUN: + case MEGA_MEGA_FG_RUN: + case MEGA_MEGA_SET_FG_RUN: + case MEGA_MEGA_DITHERED_RUN: + case MEGA_MEGA_COLOR_RUN: + case MEGA_MEGA_FGBG_IMAGE: + case MEGA_MEGA_SET_FGBG_IMAGE: + case MEGA_MEGA_COLOR_IMAGE: + case SPECIAL_FGBG_1: + case SPECIAL_FGBG_2: + case SPECIAL_WHITE: + case SPECIAL_BLACK: + return bOrderHdr; + } + code = bOrderHdr >> 5; + switch (code) + { + case REGULAR_BG_RUN: + case REGULAR_FG_RUN: + case REGULAR_COLOR_RUN: + case REGULAR_FGBG_IMAGE: + case REGULAR_COLOR_IMAGE: + return code; + } + return bOrderHdr >> 4; +} + +/** + * Extract the run length of a compression order. + */ +static uint32 ExtractRunLength(uint32 code, uint8* pbOrderHdr, uint32* advance) +{ + uint32 runLength; + uint32 ladvance; + + ladvance = 1; + runLength = 0; + switch (code) + { + case REGULAR_FGBG_IMAGE: + runLength = (*pbOrderHdr) & g_MaskRegularRunLength; + if (runLength == 0) + { + runLength = (*(pbOrderHdr + 1)) + 1; + ladvance += 1; + } + else + { + runLength = runLength * 8; + } + break; + case LITE_SET_FG_FGBG_IMAGE: + runLength = (*pbOrderHdr) & g_MaskLiteRunLength; + if (runLength == 0) + { + runLength = (*(pbOrderHdr + 1)) + 1; + ladvance += 1; + } + else + { + runLength = runLength * 8; + } + break; + case REGULAR_BG_RUN: + case REGULAR_FG_RUN: + case REGULAR_COLOR_RUN: + case REGULAR_COLOR_IMAGE: + runLength = (*pbOrderHdr) & g_MaskRegularRunLength; + if (runLength == 0) + { + /* An extended (MEGA) run. */ + runLength = (*(pbOrderHdr + 1)) + 32; + ladvance += 1; + } + break; + case LITE_SET_FG_FG_RUN: + case LITE_DITHERED_RUN: + runLength = (*pbOrderHdr) & g_MaskLiteRunLength; + if (runLength == 0) + { + /* An extended (MEGA) run. */ + runLength = (*(pbOrderHdr + 1)) + 16; + ladvance += 1; + } + break; + case MEGA_MEGA_BG_RUN: + case MEGA_MEGA_FG_RUN: + case MEGA_MEGA_SET_FG_RUN: + case MEGA_MEGA_DITHERED_RUN: + case MEGA_MEGA_COLOR_RUN: + case MEGA_MEGA_FGBG_IMAGE: + case MEGA_MEGA_SET_FGBG_IMAGE: + case MEGA_MEGA_COLOR_IMAGE: + runLength = ((uint16) pbOrderHdr[1]) | ((uint16) (pbOrderHdr[2] << 8)); + ladvance += 2; + break; + } + *advance = ladvance; + return runLength; +} + +#endif + /** * Write a foreground/background image to a destination buffer. */ diff --git a/libfreerdp-core/tls.c b/libfreerdp-core/tls.c index 9f6fb3f4d..016596ae2 100644 --- a/libfreerdp-core/tls.c +++ b/libfreerdp-core/tls.c @@ -114,6 +114,7 @@ int tls_write(rdpTls* tls, uint8* data, int length) default: tls_print_error("SSL_write", tls->ssl, status); status = -1; + break; } return status;