Indent fixes

git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@434 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
Peter Åstrand 2003-07-09 09:18:20 +00:00
parent 11569c322f
commit 7ff54cdd90
16 changed files with 275 additions and 172 deletions

View File

@ -67,7 +67,7 @@ channel_register(char *name, uint32 flags, void (*callback) (STREAM))
}
STREAM
channel_init(VCHANNEL *channel, uint32 length)
channel_init(VCHANNEL * channel, uint32 length)
{
STREAM s;
@ -77,7 +77,7 @@ channel_init(VCHANNEL *channel, uint32 length)
}
void
channel_send(STREAM s, VCHANNEL *channel)
channel_send(STREAM s, VCHANNEL * channel)
{
uint32 length, flags;
uint32 thislength, remaining;
@ -89,7 +89,7 @@ channel_send(STREAM s, VCHANNEL *channel)
thislength = MIN(length, CHANNEL_CHUNK_LENGTH);
remaining = length - thislength;
flags = (remaining == 0) ? CHANNEL_FLAG_FIRST|CHANNEL_FLAG_LAST : CHANNEL_FLAG_FIRST;
flags = (remaining == 0) ? CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST : CHANNEL_FLAG_FIRST;
if (channel->flags & CHANNEL_OPTION_SHOW_PROTOCOL)
flags |= CHANNEL_FLAG_SHOW_PROTOCOL;
@ -168,4 +168,3 @@ channel_process(STREAM s, uint16 mcs_channel)
}
}
}

View File

@ -34,7 +34,7 @@
static VCHANNEL *cliprdr_channel;
static void
cliprdr_send_packet(uint16 type, uint16 status, uint8 *data, uint32 length)
cliprdr_send_packet(uint16 type, uint16 status, uint8 * data, uint32 length)
{
STREAM s;
@ -45,7 +45,7 @@ cliprdr_send_packet(uint16 type, uint16 status, uint8 *data, uint32 length)
out_uint16_le(s, status);
out_uint32_le(s, length);
out_uint8p(s, data, length);
out_uint32(s, 0); /* pad? */
out_uint32(s, 0); /* pad? */
s_mark_end(s);
channel_send(s, cliprdr_channel);
}
@ -56,7 +56,7 @@ cliprdr_send_text_format_announce(void)
uint8 buffer[36];
buf_out_uint32(buffer, CF_TEXT);
memset(buffer+4, 0, sizeof(buffer)-4); /* description */
memset(buffer + 4, 0, sizeof(buffer) - 4); /* description */
cliprdr_send_packet(CLIPRDR_FORMAT_ANNOUNCE, CLIPRDR_REQUEST, buffer, sizeof(buffer));
}
@ -66,12 +66,12 @@ cliprdr_send_blah_format_announce(void)
uint8 buffer[36];
buf_out_uint32(buffer, CF_OEMTEXT);
memset(buffer+4, 0, sizeof(buffer)-4); /* description */
memset(buffer + 4, 0, sizeof(buffer) - 4); /* description */
cliprdr_send_packet(CLIPRDR_FORMAT_ANNOUNCE, CLIPRDR_REQUEST, buffer, sizeof(buffer));
}
void
cliprdr_send_native_format_announce(uint8 *data, uint32 length)
cliprdr_send_native_format_announce(uint8 * data, uint32 length)
{
cliprdr_send_packet(CLIPRDR_FORMAT_ANNOUNCE, CLIPRDR_REQUEST, data, length);
}
@ -86,7 +86,7 @@ cliprdr_send_data_request(uint32 format)
}
void
cliprdr_send_data(uint8 *data, uint32 length)
cliprdr_send_data(uint8 * data, uint32 length)
{
cliprdr_send_packet(CLIPRDR_DATA_RESPONSE, CLIPRDR_RESPONSE, data, length);
}
@ -145,7 +145,10 @@ cliprdr_process(STREAM s)
BOOL
cliprdr_init(void)
{
cliprdr_channel = channel_register("cliprdr", CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP \
| CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL, cliprdr_process);
cliprdr_channel =
channel_register("cliprdr",
CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP |
CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL,
cliprdr_process);
return (cliprdr_channel != NULL);
}

View File

