Ran indent-all.sh

git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@579 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
Peter Åstrand 2004-01-23 08:35:52 +00:00
parent 113a0b179a
commit a9a863db41
10 changed files with 308 additions and 220 deletions

View File

@ -12,7 +12,8 @@
extern RDPDR_DEVICE g_rdpdr_device[]; extern RDPDR_DEVICE g_rdpdr_device[];
PARALLEL_DEVICE * get_parallel_data(HANDLE handle) PARALLEL_DEVICE *
get_parallel_data(HANDLE handle)
{ {
int index; int index;

View File

@ -4,7 +4,8 @@
extern RDPDR_DEVICE g_rdpdr_device[]; extern RDPDR_DEVICE g_rdpdr_device[];
PRINTER * get_printer_data(HANDLE handle) PRINTER *
get_printer_data(HANDLE handle)
{ {
int index; int index;

View File

@ -83,7 +83,8 @@ printercache_load_blob(char *printer_name, uint8 ** data)
if (home == NULL) if (home == NULL)
return 0; return 0;
path = (char *) xmalloc(strlen(home) + sizeof("/.rdesktop/rdpdr/") + strlen(printer_name) + sizeof("/AutoPrinterCacheData")); path = (char *) xmalloc(strlen(home) + sizeof("/.rdesktop/rdpdr/") + strlen(printer_name) +
sizeof("/AutoPrinterCacheData"));
sprintf(path, "%s/.rdesktop/rdpdr/%s/AutoPrinterCacheData", home, printer_name); sprintf(path, "%s/.rdesktop/rdpdr/%s/AutoPrinterCacheData", home, printer_name);
fd = open(path, O_RDONLY); fd = open(path, O_RDONLY);
@ -116,7 +117,8 @@ printercache_save_blob(char *printer_name, uint8 * data, uint32 length)
if (!printercache_mkdir(home, printer_name)) if (!printercache_mkdir(home, printer_name))
return; return;
path = (char *) xmalloc(strlen(home) + sizeof("/.rdesktop/rdpdr/") + strlen(printer_name) + sizeof("/AutoPrinterCacheData")); path = (char *) xmalloc(strlen(home) + sizeof("/.rdesktop/rdpdr/") + strlen(printer_name) +
sizeof("/AutoPrinterCacheData"));
sprintf(path, "%s/.rdesktop/rdpdr/%s/AutoPrinterCacheData", home, printer_name); sprintf(path, "%s/.rdesktop/rdpdr/%s/AutoPrinterCacheData", home, printer_name);
fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0600); fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0600);

View File

@ -118,14 +118,18 @@ usage(char *program)
fprintf(stderr, " -N: enable numlock syncronization\n"); fprintf(stderr, " -N: enable numlock syncronization\n");
fprintf(stderr, " -a: connection colour depth\n"); fprintf(stderr, " -a: connection colour depth\n");
fprintf(stderr, " -r: enable specified device redirection (this flag can be repeated)\n"); fprintf(stderr, " -r: enable specified device redirection (this flag can be repeated)\n");
fprintf(stderr, " '-r comport:COM1=/dev/ttyS0': enable serial redirection of /dev/ttyS0 to COM1\n"); fprintf(stderr,
" '-r comport:COM1=/dev/ttyS0': enable serial redirection of /dev/ttyS0 to COM1\n");
fprintf(stderr, " or COM1=/dev/ttyS0,COM2=/dev/ttyS1\n"); fprintf(stderr, " or COM1=/dev/ttyS0,COM2=/dev/ttyS1\n");
fprintf(stderr, " '-r disk:A=/mnt/floppy': enable redirection of /mnt/floppy to A:\n"); fprintf(stderr,
" '-r disk:A=/mnt/floppy': enable redirection of /mnt/floppy to A:\n");
fprintf(stderr, " or A=/mnt/floppy,D=/mnt/cdrom'\n"); fprintf(stderr, " or A=/mnt/floppy,D=/mnt/cdrom'\n");
fprintf(stderr, " '-r lptport:LPT1=/dev/lp0': enable parallel redirection of /dev/lp0 to LPT1\n"); fprintf(stderr,
" '-r lptport:LPT1=/dev/lp0': enable parallel redirection of /dev/lp0 to LPT1\n");
fprintf(stderr, " or LPT1=/dev/lp0,LPT2=/dev/lp1\n"); fprintf(stderr, " or LPT1=/dev/lp0,LPT2=/dev/lp1\n");
fprintf(stderr, " '-r printer:mydeskjet': enable printer redirection\n"); fprintf(stderr, " '-r printer:mydeskjet': enable printer redirection\n");
fprintf(stderr, " or mydeskjet:\"HP Laserjet IIIP\" to enter server driver as well\n"); fprintf(stderr,
" or mydeskjet:\"HP Laserjet IIIP\" to enter server driver as well\n");
fprintf(stderr, " '-r sound': enable sound redirection\n"); fprintf(stderr, " '-r sound': enable sound redirection\n");
fprintf(stderr, " -0: attach to console\n"); fprintf(stderr, " -0: attach to console\n");
fprintf(stderr, " -4: use RDP version 4\n"); fprintf(stderr, " -4: use RDP version 4\n");
@ -797,7 +801,8 @@ next_arg(char *src, char needle)
void void
toupper_str(char *p) toupper_str(char *p)
{ {
while( *p ){ while (*p)
{
if ((*p >= 'a') && (*p <= 'z')) if ((*p >= 'a') && (*p <= 'z'))
*p = toupper((int) *p); *p = toupper((int) *p);
p++; p++;

View File

@ -661,7 +661,10 @@ rdpdr_init()
{ {
if (g_num_devices > 0) if (g_num_devices > 0)
{ {
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); return (rdpdr_channel != NULL);

185
serial.c
View File

@ -64,8 +64,7 @@ uint32 queue_in_size, queue_out_size;
uint32 wait_mask; uint32 wait_mask;
uint8 stop_bits, parity, word_length; uint8 stop_bits, parity, word_length;
SERIAL_DEVICE SERIAL_DEVICE * get_serial_info(HANDLE handle)
*get_serial_info(HANDLE handle)
{ {
int index; int index;
@ -92,64 +91,107 @@ get_termios(SERIAL_DEVICE *pser_inf, HANDLE serial_fd)
switch (speed) switch (speed)
{ {
#ifdef B75 #ifdef B75
case B75: pser_inf->baud_rate = 75; break; case B75:
pser_inf->baud_rate = 75;
break;
#endif #endif
#ifdef B110 #ifdef B110
case B110: pser_inf->baud_rate = 110; break; case B110:
pser_inf->baud_rate = 110;
break;
#endif #endif
#ifdef B134 #ifdef B134
case B134: pser_inf->baud_rate = 134; break; case B134:
pser_inf->baud_rate = 134;
break;
#endif #endif
#ifdef B150 #ifdef B150
case B150: pser_inf->baud_rate = 150; break; case B150:
pser_inf->baud_rate = 150;
break;
#endif #endif
#ifdef B300 #ifdef B300
case B300: pser_inf->baud_rate = 300; break; case B300:
pser_inf->baud_rate = 300;
break;
#endif #endif
#ifdef B600 #ifdef B600
case B600: pser_inf->baud_rate = 600; break; case B600:
pser_inf->baud_rate = 600;
break;
#endif #endif
#ifdef B1200 #ifdef B1200
case B1200: pser_inf->baud_rate = 1200; break; case B1200:
pser_inf->baud_rate = 1200;
break;
#endif #endif
#ifdef B1800 #ifdef B1800
case B1800: pser_inf->baud_rate = 1800; break; case B1800:
pser_inf->baud_rate = 1800;
break;
#endif #endif
#ifdef B2400 #ifdef B2400
case B2400: pser_inf->baud_rate = 2400; break; case B2400:
pser_inf->baud_rate = 2400;
break;
#endif #endif
#ifdef B4800 #ifdef B4800
case B4800: pser_inf->baud_rate = 4800; break; case B4800:
pser_inf->baud_rate = 4800;
break;
#endif #endif
#ifdef B9600 #ifdef B9600
case B9600: pser_inf->baud_rate = 9600; break; case B9600:
pser_inf->baud_rate = 9600;
break;
#endif #endif
#ifdef B19200 #ifdef B19200
case B19200: pser_inf->baud_rate = 19200; break; case B19200:
pser_inf->baud_rate = 19200;
break;
#endif #endif
#ifdef B38400 #ifdef B38400
case B38400: pser_inf->baud_rate = 38400; break; case B38400:
pser_inf->baud_rate = 38400;
break;
#endif #endif
#ifdef B57600 #ifdef B57600
case B57600: pser_inf->baud_rate = 57600; break; case B57600:
pser_inf->baud_rate = 57600;
break;
#endif #endif
#ifdef B115200 #ifdef B115200
case B115200: pser_inf->baud_rate = 115200; break; case B115200:
pser_inf->baud_rate = 115200;
break;
#endif #endif
default: pser_inf->baud_rate = 0; break; default:
pser_inf->baud_rate = 0;
break;
} }
speed = cfgetospeed(ptermios); speed = cfgetospeed(ptermios);
pser_inf->dtr = (speed == B0) ? 0 : 1; pser_inf->dtr = (speed == B0) ? 0 : 1;
pser_inf->stop_bits = (ptermios->c_cflag & CSTOPB) ? STOP_BITS_2 : STOP_BITS_1; pser_inf->stop_bits = (ptermios->c_cflag & CSTOPB) ? STOP_BITS_2 : STOP_BITS_1;
pser_inf->parity = (ptermios->c_cflag & PARENB) ? ((ptermios->c_cflag & PARODD) ? ODD_PARITY : EVEN_PARITY) : NO_PARITY; pser_inf->parity =
(ptermios->
c_cflag & PARENB) ? ((ptermios->
c_cflag & PARODD) ? ODD_PARITY : EVEN_PARITY) : NO_PARITY;
switch (ptermios->c_cflag & CSIZE) switch (ptermios->c_cflag & CSIZE)
{ {
case CS5: pser_inf->word_length = 5; break; case CS5:
case CS6: pser_inf->word_length = 6; break; pser_inf->word_length = 5;
case CS7: pser_inf->word_length = 7; break; break;
default: pser_inf->word_length = 8; break; case CS6:
pser_inf->word_length = 6;
break;
case CS7:
pser_inf->word_length = 7;
break;
default:
pser_inf->word_length = 8;
break;
} }
return True; return True;
@ -163,51 +205,83 @@ set_termios(void)
switch (baud_rate) switch (baud_rate)
{ {
#ifdef B75 #ifdef B75
case 75: speed = B75;break; case 75:
speed = B75;
break;
#endif #endif
#ifdef B110 #ifdef B110
case 110: speed = B110;break; case 110:
speed = B110;
break;
#endif #endif
#ifdef B134 #ifdef B134
case 134: speed = B134;break; case 134:
speed = B134;
break;
#endif #endif
#ifdef B150 #ifdef B150
case 150: speed = B150;break; case 150:
speed = B150;
break;
#endif #endif
#ifdef B300 #ifdef B300
case 300: speed = B300;break; case 300:
speed = B300;
break;
#endif #endif
#ifdef B600 #ifdef B600
case 600: speed = B600;break; case 600:
speed = B600;
break;
#endif #endif
#ifdef B1200 #ifdef B1200
case 1200: speed = B1200;break; case 1200:
speed = B1200;
break;
#endif #endif
#ifdef B1800 #ifdef B1800
case 1800: speed = B1800;break; case 1800:
speed = B1800;
break;
#endif #endif
#ifdef B2400 #ifdef B2400
case 2400: speed = B2400;break; case 2400:
speed = B2400;
break;
#endif #endif
#ifdef B4800 #ifdef B4800
case 4800: speed = B4800;break; case 4800:
speed = B4800;
break;
#endif #endif
#ifdef B9600 #ifdef B9600
case 9600: speed = B9600;break; case 9600:
speed = B9600;
break;
#endif #endif
#ifdef B19200 #ifdef B19200
case 19200: speed = B19200;break; case 19200:
speed = B19200;
break;
#endif #endif
#ifdef B38400 #ifdef B38400
case 38400: speed = B38400;break; case 38400:
speed = B38400;
break;
#endif #endif
#ifdef B57600 #ifdef B57600
case 57600: speed = B57600;break; case 57600:
speed = B57600;
break;
#endif #endif
#ifdef B115200 #ifdef B115200
case 115200: speed = B115200;break; case 115200:
speed = B115200;
break;
#endif #endif
default: speed = B0;break; default:
speed = B0;
break;
} }
/* on systems with separate ispeed and ospeed, we can remember the speed /* on systems with separate ispeed and ospeed, we can remember the speed
@ -280,7 +354,8 @@ serial_enum_devices(int *id, char* optarg)
g_rdpdr_device[*id].local_path = xmalloc(strlen(pos2) + 1); g_rdpdr_device[*id].local_path = xmalloc(strlen(pos2) + 1);
strcpy(g_rdpdr_device[*id].local_path, pos2); strcpy(g_rdpdr_device[*id].local_path, pos2);
printf("SERIAL %s to %s\n", g_rdpdr_device[*id].name, g_rdpdr_device[*id].local_path); printf("SERIAL %s to %s\n", g_rdpdr_device[*id].name,
g_rdpdr_device[*id].local_path);
// set device type // set device type
g_rdpdr_device[*id].device_type = DEVICE_TYPE_SERIAL; g_rdpdr_device[*id].device_type = DEVICE_TYPE_SERIAL;
g_rdpdr_device[*id].pdevice_data = (void *) pser_inf; g_rdpdr_device[*id].pdevice_data = (void *) pser_inf;
@ -293,7 +368,8 @@ serial_enum_devices(int *id, char* optarg)
} }
NTSTATUS NTSTATUS
serial_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposition, uint32 flags_and_attributes, char *filename, HANDLE *handle) serial_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposition,
uint32 flags_and_attributes, char *filename, HANDLE * handle)
{ {
HANDLE serial_fd; HANDLE serial_fd;
SERIAL_DEVICE *pser_inf; SERIAL_DEVICE *pser_inf;
@ -313,9 +389,7 @@ serial_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposi
g_rdpdr_device[device_id].handle = serial_fd; g_rdpdr_device[device_id].handle = serial_fd;
/* some sane information */ /* some sane information */
printf("INFO: SERIAL %s to %s\nINFO: speed %u baud, stop bits %u, parity %u, word length %u bits, dtr %u\n", printf("INFO: SERIAL %s to %s\nINFO: speed %u baud, stop bits %u, parity %u, word length %u bits, dtr %u\n", g_rdpdr_device[device_id].name, g_rdpdr_device[device_id].local_path, pser_inf->baud_rate, pser_inf->stop_bits, pser_inf->parity, pser_inf->word_length, pser_inf->dtr);
g_rdpdr_device[device_id].name, g_rdpdr_device[device_id].local_path,
pser_inf->baud_rate, pser_inf->stop_bits, pser_inf->parity, pser_inf->word_length, pser_inf->dtr );
printf("INFO: use stty to change settings\n"); printf("INFO: use stty to change settings\n");
//tcgetattr(serial_fd, pser_inf->ptermios); //tcgetattr(serial_fd, pser_inf->ptermios);
@ -346,7 +420,9 @@ serial_read(HANDLE handle, uint8 *data, uint32 length, uint32 offset, uint32 *re
// with requested read size // with requested read size
if (pser_inf->read_total_timeout_multiplier | pser_inf->read_total_timeout_constant) if (pser_inf->read_total_timeout_multiplier | pser_inf->read_total_timeout_constant)
{ {
timeout = (pser_inf->read_total_timeout_multiplier * length + pser_inf->read_total_timeout_constant + 99) / 100; timeout =
(pser_inf->read_total_timeout_multiplier * length +
pser_inf->read_total_timeout_constant + 99) / 100;
} }
else if (pser_inf->read_interval_timeout) else if (pser_inf->read_interval_timeout)
{ {
@ -471,11 +547,16 @@ serial_device_control(HANDLE handle, uint32 request, STREAM in, STREAM out)
printf("SERIAL_PURGE\n"); printf("SERIAL_PURGE\n");
in_uint32(in, purge_mask); in_uint32(in, purge_mask);
if (purge_mask & 0x04) flush_mask |= TCOFLUSH; if (purge_mask & 0x04)
if (purge_mask & 0x08) flush_mask |= TCIFLUSH; flush_mask |= TCOFLUSH;
if (flush_mask != 0) tcflush(handle, flush_mask); if (purge_mask & 0x08)
if (purge_mask & 0x01) rdpdr_abort_io(handle, 4, STATUS_CANCELLED); flush_mask |= TCIFLUSH;
if (purge_mask & 0x02) rdpdr_abort_io(handle, 3, STATUS_CANCELLED); if (flush_mask != 0)
tcflush(handle, flush_mask);
if (purge_mask & 0x01)
rdpdr_abort_io(handle, 4, STATUS_CANCELLED);
if (purge_mask & 0x02)
rdpdr_abort_io(handle, 3, STATUS_CANCELLED);
break; break;
case SERIAL_RESET_DEVICE: case SERIAL_RESET_DEVICE:
@ -512,7 +593,9 @@ serial_get_timeout(uint32 handle, uint32 length, uint32 *timeout, uint32 *itv_ti
pser_inf = (SERIAL_DEVICE *) g_rdpdr_device[index].pdevice_data; pser_inf = (SERIAL_DEVICE *) g_rdpdr_device[index].pdevice_data;
*timeout = pser_inf->read_total_timeout_multiplier * length + pser_inf->read_total_timeout_constant; *timeout =
pser_inf->read_total_timeout_multiplier * length +
pser_inf->read_total_timeout_constant;
*itv_timeout = pser_inf->read_interval_timeout; *itv_timeout = pser_inf->read_interval_timeout;
return True; return True;
} }

33
types.h
View File

@ -140,10 +140,14 @@ typedef uint32 HANDLE;
typedef struct _DEVICE_FNS typedef struct _DEVICE_FNS
{ {
NTSTATUS (*create)(uint32 device, uint32 desired_access, uint32 share_mode, uint32 create_disposition, uint32 flags_and_attributes, char *filename, HANDLE *handle); NTSTATUS(*create) (uint32 device, uint32 desired_access, uint32 share_mode,
uint32 create_disposition, uint32 flags_and_attributes, char *filename,
HANDLE * handle);
NTSTATUS(*close) (HANDLE handle); NTSTATUS(*close) (HANDLE handle);
NTSTATUS (*read)(HANDLE handle, uint8 *data, uint32 length, uint32 offset, uint32 *result); NTSTATUS(*read) (HANDLE handle, uint8 * data, uint32 length, uint32 offset,
NTSTATUS (*write)(HANDLE handle, uint8 *data, uint32 length, uint32 offset, uint32 *result); uint32 * result);
NTSTATUS(*write) (HANDLE handle, uint8 * data, uint32 length, uint32 offset,
uint32 * result);
NTSTATUS(*device_control) (HANDLE handle, uint32 request, STREAM in, STREAM out); NTSTATUS(*device_control) (HANDLE handle, uint32 request, STREAM in, STREAM out);
} }
DEVICE_FNS; DEVICE_FNS;
@ -169,21 +173,15 @@ typedef struct rdpdr_serial_device_info
read_interval_timeout, read_interval_timeout,
read_total_timeout_multiplier, read_total_timeout_multiplier,
read_total_timeout_constant, read_total_timeout_constant,
write_total_timeout_multiplier, write_total_timeout_multiplier, write_total_timeout_constant, posix_wait_mask;
write_total_timeout_constant, uint8 stop_bits, parity, word_length;
posix_wait_mask; struct termios *ptermios, *pold_termios;
uint8 stop_bits,
parity,
word_length;
struct termios *ptermios,
*pold_termios;
} }
SERIAL_DEVICE; SERIAL_DEVICE;
typedef struct rdpdr_parallel_device_info typedef struct rdpdr_parallel_device_info
{ {
char *driver, char *driver, *printer;
*printer;
uint32 queue_in_size, uint32 queue_in_size,
queue_out_size, queue_out_size,
wait_mask, wait_mask,
@ -191,9 +189,7 @@ typedef struct rdpdr_parallel_device_info
read_total_timeout_multiplier, read_total_timeout_multiplier,
read_total_timeout_constant, read_total_timeout_constant,
write_total_timeout_multiplier, write_total_timeout_multiplier,
write_total_timeout_constant, write_total_timeout_constant, posix_wait_mask, bloblen;
posix_wait_mask,
bloblen;
uint8 *blob; uint8 *blob;
} }
PARALLEL_DEVICE; PARALLEL_DEVICE;
@ -201,12 +197,9 @@ PARALLEL_DEVICE;
typedef struct rdpdr_printer_info typedef struct rdpdr_printer_info
{ {
FILE *printer_fp; FILE *printer_fp;
char *driver, char *driver, *printer;
*printer;
uint32 bloblen; uint32 bloblen;
uint8 *blob; uint8 *blob;
BOOL default_printer; BOOL default_printer;
} }
PRINTER; PRINTER;

8
xwin.c
View File

@ -783,7 +783,9 @@ ui_init(void)
if (!g_owncolmap) if (!g_owncolmap)
{ {
g_xcolmap = XCreateColormap(g_display,RootWindowOfScreen(g_screen),g_visual,AllocNone); g_xcolmap =
XCreateColormap(g_display, RootWindowOfScreen(g_screen), g_visual,
AllocNone);
if (g_depth <= 8) if (g_depth <= 8)
warning("Screen depth is 8 bits or lower: you may want to use -C for a private colourmap\n"); warning("Screen depth is 8 bits or lower: you may want to use -C for a private colourmap\n");
} }
@ -894,9 +896,7 @@ ui_create_window(void)
if ((g_ownbackstore) && (g_backstore == NULL)) if ((g_ownbackstore) && (g_backstore == NULL))
{ {
g_backstore = g_backstore = XCreatePixmap(g_display, g_wnd, g_width, g_height, g_depth);
XCreatePixmap(g_display, g_wnd, g_width, g_height,
g_depth);
/* clear to prevent rubbish being exposed at startup */ /* clear to prevent rubbish being exposed at startup */
XSetForeground(g_display, g_gc, BlackPixelOfScreen(g_screen)); XSetForeground(g_display, g_gc, BlackPixelOfScreen(g_screen));