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

@ -69,7 +69,7 @@ void error(char *format, ...);
void warning(char *format, ...); void warning(char *format, ...);
void unimpl(char *format, ...); void unimpl(char *format, ...);
void hexdump(unsigned char *p, unsigned int len); void hexdump(unsigned char *p, unsigned int len);
void toupper_str(char* p); void toupper_str(char *p);
char *ltoa(long N, int base); char *ltoa(long N, int base);
int load_licence(unsigned char **data); int load_licence(unsigned char **data);
void save_licence(unsigned char *data, int length); void save_licence(unsigned char *data, int length);

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");
@ -758,24 +762,24 @@ next_arg(char *src, char needle)
p = src; p = src;
/* skip escaped needles */ /* skip escaped needles */
while( (nextval = strchr(p, needle) ) ) while ((nextval = strchr(p, needle)))
{ {
mvp = nextval - 1; mvp = nextval - 1;
/* found backslashed needle */ /* found backslashed needle */
if( *mvp == '\\' && (mvp > src) ) if (*mvp == '\\' && (mvp > src))
{ {
/* move string one to the left */ /* move string one to the left */
while( *(mvp+1) != (char)0x00 ) while (*(mvp + 1) != (char) 0x00)
{ {
*mvp = *(mvp+1); *mvp = *(mvp + 1);
*mvp++; *mvp++;
} }
*mvp = (char)0x00; *mvp = (char) 0x00;
p = nextval; p = nextval;
} }
else else
{ {
p = nextval +1; p = nextval + 1;
break; break;
} }
@ -795,10 +799,11 @@ 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);

View File

@ -628,16 +628,16 @@ sec_parse_crypt_info(STREAM s, uint32 * rc4_key_size,
uint32 certcount; uint32 certcount;
DEBUG_RDP5(("We're going for the RDP5-style encryption\n")); DEBUG_RDP5(("We're going for the RDP5-style encryption\n"));
in_uint32_le(s, certcount); /* Number of certificates */ in_uint32_le(s, certcount); /* Number of certificates */
if(certcount < 2) if (certcount < 2)
{ {
error("Server didn't send enough X509 certificates\n"); error("Server didn't send enough X509 certificates\n");
return False; return False;
} }
for(; certcount > 2; certcount--) for (; certcount > 2; certcount--)
{ /* ignore all the certificates between the root and the signing CA */ { /* ignore all the certificates between the root and the signing CA */
uint32 ignorelen; uint32 ignorelen;
X509 *ignorecert; X509 *ignorecert;
@ -647,13 +647,13 @@ sec_parse_crypt_info(STREAM s, uint32 * rc4_key_size,
DEBUG_RDP5(("Ignored Certificate length is %d\n", ignorelen)); DEBUG_RDP5(("Ignored Certificate length is %d\n", ignorelen));
ignorecert = d2i_X509(NULL, &(s->p), ignorelen); ignorecert = d2i_X509(NULL, &(s->p), ignorelen);
if(ignorecert == NULL) if (ignorecert == NULL)
{ /* XXX: error out? */ { /* XXX: error out? */
DEBUG_RDP5(("got a bad cert: this will probably screw up the rest of the communication\n")); DEBUG_RDP5(("got a bad cert: this will probably screw up the rest of the communication\n"));
} }
#ifdef WITH_DEBUG_RDP5 #ifdef WITH_DEBUG_RDP5
DEBUG_RDP5(("cert #%d (ignored):\n",certcount)); DEBUG_RDP5(("cert #%d (ignored):\n", certcount));
X509_print_fp(stdout, ignorecert); X509_print_fp(stdout, ignorecert);
#endif #endif
} }

365
serial.c
View File

@ -53,7 +53,7 @@
#define ODD_PARITY 1 #define ODD_PARITY 1
#define EVEN_PARITY 2 #define EVEN_PARITY 2
extern RDPDR_DEVICE g_rdpdr_device[]; extern RDPDR_DEVICE g_rdpdr_device[];
int serial_fd; int serial_fd;
struct termios termios; struct termios termios;
@ -64,95 +64,137 @@ 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;
for (index = 0; index < RDPDR_MAX_DEVICES; index++) for (index = 0; index < RDPDR_MAX_DEVICES; index++)
{ {
if (handle == g_rdpdr_device[index].handle) if (handle == g_rdpdr_device[index].handle)
return (SERIAL_DEVICE *) g_rdpdr_device[index].pdevice_data; return (SERIAL_DEVICE *) g_rdpdr_device[index].pdevice_data;
} }
return NULL; return NULL;
} }
BOOL BOOL
get_termios(SERIAL_DEVICE *pser_inf, HANDLE serial_fd) get_termios(SERIAL_DEVICE * pser_inf, HANDLE serial_fd)
{ {
speed_t speed; speed_t speed;
struct termios *ptermios; struct termios *ptermios;
ptermios = pser_inf->ptermios; ptermios = pser_inf->ptermios;
if (tcgetattr(serial_fd, ptermios) == -1) if (tcgetattr(serial_fd, ptermios) == -1)
return False; return False;
speed = cfgetispeed(ptermios); speed = cfgetispeed(ptermios);
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 =
switch (ptermios->c_cflag & CSIZE) (ptermios->
{ c_cflag & PARENB) ? ((ptermios->
case CS5: pser_inf->word_length = 5; break; c_cflag & PARODD) ? ODD_PARITY : EVEN_PARITY) : NO_PARITY;
case CS6: pser_inf->word_length = 6; break; switch (ptermios->c_cflag & CSIZE)
case CS7: pser_inf->word_length = 7; break; {
default: pser_inf->word_length = 8; break; case CS5:
} pser_inf->word_length = 5;
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;
} }
static void static void
@ -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
@ -256,9 +330,9 @@ set_termios(void)
/* when it arrives to this function. */ /* when it arrives to this function. */
/* :com1=/dev/ttyS0,com2=/dev/ttyS1 */ /* :com1=/dev/ttyS0,com2=/dev/ttyS1 */
int int
serial_enum_devices(int *id, char* optarg) serial_enum_devices(int *id, char *optarg)
{ {
SERIAL_DEVICE* pser_inf; SERIAL_DEVICE *pser_inf;
char *pos = optarg; char *pos = optarg;
char *pos2; char *pos2;
@ -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,35 +368,34 @@ 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;
struct termios *ptermios; struct termios *ptermios;
pser_inf = (SERIAL_DEVICE *) g_rdpdr_device[device_id].pdevice_data; pser_inf = (SERIAL_DEVICE *) g_rdpdr_device[device_id].pdevice_data;
ptermios = pser_inf->ptermios; ptermios = pser_inf->ptermios;
serial_fd = open(g_rdpdr_device[device_id].local_path, O_RDWR | O_NOCTTY); serial_fd = open(g_rdpdr_device[device_id].local_path, O_RDWR | O_NOCTTY);
if (serial_fd == -1) if (serial_fd == -1)
return STATUS_ACCESS_DENIED; return STATUS_ACCESS_DENIED;
if (!get_termios(pser_inf, serial_fd )) if (!get_termios(pser_inf, serial_fd))
return STATUS_ACCESS_DENIED; return STATUS_ACCESS_DENIED;
// Store handle for later use // Store handle for later use
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, printf("INFO: use stty to change settings\n");
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" );
//tcgetattr(serial_fd, pser_inf->ptermios); //tcgetattr(serial_fd, pser_inf->ptermios);
*handle = serial_fd; *handle = serial_fd;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
static NTSTATUS static NTSTATUS
@ -332,51 +406,53 @@ serial_close(HANDLE handle)
} }
NTSTATUS NTSTATUS
serial_read(HANDLE handle, uint8 *data, uint32 length, uint32 offset, uint32 *result) serial_read(HANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)
{ {
long timeout; long timeout;
SERIAL_DEVICE *pser_inf; SERIAL_DEVICE *pser_inf;
struct termios *ptermios; struct termios *ptermios;
timeout = 0; timeout = 0;
pser_inf = get_serial_info(handle); pser_inf = get_serial_info(handle);
ptermios = pser_inf->ptermios; ptermios = pser_inf->ptermios;
// Set timeouts kind of like the windows serial timeout parameters. Multiply timeout // Set timeouts kind of like the windows serial timeout parameters. Multiply timeout
// 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 +
else if (pser_inf->read_interval_timeout) pser_inf->read_total_timeout_constant + 99) / 100;
{ }
timeout = (pser_inf->read_interval_timeout * length + 99) / 100; else if (pser_inf->read_interval_timeout)
} {
timeout = (pser_inf->read_interval_timeout * length + 99) / 100;
}
// If a timeout is set, do a blocking read, which times out after some time. // If a timeout is set, do a blocking read, which times out after some time.
// It will make rdesktop less responsive, but it will improve serial performance, by not // It will make rdesktop less responsive, but it will improve serial performance, by not
// reading one character at a time. // reading one character at a time.
if (timeout == 0) if (timeout == 0)
{ {
ptermios->c_cc[VTIME] = 0; ptermios->c_cc[VTIME] = 0;
ptermios->c_cc[VMIN] = 0; ptermios->c_cc[VMIN] = 0;
} }
else else
{ {
ptermios->c_cc[VTIME] = timeout; ptermios->c_cc[VTIME] = timeout;
ptermios->c_cc[VMIN] = 1; ptermios->c_cc[VMIN] = 1;
} }
tcsetattr(handle, TCSANOW, ptermios); tcsetattr(handle, TCSANOW, ptermios);
*result = read(handle, data, length); *result = read(handle, data, length);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
NTSTATUS NTSTATUS
serial_write(HANDLE handle, uint8 *data, uint32 length, uint32 offset, uint32 *result) serial_write(HANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)
{ {
*result = write(handle, data, length); *result = write(handle, data, length);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
static NTSTATUS static NTSTATUS
@ -469,14 +545,19 @@ serial_device_control(HANDLE handle, uint32 request, STREAM in, STREAM out)
break; break;
case SERIAL_PURGE: case SERIAL_PURGE:
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)
break; 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;
case SERIAL_RESET_DEVICE: case SERIAL_RESET_DEVICE:
case SERIAL_SET_BREAK_OFF: case SERIAL_SET_BREAK_OFF:
@ -498,23 +579,25 @@ serial_device_control(HANDLE handle, uint32 request, STREAM in, STREAM out)
/* Read timeout for a given file descripter (device) when adding fd's to select() */ /* Read timeout for a given file descripter (device) when adding fd's to select() */
BOOL BOOL
serial_get_timeout(uint32 handle, uint32 length, uint32 *timeout, uint32 *itv_timeout) serial_get_timeout(uint32 handle, uint32 length, uint32 * timeout, uint32 * itv_timeout)
{ {
int index; int index;
SERIAL_DEVICE *pser_inf; SERIAL_DEVICE *pser_inf;
index = get_device_index(handle); index = get_device_index(handle);
if (g_rdpdr_device[index].device_type != DEVICE_TYPE_SERIAL) if (g_rdpdr_device[index].device_type != DEVICE_TYPE_SERIAL)
{ {
return False; return False;
} }
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 =
*itv_timeout = pser_inf->read_interval_timeout; pser_inf->read_total_timeout_multiplier * length +
return True; pser_inf->read_total_timeout_constant;
*itv_timeout = pser_inf->read_interval_timeout;
return True;
} }
DEVICE_FNS serial_fns = { DEVICE_FNS serial_fns = {

87
types.h
View File

@ -140,73 +140,66 @@ 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,
NTSTATUS (*close)(HANDLE handle); uint32 create_disposition, uint32 flags_and_attributes, char *filename,
NTSTATUS (*read)(HANDLE handle, uint8 *data, uint32 length, uint32 offset, uint32 *result); HANDLE * handle);
NTSTATUS (*write)(HANDLE handle, uint8 *data, uint32 length, uint32 offset, uint32 *result); NTSTATUS(*close) (HANDLE handle);
NTSTATUS (*device_control)(HANDLE handle, uint32 request, STREAM in, STREAM out); NTSTATUS(*read) (HANDLE handle, uint8 * data, uint32 length, uint32 offset,
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);
} }
DEVICE_FNS; DEVICE_FNS;
typedef struct rdpdr_device_info typedef struct rdpdr_device_info
{ {
uint32 device_type; uint32 device_type;
HANDLE handle; HANDLE handle;
char name[8]; char name[8];
char *local_path; char *local_path;
void *pdevice_data; void *pdevice_data;
} }
RDPDR_DEVICE; RDPDR_DEVICE;
typedef struct rdpdr_serial_device_info typedef struct rdpdr_serial_device_info
{ {
int dtr; int dtr;
uint32 baud_rate, uint32 baud_rate,
queue_in_size, queue_in_size,
queue_out_size, queue_out_size,
wait_mask, wait_mask,
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, 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, bloblen;
write_total_timeout_constant, uint8 *blob;
posix_wait_mask,
bloblen;
uint8 *blob;
} }
PARALLEL_DEVICE; 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;

10
xwin.c
View File

@ -731,7 +731,7 @@ ui_init(void)
TrueColorVisual = True; TrueColorVisual = True;
} }
if ((g_server_bpp == 8) && ((! TrueColorVisual) || (g_depth <= 8))) if ((g_server_bpp == 8) && ((!TrueColorVisual) || (g_depth <= 8)))
{ {
/* we use a colourmap, so the default visual should do */ /* we use a colourmap, so the default visual should do */
g_visual = DefaultVisualOfScreen(g_screen); g_visual = DefaultVisualOfScreen(g_screen);
@ -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));