MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / REMOTE_inflate

Function REMOTE_inflate

src/remote/remote.cpp:1551–1641  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1549}
1550
1551bool REMOTE_inflate(rem_port* port, PacketReceive* packet_receive, UCHAR* buffer,
1552 SSHORT buffer_length, SSHORT* length)
1553{
1554#ifdef WIRE_COMPRESS_SUPPORT
1555 if (!port->port_compressed)
1556 {
1557 const bool ret = packet_receive(port, buffer, buffer_length, length);
1558 if (ret)
1559 port->bumpLogBytes(rem_port::RECEIVE, *length);
1560 return ret;
1561 }
1562
1563 z_stream& strm = port->port_recv_stream;
1564 strm.avail_out = buffer_length;
1565 strm.next_out = buffer;
1566
1567 for (;;)
1568 {
1569 if (strm.avail_in)
1570 {
1571#ifdef COMPRESS_DEBUG
1572 fprintf(stderr, "Data to inflate %d port %p\n", strm.avail_in, port);
1573#if COMPRESS_DEBUG > 1
1574 for (unsigned n = 0; n < strm.avail_in; ++n) fprintf(stderr, "%02x ", strm.next_in[n]);
1575 fprintf(stderr, "\n");
1576#endif
1577#endif
1578
1579 if (zlib().inflate(&strm, Z_NO_FLUSH) != Z_OK)
1580 {
1581#ifdef COMPRESS_DEBUG
1582 fprintf(stderr, "Inflate error\n");
1583#endif
1584 port->port_z_data = false;
1585 return false;
1586 }
1587#ifdef COMPRESS_DEBUG
1588 fprintf(stderr, "Inflated data %d\n", buffer_length - strm.avail_out);
1589#if COMPRESS_DEBUG > 1
1590 for (unsigned n = 0; n < buffer_length - strm.avail_out; ++n) fprintf(stderr, "%02x ", buffer[n]);
1591 fprintf(stderr, "\n");
1592#endif
1593#endif
1594 if (strm.next_out != buffer)
1595 break;
1596
1597 if (port->port_z_data) // Was called from select_multi() but nothing decompressed
1598 {
1599 port->port_z_data = false;
1600 return false;
1601 }
1602
1603 UCHAR* compressed = &port->port_compressed[REM_RECV_OFFSET(port->port_buff_size)];
1604 if (strm.next_in != compressed)
1605 {
1606 memmove(compressed, strm.next_in, strm.avail_in);
1607 strm.next_in = compressed;
1608 }

Callers 2

select_multiFunction · 0.85
inet_readFunction · 0.85

Calls 2

packet_receiveFunction · 0.85
bumpLogBytesMethod · 0.80

Tested by

no test coverage detected