]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - berkeley/lprm.c
Load cups into easysw/current.
[thirdparty/cups.git] / berkeley / lprm.c
index db4c5b382e2779229c2b1e88c865a433cd5c8a6b..574f2650746f815559f87725ca342e1dfc0ac179 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id$"
+ * "$Id: lprm.c 5878 2006-08-24 15:55:42Z mike $"
  *
  *   "lprm" command for the Common UNIX Printing System (CUPS).
  *
@@ -55,12 +55,14 @@ main(int  argc,                     /* I - Number of command-line arguments */
   ipp_t                *request;       /* IPP request */
   ipp_t                *response;      /* IPP response */
   ipp_op_t     op;             /* Operation */
-  cups_lang_t  *language;      /* Language */
   int          num_dests;      /* Number of destinations */
-  cups_dest_t  *dests;         /* Destinations */
+  cups_dest_t  *dests,         /* Destinations */
+               *defdest;       /* Default destination */
   http_encryption_t encryption;        /* Encryption? */
 
 
+  _cupsSetLocale();
+
  /*
   * Setup to cancel individual print jobs...
   */
@@ -71,12 +73,6 @@ main(int  argc,                      /* I - Number of command-line arguments */
   response   = NULL;
   http       = NULL;
   encryption = cupsEncryption();
-  language   = cupsLangDefault();
-  num_dests  = cupsGetDests(&dests);
-
-  for (i = 0; i < num_dests; i ++)
-    if (dests[i].is_default)
-      dest = dests[i].name;
 
  /*
   * Open a connection to the server...
@@ -85,10 +81,13 @@ main(int  argc,                     /* I - Number of command-line arguments */
   if ((http = httpConnectEncrypt(cupsServer(), ippPort(), encryption)) == NULL)
   {
     _cupsLangPuts(stderr, _("lprm: Unable to contact server!\n"));
-    cupsFreeDests(num_dests, dests);
     return (1);
   }
 
+  num_dests  = cupsGetDests2(http, &dests);
+  defdest    = cupsGetDest(NULL, NULL, num_dests, dests);
+  dest       = defdest ? defdest->name : NULL;
+
  /*
   * Process command-line arguments...
   */
@@ -102,6 +101,7 @@ main(int  argc,                     /* I - Number of command-line arguments */
            encryption = HTTP_ENCRYPT_REQUIRED;
 
            httpEncryption(http, encryption);
+           cupsSetEncryption(encryption);
 #else
             _cupsLangPrintf(stderr,
                            _("%s: Sorry, no encryption support compiled in!\n"),
@@ -152,9 +152,6 @@ main(int  argc,                     /* I - Number of command-line arguments */
            break;
            
         case 'h' : /* Connect to host */
-           if (http != NULL)
-             httpClose(http);
-
            if (argv[i][2] != '\0')
               cupsSetServer(argv[i] + 2);
            else
@@ -172,6 +169,20 @@ main(int  argc,                    /* I - Number of command-line arguments */
              else
                 cupsSetServer(argv[i]);
            }
+
+            httpClose(http);
+            cupsFreeDests(num_dests, dests);
+
+           if ((http = httpConnectEncrypt(cupsServer(), ippPort(),
+                                          encryption)) == NULL)
+           {
+             _cupsLangPuts(stderr, _("lprm: Unable to contact server!\n"));
+             return (1);
+           }
+
+           num_dests  = cupsGetDests2(http, &dests);
+           defdest    = cupsGetDest(NULL, NULL, num_dests, dests);
+           dest       = defdest ? defdest->name : NULL;
            break;
 
        default :
@@ -262,7 +273,7 @@ main(int  argc,                     /* I - Number of command-line arguments */
     }
 
  /*
-  * If nothing has been cancelled yet, cancel the current job on the specified
+  * If nothing has been canceled yet, cancel the current job on the specified
   * (or default) printer...
   */
 
@@ -283,5 +294,5 @@ main(int  argc,                     /* I - Number of command-line arguments */
 
 
 /*
- * End of "$Id$".
+ * End of "$Id: lprm.c 5878 2006-08-24 15:55:42Z mike $".
  */