| 1500 | */ |
| 1501 | |
| 1502 | static size_t /* O - Number of bytes needed */ |
| 1503 | cups_collection_string( |
| 1504 | ipp_attribute_t *attr, /* I - Collection attribute */ |
| 1505 | char *buffer, /* I - String buffer */ |
| 1506 | size_t bufsize) /* I - Size of buffer */ |
| 1507 | { |
| 1508 | int i, j, /* Looping vars */ |
| 1509 | count, /* Number of collection values */ |
| 1510 | mcount; /* Number of member values */ |
| 1511 | ipp_t *col; /* Collection */ |
| 1512 | ipp_attribute_t *first, /* First member attribute */ |
| 1513 | *member; /* Member attribute */ |
| 1514 | char *bufptr, /* Pointer into buffer */ |
| 1515 | *bufend, /* End of buffer */ |
| 1516 | temp[100]; /* Temporary string */ |
| 1517 | const char *mptr; /* Pointer into member value */ |
| 1518 | int mlen; /* Length of octetString */ |
| 1519 | |
| 1520 | |
| 1521 | bufptr = buffer; |
| 1522 | bufend = buffer + bufsize - 1; |
| 1523 | |
| 1524 | for (i = 0, count = ippGetCount(attr); i < count; i ++) |
| 1525 | { |
| 1526 | col = ippGetCollection(attr, i); |
| 1527 | |
| 1528 | if (i) |
| 1529 | { |
| 1530 | if (bufptr < bufend) |
| 1531 | *bufptr++ = ','; |
| 1532 | else |
| 1533 | bufptr ++; |
| 1534 | } |
| 1535 | |
| 1536 | if (bufptr < bufend) |
| 1537 | *bufptr++ = '{'; |
| 1538 | else |
| 1539 | bufptr ++; |
| 1540 | |
| 1541 | for (member = first = ippFirstAttribute(col); member; member = ippNextAttribute(col)) |
| 1542 | { |
| 1543 | const char *mname = ippGetName(member); |
| 1544 | |
| 1545 | if (member != first) |
| 1546 | { |
| 1547 | if (bufptr < bufend) |
| 1548 | *bufptr++ = ' '; |
| 1549 | else |
| 1550 | bufptr ++; |
| 1551 | } |
| 1552 | |
| 1553 | if (ippGetValueTag(member) == IPP_TAG_BOOLEAN) |
| 1554 | { |
| 1555 | if (!ippGetBoolean(member, 0)) |
| 1556 | { |
| 1557 | if (bufptr < bufend) |
| 1558 | strlcpy(bufptr, "no", (size_t)(bufend - bufptr + 1)); |
| 1559 | bufptr += 2; |
no test coverage detected