diff -up hplip-3.12.6/scan/sane/hpaio.c.ipp_accessors hplip-3.12.6/scan/sane/hpaio.c --- hplip-3.12.6/scan/sane/hpaio.c.ipp_accessors 2012-06-18 12:42:51.000000000 +0200 +++ hplip-3.12.6/scan/sane/hpaio.c 2012-07-19 17:12:34.557848760 +0200 @@ -47,6 +47,43 @@ #define DEBUG_DECLARE_ONLY #include "sanei_debug.h" +#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5) +#define HAVE_CUPS_1_6 1 +#endif + +#ifndef HAVE_CUPS_1_6 +#define ippGetGroupTag(attr) attr->group_tag +#define ippGetValueTag(attr) attr->value_tag +#define ippGetName(attr) attr->name +#define ippGetString(attr, element, language) attr->values[element].string.text + +static ipp_attribute_t * ippFirstAttribute( ipp_t *ipp ) +{ + if (!ipp) + return (NULL); + return (ipp->current = ipp->attrs); +} + +static ipp_attribute_t * ippNextAttribute( ipp_t *ipp ) +{ + if (!ipp || !ipp->current) + return (NULL); + return (ipp->current = ipp->current->next); +} + +static int ippSetOperation( ipp_t *ipp, ipp_op_t op ) +{ + ipp->request.op.operation_id = op; + return (1); +} + +static int ippSetRequestId( ipp_t *ipp, int request_id ) +{ + ipp->request.any.request_id = request_id; + return (1); +} +#endif + static SANE_Device **DeviceList = NULL; static int AddDeviceList(char *uri, char *model, SANE_Device ***pd) @@ -186,8 +223,8 @@ static int GetCupsPrinters(char ***print /* Assemble the IPP request */ request = ippNew(); - request->request.op.operation_id = CUPS_GET_PRINTERS; - request->request.any.request_id = 1; + ippSetOperation( request, CUPS_GET_PRINTERS ); + ippSetRequestId( request, 1 ); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, "attributes-charset", NULL, "utf-8"); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, "en"); @@ -197,20 +234,20 @@ static int GetCupsPrinters(char ***print if ((response = cupsDoRequest(http, request, "/")) == NULL) goto bugout; - for (attr = response->attrs; attr != NULL; attr = attr->next) + for (attr = ippFirstAttribute ( response ); attr != NULL; attr = ippNextAttribute( response )) { /* Skip leading attributes until we hit a printer. */ - while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER) - attr = attr->next; + while (attr != NULL && ippGetGroupTag( attr ) != IPP_TAG_PRINTER) + attr = ippNextAttribute( response ); if (attr == NULL) break; - while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER) + while (attr != NULL && ippGetGroupTag( attr ) == IPP_TAG_PRINTER) { - if (strcmp(attr->name, "device-uri") == 0 && attr->value_tag == IPP_TAG_URI && AddCupsList(attr->values[0].string.text, printer) == 0) + if (strcmp(ippGetName( attr ), "device-uri") == 0 && ippGetValueTag( attr ) == IPP_TAG_URI && AddCupsList(ippGetString( attr, 0, NULL ), printer) == 0) cnt++; - attr = attr->next; + attr = ippNextAttribute( response ); } if (attr == NULL)