]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add support for "-e" option in lpstat (Issue #5005)
authorMichael Sweet <michael.r.sweet@gmail.com>
Fri, 26 May 2017 14:06:54 +0000 (10:06 -0400)
committerMichael Sweet <michael.r.sweet@gmail.com>
Fri, 26 May 2017 14:06:54 +0000 (10:06 -0400)
CHANGES.md
man/lpstat.man
systemv/lpstat.c

index c9836e0de0d4bf7085755c499ef9cd89ad05a447..235479eab3c1a605fc01a41a309d86994c4a4148 100644 (file)
@@ -17,6 +17,8 @@ CHANGES IN CUPS V2.2.4
 - Fixed the "cancel all jobs" function in the web interface for several
   languages (Issue #4999)
 - Fixed issues with local queues (Issue #5003, Issue #5008, Issue #5009)
+- The `lpstat` command now supports a `-e` option to enumerate local printers
+  (either previously added or on the network) that can be accessed.
 
 
 CHANGES IN CUPS V2.2.3
index 64ed768399bcb36b8458c94fa5a6d7ed97cfc985..5adb08dde5ef8f2f4e42a28449ad0916c9751b38 100644 (file)
@@ -1,7 +1,7 @@
 .\"
 .\" lpstat man page for CUPS.
 .\"
-.\" Copyright 2007-2014 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
@@ -10,7 +10,7 @@
 .\" 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/".
 .\"
-.TH lpstat 1 "CUPS" "12 June 2014" "Apple Inc."
+.TH lpstat 1 "CUPS" "26 May 2017" "Apple Inc."
 .SH NAME
 lpstat \- print cups status information
 .SH SYNOPSIS
@@ -40,6 +40,8 @@ lpstat \- print cups status information
 ] ] [
 .B \-d
 ] [
+.B \-e
+] [
 .B \-o
 [
 .I destination(s)
@@ -97,6 +99,9 @@ If no classes are specified then all classes are listed.
 .B \-d
 Shows the current default destination.
 .TP 5
+.B \-e
+Shows all available destinations on the local network.
+.TP 5
 \fB\-h \fIserver\fR[\fB:\fIport\fR]
 Specifies an alternate server.
 .TP 5
@@ -133,7 +138,7 @@ If no printers are specified then all printers are listed.
 Unlike the System V printing system, CUPS allows printer names to contain any printable character except SPACE, TAB, "/", and "#".
 Also, printer and class names are \fInot\fR case-sensitive.
 .LP
-The \fI\-h\fR, \fI\-E\fR, \fI\-U\fR, and \fI\-W\fR options are unique to CUPS.
+The \fI\-h\fR, \fI-e\fR, \fI\-E\fR, \fI\-U\fR, and \fI\-W\fR options are unique to CUPS.
 .LP
 The Solaris \fI\-f\fR, \fI\-P\fR, and \fI\-S\fR options are silently ignored.
 .SH SEE ALSO
index 6feb00e599f0a5cc3ad7afa2a75689e4a0f9c6cf..e239e9770357bf1c47bb70f46a3757292a59cca7 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * "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
@@ -24,6 +24,7 @@
 
 static void    check_dest(const char *command, const char *name,
                           int *num_dests, cups_dest_t **dests);
+static int      enum_cb(void *user_data, unsigned flags, cups_dest_t *dest);
 static int     match_list(const char *list, const char *name);
 static int     show_accepting(const char *printers, int num_dests,
                               cups_dest_t *dests);
@@ -240,6 +241,11 @@ main(int  argc,                            /* I - Number of command-line arguments */
              show_default(dests);
              break;
 
+         case 'e' : /* List destinations */
+             op = 'e';
+              cupsEnumDests(CUPS_DEST_FLAGS_NONE, 1000, NULL, 0, 0, enum_cb, NULL);
+              break;
+
          case 'f' : /* Show forms */
              op   = 'f';
              if (opt[1] != '\0')
@@ -578,6 +584,29 @@ check_dest(const char  *command,   /* I  - Command name */
 }
 
 
+/*
+ * 'enum_cb()' - Print a destination on the standard output.
+ */
+
+static int                              /* O - 1 to continue */
+enum_cb(void        *user_data,         /* I - User data (unused) */
+        unsigned    flags,              /* I - Enumeration flags */
+        cups_dest_t *dest)              /* I - Destination */
+{
+  (void)user_data;
+
+  if (!(flags & CUPS_DEST_FLAGS_REMOVED))
+  {
+    if (dest->instance)
+      printf("%s/%s\n", dest->name, dest->instance);
+    else
+      puts(dest->name);
+  }
+
+  return (1);
+}
+
+
 /*
  * 'match_list()' - Match a name from a list of comma or space-separated names.
  */