From 0685b1b65c659ab4c70717ffeaec34f9cdcdf5d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20=C3=85strand?= Date: Thu, 18 Jul 2002 16:38:31 +0000 Subject: [PATCH] Fixed indentation with indent git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@63 423420c4-83ab-492f-b58f-81f9feb106b5 --- cache.c | 5 +- constants.h | 12 +- iso.c | 2 +- licence.c | 29 ++-- mcs.c | 2 +- orders.c | 51 +++--- orders.h | 48 ++++-- parse.h | 3 +- proto.h | 66 +++++--- rdesktop.c | 21 +-- rdp.c | 8 +- secure.c | 40 ++--- types.h | 21 ++- xkeymap.c | 35 +++-- xwin.c | 442 +++++++++++++++++++++++++++++----------------------- 15 files changed, 447 insertions(+), 338 deletions(-) diff --git a/cache.c b/cache.c index 4e5fb60..e2d6e57 100644 --- a/cache.c +++ b/cache.c @@ -178,7 +178,7 @@ cache_get_desktop(uint32 offset, int cx, int cy, int bytes_per_pixel) /* Store desktop data in the cache */ void cache_put_desktop(uint32 offset, int cx, int cy, int scanline, - int bytes_per_pixel, uint8 *data) + int bytes_per_pixel, uint8 * data) { int length = cx * cy * bytes_per_pixel; @@ -203,7 +203,8 @@ cache_put_desktop(uint32 offset, int cx, int cy, int scanline, static HCURSOR cursorcache[0x20]; /* Retrieve cursor from cache */ -HCURSOR cache_get_cursor(uint16 cache_idx) +HCURSOR +cache_get_cursor(uint16 cache_idx) { HCURSOR cursor; diff --git a/constants.h b/constants.h index fa2c5d6..0bb8fe6 100644 --- a/constants.h +++ b/constants.h @@ -24,11 +24,11 @@ /* ISO PDU codes */ enum ISO_PDU_CODE { - ISO_PDU_CR = 0xE0, /* Connection Request */ - ISO_PDU_CC = 0xD0, /* Connection Confirm */ - ISO_PDU_DR = 0x80, /* Disconnect Request */ - ISO_PDU_DT = 0xF0, /* Data */ - ISO_PDU_ER = 0x70 /* Error */ + ISO_PDU_CR = 0xE0, /* Connection Request */ + ISO_PDU_CC = 0xD0, /* Connection Confirm */ + ISO_PDU_DR = 0x80, /* Disconnect Request */ + ISO_PDU_DT = 0xF0, /* Data */ + ISO_PDU_ER = 0x70 /* Error */ }; /* MCS PDU codes */ @@ -76,7 +76,7 @@ enum MCS_PDU_TYPE #define SEC_TAG_PUBKEY 0x0006 #define SEC_TAG_KEYSIG 0x0008 -#define SEC_RSA_MAGIC 0x31415352 /* RSA1 */ +#define SEC_RSA_MAGIC 0x31415352 /* RSA1 */ /* RDP licensing constants */ #define LICENCE_TOKEN_SIZE 10 diff --git a/iso.c b/iso.c index a07acaa..df09c89 100644 --- a/iso.c +++ b/iso.c @@ -44,7 +44,7 @@ iso_send_msg(uint8 code) /* Receive a message on the ISO layer, return code */ static STREAM -iso_recv_msg(uint8 *code) +iso_recv_msg(uint8 * code) { STREAM s; uint16 length; diff --git a/licence.c b/licence.c index d75e89d..a84a7dc 100644 --- a/licence.c +++ b/licence.c @@ -32,7 +32,8 @@ BOOL licence_issued = False; /* Generate a session key and RC4 keys, given client and server randoms */ static void -licence_generate_keys(uint8 *client_key, uint8 *server_key, uint8 *client_rsa) +licence_generate_keys(uint8 * client_key, uint8 * server_key, + uint8 * client_rsa) { uint8 session_key[48]; uint8 temp_hash[48]; @@ -49,7 +50,7 @@ licence_generate_keys(uint8 *client_key, uint8 *server_key, uint8 *client_rsa) } static void -licence_generate_hwid(uint8 *hwid) +licence_generate_hwid(uint8 * hwid) { buf_out_uint32(hwid, 2); strncpy(hwid + 4, hostname, LICENCE_HWID_SIZE - 4); @@ -57,13 +58,14 @@ licence_generate_hwid(uint8 *hwid) /* Present an existing licence to the server */ static void -licence_present(uint8 *client_random, uint8 *rsa_data, - uint8 *licence_data, int licence_size, - uint8 *hwid, uint8 *signature) +licence_present(uint8 * client_random, uint8 * rsa_data, + uint8 * licence_data, int licence_size, + uint8 * hwid, uint8 * signature) { uint32 sec_flags = SEC_LICENCE_NEG; - uint16 length = 16 + SEC_RANDOM_SIZE + SEC_MODULUS_SIZE + SEC_PADDING_SIZE - + licence_size + LICENCE_HWID_SIZE + LICENCE_SIGNATURE_SIZE; + uint16 length = + 16 + SEC_RANDOM_SIZE + SEC_MODULUS_SIZE + SEC_PADDING_SIZE + + licence_size + LICENCE_HWID_SIZE + LICENCE_SIGNATURE_SIZE; STREAM s; s = sec_init(sec_flags, length + 4); @@ -97,7 +99,7 @@ licence_present(uint8 *client_random, uint8 *rsa_data, /* Send a licence request packet */ static void -licence_send_request(uint8 *client_random, uint8 *rsa_data, +licence_send_request(uint8 * client_random, uint8 * rsa_data, char *user, char *host) { uint32 sec_flags = SEC_LICENCE_NEG; @@ -156,7 +158,8 @@ licence_process_demand(STREAM s) licence_size = load_licence(&licence_data); if (licence_size == -1) { - licence_send_request(null_data, null_data, username, hostname); + licence_send_request(null_data, null_data, username, + hostname); return; } @@ -169,13 +172,13 @@ licence_process_demand(STREAM s) RC4(&crypt_key, sizeof(hwid), hwid, hwid); licence_present(null_data, null_data, licence_data, licence_size, - hwid, signature); + hwid, signature); xfree(licence_data); } /* Send an authentication response packet */ static void -licence_send_authresp(uint8 *token, uint8 *crypt_hwid, uint8 *signature) +licence_send_authresp(uint8 * token, uint8 * crypt_hwid, uint8 * signature) { uint32 sec_flags = SEC_LICENCE_NEG; uint16 length = 58; @@ -202,7 +205,7 @@ licence_send_authresp(uint8 *token, uint8 *crypt_hwid, uint8 *signature) /* Parse an authentication request packet */ static BOOL -licence_parse_authreq(STREAM s, uint8 **token, uint8 **signature) +licence_parse_authreq(STREAM s, uint8 ** token, uint8 ** signature) { uint16 tokenlen; @@ -280,7 +283,7 @@ licence_process_issue(STREAM s) return; licence_issued = True; - save_licence(s->p, length-2); + save_licence(s->p, length - 2); } /* Process a licence packet */ diff --git a/mcs.c b/mcs.c index f334412..ce852f9 100644 --- a/mcs.c +++ b/mcs.c @@ -215,7 +215,7 @@ mcs_send_aurq() /* Expect a AUcf message (ASN.1 PER) */ static BOOL -mcs_recv_aucf(uint16 *mcs_userid) +mcs_recv_aucf(uint16 * mcs_userid) { uint8 opcode, result; STREAM s; diff --git a/orders.c b/orders.c index a8690ba..d486e22 100644 --- a/orders.c +++ b/orders.c @@ -26,7 +26,7 @@ static RDP_ORDER_STATE order_state; /* Read field indicating which parameters are present */ static void -rdp_in_present(STREAM s, uint32 *present, uint8 flags, int size) +rdp_in_present(STREAM s, uint32 * present, uint8 flags, int size) { uint8 bits; int i; @@ -54,7 +54,7 @@ rdp_in_present(STREAM s, uint32 *present, uint8 flags, int size) /* Read a co-ordinate (16-bit, or 8-bit delta) */ static void -rdp_in_coord(STREAM s, uint16 *coord, BOOL delta) +rdp_in_coord(STREAM s, uint16 * coord, BOOL delta) { uint8 change; @@ -71,7 +71,7 @@ rdp_in_coord(STREAM s, uint16 *coord, BOOL delta) /* Read a colour entry */ static void -rdp_in_colour(STREAM s, uint8 *colour) +rdp_in_colour(STREAM s, uint8 * colour) { in_uint8(s, *colour); s->p += 2; @@ -79,7 +79,7 @@ rdp_in_colour(STREAM s, uint8 *colour) /* Parse bounds information */ static BOOL -rdp_parse_bounds(STREAM s, BOUNDS *bounds) +rdp_parse_bounds(STREAM s, BOUNDS * bounds) { uint8 present; @@ -110,7 +110,7 @@ rdp_parse_bounds(STREAM s, BOUNDS *bounds) /* Parse a pen */ static BOOL -rdp_parse_pen(STREAM s, PEN *pen, uint32 present) +rdp_parse_pen(STREAM s, PEN * pen, uint32 present) { if (present & 1) in_uint8(s, pen->style); @@ -126,7 +126,7 @@ rdp_parse_pen(STREAM s, PEN *pen, uint32 present) /* Parse a brush */ static BOOL -rdp_parse_brush(STREAM s, BRUSH *brush, uint32 present) +rdp_parse_brush(STREAM s, BRUSH * brush, uint32 present) { if (present & 1) in_uint8(s, brush->xorigin); @@ -148,7 +148,7 @@ rdp_parse_brush(STREAM s, BRUSH *brush, uint32 present) /* Process a destination blt order */ static void -process_destblt(STREAM s, DESTBLT_ORDER *os, uint32 present, BOOL delta) +process_destblt(STREAM s, DESTBLT_ORDER * os, uint32 present, BOOL delta) { if (present & 0x01) rdp_in_coord(s, &os->x, delta); @@ -173,7 +173,7 @@ process_destblt(STREAM s, DESTBLT_ORDER *os, uint32 present, BOOL delta) /* Process a pattern blt order */ static void -process_patblt(STREAM s, PATBLT_ORDER *os, uint32 present, BOOL delta) +process_patblt(STREAM s, PATBLT_ORDER * os, uint32 present, BOOL delta) { if (present & 0x0001) rdp_in_coord(s, &os->x, delta); @@ -198,9 +198,7 @@ process_patblt(STREAM s, PATBLT_ORDER *os, uint32 present, BOOL delta) rdp_parse_brush(s, &os->brush, present >> 7); - DEBUG(("PATBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,bs=%d,bg=0x%x,fg=0x%x)\n", - os->opcode, os->x, os->y, os->cx, os->cy, - os->brush.style, os->bgcolour, os->fgcolour)); + DEBUG(("PATBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,bs=%d,bg=0x%x,fg=0x%x)\n", os->opcode, os->x, os->y, os->cx, os->cy, os->brush.style, os->bgcolour, os->fgcolour)); ui_patblt(ROP2_P(os->opcode), os->x, os->y, os->cx, os->cy, &os->brush, os->bgcolour, os->fgcolour); @@ -208,7 +206,7 @@ process_patblt(STREAM s, PATBLT_ORDER *os, uint32 present, BOOL delta) /* Process a screen blt order */ static void -process_screenblt(STREAM s, SCREENBLT_ORDER *os, uint32 present, BOOL delta) +process_screenblt(STREAM s, SCREENBLT_ORDER * os, uint32 present, BOOL delta) { if (present & 0x0001) rdp_in_coord(s, &os->x, delta); @@ -240,7 +238,7 @@ process_screenblt(STREAM s, SCREENBLT_ORDER *os, uint32 present, BOOL delta) /* Process a line order */ static void -process_line(STREAM s, LINE_ORDER *os, uint32 present, BOOL delta) +process_line(STREAM s, LINE_ORDER * os, uint32 present, BOOL delta) { if (present & 0x0001) in_uint16_le(s, os->mixmode); @@ -281,7 +279,7 @@ process_line(STREAM s, LINE_ORDER *os, uint32 present, BOOL delta) /* Process an opaque rectangle order */ static void -process_rect(STREAM s, RECT_ORDER *os, uint32 present, BOOL delta) +process_rect(STREAM s, RECT_ORDER * os, uint32 present, BOOL delta) { if (present & 0x01) rdp_in_coord(s, &os->x, delta); @@ -306,7 +304,7 @@ process_rect(STREAM s, RECT_ORDER *os, uint32 present, BOOL delta) /* Process a desktop save order */ static void -process_desksave(STREAM s, DESKSAVE_ORDER *os, uint32 present, BOOL delta) +process_desksave(STREAM s, DESKSAVE_ORDER * os, uint32 present, BOOL delta) { int width, height; @@ -344,7 +342,7 @@ process_desksave(STREAM s, DESKSAVE_ORDER *os, uint32 present, BOOL delta) /* Process a memory blt order */ static void -process_memblt(STREAM s, MEMBLT_ORDER *os, uint32 present, BOOL delta) +process_memblt(STREAM s, MEMBLT_ORDER * os, uint32 present, BOOL delta) { HBITMAP bitmap; @@ -392,7 +390,7 @@ process_memblt(STREAM s, MEMBLT_ORDER *os, uint32 present, BOOL delta) /* Process a 3-way blt order */ static void -process_triblt(STREAM s, TRIBLT_ORDER *os, uint32 present, BOOL delta) +process_triblt(STREAM s, TRIBLT_ORDER * os, uint32 present, BOOL delta) { HBITMAP bitmap; @@ -437,9 +435,7 @@ process_triblt(STREAM s, TRIBLT_ORDER *os, uint32 present, BOOL delta) if (present & 0x010000) in_uint16_le(s, os->unknown); - DEBUG(("TRIBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,id=%d,idx=%d,bs=%d,bg=0x%x,fg=0x%x)\n", - os->opcode, os->x, os->y, os->cx, os->cy, os->cache_id, - os->cache_idx, os->brush.style, os->bgcolour, os->fgcolour)); + DEBUG(("TRIBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,id=%d,idx=%d,bs=%d,bg=0x%x,fg=0x%x)\n", os->opcode, os->x, os->y, os->cx, os->cy, os->cache_id, os->cache_idx, os->brush.style, os->bgcolour, os->fgcolour)); bitmap = cache_get_bitmap(os->cache_id, os->cache_idx); if (bitmap == NULL) @@ -452,7 +448,7 @@ process_triblt(STREAM s, TRIBLT_ORDER *os, uint32 present, BOOL delta) /* Parse a delta co-ordinate in polyline order form */ static int -parse_delta(uint8 *buffer, int *offset) +parse_delta(uint8 * buffer, int *offset) { int value = buffer[(*offset)++]; int two_byte = value & 0x80; @@ -470,7 +466,7 @@ parse_delta(uint8 *buffer, int *offset) /* Process a polyline order */ static void -process_polyline(STREAM s, POLYLINE_ORDER *os, uint32 present, BOOL delta) +process_polyline(STREAM s, POLYLINE_ORDER * os, uint32 present, BOOL delta) { int index, line, data; int x, y, xfrom, yfrom; @@ -504,7 +500,8 @@ process_polyline(STREAM s, POLYLINE_ORDER *os, uint32 present, BOOL delta) opcode = ROP2_NXOR; DEBUG(("POLYLINE(x=%d,y=%d,fl=0x%x,fg=0x%x,n=%d,sz=%d)\n", - os->x, os->y, os->flags, os->fgcolour, os->lines, os->datasize)); + os->x, os->y, os->flags, os->fgcolour, os->lines, + os->datasize)); DEBUG(("Data: ")); @@ -545,7 +542,7 @@ process_polyline(STREAM s, POLYLINE_ORDER *os, uint32 present, BOOL delta) /* Process a text order */ static void -process_text2(STREAM s, TEXT2_ORDER *os, uint32 present, BOOL delta) +process_text2(STREAM s, TEXT2_ORDER * os, uint32 present, BOOL delta) { int i; @@ -603,11 +600,7 @@ process_text2(STREAM s, TEXT2_ORDER *os, uint32 present, BOOL delta) in_uint8a(s, os->text, os->length); } - DEBUG(("TEXT2(x=%d,y=%d,cl=%d,ct=%d,cr=%d,cb=%d,bl=%d,bt=%d,bb=%d,br=%d,fg=0x%x,bg=0x%x,font=%d,fl=0x%x,mix=%d,unk=0x%x,n=%d)\n", - os->x, os->y, os->clipleft, os->cliptop, os->clipright, - os->clipbottom, os->boxleft, os->boxtop, os->boxright, - os->boxbottom, os->fgcolour, os->bgcolour, os->font, - os->flags, os->mixmode, os->unknown, os->length)); + DEBUG(("TEXT2(x=%d,y=%d,cl=%d,ct=%d,cr=%d,cb=%d,bl=%d,bt=%d,bb=%d,br=%d,fg=0x%x,bg=0x%x,font=%d,fl=0x%x,mix=%d,unk=0x%x,n=%d)\n", os->x, os->y, os->clipleft, os->cliptop, os->clipright, os->clipbottom, os->boxleft, os->boxtop, os->boxright, os->boxbottom, os->fgcolour, os->bgcolour, os->font, os->flags, os->mixmode, os->unknown, os->length)); DEBUG(("Text: ")); diff --git a/orders.h b/orders.h index 2f3c0c2..73efd2a 100644 --- a/orders.h +++ b/orders.h @@ -57,7 +57,8 @@ typedef struct _DESTBLT_ORDER uint16 cy; uint8 opcode; -} DESTBLT_ORDER; +} +DESTBLT_ORDER; typedef struct _PATBLT_ORDER { @@ -70,7 +71,8 @@ typedef struct _PATBLT_ORDER uint8 fgcolour; BRUSH brush; -} PATBLT_ORDER; +} +PATBLT_ORDER; typedef struct _SCREENBLT_ORDER { @@ -82,7 +84,8 @@ typedef struct _SCREENBLT_ORDER uint16 srcx; uint16 srcy; -} SCREENBLT_ORDER; +} +SCREENBLT_ORDER; typedef struct _LINE_ORDER { @@ -95,7 +98,8 @@ typedef struct _LINE_ORDER uint8 opcode; PEN pen; -} LINE_ORDER; +} +LINE_ORDER; typedef struct _RECT_ORDER { @@ -105,7 +109,8 @@ typedef struct _RECT_ORDER uint16 cy; uint8 colour; -} RECT_ORDER; +} +RECT_ORDER; typedef struct _DESKSAVE_ORDER { @@ -116,7 +121,8 @@ typedef struct _DESKSAVE_ORDER uint16 bottom; uint8 action; -} DESKSAVE_ORDER; +} +DESKSAVE_ORDER; typedef struct _TRIBLT_ORDER { @@ -135,7 +141,8 @@ typedef struct _TRIBLT_ORDER uint16 cache_idx; uint16 unknown; -} TRIBLT_ORDER; +} +TRIBLT_ORDER; typedef struct _MEMBLT_ORDER { @@ -150,7 +157,8 @@ typedef struct _MEMBLT_ORDER uint16 srcy; uint16 cache_idx; -} MEMBLT_ORDER; +} +MEMBLT_ORDER; #define MAX_DATA 256 @@ -164,7 +172,8 @@ typedef struct _POLYLINE_ORDER uint8 datasize; uint8 data[MAX_DATA]; -} POLYLINE_ORDER; +} +POLYLINE_ORDER; #define MAX_TEXT 256 @@ -189,7 +198,8 @@ typedef struct _TEXT2_ORDER uint8 length; uint8 text[MAX_TEXT]; -} TEXT2_ORDER; +} +TEXT2_ORDER; typedef struct _RDP_ORDER_STATE { @@ -207,7 +217,8 @@ typedef struct _RDP_ORDER_STATE POLYLINE_ORDER polyline; TEXT2_ORDER text2; -} RDP_ORDER_STATE; +} +RDP_ORDER_STATE; typedef struct _RDP_RAW_BMPCACHE_ORDER { @@ -220,7 +231,8 @@ typedef struct _RDP_RAW_BMPCACHE_ORDER uint16 cache_idx; uint8 *data; -} RDP_RAW_BMPCACHE_ORDER; +} +RDP_RAW_BMPCACHE_ORDER; typedef struct _RDP_BMPCACHE_ORDER { @@ -237,7 +249,8 @@ typedef struct _RDP_BMPCACHE_ORDER uint16 final_size; uint8 *data; -} RDP_BMPCACHE_ORDER; +} +RDP_BMPCACHE_ORDER; #define MAX_GLYPH 32 @@ -250,7 +263,8 @@ typedef struct _RDP_FONT_GLYPH uint16 height; uint8 data[MAX_GLYPH]; -} RDP_FONT_GLYPH; +} +RDP_FONT_GLYPH; #define MAX_GLYPHS 256 @@ -260,11 +274,13 @@ typedef struct _RDP_FONTCACHE_ORDER uint8 nglyphs; RDP_FONT_GLYPH glyphs[MAX_GLYPHS]; -} RDP_FONTCACHE_ORDER; +} +RDP_FONTCACHE_ORDER; typedef struct _RDP_COLCACHE_ORDER { uint8 cache_id; COLOURMAP map; -} RDP_COLCACHE_ORDER; +} +RDP_COLCACHE_ORDER; diff --git a/parse.h b/parse.h index da55f21..c84d151 100644 --- a/parse.h +++ b/parse.h @@ -32,7 +32,8 @@ typedef struct stream unsigned char *sec_hdr; unsigned char *rdp_hdr; -} *STREAM; +} + *STREAM; #define s_push_layer(s,h,n) { (s)->h = (s)->p; (s)->p += n; } #define s_pop_layer(s,h) (s)->p = (s)->h; diff --git a/proto.h b/proto.h index 33681a3..7fbefe7 100644 --- a/proto.h +++ b/proto.h @@ -1,14 +1,18 @@ /* bitmap.c */ -BOOL bitmap_decompress(unsigned char *output, int width, int height, unsigned char *input, int size); +BOOL bitmap_decompress(unsigned char *output, int width, int height, + unsigned char *input, int size); /* cache.c */ HBITMAP cache_get_bitmap(uint8 cache_id, uint16 cache_idx); void cache_put_bitmap(uint8 cache_id, uint16 cache_idx, HBITMAP bitmap); FONTGLYPH *cache_get_font(uint8 font, uint16 character); -void cache_put_font(uint8 font, uint16 character, uint16 offset, uint16 baseline, uint16 width, uint16 height, HGLYPH pixmap); +void cache_put_font(uint8 font, uint16 character, uint16 offset, + uint16 baseline, uint16 width, uint16 height, + HGLYPH pixmap); DATABLOB *cache_get_text(uint8 cache_id); void cache_put_text(uint8 cache_id, void *data, int length); uint8 *cache_get_desktop(uint32 offset, int cx, int cy, int bytes_per_pixel); -void cache_put_desktop(uint32 offset, int cx, int cy, int scanline, int bytes_per_pixel, uint8 *data); +void cache_put_desktop(uint32 offset, int cx, int cy, int scanline, + int bytes_per_pixel, uint8 * data); HCURSOR cache_get_cursor(uint16 cache_idx); void cache_put_cursor(uint16 cache_idx, HCURSOR cursor); /* iso.c */ @@ -30,7 +34,7 @@ void process_orders(STREAM s); void reset_order_state(void); /* rdesktop.c */ int main(int argc, char *argv[]); -void generate_random(uint8 *random); +void generate_random(uint8 * random); void *xmalloc(int size); void *xrealloc(void *oldmem, int size); void xfree(void *mem); @@ -41,15 +45,19 @@ int load_licence(unsigned char **data); void save_licence(unsigned char *data, int length); /* rdp.c */ void rdp_out_unistr(STREAM s, char *string, int len); -void rdp_send_input(uint32 time, uint16 message_type, uint16 device_flags, uint16 param1, uint16 param2); +void rdp_send_input(uint32 time, uint16 message_type, uint16 device_flags, + uint16 param1, uint16 param2); void rdp_main_loop(void); -BOOL rdp_connect(char *server, uint32 flags, char *domain, char *password, char *command, char *directory); +BOOL rdp_connect(char *server, uint32 flags, char *domain, char *password, + char *command, char *directory); void rdp_disconnect(void); /* secure.c */ -void sec_hash_48(uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2, uint8 salt); -void sec_hash_16(uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2); -void buf_out_uint32(uint8 *buffer, uint32 value); -void sec_sign(uint8 *signature, int siglen, uint8 *session_key, int keylen, uint8 *data, int datalen); +void sec_hash_48(uint8 * out, uint8 * in, uint8 * salt1, uint8 * salt2, + uint8 salt); +void sec_hash_16(uint8 * out, uint8 * in, uint8 * salt1, uint8 * salt2); +void buf_out_uint32(uint8 * buffer, uint32 value); +void sec_sign(uint8 * signature, int siglen, uint8 * session_key, int keylen, + uint8 * data, int datalen); STREAM sec_init(uint32 flags, int maxlen); void sec_send(STREAM s, uint32 flags); STREAM sec_recv(void); @@ -63,35 +71,47 @@ BOOL tcp_connect(char *server); void tcp_disconnect(void); /* xkeymap.c */ void xkeymap_init(void); -uint8 xkeymap_translate_key(unsigned int keysym, unsigned int keycode, uint16 *flags); +uint8 xkeymap_translate_key(unsigned int keysym, unsigned int keycode, + uint16 * flags); uint16 xkeymap_translate_button(unsigned int button); /* xwin.c */ BOOL ui_create_window(char *title); void ui_destroy_window(void); void ui_select(int rdp_socket); void ui_move_pointer(int x, int y); -HBITMAP ui_create_bitmap(int width, int height, uint8 *data); -void ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, uint8 *data); +HBITMAP ui_create_bitmap(int width, int height, uint8 * data); +void ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, + uint8 * data); void ui_destroy_bitmap(HBITMAP bmp); -HGLYPH ui_create_glyph(int width, int height, uint8 *data); +HGLYPH ui_create_glyph(int width, int height, uint8 * data); void ui_destroy_glyph(HGLYPH glyph); -HCURSOR ui_create_cursor(unsigned int x, unsigned int y, int width, int height, uint8 *andmask, uint8 *xormask); +HCURSOR ui_create_cursor(unsigned int x, unsigned int y, int width, + int height, uint8 * andmask, uint8 * xormask); void ui_set_cursor(HCURSOR cursor); void ui_destroy_cursor(HCURSOR cursor); -HCOLOURMAP ui_create_colourmap(COLOURMAP *colours); +HCOLOURMAP ui_create_colourmap(COLOURMAP * colours); void ui_destroy_colourmap(HCOLOURMAP map); void ui_set_colourmap(HCOLOURMAP map); void ui_set_clip(int x, int y, int cx, int cy); void ui_reset_clip(void); void ui_bell(void); void ui_destblt(uint8 opcode, int x, int y, int cx, int cy); -void ui_patblt(uint8 opcode, int x, int y, int cx, int cy, BRUSH *brush, int bgcolour, int fgcolour); -void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy, int srcx, int srcy); -void ui_memblt(uint8 opcode, int x, int y, int cx, int cy, HBITMAP src, int srcx, int srcy); -void ui_triblt(uint8 opcode, int x, int y, int cx, int cy, HBITMAP src, int srcx, int srcy, BRUSH *brush, int bgcolour, int fgcolour); -void ui_line(uint8 opcode, int startx, int starty, int endx, int endy, PEN *pen); +void ui_patblt(uint8 opcode, int x, int y, int cx, int cy, BRUSH * brush, + int bgcolour, int fgcolour); +void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy, int srcx, + int srcy); +void ui_memblt(uint8 opcode, int x, int y, int cx, int cy, HBITMAP src, + int srcx, int srcy); +void ui_triblt(uint8 opcode, int x, int y, int cx, int cy, HBITMAP src, + int srcx, int srcy, BRUSH * brush, int bgcolour, int fgcolour); +void ui_line(uint8 opcode, int startx, int starty, int endx, int endy, + PEN * pen); void ui_rect(int x, int y, int cx, int cy, int colour); -void ui_draw_glyph(int mixmode, int x, int y, int cx, int cy, HGLYPH glyph, int srcx, int srcy, int bgcolour, int fgcolour); -void ui_draw_text(uint8 font, uint8 flags, int mixmode, int x, int y, int clipx, int clipy, int clipcx, int clipcy, int boxx, int boxy, int boxcx, int boxcy, int bgcolour, int fgcolour, uint8 *text, uint8 length); +void ui_draw_glyph(int mixmode, int x, int y, int cx, int cy, HGLYPH glyph, + int srcx, int srcy, int bgcolour, int fgcolour); +void ui_draw_text(uint8 font, uint8 flags, int mixmode, int x, int y, + int clipx, int clipy, int clipcx, int clipcy, int boxx, + int boxy, int boxcx, int boxcy, int bgcolour, int fgcolour, + uint8 * text, uint8 length); void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy); void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy); diff --git a/rdesktop.c b/rdesktop.c index 4ba5b5b..6a903e4 100644 --- a/rdesktop.c +++ b/rdesktop.c @@ -81,7 +81,8 @@ main(int argc, char *argv[]) int c; printf("rdesktop: A Remote Desktop Protocol client.\n"); - printf("Version " VERSION ". Copyright (C) 1999-2001 Matt Chapman.\n"); + printf("Version " VERSION + ". Copyright (C) 1999-2001 Matt Chapman.\n"); printf("See http://www.rdesktop.org/ for more information.\n\n"); flags = RDP_LOGON_NORMAL; @@ -118,13 +119,14 @@ main(int argc, char *argv[]) break; case 'k': - STRNCPY(keymapname, optarg, sizeof(keymapname)); + STRNCPY(keymapname, optarg, + sizeof(keymapname)); break; case 'g': width = strtol(optarg, &p, 10); if (*p == 'x') - height = strtol(p+1, NULL, 10); + height = strtol(p + 1, NULL, 10); if ((width == 0) || (height == 0)) { @@ -238,7 +240,7 @@ main(int argc, char *argv[]) /* Generate a 32-byte random for the secure transport code. */ void -generate_random(uint8 *random) +generate_random(uint8 * random) { struct stat st; struct tms tmsbuf; @@ -343,7 +345,7 @@ hexdump(unsigned char *p, unsigned int len) printf("%02x ", line[i]); for (; i < 16; i++) - printf(" "); + printf(" "); for (i = 0; i < thisline; i++) printf("%c", @@ -369,7 +371,7 @@ load_licence(unsigned char **data) return -1; STRNCPY(path, home, sizeof(path)); - strncat(path, "/.rdesktop/licence", sizeof(path)-strlen(path)-1); + strncat(path, "/.rdesktop/licence", sizeof(path) - strlen(path) - 1); fd = open(path, O_RDONLY); if (fd == -1) @@ -394,12 +396,12 @@ save_licence(unsigned char *data, int length) return; STRNCPY(path, home, sizeof(path)); - strncat(path, "/.rdesktop", sizeof(path)-strlen(path)-1); + strncat(path, "/.rdesktop", sizeof(path) - strlen(path) - 1); mkdir(path, 0700); - strncat(path, "/licence", sizeof(path)-strlen(path)-1); + strncat(path, "/licence", sizeof(path) - strlen(path) - 1); - fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0600); + fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0600); if (fd == -1) { perror("open"); @@ -409,4 +411,3 @@ save_licence(unsigned char *data, int length) write(fd, data, length); close(fd); } - diff --git a/rdp.c b/rdp.c index 6f0d6c5..1876192 100644 --- a/rdp.c +++ b/rdp.c @@ -60,7 +60,7 @@ rdp_send(STREAM s, uint8 pdu_type) /* Receive an RDP packet */ static STREAM -rdp_recv(uint8 *type) +rdp_recv(uint8 * type) { static STREAM rdp_s; uint16 length, pdu_type; @@ -156,7 +156,7 @@ rdp_send_logon_info(uint32 flags, char *domain, char *user, int len_program = 2 * strlen(program); int len_directory = 2 * strlen(directory); uint32 sec_flags = encryption ? (SEC_LOGON_INFO | SEC_ENCRYPT) - : SEC_LOGON_INFO; + : SEC_LOGON_INFO; STREAM s; s = sec_init(sec_flags, 18 + len_domain + len_user + len_password @@ -443,7 +443,7 @@ rdp_send_confirm_active() RDP_CAPLEN_BMPCACHE + RDP_CAPLEN_COLCACHE + RDP_CAPLEN_ACTIVATE + RDP_CAPLEN_CONTROL + RDP_CAPLEN_POINTER + RDP_CAPLEN_SHARE + RDP_CAPLEN_UNKNOWN - + 4 /* w2k fix, why? */; + + 4 /* w2k fix, why? */ ; s = rdp_init(14 + caplen + sizeof(RDP_SOURCE)); @@ -616,7 +616,7 @@ process_palette(STREAM s) in_uint16_le(s, map.ncolours); in_uint8s(s, 2); /* pad */ in_uint8p(s, colours, (map.ncolours * 3)); - map.colours = (COLOURENTRY *)colours; + map.colours = (COLOURENTRY *) colours; hmap = ui_create_colourmap(&map); ui_set_colourmap(hmap); diff --git a/secure.c b/secure.c index bb9fd3d..c947163 100644 --- a/secure.c +++ b/secure.c @@ -56,7 +56,7 @@ static uint8 sec_crypted_random[SEC_MODULUS_SIZE]; * Both SHA1 and MD5 algorithms are used. */ void -sec_hash_48(uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2, uint8 salt) +sec_hash_48(uint8 * out, uint8 * in, uint8 * salt1, uint8 * salt2, uint8 salt) { uint8 shasig[20]; uint8 pad[4]; @@ -87,7 +87,7 @@ sec_hash_48(uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2, uint8 salt) * only using a single round of MD5. */ void -sec_hash_16(uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2) +sec_hash_16(uint8 * out, uint8 * in, uint8 * salt1, uint8 * salt2) { MD5_CTX md5; @@ -100,7 +100,7 @@ sec_hash_16(uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2) /* Reduce key entropy from 64 to 40 bits */ static void -sec_make_40bit(uint8 *key) +sec_make_40bit(uint8 * key) { key[0] = 0xd1; key[1] = 0x26; @@ -109,7 +109,7 @@ sec_make_40bit(uint8 *key) /* Generate a session key and RC4 keys, given client and server randoms */ static void -sec_generate_keys(uint8 *client_key, uint8 *server_key, int rc4_key_size) +sec_generate_keys(uint8 * client_key, uint8 * server_key, int rc4_key_size) { uint8 session_key[48]; uint8 temp_hash[48]; @@ -171,7 +171,7 @@ static uint8 pad_92[48] = { /* Output a uint32 into a buffer (little-endian) */ void -buf_out_uint32(uint8 *buffer, uint32 value) +buf_out_uint32(uint8 * buffer, uint32 value) { buffer[0] = (value) & 0xff; buffer[1] = (value >> 8) & 0xff; @@ -181,8 +181,8 @@ buf_out_uint32(uint8 *buffer, uint32 value) /* Generate a signature hash, using a combination of SHA1 and MD5 */ void -sec_sign(uint8 *signature, int siglen, uint8 *session_key, int keylen, - uint8 *data, int datalen) +sec_sign(uint8 * signature, int siglen, uint8 * session_key, int keylen, + uint8 * data, int datalen) { uint8 shasig[20]; uint8 md5sig[16]; @@ -210,7 +210,7 @@ sec_sign(uint8 *signature, int siglen, uint8 *session_key, int keylen, /* Update an encryption key - similar to the signing process */ static void -sec_update(uint8 *key, uint8 *update_key) +sec_update(uint8 * key, uint8 * update_key) { uint8 shasig[20]; SHA_CTX sha; @@ -238,7 +238,7 @@ sec_update(uint8 *key, uint8 *update_key) /* Encrypt data using RC4 */ static void -sec_encrypt(uint8 *data, int length) +sec_encrypt(uint8 * data, int length) { static int use_count; @@ -255,7 +255,7 @@ sec_encrypt(uint8 *data, int length) /* Decrypt data using RC4 */ static void -sec_decrypt(uint8 *data, int length) +sec_decrypt(uint8 * data, int length) { static int use_count; @@ -271,12 +271,12 @@ sec_decrypt(uint8 *data, int length) } static void -reverse(uint8 *p, int len) +reverse(uint8 * p, int len) { int i, j; uint8 temp; - for (i = 0, j = len-1; i < j; i++, j--) + for (i = 0, j = len - 1; i < j; i++, j--) { temp = p[i]; p[i] = p[j]; @@ -286,8 +286,8 @@ reverse(uint8 *p, int len) /* Perform an RSA public key encryption operation */ static void -sec_rsa_encrypt(uint8 *out, uint8 *in, int len, - uint8 *modulus, uint8 *exponent) +sec_rsa_encrypt(uint8 * out, uint8 * in, int len, + uint8 * modulus, uint8 * exponent) { BN_CTX ctx; BIGNUM mod, exp, x, y; @@ -312,7 +312,7 @@ sec_rsa_encrypt(uint8 *out, uint8 *in, int len, outlen = BN_bn2bin(&y, out); reverse(out, outlen); if (outlen < SEC_MODULUS_SIZE) - memset(out+outlen, 0, SEC_MODULUS_SIZE-outlen); + memset(out + outlen, 0, SEC_MODULUS_SIZE - outlen); BN_free(&y); BN_clear_free(&x); @@ -358,7 +358,8 @@ sec_send(STREAM s, uint32 flags) hexdump(s->p + 8, datalen); #endif - sec_sign(s->p, 8, sec_sign_key, rc4_key_len, s->p + 8, datalen); + sec_sign(s->p, 8, sec_sign_key, rc4_key_len, s->p + 8, + datalen); sec_encrypt(s->p + 8, datalen); } @@ -438,7 +439,7 @@ sec_out_mcs_data(STREAM s) /* Parse a public key structure */ static BOOL -sec_parse_public_key(STREAM s, uint8 **modulus, uint8 **exponent) +sec_parse_public_key(STREAM s, uint8 ** modulus, uint8 ** exponent) { uint32 magic, modulus_len; @@ -466,8 +467,9 @@ sec_parse_public_key(STREAM s, uint8 **modulus, uint8 **exponent) /* Parse a crypto information structure */ static BOOL -sec_parse_crypt_info(STREAM s, uint32 *rc4_key_size, - uint8 **server_random, uint8 **modulus, uint8 **exponent) +sec_parse_crypt_info(STREAM s, uint32 * rc4_key_size, + uint8 ** server_random, uint8 ** modulus, + uint8 ** exponent) { uint32 crypt_level, random_len, rsa_info_len; uint16 tag, length; diff --git a/types.h b/types.h index 35daf12..67bce3f 100644 --- a/types.h +++ b/types.h @@ -40,14 +40,16 @@ typedef struct _COLOURENTRY uint8 green; uint8 blue; -} COLOURENTRY; +} +COLOURENTRY; typedef struct _COLOURMAP { uint16 ncolours; COLOURENTRY *colours; -} COLOURMAP; +} +COLOURMAP; typedef struct _BOUNDS { @@ -56,7 +58,8 @@ typedef struct _BOUNDS uint16 right; uint16 bottom; -} BOUNDS; +} +BOUNDS; typedef struct _PEN { @@ -64,7 +67,8 @@ typedef struct _PEN uint8 width; uint8 colour; -} PEN; +} +PEN; typedef struct _BRUSH { @@ -73,7 +77,8 @@ typedef struct _BRUSH uint8 style; uint8 pattern[8]; -} BRUSH; +} +BRUSH; typedef struct _FONTGLYPH { @@ -83,11 +88,13 @@ typedef struct _FONTGLYPH uint16 height; HBITMAP pixmap; -} FONTGLYPH; +} +FONTGLYPH; typedef struct _DATABLOB { void *data; int size; -} DATABLOB; +} +DATABLOB; diff --git a/xkeymap.c b/xkeymap.c index 71cddcb..774a7ab 100644 --- a/xkeymap.c +++ b/xkeymap.c @@ -36,7 +36,8 @@ extern int keylayout; static uint8 keymap[KEYMAP_SIZE]; static unsigned int min_keycode; -static BOOL xkeymap_read(char *mapname) +static BOOL +xkeymap_read(char *mapname) { FILE *fp; char line[PATH_MAX], path[PATH_MAX]; @@ -72,21 +73,23 @@ static BOOL xkeymap_read(char *mapname) keysym = XStringToKeysym(keyname); if (keysym == NoSymbol) - error("Bad keysym %s in keymap %s\n", keyname, mapname); + error("Bad keysym %s in keymap %s\n", + keyname, mapname); keymap[keysym & KEYMAP_MASK] = keycode; keyname = p; - } while (keyname != NULL); + } + while (keyname != NULL); } else if (strncmp(line, "include ", 8) == 0) { - if (!xkeymap_read(line+8)) + if (!xkeymap_read(line + 8)) return False; } else if (strncmp(line, "map ", 4) == 0) { - keylayout = strtol(line+4, NULL, 16); + keylayout = strtol(line + 4, NULL, 16); } else if (line[0] != '#') { @@ -98,7 +101,8 @@ static BOOL xkeymap_read(char *mapname) return True; } -void xkeymap_init(void) +void +xkeymap_init(void) { unsigned int max_keycode; @@ -108,7 +112,9 @@ void xkeymap_init(void) xkeymap_read(keymapname); } -uint8 xkeymap_translate_key(unsigned int keysym, unsigned int keycode, uint16 *flags) +uint8 +xkeymap_translate_key(unsigned int keysym, unsigned int keycode, + uint16 * flags) { uint8 scancode; @@ -124,7 +130,7 @@ uint8 xkeymap_translate_key(unsigned int keysym, unsigned int keycode, uint16 *f /* not in keymap, try to interpret the raw scancode */ if ((keycode >= min_keycode) && (keycode <= 0x60)) - return (uint8)(keycode - min_keycode); + return (uint8) (keycode - min_keycode); *flags |= KBD_FLAG_EXT; @@ -173,19 +179,20 @@ uint8 xkeymap_translate_key(unsigned int keysym, unsigned int keycode, uint16 *f return 0; } -uint16 xkeymap_translate_button(unsigned int button) +uint16 +xkeymap_translate_button(unsigned int button) { switch (button) { - case Button1: /* left */ + case Button1: /* left */ return MOUSE_FLAG_BUTTON1; - case Button2: /* middle */ + case Button2: /* middle */ return MOUSE_FLAG_BUTTON3; - case Button3: /* right */ + case Button3: /* right */ return MOUSE_FLAG_BUTTON2; - case Button4: /* wheel up */ + case Button4: /* wheel up */ return MOUSE_FLAG_BUTTON4; - case Button5: /* wheel down */ + case Button5: /* wheel down */ return MOUSE_FLAG_BUTTON5; } diff --git a/xwin.c b/xwin.c index ae35f67..247e99c 100644 --- a/xwin.c +++ b/xwin.c @@ -106,27 +106,27 @@ static int rop2_map[] = { #define RESET_FUNCTION(rop2) { if (rop2 != ROP2_COPY) XSetFunction(display, gc, GXcopy); } void xwin_get_numlock_mask(); -void xwin_mod_update(uint32 state, uint32 ev_time ); +void xwin_mod_update(uint32 state, uint32 ev_time); void xwin_mod_release(uint32 state, uint32 ev_time, uint32 scancode); void xwin_mod_press(uint32 state, uint32 ev_time, uint32 scancode); static void -translate8(uint8 *data, uint8 *out, uint8 *end) +translate8(uint8 * data, uint8 * out, uint8 * end) { while (out < end) - *(out++) = (uint8)colmap[*(data++)]; + *(out++) = (uint8) colmap[*(data++)]; } static void -translate16(uint8 *data, uint16 *out, uint16 *end) +translate16(uint8 * data, uint16 * out, uint16 * end) { while (out < end) - *(out++) = (uint16)colmap[*(data++)]; + *(out++) = (uint16) colmap[*(data++)]; } /* little endian - conversion happens when colourmap is built */ static void -translate24(uint8 *data, uint8 *out, uint8 *end) +translate24(uint8 * data, uint8 * out, uint8 * end) { uint32 value; @@ -140,16 +140,16 @@ translate24(uint8 *data, uint8 *out, uint8 *end) } static void -translate32(uint8 *data, uint32 *out, uint32 *end) +translate32(uint8 * data, uint32 * out, uint32 * end) { while (out < end) *(out++) = colmap[*(data++)]; } static uint8 * -translate_image(int width, int height, uint8 *data) +translate_image(int width, int height, uint8 * data) { - int size = width * height * bpp/8; + int size = width * height * bpp / 8; uint8 *out = xmalloc(size); uint8 *end = out + size; @@ -160,7 +160,7 @@ translate_image(int width, int height, uint8 *data) break; case 16: - translate16(data, (uint16 *)out, (uint16 *)end); + translate16(data, (uint16 *) out, (uint16 *) end); break; case 24: @@ -168,7 +168,7 @@ translate_image(int width, int height, uint8 *data) break; case 32: - translate32(data, (uint32 *)out, (uint32 *)end); + translate32(data, (uint32 *) out, (uint32 *) end); break; } @@ -215,22 +215,24 @@ ui_create_window(char *title) Screen *screen; uint16 test; int i; - + int xkb_minor, xkb_major; int xkb_event, xkb_error, xkb_reason; /* compare compiletime libs with runtime libs. */ xkb_major = XkbMajorVersion; xkb_minor = XkbMinorVersion; - if( XkbLibraryVersion( &xkb_major, &xkb_minor ) == False ) + if (XkbLibraryVersion(&xkb_major, &xkb_minor) == False) { error("please re-compile rdesktop\ncompile time version of xkb is not compatible with\nyour runtime version of the library\n"); return False; } - display = XkbOpenDisplay( NULL, &xkb_event, &xkb_error, &xkb_major, &xkb_minor, &xkb_reason ); - switch(xkb_reason) + display = + XkbOpenDisplay(NULL, &xkb_event, &xkb_error, &xkb_major, + &xkb_minor, &xkb_reason); + switch (xkb_reason) { case XkbOD_BadLibraryVersion: error("XkbOD_BadLibraryVersion: XKB extensions in server and the library rdesktop is linked against aren't compatible with each other.\n"); @@ -259,7 +261,7 @@ ui_create_window(char *title) screen = DefaultScreenOfDisplay(display); visual = DefaultVisualOfScreen(screen); depth = DefaultDepthOfScreen(screen); - + pfm = XListPixmapFormats(display, &i); if (pfm != NULL) { @@ -289,7 +291,7 @@ ui_create_window(char *title) xcolmap = DefaultColormapOfScreen(screen); test = 1; - host_be = !(BOOL)(*(uint8 *)(&test)); + host_be = !(BOOL) (*(uint8 *) (&test)); xserver_be = (ImageByteOrder(display) == MSBFirst); white = WhitePixelOfScreen(screen); @@ -310,7 +312,7 @@ ui_create_window(char *title) attribs.override_redirect = False; } - width = (width + 3) & ~3; /* make width a multiple of 32 bits */ + width = (width + 3) & ~3; /* make width a multiple of 32 bits */ wnd = XCreateWindow(display, RootWindowOfScreen(screen), 0, 0, width, height, 0, CopyFromParent, @@ -341,8 +343,8 @@ ui_create_window(char *title) xkeymap_init(); input_mask = KeyPressMask | KeyReleaseMask | - ButtonPressMask | ButtonReleaseMask | - EnterWindowMask | LeaveWindowMask; + ButtonPressMask | ButtonReleaseMask | + EnterWindowMask | LeaveWindowMask; if (sendmotion) input_mask |= PointerMotionMask; @@ -359,19 +361,21 @@ ui_create_window(char *title) /* TODO: error texts... make them friendly. */ xkb = XkbGetKeyboard(display, XkbAllComponentsMask, XkbUseCoreKbd); - if ((int)xkb == BadAlloc || xkb == NULL) - { - error( "XkbGetKeyboard failed.\n"); - exit(0); - } + if ((int) xkb == BadAlloc || xkb == NULL) + { + error("XkbGetKeyboard failed.\n"); + exit(0); + } /* TODO: error texts... make them friendly. */ - if( XkbSelectEvents(display, xkb->device_spec, XkbAllEventsMask, XkbAllEventsMask) == False ) + if (XkbSelectEvents + (display, xkb->device_spec, XkbAllEventsMask, + XkbAllEventsMask) == False) { - error( "XkbSelectEvents failed.\n"); - exit(0); + error("XkbSelectEvents failed.\n"); + exit(0); } - + xwin_get_numlock_mask(); return True; @@ -381,28 +385,37 @@ void xwin_get_numlock_mask() { KeyCode numlockcode; - KeyCode* keycode; + KeyCode *keycode; XModifierKeymap *modmap; - int i,j; + int i, j; /* Find out if numlock is already defined as a modifier key, and if so where */ numlockcode = XKeysymToKeycode(display, 0xFF7F); /* XF_Num_Lock = 0xFF7F */ - if (numlockcode) { + if (numlockcode) + { modmap = XGetModifierMapping(display); - if (modmap) { + if (modmap) + { keycode = modmap->modifiermap; for (i = 0; i < 8; i++) - for (j = modmap->max_keypermod; j--;) { - if (*keycode == numlockcode) { - numlock_modifier_mask = (1 << i); + for (j = modmap->max_keypermod; j--;) + { + if (*keycode == numlockcode) + { + numlock_modifier_mask = + (1 << i); i = 8; break; } keycode++; } - if (!numlock_modifier_mask) { - modmap->modifiermap[7 * modmap->max_keypermod] = numlockcode; - if (XSetModifierMapping(display, modmap) == MappingSuccess) + if (!numlock_modifier_mask) + { + modmap->modifiermap[7 * + modmap->max_keypermod] = + numlockcode; + if (XSetModifierMapping(display, modmap) == + MappingSuccess) numlock_modifier_mask = (1 << 7); else printf("XSetModifierMapping failed!\n"); @@ -413,13 +426,13 @@ xwin_get_numlock_mask() if (!numlock_modifier_mask) printf("WARNING: Failed to get a numlock modifier mapping.\n"); - + } void ui_destroy_window() { - if( xkb != NULL ) + if (xkb != NULL) XkbFreeKeyboard(xkb, XkbAllControlsMask, True); if (ownbackstore) @@ -453,21 +466,31 @@ xwin_process_events() flags = KBD_FLAG_DOWN | KBD_FLAG_UP; /* fall through */ case KeyPress: - if( XkbTranslateKeyCode(xkb, xevent.xkey.keycode, xevent.xkey.state, &tmpmods, &keysym) == False ) + if (XkbTranslateKeyCode + (xkb, xevent.xkey.keycode, + xevent.xkey.state, &tmpmods, + &keysym) == False) break; - scancode = xkeymap_translate_key(keysym, xevent.xkey.keycode, &flags); + scancode = + xkeymap_translate_key(keysym, + xevent.xkey. + keycode, + &flags); - if (scancode == 0 ) + if (scancode == 0) break; /* keep track of the modifiers -- needed for stickykeys... */ - if( xevent.type == KeyPress ) - xwin_mod_press( xevent.xkey.state, ev_time, scancode ); + if (xevent.type == KeyPress) + xwin_mod_press(xevent.xkey.state, + ev_time, scancode); - rdp_send_input(ev_time, RDP_INPUT_SCANCODE, flags, scancode, 0); + rdp_send_input(ev_time, RDP_INPUT_SCANCODE, + flags, scancode, 0); - if( xevent.type == KeyRelease ) - xwin_mod_release( xevent.xkey.state, ev_time, scancode ); + if (xevent.type == KeyRelease) + xwin_mod_release(xevent.xkey.state, + ev_time, scancode); break; @@ -476,7 +499,9 @@ xwin_process_events() /* fall through */ case ButtonRelease: - button = xkeymap_translate_button(xevent.xbutton.button); + button = xkeymap_translate_button(xevent. + xbutton. + button); if (button == 0) break; @@ -494,10 +519,12 @@ xwin_process_events() break; case EnterNotify: - XGrabKeyboard(display, wnd, True, GrabModeAsync, - GrabModeAsync, CurrentTime); + XGrabKeyboard(display, wnd, True, + GrabModeAsync, GrabModeAsync, + CurrentTime); - xwin_mod_update( xevent.xcrossing.state, ev_time ); + xwin_mod_update(xevent.xcrossing.state, + ev_time); break; case LeaveNotify: @@ -507,7 +534,8 @@ xwin_process_events() case Expose: XCopyArea(display, backstore, wnd, gc, xevent.xexpose.x, xevent.xexpose.y, - xevent.xexpose.width, xevent.xexpose.height, + xevent.xexpose.width, + xevent.xexpose.height, xevent.xexpose.x, xevent.xexpose.y); break; } @@ -515,7 +543,7 @@ xwin_process_events() } void -xwin_mod_update(uint32 state, uint32 ev_time ) +xwin_mod_update(uint32 state, uint32 ev_time) { xwin_mod_press(state, ev_time, 0); xwin_mod_release(state, ev_time, 0); @@ -524,67 +552,75 @@ xwin_mod_update(uint32 state, uint32 ev_time ) void xwin_mod_release(uint32 state, uint32 ev_time, uint32 scancode) { - switch (scancode) { - case 0x2a: - key_down_state &= ~DShift1Mask; - break; - case 0x36: - key_down_state &= ~DShift2Mask; - break; - case 0x1d: - key_down_state &= ~DControl1Mask; - break; - case 0x9d: - key_down_state &= ~DControl2Mask; - break; - case 0x38: - key_down_state &= ~DMod1Mask; - break; - case 0xb8: - key_down_state &= ~DMod2Mask; - break; + switch (scancode) + { + case 0x2a: + key_down_state &= ~DShift1Mask; + break; + case 0x36: + key_down_state &= ~DShift2Mask; + break; + case 0x1d: + key_down_state &= ~DControl1Mask; + break; + case 0x9d: + key_down_state &= ~DControl2Mask; + break; + case 0x38: + key_down_state &= ~DMod1Mask; + break; + case 0xb8: + key_down_state &= ~DMod2Mask; + break; } - if( !(numlock_modifier_mask & state) && (key_down_state & DNumLockMask) ) + if (!(numlock_modifier_mask & state) + && (key_down_state & DNumLockMask)) { rdp_send_input(ev_time, RDP_INPUT_SCANCODE, 0, 0x45, 0); - rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_DOWN | KBD_FLAG_UP, 0x45, 0); + rdp_send_input(ev_time, RDP_INPUT_SCANCODE, + KBD_FLAG_DOWN | KBD_FLAG_UP, 0x45, 0); key_down_state &= ~DNumLockMask; } - if( !(LockMask & state) && (key_down_state & DLockMask)) + if (!(LockMask & state) && (key_down_state & DLockMask)) { rdp_send_input(ev_time, RDP_INPUT_SCANCODE, 0, 0x3a, 0); - rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_DOWN | KBD_FLAG_UP, 0x3a, 0); + rdp_send_input(ev_time, RDP_INPUT_SCANCODE, + KBD_FLAG_DOWN | KBD_FLAG_UP, 0x3a, 0); key_down_state &= ~DLockMask; } - if( !(ShiftMask & state) && (key_down_state & DShift1Mask)) + if (!(ShiftMask & state) && (key_down_state & DShift1Mask)) { - rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_UP, 0x2a, 0); + rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_UP, 0x2a, + 0); key_down_state &= ~DShift1Mask; } - if( !(ControlMask & state) && (key_down_state & DControl1Mask)) + if (!(ControlMask & state) && (key_down_state & DControl1Mask)) { - rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_UP, 0x1d, 0); + rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_UP, 0x1d, + 0); key_down_state &= ~DControl1Mask; } - if( !(Mod1Mask & state) && (key_down_state & DMod1Mask)) + if (!(Mod1Mask & state) && (key_down_state & DMod1Mask)) { - rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_UP, 0x38, 0); + rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_UP, 0x38, + 0); key_down_state &= ~DMod1Mask; } - if( !(Mod2Mask & state) && (key_down_state & DMod2Mask)) + if (!(Mod2Mask & state) && (key_down_state & DMod2Mask)) { - rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_UP, 0xb8, 0); + rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_UP, 0xb8, + 0); key_down_state &= ~DMod2Mask; } } @@ -594,73 +630,85 @@ void xwin_mod_press(uint32 state, uint32 ev_time, uint32 scancode) { - switch (scancode) { - case 0x2a: - key_down_state |= DShift1Mask; - break; - case 0x36: - key_down_state |= DShift2Mask; - break; - case 0x1d: - key_down_state |= DControl1Mask; - break; - case 0x9d: - key_down_state |= DControl2Mask; - break; - case 0x3a: - key_down_state ^= DLockMask; - break; - case 0x45: - key_down_state ^= DNumLockMask; - break; - case 0x38: - key_down_state |= DMod1Mask; - break; - case 0xb8: - key_down_state |= DMod2Mask; - break; + switch (scancode) + { + case 0x2a: + key_down_state |= DShift1Mask; + break; + case 0x36: + key_down_state |= DShift2Mask; + break; + case 0x1d: + key_down_state |= DControl1Mask; + break; + case 0x9d: + key_down_state |= DControl2Mask; + break; + case 0x3a: + key_down_state ^= DLockMask; + break; + case 0x45: + key_down_state ^= DNumLockMask; + break; + case 0x38: + key_down_state |= DMod1Mask; + break; + case 0xb8: + key_down_state |= DMod2Mask; + break; } - if( (numlock_modifier_mask && state) && !(key_down_state & DNumLockMask) ) + if ((numlock_modifier_mask && state) + && !(key_down_state & DNumLockMask)) { rdp_send_input(ev_time, RDP_INPUT_SCANCODE, 0, 0x45, 0); - rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_DOWN | KBD_FLAG_UP, 0x45, 0); + rdp_send_input(ev_time, RDP_INPUT_SCANCODE, + KBD_FLAG_DOWN | KBD_FLAG_UP, 0x45, 0); key_down_state |= DNumLockMask; } - if( (LockMask & state) && !(key_down_state & DLockMask)) + if ((LockMask & state) && !(key_down_state & DLockMask)) { rdp_send_input(ev_time, RDP_INPUT_SCANCODE, 0, 0x3a, 0); - rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_DOWN | KBD_FLAG_UP, 0x3a, 0); + rdp_send_input(ev_time, RDP_INPUT_SCANCODE, + KBD_FLAG_DOWN | KBD_FLAG_UP, 0x3a, 0); key_down_state |= DLockMask; } - if( (ShiftMask & state) && !((key_down_state & DShift1Mask) || (key_down_state & DShift2Mask))) + if ((ShiftMask & state) + && !((key_down_state & DShift1Mask) + || (key_down_state & DShift2Mask))) { - rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_DOWN, 0x2a, 0); + rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_DOWN, + 0x2a, 0); key_down_state |= DShift1Mask; } - if( (ControlMask & state) && !((key_down_state & DControl1Mask) || (key_down_state & DControl2Mask))) + if ((ControlMask & state) + && !((key_down_state & DControl1Mask) + || (key_down_state & DControl2Mask))) { - rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_DOWN, 0x1d, 0); + rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_DOWN, + 0x1d, 0); key_down_state |= DControl1Mask; } - if( (Mod1Mask & state) && !(key_down_state & DMod1Mask)) + if ((Mod1Mask & state) && !(key_down_state & DMod1Mask)) { - rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_DOWN, 0x38, 0); + rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_DOWN, + 0x38, 0); key_down_state |= DMod1Mask; } - if( (Mod2Mask & state) && !(key_down_state & DMod2Mask)) + if ((Mod2Mask & state) && !(key_down_state & DMod2Mask)) { - rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_DOWN, 0xb8, 0); + rdp_send_input(ev_time, RDP_INPUT_SCANCODE, KBD_FLAG_DOWN, + 0xb8, 0); key_down_state |= DMod2Mask; } @@ -669,7 +717,7 @@ xwin_mod_press(uint32 state, uint32 ev_time, uint32 scancode) void ui_select(int rdp_socket) { - int n = (rdp_socket > x_socket) ? rdp_socket+1 : x_socket+1; + int n = (rdp_socket > x_socket) ? rdp_socket + 1 : x_socket + 1; fd_set rfds; FD_ZERO(&rfds); @@ -708,7 +756,7 @@ ui_move_pointer(int x, int y) } HBITMAP -ui_create_bitmap(int width, int height, uint8 *data) +ui_create_bitmap(int width, int height, uint8 * data) { XImage *image; Pixmap bitmap; @@ -729,7 +777,7 @@ ui_create_bitmap(int width, int height, uint8 *data) void ui_paint_bitmap(int x, int y, int cx, int cy, - int width, int height, uint8 *data) + int width, int height, uint8 * data) { XImage *image; uint8 *tdata; @@ -756,11 +804,11 @@ ui_paint_bitmap(int x, int y, int cx, int cy, void ui_destroy_bitmap(HBITMAP bmp) { - XFreePixmap(display, (Pixmap)bmp); + XFreePixmap(display, (Pixmap) bmp); } HGLYPH -ui_create_glyph(int width, int height, uint8 *data) +ui_create_glyph(int width, int height, uint8 * data) { XImage *image; Pixmap bitmap; @@ -782,18 +830,18 @@ ui_create_glyph(int width, int height, uint8 *data) XFree(image); XFreeGC(display, gc); - return (HGLYPH)bitmap; + return (HGLYPH) bitmap; } void ui_destroy_glyph(HGLYPH glyph) { - XFreePixmap(display, (Pixmap)glyph); + XFreePixmap(display, (Pixmap) glyph); } HCURSOR ui_create_cursor(unsigned int x, unsigned int y, int width, - int height, uint8 *andmask, uint8 *xormask) + int height, uint8 * andmask, uint8 * xormask) { HGLYPH maskglyph, cursorglyph; XColor bg, fg; @@ -850,27 +898,27 @@ ui_create_cursor(unsigned int x, unsigned int y, int width, cursorglyph = ui_create_glyph(width, height, cursor); maskglyph = ui_create_glyph(width, height, mask); - - xcursor = XCreatePixmapCursor(display, (Pixmap)cursorglyph, - (Pixmap)maskglyph, &fg, &bg, x, y); + + xcursor = XCreatePixmapCursor(display, (Pixmap) cursorglyph, + (Pixmap) maskglyph, &fg, &bg, x, y); ui_destroy_glyph(maskglyph); ui_destroy_glyph(cursorglyph); xfree(mask); xfree(cursor); - return (HCURSOR)xcursor; + return (HCURSOR) xcursor; } void ui_set_cursor(HCURSOR cursor) { - XDefineCursor(display, wnd, (Cursor)cursor); + XDefineCursor(display, wnd, (Cursor) cursor); } void ui_destroy_cursor(HCURSOR cursor) { - XFreeCursor(display, (Cursor)cursor); + XFreeCursor(display, (Cursor) cursor); } #define MAKE_XCOLOR(xc,c) \ @@ -880,7 +928,7 @@ ui_destroy_cursor(HCURSOR cursor) (xc)->flags = DoRed | DoGreen | DoBlue; HCOLOURMAP -ui_create_colourmap(COLOURMAP *colours) +ui_create_colourmap(COLOURMAP * colours) { COLOURENTRY *entry; int i, ncolours = colours->ncolours; @@ -903,7 +951,7 @@ ui_create_colourmap(COLOURMAP *colours) XStoreColors(display, map, xcolours, ncolours); xfree(xcolours); - return (HCOLOURMAP)map; + return (HCOLOURMAP) map; } else { @@ -933,7 +981,7 @@ void ui_destroy_colourmap(HCOLOURMAP map) { if (owncolmap) - XFreeColormap(display, (Colormap)map); + XFreeColormap(display, (Colormap) map); else xfree(map); } @@ -942,7 +990,7 @@ void ui_set_colourmap(HCOLOURMAP map) { if (owncolmap) - XSetWindowColormap(display, wnd, (Colormap)map); + XSetWindowColormap(display, wnd, (Colormap) map); else colmap = map; } @@ -989,7 +1037,7 @@ ui_destblt(uint8 opcode, void ui_patblt(uint8 opcode, /* dest */ int x, int y, int cx, int cy, - /* brush */ BRUSH *brush, int bgcolour, int fgcolour) + /* brush */ BRUSH * brush, int bgcolour, int fgcolour) { Pixmap fill; uint8 i, ipattern[8]; @@ -1012,12 +1060,13 @@ ui_patblt(uint8 opcode, SET_BACKGROUND(fgcolour); XSetFillStyle(display, gc, FillOpaqueStippled); XSetStipple(display, gc, fill); - XSetTSOrigin(display, gc, brush->xorigin, brush->yorigin); + XSetTSOrigin(display, gc, brush->xorigin, + brush->yorigin); FILL_RECTANGLE(x, y, cx, cy); XSetFillStyle(display, gc, FillSolid); - ui_destroy_glyph((HGLYPH)fill); + ui_destroy_glyph((HGLYPH) fill); break; default: @@ -1046,9 +1095,9 @@ ui_memblt(uint8 opcode, /* src */ HBITMAP src, int srcx, int srcy) { SET_FUNCTION(opcode); - XCopyArea(display, (Pixmap)src, wnd, gc, srcx, srcy, cx, cy, x, y); + XCopyArea(display, (Pixmap) src, wnd, gc, srcx, srcy, cx, cy, x, y); if (ownbackstore) - XCopyArea(display, (Pixmap)src, backstore, gc, srcx, srcy, + XCopyArea(display, (Pixmap) src, backstore, gc, srcx, srcy, cx, cy, x, y); RESET_FUNCTION(opcode); } @@ -1057,7 +1106,7 @@ void ui_triblt(uint8 opcode, /* dest */ int x, int y, int cx, int cy, /* src */ HBITMAP src, int srcx, int srcy, - /* brush */ BRUSH *brush, int bgcolour, int fgcolour) + /* brush */ BRUSH * brush, int bgcolour, int fgcolour) { /* This is potentially difficult to do in general. Until someone comes up with a more efficient way of doing it I am using cases. */ @@ -1093,7 +1142,7 @@ ui_triblt(uint8 opcode, void ui_line(uint8 opcode, /* dest */ int startx, int starty, int endx, int endy, - /* pen */ PEN *pen) + /* pen */ PEN * pen) { SET_FUNCTION(opcode); SET_FOREGROUND(pen->colour); @@ -1123,7 +1172,7 @@ ui_draw_glyph(int mixmode, XSetFillStyle(display, gc, (mixmode == MIX_TRANSPARENT) ? FillStippled : FillOpaqueStippled); - XSetStipple(display, gc, (Pixmap)glyph); + XSetStipple(display, gc, (Pixmap) glyph); XSetTSOrigin(display, gc, x, y); FILL_RECTANGLE(x, y, cx, cy); @@ -1185,48 +1234,57 @@ ui_draw_text(uint8 font, uint8 flags, int mixmode, int x, int y, } /* Paint text, character by character */ - for (i = 0; i < length;) { - switch (text[i]) { - case 0xff: - if (i + 2 < length) - cache_put_text(text[i + 1], text, text[i + 2]); - else { - error("this shouldn't be happening\n"); - break; - } - /* this will move pointer from start to first character after FF command */ - length -= i + 3; - text = &(text[i + 3]); - i = 0; - break; - - case 0xfe: - entry = cache_get_text(text[i + 1]); - if (entry != NULL) { - if ((((uint8 *) (entry->data))[1] == 0) - && (!(flags & TEXT2_IMPLICIT_X))) { - if (flags & TEXT2_VERTICAL) - y += text[i + 2]; - else - x += text[i + 2]; - } + for (i = 0; i < length;) + { + switch (text[i]) + { + case 0xff: if (i + 2 < length) - i += 3; + cache_put_text(text[i + 1], text, + text[i + 2]); else - i += 2; - length -= i; - /* this will move pointer from start to first character after FE command */ - text = &(text[i]); + { + error("this shouldn't be happening\n"); + break; + } + /* this will move pointer from start to first character after FF command */ + length -= i + 3; + text = &(text[i + 3]); i = 0; - for (j = 0; j < entry->size; j++) - DO_GLYPH(((uint8 *) (entry->data)), j); - } - break; + break; - default: - DO_GLYPH(text, i); - i++; - break; + case 0xfe: + entry = cache_get_text(text[i + 1]); + if (entry != NULL) + { + if ((((uint8 *) (entry->data))[1] == + 0) + && (!(flags & TEXT2_IMPLICIT_X))) + { + if (flags & TEXT2_VERTICAL) + y += text[i + 2]; + else + x += text[i + 2]; + } + if (i + 2 < length) + i += 3; + else + i += 2; + length -= i; + /* this will move pointer from start to first character after FE command */ + text = &(text[i]); + i = 0; + for (j = 0; j < entry->size; j++) + DO_GLYPH(((uint8 *) (entry-> + data)), + j); + } + break; + + default: + DO_GLYPH(text, i); + i++; + break; } } @@ -1253,9 +1311,9 @@ ui_desktop_save(uint32 offset, int x, int y, int cx, int cy) XFreePixmap(display, pix); } - offset *= bpp/8; + offset *= bpp / 8; cache_put_desktop(offset, cx, cy, image->bytes_per_line, - bpp/8, (uint8 *)image->data); + bpp / 8, (uint8 *) image->data); XDestroyImage(image); } @@ -1266,14 +1324,14 @@ ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy) XImage *image; uint8 *data; - offset *= bpp/8; - data = cache_get_desktop(offset, cx, cy, bpp/8); + offset *= bpp / 8; + data = cache_get_desktop(offset, cx, cy, bpp / 8); if (data == NULL) return; image = XCreateImage(display, visual, depth, ZPixmap, 0, data, cx, cy, BitmapPad(display), - cx * bpp/8); + cx * bpp / 8); if (ownbackstore) {