diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-19 10:12:15 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-19 10:12:25 +0900 |
commit | 7ffe1916bf6bab5fc5ef042323755da1ef55116c (patch) | |
tree | 2fb46592a29b81b6a1f7eaf1bd4fbc489ad2b56d /systemv | |
parent | 23c7b5e9ad4ae102e15d6507d854a352affd6df3 (diff) | |
download | cups-7ffe1916bf6bab5fc5ef042323755da1ef55116c.tar.gz cups-7ffe1916bf6bab5fc5ef042323755da1ef55116c.tar.bz2 cups-7ffe1916bf6bab5fc5ef042323755da1ef55116c.zip |
Imported Upstream version 2.2.0upstream/2.2.0
Change-Id: I937a26ed4bd71582057195c2f4f371017321055c
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'systemv')
-rw-r--r-- | systemv/Dependencies | 34 | ||||
-rw-r--r-- | systemv/Makefile | 7 | ||||
-rw-r--r-- | systemv/cancel.c | 193 | ||||
-rw-r--r-- | systemv/cupsaccept.c | 181 | ||||
-rw-r--r-- | systemv/cupsaddsmb.c | 29 | ||||
-rw-r--r-- | systemv/cupsctl.c | 30 | ||||
-rw-r--r-- | systemv/cupstestdsc.c | 37 | ||||
-rw-r--r-- | systemv/cupstestppd.c | 29 | ||||
-rw-r--r-- | systemv/lp.c | 709 | ||||
-rw-r--r-- | systemv/lpadmin.c | 804 | ||||
-rw-r--r-- | systemv/lpinfo.c | 356 | ||||
-rw-r--r-- | systemv/lpmove.c | 93 | ||||
-rw-r--r-- | systemv/lpoptions.c | 419 | ||||
-rw-r--r-- | systemv/lpstat.c | 619 |
14 files changed, 1679 insertions, 1861 deletions
diff --git a/systemv/Dependencies b/systemv/Dependencies index effbf99..a1fc7f6 100644 --- a/systemv/Dependencies +++ b/systemv/Dependencies @@ -4,86 +4,84 @@ cancel.o: cancel.c ../cups/cups-private.h ../cups/string-private.h \ ../cups/ipp.h ../cups/http.h ../cups/http-private.h ../cups/language.h \ ../cups/md5-private.h ../cups/language-private.h ../cups/transcode.h \ ../cups/pwg-private.h ../cups/cups.h ../cups/file.h ../cups/pwg.h \ - ../cups/ppd-private.h ../cups/ppd.h ../cups/thread-private.h + ../cups/thread-private.h cupsaccept.o: cupsaccept.c ../cups/cups-private.h \ ../cups/string-private.h ../config.h ../cups/debug-private.h \ ../cups/versioning.h ../cups/array-private.h ../cups/array.h \ ../cups/ipp-private.h ../cups/ipp.h ../cups/http.h \ ../cups/http-private.h ../cups/language.h ../cups/md5-private.h \ ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \ - ../cups/cups.h ../cups/file.h ../cups/pwg.h ../cups/ppd-private.h \ - ../cups/ppd.h ../cups/thread-private.h + ../cups/cups.h ../cups/file.h ../cups/pwg.h ../cups/thread-private.h cupsaddsmb.o: cupsaddsmb.c ../cups/cups-private.h \ ../cups/string-private.h ../config.h ../cups/debug-private.h \ ../cups/versioning.h ../cups/array-private.h ../cups/array.h \ ../cups/ipp-private.h ../cups/ipp.h ../cups/http.h \ ../cups/http-private.h ../cups/language.h ../cups/md5-private.h \ ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \ - ../cups/cups.h ../cups/file.h ../cups/pwg.h ../cups/ppd-private.h \ - ../cups/ppd.h ../cups/thread-private.h ../cups/adminutil.h + ../cups/cups.h ../cups/file.h ../cups/pwg.h ../cups/thread-private.h \ + ../cups/adminutil.h cupsctl.o: cupsctl.c ../cups/cups-private.h ../cups/string-private.h \ ../config.h ../cups/debug-private.h ../cups/versioning.h \ ../cups/array-private.h ../cups/array.h ../cups/ipp-private.h \ ../cups/ipp.h ../cups/http.h ../cups/http-private.h ../cups/language.h \ ../cups/md5-private.h ../cups/language-private.h ../cups/transcode.h \ ../cups/pwg-private.h ../cups/cups.h ../cups/file.h ../cups/pwg.h \ - ../cups/ppd-private.h ../cups/ppd.h ../cups/thread-private.h \ - ../cups/adminutil.h + ../cups/thread-private.h ../cups/adminutil.h cupstestdsc.o: cupstestdsc.c ../cups/cups-private.h \ ../cups/string-private.h ../config.h ../cups/debug-private.h \ ../cups/versioning.h ../cups/array-private.h ../cups/array.h \ ../cups/ipp-private.h ../cups/ipp.h ../cups/http.h \ ../cups/http-private.h ../cups/language.h ../cups/md5-private.h \ ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \ - ../cups/cups.h ../cups/file.h ../cups/pwg.h ../cups/ppd-private.h \ - ../cups/ppd.h ../cups/thread-private.h + ../cups/cups.h ../cups/file.h ../cups/pwg.h ../cups/thread-private.h cupstestppd.o: cupstestppd.c ../cups/cups-private.h \ ../cups/string-private.h ../config.h ../cups/debug-private.h \ ../cups/versioning.h ../cups/array-private.h ../cups/array.h \ ../cups/ipp-private.h ../cups/ipp.h ../cups/http.h \ ../cups/http-private.h ../cups/language.h ../cups/md5-private.h \ ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \ - ../cups/cups.h ../cups/file.h ../cups/pwg.h ../cups/ppd-private.h \ - ../cups/ppd.h ../cups/thread-private.h ../cups/dir.h ../cups/raster.h + ../cups/cups.h ../cups/file.h ../cups/pwg.h ../cups/thread-private.h \ + ../cups/dir.h ../cups/ppd-private.h ../cups/ppd.h ../cups/raster.h lp.o: lp.c ../cups/cups-private.h ../cups/string-private.h ../config.h \ ../cups/debug-private.h ../cups/versioning.h ../cups/array-private.h \ ../cups/array.h ../cups/ipp-private.h ../cups/ipp.h ../cups/http.h \ ../cups/http-private.h ../cups/language.h ../cups/md5-private.h \ ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \ - ../cups/cups.h ../cups/file.h ../cups/pwg.h ../cups/ppd-private.h \ - ../cups/ppd.h ../cups/thread-private.h + ../cups/cups.h ../cups/file.h ../cups/pwg.h ../cups/thread-private.h lpadmin.o: lpadmin.c ../cups/cups-private.h ../cups/string-private.h \ ../config.h ../cups/debug-private.h ../cups/versioning.h \ ../cups/array-private.h ../cups/array.h ../cups/ipp-private.h \ ../cups/ipp.h ../cups/http.h ../cups/http-private.h ../cups/language.h \ ../cups/md5-private.h ../cups/language-private.h ../cups/transcode.h \ ../cups/pwg-private.h ../cups/cups.h ../cups/file.h ../cups/pwg.h \ - ../cups/ppd-private.h ../cups/ppd.h ../cups/thread-private.h + ../cups/thread-private.h ../cups/ppd-private.h ../cups/ppd.h \ + ../cups/raster.h lpinfo.o: lpinfo.c ../cups/cups-private.h ../cups/string-private.h \ ../config.h ../cups/debug-private.h ../cups/versioning.h \ ../cups/array-private.h ../cups/array.h ../cups/ipp-private.h \ ../cups/ipp.h ../cups/http.h ../cups/http-private.h ../cups/language.h \ ../cups/md5-private.h ../cups/language-private.h ../cups/transcode.h \ ../cups/pwg-private.h ../cups/cups.h ../cups/file.h ../cups/pwg.h \ - ../cups/ppd-private.h ../cups/ppd.h ../cups/thread-private.h + ../cups/thread-private.h ../cups/adminutil.h lpmove.o: lpmove.c ../cups/cups-private.h ../cups/string-private.h \ ../config.h ../cups/debug-private.h ../cups/versioning.h \ ../cups/array-private.h ../cups/array.h ../cups/ipp-private.h \ ../cups/ipp.h ../cups/http.h ../cups/http-private.h ../cups/language.h \ ../cups/md5-private.h ../cups/language-private.h ../cups/transcode.h \ ../cups/pwg-private.h ../cups/cups.h ../cups/file.h ../cups/pwg.h \ - ../cups/ppd-private.h ../cups/ppd.h ../cups/thread-private.h + ../cups/thread-private.h lpoptions.o: lpoptions.c ../cups/cups-private.h ../cups/string-private.h \ ../config.h ../cups/debug-private.h ../cups/versioning.h \ ../cups/array-private.h ../cups/array.h ../cups/ipp-private.h \ ../cups/ipp.h ../cups/http.h ../cups/http-private.h ../cups/language.h \ ../cups/md5-private.h ../cups/language-private.h ../cups/transcode.h \ ../cups/pwg-private.h ../cups/cups.h ../cups/file.h ../cups/pwg.h \ - ../cups/ppd-private.h ../cups/ppd.h ../cups/thread-private.h + ../cups/thread-private.h ../cups/ppd-private.h ../cups/ppd.h \ + ../cups/raster.h lpstat.o: lpstat.c ../cups/cups-private.h ../cups/string-private.h \ ../config.h ../cups/debug-private.h ../cups/versioning.h \ ../cups/array-private.h ../cups/array.h ../cups/ipp-private.h \ ../cups/ipp.h ../cups/http.h ../cups/http-private.h ../cups/language.h \ ../cups/md5-private.h ../cups/language-private.h ../cups/transcode.h \ ../cups/pwg-private.h ../cups/cups.h ../cups/file.h ../cups/pwg.h \ - ../cups/ppd-private.h ../cups/ppd.h ../cups/thread-private.h + ../cups/thread-private.h diff --git a/systemv/Makefile b/systemv/Makefile index 62b9da7..a27f38b 100644 --- a/systemv/Makefile +++ b/systemv/Makefile @@ -1,6 +1,4 @@ # -# "$Id: Makefile 11776 2014-03-28 19:16:05Z msweet $" -# # System V commands makefile for CUPS. # # Copyright 2007-2014 by Apple Inc. @@ -276,8 +274,3 @@ lpstat: lpstat.o ../cups/$(LIBCUPS) # include Dependencies - - -# -# End of "$Id: Makefile 11776 2014-03-28 19:16:05Z msweet $". -# diff --git a/systemv/cancel.c b/systemv/cancel.c index 3881102..e72822a 100644 --- a/systemv/cancel.c +++ b/systemv/cancel.c @@ -1,20 +1,14 @@ /* - * "$Id: cancel.c 12247 2014-11-12 16:23:39Z msweet $" + * "cancel" command for CUPS. * - * "cancel" command for CUPS. + * Copyright 2007-2016 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products. * - * Copyright 2007-2013 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products. - * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * 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/". - * - * Contents: - * - * main() - Parse options and cancel jobs. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * 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/". */ /* @@ -37,7 +31,8 @@ main(int argc, /* I - Number of command-line arguments */ int job_id; /* Job ID */ int num_dests; /* Number of destinations */ cups_dest_t *dests; /* Destinations */ - char *dest, /* Destination printer */ + char *opt, /* Option pointer */ + *dest, /* Destination printer */ *job, /* Job ID pointer */ *user; /* Cancel jobs for a user */ int purge; /* Purge or cancel jobs? */ @@ -67,102 +62,106 @@ main(int argc, /* I - Number of command-line arguments */ */ for (i = 1; i < argc; i ++) + { if (argv[i][0] == '-' && argv[i][1]) { - switch (argv[i][1]) + for (opt = argv[i] + 1; *opt; opt ++) { - case 'E' : /* Encrypt */ + switch (*opt) + { + case 'E' : /* Encrypt */ #ifdef HAVE_SSL - cupsSetEncryption(HTTP_ENCRYPT_REQUIRED); + cupsSetEncryption(HTTP_ENCRYPT_REQUIRED); - if (http) - httpEncryption(http, HTTP_ENCRYPT_REQUIRED); + if (http) + httpEncryption(http, HTTP_ENCRYPT_REQUIRED); #else - _cupsLangPrintf(stderr, - _("%s: Sorry, no encryption support."), argv[0]); + _cupsLangPrintf(stderr, _("%s: Sorry, no encryption support."), argv[0]); #endif /* HAVE_SSL */ - break; - - case 'U' : /* Username */ - if (argv[i][2] != '\0') - cupsSetUser(argv[i] + 2); - else - { - i ++; - if (i >= argc) + break; + + case 'U' : /* Username */ + if (opt[1] != '\0') + { + cupsSetUser(opt + 1); + opt += strlen(opt) - 1; + } + else { - _cupsLangPrintf(stderr, - _("%s: Error - expected username after " - "\"-U\" option."), argv[0]); - return (1); + i ++; + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected username after \"-U\" option."), argv[0]); + return (1); + } + + cupsSetUser(argv[i]); } + break; - cupsSetUser(argv[i]); - } - break; + case 'a' : /* Cancel all jobs */ + op = purge ? IPP_PURGE_JOBS : IPP_CANCEL_JOBS; + break; - case 'a' : /* Cancel all jobs */ - op = purge ? IPP_PURGE_JOBS : IPP_CANCEL_JOBS; - break; + case 'h' : /* Connect to host */ + if (http != NULL) + { + httpClose(http); + http = NULL; + } - case 'h' : /* Connect to host */ - if (http != NULL) - { - httpClose(http); - http = NULL; - } + if (opt[1] != '\0') + { + cupsSetServer(opt + 1); + opt += strlen(opt) - 1; + } + else + { + i ++; + + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected hostname after \"-h\" option."), argv[0]); + return (1); + } + else + cupsSetServer(argv[i]); + } + break; - if (argv[i][2] != '\0') - cupsSetServer(argv[i] + 2); - else - { - i ++; + case 'u' : /* Username */ + op = IPP_CANCEL_MY_JOBS; - if (i >= argc) + if (opt[1] != '\0') { - _cupsLangPrintf(stderr, - _("%s: Error - expected hostname after " - "\"-h\" option."), argv[0]); - return (1); - } + user = opt + 1; + opt += strlen(opt) - 1; + } else - cupsSetServer(argv[i]); - } - break; + { + i ++; + + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected username after \"-u\" option."), argv[0]); + return (1); + } + else + user = argv[i]; + } + break; - case 'u' : /* Username */ - op = IPP_CANCEL_MY_JOBS; + case 'x' : /* Purge job(s) */ + purge = 1; - if (argv[i][2] != '\0') - user = argv[i] + 2; - else - { - i ++; + if (op == IPP_CANCEL_JOBS) + op = IPP_PURGE_JOBS; + break; - if (i >= argc) - { - _cupsLangPrintf(stderr, - _("%s: Error - expected username after " - "\"-u\" option."), argv[0]); - return (1); - } - else - user = argv[i]; - } - break; - - case 'x' : /* Purge job(s) */ - purge = 1; - - if (op == IPP_CANCEL_JOBS) - op = IPP_PURGE_JOBS; - break; - - default : - _cupsLangPrintf(stderr, - _("%s: Error - unknown option \"%c\"."), - argv[0], argv[i][1]); - return (1); + default : + _cupsLangPrintf(stderr, _("%s: Error - unknown option \"%c\"."), argv[0], *opt); + return (1); + } } } else @@ -288,7 +287,7 @@ main(int argc, /* I - Number of command-line arguments */ "requesting-user-name", NULL, cupsUser()); if (purge) - ippAddBoolean(request, IPP_TAG_OPERATION, "purge-jobs", purge); + ippAddBoolean(request, IPP_TAG_OPERATION, "purge-jobs", (char)purge); /* * Do the request and get back a response... @@ -314,6 +313,7 @@ main(int argc, /* I - Number of command-line arguments */ ippDelete(response); } + } if (num_dests == 0 && op != IPP_CANCEL_JOB) { @@ -354,7 +354,7 @@ main(int argc, /* I - Number of command-line arguments */ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser()); - ippAddBoolean(request, IPP_TAG_OPERATION, "purge-jobs", purge); + ippAddBoolean(request, IPP_TAG_OPERATION, "purge-jobs", (char)purge); /* * Do the request and get back a response... @@ -380,8 +380,3 @@ main(int argc, /* I - Number of command-line arguments */ return (0); } - - -/* - * End of "$Id: cancel.c 12247 2014-11-12 16:23:39Z msweet $". - */ diff --git a/systemv/cupsaccept.c b/systemv/cupsaccept.c index 67a682c..27f379d 100644 --- a/systemv/cupsaccept.c +++ b/systemv/cupsaccept.c @@ -1,21 +1,15 @@ /* - * "$Id: cupsaccept.c 2873 2010-11-30 03:16:24Z msweet $" + * "cupsaccept", "cupsdisable", "cupsenable", and "cupsreject" commands for + * CUPS. * - * "cupsaccept", "cupsdisable", "cupsenable", and "cupsreject" commands for - * CUPS. + * Copyright 2007-2016 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products. * - * Copyright 2007-2010 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products. - * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * 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/". - * - * Contents: - * - * main() - Parse options and accept/reject jobs or disable/enable printers. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * 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/". */ /* @@ -35,6 +29,7 @@ main(int argc, /* I - Number of command-line arguments */ { int i; /* Looping var */ char *command, /* Command to do */ + *opt, /* Option pointer */ uri[1024], /* Printer URI */ *reason; /* Reason for reject/disable */ ipp_t *request; /* IPP request */ @@ -76,94 +71,90 @@ main(int argc, /* I - Number of command-line arguments */ */ for (i = 1; i < argc; i ++) - if (argv[i][0] == '-') + { + if (!strcmp(argv[i], "--hold")) + op = IPP_HOLD_NEW_JOBS; + else if (!strcmp(argv[i], "--release")) + op = IPP_RELEASE_HELD_NEW_JOBS; + else if (argv[i][0] == '-') { - switch (argv[i][1]) + for (opt = argv[i] + 1; *opt; opt ++) { - case 'E' : /* Encrypt */ -#ifdef HAVE_SSL - cupsSetEncryption(HTTP_ENCRYPT_REQUIRED); -#else - _cupsLangPrintf(stderr, - _("%s: Sorry, no encryption support."), command); -#endif /* HAVE_SSL */ - break; - - case 'U' : /* Username */ - if (argv[i][2] != '\0') - cupsSetUser(argv[i] + 2); - else - { - i ++; - if (i >= argc) + switch (*opt) + { + case 'E' : /* Encrypt */ + #ifdef HAVE_SSL + cupsSetEncryption(HTTP_ENCRYPT_REQUIRED); + #else + _cupsLangPrintf(stderr, _("%s: Sorry, no encryption support."), command); + #endif /* HAVE_SSL */ + break; + + case 'U' : /* Username */ + if (opt[1] != '\0') { - _cupsLangPrintf(stderr, - _("%s: Error - expected username after " - "\"-U\" option."), command); - return (1); + cupsSetUser(opt + 1); + opt += strlen(opt) - 1; } - - cupsSetUser(argv[i]); - } - break; - - case 'c' : /* Cancel jobs */ - cancel = 1; - break; - - case 'h' : /* Connect to host */ - if (argv[i][2] != '\0') - cupsSetServer(argv[i] + 2); - else - { - i ++; - if (i >= argc) + else + { + i ++; + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected username after \"-U\" option."), command); + return (1); + } + + cupsSetUser(argv[i]); + } + break; + + case 'c' : /* Cancel jobs */ + cancel = 1; + break; + + case 'h' : /* Connect to host */ + if (opt[1] != '\0') + { + cupsSetServer(opt + 1); + opt += strlen(opt) - 1; + } + else { - _cupsLangPrintf(stderr, - _("%s: Error - expected hostname after " - "\"-h\" option."), command); - return (1); + i ++; + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected hostname after \"-h\" option."), command); + return (1); + } + + cupsSetServer(argv[i]); } + break; - cupsSetServer(argv[i]); - } - break; - - case 'r' : /* Reason for cancellation */ - if (argv[i][2] != '\0') - reason = argv[i] + 2; - else - { - i ++; - if (i >= argc) + case 'r' : /* Reason for cancellation */ + if (opt[1] != '\0') { - _cupsLangPrintf(stderr, - _("%s: Error - expected reason text after " - "\"-r\" option."), command); - return (1); + reason = opt + 1; + opt += strlen(opt) - 1; } + else + { + i ++; + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected reason text after \"-r\" option."), command); + return (1); + } + + reason = argv[i]; + } + break; - reason = argv[i]; - } - break; - - case '-' : - if (!strcmp(argv[i], "--hold")) - op = IPP_HOLD_NEW_JOBS; - else if (!strcmp(argv[i], "--release")) - op = IPP_RELEASE_HELD_NEW_JOBS; - else - { - _cupsLangPrintf(stderr, _("%s: Error - unknown option \"%s\"."), - command, argv[i]); + default : + _cupsLangPrintf(stderr, _("%s: Error - unknown option \"%c\"."), command, *opt); return (1); - } - break; - - default : - _cupsLangPrintf(stderr, _("%s: Error - unknown option \"%c\"."), - command, argv[i][1]); - return (1); + } } } else @@ -229,11 +220,7 @@ main(int argc, /* I - Number of command-line arguments */ } } } + } return (0); } - - -/* - * End of "$Id: cupsaccept.c 2873 2010-11-30 03:16:24Z msweet $". - */ diff --git a/systemv/cupsaddsmb.c b/systemv/cupsaddsmb.c index 48c99ae..7c28a37 100644 --- a/systemv/cupsaddsmb.c +++ b/systemv/cupsaddsmb.c @@ -1,22 +1,14 @@ /* - * "$Id: cupsaddsmb.c 10996 2013-05-29 11:51:34Z msweet $" + * "cupsaddsmb" command for CUPS. * - * "cupsaddsmb" command for CUPS. + * Copyright 2007-2012 by Apple Inc. + * Copyright 2001-2006 by Easy Software Products. * - * Copyright 2007-2012 by Apple Inc. - * Copyright 2001-2006 by Easy Software Products. - * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * 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/". - * - * Contents: - * - * main() - Export printers on the command-line. - * export_dest() - Export a destination to SAMBA. - * usage() - Show program usage and exit... + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * 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/". */ /* @@ -292,8 +284,3 @@ usage(void) exit(1); } - - -/* - * End of "$Id: cupsaddsmb.c 10996 2013-05-29 11:51:34Z msweet $". - */ diff --git a/systemv/cupsctl.c b/systemv/cupsctl.c index 09d66ea..c4e2763 100644 --- a/systemv/cupsctl.c +++ b/systemv/cupsctl.c @@ -1,23 +1,16 @@ /* - * "$Id: cupsctl.c 10996 2013-05-29 11:51:34Z msweet $" + * Scheduler control program for CUPS. * - * Scheduler control program for CUPS. + * Copyright 2007-2012 by Apple Inc. + * Copyright 2006-2007 by Easy Software Products. * - * Copyright 2007-2012 by Apple Inc. - * Copyright 2006-2007 by Easy Software Products. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * 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/". * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * 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/". - * - * This file is subject to the Apple OS-Developed Software exception. - * - * Contents: - * - * main() - Get/set server settings. - * usage() - Show program usage. + * This file is subject to the Apple OS-Developed Software exception. */ /* @@ -220,8 +213,3 @@ usage(const char *opt) /* I - Option character/string */ exit(1); } - - -/* - * End of "$Id: cupsctl.c 10996 2013-05-29 11:51:34Z msweet $". - */ diff --git a/systemv/cupstestdsc.c b/systemv/cupstestdsc.c index 5e2c809..a8420b8 100644 --- a/systemv/cupstestdsc.c +++ b/systemv/cupstestdsc.c @@ -1,26 +1,18 @@ /* - * "$Id: cupstestdsc.c 10996 2013-05-29 11:51:34Z msweet $" + * DSC test program for CUPS. * - * DSC test program for CUPS. + * Copyright 2007-2010 by Apple Inc. + * Copyright 2006 by Easy Software Products, all rights reserved. * - * Copyright 2007-2010 by Apple Inc. - * Copyright 2006 by Easy Software Products, all rights reserved. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * 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/". * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * 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/". + * PostScript is a trademark of Adobe Systems, Inc. * - * PostScript is a trademark of Adobe Systems, Inc. - * - * This file is subject to the Apple OS-Developed Software exception. - * - * Contents: - * - * main() - Main entry for test program. - * check() - Check a file for conformance. - * usage() - Show program usage. + * This file is subject to the Apple OS-Developed Software exception. */ /* @@ -195,7 +187,7 @@ check_file(const char *filename) /* I - File to read from */ return (1); } else - version = atof(line + 11); + version = (float)atof(line + 11); } else if (level > 0) { @@ -324,7 +316,7 @@ check_file(const char *filename) /* I - File to read from */ saw_trailer = 1; } - for (i = 0; !binary && i < bytes; i ++) + for (i = 0; !binary && i < (int)bytes; i ++) { ch = line[i]; @@ -435,8 +427,3 @@ usage(void) exit(1); } - - -/* - * End of "$Id: cupstestdsc.c 10996 2013-05-29 11:51:34Z msweet $". - */ diff --git a/systemv/cupstestppd.c b/systemv/cupstestppd.c index 9c6be59..8c48d80 100644 --- a/systemv/cupstestppd.c +++ b/systemv/cupstestppd.c @@ -1,20 +1,18 @@ /* - * "$Id: cupstestppd.c 12583 2015-04-03 00:33:05Z msweet $" + * PPD test program for CUPS. * - * PPD test program for CUPS. + * Copyright 2007-2016 by Apple Inc. + * Copyright 1997-2007 by Easy Software Products, all rights reserved. * - * Copyright 2007-2015 by Apple Inc. - * Copyright 1997-2007 by Easy Software Products, all rights reserved. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * 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/". * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * 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/". + * PostScript is a trademark of Adobe Systems, Inc. * - * PostScript is a trademark of Adobe Systems, Inc. - * - * This file is subject to the Apple OS-Developed Software exception. + * This file is subject to the Apple OS-Developed Software exception. */ /* @@ -3124,7 +3122,7 @@ check_sizes(ppd_file_t *ppd, /* I - PPD file */ const char *prefix; /* WARN/FAIL prefix */ ppd_option_t *page_size, /* PageSize option */ *page_region; /* PageRegion option */ - _pwg_media_t *pwg_media; /* PWG media */ + pwg_media_t *pwg_media; /* PWG media */ char buf[PPD_MAX_NAME]; /* PapeSize name that is supposed to be */ const char *ptr; /* Pointer into string */ int width_2540ths, /* PageSize width in 2540ths */ @@ -4033,8 +4031,3 @@ valid_utf8(const char *s) /* I - String to check */ return (1); } - - -/* - * End of "$Id: cupstestppd.c 12583 2015-04-03 00:33:05Z msweet $". - */ diff --git a/systemv/lp.c b/systemv/lp.c index e6eb028..bc09b4b 100644 --- a/systemv/lp.c +++ b/systemv/lp.c @@ -1,9 +1,7 @@ /* - * "$Id: lp.c 11558 2014-02-06 18:33:34Z msweet $" - * * "lp" command for CUPS. * - * Copyright 2007-2014 by Apple Inc. + * Copyright 2007-2016 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -41,6 +39,7 @@ main(int argc, /* I - Number of command-line arguments */ int job_id; /* Job ID */ char *printer, /* Printer name */ *instance, /* Instance name */ + *opt, /* Option pointer */ *val, /* Option value */ *title; /* Job title */ int priority; /* Job priority (1-100) */ @@ -86,427 +85,431 @@ main(int argc, /* I - Number of command-line arguments */ end_options = 0; for (i = 1; i < argc; i ++) + { if (argv[i][0] == '-' && argv[i][1] && !end_options) - switch (argv[i][1]) + { + for (opt = argv[i] + 1; *opt; opt ++) { - case 'E' : /* Encrypt */ + switch (*opt) + { + case 'E' : /* Encrypt */ #ifdef HAVE_SSL - cupsSetEncryption(HTTP_ENCRYPT_REQUIRED); + cupsSetEncryption(HTTP_ENCRYPT_REQUIRED); #else - _cupsLangPrintf(stderr, _("%s: Sorry, no encryption support."), - argv[0]); + _cupsLangPrintf(stderr, _("%s: Sorry, no encryption support."), argv[0]); #endif /* HAVE_SSL */ - break; + break; - case 'U' : /* Username */ - if (argv[i][2] != '\0') - cupsSetUser(argv[i] + 2); - else - { - i ++; - if (i >= argc) + case 'U' : /* Username */ + if (opt[1] != '\0') { - _cupsLangPrintf(stderr, - _("%s: Error - expected username after \"-U\" " - "option."), argv[0]); - return (1); + cupsSetUser(opt + 1); + opt += strlen(opt) - 1; } + else + { + i ++; + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected username after \"-U\" option."), argv[0]); + return (1); + } + + cupsSetUser(argv[i]); + } + break; - cupsSetUser(argv[i]); - } - break; + case 'c' : /* Copy to spool dir (always enabled) */ + break; - case 'c' : /* Copy to spool dir (always enabled) */ - break; + case 'd' : /* Destination printer or class */ + if (opt[1] != '\0') + { + printer = opt + 1; + opt += strlen(opt) - 1; + } + else + { + i ++; - case 'd' : /* Destination printer or class */ - if (argv[i][2] != '\0') - printer = argv[i] + 2; - else - { - i ++; + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected destination after \"-d\" option."), argv[0]); + return (1); + } - if (i >= argc) - { - _cupsLangPrintf(stderr, - _("%s: Error - expected destination after " - "\"-d\" option."), argv[0]); - return (1); - } - - printer = argv[i]; - } - - if ((instance = strrchr(printer, '/')) != NULL) - *instance++ = '\0'; - - if ((dest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, printer, - instance)) != NULL) - { - for (j = 0; j < dest->num_options; j ++) - if (cupsGetOption(dest->options[j].name, num_options, - options) == NULL) - num_options = cupsAddOption(dest->options[j].name, - dest->options[j].value, - num_options, &options); - } - else if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || - cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED) - { - _cupsLangPrintf(stderr, - _("%s: Error - add '/version=1.1' to server " - "name."), argv[0]); - return (1); - } - break; + printer = argv[i]; + } - case 'f' : /* Form */ - if (!argv[i][2]) - { - i ++; + if ((instance = strrchr(printer, '/')) != NULL) + *instance++ = '\0'; - if (i >= argc) + if ((dest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, printer, + instance)) != NULL) { - _cupsLangPrintf(stderr, - _("%s: Error - expected form after \"-f\" " - "option."), - argv[0]); + for (j = 0; j < dest->num_options; j ++) + if (cupsGetOption(dest->options[j].name, num_options, + options) == NULL) + num_options = cupsAddOption(dest->options[j].name, + dest->options[j].value, + num_options, &options); + } + else if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || + cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED) + { + _cupsLangPrintf(stderr, + _("%s: Error - add '/version=1.1' to server " + "name."), argv[0]); return (1); - } - } + } + break; - _cupsLangPrintf(stderr, _("%s: Warning - form option ignored."), - argv[0]); - break; + case 'f' : /* Form */ + if (opt[1] != '\0') + { + opt += strlen(opt) - 1; + } + else + { + i ++; - case 'h' : /* Destination host */ - if (argv[i][2] != '\0') - cupsSetServer(argv[i] + 2); - else - { - i ++; + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected form after \"-f\" option."), argv[0]); + return (1); + } + } - if (i >= argc) + _cupsLangPrintf(stderr, _("%s: Warning - form option ignored."), argv[0]); + break; + + case 'h' : /* Destination host */ + if (opt[1] != '\0') { - _cupsLangPrintf(stderr, - _("%s: Error - expected hostname after " - "\"-h\" option."), argv[0]); - return (1); - } + cupsSetServer(opt + 1); + opt += strlen(opt) - 1; + } + else + { + i ++; - cupsSetServer(argv[i]); - } - break; + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected hostname after \"-h\" option."), argv[0]); + return (1); + } - case 'i' : /* Change job */ - if (argv[i][2]) - val = argv[i] + 2; - else - { - i ++; + cupsSetServer(argv[i]); + } + break; - if (i >= argc) + case 'i' : /* Change job */ + if (opt[1] != '\0') { - _cupsLangPrintf(stderr, - _("%s: Expected job ID after \"-i\" option."), - argv[0]); - return (1); - } + val = opt + 1; + opt += strlen(opt) - 1; + } + else + { + i ++; - val = argv[i]; - } + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Expected job ID after \"-i\" option."), argv[0]); + return (1); + } - if (num_files > 0) - { - _cupsLangPrintf(stderr, - _("%s: Error - cannot print files and alter " - "jobs simultaneously."), argv[0]); - return (1); - } + val = argv[i]; + } + + if (num_files > 0) + { + _cupsLangPrintf(stderr, _("%s: Error - cannot print files and alter jobs simultaneously."), argv[0]); + return (1); + } - if (strrchr(val, '-') != NULL) - job_id = atoi(strrchr(val, '-') + 1); - else - job_id = atoi(val); + if (strrchr(val, '-') != NULL) + job_id = atoi(strrchr(val, '-') + 1); + else + job_id = atoi(val); - if (job_id < 0) - { - _cupsLangPrintf(stderr, _("%s: Error - bad job ID."), argv[0]); + if (job_id < 0) + { + _cupsLangPrintf(stderr, _("%s: Error - bad job ID."), argv[0]); + break; + } break; - } - break; - case 'm' : /* Send email when job is done */ + case 'm' : /* Send email when job is done */ #ifdef __sun - case 'p' : /* Notify on completion */ + case 'p' : /* Notify on completion */ #endif /* __sun */ - case 'w' : /* Write to console or email */ - { - char email[1024]; /* EMail address */ - + case 'w' : /* Write to console or email */ + { + char email[1024]; /* EMail address */ - snprintf(email, sizeof(email), "mailto:%s@%s", cupsUser(), - httpGetHostname(NULL, buffer, sizeof(buffer))); - num_options = cupsAddOption("notify-recipient-uri", email, - num_options, &options); - } - silent = 1; - break; + snprintf(email, sizeof(email), "mailto:%s@%s", cupsUser(), httpGetHostname(NULL, buffer, sizeof(buffer))); + num_options = cupsAddOption("notify-recipient-uri", email, num_options, &options); + } - case 'n' : /* Number of copies */ - if (argv[i][2] != '\0') - num_copies = atoi(argv[i] + 2); - else - { - i ++; + silent = 1; + break; - if (i >= argc) + case 'n' : /* Number of copies */ + if (opt[1] != '\0') { - _cupsLangPrintf(stderr, - _("%s: Error - expected copies after " - "\"-n\" option."), argv[0]); - return (1); - } - - num_copies = atoi(argv[i]); - } + num_copies = atoi(opt + 1); + opt += strlen(opt) - 1; + } + else + { + i ++; - sprintf(buffer, "%d", num_copies); - num_options = cupsAddOption("copies", buffer, num_options, - &options); - break; + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected copies after \"-n\" option."), argv[0]); + return (1); + } - case 'o' : /* Option */ - if (argv[i][2] != '\0') - num_options = cupsParseOptions(argv[i] + 2, num_options, - &options); - else - { - i ++; + num_copies = atoi(argv[i]); + } - if (i >= argc) + if (num_copies < 1) { - _cupsLangPrintf(stderr, - _("%s: Error - expected option=value after " - "\"-o\" option."), argv[0]); + _cupsLangPrintf(stderr, _("%s: Error - copies must be 1 or more."), argv[0]); return (1); - } + } - num_options = cupsParseOptions(argv[i], num_options, &options); - } - break; + sprintf(buffer, "%d", num_copies); + num_options = cupsAddOption("copies", buffer, num_options, + &options); + break; + + case 'o' : /* Option */ + if (opt[1] != '\0') + { + num_options = cupsParseOptions(opt + 1, num_options, &options); + opt += strlen(opt) - 1; + } + else + { + i ++; + + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected option=value after \"-o\" option."), argv[0]); + return (1); + } + + num_options = cupsParseOptions(argv[i], num_options, &options); + } + break; #ifndef __sun - case 'p' : /* Queue priority */ + case 'p' : /* Queue priority */ #endif /* !__sun */ - case 'q' : /* Queue priority */ - if (argv[i][2] != '\0') - priority = atoi(argv[i] + 2); - else - { - if ((i + 1) >= argc) - { - _cupsLangPrintf(stderr, - _("%s: Error - expected priority after " - "\"-%c\" option."), argv[0], argv[i][1]); - return (1); - } - - i ++; - - priority = atoi(argv[i]); - } - - /* - * For 100% Solaris compatibility, need to add: - * - * priority = 99 * (39 - priority) / 39 + 1; - * - * However, to keep CUPS lp the same across all platforms - * we will break compatibility this far... - */ - - if (priority < 1 || priority > 100) - { - _cupsLangPrintf(stderr, - _("%s: Error - priority must be between 1 and " - "100."), argv[0]); - return (1); - } + case 'q' : /* Queue priority */ + if (opt[1] != '\0') + { + priority = atoi(opt + 1); + opt += strlen(opt) - 1; + } + else + { + if ((i + 1) >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected priority after \"-%c\" option."), argv[0], *opt); + return (1); + } - sprintf(buffer, "%d", priority); - num_options = cupsAddOption("job-priority", buffer, num_options, - &options); - break; + i ++; - case 's' : /* Silent */ - silent = 1; - break; + priority = atoi(argv[i]); + } - case 't' : /* Title */ - if (argv[i][2] != '\0') - title = argv[i] + 2; - else - { - i ++; + /* + * For 100% Solaris compatibility, need to add: + * + * priority = 99 * (39 - priority) / 39 + 1; + * + * However, to keep CUPS lp the same across all platforms + * we will break compatibility this far... + */ - if (i >= argc) + if (priority < 1 || priority > 100) { - _cupsLangPrintf(stderr, - _("%s: Error - expected title after " - "\"-t\" option."), argv[0]); + _cupsLangPrintf(stderr, _("%s: Error - priority must be between 1 and 100."), argv[0]); return (1); - } + } - title = argv[i]; - } - break; + sprintf(buffer, "%d", priority); + num_options = cupsAddOption("job-priority", buffer, num_options, + &options); + break; - case 'y' : /* mode-list */ - if (!argv[i][2]) - { - i ++; + case 's' : /* Silent */ + silent = 1; + break; - if (i >= argc) + case 't' : /* Title */ + if (opt[1] != '\0') { - _cupsLangPrintf(stderr, - _("%s: Error - expected mode list after " - "\"-y\" option."), argv[0]); - return (1); - } - } + title = opt + 1; + opt += strlen(opt) - 1; + } + else + { + i ++; - _cupsLangPrintf(stderr, - _("%s: Warning - mode option ignored."), argv[0]); - break; + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected title after \"-t\" option."), argv[0]); + return (1); + } - case 'H' : /* Hold job */ - if (argv[i][2]) - val = argv[i] + 2; - else - { - i ++; + title = argv[i]; + } + break; - if (i >= argc) + case 'y' : /* mode-list */ + if (opt[1] != '\0') { - _cupsLangPrintf(stderr, - _("%s: Error - expected hold name after " - "\"-H\" option."), argv[0]); - return (1); - } - - val = argv[i]; - } - - if (!strcmp(val, "hold")) - num_options = cupsAddOption("job-hold-until", "indefinite", - num_options, &options); - else if (!strcmp(val, "resume") || - !strcmp(val, "release")) - num_options = cupsAddOption("job-hold-until", "no-hold", - num_options, &options); - else if (!strcmp(val, "immediate")) - { - num_options = cupsAddOption("job-hold-until", "no-hold", - num_options, &options); - num_options = cupsAddOption("job-priority", "100", - num_options, &options); - } - else if (!strcmp(val, "restart")) - { - if (job_id < 1) - { - _cupsLangPrintf(stderr, - _("%s: Need job ID (\"-i jobid\") before " - "\"-H restart\"."), argv[0]); - return (1); + opt += strlen(opt) - 1; } + else + { + i ++; - if (restart_job(argv[0], job_id)) - return (1); - } - else - num_options = cupsAddOption("job-hold-until", val, - num_options, &options); - break; + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected mode list after \"-y\" option."), argv[0]); + return (1); + } + } - case 'P' : /* Page list */ - if (argv[i][2]) - val = argv[i] + 2; - else - { - i ++; + _cupsLangPrintf(stderr, _("%s: Warning - mode option ignored."), argv[0]); + break; - if (i >= argc) + case 'H' : /* Hold job */ + if (opt[1] != '\0') { - _cupsLangPrintf(stderr, - _("%s: Error - expected page list after " - "\"-P\" option."), argv[0]); - return (1); - } + val = opt + 1; + opt += strlen(opt) - 1; + } + else + { + i ++; - val = argv[i]; - } + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected hold name after \"-H\" option."), argv[0]); + return (1); + } - num_options = cupsAddOption("page-ranges", val, num_options, - &options); - break; + val = argv[i]; + } - case 'S' : /* character set */ - if (!argv[i][2]) - { - i ++; + if (!strcmp(val, "hold")) + num_options = cupsAddOption("job-hold-until", "indefinite", num_options, &options); + else if (!strcmp(val, "resume") || !strcmp(val, "release")) + num_options = cupsAddOption("job-hold-until", "no-hold", num_options, &options); + else if (!strcmp(val, "immediate")) + { + num_options = cupsAddOption("job-hold-until", "no-hold", num_options, &options); + num_options = cupsAddOption("job-priority", "100", num_options, &options); + } + else if (!strcmp(val, "restart")) + { + if (job_id < 1) + { + _cupsLangPrintf(stderr, _("%s: Need job ID (\"-i jobid\") before \"-H restart\"."), argv[0]); + return (1); + } + + if (restart_job(argv[0], job_id)) + return (1); + } + else + num_options = cupsAddOption("job-hold-until", val, num_options, &options); + break; - if (i >= argc) + case 'P' : /* Page list */ + if (opt[1] != '\0') { - _cupsLangPrintf(stderr, - _("%s: Error - expected character set after " - "\"-S\" option."), argv[0]); - return (1); - } - } + val = opt + 1; + opt += strlen(opt) - 1; + } + else + { + i ++; - _cupsLangPrintf(stderr, - _("%s: Warning - character set option ignored."), - argv[0]); - break; + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected page list after \"-P\" option."), argv[0]); + return (1); + } - case 'T' : /* Content-Type */ - if (!argv[i][2]) - { - i ++; + val = argv[i]; + } - if (i >= argc) + num_options = cupsAddOption("page-ranges", val, num_options, &options); + break; + + case 'S' : /* character set */ + if (opt[1] != '\0') + { + opt += strlen(opt) - 1; + } + else + { + i ++; + + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected character set after \"-S\" option."), argv[0]); + return (1); + } + } + + _cupsLangPrintf(stderr, _("%s: Warning - character set option ignored."), argv[0]); + break; + + case 'T' : /* Content-Type */ + if (opt[1] != '\0') + { + opt += strlen(opt) - 1; + } + else + { + i ++; + + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected content type after \"-T\" option."), argv[0]); + return (1); + } + } + + _cupsLangPrintf(stderr, _("%s: Warning - content type option ignored."), argv[0]); + break; + + case '-' : /* Stop processing options */ + if (opt[1] != '\0') { - _cupsLangPrintf(stderr, - _("%s: Error - expected content type after " - "\"-T\" option."), argv[0]); + _cupsLangPrintf(stderr, _("%s: Error - unknown option \"%s\"."), argv[0], argv[i]); return (1); - } - } - - _cupsLangPrintf(stderr, - _("%s: Warning - content type option ignored."), - argv[0]); - break; - - case '-' : /* Stop processing options */ - if (argv[i][2]) - { - _cupsLangPrintf(stderr, _("%s: Error - unknown option \"%s\"."), - argv[0], argv[i]); - return (1); - } + } - end_options = 1; - break; + end_options = 1; + break; - default : - _cupsLangPrintf(stderr, _("%s: Error - unknown option \"%c\"."), - argv[0], argv[i][1]); - return (1); + default : + _cupsLangPrintf(stderr, _("%s: Error - unknown option \"%c\"."), argv[0], *opt); + return (1); + } } + } else if (!strcmp(argv[i], "-")) { if (num_files || job_id) @@ -527,8 +530,7 @@ main(int argc, /* I - Number of command-line arguments */ if (access(argv[i], R_OK) != 0) { - _cupsLangPrintf(stderr, _("%s: Error - unable to access \"%s\" - %s"), - argv[0], argv[i], strerror(errno)); + _cupsLangPrintf(stderr, _("%s: Error - unable to access \"%s\" - %s"), argv[0], argv[i], strerror(errno)); return (1); } @@ -544,8 +546,10 @@ main(int argc, /* I - Number of command-line arguments */ } } else - _cupsLangPrintf(stderr, _("%s: Error - too many files - \"%s\"."), - argv[0], argv[i]); + { + _cupsLangPrintf(stderr, _("%s: Error - too many files - \"%s\"."), argv[0], argv[i]); + } + } /* * See if we are altering an existing job... @@ -755,8 +759,3 @@ set_job_attrs(const char *command, /* I - Command name */ return (0); } - - -/* - * End of "$Id: lp.c 11558 2014-02-06 18:33:34Z msweet $". - */ diff --git a/systemv/lpadmin.c b/systemv/lpadmin.c index c181d2b..1344b59 100644 --- a/systemv/lpadmin.c +++ b/systemv/lpadmin.c @@ -1,9 +1,7 @@ /* - * "$Id: lpadmin.c 12603 2015-05-06 01:42:51Z msweet $" - * * "lpadmin" command for CUPS. * - * Copyright 2007-2015 by Apple Inc. + * Copyright 2007-2016 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -20,6 +18,7 @@ #define _CUPS_NO_DEPRECATED #define _PPD_DEPRECATED #include <cups/cups-private.h> +#include <cups/ppd-private.h> /* @@ -55,10 +54,11 @@ main(int argc, /* I - Number of command-line arguments */ http_t *http; /* Connection to server */ char *printer, /* Destination printer */ *pclass, /* Printer class name */ + *opt, /* Option pointer */ *val; /* Pointer to allow/deny value */ int num_options; /* Number of options */ cups_option_t *options; /* Options */ - char *file, /* New PPD file/interface script */ + char *file, /* New PPD file */ evefile[1024] = ""; /* IPP Everywhere PPD */ const char *ppd_name, /* ppd-name value */ @@ -74,549 +74,518 @@ main(int argc, /* I - Number of command-line arguments */ file = NULL; for (i = 1; i < argc; i ++) + { if (argv[i][0] == '-') - switch (argv[i][1]) + { + for (opt = argv[i] + 1; *opt; opt ++) { - case 'c' : /* Add printer to class */ - if (!http) - { - http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL); + switch (*opt) + { + case 'c' : /* Add printer to class */ + if (!http) + { + http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL); + + if (http == NULL) + { + _cupsLangPrintf(stderr, _("lpadmin: Unable to connect to server: %s"), strerror(errno)); + return (1); + } + } - if (http == NULL) + if (printer == NULL) { - _cupsLangPrintf(stderr, - _("lpadmin: Unable to connect to server: %s"), - strerror(errno)); + _cupsLangPuts(stderr, + _("lpadmin: Unable to add a printer to the class:\n" + " You must specify a printer name first.")); return (1); } - } - - if (printer == NULL) - { - _cupsLangPuts(stderr, - _("lpadmin: Unable to add a printer to the class:\n" - " You must specify a printer name " - "first.")); - return (1); - } - if (argv[i][2]) - pclass = argv[i] + 2; - else - { - i ++; + if (opt[1] != '\0') + { + pclass = opt + 1; + opt += strlen(opt) - 1; + } + else + { + i ++; - if (i >= argc) + if (i >= argc) + { + _cupsLangPuts(stderr, _("lpadmin: Expected class name after \"-c\" option.")); + return (1); + } + + pclass = argv[i]; + } + + if (!validate_name(pclass)) { _cupsLangPuts(stderr, - _("lpadmin: Expected class name after \"-c\" " - "option.")); + _("lpadmin: Class name can only contain printable " + "characters.")); return (1); } - pclass = argv[i]; - } - - if (!validate_name(pclass)) - { - _cupsLangPuts(stderr, - _("lpadmin: Class name can only contain printable " - "characters.")); - return (1); - } + if (add_printer_to_class(http, printer, pclass)) + return (1); + break; - if (add_printer_to_class(http, printer, pclass)) - return (1); - break; + case 'd' : /* Set as default destination */ + if (!http) + { + http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL); - case 'd' : /* Set as default destination */ - if (!http) - { - http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL); + if (http == NULL) + { + _cupsLangPrintf(stderr, _("lpadmin: Unable to connect to server: %s"), strerror(errno)); + return (1); + } + } - if (http == NULL) + if (opt[1] != '\0') { - _cupsLangPrintf(stderr, - _("lpadmin: Unable to connect to server: %s"), - strerror(errno)); - return (1); + printer = opt + 1; + opt += strlen(opt) - 1; } - } + else + { + i ++; - if (argv[i][2]) - printer = argv[i] + 2; - else - { - i ++; + if (i >= argc) + { + _cupsLangPuts(stderr, _("lpadmin: Expected printer name after \"-d\" option.")); + return (1); + } - if (i >= argc) + printer = argv[i]; + } + + if (!validate_name(printer)) { - _cupsLangPuts(stderr, - _("lpadmin: Expected printer name after \"-d\" " - "option.")); + _cupsLangPuts(stderr, _("lpadmin: Printer name can only contain printable characters.")); return (1); } - printer = argv[i]; - } - - if (!validate_name(printer)) - { - _cupsLangPuts(stderr, - _("lpadmin: Printer name can only contain " - "printable characters.")); - return (1); - } - - if (default_printer(http, printer)) - return (1); + if (default_printer(http, printer)) + return (1); - i = argc; - break; + i = argc; + break; - case 'h' : /* Connect to host */ - if (http) - { - httpClose(http); - http = NULL; - } - - if (argv[i][2] != '\0') - cupsSetServer(argv[i] + 2); - else - { - i ++; + case 'h' : /* Connect to host */ + if (http) + { + httpClose(http); + http = NULL; + } - if (i >= argc) + if (opt[1] != '\0') { - _cupsLangPuts(stderr, - _("lpadmin: Expected hostname after \"-h\" " - "option.")); - return (1); - } + cupsSetServer(opt + 1); + opt += strlen(opt) - 1; + } + else + { + i ++; - cupsSetServer(argv[i]); - } - break; + if (i >= argc) + { + _cupsLangPuts(stderr, _("lpadmin: Expected hostname after \"-h\" option.")); + return (1); + } - case 'i' : /* Use the specified interface script */ - if (argv[i][2]) - file = argv[i] + 2; - else - { - i ++; + cupsSetServer(argv[i]); + } + break; - if (i >= argc) + case 'P' : /* Use the specified PPD file */ + case 'i' : /* Use the specified PPD file */ + if (opt[1] != '\0') { - _cupsLangPuts(stderr, - _("lpadmin: Expected interface after \"-i\" " - "option.")); - return (1); + file = opt + 1; + opt += strlen(opt) - 1; } + else + { + i ++; - file = argv[i]; - } - break; + if (i >= argc) + { + _cupsLangPrintf(stderr, _("lpadmin: Expected PPD after \"-%c\" option."), argv[i - 1][1]); + return (1); + } - case 'E' : /* Enable the printer */ - if (printer == NULL) - { + file = argv[i]; + } + break; + + case 'E' : /* Enable the printer/enable encryption */ + if (printer == NULL) + { #ifdef HAVE_SSL - cupsSetEncryption(HTTP_ENCRYPTION_REQUIRED); + cupsSetEncryption(HTTP_ENCRYPTION_REQUIRED); - if (http) - httpEncryption(http, HTTP_ENCRYPTION_REQUIRED); + if (http) + httpEncryption(http, HTTP_ENCRYPTION_REQUIRED); #else - _cupsLangPrintf(stderr, _("%s: Sorry, no encryption support."), - argv[0]); + _cupsLangPrintf(stderr, _("%s: Sorry, no encryption support."), argv[0]); #endif /* HAVE_SSL */ - break; - } - - if (!http) - { - http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL); + break; + } - if (http == NULL) + if (!http) { - _cupsLangPrintf(stderr, - _("lpadmin: Unable to connect to server: %s"), - strerror(errno)); - return (1); + http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL); + + if (http == NULL) + { + _cupsLangPrintf(stderr, + _("lpadmin: Unable to connect to server: %s"), + strerror(errno)); + return (1); + } } - } - if (enable_printer(http, printer)) - return (1); - break; - - case 'm' : /* Use the specified standard script/PPD file */ - if (argv[i][2]) - num_options = cupsAddOption("ppd-name", argv[i] + 2, num_options, - &options); - else - { - i ++; + if (enable_printer(http, printer)) + return (1); + break; - if (i >= argc) + case 'm' : /* Use the specified standard script/PPD file */ + if (opt[1] != '\0') { - _cupsLangPuts(stderr, - _("lpadmin: Expected model after \"-m\" " - "option.")); - return (1); + num_options = cupsAddOption("ppd-name", opt + 1, num_options, &options); + opt += strlen(opt) - 1; } + else + { + i ++; - num_options = cupsAddOption("ppd-name", argv[i], num_options, - &options); - } - break; + if (i >= argc) + { + _cupsLangPuts(stderr, _("lpadmin: Expected model after \"-m\" option.")); + return (1); + } - case 'o' : /* Set option */ - if (argv[i][2]) - num_options = cupsParseOptions(argv[i] + 2, num_options, &options); - else - { - i ++; + num_options = cupsAddOption("ppd-name", argv[i], num_options, &options); + } + break; - if (i >= argc) + case 'o' : /* Set option */ + if (opt[1] != '\0') { - _cupsLangPuts(stderr, - _("lpadmin: Expected name=value after \"-o\" " - "option.")); - return (1); + num_options = cupsParseOptions(opt + 1, num_options, &options); + opt += strlen(opt) - 1; } + else + { + i ++; - num_options = cupsParseOptions(argv[i], num_options, &options); - } - break; + if (i >= argc) + { + _cupsLangPuts(stderr, _("lpadmin: Expected name=value after \"-o\" option.")); + return (1); + } - case 'p' : /* Add/modify a printer */ - if (argv[i][2]) - printer = argv[i] + 2; - else - { - i ++; + num_options = cupsParseOptions(argv[i], num_options, &options); + } + break; - if (i >= argc) + case 'p' : /* Add/modify a printer */ + if (opt[1] != '\0') { - _cupsLangPuts(stderr, - _("lpadmin: Expected printer after \"-p\" " - "option.")); - return (1); + printer = opt + 1; + opt += strlen(opt) - 1; } + else + { + i ++; - printer = argv[i]; - } - - if (!validate_name(printer)) - { - _cupsLangPuts(stderr, - _("lpadmin: Printer name can only contain " - "printable characters.")); - return (1); - } - break; + if (i >= argc) + { + _cupsLangPuts(stderr, _("lpadmin: Expected printer after \"-p\" option.")); + return (1); + } - case 'r' : /* Remove printer from class */ - if (!http) - { - http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL); + printer = argv[i]; + } - if (http == NULL) + if (!validate_name(printer)) { - _cupsLangPrintf(stderr, - _("lpadmin: Unable to connect to server: %s"), - strerror(errno)); + _cupsLangPuts(stderr, _("lpadmin: Printer name can only contain printable characters.")); return (1); } - } - - if (printer == NULL) - { - _cupsLangPuts(stderr, - _("lpadmin: Unable to remove a printer from the " - "class:\n" - " You must specify a printer name " - "first.")); - return (1); - } + break; - if (argv[i][2]) - pclass = argv[i] + 2; - else - { - i ++; + case 'r' : /* Remove printer from class */ + if (!http) + { + http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL); + + if (http == NULL) + { + _cupsLangPrintf(stderr, + _("lpadmin: Unable to connect to server: %s"), + strerror(errno)); + return (1); + } + } - if (i >= argc) + if (printer == NULL) { _cupsLangPuts(stderr, - _("lpadmin: Expected class after \"-r\" " - "option.")); + _("lpadmin: Unable to remove a printer from the class:\n" + " You must specify a printer name first.")); return (1); } - pclass = argv[i]; - } - - if (!validate_name(pclass)) - { - _cupsLangPuts(stderr, - _("lpadmin: Class name can only contain printable " - "characters.")); - return (1); - } + if (opt[1] != '\0') + { + pclass = opt + 1; + opt += strlen(opt) - 1; + } + else + { + i ++; - if (delete_printer_from_class(http, printer, pclass)) - return (1); - break; + if (i >= argc) + { + _cupsLangPuts(stderr, _("lpadmin: Expected class after \"-r\" option.")); + return (1); + } - case 'R' : /* Remove option */ - if (!http) - { - http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL); + pclass = argv[i]; + } - if (http == NULL) + if (!validate_name(pclass)) { - _cupsLangPrintf(stderr, - _("lpadmin: Unable to connect to server: %s"), - strerror(errno)); + _cupsLangPuts(stderr, _("lpadmin: Class name can only contain printable characters.")); return (1); } - } - - if (printer == NULL) - { - _cupsLangPuts(stderr, - _("lpadmin: Unable to delete option:\n" - " You must specify a printer name " - "first.")); - return (1); - } - if (argv[i][2]) - val = argv[i] + 2; - else - { - i ++; + if (delete_printer_from_class(http, printer, pclass)) + return (1); + break; - if (i >= argc) + case 'R' : /* Remove option */ + if (!http) + { + http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL); + + if (http == NULL) + { + _cupsLangPrintf(stderr, _("lpadmin: Unable to connect to server: %s"), strerror(errno)); + return (1); + } + } + + if (printer == NULL) { _cupsLangPuts(stderr, - _("lpadmin: Expected name after \"-R\" " - "option.")); + _("lpadmin: Unable to delete option:\n" + " You must specify a printer name first.")); return (1); } - val = argv[i]; - } - - if (delete_printer_option(http, printer, val)) - return (1); - break; - - case 'U' : /* Username */ - if (argv[i][2] != '\0') - cupsSetUser(argv[i] + 2); - else - { - i ++; - if (i >= argc) + if (opt[1] != '\0') { - _cupsLangPrintf(stderr, - _("%s: Error - expected username after " - "\"-U\" option."), argv[0]); - return (1); + val = opt + 1; + opt += strlen(opt) - 1; } + else + { + i ++; - cupsSetUser(argv[i]); - } - break; - - case 'u' : /* Allow/deny users */ - if (argv[i][2]) - val = argv[i] + 2; - else - { - i ++; + if (i >= argc) + { + _cupsLangPuts(stderr, _("lpadmin: Expected name after \"-R\" option.")); + return (1); + } - if (i >= argc) - { - _cupsLangPuts(stderr, - _("lpadmin: Expected allow/deny:userlist after " - "\"-u\" option.")); - return (1); + val = argv[i]; } - val = argv[i]; - } - - if (!_cups_strncasecmp(val, "allow:", 6)) - num_options = cupsAddOption("requesting-user-name-allowed", - val + 6, num_options, &options); - else if (!_cups_strncasecmp(val, "deny:", 5)) - num_options = cupsAddOption("requesting-user-name-denied", - val + 5, num_options, &options); - else - { - _cupsLangPrintf(stderr, - _("lpadmin: Unknown allow/deny option \"%s\"."), - val); - return (1); - } - break; + if (delete_printer_option(http, printer, val)) + return (1); + break; - case 'v' : /* Set the device-uri attribute */ - if (argv[i][2]) - num_options = cupsAddOption("device-uri", argv[i] + 2, - num_options, &options); - else - { - i ++; + case 'U' : /* Username */ + if (opt[1] != '\0') + { + cupsSetUser(opt + 1); + opt += strlen(opt) - 1; + } + else + { + i ++; + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected username after \"-U\" option."), argv[0]); + return (1); + } + + cupsSetUser(argv[i]); + } + break; - if (i >= argc) + case 'u' : /* Allow/deny users */ + if (opt[1] != '\0') { - _cupsLangPuts(stderr, - _("lpadmin: Expected device URI after \"-v\" " - "option.")); - return (1); + val = opt + 1; + opt += strlen(opt) - 1; } + else + { + i ++; - num_options = cupsAddOption("device-uri", argv[i], - num_options, &options); - } - break; + if (i >= argc) + { + _cupsLangPuts(stderr, _("lpadmin: Expected allow/deny:userlist after \"-u\" option.")); + return (1); + } - case 'x' : /* Delete a printer */ - if (!http) - { - http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL); + val = argv[i]; + } - if (http == NULL) + if (!_cups_strncasecmp(val, "allow:", 6)) + num_options = cupsAddOption("requesting-user-name-allowed", val + 6, num_options, &options); + else if (!_cups_strncasecmp(val, "deny:", 5)) + num_options = cupsAddOption("requesting-user-name-denied", val + 5, num_options, &options); + else { - _cupsLangPrintf(stderr, - _("lpadmin: Unable to connect to server: %s"), - strerror(errno)); + _cupsLangPrintf(stderr, _("lpadmin: Unknown allow/deny option \"%s\"."), val); return (1); } - } - - if (argv[i][2]) - printer = argv[i] + 2; - else - { - i ++; + break; - if (i >= argc) + case 'v' : /* Set the device-uri attribute */ + if (opt[1] != '\0') { - _cupsLangPuts(stderr, - _("lpadmin: Expected printer or class after " - "\"-x\" option.")); - return (1); + num_options = cupsAddOption("device-uri", opt + 1, num_options, &options); + opt += strlen(opt) - 1; } + else + { + i ++; - printer = argv[i]; - } + if (i >= argc) + { + _cupsLangPuts(stderr, _("lpadmin: Expected device URI after \"-v\" option.")); + return (1); + } - if (!validate_name(printer)) - { - _cupsLangPuts(stderr, - _("lpadmin: Printer name can only contain " - "printable characters.")); - return (1); - } + num_options = cupsAddOption("device-uri", argv[i], num_options, &options); + } + break; - if (delete_printer(http, printer)) - return (1); + case 'x' : /* Delete a printer */ + if (!http) + { + http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL); + + if (http == NULL) + { + _cupsLangPrintf(stderr, + _("lpadmin: Unable to connect to server: %s"), + strerror(errno)); + return (1); + } + } - i = argc; - break; + if (opt[1] != '\0') + { + printer = opt + 1; + opt += strlen(opt) - 1; + } + else + { + i ++; - case 'D' : /* Set the printer-info attribute */ - if (argv[i][2]) - num_options = cupsAddOption("printer-info", argv[i] + 2, - num_options, &options); - else - { - i ++; + if (i >= argc) + { + _cupsLangPuts(stderr, _("lpadmin: Expected printer or class after \"-x\" option.")); + return (1); + } - if (i >= argc) + printer = argv[i]; + } + + if (!validate_name(printer)) { - _cupsLangPuts(stderr, - _("lpadmin: Expected description after " - "\"-D\" option.")); + _cupsLangPuts(stderr, _("lpadmin: Printer name can only contain printable characters.")); return (1); } - num_options = cupsAddOption("printer-info", argv[i], - num_options, &options); - } - break; + if (delete_printer(http, printer)) + return (1); - case 'I' : /* Set the supported file types (ignored) */ - i ++; + i = argc; + break; - if (i >= argc) - { - _cupsLangPuts(stderr, - _("lpadmin: Expected file type(s) after \"-I\" " - "option.")); - return (1); - } + case 'D' : /* Set the printer-info attribute */ + if (opt[1] != '\0') + { + num_options = cupsAddOption("printer-info", opt + 1, num_options, &options); + opt += strlen(opt) - 1; + } + else + { + i ++; - _cupsLangPuts(stderr, - _("lpadmin: Warning - content type list ignored.")); - break; + if (i >= argc) + { + _cupsLangPuts(stderr, _("lpadmin: Expected description after \"-D\" option.")); + return (1); + } + + num_options = cupsAddOption("printer-info", argv[i], num_options, &options); + } + break; - case 'L' : /* Set the printer-location attribute */ - if (argv[i][2]) - num_options = cupsAddOption("printer-location", argv[i] + 2, - num_options, &options); - else - { + case 'I' : /* Set the supported file types (ignored) */ i ++; if (i >= argc) { - _cupsLangPuts(stderr, - _("lpadmin: Expected location after \"-L\" " - "option.")); + _cupsLangPuts(stderr, _("lpadmin: Expected file type(s) after \"-I\" option.")); return (1); } - num_options = cupsAddOption("printer-location", argv[i], - num_options, &options); - } - break; - - case 'P' : /* Use the specified PPD file */ - if (argv[i][2]) - file = argv[i] + 2; - else - { - i ++; + _cupsLangPuts(stderr, _("lpadmin: Warning - content type list ignored.")); + break; - if (i >= argc) + case 'L' : /* Set the printer-location attribute */ + if (opt[1] != '\0') { - _cupsLangPuts(stderr, - _("lpadmin: Expected PPD after \"-P\" option.")); - return (1); + num_options = cupsAddOption("printer-location", opt + 1, num_options, &options); + opt += strlen(opt) - 1; } + else + { + i ++; - file = argv[i]; - } - break; + if (i >= argc) + { + _cupsLangPuts(stderr, _("lpadmin: Expected location after \"-L\" option.")); + return (1); + } + + num_options = cupsAddOption("printer-location", argv[i], num_options, &options); + } + break; - default : - _cupsLangPrintf(stderr, - _("lpadmin: Unknown option \"%c\"."), argv[i][1]); - return (1); + default : + _cupsLangPrintf(stderr, _("lpadmin: Unknown option \"%c\"."), *opt); + return (1); + } } + } else { - _cupsLangPrintf(stderr, _("lpadmin: Unknown argument \"%s\"."), - argv[i]); + _cupsLangPrintf(stderr, _("lpadmin: Unknown argument \"%s\"."), argv[i]); return (1); } + } /* * Set options as needed... @@ -1614,8 +1583,3 @@ validate_name(const char *name) /* I - Name to check */ return ((ptr - name) < 128); } - - -/* - * End of "$Id: lpadmin.c 12603 2015-05-06 01:42:51Z msweet $". - */ diff --git a/systemv/lpinfo.c b/systemv/lpinfo.c index 6816615..16bdf0f 100644 --- a/systemv/lpinfo.c +++ b/systemv/lpinfo.c @@ -1,23 +1,14 @@ /* - * "$Id: lpinfo.c 10996 2013-05-29 11:51:34Z msweet $" + * "lpinfo" command for CUPS. * - * "lpinfo" command for CUPS. + * Copyright 2007-2016 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products. * - * Copyright 2007-2010 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products. - * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * 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/". - * - * Contents: - * - * main() - Parse options and show information. - * device_cb - Device callback. - * show_devices() - Show available devices. - * show_models() - Show available PPDs. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * 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/". */ /* @@ -25,6 +16,7 @@ */ #include <cups/cups-private.h> +#include <cups/adminutil.h> /* @@ -56,7 +48,8 @@ main(int argc, /* I - Number of command-line arguments */ { int i; /* Looping var */ int long_status; /* Long listing? */ - const char *device_id, /* 1284 device ID */ + const char *opt, /* Option pointer */ + *device_id, /* 1284 device ID */ *language, /* Language */ *make_model, /* Make and model */ *product, /* Product */ @@ -77,195 +70,175 @@ main(int argc, /* I - Number of command-line arguments */ timeout = CUPS_TIMEOUT_DEFAULT; for (i = 1; i < argc; i ++) - if (argv[i][0] == '-') - switch (argv[i][1]) + { + if (!strcmp(argv[i], "--device-id")) + { + i ++; + + if (i < argc) + device_id = argv[i]; + else + { + _cupsLangPuts(stderr, _("lpinfo: Expected 1284 device ID string after \"--device-id\".")); + return (1); + } + } + else if (!strncmp(argv[i], "--device-id=", 12) && argv[i][12]) + { + device_id = argv[i] + 12; + } + else if (!strcmp(argv[i], "--exclude-schemes")) + { + i ++; + + if (i < argc) + exclude_schemes = argv[i]; + else + { + _cupsLangPuts(stderr, _("lpinfo: Expected scheme list after \"--exclude-schemes\".")); + return (1); + } + } + else if (!strncmp(argv[i], "--exclude-schemes=", 18) && argv[i][18]) + { + exclude_schemes = argv[i] + 18; + } + else if (!strcmp(argv[i], "--include-schemes")) + { + i ++; + + if (i < argc) + include_schemes = argv[i]; + else + { + _cupsLangPuts(stderr, _("lpinfo: Expected scheme list after \"--include-schemes\".")); + return (1); + } + } + else if (!strncmp(argv[i], "--include-schemes=", 18) && argv[i][18]) + { + include_schemes = argv[i] + 18; + } + else if (!strcmp(argv[i], "--language")) + { + i ++; + if (i < argc) + language = argv[i]; + else + { + _cupsLangPuts(stderr, _("lpinfo: Expected language after \"--language\".")); + return (1); + } + } + else if (!strncmp(argv[i], "--language=", 11) && argv[i][11]) + { + language = argv[i] + 11; + } + else if (!strcmp(argv[i], "--make-and-model")) + { + i ++; + if (i < argc) + make_model= argv[i]; + else + { + _cupsLangPuts(stderr, _("lpinfo: Expected make and model after \"--make-and-model\".")); + return (1); + } + } + else if (!strncmp(argv[i], "--make-and-model=", 17) && argv[i][17]) + { + make_model = argv[i] + 17; + } + else if (!strcmp(argv[i], "--product")) + { + i ++; + if (i < argc) + product = argv[i]; + else + { + _cupsLangPuts(stderr, _("lpinfo: Expected product string after \"--product\".")); + return (1); + } + } + else if (!strncmp(argv[i], "--product=", 10) && argv[i][10]) + { + product = argv[i] + 10; + } + else if (!strcmp(argv[i], "--timeout")) + { + i ++; + if (i < argc) + timeout = atoi(argv[i]); + else + { + _cupsLangPuts(stderr, _("lpinfo: Expected timeout after \"--timeout\".")); + return (1); + } + } + else if (!strncmp(argv[i], "--timeout=", 10) && argv[i][10]) + { + timeout = atoi(argv[i] + 10); + } + else if (argv[i][0] == '-') + { + for (opt = argv[i] + 1; *opt; opt ++) { - case 'E' : /* Encrypt */ + switch (*opt) + { + case 'E' : /* Encrypt */ #ifdef HAVE_SSL - cupsSetEncryption(HTTP_ENCRYPT_REQUIRED); + cupsSetEncryption(HTTP_ENCRYPT_REQUIRED); #else - _cupsLangPrintf(stderr, - _("%s: Sorry, no encryption support."), - argv[0]); + _cupsLangPrintf(stderr, _("%s: Sorry, no encryption support."), argv[0]); #endif /* HAVE_SSL */ - break; - - case 'h' : /* Connect to host */ - if (argv[i][2] != '\0') - cupsSetServer(argv[i] + 2); - else - { - i ++; - - if (i >= argc) - { - _cupsLangPuts(stderr, - _("Error: need hostname after \"-h\" option.")); - return (1); - } - - cupsSetServer(argv[i]); - } - break; - - case 'l' : /* Show long listing */ - long_status = 1; - break; + break; - case 'm' : /* Show models */ - if (show_models(long_status, device_id, language, make_model, - product, include_schemes, exclude_schemes)) - return (1); - break; - - case 'v' : /* Show available devices */ - if (show_devices(long_status, timeout, include_schemes, - exclude_schemes)) - return (1); - break; - - case '-' : /* --something */ - if (!strcmp(argv[i], "--device-id")) - { - i ++; - - if (i < argc) - device_id = argv[i]; - else - { - _cupsLangPuts(stderr, - _("lpinfo: Expected 1284 device ID string " - "after \"--device-id\".")); - return (1); - } - } - else if (!strncmp(argv[i], "--device-id=", 12) && argv[i][12]) - { - device_id = argv[i] + 12; - } - else if (!strcmp(argv[i], "--exclude-schemes")) - { - i ++; - - if (i < argc) - exclude_schemes = argv[i]; - else - { - _cupsLangPuts(stderr, - _("lpinfo: Expected scheme list after " - "\"--exclude-schemes\".")); - return (1); - } - } - else if (!strncmp(argv[i], "--exclude-schemes=", 18) && argv[i][18]) - { - exclude_schemes = argv[i] + 18; - } - else if (!strcmp(argv[i], "--include-schemes")) - { - i ++; - - if (i < argc) - include_schemes = argv[i]; - else + case 'h' : /* Connect to host */ + if (opt[1] != '\0') { - _cupsLangPuts(stderr, - _("lpinfo: Expected scheme list after " - "\"--include-schemes\".")); - return (1); + cupsSetServer(opt + 1); + opt += strlen(opt) - 1; } - } - else if (!strncmp(argv[i], "--include-schemes=", 18) && argv[i][18]) - { - include_schemes = argv[i] + 18; - } - else if (!strcmp(argv[i], "--language")) - { - i ++; - if (i < argc) - language = argv[i]; else { - _cupsLangPuts(stderr, - _("lpinfo: Expected language after " - "\"--language\".")); - return (1); + i ++; + + if (i >= argc) + { + _cupsLangPuts(stderr, _("Error: need hostname after \"-h\" option.")); + return (1); + } + + cupsSetServer(argv[i]); } - } - else if (!strncmp(argv[i], "--language=", 11) && argv[i][11]) - { - language = argv[i] + 11; - } - else if (!strcmp(argv[i], "--make-and-model")) - { - i ++; - if (i < argc) - make_model= argv[i]; - else - { - _cupsLangPuts(stderr, - _("lpinfo: Expected make and model after " - "\"--make-and-model\".")); + break; + + case 'l' : /* Show long listing */ + long_status = 1; + break; + + case 'm' : /* Show models */ + if (show_models(long_status, device_id, language, make_model, product, include_schemes, exclude_schemes)) return (1); - } - } - else if (!strncmp(argv[i], "--make-and-model=", 17) && argv[i][17]) - { - make_model = argv[i] + 17; - } - else if (!strcmp(argv[i], "--product")) - { - i ++; - if (i < argc) - product = argv[i]; - else - { - _cupsLangPuts(stderr, - _("lpinfo: Expected product string after " - "\"--product\".")); + break; + + case 'v' : /* Show available devices */ + if (show_devices(long_status, timeout, include_schemes, exclude_schemes)) return (1); - } - } - else if (!strncmp(argv[i], "--product=", 10) && argv[i][10]) - { - product = argv[i] + 10; - } - else if (!strcmp(argv[i], "--timeout")) - { - i ++; - if (i < argc) - timeout = atoi(argv[i]); - else - { - _cupsLangPuts(stderr, - _("lpinfo: Expected timeout after " - "\"--timeout\".")); - return (1); - } - } - else if (!strncmp(argv[i], "--timeout=", 10) && argv[i][10]) - { - timeout = atoi(argv[i] + 10); - } - else - { - _cupsLangPrintf(stderr, _("lpinfo: Unknown option \"%s\"."), - argv[i]); - return (1); - } - break; + break; - default : - _cupsLangPrintf(stderr, _("lpinfo: Unknown option \"%c\"."), - argv[i][1]); - return (1); + default : + _cupsLangPrintf(stderr, _("%s: Unknown option \"%c\"."), argv[0], *opt); + return (1); + } } + } else { - _cupsLangPrintf(stderr, _("lpinfo: Unknown argument \"%s\"."), - argv[i]); + _cupsLangPrintf(stderr, _("%s: Unknown argument \"%s\"."), argv[0], argv[i]); return (1); } + } return (0); } @@ -491,8 +464,3 @@ show_models( return (0); } - - -/* - * End of "$Id: lpinfo.c 10996 2013-05-29 11:51:34Z msweet $". - */ diff --git a/systemv/lpmove.c b/systemv/lpmove.c index aff9d6d..a3c4f01 100644 --- a/systemv/lpmove.c +++ b/systemv/lpmove.c @@ -1,21 +1,14 @@ /* - * "$Id: lpmove.c 10996 2013-05-29 11:51:34Z msweet $" + * "lpmove" command for CUPS. * - * "lpmove" command for CUPS. + * Copyright 2007-2016 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products. * - * Copyright 2007-2010 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products. - * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * 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/". - * - * Contents: - * - * main() - Parse options and move jobs. - * move_job() - Move a job. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * 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/". */ /* @@ -43,7 +36,8 @@ main(int argc, /* I - Number of command-line arguments */ { int i; /* Looping var */ http_t *http; /* Connection to server */ - const char *job; /* Job name */ + const char *opt, /* Option pointer */ + *job; /* Job name */ int jobid; /* Job ID */ int num_dests; /* Number of destinations */ cups_dest_t *dests; /* Destinations */ @@ -61,43 +55,48 @@ main(int argc, /* I - Number of command-line arguments */ src = NULL; for (i = 1; i < argc; i ++) + { if (argv[i][0] == '-') - switch (argv[i][1]) + { + for (opt = argv[i] + 1; *opt; opt ++) { - case 'E' : /* Encrypt */ + switch (*opt) + { + case 'E' : /* Encrypt */ #ifdef HAVE_SSL - cupsSetEncryption(HTTP_ENCRYPT_REQUIRED); + cupsSetEncryption(HTTP_ENCRYPT_REQUIRED); #else - _cupsLangPrintf(stderr, - _("%s: Sorry, no encryption support."), - argv[0]); + _cupsLangPrintf(stderr, _("%s: Sorry, no encryption support."), argv[0]); #endif /* HAVE_SSL */ - break; - - case 'h' : /* Connect to host */ - if (argv[i][2] != '\0') - cupsSetServer(argv[i] + 2); - else - { - i ++; + break; - if (i >= argc) + case 'h' : /* Connect to host */ + if (opt[1] != '\0') + { + cupsSetServer(opt + 1); + opt += strlen(opt) - 1; + } + else { - _cupsLangPuts(stderr, - _("Error: need hostname after \"-h\" option.")); - return (1); - } - - cupsSetServer(argv[i]); - } - break; - - default : - _cupsLangPrintf(stderr, _("lpmove: Unknown option \"%c\"."), - argv[i][1]); - return (1); + i ++; + + if (i >= argc) + { + _cupsLangPuts(stderr, _("Error: need hostname after \"-h\" option.")); + return (1); + } + + cupsSetServer(argv[i]); + } + break; + + default : + _cupsLangPrintf(stderr, _("%s: Unknown option \"%c\"."), argv[0], *opt); + return (1); + } } + } else if (!jobid && !src) { if (num_dests == 0) @@ -119,6 +118,7 @@ main(int argc, /* I - Number of command-line arguments */ _cupsLangPrintf(stderr, _("lpmove: Unknown argument \"%s\"."), argv[i]); return (1); } + } if ((!jobid && !src) || !dest) { @@ -206,8 +206,3 @@ move_job(http_t *http, /* I - HTTP connection to server */ else return (0); } - - -/* - * End of "$Id: lpmove.c 10996 2013-05-29 11:51:34Z msweet $". - */ diff --git a/systemv/lpoptions.c b/systemv/lpoptions.c index 1ddff29..56b4f60 100644 --- a/systemv/lpoptions.c +++ b/systemv/lpoptions.c @@ -1,9 +1,7 @@ /* - * "$Id: lpoptions.c 11558 2014-02-06 18:33:34Z msweet $" - * * Printer option program for CUPS. * - * Copyright 2007-2014 by Apple Inc. + * Copyright 2007-2016 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -18,6 +16,7 @@ */ #include <cups/cups-private.h> +#include <cups/ppd-private.h> /* @@ -44,7 +43,8 @@ main(int argc, /* I - Number of command-line arguments */ int num_dests; /* Number of destinations */ cups_dest_t *dests; /* Destinations */ cups_dest_t *dest; /* Current destination */ - char *printer, /* Printer name */ + char *opt, /* Option pointer */ + *printer, /* Printer name */ *instance, /* Instance name */ *option; /* Current option */ @@ -63,272 +63,256 @@ main(int argc, /* I - Number of command-line arguments */ changes = 0; for (i = 1; i < argc; i ++) + { if (argv[i][0] == '-') { - switch (argv[i][1]) + for (opt = argv[i] + 1; *opt; opt ++) { - case 'd' : /* -d printer */ - if (argv[i][2]) - printer = argv[i] + 2; - else - { - i ++; - if (i >= argc) - usage(); - - printer = argv[i]; - } - - if ((instance = strrchr(printer, '/')) != NULL) - *instance++ = '\0'; - - if (num_dests == 0) - num_dests = cupsGetDests(&dests); - - if (num_dests == 0 || !dests || - (dest = cupsGetDest(printer, instance, num_dests, - dests)) == NULL) - { - _cupsLangPuts(stderr, _("lpoptions: Unknown printer or class.")); - return (1); - } + switch (*opt) + { + case 'd' : /* -d printer */ + if (opt[1] != '\0') + { + printer = opt + 1; + opt += strlen(opt) - 1; + } + else + { + i ++; + if (i >= argc) + usage(); - /* - * Set the default destination... - */ + printer = argv[i]; + } - for (j = 0; j < num_dests; j ++) - dests[j].is_default = 0; + if ((instance = strrchr(printer, '/')) != NULL) + *instance++ = '\0'; - dest->is_default = 1; + if (num_dests == 0) + num_dests = cupsGetDests(&dests); - cupsSetDests(num_dests, dests); + if (num_dests == 0 || !dests || (dest = cupsGetDest(printer, instance, num_dests, dests)) == NULL) + { + _cupsLangPuts(stderr, _("lpoptions: Unknown printer or class.")); + return (1); + } - for (j = 0; j < dest->num_options; j ++) - if (cupsGetOption(dest->options[j].name, num_options, - options) == NULL) - num_options = cupsAddOption(dest->options[j].name, - dest->options[j].value, - num_options, &options); - break; + /* + * Set the default destination... + */ - case 'h' : /* -h server */ - if (argv[i][2]) - cupsSetServer(argv[i] + 2); - else - { - i ++; - if (i >= argc) - usage(); + for (j = 0; j < num_dests; j ++) + dests[j].is_default = 0; - cupsSetServer(argv[i]); - } - break; + dest->is_default = 1; - case 'E' : /* Encrypt connection */ - cupsSetEncryption(HTTP_ENCRYPT_REQUIRED); - break; + cupsSetDests(num_dests, dests); - case 'l' : /* -l (list options) */ - if (dest == NULL) - { - if (num_dests == 0) - num_dests = cupsGetDests(&dests); + for (j = 0; j < dest->num_options; j ++) + if (cupsGetOption(dest->options[j].name, num_options, + options) == NULL) + num_options = cupsAddOption(dest->options[j].name, + dest->options[j].value, + num_options, &options); + break; - if ((dest = cupsGetDest(NULL, NULL, num_dests, dests)) == NULL) - dest = dests; - } + case 'h' : /* -h server */ + if (opt[1] != '\0') + { + cupsSetServer(opt + 1); + opt += strlen(opt) - 1; + } + else + { + i ++; + if (i >= argc) + usage(); - if (dest == NULL) - _cupsLangPuts(stderr, _("lpoptions: No printers.")); - else - list_options(dest); + cupsSetServer(argv[i]); + } + break; - changes = -1; - break; + case 'E' : /* Encrypt connection */ + cupsSetEncryption(HTTP_ENCRYPT_REQUIRED); + break; - case 'o' : /* -o option[=value] */ - if (dest == NULL) - { - if (num_dests == 0) - num_dests = cupsGetDests(&dests); + case 'l' : /* -l (list options) */ + if (dest == NULL) + { + if (num_dests == 0) + num_dests = cupsGetDests(&dests); - if ((dest = cupsGetDest(NULL, NULL, num_dests, dests)) == NULL) - dest = dests; + if ((dest = cupsGetDest(NULL, NULL, num_dests, dests)) == NULL) + dest = dests; + } if (dest == NULL) - { _cupsLangPuts(stderr, _("lpoptions: No printers.")); - return (1); - } - - for (j = 0; j < dest->num_options; j ++) - if (cupsGetOption(dest->options[j].name, num_options, options) == NULL) - num_options = cupsAddOption(dest->options[j].name, - dest->options[j].value, - num_options, &options); - } - - if (argv[i][2]) - num_options = cupsParseOptions(argv[i] + 2, num_options, &options); - else - { - i ++; - if (i >= argc) - usage(); - - num_options = cupsParseOptions(argv[i], num_options, &options); - } + else + list_options(dest); - changes = 1; - break; + changes = -1; + break; - case 'p' : /* -p printer */ - if (argv[i][2]) - printer = argv[i] + 2; - else - { - i ++; - if (i >= argc) - usage(); - - printer = argv[i]; - } + case 'o' : /* -o option[=value] */ + if (dest == NULL) + { + if (num_dests == 0) + num_dests = cupsGetDests(&dests); + + if ((dest = cupsGetDest(NULL, NULL, num_dests, dests)) == NULL) + dest = dests; + + if (dest == NULL) + { + _cupsLangPuts(stderr, _("lpoptions: No printers.")); + return (1); + } + + for (j = 0; j < dest->num_options; j ++) + if (cupsGetOption(dest->options[j].name, num_options, options) == NULL) + num_options = cupsAddOption(dest->options[j].name, + dest->options[j].value, + num_options, &options); + } - if ((instance = strrchr(printer, '/')) != NULL) - *instance++ = '\0'; + if (opt[1] != '\0') + { + num_options = cupsParseOptions(opt + 1, num_options, &options); + opt += strlen(opt) - 1; + } + else + { + i ++; + if (i >= argc) + usage(); - if (num_dests == 0) - num_dests = cupsGetDests(&dests); + num_options = cupsParseOptions(argv[i], num_options, &options); + } - if ((dest = cupsGetDest(printer, instance, num_dests, dests)) == NULL) - { - num_dests = cupsAddDest(printer, instance, num_dests, &dests); - dest = cupsGetDest(printer, instance, num_dests, dests); + changes = 1; + break; - if (dest == NULL) + case 'p' : /* -p printer */ + if (opt[1] != '\0') { - _cupsLangPrintf(stderr, - _("lpoptions: Unable to add printer or " - "instance: %s"), - strerror(errno)); - return (1); + printer = opt + 1; + opt += strlen(opt) - 1; } - } + else + { + i ++; + if (i >= argc) + usage(); - for (j = 0; j < dest->num_options; j ++) - if (cupsGetOption(dest->options[j].name, num_options, options) == NULL) - num_options = cupsAddOption(dest->options[j].name, - dest->options[j].value, - num_options, &options); - break; + printer = argv[i]; + } + + if ((instance = strrchr(printer, '/')) != NULL) + *instance++ = '\0'; - case 'r' : /* -r option (remove) */ - if (dest == NULL) - { if (num_dests == 0) num_dests = cupsGetDests(&dests); - if ((dest = cupsGetDest(NULL, NULL, num_dests, dests)) == NULL) - dest = dests; - - if (dest == NULL) - { - _cupsLangPuts(stderr, _("lpoptions: No printers.")); - return (1); - } + if ((dest = cupsGetDest(printer, instance, num_dests, dests)) == NULL) + { + num_dests = cupsAddDest(printer, instance, num_dests, &dests); + dest = cupsGetDest(printer, instance, num_dests, dests); + + if (dest == NULL) + { + _cupsLangPrintf(stderr, _("lpoptions: Unable to add printer or instance: %s"), strerror(errno)); + return (1); + } + } for (j = 0; j < dest->num_options; j ++) - if (cupsGetOption(dest->options[j].name, num_options, - options) == NULL) + if (cupsGetOption(dest->options[j].name, num_options, options) == NULL) num_options = cupsAddOption(dest->options[j].name, - dest->options[j].value, - num_options, &options); - } - - if (argv[i][2]) - option = argv[i] + 2; - else - { - i ++; - if (i >= argc) - usage(); + dest->options[j].value, + num_options, &options); + break; - option = argv[i]; - } - - for (j = 0; j < num_options; j ++) - if (!_cups_strcasecmp(options[j].name, option)) + case 'r' : /* -r option (remove) */ + if (dest == NULL) { - /* - * Remove this option... - */ - - num_options --; - - if (j < num_options) - memmove(options + j, options + j + 1, sizeof(cups_option_t) * (size_t)(num_options - j)); - break; - } - - changes = 1; - break; - - case 'x' : /* -x printer */ - if (argv[i][2]) - printer = argv[i] + 2; - else - { - i ++; - if (i >= argc) - usage(); - - printer = argv[i]; - } + if (num_dests == 0) + num_dests = cupsGetDests(&dests); + + if ((dest = cupsGetDest(NULL, NULL, num_dests, dests)) == NULL) + dest = dests; + + if (dest == NULL) + { + _cupsLangPuts(stderr, _("lpoptions: No printers.")); + return (1); + } + + for (j = 0; j < dest->num_options; j ++) + if (cupsGetOption(dest->options[j].name, num_options, + options) == NULL) + num_options = cupsAddOption(dest->options[j].name, + dest->options[j].value, + num_options, &options); + } - if ((instance = strrchr(printer, '/')) != NULL) - *instance++ = '\0'; + if (opt[1] != '\0') + { + option = opt + 1; + opt += strlen(opt) - 1; + } + else + { + i ++; + if (i >= argc) + usage(); - if (num_dests == 0) - num_dests = cupsGetDests(&dests); + option = argv[i]; + } - if ((dest = cupsGetDest(printer, instance, num_dests, - dests)) != NULL) - { - cupsFreeOptions(dest->num_options, dest->options); + num_options = cupsRemoveOption(option, num_options, &options); - /* - * If we are "deleting" the default printer, then just set the - * number of options to 0; if it is also the system default - * then cupsSetDests() will remove it for us... - */ + changes = 1; + break; - if (dest->is_default) + case 'x' : /* -x printer */ + if (opt[1] != '\0') { - dest->num_options = 0; - dest->options = NULL; + printer = opt + 1; + opt += strlen(opt) - 1; } else { - num_dests --; + i ++; + if (i >= argc) + usage(); - j = dest - dests; - if (j < num_dests) - memmove(dest, dest + 1, (size_t)(num_dests - j) * sizeof(cups_dest_t)); + printer = argv[i]; } - } - cupsSetDests(num_dests, dests); - dest = NULL; - changes = -1; - break; + if ((instance = strrchr(printer, '/')) != NULL) + *instance++ = '\0'; + + if (num_dests == 0) + num_dests = cupsGetDests(&dests); + + num_dests = cupsRemoveDest(printer, instance, num_dests, &dests); - default : - usage(); + cupsSetDests(num_dests, dests); + dest = NULL; + changes = -1; + break; + + default : + usage(); + } } } else + { usage(); + } + } if (num_dests == 0) num_dests = cupsGetDests(&dests); @@ -544,8 +528,3 @@ usage(void) exit(1); } - - -/* - * End of "$Id: lpoptions.c 11558 2014-02-06 18:33:34Z msweet $". - */ diff --git a/systemv/lpstat.c b/systemv/lpstat.c index 9c076cb..c13739f 100644 --- a/systemv/lpstat.c +++ b/systemv/lpstat.c @@ -1,9 +1,7 @@ /* - * "$Id: lpstat.c 12124 2014-08-28 15:37:22Z msweet $" - * * "lpstat" command for CUPS. * - * Copyright 2007-2014 by Apple Inc. + * Copyright 2007-2016 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -50,6 +48,7 @@ main(int argc, /* I - Number of command-line arguments */ { int i, /* Looping var */ status; /* Exit status */ + char *opt; /* Option pointer */ int num_dests; /* Number of user destinations */ cups_dest_t *dests; /* User destinations */ int long_status; /* Long status report? */ @@ -73,395 +72,394 @@ main(int argc, /* I - Number of command-line arguments */ op = 0; for (i = 1; i < argc; i ++) + { if (argv[i][0] == '-') - switch (argv[i][1]) + { + for (opt = argv[i] + 1; *opt; opt ++) { - case 'D' : /* Show description */ - long_status = 1; - break; + switch (argv[i][1]) + { + case 'D' : /* Show description */ + long_status = 1; + break; - case 'E' : /* Encrypt */ + case 'E' : /* Encrypt */ #ifdef HAVE_SSL - cupsSetEncryption(HTTP_ENCRYPT_REQUIRED); + cupsSetEncryption(HTTP_ENCRYPT_REQUIRED); #else - _cupsLangPrintf(stderr, - _("%s: Sorry, no encryption support."), - argv[0]); + _cupsLangPrintf(stderr, + _("%s: Sorry, no encryption support."), + argv[0]); #endif /* HAVE_SSL */ - break; + break; - case 'H' : /* Show server and port */ - if (cupsServer()[0] == '/') - _cupsLangPuts(stdout, cupsServer()); - else - _cupsLangPrintf(stdout, "%s:%d", cupsServer(), ippPort()); - op = 'H'; - break; - - case 'P' : /* Show paper types */ - op = 'P'; - break; - - case 'R' : /* Show ranking */ - ranking = 1; - break; - - case 'S' : /* Show charsets */ - op = 'S'; - if (!argv[i][2]) - i ++; - break; - - case 'U' : /* Username */ - if (argv[i][2]) - cupsSetUser(argv[i] + 2); - else - { - i ++; - if (i >= argc) + case 'H' : /* Show server and port */ + if (cupsServer()[0] == '/') + _cupsLangPuts(stdout, cupsServer()); + else + _cupsLangPrintf(stdout, "%s:%d", cupsServer(), ippPort()); + op = 'H'; + break; + + case 'P' : /* Show paper types */ + op = 'P'; + break; + + case 'R' : /* Show ranking */ + ranking = 1; + break; + + case 'S' : /* Show charsets */ + op = 'S'; + if (!argv[i][2]) + i ++; + break; + + case 'U' : /* Username */ + if (opt[1] != '\0') { - _cupsLangPrintf(stderr, - _("%s: Error - expected username after " - "\"-U\" option."), - argv[0]); - return (1); + cupsSetUser(opt + 1); + opt += strlen(opt) - 1; } + else + { + i ++; + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected username after \"-U\" option."), argv[0]); + return (1); + } - cupsSetUser(argv[i]); - } - break; + cupsSetUser(argv[i]); + } + break; - case 'W' : /* Show which jobs? */ - if (argv[i][2]) - which = argv[i] + 2; - else - { - i ++; + case 'W' : /* Show which jobs? */ + if (opt[1] != '\0') + { + which = opt + 1; + opt += strlen(opt) - 1; + } + else + { + i ++; + + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - need \"completed\", \"not-completed\", or \"all\" after \"-W\" option."), argv[0]); + return (1); + } - if (i >= argc) + which = argv[i]; + } + + 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]); + _cupsLangPrintf(stderr, _("%s: Error - need \"completed\", \"not-completed\", or \"all\" after \"-W\" option."), argv[0]); return (1); - } + } + break; - which = argv[i]; - } + case 'a' : /* Show acceptance status */ + op = 'a'; - 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); - } - break; + if (opt[1] != '\0') + { + check_dest(argv[0], opt + 1, &num_dests, &dests); - case 'a' : /* Show acceptance status */ - op = 'a'; + status |= show_accepting(opt + 1, num_dests, dests); + opt += strlen(opt) - 1; + } + else if ((i + 1) < argc && argv[i + 1][0] != '-') + { + i ++; - if (argv[i][2]) - { - check_dest(argv[0], argv[i] + 2, &num_dests, &dests); + check_dest(argv[0], argv[i], &num_dests, &dests); - status |= show_accepting(argv[i] + 2, num_dests, dests); - } - else if ((i + 1) < argc && argv[i + 1][0] != '-') - { - i ++; + status |= show_accepting(argv[i], num_dests, dests); + } + else + { + if (num_dests <= 1) + { + cupsFreeDests(num_dests, dests); + num_dests = cupsGetDests(&dests); + + if (num_dests == 0 && (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)) + { + _cupsLangPrintf(stderr, _("%s: Error - add '/version=1.1' to server name."), argv[0]); + return (1); + } + } - check_dest(argv[0], argv[i], &num_dests, &dests); + status |= show_accepting(NULL, num_dests, dests); + } + break; - status |= show_accepting(argv[i], num_dests, dests); - } - else - { - if (num_dests <= 1) + case 'c' : /* Show classes and members */ + op = 'c'; + + if (opt[1] != '\0') { - cupsFreeDests(num_dests, dests); - num_dests = cupsGetDests(&dests); + check_dest(argv[0], opt + 1, &num_dests, &dests); + + status |= show_classes(opt + 1); + opt += strlen(opt) - 1; + } + else if ((i + 1) < argc && argv[i + 1][0] != '-') + { + i ++; + + check_dest(argv[0], argv[i], &num_dests, &dests); + + status |= show_classes(argv[i]); + } + else + status |= show_classes(NULL); + break; + + case 'd' : /* Show default destination */ + op = 'd'; + + if (num_dests != 1 || !dests[0].is_default) + { + cupsFreeDests(num_dests, dests); + + dests = cupsGetNamedDest(CUPS_HTTP_DEFAULT, NULL, NULL); + num_dests = dests ? 1 : 0; if (num_dests == 0 && (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)) { - _cupsLangPrintf(stderr, - _("%s: Error - add '/version=1.1' to server " - "name."), argv[0]); + _cupsLangPrintf(stderr, _("%s: Error - add '/version=1.1' to server name."), argv[0]); return (1); } } - status |= show_accepting(NULL, num_dests, dests); - } - break; - - case 'c' : /* Show classes and members */ - op = 'c'; - - if (argv[i][2]) - { - check_dest(argv[0], argv[i] + 2, &num_dests, &dests); + show_default(dests); + break; - status |= show_classes(argv[i] + 2); - } - else if ((i + 1) < argc && argv[i + 1][0] != '-') - { - i ++; + case 'f' : /* Show forms */ + op = 'f'; + if (opt[1] != '\0') + { + opt += strlen(opt) - 1; + } + else + { + i ++; + if (i >= argc) + return (1); + } + break; - check_dest(argv[0], argv[i], &num_dests, &dests); + case 'h' : /* Connect to host */ + if (opt[1] != '\0') + { + cupsSetServer(opt + 1); + opt += strlen(opt) - 1; + } + else + { + i ++; - status |= show_classes(argv[i]); - } - else - status |= show_classes(NULL); - break; + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Error - expected hostname after \"-h\" option."), argv[0]); + return (1); + } - case 'd' : /* Show default destination */ - op = 'd'; + cupsSetServer(argv[i]); + } + break; - if (num_dests != 1 || !dests[0].is_default) - { - cupsFreeDests(num_dests, dests); + case 'l' : /* Long status or long job status */ + long_status = 2; + break; - dests = cupsGetNamedDest(CUPS_HTTP_DEFAULT, NULL, NULL); - num_dests = dests ? 1 : 0; + case 'o' : /* Show jobs by destination */ + op = 'o'; - if (num_dests == 0 && - (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || - cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)) + if (opt[1]) { - _cupsLangPrintf(stderr, - _("%s: Error - add '/version=1.1' to server " - "name."), argv[0]); - return (1); + check_dest(argv[0], opt + 1, &num_dests, &dests); + + status |= show_jobs(opt + 1, NULL, long_status, ranking, which); + opt += strlen(opt) - 1; } - } + else if ((i + 1) < argc && argv[i + 1][0] != '-') + { + i ++; - show_default(dests); - break; + check_dest(argv[0], argv[i], &num_dests, &dests); - case 'f' : /* Show forms */ - op = 'f'; - if (!argv[i][2]) - i ++; - break; + status |= show_jobs(argv[i], NULL, long_status, ranking, which); + } + else + status |= show_jobs(NULL, NULL, long_status, ranking, which); + break; - case 'h' : /* Connect to host */ - if (argv[i][2]) - cupsSetServer(argv[i] + 2); - else - { - i ++; + case 'p' : /* Show printers */ + op = 'p'; - if (i >= argc) + if (opt[1] != '\0') { - _cupsLangPrintf(stderr, - _("%s: Error - expected hostname after " - "\"-h\" option."), - argv[0]); - return (1); - } + check_dest(argv[0], opt + 1, &num_dests, &dests); - cupsSetServer(argv[i]); - } - break; + status |= show_printers(opt + 1, num_dests, dests, + long_status); + opt += strlen(opt) - 1; + } + else if ((i + 1) < argc && argv[i + 1][0] != '-') + { + i ++; - case 'l' : /* Long status or long job status */ - long_status = 2; - break; + check_dest(argv[0], argv[i], &num_dests, &dests); - case 'o' : /* Show jobs by destination */ - op = 'o'; + status |= show_printers(argv[i], num_dests, dests, long_status); + } + else + { + if (num_dests <= 1) + { + cupsFreeDests(num_dests, dests); + num_dests = cupsGetDests(&dests); + + if (num_dests == 0 && + (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || + cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)) + { + _cupsLangPrintf(stderr, _("%s: Error - add '/version=1.1' to server name."), argv[0]); + return (1); + } + } - if (argv[i][2]) - { - check_dest(argv[0], argv[i] + 2, &num_dests, &dests); + status |= show_printers(NULL, num_dests, dests, long_status); + } + break; - status |= show_jobs(argv[i] + 2, NULL, long_status, ranking, - which); - } - else if ((i + 1) < argc && argv[i + 1][0] != '-') - { - i ++; + case 'r' : /* Show scheduler status */ + op = 'r'; - check_dest(argv[0], argv[i], &num_dests, &dests); + show_scheduler(); + break; - status |= show_jobs(argv[i], NULL, long_status, ranking, which); - } - else - status |= show_jobs(NULL, NULL, long_status, ranking, which); - break; + case 's' : /* Show summary */ + op = 's'; - case 'p' : /* Show printers */ - op = 'p'; + if (num_dests <= 1) + { + cupsFreeDests(num_dests, dests); + num_dests = cupsGetDests(&dests); - if (argv[i][2]) - { - check_dest(argv[0], argv[i] + 2, &num_dests, &dests); + if (num_dests == 0 && + (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || + cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)) + { + _cupsLangPrintf(stderr, _("%s: Error - add '/version=1.1' to server name."), argv[0]); + return (1); + } + } - status |= show_printers(argv[i] + 2, num_dests, dests, - long_status); - } - else if ((i + 1) < argc && argv[i + 1][0] != '-') - { - i ++; + show_default(cupsGetDest(NULL, NULL, num_dests, dests)); + status |= show_classes(NULL); + status |= show_devices(NULL, num_dests, dests); + break; - check_dest(argv[0], argv[i], &num_dests, &dests); + case 't' : /* Show all info */ + op = 't'; - status |= show_printers(argv[i], num_dests, dests, long_status); - } - else - { - if (num_dests <= 1) + if (num_dests <= 1) { - cupsFreeDests(num_dests, dests); + cupsFreeDests(num_dests, dests); num_dests = cupsGetDests(&dests); if (num_dests == 0 && (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)) { - _cupsLangPrintf(stderr, - _("%s: Error - add '/version=1.1' to server " - "name."), argv[0]); + _cupsLangPrintf(stderr, _("%s: Error - add '/version=1.1' to server name."), argv[0]); return (1); } } + show_scheduler(); + show_default(cupsGetDest(NULL, NULL, num_dests, dests)); + status |= show_classes(NULL); + status |= show_devices(NULL, num_dests, dests); + status |= show_accepting(NULL, num_dests, dests); status |= show_printers(NULL, num_dests, dests, long_status); - } - break; - - case 'r' : /* Show scheduler status */ - op = 'r'; - - show_scheduler(); - break; - - case 's' : /* Show summary */ - op = 's'; + status |= show_jobs(NULL, NULL, long_status, ranking, which); + break; - if (num_dests <= 1) - { - cupsFreeDests(num_dests, dests); - num_dests = cupsGetDests(&dests); + case 'u' : /* Show jobs by user */ + op = 'u'; - if (num_dests == 0 && - (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || - cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)) + if (opt[1] != '\0') { - _cupsLangPrintf(stderr, - _("%s: Error - add '/version=1.1' to server " - "name."), argv[0]); - return (1); + status |= show_jobs(NULL, opt + 1, long_status, ranking, which); + opt += strlen(opt) - 1; } - } - - show_default(cupsGetDest(NULL, NULL, num_dests, dests)); - status |= show_classes(NULL); - status |= show_devices(NULL, num_dests, dests); - break; - - case 't' : /* Show all info */ - op = 't'; - - if (num_dests <= 1) - { - cupsFreeDests(num_dests, dests); - num_dests = cupsGetDests(&dests); - - if (num_dests == 0 && - (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || - cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)) + else if ((i + 1) < argc && argv[i + 1][0] != '-') { - _cupsLangPrintf(stderr, - _("%s: Error - add '/version=1.1' to server " - "name."), argv[0]); - return (1); + i ++; + status |= show_jobs(NULL, argv[i], long_status, ranking, which); } - } - - show_scheduler(); - show_default(cupsGetDest(NULL, NULL, num_dests, dests)); - status |= show_classes(NULL); - status |= show_devices(NULL, num_dests, dests); - status |= show_accepting(NULL, num_dests, dests); - status |= show_printers(NULL, num_dests, dests, long_status); - status |= show_jobs(NULL, NULL, long_status, ranking, which); - break; - - case 'u' : /* Show jobs by user */ - op = 'u'; - - if (argv[i][2]) - status |= show_jobs(NULL, argv[i] + 2, long_status, ranking, - which); - else if ((i + 1) < argc && argv[i + 1][0] != '-') - { - i ++; - status |= show_jobs(NULL, argv[i], long_status, ranking, which); - } - else - status |= show_jobs(NULL, NULL, long_status, ranking, which); - break; + else + status |= show_jobs(NULL, NULL, long_status, ranking, which); + break; - case 'v' : /* Show printer devices */ - op = 'v'; + case 'v' : /* Show printer devices */ + op = 'v'; - if (argv[i][2]) - { - check_dest(argv[0], argv[i] + 2, &num_dests, &dests); + if (opt[1] != '\0') + { + check_dest(argv[0], opt + 1, &num_dests, &dests); - status |= show_devices(argv[i] + 2, num_dests, dests); - } - else if ((i + 1) < argc && argv[i + 1][0] != '-') - { - i ++; + status |= show_devices(opt + 1, num_dests, dests); + opt += strlen(opt) - 1; + } + else if ((i + 1) < argc && argv[i + 1][0] != '-') + { + i ++; - check_dest(argv[0], argv[i], &num_dests, &dests); + check_dest(argv[0], argv[i], &num_dests, &dests); - status |= show_devices(argv[i], num_dests, dests); - } - else - { - if (num_dests <= 1) + status |= show_devices(argv[i], num_dests, dests); + } + else { - cupsFreeDests(num_dests, dests); - num_dests = cupsGetDests(&dests); - - if (num_dests == 0 && - (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || - cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)) + if (num_dests <= 1) { - _cupsLangPrintf(stderr, - _("%s: Error - add '/version=1.1' to server " - "name."), argv[0]); - return (1); + cupsFreeDests(num_dests, dests); + num_dests = cupsGetDests(&dests); + + if (num_dests == 0 && + (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || + cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)) + { + _cupsLangPrintf(stderr, _("%s: Error - add '/version=1.1' to server name."), argv[0]); + return (1); + } } - } - status |= show_devices(NULL, num_dests, dests); - } - break; + status |= show_devices(NULL, num_dests, dests); + } + break; - default : - _cupsLangPrintf(stderr, - _("%s: Error - unknown option \"%c\"."), - argv[0], argv[i][1]); - return (1); + default : + _cupsLangPrintf(stderr, _("%s: Error - unknown option \"%c\"."), argv[0], argv[i][1]); + return (1); + } } + } else { status |= show_jobs(argv[i], NULL, long_status, ranking, which); op = 'o'; } + } if (!op) status |= show_jobs(NULL, cupsUser(), long_status, ranking, which); @@ -546,7 +544,7 @@ check_dest(const char *command, /* I - Command name */ for (pptr = printer; !isspace(*dptr & 255) && *dptr != ',' && *dptr;) { - if ((pptr - printer) < (sizeof(printer) - 1)) + if ((size_t)(pptr - printer) < (sizeof(printer) - 1)) *pptr++ = *dptr++; else { @@ -1835,11 +1833,7 @@ show_printers(const char *printers, /* I - Destinations */ { _cupsLangPuts(stdout, _("\tConnection: direct")); - if (make_model && strstr(make_model, "System V Printer")) - _cupsLangPrintf(stdout, - _("\tInterface: %s/interfaces/%s"), - cg->cups_serverroot, printer); - else if (make_model && !strstr(make_model, "Raw Printer")) + if (make_model && !strstr(make_model, "Raw Printer")) _cupsLangPrintf(stdout, _("\tInterface: %s/ppd/%s.ppd"), cg->cups_serverroot, printer); @@ -1958,11 +1952,7 @@ show_printers(const char *printers, /* I - Destinations */ { _cupsLangPuts(stdout, _("\tConnection: direct")); - if (make_model && strstr(make_model, "System V Printer")) - _cupsLangPrintf(stdout, - _("\tInterface: %s/interfaces/%s"), - cg->cups_serverroot, printer); - else if (make_model && !strstr(make_model, "Raw Printer")) + if (make_model && !strstr(make_model, "Raw Printer")) _cupsLangPrintf(stdout, _("\tInterface: %s/ppd/%s.ppd"), cg->cups_serverroot, printer); @@ -2031,8 +2021,3 @@ show_scheduler(void) else _cupsLangPuts(stdout, _("scheduler is not running")); } - - -/* - * End of "$Id: lpstat.c 12124 2014-08-28 15:37:22Z msweet $". - */ |