summaryrefslogtreecommitdiffstats
path: root/cups-usb-paperout.patch
blob: f1f73f0a32ce1b3819dcc0545de2b97001becbb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
diff -up cups-1.5b1/backend/usb-unix.c.usb-paperout cups-1.5b1/backend/usb-unix.c
--- cups-1.5b1/backend/usb-unix.c.usb-paperout	2011-05-24 15:51:39.000000000 +0200
+++ cups-1.5b1/backend/usb-unix.c	2011-05-24 15:51:39.000000000 +0200
@@ -30,6 +30,11 @@
 
 #include <sys/select.h>
 
+#ifdef __linux
+#include <sys/ioctl.h>
+#include <linux/lp.h>
+#endif /* __linux */
+
 
 /*
  * Local functions...
@@ -334,7 +339,19 @@ open_device(const char *uri,		/* I - Dev
   if (!strncmp(uri, "usb:/dev/", 9))
 #ifdef __linux
   {
-    return (open(uri + 4, O_RDWR | O_EXCL));
+    fd = open(uri + 4, O_RDWR | O_EXCL);
+
+    if (fd != -1)
+    {
+     /*
+      * Tell the driver to return from write() with errno==ENOSPACE
+      * on paper-out.
+      */
+      unsigned int t = 1;
+      ioctl (fd, LPABORT, &t);
+    }
+
+    return fd;
   }
   else if (!strncmp(uri, "usb://", 6))
   {
@@ -400,7 +417,14 @@ open_device(const char *uri,		/* I - Dev
         if (!strcmp(uri, device_uri))
 	{
 	 /*
-	  * Yes, return this file descriptor...
+	  * Yes, tell the driver to return from write() with
+	  * errno==ENOSPACE on paper-out.
+	  */
+	  unsigned int t = 1;
+	  ioctl (fd, LPABORT, &t);
+
+	 /*
+	  * Return this file descriptor...
 	  */
 
 	  fprintf(stderr, "DEBUG: Printer using device file \"%s\"...\n",