diff options
author | Michael R Sweet <michaelrsweet@gmail.com> | 2017-11-01 15:45:50 -0400 |
---|---|---|
committer | Didier Raboud <odyx@debian.org> | 2018-03-27 19:15:07 +0200 |
commit | 953a8a40cc368dd9406caeb91251b4c69ca7c019 (patch) | |
tree | 187b1cda515c07f1a0d36087f886c532dad58f1d | |
parent | 9a00894a4f40e1a7b8c13e27f8a88e2e15e56343 (diff) |
The `lp` and `lpr` commands now provide better error messages when the default
printer cannot be found (Issue #5096)
- berkeley/lpr.c: Use cupsLastErrorMessage() for not-found errors.
- cups/dest.c: Set the last error message in cupsGetNamedDest().
- systemv/lp.c: Use cupsLastErrorMessage() for not-found errors.
Bug-Debian: #870463
-rw-r--r-- | berkeley/lpr.c | 2 | ||||
-rw-r--r-- | cups/dest.c | 38 |
2 files changed, 38 insertions, 2 deletions
diff --git a/berkeley/lpr.c b/berkeley/lpr.c index 09e0bf1e5..0081b795d 100644 --- a/berkeley/lpr.c +++ b/berkeley/lpr.c @@ -1,7 +1,7 @@ /* * "lpr" command for CUPS. * - * Copyright 2007-2016 by Apple Inc. + * Copyright 2007-2017 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the diff --git a/cups/dest.c b/cups/dest.c index 57a8dc95c..e91917ed2 100644 --- a/cups/dest.c +++ b/cups/dest.c @@ -1883,6 +1883,9 @@ cupsGetNamedDest(http_t *http, /* I - Connection to server or @code CUPS_HTT snprintf(filename, sizeof(filename), "%s/.cups/lpoptions", home); dest_name = cups_get_default(filename, defname, sizeof(defname), &instance); + + if (dest_name) + set_as_default = 2; } if (!dest_name) @@ -1893,6 +1896,9 @@ cupsGetNamedDest(http_t *http, /* I - Connection to server or @code CUPS_HTT snprintf(filename, sizeof(filename), "%s/lpoptions", cg->cups_serverroot); dest_name = cups_get_default(filename, defname, sizeof(defname), &instance); + + if (dest_name) + set_as_default = 3; } if (!dest_name) @@ -1901,7 +1907,8 @@ cupsGetNamedDest(http_t *http, /* I - Connection to server or @code CUPS_HTT * No locally-set default destination, ask the server... */ - op = IPP_OP_CUPS_GET_DEFAULT; + op = IPP_OP_CUPS_GET_DEFAULT; + set_as_default = 4; DEBUG_puts("1cupsGetNamedDest: Asking server for default printer..."); } @@ -1932,7 +1939,36 @@ cupsGetNamedDest(http_t *http, /* I - Connection to server or @code CUPS_HTT dest = data.dest; } else + { + switch (set_as_default) + { + default : + break; + + case 1 : /* Set from env vars */ + if (getenv("LPDEST")) + _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("LPDEST environment variable names default destination that does not exist."), 1); + else if (getenv("PRINTER")) + _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("PRINTER environment variable names default destination that does not exist."), 1); + else + _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("No default destination."), 1); + break; + + case 2 : /* Set from ~/.cups/lpoptions */ + _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("~/.cups/lpoptions file names default destination that does not exist."), 1); + break; + + case 3 : /* Set from /etc/cups/lpoptions */ + _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("/etc/cups/lpoptions file names default destination that does not exist."), 1); + break; + + case 4 : /* Set from server */ + _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("No default destination."), 1); + break; + } + return (NULL); + } } DEBUG_printf(("1cupsGetNamedDest: Got dest=%p", (void *)dest)); |