Blame SOURCES/cups-usb-paperout.patch

ad8523
diff -up cups-1.5b1/backend/usb-unix.c.usb-paperout cups-1.5b1/backend/usb-unix.c
ad8523
--- cups-1.5b1/backend/usb-unix.c.usb-paperout	2011-05-24 15:51:39.000000000 +0200
ad8523
+++ cups-1.5b1/backend/usb-unix.c	2011-05-24 15:51:39.000000000 +0200
ad8523
@@ -30,6 +30,11 @@
ad8523
 
ad8523
 #include <sys/select.h>
ad8523
 
ad8523
+#ifdef __linux
ad8523
+#include <sys/ioctl.h>
ad8523
+#include <linux/lp.h>
ad8523
+#endif /* __linux */
ad8523
+
ad8523
 
ad8523
 /*
ad8523
  * Local functions...
ad8523
@@ -334,7 +339,19 @@ open_device(const char *uri,		/* I - Dev
ad8523
   if (!strncmp(uri, "usb:/dev/", 9))
ad8523
 #ifdef __linux
ad8523
   {
ad8523
-    return (open(uri + 4, O_RDWR | O_EXCL));
ad8523
+    fd = open(uri + 4, O_RDWR | O_EXCL);
ad8523
+
ad8523
+    if (fd != -1)
ad8523
+    {
ad8523
+     /*
ad8523
+      * Tell the driver to return from write() with errno==ENOSPACE
ad8523
+      * on paper-out.
ad8523
+      */
ad8523
+      unsigned int t = 1;
ad8523
+      ioctl (fd, LPABORT, &t);
ad8523
+    }
ad8523
+
ad8523
+    return fd;
ad8523
   }
ad8523
   else if (!strncmp(uri, "usb://", 6))
ad8523
   {
ad8523
@@ -400,7 +417,14 @@ open_device(const char *uri,		/* I - Dev
ad8523
         if (!strcmp(uri, device_uri))
ad8523
 	{
ad8523
 	 /*
ad8523
-	  * Yes, return this file descriptor...
ad8523
+	  * Yes, tell the driver to return from write() with
ad8523
+	  * errno==ENOSPACE on paper-out.
ad8523
+	  */
ad8523
+	  unsigned int t = 1;
ad8523
+	  ioctl (fd, LPABORT, &t);
ad8523
+
ad8523
+	 /*
ad8523
+	  * Return this file descriptor...
ad8523
 	  */
ad8523
 
ad8523
 	  fprintf(stderr, "DEBUG: Printer using device file \"%s\"...\n",