--- sourceforge.net/trunk/rdesktop/parallel.c 2004/03/05 06:48:08 631 +++ sourceforge.net/trunk/rdesktop/parallel.c 2005/03/15 11:25:50 865 @@ -8,26 +8,16 @@ #include #include #include -#include #include +#if defined(__linux__) +#include +#endif + extern int errno; extern RDPDR_DEVICE g_rdpdr_device[]; -PARALLEL_DEVICE * -get_parallel_data(HANDLE handle) -{ - int index; - - for (index = 0; index < RDPDR_MAX_DEVICES; index++) - { - if (handle == g_rdpdr_device[index].handle) - return (PARALLEL_DEVICE *) g_rdpdr_device[index].pdevice_data; - } - return NULL; -} - /* Enumeration of devices from rdesktop.c */ /* returns numer of units found and initialized. */ @@ -42,7 +32,7 @@ char *pos2; int count = 0; - // skip the first colon + /* skip the first colon */ optarg++; while ((pos = next_arg(optarg, ',')) && *id < RDPDR_MAX_DEVICES) { @@ -57,7 +47,7 @@ strcpy(g_rdpdr_device[*id].local_path, pos2); printf("PARALLEL %s to %s\n", optarg, pos2); - // set device type + /* set device type */ g_rdpdr_device[*id].device_type = DEVICE_TYPE_PARALLEL; g_rdpdr_device[*id].pdevice_data = (void *) ppar_info; g_rdpdr_device[*id].handle = 0; @@ -71,7 +61,7 @@ static NTSTATUS parallel_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposition, - uint32 flags, char *filename, HANDLE * handle) + uint32 flags, char *filename, NTHANDLE * handle) { int parallel_fd; @@ -86,7 +76,10 @@ if (fcntl(parallel_fd, F_SETFL, O_NONBLOCK) == -1) perror("fcntl"); +#if defined(LPABORT) + /* Retry on errors */ ioctl(parallel_fd, LPABORT, (int) 1); +#endif g_rdpdr_device[device_id].handle = parallel_fd; @@ -96,7 +89,7 @@ } static NTSTATUS -parallel_close(HANDLE handle) +parallel_close(NTHANDLE handle) { int i = get_device_index(handle); if (i >= 0) @@ -105,22 +98,24 @@ return STATUS_SUCCESS; } -NTSTATUS -parallel_read(HANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) +static NTSTATUS +parallel_read(NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) { *result = read(handle, data, length); return STATUS_SUCCESS; } static NTSTATUS -parallel_write(HANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) +parallel_write(NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) { int rc = STATUS_SUCCESS; int n = write(handle, data, length); if (n < 0) { +#if defined(LPGETSTATUS) int status; +#endif *result = 0; switch (errno) @@ -134,18 +129,20 @@ default: rc = STATUS_DEVICE_POWERED_OFF; } +#if defined(LPGETSTATUS) if (ioctl(handle, LPGETSTATUS, &status) == 0) { /* coming soon: take care for the printer status */ printf("parallel_write: status = %d, errno = %d\n", status, errno); } +#endif } *result = n; return rc; } static NTSTATUS -parallel_device_control(HANDLE handle, uint32 request, STREAM in, STREAM out) +parallel_device_control(NTHANDLE handle, uint32 request, STREAM in, STREAM out) { if ((request >> 16) != FILE_DEVICE_PARALLEL) return STATUS_INVALID_PARAMETER;