]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - systemv/lpstat.c
Move debug printfs to internal usage only.
[thirdparty/cups.git] / systemv / lpstat.c
index c13739fc8968cf70d27cdd641ae9629f56ce266f..d6aa45e786279be68252ad4091491f5b75a45c49 100644 (file)
@@ -1,14 +1,10 @@
 /*
  * "lpstat" command for CUPS.
  *
- * Copyright 2007-2016 by Apple Inc.
+ * Copyright 2007-2017 by Apple Inc.
  * Copyright 1997-2006 by Easy Software Products.
  *
- * 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.
  */
 
 /*
@@ -77,7 +73,7 @@ main(int  argc,                               /* I - Number of command-line arguments */
     {
       for (opt = argv[i] + 1; *opt; opt ++)
       {
-       switch (argv[i][1])
+       switch (*opt)
        {
          case 'D' : /* Show description */
              long_status = 1;
@@ -240,6 +236,41 @@ main(int  argc,                            /* I - Number of command-line arguments */
              show_default(dests);
              break;
 
+         case 'e' : /* List destinations */
+             {
+                cups_dest_t *temp = NULL, *dest;
+                int j, num_temp = cupsGetDests(&temp);
+
+                op = 'e';
+
+                for (j = num_temp, dest = temp; j > 0; j --, dest ++)
+                {
+                  if (dest->instance)
+                    printf("%s/%s", dest->name, dest->instance);
+                  else
+                    fputs(dest->name, stdout);
+
+                  if (long_status)
+                  {
+                    const char *printer_uri_supported = cupsGetOption("printer-uri-supported", dest->num_options, dest->options);
+                    const char *printer_is_temporary = cupsGetOption("printer-is-temporary", dest->num_options, dest->options);
+                    const char *type = "network";
+
+                    if (printer_is_temporary && !strcmp(printer_is_temporary, "true"))
+                      type = "temporary";
+                    else if (printer_uri_supported)
+                      type = "permanent";
+
+                    printf(" %s %s %s\n", type, printer_uri_supported ? printer_uri_supported : "none", cupsGetOption("device-uri", dest->num_options, dest->options));
+                  }
+                  else
+                    putchar('\n');
+                }
+
+                cupsFreeDests(num_temp, temp);
+              }
+              break;
+
          case 'f' : /* Show forms */
              op   = 'f';
              if (opt[1] != '\0')
@@ -657,8 +688,6 @@ show_accepting(const char  *printers,       /* I - Destinations */
                };
 
 
-  DEBUG_printf(("show_accepting(printers=\"%s\")\n", printers));
-
   if (printers != NULL && !strcmp(printers, "all"))
     printers = NULL;
 
@@ -705,8 +734,6 @@ show_accepting(const char  *printers,       /* I - Destinations */
 
   if (response)
   {
-    DEBUG_puts("show_accepting: request succeeded...");
-
    /*
     * Loop through the printers returned in the list and display
     * their devices...
@@ -841,8 +868,6 @@ show_classes(const char *dests)             /* I - Destinations */
                };
 
 
-  DEBUG_printf(("show_classes(dests=\"%s\")\n", dests));
-
   if (dests != NULL && !strcmp(dests, "all"))
     dests = NULL;
 
@@ -889,8 +914,6 @@ show_classes(const char *dests)             /* I - Destinations */
 
   if (response)
   {
-    DEBUG_puts("show_classes: request succeeded...");
-
     if (response->request.status.status_code > IPP_OK_CONFLICT)
     {
       _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
@@ -1102,8 +1125,6 @@ show_devices(const char  *printers,       /* I - Destinations */
                };
 
 
-  DEBUG_printf(("show_devices(printers=\"%s\")\n", printers));
-
   if (printers != NULL && !strcmp(printers, "all"))
     printers = NULL;
 
@@ -1150,8 +1171,6 @@ show_devices(const char  *printers,       /* I - Destinations */
 
   if (response)
   {
-    DEBUG_puts("show_devices: request succeeded...");
-
    /*
     * Loop through the printers returned in the list and display
     * their devices...
@@ -1290,10 +1309,6 @@ show_jobs(const char *dests,             /* I - Destinations */
                };
 
 
-  DEBUG_printf(("show_jobs(dests=\"%s\", users=\"%s\", long_status=%d, "
-                "ranking=%d, which=\"%s\")\n", dests, users, long_status,
-               ranking, which));
-
   if (dests != NULL && !strcmp(dests, "all"))
     dests = NULL;
 
@@ -1539,9 +1554,6 @@ show_printers(const char  *printers,      /* I - Destinations */
                };
 
 
-  DEBUG_printf(("show_printers(printers=\"%s\", num_dests=%d, dests=%p, "
-                "long_status=%d)\n", printers, num_dests, dests, long_status));
-
   if (printers != NULL && !strcmp(printers, "all"))
     printers = NULL;
 
@@ -1588,8 +1600,6 @@ show_printers(const char  *printers,      /* I - Destinations */
 
   if (response)
   {
-    DEBUG_puts("show_printers: request succeeded...");
-
    /*
     * Loop through the printers returned in the list and display
     * their status...
@@ -1760,20 +1770,16 @@ show_printers(const char  *printers,    /* I - Destinations */
         switch (pstate)
        {
          case IPP_PRINTER_IDLE :
-             _cupsLangPrintf(stdout,
-                             _("printer %s is idle.  enabled since %s"),
-                             printer, printer_state_time);
+             if (ippContainsString(reasons, "hold-new-jobs"))
+               _cupsLangPrintf(stdout, _("printer %s is holding new jobs.  enabled since %s"), printer, printer_state_time);
+             else
+               _cupsLangPrintf(stdout, _("printer %s is idle.  enabled since %s"), printer, printer_state_time);
              break;
          case IPP_PRINTER_PROCESSING :
-             _cupsLangPrintf(stdout,
-                             _("printer %s now printing %s-%d.  "
-                               "enabled since %s"),
-                             printer, printer, jobid, printer_state_time);
+             _cupsLangPrintf(stdout, _("printer %s now printing %s-%d.  enabled since %s"), printer, printer, jobid, printer_state_time);
              break;
          case IPP_PRINTER_STOPPED :
-             _cupsLangPrintf(stdout,
-                             _("printer %s disabled since %s -"),
-                             printer, printer_state_time);
+             _cupsLangPrintf(stdout, _("printer %s disabled since %s -"), printer, printer_state_time);
              break;
        }