@ -303,4 +303,3 @@ enum RDP_INPUT_DEVICE
#define STATUS_INVALID_PARAMETER 0xc000000d
#define STATUS_INVALID_DEVICE_REQUEST 0xc0000010
#define STATUS_ACCESS_DENIED 0xc0000022

View File

@ -3,7 +3,7 @@
FILE *printer_fp;
static NTSTATUS
printer_create(HANDLE *handle)
printer_create(HANDLE * handle)
{
printer_fp = popen("lpr", "w");
*handle = 0;
@ -18,18 +18,16 @@ printer_close(HANDLE handle)
}
static NTSTATUS
printer_write(HANDLE handle, uint8 *data, uint32 length, uint32 *result)
printer_write(HANDLE handle, uint8 * data, uint32 length, uint32 * result)
{
*result = fwrite(data, 1, length, printer_fp);
return STATUS_SUCCESS;
}
DEVICE_FNS printer_fns =
{
DEVICE_FNS printer_fns = {
printer_create,
printer_close,
NULL, /* read */
NULL, /* read */
printer_write,
NULL /* device_control */
NULL /* device_control */
};

71
proto.h
View File

@ -1,29 +1,32 @@
/* bitmap.c */
BOOL bitmap_decompress(unsigned char *output, int width, int height, unsigned char *input, int size, int Bpp);
BOOL bitmap_decompress(unsigned char *output, int width, int height, unsigned char *input, int size,
int Bpp);
/* 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);
/* channels.c */
VCHANNEL *channel_register(char *name, uint32 flags, void (*callback)(STREAM));
STREAM channel_init(VCHANNEL *channel, uint32 length);
void channel_send(STREAM s, VCHANNEL *channel);
VCHANNEL *channel_register(char *name, uint32 flags, void (*callback) (STREAM));
STREAM channel_init(VCHANNEL * channel, uint32 length);
void channel_send(STREAM s, VCHANNEL * channel);
void channel_process(STREAM s, uint16 mcs_channel);
/* cliprdr.c */
void cliprdr_send_text_format_announce(void);
void cliprdr_send_native_format_announce(uint8 *data, uint32 length);
void cliprdr_send_native_format_announce(uint8 * data, uint32 length);
void cliprdr_send_data_request(uint32 format);
void cliprdr_send_data(uint8 *data, uint32 length);
void cliprdr_send_data(uint8 * data, uint32 length);
BOOL cliprdr_init(void);
/* ewmhints.c */
int get_current_workarea(uint32 *x, uint32 *y, uint32 *width, uint32 *height);
int get_current_workarea(uint32 * x, uint32 * y, uint32 * width, uint32 * height);
/* iso.c */
STREAM iso_init(int length);
void iso_send(STREAM s);
@ -36,7 +39,7 @@ void licence_process(STREAM s);
STREAM mcs_init(int length);
void mcs_send_to_channel(STREAM s, uint16 channel);
void mcs_send(STREAM s);
STREAM mcs_recv(uint16 *channel);
STREAM mcs_recv(uint16 * channel);
BOOL mcs_connect(char *server, STREAM mcs_data, char *username);
void mcs_disconnect(void);
/* orders.c */
@ -44,7 +47,7 @@ void process_orders(STREAM s, uint16 num_orders);
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);
@ -56,14 +59,16 @@ 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 process_null_system_pointer_pdu(STREAM s);
void process_colour_pointer_pdu(STREAM s);
void process_cached_pointer_pdu(STREAM s);
void process_bitmap_updates(STREAM s);
void process_palette(STREAM s);
BOOL 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);
/* rdp5.c */
void rdp5_process(STREAM s, BOOL encryption);
@ -71,14 +76,16 @@ void rdp5_process(STREAM s, BOOL encryption);
void rdpdr_send_connect(void);
void rdpdr_send_name(void);
void rdpdr_send_available(void);
void rdpdr_send_completion(uint32 device, uint32 id, uint32 status, uint32 result, uint8 *buffer, uint32 length);
void rdpdr_send_completion(uint32 device, uint32 id, uint32 status, uint32 result, uint8 * buffer,
uint32 length);
BOOL rdpdr_init(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_decrypt(uint8 *data, int length);
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_decrypt(uint8 * data, int length);
STREAM sec_init(uint32 flags, int maxlen);
void sec_send_to_channel(STREAM s, uint32 flags, uint16 channel);
void sec_send(STREAM s, uint32 flags);
@ -116,28 +123,34 @@ void ui_destroy_window(void);
void xwin_toggle_fullscreen(void);
int 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_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_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);

