From: mike Date: Tue, 11 Dec 2012 20:01:35 +0000 (+0000) Subject: Generate full 1284 device ID as needed (STR #3702) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e69689e102747ea8c4a29352523d07b1eee6829;p=thirdparty%2Fcups.git Generate full 1284 device ID as needed (STR #3702) git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10748 7a7537e8-13f0-0310-91df-b6672ffda945 --- diff --git a/CHANGES.txt b/CHANGES.txt index 3f46641592..38f8edf70a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,4 @@ -CHANGES.txt - 1.7b1 - 2012-11-15 +CHANGES.txt - 1.7b1 - 2012-12-11 -------------------------------- CHANGES IN CUPS V1.7b1 @@ -6,6 +6,7 @@ CHANGES IN CUPS V1.7b1 - Added new IPP APIs for checking values (STR #4167) - Added new IPP APis for adding and setting formatted strings. - Added new HTTP APIs to support basic server functionality via libcups. + - The dnssd backend now generates a 1284 device ID as needed (STR #3702) - CUPS now supports compressing and decompressing streamed data (STR #4168) - CUPS now supports higher-level PIN printing, external accounting diff --git a/backend/dnssd.c b/backend/dnssd.c index 46c0f13471..9cea92e037 100644 --- a/backend/dnssd.c +++ b/backend/dnssd.c @@ -1031,6 +1031,7 @@ query_callback( value[256], /* Value string */ make_and_model[512], /* Manufacturer and model */ model[256], /* Model */ + pdl[256], /* PDL */ device_id[2048]; /* 1284 device ID */ @@ -1079,6 +1080,7 @@ query_callback( device_id[0] = '\0'; make_and_model[0] = '\0'; + pdl[0] = '\0'; strlcpy(model, "Unknown", sizeof(model)); @@ -1160,6 +1162,8 @@ query_callback( if ((ptr = strchr(model, ',')) != NULL) *ptr = '\0'; } + else if (!_cups_strcasecmp(key, "pdl")) + strlcpy(pdl, value, sizeof(pdl)); else if (!_cups_strcasecmp(key, "priority")) device->priority = atoi(value); else if ((device->type == CUPS_DEVICE_IPP || @@ -1204,6 +1208,46 @@ query_callback( } } + if (device_id[0] && + !strstr(device_id, "CMD:") && + !strstr(device_id, "COMMAND SET:") && + (strstr(pdl, "application/pdf") || + strstr(pdl, "application/postscript") || + strstr(pdl, "application/vnd.hp-PCL") || + strstr(pdl, "image/"))) + { + value[0] = '\0'; + if (strstr(pdl, "application/pdf")) + strlcat(value, ",PDF", sizeof(value)); + if (strstr(pdl, "application/postscript")) + strlcat(value, ",PS", sizeof(value)); + if (strstr(pdl, "application/vnd.hp-PCL")) + strlcat(value, ",PCL", sizeof(value)); + for (ptr = strstr(pdl, "image/"); ptr; ptr = strstr(ptr, "image/")) + { + char *valptr = value + strlen(value); + /* Pointer into value */ + + if (valptr < (value + sizeof(value) - 1)) + *valptr++ = ','; + + ptr += 6; + while (isalnum(*ptr & 255) || *ptr == '-' || *ptr == '.') + { + if (isalnum(*ptr & 255) && valptr < (value + sizeof(value) - 1)) + *valptr++ = toupper(*ptr++ & 255); + else + break; + } + + *valptr = '\0'; + } + + ptr = device_id + strlen(device_id); + snprintf(ptr, sizeof(device_id) - (ptr - device_id), "CMD:%s;", + value + 1); + } + if (device_id[0]) device->device_id = strdup(device_id); else