X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=systemv%2Flpmove.c;h=a3c4f01827704ca4acefdb78cf6f520d5d58dbc5;hb=bdbfacc73eb01dc0bb79842da2b0da47d7c6aaab;hp=49674014f69e1886a56354be81f806fd99d82f2b;hpb=c07d5b2daf136da7af01c48ff78135d06d2762fc;p=thirdparty%2Fcups.git diff --git a/systemv/lpmove.c b/systemv/lpmove.c index 49674014f..a3c4f0182 100644 --- a/systemv/lpmove.c +++ b/systemv/lpmove.c @@ -1,43 +1,21 @@ /* - * "$Id: lpmove.c 177 2006-06-21 00:20:03Z jlovell $" + * "lpmove" command for CUPS. * - * "lpmove" command for the Common UNIX Printing System (CUPS). + * Copyright 2007-2016 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products. * - * Copyright 1997-2006 by Easy Software Products. - * - * These coded instructions, statements, and computer programs are the - * property of Easy Software Products 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 missing or damaged please contact Easy Software Products - * at: - * - * Attn: CUPS Licensing Information - * Easy Software Products - * 44141 Airport View Drive, Suite 204 - * Hollywood, Maryland 20636 USA - * - * Voice: (301) 373-9600 - * EMail: cups-info@cups.org - * WWW: 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/". */ /* * Include necessary headers... */ -#include -#include -#include -#include -#include -#include -#include +#include /* @@ -58,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 */ @@ -66,60 +45,58 @@ main(int argc, /* I - Number of command-line arguments */ *dest; /* New destination */ + _cupsSetLocale(argv); + dest = NULL; dests = NULL; - http = NULL; job = NULL; jobid = 0; num_dests = 0; 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); - if (http) - httpEncryption(http, HTTP_ENCRYPT_REQUIRED); #else - _cupsLangPrintf(stderr, - _("%s: Sorry, no encryption support compiled in!\n"), - argv[0]); + _cupsLangPrintf(stderr, _("%s: Sorry, no encryption support."), argv[0]); #endif /* HAVE_SSL */ - break; - - case 'h' : /* Connect to host */ - if (http) - { - httpClose(http); - http = NULL; - } - - if (argv[i][2] != '\0') - cupsSetServer(argv[i] + 2); - else - { - i ++; - - if (i >= argc) + break; + + case 'h' : /* Connect to host */ + if (opt[1] != '\0') { - _cupsLangPuts(stderr, - _("Error: need hostname after \'-h\' option!\n")); - return (1); - } - - cupsSetServer(argv[i]); - } - break; - - default : - _cupsLangPrintf(stderr, _("lpmove: Unknown option \'%c\'!\n"), - argv[i][1]); - return (1); + cupsSetServer(opt + 1); + opt += strlen(opt) - 1; + } + else + { + 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) @@ -128,6 +105,9 @@ main(int argc, /* I - Number of command-line arguments */ if ((job = strrchr(argv[i], '-')) != NULL && cupsGetDest(argv[i], NULL, num_dests, dests) == NULL) jobid = atoi(job + 1); + else if (isdigit(argv[i][0] & 255) && + !cupsGetDest(argv[i], NULL, num_dests, dests)) + jobid = atoi(argv[i]); else src = argv[i]; } @@ -135,28 +115,24 @@ main(int argc, /* I - Number of command-line arguments */ dest = argv[i]; else { - _cupsLangPrintf(stderr, _("lpmove: Unknown argument \'%s\'!\n"), - argv[i]); + _cupsLangPrintf(stderr, _("lpmove: Unknown argument \"%s\"."), argv[i]); return (1); } + } if ((!jobid && !src) || !dest) { - _cupsLangPuts(stdout, _("Usage: lpmove job/src dest\n")); + _cupsLangPuts(stdout, _("Usage: lpmove job/src dest")); return (1); } - if (!http) - { - http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption()); + http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption()); - if (http == NULL) - { - _cupsLangPrintf(stderr, - _("lpmove: Unable to connect to server: %s\n"), - strerror(errno)); - return (1); - } + if (http == NULL) + { + _cupsLangPrintf(stderr, _("lpmove: Unable to connect to server: %s"), + strerror(errno)); + return (1); } return (move_job(http, src, jobid, dest)); @@ -224,14 +200,9 @@ move_job(http_t *http, /* I - HTTP connection to server */ if (cupsLastError() > IPP_OK_CONFLICT) { - _cupsLangPrintf(stderr, "lpmove: %s\n", cupsLastErrorString()); + _cupsLangPrintf(stderr, "lpmove: %s", cupsLastErrorString()); return (1); } else return (0); } - - -/* - * End of "$Id: lpmove.c 177 2006-06-21 00:20:03Z jlovell $". - */