View File

@ -274,7 +274,7 @@ main(int argc, char *argv[])
case 'e':
encryption = False;
break;
case 'E':
case 'E':
packet_encryption = False;
break;
case 'm':
@ -384,7 +384,7 @@ main(int argc, char *argv[])
/* By setting encryption to False here, we have an encrypted login
packet but unencrypted transfer of other packets */
if (!packet_encryption)
if (!packet_encryption)
encryption = False;
@ -401,7 +401,7 @@ main(int argc, char *argv[])
rdp_disconnect();
ui_deinit();
if (True == rdp_retval)
if (True == rdp_retval)
return 0;
else
return 2;

4
rdp.c
View File

@ -889,8 +889,8 @@ rdp_main_loop(void)
}
return True;
/* We want to detect if we got a clean shutdown, but we
can't. Se above.
return False; */
can't. Se above.
return False; */
}
/* Establish a connection up to the RDP layer */

10
rdp5.c
View File

@ -49,10 +49,10 @@ rdp5_process(STREAM s, BOOL encryption)
switch (type)
{
/* Thanks to Jeroen Meijer <jdmeijer at yahoo
dot com> for finding out the meaning of
most of the opcodes here. Especially opcode
8! :) */
/* Thanks to Jeroen Meijer <jdmeijer at yahoo
dot com> for finding out the meaning of
most of the opcodes here. Especially opcode
8! :) */
case 0: /* orders */
in_uint16_le(s, count);
process_orders(s, count);
@ -70,7 +70,7 @@ rdp5_process(STREAM s, BOOL encryption)
case 5:
process_null_system_pointer_pdu(s);
break;
case 8:
case 8:
in_uint16_le(s, x);
in_uint16_le(s, y);
if (s_check(s))

57
rdpdr.c
View File

@ -20,9 +20,9 @@ rdpdr_send_connect(void)
s = channel_init(rdpdr_channel, 12);
out_uint8a(s, magic, 4);
out_uint16_le(s, 1); /* unknown */
out_uint16_le(s, 1); /* unknown */
out_uint16_le(s, 5);
out_uint32_be(s, 0x815ed39d); /* IP address (use 127.0.0.1) 0x815ed39d */
out_uint32_be(s, 0x815ed39d); /* IP address (use 127.0.0.1) 0x815ed39d */
s_mark_end(s);
channel_send(s, rdpdr_channel);
}
@ -31,16 +31,16 @@ void
rdpdr_send_name(void)
{
uint8 magic[4] = "rDNC";
uint32 hostlen = (strlen(hostname)+1)*2;
uint32 hostlen = (strlen(hostname) + 1) * 2;
STREAM s;
s = channel_init(rdpdr_channel, 16+hostlen);
s = channel_init(rdpdr_channel, 16 + hostlen);
out_uint8a(s, magic, 4);
out_uint16_le(s, 0x63); /* unknown */
out_uint16_le(s, 0x63); /* unknown */
out_uint16_le(s, 0x72);
out_uint32(s, 0);
out_uint32_le(s, hostlen);
rdp_out_unistr(s, hostname, hostlen-2);
rdp_out_unistr(s, hostname, hostlen - 2);
s_mark_end(s);
channel_send(s, rdpdr_channel);
}
@ -49,15 +49,15 @@ void
rdpdr_send_available(void)
{
uint8 magic[4] = "rDAD";
char *driver = "Digital turbo PrintServer 20"; /* Fairly generic PostScript driver */
char *driver = "Digital turbo PrintServer 20"; /* Fairly generic PostScript driver */
char *printer = "PostScript";
uint32 driverlen = (strlen(driver)+1)*2;
uint32 printerlen = (strlen(printer)+1)*2;
uint32 driverlen = (strlen(driver) + 1) * 2;
uint32 printerlen = (strlen(printer) + 1) * 2;
STREAM s;
s = channel_init(rdpdr_channel, 8+20);
s = channel_init(rdpdr_channel, 8 + 20);
out_uint8a(s, magic, 4);
out_uint32_le(s, 1); /* Number of devices */
out_uint32_le(s, 1); /* Number of devices */
#if 1
out_uint32_le(s, 0x1); /* Device type 0x1 - serial */
@ -67,35 +67,35 @@ rdpdr_send_available(void)
out_uint32(s, 0);
#endif
#if 0
out_uint32_le(s, 0x2); /* Device type 0x2 - parallel */
out_uint32_le(s, 0x2); /* Device type 0x2 - parallel */
out_uint32_le(s, 0);
out_uint8p(s, "LPT2", 4);
out_uint8s(s, 4);
out_uint32(s, 0);
#endif
#if 1
out_uint32_le(s, 0x4); /* Device type 0x4 - printer */
out_uint32_le(s, 0x4); /* Device type 0x4 - printer */
out_uint32_le(s, 1);
out_uint8p(s, "PRN1", 4);
out_uint8s(s, 4);
out_uint32_le(s, 24+driverlen+printerlen); /* length of extra info */
out_uint32_le(s, 2); /* unknown */
out_uint8s(s, 8); /* unknown */
out_uint32_le(s, driverlen); /* length of driver name */
out_uint32_le(s, printerlen); /* length of printer name */
out_uint32(s, 0); /* unknown */
rdp_out_unistr(s, driver, driverlen-2);
rdp_out_unistr(s, printer, printerlen-2);
out_uint32_le(s, 24 + driverlen + printerlen); /* length of extra info */
out_uint32_le(s, 2); /* unknown */
out_uint8s(s, 8); /* unknown */
out_uint32_le(s, driverlen); /* length of driver name */
out_uint32_le(s, printerlen); /* length of printer name */
out_uint32(s, 0); /* unknown */
rdp_out_unistr(s, driver, driverlen - 2);
rdp_out_unistr(s, printer, printerlen - 2);
#endif
#if 0
out_uint32_le(s, 0x8); /* Device type 0x8 - disk */
out_uint32_le(s, 0x8); /* Device type 0x8 - disk */
out_uint32_le(s, 0);
out_uint8p(s, "Z:", 2);
out_uint8s(s, 6);
out_uint32(s, 0);
#endif
#if 0
out_uint32_le(s, 0x20); /* Device type 0x20 - smart card */
out_uint32_le(s, 0x20); /* Device type 0x20 - smart card */
out_uint32_le(s, 0);
out_uint8p(s, "SCARD", 5);
out_uint8s(s, 3);
@ -107,7 +107,8 @@ rdpdr_send_available(void)
}
void
rdpdr_send_completion(uint32 device, uint32 id, uint32 status, uint32 result, uint8 *buffer, uint32 length)
rdpdr_send_completion(uint32 device, uint32 id, uint32 status, uint32 result, uint8 * buffer,
uint32 length)
{
uint8 magic[4] = "rDCI";
STREAM s;
@ -120,7 +121,7 @@ rdpdr_send_completion(uint32 device, uint32 id, uint32 status, uint32 result, ui
out_uint32_le(s, result);
out_uint8p(s, buffer, length);
s_mark_end(s);
hexdump(s->channel_hdr+8, s->end-s->channel_hdr-8);
hexdump(s->channel_hdr + 8, s->end - s->channel_hdr - 8);
channel_send(s, rdpdr_channel);
}
@ -211,7 +212,7 @@ rdpdr_process(STREAM s)
char *magic;
printf("rdpdr_process\n");
hexdump(s->p, s->end-s->p);
hexdump(s->p, s->end - s->p);
in_uint8p(s, magic, 4);
if ((magic[0] == 'r') && (magic[1] == 'D'))
@ -247,6 +248,8 @@ rdpdr_process(STREAM s)
BOOL
rdpdr_init(void)
{
rdpdr_channel = channel_register("rdpdr", CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_COMPRESS_RDP, rdpdr_process);
rdpdr_channel =
channel_register("rdpdr", CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_COMPRESS_RDP,
rdpdr_process);
return (rdpdr_channel != NULL);
}

View File

@ -6,12 +6,14 @@ static void
rdpsnd_process(STREAM s)
{
printf("rdpsnd_process\n");
hexdump(s->p, s->end-s->p);
hexdump(s->p, s->end - s->p);
}
BOOL
rdpsnd_init(void)
{
rdpsnd_channel = channel_register("rdpsnd", CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP, rdpsnd_process);
rdpsnd_channel =
channel_register("rdpsnd", CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP,
rdpsnd_process);
return (rdpsnd_channel != NULL);
}

View File

@ -406,7 +406,7 @@ sec_out_mcs_data(STREAM s)
unsigned int i;
if (g_num_channels > 0)
length += g_num_channels*12 + 8;
length += g_num_channels * 12 + 8;
if (hostlen > 30)
hostlen = 30;
@ -779,7 +779,7 @@ sec_process_mcs_data(STREAM s)
case SEC_TAG_SRV_CHANNELS:
/* FIXME: We should parse this information and
use it to map RDP5 channels to MCS
channels */
channels */
break;
default:

180
serial.c
View File

@ -72,35 +72,77 @@ get_termios(void)
speed = cfgetispeed(&termios);
switch (speed)
{
case B75: baud_rate = 75; break;
case B110: baud_rate = 110; break;
case B134: baud_rate = 134; break;
case B150: baud_rate = 150; break;
case B300: baud_rate = 300; break;
case B600: baud_rate = 600; break;
case B1200: baud_rate = 1200; break;
case B1800: baud_rate = 1800; break;
case B2400: baud_rate = 2400; break;
case B4800: baud_rate = 4800; break;
case B9600: baud_rate = 9600; break;
case B19200: baud_rate = 19200; break;
case B38400: baud_rate = 38400; break;
case B57600: baud_rate = 57600; break;
case B115200: baud_rate = 115200; break;
default: baud_rate = 0; break;
case B75:
baud_rate = 75;
break;
case B110:
baud_rate = 110;
break;
case B134:
baud_rate = 134;
break;
case B150:
baud_rate = 150;
break;
case B300:
baud_rate = 300;
break;
case B600:
baud_rate = 600;
break;
case B1200:
baud_rate = 1200;
break;
case B1800:
baud_rate = 1800;
break;
case B2400:
baud_rate = 2400;
break;
case B4800:
baud_rate = 4800;
break;
case B9600:
baud_rate = 9600;
break;
case B19200:
baud_rate = 19200;
break;
case B38400:
baud_rate = 38400;
break;
case B57600:
baud_rate = 57600;
break;
case B115200:
baud_rate = 115200;
break;
default:
baud_rate = 0;
break;
}
speed = cfgetospeed(&termios);
dtr = (speed == B0) ? 0 : 1;
stop_bits = (termios.c_cflag & CSTOPB) ? STOP_BITS_2 : STOP_BITS_1;
parity = (termios.c_cflag & PARENB) ? ((termios.c_cflag & PARODD) ? ODD_PARITY : EVEN_PARITY) : NO_PARITY;
parity = (termios.
c_cflag & PARENB) ? ((termios.
c_cflag & PARODD) ? ODD_PARITY : EVEN_PARITY) : NO_PARITY;
switch (termios.c_cflag & CSIZE)
{
case CS5: word_length = 5; break;
case CS6: word_length = 6; break;
case CS7: word_length = 7; break;
default: word_length = 8; break;
case CS5:
word_length = 5;
break;
case CS6:
word_length = 6;
break;
case CS7:
word_length = 7;
break;
default:
word_length = 8;
break;
}
return True;
@ -113,22 +155,54 @@ set_termios(void)
switch (baud_rate)
{
case 75: speed = B75; break;
case 110: speed = B110; break;
case 134: speed = B134; break;
case 150: speed = B150; break;
case 300: speed = B300; break;
case 600: speed = B600; break;
case 1200: speed = B1200; break;
case 1800: speed = B1800; break;
case 2400: speed = B2400; break;
case 4800: speed = B4800; break;
case 9600: speed = B9600; break;
case 19200: speed = B19200; break;
case 38400: speed = B38400; break;
case 57600: speed = B57600; break;
case 115200: speed = B115200; break;
default: speed = B0; break;
case 75:
speed = B75;
break;
case 110:
speed = B110;
break;
case 134:
speed = B134;
break;
case 150:
speed = B150;
break;
case 300:
speed = B300;
break;
case 600:
speed = B600;
break;
case 1200:
speed = B1200;
break;
case 1800:
speed = B1800;
break;
case 2400:
speed = B2400;
break;
case 4800:
speed = B4800;
break;
case 9600:
speed = B9600;
break;
case 19200:
speed = B19200;
break;
case 38400:
speed = B38400;
break;
case 57600:
speed = B57600;
break;
case 115200:
speed = B115200;
break;
default:
speed = B0;
break;
}
/* on systems with separate ispeed and ospeed, we can remember the speed
@ -136,7 +210,7 @@ set_termios(void)
cfsetispeed(&termios, speed);
cfsetospeed(&termios, dtr ? speed : 0);
termios.c_cflag &= ~(CSTOPB|PARENB|PARODD|CSIZE);
termios.c_cflag &= ~(CSTOPB | PARENB | PARODD | CSIZE);
switch (stop_bits)
{
case STOP_BITS_2:
@ -149,22 +223,30 @@ set_termios(void)
termios.c_cflag |= PARENB;
break;
case ODD_PARITY:
termios.c_cflag |= PARENB|PARODD;
termios.c_cflag |= PARENB | PARODD;
break;
}
switch (word_length)
{
case 5: termios.c_cflag |= CS5; break;
case 6: termios.c_cflag |= CS6; break;
case 7: termios.c_cflag |= CS7; break;
default: termios.c_cflag |= CS8; break;
case 5:
termios.c_cflag |= CS5;
break;
case 6:
termios.c_cflag |= CS6;
break;
case 7:
termios.c_cflag |= CS7;
break;
default:
termios.c_cflag |= CS8;
break;
}
tcsetattr(serial_fd, TCSANOW, &termios);
}
static NTSTATUS
serial_create(HANDLE *handle)
serial_create(HANDLE * handle)
{
/* XXX do we have to handle concurrent open attempts? */
serial_fd = open("/dev/ttyS0", O_RDWR);
@ -186,14 +268,14 @@ serial_close(HANDLE handle)
}
static NTSTATUS
serial_read(HANDLE handle, uint8 *data, uint32 length, uint32 *result)
serial_read(HANDLE handle, uint8 * data, uint32 length, uint32 * result)
{
*result = read(serial_fd, data, length);
return STATUS_SUCCESS;
}
static NTSTATUS
serial_write(HANDLE handle, uint8 *data, uint32 length, uint32 *result)
serial_write(HANDLE handle, uint8 * data, uint32 length, uint32 * result)
{
*result = write(serial_fd, data, length);
return STATUS_SUCCESS;
@ -253,7 +335,7 @@ serial_device_control(HANDLE handle, uint32 request, STREAM in, STREAM out)
break;
case SERIAL_GET_HANDFLOW:
out_uint32_le(out, 0);
out_uint32_le(out, 3); /* Xon/Xoff */
out_uint32_le(out, 3); /* Xon/Xoff */
out_uint32_le(out, 0);
out_uint32_le(out, 0);
break;
@ -309,12 +391,10 @@ serial_device_control(HANDLE handle, uint32 request, STREAM in, STREAM out)
return STATUS_SUCCESS;
}
DEVICE_FNS serial_fns =
{
DEVICE_FNS serial_fns = {
serial_create,
serial_close,
serial_read,
serial_write,
serial_device_control
};

11
types.h
View File

@ -125,11 +125,10 @@ typedef uint32 HANDLE;
typedef struct _DEVICE_FNS
{
NTSTATUS (*create)(HANDLE *handle);
NTSTATUS (*close)(HANDLE handle);
NTSTATUS (*read)(HANDLE handle, uint8 *data, uint32 length, uint32 *result);
NTSTATUS (*write)(HANDLE handle, uint8 *data, uint32 length, uint32 *result);
NTSTATUS (*device_control)(HANDLE handle, uint32 request, STREAM in, STREAM out);
NTSTATUS(*create) (HANDLE * handle);
NTSTATUS(*close) (HANDLE handle);
NTSTATUS(*read) (HANDLE handle, uint8 * data, uint32 length, uint32 * result);
NTSTATUS(*write) (HANDLE handle, uint8 * data, uint32 length, uint32 * result);
NTSTATUS(*device_control) (HANDLE handle, uint32 request, STREAM in, STREAM out);
}
DEVICE_FNS;

47
xclip.c
View File

@ -37,7 +37,8 @@ static int have_primary = 0;
static int rdesktop_is_selection_owner = 0;
static void
xclip_provide_selection(XSelectionRequestEvent *req, Atom type, unsigned int format, uint8 *data, uint32 length)
xclip_provide_selection(XSelectionRequestEvent * req, Atom type, unsigned int format, uint8 * data,
uint32 length)
{
XEvent xev;
@ -95,7 +96,8 @@ xclip_handle_SelectionNotify(XSelectionEvent * event)
text_target = XInternAtom(display, "TEXT", False);
for (i = 0; i < nitems; i++)
{
DEBUG_CLIPBOARD(("Target %d: %s\n", i, XGetAtomName(display, supported_targets[i])));
DEBUG_CLIPBOARD(("Target %d: %s\n", i,
XGetAtomName(display, supported_targets[i])));
if (supported_targets[i] == text_target)
{
DEBUG_CLIPBOARD(("Other party supports TEXT, choosing that as best_target\n"));
@ -105,7 +107,8 @@ xclip_handle_SelectionNotify(XSelectionEvent * event)
XFree(data);
}
XConvertSelection(display, primary_atom, best_target, rdesktop_clipboard_target_atom, wnd, event->time);
XConvertSelection(display, primary_atom, best_target,
rdesktop_clipboard_target_atom, wnd, event->time);
return;
}
@ -115,19 +118,19 @@ xclip_handle_SelectionNotify(XSelectionEvent * event)
goto fail;
}
cliprdr_send_data(data, nitems+1);
cliprdr_send_data(data, nitems + 1);
XFree(data);
if (!rdesktop_is_selection_owner)
cliprdr_send_text_format_announce();
return;
fail:
fail:
cliprdr_send_data(NULL, 0);
}
void
xclip_handle_SelectionRequest(XSelectionRequestEvent *event)
xclip_handle_SelectionRequest(XSelectionRequestEvent * event)
{
unsigned long nitems, bytes_left;
uint32 *wanted_format;
@ -141,19 +144,20 @@ xclip_handle_SelectionRequest(XSelectionRequestEvent *event)
if (event->target == targets_atom)
{
xclip_provide_selection(event, XA_ATOM, 32, (uint8 *)&targets, NUM_TARGETS);
xclip_provide_selection(event, XA_ATOM, 32, (uint8 *) & targets, NUM_TARGETS);
return;
}
else if (event->target == timestamp_atom)
{
xclip_provide_selection(event, XA_INTEGER, 32, (uint8 *)&last_gesturetime, 1);
xclip_provide_selection(event, XA_INTEGER, 32, (uint8 *) & last_gesturetime, 1);
return;
}
else if (event->target == rdesktop_clipboard_formats_atom)
{
res = XGetWindowProperty(display, event->requestor,
rdesktop_clipboard_target_atom, 0, 1, True, XA_INTEGER,
&type, &format, &nitems, &bytes_left, (unsigned char **) &wanted_format);
rdesktop_clipboard_target_atom, 0, 1, True, XA_INTEGER,
&type, &format, &nitems, &bytes_left,
(unsigned char **) &wanted_format);
format = (res == Success) ? *wanted_format : CF_TEXT;
}
else
@ -176,7 +180,7 @@ xclip_handle_SelectionClear(void)
}
void
xclip_handle_PropertyNotify(XPropertyEvent *event)
xclip_handle_PropertyNotify(XPropertyEvent * event)
{
unsigned long nitems, bytes_left;
int format, res;
@ -186,14 +190,15 @@ xclip_handle_PropertyNotify(XPropertyEvent *event)
if (event->atom != rdesktop_clipboard_formats_atom)
return;
if (have_primary) /* from us */
if (have_primary) /* from us */
return;
if (event->state == PropertyNewValue)
{
res = XGetWindowProperty(display, DefaultRootWindow(display),
rdesktop_clipboard_formats_atom, 0, XMaxRequestSize(display), False, XA_STRING,
&type, &format, &nitems, &bytes_left, &data);
rdesktop_clipboard_formats_atom, 0,
XMaxRequestSize(display), False, XA_STRING, &type, &format,
&nitems, &bytes_left, &data);
if ((res == Success) && (nitems > 0))
{
@ -221,7 +226,8 @@ ui_clip_format_announce(char *data, uint32 length)
have_primary = 1;
XChangeProperty(display, DefaultRootWindow(display),
rdesktop_clipboard_formats_atom, XA_STRING, 8, PropModeReplace, data, length);
rdesktop_clipboard_formats_atom, XA_STRING, 8, PropModeReplace, data,
length);
XSetSelectionOwner(display, clipboard_atom, wnd, last_gesturetime);
if (XGetSelectionOwner(display, clipboard_atom) != wnd)
@ -232,7 +238,7 @@ ui_clip_format_announce(char *data, uint32 length)
void
ui_clip_handle_data(char *data, uint32 length)
{
xclip_provide_selection(&selection_request, XA_STRING, 8, data, length-1);
xclip_provide_selection(&selection_request, XA_STRING, 8, data, length - 1);
}
void
@ -248,7 +254,7 @@ ui_clip_request_data(uint32 format)
XA_INTEGER, 32, PropModeReplace, (unsigned char *) &format, 1);
XConvertSelection(display, primary_atom, rdesktop_clipboard_formats_atom,
rdesktop_clipboard_target_atom, wnd, CurrentTime);
rdesktop_clipboard_target_atom, wnd, CurrentTime);
return;
}
@ -256,7 +262,7 @@ ui_clip_request_data(uint32 format)
if (selectionowner != None)
{
XConvertSelection(display, primary_atom, targets_atom,
rdesktop_clipboard_target_atom, wnd, CurrentTime);
rdesktop_clipboard_target_atom, wnd, CurrentTime);
return;
}
@ -265,7 +271,7 @@ ui_clip_request_data(uint32 format)
if (selectionowner != None)
{
XConvertSelection(display, clipboard_atom, targets_atom,
rdesktop_clipboard_target_atom, wnd, CurrentTime);
rdesktop_clipboard_target_atom, wnd, CurrentTime);
return;
}
@ -301,6 +307,7 @@ xclip_init(void)
/* rdesktop sets _RDESKTOP_CLIPBOARD_FORMATS on the root window when acquiring the clipboard.
Other interested rdesktops can use this to notify their server of the available formats. */
rdesktop_clipboard_formats_atom = XInternAtom(display, "_RDESKTOP_CLIPBOARD_FORMATS", False);
rdesktop_clipboard_formats_atom =
XInternAtom(display, "_RDESKTOP_CLIPBOARD_FORMATS", False);
XSelectInput(display, DefaultRootWindow(display), PropertyChangeMask);
}

View File

@ -1,4 +1,4 @@
void xclip_handle_SelectionNotify(XSelectionEvent *event);
void xclip_handle_SelectionRequest(XSelectionRequestEvent *xevent);
void xclip_handle_SelectionNotify(XSelectionEvent * event);
void xclip_handle_SelectionRequest(XSelectionRequestEvent * xevent);
void xclip_handle_SelectionClear(void);
void xclip_handle_PropertyNotify(XPropertyEvent *xev);
void xclip_handle_PropertyNotify(XPropertyEvent * xev);

6
xwin.c
View File

@ -802,7 +802,8 @@ xwin_process_events(void)
/* Multi_key compatible version */
{
XmbLookupString(IC,
&xevent.xkey, str, sizeof(str), &keysym, &status);
&xevent.xkey, str, sizeof(str), &keysym,
&status);
if (!((status == XLookupKeySym) || (status == XLookupBoth)))
{
error("XmbLookupString failed with status 0x%x\n",
@ -999,7 +1000,7 @@ xwin_process_events(void)
}
break;
/* clipboard stuff */
/* clipboard stuff */
case SelectionNotify:
xclip_handle_SelectionNotify(&xevent.xselection);
break;
@ -1719,4 +1720,3 @@ ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)
XFree(image);
}