From b9613445f933ba4687424b01e8dc7fe2be1aee4b Mon Sep 17 00:00:00 2001 From: Matt Chapman Date: Sat, 6 Jan 2001 03:12:10 +0000 Subject: [PATCH] ran indent (-bli0 -i8 -cli8 -npcs -npsl) git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@23 423420c4-83ab-492f-b58f-81f9feb106b5 --- bitmap.c | 112 +++++++++++++++-------------- cache.c | 15 ++-- iso.c | 34 ++++----- licence.c | 21 +++--- mcs.c | 51 ++++++------- orders.c | 118 +++++++++++++++--------------- rdesktop.c | 33 ++++----- rdp.c | 145 ++++++++++++++++++++----------------- secure.c | 97 +++++++++++++------------ tcp.c | 30 ++++---- xwin.c | 207 +++++++++++++++++++++++++++-------------------------- 11 files changed, 455 insertions(+), 408 deletions(-) diff --git a/bitmap.c b/bitmap.c index 460b0bf..c903643 100644 --- a/bitmap.c +++ b/bitmap.c @@ -87,18 +87,18 @@ BOOL bitmap_decompress(unsigned char *output, int width, int height, mixmask = 0; switch (opcode) { - case 0: /* Fill */ + case 0: /* Fill */ if ((lastopcode == opcode) && !((x == width) && (prevline == NULL))) insertmix = True; break; - case 8: /* Bicolour */ + case 8: /* Bicolour */ colour1 = CVAL(input); - case 3: /* Colour */ + case 3: /* Colour */ colour2 = CVAL(input); break; - case 6: /* SetMix/Mix */ - case 7: /* SetMix/FillOrMix */ + case 6: /* SetMix/Mix */ + case 7: /* SetMix/FillOrMix */ mix = CVAL(input); opcode -= 5; break; @@ -122,13 +122,15 @@ BOOL bitmap_decompress(unsigned char *output, int width, int height, switch (opcode) { - case 0: /* Fill */ + case 0: /* Fill */ if (insertmix) { if (prevline == NULL) line[x] = mix; else - line[x] = prevline[x] ^ mix; + line[x] = + prevline[x] ^ + mix; insertmix = False; count--; @@ -136,73 +138,79 @@ BOOL bitmap_decompress(unsigned char *output, int width, int height, } if (prevline == NULL) - REPEAT(line[x] = 0) + { + REPEAT(line[x] = 0); + } else - REPEAT(line[x] = prevline[x]) + { + REPEAT(line[x] = prevline[x]); + } break; - case 1: /* Mix */ + case 1: /* Mix */ if (prevline == NULL) - REPEAT(line[x] = mix) + { + REPEAT(line[x] = mix); + } else - REPEAT(line[x] = prevline[x] ^ mix) + { + REPEAT(line[x] = + prevline[x] ^ mix); + } break; - case 2: /* Fill or Mix */ + case 2: /* Fill or Mix */ if (prevline == NULL) - REPEAT( - MASK_UPDATE(); - - if (mask & mixmask) - line[x] = mix; - else - line[x] = 0; - ) + { + REPEAT(MASK_UPDATE(); + if (mask & mixmask) + line[x] = mix; + else + line[x] = 0;); + } else - REPEAT( - MASK_UPDATE(); - - if (mask & mixmask) - line[x] = prevline[x] ^ mix; - else - line[x] = prevline[x]; - ) + { + REPEAT(MASK_UPDATE(); + if (mask & mixmask) + line[x] = + prevline[x] ^ mix; + else + line[x] = + prevline[x];); + } break; - case 3: /* Colour */ - REPEAT(line[x] = colour2) + case 3: /* Colour */ + REPEAT(line[x] = colour2); break; - case 4: /* Copy */ - REPEAT(line[x] = CVAL(input)) + case 4: /* Copy */ + REPEAT(line[x] = CVAL(input)); break; - case 8: /* Bicolour */ - REPEAT( - if (bicolour) - { - line[x] = colour2; - bicolour = False; - } - else - { - line[x] = colour1; - bicolour = True; - count++; - } - ) + case 8: /* Bicolour */ + REPEAT(if (bicolour) + { + line[x] = colour2; + bicolour = False;} + else + { + line[x] = colour1; + bicolour = True; count++;} + ); break; - case 13: /* White */ - REPEAT(line[x] = 0xff) + case 13: /* White */ + REPEAT(line[x] = 0xff); break; - case 14: /* Black */ - REPEAT(line[x] = 0x00) + case 14: /* Black */ + REPEAT(line[x] = 0x00); break; default: - NOTIMP("bitmap opcode 0x%x\n", opcode); + NOTIMP("bitmap opcode 0x%x\n", + opcode); return False; } } diff --git a/cache.c b/cache.c index 2e4f881..e249ecc 100644 --- a/cache.c +++ b/cache.c @@ -32,7 +32,7 @@ HBITMAP cache_get_bitmap(uint8 cache_id, uint16 cache_idx) HBITMAP bitmap; if ((cache_id < NUM_ELEMENTS(bmpcache)) - && (cache_idx < NUM_ELEMENTS(bmpcache[0]))) + && (cache_idx < NUM_ELEMENTS(bmpcache[0]))) { bitmap = bmpcache[cache_id][cache_idx]; if (bitmap != NULL) @@ -49,7 +49,7 @@ void cache_put_bitmap(uint8 cache_id, uint16 cache_idx, HBITMAP bitmap) HBITMAP old; if ((cache_id < NUM_ELEMENTS(bmpcache)) - && (cache_idx < NUM_ELEMENTS(bmpcache[0]))) + && (cache_idx < NUM_ELEMENTS(bmpcache[0]))) { old = bmpcache[cache_id][cache_idx]; if (old != NULL) @@ -73,7 +73,7 @@ FONTGLYPH *cache_get_font(uint8 font, uint16 character) FONTGLYPH *glyph; if ((font < NUM_ELEMENTS(fontcache)) - && (character < NUM_ELEMENTS(fontcache[0]))) + && (character < NUM_ELEMENTS(fontcache[0]))) { glyph = &fontcache[font][character]; if (glyph->pixmap != NULL) @@ -86,12 +86,13 @@ FONTGLYPH *cache_get_font(uint8 font, uint16 character) /* Store a glyph in the font cache */ void cache_put_font(uint8 font, uint16 character, uint16 offset, - uint16 baseline, uint16 width, uint16 height, HGLYPH pixmap) + uint16 baseline, uint16 width, uint16 height, + HGLYPH pixmap) { FONTGLYPH *glyph; if ((font < NUM_ELEMENTS(fontcache)) - && (character < NUM_ELEMENTS(fontcache[0]))) + && (character < NUM_ELEMENTS(fontcache[0]))) { glyph = &fontcache[font][character]; if (glyph->pixmap != NULL) @@ -169,7 +170,8 @@ uint8 *cache_get_desktop(uint32 offset, int cx, int cy) } /* Store desktop data in the cache */ -void cache_put_desktop(uint32 offset, int cx, int cy, int scanline, uint8 *data) +void cache_put_desktop(uint32 offset, int cx, int cy, int scanline, + uint8 *data) { int length = cx * cy; @@ -187,4 +189,3 @@ void cache_put_desktop(uint32 offset, int cx, int cy, int scanline, uint8 *data) ERROR("put desktop %d:%d\n", offset, length); } } - diff --git a/iso.c b/iso.c index c94e4c0..68b7267 100644 --- a/iso.c +++ b/iso.c @@ -27,15 +27,15 @@ static void iso_send_msg(uint8 code) s = tcp_init(11); - out_uint8(s, 3); /* version */ - out_uint8(s, 0); /* reserved */ - out_uint16_be(s, 11); /* length */ + out_uint8(s, 3); /* version */ + out_uint8(s, 0); /* reserved */ + out_uint16_be(s, 11); /* length */ - out_uint8(s, 6); /* hdrlen */ + out_uint8(s, 6); /* hdrlen */ out_uint8(s, code); - out_uint16(s, 0); /* dst_ref */ - out_uint16(s, 0); /* src_ref */ - out_uint8(s, 0); /* class */ + out_uint16(s, 0); /* dst_ref */ + out_uint16(s, 0); /* src_ref */ + out_uint8(s, 0); /* class */ s_mark_end(s); tcp_send(s); @@ -59,23 +59,23 @@ static STREAM iso_recv_msg(uint8 *code) return False; } - in_uint8s(s, 1); /* pad */ + in_uint8s(s, 1); /* pad */ in_uint16_be(s, length); s = tcp_recv(length - 4); if (s == NULL) return False; - in_uint8s(s, 1); /* hdrlen */ + in_uint8s(s, 1); /* hdrlen */ in_uint8(s, *code); if (*code == ISO_PDU_DT) { - in_uint8s(s, 1); /* eot */ - return s; + in_uint8s(s, 1); /* eot */ + return s; } - in_uint8s(s, 5); /* dst_ref, src_ref, class */ + in_uint8s(s, 5); /* dst_ref, src_ref, class */ return s; } @@ -98,13 +98,13 @@ void iso_send(STREAM s) s_pop_layer(s, iso_hdr); length = s->end - s->p; - out_uint8(s, 3); /* version */ - out_uint8(s, 0); /* reserved */ + out_uint8(s, 3); /* version */ + out_uint8(s, 0); /* reserved */ out_uint16_be(s, length); - out_uint8(s, 2); /* hdrlen */ - out_uint8(s, ISO_PDU_DT); /* code */ - out_uint8(s, 0x80); /* eot */ + out_uint8(s, 2); /* hdrlen */ + out_uint8(s, ISO_PDU_DT); /* code */ + out_uint8(s, 0x80); /* eot */ tcp_send(s); } diff --git a/licence.c b/licence.c index ee8761a..369a7a5 100644 --- a/licence.c +++ b/licence.c @@ -36,11 +36,11 @@ void licence_generate_keys(uint8 *client_key, uint8 *server_key, uint8 temp_hash[48]; /* Generate session key - two rounds of sec_hash_48 */ - sec_hash_48(temp_hash, client_rsa, client_key, server_key, 65); - sec_hash_48(session_key, temp_hash, server_key, client_key, 65); + sec_hash_48(temp_hash, client_rsa, client_key, server_key, 65); + sec_hash_48(session_key, temp_hash, server_key, client_key, 65); /* Store first 16 bytes of session key, for generating signatures */ - memcpy(licence_sign_key, session_key, 16); + memcpy(licence_sign_key, session_key, 16); /* Generate RC4 key */ sec_hash_16(licence_key, &session_key[16], client_key, server_key); @@ -48,7 +48,7 @@ void licence_generate_keys(uint8 *client_key, uint8 *server_key, /* Send a licence request packet */ static void licence_send_request(uint8 *client_random, uint8 *rsa_data, - char *user, char *host) + char *user, char *host) { uint32 sec_flags = SEC_LICENCE_NEG; uint16 userlen = strlen(user) + 1; @@ -102,7 +102,7 @@ static void licence_process_demand(STREAM s) /* Send an authentication response packet */ static void licence_send_authresp(uint8 *token, uint8 *crypt_hwid, - uint8 *signature) + uint8 *signature) { uint32 sec_flags = SEC_LICENCE_NEG; uint16 length = 58; @@ -132,7 +132,7 @@ static BOOL licence_parse_authreq(STREAM s, uint8 **token, uint8 **signature) { uint16 tokenlen; - in_uint8s(s, 6); /* unknown: f8 3d 15 00 04 f6 */ + in_uint8s(s, 6); /* unknown: f8 3d 15 00 04 f6 */ in_uint16_le(s, tokenlen); if (tokenlen != LICENCE_TOKEN_SIZE) @@ -151,7 +151,8 @@ static BOOL licence_parse_authreq(STREAM s, uint8 **token, uint8 **signature) static void licence_process_authreq(STREAM s) { uint8 *in_token, *in_sig; - uint8 out_token[LICENCE_TOKEN_SIZE], decrypt_token[LICENCE_TOKEN_SIZE]; + uint8 out_token[LICENCE_TOKEN_SIZE], + decrypt_token[LICENCE_TOKEN_SIZE]; uint8 hwid[LICENCE_HWID_SIZE], crypt_hwid[LICENCE_HWID_SIZE]; uint8 sealed_buffer[LICENCE_TOKEN_SIZE + LICENCE_HWID_SIZE]; uint8 out_sig[LICENCE_SIGNATURE_SIZE]; @@ -173,7 +174,7 @@ static void licence_process_authreq(STREAM s) memcpy(sealed_buffer, decrypt_token, LICENCE_TOKEN_SIZE); memcpy(sealed_buffer + LICENCE_TOKEN_SIZE, hwid, LICENCE_HWID_SIZE); sec_sign(out_sig, licence_sign_key, 16, - sealed_buffer, sizeof(sealed_buffer)); + sealed_buffer, sizeof(sealed_buffer)); /* Deliberately break signature if licencing disabled */ if (!licence) @@ -193,7 +194,7 @@ static void licence_process_issue(STREAM s) uint32 length; uint16 check; - in_uint8s(s, 2); /* 3d 45 - unknown */ + in_uint8s(s, 2); /* 3d 45 - unknown */ in_uint16_le(s, length); if (!s_check_rem(s, length)) return; @@ -215,7 +216,7 @@ void licence_process(STREAM s) uint16 tag; in_uint16_le(s, tag); - in_uint8s(s, 2); /* length */ + in_uint8s(s, 2); /* length */ switch (tag) { diff --git a/mcs.c b/mcs.c index 1731d52..1e4da0c 100644 --- a/mcs.c +++ b/mcs.c @@ -33,8 +33,7 @@ static BOOL ber_parse_header(STREAM s, int tagval, int *length) } else { - in_uint8(s, tag) - } + in_uint8(s, tag)} if (tag != tagval) { @@ -51,7 +50,8 @@ static BOOL ber_parse_header(STREAM s, int tagval, int *length) while (len--) next_be(s, *length); } - else *length = len; + else + *length = len; return s_check(s); } @@ -73,7 +73,8 @@ static void ber_out_header(STREAM s, int tagval, int length) out_uint8(s, 0x82); out_uint16_be(s, length); } - else out_uint8(s, length); + else + out_uint8(s, length); } /* Output an ASN.1 BER integer */ @@ -85,17 +86,17 @@ static void ber_out_integer(STREAM s, int value) /* Output a DOMAIN_PARAMS structure (ASN.1 BER) */ static void mcs_out_domain_params(STREAM s, int max_channels, int max_users, - int max_tokens, int max_pdusize) + int max_tokens, int max_pdusize) { ber_out_header(s, MCS_TAG_DOMAIN_PARAMS, 32); ber_out_integer(s, max_channels); ber_out_integer(s, max_users); ber_out_integer(s, max_tokens); - ber_out_integer(s, 1); /* num_priorities */ - ber_out_integer(s, 0); /* min_throughput */ - ber_out_integer(s, 1); /* max_height */ + ber_out_integer(s, 1); /* num_priorities */ + ber_out_integer(s, 0); /* min_throughput */ + ber_out_integer(s, 1); /* max_height */ ber_out_integer(s, max_pdusize); - ber_out_integer(s, 2); /* ver_protocol */ + ber_out_integer(s, 2); /* ver_protocol */ } /* Parse a DOMAIN_PARAMS structure (ASN.1 BER) */ @@ -113,21 +114,21 @@ static BOOL mcs_parse_domain_params(STREAM s) static void mcs_send_connect_initial(STREAM mcs_data) { int datalen = mcs_data->end - mcs_data->data; - int length = 7 + 3*34 + 4 + datalen; + int length = 7 + 3 * 34 + 4 + datalen; STREAM s; s = iso_init(length + 5); ber_out_header(s, MCS_CONNECT_INITIAL, length); - ber_out_header(s, BER_TAG_OCTET_STRING, 0); /* calling domain */ - ber_out_header(s, BER_TAG_OCTET_STRING, 0); /* called domain */ + ber_out_header(s, BER_TAG_OCTET_STRING, 0); /* calling domain */ + ber_out_header(s, BER_TAG_OCTET_STRING, 0); /* called domain */ ber_out_header(s, BER_TAG_BOOLEAN, 1); - out_uint8(s, 0xff); /* upward flag */ + out_uint8(s, 0xff); /* upward flag */ - mcs_out_domain_params(s, 2, 2, 0, 0xffff); /* target params */ - mcs_out_domain_params(s, 1, 1, 1, 0x420); /* min params */ - mcs_out_domain_params(s, 0xffff, 0xfc17, 0xffff, 0xffff); /* max params */ + mcs_out_domain_params(s, 2, 2, 0, 0xffff); /* target params */ + mcs_out_domain_params(s, 1, 1, 1, 0x420); /* min params */ + mcs_out_domain_params(s, 0xffff, 0xfc17, 0xffff, 0xffff); /* max params */ ber_out_header(s, BER_TAG_OCTET_STRING, datalen); out_uint8p(s, mcs_data->data, datalen); @@ -158,7 +159,7 @@ static BOOL mcs_recv_connect_response(STREAM mcs_data) } ber_parse_header(s, BER_TAG_INTEGER, &length); - in_uint8s(s, length); /* connect id */ + in_uint8s(s, length); /* connect id */ mcs_parse_domain_params(s); ber_parse_header(s, BER_TAG_OCTET_STRING, &length); @@ -183,8 +184,8 @@ static void mcs_send_edrq() s = iso_init(5); out_uint8(s, (MCS_EDRQ << 2)); - out_uint16_be(s, 1); /* height */ - out_uint16_be(s, 1); /* interval */ + out_uint16_be(s, 1); /* height */ + out_uint16_be(s, 1); /* interval */ s_mark_end(s); iso_send(s); @@ -272,9 +273,9 @@ static BOOL mcs_recv_cjcf() return False; } - in_uint8s(s, 4); /* mcs_userid, req_chanid */ + in_uint8s(s, 4); /* mcs_userid, req_chanid */ if (opcode & 2) - in_uint8s(s, 2); /* join_chanid */ + in_uint8s(s, 2); /* join_chanid */ return s_check_end(s); } @@ -302,7 +303,7 @@ void mcs_send(STREAM s) out_uint8(s, (MCS_SDRQ << 2)); out_uint16_be(s, mcs_userid); out_uint16_be(s, MCS_GLOBAL_CHANNEL); - out_uint8(s, 0x70); /* flags */ + out_uint8(s, 0x70); /* flags */ out_uint16_be(s, length); iso_send(s); @@ -329,10 +330,10 @@ STREAM mcs_recv() return NULL; } - in_uint8s(s, 5); /* userid, chanid, flags */ + in_uint8s(s, 5); /* userid, chanid, flags */ in_uint8(s, length); if (length & 0x80) - in_uint8s(s, 1); /* second byte of length */ + in_uint8s(s, 1); /* second byte of length */ return s; } @@ -363,7 +364,7 @@ BOOL mcs_connect(char *server, STREAM mcs_data) return True; - error: + error: iso_disconnect(); return False; } diff --git a/orders.c b/orders.c index 00b5394..72636c7 100644 --- a/orders.c +++ b/orders.c @@ -59,7 +59,7 @@ static void rdp_in_coord(STREAM s, uint16 *coord, BOOL delta) if (delta) { in_uint8(s, change); - *coord += (char)change; + *coord += (char) change; } else { @@ -142,7 +142,7 @@ static BOOL 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) + uint32 present, BOOL delta) { if (present & 0x01) rdp_in_coord(s, &os->x, delta); @@ -167,7 +167,7 @@ static void process_destblt(STREAM s, DESTBLT_ORDER *os, /* Process a pattern blt order */ static void process_patblt(STREAM s, PATBLT_ORDER *os, - uint32 present, BOOL delta) + uint32 present, BOOL delta) { if (present & 0x0001) rdp_in_coord(s, &os->x, delta); @@ -197,12 +197,12 @@ static void process_patblt(STREAM s, PATBLT_ORDER *os, 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); + &os->brush, os->bgcolour, os->fgcolour); } /* Process a screen blt order */ static void process_screenblt(STREAM s, SCREENBLT_ORDER *os, - uint32 present, BOOL delta) + uint32 present, BOOL delta) { if (present & 0x0001) rdp_in_coord(s, &os->x, delta); @@ -229,7 +229,7 @@ static void process_screenblt(STREAM s, SCREENBLT_ORDER *os, os->opcode, os->x, os->y, os->cx, os->cy, os->srcx, os->srcy); ui_screenblt(ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy, - os->srcx, os->srcy); + os->srcx, os->srcy); } /* Process a line order */ @@ -268,8 +268,8 @@ static void process_line(STREAM s, LINE_ORDER *os, uint32 present, BOOL delta) return; } - ui_line(os->opcode-1, os->startx, os->starty, - os->endx, os->endy, &os->pen); + ui_line(os->opcode - 1, os->startx, os->starty, + os->endx, os->endy, &os->pen); } /* Process an opaque rectangle order */ @@ -298,7 +298,7 @@ static void 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) + uint32 present, BOOL delta) { int width, height; @@ -330,12 +330,13 @@ static void process_desksave(STREAM s, DESKSAVE_ORDER *os, if (os->action == 0) ui_desktop_save(os->offset, os->left, os->top, width, height); else - ui_desktop_restore(os->offset, os->left, os->top, width, height); + ui_desktop_restore(os->offset, os->left, os->top, width, + height); } /* Process a memory blt order */ static void process_memblt(STREAM s, MEMBLT_ORDER *os, - uint32 present, BOOL delta) + uint32 present, BOOL delta) { HBITMAP bitmap; @@ -378,12 +379,12 @@ static void process_memblt(STREAM s, MEMBLT_ORDER *os, return; ui_memblt(ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy, - bitmap, os->srcx, os->srcy); + bitmap, os->srcx, os->srcy); } /* Process a 3-way blt order */ static void process_triblt(STREAM s, TRIBLT_ORDER *os, - uint32 present, BOOL delta) + uint32 present, BOOL delta) { HBITMAP bitmap; @@ -428,17 +429,18 @@ static void process_triblt(STREAM s, TRIBLT_ORDER *os, 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) return; ui_triblt(os->opcode, os->x, os->y, os->cx, os->cy, - bitmap, os->srcx, os->srcy, - &os->brush, os->bgcolour, os->fgcolour); + bitmap, os->srcx, os->srcy, + &os->brush, os->bgcolour, os->fgcolour); } /* Parse a delta co-ordinate in polyline order form */ @@ -447,7 +449,7 @@ static int parse_delta(uint8 *buffer, int *offset) int value = buffer[(*offset)++]; int two_byte = value & 0x80; - if (value & 0x40) /* sign bit */ + if (value & 0x40) /* sign bit */ value |= ~0x3f; else value &= 0x3f; @@ -460,7 +462,7 @@ static int parse_delta(uint8 *buffer, int *offset) /* Process a polyline order */ static void process_polyline(STREAM s, POLYLINE_ORDER *os, - uint32 present, BOOL delta) + uint32 present, BOOL delta) { int index, line, data; int x, y, xfrom, yfrom; @@ -489,7 +491,7 @@ static void process_polyline(STREAM s, POLYLINE_ORDER *os, } 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: "); @@ -514,7 +516,7 @@ static void process_polyline(STREAM s, POLYLINE_ORDER *os, flags = os->data[index++]; if ((flags & 0xc0) == 0) - flags |= 0xc0; /* none = both */ + flags |= 0xc0; /* none = both */ if (flags & 0x40) x += parse_delta(os->data, &data); @@ -529,7 +531,8 @@ static void process_polyline(STREAM s, POLYLINE_ORDER *os, } /* Process a text order */ -static void process_text2(STREAM s, TEXT2_ORDER *os, uint32 present, BOOL delta) +static void process_text2(STREAM s, TEXT2_ORDER *os, uint32 present, + BOOL delta) { DATABLOB *entry; int i; @@ -588,11 +591,12 @@ static void 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: "); @@ -608,24 +612,25 @@ static void process_text2(STREAM s, TEXT2_ORDER *os, uint32 present, BOOL delta) if (entry == NULL) return; - + memcpy(os->text, entry->data, entry->size); os->length = entry->size; } - else if ((os->length >= 3) && (os->text[os->length-3] == 0xff)) + else if ((os->length >= 3) && (os->text[os->length - 3] == 0xff)) { os->length -= 3; - cache_put_text(os->text[os->length+1], os->text, os->length); + cache_put_text(os->text[os->length + 1], os->text, + os->length); } ui_draw_text(os->font, os->flags, os->mixmode, os->x, os->y, - os->clipleft, os->cliptop, - os->clipright - os->clipleft, - os->clipbottom - os->cliptop, - os->boxleft, os->boxtop, - os->boxright - os->boxleft, - os->boxbottom - os->boxtop, - os->bgcolour, os->fgcolour, os->text, os->length); + os->clipleft, os->cliptop, + os->clipright - os->clipleft, + os->clipbottom - os->cliptop, + os->boxleft, os->boxtop, + os->boxright - os->boxleft, + os->boxbottom - os->boxtop, + os->bgcolour, os->fgcolour, os->text, os->length); } /* Process a raw bitmap cache order */ @@ -637,7 +642,7 @@ static void process_raw_bmpcache(STREAM s) uint8 *data; in_uint8(s, cache_id); - in_uint8s(s, 1); /* pad */ + in_uint8s(s, 1); /* pad */ in_uint8(s, width); in_uint8(s, height); in_uint8(s, bpp); @@ -661,15 +666,15 @@ static void process_bmpcache(STREAM s) uint8 *data, *bmpdata; in_uint8(s, cache_id); - in_uint8s(s, 1); /* pad */ + in_uint8s(s, 1); /* pad */ in_uint8(s, width); in_uint8(s, height); in_uint8(s, bpp); - in_uint8s(s, 2); /* bufsize */ + in_uint8s(s, 2); /* bufsize */ in_uint16_le(s, cache_idx); - in_uint8s(s, 2); /* pad */ + in_uint8s(s, 2); /* pad */ in_uint16_le(s, size); - in_uint8s(s, 4); /* row_size, final_size */ + in_uint8s(s, 4); /* row_size, final_size */ in_uint8p(s, data, size); DEBUG("BMPCACHE(cx=%d,cy=%d,id=%d,idx=%d)\n", @@ -706,7 +711,7 @@ static void process_colcache(STREAM s) in_uint8(s, entry->blue); in_uint8(s, entry->green); in_uint8(s, entry->red); - in_uint8s(s, 1); /* pad */ + in_uint8s(s, 1); /* pad */ } DEBUG("COLCACHE(id=%d,n=%d)\n", cache_id, map.ncolours); @@ -723,8 +728,8 @@ static void process_fontcache(STREAM s) HGLYPH bitmap; uint8 font, nglyphs; uint16 character, offset, baseline, width, height; - uint8 *data, *rev_data, in, out; - int i, j, datasize; + int i, datasize; + uint8 *data; in_uint8(s, font); in_uint8(s, nglyphs); @@ -744,7 +749,7 @@ static void process_fontcache(STREAM s) bitmap = ui_create_glyph(width, height, data); cache_put_font(font, character, offset, baseline, - width, height, bitmap); + width, height, bitmap); } } @@ -756,7 +761,7 @@ static void process_secondary_order(STREAM s) uint8 *next_order; in_uint16_le(s, length); - in_uint8s(s, 2); /* flags */ + in_uint8s(s, 2); /* flags */ in_uint8(s, type); next_order = s->p + length + 7; @@ -796,9 +801,9 @@ void process_orders(STREAM s) int size, processed = 0; BOOL delta; - in_uint8s(s, 2); /* pad */ + in_uint8s(s, 2); /* pad */ in_uint16_le(s, num_orders); - in_uint8s(s, 2); /* pad */ + in_uint8s(s, 2); /* pad */ while (processed < num_orders) { @@ -846,9 +851,11 @@ void process_orders(STREAM s) rdp_parse_bounds(s, &os->bounds); ui_set_clip(os->bounds.left, - os->bounds.top, - os->bounds.right - os->bounds.left + 1, - os->bounds.bottom - os->bounds.top + 1); + os->bounds.top, + os->bounds.right - + os->bounds.left + 1, + os->bounds.bottom - + os->bounds.top + 1); } delta = order_flags & RDP_ORDER_DELTA; @@ -872,7 +879,7 @@ void process_orders(STREAM s) case RDP_ORDER_LINE: process_line(s, &os->line, - present, delta); + present, delta); break; case RDP_ORDER_RECT: @@ -918,7 +925,7 @@ void process_orders(STREAM s) } if (s->p != next_packet) - WARN("%d bytes remaining\n", (int)(next_packet - s->p)); + WARN("%d bytes remaining\n", (int) (next_packet - s->p)); } /* Reset order state */ @@ -926,4 +933,3 @@ void reset_order_state() { memset(&order_state, 0, sizeof(order_state)); } - diff --git a/rdesktop.c b/rdesktop.c index 2257722..15e05db 100644 --- a/rdesktop.c +++ b/rdesktop.c @@ -18,13 +18,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include /* malloc realloc free */ -#include /* read close getuid getgid getpid getppid gethostname */ -#include /* open */ -#include /* getpwuid */ -#include /* stat */ -#include /* gettimeofday */ -#include /* times */ +#include /* malloc realloc free */ +#include /* read close getuid getgid getpid getppid gethostname */ +#include /* open */ +#include /* getpwuid */ +#include /* stat */ +#include /* gettimeofday */ +#include /* times */ #include "rdesktop.h" char username[16]; @@ -68,7 +68,8 @@ int main(int argc, char *argv[]) int c; STATUS("rdesktop: A Remote Desktop Protocol client.\n"); - STATUS("Version "VERSION". Copyright (C) 1999-2000 Matt Chapman.\n"); + STATUS("Version " VERSION + ". Copyright (C) 1999-2000 Matt Chapman.\n"); STATUS("See http://www.rdesktop.org/ for more information.\n\n"); flags = RDP_LOGON_NORMAL; @@ -186,7 +187,7 @@ void generate_random(uint8 *random) { struct stat st; struct tms tmsbuf; - uint32 *r = (uint32 *)random; + uint32 *r = (uint32 *) random; int fd; /* If we have a kernel random device, use it. */ @@ -200,8 +201,8 @@ void generate_random(uint8 *random) /* Otherwise use whatever entropy we can gather - ideas welcome. */ r[0] = (getpid()) | (getppid() << 16); r[1] = (getuid()) | (getgid() << 16); - r[2] = times(&tmsbuf); /* system uptime (clocks) */ - gettimeofday((struct timeval *)&r[3], NULL); /* sec and usec */ + r[2] = times(&tmsbuf); /* system uptime (clocks) */ + gettimeofday((struct timeval *) &r[3], NULL); /* sec and usec */ stat("/tmp", &st); r[5] = st.st_atime; r[6] = st.st_mtime; @@ -253,13 +254,13 @@ void hexdump(unsigned char *p, unsigned int len) thisline = 16; for (i = 0; i < thisline; i++) - STATUS("%02x ", line[i]) - - for (; i < 16; i++) - STATUS(" "); + STATUS("%02x ", line[i]) for (; i < 16; i++) + STATUS(" "); for (i = 0; i < thisline; i++) - STATUS("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.'); + STATUS("%c", + (line[i] >= 0x20 + && line[i] < 0x7f) ? line[i] : '.'); STATUS("\n"); offset += thisline; diff --git a/rdp.c b/rdp.c index 9643996..5c517e5 100644 --- a/rdp.c +++ b/rdp.c @@ -47,7 +47,7 @@ static void rdp_send(STREAM s, uint8 pdu_type) length = s->end - s->p; out_uint16_le(s, length); - out_uint16_le(s, (pdu_type | 0x10)); /* Version 1 */ + out_uint16_le(s, (pdu_type | 0x10)); /* Version 1 */ out_uint16_le(s, (mcs_userid + 1001)); sec_send(s, SEC_ENCRYPT); @@ -74,7 +74,7 @@ static STREAM rdp_recv(uint8 *type) in_uint16_le(rdp_s, length); in_uint16_le(rdp_s, pdu_type); - in_uint8s(rdp_s, 2); /* userid */ + in_uint8s(rdp_s, 2); /* userid */ next_packet += length; *type = pdu_type & 0xf; @@ -111,12 +111,12 @@ static void rdp_send_data(STREAM s, uint8 data_pdu_type) out_uint16_le(s, (mcs_userid + 1001)); out_uint32_le(s, rdp_shareid); - out_uint8(s, 0); /* pad */ - out_uint8(s, 1); /* streamid */ + out_uint8(s, 0); /* pad */ + out_uint8(s, 1); /* streamid */ out_uint16(s, (length - 14)); out_uint8(s, data_pdu_type); - out_uint8(s, 0); /* compress_type */ - out_uint16(s, 0); /* compress_len */ + out_uint8(s, 0); /* compress_type */ + out_uint16(s, 0); /* compress_len */ sec_send(s, SEC_ENCRYPT); } @@ -139,18 +139,19 @@ void rdp_out_unistr(STREAM s, char *string, int len) /* Parse a logon info packet */ static void rdp_send_logon_info(uint32 flags, char *domain, char *user, - char *password, char *program, char *directory) + char *password, char *program, + char *directory) { - int len_domain = 2 * strlen(domain); - int len_user = 2 * strlen(user); - int len_password = 2 * strlen(password); - int len_program = 2 * strlen(program); + int len_domain = 2 * strlen(domain); + int len_user = 2 * strlen(user); + int len_password = 2 * strlen(password); + int len_program = 2 * strlen(program); int len_directory = 2 * strlen(directory); uint32 sec_flags = SEC_LOGON_INFO | SEC_ENCRYPT; STREAM s; s = sec_init(sec_flags, 18 + len_domain + len_user + len_password - + len_program + len_directory + 10); + + len_program + len_directory + 10); out_uint32(s, 0); out_uint32_le(s, flags); @@ -159,10 +160,10 @@ static void rdp_send_logon_info(uint32 flags, char *domain, char *user, out_uint16_le(s, len_password); out_uint16_le(s, len_program); out_uint16_le(s, len_directory); - rdp_out_unistr(s, domain, len_domain); - rdp_out_unistr(s, user, len_user); - rdp_out_unistr(s, password, len_password); - rdp_out_unistr(s, program, len_program); + rdp_out_unistr(s, domain, len_domain); + rdp_out_unistr(s, user, len_user); + rdp_out_unistr(s, password, len_password); + rdp_out_unistr(s, program, len_program); rdp_out_unistr(s, directory, len_directory); s_mark_end(s); @@ -177,8 +178,8 @@ static void rdp_send_control(uint16 action) s = rdp_init_data(8); out_uint16_le(s, action); - out_uint16(s, 0); /* userid */ - out_uint32(s, 0); /* control id */ + out_uint16(s, 0); /* userid */ + out_uint32(s, 0); /* control id */ s_mark_end(s); rdp_send_data(s, RDP_DATA_PDU_CONTROL); @@ -191,7 +192,7 @@ static void rdp_send_synchronise() s = rdp_init_data(4); - out_uint16_le(s, 1); /* type */ + out_uint16_le(s, 1); /* type */ out_uint16_le(s, 1002); s_mark_end(s); @@ -206,8 +207,8 @@ void rdp_send_input(uint32 time, uint16 message_type, uint16 device_flags, s = rdp_init_data(16); - out_uint16_le(s, 1); /* number of events */ - out_uint16(s, 0); /* pad */ + out_uint16_le(s, 1); /* number of events */ + out_uint16(s, 0); /* pad */ out_uint32_le(s, time); out_uint16_le(s, message_type); @@ -243,7 +244,7 @@ static void rdp_out_general_caps(STREAM s) out_uint16_le(s, 1); /* OS major type */ out_uint16_le(s, 3); /* OS minor type */ - out_uint16_le(s, 0x200); /* Protocol version */ + out_uint16_le(s, 0x200); /* Protocol version */ out_uint16(s, 0); /* Pad */ out_uint16(s, 0); /* Compression types */ out_uint16(s, 0); /* Pad */ @@ -289,7 +290,7 @@ static void rdp_out_order_caps(STREAM s) out_uint16(s, 0); /* Pad */ out_uint16_le(s, 1); /* Max order level */ out_uint16_le(s, 0x147); /* Number of fonts */ - out_uint16_le(s, 0x2a); /* Capability flags */ + out_uint16_le(s, 0x2a); /* Capability flags */ out_uint8p(s, order_caps, 32); /* Orders supported */ out_uint16_le(s, 0x6a1); /* Text capability flags */ out_uint8s(s, 6); /* Pad */ @@ -304,13 +305,13 @@ static void rdp_out_bmpcache_caps(STREAM s) out_uint16_le(s, RDP_CAPSET_BMPCACHE); out_uint16_le(s, RDP_CAPLEN_BMPCACHE); - out_uint8s(s, 24); /* unused */ - out_uint16_le(s, 0x258); /* entries */ - out_uint16_le(s, 0x100); /* max cell size */ - out_uint16_le(s, 0x12c); /* entries */ - out_uint16_le(s, 0x400); /* max cell size */ - out_uint16_le(s, 0x106); /* entries */ - out_uint16_le(s, 0x1000); /* max cell size */ + out_uint8s(s, 24); /* unused */ + out_uint16_le(s, 0x258); /* entries */ + out_uint16_le(s, 0x100); /* max cell size */ + out_uint16_le(s, 0x12c); /* entries */ + out_uint16_le(s, 0x400); /* max cell size */ + out_uint16_le(s, 0x106); /* entries */ + out_uint16_le(s, 0x1000); /* max cell size */ } /* Output control capability set */ @@ -368,16 +369,25 @@ static void rdp_out_colcache_caps(STREAM s) } static uint8 canned_caps[] = { -0x01,0x00,0x00,0x00,0x09,0x04,0x00,0x00,0x04, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x08,0x00,0x01, -0x00,0x00,0x00,0x0E,0x00,0x08,0x00,0x01,0x00,0x00,0x00,0x10,0x00,0x34,0x00,0xFE, -0x00,0x04,0x00,0xFE,0x00,0x04,0x00,0xFE,0x00,0x08,0x00,0xFE,0x00,0x08,0x00,0xFE, -0x00,0x10,0x00,0xFE,0x00,0x20,0x00,0xFE,0x00,0x40,0x00,0xFE,0x00,0x80,0x00,0xFE, -0x00,0x00,0x01,0x40,0x00,0x00,0x08,0x00,0x01,0x00,0x01,0x02,0x00,0x00,0x00 + 0x01, 0x00, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0C, 0x00, 0x08, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x0E, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x34, 0x00, 0xFE, + 0x00, 0x04, 0x00, 0xFE, 0x00, 0x04, 0x00, 0xFE, 0x00, 0x08, 0x00, + 0xFE, 0x00, 0x08, 0x00, 0xFE, + 0x00, 0x10, 0x00, 0xFE, 0x00, 0x20, 0x00, 0xFE, 0x00, 0x40, 0x00, + 0xFE, 0x00, 0x80, 0x00, 0xFE, + 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x01, + 0x02, 0x00, 0x00, 0x00 }; /* Output unknown capability set */ @@ -385,29 +395,30 @@ static void rdp_out_unknown_caps(STREAM s) { out_uint16_le(s, RDP_CAPSET_UNKNOWN); out_uint16_le(s, 0x58); - - out_uint8p(s, canned_caps, RDP_CAPLEN_UNKNOWN-4); + + out_uint8p(s, canned_caps, RDP_CAPLEN_UNKNOWN - 4); } /* Send a confirm active PDU */ static void rdp_send_confirm_active() { STREAM s; - uint16 caplen = RDP_CAPLEN_GENERAL + RDP_CAPLEN_BITMAP + RDP_CAPLEN_ORDER - + RDP_CAPLEN_BMPCACHE + RDP_CAPLEN_COLCACHE + RDP_CAPLEN_ACTIVATE - + RDP_CAPLEN_CONTROL + RDP_CAPLEN_POINTER + RDP_CAPLEN_SHARE - + RDP_CAPLEN_UNKNOWN; + uint16 caplen = + RDP_CAPLEN_GENERAL + RDP_CAPLEN_BITMAP + RDP_CAPLEN_ORDER + + RDP_CAPLEN_BMPCACHE + RDP_CAPLEN_COLCACHE + + RDP_CAPLEN_ACTIVATE + RDP_CAPLEN_CONTROL + + RDP_CAPLEN_POINTER + RDP_CAPLEN_SHARE + RDP_CAPLEN_UNKNOWN; s = rdp_init(14 + caplen + sizeof(RDP_SOURCE)); out_uint32_le(s, rdp_shareid); - out_uint16_le(s, 0x3ea); /* userid */ + out_uint16_le(s, 0x3ea); /* userid */ out_uint16_le(s, sizeof(RDP_SOURCE)); out_uint16_le(s, caplen); out_uint8p(s, RDP_SOURCE, sizeof(RDP_SOURCE)); - out_uint16_le(s, 0xd); /* num_caps */ - out_uint8s(s, 2); /* pad */ + out_uint16_le(s, 0xd); /* num_caps */ + out_uint8s(s, 2); /* pad */ rdp_out_general_caps(s); rdp_out_bitmap_caps(s); @@ -437,13 +448,13 @@ static void process_demand_active(STREAM s) rdp_send_synchronise(); rdp_send_control(RDP_CTL_COOPERATE); rdp_send_control(RDP_CTL_REQUEST_CONTROL); - rdp_recv(&type); // RDP_PDU_SYNCHRONIZE - rdp_recv(&type); // RDP_CTL_COOPERATE - rdp_recv(&type); // RDP_CTL_GRANT_CONTROL + rdp_recv(&type); // RDP_PDU_SYNCHRONIZE + rdp_recv(&type); // RDP_CTL_COOPERATE + rdp_recv(&type); // RDP_CTL_GRANT_CONTROL rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, 0, 0); rdp_send_fonts(1); rdp_send_fonts(2); - rdp_recv(&type); // RDP_PDU_UNKNOWN 0x28 + rdp_recv(&type); // RDP_PDU_UNKNOWN 0x28 reset_order_state(); } @@ -454,7 +465,7 @@ static void process_pointer_pdu(STREAM s) uint16 x, y; in_uint16_le(s, message_type); - in_uint8s(s, 2); /* pad */ + in_uint8s(s, 2); /* pad */ switch (message_type) { @@ -497,18 +508,19 @@ static void process_bitmap_updates(STREAM s) cy = bottom - top + 1; DEBUG("UPDATE(l=%d,t=%d,r=%d,b=%d,w=%d,h=%d,cmp=%d)\n", - left, top, right, bottom, width, height, compress); + left, top, right, bottom, width, height, compress); if (!compress) { in_uint8p(s, data, bufsize); - ui_paint_bitmap(left, top, cx, cy, width, height, data); + ui_paint_bitmap(left, top, cx, cy, width, height, + data); return; } - in_uint8s(s, 2); /* pad */ + in_uint8s(s, 2); /* pad */ in_uint16_le(s, size); - in_uint8s(s, 4); /* line_size, final_size */ + in_uint8s(s, 4); /* line_size, final_size */ in_uint8p(s, data, size); rawdata = xmalloc(width * height); @@ -528,10 +540,10 @@ static void process_palette(STREAM s) HCOLOURMAP hmap; COLOURMAP map; - in_uint8s(s, 2); /* pad */ - in_uint16_le(s, map.ncolours); - in_uint8s(s, 2); /* pad */ - in_uint8p(s, (uint8 *)map.colours, (map.ncolours * 3)); + in_uint8s(s, 2); /* pad */ + in_uint16_le(s, map.ncolours); + in_uint8s(s, 2); /* pad */ + in_uint8p(s, (uint8 *) map.colours, (map.ncolours * 3)); hmap = ui_create_colourmap(&map); ui_set_colourmap(hmap); @@ -572,9 +584,9 @@ static void process_data_pdu(STREAM s) { uint8 data_pdu_type; - in_uint8s(s, 8); /* shareid, pad, streamid, length */ + in_uint8s(s, 8); /* shareid, pad, streamid, length */ in_uint8(s, data_pdu_type); - in_uint8s(s, 3); /* compress_type, compress_len */ + in_uint8s(s, 3); /* compress_type, compress_len */ switch (data_pdu_type) { @@ -628,13 +640,13 @@ void rdp_main_loop() /* Establish a connection up to the RDP layer */ BOOL rdp_connect(char *server, uint32 flags, char *domain, char *password, - char *command, char *directory) + char *command, char *directory) { if (!sec_connect(server)) return False; rdp_send_logon_info(flags, domain, username, password, - command, directory); + command, directory); return True; } @@ -643,4 +655,3 @@ void rdp_disconnect() { sec_disconnect(); } - diff --git a/secure.c b/secure.c index a7dea10..752e4d2 100644 --- a/secure.c +++ b/secure.c @@ -45,7 +45,8 @@ static uint8 sec_crypted_random[64]; * a client and server salt) and a global salt value used for padding. * Both SHA1 and MD5 algorithms are used. */ -void sec_hash_48(uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2, uint8 salt) +void sec_hash_48(uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2, + uint8 salt) { uint8 shasig[20]; uint8 pad[4]; @@ -55,10 +56,10 @@ void sec_hash_48(uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2, uint8 salt) for (i = 0; i < 3; i++) { - memset(pad, salt+i, i+1); + memset(pad, salt + i, i + 1); SHA1_Init(&sha); - SHA1_Update(&sha, pad, i+1); + SHA1_Update(&sha, pad, i + 1); SHA1_Update(&sha, in, 48); SHA1_Update(&sha, salt1, 32); SHA1_Update(&sha, salt2, 32); @@ -67,7 +68,7 @@ void sec_hash_48(uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2, uint8 salt) MD5_Init(&md5); MD5_Update(&md5, in, 48); MD5_Update(&md5, shasig, 20); - MD5_Final(&out[i*16], &md5); + MD5_Final(&out[i * 16], &md5); } } @@ -103,19 +104,21 @@ static void sec_generate_keys(uint8 *client_key, uint8 *server_key, uint8 input[48]; /* Construct input data to hash */ - memcpy(input, client_key, 24); - memcpy(input+24, server_key, 24); + memcpy(input, client_key, 24); + memcpy(input + 24, server_key, 24); /* Generate session key - two rounds of sec_hash_48 */ - sec_hash_48(temp_hash, input, client_key, server_key, 65); + sec_hash_48(temp_hash, input, client_key, server_key, 65); sec_hash_48(session_key, temp_hash, client_key, server_key, 88); /* Store first 8 bytes of session key, for generating signatures */ memcpy(sec_sign_key, session_key, 8); /* Generate RC4 keys */ - sec_hash_16(sec_decrypt_key, &session_key[16], client_key, server_key); - sec_hash_16(sec_encrypt_key, &session_key[32], client_key, server_key); + sec_hash_16(sec_decrypt_key, &session_key[16], client_key, + server_key); + sec_hash_16(sec_encrypt_key, &session_key[32], client_key, + server_key); if (rc4_key_size == 1) { @@ -140,16 +143,18 @@ static void sec_generate_keys(uint8 *client_key, uint8 *server_key, RC4_set_key(&rc4_encrypt_key, rc4_key_len, sec_encrypt_key); } -static uint8 pad_54[40] = -{ - 54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54, - 54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54 +static uint8 pad_54[40] = { + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54 }; -static uint8 pad_92[48] = -{ - 92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92, - 92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92 +static uint8 pad_92[48] = { + 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, + 92, 92, 92, 92, 92, 92, 92, + 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, + 92, 92, 92, 92, 92, 92, 92 }; /* Output a uint32 into a buffer (little-endian) */ @@ -163,7 +168,7 @@ void buf_out_uint32(uint8 *buffer, uint32 value) /* Generate a signature hash, using a combination of SHA1 and MD5 */ void sec_sign(uint8 *signature, uint8 *session_key, int length, - uint8 *data, int datalen) + uint8 *data, int datalen) { uint8 shasig[20]; uint8 md5sig[16]; @@ -171,7 +176,7 @@ void sec_sign(uint8 *signature, uint8 *session_key, int length, SHA_CTX sha; MD5_CTX md5; - buf_out_uint32(lenhdr, datalen); + buf_out_uint32(lenhdr, datalen); SHA1_Init(&sha); SHA1_Update(&sha, session_key, length); @@ -249,19 +254,19 @@ static void sec_decrypt(uint8 *data, int length) } /* Read in a NUMBER from a buffer */ -static void sec_read_number(NUMBER *num, uint8 *buffer, int len) +static void sec_read_number(NUMBER * num, uint8 *buffer, int len) { INT *data = num->n_part; int i, j; for (i = 0, j = 0; j < len; i++, j += 2) - data[i] = buffer[j] | (buffer[j+1] << 8); + data[i] = buffer[j] | (buffer[j + 1] << 8); - num->n_len = i; -} + num->n_len = i; +} /* Write a NUMBER to a buffer */ -static void sec_write_number(NUMBER *num, uint8 *buffer, int len) +static void sec_write_number(NUMBER * num, uint8 *buffer, int len) { INT *data = num->n_part; int i, j; @@ -269,7 +274,7 @@ static void sec_write_number(NUMBER *num, uint8 *buffer, int len) for (i = 0, j = 0; j < len; i++, j += 2) { buffer[j] = data[i] & 0xff; - buffer[j+1] = data[i] >> 8; + buffer[j + 1] = data[i] >> 8; } } @@ -297,7 +302,7 @@ STREAM sec_init(uint32 flags, int maxlen) STREAM s; hdrlen = (flags & SEC_ENCRYPT) ? 12 : 4; - s = mcs_init(maxlen + hdrlen); + s = mcs_init(maxlen + hdrlen); s_push_layer(s, sec_hdr, hdrlen); return s; @@ -318,11 +323,11 @@ void sec_send(STREAM s, uint32 flags) #if RDP_DEBUG DEBUG("Sending encrypted packet:\n"); - hexdump(s->p+8, datalen); + hexdump(s->p + 8, datalen); #endif - sec_sign(s->p, sec_sign_key, 8, s->p+8, datalen); - sec_encrypt(s->p+8, datalen); + sec_sign(s->p, sec_sign_key, 8, s->p + 8, datalen); + sec_encrypt(s->p + 8, datalen); } mcs_send(s); @@ -355,7 +360,7 @@ static void sec_out_mcs_data(STREAM s) out_uint8(s, 0x7c); out_uint16_be(s, 1); - out_uint16_be(s, (158 | 0x8000)); /* remaining length */ + out_uint16_be(s, (158 | 0x8000)); /* remaining length */ out_uint16_be(s, 8); /* length? */ out_uint16_be(s, 16); @@ -363,8 +368,8 @@ static void sec_out_mcs_data(STREAM s) out_uint16_le(s, 0xc001); out_uint8(s, 0); - out_uint32_le(s, 0x61637544); /* "Duca" ?! */ - out_uint16_be(s, (144 | 0x8000)); /* remaining length */ + out_uint32_le(s, 0x61637544); /* "Duca" ?! */ + out_uint16_be(s, (144 | 0x8000)); /* remaining length */ /* Client information */ out_uint16_le(s, SEC_TAG_CLI_INFO); @@ -376,16 +381,16 @@ static void sec_out_mcs_data(STREAM s) out_uint16_le(s, 0xca01); out_uint16_le(s, 0xaa03); out_uint32_le(s, keylayout); - out_uint32_le(s, 419); /* client build? we are 419 compatible :-) */ + out_uint32_le(s, 419); /* client build? we are 419 compatible :-) */ /* Unicode name of client, padded to 32 bytes */ rdp_out_unistr(s, hostname, hostlen); - out_uint8s(s, 30-hostlen); + out_uint8s(s, 30 - hostlen); out_uint32_le(s, 4); out_uint32(s, 0); out_uint32_le(s, 12); - out_uint8s(s, 64); /* reserved? 4 + 12 doublewords */ + out_uint8s(s, 64); /* reserved? 4 + 12 doublewords */ out_uint16(s, 0xca01); out_uint16(s, 0); @@ -416,7 +421,7 @@ static BOOL sec_parse_public_key(STREAM s, uint8 **modulus, uint8 **exponent) return False; } - in_uint8s(s, 8); /* modulus_bits, unknown */ + in_uint8s(s, 8); /* modulus_bits, unknown */ in_uint8p(s, *exponent, SEC_EXPONENT_SIZE); in_uint8p(s, *modulus, SEC_MODULUS_SIZE); in_uint8s(s, SEC_PADDING_SIZE); @@ -426,14 +431,15 @@ static BOOL 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) + uint8 **server_random, uint8 **modulus, + uint8 **exponent) { uint32 crypt_level, random_len, rsa_info_len; uint16 tag, length; uint8 *next_tag, *end; - in_uint32_le(s, *rc4_key_size); /* 1 = 40-bit, 2 = 128-bit */ - in_uint32_le(s, crypt_level); /* 1 = low, 2 = medium, 3 = high */ + in_uint32_le(s, *rc4_key_size); /* 1 = 40-bit, 2 = 128-bit */ + in_uint32_le(s, crypt_level); /* 1 = low, 2 = medium, 3 = high */ in_uint32_le(s, random_len); in_uint32_le(s, rsa_info_len); @@ -450,7 +456,7 @@ static BOOL sec_parse_crypt_info(STREAM s, uint32 *rc4_key_size, if (end > s->end) return False; - in_uint8s(s, 12); /* unknown */ + in_uint8s(s, 12); /* unknown */ while (s->p < end) { @@ -462,7 +468,8 @@ static BOOL sec_parse_crypt_info(STREAM s, uint32 *rc4_key_size, switch (tag) { case SEC_TAG_PUBKEY: - if (!sec_parse_public_key(s, modulus, exponent)) + if (!sec_parse_public_key + (s, modulus, exponent)) return False; break; @@ -490,13 +497,13 @@ static void sec_process_crypt_info(STREAM s) uint32 rc4_key_size; if (!sec_parse_crypt_info(s, &rc4_key_size, &server_random, - &modulus, &exponent)) + &modulus, &exponent)) return; /* Generate a client random, and hence determine encryption keys */ generate_random(client_random); sec_rsa_encrypt(sec_crypted_random, client_random, - SEC_RANDOM_SIZE, modulus, exponent); + SEC_RANDOM_SIZE, modulus, exponent); sec_generate_keys(client_random, server_random, rc4_key_size); } @@ -506,7 +513,7 @@ static void sec_process_mcs_data(STREAM s) uint16 tag, length; uint8 *next_tag; - in_uint8s(s, 23); /* header */ + in_uint8s(s, 23); /* header */ while (s->p < s->end) { @@ -554,7 +561,7 @@ STREAM sec_recv() if (sec_flags & SEC_ENCRYPT) { - in_uint8s(s, 8); /* signature */ + in_uint8s(s, 8); /* signature */ sec_decrypt(s->p, s->end - s->p); } diff --git a/tcp.c b/tcp.c index c6d00a6..eaacf72 100644 --- a/tcp.c +++ b/tcp.c @@ -18,14 +18,14 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include /* select read write close */ -#include /* socket connect setsockopt */ -#include /* timeval */ -#include /* gethostbyname */ -#include /* sockaddr_in */ -#include /* TCP_NODELAY */ -#include /* inet_addr */ -#include /* errno */ +#include /* select read write close */ +#include /* socket connect setsockopt */ +#include /* timeval */ +#include /* gethostbyname */ +#include /* sockaddr_in */ +#include /* TCP_NODELAY */ +#include /* inet_addr */ +#include /* errno */ #include "rdesktop.h" static int sock; @@ -49,7 +49,7 @@ STREAM tcp_init(int maxlen) /* Send TCP transport data packet */ void tcp_send(STREAM s) { - int length = s->end - s->data; + int length = s->end - s->data; int sent, total = 0; while (total < length) @@ -90,7 +90,7 @@ STREAM tcp_recv(int length) tv.tv_sec = 0; tv.tv_usec = 100; - ret = select(sock+1, &rfds, NULL, NULL, &tv); + ret = select(sock + 1, &rfds, NULL, NULL, &tv); if (ret) { @@ -119,7 +119,8 @@ BOOL tcp_connect(char *server) if ((nslookup = gethostbyname(server)) != NULL) { - memcpy(&servaddr.sin_addr, nslookup->h_addr, sizeof(servaddr.sin_addr)); + memcpy(&servaddr.sin_addr, nslookup->h_addr, + sizeof(servaddr.sin_addr)); } else if (!(servaddr.sin_addr.s_addr = inet_addr(server))) { @@ -136,14 +137,17 @@ BOOL tcp_connect(char *server) servaddr.sin_family = AF_INET; servaddr.sin_port = htons(TCP_PORT_RDP); - if (connect(sock, (struct sockaddr *)&servaddr, sizeof(struct sockaddr)) < 0) + if (connect + (sock, (struct sockaddr *) &servaddr, + sizeof(struct sockaddr)) < 0) { STATUS("connect: %s\n", strerror(errno)); close(sock); return False; } - setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void *)&true, sizeof(true)); + setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void *) &true, + sizeof(true)); in.size = 4096; in.data = xmalloc(in.size); diff --git a/xwin.c b/xwin.c index 799aef3..8fb7217 100644 --- a/xwin.c +++ b/xwin.c @@ -61,16 +61,17 @@ BOOL ui_create_window(char *title) visual = DefaultVisual(display, DefaultScreen(display)); - attribs.background_pixel = BlackPixel(display, DefaultScreen(display)); + attribs.background_pixel = + BlackPixel(display, DefaultScreen(display)); attribs.backing_store = Always; wnd = XCreateWindow(display, DefaultRootWindow(display), - 0, 0, width, height, 0, 8, InputOutput, visual, - CWBackingStore | CWBackPixel, &attribs); + 0, 0, width, height, 0, 8, InputOutput, visual, + CWBackingStore | CWBackPixel, &attribs); XStoreName(display, wnd, title); XMapWindow(display, wnd); - input_mask = KeyPressMask | KeyReleaseMask; + input_mask = KeyPressMask | KeyReleaseMask; input_mask |= ButtonPressMask | ButtonReleaseMask; if (motion) input_mask |= PointerMotionMask; @@ -99,15 +100,15 @@ static uint8 xwin_translate_key(unsigned long key) switch (key) { - case 0x62: /* left arrow */ + case 0x62: /* left arrow */ return 0x48; - case 0x64: /* up arrow */ + case 0x64: /* up arrow */ return 0x4b; - case 0x66: /* down arrow */ + case 0x66: /* down arrow */ return 0x4d; - case 0x68: /* right arrow */ + case 0x68: /* right arrow */ return 0x50; - case 0x73: /* Windows key */ + case 0x73: /* Windows key */ DEBUG("CHECKPOINT\n"); } @@ -118,11 +119,11 @@ static uint16 xwin_translate_mouse(unsigned long 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; } @@ -146,52 +147,60 @@ void ui_process_events() switch (event.type) { case KeyPress: - scancode = xwin_translate_key(event.xkey.keycode); + scancode = + xwin_translate_key(event.xkey. + keycode); if (scancode == 0) break; rdp_send_input(ev_time, RDP_INPUT_SCANCODE, 0, - scancode, 0); + scancode, 0); break; case KeyRelease: - scancode = xwin_translate_key(event.xkey.keycode); + scancode = + xwin_translate_key(event.xkey. + keycode); if (scancode == 0) break; rdp_send_input(ev_time, RDP_INPUT_SCANCODE, - KBD_FLAG_DOWN | KBD_FLAG_UP, - scancode, 0); + KBD_FLAG_DOWN | KBD_FLAG_UP, + scancode, 0); break; case ButtonPress: - button = xwin_translate_mouse(event.xbutton.button); + button = + xwin_translate_mouse(event.xbutton. + button); if (button == 0) break; rdp_send_input(ev_time, RDP_INPUT_MOUSE, - button | MOUSE_FLAG_DOWN, - event.xbutton.x, - event.xbutton.y); + button | MOUSE_FLAG_DOWN, + event.xbutton.x, + event.xbutton.y); break; case ButtonRelease: - button = xwin_translate_mouse(event.xbutton.button); + button = + xwin_translate_mouse(event.xbutton. + button); if (button == 0) break; rdp_send_input(ev_time, RDP_INPUT_MOUSE, - button, - event.xbutton.x, - event.xbutton.y); + button, + event.xbutton.x, + event.xbutton.y); break; case MotionNotify: rdp_send_input(ev_time, RDP_INPUT_MOUSE, - MOUSE_FLAG_MOVE, - event.xmotion.x, - event.xmotion.y); + MOUSE_FLAG_MOVE, + event.xmotion.x, + event.xmotion.y); } } } @@ -209,29 +218,29 @@ HBITMAP ui_create_bitmap(int width, int height, uint8 *data) bitmap = XCreatePixmap(display, wnd, width, height, 8); image = XCreateImage(display, visual, 8, ZPixmap, 0, - data, width, height, 8, width); + data, width, height, 8, width); XSetFunction(display, gc, GXcopy); XPutImage(display, bitmap, gc, image, 0, 0, 0, 0, width, height); XFree(image); - - return (HBITMAP)bitmap; + + return (HBITMAP) bitmap; } 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; image = XCreateImage(display, visual, 8, ZPixmap, 0, - data, width, height, 8, width); + data, width, height, 8, width); XSetFunction(display, gc, GXcopy); XPutImage(display, wnd, gc, image, 0, 0, x, y, cx, cy); - XFree(image); + XFree(image); } void ui_destroy_bitmap(HBITMAP bmp) { - XFreePixmap(display, (Pixmap)bmp); + XFreePixmap(display, (Pixmap) bmp); } HGLYPH ui_create_glyph(int width, int height, uint8 *data) @@ -247,7 +256,7 @@ HGLYPH ui_create_glyph(int width, int height, uint8 *data) gc = XCreateGC(display, bitmap, 0, NULL); image = XCreateImage(display, visual, 1, ZPixmap, 0, - data, width, height, 8, scanline); + data, width, height, 8, scanline); image->byte_order = MSBFirst; image->bitmap_bit_order = MSBFirst; XInitImage(image); @@ -256,13 +265,13 @@ HGLYPH ui_create_glyph(int width, int height, uint8 *data) XPutImage(display, bitmap, gc, image, 0, 0, 0, 0, width, height); 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); } HCOLOURMAP ui_create_colourmap(COLOURMAP *colours) @@ -289,17 +298,17 @@ HCOLOURMAP ui_create_colourmap(COLOURMAP *colours) XStoreColors(display, map, xcolours, ncolours); xfree(xcolours); - return (HCOLOURMAP)map; + return (HCOLOURMAP) map; } void ui_destroy_colourmap(HCOLOURMAP map) { - XFreeColormap(display, (Colormap)map); + XFreeColormap(display, (Colormap) map); } void ui_set_colourmap(HCOLOURMAP map) { - XSetWindowColormap(display, wnd, (Colormap)map); + XSetWindowColormap(display, wnd, (Colormap) map); } void ui_set_clip(int x, int y, int cx, int cy) @@ -330,22 +339,22 @@ void ui_bell() } static int rop2_map[] = { - GXclear, /* 0 */ - GXnor, /* DPon */ - GXandInverted, /* DPna */ - GXcopyInverted, /* Pn */ - GXandReverse, /* PDna */ - GXinvert, /* Dn */ - GXxor, /* DPx */ - GXnand, /* DPan */ - GXand, /* DPa */ - GXequiv, /* DPxn */ - GXnoop, /* D */ - GXorInverted, /* DPno */ - GXcopy, /* P */ - GXorReverse, /* PDno */ - GXor, /* DPo */ - GXset /* 1 */ + GXclear, /* 0 */ + GXnor, /* DPon */ + GXandInverted, /* DPna */ + GXcopyInverted, /* Pn */ + GXandReverse, /* PDna */ + GXinvert, /* Dn */ + GXxor, /* DPx */ + GXnand, /* DPan */ + GXand, /* DPa */ + GXequiv, /* DPxn */ + GXnoop, /* D */ + GXorInverted, /* DPno */ + GXcopy, /* P */ + GXorReverse, /* PDno */ + GXor, /* DPo */ + GXset /* 1 */ }; static void xwin_set_function(uint8 rop2) @@ -354,7 +363,7 @@ static void xwin_set_function(uint8 rop2) } void ui_destblt(uint8 opcode, - /* dest */ int x, int y, int cx, int cy) + /* dest */ int x, int y, int cx, int cy) { xwin_set_function(opcode); @@ -362,8 +371,8 @@ void 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) + /* dest */ int x, int y, int cx, int cy, + /* brush */ BRUSH *brush, int bgcolour, int fgcolour) { Display *dpy = display; Pixmap fill; @@ -372,13 +381,13 @@ void ui_patblt(uint8 opcode, switch (brush->style) { - case 0: /* Solid */ + case 0: /* Solid */ XSetForeground(dpy, gc, fgcolour); XFillRectangle(dpy, wnd, gc, x, y, cx, cy); break; - case 3: /* Pattern */ - fill = (Pixmap)ui_create_glyph(8, 8, brush->pattern); + case 3: /* Pattern */ + fill = (Pixmap) ui_create_glyph(8, 8, brush->pattern); XSetForeground(dpy, gc, fgcolour); XSetBackground(dpy, gc, bgcolour); @@ -388,7 +397,7 @@ void ui_patblt(uint8 opcode, XFillRectangle(dpy, wnd, gc, x, y, cx, cy); XSetFillStyle(dpy, gc, FillSolid); - ui_destroy_glyph((HGLYPH)fill); + ui_destroy_glyph((HGLYPH) fill); break; default: @@ -397,47 +406,45 @@ void ui_patblt(uint8 opcode, } void ui_screenblt(uint8 opcode, - /* dest */ int x, int y, int cx, int cy, - /* src */ int srcx, int srcy) + /* dest */ int x, int y, int cx, int cy, + /* src */ int srcx, int srcy) { xwin_set_function(opcode); - XCopyArea(display, wnd, wnd, gc, srcx, srcy, - cx, cy, x, y); + XCopyArea(display, wnd, wnd, gc, srcx, srcy, cx, cy, x, y); } void ui_memblt(uint8 opcode, - /* dest */ int x, int y, int cx, int cy, - /* src */ HBITMAP src, int srcx, int srcy) + /* dest */ int x, int y, int cx, int cy, + /* src */ HBITMAP src, int srcx, int srcy) { xwin_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); } 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) + /* dest */ int x, int y, int cx, int cy, + /* src */ HBITMAP src, int srcx, int srcy, + /* 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. */ switch (opcode) { - case 0x69: /* PDSxxn */ + case 0x69: /* PDSxxn */ ui_memblt(ROP2_XOR, x, y, cx, cy, src, srcx, srcy); ui_patblt(ROP2_NXOR, x, y, cx, cy, - brush, bgcolour, fgcolour); + brush, bgcolour, fgcolour); break; - case 0xb8: /* PSDPxax */ + case 0xb8: /* PSDPxax */ ui_patblt(ROP2_XOR, x, y, cx, cy, - brush, bgcolour, fgcolour); + brush, bgcolour, fgcolour); ui_memblt(ROP2_AND, x, y, cx, cy, src, srcx, srcy); ui_patblt(ROP2_XOR, x, y, cx, cy, - brush, bgcolour, fgcolour); + brush, bgcolour, fgcolour); break; default: @@ -447,8 +454,8 @@ void ui_triblt(uint8 opcode, } void ui_line(uint8 opcode, - /* dest */ int startx, int starty, int endx, int endy, - /* pen */ PEN *pen) + /* dest */ int startx, int starty, int endx, int endy, + /* pen */ PEN *pen) { xwin_set_function(opcode); @@ -457,8 +464,8 @@ void ui_line(uint8 opcode, } void ui_rect( - /* dest */ int x, int y, int cx, int cy, - /* brush */ int colour) + /* dest */ int x, int y, int cx, int cy, + /* brush */ int colour) { xwin_set_function(ROP2_COPY); @@ -467,10 +474,11 @@ void ui_rect( } void ui_draw_glyph(int mixmode, - /* dest */ int x, int y, int cx, int cy, - /* src */ HGLYPH glyph, int srcx, int srcy, int bgcolour, int fgcolour) + /* dest */ int x, int y, int cx, int cy, + /* src */ HGLYPH glyph, int srcx, int srcy, int bgcolour, + int fgcolour) { - Pixmap pixmap = (Pixmap)glyph; + Pixmap pixmap = (Pixmap) glyph; xwin_set_function(ROP2_COPY); @@ -482,15 +490,14 @@ void ui_draw_glyph(int mixmode, XSetStipple(display, gc, pixmap); XSetFillStyle(display, gc, FillStippled); XSetTSOrigin(display, gc, x, y); - XFillRectangle(display, wnd, gc, - x, y, cx, cy); + XFillRectangle(display, wnd, gc, x, y, cx, cy); XSetFillStyle(display, gc, FillSolid); break; case MIX_OPAQUE: XSetBackground(display, gc, bgcolour); XCopyPlane(display, pixmap, wnd, gc, - srcx, srcy, cx, cy, x, y, 1); + srcx, srcy, cx, cy, x, y, 1); break; default: @@ -499,9 +506,9 @@ void ui_draw_glyph(int mixmode, } 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) + int clipx, int clipy, int clipcx, int clipcy, + int boxx, int boxy, int boxcx, int boxcy, + int bgcolour, int fgcolour, uint8 *text, uint8 length) { FONTGLYPH *glyph; int i; @@ -525,11 +532,11 @@ void ui_draw_text(uint8 font, uint8 flags, int mixmode, int x, int y, if (glyph != NULL) { - ui_draw_glyph(mixmode, x + (short)glyph->offset, - y + (short)glyph->baseline, - glyph->width, glyph->height, - glyph->pixmap, 0, 0, - bgcolour, fgcolour); + ui_draw_glyph(mixmode, x + (short) glyph->offset, + y + (short) glyph->baseline, + glyph->width, glyph->height, + glyph->pixmap, 0, 0, + bgcolour, fgcolour); if (flags & TEXT2_IMPLICIT_X) x += glyph->width; @@ -557,7 +564,7 @@ void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy) return; image = XCreateImage(display, visual, 8, ZPixmap, 0, - data, cx, cy, 32, cx); + data, cx, cy, 32, cx); XSetFunction(display, gc, GXcopy); XPutImage(display, wnd, gc, image, 0, 0, x, y, cx, cy); XFree(image);