| 1607 | |
| 1608 | |
| 1609 | static bool_t xdr_packed_message( RemoteXdr* xdrs, RMessage* message, const rem_fmt* format) |
| 1610 | { |
| 1611 | /************************************** |
| 1612 | * |
| 1613 | * x d r _ p a c k e d _ m e s s a g e |
| 1614 | * |
| 1615 | ************************************** |
| 1616 | * |
| 1617 | * Functional description |
| 1618 | * Map a formatted message. |
| 1619 | * |
| 1620 | **************************************/ |
| 1621 | |
| 1622 | if (xdrs->x_op == XDR_FREE) |
| 1623 | return TRUE; |
| 1624 | |
| 1625 | const rem_port* const port = xdrs->x_public; |
| 1626 | |
| 1627 | if (!message || !format) |
| 1628 | return FALSE; |
| 1629 | |
| 1630 | // If we are running a symmetric version of the protocol, just slop |
| 1631 | // the bits and don't sweat the translations |
| 1632 | |
| 1633 | if (port->port_flags & PORT_symmetric) |
| 1634 | return xdr_opaque(xdrs, reinterpret_cast<SCHAR*>(message->msg_address), format->fmt_length); |
| 1635 | |
| 1636 | // Optimize the message by transforming NULL indicators into a bitmap |
| 1637 | // and then skipping the NULL items |
| 1638 | |
| 1639 | class NullBitmap : private HalfStaticArray<UCHAR, 4> |
| 1640 | { |
| 1641 | public: |
| 1642 | explicit NullBitmap(USHORT size) |
| 1643 | { |
| 1644 | resize(size); |
| 1645 | } |
| 1646 | |
| 1647 | void setNull(USHORT id) |
| 1648 | { |
| 1649 | data[id >> 3] |= (1 << (id & 7)); |
| 1650 | } |
| 1651 | |
| 1652 | bool isNull(USHORT id) const |
| 1653 | { |
| 1654 | return data[id >> 3] & (1 << (id & 7)); |
| 1655 | } |
| 1656 | |
| 1657 | UCHAR* getData() |
| 1658 | { |
| 1659 | return data; |
| 1660 | } |
| 1661 | }; |
| 1662 | |
| 1663 | fb_assert(format->fmt_desc.getCount() % 2 == 0); |
| 1664 | const USHORT flagBytes = (format->fmt_desc.getCount() / 2 + 7) / 8; |
| 1665 | NullBitmap nulls(flagBytes); |
| 1666 |
no test coverage detected