diff --git a/man/lp.man b/man/lp.man index d6bba88331..9cde2c5eec 100644 --- a/man/lp.man +++ b/man/lp.man @@ -1,12 +1,13 @@ .\" .\" lp man page for CUPS. .\" -.\" Copyright 2007-2016 by Apple Inc. -.\" Copyright 1997-2006 by Easy Software Products. +.\" Copyright © 2007-2018 by Apple Inc. +.\" Copyright © 1997-2006 by Easy Software Products. .\" -.\" Licensed under Apache License v2.0. See the file "LICENSE" for more information. +.\" Licensed under Apache License v2.0. See the file "LICENSE" for more +.\" information. .\" -.TH lp 1 "CUPS" "2 May 2016" "Apple Inc." +.TH lp 1 "CUPS" "6 December 2018" "Apple Inc." .SH NAME lp \- print files .SH SYNOPSIS @@ -158,44 +159,16 @@ Aside from the printer-specific options reported by the .BR lpoptions (1) command, the following generic options are available: .TP 5 -\fB\-o collate=true\fR -Prints collated copies. -.TP 5 -\fB\-o fit\-to\-page\fR -Scales the print file to fit on the page. -.TP 5 -\fB\-o job-hold-until=\fIwhen\fR -Holds the job until the specified local time. -"when" can be "indefinite" to hold the until released, "day-time" to print the job between 6am and 6pm local time, "night" to print the job between 6pm and 6am local time, "second-shift" to print the job between 4pm and 12am local time, "third-shift" to print the job between 12am and 8am local time, or "weekend" to print the job on Saturday or Sunday. -.TP 5 -\fB\-o job-hold-until=\fIhh:mm\fR -Holds the job until the specified time in hours and minutes UTC. -.TP 5 -\fB\-o job-priority=\fIpriority\fR -Set the priority to a value from 1 (lowest) to 100 (highest), which influences when a job is scheduled for printing. -The default priority is typically 50. -.TP 5 \fB\-o job-sheets=\fIname\fR\fR Prints a cover page (banner) with the document. The "name" can be "classified", "confidential", "secret", "standard", "topsecret", or "unclassified". .TP 5 -\fB\-o job-sheets=\fIstart-name,end-name\fR\fR -Prints cover pages (banners) with the document. -.TP 5 \fB\-o media=\fIsize\fR Sets the page size to \fIsize\fR. Most printers support at least the size names "a4", "letter", and "legal". .TP 5 -\fB\-o mirror\fR -Mirrors each page. -.TP 5 \fB\-o number\-up=\fR{\fI2|4|6|9|16\fR} Prints 2, 4, 6, 9, or 16 document (input) pages on each output page. .TP 5 -\fB\-o number\-up\-layout=\fIlayout\fR -Specifies the layout of pages with the "number-up" option. -The "layout" string can be "btlr", "btrl", "lrbt", "lrtb", "rlbt", "rltb", "tblr", or "tbrl" - the first two letters determine the column order while the second two letters determine the row order. -"bt" is bottom-to-top, "lr" is left-to-right, "rl" is right-to-left, and "tb" is top-to-bottom. -.TP 5 \fB\-o orientation\-requested=4\fR Prints the job in landscape (rotated 90 degrees counter-clockwise). .TP 5 @@ -205,17 +178,12 @@ Prints the job in landscape (rotated 90 degrees clockwise). \fB\-o orientation\-requested=6\fR Prints the job in reverse portrait (rotated 180 degrees). .TP 5 -\fB\-o outputorder=reverse\fR -Prints pages in reverse order. +\fB\-o print\-quality=3\fR .TP 5 -\fB\-o page\-border=\fIborder\fR -Prints a border around each document page. -"border" is "double", "double\-thick", "single", or "single\-thick". +\fB\-o print\-quality=4\fR .TP 5 -\fB\-o page\-ranges=\fIpage-list\fR -Specifies which pages to print in the document. -The list can contain a list of numbers and ranges (#-#) separated by commas, e.g., "1,3-5,16". -The page numbers refer to the output pages and not the document's original pages - options like "number-up" can affect the numbering of the pages. +\fB\-o print\-quality=5\fR +Specifies the output quality - draft (3), normal (4), or best (5). .TP 5 \fB\-o sides=one\-sided\fR Prints on one side of the paper. @@ -243,10 +211,10 @@ Print a double-sided legal document to a printer called "foo": lp -d foo -o media=legal -o sides=two-sided-long-edge filename .fi -Print a presentation document 2-up to a printer called "foo": +Print a presentation document 2-up to a printer called "bar": .nf - lp -d foo -o number-up=2 filename + lp -d bar -o number-up=2 filename .fi .SH SEE ALSO .BR cancel (1), diff --git a/man/lpr.man b/man/lpr.man index c7d517705c..cae4ac0419 100644 --- a/man/lpr.man +++ b/man/lpr.man @@ -1,12 +1,13 @@ .\" .\" lpr man page for CUPS. .\" -.\" Copyright 2007-2016 by Apple Inc. -.\" Copyright 1997-2006 by Easy Software Products. +.\" Copyright © 2007-2018 by Apple Inc. +.\" Copyright © 1997-2006 by Easy Software Products. .\" -.\" Licensed under Apache License v2.0. See the file "LICENSE" for more information. +.\" Licensed under Apache License v2.0. See the file "LICENSE" for more +.\" information. .\" -.TH lpr 1 "CUPS" "2 May 2016" "Apple Inc." +.TH lpr 1 "CUPS" "6 December 2018" "Apple Inc." .SH NAME lpr \- print files .SH SYNOPSIS @@ -113,44 +114,16 @@ Aside from the printer-specific options reported by the .BR lpoptions (1) command, the following generic options are available: .TP 5 -\fB\-o collate=true\fR -Prints collated copies. -.TP 5 -\fB\-o fit\-to\-page\fR -Scales the print file to fit on the page. -.TP 5 -\fB\-o job-hold-until=\fIwhen\fR -Holds the job until the specified local time. -"when" can be "indefinite" to hold the until released, "day-time" to print the job between 6am and 6pm local time, "night" to print the job between 6pm and 6am local time, "second-shift" to print the job between 4pm and 12am local time, "third-shift" to print the job between 12am and 8am local time, or "weekend" to print the job on Saturday or Sunday. -.TP 5 -\fB\-o job-hold-until=\fIhh:mm\fR -Holds the job until the specified time in hours and minutes UTC. -.TP 5 -\fB\-o job-priority=\fIpriority\fR -Set the priority to a value from 1 (lowest) to 100 (highest), which influences when a job is scheduled for printing. -The default priority is typically 50. -.TP 5 \fB\-o job-sheets=\fIname\fR\fR Prints a cover page (banner) with the document. The "name" can be "classified", "confidential", "secret", "standard", "topsecret", or "unclassified". .TP 5 -\fB\-o job-sheets=\fIstart-name,end-name\fR\fR -Prints cover pages (banners) with the document. -.TP 5 \fB\-o media=\fIsize\fR Sets the page size to \fIsize\fR. Most printers support at least the size names "a4", "letter", and "legal". .TP 5 -\fB\-o mirror\fR -Mirrors each page. -.TP 5 \fB\-o number\-up=\fR{\fI2|4|6|9|16\fR} Prints 2, 4, 6, 9, or 16 document (input) pages on each output page. .TP 5 -\fB\-o number\-up\-layout=\fIlayout\fR -Specifies the layout of pages with the "number-up" option. -The "layout" string can be "btlr", "btrl", "lrbt", "lrtb", "rlbt", "rltb", "tblr", or "tbrl" - the first two letters determine the column order while the second two letters determine the row order. -"bt" is bottom-to-top, "lr" is left-to-right, "rl" is right-to-left, and "tb" is top-to-bottom. -.TP 5 \fB\-o orientation\-requested=4\fR Prints the job in landscape (rotated 90 degrees counter-clockwise). .TP 5 @@ -160,17 +133,12 @@ Prints the job in landscape (rotated 90 degrees clockwise). \fB\-o orientation\-requested=6\fR Prints the job in reverse portrait (rotated 180 degrees). .TP 5 -\fB\-o outputorder=reverse\fR -Prints pages in reverse order. +\fB\-o print\-quality=3\fR .TP 5 -\fB\-o page\-border=\fIborder\fR -Prints a border around each document page. -"border" is "double", "double\-thick", "single", or "single\-thick". +\fB\-o print\-quality=4\fR .TP 5 -\fB\-o page\-ranges=\fIpage-list\fR -Specifies which pages to print in the document. -The list can contain a list of numbers and ranges (#-#) separated by commas, e.g., "1,3-5,16". -The page numbers refer to the output pages and not the document's original pages - options like "number-up" can affect the numbering of the pages. +\fB\-o print\-quality=5\fR +Specifies the output quality - draft (3), normal (4), or best (5). .TP 5 \fB\-o sides=one\-sided\fR Prints on one side of the paper. diff --git a/systemv/cancel.c b/systemv/cancel.c index 7314aa6685..c85a86e0ca 100644 --- a/systemv/cancel.c +++ b/systemv/cancel.c @@ -1,10 +1,11 @@ /* * "cancel" command for CUPS. * - * Copyright 2007-2016 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products. + * Copyright © 2007-2018 by Apple Inc. + * Copyright © 1997-2006 by Easy Software Products. * - * Licensed under Apache License v2.0. See the file "LICENSE" for more information. + * Licensed under Apache License v2.0. See the file "LICENSE" for more + * information. */ /* @@ -14,6 +15,13 @@ #include +/* + * Local functions... + */ + +static void usage(void) _CUPS_NORETURN; + + /* * 'main()' - Parse options and cancel jobs. */ @@ -59,7 +67,9 @@ main(int argc, /* I - Number of command-line arguments */ for (i = 1; i < argc; i ++) { - if (argv[i][0] == '-' && argv[i][1]) + if (!strcmp(argv[i], "--help")) + usage(); + else if (argv[i][0] == '-' && argv[i][1]) { for (opt = argv[i] + 1; *opt; opt ++) { @@ -88,7 +98,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected username after \"-U\" option."), argv[0]); - return (1); + usage(); } cupsSetUser(argv[i]); @@ -118,7 +128,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected hostname after \"-h\" option."), argv[0]); - return (1); + usage(); } else cupsSetServer(argv[i]); @@ -140,7 +150,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected username after \"-u\" option."), argv[0]); - return (1); + usage(); } else user = argv[i]; @@ -376,3 +386,25 @@ main(int argc, /* I - Number of command-line arguments */ return (0); } + + +/* + * 'usage()' - Show program usage and exit. + */ + +static void +usage(void) +{ + _cupsLangPuts(stdout, _("Usage: cancel [options] [id]\n" + " cancel [options] [destination]\n" + " cancel [options] [destination-id]")); + _cupsLangPuts(stdout, _("Options:")); + _cupsLangPuts(stdout, _("-a Cancel all jobs")); + _cupsLangPuts(stdout, _("-E Encrypt the connection to the server")); + _cupsLangPuts(stdout, _("-h server[:port] Connect to the named server and port")); + _cupsLangPuts(stdout, _("-u owner Specify the owner to use for jobs")); + _cupsLangPuts(stdout, _("-U username Specify the username to use for authentication")); + _cupsLangPuts(stdout, _("-x Purge jobs rather than just canceling")); + + exit(1); +} diff --git a/systemv/cupsaccept.c b/systemv/cupsaccept.c index 7d597b386d..22fb01be19 100644 --- a/systemv/cupsaccept.c +++ b/systemv/cupsaccept.c @@ -2,10 +2,11 @@ * "cupsaccept", "cupsdisable", "cupsenable", and "cupsreject" commands for * CUPS. * - * Copyright 2007-2017 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products. + * Copyright © 2007-2018 by Apple Inc. + * Copyright © 1997-2006 by Easy Software Products. * - * Licensed under Apache License v2.0. See the file "LICENSE" for more information. + * Licensed under Apache License v2.0. See the file "LICENSE" for more + * information. */ /* @@ -15,6 +16,13 @@ #include +/* + * Local functions... + */ + +static void usage(const char *command) _CUPS_NORETURN; + + /* * 'main()' - Parse options and accept/reject jobs or disable/enable printers. */ @@ -46,13 +54,13 @@ main(int argc, /* I - Number of command-line arguments */ cancel = 0; - if (!strcmp(command, "cupsaccept") || !strcmp(command, "accept")) + if (!strcmp(command, "cupsaccept")) op = CUPS_ACCEPT_JOBS; - else if (!strcmp(command, "cupsreject") || !strcmp(command, "reject")) + else if (!strcmp(command, "cupsreject")) op = CUPS_REJECT_JOBS; - else if (!strcmp(command, "cupsdisable") || !strcmp(command, "disable")) + else if (!strcmp(command, "cupsdisable")) op = IPP_PAUSE_PRINTER; - else if (!strcmp(command, "cupsenable") || !strcmp(command, "enable")) + else if (!strcmp(command, "cupsenable")) op = IPP_RESUME_PRINTER; else { @@ -68,7 +76,9 @@ main(int argc, /* I - Number of command-line arguments */ for (i = 1; i < argc; i ++) { - if (!strcmp(argv[i], "--hold")) + if (!strcmp(argv[i], "--help")) + usage(command); + else if (!strcmp(argv[i], "--hold")) op = IPP_HOLD_NEW_JOBS; else if (!strcmp(argv[i], "--release")) op = IPP_RELEASE_HELD_NEW_JOBS; @@ -98,7 +108,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected username after \"-U\" option."), command); - return (1); + usage(command); } cupsSetUser(argv[i]); @@ -121,7 +131,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected hostname after \"-h\" option."), command); - return (1); + usage(command); } cupsSetServer(argv[i]); @@ -140,7 +150,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected reason text after \"-r\" option."), command); - return (1); + usage(command); } reason = argv[i]; @@ -149,7 +159,7 @@ main(int argc, /* I - Number of command-line arguments */ default : _cupsLangPrintf(stderr, _("%s: Error - unknown option \"%c\"."), command, *opt); - return (1); + usage(command); } } } @@ -220,3 +230,25 @@ main(int argc, /* I - Number of command-line arguments */ return (0); } + + +/* + * 'usage()' - Show program usage and exit. + */ + +static void +usage(const char *command) /* I - Command name */ +{ + _cupsLangPrintf(stdout, _("Usage: %s [options] destination(s)"), command); + _cupsLangPuts(stdout, _("Options:")); + _cupsLangPuts(stdout, _("-E Encrypt the connection to the server")); + _cupsLangPuts(stdout, _("-h server[:port] Connect to the named server and port")); + _cupsLangPuts(stdout, _("-r reason Specify a reason message that others can see")); + _cupsLangPuts(stdout, _("-U username Specify the username to use for authentication")); + if (!strcmp(command, "cupsdisable")) + _cupsLangPuts(stdout, _("--hold Hold new jobs")); + if (!strcmp(command, "cupsenable")) + _cupsLangPuts(stdout, _("--release Release previously held jobs")); + + exit(1); +} diff --git a/systemv/cupsctl.c b/systemv/cupsctl.c index 053029b239..efbd4ba5b7 100644 --- a/systemv/cupsctl.c +++ b/systemv/cupsctl.c @@ -1,10 +1,11 @@ /* * Scheduler control program for CUPS. * - * Copyright 2007-2012 by Apple Inc. - * Copyright 2006-2007 by Easy Software Products. + * Copyright © 2007-2018 by Apple Inc. + * Copyright © 2006-2007 by Easy Software Products. * - * Licensed under Apache License v2.0. See the file "LICENSE" for more information. + * Licensed under Apache License v2.0. See the file "LICENSE" for more + * information. */ /* @@ -48,7 +49,9 @@ main(int argc, /* I - Number of command-line args */ for (i = 1; i < argc; i ++) { - if (argv[i][0] == '-') + if (!strcmp(argv[i], "--help")) + usage(NULL); + else if (argv[i][0] == '-') { if (argv[i][1] == '-') { @@ -184,26 +187,16 @@ usage(const char *opt) /* I - Option character/string */ _cupsLangPrintf(stderr, _("cupsctl: Unknown option \"-%c\""), *opt); } - _cupsLangPuts(stdout, _("Usage: cupsctl [options] [param=value ... " - "paramN=valueN]")); - _cupsLangPuts(stdout, ""); + _cupsLangPuts(stdout, _("Usage: cupsctl [options] [param=value ... paramN=valueN]")); _cupsLangPuts(stdout, _("Options:")); - _cupsLangPuts(stdout, ""); - _cupsLangPuts(stdout, _(" -E Encrypt the connection.")); - _cupsLangPuts(stdout, _(" -U username Specify username.")); - _cupsLangPuts(stdout, _(" -h server[:port] Specify server " - "address.")); - _cupsLangPuts(stdout, ""); - _cupsLangPuts(stdout, _(" --[no-]debug-logging Turn debug logging " - "on/off.")); - _cupsLangPuts(stdout, _(" --[no-]remote-admin Turn remote " - "administration on/off.")); - _cupsLangPuts(stdout, _(" --[no-]remote-any Allow/prevent access " - "from the Internet.")); - _cupsLangPuts(stdout, _(" --[no-]share-printers Turn printer sharing " - "on/off.")); - _cupsLangPuts(stdout, _(" --[no-]user-cancel-any Allow/prevent users to " - "cancel any job.")); + _cupsLangPuts(stdout, _("-E Encrypt the connection to the server")); + _cupsLangPuts(stdout, _("-h server[:port] Connect to the named server and port")); + _cupsLangPuts(stdout, _("-U username Specify username to use for authentication")); + _cupsLangPuts(stdout, _("--[no-]debug-logging Turn debug logging on/off")); + _cupsLangPuts(stdout, _("--[no-]remote-admin Turn remote administration on/off")); + _cupsLangPuts(stdout, _("--[no-]remote-any Allow/prevent access from the Internet")); + _cupsLangPuts(stdout, _("--[no-]share-printers Turn printer sharing on/off")); + _cupsLangPuts(stdout, _("--[no-]user-cancel-any Allow/prevent users to cancel any job")); exit(1); } diff --git a/systemv/cupstestppd.c b/systemv/cupstestppd.c index 8e498a5962..b94cae9440 100644 --- a/systemv/cupstestppd.c +++ b/systemv/cupstestppd.c @@ -1,10 +1,13 @@ /* * PPD test program for CUPS. * - * Copyright 2007-2016 by Apple Inc. - * Copyright 1997-2007 by Easy Software Products, all rights reserved. + * THIS PROGRAM IS DEPRECATED AND WILL BE REMOVED IN A FUTURE VERSION OF CUPS. * - * Licensed under Apache License v2.0. See the file "LICENSE" for more information. + * Copyright © 2007-2018 by Apple Inc. + * Copyright © 1997-2007 by Easy Software Products, all rights reserved. + * + * Licensed under Apache License v2.0. See the file "LICENSE" for more + * information. * * PostScript is a trademark of Adobe Systems, Inc. */ @@ -164,7 +167,9 @@ main(int argc, /* I - Number of command-line args */ ignore = WARN_NONE; for (i = 1; i < argc; i ++) - if (argv[i][0] == '-' && argv[i][1]) + if (!strcmp(argv[i], "--help")) + usage(); + else if (argv[i][0] == '-' && argv[i][1]) { for (opt = argv[i] + 1; *opt; opt ++) switch (*opt) @@ -3846,23 +3851,19 @@ test_raster(ppd_file_t *ppd, /* I - PPD file */ static void usage(void) { - _cupsLangPuts(stdout, _("Usage: cupstestppd [options] filename1.ppd[.gz] " - "[... filenameN.ppd[.gz]]")); - _cupsLangPuts(stdout, _(" program | cupstestppd [options] -")); - _cupsLangPuts(stdout, ""); + _cupsLangPuts(stdout, _("Warning: This program will be removed in a future version of CUPS.")); + _cupsLangPuts(stdout, _("Usage: cupstestppd [options] filename1.ppd[.gz] [... filenameN.ppd[.gz]]\n" + " program | cupstestppd [options] -")); _cupsLangPuts(stdout, _("Options:")); - _cupsLangPuts(stdout, ""); - _cupsLangPuts(stdout, _(" -I {filename,filters,none,profiles}")); - _cupsLangPuts(stdout, _(" Ignore specific warnings.")); - _cupsLangPuts(stdout, _(" -R root-directory Set alternate root.")); - _cupsLangPuts(stdout, _(" -W {all,none,constraints,defaults,duplex," - "filters,profiles,sizes,translations}")); - _cupsLangPuts(stdout, _(" Issue warnings instead of " - "errors.")); - _cupsLangPuts(stdout, _(" -q Run silently.")); - _cupsLangPuts(stdout, _(" -r Use 'relaxed' open mode.")); - _cupsLangPuts(stdout, _(" -v Be verbose.")); - _cupsLangPuts(stdout, _(" -vv Be very verbose.")); + _cupsLangPuts(stdout, _("-I {filename,filters,none,profiles}\n" + " Ignore specific warnings")); + _cupsLangPuts(stdout, _("-R root-directory Set alternate root")); + _cupsLangPuts(stdout, _("-W {all,none,constraints,defaults,duplex,filters,profiles,sizes,translations}\n" + " Issue warnings instead of errors")); + _cupsLangPuts(stdout, _("-q Run silently")); + _cupsLangPuts(stdout, _("-r Use 'relaxed' open mode")); + _cupsLangPuts(stdout, _("-v Be verbose")); + _cupsLangPuts(stdout, _("-vv Be very verbose")); exit(ERROR_USAGE); } diff --git a/systemv/lp.c b/systemv/lp.c index 5786d645bf..ad22715b26 100644 --- a/systemv/lp.c +++ b/systemv/lp.c @@ -1,10 +1,11 @@ /* * "lp" command for CUPS. * - * Copyright 2007-2017 by Apple Inc. - * Copyright 1997-2007 by Easy Software Products. + * Copyright © 2007-2018 by Apple Inc. + * Copyright © 1997-2007 by Easy Software Products. * - * Licensed under Apache License v2.0. See the file "LICENSE" for more information. + * Licensed under Apache License v2.0. See the file "LICENSE" for more + * information. */ /* @@ -18,9 +19,9 @@ * Local functions. */ -int restart_job(const char *command, int job_id); -int set_job_attrs(const char *command, int job_id, int num_options, - cups_option_t *options); +static int restart_job(const char *command, int job_id); +static int set_job_attrs(const char *command, int job_id, int num_options, cups_option_t *options); +static void usage(void) _CUPS_NORETURN; /* @@ -82,7 +83,9 @@ main(int argc, /* I - Number of command-line arguments */ for (i = 1; i < argc; i ++) { - if (argv[i][0] == '-' && argv[i][1] && !end_options) + if (!strcmp(argv[i], "--help")) + usage(); + else if (argv[i][0] == '-' && argv[i][1] && !end_options) { for (opt = argv[i] + 1; *opt; opt ++) { @@ -108,7 +111,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected username after \"-U\" option."), argv[0]); - return (1); + usage(); } cupsSetUser(argv[i]); @@ -131,7 +134,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected destination after \"-d\" option."), argv[0]); - return (1); + usage(); } printer = argv[i]; @@ -172,7 +175,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected form after \"-f\" option."), argv[0]); - return (1); + usage(); } } @@ -192,7 +195,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected hostname after \"-h\" option."), argv[0]); - return (1); + usage(); } cupsSetServer(argv[i]); @@ -212,7 +215,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Expected job ID after \"-i\" option."), argv[0]); - return (1); + usage(); } val = argv[i]; @@ -265,7 +268,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected copies after \"-n\" option."), argv[0]); - return (1); + usage(); } num_copies = atoi(argv[i]); @@ -295,7 +298,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected option=value after \"-o\" option."), argv[0]); - return (1); + usage(); } num_options = cupsParseOptions(argv[i], num_options, &options); @@ -316,7 +319,7 @@ main(int argc, /* I - Number of command-line arguments */ if ((i + 1) >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected priority after \"-%c\" option."), argv[0], *opt); - return (1); + usage(); } i ++; @@ -361,7 +364,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected title after \"-t\" option."), argv[0]); - return (1); + usage(); } title = argv[i]; @@ -380,7 +383,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected mode list after \"-y\" option."), argv[0]); - return (1); + usage(); } } @@ -400,7 +403,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected hold name after \"-H\" option."), argv[0]); - return (1); + usage(); } val = argv[i]; @@ -443,7 +446,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected page list after \"-P\" option."), argv[0]); - return (1); + usage(); } val = argv[i]; @@ -464,7 +467,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected character set after \"-S\" option."), argv[0]); - return (1); + usage(); } } @@ -483,7 +486,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected content type after \"-T\" option."), argv[0]); - return (1); + usage(); } } @@ -494,7 +497,7 @@ main(int argc, /* I - Number of command-line arguments */ if (opt[1] != '\0') { _cupsLangPrintf(stderr, _("%s: Error - unknown option \"%s\"."), argv[0], argv[i]); - return (1); + usage(); } end_options = 1; @@ -502,7 +505,7 @@ main(int argc, /* I - Number of command-line arguments */ default : _cupsLangPrintf(stderr, _("%s: Error - unknown option \"%c\"."), argv[0], *opt); - return (1); + usage(); } } } @@ -647,7 +650,7 @@ main(int argc, /* I - Number of command-line arguments */ * 'restart_job()' - Restart a job. */ -int /* O - Exit status */ +static int /* O - Exit status */ restart_job(const char *command, /* I - Command name */ int job_id) /* I - Job ID */ { @@ -689,11 +692,12 @@ restart_job(const char *command, /* I - Command name */ * 'set_job_attrs()' - Set job attributes. */ -int /* O - Exit status */ -set_job_attrs(const char *command, /* I - Command name */ - int job_id, /* I - Job ID */ - int num_options,/* I - Number of options */ - cups_option_t *options) /* I - Options */ +static int /* O - Exit status */ +set_job_attrs( + const char *command, /* I - Command name */ + int job_id, /* I - Job ID */ + int num_options, /* I - Number of options */ + cups_option_t *options) /* I - Options */ { ipp_t *request; /* IPP request */ char uri[HTTP_MAX_URI]; /* URI for job */ @@ -732,3 +736,47 @@ set_job_attrs(const char *command, /* I - Command name */ return (0); } + + +/* + * 'usage()' - Show program usage and exit. + */ + +static void +usage(void) +{ + _cupsLangPuts(stdout, _("Usage: lp [options] [--] [file(s)]\n" + " lp [options] -i id")); + _cupsLangPuts(stdout, _("Options:")); + _cupsLangPuts(stdout, _("-c Make a copy of the print file(s)")); + _cupsLangPuts(stdout, _("-E Encrypt the connection to the server")); + _cupsLangPuts(stdout, _("-h server[:port] Connect to the named server and port")); + _cupsLangPuts(stdout, _("-H HH:MM Hold the job until the specified UTC time")); + _cupsLangPuts(stdout, _("-H hold Hold the job until released/resumed")); + _cupsLangPuts(stdout, _("-H immediate Print the job as soon as possible")); + _cupsLangPuts(stdout, _("-H restart Reprint the job")); + _cupsLangPuts(stdout, _("-H resume Resume a held job")); + _cupsLangPuts(stdout, _("-i id Specify an existing job ID to modify")); + _cupsLangPuts(stdout, _("-m Send an email notification when the job completes")); + _cupsLangPuts(stdout, _("-n num-copies Specify the number of copies to print")); + _cupsLangPuts(stdout, _("-o option[=value] Specify a printer-specific option")); + _cupsLangPuts(stdout, _("-o job-sheets=standard Print a banner page with the job")); + _cupsLangPuts(stdout, _("-o media=size Specify the media size to use")); + _cupsLangPuts(stdout, _("-o number-up=N Specify that input pages should be printed N-up (1, 2, 4, 6, 9, and 16 are supported)")); + _cupsLangPuts(stdout, _("-o orientation-requested=N\n" + " Specify portrait (3) or landscape (4) orientation")); + _cupsLangPuts(stdout, _("-o print-quality=N Specify the print quality - draft (3), normal (4), or best (5)")); + _cupsLangPuts(stdout, _("-o sides=one-sided Specify 1-sided printing")); + _cupsLangPuts(stdout, _("-o sides=two-sided-long-edge\n" + " Specify 2-sided portrait printing")); + _cupsLangPuts(stdout, _("-o sides=two-sided-short-edge\n" + " Specify 2-sided landscape printing")); + _cupsLangPuts(stdout, _("-P page-list Specify a list of pages to print")); + _cupsLangPuts(stdout, _("-q priority Specify the priority from low (1) to high (100)")); + _cupsLangPuts(stdout, _("-s Be silent")); + _cupsLangPuts(stdout, _("-t title Specify the job title")); + _cupsLangPuts(stdout, _("-U username Specify the username to use for authentication")); + + + exit(1); +} diff --git a/systemv/lpadmin.c b/systemv/lpadmin.c index 7443023693..733559c2a5 100644 --- a/systemv/lpadmin.c +++ b/systemv/lpadmin.c @@ -4,7 +4,8 @@ * Copyright © 2007-2018 by Apple Inc. * Copyright © 1997-2006 by Easy Software Products. * - * Licensed under Apache License v2.0. See the file "LICENSE" for more information. + * Licensed under Apache License v2.0. See the file "LICENSE" for more + * information. */ /* @@ -33,6 +34,7 @@ static cups_ptype_t get_printer_type(http_t *http, char *printer, char *uri, static int set_printer_options(http_t *http, char *printer, int num_options, cups_option_t *options, char *file, int enable); +static void usage(void) _CUPS_NORETURN; static int validate_name(const char *name); @@ -69,7 +71,9 @@ main(int argc, /* I - Number of command-line arguments */ for (i = 1; i < argc; i ++) { - if (argv[i][0] == '-') + if (!strcmp(argv[i], "--help")) + usage(); + else if (argv[i][0] == '-') { for (opt = argv[i] + 1; *opt; opt ++) { @@ -107,7 +111,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPuts(stderr, _("lpadmin: Expected class name after \"-c\" option.")); - return (1); + usage(); } pclass = argv[i]; @@ -149,7 +153,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPuts(stderr, _("lpadmin: Expected printer name after \"-d\" option.")); - return (1); + usage(); } printer = argv[i]; @@ -186,7 +190,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPuts(stderr, _("lpadmin: Expected hostname after \"-h\" option.")); - return (1); + usage(); } cupsSetServer(argv[i]); @@ -207,7 +211,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("lpadmin: Expected PPD after \"-%c\" option."), argv[i - 1][1]); - return (1); + usage(); } file = argv[i]; @@ -276,7 +280,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPuts(stderr, _("lpadmin: Expected model after \"-m\" option.")); - return (1); + usage(); } num_options = cupsAddOption("ppd-name", argv[i], num_options, &options); @@ -296,7 +300,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPuts(stderr, _("lpadmin: Expected name=value after \"-o\" option.")); - return (1); + usage(); } num_options = cupsParseOptions(argv[i], num_options, &options); @@ -316,7 +320,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPuts(stderr, _("lpadmin: Expected printer after \"-p\" option.")); - return (1); + usage(); } printer = argv[i]; @@ -363,7 +367,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPuts(stderr, _("lpadmin: Expected class after \"-r\" option.")); - return (1); + usage(); } pclass = argv[i]; @@ -411,7 +415,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPuts(stderr, _("lpadmin: Expected name after \"-R\" option.")); - return (1); + usage(); } val = argv[i]; @@ -433,7 +437,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected username after \"-U\" option."), argv[0]); - return (1); + usage(); } cupsSetUser(argv[i]); @@ -453,7 +457,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPuts(stderr, _("lpadmin: Expected allow/deny:userlist after \"-u\" option.")); - return (1); + usage(); } val = argv[i]; @@ -483,7 +487,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPuts(stderr, _("lpadmin: Expected device URI after \"-v\" option.")); - return (1); + usage(); } num_options = cupsAddOption("device-uri", argv[i], num_options, &options); @@ -516,7 +520,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPuts(stderr, _("lpadmin: Expected printer or class after \"-x\" option.")); - return (1); + usage(); } printer = argv[i]; @@ -547,7 +551,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPuts(stderr, _("lpadmin: Expected description after \"-D\" option.")); - return (1); + usage(); } num_options = cupsAddOption("printer-info", argv[i], num_options, &options); @@ -560,7 +564,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPuts(stderr, _("lpadmin: Expected file type(s) after \"-I\" option.")); - return (1); + usage(); } _cupsLangPuts(stderr, _("lpadmin: Warning - content type list ignored.")); @@ -579,7 +583,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPuts(stderr, _("lpadmin: Expected location after \"-L\" option.")); - return (1); + usage(); } num_options = cupsAddOption("printer-location", argv[i], num_options, &options); @@ -588,14 +592,14 @@ main(int argc, /* I - Number of command-line arguments */ default : _cupsLangPrintf(stderr, _("lpadmin: Unknown option \"%c\"."), *opt); - return (1); + usage(); } } } else { _cupsLangPrintf(stderr, _("lpadmin: Unknown argument \"%s\"."), argv[i]); - return (1); + usage(); } } @@ -1611,6 +1615,58 @@ set_printer_options( } +/* + * 'usage()' - Show program usage and exit. + */ + +static void +usage(void) +{ + _cupsLangPuts(stdout, _("Usage: lpadmin [options] -d destination\n" + " lpadmin [options] -p destination\n" + " lpadmin [options] -p destination -c class\n" + " lpadmin [options] -p destination -r class\n" + " lpadmin [options] -x destination")); + _cupsLangPuts(stdout, _("Options:")); + _cupsLangPuts(stdout, _("-c class Add the named destination to a class")); + _cupsLangPuts(stdout, _("-d destination Set the named destination as the server default")); + _cupsLangPuts(stdout, _("-D description Specify the textual description of the printer")); + _cupsLangPuts(stdout, _("-E Encrypt the connection to the server")); + _cupsLangPuts(stdout, _("-E Enable and accept jobs on the printer (after -p)")); + _cupsLangPuts(stdout, _("-h server[:port] Connect to the named server and port")); + _cupsLangPuts(stdout, _("-i ppd-file Specify a PPD file for the printer")); + _cupsLangPuts(stdout, _("-L location Specify the textual location of the printer")); + _cupsLangPuts(stdout, _("-m model Specify a standard model/PPD file for the printer")); + _cupsLangPuts(stdout, _("-m everywhere Specify the printer is compatible with IPP Everywhere™")); + _cupsLangPuts(stdout, _("-o name-default=value Specify the default value for the named option")); + _cupsLangPuts(stdout, _("-o Name=Value Specify the default value for the named PPD option ")); + _cupsLangPuts(stdout, _("-o cupsIPPSupplies=false\n" + " Disable supply level reporting via IPP")); + _cupsLangPuts(stdout, _("-o cupsSNMPSupplies=false\n" + " Disable supply level reporting via SNMP")); + _cupsLangPuts(stdout, _("-o job-k-limit=N Specify the kilobyte limit for per-user quotas")); + _cupsLangPuts(stdout, _("-o job-page-limit=N Specify the page limit for per-user quotas")); + _cupsLangPuts(stdout, _("-o job-quota-period=N Specify the per-user quota period in seconds")); + _cupsLangPuts(stdout, _("-o printer-error-policy=name\n" + " Specify the printer error policy")); + _cupsLangPuts(stdout, _("-o printer-is-shared=true\n" + " Share the printer")); + _cupsLangPuts(stdout, _("-o printer-op-policy=name\n" + " Specify the printer operation policy")); + _cupsLangPuts(stdout, _("-p destination Specify/add the named destination")); + _cupsLangPuts(stdout, _("-r class Remove the named destination from a class")); + _cupsLangPuts(stdout, _("-R name-default Remove the default value for the named option")); + _cupsLangPuts(stdout, _("-u allow:all Allow all users to print")); + _cupsLangPuts(stdout, _("-u allow:list Allow the list of users or groups (@name) to print")); + _cupsLangPuts(stdout, _("-u deny:list Prevent the list of users or groups (@name) to print")); + _cupsLangPuts(stdout, _("-U username Specify the username to use for authentication")); + _cupsLangPuts(stdout, _("-v device-uri Specify the device URI for the printer")); + _cupsLangPuts(stdout, _("-x destination Remove the named destination")); + + exit(1); +} + + /* * 'validate_name()' - Make sure the printer name only contains valid chars. */ diff --git a/systemv/lpinfo.c b/systemv/lpinfo.c index c52b04292b..bb4db59677 100644 --- a/systemv/lpinfo.c +++ b/systemv/lpinfo.c @@ -1,10 +1,11 @@ /* * "lpinfo" command for CUPS. * - * Copyright 2007-2017 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products. + * Copyright © 2007-2018 by Apple Inc. + * Copyright © 1997-2006 by Easy Software Products. * - * Licensed under Apache License v2.0. See the file "LICENSE" for more information. + * Licensed under Apache License v2.0. See the file "LICENSE" for more + * information. */ /* @@ -32,6 +33,7 @@ static int show_models(int long_status, const char *make_model, const char *product, const char *include_schemes, const char *exclude_schemes); +static void usage(void) _CUPS_NORETURN; /* @@ -76,7 +78,7 @@ main(int argc, /* I - Number of command-line arguments */ else { _cupsLangPuts(stderr, _("lpinfo: Expected 1284 device ID string after \"--device-id\".")); - return (1); + usage(); } } else if (!strncmp(argv[i], "--device-id=", 12) && argv[i][12]) @@ -92,13 +94,15 @@ main(int argc, /* I - Number of command-line arguments */ else { _cupsLangPuts(stderr, _("lpinfo: Expected scheme list after \"--exclude-schemes\".")); - return (1); + usage(); } } else if (!strncmp(argv[i], "--exclude-schemes=", 18) && argv[i][18]) { exclude_schemes = argv[i] + 18; } + else if (!strcmp(argv[i], "--help")) + usage(); else if (!strcmp(argv[i], "--include-schemes")) { i ++; @@ -108,7 +112,7 @@ main(int argc, /* I - Number of command-line arguments */ else { _cupsLangPuts(stderr, _("lpinfo: Expected scheme list after \"--include-schemes\".")); - return (1); + usage(); } } else if (!strncmp(argv[i], "--include-schemes=", 18) && argv[i][18]) @@ -123,7 +127,7 @@ main(int argc, /* I - Number of command-line arguments */ else { _cupsLangPuts(stderr, _("lpinfo: Expected language after \"--language\".")); - return (1); + usage(); } } else if (!strncmp(argv[i], "--language=", 11) && argv[i][11]) @@ -138,7 +142,7 @@ main(int argc, /* I - Number of command-line arguments */ else { _cupsLangPuts(stderr, _("lpinfo: Expected make and model after \"--make-and-model\".")); - return (1); + usage(); } } else if (!strncmp(argv[i], "--make-and-model=", 17) && argv[i][17]) @@ -153,7 +157,7 @@ main(int argc, /* I - Number of command-line arguments */ else { _cupsLangPuts(stderr, _("lpinfo: Expected product string after \"--product\".")); - return (1); + usage(); } } else if (!strncmp(argv[i], "--product=", 10) && argv[i][10]) @@ -168,7 +172,7 @@ main(int argc, /* I - Number of command-line arguments */ else { _cupsLangPuts(stderr, _("lpinfo: Expected timeout after \"--timeout\".")); - return (1); + usage(); } } else if (!strncmp(argv[i], "--timeout=", 10) && argv[i][10]) @@ -202,7 +206,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPuts(stderr, _("Error: need hostname after \"-h\" option.")); - return (1); + usage(); } cupsSetServer(argv[i]); @@ -225,14 +229,14 @@ main(int argc, /* I - Number of command-line arguments */ default : _cupsLangPrintf(stderr, _("%s: Unknown option \"%c\"."), argv[0], *opt); - return (1); + usage(); } } } else { _cupsLangPrintf(stderr, _("%s: Unknown argument \"%s\"."), argv[0], argv[i]); - return (1); + usage(); } } @@ -464,7 +468,7 @@ show_models( " natural_language = %s\n" " make-and-model = %s\n" " device-id = %s"), - "everywhere", cupsLangDefault()->language, "IPP Everywhere", "CMD:PwgRaster"); + "everywhere", cupsLangDefault()->language, "IPP Everywhere™", "CMD:PwgRaster"); } else _cupsLangPuts(stdout, "everywhere IPP Everywhere"); @@ -479,3 +483,33 @@ show_models( return (0); } + + +/* + * 'usage()' - Show program usage and exit. + */ + +static void +usage(void) +{ + _cupsLangPuts(stdout, _("Usage: lpinfo [options] -m\n" + " lpinfo [options] -v")); + _cupsLangPuts(stdout, _("Options:")); + _cupsLangPuts(stdout, _("-E Encrypt the connection to the server")); + _cupsLangPuts(stdout, _("-h server[:port] Connect to the named server and port")); + _cupsLangPuts(stdout, _("-l Show verbose (long) output")); + _cupsLangPuts(stdout, _("-m Show models")); + _cupsLangPuts(stdout, _("-U username Specify the username to use for authentication")); + _cupsLangPuts(stdout, _("-v Show devices")); + _cupsLangPuts(stdout, _("--device-id device-id Show models matching the given IEEE 1284 device ID")); + _cupsLangPuts(stdout, _("--exclude-schemes scheme-list\n" + " Exclude the specified URI schemes")); + _cupsLangPuts(stdout, _("--include-schemes scheme-list\n" + " Include only the specified URI schemes")); + _cupsLangPuts(stdout, _("--language locale Show models matching the given locale")); + _cupsLangPuts(stdout, _("--make-and-model name Show models matching the given make and model name")); + _cupsLangPuts(stdout, _("--product name Show models matching the given PostScript product")); + _cupsLangPuts(stdout, _("--timeout seconds Specify the maximum number of seconds to discover devices")); + + exit(1); +} diff --git a/systemv/lpmove.c b/systemv/lpmove.c index fa8a863ff3..126db5fc05 100644 --- a/systemv/lpmove.c +++ b/systemv/lpmove.c @@ -1,10 +1,11 @@ /* * "lpmove" command for CUPS. * - * Copyright 2007-2016 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products. + * Copyright © 2007-2018 by Apple Inc. + * Copyright © 1997-2006 by Easy Software Products. * - * Licensed under Apache License v2.0. See the file "LICENSE" for more information. + * Licensed under Apache License v2.0. See the file "LICENSE" for more + * information. */ /* @@ -18,8 +19,8 @@ * Local functions... */ -static int move_job(http_t *http, const char *src, int jobid, - const char *dest); +static int move_job(http_t *http, const char *src, int jobid, const char *dest); +static void usage(void) _CUPS_NORETURN; /* @@ -52,7 +53,9 @@ main(int argc, /* I - Number of command-line arguments */ for (i = 1; i < argc; i ++) { - if (argv[i][0] == '-') + if (!strcmp(argv[i], "--help")) + usage(); + else if (argv[i][0] == '-') { for (opt = argv[i] + 1; *opt; opt ++) { @@ -80,7 +83,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPuts(stderr, _("Error: need hostname after \"-h\" option.")); - return (1); + usage(); } cupsSetServer(argv[i]); @@ -89,7 +92,7 @@ main(int argc, /* I - Number of command-line arguments */ default : _cupsLangPrintf(stderr, _("%s: Unknown option \"%c\"."), argv[0], *opt); - return (1); + usage(); } } } @@ -112,15 +115,12 @@ main(int argc, /* I - Number of command-line arguments */ else { _cupsLangPrintf(stderr, _("lpmove: Unknown argument \"%s\"."), argv[i]); - return (1); + usage(); } } if ((!jobid && !src) || !dest) - { - _cupsLangPuts(stdout, _("Usage: lpmove job/src dest")); - return (1); - } + usage(); http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption()); @@ -202,3 +202,21 @@ move_job(http_t *http, /* I - HTTP connection to server */ else return (0); } + + +/* + * 'usage()' - Show program usage and exit. + */ + +static void +usage(void) +{ + _cupsLangPuts(stdout, _("Usage: lpmove [options] job destination\n" + " lpmove [options] source-destination destination")); + _cupsLangPuts(stdout, _("Options:")); + _cupsLangPuts(stdout, _("-E Encrypt the connection to the server")); + _cupsLangPuts(stdout, _("-h server[:port] Connect to the named server and port")); + _cupsLangPuts(stdout, _("-U username Specify the username to use for authentication")); + + exit(1); +} diff --git a/systemv/lpoptions.c b/systemv/lpoptions.c index 0712c908d8..08746c000c 100644 --- a/systemv/lpoptions.c +++ b/systemv/lpoptions.c @@ -61,7 +61,9 @@ main(int argc, /* I - Number of command-line arguments */ for (i = 1; i < argc; i ++) { - if (argv[i][0] == '-') + if (!strcmp(argv[i], "--help")) + usage(); + else if (argv[i][0] == '-') { for (opt = argv[i] + 1; *opt; opt ++) { @@ -529,12 +531,19 @@ list_options(cups_dest_t *dest) /* I - Destination to list */ static void usage(void) { - _cupsLangPuts(stdout, - _("Usage: lpoptions [-h server] [-E] -d printer\n" - " lpoptions [-h server] [-E] [-p printer] -l\n" - " lpoptions [-h server] [-E] -p printer -o " - "option[=value] ...\n" - " lpoptions [-h server] [-E] -x printer")); + _cupsLangPuts(stdout, _("Usage: lpoptions [options] -d destination\n" + " lpoptions [options] [-p destination] [-l]\n" + " lpoptions [options] [-p destination] -o option[=value]\n" + " lpoptions [options] -x destination")); + _cupsLangPuts(stdout, _("Options:")); + _cupsLangPuts(stdout, _("-d destination Set default destination")); + _cupsLangPuts(stdout, _("-E Encrypt the connection to the server")); + _cupsLangPuts(stdout, _("-h server[:port] Connect to the named server and port")); + _cupsLangPuts(stdout, _("-l Show supported options and values")); + _cupsLangPuts(stdout, _("-o name[=value] Set default option and value")); + _cupsLangPuts(stdout, _("-p destination Specify a destination")); + _cupsLangPuts(stdout, _("-U username Specify the username to use for authentication")); + _cupsLangPuts(stdout, _("-x destination Remove default options for destination")); exit(1); } diff --git a/systemv/lpstat.c b/systemv/lpstat.c index d6aa45e786..1d14cb8e07 100644 --- a/systemv/lpstat.c +++ b/systemv/lpstat.c @@ -1,10 +1,11 @@ /* * "lpstat" command for CUPS. * - * Copyright 2007-2017 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products. + * Copyright © 2007-2018 by Apple Inc. + * Copyright © 1997-2006 by Easy Software Products. * - * Licensed under Apache License v2.0. See the file "LICENSE" for more information. + * Licensed under Apache License v2.0. See the file "LICENSE" for more + * information. */ /* @@ -32,6 +33,7 @@ static int show_jobs(const char *dests, const char *users, int long_status, static int show_printers(const char *printers, int num_dests, cups_dest_t *dests, int long_status); static void show_scheduler(void); +static void usage(void) _CUPS_NORETURN; /* @@ -69,7 +71,9 @@ main(int argc, /* I - Number of command-line arguments */ for (i = 1; i < argc; i ++) { - if (argv[i][0] == '-') + if (!strcmp(argv[i], "--help")) + usage(); + else if (argv[i][0] == '-') { for (opt = argv[i] + 1; *opt; opt ++) { @@ -123,7 +127,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected username after \"-U\" option."), argv[0]); - return (1); + usage(); } cupsSetUser(argv[i]); @@ -143,7 +147,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - need \"completed\", \"not-completed\", or \"all\" after \"-W\" option."), argv[0]); - return (1); + usage(); } which = argv[i]; @@ -152,7 +156,7 @@ main(int argc, /* I - Number of command-line arguments */ if (strcmp(which, "completed") && strcmp(which, "not-completed") && strcmp(which, "all")) { _cupsLangPrintf(stderr, _("%s: Error - need \"completed\", \"not-completed\", or \"all\" after \"-W\" option."), argv[0]); - return (1); + usage(); } break; @@ -481,7 +485,7 @@ main(int argc, /* I - Number of command-line arguments */ default : _cupsLangPrintf(stderr, _("%s: Error - unknown option \"%c\"."), argv[0], argv[i][1]); - return (1); + usage(); } } } @@ -2027,3 +2031,37 @@ show_scheduler(void) else _cupsLangPuts(stdout, _("scheduler is not running")); } + + +/* + * 'usage()' - Show program usage and exit. + */ + +static void +usage(void) +{ + _cupsLangPuts(stdout, _("Usage: lpstat [options]")); + _cupsLangPuts(stdout, _("Options:")); + _cupsLangPuts(stdout, _("-E Encrypt the connection to the server")); + _cupsLangPuts(stdout, _("-h server[:port] Connect to the named server and port")); + _cupsLangPuts(stdout, _("-l Show verbose (long) output")); + _cupsLangPuts(stdout, _("-U username Specify the username to use for authentication")); + + _cupsLangPuts(stdout, _("-H Show the default server and port")); + _cupsLangPuts(stdout, _("-W completed Show completed jobs")); + _cupsLangPuts(stdout, _("-W not-completed Show pending jobs")); + _cupsLangPuts(stdout, _("-a [destination(s)] Show the accepting state of destinations")); + _cupsLangPuts(stdout, _("-c [class(es)] Show classes and their member printers")); + _cupsLangPuts(stdout, _("-d Show the default destination")); + _cupsLangPuts(stdout, _("-e Show available destinations on the network")); + _cupsLangPuts(stdout, _("-o [destination(s)] Show jobs")); + _cupsLangPuts(stdout, _("-p [printer(s)] Show the processing state of destinations")); + _cupsLangPuts(stdout, _("-r Show whether the CUPS server is running")); + _cupsLangPuts(stdout, _("-R Show the ranking of jobs")); + _cupsLangPuts(stdout, _("-s Show a status summary")); + _cupsLangPuts(stdout, _("-t Show all status information")); + _cupsLangPuts(stdout, _("-u [user(s)] Show jobs queued by the current or specified users")); + _cupsLangPuts(stdout, _("-v [printer(s)] Show the devices for each destination")); + + exit(1); +}