]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - systemv/lpoptions.c
Load cups into easysw/current.
[thirdparty/cups.git] / systemv / lpoptions.c
index 3792ab499b210eaff66e499b38e64082240070b5..e6778acc9d5378a3f9488e73f61758d81aea580a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: lpoptions.c 4906 2006-01-10 20:53:28Z mike $"
+ * "$Id: lpoptions.c 6202 2007-01-22 21:37:45Z mike $"
  *
  *   Printer option program for the Common UNIX Printing System (CUPS).
  *
@@ -69,6 +69,8 @@ main(int  argc,                               /* I - Number of command-line arguments */
                *option;                /* Current option */
 
 
+  _cupsSetLocale(argv);
+
  /*
   * Loop through the command-line arguments...
   */
@@ -105,7 +107,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
             if ((dest = cupsGetDest(printer, instance, num_dests, dests)) == NULL)
            {
-             _cupsLangPuts(stderr, NULL,
+             _cupsLangPuts(stderr,
                            _("lpoptions: Unknown printer or class!\n"));
              return (1);
            }
@@ -156,7 +158,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
            }
 
             if (dest == NULL)
-             _cupsLangPuts(stderr, NULL, _("lpoptions: No printers!?!\n"));
+             _cupsLangPuts(stderr, _("lpoptions: No printers!?!\n"));
            else
              list_options(dest);
 
@@ -164,6 +166,21 @@ main(int  argc,                            /* I - Number of command-line arguments */
            break;
 
        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;
+
+             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
@@ -203,7 +220,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
               if (dest == NULL)
              {
-               _cupsLangPrintf(stderr, NULL,
+               _cupsLangPrintf(stderr,
                                _("lpoptions: Unable to add printer or "
                                  "instance: %s\n"),
                                strerror(errno));
@@ -219,6 +236,21 @@ main(int  argc,                            /* I - Number of command-line arguments */
            break;
 
        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;
+
+             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])
              option = argv[i] + 2;
            else
@@ -231,7 +263,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
            }
 
             for (j = 0; j < num_options; j ++)
-             if (strcasecmp(options[j].name, option) == 0)
+             if (!strcasecmp(options[j].name, option))
              {
               /*
                * Remove this option...
@@ -342,20 +374,20 @@ main(int  argc,                           /* I - Number of command-line arguments */
     for (i = 0; i < num_options; i ++)
     {
       if (i)
-        _cupsLangPuts(stdout, NULL, " ");
+        _cupsLangPuts(stdout, " ");
 
       if (!options[i].value[0])
-        _cupsLangPrintf(stdout, NULL, "%s", options[i].name);
+        _cupsLangPrintf(stdout, "%s", options[i].name);
       else if (strchr(options[i].value, ' ') != NULL ||
                strchr(options[i].value, '\t') != NULL)
-       _cupsLangPrintf(stdout, NULL, "%s=\'%s\'", options[i].name,
+       _cupsLangPrintf(stdout, "%s=\'%s\'", options[i].name,
                        options[i].value);
       else
-       _cupsLangPrintf(stdout, NULL, "%s=%s", options[i].name,
+       _cupsLangPrintf(stdout, "%s=%s", options[i].name,
                        options[i].value);
     }
 
-    _cupsLangPuts(stdout, NULL, "\n");
+    _cupsLangPuts(stdout, "\n");
   }
 
   return (0);
@@ -376,15 +408,15 @@ list_group(ppd_group_t *group)    /* I - Group to show */
 
   for (i = group->num_options, option = group->options; i > 0; i --, option ++)
   {
-    _cupsLangPrintf(stdout, NULL, "%s/%s:", option->keyword, option->text);
+    _cupsLangPrintf(stdout, "%s/%s:", option->keyword, option->text);
 
     for (j = option->num_choices, choice = option->choices; j > 0; j --, choice ++)
       if (choice->marked)
-        _cupsLangPrintf(stdout, NULL, " *%s", choice->choice);
+        _cupsLangPrintf(stdout, " *%s", choice->choice);
       else
-        _cupsLangPrintf(stdout, NULL, " %s", choice->choice);
+        _cupsLangPrintf(stdout, " %s", choice->choice);
 
-    _cupsLangPuts(stdout, NULL, "\n");
+    _cupsLangPuts(stdout, "\n");
   }
 
   for (i = group->num_subgroups, subgroup = group->subgroups; i > 0; i --, subgroup ++)
@@ -407,16 +439,16 @@ list_options(cups_dest_t *dest)   /* I - Destination to list */
 
   if ((filename = cupsGetPPD(dest->name)) == NULL)
   {
-    _cupsLangPrintf(stderr, NULL,
-                    _("lpoptions: Destination %s has no PPD file!\n"),
-                   dest->name);
+    _cupsLangPrintf(stderr,
+                    _("lpoptions: Unable to get PPD file for %s: %s\n"),
+                   dest->name, cupsLastErrorString());
     return;
   }
 
   if ((ppd = ppdOpenFile(filename)) == NULL)
   {
     unlink(filename);
-    _cupsLangPrintf(stderr, NULL,
+    _cupsLangPrintf(stderr,
                     _("lpoptions: Unable to open PPD file for %s!\n"),
                    dest->name);
     return;
@@ -440,7 +472,7 @@ list_options(cups_dest_t *dest)     /* I - Destination to list */
 void
 usage(void)
 {
-  _cupsLangPuts(stdout, NULL,
+  _cupsLangPuts(stdout,
                 _("Usage: lpoptions [-h server] [-E] -d printer\n"
                  "       lpoptions [-h server] [-E] [-p printer] -l\n"
                  "       lpoptions [-h server] [-E] -p printer -o "
@@ -452,5 +484,5 @@ usage(void)
 
 
 /*
- * End of "$Id: lpoptions.c 4906 2006-01-10 20:53:28Z mike $".
+ * End of "$Id: lpoptions.c 6202 2007-01-22 21:37:45Z mike $".
  */