Blame SOURCES/cups-usb-paperout.patch

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