Merge branch 'master' of github.com:FreeRDP/FreeRDP

This commit is contained in:
Marc-André Moreau 2012-02-29 02:26:36 -05:00
commit d161d26d7c
27 changed files with 165 additions and 91 deletions

View File

@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <tchar.h>
#include <sys/types.h>
#ifdef _MSC_VER
@ -178,7 +179,7 @@ boolean wf_pre_connect(freerdp* instance)
wfi->clrconv = (HCLRCONV) xzalloc(sizeof(CLRCONV));
wfi->clrconv->palette = NULL;
wfi->clrconv->alpha = 0;
wfi->clrconv->alpha = false;
instance->context->cache = cache_new(settings);
@ -318,9 +319,9 @@ boolean wf_post_connect(freerdp* instance)
if (settings->window_title != NULL)
_snwprintf(win_title, sizeof(win_title), L"%S", settings->window_title);
else if (settings->port == 3389)
_snwprintf(win_title, sizeof(win_title) / sizeof(win_title[0]), L"FreeRDP: %S", settings->hostname);
_snwprintf(win_title, ARRAY_SIZE(win_title), L"FreeRDP: %S", settings->hostname);
else
_snwprintf(win_title, sizeof(win_title) / sizeof(win_title[0]), L"FreeRDP: %S:%d", settings->hostname, settings->port);
_snwprintf(win_title, ARRAY_SIZE(win_title), L"FreeRDP: %S:%d", settings->hostname, settings->port);
if (wfi->hwnd == 0)
{
@ -385,6 +386,32 @@ boolean wf_post_connect(freerdp* instance)
boolean wf_verify_certificate(freerdp* instance, char* subject, char* issuer, char* fingerprint)
{
#if 0
DWORD mode;
int read_size;
DWORD read_count;
TCHAR answer[2];
TCHAR* read_buffer;
HANDLE input_handle;
#endif
printf("Certificate details:\n");
printf("\tSubject: %s\n", subject);
printf("\tIssuer: %s\n", issuer);
printf("\tThumbprint: %s\n", fingerprint);
printf("The above X.509 certificate could not be verified, possibly because you do not have "
"the CA certificate in your certificate store, or the certificate has expired. "
"Please look at the documentation on how to create local certificate store for a private CA.\n");
/* TODO: ask for user validation */
#if 0
input_handle = GetStdHandle(STD_INPUT_HANDLE);
GetConsoleMode(input_handle, &mode);
mode |= ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT;
SetConsoleMode(input_handle, mode);
#endif
return true;
}

View File

@ -786,7 +786,7 @@ static void xf_cliprdr_append_target(clipboardContext* cb, Atom target)
{
int i;
if (cb->num_targets >= sizeof(cb->targets) / sizeof(Atom))
if (cb->num_targets >= ARRAY_SIZE(cb->targets))
return;
for (i = 0; i < cb->num_targets; i++)

View File

@ -304,7 +304,7 @@ xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height,
input_mask |= EnterWindowMask | LeaveWindowMask;
XChangeProperty(xfi->display, window->handle, xfi->_NET_WM_ICON, XA_CARDINAL, 32,
PropModeReplace, (uint8*) xf_icon_prop, sizeof(xf_icon_prop) / sizeof(long));
PropModeReplace, (uint8*) xf_icon_prop, ARRAY_SIZE(xf_icon_prop));
XSelectInput(xfi->display, window->handle, input_mask);
XMapWindow(xfi->display, window->handle);

View File

@ -13,13 +13,11 @@ if (PKG_CONFIG_FOUND)
endif ( PKG_CONFIG_FOUND )
# avcodec
find_path(AVCODEC_INCLUDE_DIR avcodec.h PATHS ${AVCODEC_INCLUDE_DIRS}
PATH_SUFFIXES libavcodec )
find_path(AVCODEC_INCLUDE_DIR libavcodec/avcodec.h PATHS ${AVCODEC_INCLUDE_DIRS})
find_library(AVCODEC_LIBRARY avcodec PATHS ${AVCODEC_LIBRARY_DIRS})
# avutil
find_path(AVUTIL_INCLUDE_DIR avutil.h PATHS ${AVUTIL_INCLUDE_DIRS}
PATH_SUFFIXES libavutil )
find_path(AVUTIL_INCLUDE_DIR libavutil/avutil.h PATHS ${AVUTIL_INCLUDE_DIRS})
find_library(AVUTIL_LIBRARY avutil PATHS ${AVUTIL_LIBRARY_DIRS})
if(AVCODEC_INCLUDE_DIR AND AVCODEC_LIBRARY)

View File

@ -380,13 +380,13 @@ static uint8 server_app_get_resp_app_id[] =
#define EMULATE_SERVER_SEND_CHANNEL_DATA(inst, byte_array) \
emulate_server_send_channel_data(inst, byte_array, RAIL_ARRAY_SIZE(byte_array))
emulate_server_send_channel_data(inst, byte_array, ARRAY_SIZE(byte_array))
#define STREAM_EQUAL_TO_DUMP(stream, dump) \
(stream_equal_dump((stream)->data, (stream)->size, dump, RAIL_ARRAY_SIZE(dump)))
(stream_equal_dump((stream)->data, (stream)->size, dump, ARRAY_SIZE(dump)))
#define UNICODE_STRING_EQUAL_TO_DUMP(ustring, dump) \
(stream_equal_dump((ustring)->string, (ustring)->length, dump, RAIL_ARRAY_SIZE(dump)))
(stream_equal_dump((ustring)->string, (ustring)->length, dump, ARRAY_SIZE(dump)))
typedef struct
{
@ -521,7 +521,7 @@ static void emulate_server_send_channel_data(
static void save_dump(void* data, size_t size)
{
thread_param * p = global_thread_params;
if (p->in_streams_number < RAIL_ARRAY_SIZE(p->in_streams))
if (p->in_streams_number < ARRAY_SIZE(p->in_streams))
{
STREAM* s = &p->in_streams[p->in_streams_number];
s->data = malloc(size);
@ -631,7 +631,7 @@ static void process_events_and_channel_data_from_plugin(thread_param* param)
counter);
// add to global event list
if (param->in_events_number < RAIL_ARRAY_SIZE(param->in_events))
if (param->in_events_number < ARRAY_SIZE(param->in_events))
{
save_event(event, &param->in_events[param->in_events_number]);
param->in_events_number++;

View File

@ -245,7 +245,7 @@ void test_rlgr(void)
{
int n;
n = rfx_rlgr_decode(RLGR3, y_data, sizeof(y_data), buffer, sizeof(buffer) / sizeof(unsigned int));
n = rfx_rlgr_decode(RLGR3, y_data, sizeof(y_data), buffer, ARRAY_SIZE(buffer));
//printf("RLGR decode %d bytes to %d values.", sizeof(y_data), n);
//dump_buffer(buffer, n);

View File

@ -36,6 +36,7 @@
#include <freerdp/utils/args.h>
#include <freerdp/utils/passphrase.h>
#include <freerdp/utils/signal.h>
#include <freerdp/utils/memory.h>
#include "test_utils.h"
@ -142,7 +143,7 @@ void test_args(void)
"freerdp", "-a", "16", "-u", "testuser", "-d", "testdomain", "-g", "1280x960", "address2:3390"
};
char** argv = argv_c;
int argc = sizeof(argv_c) / sizeof(char*);
int argc = ARRAY_SIZE(argv_c);
int i;
int c;
rdpSettings* settings;

View File

@ -31,4 +31,6 @@ FREERDP_API char* xstrdup(const char* str);
#define xnew(_type) (_type*)xzalloc(sizeof(_type))
#define ARRAY_SIZE(_x) (sizeof(_x)/sizeof(*(_x)))
#endif /* __MEMORY_UTILS_H */

View File

@ -25,8 +25,6 @@
#include <freerdp/utils/rect.h>
#include <freerdp/utils/stream.h>
#define RAIL_ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
FREERDP_API void rail_unicode_string_alloc(UNICODE_STRING* unicode_string, uint16 cbString);
FREERDP_API void rail_unicode_string_free(UNICODE_STRING* unicode_string);
FREERDP_API void rail_read_unicode_string(STREAM* s, UNICODE_STRING* unicode_string);

View File

@ -273,7 +273,7 @@ SECURITY_FUNCTION_TABLE* sspi_GetSecurityFunctionTableByName(const char* Name)
int index;
uint32 cPackages;
cPackages = sizeof(SEC_PKG_INFO_LIST) / sizeof(SEC_PKG_INFO*);
cPackages = ARRAY_SIZE(SEC_PKG_INFO_LIST);
for (index = 0; index < (int) cPackages; index++)
{
@ -305,7 +305,7 @@ SECURITY_STATUS EnumerateSecurityPackages(uint32* pcPackages, SEC_PKG_INFO** ppP
uint32 cPackages;
SEC_PKG_INFO* pPackageInfo;
cPackages = sizeof(SEC_PKG_INFO_LIST) / sizeof(SEC_PKG_INFO*);
cPackages = ARRAY_SIZE(SEC_PKG_INFO_LIST);
size = sizeof(SEC_PKG_INFO) * cPackages;
pPackageInfo = (SEC_PKG_INFO*) sspi_ContextBufferAlloc(EnumerateSecurityPackagesIndex, size);
@ -332,7 +332,7 @@ void FreeContextBuffer_EnumerateSecurityPackages(void* contextBuffer)
uint32 cPackages;
SEC_PKG_INFO* pPackageInfo = (SEC_PKG_INFO*) contextBuffer;
cPackages = sizeof(SEC_PKG_INFO_LIST) / sizeof(SEC_PKG_INFO*);
cPackages = ARRAY_SIZE(SEC_PKG_INFO_LIST);
for (index = 0; index < (int) cPackages; index++)
{
@ -361,7 +361,7 @@ SECURITY_STATUS QuerySecurityPackageInfo(char* pszPackageName, SEC_PKG_INFO** pp
uint32 cPackages;
SEC_PKG_INFO* pPackageInfo;
cPackages = sizeof(SEC_PKG_INFO_LIST) / sizeof(SEC_PKG_INFO*);
cPackages = ARRAY_SIZE(SEC_PKG_INFO_LIST);
for (index = 0; index < (int) cPackages; index++)
{

View File

@ -437,10 +437,14 @@ static boolean bitmap_decompress4(uint8* srcData, uint8* dstData, int width, int
*/
boolean bitmap_decompress(uint8* srcData, uint8* dstData, int width, int height, int size, int srcBpp, int dstBpp)
{
uint8 * TmpBfr;
if (srcBpp == 16 && dstBpp == 16)
{
RleDecompress16to16(srcData, size, dstData, width * 2, width, height);
freerdp_bitmap_flip(dstData, dstData, width * 2, height);
TmpBfr = (uint8*) xmalloc(width * height * 2);
RleDecompress16to16(srcData, size, TmpBfr, width * 2, width, height);
freerdp_bitmap_flip(TmpBfr, dstData, width * 2, height);
xfree(TmpBfr);
}
else if (srcBpp == 32 && dstBpp == 32)
{
@ -449,18 +453,24 @@ boolean bitmap_decompress(uint8* srcData, uint8* dstData, int width, int height,
}
else if (srcBpp == 15 && dstBpp == 15)
{
RleDecompress16to16(srcData, size, dstData, width * 2, width, height);
freerdp_bitmap_flip(dstData, dstData, width * 2, height);
TmpBfr = (uint8*) xmalloc(width * height * 2);
RleDecompress16to16(srcData, size, TmpBfr, width * 2, width, height);
freerdp_bitmap_flip(TmpBfr, dstData, width * 2, height);
xfree(TmpBfr);
}
else if (srcBpp == 8 && dstBpp == 8)
{
RleDecompress8to8(srcData, size, dstData, width, width, height);
freerdp_bitmap_flip(dstData, dstData, width, height);
TmpBfr = (uint8*) xmalloc(width * height);
RleDecompress8to8(srcData, size, TmpBfr, width, width, height);
freerdp_bitmap_flip(TmpBfr, dstData, width, height);
xfree(TmpBfr);
}
else if (srcBpp == 24 && dstBpp == 24)
{
RleDecompress24to24(srcData, size, dstData, width * 3, width, height);
freerdp_bitmap_flip(dstData, dstData, width * 3, height);
TmpBfr = (uint8*) xmalloc(width * height * 3);
RleDecompress24to24(srcData, size, TmpBfr, width * 3, width, height);
freerdp_bitmap_flip(TmpBfr, dstData, width * 3, height);
xfree(TmpBfr);
}
else
{

View File

@ -744,7 +744,7 @@ void freerdp_bitmap_flip(uint8 * src, uint8 * dst, int scanLineSz, int height)
int half = height / 2;
/* Flip buffer in place by line permutations through the temp
* scan line buffer.
* Not that if height has an odd number of line, we don't need
* Note that if height has an odd number of line, we don't need
* to move the center scanline anyway.
* Also note that in place flipping takes three memcpy() calls
* to process two scanlines while src to distinct dest would

View File

@ -27,9 +27,6 @@
#include <freerdp/utils/file.h>
static const char certificate_store_dir[] = "certs";
static const char certificate_known_hosts_file[] = "known_hosts";
#include "certificate.h"
/**
@ -448,15 +445,16 @@ boolean certificate_read_server_certificate(rdpCertificate* certificate, uint8*
STREAM* s;
uint32 dwVersion;
s = stream_new(0);
stream_attach(s, server_cert, length);
printf("length %d\n", length);
if (length < 1)
{
printf("null server certificate\n");
DEBUG_CERTIFICATE("null server certificate\n");
return false;
}
s = stream_new(0);
stream_attach(s, server_cert, length);
stream_read_uint32(s, dwVersion); /* dwVersion (4 bytes) */
switch (dwVersion & CERT_CHAIN_VERSION_MASK)

View File

@ -68,7 +68,7 @@ static const char* const SECONDARY_DRAWING_ORDER_STRINGS[] =
"Cache Bitmap V3"
};
#define SECONDARY_DRAWING_ORDER_COUNT (sizeof(SECONDARY_DRAWING_ORDER_STRINGS) / sizeof(SECONDARY_DRAWING_ORDER_STRINGS[0]))
#define SECONDARY_DRAWING_ORDER_COUNT (ARRAY_SIZE(SECONDARY_DRAWING_ORDER_STRINGS))
static const char* const ALTSEC_DRAWING_ORDER_STRINGS[] =
{
@ -88,7 +88,7 @@ static const char* const ALTSEC_DRAWING_ORDER_STRINGS[] =
"Frame Marker"
};
#define ALTSEC_DRAWING_ORDER_COUNT (sizeof(ALTSEC_DRAWING_ORDER_STRINGS) / sizeof(ALTSEC_DRAWING_ORDER_STRINGS[0]))
#define ALTSEC_DRAWING_ORDER_COUNT (ARRAY_SIZE(ALTSEC_DRAWING_ORDER_STRINGS))
#endif /* WITH_DEBUG_ORDERS */
@ -121,7 +121,7 @@ static const uint8 PRIMARY_DRAWING_ORDER_FIELD_BYTES[] =
GLYPH_INDEX_ORDER_FIELD_BYTES
};
#define PRIMARY_DRAWING_ORDER_COUNT (sizeof(PRIMARY_DRAWING_ORDER_FIELD_BYTES) / sizeof(PRIMARY_DRAWING_ORDER_FIELD_BYTES[0]))
#define PRIMARY_DRAWING_ORDER_COUNT (ARRAY_SIZE(PRIMARY_DRAWING_ORDER_FIELD_BYTES))
static const uint8 CBR2_BPP[] =
{

View File

@ -24,19 +24,20 @@
#include <freerdp/crypto/per.h>
#ifdef WITH_DEBUG_RDP
static const char* const DATA_PDU_TYPE_STRINGS[] =
{
"", "", /* 0x00 - 0x01 */
"?", "?", /* 0x00 - 0x01 */
"Update", /* 0x02 */
"", "", "", "", "", "", "", "", /* 0x03 - 0x0A */
"", "", "", "", "", "", "", "", "", /* 0x0B - 0x13 */
"?", "?", "?", "?", "?", "?", "?", "?", /* 0x03 - 0x0A */
"?", "?", "?", "?", "?", "?", "?", "?", "?", /* 0x0B - 0x13 */
"Control", /* 0x14 */
"", "", "", "", "", "", /* 0x15 - 0x1A */
"?", "?", "?", "?", "?", "?", /* 0x15 - 0x1A */
"Pointer", /* 0x1B */
"Input", /* 0x1C */
"", "", /* 0x1D - 0x1E */
"?", "?", /* 0x1D - 0x1E */
"Synchronize", /* 0x1F */
"", /* 0x20 */
"?", /* 0x20 */
"Refresh Rect", /* 0x21 */
"Play Sound", /* 0x22 */
"Suppress Output", /* 0x23 */
@ -46,7 +47,7 @@ static const char* const DATA_PDU_TYPE_STRINGS[] =
"Font List", /* 0x27 */
"Font Map", /* 0x28 */
"Set Keyboard Indicators", /* 0x29 */
"", /* 0x2A */
"?", /* 0x2A */
"Bitmap Cache Persistent List", /* 0x2B */
"Bitmap Cache Error", /* 0x2C */
"Set Keyboard IME Status", /* 0x2D */
@ -55,12 +56,13 @@ static const char* const DATA_PDU_TYPE_STRINGS[] =
"Draw Nine Grid Error", /* 0x30 */
"Draw GDI+ Error", /* 0x31 */
"ARC Status", /* 0x32 */
"", "", "", /* 0x33 - 0x35 */
"?", "?", "?", /* 0x33 - 0x35 */
"Status Info", /* 0x36 */
"Monitor Layout" /* 0x37 */
"", "", "", /* 0x38 - 0x40 */
"", "", "", "", "", "" /* 0x41 - 0x46 */
"?", "?", "?", /* 0x38 - 0x40 */
"?", "?", "?", "?", "?", "?" /* 0x41 - 0x46 */
};
#endif
/**
* Read RDP Security Header.\n
@ -484,7 +486,8 @@ boolean rdp_recv_data_pdu(rdpRdp* rdp, STREAM* s)
#ifdef WITH_DEBUG_RDP
if (type != DATA_PDU_TYPE_UPDATE)
printf("recv %s Data PDU (0x%02X), length:%d\n", DATA_PDU_TYPE_STRINGS[type], type, length);
printf("recv %s Data PDU (0x%02X), length:%d\n",
type < ARRAY_SIZE(DATA_PDU_TYPE_STRINGS) ? DATA_PDU_TYPE_STRINGS[type] : "???", type, length);
#endif
switch (type)

View File

@ -30,10 +30,16 @@ boolean per_read_length(STREAM* s, uint16* length)
{
uint8 byte;
if (stream_get_left(s) < 1)
return false;
stream_read_uint8(s, byte);
if (byte & 0x80)
{
if (stream_get_left(s) < 1)
return false;
byte &= ~(0x80);
*length = (byte << 8);
stream_read_uint8(s, byte);
@ -70,6 +76,9 @@ void per_write_length(STREAM* s, int length)
boolean per_read_choice(STREAM* s, uint8* choice)
{
if (stream_get_left(s) < 1)
return false;
stream_read_uint8(s, *choice);
return true;
}
@ -94,6 +103,9 @@ void per_write_choice(STREAM* s, uint8 choice)
boolean per_read_selection(STREAM* s, uint8* selection)
{
if (stream_get_left(s) < 1)
return false;
stream_read_uint8(s, *selection);
return true;
}
@ -118,6 +130,9 @@ void per_write_selection(STREAM* s, uint8 selection)
boolean per_read_number_of_sets(STREAM* s, uint8* number)
{
if (stream_get_left(s) < 1)
return false;
stream_read_uint8(s, *number);
return true;
}
@ -141,8 +156,10 @@ void per_write_number_of_sets(STREAM* s, uint8 number)
boolean per_read_padding(STREAM* s, int length)
{
stream_seek(s, length);
if (stream_get_left(s) < length)
return false;
stream_seek(s, length);
return true;
}
@ -171,7 +188,11 @@ boolean per_read_integer(STREAM* s, uint32* integer)
{
uint16 length;
per_read_length(s, &length);
if (!per_read_length(s, &length))
return false;
if (stream_get_left(s) < length)
return false;
if (length == 1)
stream_read_uint8(s, *integer);
@ -218,6 +239,9 @@ void per_write_integer(STREAM* s, uint32 integer)
boolean per_read_integer16(STREAM* s, uint16* integer, uint16 min)
{
if (stream_get_left(s) < 2)
return false;
stream_read_uint16_be(s, *integer);
if (*integer + min > 0xFFFF)
@ -250,6 +274,9 @@ void per_write_integer16(STREAM* s, uint16 integer, uint16 min)
boolean per_read_enumerated(STREAM* s, uint8* enumerated, uint8 count)
{
if (stream_get_left(s) < 1)
return false;
stream_read_uint8(s, *enumerated);
/* check that enumerated value falls within expected range */
@ -285,12 +312,15 @@ boolean per_read_object_identifier(STREAM* s, uint8 oid[6])
uint16 length;
uint8 a_oid[6];
per_read_length(s, &length); /* length */
if (!per_read_length(s, &length))
return false;
if (length != 5)
return false;
if (stream_get_left(s) < length)
return false;
stream_read_uint8(s, t12); /* first two tuples */
a_oid[0] = (t12 >> 4);
a_oid[1] = (t12 & 0x0F);
@ -359,11 +389,15 @@ boolean per_read_octet_string(STREAM* s, uint8* oct_str, int length, int min)
uint16 mlength;
uint8* a_oct_str;
per_read_length(s, &mlength);
if (!per_read_length(s, &mlength))
return false;
if (mlength + min != length)
return false;
if (stream_get_left(s) < length)
return false;
a_oct_str = s->p;
stream_seek(s, length);
@ -407,19 +441,18 @@ void per_write_octet_string(STREAM* s, uint8* oct_str, int length, int min)
boolean per_read_numeric_string(STREAM* s, int min)
{
int i;
int length;
uint16 mlength;
per_read_length(s, &mlength);
if (!per_read_length(s, &mlength))
return false;
length = mlength + min;
length = (mlength + min + 1) / 2;
for (i = 0; i < length; i += 2)
{
stream_seek(s, 1);
}
if (stream_get_left(s) < length)
return false;
stream_seek(s, length);
return true;
}

View File

@ -404,6 +404,7 @@ boolean tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname)
xfree(fingerprint);
}
#ifndef _WIN32
if (common_name)
xfree(common_name);
@ -414,6 +415,7 @@ boolean tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname)
xfree(alt_names);
}
#endif
if (certificate_data)
{

View File

@ -1001,7 +1001,7 @@ RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(uint32 types)
if ((types & RDP_KEYBOARD_LAYOUT_TYPE_STANDARD) != 0)
{
length = sizeof(RDP_KEYBOARD_LAYOUT_TABLE) / sizeof(RDP_KEYBOARD_LAYOUT);
length = ARRAY_SIZE(RDP_KEYBOARD_LAYOUT_TABLE);
layouts = (RDP_KEYBOARD_LAYOUT*) xrealloc(layouts, (num + length + 1) * sizeof(RDP_KEYBOARD_LAYOUT));
for (i = 0; i < length; i++, num++)
@ -1012,7 +1012,7 @@ RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(uint32 types)
}
if ((types & RDP_KEYBOARD_LAYOUT_TYPE_VARIANT) != 0)
{
length = sizeof(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE) / sizeof(RDP_KEYBOARD_LAYOUT_VARIANT);
length = ARRAY_SIZE(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE);
layouts = (RDP_KEYBOARD_LAYOUT*) xrealloc(layouts, (num + length + 1) * sizeof(RDP_KEYBOARD_LAYOUT));
for (i = 0; i < length; i++, num++)
@ -1023,7 +1023,7 @@ RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(uint32 types)
}
if ((types & RDP_KEYBOARD_LAYOUT_TYPE_IME) != 0)
{
length = sizeof(RDP_KEYBOARD_IME_TABLE) / sizeof(RDP_KEYBOARD_IME);
length = ARRAY_SIZE(RDP_KEYBOARD_IME_TABLE);
layouts = (RDP_KEYBOARD_LAYOUT*) realloc(layouts, (num + length + 1) * sizeof(RDP_KEYBOARD_LAYOUT));
for (i = 0; i < length; i++, num++)
@ -1042,19 +1042,19 @@ const char* freerdp_keyboard_get_layout_name_from_id(uint32 keyboardLayoutID)
{
int i;
for (i = 0; i < sizeof(RDP_KEYBOARD_LAYOUT_TABLE) / sizeof(RDP_KEYBOARD_LAYOUT); i++)
for (i = 0; i < ARRAY_SIZE(RDP_KEYBOARD_LAYOUT_TABLE); i++)
{
if (RDP_KEYBOARD_LAYOUT_TABLE[i].code == keyboardLayoutID)
return RDP_KEYBOARD_LAYOUT_TABLE[i].name;
}
for (i = 0; i < sizeof(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE) / sizeof(RDP_KEYBOARD_LAYOUT_VARIANT); i++)
for (i = 0; i < ARRAY_SIZE(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE); i++)
{
if (RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].code == keyboardLayoutID)
return RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].name;
}
for (i = 0; i < sizeof(RDP_KEYBOARD_IME_TABLE) / sizeof(RDP_KEYBOARD_IME); i++)
for (i = 0; i < ARRAY_SIZE(RDP_KEYBOARD_IME_TABLE); i++)
{
if (RDP_KEYBOARD_IME_TABLE[i].code == keyboardLayoutID)
return RDP_KEYBOARD_IME_TABLE[i].name;

View File

@ -245,7 +245,7 @@ uint32 freerdp_detect_keyboard_type_and_layout_solaris(char* xkbfile, int length
}
pclose(kbd);
for (i = 0; i < sizeof(SOLARIS_KEYBOARD_TABLE) / sizeof(SOLARIS_KEYBOARD); i++)
for (i = 0; i < ARRAY_SIZE(SOLARIS_KEYBOARD_TABLE); i++)
{
if (SOLARIS_KEYBOARD_TABLE[i].type == type)
{

View File

@ -907,7 +907,7 @@ uint32 find_keyboard_layout_in_xorg_rules(char* layout, char* variant)
DEBUG_KBD("xkbLayout: %s\txkbVariant: %s", layout, variant);
for (i = 0; i < sizeof(xkbLayouts) / sizeof(XKB_LAYOUT); i++)
for (i = 0; i < ARRAY_SIZE(xkbLayouts); i++)
{
if (strcmp(xkbLayouts[i].layout, layout) == 0)
{

View File

@ -22,6 +22,7 @@
#include <string.h>
#include "liblocale.h"
#include <freerdp/utils/memory.h>
#include <freerdp/locale/locale.h>
struct _SYSTEM_LOCALE
@ -673,7 +674,7 @@ SYSTEM_LOCALE* freerdp_detect_system_locale()
freerdp_get_system_language_and_country_codes(language, country);
for (i = 0; i < sizeof(SYSTEM_LOCALE_TABLE) / sizeof(SYSTEM_LOCALE); i++)
for (i = 0; i < ARRAY_SIZE(SYSTEM_LOCALE_TABLE); i++)
{
if ((strcmp(language, SYSTEM_LOCALE_TABLE[i].language) == 0) && (strcmp(country, SYSTEM_LOCALE_TABLE[i].country) == 0))
{
@ -701,7 +702,7 @@ const char* freerdp_get_system_locale_name_from_id(uint32 localeId)
{
int index;
for (index = 0; index < sizeof(LOCALE_NAME_TABLE) / sizeof(LOCALE_NAME); index++)
for (index = 0; index < ARRAY_SIZE(LOCALE_NAME_TABLE); index++)
{
if (localeId == LOCALE_NAME_TABLE[index].localeId)
return LOCALE_NAME_TABLE[index].name;
@ -729,7 +730,7 @@ uint32 freerdp_detect_keyboard_layout_from_system_locale()
DEBUG_KBD("Found locale : %s_%s", locale->language, locale->country);
for (i = 0; i < sizeof(LOCALE_KEYBOARD_LAYOUTS_TABLE) / sizeof(LOCALE_KEYBOARD_LAYOUTS); i++)
for (i = 0; i < ARRAY_SIZE(LOCALE_KEYBOARD_LAYOUTS_TABLE); i++)
{
if (LOCALE_KEYBOARD_LAYOUTS_TABLE[i].locale == locale->code)
{

View File

@ -1576,11 +1576,11 @@ TIME_ZONE_ENTRY* freerdp_detect_windows_time_zone(uint32 bias)
if (tzid == NULL)
return NULL;
for (i = 0; i < sizeof(TimeZoneTable) / sizeof(TIME_ZONE_ENTRY); i++)
for (i = 0; i < ARRAY_SIZE(TimeZoneTable); i++)
{
if (bias == TimeZoneTable[i].Bias)
{
for (j = 0; j < sizeof(WindowsTimeZoneIdTable) / sizeof(WINDOWS_TZID_ENTRY); j++)
for (j = 0; j < ARRAY_SIZE(WindowsTimeZoneIdTable); j++)
{
if (strcmp(TimeZoneTable[i].Id, WindowsTimeZoneIdTable[j].windows) != 0)
continue;

View File

@ -96,7 +96,7 @@ void print_window_styles(uint32 style)
int i;
printf("Window Styles:\n{\n");
for (i = 0; i < sizeof(WINDOW_STYLES) / sizeof(WINDOW_STYLE); i++)
for (i = 0; i < ARRAY_SIZE(WINDOW_STYLES); i++)
{
if (style & WINDOW_STYLES[i].style)
{
@ -117,7 +117,7 @@ void print_extended_window_styles(uint32 style)
int i;
printf("Extended Window Styles:\n{\n");
for (i = 0; i < sizeof(EXTENDED_WINDOW_STYLES) / sizeof(WINDOW_STYLE); i++)
for (i = 0; i < ARRAY_SIZE(EXTENDED_WINDOW_STYLES); i++)
{
if (style & EXTENDED_WINDOW_STYLES[i].style)
{

View File

@ -596,7 +596,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
printf("missing extension name\n");
return FREERDP_ARGS_PARSE_FAILURE;
}
if (num_extensions >= sizeof(settings->extensions) / sizeof(struct rdp_ext_set))
if (num_extensions >= ARRAY_SIZE(settings->extensions))
{
printf("maximum extensions reached\n");
return FREERDP_ARGS_PARSE_FAILURE;

View File

@ -44,7 +44,7 @@
#include <windows.h>
#define PATH_SEPARATOR_STR "\\"
#define PATH_SEPARATOR_CHR '\\'
#define HOME_ENV_VARIABLE "HOMEPATH"
#define HOME_ENV_VARIABLE "HOME"
#endif
#ifdef _WIN32
@ -94,7 +94,7 @@ char* freerdp_get_config_path(rdpSettings* settings)
return settings->config_path;
settings->config_path = (char*) xmalloc(strlen(settings->home_path) + sizeof(FREERDP_CONFIG_DIR) + 2);
sprintf(settings->config_path, "%s/%s", settings->home_path, FREERDP_CONFIG_DIR);
sprintf(settings->config_path, "%s" PATH_SEPARATOR_STR "%s", settings->home_path, FREERDP_CONFIG_DIR);
if (!freerdp_check_file_exists(settings->config_path))
freerdp_mkdir(settings->config_path);

View File

@ -110,7 +110,7 @@ void* rail_clone_order(uint32 event_type, void* order)
size_t order_size = 0;
void* new_order = NULL;
for (i = 0; i < RAIL_ARRAY_SIZE(ordersize_table); i++)
for (i = 0; i < ARRAY_SIZE(ordersize_table); i++)
{
if (event_type == ordersize_table[i].type)
{

View File

@ -19,6 +19,7 @@
#include <stddef.h>
#include <freerdp/utils/signal.h>
#include <freerdp/utils/memory.h>
#ifdef _WIN32
#include <errno.h>
int freerdp_handle_signals(void)
@ -101,7 +102,7 @@ int freerdp_handle_signals(void)
fatal_sigaction.sa_flags = 0;
for (signal_index = 0;
signal_index < (sizeof fatal_signals / sizeof fatal_signals[0]);
signal_index < ARRAY_SIZE(fatal_signals);
signal_index++)
if (sigaction(fatal_signals[signal_index],
NULL, &orig_sigaction) == 0)