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

Function unzip_read_block

src/burp/mvol.cpp:426–490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

424//
425
426static ULONG unzip_read_block(BurpGlobals* tdgbl, UCHAR* buffer, FB_SIZE_T buffer_length)
427{
428 if (!tdgbl->gbl_sw_zip)
429 {
430 return crypt_read_block(tdgbl, buffer, buffer_length);
431 }
432
433#ifdef HAVE_ZLIB_H
434 z_stream& strm = tdgbl->gbl_stream;
435 strm.avail_out = buffer_length;
436 strm.next_out = buffer;
437
438 for (;;)
439 {
440 if (strm.avail_in)
441 {
442#ifdef COMPRESS_DEBUG
443 fprintf(stderr, "Data to inflate %d port %p\n", strm.avail_in, port);
444#if COMPRESS_DEBUG > 1
445 for (unsigned n = 0; n < strm.avail_in; ++n) fprintf(stderr, "%02x ", strm.next_in[n]);
446 fprintf(stderr, "\n");
447#endif
448#endif
449 ULONG wasAvail = strm.avail_out;
450 int ret = zlib().inflate(&strm, Z_NO_FLUSH);
451 if (ret == Z_DATA_ERROR && wasAvail != strm.avail_out)
452 ret = Z_OK;
453
454 if (ret != Z_OK)
455 {
456#ifdef COMPRESS_DEBUG
457 fprintf(stderr, "Inflate error %d\n", ret);
458#endif
459 BURP_error(379, true, SafeArg() << ret);
460 }
461#ifdef COMPRESS_DEBUG
462 fprintf(stderr, "Inflated data %d\n", buffer_length - strm.avail_out);
463#if COMPRESS_DEBUG > 1
464 for (unsigned n = 0; n < buffer_length - strm.avail_out; ++n) fprintf(stderr, "%02x ", buffer[n]);
465 fprintf(stderr, "\n");
466#endif
467#endif
468 if (strm.next_out != buffer)
469 break;
470
471 UCHAR* compressed = tdgbl->gbl_decompress;
472 if (strm.next_in != compressed)
473 {
474 memmove(compressed, strm.next_in, strm.avail_in);
475 strm.next_in = compressed;
476 }
477 }
478 else
479 strm.next_in = tdgbl->gbl_decompress;
480
481 ULONG l = ZC_BUFSIZE - strm.avail_in;
482 l = crypt_read_block(tdgbl, strm.next_in, l);
483 strm.avail_in += l;

Callers 1

MVOL_readFunction · 0.85

Calls 5

crypt_read_blockFunction · 0.85
BURP_errorFunction · 0.85
GdsClass · 0.85
SafeArgClass · 0.50
raiseMethod · 0.45

Tested by

no test coverage detected