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