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

Function zip_write_block

src/burp/mvol.cpp:492–555  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

490}
491
492static void zip_write_block(BurpGlobals* tdgbl, const UCHAR* buffer, FB_SIZE_T buffer_length, bool flash)
493{
494 if (!tdgbl->gbl_sw_zip)
495 {
496 crypt_write_block(tdgbl, buffer, buffer_length, flash);
497 return;
498 }
499
500#ifdef HAVE_ZLIB_H
501 z_stream& strm = tdgbl->gbl_stream;
502 strm.avail_in = buffer_length;
503 strm.next_in = (Bytef*)buffer;
504 UCHAR* compressed = tdgbl->gbl_decompress;
505
506 if (!strm.next_out)
507 {
508 strm.avail_out = ZC_BUFSIZE;
509 strm.next_out = (Bytef*)compressed;
510 }
511
512 bool expectMoreOut = flash;
513
514 while (strm.avail_in || expectMoreOut)
515 {
516#ifdef COMPRESS_DEBUG
517 fprintf(stderr, "Data to deflate %d port %p\n", strm.avail_in, port);
518#if COMPRESS_DEBUG>1
519 for (unsigned n = 0; n < strm.avail_in; ++n) fprintf(stderr, "%02x ", strm.next_in[n]);
520 fprintf(stderr, "\n");
521#endif
522#endif
523 int ret = zlib().deflate(&strm, flash ? Z_FULL_FLUSH : Z_NO_FLUSH);
524 if (ret == Z_BUF_ERROR)
525 ret = 0;
526 if (ret != 0)
527 {
528#ifdef COMPRESS_DEBUG
529 fprintf(stderr, "Deflate error %d\n", ret);
530#endif
531 BURP_error(380, true, SafeArg() << ret);
532 }
533
534#ifdef COMPRESS_DEBUG
535 fprintf(stderr, "Deflated data %d\n", ZC_BUFSIZE - strm.avail_out);
536#if COMPRESS_DEBUG>1
537 for (unsigned n = 0; n < port->port_buff_size - strm.avail_out; ++n)
538 fprintf(stderr, "%02x ", compressed[n]);
539 fprintf(stderr, "\n");
540#endif
541#endif
542
543 expectMoreOut = !strm.avail_out;
544 if ((ZC_BUFSIZE != strm.avail_out) && (flash || !strm.avail_out))
545 {
546 crypt_write_block(tdgbl, compressed, ZC_BUFSIZE - strm.avail_out, flash);
547
548 strm.avail_out = ZC_BUFSIZE;
549 strm.next_out = (Bytef*)compressed;

Callers 3

MVOL_fini_writeFunction · 0.85
MVOL_writeFunction · 0.85
MVOL_write_blockFunction · 0.85

Calls 5

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

Tested by

no test coverage detected