LCOV - code coverage report
Current view: top level - libs/capy/src_zlib - inflate.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 13.6 % 59 8
Test Date: 2025-12-15 05:33:30 Functions: 15.0 % 20 3

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com)
       3              : // Copyright (c) 2025 Mohammad Nejati
       4              : //
       5              : // Distributed under the Boost Software License, Version 1.0. (See accompanying
       6              : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       7              : //
       8              : // Official repository: https://github.com/cppalliance/capy
       9              : //
      10              : 
      11              : #include <boost/capy/polystore.hpp>
      12              : #include <boost/capy/zlib/inflate.hpp>
      13              : 
      14              : #include "stream_cast.hpp"
      15              : 
      16              : #include <boost/core/detail/static_assert.hpp>
      17              : 
      18              : #include <zlib.h>
      19              : 
      20              : namespace boost {
      21              : namespace capy {
      22              : namespace zlib {
      23              : 
      24              : BOOST_CORE_STATIC_ASSERT(sizeof(stream) == sizeof(z_stream_s));
      25              : BOOST_CORE_STATIC_ASSERT(is_layout_identical<stream, z_stream_s>());
      26              : 
      27              : //------------------------------------------------
      28              : 
      29              : class inflate_service_impl
      30              :     : public inflate_service
      31              : {
      32              : public:
      33              :     using key_type = inflate_service;
      34              : 
      35              :     explicit
      36            1 :     inflate_service_impl(
      37              :         capy::polystore&) noexcept
      38            1 :     {
      39            1 :     }
      40              : 
      41            1 :     ~inflate_service_impl()
      42            1 :     {
      43            1 :     }
      44              : 
      45              :     char const*
      46            0 :     version() const noexcept override
      47              :     {
      48            0 :         return zlibVersion();
      49              :     }
      50              : 
      51              :     int
      52            0 :     init(
      53              :         stream& st) const override
      54              :     {
      55            0 :         stream_cast sc(st);
      56            0 :         return inflateInit(sc.get());
      57              :     }
      58              : 
      59              :     int
      60            0 :     init2(
      61              :         stream& st,
      62              :         int windowBits) const override
      63              :     {
      64            0 :         stream_cast sc(st);
      65            0 :         return inflateInit2(sc.get(), windowBits);
      66              :     }
      67              : 
      68              :     int
      69            0 :     inflate(
      70              :         stream& st,
      71              :         int flush) const override
      72              :     {
      73            0 :         stream_cast sc(st);
      74            0 :         return ::inflate(sc.get(), flush);
      75              :     }
      76              : 
      77              :     int
      78            0 :     inflate_end(
      79              :         stream& st) const override
      80              :     {
      81            0 :         stream_cast sc(st);
      82            0 :         return inflateEnd(sc.get());
      83              :     }
      84              : 
      85              :     int
      86            0 :     set_dict(
      87              :         stream& st,
      88              :         unsigned char const* dict,
      89              :         unsigned len) const override
      90              :     {
      91            0 :         stream_cast sc(st);
      92            0 :         return inflateSetDictionary(sc.get(), dict, len);
      93              :     }
      94              : 
      95              :     int
      96            0 :     get_dict(
      97              :         stream& st,
      98              :         unsigned char* dest,
      99              :         unsigned* len) const override
     100              :     {
     101            0 :         stream_cast sc(st);
     102            0 :         return inflateGetDictionary(sc.get(), dest, len);
     103              :     }
     104              : 
     105              :     int
     106            0 :     sync(
     107              :         stream& st) const override
     108              :     {
     109            0 :         stream_cast sc(st);
     110            0 :         return inflateSync(sc.get());
     111              :     }
     112              : 
     113              :     int
     114            0 :     dup(
     115              :         stream& dest,
     116              :         stream& src) const override
     117              :     {
     118            0 :         stream_cast sc0(dest);
     119            0 :         stream_cast sc1(src);
     120            0 :         return inflateCopy(sc0.get(), sc1.get());
     121              :     }
     122              : 
     123              :     int
     124            0 :     reset(
     125              :         stream& st) const override
     126              :     {
     127            0 :         stream_cast sc(st);
     128            0 :         return inflateReset(sc.get());
     129              :     }
     130              : 
     131              :     int
     132            0 :     reset2(
     133              :         stream& st,
     134              :         int windowBits) const override
     135              :     {
     136            0 :         stream_cast sc(st);
     137            0 :         return inflateReset2(sc.get(), windowBits);
     138              :     }
     139              : 
     140              :     int
     141            0 :     prime(
     142              :         stream& st,
     143              :         int bits,
     144              :         int value) const override
     145              :     {
     146            0 :         stream_cast sc(st);
     147            0 :         return inflatePrime(sc.get(), bits, value);
     148              :     }
     149              : 
     150              :     long
     151            0 :     mark(
     152              :         stream& st) const override
     153              :     {
     154            0 :         stream_cast sc(st);
     155            0 :         return inflateMark(sc.get());
     156              :     }
     157              : 
     158              :     int
     159            0 :     get_header(
     160              :         stream& st,
     161              :         void* header) const override
     162              :     {
     163            0 :         stream_cast sc(st);
     164            0 :         return inflateGetHeader(sc.get(),
     165            0 :             reinterpret_cast<gz_headerp>(header));
     166              :     }
     167              : 
     168              :     int
     169            0 :     back_init(
     170              :         stream& st,
     171              :         int windowBits,
     172              :         unsigned char* window) const override
     173              :     {
     174            0 :         stream_cast sc(st);
     175            0 :         return inflateBackInit(sc.get(), windowBits, window);
     176              :     }
     177              : 
     178              :     int
     179            0 :     back_end(
     180              :         stream& st) const override
     181              :     {
     182            0 :         stream_cast sc(st);
     183            0 :         return inflateBackEnd(sc.get());
     184              :     }
     185              : 
     186              :     unsigned long
     187            0 :     compile_flags() const override
     188              :     {
     189            0 :         return zlibCompileFlags();
     190              :     }
     191              : };
     192              : 
     193              : inflate_service&
     194            1 : install_inflate_service(polystore& ctx)
     195              : {
     196            1 :     return ctx.emplace<inflate_service_impl>(ctx);
     197              : }
     198              : 
     199              : } // zlib
     200              : } // capy
     201              : } // boost
        

Generated by: LCOV version 2.1