]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - berkeley/lprm.c
Update libtool support to include --mode=foo stuff - surprise, libtool changed in
[thirdparty/cups.git] / berkeley / lprm.c
index d00372c55106153a5817acdfe952fe755246b618..bd190bb3e57b5230743221559ab545d663fd7e8e 100644 (file)
@@ -1,32 +1,21 @@
 /*
- * "$Id: lprm.c 6649 2007-07-11 21:46:42Z mike $"
+ * "lprm" command for CUPS.
  *
- *   "lprm" command for the Common UNIX Printing System (CUPS).
+ * Copyright 2007-2016 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
  *
- *   Copyright 2007 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
+ * missing or damaged, see the license at "http://www.cups.org/".
  */
 
 /*
  * Include necessary headers...
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <cups/cups.h>
-#include <cups/i18n.h>
-#include <cups/string.h>
+#include <cups/cups-private.h>
 
 
 /*
@@ -40,7 +29,8 @@ main(int  argc,                       /* I - Number of command-line arguments */
   int          i;              /* Looping var */
   int          job_id;         /* Job ID */
   const char   *name;          /* Destination printer */
-  char         *instance;      /* Pointer to instance name */
+  char         *instance,      /* Pointer to instance name */
+               *opt;           /* Option pointer */
   cups_dest_t  *dest,          /* Destination */
                *defdest;       /* Default destination */
   int          did_cancel;     /* Did we cancel something? */
@@ -61,94 +51,96 @@ main(int  argc,                     /* I - Number of command-line arguments */
   */
 
   for (i = 1; i < argc; i ++)
+  {
     if (argv[i][0] == '-' && argv[i][1] != '\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 compiled in!\n"),
-                           argv[0]);
+             _cupsLangPrintf(stderr, _("%s: Sorry, no encryption support."), argv[0]);
 #endif /* HAVE_SSL */
-           break;
-
-        case 'P' : /* Cancel jobs on a printer */
-           if (argv[i][2])
-             name = argv[i] + 2;
-           else
-           {
-             i ++;
-             name = argv[i];
-           }
-
-           if ((instance = strchr(name, '/')) != NULL)
-             *instance = '\0';
-
-           if ((dest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, name,
-                                        NULL)) == NULL)
-           {
-             _cupsLangPrintf(stderr,
-                             _("%s: Error - unknown destination \"%s\"!\n"),
-                             argv[0], name);
-              goto error;
-           }
-
-           cupsFreeDests(1, dest);
-           break;
-
-        case 'U' : /* Username */
-           if (argv[i][2] != '\0')
-             cupsSetUser(argv[i] + 2);
-           else
-           {
-             i ++;
-             if (i >= argc)
+             break;
+
+         case 'P' : /* Cancel jobs on a printer */
+             if (opt[1] != '\0')
+             {
+               name = opt + 1;
+               opt += strlen(opt) - 1;
+             }
+             else
              {
-               _cupsLangPrintf(stderr,
-                               _("%s: Error - expected username after "
-                                 "\'-U\' option!\n"),
-                               argv[0]);
-               goto error;
+               i ++;
+               name = argv[i];
              }
 
-              cupsSetUser(argv[i]);
-           }
-           break;
-           
-        case 'h' : /* Connect to host */
-           if (argv[i][2] != '\0')
-              cupsSetServer(argv[i] + 2);
-           else
-           {
-             i ++;
-
-             if (i >= argc)
+             if ((instance = strchr(name, '/')) != NULL)
+               *instance = '\0';
+
+             if ((dest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, name, NULL)) == NULL)
              {
-               _cupsLangPrintf(stderr,
-                               _("%s: Error - expected hostname after "
-                                 "\'-h\' option!\n"),
-                               argv[0]);
+               _cupsLangPrintf(stderr, _("%s: Error - unknown destination \"%s\"."), argv[0], name);
                goto error;
-              }
+             }
+
+             cupsFreeDests(1, dest);
+             break;
+
+         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]);
+                 goto error;
+               }
+
+               cupsSetUser(argv[i]);
+             }
+             break;
+
+         case 'h' : /* Connect to host */
+             if (opt[1] != '\0')
+             {
+               cupsSetServer(opt + 1);
+               opt += strlen(opt) - 1;
+             }
              else
-                cupsSetServer(argv[i]);
-           }
+             {
+               i ++;
+
+               if (i >= argc)
+               {
+                 _cupsLangPrintf(stderr, _("%s: Error - expected hostname after \"-h\" option."), argv[0]);
+                 goto error;
+               }
+               else
+                 cupsSetServer(argv[i]);
+             }
 
-            if (defdest)
-             cupsFreeDests(1, defdest);
+             if (defdest)
+               cupsFreeDests(1, defdest);
 
-           defdest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, NULL, NULL);
-           name    = defdest ? defdest->name : NULL;
-           break;
+             defdest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, NULL, NULL);
+             name    = defdest ? defdest->name : NULL;
+             break;
 
-       default :
-           _cupsLangPrintf(stderr,
-                           _("%s: Error - unknown option \'%c\'!\n"),
-                           argv[0], argv[i][1]);
-            goto error;
+         default :
+             _cupsLangPrintf(stderr, _("%s: Error - unknown option \"%c\"."), argv[0], *opt);
+             goto error;
+       }
       }
+    }
     else
     {
      /*
@@ -178,20 +170,20 @@ main(int  argc,                   /* I - Number of command-line arguments */
       }
       else
       {
-       _cupsLangPrintf(stderr,
-                       _("%s: Error - unknown destination \"%s\"!\n"),
+       _cupsLangPrintf(stderr, _("%s: Error - unknown destination \"%s\"."),
                        argv[0], argv[i]);
        goto error;
       }
 
       if (cupsCancelJob2(CUPS_HTTP_DEFAULT, name, job_id, 0) != IPP_OK)
       {
-        _cupsLangPrintf(stderr, "%s: %s\n", argv[0], cupsLastErrorString());
+        _cupsLangPrintf(stderr, "%s: %s", argv[0], cupsLastErrorString());
        goto error;
       }
 
       did_cancel = 1;
     }
+  }
 
  /*
   * If nothing has been canceled yet, cancel the current job on the specified
@@ -200,7 +192,7 @@ main(int  argc,                     /* I - Number of command-line arguments */
 
   if (!did_cancel && cupsCancelJob2(CUPS_HTTP_DEFAULT, name, 0, 0) != IPP_OK)
     {
-      _cupsLangPrintf(stderr, "%s: %s\n", argv[0], cupsLastErrorString());
+      _cupsLangPrintf(stderr, "%s: %s", argv[0], cupsLastErrorString());
       goto error;
     }
 
@@ -220,8 +212,3 @@ main(int  argc,                     /* I - Number of command-line arguments */
 
   return (1);
 }
-
-
-/*
- * End of "$Id: lprm.c 6649 2007-07-11 21:46:42Z mike $".
- */