summaryrefslogtreecommitdiff
path: root/systemv
diff options
context:
space:
mode:
authorMichael R Sweet <michaelrsweet@gmail.com>2017-11-01 15:45:50 -0400
committerMichael R Sweet <michaelrsweet@gmail.com>2017-11-01 15:45:50 -0400
commitd6db9ea1dc43510e28e0a29989b4e2e39ee099a7 (patch)
tree5502e9b0e63e9dd24536e76ebb8f94c7a95fa160 /systemv
parent409f54979f3dcd08d9b318e8d74d1d445e0cc520 (diff)
downloadcups-d6db9ea1dc43510e28e0a29989b4e2e39ee099a7.tar.gz
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.
Diffstat (limited to 'systemv')
-rw-r--r--systemv/lp.c31
1 files changed, 4 insertions, 27 deletions
diff --git a/systemv/lp.c b/systemv/lp.c
index 9672b080a..5033459d0 100644
--- a/systemv/lp.c
+++ b/systemv/lp.c
@@ -1,7 +1,7 @@
/*
* "lp" 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
@@ -586,33 +586,10 @@ main(int argc, /* I - Number of command-line arguments */
if (printer == NULL)
{
- val = NULL;
-
- if ((printer = getenv("LPDEST")) == NULL)
- {
- if ((printer = getenv("PRINTER")) != NULL)
- {
- if (!strcmp(printer, "lp"))
- printer = NULL;
- else
- val = "PRINTER";
- }
- }
- else
- val = "LPDEST";
-
- if (printer && !cupsGetNamedDest(NULL, printer, NULL))
- _cupsLangPrintf(stderr,
- _("%s: Error - %s environment variable names "
- "non-existent destination \"%s\"."), argv[0], val,
- printer);
- else if (cupsLastError() == IPP_NOT_FOUND)
- _cupsLangPrintf(stderr,
- _("%s: Error - no default destination available."),
- argv[0]);
+ if (!cupsGetNamedDest(NULL, NULL, NULL) && cupsLastError() == IPP_STATUS_ERROR_NOT_FOUND)
+ _cupsLangPrintf(stderr, _("%s: Error - %s"), argv[0], cupsLastErrorString());
else
- _cupsLangPrintf(stderr, _("%s: Error - scheduler not responding."),
- argv[0]);
+ _cupsLangPrintf(stderr, _("%s: Error - scheduler not responding."), argv[0]);
return (1);
}