diff options
-rw-r--r-- | CHANGES.md | 2 | ||||
-rw-r--r-- | man/lpstat.man | 11 | ||||
-rw-r--r-- | systemv/lpstat.c | 31 |
3 files changed, 40 insertions, 4 deletions
diff --git a/CHANGES.md b/CHANGES.md index c9836e0de..235479eab 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/man/lpstat.man b/man/lpstat.man index 64ed76839..5adb08dde 100644 --- a/man/lpstat.man +++ b/man/lpstat.man @@ -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 diff --git a/systemv/lpstat.c b/systemv/lpstat.c index 6feb00e59..e239e9770 100644 --- a/systemv/lpstat.c +++ b/systemv/lpstat.c @@ -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') @@ -579,6 +585,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. */ |