]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - backend/usb.c
Remove all of the Subversion keywords from various source files.
[thirdparty/cups.git] / backend / usb.c
index 6665f282ed5b4db8175e98c67a34818ee999c2a1..a3b6fba097f74d15f2c445be43553c133c51d691 100644 (file)
@@ -1,33 +1,16 @@
 /*
- * "$Id: usb.c 5373 2006-04-06 20:03:32Z mike $"
+ * USB printer backend for CUPS.
  *
- *   USB port backend for the Common UNIX Printing System (CUPS).
+ * Copyright 2007-2012 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
- *   Copyright 1997-2006 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/".
  *
- *   These coded instructions, statements, and computer programs are the
- *   property of Easy Software Products and are protected by Federal
- *   copyright law.  Distribution and use rights are outlined in the file
- *   "LICENSE" which should have been included with this file.  If this
- *   file is missing or damaged please contact Easy Software Products
- *   at:
- *
- *       Attn: CUPS Licensing Information
- *       Easy Software Products
- *       44141 Airport View Drive, Suite 204
- *       Hollywood, Maryland 20636 USA
- *
- *       Voice: (301) 373-9600
- *       EMail: cups-info@cups.org
- *         WWW: http://www.cups.org
- *
- *   This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- *   list_devices() - List all available USB devices to stdout.
- *   print_device() - Print a file to a USB device.
- *   main()         - Send a file to the specified USB port.
+ * This file is subject to the Apple OS-Developed Software exception.
  */
 
 /*
 #  include <ApplicationServices/ApplicationServices.h>
 #endif /* __APPLE__ */
 
-#include <cups/backend.h>
-#include <cups/cups.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <cups/string.h>
-#include <signal.h>
+#include "backend-private.h"
 
 #ifdef WIN32
 #  include <io.h>
 
 void   list_devices(void);
 int    print_device(const char *uri, const char *hostname,
-                    const char *resource, const char *options,
-                    int fp, int copies, int argc, char *argv[]);
+                    const char *resource, char *options,
+                    int print_fd, int copies, int argc, char *argv[]);
 
 
 /*
  * Include the vendor-specific USB implementation...
  */
 
-#ifdef __APPLE__
+#ifdef HAVE_LIBUSB
+#  include "usb-libusb.c"
+#elif defined(__APPLE__)
 #  include "usb-darwin.c"
-#elif defined(__linux) || defined(__sun) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+#elif defined(__linux) || defined(__sun) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
 #  include "usb-unix.c"
 #else
 /*
@@ -107,8 +86,8 @@ int                                  /* O - Exit status */
 print_device(const char *uri,          /* I - Device URI */
              const char *hostname,     /* I - Hostname/manufacturer */
              const char *resource,     /* I - Resource/modelname */
-            const char *options,       /* I - Device options/serial number */
-            int        fp,             /* I - File descriptor to print */
+            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 */
@@ -124,14 +103,14 @@ print_device(const char *uri,             /* I - Device URI */
   (void)hostname;
   (void)resource;
   (void)options;
-  (void)fp;
+  (void)print_fd;
   (void)copies;
   (void)argc;
   (void)argv;
 
   return (CUPS_BACKEND_FAILED);
 }
-#endif /* __APPLE__ */
+#endif /* HAVE_LIBUSB */
 
 
 /*
@@ -146,7 +125,7 @@ int                                 /* O - Exit status */
 main(int  argc,                                /* I - Number of command-line arguments (6 or 7) */
      char *argv[])                     /* I - Command-line arguments */
 {
-  int          fp;                     /* Print file */
+  int          print_fd;               /* Print file */
   int          copies;                 /* Number of copies to print */
   int          status;                 /* Exit status */
   int          port;                   /* Port number (not used) */
@@ -192,7 +171,9 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
   }
   else if (argc < 6 || argc > 7)
   {
-    fputs("Usage: usb job-id user title copies options [file]\n", stderr);
+    _cupsLangPrintf(stderr,
+                    _("Usage: %s job-id user title copies options [file]"),
+                    argv[0]);
     return (CUPS_BACKEND_FAILED);
   }
 
@@ -207,7 +188,9 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
                      hostname, sizeof(hostname), &port,
                      resource, sizeof(resource)) < HTTP_URI_OK)
   {
-    fputs("ERROR: No device URI found in argv[0] or in DEVICE_URI environment variable!\n", stderr);
+    _cupsLangPrintFilter(stderr, "ERROR",
+                        _("No device URI found in argv[0] or in DEVICE_URI "
+                           "environment variable."));
     return (1);
   }
 
@@ -232,8 +215,8 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
 
   if (argc == 6)
   {
-    fp     = 0;
-    copies = 1;
+    print_fd = 0;
+    copies   = 1;
   }
   else
   {
@@ -241,10 +224,9 @@ main(int  argc,                            /* I - Number of command-line arguments (6 or 7) */
     * Try to open the print file...
     */
 
-    if ((fp = open(argv[6], O_RDONLY)) < 0)
+    if ((print_fd = open(argv[6], O_RDONLY)) < 0)
     {
-      fprintf(stderr, "ERROR: unable to open print file %s - %s\n",
-              argv[6], strerror(errno));
+      _cupsLangPrintError("ERROR", _("Unable to open print file"));
       return (CUPS_BACKEND_FAILED);
     }
 
@@ -255,19 +237,15 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
   * Finally, send the print file...
   */
 
-  status = print_device(uri, hostname, resource, options, fp, copies, argc, argv);
+  status = print_device(uri, hostname, resource, options, print_fd, copies,
+                        argc, argv);
 
  /*
   * Close the input file and return...
   */
 
-  if (fp != 0)
-    close(fp);
+  if (print_fd != 0)
+    close(print_fd);
 
   return (status);
 }
-
-
-/*
- * End of "$Id: usb.c 5373 2006-04-06 20:03:32Z mike $".
- */