/*
- * "$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).
*
*option; /* Current option */
+ _cupsSetLocale(argv);
+
/*
* Loop through the 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);
}
}
if (dest == NULL)
- _cupsLangPuts(stderr, NULL, _("lpoptions: No printers!?!\n"));
+ _cupsLangPuts(stderr, _("lpoptions: No printers!?!\n"));
else
list_options(dest);
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
if (dest == NULL)
{
- _cupsLangPrintf(stderr, NULL,
+ _cupsLangPrintf(stderr,
_("lpoptions: Unable to add printer or "
"instance: %s\n"),
strerror(errno));
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
}
for (j = 0; j < num_options; j ++)
- if (strcasecmp(options[j].name, option) == 0)
+ if (!strcasecmp(options[j].name, option))
{
/*
* Remove this option...
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);
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 ++)
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;
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 "
/*
- * 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 $".
*/