29 | 29 |
#ifndef HAVE_CUPS_1_6
|
30 | 30 |
#define ippGetGroupTag(attr) attr->group_tag
|
31 | 31 |
#define ippGetName(attr) attr->name
|
|
32 |
#define ippGetCount(attr) attr->num_values
|
32 | 33 |
#define ippGetValueTag(attr) attr->value_tag
|
33 | 34 |
#define ippGetInteger(attr, element) attr->values[element].integer
|
|
35 |
#define ippGetBoolean(attr, element) attr->values[element].boolean
|
34 | 36 |
#define ippGetString(attr, element, language) attr->values[element].string.text
|
35 | 37 |
#define ippGetStatusCode(ipp) ipp->request.status.status_code
|
36 | 38 |
#define ippFirstAttribute(ipp) ipp->current = ipp->attrs
|
|
450 | 452 |
request = ippNewRequest (CUPS_GET_PRINTERS);
|
451 | 453 |
|
452 | 454 |
if ((response = cupsDoRequest (http, request, "/")) != NULL) {
|
453 | |
attr = ippFindNextAttribute(response, "printer-name", IPP_TAG_NAME);
|
454 | |
|
455 | |
while (attr != NULL) {
|
456 | |
if (strcmp(ippGetString(attr, 0, NULL), device) == 0) {
|
457 | |
attr = ippFindNextAttribute( response,
|
458 | |
attribute,
|
459 | |
attribute_type);
|
460 | |
rv = sv_newmortal();
|
461 | |
sv_setpv( rv, ippGetString(attr, 0, NULL));
|
462 | |
XPUSHs( rv );
|
463 | |
break;
|
464 | |
}
|
465 | |
attr = ippFindNextAttribute( response,
|
466 | |
"printer-name",
|
467 | |
IPP_TAG_NAME);
|
468 | |
if (attr == NULL) {
|
469 | |
break;
|
470 | |
}
|
|
455 |
rv = sv_newmortal();
|
|
456 |
int match = 0;
|
|
457 |
for (attr = ippFirstAttribute(response); attr != NULL; attr = ippNextAttribute(response)) {
|
|
458 |
if (ippGetName(attr) == NULL) {
|
|
459 |
if (match) break; else continue;
|
|
460 |
}
|
|
461 |
if (!strcmp(ippGetName(attr), "printer-name") && ippGetValueTag(attr) == IPP_TAG_NAME) {
|
|
462 |
match = !strcmp(ippGetString(attr, 0, NULL), device);
|
|
463 |
} else if (!strcmp(ippGetName(attr), attribute) && ippGetValueTag(attr) == attribute_type) {
|
|
464 |
if (ippGetCount(attr) == 1) {
|
|
465 |
switch (attribute_type) {
|
|
466 |
case IPP_TAG_TEXT:
|
|
467 |
case IPP_TAG_NAME:
|
|
468 |
case IPP_TAG_KEYWORD:
|
|
469 |
case IPP_TAG_URI:
|
|
470 |
case IPP_TAG_CHARSET:
|
|
471 |
case IPP_TAG_LANGUAGE:
|
|
472 |
sv_setpv(rv, ippGetString(attr, 0, NULL));
|
|
473 |
break;
|
|
474 |
case IPP_TAG_BOOLEAN:
|
|
475 |
sv_setiv(rv, ippGetBoolean(attr, 0));
|
|
476 |
break;
|
|
477 |
case IPP_TAG_INTEGER:
|
|
478 |
case IPP_TAG_ENUM:
|
|
479 |
sv_setiv(rv, ippGetInteger(attr, 0));
|
|
480 |
break;
|
|
481 |
}
|
|
482 |
} else {
|
|
483 |
/* XXX */
|
|
484 |
}
|
|
485 |
}
|
471 | 486 |
}
|
|
487 |
if (match) XPUSHs(rv);
|
472 | 488 |
}
|
473 | 489 |
ippDelete( response );
|
474 | 490 |
httpClose( http );
|