| 1 | https://rt.cpan.org/Public/Bug/Display.html?id=78583 |
| 2 | |
| 3 | --- CUPS.xs.orig |
| 4 | +++ CUPS.xs |
| 5 | @@ -5,9 +5,17 @@ |
| 6 | #include "ppport.h" |
| 7 | |
| 8 | #include <cups/cups.h> |
| 9 | +#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5) |
| 10 | +#define HAVE_CUPS_1_6 1 |
| 11 | +#endif |
| 12 | + |
| 13 | /*#include <cups/backend.h>*/ |
| 14 | #include <cups/http.h> |
| 15 | -#include <cups/image.h> |
| 16 | +#ifdef HAVE_CUPS_1_6 |
| 17 | + #include <cupsfilters/image.h> |
| 18 | +#else |
| 19 | + #include <cups/image.h> |
| 20 | +#endif |
| 21 | #include <cups/ipp.h> |
| 22 | #include <cups/ppd.h> |
| 23 | #include <cups/file.h> |
| 24 | @@ -19,6 +27,17 @@ |
| 25 | #include "const-c.inc" |
| 26 | #include "packer.c" |
| 27 | |
| 28 | +#ifndef HAVE_CUPS_1_6 |
| 29 | +#define ippGetGroupTag(attr) attr->group_tag |
| 30 | +#define ippGetName(attr) attr->name |
| 31 | +#define ippGetValueTag(attr) attr->value_tag |
| 32 | +#define ippGetInteger(attr, element) attr->values[element].integer |
| 33 | +#define ippGetString(attr, element, language) attr->values[element].string.text |
| 34 | +#define ippGetStatusCode(ipp) ipp->request.status.status_code |
| 35 | +#define ippFirstAttribute(ipp) ipp->current = ipp->attrs |
| 36 | +#define ippNextAttribute(ipp) ipp->current = ipp->current->next |
| 37 | +#endif |
| 38 | + |
| 39 | static SV *password_cb = (SV*) NULL; |
| 40 | |
| 41 | const char * |
| 42 | @@ -200,7 +219,7 @@ NETCUPS_getPPDMakes() |
| 43 | if (response != NULL) { |
| 44 | attr = ippFindAttribute(response, "ppd-make", IPP_TAG_TEXT); |
| 45 | rv = sv_newmortal(); |
| 46 | - sv_setpv(rv, attr->values[0].string.text); |
| 47 | + sv_setpv(rv, ippGetString(attr, 0, NULL)); |
| 48 | XPUSHs(rv); |
| 49 | count++; |
| 50 | |
| 51 | @@ -211,7 +230,7 @@ NETCUPS_getPPDMakes() |
| 52 | } |
| 53 | |
| 54 | rv = sv_newmortal(); |
| 55 | - sv_setpv(rv, attr->values[0].string.text); |
| 56 | + sv_setpv(rv, ippGetString(attr, 0, NULL)); |
| 57 | XPUSHs(rv); |
| 58 | count++; |
| 59 | } |
| 60 | @@ -252,7 +271,7 @@ NETCUPS_getAllPPDs () |
| 61 | "ppd-make-and-model", |
| 62 | IPP_TAG_TEXT); |
| 63 | rv = sv_newmortal(); |
| 64 | - sv_setpv(rv, attr->values[0].string.text); |
| 65 | + sv_setpv(rv, ippGetString(attr, 0, NULL)); |
| 66 | XPUSHs(rv); |
| 67 | count++; |
| 68 | while (attr != NULL) { |
| 69 | @@ -263,7 +282,7 @@ NETCUPS_getAllPPDs () |
| 70 | break; |
| 71 | } |
| 72 | rv = sv_newmortal(); |
| 73 | - sv_setpv(rv, attr->values[0].string.text); |
| 74 | + sv_setpv(rv, ippGetString(attr, 0, NULL)); |
| 75 | XPUSHs(rv); |
| 76 | count++; |
| 77 | } |
| 78 | @@ -356,14 +375,14 @@ NETCUPS_getPPDFileName(ppdfilename); |
| 79 | if (response != NULL) { |
| 80 | attr = ippFindAttribute(response, "ppd-name", IPP_TAG_NAME ); |
| 81 | while ((attr != NULL) && (i < 1)) { |
| 82 | - tmpppd = attr->values[0].string.text; |
| 83 | + tmpppd = ippGetString(attr, 0, NULL); |
| 84 | attr = ippFindNextAttribute(response, |
| 85 | "ppd-make", |
| 86 | IPP_TAG_TEXT); |
| 87 | attr = ippFindNextAttribute(response, |
| 88 | "ppd-make-and-model", |
| 89 | IPP_TAG_TEXT); |
| 90 | - if (strcmp(attr->values[0].string.text, ppdfilename) == 0 ) { |
| 91 | + if (strcmp(ippGetString(attr, 0, NULL), ppdfilename) == 0 ) { |
| 92 | /* return tmpppd; */ |
| 93 | strcpy(test, tmpppd); |
| 94 | break; |
| 95 | @@ -410,12 +429,12 @@ NETCUPS_getDeviceAttribute( device, attribute, attribute_type ) |
| 96 | attr = ippFindNextAttribute(response, "printer-name", IPP_TAG_NAME); |
| 97 | |
| 98 | while (attr != NULL) { |
| 99 | - if (strcmp(attr->values[0].string.text, device) == 0) { |
| 100 | + if (strcmp(ippGetString(attr, 0, NULL), device) == 0) { |
| 101 | attr = ippFindNextAttribute( response, |
| 102 | attribute, |
| 103 | attribute_type); |
| 104 | rv = sv_newmortal(); |
| 105 | - sv_setpv( rv, attr->values[0].string.text); |
| 106 | + sv_setpv( rv, ippGetString(attr, 0, NULL)); |
| 107 | XPUSHs( rv ); |
| 108 | break; |
| 109 | } |
| 110 | @@ -858,15 +877,15 @@ NETCUPS_getAttributes( ipp ) |
| 111 | SV* rv = NULL; |
| 112 | int count = 0; |
| 113 | ipp_attribute_t* attr = NULL; |
| 114 | - for (attr = ipp->attrs; attr != NULL; attr = attr->next) |
| 115 | + for (attr = ippFirstAttribute(ipp); attr != NULL; attr = ippNextAttribute(ipp)) |
| 116 | { |
| 117 | - while (attr != NULL && attr->group_tag != IPP_TAG_JOB) |
| 118 | - attr = attr->next; |
| 119 | + while (attr != NULL && ippGetGroupTag(attr) != IPP_TAG_JOB) |
| 120 | + attr = ippNextAttribute(ipp); |
| 121 | |
| 122 | if (attr == NULL) |
| 123 | break; |
| 124 | rv = sv_newmortal(); |
| 125 | - sv_setpv( rv, attr->name ); |
| 126 | + sv_setpv( rv, ippGetName(attr) ); |
| 127 | XPUSHs( rv ); |
| 128 | count++; |
| 129 | } |
| 130 | @@ -880,27 +899,27 @@ NETCUPS_getAttributeValue( ipp, name ) |
| 131 | SV* rv = NULL; |
| 132 | int count = 0; |
| 133 | ipp_attribute_t* attr = NULL; |
| 134 | - for (attr = ipp->attrs; attr != NULL; attr = attr->next) |
| 135 | + for (attr = ippFirstAttribute(ipp); attr != NULL; attr = ippNextAttribute(ipp)) |
| 136 | { |
| 137 | - while (attr != NULL && attr->group_tag != IPP_TAG_JOB) |
| 138 | - attr = attr->next; |
| 139 | + while (attr != NULL && ippGetGroupTag(attr) != IPP_TAG_JOB) |
| 140 | + attr = ippNextAttribute(ipp); |
| 141 | |
| 142 | if (attr == NULL) |
| 143 | break; |
| 144 | |
| 145 | - if( !strcmp( attr->name, name ) ) |
| 146 | + if( !strcmp( ippGetName(attr), name ) ) |
| 147 | { |
| 148 | rv = sv_newmortal(); |
| 149 | - if( ( attr->value_tag == IPP_TAG_INTEGER ) || |
| 150 | - ( attr->value_tag == IPP_TAG_ENUM ) ) |
| 151 | + if( ( ippGetValueTag(attr) == IPP_TAG_INTEGER ) || |
| 152 | + ( ippGetValueTag(attr) == IPP_TAG_ENUM ) ) |
| 153 | { |
| 154 | /* We have a number with any luck ... */ |
| 155 | - sv_setiv( rv, attr->values[0].integer ); |
| 156 | + sv_setiv( rv, ippGetInteger(attr, 0) ); |
| 157 | } |
| 158 | else |
| 159 | { |
| 160 | /* We have a string ... maybe ... try to set it. */ |
| 161 | - sv_setpv( rv, attr->values[0].string.text ); |
| 162 | + sv_setpv( rv, ippGetString(attr, 0, NULL) ); |
| 163 | } |
| 164 | |
| 165 | XPUSHs( rv ); |