/*
- * "$Id$"
- *
* LIBUSB interface code for CUPS.
*
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2020 by Apple Inc.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more
+ * information.
*/
/*
#include <libusb.h>
#include <cups/cups-private.h>
+#include <cups/ppd-private.h>
#include <cups/dir.h>
#include <pthread.h>
#include <sys/select.h>
#define USB_QUIRK_USB_INIT 0x0010 /* Needs vendor USB init string */
#define USB_QUIRK_VENDOR_CLASS 0x0020 /* Descriptor uses vendor-specific
Class or SubClass */
+#define USB_QUIRK_DELAY_CLOSE 0x0040 /* Delay close */
#define USB_QUIRK_WHITELIST 0x0000 /* no quirks */
* Close the connection and input file and general clean up...
*/
+ if (g.printer->quirks & USB_QUIRK_DELAY_CLOSE)
+ sleep(1);
+
close_device(g.printer);
/*
err = libusb_init(NULL);
if (err)
{
- fprintf(stderr, "DEBUG: Unable to initialize USB access via libusb, "
- "libusb error %i\n", (int)err);
+ fprintf(stderr, "ERROR: Unable to initialize USB access via libusb, libusb error %i (%s)\n", (int)err, libusb_strerror((int)err));
return (NULL);
}
protocol = 0;
for (altset = 0, altptr = ifaceptr->altsetting;
- altset < ifaceptr->num_altsetting;
+ altset < ifaceptr->num_altsetting; // lgtm [cpp/comparison-with-wider-type]
altset ++, altptr ++)
{
/*
if (strstr(line, " blacklist"))
quirk->quirks |= USB_QUIRK_BLACKLIST;
+ if (strstr(line, " delay-close"))
+ quirk->quirks |= USB_QUIRK_DELAY_CLOSE;
+
if (strstr(line, " no-reattach"))
quirk->quirks |= USB_QUIRK_NO_REATTACH;
goto error;
}
+ else if ((errcode = libusb_detach_kernel_driver(printer->handle, printer->iface)) < 0)
+ {
+ fprintf(stderr,
+ "DEBUG: Failed to detach \"usblp\" module from %04x:%04x\n",
+ devdesc.idVendor, devdesc.idProduct);
+
+ goto error;
+ }
+
+ sleep (1);
}
/*
* Make sure this loop executes no more than once every 250 miliseconds...
*/
- if ((readstatus != LIBUSB_SUCCESS || rbytes == 0) &&
- (g.wait_eof || !g.read_thread_stop))
+ if ((g.wait_eof || !g.read_thread_stop))
{
gettimeofday(&now, NULL);
if (timercmp(&now, &end, <))
return (errcode);
}
-
-
-/*
- * End of "$Id$".
- */
-