MCPcopy Create free account
hub / github.com/OpenPrinting/cups / ipp_length

Function ipp_length

cups/ipp.c:5683–5838  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5681 */
5682
5683static size_t /* O - Size of IPP message */
5684ipp_length(ipp_t *ipp, /* I - IPP message or collection */
5685 int collection) /* I - 1 if a collection, 0 otherwise */
5686{
5687 int i; /* Looping var */
5688 size_t bytes; /* Number of bytes */
5689 ipp_attribute_t *attr; /* Current attribute */
5690 ipp_tag_t group; /* Current group */
5691 _ipp_value_t *value; /* Current value */
5692
5693
5694 DEBUG_printf(("3ipp_length(ipp=%p, collection=%d)", (void *)ipp, collection));
5695
5696 if (!ipp)
5697 {
5698 DEBUG_puts("4ipp_length: Returning 0 bytes");
5699 return (0);
5700 }
5701
5702 /*
5703 * Start with 8 bytes for the IPP message header...
5704 */
5705
5706 bytes = collection ? 0 : 8;
5707
5708 /*
5709 * Then add the lengths of each attribute...
5710 */
5711
5712 group = IPP_TAG_ZERO;
5713
5714 for (attr = ipp->attrs; attr != NULL; attr = attr->next)
5715 {
5716 if (attr->group_tag != group && !collection)
5717 {
5718 group = attr->group_tag;
5719 if (group == IPP_TAG_ZERO)
5720 continue;
5721
5722 bytes ++; /* Group tag */
5723 }
5724
5725 if (!attr->name)
5726 continue;
5727
5728 DEBUG_printf(("5ipp_length: attr->name=\"%s\", attr->num_values=%d, "
5729 "bytes=" CUPS_LLFMT, attr->name, attr->num_values, CUPS_LLCAST bytes));
5730
5731 if ((attr->value_tag & ~IPP_TAG_CUPS_CONST) < IPP_TAG_EXTENSION)
5732 bytes += (size_t)attr->num_values;/* Value tag for each value */
5733 else
5734 bytes += (size_t)(5 * attr->num_values);
5735 /* Value tag for each value */
5736 bytes += (size_t)(2 * attr->num_values);
5737 /* Name lengths */
5738 bytes += strlen(attr->name); /* Name */
5739 bytes += (size_t)(2 * attr->num_values);
5740 /* Value lengths */

Callers 1

ippLengthFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected