]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - backend/usb-unix.c
Merge changes from CUPS trunk, r7566.
[thirdparty/cups.git] / backend / usb-unix.c
index 60f821d975fa9735f92403efe14acb51a11ccb4b..f1806106571203d7ca9d35d35889905ae2429e91 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: usb-unix.c 6911 2007-09-04 20:35:08Z mike $"
+ * "$Id: usb-unix.c 6910 2007-09-04 20:34:29Z mike $"
  *
  *   USB port backend for the Common UNIX Printing System (CUPS).
  *
@@ -37,7 +37,8 @@
  */
 
 static int     open_device(const char *uri, int *use_bc);
-static void    side_cb(int print_fd, int device_fd, int use_bc);
+static void    side_cb(int print_fd, int device_fd, int snmp_fd,
+                       http_addr_t *addr, int use_bc);
 
 
 /*
@@ -90,8 +91,8 @@ print_device(const char *uri,         /* I - Device URI */
 
     use_bc = strcasecmp(hostname, "Brother") &&
              strcasecmp(hostname, "Canon") &&
-             strcasecmp(hostname, "Konica Minolta") &&
-             strcasecmp(hostname, "Minolta");
+             strncasecmp(hostname, "Konica", 6) &&
+             strncasecmp(hostname, "Minolta", 7);
 #endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __DragonFly__ */
 
     if ((device_fd = open_device(uri, &use_bc)) == -1)
@@ -173,7 +174,7 @@ print_device(const char *uri,               /* I - Device URI */
       lseek(print_fd, 0, SEEK_SET);
     }
 
-    tbytes = backendRunLoop(print_fd, device_fd, use_bc, side_cb);
+    tbytes = backendRunLoop(print_fd, device_fd, -1, NULL, use_bc, side_cb);
 
     if (print_fd != 0 && tbytes >= 0)
       _cupsLangPrintf(stderr,
@@ -281,7 +282,7 @@ list_devices(void)
   }
 #elif defined(__hpux)
 #elif defined(__osf)
-#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
   int   i;                      /* Looping var */
   char  device[255];            /* Device filename */
 
@@ -345,7 +346,7 @@ open_device(const char *uri,                /* I - Device URI */
     * Find the correct USB device...
     */
 
-    do
+    for (;;)
     {
       for (busy = 0, i = 0; i < 16; i ++)
       {
@@ -414,21 +415,11 @@ open_device(const char *uri,              /* I - Device URI */
       */
 
       if (busy)
-      {
        _cupsLangPuts(stderr,
                      _("INFO: Printer busy; will retry in 5 seconds...\n"));
-       sleep(5);
-      }
-    }
-    while (busy);
 
-   /*
-    * Couldn't find the printer, return "no such device or address"...
-    */
-
-    errno = ENODEV;
-
-    return (-1);
+      sleep(5);
+    }
   }
 #elif defined(__sun) && defined(ECPPIOC_GETDEVID)
   {
@@ -525,7 +516,7 @@ open_device(const char *uri,                /* I - Device URI */
   }
 #else
   {
-    if (use_bc)
+    if (*use_bc)
       fd = open(uri + 4, O_RDWR | O_EXCL);
     else
       fd = -1;
@@ -552,9 +543,11 @@ open_device(const char *uri,               /* I - Device URI */
  */
 
 static void
-side_cb(int print_fd,                  /* I - Print file */
-        int device_fd,                 /* I - Device file */
-       int use_bc)                     /* I - Using back-channel? */
+side_cb(int         print_fd,          /* I - Print file */
+        int         device_fd,         /* I - Device file */
+        int         snmp_fd,           /* I - SNMP socket (unused) */
+       http_addr_t *addr,              /* I - Device address (unused) */
+       int         use_bc)             /* I - Using back-channel? */
 {
   cups_sc_command_t    command;        /* Request command */
   cups_sc_status_t     status;         /* Request/response status */
@@ -562,6 +555,9 @@ side_cb(int print_fd,                       /* I - Print file */
   int                  datalen;        /* Request/response data size */
 
 
+  (void)snmp_fd;
+  (void)addr;
+
   datalen = sizeof(data);
 
   if (cupsSideChannelRead(&command, &status, data, &datalen, 1.0))
@@ -615,5 +611,5 @@ side_cb(int print_fd,                       /* I - Print file */
 
 
 /*
- * End of "$Id: usb-unix.c 6911 2007-09-04 20:35:08Z mike $".
+ * End of "$Id: usb-unix.c 6910 2007-09-04 20:34:29Z mike $".
  */