1 |
#include <unistd.h> |
#include <unistd.h> |
2 |
#include <sys/types.h> |
#include <sys/types.h> |
3 |
|
#include <sys/time.h> |
4 |
#include <time.h> |
#include <time.h> |
5 |
#include "rdesktop.h" |
#include "rdesktop.h" |
6 |
|
|
82 |
/* Add a new io request to the table containing pending io requests so it won't block rdesktop */ |
/* Add a new io request to the table containing pending io requests so it won't block rdesktop */ |
83 |
BOOL |
BOOL |
84 |
add_async_iorequest(uint32 device, uint32 file, uint32 id, uint32 major, uint32 length, |
add_async_iorequest(uint32 device, uint32 file, uint32 id, uint32 major, uint32 length, |
85 |
DEVICE_FNS * fns, long total_timeout, long interval_timeout, uint8 * buffer) |
DEVICE_FNS * fns, uint32 total_timeout, uint32 interval_timeout, uint8 * buffer) |
86 |
{ |
{ |
87 |
struct async_iorequest *iorq; |
struct async_iorequest *iorq; |
88 |
|
|
89 |
if (g_iorequest == NULL) |
if (g_iorequest == NULL) |
90 |
{ |
{ |
91 |
g_iorequest = (struct async_iorequest *) xmalloc(sizeof(struct async_iorequest)); |
g_iorequest = (struct async_iorequest *) xmalloc(sizeof(struct async_iorequest)); |
92 |
|
if (!g_iorequest) |
93 |
|
return False; |
94 |
g_iorequest->fd = 0; |
g_iorequest->fd = 0; |
95 |
g_iorequest->next = NULL; |
g_iorequest->next = NULL; |
96 |
} |
} |
104 |
{ |
{ |
105 |
iorq->next = |
iorq->next = |
106 |
(struct async_iorequest *) xmalloc(sizeof(struct async_iorequest)); |
(struct async_iorequest *) xmalloc(sizeof(struct async_iorequest)); |
107 |
|
if (!iorq->next) |
108 |
|
return False; |
109 |
iorq->next->fd = 0; |
iorq->next->fd = 0; |
110 |
iorq->next->next = NULL; |
iorq->next->next = NULL; |
111 |
} |
} |
392 |
if (rw_blocking) // Complete read immediately |
if (rw_blocking) // Complete read immediately |
393 |
{ |
{ |
394 |
buffer = (uint8 *) xrealloc((void *) buffer, length); |
buffer = (uint8 *) xrealloc((void *) buffer, length); |
395 |
|
if (!buffer) |
396 |
|
{ |
397 |
|
status = STATUS_CANCELLED; |
398 |
|
break; |
399 |
|
} |
400 |
status = fns->read(file, buffer, length, offset, &result); |
status = fns->read(file, buffer, length, offset, &result); |
401 |
buffer_len = result; |
buffer_len = result; |
402 |
break; |
break; |
404 |
|
|
405 |
// Add request to table |
// Add request to table |
406 |
pst_buf = (uint8 *) xmalloc(length); |
pst_buf = (uint8 *) xmalloc(length); |
407 |
|
if (!pst_buf) |
408 |
|
{ |
409 |
|
status = STATUS_CANCELLED; |
410 |
|
break; |
411 |
|
} |
412 |
serial_get_timeout(file, length, &total_timeout, &interval_timeout); |
serial_get_timeout(file, length, &total_timeout, &interval_timeout); |
413 |
if (add_async_iorequest |
if (add_async_iorequest |
414 |
(device, file, id, major, length, fns, total_timeout, interval_timeout, |
(device, file, id, major, length, fns, total_timeout, interval_timeout, |
444 |
|
|
445 |
// Add to table |
// Add to table |
446 |
pst_buf = (uint8 *) xmalloc(length); |
pst_buf = (uint8 *) xmalloc(length); |
447 |
|
if (!pst_buf) |
448 |
|
{ |
449 |
|
status = STATUS_CANCELLED; |
450 |
|
break; |
451 |
|
} |
452 |
|
|
453 |
in_uint8a(s, pst_buf, length); |
in_uint8a(s, pst_buf, length); |
454 |
|
|
455 |
if (add_async_iorequest |
if (add_async_iorequest |
573 |
in_uint8s(s, 0x14); |
in_uint8s(s, 0x14); |
574 |
|
|
575 |
buffer = (uint8 *) xrealloc((void *) buffer, bytes_out + 0x14); |
buffer = (uint8 *) xrealloc((void *) buffer, bytes_out + 0x14); |
576 |
|
if (!buffer) |
577 |
|
{ |
578 |
|
status = STATUS_CANCELLED; |
579 |
|
break; |
580 |
|
} |
581 |
|
|
582 |
out.data = out.p = buffer; |
out.data = out.p = buffer; |
583 |
out.size = sizeof(buffer); |
out.size = sizeof(buffer); |
584 |
status = fns->device_control(file, request, s, &out); |
status = fns->device_control(file, request, s, &out); |
594 |
{ |
{ |
595 |
rdpdr_send_completion(device, id, status, result, buffer, buffer_len); |
rdpdr_send_completion(device, id, status, result, buffer, buffer_len); |
596 |
} |
} |
597 |
xfree(buffer); |
if (buffer) |
598 |
|
xfree(buffer); |
599 |
|
buffer = NULL; |
600 |
} |
} |
601 |
|
|
602 |
void |
void |
715 |
void |
void |
716 |
rdpdr_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv, BOOL * timeout) |
rdpdr_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv, BOOL * timeout) |
717 |
{ |
{ |
718 |
long select_timeout = 0; // Timeout value to be used for select() (in millisecons). |
uint32 select_timeout = 0; // Timeout value to be used for select() (in millisecons). |
719 |
struct async_iorequest *iorq; |
struct async_iorequest *iorq; |
720 |
|
|
721 |
iorq = g_iorequest; |
iorq = g_iorequest; |
864 |
status = STATUS_SUCCESS; |
status = STATUS_SUCCESS; |
865 |
rdpdr_send_completion(iorq->device, |
rdpdr_send_completion(iorq->device, |
866 |
iorq->id, status, |
iorq->id, status, |
867 |
iorq->partial_len, (uint8*)"", |
iorq->partial_len, |
868 |
1); |
(uint8 *) "", 1); |
869 |
|
|
870 |
xfree(iorq->buffer); |
xfree(iorq->buffer); |
871 |
iorq->fd = 0; |
iorq->fd = 0; |
909 |
if ((iorq->fd == fd) && (major == 0 || iorq->major == major)) |
if ((iorq->fd == fd) && (major == 0 || iorq->major == major)) |
910 |
{ |
{ |
911 |
result = 0; |
result = 0; |
912 |
rdpdr_send_completion(iorq->device, iorq->id, status, result, (uint8*)"", 1); |
rdpdr_send_completion(iorq->device, iorq->id, status, result, (uint8 *) "", |
913 |
|
1); |
914 |
xfree(iorq->buffer); |
xfree(iorq->buffer); |
915 |
iorq->fd = 0; |
iorq->fd = 0; |
916 |
if (prev != NULL) |
if (prev != NULL) |