diff options
author | Michael R Sweet <michaelrsweet@gmail.com> | 2017-11-01 15:45:50 -0400 |
---|---|---|
committer | Didier Raboud <odyx@debian.org> | 2018-12-08 13:19:30 +0100 |
commit | 8725244c07382b15e8e1ac38db8d206ac38b16dc (patch) | |
tree | 0e9a59d94a034f912db79997c1526520a62ee1ea | |
parent | 3fbb29bc87ee87c346c8b4f886748d7dae6e960c (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-- | cups/dest.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/cups/dest.c b/cups/dest.c index 7ef85a1b9..d92d23d8e 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)); |