Fixing formatting with astyle in common/*
This commit is contained in:
parent
feb8ef33f5
commit
bb9d3079c0
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -42,25 +42,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 +69,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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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 */
|
||||
|
@ -447,7 +447,7 @@ g_tcp_socket(void)
|
||||
}
|
||||
#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,8 +458,8 @@ 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");
|
||||
}
|
||||
@ -475,7 +475,7 @@ 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");
|
||||
}
|
||||
@ -492,7 +492,7 @@ 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");
|
||||
}
|
||||
@ -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;
|
||||
@ -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;
|
||||
@ -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)
|
||||
@ -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,7 +984,7 @@ 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;
|
||||
}
|
||||
@ -995,7 +996,7 @@ g_tcp_bind(int sck, const char *port)
|
||||
}
|
||||
#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,7 +1101,7 @@ 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;
|
||||
}
|
||||
@ -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)
|
||||
@ -1200,7 +1201,7 @@ g_tcp_bind_address(int sck, const char *port, const char *address)
|
||||
}
|
||||
#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:
|
||||
{
|
||||
@ -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:
|
||||
{
|
||||
@ -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 */
|
||||
}
|
||||
@ -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))
|
||||
{
|
||||
@ -3225,7 +3226,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;
|
||||
@ -3267,7 +3268,7 @@ g_shmat(int shmid)
|
||||
#if defined(_WIN32)
|
||||
return 0;
|
||||
#else
|
||||
return shmat(shmid, 0, 0);
|
||||
return shmat(shmid, 0, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -3398,7 +3399,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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
486
common/parse.h
486
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)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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
|
||||
|
100
common/rail.h
100
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
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -454,7 +454,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 +635,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 +662,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 +824,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 +848,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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user