From 25c6a91659bc18dc60a5278ef82eb6cf8edd0d6c Mon Sep 17 00:00:00 2001 From: Till Kamppeter Date: Tue, 1 Dec 2020 23:39:47 +0100 Subject: [PATCH] libppd: Generated PPDs could have an "Unknown" default InputSlot --- NEWS | 4 ++-- ppd/ppd-cache.c | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index f163ed294..b439a01c2 100644 --- a/NEWS +++ b/NEWS @@ -3,8 +3,8 @@ NEWS - OpenPrinting CUPS Filters v1.27.5 - 2020-06-05 CHANGES IN V2.0.0 - - libcupsfilters: Generated PPDs could have an "Unknown" - default InputSlot (OpenPrinting CUPS issue #44). + - libcupsfilters, libppd: Generated PPDs could have an + "Unknown" default InputSlot (OpenPrinting CUPS issue #44). - cups-browsed: Removed unneeded IPP attribute additions preventing the created local queues from preserving a location or description the user assigns to them (Issue diff --git a/ppd/ppd-cache.c b/ppd/ppd-cache.c index b0c645b86..4e6aeadb3 100644 --- a/ppd/ppd-cache.c +++ b/ppd/ppd-cache.c @@ -3687,10 +3687,12 @@ ppdCreateFromIPPCUPS(char *buffer, /* I - Filename buffer */ if ((attr = ippFindAttribute(ippGetCollection(defattr, 0), "media-source", IPP_TAG_ZERO)) != NULL) ppdPwgPpdizeName(ippGetString(attr, 0, NULL), ppdname, sizeof(ppdname)); else - strlcpy(ppdname, "Unknown", sizeof(ppdname)); + ppdname[0] = '\0'; if ((attr = ippFindAttribute(response, "media-source-supported", IPP_TAG_ZERO)) != NULL && (count = ippGetCount(attr)) > 1) { + int have_default = ppdname[0] != '\0'; + /* Do we have a default InputSlot? */ static const char * const sources[] = { /* Standard "media-source" strings */ "auto", @@ -3745,15 +3747,20 @@ ppdCreateFromIPPCUPS(char *buffer, /* I - Filename buffer */ "roll-10" }; - cupsFilePrintf(fp, "*OpenUI *InputSlot: PickOne\n" - "*OrderDependency: 10 AnySetup *InputSlot\n" - "*DefaultInputSlot: %s\n", ppdname); + cupsFilePuts(fp, "*OpenUI *InputSlot: PickOne\n" + "*OrderDependency: 10 AnySetup *InputSlot\n"); + if (have_default) + cupsFilePrintf(fp, "*DefaultInputSlot: %s\n", ppdname); + for (i = 0, count = ippGetCount(attr); i < count; i ++) { keyword = ippGetString(attr, i, NULL); ppdPwgPpdizeName(keyword, ppdname, sizeof(ppdname)); + if (i == 0 && !have_default) + cupsFilePrintf(fp, "*DefaultInputSlot: %s\n", ppdname); + for (j = 0; j < (int)(sizeof(sources) / sizeof(sources[0])); j ++) if (!strcmp(sources[j], keyword)) { -- 2.47.3