CVS: rdesktop parallel.c,1.8,1.9
Peter Bystr?m <[email protected]>
| Newsgroups | gmane.network.rdesktop.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23190
Modified Files:
parallel.c
Log Message:
zero handle at init.
better error handling
add paper status - volker milde
Index: parallel.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/parallel.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** parallel.c 15 Feb 2004 21:19:28 -0000 1.8
--- parallel.c 5 Mar 2004 06:48:08 -0000 1.9
***************
*** 8,11 ****
--- 8,16 ----
#include <unistd.h>
#include <fcntl.h>
+ #include <sys/ioctl.h>
+ #include <linux/lp.h>
+ #include <errno.h>
+
+ extern int errno;
extern RDPDR_DEVICE g_rdpdr_device[];
***************
*** 56,59 ****
--- 61,65 ----
g_rdpdr_device[*id].device_type = DEVICE_TYPE_PARALLEL;
g_rdpdr_device[*id].pdevice_data = (void *) ppar_info;
+ g_rdpdr_device[*id].handle = 0;
count++;
(*id)++;
***************
*** 77,88 ****
}
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;
}
--- 83,96 ----
}
+ /* all read and writes should be non blocking */
+ if (fcntl(parallel_fd, F_SETFL, O_NONBLOCK) == -1)
+ perror("fcntl");
+
+ ioctl(parallel_fd, LPABORT, (int) 1);
+
g_rdpdr_device[device_id].handle = parallel_fd;
*handle = parallel_fd;
return STATUS_SUCCESS;
}
***************
*** 91,95 ****
parallel_close(HANDLE handle)
{
! g_rdpdr_device[get_device_index(handle)].handle = 0;
close(handle);
return STATUS_SUCCESS;
--- 99,105 ----
parallel_close(HANDLE handle)
{
! int i = get_device_index(handle);
! if (i >= 0)
! g_rdpdr_device[i].handle = 0;
close(handle);
return STATUS_SUCCESS;
***************
*** 106,111 ****
parallel_write(HANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)
{
! *result = write(handle, data, length);
! return STATUS_SUCCESS;
}
--- 116,146 ----
parallel_write(HANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)
{
! int rc = STATUS_SUCCESS;
!
! int n = write(handle, data, length);
! if (n < 0)
! {
! int status;
!
! *result = 0;
! switch (errno)
! {
! case EAGAIN:
! rc = STATUS_DEVICE_OFF_LINE;
! case ENOSPC:
! rc = STATUS_DEVICE_PAPER_EMPTY;
! case EIO:
! rc = STATUS_DEVICE_OFF_LINE;
! default:
! rc = STATUS_DEVICE_POWERED_OFF;
! }
! if (ioctl(handle, LPGETSTATUS, &status) == 0)
! {
! /* coming soon: take care for the printer status */
! printf("parallel_write: status = %d, errno = %d\n", status, errno);
! }
! }
! *result = n;
! return rc;
}
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click