Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/neutrinolabs/xrdp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatt335672 <30179339+matt335672@users.noreply.github.com>2021-03-15 13:41:22 +0300
committerGitHub <noreply@github.com>2021-03-15 13:41:22 +0300
commit89875d156abc4d1707d82e151a8d613f9db5fae8 (patch)
tree9416b7bb32675a06e3178f739d6567063e961ee0
parentfeb8ef33f53b951714fc2dca5b4d09cd7a8b277e (diff)
parentd73e45eff12a8c85083363a63db6d443db4544dc (diff)
Merge pull request #1826 from aquesnel/unify_logging_common
Unify logging in common/* #1826
-rw-r--r--common/arch.h6
-rw-r--r--common/base64.c2
-rw-r--r--common/defines.h84
-rw-r--r--common/fifo.c26
-rw-r--r--common/fifo.h4
-rw-r--r--common/file.h12
-rw-r--r--common/list.c5
-rw-r--r--common/list.h20
-rw-r--r--common/list16.c4
-rw-r--r--common/list16.h28
-rw-r--r--common/log.h2
-rw-r--r--common/ms-rdpbcgr.h40
-rw-r--r--common/os_calls.c177
-rw-r--r--common/os_calls.h110
-rw-r--r--common/parse.h486
-rw-r--r--common/pixman-region.c499
-rw-r--r--common/pixman-region.h24
-rw-r--r--common/rail.h100
-rw-r--r--common/thread_calls.c2
-rw-r--r--common/thread_calls.h2
-rw-r--r--common/trans.c15
-rw-r--r--common/trans.h52
-rw-r--r--common/xrdp_constants.h2
-rw-r--r--xrdp/xrdp.c13
24 files changed, 977 insertions, 738 deletions
diff --git a/common/arch.h b/common/arch.h
index 1e61f197..617feb5e 100644
--- a/common/arch.h
+++ b/common/arch.h
@@ -145,7 +145,7 @@ typedef int tsock;
/* format string verification */
#if defined(HAVE_FUNC_ATTRIBUTE_FORMAT)
#define printflike(arg_format, arg_first_check) \
- __attribute__((__format__(__printf__, arg_format, arg_first_check)))
+ __attribute__((__format__(__printf__, arg_format, arg_first_check)))
#else
#define printflike(arg_format, arg_first_check)
#endif
@@ -154,8 +154,8 @@ typedef int tsock;
#ifdef __cplusplus
extern "C" {
#endif
- tintptr mod_init(void);
- int mod_exit(tintptr);
+tintptr mod_init(void);
+int mod_exit(tintptr);
#ifdef __cplusplus
}
#endif
diff --git a/common/base64.c b/common/base64.c
index a5b83dfa..36cb66d8 100644
--- a/common/base64.c
+++ b/common/base64.c
@@ -67,7 +67,7 @@ base64_decode(char *dst, const char *src, size_t len)
bio = BIO_new_mem_buf(b64str, len);
bio = BIO_push(b64, bio);
BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
- decoded_bytes = BIO_read(bio , dst, len);
+ decoded_bytes = BIO_read(bio, dst, len);
BIO_free_all(bio);
/* if input is corrupt, return empty string */
diff --git a/common/defines.h b/common/defines.h
index 17ac2d9e..ce680d91 100644
--- a/common/defines.h
+++ b/common/defines.h
@@ -21,12 +21,6 @@
#ifndef DEFINES_H
#define DEFINES_H
-/* check for debug */
-#ifdef XRDP_DEBUG
-#define DEBUG(args) g_writeln args;
-#else
-#define DEBUG(args)
-#endif
/* other macros */
#undef MIN
#define MIN(x1, x2) ((x1) < (x2) ? (x1) : (x2))
@@ -42,25 +36,25 @@
/* graphics macros */
#define MAKERECT(r, x, y, cx, cy) \
-{ (r).left = x; (r).top = y; (r).right = (x) + (cx); (r).bottom = (y) + (cy); }
+ { (r).left = x; (r).top = y; (r).right = (x) + (cx); (r).bottom = (y) + (cy); }
#define ISRECTEMPTY(r) (((r).right <= (r).left) || ((r).bottom <= (r).top))
#define RECTOFFSET(r, dx, dy) \
-{ (r).left += dx; (r).top += dy; (r).right += dx; (r).bottom += dy; }
+ { (r).left += dx; (r).top += dy; (r).right += dx; (r).bottom += dy; }
#define GETPIXEL8(d, x, y, w) (*(((unsigned char*)d) + ((y) * (w) + (x))))
#define GETPIXEL16(d, x, y, w) (*(((unsigned short*)d) + ((y) * (w) + (x))))
#define GETPIXEL32(d, x, y, w) (*(((unsigned int*)d) + ((y) * (w) + (x))))
#define SETPIXEL8(d, x, y, w, v) \
-(*(((unsigned char*)d) + ((y) * (w) + (x))) = (v))
+ (*(((unsigned char*)d) + ((y) * (w) + (x))) = (v))
#define SETPIXEL16(d, x, y, w, v) \
-(*(((unsigned short*)d) + ((y) * (w) + (x))) = (v))
+ (*(((unsigned short*)d) + ((y) * (w) + (x))) = (v))
#define SETPIXEL32(d, x, y, w, v) \
-(*(((unsigned int*)d) + ((y) * (w) + (x))) = (v))
+ (*(((unsigned int*)d) + ((y) * (w) + (x))) = (v))
#define COLOR8(r, g, b) \
-( \
- (((r) >> 5) << 0) | \
- (((g) >> 5) << 3) | \
- (((b) >> 6) << 6) \
-)
+ ( \
+ (((r) >> 5) << 0) | \
+ (((g) >> 5) << 3) | \
+ (((b) >> 6) << 6) \
+ )
#define COLOR15(r, g, b) ((((r) >> 3) << 10) | (((g) >> 3) << 5) | ((b) >> 3))
#define COLOR16(r, g, b) ((((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3))
#define COLOR24RGB(r, g, b) (((r) << 16) | ((g) << 8) | (b))
@@ -69,43 +63,43 @@
#define HGREEN(c) ((c & 0x00ff00) >> 8)
#define HBLUE(c) ((c & 0x0000ff))
#define HCOLOR(bpp,c) \
-( \
- (bpp==8?COLOR8(HRED(c),HGREEN(c),HBLUE(c)): \
- (bpp==15?COLOR15(HRED(c),HGREEN(c),HBLUE(c)): \
- (bpp==16?COLOR16(HRED(c),HGREEN(c),HBLUE(c)): \
- (bpp>=24?COLOR24BGR(HRED(c),HGREEN(c),HBLUE(c)):c) \
- ) \
- ) \
- ) \
-)
+ ( \
+ (bpp==8?COLOR8(HRED(c),HGREEN(c),HBLUE(c)): \
+ (bpp==15?COLOR15(HRED(c),HGREEN(c),HBLUE(c)): \
+ (bpp==16?COLOR16(HRED(c),HGREEN(c),HBLUE(c)): \
+ (bpp>=24?COLOR24BGR(HRED(c),HGREEN(c),HBLUE(c)):c) \
+ ) \
+ ) \
+ ) \
+ )
#define SPLITCOLOR15(r, g, b, c) \
-{ \
- r = (((c) >> 7) & 0xf8) | (((c) >> 12) & 0x7); \
- g = (((c) >> 2) & 0xf8) | (((c) >> 8) & 0x7); \
- b = (((c) << 3) & 0xf8) | (((c) >> 2) & 0x7); \
-}
+ { \
+ r = (((c) >> 7) & 0xf8) | (((c) >> 12) & 0x7); \
+ g = (((c) >> 2) & 0xf8) | (((c) >> 8) & 0x7); \
+ b = (((c) << 3) & 0xf8) | (((c) >> 2) & 0x7); \
+ }
#define SPLITCOLOR16(r, g, b, c) \
-{ \
- r = (((c) >> 8) & 0xf8) | (((c) >> 13) & 0x7); \
- g = (((c) >> 3) & 0xfc) | (((c) >> 9) & 0x3); \
- b = (((c) << 3) & 0xf8) | (((c) >> 2) & 0x7); \
-}
+ { \
+ r = (((c) >> 8) & 0xf8) | (((c) >> 13) & 0x7); \
+ g = (((c) >> 3) & 0xfc) | (((c) >> 9) & 0x3); \
+ b = (((c) << 3) & 0xf8) | (((c) >> 2) & 0x7); \
+ }
#define SPLITCOLOR32(r, g, b, c) \
-{ \
- r = ((c) >> 16) & 0xff; \
- g = ((c) >> 8) & 0xff; \
- b = (c) & 0xff; \
-}
+ { \
+ r = ((c) >> 16) & 0xff; \
+ g = ((c) >> 8) & 0xff; \
+ b = (c) & 0xff; \
+ }
/* font macros */
#define FONT_DATASIZE(f) \
- ((((f)->height * (((f)->width + 7) / 8)) + 3) & ~3);
+ ((((f)->height * (((f)->width + 7) / 8)) + 3) & ~3);
/* use crc for bitmap cache lookups */
#define USE_CRC
#define XR_RGB2BGR(a_ulColor) \
- (a_ulColor & 0xFF000000) | \
- ((a_ulColor & 0x00FF0000) >> 16) | \
- (a_ulColor & 0x0000FF00) | \
- ((a_ulColor & 0x000000FF) << 16)
+ (a_ulColor & 0xFF000000) | \
+ ((a_ulColor & 0x00FF0000) >> 16) | \
+ (a_ulColor & 0x0000FF00) | \
+ ((a_ulColor & 0x000000FF) << 16)
#endif
diff --git a/common/fifo.c b/common/fifo.c
index 64e85f23..7acf85a7 100644
--- a/common/fifo.c
+++ b/common/fifo.c
@@ -47,20 +47,24 @@ fifo_delete(FIFO *self)
USER_DATA *udp;
if (!self)
+ {
return;
+ }
- if (!self->head)
- {
- /* FIFO is empty */
- g_free(self);
- return;
- }
+ if (!self->head)
+ {
+ /* FIFO is empty */
+ g_free(self);
+ return;
+ }
if (self->head == self->tail)
{
/* only one item in FIFO */
if (self->auto_free)
+ {
g_free(self->head->item);
+ }
g_free(self->head);
g_free(self);
@@ -73,7 +77,9 @@ fifo_delete(FIFO *self)
udp = self->head;
if (self->auto_free)
+ {
g_free(udp->item);
+ }
self->head = udp->next;
g_free(udp);
@@ -97,10 +103,14 @@ fifo_add_item(FIFO *self, void *item)
USER_DATA *udp;
if (!self || !item)
+ {
return -1;
+ }
if ((udp = (USER_DATA *) g_malloc(sizeof(USER_DATA), 0)) == 0)
+ {
return -1;
+ }
udp->item = item;
udp->next = 0;
@@ -135,7 +145,9 @@ fifo_remove_item(FIFO *self)
USER_DATA *udp;
if (!self || !self->head)
+ {
return 0;
+ }
if (self->head == self->tail)
{
@@ -167,7 +179,9 @@ int
fifo_is_empty(FIFO *self)
{
if (!self)
+ {
return 1;
+ }
return (self->head == 0);
}
diff --git a/common/fifo.h b/common/fifo.h
index 3a69e029..ace5c6b8 100644
--- a/common/fifo.h
+++ b/common/fifo.h
@@ -38,10 +38,10 @@ typedef struct fifo
int auto_free;
} FIFO;
-FIFO * fifo_create(void);
+FIFO *fifo_create(void);
void fifo_delete(FIFO *self);
int fifo_add_item(FIFO *self, void *item);
-void * fifo_remove_item(FIFO *self);
+void *fifo_remove_item(FIFO *self);
int fifo_is_empty(FIFO *self);
#endif
diff --git a/common/file.h b/common/file.h
index 8800e6a7..5c3cfa0d 100644
--- a/common/file.h
+++ b/common/file.h
@@ -24,14 +24,14 @@
#include "arch.h"
int
-file_read_sections(int fd, struct list* names);
+file_read_sections(int fd, struct list *names);
int
-file_by_name_read_sections(const char* file_name, struct list* names);
+file_by_name_read_sections(const char *file_name, struct list *names);
int
-file_read_section(int fd, const char* section,
- struct list* names, struct list* values);
+file_read_section(int fd, const char *section,
+ struct list *names, struct list *values);
int
-file_by_name_read_section(const char* file_name, const char* section,
- struct list* names, struct list* values);
+file_by_name_read_section(const char *file_name, const char *section,
+ struct list *names, struct list *values);
#endif
diff --git a/common/list.c b/common/list.c
index 4597b9cb..b4530e8e 100644
--- a/common/list.c
+++ b/common/list.c
@@ -26,6 +26,7 @@
#include "os_calls.h"
#include "string_calls.h"
#include "list.h"
+#include "log.h"
/*****************************************************************************/
struct list *
@@ -221,11 +222,11 @@ list_dump_items(struct list *self)
if (self->count == 0)
{
- g_writeln("List is empty");
+ LOG_DEVEL(LOG_LEVEL_TRACE, "List is empty");
}
for (index = 0; index < self->count; index++)
{
- g_writeln("%d: %p", index, (void *) list_get_item(self, index));
+ LOG_DEVEL(LOG_LEVEL_TRACE, "%d: %p", index, (void *) list_get_item(self, index));
}
}
diff --git a/common/list.h b/common/list.h
index b3c9ef13..1f562105 100644
--- a/common/list.h
+++ b/common/list.h
@@ -26,32 +26,32 @@
/* list */
struct list
{
- tintptr* items;
+ tintptr *items;
int count;
int alloc_size;
int grow_by;
int auto_free;
};
-struct list*
+struct list *
list_create(void);
void
-list_delete(struct list* self);
+list_delete(struct list *self);
void
-list_add_item(struct list* self, tintptr item);
+list_add_item(struct list *self, tintptr item);
tintptr
list_get_item(const struct list *self, int index);
void
-list_clear(struct list* self);
+list_clear(struct list *self);
int
-list_index_of(struct list* self, tintptr item);
+list_index_of(struct list *self, tintptr item);
void
-list_remove_item(struct list* self, int index);
+list_remove_item(struct list *self, int index);
void
-list_insert_item(struct list* self, int index, tintptr item);
+list_insert_item(struct list *self, int index, tintptr item);
void
-list_append_list_strdup(struct list* self, struct list* dest, int start_index);
+list_append_list_strdup(struct list *self, struct list *dest, int start_index);
void
-list_dump_items(struct list* self);
+list_dump_items(struct list *self);
#endif
diff --git a/common/list16.c b/common/list16.c
index 8e548f71..5f934a24 100644
--- a/common/list16.c
+++ b/common/list16.c
@@ -52,7 +52,7 @@ list16_delete(struct list16 *self)
/*****************************************************************************/
void
-list16_init(struct list16* self)
+list16_init(struct list16 *self)
{
g_memset(self, 0, sizeof(struct list16));
self->max_count = 4;
@@ -61,7 +61,7 @@ list16_init(struct list16* self)
/*****************************************************************************/
void
-list16_deinit(struct list16* self)
+list16_deinit(struct list16 *self)
{
if (self->items != self->mitems)
{
diff --git a/common/list16.h b/common/list16.h
index fbe36e1d..eba3f419 100644
--- a/common/list16.h
+++ b/common/list16.h
@@ -26,31 +26,31 @@
/* list */
struct list16
{
- tui16* items;
- int count;
- int max_count;
- tui16 mitems[4];
+ tui16 *items;
+ int count;
+ int max_count;
+ tui16 mitems[4];
};
-struct list16*
+struct list16 *
list16_create(void);
void
-list16_delete(struct list16* self);
+list16_delete(struct list16 *self);
void
-list16_init(struct list16* self);
+list16_init(struct list16 *self);
void
-list16_deinit(struct list16* self);
+list16_deinit(struct list16 *self);
void
-list16_add_item(struct list16* self, tui16 item);
+list16_add_item(struct list16 *self, tui16 item);
tui16
-list16_get_item(struct list16* self, int index);
+list16_get_item(struct list16 *self, int index);
void
-list16_clear(struct list16* self);
+list16_clear(struct list16 *self);
int
-list16_index_of(struct list16* self, tui16 item);
+list16_index_of(struct list16 *self, tui16 item);
void
-list16_remove_item(struct list16* self, int index);
+list16_remove_item(struct list16 *self, int index);
void
-list16_insert_item(struct list16* self, int index, tui16 item);
+list16_insert_item(struct list16 *self, int index, tui16 item);
#endif
diff --git a/common/log.h b/common/log.h
index ad2eb086..bc86c1e5 100644
--- a/common/log.h
+++ b/common/log.h
@@ -130,7 +130,7 @@ enum logReturns
#else
#define LOG(log_level, args...) log_message(log_level, args)
-/* Since log_message() returns a value ensure that the elided versions of
+/* Since log_message() returns a value ensure that the elided versions of
* LOG_DEVEL and LOG_DEVEL_HEXDUMP also "fake" returning the success value
*/
#define LOG_DEVEL(log_level, args...) UNUSED_VAR(LOG_STARTUP_OK)
diff --git a/common/ms-rdpbcgr.h b/common/ms-rdpbcgr.h
index 52b737b9..71fa5d58 100644
--- a/common/ms-rdpbcgr.h
+++ b/common/ms-rdpbcgr.h
@@ -282,16 +282,16 @@
#define TS_NEG_SCRBLT_INDEX 0x02
#define TS_NEG_MEMBLT_INDEX 0x03
#define TS_NEG_MEM3BLT_INDEX 0x04
- /* 0x05 */
- /* 0x06 */
+/* 0x05 */
+/* 0x06 */
#define TS_NEG_DRAWNINEGRID_INDEX 0x07
#define TS_NEG_LINETO_INDEX 0x08
#define TS_NEG_MULTI_DRAWNINEGRID_INDEX 0x09
- /* 0x0A */
+/* 0x0A */
#define TS_NEG_SAVEBITMAP_INDEX 0x0B
- /* 0x0C */
- /* 0x0D */
- /* 0x0E */
+/* 0x0C */
+/* 0x0D */
+/* 0x0E */
#define TS_NEG_MULTIDSTBLT_INDEX 0x0F
#define TS_NEG_MULTIPATBLT_INDEX 0x10
#define TS_NEG_MULTISCRBLT_INDEX 0x11
@@ -300,15 +300,15 @@
#define TS_NEG_POLYGON_SC_INDEX 0x14
#define TS_NEG_POLYGON_CB_INDEX 0x15
#define TS_NEG_POLYLINE_INDEX 0x16
- /* 0x17 */
+/* 0x17 */
#define TS_NEG_FAST_GLYPH_INDEX 0x18
#define TS_NEG_ELLIPSE_SC_INDEX 0x19
#define TS_NEG_ELLIPSE_CB_INDEX 0x1A
#define TS_NEG_INDEX_INDEX 0x1B
- /* 0x1C */
- /* 0x1D */
- /* 0x1E */
- /* 0x1F */
+/* 0x1C */
+/* 0x1D */
+/* 0x1E */
+/* 0x1F */
/* Input Capability Set: inputFlags (2.2.7.1.6) */
#define INPUT_FLAG_SCANCODES 0x0001
@@ -340,27 +340,27 @@
/* CODEC_GUID_NSCODEC CA8D1BB9-000F-154F-589FAE2D1A87E2D6 */
#define XR_CODEC_GUID_NSCODEC \
- "\xb9\x1b\x8d\xca\x0f\x00\x4f\x15\x58\x9f\xae\x2d\x1a\x87\xe2\xd6"
+ "\xb9\x1b\x8d\xca\x0f\x00\x4f\x15\x58\x9f\xae\x2d\x1a\x87\xe2\xd6"
/* CODEC_GUID_REMOTEFX 76772F12-BD72-4463-AFB3B73C9C6F7886 */
#define XR_CODEC_GUID_REMOTEFX \
- "\x12\x2F\x77\x76\x72\xBD\x63\x44\xAF\xB3\xB7\x3C\x9C\x6F\x78\x86"
+ "\x12\x2F\x77\x76\x72\xBD\x63\x44\xAF\xB3\xB7\x3C\x9C\x6F\x78\x86"
/* CODEC_GUID_IMAGE_REMOTEFX 2744CCD4-9D8A-4E74-803C-0ECBEEA19C54 */
#define XR_CODEC_GUID_IMAGE_REMOTEFX \
- "\xD4\xCC\x44\x27\x8A\x9D\x74\x4E\x80\x3C\x0E\xCB\xEE\xA1\x9C\x54"
+ "\xD4\xCC\x44\x27\x8A\x9D\x74\x4E\x80\x3C\x0E\xCB\xEE\xA1\x9C\x54"
/* MFVideoFormat_H264 0x34363248-0000-0010-800000AA00389B71 */
#define XR_CODEC_GUID_H264 \
- "\x48\x32\x36\x34\x00\x00\x10\x00\x80\x00\x00\xAA\x00\x38\x9B\x71"
+ "\x48\x32\x36\x34\x00\x00\x10\x00\x80\x00\x00\xAA\x00\x38\x9B\x71"
/* CODEC_GUID_JPEG 1BAF4CE6-9EED-430C-869ACB8B37B66237 */
#define XR_CODEC_GUID_JPEG \
- "\xE6\x4C\xAF\x1B\xED\x9E\x0C\x43\x86\x9A\xCB\x8B\x37\xB6\x62\x37"
+ "\xE6\x4C\xAF\x1B\xED\x9E\x0C\x43\x86\x9A\xCB\x8B\x37\xB6\x62\x37"
/* CODEC_GUID_PNG 0E0C858D-28E0-45DB-ADAA0F83E57CC560 */
#define XR_CODEC_GUID_PNG \
- "\x8D\x85\x0C\x0E\xE0\x28\xDB\x45\xAD\xAA\x0F\x83\xE5\x7C\xC5\x60"
+ "\x8D\x85\x0C\x0E\xE0\x28\xDB\x45\xAD\xAA\x0F\x83\xE5\x7C\xC5\x60"
/* PDU Types (2.2.8.1.1.1.1) */
#define PDUTYPE_DEMANDACTIVEPDU 0x1
@@ -376,7 +376,7 @@
(pdu_type) == PDUTYPE_DATAPDU ? "PDUTYPE_DATAPDU" : \
(pdu_type) == PDUTYPE_SERVER_REDIR_PKT ? "PDUTYPE_SERVER_REDIR_PKT" : \
"unknown" \
- )
+ )
/* Share Data Header: pduType2 (2.2.8.1.1.1.2) */
/* TODO: to be renamed */
@@ -417,7 +417,7 @@
/* Keyboard Event: keyboardFlags (2.2.8.1.1.3.1.1.1) */
/* TODO: to be renamed */
-#define KBD_FLAG_RIGHT 0x0001
+#define KBD_FLAG_RIGHT 0x0001
#define KBD_FLAG_EXT 0x0100 /* KBDFLAGS_EXTENDED */
#define KBD_FLAG_QUIET 0x1000
#define KBD_FLAG_DOWN 0x4000
@@ -475,7 +475,7 @@
(type) == RDP_UPDATE_PALETTE ? "RDP_UPDATE_PALETTE" : \
(type) == RDP_UPDATE_SYNCHRONIZE ? "RDP_UPDATE_SYNCHRONIZE" : \
"unknown" \
- )
+ )
/* Server Pointer Update PDU: messageType (2.2.9.1.1.4) */
/* TODO: to be renamed */
diff --git a/common/os_calls.c b/common/os_calls.c
index 897dd5a1..a725247e 100644
--- a/common/os_calls.c
+++ b/common/os_calls.c
@@ -121,9 +121,9 @@ g_mk_socket_path(const char *app_name)
/* if failed, still check if it got created by someone else */
if (!g_directory_exist(XRDP_SOCKET_PATH))
{
- log_message(LOG_LEVEL_ERROR,
- "g_mk_socket_path: g_create_path(%s) failed",
- XRDP_SOCKET_PATH);
+ LOG(LOG_LEVEL_ERROR,
+ "g_mk_socket_path: g_create_path(%s) failed",
+ XRDP_SOCKET_PATH);
return 1;
}
}
@@ -269,7 +269,7 @@ g_write(const char *format, ...)
}
/*****************************************************************************/
-/* produce a hex dump */
+/* print a hex dump to stdout*/
void
g_hexdump(const char *p, int len)
{
@@ -360,13 +360,13 @@ g_tcp_set_no_delay(int sck)
}
else
{
- g_writeln("Error setting tcp_nodelay");
+ LOG(LOG_LEVEL_ERROR, "Error setting tcp_nodelay");
}
}
}
else
{
- g_writeln("Error getting tcp_nodelay");
+ LOG(LOG_LEVEL_ERROR, "Error getting tcp_nodelay");
}
return ret;
@@ -399,13 +399,13 @@ g_tcp_set_keepalive(int sck)
}
else
{
- g_writeln("Error setting tcp_keepalive");
+ LOG(LOG_LEVEL_ERROR, "Error setting tcp_keepalive");
}
}
}
else
{
- g_writeln("Error getting tcp_keepalive");
+ LOG(LOG_LEVEL_ERROR, "Error getting tcp_keepalive");
}
return ret;
@@ -428,12 +428,12 @@ g_tcp_socket(void)
switch (errno)
{
case EAFNOSUPPORT: /* if IPv6 not supported, retry IPv4 */
- log_message(LOG_LEVEL_INFO, "IPv6 not supported, falling back to IPv4");
+ LOG(LOG_LEVEL_INFO, "IPv6 not supported, falling back to IPv4");
rv = (int)socket(AF_INET, SOCK_STREAM, 0);
break;
default:
- log_message(LOG_LEVEL_ERROR, "g_tcp_socket: %s", g_get_strerror());
+ LOG(LOG_LEVEL_ERROR, "g_tcp_socket: %s", g_get_strerror());
return -1;
}
}
@@ -442,12 +442,12 @@ g_tcp_socket(void)
#endif
if (rv < 0)
{
- log_message(LOG_LEVEL_ERROR, "g_tcp_socket: %s", g_get_strerror());
+ LOG(LOG_LEVEL_ERROR, "g_tcp_socket: %s", g_get_strerror());
return -1;
}
#if defined(XRDP_ENABLE_IPV6)
option_len = sizeof(option_value);
- if (getsockopt(rv, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&option_value,
+ if (getsockopt(rv, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&option_value,
&option_len) == 0)
{
if (option_value != 0)
@@ -458,10 +458,10 @@ g_tcp_socket(void)
option_value = 0;
#endif
option_len = sizeof(option_value);
- if (setsockopt(rv, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&option_value,
- option_len) < 0)
+ if (setsockopt(rv, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&option_value,
+ option_len) < 0)
{
- log_message(LOG_LEVEL_ERROR, "g_tcp_socket: setsockopt() failed");
+ LOG(LOG_LEVEL_ERROR, "g_tcp_socket: setsockopt() failed");
}
}
}
@@ -475,9 +475,9 @@ g_tcp_socket(void)
option_value = 1;
option_len = sizeof(option_value);
if (setsockopt(rv, SOL_SOCKET, SO_REUSEADDR, (char *)&option_value,
- option_len) < 0)
+ option_len) < 0)
{
- log_message(LOG_LEVEL_ERROR, "g_tcp_socket: setsockopt() failed");
+ LOG(LOG_LEVEL_ERROR, "g_tcp_socket: setsockopt() failed");
}
}
}
@@ -492,9 +492,9 @@ g_tcp_socket(void)
option_value = 1024 * 32;
option_len = sizeof(option_value);
if (setsockopt(rv, SOL_SOCKET, SO_SNDBUF, (char *)&option_value,
- option_len) < 0)
+ option_len) < 0)
{
- log_message(LOG_LEVEL_ERROR, "g_tcp_socket: setsockopt() failed");
+ LOG(LOG_LEVEL_ERROR, "g_tcp_socket: setsockopt() failed");
}
}
}
@@ -638,9 +638,9 @@ g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid)
if (getsockopt(sck, SOL_SOCKET, LOCAL_PEERCRED, &xucred, &xucred_length))
{
- return 1;
+ return 1;
}
- if (pid !=0)
+ if (pid != 0)
{
*pid = 0; /* can't get pid in FreeBSD, OS X */
}
@@ -648,7 +648,8 @@ g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid)
{
*uid = xucred.cr_uid;
}
- if (gid != 0) {
+ if (gid != 0)
+ {
*gid = xucred.cr_gid;
}
return 0;
@@ -738,8 +739,8 @@ g_sck_close(int sck)
}
else
{
- log_message(LOG_LEVEL_WARNING, "getsockname() failed on socket %d: %s",
- sck, g_get_strerror());
+ LOG(LOG_LEVEL_WARNING, "getsockname() failed on socket %d: %s",
+ sck, g_get_strerror());
if (errno == EBADF || errno == ENOTSOCK)
{
@@ -751,12 +752,12 @@ g_sck_close(int sck)
if (close(sck) == 0)
{
- log_message(LOG_LEVEL_DEBUG, "Closed socket %d (%s)", sck, sockname);
+ LOG(LOG_LEVEL_DEBUG, "Closed socket %d (%s)", sck, sockname);
}
else
{
- log_message(LOG_LEVEL_WARNING, "Cannot close socket %d (%s): %s", sck,
- sockname, g_get_strerror());
+ LOG(LOG_LEVEL_WARNING, "Cannot close socket %d (%s): %s", sck,
+ sockname, g_get_strerror());
}
#endif
@@ -777,7 +778,7 @@ connect_loopback(int sck, const char *port)
sa.sin6_family = AF_INET6;
sa.sin6_addr = in6addr_loopback; // IPv6 ::1
sa.sin6_port = htons((tui16)atoi(port));
- res = connect(sck, (struct sockaddr*)&sa, sizeof(sa));
+ res = connect(sck, (struct sockaddr *)&sa, sizeof(sa));
if (res == -1 && errno == EINPROGRESS)
{
return -1;
@@ -792,7 +793,7 @@ connect_loopback(int sck, const char *port)
s.sin_family = AF_INET;
s.sin_addr.s_addr = htonl(INADDR_LOOPBACK); // IPv4 127.0.0.1
s.sin_port = htons((tui16)atoi(port));
- res = connect(sck, (struct sockaddr*)&s, sizeof(s));
+ res = connect(sck, (struct sockaddr *)&s, sizeof(s));
if (res == -1 && errno == EINPROGRESS)
{
return -1;
@@ -807,7 +808,7 @@ connect_loopback(int sck, const char *port)
sa.sin6_family = AF_INET6;
inet_pton(AF_INET6, "::FFFF:127.0.0.1", &sa.sin6_addr);
sa.sin6_port = htons((tui16)atoi(port));
- res = connect(sck, (struct sockaddr*)&sa, sizeof(sa));
+ res = connect(sck, (struct sockaddr *)&sa, sizeof(sa));
if (res == -1 && errno == EINPROGRESS)
{
return -1;
@@ -850,8 +851,8 @@ g_tcp_connect(int sck, const char *address, const char *port)
}
if (res != 0)
{
- log_message(LOG_LEVEL_ERROR, "g_tcp_connect(%d, %s, %s): getaddrinfo() failed: %s",
- sck, address, port, gai_strerror(res));
+ LOG(LOG_LEVEL_ERROR, "g_tcp_connect(%d, %s, %s): getaddrinfo() failed: %s",
+ sck, address, port, gai_strerror(res));
}
if (res > -1)
{
@@ -879,10 +880,10 @@ g_tcp_connect(int sck, const char *address, const char *port)
}
#else
int
-g_tcp_connect(int sck, const char* address, const char* port)
+g_tcp_connect(int sck, const char *address, const char *port)
{
struct sockaddr_in s;
- struct hostent* h;
+ struct hostent *h;
int res;
g_memset(&s, 0, sizeof(struct sockaddr_in));
@@ -900,13 +901,13 @@ g_tcp_connect(int sck, const char* address, const char* port)
{
if ((*(h->h_addr_list)) != 0)
{
- s.sin_addr.s_addr = *((int*)(*(h->h_addr_list)));
+ s.sin_addr.s_addr = *((int *)(*(h->h_addr_list)));
}
}
}
}
}
- res = connect(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in));
+ res = connect(sck, (struct sockaddr *)&s, sizeof(struct sockaddr_in));
/* Mac OSX connect() returns -1 for already established connections */
if (res == -1 && errno == EISCONN)
@@ -951,7 +952,7 @@ g_sck_set_non_blocking(int sck)
i = i | O_NONBLOCK;
if (fcntl(sck, F_SETFL, i) < 0)
{
- log_message(LOG_LEVEL_ERROR, "g_sck_set_non_blocking: fcntl() failed");
+ LOG(LOG_LEVEL_ERROR, "g_sck_set_non_blocking: fcntl() failed");
}
#endif
return 0;
@@ -972,7 +973,7 @@ g_tcp_bind(int sck, const char *port)
sa.sin6_family = AF_INET6;
sa.sin6_addr = in6addr_any; // IPv6 ::
sa.sin6_port = htons((tui16)atoi(port));
- if (bind(sck, (struct sockaddr*)&sa, sizeof(sa)) == 0)
+ if (bind(sck, (struct sockaddr *)&sa, sizeof(sa)) == 0)
{
return 0;
}
@@ -983,19 +984,19 @@ g_tcp_bind(int sck, const char *port)
s.sin_family = AF_INET;
s.sin_addr.s_addr = htonl(INADDR_ANY); // IPv4 0.0.0.0
s.sin_port = htons((tui16)atoi(port));
- if (bind(sck, (struct sockaddr*)&s, sizeof(s)) == 0)
+ if (bind(sck, (struct sockaddr *)&s, sizeof(s)) == 0)
{
return 0;
}
- log_message(LOG_LEVEL_ERROR, "g_tcp_bind(%d, %s) failed "
- "bind IPv6 (errno=%d) and IPv4 (errno=%d).",
- sck, port, errno6, errno);
+ LOG(LOG_LEVEL_ERROR, "g_tcp_bind(%d, %s) failed "
+ "bind IPv6 (errno=%d) and IPv4 (errno=%d).",
+ sck, port, errno6, errno);
return -1;
}
#else
int
-g_tcp_bind(int sck, const char* port)
+g_tcp_bind(int sck, const char *port)
{
struct sockaddr_in s;
@@ -1003,7 +1004,7 @@ g_tcp_bind(int sck, const char* port)
s.sin_family = AF_INET;
s.sin_port = htons((tui16)atoi(port));
s.sin_addr.s_addr = INADDR_ANY;
- return bind(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in));
+ return bind(sck, (struct sockaddr *)&s, sizeof(struct sockaddr_in));
}
#endif
@@ -1078,7 +1079,7 @@ bind_loopback(int sck, const char *port)
sa.sin6_family = AF_INET6;
sa.sin6_addr = in6addr_loopback; // IPv6 ::1
sa.sin6_port = htons((tui16)atoi(port));
- if (bind(sck, (struct sockaddr*)&sa, sizeof(sa)) == 0)
+ if (bind(sck, (struct sockaddr *)&sa, sizeof(sa)) == 0)
{
return 0;
}
@@ -1089,7 +1090,7 @@ bind_loopback(int sck, const char *port)
s.sin_family = AF_INET;
s.sin_addr.s_addr = htonl(INADDR_LOOPBACK); // IPv4 127.0.0.1
s.sin_port = htons((tui16)atoi(port));
- if (bind(sck, (struct sockaddr*)&s, sizeof(s)) == 0)
+ if (bind(sck, (struct sockaddr *)&s, sizeof(s)) == 0)
{
return 0;
}
@@ -1100,14 +1101,14 @@ bind_loopback(int sck, const char *port)
sa.sin6_family = AF_INET6;
inet_pton(AF_INET6, "::FFFF:127.0.0.1", &sa.sin6_addr);
sa.sin6_port = htons((tui16)atoi(port));
- if (bind(sck, (struct sockaddr*)&sa, sizeof(sa)) == 0)
+ if (bind(sck, (struct sockaddr *)&sa, sizeof(sa)) == 0)
{
return 0;
}
- log_message(LOG_LEVEL_ERROR, "bind_loopback(%d, %s) failed; "
- "IPv6 ::1 (errno=%d), IPv4 127.0.0.1 (errno=%d) and IPv6 ::FFFF:127.0.0.1 (errno=%d).",
- sck, port, errno6, errno4, errno);
+ LOG(LOG_LEVEL_ERROR, "bind_loopback(%d, %s) failed; "
+ "IPv6 ::1 (errno=%d), IPv4 127.0.0.1 (errno=%d) and IPv6 ::FFFF:127.0.0.1 (errno=%d).",
+ sck, port, errno6, errno4, errno);
return -1;
}
@@ -1142,7 +1143,7 @@ getaddrinfo_bind(int sck, const char *port, const char *address)
}
else
{
- log_message(LOG_LEVEL_ERROR, "getaddrinfo error: %s", gai_strerror(error));
+ LOG(LOG_LEVEL_ERROR, "getaddrinfo error: %s", gai_strerror(error));
return -1;
}
return res;
@@ -1159,16 +1160,16 @@ g_tcp_bind_address(int sck, const char *port, const char *address)
int res;
if ((address == 0) ||
- (address[0] == 0) ||
- (g_strcmp(address, "0.0.0.0") == 0) ||
- (g_strcmp(address, "::") == 0))
+ (address[0] == 0) ||
+ (g_strcmp(address, "0.0.0.0") == 0) ||
+ (g_strcmp(address, "::") == 0))
{
return g_tcp_bind(sck, port);
}
if ((g_strcmp(address, "127.0.0.1") == 0) ||
- (g_strcmp(address, "::1") == 0) ||
- (g_strcmp(address, "localhost") == 0))
+ (g_strcmp(address, "::1") == 0) ||
+ (g_strcmp(address, "localhost") == 0))
{
return bind_loopback(sck, port);
}
@@ -1183,7 +1184,7 @@ g_tcp_bind_address(int sck, const char *port, const char *address)
struct in_addr a;
if ((inet_aton(address, &a) == 1) && (strlen(address) <= 15))
{
- char sz[7+15+1];
+ char sz[7 + 15 + 1];
sprintf(sz, "::FFFF:%s", address);
res = getaddrinfo_bind(sck, port, sz);
if (res == 0)
@@ -1192,15 +1193,15 @@ g_tcp_bind_address(int sck, const char *port, const char *address)
}
}
- log_message(LOG_LEVEL_ERROR, "g_tcp_bind_address(%d, %s, %s) Failed!",
- sck, port, address);
+ LOG(LOG_LEVEL_ERROR, "g_tcp_bind_address(%d, %s, %s) Failed!",
+ sck, port, address);
return -1;
}
return 0;
}
#else
int
-g_tcp_bind_address(int sck, const char* port, const char* address)
+g_tcp_bind_address(int sck, const char *port, const char *address)
{
struct sockaddr_in s;
@@ -1212,7 +1213,7 @@ g_tcp_bind_address(int sck, const char* port, const char* address)
{
return -1; /* bad address */
}
- return bind(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in));
+ return bind(sck, (struct sockaddr *)&s, sizeof(struct sockaddr_in));
}
#endif
@@ -1246,7 +1247,7 @@ g_tcp_accept(int sck)
if (ret > 0)
{
- switch(sock_info.sock_addr.sa_family)
+ switch (sock_info.sock_addr.sa_family)
{
case AF_INET:
{
@@ -1255,7 +1256,7 @@ g_tcp_accept(int sck)
g_snprintf(msg, sizeof(msg), "A connection received from %s port %d",
inet_ntoa(sock_addr_in->sin_addr),
ntohs(sock_addr_in->sin_port));
- log_message(LOG_LEVEL_INFO, "%s", msg);
+ LOG(LOG_LEVEL_INFO, "%s", msg);
break;
}
@@ -1271,7 +1272,7 @@ g_tcp_accept(int sck)
&sock_addr_in6->sin6_addr, addr, sizeof(addr));
g_snprintf(msg, sizeof(msg), "A connection received from %s port %d",
addr, ntohs(sock_addr_in6->sin6_port));
- log_message(LOG_LEVEL_INFO, "%s", msg);
+ LOG(LOG_LEVEL_INFO, "%s", msg);
break;
@@ -1310,7 +1311,7 @@ g_sck_accept(int sck, char *addr, int addr_bytes, char *port, int port_bytes)
if (ret > 0)
{
- switch(sock_info.sock_addr.sa_family)
+ switch (sock_info.sock_addr.sa_family)
{
case AF_INET:
{
@@ -1380,7 +1381,7 @@ g_sck_accept(int sck, char *addr, int addr_bytes, char *port, int port_bytes)
}
- log_message(LOG_LEVEL_INFO, "Socket %d: %s", ret, msg);
+ LOG(LOG_LEVEL_INFO, "Socket %d: %s", ret, msg);
}
@@ -1419,7 +1420,7 @@ g_write_ip_address(int rcv_sck, char *ip_address, int bytes)
if (getpeername(rcv_sck, (struct sockaddr *)&sock_info, &sock_len) == 0)
{
- switch(sock_info.sock_addr.sa_family)
+ switch (sock_info.sock_addr.sa_family)
{
case AF_INET:
{
@@ -1806,7 +1807,7 @@ g_set_wait_obj(tintptr obj)
{
error = errno;
if ((error == EAGAIN) || (error == EWOULDBLOCK) ||
- (error == EINPROGRESS) || (error == EINTR))
+ (error == EINPROGRESS) || (error == EINTR))
{
/* ok */
}
@@ -1857,7 +1858,7 @@ g_reset_wait_obj(tintptr obj)
{
error = errno;
if ((error == EAGAIN) || (error == EWOULDBLOCK) ||
- (error == EINPROGRESS) || (error == EINTR))
+ (error == EINPROGRESS) || (error == EINTR))
{
/* ok */
}
@@ -2008,7 +2009,7 @@ g_obj_wait(tintptr *read_objs, int rcount, tintptr *write_objs, int wcount,
}
else if (rcount > 0)
{
- g_writeln("Programming error read_objs is null");
+ LOG(LOG_LEVEL_ERROR, "Programming error read_objs is null");
return 1; /* error */
}
@@ -2031,7 +2032,7 @@ g_obj_wait(tintptr *read_objs, int rcount, tintptr *write_objs, int wcount,
}
else if (wcount > 0)
{
- g_writeln("Programming error write_objs is null");
+ LOG(LOG_LEVEL_ERROR, "Programming error write_objs is null");
return 1; /* error */
}
@@ -3135,11 +3136,11 @@ struct dib_hdr
int vres;
unsigned int ncolors;
unsigned int nimpcolors;
- };
+};
/******************************************************************************/
int
-g_save_to_bmp(const char* filename, char* data, int stride_bytes,
+g_save_to_bmp(const char *filename, char *data, int stride_bytes,
int width, int height, int depth, int bits_per_pixel)
{
struct bmp_magic bm;
@@ -3152,8 +3153,8 @@ g_save_to_bmp(const char* filename, char* data, int stride_bytes,
int pixel;
int extra;
int file_stride_bytes;
- char* line;
- char* line_ptr;
+ char *line;
+ char *line_ptr;
if ((depth == 24) && (bits_per_pixel == 32))
{
@@ -3163,7 +3164,9 @@ g_save_to_bmp(const char* filename, char* data, int stride_bytes,
}
else
{
- g_writeln("g_save_to_bpp: unimp");
+ LOG(LOG_LEVEL_ERROR,
+ "g_save_to_bpp: unimplemented for: depth %d, bits_per_pixel %d",
+ depth, bits_per_pixel);
return 1;
}
bm.magic[0] = 'B';
@@ -3196,23 +3199,23 @@ g_save_to_bmp(const char* filename, char* data, int stride_bytes,
fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
if (fd == -1)
{
- g_writeln("g_save_to_bpp: open error");
+ LOG(LOG_LEVEL_ERROR, "g_save_to_bpp: open error");
return 1;
}
bytes = write(fd, &bm, sizeof(bm));
if (bytes != sizeof(bm))
{
- g_writeln("g_save_to_bpp: write error");
+ LOG(LOG_LEVEL_ERROR, "g_save_to_bpp: write error");
}
bytes = write(fd, &bh, sizeof(bh));
if (bytes != sizeof(bh))
{
- g_writeln("g_save_to_bpp: write error");
+ LOG(LOG_LEVEL_ERROR, "g_save_to_bpp: write error");
}
bytes = write(fd, &dh, sizeof(dh));
if (bytes != sizeof(dh))
{
- g_writeln("g_save_to_bpp: write error");
+ LOG(LOG_LEVEL_ERROR, "g_save_to_bpp: write error");
}
data += stride_bytes * height;
data -= stride_bytes;
@@ -3225,7 +3228,7 @@ g_save_to_bmp(const char* filename, char* data, int stride_bytes,
line_ptr = line;
for (i1 = 0; i1 < width; i1++)
{
- pixel = ((int*)data)[i1];
+ pixel = ((int *)data)[i1];
*(line_ptr++) = (pixel >> 0) & 0xff;
*(line_ptr++) = (pixel >> 8) & 0xff;
*(line_ptr++) = (pixel >> 16) & 0xff;
@@ -3233,7 +3236,7 @@ g_save_to_bmp(const char* filename, char* data, int stride_bytes,
bytes = write(fd, line, file_stride_bytes);
if (bytes != file_stride_bytes)
{
- g_writeln("g_save_to_bpp: write error");
+ LOG(LOG_LEVEL_ERROR, "g_save_to_bpp: write error");
}
data -= stride_bytes;
}
@@ -3246,14 +3249,16 @@ g_save_to_bmp(const char* filename, char* data, int stride_bytes,
bytes = write(fd, data, width * (bits_per_pixel / 8));
if (bytes != width * (bits_per_pixel / 8))
{
- g_writeln("g_save_to_bpp: write error");
+ LOG(LOG_LEVEL_ERROR, "g_save_to_bpp: write error");
}
data -= stride_bytes;
}
}
else
{
- g_writeln("g_save_to_bpp: unimp");
+ LOG(LOG_LEVEL_ERROR,
+ "g_save_to_bpp: unimplemented for: depth %d, bits_per_pixel %d",
+ depth, bits_per_pixel);
}
close(fd);
return 0;
@@ -3267,7 +3272,7 @@ g_shmat(int shmid)
#if defined(_WIN32)
return 0;
#else
- return shmat(shmid, 0, 0);
+ return shmat(shmid, 0, 0);
#endif
}
@@ -3398,7 +3403,7 @@ g_tcp4_bind_address(int sck, const char *port, const char *address)
{
return -1; /* bad address */
}
- if (bind(sck, (struct sockaddr*) &s, sizeof(s)) < 0)
+ if (bind(sck, (struct sockaddr *) &s, sizeof(s)) < 0)
{
return -1;
}
diff --git a/common/os_calls.h b/common/os_calls.h
index 99454044..6b73402b 100644
--- a/common/os_calls.h
+++ b/common/os_calls.h
@@ -38,21 +38,21 @@
#define g_close_wait_obj g_delete_wait_obj
int g_rm_temp_dir(void);
-int g_mk_socket_path(const char* app_name);
-void g_init(const char* app_name);
+int g_mk_socket_path(const char *app_name);
+void g_init(const char *app_name);
void g_deinit(void);
-void* g_malloc(int size, int zero);
-void g_free(void* ptr);
+void *g_malloc(int size, int zero);
+void g_free(void *ptr);
void g_printf(const char *format, ...) printflike(1, 2);
-void g_sprintf(char* dest, const char* format, ...) \
- printflike(2, 3);
-int g_snprintf(char* dest, int len, const char* format, ...) \
- printflike(3, 4);
-void g_writeln(const char* format, ...) printflike(1, 2);
-void g_write(const char* format, ...) printflike(1, 2);
+void g_sprintf(char *dest, const char *format, ...) \
+printflike(2, 3);
+int g_snprintf(char *dest, int len, const char *format, ...) \
+printflike(3, 4);
+void g_writeln(const char *format, ...) printflike(1, 2);
+void g_write(const char *format, ...) printflike(1, 2);
void g_hexdump(const char *p, int len);
-void g_memset(void* ptr, int val, int size);
-void g_memcpy(void* d_ptr, const void* s_ptr, int size);
+void g_memset(void *ptr, int val, int size);
+void g_memcpy(void *d_ptr, const void *s_ptr, int size);
int g_getchar(void);
int g_tcp_set_no_delay(int sck);
int g_tcp_set_keepalive(int sck);
@@ -65,26 +65,26 @@ int g_sck_local_socket(void);
int g_sck_vsock_socket(void);
int g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid);
void g_sck_close(int sck);
-int g_tcp_connect(int sck, const char* address, const char* port);
-int g_sck_local_connect(int sck, const char* port);
+int g_tcp_connect(int sck, const char *address, const char *port);
+int g_sck_local_connect(int sck, const char *port);
int g_sck_set_non_blocking(int sck);
int g_tcp_bind(int sck, const char *port);
-int g_sck_local_bind(int sck, const char* port);
-int g_sck_vsock_bind(int sck, const char* port);
+int g_sck_local_bind(int sck, const char *port);
+int g_sck_vsock_bind(int sck, const char *port);
int g_sck_vsock_bind_address(int sck, const char *port, const char *address);
-int g_tcp_bind_address(int sck, const char* port, const char* address);
+int g_tcp_bind_address(int sck, const char *port, const char *address);
int g_sck_listen(int sck);
int g_tcp_accept(int sck);
int g_sck_accept(int sck, char *addr, int addr_bytes,
- char *port, int port_bytes);
-int g_sck_recv(int sck, void* ptr, int len, int flags);
-int g_sck_send(int sck, const void* ptr, int len, int flags);
+ char *port, int port_bytes);
+int g_sck_recv(int sck, void *ptr, int len, int flags);
+int g_sck_send(int sck, const void *ptr, int len, int flags);
int g_sck_last_error_would_block(int sck);
int g_sck_socket_ok(int sck);
int g_sck_can_send(int sck, int millis);
int g_sck_can_recv(int sck, int millis);
int g_sck_select(int sck1, int sck2);
-void g_write_ip_address(int rcv_sck, char* ip_address, int bytes);
+void g_write_ip_address(int rcv_sck, char *ip_address, int bytes);
void g_sleep(int msecs);
tintptr g_create_wait_obj(const char *name);
tintptr g_create_wait_obj_from_socket(tintptr socket, int write);
@@ -93,40 +93,40 @@ int g_set_wait_obj(tintptr obj);
int g_reset_wait_obj(tintptr obj);
int g_is_wait_obj_set(tintptr obj);
int g_delete_wait_obj(tintptr obj);
-int g_obj_wait(tintptr* read_objs, int rcount, tintptr* write_objs,
- int wcount,int mstimeout);
-void g_random(char* data, int len);
+int g_obj_wait(tintptr *read_objs, int rcount, tintptr *write_objs,
+ int wcount, int mstimeout);
+void g_random(char *data, int len);
int g_abs(int i);
-int g_memcmp(const void* s1, const void* s2, int len);
-int g_file_open(const char* file_name);
+int g_memcmp(const void *s1, const void *s2, int len);
+int g_file_open(const char *file_name);
int g_file_open_ex(const char *file_name, int aread, int awrite,
- int acreate, int atrunc);
+ int acreate, int atrunc);
int g_file_close(int fd);
-int g_file_read(int fd, char* ptr, int len);
+int g_file_read(int fd, char *ptr, int len);
int g_file_write(int fd, const char *ptr, int len);
int g_file_seek(int fd, int offset);
int g_file_lock(int fd, int start, int len);
-int g_chmod_hex(const char* filename, int flags);
-int g_chown(const char* name, int uid, int gid);
-int g_mkdir(const char* dirname);
-char* g_get_current_dir(char* dirname, int maxlen);
+int g_chmod_hex(const char *filename, int flags);
+int g_chown(const char *name, int uid, int gid);
+int g_mkdir(const char *dirname);
+char *g_get_current_dir(char *dirname, int maxlen);
int g_set_current_dir(const char *dirname);
-int g_file_exist(const char* filename);
+int g_file_exist(const char *filename);
int g_file_readable(const char *filename);
-int g_directory_exist(const char* dirname);
-int g_create_dir(const char* dirname);
-int g_create_path(const char* path);
-int g_remove_dir(const char* dirname);
-int g_file_delete(const char* filename);
-int g_file_get_size(const char* filename);
-long g_load_library(char* in);
+int g_directory_exist(const char *dirname);
+int g_create_dir(const char *dirname);
+int g_create_path(const char *path);
+int g_remove_dir(const char *dirname);
+int g_file_delete(const char *filename);
+int g_file_get_size(const char *filename);
+long g_load_library(char *in);
int g_free_library(long lib);
-void* g_get_proc_address(long lib, const char* name);
-int g_system(char* aexec);
-char* g_get_strerror(void);
+void *g_get_proc_address(long lib, const char *name);
+int g_system(char *aexec);
+char *g_get_strerror(void);
int g_get_errno(void);
-int g_execvp(const char* p1, char* args[]);
-int g_execlp3(const char* a1, const char* a2, const char* a3);
+int g_execvp(const char *p1, char *args[]);
+int g_execlp3(const char *a1, const char *a2, const char *a3);
void g_signal_child_stop(void (*func)(int));
void g_signal_segfault(void (*func)(int));
void g_signal_hang_up(void (*func)(int));
@@ -136,7 +136,7 @@ void g_signal_pipe(void (*func)(int));
void g_signal_usr1(void (*func)(int));
int g_fork(void);
int g_setgid(int pid);
-int g_initgroups(const char* user, int gid);
+int g_initgroups(const char *user, int gid);
int g_getuid(void);
int g_getgid(void);
int g_setuid(int pid);
@@ -146,21 +146,21 @@ int g_setlogin(const char *name);
int g_waitchild(void);
int g_waitpid(int pid);
void g_clearenv(void);
-int g_setenv(const char* name, const char* value, int rewrite);
-char* g_getenv(const char* name);
+int g_setenv(const char *name, const char *value, int rewrite);
+char *g_getenv(const char *name);
int g_exit(int exit_code);
int g_getpid(void);
int g_sigterm(int pid);
-int g_getuser_info(const char* username, int* gid, int* uid, char** shell,
- char** dir, char** gecos);
-int g_getgroup_info(const char* groupname, int* gid);
-int g_check_user_in_group(const char* username, int gid, int* ok);
+int g_getuser_info(const char *username, int *gid, int *uid, char **shell,
+ char **dir, char **gecos);
+int g_getgroup_info(const char *groupname, int *gid);
+int g_check_user_in_group(const char *username, int gid, int *ok);
int g_time1(void);
int g_time2(void);
int g_time3(void);
-int g_save_to_bmp(const char* filename, char* data, int stride_bytes,
- int width, int height, int depth, int bits_per_pixel);
-void * g_shmat(int shmid);
+int g_save_to_bmp(const char *filename, char *data, int stride_bytes,
+ int width, int height, int depth, int bits_per_pixel);
+void *g_shmat(int shmid);
int g_shmdt(const void *shmaddr);
int g_gethostname(char *name, int len);
int g_mirror_memcpy(void *dst, const void *src, int len);
diff --git a/common/parse.h b/common/parse.h
index 4be6fbef..0e14a3cc 100644
--- a/common/parse.h
+++ b/common/parse.h
@@ -62,7 +62,7 @@ struct stream
/******************************************************************************/
/**
- * @returns true if there are at least n bytes remaining in the stream,
+ * @returns true if there are at least n bytes remaining in the stream,
* else false and logs an error message
*/
#define s_check_rem_and_log(s, n, msg_prefix) \
@@ -71,14 +71,14 @@ struct stream
LOG(LOG_LEVEL_ERROR, \
"%s Not enough bytes in the stream: expected %d, remaining %d", \
(msg_prefix), (n), s_rem(s)) \
- && 0 )
+ && 0 )
/******************************************************************************/
#define s_check_rem_out(s, n) ((s)->p + (n) <= (s)->data + (s)->size)
/******************************************************************************/
/**
- * @returns true if there are at least n bytes remaining in the stream,
+ * @returns true if there are at least n bytes remaining in the stream,
* else false and logs an error message
*/
#define s_check_rem_out_and_log(s, n, msg_prefix) \
@@ -87,14 +87,14 @@ struct stream
LOG(LOG_LEVEL_ERROR, \
"%s Not enough bytes in the stream: expected %d, remaining %d", \
(msg_prefix), (n), s_rem_out(s)) \
- && 0 )
-
+ && 0 )
+
/******************************************************************************/
#define s_check_end(s) ((s)->p == (s)->end)
/******************************************************************************/
/**
- * @returns true if there are exactly 0 bytes remaining in the stream,
+ * @returns true if there are exactly 0 bytes remaining in the stream,
* else false and logs an error message
*/
#define s_check_end_and_log(s, msg_prefix) \
@@ -104,7 +104,7 @@ struct stream
"%s Expected to be at the end of the stream, " \
"but there are %d bytes remaining", \
(msg_prefix), s_rem(s)) \
- && 0 )
+ && 0 )
/******************************************************************************/
#define s_rem(s) ((int) ((s)->end - (s)->p))
@@ -118,34 +118,34 @@ struct stream
/******************************************************************************/
#define init_stream(s, v) do \
-{ \
- if ((v) > (s)->size) \
{ \
- g_free((s)->data); \
- (s)->data = (char*)g_malloc((v), 0); \
- (s)->size = (v); \
- } \
- (s)->p = (s)->data; \
- (s)->end = (s)->data; \
- (s)->next_packet = 0; \
-} while (0)
+ if ((v) > (s)->size) \
+ { \
+ g_free((s)->data); \
+ (s)->data = (char*)g_malloc((v), 0); \
+ (s)->size = (v); \
+ } \
+ (s)->p = (s)->data; \
+ (s)->end = (s)->data; \
+ (s)->next_packet = 0; \
+ } while (0)
/******************************************************************************/
#define free_stream(s) do \
-{ \
- if ((s) != 0) \
{ \
- g_free((s)->data); \
- } \
- g_free((s)); \
-} while (0)
+ if ((s) != 0) \
+ { \
+ g_free((s)->data); \
+ } \
+ g_free((s)); \
+ } while (0)
/******************************************************************************/
#define s_push_layer(s, h, n) do \
-{ \
- (s)->h = (s)->p; \
- (s)->p += (n); \
-} while (0)
+ { \
+ (s)->h = (s)->p; \
+ (s)->p += (n); \
+ } while (0)
/******************************************************************************/
#define s_pop_layer(s, h) \
@@ -156,238 +156,238 @@ struct stream
(s)->end = (s)->p
#define in_sint8(s, v) do \
-{ \
- (v) = *((signed char*)((s)->p)); \
- (s)->p++; \
-} while (0)
+ { \
+ (v) = *((signed char*)((s)->p)); \
+ (s)->p++; \
+ } while (0)
/******************************************************************************/
#define in_uint8(s, v) do \
-{ \
- (v) = *((unsigned char*)((s)->p)); \
- (s)->p++; \
-} while (0)
+ { \
+ (v) = *((unsigned char*)((s)->p)); \
+ (s)->p++; \
+ } while (0)
/******************************************************************************/
#define in_uint8_peek(s, v) do { v = *s->p; } while (0)
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define in_sint16_le(s, v) do \
-{ \
- (v) = (signed short) \
- ( \
- (*((unsigned char*)((s)->p + 0)) << 0) | \
- (*((unsigned char*)((s)->p + 1)) << 8) \
- ); \
- (s)->p += 2; \
-} while (0)
+ { \
+ (v) = (signed short) \
+ ( \
+ (*((unsigned char*)((s)->p + 0)) << 0) | \
+ (*((unsigned char*)((s)->p + 1)) << 8) \
+ ); \
+ (s)->p += 2; \
+ } while (0)
#else
#define in_sint16_le(s, v) do \
-{ \
- (v) = *((signed short*)((s)->p)); \
- (s)->p += 2; \
-} while (0)
+ { \
+ (v) = *((signed short*)((s)->p)); \
+ (s)->p += 2; \
+ } while (0)
#endif
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define in_uint16_le(s, v) do \
-{ \
- (v) = (unsigned short) \
- ( \
- (*((unsigned char*)((s)->p + 0)) << 0) | \
- (*((unsigned char*)((s)->p + 1)) << 8) \
- ); \
- (s)->p += 2; \
-} while (0)
+ { \
+ (v) = (unsigned short) \
+ ( \
+ (*((unsigned char*)((s)->p + 0)) << 0) | \
+ (*((unsigned char*)((s)->p + 1)) << 8) \
+ ); \
+ (s)->p += 2; \
+ } while (0)
#else
#define in_uint16_le(s, v) do \
-{ \
- (v) = *((unsigned short*)((s)->p)); \
- (s)->p += 2; \
-} while (0)
+ { \
+ (v) = *((unsigned short*)((s)->p)); \
+ (s)->p += 2; \
+ } while (0)
#endif
/******************************************************************************/
#define in_uint16_be(s, v) do \
-{ \
- (v) = *((unsigned char*)((s)->p)); \
- (s)->p++; \
- (v) <<= 8; \
- (v) |= *((unsigned char*)((s)->p)); \
- (s)->p++; \
-} while (0)
+ { \
+ (v) = *((unsigned char*)((s)->p)); \
+ (s)->p++; \
+ (v) <<= 8; \
+ (v) |= *((unsigned char*)((s)->p)); \
+ (s)->p++; \
+ } while (0)
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define in_uint32_le(s, v) do \
-{ \
- (v) = (unsigned int) \
- ( \
- (*((unsigned char*)((s)->p + 0)) << 0) | \
- (*((unsigned char*)((s)->p + 1)) << 8) | \
- (*((unsigned char*)((s)->p + 2)) << 16) | \
- (*((unsigned char*)((s)->p + 3)) << 24) \
- ); \
- (s)->p += 4; \
-} while (0)
+ { \
+ (v) = (unsigned int) \
+ ( \
+ (*((unsigned char*)((s)->p + 0)) << 0) | \
+ (*((unsigned char*)((s)->p + 1)) << 8) | \
+ (*((unsigned char*)((s)->p + 2)) << 16) | \
+ (*((unsigned char*)((s)->p + 3)) << 24) \
+ ); \
+ (s)->p += 4; \
+ } while (0)
#else
#define in_uint32_le(s, v) do \
-{ \
- (v) = *((unsigned int*)((s)->p)); \
- (s)->p += 4; \
-} while (0)
+ { \
+ (v) = *((unsigned int*)((s)->p)); \
+ (s)->p += 4; \
+ } while (0)
#endif
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define in_uint64_le(s, v) do \
-{ \
- (v) = (tui64) \
- ( \
- (((tui64)(*((unsigned char*)((s)->p + 0)))) << 0) | \
- (((tui64)(*((unsigned char*)((s)->p + 1)))) << 8) | \
- (((tui64)(*((unsigned char*)((s)->p + 2)))) << 16) | \
- (((tui64)(*((unsigned char*)((s)->p + 3)))) << 24) | \
- (((tui64)(*((unsigned char*)((s)->p + 4)))) << 32) | \
- (((tui64)(*((unsigned char*)((s)->p + 5)))) << 40) | \
- (((tui64)(*((unsigned char*)((s)->p + 6)))) << 48) | \
- (((tui64)(*((unsigned char*)((s)->p + 7)))) << 56) \
- ); \
- (s)->p += 8; \
-} while (0)
+ { \
+ (v) = (tui64) \
+ ( \
+ (((tui64)(*((unsigned char*)((s)->p + 0)))) << 0) | \
+ (((tui64)(*((unsigned char*)((s)->p + 1)))) << 8) | \
+ (((tui64)(*((unsigned char*)((s)->p + 2)))) << 16) | \
+ (((tui64)(*((unsigned char*)((s)->p + 3)))) << 24) | \
+ (((tui64)(*((unsigned char*)((s)->p + 4)))) << 32) | \
+ (((tui64)(*((unsigned char*)((s)->p + 5)))) << 40) | \
+ (((tui64)(*((unsigned char*)((s)->p + 6)))) << 48) | \
+ (((tui64)(*((unsigned char*)((s)->p + 7)))) << 56) \
+ ); \
+ (s)->p += 8; \
+ } while (0)
#else
#define in_uint64_le(s, v) do \
-{ \
- (v) = *((tui64*)((s)->p)); \
- (s)->p += 8; \
-} while (0)
+ { \
+ (v) = *((tui64*)((s)->p)); \
+ (s)->p += 8; \
+ } while (0)
#endif
/******************************************************************************/
#define in_uint32_be(s, v) do \
-{ \
- (v) = *((unsigned char*)((s)->p)); \
- (s)->p++; \
- (v) <<= 8; \
- (v) |= *((unsigned char*)((s)->p)); \
- (s)->p++; \
- (v) <<= 8; \
- (v) |= *((unsigned char*)((s)->p)); \
- (s)->p++; \
- (v) <<= 8; \
- (v) |= *((unsigned char*)((s)->p)); \
- (s)->p++; \
-} while (0)
+ { \
+ (v) = *((unsigned char*)((s)->p)); \
+ (s)->p++; \
+ (v) <<= 8; \
+ (v) |= *((unsigned char*)((s)->p)); \
+ (s)->p++; \
+ (v) <<= 8; \
+ (v) |= *((unsigned char*)((s)->p)); \
+ (s)->p++; \
+ (v) <<= 8; \
+ (v) |= *((unsigned char*)((s)->p)); \
+ (s)->p++; \
+ } while (0)
/******************************************************************************/
#define out_uint8(s, v) do \
-{ \
- *((s)->p) = (unsigned char)(v); \
- (s)->p++; \
-} while (0)
+ { \
+ *((s)->p) = (unsigned char)(v); \
+ (s)->p++; \
+ } while (0)
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define out_uint16_le(s, v) do \
-{ \
- *((s)->p) = (unsigned char)((v) >> 0); \
- (s)->p++; \
- *((s)->p) = (unsigned char)((v) >> 8); \
- (s)->p++; \
-} while (0)
+ { \
+ *((s)->p) = (unsigned char)((v) >> 0); \
+ (s)->p++; \
+ *((s)->p) = (unsigned char)((v) >> 8); \
+ (s)->p++; \
+ } while (0)
#else
#define out_uint16_le(s, v) do \
-{ \
- *((unsigned short*)((s)->p)) = (unsigned short)(v); \
- (s)->p += 2; \
-} while (0)
+ { \
+ *((unsigned short*)((s)->p)) = (unsigned short)(v); \
+ (s)->p += 2; \
+ } while (0)
#endif
/******************************************************************************/
#define out_uint16_be(s, v) do \
-{ \
- *((s)->p) = (unsigned char)((v) >> 8); \
- (s)->p++; \
- *((s)->p) = (unsigned char)((v) >> 0); \
- (s)->p++; \
-} while (0)
+ { \
+ *((s)->p) = (unsigned char)((v) >> 8); \
+ (s)->p++; \
+ *((s)->p) = (unsigned char)((v) >> 0); \
+ (s)->p++; \
+ } while (0)
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define out_uint32_le(s, v) do \
-{ \
- *((s)->p) = (unsigned char)((v) >> 0); \
- (s)->p++; \
- *((s)->p) = (unsigned char)((v) >> 8); \
- (s)->p++; \
- *((s)->p) = (unsigned char)((v) >> 16); \
- (s)->p++; \
- *((s)->p) = (unsigned char)((v) >> 24); \
- (s)->p++; \
-} while (0)
+ { \
+ *((s)->p) = (unsigned char)((v) >> 0); \
+ (s)->p++; \
+ *((s)->p) = (unsigned char)((v) >> 8); \
+ (s)->p++; \
+ *((s)->p) = (unsigned char)((v) >> 16); \
+ (s)->p++; \
+ *((s)->p) = (unsigned char)((v) >> 24); \
+ (s)->p++; \
+ } while (0)
#else
#define out_uint32_le(s, v) do \
-{ \
- *((unsigned int*)((s)->p)) = (v); \
- (s)->p += 4; \
-} while (0)
+ { \
+ *((unsigned int*)((s)->p)) = (v); \
+ (s)->p += 4; \
+ } while (0)
#endif
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define out_uint64_le(s, v) do \
-{ \
- *((s)->p) = (unsigned char)((v) >> 0); \
- (s)->p++; \
- *((s)->p) = (unsigned char)((v) >> 8); \
- (s)->p++; \
- *((s)->p) = (unsigned char)((v) >> 16); \
- (s)->p++; \
- *((s)->p) = (unsigned char)((v) >> 24); \
- (s)->p++; \
- *((s)->p) = (unsigned char)((v) >> 32); \
- (s)->p++; \
- *((s)->p) = (unsigned char)((v) >> 40); \
- (s)->p++; \
- *((s)->p) = (unsigned char)((v) >> 48); \
- (s)->p++; \
- *((s)->p) = (unsigned char)((v) >> 56); \
- (s)->p++; \
-} while (0)
+ { \
+ *((s)->p) = (unsigned char)((v) >> 0); \
+ (s)->p++; \
+ *((s)->p) = (unsigned char)((v) >> 8); \
+ (s)->p++; \
+ *((s)->p) = (unsigned char)((v) >> 16); \
+ (s)->p++; \
+ *((s)->p) = (unsigned char)((v) >> 24); \
+ (s)->p++; \
+ *((s)->p) = (unsigned char)((v) >> 32); \
+ (s)->p++; \
+ *((s)->p) = (unsigned char)((v) >> 40); \
+ (s)->p++; \
+ *((s)->p) = (unsigned char)((v) >> 48); \
+ (s)->p++; \
+ *((s)->p) = (unsigned char)((v) >> 56); \
+ (s)->p++; \
+ } while (0)
#else
#define out_uint64_le(s, v) do \
-{ \
- *((tui64*)((s)->p)) = (v); \
- (s)->p += 8; \
-} while (0)
+ { \
+ *((tui64*)((s)->p)) = (v); \
+ (s)->p += 8; \
+ } while (0)
#endif
/******************************************************************************/
#define out_uint32_be(s, v) do \
-{ \
- *((s)->p) = (unsigned char)((v) >> 24); \
- s->p++; \
- *((s)->p) = (unsigned char)((v) >> 16); \
- s->p++; \
- *((s)->p) = (unsigned char)((v) >> 8); \
- s->p++; \
- *((s)->p) = (unsigned char)(v); \
- (s)->p++; \
-} while (0)
+ { \
+ *((s)->p) = (unsigned char)((v) >> 24); \
+ s->p++; \
+ *((s)->p) = (unsigned char)((v) >> 16); \
+ s->p++; \
+ *((s)->p) = (unsigned char)((v) >> 8); \
+ s->p++; \
+ *((s)->p) = (unsigned char)(v); \
+ (s)->p++; \
+ } while (0)
/******************************************************************************/
#define in_uint8p(s, v, n) do \
-{ \
- (v) = (s)->p; \
- (s)->p += (n); \
-} while (0)
+ { \
+ (v) = (s)->p; \
+ (s)->p += (n); \
+ } while (0)
/******************************************************************************/
#define in_uint8a(s, v, n) do \
-{ \
- g_memcpy((v), (s)->p, (n)); \
- (s)->p += (n); \
-} while (0)
+ { \
+ g_memcpy((v), (s)->p, (n)); \
+ (s)->p += (n); \
+ } while (0)
/******************************************************************************/
#define in_uint8s(s, n) \
@@ -395,10 +395,10 @@ struct stream
/******************************************************************************/
#define out_uint8p(s, v, n) do \
-{ \
- g_memcpy((s)->p, (v), (n)); \
- (s)->p += (n); \
-} while (0)
+ { \
+ g_memcpy((s)->p, (v), (n)); \
+ (s)->p += (n); \
+ } while (0)
/******************************************************************************/
#define out_uint8a(s, v, n) \
@@ -406,10 +406,10 @@ struct stream
/******************************************************************************/
#define out_uint8s(s, n) do \
-{ \
- g_memset((s)->p, 0, (n)); \
- (s)->p += (n); \
-} while (0)
+ { \
+ g_memset((s)->p, 0, (n)); \
+ (s)->p += (n); \
+ } while (0)
/*
* @brief allocate a new stream
@@ -418,11 +418,11 @@ struct stream
* @param _l length of new stream
******************************************************************************/
#define xstream_new(_s, _l) \
-do \
-{ \
- make_stream((_s)); \
- init_stream((_s), (_l)); \
-} while (0)
+ do \
+ { \
+ make_stream((_s)); \
+ init_stream((_s), (_l)); \
+ } while (0)
/**
* @brief release a previously allocated stream
@@ -448,63 +448,63 @@ do \
#define xstream_wr_s32_le(_s, _var) TODO
#define xstream_rd_u64_le(_s, _v) \
-do \
-{ \
- _v = \
- (tui64)(*((unsigned char *)_s->p)) | \
- (((tui64) (*(((unsigned char *)_s->p) + 1))) << 8) | \
- (((tui64) (*(((unsigned char *)_s->p) + 2))) << 16) | \
- (((tui64) (*(((unsigned char *)_s->p) + 3))) << 24) | \
- (((tui64) (*(((unsigned char *)_s->p) + 4))) << 32) | \
- (((tui64) (*(((unsigned char *)_s->p) + 5))) << 40) | \
- (((tui64) (*(((unsigned char *)_s->p) + 6))) << 48) | \
- (((tui64) (*(((unsigned char *)_s->p) + 7))) << 56); \
- _s->p += 8; \
-} while (0)
+ do \
+ { \
+ _v = \
+ (tui64)(*((unsigned char *)_s->p)) | \
+ (((tui64) (*(((unsigned char *)_s->p) + 1))) << 8) | \
+ (((tui64) (*(((unsigned char *)_s->p) + 2))) << 16) | \
+ (((tui64) (*(((unsigned char *)_s->p) + 3))) << 24) | \
+ (((tui64) (*(((unsigned char *)_s->p) + 4))) << 32) | \
+ (((tui64) (*(((unsigned char *)_s->p) + 5))) << 40) | \
+ (((tui64) (*(((unsigned char *)_s->p) + 6))) << 48) | \
+ (((tui64) (*(((unsigned char *)_s->p) + 7))) << 56); \
+ _s->p += 8; \
+ } while (0)
#define xstream_wr_u64_le(_s, _v) \
-do \
-{ \
- *(((unsigned char *) _s->p) + 0) = (unsigned char) ((_v >> 0) & 0xff); \
- *(((unsigned char *) _s->p) + 1) = (unsigned char) ((_v >> 8) & 0xff); \
- *(((unsigned char *) _s->p) + 2) = (unsigned char) ((_v >> 16) & 0xff); \
- *(((unsigned char *) _s->p) + 3) = (unsigned char) ((_v >> 24) & 0xff); \
- *(((unsigned char *) _s->p) + 4) = (unsigned char) ((_v >> 32) & 0xff); \
- *(((unsigned char *) _s->p) + 5) = (unsigned char) ((_v >> 40) & 0xff); \
- *(((unsigned char *) _s->p) + 6) = (unsigned char) ((_v >> 48) & 0xff); \
- *(((unsigned char *) _s->p) + 7) = (unsigned char) ((_v >> 56) & 0xff); \
- _s->p += 8; \
-} while (0)
+ do \
+ { \
+ *(((unsigned char *) _s->p) + 0) = (unsigned char) ((_v >> 0) & 0xff); \
+ *(((unsigned char *) _s->p) + 1) = (unsigned char) ((_v >> 8) & 0xff); \
+ *(((unsigned char *) _s->p) + 2) = (unsigned char) ((_v >> 16) & 0xff); \
+ *(((unsigned char *) _s->p) + 3) = (unsigned char) ((_v >> 24) & 0xff); \
+ *(((unsigned char *) _s->p) + 4) = (unsigned char) ((_v >> 32) & 0xff); \
+ *(((unsigned char *) _s->p) + 5) = (unsigned char) ((_v >> 40) & 0xff); \
+ *(((unsigned char *) _s->p) + 6) = (unsigned char) ((_v >> 48) & 0xff); \
+ *(((unsigned char *) _s->p) + 7) = (unsigned char) ((_v >> 56) & 0xff); \
+ _s->p += 8; \
+ } while (0)
/* copy data into stream */
#define xstream_copyin(_s, _dest, _len) \
-do \
-{ \
- g_memcpy((_s)->p, (_dest), (_len)); \
- (_s)->p += (_len); \
-} while (0)
+ do \
+ { \
+ g_memcpy((_s)->p, (_dest), (_len)); \
+ (_s)->p += (_len); \
+ } while (0)
/* copy data out of stream */
#define xstream_copyout(_dest, _s, _len) \
-do \
-{ \
- g_memcpy((_dest), (_s)->p, (_len)); \
- (_s)->p += (_len); \
-} while (0)
+ do \
+ { \
+ g_memcpy((_dest), (_s)->p, (_len)); \
+ (_s)->p += (_len); \
+ } while (0)
#define xstream_rd_string(_dest, _s, _len) \
-do \
-{ \
- g_memcpy((_dest), (_s)->p, (_len)); \
- (_s)->p += (_len); \
-} while (0)
+ do \
+ { \
+ g_memcpy((_dest), (_s)->p, (_len)); \
+ (_s)->p += (_len); \
+ } while (0)
#define xstream_wr_string(_s, _src, _len) \
-do \
-{ \
- g_memcpy((_s)->p, (_src), (_len)); \
- (_s)->p += (_len); \
-} while (0)
+ do \
+ { \
+ g_memcpy((_s)->p, (_src), (_len)); \
+ (_s)->p += (_len); \
+ } while (0)
#define xstream_len(_s) (int) ((_s)->p - (_s)->data)
#define xstream_seek(_s, _len) (_s)->p += (_len)
diff --git a/common/pixman-region.c b/common/pixman-region.c
index 8896b241..464faf02 100644
--- a/common/pixman-region.c
+++ b/common/pixman-region.c
@@ -1,31 +1,31 @@
/*
* Copyright 1987, 1988, 1989, 1998 The Open Group
- *
+ *
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation.
- *
+ *
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
+ *
* Except as contained in this notice, the name of The Open Group shall not be
* used in advertising or otherwise to promote the sale, use or other dealings
* in this Software without prior written authorization from The Open Group.
- *
+ *
* Copyright 1987, 1988, 1989 by
* Digital Equipment Corporation, Maynard, Massachusetts.
- *
+ *
* All Rights Reserved
- *
+ *
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notice appear in all copies and that
@@ -33,7 +33,7 @@
* supporting documentation, and that the name of Digital not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
- *
+ *
* DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
@@ -115,11 +115,11 @@ static const region_data_type_t PREFIX (_broken_data_) = { 0, 0 };
#endif
static box_type_t *pixman_region_empty_box =
- (box_type_t *)&PREFIX (_empty_box_);
+ (box_type_t *) &PREFIX (_empty_box_);
static region_data_type_t *pixman_region_empty_data =
- (region_data_type_t *)&PREFIX (_empty_data_);
+ (region_data_type_t *) &PREFIX (_empty_data_);
static region_data_type_t *pixman_broken_data =
- (region_data_type_t *)&PREFIX (_broken_data_);
+ (region_data_type_t *) &PREFIX (_broken_data_);
static pixman_bool_t
pixman_break (region_type_t *region);
@@ -198,12 +198,16 @@ static size_t
PIXREGION_SZOF (size_t n)
{
size_t size = n * sizeof(box_type_t);
-
+
if (n > UINT32_MAX / sizeof(box_type_t))
+ {
return 0;
+ }
if (sizeof(region_data_type_t) > UINT32_MAX - size)
+ {
return 0;
+ }
return size + sizeof(region_data_type_t);
}
@@ -214,7 +218,9 @@ alloc_data (size_t n)
size_t sz = PIXREGION_SZOF (n);
if (!sz)
+ {
return NULL;
+ }
return (region_data_type_t *) malloc(sz);
}
@@ -225,7 +231,7 @@ alloc_data (size_t n)
do \
{ \
if (!(region)->data || \
- (((region)->data->numRects + (n)) > (region)->data->size)) \
+ (((region)->data->numRects + (n)) > (region)->data->size)) \
{ \
if (!pixman_rect_alloc (region, n)) \
goto bail; \
@@ -236,7 +242,7 @@ alloc_data (size_t n)
do \
{ \
if (!(region)->data || \
- (((region)->data->numRects + (n)) > (region)->data->size)) \
+ (((region)->data->numRects + (n)) > (region)->data->size)) \
{ \
if (!pixman_rect_alloc (region, n)) { \
return FALSE; \
@@ -259,7 +265,7 @@ alloc_data (size_t n)
do \
{ \
if (!(region)->data || \
- ((region)->data->numRects == (region)->data->size)) \
+ ((region)->data->numRects == (region)->data->size)) \
{ \
if (!pixman_rect_alloc (region, 1)) \
return FALSE; \
@@ -274,11 +280,11 @@ alloc_data (size_t n)
do \
{ \
if (((numRects) < ((reg)->data->size >> 1)) && \
- ((reg)->data->size > 50)) \
+ ((reg)->data->size > 50)) \
{ \
region_data_type_t * new_data; \
size_t data_size = PIXREGION_SZOF (numRects); \
- \
+ \
if (!data_size) \
{ \
new_data = NULL; \
@@ -286,9 +292,9 @@ alloc_data (size_t n)
else \
{ \
new_data = (region_data_type_t *) \
- realloc ((reg)->data, data_size); \
+ realloc ((reg)->data, data_size); \
} \
- \
+ \
if (new_data) \
{ \
new_data->size = (numRects); \
@@ -305,36 +311,54 @@ PREFIX (_equal) (region_type_t *reg1, region_type_t *reg2)
box_type_t *rects2;
if (reg1->extents.x1 != reg2->extents.x1)
+ {
return FALSE;
-
+ }
+
if (reg1->extents.x2 != reg2->extents.x2)
+ {
return FALSE;
-
+ }
+
if (reg1->extents.y1 != reg2->extents.y1)
+ {
return FALSE;
-
+ }
+
if (reg1->extents.y2 != reg2->extents.y2)
+ {
return FALSE;
-
+ }
+
if (PIXREGION_NUMRECTS (reg1) != PIXREGION_NUMRECTS (reg2))
+ {
return FALSE;
+ }
rects1 = PIXREGION_RECTS (reg1);
rects2 = PIXREGION_RECTS (reg2);
-
+
for (i = 0; i != PIXREGION_NUMRECTS (reg1); i++)
{
if (rects1[i].x1 != rects2[i].x1)
+ {
return FALSE;
-
+ }
+
if (rects1[i].x2 != rects2[i].x2)
+ {
return FALSE;
-
+ }
+
if (rects1[i].y1 != rects2[i].y1)
+ {
return FALSE;
-
+ }
+
if (rects1[i].y2 != rects2[i].y2)
+ {
return FALSE;
+ }
}
return TRUE;
@@ -345,7 +369,7 @@ PREFIX (_print) (region_type_t *rgn)
{
int num, size;
int i;
- box_type_t * rects;
+ box_type_t *rects;
num = PIXREGION_NUMRECTS (rgn);
size = PIXREGION_SIZE (rgn);
@@ -357,16 +381,16 @@ PREFIX (_print) (region_type_t *rgn)
rgn->extents.y1,
rgn->extents.x2,
rgn->extents.y2);
-
+
for (i = 0; i < num; i++)
{
fprintf (stderr, "%d %d %d %d \n",
rects[i].x1, rects[i].y1, rects[i].x2, rects[i].y2);
}
-
+
fprintf (stderr, "\n");
- return(num);
+ return (num);
}
@@ -378,7 +402,7 @@ PREFIX (_init) (region_type_t *region)
}
PIXMAN_EXPORT void
-PREFIX (_init_rect) (region_type_t * region,
+PREFIX (_init_rect) (region_type_t *region,
int x,
int y,
unsigned int width,
@@ -392,7 +416,9 @@ PREFIX (_init_rect) (region_type_t * region,
if (!GOOD_RECT (&region->extents))
{
if (BAD_RECT (&region->extents))
+ {
_pixman_log_error (FUNC, "Invalid rectangle passed");
+ }
PREFIX (_init) (region);
return;
}
@@ -406,7 +432,9 @@ PREFIX (_init_with_extents) (region_type_t *region, box_type_t *extents)
if (!GOOD_RECT (extents))
{
if (BAD_RECT (extents))
+ {
_pixman_log_error (FUNC, "Invalid rectangle passed");
+ }
PREFIX (_init) (region);
return;
}
@@ -433,7 +461,9 @@ PREFIX (_rectangles) (region_type_t *region,
int *n_rects)
{
if (n_rects)
+ {
*n_rects = PIXREGION_NUMRECTS (region);
+ }
return PIXREGION_RECTS (region);
}
@@ -450,7 +480,7 @@ pixman_break (region_type_t *region)
}
static pixman_bool_t
-pixman_rect_alloc (region_type_t * region,
+pixman_rect_alloc (region_type_t *region,
int n)
{
region_data_type_t *data;
@@ -461,7 +491,9 @@ pixman_rect_alloc (region_type_t * region,
region->data = alloc_data (n);
if (!region->data)
+ {
return pixman_break (region);
+ }
region->data->numRects = 1;
*PIXREGION_BOXPTR (region) = region->extents;
@@ -471,7 +503,9 @@ pixman_rect_alloc (region_type_t * region,
region->data = alloc_data (n);
if (!region->data)
+ {
return pixman_break (region);
+ }
region->data->numRects = 0;
}
@@ -483,7 +517,9 @@ pixman_rect_alloc (region_type_t * region,
{
n = region->data->numRects;
if (n > 500) /* XXX pick numbers out of a hat */
+ {
n = 250;
+ }
}
n += region->data->numRects;
@@ -496,15 +532,17 @@ pixman_rect_alloc (region_type_t * region,
else
{
data = (region_data_type_t *)
- realloc (region->data, PIXREGION_SZOF (n));
+ realloc (region->data, PIXREGION_SZOF (n));
}
-
+
if (!data)
+ {
return pixman_break (region);
-
+ }
+
region->data = data;
}
-
+
region->data->size = n;
return TRUE;
@@ -517,8 +555,10 @@ PREFIX (_copy) (region_type_t *dst, region_type_t *src)
GOOD (src);
if (dst == src)
+ {
return TRUE;
-
+ }
+
dst->extents = src->extents;
if (!src->data || !src->data->size)
@@ -527,7 +567,7 @@ PREFIX (_copy) (region_type_t *dst, region_type_t *src)
dst->data = src->data;
return TRUE;
}
-
+
if (!dst->data || (dst->data->size < src->data->numRects))
{
FREE_DATA (dst);
@@ -535,7 +575,9 @@ PREFIX (_copy) (region_type_t *dst, region_type_t *src)
dst->data = alloc_data (src->data->numRects);
if (!dst->data)
+ {
return pixman_break (dst);
+ }
dst->data->size = src->data->numRects;
}
@@ -571,7 +613,7 @@ PREFIX (_copy) (region_type_t *dst, region_type_t *src)
*-----------------------------------------------------------------------
*/
static inline int
-pixman_coalesce (region_type_t * region, /* Region to coalesce */
+pixman_coalesce (region_type_t *region, /* Region to coalesce */
int prev_start, /* Index of start of previous band */
int cur_start) /* Index of start of current band */
{
@@ -586,7 +628,10 @@ pixman_coalesce (region_type_t * region, /* Region to coalesce
numRects = cur_start - prev_start;
critical_if_fail (numRects == region->data->numRects - cur_start);
- if (!numRects) return cur_start;
+ if (!numRects)
+ {
+ return cur_start;
+ }
/*
* The bands may only be coalesced if the bottom of the previous
@@ -594,7 +639,10 @@ pixman_coalesce (region_type_t * region, /* Region to coalesce
*/
prev_box = PIXREGION_BOX (region, prev_start);
cur_box = PIXREGION_BOX (region, cur_start);
- if (prev_box->y2 != cur_box->y1) return cur_start;
+ if (prev_box->y2 != cur_box->y1)
+ {
+ return cur_start;
+ }
/*
* Make sure the bands have boxes in the same places. This
@@ -607,8 +655,10 @@ pixman_coalesce (region_type_t * region, /* Region to coalesce
do
{
if ((prev_box->x1 != cur_box->x1) || (prev_box->x2 != cur_box->x2))
+ {
return (cur_start);
-
+ }
+
prev_box++;
cur_box++;
numRects--;
@@ -661,9 +711,9 @@ pixman_coalesce (region_type_t * region, /* Region to coalesce
*-----------------------------------------------------------------------
*/
static inline pixman_bool_t
-pixman_region_append_non_o (region_type_t * region,
- box_type_t * r,
- box_type_t * r_end,
+pixman_region_append_non_o (region_type_t *region,
+ box_type_t *r,
+ box_type_t *r_end,
int y1,
int y2)
{
@@ -743,26 +793,26 @@ pixman_region_append_non_o (region_type_t * region,
*/
typedef pixman_bool_t (*overlap_proc_ptr) (region_type_t *region,
- box_type_t * r1,
- box_type_t * r1_end,
- box_type_t * r2,
- box_type_t * r2_end,
- int y1,
- int y2);
+ box_type_t *r1,
+ box_type_t *r1_end,
+ box_type_t *r2,
+ box_type_t *r2_end,
+ int y1,
+ int y2);
static pixman_bool_t
-pixman_op (region_type_t * new_reg, /* Place to store result */
- region_type_t * reg1, /* First region in operation */
- region_type_t * reg2, /* 2d region in operation */
+pixman_op (region_type_t *new_reg, /* Place to store result */
+ region_type_t *reg1, /* First region in operation */
+ region_type_t *reg2, /* 2d region in operation */
overlap_proc_ptr overlap_func, /* Function to call for over-
* lapping bands */
- int append_non1, /* Append non-overlapping bands
+ int append_non1, /* Append non-overlapping bands
* in region 1 ?
*/
int append_non2 /* Append non-overlapping bands
* in region 2 ?
*/
- )
+ )
{
box_type_t *r1; /* Pointer into first region */
box_type_t *r2; /* Pointer into 2d region */
@@ -775,8 +825,8 @@ pixman_op (region_type_t * new_reg, /* Place to store result
* previous band in new_reg */
int cur_band; /* Index of start of current
* band in new_reg */
- box_type_t * r1_band_end; /* End of current band in r1 */
- box_type_t * r2_band_end; /* End of current band in r2 */
+ box_type_t *r1_band_end; /* End of current band in r1 */
+ box_type_t *r2_band_end; /* End of current band in r2 */
int top; /* Top of non-overlapping band */
int bot; /* Bottom of non-overlapping band*/
int r1y1; /* Temps for r1->y1 and r2->y1 */
@@ -788,7 +838,9 @@ pixman_op (region_type_t * new_reg, /* Place to store result
* Break any region computed from a broken region
*/
if (PIXREGION_NAR (reg1) || PIXREGION_NAR (reg2))
+ {
return pixman_break (new_reg);
+ }
/*
* Initialization:
@@ -805,14 +857,14 @@ pixman_op (region_type_t * new_reg, /* Place to store result
numRects = PIXREGION_NUMRECTS (reg2);
r2 = PIXREGION_RECTS (reg2);
r2_end = r2 + numRects;
-
+
critical_if_fail (r1 != r1_end);
critical_if_fail (r2 != r2_end);
old_data = (region_data_type_t *)NULL;
if (((new_reg == reg1) && (new_size > 1)) ||
- ((new_reg == reg2) && (numRects > 1)))
+ ((new_reg == reg2) && (numRects > 1)))
{
old_data = new_reg->data;
new_reg->data = pixman_region_empty_data;
@@ -820,14 +872,20 @@ pixman_op (region_type_t * new_reg, /* Place to store result
/* guess at new size */
if (numRects > new_size)
+ {
new_size = numRects;
+ }
new_size <<= 1;
if (!new_reg->data)
+ {
new_reg->data = pixman_region_empty_data;
+ }
else if (new_reg->data->size)
+ {
new_reg->data->numRects = 0;
+ }
if (new_size > new_reg->data->size)
{
@@ -898,7 +956,9 @@ pixman_op (region_type_t * new_reg, /* Place to store result
{
cur_band = new_reg->data->numRects;
if (!pixman_region_append_non_o (new_reg, r1, r1_band_end, top, bot))
+ {
goto bail;
+ }
COALESCE (new_reg, prev_band, cur_band);
}
}
@@ -910,13 +970,15 @@ pixman_op (region_type_t * new_reg, /* Place to store result
{
top = MAX (r2y1, ybot);
bot = MIN (r2->y2, r1y1);
-
+
if (top != bot)
{
cur_band = new_reg->data->numRects;
if (!pixman_region_append_non_o (new_reg, r2, r2_band_end, top, bot))
+ {
goto bail;
+ }
COALESCE (new_reg, prev_band, cur_band);
}
@@ -944,7 +1006,7 @@ pixman_op (region_type_t * new_reg, /* Place to store result
{
goto bail;
}
-
+
COALESCE (new_reg, prev_band, cur_band);
}
@@ -953,10 +1015,14 @@ pixman_op (region_type_t * new_reg, /* Place to store result
* in the region to the next band.
*/
if (r1->y2 == ybot)
+ {
r1 = r1_band_end;
+ }
if (r2->y2 == ybot)
+ {
r2 = r2_band_end;
+ }
}
while (r1 != r1_end && r2 != r2_end);
@@ -973,16 +1039,16 @@ pixman_op (region_type_t * new_reg, /* Place to store result
{
/* Do first non_overlap1Func call, which may be able to coalesce */
FIND_BAND (r1, r1_band_end, r1_end, r1y1);
-
+
cur_band = new_reg->data->numRects;
-
+
if (!pixman_region_append_non_o (new_reg,
r1, r1_band_end,
MAX (r1y1, ybot), r1->y2))
{
goto bail;
}
-
+
COALESCE (new_reg, prev_band, cur_band);
/* Just append the rest of the boxes */
@@ -1055,7 +1121,9 @@ pixman_set_extents (region_type_t *region)
box_type_t *box, *box_end;
if (!region->data)
+ {
return;
+ }
if (!region->data->size)
{
@@ -1084,9 +1152,13 @@ pixman_set_extents (region_type_t *region)
while (box <= box_end)
{
if (box->x1 < region->extents.x1)
+ {
region->extents.x1 = box->x1;
+ }
if (box->x2 > region->extents.x2)
+ {
region->extents.x2 = box->x2;
+ }
box++;
}
@@ -1112,16 +1184,16 @@ pixman_set_extents (region_type_t *region)
/*ARGSUSED*/
static pixman_bool_t
pixman_region_intersect_o (region_type_t *region,
- box_type_t * r1,
- box_type_t * r1_end,
- box_type_t * r2,
- box_type_t * r2_end,
+ box_type_t *r1,
+ box_type_t *r1_end,
+ box_type_t *r2,
+ box_type_t *r2_end,
int y1,
int y2)
{
int x1;
int x2;
- box_type_t * next_rect;
+ box_type_t *next_rect;
next_rect = PIXREGION_TOP (region);
@@ -1138,7 +1210,9 @@ pixman_region_intersect_o (region_type_t *region,
* overlap to the new region.
*/
if (x1 < x2)
+ {
NEWRECT (region, next_rect, x1, y1, x2, y2);
+ }
/*
* Advance the pointer(s) with the leftmost right side, since the next
@@ -1160,9 +1234,9 @@ pixman_region_intersect_o (region_type_t *region,
}
PIXMAN_EXPORT pixman_bool_t
-PREFIX (_intersect) (region_type_t * new_reg,
- region_type_t * reg1,
- region_type_t * reg2)
+PREFIX (_intersect) (region_type_t *new_reg,
+ region_type_t *reg1,
+ region_type_t *reg2)
{
GOOD (reg1);
GOOD (reg2);
@@ -1170,7 +1244,7 @@ PREFIX (_intersect) (region_type_t * new_reg,
/* check for trivial reject */
if (PIXREGION_NIL (reg1) || PIXREGION_NIL (reg2) ||
- !EXTENTCHECK (&reg1->extents, &reg2->extents))
+ !EXTENTCHECK (&reg1->extents, &reg2->extents))
{
/* Covers about 20% of all cases */
FREE_DATA (new_reg);
@@ -1215,13 +1289,15 @@ PREFIX (_intersect) (region_type_t * new_reg,
/* General purpose intersection */
if (!pixman_op (new_reg, reg1, reg2, pixman_region_intersect_o, FALSE, FALSE))
+ {
return FALSE;
-
+ }
+
pixman_set_extents (new_reg);
}
GOOD (new_reg);
- return(TRUE);
+ return (TRUE);
}
#define MERGERECT(r) \
@@ -1264,10 +1340,10 @@ PREFIX (_intersect) (region_type_t * new_reg,
*/
static pixman_bool_t
pixman_region_union_o (region_type_t *region,
- box_type_t * r1,
- box_type_t * r1_end,
- box_type_t * r2,
- box_type_t * r2_end,
+ box_type_t *r1,
+ box_type_t *r1_end,
+ box_type_t *r2,
+ box_type_t *r2_end,
int y1,
int y2)
{
@@ -1296,9 +1372,13 @@ pixman_region_union_o (region_type_t *region,
while (r1 != r1_end && r2 != r2_end)
{
if (r1->x1 < r2->x1)
+ {
MERGERECT (r1);
+ }
else
+ {
MERGERECT (r2);
+ }
}
/* Finish off whoever (if any) is left */
@@ -1361,7 +1441,9 @@ PREFIX (_union) (region_type_t *new_reg,
* Region 1 and 2 are the same
*/
if (reg1 == reg2)
+ {
return PREFIX (_copy) (new_reg, reg1);
+ }
/*
* Region 1 is empty
@@ -1369,10 +1451,14 @@ PREFIX (_union) (region_type_t *new_reg,
if (PIXREGION_NIL (reg1))
{
if (PIXREGION_NAR (reg1))
+ {
return pixman_break (new_reg);
+ }
if (new_reg != reg2)
+ {
return PREFIX (_copy) (new_reg, reg2);
+ }
return TRUE;
}
@@ -1383,10 +1469,14 @@ PREFIX (_union) (region_type_t *new_reg,
if (PIXREGION_NIL (reg2))
{
if (PIXREGION_NAR (reg2))
+ {
return pixman_break (new_reg);
+ }
if (new_reg != reg1)
+ {
return PREFIX (_copy) (new_reg, reg1);
+ }
return TRUE;
}
@@ -1397,7 +1487,9 @@ PREFIX (_union) (region_type_t *new_reg,
if (!reg1->data && SUBSUMES (&reg1->extents, &reg2->extents))
{
if (new_reg != reg1)
+ {
return PREFIX (_copy) (new_reg, reg1);
+ }
return TRUE;
}
@@ -1408,19 +1500,23 @@ PREFIX (_union) (region_type_t *new_reg,
if (!reg2->data && SUBSUMES (&reg2->extents, &reg1->extents))
{
if (new_reg != reg2)
+ {
return PREFIX (_copy) (new_reg, reg2);
+ }
return TRUE;
}
if (!pixman_op (new_reg, reg1, reg2, pixman_region_union_o, TRUE, TRUE))
+ {
return FALSE;
+ }
new_reg->extents.x1 = MIN (reg1->extents.x1, reg2->extents.x1);
new_reg->extents.y1 = MIN (reg1->extents.y1, reg2->extents.y1);
new_reg->extents.x2 = MAX (reg1->extents.x2, reg2->extents.x2);
new_reg->extents.y2 = MAX (reg1->extents.y2, reg2->extents.y2);
-
+
GOOD (new_reg);
return TRUE;
@@ -1447,7 +1543,9 @@ PREFIX (_union_rect) (region_type_t *dest,
if (!GOOD_RECT (&region.extents))
{
if (BAD_RECT (&region.extents))
+ {
_pixman_log_error (FUNC, "Invalid rectangle passed");
+ }
return PREFIX (_copy) (dest, source);
}
@@ -1485,7 +1583,7 @@ quick_sort_rects (
if (numRects == 2)
{
if (rects[0].y1 > rects[1].y1 ||
- (rects[0].y1 == rects[1].y1 && rects[0].x1 > rects[1].x1))
+ (rects[0].y1 == rects[1].y1 && rects[0].x1 > rects[1].x1))
{
EXCHANGE_RECTS (0, 1);
}
@@ -1519,9 +1617,11 @@ quick_sort_rects (
j--;
}
while (y1 < r->y1 || (y1 == r->y1 && x1 < r->x1));
-
+
if (i < j)
+ {
EXCHANGE_RECTS (i, j);
+ }
}
while (i < j);
@@ -1530,7 +1630,9 @@ quick_sort_rects (
/* Recurse */
if (numRects - j - 1 > 1)
+ {
quick_sort_rects (&rects[j + 1], numRects - j - 1);
+ }
numRects = j;
}
@@ -1571,7 +1673,7 @@ quick_sort_rects (
*/
static pixman_bool_t
-validate (region_type_t * badreg)
+validate (region_type_t *badreg)
{
/* Descriptor for regions under construction in Step 2. */
typedef struct
@@ -1601,16 +1703,18 @@ validate (region_type_t * badreg)
GOOD (badreg);
return TRUE;
}
-
+
numRects = badreg->data->numRects;
if (!numRects)
{
if (PIXREGION_NAR (badreg))
+ {
return FALSE;
+ }
GOOD (badreg);
return TRUE;
}
-
+
if (badreg->extents.x1 < badreg->extents.x2)
{
if ((numRects) == 1)
@@ -1670,7 +1774,9 @@ validate (region_type_t * badreg)
{
/* Merge it with ri_box */
if (box->x2 > ri_box->x2)
+ {
ri_box->x2 = box->x2;
+ }
}
else
{
@@ -1678,18 +1784,22 @@ validate (region_type_t * badreg)
*PIXREGION_TOP (reg) = *box;
reg->data->numRects++;
}
-
+
goto next_rect; /* So sue me */
}
else if (box->y1 >= ri_box->y2)
{
/* Put box into new band */
if (reg->extents.x2 < ri_box->x2)
+ {
reg->extents.x2 = ri_box->x2;
-
+ }
+
if (reg->extents.x1 > box->x1)
+ {
reg->extents.x1 = box->x1;
-
+ }
+
COALESCE (reg, rit->prev_band, rit->cur_band);
rit->cur_band = reg->data->numRects;
RECTALLOC_BAIL (reg, 1, bail);
@@ -1711,20 +1821,26 @@ validate (region_type_t * badreg)
data_size = size_ri * sizeof(region_info_t);
if (data_size / size_ri != sizeof(region_info_t))
+ {
goto bail;
+ }
if (ri == stack_regions)
{
rit = (region_info_t *) malloc(data_size);
if (!rit)
+ {
goto bail;
+ }
memcpy (rit, ri, num_ri * sizeof (region_info_t));
}
else
{
rit = (region_info_t *) realloc (ri, data_size);
if (!rit)
+ {
goto bail;
+ }
}
ri = rit;
rit = &ri[num_ri];
@@ -1737,9 +1853,12 @@ validate (region_type_t * badreg)
/* MUST force allocation */
if (!pixman_rect_alloc (&rit->reg, (i + num_ri) / num_ri))
+ {
goto bail;
-
- next_rect: ;
+ }
+
+next_rect:
+ ;
} /* for i */
/* Make a final pass over each region in order to COALESCE and set
@@ -1752,8 +1871,10 @@ validate (region_type_t * badreg)
reg->extents.y2 = ri_box->y2;
if (reg->extents.x2 < ri_box->x2)
+ {
reg->extents.x2 = ri_box->x2;
-
+ }
+
COALESCE (reg, rit->prev_band, rit->cur_band);
if (reg->data->numRects == 1) /* keep unions happy below */
@@ -1773,19 +1894,29 @@ validate (region_type_t * badreg)
hreg = &ri[j + half].reg;
if (!pixman_op (reg, reg, hreg, pixman_region_union_o, TRUE, TRUE))
+ {
ret = FALSE;
+ }
if (hreg->extents.x1 < reg->extents.x1)
+ {
reg->extents.x1 = hreg->extents.x1;
+ }
if (hreg->extents.y1 < reg->extents.y1)
+ {
reg->extents.y1 = hreg->extents.y1;
+ }
if (hreg->extents.x2 > reg->extents.x2)
+ {
reg->extents.x2 = hreg->extents.x2;
+ }
if (hreg->extents.y2 > reg->extents.y2)
+ {
reg->extents.y2 = hreg->extents.y2;
+ }
FREE_DATA (hreg);
}
@@ -1793,7 +1924,9 @@ validate (region_type_t * badreg)
num_ri -= half;
if (!ret)
+ {
goto bail;
+ }
}
*badreg = ri[0].reg;
@@ -1809,7 +1942,9 @@ validate (region_type_t * badreg)
bail:
for (i = 0; i < num_ri; i++)
+ {
FREE_DATA (&ri[i].reg);
+ }
if (ri != stack_regions)
{
@@ -1840,15 +1975,15 @@ bail:
*/
/*ARGSUSED*/
static pixman_bool_t
-pixman_region_subtract_o (region_type_t * region,
- box_type_t * r1,
- box_type_t * r1_end,
- box_type_t * r2,
- box_type_t * r2_end,
+pixman_region_subtract_o (region_type_t *region,
+ box_type_t *r1,
+ box_type_t *r1_end,
+ box_type_t *r2,
+ box_type_t *r2_end,
int y1,
int y2)
{
- box_type_t * next_rect;
+ box_type_t *next_rect;
int x1;
x1 = r1->x1;
@@ -1881,7 +2016,9 @@ pixman_region_subtract_o (region_type_t * region,
*/
r1++;
if (r1 != r1_end)
+ {
x1 = r1->x1;
+ }
}
else
{
@@ -1909,7 +2046,9 @@ pixman_region_subtract_o (region_type_t * region,
*/
r1++;
if (r1 != r1_end)
+ {
x1 = r1->x1;
+ }
}
else
{
@@ -1925,12 +2064,16 @@ pixman_region_subtract_o (region_type_t * region,
* Minuend used up: add any remaining piece before advancing.
*/
if (r1->x2 > x1)
+ {
NEWRECT (region, next_rect, x1, y1, r1->x2, y2);
+ }
r1++;
if (r1 != r1_end)
+ {
x1 = r1->x1;
+ }
}
}
while ((r1 != r1_end) && (r2 != r2_end));
@@ -1946,7 +2089,9 @@ pixman_region_subtract_o (region_type_t * region,
r1++;
if (r1 != r1_end)
+ {
x1 = r1->x1;
+ }
}
return TRUE;
}
@@ -1973,14 +2118,16 @@ PREFIX (_subtract) (region_type_t *reg_d,
GOOD (reg_m);
GOOD (reg_s);
GOOD (reg_d);
-
+
/* check for trivial rejects */
if (PIXREGION_NIL (reg_m) || PIXREGION_NIL (reg_s) ||
- !EXTENTCHECK (&reg_m->extents, &reg_s->extents))
+ !EXTENTCHECK (&reg_m->extents, &reg_s->extents))
{
if (PIXREGION_NAR (reg_s))
+ {
return pixman_break (reg_d);
-
+ }
+
return PREFIX (_copy) (reg_d, reg_m);
}
else if (reg_m == reg_s)
@@ -1997,7 +2144,9 @@ PREFIX (_subtract) (region_type_t *reg_d,
do yucky subtraction for overlaps, and
just throw away rectangles in region 2 that aren't in region 1 */
if (!pixman_op (reg_d, reg_m, reg_s, pixman_region_subtract_o, TRUE, FALSE))
+ {
return FALSE;
+ }
/*
* Can't alter reg_d's extents before we call pixman_op because
@@ -2033,23 +2182,25 @@ PREFIX (_subtract) (region_type_t *reg_d,
PIXMAN_EXPORT pixman_bool_t
PREFIX (_inverse) (region_type_t *new_reg, /* Destination region */
region_type_t *reg1, /* Region to invert */
- box_type_t * inv_rect) /* Bounding box for inversion */
+ box_type_t *inv_rect) /* Bounding box for inversion */
{
region_type_t inv_reg; /* Quick and dirty region made from the
* bounding box */
GOOD (reg1);
GOOD (new_reg);
-
+
/* check for trivial rejects */
if (PIXREGION_NIL (reg1) || !EXTENTCHECK (inv_rect, &reg1->extents))
{
if (PIXREGION_NAR (reg1))
+ {
return pixman_break (new_reg);
-
+ }
+
new_reg->extents = *inv_rect;
FREE_DATA (new_reg);
new_reg->data = (region_data_type_t *)NULL;
-
+
return TRUE;
}
@@ -2060,7 +2211,9 @@ PREFIX (_inverse) (region_type_t *new_reg, /* Destination region */
inv_reg.extents = *inv_rect;
inv_reg.data = (region_data_type_t *)NULL;
if (!pixman_op (new_reg, &inv_reg, reg1, pixman_region_subtract_o, TRUE, FALSE))
+ {
return FALSE;
+ }
/*
* Can't alter new_reg's extents before we call pixman_op because
@@ -2083,14 +2236,20 @@ find_box_for_y (box_type_t *begin, box_type_t *end, int y)
box_type_t *mid;
if (end == begin)
+ {
return end;
+ }
if (end - begin == 1)
{
if (begin->y2 > y)
+ {
return begin;
+ }
else
+ {
return end;
+ }
}
mid = begin + (end - begin) / 2;
@@ -2125,11 +2284,11 @@ find_box_for_y (box_type_t *begin, box_type_t *end, int y)
* that doesn't overlap the box at all and part_in is false)
*/
PIXMAN_EXPORT pixman_region_overlap_t
-PREFIX (_contains_rectangle) (region_type_t * region,
- box_type_t * prect)
+PREFIX (_contains_rectangle) (region_type_t *region,
+ box_type_t *prect)
{
- box_type_t * pbox;
- box_type_t * pbox_end;
+ box_type_t *pbox;
+ box_type_t *pbox_end;
int part_in, part_out;
int numRects;
int x, y;
@@ -2140,15 +2299,21 @@ PREFIX (_contains_rectangle) (region_type_t * region,
/* useful optimization */
if (!numRects || !EXTENTCHECK (&region->extents, prect))
- return(PIXMAN_REGION_OUT);
+ {
+ return (PIXMAN_REGION_OUT);
+ }
if (numRects == 1)
{
/* We know that it must be PIXMAN_REGION_IN or PIXMAN_REGION_PART */
if (SUBSUMES (&region->extents, prect))
- return(PIXMAN_REGION_IN);
+ {
+ return (PIXMAN_REGION_IN);
+ }
else
- return(PIXMAN_REGION_PART);
+ {
+ return (PIXMAN_REGION_PART);
+ }
}
part_out = FALSE;
@@ -2160,46 +2325,58 @@ PREFIX (_contains_rectangle) (region_type_t * region,
/* can stop when both part_out and part_in are TRUE, or we reach prect->y2 */
for (pbox = PIXREGION_BOXPTR (region), pbox_end = pbox + numRects;
- pbox != pbox_end;
- pbox++)
+ pbox != pbox_end;
+ pbox++)
{
/* getting up to speed or skipping remainder of band */
if (pbox->y2 <= y)
{
if ((pbox = find_box_for_y (pbox, pbox_end, y)) == pbox_end)
+ {
break;
+ }
}
if (pbox->y1 > y)
{
part_out = TRUE; /* missed part of rectangle above */
if (part_in || (pbox->y1 >= prect->y2))
+ {
break;
+ }
y = pbox->y1; /* x guaranteed to be == prect->x1 */
}
if (pbox->x2 <= x)
- continue; /* not far enough over yet */
+ {
+ continue; /* not far enough over yet */
+ }
if (pbox->x1 > x)
{
part_out = TRUE; /* missed part of rectangle to left */
if (part_in)
+ {
break;
+ }
}
if (pbox->x1 < prect->x2)
{
part_in = TRUE; /* definitely overlap */
if (part_out)
+ {
break;
+ }
}
if (pbox->x2 >= prect->x2)
{
y = pbox->y2; /* finished with this band */
if (y >= prect->y2)
+ {
break;
+ }
x = prect->x1; /* reset x out to left again */
}
else
@@ -2219,9 +2396,13 @@ PREFIX (_contains_rectangle) (region_type_t * region,
if (part_in)
{
if (y < prect->y2)
+ {
return PIXMAN_REGION_PART;
+ }
else
+ {
return PIXMAN_REGION_IN;
+ }
}
else
{
@@ -2238,14 +2419,14 @@ PREFIX (_translate) (region_type_t *region, int x, int y)
{
overflow_int_t x1, x2, y1, y2;
int nbox;
- box_type_t * pbox;
+ box_type_t *pbox;
GOOD (region);
region->extents.x1 = x1 = region->extents.x1 + x;
region->extents.y1 = y1 = region->extents.y1 + y;
region->extents.x2 = x2 = region->extents.x2 + x;
region->extents.y2 = y2 = region->extents.y2 + y;
-
+
if (((x1 - PIXMAN_REGION_MIN) | (y1 - PIXMAN_REGION_MIN) | (PIXMAN_REGION_MAX - x2) | (PIXMAN_REGION_MAX - y2)) >= 0)
{
if (region->data && (nbox = region->data->numRects))
@@ -2271,18 +2452,26 @@ PREFIX (_translate) (region_type_t *region, int x, int y)
}
if (x1 < PIXMAN_REGION_MIN)
+ {
region->extents.x1 = PIXMAN_REGION_MIN;
+ }
else if (x2 > PIXMAN_REGION_MAX)
+ {
region->extents.x2 = PIXMAN_REGION_MAX;
+ }
if (y1 < PIXMAN_REGION_MIN)
+ {
region->extents.y1 = PIXMAN_REGION_MIN;
+ }
else if (y2 > PIXMAN_REGION_MAX)
+ {
region->extents.y2 = PIXMAN_REGION_MAX;
+ }
if (region->data && (nbox = region->data->numRects))
{
- box_type_t * pbox_out;
+ box_type_t *pbox_out;
for (pbox_out = pbox = PIXREGION_BOXPTR (region); nbox--; pbox++)
{
@@ -2292,21 +2481,29 @@ PREFIX (_translate) (region_type_t *region, int x, int y)
pbox_out->y2 = y2 = pbox->y2 + y;
if (((x2 - PIXMAN_REGION_MIN) | (y2 - PIXMAN_REGION_MIN) |
- (PIXMAN_REGION_MAX - x1) | (PIXMAN_REGION_MAX - y1)) <= 0)
+ (PIXMAN_REGION_MAX - x1) | (PIXMAN_REGION_MAX - y1)) <= 0)
{
region->data->numRects--;
continue;
}
if (x1 < PIXMAN_REGION_MIN)
+ {
pbox_out->x1 = PIXMAN_REGION_MIN;
+ }
else if (x2 > PIXMAN_REGION_MAX)
+ {
pbox_out->x2 = PIXMAN_REGION_MAX;
+ }
if (y1 < PIXMAN_REGION_MIN)
+ {
pbox_out->y1 = PIXMAN_REGION_MIN;
+ }
else if (y2 > PIXMAN_REGION_MAX)
+ {
pbox_out->y2 = PIXMAN_REGION_MAX;
+ }
pbox_out++;
}
@@ -2355,9 +2552,9 @@ PREFIX (_clear) (region_type_t *region)
/* box is "return" value */
PIXMAN_EXPORT int
-PREFIX (_contains_point) (region_type_t * region,
+PREFIX (_contains_point) (region_type_t *region,
int x, int y,
- box_type_t * box)
+ box_type_t *box)
{
box_type_t *pbox, *pbox_end;
int numRects;
@@ -2366,14 +2563,18 @@ PREFIX (_contains_point) (region_type_t * region,
numRects = PIXREGION_NUMRECTS (region);
if (!numRects || !INBOX (&region->extents, x, y))
- return(FALSE);
+ {
+ return (FALSE);
+ }
if (numRects == 1)
{
if (box)
+ {
*box = region->extents;
+ }
- return(TRUE);
+ return (TRUE);
}
pbox = PIXREGION_BOXPTR (region);
@@ -2381,37 +2582,43 @@ PREFIX (_contains_point) (region_type_t * region,
pbox = find_box_for_y (pbox, pbox_end, y);
- for (;pbox != pbox_end; pbox++)
+ for (; pbox != pbox_end; pbox++)
{
if ((y < pbox->y1) || (x < pbox->x1))
- break; /* missed it */
+ {
+ break; /* missed it */
+ }
if (x >= pbox->x2)
- continue; /* not there yet */
+ {
+ continue; /* not there yet */
+ }
if (box)
+ {
*box = *pbox;
+ }
- return(TRUE);
+ return (TRUE);
}
- return(FALSE);
+ return (FALSE);
}
PIXMAN_EXPORT int
-PREFIX (_not_empty) (region_type_t * region)
+PREFIX (_not_empty) (region_type_t *region)
{
GOOD (region);
- return(!PIXREGION_NIL (region));
+ return (!PIXREGION_NIL (region));
}
PIXMAN_EXPORT box_type_t *
-PREFIX (_extents) (region_type_t * region)
+PREFIX (_extents) (region_type_t *region)
{
GOOD (region);
- return(&region->extents);
+ return (&region->extents);
}
/*
@@ -2427,7 +2634,7 @@ PREFIX (_selfcheck) (region_type_t *reg)
int i, numRects;
if ((reg->extents.x1 > reg->extents.x2) ||
- (reg->extents.y1 > reg->extents.y2))
+ (reg->extents.y1 > reg->extents.y2))
{
return FALSE;
}
@@ -2445,7 +2652,7 @@ PREFIX (_selfcheck) (region_type_t *reg)
}
else
{
- box_type_t * pbox_p, * pbox_n;
+ box_type_t *pbox_p, * pbox_n;
box_type_t box;
pbox_p = PIXREGION_RECTS (reg);
@@ -2456,20 +2663,24 @@ PREFIX (_selfcheck) (region_type_t *reg)
for (i = numRects; --i > 0; pbox_p++, pbox_n++)
{
if ((pbox_n->x1 >= pbox_n->x2) ||
- (pbox_n->y1 >= pbox_n->y2))
+ (pbox_n->y1 >= pbox_n->y2))
{
return FALSE;
}
if (pbox_n->x1 < box.x1)
+ {
box.x1 = pbox_n->x1;
-
+ }
+
if (pbox_n->x2 > box.x2)
+ {
box.x2 = pbox_n->x2;
-
+ }
+
if ((pbox_n->y1 < pbox_p->y1) ||
- ((pbox_n->y1 == pbox_p->y1) &&
- ((pbox_n->x1 < pbox_p->x2) || (pbox_n->y2 != pbox_p->y2))))
+ ((pbox_n->y1 == pbox_p->y1) &&
+ ((pbox_n->x1 < pbox_p->x2) || (pbox_n->y2 != pbox_p->y2))))
{
return FALSE;
}
@@ -2510,10 +2721,14 @@ PREFIX (_init_rects) (region_type_t *region,
* static pixman_region_empty_data data).
*/
if (count == 0)
+ {
return TRUE;
+ }
if (!pixman_rect_alloc (region, count))
+ {
return FALSE;
+ }
rects = PIXREGION_RECTS (region);
@@ -2529,9 +2744,13 @@ PREFIX (_init_rects) (region_type_t *region,
box_type_t *box = &rects[i];
if (box->x1 >= box->x2 || box->y1 >= box->y2)
+ {
displacement++;
+ }
else if (displacement)
+ {
rects[i - displacement] = rects[i];
+ }
}
region->data->numRects -= displacement;
diff --git a/common/pixman-region.h b/common/pixman-region.h
index 9c82c4d9..bcc09cb6 100644
--- a/common/pixman-region.h
+++ b/common/pixman-region.h
@@ -56,21 +56,21 @@ typedef struct pixman_region16 pixman_region16_t;
/* creation/destruction */
void pixman_region_init (pixman_region16_t *region);
void pixman_region_init_rect (pixman_region16_t *region,
- int x,
- int y,
- unsigned int width,
- unsigned int height);
+ /**/ int x,
+ /**/ int y,
+ /**/ unsigned int width,
+ /**/ unsigned int height);
void pixman_region_fini (pixman_region16_t *region);
pixman_bool_t pixman_region_union (pixman_region16_t *new_reg,
- pixman_region16_t *reg1,
- pixman_region16_t *reg2);
+ /**/ pixman_region16_t *reg1,
+ /**/ pixman_region16_t *reg2);
pixman_bool_t pixman_region_subtract (pixman_region16_t *reg_d,
- pixman_region16_t *reg_m,
- pixman_region16_t *reg_s);
+ /**/ pixman_region16_t *reg_m,
+ /**/ pixman_region16_t *reg_s);
pixman_bool_t pixman_region_intersect (pixman_region16_t *new_reg,
- pixman_region16_t *reg1,
- pixman_region16_t *reg2);
-pixman_box16_t * pixman_region_rectangles (pixman_region16_t *region,
- int *n_rects);
+ /**/ pixman_region16_t *reg1,
+ /**/ pixman_region16_t *reg2);
+pixman_box16_t *pixman_region_rectangles (pixman_region16_t *region,
+ /**/ int *n_rects);
#endif
diff --git a/common/rail.h b/common/rail.h
index 26605cd9..b93672be 100644
--- a/common/rail.h
+++ b/common/rail.h
@@ -72,76 +72,76 @@
struct rail_icon_info
{
- int bpp;
- int width;
- int height;
- int cmap_bytes;
- int mask_bytes;
- int data_bytes;
- char* mask;
- char* cmap;
- char* data;
+ int bpp;
+ int width;
+ int height;
+ int cmap_bytes;
+ int mask_bytes;
+ int data_bytes;
+ char *mask;
+ char *cmap;
+ char *data;
};
struct rail_window_rect
{
- short left;
- short top;
- short right;
- short bottom;
+ short left;
+ short top;
+ short right;
+ short bottom;
};
struct rail_notify_icon_infotip
{
- int timeout;
- int flags;
- char* text;
- char* title;
+ int timeout;
+ int flags;
+ char *text;
+ char *title;
};
struct rail_window_state_order
{
- int owner_window_id;
- int style;
- int extended_style;
- int show_state;
- char* title_info;
- int client_offset_x;
- int client_offset_y;
- int client_area_width;
- int client_area_height;
- int rp_content;
- int root_parent_handle;
- int window_offset_x;
- int window_offset_y;
- int window_client_delta_x;
- int window_client_delta_y;
- int window_width;
- int window_height;
- int num_window_rects;
- struct rail_window_rect* window_rects;
- int visible_offset_x;
- int visible_offset_y;
- int num_visibility_rects;
- struct rail_window_rect* visibility_rects;
+ int owner_window_id;
+ int style;
+ int extended_style;
+ int show_state;
+ char *title_info;
+ int client_offset_x;
+ int client_offset_y;
+ int client_area_width;
+ int client_area_height;
+ int rp_content;
+ int root_parent_handle;
+ int window_offset_x;
+ int window_offset_y;
+ int window_client_delta_x;
+ int window_client_delta_y;
+ int window_width;
+ int window_height;
+ int num_window_rects;
+ struct rail_window_rect *window_rects;
+ int visible_offset_x;
+ int visible_offset_y;
+ int num_visibility_rects;
+ struct rail_window_rect *visibility_rects;
};
struct rail_notify_state_order
{
- int version;
- char* tool_tip;
- struct rail_notify_icon_infotip infotip;
- int state;
- int icon_cache_entry;
- int icon_cache_id;
- struct rail_icon_info icon_info;
+ int version;
+ char *tool_tip;
+ struct rail_notify_icon_infotip infotip;
+ int state;
+ int icon_cache_entry;
+ int icon_cache_id;
+ struct rail_icon_info icon_info;
};
struct rail_monitored_desktop_order
{
- int active_window_id;
- int num_window_ids;
- int* window_ids;
+ int active_window_id;
+ int num_window_ids;
+ int *window_ids;
};
#endif
diff --git a/common/thread_calls.c b/common/thread_calls.c
index 4ce25897..0b821b8f 100644
--- a/common/thread_calls.c
+++ b/common/thread_calls.c
@@ -55,7 +55,7 @@ tc_thread_create(unsigned long (__stdcall *start_routine)(void *), void *arg)
}
#else
int
-tc_thread_create(void * (* start_routine)(void *), void *arg)
+tc_thread_create(void *(* start_routine)(void *), void *arg)
{
int rv = 0;
pthread_t thread = (pthread_t)0;
diff --git a/common/thread_calls.h b/common/thread_calls.h
index c8b6640a..1e7d29ba 100644
--- a/common/thread_calls.h
+++ b/common/thread_calls.h
@@ -24,7 +24,7 @@
#include "arch.h"
int
-tc_thread_create(THREAD_RV (THREAD_CC * start_routine)(void*), void* arg);
+tc_thread_create(THREAD_RV (THREAD_CC *start_routine)(void *), void *arg);
tbus
tc_get_threadid(void);
int
diff --git a/common/trans.c b/common/trans.c
index c8820a54..31ceef29 100644
--- a/common/trans.c
+++ b/common/trans.c
@@ -28,6 +28,7 @@
#include "arch.h"
#include "parse.h"
#include "ssl_calls.h"
+#include "log.h"
#define MAX_SBYTES 0
@@ -454,7 +455,7 @@ trans_force_read_s(struct trans *self, struct stream *in_s, int size)
int rcvd;
if (self->status != TRANS_STATUS_UP ||
- size < 0 || !s_check_rem_out(in_s, size))
+ size < 0 || !s_check_rem_out(in_s, size))
{
return 1;
}
@@ -635,7 +636,7 @@ trans_write_copy_s(struct trans *self, struct stream *out_s)
if (self->si != 0)
{
if ((self->si->cur_source != XRDP_SOURCE_NONE) &&
- (self->si->cur_source != self->my_source))
+ (self->si->cur_source != self->my_source))
{
self->si->source[self->si->cur_source] += size;
wait_s->source = self->si->source + self->si->cur_source;
@@ -662,7 +663,7 @@ trans_write_copy_s(struct trans *self, struct stream *out_s)
/*****************************************************************************/
int
-trans_write_copy(struct trans* self)
+trans_write_copy(struct trans *self)
{
return trans_write_copy_s(self, self->out_s);
}
@@ -824,7 +825,9 @@ trans_listen_address(struct trans *self, char *port, const char *address)
{
self->sck = g_tcp_socket();
if (self->sck < 0)
+ {
return 1;
+ }
g_tcp_set_non_blocking(self->sck);
@@ -846,7 +849,9 @@ trans_listen_address(struct trans *self, char *port, const char *address)
self->sck = g_tcp_local_socket();
if (self->sck < 0)
+ {
return 1;
+ }
g_tcp_set_non_blocking(self->sck);
@@ -975,13 +980,13 @@ trans_set_tls_mode(struct trans *self, const char *key, const char *cert,
self->tls = ssl_tls_create(self, key, cert);
if (self->tls == NULL)
{
- g_writeln("trans_set_tls_mode: ssl_tls_create malloc error");
+ LOG(LOG_LEVEL_ERROR, "trans_set_tls_mode: ssl_tls_create malloc error");
return 1;
}
if (ssl_tls_accept(self->tls, ssl_protocols, tls_ciphers) != 0)
{
- g_writeln("trans_set_tls_mode: ssl_tls_accept failed");
+ LOG(LOG_LEVEL_ERROR, "trans_set_tls_mode: ssl_tls_accept failed");
return 1;
}
diff --git a/common/trans.h b/common/trans.h
index 9565e1fc..d76342d6 100644
--- a/common/trans.h
+++ b/common/trans.h
@@ -40,9 +40,9 @@
struct trans; /* forward declaration */
struct xrdp_tls;
-typedef int (*ttrans_data_in)(struct trans* self);
-typedef int (*ttrans_conn_in)(struct trans* self,
- struct trans* new_self);
+typedef int (*ttrans_data_in)(struct trans *self);
+typedef int (*ttrans_conn_in)(struct trans *self,
+ struct trans *new_self);
typedef int (*tis_term)(void);
typedef int (*trans_recv_proc) (struct trans *self, char *ptr, int len);
typedef int (*trans_send_proc) (struct trans *self, const char *data, int len);
@@ -97,13 +97,13 @@ struct trans
int type1; /* 1 listener 2 server 3 client */
ttrans_data_in trans_data_in;
ttrans_conn_in trans_conn_in;
- void* callback_data;
+ void *callback_data;
int header_size;
- struct stream* in_s;
- struct stream* out_s;
- char* listen_filename;
+ struct stream *in_s;
+ struct stream *out_s;
+ char *listen_filename;
tis_term is_term; /* used to test for exit */
- struct stream* wait_s;
+ struct stream *wait_s;
char addr[256];
char port[256];
int no_stream_init_on_data_in;
@@ -118,43 +118,43 @@ struct trans
enum xrdp_source my_source;
};
-struct trans*
+struct trans *
trans_create(int mode, int in_size, int out_size);
void
-trans_delete(struct trans* self);
+trans_delete(struct trans *self);
void
-trans_delete_from_child(struct trans* self);
+trans_delete_from_child(struct trans *self);
int
-trans_get_wait_objs(struct trans* self, tbus* objs, int* count);
+trans_get_wait_objs(struct trans *self, tbus *objs, int *count);
int
trans_get_wait_objs_rw(struct trans *self,
tbus *robjs, int *rcount,
tbus *wobjs, int *wcount, int *timeout);
int
-trans_check_wait_objs(struct trans* self);
+trans_check_wait_objs(struct trans *self);
int
-trans_force_read_s(struct trans* self, struct stream* in_s, int size);
+trans_force_read_s(struct trans *self, struct stream *in_s, int size);
int
-trans_force_write_s(struct trans* self, struct stream* out_s);
+trans_force_write_s(struct trans *self, struct stream *out_s);
int
-trans_force_read(struct trans* self, int size);
+trans_force_read(struct trans *self, int size);
int
-trans_force_write(struct trans* self);
+trans_force_write(struct trans *self);
int
-trans_write_copy(struct trans* self);
+trans_write_copy(struct trans *self);
int
-trans_write_copy_s(struct trans* self, struct stream* out_s);
+trans_write_copy_s(struct trans *self, struct stream *out_s);
int
-trans_connect(struct trans* self, const char* server, const char* port,
+trans_connect(struct trans *self, const char *server, const char *port,
int timeout);
int
-trans_listen_address(struct trans* self, char* port, const char* address);
+trans_listen_address(struct trans *self, char *port, const char *address);
int
-trans_listen(struct trans* self, char* port);
-struct stream*
-trans_get_in_s(struct trans* self);
-struct stream*
-trans_get_out_s(struct trans* self, int size);
+trans_listen(struct trans *self, char *port);
+struct stream *
+trans_get_in_s(struct trans *self);
+struct stream *
+trans_get_out_s(struct trans *self, int size);
int
trans_set_tls_mode(struct trans *self, const char *key, const char *cert,
long ssl_protocols, const char *tls_ciphers);
diff --git a/common/xrdp_constants.h b/common/xrdp_constants.h
index f9eca7d6..95bb1407 100644
--- a/common/xrdp_constants.h
+++ b/common/xrdp_constants.h
@@ -180,7 +180,7 @@
#define MASK_REMOVE_BITS(var, mask) (var &= ~mask)
#define MASK_HAS_BITS(var, mask) ((var & mask)>0)
#define MASK_CHANGE_BIT(var, mask, active) \
- (var = ((var & ~mask) | (active ? mask : 0)))
+ (var = ((var & ~mask) | (active ? mask : 0)))
/* Clipboard constants, "borrowed" from GCC system headers in
the w32 cross compiler */
diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c
index 5c061950..3f4f8595 100644
--- a/xrdp/xrdp.c
+++ b/xrdp/xrdp.c
@@ -445,7 +445,6 @@ int
main(int argc, char **argv)
{
int exit_status = 0;
- int test;
enum logReturns error;
struct xrdp_startup_params startup_params = {0};
int pid;
@@ -453,16 +452,18 @@ main(int argc, char **argv)
int daemon;
char text[256];
const char *pid_file = XRDP_PID_PATH "/xrdp.pid";
-
int errored_argc;
- g_init("xrdp");
- ssl_init();
-
+#ifdef XRDP_DEBUG
+ int test;
for (test = 0; test < argc; test++)
{
- DEBUG(("Argument %i - %s", test, argv[test]));
+ g_writeln("Argument %i - %s", test, argv[test]);
}
+#endif
+
+ g_init("xrdp");
+ ssl_init();
startup_params.xrdp_ini = XRDP_CFG_PATH "/xrdp.ini";