]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - backend/usb.c
Load cups into easysw/current.
[thirdparty/cups.git] / backend / usb.c
index 3ffe2d0d131cf280631a77d0cd6323a9f7e9101b..ad6d95d07acff40493aac40f58d56a2570d6fdf9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: usb.c 4906 2006-01-10 20:53:28Z mike $"
+ * "$Id: usb.c 5590 2006-05-26 19:48:26Z mike $"
  *
  *   USB port backend for the Common UNIX Printing System (CUPS).
  *
@@ -63,7 +63,7 @@
 void   list_devices(void);
 int    print_device(const char *uri, const char *hostname,
                     const char *resource, const char *options,
-                    int fp, int copies);
+                    int print_fd, int copies, int argc, char *argv[]);
 
 
 /*
@@ -72,7 +72,7 @@ int   print_device(const char *uri, const char *hostname,
 
 #ifdef __APPLE__
 #  include "usb-darwin.c"
-#elif defined(__linux) || defined(__sun) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#elif defined(__linux) || defined(__sun) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
 #  include "usb-unix.c"
 #else
 /*
@@ -108,8 +108,10 @@ 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 */
-            int        copies)         /* I - Copies to print */
+            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 */
 {
  /*
   * Can't print, so just reference the arguments to eliminate compiler
@@ -122,8 +124,10 @@ 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);
 }
@@ -142,7 +146,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) */
@@ -196,21 +200,17 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
   * Extract the device name and options from the URI...
   */
 
-  if (strncmp(argv[0], "usb:", 4))
-    uri = getenv("DEVICE_URI");
-  else
-    uri = argv[0];
+  uri = cupsBackendDeviceURI(argv);
 
-  if (!uri)
+  if (httpSeparateURI(HTTP_URI_CODING_ALL, uri,
+                      method, sizeof(method), username, sizeof(username),
+                     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);
     return (1);
   }
 
-  httpSeparateURI(argv[0], method, sizeof(method), username, sizeof(username),
-                  hostname, sizeof(hostname), &port,
-                 resource, sizeof(resource));
-
  /*
   * See if there are any options...
   */
@@ -232,8 +232,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,7 +241,7 @@ 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));
@@ -255,19 +255,20 @@ 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);
+  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 4906 2006-01-10 20:53:28Z mike $".
+ * End of "$Id: usb.c 5590 2006-05-26 19:48:26Z mike $".
  */