landgraf / rpms / cups

Forked from rpms/cups 6 years ago
Clone
390aca2
--- cups-1.2.10/backend/usb-unix.c.usb-paperout	2007-06-26 15:11:14.000000000 +0100
390aca2
+++ cups-1.2.10/backend/usb-unix.c	2007-06-26 15:16:23.000000000 +0100
390aca2
@@ -39,6 +39,11 @@
390aca2
 #include "ieee1284.c"
390aca2
 #include <sys/select.h>
2df06f8
 
2df06f8
+#ifdef __linux
2df06f8
+#include <sys/ioctl.h>
2df06f8
+#include <linux/lp.h>
2df06f8
+#endif /* __linux */
2df06f8
+
72e0124
 
390aca2
 /*
390aca2
  * Local functions...
390aca2
@@ -308,7 +313,19 @@
390aca2
   if (!strncmp(uri, "usb:/dev/", 9))
390aca2
 #ifdef __linux
390aca2
   {
390aca2
-    return (open(uri + 4, O_RDWR | O_EXCL));
390aca2
+    fd = open(uri + 4, O_RDWR | O_EXCL);
2df06f8
+
390aca2
+    if (fd != -1)
2df06f8
+    {
390aca2
+     /*
390aca2
+      * Tell the driver to return from write() with errno==ENOSPACE
390aca2
+      * on paper-out.
390aca2
+      */
390aca2
+      unsigned int t = 1;
390aca2
+      ioctl (fd, LPABORT, &t);
2df06f8
+    }
2df06f8
+
390aca2
+    return fd;
2df06f8
   }
390aca2
   else if (!strncmp(uri, "usb://", 6))
390aca2
   {
390aca2
@@ -374,7 +391,14 @@
390aca2
         if (!strcmp(uri, device_uri))
390aca2
 	{
390aca2
 	 /*
390aca2
-	  * Yes, return this file descriptor...
390aca2
+	  * Yes, tell the driver to return from write() with
390aca2
+	  * errno==ENOSPACE on paper-out.
390aca2
+	  */
390aca2
+	  unsigned int t = 1;
390aca2
+	  ioctl (fd, LPABORT, &t);
2df06f8
+
390aca2
+	 /*
390aca2
+	  * Return this file descriptor...
390aca2
 	  */
2df06f8
 
390aca2
 	  fprintf(stderr, "DEBUG: Printer using device file \"%s\"...\n", device);