diff options
Diffstat (limited to 'systemv/lp.c')
-rw-r--r-- | systemv/lp.c | 106 |
1 files changed, 77 insertions, 29 deletions
diff --git a/systemv/lp.c b/systemv/lp.c index 5786d645b..ad22715b2 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); +} |