| 6401 | */ |
| 6402 | |
| 6403 | static int /* O - 1 on match, 0 on non-match */ |
| 6404 | with_value_from( |
| 6405 | cups_array_t *errors, /* I - Errors array */ |
| 6406 | ipp_attribute_t *fromattr, /* I - "From" attribute */ |
| 6407 | ipp_attribute_t *attr, /* I - Attribute to compare */ |
| 6408 | char *matchbuf, /* I - Buffer to hold matching value */ |
| 6409 | size_t matchlen) /* I - Length of match buffer */ |
| 6410 | { |
| 6411 | int i, j, /* Looping vars */ |
| 6412 | count = ippGetCount(attr), /* Number of attribute values */ |
| 6413 | match = 1; /* Match? */ |
| 6414 | |
| 6415 | |
| 6416 | *matchbuf = '\0'; |
| 6417 | |
| 6418 | /* |
| 6419 | * Compare the from value(s) to the attribute value(s)... |
| 6420 | */ |
| 6421 | |
| 6422 | switch (ippGetValueTag(attr)) |
| 6423 | { |
| 6424 | case IPP_TAG_INTEGER : |
| 6425 | if (ippGetValueTag(fromattr) != IPP_TAG_INTEGER && ippGetValueTag(fromattr) != IPP_TAG_RANGE) |
| 6426 | goto wrong_value_tag; |
| 6427 | |
| 6428 | for (i = 0; i < count; i ++) |
| 6429 | { |
| 6430 | int value = ippGetInteger(attr, i); |
| 6431 | /* Current integer value */ |
| 6432 | |
| 6433 | if (ippContainsInteger(fromattr, value)) |
| 6434 | { |
| 6435 | if (!matchbuf[0]) |
| 6436 | snprintf(matchbuf, matchlen, "%d", value); |
| 6437 | } |
| 6438 | else |
| 6439 | { |
| 6440 | add_stringf(errors, "GOT: %s=%d", ippGetName(attr), value); |
| 6441 | match = 0; |
| 6442 | } |
| 6443 | } |
| 6444 | break; |
| 6445 | |
| 6446 | case IPP_TAG_ENUM : |
| 6447 | if (ippGetValueTag(fromattr) != IPP_TAG_ENUM) |
| 6448 | goto wrong_value_tag; |
| 6449 | |
| 6450 | for (i = 0; i < count; i ++) |
| 6451 | { |
| 6452 | int value = ippGetInteger(attr, i); |
| 6453 | /* Current integer value */ |
| 6454 | |
| 6455 | if (ippContainsInteger(fromattr, value)) |
| 6456 | { |
| 6457 | if (!matchbuf[0]) |
| 6458 | snprintf(matchbuf, matchlen, "%d", value); |
| 6459 | } |
| 6460 | else |
no test coverage detected