]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
The lpstat command now shows the correct interface script or PPD
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Sat, 14 Jun 2003 14:07:47 +0000 (14:07 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Sat, 14 Jun 2003 14:07:47 +0000 (14:07 +0000)
file, if any, for a print queue (STR #89)

The lpstat command now shows the printer-state-message and
printer-state-reasons attributes whenever they are not blank
(STR #152)

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@3769 7a7537e8-13f0-0310-91df-b6672ffda945

CHANGES.txt
systemv/lpstat.c

index 19fc321549cddd57d297ccf95ce3e2b9248a9e20..55875fac9b92517bd840558d9c6b329997c602be 100644 (file)
@@ -3,6 +3,11 @@ CHANGES.txt - 06/14/2003
 
 CHANGES IN CUPS V1.1.20rc1
 
+       - The lpstat command now shows the correct interface
+         script or PPD file, if any, for a print queue (STR #89)
+       - The lpstat command now shows the printer-state-message
+         and printer-state-reasons attributes whenever they are
+         not blank (STR #152)
        - The French and German option-conflict.tmpl template
          files did not get installed (STR #148)
        - The cups.list.in file did not work when compiling
index 1992a7b998bcd0d737bd052b7ffa4e4ab9e0d8a1..fcd278869605d55195e4060499a85e0fc0db982b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: lpstat.c,v 1.52 2003/04/10 18:41:39 mike Exp $"
+ * "$Id: lpstat.c,v 1.53 2003/06/14 14:07:47 mike Exp $"
  *
  *   "lpstat" command for the Common UNIX Printing System (CUPS).
  *
@@ -1716,17 +1716,20 @@ show_printers(http_t      *http,        /* I - HTTP connection to server */
              cups_dest_t *dests,       /* I - User-defined destinations */
               int         long_status) /* I - Show long status? */
 {
-  int          i;                      /* Looping var */
+  int          i, j;                   /* Looping vars */
   ipp_t                *request,               /* IPP Request */
                *response,              /* IPP Response */
                *jobs;                  /* IPP Get Jobs response */
-  ipp_attribute_t *attr;               /* Current attribute */
-  ipp_attribute_t *jobattr;            /* Job ID attribute */
+  ipp_attribute_t *attr,               /* Current attribute */
+               *jobattr,               /* Job ID attribute */
+               *reasons;               /* Job state reasons attribute */
   cups_lang_t  *language;              /* Default language */
   const char   *printer,               /* Printer name */
                *message,               /* Printer state message */
                *description,           /* Description of printer */
-               *location;              /* Location of printer */
+               *location,              /* Location of printer */
+               *make_model,            /* Make and model of printer */
+               *uri;                   /* URI of printer */
   ipp_pstate_t pstate;                 /* Printer state */
   cups_ptype_t ptype;                  /* Printer type */
   int          jobid;                  /* Job ID of current job */
@@ -1741,9 +1744,12 @@ show_printers(http_t      *http, /* I - HTTP connection to server */
                  "printer-name",
                  "printer-state",
                  "printer-state-message",
+                 "printer-state-reasons",
                  "printer-type",
                  "printer-info",
-                   "printer-location"
+                  "printer-location",
+                 "printer-make-and-model",
+                 "printer-uri-supported"
                };
   static const char *jattrs[] =                /* Attributes we need for jobs... */
                {
@@ -1830,7 +1836,10 @@ show_printers(http_t      *http, /* I - HTTP connection to server */
       pstate      = IPP_PRINTER_IDLE;
       message     = NULL;
       description = NULL;
-      location = NULL;
+      location    = NULL;
+      make_model  = NULL;
+      reasons     = NULL;
+      uri         = NULL;
       jobid       = 0;
 
       while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER)
@@ -1838,26 +1847,30 @@ show_printers(http_t      *http,        /* I - HTTP connection to server */
         if (strcmp(attr->name, "printer-name") == 0 &&
            attr->value_tag == IPP_TAG_NAME)
          printer = attr->values[0].string.text;
-
-        if (strcmp(attr->name, "printer-state") == 0 &&
-           attr->value_tag == IPP_TAG_ENUM)
+        else if (strcmp(attr->name, "printer-state") == 0 &&
+                attr->value_tag == IPP_TAG_ENUM)
          pstate = (ipp_pstate_t)attr->values[0].integer;
-
-        if (strcmp(attr->name, "printer-type") == 0 &&
-           attr->value_tag == IPP_TAG_ENUM)
+        else if (strcmp(attr->name, "printer-type") == 0 &&
+                attr->value_tag == IPP_TAG_ENUM)
          ptype = (cups_ptype_t)attr->values[0].integer;
-
-        if (strcmp(attr->name, "printer-state-message") == 0 &&
-           attr->value_tag == IPP_TAG_TEXT)
+        else if (strcmp(attr->name, "printer-state-message") == 0 &&
+                attr->value_tag == IPP_TAG_TEXT)
          message = attr->values[0].string.text;
-
-        if (strcmp(attr->name, "printer-info") == 0 &&
-           attr->value_tag == IPP_TAG_TEXT)
+        else if (strcmp(attr->name, "printer-info") == 0 &&
+                attr->value_tag == IPP_TAG_TEXT)
          description = attr->values[0].string.text;
-
-        if (strcmp(attr->name, "printer-location") == 0 &&
-           attr->value_tag == IPP_TAG_TEXT)
+        else if (strcmp(attr->name, "printer-location") == 0 &&
+                attr->value_tag == IPP_TAG_TEXT)
          location = attr->values[0].string.text;
+        else if (strcmp(attr->name, "printer-make-and-model") == 0 &&
+                attr->value_tag == IPP_TAG_TEXT)
+         make_model = attr->values[0].string.text;
+        else if (strcmp(attr->name, "printer-uri-supported") == 0 &&
+                attr->value_tag == IPP_TAG_URI)
+         uri = attr->values[0].string.text;
+        else if (strcmp(attr->name, "printer-state-reasons") == 0 &&
+                attr->value_tag == IPP_TAG_KEYWORD)
+         reasons = attr;
 
         attr = attr->next;
       }
@@ -1995,11 +2008,14 @@ show_printers(http_t      *http,        /* I - HTTP connection to server */
              printf("printer %s now printing %s-%d.  enabled since Jan 01 00:00\n", printer, printer, jobid);
              break;
          case IPP_PRINTER_STOPPED :
-             printf("printer %s disabled since Jan 01 00:00 -\n\t%s\n", printer,
-                    message == NULL ? "reason unknown" : message);
+             printf("printer %s disabled since Jan 01 00:00 -\n", printer);
              break;
        }
 
+        if ((message && *message) || pstate == IPP_PRINTER_STOPPED)
+         printf("\t%s\n", message == NULL || !*message ? "reason unknown" :
+                                                         message);
+
         if (long_status > 1)
        {
          puts("\tForm mounted:");
@@ -2007,14 +2023,32 @@ show_printers(http_t      *http,        /* I - HTTP connection to server */
          puts("\tPrinter types: unknown");
        }
         if (long_status)
+       {
          printf("\tDescription: %s\n", description ? description : "");
+         if (reasons)
+         {
+           printf("\tAlerts:");
+           for (i = 0; i < reasons->num_values; i ++)
+             printf(" %s", reasons->values[i].string.text);
+           putchar('\n');
+         }
+       }
         if (long_status > 1)
        {
          printf("\tLocation: %s\n", location ? location : "");
          printf("\tConnection: %s\n",
                 (ptype & CUPS_PRINTER_REMOTE) ? "remote" : "direct");
          if (!(ptype & CUPS_PRINTER_REMOTE))
-           printf("\tInterface: %s/ppd/%s.ppd\n", root, printer);
+         {
+           if (make_model && strstr(make_model, "System V Printer"))
+             printf("\tInterface: %s/ppd/%s.ppd\n", root, printer);
+           else if (make_model && !strstr(make_model, "Raw Printer"))
+             printf("\tInterface: %s/ppd/%s.ppd\n", root, printer);
+          }
+         else if (make_model && !strstr(make_model, "System V Printer") &&
+                  !strstr(make_model, "Raw Printer") && uri)
+           printf("\tInterface: %s.ppd\n", uri);
+
          puts("\tOn fault: no alert");
          puts("\tAfter fault: continue");
          puts("\tUsers allowed:");
@@ -2042,12 +2076,15 @@ show_printers(http_t      *http,        /* I - HTTP connection to server */
                         dests[i].instance, printer, jobid);
                  break;
              case IPP_PRINTER_STOPPED :
-                 printf("printer %s/%s disabled since Jan 01 00:00 -\n\t%s\n", printer,
-                        dests[i].instance,
-                        message == NULL ? "reason unknown" : message);
+                 printf("printer %s/%s disabled since Jan 01 00:00 -\n", printer,
+                        dests[i].instance);
                  break;
            }
 
+            if ((message && *message) || pstate == IPP_PRINTER_STOPPED)
+             printf("\t%s\n", message == NULL || !*message ? "reason unknown" :
+                                                             message);
+
             if (long_status > 1)
            {
              puts("\tForm mounted:");
@@ -2055,14 +2092,31 @@ show_printers(http_t      *http,        /* I - HTTP connection to server */
              puts("\tPrinter types: unknown");
            }
             if (long_status)
+           {
              printf("\tDescription: %s\n", description ? description : "");
+             if (reasons)
+             {
+               printf("\tAlerts:");
+               for (j = 0; j < reasons->num_values; j ++)
+                 printf(" %s", reasons->values[j].string.text);
+               putchar('\n');
+             }
+           }
             if (long_status > 1)
            {
              printf("\tLocation: %s\n", location ? location : "");
              printf("\tConnection: %s\n",
                     (ptype & CUPS_PRINTER_REMOTE) ? "remote" : "direct");
              if (!(ptype & CUPS_PRINTER_REMOTE))
-               printf("\tInterface: %s/ppd/%s.ppd\n", root, printer);
+             {
+               if (make_model && strstr(make_model, "System V Printer"))
+                 printf("\tInterface: %s/ppd/%s.ppd\n", root, printer);
+               else if (make_model && !strstr(make_model, "Raw Printer"))
+                 printf("\tInterface: %s/ppd/%s.ppd\n", root, printer);
+              }
+             else if (make_model && !strstr(make_model, "System V Printer") &&
+                      !strstr(make_model, "Raw Printer") && uri)
+               printf("\tInterface: %s.ppd\n", uri);
              puts("\tOn fault: no alert");
              puts("\tAfter fault: continue");
              puts("\tUsers allowed:");
@@ -2108,5 +2162,5 @@ show_scheduler(http_t *http)      /* I - HTTP connection to server */
 
 
 /*
- * End of "$Id: lpstat.c,v 1.52 2003/04/10 18:41:39 mike Exp $".
+ * End of "$Id: lpstat.c,v 1.53 2003/06/14 14:07:47 mike Exp $".
  */