--- sourceforge.net/trunk/rdesktop/parallel.c 2004/01/23 08:35:52 580 +++ sourceforge.net/trunk/rdesktop/parallel.c 2004/02/07 17:32:21 602 @@ -4,8 +4,6 @@ #define IOCTL_PAR_QUERY_RAW_DEVICE_ID 0x0c -#define PARALLELDEV0 "/dev/lp0" - #include "rdesktop.h" #include #include @@ -31,9 +29,8 @@ /* optarg looks like ':LPT1=/dev/lp0' */ /* when it arrives to this function. */ int -parallel_enum_devices(int *id, char *optarg) +parallel_enum_devices(uint32 *id, char *optarg) { - //TODO: Read from configuration file? CUPS? PARALLEL_DEVICE *ppar_info; char *pos = optarg; @@ -67,25 +64,44 @@ } static NTSTATUS -parallel_create(uint32 device_id, HANDLE * handle) +parallel_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposition, + uint32 flags, char *filename, HANDLE * handle) { int parallel_fd; - parallel_fd = open(PARALLELDEV0, O_WRONLY); + parallel_fd = open(g_rdpdr_device[device_id].local_path, O_RDWR); if (parallel_fd == -1) + { + perror("open"); return STATUS_ACCESS_DENIED; + } + + g_rdpdr_device[device_id].handle = parallel_fd; *handle = parallel_fd; + + /* all read and writes should be non blocking */ + if (fcntl(*handle, F_SETFL, O_NONBLOCK) == -1) + perror("fcntl"); + return STATUS_SUCCESS; } static NTSTATUS parallel_close(HANDLE handle) { + g_rdpdr_device[get_device_index(handle)].handle = 0; close(handle); return STATUS_SUCCESS; } +NTSTATUS +parallel_read(HANDLE 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) { @@ -120,7 +136,7 @@ DEVICE_FNS parallel_fns = { parallel_create, parallel_close, - NULL, + parallel_read, parallel_write, parallel_device_control };