$NetBSD: patch-ak,v 1.14 2010/06/09 09:01:43 sbd Exp $ Incorporate usb-backend-both-usblp-and-libusb.dpatch by http://www.cups.org/str.php?L3357 --- backend/usb-hybrid.c.orig 2010-06-06 00:29:57.033597544 +0000 +++ backend/usb-hybrid.c @@ -0,0 +1,88 @@ +/* + * "Id: usb-hybrid.c 8807 2009-08-31 18:45:43Z mike " + * + * USB port backend for the Common UNIX Printing System (CUPS). + * + * This file is included from "usb.c" when compiled on Linux. + * + * Copyright 2007-2008 by Apple Inc. + * Copyright 1997-2007 by Easy Software Products, all rights reserved. + * + * 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" + * "LICENSE" which should have been included with this file. If this + * file is missing or damaged, see the license at "http://www.cups.org/". + * + * This file is subject to the Apple OS-Developed Software exception. + * + * Contents: + * + * print_device() - Print a file to a USB device. + * list_devices() - List all USB devices. + */ + +/* + * Include necessary headers. + */ + +#include + +/* + * Include the two USB implementations used under Linux ... + */ + +#define USB_HYBRID 1 +#include "usb-libusb.c" +#include "usb-unix.c" + +/* + * 'print_device()' - Print a file to a USB device. + */ + +int /* O - Exit status */ +print_device(const char *uri, /* I - Device URI */ + const char *hostname, /* I - Hostname/manufacturer */ + const char *resource, /* I - Resource/modelname */ + char *options, /* I - Device options/serial number */ + int print_fd, /* I - File descriptor to print */ + int copies, /* I - Copies to print */ + int argc, /* I - Number of command-line arguments (6 or 7) */ + char *argv[]) /* I - Command-line arguments */ +{ + int result; + for(;;) + { + result = print_device_unix(uri, hostname, resource, options, print_fd, + copies, argc, argv); + if (result == -1) + { + result = print_device_libusb(uri, hostname, resource, options, print_fd, + copies, argc, argv); + if (result == -1) + sleep(5); + else + return(result); + } + else + return(result); + } +} + +/* + * 'list_devices()' - List all USB devices. + */ + +void +list_devices(void) +{ + /* Try both discovery methods, each device will appear only under one + of them */ + list_devices_libusb(); + list_devices_unix(); +} + + +/* + * End of "Id: usb-hybrid.c 8807 2009-08-31 18:45:43Z mike ". + */